@webiny/api 5.43.0-beta.0 → 5.43.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Context.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { Context as ContextInterface } from "./types";
1
+ import type { Context as ContextInterface } from "./types";
2
2
  import { PluginsContainer } from "@webiny/plugins";
3
- import { PluginCollection } from "@webiny/plugins/types";
3
+ import type { PluginCollection } from "@webiny/plugins/types";
4
4
  import { Benchmark } from "./Benchmark";
5
+ import type { ICompressor } from "@webiny/utils/compression/Compressor";
5
6
  export interface ContextParams {
6
7
  plugins?: PluginCollection | PluginsContainer;
7
8
  WEBINY_VERSION: string;
@@ -12,6 +13,7 @@ export declare class Context implements ContextInterface {
12
13
  readonly plugins: PluginsContainer;
13
14
  readonly WEBINY_VERSION: string;
14
15
  readonly benchmark: Benchmark;
16
+ readonly compressor: ICompressor;
15
17
  private readonly waiters;
16
18
  constructor(params: ContextParams);
17
19
  getResult(): any;
package/Context.js CHANGED
@@ -7,6 +7,8 @@ exports.Context = void 0;
7
7
  var _plugins = require("@webiny/plugins");
8
8
  var _Benchmark = require("./Benchmark");
9
9
  var _BenchmarkPlugin = require("./plugins/BenchmarkPlugin");
10
+ var _compression = require("@webiny/utils/compression");
11
+ var _CompressorPlugin = require("./plugins/CompressorPlugin");
10
12
  const getPluginsContainer = plugins => {
11
13
  if (!plugins) {
12
14
  return new _plugins.PluginsContainer();
@@ -30,7 +32,14 @@ class Context {
30
32
  * Also, register the plugin to have benchmark accessible via plugins container.
31
33
  */
32
34
  this.benchmark = new _Benchmark.Benchmark();
33
- this.plugins.register(new _BenchmarkPlugin.BenchmarkPlugin(this.benchmark));
35
+ this.compressor = (0, _compression.createDefaultCompressor)({
36
+ plugins: this.plugins
37
+ });
38
+ this.plugins.register(new _BenchmarkPlugin.BenchmarkPlugin(this.benchmark), new _CompressorPlugin.CompressorPlugin({
39
+ getCompressor: () => {
40
+ return this.compressor;
41
+ }
42
+ }));
34
43
  }
35
44
  getResult() {
36
45
  return this._result;
package/Context.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","_Benchmark","_BenchmarkPlugin","getPluginsContainer","plugins","PluginsContainer","Context","waiters","constructor","params","WEBINY_VERSION","benchmark","Benchmark","register","BenchmarkPlugin","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","includes","filter","t","length","get","configurable","push","exports"],"sources":["Context.ts"],"sourcesContent":["import { Context as ContextInterface } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport { Benchmark } from \"~/Benchmark\";\nimport { BenchmarkPlugin } from \"~/plugins/BenchmarkPlugin\";\n\ninterface Waiter {\n targets: string[];\n cb: (context: ContextInterface) => void;\n}\n\nexport interface ContextParams {\n plugins?: PluginCollection | PluginsContainer;\n WEBINY_VERSION: string;\n}\n\nconst getPluginsContainer = (plugins?: PluginCollection | PluginsContainer): PluginsContainer => {\n if (!plugins) {\n return new PluginsContainer();\n }\n if (plugins instanceof PluginsContainer) {\n return plugins;\n }\n return new PluginsContainer(plugins);\n};\n\nexport class Context implements ContextInterface {\n public _result: any;\n public args: any;\n public readonly plugins: PluginsContainer;\n public readonly WEBINY_VERSION: string;\n public readonly benchmark: Benchmark;\n\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, WEBINY_VERSION } = params;\n this.plugins = getPluginsContainer(plugins);\n this.WEBINY_VERSION = WEBINY_VERSION;\n /**\n * At the moment let's have benchmark as part of the context.\n * Also, register the plugin to have benchmark accessible via plugins container.\n */\n this.benchmark = new Benchmark();\n this.plugins.register(new BenchmarkPlugin(this.benchmark));\n }\n\n public getResult(): any {\n return this._result;\n }\n\n public hasResult(): boolean {\n return !!this._result;\n }\n\n public setResult(value: any): void {\n this._result = value;\n }\n\n public waitFor<T extends ContextInterface = ContextInterface>(\n obj: string | string[],\n cb: (context: T) => void\n ): void {\n const initialTargets = Array.isArray(obj) ? obj : [obj];\n const targets: string[] = [];\n /**\n * We go only through the first level properties\n */\n for (const key in initialTargets) {\n const target = initialTargets[key] as keyof this;\n /**\n * If property already exists, there is no need to wait for it, so we just continue the loop.\n * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.\n */\n if (this[target]) {\n continue;\n } else if (typeof target !== \"string\") {\n continue;\n }\n /**\n * Since there is no property, we must define it with its setter and getter.\n * We could not know when it got defined otherwise.\n */\n Object.defineProperty(this, target, {\n /**\n * Setter sets the given value to this object.\n * We cannot set it on exact property name it is defined because it would go into loop of setting itself.\n * And that is why we add __ around the property name.\n */\n set: (value: any) => {\n const newTargetKey = `__${target}__` as keyof this;\n this[newTargetKey] = value;\n /**\n * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.\n */\n for (const waiter of this.waiters) {\n if (waiter.targets.includes(target) === false) {\n continue;\n }\n /**\n * Remove currently set property so we know if there are any more to be waited for.\n */\n waiter.targets = waiter.targets.filter(t => t !== target);\n /**\n * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.\n */\n if (waiter.targets.length > 0) {\n continue;\n }\n /**\n * And if there is nothing more to be waited for, we execute the callable.\n * Note that this callable is not async.\n */\n waiter.cb(this);\n }\n },\n /**\n * As we have set property with __ around it, we must get it as well.\n */\n get: (): any => {\n const newTargetKey = `__${target}__` as keyof this;\n return this[newTargetKey];\n },\n configurable: false\n });\n /**\n * We add the target to be awaited.\n */\n targets.push(target as string);\n }\n /**\n * If there are no targets to be awaited, just fire the callable.\n */\n if (targets.length === 0) {\n cb(this as unknown as T);\n return;\n }\n /**\n * Otherwise add the waiter for the target properties.\n */\n this.waiters.push({\n targets,\n /**\n * TODO @ts-refactor\n * Problem with possible subtype initialization\n */\n // @ts-expect-error\n cb\n });\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OA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CAACiC,IAAI,CAAC;MACdd,OAAO;MACP;AACZ;AACA;AACA;MACY;MACAJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACmB,OAAA,CAAAnC,OAAA,GAAAA,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_plugins","require","_Benchmark","_BenchmarkPlugin","_compression","_CompressorPlugin","getPluginsContainer","plugins","PluginsContainer","Context","waiters","constructor","params","WEBINY_VERSION","benchmark","Benchmark","compressor","createDefaultCompressor","register","BenchmarkPlugin","CompressorPlugin","getCompressor","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","includes","filter","t","length","get","configurable","push","exports"],"sources":["Context.ts"],"sourcesContent":["import type { Context as ContextInterface } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport type { PluginCollection } from \"@webiny/plugins/types\";\nimport { Benchmark } from \"~/Benchmark\";\nimport { BenchmarkPlugin } from \"~/plugins/BenchmarkPlugin\";\nimport type { ICompressor } from \"@webiny/utils/compression/Compressor\";\nimport { createDefaultCompressor } from \"@webiny/utils/compression\";\nimport { CompressorPlugin } from \"~/plugins/CompressorPlugin\";\n\ninterface Waiter {\n targets: string[];\n cb: (context: ContextInterface) => void;\n}\n\nexport interface ContextParams {\n plugins?: PluginCollection | PluginsContainer;\n WEBINY_VERSION: string;\n}\n\nconst getPluginsContainer = (plugins?: PluginCollection | PluginsContainer): PluginsContainer => {\n if (!plugins) {\n return new PluginsContainer();\n }\n if (plugins instanceof PluginsContainer) {\n return plugins;\n }\n return new PluginsContainer(plugins);\n};\n\nexport class Context implements ContextInterface {\n public _result: any;\n public args: any;\n public readonly plugins: PluginsContainer;\n public readonly WEBINY_VERSION: string;\n public readonly benchmark: Benchmark;\n public readonly compressor: ICompressor;\n\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, WEBINY_VERSION } = params;\n this.plugins = getPluginsContainer(plugins);\n this.WEBINY_VERSION = WEBINY_VERSION;\n /**\n * At the moment let's have benchmark as part of the context.\n * Also, register the plugin to have benchmark accessible via plugins container.\n */\n this.benchmark = new Benchmark();\n this.compressor = createDefaultCompressor({\n plugins: this.plugins\n });\n this.plugins.register(\n new BenchmarkPlugin(this.benchmark),\n new CompressorPlugin({\n getCompressor: () => {\n return this.compressor;\n }\n })\n );\n }\n\n public getResult(): any {\n return this._result;\n }\n\n public hasResult(): boolean {\n return !!this._result;\n }\n\n public setResult(value: any): void {\n this._result = value;\n }\n\n public waitFor<T extends ContextInterface = ContextInterface>(\n obj: string | string[],\n cb: (context: T) => void\n ): void {\n const initialTargets = Array.isArray(obj) ? obj : [obj];\n const targets: string[] = [];\n /**\n * We go only through the first level properties\n */\n for (const key in initialTargets) {\n const target = initialTargets[key] as keyof this;\n /**\n * If property already exists, there is no need to wait for it, so we just continue the loop.\n * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.\n */\n if (this[target]) {\n continue;\n } else if (typeof target !== \"string\") {\n continue;\n }\n /**\n * Since there is no property, we must define it with its setter and getter.\n * We could not know when it got defined otherwise.\n */\n Object.defineProperty(this, target, {\n /**\n * Setter sets the given value to this object.\n * We cannot set it on exact property name it is defined because it would go into loop of setting itself.\n * And that is why we add __ around the property name.\n */\n set: (value: any) => {\n const newTargetKey = `__${target}__` as keyof this;\n this[newTargetKey] = value;\n /**\n * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.\n */\n for (const waiter of this.waiters) {\n if (waiter.targets.includes(target) === false) {\n continue;\n }\n /**\n * Remove currently set property so we know if there are any more to be waited for.\n */\n waiter.targets = waiter.targets.filter(t => t !== target);\n /**\n * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.\n */\n if (waiter.targets.length > 0) {\n continue;\n }\n /**\n * And if there is nothing more to be waited for, we execute the callable.\n * Note that this callable is not async.\n */\n waiter.cb(this);\n }\n },\n /**\n * As we have set property with __ around it, we must get it as well.\n */\n get: (): any => {\n const newTargetKey = `__${target}__` as keyof this;\n return this[newTargetKey];\n },\n configurable: false\n });\n /**\n * We add the target to be awaited.\n */\n targets.push(target as string);\n }\n /**\n * If there are no targets to be awaited, just fire the callable.\n */\n if (targets.length === 0) {\n cb(this as unknown as T);\n return;\n }\n /**\n * Otherwise add the waiter for the target properties.\n */\n this.waiters.push({\n targets,\n /**\n * TODO @ts-refactor\n * Problem with possible subtype initialization\n */\n // @ts-expect-error\n cb\n });\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAYA,MAAMK,mBAAmB,GAAIC,OAA6C,IAAuB;EAC7F,IAAI,CAACA,OAAO,EAAE;IACV,OAAO,IAAIC,yBAAgB,CAAC,CAAC;EACjC;EACA,IAAID,OAAO,YAAYC,yBAAgB,EAAE;IACrC,OAAOD,OAAO;EAClB;EACA,OAAO,IAAIC,yBAAgB,CAACD,OAAO,CAAC;AACxC,CAAC;AAEM,MAAME,OAAO,CAA6B;EAQ5BC,OAAO,GAAa,EAAE;EAEhCC,WAAWA,CAACC,MAAqB,EAAE;IACtC,MAAM;MAAEL,OAAO;MAAEM;IAAe,CAAC,GAAGD,MAAM;IAC1C,IAAI,CAACL,OAAO,GAAGD,mBAAmB,CAACC,OAAO,CAAC;IAC3C,IAAI,CAACM,cAAc,GAAGA,cAAc;IACpC;AACR;AACA;AACA;IACQ,IAAI,CAACC,SAAS,GAAG,IAAIC,oBAAS,CAAC,CAAC;IAChC,IAAI,CAACC,UAAU,GAAG,IAAAC,oCAAuB,EAAC;MACtCV,OAAO,EAAE,IAAI,CAACA;IAClB,CAAC,CAAC;IACF,IAAI,CAACA,OAAO,CAACW,QAAQ,CACjB,IAAIC,gCAAe,CAAC,IAAI,CAACL,SAAS,CAAC,EACnC,IAAIM,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M,CAACC,CAAC,IAAIA,CAAC,KAAKR,MAAM,CAAC;YACzD;AACxB;AACA;YACwB,IAAIK,MAAM,CAACP,OAAO,CAACW,MAAM,GAAG,CAAC,EAAE;cAC3B;YACJ;YACA;AACxB;AACA;AACA;YACwBJ,MAAM,CAACX,EAAE,CAAC,IAAI,CAAC;UACnB;QACJ,CAAC;QACD;AAChB;AACA;QACgBgB,GAAG,EAAEA,CAAA,KAAW;UACZ,MAAMN,YAAY,GAAG,KAAKJ,MAAM,IAAkB;UAClD,OAAO,IAAI,CAACI,YAAY,CAAC;QAC7B,CAAC;QACDO,YAAY,EAAE;MAClB,CAAC,CAAC;MACF;AACZ;AACA;MACYb,OAAO,CAACc,IAAI,CAACZ,MAAgB,CAAC;IAClC;IACA;AACR;AACA;IACQ,IAAIF,OAAO,CAACW,MAAM,KAAK,CAAC,EAAE;MACtBf,EAAE,CAAC,IAAoB,CAAC;MACxB;IACJ;IACA;AACR;AACA;IACQ,IAAI,CAACnB,OAAO,CAACqC,IAAI,CAAC;MACdd,OAAO;MACP;AACZ;AACA;AACA;MACY;MACAJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACmB,OAAA,CAAAvC,OAAA,GAAAA,OAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./Context";
2
+ export * from "./plugins/CompressorPlugin";
2
3
  export * from "./decorateContext";
3
4
  export * from "./createConditionalPluginFactory";
4
5
  export * from "./ServiceDiscovery";
package/index.js CHANGED
@@ -14,6 +14,17 @@ Object.keys(_Context).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _CompressorPlugin = require("./plugins/CompressorPlugin");
18
+ Object.keys(_CompressorPlugin).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _CompressorPlugin[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _CompressorPlugin[key];
25
+ }
26
+ });
27
+ });
17
28
  var _decorateContext = require("./decorateContext");
18
29
  Object.keys(_decorateContext).forEach(function (key) {
19
30
  if (key === "default" || key === "__esModule") return;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_Context","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_decorateContext","_createConditionalPluginFactory","_ServiceDiscovery","_ContextPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"./Context\";\nexport * from \"./decorateContext\";\nexport * from \"./createConditionalPluginFactory\";\nexport * from \"./ServiceDiscovery\";\nexport * from \"./plugins/ContextPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,gBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,gBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,gBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,gBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,+BAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,+BAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,+BAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,+BAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,iBAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,iBAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,iBAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,iBAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,cAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,cAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,cAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,cAAA,CAAAR,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Context","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_CompressorPlugin","_decorateContext","_createConditionalPluginFactory","_ServiceDiscovery","_ContextPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"./Context\";\nexport * from \"./plugins/CompressorPlugin\";\nexport * from \"./decorateContext\";\nexport * from \"./createConditionalPluginFactory\";\nexport * from \"./ServiceDiscovery\";\n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EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,+BAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,+BAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,iBAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,iBAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,iBAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,iBAAA,CAAAR,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,cAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,cAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,cAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,cAAA,CAAAT,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api",
3
- "version": "5.43.0-beta.0",
3
+ "version": "5.43.0-beta.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,14 +12,14 @@
12
12
  ],
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@webiny/aws-sdk": "5.43.0-beta.0",
16
- "@webiny/plugins": "5.43.0-beta.0"
15
+ "@webiny/aws-sdk": "5.43.0-beta.2",
16
+ "@webiny/plugins": "5.43.0-beta.2",
17
+ "@webiny/utils": "5.43.0-beta.2"
17
18
  },
18
19
  "devDependencies": {
19
- "@webiny/project-utils": "5.43.0-beta.0",
20
+ "@webiny/project-utils": "5.43.0-beta.2",
20
21
  "rimraf": "6.0.1",
21
- "ttypescript": "1.5.15",
22
- "typescript": "4.9.5"
22
+ "typescript": "5.3.3"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public",
@@ -29,5 +29,5 @@
29
29
  "build": "node ../cli/bin.js run build",
30
30
  "watch": "node ../cli/bin.js run watch"
31
31
  },
32
- "gitHead": "abfb4ec7b4391f2414cd22f2c5539c84b6c8abbf"
32
+ "gitHead": "dbed8c263df662358aca18c3cf452cd280f2dfd9"
33
33
  }
@@ -0,0 +1,14 @@
1
+ import { Plugin } from "@webiny/plugins/Plugin";
2
+ import { ICompressor } from "@webiny/utils/compression/Compressor";
3
+ export interface ICompressorPluginParams {
4
+ getCompressor(): ICompressor;
5
+ }
6
+ /**
7
+ * Should never be initialized outside the api package.
8
+ */
9
+ export declare class CompressorPlugin extends Plugin {
10
+ readonly name: string;
11
+ static type: string;
12
+ readonly getCompressor: () => ICompressor;
13
+ constructor(params: ICompressorPluginParams);
14
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CompressorPlugin = void 0;
7
+ var _Plugin = require("@webiny/plugins/Plugin");
8
+ /**
9
+ * Should never be initialized outside the api package.
10
+ */
11
+ class CompressorPlugin extends _Plugin.Plugin {
12
+ name = "context.compressor";
13
+ static type = "context.compressor";
14
+ constructor(params) {
15
+ super();
16
+ this.getCompressor = params.getCompressor;
17
+ }
18
+ }
19
+ exports.CompressorPlugin = CompressorPlugin;
20
+
21
+ //# sourceMappingURL=CompressorPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Plugin","require","CompressorPlugin","Plugin","name","type","constructor","params","getCompressor","exports"],"sources":["CompressorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ICompressor } from \"@webiny/utils/compression/Compressor\";\n\nexport interface ICompressorPluginParams {\n getCompressor(): ICompressor;\n}\n\n/**\n * Should never be initialized outside the api package.\n */\nexport class CompressorPlugin extends Plugin {\n public override readonly name: string = \"context.compressor\";\n public static override type: string = \"context.compressor\";\n\n public readonly getCompressor: () => ICompressor;\n\n public constructor(params: ICompressorPluginParams) {\n super();\n this.getCompressor = params.getCompressor;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAOA;AACA;AACA;AACO,MAAMC,gBAAgB,SAASC,cAAM,CAAC;EAChBC,IAAI,GAAW,oBAAoB;EAC5D,OAAuBC,IAAI,GAAW,oBAAoB;EAInDC,WAAWA,CAACC,MAA+B,EAAE;IAChD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,aAAa,GAAGD,MAAM,CAACC,aAAa;EAC7C;AACJ;AAACC,OAAA,CAAAP,gBAAA,GAAAA,gBAAA","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PluginsContainer } from "@webiny/plugins";
2
+ import { ICompressor } from "@webiny/utils/compression/Compressor";
2
3
  export type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;
3
4
  export type NonEmptyArray<T> = [T, ...T[]];
4
5
  export type BenchmarkRuns = GenericRecord<string, number>;
@@ -69,5 +70,12 @@ export interface Context {
69
70
  * In case of multiple objects defined, wait for all of them.
70
71
  */
71
72
  waitFor: <T extends Context = Context>(obj: string[] | string, cb: (context: T) => void) => void;
73
+ /**
74
+ * Benchmark instance to help determine possible bugs and slow code.
75
+ */
72
76
  benchmark: Benchmark;
77
+ /**
78
+ * Compressor instance to compress and decompress the data.
79
+ */
80
+ compressor: ICompressor;
73
81
  }
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\n\nexport type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\n\nexport type BenchmarkRuns = GenericRecord<string, number>;\n\nexport interface BenchmarkMeasurement {\n name: string;\n category: string;\n start: Date;\n end: Date;\n elapsed: number;\n memory: number;\n}\n\nexport interface BenchmarkEnableOnCallable {\n (): Promise<boolean>;\n}\n\nexport interface BenchmarkOutputCallableParams {\n benchmark: Benchmark;\n stop: () => \"stop\";\n}\nexport interface BenchmarkOutputCallable {\n (params: BenchmarkOutputCallableParams): Promise<\"stop\" | undefined | null | void>;\n}\nexport interface BenchmarkMeasureOptions {\n name: string;\n category: string;\n}\nexport interface Benchmark {\n elapsed: number;\n runs: BenchmarkRuns;\n measurements: BenchmarkMeasurement[];\n output: () => Promise<void>;\n onOutput: (cb: BenchmarkOutputCallable) => void;\n enableOn: (cb: BenchmarkEnableOnCallable) => void;\n measure: <T = any>(\n options: BenchmarkMeasureOptions | string,\n cb: () => Promise<T>\n ) => Promise<T>;\n enable: () => void;\n disable: () => void;\n}\n\n/**\n * The main context which is constructed on every request.\n * All other contexts should extend or augment this one.\n */\nexport interface Context {\n plugins: PluginsContainer;\n readonly WEBINY_VERSION: string;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n hasResult: () => boolean;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n *\n * @private\n */\n _result?: unknown;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n setResult: (value: unknown) => void;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n getResult: () => void;\n /**\n * Wait for property to be defined on the object and then execute the callable.\n * In case of multiple objects defined, wait for all of them.\n */\n waitFor: <T extends Context = Context>(\n obj: string[] | string,\n cb: (context: T) => void\n ) => void;\n\n benchmark: Benchmark;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { ICompressor } from \"@webiny/utils/compression/Compressor\";\n\nexport type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\n\nexport type BenchmarkRuns = GenericRecord<string, number>;\n\nexport interface BenchmarkMeasurement {\n name: string;\n category: string;\n start: Date;\n end: Date;\n elapsed: number;\n memory: number;\n}\n\nexport interface BenchmarkEnableOnCallable {\n (): Promise<boolean>;\n}\n\nexport interface BenchmarkOutputCallableParams {\n benchmark: Benchmark;\n stop: () => \"stop\";\n}\nexport interface BenchmarkOutputCallable {\n (params: BenchmarkOutputCallableParams): Promise<\"stop\" | undefined | null | void>;\n}\nexport interface BenchmarkMeasureOptions {\n name: string;\n category: string;\n}\nexport interface Benchmark {\n elapsed: number;\n runs: BenchmarkRuns;\n measurements: BenchmarkMeasurement[];\n output: () => Promise<void>;\n onOutput: (cb: BenchmarkOutputCallable) => void;\n enableOn: (cb: BenchmarkEnableOnCallable) => void;\n measure: <T = any>(\n options: BenchmarkMeasureOptions | string,\n cb: () => Promise<T>\n ) => Promise<T>;\n enable: () => void;\n disable: () => void;\n}\n\n/**\n * The main context which is constructed on every request.\n * All other contexts should extend or augment this one.\n */\nexport interface Context {\n plugins: PluginsContainer;\n readonly WEBINY_VERSION: string;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n hasResult: () => boolean;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n *\n * @private\n */\n _result?: unknown;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n setResult: (value: unknown) => void;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n getResult: () => void;\n /**\n * Wait for property to be defined on the object and then execute the callable.\n * In case of multiple objects defined, wait for all of them.\n */\n waitFor: <T extends Context = Context>(\n obj: string[] | string,\n cb: (context: T) => void\n ) => void;\n /**\n * Benchmark instance to help determine possible bugs and slow code.\n */\n benchmark: Benchmark;\n /**\n * Compressor instance to compress and decompress the data.\n */\n compressor: ICompressor;\n}\n"],"mappings":"","ignoreList":[]}