-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
127 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** Query types used for reading data. */ | ||
export const DML_READ_QUERY_TYPES = ['get', 'count'] as const; | ||
|
||
/** Query types used for writing data. */ | ||
export const DML_WRITE_QUERY_TYPES = ['set', 'add', 'remove'] as const; | ||
|
||
/** Query types used for interacting with data. */ | ||
export const DML_QUERY_TYPES = [ | ||
...DML_READ_QUERY_TYPES, | ||
...DML_WRITE_QUERY_TYPES, | ||
] as const; | ||
|
||
/** Query types used for interacting with the database schema. */ | ||
export const DDL_QUERY_TYPES = ['create', 'alter', 'drop'] as const; | ||
|
||
/** | ||
* A list of placeholders that can be located inside queries after those queries were | ||
* serialized into JSON objects. | ||
* | ||
* These placeholders are used to represent special keys and values. For example, if a | ||
* query is nested into a query, the nested query will be marked with `__RONIN_QUERY`, | ||
* which allows for distinguishing that nested query from an object of instructions. | ||
*/ | ||
export const QUERY_SYMBOLS = { | ||
// Represents a sub query. | ||
QUERY: '__RONIN_QUERY', | ||
|
||
// Represents an expression that should be evaluated. | ||
EXPRESSION: '__RONIN_EXPRESSION', | ||
|
||
// Represents the value of a field in the model. | ||
FIELD: '__RONIN_FIELD_', | ||
|
||
// Represents the value of a field in the model of a parent query. | ||
FIELD_PARENT: '__RONIN_FIELD_PARENT_', | ||
|
||
// Represents the old value of a field in the parent model. Used for triggers. | ||
FIELD_PARENT_OLD: '__RONIN_FIELD_PARENT_OLD_', | ||
|
||
// Represents the new value of a field in the parent model. Used for triggers. | ||
FIELD_PARENT_NEW: '__RONIN_FIELD_PARENT_NEW_', | ||
|
||
// Represents a value provided to a query preset. | ||
VALUE: '__RONIN_VALUE', | ||
} as const; | ||
|
||
/** | ||
* A regular expression for matching the symbol that represents a field of a model. | ||
*/ | ||
export const RONIN_MODEL_FIELD_REGEX = new RegExp( | ||
`${QUERY_SYMBOLS.FIELD}[_a-zA-Z0-9.]+`, | ||
'g', | ||
); | ||
|
||
// JavaScript types that can directly be used as field types in RONIN. | ||
export const RAW_FIELD_TYPES = ['string', 'number', 'boolean'] as const; | ||
export type RawFieldType = (typeof RAW_FIELD_TYPES)[number]; | ||
|
||
// An expression that produces a timestamp in the format "YYYY-MM-DDTHH:MM:SS.SSSZ", | ||
// which matches the output of `new Date().toISOString()` in JavaScript (ISO 8601). | ||
export const CURRENT_TIME_EXPRESSION = { | ||
[QUERY_SYMBOLS.EXPRESSION]: `strftime('%Y-%m-%dT%H:%M:%f', 'now') || 'Z'`, | ||
}; | ||
|
||
// A regular expression for splitting up the components of a field mounting path, meaning | ||
// the path within a record under which a particular field's value should be mounted. | ||
export const MOUNTING_PATH_SUFFIX = /(.*?)(\{(\d+)\})?$/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters