@pulse-compute/wasm-contracts 0.0.0 → 1.0.0-beta.2
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/README.md +35 -2
- package/package.json +124 -6
- package/src/assets/contracts.js +296 -0
- package/src/config/provider-resolution.js +54 -0
- package/src/config/runtime-provider-kv.js +73 -0
- package/src/config/symbolic-refs.js +192 -0
- package/src/crypto/contracts.js +647 -0
- package/src/definitions/config-schema.js +30 -0
- package/src/definitions/handler-roles.js +66 -0
- package/src/definitions/path-grammar.js +11 -0
- package/src/definitions/router-api.js +149 -0
- package/src/diagnostics/codes.js +42 -0
- package/src/diagnostics/reporter.js +20 -0
- package/src/diagnostics.js +139 -0
- package/src/dispatch-table.js +23 -0
- package/src/entities/catalog.d.ts +7 -0
- package/src/entities/catalog.js +87 -0
- package/src/entities/contracts.d.ts +95 -0
- package/src/entities/contracts.js +122 -0
- package/src/entities/json-rpc.d.ts +27 -0
- package/src/entities/json-rpc.js +69 -0
- package/src/entities/runtime.d.ts +67 -0
- package/src/entities/runtime.js +288 -0
- package/src/events/contracts.js +456 -0
- package/src/execution-plan.js +42 -0
- package/src/grip/contracts.js +106 -0
- package/src/handler/backend-json-request-body.js +58 -0
- package/src/handler/beta-lifecycle-golden.js +97 -0
- package/src/handler/canonical-native-plan.js +143 -0
- package/src/handler/canonical-native-runtime.js +168 -0
- package/src/handler/canonical-runtime.js +13 -0
- package/src/handler/context.js +131 -0
- package/src/handler/ctx-contract.js +71 -0
- package/src/handler/doctor-readiness-aggregator.js +67 -0
- package/src/handler/effects.js +446 -0
- package/src/handler/io-lifecycle.js +134 -0
- package/src/handler/lifecycle-authoring-alignment.js +56 -0
- package/src/handler/lifecycle-readiness-aggregate.js +93 -0
- package/src/handler/reference-node-lifecycle-golden.js +73 -0
- package/src/handler/request-json-body.js +147 -0
- package/src/handler/runtime-api.js +471 -0
- package/src/handler/schema-decode-result.js +135 -0
- package/src/handler/schema-response-codec.js +141 -0
- package/src/handler/surface-contract.js +601 -0
- package/src/handler/types-contract.js +51 -0
- package/src/handler-table.js +28 -0
- package/src/host/backend-capabilities.js +24 -0
- package/src/host/capabilities.js +273 -0
- package/src/host/channel-broadcaster.js +60 -0
- package/src/host/json-body.js +80 -0
- package/src/host/request-result-headers.js +38 -0
- package/src/host/streaming-passthrough.js +90 -0
- package/src/host/wasm-host-abi.js +154 -0
- package/src/index.js +75 -0
- package/src/jwt/contracts.js +427 -0
- package/src/library/api-surface.js +99 -0
- package/src/library/contracts.js +273 -0
- package/src/library/manifest.js +317 -0
- package/src/library/second-package-owned-lowering.js +39 -0
- package/src/library/sidecars.js +147 -0
- package/src/logging.js +89 -0
- package/src/package/package-contract.js +975 -0
- package/src/package/package-contract.schema.json +303 -0
- package/src/package/runtime-pulse-live.js +100 -0
- package/src/path-table.js +12 -0
- package/src/path.js +275 -0
- package/src/project/config-factory.js +48 -0
- package/src/project/config-plan.js +409 -0
- package/src/project/config-runtime.js +46 -0
- package/src/project/javascript-application.js +212 -0
- package/src/project/javascript-core-capabilities.js +44 -0
- package/src/project/native-optimization.js +9 -0
- package/src/project/package-ownership.js +242 -0
- package/src/project/package-product-projection.js +171 -0
- package/src/project/reachable-graph-identity.js +219 -0
- package/src/project/reachable-graph-projections.js +279 -0
- package/src/project/reachable-graph-resolver.js +303 -0
- package/src/project/reachable-graph-v2.js +430 -0
- package/src/project/reachable-graph-v2.schema.json +285 -0
- package/src/project/reachable-graph.js +199 -0
- package/src/project/reachable-graph.schema.json +222 -0
- package/src/project/target-support-evidence.js +559 -0
- package/src/provider/canonical-provider.js +239 -0
- package/src/provider/final-wasm-policy.js +87 -0
- package/src/provider/toolchain.js +771 -0
- package/src/route-plan.js +43 -0
- package/src/s3/contracts.js +12 -0
- package/src/schema-json/compile.js +63 -0
- package/src/schema-json/contracts.js +10 -0
- package/src/schema-json/generic-parser.js +62 -0
- package/src/schema-json/registry.js +359 -0
- package/src/schema-json/semantic-trace.js +241 -0
- package/src/schema-json/v1.js +65 -0
- package/src/schema-json/v2.js +110 -0
- package/src/sha256.js +104 -0
- package/src/spine.js +381 -0
- package/src/stable-id.js +142 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CONFIG_REFERENCES_PHASE = '12C.2';
|
|
4
|
+
const CONFIG_REFERENCES_VERSION = 'pulsewasm.config-references.v1';
|
|
5
|
+
const RUNTIME_CONFIG_REFERENCES_VERSION = 'pulsewasm.runtime-config-references.v1';
|
|
6
|
+
const PLATFORM_STORE_MAP_VERSION = 'pulsewasm.platform-store-map.v1';
|
|
7
|
+
const CONFIG_AUTHORING_SHAPE_VERSION = 'pulsewasm.config-authoring-shape.v1';
|
|
8
|
+
|
|
9
|
+
const SYMBOLIC_REF_MARKERS = Object.freeze(['$config', '$secret']);
|
|
10
|
+
const CONFIG_AUTHORING_ROOT_ALLOWED_KEYS = Object.freeze(['entry', 'rootRouter', 'profiles']);
|
|
11
|
+
const CONFIG_AUTHORING_PROFILE_RUNTIME_KEYS = Object.freeze(['engine', 'handlerExecutionMode', 'timeouts', 'payload', 'capabilities', 'platform']);
|
|
12
|
+
const CONFIG_AUTHORING_DISALLOWED_ROOT_RUNTIME_KEYS = Object.freeze(['runtime', 'json', 'backends', 'timeouts', 'assets', 'broadcaster', 'deployment']);
|
|
13
|
+
|
|
14
|
+
function plainObject(value) {
|
|
15
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function hasOwn(obj, key) {
|
|
19
|
+
return Object.prototype.hasOwnProperty.call(obj || {}, key);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isSymbolicRef(value) {
|
|
23
|
+
return value && typeof value === 'object' && !Array.isArray(value) &&
|
|
24
|
+
(hasOwn(value, '$config') || hasOwn(value, '$secret'));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function refKind(value) {
|
|
28
|
+
if (!isSymbolicRef(value)) return undefined;
|
|
29
|
+
if (hasOwn(value, '$config') && hasOwn(value, '$secret')) return 'mixed';
|
|
30
|
+
if (hasOwn(value, '$secret')) return 'secret';
|
|
31
|
+
return 'config';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function refKey(value) {
|
|
35
|
+
if (!isSymbolicRef(value)) return undefined;
|
|
36
|
+
const kind = refKind(value);
|
|
37
|
+
if (kind === 'secret') return value.$secret;
|
|
38
|
+
if (kind === 'config') return value.$config;
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function collectSymbolicRefs(value, pathSegments = [], out = []) {
|
|
43
|
+
if (isSymbolicRef(value)) {
|
|
44
|
+
out.push({
|
|
45
|
+
kind: refKind(value),
|
|
46
|
+
key: refKey(value),
|
|
47
|
+
path: pathSegments.slice(),
|
|
48
|
+
raw: value
|
|
49
|
+
});
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(value)) {
|
|
53
|
+
value.forEach((item, index) => collectSymbolicRefs(item, pathSegments.concat(String(index)), out));
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
if (value && typeof value === 'object') {
|
|
57
|
+
for (const [key, child] of Object.entries(value)) {
|
|
58
|
+
collectSymbolicRefs(child, pathSegments.concat(key), out);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const collectRefs = collectSymbolicRefs;
|
|
65
|
+
|
|
66
|
+
function platformFastly(runtime) {
|
|
67
|
+
const runtimeObject = plainObject(runtime);
|
|
68
|
+
const platform = plainObject(runtimeObject.platform);
|
|
69
|
+
return plainObject(platform.fastly || runtimeObject.fastly);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function providerForSymbolicRef(ref, runtime) {
|
|
73
|
+
const fastly = platformFastly(runtime);
|
|
74
|
+
if (ref.kind === 'config') {
|
|
75
|
+
return {
|
|
76
|
+
provider: fastly.configStore ? 'fastly.configStore' : 'unmapped.configStore',
|
|
77
|
+
store: fastly.configStore || null,
|
|
78
|
+
compiledIntoBinary: false
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (ref.kind === 'secret') {
|
|
82
|
+
return {
|
|
83
|
+
provider: fastly.secretStore ? 'fastly.secretStore' : 'unmapped.secretStore',
|
|
84
|
+
store: fastly.secretStore || null,
|
|
85
|
+
compiledIntoBinary: false
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return { provider: 'invalid', store: null, compiledIntoBinary: false };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const providerFor = providerForSymbolicRef;
|
|
92
|
+
|
|
93
|
+
function authoringShapeForKind(kind) {
|
|
94
|
+
return kind === 'secret' ? '{ $secret: "KEY" }' : '{ $config: "KEY" }';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function normalizeSymbolicRef(ref, runtime) {
|
|
98
|
+
const provider = providerForSymbolicRef(ref, runtime);
|
|
99
|
+
return {
|
|
100
|
+
kind: ref.kind,
|
|
101
|
+
key: ref.key,
|
|
102
|
+
path: ref.path,
|
|
103
|
+
provider: provider.provider,
|
|
104
|
+
store: provider.store,
|
|
105
|
+
secret: ref.kind === 'secret',
|
|
106
|
+
compiledIntoBinary: false,
|
|
107
|
+
authoringShape: authoringShapeForKind(ref.kind)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function groupSymbolicRefs(refs, runtime) {
|
|
112
|
+
const fastly = platformFastly(runtime);
|
|
113
|
+
const configRefs = refs.filter((ref) => ref.kind === 'config').map((ref) => normalizeSymbolicRef(ref, runtime));
|
|
114
|
+
const secretRefs = refs.filter((ref) => ref.kind === 'secret').map((ref) => normalizeSymbolicRef(ref, runtime));
|
|
115
|
+
return {
|
|
116
|
+
fastly: {
|
|
117
|
+
configStore: {
|
|
118
|
+
name: fastly.configStore || null,
|
|
119
|
+
refs: configRefs,
|
|
120
|
+
ready: Boolean(fastly.configStore) || configRefs.length === 0
|
|
121
|
+
},
|
|
122
|
+
secretStore: {
|
|
123
|
+
name: fastly.secretStore || null,
|
|
124
|
+
refs: secretRefs,
|
|
125
|
+
ready: Boolean(fastly.secretStore) || secretRefs.length === 0
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
local: {
|
|
129
|
+
configProvider: 'local-env-or-file-reserved',
|
|
130
|
+
secretProvider: 'local-env-or-file-reserved',
|
|
131
|
+
refs: refs.map((ref) => normalizeSymbolicRef(ref, runtime))
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function configAuthoringShape(generatedBy, phase = CONFIG_REFERENCES_PHASE) {
|
|
137
|
+
return {
|
|
138
|
+
version: CONFIG_AUTHORING_SHAPE_VERSION,
|
|
139
|
+
generatedBy,
|
|
140
|
+
phase,
|
|
141
|
+
status: 'locked',
|
|
142
|
+
root: {
|
|
143
|
+
purpose: 'app topology',
|
|
144
|
+
allowedKeys: CONFIG_AUTHORING_ROOT_ALLOWED_KEYS.slice(),
|
|
145
|
+
profileSelector: 'external PULSE_PROFILE or CLI --profile',
|
|
146
|
+
disallowedRuntimeKeys: CONFIG_AUTHORING_DISALLOWED_ROOT_RUNTIME_KEYS.slice()
|
|
147
|
+
},
|
|
148
|
+
profile: {
|
|
149
|
+
purpose: 'runtime/deployment behavior',
|
|
150
|
+
runtimeKeys: CONFIG_AUTHORING_PROFILE_RUNTIME_KEYS.slice(),
|
|
151
|
+
symbolicRefs: SYMBOLIC_REF_MARKERS.map((marker) => `{ ${marker}: "KEY" }`)
|
|
152
|
+
},
|
|
153
|
+
envHelperPolicy: {
|
|
154
|
+
required: false,
|
|
155
|
+
canonical: false,
|
|
156
|
+
status: 'legacy-compatible-but-not-preferred',
|
|
157
|
+
note: 'The canonical authoring shape uses symbolic refs and external profile selection.'
|
|
158
|
+
},
|
|
159
|
+
splitConfigFiles: {
|
|
160
|
+
supportedConceptually: true,
|
|
161
|
+
implementationStatus: 'reserved-strict-static-imports-only',
|
|
162
|
+
allowedFuture: 'direct named imports of exported object literals',
|
|
163
|
+
rejectedFuture: ['function-produced config', 'conditional config', 'computed keys', 'runtime env reads']
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
module.exports = {
|
|
169
|
+
CONFIG_REFERENCES_PHASE,
|
|
170
|
+
CONFIG_REFERENCES_VERSION,
|
|
171
|
+
RUNTIME_CONFIG_REFERENCES_VERSION,
|
|
172
|
+
PLATFORM_STORE_MAP_VERSION,
|
|
173
|
+
CONFIG_AUTHORING_SHAPE_VERSION,
|
|
174
|
+
SYMBOLIC_REF_MARKERS,
|
|
175
|
+
CONFIG_AUTHORING_ROOT_ALLOWED_KEYS,
|
|
176
|
+
CONFIG_AUTHORING_PROFILE_RUNTIME_KEYS,
|
|
177
|
+
CONFIG_AUTHORING_DISALLOWED_ROOT_RUNTIME_KEYS,
|
|
178
|
+
plainObject,
|
|
179
|
+
hasOwn,
|
|
180
|
+
platformFastly,
|
|
181
|
+
isSymbolicRef,
|
|
182
|
+
refKind,
|
|
183
|
+
refKey,
|
|
184
|
+
collectSymbolicRefs,
|
|
185
|
+
collectRefs,
|
|
186
|
+
providerFor,
|
|
187
|
+
providerForSymbolicRef,
|
|
188
|
+
authoringShapeForKind,
|
|
189
|
+
normalizeSymbolicRef,
|
|
190
|
+
groupSymbolicRefs,
|
|
191
|
+
configAuthoringShape
|
|
192
|
+
};
|