@webiny/api-event-handler-core 0.0.0-unstable.0156a4c312

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/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,11 @@
1
+ # @webiny/api-event-handler-core
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/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { registerApiRequestStack } from "./registerApiRequestStack.js";
2
+ export type { RegisterApiRequestStackConfig } from "./registerApiRequestStack.js";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { registerApiRequestStack } from "./registerApiRequestStack.js";
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@webiny/api-event-handler-core",
3
+ "version": "0.0.0-unstable.0156a4c312",
4
+ "type": "module",
5
+ "main": "index.js",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./*": "./*"
9
+ },
10
+ "types": "index.d.ts",
11
+ "description": "Transport-agnostic composition of the Webiny API request stack (registerApiRequestStack).",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/webiny/webiny-js.git"
15
+ },
16
+ "contributors": [
17
+ "Webiny Team"
18
+ ],
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "@webiny/api-aco": "0.0.0-unstable.0156a4c312",
22
+ "@webiny/api-audit-logs": "0.0.0-unstable.0156a4c312",
23
+ "@webiny/api-core": "0.0.0-unstable.0156a4c312",
24
+ "@webiny/api-dashboard": "0.0.0-unstable.0156a4c312",
25
+ "@webiny/api-file-manager": "0.0.0-unstable.0156a4c312",
26
+ "@webiny/api-file-manager-aco": "0.0.0-unstable.0156a4c312",
27
+ "@webiny/api-graphql": "0.0.0-unstable.0156a4c312",
28
+ "@webiny/api-headless-cms": "0.0.0-unstable.0156a4c312",
29
+ "@webiny/api-headless-cms-aco": "0.0.0-unstable.0156a4c312",
30
+ "@webiny/api-headless-cms-scheduler": "0.0.0-unstable.0156a4c312",
31
+ "@webiny/api-headless-cms-tasks": "0.0.0-unstable.0156a4c312",
32
+ "@webiny/api-headless-cms-workflows": "0.0.0-unstable.0156a4c312",
33
+ "@webiny/api-mailer": "0.0.0-unstable.0156a4c312",
34
+ "@webiny/api-record-locking": "0.0.0-unstable.0156a4c312",
35
+ "@webiny/api-scheduler": "0.0.0-unstable.0156a4c312",
36
+ "@webiny/api-website-builder": "0.0.0-unstable.0156a4c312",
37
+ "@webiny/api-website-builder-scheduler": "0.0.0-unstable.0156a4c312",
38
+ "@webiny/api-website-builder-workflows": "0.0.0-unstable.0156a4c312",
39
+ "@webiny/api-websockets": "0.0.0-unstable.0156a4c312",
40
+ "@webiny/api-workflows": "0.0.0-unstable.0156a4c312",
41
+ "@webiny/background-tasks": "0.0.0-unstable.0156a4c312",
42
+ "@webiny/handler": "0.0.0-unstable.0156a4c312",
43
+ "@webiny/webhooks": "0.0.0-unstable.0156a4c312"
44
+ },
45
+ "peerDependencies": {
46
+ "@webiny/di": "^2.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "@webiny/build-tools": "0.0.0-unstable.0156a4c312",
50
+ "@webiny/di": "2.0.0",
51
+ "rimraf": "6.1.3",
52
+ "typescript": "7.0.2",
53
+ "vitest": "5.0.5"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "webiny": {
59
+ "publishFrom": "dist"
60
+ }
61
+ }
@@ -0,0 +1,58 @@
1
+ import type { Container } from "@webiny/di";
2
+ import { registerExtensions } from "@webiny/handler";
3
+ /** Installs a hosting-specific transport adapter into the per-request container at its interleave point. */
4
+ export type TransportRegistrar = (container: Container) => void | Promise<void>;
5
+ export interface RegisterApiRequestStackConfig {
6
+ /**
7
+ * Project-defined extensions, applied at register() time (so extension features β€” including
8
+ * code-defined CMS models β€” are registered before anything lists/caches the model set).
9
+ */
10
+ extensions: () => Parameters<typeof registerExtensions>[1];
11
+ /**
12
+ * Hosting-specific transport adapters, each installed at its exact interleave point in the stack.
13
+ * Every entry follows the same shape: it runs immediately AFTER the transport-agnostic domain
14
+ * Feature has registered its NULL default, and overrides that default (nearest-container-last-wins)
15
+ * with the real adapter. Each is optional β€” omit one for a deployment/transport that lacks that
16
+ * capability. AWS supplies AWS adapters (API Gateway Management API / EventBridge / S3); the
17
+ * standalone server supplies in-process adapters (server WebSockets / Bree / local disk).
18
+ */
19
+ transports?: {
20
+ /**
21
+ * Hosting-specific replacements for api-core defaults, run right after `ApiCoreFeature`:
22
+ * `PublicUrls` (default: every URL unknown), and `EncryptionConfig` / `HashingConfig`
23
+ * (default: read from build params).
24
+ */
25
+ hostingConfig?: TransportRegistrar;
26
+ /**
27
+ * Real-time (WebSockets) transport, run right after `WebsocketsFeature`. Overrides the
28
+ * NullWebsocketsTransport, otherwise every server→client send() is a silent no-op.
29
+ */
30
+ realtime?: TransportRegistrar;
31
+ /**
32
+ * Scheduler transport, run AFTER `SchedulerFeature` and BEFORE `CmsSchedulerFeature`.
33
+ */
34
+ scheduler?: TransportRegistrar;
35
+ /**
36
+ * File-manager storage transport, run AFTER `FileManagerAppFeature` (which registers the
37
+ * AssetDeliveryRoute + NULL asset-delivery impls). Overrides those nulls with real impls and
38
+ * adds the file-operation features.
39
+ */
40
+ fileManager?: TransportRegistrar;
41
+ };
42
+ }
43
+ /**
44
+ * Registers the transport-AGNOSTIC Webiny API request stack: every domain feature + the GraphQL
45
+ * engine, in the correct (order-sensitive) sequence. This is shared by all transport composition
46
+ * packages (`@webiny/api-event-handler-aws`, and the future `-server`) so the feature set and its
47
+ * ordering live in ONE place and can't drift between transports.
48
+ *
49
+ * Transport- and storage-specific pieces are injected via the hooks in {@link RegisterApiRequestStackConfig}
50
+ * at their exact interleave points. The caller is responsible for the ROOT-container transport wiring
51
+ * (HTTP/event transport, auth/tenant loaders, identity provider, DB + storage) before dispatch reaches
52
+ * this per-request stack. That includes the `Logger`: api-core registers none, so a root without one
53
+ * fails the first time anything that logs is built.
54
+ *
55
+ * ORDER IS LOAD-BEARING β€” do not reorder. Notably: extensions must be applied before anything that
56
+ * lists + caches the per-request model set; the GraphQL engine must be registered last.
57
+ */
58
+ export declare function registerApiRequestStack(container: Container, config: RegisterApiRequestStackConfig): Promise<void>;
@@ -0,0 +1,63 @@
1
+ import { registerBuildParams, registerExtensions } from "@webiny/handler";
2
+ import { GraphQLEngineFeature } from "@webiny/api-graphql";
3
+ import { ApiCoreFeature } from "@webiny/api-core";
4
+ import { WcpLicenseLoader } from "@webiny/api-core/features/wcp/WcpLicenseLoader.js";
5
+ import { HeadlessCmsFeature } from "@webiny/api-headless-cms";
6
+ import { AcoHcmsFeature } from "@webiny/api-headless-cms-aco";
7
+ import { HcmsTasksFeature } from "@webiny/api-headless-cms-tasks";
8
+ import { CmsWorkflowsFeature } from "@webiny/api-headless-cms-workflows";
9
+ import { CmsSchedulerFeature } from "@webiny/api-headless-cms-scheduler";
10
+ import { MailerFeature } from "@webiny/api-mailer";
11
+ import { RecordLockingAppFeature } from "@webiny/api-record-locking";
12
+ import { AuditLogsFeature } from "@webiny/api-audit-logs";
13
+ import { DashboardAppFeature } from "@webiny/api-dashboard";
14
+ import { WebhooksFeature } from "@webiny/webhooks/api";
15
+ import { AcoFeature } from "@webiny/api-aco";
16
+ import { BackgroundTasksFeature } from "@webiny/background-tasks/api";
17
+ import { FileManagerAppFeature } from "@webiny/api-file-manager";
18
+ import { FileManagerAcoFeature } from "@webiny/api-file-manager-aco";
19
+ import { WebsiteBuilderFeature } from "@webiny/api-website-builder";
20
+ import { WebsiteBuilderWorkflowsFeature } from "@webiny/api-website-builder-workflows";
21
+ import { WebsiteBuilderSchedulerFeature } from "@webiny/api-website-builder-scheduler";
22
+ import { WebsocketsFeature } from "@webiny/api-websockets";
23
+ import { WorkflowsFeature } from "@webiny/api-workflows";
24
+ import { SchedulerFeature } from "@webiny/api-scheduler";
25
+ async function registerApiRequestStack(container, config) {
26
+ await WcpLicenseLoader.load();
27
+ const extensions = config.extensions();
28
+ await registerBuildParams(container, extensions);
29
+ ApiCoreFeature.register(container, {
30
+ wcpLicense: void 0
31
+ });
32
+ await config.transports?.hostingConfig?.(container);
33
+ HeadlessCmsFeature.register(container, {
34
+ type: "manage"
35
+ });
36
+ AcoFeature.register(container);
37
+ AcoHcmsFeature.register(container);
38
+ HcmsTasksFeature.register(container);
39
+ FileManagerAppFeature.register(container);
40
+ FileManagerAcoFeature.register(container);
41
+ await config.transports?.fileManager?.(container);
42
+ WebsiteBuilderFeature.register(container);
43
+ WebsiteBuilderWorkflowsFeature.register(container);
44
+ WebsiteBuilderSchedulerFeature.register(container);
45
+ WebsocketsFeature.register(container);
46
+ await config.transports?.realtime?.(container);
47
+ MailerFeature.register(container);
48
+ RecordLockingAppFeature.register(container, {});
49
+ AuditLogsFeature.register(container, {});
50
+ DashboardAppFeature.register(container);
51
+ WebhooksFeature.register(container);
52
+ BackgroundTasksFeature.register(container);
53
+ WorkflowsFeature.register(container);
54
+ CmsWorkflowsFeature.register(container);
55
+ SchedulerFeature.register(container);
56
+ await config.transports?.scheduler?.(container);
57
+ CmsSchedulerFeature.register(container);
58
+ await registerExtensions(container, extensions);
59
+ GraphQLEngineFeature.register(container);
60
+ }
61
+ export { registerApiRequestStack };
62
+
63
+ //# sourceMappingURL=registerApiRequestStack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerApiRequestStack.js","sources":["../src/registerApiRequestStack.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { registerBuildParams, registerExtensions } from \"@webiny/handler\";\nimport { GraphQLEngineFeature } from \"@webiny/api-graphql\";\nimport { ApiCoreFeature } from \"@webiny/api-core\";\nimport { WcpLicenseLoader } from \"@webiny/api-core/features/wcp/WcpLicenseLoader.js\";\nimport { HeadlessCmsFeature } from \"@webiny/api-headless-cms\";\nimport { AcoHcmsFeature } from \"@webiny/api-headless-cms-aco\";\nimport { HcmsTasksFeature } from \"@webiny/api-headless-cms-tasks\";\nimport { CmsWorkflowsFeature } from \"@webiny/api-headless-cms-workflows\";\nimport { CmsSchedulerFeature } from \"@webiny/api-headless-cms-scheduler\";\nimport { MailerFeature } from \"@webiny/api-mailer\";\nimport { RecordLockingAppFeature } from \"@webiny/api-record-locking\";\nimport { AuditLogsFeature } from \"@webiny/api-audit-logs\";\nimport { DashboardAppFeature } from \"@webiny/api-dashboard\";\nimport { WebhooksFeature } from \"@webiny/webhooks/api\";\nimport { AcoFeature } from \"@webiny/api-aco\";\nimport { BackgroundTasksFeature } from \"@webiny/background-tasks/api\";\nimport { FileManagerAppFeature } from \"@webiny/api-file-manager\";\nimport { FileManagerAcoFeature } from \"@webiny/api-file-manager-aco\";\nimport { WebsiteBuilderFeature } from \"@webiny/api-website-builder\";\nimport { WebsiteBuilderWorkflowsFeature } from \"@webiny/api-website-builder-workflows\";\nimport { WebsiteBuilderSchedulerFeature } from \"@webiny/api-website-builder-scheduler\";\nimport { WebsocketsFeature } from \"@webiny/api-websockets\";\nimport { WorkflowsFeature } from \"@webiny/api-workflows\";\nimport { SchedulerFeature } from \"@webiny/api-scheduler\";\n\n/** Installs a hosting-specific transport adapter into the per-request container at its interleave point. */\nexport type TransportRegistrar = (container: Container) => void | Promise<void>;\n\nexport interface RegisterApiRequestStackConfig {\n /**\n * Project-defined extensions, applied at register() time (so extension features β€” including\n * code-defined CMS models β€” are registered before anything lists/caches the model set).\n */\n extensions: () => Parameters<typeof registerExtensions>[1];\n /**\n * Hosting-specific transport adapters, each installed at its exact interleave point in the stack.\n * Every entry follows the same shape: it runs immediately AFTER the transport-agnostic domain\n * Feature has registered its NULL default, and overrides that default (nearest-container-last-wins)\n * with the real adapter. Each is optional β€” omit one for a deployment/transport that lacks that\n * capability. AWS supplies AWS adapters (API Gateway Management API / EventBridge / S3); the\n * standalone server supplies in-process adapters (server WebSockets / Bree / local disk).\n */\n transports?: {\n /**\n * Hosting-specific replacements for api-core defaults, run right after `ApiCoreFeature`:\n * `PublicUrls` (default: every URL unknown), and `EncryptionConfig` / `HashingConfig`\n * (default: read from build params).\n */\n hostingConfig?: TransportRegistrar;\n /**\n * Real-time (WebSockets) transport, run right after `WebsocketsFeature`. Overrides the\n * NullWebsocketsTransport, otherwise every serverβ†’client send() is a silent no-op.\n */\n realtime?: TransportRegistrar;\n /**\n * Scheduler transport, run AFTER `SchedulerFeature` and BEFORE `CmsSchedulerFeature`.\n */\n scheduler?: TransportRegistrar;\n /**\n * File-manager storage transport, run AFTER `FileManagerAppFeature` (which registers the\n * AssetDeliveryRoute + NULL asset-delivery impls). Overrides those nulls with real impls and\n * adds the file-operation features.\n */\n fileManager?: TransportRegistrar;\n };\n}\n\n/**\n * Registers the transport-AGNOSTIC Webiny API request stack: every domain feature + the GraphQL\n * engine, in the correct (order-sensitive) sequence. This is shared by all transport composition\n * packages (`@webiny/api-event-handler-aws`, and the future `-server`) so the feature set and its\n * ordering live in ONE place and can't drift between transports.\n *\n * Transport- and storage-specific pieces are injected via the hooks in {@link RegisterApiRequestStackConfig}\n * at their exact interleave points. The caller is responsible for the ROOT-container transport wiring\n * (HTTP/event transport, auth/tenant loaders, identity provider, DB + storage) before dispatch reaches\n * this per-request stack. That includes the `Logger`: api-core registers none, so a root without one\n * fails the first time anything that logs is built.\n *\n * ORDER IS LOAD-BEARING β€” do not reorder. Notably: extensions must be applied before anything that\n * lists + caches the per-request model set; the GraphQL engine must be registered last.\n */\nexport async function registerApiRequestStack(\n container: Container,\n config: RegisterApiRequestStackConfig\n): Promise<void> {\n // Refresh the WCP license BEFORE any feature registers β€” this is the single per-request refresh.\n // register()-time feature-flag checks (e.g. the private-files gate) and WcpContext.canUse* both\n // read it via the process cache (`WcpLicenseProvider.get()` / `WcpLicenseLoader.getCached()`). Runs here\n // β€” the shared request stack both hosting types call β€” so no handler wires it. Process-cached\n // (~5-min TTL) + single-flighted β†’ cheap no-op on warm requests.\n await WcpLicenseLoader.load();\n\n // ── Build params (before ANY feature) ──────────────────────\n // Features gate themselves on FeatureFlags at register() time (AuditLogs, RecordLocking,\n // Workflows, ...), and FeatureFlags is a BuildParam. Registered with the rest of the extensions\n // below, it arrived too late: those gates read `{}`, and a license-granted feature couldn't be\n // disabled from config.\n const extensions = config.extensions();\n await registerBuildParams(container, extensions);\n\n // ── Core API (per-request: EventPublisher + tenant/identity/request contexts must bind to the\n // request child container so per-request event handlers are resolvable) ─────────\n ApiCoreFeature.register(container, { wcpLicense: undefined });\n await config.transports?.hostingConfig?.(container);\n\n // ── CMS ────────────────────────────────────────────────────\n HeadlessCmsFeature.register(container, { type: \"manage\" });\n AcoFeature.register(container);\n AcoHcmsFeature.register(container);\n HcmsTasksFeature.register(container);\n\n // ── File Manager (domain) + storage transport ──────────────\n FileManagerAppFeature.register(container);\n FileManagerAcoFeature.register(container);\n await config.transports?.fileManager?.(container);\n\n // ── Website Builder ────────────────────────────────────────\n WebsiteBuilderFeature.register(container);\n WebsiteBuilderWorkflowsFeature.register(container);\n WebsiteBuilderSchedulerFeature.register(container);\n\n // ── Websockets (domain) + real-time transport ──────────────\n WebsocketsFeature.register(container);\n await config.transports?.realtime?.(container);\n\n // ── Supporting services ────────────────────────────────────\n MailerFeature.register(container);\n RecordLockingAppFeature.register(container, {});\n AuditLogsFeature.register(container, {});\n DashboardAppFeature.register(container);\n WebhooksFeature.register(container);\n BackgroundTasksFeature.register(container);\n\n // ── Workflows ──────────────────────────────────────────────\n WorkflowsFeature.register(container);\n CmsWorkflowsFeature.register(container);\n\n // ── Scheduler + scheduler transport ────────────────────────\n SchedulerFeature.register(container);\n await config.transports?.scheduler?.(container);\n CmsSchedulerFeature.register(container);\n\n // ── Extensions ─────────────────────────────────────────────\n // Apply at register() time so extension features β€” including code-defined CMS models\n // (ModelFactory), e.g. Languages β€” are registered before anything populates ModelCache. Anything\n // reaching the model set through GetModel/ListModels (which go via ModelsFetcher ->\n // ModelCache.getOrSet) caches it for the rest of the request, so a set built before extensions\n // register would be missing their models. Every consumer now resolves models at schema-build or\n // resolver time, i.e. after all registration.\n await registerExtensions(container, extensions);\n\n // ── GraphQL engine (always last) ───────────────────────────\n GraphQLEngineFeature.register(container);\n}\n"],"names":["registerApiRequestStack","container","config","WcpLicenseLoader","extensions","registerBuildParams","ApiCoreFeature","undefined","HeadlessCmsFeature","AcoFeature","AcoHcmsFeature","HcmsTasksFeature","FileManagerAppFeature","FileManagerAcoFeature","WebsiteBuilderFeature","WebsiteBuilderWorkflowsFeature","WebsiteBuilderSchedulerFeature","WebsocketsFeature","MailerFeature","RecordLockingAppFeature","AuditLogsFeature","DashboardAppFeature","WebhooksFeature","BackgroundTasksFeature","WorkflowsFeature","CmsWorkflowsFeature","SchedulerFeature","CmsSchedulerFeature","registerExtensions","GraphQLEngineFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmFO,eAAeA,wBAClBC,SAAoB,EACpBC,MAAqC;IAOrC,MAAMC,iBAAiB,IAAI;IAO3B,MAAMC,aAAaF,OAAO,UAAU;IACpC,MAAMG,oBAAoBJ,WAAWG;IAIrCE,eAAe,QAAQ,CAACL,WAAW;QAAE,YAAYM;IAAU;IAC3D,MAAML,OAAO,UAAU,EAAE,gBAAgBD;IAGzCO,mBAAmB,QAAQ,CAACP,WAAW;QAAE,MAAM;IAAS;IACxDQ,WAAW,QAAQ,CAACR;IACpBS,eAAe,QAAQ,CAACT;IACxBU,iBAAiB,QAAQ,CAACV;IAG1BW,sBAAsB,QAAQ,CAACX;IAC/BY,sBAAsB,QAAQ,CAACZ;IAC/B,MAAMC,OAAO,UAAU,EAAE,cAAcD;IAGvCa,sBAAsB,QAAQ,CAACb;IAC/Bc,+BAA+B,QAAQ,CAACd;IACxCe,+BAA+B,QAAQ,CAACf;IAGxCgB,kBAAkB,QAAQ,CAAChB;IAC3B,MAAMC,OAAO,UAAU,EAAE,WAAWD;IAGpCiB,cAAc,QAAQ,CAACjB;IACvBkB,wBAAwB,QAAQ,CAAClB,WAAW,CAAC;IAC7CmB,iBAAiB,QAAQ,CAACnB,WAAW,CAAC;IACtCoB,oBAAoB,QAAQ,CAACpB;IAC7BqB,gBAAgB,QAAQ,CAACrB;IACzBsB,uBAAuB,QAAQ,CAACtB;IAGhCuB,iBAAiB,QAAQ,CAACvB;IAC1BwB,oBAAoB,QAAQ,CAACxB;IAG7ByB,iBAAiB,QAAQ,CAACzB;IAC1B,MAAMC,OAAO,UAAU,EAAE,YAAYD;IACrC0B,oBAAoB,QAAQ,CAAC1B;IAS7B,MAAM2B,mBAAmB3B,WAAWG;IAGpCyB,qBAAqB,QAAQ,CAAC5B;AAClC"}