@creator.co/wapi 1.6.1 → 1.7.1-alpha1

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.
Files changed (127) hide show
  1. package/.eslintignore +2 -1
  2. package/.github/workflows/npmpublish.yml +1 -1
  3. package/.github/workflows/prs.yml +1 -1
  4. package/dist/index.js +45 -31
  5. package/dist/index.js.map +1 -1
  6. package/dist/package-lock.json +11786 -0
  7. package/dist/package.json +24 -22
  8. package/dist/src/API/Request.js +53 -59
  9. package/dist/src/API/Request.js.map +1 -1
  10. package/dist/src/API/Response.js +81 -156
  11. package/dist/src/API/Response.js.map +1 -1
  12. package/dist/src/BaseEvent/EventProcessor.js +54 -132
  13. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  14. package/dist/src/BaseEvent/Process.js +40 -98
  15. package/dist/src/BaseEvent/Process.js.map +1 -1
  16. package/dist/src/BaseEvent/Transaction.js +122 -310
  17. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  18. package/dist/src/Cache/Redis.js +55 -119
  19. package/dist/src/Cache/Redis.js.map +1 -1
  20. package/dist/src/Cache/types.js +1 -2
  21. package/dist/src/Config/Configuration.js +46 -86
  22. package/dist/src/Config/Configuration.js.map +1 -1
  23. package/dist/src/Config/EnvironmentVar.js +57 -119
  24. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  25. package/dist/src/Crypto/Crypto.js +35 -82
  26. package/dist/src/Crypto/Crypto.js.map +1 -1
  27. package/dist/src/Crypto/JWT.d.ts +1 -1
  28. package/dist/src/Crypto/JWT.js +12 -27
  29. package/dist/src/Crypto/JWT.js.map +1 -1
  30. package/dist/src/Database/Database.js +3 -8
  31. package/dist/src/Database/Database.js.map +1 -1
  32. package/dist/src/Database/DatabaseManager.js +23 -28
  33. package/dist/src/Database/DatabaseManager.js.map +1 -1
  34. package/dist/src/Database/DatabaseTransaction.js +50 -166
  35. package/dist/src/Database/DatabaseTransaction.js.map +1 -1
  36. package/dist/src/Database/index.js +11 -15
  37. package/dist/src/Database/index.js.map +1 -1
  38. package/dist/src/Database/integrations/knex/KnexDatabase.js +22 -76
  39. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
  40. package/dist/src/Database/integrations/knex/KnexTransaction.js +19 -85
  41. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
  42. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +37 -88
  43. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
  44. package/dist/src/Database/integrations/kysely/KyselyTransaction.js +46 -114
  45. package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -1
  46. package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +3 -3
  47. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +20 -71
  48. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
  49. package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +9 -9
  50. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +19 -85
  51. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
  52. package/dist/src/Database/types.js +1 -2
  53. package/dist/src/Globals.js +93 -98
  54. package/dist/src/Globals.js.map +1 -1
  55. package/dist/src/Logger/Logger.js +88 -222
  56. package/dist/src/Logger/Logger.js.map +1 -1
  57. package/dist/src/Mailer/Mailer.d.ts +1 -1
  58. package/dist/src/Mailer/Mailer.js +83 -204
  59. package/dist/src/Mailer/Mailer.js.map +1 -1
  60. package/dist/src/Publisher/Publisher.js +43 -107
  61. package/dist/src/Publisher/Publisher.js.map +1 -1
  62. package/dist/src/Server/RouteResolver.js +22 -49
  63. package/dist/src/Server/RouteResolver.js.map +1 -1
  64. package/dist/src/Server/Router.d.ts +1 -1
  65. package/dist/src/Server/Router.js +12 -16
  66. package/dist/src/Server/Router.js.map +1 -1
  67. package/dist/src/Server/lib/ContainerServer.js +21 -83
  68. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  69. package/dist/src/Server/lib/Server.js +50 -99
  70. package/dist/src/Server/lib/Server.js.map +1 -1
  71. package/dist/src/Server/lib/container/GenericHandler.js +32 -107
  72. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  73. package/dist/src/Server/lib/container/GenericHandlerEvent.js +37 -81
  74. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  75. package/dist/src/Server/lib/container/HealthHandler.js +3 -35
  76. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  77. package/dist/src/Server/lib/container/Proxy.js +66 -127
  78. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  79. package/dist/src/Server/lib/container/Utils.js +12 -55
  80. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  81. package/dist/src/Util/AsyncSingleton.js +40 -164
  82. package/dist/src/Util/AsyncSingleton.js.map +1 -1
  83. package/dist/src/Util/Utils.js +18 -24
  84. package/dist/src/Util/Utils.js.map +1 -1
  85. package/dist/src/Validation/Validator.js +10 -16
  86. package/dist/src/Validation/Validator.js.map +1 -1
  87. package/jest.config.ts +1 -0
  88. package/jest.smoke.config.ts +35 -0
  89. package/package.json +24 -22
  90. package/src/Config/Configuration.ts +2 -2
  91. package/src/Crypto/JWT.ts +1 -1
  92. package/src/Database/DatabaseManager.ts +1 -1
  93. package/src/Database/integrations/knex/KnexDatabase.ts +1 -1
  94. package/src/Database/integrations/kysely/KyselyDatabase.ts +2 -2
  95. package/src/Database/integrations/pgsql/PostgresDatabase.ts +4 -4
  96. package/src/Database/integrations/pgsql/PostgresTransaction.ts +8 -8
  97. package/src/Globals.ts +1 -1
  98. package/src/Logger/Logger.ts +3 -3
  99. package/src/Mailer/Mailer.ts +3 -3
  100. package/src/Publisher/Publisher.ts +1 -1
  101. package/src/Server/Router.ts +1 -1
  102. package/src/Server/lib/container/GenericHandlerEvent.ts +1 -1
  103. package/src/Server/lib/container/Proxy.ts +6 -3
  104. package/tests/API/Response.test.ts +1 -0
  105. package/tests/BaseEvent/Transaction.test.ts +1 -0
  106. package/tests/Cache/Redis-client.test.ts +2 -0
  107. package/tests/Cache/Redis-cluster.test.ts +2 -0
  108. package/tests/Database/DatabaseManager.test.ts +4 -3
  109. package/tests/Database/integrations/knex/KnexDatabase.test.ts +1 -0
  110. package/tests/Database/integrations/knex/KnexTransaction.test.ts +1 -0
  111. package/tests/Database/integrations/kysely/KyselyDatabase.test.ts +4 -3
  112. package/tests/Database/integrations/kysely/KyselyTransaction.test.ts +2 -1
  113. package/tests/Database/integrations/pg/PostgresDatabase.test.ts +3 -2
  114. package/tests/Database/integrations/pg/PostgresTransaction.test.ts +4 -3
  115. package/tests/Logger/Logger.test.ts +6 -3
  116. package/tests/Server/Router.test.ts +1 -0
  117. package/tests/Server/lib/ContainerServer.test.ts +2 -1
  118. package/tests/Server/lib/container/GenericHandler.test.ts +1 -0
  119. package/tests/Server/lib/container/HealthHandler.test.ts +1 -0
  120. package/tests/Server/lib/container/Proxy.test.ts +2 -1
  121. package/tests/Test.utils.ts +2 -1
  122. package/tsconfig.json +6 -2
  123. package/tsconfig.smoke.json +26 -0
  124. package/dist/jest.config.d.ts +0 -3
  125. package/dist/jest.config.js +0 -34
  126. package/dist/jest.config.js.map +0 -1
  127. package/tests/main.test.ts +0 -15
@@ -1,4 +1,5 @@
1
- import { Pool, PoolClient } from 'pg'
1
+ import { jest } from '@jest/globals'
2
+ import * as pg from 'pg'
2
3
 
3
4
  import type { DbConfig } from '../../../../src/Database'
4
5
  import { PostgresDatabase } from '../../../../src/Database/integrations/pgsql/PostgresDatabase'
@@ -18,13 +19,13 @@ const testResources = async (config: Partial<DbConfig<'pg'>>) => {
18
19
  rollback: jest.fn(),
19
20
  query: jest.fn(),
20
21
  }
21
- })() as any as PoolClient
22
+ })() as any as pg.PoolClient
22
23
 
23
24
  const writer = jest.fn().mockImplementation(() => {
24
25
  return {
25
26
  connect: jest.fn(() => transaction),
26
27
  }
27
- })() as any as Pool
28
+ })() as any as pg.Pool
28
29
 
29
30
  return {
30
31
  transaction,
@@ -1,3 +1,4 @@
1
+ import { jest } from '@jest/globals'
1
2
  import { expect as c_expect } from 'chai'
2
3
 
3
4
  // get console ref and mock before logger import
@@ -166,9 +167,11 @@ function testLogs(isContainer: boolean, provider?: Logger) {
166
167
  )
167
168
  expect(consoleProxy.log).toHaveBeenNthCalledWith(
168
169
  1,
169
- expect.stringContaining(
170
- '[INFO] [Logger.test.ts:199] {\n' + ' "self": "[Circular ~]"\n' + '}'
171
- )
170
+ expect.stringContaining('[INFO] [Logger.test.ts:')
171
+ )
172
+ expect(consoleProxy.log).toHaveBeenNthCalledWith(
173
+ 1,
174
+ expect.stringContaining('] {\n' + ' "self": "[Circular ~]"\n' + '}')
172
175
  )
173
176
  })
174
177
 
@@ -1,3 +1,4 @@
1
+ import { jest } from '@jest/globals'
1
2
  import { expect } from 'chai'
2
3
 
3
4
  import ContainerServer from '../../src/Server/lib/ContainerServer'
@@ -1,5 +1,6 @@
1
+ import { jest } from '@jest/globals'
1
2
  import { expect as c_expect } from 'chai'
2
- import * as request from 'supertest'
3
+ import request from 'supertest'
3
4
  import { z } from 'zod'
4
5
 
5
6
  import { HttpMethod } from '../../../src/API/Request'
@@ -1,3 +1,4 @@
1
+ import { jest } from '@jest/globals'
1
2
  import { APIGatewayProxyEvent, Context } from 'aws-lambda'
2
3
  import { expect as c_expect } from 'chai'
3
4
  import { Request, Response } from 'express'
@@ -1,3 +1,4 @@
1
+ import { jest } from '@jest/globals'
1
2
  import { expect as c_expect } from 'chai'
2
3
  import { Request, Response } from 'express'
3
4
 
@@ -1,6 +1,7 @@
1
+ import { jest } from '@jest/globals'
1
2
  import { APIGatewayProxyEvent, Context } from 'aws-lambda'
2
3
  import { expect as c_expect } from 'chai'
3
- import * as request from 'supertest'
4
+ import request from 'supertest'
4
5
 
5
6
  import Globals from '../../../../src/Globals'
6
7
  import Proxy from '../../../../src/Server/lib/container/Proxy'
@@ -1,3 +1,4 @@
1
+ import { jest } from '@jest/globals'
1
2
  import { APIGatewayEvent, Context, SQSEvent } from 'aws-lambda'
2
3
  import { z } from 'zod'
3
4
 
@@ -68,6 +69,6 @@ export function emptyQueueEvent(data?: any) {
68
69
 
69
70
  export function observableTransaction() {
70
71
  const t = new Transaction(emptyEvent(), observableContext())
71
- t.responseProxy = jest.fn()
72
+ t.responseProxy = jest.fn() as any
72
73
  return t
73
74
  }
package/tsconfig.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
- "exclude": ["**/*.test.*", "**/__mocks__/*", "**/__tests__/*", "**/tests/*", "./dist/**/*"],
2
+ "exclude": ["**/*.test.*", "**/__mocks__/*", "**/__tests__/*", "**/tests/*", "./dist/**/*", "./smoke-tests/**/*", "./jest*", "./node_modules"],
3
+ "include": ["./**/*", "./package.json", "./package-lock.json"],
3
4
  "compilerOptions": {
4
5
  "lib": [
5
6
  "es5",
6
7
  "es6",
7
8
  "dom"
8
9
  ],
10
+ "module": "esnext",
11
+ "target": "es6",
12
+ "moduleResolution": "node",
13
+ "esModuleInterop": true,
9
14
  "noImplicitAny": false,
10
15
  "noEmitOnError": true,
11
16
  "removeComments": false,
12
17
  "downlevelIteration": true,
13
18
  "resolveJsonModule": true,
14
19
  "sourceMap": true,
15
- "target": "es5",
16
20
  "outDir": "dist",
17
21
  "declaration": true,
18
22
  "skipLibCheck": true,
@@ -0,0 +1,26 @@
1
+ {
2
+ "exclude": ["./dist/**/*", "./smoke-tests/**/*", "./node_modules", "./**/Logger.test.*"],
3
+ "include": ["./**/*", "./package.json", "./package-lock.json"],
4
+ "compilerOptions": {
5
+ "lib": [
6
+ "es5",
7
+ "es6",
8
+ "dom"
9
+ ],
10
+ "module": "esnext",
11
+ "target": "es6",
12
+ "moduleResolution": "node",
13
+ "noImplicitAny": false,
14
+ "noEmitOnError": true,
15
+ "removeComments": false,
16
+ "downlevelIteration": true,
17
+ "resolveJsonModule": true,
18
+ "sourceMap": true,
19
+ "esModuleInterop": true,
20
+ "outDir": "smoke-tests",
21
+ "declaration": true,
22
+ "skipLibCheck": true,
23
+ "strictNullChecks": true,
24
+ "noErrorTruncation": true
25
+ }
26
+ }
@@ -1,3 +0,0 @@
1
- import type { Config } from '@jest/types';
2
- declare const config: Config.InitialOptions;
3
- export default config;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-env node */
4
- var config = {
5
- preset: 'ts-jest',
6
- testEnvironment: 'node',
7
- reporters: [
8
- 'default',
9
- [
10
- 'jest-junit',
11
- {
12
- outputDirectory: 'coverage',
13
- outputName: 'jest-junit.xml',
14
- ancestorSeparator: ' › ',
15
- uniqueOutputName: 'false',
16
- suiteNameTemplate: '{filepath}',
17
- classNameTemplate: '{classname}',
18
- titleTemplate: '{title}',
19
- },
20
- ],
21
- ],
22
- coverageReporters: ['clover', 'json', 'lcov', ['text', { file: 'coverage.txt' }], 'json-summary'],
23
- collectCoverageFrom: ['src/**/*.(t|j)s', '!src/**/*.d.(t|j)s'],
24
- coverageThreshold: {
25
- global: {
26
- branches: 80,
27
- functions: 80,
28
- lines: 80,
29
- statements: 80,
30
- },
31
- },
32
- };
33
- exports.default = config;
34
- //# sourceMappingURL=jest.config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../jest.config.ts"],"names":[],"mappings":";;AACA,qBAAqB;AACrB,IAAM,MAAM,GAA0B;IACpC,MAAM,EAAE,SAAS;IACjB,eAAe,EAAE,MAAM;IACvB,SAAS,EAAE;QACT,SAAS;QACT;YACE,YAAY;YACZ;gBACE,eAAe,EAAE,UAAU;gBAC3B,UAAU,EAAE,gBAAgB;gBAC5B,iBAAiB,EAAE,KAAK;gBACxB,gBAAgB,EAAE,OAAO;gBACzB,iBAAiB,EAAE,YAAY;gBAC/B,iBAAiB,EAAE,aAAa;gBAChC,aAAa,EAAE,SAAS;aACzB;SACF;KACF;IACD,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,CAAC;IACjG,mBAAmB,EAAE,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;IAC9D,iBAAiB,EAAE;QACjB,MAAM,EAAE;YACN,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;YACb,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;SACf;KACF;CACF,CAAA;AACD,kBAAe,MAAM,CAAA"}
@@ -1,15 +0,0 @@
1
- // requireActual ensures you get the real file
2
- // instead of an automock
3
- // we use import type and <typeof ...> to still get types
4
- // import type * as Silly from "../silly"
5
- // const { sillyFunction } = jest.requireActual<typeof Silly>("../silly")
6
-
7
- describe('silly function', () => {
8
- test('guaranteed random', () => {
9
- expect(4).toBe(4)
10
- })
11
- })
12
-
13
- // required with this small example
14
- // to make the isolatedModules config happy
15
- export {}