@webiny/api 0.0.0-unstable.06b2ede40f → 0.0.0-unstable.0d717d18dd
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 +120 -156
- package/Benchmark.js.map +1 -1
- package/Context.d.ts +5 -5
- package/Context.js +61 -137
- package/Context.js.map +1 -1
- package/README.md +10 -14
- package/abstractions.d.ts +5 -0
- package/abstractions.js +5 -0
- package/abstractions.js.map +1 -0
- package/createConditionalPluginFactory.d.ts +1 -1
- package/createConditionalPluginFactory.js +5 -15
- package/createConditionalPluginFactory.js.map +1 -1
- package/decorateContext.js +10 -19
- package/decorateContext.js.map +1 -1
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +0 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +0 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +0 -0
- package/helpers/InterfaceGenerator/index.d.ts +6 -0
- package/helpers/InterfaceGenerator/index.js +0 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +0 -0
- package/helpers/InterfaceGenerator/text.d.ts +11 -0
- package/helpers/InterfaceGenerator/text.js +0 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +0 -0
- package/index.d.ts +5 -6
- package/index.js +5 -73
- package/package.json +19 -15
- package/plugins/BenchmarkPlugin.d.ts +1 -1
- package/plugins/BenchmarkPlugin.js +19 -27
- package/plugins/BenchmarkPlugin.js.map +1 -1
- package/types.d.ts +5 -10
- package/types.js +0 -7
- package/ServiceDiscovery.d.ts +0 -12
- package/ServiceDiscovery.js +0 -77
- package/ServiceDiscovery.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/CompressorPlugin.d.ts +0 -14
- package/plugins/CompressorPlugin.js +0 -21
- package/plugins/CompressorPlugin.js.map +0 -1
- package/plugins/ContextPlugin.d.ts +0 -16
- package/plugins/ContextPlugin.js +0 -31
- package/plugins/ContextPlugin.js.map +0 -1
- package/types.js.map +0 -1
package/plugins/ContextPlugin.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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 {
|
|
9
|
-
static type = "context";
|
|
10
|
-
constructor(callable) {
|
|
11
|
-
super();
|
|
12
|
-
this._callable = callable;
|
|
13
|
-
}
|
|
14
|
-
async apply(context) {
|
|
15
|
-
if (typeof this._callable !== "function") {
|
|
16
|
-
throw Error(`Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the "apply" method.`);
|
|
17
|
-
}
|
|
18
|
-
return this._callable(context);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.ContextPlugin = ContextPlugin;
|
|
22
|
-
const createContextPlugin = (callable, options) => {
|
|
23
|
-
const plugin = new ContextPlugin(callable);
|
|
24
|
-
if (options && options.name) {
|
|
25
|
-
plugin.name = options.name;
|
|
26
|
-
}
|
|
27
|
-
return plugin;
|
|
28
|
-
};
|
|
29
|
-
exports.createContextPlugin = createContextPlugin;
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=ContextPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","ContextPlugin","Plugin","type","constructor","callable","_callable","apply","context","Error","exports","createContextPlugin","options","plugin","name"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { 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\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,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;AAMM,MAAMU,mBAAmB,GAAGA,CAC/BN,QAAkC,EAClCO,OAA8B,KACX;EACnB,MAAMC,MAAM,GAAG,IAAIZ,aAAa,CAAII,QAAQ,CAAC;EAC7C,IAAIO,OAAO,IAAIA,OAAO,CAACE,IAAI,EAAE;IACzBD,MAAM,CAACC,IAAI,GAAGF,OAAO,CAACE,IAAI;EAC9B;EACA,OAAOD,MAAM;AACjB,CAAC;AAACH,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 * Wait for property to be defined on the object and then execute the callable.\n * In case of multiple objects defined, wait for all of them.\n */\n waitFor: <T extends Context = Context>(\n obj: string[] | string,\n cb: (context: T) => void\n ) => void;\n /**\n * Benchmark instance to help determine possible bugs and slow code.\n */\n benchmark: Benchmark;\n /**\n * Compressor instance to compress and decompress the data.\n */\n compressor: ICompressor;\n}\n"],"mappings":"","ignoreList":[]}
|