@dbml/core 7.1.0-alpha.0 → 7.1.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/lib/index.cjs +56 -53
- package/lib/index.mjs +285 -256
- package/package.json +3 -5
- package/types/index.d.ts +2 -35
- package/types/model_structure/database.d.ts +1 -0
package/lib/index.mjs
CHANGED
|
@@ -9839,8 +9839,14 @@ function processColumnInDb(_) {
|
|
|
9839
9839
|
}
|
|
9840
9840
|
function expandDiagramViewWildcards(_) {
|
|
9841
9841
|
for (let HY of _.diagramViews.values()) {
|
|
9842
|
-
let P = HY.visibleEntities, UY = _.diagramViewWildcards.get(HY)
|
|
9843
|
-
|
|
9842
|
+
let P = HY.visibleEntities, UY = _.diagramViewWildcards.get(HY);
|
|
9843
|
+
if (UY) {
|
|
9844
|
+
if (UY.has("tables") || UY.has("schemas")) {
|
|
9845
|
+
P.tables = [], P.tableGroups = [], P.schemas = [];
|
|
9846
|
+
continue;
|
|
9847
|
+
}
|
|
9848
|
+
UY.has("tableGroups") && P.tableGroups && P.tableGroups.length === 0 && (P.tableGroups = Array.from(_.tableGroups.values()).map((_) => ({ name: _.name })));
|
|
9849
|
+
}
|
|
9844
9850
|
}
|
|
9845
9851
|
}
|
|
9846
9852
|
function convertEnvToDb(_, HY) {
|
|
@@ -12118,14 +12124,49 @@ function findDiagramViewBlocks$1(_) {
|
|
|
12118
12124
|
}
|
|
12119
12125
|
return HY;
|
|
12120
12126
|
}
|
|
12127
|
+
function emitTablesBlock(_, HY) {
|
|
12128
|
+
let P = HY.map((_) => {
|
|
12129
|
+
let HY = addDoubleQuoteIfNeeded(_.name);
|
|
12130
|
+
return _.schemaName === "public" ? HY : `${addDoubleQuoteIfNeeded(_.schemaName)}.${HY}`;
|
|
12131
|
+
});
|
|
12132
|
+
_.push(" Tables {"), P.forEach((HY) => _.push(` ${HY}`)), _.push(" }");
|
|
12133
|
+
}
|
|
12134
|
+
function emitTableGroupsBlock(_, HY) {
|
|
12135
|
+
_.push(" TableGroups {"), HY.forEach((HY) => _.push(` ${addDoubleQuoteIfNeeded(HY.name)}`)), _.push(" }");
|
|
12136
|
+
}
|
|
12137
|
+
function emitSchemasBlock(_, HY) {
|
|
12138
|
+
_.push(" Schemas {"), HY.forEach((HY) => _.push(` ${addDoubleQuoteIfNeeded(HY.name)}`)), _.push(" }");
|
|
12139
|
+
}
|
|
12140
|
+
function emitNotesBlock(_, HY) {
|
|
12141
|
+
_.push(" Notes {"), HY.forEach((HY) => _.push(` ${addDoubleQuoteIfNeeded(HY.name)}`)), _.push(" }");
|
|
12142
|
+
}
|
|
12121
12143
|
function generateDiagramViewBlock(_, HY) {
|
|
12122
|
-
let P =
|
|
12123
|
-
if (HY
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12144
|
+
let P = `DiagramView ${addDoubleQuoteIfNeeded(_)} {`;
|
|
12145
|
+
if (!HY) return `${P}\n}`;
|
|
12146
|
+
let { tables: UY, tableGroups: WY, schemas: GY, stickyNotes: KY } = HY, qY = UY === null, JY = WY === null, YY = GY === null;
|
|
12147
|
+
if (qY && JY && YY && KY === null) return `${P}\n}`;
|
|
12148
|
+
if (qY || JY || YY) {
|
|
12149
|
+
let _ = !qY && UY.length > 0, HY = !JY && WY.length > 0, XY = !YY && GY.length > 0;
|
|
12150
|
+
if (!(_ || HY || XY)) {
|
|
12151
|
+
if (KY && KY.length > 0) {
|
|
12152
|
+
let _ = [P];
|
|
12153
|
+
return emitNotesBlock(_, KY), _.push("}"), _.join("\n");
|
|
12154
|
+
}
|
|
12155
|
+
return `${P}\n Notes { * }\n}`;
|
|
12156
|
+
}
|
|
12157
|
+
let ZY = [P];
|
|
12158
|
+
return _ && emitTablesBlock(ZY, UY), HY && emitTableGroupsBlock(ZY, WY), XY && emitSchemasBlock(ZY, GY), KY && KY.length > 0 && emitNotesBlock(ZY, KY), ZY.push("}"), ZY.join("\n");
|
|
12159
|
+
}
|
|
12160
|
+
let XY = UY, ZY = WY, QY = GY, $Y = XY.length === 0 && ZY.length === 0 && QY.length === 0, eX = KY != null && KY.length > 0;
|
|
12161
|
+
if ($Y) {
|
|
12162
|
+
if (eX) {
|
|
12163
|
+
let _ = [P, " Tables { * }"];
|
|
12164
|
+
return emitNotesBlock(_, KY), _.push("}"), _.join("\n");
|
|
12165
|
+
}
|
|
12166
|
+
return `${P}\n *\n}`;
|
|
12167
|
+
}
|
|
12168
|
+
let tX = [P];
|
|
12169
|
+
return XY.length > 0 && emitTablesBlock(tX, XY), ZY.length > 0 && emitTableGroupsBlock(tX, ZY), QY.length > 0 && emitSchemasBlock(tX, QY), eX && emitNotesBlock(tX, KY), tX.push("}"), tX.join("\n");
|
|
12129
12170
|
}
|
|
12130
12171
|
function syncDiagramView$1(_, HY, P) {
|
|
12131
12172
|
let UY = P ?? findDiagramViewBlocks$1(_), WY = [];
|
|
@@ -16203,19 +16244,19 @@ var POSTGRES_BUILTIN_TYPES = /* @__PURE__ */ "SMALLINT.INTEGER.INT.BIGINT.DECIMA
|
|
|
16203
16244
|
];
|
|
16204
16245
|
return concat_default(KY.schemas, KY.enums, KY.tables, KY.indexes, KY.comments, KY.refs, JY).join("\n");
|
|
16205
16246
|
}
|
|
16247
|
+
}, DbState = class {
|
|
16248
|
+
constructor() {
|
|
16249
|
+
this.dbId = 1, this.schemaId = 1, this.enumId = 1, this.tableGroupId = 1, this.refId = 1, this.tableId = 1, this.noteId = 1, this.enumValueId = 1, this.endpointId = 1, this.indexId = 1, this.checkId = 1, this.fieldId = 1, this.indexColumnId = 1, this.recordId = 1, this.tablePartialId = 1;
|
|
16250
|
+
}
|
|
16251
|
+
generateId(_) {
|
|
16252
|
+
let HY = this[_];
|
|
16253
|
+
return this[_] += 1, HY;
|
|
16254
|
+
}
|
|
16206
16255
|
}, ElementError = class extends Error {
|
|
16207
|
-
constructor(_, HY = {
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
offset: 0
|
|
16212
|
-
},
|
|
16213
|
-
end: {
|
|
16214
|
-
line: 1,
|
|
16215
|
-
column: 1,
|
|
16216
|
-
offset: 0
|
|
16217
|
-
}
|
|
16218
|
-
}) {
|
|
16256
|
+
constructor(_, HY = { start: {
|
|
16257
|
+
line: 1,
|
|
16258
|
+
column: 1
|
|
16259
|
+
} }) {
|
|
16219
16260
|
super(_), this.location = HY, this.error = "error";
|
|
16220
16261
|
}
|
|
16221
16262
|
}, element_default = class {
|
|
@@ -16228,8 +16269,207 @@ var POSTGRES_BUILTIN_TYPES = /* @__PURE__ */ "SMALLINT.INTEGER.INT.BIGINT.DECIMA
|
|
|
16228
16269
|
error(_) {
|
|
16229
16270
|
throw new ElementError(_, this.token);
|
|
16230
16271
|
}
|
|
16272
|
+
};
|
|
16273
|
+
init_lodash();
|
|
16274
|
+
var enumValue_default = class extends element_default {
|
|
16275
|
+
constructor({ name: _, token: HY, note: P, _enum: UY, noteToken: WY = null } = {}) {
|
|
16276
|
+
super(HY), _ || this.error("Enum value must have a name"), this.name = _, this.note = P ? get_default(P, "value", P) : null, this.noteToken = P ? get_default(P, "token", WY) : null, this._enum = UY, this.dbState = this._enum.dbState, this.generateId();
|
|
16277
|
+
}
|
|
16278
|
+
generateId() {
|
|
16279
|
+
this.id = this.dbState.generateId("enumValueId");
|
|
16280
|
+
}
|
|
16281
|
+
export() {
|
|
16282
|
+
return { ...this.shallowExport() };
|
|
16283
|
+
}
|
|
16284
|
+
exportParentIds() {
|
|
16285
|
+
return { enumId: this._enum.id };
|
|
16286
|
+
}
|
|
16287
|
+
shallowExport() {
|
|
16288
|
+
return {
|
|
16289
|
+
name: this.name,
|
|
16290
|
+
note: this.note
|
|
16291
|
+
};
|
|
16292
|
+
}
|
|
16293
|
+
normalize(_) {
|
|
16294
|
+
_.enumValues[this.id] = {
|
|
16295
|
+
id: this.id,
|
|
16296
|
+
...this.shallowExport(),
|
|
16297
|
+
...this.exportParentIds()
|
|
16298
|
+
};
|
|
16299
|
+
}
|
|
16300
|
+
};
|
|
16301
|
+
init_lodash();
|
|
16302
|
+
var enum_default = class extends element_default {
|
|
16303
|
+
constructor({ name: _, token: HY, values: P, note: UY, schema: WY, noteToken: GY = null } = {}) {
|
|
16304
|
+
super(HY), _ || this.error("Enum must have a name"), this.name = _, this.note = UY ? get_default(UY, "value", UY) : null, this.noteToken = UY ? get_default(UY, "token", GY) : null, this.values = [], this.fields = [], this.schema = WY, this.dbState = this.schema.dbState, this.generateId(), this.processValues(P);
|
|
16305
|
+
}
|
|
16306
|
+
generateId() {
|
|
16307
|
+
this.id = this.dbState.generateId("enumId");
|
|
16308
|
+
}
|
|
16309
|
+
processValues(_) {
|
|
16310
|
+
_.forEach((_) => {
|
|
16311
|
+
this.pushValue(new enumValue_default({
|
|
16312
|
+
..._,
|
|
16313
|
+
_enum: this
|
|
16314
|
+
}));
|
|
16315
|
+
});
|
|
16316
|
+
}
|
|
16317
|
+
pushValue(_) {
|
|
16318
|
+
this.checkValue(_), this.values.push(_);
|
|
16319
|
+
}
|
|
16320
|
+
checkValue(_) {
|
|
16321
|
+
this.values.some((HY) => HY.name === _.name) && _.error(`Enum value "${_.name}" existed in enum ${shouldPrintSchema$1(this.schema) ? `"${this.schema.name}".` : ""}"${this.name}"`);
|
|
16322
|
+
}
|
|
16323
|
+
pushField(_) {
|
|
16324
|
+
this.checkField(_), this.fields.push(_);
|
|
16325
|
+
}
|
|
16326
|
+
checkField(_) {
|
|
16327
|
+
this.fields.some((HY) => HY.id === _.id) && this.error(`Field ${shouldPrintSchema$1(_.table.schema) ? `"${_.table.schema.name}".` : ""}"${_.table.name}"."${_.name}" already associated with enum ${shouldPrintSchema$1(this.schema) ? `"${this.schema.name}".` : ""}${this.name}"`);
|
|
16328
|
+
}
|
|
16329
|
+
export() {
|
|
16330
|
+
return {
|
|
16331
|
+
...this.shallowExport(),
|
|
16332
|
+
...this.exportChild()
|
|
16333
|
+
};
|
|
16334
|
+
}
|
|
16335
|
+
exportChild() {
|
|
16336
|
+
return { values: this.values.map((_) => _.export()) };
|
|
16337
|
+
}
|
|
16338
|
+
exportChildIds() {
|
|
16339
|
+
return {
|
|
16340
|
+
valueIds: this.values.map((_) => _.id),
|
|
16341
|
+
fieldIds: this.fields.map((_) => _.id)
|
|
16342
|
+
};
|
|
16343
|
+
}
|
|
16344
|
+
exportParentIds() {
|
|
16345
|
+
return { schemaId: this.schema.id };
|
|
16346
|
+
}
|
|
16347
|
+
shallowExport() {
|
|
16348
|
+
return {
|
|
16349
|
+
name: this.name,
|
|
16350
|
+
note: this.note
|
|
16351
|
+
};
|
|
16352
|
+
}
|
|
16353
|
+
normalize(_) {
|
|
16354
|
+
_.enums[this.id] = {
|
|
16355
|
+
id: this.id,
|
|
16356
|
+
...this.shallowExport(),
|
|
16357
|
+
...this.exportChildIds(),
|
|
16358
|
+
...this.exportParentIds()
|
|
16359
|
+
}, this.values.forEach((HY) => HY.normalize(_));
|
|
16360
|
+
}
|
|
16361
|
+
}, endpoint_default = class extends element_default {
|
|
16362
|
+
constructor({ tableName: _, schemaName: HY, fieldNames: P, relation: UY, token: WY, ref: GY }) {
|
|
16363
|
+
super(WY), this.relation = UY, this.schemaName = HY, this.tableName = _, this.fieldNames = P, this.fields = [], this.ref = GY, this.dbState = this.ref.dbState, this.generateId();
|
|
16364
|
+
let KY = GY.schema.database.findOrCreateSchema(HY || "public").database.findTable(HY, _);
|
|
16365
|
+
KY || this.error(`Can't find table ${shouldPrintSchemaName(HY) ? `"${HY}".` : ""}"${_}"`), this.setFields(P, KY);
|
|
16366
|
+
}
|
|
16367
|
+
generateId() {
|
|
16368
|
+
this.id = this.dbState.generateId("endpointId");
|
|
16369
|
+
}
|
|
16370
|
+
equals(_) {
|
|
16371
|
+
return this.fields.length === _.fields.length ? this.compareFields(_) : !1;
|
|
16372
|
+
}
|
|
16373
|
+
compareFields(_) {
|
|
16374
|
+
let HY = this.fields.map((_) => _.id).sort(), P = _.fields.map((_) => _.id).sort();
|
|
16375
|
+
for (let _ = 0; _ < HY.length; _ += 1) if (HY[_] !== P[_]) return !1;
|
|
16376
|
+
return !0;
|
|
16377
|
+
}
|
|
16378
|
+
export() {
|
|
16379
|
+
return { ...this.shallowExport() };
|
|
16380
|
+
}
|
|
16381
|
+
exportParentIds() {
|
|
16382
|
+
return {
|
|
16383
|
+
refId: this.ref.id,
|
|
16384
|
+
fieldIds: this.fields.map((_) => _.id)
|
|
16385
|
+
};
|
|
16386
|
+
}
|
|
16387
|
+
shallowExport() {
|
|
16388
|
+
return {
|
|
16389
|
+
schemaName: this.schemaName,
|
|
16390
|
+
tableName: this.tableName,
|
|
16391
|
+
fieldNames: this.fieldNames,
|
|
16392
|
+
relation: this.relation
|
|
16393
|
+
};
|
|
16394
|
+
}
|
|
16395
|
+
setFields(_, HY) {
|
|
16396
|
+
let P = _ && _.length ? [..._] : [];
|
|
16397
|
+
if (!P.length) {
|
|
16398
|
+
let _ = HY.fields.find((_) => _.pk);
|
|
16399
|
+
if (_) P.push(_.name);
|
|
16400
|
+
else {
|
|
16401
|
+
let _ = HY.indexes.find((_) => _.pk);
|
|
16402
|
+
_ ? P = _.columns.map((_) => _.value) : this.error(`Can't find primary or composite key in table ${shouldPrintSchema$1(HY.schema) ? `"${HY.schema.name}".` : ""}"${HY.name}"`);
|
|
16403
|
+
}
|
|
16404
|
+
}
|
|
16405
|
+
P.forEach((_) => {
|
|
16406
|
+
let P = HY.findField(_);
|
|
16407
|
+
P || this.error(`Can't find field ${shouldPrintSchema$1(HY.schema) ? `"${HY.schema.name}".` : ""}"${_}" in table "${HY.name}"`), this.fields.push(P), P.pushEndpoint(this);
|
|
16408
|
+
});
|
|
16409
|
+
}
|
|
16410
|
+
normalize(_) {
|
|
16411
|
+
_.endpoints[this.id] = {
|
|
16412
|
+
id: this.id,
|
|
16413
|
+
...this.shallowExport(),
|
|
16414
|
+
...this.exportParentIds()
|
|
16415
|
+
};
|
|
16416
|
+
}
|
|
16417
|
+
};
|
|
16418
|
+
function isEqualPair(_, HY) {
|
|
16419
|
+
return _[0].equals(HY[0]) && _[1].equals(HY[1]);
|
|
16420
|
+
}
|
|
16421
|
+
var ref_default = class extends element_default {
|
|
16422
|
+
constructor({ name: _, color: HY, endpoints: P, onDelete: UY, onUpdate: WY, token: GY, schema: KY = {}, injectedPartial: qY = null } = {}) {
|
|
16423
|
+
super(GY), this.name = _, this.color = HY, this.onDelete = UY, this.onUpdate = WY, this.endpoints = [], this.schema = KY, this.injectedPartial = qY, this.dbState = this.schema.dbState, this.generateId(), this.processEndpoints(P);
|
|
16424
|
+
}
|
|
16425
|
+
generateId() {
|
|
16426
|
+
this.id = this.dbState.generateId("refId");
|
|
16427
|
+
}
|
|
16428
|
+
processEndpoints(_) {
|
|
16429
|
+
_.forEach((_) => {
|
|
16430
|
+
this.endpoints.push(new endpoint_default({
|
|
16431
|
+
..._,
|
|
16432
|
+
ref: this
|
|
16433
|
+
})), _.schemaName;
|
|
16434
|
+
}), this.endpoints[0].equals(this.endpoints[1]) && this.error("Two endpoints are the same"), this.endpoints[0].fields.length !== this.endpoints[1].fields.length && this.error("Two endpoints have unequal number of fields");
|
|
16435
|
+
}
|
|
16436
|
+
equals(_) {
|
|
16437
|
+
return isEqualPair(this.endpoints, _.endpoints) || isEqualPair(this.endpoints, _.endpoints.slice().reverse());
|
|
16438
|
+
}
|
|
16439
|
+
export() {
|
|
16440
|
+
return {
|
|
16441
|
+
...this.shallowExport(),
|
|
16442
|
+
...this.exportChild()
|
|
16443
|
+
};
|
|
16444
|
+
}
|
|
16445
|
+
shallowExport() {
|
|
16446
|
+
return {
|
|
16447
|
+
name: this.name,
|
|
16448
|
+
color: this.color,
|
|
16449
|
+
onDelete: this.onDelete,
|
|
16450
|
+
onUpdate: this.onUpdate,
|
|
16451
|
+
injectedPartialId: this.injectedPartial?.id
|
|
16452
|
+
};
|
|
16453
|
+
}
|
|
16454
|
+
exportChild() {
|
|
16455
|
+
return { endpoints: this.endpoints.map((_) => _.export()) };
|
|
16456
|
+
}
|
|
16457
|
+
exportChildIds() {
|
|
16458
|
+
return { endpointIds: this.endpoints.map((_) => _.id) };
|
|
16459
|
+
}
|
|
16460
|
+
exportParentIds() {
|
|
16461
|
+
return { schemaId: this.schema.id };
|
|
16462
|
+
}
|
|
16463
|
+
normalize(_) {
|
|
16464
|
+
_.refs[this.id] = {
|
|
16465
|
+
id: this.id,
|
|
16466
|
+
...this.shallowExport(),
|
|
16467
|
+
...this.exportChildIds(),
|
|
16468
|
+
...this.exportParentIds()
|
|
16469
|
+
}, this.endpoints.forEach((HY) => HY.normalize(_));
|
|
16470
|
+
}
|
|
16231
16471
|
}, check_default = class extends element_default {
|
|
16232
|
-
constructor({ token: _, name: HY, expression: P, table: UY, column: WY = null, injectedPartial: GY = null }) {
|
|
16472
|
+
constructor({ token: _, name: HY, expression: P, table: UY, column: WY = null, injectedPartial: GY = null } = {}) {
|
|
16233
16473
|
super(_), this.name = HY, this.expression = P, this.table = UY, this.column = WY, this.injectedPartial = GY, this.dbState = this.table.dbState, this.generateId();
|
|
16234
16474
|
}
|
|
16235
16475
|
generateId() {
|
|
@@ -16241,8 +16481,8 @@ var POSTGRES_BUILTIN_TYPES = /* @__PURE__ */ "SMALLINT.INTEGER.INT.BIGINT.DECIMA
|
|
|
16241
16481
|
exportParentIds() {
|
|
16242
16482
|
return {
|
|
16243
16483
|
tableId: this.table.id,
|
|
16244
|
-
columnId: this.column?.id
|
|
16245
|
-
injectedPartialId: this.injectedPartial?.id
|
|
16484
|
+
columnId: this.column?.id,
|
|
16485
|
+
injectedPartialId: this.injectedPartial?.id
|
|
16246
16486
|
};
|
|
16247
16487
|
}
|
|
16248
16488
|
shallowExport() {
|
|
@@ -16252,9 +16492,8 @@ var POSTGRES_BUILTIN_TYPES = /* @__PURE__ */ "SMALLINT.INTEGER.INT.BIGINT.DECIMA
|
|
|
16252
16492
|
};
|
|
16253
16493
|
}
|
|
16254
16494
|
normalize(_) {
|
|
16255
|
-
|
|
16256
|
-
|
|
16257
|
-
id: HY,
|
|
16495
|
+
_.checks[this.id] = {
|
|
16496
|
+
id: this.id,
|
|
16258
16497
|
...this.shallowExport(),
|
|
16259
16498
|
...this.exportParentIds()
|
|
16260
16499
|
};
|
|
@@ -16262,7 +16501,7 @@ var POSTGRES_BUILTIN_TYPES = /* @__PURE__ */ "SMALLINT.INTEGER.INT.BIGINT.DECIMA
|
|
|
16262
16501
|
};
|
|
16263
16502
|
init_lodash();
|
|
16264
16503
|
var field_default = class extends element_default {
|
|
16265
|
-
constructor({ name: _, type: HY, unique: P, pk: UY, token: WY, not_null: GY, note: KY, dbdefault: qY, increment: JY, checks: YY = [], table: XY = {}, noteToken: ZY = null, injectedPartial: QY = null, injectedToken: $Y = null }) {
|
|
16504
|
+
constructor({ name: _, type: HY, unique: P, pk: UY, token: WY, not_null: GY, note: KY, dbdefault: qY, increment: JY, checks: YY = [], table: XY = {}, noteToken: ZY = null, injectedPartial: QY = null, injectedToken: $Y = null } = {}) {
|
|
16266
16505
|
super(WY), _ || this.error("Field must have a name"), HY || this.error("Field must have a type"), this.name = _, this.type = HY, this.unique = P, this.pk = UY, this.not_null = GY, this.note = KY ? get_default(KY, "value", KY) : null, this.noteToken = KY ? get_default(KY, "token", ZY) : null, this.dbdefault = qY, this.increment = JY, this.checks = [], this.endpoints = [], this.table = XY, this.injectedPartial = QY, this.injectedToken = $Y, this.dbState = this.table.dbState, this.generateId(), this.bindType(), this.processChecks(YY);
|
|
16267
16506
|
}
|
|
16268
16507
|
generateId() {
|
|
@@ -16331,7 +16570,7 @@ var field_default = class extends element_default {
|
|
|
16331
16570
|
}
|
|
16332
16571
|
}, indexColumn_default = class extends element_default {
|
|
16333
16572
|
constructor({ type: _, value: HY, index: P, token: UY }) {
|
|
16334
|
-
super(
|
|
16573
|
+
super(), this.type = _, this.value = HY, this.index = P, this.token = UY, this.dbState = this.index.dbState, this.generateId();
|
|
16335
16574
|
}
|
|
16336
16575
|
generateId() {
|
|
16337
16576
|
this.id = this.dbState.generateId("indexColumnId");
|
|
@@ -16356,7 +16595,7 @@ var field_default = class extends element_default {
|
|
|
16356
16595
|
};
|
|
16357
16596
|
}
|
|
16358
16597
|
}, indexes_default = class extends element_default {
|
|
16359
|
-
constructor({ columns: _, type: HY, unique: P, pk: UY, token: WY, name: GY, note: KY, table: qY = {}, injectedPartial: JY = null }) {
|
|
16598
|
+
constructor({ columns: _, type: HY, unique: P, pk: UY, token: WY, name: GY, note: KY, table: qY = {}, injectedPartial: JY = null } = {}) {
|
|
16360
16599
|
super(WY), this.name = GY, this.type = HY, this.unique = P, this.note = KY ? KY.value : null, this.noteToken = KY ? KY.token : null, this.pk = UY, this.columns = [], this.table = qY, this.injectedPartial = JY, this.dbState = this.table.dbState, this.generateId(), this.processIndexColumns(_);
|
|
16361
16600
|
}
|
|
16362
16601
|
generateId() {
|
|
@@ -16412,7 +16651,7 @@ var field_default = class extends element_default {
|
|
|
16412
16651
|
};
|
|
16413
16652
|
init_lodash();
|
|
16414
16653
|
var table_default = class extends element_default {
|
|
16415
|
-
constructor({ name: _, alias: HY, note: P, fields: UY = [], indexes: WY = [], checks: GY = [], schema: KY = {}, token: qY, headerColor: JY, noteToken: YY = null, partials: XY = [] }) {
|
|
16654
|
+
constructor({ name: _, alias: HY, note: P, fields: UY = [], indexes: WY = [], checks: GY = [], schema: KY = {}, token: qY, headerColor: JY, noteToken: YY = null, partials: XY = [] } = {}) {
|
|
16416
16655
|
super(qY), this.name = _, this.alias = HY, this.note = P ? get_default(P, "value", P) : null, this.noteToken = P ? get_default(P, "token", YY) : null, this.headerColor = JY, this.fields = [], this.indexes = [], this.checks = [], this.schema = KY, this.partials = XY, this.records = [], this.dbState = this.schema.dbState, this.generateId(), this.processFields(UY), this.processPartials(), this.checkFieldCount(), this.processIndexes(WY), this.processChecks(GY);
|
|
16417
16656
|
}
|
|
16418
16657
|
generateId() {
|
|
@@ -16466,18 +16705,18 @@ var table_default = class extends element_default {
|
|
|
16466
16705
|
return this.fields.find((HY) => HY.name === _);
|
|
16467
16706
|
}
|
|
16468
16707
|
checkSameId(_) {
|
|
16469
|
-
return this.schema.checkSameId(_.schemaName || "public") && (this.name === _.name || this.alias === _.name || this.name === _.alias ||
|
|
16708
|
+
return this.schema.checkSameId(_.schemaName || "public") && (this.name === _.name || this.alias === _.name || this.name === _.alias || this.alias && this.alias === _.alias);
|
|
16470
16709
|
}
|
|
16471
16710
|
processPartials() {
|
|
16472
16711
|
if (!this.partials?.length) return;
|
|
16473
16712
|
let _ = new Set(this.fields.map((_) => _.name)), HY = /* @__PURE__ */ new Set();
|
|
16474
16713
|
isNil_default(this.note) || HY.add("note"), isNil_default(this.headerColor) || HY.add("headerColor");
|
|
16475
16714
|
let P = this.partials.sort((_, HY) => HY.order - _.order);
|
|
16476
|
-
|
|
16715
|
+
P.toReversed().forEach((_) => {
|
|
16477
16716
|
this.fields.splice(_.order, 0, "dummy");
|
|
16478
16717
|
}), P.forEach((P) => {
|
|
16479
16718
|
let UY = this.schema.database.findTablePartial(P.name);
|
|
16480
|
-
if (UY || this.error(`Table partial ${P.name} not found
|
|
16719
|
+
if (UY || this.error(`Table partial ${P.name} not found`, P.token), P.id = UY.id, UY.fields) {
|
|
16481
16720
|
let HY = UY.fields.filter((HY) => !_.has(HY.name)).map((HY) => (_.add(HY.name), HY.inline_refs && HY.inline_refs.forEach((_) => {
|
|
16482
16721
|
let P = {
|
|
16483
16722
|
token: HY.token,
|
|
@@ -16567,95 +16806,6 @@ var table_default = class extends element_default {
|
|
|
16567
16806
|
}
|
|
16568
16807
|
};
|
|
16569
16808
|
init_lodash();
|
|
16570
|
-
var enumValue_default = class extends element_default {
|
|
16571
|
-
constructor({ name: _, token: HY, note: P, _enum: UY, noteToken: WY = null }) {
|
|
16572
|
-
super(HY), _ || this.error("Enum value must have a name"), this.name = _, this.note = P ? get_default(P, "value", P) : null, this.noteToken = P ? get_default(P, "token", WY) : null, this._enum = UY, this.dbState = this._enum.dbState, this.generateId();
|
|
16573
|
-
}
|
|
16574
|
-
generateId() {
|
|
16575
|
-
this.id = this.dbState.generateId("enumValueId");
|
|
16576
|
-
}
|
|
16577
|
-
export() {
|
|
16578
|
-
return { ...this.shallowExport() };
|
|
16579
|
-
}
|
|
16580
|
-
exportParentIds() {
|
|
16581
|
-
return { enumId: this._enum.id };
|
|
16582
|
-
}
|
|
16583
|
-
shallowExport() {
|
|
16584
|
-
return {
|
|
16585
|
-
name: this.name,
|
|
16586
|
-
note: this.note
|
|
16587
|
-
};
|
|
16588
|
-
}
|
|
16589
|
-
normalize(_) {
|
|
16590
|
-
_.enumValues[this.id] = {
|
|
16591
|
-
id: this.id,
|
|
16592
|
-
...this.shallowExport(),
|
|
16593
|
-
...this.exportParentIds()
|
|
16594
|
-
};
|
|
16595
|
-
}
|
|
16596
|
-
};
|
|
16597
|
-
init_lodash();
|
|
16598
|
-
var enum_default = class extends element_default {
|
|
16599
|
-
constructor({ name: _, token: HY, values: P, note: UY, schema: WY, noteToken: GY = null }) {
|
|
16600
|
-
super(HY), _ || this.error("Enum must have a name"), this.name = _, this.note = UY ? get_default(UY, "value", UY) : null, this.noteToken = UY ? get_default(UY, "token", GY) : null, this.values = [], this.fields = [], this.schema = WY, this.dbState = this.schema.dbState, this.generateId(), this.processValues(P);
|
|
16601
|
-
}
|
|
16602
|
-
generateId() {
|
|
16603
|
-
this.id = this.dbState.generateId("enumId");
|
|
16604
|
-
}
|
|
16605
|
-
processValues(_) {
|
|
16606
|
-
_.forEach((_) => {
|
|
16607
|
-
this.pushValue(new enumValue_default({
|
|
16608
|
-
..._,
|
|
16609
|
-
_enum: this
|
|
16610
|
-
}));
|
|
16611
|
-
});
|
|
16612
|
-
}
|
|
16613
|
-
pushValue(_) {
|
|
16614
|
-
this.checkValue(_), this.values.push(_);
|
|
16615
|
-
}
|
|
16616
|
-
checkValue(_) {
|
|
16617
|
-
this.values.some((HY) => HY.name === _.name) && _.error(`Enum value "${_.name}" existed in enum ${shouldPrintSchema$1(this.schema) ? `"${this.schema.name}".` : ""}"${this.name}"`);
|
|
16618
|
-
}
|
|
16619
|
-
pushField(_) {
|
|
16620
|
-
this.checkField(_), this.fields.push(_);
|
|
16621
|
-
}
|
|
16622
|
-
checkField(_) {
|
|
16623
|
-
this.fields.some((HY) => HY.id === _.id) && this.error(`Field ${shouldPrintSchema$1(_.table.schema) ? `"${_.table.schema.name}".` : ""}"${_.table.name}"."${_.name}" already associated with enum ${shouldPrintSchema$1(this.schema) ? `"${this.schema.name}".` : ""}${this.name}"`);
|
|
16624
|
-
}
|
|
16625
|
-
export() {
|
|
16626
|
-
return {
|
|
16627
|
-
...this.shallowExport(),
|
|
16628
|
-
...this.exportChild()
|
|
16629
|
-
};
|
|
16630
|
-
}
|
|
16631
|
-
exportChild() {
|
|
16632
|
-
return { values: this.values.map((_) => _.export()) };
|
|
16633
|
-
}
|
|
16634
|
-
exportChildIds() {
|
|
16635
|
-
return {
|
|
16636
|
-
valueIds: this.values.map((_) => _.id),
|
|
16637
|
-
fieldIds: this.fields.map((_) => _.id)
|
|
16638
|
-
};
|
|
16639
|
-
}
|
|
16640
|
-
exportParentIds() {
|
|
16641
|
-
return { schemaId: this.schema.id };
|
|
16642
|
-
}
|
|
16643
|
-
shallowExport() {
|
|
16644
|
-
return {
|
|
16645
|
-
name: this.name,
|
|
16646
|
-
note: this.note
|
|
16647
|
-
};
|
|
16648
|
-
}
|
|
16649
|
-
normalize(_) {
|
|
16650
|
-
_.enums[this.id] = {
|
|
16651
|
-
id: this.id,
|
|
16652
|
-
...this.shallowExport(),
|
|
16653
|
-
...this.exportChildIds(),
|
|
16654
|
-
...this.exportParentIds()
|
|
16655
|
-
}, this.values.forEach((HY) => HY.normalize(_));
|
|
16656
|
-
}
|
|
16657
|
-
};
|
|
16658
|
-
init_lodash();
|
|
16659
16809
|
var tableGroup_default = class extends element_default {
|
|
16660
16810
|
constructor({ name: _, token: HY, tables: P = [], schema: UY = {}, note: WY, color: GY, noteToken: KY = null }) {
|
|
16661
16811
|
super(HY), this.name = _, this.tables = [], this.schema = UY, this.dbState = this.schema.dbState, this.note = WY ? get_default(WY, "value", WY) : null, this.noteToken = WY ? get_default(WY, "token", KY) : null, this.color = GY, this.generateId(), this.processTables(P);
|
|
@@ -16708,120 +16858,10 @@ var tableGroup_default = class extends element_default {
|
|
|
16708
16858
|
...this.exportParentIds()
|
|
16709
16859
|
};
|
|
16710
16860
|
}
|
|
16711
|
-
}, endpoint_default = class extends element_default {
|
|
16712
|
-
constructor({ tableName: _, schemaName: HY, fieldNames: P, relation: UY, token: WY, ref: GY }) {
|
|
16713
|
-
super(WY), this.relation = UY, this.schemaName = HY, this.tableName = _, this.fieldNames = P, this.fields = [], this.ref = GY, this.dbState = this.ref.dbState, this.generateId();
|
|
16714
|
-
let KY = GY.schema.database.findOrCreateSchema(HY || "public").database.findTable(HY, _);
|
|
16715
|
-
KY || this.error(`Can't find table ${shouldPrintSchemaName(HY) ? `"${HY}".` : ""}"${_}"`), this.setFields(P, KY);
|
|
16716
|
-
}
|
|
16717
|
-
generateId() {
|
|
16718
|
-
this.id = this.dbState.generateId("endpointId");
|
|
16719
|
-
}
|
|
16720
|
-
equals(_) {
|
|
16721
|
-
return this.fields.length === _.fields.length ? this.compareFields(_) : !1;
|
|
16722
|
-
}
|
|
16723
|
-
compareFields(_) {
|
|
16724
|
-
let HY = this.fields.map((_) => _.id).sort(), P = _.fields.map((_) => _.id).sort();
|
|
16725
|
-
for (let _ = 0; _ < HY.length; _ += 1) if (HY[_] !== P[_]) return !1;
|
|
16726
|
-
return !0;
|
|
16727
|
-
}
|
|
16728
|
-
export() {
|
|
16729
|
-
return { ...this.shallowExport() };
|
|
16730
|
-
}
|
|
16731
|
-
exportParentIds() {
|
|
16732
|
-
return {
|
|
16733
|
-
refId: this.ref.id,
|
|
16734
|
-
fieldIds: this.fields.map((_) => _.id)
|
|
16735
|
-
};
|
|
16736
|
-
}
|
|
16737
|
-
shallowExport() {
|
|
16738
|
-
return {
|
|
16739
|
-
schemaName: this.schemaName,
|
|
16740
|
-
tableName: this.tableName,
|
|
16741
|
-
fieldNames: this.fieldNames,
|
|
16742
|
-
relation: this.relation
|
|
16743
|
-
};
|
|
16744
|
-
}
|
|
16745
|
-
setFields(_, HY) {
|
|
16746
|
-
let P = _ && _.length ? [..._] : [];
|
|
16747
|
-
if (!P.length) {
|
|
16748
|
-
let _ = HY.fields.find((_) => _.pk);
|
|
16749
|
-
if (_) P.push(_.name);
|
|
16750
|
-
else {
|
|
16751
|
-
let _ = HY.indexes.find((_) => _.pk);
|
|
16752
|
-
_ ? P = _.columns.map((_) => _.value) : this.error(`Can't find primary or composite key in table ${shouldPrintSchema$1(HY.schema) ? `"${HY.schema.name}".` : ""}"${HY.name}"`);
|
|
16753
|
-
}
|
|
16754
|
-
}
|
|
16755
|
-
P.forEach((_) => {
|
|
16756
|
-
let P = HY.findField(_);
|
|
16757
|
-
P || this.error(`Can't find field ${shouldPrintSchema$1(HY.schema) ? `"${HY.schema.name}".` : ""}"${_}" in table "${HY.name}"`), this.fields.push(P), P.pushEndpoint(this);
|
|
16758
|
-
});
|
|
16759
|
-
}
|
|
16760
|
-
normalize(_) {
|
|
16761
|
-
_.endpoints[this.id] = {
|
|
16762
|
-
id: this.id,
|
|
16763
|
-
...this.shallowExport(),
|
|
16764
|
-
...this.exportParentIds()
|
|
16765
|
-
};
|
|
16766
|
-
}
|
|
16767
|
-
};
|
|
16768
|
-
function isEqualPair(_, HY) {
|
|
16769
|
-
return _[0].equals(HY[0]) && _[1].equals(HY[1]);
|
|
16770
|
-
}
|
|
16771
|
-
var ref_default = class extends element_default {
|
|
16772
|
-
constructor({ name: _, color: HY, endpoints: P, onDelete: UY, onUpdate: WY, token: GY, schema: KY = {}, injectedPartial: qY = void 0 }) {
|
|
16773
|
-
super(GY), this.name = _, this.color = HY, this.onDelete = UY, this.onUpdate = WY, this.endpoints = [], this.schema = KY, this.injectedPartial = qY, this.dbState = this.schema.dbState, this.generateId(), this.processEndpoints(P);
|
|
16774
|
-
}
|
|
16775
|
-
generateId() {
|
|
16776
|
-
this.id = this.dbState.generateId("refId");
|
|
16777
|
-
}
|
|
16778
|
-
processEndpoints(_) {
|
|
16779
|
-
_.forEach((_) => {
|
|
16780
|
-
this.endpoints.push(new endpoint_default({
|
|
16781
|
-
..._,
|
|
16782
|
-
ref: this
|
|
16783
|
-
})), _.schemaName;
|
|
16784
|
-
}), this.endpoints[0].equals(this.endpoints[1]) && this.error("Two endpoints are the same"), this.endpoints[0].fields.length !== this.endpoints[1].fields.length && this.error("Two endpoints have unequal number of fields");
|
|
16785
|
-
}
|
|
16786
|
-
equals(_) {
|
|
16787
|
-
return isEqualPair(this.endpoints, _.endpoints) || isEqualPair(this.endpoints, _.endpoints.slice().reverse());
|
|
16788
|
-
}
|
|
16789
|
-
export() {
|
|
16790
|
-
return {
|
|
16791
|
-
...this.shallowExport(),
|
|
16792
|
-
...this.exportChild()
|
|
16793
|
-
};
|
|
16794
|
-
}
|
|
16795
|
-
shallowExport() {
|
|
16796
|
-
return {
|
|
16797
|
-
name: this.name,
|
|
16798
|
-
color: this.color,
|
|
16799
|
-
onDelete: this.onDelete,
|
|
16800
|
-
onUpdate: this.onUpdate,
|
|
16801
|
-
injectedPartialId: this.injectedPartial?.id
|
|
16802
|
-
};
|
|
16803
|
-
}
|
|
16804
|
-
exportChild() {
|
|
16805
|
-
return { endpoints: this.endpoints.map((_) => _.export()) };
|
|
16806
|
-
}
|
|
16807
|
-
exportChildIds() {
|
|
16808
|
-
return { endpointIds: this.endpoints.map((_) => _.id) };
|
|
16809
|
-
}
|
|
16810
|
-
exportParentIds() {
|
|
16811
|
-
return { schemaId: this.schema.id };
|
|
16812
|
-
}
|
|
16813
|
-
normalize(_) {
|
|
16814
|
-
_.refs[this.id] = {
|
|
16815
|
-
id: this.id,
|
|
16816
|
-
...this.shallowExport(),
|
|
16817
|
-
...this.exportChildIds(),
|
|
16818
|
-
...this.exportParentIds()
|
|
16819
|
-
}, this.endpoints.forEach((HY) => HY.normalize(_));
|
|
16820
|
-
}
|
|
16821
16861
|
};
|
|
16822
16862
|
init_lodash();
|
|
16823
16863
|
var schema_default = class extends element_default {
|
|
16824
|
-
constructor({ name: _, alias: HY, note: P, tables: UY = [], refs: WY = [], enums: GY = [], tableGroups: KY = [], token: qY, database: JY = {}, noteToken: YY = null }) {
|
|
16864
|
+
constructor({ name: _, alias: HY, note: P, tables: UY = [], refs: WY = [], enums: GY = [], tableGroups: KY = [], token: qY, database: JY = {}, noteToken: YY = null } = {}) {
|
|
16825
16865
|
super(qY), this.tables = [], this.enums = [], this.tableGroups = [], this.refs = [], this.name = _, this.note = P ? get_default(P, "value", P) : null, this.noteToken = P ? get_default(P, "token", YY) : null, this.alias = HY, this.database = JY, this.dbState = this.database.dbState, this.generateId(), this.processEnums(GY), this.processTables(UY), this.processRefs(WY), this.processTableGroups(KY);
|
|
16826
16866
|
}
|
|
16827
16867
|
generateId() {
|
|
@@ -16871,7 +16911,7 @@ var schema_default = class extends element_default {
|
|
|
16871
16911
|
}
|
|
16872
16912
|
checkRef(_) {
|
|
16873
16913
|
if (this.refs.some((HY) => HY.equals(_))) {
|
|
16874
|
-
let HY = _.endpoints[0], P = HY.fieldNames.map(
|
|
16914
|
+
let HY = _.endpoints[0], P = HY.fieldNames.map(JSON.stringify).join(", "), UY = _.endpoints[1], WY = UY.fieldNames.map(JSON.stringify).join(", "), GY = `"${HY.schemaName ? `${HY.schemaName}"."` : ""}${HY.tableName}"(${P})`, KY = `"${UY.schemaName ? `${UY.schemaName}"."` : ""}${UY.tableName}"(${WY})`;
|
|
16875
16915
|
_.error(`Reference with the same endpoints already exists: ${GY} references ${KY}`);
|
|
16876
16916
|
}
|
|
16877
16917
|
}
|
|
@@ -16890,7 +16930,7 @@ var schema_default = class extends element_default {
|
|
|
16890
16930
|
this.tableGroups.some((HY) => HY.name === _.name) && _.error(`Table Group ${shouldPrintSchema$1(this) ? `"${this.name}".` : ""}"${_.name}" existed`);
|
|
16891
16931
|
}
|
|
16892
16932
|
checkSameId(_) {
|
|
16893
|
-
return this.name === _.name || this.alias === _.name || this.name === _.alias ||
|
|
16933
|
+
return this.name === _.name || this.alias === _.name || this.name === _.alias || this.alias && this.alias === _.alias;
|
|
16894
16934
|
}
|
|
16895
16935
|
export() {
|
|
16896
16936
|
return {
|
|
@@ -16933,7 +16973,7 @@ var schema_default = class extends element_default {
|
|
|
16933
16973
|
}, this.tables.forEach((HY) => HY.normalize(_)), this.enums.forEach((HY) => HY.normalize(_)), this.tableGroups.forEach((HY) => HY.normalize(_)), this.refs.forEach((HY) => HY.normalize(_));
|
|
16934
16974
|
}
|
|
16935
16975
|
}, stickyNote_default = class extends element_default {
|
|
16936
|
-
constructor({ name: _, content: HY, headerColor: P, token: UY, database: WY = {} }) {
|
|
16976
|
+
constructor({ name: _, content: HY, headerColor: P, token: UY, database: WY = {} } = {}) {
|
|
16937
16977
|
super(UY), this.name = _, this.content = HY, this.headerColor = P, this.database = WY, this.dbState = this.database.dbState, this.generateId();
|
|
16938
16978
|
}
|
|
16939
16979
|
generateId() {
|
|
@@ -16952,18 +16992,10 @@ var schema_default = class extends element_default {
|
|
|
16952
16992
|
...this.export()
|
|
16953
16993
|
};
|
|
16954
16994
|
}
|
|
16955
|
-
}, DbState = class {
|
|
16956
|
-
constructor() {
|
|
16957
|
-
this.dbId = 1, this.schemaId = 1, this.enumId = 1, this.tableGroupId = 1, this.refId = 1, this.tableId = 1, this.noteId = 1, this.enumValueId = 1, this.endpointId = 1, this.indexId = 1, this.checkId = 1, this.fieldId = 1, this.indexColumnId = 1, this.recordId = 1, this.tablePartialId = 1;
|
|
16958
|
-
}
|
|
16959
|
-
generateId(_) {
|
|
16960
|
-
let HY = this[_];
|
|
16961
|
-
return this[_] += 1, HY;
|
|
16962
|
-
}
|
|
16963
16995
|
};
|
|
16964
16996
|
init_lodash();
|
|
16965
16997
|
var tablePartial_default = class extends element_default {
|
|
16966
|
-
constructor({ name: _, note: HY, fields: P = [], indexes: UY = [], checks: WY = [], token: GY, headerColor: KY, noteToken: qY = null, dbState: JY }) {
|
|
16998
|
+
constructor({ name: _, note: HY, fields: P = [], indexes: UY = [], checks: WY = [], token: GY, headerColor: KY, noteToken: qY = null, dbState: JY } = {}) {
|
|
16967
16999
|
super(GY), this.name = _, this.note = HY ? get_default(HY, "value", HY) : null, this.noteToken = HY ? get_default(HY, "token", qY) : null, this.headerColor = KY, this.fields = P, this.indexes = UY, this.checks = WY, this.dbState = JY, this.generateId();
|
|
16968
17000
|
}
|
|
16969
17001
|
generateId() {
|
|
@@ -16991,7 +17023,7 @@ var tablePartial_default = class extends element_default {
|
|
|
16991
17023
|
init_lodash();
|
|
16992
17024
|
var database_default = class extends element_default {
|
|
16993
17025
|
constructor({ schemas: _ = [], tables: HY = [], notes: P = [], enums: UY = [], refs: WY = [], tableGroups: GY = [], project: KY = {}, aliases: qY = [], records: JY = [], tablePartials: YY = [] }) {
|
|
16994
|
-
super(
|
|
17026
|
+
super(), this.dbState = new DbState(), this.generateId(), this.hasDefaultSchema = !1, this.schemas = [], this.notes = [], this.note = KY.note ? get_default(KY, "note.value", KY.note) : null, this.noteToken = KY.note ? get_default(KY, "note.token", KY.noteToken) : null, this.databaseType = KY.database_type, this.name = KY.name, this.token = KY.token, this.aliases = qY, this.records = [], this.tablePartials = [], this.injectedRawRefs = [], this.processNotes(P), this.processRecords(JY), this.processTablePartials(YY), this.processSchemas(_), this.processSchemaElements(UY, ENUM), this.processSchemaElements(HY, TABLE), this.linkRecordsToTables(), this.processSchemaElements(P, "note"), this.processSchemaElements(WY, "ref"), this.processSchemaElements(GY, TABLE_GROUP), this.injectedRawRefs.forEach((_) => {
|
|
16995
17027
|
let HY = this.findOrCreateSchema(DEFAULT_SCHEMA_NAME), P = new ref_default({
|
|
16996
17028
|
..._,
|
|
16997
17029
|
schema: HY
|
|
@@ -17097,30 +17129,27 @@ var database_default = class extends element_default {
|
|
|
17097
17129
|
let HY = this.schemas.find((HY) => HY.name === _ || HY.alias === _);
|
|
17098
17130
|
return HY || (HY = new schema_default({
|
|
17099
17131
|
name: _,
|
|
17100
|
-
note: {
|
|
17101
|
-
value: _ === "public" ? `Default ${capitalize_default(DEFAULT_SCHEMA_NAME)} Schema` : null,
|
|
17102
|
-
token: void 0
|
|
17103
|
-
},
|
|
17132
|
+
note: { value: _ === "public" ? `Default ${capitalize_default(DEFAULT_SCHEMA_NAME)} Schema` : null },
|
|
17104
17133
|
database: this
|
|
17105
17134
|
}), this.pushSchema(HY)), HY;
|
|
17106
17135
|
}
|
|
17107
17136
|
findTableAlias(_) {
|
|
17108
17137
|
let HY = this.aliases.find((HY) => HY.name === _);
|
|
17109
|
-
if (!HY || HY.kind !== "table") return;
|
|
17138
|
+
if (!HY || HY.kind !== "table") return null;
|
|
17110
17139
|
let P = HY.value.schemaName || "public", UY = this.schemas.find((_) => _.name === P);
|
|
17111
|
-
if (!UY) return;
|
|
17140
|
+
if (!UY) return null;
|
|
17112
17141
|
let { tableName: WY } = HY.value;
|
|
17113
17142
|
return UY.tables.find((_) => _.name === WY);
|
|
17114
17143
|
}
|
|
17115
17144
|
findTable(_, HY) {
|
|
17116
|
-
let P;
|
|
17145
|
+
let P = null;
|
|
17117
17146
|
if (!_ && (P = this.findTableAlias(HY), P)) return P;
|
|
17118
17147
|
let UY = this.findOrCreateSchema(_ || "public");
|
|
17119
17148
|
return UY || this.error(`Schema ${_ || "public"} don't exist`), UY.findTable(HY);
|
|
17120
17149
|
}
|
|
17121
17150
|
findEnum(_, HY) {
|
|
17122
17151
|
let P = this.schemas.find((HY) => HY.name === _ || HY.alias === _);
|
|
17123
|
-
|
|
17152
|
+
return P ? P.enums.find((_) => _.name === HY) : null;
|
|
17124
17153
|
}
|
|
17125
17154
|
findTablePartial(_) {
|
|
17126
17155
|
return this.tablePartials.find((HY) => HY.name === _);
|
|
@@ -1822011,5 +1822040,5 @@ function findDiagramViewBlocks(_) {
|
|
|
1822011
1822040
|
let HY = new Compiler();
|
|
1822012
1822041
|
return HY.setSource(_), HY.findDiagramViewBlocks();
|
|
1822013
1822042
|
}
|
|
1822014
|
-
const VERSION = "7.1.
|
|
1822043
|
+
const VERSION = "7.1.1";
|
|
1822015
1822044
|
export { CompilerError, ModelExporter_default as ModelExporter, Parser_default as Parser, VERSION, addDoubleQuoteIfNeeded, dbmlMonarchTokensProvider, export_default as exporter, findDiagramViewBlocks, formatRecordValue, import_default as importer, isBinaryType, isBooleanType, isDateTimeType, isFloatType, isIntegerType, isNumericType, isSerialType, isStringType, renameTable, syncDiagramView, tryExtractBoolean, tryExtractDateTime, tryExtractEnum, tryExtractInteger, tryExtractNumeric, tryExtractString };
|