@void/deploy-core 1.11.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 +8 -4
- package/dist/index.mjs +21 -16
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -288,8 +288,11 @@ export declare function isSingleStatement(sql: string): boolean;
|
|
|
288
288
|
export declare function splitSqlStatements(sql: string): Array<string> | null;
|
|
289
289
|
/** Classify SQL without imposing the caller's execution policy or hashing implementation. */
|
|
290
290
|
export declare function classifySqlMigration(sql: string): SqlMigrationClassification;
|
|
291
|
+
type MigrationPlanHashPreimage = Pick<MigrationPlanHashInput, "classifierVersion" | "dialect" | "kind" | "name" | "sqlHash" | "stability"> & {
|
|
292
|
+
statements?: Array<string>;
|
|
293
|
+
};
|
|
291
294
|
/** Preserve the classifier-v1 hash preimage; policy markers and warnings are not hashed. */
|
|
292
|
-
export declare function getMigrationPlanHashInput(plan: MigrationPlanHashInput):
|
|
295
|
+
export declare function getMigrationPlanHashInput(plan: MigrationPlanHashInput): MigrationPlanHashPreimage;
|
|
293
296
|
export declare const SUPPORTED_MANIFEST_VERSIONS: ReadonlyArray<number>;
|
|
294
297
|
export type MigrationMeta = {
|
|
295
298
|
name: string;
|
|
@@ -375,13 +378,14 @@ export declare function planWebSocketMigrations(input: {
|
|
|
375
378
|
currentVersion: number;
|
|
376
379
|
tagPrefix?: string;
|
|
377
380
|
}): PlannedWebSocketMigrations;
|
|
378
|
-
|
|
379
|
-
export declare function appendSqliteClassMigration(migrations: ReadonlyArray<DurableObjectMigrationStep>, classes: ReadonlyArray<string>, baseTag: string, knownExistingClasses?: ReadonlyArray<string>): {
|
|
381
|
+
type SqliteClassMigrationResult = {
|
|
380
382
|
migrations: ReadonlyArray<DurableObjectMigrationStep>;
|
|
381
383
|
added: boolean;
|
|
382
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;
|
|
383
387
|
export type WebSocketManifestMeta = {
|
|
384
|
-
routes: ReadonlyArray<WebSocketRouteMeta
|
|
388
|
+
routes: ReadonlyArray<Pick<WebSocketRouteMeta, "className" | "bindingName"> & Partial<Omit<WebSocketRouteMeta, "className" | "bindingName">>>;
|
|
385
389
|
classes: ReadonlyArray<string>;
|
|
386
390
|
migrations?: ReadonlyArray<WebSocketMigrationMeta>;
|
|
387
391
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -101,11 +101,13 @@ function validateManifestShape(manifest) {
|
|
|
101
101
|
if (bindingValue === void 0) continue;
|
|
102
102
|
if (!Array.isArray(bindingValue) || !bindingValue.every((value) => typeof value === "string")) return `invalid manifest shape: bindings.${key} must be an array of strings`;
|
|
103
103
|
}
|
|
104
|
+
const queueBindingNames = [];
|
|
104
105
|
if (manifest.queues !== void 0) {
|
|
105
106
|
if (!Array.isArray(manifest.queues)) return "invalid manifest shape: queues must be an array";
|
|
106
107
|
for (const queue of manifest.queues) {
|
|
107
108
|
if (!isRecord(queue)) return "invalid manifest shape: queues entries must be objects";
|
|
108
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);
|
|
109
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";
|
|
110
112
|
for (const tuning of [
|
|
111
113
|
"maxBatchSize",
|
|
@@ -189,17 +191,17 @@ function validateManifestShape(manifest) {
|
|
|
189
191
|
if (manifest.assetConfig !== void 0) {
|
|
190
192
|
if (!isRecord(manifest.assetConfig)) return "invalid manifest shape: assetConfig must be an object";
|
|
191
193
|
const assetConfig = manifest.assetConfig;
|
|
192
|
-
if (assetConfig.not_found_handling !== void 0 && ![
|
|
194
|
+
if (assetConfig.not_found_handling !== void 0 && (typeof assetConfig.not_found_handling !== "string" || ![
|
|
193
195
|
"none",
|
|
194
196
|
"single-page-application",
|
|
195
197
|
"404-page"
|
|
196
|
-
].includes(assetConfig.not_found_handling)) return "invalid manifest shape: assetConfig.not_found_handling must be one of none, single-page-application, 404-page";
|
|
197
|
-
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" || ![
|
|
198
200
|
"auto-trailing-slash",
|
|
199
201
|
"force-trailing-slash",
|
|
200
202
|
"drop-trailing-slash",
|
|
201
203
|
"none"
|
|
202
|
-
].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";
|
|
203
205
|
}
|
|
204
206
|
if (manifest.revalidate !== void 0 && typeof manifest.revalidate !== "number") {
|
|
205
207
|
if (!isRecord(manifest.revalidate)) return "invalid manifest shape: revalidate must be a number or object";
|
|
@@ -242,6 +244,7 @@ function validateManifestShape(manifest) {
|
|
|
242
244
|
}
|
|
243
245
|
const fallbackRulesError = validateRoutingRules(manifest.fallbackRules, "fallbackRules");
|
|
244
246
|
if (fallbackRulesError) return fallbackRulesError;
|
|
247
|
+
const webSocketBindingNames = [];
|
|
245
248
|
if (manifest.websocket !== void 0) {
|
|
246
249
|
if (!isRecord(manifest.websocket)) return "invalid manifest shape: websocket must be an object";
|
|
247
250
|
const websocket = manifest.websocket;
|
|
@@ -250,6 +253,7 @@ function validateManifestShape(manifest) {
|
|
|
250
253
|
if (!isRecord(route)) return "invalid manifest shape: websocket.routes entries must be objects";
|
|
251
254
|
if (typeof route.className !== "string") return "invalid manifest shape: websocket.routes entries must have a string className";
|
|
252
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);
|
|
253
257
|
}
|
|
254
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";
|
|
255
259
|
const migrationsError = validateClassMigrations("websocket.migrations", websocket.migrations, [
|
|
@@ -266,10 +270,11 @@ function validateManifestShape(manifest) {
|
|
|
266
270
|
for (const key of [
|
|
267
271
|
"bindingName",
|
|
268
272
|
"className",
|
|
269
|
-
"containerName"
|
|
270
|
-
"image"
|
|
273
|
+
"containerName"
|
|
271
274
|
]) if (typeof sandbox[key] !== "string" || sandbox[key].length === 0) return `invalid manifest shape: sandbox.${key} must be a non-empty string`;
|
|
272
|
-
|
|
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";
|
|
273
278
|
if (sandbox.instanceType !== void 0 && typeof sandbox.instanceType !== "string") return "invalid manifest shape: sandbox.instanceType must be a string";
|
|
274
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";
|
|
275
280
|
const migrationsError = validateClassMigrations("sandbox.migrations", sandbox.migrations, ["newSqliteClasses", "deletedClasses"]);
|
|
@@ -291,10 +296,10 @@ function validateManifestShape(manifest) {
|
|
|
291
296
|
const names = /* @__PURE__ */ new Set();
|
|
292
297
|
const classes = /* @__PURE__ */ new Set();
|
|
293
298
|
const otherBindings = /* @__PURE__ */ new Set([
|
|
294
|
-
...Object.values(bindings).filter(Array.isArray).flat(),
|
|
299
|
+
...Object.values(bindings).filter((value) => Array.isArray(value)).flat(),
|
|
295
300
|
...Object.keys(isRecord(manifest.vars) ? manifest.vars : {}),
|
|
296
|
-
...
|
|
297
|
-
...
|
|
301
|
+
...queueBindingNames,
|
|
302
|
+
...webSocketBindingNames,
|
|
298
303
|
...isRecord(manifest.live) ? [manifest.live.bindingName] : []
|
|
299
304
|
]);
|
|
300
305
|
for (const binding of durable.bindings) {
|
|
@@ -428,10 +433,7 @@ function canonicalJson(value) {
|
|
|
428
433
|
if (value === null) return "null";
|
|
429
434
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return JSON.stringify(value);
|
|
430
435
|
if (Array.isArray(value)) return `[${value.map((entry) => canonicalJson(entry)).join(",")}]`;
|
|
431
|
-
if (
|
|
432
|
-
const object = value;
|
|
433
|
-
return `{${Object.keys(object).sort().filter((key) => object[key] !== void 0).map((key) => `${JSON.stringify(key)}:${canonicalJson(object[key])}`).join(",")}}`;
|
|
434
|
-
}
|
|
436
|
+
if (isRecord(value)) return `{${Object.keys(value).sort().filter((key) => value[key] !== void 0).map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
|
|
435
437
|
throw new TypeError(`Unsupported canonical JSON value: ${typeof value}`);
|
|
436
438
|
}
|
|
437
439
|
// src/artifact-digest.ts
|
|
@@ -549,7 +551,7 @@ function* tokenizeSql(sql) {
|
|
|
549
551
|
const MIGRATION_CLASSIFIER_VERSION = 1;
|
|
550
552
|
const UNSPLIT_MULTI_STATEMENT_PRAGMA = "-- void:allow-unsplit-multi-statement";
|
|
551
553
|
function canonicalSql(sql) {
|
|
552
|
-
return (sql.charCodeAt(0) === 65279 ? sql.slice(1) : sql).
|
|
554
|
+
return (sql.charCodeAt(0) === 65279 ? sql.slice(1) : sql).replaceAll(/\r\n?/g, "\n");
|
|
553
555
|
}
|
|
554
556
|
function hasStandalonePragma(sql, pragma) {
|
|
555
557
|
return canonicalSql(sql).split("\n").some((line) => line.trim() === pragma);
|
|
@@ -718,7 +720,10 @@ function appendSqliteClassMigration(migrations, classes, baseTag, knownExistingC
|
|
|
718
720
|
migrations,
|
|
719
721
|
added: false
|
|
720
722
|
};
|
|
721
|
-
const tags = new Set(migrations.
|
|
723
|
+
const tags = new Set(migrations.flatMap((migration) => {
|
|
724
|
+
const value = migration.tag;
|
|
725
|
+
return value ? [value] : [];
|
|
726
|
+
}));
|
|
722
727
|
let tag = baseTag;
|
|
723
728
|
for (let suffix = 2; tags.has(tag); suffix++) tag = `${baseTag}-${suffix}`;
|
|
724
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
|
}
|