@webiny/api 5.41.4 → 5.42.0-beta.1
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.map +1 -1
- package/Context.js.map +1 -1
- package/ServiceDiscovery.js.map +1 -1
- package/package.json +7 -12
- package/plugins/ContextPlugin.js.map +1 -1
- package/types.d.ts +2 -3
- package/types.js.map +1 -1
package/Benchmark.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BenchmarkState","createDefaultOutputCallable","benchmark","console","log","elapsed","measurements","Benchmark","outputDone","isAlreadyRunning","totalElapsed","runs","enableOnCallables","onOutputCallables","state","UNDETERMINED","enableOn","cb","push","onOutput","enable","setState","ENABLED","disable","DISABLED","output","length","callables","reverse","result","stop","measure","options","enabled","getIsEnabled","measurement","startMeasurement","getIsAlreadyRunning","startRunning","measurementEnded","stopMeasurement","addRun","addElapsed","endRunning","name","category","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,CAACC,GAAG,CAACF,SAAS,CAACI,YAAY,CAAC;EACvC,CAAC;AACL,CAAC;AAEM,MAAMC,SAAS,CAA+B;EACjCD,YAAY,GAA2B,EAAE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CAAC,CAACC,QAAQ;IAChD,MAAM9C,OAAO,GAAG+C,GAAG,CAACE,OAAO,CAAC,CAAC,GAAGnB,WAAW,CAACW,KAAK,CAACQ,OAAO,CAAC,CAAC;IAC3D,OAAO;MACHV,IAAI,EAAET,WAAW,CAACS,IAAI;MACtBC,QAAQ,EAAEV,WAAW,CAACU,QAAQ;MAC9BC,KAAK,EAAEX,WAAW,CAACW,KAAK;MACxBM,GAAG;MACH/C,OAAO;MACPkD,MAAM,EAAEF,SAAS,GAAGlB,WAAW,CAACa;IACpC,CAAC;EACL;AACJ;AAACQ,OAAA,CAAAjD,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BenchmarkState","createDefaultOutputCallable","benchmark","console","log","elapsed","measurements","Benchmark","outputDone","isAlreadyRunning","totalElapsed","runs","enableOnCallables","onOutputCallables","state","UNDETERMINED","enableOn","cb","push","onOutput","enable","setState","ENABLED","disable","DISABLED","output","length","callables","reverse","result","stop","measure","options","enabled","getIsEnabled","measurement","startMeasurement","getIsAlreadyRunning","startRunning","measurementEnded","stopMeasurement","addRun","addElapsed","endRunning","name","category","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,CAAC,iCAAiCF,SAAS,CAACG,OAAO,IAAI,CAAC;IACnEF,OAAO,CAACC,GAAG,CAAC,yBAAyB,CAAC;IACtCD,OAAO,CAACC,GA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EAAwB;IAClF,MAAMiB,GAAG,GAAG,IAAIL,IAAI,CAAC,CAAC;IACtB,MAAMM,SAAS,GAAGJ,OAAO,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ;IAChD,MAAM9C,OAAO,GAAG+C,GAAG,CAACE,OAAO,CAAC,CAAC,GAAGnB,WAAW,CAACW,KAAK,CAACQ,OAAO,CAAC,CAAC;IAC3D,OAAO;MACHV,IAAI,EAAET,WAAW,CAACS,IAAI;MACtBC,QAAQ,EAAEV,WAAW,CAACU,QAAQ;MAC9BC,KAAK,EAAEX,WAAW,CAACW,KAAK;MACxBM,GAAG;MACH/C,OAAO;MACPkD,MAAM,EAAEF,SAAS,GAAGlB,WAAW,CAACa;IACpC,CAAC;EACL;AACJ;AAACQ,OAAA,CAAAjD,SAAA,GAAAA,SAAA","ignoreList":[]}
|
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,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAYA,MAAMG,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;EAO5BC,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,CAACR,OAAO,CAACS,QAAQ,CAAC,IAAIC,gCAAe,CAAC,IAAI,CAACH,SAAS,CAAC,CAAC;EAC9D;EAEOI,SAASA,CAAA,EAAQ;IACpB,OAAO,IAAI,CAACC,OAAO;EACvB;EAEOC,SAASA,CAAA,EAAY;IACxB,OAAO,CAAC,CAAC,IAAI,CAACD,OAAO;EACzB;EAEOE,SAASA,CAACC,KAAU,EAAQ;IAC/B,IAAI,CAACH,OAAO,GAAGG,KAAK;EACxB;EAEOC,OAAOA,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;IAC5B;AACR;AACA;IACQ,KAAK,MAAMC,GAAG,IAAIJ,cAAc,EAAE;MAC9B,MAAMK,MAAM,GAAGL,cAAc,CAACI,GAAG,CAAe;MAChD;AACZ;AACA;AACA;MACY,IAAI,IAAI,CAACC,MAAM,CAAC,EAAE;QACd;MACJ,CAAC,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;QACnC;MACJ;MACA;AACZ;AACA;AACA;MACYC,MAAM,CAACC,cAAc,CAAC,IAAI,EAAEF,MAAM,EAAE;QAChC;AAChB;AACA;AACA;AACA;QACgBG,GAAG,EAAGZ,KAAU,IAAK;UACjB,MAAMa,YAAY,
|
|
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,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAYA,MAAMG,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;EAO5BC,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,cAA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YACJ;YACA;AACxB;AACA;YACwBK,MAAM,CAACP,OAAO,GAAGO,MAAM,CAACP,OAAO,CAACS,MAAM,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,CAACf,OAAO,CAACiC,IAAI,CAAC;MACdd,OAAO;MACP;AACZ;AACA;AACA;MACY;MACAJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACmB,OAAA,CAAAnC,OAAA,GAAAA,OAAA","ignoreList":[]}
|
package/ServiceDiscovery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clientDynamodb","require","ServiceManifestLoader","manifest","undefined","load","manifests","loadManifests","reduce","acc","name","setDocumentClient","client","getDocumentClient","Items","send","QueryCommand","TableName","String","process","env","DB_TABLE","IndexName","KeyConditionExpression","ExpressionAttributeValues","S","Array","isArray","map","item","unmarshall","data","serviceManifestLoader","ServiceDiscovery","exports"],"sources":["ServiceDiscovery.ts"],"sourcesContent":["import {\n getDocumentClient,\n DynamoDBDocument,\n QueryCommand,\n unmarshall\n} from \"@webiny/aws-sdk/client-dynamodb\";\nimport { GenericRecord } from \"~/types\";\n\ninterface ServiceManifest {\n name: string;\n manifest: Manifest;\n}\n\ntype Manifest = GenericRecord<string>;\n\nclass ServiceManifestLoader {\n private client: DynamoDBDocument | undefined;\n private manifest: Manifest | undefined = undefined;\n\n async load() {\n if (this.manifest) {\n return this.manifest;\n }\n\n const manifests = await this.loadManifests();\n\n if (!manifests) {\n return undefined;\n }\n\n /**\n * Service manifests are already merged by unique names in the database, so we only need to construct\n * a final object containing all manifests by name.\n */\n this.manifest = manifests.reduce((acc, manifest) => {\n return { ...acc, [manifest.name]: manifest.manifest };\n }, {});\n\n return this.manifest;\n }\n\n setDocumentClient(client: DynamoDBDocument) {\n this.client = client;\n }\n\n private async loadManifests(): Promise<ServiceManifest[] | undefined> {\n const client = this.client || getDocumentClient();\n const { Items } = await client.send(\n new QueryCommand({\n TableName: String(process.env.DB_TABLE),\n IndexName: \"GSI1\",\n KeyConditionExpression: \"GSI1_PK = :GSI1_PK AND GSI1_SK > :GSI1_SK\",\n ExpressionAttributeValues: {\n \":GSI1_PK\": { S: `SERVICE_MANIFESTS` },\n \":GSI1_SK\": { S: \" \" }\n }\n })\n );\n\n if (!Array.isArray(Items)) {\n return undefined;\n }\n\n return Items.map(item => unmarshall(item).data);\n }\n}\n\nconst serviceManifestLoader = new ServiceManifestLoader();\n\nexport class ServiceDiscovery {\n static setDocumentClient(client: DynamoDBDocument): void {\n serviceManifestLoader.setDocumentClient(client);\n }\n\n static async load() {\n return serviceManifestLoader.load();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAeA,MAAMC,qBAAqB,CAAC;EAEhBC,QAAQ,GAAyBC,SAAS;EAElD,MAAMC,IAAIA,CAAA,EAAG;IACT,IAAI,IAAI,CAACF,QAAQ,EAAE;MACf,OAAO,IAAI,CAACA,QAAQ;IACxB;IAEA,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACC,aAAa,CAAC,CAAC;IAE5C,IAAI,CAACD,SAAS,EAAE;MACZ,OAAOF,SAAS;IACpB;;IAEA;AACR;AACA;AACA;IACQ,IAAI,CAACD,QAAQ,GAAGG,SAAS,CAACE,MAAM,CAAC,CAACC,GAAG,EAAEN,QAAQ,KAAK;MAChD,OAAO;QAAE,GAAGM,GAAG;QAAE,CAACN,QAAQ,CAACO,IAAI,GAAGP,QAAQ,CAACA;MAAS,CAAC;IACzD,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,OAAO,IAAI,CAACA,QAAQ;EACxB;EAEAQ,iBAAiBA,CAACC,MAAwB,EAAE;IACxC,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAcL,aAAaA,CAAA,EAA2C;IAClE,MAAMK,MAAM,GAAG,IAAI,CAACA,MAAM,IAAI,IAAAC,iCAAiB,EAAC,CAAC;IACjD,MAAM;MAAEC;IAAM,CAAC,GAAG,MAAMF,MAAM,CAACG,IAAI,CAC/B,IAAIC,4BAAY,CAAC;MACbC,SAAS,EAAEC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,QAAQ,CAAC;MACvCC,SAAS,EAAE,MAAM;MACjBC,sBAAsB,EAAE,2CAA2C;MACnEC,yBAAyB,EAAE;QACvB,UAAU,EAAE;UAAEC,CAAC,
|
|
1
|
+
{"version":3,"names":["_clientDynamodb","require","ServiceManifestLoader","manifest","undefined","load","manifests","loadManifests","reduce","acc","name","setDocumentClient","client","getDocumentClient","Items","send","QueryCommand","TableName","String","process","env","DB_TABLE","IndexName","KeyConditionExpression","ExpressionAttributeValues","S","Array","isArray","map","item","unmarshall","data","serviceManifestLoader","ServiceDiscovery","exports"],"sources":["ServiceDiscovery.ts"],"sourcesContent":["import {\n getDocumentClient,\n DynamoDBDocument,\n QueryCommand,\n unmarshall\n} from \"@webiny/aws-sdk/client-dynamodb\";\nimport { GenericRecord } from \"~/types\";\n\ninterface ServiceManifest {\n name: string;\n manifest: Manifest;\n}\n\ntype Manifest = GenericRecord<string>;\n\nclass ServiceManifestLoader {\n private client: DynamoDBDocument | undefined;\n private manifest: Manifest | undefined = undefined;\n\n async load() {\n if (this.manifest) {\n return this.manifest;\n }\n\n const manifests = await this.loadManifests();\n\n if (!manifests) {\n return undefined;\n }\n\n /**\n * Service manifests are already merged by unique names in the database, so we only need to construct\n * a final object containing all manifests by name.\n */\n this.manifest = manifests.reduce((acc, manifest) => {\n return { ...acc, [manifest.name]: manifest.manifest };\n }, {});\n\n return this.manifest;\n }\n\n setDocumentClient(client: DynamoDBDocument) {\n this.client = client;\n }\n\n private async loadManifests(): Promise<ServiceManifest[] | undefined> {\n const client = this.client || getDocumentClient();\n const { Items } = await client.send(\n new QueryCommand({\n TableName: String(process.env.DB_TABLE),\n IndexName: \"GSI1\",\n KeyConditionExpression: \"GSI1_PK = :GSI1_PK AND GSI1_SK > :GSI1_SK\",\n ExpressionAttributeValues: {\n \":GSI1_PK\": { S: `SERVICE_MANIFESTS` },\n \":GSI1_SK\": { S: \" \" }\n }\n })\n );\n\n if (!Array.isArray(Items)) {\n return undefined;\n }\n\n return Items.map(item => unmarshall(item).data);\n }\n}\n\nconst serviceManifestLoader = new ServiceManifestLoader();\n\nexport class ServiceDiscovery {\n static setDocumentClient(client: DynamoDBDocument): void {\n serviceManifestLoader.setDocumentClient(client);\n }\n\n static async load() {\n return serviceManifestLoader.load();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAeA,MAAMC,qBAAqB,CAAC;EAEhBC,QAAQ,GAAyBC,SAAS;EAElD,MAAMC,IAAIA,CAAA,EAAG;IACT,IAAI,IAAI,CAACF,QAAQ,EAAE;MACf,OAAO,IAAI,CAACA,QAAQ;IACxB;IAEA,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACC,aAAa,CAAC,CAAC;IAE5C,IAAI,CAACD,SAAS,EAAE;MACZ,OAAOF,SAAS;IACpB;;IAEA;AACR;AACA;AACA;IACQ,IAAI,CAACD,QAAQ,GAAGG,SAAS,CAACE,MAAM,CAAC,CA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B,OAAA,CAAAD,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.42.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,18 +12,13 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"@webiny/
|
|
17
|
-
"@webiny/plugins": "5.41.4"
|
|
15
|
+
"@webiny/aws-sdk": "5.42.0-beta.1",
|
|
16
|
+
"@webiny/plugins": "5.42.0-beta.1"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
23
|
-
"@babel/preset-typescript": "7.24.1",
|
|
24
|
-
"@webiny/cli": "5.41.4",
|
|
25
|
-
"@webiny/project-utils": "5.41.4",
|
|
26
|
-
"rimraf": "5.0.5",
|
|
19
|
+
"@webiny/cli": "5.42.0-beta.1",
|
|
20
|
+
"@webiny/project-utils": "5.42.0-beta.1",
|
|
21
|
+
"rimraf": "6.0.1",
|
|
27
22
|
"ttypescript": "1.5.15",
|
|
28
23
|
"typescript": "4.9.5"
|
|
29
24
|
},
|
|
@@ -35,5 +30,5 @@
|
|
|
35
30
|
"build": "yarn webiny run build",
|
|
36
31
|
"watch": "yarn webiny run watch"
|
|
37
32
|
},
|
|
38
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "5e69da579efa4f2c8268e0c97ac6407ddc3f5f07"
|
|
39
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","ContextPlugin","Plugin","type","constructor","callable","_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;EACnE,OAAgCC,IAAI,GAAW,SAAS;EAGxDC,WAAWA,CAACC,QAAkC,EAAE;IAC5C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAKA,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,
|
|
1
|
+
{"version":3,"names":["_plugins","require","ContextPlugin","Plugin","type","constructor","callable","_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;EACnE,OAAgCC,IAAI,GAAW,SAAS;EAGxDC,WAAWA,CAACC,QAAkC,EAAE;IAC5C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAKA,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACP,uIACJ,CAAC;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAACE,OAAA,CAAAT,aAAA,GAAAA,aAAA;AAEM,MAAMU,mBAAmB,GAC5BN,QAAkC,IACf;EACnB,OAAO,IAAIJ,aAAa,CAAII,QAAQ,CAAC;AACzC,CAAC;AAACK,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -41,7 +41,6 @@ export interface Benchmark {
|
|
|
41
41
|
*/
|
|
42
42
|
export interface Context {
|
|
43
43
|
plugins: PluginsContainer;
|
|
44
|
-
args: any;
|
|
45
44
|
readonly WEBINY_VERSION: string;
|
|
46
45
|
/**
|
|
47
46
|
* Not to be used outside of Webiny internal code.
|
|
@@ -54,12 +53,12 @@ export interface Context {
|
|
|
54
53
|
*
|
|
55
54
|
* @private
|
|
56
55
|
*/
|
|
57
|
-
_result?:
|
|
56
|
+
_result?: unknown;
|
|
58
57
|
/**
|
|
59
58
|
* Not to be used outside of Webiny internal code.
|
|
60
59
|
* @internal
|
|
61
60
|
*/
|
|
62
|
-
setResult: (value:
|
|
61
|
+
setResult: (value: unknown) => void;
|
|
63
62
|
/**
|
|
64
63
|
* Not to be used outside of Webiny internal code.
|
|
65
64
|
* @internal
|
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
|
|
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":[]}
|