@ronin/compiler 0.18.5 → 0.18.6
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/index.js +20 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1597,7 +1597,16 @@ var getSystemFields = (idPrefix) => ({
|
|
1597
1597
|
}
|
1598
1598
|
});
|
1599
1599
|
var ROOT_MODEL = {
|
1600
|
+
// Provide the ID ahead of time, because certain runtime environments (e.g. Cloudflare
|
1601
|
+
// Workers) do not support the `crypto` module running in global scope, which would
|
1602
|
+
// happen when generating the default attributes of the root model.
|
1603
|
+
id: "mod_26cedf5fc602c3ba",
|
1604
|
+
// While the `slug` is required, we are providing the other attributes in order to
|
1605
|
+
// avoid needing to generate them at runtime.
|
1600
1606
|
slug: "roninModel",
|
1607
|
+
pluralSlug: "roninModels",
|
1608
|
+
name: "Ronin Model",
|
1609
|
+
pluralName: "Ronin Models",
|
1601
1610
|
identifiers: {
|
1602
1611
|
name: "name",
|
1603
1612
|
slug: "slug"
|
@@ -1684,7 +1693,16 @@ var getFieldStatement = (models, model, field) => {
|
|
1684
1693
|
const symbol = getQuerySymbol(field.defaultValue);
|
1685
1694
|
let value = typeof field.defaultValue === "string" ? `'${field.defaultValue}'` : field.defaultValue;
|
1686
1695
|
if (symbol) value = `(${parseFieldExpression(model, "to", symbol.value)})`;
|
1687
|
-
if (field.type === "json")
|
1696
|
+
if (field.type === "json") {
|
1697
|
+
if (!isObject(field.defaultValue)) {
|
1698
|
+
throw new RoninError({
|
1699
|
+
message: `The default value of JSON field "${field.slug}" must be an object.`,
|
1700
|
+
code: "INVALID_MODEL_VALUE",
|
1701
|
+
field: "fields"
|
1702
|
+
});
|
1703
|
+
}
|
1704
|
+
value = `'${JSON.stringify(field.defaultValue)}'`;
|
1705
|
+
}
|
1688
1706
|
statement += ` DEFAULT ${value}`;
|
1689
1707
|
}
|
1690
1708
|
if (field.type === "string" && field.collation) {
|
@@ -2001,7 +2019,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
|
|
2001
2019
|
throw new RoninError({
|
2002
2020
|
message: `When ${actionReadable} ${PLURAL_MODEL_ENTITIES[entity]}, at least one field must be provided.`,
|
2003
2021
|
code: "INVALID_MODEL_VALUE",
|
2004
|
-
|
2022
|
+
field: PLURAL_MODEL_ENTITIES[entity]
|
2005
2023
|
});
|
2006
2024
|
}
|
2007
2025
|
const columns = index.fields.map((field2) => {
|