@ronin/compiler 0.18.3 → 0.18.4-invalid-json-experimental-443

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
@@ -392,7 +392,7 @@ type ExpandedResult<T = ResultRecord> = {
392
392
  };
393
393
  type Result<T = ResultRecord> = RegularResult<T> | ExpandedResult<T>;
394
394
 
395
- 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';
395
+ 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' | 'INVALID_FIELD_VALUE' | 'EXISTING_MODEL_ENTITY' | 'REQUIRED_MODEL_ENTITY' | 'MUTUALLY_EXCLUSIVE_INSTRUCTIONS' | 'MISSING_INSTRUCTION' | 'MISSING_FIELD';
396
396
  interface Issue {
397
397
  message: string;
398
398
  path: Array<string | number>;
package/dist/index.js CHANGED
@@ -1371,8 +1371,18 @@ var composeConditions = (models, model, statementParams, instructionName, value,
1371
1371
  instructionName
1372
1372
  });
1373
1373
  const { field: modelField } = fieldDetails || {};
1374
- const consumeJSON = (modelField?.type === "json" || modelField?.type === "blob") && instructionName === "to";
1375
- if (modelField && !(isObject(value) || Array.isArray(value)) || getQuerySymbol(value) || consumeJSON) {
1374
+ const fieldIsJSON = (modelField?.type === "json" || modelField?.type === "blob") && instructionName === "to";
1375
+ const valueIsJSON = isObject(value) || (modelField?.type === "blob" ? null : Array.isArray(value));
1376
+ if (!valueIsJSON || getQuerySymbol(value) || fieldIsJSON) {
1377
+ if (modelField && fieldIsJSON && !valueIsJSON && value !== null) {
1378
+ const messagePrefix = "The provided field value is not";
1379
+ const message = modelField.type === "json" ? `${messagePrefix} valid JSON. Only objects and arrays should be provided. Other types of values should be stored in their respective primitive field types.` : `${messagePrefix} a valid Blob reference.`;
1380
+ throw new RoninError({
1381
+ message,
1382
+ field: modelField?.slug,
1383
+ code: "INVALID_FIELD_VALUE"
1384
+ });
1385
+ }
1376
1386
  return composeFieldValues(
1377
1387
  models,
1378
1388
  model,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.18.3",
3
+ "version": "0.18.4-invalid-json-experimental-443",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {