@marinoscar/platform-db 0.0.0-stage → 0.1.0-next.10
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/CHANGELOG.md +86 -0
- package/LICENSE +21 -0
- package/README.md +525 -2
- package/bin/platform.js +28 -0
- package/dist/baseline/deps.d.ts +32 -0
- package/dist/baseline/deps.d.ts.map +1 -0
- package/dist/baseline/deps.js +66 -0
- package/dist/baseline/deps.js.map +1 -0
- package/dist/baseline/errors.d.ts +36 -0
- package/dist/baseline/errors.d.ts.map +1 -0
- package/dist/baseline/errors.js +23 -0
- package/dist/baseline/errors.js.map +1 -0
- package/dist/baseline/fs.d.ts +9 -0
- package/dist/baseline/fs.d.ts.map +1 -0
- package/dist/baseline/fs.js +39 -0
- package/dist/baseline/fs.js.map +1 -0
- package/dist/baseline/index.d.ts +8 -0
- package/dist/baseline/index.d.ts.map +1 -0
- package/dist/baseline/index.js +24 -0
- package/dist/baseline/index.js.map +1 -0
- package/dist/baseline/mapping.d.ts +43 -0
- package/dist/baseline/mapping.d.ts.map +1 -0
- package/dist/baseline/mapping.js +80 -0
- package/dist/baseline/mapping.js.map +1 -0
- package/dist/baseline/normalise.d.ts +42 -0
- package/dist/baseline/normalise.d.ts.map +1 -0
- package/dist/baseline/normalise.js +133 -0
- package/dist/baseline/normalise.js.map +1 -0
- package/dist/baseline/plan.d.ts +66 -0
- package/dist/baseline/plan.d.ts.map +1 -0
- package/dist/baseline/plan.js +105 -0
- package/dist/baseline/plan.js.map +1 -0
- package/dist/baseline/report.d.ts +127 -0
- package/dist/baseline/report.d.ts.map +1 -0
- package/dist/baseline/report.js +89 -0
- package/dist/baseline/report.js.map +1 -0
- package/dist/baseline/run.d.ts +117 -0
- package/dist/baseline/run.d.ts.map +1 -0
- package/dist/baseline/run.js +358 -0
- package/dist/baseline/run.js.map +1 -0
- package/dist/bin/db-commands.d.ts +31 -0
- package/dist/bin/db-commands.d.ts.map +1 -0
- package/dist/bin/db-commands.js +311 -0
- package/dist/bin/db-commands.js.map +1 -0
- package/dist/bin/fs-io.d.ts +7 -0
- package/dist/bin/fs-io.d.ts.map +1 -0
- package/dist/bin/fs-io.js +45 -0
- package/dist/bin/fs-io.js.map +1 -0
- package/dist/bin/platform.d.ts +21 -0
- package/dist/bin/platform.d.ts.map +1 -0
- package/dist/bin/platform.js +99 -0
- package/dist/bin/platform.js.map +1 -0
- package/dist/compose/api.d.ts +84 -0
- package/dist/compose/api.d.ts.map +1 -0
- package/dist/compose/api.js +101 -0
- package/dist/compose/api.js.map +1 -0
- package/dist/compose/compose.d.ts +51 -0
- package/dist/compose/compose.d.ts.map +1 -0
- package/dist/compose/compose.js +177 -0
- package/dist/compose/compose.js.map +1 -0
- package/dist/compose/diff.d.ts +7 -0
- package/dist/compose/diff.d.ts.map +1 -0
- package/dist/compose/diff.js +68 -0
- package/dist/compose/diff.js.map +1 -0
- package/dist/compose/errors.d.ts +31 -0
- package/dist/compose/errors.d.ts.map +1 -0
- package/dist/compose/errors.js +35 -0
- package/dist/compose/errors.js.map +1 -0
- package/dist/compose/index.d.ts +3 -0
- package/dist/compose/index.d.ts.map +1 -0
- package/dist/compose/index.js +11 -0
- package/dist/compose/index.js.map +1 -0
- package/dist/compose/parse.d.ts +65 -0
- package/dist/compose/parse.d.ts.map +1 -0
- package/dist/compose/parse.js +122 -0
- package/dist/compose/parse.js.map +1 -0
- package/dist/drift/app-objects.d.ts +107 -0
- package/dist/drift/app-objects.d.ts.map +1 -0
- package/dist/drift/app-objects.js +193 -0
- package/dist/drift/app-objects.js.map +1 -0
- package/dist/drift/db-conformance.d.ts +52 -0
- package/dist/drift/db-conformance.d.ts.map +1 -0
- package/dist/drift/db-conformance.js +89 -0
- package/dist/drift/db-conformance.js.map +1 -0
- package/dist/drift/index.d.ts +8 -0
- package/dist/drift/index.d.ts.map +1 -0
- package/dist/drift/index.js +43 -0
- package/dist/drift/index.js.map +1 -0
- package/dist/drift/raw-sql-indexes.d.ts +106 -0
- package/dist/drift/raw-sql-indexes.d.ts.map +1 -0
- package/dist/drift/raw-sql-indexes.js +113 -0
- package/dist/drift/raw-sql-indexes.js.map +1 -0
- package/dist/drift/raw-sql-tripwire.d.ts +191 -0
- package/dist/drift/raw-sql-tripwire.d.ts.map +1 -0
- package/dist/drift/raw-sql-tripwire.js +422 -0
- package/dist/drift/raw-sql-tripwire.js.map +1 -0
- package/dist/drift/rls-policies.d.ts +226 -0
- package/dist/drift/rls-policies.d.ts.map +1 -0
- package/dist/drift/rls-policies.js +317 -0
- package/dist/drift/rls-policies.js.map +1 -0
- package/dist/drift/run.d.ts +152 -0
- package/dist/drift/run.d.ts.map +1 -0
- package/dist/drift/run.js +252 -0
- package/dist/drift/run.js.map +1 -0
- package/dist/drift/sql-expression.d.ts +27 -0
- package/dist/drift/sql-expression.d.ts.map +1 -0
- package/dist/drift/sql-expression.js +64 -0
- package/dist/drift/sql-expression.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/lock/hash.d.ts +13 -0
- package/dist/lock/hash.d.ts.map +1 -0
- package/dist/lock/hash.js +19 -0
- package/dist/lock/hash.js.map +1 -0
- package/dist/lock/index.d.ts +5 -0
- package/dist/lock/index.d.ts.map +1 -0
- package/dist/lock/index.js +20 -0
- package/dist/lock/index.js.map +1 -0
- package/dist/lock/lock.d.ts +154 -0
- package/dist/lock/lock.d.ts.map +1 -0
- package/dist/lock/lock.js +151 -0
- package/dist/lock/lock.js.map +1 -0
- package/dist/lock/manifest.d.ts +68 -0
- package/dist/lock/manifest.d.ts.map +1 -0
- package/dist/lock/manifest.js +96 -0
- package/dist/lock/manifest.js.map +1 -0
- package/dist/lock/semver.d.ts +10 -0
- package/dist/lock/semver.d.ts.map +1 -0
- package/dist/lock/semver.js +13 -0
- package/dist/lock/semver.js.map +1 -0
- package/dist/seed/index.d.ts +5 -0
- package/dist/seed/index.d.ts.map +1 -0
- package/dist/seed/index.js +16 -0
- package/dist/seed/index.js.map +1 -0
- package/dist/seed/input.d.ts +52 -0
- package/dist/seed/input.d.ts.map +1 -0
- package/dist/seed/input.js +77 -0
- package/dist/seed/input.js.map +1 -0
- package/dist/seed/seed-platform.d.ts +41 -0
- package/dist/seed/seed-platform.d.ts.map +1 -0
- package/dist/seed/seed-platform.js +165 -0
- package/dist/seed/seed-platform.js.map +1 -0
- package/dist/seed/steps.d.ts +172 -0
- package/dist/seed/steps.d.ts.map +1 -0
- package/dist/seed/steps.js +136 -0
- package/dist/seed/steps.js.map +1 -0
- package/dist/seed/types.d.ts +287 -0
- package/dist/seed/types.d.ts.map +1 -0
- package/dist/seed/types.js +5 -0
- package/dist/seed/types.js.map +1 -0
- package/dist/sync/app-migrations.d.ts +52 -0
- package/dist/sync/app-migrations.d.ts.map +1 -0
- package/dist/sync/app-migrations.js +62 -0
- package/dist/sync/app-migrations.js.map +1 -0
- package/dist/sync/apply.d.ts +29 -0
- package/dist/sync/apply.d.ts.map +1 -0
- package/dist/sync/apply.js +38 -0
- package/dist/sync/apply.js.map +1 -0
- package/dist/sync/check.d.ts +59 -0
- package/dist/sync/check.d.ts.map +1 -0
- package/dist/sync/check.js +115 -0
- package/dist/sync/check.js.map +1 -0
- package/dist/sync/errors.d.ts +32 -0
- package/dist/sync/errors.d.ts.map +1 -0
- package/dist/sync/errors.js +23 -0
- package/dist/sync/errors.js.map +1 -0
- package/dist/sync/index.d.ts +10 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +27 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/ledger.d.ts +65 -0
- package/dist/sync/ledger.d.ts.map +1 -0
- package/dist/sync/ledger.js +49 -0
- package/dist/sync/ledger.js.map +1 -0
- package/dist/sync/plan.d.ts +63 -0
- package/dist/sync/plan.d.ts.map +1 -0
- package/dist/sync/plan.js +86 -0
- package/dist/sync/plan.js.map +1 -0
- package/dist/sync/promote.d.ts +62 -0
- package/dist/sync/promote.d.ts.map +1 -0
- package/dist/sync/promote.js +95 -0
- package/dist/sync/promote.js.map +1 -0
- package/dist/sync/timestamps.d.ts +41 -0
- package/dist/sync/timestamps.d.ts.map +1 -0
- package/dist/sync/timestamps.js +68 -0
- package/dist/sync/timestamps.js.map +1 -0
- package/dist/sync/version.d.ts +28 -0
- package/dist/sync/version.d.ts.map +1 -0
- package/dist/sync/version.js +66 -0
- package/dist/sync/version.js.map +1 -0
- package/migrations/0001_initial/migration.sql +297 -0
- package/migrations/0002_add_personal_access_tokens/migration.sql +31 -0
- package/migrations/0003_add_credentials/migration.sql +20 -0
- package/migrations/0004_add_notification_deliveries/migration.sql +27 -0
- package/migrations/0005_drop_stale_uuid_defaults/migration.sql +35 -0
- package/migrations/0006_add_notifications/migration.sql +22 -0
- package/migrations/0007_add_push_subscriptions/migration.sql +25 -0
- package/migrations/0008_add_jobs/migration.sql +110 -0
- package/migrations/0009_add_worker_nodes/migration.sql +90 -0
- package/migrations/0010_add_database_backup_runs/migration.sql +104 -0
- package/migrations/0011_add_notification_broadcasts/migration.sql +57 -0
- package/migrations/0012_add_backup_run_job_link/migration.sql +87 -0
- package/migrations/0013_add_job_node_secrets/migration.sql +61 -0
- package/migrations/0014_add_backup_run_pg_dump_version/migration.sql +26 -0
- package/migrations/0015_add_job_claim_token/migration.sql +92 -0
- package/migrations/0016_add_ai_platform/migration.sql +108 -0
- package/migrations/0017_revoke_viewer_ai_use/migration.sql +32 -0
- package/migrations/0018_add_user_credentials/migration.sql +29 -0
- package/migrations/0019_add_device_session_credential_link/migration.sql +52 -0
- package/migrations/0020_add_worker_node_vitals/migration.sql +3 -0
- package/migrations/0021_add_job_trace_context/migration.sql +6 -0
- package/migrations/0022_add_retention_created_at_indexes/migration.sql +13 -0
- package/migrations/0023_add_organizations/migration.sql +142 -0
- package/migrations/0024_split_system_org_roles/migration.sql +131 -0
- package/migrations/0025_org_scoped_rls/migration.sql +215 -0
- package/migrations/0026_add_groups/migration.sql +165 -0
- package/migrations/0027_add_grants/migration.sql +117 -0
- package/migrations/0028_add_org_settings/migration.sql +49 -0
- package/migrations/0029_add_org_credentials/migration.sql +54 -0
- package/migrations/0030_add_jobs_org_id/migration.sql +18 -0
- package/migrations/0031_add_jobs_org_id_status_index/migration.sql +6 -0
- package/migrations/0032_add_broadcast_target_org/migration.sql +21 -0
- package/migrations/0033_add_android_app/migration.sql +60 -0
- package/migrations/0034_open_job_reason/migration.sql +16 -0
- package/migrations/0035_ai_usage_feature/migration.sql +37 -0
- package/migrations/0036_add_app_metadata/migration.sql +49 -0
- package/migrations/0037_open_sharing_vocabularies/migration.sql +97 -0
- package/migrations/manifest.json +379 -0
- package/package.json +78 -4
- package/raw-sql-indexes.json +94 -0
- package/rls-policies.json +74 -0
- package/schema/ai.prisma +444 -0
- package/schema/android-app.prisma +47 -0
- package/schema/base.prisma +11 -0
- package/schema/credentials.prisma +170 -0
- package/schema/db-backup.prisma +376 -0
- package/schema/identity.prisma +439 -0
- package/schema/jobs.prisma +760 -0
- package/schema/notifications.prisma +649 -0
- package/schema/settings.prisma +60 -0
- package/schema/sharing.prisma +223 -0
- package/schema/storage.prisma +84 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// A deliberately small, line-oriented reader for `prisma format`-shaped schema
|
|
3
|
+
// text. It is NOT a Prisma parser (no Prisma-internal dependency: those APIs
|
|
4
|
+
// are unstable). It relies on two properties `prisma format` guarantees and
|
|
5
|
+
// that every fragment must keep; the composer rejects a file that breaks them:
|
|
6
|
+
// 1. a block header is `<kind> <Name> {` on ONE line, at column 0;
|
|
7
|
+
// 2. a block ends with `}` alone on a line, at column 0.
|
|
8
|
+
// Comments and blank lines between blocks are kept as the NEXT block's
|
|
9
|
+
// "leading" text, so a banner or a doc comment travels with its model.
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.parseBlocks = parseBlocks;
|
|
12
|
+
exports.isExtensible = isExtensible;
|
|
13
|
+
exports.parseBody = parseBody;
|
|
14
|
+
exports.renderBlock = renderBlock;
|
|
15
|
+
const errors_js_1 = require("./errors.js");
|
|
16
|
+
const KINDS = 'model|enum|type|view|generator|datasource';
|
|
17
|
+
const HEADER = new RegExp(`^(?:(extend)\\s+)?(${KINDS})\\s+([A-Za-z_]\\w*)\\s*\\{\\s*$`);
|
|
18
|
+
const LOOSE_HEADER = new RegExp(`^\\s*(?:extend\\s+)?(?:${KINDS})\\s+\\w+\\s*(?:\\{.*)?$`);
|
|
19
|
+
const FIELD = /^\s*([A-Za-z_]\w*)\s+([A-Za-z_]\w*)(?:\([^)]*\))?(?:\[\])?\??(\s.*)?$/;
|
|
20
|
+
/**
|
|
21
|
+
* Splits one fragment into top-level blocks.
|
|
22
|
+
*
|
|
23
|
+
* @param src - File contents.
|
|
24
|
+
* @param file - Path to name in errors.
|
|
25
|
+
* @returns The blocks in file order and the text after the last block.
|
|
26
|
+
* @throws {@link ComposeError} `MALFORMED` for a header or footer that is not `prisma format` shaped.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
function parseBlocks(src, file) {
|
|
30
|
+
const lines = src.replace(/\r\n/g, '\n').split('\n');
|
|
31
|
+
const blocks = [];
|
|
32
|
+
let acc = [];
|
|
33
|
+
let cur = null;
|
|
34
|
+
lines.forEach((text, i) => {
|
|
35
|
+
const lineNo = i + 1;
|
|
36
|
+
if (!cur) {
|
|
37
|
+
const m = HEADER.exec(text);
|
|
38
|
+
if (m) {
|
|
39
|
+
cur = {
|
|
40
|
+
extend: m[1] === 'extend',
|
|
41
|
+
kind: m[2],
|
|
42
|
+
name: m[3],
|
|
43
|
+
leading: acc.join('\n'),
|
|
44
|
+
lines: [text],
|
|
45
|
+
line: lineNo,
|
|
46
|
+
};
|
|
47
|
+
acc = [];
|
|
48
|
+
}
|
|
49
|
+
else if (LOOSE_HEADER.test(text)) {
|
|
50
|
+
throw new errors_js_1.ComposeError('MALFORMED', file, lineNo, `a block header must be "<kind> <Name> {" on one line at column 0 (prisma format shape), got: ${text.trim()}`);
|
|
51
|
+
}
|
|
52
|
+
else if (text.trim() === '}') {
|
|
53
|
+
throw new errors_js_1.ComposeError('MALFORMED', file, lineNo, 'a "}" with no open block');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
acc.push(text);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
cur.lines.push(text);
|
|
61
|
+
if (text === '}') {
|
|
62
|
+
blocks.push(cur);
|
|
63
|
+
cur = null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (cur) {
|
|
68
|
+
const open = cur;
|
|
69
|
+
throw new errors_js_1.ComposeError('MALFORMED', file, open.line, `block "${open.name}" is not closed by a "}" alone at column 0`);
|
|
70
|
+
}
|
|
71
|
+
return { blocks, trailing: acc.join('\n') };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Is the block marked `// @extensible` in the comment run directly above it?
|
|
75
|
+
*
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
function isExtensible(block) {
|
|
79
|
+
const above = block.leading.split('\n');
|
|
80
|
+
for (let i = above.length - 1; i >= 0; i--) {
|
|
81
|
+
const text = above[i].trim();
|
|
82
|
+
if (text === '')
|
|
83
|
+
break;
|
|
84
|
+
if (/^\/\/\s*@extensible\b/.test(text))
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The fields and block attributes of a model body.
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
function parseBody(block, file) {
|
|
95
|
+
const fields = [];
|
|
96
|
+
const attrs = [];
|
|
97
|
+
block.lines.slice(1, -1).forEach((raw, i) => {
|
|
98
|
+
const line = block.line + 1 + i;
|
|
99
|
+
const t = raw.trim();
|
|
100
|
+
if (t === '' || t.startsWith('//'))
|
|
101
|
+
return;
|
|
102
|
+
if (t.startsWith('@@')) {
|
|
103
|
+
attrs.push({ raw, line });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const m = FIELD.exec(raw);
|
|
107
|
+
if (!m) {
|
|
108
|
+
throw new errors_js_1.ComposeError('MALFORMED', file, line, `cannot read a field in ${block.name}: ${t}`);
|
|
109
|
+
}
|
|
110
|
+
fields.push({ name: m[1], type: m[2], attrs: m[3] ?? '', raw, line });
|
|
111
|
+
});
|
|
112
|
+
return { fields, attrs };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The block as text, with its leading comments.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
function renderBlock(block) {
|
|
120
|
+
return `${block.leading ? `${block.leading}\n` : ''}${block.lines.join('\n')}`;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/compose/parse.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,6EAA6E;AAC7E,4EAA4E;AAC5E,+EAA+E;AAC/E,qEAAqE;AACrE,2DAA2D;AAC3D,uEAAuE;AACvE,uEAAuE;;AAgDvE,kCAiDC;AAOD,oCAQC;AAOD,8BAkBC;AAOD,kCAEC;AAhJD,2CAA2C;AAgC3C,MAAM,KAAK,GAAG,2CAA2C,CAAC;AAC1D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,sBAAsB,KAAK,kCAAkC,CAAC,CAAC;AACzF,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,0BAA0B,KAAK,0BAA0B,CAAC,CAAC;AAC3F,MAAM,KAAK,GAAG,uEAAuE,CAAC;AAEtF;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,GAAW,EAAE,IAAY;IACnD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,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type PackageRlsPolicy } from './rls-policies.js';
|
|
4
|
+
/**
|
|
5
|
+
* The class of an app schema-object failure.
|
|
6
|
+
*
|
|
7
|
+
* - `APP_INDEX_NOT_FOUND`: `platform.lock` `rawSqlIndexes` lists an index no migration creates, or a later migration drops it.
|
|
8
|
+
* - `APP_INDEX_MISMATCH`: the listed `definition` names another table, uniqueness or key columns than the migrations leave.
|
|
9
|
+
* - `UNLISTED_APP_RAW_INDEX`: the migrations leave a partial or expression index that neither the package nor `platform.lock` lists.
|
|
10
|
+
* - `APP_POLICY_NOT_FOUND`: `platform.lock` `rlsPolicies` lists a policy no migration creates, or a later migration drops it.
|
|
11
|
+
* - `APP_POLICY_EXPRESSION_MISMATCH`: the listed `usingSha256` or `checkSha256` differs from the expression the migrations leave.
|
|
12
|
+
* - `UNLISTED_APP_POLICY`: the migrations leave a policy that neither the package nor `platform.lock` lists.
|
|
13
|
+
* - `APP_POLICY_TABLE_NOT_ENABLED` / `APP_POLICY_TABLE_NOT_FORCED`: a listed policy's table does not `ENABLE` / `FORCE ROW LEVEL SECURITY` in the migrations.
|
|
14
|
+
*
|
|
15
|
+
* @stability experimental
|
|
16
|
+
*/
|
|
17
|
+
export type AppObjectProblemCode = 'APP_INDEX_NOT_FOUND' | 'APP_INDEX_MISMATCH' | 'UNLISTED_APP_RAW_INDEX' | 'APP_POLICY_NOT_FOUND' | 'APP_POLICY_EXPRESSION_MISMATCH' | 'UNLISTED_APP_POLICY' | 'APP_POLICY_TABLE_NOT_ENABLED' | 'APP_POLICY_TABLE_NOT_FORCED';
|
|
18
|
+
/**
|
|
19
|
+
* One app schema-object failure.
|
|
20
|
+
*
|
|
21
|
+
* @stability experimental
|
|
22
|
+
*/
|
|
23
|
+
export interface AppObjectProblem {
|
|
24
|
+
/** The class of failure. */
|
|
25
|
+
code: AppObjectProblemCode;
|
|
26
|
+
/** The index or policy name. */
|
|
27
|
+
name: string;
|
|
28
|
+
/** A one-line explanation naming the migration or lock entry and the fix. */
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What {@link checkAppSchemaObjects} reads.
|
|
33
|
+
*
|
|
34
|
+
* @stability experimental
|
|
35
|
+
*/
|
|
36
|
+
export interface AppSchemaObjectsInput {
|
|
37
|
+
/** The app's `platform.lock`. */
|
|
38
|
+
lock: Pick<PlatformLock, 'rawSqlIndexes' | 'rlsPolicies'>;
|
|
39
|
+
/** Every migration of the app's history, installed or app-authored, as `[directory, sql]` in history (directory name) order. */
|
|
40
|
+
migrations: ReadonlyArray<readonly [string, string]>;
|
|
41
|
+
/** The package's raw-SQL indexes; default {@link RAW_SQL_INDEXES}. Only the names are read. */
|
|
42
|
+
packageIndexes?: ReadonlyArray<Pick<PackageRawSqlIndex, 'name'>>;
|
|
43
|
+
/** The package's policies; default {@link RLS_POLICIES}. Only the name and table are read. */
|
|
44
|
+
packagePolicies?: ReadonlyArray<Pick<PackageRlsPolicy, 'name' | 'table'>>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The offline check of the schema objects an app owns beyond the package's:
|
|
48
|
+
* the raw-SQL indexes and the row-level-security policies listed in its
|
|
49
|
+
* `platform.lock`. Prisma cannot express either, and `platform db drift`
|
|
50
|
+
* asserts them only against a live database; this reads the migration SQL.
|
|
51
|
+
*
|
|
52
|
+
* It fails when
|
|
53
|
+
*
|
|
54
|
+
* - a listed index or policy is not created by some migration, or a later migration drops it,
|
|
55
|
+
* - a listed index's `definition` states another table, uniqueness or key columns than the migrations leave,
|
|
56
|
+
* - a listed policy carries a `usingSha256` or `checkSha256` that differs from the expression the migrations leave (a weakened policy is caught without a database),
|
|
57
|
+
* - a listed policy's table does not both `ENABLE` and `FORCE ROW LEVEL SECURITY`,
|
|
58
|
+
* - the migrations leave a partial or expression index, or a policy, that neither the package's lists nor the lock lists (the lock is the app's allow-list, as `raw-sql-indexes.json` and `rls-policies.json` are the package's).
|
|
59
|
+
*
|
|
60
|
+
* The package's own entries are read, never judged: they are the package
|
|
61
|
+
* tripwires' business (`assertRawSqlIndexes`, `assertRlsPolicies`).
|
|
62
|
+
*
|
|
63
|
+
* @param input - See {@link AppSchemaObjectsInput}.
|
|
64
|
+
* @returns Every problem found, in a stable order; empty when the lock and the migrations agree.
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const problems = checkAppSchemaObjects({ lock, migrations: [['20270101000000_add_notes', sql]] });
|
|
68
|
+
* ```
|
|
69
|
+
* @stability experimental
|
|
70
|
+
*/
|
|
71
|
+
export declare function checkAppSchemaObjects(input: AppSchemaObjectsInput): AppObjectProblem[];
|
|
72
|
+
/**
|
|
73
|
+
* Reads every migration of an app's `prisma/migrations`, in directory-name
|
|
74
|
+
* order, as `[directory, sql]`. A directory without a `migration.sql` is
|
|
75
|
+
* skipped. Shared by the conformance suite and {@link assertAppSchemaObjects}.
|
|
76
|
+
*
|
|
77
|
+
* @param migrationsDir - The app's `prisma/migrations` directory; a missing directory means none.
|
|
78
|
+
* @returns The migrations in history order.
|
|
79
|
+
* @stability experimental
|
|
80
|
+
*/
|
|
81
|
+
export declare function readAppMigrations(migrationsDir: string): Array<[string, string]>;
|
|
82
|
+
/**
|
|
83
|
+
* What {@link assertAppSchemaObjects} reads from disk.
|
|
84
|
+
*
|
|
85
|
+
* @stability experimental
|
|
86
|
+
*/
|
|
87
|
+
export interface AssertAppSchemaObjectsOptions {
|
|
88
|
+
/** The app's `platform.lock`, parsed. */
|
|
89
|
+
lock: Pick<PlatformLock, 'rawSqlIndexes' | 'rlsPolicies'>;
|
|
90
|
+
/** The app's `prisma/migrations` directory. */
|
|
91
|
+
migrationsDir: string;
|
|
92
|
+
/** The package's raw-SQL indexes; default {@link RAW_SQL_INDEXES}. */
|
|
93
|
+
packageIndexes?: ReadonlyArray<Pick<PackageRawSqlIndex, 'name'>>;
|
|
94
|
+
/** The package's policies; default {@link RLS_POLICIES}. */
|
|
95
|
+
packagePolicies?: ReadonlyArray<Pick<PackageRlsPolicy, 'name' | 'table'>>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Runs {@link checkAppSchemaObjects} against the migrations on disk and
|
|
99
|
+
* throws, listing every problem, when the lock and the migrations disagree.
|
|
100
|
+
* This is the entry the conformance suite and an app's CI call.
|
|
101
|
+
*
|
|
102
|
+
* @param options - See {@link AssertAppSchemaObjectsOptions}.
|
|
103
|
+
* @throws Error naming each problem.
|
|
104
|
+
* @stability experimental
|
|
105
|
+
*/
|
|
106
|
+
export declare function assertAppSchemaObjects(options: AssertAppSchemaObjectsOptions): void;
|
|
107
|
+
//# sourceMappingURL=app-objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-objects.d.ts","sourceRoot":"","sources":["../../src/drift/app-objects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EAAiC,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGzF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAC5B,qBAAqB,GACrB,oBAAoB,GACpB,wBAAwB,GACxB,sBAAsB,GACtB,gCAAgC,GAChC,qBAAqB,GACrB,8BAA8B,GAC9B,6BAA6B,CAAC;AAElC;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4BAA4B;IAC5B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,iCAAiC;IACjC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,GAAG,aAAa,CAAC,CAAC;IAC1D,gIAAgI;IAChI,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,+FAA+F;IAC/F,cAAc,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC;IACjE,8FAA8F;IAC9F,eAAe,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAC3E;AAeD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,EAAE,CAqGtF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAUhF;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,yCAAyC;IACzC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,GAAG,aAAa,CAAC,CAAC;IAC1D,+CAA+C;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,cAAc,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC;IACjE,4DAA4D;IAC5D,eAAe,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAC3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAUnF"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAppSchemaObjects = checkAppSchemaObjects;
|
|
4
|
+
exports.readAppMigrations = readAppMigrations;
|
|
5
|
+
exports.assertAppSchemaObjects = assertAppSchemaObjects;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const raw_sql_indexes_js_1 = require("./raw-sql-indexes.js");
|
|
9
|
+
const raw_sql_tripwire_js_1 = require("./raw-sql-tripwire.js");
|
|
10
|
+
const rls_policies_js_1 = require("./rls-policies.js");
|
|
11
|
+
const sql_expression_js_1 = require("./sql-expression.js");
|
|
12
|
+
const DEFINITION = /^CREATE\s+(UNIQUE\s+)?INDEX\s+("[^"]+"|[\w$]+)\s+ON\s+(?:ONLY\s+)?((?:"[^"]+"|[\w$]+)(?:\.(?:"[^"]+"|[\w$]+))?)\s+USING\b/i;
|
|
13
|
+
const strip = (ident) => (ident.startsWith('"') ? ident.slice(1, -1) : ident.toLowerCase());
|
|
14
|
+
/** The uniqueness, table and key columns a `pg_indexes.indexdef` string states. */
|
|
15
|
+
function readDefinition(definition) {
|
|
16
|
+
const match = DEFINITION.exec(definition.trim());
|
|
17
|
+
if (!match)
|
|
18
|
+
return undefined;
|
|
19
|
+
const parts = match[3].match(/"[^"]+"|[\w$]+/g) ?? [match[3]];
|
|
20
|
+
return { unique: Boolean(match[1]), table: strip(parts[parts.length - 1]), columns: (0, raw_sql_tripwire_js_1.columnsOfDefinition)(definition) };
|
|
21
|
+
}
|
|
22
|
+
const sameColumns = (a, b) => a.length === b.length && a.every((c, i) => c === b[i]);
|
|
23
|
+
/**
|
|
24
|
+
* The offline check of the schema objects an app owns beyond the package's:
|
|
25
|
+
* the raw-SQL indexes and the row-level-security policies listed in its
|
|
26
|
+
* `platform.lock`. Prisma cannot express either, and `platform db drift`
|
|
27
|
+
* asserts them only against a live database; this reads the migration SQL.
|
|
28
|
+
*
|
|
29
|
+
* It fails when
|
|
30
|
+
*
|
|
31
|
+
* - a listed index or policy is not created by some migration, or a later migration drops it,
|
|
32
|
+
* - a listed index's `definition` states another table, uniqueness or key columns than the migrations leave,
|
|
33
|
+
* - a listed policy carries a `usingSha256` or `checkSha256` that differs from the expression the migrations leave (a weakened policy is caught without a database),
|
|
34
|
+
* - a listed policy's table does not both `ENABLE` and `FORCE ROW LEVEL SECURITY`,
|
|
35
|
+
* - the migrations leave a partial or expression index, or a policy, that neither the package's lists nor the lock lists (the lock is the app's allow-list, as `raw-sql-indexes.json` and `rls-policies.json` are the package's).
|
|
36
|
+
*
|
|
37
|
+
* The package's own entries are read, never judged: they are the package
|
|
38
|
+
* tripwires' business (`assertRawSqlIndexes`, `assertRlsPolicies`).
|
|
39
|
+
*
|
|
40
|
+
* @param input - See {@link AppSchemaObjectsInput}.
|
|
41
|
+
* @returns Every problem found, in a stable order; empty when the lock and the migrations agree.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const problems = checkAppSchemaObjects({ lock, migrations: [['20270101000000_add_notes', sql]] });
|
|
45
|
+
* ```
|
|
46
|
+
* @stability experimental
|
|
47
|
+
*/
|
|
48
|
+
function checkAppSchemaObjects(input) {
|
|
49
|
+
const problems = [];
|
|
50
|
+
const indexes = (0, raw_sql_tripwire_js_1.scanAllIndexes)(input.migrations);
|
|
51
|
+
const byName = new Map(indexes.map((index) => [index.name, index]));
|
|
52
|
+
const packageIndexNames = new Set((input.packageIndexes ?? raw_sql_indexes_js_1.RAW_SQL_INDEXES).map((index) => index.name));
|
|
53
|
+
const listedIndexes = input.lock.rawSqlIndexes ?? [];
|
|
54
|
+
const listedIndexNames = new Set(listedIndexes.map((index) => index.name));
|
|
55
|
+
for (const listed of listedIndexes) {
|
|
56
|
+
if (packageIndexNames.has(listed.name))
|
|
57
|
+
continue;
|
|
58
|
+
const actual = byName.get(listed.name);
|
|
59
|
+
if (!actual) {
|
|
60
|
+
problems.push({
|
|
61
|
+
code: 'APP_INDEX_NOT_FOUND',
|
|
62
|
+
name: listed.name,
|
|
63
|
+
message: `${listed.name}: platform.lock rawSqlIndexes lists it but no migration leaves an index of that name (not created, or dropped by a later migration)`,
|
|
64
|
+
});
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const stated = readDefinition(listed.definition);
|
|
68
|
+
if (!stated) {
|
|
69
|
+
problems.push({
|
|
70
|
+
code: 'APP_INDEX_MISMATCH',
|
|
71
|
+
name: listed.name,
|
|
72
|
+
message: `${listed.name}: the lock's definition is not a "CREATE [UNIQUE] INDEX ... ON table USING method (...)" statement as pg_indexes.indexdef prints it`,
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const differences = [];
|
|
77
|
+
if (stated.table !== actual.table)
|
|
78
|
+
differences.push(`table ${actual.table} (lock ${stated.table})`);
|
|
79
|
+
if (stated.unique !== actual.unique)
|
|
80
|
+
differences.push(`unique=${actual.unique} (lock ${stated.unique})`);
|
|
81
|
+
if (stated.columns && actual.columns && !sameColumns(stated.columns, actual.columns)) {
|
|
82
|
+
differences.push(`key (${actual.columns.join(', ')}) (lock (${stated.columns.join(', ')}))`);
|
|
83
|
+
}
|
|
84
|
+
if (differences.length) {
|
|
85
|
+
problems.push({ code: 'APP_INDEX_MISMATCH', name: listed.name, message: `${listed.name}: ${actual.createdIn} says ${differences.join(', ')}` });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const index of indexes) {
|
|
89
|
+
if (index.raw && !packageIndexNames.has(index.name) && !listedIndexNames.has(index.name)) {
|
|
90
|
+
problems.push({
|
|
91
|
+
code: 'UNLISTED_APP_RAW_INDEX',
|
|
92
|
+
name: index.name,
|
|
93
|
+
message: `${index.name}: ${index.createdIn} creates a partial or expression index on ${index.table} that platform.lock rawSqlIndexes does not list; add { name, definition } (the definition is pg_indexes.indexdef, printed by \`platform db drift\` when it is wrong)`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const scanned = (0, rls_policies_js_1.scanRlsPolicies)(input.migrations);
|
|
98
|
+
const key = (policy) => `${policy.table}\u0000${policy.name}`;
|
|
99
|
+
const byKey = new Map(scanned.policies.map((policy) => [key(policy), policy]));
|
|
100
|
+
const packageKeys = new Set((input.packagePolicies ?? rls_policies_js_1.RLS_POLICIES).map(key));
|
|
101
|
+
const listedPolicies = input.lock.rlsPolicies ?? [];
|
|
102
|
+
const listedKeys = new Set(listedPolicies.map(key));
|
|
103
|
+
for (const listed of listedPolicies) {
|
|
104
|
+
if (packageKeys.has(key(listed)))
|
|
105
|
+
continue;
|
|
106
|
+
const actual = byKey.get(key(listed));
|
|
107
|
+
if (!actual) {
|
|
108
|
+
problems.push({
|
|
109
|
+
code: 'APP_POLICY_NOT_FOUND',
|
|
110
|
+
name: listed.name,
|
|
111
|
+
message: `${listed.name}: platform.lock rlsPolicies lists it on ${listed.table} but no migration leaves a policy of that name there (not created, or dropped by a later migration)`,
|
|
112
|
+
});
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const [label, want, got] of [
|
|
116
|
+
['USING', listed.usingSha256, actual.using],
|
|
117
|
+
['WITH CHECK', listed.checkSha256, actual.check],
|
|
118
|
+
]) {
|
|
119
|
+
if (want === undefined)
|
|
120
|
+
continue;
|
|
121
|
+
const actualHash = got === undefined ? undefined : (0, sql_expression_js_1.sqlExpressionSha256)(got);
|
|
122
|
+
if (actualHash !== want) {
|
|
123
|
+
problems.push({
|
|
124
|
+
code: 'APP_POLICY_EXPRESSION_MISMATCH',
|
|
125
|
+
name: listed.name,
|
|
126
|
+
message: `${listed.name}: the lock records ${label} ${want.slice(0, 12)} but the migrations leave ${actualHash ? actualHash.slice(0, 12) : `no ${label} expression`}; a policy changed after it was locked (\`platform db policies\` prints the current hashes)`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (!scanned.enabled.includes(listed.table)) {
|
|
131
|
+
problems.push({ code: 'APP_POLICY_TABLE_NOT_ENABLED', name: listed.name, message: `${listed.name}: no migration leaves ${listed.table} with ENABLE ROW LEVEL SECURITY` });
|
|
132
|
+
}
|
|
133
|
+
if (!scanned.forced.includes(listed.table)) {
|
|
134
|
+
problems.push({
|
|
135
|
+
code: 'APP_POLICY_TABLE_NOT_FORCED',
|
|
136
|
+
name: listed.name,
|
|
137
|
+
message: `${listed.name}: no migration leaves ${listed.table} with FORCE ROW LEVEL SECURITY, so the application role would bypass the policy`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
for (const policy of scanned.policies) {
|
|
142
|
+
if (!packageKeys.has(key(policy)) && !listedKeys.has(key(policy))) {
|
|
143
|
+
problems.push({
|
|
144
|
+
code: 'UNLISTED_APP_POLICY',
|
|
145
|
+
name: policy.name,
|
|
146
|
+
message: `${policy.name}: ${policy.createdIn} creates a policy on ${policy.table} that platform.lock rlsPolicies does not list; add { name, table } (and usingSha256/checkSha256 from \`platform db policies\`)`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return problems;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Reads every migration of an app's `prisma/migrations`, in directory-name
|
|
154
|
+
* order, as `[directory, sql]`. A directory without a `migration.sql` is
|
|
155
|
+
* skipped. Shared by the conformance suite and {@link assertAppSchemaObjects}.
|
|
156
|
+
*
|
|
157
|
+
* @param migrationsDir - The app's `prisma/migrations` directory; a missing directory means none.
|
|
158
|
+
* @returns The migrations in history order.
|
|
159
|
+
* @stability experimental
|
|
160
|
+
*/
|
|
161
|
+
function readAppMigrations(migrationsDir) {
|
|
162
|
+
if (!(0, node_fs_1.existsSync)(migrationsDir))
|
|
163
|
+
return [];
|
|
164
|
+
return (0, node_fs_1.readdirSync)(migrationsDir, { withFileTypes: true })
|
|
165
|
+
.filter((entry) => entry.isDirectory())
|
|
166
|
+
.map((entry) => entry.name)
|
|
167
|
+
.sort()
|
|
168
|
+
.flatMap((dir) => {
|
|
169
|
+
const file = (0, node_path_1.join)(migrationsDir, dir, 'migration.sql');
|
|
170
|
+
return (0, node_fs_1.existsSync)(file) ? [[dir, (0, node_fs_1.readFileSync)(file, 'utf8')]] : [];
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Runs {@link checkAppSchemaObjects} against the migrations on disk and
|
|
175
|
+
* throws, listing every problem, when the lock and the migrations disagree.
|
|
176
|
+
* This is the entry the conformance suite and an app's CI call.
|
|
177
|
+
*
|
|
178
|
+
* @param options - See {@link AssertAppSchemaObjectsOptions}.
|
|
179
|
+
* @throws Error naming each problem.
|
|
180
|
+
* @stability experimental
|
|
181
|
+
*/
|
|
182
|
+
function assertAppSchemaObjects(options) {
|
|
183
|
+
const problems = checkAppSchemaObjects({
|
|
184
|
+
lock: options.lock,
|
|
185
|
+
migrations: readAppMigrations(options.migrationsDir),
|
|
186
|
+
...(options.packageIndexes ? { packageIndexes: options.packageIndexes } : {}),
|
|
187
|
+
...(options.packagePolicies ? { packagePolicies: options.packagePolicies } : {}),
|
|
188
|
+
});
|
|
189
|
+
if (problems.length > 0) {
|
|
190
|
+
throw new Error(`the app schema-object check failed (${problems.length}):\n${problems.map((p) => ` ${p.code} ${p.message}`).join('\n')}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=app-objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-objects.js","sourceRoot":"","sources":["../../src/drift/app-objects.ts"],"names":[],"mappings":";;AAmGA,sDAqGC;AAWD,8CAUC;AA2BD,wDAUC;AAlQD,qCAAgE;AAChE,yCAAiC;AAEjC,6DAAgF;AAChF,+DAA4E;AAC5E,uDAAyF;AACzF,2DAA0D;AAuD1D,MAAM,UAAU,GAAG,4HAA4H,CAAC;AAChJ,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AAE5G,mFAAmF;AACnF,SAAS,cAAc,CAAC,UAAkB;IACxC,MAAM,KAAK,GAAG,UAA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;QAClB,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,aAAa,CAAC;QACpD,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7E,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjF,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,CAAC,MAAM,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9I,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The slice of a test runner {@link runDbConformance} needs; Jest and Vitest
|
|
3
|
+
* (`globals: true`) both fit, and neither is imported here.
|
|
4
|
+
*
|
|
5
|
+
* @stability experimental
|
|
6
|
+
*/
|
|
7
|
+
export interface DbConformanceTestApi {
|
|
8
|
+
/** Registers a group of tests. */
|
|
9
|
+
describe(name: string, fn: () => void): void;
|
|
10
|
+
/** Registers one test; a thrown error fails it. */
|
|
11
|
+
it(name: string, fn: () => void): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* What an app passes to {@link runDbConformance}.
|
|
15
|
+
*
|
|
16
|
+
* @stability experimental
|
|
17
|
+
*/
|
|
18
|
+
export interface DbConformanceOptions {
|
|
19
|
+
/** The app directory that holds `prisma/` (`prisma/platform.lock`, `prisma/migrations`). */
|
|
20
|
+
appRoot: string;
|
|
21
|
+
/** The `@marinoscar/platform-db` package directory; default: the one this code runs from. */
|
|
22
|
+
packageDir?: string;
|
|
23
|
+
/** Defaults to the globals `describe` and `it` (Jest, or Vitest with `globals: true`). */
|
|
24
|
+
testApi?: DbConformanceTestApi;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Registers the `db` conformance suite: the invariants of the platform's data
|
|
28
|
+
* layer that an app proves in its own CI, offline (no database needed).
|
|
29
|
+
*
|
|
30
|
+
* - **raw-SQL index tripwire**: every partial or expression index the package's migrations create is listed in `RAW_SQL_INDEXES`, every listed one exists, and no schema fragment tries to "fix" one with `@@unique`/`@@index` (see {@link assertRawSqlIndexes}).
|
|
31
|
+
* - **rls-policies tripwire**: every row-level-security policy the package's migrations leave behind is listed in `RLS_POLICIES`, every listed one is created, and its table both enables and forces row-level security (see {@link assertRlsPolicies}).
|
|
32
|
+
* - **platform.lock**: the app's installed migrations are byte-identical to the package's, every package migration is installed, and nothing is edited (see {@link checkLock}).
|
|
33
|
+
* - **app-schema-objects**: every raw-SQL index and row-level-security policy the app lists in `platform.lock` (`rawSqlIndexes`, `rlsPolicies`) is created by some migration of its history and dropped by none, a listed policy's optional expression hashes match the migration SQL, and no unlisted partial or expression index or policy exists (see {@link assertAppSchemaObjects}). Offline: `platform db drift` makes the same assertions against a live database.
|
|
34
|
+
* - **app-migrations**: no app-authored migration directory is named like a package migration or would reorder the installed platform history (see {@link checkAppMigrations}).
|
|
35
|
+
*
|
|
36
|
+
* Call it at the top level of a spec file. It is the data-layer counterpart of
|
|
37
|
+
* `runPlatformConformance()` in `@marinoscar/platform-api/testing`, which scans
|
|
38
|
+
* TypeScript source roots and so cannot run a check over SQL and Prisma files.
|
|
39
|
+
*
|
|
40
|
+
* @param options - See {@link DbConformanceOptions}.
|
|
41
|
+
* @throws Error when no test API is available.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* // apps/api/test/prisma/platform-db-conformance.spec.ts
|
|
46
|
+
* runDbConformance({ appRoot: join(__dirname, '..', '..') });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @stability experimental
|
|
50
|
+
*/
|
|
51
|
+
export declare function runDbConformance(options: DbConformanceOptions): void;
|
|
52
|
+
//# sourceMappingURL=db-conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-conformance.d.ts","sourceRoot":"","sources":["../../src/drift/db-conformance.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC7C,mDAAmD;IACnD,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAUD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAkDpE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runDbConformance = runDbConformance;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const index_js_1 = require("../lock/index.js");
|
|
7
|
+
const index_js_2 = require("../sync/index.js");
|
|
8
|
+
const app_objects_js_1 = require("./app-objects.js");
|
|
9
|
+
const raw_sql_tripwire_js_1 = require("./raw-sql-tripwire.js");
|
|
10
|
+
const rls_policies_js_1 = require("./rls-policies.js");
|
|
11
|
+
function globalTestApi() {
|
|
12
|
+
const g = globalThis;
|
|
13
|
+
if (typeof g.describe !== 'function' || typeof g.it !== 'function') {
|
|
14
|
+
throw new Error('runDbConformance: no global describe/it. Run it under Jest, under Vitest with `globals: true`, or pass `testApi`.');
|
|
15
|
+
}
|
|
16
|
+
return { describe: g.describe, it: g.it };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Registers the `db` conformance suite: the invariants of the platform's data
|
|
20
|
+
* layer that an app proves in its own CI, offline (no database needed).
|
|
21
|
+
*
|
|
22
|
+
* - **raw-SQL index tripwire**: every partial or expression index the package's migrations create is listed in `RAW_SQL_INDEXES`, every listed one exists, and no schema fragment tries to "fix" one with `@@unique`/`@@index` (see {@link assertRawSqlIndexes}).
|
|
23
|
+
* - **rls-policies tripwire**: every row-level-security policy the package's migrations leave behind is listed in `RLS_POLICIES`, every listed one is created, and its table both enables and forces row-level security (see {@link assertRlsPolicies}).
|
|
24
|
+
* - **platform.lock**: the app's installed migrations are byte-identical to the package's, every package migration is installed, and nothing is edited (see {@link checkLock}).
|
|
25
|
+
* - **app-schema-objects**: every raw-SQL index and row-level-security policy the app lists in `platform.lock` (`rawSqlIndexes`, `rlsPolicies`) is created by some migration of its history and dropped by none, a listed policy's optional expression hashes match the migration SQL, and no unlisted partial or expression index or policy exists (see {@link assertAppSchemaObjects}). Offline: `platform db drift` makes the same assertions against a live database.
|
|
26
|
+
* - **app-migrations**: no app-authored migration directory is named like a package migration or would reorder the installed platform history (see {@link checkAppMigrations}).
|
|
27
|
+
*
|
|
28
|
+
* Call it at the top level of a spec file. It is the data-layer counterpart of
|
|
29
|
+
* `runPlatformConformance()` in `@marinoscar/platform-api/testing`, which scans
|
|
30
|
+
* TypeScript source roots and so cannot run a check over SQL and Prisma files.
|
|
31
|
+
*
|
|
32
|
+
* @param options - See {@link DbConformanceOptions}.
|
|
33
|
+
* @throws Error when no test API is available.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // apps/api/test/prisma/platform-db-conformance.spec.ts
|
|
38
|
+
* runDbConformance({ appRoot: join(__dirname, '..', '..') });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @stability experimental
|
|
42
|
+
*/
|
|
43
|
+
function runDbConformance(options) {
|
|
44
|
+
const api = options.testApi ?? globalTestApi();
|
|
45
|
+
const appRoot = (0, node_path_1.resolve)(options.appRoot);
|
|
46
|
+
// `src/drift` and `dist/drift` are both two levels below the package root.
|
|
47
|
+
const packageDir = (0, node_path_1.resolve)(options.packageDir ?? (0, node_path_1.join)(__dirname, '..', '..'));
|
|
48
|
+
const migrationsDir = (0, node_path_1.join)(packageDir, 'migrations');
|
|
49
|
+
const manifest = () => {
|
|
50
|
+
const file = (0, node_path_1.join)(migrationsDir, 'manifest.json');
|
|
51
|
+
return (0, index_js_1.parseManifest)((0, node_fs_1.readFileSync)(file, 'utf8'), file);
|
|
52
|
+
};
|
|
53
|
+
api.describe('platform-db conformance', () => {
|
|
54
|
+
api.it('raw-sql-indexes: every raw-SQL index is listed, present in the migrations, and not redeclared in a fragment', () => {
|
|
55
|
+
(0, raw_sql_tripwire_js_1.assertRawSqlIndexes)({ manifest: manifest(), migrationsDir, fragmentsDir: (0, node_path_1.join)(packageDir, 'schema') });
|
|
56
|
+
});
|
|
57
|
+
api.it('rls-policies: every policy the migrations leave is listed in RLS_POLICIES, and each listed table enables and forces row-level security', () => {
|
|
58
|
+
(0, rls_policies_js_1.assertRlsPolicies)({ manifest: manifest(), migrationsDir });
|
|
59
|
+
});
|
|
60
|
+
api.it('platform.lock: installed migrations are byte-identical to the package, none missing or edited', () => {
|
|
61
|
+
const lockFile = (0, node_path_1.join)(appRoot, 'prisma', 'platform.lock');
|
|
62
|
+
if (!(0, node_fs_1.existsSync)(lockFile))
|
|
63
|
+
throw new Error(`${lockFile} does not exist; run \`platform db sync\``);
|
|
64
|
+
const lock = (0, index_js_1.parseLock)((0, node_fs_1.readFileSync)(lockFile, 'utf8'), lockFile);
|
|
65
|
+
const read = (file) => ((0, node_fs_1.existsSync)(file) ? (0, node_fs_1.readFileSync)(file) : undefined);
|
|
66
|
+
const installed = (0, node_path_1.join)(appRoot, 'prisma', 'migrations');
|
|
67
|
+
const result = (0, index_js_2.checkLock)(manifest(), lock, (dir) => read((0, node_path_1.join)(installed, dir, 'migration.sql')), (dir) => read((0, node_path_1.join)(migrationsDir, dir, 'migration.sql')));
|
|
68
|
+
if (!result.ok)
|
|
69
|
+
throw new Error(`platform.lock check failed:\n${result.problems.map((p) => ` ${p.code} ${p.message}`).join('\n')}`);
|
|
70
|
+
});
|
|
71
|
+
api.it('app-schema-objects: every raw-SQL index and RLS policy the app lists in platform.lock is created by a migration, and none is unlisted', () => {
|
|
72
|
+
const lockFile = (0, node_path_1.join)(appRoot, 'prisma', 'platform.lock');
|
|
73
|
+
if (!(0, node_fs_1.existsSync)(lockFile))
|
|
74
|
+
throw new Error(`${lockFile} does not exist; run \`platform db sync\``);
|
|
75
|
+
(0, app_objects_js_1.assertAppSchemaObjects)({ lock: (0, index_js_1.parseLock)((0, node_fs_1.readFileSync)(lockFile, 'utf8'), lockFile), migrationsDir: (0, node_path_1.join)(appRoot, 'prisma', 'migrations') });
|
|
76
|
+
});
|
|
77
|
+
api.it('app-migrations: no app migration collides with or reorders the installed platform history', () => {
|
|
78
|
+
const lockFile = (0, node_path_1.join)(appRoot, 'prisma', 'platform.lock');
|
|
79
|
+
if (!(0, node_fs_1.existsSync)(lockFile))
|
|
80
|
+
throw new Error(`${lockFile} does not exist; run \`platform db sync\``);
|
|
81
|
+
const installed = (0, node_path_1.join)(appRoot, 'prisma', 'migrations');
|
|
82
|
+
const dirs = (0, node_fs_1.existsSync)(installed) ? (0, node_fs_1.readdirSync)(installed, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name) : [];
|
|
83
|
+
const problems = (0, index_js_2.checkAppMigrations)(manifest(), (0, index_js_1.parseLock)((0, node_fs_1.readFileSync)(lockFile, 'utf8'), lockFile), dirs);
|
|
84
|
+
if (problems.length > 0)
|
|
85
|
+
throw new Error(`app migrations collide with the platform history:\n${problems.map((p) => ` ${p.code} ${p.message}`).join('\n')}`);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=db-conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-conformance.js","sourceRoot":"","sources":["../../src/drift/db-conformance.ts"],"names":[],"mappings":";;AAoEA,4CAkDC;AAtHD,qCAAgE;AAChE,yCAA0C;AAC1C,+CAA4D;AAC5D,+CAAiE;AACjE,qDAA0D;AAC1D,+DAA4D;AAC5D,uDAAsD;AA6BtD,SAAS,aAAa;IACpB,MAAM,CAAC,GAAG,UAAsD,CAAC;IACjE,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,UAAU,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,mHAAmH,CAAC,CAAC;IACvI,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,gBAAgB,CAAC,OAA6B;IAC5D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,IAAI,aAAa,EAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAA,mBAAO,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,2EAA2E;IAC3E,MAAM,UAAU,GAAG,IAAA,mBAAO,EAAC,OAAO,CAAC,UAAU,IAAI,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9E,MAAM,aAAa,GAAG,IAAA,gBAAI,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACrD,MAAM,Q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exProblem, type RawIndexProblemCode, } from './raw-sql-indexes.js';
|
|
2
|
+
export { loadPg, prismaCli, readIndexRows, readLedgerRows, readPolicyRows, readTableRlsRows, runDrift, schemaDiff, stripBanner, withShadowDatabase, type DriftOptions, type DriftResult, type PgClient, } from './run.js';
|
|
3
|
+
export { assertAppSchemaObjects, checkAppSchemaObjects, readAppMigrations, type AppObjectProblem, type AppObjectProblemCode, type AppSchemaObjectsInput, type AssertAppSchemaObjectsOptions, } from './app-objects.js';
|
|
4
|
+
export { normaliseSqlExpression, sqlExpressionSha256 } from './sql-expression.js';
|
|
5
|
+
export { assertRawSqlIndexes, scanAllIndexes, checkRawSqlIndexSources, scanFragmentIndexes, scanRawSqlIndexes, type AssertRawSqlIndexesOptions, type FragmentIndex, type ScannedAnyIndex, type ScannedIndex, type TripwireInput, type TripwireProblem, type TripwireProblemCode, } from './raw-sql-tripwire.js';
|
|
6
|
+
export { runDbConformance, type DbConformanceOptions, type DbConformanceTestApi, } from './db-conformance.js';
|
|
7
|
+
export { RLS_POLICIES, assertRlsPolicies, checkRlsPolicies, checkRlsPolicySources, readPackageRlsPolicies, scanRlsPolicies, type AssertRlsPoliciesOptions, type PackageRlsPolicy, type PolicyRow, type RlsPolicyRef, type RlsProblem, type RlsProblemCode, type RlsTripwireCode, type RlsTripwireInput, type RlsTripwireProblem, type ScannedPolicy, type ScannedRls, type TableRlsRow, } from './rls-policies.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drift/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,MAAM,EACN,SAAS,EACT,a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