@creator.co/wapi 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +4 -2
- package/dist/index.d.ts +14 -14
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/package-lock.json +2676 -454
- package/dist/package.json +2 -1
- package/dist/src/API/Request.d.ts +1 -1
- package/dist/src/API/Request.js +1 -1
- package/dist/src/API/Request.js.map +1 -1
- package/dist/src/API/Response.d.ts +1 -1
- package/dist/src/API/Response.js +1 -1
- package/dist/src/API/Response.js.map +1 -1
- package/dist/src/BaseEvent/EventProcessor.d.ts +2 -2
- package/dist/src/BaseEvent/EventProcessor.js +3 -3
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
- package/dist/src/BaseEvent/Process.d.ts +3 -3
- package/dist/src/BaseEvent/Process.js +2 -2
- package/dist/src/BaseEvent/Process.js.map +1 -1
- package/dist/src/BaseEvent/Transaction.d.ts +5 -5
- package/dist/src/BaseEvent/Transaction.js +6 -6
- package/dist/src/BaseEvent/Transaction.js.map +1 -1
- package/dist/src/Cache/Redis.d.ts +1 -1
- package/dist/src/Cache/Redis.js +1 -1
- package/dist/src/Cache/Redis.js.map +1 -1
- package/dist/src/Cache/types.d.ts +1 -1
- package/dist/src/Config/Configuration.js +1 -1
- package/dist/src/Config/Configuration.js.map +1 -1
- package/dist/src/Database/Database.d.ts +2 -2
- package/dist/src/Database/DatabaseManager.d.ts +4 -4
- package/dist/src/Database/DatabaseManager.js +3 -3
- package/dist/src/Database/DatabaseManager.js.map +1 -1
- package/dist/src/Database/DatabaseTransaction.d.ts +1 -1
- package/dist/src/Database/index.d.ts +10 -10
- package/dist/src/Database/index.js +6 -6
- package/dist/src/Database/index.js.map +1 -1
- package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +3 -3
- package/dist/src/Database/integrations/knex/KnexDatabase.js +2 -2
- package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
- package/dist/src/Database/integrations/knex/KnexTransaction.d.ts +3 -3
- package/dist/src/Database/integrations/knex/KnexTransaction.js +1 -1
- package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
- package/dist/src/Database/integrations/kysely/KyselyDatabase.d.ts +3 -3
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js +2 -2
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
- package/dist/src/Database/integrations/kysely/KyselyTransaction.d.ts +3 -3
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js +1 -1
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -1
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +3 -3
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +2 -2
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +3 -3
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +1 -1
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
- package/dist/src/Database/types.d.ts +5 -5
- package/dist/src/Globals.js +1 -1
- package/dist/src/Globals.js.map +1 -1
- package/dist/src/Logger/Logger.d.ts +1 -0
- package/dist/src/Logger/Logger.js +11 -4
- package/dist/src/Logger/Logger.js.map +1 -1
- package/dist/src/Server/RouteResolver.d.ts +2 -2
- package/dist/src/Server/Router.d.ts +3 -3
- package/dist/src/Server/Router.js +3 -3
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Server/lib/ContainerServer.d.ts +3 -3
- package/dist/src/Server/lib/ContainerServer.js +2 -2
- package/dist/src/Server/lib/ContainerServer.js.map +1 -1
- package/dist/src/Server/lib/Server.d.ts +2 -2
- package/dist/src/Server/lib/Server.js +4 -4
- package/dist/src/Server/lib/Server.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandler.d.ts +1 -1
- package/dist/src/Server/lib/container/GenericHandler.js +3 -3
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +1 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +2 -2
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
- package/dist/src/Server/lib/container/Proxy.d.ts +2 -2
- package/dist/src/Server/lib/container/Proxy.js +4 -4
- package/dist/src/Server/lib/container/Proxy.js.map +1 -1
- package/dist/src/Validation/Validator.d.ts +1 -1
- package/dist/src/Validation/Validator.js +2 -2
- package/dist/src/Validation/Validator.js.map +1 -1
- package/index.ts +14 -14
- package/jest.config.ts +5 -1
- package/jest.smoke.config.ts +0 -1
- package/package.json +2 -1
- package/src/API/Request.ts +2 -2
- package/src/API/Response.ts +2 -2
- package/src/BaseEvent/EventProcessor.ts +3 -3
- package/src/BaseEvent/Process.ts +3 -3
- package/src/BaseEvent/Transaction.ts +8 -8
- package/src/Cache/Redis.ts +2 -2
- package/src/Cache/types.ts +1 -1
- package/src/Config/Configuration.ts +1 -1
- package/src/Database/Database.ts +2 -2
- package/src/Database/DatabaseManager.ts +4 -4
- package/src/Database/DatabaseTransaction.ts +1 -1
- package/src/Database/index.ts +10 -10
- package/src/Database/integrations/knex/KnexDatabase.ts +3 -3
- package/src/Database/integrations/knex/KnexTransaction.ts +3 -3
- package/src/Database/integrations/kysely/KyselyDatabase.ts +3 -3
- package/src/Database/integrations/kysely/KyselyTransaction.ts +3 -3
- package/src/Database/integrations/pgsql/PostgresDatabase.ts +3 -3
- package/src/Database/integrations/pgsql/PostgresTransaction.ts +3 -3
- package/src/Database/types.ts +5 -5
- package/src/Globals.ts +1 -1
- package/src/Logger/Logger.ts +15 -6
- package/src/Server/RouteResolver.ts +2 -2
- package/src/Server/Router.ts +6 -6
- package/src/Server/lib/ContainerServer.ts +3 -3
- package/src/Server/lib/Server.ts +6 -6
- package/src/Server/lib/container/GenericHandler.ts +4 -4
- package/src/Server/lib/container/GenericHandlerEvent.ts +3 -3
- package/src/Server/lib/container/Proxy.ts +6 -6
- package/src/Validation/Validator.ts +2 -2
- package/tests/API/Request.test.ts +2 -2
- package/tests/API/Response.test.ts +4 -4
- package/tests/API/Utils.test.ts +1 -1
- package/tests/BaseEvent/EventProcessor.test.ts +4 -4
- package/tests/BaseEvent/Process.test.ts +2 -2
- package/tests/BaseEvent/Transaction.test.ts +5 -5
- package/tests/Cache/Redis-client.test.ts +1 -1
- package/tests/Cache/Redis-cluster.test.ts +1 -1
- package/tests/Config/Config.test.ts +2 -2
- package/tests/Config/EnvironmentVar.test.ts +1 -1
- package/tests/Crypto/Crypto.test.ts +1 -1
- package/tests/Crypto/JWT.test.ts +2 -2
- package/tests/Database/DatabaseManager.test.ts +2 -2
- package/tests/Database/integrations/knex/KnexDatabase.test.ts +2 -2
- package/tests/Database/integrations/knex/KnexTransaction.test.ts +3 -3
- package/tests/Database/integrations/kysely/KyselyDatabase.test.ts +2 -2
- package/tests/Database/integrations/kysely/KyselyTransaction.test.ts +3 -3
- package/tests/Database/integrations/pg/PostgresDatabase.test.ts +2 -2
- package/tests/Database/integrations/pg/PostgresTransaction.test.ts +3 -3
- package/tests/Logger/Logger.test.ts +2 -6
- package/tests/Mailer/Mailer.test.ts +1 -1
- package/tests/Publisher/Publisher.test.ts +1 -1
- package/tests/Server/RouteResolver.test.ts +3 -3
- package/tests/Server/Router.test.ts +3 -3
- package/tests/Server/lib/ContainerServer.test.ts +5 -5
- package/tests/Server/lib/Server.test.ts +1 -1
- package/tests/Server/lib/container/GenericHandler.test.ts +2 -2
- package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
- package/tests/Server/lib/container/HealthHandler.test.ts +1 -1
- package/tests/Server/lib/container/Proxy.test.ts +3 -3
- package/tests/Server/lib/container/Utils.test.ts +1 -1
- package/tests/Test.utils.ts +2 -2
- package/tests/Validation/Validator.test.ts +4 -4
package/src/Database/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Database } from './Database'
|
|
2
|
-
import { DatabaseManager } from './DatabaseManager'
|
|
3
|
-
import { DatabaseTransaction } from './DatabaseTransaction'
|
|
4
|
-
import { KnexDatabase } from './integrations/knex/KnexDatabase'
|
|
5
|
-
import { KnexTransaction } from './integrations/knex/KnexTransaction'
|
|
6
|
-
import { KyselyDatabase } from './integrations/kysely/KyselyDatabase'
|
|
7
|
-
import { KyselyTransaction } from './integrations/kysely/KyselyTransaction'
|
|
8
|
-
import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase'
|
|
9
|
-
import { PostgresTransaction } from './integrations/pgsql/PostgresTransaction'
|
|
10
|
-
import { DbConfig } from './types'
|
|
1
|
+
import { Database } from './Database.js'
|
|
2
|
+
import { DatabaseManager } from './DatabaseManager.js'
|
|
3
|
+
import { DatabaseTransaction } from './DatabaseTransaction.js'
|
|
4
|
+
import { KnexDatabase } from './integrations/knex/KnexDatabase.js'
|
|
5
|
+
import { KnexTransaction } from './integrations/knex/KnexTransaction.js'
|
|
6
|
+
import { KyselyDatabase } from './integrations/kysely/KyselyDatabase.js'
|
|
7
|
+
import { KyselyTransaction } from './integrations/kysely/KyselyTransaction.js'
|
|
8
|
+
import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase.js'
|
|
9
|
+
import { PostgresTransaction } from './integrations/pgsql/PostgresTransaction.js'
|
|
10
|
+
import { DbConfig } from './types.js'
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
// Abstracts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import knex, { Knex } from 'knex'
|
|
2
2
|
import knexStringcase from 'knex-stringcase'
|
|
3
3
|
|
|
4
|
-
import { KnexTransaction, KnexTransactionImpl } from './KnexTransaction'
|
|
5
|
-
import { Database } from '../../Database'
|
|
6
|
-
import type { DbConfig } from '../../types'
|
|
4
|
+
import { KnexTransaction, KnexTransactionImpl } from './KnexTransaction.js'
|
|
5
|
+
import { Database } from '../../Database.js'
|
|
6
|
+
import type { DbConfig } from '../../types.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Represents a KnexDatabase class that extends Database and provides methods for interacting with a Knex database.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Knex } from 'knex'
|
|
2
2
|
|
|
3
|
-
import { KnexDatabase } from './KnexDatabase'
|
|
4
|
-
import { Database } from '../../Database'
|
|
5
|
-
import { DatabaseTransaction } from '../../DatabaseTransaction'
|
|
3
|
+
import { KnexDatabase } from './KnexDatabase.js'
|
|
4
|
+
import { Database } from '../../Database.js'
|
|
5
|
+
import { DatabaseTransaction } from '../../DatabaseTransaction.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Represents a Knex transaction, combining the functionality of KnexTransactionImpl
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CamelCasePlugin, Kysely, PostgresDialect } from 'kysely'
|
|
2
2
|
import * as pg from 'pg'
|
|
3
3
|
|
|
4
|
-
import { KyselyTransaction, KyselyTransactionImpl } from './KyselyTransaction'
|
|
5
|
-
import { Database } from '../../Database'
|
|
6
|
-
import type { DbBaseConfig, DbConfig } from '../../types'
|
|
4
|
+
import { KyselyTransaction, KyselyTransactionImpl } from './KyselyTransaction.js'
|
|
5
|
+
import { Database } from '../../Database.js'
|
|
6
|
+
import type { DbBaseConfig, DbConfig } from '../../types.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Represents a database connection using the Kysely library with support for transactions.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Kysely, Transaction } from 'kysely'
|
|
2
2
|
|
|
3
|
-
import { KyselyDatabase } from './KyselyDatabase'
|
|
4
|
-
import { Database } from '../../Database'
|
|
5
|
-
import { DatabaseTransaction } from '../../DatabaseTransaction'
|
|
3
|
+
import { KyselyDatabase } from './KyselyDatabase.js'
|
|
4
|
+
import { Database } from '../../Database.js'
|
|
5
|
+
import { DatabaseTransaction } from '../../DatabaseTransaction.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Represents a transaction for querying a database with a specific schema.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as pg from 'pg'
|
|
2
2
|
|
|
3
|
-
import { PostgresTransaction, PostgresTransactionImpl } from './PostgresTransaction'
|
|
4
|
-
import { Database } from '../../Database'
|
|
5
|
-
import type { DbBaseConfig, DbConfig } from '../../types'
|
|
3
|
+
import { PostgresTransaction, PostgresTransactionImpl } from './PostgresTransaction.js'
|
|
4
|
+
import { Database } from '../../Database.js'
|
|
5
|
+
import type { DbBaseConfig, DbConfig } from '../../types.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Represents a Postgres database connection that extends the Database class.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as pg from 'pg'
|
|
2
2
|
|
|
3
|
-
import { PostgresDatabase } from './PostgresDatabase'
|
|
4
|
-
import { Database } from '../../Database'
|
|
5
|
-
import { DatabaseTransaction } from '../../DatabaseTransaction'
|
|
3
|
+
import { PostgresDatabase } from './PostgresDatabase.js'
|
|
4
|
+
import { Database } from '../../Database.js'
|
|
5
|
+
import { DatabaseTransaction } from '../../DatabaseTransaction.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A type alias representing a Postgres transaction. It extends the `PostgresTransactionImpl`
|
package/src/Database/types.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Database } from './Database'
|
|
2
|
-
import { DATABASES } from './DatabaseManager'
|
|
3
|
-
import { KnexDatabase } from './integrations/knex/KnexDatabase'
|
|
4
|
-
import { KyselyDatabase } from './integrations/kysely/KyselyDatabase'
|
|
5
|
-
import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase'
|
|
1
|
+
import { Database } from './Database.js'
|
|
2
|
+
import { DATABASES } from './DatabaseManager.js'
|
|
3
|
+
import { KnexDatabase } from './integrations/knex/KnexDatabase.js'
|
|
4
|
+
import { KyselyDatabase } from './integrations/kysely/KyselyDatabase.js'
|
|
5
|
+
import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Represents the possible types of databases available in the system.
|
package/src/Globals.ts
CHANGED
package/src/Logger/Logger.ts
CHANGED
|
@@ -2,7 +2,7 @@ import abind from 'abind'
|
|
|
2
2
|
import stringify from 'json-stringify-safe'
|
|
3
3
|
import stackTrace from 'stack-trace'
|
|
4
4
|
|
|
5
|
-
import Utils from '../Util/Utils'
|
|
5
|
+
import Utils from '../Util/Utils.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Enumeration of log levels.
|
|
@@ -245,13 +245,10 @@ export default class Logger {
|
|
|
245
245
|
private processLog(level: LOG_LEVELS, args: any): void {
|
|
246
246
|
if (level < this._LOG_LEVEL) return
|
|
247
247
|
//get args
|
|
248
|
-
const msg:
|
|
248
|
+
const msg: string[] = []
|
|
249
249
|
for (const arg of args) {
|
|
250
250
|
// Deep clone object so we dont modify source
|
|
251
|
-
const fMsg =
|
|
252
|
-
typeof arg === 'object' && arg
|
|
253
|
-
? stringify(this.suppressSensitiveInfo(JSON.parse(stringify(arg))), null, 2)
|
|
254
|
-
: this.suppressSensitiveInfo(arg)
|
|
251
|
+
const fMsg = this.formatArgument(arg)
|
|
255
252
|
msg.push(fMsg)
|
|
256
253
|
}
|
|
257
254
|
//push into logs stack
|
|
@@ -259,6 +256,18 @@ export default class Logger {
|
|
|
259
256
|
this.pushLog(level, this.formattedLog(level, msg, this.callerName(3)))
|
|
260
257
|
}
|
|
261
258
|
|
|
259
|
+
private formatArgument(arg: any): string {
|
|
260
|
+
if (arg instanceof Error) {
|
|
261
|
+
return arg.message + '\n' + arg.stack
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (arg && typeof arg === 'object') {
|
|
265
|
+
return stringify(this.suppressSensitiveInfo(JSON.parse(stringify(arg))), null, 2)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return `${this.suppressSensitiveInfo(arg)}`
|
|
269
|
+
}
|
|
270
|
+
|
|
262
271
|
/**
|
|
263
272
|
* Logs an exception along with additional arguments and the stack trace.
|
|
264
273
|
* @param {Error} exception - The exception object to log.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyRoute, RouterConfig } from './Router'
|
|
2
|
-
import { HttpMethod } from '../API/Request'
|
|
1
|
+
import { AnyRoute, RouterConfig } from './Router.js'
|
|
2
|
+
import { HttpMethod } from '../API/Request.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents a collection of routes that can be added and resolved.
|
package/src/Server/Router.ts
CHANGED
|
@@ -3,16 +3,16 @@ import { Server as HTTPServer } from 'http'
|
|
|
3
3
|
import express from 'express'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
|
|
6
|
-
import ContainerServer from './lib/ContainerServer'
|
|
7
|
-
import Server from './lib/Server'
|
|
8
|
-
import { HttpMethod } from '../API/Request'
|
|
9
|
-
import { ResponseErrorType } from '../API/Response'
|
|
6
|
+
import ContainerServer from './lib/ContainerServer.js'
|
|
7
|
+
import Server from './lib/Server.js'
|
|
8
|
+
import { HttpMethod } from '../API/Request.js'
|
|
9
|
+
import { ResponseErrorType } from '../API/Response.js'
|
|
10
10
|
import Transaction, {
|
|
11
11
|
TransactionConfig,
|
|
12
12
|
TransactionExecution,
|
|
13
13
|
StringMap,
|
|
14
|
-
} from '../BaseEvent/Transaction'
|
|
15
|
-
import Utils from '../Util/Utils'
|
|
14
|
+
} from '../BaseEvent/Transaction.js'
|
|
15
|
+
import Utils from '../Util/Utils.js'
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Represents a route in an API.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Proxy from './container/Proxy'
|
|
2
|
-
import Server from './Server'
|
|
3
|
-
import { RouterConfig } from '../Router'
|
|
1
|
+
import Proxy from './container/Proxy.js'
|
|
2
|
+
import Server from './Server.js'
|
|
3
|
+
import { RouterConfig } from '../Router.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a server container that extends the Server class and handles serverless events.
|
package/src/Server/lib/Server.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { APIGatewayProxyEvent, Context } from 'aws-lambda'
|
|
2
2
|
import { pathToRegexp } from 'path-to-regexp'
|
|
3
3
|
|
|
4
|
-
import Request from '../../API/Request'
|
|
5
|
-
import Response, { ResponseErrorType } from '../../API/Response'
|
|
6
|
-
import Transaction, { StringMap } from '../../BaseEvent/Transaction'
|
|
7
|
-
import Validator from '../../Validation/Validator'
|
|
8
|
-
import { RouterConfig } from '../Router'
|
|
9
|
-
import RouteResolver from '../RouteResolver'
|
|
4
|
+
import Request from '../../API/Request.js'
|
|
5
|
+
import Response, { ResponseErrorType } from '../../API/Response.js'
|
|
6
|
+
import Transaction, { StringMap } from '../../BaseEvent/Transaction.js'
|
|
7
|
+
import Validator from '../../Validation/Validator.js'
|
|
8
|
+
import { RouterConfig } from '../Router.js'
|
|
9
|
+
import RouteResolver from '../RouteResolver.js'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents a server that handles serverless events and routes them to appropriate handlers.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Request, Response } from 'express'
|
|
2
2
|
|
|
3
|
-
import GenericHandlerEvent, { GenericHandlerEventResponse } from './GenericHandlerEvent'
|
|
4
|
-
import Globals from '../../../Globals'
|
|
5
|
-
import Utils from '../../../Util/Utils'
|
|
6
|
-
import Server from '../Server'
|
|
3
|
+
import GenericHandlerEvent, { GenericHandlerEventResponse } from './GenericHandlerEvent.js'
|
|
4
|
+
import Globals from '../../../Globals.js'
|
|
5
|
+
import Utils from '../../../Util/Utils.js'
|
|
6
|
+
import Server from '../Server.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Creates an async function that handles serverless events and sends a response.
|
|
@@ -2,9 +2,9 @@ import type { APIGatewayProxyEvent, Context } from 'aws-lambda'
|
|
|
2
2
|
import cuid from 'cuid'
|
|
3
3
|
import { Request } from 'express'
|
|
4
4
|
|
|
5
|
-
import { parseMultiValueQueryStringParameters, parseQueryStringParameters } from './Utils'
|
|
6
|
-
import Globals from '../../../Globals'
|
|
7
|
-
import Server from '../Server'
|
|
5
|
+
import { parseMultiValueQueryStringParameters, parseQueryStringParameters } from './Utils.js'
|
|
6
|
+
import Globals from '../../../Globals.js'
|
|
7
|
+
import Server from '../Server.js'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Represents the response object returned by a generic event handler.
|
|
@@ -4,12 +4,12 @@ import { Server as HTTPServer, createServer } from 'http'
|
|
|
4
4
|
import cors from 'cors'
|
|
5
5
|
import express from 'express'
|
|
6
6
|
|
|
7
|
-
import Server from './../Server'
|
|
8
|
-
import GenericHandler from './GenericHandler'
|
|
9
|
-
import HealthHandler from './HealthHandler'
|
|
10
|
-
import Globals from '../../../Globals'
|
|
11
|
-
import Utils from '../../../Util/Utils'
|
|
12
|
-
import { RouterConfig } from '../../Router'
|
|
7
|
+
import Server from './../Server.js'
|
|
8
|
+
import GenericHandler from './GenericHandler.js'
|
|
9
|
+
import HealthHandler from './HealthHandler.js'
|
|
10
|
+
import Globals from '../../../Globals.js'
|
|
11
|
+
import Utils from '../../../Util/Utils.js'
|
|
12
|
+
import { RouterConfig } from '../../Router.js'
|
|
13
13
|
|
|
14
14
|
/* Get package.json version from Wapi on ESM */
|
|
15
15
|
const { version: appVersion } = JSON.parse(fs.readFileSync('package.json').toString())
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
import Response, { ResponseErrorType } from '../API/Response'
|
|
4
|
-
import Globals from '../Globals'
|
|
3
|
+
import Response, { ResponseErrorType } from '../API/Response.js'
|
|
4
|
+
import Globals from '../Globals.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Validates the given data against the provided schema.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { APIGatewayEvent, Context } from 'aws-lambda'
|
|
2
2
|
import { expect } from 'chai'
|
|
3
3
|
|
|
4
|
-
import Request, { HttpMethod } from '../../src/API/Request'
|
|
5
|
-
import Logger from '../../src/Logger/Logger'
|
|
4
|
+
import Request, { HttpMethod } from '../../src/API/Request.js'
|
|
5
|
+
import Logger from '../../src/Logger/Logger.js'
|
|
6
6
|
|
|
7
7
|
function newReq(event: any, context?: any) {
|
|
8
8
|
const logger = new Logger(
|
|
@@ -2,10 +2,10 @@ import { jest } from '@jest/globals'
|
|
|
2
2
|
import { APIGatewayEvent, Context } from 'aws-lambda'
|
|
3
3
|
import { expect as c_expect } from 'chai'
|
|
4
4
|
|
|
5
|
-
import Response from '../../src/API/Response'
|
|
6
|
-
import Transaction from '../../src/BaseEvent/Transaction'
|
|
7
|
-
import Globals from '../../src/Globals'
|
|
8
|
-
import { observableTransaction, defaultHeaders } from '../Test.utils'
|
|
5
|
+
import Response from '../../src/API/Response.js'
|
|
6
|
+
import Transaction from '../../src/BaseEvent/Transaction.js'
|
|
7
|
+
import Globals from '../../src/Globals.js'
|
|
8
|
+
import { observableTransaction, defaultHeaders } from '../Test.utils.js'
|
|
9
9
|
|
|
10
10
|
async function testResponse(r: Response<any>, body: any, optCode?: number, optHeaders?: any) {
|
|
11
11
|
const t = observableTransaction()
|
package/tests/API/Utils.test.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { expect as c_expect } from 'chai'
|
|
2
2
|
|
|
3
|
-
import Response from '../../src/API/Response'
|
|
4
|
-
import EventProcessor from '../../src/BaseEvent/EventProcessor'
|
|
5
|
-
import Globals from '../../src/Globals'
|
|
6
|
-
import { emptyQueueEvent, observableContext } from '../Test.utils'
|
|
3
|
+
import Response from '../../src/API/Response.js'
|
|
4
|
+
import EventProcessor from '../../src/BaseEvent/EventProcessor.js'
|
|
5
|
+
import Globals from '../../src/Globals.js'
|
|
6
|
+
import { emptyQueueEvent, observableContext } from '../Test.utils.js'
|
|
7
7
|
|
|
8
8
|
describe('EventProcessor success invocation path', () => {
|
|
9
9
|
test('Simple success', async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'chai'
|
|
2
2
|
|
|
3
|
-
import Response from '../../src/API/Response'
|
|
4
|
-
import Process from '../../src/BaseEvent/Process'
|
|
3
|
+
import Response from '../../src/API/Response.js'
|
|
4
|
+
import Process from '../../src/BaseEvent/Process.js'
|
|
5
5
|
|
|
6
6
|
describe('Process success invocation path', () => {
|
|
7
7
|
test('Simple success', async () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import { expect as c_expect } from 'chai'
|
|
3
3
|
|
|
4
|
-
import Response from '../../src/API/Response'
|
|
5
|
-
import Transaction from '../../src/BaseEvent/Transaction'
|
|
6
|
-
import type { DbConfig } from '../../src/Database/types'
|
|
7
|
-
import Globals from '../../src/Globals'
|
|
8
|
-
import { defaultHeaders, emptyEvent, observableContext } from '../Test.utils'
|
|
4
|
+
import Response from '../../src/API/Response.js'
|
|
5
|
+
import Transaction from '../../src/BaseEvent/Transaction.js'
|
|
6
|
+
import type { DbConfig } from '../../src/Database/types.js'
|
|
7
|
+
import Globals from '../../src/Globals.js'
|
|
8
|
+
import { defaultHeaders, emptyEvent, observableContext } from '../Test.utils.js'
|
|
9
9
|
|
|
10
10
|
describe('Transaction success invocation path', () => {
|
|
11
11
|
test('Simple success', async () => {
|
|
@@ -2,8 +2,8 @@ import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm'
|
|
|
2
2
|
import { mockClient } from 'aws-sdk-client-mock'
|
|
3
3
|
import { expect as c_expect } from 'chai'
|
|
4
4
|
|
|
5
|
-
import Configuration from '../../src/Config/Configuration'
|
|
6
|
-
import { SampleConfig } from '../Test.utils'
|
|
5
|
+
import Configuration from '../../src/Config/Configuration.js'
|
|
6
|
+
import { SampleConfig } from '../Test.utils.js'
|
|
7
7
|
|
|
8
8
|
const SSMMock = mockClient(SSMClient)
|
|
9
9
|
const config = new Configuration<typeof SampleConfig>(SampleConfig, 'my-prefix')
|
|
@@ -3,7 +3,7 @@ import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm'
|
|
|
3
3
|
import { mockClient } from 'aws-sdk-client-mock'
|
|
4
4
|
import { expect } from 'chai'
|
|
5
5
|
|
|
6
|
-
import EnvironmentVar, { EnvironmentType } from '../../src/Config/EnvironmentVar'
|
|
6
|
+
import EnvironmentVar, { EnvironmentType } from '../../src/Config/EnvironmentVar.js'
|
|
7
7
|
|
|
8
8
|
const SSMMock = mockClient(SSMClient)
|
|
9
9
|
const SecretsManagerMock = mockClient(SecretsManagerClient)
|
|
@@ -2,7 +2,7 @@ import { DecryptCommand, EncryptCommand, KMSClient } from '@aws-sdk/client-kms'
|
|
|
2
2
|
import { mockClient } from 'aws-sdk-client-mock'
|
|
3
3
|
import { expect } from 'chai'
|
|
4
4
|
|
|
5
|
-
import Crypto from '../../src/Crypto/Crypto'
|
|
5
|
+
import Crypto from '../../src/Crypto/Crypto.js'
|
|
6
6
|
|
|
7
7
|
const KMSMock = mockClient(KMSClient)
|
|
8
8
|
|
package/tests/Crypto/JWT.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'chai'
|
|
2
2
|
|
|
3
|
-
import JWT from '../../src/Crypto/JWT'
|
|
4
|
-
import { foreignToken, privateKey } from '../Test.utils'
|
|
3
|
+
import JWT from '../../src/Crypto/JWT.js'
|
|
4
|
+
import { foreignToken, privateKey } from '../Test.utils.js'
|
|
5
5
|
|
|
6
6
|
describe('Creates token', () => {
|
|
7
7
|
const provider = new JWT(privateKey, '7d')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import { expect } from 'chai'
|
|
3
3
|
|
|
4
|
-
import { DatabaseManager } from '../../src/Database'
|
|
5
|
-
import type { DatabaseType, DbConfig } from '../../src/Database/types'
|
|
4
|
+
import { DatabaseManager } from '../../src/Database/index.js'
|
|
5
|
+
import type { DatabaseType, DbConfig } from '../../src/Database/types.js'
|
|
6
6
|
|
|
7
7
|
type FakeDatabase = { host: string; type: 'knex' | 'pg' | 'kysely' }
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import { Knex } from 'knex'
|
|
3
3
|
|
|
4
|
-
import type { DbConfig } from '../../../../src/Database'
|
|
5
|
-
import { KnexDatabase } from '../../../../src/Database/integrations/knex/KnexDatabase'
|
|
4
|
+
import type { DbConfig } from '../../../../src/Database/index.js'
|
|
5
|
+
import { KnexDatabase } from '../../../../src/Database/integrations/knex/KnexDatabase.js'
|
|
6
6
|
|
|
7
7
|
const config: DbConfig<'knex'> = {
|
|
8
8
|
type: 'knex',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import { Knex } from 'knex'
|
|
3
3
|
|
|
4
|
-
import { DbConfig } from '../../../../src/Database'
|
|
5
|
-
import { KnexDatabase } from '../../../../src/Database/integrations/knex/KnexDatabase'
|
|
6
|
-
import { KnexTransactionImpl } from '../../../../src/Database/integrations/knex/KnexTransaction'
|
|
4
|
+
import { DbConfig } from '../../../../src/Database/index.js'
|
|
5
|
+
import { KnexDatabase } from '../../../../src/Database/integrations/knex/KnexDatabase.js'
|
|
6
|
+
import { KnexTransactionImpl } from '../../../../src/Database/integrations/knex/KnexTransaction.js'
|
|
7
7
|
|
|
8
8
|
const testResources = async (config: Partial<DbConfig<'knex'>>) => {
|
|
9
9
|
const database = {
|
|
@@ -2,8 +2,8 @@ import { jest } from '@jest/globals'
|
|
|
2
2
|
import { PostgresDialect } from 'kysely'
|
|
3
3
|
import * as pg from 'pg'
|
|
4
4
|
|
|
5
|
-
import type { DbConfig } from '../../../../src/Database'
|
|
6
|
-
import { KyselyDatabase } from '../../../../src/Database/integrations/kysely/KyselyDatabase'
|
|
5
|
+
import type { DbConfig } from '../../../../src/Database/index.js'
|
|
6
|
+
import { KyselyDatabase } from '../../../../src/Database/integrations/kysely/KyselyDatabase.js'
|
|
7
7
|
|
|
8
8
|
const config: DbConfig<'kysely'> = {
|
|
9
9
|
type: 'kysely',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import { Kysely, Transaction } from 'kysely'
|
|
3
3
|
|
|
4
|
-
import type { DbConfig } from '../../../../src/Database'
|
|
5
|
-
import { KyselyDatabase } from '../../../../src/Database/integrations/kysely/KyselyDatabase'
|
|
6
|
-
import { KyselyTransactionImpl } from '../../../../src/Database/integrations/kysely/KyselyTransaction'
|
|
4
|
+
import type { DbConfig } from '../../../../src/Database/index.js'
|
|
5
|
+
import { KyselyDatabase } from '../../../../src/Database/integrations/kysely/KyselyDatabase.js'
|
|
6
|
+
import { KyselyTransactionImpl } from '../../../../src/Database/integrations/kysely/KyselyTransaction.js'
|
|
7
7
|
|
|
8
8
|
const testResources = async (config: Partial<DbConfig<'kysely'>>) => {
|
|
9
9
|
type DB = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import * as pg from 'pg'
|
|
3
3
|
|
|
4
|
-
import type { DbConfig } from '../../../../src/Database'
|
|
5
|
-
import { PostgresDatabase } from '../../../../src/Database/integrations/pgsql/PostgresDatabase'
|
|
4
|
+
import type { DbConfig } from '../../../../src/Database/index.js'
|
|
5
|
+
import { PostgresDatabase } from '../../../../src/Database/integrations/pgsql/PostgresDatabase.js'
|
|
6
6
|
|
|
7
7
|
const config: DbConfig<'pg'> = {
|
|
8
8
|
type: 'pg',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import * as pg from 'pg'
|
|
3
3
|
|
|
4
|
-
import type { DbConfig } from '../../../../src/Database'
|
|
5
|
-
import { PostgresDatabase } from '../../../../src/Database/integrations/pgsql/PostgresDatabase'
|
|
6
|
-
import { PostgresTransactionImpl } from '../../../../src/Database/integrations/pgsql/PostgresTransaction'
|
|
4
|
+
import type { DbConfig } from '../../../../src/Database/index.js'
|
|
5
|
+
import { PostgresDatabase } from '../../../../src/Database/integrations/pgsql/PostgresDatabase.js'
|
|
6
|
+
import { PostgresTransactionImpl } from '../../../../src/Database/integrations/pgsql/PostgresTransaction.js'
|
|
7
7
|
|
|
8
8
|
const testResources = async (config: Partial<DbConfig<'pg'>>) => {
|
|
9
9
|
const database = {
|
|
@@ -5,7 +5,7 @@ import { expect as c_expect } from 'chai'
|
|
|
5
5
|
const consoleProxy = console
|
|
6
6
|
const mock = jest.spyOn(consoleProxy, 'log')
|
|
7
7
|
// import logger after first ref
|
|
8
|
-
import Logger from '../../src/Logger/Logger'
|
|
8
|
+
import Logger from '../../src/Logger/Logger.js'
|
|
9
9
|
// get console reference after logger import
|
|
10
10
|
const transactionID = '123-456'
|
|
11
11
|
|
|
@@ -167,11 +167,7 @@ function testLogs(isContainer: boolean, provider?: Logger) {
|
|
|
167
167
|
)
|
|
168
168
|
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
169
169
|
1,
|
|
170
|
-
expect.stringContaining('
|
|
171
|
-
)
|
|
172
|
-
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
173
|
-
1,
|
|
174
|
-
expect.stringContaining('] {\n' + ' "self": "[Circular ~]"\n' + '}')
|
|
170
|
+
expect.stringContaining('tests/Logger/Logger.test.ts:')
|
|
175
171
|
)
|
|
176
172
|
})
|
|
177
173
|
|
|
@@ -2,7 +2,7 @@ import { SESClient, SendRawEmailCommand } from '@aws-sdk/client-ses'
|
|
|
2
2
|
import { mockClient } from 'aws-sdk-client-mock'
|
|
3
3
|
import { expect } from 'chai'
|
|
4
4
|
|
|
5
|
-
import Mailer from '../../src/Mailer/Mailer'
|
|
5
|
+
import Mailer from '../../src/Mailer/Mailer.js'
|
|
6
6
|
|
|
7
7
|
const SESMock = mockClient(SESClient)
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import { SNSClient, PublishCommand } from '@aws-sdk/client-sns'
|
|
|
2
2
|
import { mockClient } from 'aws-sdk-client-mock'
|
|
3
3
|
import { expect } from 'chai'
|
|
4
4
|
|
|
5
|
-
import Publisher from '../../src/Publisher/Publisher'
|
|
5
|
+
import Publisher from '../../src/Publisher/Publisher.js'
|
|
6
6
|
|
|
7
7
|
const SNSMock = mockClient(SNSClient)
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpMethod } from '../../src/API/Request'
|
|
2
|
-
import { Route } from '../../src/Server/Router'
|
|
3
|
-
import RouteResolver from '../../src/Server/RouteResolver'
|
|
1
|
+
import { HttpMethod } from '../../src/API/Request.js'
|
|
2
|
+
import { Route } from '../../src/Server/Router.js'
|
|
3
|
+
import RouteResolver from '../../src/Server/RouteResolver.js'
|
|
4
4
|
|
|
5
5
|
const mockRoute = (method: HttpMethod, path: string) =>
|
|
6
6
|
({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jest } from '@jest/globals'
|
|
2
2
|
import { expect } from 'chai'
|
|
3
3
|
|
|
4
|
-
import ContainerServer from '../../src/Server/lib/ContainerServer'
|
|
5
|
-
import Server from '../../src/Server/lib/Server'
|
|
6
|
-
import Router from '../../src/Server/Router'
|
|
4
|
+
import ContainerServer from '../../src/Server/lib/ContainerServer.js'
|
|
5
|
+
import Server from '../../src/Server/lib/Server.js'
|
|
6
|
+
import Router from '../../src/Server/Router.js'
|
|
7
7
|
|
|
8
8
|
describe('Router basics', () => {
|
|
9
9
|
// @ts-ignore
|
|
@@ -3,11 +3,11 @@ import { expect as c_expect } from 'chai'
|
|
|
3
3
|
import request from 'supertest'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
|
|
6
|
-
import { HttpMethod } from '../../../src/API/Request'
|
|
7
|
-
import Response from '../../../src/API/Response'
|
|
8
|
-
import Globals from '../../../src/Globals'
|
|
9
|
-
import ContainerServer from '../../../src/Server/lib/ContainerServer'
|
|
10
|
-
import { defaultUrl } from '../../Test.utils'
|
|
6
|
+
import { HttpMethod } from '../../../src/API/Request.js'
|
|
7
|
+
import Response from '../../../src/API/Response.js'
|
|
8
|
+
import Globals from '../../../src/Globals.js'
|
|
9
|
+
import ContainerServer from '../../../src/Server/lib/ContainerServer.js'
|
|
10
|
+
import { defaultUrl } from '../../Test.utils.js'
|
|
11
11
|
|
|
12
12
|
export const ViewSchema = z.object({
|
|
13
13
|
id: z.string(),
|