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