@ronin/compiler 0.13.8 → 0.13.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.
Files changed (2) hide show
  1. package/dist/index.js +8 -8
  2. package/package.json +1 -4
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.8",
3
+ "version": "0.13.9",
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",