@gapi/core 1.8.222 → 1.8.224

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/dist/index.d.ts CHANGED
@@ -11,5 +11,6 @@ export * from '@rxdi/graphql-pubsub';
11
11
  export { withFilter } from '@rxdi/graphql-rabbitmq-subscriptions';
12
12
  export * from '@rxdi/hapi';
13
13
  export * from 'graphql';
14
+ export { awaitLambdaModule, Bootstrap, deliverLambdaModule, isLambdaModuleDelivered, isLambdaRuntime, resetLambdaBridge, } from './lambda-bridge';
14
15
  export { buildSchema, ExecutionResult, extendSchema, isSpecifiedScalarType, } from 'graphql';
15
16
  export { FilterFn, PubSubEngine, PubSubOptions, ResolverFn, } from 'graphql-subscriptions';
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
21
  };
22
22
  var CoreModule_1;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.PubSubEngine = exports.isSpecifiedScalarType = exports.extendSchema = exports.buildSchema = exports.withFilter = exports.GeoJSON = exports.CoreModule = void 0;
24
+ exports.PubSubEngine = exports.isSpecifiedScalarType = exports.extendSchema = exports.buildSchema = exports.resetLambdaBridge = exports.isLambdaRuntime = exports.isLambdaModuleDelivered = exports.deliverLambdaModule = exports.Bootstrap = exports.awaitLambdaModule = exports.withFilter = exports.GeoJSON = exports.CoreModule = void 0;
25
25
  const core_1 = require("@rxdi/core");
26
26
  const graphql_1 = require("@rxdi/graphql");
27
27
  const graphql_pubsub_1 = require("@rxdi/graphql-pubsub");
@@ -56,6 +56,16 @@ var graphql_rabbitmq_subscriptions_1 = require("@rxdi/graphql-rabbitmq-subscript
56
56
  Object.defineProperty(exports, "withFilter", { enumerable: true, get: function () { return graphql_rabbitmq_subscriptions_1.withFilter; } });
57
57
  __exportStar(require("@rxdi/hapi"), exports);
58
58
  __exportStar(require("graphql"), exports);
59
+ // Explicit re-export of the lambda-aware Bootstrap MUST come after the
60
+ // `export * from '@rxdi/core'` above so it shadows the upstream Bootstrap.
61
+ // Outside Lambforge (LAMBFORGE_RUNTIME unset), this delegates verbatim.
62
+ var lambda_bridge_1 = require("./lambda-bridge");
63
+ Object.defineProperty(exports, "awaitLambdaModule", { enumerable: true, get: function () { return lambda_bridge_1.awaitLambdaModule; } });
64
+ Object.defineProperty(exports, "Bootstrap", { enumerable: true, get: function () { return lambda_bridge_1.Bootstrap; } });
65
+ Object.defineProperty(exports, "deliverLambdaModule", { enumerable: true, get: function () { return lambda_bridge_1.deliverLambdaModule; } });
66
+ Object.defineProperty(exports, "isLambdaModuleDelivered", { enumerable: true, get: function () { return lambda_bridge_1.isLambdaModuleDelivered; } });
67
+ Object.defineProperty(exports, "isLambdaRuntime", { enumerable: true, get: function () { return lambda_bridge_1.isLambdaRuntime; } });
68
+ Object.defineProperty(exports, "resetLambdaBridge", { enumerable: true, get: function () { return lambda_bridge_1.resetLambdaBridge; } });
59
69
  var graphql_2 = require("graphql");
60
70
  Object.defineProperty(exports, "buildSchema", { enumerable: true, get: function () { return graphql_2.buildSchema; } });
61
71
  Object.defineProperty(exports, "extendSchema", { enumerable: true, get: function () { return graphql_2.extendSchema; } });
@@ -0,0 +1,35 @@
1
+ import { ConfigModel, ObservableContainer } from '@rxdi/core';
2
+ import { Observable } from 'rxjs';
3
+ export declare function isLambdaRuntime(): boolean;
4
+ /**
5
+ * Synchronous check: did a user bundle already deliver its AppModule via
6
+ * the bridge? Useful right after `await import(userBundle)` to decide
7
+ * between the new (Bootstrap-based) and legacy (default-export-function)
8
+ * specialize paths without paying a Promise-race timeout.
9
+ */
10
+ export declare function isLambdaModuleDelivered(): boolean;
11
+ /**
12
+ * Called by the host (e.g. FissionPlugin) before loading the user bundle.
13
+ * Returns a Promise that resolves with the user's AppModule once the
14
+ * lambda-aware Bootstrap intercepts it.
15
+ */
16
+ export declare function awaitLambdaModule(): Promise<Function>;
17
+ /**
18
+ * Called by the lambda-aware Bootstrap wrapper to hand the user's AppModule
19
+ * to the waiting host. If the host hasn't called `awaitLambdaModule()` yet,
20
+ * we cache the module so the next caller gets it.
21
+ */
22
+ export declare function deliverLambdaModule(appModule: Function): void;
23
+ /**
24
+ * Resets bridge state. Useful for tests and (eventually) re-specialization
25
+ * if a single container ever needs to load more than one user bundle.
26
+ */
27
+ export declare function resetLambdaBridge(): void;
28
+ /**
29
+ * Drop-in replacement for `@rxdi/core` Bootstrap that detects Lambforge mode
30
+ * via env. In lambda mode, the AppModule is delivered to the bridge and a
31
+ * dummy observable resolves so user code's `.subscribe(...)` still fires
32
+ * (which lets `console.log('Server started')` style callbacks run as the
33
+ * user expects). In normal mode, this is exactly the upstream Bootstrap.
34
+ */
35
+ export declare function Bootstrap(app: Function, config?: ConfigModel): Observable<ObservableContainer>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLambdaRuntime = isLambdaRuntime;
4
+ exports.isLambdaModuleDelivered = isLambdaModuleDelivered;
5
+ exports.awaitLambdaModule = awaitLambdaModule;
6
+ exports.deliverLambdaModule = deliverLambdaModule;
7
+ exports.resetLambdaBridge = resetLambdaBridge;
8
+ exports.Bootstrap = Bootstrap;
9
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
10
+ const core_1 = require("@rxdi/core");
11
+ const rxjs_1 = require("rxjs");
12
+ /**
13
+ * Lambda bridge for Lambforge (or any host that pre-bootstraps a gapi
14
+ * runtime and later wants the user's AppModule applied in-place).
15
+ *
16
+ * In a normal process, `Bootstrap(AppModule)` starts the whole framework.
17
+ * Inside a Lambforge container the framework is already running — the user's
18
+ * AppModule needs to be wired into the live container rather than starting
19
+ * a fresh one. The host (FissionPlugin) calls `awaitLambdaModule()` after
20
+ * loading the user bundle; when the user bundle's `Bootstrap(AppModule)`
21
+ * fires, the env-gated wrapper delivers the module reference here, and the
22
+ * host applies it via `BootstrapService.applyModule`.
23
+ *
24
+ * Activation: set `LAMBFORGE_RUNTIME=1` in the container's process env
25
+ * BEFORE `require()`ing the user bundle. The user's source code is
26
+ * unchanged — `Bootstrap(AppModule).subscribe(...)` works in both modes.
27
+ */
28
+ let pendingResolver = null;
29
+ let pendingPromise = null;
30
+ let pendingDelivered = null;
31
+ function isLambdaRuntime() {
32
+ return process.env.LAMBFORGE_RUNTIME === '1';
33
+ }
34
+ /**
35
+ * Synchronous check: did a user bundle already deliver its AppModule via
36
+ * the bridge? Useful right after `await import(userBundle)` to decide
37
+ * between the new (Bootstrap-based) and legacy (default-export-function)
38
+ * specialize paths without paying a Promise-race timeout.
39
+ */
40
+ function isLambdaModuleDelivered() {
41
+ return pendingDelivered !== null;
42
+ }
43
+ /**
44
+ * Called by the host (e.g. FissionPlugin) before loading the user bundle.
45
+ * Returns a Promise that resolves with the user's AppModule once the
46
+ * lambda-aware Bootstrap intercepts it.
47
+ */
48
+ function awaitLambdaModule() {
49
+ if (pendingDelivered) {
50
+ return Promise.resolve(pendingDelivered);
51
+ }
52
+ if (pendingPromise) {
53
+ return pendingPromise;
54
+ }
55
+ pendingPromise = new Promise((resolve) => {
56
+ pendingResolver = resolve;
57
+ });
58
+ return pendingPromise;
59
+ }
60
+ /**
61
+ * Called by the lambda-aware Bootstrap wrapper to hand the user's AppModule
62
+ * to the waiting host. If the host hasn't called `awaitLambdaModule()` yet,
63
+ * we cache the module so the next caller gets it.
64
+ */
65
+ function deliverLambdaModule(appModule) {
66
+ if (pendingResolver) {
67
+ pendingResolver(appModule);
68
+ pendingResolver = null;
69
+ pendingPromise = null;
70
+ pendingDelivered = appModule;
71
+ return;
72
+ }
73
+ pendingDelivered = appModule;
74
+ pendingPromise = Promise.resolve(appModule);
75
+ }
76
+ /**
77
+ * Resets bridge state. Useful for tests and (eventually) re-specialization
78
+ * if a single container ever needs to load more than one user bundle.
79
+ */
80
+ function resetLambdaBridge() {
81
+ pendingResolver = null;
82
+ pendingPromise = null;
83
+ pendingDelivered = null;
84
+ }
85
+ /**
86
+ * Drop-in replacement for `@rxdi/core` Bootstrap that detects Lambforge mode
87
+ * via env. In lambda mode, the AppModule is delivered to the bridge and a
88
+ * dummy observable resolves so user code's `.subscribe(...)` still fires
89
+ * (which lets `console.log('Server started')` style callbacks run as the
90
+ * user expects). In normal mode, this is exactly the upstream Bootstrap.
91
+ */
92
+ function Bootstrap(app, config) {
93
+ if (isLambdaRuntime()) {
94
+ deliverLambdaModule(app);
95
+ return new rxjs_1.Observable((subscriber) => {
96
+ subscriber.next(core_1.Container);
97
+ subscriber.complete();
98
+ });
99
+ }
100
+ return (0, core_1.Bootstrap)(app, config);
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/core",
3
- "version": "1.8.222",
3
+ "version": "1.8.224",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
@@ -25,10 +25,10 @@
25
25
  "url": "https://github.com/Stradivario/gapi/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@rxdi/core": "^0.7.244",
29
- "@rxdi/graphql": "^0.7.244",
30
- "@rxdi/graphql-pubsub": "^0.7.244",
31
- "@rxdi/hapi": "^0.7.244",
28
+ "@rxdi/core": "^0.7.246",
29
+ "@rxdi/graphql": "^0.7.246",
30
+ "@rxdi/graphql-pubsub": "^0.7.246",
31
+ "@rxdi/hapi": "^0.7.246",
32
32
  "graphql": "^16.12.0"
33
33
  },
34
34
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -30,6 +30,17 @@ export * from '@rxdi/graphql-pubsub';
30
30
  export { withFilter } from '@rxdi/graphql-rabbitmq-subscriptions';
31
31
  export * from '@rxdi/hapi';
32
32
  export * from 'graphql';
33
+ // Explicit re-export of the lambda-aware Bootstrap MUST come after the
34
+ // `export * from '@rxdi/core'` above so it shadows the upstream Bootstrap.
35
+ // Outside Lambforge (LAMBFORGE_RUNTIME unset), this delegates verbatim.
36
+ export {
37
+ awaitLambdaModule,
38
+ Bootstrap,
39
+ deliverLambdaModule,
40
+ isLambdaModuleDelivered,
41
+ isLambdaRuntime,
42
+ resetLambdaBridge,
43
+ } from './lambda-bridge';
33
44
  export {
34
45
  buildSchema,
35
46
  ExecutionResult,
@@ -0,0 +1,109 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
2
+ import {
3
+ Bootstrap as RxdiBootstrap,
4
+ ConfigModel,
5
+ Container,
6
+ ObservableContainer,
7
+ } from '@rxdi/core';
8
+ import { Observable } from 'rxjs';
9
+
10
+ /**
11
+ * Lambda bridge for Lambforge (or any host that pre-bootstraps a gapi
12
+ * runtime and later wants the user's AppModule applied in-place).
13
+ *
14
+ * In a normal process, `Bootstrap(AppModule)` starts the whole framework.
15
+ * Inside a Lambforge container the framework is already running — the user's
16
+ * AppModule needs to be wired into the live container rather than starting
17
+ * a fresh one. The host (FissionPlugin) calls `awaitLambdaModule()` after
18
+ * loading the user bundle; when the user bundle's `Bootstrap(AppModule)`
19
+ * fires, the env-gated wrapper delivers the module reference here, and the
20
+ * host applies it via `BootstrapService.applyModule`.
21
+ *
22
+ * Activation: set `LAMBFORGE_RUNTIME=1` in the container's process env
23
+ * BEFORE `require()`ing the user bundle. The user's source code is
24
+ * unchanged — `Bootstrap(AppModule).subscribe(...)` works in both modes.
25
+ */
26
+
27
+ let pendingResolver: ((module: Function) => void) | null = null;
28
+ let pendingPromise: Promise<Function> | null = null;
29
+ let pendingDelivered: Function | null = null;
30
+
31
+ export function isLambdaRuntime(): boolean {
32
+ return process.env.LAMBFORGE_RUNTIME === '1';
33
+ }
34
+
35
+ /**
36
+ * Synchronous check: did a user bundle already deliver its AppModule via
37
+ * the bridge? Useful right after `await import(userBundle)` to decide
38
+ * between the new (Bootstrap-based) and legacy (default-export-function)
39
+ * specialize paths without paying a Promise-race timeout.
40
+ */
41
+ export function isLambdaModuleDelivered(): boolean {
42
+ return pendingDelivered !== null;
43
+ }
44
+
45
+ /**
46
+ * Called by the host (e.g. FissionPlugin) before loading the user bundle.
47
+ * Returns a Promise that resolves with the user's AppModule once the
48
+ * lambda-aware Bootstrap intercepts it.
49
+ */
50
+ export function awaitLambdaModule(): Promise<Function> {
51
+ if (pendingDelivered) {
52
+ return Promise.resolve(pendingDelivered);
53
+ }
54
+ if (pendingPromise) {
55
+ return pendingPromise;
56
+ }
57
+ pendingPromise = new Promise<Function>((resolve) => {
58
+ pendingResolver = resolve;
59
+ });
60
+ return pendingPromise;
61
+ }
62
+
63
+ /**
64
+ * Called by the lambda-aware Bootstrap wrapper to hand the user's AppModule
65
+ * to the waiting host. If the host hasn't called `awaitLambdaModule()` yet,
66
+ * we cache the module so the next caller gets it.
67
+ */
68
+ export function deliverLambdaModule(appModule: Function): void {
69
+ if (pendingResolver) {
70
+ pendingResolver(appModule);
71
+ pendingResolver = null;
72
+ pendingPromise = null;
73
+ pendingDelivered = appModule;
74
+ return;
75
+ }
76
+ pendingDelivered = appModule;
77
+ pendingPromise = Promise.resolve(appModule);
78
+ }
79
+
80
+ /**
81
+ * Resets bridge state. Useful for tests and (eventually) re-specialization
82
+ * if a single container ever needs to load more than one user bundle.
83
+ */
84
+ export function resetLambdaBridge(): void {
85
+ pendingResolver = null;
86
+ pendingPromise = null;
87
+ pendingDelivered = null;
88
+ }
89
+
90
+ /**
91
+ * Drop-in replacement for `@rxdi/core` Bootstrap that detects Lambforge mode
92
+ * via env. In lambda mode, the AppModule is delivered to the bridge and a
93
+ * dummy observable resolves so user code's `.subscribe(...)` still fires
94
+ * (which lets `console.log('Server started')` style callbacks run as the
95
+ * user expects). In normal mode, this is exactly the upstream Bootstrap.
96
+ */
97
+ export function Bootstrap(
98
+ app: Function,
99
+ config?: ConfigModel,
100
+ ): Observable<ObservableContainer> {
101
+ if (isLambdaRuntime()) {
102
+ deliverLambdaModule(app);
103
+ return new Observable<ObservableContainer>((subscriber) => {
104
+ subscriber.next(Container as ObservableContainer);
105
+ subscriber.complete();
106
+ });
107
+ }
108
+ return RxdiBootstrap(app, config);
109
+ }