@cloudhal/core-contracts 0.8.0 → 0.9.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.
@@ -1,6 +1,6 @@
1
1
  import type { ErrorObject } from "ajv";
2
2
  import type { RootSchemaName } from "../scripts/schema-list.js";
3
- import type { AnalyticsBeacon, AnalyticsEvent, Asset, Automation, Comment, CommentSubmission, ContentEntry, Glossary, Menu, Page, Project, Redirect, Release, ScheduleRun, Section, Site, SkillManifest, Snapshot, Taxonomy, Term } from "./generated/index.js";
3
+ import type { AnalyticsBeacon, AnalyticsEvent, Asset, Automation, Comment, CommentSubmission, ContentEntry, Glossary, Menu, Page, Project, Redirect, Release, ReleaseManifest, ReleaseStatement, ScheduleRun, Section, Site, SkillManifest, Snapshot, Taxonomy, Term } from "./generated/index.js";
4
4
  /** Map from contract name to its TypeScript type. */
5
5
  export interface ContractTypes {
6
6
  project: Project;
@@ -23,6 +23,8 @@ export interface ContractTypes {
23
23
  automation: Automation;
24
24
  "schedule-run": ScheduleRun;
25
25
  glossary: Glossary;
26
+ "release-manifest": ReleaseManifest;
27
+ "release-statement": ReleaseStatement;
26
28
  }
27
29
  export declare class ContractValidationError extends Error {
28
30
  readonly name = "ContractValidationError";
@@ -14,6 +14,8 @@
14
14
 
15
15
 
16
16
 
17
+
18
+
17
19
 
18
20
 
19
21
 
@@ -46,6 +48,8 @@ import * as v from "./generated/validators.js";
46
48
 
47
49
 
48
50
 
51
+
52
+
49
53
 
50
54
 
51
55
  const validators = {
@@ -69,6 +73,8 @@ const validators
69
73
  automation: v.validateAutomation,
70
74
  "schedule-run": v.validateScheduleRun,
71
75
  glossary: v.validateGlossary,
76
+ "release-manifest": v.validateReleaseManifest,
77
+ "release-statement": v.validateReleaseStatement,
72
78
  };
73
79
 
74
80
  export class ContractValidationError extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudhal/core-contracts",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Cloudhal domain contracts: JSON Schema source of truth plus generated TypeScript types",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://cloudhal.dev",
@@ -0,0 +1,571 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://cloudhal.dev/schemas/v1/release-manifest.schema.json",
4
+ "title": "ReleaseManifest",
5
+ "description": "cloudhal.release-manifest@1 (RFC-0046): the manifest of one Cloudhal release bundle, published as the release asset manifest.json next to the gzip tarball cloudhal-release-<version>.tar.gz. A project release is signed through release-statement.json, which pins this file's SHA-256 and size (signing.signature = release-statement.sig); the legacy form manifest.sig, a raw 64-byte Ed25519 signature over these exact bytes, is for development keys only. It describes every built Worker module and static asset by size and SHA-256, the binding templates, feature levels, migration range and rollback facts a remote deployer needs to install, update or refuse a version without running a build. Portable on purpose: it references common only for SchemaVersion and Timestamp; every other definition is local.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schemaVersion",
10
+ "format",
11
+ "version",
12
+ "channel",
13
+ "securityRelease",
14
+ "commit",
15
+ "createdAt",
16
+ "contracts",
17
+ "levels",
18
+ "migrations",
19
+ "durableObjects",
20
+ "runtime",
21
+ "toolchain",
22
+ "theme",
23
+ "skills",
24
+ "workers",
25
+ "bindingTemplates",
26
+ "requiredScopes",
27
+ "optionalScopes",
28
+ "requiredCapabilities",
29
+ "optionalCapabilities",
30
+ "starter",
31
+ "features",
32
+ "planVersion",
33
+ "signing"
34
+ ],
35
+ "properties": {
36
+ "schemaVersion": {
37
+ "$ref": "common.schema.json#/$defs/SchemaVersion"
38
+ },
39
+ "format": {
40
+ "type": "string",
41
+ "enum": ["cloudhal.release-manifest@1"]
42
+ },
43
+ "version": {
44
+ "$ref": "#/$defs/CloudhalVersion"
45
+ },
46
+ "channel": {
47
+ "type": "string",
48
+ "enum": ["stable", "next"]
49
+ },
50
+ "securityRelease": {
51
+ "type": "boolean"
52
+ },
53
+ "commit": {
54
+ "type": "string",
55
+ "pattern": "^[0-9a-f]{40}$"
56
+ },
57
+ "createdAt": {
58
+ "$ref": "common.schema.json#/$defs/Timestamp"
59
+ },
60
+ "contracts": {
61
+ "type": "object",
62
+ "additionalProperties": false,
63
+ "required": ["schemaVersion"],
64
+ "properties": {
65
+ "schemaVersion": {
66
+ "type": "integer",
67
+ "enum": [1]
68
+ }
69
+ }
70
+ },
71
+ "levels": {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": ["schedules", "gates"],
75
+ "properties": {
76
+ "schedules": {
77
+ "type": "integer",
78
+ "minimum": 0
79
+ },
80
+ "gates": {
81
+ "type": "integer",
82
+ "minimum": 0
83
+ }
84
+ }
85
+ },
86
+ "migrations": {
87
+ "type": "object",
88
+ "additionalProperties": false,
89
+ "required": ["first", "last", "count", "names", "compatibleWithPrevious"],
90
+ "properties": {
91
+ "first": {
92
+ "$ref": "#/$defs/MigrationName"
93
+ },
94
+ "last": {
95
+ "$ref": "#/$defs/MigrationName"
96
+ },
97
+ "count": {
98
+ "type": "integer",
99
+ "minimum": 1
100
+ },
101
+ "names": {
102
+ "type": "array",
103
+ "minItems": 1,
104
+ "uniqueItems": true,
105
+ "items": {
106
+ "$ref": "#/$defs/MigrationName"
107
+ }
108
+ },
109
+ "compatibleWithPrevious": {
110
+ "type": "boolean"
111
+ }
112
+ }
113
+ },
114
+ "durableObjects": {
115
+ "type": "object",
116
+ "additionalProperties": false,
117
+ "required": ["bindings", "lifecycleChange"],
118
+ "properties": {
119
+ "bindings": {
120
+ "type": "array",
121
+ "items": {
122
+ "type": "object",
123
+ "additionalProperties": false,
124
+ "required": ["name", "className", "migration"],
125
+ "properties": {
126
+ "name": {
127
+ "$ref": "#/$defs/BindingName"
128
+ },
129
+ "className": {
130
+ "type": "string",
131
+ "pattern": "^[A-Z][A-Za-z0-9]*$"
132
+ },
133
+ "migration": {
134
+ "type": "string",
135
+ "pattern": "^v[1-9][0-9]*$"
136
+ }
137
+ }
138
+ }
139
+ },
140
+ "lifecycleChange": {
141
+ "type": "boolean"
142
+ }
143
+ }
144
+ },
145
+ "runtime": {
146
+ "type": "object",
147
+ "additionalProperties": false,
148
+ "required": ["compatibilityDate", "compatibilityFlags"],
149
+ "properties": {
150
+ "compatibilityDate": {
151
+ "type": "string",
152
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
153
+ },
154
+ "compatibilityFlags": {
155
+ "type": "array",
156
+ "uniqueItems": true,
157
+ "items": {
158
+ "type": "string",
159
+ "pattern": "^[a-z0-9_]+$"
160
+ }
161
+ }
162
+ }
163
+ },
164
+ "toolchain": {
165
+ "type": "object",
166
+ "additionalProperties": {
167
+ "type": "string",
168
+ "maxLength": 64
169
+ }
170
+ },
171
+ "theme": {
172
+ "type": "object",
173
+ "additionalProperties": false,
174
+ "required": ["name", "version", "blockTypes", "settingsSha256", "designSha256"],
175
+ "properties": {
176
+ "name": {
177
+ "type": "string",
178
+ "pattern": "^[a-z][a-z0-9-]{0,63}$"
179
+ },
180
+ "version": {
181
+ "type": "string",
182
+ "maxLength": 64
183
+ },
184
+ "blockTypes": {
185
+ "type": "array",
186
+ "uniqueItems": true,
187
+ "items": {
188
+ "type": "string"
189
+ }
190
+ },
191
+ "settingsSha256": {
192
+ "$ref": "#/$defs/Sha256Hex"
193
+ },
194
+ "designSha256": {
195
+ "$ref": "#/$defs/Sha256Hex"
196
+ }
197
+ }
198
+ },
199
+ "skills": {
200
+ "type": "array",
201
+ "items": {
202
+ "type": "object",
203
+ "additionalProperties": false,
204
+ "required": ["name", "sha256"],
205
+ "properties": {
206
+ "name": {
207
+ "type": "string",
208
+ "pattern": "^[a-z][a-z0-9-]{0,63}$"
209
+ },
210
+ "sha256": {
211
+ "$ref": "#/$defs/Sha256Hex"
212
+ }
213
+ }
214
+ }
215
+ },
216
+ "workers": {
217
+ "type": "object",
218
+ "additionalProperties": false,
219
+ "required": ["site", "admin"],
220
+ "properties": {
221
+ "site": {
222
+ "$ref": "#/$defs/WorkerArtifact"
223
+ },
224
+ "admin": {
225
+ "$ref": "#/$defs/WorkerArtifact"
226
+ }
227
+ }
228
+ },
229
+ "bindingTemplates": {
230
+ "type": "object",
231
+ "additionalProperties": false,
232
+ "required": ["site", "admin"],
233
+ "properties": {
234
+ "site": {
235
+ "$ref": "#/$defs/BindingTemplate"
236
+ },
237
+ "admin": {
238
+ "$ref": "#/$defs/BindingTemplate"
239
+ }
240
+ }
241
+ },
242
+ "requiredScopes": {
243
+ "type": "array",
244
+ "uniqueItems": true,
245
+ "items": {
246
+ "$ref": "#/$defs/ScopeId"
247
+ }
248
+ },
249
+ "optionalScopes": {
250
+ "type": "array",
251
+ "uniqueItems": true,
252
+ "items": {
253
+ "$ref": "#/$defs/ScopeId"
254
+ }
255
+ },
256
+ "requiredCapabilities": {
257
+ "type": "array",
258
+ "uniqueItems": true,
259
+ "items": {
260
+ "$ref": "#/$defs/Capability"
261
+ }
262
+ },
263
+ "optionalCapabilities": {
264
+ "type": "array",
265
+ "uniqueItems": true,
266
+ "items": {
267
+ "$ref": "#/$defs/Capability"
268
+ }
269
+ },
270
+ "starter": {
271
+ "oneOf": [
272
+ {
273
+ "type": "object",
274
+ "additionalProperties": false,
275
+ "required": ["kind"],
276
+ "properties": {
277
+ "kind": {
278
+ "type": "string",
279
+ "enum": ["admin-api"]
280
+ }
281
+ }
282
+ },
283
+ {
284
+ "type": "object",
285
+ "additionalProperties": false,
286
+ "required": ["kind", "path", "bytes", "sha256", "siteId"],
287
+ "properties": {
288
+ "kind": {
289
+ "type": "string",
290
+ "enum": ["bundle"]
291
+ },
292
+ "path": {
293
+ "type": "string",
294
+ "pattern": "^starter/[A-Za-z0-9._-]+$"
295
+ },
296
+ "bytes": {
297
+ "type": "integer",
298
+ "minimum": 1
299
+ },
300
+ "sha256": {
301
+ "$ref": "#/$defs/Sha256Hex"
302
+ },
303
+ "siteId": {
304
+ "$ref": "#/$defs/SiteId"
305
+ }
306
+ }
307
+ }
308
+ ]
309
+ },
310
+ "features": {
311
+ "type": "object",
312
+ "additionalProperties": {
313
+ "type": "boolean"
314
+ },
315
+ "required": ["adminSitesAcceptsSiteId", "healthReportsVersion", "mediaTransformVar"],
316
+ "properties": {
317
+ "adminSitesAcceptsSiteId": {
318
+ "type": "boolean"
319
+ },
320
+ "healthReportsVersion": {
321
+ "type": "boolean"
322
+ },
323
+ "mediaTransformVar": {
324
+ "type": "boolean"
325
+ }
326
+ }
327
+ },
328
+ "planVersion": {
329
+ "type": "integer",
330
+ "minimum": 1
331
+ },
332
+ "signing": {
333
+ "type": "object",
334
+ "additionalProperties": false,
335
+ "required": ["keyId", "algorithm", "signature"],
336
+ "properties": {
337
+ "keyId": {
338
+ "type": "string",
339
+ "pattern": "^[a-z0-9][a-z0-9-]{2,63}$"
340
+ },
341
+ "algorithm": {
342
+ "type": "string",
343
+ "enum": ["Ed25519"]
344
+ },
345
+ "signature": {
346
+ "type": "string",
347
+ "enum": ["manifest.sig", "release-statement.sig"]
348
+ }
349
+ }
350
+ }
351
+ },
352
+ "$defs": {
353
+ "MigrationName": {
354
+ "type": "string",
355
+ "pattern": "^[0-9]{4}_[a-z0-9_]+$"
356
+ },
357
+ "BindingName": {
358
+ "type": "string",
359
+ "pattern": "^[A-Z][A-Z0-9_]*(_\\*)?$"
360
+ },
361
+ "ScopeId": {
362
+ "type": "string",
363
+ "pattern": "^[a-z0-9-]+(\\.[a-z0-9-]+)+$"
364
+ },
365
+ "Capability": {
366
+ "type": "string",
367
+ "enum": ["account", "workers", "d1", "r2", "analytics", "domains"]
368
+ },
369
+ "CloudhalVersion": {
370
+ "type": "string",
371
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"
372
+ },
373
+ "Sha256Hex": {
374
+ "type": "string",
375
+ "pattern": "^[0-9a-f]{64}$"
376
+ },
377
+ "SiteId": {
378
+ "type": "string",
379
+ "pattern": "^site_[A-Za-z0-9]{6,32}$"
380
+ },
381
+ "SecretName": {
382
+ "type": "string",
383
+ "enum": [
384
+ "BETTER_AUTH_SECRET",
385
+ "MCP_STATE_KEY",
386
+ "CLOUDHAL_PREVIEW_SECRET",
387
+ "CLOUDHAL_PURGE_TOKEN",
388
+ "CLOUDHAL_DEPLOY_TOKEN",
389
+ "CLOUDHAL_SETUP_TOKEN",
390
+ "CLOUDHAL_COMMENTS_KEY"
391
+ ]
392
+ },
393
+ "WorkerArtifact": {
394
+ "type": "object",
395
+ "additionalProperties": false,
396
+ "required": ["mainModule", "modules", "assets"],
397
+ "properties": {
398
+ "mainModule": {
399
+ "type": "string",
400
+ "pattern": "^[A-Za-z0-9._/-]+$"
401
+ },
402
+ "modules": {
403
+ "type": "array",
404
+ "minItems": 1,
405
+ "items": {
406
+ "type": "object",
407
+ "additionalProperties": false,
408
+ "required": ["path", "type", "bytes", "sha256"],
409
+ "properties": {
410
+ "path": {
411
+ "type": "string",
412
+ "pattern": "^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$"
413
+ },
414
+ "type": {
415
+ "type": "string",
416
+ "enum": ["esm", "cjs", "wasm", "text", "data"]
417
+ },
418
+ "bytes": {
419
+ "type": "integer",
420
+ "minimum": 1
421
+ },
422
+ "sha256": {
423
+ "$ref": "#/$defs/Sha256Hex"
424
+ }
425
+ }
426
+ }
427
+ },
428
+ "assets": {
429
+ "type": "object",
430
+ "additionalProperties": false,
431
+ "required": ["count", "bytes", "files", "headers"],
432
+ "properties": {
433
+ "count": {
434
+ "type": "integer",
435
+ "minimum": 0,
436
+ "maximum": 20000
437
+ },
438
+ "bytes": {
439
+ "type": "integer",
440
+ "minimum": 0
441
+ },
442
+ "files": {
443
+ "type": "array",
444
+ "maxItems": 20000,
445
+ "items": {
446
+ "type": "object",
447
+ "additionalProperties": false,
448
+ "required": ["path", "bytes", "sha256", "assetHash", "contentType"],
449
+ "properties": {
450
+ "path": {
451
+ "type": "string",
452
+ "pattern": "^/[^\\s]*$",
453
+ "maxLength": 1024
454
+ },
455
+ "bytes": {
456
+ "type": "integer",
457
+ "minimum": 0,
458
+ "maximum": 26214400
459
+ },
460
+ "sha256": {
461
+ "$ref": "#/$defs/Sha256Hex"
462
+ },
463
+ "assetHash": {
464
+ "type": "string",
465
+ "pattern": "^[0-9a-f]{32}$"
466
+ },
467
+ "contentType": {
468
+ "type": "string",
469
+ "maxLength": 128
470
+ }
471
+ }
472
+ }
473
+ },
474
+ "headers": {
475
+ "type": "string",
476
+ "maxLength": 100000
477
+ },
478
+ "config": {
479
+ "type": "object",
480
+ "additionalProperties": false,
481
+ "properties": {
482
+ "not_found_handling": {
483
+ "type": "string",
484
+ "enum": ["none", "404-page", "single-page-application"]
485
+ },
486
+ "run_worker_first": {
487
+ "type": "array",
488
+ "items": {
489
+ "type": "string",
490
+ "pattern": "^/"
491
+ }
492
+ }
493
+ }
494
+ }
495
+ }
496
+ },
497
+ "bindingTemplate": {
498
+ "type": "string",
499
+ "enum": ["site", "admin"]
500
+ }
501
+ }
502
+ },
503
+ "BindingTemplate": {
504
+ "type": "object",
505
+ "additionalProperties": false,
506
+ "required": ["bindings", "vars", "secrets"],
507
+ "properties": {
508
+ "bindings": {
509
+ "type": "array",
510
+ "items": {
511
+ "type": "object",
512
+ "additionalProperties": false,
513
+ "required": ["name", "type", "required"],
514
+ "properties": {
515
+ "name": {
516
+ "$ref": "#/$defs/BindingName"
517
+ },
518
+ "type": {
519
+ "type": "string",
520
+ "enum": [
521
+ "d1",
522
+ "r2_bucket",
523
+ "assets",
524
+ "service",
525
+ "durable_object_namespace",
526
+ "analytics_engine",
527
+ "analytics_sql",
528
+ "ratelimit",
529
+ "ai_search",
530
+ "send_email",
531
+ "ai",
532
+ "browser"
533
+ ]
534
+ },
535
+ "required": {
536
+ "type": "boolean"
537
+ },
538
+ "aliases": {
539
+ "type": "array",
540
+ "items": {
541
+ "$ref": "#/$defs/BindingName"
542
+ }
543
+ }
544
+ }
545
+ }
546
+ },
547
+ "vars": {
548
+ "type": "array",
549
+ "uniqueItems": true,
550
+ "items": {
551
+ "$ref": "#/$defs/BindingName"
552
+ }
553
+ },
554
+ "secrets": {
555
+ "type": "array",
556
+ "uniqueItems": true,
557
+ "items": {
558
+ "$ref": "#/$defs/SecretName"
559
+ }
560
+ },
561
+ "cache": {
562
+ "type": "boolean"
563
+ },
564
+ "cron": {
565
+ "type": "string",
566
+ "pattern": "^[0-9*/,\\- ]+$"
567
+ }
568
+ }
569
+ }
570
+ }
571
+ }