@void/deploy-core 0.25.0 → 0.26.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 +6 -0
- package/dist/index.mjs +33 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -247,6 +247,12 @@ type MigrationPlanHashInput = SqlMigrationClassification & {
|
|
|
247
247
|
export declare function canonicalSql(sql: string): string;
|
|
248
248
|
export declare function hasStandalonePragma(sql: string, pragma: string): boolean;
|
|
249
249
|
export declare function isSingleStatement(sql: string): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Split SQL on top-level semicolons, ignoring literals and comments. Returns
|
|
252
|
+
* null when a statement may contain a compound `BEGIN ... END` body (such as
|
|
253
|
+
* CREATE TRIGGER), whose inner semicolons cannot be told apart lexically.
|
|
254
|
+
*/
|
|
255
|
+
export declare function splitSqlStatements(sql: string): Array<string> | null;
|
|
250
256
|
/** Classify SQL without imposing the caller's execution policy or hashing implementation. */
|
|
251
257
|
export declare function classifySqlMigration(sql: string): SqlMigrationClassification;
|
|
252
258
|
/** Preserve the classifier-v1 hash preimage; policy markers and warnings are not hashed. */
|
package/dist/index.mjs
CHANGED
|
@@ -552,30 +552,57 @@ function hasStatementBreakpointOutsideLiterals(sql) {
|
|
|
552
552
|
}
|
|
553
553
|
return false;
|
|
554
554
|
}
|
|
555
|
-
function
|
|
555
|
+
function scanStatements(sql) {
|
|
556
556
|
const normalized = canonicalSql(sql);
|
|
557
|
-
|
|
557
|
+
const ranges = [];
|
|
558
|
+
let cursor = 0;
|
|
558
559
|
let inStatement = false;
|
|
560
|
+
let hasCompoundBody = false;
|
|
559
561
|
for (const segment of tokenizeSql(normalized)) {
|
|
560
562
|
if (segment.kind === "line-comment" || segment.kind === "block-comment") continue;
|
|
561
563
|
if (segment.kind === "string" || segment.kind === "ident-quote") {
|
|
562
564
|
inStatement = true;
|
|
563
565
|
continue;
|
|
564
566
|
}
|
|
567
|
+
if (/\b(?:BEGIN|TRIGGER)\b/i.test(normalized.slice(segment.start, segment.end))) hasCompoundBody = true;
|
|
565
568
|
for (let index = segment.start; index < segment.end; index++) {
|
|
566
569
|
const character = normalized[index];
|
|
567
570
|
if (character === ";") {
|
|
568
571
|
if (inStatement) {
|
|
569
|
-
|
|
572
|
+
ranges.push({
|
|
573
|
+
start: cursor,
|
|
574
|
+
end: index + 1
|
|
575
|
+
});
|
|
570
576
|
inStatement = false;
|
|
571
577
|
}
|
|
578
|
+
cursor = index + 1;
|
|
572
579
|
continue;
|
|
573
580
|
}
|
|
574
581
|
if (character !== " " && character !== " " && character !== "\n" && character !== "\r") inStatement = true;
|
|
575
582
|
}
|
|
576
583
|
}
|
|
577
|
-
if (inStatement)
|
|
578
|
-
|
|
584
|
+
if (inStatement) ranges.push({
|
|
585
|
+
start: cursor,
|
|
586
|
+
end: normalized.length
|
|
587
|
+
});
|
|
588
|
+
return {
|
|
589
|
+
normalized,
|
|
590
|
+
ranges,
|
|
591
|
+
hasCompoundBody
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function isSingleStatement(sql) {
|
|
595
|
+
return scanStatements(sql).ranges.length === 1;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Split SQL on top-level semicolons, ignoring literals and comments. Returns
|
|
599
|
+
* null when a statement may contain a compound `BEGIN ... END` body (such as
|
|
600
|
+
* CREATE TRIGGER), whose inner semicolons cannot be told apart lexically.
|
|
601
|
+
*/
|
|
602
|
+
function splitSqlStatements(sql) {
|
|
603
|
+
const { normalized, ranges, hasCompoundBody } = scanStatements(sql);
|
|
604
|
+
if (hasCompoundBody) return null;
|
|
605
|
+
return ranges.map((range) => normalized.slice(range.start, range.end).trim());
|
|
579
606
|
}
|
|
580
607
|
/** Classify SQL without imposing the caller's execution policy or hashing implementation. */
|
|
581
608
|
function classifySqlMigration(sql) {
|
|
@@ -688,4 +715,4 @@ function isSandboxRegistryImage(image) {
|
|
|
688
715
|
return /^registry\.cloudflare\.com\/[^/@\s]+\/[^@\s]+@sha256:[a-f\d]{64}$/.test(image);
|
|
689
716
|
}
|
|
690
717
|
//#endregion
|
|
691
|
-
export { DEPLOY_ARTIFACT_VERSION, MANIFEST_REDIRECT_RULE_STATUSES, MAX_REVALIDATE_QUERY_ALLOWLIST_ENTRIES, MAX_ROUTING_RULES, MIGRATION_CLASSIFIER_VERSION, SUPPORTED_MANIFEST_VERSIONS, UNSPLIT_MULTI_STATEMENT_PRAGMA, appendSqliteClassMigration, canonicalJson, canonicalSql, classifySqlMigration, createDeployArtifact, createDeployIntent, createDeployResourcePlan, createDeployUploadPayload, getMigrationPlanHashInput, hasStandalonePragma, isRecord, isSandboxRegistryImage, isSingleStatement, planWebSocketMigrations, tokenizeSql, validateManifestShape };
|
|
718
|
+
export { DEPLOY_ARTIFACT_VERSION, MANIFEST_REDIRECT_RULE_STATUSES, MAX_REVALIDATE_QUERY_ALLOWLIST_ENTRIES, MAX_ROUTING_RULES, MIGRATION_CLASSIFIER_VERSION, SUPPORTED_MANIFEST_VERSIONS, UNSPLIT_MULTI_STATEMENT_PRAGMA, appendSqliteClassMigration, canonicalJson, canonicalSql, classifySqlMigration, createDeployArtifact, createDeployIntent, createDeployResourcePlan, createDeployUploadPayload, getMigrationPlanHashInput, hasStandalonePragma, isRecord, isSandboxRegistryImage, isSingleStatement, planWebSocketMigrations, splitSqlStatements, tokenizeSql, validateManifestShape };
|