@ronin/compiler 0.12.8-leo-ron-1071-experimental-262 → 0.12.8-leo-ron-1071-experimental-263
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 +40 -40
- package/dist/index.js +6 -8
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* A list of placeholders that can be located inside queries after those queries were
|
3
|
+
* serialized into JSON objects.
|
4
|
+
*
|
5
|
+
* These placeholders are used to represent special keys and values. For example, if a
|
6
|
+
* query is nested into a query, the nested query will be marked with `__RONIN_QUERY`,
|
7
|
+
* which allows for distinguishing that nested query from an object of instructions.
|
8
|
+
*/
|
9
|
+
declare const QUERY_SYMBOLS: {
|
10
|
+
readonly QUERY: "__RONIN_QUERY";
|
11
|
+
readonly EXPRESSION: "__RONIN_EXPRESSION";
|
12
|
+
readonly FIELD: "__RONIN_FIELD_";
|
13
|
+
readonly FIELD_PARENT: "__RONIN_FIELD_PARENT_";
|
14
|
+
readonly FIELD_PARENT_OLD: "__RONIN_FIELD_PARENT_OLD_";
|
15
|
+
readonly FIELD_PARENT_NEW: "__RONIN_FIELD_PARENT_NEW_";
|
16
|
+
readonly VALUE: "__RONIN_VALUE";
|
17
|
+
};
|
18
|
+
type RoninErrorCode = 'MODEL_NOT_FOUND' | 'FIELD_NOT_FOUND' | 'INDEX_NOT_FOUND' | 'TRIGGER_NOT_FOUND' | 'PRESET_NOT_FOUND' | 'INVALID_WITH_VALUE' | 'INVALID_TO_VALUE' | 'INVALID_INCLUDING_VALUE' | 'INVALID_FOR_VALUE' | 'INVALID_BEFORE_OR_AFTER_INSTRUCTION' | 'INVALID_MODEL_VALUE' | 'MUTUALLY_EXCLUSIVE_INSTRUCTIONS' | 'MISSING_INSTRUCTION' | 'MISSING_FIELD';
|
19
|
+
interface Issue {
|
20
|
+
message: string;
|
21
|
+
path: Array<string | number>;
|
22
|
+
}
|
23
|
+
interface Details {
|
24
|
+
message: string;
|
25
|
+
code: RoninErrorCode;
|
26
|
+
field?: string;
|
27
|
+
fields?: Array<string>;
|
28
|
+
issues?: Array<Issue>;
|
29
|
+
queries?: Array<Query> | null;
|
30
|
+
}
|
31
|
+
declare class RoninError extends Error {
|
32
|
+
code: Details['code'];
|
33
|
+
field?: Details['field'];
|
34
|
+
fields?: Details['fields'];
|
35
|
+
issues?: Details['issues'];
|
36
|
+
queries?: Details['queries'];
|
37
|
+
constructor(details: Details);
|
38
|
+
}
|
39
|
+
|
1
40
|
type QueryTypeEnum = 'get' | 'set' | 'add' | 'remove' | 'count';
|
2
41
|
type ModelQueryTypeEnum = 'create' | 'alter' | 'drop';
|
3
42
|
type ModelEntityEnum = 'field' | 'index' | 'trigger' | 'preset';
|
4
43
|
type FieldValue = string | number | boolean | null | unknown;
|
5
44
|
type FieldSelector = Record<string, FieldValue>;
|
6
45
|
type Expression = {
|
7
|
-
|
46
|
+
[QUERY_SYMBOLS.EXPRESSION]: string;
|
8
47
|
};
|
9
48
|
type WithInstructionRefinement = FieldValue | {
|
10
49
|
being?: FieldValue | Array<FieldValue>;
|
@@ -282,45 +321,6 @@ type AmountResult = {
|
|
282
321
|
};
|
283
322
|
type Result<T = NativeRecord> = SingleRecordResult<T> | MultipleRecordResult<T> | AmountResult;
|
284
323
|
|
285
|
-
/**
|
286
|
-
* A list of placeholders that can be located inside queries after those queries were
|
287
|
-
* serialized into JSON objects.
|
288
|
-
*
|
289
|
-
* These placeholders are used to represent special keys and values. For example, if a
|
290
|
-
* query is nested into a query, the nested query will be marked with `__RONIN_QUERY`,
|
291
|
-
* which allows for distinguishing that nested query from an object of instructions.
|
292
|
-
*/
|
293
|
-
declare const QUERY_SYMBOLS: {
|
294
|
-
readonly QUERY: "__RONIN_QUERY";
|
295
|
-
readonly EXPRESSION: "__RONIN_EXPRESSION";
|
296
|
-
readonly FIELD: "__RONIN_FIELD_";
|
297
|
-
readonly FIELD_PARENT: "__RONIN_FIELD_PARENT_";
|
298
|
-
readonly FIELD_PARENT_OLD: "__RONIN_FIELD_PARENT_OLD_";
|
299
|
-
readonly FIELD_PARENT_NEW: "__RONIN_FIELD_PARENT_NEW_";
|
300
|
-
readonly VALUE: "__RONIN_VALUE";
|
301
|
-
};
|
302
|
-
type RoninErrorCode = 'MODEL_NOT_FOUND' | 'FIELD_NOT_FOUND' | 'INDEX_NOT_FOUND' | 'TRIGGER_NOT_FOUND' | 'PRESET_NOT_FOUND' | 'INVALID_WITH_VALUE' | 'INVALID_TO_VALUE' | 'INVALID_INCLUDING_VALUE' | 'INVALID_FOR_VALUE' | 'INVALID_BEFORE_OR_AFTER_INSTRUCTION' | 'INVALID_MODEL_VALUE' | 'MUTUALLY_EXCLUSIVE_INSTRUCTIONS' | 'MISSING_INSTRUCTION' | 'MISSING_FIELD';
|
303
|
-
interface Issue {
|
304
|
-
message: string;
|
305
|
-
path: Array<string | number>;
|
306
|
-
}
|
307
|
-
interface Details {
|
308
|
-
message: string;
|
309
|
-
code: RoninErrorCode;
|
310
|
-
field?: string;
|
311
|
-
fields?: Array<string>;
|
312
|
-
issues?: Array<Issue>;
|
313
|
-
queries?: Array<Query> | null;
|
314
|
-
}
|
315
|
-
declare class RoninError extends Error {
|
316
|
-
code: Details['code'];
|
317
|
-
field?: Details['field'];
|
318
|
-
fields?: Details['fields'];
|
319
|
-
issues?: Details['issues'];
|
320
|
-
queries?: Details['queries'];
|
321
|
-
constructor(details: Details);
|
322
|
-
}
|
323
|
-
|
324
324
|
interface TransactionOptions {
|
325
325
|
/** A list of models that already exist in the database. */
|
326
326
|
models?: Array<PublicModel>;
|
package/dist/index.js
CHANGED
@@ -688,7 +688,7 @@ var handleSystemModel = (models, dependencyStatements, action, systemModel, newM
|
|
688
688
|
const query = {
|
689
689
|
[action]: { model: action === "create" ? systemModelClean : systemModelClean.slug }
|
690
690
|
};
|
691
|
-
if (action === "alter" && newModel && "alter" in query &&
|
691
|
+
if (action === "alter" && newModel && "alter" in query && query.alter) {
|
692
692
|
const { system: _2, ...newModelClean } = newModel;
|
693
693
|
query.alter.to = newModelClean;
|
694
694
|
}
|
@@ -704,12 +704,12 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query)
|
|
704
704
|
let slug = entity === "model" && action === "create" ? null : query[queryType].model;
|
705
705
|
let modelSlug = slug;
|
706
706
|
let jsonValue;
|
707
|
-
if ("create" in query &&
|
707
|
+
if ("create" in query && query.create) {
|
708
708
|
const init = query.create.model;
|
709
709
|
jsonValue = "to" in query.create ? { slug: init, ...query.create.to } : init;
|
710
710
|
slug = modelSlug = jsonValue.slug;
|
711
711
|
}
|
712
|
-
if ("alter" in query &&
|
712
|
+
if ("alter" in query && query.alter) {
|
713
713
|
if ("to" in query.alter) {
|
714
714
|
jsonValue = query.alter.to;
|
715
715
|
} else {
|
@@ -719,9 +719,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query)
|
|
719
719
|
slug = item.slug || `${entity}Slug`;
|
720
720
|
jsonValue = { slug, ...item };
|
721
721
|
}
|
722
|
-
if ("alter" in query.alter &&
|
723
|
-
jsonValue = query.alter.alter.to;
|
724
|
-
}
|
722
|
+
if ("alter" in query.alter && query.alter.alter) jsonValue = query.alter.alter.to;
|
725
723
|
}
|
726
724
|
}
|
727
725
|
if (!(modelSlug && slug)) return query;
|
@@ -1510,7 +1508,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
1510
1508
|
statementParams,
|
1511
1509
|
queryType,
|
1512
1510
|
dependencyStatements,
|
1513
|
-
{ with: instructions
|
1511
|
+
{ with: instructions.with, to: instructions.to },
|
1514
1512
|
options?.parentModel
|
1515
1513
|
);
|
1516
1514
|
statement += `${toStatement} `;
|
@@ -1521,7 +1519,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
1521
1519
|
models,
|
1522
1520
|
model,
|
1523
1521
|
statementParams,
|
1524
|
-
instructions
|
1522
|
+
instructions.with,
|
1525
1523
|
options?.parentModel
|
1526
1524
|
);
|
1527
1525
|
if (withStatement.length > 0) conditions.push(withStatement);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ronin/compiler",
|
3
|
-
"version": "0.12.8-leo-ron-1071-experimental-
|
3
|
+
"version": "0.12.8-leo-ron-1071-experimental-263",
|
4
4
|
"type": "module",
|
5
5
|
"description": "Compiles RONIN queries to SQL statements.",
|
6
6
|
"publishConfig": {
|
@@ -37,7 +37,6 @@
|
|
37
37
|
"@types/bun": "1.1.10",
|
38
38
|
"@types/title": "3.4.3",
|
39
39
|
"tsup": "8.3.0",
|
40
|
-
"typescript": "5.6.2"
|
41
|
-
"zod": "3.23.8"
|
40
|
+
"typescript": "5.6.2"
|
42
41
|
}
|
43
42
|
}
|