You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP β†’
Socket
Book a DemoSign in
Socket

@webiny/utils

Package Overview
Dependencies
Maintainers
1
Versions
504
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webiny/utils - npm Package Compare versions

Comparing version
0.0.0-unstable.ecd8734205
to
0.0.0-unstable.f6dc066313
+2
cacheKey.d.ts
export type ICacheKeyKeys = Record<string, any> | string | number;
export declare const createCacheKey: (input: ICacheKeyKeys) => string;
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 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;
/**
* 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;
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;
}[];
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":[]}
+5
-10

@@ -1,9 +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 => {

@@ -25,3 +18,3 @@ if (!functions.length) {

}
function composeSync(functions = []) {
export function composeSync(functions = []) {
return input => {

@@ -44,2 +37,4 @@ if (!functions.length) {

};
}
}
//# sourceMappingURL=compose.js.map

@@ -1,1 +0,1 @@

{"version":3,"names":["composeAsync","functions","input","length","Promise","resolve","index","next","fn","composeSync"],"sources":["compose.ts"],"sourcesContent":["export interface NextAsyncProcessor<TInput, TOutput> {\n (input: TInput): Promise<TOutput>;\n}\n\nexport interface AsyncProcessor<TInput, TOutput = TInput> {\n (next: NextAsyncProcessor<TInput, TOutput>): NextAsyncProcessor<TInput, TOutput>;\n}\n\nexport interface NextSyncProcessor<TInput, TOutput = TInput> {\n (input: TInput): TOutput;\n}\n\nexport interface SyncProcessor<TInput, TOutput = TInput> {\n (next: NextSyncProcessor<TInput, TOutput>): NextSyncProcessor<TInput, TOutput>;\n}\n\nexport function composeAsync<TInput = unknown, TOutput = TInput>(\n functions: Array<AsyncProcessor<TInput, TOutput>> = []\n): NextAsyncProcessor<TInput, TOutput> {\n return (input: TInput): Promise<TOutput> => {\n if (!functions.length) {\n return Promise.resolve(input as unknown as TOutput);\n }\n\n let index = -1;\n\n const next: NextAsyncProcessor<TInput, TOutput> = async input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n\nexport function composeSync<TInput = unknown, TOutput = TInput>(\n functions: Array<SyncProcessor<TInput, TOutput>> = []\n): NextSyncProcessor<TInput, TOutput> {\n return (input: TInput): TOutput => {\n if (!functions.length) {\n return input as unknown as TOutput;\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n let index = -1;\n\n const next: NextSyncProcessor<TInput, TOutput> = input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n"],"mappings":";;;;;;;AAgBO,SAASA,YAAY,CACxBC,SAAiD,GAAG,EAAE,EACnB;EACnC,OAAQC,KAAa,IAAuB;IACxC,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOC,OAAO,CAACC,OAAO,CAACH,KAAK,CAAuB;IACvD;IAEA,IAAII,KAAK,GAAG,CAAC,CAAC;IAEd,MAAMC,IAAyC,GAAG,MAAML,KAAK,IAAI;MAC7DI,KAAK,EAAE;MAEP,MAAME,EAAE,GAAGP,SAAS,CAACK,KAAK,CAAC;MAC3B,IAAI,CAACE,EAAE,EAAE;QACL,OAAON,KAAK;MAChB;MAEA,OAAOM,EAAE,CAACD,IAAI,CAAC,CAACL,KAAK,CAAC;IAC1B,CAAC;IAED,OAAOK,IAAI,CAACL,KAAK,CAAC;EACtB,CAAC;AACL;AAEO,SAASO,WAAW,CACvBR,SAAgD,GAAG,EAAE,EACnB;EAClC,OAAQC,KAAa,IAAc;IAC/B,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOD,KAAK;IAChB;;IAEA;IACA,IAAII,KAAK,GAAG,CAAC,CAAC;IAEd,MAAMC,IAAwC,GAAGL,KAAK,IAAI;MACtDI,KAAK,EAAE;MAEP,MAAME,EAAE,GAAGP,SAAS,CAACK,KAAK,CAAC;MAC3B,IAAI,CAACE,EAAE,EAAE;QACL,OAAON,KAAK;MAChB;MAEA,OAAOM,EAAE,CAACD,IAAI,CAAC,CAACL,KAAK,CAAC;IAC1B,CAAC;IAED,OAAOK,IAAI,CAACL,KAAK,CAAC;EACtB,CAAC;AACL"}
{"version":3,"names":["composeAsync","functions","input","length","Promise","resolve","index","next","fn","composeSync"],"sources":["compose.ts"],"sourcesContent":["export interface NextAsyncProcessor<TInput, TOutput> {\n (input: TInput): Promise<TOutput>;\n}\n\nexport interface AsyncProcessor<TInput, TOutput = TInput> {\n (next: NextAsyncProcessor<TInput, TOutput>): NextAsyncProcessor<TInput, TOutput>;\n}\n\nexport interface NextSyncProcessor<TInput, TOutput = TInput> {\n (input: TInput): TOutput;\n}\n\nexport interface SyncProcessor<TInput, TOutput = TInput> {\n (next: NextSyncProcessor<TInput, TOutput>): NextSyncProcessor<TInput, TOutput>;\n}\n\nexport function composeAsync<TInput = unknown, TOutput = TInput>(\n functions: Array<AsyncProcessor<TInput, TOutput>> = []\n): NextAsyncProcessor<TInput, TOutput> {\n return (input: TInput): Promise<TOutput> => {\n if (!functions.length) {\n return Promise.resolve(input as unknown as TOutput);\n }\n\n let index = -1;\n\n const next: NextAsyncProcessor<TInput, TOutput> = async input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n\nexport function composeSync<TInput = unknown, TOutput = TInput>(\n functions: Array<SyncProcessor<TInput, TOutput>> = []\n): NextSyncProcessor<TInput, TOutput> {\n return (input: TInput): TOutput => {\n if (!functions.length) {\n return input as unknown as TOutput;\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n let index = -1;\n\n const next: NextSyncProcessor<TInput, TOutput> = input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n"],"mappings":"AAgBA,OAAO,SAASA,YAAYA,CACxBC,SAAiD,GAAG,EAAE,EACnB;EACnC,OAAQC,KAAa,IAAuB;IACxC,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOC,OAAO,CAACC,OAAO,CAACH,KAA2B,CAAC;IACvD;IAEA,IAAII,KAAK,GAAG,CAAC,CAAC;IAEd,MAAMC,IAAyC,GAAG,MAAML,KAAK,IAAI;MAC7DI,KAAK,EAAE;MAEP,MAAME,EAAE,GAAGP,SAAS,CAACK,KAAK,CAAC;MAC3B,IAAI,CAACE,EAAE,EAAE;QACL,OAAON,KAAK;MAChB;MAEA,OAAOM,EAAE,CAACD,IAAI,CAAC,CAACL,KAAK,CAAC;IAC1B,CAAC;IAED,OAAOK,IAAI,CAACL,KAAK,CAAC;EACtB,CAAC;AACL;AAEA,OAAO,SAASO,WAAWA,CACvBR,SAAgD,GAAG,EAAE,EACnB;EAClC,OAAQC,KAAa,IAAc;IAC/B,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOD,KAAK;IAChB;;IAEA;IACA,IAAII,KAAK,GAAG,CAAC,CAAC;IAEd,MAAMC,IAAwC,GAAGL,KAAK,IAAI;MACtDI,KAAK,EAAE;MAEP,MAAME,EAAE,GAAGP,SAAS,CAACK,KAAK,CAAC;MAC3B,IAAI,CAACE,EAAE,EAAE;QACL,OAAON,KAAK;MAChB;MAEA,OAAOM,EAAE,CAACD,IAAI,CAAC,CAACL,KAAK,CAAC;IAC1B,CAAC;IAED,OAAOK,IAAI,CAACL,KAAK,CAAC;EACtB,CAAC;AACL","ignoreList":[]}

@@ -1,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>;

@@ -1,12 +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) {

@@ -20,6 +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) {

@@ -33,2 +25,3 @@ resolve(result);

};
exports.decompress = decompress;
//# sourceMappingURL=gzip.js.map

@@ -1,1 +0,1 @@

{"version":3,"names":["compress","input","options","Promise","resolve","reject","zlib","gzip","error","result","decompress","gunzip"],"sources":["gzip.ts"],"sourcesContent":["import zlib from \"zlib\";\n\nexport const compress = (input: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer> => {\n return new Promise(function (resolve, reject) {\n zlib.gzip(input, options || {}, function (error, result) {\n if (!error) {\n resolve(result);\n } else {\n reject(error);\n }\n });\n });\n};\nexport const decompress = (input: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer> => {\n return new Promise(function (resolve, reject) {\n zlib.gunzip(input, options || {}, function (error, result) {\n if (!error) {\n resolve(result);\n } else {\n reject(error);\n }\n });\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEO,MAAMA,QAAQ,GAAG,CAACC,KAAqB,EAAEC,OAA0B,KAAsB;EAC5F,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;IAC1CC,aAAI,CAACC,IAAI,CAACN,KAAK,EAAEC,OAAO,IAAI,CAAC,CAAC,EAAE,UAAUM,KAAK,EAAEC,MAAM,EAAE;MACrD,IAAI,CAACD,KAAK,EAAE;QACRJ,OAAO,CAACK,MAAM,CAAC;MACnB,CAAC,MAAM;QACHJ,MAAM,CAACG,KAAK,CAAC;MACjB;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC;AACK,MAAME,UAAU,GAAG,CAACT,KAAqB,EAAEC,OAA0B,KAAsB;EAC9F,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;IAC1CC,aAAI,CAACK,MAAM,CAACV,KAAK,EAAEC,OAAO,IAAI,CAAC,CAAC,EAAE,UAAUM,KAAK,EAAEC,MAAM,EAAE;MACvD,IAAI,CAACD,KAAK,EAAE;QACRJ,OAAO,CAACK,MAAM,CAAC;MACnB,CAAC,MAAM;QACHJ,MAAM,CAACG,KAAK,CAAC;MACjB;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
{"version":3,"names":["zlib","compress","input","options","Promise","resolve","reject","gzip","error","result","decompress","gunzip"],"sources":["gzip.ts"],"sourcesContent":["import zlib from \"zlib\";\n\nexport const compress = (input: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer> => {\n return new Promise(function (resolve, reject) {\n zlib.gzip(input, options || {}, function (error, result) {\n if (!error) {\n resolve(result);\n } else {\n reject(error);\n }\n });\n });\n};\nexport const decompress = (input: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer> => {\n return new Promise(function (resolve, reject) {\n zlib.gunzip(input, options || {}, function (error, result) {\n if (!error) {\n resolve(result);\n } else {\n reject(error);\n }\n });\n });\n};\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAEvB,OAAO,MAAMC,QAAQ,GAAGA,CAACC,KAAqB,EAAEC,OAA0B,KAAsB;EAC5F,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;IAC1CN,IAAI,CAACO,IAAI,CAACL,KAAK,EAAEC,OAAO,IAAI,CAAC,CAAC,EAAE,UAAUK,KAAK,EAAEC,MAAM,EAAE;MACrD,IAAI,CAACD,KAAK,EAAE;QACRH,OAAO,CAACI,MAAM,CAAC;MACnB,CAAC,MAAM;QACHH,MAAM,CAACE,KAAK,CAAC;MACjB;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AACD,OAAO,MAAME,UAAU,GAAGA,CAACR,KAAqB,EAAEC,OAA0B,KAAsB;EAC9F,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;IAC1CN,IAAI,CAACW,MAAM,CAACT,KAAK,EAAEC,OAAO,IAAI,CAAC,CAAC,EAAE,UAAUK,KAAK,EAAEC,MAAM,EAAE;MACvD,IAAI,CAACD,KAAK,EAAE;QACRH,OAAO,CAACI,MAAM,CAAC;MACnB,CAAC,MAAM;QACHH,MAAM,CAACE,KAAK,CAAC;MACjB;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC","ignoreList":[]}

@@ -1,15 +0,19 @@

"use strict";
import { zeroPad } from "./zeroPad.js";
import { parseIdentifier } from "./parseIdentifier.js";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createIdentifier = void 0;
var _zeroPad = require("./zeroPad");
var _parseIdentifier = require("./parseIdentifier");
const createIdentifier = values => {
/**
* 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.
*/
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

@@ -1,1 +0,1 @@

{"version":3,"names":["createIdentifier","values","id","parseIdentifier","zeroPad","version"],"sources":["createIdentifier.ts"],"sourcesContent":["import { zeroPad } from \"~/zeroPad\";\nimport { parseIdentifier } from \"~/parseIdentifier\";\n\n/**\n * Used to create the identifier that is an absolute unique for the record.\n * It is created out of the generated ID and version of the record.\n *\n *\n * The input ID is being parsed as you might send a full ID instead of only the generated one.\n */\nexport interface CreateIdentifierParams {\n id: string;\n version: number;\n}\n\nexport const createIdentifier = (values: CreateIdentifierParams): string => {\n const { id } = parseIdentifier(values.id);\n\n return `${id}#${zeroPad(values.version)}`;\n};\n"],"mappings":";;;;;;AAAA;AACA;AAcO,MAAMA,gBAAgB,GAAIC,MAA8B,IAAa;EACxE,MAAM;IAAEC;EAAG,CAAC,GAAG,IAAAC,gCAAe,EAACF,MAAM,CAACC,EAAE,CAAC;EAEzC,OAAQ,GAAEA,EAAG,IAAG,IAAAE,gBAAO,EAACH,MAAM,CAACI,OAAO,CAAE,EAAC;AAC7C,CAAC;AAAC"}
{"version":3,"names":["zeroPad","parseIdentifier","createIdentifier","values","id","version"],"sources":["createIdentifier.ts"],"sourcesContent":["import { zeroPad } from \"./zeroPad.js\";\nimport { parseIdentifier } from \"./parseIdentifier.js\";\n\n/**\n * Used to create the identifier that is an absolute unique for the record.\n * It is created out of the generated ID and version of the record.\n *\n *\n * The input ID is being parsed as you might send a full ID instead of only the generated one.\n */\nexport interface CreateIdentifierParams {\n id: string;\n version: number;\n}\n\nexport const createIdentifier = (values: CreateIdentifierParams): string => {\n const { id } = parseIdentifier(values.id);\n\n return `${id}#${zeroPad(values.version)}`;\n};\n"],"mappings":"AAAA,SAASA,OAAO;AAChB,SAASC,eAAe;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAa;EACxE,MAAM;IAAEC;EAAG,CAAC,GAAGH,eAAe,CAACE,MAAM,CAACC,EAAE,CAAC;EAEzC,OAAO,GAAGA,EAAE,IAAIJ,OAAO,CAACG,MAAM,CAACE,OAAO,CAAC,EAAE;AAC7C,CAAC","ignoreList":[]}
import WebinyError from "@webiny/error";
import { ZodError } from "zod/lib/ZodError";
import type { ZodError } from "zod";
interface OutputError {

@@ -8,3 +8,3 @@ code: string;

}
interface OutputErrors {
export interface OutputErrors {
[key: string]: OutputError;

@@ -11,0 +11,0 @@ }

@@ -1,9 +0,3 @@

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createZodError = void 0;
var _error = _interopRequireDefault(require("@webiny/error"));
import WebinyError from "@webiny/error";
import { generateAlphaNumericId } from "./generateId.js";
const createValidationErrorData = error => {

@@ -13,6 +7,7 @@ return {

const name = issue.path.join(".");
if (!name) {
if (!name && !issue.code) {
return collection;
}
collection[name] = {
const key = name || issue.path.join(".") || issue.message || issue.code || generateAlphaNumericId();
collection[key] = {
code: issue.code,

@@ -29,4 +24,4 @@ message: issue.message,

};
const createZodError = error => {
return new _error.default({
export const createZodError = error => {
return new WebinyError({
message: `Validation failed.`,

@@ -37,2 +32,3 @@ code: "VALIDATION_FAILED_INVALID_FIELDS",

};
exports.createZodError = createZodError;
//# sourceMappingURL=createZodError.js.map

@@ -1,1 +0,1 @@

{"version":3,"names":["createValidationErrorData","error","invalidFields","issues","reduce","collection","issue","name","path","join","code","message","data","fatal","createZodError","WebinyError"],"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\ninterface 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[name] = {\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;AAaA,MAAMA,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,EAAE;QACP,OAAOF,UAAU;MACrB;MACAA,UAAU,CAACE,IAAI,CAAC,GAAG;QACfG,IAAI,EAAEJ,KAAK,CAACI,IAAI;QAChBC,OAAO,EAAEL,KAAK,CAACK,OAAO;QACtBC,IAAI,EAAE;UACFC,KAAK,EAAEP,KAAK,CAACO,KAAK;UAClBL,IAAI,EAAEF,KAAK,CAACE;QAChB;MACJ,CAAC;MAED,OAAOH,UAAU;IACrB,CAAC,EAAE,CAAC,CAAC;EACT,CAAC;AACL,CAAC;AAEM,MAAMS,cAAc,GAAIb,KAAe,IAAK;EAC/C,OAAO,IAAIc,cAAW,CAAC;IACnBJ,OAAO,EAAG,oBAAmB;IAC7BD,IAAI,EAAE,kCAAkC;IACxCE,IAAI,EAAEZ,yBAAyB,CAACC,KAAK;EACzC,CAAC,CAAC;AACN,CAAC;AAAC"}
{"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":[]}

@@ -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;

@@ -1,8 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.encodeCursor = exports.decodeCursor = void 0;
const encodeCursor = cursor => {
export const encodeCursor = cursor => {
if (!cursor) {

@@ -19,4 +13,3 @@ return null;

};
exports.encodeCursor = encodeCursor;
const decodeCursor = cursor => {
export const decodeCursor = cursor => {
if (!cursor) {

@@ -37,2 +30,3 @@ return null;

};
exports.decodeCursor = decodeCursor;
//# sourceMappingURL=cursor.js.map

@@ -1,1 +0,1 @@

{"version":3,"names":["encodeCursor","cursor","Buffer","from","JSON","stringify","toString","ex","console","log","message","decodeCursor","value","parse"],"sources":["cursor.ts"],"sourcesContent":["export type CursorInput = string | number | (string | number)[] | null;\nexport type CursorOutput = string | null;\n\nexport const encodeCursor = (cursor?: CursorInput): CursorOutput => {\n if (!cursor) {\n return null;\n }\n\n try {\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n } catch (ex) {\n console.log(\"Utils encode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n\nexport const decodeCursor = (cursor?: CursorOutput): CursorInput => {\n if (!cursor) {\n return null;\n }\n\n try {\n const value = Buffer.from(cursor, \"base64\").toString(\"ascii\");\n if (!value) {\n return null;\n }\n return JSON.parse(value);\n } catch (ex) {\n console.log(\"Utils decode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n"],"mappings":";;;;;;AAGO,MAAMA,YAAY,GAAIC,MAAoB,IAAmB;EAChE,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,IAAI;IACA,OAAOC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACJ,MAAM,CAAC,CAAC,CAACK,QAAQ,CAAC,QAAQ,CAAC;EACjE,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC;IACnCD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;IACvB,OAAO,IAAI;EACf;AACJ,CAAC;AAAC;AAEK,MAAMC,YAAY,GAAIV,MAAqB,IAAkB;EAChE,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,IAAI;IACA,MAAMW,KAAK,GAAGV,MAAM,CAACC,IAAI,CAACF,MAAM,EAAE,QAAQ,CAAC,CAACK,QAAQ,CAAC,OAAO,CAAC;IAC7D,IAAI,CAACM,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,OAAOR,IAAI,CAACS,KAAK,CAACD,KAAK,CAAC;EAC5B,CAAC,CAAC,OAAOL,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC;IACnCD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;IACvB,OAAO,IAAI;EACf;AACJ,CAAC;AAAC"}
{"version":3,"names":["encodeCursor","cursor","Buffer","from","JSON","stringify","toString","ex","console","log","message","decodeCursor","value","parse"],"sources":["cursor.ts"],"sourcesContent":["export type CursorInput = string | number | (string | number)[] | null;\nexport type CursorOutput = string | null;\n\nexport const encodeCursor = (cursor?: CursorInput): CursorOutput => {\n if (!cursor) {\n return null;\n }\n\n try {\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n } catch (ex) {\n console.log(\"Utils encode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n\nexport const decodeCursor = (cursor?: CursorOutput): CursorInput => {\n if (!cursor) {\n return null;\n }\n\n try {\n const value = Buffer.from(cursor, \"base64\").toString(\"ascii\");\n if (!value) {\n return null;\n }\n return JSON.parse(value);\n } catch (ex) {\n console.log(\"Utils decode cursor.\");\n console.log(ex.message);\n return null;\n }\n};\n"],"mappings":"AAGA,OAAO,MAAMA,YAAY,GAAIC,MAAoB,IAAmB;EAChE,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,IAAI;IACA,OAAOC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACJ,MAAM,CAAC,CAAC,CAACK,QAAQ,CAAC,QAAQ,CAAC;EACjE,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC;IACnCD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;IACvB,OAAO,IAAI;EACf;AACJ,CAAC;AAED,OAAO,MAAMC,YAAY,GAAIV,MAAqB,IAAkB;EAChE,IAAI,CAACA,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,IAAI;IACA,MAAMW,KAAK,GAAGV,MAAM,CAACC,IAAI,CAACF,MAAM,EAAE,QAAQ,CAAC,CAACK,QAAQ,CAAC,OAAO,CAAC;IAC7D,IAAI,CAACM,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,OAAOR,IAAI,CAACS,KAAK,CAACD,KAAK,CAAC;EAC5B,CAAC,CAAC,OAAOL,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC;IACnCD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;IACvB,OAAO,IAAI;EACf;AACJ,CAAC","ignoreList":[]}

@@ -1,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;

@@ -1,28 +0,13 @@

"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");
/**
* Package nanoid-dictionary is missing types
*/
// @ts-ignore
import { customAlphabet, nanoid } from "nanoid";
import { alphanumeric, lowercase, numbers, uppercase } from "nanoid-dictionary";
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

@@ -1,1 +0,1 @@

{"version":3,"names":["DEFAULT_SIZE","generateAlphaNumericId","customAlphabet","alphanumeric","generateAlphaNumericLowerCaseId","lowercase","numbers","generateAlphaId","uppercase","generateAlphaLowerCaseId","generateAlphaUpperCaseId","generateId","size","nanoid"],"sources":["generateId.ts"],"sourcesContent":["import { nanoid, customAlphabet } from \"nanoid\";\n/**\n * Package nanoid-dictionary is missing types\n */\n// @ts-ignore\nimport { lowercase, uppercase, alphanumeric, numbers } from \"nanoid-dictionary\";\n\nconst DEFAULT_SIZE = 21;\n\nexport const generateAlphaNumericId = customAlphabet(alphanumeric, DEFAULT_SIZE);\n\nexport const generateAlphaNumericLowerCaseId = customAlphabet(\n `${lowercase}${numbers}`,\n DEFAULT_SIZE\n);\n\nexport const generateAlphaId = customAlphabet(`${lowercase}${uppercase}`, DEFAULT_SIZE);\n\nexport const generateAlphaLowerCaseId = customAlphabet(lowercase, DEFAULT_SIZE);\n\nexport const generateAlphaUpperCaseId = customAlphabet(uppercase, DEFAULT_SIZE);\n\nexport const generateId = (size = DEFAULT_SIZE): string => {\n return nanoid(size);\n};\n"],"mappings":";;;;;;AAAA;AAKA;AAJA;AACA;AACA;AACA;;AAGA,MAAMA,YAAY,GAAG,EAAE;AAEhB,MAAMC,sBAAsB,GAAG,IAAAC,sBAAc,EAACC,8BAAY,EAAEH,YAAY,CAAC;AAAC;AAE1E,MAAMI,+BAA+B,GAAG,IAAAF,sBAAc,EACxD,GAAEG,2BAAU,GAAEC,yBAAQ,EAAC,EACxBN,YAAY,CACf;AAAC;AAEK,MAAMO,eAAe,GAAG,IAAAL,sBAAc,EAAE,GAAEG,2BAAU,GAAEG,2BAAU,EAAC,EAAER,YAAY,CAAC;AAAC;AAEjF,MAAMS,wBAAwB,GAAG,IAAAP,sBAAc,EAACG,2BAAS,EAAEL,YAAY,CAAC;AAAC;AAEzE,MAAMU,wBAAwB,GAAG,IAAAR,sBAAc,EAACM,2BAAS,EAAER,YAAY,CAAC;AAAC;AAEzE,MAAMW,UAAU,GAAG,CAACC,IAAI,GAAGZ,YAAY,KAAa;EACvD,OAAO,IAAAa,cAAM,EAACD,IAAI,CAAC;AACvB,CAAC;AAAC"}
{"version":3,"names":["customAlphabet","nanoid","alphanumeric","lowercase","numbers","uppercase","DEFAULT_SIZE","generateAlphaNumericId","generateAlphaNumericLowerCaseId","generateAlphaId","generateAlphaLowerCaseId","generateAlphaUpperCaseId","generateId","size"],"sources":["generateId.ts"],"sourcesContent":["import { customAlphabet, nanoid } from \"nanoid\";\nimport { alphanumeric, lowercase, numbers, uppercase } from \"nanoid-dictionary\";\n\nconst DEFAULT_SIZE = 21;\n\nexport const generateAlphaNumericId = customAlphabet(alphanumeric, DEFAULT_SIZE);\n\nexport const generateAlphaNumericLowerCaseId = customAlphabet(\n `${lowercase}${numbers}`,\n DEFAULT_SIZE\n);\n\nexport const generateAlphaId = customAlphabet(`${lowercase}${uppercase}`, DEFAULT_SIZE);\n\nexport const generateAlphaLowerCaseId = customAlphabet(lowercase, DEFAULT_SIZE);\n\nexport const generateAlphaUpperCaseId = customAlphabet(uppercase, DEFAULT_SIZE);\n\nexport const generateId = (size = DEFAULT_SIZE): string => {\n return nanoid(size);\n};\n"],"mappings":"AAAA,SAASA,cAAc,EAAEC,MAAM,QAAQ,QAAQ;AAC/C,SAASC,YAAY,EAAEC,SAAS,EAAEC,OAAO,EAAEC,SAAS,QAAQ,mBAAmB;AAE/E,MAAMC,YAAY,GAAG,EAAE;AAEvB,OAAO,MAAMC,sBAAsB,GAAGP,cAAc,CAACE,YAAY,EAAEI,YAAY,CAAC;AAEhF,OAAO,MAAME,+BAA+B,GAAGR,cAAc,CACzD,GAAGG,SAAS,GAAGC,OAAO,EAAE,EACxBE,YACJ,CAAC;AAED,OAAO,MAAMG,eAAe,GAAGT,cAAc,CAAC,GAAGG,SAAS,GAAGE,SAAS,EAAE,EAAEC,YAAY,CAAC;AAEvF,OAAO,MAAMI,wBAAwB,GAAGV,cAAc,CAACG,SAAS,EAAEG,YAAY,CAAC;AAE/E,OAAO,MAAMK,wBAAwB,GAAGX,cAAc,CAACK,SAAS,EAAEC,YAAY,CAAC;AAE/E,OAAO,MAAMM,UAAU,GAAGA,CAACC,IAAI,GAAGP,YAAY,KAAa;EACvD,OAAOL,MAAM,CAACY,IAAI,CAAC;AACvB,CAAC","ignoreList":[]}
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;
};

@@ -1,10 +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;

@@ -19,5 +12,6 @@ const version = process.env.WEBINY_VERSION;

return {
[WEBINY_VERSION_HEADER]: version
"x-webiny-version": version
};
};
exports.getWebinyVersionHeaders = getWebinyVersionHeaders;
//# sourceMappingURL=headers.js.map

@@ -1,1 +0,1 @@

{"version":3,"names":["WEBINY_VERSION_HEADER","getWebinyVersionHeaders","enable","process","env","WEBINY_ENABLE_VERSION_HEADER","version","WEBINY_VERSION"],"sources":["headers.ts"],"sourcesContent":["export const WEBINY_VERSION_HEADER = \"x-webiny-version\";\nexport interface Headers {\n [WEBINY_VERSION_HEADER]: string;\n}\nexport const getWebinyVersionHeaders = (): Headers => {\n const enable: string | undefined = process.env.WEBINY_ENABLE_VERSION_HEADER;\n const version: string | undefined = process.env.WEBINY_VERSION;\n /**\n * Disable version headers by default.\n */\n if (enable !== \"true\" || !version) {\n return {} as Headers;\n }\n return {\n [WEBINY_VERSION_HEADER]: version\n };\n};\n"],"mappings":";;;;;;AAAO,MAAMA,qBAAqB,GAAG,kBAAkB;AAAC;AAIjD,MAAMC,uBAAuB,GAAG,MAAe;EAClD,MAAMC,MAA0B,GAAGC,OAAO,CAACC,GAAG,CAACC,4BAA4B;EAC3E,MAAMC,OAA2B,GAAGH,OAAO,CAACC,GAAG,CAACG,cAAc;EAC9D;AACJ;AACA;EACI,IAAIL,MAAM,KAAK,MAAM,IAAI,CAACI,OAAO,EAAE;IAC/B,OAAO,CAAC,CAAC;EACb;EACA,OAAO;IACH,CAACN,qBAAqB,GAAGM;EAC7B,CAAC;AACL,CAAC;AAAC"}
{"version":3,"names":["WEBINY_VERSION_HEADER","getWebinyVersionHeaders","enable","process","env","WEBINY_ENABLE_VERSION_HEADER","version","WEBINY_VERSION"],"sources":["headers.ts"],"sourcesContent":["export const WEBINY_VERSION_HEADER = \"x-webiny-version\";\n\nexport const getWebinyVersionHeaders = () => {\n const enable: string | undefined = process.env.WEBINY_ENABLE_VERSION_HEADER;\n const version: string | undefined = process.env.WEBINY_VERSION;\n /**\n * Disable version headers by default.\n */\n if (enable !== \"true\" || !version) {\n return {};\n }\n return {\n \"x-webiny-version\": version\n };\n};\n"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,GAAG,kBAAkB;AAEvD,OAAO,MAAMC,uBAAuB,GAAGA,CAAA,KAAM;EACzC,MAAMC,MAA0B,GAAGC,OAAO,CAACC,GAAG,CAACC,4BAA4B;EAC3E,MAAMC,OAA2B,GAAGH,OAAO,CAACC,GAAG,CAACG,cAAc;EAC9D;AACJ;AACA;EACI,IAAIL,MAAM,KAAK,MAAM,IAAI,CAACI,OAAO,EAAE;IAC/B,OAAO,CAAC,CAAC;EACb;EACA,OAAO;IACH,kBAAkB,EAAEA;EACxB,CAAC;AACL,CAAC","ignoreList":[]}

@@ -1,10 +0,21 @@

export * from "./parseIdentifier";
export * from "./zeroPad";
export * from "./createIdentifier";
export * from "./cursor";
export * from "./headers";
export * from "./generateId";
export * from "./createZodError";
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
-98

@@ -1,99 +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 _createZodError = require("./createZodError");
Object.keys(_createZodError).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _createZodError[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _createZodError[key];
}
});
});
var _compose = require("./compose");
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/parseIdentifier\";\nexport * from \"~/zeroPad\";\nexport * from \"~/createIdentifier\";\nexport * from \"~/cursor\";\nexport * from \"~/headers\";\nexport * from \"~/generateId\";\nexport * from \"~/createZodError\";\nimport { composeAsync, AsyncProcessor, NextAsyncProcessor } from \"~/compose\";\n\nexport { composeAsync };\nexport type { AsyncProcessor, NextAsyncProcessor };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA"}
{"version":3,"names":["composeAsync"],"sources":["index.ts"],"sourcesContent":["export * from \"~/parseIdentifier.js\";\nexport * from \"~/zeroPad.js\";\nexport * from \"~/exception.js\";\nexport * from \"~/createIdentifier.js\";\nexport * from \"~/cursor.js\";\nexport * from \"~/headers.js\";\nexport * from \"~/generateId.js\";\nexport * from \"~/mdbid.js\";\nexport * from \"~/createZodError.js\";\nexport * from \"~/executeWithRetry.js\";\nexport * from \"~/removeUndefinedValues.js\";\nexport * from \"~/removeNullValues.js\";\nexport * from \"~/utcTimezones.js\";\nexport * from \"./cacheKey.js\";\nexport * from \"./getObjectProperties.js\";\nexport * from \"./middleware.js\";\nexport type { GenericRecord } from \"./GenericRecord.js\";\n\nimport type { AsyncProcessor, NextAsyncProcessor } from \"~/compose.js\";\nimport { composeAsync } from \"~/compose.js\";\n\nexport { composeAsync };\nexport type { AsyncProcessor, NextAsyncProcessor };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,SAASA,YAAY;AAErB,SAASA,YAAY","ignoreList":[]}
{
"name": "@webiny/utils",
"version": "0.0.0-unstable.ecd8734205",
"version": "0.0.0-unstable.f6dc066313",
"type": "module",
"main": "index.js",

@@ -18,25 +19,18 @@ "types": "index.d.ts",

"dependencies": {
"@webiny/error": "0.0.0-unstable.ecd8734205",
"nanoid": "3.3.4",
"nanoid-dictionary": "4.3.0"
"@noble/hashes": "2.0.1",
"@webiny/error": "0.0.0-unstable.f6dc066313",
"@webiny/plugins": "0.0.0-unstable.f6dc066313",
"bson-objectid": "2.0.4",
"jsonpack": "1.1.5",
"nanoid": "5.1.6",
"nanoid-dictionary": "5.0.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.ecd8734205",
"@webiny/project-utils": "^0.0.0-unstable.ecd8734205",
"rimraf": "^3.0.2",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"@webiny/build-tools": "0.0.0-unstable.f6dc066313",
"rimraf": "6.1.3",
"typescript": "5.9.3",
"vitest": "4.0.18"
},
"peerDependencies": {
"zod": "^3.20.2"
},
"scripts": {
"build": "yarn webiny run build",
"watch": "yarn webiny run watch"
},
"adio": {

@@ -49,3 +43,3 @@ "ignore": {

},
"gitHead": "ecd8734205e0e21ae04076c28ff9806dad07a730"
"gitHead": "f6dc066313ddce5339d2aacec3aa84e61232689b"
}

@@ -5,2 +5,2 @@ export interface ParseIdentifierResult {

}
export declare const parseIdentifier: (value?: string) => ParseIdentifierResult;
export declare const parseIdentifier: (value: string | undefined) => ParseIdentifierResult;

@@ -1,9 +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"));
/**

@@ -14,10 +6,10 @@ * 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

@@ -28,3 +20,3 @@ });

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,2 +32,3 @@ version,

};
exports.parseIdentifier = parseIdentifier;
//# sourceMappingURL=parseIdentifier.js.map

@@ -1,1 +0,1 @@

{"version":3,"names":["parseIdentifier","value","WebinyError","id","initialVersion","split","version","Number"],"sources":["parseIdentifier.ts"],"sourcesContent":["/**\n * When you want to extract the generated ID and version out of the identifier string.\n * In case there is no version, it's not a problem, possibly only generated ID was sent.\n * It does not cause an error. Write check for that in the code using this fn.\n */\nimport WebinyError from \"@webiny/error\";\n\nexport interface ParseIdentifierResult {\n id: string;\n version: number | null;\n}\n\nexport const parseIdentifier = (value?: string): ParseIdentifierResult => {\n if (!value) {\n throw new WebinyError(\"Missing value to be parsed for the identifier.\", \"MALFORMED_VALUE\");\n }\n const [id, initialVersion] = value.split(\"#\");\n if (!id) {\n throw new WebinyError(\"Missing ID in given value.\", \"MALFORMED_VALUE\", {\n value\n });\n }\n const version = initialVersion ? Number(initialVersion) : null;\n if (version !== null && version <= 0) {\n throw new WebinyError(\n \"Version parsed from ID is less or equal to zero.\",\n \"MALFORMED_VALUE\",\n {\n id,\n version,\n value\n }\n );\n }\n return {\n id,\n version\n };\n};\n"],"mappings":";;;;;;;AAKA;AALA;AACA;AACA;AACA;AACA;;AAQO,MAAMA,eAAe,GAAIC,KAAc,IAA4B;EACtE,IAAI,CAACA,KAAK,EAAE;IACR,MAAM,IAAIC,cAAW,CAAC,gDAAgD,EAAE,iBAAiB,CAAC;EAC9F;EACA,MAAM,CAACC,EAAE,EAAEC,cAAc,CAAC,GAAGH,KAAK,CAACI,KAAK,CAAC,GAAG,CAAC;EAC7C,IAAI,CAACF,EAAE,EAAE;IACL,MAAM,IAAID,cAAW,CAAC,4BAA4B,EAAE,iBAAiB,EAAE;MACnED;IACJ,CAAC,CAAC;EACN;EACA,MAAMK,OAAO,GAAGF,cAAc,GAAGG,MAAM,CAACH,cAAc,CAAC,GAAG,IAAI;EAC9D,IAAIE,OAAO,KAAK,IAAI,IAAIA,OAAO,IAAI,CAAC,EAAE;IAClC,MAAM,IAAIJ,cAAW,CACjB,kDAAkD,EAClD,iBAAiB,EACjB;MACIC,EAAE;MACFG,OAAO;MACPL;IACJ,CAAC,CACJ;EACL;EACA,OAAO;IACHE,EAAE;IACFG;EACJ,CAAC;AACL,CAAC;AAAC"}
{"version":3,"names":["WebinyError","parseIdentifier","value","id","initialVersion","split","version","Number"],"sources":["parseIdentifier.ts"],"sourcesContent":["/**\n * When you want to extract the generated ID and version out of the identifier string.\n * In case there is no version, it's not a problem, possibly only generated ID was sent.\n * It does not cause an error. Write check for that in the code using this fn.\n */\nimport WebinyError from \"@webiny/error\";\n\nexport interface ParseIdentifierResult {\n id: string;\n version: number | null;\n}\n\nexport const parseIdentifier = (value: string | undefined): ParseIdentifierResult => {\n if (!value) {\n throw new WebinyError(\"Missing value to be parsed for the identifier.\", \"MALFORMED_VALUE\");\n }\n const [id, initialVersion] = value.split(\"#\");\n if (!id) {\n throw new WebinyError(\"Missing ID in given value.\", \"MALFORMED_VALUE\", {\n value\n });\n }\n const version = initialVersion ? Number(initialVersion) : null;\n if (version !== null && version <= 0) {\n throw new WebinyError(\n \"Version parsed from ID is less or equal to zero.\",\n \"MALFORMED_VALUE\",\n {\n id,\n version,\n value\n }\n );\n }\n return {\n id,\n version\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,eAAe;AAOvC,OAAO,MAAMC,eAAe,GAAIC,KAAyB,IAA4B;EACjF,IAAI,CAACA,KAAK,EAAE;IACR,MAAM,IAAIF,WAAW,CAAC,gDAAgD,EAAE,iBAAiB,CAAC;EAC9F;EACA,MAAM,CAACG,EAAE,EAAEC,cAAc,CAAC,GAAGF,KAAK,CAACG,KAAK,CAAC,GAAG,CAAC;EAC7C,IAAI,CAACF,EAAE,EAAE;IACL,MAAM,IAAIH,WAAW,CAAC,4BAA4B,EAAE,iBAAiB,EAAE;MACnEE;IACJ,CAAC,CAAC;EACN;EACA,MAAMI,OAAO,GAAGF,cAAc,GAAGG,MAAM,CAACH,cAAc,CAAC,GAAG,IAAI;EAC9D,IAAIE,OAAO,KAAK,IAAI,IAAIA,OAAO,IAAI,CAAC,EAAE;IAClC,MAAM,IAAIN,WAAW,CACjB,kDAAkD,EAClD,iBAAiB,EACjB;MACIG,EAAE;MACFG,OAAO;MACPJ;IACJ,CACJ,CAAC;EACL;EACA,OAAO;IACHC,EAAE;IACFG;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
# @webiny/utils
[![](https://img.shields.io/npm/dw/@webiny/utils.svg)](https://www.npmjs.com/package/@webiny/utils)
[![](https://img.shields.io/npm/v/@webiny/utils.svg)](https://www.npmjs.com/package/@webiny/utils)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](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._

@@ -1,7 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zeroPad = void 0;
/**

@@ -11,5 +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

@@ -1,1 +0,1 @@

{"version":3,"names":["zeroPad","version","amount","padStart"],"sources":["zeroPad.ts"],"sourcesContent":["/**\n * Used when we need to create an ID of some data record.\n * Or, for example, when adding the revision record to the DynamoDB table.\n */\nexport const zeroPad = (version: string | number, amount = 4): string => {\n return `${version}`.padStart(amount, \"0\");\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,OAAO,GAAG,CAACC,OAAwB,EAAEC,MAAM,GAAG,CAAC,KAAa;EACrE,OAAQ,GAAED,OAAQ,EAAC,CAACE,QAAQ,CAACD,MAAM,EAAE,GAAG,CAAC;AAC7C,CAAC;AAAC"}
{"version":3,"names":["zeroPad","version","amount","padStart"],"sources":["zeroPad.ts"],"sourcesContent":["/**\n * Used when we need to create an ID of some data record.\n * Or, for example, when adding the revision record to the DynamoDB table.\n */\nexport const zeroPad = (version: string | number, amount = 4): string => {\n return `${version}`.padStart(amount, \"0\");\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAO,MAAMA,OAAO,GAAGA,CAACC,OAAwB,EAAEC,MAAM,GAAG,CAAC,KAAa;EACrE,OAAO,GAAGD,OAAO,EAAE,CAACE,QAAQ,CAACD,MAAM,EAAE,GAAG,CAAC;AAC7C,CAAC","ignoreList":[]}