@ronin/compiler 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +13 -13
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -3811,7 +3811,7 @@ declare const QuerySchema: z.ZodObject<{
|
|
3811
3811
|
after?: string | null | undefined;
|
3812
3812
|
limitedTo?: number | undefined;
|
3813
3813
|
}>>>;
|
3814
|
-
|
3814
|
+
remove: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<Omit<{
|
3815
3815
|
with: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodAny]>, z.ZodEffects<z.ZodObject<{
|
3816
3816
|
being: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodAny]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodAny]>, "many">]>>;
|
3817
3817
|
notBeing: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodAny]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodAny]>, "many">]>>;
|
@@ -5641,7 +5641,7 @@ declare const QuerySchema: z.ZodObject<{
|
|
5641
5641
|
after?: string | null | undefined;
|
5642
5642
|
limitedTo?: number | undefined;
|
5643
5643
|
}> | undefined;
|
5644
|
-
|
5644
|
+
remove?: Record<string, {
|
5645
5645
|
with?: Record<string, any> | Record<string, any>[] | undefined;
|
5646
5646
|
including?: Record<string, any> | undefined;
|
5647
5647
|
selecting?: string[] | undefined;
|
@@ -5751,7 +5751,7 @@ declare const QuerySchema: z.ZodObject<{
|
|
5751
5751
|
after?: string | null | undefined;
|
5752
5752
|
limitedTo?: number | undefined;
|
5753
5753
|
}> | undefined;
|
5754
|
-
|
5754
|
+
remove?: Record<string, {
|
5755
5755
|
with?: Record<string, any> | Record<string, any>[] | undefined;
|
5756
5756
|
including?: Record<string, any> | undefined;
|
5757
5757
|
selecting?: string[] | undefined;
|
package/dist/index.js
CHANGED
@@ -667,7 +667,7 @@ var addDefaultModelPresets = (list, model) => {
|
|
667
667
|
var mappedInstructions = {
|
668
668
|
add: "to",
|
669
669
|
set: "with",
|
670
|
-
|
670
|
+
remove: "with"
|
671
671
|
};
|
672
672
|
var typesInSQLite = {
|
673
673
|
link: "TEXT",
|
@@ -711,7 +711,7 @@ var getFieldStatement = (models, model, field) => {
|
|
711
711
|
};
|
712
712
|
var addModelQueries = (models, dependencyStatements, queryDetails) => {
|
713
713
|
const { queryType, queryModel, queryInstructions } = queryDetails;
|
714
|
-
if (!["add", "set", "
|
714
|
+
if (!["add", "set", "remove"].includes(queryType)) return;
|
715
715
|
if (!SYSTEM_MODEL_SLUGS.includes(queryModel)) return;
|
716
716
|
const instructionName = mappedInstructions[queryType];
|
717
717
|
const instructionList = queryInstructions[instructionName];
|
@@ -731,7 +731,7 @@ var addModelQueries = (models, dependencyStatements, queryDetails) => {
|
|
731
731
|
queryTypeReadable = "updating";
|
732
732
|
break;
|
733
733
|
}
|
734
|
-
case "
|
734
|
+
case "remove": {
|
735
735
|
if (kind === "models" || kind === "indexes" || kind === "triggers") {
|
736
736
|
tableAction = "DROP";
|
737
737
|
}
|
@@ -852,7 +852,7 @@ var addModelQueries = (models, dependencyStatements, queryDetails) => {
|
|
852
852
|
});
|
853
853
|
}
|
854
854
|
Object.assign(targetModel, queryInstructions.to);
|
855
|
-
} else if (queryType === "
|
855
|
+
} else if (queryType === "remove") {
|
856
856
|
models.splice(models.indexOf(targetModel), 1);
|
857
857
|
dependencyStatements.push({ statement, params: [] });
|
858
858
|
}
|
@@ -873,7 +873,7 @@ var addModelQueries = (models, dependencyStatements, queryDetails) => {
|
|
873
873
|
params: []
|
874
874
|
});
|
875
875
|
}
|
876
|
-
} else if (queryType === "
|
876
|
+
} else if (queryType === "remove") {
|
877
877
|
dependencyStatements.push({
|
878
878
|
statement: `${statement} DROP COLUMN "${slug}"`,
|
879
879
|
params: []
|
@@ -1202,7 +1202,7 @@ var handleTo = (models, model, statementParams, queryType, dependencyStatements,
|
|
1202
1202
|
).main;
|
1203
1203
|
};
|
1204
1204
|
if (Array.isArray(fieldValue)) {
|
1205
|
-
dependencyStatements.push(composeStatement("
|
1205
|
+
dependencyStatements.push(composeStatement("remove"));
|
1206
1206
|
for (const record of fieldValue) {
|
1207
1207
|
dependencyStatements.push(composeStatement("add", record));
|
1208
1208
|
}
|
@@ -1211,7 +1211,7 @@ var handleTo = (models, model, statementParams, queryType, dependencyStatements,
|
|
1211
1211
|
dependencyStatements.push(composeStatement("add", recordToAdd));
|
1212
1212
|
}
|
1213
1213
|
for (const recordToRemove of fieldValue.notContaining || []) {
|
1214
|
-
dependencyStatements.push(composeStatement("
|
1214
|
+
dependencyStatements.push(composeStatement("remove", recordToRemove));
|
1215
1215
|
}
|
1216
1216
|
}
|
1217
1217
|
}
|
@@ -1266,7 +1266,7 @@ var compileQueryInput = (query, models, statementParams, options) => {
|
|
1266
1266
|
case "add":
|
1267
1267
|
statement += "INSERT INTO ";
|
1268
1268
|
break;
|
1269
|
-
case "
|
1269
|
+
case "remove":
|
1270
1270
|
statement += "DELETE FROM ";
|
1271
1271
|
break;
|
1272
1272
|
case "count":
|
@@ -1364,7 +1364,7 @@ var compileQueryInput = (query, models, statementParams, options) => {
|
|
1364
1364
|
if (queryType === "get" && !isJoiningMultipleRows && (single || instructions?.limitedTo)) {
|
1365
1365
|
statement += handleLimitedTo(single, instructions?.limitedTo);
|
1366
1366
|
}
|
1367
|
-
if (["add", "set", "
|
1367
|
+
if (["add", "set", "remove"].includes(queryType) && returning) {
|
1368
1368
|
statement += "RETURNING * ";
|
1369
1369
|
}
|
1370
1370
|
const mainStatement = {
|
@@ -1405,12 +1405,12 @@ var transformMetaQuery = (models, dependencyStatements, query) => {
|
|
1405
1405
|
with: { slug }
|
1406
1406
|
};
|
1407
1407
|
addModelQueries(models, dependencyStatements, {
|
1408
|
-
queryType: "
|
1408
|
+
queryType: "remove",
|
1409
1409
|
queryModel: "model",
|
1410
1410
|
queryInstructions: instructions
|
1411
1411
|
});
|
1412
1412
|
return {
|
1413
|
-
|
1413
|
+
remove: {
|
1414
1414
|
model: instructions
|
1415
1415
|
}
|
1416
1416
|
};
|
@@ -1481,12 +1481,12 @@ var transformMetaQuery = (models, dependencyStatements, query) => {
|
|
1481
1481
|
with: { model: { slug }, slug: itemSlug }
|
1482
1482
|
};
|
1483
1483
|
addModelQueries(models, dependencyStatements, {
|
1484
|
-
queryType: "
|
1484
|
+
queryType: "remove",
|
1485
1485
|
queryModel: type,
|
1486
1486
|
queryInstructions: instructions
|
1487
1487
|
});
|
1488
1488
|
return {
|
1489
|
-
|
1489
|
+
remove: {
|
1490
1490
|
[type]: instructions
|
1491
1491
|
}
|
1492
1492
|
};
|