@webiny/api 5.37.0-beta.0 → 5.37.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/Benchmark.js CHANGED
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.Benchmark = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var BenchmarkState;
10
- (function (BenchmarkState) {
9
+ var BenchmarkState = /*#__PURE__*/function (BenchmarkState) {
11
10
  BenchmarkState["DISABLED"] = "disabled";
12
11
  BenchmarkState["ENABLED"] = "enabled";
13
12
  BenchmarkState["UNDETERMINED"] = "undetermined";
14
- })(BenchmarkState || (BenchmarkState = {}));
13
+ return BenchmarkState;
14
+ }(BenchmarkState || {});
15
15
  const createDefaultOutputCallable = () => {
16
16
  return async ({
17
17
  benchmark
package/Benchmark.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["BenchmarkState","createDefaultOutputCallable","benchmark","console","log","elapsed","measurements","Benchmark","UNDETERMINED","totalElapsed","enableOn","cb","enableOnCallables","push","onOutput","onOutputCallables","enable","setState","ENABLED","disable","DISABLED","output","outputDone","length","callables","reverse","result","stop","measure","options","enabled","getIsEnabled","measurement","startMeasurement","isAlreadyRunning","getIsAlreadyRunning","startRunning","measurementEnded","stopMeasurement","addRun","addElapsed","endRunning","state","name","category","runs","start","Date","memoryStart","process","memoryUsage","heapUsed","end","memoryEnd","getTime","memory"],"sources":["Benchmark.ts"],"sourcesContent":["import {\n Benchmark as BenchmarkInterface,\n BenchmarkEnableOnCallable,\n BenchmarkMeasurement,\n BenchmarkMeasureOptions,\n BenchmarkOutputCallable,\n BenchmarkRuns\n} from \"~/types\";\n\nenum BenchmarkState {\n DISABLED = \"disabled\",\n ENABLED = \"enabled\",\n UNDETERMINED = \"undetermined\"\n}\n\ninterface BenchmarkMeasurementStart\n extends Pick<BenchmarkMeasurement, \"name\" | \"category\" | \"start\"> {\n memoryStart: number;\n}\n\nconst createDefaultOutputCallable = (): BenchmarkOutputCallable => {\n return async ({ benchmark }) => {\n console.log(`Benchmark total time elapsed: ${benchmark.elapsed}ms`);\n console.log(\"Benchmark measurements:\");\n console.log(benchmark.measurements);\n };\n};\n\nexport class Benchmark implements BenchmarkInterface {\n public readonly measurements: BenchmarkMeasurement[] = [];\n\n private outputDone = false;\n private isAlreadyRunning = false;\n private totalElapsed = 0;\n public readonly runs: BenchmarkRuns = {};\n private readonly enableOnCallables: BenchmarkEnableOnCallable[] = [];\n private readonly onOutputCallables: BenchmarkOutputCallable[] = [];\n private state: BenchmarkState = BenchmarkState.UNDETERMINED;\n\n public get elapsed(): number {\n return this.totalElapsed;\n }\n\n public enableOn(cb: BenchmarkEnableOnCallable): void {\n this.enableOnCallables.push(cb);\n }\n\n public onOutput(cb: BenchmarkOutputCallable): void {\n this.onOutputCallables.push(cb);\n }\n\n public enable(): void {\n this.setState(BenchmarkState.ENABLED);\n }\n\n public disable(): void {\n this.setState(BenchmarkState.DISABLED);\n }\n\n /**\n * When running the output, we need to reverse the callables array, so that the last one added is the first one executed.\n *\n * The last one is our built-in console.log output.\n */\n public async output(): Promise<void> {\n /**\n * No point in outputting more than once or if no measurements were made.\n */\n if (this.outputDone || this.measurements.length === 0) {\n return;\n }\n const callables = [...this.onOutputCallables].reverse();\n callables.push(createDefaultOutputCallable());\n for (const cb of callables) {\n const result = await cb({\n benchmark: this,\n stop: () => \"stop\"\n });\n if (result === \"stop\") {\n return;\n }\n }\n this.outputDone = true;\n }\n\n public async measure<T = any>(\n options: BenchmarkMeasureOptions | string,\n cb: () => Promise<T>\n ): Promise<T> {\n const enabled = await this.getIsEnabled();\n if (!enabled) {\n return cb();\n }\n const measurement = this.startMeasurement(options);\n const isAlreadyRunning = this.getIsAlreadyRunning();\n this.startRunning();\n try {\n return await cb();\n } finally {\n const measurementEnded = this.stopMeasurement(measurement);\n this.measurements.push(measurementEnded);\n this.addRun(measurementEnded);\n /**\n * Only add to total time if this run is not a child of another run.\n * And then end running.\n */\n if (!isAlreadyRunning) {\n this.addElapsed(measurementEnded);\n this.endRunning();\n }\n }\n }\n\n private getIsAlreadyRunning(): boolean {\n return this.isAlreadyRunning;\n }\n private startRunning(): void {\n this.isAlreadyRunning = true;\n }\n private endRunning(): void {\n this.isAlreadyRunning = false;\n }\n\n private async getIsEnabled(): Promise<boolean> {\n if (this.state === BenchmarkState.ENABLED) {\n return true;\n } else if (this.state === BenchmarkState.DISABLED) {\n return false;\n }\n\n for (const cb of this.enableOnCallables) {\n const result = await cb();\n if (result) {\n this.enable();\n return true;\n }\n }\n this.disable();\n return false;\n }\n\n private addElapsed(measurement: Pick<BenchmarkMeasurement, \"elapsed\">): void {\n this.totalElapsed = this.totalElapsed + measurement.elapsed;\n }\n\n private addRun(measurement: Pick<BenchmarkMeasurement, \"name\" | \"category\">): void {\n const name = `${measurement.category}#${measurement.name}`;\n if (!this.runs[name]) {\n this.runs[name] = 0;\n }\n this.runs[name]++;\n }\n\n private setState(state: BenchmarkState): void {\n this.state = state;\n }\n\n private startMeasurement(options: BenchmarkMeasureOptions | string): BenchmarkMeasurementStart {\n const name = typeof options === \"string\" ? options : options.name;\n const category = typeof options === \"string\" ? \"webiny\" : options.category;\n return {\n name,\n category,\n start: new Date(),\n memoryStart: process.memoryUsage().heapUsed\n };\n }\n\n private stopMeasurement(measurement: BenchmarkMeasurementStart): BenchmarkMeasurement {\n const end = new Date();\n const memoryEnd = process.memoryUsage().heapUsed;\n const elapsed = end.getTime() - measurement.start.getTime();\n return {\n name: measurement.name,\n category: measurement.category,\n start: measurement.start,\n end,\n elapsed,\n memory: memoryEnd - measurement.memoryStart\n };\n }\n}\n"],"mappings":";;;;;;;;IASKA,cAAc;AAAA,WAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;AAAA,GAAdA,cAAc,KAAdA,cAAc;AAWnB,MAAMC,2BAA2B,GAAG,MAA+B;EAC/D,O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IACtB,MAAMM,SAAS,GAAGJ,OAAO,CAACC,WAAW,EAAE,CAACC,QAAQ;IAChD,MAAM9C,OAAO,GAAG+C,GAAG,CAACE,OAAO,EAAE,GAAGtB,WAAW,CAACc,KAAK,CAACQ,OAAO,EAAE;IAC3D,OAAO;MACHX,IAAI,EAAEX,WAAW,CAACW,IAAI;MACtBC,QAAQ,EAAEZ,WAAW,CAACY,QAAQ;MAC9BE,KAAK,EAAEd,WAAW,CAACc,KAAK;MACxBM,GAAG;MACH/C,OAAO;MACPkD,MAAM,EAAEF,SAAS,GAAGrB,WAAW,CAACgB;IACpC,CAAC;EACL;AACJ;AAAC"}
1
+ {"version":3,"names":["BenchmarkState","createDefaultOutputCallable","benchmark","console","log","elapsed","measurements","Benchmark","constructor","_defineProperty2","default","UNDETERMINED","totalElapsed","enableOn","cb","enableOnCallables","push","onOutput","onOutputCallables","enable","setState","ENABLED","disable","DISABLED","output","outputDone","length","callables","reverse","result","stop","measure","options","enabled","getIsEnabled","measurement","startMeasurement","isAlreadyRunning","getIsAlreadyRunning","startRunning","measurementEnded","stopMeasurement","addRun","addElapsed","endRunning","state","name","category","runs","start","Date","memoryStart","process","memoryUsage","heapUsed","end","memoryEnd","getTime","memory","exports"],"sources":["Benchmark.ts"],"sourcesContent":["import {\n Benchmark as BenchmarkInterface,\n BenchmarkEnableOnCallable,\n BenchmarkMeasurement,\n BenchmarkMeasureOptions,\n BenchmarkOutputCallable,\n BenchmarkRuns\n} from \"~/types\";\n\nenum BenchmarkState {\n DISABLED = \"disabled\",\n ENABLED = \"enabled\",\n UNDETERMINED = \"undetermined\"\n}\n\ninterface BenchmarkMeasurementStart\n extends Pick<BenchmarkMeasurement, \"name\" | \"category\" | \"start\"> {\n memoryStart: number;\n}\n\nconst createDefaultOutputCallable = (): BenchmarkOutputCallable => {\n return async ({ benchmark }) => {\n console.log(`Benchmark total time elapsed: ${benchmark.elapsed}ms`);\n console.log(\"Benchmark measurements:\");\n console.log(benchmark.measurements);\n };\n};\n\nexport class Benchmark implements BenchmarkInterface {\n public readonly measurements: BenchmarkMeasurement[] = [];\n\n private outputDone = false;\n private isAlreadyRunning = false;\n private totalElapsed = 0;\n public readonly runs: BenchmarkRuns = {};\n private readonly enableOnCallables: BenchmarkEnableOnCallable[] = [];\n private readonly onOutputCallables: BenchmarkOutputCallable[] = [];\n private state: BenchmarkState = BenchmarkState.UNDETERMINED;\n\n public get elapsed(): number {\n return this.totalElapsed;\n }\n\n public enableOn(cb: BenchmarkEnableOnCallable): void {\n this.enableOnCallables.push(cb);\n }\n\n public onOutput(cb: BenchmarkOutputCallable): void {\n this.onOutputCallables.push(cb);\n }\n\n public enable(): void {\n this.setState(BenchmarkState.ENABLED);\n }\n\n public disable(): void {\n this.setState(BenchmarkState.DISABLED);\n }\n\n /**\n * When running the output, we need to reverse the callables array, so that the last one added is the first one executed.\n *\n * The last one is our built-in console.log output.\n */\n public async output(): Promise<void> {\n /**\n * No point in outputting more than once or if no measurements were made.\n */\n if (this.outputDone || this.measurements.length === 0) {\n return;\n }\n const callables = [...this.onOutputCallables].reverse();\n callables.push(createDefaultOutputCallable());\n for (const cb of callables) {\n const result = await cb({\n benchmark: this,\n stop: () => \"stop\"\n });\n if (result === \"stop\") {\n return;\n }\n }\n this.outputDone = true;\n }\n\n public async measure<T = any>(\n options: BenchmarkMeasureOptions | string,\n cb: () => Promise<T>\n ): Promise<T> {\n const enabled = await this.getIsEnabled();\n if (!enabled) {\n return cb();\n }\n const measurement = this.startMeasurement(options);\n const isAlreadyRunning = this.getIsAlreadyRunning();\n this.startRunning();\n try {\n return await cb();\n } finally {\n const measurementEnded = this.stopMeasurement(measurement);\n this.measurements.push(measurementEnded);\n this.addRun(measurementEnded);\n /**\n * Only add to total time if this run is not a child of another run.\n * And then end running.\n */\n if (!isAlreadyRunning) {\n this.addElapsed(measurementEnded);\n this.endRunning();\n }\n }\n }\n\n private getIsAlreadyRunning(): boolean {\n return this.isAlreadyRunning;\n }\n private startRunning(): void {\n this.isAlreadyRunning = true;\n }\n private endRunning(): void {\n this.isAlreadyRunning = false;\n }\n\n private async getIsEnabled(): Promise<boolean> {\n if (this.state === BenchmarkState.ENABLED) {\n return true;\n } else if (this.state === BenchmarkState.DISABLED) {\n return false;\n }\n\n for (const cb of this.enableOnCallables) {\n const result = await cb();\n if (result) {\n this.enable();\n return true;\n }\n }\n this.disable();\n return false;\n }\n\n private addElapsed(measurement: Pick<BenchmarkMeasurement, \"elapsed\">): void {\n this.totalElapsed = this.totalElapsed + measurement.elapsed;\n }\n\n private addRun(measurement: Pick<BenchmarkMeasurement, \"name\" | \"category\">): void {\n const name = `${measurement.category}#${measurement.name}`;\n if (!this.runs[name]) {\n this.runs[name] = 0;\n }\n this.runs[name]++;\n }\n\n private setState(state: BenchmarkState): void {\n this.state = state;\n }\n\n private startMeasurement(options: BenchmarkMeasureOptions | string): BenchmarkMeasurementStart {\n const name = typeof options === \"string\" ? options : options.name;\n const category = typeof options === \"string\" ? \"webiny\" : options.category;\n return {\n name,\n category,\n start: new Date(),\n memoryStart: process.memoryUsage().heapUsed\n };\n }\n\n private stopMeasurement(measurement: BenchmarkMeasurementStart): BenchmarkMeasurement {\n const end = new Date();\n const memoryEnd = process.memoryUsage().heapUsed;\n const elapsed = end.getTime() - measurement.start.getTime();\n return {\n name: measurement.name,\n category: measurement.category,\n start: measurement.start,\n end,\n elapsed,\n memory: memoryEnd - measurement.memoryStart\n };\n }\n}\n"],"mappings":";;;;;;;;IASKA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA,EAAdA,cAAc;AAWnB,MAAMC,2BAA2B,GAAGA,CAAA,KAA+B;EAC/D,OAAO,OAAO;IAAEC;EAAU,CAAC,KAAK;IAC5BC,OAAO,CAACC,GAAG,CAAE,iCAAgCF,SAAS,CAACG,OAAQ,IAAG,CAAC;IACnEF,OAAO,CAACC,GAAG,CAAC,yBAAyB,CAAC;IACtCD,OAAO,CA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,QAAQ;MACRE,KAAK,EAAE,IAAIC,IAAI,CAAC,CAAC;MACjBC,WAAW,EAAEC,OAAO,CAACC,WAAW,CAAC,CAAC,CAACC;IACvC,CAAC;EACL;EAEQb,eAAeA,CAACN,WAAsC,EAAwB;IAClF,MAAMoB,GAAG,GAAG,IAAIL,IAAI,CAAC,CAAC;IACtB,MAAMM,SAAS,GAAGJ,OAAO,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ;IAChD,MAAMjD,OAAO,GAAGkD,GAAG,CAACE,OAAO,CAAC,CAAC,GAAGtB,WAAW,CAACc,KAAK,CAACQ,OAAO,CAAC,CAAC;IAC3D,OAAO;MACHX,IAAI,EAAEX,WAAW,CAACW,IAAI;MACtBC,QAAQ,EAAEZ,WAAW,CAACY,QAAQ;MAC9BE,KAAK,EAAEd,WAAW,CAACc,KAAK;MACxBM,GAAG;MACHlD,OAAO;MACPqD,MAAM,EAAEF,SAAS,GAAGrB,WAAW,CAACgB;IACpC,CAAC;EACL;AACJ;AAACQ,OAAA,CAAApD,SAAA,GAAAA,SAAA"}
package/Context.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["Context","constructor","params","plugins","WEBINY_VERSION","PluginsContainer","benchmark","Benchmark","register","BenchmarkPlugin","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","waiters","includes","filter","t","length","get","configurable","push"],"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;\n WEBINY_VERSION: string;\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 = new PluginsContainer(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 any);\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-ignore\n cb\n });\n }\n}\n"],"mappings":";;;;;;;;AACA;AAEA;AACA;AAYO,MAAMA,OAAO,CAA6B;EAStCC,WAAW,CAACC,MAAqB,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA,+CAFL,EAAE;IAGnC,MAAM;MAAEC,OAAO;MAAEC;IAAe,CAAC,GAAGF,MAAM;IAC1C,IAAI,CAACC,OAAO,GAAG,IAAIE,yBAAgB,CAACF,OAAO,IAAI,EAAE,CAAC;IAClD,IAAI,CAACC,cAAc,GAAGA,cAAc;IACpC;AACR;AACA;AACA;IACQ,IAAI,CAACE,SAAS,GAAG,IAAIC,oBAAS,EAAE;IAChC,IAAI,CAACJ,OAAO,CAACK,QAAQ,CAAC,IAAIC,gCAAe,CAAC,IAAI,CAACH,SAAS,CAAC,CAAC;EAC9D;EAEOI,SAAS,GAAQ;IACpB,OAAO,IAAI,CAACC,OAAO;EACvB;EAEOC,SAAS,GAAY;IACxB,OAAO,CAAC,CAAC,IAAI,CAACD,OAAO;EACzB;EAEOE,SAAS,CAACC,KAAU,EAAQ;IAC/B,IAAI,CAACH,OAAO,GAAGG,KAAK;EACxB;EAEOC,OAAO,CACVC,GAAsB,EACtBC,EAAwB,EACpB;IACJ,MAAMC,cAAc,GAAGC,KAAK,CAACC,OAAO,CAACJ,GAAG,CAAC,GAAGA,GAAG,GAAG,CAACA,GAAG,CAAC;IACvD,MAAMK,OAAiB,GAAG,EAAE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CAAC,EAAE;MACtBhB,EAAE,CAAC,IAAI,CAAQ;MACf;IACJ;IACA;AACR;AACA;IACQ,IAAI,CAACY,OAAO,CAACO,IAAI,CAAC;MACdf,OAAO;MACP;AACZ;AACA;AACA;MACY;MACAJ;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
1
+ {"version":3,"names":["_plugins","require","_Benchmark","_BenchmarkPlugin","Context","constructor","params","_defineProperty2","default","plugins","WEBINY_VERSION","PluginsContainer","benchmark","Benchmark","register","BenchmarkPlugin","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","waiters","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;\n WEBINY_VERSION: string;\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 = new PluginsContainer(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 any);\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-ignore\n cb\n });\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAA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N;AACJ;AAACoB,OAAA,CAAAvC,OAAA,GAAAA,OAAA"}
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/Context\";\nexport * from \"~/plugins/ContextPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_Context","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_ContextPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"~/Context\";\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,cAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,cAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,cAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,cAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api",
3
- "version": "5.37.0-beta.0",
3
+ "version": "5.37.0-beta.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,16 +12,16 @@
12
12
  ],
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@babel/runtime": "7.20.13",
16
- "@webiny/plugins": "5.37.0-beta.0"
15
+ "@babel/runtime": "7.22.6",
16
+ "@webiny/plugins": "5.37.0-beta.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@babel/cli": "7.20.7",
20
- "@babel/core": "7.20.12",
21
- "@babel/preset-env": "7.20.2",
22
- "@babel/preset-typescript": "7.18.6",
23
- "@webiny/cli": "5.37.0-beta.0",
24
- "@webiny/project-utils": "5.37.0-beta.0",
19
+ "@babel/cli": "7.22.6",
20
+ "@babel/core": "7.22.8",
21
+ "@babel/preset-env": "7.22.7",
22
+ "@babel/preset-typescript": "7.22.5",
23
+ "@webiny/cli": "5.37.0-beta.2",
24
+ "@webiny/project-utils": "5.37.0-beta.2",
25
25
  "rimraf": "3.0.2",
26
26
  "ttypescript": "1.5.15",
27
27
  "typescript": "4.7.4"
@@ -34,5 +34,5 @@
34
34
  "build": "yarn webiny run build",
35
35
  "watch": "yarn webiny run watch"
36
36
  },
37
- "gitHead": "7bb6232942f0414e22a4549113dd112bb92e52c5"
37
+ "gitHead": "8d3f4ba102f9f73b0a17455fc401a15aea68ce63"
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"names":["BenchmarkPlugin","Plugin","constructor","benchmark","enable","disable","measure","name","cb"],"sources":["BenchmarkPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Benchmark } from \"~/types\";\n\n/**\n * This plugin should be initialized only once per context, hence the name of the plugin.\n */\nexport class BenchmarkPlugin extends Plugin {\n public static override readonly type: string = \"context.benchmark\";\n public override name = \"context.benchmark\";\n public readonly benchmark: Benchmark;\n\n public constructor(benchmark: Benchmark) {\n super();\n this.benchmark = benchmark;\n }\n\n public enable(): void {\n this.benchmark.enable();\n }\n\n public disable(): void {\n this.benchmark.disable();\n }\n\n public async measure<T = any>(name: string, cb: () => Promise<T>): Promise<T> {\n return this.benchmark.measure<T>(name, cb);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAGA;AACA;AACA;AACO,MAAMA,eAAe,SAASC,eAAM,CAAC;EAKjCC,WAAW,CAACC,SAAoB,EAAE;IACrC,KAAK,EAAE;IAAC,4CAJW,mBAAmB;IAAA;IAKtC,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC9B;EAEOC,MAAM,GAAS;IAClB,IAAI,CAACD,SAAS,CAACC,MAAM,EAAE;EAC3B;EAEOC,OAAO,GAAS;IACnB,IAAI,CAACF,SAAS,CAACE,OAAO,EAAE;EAC5B;EAEA,MAAaC,OAAO,CAAUC,IAAY,EAAEC,EAAoB,EAAc;IAC1E,OAAO,IAAI,CAACL,SAAS,CAACG,OAAO,CAAIC,IAAI,EAAEC,EAAE,CAAC;EAC9C;AACJ;AAAC;AAAA,8BArBYR,eAAe,UACuB,mBAAmB"}
1
+ {"version":3,"names":["_plugins","require","BenchmarkPlugin","Plugin","constructor","benchmark","_defineProperty2","default","enable","disable","measure","name","cb","exports"],"sources":["BenchmarkPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Benchmark } from \"~/types\";\n\n/**\n * This plugin should be initialized only once per context, hence the name of the plugin.\n */\nexport class BenchmarkPlugin extends Plugin {\n public static override readonly type: string = \"context.benchmark\";\n public override name = \"context.benchmark\";\n public readonly benchmark: Benchmark;\n\n public constructor(benchmark: Benchmark) {\n super();\n this.benchmark = benchmark;\n }\n\n public enable(): void {\n this.benchmark.enable();\n }\n\n public disable(): void {\n this.benchmark.disable();\n }\n\n public async measure<T = any>(name: string, cb: () => Promise<T>): Promise<T> {\n return this.benchmark.measure<T>(name, cb);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACO,MAAMC,eAAe,SAASC,eAAM,CAAC;EAKjCC,WAAWA,CAACC,SAAoB,EAAE;IACrC,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,gBAJW,mBAAmB;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAKtC,IAAI,CAACF,SAAS,GAAGA,SAAS;EAC9B;EAEOG,MAAMA,CAAA,EAAS;IAClB,IAAI,CAACH,SAAS,CAACG,MAAM,CAAC,CAAC;EAC3B;EAEOC,OAAOA,CAAA,EAAS;IACnB,IAAI,CAACJ,SAAS,CAACI,OAAO,CAAC,CAAC;EAC5B;EAEA,MAAaC,OAAOA,CAAUC,IAAY,EAAEC,EAAoB,EAAc;IAC1E,OAAO,IAAI,CAACP,SAAS,CAACK,OAAO,CAAIC,IAAI,EAAEC,EAAE,CAAC;EAC9C;AACJ;AAACC,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EArBYL,eAAe,UACuB,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","Plugin","constructor","callable","_callable","apply","context","Error","createContextPlugin"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface ContextPluginCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class ContextPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"context\";\n private readonly _callable: ContextPluginCallable<T>;\n\n constructor(callable: ContextPluginCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n): ContextPlugin<T> => {\n return new ContextPlugin<T>(callable);\n};\n"],"mappings":";;;;;;;;AAAA;AAOO,MAAMA,aAAa,SAAsCC,eAAM,CAAC;EAInEC,WAAW,CAACC,QAAkC,EAAE;IAC5C,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAK,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACN,uIAAsI,CAC1I;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAAC;AAAA,8BAlBYN,aAAa,UACyB,SAAS;AAmBrD,MAAMQ,mBAAmB,GAC5BL,QAAkC,IACf;EACnB,OAAO,IAAIH,aAAa,CAAIG,QAAQ,CAAC;AACzC,CAAC;AAAC"}
1
+ {"version":3,"names":["_plugins","require","ContextPlugin","Plugin","constructor","callable","_defineProperty2","default","_callable","apply","context","Error","exports","createContextPlugin"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface ContextPluginCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class ContextPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"context\";\n private readonly _callable: ContextPluginCallable<T>;\n\n constructor(callable: ContextPluginCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n): ContextPlugin<T> => {\n return new ContextPlugin<T>(callable);\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,aAAa,SAAsCC,eAAM,CAAC;EAInEC,WAAWA,CAACC,QAAkC,EAAE;IAC5C,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACC,SAAS,GAAGH,QAAQ;EAC7B;EAEA,MAAaI,KAAKA,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACN,uIACL,CAAC;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAACE,OAAA,CAAAV,aAAA,GAAAA,aAAA;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EAlBYL,aAAa,UACyB,SAAS;AAmBrD,MAAMW,mBAAmB,GAC5BR,QAAkC,IACf;EACnB,OAAO,IAAIH,aAAa,CAAIG,QAAQ,CAAC;AACzC,CAAC;AAACO,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}