@webiny/api 0.0.0-unstable.1e66d121db

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Context.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { Context as ContextInterface } from "./types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { PluginCollection } from "@webiny/plugins/types";
4
+ export interface ContextParams {
5
+ plugins?: PluginCollection;
6
+ WEBINY_VERSION: string;
7
+ }
8
+ export declare class Context implements ContextInterface {
9
+ _result: any;
10
+ args: any;
11
+ readonly plugins: PluginsContainer;
12
+ readonly WEBINY_VERSION: string;
13
+ private readonly waiters;
14
+ constructor(params: ContextParams);
15
+ getResult(): any;
16
+ hasResult(): boolean;
17
+ setResult(value: any): void;
18
+ waitFor<T extends ContextInterface = ContextInterface>(obj: string | string[], cb: (context: T) => void): void;
19
+ }
package/Context.js ADDED
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Context = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class Context {
15
+ constructor(params) {
16
+ (0, _defineProperty2.default)(this, "_result", void 0);
17
+ (0, _defineProperty2.default)(this, "args", void 0);
18
+ (0, _defineProperty2.default)(this, "plugins", void 0);
19
+ (0, _defineProperty2.default)(this, "WEBINY_VERSION", void 0);
20
+ (0, _defineProperty2.default)(this, "waiters", []);
21
+ const {
22
+ plugins,
23
+ WEBINY_VERSION
24
+ } = params;
25
+ this.plugins = new _plugins.PluginsContainer(plugins || []);
26
+ this.WEBINY_VERSION = WEBINY_VERSION;
27
+ }
28
+
29
+ getResult() {
30
+ return this._result;
31
+ }
32
+
33
+ hasResult() {
34
+ return !!this._result;
35
+ }
36
+
37
+ setResult(value) {
38
+ this._result = value;
39
+ }
40
+
41
+ waitFor(obj, cb) {
42
+ const initialTargets = Array.isArray(obj) ? obj : [obj];
43
+ const targets = [];
44
+ /**
45
+ * We go only through the first level properties
46
+ */
47
+
48
+ for (const key in initialTargets) {
49
+ const target = initialTargets[key];
50
+ /**
51
+ * If property already exists, there is no need to wait for it, so we just continue the loop.
52
+ * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.
53
+ */
54
+
55
+ if (this[target]) {
56
+ continue;
57
+ } else if (typeof target !== "string") {
58
+ continue;
59
+ }
60
+ /**
61
+ * Since there is no property, we must define it with its setter and getter.
62
+ * We could not know when it got defined otherwise.
63
+ */
64
+
65
+
66
+ Object.defineProperty(this, target, {
67
+ /**
68
+ * Setter sets the given value to this object.
69
+ * We cannot set it on exact property name it is defined because it would go into loop of setting itself.
70
+ * And that is why we add __ around the property name.
71
+ */
72
+ set: value => {
73
+ const newTargetKey = `__${target}__`;
74
+ this[newTargetKey] = value;
75
+ /**
76
+ * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.
77
+ */
78
+
79
+ for (const waiter of this.waiters) {
80
+ if (waiter.targets.includes(target) === false) {
81
+ continue;
82
+ }
83
+ /**
84
+ * Remove currently set property so we know if there are any more to be waited for.
85
+ */
86
+
87
+
88
+ waiter.targets = waiter.targets.filter(t => t !== target);
89
+ /**
90
+ * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.
91
+ */
92
+
93
+ if (waiter.targets.length > 0) {
94
+ continue;
95
+ }
96
+ /**
97
+ * And if there is nothing more to be waited for, we execute the callable.
98
+ * Note that this callable is not async.
99
+ */
100
+
101
+
102
+ waiter.cb(this);
103
+ }
104
+ },
105
+
106
+ /**
107
+ * As we have set property with __ around it, we must get it as well.
108
+ */
109
+ get: () => {
110
+ const newTargetKey = `__${target}__`;
111
+ return this[newTargetKey];
112
+ },
113
+ configurable: false
114
+ });
115
+ /**
116
+ * We add the target to be awaited.
117
+ */
118
+
119
+ targets.push(target);
120
+ }
121
+ /**
122
+ * If there are no targets to be awaited, just fire the callable.
123
+ */
124
+
125
+
126
+ if (targets.length === 0) {
127
+ cb(this);
128
+ return;
129
+ }
130
+ /**
131
+ * Otherwise add the waiter for the target properties.
132
+ */
133
+
134
+
135
+ this.waiters.push({
136
+ targets,
137
+
138
+ /**
139
+ * TODO @ts-refactor
140
+ * Problem with possible subtype initialization
141
+ */
142
+ // @ts-ignore
143
+ cb
144
+ });
145
+ }
146
+
147
+ }
148
+
149
+ exports.Context = Context;
package/Context.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Context","constructor","params","plugins","WEBINY_VERSION","PluginsContainer","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","waiters","includes","filter","t","length","get","configurable","push"],"sources":["Context.ts"],"sourcesContent":["import { Context as ContextInterface } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\n\ninterface Waiter {\n targets: string[];\n cb: (context: ContextInterface) => void;\n}\n\nexport interface ContextParams {\n plugins?: PluginCollection;\n WEBINY_VERSION: string;\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\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, WEBINY_VERSION } = params;\n this.plugins = new PluginsContainer(plugins || []);\n this.WEBINY_VERSION = WEBINY_VERSION;\n }\n\n public getResult(): any {\n return this._result;\n }\n\n public hasResult(): boolean {\n return !!this._result;\n }\n\n public setResult(value: any): void {\n this._result = value;\n }\n\n public waitFor<T extends ContextInterface = ContextInterface>(\n obj: string | string[],\n cb: (context: T) => void\n ): void {\n const initialTargets = Array.isArray(obj) ? obj : [obj];\n const targets: string[] = [];\n /**\n * We go only through the first level properties\n */\n for (const key in initialTargets) {\n const target = initialTargets[key] as keyof this;\n /**\n * If property already exists, there is no need to wait for it, so we just continue the loop.\n * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.\n */\n if (this[target]) {\n continue;\n } else if (typeof target !== \"string\") {\n continue;\n }\n /**\n * Since there is no property, we must define it with its setter and getter.\n * We could not know when it got defined otherwise.\n */\n Object.defineProperty(this, target, {\n /**\n * Setter sets the given value to this object.\n * We cannot set it on exact property name it is defined because it would go into loop of setting itself.\n * And that is why we add __ around the property name.\n */\n set: (value: any) => {\n const newTargetKey = `__${target}__` as keyof this;\n this[newTargetKey] = value;\n /**\n * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.\n */\n for (const waiter of this.waiters) {\n if (waiter.targets.includes(target) === false) {\n continue;\n }\n /**\n * Remove currently set property so we know if there are any more to be waited for.\n */\n waiter.targets = waiter.targets.filter(t => t !== target);\n /**\n * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.\n */\n if (waiter.targets.length > 0) {\n continue;\n }\n /**\n * And if there is nothing more to be waited for, we execute the callable.\n * Note that this callable is not async.\n */\n waiter.cb(this);\n }\n },\n /**\n * As we have set property with __ around it, we must get it as well.\n */\n get: (): any => {\n const newTargetKey = `__${target}__` as keyof this;\n return this[newTargetKey];\n },\n configurable: false\n });\n /**\n * We add the target to be awaited.\n */\n targets.push(target as string);\n }\n /**\n * If there are no targets to be awaited, just fire the callable.\n */\n if (targets.length === 0) {\n cb(this as any);\n return;\n }\n /**\n * Otherwise add the waiter for the target properties.\n */\n this.waiters.push({\n targets,\n /**\n * TODO @ts-refactor\n * Problem with possible subtype initialization\n */\n // @ts-ignore\n cb\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;;AAYO,MAAMA,OAAN,CAA0C;EAQtCC,WAAW,CAACC,MAAD,EAAwB;IAAA;IAAA;IAAA;IAAA;IAAA,+CAFL,EAEK;IACtC,MAAM;MAAEC,OAAF;MAAWC;IAAX,IAA8BF,MAApC;IACA,KAAKC,OAAL,GAAe,IAAIE,yBAAJ,CAAqBF,OAAO,IAAI,EAAhC,CAAf;IACA,KAAKC,cAAL,GAAsBA,cAAtB;EACH;;EAEME,SAAS,GAAQ;IACpB,OAAO,KAAKC,OAAZ;EACH;;EAEMC,SAAS,GAAY;IACxB,OAAO,CAAC,CAAC,KAAKD,OAAd;EACH;;EAEME,SAAS,CAACC,KAAD,EAAmB;IAC/B,KAAKH,OAAL,GAAeG,KAAf;EACH;;EAEMC,OAAO,CACVC,GADU,EAEVC,EAFU,EAGN;IACJ,MAAMC,cAAc,GAAGC,KAAK,CAACC,OAAN,CAAcJ,GAAd,IAAqBA,GAArB,GAA2B,CAACA,GAAD,CAAlD;IACA,MAAMK,OAAiB,GAAG,EAA1B;IACA;AACR;AACA;;IACQ,KAAK,MAAMC,GAAX,IAAkBJ,cAAlB,EAAkC;MAC9B,MAAMK,MAAM,GAAGL,cAAc,CAACI,GAAD,CAA7B;MACA;AACZ;AACA;AACA;;MACY,IAAI,KAAKC,MAAL,CAAJ,EAAkB;QACd;MACH,CAFD,MAEO,IAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;QACnC;MACH;MACD;AACZ;AACA;AACA;;;MACYC,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4BF,MAA5B,EAAoC;QAChC;AAChB;AACA;AACA;AACA;QACgBG,GAAG,EAAGZ,KAAD,IAAgB;UACjB,MAAMa,YAAY,GAAI,KAAIJ,MAAO,IAAjC;UACA,KAAKI,YAAL,IAAqBb,KAArB;UACA;AACpB;AACA;;UACoB,KAAK,MAAMc,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;YAC/B,IAAID,MAAM,CAACP,OAAP,CAAeS,QAAf,CAAwBP,MAAxB,MAAoC,KAAxC,EAA+C;cAC3C;YACH;YACD;AACxB;AACA;;;YACwBK,MAAM,CAACP,OAAP,GAAiBO,MAAM,CAACP,OAAP,CAAeU,MAAf,CAAsBC,CAAC,IAAIA,CAAC,KAAKT,MAAjC,CAAjB;YACA;AACxB;AACA;;YACwB,IAAIK,MAAM,CAACP,OAAP,CAAeY,MAAf,GAAwB,CAA5B,EAA+B;cAC3B;YACH;YACD;AACxB;AACA;AACA;;;YACwBL,MAAM,CAACX,EAAP,CAAU,IAAV;UACH;QACJ,CAhC+B;;QAiChC;AAChB;AACA;QACgBiB,GAAG,EAAE,MAAW;UACZ,MAAMP,YAAY,GAAI,KAAIJ,MAAO,IAAjC;UACA,OAAO,KAAKI,YAAL,CAAP;QACH,CAvC+B;QAwChCQ,YAAY,EAAE;MAxCkB,CAApC;MA0CA;AACZ;AACA;;MACYd,OAAO,CAACe,IAAR,CAAab,MAAb;IACH;IACD;AACR;AACA;;;IACQ,IAAIF,OAAO,CAACY,MAAR,KAAmB,CAAvB,EAA0B;MACtBhB,EAAE,CAAC,IAAD,CAAF;MACA;IACH;IACD;AACR;AACA;;;IACQ,KAAKY,OAAL,CAAaO,IAAb,CAAkB;MACdf,OADc;;MAEd;AACZ;AACA;AACA;MACY;MACAJ;IAPc,CAAlB;EASH;;AApH4C"}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @webiny/api
2
+ [![](https://img.shields.io/npm/dw/@webiny/api.svg)](https://www.npmjs.com/package/@webiny/api)
3
+ [![](https://img.shields.io/npm/v/@webiny/api.svg)](https://www.npmjs.com/package/@webiny/api)
4
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
+
7
+ ## Install
8
+ ```
9
+ npm install --save @webiny/api
10
+ ```
11
+
12
+ Or if you prefer yarn:
13
+ ```
14
+ yarn add @webiny/api
15
+ ```
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./Context";
2
+ export * from "./plugins/ContextPlugin";
package/index.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _Context = require("./Context");
8
+
9
+ Object.keys(_Context).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _Context[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Context[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _ContextPlugin = require("./plugins/ContextPlugin");
21
+
22
+ Object.keys(_ContextPlugin).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _ContextPlugin[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _ContextPlugin[key];
29
+ }
30
+ });
31
+ });
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/Context\";\nexport * from \"~/plugins/ContextPlugin\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@webiny/api",
3
+ "version": "0.0.0-unstable.1e66d121db",
4
+ "main": "index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/webiny/webiny-js.git"
8
+ },
9
+ "description": "Core package for all of our API packages.",
10
+ "contributors": [
11
+ "Bruno Zorić <bruno@webiny.com>"
12
+ ],
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "@babel/runtime": "7.19.0",
16
+ "@webiny/plugins": "0.0.0-unstable.1e66d121db"
17
+ },
18
+ "devDependencies": {
19
+ "@babel/cli": "^7.19.3",
20
+ "@babel/core": "^7.19.3",
21
+ "@babel/preset-env": "^7.19.4",
22
+ "@babel/preset-typescript": "^7.18.6",
23
+ "@webiny/cli": "^0.0.0-unstable.1e66d121db",
24
+ "@webiny/project-utils": "^0.0.0-unstable.1e66d121db",
25
+ "rimraf": "^3.0.2",
26
+ "ttypescript": "^1.5.13",
27
+ "typescript": "4.7.4"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "directory": "dist"
32
+ },
33
+ "scripts": {
34
+ "build": "yarn webiny run build",
35
+ "watch": "yarn webiny run watch"
36
+ },
37
+ "gitHead": "b670bf27c5039de1a2b0be764a09ba4cb94ad5e2"
38
+ }
@@ -0,0 +1,12 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { Context } from "../types";
3
+ export interface ContextPluginCallable<T extends Context = Context> {
4
+ (context: T): void | Promise<void>;
5
+ }
6
+ export declare class ContextPlugin<T extends Context = Context> extends Plugin {
7
+ static readonly type: string;
8
+ private readonly _callable;
9
+ constructor(callable: ContextPluginCallable<T>);
10
+ apply(context: T): Promise<void>;
11
+ }
12
+ export declare const createContextPlugin: <T extends Context = Context>(callable: ContextPluginCallable<T>) => ContextPlugin<T>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createContextPlugin = exports.ContextPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class ContextPlugin extends _plugins.Plugin {
15
+ constructor(callable) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "_callable", void 0);
18
+ this._callable = callable;
19
+ }
20
+
21
+ async apply(context) {
22
+ if (typeof this._callable !== "function") {
23
+ throw Error(`Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the "apply" method.`);
24
+ }
25
+
26
+ return this._callable(context);
27
+ }
28
+
29
+ }
30
+
31
+ exports.ContextPlugin = ContextPlugin;
32
+ (0, _defineProperty2.default)(ContextPlugin, "type", "context");
33
+
34
+ const createContextPlugin = callable => {
35
+ return new ContextPlugin(callable);
36
+ };
37
+
38
+ exports.createContextPlugin = createContextPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ContextPlugin","Plugin","constructor","callable","_callable","apply","context","Error","createContextPlugin"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface ContextPluginCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class ContextPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"context\";\n private readonly _callable: ContextPluginCallable<T>;\n\n constructor(callable: ContextPluginCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n): ContextPlugin<T> => {\n return new ContextPlugin<T>(callable);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAMA,aAAN,SAAyDC,eAAzD,CAAgE;EAInEC,WAAW,CAACC,QAAD,EAAqC;IAC5C;IAD4C;IAE5C,KAAKC,SAAL,GAAiBD,QAAjB;EACH;;EAEiB,MAALE,KAAK,CAACC,OAAD,EAA4B;IAC1C,IAAI,OAAO,KAAKF,SAAZ,KAA0B,UAA9B,EAA0C;MACtC,MAAMG,KAAK,CACN,uIADM,CAAX;IAGH;;IAED,OAAO,KAAKH,SAAL,CAAeE,OAAf,CAAP;EACH;;AAjBkE;;;8BAA1DN,a,UACsC,S;;AAmB5C,MAAMQ,mBAAmB,GAC5BL,QAD+B,IAEZ;EACnB,OAAO,IAAIH,aAAJ,CAAqBG,QAArB,CAAP;AACH,CAJM"}
package/types.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ /**
3
+ * The main context which is constructed on every request.
4
+ * All other contexts should extend or augment this one.
5
+ */
6
+ export interface Context {
7
+ plugins: PluginsContainer;
8
+ args: any;
9
+ readonly WEBINY_VERSION: string;
10
+ /**
11
+ * Not to be used outside of Webiny internal code.
12
+ * @internal
13
+ */
14
+ hasResult: () => boolean;
15
+ /**
16
+ * Not to be used outside of Webiny internal code.
17
+ * @internal
18
+ *
19
+ * @private
20
+ */
21
+ _result?: any;
22
+ /**
23
+ * Not to be used outside of Webiny internal code.
24
+ * @internal
25
+ */
26
+ setResult: (value: any) => void;
27
+ /**
28
+ * Not to be used outside of Webiny internal code.
29
+ * @internal
30
+ */
31
+ getResult: () => void;
32
+ /**
33
+ * Wait for property to be defined on the object and then execute the callable.
34
+ * In case of multiple objects defined, wait for all of them.
35
+ */
36
+ waitFor: <T extends Context = Context>(obj: string[] | string, cb: (context: T) => void) => void;
37
+ }
package/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\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 args: any;\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?: any;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n setResult: (value: any) => 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"],"mappings":""}