@void/deploy-core 1.10.0 → 1.12.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/dist/index.d.mts +13 -4
- package/dist/index.mjs +27 -17
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,7 @@ export declare function validateManifestShape(manifest: unknown): string | null;
|
|
|
15
15
|
type DeployResource = {
|
|
16
16
|
type: "d1";
|
|
17
17
|
bindingName: string;
|
|
18
|
+
readReplication?: boolean;
|
|
18
19
|
} | {
|
|
19
20
|
type: "kv";
|
|
20
21
|
bindingName: string;
|
|
@@ -287,8 +288,11 @@ export declare function isSingleStatement(sql: string): boolean;
|
|
|
287
288
|
export declare function splitSqlStatements(sql: string): Array<string> | null;
|
|
288
289
|
/** Classify SQL without imposing the caller's execution policy or hashing implementation. */
|
|
289
290
|
export declare function classifySqlMigration(sql: string): SqlMigrationClassification;
|
|
291
|
+
type MigrationPlanHashPreimage = Pick<MigrationPlanHashInput, "classifierVersion" | "dialect" | "kind" | "name" | "sqlHash" | "stability"> & {
|
|
292
|
+
statements?: Array<string>;
|
|
293
|
+
};
|
|
290
294
|
/** Preserve the classifier-v1 hash preimage; policy markers and warnings are not hashed. */
|
|
291
|
-
export declare function getMigrationPlanHashInput(plan: MigrationPlanHashInput):
|
|
295
|
+
export declare function getMigrationPlanHashInput(plan: MigrationPlanHashInput): MigrationPlanHashPreimage;
|
|
292
296
|
export declare const SUPPORTED_MANIFEST_VERSIONS: ReadonlyArray<number>;
|
|
293
297
|
export type MigrationMeta = {
|
|
294
298
|
name: string;
|
|
@@ -374,13 +378,14 @@ export declare function planWebSocketMigrations(input: {
|
|
|
374
378
|
currentVersion: number;
|
|
375
379
|
tagPrefix?: string;
|
|
376
380
|
}): PlannedWebSocketMigrations;
|
|
377
|
-
|
|
378
|
-
export declare function appendSqliteClassMigration(migrations: ReadonlyArray<DurableObjectMigrationStep>, classes: ReadonlyArray<string>, baseTag: string, knownExistingClasses?: ReadonlyArray<string>): {
|
|
381
|
+
type SqliteClassMigrationResult = {
|
|
379
382
|
migrations: ReadonlyArray<DurableObjectMigrationStep>;
|
|
380
383
|
added: boolean;
|
|
381
384
|
};
|
|
385
|
+
/** Append one SQLite class step without reclassifying an existing namespace. */
|
|
386
|
+
export declare function appendSqliteClassMigration(migrations: ReadonlyArray<DurableObjectMigrationStep>, classes: ReadonlyArray<string>, baseTag: string, knownExistingClasses?: ReadonlyArray<string>): SqliteClassMigrationResult;
|
|
382
387
|
export type WebSocketManifestMeta = {
|
|
383
|
-
routes: ReadonlyArray<WebSocketRouteMeta
|
|
388
|
+
routes: ReadonlyArray<Pick<WebSocketRouteMeta, "className" | "bindingName"> & Partial<Omit<WebSocketRouteMeta, "className" | "bindingName">>>;
|
|
384
389
|
classes: ReadonlyArray<string>;
|
|
385
390
|
migrations?: ReadonlyArray<WebSocketMigrationMeta>;
|
|
386
391
|
};
|
|
@@ -431,6 +436,10 @@ export type DurableObjectManifestMeta = {
|
|
|
431
436
|
};
|
|
432
437
|
export type DeployManifest = {
|
|
433
438
|
version: number;
|
|
439
|
+
/** D1 provisioning preferences. Omitted preserves existing replication; false disables it. */
|
|
440
|
+
database?: {
|
|
441
|
+
readReplication?: boolean;
|
|
442
|
+
};
|
|
434
443
|
/** R2 creation preferences. Requires manifest version 5. */
|
|
435
444
|
storage?: StorageConfig;
|
|
436
445
|
assetManifestVersion?: 1 | 2;
|
package/dist/index.mjs
CHANGED
|
@@ -87,6 +87,10 @@ function validateManifestShape(manifest) {
|
|
|
87
87
|
if (manifest.migrationMode !== void 0 && manifest.migrationMode !== "apply" && manifest.migrationMode !== "skip") return "invalid manifest shape: migrationMode must be apply or skip";
|
|
88
88
|
if (!isRecord(manifest.bindings)) return "invalid manifest shape: bindings must be an object";
|
|
89
89
|
const bindings = manifest.bindings;
|
|
90
|
+
if (manifest.database !== void 0) {
|
|
91
|
+
if (!isRecord(manifest.database) || Object.keys(manifest.database).some((key) => key !== "readReplication") || manifest.database.readReplication !== void 0 && typeof manifest.database.readReplication !== "boolean") return "invalid manifest shape: database.readReplication must be a boolean";
|
|
92
|
+
if (!Array.isArray(bindings.d1) || bindings.d1.length === 0) return "invalid manifest shape: database requires a D1 binding";
|
|
93
|
+
}
|
|
90
94
|
for (const key of [
|
|
91
95
|
"d1",
|
|
92
96
|
"kv",
|
|
@@ -97,11 +101,13 @@ function validateManifestShape(manifest) {
|
|
|
97
101
|
if (bindingValue === void 0) continue;
|
|
98
102
|
if (!Array.isArray(bindingValue) || !bindingValue.every((value) => typeof value === "string")) return `invalid manifest shape: bindings.${key} must be an array of strings`;
|
|
99
103
|
}
|
|
104
|
+
const queueBindingNames = [];
|
|
100
105
|
if (manifest.queues !== void 0) {
|
|
101
106
|
if (!Array.isArray(manifest.queues)) return "invalid manifest shape: queues must be an array";
|
|
102
107
|
for (const queue of manifest.queues) {
|
|
103
108
|
if (!isRecord(queue)) return "invalid manifest shape: queues entries must be objects";
|
|
104
109
|
if (typeof queue.name !== "string" || typeof queue.bindingName !== "string") return "invalid manifest shape: queues entries must have string name and bindingName";
|
|
110
|
+
queueBindingNames.push(queue.bindingName);
|
|
105
111
|
if (queue.maxConcurrency !== void 0 && (typeof queue.maxConcurrency !== "number" || !Number.isInteger(queue.maxConcurrency) || queue.maxConcurrency < 1 || queue.maxConcurrency > 250)) return "invalid manifest shape: queues entry maxConcurrency must be an integer between 1 and 250";
|
|
106
112
|
for (const tuning of [
|
|
107
113
|
"maxBatchSize",
|
|
@@ -185,17 +191,17 @@ function validateManifestShape(manifest) {
|
|
|
185
191
|
if (manifest.assetConfig !== void 0) {
|
|
186
192
|
if (!isRecord(manifest.assetConfig)) return "invalid manifest shape: assetConfig must be an object";
|
|
187
193
|
const assetConfig = manifest.assetConfig;
|
|
188
|
-
if (assetConfig.not_found_handling !== void 0 && ![
|
|
194
|
+
if (assetConfig.not_found_handling !== void 0 && (typeof assetConfig.not_found_handling !== "string" || ![
|
|
189
195
|
"none",
|
|
190
196
|
"single-page-application",
|
|
191
197
|
"404-page"
|
|
192
|
-
].includes(assetConfig.not_found_handling)) return "invalid manifest shape: assetConfig.not_found_handling must be one of none, single-page-application, 404-page";
|
|
193
|
-
if (assetConfig.html_handling !== void 0 && ![
|
|
198
|
+
].includes(assetConfig.not_found_handling))) return "invalid manifest shape: assetConfig.not_found_handling must be one of none, single-page-application, 404-page";
|
|
199
|
+
if (assetConfig.html_handling !== void 0 && (typeof assetConfig.html_handling !== "string" || ![
|
|
194
200
|
"auto-trailing-slash",
|
|
195
201
|
"force-trailing-slash",
|
|
196
202
|
"drop-trailing-slash",
|
|
197
203
|
"none"
|
|
198
|
-
].includes(assetConfig.html_handling)) return "invalid manifest shape: assetConfig.html_handling must be one of auto-trailing-slash, force-trailing-slash, drop-trailing-slash, none";
|
|
204
|
+
].includes(assetConfig.html_handling))) return "invalid manifest shape: assetConfig.html_handling must be one of auto-trailing-slash, force-trailing-slash, drop-trailing-slash, none";
|
|
199
205
|
}
|
|
200
206
|
if (manifest.revalidate !== void 0 && typeof manifest.revalidate !== "number") {
|
|
201
207
|
if (!isRecord(manifest.revalidate)) return "invalid manifest shape: revalidate must be a number or object";
|
|
@@ -238,6 +244,7 @@ function validateManifestShape(manifest) {
|
|
|
238
244
|
}
|
|
239
245
|
const fallbackRulesError = validateRoutingRules(manifest.fallbackRules, "fallbackRules");
|
|
240
246
|
if (fallbackRulesError) return fallbackRulesError;
|
|
247
|
+
const webSocketBindingNames = [];
|
|
241
248
|
if (manifest.websocket !== void 0) {
|
|
242
249
|
if (!isRecord(manifest.websocket)) return "invalid manifest shape: websocket must be an object";
|
|
243
250
|
const websocket = manifest.websocket;
|
|
@@ -246,6 +253,7 @@ function validateManifestShape(manifest) {
|
|
|
246
253
|
if (!isRecord(route)) return "invalid manifest shape: websocket.routes entries must be objects";
|
|
247
254
|
if (typeof route.className !== "string") return "invalid manifest shape: websocket.routes entries must have a string className";
|
|
248
255
|
if (route.bindingName !== void 0 && typeof route.bindingName !== "string") return "invalid manifest shape: websocket.routes entry bindingName must be a string";
|
|
256
|
+
webSocketBindingNames.push(route.bindingName ?? route.className);
|
|
249
257
|
}
|
|
250
258
|
if (!Array.isArray(websocket.classes) || !websocket.classes.every((x) => typeof x === "string")) return "invalid manifest shape: websocket.classes must be an array of strings";
|
|
251
259
|
const migrationsError = validateClassMigrations("websocket.migrations", websocket.migrations, [
|
|
@@ -262,10 +270,11 @@ function validateManifestShape(manifest) {
|
|
|
262
270
|
for (const key of [
|
|
263
271
|
"bindingName",
|
|
264
272
|
"className",
|
|
265
|
-
"containerName"
|
|
266
|
-
"image"
|
|
273
|
+
"containerName"
|
|
267
274
|
]) if (typeof sandbox[key] !== "string" || sandbox[key].length === 0) return `invalid manifest shape: sandbox.${key} must be a non-empty string`;
|
|
268
|
-
|
|
275
|
+
const image = sandbox.image;
|
|
276
|
+
if (typeof image !== "string" || image.length === 0) return "invalid manifest shape: sandbox.image must be a non-empty string";
|
|
277
|
+
if (isLocalImageReference(image)) return "invalid manifest shape: sandbox.image must be a registry image reference";
|
|
269
278
|
if (sandbox.instanceType !== void 0 && typeof sandbox.instanceType !== "string") return "invalid manifest shape: sandbox.instanceType must be a string";
|
|
270
279
|
if (sandbox.maxInstances !== void 0 && (typeof sandbox.maxInstances !== "number" || !Number.isInteger(sandbox.maxInstances) || sandbox.maxInstances < 1)) return "invalid manifest shape: sandbox.maxInstances must be a positive integer";
|
|
271
280
|
const migrationsError = validateClassMigrations("sandbox.migrations", sandbox.migrations, ["newSqliteClasses", "deletedClasses"]);
|
|
@@ -287,10 +296,10 @@ function validateManifestShape(manifest) {
|
|
|
287
296
|
const names = /* @__PURE__ */ new Set();
|
|
288
297
|
const classes = /* @__PURE__ */ new Set();
|
|
289
298
|
const otherBindings = /* @__PURE__ */ new Set([
|
|
290
|
-
...Object.values(bindings).filter(Array.isArray).flat(),
|
|
299
|
+
...Object.values(bindings).filter((value) => Array.isArray(value)).flat(),
|
|
291
300
|
...Object.keys(isRecord(manifest.vars) ? manifest.vars : {}),
|
|
292
|
-
...
|
|
293
|
-
...
|
|
301
|
+
...queueBindingNames,
|
|
302
|
+
...webSocketBindingNames,
|
|
294
303
|
...isRecord(manifest.live) ? [manifest.live.bindingName] : []
|
|
295
304
|
]);
|
|
296
305
|
for (const binding of durable.bindings) {
|
|
@@ -324,7 +333,8 @@ function createDeployResourcePlan(manifest) {
|
|
|
324
333
|
const resources = [];
|
|
325
334
|
for (const bindingName of manifest.bindings.d1 ?? []) resources.push({
|
|
326
335
|
type: "d1",
|
|
327
|
-
bindingName
|
|
336
|
+
bindingName,
|
|
337
|
+
...manifest.database?.readReplication !== void 0 && { readReplication: manifest.database.readReplication }
|
|
328
338
|
});
|
|
329
339
|
for (const bindingName of manifest.bindings.kv ?? []) resources.push({
|
|
330
340
|
type: "kv",
|
|
@@ -423,10 +433,7 @@ function canonicalJson(value) {
|
|
|
423
433
|
if (value === null) return "null";
|
|
424
434
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return JSON.stringify(value);
|
|
425
435
|
if (Array.isArray(value)) return `[${value.map((entry) => canonicalJson(entry)).join(",")}]`;
|
|
426
|
-
if (
|
|
427
|
-
const object = value;
|
|
428
|
-
return `{${Object.keys(object).sort().filter((key) => object[key] !== void 0).map((key) => `${JSON.stringify(key)}:${canonicalJson(object[key])}`).join(",")}}`;
|
|
429
|
-
}
|
|
436
|
+
if (isRecord(value)) return `{${Object.keys(value).sort().filter((key) => value[key] !== void 0).map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
|
|
430
437
|
throw new TypeError(`Unsupported canonical JSON value: ${typeof value}`);
|
|
431
438
|
}
|
|
432
439
|
// src/artifact-digest.ts
|
|
@@ -544,7 +551,7 @@ function* tokenizeSql(sql) {
|
|
|
544
551
|
const MIGRATION_CLASSIFIER_VERSION = 1;
|
|
545
552
|
const UNSPLIT_MULTI_STATEMENT_PRAGMA = "-- void:allow-unsplit-multi-statement";
|
|
546
553
|
function canonicalSql(sql) {
|
|
547
|
-
return (sql.charCodeAt(0) === 65279 ? sql.slice(1) : sql).
|
|
554
|
+
return (sql.charCodeAt(0) === 65279 ? sql.slice(1) : sql).replaceAll(/\r\n?/g, "\n");
|
|
548
555
|
}
|
|
549
556
|
function hasStandalonePragma(sql, pragma) {
|
|
550
557
|
return canonicalSql(sql).split("\n").some((line) => line.trim() === pragma);
|
|
@@ -713,7 +720,10 @@ function appendSqliteClassMigration(migrations, classes, baseTag, knownExistingC
|
|
|
713
720
|
migrations,
|
|
714
721
|
added: false
|
|
715
722
|
};
|
|
716
|
-
const tags = new Set(migrations.
|
|
723
|
+
const tags = new Set(migrations.flatMap((migration) => {
|
|
724
|
+
const value = migration.tag;
|
|
725
|
+
return value ? [value] : [];
|
|
726
|
+
}));
|
|
717
727
|
let tag = baseTag;
|
|
718
728
|
for (let suffix = 2; tags.has(tag); suffix++) tag = `${baseTag}-${suffix}`;
|
|
719
729
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/deploy-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Shared deployment contracts, manifests, and resource plans for Void.",
|
|
5
5
|
"homepage": "https://void.cloud",
|
|
6
6
|
"bugs": {
|
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
+
"tsrs": "7.1.0-beta.tsrs4",
|
|
29
30
|
"typescript": "7.0.2",
|
|
30
|
-
"vite-plus": "1.
|
|
31
|
+
"vite-plus": "1.8.0"
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
33
34
|
"build": "vp pack",
|
|
34
35
|
"dev": "vp pack --watch",
|
|
35
|
-
"typecheck": "
|
|
36
|
+
"typecheck": "tsrs --noEmit"
|
|
36
37
|
}
|
|
37
38
|
}
|