@quickback-dev/cli 0.60.3 → 0.60.5
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/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +89 -13
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/compile.test.js +52 -5
- package/dist/commands/compile.test.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/api-client.d.ts +15 -0
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +10 -8
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/migrations/commit.d.ts +38 -0
- package/dist/lib/migrations/commit.d.ts.map +1 -0
- package/dist/lib/migrations/commit.js +39 -0
- package/dist/lib/migrations/commit.js.map +1 -0
- package/dist/lib/migrations/drizzle-prompts.d.ts +97 -0
- package/dist/lib/migrations/drizzle-prompts.d.ts.map +1 -0
- package/dist/lib/migrations/drizzle-prompts.js +190 -0
- package/dist/lib/migrations/drizzle-prompts.js.map +1 -0
- package/dist/lib/migrations/drizzle-prompts.test.d.ts +2 -0
- package/dist/lib/migrations/drizzle-prompts.test.d.ts.map +1 -0
- package/dist/lib/migrations/drizzle-prompts.test.js +135 -0
- package/dist/lib/migrations/drizzle-prompts.test.js.map +1 -0
- package/dist/lib/migrations/drizzle-wrapper.d.ts +28 -0
- package/dist/lib/migrations/drizzle-wrapper.d.ts.map +1 -0
- package/dist/lib/migrations/drizzle-wrapper.js +63 -0
- package/dist/lib/migrations/drizzle-wrapper.js.map +1 -0
- package/dist/lib/migrations/executor.d.ts +4 -1
- package/dist/lib/migrations/executor.d.ts.map +1 -1
- package/dist/lib/migrations/executor.js +0 -6
- package/dist/lib/migrations/executor.js.map +1 -1
- package/dist/lib/migrations/file-envelopes.d.ts +42 -0
- package/dist/lib/migrations/file-envelopes.d.ts.map +1 -0
- package/dist/lib/migrations/file-envelopes.js +255 -0
- package/dist/lib/migrations/file-envelopes.js.map +1 -0
- package/dist/lib/migrations/postprocessors/audit-migration-hardening.d.ts +29 -0
- package/dist/lib/migrations/postprocessors/audit-migration-hardening.d.ts.map +1 -0
- package/dist/lib/migrations/postprocessors/audit-migration-hardening.js +67 -0
- package/dist/lib/migrations/postprocessors/audit-migration-hardening.js.map +1 -0
- package/dist/lib/migrations/postprocessors/index.d.ts +58 -0
- package/dist/lib/migrations/postprocessors/index.d.ts.map +1 -0
- package/dist/lib/migrations/postprocessors/index.js +344 -0
- package/dist/lib/migrations/postprocessors/index.js.map +1 -0
- package/dist/lib/migrations/postprocessors/index.test.d.ts +2 -0
- package/dist/lib/migrations/postprocessors/index.test.d.ts.map +1 -0
- package/dist/lib/migrations/postprocessors/index.test.js +298 -0
- package/dist/lib/migrations/postprocessors/index.test.js.map +1 -0
- package/dist/lib/migrations/postprocessors/migration-reorder.d.ts +39 -0
- package/dist/lib/migrations/postprocessors/migration-reorder.d.ts.map +1 -0
- package/dist/lib/migrations/postprocessors/migration-reorder.js +185 -0
- package/dist/lib/migrations/postprocessors/migration-reorder.js.map +1 -0
- package/dist/lib/migrations/postprocessors/trigger-sql.d.ts +51 -0
- package/dist/lib/migrations/postprocessors/trigger-sql.d.ts.map +1 -0
- package/dist/lib/migrations/postprocessors/trigger-sql.js +62 -0
- package/dist/lib/migrations/postprocessors/trigger-sql.js.map +1 -0
- package/dist/lib/migrations/prior-state.d.ts +63 -0
- package/dist/lib/migrations/prior-state.d.ts.map +1 -0
- package/dist/lib/migrations/prior-state.js +141 -0
- package/dist/lib/migrations/prior-state.js.map +1 -0
- package/dist/lib/migrations/prompt-runner.d.ts +32 -0
- package/dist/lib/migrations/prompt-runner.d.ts.map +1 -0
- package/dist/lib/migrations/prompt-runner.js +158 -0
- package/dist/lib/migrations/prompt-runner.js.map +1 -0
- package/dist/lib/migrations/prompt-runner.test.d.ts +2 -0
- package/dist/lib/migrations/prompt-runner.test.d.ts.map +1 -0
- package/dist/lib/migrations/prompt-runner.test.js +131 -0
- package/dist/lib/migrations/prompt-runner.test.js.map +1 -0
- package/dist/lib/migrations/schema-contract.d.ts +44 -0
- package/dist/lib/migrations/schema-contract.d.ts.map +1 -0
- package/dist/lib/migrations/schema-contract.js +51 -0
- package/dist/lib/migrations/schema-contract.js.map +1 -0
- package/dist/skill/docs/api/errors.md +1 -0
- package/dist/skill/docs/changelog/index.md +24 -0
- package/dist/skill/docs/configure/domains.md +84 -0
- package/dist/skill/docs/define/firewall.md +1 -0
- package/dist/skill/docs/define/relationships.md +35 -0
- package/dist/skill/docs/platform/database/d1.md +14 -0
- package/dist/skill/docs/platform/database/neon.md +12 -5
- package/dist/skill/docs/start/deploy-browser.md +3 -0
- package/dist/skill/docs/tooling/output.md +28 -10
- package/package.json +1 -1
- package/src/skill/docs/api/errors.md +1 -0
- package/src/skill/docs/changelog/index.md +24 -0
- package/src/skill/docs/configure/domains.md +84 -0
- package/src/skill/docs/define/firewall.md +1 -0
- package/src/skill/docs/define/relationships.md +35 -0
- package/src/skill/docs/platform/database/d1.md +14 -0
- package/src/skill/docs/platform/database/neon.md +12 -5
- package/src/skill/docs/start/deploy-browser.md +3 -0
- package/src/skill/docs/tooling/output.md +28 -10
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header/footer envelopes for generated files.
|
|
3
|
+
*
|
|
4
|
+
* Copied verbatim from `apps/compiler/src/runner/file-envelopes.ts`. The
|
|
5
|
+
* compiler stamps every file it emits — `-- Generated by quickback.dev` on
|
|
6
|
+
* source, a `$$__quickback_warning__$$` key on drizzle journals. Under
|
|
7
|
+
* compiler-owned migrations those stamped bytes are what landed in the user's
|
|
8
|
+
* repo, so locally generated migrations must carry the same envelope or a
|
|
9
|
+
* project's migration tree ends up half-decorated across the cutover.
|
|
10
|
+
*
|
|
11
|
+
* Both `addHeader` and `addFooter` are idempotent by design (the compiler's
|
|
12
|
+
* envelope pass already runs in both its compile paths), which is what makes
|
|
13
|
+
* it safe to apply on every commit, including to files staged from a previous
|
|
14
|
+
* compile that already carry an envelope.
|
|
15
|
+
*
|
|
16
|
+
* Keep byte-equivalent to the compiler's copy — the parity gate compares
|
|
17
|
+
* these exact bytes.
|
|
18
|
+
*/
|
|
19
|
+
export interface GeneratedFile {
|
|
20
|
+
path: string;
|
|
21
|
+
content: string;
|
|
22
|
+
type?: string;
|
|
23
|
+
feature?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Strip the `$$__quickback_warning__$$` key from a JSON payload, if present.
|
|
27
|
+
*/
|
|
28
|
+
export declare function stripJsonHeader(content: string): string;
|
|
29
|
+
export declare function stripGeneratedSqlEnvelope(content: string): string;
|
|
30
|
+
export declare const DRIZZLE_JOURNAL_JSON_RE: RegExp;
|
|
31
|
+
export declare const DRIZZLE_SNAPSHOT_JSON_RE: RegExp;
|
|
32
|
+
export declare function addHeader(file: GeneratedFile): GeneratedFile;
|
|
33
|
+
export declare function addFooter(file: GeneratedFile): GeneratedFile;
|
|
34
|
+
/**
|
|
35
|
+
* MIT license for the generated output. The copyright holder is the project's
|
|
36
|
+
* own authors — the generated code belongs to the user; Quickback grants and
|
|
37
|
+
* claims nothing over it beyond the disclaimer. No year on the copyright line:
|
|
38
|
+
* compile output stays byte-deterministic across year boundaries.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildLicenseFile(projectName?: string): GeneratedFile;
|
|
41
|
+
export declare function buildDisclaimerFile(): GeneratedFile;
|
|
42
|
+
//# sourceMappingURL=file-envelopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-envelopes.d.ts","sourceRoot":"","sources":["../../../src/lib/migrations/file-envelopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA+ED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAevD;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAejE;AAED,eAAO,MAAM,uBAAuB,QAAiD,CAAC;AACtF,eAAO,MAAM,wBAAwB,QAAqD,CAAC;AAE3F,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAwB5D;AAkCD,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAmB5D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,aAAa,CA8BpE;AAED,wBAAgB,mBAAmB,IAAI,aAAa,CA8BnD"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header/footer envelopes for generated files.
|
|
3
|
+
*
|
|
4
|
+
* Copied verbatim from `apps/compiler/src/runner/file-envelopes.ts`. The
|
|
5
|
+
* compiler stamps every file it emits — `-- Generated by quickback.dev` on
|
|
6
|
+
* source, a `$$__quickback_warning__$$` key on drizzle journals. Under
|
|
7
|
+
* compiler-owned migrations those stamped bytes are what landed in the user's
|
|
8
|
+
* repo, so locally generated migrations must carry the same envelope or a
|
|
9
|
+
* project's migration tree ends up half-decorated across the cutover.
|
|
10
|
+
*
|
|
11
|
+
* Both `addHeader` and `addFooter` are idempotent by design (the compiler's
|
|
12
|
+
* envelope pass already runs in both its compile paths), which is what makes
|
|
13
|
+
* it safe to apply on every commit, including to files staged from a previous
|
|
14
|
+
* compile that already carry an envelope.
|
|
15
|
+
*
|
|
16
|
+
* Keep byte-equivalent to the compiler's copy — the parity gate compares
|
|
17
|
+
* these exact bytes.
|
|
18
|
+
*/
|
|
19
|
+
const HEADER_LINES = [
|
|
20
|
+
'Generated by quickback.dev',
|
|
21
|
+
'SPDX-License-Identifier: MIT (see LICENSE.txt at the project root)',
|
|
22
|
+
'',
|
|
23
|
+
'This file is managed by the Quickback Compiler — do not edit directly.',
|
|
24
|
+
'To make changes, update your config and feature definitions in the quickback/ folder,',
|
|
25
|
+
'then run `quickback compile` to regenerate.',
|
|
26
|
+
'Docs for humans and agents: https://docs.quickback.dev/llms.txt',
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* SQL migrations keep the pre-MIT header, EXACTLY. The deployment manifest
|
|
30
|
+
* hashes migration files after stamping, and the broker's ledger refuses
|
|
31
|
+
* drift on previously-applied migrations — adding a line here would change
|
|
32
|
+
* every existing deployment's migration hashes and hard-fail their next
|
|
33
|
+
* brokered deploy. The MIT grant still covers them via LICENSE.txt.
|
|
34
|
+
*/
|
|
35
|
+
const SQL_HEADER_LINES = [
|
|
36
|
+
'Generated by quickback.dev',
|
|
37
|
+
'',
|
|
38
|
+
'This file is managed by the Quickback Compiler — do not edit directly.',
|
|
39
|
+
'To make changes, update your config and feature definitions in the quickback/ folder,',
|
|
40
|
+
'then run `quickback compile` to regenerate.',
|
|
41
|
+
];
|
|
42
|
+
const JS_HEADER = { open: '/**', prefix: ' * ', close: ' */' };
|
|
43
|
+
const SQL_HEADER = { open: '--', prefix: '-- ' };
|
|
44
|
+
const TOML_HEADER = { open: '#', prefix: '# ' };
|
|
45
|
+
// Comments before <!doctype html> are spec-legal; browsers stay in
|
|
46
|
+
// standards mode. Lets the staged SPA shells carry the disclaimer too.
|
|
47
|
+
const HTML_HEADER = { open: '<!--', prefix: ' ', close: '-->' };
|
|
48
|
+
const HEADER_STYLE = {
|
|
49
|
+
'.ts': JS_HEADER, '.js': JS_HEADER, '.tsx': JS_HEADER, '.jsx': JS_HEADER,
|
|
50
|
+
'.css': JS_HEADER,
|
|
51
|
+
'.html': HTML_HEADER,
|
|
52
|
+
'.sql': SQL_HEADER,
|
|
53
|
+
'.toml': TOML_HEADER,
|
|
54
|
+
};
|
|
55
|
+
function buildHeaderFromLines(style, headerLines) {
|
|
56
|
+
const lines = [style.open, ...headerLines.map(l => l ? style.prefix + l : style.prefix.trimEnd())];
|
|
57
|
+
if (style.close)
|
|
58
|
+
lines.push(style.close);
|
|
59
|
+
lines.push('');
|
|
60
|
+
return lines.join('\n');
|
|
61
|
+
}
|
|
62
|
+
function buildHeader(style) {
|
|
63
|
+
return buildHeaderFromLines(style, style === SQL_HEADER ? SQL_HEADER_LINES : HEADER_LINES);
|
|
64
|
+
}
|
|
65
|
+
const JSON_WARNING_KEY = '$$__quickback_warning__$$';
|
|
66
|
+
const JSON_WARNING_VALUE = 'DO NOT EDIT — Generated by quickback.dev. ' +
|
|
67
|
+
'This file is managed by the Quickback Compiler. ' +
|
|
68
|
+
'To make changes, update your config in the quickback/ folder and run `quickback compile`. ' +
|
|
69
|
+
'THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.';
|
|
70
|
+
function addJsonHeader(content) {
|
|
71
|
+
let parsed;
|
|
72
|
+
try {
|
|
73
|
+
parsed = JSON.parse(content);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return content;
|
|
77
|
+
}
|
|
78
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
79
|
+
return content;
|
|
80
|
+
}
|
|
81
|
+
const { [JSON_WARNING_KEY]: _stale, ...rest } = parsed;
|
|
82
|
+
return JSON.stringify({ [JSON_WARNING_KEY]: JSON_WARNING_VALUE, ...rest }, null, 2) + '\n';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Strip the `$$__quickback_warning__$$` key from a JSON payload, if present.
|
|
86
|
+
*/
|
|
87
|
+
export function stripJsonHeader(content) {
|
|
88
|
+
let parsed;
|
|
89
|
+
try {
|
|
90
|
+
parsed = JSON.parse(content);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return content;
|
|
94
|
+
}
|
|
95
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
96
|
+
return content;
|
|
97
|
+
}
|
|
98
|
+
if (!(JSON_WARNING_KEY in parsed)) {
|
|
99
|
+
return content;
|
|
100
|
+
}
|
|
101
|
+
const { [JSON_WARNING_KEY]: _stale, ...rest } = parsed;
|
|
102
|
+
return JSON.stringify(rest, null, 2) + '\n';
|
|
103
|
+
}
|
|
104
|
+
export function stripGeneratedSqlEnvelope(content) {
|
|
105
|
+
const style = HEADER_STYLE['.sql'];
|
|
106
|
+
const footer = buildFooter(FOOTER_STYLE['.sql']).trimEnd();
|
|
107
|
+
// Strip both the canonical SQL header and the general (SPDX-carrying)
|
|
108
|
+
// shape, in case a future release ever stamped SQL with it.
|
|
109
|
+
let withoutHeaders = content;
|
|
110
|
+
for (const lines of [SQL_HEADER_LINES, HEADER_LINES]) {
|
|
111
|
+
const header = buildHeaderFromLines(style, lines);
|
|
112
|
+
withoutHeaders = withoutHeaders.split(header).join('');
|
|
113
|
+
}
|
|
114
|
+
const withoutFooters = withoutHeaders.split(footer).join('');
|
|
115
|
+
const trimmed = withoutFooters.trim();
|
|
116
|
+
return trimmed.length > 0 ? `${trimmed}\n` : '';
|
|
117
|
+
}
|
|
118
|
+
export const DRIZZLE_JOURNAL_JSON_RE = /\/drizzle(?:\/[^/]+)?\/meta\/_journal\.json$/;
|
|
119
|
+
export const DRIZZLE_SNAPSHOT_JSON_RE = /\/drizzle(?:\/[^/]+)?\/meta\/\d+_snapshot\.json$/;
|
|
120
|
+
export function addHeader(file) {
|
|
121
|
+
const { path, content } = file;
|
|
122
|
+
if (DRIZZLE_JOURNAL_JSON_RE.test(path)) {
|
|
123
|
+
return { ...file, content: addJsonHeader(content) };
|
|
124
|
+
}
|
|
125
|
+
if (path.endsWith('package.json') || path.endsWith('.lockb') || path.endsWith('-lock.json') || path.endsWith('.json')) {
|
|
126
|
+
return file;
|
|
127
|
+
}
|
|
128
|
+
const ext = path.slice(path.lastIndexOf('.'));
|
|
129
|
+
const style = HEADER_STYLE[ext];
|
|
130
|
+
if (!style)
|
|
131
|
+
return file;
|
|
132
|
+
const header = buildHeader(style);
|
|
133
|
+
// Idempotent: the envelope pass runs in both compile paths (basic and
|
|
134
|
+
// complete), and the complete path stages basic output before re-stamping.
|
|
135
|
+
if (content.startsWith(header))
|
|
136
|
+
return file;
|
|
137
|
+
return {
|
|
138
|
+
...file,
|
|
139
|
+
content: header + content,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const FOOTER_LINES = [
|
|
143
|
+
'THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR',
|
|
144
|
+
'IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,',
|
|
145
|
+
'FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL',
|
|
146
|
+
'THE AUTHORS OR COPYRIGHT HOLDERS OR DISTRIBUTORS BE LIABLE FOR ANY CLAIM,',
|
|
147
|
+
'DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR',
|
|
148
|
+
'OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE FILE OR THE USE',
|
|
149
|
+
'OR OTHER DEALINGS IN THE FILE.',
|
|
150
|
+
];
|
|
151
|
+
const JS_FOOTER = { header: '/**\n * Generated by quickback.dev', empty: ' *', prefix: ' * ', close: ' */' };
|
|
152
|
+
const SQL_FOOTER = { header: '-- Generated by quickback.dev', empty: '--', prefix: '-- ' };
|
|
153
|
+
const TOML_FOOTER = { header: '# Generated by quickback.dev', empty: '#', prefix: '# ' };
|
|
154
|
+
const HTML_FOOTER = { header: '<!--\n Generated by quickback.dev', empty: '', prefix: ' ', close: '-->' };
|
|
155
|
+
const FOOTER_STYLE = {
|
|
156
|
+
'.ts': JS_FOOTER, '.js': JS_FOOTER, '.tsx': JS_FOOTER, '.jsx': JS_FOOTER,
|
|
157
|
+
'.css': JS_FOOTER,
|
|
158
|
+
'.html': HTML_FOOTER,
|
|
159
|
+
'.sql': SQL_FOOTER,
|
|
160
|
+
'.toml': TOML_FOOTER,
|
|
161
|
+
};
|
|
162
|
+
function buildFooter(style) {
|
|
163
|
+
const lines = ['', '', style.header, style.empty, ...FOOTER_LINES.map(l => style.prefix + l)];
|
|
164
|
+
if (style.close)
|
|
165
|
+
lines.push(style.close);
|
|
166
|
+
lines.push('');
|
|
167
|
+
return lines.join('\n');
|
|
168
|
+
}
|
|
169
|
+
export function addFooter(file) {
|
|
170
|
+
const { path, content } = file;
|
|
171
|
+
if (path.endsWith('package.json') || path.endsWith('.lockb') || path.endsWith('-lock.json')) {
|
|
172
|
+
return file;
|
|
173
|
+
}
|
|
174
|
+
const ext = path.slice(path.lastIndexOf('.'));
|
|
175
|
+
const style = FOOTER_STYLE[ext];
|
|
176
|
+
if (!style)
|
|
177
|
+
return file;
|
|
178
|
+
const footer = buildFooter(style);
|
|
179
|
+
// Idempotent — see addHeader.
|
|
180
|
+
if (content.trimEnd().endsWith(footer.trimEnd()))
|
|
181
|
+
return file;
|
|
182
|
+
return {
|
|
183
|
+
...file,
|
|
184
|
+
content: content.trimEnd() + footer,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* MIT license for the generated output. The copyright holder is the project's
|
|
189
|
+
* own authors — the generated code belongs to the user; Quickback grants and
|
|
190
|
+
* claims nothing over it beyond the disclaimer. No year on the copyright line:
|
|
191
|
+
* compile output stays byte-deterministic across year boundaries.
|
|
192
|
+
*/
|
|
193
|
+
export function buildLicenseFile(projectName) {
|
|
194
|
+
const holder = projectName
|
|
195
|
+
? `The ${projectName} project authors`
|
|
196
|
+
: 'The project authors';
|
|
197
|
+
return {
|
|
198
|
+
path: 'LICENSE.txt',
|
|
199
|
+
type: 'other',
|
|
200
|
+
content: `MIT License
|
|
201
|
+
|
|
202
|
+
Copyright (c) ${holder}
|
|
203
|
+
|
|
204
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
205
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
206
|
+
in the Software without restriction, including without limitation the rights
|
|
207
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
208
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
209
|
+
furnished to do so, subject to the following conditions:
|
|
210
|
+
|
|
211
|
+
The above copyright notice and this permission notice shall be included in all
|
|
212
|
+
copies or substantial portions of the Software.
|
|
213
|
+
|
|
214
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
215
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
216
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
217
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
218
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
219
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
220
|
+
SOFTWARE.
|
|
221
|
+
`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export function buildDisclaimerFile() {
|
|
225
|
+
return {
|
|
226
|
+
path: 'DISCLAIMER.txt',
|
|
227
|
+
type: 'other',
|
|
228
|
+
content: `DISCLAIMER — Generated Code
|
|
229
|
+
|
|
230
|
+
This source code was generated by the Quickback Compiler (https://quickback.dev)
|
|
231
|
+
and is licensed to you under the MIT License — see LICENSE.txt in this directory.
|
|
232
|
+
|
|
233
|
+
THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
234
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
235
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
236
|
+
COPYRIGHT HOLDERS OR DISTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
237
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
238
|
+
OUT OF OR IN CONNECTION WITH THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
|
|
239
|
+
|
|
240
|
+
By using this generated code you acknowledge that:
|
|
241
|
+
|
|
242
|
+
1. The generated code is a starting point and may require review, testing, and
|
|
243
|
+
modification before use in production.
|
|
244
|
+
|
|
245
|
+
2. You are solely responsible for the security, correctness, and compliance of
|
|
246
|
+
any application built with this code.
|
|
247
|
+
|
|
248
|
+
3. Quickback and its contributors accept no liability for data loss, security
|
|
249
|
+
breaches, or any other damages resulting from the use of this generated code.
|
|
250
|
+
|
|
251
|
+
For documentation and support visit https://quickback.dev/docs
|
|
252
|
+
`,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=file-envelopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-envelopes.js","sourceRoot":"","sources":["../../../src/lib/migrations/file-envelopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,MAAM,YAAY,GAAG;IACnB,4BAA4B;IAC5B,oEAAoE;IACpE,EAAE;IACF,wEAAwE;IACxE,uFAAuF;IACvF,6CAA6C;IAC7C,iEAAiE;CAClE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG;IACvB,4BAA4B;IAC5B,EAAE;IACF,wEAAwE;IACxE,uFAAuF;IACvF,6CAA6C;CAC9C,CAAC;AAIF,MAAM,SAAS,GAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC5E,MAAM,UAAU,GAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC9D,MAAM,WAAW,GAAgB,EAAE,IAAI,EAAE,G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,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC;IAE9D,OAAO;QACL,GAAG,IAAI;QACP,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,MAAM;KACpC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAoB;IACnD,MAAM,MAAM,GAAG,WAAW;QACxB,CAAC,CAAC,OAAO,WAAW,kBAAkB;QACtC,CAAC,CAAC,qBAAqB,CAAC;IAC1B,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,OAAgB;QACtB,OAAO,EAAE;;gBAEG,MAAM;;;;;;;;;;;;;;;;;;;CAmBrB;KACE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,OAAgB;QACtB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;CAwBZ;KACE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit-subsystem migration hardening.
|
|
3
|
+
*
|
|
4
|
+
* `audit.events` is an append-only forensic sink, so its DDL gets two
|
|
5
|
+
* guarantees no other subsystem needs:
|
|
6
|
+
*
|
|
7
|
+
* 1. Creation is idempotent — `CREATE SCHEMA/TABLE/INDEX` targeting the
|
|
8
|
+
* audit subsystem is rewritten to the `IF NOT EXISTS` form, so a
|
|
9
|
+
* re-emission after a broken snapshot lineage can never collide with
|
|
10
|
+
* objects the database already holds (SQLSTATE 42P06/42P07).
|
|
11
|
+
* 2. Destruction is vetoed — generated `DROP` statements against the
|
|
12
|
+
* audit schema, table, or indexes are removed outright. Purging
|
|
13
|
+
* evidence must be a deliberate operator action, never a generated
|
|
14
|
+
* migration. (The emission latch in utils/audit-latch.ts prevents the
|
|
15
|
+
* drop from being generated in the first place; this is defense in
|
|
16
|
+
* depth for lineages that already diverged.)
|
|
17
|
+
*
|
|
18
|
+
* Deliberately NOT in migration-reorder.ts: that module's contract is
|
|
19
|
+
* "reorders dependency-linked constraint statements, byte-identical
|
|
20
|
+
* otherwise", while this transform rewrites statement text. The runner
|
|
21
|
+
* applies it only to migration files generated in the current compile —
|
|
22
|
+
* rewriting an already-applied file would drift its migrator hash.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Harden one migration file's SQL. Byte-identical when the file touches
|
|
26
|
+
* nothing in the audit subsystem; idempotent (f(f(x)) === f(x)).
|
|
27
|
+
*/
|
|
28
|
+
export declare function hardenAuditMigrationSql(sql: string): string;
|
|
29
|
+
//# sourceMappingURL=audit-migration-hardening.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-migration-hardening.d.ts","sourceRoot":"","sources":["../../../../src/lib/migrations/postprocessors/audit-migration-hardening.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAiBH;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA4B3D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit-subsystem migration hardening.
|
|
3
|
+
*
|
|
4
|
+
* `audit.events` is an append-only forensic sink, so its DDL gets two
|
|
5
|
+
* guarantees no other subsystem needs:
|
|
6
|
+
*
|
|
7
|
+
* 1. Creation is idempotent — `CREATE SCHEMA/TABLE/INDEX` targeting the
|
|
8
|
+
* audit subsystem is rewritten to the `IF NOT EXISTS` form, so a
|
|
9
|
+
* re-emission after a broken snapshot lineage can never collide with
|
|
10
|
+
* objects the database already holds (SQLSTATE 42P06/42P07).
|
|
11
|
+
* 2. Destruction is vetoed — generated `DROP` statements against the
|
|
12
|
+
* audit schema, table, or indexes are removed outright. Purging
|
|
13
|
+
* evidence must be a deliberate operator action, never a generated
|
|
14
|
+
* migration. (The emission latch in utils/audit-latch.ts prevents the
|
|
15
|
+
* drop from being generated in the first place; this is defense in
|
|
16
|
+
* depth for lineages that already diverged.)
|
|
17
|
+
*
|
|
18
|
+
* Deliberately NOT in migration-reorder.ts: that module's contract is
|
|
19
|
+
* "reorders dependency-linked constraint statements, byte-identical
|
|
20
|
+
* otherwise", while this transform rewrites statement text. The runner
|
|
21
|
+
* applies it only to migration files generated in the current compile —
|
|
22
|
+
* rewriting an already-applied file would drift its migrator hash.
|
|
23
|
+
*/
|
|
24
|
+
const BREAKPOINT = '--> statement-breakpoint';
|
|
25
|
+
const CREATE_SCHEMA_RE = /\bCREATE SCHEMA "audit"/;
|
|
26
|
+
const CREATE_TABLE_RE = /\bCREATE TABLE "audit"\."events"/;
|
|
27
|
+
const CREATE_INDEX_RE = /\bCREATE (UNIQUE )?INDEX ("(?:[^"]|"")+") ON "audit"\."events"/g;
|
|
28
|
+
/**
|
|
29
|
+
* A whole breakpoint segment consisting of one destructive statement against
|
|
30
|
+
* the audit subsystem. Vetoed segments are removed (never commented out —
|
|
31
|
+
* they only ever appear in freshly generated, never-applied files, and a
|
|
32
|
+
* comment-only segment is undefined territory for the migrator's executor).
|
|
33
|
+
*/
|
|
34
|
+
const VETOED_DROP_RE = /^\s*DROP\s+(?:SCHEMA\s+"audit"(?:\s+CASCADE)?|TABLE\s+(?:IF\s+EXISTS\s+)?"audit"\."events"(?:\s+CASCADE)?|INDEX\s+(?:IF\s+EXISTS\s+)?(?:"audit"\.)?"audit_events_[^"]+")\s*;\s*$/;
|
|
35
|
+
/**
|
|
36
|
+
* Harden one migration file's SQL. Byte-identical when the file touches
|
|
37
|
+
* nothing in the audit subsystem; idempotent (f(f(x)) === f(x)).
|
|
38
|
+
*/
|
|
39
|
+
export function hardenAuditMigrationSql(sql) {
|
|
40
|
+
const segments = sql.split(BREAKPOINT);
|
|
41
|
+
const kept = [];
|
|
42
|
+
const vetoed = [];
|
|
43
|
+
let changed = false;
|
|
44
|
+
for (const seg of segments) {
|
|
45
|
+
if (VETOED_DROP_RE.test(seg)) {
|
|
46
|
+
vetoed.push(seg.trim());
|
|
47
|
+
changed = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const hardened = seg
|
|
51
|
+
.replace(CREATE_SCHEMA_RE, 'CREATE SCHEMA IF NOT EXISTS "audit"')
|
|
52
|
+
.replace(CREATE_TABLE_RE, 'CREATE TABLE IF NOT EXISTS "audit"."events"')
|
|
53
|
+
.replace(CREATE_INDEX_RE, 'CREATE $1INDEX IF NOT EXISTS $2 ON "audit"."events"');
|
|
54
|
+
if (hardened !== seg)
|
|
55
|
+
changed = true;
|
|
56
|
+
kept.push(hardened);
|
|
57
|
+
}
|
|
58
|
+
if (!changed)
|
|
59
|
+
return sql;
|
|
60
|
+
const header = vetoed.length
|
|
61
|
+
? `-- quickback: vetoed ${vetoed.length} destructive audit statement(s) — audit.events is an append-only forensic sink; purging it must be an explicit operator action:\n` +
|
|
62
|
+
vetoed.map((v) => `-- ${v.replace(/\n/g, ' ')}`).join('\n') +
|
|
63
|
+
'\n'
|
|
64
|
+
: '';
|
|
65
|
+
return header + kept.join(BREAKPOINT);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=audit-migration-hardening.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-migration-hardening.js","sourceRoot":"","sources":["../../../../src/lib/migrations/postprocessors/audit-migration-hardening.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AACnD,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAC3D,MAAM,eAAe,GAAG,iEAAiE,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,cAAc,GAClB,kLAAkL,CAAC;AAErL;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW;IACjD,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YACxB,OAAO,GAAG,IAAI,CAAC;YACf,SAAS;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,GAAG;aACjB,OAAO,CAAC,gBAAgB,EAAE,qCAAqC,CAAC;aAChE,OAAO,CAAC,eAAe,EAAE,6CAA6C,CAAC;aACvE,OAAO,CAAC,eAAe,EAAE,qDAAqD,CAAC,CAAC;QACnF,IAAI,QAAQ,KAAK,GAAG;YAAE,OAAO,GAAG,IAAI,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC;IAEzB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM;QAC1B,CAAC,CAAC,wBAAwB,MAAM,CAAC,MAAM,mIAAmI;YACxK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC7D,IAAI;QACN,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side implementations of the six migration postprocessors the
|
|
3
|
+
* compiler names in `ClientMigrationTarget.postprocessors`.
|
|
4
|
+
*
|
|
5
|
+
* These are behavior-for-behavior ports of `apps/compiler/src/runner/
|
|
6
|
+
* migrations.ts`, which is what makes the cutover verifiable: the output
|
|
7
|
+
* matrix normalizes drizzle's known nondeterminism (codenames, journal
|
|
8
|
+
* `when`, snapshot ids), so a correct port leaves every golden unchanged.
|
|
9
|
+
*
|
|
10
|
+
* Two differences from the server, both deliberate and both narrowing:
|
|
11
|
+
*
|
|
12
|
+
* - **Per-target, not a sweep.** The server iterated a fixed list of three
|
|
13
|
+
* journal paths because it could not know which targets ran. The executor
|
|
14
|
+
* invokes each postprocessor with the target that just generated, so each
|
|
15
|
+
* handler touches exactly one migration directory. The executor's
|
|
16
|
+
* `assertNewPathsBelongToTarget` enforces that.
|
|
17
|
+
*
|
|
18
|
+
* - **`harden-audit` uses the real prior inventory.** The server approximated
|
|
19
|
+
* "files that existed before this compile" from the uploaded `existingFiles`
|
|
20
|
+
* map. The executor hands us `inventoryBeforeTarget` — the actual on-disk
|
|
21
|
+
* state before drizzle ran — which is a strictly better hash-drift guard.
|
|
22
|
+
*
|
|
23
|
+
* `d1-safety` is intentionally a NO-OP. It is named on every sqlite target but
|
|
24
|
+
* has never had an implementation on either side, and plan 001 never specifies
|
|
25
|
+
* one. Making it do something here would change behavior relative to the
|
|
26
|
+
* server path and break golden parity — it must stay inert until it is
|
|
27
|
+
* specified and landed as its own reviewed change.
|
|
28
|
+
*/
|
|
29
|
+
import type { MigrationPostprocessorHandler } from '../executor.js';
|
|
30
|
+
import type { ClientMigrationPostprocessor } from '../types.js';
|
|
31
|
+
import { type RlsJournalMigrationMeta, type TriggerJournalMigrationMeta } from './trigger-sql.js';
|
|
32
|
+
export interface MigrationPostprocessorDeps {
|
|
33
|
+
/**
|
|
34
|
+
* The compiler-computed RLS migration for this compile, from
|
|
35
|
+
* `meta.rlsJournalMigration`. Undefined on non-Postgres targets.
|
|
36
|
+
*/
|
|
37
|
+
rlsJournalMigration?: RlsJournalMigrationMeta;
|
|
38
|
+
/**
|
|
39
|
+
* The compiler-computed trigger set, from `meta.triggerJournalMigration`.
|
|
40
|
+
* Undefined when the project renders no SQL triggers.
|
|
41
|
+
*/
|
|
42
|
+
triggerJournalMigration?: TriggerJournalMigrationMeta;
|
|
43
|
+
/** Verbose progress sink. Defaults to silence. */
|
|
44
|
+
log?: (message: string) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Collector for non-fatal drift diagnostics (snapshot drift). The compile
|
|
47
|
+
* command surfaces these the way the server's `commandWarnings` were.
|
|
48
|
+
*/
|
|
49
|
+
warnings?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build the complete handler registry the executor requires. Every member of
|
|
53
|
+
* `ClientMigrationPostprocessor` must be present — the executor throws on an
|
|
54
|
+
* unregistered operation, which is the behavior that catches a compiler that
|
|
55
|
+
* starts naming a postprocessor this CLI does not implement.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createMigrationPostprocessors(deps?: MigrationPostprocessorDeps): Record<ClientMigrationPostprocessor, MigrationPostprocessorHandler>;
|
|
58
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/migrations/postprocessors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,OAAO,KAAK,EAAiC,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAEnG,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EAML,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EACjC,MAAM,kBAAkB,CAAC;AAgB1B,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C;;;OAGG;IACH,uBAAuB,CAAC,EAAE,2BAA2B,CAAC;IACtD,kDAAkD;IAClD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAmUD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,GAAE,0BAA+B,GACpC,MAAM,CAAC,4BAA4B,EAAE,6BAA6B,CAAC,CASrE"}
|