@ronin/compiler 0.16.0 → 0.16.1-leo-ron-1099-1-experimental-366
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 +4 -2
- package/dist/index.js +18 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -392,7 +392,9 @@ type AmountResult = {
|
|
392
392
|
amount: number;
|
393
393
|
};
|
394
394
|
type RegularResult<T = ResultRecord> = SingleRecordResult<T> | MultipleRecordResult<T> | AmountResult;
|
395
|
-
type ExpandedResult<T = ResultRecord> =
|
395
|
+
type ExpandedResult<T = ResultRecord> = {
|
396
|
+
models: Record<Model['slug'], RegularResult<T>>;
|
397
|
+
};
|
396
398
|
type Result<T = ResultRecord> = RegularResult<T> | ExpandedResult<T>;
|
397
399
|
|
398
400
|
interface TransactionOptions {
|
@@ -415,4 +417,4 @@ declare class Transaction {
|
|
415
417
|
|
416
418
|
declare const CLEAN_ROOT_MODEL: PublicModel;
|
417
419
|
|
418
|
-
export { type AddInstructions, type AddQuery, type AddInstructions as AddQueryInstructions, type AlterQuery, type CombinedInstructions, type CountInstructions, type CountQuery, type CountInstructions as CountQueryInstructions, type CreateQuery, type DropQuery, type GetInstructions, type GetQuery, type GetInstructions as GetQueryInstructions, type PublicModel as Model, type ModelField, type ModelIndex, type ModelPreset, type ModelTrigger, QUERY_SYMBOLS, type Query, type QueryInstructionType as QueryInstruction, type QuerySchemaType, type QueryType, CLEAN_ROOT_MODEL as ROOT_MODEL, type RemoveInstructions, type RemoveQuery, type RemoveInstructions as RemoveQueryInstructions, type Result, type ResultRecord, RoninError, type SetInstructions, type SetQuery, type SetInstructions as SetQueryInstructions, type Statement, type StoredObject, Transaction, type WithInstruction, getQuerySymbol };
|
420
|
+
export { type AddInstructions, type AddQuery, type AddInstructions as AddQueryInstructions, type AlterQuery, type CombinedInstructions, type CountInstructions, type CountQuery, type CountInstructions as CountQueryInstructions, type CreateQuery, type DropQuery, type ExpandedResult, type GetInstructions, type GetQuery, type GetInstructions as GetQueryInstructions, type PublicModel as Model, type ModelField, type ModelIndex, type ModelPreset, type ModelTrigger, QUERY_SYMBOLS, type Query, type QueryInstructionType as QueryInstruction, type QuerySchemaType, type QueryType, CLEAN_ROOT_MODEL as ROOT_MODEL, type RegularResult, type RemoveInstructions, type RemoveQuery, type RemoveInstructions as RemoveQueryInstructions, type Result, type ResultRecord, RoninError, type SetInstructions, type SetQuery, type SetInstructions as SetQueryInstructions, type Statement, type StoredObject, Transaction, type WithInstruction, getQuerySymbol };
|
package/dist/index.js
CHANGED
@@ -174,7 +174,7 @@ var generatePaginationCursor = (model, orderedBy, record) => {
|
|
174
174
|
};
|
175
175
|
|
176
176
|
// src/instructions/before-after.ts
|
177
|
-
var handleBeforeOrAfter = (model, statementParams, instructions) => {
|
177
|
+
var handleBeforeOrAfter = (model, statementParams, queryType, instructions) => {
|
178
178
|
if (!(instructions.before || instructions.after)) {
|
179
179
|
throw new RoninError({
|
180
180
|
message: "The `before` or `after` instruction must not be empty.",
|
@@ -187,7 +187,7 @@ var handleBeforeOrAfter = (model, statementParams, instructions) => {
|
|
187
187
|
code: "MUTUALLY_EXCLUSIVE_INSTRUCTIONS"
|
188
188
|
});
|
189
189
|
}
|
190
|
-
if (!instructions.limitedTo) {
|
190
|
+
if (!instructions.limitedTo && queryType !== "count") {
|
191
191
|
let message = "When providing a pagination cursor in the `before` or `after`";
|
192
192
|
message += " instruction, a `limitedTo` instruction must be provided as well, to";
|
193
193
|
message += " define the page size.";
|
@@ -724,7 +724,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
724
724
|
);
|
725
725
|
if (withStatement.length > 0) conditions.push(withStatement);
|
726
726
|
}
|
727
|
-
if ((queryType === "get" || queryType === "count"
|
727
|
+
if (!single && (queryType === "get" && instructions?.limitedTo || queryType === "count" && (instructions?.before || instructions?.after))) {
|
728
728
|
instructions = instructions || {};
|
729
729
|
instructions.orderedBy = instructions.orderedBy || {};
|
730
730
|
instructions.orderedBy.ascending = instructions.orderedBy.ascending || [];
|
@@ -744,13 +744,18 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
744
744
|
queries: [query]
|
745
745
|
});
|
746
746
|
}
|
747
|
-
const beforeAndAfterStatement = handleBeforeOrAfter(
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
747
|
+
const beforeAndAfterStatement = handleBeforeOrAfter(
|
748
|
+
model,
|
749
|
+
statementParams,
|
750
|
+
queryType,
|
751
|
+
{
|
752
|
+
before: instructions.before,
|
753
|
+
after: instructions.after,
|
754
|
+
with: instructions.with,
|
755
|
+
orderedBy: instructions.orderedBy,
|
756
|
+
limitedTo: instructions.limitedTo
|
757
|
+
}
|
758
|
+
);
|
754
759
|
conditions.push(beforeAndAfterStatement);
|
755
760
|
}
|
756
761
|
if (conditions.length > 0) {
|
@@ -2145,8 +2150,9 @@ var Transaction = class {
|
|
2145
2150
|
if (!returning) return finalResults;
|
2146
2151
|
const addResult = (result2) => {
|
2147
2152
|
if (typeof expansionIndex !== "undefined") {
|
2148
|
-
|
2149
|
-
finalResults[expansionIndex]
|
2153
|
+
let match = finalResults[expansionIndex];
|
2154
|
+
if (!match) match = finalResults[expansionIndex] = { models: {} };
|
2155
|
+
match.models[queryModel] = result2;
|
2150
2156
|
} else {
|
2151
2157
|
finalResults.push(result2);
|
2152
2158
|
}
|