@vizejs/marquette 0.814.0 → 0.816.0
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 +182 -70
- package/dist/adapter-capability-manifest.schema.json +2 -2
- package/dist/adapter.d.mts +4 -4
- package/dist/adapter.d.mts.map +1 -1
- package/dist/adapter.mjs +11 -6
- package/dist/adapter.mjs.map +1 -1
- package/dist/application-contract.schema.json +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{model-B_mM8AeH.d.mts → model-BcXukmxj.d.mts} +2 -2
- package/dist/{model-B_mM8AeH.d.mts.map → model-BcXukmxj.d.mts.map} +1 -1
- package/dist/native-build-admission.d.mts +381 -0
- package/dist/native-build-admission.d.mts.map +1 -0
- package/dist/native-build-admission.mjs +505 -0
- package/dist/native-build-admission.mjs.map +1 -0
- package/dist/native-build.d.mts +28 -1
- package/dist/native-build.d.mts.map +1 -1
- package/dist/native-build.mjs +11 -1
- package/dist/native-build.mjs.map +1 -1
- package/dist/navigation-links.d.mts +1 -1
- package/dist/navigation.d.mts +1 -1
- package/dist/validate.d.mts +1 -1
- package/dist/validate.mjs +2 -2
- package/dist/validate.mjs.map +1 -1
- package/package.json +6 -1
- package/scripts/package-tasks.cjs +6 -0
package/README.md
CHANGED
|
@@ -11,48 +11,42 @@ package provides literal-preserving TypeScript authoring. Runtime validation is
|
|
|
11
11
|
available through a separate entry, while canonicalization and compatibility
|
|
12
12
|
analysis remain focused layers.
|
|
13
13
|
|
|
14
|
+
The following named modules form one executable example folder. Install
|
|
15
|
+
`@vizejs/marquette` in an ESM project (`"type": "module"` in `package.json`) and
|
|
16
|
+
copy the linked sample inputs when running the test-run recipe. Run any module
|
|
17
|
+
directly with Node 24, for example `node validate.ts`.
|
|
18
|
+
|
|
14
19
|
## Author a marquette
|
|
15
20
|
|
|
16
|
-
```ts
|
|
21
|
+
```ts filename="app.marquette.ts"
|
|
17
22
|
import { defineApplicationMarquette } from "@vizejs/marquette";
|
|
18
23
|
|
|
19
|
-
export
|
|
24
|
+
export const shop = defineApplicationMarquette({
|
|
20
25
|
application: "shop",
|
|
21
26
|
targets: ["web", "native"],
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
capabilities: {
|
|
28
|
+
"native.rendering": { id: "native.rendering", description: "Render native views", version: 1 },
|
|
29
|
+
"native.text": { id: "native.text", description: "Render native text", version: 1 },
|
|
30
|
+
"native.camera": { id: "native.camera", description: "Capture images", version: 1 },
|
|
31
|
+
"native.notifications": {
|
|
32
|
+
id: "native.notifications",
|
|
33
|
+
description: "Deliver notifications",
|
|
34
|
+
version: 1,
|
|
28
35
|
},
|
|
36
|
+
},
|
|
37
|
+
environments: [
|
|
38
|
+
{ id: "web", target: "web", consumer: "client", runtime: "browser" },
|
|
29
39
|
{
|
|
30
40
|
id: "native",
|
|
31
41
|
target: "native",
|
|
32
42
|
consumer: "client",
|
|
33
43
|
runtime: "native",
|
|
44
|
+
capabilities: ["native.rendering"],
|
|
34
45
|
},
|
|
35
|
-
{
|
|
36
|
-
id: "server",
|
|
37
|
-
target: "web",
|
|
38
|
-
consumer: "server",
|
|
39
|
-
runtime: "rust",
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
backends: [
|
|
43
|
-
{
|
|
44
|
-
id: "api",
|
|
45
|
-
family: "rust",
|
|
46
|
-
environment: "server",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
protocols: [
|
|
50
|
-
{
|
|
51
|
-
id: "api.query",
|
|
52
|
-
family: "schema-query",
|
|
53
|
-
backend: "api",
|
|
54
|
-
},
|
|
46
|
+
{ id: "server", target: "web", consumer: "server", runtime: "rust" },
|
|
55
47
|
],
|
|
48
|
+
backends: [{ id: "api", family: "rust", environment: "server" }],
|
|
49
|
+
protocols: [{ id: "api.query", family: "schema-query", backend: "api" }],
|
|
56
50
|
routes: [
|
|
57
51
|
{
|
|
58
52
|
id: "home",
|
|
@@ -62,8 +56,17 @@ export default defineApplicationMarquette({
|
|
|
62
56
|
backend: "api",
|
|
63
57
|
protocol: "api.query",
|
|
64
58
|
},
|
|
59
|
+
{
|
|
60
|
+
id: "profile",
|
|
61
|
+
path: "/users/:userId",
|
|
62
|
+
environment: "native",
|
|
63
|
+
rendering: "native",
|
|
64
|
+
capabilities: ["native.text"],
|
|
65
|
+
},
|
|
65
66
|
],
|
|
66
67
|
});
|
|
68
|
+
|
|
69
|
+
export default shop;
|
|
67
70
|
```
|
|
68
71
|
|
|
69
72
|
Environment dependencies, backend owners, protocol owners, and route
|
|
@@ -76,13 +79,13 @@ surprise.
|
|
|
76
79
|
Use the dedicated validation entry when contracts cross file, process, or
|
|
77
80
|
language boundaries:
|
|
78
81
|
|
|
79
|
-
```ts
|
|
82
|
+
```ts filename="validate.ts"
|
|
83
|
+
import assert from "node:assert/strict";
|
|
80
84
|
import { validateApplicationMarquette } from "@vizejs/marquette/validate";
|
|
85
|
+
import shop from "./app.marquette.ts";
|
|
81
86
|
|
|
82
87
|
const diagnostics = validateApplicationMarquette(shop);
|
|
83
|
-
|
|
84
|
-
console.error(diagnostic.code, diagnostic.path, diagnostic.message);
|
|
85
|
-
}
|
|
88
|
+
assert.deepEqual(diagnostics, []);
|
|
86
89
|
```
|
|
87
90
|
|
|
88
91
|
Validation is deterministic, does not mutate the authored object, and reports
|
|
@@ -98,25 +101,42 @@ for requirements; an undeclared requirement fails closed even when an adapter
|
|
|
98
101
|
offers a capability with the same identifier. Adapter-only capabilities are
|
|
99
102
|
allowed and remain additive until an application requires them.
|
|
100
103
|
|
|
101
|
-
```ts
|
|
104
|
+
```ts filename="adapter.ts"
|
|
105
|
+
import assert from "node:assert/strict";
|
|
106
|
+
import { defineApplicationMarquette } from "@vizejs/marquette";
|
|
102
107
|
import {
|
|
103
108
|
negotiateAdapterCapabilities,
|
|
104
109
|
type AdapterCapabilityManifest,
|
|
105
110
|
} from "@vizejs/marquette/adapter";
|
|
106
111
|
|
|
112
|
+
const terminal = defineApplicationMarquette({
|
|
113
|
+
application: "terminal-example",
|
|
114
|
+
targets: ["terminal"],
|
|
115
|
+
capabilities: {
|
|
116
|
+
"terminal.color": { id: "terminal.color", description: "Render terminal colors", version: 2 },
|
|
117
|
+
},
|
|
118
|
+
environments: [
|
|
119
|
+
{
|
|
120
|
+
id: "terminal",
|
|
121
|
+
target: "terminal",
|
|
122
|
+
consumer: "client",
|
|
123
|
+
runtime: "terminal",
|
|
124
|
+
capabilities: ["terminal.color"],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
});
|
|
107
128
|
const adapter = {
|
|
108
129
|
adapter: "terminal.fresco",
|
|
109
130
|
capabilities: [{ id: "terminal.color", minVersion: 1, maxVersion: 3 }],
|
|
110
131
|
} satisfies AdapterCapabilityManifest;
|
|
111
|
-
|
|
112
132
|
const result = negotiateAdapterCapabilities(
|
|
113
|
-
|
|
114
|
-
|
|
133
|
+
terminal,
|
|
134
|
+
terminal.environments[0].capabilities,
|
|
115
135
|
adapter,
|
|
116
136
|
);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
137
|
+
assert.equal(result.compatible, true);
|
|
138
|
+
assert.deepEqual(result.diagnostics, []);
|
|
139
|
+
assert.deepEqual(result.mismatches, []);
|
|
120
140
|
```
|
|
121
141
|
|
|
122
142
|
Exact and inclusive-bound matches are compatible. Missing support,
|
|
@@ -131,16 +151,31 @@ not mutate their inputs. Compatibility reports expose validation diagnostics for
|
|
|
131
151
|
both manifests and omit changes when either input is invalid. The published manifest schema is available from
|
|
132
152
|
`@vizejs/marquette/adapter/schema`.
|
|
133
153
|
|
|
154
|
+
Capability definitions and adapter bounds use positive unsigned 32-bit integer
|
|
155
|
+
versions (`1` through `4294967295`) in TypeScript, native contracts, and published
|
|
156
|
+
schemas. Direct validation and negotiation refuse non-finite, fractional, and
|
|
157
|
+
out-of-range numbers. An invalid application requirement produces the stable
|
|
158
|
+
`invalid-requirement-version` mismatch without serializing the invalid number.
|
|
159
|
+
|
|
134
160
|
Native rendering adapters share one closed version-one baseline for rendering,
|
|
135
161
|
events, layout, text, images, animation, accessibility, and lifecycle:
|
|
136
162
|
|
|
137
|
-
```ts
|
|
138
|
-
import
|
|
163
|
+
```ts filename="native-adapter.ts"
|
|
164
|
+
import assert from "node:assert/strict";
|
|
165
|
+
import {
|
|
166
|
+
nativeEngineCapabilityProfile,
|
|
167
|
+
type AdapterCapabilityManifest,
|
|
168
|
+
} from "@vizejs/marquette/adapter";
|
|
139
169
|
|
|
140
|
-
const nativeAdapter = {
|
|
170
|
+
export const nativeAdapter = {
|
|
141
171
|
adapter: "native.example",
|
|
142
|
-
capabilities:
|
|
143
|
-
|
|
172
|
+
capabilities: [
|
|
173
|
+
...nativeEngineCapabilityProfile(),
|
|
174
|
+
{ id: "native.camera", minVersion: 1, maxVersion: 1 },
|
|
175
|
+
{ id: "native.notifications", minVersion: 1, maxVersion: 1 },
|
|
176
|
+
],
|
|
177
|
+
} satisfies AdapterCapabilityManifest;
|
|
178
|
+
assert.equal(nativeAdapter.capabilities.length, 10);
|
|
144
179
|
```
|
|
145
180
|
|
|
146
181
|
The canonical identifiers use the `native.*` namespace and are emitted in a
|
|
@@ -155,10 +190,15 @@ configuration, platform destinations, signing strategy, capability set, and
|
|
|
155
190
|
optional update channel without embedding an executor, credentials, or secret
|
|
156
191
|
values:
|
|
157
192
|
|
|
158
|
-
```ts
|
|
159
|
-
import
|
|
193
|
+
```ts filename="native-build-profile.ts"
|
|
194
|
+
import assert from "node:assert/strict";
|
|
195
|
+
import {
|
|
196
|
+
defineNativeApplicationBuildProfile,
|
|
197
|
+
defineNativeBuildProfile,
|
|
198
|
+
} from "@vizejs/marquette/native-build";
|
|
199
|
+
import shop from "./app.marquette.ts";
|
|
160
200
|
|
|
161
|
-
export
|
|
201
|
+
export const profile = defineNativeBuildProfile({
|
|
162
202
|
format: "vize.native-build-profile",
|
|
163
203
|
formatVersion: 1,
|
|
164
204
|
profile: "production",
|
|
@@ -171,6 +211,8 @@ export default defineNativeBuildProfile({
|
|
|
171
211
|
capabilities: ["native.camera", "native.notifications"],
|
|
172
212
|
updates: { channel: "stable", runtimeVersion: "1.4.0" },
|
|
173
213
|
});
|
|
214
|
+
assert.equal(defineNativeApplicationBuildProfile(shop, profile), profile);
|
|
215
|
+
export default profile;
|
|
174
216
|
```
|
|
175
217
|
|
|
176
218
|
Use `parseNativeBuildProfile` at an untrusted JSON boundary and
|
|
@@ -182,6 +224,49 @@ The published profile schema is available from
|
|
|
182
224
|
`@vizejs/marquette/native-build/schema` and is embedded by the Rust contract
|
|
183
225
|
crate for native hosts.
|
|
184
226
|
|
|
227
|
+
### Admission before scheduling
|
|
228
|
+
|
|
229
|
+
The experimental `defineNativeApplicationBuildProfile(app, profile)` helper
|
|
230
|
+
infers native client environment identifiers and declared capability identifiers
|
|
231
|
+
from `app`. It preserves the original profile and its literal types. Standalone
|
|
232
|
+
`defineNativeBuildProfile` remains available for portable records.
|
|
233
|
+
|
|
234
|
+
Local and hosted executors can use the lazy
|
|
235
|
+
`@vizejs/marquette/native-build/admission` entry before scheduling:
|
|
236
|
+
|
|
237
|
+
```ts filename="native-build-admission.ts"
|
|
238
|
+
import assert from "node:assert/strict";
|
|
239
|
+
import { admitNativeBuildProfile } from "@vizejs/marquette/native-build/admission";
|
|
240
|
+
import shop from "./app.marquette.ts";
|
|
241
|
+
import { nativeAdapter } from "./native-adapter.ts";
|
|
242
|
+
import profile from "./native-build-profile.ts";
|
|
243
|
+
|
|
244
|
+
const result = admitNativeBuildProfile(shop, profile, nativeAdapter);
|
|
245
|
+
if (!result.allowed) throw new Error(JSON.stringify(result.diagnostics));
|
|
246
|
+
assert.deepEqual(result.diagnostics, []);
|
|
247
|
+
assert.deepEqual(result.capabilities, [
|
|
248
|
+
"native.camera",
|
|
249
|
+
"native.notifications",
|
|
250
|
+
"native.rendering",
|
|
251
|
+
"native.text",
|
|
252
|
+
]);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Admission validates the application, profile, and adapter, binds the selected
|
|
256
|
+
environment to a native client, and negotiates every capability required by
|
|
257
|
+
the profile, that environment, and its routes. A capability offered only by the
|
|
258
|
+
adapter cannot authorize an undeclared application requirement. Findings retain
|
|
259
|
+
their source, stable code, path, severity, and explanation; application warnings
|
|
260
|
+
remain visible. The result is deterministic and does not mutate inputs.
|
|
261
|
+
Strict profile and adapter parsing runs before graph inspection. Unknown fields,
|
|
262
|
+
invalid enum values, or unsafe numeric bounds throw `TypeError`; semantic
|
|
263
|
+
failures return `allowed: false`. Executors must treat either as a refusal.
|
|
264
|
+
|
|
265
|
+
Executors must check the same inputs immediately before scheduling. Admission
|
|
266
|
+
does not run builds, access signing material, or persist an approval. Its
|
|
267
|
+
complete emitted runtime dependency graph has an enforced 8 KiB gzip budget;
|
|
268
|
+
authoring imports do not include admission or validation code.
|
|
269
|
+
|
|
185
270
|
## Typed navigation
|
|
186
271
|
|
|
187
272
|
`@vizejs/marquette/navigation` derives programmatic navigation directly from
|
|
@@ -190,12 +275,19 @@ accept one string or finite number. A `*name` segment preserves path separators
|
|
|
190
275
|
while encoding each segment. The host adapter receives only a resolved route,
|
|
191
276
|
environment, and encoded path.
|
|
192
277
|
|
|
193
|
-
```ts
|
|
278
|
+
```ts filename="navigation.ts"
|
|
279
|
+
import assert from "node:assert/strict";
|
|
194
280
|
import { createMarquetteNavigator } from "@vizejs/marquette/navigation";
|
|
281
|
+
import shop from "./app.marquette.ts";
|
|
195
282
|
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
283
|
+
const opened: string[] = [];
|
|
284
|
+
const navigation = createMarquetteNavigator(shop, (target) => {
|
|
285
|
+
opened.push(target.path);
|
|
286
|
+
return target;
|
|
287
|
+
});
|
|
288
|
+
const target = navigation.navigate("profile", { userId: "a user" });
|
|
289
|
+
assert.deepEqual(target, { route: "profile", environment: "native", path: "/users/a%20user" });
|
|
290
|
+
assert.deepEqual(opened, ["/users/a%20user"]);
|
|
199
291
|
```
|
|
200
292
|
|
|
201
293
|
Unknown routes and missing, extra, empty, or non-finite parameters are rejected
|
|
@@ -208,20 +300,26 @@ The experimental `@vizejs/marquette/navigation/links` entry resolves incoming
|
|
|
208
300
|
HTTPS and custom-scheme links against the same authored route contract. Select
|
|
209
301
|
the owning environment and explicitly admit each origin:
|
|
210
302
|
|
|
211
|
-
```ts
|
|
303
|
+
```ts filename="links.ts"
|
|
304
|
+
import assert from "node:assert/strict";
|
|
212
305
|
import { createMarquetteLinkResolver } from "@vizejs/marquette/navigation/links";
|
|
306
|
+
import shop from "./app.marquette.ts";
|
|
213
307
|
|
|
214
|
-
const links = createMarquetteLinkResolver(
|
|
308
|
+
const links = createMarquetteLinkResolver(shop, {
|
|
215
309
|
environment: "native",
|
|
216
310
|
origins: ["https://shop.example", "shop://app"],
|
|
217
311
|
});
|
|
218
|
-
|
|
312
|
+
const incomingLink = "shop://app/users/a%20user";
|
|
219
313
|
const result = links.resolve(incomingLink);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
314
|
+
assert.deepEqual(result, {
|
|
315
|
+
matched: true,
|
|
316
|
+
target: {
|
|
317
|
+
route: "profile",
|
|
318
|
+
environment: "native",
|
|
319
|
+
path: "/users/a%20user",
|
|
320
|
+
parameters: { userId: "a user" },
|
|
321
|
+
},
|
|
322
|
+
});
|
|
225
323
|
```
|
|
226
324
|
|
|
227
325
|
Successful targets preserve route and environment literals, infer decoded string
|
|
@@ -244,25 +342,39 @@ launch and operating-system link registration remain host responsibilities.
|
|
|
244
342
|
## Test-run evidence
|
|
245
343
|
|
|
246
344
|
Release-bound test-run evidence records live in their own lazy entries so
|
|
247
|
-
deployment tooling can bind a `tests` check to retained, immutable facts
|
|
345
|
+
deployment tooling can bind a `tests` check to retained, immutable facts.
|
|
346
|
+
Copy the [sample inputs](./examples/test-run-inputs.ts) into `examples/`. They
|
|
347
|
+
retain the shared canonical fixtures and their fixed historical clock; they
|
|
348
|
+
demonstrate API behavior and do not authorize a current release.
|
|
248
349
|
|
|
249
|
-
```ts
|
|
350
|
+
```ts filename="test-run.ts"
|
|
351
|
+
import assert from "node:assert/strict";
|
|
250
352
|
import { defineTestRunEvidence } from "@vizejs/marquette/test-run";
|
|
251
353
|
import { validateTestRunEvidence } from "@vizejs/marquette/test-run/validate";
|
|
252
354
|
import { testRunAdmissionId } from "@vizejs/marquette/test-run/canonical";
|
|
253
355
|
import { admitTestRun, decideTestRunAdmission } from "@vizejs/marquette/test-run/admission";
|
|
254
356
|
import { verifyTestRunCheck } from "@vizejs/marquette/test-run/check";
|
|
255
357
|
import { verifyTestRunTransition } from "@vizejs/marquette/test-run/transition";
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
358
|
+
import {
|
|
359
|
+
rawEvidence,
|
|
360
|
+
candidate,
|
|
361
|
+
now,
|
|
362
|
+
retainedCheck,
|
|
363
|
+
nextTransition,
|
|
364
|
+
chainTip,
|
|
365
|
+
expectedAdmissionId,
|
|
366
|
+
} from "./examples/test-run-inputs.ts";
|
|
367
|
+
|
|
368
|
+
const evidence = defineTestRunEvidence(rawEvidence);
|
|
369
|
+
assert.equal(evidence, rawEvidence);
|
|
370
|
+
assert.deepEqual(validateTestRunEvidence(evidence), []);
|
|
371
|
+
const admissionId = await testRunAdmissionId(evidence);
|
|
372
|
+
assert.equal(admissionId, expectedAdmissionId);
|
|
373
|
+
assert.deepEqual(await admitTestRun(evidence, candidate, admissionId, now), []);
|
|
260
374
|
const decision = await decideTestRunAdmission(evidence, candidate, admissionId, now);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const release = await verifyTestRunCheck(retainedCheck, candidate, evidence, now);
|
|
265
|
-
const journal = await verifyTestRunTransition(nextTransition, chainTip);
|
|
375
|
+
assert.deepEqual(decision, { allowed: true, denialCodes: [], diagnostics: [] });
|
|
376
|
+
assert.deepEqual(await verifyTestRunCheck(retainedCheck, candidate, evidence, now), decision);
|
|
377
|
+
assert.deepEqual(await verifyTestRunTransition(nextTransition, chainTip), decision);
|
|
266
378
|
```
|
|
267
379
|
|
|
268
380
|
Validation shares its `VIZE_MARQUETTE_1xx` codes, paths, and ordering with the
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"required": ["id", "minVersion", "maxVersion"],
|
|
16
16
|
"properties": {
|
|
17
17
|
"id": { "$ref": "#/$defs/identifier" },
|
|
18
|
-
"minVersion": { "type": "integer", "minimum": 1 },
|
|
19
|
-
"maxVersion": { "type": "integer", "minimum": 1 }
|
|
18
|
+
"minVersion": { "type": "integer", "minimum": 1, "maximum": 4294967295 },
|
|
19
|
+
"maxVersion": { "type": "integer", "minimum": 1, "maximum": 4294967295 }
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"manifest": {
|
package/dist/adapter.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ApplicationMarquette } from "./model-
|
|
1
|
+
import { t as ApplicationMarquette } from "./model-BcXukmxj.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/adapter-model.d.ts
|
|
4
4
|
/** Current serialized adapter-capability manifest format. */
|
|
@@ -7,9 +7,9 @@ declare const ADAPTER_CAPABILITY_FORMAT_VERSION: 1;
|
|
|
7
7
|
interface AdapterCapabilitySupport {
|
|
8
8
|
/** Stable capability identifier from an application marquette. */
|
|
9
9
|
readonly id: string;
|
|
10
|
-
/** Oldest supported capability contract version, inclusive. */
|
|
10
|
+
/** Oldest supported capability contract version, inclusive; a positive unsigned 32-bit integer. */
|
|
11
11
|
readonly minVersion: number;
|
|
12
|
-
/** Newest supported capability contract version, inclusive. */
|
|
12
|
+
/** Newest supported capability contract version, inclusive; a positive unsigned 32-bit integer. */
|
|
13
13
|
readonly maxVersion: number;
|
|
14
14
|
}
|
|
15
15
|
/** Versioned, language-neutral capabilities offered by one adapter. */
|
|
@@ -41,7 +41,7 @@ interface AdapterCapabilityDiagnostic {
|
|
|
41
41
|
readonly message: string;
|
|
42
42
|
}
|
|
43
43
|
/** Stable incompatibility code emitted during capability negotiation. */
|
|
44
|
-
type AdapterCapabilityMismatchCode = "unknown-requirement" | "missing-capability" | "version-below-minimum" | "version-above-maximum";
|
|
44
|
+
type AdapterCapabilityMismatchCode = "unknown-requirement" | "missing-capability" | "version-below-minimum" | "version-above-maximum" | "invalid-requirement-version";
|
|
45
45
|
/** One failed adapter capability requirement. */
|
|
46
46
|
interface AdapterCapabilityMismatch {
|
|
47
47
|
/** Stable machine-readable mismatch code. */
|
package/dist/adapter.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.mts","names":[],"sources":["../src/adapter-model.ts","../src/adapter-native-profile.ts","../src/adapter-compatibility.ts","../src/adapter-negotiate.ts","../src/adapter-validate.ts"],"mappings":";;;;cACa,iCAAA;;UAGI,wBAAA;EAH0C;EAAA,SAKhD,EAAA;EALgD;EAAA,SAOhD,UAAA;EAJM;EAAA,SAMN,UAAA;AAAA;;UAIM,yBAAA;EANN;;;AAEU;AAIrB;EANW,SAYA,aAAA,UAAuB,iCAAA;;WAEvB,OAAA;EAFA;;;;;EAAA,SAQA,YAAA,YAAwB,wBAAwB;AAAA;AAI3D;AAAA,KAAY,+BAAA;;UASK,2BAAA;EAT0B;EAAA,SAWhC,IAAA,EAAM,+BAA+B;EAFJ;EAAA,SAIjC,IAAA;EAFqC;EAAA,SAIrC,OAAA;AAAA;;KAIC,6BAAA;;
|
|
1
|
+
{"version":3,"file":"adapter.d.mts","names":[],"sources":["../src/adapter-model.ts","../src/adapter-native-profile.ts","../src/adapter-compatibility.ts","../src/adapter-negotiate.ts","../src/adapter-validate.ts"],"mappings":";;;;cACa,iCAAA;;UAGI,wBAAA;EAH0C;EAAA,SAKhD,EAAA;EALgD;EAAA,SAOhD,UAAA;EAJM;EAAA,SAMN,UAAA;AAAA;;UAIM,yBAAA;EANN;;;AAEU;AAIrB;EANW,S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,GACT,2BAA2B;AJnB9B;;;;AAA2D;AAG3D;;AAHA,iBIkIgB,8BAAA,CAA+B,KAAA,YAAiB,yBAAyB"}
|
package/dist/adapter.mjs
CHANGED
|
@@ -51,8 +51,10 @@ function validateAdapterCapabilityManifest(manifest) {
|
|
|
51
51
|
if (!IDENTIFIER.test(capability.id)) diagnostics.push(diagnostic("invalid-capability-id", `${path}.id`, "capability id must be a lowercase portable identifier"));
|
|
52
52
|
if (seen.has(capability.id)) diagnostics.push(diagnostic("duplicate-capability", `${path}.id`, "capability id must be unique within the adapter manifest"));
|
|
53
53
|
seen.add(capability.id);
|
|
54
|
-
if (capability.minVersion
|
|
55
|
-
if (capability.
|
|
54
|
+
if (!Number.isInteger(capability.minVersion) || capability.minVersion < 0 || capability.minVersion > 4294967295) diagnostics.push(diagnostic("invalid-version", `${path}.minVersion`, "minimum supported version must be an unsigned 32-bit integer"));
|
|
55
|
+
else if (capability.minVersion === 0) diagnostics.push(diagnostic("invalid-version", `${path}.minVersion`, "minimum supported version must be greater than zero"));
|
|
56
|
+
if (!Number.isInteger(capability.maxVersion) || capability.maxVersion < 0 || capability.maxVersion > 4294967295) diagnostics.push(diagnostic("invalid-version", `${path}.maxVersion`, "maximum supported version must be an unsigned 32-bit integer"));
|
|
57
|
+
else if (capability.maxVersion === 0) diagnostics.push(diagnostic("invalid-version", `${path}.maxVersion`, "maximum supported version must be greater than zero"));
|
|
56
58
|
if (capability.minVersion > capability.maxVersion) diagnostics.push(diagnostic("invalid-version-range", path, "minimum supported version must not exceed maximum supported version"));
|
|
57
59
|
}
|
|
58
60
|
return diagnostics.sort((left, right) => compareText$1(left.path, right.path) || DIAGNOSTIC_ORDER[left.code] - DIAGNOSTIC_ORDER[right.code] || compareText$1(left.message, right.message));
|
|
@@ -84,8 +86,8 @@ function parseAdapterCapabilityManifest(value) {
|
|
|
84
86
|
"maxVersion"
|
|
85
87
|
], path);
|
|
86
88
|
if (typeof capability.id !== "string") throw new TypeError(`${path}.id must be a string`);
|
|
87
|
-
if (typeof capability.minVersion !== "number" || !Number.isSafeInteger(capability.minVersion) || capability.minVersion < 0) throw new TypeError(`${path}.minVersion must be a safe integer`);
|
|
88
|
-
if (typeof capability.maxVersion !== "number" || !Number.isSafeInteger(capability.maxVersion) || capability.maxVersion < 0) throw new TypeError(`${path}.maxVersion must be a safe integer`);
|
|
89
|
+
if (typeof capability.minVersion !== "number" || !Number.isSafeInteger(capability.minVersion) || capability.minVersion < 0 || capability.minVersion > 4294967295) throw new TypeError(`${path}.minVersion must be a safe integer in the unsigned 32-bit range`);
|
|
90
|
+
if (typeof capability.maxVersion !== "number" || !Number.isSafeInteger(capability.maxVersion) || capability.maxVersion < 0 || capability.maxVersion > 4294967295) throw new TypeError(`${path}.maxVersion must be a safe integer in the unsigned 32-bit range`);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
return value;
|
|
@@ -177,10 +179,12 @@ function negotiateAdapterCapabilities(marquette, requiredCapabilities, manifest)
|
|
|
177
179
|
};
|
|
178
180
|
}
|
|
179
181
|
function mismatch(marquette, id, support, manifestIsValid) {
|
|
180
|
-
const
|
|
182
|
+
const declarations = marquette.capabilities;
|
|
183
|
+
const requirement = declarations && Object.hasOwn(declarations, id) ? declarations[id] : void 0;
|
|
181
184
|
if (requirement === void 0) return [problem("unknown-requirement", id)];
|
|
185
|
+
const requiredVersion = requirement.version === void 0 ? 1 : requirement.version;
|
|
186
|
+
if (!Number.isInteger(requiredVersion) || requiredVersion < 1 || requiredVersion > 4294967295) return [problem("invalid-requirement-version", id)];
|
|
182
187
|
if (!manifestIsValid) return [];
|
|
183
|
-
const requiredVersion = requirement.version ?? 1;
|
|
184
188
|
if (support === void 0) return [problem("missing-capability", id, requiredVersion)];
|
|
185
189
|
if (requiredVersion < support.minVersion) return [problem("version-below-minimum", id, requiredVersion, support)];
|
|
186
190
|
if (requiredVersion > support.maxVersion) return [problem("version-above-maximum", id, requiredVersion, support)];
|
|
@@ -202,6 +206,7 @@ function problem(code, capability, requiredVersion, support) {
|
|
|
202
206
|
function mismatchMessage(code) {
|
|
203
207
|
switch (code) {
|
|
204
208
|
case "unknown-requirement": return "application references an undeclared capability requirement";
|
|
209
|
+
case "invalid-requirement-version": return "application capability version must be a positive unsigned 32-bit integer";
|
|
205
210
|
case "missing-capability": return "adapter does not support the required capability";
|
|
206
211
|
case "version-below-minimum": return "application requires a capability version below the adapter minimum";
|
|
207
212
|
case "version-above-maximum": return "application requires a capability version above the adapter maximum";
|
package/dist/adapter.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.mjs","names":["compareText"],"sources":["../src/adapter-model.ts","../src/adapter-native-profile.ts","../src/adapter-validate.ts","../src/adapter-compatibility.ts","../src/adapter-negotiate.ts"],"sourcesContent":["/** Current serialized adapter-capability manifest format. */\nexport const ADAPTER_CAPABILITY_FORMAT_VERSION = 1 as const;\n\n/** Inclusive version range supported for one capability contract. */\nexport interface AdapterCapabilitySupport {\n /** Stable capability identifier from an application marquette. */\n readonly id: string;\n /** Oldest supported capability contract version, inclusive. */\n readonly minVersion: number;\n /** Newest supported capability contract version, inclusive. */\n readonly maxVersion: number;\n}\n\n/** Versioned, language-neutral capabilities offered by one adapter. */\nexport interface AdapterCapabilityManifest {\n /**\n * Serialized manifest format.\n *\n * @default 1\n */\n readonly formatVersion?: typeof ADAPTER_CAPABILITY_FORMAT_VERSION;\n /** Stable adapter identifier shown in diagnostics and reports. */\n readonly adapter: string;\n /**\n * Supported capability ranges.\n *\n * @default []\n */\n readonly capabilities?: readonly AdapterCapabilitySupport[];\n}\n\n/** Stable validation code for an adapter capability manifest. */\nexport type AdapterCapabilityDiagnosticCode =\n | \"invalid-format-version\"\n | \"invalid-adapter-id\"\n | \"invalid-capability-id\"\n | \"invalid-version\"\n | \"invalid-version-range\"\n | \"duplicate-capability\";\n\n/** Deterministic validation diagnostic for an adapter capability manifest. */\nexport interface AdapterCapabilityDiagnostic {\n /** Stable machine-readable diagnostic code. */\n readonly code: AdapterCapabilityDiagnosticCode;\n /** JSON-style path of the invalid value. */\n readonly path: string;\n /** Human-readable explanation. */\n readonly message: string;\n}\n\n/** Stable incompatibility code emitted during capability negotiation. */\nexport type AdapterCapabilityMismatchCode =\n | \"unknown-requirement\"\n | \"missing-capability\"\n | \"version-below-minimum\"\n | \"version-above-maximum\";\n\n/** One failed adapter capability requirement. */\nexport interface AdapterCapabilityMismatch {\n /** Stable machine-readable mismatch code. */\n readonly code: AdapterCapabilityMismatchCode;\n /** Required capability identifier. */\n readonly capability: string;\n /** JSON-style path of the unsupported application capability requirement. */\n readonly path: string;\n /** Human-readable explanation with stable wording for renderer diagnostics. */\n readonly message: string;\n /** Required contract version when the capability is declared. */\n readonly requiredVersion?: number;\n /** Adapter minimum when support exists. */\n readonly minVersion?: number;\n /** Adapter maximum when support exists. */\n readonly maxVersion?: number;\n}\n\n/** Deterministic result of negotiating requirements with one adapter. */\nexport interface AdapterCapabilityNegotiation {\n /** Adapter whose support was inspected. */\n readonly adapter: string;\n /** Whether the manifest is valid and every requirement is supported. */\n readonly compatible: boolean;\n /** Manifest validation failures, in stable path order. */\n readonly diagnostics: readonly AdapterCapabilityDiagnostic[];\n /** Unsupported or unknown requirements, in stable capability order. */\n readonly mismatches: readonly AdapterCapabilityMismatch[];\n}\n\n/** Compatibility classification for one adapter capability change. */\nexport type CompatibilityChangeKind = \"additive\" | \"breaking\";\n\n/** One stable adapter capability compatibility change. */\nexport interface AdapterCapabilityCompatibilityChange {\n /** Compatibility classification. */\n readonly kind: CompatibilityChangeKind;\n /** JSON-style path of the changed capability support. */\n readonly path: string;\n /** Human-readable summary. */\n readonly message: string;\n}\n\n/** Deterministic compatibility report between two adapter manifests. */\nexport interface AdapterCapabilityCompatibilityReport {\n /** Validation failures in the previous manifest. */\n readonly previousDiagnostics: readonly AdapterCapabilityDiagnostic[];\n /** Validation failures in the next manifest. */\n readonly nextDiagnostics: readonly AdapterCapabilityDiagnostic[];\n /** All changes in stable path order. */\n readonly changes: readonly AdapterCapabilityCompatibilityChange[];\n}\n","import type { AdapterCapabilitySupport } from \"./adapter-model.js\";\n\n/** Current contract version shared by the native-engine capability profile. */\nexport const NATIVE_ENGINE_CAPABILITY_VERSION = 1 as const;\n\n/** Closed set of capability identifiers required from a native rendering engine. */\nexport const NATIVE_ENGINE_CAPABILITY_IDS = [\n \"native.rendering\",\n \"native.events\",\n \"native.layout\",\n \"native.text\",\n \"native.images\",\n \"native.animation\",\n \"native.accessibility\",\n \"native.lifecycle\",\n] as const;\n\n/** One identifier from the canonical native-engine capability profile. */\nexport type NativeEngineCapabilityId = (typeof NATIVE_ENGINE_CAPABILITY_IDS)[number];\n\n/**\n * Creates the canonical version-one native-engine capability profile.\n *\n * A fresh list is returned so an adapter can extend its manifest without\n * mutating the shared profile seen by another consumer.\n */\nexport function nativeEngineCapabilityProfile(): readonly AdapterCapabilitySupport[] {\n return NATIVE_ENGINE_CAPABILITY_IDS.map((id) => ({\n id,\n minVersion: NATIVE_ENGINE_CAPABILITY_VERSION,\n maxVersion: NATIVE_ENGINE_CAPABILITY_VERSION,\n }));\n}\n","import {\n ADAPTER_CAPABILITY_FORMAT_VERSION,\n type AdapterCapabilityDiagnostic,\n type AdapterCapabilityDiagnosticCode,\n type AdapterCapabilityManifest,\n} from \"./adapter-model.js\";\n\nconst IDENTIFIER = /^[a-z0-9][a-z0-9._-]*$/;\nconst DIAGNOSTIC_ORDER: Record<AdapterCapabilityDiagnosticCode, number> = {\n \"invalid-format-version\": 0,\n \"invalid-adapter-id\": 1,\n \"invalid-capability-id\": 2,\n \"invalid-version\": 3,\n \"invalid-version-range\": 4,\n \"duplicate-capability\": 5,\n};\n\n/** Validates an adapter capability manifest without mutating it. */\nexport function validateAdapterCapabilityManifest(\n manifest: AdapterCapabilityManifest,\n): AdapterCapabilityDiagnostic[] {\n const diagnostics: AdapterCapabilityDiagnostic[] = [];\n if ((manifest.formatVersion ?? 1) !== ADAPTER_CAPABILITY_FORMAT_VERSION) {\n diagnostics.push(\n diagnostic(\n \"invalid-format-version\",\n \"formatVersion\",\n \"unsupported adapter capability manifest format version\",\n ),\n );\n }\n if (!IDENTIFIER.test(manifest.adapter)) {\n diagnostics.push(\n diagnostic(\n \"invalid-adapter-id\",\n \"adapter\",\n \"adapter must be a lowercase portable identifier\",\n ),\n );\n }\n\n const seen = new Set<string>();\n for (const [index, capability] of (manifest.capabilities ?? []).entries()) {\n const path = `capabilities.${index}`;\n if (!IDENTIFIER.test(capability.id)) {\n diagnostics.push(\n diagnostic(\n \"invalid-capability-id\",\n `${path}.id`,\n \"capability id must be a lowercase portable identifier\",\n ),\n );\n }\n if (seen.has(capability.id)) {\n diagnostics.push(\n diagnostic(\n \"duplicate-capability\",\n `${path}.id`,\n \"capability id must be unique within the adapter manifest\",\n ),\n );\n }\n seen.add(capability.id);\n if (capability.minVersion <= 0) {\n diagnostics.push(\n diagnostic(\n \"invalid-version\",\n `${path}.minVersion`,\n \"minimum supported version must be greater than zero\",\n ),\n );\n }\n if (capability.maxVersion <= 0) {\n diagnostics.push(\n diagnostic(\n \"invalid-version\",\n `${path}.maxVersion`,\n \"maximum supported version must be greater than zero\",\n ),\n );\n }\n if (capability.minVersion > capability.maxVersion) {\n diagnostics.push(\n diagnostic(\n \"invalid-version-range\",\n path,\n \"minimum supported version must not exceed maximum supported version\",\n ),\n );\n }\n }\n\n return diagnostics.sort(\n (left, right) =>\n compareText(left.path, right.path) ||\n DIAGNOSTIC_ORDER[left.code] - DIAGNOSTIC_ORDER[right.code] ||\n compareText(left.message, right.message),\n );\n}\n\n/**\n * Parses an untrusted manifest with strict field and primitive checks.\n *\n * Unknown fields, missing required fields, and mismatched primitive types\n * throw before negotiation. Semantic range errors remain available from\n * {@link validateAdapterCapabilityManifest}.\n */\nexport function parseAdapterCapabilityManifest(value: unknown): AdapterCapabilityManifest {\n assertRecord(value, \"manifest\");\n assertKnownFields(value, [\"formatVersion\", \"adapter\", \"capabilities\"], \"manifest\");\n if (value.formatVersion !== undefined && typeof value.formatVersion !== \"number\") {\n throw new TypeError(\"formatVersion must be a number\");\n }\n if (typeof value.adapter !== \"string\") {\n throw new TypeError(\"adapter must be a string\");\n }\n if (value.capabilities !== undefined) {\n if (!Array.isArray(value.capabilities)) {\n throw new TypeError(\"capabilities must be an array\");\n }\n for (const [index, capability] of value.capabilities.entries()) {\n const path = `capabilities.${index}`;\n assertRecord(capability, path);\n assertKnownFields(capability, [\"id\", \"minVersion\", \"maxVersion\"], path);\n if (typeof capability.id !== \"string\") throw new TypeError(`${path}.id must be a string`);\n if (\n typeof capability.minVersion !== \"number\" ||\n !Number.isSafeInteger(capability.minVersion) ||\n capability.minVersion < 0\n ) {\n throw new TypeError(`${path}.minVersion must be a safe integer`);\n }\n if (\n typeof capability.maxVersion !== \"number\" ||\n !Number.isSafeInteger(capability.maxVersion) ||\n capability.maxVersion < 0\n ) {\n throw new TypeError(`${path}.maxVersion must be a safe integer`);\n }\n }\n }\n return value as unknown as AdapterCapabilityManifest;\n}\n\nfunction diagnostic(\n code: AdapterCapabilityDiagnosticCode,\n path: string,\n message: string,\n): AdapterCapabilityDiagnostic {\n return { code, path, message };\n}\n\nfunction assertRecord(value: unknown, path: string): asserts value is Record<string, unknown> {\n if (value == null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(`${path} must be an object`);\n }\n}\n\nfunction assertKnownFields(\n value: Record<string, unknown>,\n expected: readonly string[],\n path: string,\n): void {\n const known = new Set(expected);\n const unknown = Object.keys(value).find((field) => !known.has(field));\n if (unknown !== undefined) throw new TypeError(`${path} has unknown field ${unknown}`);\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n","import type {\n AdapterCapabilityCompatibilityChange,\n AdapterCapabilityCompatibilityReport,\n AdapterCapabilityManifest,\n AdapterCapabilitySupport,\n CompatibilityChangeKind,\n} from \"./adapter-model.js\";\nimport { validateAdapterCapabilityManifest } from \"./adapter-validate.js\";\n\n/**\n * Compares adapter capability support from older to newer.\n *\n * Adding support or widening an inclusive version range is additive.\n * Removing support or narrowing either bound is breaking.\n */\nexport function compareAdapterCapabilities(\n previous: AdapterCapabilityManifest,\n next: AdapterCapabilityManifest,\n): AdapterCapabilityCompatibilityReport {\n const previousDiagnostics = validateAdapterCapabilityManifest(previous);\n const nextDiagnostics = validateAdapterCapabilityManifest(next);\n if (previousDiagnostics.length > 0 || nextDiagnostics.length > 0) {\n return { previousDiagnostics, nextDiagnostics, changes: [] };\n }\n\n const changes: AdapterCapabilityCompatibilityChange[] = [];\n if (previous.adapter !== next.adapter) {\n changes.push(change(\"breaking\", \"adapter\", \"adapter identity changed\"));\n }\n\n const oldSupport = byId(previous);\n const newSupport = byId(next);\n for (const id of [...oldSupport.keys()].filter((id) => !newSupport.has(id)).sort()) {\n changes.push(change(\"breaking\", `capabilities.${id}`, \"capability support was removed\"));\n }\n for (const id of [...newSupport.keys()].filter((id) => !oldSupport.has(id)).sort()) {\n changes.push(change(\"additive\", `capabilities.${id}`, \"capability support was added\"));\n }\n for (const [id, old] of oldSupport) {\n const current = newSupport.get(id);\n if (current === undefined) continue;\n if (old.minVersion !== current.minVersion) {\n changes.push(\n change(\n current.minVersion < old.minVersion ? \"additive\" : \"breaking\",\n `capabilities.${id}.minVersion`,\n current.minVersion < old.minVersion\n ? \"minimum supported version decreased\"\n : \"minimum supported version increased\",\n ),\n );\n }\n if (old.maxVersion !== current.maxVersion) {\n changes.push(\n change(\n current.maxVersion > old.maxVersion ? \"additive\" : \"breaking\",\n `capabilities.${id}.maxVersion`,\n current.maxVersion > old.maxVersion\n ? \"maximum supported version increased\"\n : \"maximum supported version decreased\",\n ),\n );\n }\n }\n\n changes.sort(\n (left, right) => compareText(left.path, right.path) || compareText(left.kind, right.kind),\n );\n return { previousDiagnostics, nextDiagnostics, changes };\n}\n\nfunction byId(manifest: AdapterCapabilityManifest): Map<string, AdapterCapabilitySupport> {\n return new Map((manifest.capabilities ?? []).map((value) => [value.id, value] as const));\n}\n\nfunction change(\n kind: CompatibilityChangeKind,\n path: string,\n message: string,\n): AdapterCapabilityCompatibilityChange {\n return { kind, path, message };\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n","import type { ApplicationMarquette } from \"./model.js\";\nimport type {\n AdapterCapabilityManifest,\n AdapterCapabilityMismatch,\n AdapterCapabilityMismatchCode,\n AdapterCapabilityNegotiation,\n AdapterCapabilitySupport,\n} from \"./adapter-model.js\";\nimport { validateAdapterCapabilityManifest } from \"./adapter-validate.js\";\n\n/**\n * Negotiates application capability requirements against one adapter.\n *\n * Requirement identifiers are deduplicated and sorted. Unknown application\n * capability identifiers fail closed instead of being treated as adapter\n * omissions. An invalid manifest never produces a compatible result.\n */\nexport function negotiateAdapterCapabilities(\n marquette: ApplicationMarquette,\n requiredCapabilities: readonly string[],\n manifest: AdapterCapabilityManifest,\n): AdapterCapabilityNegotiation {\n const diagnostics = validateAdapterCapabilityManifest(manifest);\n const support = new Map(\n (manifest.capabilities ?? []).map((capability) => [capability.id, capability] as const),\n );\n const mismatches = [...new Set(requiredCapabilities)]\n .sort()\n .flatMap((id) => mismatch(marquette, id, support.get(id), diagnostics.length === 0));\n\n return {\n adapter: manifest.adapter,\n compatible: diagnostics.length === 0 && mismatches.length === 0,\n diagnostics,\n mismatches,\n };\n}\n\nfunction mismatch(\n marquette: ApplicationMarquette,\n id: string,\n support: AdapterCapabilitySupport | undefined,\n manifestIsValid: boolean,\n): AdapterCapabilityMismatch[] {\n const requirement = marquette.capabilities?.[id];\n if (requirement === undefined) return [problem(\"unknown-requirement\", id)];\n if (!manifestIsValid) return [];\n\n const requiredVersion = requirement.version ?? 1;\n if (support === undefined) return [problem(\"missing-capability\", id, requiredVersion)];\n if (requiredVersion < support.minVersion) {\n return [problem(\"version-below-minimum\", id, requiredVersion, support)];\n }\n if (requiredVersion > support.maxVersion) {\n return [problem(\"version-above-maximum\", id, requiredVersion, support)];\n }\n return [];\n}\n\nfunction problem(\n code: AdapterCapabilityMismatchCode,\n capability: string,\n requiredVersion?: number,\n support?: AdapterCapabilitySupport,\n): AdapterCapabilityMismatch {\n return {\n code,\n capability,\n path: `capabilities.${capability}`,\n message: mismatchMessage(code),\n ...(requiredVersion === undefined ? {} : { requiredVersion }),\n ...(support === undefined\n ? {}\n : { minVersion: support.minVersion, maxVersion: support.maxVersion }),\n };\n}\n\nfunction mismatchMessage(code: AdapterCapabilityMismatchCode): string {\n switch (code) {\n case \"unknown-requirement\":\n return \"application references an undeclared capability requirement\";\n case \"missing-capability\":\n return \"adapter does not support the required capability\";\n case \"version-below-minimum\":\n return \"application requires a capability version below the adapter minimum\";\n case \"version-above-maximum\":\n return \"application requires a capability version above the adapter maximum\";\n }\n}\n"],"mappings":";;AACA,MAAa,oCAAoC;;;;ACEjD,MAAa,mCAAmC;;AAGhD,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAWA,SAAgB,gCAAqE;CACnF,OAAO,6BAA6B,KAAK,QAAQ;EAC/C;EACA,YAAA;EACA,YAAA;CACF,EAAE;AACJ;;;ACzBA,MAAM,aAAa;AACnB,MAAM,mBAAoE;CACxE,0BAA0B;CAC1B,sBAAsB;CACtB,yBAAyB;CACzB,mBAAmB;CACnB,yBAAyB;CACzB,wBAAwB;AAC1B;;AAGA,SAAgB,kCACd,UAC+B;CAC/B,MAAM,cAA6C,CAAC;CACpD,KAAK,SAAS,iBAAiB,OAAA,GAC7B,YAAY,KACV,WACE,0BACA,iBACA,wDACF,CACF;CAEF,IAAI,CAAC,WAAW,KAAK,SAAS,OAAO,GACnC,YAAY,KACV,WACE,sBACA,WACA,iDACF,CACF;CAGF,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,CAAC,OAAO,gBAAgB,SAAS,gBAAgB,CAAC,GAAG,QAAQ,GAAG;EACzE,MAAM,OAAO,gBAAgB;EAC7B,IAAI,CAAC,WAAW,KAAK,WAAW,EAAE,GAChC,YA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K,sBACH,OAAO;EACT,KAAK,yBACH,OAAO;EACT,KAAK,yBACH,OAAO;CACX;AACF"}
|
|
1
|
+
{"version":3,"file":"adapter.mjs","names":["compareText"],"sources":["../src/adapter-model.ts","../src/adapter-native-profile.ts","../src/adapter-validate.ts","../src/adapter-compatibility.ts","../src/adapter-negotiate.ts"],"sourcesContent":["/** Current serialized adapter-capability manifest format. */\nexport const ADAPTER_CAPABILITY_FORMAT_VERSION = 1 as const;\n\n/** Inclusive version range supported for one capability contract. */\nexport interface AdapterCapabilitySupport {\n /** Stable capability identifier from an application marquette. */\n readonly id: string;\n /** Oldest supported capability contract version, inclusive; a positive unsigned 32-bit integer. */\n readonly minVersion: number;\n /** Newest supported capability contract version, inclusive; a positive unsigned 32-bit integer. */\n readonly maxVersion: number;\n}\n\n/** Versioned, language-neutral capabilities offered by one adapter. */\nexport interface AdapterCapabilityManifest {\n /**\n * Serialized manifest format.\n *\n * @default 1\n */\n readonly formatVersion?: typeof ADAPTER_CAPABILITY_FORMAT_VERSION;\n /** Stable adapter identifier shown in diagnostics and reports. */\n readonly adapter: string;\n /**\n * Supported capability ranges.\n *\n * @default []\n */\n readonly capabilities?: readonly AdapterCapabilitySupport[];\n}\n\n/** Stable validation code for an adapter capability manifest. */\nexport type AdapterCapabilityDiagnosticCode =\n | \"invalid-format-version\"\n | \"invalid-adapter-id\"\n | \"invalid-capability-id\"\n | \"invalid-version\"\n | \"invalid-version-range\"\n | \"duplicate-capability\";\n\n/** Deterministic validation diagnostic for an adapter capability manifest. */\nexport interface AdapterCapabilityDiagnostic {\n /** Stable machine-readable diagnostic code. */\n readonly code: AdapterCapabilityDiagnosticCode;\n /** JSON-style path of the invalid value. */\n readonly path: string;\n /** Human-readable explanation. */\n readonly message: string;\n}\n\n/** Stable incompatibility code emitted during capability negotiation. */\nexport type AdapterCapabilityMismatchCode =\n | \"unknown-requirement\"\n | \"missing-capability\"\n | \"version-below-minimum\"\n | \"version-above-maximum\"\n | \"invalid-requirement-version\";\n\n/** One failed adapter capability requirement. */\nexport interface AdapterCapabilityMismatch {\n /** Stable machine-readable mismatch code. */\n readonly code: AdapterCapabilityMismatchCode;\n /** Required capability identifier. */\n readonly capability: string;\n /** JSON-style path of the unsupported application capability requirement. */\n readonly path: string;\n /** Human-readable explanation with stable wording for renderer diagnostics. */\n readonly message: string;\n /** Required contract version when the capability is declared. */\n readonly requiredVersion?: number;\n /** Adapter minimum when support exists. */\n readonly minVersion?: number;\n /** Adapter maximum when support exists. */\n readonly maxVersion?: number;\n}\n\n/** Deterministic result of negotiating requirements with one adapter. */\nexport interface AdapterCapabilityNegotiation {\n /** Adapter whose support was inspected. */\n readonly adapter: string;\n /** Whether the manifest is valid and every requirement is supported. */\n readonly compatible: boolean;\n /** Manifest validation failures, in stable path order. */\n readonly diagnostics: readonly AdapterCapabilityDiagnostic[];\n /** Unsupported or unknown requirements, in stable capability order. */\n readonly mismatches: readonly AdapterCapabilityMismatch[];\n}\n\n/** Compatibility classification for one adapter capability change. */\nexport type CompatibilityChangeKind = \"additive\" | \"breaking\";\n\n/** One stable adapter capability compatibility change. */\nexport interface AdapterCapabilityCompatibilityChange {\n /** Compatibility classification. */\n readonly kind: CompatibilityChangeKind;\n /** JSON-style path of the changed capability support. */\n readonly path: string;\n /** Human-readable summary. */\n readonly message: string;\n}\n\n/** Deterministic compatibility report between two adapter manifests. */\nexport interface AdapterCapabilityCompatibilityReport {\n /** Validation failures in the previous manifest. */\n readonly previousDiagnostics: readonly AdapterCapabilityDiagnostic[];\n /** Validation failures in the next manifest. */\n readonly nextDiagnostics: readonly AdapterCapabilityDiagnostic[];\n /** All changes in stable path order. */\n readonly changes: readonly AdapterCapabilityCompatibilityChange[];\n}\n","import type { AdapterCapabilitySupport } from \"./adapter-model.js\";\n\n/** Current contract version shared by the native-engine capability profile. */\nexport const NATIVE_ENGINE_CAPABILITY_VERSION = 1 as const;\n\n/** Closed set of capability identifiers required from a native rendering engine. */\nexport const NATIVE_ENGINE_CAPABILITY_IDS = [\n \"native.rendering\",\n \"native.events\",\n \"native.layout\",\n \"native.text\",\n \"native.images\",\n \"native.animation\",\n \"native.accessibility\",\n \"native.lifecycle\",\n] as const;\n\n/** One identifier from the canonical native-engine capability profile. */\nexport type NativeEngineCapabilityId = (typeof NATIVE_ENGINE_CAPABILITY_IDS)[number];\n\n/**\n * Creates the canonical version-one native-engine capability profile.\n *\n * A fresh list is returned so an adapter can extend its manifest without\n * mutating the shared profile seen by another consumer.\n */\nexport function nativeEngineCapabilityProfile(): readonly AdapterCapabilitySupport[] {\n return NATIVE_ENGINE_CAPABILITY_IDS.map((id) => ({\n id,\n minVersion: NATIVE_ENGINE_CAPABILITY_VERSION,\n maxVersion: NATIVE_ENGINE_CAPABILITY_VERSION,\n }));\n}\n","import {\n ADAPTER_CAPABILITY_FORMAT_VERSION,\n type AdapterCapabilityDiagnostic,\n type AdapterCapabilityDiagnosticCode,\n type AdapterCapabilityManifest,\n} from \"./adapter-model.js\";\n\nconst IDENTIFIER = /^[a-z0-9][a-z0-9._-]*$/;\nconst DIAGNOSTIC_ORDER: Record<AdapterCapabilityDiagnosticCode, number> = {\n \"invalid-format-version\": 0,\n \"invalid-adapter-id\": 1,\n \"invalid-capability-id\": 2,\n \"invalid-version\": 3,\n \"invalid-version-range\": 4,\n \"duplicate-capability\": 5,\n};\n\n/** Validates an adapter capability manifest without mutating it. */\nexport function validateAdapterCapabilityManifest(\n manifest: AdapterCapabilityManifest,\n): AdapterCapabilityDiagnostic[] {\n const diagnostics: AdapterCapabilityDiagnostic[] = [];\n if ((manifest.formatVersion ?? 1) !== ADAPTER_CAPABILITY_FORMAT_VERSION) {\n diagnostics.push(\n diagnostic(\n \"invalid-format-version\",\n \"formatVersion\",\n \"unsupported adapter capability manifest format version\",\n ),\n );\n }\n if (!IDENTIFIER.test(manifest.adapter)) {\n diagnostics.push(\n diagnostic(\n \"invalid-adapter-id\",\n \"adapter\",\n \"adapter must be a lowercase portable identifier\",\n ),\n );\n }\n\n const seen = new Set<string>();\n for (const [index, capability] of (manifest.capabilities ?? []).entries()) {\n const path = `capabilities.${index}`;\n if (!IDENTIFIER.test(capability.id)) {\n diagnostics.push(\n diagnostic(\n \"invalid-capability-id\",\n `${path}.id`,\n \"capability id must be a lowercase portable identifier\",\n ),\n );\n }\n if (seen.has(capability.id)) {\n diagnostics.push(\n diagnostic(\n \"duplicate-capability\",\n `${path}.id`,\n \"capability id must be unique within the adapter manifest\",\n ),\n );\n }\n seen.add(capability.id);\n if (\n !Number.isInteger(capability.minVersion) ||\n capability.minVersion < 0 ||\n capability.minVersion > 0xffff_ffff\n ) {\n diagnostics.push(\n diagnostic(\n \"invalid-version\",\n `${path}.minVersion`,\n \"minimum supported version must be an unsigned 32-bit integer\",\n ),\n );\n } else if (capability.minVersion === 0) {\n diagnostics.push(\n diagnostic(\n \"invalid-version\",\n `${path}.minVersion`,\n \"minimum supported version must be greater than zero\",\n ),\n );\n }\n if (\n !Number.isInteger(capability.maxVersion) ||\n capability.maxVersion < 0 ||\n capability.maxVersion > 0xffff_ffff\n ) {\n diagnostics.push(\n diagnostic(\n \"invalid-version\",\n `${path}.maxVersion`,\n \"maximum supported version must be an unsigned 32-bit integer\",\n ),\n );\n } else if (capability.maxVersion === 0) {\n diagnostics.push(\n diagnostic(\n \"invalid-version\",\n `${path}.maxVersion`,\n \"maximum supported version must be greater than zero\",\n ),\n );\n }\n if (capability.minVersion > capability.maxVersion) {\n diagnostics.push(\n diagnostic(\n \"invalid-version-range\",\n path,\n \"minimum supported version must not exceed maximum supported version\",\n ),\n );\n }\n }\n\n return diagnostics.sort(\n (left, right) =>\n compareText(left.path, right.path) ||\n DIAGNOSTIC_ORDER[left.code] - DIAGNOSTIC_ORDER[right.code] ||\n compareText(left.message, right.message),\n );\n}\n\n/**\n * Parses an untrusted manifest with strict field and primitive checks.\n *\n * Unknown fields, missing required fields, and mismatched primitive types\n * throw before negotiation. Semantic range errors remain available from\n * {@link validateAdapterCapabilityManifest}.\n */\nexport function parseAdapterCapabilityManifest(value: unknown): AdapterCapabilityManifest {\n assertRecord(value, \"manifest\");\n assertKnownFields(value, [\"formatVersion\", \"adapter\", \"capabilities\"], \"manifest\");\n if (value.formatVersion !== undefined && typeof value.formatVersion !== \"number\") {\n throw new TypeError(\"formatVersion must be a number\");\n }\n if (typeof value.adapter !== \"string\") {\n throw new TypeError(\"adapter must be a string\");\n }\n if (value.capabilities !== undefined) {\n if (!Array.isArray(value.capabilities)) {\n throw new TypeError(\"capabilities must be an array\");\n }\n for (const [index, capability] of value.capabilities.entries()) {\n const path = `capabilities.${index}`;\n assertRecord(capability, path);\n assertKnownFields(capability, [\"id\", \"minVersion\", \"maxVersion\"], path);\n if (typeof capability.id !== \"string\") throw new TypeError(`${path}.id must be a string`);\n if (\n typeof capability.minVersion !== \"number\" ||\n !Number.isSafeInteger(capability.minVersion) ||\n capability.minVersion < 0 ||\n capability.minVersion > 0xffff_ffff\n ) {\n throw new TypeError(\n `${path}.minVersion must be a safe integer in the unsigned 32-bit range`,\n );\n }\n if (\n typeof capability.maxVersion !== \"number\" ||\n !Number.isSafeInteger(capability.maxVersion) ||\n capability.maxVersion < 0 ||\n capability.maxVersion > 0xffff_ffff\n ) {\n throw new TypeError(\n `${path}.maxVersion must be a safe integer in the unsigned 32-bit range`,\n );\n }\n }\n }\n return value as unknown as AdapterCapabilityManifest;\n}\n\nfunction diagnostic(\n code: AdapterCapabilityDiagnosticCode,\n path: string,\n message: string,\n): AdapterCapabilityDiagnostic {\n return { code, path, message };\n}\n\nfunction assertRecord(value: unknown, path: string): asserts value is Record<string, unknown> {\n if (value == null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(`${path} must be an object`);\n }\n}\n\nfunction assertKnownFields(\n value: Record<string, unknown>,\n expected: readonly string[],\n path: string,\n): void {\n const known = new Set(expected);\n const unknown = Object.keys(value).find((field) => !known.has(field));\n if (unknown !== undefined) throw new TypeError(`${path} has unknown field ${unknown}`);\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n","import type {\n AdapterCapabilityCompatibilityChange,\n AdapterCapabilityCompatibilityReport,\n AdapterCapabilityManifest,\n AdapterCapabilitySupport,\n CompatibilityChangeKind,\n} from \"./adapter-model.js\";\nimport { validateAdapterCapabilityManifest } from \"./adapter-validate.js\";\n\n/**\n * Compares adapter capability support from older to newer.\n *\n * Adding support or widening an inclusive version range is additive.\n * Removing support or narrowing either bound is breaking.\n */\nexport function compareAdapterCapabilities(\n previous: AdapterCapabilityManifest,\n next: AdapterCapabilityManifest,\n): AdapterCapabilityCompatibilityReport {\n const previousDiagnostics = validateAdapterCapabilityManifest(previous);\n const nextDiagnostics = validateAdapterCapabilityManifest(next);\n if (previousDiagnostics.length > 0 || nextDiagnostics.length > 0) {\n return { previousDiagnostics, nextDiagnostics, changes: [] };\n }\n\n const changes: AdapterCapabilityCompatibilityChange[] = [];\n if (previous.adapter !== next.adapter) {\n changes.push(change(\"breaking\", \"adapter\", \"adapter identity changed\"));\n }\n\n const oldSupport = byId(previous);\n const newSupport = byId(next);\n for (const id of [...oldSupport.keys()].filter((id) => !newSupport.has(id)).sort()) {\n changes.push(change(\"breaking\", `capabilities.${id}`, \"capability support was removed\"));\n }\n for (const id of [...newSupport.keys()].filter((id) => !oldSupport.has(id)).sort()) {\n changes.push(change(\"additive\", `capabilities.${id}`, \"capability support was added\"));\n }\n for (const [id, old] of oldSupport) {\n const current = newSupport.get(id);\n if (current === undefined) continue;\n if (old.minVersion !== current.minVersion) {\n changes.push(\n change(\n current.minVersion < old.minVersion ? \"additive\" : \"breaking\",\n `capabilities.${id}.minVersion`,\n current.minVersion < old.minVersion\n ? \"minimum supported version decreased\"\n : \"minimum supported version increased\",\n ),\n );\n }\n if (old.maxVersion !== current.maxVersion) {\n changes.push(\n change(\n current.maxVersion > old.maxVersion ? \"additive\" : \"breaking\",\n `capabilities.${id}.maxVersion`,\n current.maxVersion > old.maxVersion\n ? \"maximum supported version increased\"\n : \"maximum supported version decreased\",\n ),\n );\n }\n }\n\n changes.sort(\n (left, right) => compareText(left.path, right.path) || compareText(left.kind, right.kind),\n );\n return { previousDiagnostics, nextDiagnostics, changes };\n}\n\nfunction byId(manifest: AdapterCapabilityManifest): Map<string, AdapterCapabilitySupport> {\n return new Map((manifest.capabilities ?? []).map((value) => [value.id, value] as const));\n}\n\nfunction change(\n kind: CompatibilityChangeKind,\n path: string,\n message: string,\n): AdapterCapabilityCompatibilityChange {\n return { kind, path, message };\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n","import type { ApplicationMarquette } from \"./model.js\";\nimport type {\n AdapterCapabilityManifest,\n AdapterCapabilityMismatch,\n AdapterCapabilityMismatchCode,\n AdapterCapabilityNegotiation,\n AdapterCapabilitySupport,\n} from \"./adapter-model.js\";\nimport { validateAdapterCapabilityManifest } from \"./adapter-validate.js\";\n\n/**\n * Negotiates application capability requirements against one adapter.\n *\n * Requirement identifiers are deduplicated and sorted. Unknown application\n * capability identifiers fail closed instead of being treated as adapter\n * omissions. An invalid manifest never produces a compatible result.\n */\nexport function negotiateAdapterCapabilities(\n marquette: ApplicationMarquette,\n requiredCapabilities: readonly string[],\n manifest: AdapterCapabilityManifest,\n): AdapterCapabilityNegotiation {\n const diagnostics = validateAdapterCapabilityManifest(manifest);\n const support = new Map(\n (manifest.capabilities ?? []).map((capability) => [capability.id, capability] as const),\n );\n const mismatches = [...new Set(requiredCapabilities)]\n .sort()\n .flatMap((id) => mismatch(marquette, id, support.get(id), diagnostics.length === 0));\n\n return {\n adapter: manifest.adapter,\n compatible: diagnostics.length === 0 && mismatches.length === 0,\n diagnostics,\n mismatches,\n };\n}\n\nfunction mismatch(\n marquette: ApplicationMarquette,\n id: string,\n support: AdapterCapabilitySupport | undefined,\n manifestIsValid: boolean,\n): AdapterCapabilityMismatch[] {\n const declarations = marquette.capabilities;\n const requirement =\n declarations && Object.hasOwn(declarations, id) ? declarations[id] : undefined;\n if (requirement === undefined) return [problem(\"unknown-requirement\", id)];\n const requiredVersion = requirement.version === undefined ? 1 : requirement.version;\n if (!Number.isInteger(requiredVersion) || requiredVersion < 1 || requiredVersion > 0xffff_ffff) {\n return [problem(\"invalid-requirement-version\", id)];\n }\n if (!manifestIsValid) return [];\n\n if (support === undefined) return [problem(\"missing-capability\", id, requiredVersion)];\n if (requiredVersion < support.minVersion) {\n return [problem(\"version-below-minimum\", id, requiredVersion, support)];\n }\n if (requiredVersion > support.maxVersion) {\n return [problem(\"version-above-maximum\", id, requiredVersion, support)];\n }\n return [];\n}\n\nfunction problem(\n code: AdapterCapabilityMismatchCode,\n capability: string,\n requiredVersion?: number,\n support?: AdapterCapabilitySupport,\n): AdapterCapabilityMismatch {\n return {\n code,\n capability,\n path: `capabilities.${capability}`,\n message: mismatchMessage(code),\n ...(requiredVersion === undefined ? {} : { requiredVersion }),\n ...(support === undefined\n ? {}\n : { minVersion: support.minVersion, maxVersion: support.maxVersion }),\n };\n}\n\nfunction mismatchMessage(code: AdapterCapabilityMismatchCode): string {\n switch (code) {\n case \"unknown-requirement\":\n return \"application references an undeclared capability requirement\";\n case \"invalid-requirement-version\":\n return \"application capability version must be a positive unsigned 32-bit integer\";\n case \"missing-capability\":\n return \"adapter does not support the required capability\";\n case \"version-below-minimum\":\n return \"application requires a capability version below the adapter minimum\";\n case \"version-above-maximum\":\n return \"application requires a capability version above the adapter maximum\";\n }\n}\n"],"mappings":";;AACA,MAAa,oCAAoC;;;;ACEjD,MAAa,mCAAmC;;AAGhD,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAWA,SAAgB,gCAAqE;CACnF,OAAO,6BAA6B,KAAK,QAAQ;EAC/C;EACA,YAAA;EACA,YAAA;CACF,EAAE;AACJ;;;ACzBA,MAAM,aAAa;AACnB,MAAM,mBAAoE;CACxE,0BAA0B;CAC1B,sBAAsB;CACtB,yBAAyB;CACzB,mBAAmB;CACnB,yBAAyB;CACzB,wBAA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,KAAA;CACvE,IAAI,gBAAgB,KAAA,GAAW,OAAO,CAAC,QAAQ,uBAAuB,EAAE,CAAC;CACzE,MAAM,kBAAkB,YAAY,YAAY,KAAA,IAAY,IAAI,YAAY;CAC5E,IAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,KAAK,kBAAkB,YACjF,OAAO,CAAC,QAAQ,+BAA+B,EAAE,CAAC;CAEpD,IAAI,CAAC,iBAAiB,OAAO,CAAC;CAE9B,IAAI,YAAY,KAAA,GAAW,OAAO,CAAC,QAAQ,sBAAsB,IAAI,eAAe,CAAC;CACrF,IAAI,kBAAkB,QAAQ,YAC5B,OAAO,CAAC,QAAQ,yBAAyB,IAAI,iBAAiB,OAAO,CAAC;CAExE,IAAI,kBAAkB,QAAQ,YAC5B,OAAO,CAAC,QAAQ,yBAAyB,IAAI,iBAAiB,OAAO,CAAC;CAExE,OAAO,CAAC;AACV;AAEA,SAAS,QACP,MACA,YACA,iBACA,SAC2B;CAC3B,OAAO;EACL;EACA;EACA,MAAM,gBAAgB;EACtB,SAAS,gBAAgB,IAAI;EAC7B,GAAI,oBAAoB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB;EAC3D,GAAI,YAAY,KAAA,IACZ,CAAC,IACD;GAAE,YAAY,QAAQ;GAAY,YAAY,QAAQ;EAAW;CACvE;AACF;AAEA,SAAS,gBAAgB,MAA6C;CACpE,QAAQ,MAAR;EACE,KAAK,uBACH,OAAO;EACT,KAAK,+BACH,OAAO;EACT,KAAK,sBACH,OAAO;EACT,KAAK,yBACH,OAAO;EACT,KAAK,yBACH,OAAO;CACX;AACF"}
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"properties": {
|
|
33
33
|
"id": { "$ref": "#/$defs/identifier" },
|
|
34
34
|
"description": { "type": "string", "minLength": 1 },
|
|
35
|
-
"version": { "type": "integer", "minimum": 1, "default": 1 }
|
|
35
|
+
"version": { "type": "integer", "minimum": 1, "maximum": 4294967295, "default": 1 }
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"environment": {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as RouteId, a as CapabilityId, b as TargetId, c as MARQUETTE_FORMAT_VERSION, d as MarquetteProtocol, f as MarquetteRoute, g as RenderingMode, h as ProtocolId, i as CapabilityDefinition, l as MarquetteBackend, m as ProtocolFamily, n as BackendFamily, o as EnvironmentConsumer, p as MarquetteTarget, r as BackendId, s as EnvironmentId, t as ApplicationMarquette, u as MarquetteEnvironment, v as RuntimeFamily, y as ServerEnvironmentId } from "./model-
|
|
1
|
+
import { _ as RouteId, a as CapabilityId, b as TargetId, c as MARQUETTE_FORMAT_VERSION, d as MarquetteProtocol, f as MarquetteRoute, g as RenderingMode, h as ProtocolId, i as CapabilityDefinition, l as MarquetteBackend, m as ProtocolFamily, n as BackendFamily, o as EnvironmentConsumer, p as MarquetteTarget, r as BackendId, s as EnvironmentId, t as ApplicationMarquette, u as MarquetteEnvironment, v as RuntimeFamily, y as ServerEnvironmentId } from "./model-BcXukmxj.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/author.d.ts
|
|
4
4
|
/**
|