@ronin/compiler 0.14.5 → 0.14.6-corny-ron-1099-experimental-331

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
@@ -57,7 +57,21 @@ type QueryTypeEnum = 'get' | 'set' | 'add' | 'remove' | 'count';
57
57
  type ModelQueryTypeEnum = 'create' | 'alter' | 'drop';
58
58
  type ModelEntityEnum = 'field' | 'index' | 'trigger' | 'preset';
59
59
  type FieldValue = string | number | boolean | null | unknown;
60
- type FieldSelector = Record<string, FieldValue>;
60
+ type FieldSelector = Record<string, FieldValue | StoredObject>;
61
+ type StoredObject = {
62
+ key: string;
63
+ src: string;
64
+ name: string | null;
65
+ placeholder: {
66
+ base64: string | null;
67
+ } | null;
68
+ meta: {
69
+ size: number;
70
+ type: string;
71
+ width?: number;
72
+ height?: number;
73
+ };
74
+ };
61
75
  type Expression = {
62
76
  [QUERY_SYMBOLS.EXPRESSION]: string;
63
77
  };
@@ -185,7 +199,7 @@ type ModelFieldBasics = {
185
199
  * The value that should be inserted into the field in the case that no value was
186
200
  * explicitly provided for it when a record is created.
187
201
  */
188
- defaultValue?: Expression | unknown;
202
+ defaultValue?: Expression | unknown | (() => Expression);
189
203
  /**
190
204
  * An expression that should be evaluated to form the value of the field. The
191
205
  * expression can either be VIRTUAL (evaluated whenever a record is read) or STORED
@@ -193,10 +207,10 @@ type ModelFieldBasics = {
193
207
  */
194
208
  computedAs?: {
195
209
  kind: 'VIRTUAL' | 'STORED';
196
- value: Expression;
210
+ value: Expression | unknown | ((fields: Record<string, unknown>) => Expression);
197
211
  };
198
212
  /** An expression that gets evaluated every time a value is provided for the field. */
199
- check?: Expression;
213
+ check?: Expression | ((fields: Record<string, unknown>) => Expression);
200
214
  };
201
215
  type ModelField = ModelFieldBasics & ({
202
216
  /** The kind of value that should be stored inside the field. */
@@ -394,4 +408,4 @@ declare class Transaction {
394
408
 
395
409
  declare const CLEAN_ROOT_MODEL: PublicModel;
396
410
 
397
- 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 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 RemoveInstructions, type RemoveQuery, type RemoveInstructions as RemoveQueryInstructions, type Result, RoninError, type SetInstructions, type SetQuery, type SetInstructions as SetQueryInstructions, type Statement, Transaction, type WithInstruction, getQuerySymbol };
411
+ 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 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 RemoveInstructions, type RemoveQuery, type RemoveInstructions as RemoveQueryInstructions, type Result, RoninError, type SetInstructions, type SetQuery, type SetInstructions as SetQueryInstructions, type Statement, type StoredObject, Transaction, type WithInstruction, getQuerySymbol };
package/dist/index.js CHANGED
@@ -882,7 +882,7 @@ var composeConditions = (models, model, statementParams, instructionName, value,
882
882
  instructionName
883
883
  });
884
884
  const { field: modelField } = fieldDetails || {};
885
- const consumeJSON = modelField?.type === "json" && instructionName === "to";
885
+ const consumeJSON = (modelField?.type === "json" || modelField?.type === "blob") && instructionName === "to";
886
886
  if (modelField && !(isObject(value) || Array.isArray(value)) || getQuerySymbol(value) || consumeJSON) {
887
887
  return composeFieldValues(
888
888
  models,
@@ -1389,7 +1389,7 @@ var composeAssociationModelSlug = (model, field) => convertToCamelCase(`ronin_li
1389
1389
  var getFieldSelector = (model, field, fieldPath, writing) => {
1390
1390
  const symbol = model.tableAlias?.startsWith(QUERY_SYMBOLS.FIELD_PARENT) ? `${model.tableAlias.replace(QUERY_SYMBOLS.FIELD_PARENT, "").slice(0, -1)}.` : "";
1391
1391
  const tablePrefix = symbol || (model.tableAlias ? `"${model.tableAlias}".` : "");
1392
- if (field.type === "json" && !writing) {
1392
+ if ((field.type === "json" || field.type === "blob") && !writing) {
1393
1393
  const dotParts = fieldPath.split(".");
1394
1394
  const columnName = tablePrefix + dotParts.shift();
1395
1395
  if (dotParts.length > 0) {
@@ -1407,7 +1407,7 @@ function getFieldFromModel(model, fieldPath, source, shouldThrow = true) {
1407
1407
  let modelField;
1408
1408
  if (fieldPath.includes(".")) {
1409
1409
  modelField = modelFields.find((field) => field.slug === fieldPath.split(".")[0]);
1410
- if (modelField?.type === "json") {
1410
+ if (modelField?.type === "json" || modelField?.type === "blob") {
1411
1411
  const fieldSelector2 = getFieldSelector(model, modelField, fieldPath, writingField);
1412
1412
  return { field: modelField, fieldSelector: fieldSelector2 };
1413
1413
  }
@@ -2009,7 +2009,7 @@ var Transaction = class {
2009
2009
  const record = fields.reduce((acc, field, fieldIndex) => {
2010
2010
  let newSlug = field.mountingPath;
2011
2011
  let newValue = row[fieldIndex];
2012
- if (field.type === "json") {
2012
+ if (field.type === "json" || field.type === "blob") {
2013
2013
  newValue = JSON.parse(newValue);
2014
2014
  } else if (field.type === "boolean") {
2015
2015
  newValue = Boolean(newValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.14.5",
3
+ "version": "0.14.6-corny-ron-1099-experimental-331",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {