@webiny/handler 5.29.0-beta.1 → 5.30.0-beta.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/middleware.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare const _default: (functions?: Array<Function>) => Function;
2
1
  /**
3
2
  * Compose a single middleware from the array of middleware functions
4
3
  */
4
+ declare const _default: (functions?: Array<Function>) => Function;
5
5
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler",
3
- "version": "5.29.0-beta.1",
3
+ "version": "5.30.0-beta.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,18 +14,18 @@
14
14
  "Adrian Smijulj <adrian@webiny.com>"
15
15
  ],
16
16
  "dependencies": {
17
- "@babel/runtime": "7.18.3",
18
- "@webiny/plugins": "5.29.0-beta.1"
17
+ "@babel/runtime": "7.18.6",
18
+ "@webiny/plugins": "5.30.0-beta.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@babel/cli": "^7.16.0",
22
22
  "@babel/core": "^7.16.0",
23
23
  "@babel/preset-env": "^7.16.4",
24
- "@webiny/cli": "^5.29.0-beta.1",
25
- "@webiny/project-utils": "^5.29.0-beta.1",
24
+ "@webiny/cli": "^5.30.0-beta.0",
25
+ "@webiny/project-utils": "^5.30.0-beta.0",
26
26
  "rimraf": "^3.0.2",
27
27
  "ttypescript": "^1.5.13",
28
- "typescript": "4.5.5"
28
+ "typescript": "4.7.4"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public",
@@ -35,5 +35,5 @@
35
35
  "build": "yarn webiny run build",
36
36
  "watch": "yarn webiny run watch"
37
37
  },
38
- "gitHead": "e4393aa7faa07c7a465ff320d8b4dc51f2f38315"
38
+ "gitHead": "622d120f5637e3ca807b8bfc9ed2cd034ac85fb7"
39
39
  }
@@ -51,10 +51,13 @@ class Context {
51
51
  const target = initialTargets[key];
52
52
  /**
53
53
  * If property already exists, there is no need to wait for it, so we just continue the loop.
54
+ * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.
54
55
  */
55
56
 
56
57
  if (this[target]) {
57
58
  continue;
59
+ } else if (typeof target !== "string") {
60
+ continue;
58
61
  }
59
62
  /**
60
63
  * Since there is no property, we must define it with its setter and getter.
@@ -1 +1 @@
1
- {"version":3,"names":["Context","constructor","params","plugins","args","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, HandlerArgs } 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 args?: HandlerArgs;\n plugins?: PluginCollection;\n WEBINY_VERSION: string;\n}\nexport class Context implements ContextInterface {\n public _result: any;\n public readonly plugins: PluginsContainer;\n public readonly args: HandlerArgs;\n public readonly WEBINY_VERSION: string;\n\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, args, WEBINY_VERSION } = params;\n this.plugins = new PluginsContainer(plugins || []);\n this.args = args || [];\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 */\n if (this[target]) {\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 as string) === 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;;AAaO,MAAMA,OAAN,CAA0C;EAQtCC,WAAW,CAACC,MAAD,EAAwB;IAAA;IAAA;IAAA;IAAA;IAAA,+CAFL,EAEK;IACtC,MAAM;MAAEC,OAAF;MAAWC,IAAX;MAAiBC;IAAjB,IAAoCH,MAA1C;IACA,KAAKC,OAAL,GAAe,IAAIG,yBAAJ,CAAqBH,OAAO,IAAI,EAAhC,CAAf;IACA,KAAKC,IAAL,GAAYA,IAAI,IAAI,EAApB;IACA,KAAKC,cAAL,GAAsBA,cAAtB;EACH;;EAE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+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;;AAlH4C"}
1
+ {"version":3,"names":["Context","constructor","params","plugins","args","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, HandlerArgs } 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 args?: HandlerArgs;\n plugins?: PluginCollection;\n WEBINY_VERSION: string;\n}\nexport class Context implements ContextInterface {\n public _result: any;\n public readonly plugins: PluginsContainer;\n public readonly args: HandlerArgs;\n public readonly WEBINY_VERSION: string;\n\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, args, WEBINY_VERSION } = params;\n this.plugins = new PluginsContainer(plugins || []);\n this.args = args || [];\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;;AAaO,MAAMA,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