@webiny/utils 6.3.0-beta.4 → 6.4.0-beta.0

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 (67) hide show
  1. package/GenericRecord.js +0 -3
  2. package/cacheKey.js +10 -12
  3. package/cacheKey.js.map +1 -1
  4. package/compose.js +23 -32
  5. package/compose.js.map +1 -1
  6. package/createIdentifier.js +4 -14
  7. package/createIdentifier.js.map +1 -1
  8. package/createZodError.js +22 -27
  9. package/createZodError.js.map +1 -1
  10. package/cursor.js +20 -25
  11. package/cursor.js.map +1 -1
  12. package/exception.js +8 -13
  13. package/exception.js.map +1 -1
  14. package/executeWithRetry.js +11 -10
  15. package/executeWithRetry.js.map +1 -1
  16. package/exports/api.js +0 -2
  17. package/features/compression/CompressionHandler.js +21 -27
  18. package/features/compression/CompressionHandler.js.map +1 -1
  19. package/features/compression/GzipCompression.js +21 -20
  20. package/features/compression/GzipCompression.js.map +1 -1
  21. package/features/compression/JsonpackCompression.js +21 -23
  22. package/features/compression/JsonpackCompression.js.map +1 -1
  23. package/features/compression/abstractions/Compression.js +2 -1
  24. package/features/compression/abstractions/Compression.js.map +1 -1
  25. package/features/compression/abstractions/CompressionHandler.js +2 -1
  26. package/features/compression/abstractions/CompressionHandler.js.map +1 -1
  27. package/features/compression/feature.js +8 -7
  28. package/features/compression/feature.js.map +1 -1
  29. package/features/compression/legacy/CompressionPlugin.js +5 -2
  30. package/features/compression/legacy/CompressionPlugin.js.map +1 -1
  31. package/features/compression/legacy/Compressor.js +41 -53
  32. package/features/compression/legacy/Compressor.js.map +1 -1
  33. package/features/compression/legacy/gzip.js +12 -21
  34. package/features/compression/legacy/gzip.js.map +1 -1
  35. package/features/compression/legacy/index.js +0 -2
  36. package/features/compression/legacy/jsonpack.js +5 -8
  37. package/features/compression/legacy/jsonpack.js.map +1 -1
  38. package/features/compression/legacy/plugins/GzipCompression.js +52 -45
  39. package/features/compression/legacy/plugins/GzipCompression.js.map +1 -1
  40. package/features/compression/legacy/plugins/JsonpackCompression.js +32 -41
  41. package/features/compression/legacy/plugins/JsonpackCompression.js.map +1 -1
  42. package/generateId.js +7 -8
  43. package/generateId.js.map +1 -1
  44. package/getObjectProperties.js +7 -12
  45. package/getObjectProperties.js.map +1 -1
  46. package/headers.js +9 -13
  47. package/headers.js.map +1 -1
  48. package/index.js +1 -4
  49. package/mdbid.js +3 -4
  50. package/mdbid.js.map +1 -1
  51. package/middleware.js +25 -37
  52. package/middleware.js.map +1 -1
  53. package/package.json +8 -8
  54. package/parseIdentifier.js +16 -26
  55. package/parseIdentifier.js.map +1 -1
  56. package/removeNullValues.js +5 -9
  57. package/removeNullValues.js.map +1 -1
  58. package/removeUndefinedValues.js +5 -9
  59. package/removeUndefinedValues.js.map +1 -1
  60. package/utcTimezones.js +159 -118
  61. package/utcTimezones.js.map +1 -1
  62. package/zeroPad.js +2 -7
  63. package/zeroPad.js.map +1 -1
  64. package/GenericRecord.js.map +0 -1
  65. package/exports/api.js.map +0 -1
  66. package/features/compression/legacy/index.js.map +0 -1
  67. package/index.js.map +0 -1
package/GenericRecord.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=GenericRecord.js.map
package/cacheKey.js CHANGED
@@ -1,17 +1,15 @@
1
1
  import { sha256 } from "@noble/hashes/sha2.js";
2
- import { utf8ToBytes, bytesToHex } from "@noble/hashes/utils.js";
3
- const getCacheKey = input => {
4
- if (typeof input === "string") {
5
- return input;
6
- } else if (typeof input === "number") {
7
- return `${input}`;
8
- }
9
- return JSON.stringify(input);
2
+ import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
3
+ const getCacheKey = (input)=>{
4
+ if ("string" == typeof input) return input;
5
+ if ("number" == typeof input) return `${input}`;
6
+ return JSON.stringify(input);
10
7
  };
11
- export const createCacheKey = input => {
12
- const key = getCacheKey(input);
13
- const hash = sha256(utf8ToBytes(key));
14
- return bytesToHex(hash);
8
+ const createCacheKey = (input)=>{
9
+ const key = getCacheKey(input);
10
+ const hash = sha256(utf8ToBytes(key));
11
+ return bytesToHex(hash);
15
12
  };
13
+ export { createCacheKey };
16
14
 
17
15
  //# sourceMappingURL=cacheKey.js.map
package/cacheKey.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["sha256","utf8ToBytes","bytesToHex","getCacheKey","input","JSON","stringify","createCacheKey","key","hash"],"sources":["cacheKey.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { utf8ToBytes, bytesToHex } from \"@noble/hashes/utils.js\";\n\nexport type ICacheKeyKeys = Record<string, any> | string | number;\n\nconst getCacheKey = (input: ICacheKeyKeys): string => {\n if (typeof input === \"string\") {\n return input;\n } else if (typeof input === \"number\") {\n return `${input}`;\n }\n return JSON.stringify(input);\n};\n\nexport const createCacheKey = (input: ICacheKeyKeys): string => {\n const key = getCacheKey(input);\n\n const hash = sha256(utf8ToBytes(key));\n\n return bytesToHex(hash);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,EAAEC,UAAU,QAAQ,wBAAwB;AAIhE,MAAMC,WAAW,GAAIC,KAAoB,IAAa;EAClD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAO,GAAGA,KAAK,EAAE;EACrB;EACA,OAAOC,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC;AAChC,CAAC;AAED,OAAO,MAAMG,cAAc,GAAIH,KAAoB,IAAa;EAC5D,MAAMI,GAAG,GAAGL,WAAW,CAACC,KAAK,CAAC;EAE9B,MAAMK,IAAI,GAAGT,MAAM,CAACC,WAAW,CAACO,GAAG,CAAC,CAAC;EAErC,OAAON,UAAU,CAACO,IAAI,CAAC;AAC3B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"cacheKey.js","sources":["../src/cacheKey.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { utf8ToBytes, bytesToHex } from \"@noble/hashes/utils.js\";\n\nexport type ICacheKeyKeys = Record<string, any> | string | number;\n\nconst getCacheKey = (input: ICacheKeyKeys): string => {\n if (typeof input === \"string\") {\n return input;\n } else if (typeof input === \"number\") {\n return `${input}`;\n }\n return JSON.stringify(input);\n};\n\nexport const createCacheKey = (input: ICacheKeyKeys): string => {\n const key = getCacheKey(input);\n\n const hash = sha256(utf8ToBytes(key));\n\n return bytesToHex(hash);\n};\n"],"names":["getCacheKey","input","JSON","createCacheKey","key","hash","sha256","utf8ToBytes","bytesToHex"],"mappings":";;AAKA,MAAMA,cAAc,CAACC;IACjB,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAOA;IACJ,IAAI,AAAiB,YAAjB,OAAOA,OACd,OAAO,GAAGA,OAAO;IAErB,OAAOC,KAAK,SAAS,CAACD;AAC1B;AAEO,MAAME,iBAAiB,CAACF;IAC3B,MAAMG,MAAMJ,YAAYC;IAExB,MAAMI,OAAOC,OAAOC,YAAYH;IAEhC,OAAOI,WAAWH;AACtB"}
package/compose.js CHANGED
@@ -1,38 +1,29 @@
1
- export function composeAsync(functions = []) {
2
- return input => {
3
- if (!functions.length) {
4
- return Promise.resolve(input);
5
- }
6
- let index = -1;
7
- const next = async input => {
8
- index++;
9
- const fn = functions[index];
10
- if (!fn) {
11
- return input;
12
- }
13
- return fn(next)(input);
1
+ function composeAsync(functions = []) {
2
+ return (input)=>{
3
+ if (!functions.length) return Promise.resolve(input);
4
+ let index = -1;
5
+ const next = async (input)=>{
6
+ index++;
7
+ const fn = functions[index];
8
+ if (!fn) return input;
9
+ return fn(next)(input);
10
+ };
11
+ return next(input);
14
12
  };
15
- return next(input);
16
- };
17
13
  }
18
- export function composeSync(functions = []) {
19
- return input => {
20
- if (!functions.length) {
21
- return input;
22
- }
23
-
24
- // Create a clone of function chain to prevent modifying the original array with `shift()`
25
- let index = -1;
26
- const next = input => {
27
- index++;
28
- const fn = functions[index];
29
- if (!fn) {
30
- return input;
31
- }
32
- return fn(next)(input);
14
+ function composeSync(functions = []) {
15
+ return (input)=>{
16
+ if (!functions.length) return input;
17
+ let index = -1;
18
+ const next = (input)=>{
19
+ index++;
20
+ const fn = functions[index];
21
+ if (!fn) return input;
22
+ return fn(next)(input);
23
+ };
24
+ return next(input);
33
25
  };
34
- return next(input);
35
- };
36
26
  }
27
+ export { composeAsync, composeSync };
37
28
 
38
29
  //# sourceMappingURL=compose.js.map
package/compose.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["composeAsync","functions","input","length","Promise","resolve","index","next","fn","composeSync"],"sources":["compose.ts"],"sourcesContent":["export interface NextAsyncProcessor<TInput, TOutput> {\n (input: TInput): Promise<TOutput>;\n}\n\nexport interface AsyncProcessor<TInput, TOutput = TInput> {\n (next: NextAsyncProcessor<TInput, TOutput>): NextAsyncProcessor<TInput, TOutput>;\n}\n\nexport interface NextSyncProcessor<TInput, TOutput = TInput> {\n (input: TInput): TOutput;\n}\n\nexport interface SyncProcessor<TInput, TOutput = TInput> {\n (next: NextSyncProcessor<TInput, TOutput>): NextSyncProcessor<TInput, TOutput>;\n}\n\nexport function composeAsync<TInput = unknown, TOutput = TInput>(\n functions: Array<AsyncProcessor<TInput, TOutput>> = []\n): NextAsyncProcessor<TInput, TOutput> {\n return (input: TInput): Promise<TOutput> => {\n if (!functions.length) {\n return Promise.resolve(input as unknown as TOutput);\n }\n\n let index = -1;\n\n const next: NextAsyncProcessor<TInput, TOutput> = async input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n\nexport function composeSync<TInput = unknown, TOutput = TInput>(\n functions: Array<SyncProcessor<TInput, TOutput>> = []\n): NextSyncProcessor<TInput, TOutput> {\n return (input: TInput): TOutput => {\n if (!functions.length) {\n return input as unknown as TOutput;\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n let index = -1;\n\n const next: NextSyncProcessor<TInput, TOutput> = input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n"],"mappings":"AAgBA,OAAO,SAASA,YAAYA,CACxBC,SAAiD,GAAG,EAAE,EACnB;EACnC,OAAQC,KAAa,IAAuB;IACxC,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOC,OAAO,CAACC,OAAO,CAACH,KAA2B,CAAC;IACvD;IAEA,IAAII,KAAK,GAAG,CAAC,CAAC;IAEd,MAAMC,IAAyC,GAAG,MAAML,KAAK,IAAI;MAC7DI,KAAK,EAAE;MAEP,MAAME,EAAE,GAAGP,SAAS,CAACK,KAAK,CAAC;MAC3B,IAAI,CAACE,EAAE,EAAE;QACL,OAAON,KAAK;MAChB;MAEA,OAAOM,EAAE,CAACD,IAAI,CAAC,CAACL,KAAK,CAAC;IAC1B,CAAC;IAED,OAAOK,IAAI,CAACL,KAAK,CAAC;EACtB,CAAC;AACL;AAEA,OAAO,SAASO,WAAWA,CACvBR,SAAgD,GAAG,EAAE,EACnB;EAClC,OAAQC,KAAa,IAAc;IAC/B,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOD,KAAK;IAChB;;IAEA;IACA,IAAII,KAAK,GAAG,CAAC,CAAC;IAEd,MAAMC,IAAwC,GAAGL,KAAK,IAAI;MACtDI,KAAK,EAAE;MAEP,MAAME,EAAE,GAAGP,SAAS,CAACK,KAAK,CAAC;MAC3B,IAAI,CAACE,EAAE,EAAE;QACL,OAAON,KAAK;MAChB;MAEA,OAAOM,EAAE,CAACD,IAAI,CAAC,CAACL,KAAK,CAAC;IAC1B,CAAC;IAED,OAAOK,IAAI,CAACL,KAAK,CAAC;EACtB,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"compose.js","sources":["../src/compose.ts"],"sourcesContent":["export interface NextAsyncProcessor<TInput, TOutput> {\n (input: TInput): Promise<TOutput>;\n}\n\nexport interface AsyncProcessor<TInput, TOutput = TInput> {\n (next: NextAsyncProcessor<TInput, TOutput>): NextAsyncProcessor<TInput, TOutput>;\n}\n\nexport interface NextSyncProcessor<TInput, TOutput = TInput> {\n (input: TInput): TOutput;\n}\n\nexport interface SyncProcessor<TInput, TOutput = TInput> {\n (next: NextSyncProcessor<TInput, TOutput>): NextSyncProcessor<TInput, TOutput>;\n}\n\nexport function composeAsync<TInput = unknown, TOutput = TInput>(\n functions: Array<AsyncProcessor<TInput, TOutput>> = []\n): NextAsyncProcessor<TInput, TOutput> {\n return (input: TInput): Promise<TOutput> => {\n if (!functions.length) {\n return Promise.resolve(input as unknown as TOutput);\n }\n\n let index = -1;\n\n const next: NextAsyncProcessor<TInput, TOutput> = async input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n\nexport function composeSync<TInput = unknown, TOutput = TInput>(\n functions: Array<SyncProcessor<TInput, TOutput>> = []\n): NextSyncProcessor<TInput, TOutput> {\n return (input: TInput): TOutput => {\n if (!functions.length) {\n return input as unknown as TOutput;\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n let index = -1;\n\n const next: NextSyncProcessor<TInput, TOutput> = input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n"],"names":["composeAsync","functions","input","Promise","index","next","fn","composeSync"],"mappings":"AAgBO,SAASA,aACZC,YAAoD,EAAE;IAEtD,OAAO,CAACC;QACJ,IAAI,CAACD,UAAU,MAAM,EACjB,OAAOE,QAAQ,OAAO,CAACD;QAG3B,IAAIE,QAAQ;QAEZ,MAAMC,OAA4C,OAAMH;YACpDE;YAEA,MAAME,KAAKL,SAAS,CAACG,MAAM;YAC3B,IAAI,CAACE,IACD,OAAOJ;YAGX,OAAOI,GAAGD,MAAMH;QACpB;QAEA,OAAOG,KAAKH;IAChB;AACJ;AAEO,SAASK,YACZN,YAAmD,EAAE;IAErD,OAAO,CAACC;QACJ,IAAI,CAACD,UAAU,MAAM,EACjB,OAAOC;QAIX,IAAIE,QAAQ;QAEZ,MAAMC,OAA2CH,CAAAA;YAC7CE;YAEA,MAAME,KAAKL,SAAS,CAACG,MAAM;YAC3B,IAAI,CAACE,IACD,OAAOJ;YAGX,OAAOI,GAAGD,MAAMH;QACpB;QAEA,OAAOG,KAAKH;IAChB;AACJ"}
@@ -1,19 +1,9 @@
1
1
  import { zeroPad } from "./zeroPad.js";
2
2
  import { parseIdentifier } from "./parseIdentifier.js";
3
-
4
- /**
5
- * Used to create the identifier that is an absolute unique for the record.
6
- * It is created out of the generated ID and version of the record.
7
- *
8
- *
9
- * The input ID is being parsed as you might send a full ID instead of only the generated one.
10
- */
11
-
12
- export const createIdentifier = values => {
13
- const {
14
- id
15
- } = parseIdentifier(values.id);
16
- return `${id}#${zeroPad(values.version)}`;
3
+ const createIdentifier = (values)=>{
4
+ const { id } = parseIdentifier(values.id);
5
+ return `${id}#${zeroPad(values.version)}`;
17
6
  };
7
+ export { createIdentifier };
18
8
 
19
9
  //# sourceMappingURL=createIdentifier.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["zeroPad","parseIdentifier","createIdentifier","values","id","version"],"sources":["createIdentifier.ts"],"sourcesContent":["import { zeroPad } from \"./zeroPad.js\";\nimport { parseIdentifier } from \"./parseIdentifier.js\";\n\n/**\n * Used to create the identifier that is an absolute unique for the record.\n * It is created out of the generated ID and version of the record.\n *\n *\n * The input ID is being parsed as you might send a full ID instead of only the generated one.\n */\nexport interface CreateIdentifierParams {\n id: string;\n version: number;\n}\n\nexport const createIdentifier = (values: CreateIdentifierParams): string => {\n const { id } = parseIdentifier(values.id);\n\n return `${id}#${zeroPad(values.version)}`;\n};\n"],"mappings":"AAAA,SAASA,OAAO;AAChB,SAASC,eAAe;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAa;EACxE,MAAM;IAAEC;EAAG,CAAC,GAAGH,eAAe,CAACE,MAAM,CAACC,EAAE,CAAC;EAEzC,OAAO,GAAGA,EAAE,IAAIJ,OAAO,CAACG,MAAM,CAACE,OAAO,CAAC,EAAE;AAC7C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createIdentifier.js","sources":["../src/createIdentifier.ts"],"sourcesContent":["import { zeroPad } from \"./zeroPad.js\";\nimport { parseIdentifier } from \"./parseIdentifier.js\";\n\n/**\n * Used to create the identifier that is an absolute unique for the record.\n * It is created out of the generated ID and version of the record.\n *\n *\n * The input ID is being parsed as you might send a full ID instead of only the generated one.\n */\nexport interface CreateIdentifierParams {\n id: string;\n version: number;\n}\n\nexport const createIdentifier = (values: CreateIdentifierParams): string => {\n const { id } = parseIdentifier(values.id);\n\n return `${id}#${zeroPad(values.version)}`;\n};\n"],"names":["createIdentifier","values","id","parseIdentifier","zeroPad"],"mappings":";;AAeO,MAAMA,mBAAmB,CAACC;IAC7B,MAAM,EAAEC,EAAE,EAAE,GAAGC,gBAAgBF,OAAO,EAAE;IAExC,OAAO,GAAGC,GAAG,CAAC,EAAEE,QAAQH,OAAO,OAAO,GAAG;AAC7C"}
package/createZodError.js CHANGED
@@ -1,30 +1,25 @@
1
- import WebinyError from "@webiny/error";
1
+ import _webiny_error from "@webiny/error";
2
2
  import { generateAlphaNumericId } from "./generateId.js";
3
- const createValidationErrorData = error => {
4
- return {
5
- invalidFields: error.issues.reduce((collection, issue) => {
6
- const name = issue.path.join(".");
7
- if (!name && !issue.code) {
8
- return collection;
9
- }
10
- const key = name || issue.path.join(".") || issue.message || issue.code || generateAlphaNumericId();
11
- collection[key] = {
12
- code: issue.code,
13
- message: issue.message,
14
- data: {
15
- path: issue.path
16
- }
17
- };
18
- return collection;
19
- }, {})
20
- };
21
- };
22
- export const createZodError = error => {
23
- return new WebinyError({
24
- message: `Validation failed.`,
25
- code: "VALIDATION_FAILED_INVALID_FIELDS",
26
- data: createValidationErrorData(error)
27
- });
28
- };
3
+ const createValidationErrorData = (error)=>({
4
+ invalidFields: error.issues.reduce((collection, issue)=>{
5
+ const name = issue.path.join(".");
6
+ if (!name && !issue.code) return collection;
7
+ const key = name || issue.path.join(".") || issue.message || issue.code || generateAlphaNumericId();
8
+ collection[key] = {
9
+ code: issue.code,
10
+ message: issue.message,
11
+ data: {
12
+ path: issue.path
13
+ }
14
+ };
15
+ return collection;
16
+ }, {})
17
+ });
18
+ const createZodError = (error)=>new _webiny_error({
19
+ message: "Validation failed.",
20
+ code: "VALIDATION_FAILED_INVALID_FIELDS",
21
+ data: createValidationErrorData(error)
22
+ });
23
+ export { createZodError };
29
24
 
30
25
  //# sourceMappingURL=createZodError.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","generateAlphaNumericId","createValidationErrorData","error","invalidFields","issues","reduce","collection","issue","name","path","join","code","key","message","data","createZodError"],"sources":["createZodError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ZodError } from \"zod\";\nimport { generateAlphaNumericId } from \"~/generateId.js\";\n\ninterface OutputError {\n code: string;\n data: Record<string, any> | null;\n message: string;\n}\n\nexport interface OutputErrors {\n [key: string]: OutputError;\n}\n\nconst createValidationErrorData = (error: ZodError) => {\n return {\n invalidFields: error.issues.reduce<OutputErrors>((collection, issue) => {\n const name = issue.path.join(\".\");\n if (!name && !issue.code) {\n return collection;\n }\n\n const key =\n name ||\n issue.path.join(\".\") ||\n issue.message ||\n issue.code ||\n generateAlphaNumericId();\n collection[key] = {\n code: issue.code,\n message: issue.message,\n data: {\n path: issue.path\n }\n };\n\n return collection;\n }, {})\n };\n};\n\nexport const createZodError = (error: ZodError) => {\n return new WebinyError({\n message: `Validation failed.`,\n code: \"VALIDATION_FAILED_INVALID_FIELDS\",\n data: createValidationErrorData(error)\n });\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,sBAAsB;AAY/B,MAAMC,yBAAyB,GAAIC,KAAe,IAAK;EACnD,OAAO;IACHC,aAAa,EAAED,KAAK,CAACE,MAAM,CAACC,MAAM,CAAe,CAACC,UAAU,EAAEC,KAAK,KAAK;MACpE,MAAMC,IAAI,GAAGD,KAAK,CAACE,IAAI,CAACC,IAAI,CAAC,GAAG,CAAC;MACjC,IAAI,CAACF,IAAI,IAAI,CAACD,KAAK,CAACI,IAAI,EAAE;QACtB,OAAOL,UAAU;MACrB;MAEA,MAAMM,GAAG,GACLJ,IAAI,IACJD,KAAK,CAACE,IAAI,CAACC,IAAI,CAAC,GAAG,CAAC,IACpBH,KAAK,CAACM,OAAO,IACbN,KAAK,CAACI,IAAI,IACVX,sBAAsB,CAAC,CAAC;MAC5BM,UAAU,CAACM,GAAG,CAAC,GAAG;QACdD,IAAI,EAAEJ,KAAK,CAACI,IAAI;QAChBE,OAAO,EAAEN,KAAK,CAACM,OAAO;QACtBC,IAAI,EAAE;UACFL,IAAI,EAAEF,KAAK,CAACE;QAChB;MACJ,CAAC;MAED,OAAOH,UAAU;IACrB,CAAC,EAAE,CAAC,CAAC;EACT,CAAC;AACL,CAAC;AAED,OAAO,MAAMS,cAAc,GAAIb,KAAe,IAAK;EAC/C,OAAO,IAAIH,WAAW,CAAC;IACnBc,OAAO,EAAE,oBAAoB;IAC7BF,IAAI,EAAE,kCAAkC;IACxCG,IAAI,EAAEb,yBAAyB,CAACC,KAAK;EACzC,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createZodError.js","sources":["../src/createZodError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ZodError } from \"zod\";\nimport { generateAlphaNumericId } from \"~/generateId.js\";\n\ninterface OutputError {\n code: string;\n data: Record<string, any> | null;\n message: string;\n}\n\nexport interface OutputErrors {\n [key: string]: OutputError;\n}\n\nconst createValidationErrorData = (error: ZodError) => {\n return {\n invalidFields: error.issues.reduce<OutputErrors>((collection, issue) => {\n const name = issue.path.join(\".\");\n if (!name && !issue.code) {\n return collection;\n }\n\n const key =\n name ||\n issue.path.join(\".\") ||\n issue.message ||\n issue.code ||\n generateAlphaNumericId();\n collection[key] = {\n code: issue.code,\n message: issue.message,\n data: {\n path: issue.path\n }\n };\n\n return collection;\n }, {})\n };\n};\n\nexport const createZodError = (error: ZodError) => {\n return new WebinyError({\n message: `Validation failed.`,\n code: \"VALIDATION_FAILED_INVALID_FIELDS\",\n data: createValidationErrorData(error)\n });\n};\n"],"names":["createValidationErrorData","error","collection","issue","name","key","generateAlphaNumericId","createZodError","WebinyError"],"mappings":";;AAcA,MAAMA,4BAA4B,CAACC,QACxB;QACH,eAAeA,MAAM,MAAM,CAAC,MAAM,CAAe,CAACC,YAAYC;YAC1D,MAAMC,OAAOD,MAAM,IAAI,CAAC,IAAI,CAAC;YAC7B,IAAI,CAACC,QAAQ,CAACD,MAAM,IAAI,EACpB,OAAOD;YAGX,MAAMG,MACFD,QACAD,MAAM,IAAI,CAAC,IAAI,CAAC,QAChBA,MAAM,OAAO,IACbA,MAAM,IAAI,IACVG;YACJJ,UAAU,CAACG,IAAI,GAAG;gBACd,MAAMF,MAAM,IAAI;gBAChB,SAASA,MAAM,OAAO;gBACtB,MAAM;oBACF,MAAMA,MAAM,IAAI;gBACpB;YACJ;YAEA,OAAOD;QACX,GAAG,CAAC;IACR;AAGG,MAAMK,iBAAiB,CAACN,QACpB,IAAIO,cAAY;QACnB,SAAS;QACT,MAAM;QACN,MAAMR,0BAA0BC;IACpC"}
package/cursor.js CHANGED
@@ -1,30 +1,25 @@
1
- export const encodeCursor = cursor => {
2
- if (!cursor) {
3
- return null;
4
- }
5
- try {
6
- return Buffer.from(JSON.stringify(cursor)).toString("base64");
7
- } catch (ex) {
8
- console.log("Utils encode cursor.");
9
- console.log(ex.message);
10
- return null;
11
- }
1
+ const encodeCursor = (cursor)=>{
2
+ if (!cursor) return null;
3
+ try {
4
+ return Buffer.from(JSON.stringify(cursor)).toString("base64");
5
+ } catch (ex) {
6
+ console.log("Utils encode cursor.");
7
+ console.log(ex.message);
8
+ return null;
9
+ }
12
10
  };
13
- export const decodeCursor = cursor => {
14
- if (!cursor) {
15
- return null;
16
- }
17
- try {
18
- const value = Buffer.from(cursor, "base64").toString("ascii");
19
- if (!value) {
20
- return null;
11
+ const decodeCursor = (cursor)=>{
12
+ if (!cursor) return null;
13
+ try {
14
+ const value = Buffer.from(cursor, "base64").toString("ascii");
15
+ if (!value) return null;
16
+ return JSON.parse(value);
17
+ } catch (ex) {
18
+ console.log("Utils decode cursor.");
19
+ console.log(ex.message);
20
+ return null;
21
21
  }
22
- return JSON.parse(value);
23
- } catch (ex) {
24
- console.log("Utils decode cursor.");
25
- console.log(ex.message);
26
- return null;
27
- }
28
22
  };
23
+ export { decodeCursor, encodeCursor };
29
24
 
30
25
  //# sourceMappingURL=cursor.js.map
package/cursor.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["encodeCursor","cursor","Buffer","from","JSON","stringify","toString","ex","console","log","message","decodeCursor","value","parse"],"sources":["cursor.ts"],"sourcesContent":["export type CursorInput = string | number | (string | number)[] | null;\nexport type CursorOutput = string | null;\n\nexport const encodeCursor = (cursor?: CursorInput): CursorOutput => {\n if (!cursor) {\n return null;\n }\n\n try {\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n } catch (ex) {\n console.log(\"Utils encode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n\nexport const decodeCursor = (cursor?: CursorOutput): CursorInput => {\n if (!cursor) {\n return null;\n }\n\n try {\n const value = Buffer.from(cursor, \"base64\").toString(\"ascii\");\n if (!value) {\n return null;\n }\n return JSON.parse(value);\n } catch (ex) {\n console.log(\"Utils decode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n"],"mappings":"AAGA,OAAO,MAAMA,YAAY,GAAIC,MAAoB,IAAmB;EAChE,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,IAAI;IACA,OAAOC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACJ,MAAM,CAAC,CAAC,CAACK,QAAQ,CAAC,QAAQ,CAAC;EACjE,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC;IACnCD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;IACvB,OAAO,IAAI;EACf;AACJ,CAAC;AAED,OAAO,MAAMC,YAAY,GAAIV,MAAqB,IAAkB;EAChE,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,IAAI;IACA,MAAMW,KAAK,GAAGV,MAAM,CAACC,IAAI,CAACF,MAAM,EAAE,QAAQ,CAAC,CAACK,QAAQ,CAAC,OAAO,CAAC;IAC7D,IAAI,CAACM,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,OAAOR,IAAI,CAACS,KAAK,CAACD,KAAK,CAAC;EAC5B,CAAC,CAAC,OAAOL,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC;IACnCD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;IACvB,OAAO,IAAI;EACf;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"cursor.js","sources":["../src/cursor.ts"],"sourcesContent":["export type CursorInput = string | number | (string | number)[] | null;\nexport type CursorOutput = string | null;\n\nexport const encodeCursor = (cursor?: CursorInput): CursorOutput => {\n if (!cursor) {\n return null;\n }\n\n try {\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n } catch (ex) {\n console.log(\"Utils encode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n\nexport const decodeCursor = (cursor?: CursorOutput): CursorInput => {\n if (!cursor) {\n return null;\n }\n\n try {\n const value = Buffer.from(cursor, \"base64\").toString(\"ascii\");\n if (!value) {\n return null;\n }\n return JSON.parse(value);\n } catch (ex) {\n console.log(\"Utils decode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n"],"names":["encodeCursor","cursor","Buffer","JSON","ex","console","decodeCursor","value"],"mappings":"AAGO,MAAMA,eAAe,CAACC;IACzB,IAAI,CAACA,QACD,OAAO;IAGX,IAAI;QACA,OAAOC,OAAO,IAAI,CAACC,KAAK,SAAS,CAACF,SAAS,QAAQ,CAAC;IACxD,EAAE,OAAOG,IAAI;QACTC,QAAQ,GAAG,CAAC;QACZA,QAAQ,GAAG,CAACD,GAAG,OAAO;QACtB,OAAO;IACX;AACJ;AAEO,MAAME,eAAe,CAACL;IACzB,IAAI,CAACA,QACD,OAAO;IAGX,IAAI;QACA,MAAMM,QAAQL,OAAO,IAAI,CAACD,QAAQ,UAAU,QAAQ,CAAC;QACrD,IAAI,CAACM,OACD,OAAO;QAEX,OAAOJ,KAAK,KAAK,CAACI;IACtB,EAAE,OAAOH,IAAI;QACTC,QAAQ,GAAG,CAAC;QACZA,QAAQ,GAAG,CAACD,GAAG,OAAO;QACtB,OAAO;IACX;AACJ"}
package/exception.js CHANGED
@@ -1,16 +1,11 @@
1
- /**
2
- * This will help with output of the error object.
3
- * Normally, the error object is not serializable, so we need to convert it to a plain object.
4
- */
5
- export const convertException = (error, remove) => {
6
- const properties = Object.getOwnPropertyNames(error);
7
- return properties.reduce((items, property) => {
8
- if (remove && remove.includes(property)) {
9
- return items;
10
- }
11
- items[property] = error[property];
12
- return items;
13
- }, {});
1
+ const convertException = (error, remove)=>{
2
+ const properties = Object.getOwnPropertyNames(error);
3
+ return properties.reduce((items, property)=>{
4
+ if (remove && remove.includes(property)) return items;
5
+ items[property] = error[property];
6
+ return items;
7
+ }, {});
14
8
  };
9
+ export { convertException };
15
10
 
16
11
  //# sourceMappingURL=exception.js.map
package/exception.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["convertException","error","remove","properties","Object","getOwnPropertyNames","reduce","items","property","includes"],"sources":["exception.ts"],"sourcesContent":["import type { GenericRecord } from \"~/GenericRecord.js\";\n\n/**\n * This will help with output of the error object.\n * Normally, the error object is not serializable, so we need to convert it to a plain object.\n */\nexport const convertException = (error: Error, remove?: string[]): GenericRecord => {\n const properties = Object.getOwnPropertyNames(error) as (keyof Error)[];\n return properties.reduce<GenericRecord>((items, property) => {\n if (remove && remove.includes(property)) {\n return items;\n }\n items[property] = error[property];\n return items;\n }, {});\n};\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAGA,CAACC,KAAY,EAAEC,MAAiB,KAAoB;EAChF,MAAMC,UAAU,GAAGC,MAAM,CAACC,mBAAmB,CAACJ,KAAK,CAAoB;EACvE,OAAOE,UAAU,CAACG,MAAM,CAAgB,CAACC,KAAK,EAAEC,QAAQ,KAAK;IACzD,IAAIN,MAAM,IAAIA,MAAM,CAACO,QAAQ,CAACD,QAAQ,CAAC,EAAE;MACrC,OAAOD,KAAK;IAChB;IACAA,KAAK,CAACC,QAAQ,CAAC,GAAGP,KAAK,CAACO,QAAQ,CAAC;IACjC,OAAOD,KAAK;EAChB,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"exception.js","sources":["../src/exception.ts"],"sourcesContent":["import type { GenericRecord } from \"~/GenericRecord.js\";\n\n/**\n * This will help with output of the error object.\n * Normally, the error object is not serializable, so we need to convert it to a plain object.\n */\nexport const convertException = (error: Error, remove?: string[]): GenericRecord => {\n const properties = Object.getOwnPropertyNames(error) as (keyof Error)[];\n return properties.reduce<GenericRecord>((items, property) => {\n if (remove && remove.includes(property)) {\n return items;\n }\n items[property] = error[property];\n return items;\n }, {});\n};\n"],"names":["convertException","error","remove","properties","Object","items","property"],"mappings":"AAMO,MAAMA,mBAAmB,CAACC,OAAcC;IAC3C,MAAMC,aAAaC,OAAO,mBAAmB,CAACH;IAC9C,OAAOE,WAAW,MAAM,CAAgB,CAACE,OAAOC;QAC5C,IAAIJ,UAAUA,OAAO,QAAQ,CAACI,WAC1B,OAAOD;QAEXA,KAAK,CAACC,SAAS,GAAGL,KAAK,CAACK,SAAS;QACjC,OAAOD;IACX,GAAG,CAAC;AACR"}
@@ -1,13 +1,14 @@
1
- import pRetry from "p-retry";
2
- export const executeWithRetry = (execute, options) => {
3
- const retries = 20;
4
- return pRetry(execute, {
5
- maxRetryTime: 300000,
6
- retries,
7
- minTimeout: 1500,
8
- maxTimeout: 30000,
9
- ...options
10
- });
1
+ import p_retry from "p-retry";
2
+ const executeWithRetry = (execute, options)=>{
3
+ const retries = 20;
4
+ return p_retry(execute, {
5
+ maxRetryTime: 300000,
6
+ retries,
7
+ minTimeout: 1500,
8
+ maxTimeout: 30000,
9
+ ...options
10
+ });
11
11
  };
12
+ export { executeWithRetry };
12
13
 
13
14
  //# sourceMappingURL=executeWithRetry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["pRetry","executeWithRetry","execute","options","retries","maxRetryTime","minTimeout","maxTimeout"],"sources":["executeWithRetry.ts"],"sourcesContent":["import pRetry from \"p-retry\";\n\nexport type ExecuteWithRetryOptions = Parameters<typeof pRetry>[1];\n\nexport const executeWithRetry = <T>(\n execute: () => Promise<T>,\n options?: ExecuteWithRetryOptions\n) => {\n const retries = 20;\n return pRetry(execute, {\n maxRetryTime: 300000,\n retries,\n minTimeout: 1500,\n maxTimeout: 30000,\n ...options\n });\n};\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,SAAS;AAI5B,OAAO,MAAMC,gBAAgB,GAAGA,CAC5BC,OAAyB,EACzBC,OAAiC,KAChC;EACD,MAAMC,OAAO,GAAG,EAAE;EAClB,OAAOJ,MAAM,CAACE,OAAO,EAAE;IACnBG,YAAY,EAAE,MAAM;IACpBD,OAAO;IACPE,UAAU,EAAE,IAAI;IAChBC,UAAU,EAAE,KAAK;IACjB,GAAGJ;EACP,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"executeWithRetry.js","sources":["../src/executeWithRetry.ts"],"sourcesContent":["import pRetry from \"p-retry\";\n\nexport type ExecuteWithRetryOptions = Parameters<typeof pRetry>[1];\n\nexport const executeWithRetry = <T>(\n execute: () => Promise<T>,\n options?: ExecuteWithRetryOptions\n) => {\n const retries = 20;\n return pRetry(execute, {\n maxRetryTime: 300000,\n retries,\n minTimeout: 1500,\n maxTimeout: 30000,\n ...options\n });\n};\n"],"names":["executeWithRetry","execute","options","retries","pRetry"],"mappings":";AAIO,MAAMA,mBAAmB,CAC5BC,SACAC;IAEA,MAAMC,UAAU;IAChB,OAAOC,QAAOH,SAAS;QACnB,cAAc;QACdE;QACA,YAAY;QACZ,YAAY;QACZ,GAAGD,OAAO;IACd;AACJ"}
package/exports/api.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export { CompressionHandler } from "../features/compression/abstractions/CompressionHandler.js";
2
2
  export { Compression } from "../features/compression/abstractions/Compression.js";
3
-
4
- //# sourceMappingURL=api.js.map
@@ -1,35 +1,29 @@
1
- import { CompressionHandler as CompressionHandlerAbstraction } from "./abstractions/CompressionHandler.js";
1
+ import { CompressionHandler } from "./abstractions/CompressionHandler.js";
2
2
  import { Compression } from "./abstractions/Compression.js";
3
3
  class CompressionHandlerImpl {
4
- constructor(compressions) {
5
- this.compressions = compressions;
6
- }
7
- async compress(data) {
8
- for (const compression of this.compressions) {
9
- if (compression.canCompress(data)) {
10
- return compression.compress(data);
11
- }
4
+ constructor(compressions){
5
+ this.compressions = compressions;
12
6
  }
13
- /**
14
- * Just return what was received as no compressor can handle that type of data.
15
- */
16
- // @ts-expect-error
17
- return data;
18
- }
19
- async decompress(data) {
20
- for (const compression of this.compressions) {
21
- if (compression.canDecompress(data)) {
22
- return compression.decompress(data);
23
- }
7
+ async compress(data) {
8
+ for (const compression of this.compressions)if (compression.canCompress(data)) return compression.compress(data);
9
+ return data;
10
+ }
11
+ async decompress(data) {
12
+ for (const compression of this.compressions)if (compression.canDecompress(data)) return compression.decompress(data);
13
+ return data;
24
14
  }
25
- return data;
26
- }
27
15
  }
28
- export const CompressionHandler = CompressionHandlerAbstraction.createImplementation({
29
- implementation: CompressionHandlerImpl,
30
- dependencies: [[Compression, {
31
- multiple: true
32
- }]]
16
+ const CompressionHandler_CompressionHandler = CompressionHandler.createImplementation({
17
+ implementation: CompressionHandlerImpl,
18
+ dependencies: [
19
+ [
20
+ Compression,
21
+ {
22
+ multiple: true
23
+ }
24
+ ]
25
+ ]
33
26
  });
27
+ export { CompressionHandler_CompressionHandler as CompressionHandler };
34
28
 
35
29
  //# sourceMappingURL=CompressionHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CompressionHandler","CompressionHandlerAbstraction","Compression","CompressionHandlerImpl","constructor","compressions","compress","data","compression","canCompress","decompress","canDecompress","createImplementation","implementation","dependencies","multiple"],"sources":["CompressionHandler.ts"],"sourcesContent":["import { CompressionHandler as CompressionHandlerAbstraction } from \"./abstractions/CompressionHandler.js\";\nimport { Compression } from \"./abstractions/Compression.js\";\n\nclass CompressionHandlerImpl implements CompressionHandlerAbstraction.Interface {\n public constructor(private readonly compressions: Compression.Interface[]) {}\n\n public async compress<T = unknown>(\n data: CompressionHandlerAbstraction.CompressParams<T>\n ): CompressionHandlerAbstraction.CompressResponse {\n for (const compression of this.compressions) {\n if (compression.canCompress(data)) {\n return compression.compress<T>(data);\n }\n }\n /**\n * Just return what was received as no compressor can handle that type of data.\n */\n // @ts-expect-error\n return data;\n }\n\n public async decompress<T = unknown>(\n data: CompressionHandlerAbstraction.DecompressParams | unknown\n ): CompressionHandlerAbstraction.DecompressResponse<T> {\n for (const compression of this.compressions) {\n if (compression.canDecompress(data)) {\n return compression.decompress<T>(data);\n }\n }\n return data as T;\n }\n}\n\nexport const CompressionHandler = CompressionHandlerAbstraction.createImplementation({\n implementation: CompressionHandlerImpl,\n dependencies: [[Compression, { multiple: true }]]\n});\n"],"mappings":"AAAA,SAASA,kBAAkB,IAAIC,6BAA6B;AAC5D,SAASC,WAAW;AAEpB,MAAMC,sBAAsB,CAAoD;EACrEC,WAAWA,CAAkBC,YAAqC,EAAE;IAAA,KAAvCA,YAAqC,GAArCA,YAAqC;EAAG;EAE5E,MAAaC,QAAQA,CACjBC,IAAqD,EACP;IAC9C,KAAK,MAAMC,WAAW,IAAI,IAAI,CAACH,YAAY,EAAE;MACzC,IAAIG,WAAW,CAACC,WAAW,CAACF,IAAI,CAAC,EAAE;QAC/B,OAAOC,WAAW,CAACF,QAAQ,CAAIC,IAAI,CAAC;MACxC;IACJ;IACA;AACR;AACA;IACQ;IACA,OAAOA,IAAI;EACf;EAEA,MAAaG,UAAUA,CACnBH,IAA8D,EACX;IACnD,KAAK,MAAMC,WAAW,IAAI,IAAI,CAACH,YAAY,EAAE;MACzC,IAAIG,WAAW,CAACG,aAAa,CAACJ,IAAI,CAAC,EAAE;QACjC,OAAOC,WAAW,CAACE,UAAU,CAAIH,IAAI,CAAC;MAC1C;IACJ;IACA,OAAOA,IAAI;EACf;AACJ;AAEA,OAAO,MAAMP,kBAAkB,GAAGC,6BAA6B,CAACW,oBAAoB,CAAC;EACjFC,cAAc,EAAEV,sBAAsB;EACtCW,YAAY,EAAE,CAAC,CAACZ,WAAW,EAAE;IAAEa,QAAQ,EAAE;EAAK,CAAC,CAAC;AACpD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/compression/CompressionHandler.js","sources":["../../../src/features/compression/CompressionHandler.ts"],"sourcesContent":["import { CompressionHandler as CompressionHandlerAbstraction } from \"./abstractions/CompressionHandler.js\";\nimport { Compression } from \"./abstractions/Compression.js\";\n\nclass CompressionHandlerImpl implements CompressionHandlerAbstraction.Interface {\n public constructor(private readonly compressions: Compression.Interface[]) {}\n\n public async compress<T = unknown>(\n data: CompressionHandlerAbstraction.CompressParams<T>\n ): CompressionHandlerAbstraction.CompressResponse {\n for (const compression of this.compressions) {\n if (compression.canCompress(data)) {\n return compression.compress<T>(data);\n }\n }\n /**\n * Just return what was received as no compressor can handle that type of data.\n */\n // @ts-expect-error\n return data;\n }\n\n public async decompress<T = unknown>(\n data: CompressionHandlerAbstraction.DecompressParams | unknown\n ): CompressionHandlerAbstraction.DecompressResponse<T> {\n for (const compression of this.compressions) {\n if (compression.canDecompress(data)) {\n return compression.decompress<T>(data);\n }\n }\n return data as T;\n }\n}\n\nexport const CompressionHandler = CompressionHandlerAbstraction.createImplementation({\n implementation: CompressionHandlerImpl,\n dependencies: [[Compression, { multiple: true }]]\n});\n"],"names":["CompressionHandlerImpl","compressions","data","compression","CompressionHandler","CompressionHandlerAbstraction","Compression"],"mappings":";;AAGA,MAAMA;IACF,YAAoCC,YAAqC,CAAE;aAAvCA,YAAY,GAAZA;IAAwC;IAE5E,MAAa,SACTC,IAAqD,EACP;QAC9C,KAAK,MAAMC,eAAe,IAAI,CAAC,YAAY,CACvC,IAAIA,YAAY,WAAW,CAACD,OACxB,OAAOC,YAAY,QAAQ,CAAID;QAOvC,OAAOA;IACX;IAEA,MAAa,WACTA,IAA8D,EACX;QACnD,KAAK,MAAMC,eAAe,IAAI,CAAC,YAAY,CACvC,IAAIA,YAAY,aAAa,CAACD,OAC1B,OAAOC,YAAY,UAAU,CAAID;QAGzC,OAAOA;IACX;AACJ;AAEO,MAAME,wCAAqBC,mBAAAA,oBAAkD,CAAC;IACjF,gBAAgBL;IAChB,cAAc;QAAC;YAACM;YAAa;gBAAE,UAAU;YAAK;SAAE;KAAC;AACrD"}
@@ -1,26 +1,27 @@
1
- import { Compression as CompressionAbstraction } from "./abstractions/Compression.js";
1
+ import { Compression } from "./abstractions/Compression.js";
2
2
  import { createGzipCompression } from "./legacy/index.js";
3
- const plugin = createGzipCompression();
3
+ const GzipCompression_plugin = createGzipCompression();
4
4
  class GzipCompressionImpl {
5
- name = "gzip";
6
- canCompress(data) {
7
- return plugin.canCompress(data);
8
- }
9
- async compress(data) {
10
- return plugin.compress(data);
11
- }
12
- canDecompress(data) {
13
- // @ts-expect-error
14
- return plugin.canDecompress(data);
15
- }
16
- async decompress(data) {
17
- // @ts-expect-error
18
- return plugin.decompress(data);
19
- }
5
+ canCompress(data) {
6
+ return GzipCompression_plugin.canCompress(data);
7
+ }
8
+ async compress(data) {
9
+ return GzipCompression_plugin.compress(data);
10
+ }
11
+ canDecompress(data) {
12
+ return GzipCompression_plugin.canDecompress(data);
13
+ }
14
+ async decompress(data) {
15
+ return GzipCompression_plugin.decompress(data);
16
+ }
17
+ constructor(){
18
+ this.name = "gzip";
19
+ }
20
20
  }
21
- export const GzipCompression = CompressionAbstraction.createImplementation({
22
- implementation: GzipCompressionImpl,
23
- dependencies: []
21
+ const GzipCompression = Compression.createImplementation({
22
+ implementation: GzipCompressionImpl,
23
+ dependencies: []
24
24
  });
25
+ export { GzipCompression };
25
26
 
26
27
  //# sourceMappingURL=GzipCompression.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Compression","CompressionAbstraction","createGzipCompression","plugin","GzipCompressionImpl","name","canCompress","data","compress","canDecompress","decompress","GzipCompression","createImplementation","implementation","dependencies"],"sources":["GzipCompression.ts"],"sourcesContent":["import {\n Compression as CompressionAbstraction,\n ICompressedValue\n} from \"./abstractions/Compression.js\";\nimport { createGzipCompression } from \"./legacy/index.js\";\n\nconst plugin = createGzipCompression();\n\nclass GzipCompressionImpl implements CompressionAbstraction.Interface {\n public readonly name = \"gzip\";\n\n public canCompress(data: any): boolean {\n return plugin.canCompress(data);\n }\n\n public async compress<T>(data: T): Promise<ICompressedValue> {\n return plugin.compress(data);\n }\n\n public canDecompress(data: ICompressedValue | unknown): boolean {\n // @ts-expect-error\n return plugin.canDecompress(data);\n }\n\n public async decompress<T>(data: ICompressedValue | unknown): Promise<T> {\n // @ts-expect-error\n return plugin.decompress(data);\n }\n}\n\nexport const GzipCompression = CompressionAbstraction.createImplementation({\n implementation: GzipCompressionImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SACIA,WAAW,IAAIC,sBAAsB;AAGzC,SAASC,qBAAqB;AAE9B,MAAMC,MAAM,GAAGD,qBAAqB,CAAC,CAAC;AAEtC,MAAME,mBAAmB,CAA6C;EAClDC,IAAI,GAAG,MAAM;EAEtBC,WAAWA,CAACC,IAAS,EAAW;IACnC,OAAOJ,MAAM,CAACG,WAAW,CAACC,IAAI,CAAC;EACnC;EAEA,MAAaC,QAAQA,CAAID,IAAO,EAA6B;IACzD,OAAOJ,MAAM,CAACK,QAAQ,CAACD,IAAI,CAAC;EAChC;EAEOE,aAAaA,CAACF,IAAgC,EAAW;IAC5D;IACA,OAAOJ,MAAM,CAACM,aAAa,CAACF,IAAI,CAAC;EACrC;EAEA,MAAaG,UAAUA,CAAIH,IAAgC,EAAc;IACrE;IACA,OAAOJ,MAAM,CAACO,UAAU,CAACH,IAAI,CAAC;EAClC;AACJ;AAEA,OAAO,MAAMI,eAAe,GAAGV,sBAAsB,CAACW,oBAAoB,CAAC;EACvEC,cAAc,EAAET,mBAAmB;EACnCU,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/compression/GzipCompression.js","sources":["../../../src/features/compression/GzipCompression.ts"],"sourcesContent":["import {\n Compression as CompressionAbstraction,\n ICompressedValue\n} from \"./abstractions/Compression.js\";\nimport { createGzipCompression } from \"./legacy/index.js\";\n\nconst plugin = createGzipCompression();\n\nclass GzipCompressionImpl implements CompressionAbstraction.Interface {\n public readonly name = \"gzip\";\n\n public canCompress(data: any): boolean {\n return plugin.canCompress(data);\n }\n\n public async compress<T>(data: T): Promise<ICompressedValue> {\n return plugin.compress(data);\n }\n\n public canDecompress(data: ICompressedValue | unknown): boolean {\n // @ts-expect-error\n return plugin.canDecompress(data);\n }\n\n public async decompress<T>(data: ICompressedValue | unknown): Promise<T> {\n // @ts-expect-error\n return plugin.decompress(data);\n }\n}\n\nexport const GzipCompression = CompressionAbstraction.createImplementation({\n implementation: GzipCompressionImpl,\n dependencies: []\n});\n"],"names":["plugin","createGzipCompression","GzipCompressionImpl","data","GzipCompression","CompressionAbstraction"],"mappings":";;AAMA,MAAMA,yBAASC;AAEf,MAAMC;IAGK,YAAYC,IAAS,EAAW;QACnC,OAAOH,uBAAO,WAAW,CAACG;IAC9B;IAEA,MAAa,SAAYA,IAAO,EAA6B;QACzD,OAAOH,uBAAO,QAAQ,CAACG;IAC3B;IAEO,cAAcA,IAAgC,EAAW;QAE5D,OAAOH,uBAAO,aAAa,CAACG;IAChC;IAEA,MAAa,WAAcA,IAAgC,EAAc;QAErE,OAAOH,uBAAO,UAAU,CAACG;IAC7B;;aAlBgB,IAAI,GAAG;;AAmB3B;AAEO,MAAMC,kBAAkBC,YAAAA,oBAA2C,CAAC;IACvE,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -1,29 +1,27 @@
1
- import { Compression as CompressionAbstraction } from "./abstractions/Compression.js";
1
+ import { Compression } from "./abstractions/Compression.js";
2
2
  import { createJsonpackCompression } from "./legacy/index.js";
3
- const plugin = createJsonpackCompression();
3
+ const JsonpackCompression_plugin = createJsonpackCompression();
4
4
  class JsonpackCompressionImpl {
5
- name = "jsonpack";
6
- /**
7
- * We do not want to use jsonpack for compression anymore, but we want to keep the plugin around for decompression of old data.
8
- */
9
- canCompress() {
10
- return false;
11
- }
12
- async compress(data) {
13
- return plugin.compress(data);
14
- }
15
- canDecompress(data) {
16
- // @ts-expect-error
17
- return plugin.canDecompress(data);
18
- }
19
- async decompress(data) {
20
- // @ts-expect-error
21
- return plugin.decompress(data);
22
- }
5
+ canCompress() {
6
+ return false;
7
+ }
8
+ async compress(data) {
9
+ return JsonpackCompression_plugin.compress(data);
10
+ }
11
+ canDecompress(data) {
12
+ return JsonpackCompression_plugin.canDecompress(data);
13
+ }
14
+ async decompress(data) {
15
+ return JsonpackCompression_plugin.decompress(data);
16
+ }
17
+ constructor(){
18
+ this.name = "jsonpack";
19
+ }
23
20
  }
24
- export const JsonpackCompression = CompressionAbstraction.createImplementation({
25
- implementation: JsonpackCompressionImpl,
26
- dependencies: []
21
+ const JsonpackCompression = Compression.createImplementation({
22
+ implementation: JsonpackCompressionImpl,
23
+ dependencies: []
27
24
  });
25
+ export { JsonpackCompression };
28
26
 
29
27
  //# sourceMappingURL=JsonpackCompression.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Compression","CompressionAbstraction","createJsonpackCompression","plugin","JsonpackCompressionImpl","name","canCompress","compress","data","canDecompress","decompress","JsonpackCompression","createImplementation","implementation","dependencies"],"sources":["JsonpackCompression.ts"],"sourcesContent":["import { Compression as CompressionAbstraction } from \"./abstractions/Compression.js\";\nimport { createJsonpackCompression } from \"./legacy/index.js\";\n\nconst plugin = createJsonpackCompression();\n\nclass JsonpackCompressionImpl implements CompressionAbstraction.Interface {\n public readonly name = \"jsonpack\";\n /**\n * We do not want to use jsonpack for compression anymore, but we want to keep the plugin around for decompression of old data.\n */\n public canCompress(): boolean {\n return false;\n }\n\n public async compress(\n data: CompressionAbstraction.CompressParams\n ): CompressionAbstraction.CompressResponse {\n return plugin.compress(data);\n }\n\n public canDecompress(data: CompressionAbstraction.DecompressParams): boolean {\n // @ts-expect-error\n return plugin.canDecompress(data);\n }\n\n public async decompress<T>(\n data: CompressionAbstraction.DecompressParams\n ): CompressionAbstraction.DecompressResponse<T> {\n // @ts-expect-error\n return plugin.decompress(data);\n }\n}\n\nexport const JsonpackCompression = CompressionAbstraction.createImplementation({\n implementation: JsonpackCompressionImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,WAAW,IAAIC,sBAAsB;AAC9C,SAASC,yBAAyB;AAElC,MAAMC,MAAM,GAAGD,yBAAyB,CAAC,CAAC;AAE1C,MAAME,uBAAuB,CAA6C;EACtDC,IAAI,GAAG,UAAU;EACjC;AACJ;AACA;EACWC,WAAWA,CAAA,EAAY;IAC1B,OAAO,KAAK;EAChB;EAEA,MAAaC,QAAQA,CACjBC,IAA2C,EACJ;IACvC,OAAOL,MAAM,CAACI,QAAQ,CAACC,IAAI,CAAC;EAChC;EAEOC,aAAaA,CAACD,IAA6C,EAAW;IACzE;IACA,OAAOL,MAAM,CAACM,aAAa,CAACD,IAAI,CAAC;EACrC;EAEA,MAAaE,UAAUA,CACnBF,IAA6C,EACD;IAC5C;IACA,OAAOL,MAAM,CAACO,UAAU,CAACF,IAAI,CAAC;EAClC;AACJ;AAEA,OAAO,MAAMG,mBAAmB,GAAGV,sBAAsB,CAACW,oBAAoB,CAAC;EAC3EC,cAAc,EAAET,uBAAuB;EACvCU,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/compression/JsonpackCompression.js","sources":["../../../src/features/compression/JsonpackCompression.ts"],"sourcesContent":["import { Compression as CompressionAbstraction } from \"./abstractions/Compression.js\";\nimport { createJsonpackCompression } from \"./legacy/index.js\";\n\nconst plugin = createJsonpackCompression();\n\nclass JsonpackCompressionImpl implements CompressionAbstraction.Interface {\n public readonly name = \"jsonpack\";\n /**\n * We do not want to use jsonpack for compression anymore, but we want to keep the plugin around for decompression of old data.\n */\n public canCompress(): boolean {\n return false;\n }\n\n public async compress(\n data: CompressionAbstraction.CompressParams\n ): CompressionAbstraction.CompressResponse {\n return plugin.compress(data);\n }\n\n public canDecompress(data: CompressionAbstraction.DecompressParams): boolean {\n // @ts-expect-error\n return plugin.canDecompress(data);\n }\n\n public async decompress<T>(\n data: CompressionAbstraction.DecompressParams\n ): CompressionAbstraction.DecompressResponse<T> {\n // @ts-expect-error\n return plugin.decompress(data);\n }\n}\n\nexport const JsonpackCompression = CompressionAbstraction.createImplementation({\n implementation: JsonpackCompressionImpl,\n dependencies: []\n});\n"],"names":["plugin","createJsonpackCompression","JsonpackCompressionImpl","data","JsonpackCompression","CompressionAbstraction"],"mappings":";;AAGA,MAAMA,6BAASC;AAEf,MAAMC;IAKK,cAAuB;QAC1B,OAAO;IACX;IAEA,MAAa,SACTC,IAA2C,EACJ;QACvC,OAAOH,2BAAO,QAAQ,CAACG;IAC3B;IAEO,cAAcA,IAA6C,EAAW;QAEzE,OAAOH,2BAAO,aAAa,CAACG;IAChC;IAEA,MAAa,WACTA,IAA6C,EACD;QAE5C,OAAOH,2BAAO,UAAU,CAACG;IAC7B;;aAxBgB,IAAI,GAAG;;AAyB3B;AAEO,MAAMC,sBAAsBC,YAAAA,oBAA2C,CAAC;IAC3E,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -1,4 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const Compression = createAbstraction("Api/Compression/Type");
2
+ const Compression = createAbstraction("Api/Compression/Type");
3
+ export { Compression };
3
4
 
4
5
  //# sourceMappingURL=Compression.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","Compression"],"sources":["Compression.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface ICompressedValue {\n compression: string;\n value: string;\n}\n\nexport interface ICompression {\n readonly name: string;\n canCompress(data: any): boolean;\n compress<T>(data: T): Promise<ICompressedValue>;\n canDecompress(data: ICompressedValue | unknown): boolean;\n decompress<T>(data: ICompressedValue | unknown): Promise<T>;\n}\n\nexport const Compression = createAbstraction<ICompression>(\"Api/Compression/Type\");\n\nexport namespace Compression {\n export type Interface = ICompression;\n export type CompressParams<T = unknown> = T;\n export type CompressResponse = Promise<ICompressedValue>;\n export type DecompressParams = ICompressedValue | unknown;\n export type DecompressResponse<T = unknown> = Promise<T>;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAevD,OAAO,MAAMC,WAAW,GAAGD,iBAAiB,CAAe,sBAAsB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/compression/abstractions/Compression.js","sources":["../../../../src/features/compression/abstractions/Compression.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface ICompressedValue {\n compression: string;\n value: string;\n}\n\nexport interface ICompression {\n readonly name: string;\n canCompress(data: any): boolean;\n compress<T>(data: T): Promise<ICompressedValue>;\n canDecompress(data: ICompressedValue | unknown): boolean;\n decompress<T>(data: ICompressedValue | unknown): Promise<T>;\n}\n\nexport const Compression = createAbstraction<ICompression>(\"Api/Compression/Type\");\n\nexport namespace Compression {\n export type Interface = ICompression;\n export type CompressParams<T = unknown> = T;\n export type CompressResponse = Promise<ICompressedValue>;\n export type DecompressParams = ICompressedValue | unknown;\n export type DecompressResponse<T = unknown> = Promise<T>;\n}\n"],"names":["Compression","createAbstraction"],"mappings":";AAeO,MAAMA,cAAcC,kBAAgC"}
@@ -1,4 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const CompressionHandler = createAbstraction("Api/Compression/Handler");
2
+ const CompressionHandler = createAbstraction("Api/Compression/Handler");
3
+ export { CompressionHandler };
3
4
 
4
5
  //# sourceMappingURL=CompressionHandler.js.map