@ronin/compiler 0.12.8 → 0.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.d.ts +136 -15444
- package/dist/index.js +10 -9
- package/package.json +2 -3
package/dist/index.js
CHANGED
@@ -638,7 +638,7 @@ var typesInSQLite = {
|
|
638
638
|
json: "TEXT"
|
639
639
|
};
|
640
640
|
var getFieldStatement = (models, model, field) => {
|
641
|
-
let statement = `"${field.slug}" ${typesInSQLite[field.type]}`;
|
641
|
+
let statement = `"${field.slug}" ${typesInSQLite[field.type || "string"]}`;
|
642
642
|
if (field.slug === "id") statement += " PRIMARY KEY";
|
643
643
|
if (field.unique === true) statement += " UNIQUE";
|
644
644
|
if (field.required === true) statement += " NOT NULL";
|
@@ -688,7 +688,7 @@ var handleSystemModel = (models, dependencyStatements, action, systemModel, newM
|
|
688
688
|
const query = {
|
689
689
|
[action]: { model: action === "create" ? systemModelClean : systemModelClean.slug }
|
690
690
|
};
|
691
|
-
if (action === "alter" && newModel) {
|
691
|
+
if (action === "alter" && newModel && "alter" in query && query.alter) {
|
692
692
|
const { system: _2, ...newModelClean } = newModel;
|
693
693
|
query.alter.to = newModelClean;
|
694
694
|
}
|
@@ -697,19 +697,19 @@ var handleSystemModel = (models, dependencyStatements, action, systemModel, newM
|
|
697
697
|
};
|
698
698
|
var transformMetaQuery = (models, dependencyStatements, statementParams, query) => {
|
699
699
|
const { queryType } = splitQuery(query);
|
700
|
-
const subAltering = query.alter && !("to" in query.alter);
|
700
|
+
const subAltering = "alter" in query && query.alter && !("to" in query.alter);
|
701
701
|
const action = subAltering && query.alter ? Object.keys(query.alter).filter((key) => key !== "model")[0] : queryType;
|
702
702
|
const actionReadable = action === "create" ? "creating" : action === "alter" ? "altering" : "dropping";
|
703
703
|
const entity = subAltering && query.alter ? Object.keys(query.alter[action])[0] : "model";
|
704
704
|
let slug = entity === "model" && action === "create" ? null : query[queryType].model;
|
705
705
|
let modelSlug = slug;
|
706
706
|
let jsonValue;
|
707
|
-
if (query.create) {
|
707
|
+
if ("create" in query && query.create) {
|
708
708
|
const init = query.create.model;
|
709
709
|
jsonValue = "to" in query.create ? { slug: init, ...query.create.to } : init;
|
710
710
|
slug = modelSlug = jsonValue.slug;
|
711
711
|
}
|
712
|
-
if (query.alter) {
|
712
|
+
if ("alter" in query && query.alter) {
|
713
713
|
if ("to" in query.alter) {
|
714
714
|
jsonValue = query.alter.to;
|
715
715
|
} else {
|
@@ -719,7 +719,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query)
|
|
719
719
|
slug = item.slug || `${entity}Slug`;
|
720
720
|
jsonValue = { slug, ...item };
|
721
721
|
}
|
722
|
-
if ("alter" in query.alter) jsonValue = query.alter.alter.to;
|
722
|
+
if ("alter" in query.alter && query.alter.alter) jsonValue = query.alter.alter.to;
|
723
723
|
}
|
724
724
|
}
|
725
725
|
if (!(modelSlug && slug)) return query;
|
@@ -1395,10 +1395,11 @@ var handleTo = (models, model, statementParams, queryType, dependencyStatements,
|
|
1395
1395
|
dependencyStatements.push(composeStatement("add", record));
|
1396
1396
|
}
|
1397
1397
|
} else if (isObject(fieldValue)) {
|
1398
|
-
|
1398
|
+
const value = fieldValue;
|
1399
|
+
for (const recordToAdd of value.containing || []) {
|
1399
1400
|
dependencyStatements.push(composeStatement("add", recordToAdd));
|
1400
1401
|
}
|
1401
|
-
for (const recordToRemove of
|
1402
|
+
for (const recordToRemove of value.notContaining || []) {
|
1402
1403
|
dependencyStatements.push(composeStatement("remove", recordToRemove));
|
1403
1404
|
}
|
1404
1405
|
}
|
@@ -1518,7 +1519,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
1518
1519
|
models,
|
1519
1520
|
model,
|
1520
1521
|
statementParams,
|
1521
|
-
instructions
|
1522
|
+
instructions.with,
|
1522
1523
|
options?.parentModel
|
1523
1524
|
);
|
1524
1525
|
if (withStatement.length > 0) conditions.push(withStatement);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ronin/compiler",
|
3
|
-
"version": "0.12.
|
3
|
+
"version": "0.12.9",
|
4
4
|
"type": "module",
|
5
5
|
"description": "Compiles RONIN queries to SQL statements.",
|
6
6
|
"publishConfig": {
|
@@ -37,7 +37,6 @@
|
|
37
37
|
"@types/bun": "1.1.10",
|
38
38
|
"@types/title": "3.4.3",
|
39
39
|
"tsup": "8.3.0",
|
40
|
-
"typescript": "5.6.2"
|
41
|
-
"zod": "3.23.8"
|
40
|
+
"typescript": "5.6.2"
|
42
41
|
}
|
43
42
|
}
|