@webiny/api 6.0.0-alpha.5 → 6.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Benchmark.d.ts +1 -1
- package/Benchmark.js +1 -8
- package/Benchmark.js.map +1 -1
- package/Context.d.ts +6 -4
- package/Context.js +15 -20
- package/Context.js.map +1 -1
- package/README.md +10 -14
- package/ServiceDiscovery.d.ts +2 -2
- package/ServiceDiscovery.js +5 -12
- package/ServiceDiscovery.js.map +1 -1
- package/createConditionalPluginFactory.d.ts +1 -1
- package/createConditionalPluginFactory.js +1 -8
- package/createConditionalPluginFactory.js.map +1 -1
- package/decorateContext.js +1 -8
- package/decorateContext.js.map +1 -1
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +3 -0
- package/helpers/InterfaceGenerator/date.js.map +1 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +3 -0
- package/helpers/InterfaceGenerator/id.js.map +1 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +3 -0
- package/helpers/InterfaceGenerator/identity.js.map +1 -0
- package/helpers/InterfaceGenerator/index.d.ts +5 -0
- package/helpers/InterfaceGenerator/index.js +3 -0
- package/helpers/InterfaceGenerator/index.js.map +1 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +3 -0
- package/helpers/InterfaceGenerator/numeric.js.map +1 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +3 -0
- package/helpers/InterfaceGenerator/truthful.js.map +1 -0
- package/index.d.ts +7 -6
- package/index.js +7 -71
- package/index.js.map +1 -1
- package/package.json +12 -12
- package/plugins/BenchmarkPlugin.d.ts +1 -1
- package/plugins/BenchmarkPlugin.js +2 -9
- package/plugins/BenchmarkPlugin.js.map +1 -1
- package/plugins/CompressorPlugin.d.ts +2 -2
- package/plugins/CompressorPlugin.js +2 -9
- package/plugins/CompressorPlugin.js.map +1 -1
- package/plugins/ContextPlugin.d.ts +1 -1
- package/plugins/ContextPlugin.js +3 -11
- package/plugins/ContextPlugin.js.map +1 -1
- package/types.d.ts +6 -6
- package/types.js +1 -5
- package/types.js.map +1 -1
package/Benchmark.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Benchmark as BenchmarkInterface, BenchmarkEnableOnCallable, BenchmarkMeasurement, BenchmarkMeasureOptions, BenchmarkOutputCallable, BenchmarkRuns } from "./types";
|
|
1
|
+
import type { Benchmark as BenchmarkInterface, BenchmarkEnableOnCallable, BenchmarkMeasurement, BenchmarkMeasureOptions, BenchmarkOutputCallable, BenchmarkRuns } from "./types.js";
|
|
2
2
|
export declare class Benchmark implements BenchmarkInterface {
|
|
3
3
|
readonly measurements: BenchmarkMeasurement[];
|
|
4
4
|
private outputDone;
|
package/Benchmark.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Benchmark = void 0;
|
|
7
1
|
var BenchmarkState = /*#__PURE__*/function (BenchmarkState) {
|
|
8
2
|
BenchmarkState["DISABLED"] = "disabled";
|
|
9
3
|
BenchmarkState["ENABLED"] = "enabled";
|
|
@@ -19,7 +13,7 @@ const createDefaultOutputCallable = () => {
|
|
|
19
13
|
console.log(benchmark.measurements);
|
|
20
14
|
};
|
|
21
15
|
};
|
|
22
|
-
class Benchmark {
|
|
16
|
+
export class Benchmark {
|
|
23
17
|
measurements = [];
|
|
24
18
|
outputDone = false;
|
|
25
19
|
isAlreadyRunning = false;
|
|
@@ -155,6 +149,5 @@ class Benchmark {
|
|
|
155
149
|
};
|
|
156
150
|
}
|
|
157
151
|
}
|
|
158
|
-
exports.Benchmark = Benchmark;
|
|
159
152
|
|
|
160
153
|
//# sourceMappingURL=Benchmark.js.map
|
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 type {\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,GAAG,CAACF,SAAS,CAACI,YAAY,CAAC;EACvC,CAAC;AACL,CAAC;AAEM,MAAMC,SAAS,CAA+B;EACjCD,YAAY,GAA2B,EAAE;EAEjDE,UAAU,GAAG,KAAK;EAClBC,gBAAgB,GAAG,KAAK;EACxBC,YAAY,GAAG,CAAC;EACRC,IAAI,GAAkB,CAAC,CAAC;EACvBC,iBAAiB,GAAgC,EAAE;EACnDC,iBAAiB,GAA8B,EAAE;EAC1DC,KAAK,GAAmBd,cAAc,C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EV,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"],"sources":["Benchmark.ts"],"sourcesContent":["import type {\n Benchmark as BenchmarkInterface,\n BenchmarkEnableOnCallable,\n BenchmarkMeasurement,\n BenchmarkMeasureOptions,\n BenchmarkOutputCallable,\n BenchmarkRuns\n} from \"~/types.js\";\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,GAAG,CAACF,SAAS,CAACI,YAAY,CAAC;EACvC,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,SAAS,CAA+B;EACjCD,YAAY,GAA2B,EAAE;EAEjDE,UAAU,GAAG,KAAK;EAClBC,gBAAgB,GAAG,KAAK;EACxBC,YAAY,GAAG,CAAC;EACRC,IAA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AAW,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","ignoreList":[]}
|
package/Context.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Context as ContextInterface } from "./types";
|
|
1
|
+
import type { Context as ContextInterface } from "./types.js";
|
|
2
2
|
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import type { PluginCollection } from "@webiny/plugins/types";
|
|
4
|
-
import { Benchmark } from "./Benchmark";
|
|
5
|
-
import type { ICompressor } from "@webiny/utils/compression/Compressor";
|
|
3
|
+
import type { PluginCollection } from "@webiny/plugins/types.js";
|
|
4
|
+
import { Benchmark } from "./Benchmark.js";
|
|
5
|
+
import type { ICompressor } from "@webiny/utils/compression/Compressor.js";
|
|
6
|
+
import { Container } from "@webiny/di";
|
|
6
7
|
export interface ContextParams {
|
|
7
8
|
plugins?: PluginCollection | PluginsContainer;
|
|
8
9
|
WEBINY_VERSION: string;
|
|
@@ -14,6 +15,7 @@ export declare class Context implements ContextInterface {
|
|
|
14
15
|
readonly WEBINY_VERSION: string;
|
|
15
16
|
readonly benchmark: Benchmark;
|
|
16
17
|
readonly compressor: ICompressor;
|
|
18
|
+
readonly container: Container;
|
|
17
19
|
private readonly waiters;
|
|
18
20
|
constructor(params: ContextParams);
|
|
19
21
|
getResult(): any;
|
package/Context.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
var _plugins = require("@webiny/plugins");
|
|
8
|
-
var _Benchmark = require("./Benchmark");
|
|
9
|
-
var _BenchmarkPlugin = require("./plugins/BenchmarkPlugin");
|
|
10
|
-
var _compression = require("@webiny/utils/compression");
|
|
11
|
-
var _CompressorPlugin = require("./plugins/CompressorPlugin");
|
|
1
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
+
import { Benchmark } from "./Benchmark.js";
|
|
3
|
+
import { BenchmarkPlugin } from "./plugins/BenchmarkPlugin.js";
|
|
4
|
+
import { createDefaultCompressor } from "@webiny/utils/compression/index.js";
|
|
5
|
+
import { CompressorPlugin } from "./plugins/CompressorPlugin.js";
|
|
6
|
+
import { Container } from "@webiny/di";
|
|
12
7
|
const getPluginsContainer = plugins => {
|
|
13
8
|
if (!plugins) {
|
|
14
|
-
return new
|
|
9
|
+
return new PluginsContainer();
|
|
15
10
|
}
|
|
16
|
-
if (plugins instanceof
|
|
11
|
+
if (plugins instanceof PluginsContainer) {
|
|
17
12
|
return plugins;
|
|
18
13
|
}
|
|
19
|
-
return new
|
|
14
|
+
return new PluginsContainer(plugins);
|
|
20
15
|
};
|
|
21
|
-
class Context {
|
|
16
|
+
export class Context {
|
|
22
17
|
waiters = [];
|
|
23
18
|
constructor(params) {
|
|
24
19
|
const {
|
|
@@ -27,15 +22,16 @@ class Context {
|
|
|
27
22
|
} = params;
|
|
28
23
|
this.plugins = getPluginsContainer(plugins);
|
|
29
24
|
this.WEBINY_VERSION = WEBINY_VERSION;
|
|
25
|
+
this.container = new Container();
|
|
30
26
|
/**
|
|
31
|
-
* At the moment let's have benchmark as part of the context.
|
|
27
|
+
* At the moment, let's have benchmark as part of the context.
|
|
32
28
|
* Also, register the plugin to have benchmark accessible via plugins container.
|
|
33
29
|
*/
|
|
34
|
-
this.benchmark = new
|
|
35
|
-
this.compressor =
|
|
30
|
+
this.benchmark = new Benchmark();
|
|
31
|
+
this.compressor = createDefaultCompressor({
|
|
36
32
|
plugins: this.plugins
|
|
37
33
|
});
|
|
38
|
-
this.plugins.register(new
|
|
34
|
+
this.plugins.register(new BenchmarkPlugin(this.benchmark), new CompressorPlugin({
|
|
39
35
|
getCompressor: () => {
|
|
40
36
|
return this.compressor;
|
|
41
37
|
}
|
|
@@ -139,6 +135,5 @@ class Context {
|
|
|
139
135
|
});
|
|
140
136
|
}
|
|
141
137
|
}
|
|
142
|
-
exports.Context = Context;
|
|
143
138
|
|
|
144
139
|
//# sourceMappingURL=Context.js.map
|
package/Context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["PluginsContainer","Benchmark","BenchmarkPlugin","createDefaultCompressor","CompressorPlugin","Container","getPluginsContainer","plugins","Context","waiters","constructor","params","WEBINY_VERSION","container","benchmark","compressor","register","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"],"sources":["Context.ts"],"sourcesContent":["import type { Context as ContextInterface } from \"~/types.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport type { PluginCollection } from \"@webiny/plugins/types.js\";\nimport { Benchmark } from \"~/Benchmark.js\";\nimport { BenchmarkPlugin } from \"~/plugins/BenchmarkPlugin.js\";\nimport type { ICompressor } from \"@webiny/utils/compression/Compressor.js\";\nimport { createDefaultCompressor } from \"@webiny/utils/compression/index.js\";\nimport { CompressorPlugin } from \"~/plugins/CompressorPlugin.js\";\nimport { Container } from \"@webiny/di\";\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 public readonly container: Container;\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 this.container = new Container();\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,SAASA,gBAAgB,QAAQ,iBAAiB;AAElD,SAASC,SAAS;AAClB,SAASC,eAAe;AAExB,SAASC,uBAAuB,QAAQ,oCAAoC;AAC5E,SAASC,gBAAgB;AACzB,SAASC,SAAS,QAAQ,YAAY;AAYtC,MAAMC,mBAAmB,GAAIC,OAA6C,IAAuB;EAC7F,IAAI,CAACA,OAAO,EAAE;IACV,OAAO,IAAIP,gBAAgB,CAAC,CAAC;EACjC;EACA,IAAIO,OAAO,YAAYP,gBAAgB,EAAE;IACrC,OAAOO,OAAO;EAClB;EACA,OAAO,IAAIP,gBAAgB,CAACO,OAAO,CAAC;AACxC,CAAC;AAED,OAAO,MAAMC,OAAO,CAA6B;EAS5BC,OAAO,GAAa,EAAE;EAEhCC,WAAWA,CAACC,MAAqB,EAAE;IACtC,MAAM;MAAEJ,OAAO;MAAEK;IAAe,CAAC,GAAGD,MAAM;IAC1C,IAAI,CAACJ,OAAO,GAAGD,mBAAmB,CAACC,OAAO,CAAC;IAC3C,IAAI,CAACK,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,SAAS,GAAG,IAAIR,SAAS,CAAC,CAAC;IAChC;AACR;AACA;AACA;IACQ,IAAI,CAACS,SAAS,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KAAK,MAAMc,MAAM,IAAI,IAAI,CAAC3B,OAAO,EAAE;YAC/B,IAAI2B,MAAM,CAACP,OAAO,CAACQ,QAAQ,CAACN,MAAM,CAAC,KAAK,KAAK,EAAE;cAC3C;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,CAAChB,OAAO,CAACkC,IAAI,CAAC;MACdd,OAAO;MACP;AACZ;AACA;AACA;MACY;MACAJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
package/README.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
# @webiny/api
|
|
2
|
-
|
|
3
|
-
[!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Or if you prefer yarn:
|
|
13
|
-
```
|
|
14
|
-
yarn add @webiny/api
|
|
15
|
-
```
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/ServiceDiscovery.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
-
import type { GenericRecord } from "./types";
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
import type { GenericRecord } from "./types.js";
|
|
3
3
|
type Manifest = GenericRecord<string>;
|
|
4
4
|
export declare class ServiceDiscovery {
|
|
5
5
|
static setDocumentClient(client: Pick<DynamoDBDocument, "send">): void;
|
package/ServiceDiscovery.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ServiceDiscovery = void 0;
|
|
7
|
-
var _clientDynamodb = require("@webiny/aws-sdk/client-dynamodb");
|
|
1
|
+
import { getDocumentClient, QueryCommand, unmarshall } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
8
2
|
class ServiceManifestLoader {
|
|
9
3
|
manifest = undefined;
|
|
10
4
|
async load() {
|
|
@@ -35,10 +29,10 @@ class ServiceManifestLoader {
|
|
|
35
29
|
this.manifest = undefined;
|
|
36
30
|
}
|
|
37
31
|
async loadManifests() {
|
|
38
|
-
const client = this.client ||
|
|
32
|
+
const client = this.client || getDocumentClient();
|
|
39
33
|
const {
|
|
40
34
|
Items
|
|
41
|
-
} = await client.send(new
|
|
35
|
+
} = await client.send(new QueryCommand({
|
|
42
36
|
TableName: String(process.env.DB_TABLE),
|
|
43
37
|
IndexName: "GSI1",
|
|
44
38
|
KeyConditionExpression: "GSI1_PK = :GSI1_PK AND GSI1_SK > :GSI1_SK",
|
|
@@ -54,11 +48,11 @@ class ServiceManifestLoader {
|
|
|
54
48
|
if (!Array.isArray(Items)) {
|
|
55
49
|
return undefined;
|
|
56
50
|
}
|
|
57
|
-
return Items.map(item =>
|
|
51
|
+
return Items.map(item => unmarshall(item).data);
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
const serviceManifestLoader = new ServiceManifestLoader();
|
|
61
|
-
class ServiceDiscovery {
|
|
55
|
+
export class ServiceDiscovery {
|
|
62
56
|
static setDocumentClient(client) {
|
|
63
57
|
serviceManifestLoader.setDocumentClient(client);
|
|
64
58
|
}
|
|
@@ -72,6 +66,5 @@ class ServiceDiscovery {
|
|
|
72
66
|
serviceManifestLoader.clear();
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
|
-
exports.ServiceDiscovery = ServiceDiscovery;
|
|
76
69
|
|
|
77
70
|
//# sourceMappingURL=ServiceDiscovery.js.map
|
package/ServiceDiscovery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getDocumentClient","QueryCommand","unmarshall","ServiceManifestLoader","manifest","undefined","load","manifests","loadManifests","reduce","acc","name","setDocumentClient","client","clear","Items","send","TableName","String","process","env","DB_TABLE","IndexName","KeyConditionExpression","ExpressionAttributeValues","S","Array","isArray","map","item","data","serviceManifestLoader","ServiceDiscovery"],"sources":["ServiceDiscovery.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport {\n getDocumentClient,\n QueryCommand,\n unmarshall\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { GenericRecord } from \"~/types.js\";\n\ninterface ServiceManifest {\n name: string;\n manifest: Manifest;\n}\n\ntype Manifest = GenericRecord<string>;\n\nclass ServiceManifestLoader {\n private client: Pick<DynamoDBDocument, \"send\"> | undefined;\n private manifest: Manifest | undefined = undefined;\n\n public 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 public setDocumentClient(client: Pick<DynamoDBDocument, \"send\">) {\n this.client = client;\n }\n\n public clear(): void {\n this.manifest = undefined;\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: Pick<DynamoDBDocument, \"send\">): void {\n serviceManifestLoader.setDocumentClient(client);\n }\n\n static async load() {\n return serviceManifestLoader.load();\n }\n /**\n * Should be used for testing purposes only!\n */\n static clear(): void {\n serviceManifestLoader.clear();\n }\n}\n"],"mappings":"AACA,SACIA,iBAAiB,EACjBC,YAAY,EACZC,UAAU,QACP,0CAA0C;AAUjD,MAAMC,qBAAqB,CAAC;EAEhBC,QAAQ,GAAyBC,SAAS;EAElD,MAAaC,IAAIA,CAAA,EAAG;IAChB,IAAI,IAAI,CAACF,QAAQ,EAAE;MACf,OAAO,IAAI,CAACA,QAAQ;IACxB;IAEA,MAAMG,SAAS,GAAG,MAAM,IAAI,C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,OAAO,MAAM6B,gBAAgB,CAAC;EAC1B,OAAOpB,iBAAiBA,CAACC,MAAsC,EAAQ;IACnEkB,qBAAqB,CAACnB,iBAAiB,CAACC,MAAM,CAAC;EACnD;EAEA,aAAaP,IAAIA,CAAA,EAAG;IAChB,OAAOyB,qBAAqB,CAACzB,IAAI,CAAC,CAAC;EACvC;EACA;AACJ;AACA;EACI,OAAOQ,KAAKA,CAAA,EAAS;IACjBiB,qBAAqB,CAACjB,KAAK,CAAC,CAAC;EACjC;AACJ","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PluginFactory } from "@webiny/plugins/types";
|
|
1
|
+
import type { PluginFactory } from "@webiny/plugins/types.js";
|
|
2
2
|
export type Condition = () => boolean;
|
|
3
3
|
export declare const createConditionalPluginFactory: (condition: Condition, cb: PluginFactory) => PluginFactory;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createConditionalPluginFactory = void 0;
|
|
7
|
-
const createConditionalPluginFactory = (condition, cb) => {
|
|
1
|
+
export const createConditionalPluginFactory = (condition, cb) => {
|
|
8
2
|
return () => {
|
|
9
3
|
if (condition()) {
|
|
10
4
|
return cb();
|
|
@@ -12,6 +6,5 @@ const createConditionalPluginFactory = (condition, cb) => {
|
|
|
12
6
|
return Promise.resolve([]);
|
|
13
7
|
};
|
|
14
8
|
};
|
|
15
|
-
exports.createConditionalPluginFactory = createConditionalPluginFactory;
|
|
16
9
|
|
|
17
10
|
//# sourceMappingURL=createConditionalPluginFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createConditionalPluginFactory","condition","cb","Promise","resolve"
|
|
1
|
+
{"version":3,"names":["createConditionalPluginFactory","condition","cb","Promise","resolve"],"sources":["createConditionalPluginFactory.ts"],"sourcesContent":["import type { PluginFactory } from \"@webiny/plugins/types.js\";\n\nexport type Condition = () => boolean;\n\nexport const createConditionalPluginFactory = (\n condition: Condition,\n cb: PluginFactory\n): PluginFactory => {\n return () => {\n if (condition()) {\n return cb();\n }\n\n return Promise.resolve([]);\n };\n};\n"],"mappings":"AAIA,OAAO,MAAMA,8BAA8B,GAAGA,CAC1CC,SAAoB,EACpBC,EAAiB,KACD;EAChB,OAAO,MAAM;IACT,IAAID,SAAS,CAAC,CAAC,EAAE;MACb,OAAOC,EAAE,CAAC,CAAC;IACf;IAEA,OAAOC,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;EAC9B,CAAC;AACL,CAAC","ignoreList":[]}
|
package/decorateContext.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.decorateContext = void 0;
|
|
7
|
-
const decorateContext = (decoratee, decorators) => {
|
|
1
|
+
export const decorateContext = (decoratee, decorators) => {
|
|
8
2
|
return Object.keys(decorators).reduce((acc, key) => {
|
|
9
3
|
const decoratedMethod = acc[key];
|
|
10
4
|
return {
|
|
@@ -16,6 +10,5 @@ const decorateContext = (decoratee, decorators) => {
|
|
|
16
10
|
};
|
|
17
11
|
}, decoratee);
|
|
18
12
|
};
|
|
19
|
-
exports.decorateContext = decorateContext;
|
|
20
13
|
|
|
21
14
|
//# sourceMappingURL=decorateContext.js.map
|
package/decorateContext.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["decorateContext","decoratee","decorators","Object","keys","reduce","acc","key","decoratedMethod","args","bind"
|
|
1
|
+
{"version":3,"names":["decorateContext","decoratee","decorators","Object","keys","reduce","acc","key","decoratedMethod","args","bind"],"sources":["decorateContext.ts"],"sourcesContent":["type Decorators<TDecoratee> = {\n [K in keyof TDecoratee]?: (decoratee: TDecoratee[K]) => TDecoratee[K];\n};\n\nexport const decorateContext = <T extends Record<string, any>>(\n decoratee: T,\n decorators: Decorators<T>\n) => {\n return Object.keys(decorators).reduce((acc, key) => {\n const decoratedMethod = acc[key];\n\n return {\n ...acc,\n [key]: function (...args: any[]) {\n // @ts-expect-error\n return decorators[key](decoratedMethod.bind(decoratee))(...args);\n }\n };\n }, decoratee);\n};\n"],"mappings":"AAIA,OAAO,MAAMA,eAAe,GAAGA,CAC3BC,SAAY,EACZC,UAAyB,KACxB;EACD,OAAOC,MAAM,CAACC,IAAI,CAACF,UAAU,CAAC,CAACG,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;IAChD,MAAMC,eAAe,GAAGF,GAAG,CAACC,GAAG,CAAC;IAEhC,OAAO;MACH,GAAGD,GAAG;MACN,CAACC,GAAG,GAAG,UAAU,GAAGE,IAAW,EAAE;QAC7B;QACA,OAAOP,UAAU,CAACK,GAAG,CAAC,CAACC,eAAe,CAACE,IAAI,CAACT,SAAS,CAAC,CAAC,CAAC,GAAGQ,IAAI,CAAC;MACpE;IACJ,CAAC;EACL,CAAC,EAAER,SAAS,CAAC;AACjB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type DateOps<T> = {
|
|
2
|
+
"": T;
|
|
3
|
+
_gt: T;
|
|
4
|
+
_gte: T;
|
|
5
|
+
_lt: T;
|
|
6
|
+
_lte: T;
|
|
7
|
+
_between: [T, T];
|
|
8
|
+
};
|
|
9
|
+
export type DateInterfaceGenerator<Name extends string> = {
|
|
10
|
+
[K in keyof DateOps<Date> as `${Name}${K}`]?: DateOps<Date>[K];
|
|
11
|
+
};
|
|
12
|
+
export type DateStringInterfaceGenerator<Name extends string> = {
|
|
13
|
+
[K in keyof DateOps<string> as `${Name}${K}`]?: DateOps<string>[K];
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["date.ts"],"sourcesContent":["type DateOps<T> = {\n \"\": T;\n _gt: T;\n _gte: T;\n _lt: T;\n _lte: T;\n _between: [T, T];\n};\n\nexport type DateInterfaceGenerator<Name extends string> = {\n [K in keyof DateOps<Date> as `${Name}${K}`]?: DateOps<Date>[K];\n};\n\nexport type DateStringInterfaceGenerator<Name extends string> = {\n [K in keyof DateOps<string> as `${Name}${K}`]?: DateOps<string>[K];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type IdOperators<TType extends string> = {
|
|
2
|
+
"": TType;
|
|
3
|
+
_not: TType;
|
|
4
|
+
_in: TType[];
|
|
5
|
+
_not_in: TType[];
|
|
6
|
+
};
|
|
7
|
+
export type IdInterfaceGenerator<TName extends string, TType extends string = string> = {
|
|
8
|
+
[K in keyof IdOperators<TType> as `${TName}${K}`]?: IdOperators<TType>[K];
|
|
9
|
+
};
|
|
10
|
+
type IdMixedOperators = {
|
|
11
|
+
"": string;
|
|
12
|
+
_not: string;
|
|
13
|
+
_in: string[];
|
|
14
|
+
_not_in: string[];
|
|
15
|
+
_gt: number | string;
|
|
16
|
+
_gte: number | string;
|
|
17
|
+
_lt: number | string;
|
|
18
|
+
_lte: number | string;
|
|
19
|
+
};
|
|
20
|
+
export type IdMixedInterfaceGenerator<TName extends string> = {
|
|
21
|
+
[K in keyof IdMixedOperators as `${TName}${K}`]?: IdMixedOperators[K];
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["id.ts"],"sourcesContent":["type IdOperators<TType extends string> = {\n \"\": TType;\n _not: TType;\n _in: TType[];\n _not_in: TType[];\n};\n\nexport type IdInterfaceGenerator<TName extends string, TType extends string = string> = {\n [K in keyof IdOperators<TType> as `${TName}${K}`]?: IdOperators<TType>[K];\n};\n\ntype IdMixedOperators = {\n \"\": string;\n _not: string;\n _in: string[];\n _not_in: string[];\n _gt: number | string;\n _gte: number | string;\n _lt: number | string;\n _lte: number | string;\n};\n\nexport type IdMixedInterfaceGenerator<TName extends string> = {\n [K in keyof IdMixedOperators as `${TName}${K}`]?: IdMixedOperators[K];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["identity.ts"],"sourcesContent":["type IdentityOps<TId> = {\n \"\": TId;\n _not: TId;\n _in: TId[];\n _not_in: TId[];\n};\n\nexport type IdentityInterfaceGenerator<Name extends string, TId = string> = {\n [K in keyof IdentityOps<TId> as `${Name}${K}`]?: IdentityOps<TId>[K];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { IdInterfaceGenerator, IdMixedInterfaceGenerator } from "./id.js";
|
|
2
|
+
export type { DateInterfaceGenerator, DateStringInterfaceGenerator } from "./date.js";
|
|
3
|
+
export type { IdentityInterfaceGenerator } from "./identity.js";
|
|
4
|
+
export type { NumericInterfaceGenerator } from "./numeric.js";
|
|
5
|
+
export type { TruthfulInterfaceGenerator } from "./truthful.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { IdInterfaceGenerator, IdMixedInterfaceGenerator } from \"./id.js\";\nexport type { DateInterfaceGenerator, DateStringInterfaceGenerator } from \"./date.js\";\nexport type { IdentityInterfaceGenerator } from \"./identity.js\";\nexport type { NumericInterfaceGenerator } from \"./numeric.js\";\nexport type { TruthfulInterfaceGenerator } from \"./truthful.js\";\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Numeric = {
|
|
2
|
+
"": number;
|
|
3
|
+
_gt: number;
|
|
4
|
+
_gte: number;
|
|
5
|
+
_lt: number;
|
|
6
|
+
_lte: number;
|
|
7
|
+
_between: [number, number];
|
|
8
|
+
};
|
|
9
|
+
export type NumericInterfaceGenerator<Name extends string> = {
|
|
10
|
+
[K in keyof Numeric as `${Name}${K}`]?: Numeric[K];
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["numeric.ts"],"sourcesContent":["type Numeric = {\n \"\": number;\n _gt: number;\n _gte: number;\n _lt: number;\n _lte: number;\n _between: [number, number];\n};\n\nexport type NumericInterfaceGenerator<Name extends string> = {\n [K in keyof Numeric as `${Name}${K}`]?: Numeric[K];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["truthful.ts"],"sourcesContent":["type Truthful = {\n \"\": boolean;\n};\n\nexport type TruthfulInterfaceGenerator<Name extends string> = {\n [K in keyof Truthful as `${Name}${K}`]?: Truthful[K];\n};\n"],"mappings":"","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from "./Context";
|
|
2
|
-
export * from "./plugins/CompressorPlugin";
|
|
3
|
-
export * from "./decorateContext";
|
|
4
|
-
export * from "./createConditionalPluginFactory";
|
|
5
|
-
export * from "./ServiceDiscovery";
|
|
6
|
-
export * from "./plugins/ContextPlugin";
|
|
1
|
+
export * from "./Context.js";
|
|
2
|
+
export * from "./plugins/CompressorPlugin.js";
|
|
3
|
+
export * from "./decorateContext.js";
|
|
4
|
+
export * from "./createConditionalPluginFactory.js";
|
|
5
|
+
export * from "./ServiceDiscovery.js";
|
|
6
|
+
export * from "./plugins/ContextPlugin.js";
|
|
7
|
+
export * from "./helpers/InterfaceGenerator/index.js";
|
package/index.js
CHANGED
|
@@ -1,73 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _Context[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _Context[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
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
|
-
});
|
|
28
|
-
var _decorateContext = require("./decorateContext");
|
|
29
|
-
Object.keys(_decorateContext).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _decorateContext[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _decorateContext[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _createConditionalPluginFactory = require("./createConditionalPluginFactory");
|
|
40
|
-
Object.keys(_createConditionalPluginFactory).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _createConditionalPluginFactory[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _createConditionalPluginFactory[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _ServiceDiscovery = require("./ServiceDiscovery");
|
|
51
|
-
Object.keys(_ServiceDiscovery).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _ServiceDiscovery[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _ServiceDiscovery[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _ContextPlugin = require("./plugins/ContextPlugin");
|
|
62
|
-
Object.keys(_ContextPlugin).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _ContextPlugin[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _ContextPlugin[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
1
|
+
export * from "./Context.js";
|
|
2
|
+
export * from "./plugins/CompressorPlugin.js";
|
|
3
|
+
export * from "./decorateContext.js";
|
|
4
|
+
export * from "./createConditionalPluginFactory.js";
|
|
5
|
+
export * from "./ServiceDiscovery.js";
|
|
6
|
+
export * from "./plugins/ContextPlugin.js";
|
|
7
|
+
export * from "./helpers/InterfaceGenerator/index.js";
|
|
72
8
|
|
|
73
9
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Context.js\";\nexport * from \"./plugins/CompressorPlugin.js\";\nexport * from \"./decorateContext.js\";\nexport * from \"./createConditionalPluginFactory.js\";\nexport * from \"./ServiceDiscovery.js\";\nexport * from \"./plugins/ContextPlugin.js\";\nexport * from \"./helpers/InterfaceGenerator/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -12,22 +13,21 @@
|
|
|
12
13
|
],
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"@webiny/aws-sdk": "6.0.0-
|
|
16
|
-
"@webiny/
|
|
17
|
-
"@webiny/
|
|
16
|
+
"@webiny/aws-sdk": "6.0.0-rc.0",
|
|
17
|
+
"@webiny/di": "0.2.3",
|
|
18
|
+
"@webiny/plugins": "6.0.0-rc.0",
|
|
19
|
+
"@webiny/utils": "6.0.0-rc.0"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
|
-
"@webiny/
|
|
21
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"@webiny/build-tools": "6.0.0-rc.0",
|
|
23
|
+
"@webiny/project-utils": "6.0.0-rc.0",
|
|
24
|
+
"rimraf": "6.1.3",
|
|
25
|
+
"typescript": "5.9.3",
|
|
26
|
+
"vitest": "4.0.18"
|
|
23
27
|
},
|
|
24
28
|
"publishConfig": {
|
|
25
29
|
"access": "public",
|
|
26
30
|
"directory": "dist"
|
|
27
31
|
},
|
|
28
|
-
"
|
|
29
|
-
"build": "node ../cli/bin.js run build",
|
|
30
|
-
"watch": "node ../cli/bin.js run watch"
|
|
31
|
-
},
|
|
32
|
-
"gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
|
|
32
|
+
"gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
|
|
33
33
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.BenchmarkPlugin = void 0;
|
|
7
|
-
var _plugins = require("@webiny/plugins");
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
8
2
|
/**
|
|
9
3
|
* This plugin should be initialized only once per context, hence the name of the plugin.
|
|
10
4
|
*/
|
|
11
|
-
class BenchmarkPlugin extends
|
|
5
|
+
export class BenchmarkPlugin extends Plugin {
|
|
12
6
|
static type = "context.benchmark";
|
|
13
7
|
name = "context.benchmark";
|
|
14
8
|
constructor(benchmark) {
|
|
@@ -25,6 +19,5 @@ class BenchmarkPlugin extends _plugins.Plugin {
|
|
|
25
19
|
return this.benchmark.measure(name, cb);
|
|
26
20
|
}
|
|
27
21
|
}
|
|
28
|
-
exports.BenchmarkPlugin = BenchmarkPlugin;
|
|
29
22
|
|
|
30
23
|
//# sourceMappingURL=BenchmarkPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","BenchmarkPlugin","type","name","constructor","benchmark","enable","disable","measure","cb"],"sources":["BenchmarkPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Benchmark } from \"~/types.js\";\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,SAASA,MAAM,QAAQ,iBAAiB;AAGxC;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAASD,MAAM,CAAC;EACxC,OAAgCE,IAAI,GAAW,mBAAmB;EAClDC,IAAI,GAAG,mBAAmB;EAGnCC,WAAWA,CAACC,SAAoB,EAAE;IACrC,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC9B;EAEOC,MAAMA,CAAA,EAAS;IAClB,IAAI,CAACD,SAAS,CAACC,MAAM,CAAC,CAAC;EAC3B;EAEOC,OAAOA,CAAA,EAAS;IACnB,IAAI,CAACF,SAAS,CAACE,OAAO,CAAC,CAAC;EAC5B;EAEA,MAAaC,OAAOA,CAAUL,IAAY,EAAEM,EAAoB,EAAc;IAC1E,OAAO,IAAI,CAACJ,SAAS,CAACG,OAAO,CAAIL,IAAI,EAAEM,EAAE,CAAC;EAC9C;AACJ","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import type { ICompressor } from "@webiny/utils/compression/Compressor";
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
import type { ICompressor } from "@webiny/utils/compression/Compressor.js";
|
|
3
3
|
export interface ICompressorPluginParams {
|
|
4
4
|
getCompressor(): ICompressor;
|
|
5
5
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CompressorPlugin = void 0;
|
|
7
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
8
2
|
/**
|
|
9
3
|
* Should never be initialized outside the api package.
|
|
10
4
|
*/
|
|
11
|
-
class CompressorPlugin extends
|
|
5
|
+
export class CompressorPlugin extends Plugin {
|
|
12
6
|
name = "context.compressor";
|
|
13
7
|
static type = "context.compressor";
|
|
14
8
|
constructor(params) {
|
|
@@ -16,6 +10,5 @@ class CompressorPlugin extends _Plugin.Plugin {
|
|
|
16
10
|
this.getCompressor = params.getCompressor;
|
|
17
11
|
}
|
|
18
12
|
}
|
|
19
|
-
exports.CompressorPlugin = CompressorPlugin;
|
|
20
13
|
|
|
21
14
|
//# sourceMappingURL=CompressorPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","CompressorPlugin","name","type","constructor","params","getCompressor"],"sources":["CompressorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { ICompressor } from \"@webiny/utils/compression/Compressor.js\";\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,SAASA,MAAM,QAAQ,2BAA2B;AAOlD;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASD,MAAM,CAAC;EAChBE,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","ignoreList":[]}
|
package/plugins/ContextPlugin.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createContextPlugin = exports.ContextPlugin = void 0;
|
|
7
|
-
var _plugins = require("@webiny/plugins");
|
|
8
|
-
class ContextPlugin extends _plugins.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
export class ContextPlugin extends Plugin {
|
|
9
3
|
static type = "context";
|
|
10
4
|
constructor(callable) {
|
|
11
5
|
super();
|
|
@@ -18,14 +12,12 @@ class ContextPlugin extends _plugins.Plugin {
|
|
|
18
12
|
return this._callable(context);
|
|
19
13
|
}
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
const createContextPlugin = (callable, options) => {
|
|
15
|
+
export const createContextPlugin = (callable, options) => {
|
|
23
16
|
const plugin = new ContextPlugin(callable);
|
|
24
17
|
if (options && options.name) {
|
|
25
18
|
plugin.name = options.name;
|
|
26
19
|
}
|
|
27
20
|
return plugin;
|
|
28
21
|
};
|
|
29
|
-
exports.createContextPlugin = createContextPlugin;
|
|
30
22
|
|
|
31
23
|
//# sourceMappingURL=ContextPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","ContextPlugin","type","constructor","callable","_callable","apply","context","Error","createContextPlugin","options","plugin","name"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\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\ninterface ContextPluginOptions {\n name?: string;\n}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>,\n options?: ContextPluginOptions\n): ContextPlugin<T> => {\n const plugin = new ContextPlugin<T>(callable);\n if (options && options.name) {\n plugin.name = options.name;\n }\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAMC,aAAa,SAAsCD,MAAM,CAAC;EACnE,OAAgCE,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;AAMA,OAAO,MAAME,mBAAmB,GAAGA,CAC/BL,QAAkC,EAClCM,OAA8B,KACX;EACnB,MAAMC,MAAM,GAAG,IAAIV,aAAa,CAAIG,QAAQ,CAAC;EAC7C,IAAIM,OAAO,IAAIA,OAAO,CAACE,IAAI,EAAE;IACzBD,MAAM,CAACC,IAAI,GAAGF,OAAO,CAACE,IAAI;EAC9B;EACA,OAAOD,MAAM;AACjB,CAAC","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Container } from "@webiny/di";
|
|
1
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import type { ICompressor } from "@webiny/utils/compression/Compressor";
|
|
3
|
+
import type { ICompressor } from "@webiny/utils/compression/Compressor.js";
|
|
3
4
|
export type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;
|
|
4
5
|
export type NonEmptyArray<T> = [T, ...T[]];
|
|
5
6
|
export type PossiblyUndefinedProperties<T> = {
|
|
@@ -45,6 +46,10 @@ export interface Benchmark {
|
|
|
45
46
|
*/
|
|
46
47
|
export interface Context {
|
|
47
48
|
plugins: PluginsContainer;
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
container: Container;
|
|
48
53
|
readonly WEBINY_VERSION: string;
|
|
49
54
|
/**
|
|
50
55
|
* Not to be used outside of Webiny internal code.
|
|
@@ -68,11 +73,6 @@ export interface Context {
|
|
|
68
73
|
* @internal
|
|
69
74
|
*/
|
|
70
75
|
getResult: () => void;
|
|
71
|
-
/**
|
|
72
|
-
* Wait for property to be defined on the object and then execute the callable.
|
|
73
|
-
* In case of multiple objects defined, wait for all of them.
|
|
74
|
-
*/
|
|
75
|
-
waitFor: <T extends Context = Context>(obj: string[] | string, cb: (context: T) => void) => void;
|
|
76
76
|
/**
|
|
77
77
|
* Benchmark instance to help determine possible bugs and slow code.
|
|
78
78
|
*/
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type { 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 PossiblyUndefinedProperties<T> = {\n [K in keyof T]: T[K] extends undefined ? T[K] : T[K] | undefined;\n};\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 *
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { ICompressor } from \"@webiny/utils/compression/Compressor.js\";\n\nexport type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\n\nexport type PossiblyUndefinedProperties<T> = {\n [K in keyof T]: T[K] extends undefined ? T[K] : T[K] | undefined;\n};\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 /**\n * @internal\n */\n container: Container;\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 * 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":[]}
|