@bleedingdev/modern-js-server-runtime-extensions 3.5.0-ultramodern.30 → 3.5.0-ultramodern.32
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/cjs/contract-gate-snapshot-store/file-store.js +102 -0
- package/dist/cjs/contract-gate-snapshot-store/http-store.js +142 -0
- package/dist/cjs/contract-gate-snapshot-store/index.js +58 -0
- package/dist/cjs/contract-gate-snapshot-store/resolve.js +122 -0
- package/dist/cjs/contract-gate-snapshot-store/types.js +44 -0
- package/dist/cjs/contractGateAutopilot.js +27 -6
- package/dist/cjs/index.js +13 -13
- package/dist/cjs/module-federation-css/collector.js +79 -0
- package/dist/cjs/module-federation-css/index.js +55 -0
- package/dist/cjs/module-federation-css/manifest.js +144 -0
- package/dist/cjs/module-federation-css/plugin.js +71 -0
- package/dist/cjs/module-federation-css/remote.js +133 -0
- package/dist/cjs/runtime-fallback-signal/auth.js +87 -0
- package/dist/cjs/runtime-fallback-signal/constants.js +72 -0
- package/dist/cjs/runtime-fallback-signal/contract-gate.js +64 -0
- package/dist/cjs/runtime-fallback-signal/endpoint.js +50 -0
- package/dist/cjs/runtime-fallback-signal/errors.js +44 -0
- package/dist/cjs/runtime-fallback-signal/index.js +99 -0
- package/dist/cjs/runtime-fallback-signal/payload.js +72 -0
- package/dist/cjs/runtime-fallback-signal/source.js +66 -0
- package/dist/cjs/runtime-fallback-signal/state.js +57 -0
- package/dist/cjs/runtime-fallback-signal/status.js +47 -0
- package/dist/cjs/runtime-fallback-signal/trust-policy.js +108 -0
- package/dist/cjs/runtime-fallback-signal/types.js +18 -0
- package/dist/cjs/runtimeFallbackSignal.js +32 -281
- package/dist/cjs/telemetry/canary.js +180 -0
- package/dist/cjs/telemetry/canaryEvaluation.js +79 -0
- package/dist/cjs/telemetry/canarySetup.js +107 -0
- package/dist/cjs/telemetry/envelope.js +148 -0
- package/dist/cjs/telemetry/exporters.js +148 -0
- package/dist/cjs/telemetry/lifecycle.js +98 -0
- package/dist/cjs/telemetry/metrics.js +115 -0
- package/dist/cjs/telemetry/plugin.js +185 -0
- package/dist/cjs/telemetry/registry.js +348 -0
- package/dist/cjs/telemetry/registryTypes.js +46 -0
- package/dist/cjs/telemetry/runtimeEndpoints.js +135 -0
- package/dist/cjs/telemetry.js +32 -343
- package/dist/cjs/telemetryCore.js +14 -767
- package/dist/esm/contract-gate-snapshot-store/file-store.mjs +51 -0
- package/dist/esm/contract-gate-snapshot-store/http-store.mjs +92 -0
- package/dist/esm/contract-gate-snapshot-store/index.mjs +4 -0
- package/dist/esm/contract-gate-snapshot-store/resolve.mjs +68 -0
- package/dist/esm/contract-gate-snapshot-store/types.mjs +3 -0
- package/dist/esm/contractGateAutopilot.mjs +26 -5
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/module-federation-css/collector.mjs +38 -0
- package/dist/esm/module-federation-css/index.mjs +4 -0
- package/dist/esm/module-federation-css/manifest.mjs +69 -0
- package/dist/esm/module-federation-css/plugin.mjs +33 -0
- package/dist/esm/module-federation-css/remote.mjs +92 -0
- package/dist/esm/runtime-fallback-signal/auth.mjs +40 -0
- package/dist/esm/runtime-fallback-signal/constants.mjs +10 -0
- package/dist/esm/runtime-fallback-signal/contract-gate.mjs +26 -0
- package/dist/esm/runtime-fallback-signal/endpoint.mjs +12 -0
- package/dist/esm/runtime-fallback-signal/errors.mjs +6 -0
- package/dist/esm/runtime-fallback-signal/index.mjs +9 -0
- package/dist/esm/runtime-fallback-signal/payload.mjs +31 -0
- package/dist/esm/runtime-fallback-signal/source.mjs +22 -0
- package/dist/esm/runtime-fallback-signal/state.mjs +16 -0
- package/dist/esm/runtime-fallback-signal/status.mjs +9 -0
- package/dist/esm/runtime-fallback-signal/trust-policy.mjs +67 -0
- package/dist/esm/runtime-fallback-signal/types.mjs +0 -0
- package/dist/esm/runtimeFallbackSignal.mjs +1 -222
- package/dist/esm/telemetry/canary.mjs +142 -0
- package/dist/esm/telemetry/canaryEvaluation.mjs +41 -0
- package/dist/esm/telemetry/canarySetup.mjs +69 -0
- package/dist/esm/telemetry/envelope.mjs +101 -0
- package/dist/esm/telemetry/exporters.mjs +104 -0
- package/dist/esm/telemetry/lifecycle.mjs +60 -0
- package/dist/esm/telemetry/metrics.mjs +77 -0
- package/dist/esm/telemetry/plugin.mjs +87 -0
- package/dist/esm/telemetry/registry.mjs +310 -0
- package/dist/esm/telemetry/registryTypes.mjs +8 -0
- package/dist/esm/telemetry/runtimeEndpoints.mjs +94 -0
- package/dist/esm/telemetry.mjs +1 -275
- package/dist/esm/telemetryCore.mjs +6 -759
- package/dist/esm-node/contract-gate-snapshot-store/file-store.mjs +52 -0
- package/dist/esm-node/contract-gate-snapshot-store/http-store.mjs +93 -0
- package/dist/esm-node/contract-gate-snapshot-store/index.mjs +5 -0
- package/dist/esm-node/contract-gate-snapshot-store/resolve.mjs +70 -0
- package/dist/esm-node/contract-gate-snapshot-store/types.mjs +4 -0
- package/dist/esm-node/contractGateAutopilot.mjs +26 -5
- package/dist/esm-node/index.mjs +2 -2
- package/dist/esm-node/module-federation-css/collector.mjs +39 -0
- package/dist/esm-node/module-federation-css/index.mjs +5 -0
- package/dist/esm-node/module-federation-css/manifest.mjs +70 -0
- package/dist/esm-node/module-federation-css/plugin.mjs +34 -0
- package/dist/esm-node/module-federation-css/remote.mjs +93 -0
- package/dist/esm-node/runtime-fallback-signal/auth.mjs +41 -0
- package/dist/esm-node/runtime-fallback-signal/constants.mjs +11 -0
- package/dist/esm-node/runtime-fallback-signal/contract-gate.mjs +27 -0
- package/dist/esm-node/runtime-fallback-signal/endpoint.mjs +13 -0
- package/dist/esm-node/runtime-fallback-signal/errors.mjs +7 -0
- package/dist/esm-node/runtime-fallback-signal/index.mjs +10 -0
- package/dist/esm-node/runtime-fallback-signal/payload.mjs +32 -0
- package/dist/esm-node/runtime-fallback-signal/source.mjs +23 -0
- package/dist/esm-node/runtime-fallback-signal/state.mjs +17 -0
- package/dist/esm-node/runtime-fallback-signal/status.mjs +10 -0
- package/dist/esm-node/runtime-fallback-signal/trust-policy.mjs +68 -0
- package/dist/esm-node/runtime-fallback-signal/types.mjs +1 -0
- package/dist/esm-node/runtimeFallbackSignal.mjs +1 -222
- package/dist/esm-node/telemetry/canary.mjs +143 -0
- package/dist/esm-node/telemetry/canaryEvaluation.mjs +42 -0
- package/dist/esm-node/telemetry/canarySetup.mjs +70 -0
- package/dist/esm-node/telemetry/envelope.mjs +102 -0
- package/dist/esm-node/telemetry/exporters.mjs +105 -0
- package/dist/esm-node/telemetry/lifecycle.mjs +61 -0
- package/dist/esm-node/telemetry/metrics.mjs +78 -0
- package/dist/esm-node/telemetry/plugin.mjs +88 -0
- package/dist/esm-node/telemetry/registry.mjs +311 -0
- package/dist/esm-node/telemetry/registryTypes.mjs +9 -0
- package/dist/esm-node/telemetry/runtimeEndpoints.mjs +95 -0
- package/dist/esm-node/telemetry.mjs +1 -275
- package/dist/esm-node/telemetryCore.mjs +6 -759
- package/dist/types/contract-gate-snapshot-store/file-store.d.ts +3 -0
- package/dist/types/contract-gate-snapshot-store/http-store.d.ts +11 -0
- package/dist/types/contract-gate-snapshot-store/index.d.ts +5 -0
- package/dist/types/contract-gate-snapshot-store/resolve.d.ts +9 -0
- package/dist/types/{contractGateSnapshotStore.d.ts → contract-gate-snapshot-store/types.d.ts} +1 -11
- package/dist/types/contractGateAutopilot.d.ts +4 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/module-federation-css/collector.d.ts +25 -0
- package/dist/types/module-federation-css/index.d.ts +8 -0
- package/dist/types/module-federation-css/manifest.d.ts +33 -0
- package/dist/types/module-federation-css/plugin.d.ts +23 -0
- package/dist/types/module-federation-css/remote.d.ts +20 -0
- package/dist/types/runtime-fallback-signal/auth.d.ts +18 -0
- package/dist/types/runtime-fallback-signal/constants.d.ts +9 -0
- package/dist/types/runtime-fallback-signal/contract-gate.d.ts +2 -0
- package/dist/types/runtime-fallback-signal/endpoint.d.ts +1 -0
- package/dist/types/runtime-fallback-signal/errors.d.ts +2 -0
- package/dist/types/runtime-fallback-signal/index.d.ts +10 -0
- package/dist/types/runtime-fallback-signal/payload.d.ts +6 -0
- package/dist/types/runtime-fallback-signal/source.d.ts +3 -0
- package/dist/types/runtime-fallback-signal/state.d.ts +3 -0
- package/dist/types/runtime-fallback-signal/status.d.ts +2 -0
- package/dist/types/runtime-fallback-signal/trust-policy.d.ts +13 -0
- package/dist/types/runtime-fallback-signal/types.d.ts +50 -0
- package/dist/types/runtimeFallbackSignal.d.ts +1 -94
- package/dist/types/telemetry/canary.d.ts +85 -0
- package/dist/types/telemetry/canaryEvaluation.d.ts +19 -0
- package/dist/types/telemetry/canarySetup.d.ts +17 -0
- package/dist/types/telemetry/envelope.d.ts +45 -0
- package/dist/types/telemetry/exporters.d.ts +12 -0
- package/dist/types/telemetry/lifecycle.d.ts +18 -0
- package/dist/types/telemetry/metrics.d.ts +3 -0
- package/dist/types/telemetry/plugin.d.ts +12 -0
- package/dist/types/telemetry/registry.d.ts +72 -0
- package/dist/types/telemetry/registryTypes.d.ts +50 -0
- package/dist/types/telemetry/runtimeEndpoints.d.ts +35 -0
- package/dist/types/telemetry.d.ts +1 -12
- package/dist/types/telemetryCore.d.ts +6 -257
- package/package.json +7 -7
- package/src/contract-gate-snapshot-store/file-store.ts +85 -0
- package/src/contract-gate-snapshot-store/http-store.ts +159 -0
- package/src/contract-gate-snapshot-store/index.ts +20 -0
- package/src/contract-gate-snapshot-store/resolve.ts +175 -0
- package/src/contract-gate-snapshot-store/types.ts +64 -0
- package/src/contractGateAutopilot.ts +45 -9
- package/src/index.ts +6 -6
- package/src/module-federation-css/collector.ts +82 -0
- package/src/module-federation-css/index.ts +14 -0
- package/src/module-federation-css/manifest.ts +166 -0
- package/src/module-federation-css/plugin.ts +86 -0
- package/src/module-federation-css/remote.ts +165 -0
- package/src/runtime-fallback-signal/auth.ts +117 -0
- package/src/runtime-fallback-signal/constants.ts +19 -0
- package/src/runtime-fallback-signal/contract-gate.ts +43 -0
- package/src/runtime-fallback-signal/endpoint.ts +22 -0
- package/src/runtime-fallback-signal/errors.ts +10 -0
- package/src/runtime-fallback-signal/index.ts +36 -0
- package/src/runtime-fallback-signal/payload.ts +79 -0
- package/src/runtime-fallback-signal/source.ts +49 -0
- package/src/runtime-fallback-signal/state.ts +34 -0
- package/src/runtime-fallback-signal/status.ts +22 -0
- package/src/runtime-fallback-signal/trust-policy.ts +179 -0
- package/src/runtime-fallback-signal/types.ts +66 -0
- package/src/runtimeFallbackSignal.ts +1 -584
- package/src/telemetry/canary.ts +291 -0
- package/src/telemetry/canaryEvaluation.ts +83 -0
- package/src/telemetry/canarySetup.ts +160 -0
- package/src/telemetry/envelope.ts +189 -0
- package/src/telemetry/exporters.ts +165 -0
- package/src/telemetry/lifecycle.ts +138 -0
- package/src/telemetry/metrics.ts +141 -0
- package/src/telemetry/plugin.ts +197 -0
- package/src/telemetry/registry.ts +467 -0
- package/src/telemetry/registryTypes.ts +63 -0
- package/src/telemetry/runtimeEndpoints.ts +172 -0
- package/src/telemetry.ts +1 -554
- package/src/telemetryCore.ts +34 -1332
- package/tests/contractGateAutopilot.test.ts +205 -0
- package/tests/contractGateSnapshotStore.test.ts +54 -1
- package/tests/helpers.ts +1 -0
- package/tests/moduleFederationCss.test.ts +1 -1
- package/tests/registration.test.ts +1 -1
- package/tests/telemetry.test.ts +40 -0
- package/tests/telemetryLifecycle.test.ts +253 -2
- package/dist/cjs/contractGateSnapshotStore.js +0 -253
- package/dist/cjs/moduleFederationCss.js +0 -285
- package/dist/esm/contractGateSnapshotStore.mjs +0 -190
- package/dist/esm/moduleFederationCss.mjs +0 -225
- package/dist/esm-node/contractGateSnapshotStore.mjs +0 -192
- package/dist/esm-node/moduleFederationCss.mjs +0 -226
- package/dist/types/moduleFederationCss.d.ts +0 -87
- package/src/contractGateSnapshotStore.ts +0 -420
- package/src/moduleFederationCss.ts +0 -473
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
createFileContractGateSnapshotStore: ()=>createFileContractGateSnapshotStore,
|
|
41
|
+
resolveContractGateSnapshotPath: ()=>resolveContractGateSnapshotPath
|
|
42
|
+
});
|
|
43
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
44
|
+
const external_fs_namespaceObject = require("fs");
|
|
45
|
+
const external_path_namespaceObject = require("path");
|
|
46
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
47
|
+
const external_env_js_namespaceObject = require("../env.js");
|
|
48
|
+
const external_resolve_js_namespaceObject = require("./resolve.js");
|
|
49
|
+
const external_types_js_namespaceObject = require("./types.js");
|
|
50
|
+
const resolveContractGateSnapshotPath = (appDirectory, configuredPath)=>{
|
|
51
|
+
const rawPath = configuredPath || (0, external_env_js_namespaceObject.parseServerRuntimeExtensionsEnv)().contractGatesFile || external_types_js_namespaceObject.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH;
|
|
52
|
+
if (external_path_default().isAbsolute(rawPath)) return rawPath;
|
|
53
|
+
return external_path_default().resolve(appDirectory, rawPath);
|
|
54
|
+
};
|
|
55
|
+
const writeSnapshotFileAtomically = async (resolvedPath, contents)=>{
|
|
56
|
+
const directory = external_path_default().dirname(resolvedPath);
|
|
57
|
+
await external_fs_namespaceObject.promises.mkdir(directory, {
|
|
58
|
+
recursive: true
|
|
59
|
+
});
|
|
60
|
+
const temporaryPath = external_path_default().join(directory, `.${external_path_default().basename(resolvedPath)}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`);
|
|
61
|
+
try {
|
|
62
|
+
await external_fs_namespaceObject.promises.writeFile(temporaryPath, contents);
|
|
63
|
+
await external_fs_namespaceObject.promises.rename(temporaryPath, resolvedPath);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
await external_fs_namespaceObject.promises.rm(temporaryPath, {
|
|
66
|
+
force: true
|
|
67
|
+
}).catch(()=>{});
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const createFileContractGateSnapshotStore = (gateSnapshotPath)=>{
|
|
72
|
+
const resolvedPath = external_path_default().resolve(gateSnapshotPath);
|
|
73
|
+
return {
|
|
74
|
+
name: `file:${resolvedPath}`,
|
|
75
|
+
async readSnapshot () {
|
|
76
|
+
if (!await utils_namespaceObject.fs.pathExists(resolvedPath)) return;
|
|
77
|
+
try {
|
|
78
|
+
const raw = await external_fs_namespaceObject.promises.readFile(resolvedPath, 'utf8');
|
|
79
|
+
return (0, external_resolve_js_namespaceObject.normalizeSnapshot)(JSON.parse(raw));
|
|
80
|
+
} catch (_error) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
async writeSnapshot (snapshot) {
|
|
85
|
+
const normalized = (0, external_resolve_js_namespaceObject.normalizeSnapshot)(snapshot) || {
|
|
86
|
+
schemaVersion: external_types_js_namespaceObject.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
87
|
+
updatedAt: Date.now(),
|
|
88
|
+
gates: {}
|
|
89
|
+
};
|
|
90
|
+
await writeSnapshotFileAtomically(resolvedPath, `${JSON.stringify(normalized, null, 2)}\n`);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
exports.createFileContractGateSnapshotStore = __webpack_exports__.createFileContractGateSnapshotStore;
|
|
95
|
+
exports.resolveContractGateSnapshotPath = __webpack_exports__.resolveContractGateSnapshotPath;
|
|
96
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
97
|
+
"createFileContractGateSnapshotStore",
|
|
98
|
+
"resolveContractGateSnapshotPath"
|
|
99
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
100
|
+
Object.defineProperty(exports, '__esModule', {
|
|
101
|
+
value: true
|
|
102
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
BUILTIN_HTTP_STATE_STORE_MODULES: ()=>BUILTIN_HTTP_STATE_STORE_MODULES,
|
|
32
|
+
createHttpContractGateSnapshotStore: ()=>createHttpContractGateSnapshotStore,
|
|
33
|
+
normalizeHttpStoreOptions: ()=>normalizeHttpStoreOptions,
|
|
34
|
+
tryResolveBuiltinSnapshotStore: ()=>tryResolveBuiltinSnapshotStore,
|
|
35
|
+
withTimeoutAbort: ()=>withTimeoutAbort
|
|
36
|
+
});
|
|
37
|
+
const external_resolve_js_namespaceObject = require("./resolve.js");
|
|
38
|
+
const external_types_js_namespaceObject = require("./types.js");
|
|
39
|
+
const DEFAULT_HTTP_STORE_TIMEOUT_MS = 5000;
|
|
40
|
+
const BUILTIN_HTTP_STATE_STORE_MODULES = new Set([
|
|
41
|
+
'http',
|
|
42
|
+
'@modern-js/server-core/http',
|
|
43
|
+
'@modern-js/server-core/contract-gate-http-store',
|
|
44
|
+
'@modern-js/server-runtime-extensions/http',
|
|
45
|
+
'@modern-js/server-runtime-extensions/contract-gate-http-store'
|
|
46
|
+
]);
|
|
47
|
+
const normalizeHttpStoreOptions = (options)=>{
|
|
48
|
+
const endpoint = 'string' == typeof options?.endpoint ? options.endpoint.trim() : '';
|
|
49
|
+
if (!endpoint) throw new Error('[telemetry.canary.autopilot] HTTP stateStore requires options.endpoint');
|
|
50
|
+
const readMethod = 'string' == typeof options?.readMethod && options.readMethod.trim() ? options.readMethod.trim().toUpperCase() : 'GET';
|
|
51
|
+
const writeMethod = 'string' == typeof options?.writeMethod && options.writeMethod.trim() ? options.writeMethod.trim().toUpperCase() : 'PUT';
|
|
52
|
+
const timeoutMsRaw = Number(options?.timeoutMs);
|
|
53
|
+
const timeoutMs = Number.isFinite(timeoutMsRaw) && timeoutMsRaw > 0 ? Math.floor(timeoutMsRaw) : DEFAULT_HTTP_STORE_TIMEOUT_MS;
|
|
54
|
+
const headersRaw = options?.headers;
|
|
55
|
+
const headers = {};
|
|
56
|
+
if (headersRaw && 'object' == typeof headersRaw && !Array.isArray(headersRaw)) Object.entries(headersRaw).forEach(([key, value])=>{
|
|
57
|
+
if ('string' == typeof key && key.trim().length > 0 && null != value) headers[key] = String(value);
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
endpoint,
|
|
61
|
+
readMethod,
|
|
62
|
+
writeMethod,
|
|
63
|
+
headers,
|
|
64
|
+
timeoutMs
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const withTimeoutAbort = (timeoutMs)=>{
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const timer = setTimeout(()=>controller.abort(), timeoutMs);
|
|
70
|
+
return {
|
|
71
|
+
signal: controller.signal,
|
|
72
|
+
clear: ()=>clearTimeout(timer)
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const createHttpContractGateSnapshotStore = (options)=>{
|
|
76
|
+
const normalized = normalizeHttpStoreOptions(options);
|
|
77
|
+
const endpoint = normalized.endpoint;
|
|
78
|
+
return {
|
|
79
|
+
name: `http:${endpoint}`,
|
|
80
|
+
async readSnapshot () {
|
|
81
|
+
const { signal, clear } = withTimeoutAbort(normalized.timeoutMs || 5000);
|
|
82
|
+
try {
|
|
83
|
+
const response = await fetch(endpoint, {
|
|
84
|
+
method: normalized.readMethod || 'GET',
|
|
85
|
+
headers: {
|
|
86
|
+
accept: 'application/json',
|
|
87
|
+
...normalized.headers || {}
|
|
88
|
+
},
|
|
89
|
+
signal
|
|
90
|
+
});
|
|
91
|
+
if (404 === response.status) return;
|
|
92
|
+
if (!response.ok) throw new Error(`HTTP stateStore read failed with status ${String(response.status)}`);
|
|
93
|
+
const payload = await response.json();
|
|
94
|
+
return (0, external_resolve_js_namespaceObject.normalizeSnapshot)(payload);
|
|
95
|
+
} finally{
|
|
96
|
+
clear();
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
async writeSnapshot (snapshot) {
|
|
100
|
+
const body = JSON.stringify((0, external_resolve_js_namespaceObject.normalizeSnapshot)(snapshot) || {
|
|
101
|
+
schemaVersion: external_types_js_namespaceObject.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
102
|
+
updatedAt: Date.now(),
|
|
103
|
+
gates: {}
|
|
104
|
+
});
|
|
105
|
+
const { signal, clear } = withTimeoutAbort(normalized.timeoutMs || 5000);
|
|
106
|
+
try {
|
|
107
|
+
const response = await fetch(endpoint, {
|
|
108
|
+
method: normalized.writeMethod || 'PUT',
|
|
109
|
+
headers: {
|
|
110
|
+
'content-type': 'application/json',
|
|
111
|
+
...normalized.headers || {}
|
|
112
|
+
},
|
|
113
|
+
body,
|
|
114
|
+
signal
|
|
115
|
+
});
|
|
116
|
+
if (!response.ok) throw new Error(`HTTP stateStore write failed with status ${String(response.status)}`);
|
|
117
|
+
} finally{
|
|
118
|
+
clear();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
const tryResolveBuiltinSnapshotStore = (input)=>{
|
|
124
|
+
const moduleName = input.stateStore.module.trim();
|
|
125
|
+
if (!BUILTIN_HTTP_STATE_STORE_MODULES.has(moduleName)) return;
|
|
126
|
+
return createHttpContractGateSnapshotStore(input.stateStore.options || {});
|
|
127
|
+
};
|
|
128
|
+
exports.BUILTIN_HTTP_STATE_STORE_MODULES = __webpack_exports__.BUILTIN_HTTP_STATE_STORE_MODULES;
|
|
129
|
+
exports.createHttpContractGateSnapshotStore = __webpack_exports__.createHttpContractGateSnapshotStore;
|
|
130
|
+
exports.normalizeHttpStoreOptions = __webpack_exports__.normalizeHttpStoreOptions;
|
|
131
|
+
exports.tryResolveBuiltinSnapshotStore = __webpack_exports__.tryResolveBuiltinSnapshotStore;
|
|
132
|
+
exports.withTimeoutAbort = __webpack_exports__.withTimeoutAbort;
|
|
133
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
134
|
+
"BUILTIN_HTTP_STATE_STORE_MODULES",
|
|
135
|
+
"createHttpContractGateSnapshotStore",
|
|
136
|
+
"normalizeHttpStoreOptions",
|
|
137
|
+
"tryResolveBuiltinSnapshotStore",
|
|
138
|
+
"withTimeoutAbort"
|
|
139
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
140
|
+
Object.defineProperty(exports, '__esModule', {
|
|
141
|
+
value: true
|
|
142
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION: ()=>external_types_js_namespaceObject.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
32
|
+
DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH: ()=>external_types_js_namespaceObject.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH,
|
|
33
|
+
createFileContractGateSnapshotStore: ()=>external_file_store_js_namespaceObject.createFileContractGateSnapshotStore,
|
|
34
|
+
createHttpContractGateSnapshotStore: ()=>external_http_store_js_namespaceObject.createHttpContractGateSnapshotStore,
|
|
35
|
+
resolveContractGateSnapshotPath: ()=>external_file_store_js_namespaceObject.resolveContractGateSnapshotPath,
|
|
36
|
+
resolveContractGateSnapshotStore: ()=>external_resolve_js_namespaceObject.resolveContractGateSnapshotStore
|
|
37
|
+
});
|
|
38
|
+
const external_file_store_js_namespaceObject = require("./file-store.js");
|
|
39
|
+
const external_http_store_js_namespaceObject = require("./http-store.js");
|
|
40
|
+
const external_resolve_js_namespaceObject = require("./resolve.js");
|
|
41
|
+
const external_types_js_namespaceObject = require("./types.js");
|
|
42
|
+
exports.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = __webpack_exports__.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
|
|
43
|
+
exports.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH = __webpack_exports__.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH;
|
|
44
|
+
exports.createFileContractGateSnapshotStore = __webpack_exports__.createFileContractGateSnapshotStore;
|
|
45
|
+
exports.createHttpContractGateSnapshotStore = __webpack_exports__.createHttpContractGateSnapshotStore;
|
|
46
|
+
exports.resolveContractGateSnapshotPath = __webpack_exports__.resolveContractGateSnapshotPath;
|
|
47
|
+
exports.resolveContractGateSnapshotStore = __webpack_exports__.resolveContractGateSnapshotStore;
|
|
48
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
49
|
+
"CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION",
|
|
50
|
+
"DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH",
|
|
51
|
+
"createFileContractGateSnapshotStore",
|
|
52
|
+
"createHttpContractGateSnapshotStore",
|
|
53
|
+
"resolveContractGateSnapshotPath",
|
|
54
|
+
"resolveContractGateSnapshotStore"
|
|
55
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
isRecord: ()=>isRecord,
|
|
41
|
+
normalizeSnapshot: ()=>normalizeSnapshot,
|
|
42
|
+
resolveContractGateSnapshotStore: ()=>resolveContractGateSnapshotStore
|
|
43
|
+
});
|
|
44
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
45
|
+
const external_path_namespaceObject = require("path");
|
|
46
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
47
|
+
const external_file_store_js_namespaceObject = require("./file-store.js");
|
|
48
|
+
const external_http_store_js_namespaceObject = require("./http-store.js");
|
|
49
|
+
const external_types_js_namespaceObject = require("./types.js");
|
|
50
|
+
const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
51
|
+
const normalizeSnapshot = (snapshot)=>{
|
|
52
|
+
if (!isRecord(snapshot)) return;
|
|
53
|
+
const schemaVersion = 'number' == typeof snapshot.schemaVersion ? snapshot.schemaVersion : external_types_js_namespaceObject.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
|
|
54
|
+
const updatedAt = 'number' == typeof snapshot.updatedAt ? snapshot.updatedAt : Date.now();
|
|
55
|
+
const gates = isRecord(snapshot.gates) ? snapshot.gates : {};
|
|
56
|
+
return {
|
|
57
|
+
schemaVersion,
|
|
58
|
+
updatedAt,
|
|
59
|
+
gates
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const pickStoreFactory = (mod)=>{
|
|
63
|
+
if ('function' == typeof mod) return mod;
|
|
64
|
+
if ('function' == typeof mod.createContractGateSnapshotStore) return mod.createContractGateSnapshotStore;
|
|
65
|
+
if ('function' == typeof mod.default) return mod.default;
|
|
66
|
+
if (mod.default && 'object' == typeof mod.default && 'function' == typeof mod.default.createContractGateSnapshotStore) return mod.default.createContractGateSnapshotStore;
|
|
67
|
+
};
|
|
68
|
+
const ensureStoreShape = (store, modulePath)=>{
|
|
69
|
+
if (!store || 'object' != typeof store || 'function' != typeof store.readSnapshot || 'function' != typeof store.writeSnapshot) throw new Error(`Invalid contract gate snapshot store from "${modulePath}". Expected { readSnapshot(), writeSnapshot() }.`);
|
|
70
|
+
};
|
|
71
|
+
const resolveStoreModulePath = (appDirectory, modulePath)=>{
|
|
72
|
+
const normalized = modulePath.trim();
|
|
73
|
+
if (!normalized) throw new Error('Contract gate snapshot stateStore.module must be non-empty');
|
|
74
|
+
if (external_path_default().isAbsolute(normalized)) return normalized;
|
|
75
|
+
if (normalized.startsWith('.')) return external_path_default().resolve(appDirectory, normalized);
|
|
76
|
+
const appRequire = (0, external_node_module_namespaceObject.createRequire)(external_path_default().join(appDirectory, 'package.json'));
|
|
77
|
+
try {
|
|
78
|
+
return appRequire.resolve(normalized);
|
|
79
|
+
} catch (_error) {
|
|
80
|
+
return normalized;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const resolveContractGateSnapshotStore = async (input)=>{
|
|
84
|
+
const { appDirectory, gateSnapshotPath, stateStore, logger } = input;
|
|
85
|
+
if (!stateStore?.module) return (0, external_file_store_js_namespaceObject.createFileContractGateSnapshotStore)(gateSnapshotPath);
|
|
86
|
+
const builtinStore = (0, external_http_store_js_namespaceObject.tryResolveBuiltinSnapshotStore)({
|
|
87
|
+
stateStore
|
|
88
|
+
});
|
|
89
|
+
if (builtinStore) {
|
|
90
|
+
logger?.info?.(`[telemetry.canary.autopilot] using built-in contract gate snapshot store "${builtinStore.name}"`);
|
|
91
|
+
return builtinStore;
|
|
92
|
+
}
|
|
93
|
+
const modulePath = resolveStoreModulePath(appDirectory, stateStore.module);
|
|
94
|
+
let mod;
|
|
95
|
+
try {
|
|
96
|
+
mod = require(modulePath);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
throw new Error(`[telemetry.canary.autopilot] Failed to load stateStore.module "${stateStore.module}" (${modulePath}): ${error instanceof Error ? error.message : String(error)}`);
|
|
99
|
+
}
|
|
100
|
+
const factory = pickStoreFactory(mod);
|
|
101
|
+
if (!factory) throw new Error(`[telemetry.canary.autopilot] stateStore.module "${stateStore.module}" does not export createContractGateSnapshotStore()`);
|
|
102
|
+
const store = await factory({
|
|
103
|
+
appDirectory,
|
|
104
|
+
gateSnapshotPath,
|
|
105
|
+
options: stateStore.options,
|
|
106
|
+
logger
|
|
107
|
+
});
|
|
108
|
+
ensureStoreShape(store, modulePath);
|
|
109
|
+
logger?.info?.(`[telemetry.canary.autopilot] using contract gate snapshot store "${store.name || modulePath}"`);
|
|
110
|
+
return store;
|
|
111
|
+
};
|
|
112
|
+
exports.isRecord = __webpack_exports__.isRecord;
|
|
113
|
+
exports.normalizeSnapshot = __webpack_exports__.normalizeSnapshot;
|
|
114
|
+
exports.resolveContractGateSnapshotStore = __webpack_exports__.resolveContractGateSnapshotStore;
|
|
115
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
116
|
+
"isRecord",
|
|
117
|
+
"normalizeSnapshot",
|
|
118
|
+
"resolveContractGateSnapshotStore"
|
|
119
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
120
|
+
Object.defineProperty(exports, '__esModule', {
|
|
121
|
+
value: true
|
|
122
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
31
|
+
const DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH = '.modern/contract-gates.json';
|
|
32
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
33
|
+
CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION: CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
34
|
+
DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH: DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH
|
|
35
|
+
});
|
|
36
|
+
exports.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = __webpack_exports__.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
|
|
37
|
+
exports.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH = __webpack_exports__.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH;
|
|
38
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
39
|
+
"CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION",
|
|
40
|
+
"DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH"
|
|
41
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
42
|
+
Object.defineProperty(exports, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
@@ -30,7 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
ContractGateAutopilot: ()=>ContractGateAutopilot
|
|
32
32
|
});
|
|
33
|
-
const
|
|
33
|
+
const index_js_namespaceObject = require("./contract-gate-snapshot-store/index.js");
|
|
34
34
|
const DEFAULT_POLL_INTERVAL_MS = 15000;
|
|
35
35
|
const DEFAULT_GATE_STALE_AFTER_MS = 600000;
|
|
36
36
|
class ContractGateAutopilot {
|
|
@@ -49,10 +49,13 @@ class ContractGateAutopilot {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
async syncOnce() {
|
|
52
|
+
const syncGeneration = ++this.syncGeneration;
|
|
52
53
|
const snapshot = await this.loadSnapshot();
|
|
54
|
+
if (syncGeneration !== this.syncGeneration) return 0;
|
|
53
55
|
if (!snapshot) return 0;
|
|
56
|
+
const snapshotGateNames = this.getSnapshotGateNames(snapshot);
|
|
54
57
|
const gates = this.normalizeSnapshot(snapshot);
|
|
55
|
-
let updatedCount = 0;
|
|
58
|
+
let updatedCount = snapshotGateNames ? this.clearOmittedGates(snapshotGateNames) : 0;
|
|
56
59
|
for (const gate of gates){
|
|
57
60
|
this.orchestrator.addRequiredContractGate(gate.name);
|
|
58
61
|
const fingerprint = `${gate.passed ? '1' : '0'}:${gate.reason || ''}`;
|
|
@@ -65,13 +68,30 @@ class ContractGateAutopilot {
|
|
|
65
68
|
}
|
|
66
69
|
return updatedCount;
|
|
67
70
|
}
|
|
71
|
+
getSnapshotGateNames(snapshot) {
|
|
72
|
+
const gates = snapshot.gates;
|
|
73
|
+
if (!gates || 'object' != typeof gates) return;
|
|
74
|
+
const names = new Set();
|
|
75
|
+
for (const name of Object.keys(gates)){
|
|
76
|
+
const normalizedName = name.trim();
|
|
77
|
+
if (normalizedName) names.add(normalizedName);
|
|
78
|
+
}
|
|
79
|
+
return names;
|
|
80
|
+
}
|
|
81
|
+
clearOmittedGates(snapshotGateNames) {
|
|
82
|
+
let updatedCount = 0;
|
|
83
|
+
for (const gateName of Array.from(this.appliedGateFingerprints.keys()))if (!snapshotGateNames.has(gateName)) {
|
|
84
|
+
this.orchestrator.setContractGate(gateName, true);
|
|
85
|
+
this.appliedGateFingerprints.delete(gateName);
|
|
86
|
+
updatedCount += 1;
|
|
87
|
+
this.logger?.info?.(`[telemetry.canary.autopilot] gate=${gateName} passed=true reason=omitted`);
|
|
88
|
+
}
|
|
89
|
+
return updatedCount;
|
|
90
|
+
}
|
|
68
91
|
async loadSnapshot() {
|
|
69
92
|
try {
|
|
70
93
|
const snapshot = await this.gateSnapshotStore.readSnapshot();
|
|
71
94
|
if (!snapshot) return;
|
|
72
|
-
const fingerprint = JSON.stringify(snapshot);
|
|
73
|
-
if (fingerprint === this.lastSnapshotFingerprint) return;
|
|
74
|
-
this.lastSnapshotFingerprint = fingerprint;
|
|
75
95
|
return snapshot;
|
|
76
96
|
} catch (error) {
|
|
77
97
|
const source = this.gateSnapshotPath || this.gateSnapshotStore.name || 'stateStore';
|
|
@@ -143,11 +163,12 @@ class ContractGateAutopilot {
|
|
|
143
163
|
if ('number' == typeof value && Number.isFinite(value) && value > 0) return value;
|
|
144
164
|
}
|
|
145
165
|
constructor(options){
|
|
166
|
+
this.syncGeneration = 0;
|
|
146
167
|
this.appliedGateFingerprints = new Map();
|
|
147
168
|
this.orchestrator = options.orchestrator;
|
|
148
169
|
if (!options.gateSnapshotStore && !options.gateSnapshotPath) throw new Error('ContractGateAutopilot requires gateSnapshotPath or gateSnapshotStore');
|
|
149
170
|
this.gateSnapshotPath = options.gateSnapshotPath;
|
|
150
|
-
this.gateSnapshotStore = options.gateSnapshotStore || (0,
|
|
171
|
+
this.gateSnapshotStore = options.gateSnapshotStore || (0, index_js_namespaceObject.createFileContractGateSnapshotStore)(options.gateSnapshotPath);
|
|
151
172
|
this.pollIntervalMs = Math.max(250, options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS);
|
|
152
173
|
this.gateStaleAfterMs = Math.max(0, options.gateStaleAfterMs ?? DEFAULT_GATE_STALE_AFTER_MS);
|
|
153
174
|
this.logger = options.logger;
|
package/dist/cjs/index.js
CHANGED
|
@@ -28,21 +28,21 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION: ()=>
|
|
31
|
+
CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION: ()=>index_js_namespaceObject.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
32
32
|
ContractGateAutopilot: ()=>external_contractGateAutopilot_js_namespaceObject.ContractGateAutopilot,
|
|
33
|
-
DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH: ()=>
|
|
33
|
+
DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH: ()=>index_js_namespaceObject.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH,
|
|
34
34
|
DEFAULT_ENVIRONMENT_NAME: ()=>external_env_js_namespaceObject.DEFAULT_ENVIRONMENT_NAME,
|
|
35
35
|
DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT: ()=>external_telemetry_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT,
|
|
36
36
|
DEFAULT_RUNTIME_STATUS_ENDPOINT: ()=>external_telemetry_js_namespaceObject.DEFAULT_RUNTIME_STATUS_ENDPOINT,
|
|
37
37
|
TelemetryCanaryOrchestrator: ()=>external_telemetry_js_namespaceObject.TelemetryCanaryOrchestrator,
|
|
38
38
|
TelemetryRegistry: ()=>external_telemetry_js_namespaceObject.TelemetryRegistry,
|
|
39
39
|
TelemetryStartupHealthError: ()=>external_telemetry_js_namespaceObject.TelemetryStartupHealthError,
|
|
40
|
-
collectDirectRemoteModuleFederationCss: ()=>
|
|
41
|
-
collectDirectRemoteModuleFederationCssWithMeta: ()=>
|
|
42
|
-
collectModuleFederationManifestCss: ()=>
|
|
43
|
-
createFileContractGateSnapshotStore: ()=>
|
|
44
|
-
createHttpContractGateSnapshotStore: ()=>
|
|
45
|
-
createModuleFederationCssCollector: ()=>
|
|
40
|
+
collectDirectRemoteModuleFederationCss: ()=>external_module_federation_css_index_js_namespaceObject.collectDirectRemoteModuleFederationCss,
|
|
41
|
+
collectDirectRemoteModuleFederationCssWithMeta: ()=>external_module_federation_css_index_js_namespaceObject.collectDirectRemoteModuleFederationCssWithMeta,
|
|
42
|
+
collectModuleFederationManifestCss: ()=>external_module_federation_css_index_js_namespaceObject.collectModuleFederationManifestCss,
|
|
43
|
+
createFileContractGateSnapshotStore: ()=>index_js_namespaceObject.createFileContractGateSnapshotStore,
|
|
44
|
+
createHttpContractGateSnapshotStore: ()=>index_js_namespaceObject.createHttpContractGateSnapshotStore,
|
|
45
|
+
createModuleFederationCssCollector: ()=>external_module_federation_css_index_js_namespaceObject.createModuleFederationCssCollector,
|
|
46
46
|
createOtlpTelemetryExporter: ()=>external_telemetry_js_namespaceObject.createOtlpTelemetryExporter,
|
|
47
47
|
createRuntimeFallbackSignalRuntimeState: ()=>external_telemetry_js_namespaceObject.createRuntimeFallbackSignalRuntimeState,
|
|
48
48
|
createRuntimeSignalError: ()=>external_telemetry_js_namespaceObject.createRuntimeSignalError,
|
|
@@ -54,7 +54,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
54
54
|
getRuntimeSignalErrorStatusCode: ()=>external_telemetry_js_namespaceObject.getRuntimeSignalErrorStatusCode,
|
|
55
55
|
hasEnabledTelemetryExporters: ()=>external_telemetry_js_namespaceObject.hasEnabledTelemetryExporters,
|
|
56
56
|
injectMfAssetCacheHeadersPlugin: ()=>external_mfCache_js_namespaceObject.injectMfAssetCacheHeadersPlugin,
|
|
57
|
-
injectModuleFederationCssPlugin: ()=>
|
|
57
|
+
injectModuleFederationCssPlugin: ()=>external_module_federation_css_index_js_namespaceObject.injectModuleFederationCssPlugin,
|
|
58
58
|
injectTelemetryPlugin: ()=>external_telemetry_js_namespaceObject.injectTelemetryPlugin,
|
|
59
59
|
isMfManifestAsset: ()=>external_mfCache_js_namespaceObject.isMfManifestAsset,
|
|
60
60
|
isMfRemoteEntryAsset: ()=>external_mfCache_js_namespaceObject.isMfRemoteEntryAsset,
|
|
@@ -63,17 +63,17 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
63
63
|
normalizeRuntimeFallbackTrustPolicy: ()=>external_telemetry_js_namespaceObject.normalizeRuntimeFallbackTrustPolicy,
|
|
64
64
|
parseRuntimeFallbackSignalPayloadFromRawBody: ()=>external_telemetry_js_namespaceObject.parseRuntimeFallbackSignalPayloadFromRawBody,
|
|
65
65
|
parseServerRuntimeExtensionsEnv: ()=>external_env_js_namespaceObject.parseServerRuntimeExtensionsEnv,
|
|
66
|
-
resolveContractGateSnapshotPath: ()=>
|
|
67
|
-
resolveContractGateSnapshotStore: ()=>
|
|
66
|
+
resolveContractGateSnapshotPath: ()=>index_js_namespaceObject.resolveContractGateSnapshotPath,
|
|
67
|
+
resolveContractGateSnapshotStore: ()=>index_js_namespaceObject.resolveContractGateSnapshotStore,
|
|
68
68
|
resolveMfAssetCacheHeaders: ()=>external_mfCache_js_namespaceObject.resolveMfAssetCacheHeaders,
|
|
69
69
|
resolveRuntimeFallbackSignalEndpoint: ()=>external_telemetry_js_namespaceObject.resolveRuntimeFallbackSignalEndpoint,
|
|
70
70
|
resolveTelemetrySloOptions: ()=>external_telemetry_js_namespaceObject.resolveTelemetrySloOptions
|
|
71
71
|
});
|
|
72
|
+
const index_js_namespaceObject = require("./contract-gate-snapshot-store/index.js");
|
|
72
73
|
const external_contractGateAutopilot_js_namespaceObject = require("./contractGateAutopilot.js");
|
|
73
|
-
const external_contractGateSnapshotStore_js_namespaceObject = require("./contractGateSnapshotStore.js");
|
|
74
74
|
const external_env_js_namespaceObject = require("./env.js");
|
|
75
75
|
const external_mfCache_js_namespaceObject = require("./mfCache.js");
|
|
76
|
-
const
|
|
76
|
+
const external_module_federation_css_index_js_namespaceObject = require("./module-federation-css/index.js");
|
|
77
77
|
const external_telemetry_js_namespaceObject = require("./telemetry.js");
|
|
78
78
|
exports.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = __webpack_exports__.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
|
|
79
79
|
exports.ContractGateAutopilot = __webpack_exports__.ContractGateAutopilot;
|