12 Commits
0.5.2 ... 0.5.7

Author SHA1 Message Date
96e13d85fc Bump version
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-10-19 13:59:14 -05:00
5a9283ad85 orm(PostgreSQLDialect): double-quote column names in INSERT field lists 2021-10-19 13:59:00 -05:00
b1ea489ccb Bump version
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-10-19 13:00:27 -05:00
c3f2779650 Add generic to APIResponse 2021-10-19 13:00:14 -05:00
248b24e612 Bump version
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-10-19 10:26:47 -05:00
b4a9057e2b CLI invocation output better debugging infor 2021-10-19 10:26:32 -05:00
c078d695a8 Bump version
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-10-18 17:23:30 -05:00
55ffadc742 Export CLI decorators
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-18 17:23:16 -05:00
56574d43ce Bump version
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
continuous-integration/drone Build is passing
2021-10-18 14:57:44 -05:00
e16f02ce12 Readd migrations
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-18 14:49:19 -05:00
c34fad3502 Fix path in drone docs deploy
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
2021-10-18 14:02:00 -05:00
156006053b Fix path in drone static deploy
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone Build is failing
2021-10-18 13:53:37 -05:00
8 changed files with 99 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ steps:
from_secret: docs_deploy_key from_secret: docs_deploy_key
port: 22 port: 22
source: extollo_api_documentation.tar.gz source: extollo_api_documentation.tar.gz
target: /var/nfs/general/static/sites/extollo target: /var/nfs/storage/static/sites/extollo
when: when:
event: promote event: promote
target: docs target: docs
@@ -38,7 +38,7 @@ steps:
from_secret: docs_deploy_key from_secret: docs_deploy_key
port: 22 port: 22
script: script:
- cd /var/nfs/general/static/sites/extollo - cd /var/nfs/storage/static/sites/extollo
- rm -rf docs - rm -rf docs
- tar xzf extollo_api_documentation.tar.gz - tar xzf extollo_api_documentation.tar.gz
- rm -rf extollo_api_documentation.tar.gz - rm -rf extollo_api_documentation.tar.gz

View File

@@ -1,6 +1,6 @@
{ {
"name": "@extollo/lib", "name": "@extollo/lib",
"version": "0.5.2", "version": "0.5.7",
"description": "The framework library that lifts up your code.", "description": "The framework library that lifts up your code.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -172,6 +172,7 @@ export abstract class Directive extends AppClass {
} catch (e: unknown) { } catch (e: unknown) {
if ( e instanceof Error ) { if ( e instanceof Error ) {
this.nativeOutput(e.message) this.nativeOutput(e.message)
this.error(e)
} }
if ( e instanceof OptionValidationError ) { if ( e instanceof OptionValidationError ) {

View File

@@ -11,3 +11,5 @@ export * from './directive/options/PositionalOption'
export * from './directive/ShellDirective' export * from './directive/ShellDirective'
export * from './directive/TemplateDirective' export * from './directive/TemplateDirective'
export * from './directive/UsageDirective' export * from './directive/UsageDirective'
export * from './decorators'

View File

@@ -1,10 +1,10 @@
/** /**
* Base type for an API response format. * Base type for an API response format.
*/ */
export interface APIResponse { export interface APIResponse<T> {
success: boolean, success: boolean,
message?: string, message?: string,
data?: any, data?: T,
error?: { error?: {
name: string, name: string,
message: string, message: string,
@@ -17,7 +17,7 @@ export interface APIResponse {
* @param {string} displayMessage * @param {string} displayMessage
* @return APIResponse * @return APIResponse
*/ */
export function message(displayMessage: string): APIResponse { export function message(displayMessage: string): APIResponse<void> {
return { return {
success: true, success: true,
message: displayMessage, message: displayMessage,
@@ -29,7 +29,7 @@ export function message(displayMessage: string): APIResponse {
* @param record * @param record
* @return APIResponse * @return APIResponse
*/ */
export function one(record: unknown): APIResponse { export function one<T>(record: T): APIResponse<T> {
return { return {
success: true, success: true,
data: record, data: record,
@@ -41,7 +41,7 @@ export function one(record: unknown): APIResponse {
* @param {array} records * @param {array} records
* @return APIResponse * @return APIResponse
*/ */
export function many(records: any[]): APIResponse { export function many<T>(records: T[]): APIResponse<{records: T[], total: number}> {
return { return {
success: true, success: true,
data: { data: {
@@ -56,7 +56,7 @@ export function many(records: any[]): APIResponse {
* @return APIResponse * @return APIResponse
* @param thrownError * @param thrownError
*/ */
export function error(thrownError: string | Error): APIResponse { export function error(thrownError: string | Error): APIResponse<void> {
if ( typeof thrownError === 'string' ) { if ( typeof thrownError === 'string' ) {
return { return {
success: false, success: false,

View File

@@ -0,0 +1,39 @@
import {Inject, Injectable} from '../di'
import {ConstraintType, DatabaseService, FieldType, Migration, Schema} from '../orm'
/**
* Migration that creates the sessions table used by the ORMSession backend.
*/
@Injectable()
export default class CreateSessionsTableMigration extends Migration {
@Inject()
protected readonly db!: DatabaseService
async up(): Promise<void> {
const schema: Schema = this.db.get().schema()
const table = await schema.table('sessions')
table.primaryKey('session_uuid', FieldType.varchar)
.required()
table.column('session_data')
.type(FieldType.json)
.required()
.default('{}')
table.constraint('session_uuid_ck')
.type(ConstraintType.Check)
.expression('LENGTH(session_uuid) > 0')
await schema.commit(table)
}
async down(): Promise<void> {
const schema: Schema = this.db.get().schema()
const table = await schema.table('sessions')
table.dropIfExists()
await schema.commit(table)
}
}

View File

@@ -0,0 +1,47 @@
import {Inject, Injectable} from '../di'
import {DatabaseService, FieldType, Migration, Schema} from '../orm'
/**
* Migration that creates the users table used by @extollo/lib.auth.
*/
@Injectable()
export default class CreateUsersTableMigration extends Migration {
@Inject()
protected readonly db!: DatabaseService
async up(): Promise<void> {
const schema: Schema = this.db.get().schema()
const table = await schema.table('users')
table.primaryKey('user_id')
.required()
table.column('first_name')
.type(FieldType.varchar)
.nullable()
table.column('last_name')
.type(FieldType.varchar)
.nullable()
table.column('password_hash')
.type(FieldType.text)
.nullable()
table.column('username')
.type(FieldType.varchar)
.required()
.unique()
await schema.commit(table)
}
async down(): Promise<void> {
const schema: Schema = this.db.get().schema()
const table = await schema.table('users')
table.dropIfExists()
await schema.commit(table)
}
}

View File

@@ -230,7 +230,7 @@ export class PostgreSQLDialect extends SQLDialect {
const table: string = tableString.split('.').map(x => `"${x}"`) const table: string = tableString.split('.').map(x => `"${x}"`)
.join('.') .join('.')
queryLines.push('INSERT INTO ' + (typeof source === 'string' ? table : `${table} AS "${source.alias}"`) queryLines.push('INSERT INTO ' + (typeof source === 'string' ? table : `${table} AS "${source.alias}"`)
+ (columns.length ? ` (${columns.join(', ')})` : '')) + (columns.length ? ` (${columns.map(x => `"${x}"`).join(', ')})` : ''))
} }
if ( Array.isArray(data) && !data.length ) { if ( Array.isArray(data) && !data.length ) {