@webiny/utils 6.0.0-alpha.5 β†’ 6.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/GenericRecord.js +1 -5
  2. package/README.md +6 -20
  3. package/cacheKey.d.ts +1 -8
  4. package/cacheKey.js +5 -11
  5. package/cacheKey.js.map +1 -1
  6. package/compose.js +2 -9
  7. package/compose.js.map +1 -1
  8. package/compression/CompressionPlugin.js +2 -9
  9. package/compression/CompressionPlugin.js.map +1 -1
  10. package/compression/Compressor.d.ts +1 -1
  11. package/compression/Compressor.js +6 -13
  12. package/compression/Compressor.js.map +1 -1
  13. package/compression/gzip.d.ts +0 -3
  14. package/compression/gzip.js +5 -14
  15. package/compression/gzip.js.map +1 -1
  16. package/compression/index.d.ts +4 -4
  17. package/compression/index.js +4 -49
  18. package/compression/index.js.map +1 -1
  19. package/compression/jsonpack.js +5 -14
  20. package/compression/jsonpack.js.map +1 -1
  21. package/compression/plugins/GzipCompression.d.ts +2 -4
  22. package/compression/plugins/GzipCompression.js +7 -16
  23. package/compression/plugins/GzipCompression.js.map +1 -1
  24. package/compression/plugins/JsonpackCompression.d.ts +1 -1
  25. package/compression/plugins/JsonpackCompression.js +6 -14
  26. package/compression/plugins/JsonpackCompression.js.map +1 -1
  27. package/createIdentifier.js +5 -11
  28. package/createIdentifier.js.map +1 -1
  29. package/createZodError.d.ts +1 -1
  30. package/createZodError.js +5 -13
  31. package/createZodError.js.map +1 -1
  32. package/cursor.js +2 -10
  33. package/cursor.js.map +1 -1
  34. package/exception.js +1 -8
  35. package/exception.js.map +1 -1
  36. package/executeWithRetry.js +3 -11
  37. package/executeWithRetry.js.map +1 -1
  38. package/generateId.d.ts +5 -5
  39. package/generateId.js +9 -21
  40. package/generateId.js.map +1 -1
  41. package/getObjectProperties.js +1 -8
  42. package/getObjectProperties.js.map +1 -1
  43. package/headers.js +2 -9
  44. package/headers.js.map +1 -1
  45. package/index.d.ts +18 -18
  46. package/index.js +18 -207
  47. package/index.js.map +1 -1
  48. package/mdbid.js +4 -12
  49. package/mdbid.js.map +1 -1
  50. package/middleware.d.ts +1 -1
  51. package/middleware.js +1 -8
  52. package/middleware.js.map +1 -1
  53. package/package.json +15 -18
  54. package/parseIdentifier.d.ts +1 -1
  55. package/parseIdentifier.js +5 -14
  56. package/parseIdentifier.js.map +1 -1
  57. package/removeNullValues.js +1 -8
  58. package/removeNullValues.js.map +1 -1
  59. package/removeUndefinedValues.js +1 -8
  60. package/removeUndefinedValues.js.map +1 -1
  61. package/utcTimezones.js +1 -7
  62. package/utcTimezones.js.map +1 -1
  63. package/zeroPad.js +1 -8
  64. package/zeroPad.js.map +1 -1
package/GenericRecord.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=GenericRecord.js.map
package/README.md CHANGED
@@ -1,25 +1,11 @@
1
1
  # @webiny/utils
2
2
 
3
- [![](https://img.shields.io/npm/dw/@webiny/utils.svg)](https://www.npmjs.com/package/@webiny/utils)
4
- [![](https://img.shields.io/npm/v/@webiny/utils.svg)](https://www.npmjs.com/package/@webiny/utils)
5
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
7
6
 
8
- ## About
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
9
8
 
10
- Small package containing the methods that are used throughout our other packages.
11
- * for example, zeroPad adds zeros to the start of the version number.
9
+ ---
12
10
 
13
- ## Install
14
-
15
- ```
16
- yarn add @webiny/utils
17
- ```
18
-
19
-
20
- ## Testing
21
-
22
- ### Command
23
- ````
24
- yarn test packages/utils
25
- ````
11
+ _This README file is automatically generated during the publish process._
package/cacheKey.d.ts CHANGED
@@ -1,9 +1,2 @@
1
- /// <reference types="node" />
2
- import type { BinaryToTextEncoding } from "crypto";
3
1
  export type ICacheKeyKeys = Record<string, any> | string | number;
4
- export interface ICacheKeyOptions {
5
- algorithm?: CacheKeyAlgorithmType;
6
- encoding?: BinaryToTextEncoding;
7
- }
8
- export type CacheKeyAlgorithmType = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
9
- export declare const createCacheKey: (input: ICacheKeyKeys, options?: ICacheKeyOptions) => string;
2
+ export declare const createCacheKey: (input: ICacheKeyKeys) => string;
package/cacheKey.js CHANGED
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createCacheKey = void 0;
8
- var _crypto = _interopRequireDefault(require("crypto"));
1
+ import { sha256 } from "@noble/hashes/sha2.js";
2
+ import { utf8ToBytes, bytesToHex } from "@noble/hashes/utils.js";
9
3
  const getCacheKey = input => {
10
4
  if (typeof input === "string") {
11
5
  return input;
@@ -14,10 +8,10 @@ const getCacheKey = input => {
14
8
  }
15
9
  return JSON.stringify(input);
16
10
  };
17
- const createCacheKey = (input, options) => {
11
+ export const createCacheKey = input => {
18
12
  const key = getCacheKey(input);
19
- return _crypto.default.createHash(options?.algorithm || "sha1").update(key).digest(options?.encoding || "hex");
13
+ const hash = sha256(utf8ToBytes(key));
14
+ return bytesToHex(hash);
20
15
  };
21
- exports.createCacheKey = createCacheKey;
22
16
 
23
17
  //# sourceMappingURL=cacheKey.js.map
package/cacheKey.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_crypto","_interopRequireDefault","require","getCacheKey","input","JSON","stringify","createCacheKey","options","key","crypto","createHash","algorithm","update","digest","encoding","exports"],"sources":["cacheKey.ts"],"sourcesContent":["import type { BinaryToTextEncoding } from \"crypto\";\nimport crypto from \"crypto\";\n\nexport type ICacheKeyKeys = Record<string, any> | string | number;\n\nexport interface ICacheKeyOptions {\n algorithm?: CacheKeyAlgorithmType;\n encoding?: BinaryToTextEncoding;\n}\n\nexport type CacheKeyAlgorithmType = \"md5\" | \"sha1\" | \"sha224\" | \"sha256\" | \"sha384\" | \"sha512\";\n\nconst getCacheKey = (input: ICacheKeyKeys): string => {\n if (typeof input === \"string\") {\n return input;\n } else if (typeof input === \"number\") {\n return `${input}`;\n }\n return JSON.stringify(input);\n};\n\nexport const createCacheKey = (input: ICacheKeyKeys, options?: ICacheKeyOptions): string => {\n const key = getCacheKey(input);\n return crypto\n .createHash(options?.algorithm || \"sha1\")\n .update(key)\n .digest(options?.encoding || \"hex\");\n};\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,MAAMC,WAAW,GAAIC,KAAoB,IAAa;EAClD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAO,GAAGA,KAAK,EAAE;EACrB;EACA,OAAOC,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC;AAChC,CAAC;AAEM,MAAMG,cAAc,GAAGA,CAACH,KAAoB,EAAEI,OAA0B,KAAa;EACxF,MAAMC,GAAG,GAAGN,WAAW,CAACC,KAAK,CAAC;EAC9B,OAAOM,eAAM,CACRC,UAAU,CAACH,OAAO,EAAEI,SAAS,IAAI,MAAM,CAAC,CACxCC,MAAM,CAACJ,GAAG,CAAC,CACXK,MAAM,CAACN,OAAO,EAAEO,QAAQ,IAAI,KAAK,CAAC;AAC3C,CAAC;AAACC,OAAA,CAAAT,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"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":[]}
package/compose.js CHANGED
@@ -1,11 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.composeAsync = composeAsync;
7
- exports.composeSync = composeSync;
8
- function composeAsync(functions = []) {
1
+ export function composeAsync(functions = []) {
9
2
  return input => {
10
3
  if (!functions.length) {
11
4
  return Promise.resolve(input);
@@ -22,7 +15,7 @@ function composeAsync(functions = []) {
22
15
  return next(input);
23
16
  };
24
17
  }
25
- function composeSync(functions = []) {
18
+ export function composeSync(functions = []) {
26
19
  return input => {
27
20
  if (!functions.length) {
28
21
  return input;
package/compose.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["composeAsync","functions","input","length","Promise","resolve","index","next","fn","composeSync"],"sources":["compose.ts"],"sourcesContent":["export interface NextAsyncProcessor<TInput, TOutput> {\n (input: TInput): Promise<TOutput>;\n}\n\nexport interface AsyncProcessor<TInput, TOutput = TInput> {\n (next: NextAsyncProcessor<TInput, TOutput>): NextAsyncProcessor<TInput, TOutput>;\n}\n\nexport interface NextSyncProcessor<TInput, TOutput = TInput> {\n (input: TInput): TOutput;\n}\n\nexport interface SyncProcessor<TInput, TOutput = TInput> {\n (next: NextSyncProcessor<TInput, TOutput>): NextSyncProcessor<TInput, TOutput>;\n}\n\nexport function composeAsync<TInput = unknown, TOutput = TInput>(\n functions: Array<AsyncProcessor<TInput, TOutput>> = []\n): NextAsyncProcessor<TInput, TOutput> {\n return (input: TInput): Promise<TOutput> => {\n if (!functions.length) {\n return Promise.resolve(input as unknown as TOutput);\n }\n\n let index = -1;\n\n const next: NextAsyncProcessor<TInput, TOutput> = async input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n\nexport function composeSync<TInput = unknown, TOutput = TInput>(\n functions: Array<SyncProcessor<TInput, TOutput>> = []\n): NextSyncProcessor<TInput, TOutput> {\n return (input: TInput): TOutput => {\n if (!functions.length) {\n return input as unknown as TOutput;\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n let index = -1;\n\n const next: NextSyncProcessor<TInput, TOutput> = input => {\n index++;\n\n const fn = functions[index];\n if (!fn) {\n return input as unknown as TOutput;\n }\n\n return fn(next)(input);\n };\n\n return next(input);\n };\n}\n"],"mappings":";;;;;;;AAgBO,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;AAEO,SAASO,WAAWA,CACvBR,SAAgD,GAAG,EAAE,EACnB;EAClC,OAAQC,KAAa,IAAc;IAC/B,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE;MACnB,OAAOD,KAAK;IAChB;;IAEA;IACA,IAAII,KAAK,GAAG,CAAC,CAAC;IAEd,MAAMC,IAAwC,GAAGL,KAAK,IAAI;MACtDI,KAAK,EAAE;MAEP,MAAME,EAAE,GAAGP,SAAS,CAACK,KAAK,CAAC;MAC3B,IAAI,CAACE,EAAE,EAAE;QACL,OAAON,KAAK;MAChB;MAEA,OAAOM,EAAE,CAACD,IAAI,CAAC,CAACL,KAAK,CAAC;IAC1B,CAAC;IAED,OAAOK,IAAI,CAACL,KAAK,CAAC;EACtB,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"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,13 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CompressionPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- class CompressionPlugin extends _plugins.Plugin {
1
+ import { Plugin } from "@webiny/plugins";
2
+ export class CompressionPlugin extends Plugin {
9
3
  static type = "utils.compression";
10
4
  }
11
- exports.CompressionPlugin = CompressionPlugin;
12
5
 
13
6
  //# sourceMappingURL=CompressionPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","CompressionPlugin","Plugin","type","exports"],"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,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAeC,iBAAiB,SAASC,eAAM,CAAC;EACnD,OAAuBC,IAAI,GAAW,mBAAmB;AAK7D;AAACC,OAAA,CAAAH,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"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":[]}
@@ -1,5 +1,5 @@
1
1
  import type { PluginsContainer } from "@webiny/plugins";
2
- import { type ICompressedValue } from "./CompressionPlugin";
2
+ import { type ICompressedValue } from "./CompressionPlugin.js";
3
3
  export interface ICompressorParams {
4
4
  plugins: PluginsContainer;
5
5
  }
@@ -1,16 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createDefaultCompressor = void 0;
7
- var _CompressionPlugin = require("./CompressionPlugin");
8
- var _GzipCompression = require("./plugins/GzipCompression");
9
- var _JsonpackCompression = require("./plugins/JsonpackCompression");
1
+ import { CompressionPlugin } from "./CompressionPlugin.js";
2
+ import { createGzipCompression } from "./plugins/GzipCompression.js";
3
+ import { createJsonpackCompression } from "./plugins/JsonpackCompression.js";
10
4
  class Compressor {
11
5
  disabled = new Set();
12
6
  get plugins() {
13
- return this._plugins.byType(_CompressionPlugin.CompressionPlugin.type).reverse();
7
+ return this._plugins.byType(CompressionPlugin.type).reverse();
14
8
  }
15
9
  constructor(params) {
16
10
  this._plugins = params.plugins;
@@ -56,15 +50,14 @@ class Compressor {
56
50
  return data;
57
51
  }
58
52
  }
59
- const createDefaultCompressor = params => {
53
+ export const createDefaultCompressor = params => {
60
54
  const {
61
55
  plugins
62
56
  } = params;
63
- plugins.register([(0, _JsonpackCompression.createJsonpackCompression)(), (0, _GzipCompression.createGzipCompression)()]);
57
+ plugins.register([createJsonpackCompression(), createGzipCompression()]);
64
58
  return new Compressor({
65
59
  plugins
66
60
  });
67
61
  };
68
- exports.createDefaultCompressor = createDefaultCompressor;
69
62
 
70
63
  //# sourceMappingURL=Compressor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_CompressionPlugin","require","_GzipCompression","_JsonpackCompression","Compressor","disabled","Set","plugins","_plugins","byType","CompressionPlugin","type","reverse","constructor","params","disable","name","add","enable","delete","compress","data","plugin","has","canCompress","ex","console","error","log","decompress","canDecompress","createDefaultCompressor","register","createJsonpackCompression","createGzipCompression","exports"],"sources":["Compressor.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { CompressionPlugin, type ICompressedValue } from \"./CompressionPlugin\";\nimport { createGzipCompression } from \"./plugins/GzipCompression\";\nimport { createJsonpackCompression } from \"./plugins/JsonpackCompression\";\n\nexport interface ICompressorParams {\n plugins: PluginsContainer;\n}\n\nexport interface ICompressor {\n disable(name: string): void;\n enable(name: string): void;\n /**\n * Compresses the given data using the first plugin that can compress it.\n */\n compress<T = unknown>(data: T): Promise<T | ICompressedValue>;\n /**\n * Decompresses the given data using the first plugin that can decompress it.\n */\n decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T>;\n}\n\nclass Compressor implements ICompressor {\n private readonly _plugins: PluginsContainer;\n\n private readonly disabled: Set<string> = new Set();\n\n private get plugins(): CompressionPlugin[] {\n return this._plugins.byType<CompressionPlugin>(CompressionPlugin.type).reverse();\n }\n\n public constructor(params: ICompressorParams) {\n this._plugins = params.plugins;\n }\n\n public disable(name: string): void {\n this.disabled.add(name);\n }\n\n public enable(name: string): void {\n this.disabled.delete(name);\n }\n\n public async compress<T = unknown>(data: T): Promise<T | ICompressedValue> {\n for (const plugin of this.plugins) {\n /**\n * We skip disabled plugins.\n */\n if (plugin.name && this.disabled.has(plugin.name)) {\n continue;\n }\n if (plugin.canCompress(data) === false) {\n continue;\n }\n try {\n return await plugin.compress(data);\n } catch (ex) {\n console.error(\n `Could not compress given data. More info in next line. Trying next plugin.`\n );\n console.log(ex);\n }\n }\n return data;\n }\n\n public async decompress<T = unknown>(data: ICompressedValue | unknown): Promise<T> {\n for (const plugin of this.plugins) {\n if (plugin.canDecompress(data) === false) {\n continue;\n }\n try {\n return await plugin.decompress(data);\n } catch (ex) {\n console.error(\n `Could not decompress given data. More info in next line. Trying next plugin.`\n );\n console.log(ex);\n }\n }\n return data as T;\n }\n}\n\nexport const createDefaultCompressor = (params: ICompressorParams) => {\n const { plugins } = params;\n plugins.register([createJsonpackCompression(), createGzipCompression()]);\n return new Compressor({\n plugins\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAmBA,MAAMG,UAAU,CAAwB;EAGnBC,QAAQ,GAAgB,IAAIC,GAAG,CAAC,CAAC;EAElD,IAAYC,OAAOA,CAAA,EAAwB;IACvC,OAAO,IAAI,CAACC,QAAQ,CAACC,MAAM,CAAoBC,oCAAiB,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;EACpF;EAEOC,WAAWA,CAACC,MAAyB,EAAE;IAC1C,IAAI,CAACN,QAAQ,GAAGM,MAAM,CAACP,OAAO;EAClC;EAEOQ,OAAOA,CAACC,IAAY,EAAQ;IAC/B,IAAI,CAACX,QAAQ,CAACY,GAAG,CAACD,IAAI,CAAC;EAC3B;EAEOE,MAAMA,CAACF,IAAY,EAAQ;IAC9B,IAAI,CAACX,QAAQ,CAACc,MAAM,CAACH,IAAI,CAAC;EAC9B;EAEA,MAAaI,QAAQA,CAAcC,IAAO,EAAiC;IACvE,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACf,OAAO,EAAE;MAC/B;AACZ;AACA;MACY,IAAIe,MAAM,CAACN,IAAI,IAAI,IAAI,CAACX,QAAQ,CAACkB,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,CAACf,OAAO,EAAE;MAC/B,IAAIe,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;AAEO,MAAMU,uBAAuB,GAAIjB,MAAyB,IAAK;EAClE,MAAM;IAAEP;EAAQ,CAAC,GAAGO,MAAM;EAC1BP,OAAO,CAACyB,QAAQ,CAAC,CAAC,IAAAC,8CAAyB,EAAC,CAAC,EAAE,IAAAC,sCAAqB,EAAC,CAAC,CAAC,CAAC;EACxE,OAAO,IAAI9B,UAAU,CAAC;IAClBG;EACJ,CAAC,CAAC;AACN,CAAC;AAAC4B,OAAA,CAAAJ,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"names":["CompressionPlugin","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":[]}
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import zlib from "zlib";
5
2
  export declare const compress: (input: zlib.InputType, options?: zlib.ZlibOptions) => Promise<Buffer>;
6
3
  export declare const decompress: (input: zlib.InputType, options?: zlib.ZlibOptions) => Promise<Buffer>;
@@ -1,14 +1,7 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.decompress = exports.compress = void 0;
8
- var _zlib = _interopRequireDefault(require("zlib"));
9
- const compress = (input, options) => {
1
+ import zlib from "zlib";
2
+ export const compress = (input, options) => {
10
3
  return new Promise(function (resolve, reject) {
11
- _zlib.default.gzip(input, options || {}, function (error, result) {
4
+ zlib.gzip(input, options || {}, function (error, result) {
12
5
  if (!error) {
13
6
  resolve(result);
14
7
  } else {
@@ -17,10 +10,9 @@ const compress = (input, options) => {
17
10
  });
18
11
  });
19
12
  };
20
- exports.compress = compress;
21
- const decompress = (input, options) => {
13
+ export const decompress = (input, options) => {
22
14
  return new Promise(function (resolve, reject) {
23
- _zlib.default.gunzip(input, options || {}, function (error, result) {
15
+ zlib.gunzip(input, options || {}, function (error, result) {
24
16
  if (!error) {
25
17
  resolve(result);
26
18
  } else {
@@ -29,6 +21,5 @@ const decompress = (input, options) => {
29
21
  });
30
22
  });
31
23
  };
32
- exports.decompress = decompress;
33
24
 
34
25
  //# sourceMappingURL=gzip.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_zlib","_interopRequireDefault","require","compress","input","options","Promise","resolve","reject","zlib","gzip","error","result","exports","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,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAGA,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;AAACE,OAAA,CAAAV,QAAA,GAAAA,QAAA;AACK,MAAMW,UAAU,GAAGA,CAACV,KAAqB,EAAEC,OAA0B,KAAsB;EAC9F,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;IAC1CC,aAAI,CAACM,MAAM,CAACX,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;AAACE,OAAA,CAAAC,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"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,4 +1,4 @@
1
- export * from "./Compressor";
2
- export * from "./CompressionPlugin";
3
- export * from "./plugins/GzipCompression";
4
- export * from "./plugins/JsonpackCompression";
1
+ export * from "./Compressor.js";
2
+ export * from "./CompressionPlugin.js";
3
+ export * from "./plugins/GzipCompression.js";
4
+ export * from "./plugins/JsonpackCompression.js";
@@ -1,51 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _Compressor = require("./Compressor");
7
- Object.keys(_Compressor).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _Compressor[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _Compressor[key];
14
- }
15
- });
16
- });
17
- var _CompressionPlugin = require("./CompressionPlugin");
18
- Object.keys(_CompressionPlugin).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _CompressionPlugin[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _CompressionPlugin[key];
25
- }
26
- });
27
- });
28
- var _GzipCompression = require("./plugins/GzipCompression");
29
- Object.keys(_GzipCompression).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _GzipCompression[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _GzipCompression[key];
36
- }
37
- });
38
- });
39
- var _JsonpackCompression = require("./plugins/JsonpackCompression");
40
- Object.keys(_JsonpackCompression).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _JsonpackCompression[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _JsonpackCompression[key];
47
- }
48
- });
49
- });
1
+ export * from "./Compressor.js";
2
+ export * from "./CompressionPlugin.js";
3
+ export * from "./plugins/GzipCompression.js";
4
+ export * from "./plugins/JsonpackCompression.js";
50
5
 
51
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Compressor","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_CompressionPlugin","_GzipCompression","_JsonpackCompression"],"sources":["index.ts"],"sourcesContent":["export * from \"./Compressor\";\nexport * from \"./CompressionPlugin\";\nexport * from \"./plugins/GzipCompression\";\nexport * from \"./plugins/JsonpackCompression\";\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,kBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,kBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,kBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,gBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,gBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,gBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,gBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,oBAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,oBAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,oBAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,oBAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"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":[]}
@@ -1,20 +1,11 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.decompress = exports.compress = void 0;
8
- var _jsonpack = _interopRequireDefault(require("jsonpack"));
9
- const compress = async value => {
10
- return _jsonpack.default.pack(value, {
1
+ import jsonpack from "jsonpack";
2
+ export const compress = async value => {
3
+ return jsonpack.pack(value, {
11
4
  verbose: false
12
5
  });
13
6
  };
14
- exports.compress = compress;
15
- const decompress = async value => {
16
- return _jsonpack.default.unpack(value);
7
+ export const decompress = async value => {
8
+ return jsonpack.unpack(value);
17
9
  };
18
- exports.decompress = decompress;
19
10
 
20
11
  //# sourceMappingURL=jsonpack.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_jsonpack","_interopRequireDefault","require","compress","value","jsonpack","pack","verbose","exports","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,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAG,MAAOC,KAAU,IAAK;EAC1C,OAAOC,iBAAQ,CAACC,IAAI,CAACF,KAAK,EAAE;IACxBG,OAAO,EAAE;EACb,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAL,QAAA,GAAAA,QAAA;AAEK,MAAMM,UAAU,GAAG,MAAOL,KAAa,IAAK;EAC/C,OAAOC,iBAAQ,CAACK,MAAM,CAACN,KAAK,CAAC;AACjC,CAAC;AAACI,OAAA,CAAAC,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"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":[]}
@@ -1,7 +1,5 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { CompressionPlugin, type ICompressedValue } from "../CompressionPlugin";
4
- export declare const convertToBuffer: (value: string | Buffer) => Buffer;
1
+ import { CompressionPlugin, type ICompressedValue } from "../CompressionPlugin.js";
2
+ export declare const convertToBuffer: (value: string | Buffer) => Buffer<ArrayBufferLike>;
5
3
  export declare class GzipCompression extends CompressionPlugin {
6
4
  name: string;
7
5
  canCompress(data: any): boolean;
@@ -1,22 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createGzipCompression = exports.convertToBuffer = exports.GzipCompression = void 0;
7
- var _CompressionPlugin = require("../CompressionPlugin");
8
- var _gzip = require("../gzip");
1
+ import { CompressionPlugin } from "../CompressionPlugin.js";
2
+ import { compress as gzip, decompress as ungzip } from "../gzip.js";
9
3
  const GZIP = "gzip";
10
4
  const TO_STORAGE_ENCODING = "base64";
11
5
  const FROM_STORAGE_ENCODING = "utf8";
12
- const convertToBuffer = value => {
6
+ export const convertToBuffer = value => {
13
7
  if (typeof value === "string") {
14
8
  return Buffer.from(value, TO_STORAGE_ENCODING);
15
9
  }
16
10
  return value;
17
11
  };
18
- exports.convertToBuffer = convertToBuffer;
19
- class GzipCompression extends _CompressionPlugin.CompressionPlugin {
12
+ export class GzipCompression extends CompressionPlugin {
20
13
  name = "utils.compression.gzip";
21
14
  canCompress(data) {
22
15
  if (!!data?.compression) {
@@ -29,7 +22,7 @@ class GzipCompression extends _CompressionPlugin.CompressionPlugin {
29
22
  return data;
30
23
  }
31
24
  // This stringifies both regular strings and JSON objects.
32
- const value = await (0, _gzip.compress)(JSON.stringify(data));
25
+ const value = await gzip(JSON.stringify(data));
33
26
  return {
34
27
  compression: GZIP,
35
28
  value: value.toString(TO_STORAGE_ENCODING)
@@ -49,7 +42,7 @@ class GzipCompression extends _CompressionPlugin.CompressionPlugin {
49
42
  return null;
50
43
  }
51
44
  try {
52
- const buf = await (0, _gzip.decompress)(convertToBuffer(data.value));
45
+ const buf = await ungzip(convertToBuffer(data.value));
53
46
  const value = buf.toString(FROM_STORAGE_ENCODING);
54
47
  return JSON.parse(value);
55
48
  } catch (ex) {
@@ -58,10 +51,8 @@ class GzipCompression extends _CompressionPlugin.CompressionPlugin {
58
51
  }
59
52
  }
60
53
  }
61
- exports.GzipCompression = GzipCompression;
62
- const createGzipCompression = () => {
54
+ export const createGzipCompression = () => {
63
55
  return new GzipCompression();
64
56
  };
65
- exports.createGzipCompression = createGzipCompression;
66
57
 
67
58
  //# sourceMappingURL=GzipCompression.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_CompressionPlugin","require","_gzip","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","exports","GzipCompression","CompressionPlugin","name","canCompress","data","compression","compress","undefined","gzip","JSON","stringify","toString","canDecompress","toLowerCase","decompress","buf","ungzip","parse","ex","console","log","message","createGzipCompression"],"sources":["GzipCompression.ts"],"sourcesContent":["import { CompressionPlugin, type ICompressedValue } from \"../CompressionPlugin\";\nimport { compress as gzip, decompress as ungzip } from \"~/compression/gzip\";\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,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,MAAME,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAE7B,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;AAACG,OAAA,CAAAJ,eAAA,GAAAA,eAAA;AAEK,MAAMK,eAAe,SAASC,oCAAiB,CAAC;EACnCC,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,MAAsBC,QAAQA,CAACF,IAAS,EAA6B;IACjE,IAAIA,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAKG,SAAS,EAAE;MACrC,OAAOH,IAAI;IACf;IACA;IACA,MAAMR,KAAK,GAAG,MAAM,IAAAY,cAAI,EAACC,IAAI,CAACC,SAAS,CAACN,IAAI,CAAC,CAAC;IAE9C,OAAO;MACHC,WAAW,EAAEb,IAAI;MACjBI,KAAK,EAAEA,KAAK,CAACe,QAAQ,CAAClB,mBAAmB;IAC7C,CAAC;EACL;EAEgBmB,aAAaA,CAACR,IAA+B,EAAW;IACpE,IAAI,CAACA,IAAI,EAAEC,WAAW,EAAE;MACpB,OAAO,KAAK;IAChB;IAEA,MAAMA,WAAW,GAAGD,IAAI,CAACC,WAAqB;IAE9C,OAAOA,WAAW,CAACQ,WAAW,CAAC,CAAC,KAAKrB,IAAI;EAC7C;EAEA,MAAsBsB,UAAUA,CAACV,IAAsB,EAAgB;IACnE,IAAI,CAACA,IAAI,EAAE;MACP,OAAOA,IAAI;IACf,CAAC,MAAM,IAAI,CAACA,IAAI,CAACR,KAAK,EAAE;MACpB,OAAO,IAAI;IACf;IACA,IAAI;MACA,MAAMmB,GAAG,GAAG,MAAM,IAAAC,gBAAM,EAACrB,eAAe,CAACS,IAAI,CAACR,KAAK,CAAC,CAAC;MACrD,MAAMA,KAAK,GAAGmB,GAAG,CAACJ,QAAQ,CAACjB,qBAAqB,CAAC;MACjD,OAAOe,IAAI,CAACQ,KAAK,CAACrB,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOsB,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC,kCAAkC,EAAEF,EAAE,CAACG,OAAO,CAAC;MAC3D,OAAO,IAAI;IACf;EACJ;AACJ;AAACtB,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAEM,MAAMsB,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,IAAItB,eAAe,CAAC,CAAC;AAChC,CAAC;AAACD,OAAA,CAAAuB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"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":[]}
@@ -1,4 +1,4 @@
1
- import { CompressionPlugin, type ICompressedValue } from "../CompressionPlugin";
1
+ import { CompressionPlugin, type ICompressedValue } from "../CompressionPlugin.js";
2
2
  export declare class JsonpackCompression extends CompressionPlugin {
3
3
  name: string;
4
4
  canCompress(data: any): boolean;
@@ -1,13 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createJsonpackCompression = exports.JsonpackCompression = void 0;
7
- var _CompressionPlugin = require("../CompressionPlugin");
8
- var _jsonpack = require("../jsonpack");
1
+ import { CompressionPlugin } from "../CompressionPlugin.js";
2
+ import { compress, decompress } from "../jsonpack.js";
9
3
  const JSONPACK = "jsonpack";
10
- class JsonpackCompression extends _CompressionPlugin.CompressionPlugin {
4
+ export class JsonpackCompression extends CompressionPlugin {
11
5
  name = "utils.compression.jsonpack";
12
6
  canCompress(data) {
13
7
  if (typeof data !== "object") {
@@ -22,7 +16,7 @@ class JsonpackCompression extends _CompressionPlugin.CompressionPlugin {
22
16
  if (data === null || data === undefined) {
23
17
  return data;
24
18
  }
25
- const value = await (0, _jsonpack.compress)(data);
19
+ const value = await compress(data);
26
20
  return {
27
21
  compression: JSONPACK,
28
22
  value
@@ -44,17 +38,15 @@ class JsonpackCompression extends _CompressionPlugin.CompressionPlugin {
44
38
  return null;
45
39
  }
46
40
  try {
47
- return await (0, _jsonpack.decompress)(data.value);
41
+ return await decompress(data.value);
48
42
  } catch (ex) {
49
43
  console.log(`Could not decompress given data.`, ex.message);
50
44
  return null;
51
45
  }
52
46
  }
53
47
  }
54
- exports.JsonpackCompression = JsonpackCompression;
55
- const createJsonpackCompression = () => {
48
+ export const createJsonpackCompression = () => {
56
49
  return new JsonpackCompression();
57
50
  };
58
- exports.createJsonpackCompression = createJsonpackCompression;
59
51
 
60
52
  //# sourceMappingURL=JsonpackCompression.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_CompressionPlugin","require","_jsonpack","JSONPACK","JsonpackCompression","CompressionPlugin","name","canCompress","data","compression","compress","undefined","value","canDecompress","toLowerCase","decompress","ex","console","log","message","exports","createJsonpackCompression"],"sources":["JsonpackCompression.ts"],"sourcesContent":["import { CompressionPlugin, type ICompressedValue } from \"../CompressionPlugin\";\nimport { compress, decompress } from \"~/compression/jsonpack\";\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,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,MAAME,QAAQ,GAAG,UAAU;AAEpB,MAAMC,mBAAmB,SAASC,oCAAiB,CAAC;EACvCC,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,MAAsBC,QAAQA,CAACF,IAAS,EAA6B;IACjE,IAAIA,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAKG,SAAS,EAAE;MACrC,OAAOH,IAAI;IACf;IACA,MAAMI,KAAK,GAAG,MAAM,IAAAF,kBAAQ,EAACF,IAAI,CAAC;IAElC,OAAO;MACHC,WAAW,EAAEN,QAAQ;MACrBS;IACJ,CAAC;EACL;EAEgBC,aAAaA,CAACL,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,CAACK,WAAW,CAAC,CAAC,KAAKX,QAAQ;EACjD;EAEA,MAAsBY,UAAUA,CAACP,IAAsB,EAAgB;IACnE,IAAI,CAACA,IAAI,EAAE;MACP,OAAOA,IAAI;IACf,CAAC,MAAM,IAAI,CAACA,IAAI,CAACI,KAAK,EAAE;MACpB,OAAO,IAAI;IACf;IACA,IAAI;MACA,OAAO,MAAM,IAAAG,oBAAU,EAACP,IAAI,CAACI,KAAK,CAAC;IACvC,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC,kCAAkC,EAAEF,EAAE,CAACG,OAAO,CAAC;MAC3D,OAAO,IAAI;IACf;EACJ;AACJ;AAACC,OAAA,CAAAhB,mBAAA,GAAAA,mBAAA;AAEM,MAAMiB,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,IAAIjB,mBAAmB,CAAC,CAAC;AACpC,CAAC;AAACgB,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"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":[]}
@@ -1,11 +1,6 @@
1
- "use strict";
1
+ import { zeroPad } from "./zeroPad.js";
2
+ import { parseIdentifier } from "./parseIdentifier.js";
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createIdentifier = void 0;
7
- var _zeroPad = require("./zeroPad");
8
- var _parseIdentifier = require("./parseIdentifier");
9
4
  /**
10
5
  * Used to create the identifier that is an absolute unique for the record.
11
6
  * It is created out of the generated ID and version of the record.
@@ -14,12 +9,11 @@ var _parseIdentifier = require("./parseIdentifier");
14
9
  * The input ID is being parsed as you might send a full ID instead of only the generated one.
15
10
  */
16
11
 
17
- const createIdentifier = values => {
12
+ export const createIdentifier = values => {
18
13
  const {
19
14
  id
20
- } = (0, _parseIdentifier.parseIdentifier)(values.id);
21
- return `${id}#${(0, _zeroPad.zeroPad)(values.version)}`;
15
+ } = parseIdentifier(values.id);
16
+ return `${id}#${zeroPad(values.version)}`;
22
17
  };
23
- exports.createIdentifier = createIdentifier;
24
18
 
25
19
  //# sourceMappingURL=createIdentifier.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_zeroPad","require","_parseIdentifier","createIdentifier","values","id","parseIdentifier","zeroPad","version","exports"],"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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,MAAME,gBAAgB,GAAIC,MAA8B,IAAa;EACxE,MAAM;IAAEC;EAAG,CAAC,GAAG,IAAAC,gCAAe,EAACF,MAAM,CAACC,EAAE,CAAC;EAEzC,OAAO,GAAGA,EAAE,IAAI,IAAAE,gBAAO,EAACH,MAAM,CAACI,OAAO,CAAC,EAAE;AAC7C,CAAC;AAACC,OAAA,CAAAN,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["zeroPad","parseIdentifier","createIdentifier","values","id","version"],"sources":["createIdentifier.ts"],"sourcesContent":["import { zeroPad } from \"./zeroPad.js\";\nimport { parseIdentifier } from \"./parseIdentifier.js\";\n\n/**\n * Used to create the identifier that is an absolute unique for the record.\n * It is created out of the generated ID and version of the record.\n *\n *\n * The input ID is being parsed as you might send a full ID instead of only the generated one.\n */\nexport interface CreateIdentifierParams {\n id: string;\n version: number;\n}\n\nexport const createIdentifier = (values: CreateIdentifierParams): string => {\n const { id } = parseIdentifier(values.id);\n\n return `${id}#${zeroPad(values.version)}`;\n};\n"],"mappings":"AAAA,SAASA,OAAO;AAChB,SAASC,eAAe;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAa;EACxE,MAAM;IAAEC;EAAG,CAAC,GAAGH,eAAe,CAACE,MAAM,CAACC,EAAE,CAAC;EAEzC,OAAO,GAAGA,EAAE,IAAIJ,OAAO,CAACG,MAAM,CAACE,OAAO,CAAC,EAAE;AAC7C,CAAC","ignoreList":[]}