okmodel 0.9.0 → 0.9.1
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/README.md +9 -1
- package/dist/adapters/pg/bunsql-extra.d.ts +5 -5
- package/dist/adapters/pg/bunsql.d.ts +6 -2
- package/dist/adapters/pg/nodepostgres.d.ts +16 -1
- package/dist/adapters/pg/postgres-extra.d.ts +3 -17
- package/dist/adapters/pg/postgresjs.d.ts +2 -1
- package/dist/contracts/driver.d.ts +3 -2
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/errors.d.ts +2 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.js +1 -1
- package/dist/dialects/pg/ext/hstore.js +1 -1
- package/dist/dialects/pg/ext/ltree.js +1 -1
- package/dist/dialects/pg/ext/pgcrypto.js +1 -1
- package/dist/dialects/pg/ext/unaccent.js +1 -1
- package/dist/dialects/pg/filters.d.ts +2 -2
- package/dist/dialects/pg/fn/index.js +1 -1
- package/dist/dialects/pg/index.js +3 -3
- package/dist/dialects/pg/introspect.d.ts +12 -0
- package/dist/dialects/pg/view/index.js +2 -2
- package/dist/runtime/param-limit.d.ts +20 -0
- package/dist/runtime/pg/bun.js +3 -3
- package/dist/runtime/pg/neon.js +3 -3
- package/dist/runtime/pg/pg.js +3 -3
- package/dist/runtime/pg/pglite.js +2 -2
- package/dist/runtime/pg/postgresjs.js +10 -10
- package/dist/runtime/tenancy/index.js +1 -1
- package/dist/runtime/traits/index.js +2 -2
- package/dist/runtime/validate/index.js +2 -2
- package/dist/runtime/write.d.ts +1 -1
- package/dist/shared/{5kyb3tqx.js → 1h5h1rf5.js} +1 -1
- package/dist/shared/{4vbf83xx.js → 2vcnpf0n.js} +1 -1
- package/dist/shared/{8n688yjg.js → 3ap5hxvj.js} +2 -1
- package/dist/shared/{wvtjg5m3.js → 3d7a80fq.js} +1 -1
- package/dist/shared/{bphrgwz9.js → 3dr444ny.js} +57 -78
- package/dist/shared/{yvabyg9k.js → 3vvpcphd.js} +7 -6
- package/dist/shared/{760ppr76.js → 4a3mmhhe.js} +2 -2
- package/dist/shared/{90sg0w5a.js → 4pkz5nvw.js} +65 -10
- package/dist/shared/{mazpbcdj.js → 4te76xc5.js} +1 -1
- package/dist/shared/{xwhdcrm4.js → 60y4ahmw.js} +1 -1
- package/dist/shared/{9dtgn1z2.js → 63qjmhnp.js} +100 -17
- package/dist/shared/{s7he5e5d.js → 67w3kn71.js} +1 -1
- package/dist/shared/{n306gqkd.js → 6vfvsdkt.js} +9 -7
- package/dist/shared/{jpybhf98.js → 6xqvesa5.js} +1 -1
- package/dist/shared/{n5whk3mt.js → 8gdbty5v.js} +8 -8
- package/dist/shared/{ccsmhv9r.js → 8ma6drzr.js} +194 -31
- package/dist/shared/{3456242y.js → 8p2bgye0.js} +110 -18
- package/dist/shared/{ebhz8vh6.js → 8qwqrxed.js} +11 -3
- package/dist/shared/{ss2kv2rs.js → 8v7vzpgt.js} +10 -7
- package/dist/shared/{8qzkd9f3.js → ak61ye1f.js} +3 -3
- package/dist/shared/{6nae0spm.js → bdekbvmt.js} +69 -7
- package/dist/shared/{tw1nvvfj.js → bxjq6xqv.js} +2 -2
- package/dist/shared/{rbxt795q.js → c7dqd3gk.js} +81 -41
- package/dist/shared/ddh72ym5.js +20 -0
- package/dist/shared/e1c55v04.js +10 -0
- package/dist/shared/{8jesqsrk.js → ekhq3ytz.js} +1 -1
- package/dist/shared/{7ba5h6pb.js → esy4dyxe.js} +5 -5
- package/dist/shared/{gcefca6p.js → f9t9g54z.js} +22 -9
- package/dist/shared/fkjne6gx.js +8 -0
- package/dist/shared/{ds229x4r.js → fne90dvz.js} +4 -1
- package/dist/shared/{cexb7z6b.js → gr9sn4za.js} +1 -1
- package/dist/shared/{mvmm3xpb.js → gzgfsspx.js} +1 -1
- package/dist/shared/{fdsz3w80.js → hgt69zjf.js} +2 -2
- package/dist/shared/{dd5pmnky.js → jvxcp1qk.js} +70 -86
- package/dist/shared/{yybhre6n.js → k73e8n9d.js} +3 -3
- package/dist/shared/{mgaq2sd3.js → kzgrcy8s.js} +8 -7
- package/dist/shared/{myk8fswx.js → mz48rs74.js} +14 -3
- package/dist/shared/{62b603gr.js → n6je5b28.js} +10 -23
- package/dist/shared/{2szgv6yj.js → ns35jqz0.js} +71 -45
- package/dist/shared/{xtsydxjg.js → nstwgzn8.js} +1 -1
- package/dist/shared/{stfa9xcw.js → py2zrrm6.js} +7 -6
- package/dist/shared/{9dr2qnx7.js → qqm3ze6q.js} +1 -1
- package/dist/shared/{cf8zdz5p.js → rcjm0yn7.js} +27 -34
- package/dist/shared/{ckz05z15.js → rged92v6.js} +7 -4
- package/dist/shared/{qvwwp1mp.js → rw4tpcd0.js} +30 -21
- package/dist/shared/{bsek72fg.js → s5qe47a6.js} +3 -0
- package/dist/shared/{1d9q9cv2.js → smxzjz60.js} +2 -2
- package/dist/shared/{c3mvnq7a.js → th5rnaxw.js} +1 -1
- package/dist/shared/{1mxm04fy.js → tyqapcgk.js} +71 -8
- package/dist/shared/{zdqf8k5d.js → vsna85qf.js} +1 -1
- package/dist/shared/{63qtkrca.js → vy47ryqa.js} +55 -5
- package/dist/shared/{xv8qj97g.js → wbdh9qbg.js} +3 -1
- package/dist/shared/{2zdxkt7b.js → wp7y8q3y.js} +41 -9
- package/dist/shared/{pg4ezgyf.js → xbd9xs6p.js} +2 -2
- package/dist/shared/{npdftanb.js → xbvz446k.js} +16 -13
- package/dist/shared/{aksb89mn.js → y6tfjk9q.js} +2 -2
- package/dist/shared/{3bb7wsqt.js → ycnft340.js} +1 -1
- package/dist/shared/{z7s6fpxv.js → ymenf259.js} +1 -1
- package/dist/shared/{71n0jmhc.js → ysdw2fg3.js} +10 -2
- package/dist/shared/{xqacq37x.js → zecrwdk9.js} +1 -1
- package/dist/shared/{3t6kw83m.js → zm2rzqba.js} +2 -1
- package/dist/tooling/cli.js +122 -44
- package/dist/tooling/driver-run.js +107 -24
- package/dist/tooling/github/comment.d.ts +8 -2
- package/dist/tooling/migrate/apply.d.ts +17 -2
- package/dist/tooling/migrate/drift.d.ts +12 -0
- package/dist/tooling/migrate/driver-url.d.ts +17 -0
- package/dist/tooling/migrate/index.js +9 -7
- package/dist/tooling/migrate/policy.d.ts +17 -5
- package/dist/tooling/migrate/pooler-probe.d.ts +23 -0
- package/dist/tooling/migrate/pull.d.ts +3 -0
- package/dist/tooling/migrate/runner.d.ts +24 -1
- package/dist/tooling/shared/{0j0jtse1.js → 09a6vsys.js} +1 -1
- package/dist/tooling/shared/{68tf18v4.js → 0v9ptnxp.js} +8 -8
- package/dist/tooling/shared/{qartgazh.js → 0wtzps9p.js} +6 -6
- package/dist/tooling/shared/{1800eymw.js → 0yhf1db4.js} +6 -6
- package/dist/tooling/shared/{s6qha57m.js → 19msgrsc.js} +2 -2
- package/dist/tooling/shared/{3yn79q5m.js → 1fwfm5m3.js} +1 -1
- package/dist/tooling/shared/{hfq3n3bd.js → 2jdn09e2.js} +55 -5
- package/dist/tooling/shared/{v6j1ep6w.js → 2qrte2ct.js} +5 -5
- package/dist/tooling/shared/{yb4kd19s.js → 2v4nwnkb.js} +1 -1
- package/dist/tooling/shared/{ezqn88nj.js → 33z39trp.js} +106 -23
- package/dist/tooling/shared/{0r05zhyq.js → 353vnw9z.js} +5 -5
- package/dist/tooling/shared/{m4hhb8aa.js → 390kry9g.js} +2 -2
- package/dist/tooling/shared/{rcywj2w8.js → 3f6etb9z.js} +18 -31
- package/dist/tooling/shared/{9wsnsvbf.js → 3t2cqmsx.js} +1 -1
- package/dist/tooling/shared/{5zrzffnk.js → 4dzvjtpy.js} +1 -1
- package/dist/tooling/shared/{am04v8na.js → 4ec0nxvw.js} +10 -10
- package/dist/tooling/shared/{04svnxxj.js → 4tg2bn41.js} +59 -78
- package/dist/tooling/shared/{829fjxyw.js → 5rah55z0.js} +2 -2
- package/dist/tooling/shared/{c0xevn1h.js → 804w1t69.js} +4 -4
- package/dist/tooling/shared/{dhatassp.js → 8g0m0rvd.js} +6 -6
- package/dist/tooling/shared/{zx3v9phv.js → 8msbtw5s.js} +1 -1
- package/dist/tooling/shared/{7pxncnzs.js → 8t22h3h7.js} +2 -2
- package/dist/tooling/shared/{wbwq1jsa.js → 91c59b7b.js} +2 -2
- package/dist/tooling/shared/{a2xe04bm.js → adk9k6va.js} +1 -1
- package/dist/tooling/shared/{w17sj05d.js → ajjd5cwz.js} +2 -2
- package/dist/tooling/shared/{35zemrmf.js → angjck01.js} +1 -1
- package/dist/tooling/shared/{jsjjz875.js → asnnc3v5.js} +1 -1
- package/dist/tooling/shared/{5bmksndh.js → bj1kyqc8.js} +2 -2
- package/dist/tooling/shared/{kbqnrs1x.js → bt3tjemb.js} +11 -3
- package/dist/tooling/shared/{vwr2y833.js → chk2bh4f.js} +2 -2
- package/dist/tooling/shared/{ybdew6j7.js → ckq4z5ax.js} +5 -2
- package/dist/tooling/shared/{3rmaz3pq.js → d3rhb24q.js} +1 -1
- package/dist/tooling/shared/{mw5npye0.js → d8q00vxg.js} +4 -4
- package/dist/tooling/shared/{j664qjrt.js → dx188rxs.js} +2 -2
- package/dist/tooling/shared/{8yr7ges1.js → efq6p9df.js} +35 -42
- package/dist/tooling/shared/{yhp829bx.js → en6rwzq0.js} +3 -3
- package/dist/tooling/shared/{f77nnfqy.js → f2r5g0fs.js} +2 -2
- package/dist/tooling/shared/{zs9aymcp.js → f4gep0nk.js} +1 -1
- package/dist/tooling/shared/{kz715295.js → f8a010fm.js} +13 -11
- package/dist/tooling/shared/{w5d89rb4.js → fdsek6pa.js} +1 -1
- package/dist/tooling/shared/fvmrxsd1.js +8 -0
- package/dist/tooling/shared/{jpgmjsx3.js → g3xybeqf.js} +4 -3
- package/dist/tooling/shared/{wezxf3h8.js → gefmpwsa.js} +1 -1
- package/dist/tooling/shared/{jr2nmr81.js → gjj71hfh.js} +23 -20
- package/dist/tooling/shared/{9sfbtwsk.js → jgzt69pa.js} +5 -5
- package/dist/tooling/shared/{a4pzghha.js → jm30k2ca.js} +10 -8
- package/dist/tooling/shared/{shjs0379.js → kayqzpbk.js} +6 -3
- package/dist/tooling/shared/{tcwpjvxe.js → kvw1672d.js} +1 -1
- package/dist/tooling/shared/{stebqyyd.js → mr1kcgpw.js} +3 -3
- package/dist/tooling/shared/{tpssp7ac.js → mwbdf409.js} +1 -1
- package/dist/tooling/shared/{fh07z1dt.js → ns9207v3.js} +1 -1
- package/dist/tooling/shared/{5p8km5jb.js → p6tjv97k.js} +3 -3
- package/dist/tooling/shared/{ytk1tjs0.js → p73evwf0.js} +1 -1
- package/dist/tooling/shared/{8m5znpdt.js → phc1nc4g.js} +1 -1
- package/dist/tooling/shared/{asgr07mp.js → ppybjw50.js} +79 -16
- package/dist/tooling/shared/{t4xveemq.js → qdrn8ghn.js} +5 -4
- package/dist/tooling/shared/rd8h01ta.js +20 -0
- package/dist/tooling/shared/{7aews1zg.js → rwg8y90m.js} +3 -3
- package/dist/tooling/shared/{5x3pf400.js → ry2f3w8p.js} +3 -3
- package/dist/tooling/shared/{m3xt8b1h.js → ryc5sa58.js} +8 -8
- package/dist/tooling/shared/{57btdkgm.js → ss87qxwv.js} +2 -2
- package/dist/tooling/shared/{6vk28rjp.js → vg68k11z.js} +3 -3
- package/dist/tooling/shared/{62fxpc1p.js → vms9dta5.js} +73 -89
- package/dist/tooling/shared/{gqwevek4.js → xchpnbdv.js} +1 -1
- package/dist/tooling/shared/{t6zjeake.js → xn6p01fh.js} +5 -5
- package/dist/tooling/shared/{7b3xp9gc.js → xwr6q618.js} +3 -3
- package/dist/tooling/shared/{yfedr1zb.js → xx3gmq94.js} +1 -1
- package/dist/tooling/shared/{9qr9rkbh.js → y2bd7yfx.js} +21 -13
- package/dist/tooling/shared/{nxq95eb6.js → y4gq9rbe.js} +11 -11
- package/dist/tooling/shared/{76pv6qff.js → y4vwft92.js} +2 -2
- package/dist/tooling/shared/{sjwkt1pg.js → yz68xcmc.js} +1 -1
- package/dist/tooling/testing/factories.d.ts +1 -3
- package/dist/tooling/testing/index.js +1 -1
- package/package.json +2 -1
|
@@ -13,18 +13,19 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
cellText,
|
|
15
15
|
introspectSchema
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./mz48rs74.js";
|
|
17
17
|
import {
|
|
18
18
|
projectPath,
|
|
19
19
|
loadConfig
|
|
20
|
-
} from "./
|
|
20
|
+
} from "./wp7y8q3y.js";
|
|
21
21
|
import {
|
|
22
|
+
driverUrl,
|
|
22
23
|
sqlIdentifiers,
|
|
23
24
|
sessionFailure,
|
|
24
25
|
finishQuiet,
|
|
25
26
|
assertTargetPolicy,
|
|
26
27
|
selectTarget
|
|
27
|
-
} from "./
|
|
28
|
+
} from "./bdekbvmt.js";
|
|
28
29
|
import {
|
|
29
30
|
dependencyOrder,
|
|
30
31
|
catalog,
|
|
@@ -41,7 +42,7 @@ import {
|
|
|
41
42
|
// src/tooling/migrate/pull.ts
|
|
42
43
|
import { spawnSync } from "node:child_process";
|
|
43
44
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
44
|
-
import { dirname as dirname2, join } from "node:path";
|
|
45
|
+
import { delimiter, dirname as dirname2, join } from "node:path";
|
|
45
46
|
import postgres from "postgres";
|
|
46
47
|
|
|
47
48
|
// src/tooling/migrate/pull-emit.ts
|
|
@@ -545,20 +546,29 @@ function emitPull(source, layout, review) {
|
|
|
545
546
|
const files = [];
|
|
546
547
|
const imports = [];
|
|
547
548
|
const usedFiles = new Set;
|
|
549
|
+
const usedExports = new Set;
|
|
548
550
|
const identitySequences = new Set;
|
|
549
551
|
const tableExports = new Map;
|
|
552
|
+
for (const table of tables) {
|
|
553
|
+
if (table.definition.partition !== undefined)
|
|
554
|
+
continue;
|
|
555
|
+
const exportName = freshIdent(declaredIdent(table.provenance.source, table.identity.name), usedExports);
|
|
556
|
+
tableExports.set(table.identity.name, exportName);
|
|
557
|
+
}
|
|
550
558
|
for (const table of tables) {
|
|
551
559
|
if (table.definition.partition !== undefined) {
|
|
552
560
|
skipped.push(skip2(table, "table", table.identity.name, "table() has no partition option", statementFor(statements, table.identity.name)));
|
|
553
561
|
skipChildren(table.identity.name, byParent, statements, skipped);
|
|
554
562
|
continue;
|
|
555
563
|
}
|
|
556
|
-
const
|
|
564
|
+
const exportName = tableExports.get(table.identity.name);
|
|
565
|
+
if (exportName === undefined)
|
|
566
|
+
continue;
|
|
567
|
+
const planned = planTable(table, byParent, enums, domains, statements, skipped, exportName, tableExports);
|
|
557
568
|
if (planned === undefined)
|
|
558
569
|
continue;
|
|
559
570
|
if (planned.identitySequence !== undefined)
|
|
560
571
|
identitySequences.add(planned.identitySequence);
|
|
561
|
-
tableExports.set(table.identity.name, planned.exportName);
|
|
562
572
|
const fileName = uniqueFile(planned.exportName, usedFiles);
|
|
563
573
|
const path = `${layout.tablesDir}/${fileName}.ts`;
|
|
564
574
|
files.push({ path, text: planned.text });
|
|
@@ -666,7 +676,7 @@ function formatPullReport(counts, skipped, verdicts = [], unexpressed = [], verb
|
|
|
666
676
|
`)}
|
|
667
677
|
`;
|
|
668
678
|
}
|
|
669
|
-
function planTable(table, byParent, enums, domains, statements, skipped) {
|
|
679
|
+
function planTable(table, byParent, enums, domains, statements, skipped, exportName, tableExports) {
|
|
670
680
|
const bag = byParent.get(table.identity.name) ?? {
|
|
671
681
|
columns: [],
|
|
672
682
|
constraints: [],
|
|
@@ -684,8 +694,8 @@ function planTable(table, byParent, enums, domains, statements, skipped) {
|
|
|
684
694
|
const field = freshIdent(declaredIdent(column.provenance.source, column.identity.name), names);
|
|
685
695
|
fields.set(column.identity.name, field);
|
|
686
696
|
if (column === identityColumn) {
|
|
687
|
-
const renamed =
|
|
688
|
-
columnLines.push(` ${field}: t.identity()${renamed},`);
|
|
697
|
+
const renamed = field !== column.identity.name ? `.sqlName(${JSON.stringify(column.identity.name)})` : "";
|
|
698
|
+
columnLines.push(` ${jsKey(field)}: t.identity()${renamed},`);
|
|
689
699
|
emitted.add(column.identity.name);
|
|
690
700
|
continue;
|
|
691
701
|
}
|
|
@@ -694,11 +704,10 @@ function planTable(table, byParent, enums, domains, statements, skipped) {
|
|
|
694
704
|
skipped.push(skip2(column, "column", `${table.identity.name}.${column.identity.name}`, columnReason(column), ""));
|
|
695
705
|
continue;
|
|
696
706
|
}
|
|
697
|
-
columnLines.push(` ${field}: ${built},`);
|
|
707
|
+
columnLines.push(` ${jsKey(field)}: ${built},`);
|
|
698
708
|
emitted.add(column.identity.name);
|
|
699
709
|
}
|
|
700
710
|
const options = [];
|
|
701
|
-
const exportName = table.provenance.source === undefined ? exportNameOf(table.identity.name) : freshIdent(declaredIdent(table.provenance.source, table.identity.name), new Set);
|
|
702
711
|
if (exportName !== table.identity.name) {
|
|
703
712
|
options.push(` sqlName: ${JSON.stringify(table.identity.name)},`);
|
|
704
713
|
}
|
|
@@ -751,7 +760,7 @@ function planTable(table, byParent, enums, domains, statements, skipped) {
|
|
|
751
760
|
}
|
|
752
761
|
if (field === undefined)
|
|
753
762
|
continue;
|
|
754
|
-
foreign.set(field, referenceCall(references));
|
|
763
|
+
foreign.set(field, referenceCall(references, tableExports));
|
|
755
764
|
continue;
|
|
756
765
|
}
|
|
757
766
|
skipped.push(skip2(constraint, "constraint", label, "table() cannot store this constraint", statementFor(statements, constraint.identity.name)));
|
|
@@ -976,17 +985,18 @@ function columnReason(column) {
|
|
|
976
985
|
}
|
|
977
986
|
function rewriteForeign(lines, foreign) {
|
|
978
987
|
return lines.map((line) => {
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
return
|
|
986
|
-
|
|
988
|
+
for (const [field, call] of foreign) {
|
|
989
|
+
const key = jsKey(field);
|
|
990
|
+
const prefix = ` ${key}: `;
|
|
991
|
+
if (!line.startsWith(prefix) || !line.endsWith(","))
|
|
992
|
+
continue;
|
|
993
|
+
const body = line.slice(prefix.length, -1);
|
|
994
|
+
return `${prefix}${body}${call},`;
|
|
995
|
+
}
|
|
996
|
+
return line;
|
|
987
997
|
});
|
|
988
998
|
}
|
|
989
|
-
function referenceCall(references) {
|
|
999
|
+
function referenceCall(references, tableExports) {
|
|
990
1000
|
const options = [];
|
|
991
1001
|
if (references.columns.length > 0) {
|
|
992
1002
|
options.push(`columns: [${references.columns.map((name) => JSON.stringify(name)).join(", ")}]`);
|
|
@@ -996,7 +1006,8 @@ function referenceCall(references) {
|
|
|
996
1006
|
if (references.onUpdate !== undefined)
|
|
997
1007
|
options.push(`onUpdate: ${JSON.stringify(references.onUpdate)}`);
|
|
998
1008
|
const optionText = options.length === 0 ? "" : `, { ${options.join(", ")} }`;
|
|
999
|
-
|
|
1009
|
+
const parent = tableExports.get(references.parent.name) ?? exportNameOf(references.parent.name);
|
|
1010
|
+
return `.references(${JSON.stringify(parent)}${optionText})`;
|
|
1000
1011
|
}
|
|
1001
1012
|
function indexCall(index, fields) {
|
|
1002
1013
|
const columns = index.definition.columns.map((name) => `columns.${fields.get(name) ?? name}`).join(", ");
|
|
@@ -1222,29 +1233,55 @@ function objectName(object) {
|
|
|
1222
1233
|
return object.identity.name;
|
|
1223
1234
|
return "";
|
|
1224
1235
|
}
|
|
1236
|
+
var WINDOWS_RESERVED = new Set([
|
|
1237
|
+
"con",
|
|
1238
|
+
"prn",
|
|
1239
|
+
"aux",
|
|
1240
|
+
"nul",
|
|
1241
|
+
"com1",
|
|
1242
|
+
"com2",
|
|
1243
|
+
"com3",
|
|
1244
|
+
"com4",
|
|
1245
|
+
"com5",
|
|
1246
|
+
"com6",
|
|
1247
|
+
"com7",
|
|
1248
|
+
"com8",
|
|
1249
|
+
"com9",
|
|
1250
|
+
"lpt1",
|
|
1251
|
+
"lpt2",
|
|
1252
|
+
"lpt3",
|
|
1253
|
+
"lpt4",
|
|
1254
|
+
"lpt5",
|
|
1255
|
+
"lpt6",
|
|
1256
|
+
"lpt7",
|
|
1257
|
+
"lpt8",
|
|
1258
|
+
"lpt9"
|
|
1259
|
+
]);
|
|
1225
1260
|
function uniqueFile(name, used) {
|
|
1226
|
-
|
|
1261
|
+
const base = reservedFileStem(name);
|
|
1262
|
+
let file = base;
|
|
1227
1263
|
let salt = 2;
|
|
1228
|
-
while (used.has(file)) {
|
|
1229
|
-
file = `${
|
|
1264
|
+
while (used.has(file.toLowerCase())) {
|
|
1265
|
+
file = `${base}_${String(salt)}`;
|
|
1230
1266
|
salt += 1;
|
|
1231
1267
|
}
|
|
1232
|
-
used.add(file);
|
|
1268
|
+
used.add(file.toLowerCase());
|
|
1233
1269
|
return file;
|
|
1234
1270
|
}
|
|
1271
|
+
function reservedFileStem(name) {
|
|
1272
|
+
return WINDOWS_RESERVED.has(name.toLowerCase()) ? `_${name}` : name;
|
|
1273
|
+
}
|
|
1235
1274
|
function tableExportNames(source) {
|
|
1236
1275
|
const names = new Map;
|
|
1276
|
+
const used = new Set;
|
|
1237
1277
|
for (const object of source.objects) {
|
|
1238
1278
|
if (object.kind !== "table" || object.definition.partition !== undefined)
|
|
1239
1279
|
continue;
|
|
1240
|
-
names.set(object.identity.name,
|
|
1280
|
+
names.set(object.identity.name, freshIdent(declaredIdent(object.provenance.source, object.identity.name), used));
|
|
1241
1281
|
}
|
|
1242
1282
|
return names;
|
|
1243
1283
|
}
|
|
1244
1284
|
function exportNameOf(name) {
|
|
1245
|
-
const sqlName = jsIdent(name);
|
|
1246
|
-
if (sqlName === name)
|
|
1247
|
-
return name;
|
|
1248
1285
|
return freshIdent(name, new Set);
|
|
1249
1286
|
}
|
|
1250
1287
|
function declaredIdent(source, fallback) {
|
|
@@ -1268,12 +1305,13 @@ function freshIdent(sql, used) {
|
|
|
1268
1305
|
let name = jsIdent(sql);
|
|
1269
1306
|
if (name === "table" || name === "columns")
|
|
1270
1307
|
name = `${name}Name`;
|
|
1308
|
+
const base = name;
|
|
1271
1309
|
let salt = 2;
|
|
1272
|
-
while (used.has(name)) {
|
|
1273
|
-
name = `${
|
|
1310
|
+
while (used.has(name.toLowerCase())) {
|
|
1311
|
+
name = `${base}_${String(salt)}`;
|
|
1274
1312
|
salt += 1;
|
|
1275
1313
|
}
|
|
1276
|
-
used.add(name);
|
|
1314
|
+
used.add(name.toLowerCase());
|
|
1277
1315
|
return name;
|
|
1278
1316
|
}
|
|
1279
1317
|
function jsIdent(sql) {
|
|
@@ -1292,6 +1330,8 @@ function jsIdent(sql) {
|
|
|
1292
1330
|
return out;
|
|
1293
1331
|
}
|
|
1294
1332
|
function jsKey(name) {
|
|
1333
|
+
if (name === "__proto__")
|
|
1334
|
+
return '["__proto__"]';
|
|
1295
1335
|
if (/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) && !RESERVED.has(name))
|
|
1296
1336
|
return name;
|
|
1297
1337
|
return JSON.stringify(name);
|
|
@@ -1524,7 +1564,7 @@ async function pullProject2(cwd, argv) {
|
|
|
1524
1564
|
const target = selectTarget(config, flags.target);
|
|
1525
1565
|
assertTargetPolicy(target, "pull", flags.allowProtected);
|
|
1526
1566
|
const layout = layoutOf(cwd, config.schema, config.tables, flags.out);
|
|
1527
|
-
const sql = postgres(target.url, {
|
|
1567
|
+
const sql = postgres(driverUrl(target.url), {
|
|
1528
1568
|
max: 1,
|
|
1529
1569
|
connect_timeout: 5,
|
|
1530
1570
|
idle_timeout: 1,
|
|
@@ -1722,16 +1762,16 @@ function formatFiles(files) {
|
|
|
1722
1762
|
if (files.length === 0)
|
|
1723
1763
|
return;
|
|
1724
1764
|
const root = formatterRoot(dirname2(files[0] ?? "."));
|
|
1725
|
-
const
|
|
1726
|
-
const result = spawnSync(
|
|
1765
|
+
const pathEnv = [join(root, "node_modules", ".bin"), process.env.PATH ?? ""].join(delimiter);
|
|
1766
|
+
const result = spawnSync("oxfmt", ["--write", ...files], {
|
|
1727
1767
|
cwd: root,
|
|
1728
|
-
encoding: "utf8"
|
|
1768
|
+
encoding: "utf8",
|
|
1769
|
+
env: { ...process.env, PATH: pathEnv }
|
|
1729
1770
|
});
|
|
1730
1771
|
if (result.error !== undefined || result.status !== 0) {
|
|
1731
|
-
const detail = result.stderr || result.stdout || "oxfmt failed";
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
});
|
|
1772
|
+
const detail = (result.stderr || result.stdout || result.error?.message || "oxfmt failed").trim();
|
|
1773
|
+
process.stderr.write(`notice: oxfmt missing or failed; wrote unformatted files. ${detail}
|
|
1774
|
+
`);
|
|
1735
1775
|
}
|
|
1736
1776
|
}
|
|
1737
1777
|
function formatterRoot(start) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OkmError2
|
|
3
|
+
} from "./52szzakm.js";
|
|
4
|
+
|
|
5
|
+
// src/runtime/param-limit.ts
|
|
6
|
+
var PG_PARAM_LIMIT = 65535;
|
|
7
|
+
function refuseParamLimit2(count) {
|
|
8
|
+
throw new OkmError2("OKM1126", `${String(count)} parameters (max ${String(PG_PARAM_LIMIT)}).`, {
|
|
9
|
+
kind: "invalid",
|
|
10
|
+
retryable: false,
|
|
11
|
+
fix: { summary: "Chunk the work, or use = any(array)." }
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function assertParamCount2(count) {
|
|
15
|
+
if (count <= PG_PARAM_LIMIT)
|
|
16
|
+
return;
|
|
17
|
+
refuseParamLimit2(count);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { refuseParamLimit2, assertParamCount2 };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertStableBackend
|
|
3
|
+
} from "./bdekbvmt.js";
|
|
4
|
+
|
|
5
|
+
// src/tooling/migrate/pooler-probe.ts
|
|
6
|
+
async function probeStableBackend(_url, readPid, allowPooler, options) {
|
|
7
|
+
await assertStableBackend(readPid, allowPooler, options);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { probeStableBackend };
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
pullProject2,
|
|
3
3
|
pullLayout2,
|
|
4
4
|
commitPullFiles2
|
|
5
|
-
} from "./
|
|
6
|
-
import"./
|
|
7
|
-
import"./
|
|
8
|
-
import"./
|
|
5
|
+
} from "./c7dqd3gk.js";
|
|
6
|
+
import"./mz48rs74.js";
|
|
7
|
+
import"./wp7y8q3y.js";
|
|
8
|
+
import"./bdekbvmt.js";
|
|
9
9
|
import"./n442h54c.js";
|
|
10
10
|
import"./fk9vef30.js";
|
|
11
11
|
import"./12z7aznj.js";
|
|
12
|
-
import"./
|
|
12
|
+
import"./jvxcp1qk.js";
|
|
13
13
|
export {
|
|
14
14
|
commitPullFiles2 as commitPullFiles,
|
|
15
15
|
pullLayout2 as pullLayout,
|
|
@@ -12,19 +12,19 @@ import {
|
|
|
12
12
|
} from "./52szzakm.js";
|
|
13
13
|
|
|
14
14
|
// src/dialects/pg/filters.ts
|
|
15
|
-
function openFilters(table, relations, spec,
|
|
15
|
+
function openFilters(table, relations, spec, isHidden) {
|
|
16
16
|
const allow = spec.allow ?? {};
|
|
17
17
|
const sort = spec.sort ?? [];
|
|
18
18
|
for (const field of Object.keys(allow))
|
|
19
|
-
deny(
|
|
19
|
+
deny(isHidden, table, field);
|
|
20
20
|
for (const field of sort)
|
|
21
|
-
deny(
|
|
21
|
+
deny(isHidden, table, field);
|
|
22
22
|
const nested = spec.relations;
|
|
23
23
|
if (nested !== undefined) {
|
|
24
24
|
for (const name of Object.keys(nested)) {
|
|
25
25
|
const target = relationTable(relations, name);
|
|
26
26
|
for (const field of nested[name] ?? [])
|
|
27
|
-
deny(
|
|
27
|
+
deny(isHidden, target, field);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
@@ -33,8 +33,8 @@ function openFilters(table, relations, spec, hiddenFields) {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function deny(
|
|
37
|
-
if (!
|
|
36
|
+
function deny(isHidden, table, field) {
|
|
37
|
+
if (!isHidden(table, field))
|
|
38
38
|
return;
|
|
39
39
|
throw new OkmError2("OKM1123", `Field ${table}.${field} is hidden.`, {
|
|
40
40
|
fix: {
|
|
@@ -87,7 +87,8 @@ function table2(name, columns, options) {
|
|
|
87
87
|
name,
|
|
88
88
|
columns,
|
|
89
89
|
filters(spec) {
|
|
90
|
-
|
|
90
|
+
const ownHidden = hiddenColumnFields(columns);
|
|
91
|
+
return openFilters(name, options?.relations, spec, (tableName, field) => tableName === name ? ownHidden.has(field) : hiddenFields.has(`${tableName}.${field}`));
|
|
91
92
|
},
|
|
92
93
|
...options !== undefined ? { options } : {},
|
|
93
94
|
...source !== undefined ? { source } : {}
|
|
@@ -190,11 +191,23 @@ function sqlValue(value) {
|
|
|
190
191
|
definition("sql accepts a column, a string, a number, a boolean, or null.");
|
|
191
192
|
}
|
|
192
193
|
var hiddenFields = new Set;
|
|
193
|
-
function
|
|
194
|
+
function hiddenColumnFields(columns) {
|
|
195
|
+
const fields = new Set;
|
|
194
196
|
for (const field of Object.keys(columns)) {
|
|
195
197
|
const column = columns[field];
|
|
196
198
|
if (column?.state?.hidden === true)
|
|
197
|
-
|
|
199
|
+
fields.add(field);
|
|
200
|
+
}
|
|
201
|
+
return fields;
|
|
202
|
+
}
|
|
203
|
+
function remember(name, columns) {
|
|
204
|
+
const prefix = `${name}.`;
|
|
205
|
+
for (const key of hiddenFields) {
|
|
206
|
+
if (key.startsWith(prefix))
|
|
207
|
+
hiddenFields.delete(key);
|
|
208
|
+
}
|
|
209
|
+
for (const field of hiddenColumnFields(columns)) {
|
|
210
|
+
hiddenFields.add(`${name}.${field}`);
|
|
198
211
|
}
|
|
199
212
|
}
|
|
200
213
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
withHttp,
|
|
9
9
|
settleCall
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./xbvz446k.js";
|
|
11
11
|
import {
|
|
12
12
|
rejectKeys,
|
|
13
13
|
isRecord,
|
|
@@ -47,6 +47,9 @@ async function batch(session, ops, options, replica) {
|
|
|
47
47
|
if (item.checked === "parent") {
|
|
48
48
|
throw new OkmError2("OKM1705", "batch does not take an update that sets a path column. The parent is checked in the statement, and a batch cannot report that after it commits. Use update({ where, set }) inside tx().", { fix: { summary: "Use update({ where, set }) inside tx()." } });
|
|
49
49
|
}
|
|
50
|
+
if (item.checked === "tree") {
|
|
51
|
+
fail2("OKM1121", "batch does not take an update that sets a tree parent. The cycle is checked in the statement, and a batch cannot report that after it commits. Use update({ where, set }) inside tx().");
|
|
52
|
+
}
|
|
50
53
|
if (item.checked !== undefined) {
|
|
51
54
|
fail2("OKM1121", item.checked === "restore" ? "batch does not take restore: it is refused while its parent is archived, and a batch cannot report that after it commits. Use tx()." : "batch does not take a write with expect: the count is checked after the statement ran, and a batch cannot report that after it commits. Use tx().");
|
|
52
55
|
}
|