@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.
- package/GenericRecord.js +0 -3
- package/cacheKey.js +10 -12
- package/cacheKey.js.map +1 -1
- package/compose.js +23 -32
- package/compose.js.map +1 -1
- package/createIdentifier.js +4 -14
- package/createIdentifier.js.map +1 -1
- package/createZodError.js +22 -27
- package/createZodError.js.map +1 -1
- package/cursor.js +20 -25
- package/cursor.js.map +1 -1
- package/exception.js +8 -13
- package/exception.js.map +1 -1
- package/executeWithRetry.js +11 -10
- package/executeWithRetry.js.map +1 -1
- package/exports/api.js +0 -2
- package/features/compression/CompressionHandler.js +21 -27
- package/features/compression/CompressionHandler.js.map +1 -1
- package/features/compression/GzipCompression.js +21 -20
- package/features/compression/GzipCompression.js.map +1 -1
- package/features/compression/JsonpackCompression.js +21 -23
- package/features/compression/JsonpackCompression.js.map +1 -1
- package/features/compression/abstractions/Compression.js +2 -1
- package/features/compression/abstractions/Compression.js.map +1 -1
- package/features/compression/abstractions/CompressionHandler.js +2 -1
- package/features/compression/abstractions/CompressionHandler.js.map +1 -1
- package/features/compression/feature.js +8 -7
- package/features/compression/feature.js.map +1 -1
- package/features/compression/legacy/CompressionPlugin.js +5 -2
- package/features/compression/legacy/CompressionPlugin.js.map +1 -1
- package/features/compression/legacy/Compressor.js +41 -53
- package/features/compression/legacy/Compressor.js.map +1 -1
- package/features/compression/legacy/gzip.js +12 -21
- package/features/compression/legacy/gzip.js.map +1 -1
- package/features/compression/legacy/index.js +0 -2
- package/features/compression/legacy/jsonpack.js +5 -8
- package/features/compression/legacy/jsonpack.js.map +1 -1
- package/features/compression/legacy/plugins/GzipCompression.js +52 -45
- package/features/compression/legacy/plugins/GzipCompression.js.map +1 -1
- package/features/compression/legacy/plugins/JsonpackCompression.js +32 -41
- package/features/compression/legacy/plugins/JsonpackCompression.js.map +1 -1
- package/generateId.js +7 -8
- package/generateId.js.map +1 -1
- package/getObjectProperties.js +7 -12
- package/getObjectProperties.js.map +1 -1
- package/headers.js +9 -13
- package/headers.js.map +1 -1
- package/index.js +1 -4
- package/mdbid.js +3 -4
- package/mdbid.js.map +1 -1
- package/middleware.js +25 -37
- package/middleware.js.map +1 -1
- package/package.json +8 -8
- package/parseIdentifier.js +16 -26
- package/parseIdentifier.js.map +1 -1
- package/removeNullValues.js +5 -9
- package/removeNullValues.js.map +1 -1
- package/removeUndefinedValues.js +5 -9
- package/removeUndefinedValues.js.map +1 -1
- package/utcTimezones.js +159 -118
- package/utcTimezones.js.map +1 -1
- package/zeroPad.js +2 -7
- package/zeroPad.js.map +1 -1
- package/GenericRecord.js.map +0 -1
- package/exports/api.js.map +0 -1
- package/features/compression/legacy/index.js.map +0 -1
- package/index.js.map +0 -1
package/GenericRecord.js
CHANGED
package/cacheKey.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
-
import {
|
|
3
|
-
const getCacheKey = input
|
|
4
|
-
|
|
5
|
-
return input
|
|
6
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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,"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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,"
|
|
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"}
|
package/createIdentifier.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { zeroPad } from "./zeroPad.js";
|
|
2
2
|
import { parseIdentifier } from "./parseIdentifier.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
package/createIdentifier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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
|
|
1
|
+
import _webiny_error from "@webiny/error";
|
|
2
2
|
import { generateAlphaNumericId } from "./generateId.js";
|
|
3
|
-
const createValidationErrorData = error
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
package/createZodError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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,"
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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,"
|
|
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"}
|
package/executeWithRetry.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
package/executeWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,35 +1,29 @@
|
|
|
1
|
-
import { CompressionHandler
|
|
1
|
+
import { CompressionHandler } from "./abstractions/CompressionHandler.js";
|
|
2
2
|
import { Compression } from "./abstractions/Compression.js";
|
|
3
3
|
class CompressionHandlerImpl {
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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,"
|
|
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
|
|
1
|
+
import { Compression } from "./abstractions/Compression.js";
|
|
2
2
|
import { createGzipCompression } from "./legacy/index.js";
|
|
3
|
-
const
|
|
3
|
+
const GzipCompression_plugin = createGzipCompression();
|
|
4
4
|
class GzipCompressionImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,"
|
|
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
|
|
1
|
+
import { Compression } from "./abstractions/Compression.js";
|
|
2
2
|
import { createJsonpackCompression } from "./legacy/index.js";
|
|
3
|
-
const
|
|
3
|
+
const JsonpackCompression_plugin = createJsonpackCompression();
|
|
4
4
|
class JsonpackCompressionImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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
|
-
|
|
2
|
+
const CompressionHandler = createAbstraction("Api/Compression/Handler");
|
|
3
|
+
export { CompressionHandler };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=CompressionHandler.js.map
|