@ronin/compiler 0.17.12-leo-ron-1113-experimental-402 → 0.17.13-leo-ron-1113-experimental-403
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 +49 -40
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
/** Query types used for reading data. */
|
2
|
+
declare const DML_READ_QUERY_TYPES: readonly ["get", "count"];
|
3
|
+
/** Query types used for writing data. */
|
4
|
+
declare const DML_WRITE_QUERY_TYPES: readonly ["set", "add", "remove"];
|
5
|
+
/** Query types used for interacting with data. */
|
6
|
+
declare const DML_QUERY_TYPES: readonly ["get", "count", "set", "add", "remove"];
|
7
|
+
/** Query types used for interacting with the database schema. */
|
8
|
+
declare const DDL_QUERY_TYPES: readonly ["create", "alter", "drop"];
|
1
9
|
/**
|
2
10
|
* A list of placeholders that can be located inside queries after those queries were
|
3
11
|
* serialized into JSON objects.
|
@@ -15,46 +23,9 @@ declare const QUERY_SYMBOLS: {
|
|
15
23
|
readonly FIELD_PARENT_NEW: "__RONIN_FIELD_PARENT_NEW_";
|
16
24
|
readonly VALUE: "__RONIN_VALUE";
|
17
25
|
};
|
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' | 'EXISTING_MODEL_ENTITY' | 'REQUIRED_MODEL_ENTITY' | '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
|
-
/**
|
40
|
-
* Checks if the provided value contains a RONIN model symbol (a represenation of a
|
41
|
-
* particular entity inside a query, such as an expression or a sub query) and returns
|
42
|
-
* its type and value.
|
43
|
-
*
|
44
|
-
* @param value - The value that should be checked.
|
45
|
-
*
|
46
|
-
* @returns The type and value of the symbol, if the provided value contains one.
|
47
|
-
*/
|
48
|
-
declare const getQuerySymbol: (value: unknown) => {
|
49
|
-
type: "query";
|
50
|
-
value: Query;
|
51
|
-
} | {
|
52
|
-
type: "expression";
|
53
|
-
value: string;
|
54
|
-
} | null;
|
55
26
|
|
56
|
-
type QueryTypeEnum =
|
57
|
-
type ModelQueryTypeEnum =
|
27
|
+
type QueryTypeEnum = (typeof DML_QUERY_TYPES)[number];
|
28
|
+
type ModelQueryTypeEnum = (typeof DDL_QUERY_TYPES)[number];
|
58
29
|
type ModelEntityEnum = 'field' | 'index' | 'trigger' | 'preset';
|
59
30
|
type FieldValue = string | number | boolean | null | unknown;
|
60
31
|
type FieldSelector = Record<string, FieldValue | StoredObject>;
|
@@ -426,6 +397,44 @@ type ExpandedResult<T = ResultRecord> = {
|
|
426
397
|
};
|
427
398
|
type Result<T = ResultRecord> = RegularResult<T> | ExpandedResult<T>;
|
428
399
|
|
400
|
+
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' | 'EXISTING_MODEL_ENTITY' | 'REQUIRED_MODEL_ENTITY' | 'MUTUALLY_EXCLUSIVE_INSTRUCTIONS' | 'MISSING_INSTRUCTION' | 'MISSING_FIELD';
|
401
|
+
interface Issue {
|
402
|
+
message: string;
|
403
|
+
path: Array<string | number>;
|
404
|
+
}
|
405
|
+
interface Details {
|
406
|
+
message: string;
|
407
|
+
code: RoninErrorCode;
|
408
|
+
field?: string;
|
409
|
+
fields?: Array<string>;
|
410
|
+
issues?: Array<Issue>;
|
411
|
+
queries?: Array<Query> | null;
|
412
|
+
}
|
413
|
+
declare class RoninError extends Error {
|
414
|
+
code: Details['code'];
|
415
|
+
field?: Details['field'];
|
416
|
+
fields?: Details['fields'];
|
417
|
+
issues?: Details['issues'];
|
418
|
+
queries?: Details['queries'];
|
419
|
+
constructor(details: Details);
|
420
|
+
}
|
421
|
+
/**
|
422
|
+
* Checks if the provided value contains a RONIN model symbol (a represenation of a
|
423
|
+
* particular entity inside a query, such as an expression or a sub query) and returns
|
424
|
+
* its type and value.
|
425
|
+
*
|
426
|
+
* @param value - The value that should be checked.
|
427
|
+
*
|
428
|
+
* @returns The type and value of the symbol, if the provided value contains one.
|
429
|
+
*/
|
430
|
+
declare const getQuerySymbol: (value: unknown) => {
|
431
|
+
type: "query";
|
432
|
+
value: Query;
|
433
|
+
} | {
|
434
|
+
type: "expression";
|
435
|
+
value: string;
|
436
|
+
} | null;
|
437
|
+
|
429
438
|
interface TransactionOptions {
|
430
439
|
/** A list of models that already exist in the database. */
|
431
440
|
models?: Array<PublicModel>;
|
@@ -464,4 +473,4 @@ declare class Transaction {
|
|
464
473
|
|
465
474
|
declare const CLEAN_ROOT_MODEL: PublicModel;
|
466
475
|
|
467
|
-
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 };
|
476
|
+
export { type AddInstructions, type AddQuery, type AddInstructions as AddQueryInstructions, type AlterQuery, type CombinedInstructions, type CountInstructions, type CountQuery, type CountInstructions as CountQueryInstructions, type CreateQuery, DDL_QUERY_TYPES, DML_QUERY_TYPES, DML_READ_QUERY_TYPES, DML_WRITE_QUERY_TYPES, 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
@@ -1,4 +1,11 @@
|
|
1
|
-
// src/utils/
|
1
|
+
// src/utils/constants.ts
|
2
|
+
var DML_READ_QUERY_TYPES = ["get", "count"];
|
3
|
+
var DML_WRITE_QUERY_TYPES = ["set", "add", "remove"];
|
4
|
+
var DML_QUERY_TYPES = [
|
5
|
+
...DML_READ_QUERY_TYPES,
|
6
|
+
...DML_WRITE_QUERY_TYPES
|
7
|
+
];
|
8
|
+
var DDL_QUERY_TYPES = ["create", "alter", "drop"];
|
2
9
|
var QUERY_SYMBOLS = {
|
3
10
|
// Represents a sub query.
|
4
11
|
QUERY: "__RONIN_QUERY",
|
@@ -24,6 +31,8 @@ var CURRENT_TIME_EXPRESSION = {
|
|
24
31
|
[QUERY_SYMBOLS.EXPRESSION]: `strftime('%Y-%m-%dT%H:%M:%f', 'now') || 'Z'`
|
25
32
|
};
|
26
33
|
var MOUNTING_PATH_SUFFIX = /(.*?)(\{(\d+)\})?$/;
|
34
|
+
|
35
|
+
// src/utils/helpers.ts
|
27
36
|
var composeMountingPath = (single, key, mountingPath) => {
|
28
37
|
if (key === "ronin_root") {
|
29
38
|
return mountingPath ? mountingPath.replace(
|
@@ -1192,7 +1201,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
1192
1201
|
if (queryType === "get" && !isJoiningMultipleRows && (single || instructions?.limitedTo)) {
|
1193
1202
|
statement += handleLimitedTo(single, instructions?.limitedTo);
|
1194
1203
|
}
|
1195
|
-
if (
|
1204
|
+
if (DML_WRITE_QUERY_TYPES.includes(queryType) && returning) {
|
1196
1205
|
statement += `RETURNING ${columns}`;
|
1197
1206
|
}
|
1198
1207
|
const mainStatement = {
|
@@ -2367,6 +2376,10 @@ var Transaction = class {
|
|
2367
2376
|
};
|
2368
2377
|
var CLEAN_ROOT_MODEL = omit(ROOT_MODEL, ["system"]);
|
2369
2378
|
export {
|
2379
|
+
DDL_QUERY_TYPES,
|
2380
|
+
DML_QUERY_TYPES,
|
2381
|
+
DML_READ_QUERY_TYPES,
|
2382
|
+
DML_WRITE_QUERY_TYPES,
|
2370
2383
|
QUERY_SYMBOLS,
|
2371
2384
|
CLEAN_ROOT_MODEL as ROOT_MODEL,
|
2372
2385
|
RoninError,
|
package/package.json
CHANGED