@ronin/compiler 0.11.5 → 0.11.6-leo-ron-1071-experimental-247
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 +5 -3
- package/dist/index.js +13 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -5998,16 +5998,18 @@ type NativeRecord = Record<string, unknown> & {
|
|
5998
5998
|
};
|
5999
5999
|
type SingleRecordResult<T = NativeRecord> = {
|
6000
6000
|
record: T | null;
|
6001
|
+
modelFields: Record<ModelField['slug'], ModelField['type']>;
|
6001
6002
|
};
|
6002
|
-
type MultipleRecordResult = {
|
6003
|
-
records: Array<
|
6003
|
+
type MultipleRecordResult<T = NativeRecord> = {
|
6004
|
+
records: Array<T>;
|
6004
6005
|
moreAfter?: string;
|
6005
6006
|
moreBefore?: string;
|
6007
|
+
modelFields: Record<ModelField['slug'], ModelField['type']>;
|
6006
6008
|
};
|
6007
6009
|
type AmountResult = {
|
6008
6010
|
amount: number;
|
6009
6011
|
};
|
6010
|
-
type Result = SingleRecordResult | MultipleRecordResult | AmountResult;
|
6012
|
+
type Result<T = NativeRecord> = SingleRecordResult<T> | MultipleRecordResult<T> | AmountResult;
|
6011
6013
|
|
6012
6014
|
/**
|
6013
6015
|
* A list of placeholders that can be located inside queries after those queries were
|
package/dist/index.js
CHANGED
@@ -1599,8 +1599,7 @@ var Transaction = class {
|
|
1599
1599
|
const modelListWithPresets = modelList.map((model) => {
|
1600
1600
|
return addDefaultModelPresets(modelList, model);
|
1601
1601
|
});
|
1602
|
-
const
|
1603
|
-
const mainStatements = [];
|
1602
|
+
const statements = [];
|
1604
1603
|
for (const query of queries) {
|
1605
1604
|
const result = compileQueryInput(
|
1606
1605
|
query,
|
@@ -1608,12 +1607,11 @@ var Transaction = class {
|
|
1608
1607
|
options?.inlineParams ? null : [],
|
1609
1608
|
{ expandColumns: options?.expandColumns }
|
1610
1609
|
);
|
1611
|
-
|
1612
|
-
mainStatements.push(result.main);
|
1610
|
+
statements.push(...result.dependencies, result.main);
|
1613
1611
|
this.fields.push(result.loadedFields);
|
1614
1612
|
}
|
1615
1613
|
this.models = modelListWithPresets;
|
1616
|
-
return
|
1614
|
+
return statements;
|
1617
1615
|
};
|
1618
1616
|
formatRows(fields, rows, single) {
|
1619
1617
|
const records = [];
|
@@ -1669,19 +1667,26 @@ var Transaction = class {
|
|
1669
1667
|
});
|
1670
1668
|
return normalizedResults.map((rows, index) => {
|
1671
1669
|
const query = this.queries.at(-index);
|
1672
|
-
const
|
1670
|
+
const rawModelFields = this.fields.at(-index);
|
1673
1671
|
const { queryType, queryModel, queryInstructions } = splitQuery(query);
|
1674
1672
|
const model = getModelBySlug(this.models, queryModel);
|
1673
|
+
const modelFields = Object.fromEntries(
|
1674
|
+
model.fields.map((field) => [field.slug, field.type])
|
1675
|
+
);
|
1675
1676
|
if (queryType === "count") {
|
1676
1677
|
return { amount: rows[0][0] };
|
1677
1678
|
}
|
1678
1679
|
const single = queryModel !== model.pluralSlug;
|
1679
1680
|
if (single) {
|
1680
|
-
return {
|
1681
|
+
return {
|
1682
|
+
record: rows[0] ? this.formatRows(rawModelFields, rows, single) : null,
|
1683
|
+
modelFields
|
1684
|
+
};
|
1681
1685
|
}
|
1682
1686
|
const pageSize = queryInstructions?.limitedTo;
|
1683
1687
|
const output = {
|
1684
|
-
records: this.formatRows(
|
1688
|
+
records: this.formatRows(rawModelFields, rows, single),
|
1689
|
+
modelFields
|
1685
1690
|
};
|
1686
1691
|
if (pageSize && output.records.length > 0) {
|
1687
1692
|
if (output.records.length > pageSize) {
|