@webiny/handler 6.6.0-alpha.0 → 6.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ResponseHeaders.js","sources":["../src/ResponseHeaders.ts"],"sourcesContent":["import type * as http from \"http\";\n\ntype ExtraHeaders = {\n \"content-type\"?: string | undefined;\n \"x-webiny-version\"?: http.OutgoingHttpHeader | undefined;\n};\n\ntype AllHeaders = http.OutgoingHttpHeaders & ExtraHeaders;\n\nexport type StandardHeaderValue = http.OutgoingHttpHeader | undefined;\n\n// Extract known standard headers, and remove all non-string keys.\nexport type StandardHeaders = {\n [K in keyof AllHeaders as string extends K\n ? never\n : number extends K\n ? never\n : K]: http.OutgoingHttpHeaders[K];\n} & {\n [name: string]: StandardHeaderValue;\n};\n\nfunction isFunction<T>(setter: unknown): setter is (value: T) => T {\n return typeof setter === \"function\";\n}\n\ntype Setter<T> = ((value: T) => T) | T;\n\nexport class ResponseHeaders {\n private readonly headers = new Map<keyof StandardHeaders, StandardHeaderValue>();\n\n private constructor(initialHeaders?: StandardHeaders) {\n if (initialHeaders) {\n (Object.keys(initialHeaders) as Array<keyof StandardHeaders>).forEach(key => {\n this.headers.set(key, initialHeaders[key]);\n });\n }\n }\n\n set<T extends keyof StandardHeaders>(header: T, setter: Setter<StandardHeaders[T]>) {\n if (isFunction<StandardHeaders[T]>(setter)) {\n const previousValue = this.headers.get(header) as StandardHeaders[T];\n const newValue = setter(previousValue);\n this.headers.set(header, newValue);\n return this;\n }\n\n this.headers.set(header, setter);\n\n return this;\n }\n\n merge(headers: ResponseHeaders) {\n return ResponseHeaders.create({ ...this.getHeaders(), ...headers.getHeaders() });\n }\n\n getHeaders() {\n return Object.fromEntries(this.headers);\n }\n\n static create(initialHeaders?: StandardHeaders) {\n return new ResponseHeaders(initialHeaders);\n }\n}\n"],"names":["isFunction","setter","ResponseHeaders","initialHeaders","Map","Object","key","header","previousValue","newValue","headers"],"mappings":"AAsBA,SAASA,WAAcC,MAAe;IAClC,OAAO,AAAkB,cAAlB,OAAOA;AAClB;AAIO,MAAMC;IAGT,YAAoBC,cAAgC,CAAE;aAFrC,OAAO,GAAG,IAAIC;QAG3B,IAAID,gBACCE,OAAO,IAAI,CAACF,gBAAiD,OAAO,CAACG,CAAAA;YAClE,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA,KAAKH,cAAc,CAACG,IAAI;QAC7C;IAER;IAEA,IAAqCC,MAAS,EAAEN,MAAkC,EAAE;QAChF,IAAID,WAA+BC,SAAS;YACxC,MAAMO,gBAAgB,IAAI,CAAC,OAAO,CAAC,GAAG,CAACD;YACvC,MAAME,WAAWR,OAAOO;YACxB,IAAI,CAAC,OAAO,CAAC,GAAG,CAACD,QAAQE;YACzB,OAAO,IAAI;QACf;QAEA,IAAI,CAAC,OAAO,CAAC,GAAG,CAACF,QAAQN;QAEzB,OAAO,IAAI;IACf;IAEA,MAAMS,OAAwB,EAAE;QAC5B,OAAOR,gBAAgB,MAAM,CAAC;YAAE,GAAG,IAAI,CAAC,UAAU,EAAE;YAAE,GAAGQ,QAAQ,UAAU,EAAE;QAAC;IAClF;IAEA,aAAa;QACT,OAAOL,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO;IAC1C;IAEA,OAAO,OAAOF,cAAgC,EAAE;QAC5C,OAAO,IAAID,gBAAgBC;IAC/B;AACJ"}
1
+ {"version":3,"file":"ResponseHeaders.js","sources":["../src/ResponseHeaders.ts"],"sourcesContent":["import type * as http from \"http\";\n\ntype ExtraHeaders = {\n \"content-type\"?: string | undefined;\n \"x-webiny-version\"?: http.OutgoingHttpHeader | undefined;\n};\n\ntype AllHeaders = http.OutgoingHttpHeaders & ExtraHeaders;\n\nexport type StandardHeaderValue = http.OutgoingHttpHeader | undefined;\n\n// Extract known standard headers, and remove all non-string keys.\nexport type StandardHeaders = {\n [\n K in keyof AllHeaders as string extends K ? never : number extends K ? never : K\n ]: http.OutgoingHttpHeaders[K];\n} & {\n [name: string]: StandardHeaderValue;\n};\n\nfunction isFunction<T>(setter: unknown): setter is (value: T) => T {\n return typeof setter === \"function\";\n}\n\ntype Setter<T> = ((value: T) => T) | T;\n\nexport class ResponseHeaders {\n private readonly headers = new Map<keyof StandardHeaders, StandardHeaderValue>();\n\n private constructor(initialHeaders?: StandardHeaders) {\n if (initialHeaders) {\n (Object.keys(initialHeaders) as Array<keyof StandardHeaders>).forEach(key => {\n this.headers.set(key, initialHeaders[key]);\n });\n }\n }\n\n set<T extends keyof StandardHeaders>(header: T, setter: Setter<StandardHeaders[T]>) {\n if (isFunction<StandardHeaders[T]>(setter)) {\n const previousValue = this.headers.get(header) as StandardHeaders[T];\n const newValue = setter(previousValue);\n this.headers.set(header, newValue);\n return this;\n }\n\n this.headers.set(header, setter);\n\n return this;\n }\n\n merge(headers: ResponseHeaders) {\n return ResponseHeaders.create({ ...this.getHeaders(), ...headers.getHeaders() });\n }\n\n getHeaders() {\n return Object.fromEntries(this.headers);\n }\n\n static create(initialHeaders?: StandardHeaders) {\n return new ResponseHeaders(initialHeaders);\n }\n}\n"],"names":["isFunction","setter","ResponseHeaders","initialHeaders","Map","Object","key","header","previousValue","newValue","headers"],"mappings":"AAoBA,SAASA,WAAcC,MAAe;IAClC,OAAO,AAAkB,cAAlB,OAAOA;AAClB;AAIO,MAAMC;IAGT,YAAoBC,cAAgC,CAAE;aAFrC,OAAO,GAAG,IAAIC;QAG3B,IAAID,gBACCE,OAAO,IAAI,CAACF,gBAAiD,OAAO,CAACG,CAAAA;YAClE,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA,KAAKH,cAAc,CAACG,IAAI;QAC7C;IAER;IAEA,IAAqCC,MAAS,EAAEN,MAAkC,EAAE;QAChF,IAAID,WAA+BC,SAAS;YACxC,MAAMO,gBAAgB,IAAI,CAAC,OAAO,CAAC,GAAG,CAACD;YACvC,MAAME,WAAWR,OAAOO;YACxB,IAAI,CAAC,OAAO,CAAC,GAAG,CAACD,QAAQE;YACzB,OAAO,IAAI;QACf;QAEA,IAAI,CAAC,OAAO,CAAC,GAAG,CAACF,QAAQN;QAEzB,OAAO,IAAI;IACf;IAEA,MAAMS,OAAwB,EAAE;QAC5B,OAAOR,gBAAgB,MAAM,CAAC;YAAE,GAAG,IAAI,CAAC,UAAU,EAAE;YAAE,GAAGQ,QAAQ,UAAU,EAAE;QAAC;IAClF;IAEA,aAAa;QACT,OAAOL,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO;IAC1C;IAEA,OAAO,OAAOF,cAAgC,EAAE;QAC5C,OAAO,IAAID,gBAAgBC;IAC/B;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler",
3
- "version": "6.6.0-alpha.0",
3
+ "version": "6.6.0-alpha.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -16,15 +16,15 @@
16
16
  ],
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@webiny/di": "1.0.2",
20
- "@webiny/feature": "6.6.0-alpha.0",
21
- "@webiny/plugins": "6.6.0-alpha.0"
19
+ "@webiny/di": "1.1.0",
20
+ "@webiny/feature": "6.6.0-alpha.1",
21
+ "@webiny/plugins": "6.6.0-alpha.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@webiny/build-tools": "6.6.0-alpha.0",
24
+ "@webiny/build-tools": "6.6.0-alpha.1",
25
25
  "rimraf": "6.1.3",
26
26
  "typescript": "7.0.2",
27
- "vitest": "4.1.10"
27
+ "vitest": "4.1.11"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"
@@ -13,10 +13,10 @@ export declare class RegisterExtensionPlugin<C extends Context = Context> extend
13
13
  export declare const createRegisterExtensionPlugin: <C extends Context = Context>(cb: IRegisterExtensionPluginCb<C>) => RegisterExtensionPlugin<C>;
14
14
  /**
15
15
  * Apply RegisterExtensionPlugins at register() time — synchronously with the request container,
16
- * BEFORE any RequestContextInitializer runs. Each plugin's callback only does DI registration via
16
+ * BEFORE anything lists the model set. Each plugin's callback only does DI registration via
17
17
  * registerExtension(ctx.container, ...) (feature/decorator/registration), which is register-time
18
- * safe. Doing this early is important for code-defined CMS models (ModelFactory): a later
19
- * initializer (e.g. ACO) lists + caches the model set per request, so any model registered after
20
- * that as happened when extensions ran via the post-auth initializer — was silently missing.
18
+ * safe. Doing this early is important for code-defined CMS models (ModelFactory): the first
19
+ * request-time listing (e.g. the ACO folder schema) caches the model set for the rest of the
20
+ * request, so any model registered after that point is silently missing.
21
21
  */
22
22
  export declare function registerExtensions(container: Container, plugins: unknown | unknown[]): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"plugins/RegisterExtensionPlugin.js","sources":["../../src/plugins/RegisterExtensionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Container } from \"@webiny/di\";\nimport type { Context } from \"~/types.js\";\n\nexport interface IRegisterExtensionPluginCb<C extends Context = Context> {\n (context: C): Promise<void> | void;\n}\n\nexport class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.register.extension\";\n\n public constructor(private readonly cb: IRegisterExtensionPluginCb<C>) {\n super();\n }\n\n public apply(context: C): Promise<void> | void {\n return this.cb(context);\n }\n}\n\nexport const createRegisterExtensionPlugin = <C extends Context = Context>(\n cb: IRegisterExtensionPluginCb<C>\n) => {\n return new RegisterExtensionPlugin<C>(cb);\n};\n\n/**\n * Apply RegisterExtensionPlugins at register() time — synchronously with the request container,\n * BEFORE any RequestContextInitializer runs. Each plugin's callback only does DI registration via\n * registerExtension(ctx.container, ...) (feature/decorator/registration), which is register-time\n * safe. Doing this early is important for code-defined CMS models (ModelFactory): a later\n * initializer (e.g. ACO) lists + caches the model set per request, so any model registered after\n * that as happened when extensions ran via the post-auth initializer — was silently missing.\n */\nexport async function registerExtensions(\n container: Container,\n plugins: unknown | unknown[]\n): Promise<void> {\n const flat = [plugins].flat(Infinity as 1).filter(Boolean) as RegisterExtensionPlugin[];\n for (const plugin of flat) {\n if (plugin?.type === RegisterExtensionPlugin.type && typeof plugin.apply === \"function\") {\n await plugin.apply({ container } as unknown as Context);\n }\n }\n}\n"],"names":["RegisterExtensionPlugin","Plugin","cb","context","createRegisterExtensionPlugin","registerExtensions","container","plugins","flat","Infinity","Boolean","plugin"],"mappings":";AAQO,MAAMA,gCAA6DC;;aACtC,IAAI,GAAW;;IAE/C,YAAoCC,EAAiC,CAAE;QACnE,KAAK,SAD2BA,EAAE,GAAFA;IAEpC;IAEO,MAAMC,OAAU,EAAwB;QAC3C,OAAO,IAAI,CAAC,EAAE,CAACA;IACnB;AACJ;AAEO,MAAMC,gCAAgC,CACzCF,KAEO,IAAIF,wBAA2BE;AAWnC,eAAeG,mBAClBC,SAAoB,EACpBC,OAA4B;IAE5B,MAAMC,OAAO;QAACD;KAAQ,CAAC,IAAI,CAACE,OAAe,MAAM,CAACC;IAClD,KAAK,MAAMC,UAAUH,KACjB,IAAIG,QAAQ,SAASX,wBAAwB,IAAI,IAAI,AAAwB,cAAxB,OAAOW,OAAO,KAAK,EACpE,MAAMA,OAAO,KAAK,CAAC;QAAEL;IAAU;AAG3C"}
1
+ {"version":3,"file":"plugins/RegisterExtensionPlugin.js","sources":["../../src/plugins/RegisterExtensionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Container } from \"@webiny/di\";\nimport type { Context } from \"~/types.js\";\n\nexport interface IRegisterExtensionPluginCb<C extends Context = Context> {\n (context: C): Promise<void> | void;\n}\n\nexport class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.register.extension\";\n\n public constructor(private readonly cb: IRegisterExtensionPluginCb<C>) {\n super();\n }\n\n public apply(context: C): Promise<void> | void {\n return this.cb(context);\n }\n}\n\nexport const createRegisterExtensionPlugin = <C extends Context = Context>(\n cb: IRegisterExtensionPluginCb<C>\n) => {\n return new RegisterExtensionPlugin<C>(cb);\n};\n\n/**\n * Apply RegisterExtensionPlugins at register() time — synchronously with the request container,\n * BEFORE anything lists the model set. Each plugin's callback only does DI registration via\n * registerExtension(ctx.container, ...) (feature/decorator/registration), which is register-time\n * safe. Doing this early is important for code-defined CMS models (ModelFactory): the first\n * request-time listing (e.g. the ACO folder schema) caches the model set for the rest of the\n * request, so any model registered after that point is silently missing.\n */\nexport async function registerExtensions(\n container: Container,\n plugins: unknown | unknown[]\n): Promise<void> {\n const flat = [plugins].flat(Infinity as 1).filter(Boolean) as RegisterExtensionPlugin[];\n for (const plugin of flat) {\n if (plugin?.type === RegisterExtensionPlugin.type && typeof plugin.apply === \"function\") {\n await plugin.apply({ container } as unknown as Context);\n }\n }\n}\n"],"names":["RegisterExtensionPlugin","Plugin","cb","context","createRegisterExtensionPlugin","registerExtensions","container","plugins","flat","Infinity","Boolean","plugin"],"mappings":";AAQO,MAAMA,gCAA6DC;;aACtC,IAAI,GAAW;;IAE/C,YAAoCC,EAAiC,CAAE;QACnE,KAAK,SAD2BA,EAAE,GAAFA;IAEpC;IAEO,MAAMC,OAAU,EAAwB;QAC3C,OAAO,IAAI,CAAC,EAAE,CAACA;IACnB;AACJ;AAEO,MAAMC,gCAAgC,CACzCF,KAEO,IAAIF,wBAA2BE;AAWnC,eAAeG,mBAClBC,SAAoB,EACpBC,OAA4B;IAE5B,MAAMC,OAAO;QAACD;KAAQ,CAAC,IAAI,CAACE,KAAQ,EAAO,MAAM,CAACC;IAClD,KAAK,MAAMC,UAAUH,KACjB,IAAIG,QAAQ,SAASX,wBAAwB,IAAI,IAAI,AAAwB,cAAxB,OAAOW,OAAO,KAAK,EACpE,MAAMA,OAAO,KAAK,CAAC;QAAEL;IAAU;AAG3C"}