@ronin/compiler 0.13.13 → 0.13.14
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 +1 -12
- package/dist/index.js +8 -8
- package/package.json +1 -1
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
@@ -1851,10 +1851,10 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query)
|
|
1851
1851
|
var Transaction = class {
|
1852
1852
|
statements = [];
|
1853
1853
|
models = [];
|
1854
|
-
internalStatements = [];
|
1854
|
+
#internalStatements = [];
|
1855
1855
|
constructor(queries, options) {
|
1856
1856
|
const models = options?.models || [];
|
1857
|
-
this
|
1857
|
+
this.#compileQueries(queries, models, options);
|
1858
1858
|
}
|
1859
1859
|
/**
|
1860
1860
|
* Composes SQL statements for the provided RONIN queries.
|
@@ -1865,7 +1865,7 @@ var Transaction = class {
|
|
1865
1865
|
*
|
1866
1866
|
* @returns The composed SQL statements.
|
1867
1867
|
*/
|
1868
|
-
compileQueries = (queries, models, options) => {
|
1868
|
+
#compileQueries = (queries, models, options) => {
|
1869
1869
|
const modelsWithAttributes = [ROOT_MODEL, ...models].map((model) => {
|
1870
1870
|
return addDefaultModelAttributes(model, true);
|
1871
1871
|
});
|
@@ -1890,7 +1890,7 @@ var Transaction = class {
|
|
1890
1890
|
);
|
1891
1891
|
const subStatements = [...result.dependencies, result.main];
|
1892
1892
|
this.statements.push(...subStatements);
|
1893
|
-
this
|
1893
|
+
this.#internalStatements.push(
|
1894
1894
|
...subStatements.map((statement) => ({
|
1895
1895
|
...statement,
|
1896
1896
|
query,
|
@@ -1901,7 +1901,7 @@ var Transaction = class {
|
|
1901
1901
|
this.models = modelsWithPresets;
|
1902
1902
|
return statements;
|
1903
1903
|
};
|
1904
|
-
formatRows(fields, rows, single, isMeta) {
|
1904
|
+
#formatRows(fields, rows, single, isMeta) {
|
1905
1905
|
const records = [];
|
1906
1906
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
1907
1907
|
const row = rows[rowIndex];
|
@@ -1965,7 +1965,7 @@ var Transaction = class {
|
|
1965
1965
|
returning,
|
1966
1966
|
query,
|
1967
1967
|
fields: rawModelFields
|
1968
|
-
} = this
|
1968
|
+
} = this.#internalStatements[index];
|
1969
1969
|
if (!returning) return null;
|
1970
1970
|
const { queryType, queryModel, queryInstructions } = splitQuery(query);
|
1971
1971
|
const model = getModelBySlug(this.models, queryModel);
|
@@ -1979,13 +1979,13 @@ var Transaction = class {
|
|
1979
1979
|
const single = queryModel !== model.pluralSlug;
|
1980
1980
|
if (single) {
|
1981
1981
|
return {
|
1982
|
-
record: rows[0] ? this
|
1982
|
+
record: rows[0] ? this.#formatRows(rawModelFields, rows, single, isMeta) : null,
|
1983
1983
|
modelFields
|
1984
1984
|
};
|
1985
1985
|
}
|
1986
1986
|
const pageSize = queryInstructions?.limitedTo;
|
1987
1987
|
const output = {
|
1988
|
-
records: this
|
1988
|
+
records: this.#formatRows(rawModelFields, rows, single, isMeta),
|
1989
1989
|
modelFields
|
1990
1990
|
};
|
1991
1991
|
if (pageSize && output.records.length > 0) {
|