@webiny/utils 5.43.3 → 6.0.0-alpha.1
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/cacheKey.d.ts +1 -1
- package/cacheKey.js.map +1 -1
- package/compression/Compressor.d.ts +1 -1
- package/compression/Compressor.js.map +1 -1
- package/createZodError.d.ts +1 -1
- package/createZodError.js +4 -2
- package/createZodError.js.map +1 -1
- package/exception.d.ts +6 -0
- package/exception.js +23 -0
- package/exception.js.map +1 -0
- package/index.d.ts +3 -1
- package/index.js +12 -0
- package/index.js.map +1 -1
- package/package.json +5 -5
package/cacheKey.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { BinaryToTextEncoding } from "crypto";
|
|
2
|
+
import type { BinaryToTextEncoding } from "crypto";
|
|
3
3
|
export type ICacheKeyKeys = Record<string, any> | string | number;
|
|
4
4
|
export interface ICacheKeyOptions {
|
|
5
5
|
algorithm?: CacheKeyAlgorithmType;
|
package/cacheKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_crypto","_interopRequireDefault","require","getCacheKey","input","JSON","stringify","createCacheKey","options","key","crypto","createHash","algorithm","update","digest","encoding","exports"],"sources":["cacheKey.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"names":["_crypto","_interopRequireDefault","require","getCacheKey","input","JSON","stringify","createCacheKey","options","key","crypto","createHash","algorithm","update","digest","encoding","exports"],"sources":["cacheKey.ts"],"sourcesContent":["import type { BinaryToTextEncoding } from \"crypto\";\nimport crypto from \"crypto\";\n\nexport type ICacheKeyKeys = Record<string, any> | string | number;\n\nexport interface ICacheKeyOptions {\n algorithm?: CacheKeyAlgorithmType;\n encoding?: BinaryToTextEncoding;\n}\n\nexport type CacheKeyAlgorithmType = \"md5\" | \"sha1\" | \"sha224\" | \"sha256\" | \"sha384\" | \"sha512\";\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, options?: ICacheKeyOptions): string => {\n const key = getCacheKey(input);\n return crypto\n .createHash(options?.algorithm || \"sha1\")\n .update(key)\n .digest(options?.encoding || \"hex\");\n};\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,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;AAEM,MAAMG,cAAc,GAAGA,CAACH,KAAoB,EAAEI,OAA0B,KAAa;EACxF,MAAMC,GAAG,GAAGN,WAAW,CAACC,KAAK,CAAC;EAC9B,OAAOM,eAAM,CACRC,UAAU,CAACH,OAAO,EAAEI,SAAS,IAAI,MAAM,CAAC,CACxCC,MAAM,CAACJ,GAAG,CAAC,CACXK,MAAM,CAACN,OAAO,EAAEO,QAAQ,IAAI,KAAK,CAAC;AAC3C,CAAC;AAACC,OAAA,CAAAT,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_CompressionPlugin","require","_GzipCompression","_JsonpackCompression","Compressor","disabled","Set","plugins","_plugins","byType","CompressionPlugin","type","reverse","constructor","params","disable","name","add","enable","delete","compress","data","plugin","has","canCompress","ex","console","error","log","decompress","canDecompress","createDefaultCompressor","register","createJsonpackCompression","createGzipCompression","exports"],"sources":["Compressor.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { CompressionPlugin, type ICompressedValue } from \"./CompressionPlugin\";\nimport { createGzipCompression } from \"./plugins/GzipCompression\";\nimport { createJsonpackCompression } from \"./plugins/JsonpackCompression\";\n\nexport interface ICompressorParams {\n plugins: PluginsContainer;\n}\n\nexport interface ICompressor {\n disable(name: string): void;\n enable(name: string): void;\n /**\n * Compresses the given data using the first plugin that can compress it.\n */\n compress<T = unknown>(data: T): Promise<T | ICompressedValue>;\n /**\n * Decompresses the given data using the first plugin that can decompress it.\n */\n decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T>;\n}\n\nclass Compressor implements ICompressor {\n private readonly _plugins: PluginsContainer;\n\n private readonly disabled: Set<string> = new Set();\n\n private get plugins(): CompressionPlugin[] {\n return this._plugins.byType<CompressionPlugin>(CompressionPlugin.type).reverse();\n }\n\n public constructor(params: ICompressorParams) {\n this._plugins = params.plugins;\n }\n\n public disable(name: string): void {\n this.disabled.add(name);\n }\n\n public enable(name: string): void {\n this.disabled.delete(name);\n }\n\n public async compress<T = unknown>(data: T): Promise<T | ICompressedValue> {\n for (const plugin of this.plugins) {\n /**\n * We skip disabled plugins.\n */\n if (plugin.name && this.disabled.has(plugin.name)) {\n continue;\n }\n if (plugin.canCompress(data) === false) {\n continue;\n }\n try {\n return await plugin.compress(data);\n } catch (ex) {\n console.error(\n `Could not compress given data. More info in next line. Trying next plugin.`\n );\n console.log(ex);\n }\n }\n return data;\n }\n\n public async decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T> {\n for (const plugin of this.plugins) {\n if (plugin.canDecompress(data) === false) {\n continue;\n }\n try {\n return await plugin.decompress(data);\n } catch (ex) {\n console.error(\n `Could not decompress given data. More info in next line. Trying next plugin.`\n );\n console.log(ex);\n }\n }\n return data as T;\n }\n}\n\nexport const createDefaultCompressor = (params: ICompressorParams) => {\n const { plugins } = params;\n plugins.register([createJsonpackCompression(), createGzipCompression()]);\n return new Compressor({\n plugins\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA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AAE;QACtC;MACJ;MACA,IAAI;QACA,OAAO,MAAMC,MAAM,CAACO,UAAU,CAACR,IAAI,CAAC;MACxC,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CACT,8EACJ,CAAC;QACDD,OAAO,CAACE,GAAG,CAACH,EAAE,CAAC;MACnB;IACJ;IACA,OAAOJ,IAAI;EACf;AACJ;AAEO,MAAMU,uBAAuB,GAAIjB,MAAyB,IAAK;EAClE,MAAM;IAAEP;EAAQ,CAAC,GAAGO,MAAM;EAC1BP,OAAO,CAACyB,QAAQ,CAAC,CAAC,IAAAC,8CAAyB,EAAC,CAAC,EAAE,IAAAC,sCAAqB,EAAC,CAAC,CAAC,CAAC;EACxE,OAAO,IAAI9B,UAAU,CAAC;IAClBG;EACJ,CAAC,CAAC;AACN,CAAC;AAAC4B,OAAA,CAAAJ,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_CompressionPlugin","require","_GzipCompression","_JsonpackCompression","Compressor","disabled","Set","plugins","_plugins","byType","CompressionPlugin","type","reverse","constructor","params","disable","name","add","enable","delete","compress","data","plugin","has","canCompress","ex","console","error","log","decompress","canDecompress","createDefaultCompressor","register","createJsonpackCompression","createGzipCompression","exports"],"sources":["Compressor.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { CompressionPlugin, type ICompressedValue } from \"./CompressionPlugin\";\nimport { createGzipCompression } from \"./plugins/GzipCompression\";\nimport { createJsonpackCompression } from \"./plugins/JsonpackCompression\";\n\nexport interface ICompressorParams {\n plugins: PluginsContainer;\n}\n\nexport interface ICompressor {\n disable(name: string): void;\n enable(name: string): void;\n /**\n * Compresses the given data using the first plugin that can compress it.\n */\n compress<T = unknown>(data: T): Promise<T | ICompressedValue>;\n /**\n * Decompresses the given data using the first plugin that can decompress it.\n */\n decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T>;\n}\n\nclass Compressor implements ICompressor {\n private readonly _plugins: PluginsContainer;\n\n private readonly disabled: Set<string> = new Set();\n\n private get plugins(): CompressionPlugin[] {\n return this._plugins.byType<CompressionPlugin>(CompressionPlugin.type).reverse();\n }\n\n public constructor(params: ICompressorParams) {\n this._plugins = params.plugins;\n }\n\n public disable(name: string): void {\n this.disabled.add(name);\n }\n\n public enable(name: string): void {\n this.disabled.delete(name);\n }\n\n public async compress<T = unknown>(data: T): Promise<T | ICompressedValue> {\n for (const plugin of this.plugins) {\n /**\n * We skip disabled plugins.\n */\n if (plugin.name && this.disabled.has(plugin.name)) {\n continue;\n }\n if (plugin.canCompress(data) === false) {\n continue;\n }\n try {\n return await plugin.compress(data);\n } catch (ex) {\n console.error(\n `Could not compress given data. More info in next line. Trying next plugin.`\n );\n console.log(ex);\n }\n }\n return data;\n }\n\n public async decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T> {\n for (const plugin of this.plugins) {\n if (plugin.canDecompress(data) === false) {\n continue;\n }\n try {\n return await plugin.decompress(data);\n } catch (ex) {\n console.error(\n `Could not decompress given data. More info in next line. Trying next plugin.`\n );\n console.log(ex);\n }\n }\n return data as T;\n }\n}\n\nexport const createDefaultCompressor = (params: ICompressorParams) => {\n const { plugins } = params;\n plugins.register([createJsonpackCompression(), createGzipCompression()]);\n return new Compressor({\n plugins\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAmBA,MAAMG,UAAU,CAAwB;EAGnBC,QAAQ,GAAgB,IAAIC,GAAG,CAAC,CAAC;EAElD,IAAYC,OAAOA,CAAA,EAAwB;IACvC,OAAO,IAAI,CAACC,QAAQ,CAACC,MAAM,CAAoBC,oCAAiB,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;EACpF;EAEOC,WAAWA,CAACC,MAAyB,EAAE;IAC1C,IAAI,CAACN,QAAQ,GAAGM,MAAM,CAACP,OAAO;EAClC;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1BP,OAAO,CAACyB,QAAQ,CAAC,CAAC,IAAAC,8CAAyB,EAAC,CAAC,EAAE,IAAAC,sCAAqB,EAAC,CAAC,CAAC,CAAC;EACxE,OAAO,IAAI9B,UAAU,CAAC;IAClBG;EACJ,CAAC,CAAC;AACN,CAAC;AAAC4B,OAAA,CAAAJ,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
package/createZodError.d.ts
CHANGED
package/createZodError.js
CHANGED
|
@@ -6,14 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createZodError = void 0;
|
|
8
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _generateId = require("./generateId.js");
|
|
9
10
|
const createValidationErrorData = error => {
|
|
10
11
|
return {
|
|
11
12
|
invalidFields: error.issues.reduce((collection, issue) => {
|
|
12
13
|
const name = issue.path.join(".");
|
|
13
|
-
if (!name) {
|
|
14
|
+
if (!name && !issue.code) {
|
|
14
15
|
return collection;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
const key = name || issue.path.join(".") || issue.message || issue.code || (0, _generateId.generateAlphaNumericId)();
|
|
18
|
+
collection[key] = {
|
|
17
19
|
code: issue.code,
|
|
18
20
|
message: issue.message,
|
|
19
21
|
data: {
|
package/createZodError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","createValidationErrorData","error","invalidFields","issues","reduce","collection","issue","name","path","join","code","message","data","fatal","createZodError","WebinyError","exports"],"sources":["createZodError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ZodError } from \"zod/lib/ZodError\";\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) {\n return collection;\n }\n collection[
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_generateId","createValidationErrorData","error","invalidFields","issues","reduce","collection","issue","name","path","join","code","key","message","generateAlphaNumericId","data","fatal","createZodError","WebinyError","exports"],"sources":["createZodError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ZodError } from \"zod/lib/ZodError\";\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 fatal: issue.fatal,\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAYA,MAAME,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,IACV,IAAAG,kCAAsB,EAAC,CAAC;MAC5BR,UAAU,CAACM,GAAG,CAAC,GAAG;QACdD,IAAI,EAAEJ,KAAK,CAACI,IAAI;QAChBE,OAAO,EAAEN,KAAK,CAACM,OAAO;QACtBE,IAAI,EAAE;UACFC,KAAK,EAAET,KAAK,CAACS,KAAK;UAClBP,IAAI,EAAEF,KAAK,CAACE;QAChB;MACJ,CAAC;MAED,OAAOH,UAAU;IACrB,CAAC,EAAE,CAAC,CAAC;EACT,CAAC;AACL,CAAC;AAEM,MAAMW,cAAc,GAAIf,KAAe,IAAK;EAC/C,OAAO,IAAIgB,cAAW,CAAC;IACnBL,OAAO,EAAE,oBAAoB;IAC7BF,IAAI,EAAE,kCAAkC;IACxCI,IAAI,EAAEd,yBAAyB,CAACC,KAAK;EACzC,CAAC,CAAC;AACN,CAAC;AAACiB,OAAA,CAAAF,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/exception.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GenericRecord } from "./GenericRecord.js";
|
|
2
|
+
/**
|
|
3
|
+
* This will help with output of the error object.
|
|
4
|
+
* Normally, the error object is not serializable, so we need to convert it to a plain object.
|
|
5
|
+
*/
|
|
6
|
+
export declare const convertException: (error: Error, remove?: string[]) => GenericRecord;
|
package/exception.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertException = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* This will help with output of the error object.
|
|
9
|
+
* Normally, the error object is not serializable, so we need to convert it to a plain object.
|
|
10
|
+
*/
|
|
11
|
+
const convertException = (error, remove) => {
|
|
12
|
+
const properties = Object.getOwnPropertyNames(error);
|
|
13
|
+
return properties.reduce((items, property) => {
|
|
14
|
+
if (remove && remove.includes(property)) {
|
|
15
|
+
return items;
|
|
16
|
+
}
|
|
17
|
+
items[property] = error[property];
|
|
18
|
+
return items;
|
|
19
|
+
}, {});
|
|
20
|
+
};
|
|
21
|
+
exports.convertException = convertException;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=exception.js.map
|
package/exception.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["convertException","error","remove","properties","Object","getOwnPropertyNames","reduce","items","property","includes","exports"],"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;AACO,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;AAACG,OAAA,CAAAV,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./parseIdentifier";
|
|
2
2
|
export * from "./zeroPad";
|
|
3
|
+
export * from "./exception.js";
|
|
3
4
|
export * from "./createIdentifier";
|
|
4
5
|
export * from "./cursor";
|
|
5
6
|
export * from "./headers";
|
|
@@ -14,6 +15,7 @@ export * from "./cacheKey";
|
|
|
14
15
|
export * from "./getObjectProperties";
|
|
15
16
|
export * from "./middleware";
|
|
16
17
|
export type { GenericRecord } from "./GenericRecord";
|
|
17
|
-
import { AsyncProcessor,
|
|
18
|
+
import type { AsyncProcessor, NextAsyncProcessor } from "./compose";
|
|
19
|
+
import { composeAsync } from "./compose";
|
|
18
20
|
export { composeAsync };
|
|
19
21
|
export type { AsyncProcessor, NextAsyncProcessor };
|
package/index.js
CHANGED
|
@@ -36,6 +36,18 @@ Object.keys(_zeroPad).forEach(function (key) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
var _exception = require("./exception.js");
|
|
40
|
+
Object.keys(_exception).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
43
|
+
if (key in exports && exports[key] === _exception[key]) return;
|
|
44
|
+
Object.defineProperty(exports, key, {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _exception[key];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
39
51
|
var _createIdentifier = require("./createIdentifier");
|
|
40
52
|
Object.keys(_createIdentifier).forEach(function (key) {
|
|
41
53
|
if (key === "default" || key === "__esModule") return;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_parseIdentifier","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_zeroPad","_createIdentifier","_cursor","_headers","_generateId","_mdbid","_createZodError","_executeWithRetry","_removeUndefinedValues","_removeNullValues","_utcTimezones","_cacheKey","_getObjectProperties","_middleware","_compose"],"sources":["index.ts"],"sourcesContent":["export * from \"~/parseIdentifier\";\nexport * from \"~/zeroPad\";\nexport * from \"~/createIdentifier\";\nexport * from \"~/cursor\";\nexport * from \"~/headers\";\nexport * from \"~/generateId\";\nexport * from \"~/mdbid\";\nexport * from \"~/createZodError\";\nexport * from \"~/executeWithRetry\";\nexport * from \"~/removeUndefinedValues\";\nexport * from \"~/removeNullValues\";\nexport * from \"~/utcTimezones\";\nexport * from \"./cacheKey\";\nexport * from \"./getObjectProperties\";\nexport * from \"./middleware\";\nexport type { GenericRecord } from \"./GenericRecord\";\n\nimport { AsyncProcessor,
|
|
1
|
+
{"version":3,"names":["_parseIdentifier","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_zeroPad","_exception","_createIdentifier","_cursor","_headers","_generateId","_mdbid","_createZodError","_executeWithRetry","_removeUndefinedValues","_removeNullValues","_utcTimezones","_cacheKey","_getObjectProperties","_middleware","_compose"],"sources":["index.ts"],"sourcesContent":["export * from \"~/parseIdentifier\";\nexport * from \"~/zeroPad\";\nexport * from \"~/exception.js\";\nexport * from \"~/createIdentifier\";\nexport * from \"~/cursor\";\nexport * from \"~/headers\";\nexport * from \"~/generateId\";\nexport * from \"~/mdbid\";\nexport * from \"~/createZodError\";\nexport * from \"~/executeWithRetry\";\nexport * from \"~/removeUndefinedValues\";\nexport * from \"~/removeNullValues\";\nexport * from \"~/utcTimezones\";\nexport * from \"./cacheKey\";\nexport * from \"./getObjectProperties\";\nexport * from \"./middleware\";\nexport type { GenericRecord } from \"./GenericRecord\";\n\nimport type { AsyncProcessor, NextAsyncProcessor } from \"~/compose\";\nimport { composeAsync } from \"~/compose\";\n\nexport { composeAsync };\nexport type { AsyncProcessor, NextAsyncProcessor };\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CA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EAAA;AAAA;AACA,IAAAsB,oBAAA,GAAA1B,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAwB,oBAAA,EAAAvB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAsB,oBAAA,CAAAtB,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAc,oBAAA,CAAAtB,GAAA;IAAA;EAAA;AAAA;AACA,IAAAuB,WAAA,GAAA3B,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAyB,WAAA,EAAAxB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAuB,WAAA,CAAAvB,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAe,WAAA,CAAAvB,GAAA;IAAA;EAAA;AAAA;AAIA,IAAAwB,QAAA,GAAA5B,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"directory": "dist"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@webiny/error": "
|
|
19
|
-
"@webiny/plugins": "
|
|
18
|
+
"@webiny/error": "6.0.0-alpha.1",
|
|
19
|
+
"@webiny/plugins": "6.0.0-alpha.1",
|
|
20
20
|
"jsonpack": "1.1.5",
|
|
21
21
|
"mdbid": "1.0.0",
|
|
22
22
|
"nanoid": "3.3.8",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"p-retry": "4.6.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@webiny/project-utils": "
|
|
27
|
+
"@webiny/project-utils": "6.0.0-alpha.1",
|
|
28
28
|
"rimraf": "6.0.1",
|
|
29
29
|
"typescript": "5.3.3"
|
|
30
30
|
},
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
]
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9bd236cf5e689f209a11bec089207dcc2d41a53c"
|
|
46
46
|
}
|