@webiny/utils
Advanced tools
| export type ICacheKeyKeys = Record<string, any> | string | number; | ||
| export declare const createCacheKey: (input: ICacheKeyKeys) => string; |
+17
| import { sha256 } from "@noble/hashes/sha2.js"; | ||
| import { utf8ToBytes, bytesToHex } from "@noble/hashes/utils.js"; | ||
| const getCacheKey = input => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } else if (typeof input === "number") { | ||
| return `${input}`; | ||
| } | ||
| return JSON.stringify(input); | ||
| }; | ||
| export const createCacheKey = input => { | ||
| const key = getCacheKey(input); | ||
| const hash = sha256(utf8ToBytes(key)); | ||
| return bytesToHex(hash); | ||
| }; | ||
| //# sourceMappingURL=cacheKey.js.map |
| {"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":[]} |
| import { Plugin } from "@webiny/plugins"; | ||
| export interface ICompressedValue { | ||
| compression: string; | ||
| value: string; | ||
| } | ||
| export declare abstract class CompressionPlugin extends Plugin { | ||
| static type: string; | ||
| abstract canCompress(data: any): boolean; | ||
| abstract compress(data: any): Promise<ICompressedValue>; | ||
| abstract canDecompress(data: ICompressedValue | unknown): boolean; | ||
| abstract decompress(data: ICompressedValue | unknown): Promise<any>; | ||
| } |
| import { Plugin } from "@webiny/plugins"; | ||
| export class CompressionPlugin extends Plugin { | ||
| static type = "utils.compression"; | ||
| } | ||
| //# sourceMappingURL=CompressionPlugin.js.map |
| {"version":3,"names":["Plugin","CompressionPlugin","type"],"sources":["CompressionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport interface ICompressedValue {\n compression: string;\n value: string;\n}\n\nexport abstract class CompressionPlugin extends Plugin {\n public static override type: string = \"utils.compression\";\n public abstract canCompress(data: any): boolean;\n public abstract compress(data: any): Promise<ICompressedValue>;\n public abstract canDecompress(data: ICompressedValue | unknown): boolean;\n public abstract decompress(data: ICompressedValue | unknown): Promise<any>;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAeC,iBAAiB,SAASD,MAAM,CAAC;EACnD,OAAuBE,IAAI,GAAW,mBAAmB;AAK7D","ignoreList":[]} |
| import type { PluginsContainer } from "@webiny/plugins"; | ||
| import { type ICompressedValue } from "./CompressionPlugin.js"; | ||
| export interface ICompressorParams { | ||
| plugins: PluginsContainer; | ||
| } | ||
| export interface ICompressor { | ||
| disable(name: string): void; | ||
| enable(name: string): void; | ||
| /** | ||
| * Compresses the given data using the first plugin that can compress it. | ||
| */ | ||
| compress<T = unknown>(data: T): Promise<T | ICompressedValue>; | ||
| /** | ||
| * Decompresses the given data using the first plugin that can decompress it. | ||
| */ | ||
| decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T>; | ||
| } | ||
| declare class Compressor implements ICompressor { | ||
| private readonly _plugins; | ||
| private readonly disabled; | ||
| private get plugins(); | ||
| constructor(params: ICompressorParams); | ||
| disable(name: string): void; | ||
| enable(name: string): void; | ||
| compress<T = unknown>(data: T): Promise<T | ICompressedValue>; | ||
| decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T>; | ||
| } | ||
| export declare const createDefaultCompressor: (params: ICompressorParams) => Compressor; | ||
| export {}; |
| import { CompressionPlugin } from "./CompressionPlugin.js"; | ||
| import { createGzipCompression } from "./plugins/GzipCompression.js"; | ||
| import { createJsonpackCompression } from "./plugins/JsonpackCompression.js"; | ||
| class Compressor { | ||
| disabled = new Set(); | ||
| get plugins() { | ||
| return this._plugins.byType(CompressionPlugin.type).reverse(); | ||
| } | ||
| constructor(params) { | ||
| this._plugins = params.plugins; | ||
| } | ||
| disable(name) { | ||
| this.disabled.add(name); | ||
| } | ||
| enable(name) { | ||
| this.disabled.delete(name); | ||
| } | ||
| async compress(data) { | ||
| for (const plugin of this.plugins) { | ||
| /** | ||
| * We skip disabled plugins. | ||
| */ | ||
| if (plugin.name && this.disabled.has(plugin.name)) { | ||
| continue; | ||
| } | ||
| if (plugin.canCompress(data) === false) { | ||
| continue; | ||
| } | ||
| try { | ||
| return await plugin.compress(data); | ||
| } catch (ex) { | ||
| console.error(`Could not compress given data. More info in next line. Trying next plugin.`); | ||
| console.log(ex); | ||
| } | ||
| } | ||
| return data; | ||
| } | ||
| async decompress(data) { | ||
| for (const plugin of this.plugins) { | ||
| if (plugin.canDecompress(data) === false) { | ||
| continue; | ||
| } | ||
| try { | ||
| return await plugin.decompress(data); | ||
| } catch (ex) { | ||
| console.error(`Could not decompress given data. More info in next line. Trying next plugin.`); | ||
| console.log(ex); | ||
| } | ||
| } | ||
| return data; | ||
| } | ||
| } | ||
| export const createDefaultCompressor = params => { | ||
| const { | ||
| plugins | ||
| } = params; | ||
| plugins.register([createJsonpackCompression(), createGzipCompression()]); | ||
| return new Compressor({ | ||
| plugins | ||
| }); | ||
| }; | ||
| //# sourceMappingURL=Compressor.js.map |
| {"version":3,"names":["CompressionPlugin","createGzipCompression","createJsonpackCompression","Compressor","disabled","Set","plugins","_plugins","byType","type","reverse","constructor","params","disable","name","add","enable","delete","compress","data","plugin","has","canCompress","ex","console","error","log","decompress","canDecompress","createDefaultCompressor","register"],"sources":["Compressor.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { CompressionPlugin, type ICompressedValue } from \"./CompressionPlugin.js\";\nimport { createGzipCompression } from \"./plugins/GzipCompression.js\";\nimport { createJsonpackCompression } from \"./plugins/JsonpackCompression.js\";\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,SAASA,iBAAiB;AAC1B,SAASC,qBAAqB;AAC9B,SAASC,yBAAyB;AAmBlC,MAAMC,UAAU,CAAwB;EAGnBC,QAAQ,GAAgB,IAAIC,GAAG,CAAC,CAAC;EAElD,IAAYC,OAAOA,CAAA,EAAwB;IACvC,OAAO,IAAI,CAACC,QAAQ,CAACC,MAAM,CAAoBR,iBAAiB,CAACS,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;EACpF;EAEOC,WAAWA,CAACC,MAAyB,EAAE;IAC1C,IAAI,CAACL,QAAQ,GAAGK,MAAM,CAACN,OAAO;EAClC;EAEOO,OAAOA,CAACC,IAAY,EAAQ;IAC/B,IAAI,CAACV,QAAQ,CAACW,GAAG,CAACD,IAAI,CAAC;EAC3B;EAEOE,MAAMA,CAACF,IAAY,EAAQ;IAC9B,IAAI,CAACV,QAAQ,CAACa,MAAM,CAACH,IAAI,CAAC;EAC9B;EAEA,MAAaI,QAAQA,CAAcC,IAAO,EAAiC;IACvE,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACd,OAAO,EAAE;MAC/B;AACZ;AACA;MACY,IAAIc,MAAM,CAACN,IAAI,IAAI,IAAI,CAACV,QAAQ,CAACiB,GAAG,CAACD,MAAM,CAACN,IAAI,CAAC,EAAE;QAC/C;MACJ;MACA,IAAIM,MAAM,CAACE,WAAW,CAACH,IAAI,CAAC,KAAK,KAAK,EAAE;QACpC;MACJ;MACA,IAAI;QACA,OAAO,MAAMC,MAAM,CAACF,QAAQ,CAACC,IAAI,CAAC;MACtC,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CACT,4EACJ,CAAC;QACDD,OAAO,CAACE,GAAG,CAACH,EAAE,CAAC;MACnB;IACJ;IACA,OAAOJ,IAAI;EACf;EAEA,MAAaQ,UAAUA,CAAcR,IAAgC,EAAc;IAC/E,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACd,OAAO,EAAE;MAC/B,IAAIc,MAAM,CAACQ,aAAa,CAACT,IAAI,CAAC,KAAK,KAAK,EAAE;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;AAEA,OAAO,MAAMU,uBAAuB,GAAIjB,MAAyB,IAAK;EAClE,MAAM;IAAEN;EAAQ,CAAC,GAAGM,MAAM;EAC1BN,OAAO,CAACwB,QAAQ,CAAC,CAAC5B,yBAAyB,CAAC,CAAC,EAAED,qBAAqB,CAAC,CAAC,CAAC,CAAC;EACxE,OAAO,IAAIE,UAAU,CAAC;IAClBG;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]} |
| export * from "./Compressor.js"; | ||
| export * from "./CompressionPlugin.js"; | ||
| export * from "./plugins/GzipCompression.js"; | ||
| export * from "./plugins/JsonpackCompression.js"; |
| export * from "./Compressor.js"; | ||
| export * from "./CompressionPlugin.js"; | ||
| export * from "./plugins/GzipCompression.js"; | ||
| export * from "./plugins/JsonpackCompression.js"; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Compressor.js\";\nexport * from \"./CompressionPlugin.js\";\nexport * from \"./plugins/GzipCompression.js\";\nexport * from \"./plugins/JsonpackCompression.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]} |
| export declare const compress: (value: any) => Promise<string>; | ||
| export declare const decompress: (value: string) => Promise<{}>; |
| import jsonpack from "jsonpack"; | ||
| export const compress = async value => { | ||
| return jsonpack.pack(value, { | ||
| verbose: false | ||
| }); | ||
| }; | ||
| export const decompress = async value => { | ||
| return jsonpack.unpack(value); | ||
| }; | ||
| //# sourceMappingURL=jsonpack.js.map |
| {"version":3,"names":["jsonpack","compress","value","pack","verbose","decompress","unpack"],"sources":["jsonpack.ts"],"sourcesContent":["import jsonpack from \"jsonpack\";\n\nexport const compress = async (value: any) => {\n return jsonpack.pack(value, {\n verbose: false\n });\n};\n\nexport const decompress = async (value: string) => {\n return jsonpack.unpack(value);\n};\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,UAAU;AAE/B,OAAO,MAAMC,QAAQ,GAAG,MAAOC,KAAU,IAAK;EAC1C,OAAOF,QAAQ,CAACG,IAAI,CAACD,KAAK,EAAE;IACxBE,OAAO,EAAE;EACb,CAAC,CAAC;AACN,CAAC;AAED,OAAO,MAAMC,UAAU,GAAG,MAAOH,KAAa,IAAK;EAC/C,OAAOF,QAAQ,CAACM,MAAM,CAACJ,KAAK,CAAC;AACjC,CAAC","ignoreList":[]} |
| import { CompressionPlugin, type ICompressedValue } from "../CompressionPlugin.js"; | ||
| export declare const convertToBuffer: (value: string | Buffer) => Buffer<ArrayBufferLike>; | ||
| export declare class GzipCompression extends CompressionPlugin { | ||
| name: string; | ||
| canCompress(data: any): boolean; | ||
| compress(data: any): Promise<ICompressedValue>; | ||
| canDecompress(data: Partial<ICompressedValue>): boolean; | ||
| decompress(data: ICompressedValue): Promise<any>; | ||
| } | ||
| export declare const createGzipCompression: () => GzipCompression; |
| import { CompressionPlugin } from "../CompressionPlugin.js"; | ||
| import { compress as gzip, decompress as ungzip } from "../gzip.js"; | ||
| const GZIP = "gzip"; | ||
| const TO_STORAGE_ENCODING = "base64"; | ||
| const FROM_STORAGE_ENCODING = "utf8"; | ||
| export const convertToBuffer = value => { | ||
| if (typeof value === "string") { | ||
| return Buffer.from(value, TO_STORAGE_ENCODING); | ||
| } | ||
| return value; | ||
| }; | ||
| export class GzipCompression extends CompressionPlugin { | ||
| name = "utils.compression.gzip"; | ||
| canCompress(data) { | ||
| if (!!data?.compression) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| async compress(data) { | ||
| if (data === null || data === undefined) { | ||
| return data; | ||
| } | ||
| // This stringifies both regular strings and JSON objects. | ||
| const value = await gzip(JSON.stringify(data)); | ||
| return { | ||
| compression: GZIP, | ||
| value: value.toString(TO_STORAGE_ENCODING) | ||
| }; | ||
| } | ||
| canDecompress(data) { | ||
| if (!data?.compression) { | ||
| return false; | ||
| } | ||
| const compression = data.compression; | ||
| return compression.toLowerCase() === GZIP; | ||
| } | ||
| async decompress(data) { | ||
| if (!data) { | ||
| return data; | ||
| } else if (!data.value) { | ||
| return null; | ||
| } | ||
| try { | ||
| const buf = await ungzip(convertToBuffer(data.value)); | ||
| const value = buf.toString(FROM_STORAGE_ENCODING); | ||
| return JSON.parse(value); | ||
| } catch (ex) { | ||
| console.log(`Could not decompress given data.`, ex.message); | ||
| return null; | ||
| } | ||
| } | ||
| } | ||
| export const createGzipCompression = () => { | ||
| return new GzipCompression(); | ||
| }; | ||
| //# sourceMappingURL=GzipCompression.js.map |
| {"version":3,"names":["CompressionPlugin","compress","gzip","decompress","ungzip","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","GzipCompression","name","canCompress","data","compression","undefined","JSON","stringify","toString","canDecompress","toLowerCase","buf","parse","ex","console","log","message","createGzipCompression"],"sources":["GzipCompression.ts"],"sourcesContent":["import { CompressionPlugin, type ICompressedValue } from \"../CompressionPlugin.js\";\nimport { compress as gzip, decompress as ungzip } from \"~/compression/gzip.js\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nexport const convertToBuffer = (value: string | Buffer) => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport class GzipCompression extends CompressionPlugin {\n public override name = \"utils.compression.gzip\";\n\n public override canCompress(data: any): boolean {\n if (!!data?.compression) {\n return false;\n }\n return true;\n }\n\n public override async compress(data: any): Promise<ICompressedValue> {\n if (data === null || data === undefined) {\n return data;\n }\n // This stringifies both regular strings and JSON objects.\n const value = await gzip(JSON.stringify(data));\n\n return {\n compression: GZIP,\n value: value.toString(TO_STORAGE_ENCODING)\n };\n }\n\n public override canDecompress(data: Partial<ICompressedValue>): boolean {\n if (!data?.compression) {\n return false;\n }\n\n const compression = data.compression as string;\n\n return compression.toLowerCase() === GZIP;\n }\n\n public override async decompress(data: ICompressedValue): Promise<any> {\n if (!data) {\n return data;\n } else if (!data.value) {\n return null;\n }\n try {\n const buf = await ungzip(convertToBuffer(data.value));\n const value = buf.toString(FROM_STORAGE_ENCODING);\n return JSON.parse(value);\n } catch (ex) {\n console.log(`Could not decompress given data.`, ex.message);\n return null;\n }\n }\n}\n\nexport const createGzipCompression = () => {\n return new GzipCompression();\n};\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,SAASC,QAAQ,IAAIC,IAAI,EAAEC,UAAU,IAAIC,MAAM;AAE/C,MAAMC,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,OAAO,MAAMC,eAAe,GAAIC,KAAsB,IAAK;EACvD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAED,OAAO,MAAMG,eAAe,SAASZ,iBAAiB,CAAC;EACnCa,IAAI,GAAG,wBAAwB;EAE/BC,WAAWA,CAACC,IAAS,EAAW;IAC5C,IAAI,CAAC,CAACA,IAAI,EAAEC,WAAW,EAAE;MACrB,OAAO,KAAK;IAChB;IACA,OAAO,IAAI;EACf;EAEA,MAAsBf,QAAQA,CAACc,IAAS,EAA6B;IACjE,IAAIA,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAKE,SAAS,EAAE;MACrC,OAAOF,IAAI;IACf;IACA;IACA,MAAMN,KAAK,GAAG,MAAMP,IAAI,CAACgB,IAAI,CAACC,SAAS,CAACJ,IAAI,CAAC,CAAC;IAE9C,OAAO;MACHC,WAAW,EAAEX,IAAI;MACjBI,KAAK,EAAEA,KAAK,CAACW,QAAQ,CAACd,mBAAmB;IAC7C,CAAC;EACL;EAEgBe,aAAaA,CAACN,IAA+B,EAAW;IACpE,IAAI,CAACA,IAAI,EAAEC,WAAW,EAAE;MACpB,OAAO,KAAK;IAChB;IAEA,MAAMA,WAAW,GAAGD,IAAI,CAACC,WAAqB;IAE9C,OAAOA,WAAW,CAACM,WAAW,CAAC,CAAC,KAAKjB,IAAI;EAC7C;EAEA,MAAsBF,UAAUA,CAACY,IAAsB,EAAgB;IACnE,IAAI,CAACA,IAAI,EAAE;MACP,OAAOA,IAAI;IACf,CAAC,MAAM,IAAI,CAACA,IAAI,CAACN,KAAK,EAAE;MACpB,OAAO,IAAI;IACf;IACA,IAAI;MACA,MAAMc,GAAG,GAAG,MAAMnB,MAAM,CAACI,eAAe,CAACO,IAAI,CAACN,KAAK,CAAC,CAAC;MACrD,MAAMA,KAAK,GAAGc,GAAG,CAACH,QAAQ,CAACb,qBAAqB,CAAC;MACjD,OAAOW,IAAI,CAACM,KAAK,CAACf,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOgB,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC,kCAAkC,EAAEF,EAAE,CAACG,OAAO,CAAC;MAC3D,OAAO,IAAI;IACf;EACJ;AACJ;AAEA,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,IAAIjB,eAAe,CAAC,CAAC;AAChC,CAAC","ignoreList":[]} |
| import { CompressionPlugin, type ICompressedValue } from "../CompressionPlugin.js"; | ||
| export declare class JsonpackCompression extends CompressionPlugin { | ||
| name: string; | ||
| canCompress(data: any): boolean; | ||
| compress(data: any): Promise<ICompressedValue>; | ||
| canDecompress(data: Partial<ICompressedValue>): boolean; | ||
| decompress(data: ICompressedValue): Promise<any>; | ||
| } | ||
| export declare const createJsonpackCompression: () => JsonpackCompression; |
| import { CompressionPlugin } from "../CompressionPlugin.js"; | ||
| import { compress, decompress } from "../jsonpack.js"; | ||
| const JSONPACK = "jsonpack"; | ||
| export class JsonpackCompression extends CompressionPlugin { | ||
| name = "utils.compression.jsonpack"; | ||
| canCompress(data) { | ||
| if (typeof data !== "object") { | ||
| return false; | ||
| } else if (!!data.compression) { | ||
| return false; | ||
| } | ||
| // TODO Do we want to compress anything with jsonpack anymore? Maybe not... | ||
| return false; | ||
| } | ||
| async compress(data) { | ||
| if (data === null || data === undefined) { | ||
| return data; | ||
| } | ||
| const value = await compress(data); | ||
| return { | ||
| compression: JSONPACK, | ||
| value | ||
| }; | ||
| } | ||
| canDecompress(data) { | ||
| if (typeof data !== "object") { | ||
| return false; | ||
| } else if (!data?.compression) { | ||
| return false; | ||
| } | ||
| const compression = data.compression; | ||
| return compression.toLowerCase() === JSONPACK; | ||
| } | ||
| async decompress(data) { | ||
| if (!data) { | ||
| return data; | ||
| } else if (!data.value) { | ||
| return null; | ||
| } | ||
| try { | ||
| return await decompress(data.value); | ||
| } catch (ex) { | ||
| console.log(`Could not decompress given data.`, ex.message); | ||
| return null; | ||
| } | ||
| } | ||
| } | ||
| export const createJsonpackCompression = () => { | ||
| return new JsonpackCompression(); | ||
| }; | ||
| //# sourceMappingURL=JsonpackCompression.js.map |
| {"version":3,"names":["CompressionPlugin","compress","decompress","JSONPACK","JsonpackCompression","name","canCompress","data","compression","undefined","value","canDecompress","toLowerCase","ex","console","log","message","createJsonpackCompression"],"sources":["JsonpackCompression.ts"],"sourcesContent":["import { CompressionPlugin, type ICompressedValue } from \"../CompressionPlugin.js\";\nimport { compress, decompress } from \"~/compression/jsonpack.js\";\n\nconst JSONPACK = \"jsonpack\";\n\nexport class JsonpackCompression extends CompressionPlugin {\n public override name = \"utils.compression.jsonpack\";\n\n public override canCompress(data: any): boolean {\n if (typeof data !== \"object\") {\n return false;\n } else if (!!data.compression) {\n return false;\n }\n // TODO Do we want to compress anything with jsonpack anymore? Maybe not...\n return false;\n }\n\n public override async compress(data: any): Promise<ICompressedValue> {\n if (data === null || data === undefined) {\n return data;\n }\n const value = await compress(data);\n\n return {\n compression: JSONPACK,\n value\n };\n }\n\n public override canDecompress(data: Partial<ICompressedValue>): boolean {\n if (typeof data !== \"object\") {\n return false;\n } else if (!data?.compression) {\n return false;\n }\n\n const compression = data.compression as string;\n return compression.toLowerCase() === JSONPACK;\n }\n\n public override async decompress(data: ICompressedValue): Promise<any> {\n if (!data) {\n return data;\n } else if (!data.value) {\n return null;\n }\n try {\n return await decompress(data.value);\n } catch (ex) {\n console.log(`Could not decompress given data.`, ex.message);\n return null;\n }\n }\n}\n\nexport const createJsonpackCompression = () => {\n return new JsonpackCompression();\n};\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,SAASC,QAAQ,EAAEC,UAAU;AAE7B,MAAMC,QAAQ,GAAG,UAAU;AAE3B,OAAO,MAAMC,mBAAmB,SAASJ,iBAAiB,CAAC;EACvCK,IAAI,GAAG,4BAA4B;EAEnCC,WAAWA,CAACC,IAAS,EAAW;IAC5C,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAO,KAAK;IAChB,CAAC,MAAM,IAAI,CAAC,CAACA,IAAI,CAACC,WAAW,EAAE;MAC3B,OAAO,KAAK;IAChB;IACA;IACA,OAAO,KAAK;EAChB;EAEA,MAAsBP,QAAQA,CAACM,IAAS,EAA6B;IACjE,IAAIA,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAKE,SAAS,EAAE;MACrC,OAAOF,IAAI;IACf;IACA,MAAMG,KAAK,GAAG,MAAMT,QAAQ,CAACM,IAAI,CAAC;IAElC,OAAO;MACHC,WAAW,EAAEL,QAAQ;MACrBO;IACJ,CAAC;EACL;EAEgBC,aAAaA,CAACJ,IAA+B,EAAW;IACpE,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAO,KAAK;IAChB,CAAC,MAAM,IAAI,CAACA,IAAI,EAAEC,WAAW,EAAE;MAC3B,OAAO,KAAK;IAChB;IAEA,MAAMA,WAAW,GAAGD,IAAI,CAACC,WAAqB;IAC9C,OAAOA,WAAW,CAACI,WAAW,CAAC,CAAC,KAAKT,QAAQ;EACjD;EAEA,MAAsBD,UAAUA,CAACK,IAAsB,EAAgB;IACnE,IAAI,CAACA,IAAI,EAAE;MACP,OAAOA,IAAI;IACf,CAAC,MAAM,IAAI,CAACA,IAAI,CAACG,KAAK,EAAE;MACpB,OAAO,IAAI;IACf;IACA,IAAI;MACA,OAAO,MAAMR,UAAU,CAACK,IAAI,CAACG,KAAK,CAAC;IACvC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC,kCAAkC,EAAEF,EAAE,CAACG,OAAO,CAAC;MAC3D,OAAO,IAAI;IACf;EACJ;AACJ;AAEA,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,IAAIb,mBAAmB,CAAC,CAAC;AACpC,CAAC","ignoreList":[]} |
| import WebinyError from "@webiny/error"; | ||
| import type { ZodError } from "zod"; | ||
| interface OutputError { | ||
| code: string; | ||
| data: Record<string, any> | null; | ||
| message: string; | ||
| } | ||
| export interface OutputErrors { | ||
| [key: string]: OutputError; | ||
| } | ||
| export declare const createZodError: (error: ZodError) => WebinyError<{ | ||
| invalidFields: OutputErrors; | ||
| }>; | ||
| export {}; |
| import WebinyError from "@webiny/error"; | ||
| import { generateAlphaNumericId } from "./generateId.js"; | ||
| const createValidationErrorData = error => { | ||
| return { | ||
| invalidFields: error.issues.reduce((collection, issue) => { | ||
| const name = issue.path.join("."); | ||
| if (!name && !issue.code) { | ||
| return collection; | ||
| } | ||
| const key = name || issue.path.join(".") || issue.message || issue.code || generateAlphaNumericId(); | ||
| collection[key] = { | ||
| code: issue.code, | ||
| message: issue.message, | ||
| data: { | ||
| fatal: issue.fatal, | ||
| path: issue.path | ||
| } | ||
| }; | ||
| return collection; | ||
| }, {}) | ||
| }; | ||
| }; | ||
| export const createZodError = error => { | ||
| return new WebinyError({ | ||
| message: `Validation failed.`, | ||
| code: "VALIDATION_FAILED_INVALID_FIELDS", | ||
| data: createValidationErrorData(error) | ||
| }); | ||
| }; | ||
| //# sourceMappingURL=createZodError.js.map |
| {"version":3,"names":["WebinyError","generateAlphaNumericId","createValidationErrorData","error","invalidFields","issues","reduce","collection","issue","name","path","join","code","key","message","data","fatal","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 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,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;UACFC,KAAK,EAAER,KAAK,CAACQ,KAAK;UAClBN,IAAI,EAAEF,KAAK,CAACE;QAChB;MACJ,CAAC;MAED,OAAOH,UAAU;IACrB,CAAC,EAAE,CAAC,CAAC;EACT,CAAC;AACL,CAAC;AAED,OAAO,MAAMU,cAAc,GAAId,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":[]} |
| import type { GenericRecord } from "./GenericRecord.js"; | ||
| /** | ||
| * This will help with output of the error object. | ||
| * Normally, the error object is not serializable, so we need to convert it to a plain object. | ||
| */ | ||
| export declare const convertException: (error: Error, remove?: string[]) => GenericRecord; |
+16
| /** | ||
| * This will help with output of the error object. | ||
| * Normally, the error object is not serializable, so we need to convert it to a plain object. | ||
| */ | ||
| export const convertException = (error, remove) => { | ||
| const properties = Object.getOwnPropertyNames(error); | ||
| return properties.reduce((items, property) => { | ||
| if (remove && remove.includes(property)) { | ||
| return items; | ||
| } | ||
| items[property] = error[property]; | ||
| return items; | ||
| }, {}); | ||
| }; | ||
| //# sourceMappingURL=exception.js.map |
| {"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":[]} |
| import pRetry from "p-retry"; | ||
| export type ExecuteWithRetryOptions = Parameters<typeof pRetry>[1]; | ||
| export declare const executeWithRetry: <T>(execute: () => Promise<T>, options?: ExecuteWithRetryOptions) => Promise<T>; |
| import pRetry from "p-retry"; | ||
| export const executeWithRetry = (execute, options) => { | ||
| const retries = 20; | ||
| return pRetry(execute, { | ||
| maxRetryTime: 300000, | ||
| retries, | ||
| minTimeout: 1500, | ||
| maxTimeout: 30000, | ||
| ...options | ||
| }); | ||
| }; | ||
| //# sourceMappingURL=executeWithRetry.js.map |
| {"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":[]} |
| export type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>; |
| export {}; | ||
| //# sourceMappingURL=GenericRecord.js.map |
| {"version":3,"names":[],"sources":["GenericRecord.ts"],"sourcesContent":["export type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;\n"],"mappings":"","ignoreList":[]} |
| /** | ||
| * Unfortunately we need some casting as we do not know which properties are available on the object. | ||
| */ | ||
| interface GenericRecord { | ||
| [key: string]: any; | ||
| } | ||
| export declare const getObjectProperties: <T = GenericRecord>(input: unknown) => T; | ||
| export {}; |
| /** | ||
| * Unfortunately we need some casting as we do not know which properties are available on the object. | ||
| */ | ||
| export const getObjectProperties = input => { | ||
| if (!input || typeof input !== "object") { | ||
| return {}; | ||
| } | ||
| return Object.getOwnPropertyNames(input).reduce((acc, key) => { | ||
| acc[key] = input[key]; | ||
| return acc; | ||
| }, {}); | ||
| }; | ||
| //# sourceMappingURL=getObjectProperties.js.map |
| {"version":3,"names":["getObjectProperties","input","Object","getOwnPropertyNames","reduce","acc","key"],"sources":["getObjectProperties.ts"],"sourcesContent":["/**\n * Unfortunately we need some casting as we do not know which properties are available on the object.\n */\ninterface GenericRecord {\n [key: string]: any;\n}\n\nexport const getObjectProperties = <T = GenericRecord>(input: unknown): T => {\n if (!input || typeof input !== \"object\") {\n return {} as unknown as T;\n }\n return Object.getOwnPropertyNames(input).reduce<T>((acc, key) => {\n acc[key as keyof T] = (input as unknown as T)[key as keyof T];\n return acc;\n }, {} as T) as unknown as T;\n};\n"],"mappings":"AAAA;AACA;AACA;;AAKA,OAAO,MAAMA,mBAAmB,GAAuBC,KAAc,IAAQ;EACzE,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACrC,OAAO,CAAC,CAAC;EACb;EACA,OAAOC,MAAM,CAACC,mBAAmB,CAACF,KAAK,CAAC,CAACG,MAAM,CAAI,CAACC,GAAG,EAAEC,GAAG,KAAK;IAC7DD,GAAG,CAACC,GAAG,CAAY,GAAIL,KAAK,CAAkBK,GAAG,CAAY;IAC7D,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAM,CAAC;AACf,CAAC","ignoreList":[]} |
| export declare const mdbid: () => string; |
+6
| import ObjectID from "bson-objectid"; | ||
| export const mdbid = () => { | ||
| return ObjectID().toHexString(); | ||
| }; | ||
| //# sourceMappingURL=mdbid.js.map |
| {"version":3,"names":["ObjectID","mdbid","toHexString"],"sources":["mdbid.ts"],"sourcesContent":["import ObjectID from \"bson-objectid\";\n\nexport const mdbid = () => {\n return ObjectID().toHexString();\n};\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,eAAe;AAEpC,OAAO,MAAMC,KAAK,GAAGA,CAAA,KAAM;EACvB,OAAOD,QAAQ,CAAC,CAAC,CAACE,WAAW,CAAC,CAAC;AACnC,CAAC","ignoreList":[]} |
| export interface MiddlewareCallable { | ||
| (...args: any[]): Promise<any>; | ||
| } | ||
| export interface MiddlewareResolve { | ||
| (...args: any[]): void; | ||
| } | ||
| export interface MiddlewareReject { | ||
| (error: Error): void; | ||
| } | ||
| /** | ||
| * Compose a single middleware from the array of middleware functions | ||
| */ | ||
| export declare const middleware: <Params = any, Response = any>(functions?: MiddlewareCallable[]) => (...args: Params[]) => Promise<Response | undefined>; |
| /** | ||
| * Compose a single middleware from the array of middleware functions | ||
| */ | ||
| export const middleware = (functions = []) => { | ||
| return (...args) => { | ||
| if (!functions.length) { | ||
| return Promise.resolve(undefined); | ||
| } | ||
| // Create a clone of function chain to prevent modifying the original array with `shift()` | ||
| const chain = [...functions]; | ||
| return new Promise((parentResolve, parentReject) => { | ||
| const next = async () => { | ||
| const fn = chain.shift(); | ||
| if (!fn) { | ||
| return Promise.resolve(); | ||
| } | ||
| return new Promise(async (resolve, reject) => { | ||
| try { | ||
| const result = await fn(...args, resolve); | ||
| if (typeof result !== "undefined") { | ||
| return parentResolve(result); | ||
| } | ||
| } catch (e) { | ||
| reject(e); | ||
| } | ||
| }).then(() => { | ||
| return next(); | ||
| }).then(() => { | ||
| parentResolve(...args); | ||
| }).catch(e => { | ||
| parentReject(e); | ||
| }); | ||
| }; | ||
| return next(); | ||
| }); | ||
| }; | ||
| }; | ||
| //# sourceMappingURL=middleware.js.map |
| {"version":3,"names":["middleware","functions","args","length","Promise","resolve","undefined","chain","parentResolve","parentReject","next","fn","shift","reject","result","e","then","catch"],"sources":["middleware.ts"],"sourcesContent":["export interface MiddlewareCallable {\n (...args: any[]): Promise<any>;\n}\n\nexport interface MiddlewareResolve {\n (...args: any[]): void;\n}\n\nexport interface MiddlewareReject {\n (error: Error): void;\n}\n/**\n * Compose a single middleware from the array of middleware functions\n */\nexport const middleware = <Params = any, Response = any>(functions: MiddlewareCallable[] = []) => {\n return (...args: Params[]): Promise<Response | undefined> => {\n if (!functions.length) {\n return Promise.resolve<Response | undefined>(undefined);\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n const chain = [...functions];\n return new Promise((parentResolve: MiddlewareResolve, parentReject: MiddlewareReject) => {\n const next = async (): Promise<any> => {\n const fn = chain.shift();\n if (!fn) {\n return Promise.resolve();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n const result = await fn(...args, resolve);\n if (typeof result !== \"undefined\") {\n return parentResolve(result);\n }\n } catch (e) {\n reject(e);\n }\n })\n .then(() => {\n return next();\n })\n .then(() => {\n parentResolve(...args);\n })\n .catch(e => {\n parentReject(e);\n });\n };\n\n return next();\n });\n };\n};\n"],"mappings":"AAWA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAGA,CAA+BC,SAA+B,GAAG,EAAE,KAAK;EAC9F,OAAO,CAAC,GAAGC,IAAc,KAAoC;IACzD,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOC,OAAO,CAACC,OAAO,CAAuBC,SAAS,CAAC;IAC3D;;IAEA;IACA,MAAMC,KAAK,GAAG,CAAC,GAAGN,SAAS,CAAC;IAC5B,OAAO,IAAIG,OAAO,CAAC,CAACI,aAAgC,EAAEC,YAA8B,KAAK;MACrF,MAAMC,IAAI,GAAG,MAAAA,CAAA,KAA0B;QACnC,MAAMC,EAAE,GAAGJ,KAAK,CAACK,KAAK,CAAC,CAAC;QACxB,IAAI,CAACD,EAAE,EAAE;UACL,OAAOP,OAAO,CAACC,OAAO,CAAC,CAAC;QAC5B;QAEA,OAAO,IAAID,OAAO,CAAC,OAAOC,OAAO,EAAEQ,MAAM,KAAK;UAC1C,IAAI;YACA,MAAMC,MAAM,GAAG,MAAMH,EAAE,CAAC,GAAGT,IAAI,EAAEG,OAAO,CAAC;YACzC,IAAI,OAAOS,MAAM,KAAK,WAAW,EAAE;cAC/B,OAAON,aAAa,CAACM,MAAM,CAAC;YAChC;UACJ,CAAC,CAAC,OAAOC,CAAC,EAAE;YACRF,MAAM,CAACE,CAAC,CAAC;UACb;QACJ,CAAC,CAAC,CACGC,IAAI,CAAC,MAAM;UACR,OAAON,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC,CACDM,IAAI,CAAC,MAAM;UACRR,aAAa,CAAC,GAAGN,IAAI,CAAC;QAC1B,CAAC,CAAC,CACDe,KAAK,CAACF,CAAC,IAAI;UACRN,YAAY,CAACM,CAAC,CAAC;QACnB,CAAC,CAAC;MACV,CAAC;MAED,OAAOL,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]} |
| type WithoutNullableKeys<Type> = { | ||
| [Key in keyof Type]-?: WithoutNullableKeys<NonNullable<Type[Key]>>; | ||
| }; | ||
| export declare const removeNullValues: <T extends Record<string, any>>(target: T) => WithoutNullableKeys<T>; | ||
| export {}; |
| export const removeNullValues = target => { | ||
| const result = {}; | ||
| for (const key in target) { | ||
| if (target[key] === null) { | ||
| continue; | ||
| } | ||
| result[key] = target[key]; | ||
| } | ||
| return result; | ||
| }; | ||
| //# sourceMappingURL=removeNullValues.js.map |
| {"version":3,"names":["removeNullValues","target","result","key"],"sources":["removeNullValues.ts"],"sourcesContent":["type WithoutNullableKeys<Type> = {\n [Key in keyof Type]-?: WithoutNullableKeys<NonNullable<Type[Key]>>;\n};\n\nexport const removeNullValues = <T extends Record<string, any>>(target: T) => {\n const result = {} as WithoutNullableKeys<T>;\n for (const key in target) {\n if (target[key] === null) {\n continue;\n }\n\n result[key] = target[key];\n }\n return result;\n};\n"],"mappings":"AAIA,OAAO,MAAMA,gBAAgB,GAAmCC,MAAS,IAAK;EAC1E,MAAMC,MAAM,GAAG,CAAC,CAA2B;EAC3C,KAAK,MAAMC,GAAG,IAAIF,MAAM,EAAE;IACtB,IAAIA,MAAM,CAACE,GAAG,CAAC,KAAK,IAAI,EAAE;MACtB;IACJ;IAEAD,MAAM,CAACC,GAAG,CAAC,GAAGF,MAAM,CAACE,GAAG,CAAC;EAC7B;EACA,OAAOD,MAAM;AACjB,CAAC","ignoreList":[]} |
| export declare const removeUndefinedValues: <T extends Record<string, any>>(target: T) => T; |
| export const removeUndefinedValues = target => { | ||
| const result = {}; | ||
| for (const key in target) { | ||
| if (target[key] === undefined) { | ||
| continue; | ||
| } | ||
| result[key] = target[key]; | ||
| } | ||
| return result; | ||
| }; | ||
| //# sourceMappingURL=removeUndefinedValues.js.map |
| {"version":3,"names":["removeUndefinedValues","target","result","key","undefined"],"sources":["removeUndefinedValues.ts"],"sourcesContent":["export const removeUndefinedValues = <T extends Record<string, any>>(target: T) => {\n const result = {} as T;\n for (const key in target) {\n if (target[key] === undefined) {\n continue;\n }\n\n result[key] = target[key];\n }\n return result;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,GAAmCC,MAAS,IAAK;EAC/E,MAAMC,MAAM,GAAG,CAAC,CAAM;EACtB,KAAK,MAAMC,GAAG,IAAIF,MAAM,EAAE;IACtB,IAAIA,MAAM,CAACE,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC3B;IACJ;IAEAF,MAAM,CAACC,GAAG,CAAC,GAAGF,MAAM,CAACE,GAAG,CAAC;EAC7B;EACA,OAAOD,MAAM;AACjB,CAAC","ignoreList":[]} |
| export declare const UTC_TIMEZONES: { | ||
| value: string; | ||
| label: string; | ||
| }[]; |
+120
| export const UTC_TIMEZONES = [{ | ||
| value: "-12:00", | ||
| label: "UTC-12:00" | ||
| }, { | ||
| value: "-11:00", | ||
| label: "UTC-11:00" | ||
| }, { | ||
| value: "-10:00", | ||
| label: "UTC-10:00" | ||
| }, { | ||
| value: "-09:30", | ||
| label: "UTC-09:30" | ||
| }, { | ||
| value: "-09:00", | ||
| label: "UTC-09:00" | ||
| }, { | ||
| value: "-08:00", | ||
| label: "UTC-08:00" | ||
| }, { | ||
| value: "-07:00", | ||
| label: "UTC-07:00" | ||
| }, { | ||
| value: "-06:00", | ||
| label: "UTC-06:00" | ||
| }, { | ||
| value: "-05:00", | ||
| label: "UTC-05:00" | ||
| }, { | ||
| value: "-04:30", | ||
| label: "UTC-04:30" | ||
| }, { | ||
| value: "-04:00", | ||
| label: "UTC-04:00" | ||
| }, { | ||
| value: "-03:30", | ||
| label: "UTC-03:30" | ||
| }, { | ||
| value: "-03:00", | ||
| label: "UTC-03:00" | ||
| }, { | ||
| value: "-02:00", | ||
| label: "UTC-02:00" | ||
| }, { | ||
| value: "-01:00", | ||
| label: "UTC-01:00" | ||
| }, { | ||
| value: "+00:00", | ||
| label: "UTC+00:00" | ||
| }, { | ||
| value: "+01:00", | ||
| label: "UTC+01:00" | ||
| }, { | ||
| value: "+02:00", | ||
| label: "UTC+02:00" | ||
| }, { | ||
| value: "+03:00", | ||
| label: "UTC+03:00" | ||
| }, { | ||
| value: "+03:30", | ||
| label: "UTC+03:30" | ||
| }, { | ||
| value: "+04:00", | ||
| label: "UTC+04:00" | ||
| }, { | ||
| value: "+04:30", | ||
| label: "UTC+04:30" | ||
| }, { | ||
| value: "+05:30", | ||
| label: "UTC+05:30" | ||
| }, { | ||
| value: "+05:45", | ||
| label: "UTC+05:45" | ||
| }, { | ||
| value: "+06:00", | ||
| label: "UTC+06:00" | ||
| }, { | ||
| value: "+06:30", | ||
| label: "UTC+06:30" | ||
| }, { | ||
| value: "+07:00", | ||
| label: "UTC+07:00" | ||
| }, { | ||
| value: "+08:00", | ||
| label: "UTC+08:00" | ||
| }, { | ||
| value: "+08:45", | ||
| label: "UTC+08:45" | ||
| }, { | ||
| value: "+09:00", | ||
| label: "UTC+09:00" | ||
| }, { | ||
| value: "+09:30", | ||
| label: "UTC+09:30" | ||
| }, { | ||
| value: "+10:00", | ||
| label: "UTC+10:00" | ||
| }, { | ||
| value: "+10:30", | ||
| label: "UTC+10:30" | ||
| }, { | ||
| value: "+11:00", | ||
| label: "UTC+11:00" | ||
| }, { | ||
| value: "+11:30", | ||
| label: "UTC+11:30" | ||
| }, { | ||
| value: "+12:00", | ||
| label: "UTC+12:00" | ||
| }, { | ||
| value: "+12:45", | ||
| label: "UTC+12:45" | ||
| }, { | ||
| value: "+13:00", | ||
| label: "UTC+13:00" | ||
| }, { | ||
| value: "+14:00", | ||
| label: "UTC+14:00" | ||
| }]; | ||
| //# sourceMappingURL=utcTimezones.js.map |
| {"version":3,"names":["UTC_TIMEZONES","value","label"],"sources":["utcTimezones.ts"],"sourcesContent":["export const UTC_TIMEZONES = [\n {\n value: \"-12:00\",\n label: \"UTC-12:00\"\n },\n {\n value: \"-11:00\",\n label: \"UTC-11:00\"\n },\n {\n value: \"-10:00\",\n label: \"UTC-10:00\"\n },\n {\n value: \"-09:30\",\n label: \"UTC-09:30\"\n },\n {\n value: \"-09:00\",\n label: \"UTC-09:00\"\n },\n {\n value: \"-08:00\",\n label: \"UTC-08:00\"\n },\n {\n value: \"-07:00\",\n label: \"UTC-07:00\"\n },\n {\n value: \"-06:00\",\n label: \"UTC-06:00\"\n },\n {\n value: \"-05:00\",\n label: \"UTC-05:00\"\n },\n {\n value: \"-04:30\",\n label: \"UTC-04:30\"\n },\n {\n value: \"-04:00\",\n label: \"UTC-04:00\"\n },\n {\n value: \"-03:30\",\n label: \"UTC-03:30\"\n },\n {\n value: \"-03:00\",\n label: \"UTC-03:00\"\n },\n {\n value: \"-02:00\",\n label: \"UTC-02:00\"\n },\n {\n value: \"-01:00\",\n label: \"UTC-01:00\"\n },\n {\n value: \"+00:00\",\n label: \"UTC+00:00\"\n },\n {\n value: \"+01:00\",\n label: \"UTC+01:00\"\n },\n {\n value: \"+02:00\",\n label: \"UTC+02:00\"\n },\n {\n value: \"+03:00\",\n label: \"UTC+03:00\"\n },\n {\n value: \"+03:30\",\n label: \"UTC+03:30\"\n },\n {\n value: \"+04:00\",\n label: \"UTC+04:00\"\n },\n {\n value: \"+04:30\",\n label: \"UTC+04:30\"\n },\n {\n value: \"+05:30\",\n label: \"UTC+05:30\"\n },\n {\n value: \"+05:45\",\n label: \"UTC+05:45\"\n },\n {\n value: \"+06:00\",\n label: \"UTC+06:00\"\n },\n {\n value: \"+06:30\",\n label: \"UTC+06:30\"\n },\n {\n value: \"+07:00\",\n label: \"UTC+07:00\"\n },\n {\n value: \"+08:00\",\n label: \"UTC+08:00\"\n },\n {\n value: \"+08:45\",\n label: \"UTC+08:45\"\n },\n {\n value: \"+09:00\",\n label: \"UTC+09:00\"\n },\n {\n value: \"+09:30\",\n label: \"UTC+09:30\"\n },\n {\n value: \"+10:00\",\n label: \"UTC+10:00\"\n },\n {\n value: \"+10:30\",\n label: \"UTC+10:30\"\n },\n {\n value: \"+11:00\",\n label: \"UTC+11:00\"\n },\n {\n value: \"+11:30\",\n label: \"UTC+11:30\"\n },\n {\n value: \"+12:00\",\n label: \"UTC+12:00\"\n },\n {\n value: \"+12:45\",\n label: \"UTC+12:45\"\n },\n {\n value: \"+13:00\",\n label: \"UTC+13:00\"\n },\n {\n value: \"+14:00\",\n label: \"UTC+14:00\"\n }\n];\n"],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAG,CACzB;EACIC,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,EACD;EACID,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAE;AACX,CAAC,CACJ","ignoreList":[]} |
+7
-23
@@ -1,10 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.composeAsync = composeAsync; | ||
| exports.composeSync = composeSync; | ||
| function composeAsync(functions = []) { | ||
| export function composeAsync(functions = []) { | ||
| return input => { | ||
@@ -14,42 +6,34 @@ if (!functions.length) { | ||
| } | ||
| let index = -1; | ||
| const next = async input => { | ||
| index++; | ||
| const fn = functions[index]; | ||
| if (!fn) { | ||
| return input; | ||
| } | ||
| return fn(next)(input); | ||
| }; | ||
| return next(input); | ||
| }; | ||
| } | ||
| function composeSync(functions = []) { | ||
| export function composeSync(functions = []) { | ||
| return input => { | ||
| if (!functions.length) { | ||
| return input; | ||
| } // Create a clone of function chain to prevent modifying the original array with `shift()` | ||
| } | ||
| // Create a clone of function chain to prevent modifying the original array with `shift()` | ||
| let index = -1; | ||
| const next = input => { | ||
| index++; | ||
| const fn = functions[index]; | ||
| if (!fn) { | ||
| return input; | ||
| } | ||
| return fn(next)(input); | ||
| }; | ||
| return next(input); | ||
| }; | ||
| } | ||
| } | ||
| //# sourceMappingURL=compose.js.map |
@@ -1,4 +0,3 @@ | ||
| /// <reference types="node" /> | ||
| import zlib from "zlib"; | ||
| export declare const compress: (input: zlib.InputType, options?: zlib.ZlibOptions) => Promise<Buffer>; | ||
| export declare const decompress: (input: zlib.InputType, options?: zlib.ZlibOptions) => Promise<Buffer>; |
+6
-19
@@ -1,15 +0,5 @@ | ||
| "use strict"; | ||
| var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.decompress = exports.compress = void 0; | ||
| var _zlib = _interopRequireDefault(require("zlib")); | ||
| const compress = (input, options) => { | ||
| import zlib from "zlib"; | ||
| export const compress = (input, options) => { | ||
| return new Promise(function (resolve, reject) { | ||
| _zlib.default.gzip(input, options || {}, function (error, result) { | ||
| zlib.gzip(input, options || {}, function (error, result) { | ||
| if (!error) { | ||
@@ -23,8 +13,5 @@ resolve(result); | ||
| }; | ||
| exports.compress = compress; | ||
| const decompress = (input, options) => { | ||
| export const decompress = (input, options) => { | ||
| return new Promise(function (resolve, reject) { | ||
| _zlib.default.gunzip(input, options || {}, function (error, result) { | ||
| zlib.gunzip(input, options || {}, function (error, result) { | ||
| if (!error) { | ||
@@ -39,2 +26,2 @@ resolve(result); | ||
| exports.decompress = decompress; | ||
| //# sourceMappingURL=gzip.js.map |
+13
-13
@@ -1,19 +0,19 @@ | ||
| "use strict"; | ||
| import { zeroPad } from "./zeroPad.js"; | ||
| import { parseIdentifier } from "./parseIdentifier.js"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.createIdentifier = void 0; | ||
| /** | ||
| * Used to create the identifier that is an absolute unique for the record. | ||
| * It is created out of the generated ID and version of the record. | ||
| * | ||
| * | ||
| * The input ID is being parsed as you might send a full ID instead of only the generated one. | ||
| */ | ||
| var _zeroPad = require("./zeroPad"); | ||
| var _parseIdentifier = require("./parseIdentifier"); | ||
| const createIdentifier = values => { | ||
| export const createIdentifier = values => { | ||
| const { | ||
| id | ||
| } = (0, _parseIdentifier.parseIdentifier)(values.id); | ||
| return `${id}#${(0, _zeroPad.zeroPad)(values.version)}`; | ||
| } = parseIdentifier(values.id); | ||
| return `${id}#${zeroPad(values.version)}`; | ||
| }; | ||
| exports.createIdentifier = createIdentifier; | ||
| //# sourceMappingURL=createIdentifier.js.map |
+2
-2
@@ -1,4 +0,4 @@ | ||
| export declare type CursorInput = string | number | (string | number)[] | null; | ||
| export declare type CursorOutput = string | null; | ||
| export type CursorInput = string | number | (string | number)[] | null; | ||
| export type CursorOutput = string | null; | ||
| export declare const encodeCursor: (cursor?: CursorInput) => CursorOutput; | ||
| export declare const decodeCursor: (cursor?: CursorOutput) => CursorInput; |
+3
-17
@@ -1,13 +0,5 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.encodeCursor = exports.decodeCursor = void 0; | ||
| const encodeCursor = cursor => { | ||
| export const encodeCursor = cursor => { | ||
| if (!cursor) { | ||
| return null; | ||
| } | ||
| try { | ||
@@ -21,17 +13,11 @@ return Buffer.from(JSON.stringify(cursor)).toString("base64"); | ||
| }; | ||
| exports.encodeCursor = encodeCursor; | ||
| const decodeCursor = cursor => { | ||
| export const decodeCursor = cursor => { | ||
| if (!cursor) { | ||
| return null; | ||
| } | ||
| try { | ||
| const value = Buffer.from(cursor, "base64").toString("ascii"); | ||
| if (!value) { | ||
| return null; | ||
| } | ||
| return JSON.parse(value); | ||
@@ -45,2 +31,2 @@ } catch (ex) { | ||
| exports.decodeCursor = decodeCursor; | ||
| //# sourceMappingURL=cursor.js.map |
+5
-5
@@ -1,6 +0,6 @@ | ||
| export declare const generateAlphaNumericId: (size?: number | undefined) => string; | ||
| export declare const generateAlphaNumericLowerCaseId: (size?: number | undefined) => string; | ||
| export declare const generateAlphaId: (size?: number | undefined) => string; | ||
| export declare const generateAlphaLowerCaseId: (size?: number | undefined) => string; | ||
| export declare const generateAlphaUpperCaseId: (size?: number | undefined) => string; | ||
| export declare const generateAlphaNumericId: (size?: number) => string; | ||
| export declare const generateAlphaNumericLowerCaseId: (size?: number) => string; | ||
| export declare const generateAlphaId: (size?: number) => string; | ||
| export declare const generateAlphaLowerCaseId: (size?: number) => string; | ||
| export declare const generateAlphaUpperCaseId: (size?: number) => string; | ||
| export declare const generateId: (size?: number) => string; |
+17
-26
@@ -1,32 +0,23 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.generateId = exports.generateAlphaUpperCaseId = exports.generateAlphaNumericLowerCaseId = exports.generateAlphaNumericId = exports.generateAlphaLowerCaseId = exports.generateAlphaId = void 0; | ||
| var _nanoid = require("nanoid"); | ||
| var _nanoidDictionary = require("nanoid-dictionary"); | ||
| import { nanoid, customAlphabet } from "nanoid"; | ||
| /** | ||
| * Package nanoid-dictionary is missing types | ||
| */ | ||
| // @ts-ignore | ||
| // @ts-expect-error | ||
| import nanoIdDictionary from "nanoid-dictionary"; | ||
| const { | ||
| lowercase, | ||
| uppercase, | ||
| alphanumeric, | ||
| numbers | ||
| } = nanoIdDictionary; | ||
| const DEFAULT_SIZE = 21; | ||
| const generateAlphaNumericId = (0, _nanoid.customAlphabet)(_nanoidDictionary.alphanumeric, DEFAULT_SIZE); | ||
| exports.generateAlphaNumericId = generateAlphaNumericId; | ||
| const generateAlphaNumericLowerCaseId = (0, _nanoid.customAlphabet)(`${_nanoidDictionary.lowercase}${_nanoidDictionary.numbers}`, DEFAULT_SIZE); | ||
| exports.generateAlphaNumericLowerCaseId = generateAlphaNumericLowerCaseId; | ||
| const generateAlphaId = (0, _nanoid.customAlphabet)(`${_nanoidDictionary.lowercase}${_nanoidDictionary.uppercase}`, DEFAULT_SIZE); | ||
| exports.generateAlphaId = generateAlphaId; | ||
| const generateAlphaLowerCaseId = (0, _nanoid.customAlphabet)(_nanoidDictionary.lowercase, DEFAULT_SIZE); | ||
| exports.generateAlphaLowerCaseId = generateAlphaLowerCaseId; | ||
| const generateAlphaUpperCaseId = (0, _nanoid.customAlphabet)(_nanoidDictionary.uppercase, DEFAULT_SIZE); | ||
| exports.generateAlphaUpperCaseId = generateAlphaUpperCaseId; | ||
| const generateId = (size = DEFAULT_SIZE) => { | ||
| return (0, _nanoid.nanoid)(size); | ||
| export const generateAlphaNumericId = customAlphabet(alphanumeric, DEFAULT_SIZE); | ||
| export const generateAlphaNumericLowerCaseId = customAlphabet(`${lowercase}${numbers}`, DEFAULT_SIZE); | ||
| export const generateAlphaId = customAlphabet(`${lowercase}${uppercase}`, DEFAULT_SIZE); | ||
| export const generateAlphaLowerCaseId = customAlphabet(lowercase, DEFAULT_SIZE); | ||
| export const generateAlphaUpperCaseId = customAlphabet(uppercase, DEFAULT_SIZE); | ||
| export const generateId = (size = DEFAULT_SIZE) => { | ||
| return nanoid(size); | ||
| }; | ||
| exports.generateId = generateId; | ||
| //# sourceMappingURL=generateId.js.map |
+5
-4
| export declare const WEBINY_VERSION_HEADER = "x-webiny-version"; | ||
| export interface Headers { | ||
| [WEBINY_VERSION_HEADER]: string; | ||
| } | ||
| export declare const getWebinyVersionHeaders: () => Headers; | ||
| export declare const getWebinyVersionHeaders: () => { | ||
| "x-webiny-version"?: undefined; | ||
| } | { | ||
| "x-webiny-version": string; | ||
| }; |
+4
-14
@@ -1,11 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.getWebinyVersionHeaders = exports.WEBINY_VERSION_HEADER = void 0; | ||
| const WEBINY_VERSION_HEADER = "x-webiny-version"; | ||
| exports.WEBINY_VERSION_HEADER = WEBINY_VERSION_HEADER; | ||
| const getWebinyVersionHeaders = () => { | ||
| export const WEBINY_VERSION_HEADER = "x-webiny-version"; | ||
| export const getWebinyVersionHeaders = () => { | ||
| const enable = process.env.WEBINY_ENABLE_VERSION_HEADER; | ||
@@ -16,12 +8,10 @@ const version = process.env.WEBINY_VERSION; | ||
| */ | ||
| if (enable !== "true" || !version) { | ||
| return {}; | ||
| } | ||
| return { | ||
| [WEBINY_VERSION_HEADER]: version | ||
| "x-webiny-version": version | ||
| }; | ||
| }; | ||
| exports.getWebinyVersionHeaders = getWebinyVersionHeaders; | ||
| //# sourceMappingURL=headers.js.map |
+19
-7
@@ -1,9 +0,21 @@ | ||
| export * from "./parseIdentifier"; | ||
| export * from "./zeroPad"; | ||
| export * from "./createIdentifier"; | ||
| export * from "./cursor"; | ||
| export * from "./headers"; | ||
| export * from "./generateId"; | ||
| import { composeAsync, AsyncProcessor, NextAsyncProcessor } from "./compose"; | ||
| export * from "./parseIdentifier.js"; | ||
| export * from "./zeroPad.js"; | ||
| export * from "./exception.js"; | ||
| export * from "./createIdentifier.js"; | ||
| export * from "./cursor.js"; | ||
| export * from "./headers.js"; | ||
| export * from "./generateId.js"; | ||
| export * from "./mdbid.js"; | ||
| export * from "./createZodError.js"; | ||
| export * from "./executeWithRetry.js"; | ||
| export * from "./removeUndefinedValues.js"; | ||
| export * from "./removeNullValues.js"; | ||
| export * from "./utcTimezones.js"; | ||
| export * from "./cacheKey.js"; | ||
| export * from "./getObjectProperties.js"; | ||
| export * from "./middleware.js"; | ||
| export type { GenericRecord } from "./GenericRecord.js"; | ||
| import type { AsyncProcessor, NextAsyncProcessor } from "./compose.js"; | ||
| import { composeAsync } from "./compose.js"; | ||
| export { composeAsync }; | ||
| export type { AsyncProcessor, NextAsyncProcessor }; |
+19
-99
@@ -1,100 +0,20 @@ | ||
| "use strict"; | ||
| export * from "./parseIdentifier.js"; | ||
| export * from "./zeroPad.js"; | ||
| export * from "./exception.js"; | ||
| export * from "./createIdentifier.js"; | ||
| export * from "./cursor.js"; | ||
| export * from "./headers.js"; | ||
| export * from "./generateId.js"; | ||
| export * from "./mdbid.js"; | ||
| export * from "./createZodError.js"; | ||
| export * from "./executeWithRetry.js"; | ||
| export * from "./removeUndefinedValues.js"; | ||
| export * from "./removeNullValues.js"; | ||
| export * from "./utcTimezones.js"; | ||
| export * from "./cacheKey.js"; | ||
| export * from "./getObjectProperties.js"; | ||
| export * from "./middleware.js"; | ||
| import { composeAsync } from "./compose.js"; | ||
| export { composeAsync }; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| var _exportNames = { | ||
| composeAsync: true | ||
| }; | ||
| Object.defineProperty(exports, "composeAsync", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _compose.composeAsync; | ||
| } | ||
| }); | ||
| var _parseIdentifier = require("./parseIdentifier"); | ||
| Object.keys(_parseIdentifier).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
| if (key in exports && exports[key] === _parseIdentifier[key]) return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _parseIdentifier[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _zeroPad = require("./zeroPad"); | ||
| Object.keys(_zeroPad).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
| if (key in exports && exports[key] === _zeroPad[key]) return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _zeroPad[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _createIdentifier = require("./createIdentifier"); | ||
| Object.keys(_createIdentifier).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
| if (key in exports && exports[key] === _createIdentifier[key]) return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _createIdentifier[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _cursor = require("./cursor"); | ||
| Object.keys(_cursor).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
| if (key in exports && exports[key] === _cursor[key]) return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _cursor[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _headers = require("./headers"); | ||
| Object.keys(_headers).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
| if (key in exports && exports[key] === _headers[key]) return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _headers[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _generateId = require("./generateId"); | ||
| Object.keys(_generateId).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
| if (key in exports && exports[key] === _generateId[key]) return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _generateId[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _compose = require("./compose"); | ||
| //# sourceMappingURL=index.js.map |
+16
-19
| { | ||
| "name": "@webiny/utils", | ||
| "version": "0.0.0-unstable.aad28a72ae", | ||
| "version": "0.0.0-unstable.ac6ebf63c6", | ||
| "type": "module", | ||
| "main": "index.js", | ||
@@ -18,22 +19,18 @@ "types": "index.d.ts", | ||
| "dependencies": { | ||
| "@webiny/error": "0.0.0-unstable.aad28a72ae", | ||
| "nanoid": "3.3.4", | ||
| "nanoid-dictionary": "4.3.0" | ||
| "@noble/hashes": "2.0.1", | ||
| "@webiny/error": "0.0.0-unstable.ac6ebf63c6", | ||
| "@webiny/plugins": "0.0.0-unstable.ac6ebf63c6", | ||
| "bson-objectid": "2.0.4", | ||
| "jsonpack": "1.1.5", | ||
| "nanoid": "3.3.11", | ||
| "nanoid-dictionary": "4.3.0", | ||
| "p-retry": "7.1.1", | ||
| "zod": "3.25.76" | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/cli": "^7.19.3", | ||
| "@babel/core": "^7.19.3", | ||
| "@babel/preset-env": "^7.19.4", | ||
| "@babel/preset-typescript": "^7.18.6", | ||
| "@babel/runtime": "^7.19.0", | ||
| "@webiny/cli": "^0.0.0-unstable.aad28a72ae", | ||
| "@webiny/project-utils": "^0.0.0-unstable.aad28a72ae", | ||
| "rimraf": "^3.0.2", | ||
| "ttypescript": "^1.5.12", | ||
| "typescript": "4.7.4" | ||
| "@webiny/build-tools": "0.0.0-unstable.ac6ebf63c6", | ||
| "rimraf": "6.1.3", | ||
| "typescript": "5.9.3", | ||
| "vitest": "3.2.4" | ||
| }, | ||
| "scripts": { | ||
| "build": "yarn webiny run build", | ||
| "watch": "yarn webiny run watch" | ||
| }, | ||
| "adio": { | ||
@@ -46,3 +43,3 @@ "ignore": { | ||
| }, | ||
| "gitHead": "aad28a72ae72f19b80a3196d2b4439399acc67ad" | ||
| "gitHead": "ac6ebf63c6de308703d41f2c1b375e03cd96b813" | ||
| } |
@@ -5,2 +5,2 @@ export interface ParseIdentifierResult { | ||
| } | ||
| export declare const parseIdentifier: (value?: string) => ParseIdentifierResult; | ||
| export declare const parseIdentifier: (value: string | undefined) => ParseIdentifierResult; |
+6
-21
@@ -1,12 +0,1 @@ | ||
| "use strict"; | ||
| var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.parseIdentifier = void 0; | ||
| var _error = _interopRequireDefault(require("@webiny/error")); | ||
| /** | ||
@@ -17,19 +6,16 @@ * When you want to extract the generated ID and version out of the identifier string. | ||
| */ | ||
| const parseIdentifier = value => { | ||
| import WebinyError from "@webiny/error"; | ||
| export const parseIdentifier = value => { | ||
| if (!value) { | ||
| throw new _error.default("Missing value to be parsed for the identifier.", "MALFORMED_VALUE"); | ||
| throw new WebinyError("Missing value to be parsed for the identifier.", "MALFORMED_VALUE"); | ||
| } | ||
| const [id, initialVersion] = value.split("#"); | ||
| if (!id) { | ||
| throw new _error.default("Missing ID in given value.", "MALFORMED_VALUE", { | ||
| throw new WebinyError("Missing ID in given value.", "MALFORMED_VALUE", { | ||
| value | ||
| }); | ||
| } | ||
| const version = initialVersion ? Number(initialVersion) : null; | ||
| if (version !== null && version <= 0) { | ||
| throw new _error.default("Version parsed from ID is less or equal to zero.", "MALFORMED_VALUE", { | ||
| throw new WebinyError("Version parsed from ID is less or equal to zero.", "MALFORMED_VALUE", { | ||
| id, | ||
@@ -40,3 +26,2 @@ version, | ||
| } | ||
| return { | ||
@@ -48,2 +33,2 @@ id, | ||
| exports.parseIdentifier = parseIdentifier; | ||
| //# sourceMappingURL=parseIdentifier.js.map |
+6
-20
| # @webiny/utils | ||
| [](https://www.npmjs.com/package/@webiny/utils) | ||
| [](https://www.npmjs.com/package/@webiny/utils) | ||
| [](https://github.com/prettier/prettier) | ||
| [](http://makeapullrequest.com) | ||
| > [!NOTE] | ||
| > This package is part of the [Webiny](https://www.webiny.com) monorepo. | ||
| > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package. | ||
| ## About | ||
| 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs) | ||
| Small package containing the methods that are used throughout our other packages. | ||
| * for example, zeroPad adds zeros to the start of the version number. | ||
| --- | ||
| ## Install | ||
| ``` | ||
| yarn add @webiny/utils | ||
| ``` | ||
| ## Testing | ||
| ### Command | ||
| ```` | ||
| yarn test packages/utils | ||
| ```` | ||
| _This README file is automatically generated during the publish process._ |
+2
-9
@@ -1,8 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.zeroPad = void 0; | ||
| /** | ||
@@ -12,6 +5,6 @@ * Used when we need to create an ID of some data record. | ||
| */ | ||
| const zeroPad = (version, amount = 4) => { | ||
| export const zeroPad = (version, amount = 4) => { | ||
| return `${version}`.padStart(amount, "0"); | ||
| }; | ||
| exports.zeroPad = zeroPad; | ||
| //# sourceMappingURL=zeroPad.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
74013
152.23%4
-60%81
170%835
133.89%Yes
NaN9
200%11
-56%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
Updated