@ronin/compiler 0.13.12 → 0.13.13-leo-ron-1099-1-experimental-309

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
@@ -368,21 +368,10 @@ interface TransactionOptions {
368
368
  expandColumns?: boolean;
369
369
  }
370
370
  declare class Transaction {
371
+ #private;
371
372
  statements: Array<Statement>;
372
373
  models: Array<Model>;
373
- private internalStatements;
374
374
  constructor(queries: Array<Query>, options?: TransactionOptions);
375
- /**
376
- * Composes SQL statements for the provided RONIN queries.
377
- *
378
- * @param queries - The RONIN queries for which SQL statements should be composed.
379
- * @param models - A list of models.
380
- * @param options - Additional options to adjust the behavior of the statement generation.
381
- *
382
- * @returns The composed SQL statements.
383
- */
384
- private compileQueries;
385
- private formatRows;
386
375
  formatResults<Record>(results: Array<Array<RawRow>>, raw?: true): Array<Result<Record>>;
387
376
  formatResults<Record>(results: Array<Array<ObjectRow>>, raw?: false): Array<Result<Record>>;
388
377
  }
package/dist/index.js CHANGED
@@ -1591,11 +1591,29 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query)
1591
1591
  return [pluralType2, formatModelEntity(type, list)];
1592
1592
  })
1593
1593
  );
1594
+ models.push(modelWithPresets);
1594
1595
  dependencyStatements.push({
1595
1596
  statement: `CREATE TABLE "${modelWithPresets.table}" (${columns.join(", ")})`,
1596
1597
  params: []
1597
1598
  });
1598
- models.push(modelWithPresets);
1599
+ for (const [modelEntity, pluralModelEntity] of [
1600
+ ["index", "indexes"],
1601
+ ["trigger", "triggers"]
1602
+ ]) {
1603
+ const entityValue = modelWithPresets[pluralModelEntity];
1604
+ if (!entityValue) continue;
1605
+ for (const item of entityValue) {
1606
+ const query2 = {
1607
+ alter: {
1608
+ model: modelWithPresets.slug,
1609
+ create: {
1610
+ [modelEntity]: item
1611
+ }
1612
+ }
1613
+ };
1614
+ transformMetaQuery(models, dependencyStatements, null, query2);
1615
+ }
1616
+ }
1599
1617
  const modelWithObjects = Object.assign({}, modelWithPresets);
1600
1618
  for (const entity2 in entities) {
1601
1619
  if (!Object.hasOwn(entities, entity2)) continue;
@@ -1833,10 +1851,10 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query)
1833
1851
  var Transaction = class {
1834
1852
  statements = [];
1835
1853
  models = [];
1836
- internalStatements = [];
1854
+ #internalStatements = [];
1837
1855
  constructor(queries, options) {
1838
1856
  const models = options?.models || [];
1839
- this.compileQueries(queries, models, options);
1857
+ this.#compileQueries(queries, models, options);
1840
1858
  }
1841
1859
  /**
1842
1860
  * Composes SQL statements for the provided RONIN queries.
@@ -1847,7 +1865,7 @@ var Transaction = class {
1847
1865
  *
1848
1866
  * @returns The composed SQL statements.
1849
1867
  */
1850
- compileQueries = (queries, models, options) => {
1868
+ #compileQueries = (queries, models, options) => {
1851
1869
  const modelsWithAttributes = [ROOT_MODEL, ...models].map((model) => {
1852
1870
  return addDefaultModelAttributes(model, true);
1853
1871
  });
@@ -1872,7 +1890,7 @@ var Transaction = class {
1872
1890
  );
1873
1891
  const subStatements = [...result.dependencies, result.main];
1874
1892
  this.statements.push(...subStatements);
1875
- this.internalStatements.push(
1893
+ this.#internalStatements.push(
1876
1894
  ...subStatements.map((statement) => ({
1877
1895
  ...statement,
1878
1896
  query,
@@ -1883,7 +1901,7 @@ var Transaction = class {
1883
1901
  this.models = modelsWithPresets;
1884
1902
  return statements;
1885
1903
  };
1886
- formatRows(fields, rows, single, isMeta) {
1904
+ #formatRows(fields, rows, single, isMeta) {
1887
1905
  const records = [];
1888
1906
  for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
1889
1907
  const row = rows[rowIndex];
@@ -1947,7 +1965,7 @@ var Transaction = class {
1947
1965
  returning,
1948
1966
  query,
1949
1967
  fields: rawModelFields
1950
- } = this.internalStatements[index];
1968
+ } = this.#internalStatements[index];
1951
1969
  if (!returning) return null;
1952
1970
  const { queryType, queryModel, queryInstructions } = splitQuery(query);
1953
1971
  const model = getModelBySlug(this.models, queryModel);
@@ -1961,13 +1979,13 @@ var Transaction = class {
1961
1979
  const single = queryModel !== model.pluralSlug;
1962
1980
  if (single) {
1963
1981
  return {
1964
- record: rows[0] ? this.formatRows(rawModelFields, rows, single, isMeta) : null,
1982
+ record: rows[0] ? this.#formatRows(rawModelFields, rows, single, isMeta) : null,
1965
1983
  modelFields
1966
1984
  };
1967
1985
  }
1968
1986
  const pageSize = queryInstructions?.limitedTo;
1969
1987
  const output = {
1970
- records: this.formatRows(rawModelFields, rows, single, isMeta),
1988
+ records: this.#formatRows(rawModelFields, rows, single, isMeta),
1971
1989
  modelFields
1972
1990
  };
1973
1991
  if (pageSize && output.records.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.13.12",
3
+ "version": "0.13.13-leo-ron-1099-1-experimental-309",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {