@vibeorm/generator 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/emit-dts.d.ts.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -18
- package/dist/index.js.map +6 -5
- package/dist/module-schema.d.ts +3 -0
- package/dist/module-schema.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/emit-dts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-dts.d.ts","sourceRoot":"","sources":["../src/emit-dts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAyC,MAAM,iBAAiB,CAAC;AAGpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAgD,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"emit-dts.d.ts","sourceRoot":"","sources":["../src/emit-dts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAyC,MAAM,iBAAiB,CAAC;AAGpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAgD,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAkXjG;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,MAAM,CAejE;AA00DD,2DAA2D;AAC3D,wBAAgB,OAAO,CAAC,MAAM,EAAE;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC7C,GAAG,MAAM,CAoGT"}
|
package/dist/generate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAyB,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAM7H,mCAAmC;AACnC,MAAM,MAAM,cAAc,GAAG;IAC3B,qEAAqE;IACrE,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAOF;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC3C,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,iFAAiF;IACjF,UAAU,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACtC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,cAAc,CAAC,CA8B1B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* typed surface in an index.d.ts written as text (decision D3) — the consumer's
|
|
7
7
|
* tsserver never re-infers ORM internals (constitution rules 1–2).
|
|
8
8
|
*/
|
|
9
|
+
export { prepareDatabaseModuleSchema } from "./module-schema.ts";
|
|
9
10
|
export { generateClient } from "./generate.ts";
|
|
10
11
|
export type { GenerateResult } from "./generate.ts";
|
|
11
12
|
export { bakeExtensions } from "./extension-bake.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/generator/src/module-schema.ts
|
|
3
|
+
import { prepareDatabaseModuleSchema } from "@vibeorm/schema";
|
|
2
4
|
// packages/generator/src/emit-module.ts
|
|
3
5
|
import { createHash } from "crypto";
|
|
4
6
|
import { VibeError as VibeError2, providerToDialect } from "@vibeorm/schema";
|
|
@@ -638,6 +640,8 @@ export type RelationStrategy = "query" | "join";
|
|
|
638
640
|
* query still applies its own where/scoped/policy/RLS filters.
|
|
639
641
|
*/
|
|
640
642
|
export type KeysetToken = string;
|
|
643
|
+
/** A bounded page; the continuation is null when no lookahead row exists. */
|
|
644
|
+
export type KeysetPage<T> = { readonly items: T[]; readonly nextCursor: KeysetToken | null };
|
|
641
645
|
|
|
642
646
|
/** Per-query keyset options. */
|
|
643
647
|
export type KeysetOptions = {
|
|
@@ -935,7 +939,13 @@ function checkedCreateLines(params) {
|
|
|
935
939
|
function uncheckedCreateLines(params) {
|
|
936
940
|
const { model, omitRelation } = params;
|
|
937
941
|
const omitted = new Set(omitRelation === undefined ? [] : model.relations.find((relation) => relation.name === omitRelation)?.fkFields ?? []);
|
|
938
|
-
return
|
|
942
|
+
return [
|
|
943
|
+
...model.fields.filter((field) => !omitted.has(field.name)).map((field) => createFieldProp({ field })),
|
|
944
|
+
...model.relations.map((relation) => {
|
|
945
|
+
const value = params.scalarOnly !== true && relation.fkFields.length === 0 && relation.name !== omitRelation ? nestedRefName({ relation, verb: "Create" }) : "never";
|
|
946
|
+
return ` readonly ${propKey({ name: relation.name })}?: ${value};`;
|
|
947
|
+
})
|
|
948
|
+
];
|
|
939
949
|
}
|
|
940
950
|
function checkedUpdateLines(params) {
|
|
941
951
|
const { model, omitRelation } = params;
|
|
@@ -955,7 +965,13 @@ function checkedUpdateLines(params) {
|
|
|
955
965
|
function uncheckedUpdateLines(params) {
|
|
956
966
|
const { model, omitRelation } = params;
|
|
957
967
|
const omitted = new Set(omitRelation === undefined ? [] : model.relations.find((relation) => relation.name === omitRelation)?.fkFields ?? []);
|
|
958
|
-
return
|
|
968
|
+
return [
|
|
969
|
+
...model.fields.filter((field) => !omitted.has(field.name)).map((field) => updateFieldProp({ field })),
|
|
970
|
+
...model.relations.map((relation) => {
|
|
971
|
+
const value = params.scalarOnly !== true && relation.fkFields.length === 0 && relation.name !== omitRelation ? nestedRefName({ relation, verb: "Update" }) : "never";
|
|
972
|
+
return ` readonly ${propKey({ name: relation.name })}?: ${value};`;
|
|
973
|
+
})
|
|
974
|
+
];
|
|
959
975
|
}
|
|
960
976
|
function register(params) {
|
|
961
977
|
const { registry, name, text } = params;
|
|
@@ -1032,7 +1048,7 @@ function registerNestedContext(params) {
|
|
|
1032
1048
|
lines: [` readonly where: ${t}WhereUniqueInput;`, ` readonly create: ${createUnion};`]
|
|
1033
1049
|
})
|
|
1034
1050
|
});
|
|
1035
|
-
const createManyData = inverse === null ? `readonly ${t}CreateManyInput[]` : `readonly ${
|
|
1051
|
+
const createManyData = inverse === null ? `readonly ${t}CreateManyInput[]` : `readonly { ${uncheckedCreateLines({ model: target, omitRelation: inverse, scalarOnly: true }).map((line) => skippableMembers({ block: line }).trim()).join(" ")} }[]`;
|
|
1036
1052
|
if (many) {
|
|
1037
1053
|
register({
|
|
1038
1054
|
registry,
|
|
@@ -1265,10 +1281,10 @@ ${model.relations.map((relation) => ` ${propKey({ name: relation.name })}: ${re
|
|
|
1265
1281
|
}));
|
|
1266
1282
|
parts.push(inputAlias({ name: `${n}CreateInput`, lines: checkedCreateLines({ model }) }));
|
|
1267
1283
|
parts.push(inputAlias({ name: `${n}UncheckedCreateInput`, lines: uncheckedCreateLines({ model }) }));
|
|
1268
|
-
parts.push(
|
|
1284
|
+
parts.push(inputAlias({ name: `${n}CreateManyInput`, lines: uncheckedCreateLines({ model, scalarOnly: true }) }));
|
|
1269
1285
|
parts.push(inputAlias({ name: `${n}UpdateInput`, lines: checkedUpdateLines({ model }) }));
|
|
1270
1286
|
parts.push(inputAlias({ name: `${n}UncheckedUpdateInput`, lines: uncheckedUpdateLines({ model }) }));
|
|
1271
|
-
parts.push(
|
|
1287
|
+
parts.push(inputAlias({ name: `${n}UpdateManyInput`, lines: uncheckedUpdateLines({ model, scalarOnly: true }) }));
|
|
1272
1288
|
const numericFields = model.fields.filter((field) => !field.isList && field.scalar !== null && NUMERIC_SCALARS.has(field.scalar));
|
|
1273
1289
|
const minmaxFields = model.fields.filter((field) => !field.isList && field.scalar !== null && MINMAX_SCALARS.has(field.scalar));
|
|
1274
1290
|
parts.push(inputAlias({
|
|
@@ -1319,6 +1335,21 @@ ${model.relations.map((relation) => ` ${propKey({ name: relation.name })}: ${re
|
|
|
1319
1335
|
]
|
|
1320
1336
|
}));
|
|
1321
1337
|
}
|
|
1338
|
+
parts.push(inputAlias({
|
|
1339
|
+
name: `${n}FindPageArgs`,
|
|
1340
|
+
lines: [
|
|
1341
|
+
` readonly where?: ${n}WhereInput;`,
|
|
1342
|
+
` readonly orderBy: ${orMany({ type: `${n}ScalarOrderByInput` })};`,
|
|
1343
|
+
` readonly take: number;`,
|
|
1344
|
+
` readonly after?: KeysetToken;`,
|
|
1345
|
+
` readonly keyset?: KeysetOptions;`,
|
|
1346
|
+
` readonly select?: ${n}Select;`,
|
|
1347
|
+
` readonly include?: ${n}Include;`,
|
|
1348
|
+
` readonly omit?: ${n}OmitInput;`,
|
|
1349
|
+
` readonly relationStrategy?: RelationStrategy;`,
|
|
1350
|
+
...["skip", "cursor", "distinct", "lock"].map((key) => ` readonly ${key}?: never;`)
|
|
1351
|
+
]
|
|
1352
|
+
}));
|
|
1322
1353
|
parts.push(`export type ${n}FindFirstArgs = ${n}FindManyArgs;`);
|
|
1323
1354
|
parts.push(inputAlias({
|
|
1324
1355
|
name: `${n}FindUniqueArgs`,
|
|
@@ -1334,6 +1365,7 @@ ${model.relations.map((relation) => ` ${propKey({ name: relation.name })}: ${re
|
|
|
1334
1365
|
parts.push(inputAlias({
|
|
1335
1366
|
name: `${n}CreateArgs`,
|
|
1336
1367
|
lines: [
|
|
1368
|
+
` readonly relationStrategy?: never;`,
|
|
1337
1369
|
` readonly onConflict?: never;`,
|
|
1338
1370
|
` readonly data: ${n}CreateInput | ${n}UncheckedCreateInput;`,
|
|
1339
1371
|
` readonly select?: ${n}Select;`,
|
|
@@ -1348,6 +1380,7 @@ ${model.relations.map((relation) => ` ${propKey({ name: relation.name })}: ${re
|
|
|
1348
1380
|
parts.push(inputAlias({
|
|
1349
1381
|
name: `${n}CreateOrSkipArgs`,
|
|
1350
1382
|
lines: [
|
|
1383
|
+
` readonly relationStrategy?: never;`,
|
|
1351
1384
|
` readonly data: ${n}CreateInput | ${n}UncheckedCreateInput;`,
|
|
1352
1385
|
` readonly onConflict: ${n}CreateOnConflictInput;`,
|
|
1353
1386
|
` readonly select?: ${n}Select;`,
|
|
@@ -1358,6 +1391,7 @@ ${model.relations.map((relation) => ` ${propKey({ name: relation.name })}: ${re
|
|
|
1358
1391
|
parts.push(inputAlias({
|
|
1359
1392
|
name: `${n}CreateManyArgs`,
|
|
1360
1393
|
lines: [
|
|
1394
|
+
` readonly relationStrategy?: never;`,
|
|
1361
1395
|
` readonly data: ${orMany({ type: `${n}CreateManyInput` })};`,
|
|
1362
1396
|
` readonly skipDuplicates?: boolean | { readonly target?: ${n}ConflictTarget; readonly where?: string };`
|
|
1363
1397
|
]
|
|
@@ -1365,6 +1399,7 @@ ${model.relations.map((relation) => ` ${propKey({ name: relation.name })}: ${re
|
|
|
1365
1399
|
parts.push(inputAlias({
|
|
1366
1400
|
name: `${n}CreateManyAndReturnArgs`,
|
|
1367
1401
|
lines: [
|
|
1402
|
+
` readonly relationStrategy?: never;`,
|
|
1368
1403
|
` readonly data: ${orMany({ type: `${n}CreateManyInput` })};`,
|
|
1369
1404
|
` readonly skipDuplicates?: boolean | { readonly target?: ${n}ConflictTarget; readonly where?: string };`,
|
|
1370
1405
|
` readonly select?: ${n}Select;`,
|
|
@@ -1546,6 +1581,7 @@ ${relationCases}
|
|
|
1546
1581
|
` + ` (number extends A["by"]["length"] ? Partial<Pick<${n}, A["by"][number]>> : Pick<${n}, A["by"][number]>) & ${n}AggregateResult<A>;`);
|
|
1547
1582
|
const readMethods = [
|
|
1548
1583
|
` findMany<A extends ${n}FindManyArgs = {}>(args?: A): VibeQueryPromise<${n}GetPayload<A>[]>;`,
|
|
1584
|
+
` findPage<A extends ${n}FindPageArgs>(args: A): VibeQueryPromise<KeysetPage<${n}GetPayload<A>>>;`,
|
|
1549
1585
|
` findFirst<A extends ${n}FindFirstArgs = {}>(args?: A): VibeQueryPromise<${n}GetPayload<A> | null>;`,
|
|
1550
1586
|
` findFirstOrThrow<A extends ${n}FindFirstArgs = {}>(args?: A): VibeQueryPromise<${n}GetPayload<A>>;`,
|
|
1551
1587
|
` findUnique<A extends ${n}FindUniqueArgs>(args: A): VibeQueryPromise<${n}GetPayload<A> | null>;`,
|
|
@@ -1881,8 +1917,9 @@ var CONNECTION_SURFACE_LINES = ` readonly $connect: () => Promise<void>;
|
|
|
1881
1917
|
var DEFINE_VIEW_LINE = ` /** Field-masking views (v1 defineView parity): a read-only masked projection of models. */
|
|
1882
1918
|
` + ` readonly $defineView: <D extends ViewDefinitionInput>(options: { readonly name: string; readonly definition: D }) => ViewClient<D>;
|
|
1883
1919
|
`;
|
|
1884
|
-
var
|
|
1885
|
-
|
|
1920
|
+
var READ_ONLY_DOC = ` /** A read-only handle over this one: reads pass through, and every write, raw-SQL and control method is refused with \`VIBE_READ_ONLY\`. Closed under composition \u2014 transactions, views, scoped and policy handles built from it stay read-only. */
|
|
1921
|
+
`;
|
|
1922
|
+
var READ_ONLY_LINE = READ_ONLY_DOC + ` readonly $readOnly: () => ReadOnlyClientInstance;
|
|
1886
1923
|
`;
|
|
1887
1924
|
function instanceSurfaceLines(params) {
|
|
1888
1925
|
const { view, transactionType, inTransaction, selfLabel } = params;
|
|
@@ -2064,7 +2101,7 @@ function emitClient(params) {
|
|
|
2064
2101
|
` + ` // Deliberately ABSENT: model delegates, $models, $transaction, $queryRaw / $executeRaw / $queryRawUnsafe / $executeRawUnsafe, $advisoryLock / $tryAdvisoryLock, $defineView, $readOnly and every extension mount \u2014 an unbound client has no identity, so it cannot read or write a row. Bind one with $withContext.
|
|
2065
2102
|
` + `};`);
|
|
2066
2103
|
} else {
|
|
2067
|
-
parts.push(`export type VibeClientInstance = ClientContext
|
|
2104
|
+
parts.push(`export type VibeClientInstance = ClientContext<${tsString({ value: view.models.some((model) => model.policy !== undefined) ? "restricted" : "root" })}> & {
|
|
2068
2105
|
` + instanceSurfaceLines({
|
|
2069
2106
|
view,
|
|
2070
2107
|
transactionType: "VibeTransactionClientInstance",
|
|
@@ -2072,7 +2109,7 @@ function emitClient(params) {
|
|
|
2072
2109
|
selfLabel: "db"
|
|
2073
2110
|
}) + policyClientLines({ view, selfType: "VibeClientInstance" }) + scopedClientLines({ view, scopedType: "ScopedClientInstance" }) + READ_ONLY_LINE + clientExtensionLines + `};`);
|
|
2074
2111
|
parts.push(`/** The handle \`$transaction\` gives its callback. A helper that REQUIRES a transaction takes this type, and an ordinary client no longer satisfies it. */
|
|
2075
|
-
` + `export type VibeTransactionClientInstance = ClientContext
|
|
2112
|
+
` + `export type VibeTransactionClientInstance = ClientContext<${tsString({ value: view.models.some((model) => model.policy !== undefined) ? "restricted" : "transaction" })}> & {
|
|
2076
2113
|
` + instanceSurfaceLines({
|
|
2077
2114
|
view,
|
|
2078
2115
|
transactionType: "VibeTransactionClientInstance",
|
|
@@ -2135,7 +2172,8 @@ ${modelsProps.join(`
|
|
|
2135
2172
|
` + ` };
|
|
2136
2173
|
` + (params2.inTransaction ? advisoryLockLines({ view, selfLabel: "tx" }) : CONNECTION_SURFACE_LINES) + ` /** Field-masking views compose over the scoped handle (columns \xD7 rows). */
|
|
2137
2174
|
` + ` readonly $defineView: <D extends ViewDefinitionInput>(options: { readonly name: string; readonly definition: D }) => ViewClient<D>;
|
|
2138
|
-
` +
|
|
2175
|
+
` + READ_ONLY_DOC + ` readonly $readOnly: () => ReadOnlyClientInstance<"restricted">;
|
|
2176
|
+
`;
|
|
2139
2177
|
return [
|
|
2140
2178
|
banner({ title: "Tenant scoping ($scoped)" }),
|
|
2141
2179
|
`/** What a scoped handle does when this model appears INSIDE another model's nested write: "verify" (default) rewrites reference verbs into tenant-verified lookups; "refuse" rejects them. */
|
|
@@ -2145,11 +2183,11 @@ export type ScopedModelsConfig = {
|
|
|
2145
2183
|
${entries.join(`
|
|
2146
2184
|
`)}
|
|
2147
2185
|
};`,
|
|
2148
|
-
`export type ScopedClientInstance = {
|
|
2186
|
+
`export type ScopedClientInstance = ClientContext<"restricted"> & {
|
|
2149
2187
|
` + scopedSurface({ transactionType: "ScopedTransactionClientInstance", inTransaction: false }) + ` // Deliberately ABSENT: $queryRaw / $executeRaw / $queryRawUnsafe / $executeRawUnsafe (raw SQL cannot be tenant-verified \u2014 use the base client) and $scoped (scope once, from the base client).
|
|
2150
2188
|
` + `};`,
|
|
2151
2189
|
`/** The scoped handle inside \`$transaction\`: same scope, plus the locks that require a transaction. */
|
|
2152
|
-
` + `export type ScopedTransactionClientInstance = {
|
|
2190
|
+
` + `export type ScopedTransactionClientInstance = ClientContext<"restricted"> & {
|
|
2153
2191
|
` + scopedSurface({ transactionType: "ScopedTransactionClientInstance", inTransaction: true }) + ` // Deliberately ABSENT: the raw-SQL doors, $scoped, and $connect / $disconnect (the open transaction owns the connection).
|
|
2154
2192
|
` + `};`
|
|
2155
2193
|
];
|
|
@@ -2186,6 +2224,9 @@ function emitReadOnlySection(params) {
|
|
|
2186
2224
|
const extensionLines = baked.readOnlyClientDts.length === 0 ? "" : `${baked.readOnlyClientDts.join(`
|
|
2187
2225
|
`)}
|
|
2188
2226
|
`;
|
|
2227
|
+
const scopeLines = scopedClientLines({ view, scopedType: 'ReadOnlyClientInstance<"restricted">' });
|
|
2228
|
+
const scopeSurface = scopeLines.length === 0 ? "" : `(ContextKind extends "readOnly" ? {
|
|
2229
|
+
${scopeLines}} : {}) & `;
|
|
2189
2230
|
return [
|
|
2190
2231
|
banner({ title: "Read-only clients ($readOnly)" }),
|
|
2191
2232
|
`/**
|
|
@@ -2199,9 +2240,9 @@ function emitReadOnlySection(params) {
|
|
|
2199
2240
|
` + ` * await reader.user.findMany(); // fine
|
|
2200
2241
|
` + ` * await reader.user.upsertMany({ \u2026 }); // VIBE_READ_ONLY, and a compile error
|
|
2201
2242
|
` + ` */
|
|
2202
|
-
` + `export type ReadOnlyClientInstance =
|
|
2203
|
-
` + delegateSurfaceLines({ view, delegateSuffix: "ReadOnlyDelegate" }) + transactionLines({ transactionType: "ReadOnlyClientInstance", reads: true }) + DEFINE_VIEW_LINE + policyClientLines({ view, selfType: "ReadOnlyClientInstance" }) +
|
|
2204
|
-
` + ` readonly $readOnly: () => ReadOnlyClientInstance
|
|
2243
|
+
` + `export type ReadOnlyClientInstance<ContextKind extends "readOnly" | "restricted" = ${tsString({ value: hasNativeRls({ view }) || view.models.some((model) => model.policy !== undefined) ? "restricted" : "readOnly" })}> = ClientContext<ContextKind> & ${scopeSurface}{
|
|
2244
|
+
` + delegateSurfaceLines({ view, delegateSuffix: "ReadOnlyDelegate" }) + transactionLines({ transactionType: "ReadOnlyClientInstance<ContextKind>", reads: true }) + DEFINE_VIEW_LINE + policyClientLines({ view, selfType: "ReadOnlyClientInstance<ContextKind>" }) + ` /** Idempotent: the same read-only restriction and underlying context are retained. */
|
|
2245
|
+
` + ` readonly $readOnly: () => ReadOnlyClientInstance<ContextKind>;
|
|
2205
2246
|
` + extensionLines + ` // Deliberately ABSENT: every write method, $queryRaw / $executeRaw / $queryRawUnsafe / $executeRawUnsafe, $connect / $disconnect, $advisoryLock / $tryAdvisoryLock, $withContext, and every extension surface its author did not classify as a read.
|
|
2206
2247
|
` + `};`
|
|
2207
2248
|
];
|
|
@@ -2451,7 +2492,8 @@ var README = `# Generated VibeORM client
|
|
|
2451
2492
|
This directory was generated by \`@vibeorm/generator\` from your VibeORM schema \u2014 do not edit it by hand, any change is overwritten on the next generate. After every schema change, regenerate with \`vibeorm generate\` (or programmatically via \`generateClient({ schema, outDir })\` from \`@vibeorm/generator\`).
|
|
2452
2493
|
`;
|
|
2453
2494
|
async function generateClient(params) {
|
|
2454
|
-
const {
|
|
2495
|
+
const { outDir } = params;
|
|
2496
|
+
const schema = params.module === undefined ? params.schema : prepareDatabaseModuleSchema({ schema: params.schema, module: params.module });
|
|
2455
2497
|
const view = buildSchemaView({ schema });
|
|
2456
2498
|
const baked = bakeExtensions({ schema: view.schema, extensions: params.extensions ?? [] });
|
|
2457
2499
|
let computed = [];
|
|
@@ -2480,7 +2522,8 @@ async function generateClient(params) {
|
|
|
2480
2522
|
}
|
|
2481
2523
|
export {
|
|
2482
2524
|
bakeExtensions,
|
|
2483
|
-
generateClient
|
|
2525
|
+
generateClient,
|
|
2526
|
+
prepareDatabaseModuleSchema
|
|
2484
2527
|
};
|
|
2485
2528
|
|
|
2486
|
-
//# debugId=
|
|
2529
|
+
//# debugId=BD8C77FCC6EC9CEF64756E2164756E21
|