@ronin/compiler 0.13.7 → 0.13.8-leo-ron-1071-experimental-301

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.d.ts CHANGED
@@ -182,25 +182,34 @@ type ModelFieldBasics = {
182
182
  /** An expression that gets evaluated every time a value is provided for the field. */
183
183
  check?: Expression;
184
184
  };
185
- type ModelField = (ModelFieldBasics & {
185
+ type ModelField = ModelFieldBasics & ({
186
186
  /** The kind of value that should be stored inside the field. */
187
187
  type?: never;
188
- }) | (ModelFieldBasics & {
188
+ } | {
189
+ /** The kind of value that should be stored inside the field. */
190
+ type: 'boolean';
191
+ } | {
192
+ /** The kind of value that should be stored inside the field. */
193
+ type: 'date';
194
+ } | {
189
195
  /** The kind of value that should be stored inside the field. */
190
- type: 'boolean' | 'date' | 'json' | 'blob';
191
- }) | (ModelFieldBasics & {
196
+ type: 'json';
197
+ } | {
198
+ /** The kind of value that should be stored inside the field. */
199
+ type: 'blob';
200
+ } | {
192
201
  /** The kind of value that should be stored inside the field. */
193
202
  type: 'string';
194
203
  /** The collation sequence to use for the field value. */
195
204
  collation?: ModelFieldCollation;
196
- }) | (ModelFieldBasics & {
205
+ } | {
197
206
  /** The kind of value that should be stored inside the field. */
198
207
  type: 'number';
199
208
  /**
200
209
  * Automatically increments the value of the field with every new inserted record.
201
210
  */
202
211
  increment?: boolean;
203
- }) | (ModelFieldBasics & {
212
+ } | {
204
213
  /** The kind of value that should be stored inside the field. */
205
214
  type: 'link';
206
215
  /** The target model of the relationship that is being established. */
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  // src/utils/helpers.ts
2
- import { init as cuid } from "@paralleldrive/cuid2";
3
2
  var QUERY_SYMBOLS = {
4
3
  // Represents a sub query.
5
4
  QUERY: "__RONIN_QUERY",
@@ -54,7 +53,6 @@ var DOUBLE_QUOTE_REGEX = /"/g;
54
53
  var AMPERSAND_REGEX = /\s*&+\s*/g;
55
54
  var SPECIAL_CHARACTERS_REGEX = /[^\w\s-]+/g;
56
55
  var SPLIT_REGEX = /(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|[\s.\-_]+/;
57
- var generateRecordId = (prefix) => `${prefix}_${cuid({ length: 16 })()}`;
58
56
  var capitalize = (str) => {
59
57
  if (!str || str.length === 0) return "";
60
58
  return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
@@ -653,16 +651,21 @@ var addDefaultModelFields = (model, isNew) => {
653
651
  );
654
652
  copiedModel.identifiers.slug = suitableField?.slug || "id";
655
653
  }
656
- copiedModel.fields = [...SYSTEM_FIELDS, ...newFields];
654
+ copiedModel.fields = [...getSystemFields(copiedModel.idPrefix), ...newFields];
657
655
  }
658
656
  return copiedModel;
659
657
  };
660
- var SYSTEM_FIELDS = [
658
+ var getSystemFields = (idPrefix = "rec") => [
661
659
  {
662
660
  name: "ID",
663
661
  type: "string",
664
662
  slug: "id",
665
- displayAs: "single-line"
663
+ defaultValue: {
664
+ // Since default values in SQLite cannot rely on other columns, we unfortunately
665
+ // cannot rely on the `idPrefix` column here. Instead, we need to inject it directly
666
+ // into the expression as a static string.
667
+ [QUERY_SYMBOLS.EXPRESSION]: `'${idPrefix}_' || lower(substr(hex(randomblob(12)), 1, 16))`
668
+ }
666
669
  },
667
670
  {
668
671
  name: "RONIN - Locked",
@@ -1513,9 +1516,6 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1513
1516
  var handleTo = (models, model, statementParams, queryType, dependencyStatements, instructions, parentModel) => {
1514
1517
  const { with: withInstruction, to: toInstruction } = instructions;
1515
1518
  const defaultFields = {};
1516
- if (queryType === "add") {
1517
- defaultFields.id = toInstruction.id || generateRecordId(model.idPrefix);
1518
- }
1519
1519
  if (queryType === "set" || toInstruction.ronin) {
1520
1520
  defaultFields.ronin = {
1521
1521
  // If records are being updated, bump their update time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.13.7",
3
+ "version": "0.13.8-leo-ron-1071-experimental-301",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {
@@ -27,9 +27,6 @@
27
27
  ],
28
28
  "author": "ronin",
29
29
  "license": "Apache-2.0",
30
- "dependencies": {
31
- "@paralleldrive/cuid2": "2.2.2"
32
- },
33
30
  "devDependencies": {
34
31
  "@biomejs/biome": "1.9.4",
35
32
  "@ronin/engine": "0.0.27",