@creator.co/wapi 1.7.5-alpha2 → 1.7.5

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 (51) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.js.map +1 -1
  3. package/dist/package-lock.json +557 -994
  4. package/dist/package.json +1 -3
  5. package/dist/src/API/Request.js +2 -1
  6. package/dist/src/API/Request.js.map +1 -1
  7. package/dist/src/Database/DatabaseManager.d.ts +0 -2
  8. package/dist/src/Database/DatabaseManager.js +0 -2
  9. package/dist/src/Database/DatabaseManager.js.map +1 -1
  10. package/dist/src/Database/DatabaseTransaction.js +1 -1
  11. package/dist/src/Database/DatabaseTransaction.js.map +1 -1
  12. package/dist/src/Database/index.d.ts +1 -2
  13. package/dist/src/Database/index.js +1 -6
  14. package/dist/src/Database/index.js.map +1 -1
  15. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +1 -1
  16. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
  17. package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +1 -1
  18. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +1 -1
  19. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
  20. package/dist/src/Database/types.d.ts +3 -10
  21. package/dist/src/Server/RouteResolver.js +10 -2
  22. package/dist/src/Server/RouteResolver.js.map +1 -1
  23. package/dist/src/Server/Router.d.ts +1 -1
  24. package/dist/src/Server/lib/Server.js +3 -1
  25. package/dist/src/Server/lib/Server.js.map +1 -1
  26. package/dist/src/Validation/Validator.js +2 -1
  27. package/dist/src/Validation/Validator.js.map +1 -1
  28. package/index.ts +1 -2
  29. package/package.json +1 -3
  30. package/src/API/Request.ts +1 -1
  31. package/src/Database/DatabaseManager.ts +1 -3
  32. package/src/Database/DatabaseTransaction.ts +1 -1
  33. package/src/Database/index.ts +0 -5
  34. package/src/Database/integrations/kysely/KyselyDatabase.ts +1 -1
  35. package/src/Database/integrations/pgsql/PostgresDatabase.ts +1 -1
  36. package/src/Database/types.ts +6 -16
  37. package/src/Server/lib/Server.ts +4 -1
  38. package/src/Validation/Validator.ts +2 -1
  39. package/tests/Database/DatabaseManager.test.ts +1 -24
  40. package/tests/Database/integrations/knex/KnexTransaction.test.ts +1 -1
  41. package/tests/Database/integrations/kysely/KyselyTransaction.test.ts +1 -1
  42. package/tests/Database/integrations/pg/PostgresTransaction.test.ts +1 -1
  43. package/tests/Server/RouteResolver.test.ts +18 -4
  44. package/tests/Validation/Validator.test.ts +6 -0
  45. package/dist/src/Database/integrations/dynamo/DynamoDatabase.d.ts +0 -10
  46. package/dist/src/Database/integrations/dynamo/DynamoDatabase.js +0 -37
  47. package/dist/src/Database/integrations/dynamo/DynamoDatabase.js.map +0 -1
  48. package/dist/src/Database/integrations/dynamo/DynamoTransaction.d.ts +0 -12
  49. package/dist/src/Database/integrations/dynamo/DynamoTransaction.js +0 -30
  50. package/dist/src/Database/integrations/dynamo/DynamoTransaction.js.map +0 -1
  51. package/src/Database/integrations/dynamo/DynamoDatabase.ts +0 -33
@@ -2,7 +2,7 @@ import { HttpMethod } from '../../src/API/Request.js'
2
2
  import { Route } from '../../src/Server/Router.js'
3
3
  import RouteResolver from '../../src/Server/RouteResolver.js'
4
4
 
5
- const mockRoute = (method: HttpMethod, path: string) =>
5
+ const mockRoute = (method: HttpMethod, path: string | string[]) =>
6
6
  ({
7
7
  method: method,
8
8
  path: path,
@@ -55,6 +55,20 @@ describe('RouteResolver', () => {
55
55
  )
56
56
  })
57
57
 
58
+ test('multi matching', () => {
59
+ parameterizedTest(
60
+ {
61
+ getA: mockRoute(HttpMethod.GET, ['/a', '/b']),
62
+ variable: mockRoute(HttpMethod.GET, '/:a'),
63
+ },
64
+ routes => [
65
+ [HttpMethod.GET, '/a', routes.getA],
66
+ [HttpMethod.GET, '/b', routes.getA],
67
+ [HttpMethod.GET, '/c', routes.variable],
68
+ ]
69
+ )
70
+ })
71
+
58
72
  test('path variables', () => {
59
73
  parameterizedTest(
60
74
  {
@@ -80,8 +94,8 @@ describe('RouteResolver', () => {
80
94
  () =>
81
95
  new RouteResolver({
82
96
  routes: [
83
- mockRoute(HttpMethod.GET, '/a/b/c/:d/:e/b'),
84
- mockRoute(HttpMethod.GET, '/a/b/c/:jshj/:e/b'),
97
+ mockRoute(HttpMethod.GET, '/a/b/c/:d/:e/b') as any,
98
+ mockRoute(HttpMethod.GET, '/a/b/c/:jshj/:e/b') as any,
85
99
  ],
86
100
  })
87
101
  ).toThrowError('Duplicate route: GET: /a/b/c/:jshj/:e/b')
@@ -93,7 +107,7 @@ const parameterizedTest = <T extends { [k: string]: Route }>(
93
107
  tests: (routes: T) => [HttpMethod, string, Route?][]
94
108
  ) => {
95
109
  const underTest = new RouteResolver({
96
- routes: Object.values(routes),
110
+ routes: Object.values(routes) as any,
97
111
  })
98
112
 
99
113
  tests(routes).forEach(([method, path, expected]) =>
@@ -1,4 +1,5 @@
1
1
  import { expect } from 'chai'
2
+ import { z } from 'zod'
2
3
 
3
4
  import Response from '../../src/API/Response.js'
4
5
  import Globals from '../../src/Globals.js'
@@ -71,6 +72,11 @@ describe('Validates successfully', () => {
71
72
  expect(validationResult).to.not.be.an.instanceof(Response)
72
73
  expect(validationResult).to.be.true
73
74
  })
75
+ test('Succeeds to validate null schema', () => {
76
+ const validationResult = Validator.validateSchema(null, ViewSchema.or(z.null()))
77
+ expect(validationResult).to.not.be.an.instanceof(Response)
78
+ expect(validationResult).to.be.true
79
+ })
74
80
  })
75
81
 
76
82
  export {}
@@ -1,10 +0,0 @@
1
- import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
2
- import { Database } from '../../Database.js';
3
- import type { DbConfig } from '../../types.js';
4
- export declare class DynamoDatabase extends Database<any> {
5
- private static dynamoProvider;
6
- readonly client: DynamoDBClient;
7
- constructor(config: DbConfig<'dynamo'>);
8
- transaction(): Promise<any>;
9
- private providerFactory;
10
- }
@@ -1,37 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { Agent } from 'https';
11
- import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
12
- import { NodeHttpHandler } from '@smithy/node-http-handler';
13
- import { Database } from '../../Database.js';
14
- export class DynamoDatabase extends Database {
15
- constructor(config) {
16
- super(config);
17
- this.client = this.providerFactory(config);
18
- }
19
- transaction() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- return Promise.resolve(null);
22
- });
23
- }
24
- providerFactory(config) {
25
- return new DynamoDatabase.dynamoProvider({
26
- region: config.region,
27
- maxAttempts: config.maxAttempts,
28
- requestHandler: new NodeHttpHandler({
29
- connectionTimeout: config.connectionTimeout,
30
- socketTimeout: config.connectionTimeout,
31
- httpsAgent: new Agent({ keepAlive: false, maxSockets: 50, rejectUnauthorized: true }),
32
- }),
33
- });
34
- }
35
- }
36
- DynamoDatabase.dynamoProvider = DynamoDBClient;
37
- //# sourceMappingURL=DynamoDatabase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamoDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/dynamo/DynamoDatabase.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAG5C,MAAM,OAAO,cAAe,SAAQ,QAAa;IAI/C,YAAmB,MAA0B;QAC3C,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;IAC5C,CAAC;IAEqB,WAAW;;YAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;KAAA;IAEO,eAAe,CAAC,MAA0B;QAChD,OAAO,IAAI,cAAc,CAAC,cAAc,CAAC;YACvC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,cAAc,EAAE,IAAI,eAAe,CAAC;gBAClC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,aAAa,EAAE,MAAM,CAAC,iBAAiB;gBACvC,UAAU,EAAE,IAAI,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;aACtF,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;;AAtBc,6BAAc,GAAG,cAAc,CAAA"}
@@ -1,12 +0,0 @@
1
- import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
2
- import { DynamoDatabase } from './DynamoDatabase.js';
3
- import { DatabaseTransaction } from '../../DatabaseTransaction.js';
4
- export declare class DynamoTransaction extends DatabaseTransaction {
5
- readonly writer: DynamoDBClient;
6
- protected database: DynamoDatabase;
7
- private constructor();
8
- static newTransaction(writer: DynamoDBClient, database: DynamoDatabase): Promise<DynamoTransaction>;
9
- protected doBegin: () => Promise<void>;
10
- protected doCommit: () => Promise<void>;
11
- protected doRollback: () => Promise<void>;
12
- }
@@ -1,30 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { DatabaseTransaction } from '../../DatabaseTransaction.js';
11
- export class DynamoTransaction extends DatabaseTransaction {
12
- constructor(writer, database) {
13
- super(writer, database);
14
- this.doBegin = () => __awaiter(this, void 0, void 0, function* () { });
15
- this.doCommit = () => {
16
- return Promise.resolve();
17
- };
18
- this.doRollback = () => {
19
- return Promise.resolve();
20
- };
21
- }
22
- static newTransaction(writer, database) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const tx = new DynamoTransaction(writer, database);
25
- yield tx.begin(); // defaults to opened
26
- return DatabaseTransaction.proxyInstance(tx);
27
- });
28
- }
29
- }
30
- //# sourceMappingURL=DynamoTransaction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamoTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/dynamo/DynamoTransaction.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAElE,MAAM,OAAO,iBAAkB,SAAQ,mBAAmB;IAGxD,YAAoB,MAAsB,EAAE,QAAwB;QAClE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAYf,YAAO,GAAG,GAAS,EAAE,gDAAE,CAAC,CAAA,CAAA;QACxB,aAAQ,GAAG,GAAG,EAAE;YACxB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC,CAAA;QACS,eAAU,GAAG,GAAG,EAAE;YAC1B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC,CAAA;IAjBD,CAAC;IAEM,MAAM,CAAO,cAAc,CAChC,MAAsB,EACtB,QAAwB;;YAExB,MAAM,EAAE,GAAG,IAAI,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YAClD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA,CAAC,qBAAqB;YACtC,OAAO,mBAAmB,CAAC,aAAa,CAAC,EAAE,CAAQ,CAAA;QACrD,CAAC;KAAA;CASF"}
@@ -1,33 +0,0 @@
1
- import { Agent } from 'https'
2
-
3
- import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
4
- import { NodeHttpHandler } from '@smithy/node-http-handler'
5
-
6
- import { Database } from '../../Database.js'
7
- import type { DbConfig } from '../../types.js'
8
-
9
- export class DynamoDatabase extends Database<any> {
10
- private static dynamoProvider = DynamoDBClient
11
- public readonly client: DynamoDBClient
12
-
13
- public constructor(config: DbConfig<'dynamo'>) {
14
- super(config)
15
- this.client = this.providerFactory(config)
16
- }
17
-
18
- public override async transaction(): Promise<any> {
19
- return Promise.resolve(null)
20
- }
21
-
22
- private providerFactory(config: DbConfig<'dynamo'>) {
23
- return new DynamoDatabase.dynamoProvider({
24
- region: config.region,
25
- maxAttempts: config.maxAttempts || 3,
26
- requestHandler: new NodeHttpHandler({
27
- connectionTimeout: config.connectionTimeout || 60,
28
- socketTimeout: config.connectionTimeout || 60,
29
- httpsAgent: new Agent({ keepAlive: false, maxSockets: 50, rejectUnauthorized: true }),
30
- }),
31
- })
32
- }
33
- }