@cedarjs/api 9.0.0-canary.1784 → 9.0.0-canary.3124

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 (137) hide show
  1. package/dist/auth/index.d.ts +14 -1
  2. package/dist/auth/index.d.ts.map +1 -1
  3. package/dist/auth/index.js +19 -5
  4. package/dist/bins/cedar.js +14 -0
  5. package/dist/bins/cfw.js +14 -0
  6. package/dist/bins/redwood.js +14 -0
  7. package/dist/bins/tsc.js +8 -0
  8. package/dist/cache/clients/RedisClient.d.ts.map +1 -1
  9. package/dist/cache/index.d.ts.map +1 -1
  10. package/dist/cache/index.js +8 -4
  11. package/dist/errors.d.ts +9 -1
  12. package/dist/errors.d.ts.map +1 -1
  13. package/dist/errors.js +9 -2
  14. package/dist/index.d.ts +5 -4
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +5 -19
  17. package/dist/logger/index.d.ts +7 -5
  18. package/dist/logger/index.d.ts.map +1 -1
  19. package/dist/logger/index.js +1 -1
  20. package/dist/runtime.d.ts +48 -0
  21. package/dist/runtime.d.ts.map +1 -0
  22. package/dist/runtime.js +131 -0
  23. package/dist/signedTokens/index.d.ts +2 -0
  24. package/dist/signedTokens/index.d.ts.map +1 -0
  25. package/dist/signedTokens/index.js +1 -0
  26. package/dist/signedTokens/signedTokens.d.ts +99 -0
  27. package/dist/signedTokens/signedTokens.d.ts.map +1 -0
  28. package/dist/signedTokens/signedTokens.js +100 -0
  29. package/dist/transforms.d.ts +1 -0
  30. package/dist/transforms.d.ts.map +1 -1
  31. package/dist/transforms.js +82 -1
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/validations/validations.d.ts +21 -8
  34. package/dist/validations/validations.d.ts.map +1 -1
  35. package/dist/validations/validations.js +16 -14
  36. package/package.json +35 -46
  37. package/LICENSE +0 -21
  38. package/dist/cjs/auth/index.d.ts +0 -51
  39. package/dist/cjs/auth/index.d.ts.map +0 -1
  40. package/dist/cjs/auth/index.js +0 -129
  41. package/dist/cjs/auth/parseJWT.d.ts +0 -6
  42. package/dist/cjs/auth/parseJWT.d.ts.map +0 -1
  43. package/dist/cjs/auth/parseJWT.js +0 -57
  44. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +0 -18
  45. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +0 -1
  46. package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +0 -77
  47. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +0 -18
  48. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +0 -1
  49. package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +0 -77
  50. package/dist/cjs/auth/verifiers/common.d.ts +0 -112
  51. package/dist/cjs/auth/verifiers/common.d.ts.map +0 -1
  52. package/dist/cjs/auth/verifiers/common.js +0 -89
  53. package/dist/cjs/auth/verifiers/index.d.ts +0 -8
  54. package/dist/cjs/auth/verifiers/index.d.ts.map +0 -1
  55. package/dist/cjs/auth/verifiers/index.js +0 -39
  56. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +0 -18
  57. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +0 -1
  58. package/dist/cjs/auth/verifiers/jwtVerifier.js +0 -84
  59. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +0 -11
  60. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +0 -1
  61. package/dist/cjs/auth/verifiers/secretKeyVerifier.js +0 -43
  62. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +0 -17
  63. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +0 -1
  64. package/dist/cjs/auth/verifiers/sha1Verifier.js +0 -85
  65. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +0 -17
  66. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +0 -1
  67. package/dist/cjs/auth/verifiers/sha256Verifier.js +0 -85
  68. package/dist/cjs/auth/verifiers/skipVerifier.d.ts +0 -11
  69. package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +0 -1
  70. package/dist/cjs/auth/verifiers/skipVerifier.js +0 -40
  71. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +0 -14
  72. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +0 -1
  73. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +0 -86
  74. package/dist/cjs/bins/cedar.d.ts +0 -9
  75. package/dist/cjs/bins/cedar.d.ts.map +0 -1
  76. package/dist/cjs/bins/cedar.js +0 -36
  77. package/dist/cjs/bins/cfw.d.ts +0 -3
  78. package/dist/cjs/bins/cfw.d.ts.map +0 -1
  79. package/dist/cjs/bins/cfw.js +0 -36
  80. package/dist/cjs/bins/redwood.d.ts +0 -9
  81. package/dist/cjs/bins/redwood.d.ts.map +0 -1
  82. package/dist/cjs/bins/redwood.js +0 -36
  83. package/dist/cjs/bins/tsc.d.ts +0 -3
  84. package/dist/cjs/bins/tsc.d.ts.map +0 -1
  85. package/dist/cjs/bins/tsc.js +0 -30
  86. package/dist/cjs/cache/clients/BaseClient.d.ts +0 -11
  87. package/dist/cjs/cache/clients/BaseClient.d.ts.map +0 -1
  88. package/dist/cjs/cache/clients/BaseClient.js +0 -31
  89. package/dist/cjs/cache/clients/InMemoryClient.d.ts +0 -31
  90. package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +0 -1
  91. package/dist/cjs/cache/clients/InMemoryClient.js +0 -94
  92. package/dist/cjs/cache/clients/MemcachedClient.d.ts +0 -16
  93. package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +0 -1
  94. package/dist/cjs/cache/clients/MemcachedClient.js +0 -79
  95. package/dist/cjs/cache/clients/RedisClient.d.ts +0 -20
  96. package/dist/cjs/cache/clients/RedisClient.d.ts.map +0 -1
  97. package/dist/cjs/cache/clients/RedisClient.js +0 -83
  98. package/dist/cjs/cache/errors.d.ts +0 -4
  99. package/dist/cjs/cache/errors.d.ts.map +0 -1
  100. package/dist/cjs/cache/errors.js +0 -33
  101. package/dist/cjs/cache/index.d.ts +0 -35
  102. package/dist/cjs/cache/index.d.ts.map +0 -1
  103. package/dist/cjs/cache/index.js +0 -171
  104. package/dist/cjs/cors.d.ts +0 -16
  105. package/dist/cjs/cors.d.ts.map +0 -1
  106. package/dist/cjs/cors.js +0 -93
  107. package/dist/cjs/errors.d.ts +0 -5
  108. package/dist/cjs/errors.d.ts.map +0 -1
  109. package/dist/cjs/errors.js +0 -38
  110. package/dist/cjs/event.d.ts +0 -3
  111. package/dist/cjs/event.d.ts.map +0 -1
  112. package/dist/cjs/event.js +0 -34
  113. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +0 -4
  114. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +0 -1
  115. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +0 -72
  116. package/dist/cjs/index.d.ts +0 -15
  117. package/dist/cjs/index.d.ts.map +0 -1
  118. package/dist/cjs/index.js +0 -70
  119. package/dist/cjs/logger/index.d.ts +0 -179
  120. package/dist/cjs/logger/index.d.ts.map +0 -1
  121. package/dist/cjs/logger/index.js +0 -195
  122. package/dist/cjs/package.json +0 -1
  123. package/dist/cjs/transforms.d.ts +0 -35
  124. package/dist/cjs/transforms.d.ts.map +0 -1
  125. package/dist/cjs/transforms.js +0 -98
  126. package/dist/cjs/types.d.ts +0 -25
  127. package/dist/cjs/types.d.ts.map +0 -1
  128. package/dist/cjs/types.js +0 -16
  129. package/dist/cjs/validations/errors.d.ts +0 -101
  130. package/dist/cjs/validations/errors.d.ts.map +0 -1
  131. package/dist/cjs/validations/errors.js +0 -298
  132. package/dist/cjs/validations/validations.d.ts +0 -222
  133. package/dist/cjs/validations/validations.d.ts.map +0 -1
  134. package/dist/cjs/validations/validations.js +0 -351
  135. package/dist/cjs/webhooks/index.d.ts +0 -77
  136. package/dist/cjs/webhooks/index.d.ts.map +0 -1
  137. package/dist/cjs/webhooks/index.js +0 -102
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
- var import_node_module = require("node:module");
26
- var import_node_url = require("node:url");
27
- const cliPackageJsonFileUrl = (0, import_node_url.pathToFileURL)(
28
- require.resolve("@cedarjs/cli/package.json")
29
- );
30
- const requireFromCli = (0, import_node_module.createRequire)(cliPackageJsonFileUrl);
31
- const bins = requireFromCli("./package.json")["bin"];
32
- const cliEntryPointUrl = new URL(bins["cfw"], cliPackageJsonFileUrl);
33
- if (process.env.PROJECT_CWD) {
34
- process.chdir(process.env.PROJECT_CWD);
35
- }
36
- import(cliEntryPointUrl.toString());
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * This file lets users run the Cedar CLI commands inside the /api directory
4
- * in their projects.
5
- * This works because of the "bin" field in the @cedarjs/api package.json file
6
- * that points to this file.
7
- */
8
- export {};
9
- //# sourceMappingURL=redwood.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redwood.d.ts","sourceRoot":"","sources":["../../../src/bins/redwood.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
- var import_node_module = require("node:module");
26
- var import_node_url = require("node:url");
27
- const cliPackageJsonFileUrl = (0, import_node_url.pathToFileURL)(
28
- require.resolve("@cedarjs/cli/package.json")
29
- );
30
- const requireFromCli = (0, import_node_module.createRequire)(cliPackageJsonFileUrl);
31
- const bins = requireFromCli("./package.json")["bin"];
32
- const cliEntryPointUrl = new URL(bins["redwood"], cliPackageJsonFileUrl);
33
- if (process.env.PROJECT_CWD) {
34
- process.chdir(process.env.PROJECT_CWD);
35
- }
36
- import(cliEntryPointUrl.toString());
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=tsc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsc.d.ts","sourceRoot":"","sources":["../../../src/bins/tsc.ts"],"names":[],"mappings":""}
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
- var import_node_module = require("node:module");
26
- const requireFromTypeScript = (0, import_node_module.createRequire)(
27
- require.resolve("typescript/package.json")
28
- );
29
- const bins = requireFromTypeScript("./package.json")["bin"];
30
- requireFromTypeScript(bins["tsc"]);
@@ -1,11 +0,0 @@
1
- export declare abstract class BaseClient {
2
- constructor();
3
- disconnect?(): void | Promise<void>;
4
- abstract connect(): void | Promise<void>;
5
- abstract get(key: string): any;
6
- abstract set(key: string, value: unknown, options: {
7
- expires?: number;
8
- }): Promise<any> | any;
9
- abstract del(key: string): Promise<boolean> | any;
10
- }
11
- //# sourceMappingURL=BaseClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../../../../src/cache/clients/BaseClient.ts"],"names":[],"mappings":"AAAA,8BAAsB,UAAU;;IAK9B,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnC,QAAQ,CAAC,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAGxC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAG9B,QAAQ,CAAC,GAAG,CACV,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,EACd,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAGrB,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG;CAClD"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var BaseClient_exports = {};
20
- __export(BaseClient_exports, {
21
- BaseClient: () => BaseClient
22
- });
23
- module.exports = __toCommonJS(BaseClient_exports);
24
- class BaseClient {
25
- constructor() {
26
- }
27
- }
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- BaseClient
31
- });
@@ -1,31 +0,0 @@
1
- import { BaseClient } from './BaseClient.js';
2
- type CacheOptions = {
3
- expires?: number;
4
- };
5
- export declare class InMemoryClient extends BaseClient {
6
- storage: Record<string, {
7
- expires: number;
8
- value: string;
9
- }>;
10
- constructor(data?: {});
11
- /**
12
- * Special function for testing, only available in InMemoryClient
13
- *
14
- * Returns deserialized content of cache as an array of values (without cache keys)
15
- *
16
- */
17
- get contents(): any[];
18
- disconnect(): Promise<void>;
19
- connect(): Promise<void>;
20
- get(key: string): Promise<any>;
21
- set(key: string, value: unknown, options?: CacheOptions): Promise<boolean>;
22
- del(key: string): Promise<boolean>;
23
- /**
24
- * Special functions for testing, only available in InMemoryClient
25
- */
26
- clear(): Promise<void>;
27
- cacheKeyForValue(value: any): string | null;
28
- isCached(value: any): boolean;
29
- }
30
- export {};
31
- //# sourceMappingURL=InMemoryClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InMemoryClient.d.ts","sourceRoot":"","sources":["../../../../src/cache/clients/InMemoryClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,KAAK,YAAY,GAAG;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,qBAAa,cAAe,SAAQ,UAAU;IAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;gBAG/C,IAAI,KAAK;IAKrB;;;;;OAKG;IACH,IAAI,QAAQ,UAIX;IAGK,UAAU;IACV,OAAO;IAEP,GAAG,CAAC,GAAG,EAAE,MAAM;IAWf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB;IAU3D,GAAG,CAAC,GAAG,EAAE,MAAM;IASrB;;OAEG;IACG,KAAK;IAIX,gBAAgB,CAAC,KAAK,EAAE,GAAG;IAU3B,QAAQ,CAAC,KAAK,EAAE,GAAG;CAGpB"}
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var InMemoryClient_exports = {};
20
- __export(InMemoryClient_exports, {
21
- InMemoryClient: () => InMemoryClient
22
- });
23
- module.exports = __toCommonJS(InMemoryClient_exports);
24
- var import_BaseClient = require("./BaseClient.js");
25
- class InMemoryClient extends import_BaseClient.BaseClient {
26
- storage;
27
- // initialize with pre-cached data if needed
28
- constructor(data = {}) {
29
- super();
30
- this.storage = data;
31
- }
32
- /**
33
- * Special function for testing, only available in InMemoryClient
34
- *
35
- * Returns deserialized content of cache as an array of values (without cache keys)
36
- *
37
- */
38
- get contents() {
39
- return Object.values(this.storage).map(
40
- (cacheObj) => JSON.parse(cacheObj.value)
41
- );
42
- }
43
- // Not needed for InMemoryClient
44
- async disconnect() {
45
- }
46
- async connect() {
47
- }
48
- async get(key) {
49
- const now = /* @__PURE__ */ new Date();
50
- if (this.storage[key] && this.storage[key].expires > now.getTime()) {
51
- return JSON.parse(this.storage[key].value);
52
- } else {
53
- delete this.storage[key];
54
- return null;
55
- }
56
- }
57
- // stores expiration dates as epoch
58
- async set(key, value, options = {}) {
59
- const now = /* @__PURE__ */ new Date();
60
- now.setSeconds(now.getSeconds() + (options?.expires || 31536e4));
61
- const data = { expires: now.getTime(), value: JSON.stringify(value) };
62
- this.storage[key] = data;
63
- return true;
64
- }
65
- async del(key) {
66
- if (this.storage[key]) {
67
- delete this.storage[key];
68
- return true;
69
- } else {
70
- return false;
71
- }
72
- }
73
- /**
74
- * Special functions for testing, only available in InMemoryClient
75
- */
76
- async clear() {
77
- this.storage = {};
78
- }
79
- cacheKeyForValue(value) {
80
- for (const [cacheKey, cacheObj] of Object.entries(this.storage)) {
81
- if (cacheObj.value === JSON.stringify(value)) {
82
- return cacheKey;
83
- }
84
- }
85
- return null;
86
- }
87
- isCached(value) {
88
- return !!this.cacheKeyForValue(value);
89
- }
90
- }
91
- // Annotate the CommonJS export names for ESM import in node:
92
- 0 && (module.exports = {
93
- InMemoryClient
94
- });
@@ -1,16 +0,0 @@
1
- import type { Client as ClientType, ClientOptions, ServerOptions } from 'memjs';
2
- import { BaseClient } from './BaseClient.js';
3
- export declare class MemcachedClient extends BaseClient {
4
- client?: ClientType | null;
5
- servers: string;
6
- options: (ClientOptions<string | Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike> | null> & ServerOptions) | undefined;
7
- constructor(servers: string, options?: ClientOptions & ServerOptions);
8
- connect(): Promise<void>;
9
- disconnect(): Promise<void>;
10
- get(key: string): Promise<any>;
11
- set(key: string, value: unknown, options: {
12
- expires?: number;
13
- }): Promise<boolean | undefined>;
14
- del(key: string): Promise<boolean | undefined>;
15
- }
16
- //# sourceMappingURL=MemcachedClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MemcachedClient.d.ts","sourceRoot":"","sources":["../../../../src/cache/clients/MemcachedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC1B,OAAO,SAAA;IACP,OAAO,gHAAA;gBAEK,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa;IAM9D,OAAO;IAKP,UAAU;IAKV,GAAG,CAAC,GAAG,EAAE,MAAM;IAcf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAQ9D,GAAG,CAAC,GAAG,EAAE,MAAM;CAQtB"}
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var MemcachedClient_exports = {};
30
- __export(MemcachedClient_exports, {
31
- MemcachedClient: () => MemcachedClient
32
- });
33
- module.exports = __toCommonJS(MemcachedClient_exports);
34
- var import_BaseClient = require("./BaseClient.js");
35
- class MemcachedClient extends import_BaseClient.BaseClient {
36
- client;
37
- servers;
38
- options;
39
- constructor(servers, options) {
40
- super();
41
- this.servers = servers;
42
- this.options = options;
43
- }
44
- async connect() {
45
- const { Client: MemCachedClient } = await import("memjs");
46
- this.client = MemCachedClient.create(this.servers, this.options);
47
- }
48
- async disconnect() {
49
- this.client?.close();
50
- this.client = null;
51
- }
52
- async get(key) {
53
- if (!this.client) {
54
- await this.connect();
55
- }
56
- const result = await this.client?.get(key);
57
- if (result?.value) {
58
- return JSON.parse(result.value.toString());
59
- } else {
60
- return result?.value;
61
- }
62
- }
63
- async set(key, value, options) {
64
- if (!this.client) {
65
- await this.connect();
66
- }
67
- return this.client?.set(key, JSON.stringify(value), options);
68
- }
69
- async del(key) {
70
- if (!this.client) {
71
- await this.connect();
72
- }
73
- return this.client?.delete(key);
74
- }
75
- }
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
78
- MemcachedClient
79
- });
@@ -1,20 +0,0 @@
1
- import type { RedisClientType, RedisClientOptions } from 'redis';
2
- import type { Logger } from '../../logger/index.js';
3
- import { BaseClient } from './BaseClient.js';
4
- type LoggerOptions = {
5
- logger?: Logger;
6
- };
7
- export declare class RedisClient extends BaseClient {
8
- client?: RedisClientType | null;
9
- logger?: Logger;
10
- redisOptions?: RedisClientOptions;
11
- constructor(options: RedisClientOptions & LoggerOptions);
12
- connect(): Promise<void>;
13
- get(key: string): Promise<any>;
14
- set(key: string, value: unknown, options: {
15
- expires?: number;
16
- }): Promise<string | null | undefined>;
17
- del(key: string): Promise<boolean>;
18
- }
19
- export {};
20
- //# sourceMappingURL=RedisClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RedisClient.d.ts","sourceRoot":"","sources":["../../../../src/cache/clients/RedisClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAM5C,KAAK,aAAa,GAAG;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,qBAAa,WAAY,SAAQ,UAAU;IACzC,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,kBAAkB,CAAA;gBAErB,OAAO,EAAE,kBAAkB,GAAG,aAAa;IAQjD,OAAO;IAiBP,GAAG,CAAC,GAAG,EAAE,MAAM;IAUf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAc9D,GAAG,CAAC,GAAG,EAAE,MAAM;CAQtB"}
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var RedisClient_exports = {};
30
- __export(RedisClient_exports, {
31
- RedisClient: () => RedisClient
32
- });
33
- module.exports = __toCommonJS(RedisClient_exports);
34
- var import_BaseClient = require("./BaseClient.js");
35
- class RedisClient extends import_BaseClient.BaseClient {
36
- client;
37
- logger;
38
- redisOptions;
39
- constructor(options) {
40
- const { logger, ...redisOptions } = options;
41
- super();
42
- this.logger = logger;
43
- this.redisOptions = redisOptions;
44
- }
45
- async connect() {
46
- const { createClient } = await import("redis");
47
- this.client = createClient(this.redisOptions);
48
- this.client.on(
49
- "error",
50
- (err) => this.logger?.error(err) || console.error(err)
51
- );
52
- await this.client.connect();
53
- }
54
- // @NOTE: disconnect intentionally not implemented for Redis
55
- // Because node-redis recovers gracefully from connection loss
56
- async get(key) {
57
- if (!this.client) {
58
- await this.connect();
59
- }
60
- const result = await this.client?.get(key);
61
- return result ? JSON.parse(result) : null;
62
- }
63
- async set(key, value, options) {
64
- const setOptions = {};
65
- if (!this.client) {
66
- await this.connect();
67
- }
68
- if (options.expires) {
69
- setOptions.EX = options.expires;
70
- }
71
- return this.client?.set(key, JSON.stringify(value), setOptions);
72
- }
73
- async del(key) {
74
- if (!this.client) {
75
- await this.connect();
76
- }
77
- return !!await this.client?.del([key]);
78
- }
79
- }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- RedisClient
83
- });
@@ -1,4 +0,0 @@
1
- export declare class CacheTimeoutError extends Error {
2
- constructor();
3
- }
4
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/cache/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAkB,SAAQ,KAAK;;CAK3C"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var errors_exports = {};
20
- __export(errors_exports, {
21
- CacheTimeoutError: () => CacheTimeoutError
22
- });
23
- module.exports = __toCommonJS(errors_exports);
24
- class CacheTimeoutError extends Error {
25
- constructor() {
26
- super("Timed out waiting for response from the cache server");
27
- this.name = "CacheTimeoutError";
28
- }
29
- }
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- CacheTimeoutError
33
- });
@@ -1,35 +0,0 @@
1
- import type { Logger } from '../logger/index.js';
2
- import type { BaseClient } from './clients/BaseClient.js';
3
- export { MemcachedClient } from './clients/MemcachedClient.js';
4
- export { RedisClient } from './clients/RedisClient.js';
5
- export { InMemoryClient } from './clients/InMemoryClient.js';
6
- export interface CreateCacheOptions {
7
- logger?: Logger;
8
- timeout?: number;
9
- prefix?: string;
10
- fields?: {
11
- id: string;
12
- updatedAt: string;
13
- };
14
- }
15
- export interface CacheOptions {
16
- expires?: number;
17
- }
18
- export interface CacheFindManyOptions<TFindManyArgs extends Record<string, unknown>> extends CacheOptions {
19
- conditions?: TFindManyArgs;
20
- }
21
- export type CacheKey = string | string[];
22
- export type LatestQuery = Record<string, unknown>;
23
- type GenericDelegate = {
24
- findMany: (...args: any) => any;
25
- findFirst: (...args: any) => any;
26
- };
27
- export declare const cacheKeySeparator = "-";
28
- export declare const formatCacheKey: (key: CacheKey, prefix?: string) => string;
29
- export declare const createCache: (cacheClient: BaseClient, options?: CreateCacheOptions) => {
30
- cache: <TResult>(key: CacheKey, input: () => TResult | Promise<TResult>, options?: CacheOptions) => Promise<any>;
31
- cacheFindMany: <TDelegate extends GenericDelegate>(key: CacheKey, model: TDelegate, options?: CacheFindManyOptions<Parameters<TDelegate["findMany"]>[0]>) => Promise<any>;
32
- cacheClient: BaseClient;
33
- deleteCacheKey: (key: CacheKey) => Promise<any>;
34
- };
35
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE5D,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,oBAAoB,CACnC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C,SAAQ,YAAY;IACpB,UAAU,CAAC,EAAE,aAAa,CAAA;CAC3B;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AACxC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjD,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;IAC/B,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;CACjC,CAAA;AAQD,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,eAAO,MAAM,cAAc,GAAI,KAAK,QAAQ,EAAE,SAAS,MAAM,WAkB5D,CAAA;AAMD,eAAO,MAAM,WAAW,GACtB,aAAa,UAAU,EACvB,UAAU,kBAAkB;YAQP,OAAO,OACrB,QAAQ,SACN,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,YAC7B,YAAY,KACrB,OAAO,CAAC,GAAG,CAAC;oBAqDc,SAAS,SAAS,eAAe,OACvD,QAAQ,SACN,SAAS,YACP,oBAAoB,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;0BAgDlC,QAAQ;CA0B5C,CAAA"}