@kurotako/ir 0.1.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/index.cjs +1006 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +576 -0
- package/dist/index.d.ts +576 -0
- package/dist/index.js +929 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1006 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
CompositeUniqueSchema: () => CompositeUniqueSchema,
|
|
34
|
+
ConstraintsSchema: () => ConstraintsSchema,
|
|
35
|
+
DefaultValueSchema: () => DefaultValueSchema,
|
|
36
|
+
EntitySchema: () => EntitySchema,
|
|
37
|
+
EnumDefSchema: () => EnumDefSchema,
|
|
38
|
+
EnumValueSchema: () => EnumValueSchema,
|
|
39
|
+
FieldSchema: () => FieldSchema,
|
|
40
|
+
FieldTypeSchema: () => FieldTypeSchema,
|
|
41
|
+
IR_VERSION: () => IR_VERSION,
|
|
42
|
+
IndexDefSchema: () => IndexDefSchema,
|
|
43
|
+
IndexTypeSchema: () => IndexTypeSchema,
|
|
44
|
+
IrBuildError: () => IrBuildError,
|
|
45
|
+
IrSchema: () => IrSchema,
|
|
46
|
+
IrValidationError: () => IrValidationError,
|
|
47
|
+
JsonValueSchema: () => JsonValueSchema,
|
|
48
|
+
ReferentialActionSchema: () => ReferentialActionSchema,
|
|
49
|
+
RelationSchema: () => RelationSchema,
|
|
50
|
+
RelationTargetSchema: () => RelationTargetSchema,
|
|
51
|
+
ScalarTypeSchema: () => ScalarTypeSchema,
|
|
52
|
+
SourceIrSchema: () => SourceIrSchema,
|
|
53
|
+
StringFormatSchema: () => StringFormatSchema,
|
|
54
|
+
assertIR: () => assertIR,
|
|
55
|
+
assertSourceIR: () => assertSourceIR,
|
|
56
|
+
createFields: () => createFields,
|
|
57
|
+
createSourceIR: () => createSourceIR,
|
|
58
|
+
getSource: () => getSource,
|
|
59
|
+
isCompatible: () => isCompatible,
|
|
60
|
+
isCreateOptional: () => isCreateOptional,
|
|
61
|
+
isCrossSource: () => isCrossSource,
|
|
62
|
+
isDbAssigned: () => isDbAssigned,
|
|
63
|
+
iterEntities: () => iterEntities,
|
|
64
|
+
iterFields: () => iterFields,
|
|
65
|
+
parseIR: () => parseIR,
|
|
66
|
+
primaryKeyFields: () => primaryKeyFields,
|
|
67
|
+
resolveEntity: () => resolveEntity,
|
|
68
|
+
resolveEnum: () => resolveEnum,
|
|
69
|
+
resolveRelationTarget: () => resolveRelationTarget,
|
|
70
|
+
scalarTsType: () => scalarTsType,
|
|
71
|
+
updateFields: () => updateFields,
|
|
72
|
+
validateIR: () => validateIR,
|
|
73
|
+
validateSourceIR: () => validateSourceIR
|
|
74
|
+
});
|
|
75
|
+
module.exports = __toCommonJS(index_exports);
|
|
76
|
+
|
|
77
|
+
// src/builder.ts
|
|
78
|
+
var v3 = __toESM(require("valibot"), 1);
|
|
79
|
+
|
|
80
|
+
// src/schemas.ts
|
|
81
|
+
var v = __toESM(require("valibot"), 1);
|
|
82
|
+
var JsonValueSchema = v.lazy(
|
|
83
|
+
() => v.union([
|
|
84
|
+
v.null(),
|
|
85
|
+
v.boolean(),
|
|
86
|
+
v.number(),
|
|
87
|
+
v.string(),
|
|
88
|
+
v.array(JsonValueSchema),
|
|
89
|
+
v.record(v.string(), JsonValueSchema)
|
|
90
|
+
])
|
|
91
|
+
);
|
|
92
|
+
var ScalarTypeSchema = v.picklist([
|
|
93
|
+
"string",
|
|
94
|
+
"boolean",
|
|
95
|
+
"int",
|
|
96
|
+
"bigint",
|
|
97
|
+
"float",
|
|
98
|
+
"decimal",
|
|
99
|
+
"date",
|
|
100
|
+
"datetime",
|
|
101
|
+
"uuid",
|
|
102
|
+
"bytes",
|
|
103
|
+
"json"
|
|
104
|
+
]);
|
|
105
|
+
var StringFormatSchema = v.picklist([
|
|
106
|
+
"email",
|
|
107
|
+
"url",
|
|
108
|
+
"uuid",
|
|
109
|
+
"cuid",
|
|
110
|
+
"cuid2",
|
|
111
|
+
"ulid",
|
|
112
|
+
"datetime",
|
|
113
|
+
"date",
|
|
114
|
+
"time",
|
|
115
|
+
"duration",
|
|
116
|
+
"ipv4",
|
|
117
|
+
"ipv6"
|
|
118
|
+
]);
|
|
119
|
+
var ReferentialActionSchema = v.picklist([
|
|
120
|
+
"cascade",
|
|
121
|
+
"restrict",
|
|
122
|
+
"setNull",
|
|
123
|
+
"setDefault",
|
|
124
|
+
"noAction"
|
|
125
|
+
]);
|
|
126
|
+
var IndexTypeSchema = v.picklist([
|
|
127
|
+
"btree",
|
|
128
|
+
"hash",
|
|
129
|
+
"gin",
|
|
130
|
+
"gist",
|
|
131
|
+
"brin",
|
|
132
|
+
"spgist"
|
|
133
|
+
]);
|
|
134
|
+
var FieldTypeSchema = v.variant("kind", [
|
|
135
|
+
v.object({ kind: v.literal("scalar"), scalar: ScalarTypeSchema }),
|
|
136
|
+
v.object({ kind: v.literal("enum"), ref: v.string() }),
|
|
137
|
+
v.object({ kind: v.literal("unknown"), hint: v.optional(v.string()) })
|
|
138
|
+
]);
|
|
139
|
+
var ConstraintsSchema = v.object({
|
|
140
|
+
min: v.optional(v.number()),
|
|
141
|
+
max: v.optional(v.number()),
|
|
142
|
+
minLength: v.optional(v.number()),
|
|
143
|
+
maxLength: v.optional(v.number()),
|
|
144
|
+
regex: v.optional(v.string()),
|
|
145
|
+
format: v.optional(StringFormatSchema),
|
|
146
|
+
unique: v.optional(v.boolean())
|
|
147
|
+
});
|
|
148
|
+
var DefaultValueSchema = v.variant("kind", [
|
|
149
|
+
v.object({ kind: v.literal("value"), value: JsonValueSchema }),
|
|
150
|
+
v.object({
|
|
151
|
+
kind: v.literal("expr"),
|
|
152
|
+
expr: v.string(),
|
|
153
|
+
args: v.optional(v.array(JsonValueSchema))
|
|
154
|
+
})
|
|
155
|
+
]);
|
|
156
|
+
var FieldSchema = v.object({
|
|
157
|
+
name: v.string(),
|
|
158
|
+
type: FieldTypeSchema,
|
|
159
|
+
list: v.boolean(),
|
|
160
|
+
optional: v.boolean(),
|
|
161
|
+
nullable: v.boolean(),
|
|
162
|
+
constraints: ConstraintsSchema,
|
|
163
|
+
default: v.optional(DefaultValueSchema),
|
|
164
|
+
doc: v.optional(v.string()),
|
|
165
|
+
dbName: v.optional(v.string())
|
|
166
|
+
});
|
|
167
|
+
var RelationTargetSchema = v.object({
|
|
168
|
+
namespace: v.string(),
|
|
169
|
+
entity: v.string()
|
|
170
|
+
});
|
|
171
|
+
var RelationSchema = v.object({
|
|
172
|
+
name: v.string(),
|
|
173
|
+
target: RelationTargetSchema,
|
|
174
|
+
cardinality: v.picklist(["one", "many"]),
|
|
175
|
+
optional: v.boolean(),
|
|
176
|
+
owning: v.boolean(),
|
|
177
|
+
backRelation: v.optional(v.string()),
|
|
178
|
+
fkFields: v.optional(v.array(v.string())),
|
|
179
|
+
references: v.optional(v.array(v.string())),
|
|
180
|
+
onDelete: v.optional(ReferentialActionSchema),
|
|
181
|
+
onUpdate: v.optional(ReferentialActionSchema)
|
|
182
|
+
});
|
|
183
|
+
var EnumValueSchema = v.object({
|
|
184
|
+
name: v.string(),
|
|
185
|
+
dbName: v.optional(v.string()),
|
|
186
|
+
doc: v.optional(v.string())
|
|
187
|
+
});
|
|
188
|
+
var EnumDefSchema = v.object({
|
|
189
|
+
name: v.string(),
|
|
190
|
+
values: v.array(EnumValueSchema),
|
|
191
|
+
doc: v.optional(v.string()),
|
|
192
|
+
dbName: v.optional(v.string())
|
|
193
|
+
});
|
|
194
|
+
var IndexDefSchema = v.object({
|
|
195
|
+
fields: v.array(v.string()),
|
|
196
|
+
name: v.optional(v.string()),
|
|
197
|
+
type: v.optional(IndexTypeSchema)
|
|
198
|
+
});
|
|
199
|
+
var CompositeUniqueSchema = v.object({
|
|
200
|
+
fields: v.array(v.string()),
|
|
201
|
+
name: v.optional(v.string())
|
|
202
|
+
});
|
|
203
|
+
var EntitySchema = v.object({
|
|
204
|
+
name: v.string(),
|
|
205
|
+
fields: v.array(FieldSchema),
|
|
206
|
+
relations: v.array(RelationSchema),
|
|
207
|
+
enums: v.optional(v.record(v.string(), EnumDefSchema)),
|
|
208
|
+
primaryKey: v.optional(v.array(v.string())),
|
|
209
|
+
indexes: v.array(IndexDefSchema),
|
|
210
|
+
uniques: v.array(CompositeUniqueSchema),
|
|
211
|
+
doc: v.optional(v.string()),
|
|
212
|
+
dbName: v.optional(v.string())
|
|
213
|
+
});
|
|
214
|
+
var SourceIrSchema = v.object({
|
|
215
|
+
namespace: v.string(),
|
|
216
|
+
parser: v.string(),
|
|
217
|
+
parserVersion: v.optional(v.string()),
|
|
218
|
+
entities: v.record(v.string(), EntitySchema),
|
|
219
|
+
enums: v.record(v.string(), EnumDefSchema)
|
|
220
|
+
});
|
|
221
|
+
var IrSchema = v.object({
|
|
222
|
+
irVersion: v.string(),
|
|
223
|
+
sources: v.record(v.string(), SourceIrSchema)
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// src/validate.ts
|
|
227
|
+
var v2 = __toESM(require("valibot"), 1);
|
|
228
|
+
|
|
229
|
+
// src/version.ts
|
|
230
|
+
var IR_VERSION = "1";
|
|
231
|
+
function isCompatible(irVersion) {
|
|
232
|
+
return irVersion === IR_VERSION;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/validate.ts
|
|
236
|
+
var IrValidationError = class extends Error {
|
|
237
|
+
issues;
|
|
238
|
+
constructor(issues) {
|
|
239
|
+
const detail = issues.map((i) => `${i.path === "" ? "<root>" : i.path}: ${i.message}`).join("; ");
|
|
240
|
+
super(`invalid IR: ${detail}`);
|
|
241
|
+
this.name = "IrValidationError";
|
|
242
|
+
this.issues = issues;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
function normaliseValibotIssues(issues) {
|
|
246
|
+
return issues.map((issue) => ({
|
|
247
|
+
path: v2.getDotPath(issue) ?? "",
|
|
248
|
+
code: "shape",
|
|
249
|
+
message: issue.message
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
function pushIssue(issues, path, code, message) {
|
|
253
|
+
issues.push({ path, code, message });
|
|
254
|
+
}
|
|
255
|
+
function checkConstraints(issues, path, c) {
|
|
256
|
+
if (c.min !== void 0 && c.max !== void 0 && c.min > c.max) {
|
|
257
|
+
pushIssue(
|
|
258
|
+
issues,
|
|
259
|
+
path,
|
|
260
|
+
"invalid_constraint",
|
|
261
|
+
`min (${c.min}) is greater than max (${c.max})`
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
if (c.minLength !== void 0 && c.maxLength !== void 0 && c.minLength > c.maxLength) {
|
|
265
|
+
pushIssue(
|
|
266
|
+
issues,
|
|
267
|
+
path,
|
|
268
|
+
"invalid_constraint",
|
|
269
|
+
`minLength (${c.minLength}) is greater than maxLength (${c.maxLength})`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
if (c.regex !== void 0) {
|
|
273
|
+
try {
|
|
274
|
+
new RegExp(c.regex);
|
|
275
|
+
} catch {
|
|
276
|
+
pushIssue(
|
|
277
|
+
issues,
|
|
278
|
+
path,
|
|
279
|
+
"invalid_regex",
|
|
280
|
+
`regex does not compile: ${c.regex}`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function checkEnumValues(issues, path, values) {
|
|
286
|
+
const seen = /* @__PURE__ */ new Set();
|
|
287
|
+
for (const value of values) {
|
|
288
|
+
if (seen.has(value.name)) {
|
|
289
|
+
pushIssue(
|
|
290
|
+
issues,
|
|
291
|
+
`${path}.${value.name}`,
|
|
292
|
+
"duplicate_enum_value",
|
|
293
|
+
`duplicate enum value '${value.name}'`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
seen.add(value.name);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function checkSource(namespace, source, lookupEntity, isNamespacePresent, issues) {
|
|
300
|
+
for (const [key, def] of Object.entries(source.enums)) {
|
|
301
|
+
if (def.name !== key) {
|
|
302
|
+
pushIssue(
|
|
303
|
+
issues,
|
|
304
|
+
`${namespace}.enums.${key}`,
|
|
305
|
+
"entity_key_mismatch",
|
|
306
|
+
`enum key '${key}' does not match enum name '${def.name}'`
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
checkEnumValues(issues, `${namespace}.enums.${key}`, def.values);
|
|
310
|
+
}
|
|
311
|
+
for (const [key, entity] of Object.entries(source.entities)) {
|
|
312
|
+
const ePath = `${namespace}.${key}`;
|
|
313
|
+
if (entity.name !== key) {
|
|
314
|
+
pushIssue(
|
|
315
|
+
issues,
|
|
316
|
+
ePath,
|
|
317
|
+
"entity_key_mismatch",
|
|
318
|
+
`entity key '${key}' does not match entity name '${entity.name}'`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
const fieldNames = /* @__PURE__ */ new Set();
|
|
322
|
+
for (const field of entity.fields) {
|
|
323
|
+
const fPath = `${ePath}.${field.name}`;
|
|
324
|
+
if (fieldNames.has(field.name)) {
|
|
325
|
+
pushIssue(
|
|
326
|
+
issues,
|
|
327
|
+
fPath,
|
|
328
|
+
"duplicate_field",
|
|
329
|
+
`duplicate field '${field.name}'`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
fieldNames.add(field.name);
|
|
333
|
+
checkConstraints(issues, `${fPath}.constraints`, field.constraints);
|
|
334
|
+
if (field.type.kind === "enum") {
|
|
335
|
+
const resolved = entity.enums?.[field.type.ref] ?? source.enums[field.type.ref];
|
|
336
|
+
if (resolved === void 0) {
|
|
337
|
+
pushIssue(
|
|
338
|
+
issues,
|
|
339
|
+
fPath,
|
|
340
|
+
"unresolved_enum_ref",
|
|
341
|
+
`field '${field.name}' references unknown enum '${field.type.ref}'`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
for (const [localKey, def] of Object.entries(entity.enums ?? {})) {
|
|
347
|
+
if (def.name !== localKey) {
|
|
348
|
+
pushIssue(
|
|
349
|
+
issues,
|
|
350
|
+
`${ePath}.enums.${localKey}`,
|
|
351
|
+
"entity_key_mismatch",
|
|
352
|
+
`local enum key '${localKey}' does not match name '${def.name}'`
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
checkEnumValues(issues, `${ePath}.enums.${localKey}`, def.values);
|
|
356
|
+
}
|
|
357
|
+
const hasField = (name) => fieldNames.has(name);
|
|
358
|
+
for (const pk of entity.primaryKey ?? []) {
|
|
359
|
+
if (!hasField(pk)) {
|
|
360
|
+
pushIssue(
|
|
361
|
+
issues,
|
|
362
|
+
`${ePath}.primaryKey`,
|
|
363
|
+
"unresolved_field_ref",
|
|
364
|
+
`primaryKey references unknown field '${pk}'`
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
entity.indexes.forEach((idx, i) => {
|
|
369
|
+
for (const f of idx.fields) {
|
|
370
|
+
if (!hasField(f)) {
|
|
371
|
+
pushIssue(
|
|
372
|
+
issues,
|
|
373
|
+
`${ePath}.indexes.${i}`,
|
|
374
|
+
"unresolved_field_ref",
|
|
375
|
+
`index references unknown field '${f}'`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
entity.uniques.forEach((u, i) => {
|
|
381
|
+
for (const f of u.fields) {
|
|
382
|
+
if (!hasField(f)) {
|
|
383
|
+
pushIssue(
|
|
384
|
+
issues,
|
|
385
|
+
`${ePath}.uniques.${i}`,
|
|
386
|
+
"unresolved_field_ref",
|
|
387
|
+
`unique references unknown field '${f}'`
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
entity.relations.forEach((rel, i) => {
|
|
393
|
+
const rPath = `${ePath}.relations.${rel.name === "" ? i : rel.name}`;
|
|
394
|
+
for (const fk of rel.fkFields ?? []) {
|
|
395
|
+
if (!hasField(fk)) {
|
|
396
|
+
pushIssue(
|
|
397
|
+
issues,
|
|
398
|
+
rPath,
|
|
399
|
+
"unresolved_field_ref",
|
|
400
|
+
`relation '${rel.name}' fkField references unknown field '${fk}'`
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const targetNs = rel.target.namespace;
|
|
405
|
+
if (targetNs === "") {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const sameNs = targetNs === namespace;
|
|
409
|
+
if (!sameNs && !isNamespacePresent(targetNs)) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const targetEntity = lookupEntity(targetNs, rel.target.entity);
|
|
413
|
+
if (targetEntity === void 0) {
|
|
414
|
+
pushIssue(
|
|
415
|
+
issues,
|
|
416
|
+
rPath,
|
|
417
|
+
"unresolved_relation_target",
|
|
418
|
+
`relation '${rel.name}' target ${targetNs}.${rel.target.entity} does not exist`
|
|
419
|
+
);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (rel.backRelation !== void 0 && !targetEntity.relations.some((r) => r.name === rel.backRelation)) {
|
|
423
|
+
pushIssue(
|
|
424
|
+
issues,
|
|
425
|
+
rPath,
|
|
426
|
+
"unresolved_back_relation",
|
|
427
|
+
`backRelation '${rel.backRelation}' not found on ${targetNs}.${rel.target.entity}`
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
for (const ref of rel.references ?? []) {
|
|
431
|
+
if (!targetEntity.fields.some((f) => f.name === ref)) {
|
|
432
|
+
pushIssue(
|
|
433
|
+
issues,
|
|
434
|
+
rPath,
|
|
435
|
+
"unresolved_field_ref",
|
|
436
|
+
`relation '${rel.name}' references unknown field '${ref}' on ${targetNs}.${rel.target.entity}`
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function validateSourceIR(value) {
|
|
444
|
+
const parsed = v2.safeParse(SourceIrSchema, value);
|
|
445
|
+
if (!parsed.success) {
|
|
446
|
+
return { ok: false, issues: normaliseValibotIssues(parsed.issues) };
|
|
447
|
+
}
|
|
448
|
+
const source = parsed.output;
|
|
449
|
+
const issues = [];
|
|
450
|
+
const lookup = (ns, name) => ns === source.namespace ? source.entities[name] : void 0;
|
|
451
|
+
const isPresent = (ns) => ns === source.namespace;
|
|
452
|
+
checkSource(source.namespace, source, lookup, isPresent, issues);
|
|
453
|
+
return issues.length > 0 ? { ok: false, issues } : { ok: true, value: source };
|
|
454
|
+
}
|
|
455
|
+
function validateIR(value) {
|
|
456
|
+
const parsed = v2.safeParse(IrSchema, value);
|
|
457
|
+
if (!parsed.success) {
|
|
458
|
+
return { ok: false, issues: normaliseValibotIssues(parsed.issues) };
|
|
459
|
+
}
|
|
460
|
+
const ir = parsed.output;
|
|
461
|
+
const issues = [];
|
|
462
|
+
if (!isCompatible(ir.irVersion)) {
|
|
463
|
+
pushIssue(
|
|
464
|
+
issues,
|
|
465
|
+
"irVersion",
|
|
466
|
+
"version_incompatible",
|
|
467
|
+
`IR version '${ir.irVersion}' is not compatible with supported version '${IR_VERSION}'`
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
const lookup = (ns, name) => ir.sources[ns]?.entities[name];
|
|
471
|
+
const isPresent = (ns) => ns in ir.sources;
|
|
472
|
+
for (const [key, source] of Object.entries(ir.sources)) {
|
|
473
|
+
if (source.namespace !== key) {
|
|
474
|
+
pushIssue(
|
|
475
|
+
issues,
|
|
476
|
+
`sources.${key}`,
|
|
477
|
+
"namespace_key_mismatch",
|
|
478
|
+
`source key '${key}' does not match namespace '${source.namespace}'`
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
checkSource(source.namespace, source, lookup, isPresent, issues);
|
|
482
|
+
}
|
|
483
|
+
return issues.length > 0 ? { ok: false, issues } : { ok: true, value: ir };
|
|
484
|
+
}
|
|
485
|
+
function assertIR(value) {
|
|
486
|
+
const result = validateIR(value);
|
|
487
|
+
if (!result.ok) {
|
|
488
|
+
throw new IrValidationError(result.issues);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function assertSourceIR(value) {
|
|
492
|
+
const result = validateSourceIR(value);
|
|
493
|
+
if (!result.ok) {
|
|
494
|
+
throw new IrValidationError(result.issues);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function parseIR(json) {
|
|
498
|
+
const value = JSON.parse(json);
|
|
499
|
+
assertIR(value);
|
|
500
|
+
return value;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/builder.ts
|
|
504
|
+
var IrBuildError = class extends Error {
|
|
505
|
+
path;
|
|
506
|
+
issues;
|
|
507
|
+
constructor(path, message, issues) {
|
|
508
|
+
super(`${path}: ${message}`);
|
|
509
|
+
this.name = "IrBuildError";
|
|
510
|
+
this.path = path;
|
|
511
|
+
this.issues = issues;
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
var EnumBuilderImpl = class {
|
|
515
|
+
#def;
|
|
516
|
+
constructor(name) {
|
|
517
|
+
this.#def = { name, values: [] };
|
|
518
|
+
}
|
|
519
|
+
value(name, opts) {
|
|
520
|
+
const entry = { name };
|
|
521
|
+
if (opts?.dbName !== void 0) {
|
|
522
|
+
entry.dbName = opts.dbName;
|
|
523
|
+
}
|
|
524
|
+
if (opts?.doc !== void 0) {
|
|
525
|
+
entry.doc = opts.doc;
|
|
526
|
+
}
|
|
527
|
+
this.#def.values.push(entry);
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
530
|
+
doc(text) {
|
|
531
|
+
this.#def.doc = text;
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
534
|
+
dbName(name) {
|
|
535
|
+
this.#def.dbName = name;
|
|
536
|
+
return this;
|
|
537
|
+
}
|
|
538
|
+
build() {
|
|
539
|
+
return this.#def;
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
var FieldBuilderImpl = class {
|
|
543
|
+
#path;
|
|
544
|
+
#field;
|
|
545
|
+
#onPrimary;
|
|
546
|
+
constructor(path, name, onPrimary) {
|
|
547
|
+
this.#path = path;
|
|
548
|
+
this.#onPrimary = onPrimary;
|
|
549
|
+
this.#field = {
|
|
550
|
+
name,
|
|
551
|
+
type: { kind: "unknown" },
|
|
552
|
+
list: false,
|
|
553
|
+
optional: false,
|
|
554
|
+
nullable: false,
|
|
555
|
+
constraints: {}
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
scalar(t) {
|
|
559
|
+
if (!v3.is(ScalarTypeSchema, t)) {
|
|
560
|
+
throw new IrBuildError(this.#path, `unknown scalar type '${t}'`);
|
|
561
|
+
}
|
|
562
|
+
this.#field.type = { kind: "scalar", scalar: t };
|
|
563
|
+
return this;
|
|
564
|
+
}
|
|
565
|
+
enum(ref) {
|
|
566
|
+
this.#field.type = { kind: "enum", ref };
|
|
567
|
+
return this;
|
|
568
|
+
}
|
|
569
|
+
unknown(hint) {
|
|
570
|
+
this.#field.type = hint === void 0 ? { kind: "unknown" } : { kind: "unknown", hint };
|
|
571
|
+
return this;
|
|
572
|
+
}
|
|
573
|
+
list() {
|
|
574
|
+
this.#field.list = true;
|
|
575
|
+
return this;
|
|
576
|
+
}
|
|
577
|
+
optional() {
|
|
578
|
+
this.#field.optional = true;
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
nullable() {
|
|
582
|
+
this.#field.nullable = true;
|
|
583
|
+
return this;
|
|
584
|
+
}
|
|
585
|
+
primary() {
|
|
586
|
+
if (this.#field.list) {
|
|
587
|
+
throw new IrBuildError(
|
|
588
|
+
this.#path,
|
|
589
|
+
"primary() cannot be used on a list field"
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
this.#onPrimary(this.#field.name);
|
|
593
|
+
return this;
|
|
594
|
+
}
|
|
595
|
+
unique() {
|
|
596
|
+
this.#field.constraints.unique = true;
|
|
597
|
+
return this;
|
|
598
|
+
}
|
|
599
|
+
min(n) {
|
|
600
|
+
this.#field.constraints.min = n;
|
|
601
|
+
return this;
|
|
602
|
+
}
|
|
603
|
+
max(n) {
|
|
604
|
+
this.#field.constraints.max = n;
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
minLength(n) {
|
|
608
|
+
this.#field.constraints.minLength = n;
|
|
609
|
+
return this;
|
|
610
|
+
}
|
|
611
|
+
maxLength(n) {
|
|
612
|
+
this.#field.constraints.maxLength = n;
|
|
613
|
+
return this;
|
|
614
|
+
}
|
|
615
|
+
regex(src) {
|
|
616
|
+
this.#field.constraints.regex = src;
|
|
617
|
+
return this;
|
|
618
|
+
}
|
|
619
|
+
format(f) {
|
|
620
|
+
if (this.#field.type.kind !== "scalar" || this.#field.type.scalar !== "string") {
|
|
621
|
+
throw new IrBuildError(
|
|
622
|
+
this.#path,
|
|
623
|
+
"format() requires a string scalar field"
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
this.#field.constraints.format = f;
|
|
627
|
+
return this;
|
|
628
|
+
}
|
|
629
|
+
default(d) {
|
|
630
|
+
this.#field.default = d;
|
|
631
|
+
return this;
|
|
632
|
+
}
|
|
633
|
+
doc(text) {
|
|
634
|
+
this.#field.doc = text;
|
|
635
|
+
return this;
|
|
636
|
+
}
|
|
637
|
+
dbName(name) {
|
|
638
|
+
this.#field.dbName = name;
|
|
639
|
+
return this;
|
|
640
|
+
}
|
|
641
|
+
build() {
|
|
642
|
+
return this.#field;
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
var RelationBuilderImpl = class {
|
|
646
|
+
#rel;
|
|
647
|
+
constructor(name) {
|
|
648
|
+
this.#rel = {
|
|
649
|
+
name,
|
|
650
|
+
target: { namespace: "", entity: "" },
|
|
651
|
+
cardinality: "one",
|
|
652
|
+
optional: false,
|
|
653
|
+
owning: false
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
to(namespace, entity) {
|
|
657
|
+
this.#rel.target = { namespace, entity };
|
|
658
|
+
return this;
|
|
659
|
+
}
|
|
660
|
+
one() {
|
|
661
|
+
this.#rel.cardinality = "one";
|
|
662
|
+
return this;
|
|
663
|
+
}
|
|
664
|
+
many() {
|
|
665
|
+
this.#rel.cardinality = "many";
|
|
666
|
+
return this;
|
|
667
|
+
}
|
|
668
|
+
optional() {
|
|
669
|
+
this.#rel.optional = true;
|
|
670
|
+
return this;
|
|
671
|
+
}
|
|
672
|
+
owning() {
|
|
673
|
+
this.#rel.owning = true;
|
|
674
|
+
return this;
|
|
675
|
+
}
|
|
676
|
+
backRelation(name) {
|
|
677
|
+
this.#rel.backRelation = name;
|
|
678
|
+
return this;
|
|
679
|
+
}
|
|
680
|
+
fkFields(...fields) {
|
|
681
|
+
this.#rel.fkFields = fields;
|
|
682
|
+
return this;
|
|
683
|
+
}
|
|
684
|
+
references(...fields) {
|
|
685
|
+
this.#rel.references = fields;
|
|
686
|
+
return this;
|
|
687
|
+
}
|
|
688
|
+
onDelete(action) {
|
|
689
|
+
this.#rel.onDelete = action;
|
|
690
|
+
return this;
|
|
691
|
+
}
|
|
692
|
+
onUpdate(action) {
|
|
693
|
+
this.#rel.onUpdate = action;
|
|
694
|
+
return this;
|
|
695
|
+
}
|
|
696
|
+
build() {
|
|
697
|
+
return this.#rel;
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
var EntityBuilderImpl = class {
|
|
701
|
+
#namespace;
|
|
702
|
+
#name;
|
|
703
|
+
#fields = [];
|
|
704
|
+
#fieldNames = /* @__PURE__ */ new Set();
|
|
705
|
+
#relations = [];
|
|
706
|
+
#localEnums = {};
|
|
707
|
+
#primaryKey = [];
|
|
708
|
+
#indexes = [];
|
|
709
|
+
#uniques = [];
|
|
710
|
+
#doc;
|
|
711
|
+
#dbName;
|
|
712
|
+
constructor(namespace, name) {
|
|
713
|
+
this.#namespace = namespace;
|
|
714
|
+
this.#name = name;
|
|
715
|
+
}
|
|
716
|
+
#addPrimary(field) {
|
|
717
|
+
if (!this.#primaryKey.includes(field)) {
|
|
718
|
+
this.#primaryKey.push(field);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
field(name, def) {
|
|
722
|
+
if (this.#fieldNames.has(name)) {
|
|
723
|
+
throw new IrBuildError(
|
|
724
|
+
`${this.#namespace}.${this.#name}.${name}`,
|
|
725
|
+
`duplicate field '${name}'`
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
this.#fieldNames.add(name);
|
|
729
|
+
const builder = new FieldBuilderImpl(
|
|
730
|
+
`${this.#namespace}.${this.#name}.${name}`,
|
|
731
|
+
name,
|
|
732
|
+
(pk) => this.#addPrimary(pk)
|
|
733
|
+
);
|
|
734
|
+
def(builder);
|
|
735
|
+
this.#fields.push(builder);
|
|
736
|
+
return this;
|
|
737
|
+
}
|
|
738
|
+
relation(name, def) {
|
|
739
|
+
const builder = new RelationBuilderImpl(name);
|
|
740
|
+
def(builder);
|
|
741
|
+
this.#relations.push(builder);
|
|
742
|
+
return this;
|
|
743
|
+
}
|
|
744
|
+
localEnum(name, def) {
|
|
745
|
+
const builder = new EnumBuilderImpl(name);
|
|
746
|
+
def(builder);
|
|
747
|
+
this.#localEnums[name] = builder.build();
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
primaryKey(...fields) {
|
|
751
|
+
for (const field of fields) {
|
|
752
|
+
this.#addPrimary(field);
|
|
753
|
+
}
|
|
754
|
+
return this;
|
|
755
|
+
}
|
|
756
|
+
index(fields, opts) {
|
|
757
|
+
const idx = { fields };
|
|
758
|
+
if (opts?.name !== void 0) {
|
|
759
|
+
idx.name = opts.name;
|
|
760
|
+
}
|
|
761
|
+
if (opts?.type !== void 0) {
|
|
762
|
+
idx.type = opts.type;
|
|
763
|
+
}
|
|
764
|
+
this.#indexes.push(idx);
|
|
765
|
+
return this;
|
|
766
|
+
}
|
|
767
|
+
unique(fields, opts) {
|
|
768
|
+
const entry = { fields };
|
|
769
|
+
if (opts?.name !== void 0) {
|
|
770
|
+
entry.name = opts.name;
|
|
771
|
+
}
|
|
772
|
+
this.#uniques.push(entry);
|
|
773
|
+
return this;
|
|
774
|
+
}
|
|
775
|
+
doc(text) {
|
|
776
|
+
this.#doc = text;
|
|
777
|
+
return this;
|
|
778
|
+
}
|
|
779
|
+
dbName(name) {
|
|
780
|
+
this.#dbName = name;
|
|
781
|
+
return this;
|
|
782
|
+
}
|
|
783
|
+
build() {
|
|
784
|
+
const entity = {
|
|
785
|
+
name: this.#name,
|
|
786
|
+
fields: this.#fields.map((f) => f.build()),
|
|
787
|
+
relations: this.#relations.map((r) => r.build()),
|
|
788
|
+
indexes: this.#indexes,
|
|
789
|
+
uniques: this.#uniques
|
|
790
|
+
};
|
|
791
|
+
if (Object.keys(this.#localEnums).length > 0) {
|
|
792
|
+
entity.enums = this.#localEnums;
|
|
793
|
+
}
|
|
794
|
+
if (this.#primaryKey.length > 0) {
|
|
795
|
+
entity.primaryKey = this.#primaryKey;
|
|
796
|
+
}
|
|
797
|
+
if (this.#doc !== void 0) {
|
|
798
|
+
entity.doc = this.#doc;
|
|
799
|
+
}
|
|
800
|
+
if (this.#dbName !== void 0) {
|
|
801
|
+
entity.dbName = this.#dbName;
|
|
802
|
+
}
|
|
803
|
+
return entity;
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
var SourceIrBuilderImpl = class {
|
|
807
|
+
#namespace;
|
|
808
|
+
#parser;
|
|
809
|
+
#parserVersion;
|
|
810
|
+
#entities = [];
|
|
811
|
+
#entityNames = /* @__PURE__ */ new Set();
|
|
812
|
+
#enums = {};
|
|
813
|
+
constructor(init) {
|
|
814
|
+
this.#namespace = init.namespace;
|
|
815
|
+
this.#parser = init.parser;
|
|
816
|
+
this.#parserVersion = init.parserVersion;
|
|
817
|
+
}
|
|
818
|
+
addEnum(name, def) {
|
|
819
|
+
const builder = new EnumBuilderImpl(name);
|
|
820
|
+
def(builder);
|
|
821
|
+
this.#enums[name] = builder.build();
|
|
822
|
+
return this;
|
|
823
|
+
}
|
|
824
|
+
addEntity(name, def) {
|
|
825
|
+
if (this.#entityNames.has(name)) {
|
|
826
|
+
throw new IrBuildError(
|
|
827
|
+
`${this.#namespace}.${name}`,
|
|
828
|
+
`duplicate entity '${name}'`
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
this.#entityNames.add(name);
|
|
832
|
+
const builder = new EntityBuilderImpl(this.#namespace, name);
|
|
833
|
+
def(builder);
|
|
834
|
+
this.#entities.push(builder);
|
|
835
|
+
return this;
|
|
836
|
+
}
|
|
837
|
+
build() {
|
|
838
|
+
const source = {
|
|
839
|
+
namespace: this.#namespace,
|
|
840
|
+
parser: this.#parser,
|
|
841
|
+
entities: Object.fromEntries(
|
|
842
|
+
this.#entities.map((e) => {
|
|
843
|
+
const built = e.build();
|
|
844
|
+
return [built.name, built];
|
|
845
|
+
})
|
|
846
|
+
),
|
|
847
|
+
enums: this.#enums
|
|
848
|
+
};
|
|
849
|
+
if (this.#parserVersion !== void 0) {
|
|
850
|
+
source.parserVersion = this.#parserVersion;
|
|
851
|
+
}
|
|
852
|
+
try {
|
|
853
|
+
assertSourceIR(source);
|
|
854
|
+
} catch (err) {
|
|
855
|
+
if (err instanceof IrValidationError) {
|
|
856
|
+
const first = err.issues[0];
|
|
857
|
+
throw new IrBuildError(
|
|
858
|
+
first?.path ?? this.#namespace,
|
|
859
|
+
first?.message ?? "invalid SourceIR",
|
|
860
|
+
err.issues
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
throw err;
|
|
864
|
+
}
|
|
865
|
+
return source;
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
function createSourceIR(init) {
|
|
869
|
+
return new SourceIrBuilderImpl(init);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// src/helpers.ts
|
|
873
|
+
function getSource(ir, namespace) {
|
|
874
|
+
return ir.sources[namespace];
|
|
875
|
+
}
|
|
876
|
+
function resolveEntity(ir, namespace, name) {
|
|
877
|
+
return ir.sources[namespace]?.entities[name];
|
|
878
|
+
}
|
|
879
|
+
function resolveEnum(source, entity, ref) {
|
|
880
|
+
return entity?.enums?.[ref] ?? source.enums[ref];
|
|
881
|
+
}
|
|
882
|
+
function isCrossSource(fromNamespace, rel) {
|
|
883
|
+
return rel.target.namespace !== fromNamespace;
|
|
884
|
+
}
|
|
885
|
+
function resolveRelationTarget(ir, fromNamespace, rel) {
|
|
886
|
+
const ns = isCrossSource(fromNamespace, rel) ? rel.target.namespace : fromNamespace;
|
|
887
|
+
return ir.sources[ns]?.entities[rel.target.entity];
|
|
888
|
+
}
|
|
889
|
+
function* iterEntities(ir) {
|
|
890
|
+
for (const [namespace, source] of Object.entries(ir.sources)) {
|
|
891
|
+
for (const entity of Object.values(source.entities)) {
|
|
892
|
+
yield { namespace, entity };
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
function* iterFields(entity) {
|
|
897
|
+
yield* entity.fields;
|
|
898
|
+
}
|
|
899
|
+
function primaryKeyFields(entity) {
|
|
900
|
+
const pk = entity.primaryKey;
|
|
901
|
+
if (pk === void 0) {
|
|
902
|
+
return [];
|
|
903
|
+
}
|
|
904
|
+
const byName = new Map(entity.fields.map((f) => [f.name, f]));
|
|
905
|
+
const out = [];
|
|
906
|
+
for (const name of pk) {
|
|
907
|
+
const field = byName.get(name);
|
|
908
|
+
if (field !== void 0) {
|
|
909
|
+
out.push(field);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
return out;
|
|
913
|
+
}
|
|
914
|
+
function isDbAssigned(field) {
|
|
915
|
+
return field.default?.kind === "expr";
|
|
916
|
+
}
|
|
917
|
+
function createFields(entity) {
|
|
918
|
+
const pk = new Set(entity.primaryKey ?? []);
|
|
919
|
+
return entity.fields.filter(
|
|
920
|
+
(field) => !(pk.has(field.name) && isDbAssigned(field))
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
function isCreateOptional(field) {
|
|
924
|
+
return field.optional || field.default !== void 0 || isDbAssigned(field);
|
|
925
|
+
}
|
|
926
|
+
function updateFields(entity) {
|
|
927
|
+
const pk = new Set(entity.primaryKey ?? []);
|
|
928
|
+
return entity.fields.filter((field) => !pk.has(field.name));
|
|
929
|
+
}
|
|
930
|
+
function scalarTsType(type) {
|
|
931
|
+
switch (type.kind) {
|
|
932
|
+
case "enum":
|
|
933
|
+
return type.ref;
|
|
934
|
+
case "unknown":
|
|
935
|
+
return "unknown";
|
|
936
|
+
case "scalar":
|
|
937
|
+
return mapScalar(type.scalar);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
function mapScalar(scalar) {
|
|
941
|
+
switch (scalar) {
|
|
942
|
+
case "string":
|
|
943
|
+
case "uuid":
|
|
944
|
+
case "decimal":
|
|
945
|
+
return "string";
|
|
946
|
+
case "boolean":
|
|
947
|
+
return "boolean";
|
|
948
|
+
case "int":
|
|
949
|
+
case "float":
|
|
950
|
+
return "number";
|
|
951
|
+
case "bigint":
|
|
952
|
+
return "bigint";
|
|
953
|
+
case "date":
|
|
954
|
+
case "datetime":
|
|
955
|
+
return "Date";
|
|
956
|
+
case "bytes":
|
|
957
|
+
return "Uint8Array";
|
|
958
|
+
case "json":
|
|
959
|
+
return "JsonValue";
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
963
|
+
0 && (module.exports = {
|
|
964
|
+
CompositeUniqueSchema,
|
|
965
|
+
ConstraintsSchema,
|
|
966
|
+
DefaultValueSchema,
|
|
967
|
+
EntitySchema,
|
|
968
|
+
EnumDefSchema,
|
|
969
|
+
EnumValueSchema,
|
|
970
|
+
FieldSchema,
|
|
971
|
+
FieldTypeSchema,
|
|
972
|
+
IR_VERSION,
|
|
973
|
+
IndexDefSchema,
|
|
974
|
+
IndexTypeSchema,
|
|
975
|
+
IrBuildError,
|
|
976
|
+
IrSchema,
|
|
977
|
+
IrValidationError,
|
|
978
|
+
JsonValueSchema,
|
|
979
|
+
ReferentialActionSchema,
|
|
980
|
+
RelationSchema,
|
|
981
|
+
RelationTargetSchema,
|
|
982
|
+
ScalarTypeSchema,
|
|
983
|
+
SourceIrSchema,
|
|
984
|
+
StringFormatSchema,
|
|
985
|
+
assertIR,
|
|
986
|
+
assertSourceIR,
|
|
987
|
+
createFields,
|
|
988
|
+
createSourceIR,
|
|
989
|
+
getSource,
|
|
990
|
+
isCompatible,
|
|
991
|
+
isCreateOptional,
|
|
992
|
+
isCrossSource,
|
|
993
|
+
isDbAssigned,
|
|
994
|
+
iterEntities,
|
|
995
|
+
iterFields,
|
|
996
|
+
parseIR,
|
|
997
|
+
primaryKeyFields,
|
|
998
|
+
resolveEntity,
|
|
999
|
+
resolveEnum,
|
|
1000
|
+
resolveRelationTarget,
|
|
1001
|
+
scalarTsType,
|
|
1002
|
+
updateFields,
|
|
1003
|
+
validateIR,
|
|
1004
|
+
validateSourceIR
|
|
1005
|
+
});
|
|
1006
|
+
//# sourceMappingURL=index.cjs.map
|