@ronin/compiler 0.14.14-leo-ron-1099-1-experimental-357 → 0.14.14-leo-ron-1099-1-experimental-358

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 +49 -49
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -256,55 +256,6 @@ var handleBeforeOrAfter = (model, statementParams, instructions) => {
256
256
  return `${clause}(${conditions.join(" OR ")})`;
257
257
  };
258
258
 
259
- // src/instructions/for.ts
260
- var handleUsing = (model, instructions) => {
261
- const normalizedFor = Array.isArray(instructions.using) ? Object.fromEntries(instructions.using.map((presetSlug) => [presetSlug, null])) : instructions.using;
262
- for (const presetSlug in normalizedFor) {
263
- if (!Object.hasOwn(normalizedFor, presetSlug)) continue;
264
- const arg = normalizedFor[presetSlug];
265
- const preset = model.presets?.find((preset2) => preset2.slug === presetSlug);
266
- if (!preset) {
267
- throw new RoninError({
268
- message: `Preset "${presetSlug}" does not exist in model "${model.name}".`,
269
- code: "PRESET_NOT_FOUND"
270
- });
271
- }
272
- const replacedUsingFilter = structuredClone(preset.instructions);
273
- if (arg !== null) {
274
- findInObject(
275
- replacedUsingFilter,
276
- QUERY_SYMBOLS.VALUE,
277
- (match) => match.replace(QUERY_SYMBOLS.VALUE, arg)
278
- );
279
- }
280
- for (const subInstruction in replacedUsingFilter) {
281
- if (!Object.hasOwn(replacedUsingFilter, subInstruction)) continue;
282
- const instructionName = subInstruction;
283
- const currentValue = instructions[instructionName];
284
- if (currentValue) {
285
- let newValue;
286
- if (Array.isArray(currentValue)) {
287
- newValue = [
288
- ...replacedUsingFilter[instructionName],
289
- ...currentValue
290
- ];
291
- } else if (isObject(currentValue)) {
292
- newValue = {
293
- ...replacedUsingFilter[instructionName],
294
- ...currentValue
295
- };
296
- }
297
- Object.assign(instructions, { [instructionName]: newValue });
298
- continue;
299
- }
300
- Object.assign(instructions, {
301
- [instructionName]: replacedUsingFilter[instructionName]
302
- });
303
- }
304
- }
305
- return instructions;
306
- };
307
-
308
259
  // src/instructions/including.ts
309
260
  var handleIncluding = (models, model, statementParams, single, instruction, options = {}) => {
310
261
  let statement = "";
@@ -598,6 +549,55 @@ var handleTo = (models, model, statementParams, queryType, dependencyStatements,
598
549
  return statement;
599
550
  };
600
551
 
552
+ // src/instructions/using.ts
553
+ var handleUsing = (model, instructions) => {
554
+ const normalizedUsing = Array.isArray(instructions.using) ? Object.fromEntries(instructions.using.map((presetSlug) => [presetSlug, null])) : instructions.using;
555
+ for (const presetSlug in normalizedUsing) {
556
+ if (!Object.hasOwn(normalizedUsing, presetSlug)) continue;
557
+ const arg = normalizedUsing[presetSlug];
558
+ const preset = model.presets?.find((preset2) => preset2.slug === presetSlug);
559
+ if (!preset) {
560
+ throw new RoninError({
561
+ message: `Preset "${presetSlug}" does not exist in model "${model.name}".`,
562
+ code: "PRESET_NOT_FOUND"
563
+ });
564
+ }
565
+ const replacedUsingFilter = structuredClone(preset.instructions);
566
+ if (arg !== null) {
567
+ findInObject(
568
+ replacedUsingFilter,
569
+ QUERY_SYMBOLS.VALUE,
570
+ (match) => match.replace(QUERY_SYMBOLS.VALUE, arg)
571
+ );
572
+ }
573
+ for (const subInstruction in replacedUsingFilter) {
574
+ if (!Object.hasOwn(replacedUsingFilter, subInstruction)) continue;
575
+ const instructionName = subInstruction;
576
+ const currentValue = instructions[instructionName];
577
+ if (currentValue) {
578
+ let newValue;
579
+ if (Array.isArray(currentValue)) {
580
+ newValue = [
581
+ ...replacedUsingFilter[instructionName],
582
+ ...currentValue
583
+ ];
584
+ } else if (isObject(currentValue)) {
585
+ newValue = {
586
+ ...replacedUsingFilter[instructionName],
587
+ ...currentValue
588
+ };
589
+ }
590
+ Object.assign(instructions, { [instructionName]: newValue });
591
+ continue;
592
+ }
593
+ Object.assign(instructions, {
594
+ [instructionName]: replacedUsingFilter[instructionName]
595
+ });
596
+ }
597
+ }
598
+ return instructions;
599
+ };
600
+
601
601
  // src/utils/index.ts
602
602
  var compileQueryInput = (defaultQuery, models, statementParams, options) => {
603
603
  const dependencyStatements = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.14.14-leo-ron-1099-1-experimental-357",
3
+ "version": "0.14.14-leo-ron-1099-1-experimental-358",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {