@ronin/compiler 0.13.3-leo-ron-1071-experimental-294 → 0.13.4-leo-ron-1071-experimental-295

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 CHANGED
@@ -147,7 +147,10 @@ interface Statement {
147
147
  }
148
148
 
149
149
  type ModelFieldCollation = 'BINARY' | 'NOCASE' | 'RTRIM';
150
+ type ModelFieldLinkAction = 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT' | 'NO ACTION';
150
151
  type ModelFieldBasics = {
152
+ /** The kind of value that should be stored inside the field. */
153
+ type?: 'boolean' | 'date' | 'json';
151
154
  /** The label that should be used when displaying the field on the RONIN dashboard. */
152
155
  name?: string;
153
156
  /** Allows for addressing the field programmatically. */
@@ -180,31 +183,34 @@ type ModelFieldBasics = {
180
183
  };
181
184
  /** An expression that gets evaluated every time a value is provided for the field. */
182
185
  check?: Expression;
183
- /**
184
- * If the field is of type `string`, setting this attribute defines the collation
185
- * sequence to use for the field value.
186
- */
186
+ };
187
+ type ModelField = ModelFieldBasics | (Omit<ModelFieldBasics, 'type'> & {
188
+ /** The kind of value that should be stored inside the field. */
189
+ type: 'string';
190
+ /** The collation sequence to use for the field value. */
187
191
  collation?: ModelFieldCollation;
192
+ }) | (Omit<ModelFieldBasics, 'type'> & {
193
+ /** The kind of value that should be stored inside the field. */
194
+ type: 'number';
188
195
  /**
189
- * If the field is of type `number`, setting this attribute will automatically increment
190
- * the value of the field with every new record that gets inserted.
196
+ * Automatically increments the value of the field with every new inserted record.
191
197
  */
192
198
  increment?: boolean;
193
- };
194
- type ModelFieldNormal = ModelFieldBasics & {
195
- type?: 'string' | 'number' | 'boolean' | 'date' | 'json';
196
- };
197
- type ModelFieldReferenceAction = 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT' | 'NO ACTION';
198
- type ModelFieldReference = ModelFieldBasics & {
199
+ }) | (Omit<ModelFieldBasics, 'type'> & {
200
+ /** The kind of value that should be stored inside the field. */
199
201
  type: 'link';
202
+ /** The target model of the relationship that is being established. */
200
203
  target: string;
204
+ /** Whether the field should be related to one record, or many records. */
201
205
  kind?: 'one' | 'many';
206
+ /**
207
+ * If the target record is updated or deleted, the defined actions maybe executed.
208
+ */
202
209
  actions?: {
203
- onDelete?: ModelFieldReferenceAction;
204
- onUpdate?: ModelFieldReferenceAction;
210
+ onDelete?: ModelFieldLinkAction;
211
+ onUpdate?: ModelFieldLinkAction;
205
212
  };
206
- };
207
- type ModelField = ModelFieldNormal | ModelFieldReference;
213
+ });
208
214
  type ModelIndexField<T extends Array<ModelField> = Array<ModelField>> = {
209
215
  /** The collating sequence used for text placed inside the field. */
210
216
  collation?: ModelFieldCollation;
package/dist/index.js CHANGED
@@ -840,8 +840,12 @@ var getFieldStatement = (models, model, field) => {
840
840
  if (symbol) value = `(${parseFieldExpression(model, "to", symbol.value)})`;
841
841
  statement += ` DEFAULT ${value}`;
842
842
  }
843
- if (field.collation) statement += ` COLLATE ${field.collation}`;
844
- if (field.increment === true) statement += " AUTOINCREMENT";
843
+ if (field.type === "string" && field.collation) {
844
+ statement += ` COLLATE ${field.collation}`;
845
+ }
846
+ if (field.type === "number" && field.increment === true) {
847
+ statement += " AUTOINCREMENT";
848
+ }
845
849
  if (typeof field.check !== "undefined") {
846
850
  const symbol = getSymbol(field.check);
847
851
  statement += ` CHECK (${parseFieldExpression(model, "to", symbol?.value)})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.13.3-leo-ron-1071-experimental-294",
3
+ "version": "0.13.4-leo-ron-1071-experimental-295",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {