kintone-migrator 0.16.0 → 0.17.0

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.mjs CHANGED
@@ -321,6 +321,42 @@ function isSystemError(error) {
321
321
  return error instanceof SystemError;
322
322
  }
323
323
 
324
+ //#endregion
325
+ //#region src/core/domain/typeGuards.ts
326
+ /**
327
+ * Type guard utilities for safe runtime type narrowing.
328
+ * Use these functions instead of `as` casts when working with `unknown` values.
329
+ */
330
+ /**
331
+ * Narrows `unknown` to `Record<string, unknown>`.
332
+ * Returns true when the value is a non-null object (and not an array).
333
+ */
334
+ function isRecord$1(value) {
335
+ return typeof value === "object" && value !== null && !Array.isArray(value);
336
+ }
337
+ /**
338
+ * Narrows `unknown` to `{ code: string }`.
339
+ */
340
+ function hasCode(value) {
341
+ return isRecord$1(value) && typeof value.code === "string";
342
+ }
343
+ /**
344
+ * Narrows `unknown` to `{ value: Record<string, { value: unknown }> }`.
345
+ * Used when processing kintone subtable rows.
346
+ */
347
+ function isKintoneSubtableRow(value) {
348
+ if (!isRecord$1(value)) return false;
349
+ if (!isRecord$1(value.value)) return false;
350
+ return Object.values(value.value).every((cell) => isRecord$1(cell) && "value" in cell);
351
+ }
352
+ /**
353
+ * Narrows `unknown` to `{ type?: string }`.
354
+ */
355
+ function hasOptionalType(value) {
356
+ if (!isRecord$1(value)) return false;
357
+ return value.type === void 0 || typeof value.type === "string";
358
+ }
359
+
324
360
  //#endregion
325
361
  //#region src/core/domain/action/valueObject.ts
326
362
  const VALID_SRC_TYPES = new Set(["FIELD", "RECORD_URL"]);
@@ -333,7 +369,7 @@ const VALID_ENTITY_TYPES$10 = new Set([
333
369
  //#endregion
334
370
  //#region src/core/domain/action/services/configParser.ts
335
371
  function parseDestApp(raw, actionName) {
336
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" destApp must be an object`);
372
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" destApp must be an object`);
337
373
  const obj = raw;
338
374
  const result = {};
339
375
  if (obj.app !== void 0 && obj.app !== null) result.app = String(obj.app);
@@ -341,7 +377,7 @@ function parseDestApp(raw, actionName) {
341
377
  return result;
342
378
  }
343
379
  function parseMapping(raw, index, actionName) {
344
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" mapping at index ${index} must be an object`);
380
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" mapping at index ${index} must be an object`);
345
381
  const obj = raw;
346
382
  if (typeof obj.srcType !== "string" || !VALID_SRC_TYPES.has(obj.srcType)) throw new BusinessRuleError(ActionErrorCode.AcInvalidSrcType, `Action "${actionName}" mapping at index ${index} has invalid srcType: ${String(obj.srcType)}. Must be FIELD or RECORD_URL`);
347
383
  if (typeof obj.destField !== "string" || obj.destField.length === 0) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" mapping at index ${index} must have a non-empty "destField" property`);
@@ -352,7 +388,7 @@ function parseMapping(raw, index, actionName) {
352
388
  };
353
389
  }
354
390
  function parseEntity$4(raw, index, actionName) {
355
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" entity at index ${index} must be an object`);
391
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" entity at index ${index} must be an object`);
356
392
  const obj = raw;
357
393
  if (typeof obj.type !== "string" || !VALID_ENTITY_TYPES$10.has(obj.type)) throw new BusinessRuleError(ActionErrorCode.AcInvalidEntityType, `Action "${actionName}" entity at index ${index} has invalid type: ${String(obj.type)}. Must be USER, GROUP, or ORGANIZATION`);
358
394
  if (typeof obj.code !== "string" || obj.code.length === 0) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" entity at index ${index} must have a non-empty "code" property`);
@@ -362,11 +398,11 @@ function parseEntity$4(raw, index, actionName) {
362
398
  };
363
399
  }
364
400
  function parseActionConfig(raw, actionName) {
365
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" must be an object`);
401
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" must be an object`);
366
402
  const obj = raw;
367
403
  if (actionName.length === 0) throw new BusinessRuleError(ActionErrorCode.AcEmptyActionName, "Action name (key) must not be empty");
368
404
  if (typeof obj.index !== "number") throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" must have a numeric "index" property`);
369
- if (typeof obj.destApp !== "object" || obj.destApp === null) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" must have a "destApp" object`);
405
+ if (!isRecord$1(obj.destApp)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" must have a "destApp" object`);
370
406
  const destApp = parseDestApp(obj.destApp, actionName);
371
407
  if (!Array.isArray(obj.mappings)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, `Action "${actionName}" must have a "mappings" array`);
372
408
  const mappings = obj.mappings.map((item, i) => parseMapping(item, i, actionName));
@@ -390,9 +426,9 @@ const ActionConfigParser = { parse: (rawText) => {
390
426
  } catch (error) {
391
427
  throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
392
428
  }
393
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, "Config must be a YAML object");
429
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, "Config must be a YAML object");
394
430
  const obj = parsed;
395
- if (typeof obj.actions !== "object" || obj.actions === null) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, "Config must have an \"actions\" object");
431
+ if (!isRecord$1(obj.actions)) throw new BusinessRuleError(ActionErrorCode.AcInvalidConfigStructure, "Config must have an \"actions\" object");
396
432
  const rawActions = obj.actions;
397
433
  const actions = {};
398
434
  for (const [key, value] of Object.entries(rawActions)) actions[key] = parseActionConfig(value, key);
@@ -2326,7 +2362,7 @@ const AdminNotesConfigParser = { parse: (rawText) => {
2326
2362
  } catch (error) {
2327
2363
  throw new BusinessRuleError(AdminNotesErrorCode.AnInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
2328
2364
  }
2329
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(AdminNotesErrorCode.AnInvalidConfigStructure, "Config must be a YAML object");
2365
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(AdminNotesErrorCode.AnInvalidConfigStructure, "Config must be a YAML object");
2330
2366
  const obj = parsed;
2331
2367
  if (typeof obj.content !== "string") throw new BusinessRuleError(AdminNotesErrorCode.AnInvalidConfigStructure, "Config must have a \"content\" string property");
2332
2368
  if (typeof obj.includeInTemplateAndDuplicates !== "boolean") throw new BusinessRuleError(AdminNotesErrorCode.AnInvalidConfigStructure, "Config must have an \"includeInTemplateAndDuplicates\" boolean property");
@@ -2623,7 +2659,7 @@ const VALID_ENTITY_TYPES$9 = new Set([
2623
2659
  "CREATOR"
2624
2660
  ]);
2625
2661
  function parseEntity$3(raw, index) {
2626
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigStructure, `Entity at index ${index} must be an object`);
2662
+ if (!isRecord$1(raw)) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigStructure, `Entity at index ${index} must be an object`);
2627
2663
  const obj = raw;
2628
2664
  if (typeof obj.type !== "string" || !VALID_ENTITY_TYPES$9.has(obj.type)) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidEntityType, `Entity at index ${index} has invalid type: ${String(obj.type)}. Must be USER, GROUP, ORGANIZATION, or CREATOR`);
2629
2665
  const type = obj.type;
@@ -2643,7 +2679,7 @@ function parseBooleanField$1(obj, field, index) {
2643
2679
  return value;
2644
2680
  }
2645
2681
  function parseAppRight(raw, index) {
2646
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigStructure, `App right at index ${index} must be an object`);
2682
+ if (!isRecord$1(raw)) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigStructure, `App right at index ${index} must be an object`);
2647
2683
  const obj = raw;
2648
2684
  return {
2649
2685
  entity: parseEntity$3(obj.entity, index),
@@ -2665,7 +2701,7 @@ const AppPermissionConfigParser = { parse: (rawText) => {
2665
2701
  } catch (error) {
2666
2702
  throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
2667
2703
  }
2668
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigStructure, "Config must be a YAML object");
2704
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigStructure, "Config must be a YAML object");
2669
2705
  const obj = parsed;
2670
2706
  if (!Array.isArray(obj.rights)) throw new BusinessRuleError(AppPermissionErrorCode.ApInvalidConfigStructure, "Config must have a \"rights\" array");
2671
2707
  const rights = obj.rights.map((item, i) => parseAppRight(item, i));
@@ -3048,7 +3084,7 @@ const VALID_SCOPES = new Set([
3048
3084
  ]);
3049
3085
  const VALID_RESOURCE_TYPES = new Set(["FILE", "URL"]);
3050
3086
  function parseResource(raw, index) {
3051
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(CustomizationErrorCode.CzInvalidConfigStructure, `Resource at index ${index} must be an object`);
3087
+ if (!isRecord$1(raw)) throw new BusinessRuleError(CustomizationErrorCode.CzInvalidConfigStructure, `Resource at index ${index} must be an object`);
3052
3088
  const obj = raw;
3053
3089
  const type = obj.type;
3054
3090
  if (typeof type !== "string" || !VALID_RESOURCE_TYPES.has(type)) throw new BusinessRuleError(CustomizationErrorCode.CzInvalidResourceType, `Resource at index ${index} has invalid type: ${String(type)}. Must be FILE or URL`);
@@ -3070,7 +3106,7 @@ function parseResourceList(raw) {
3070
3106
  return raw.map((item, index) => parseResource(item, index));
3071
3107
  }
3072
3108
  function parsePlatform(raw) {
3073
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new BusinessRuleError(CustomizationErrorCode.CzInvalidConfigStructure, "Platform configuration must be an object");
3109
+ if (!isRecord$1(raw)) throw new BusinessRuleError(CustomizationErrorCode.CzInvalidConfigStructure, "Platform configuration must be an object");
3074
3110
  const obj = raw;
3075
3111
  return {
3076
3112
  js: obj.js === void 0 || obj.js === null ? [] : parseResourceList(obj.js),
@@ -3085,7 +3121,7 @@ const ConfigParser = { parse: (rawText) => {
3085
3121
  } catch (error) {
3086
3122
  throw new BusinessRuleError(CustomizationErrorCode.CzInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
3087
3123
  }
3088
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(CustomizationErrorCode.CzInvalidConfigStructure, "Config must be a YAML object");
3124
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(CustomizationErrorCode.CzInvalidConfigStructure, "Config must be a YAML object");
3089
3125
  const obj = parsed;
3090
3126
  let scope;
3091
3127
  if (obj.scope !== void 0 && obj.scope !== null) {
@@ -3660,7 +3696,7 @@ const VALID_ENTITY_TYPES$6 = new Set([
3660
3696
  "FIELD_ENTITY"
3661
3697
  ]);
3662
3698
  function parseEntity$2(raw, index) {
3663
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, `Entity at index ${index} must be an object`);
3699
+ if (!isRecord$1(raw)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, `Entity at index ${index} must be an object`);
3664
3700
  const obj = raw;
3665
3701
  if (typeof obj.type !== "string" || !VALID_ENTITY_TYPES$6.has(obj.type)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidEntityType, `Entity at index ${index} has invalid type: ${String(obj.type)}. Must be USER, GROUP, ORGANIZATION, or FIELD_ENTITY`);
3666
3702
  if (typeof obj.code !== "string" || obj.code.length === 0) throw new BusinessRuleError(FieldPermissionErrorCode.FpEmptyEntityCode, `Entity at index ${index} must have a non-empty "code" property`);
@@ -3670,7 +3706,7 @@ function parseEntity$2(raw, index) {
3670
3706
  };
3671
3707
  }
3672
3708
  function parseFieldRightEntity(raw, index) {
3673
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, `Field right entity at index ${index} must be an object`);
3709
+ if (!isRecord$1(raw)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, `Field right entity at index ${index} must be an object`);
3674
3710
  const obj = raw;
3675
3711
  if (typeof obj.accessibility !== "string" || !VALID_ACCESSIBILITIES.has(obj.accessibility)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidAccessibility, `Field right entity at index ${index} has invalid accessibility: ${String(obj.accessibility)}. Must be READ, WRITE, or NONE`);
3676
3712
  const entity = parseEntity$2(obj.entity, index);
@@ -3685,7 +3721,7 @@ function parseFieldRightEntity(raw, index) {
3685
3721
  return result;
3686
3722
  }
3687
3723
  function parseFieldRight(raw, index) {
3688
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, `Field right at index ${index} must be an object`);
3724
+ if (!isRecord$1(raw)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, `Field right at index ${index} must be an object`);
3689
3725
  const obj = raw;
3690
3726
  if (typeof obj.code !== "string" || obj.code.length === 0) throw new BusinessRuleError(FieldPermissionErrorCode.FpEmptyFieldCode, `Field right at index ${index} must have a non-empty "code" property`);
3691
3727
  if (!Array.isArray(obj.entities)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, `Field right at index ${index} must have an "entities" array`);
@@ -3703,7 +3739,7 @@ const FieldPermissionConfigParser = { parse: (rawText) => {
3703
3739
  } catch (error) {
3704
3740
  throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
3705
3741
  }
3706
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, "Config must be a YAML object");
3742
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, "Config must be a YAML object");
3707
3743
  const obj = parsed;
3708
3744
  if (!Array.isArray(obj.rights)) throw new BusinessRuleError(FieldPermissionErrorCode.FpInvalidConfigStructure, "Config must have a \"rights\" array");
3709
3745
  const rights = obj.rights.map((item, i) => parseFieldRight(item, i));
@@ -5917,8 +5953,8 @@ function fromKintoneFieldValue(value) {
5917
5953
  const first = value[0];
5918
5954
  if (typeof first === "string") return value;
5919
5955
  if (typeof first === "object" && first !== null) {
5920
- if ("code" in first && !("value" in first)) return value.map((u) => ({ code: u.code }));
5921
- if ("value" in first) return value.map((row) => {
5956
+ if ("code" in first && !("value" in first)) return value.filter(hasCode).map((u) => ({ code: u.code }));
5957
+ if ("value" in first) return value.filter(isKintoneSubtableRow).map((row) => {
5922
5958
  const cells = row.value;
5923
5959
  const flat = {};
5924
5960
  for (const [k, cell] of Object.entries(cells)) {
@@ -5946,7 +5982,7 @@ const RecordConverter = {
5946
5982
  const seedRecord = {};
5947
5983
  for (const [fieldCode, cell] of Object.entries(record)) {
5948
5984
  if (SYSTEM_FIELDS.has(fieldCode)) continue;
5949
- const fieldType = cell.type;
5985
+ const fieldType = hasOptionalType(cell) ? cell.type : void 0;
5950
5986
  if (fieldType !== void 0 && SYSTEM_FIELD_TYPES$1.has(fieldType)) continue;
5951
5987
  seedRecord[fieldCode] = fromKintoneFieldValue(cell.value);
5952
5988
  }
@@ -6391,7 +6427,7 @@ const VALID_ENTITY_TYPES$2 = new Set([
6391
6427
  "FIELD_ENTITY"
6392
6428
  ]);
6393
6429
  function parseEntity$1(raw, context) {
6394
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `${context}: entity must be an object`);
6430
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `${context}: entity must be an object`);
6395
6431
  const obj = raw;
6396
6432
  if (typeof obj.type !== "string" || !VALID_ENTITY_TYPES$2.has(obj.type)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidEntityType, `${context}: entity has invalid type: ${String(obj.type)}. Must be USER, GROUP, ORGANIZATION, or FIELD_ENTITY`);
6397
6433
  if (typeof obj.code !== "string" || obj.code.length === 0) throw new BusinessRuleError(NotificationErrorCode.NtEmptyEntityCode, `${context}: entity must have a non-empty "code" property`);
@@ -6401,7 +6437,7 @@ function parseEntity$1(raw, context) {
6401
6437
  };
6402
6438
  }
6403
6439
  function parseGeneralNotification(raw, index) {
6404
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `General notification at index ${index} must be an object`);
6440
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `General notification at index ${index} must be an object`);
6405
6441
  const obj = raw;
6406
6442
  const result = {
6407
6443
  entity: parseEntity$1(obj.entity, `General notification at index ${index}`),
@@ -6418,7 +6454,7 @@ function parseGeneralNotification(raw, index) {
6418
6454
  return result;
6419
6455
  }
6420
6456
  function parseGeneralConfig(raw) {
6421
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "\"general\" must be an object");
6457
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "\"general\" must be an object");
6422
6458
  const obj = raw;
6423
6459
  if (!Array.isArray(obj.notifications)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "\"general\" must have a \"notifications\" array");
6424
6460
  const notifications = obj.notifications.map((item, i) => parseGeneralNotification(item, i));
@@ -6428,7 +6464,7 @@ function parseGeneralConfig(raw) {
6428
6464
  };
6429
6465
  }
6430
6466
  function parsePerRecordTarget(raw, index) {
6431
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Per-record target at index ${index} must be an object`);
6467
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Per-record target at index ${index} must be an object`);
6432
6468
  const obj = raw;
6433
6469
  const result = { entity: parseEntity$1(obj.entity, `Per-record target at index ${index}`) };
6434
6470
  if (obj.includeSubs !== void 0 && obj.includeSubs !== null) return {
@@ -6438,7 +6474,7 @@ function parsePerRecordTarget(raw, index) {
6438
6474
  return result;
6439
6475
  }
6440
6476
  function parsePerRecordNotification(raw, index) {
6441
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Per-record notification at index ${index} must be an object`);
6477
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Per-record notification at index ${index} must be an object`);
6442
6478
  const obj = raw;
6443
6479
  if (!Array.isArray(obj.targets)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Per-record notification at index ${index} must have a "targets" array`);
6444
6480
  const targets = obj.targets.map((item, i) => parsePerRecordTarget(item, i));
@@ -6454,7 +6490,7 @@ function parsePerRecordConfig(raw) {
6454
6490
  return raw.map((item, i) => parsePerRecordNotification(item, i));
6455
6491
  }
6456
6492
  function parseReminderTarget(raw, index) {
6457
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Reminder target at index ${index} must be an object`);
6493
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Reminder target at index ${index} must be an object`);
6458
6494
  const obj = raw;
6459
6495
  const result = { entity: parseEntity$1(obj.entity, `Reminder target at index ${index}`) };
6460
6496
  if (obj.includeSubs !== void 0 && obj.includeSubs !== null) return {
@@ -6464,7 +6500,7 @@ function parseReminderTarget(raw, index) {
6464
6500
  return result;
6465
6501
  }
6466
6502
  function parseReminderNotification(raw, index) {
6467
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Reminder notification at index ${index} must be an object`);
6503
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Reminder notification at index ${index} must be an object`);
6468
6504
  const obj = raw;
6469
6505
  if (typeof obj.code !== "string" || obj.code.length === 0) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Reminder notification at index ${index} must have a non-empty "code" property`);
6470
6506
  if (!Array.isArray(obj.targets)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, `Reminder notification at index ${index} must have a "targets" array`);
@@ -6491,7 +6527,7 @@ function parseReminderNotification(raw, index) {
6491
6527
  return result;
6492
6528
  }
6493
6529
  function parseReminderConfig(raw) {
6494
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "\"reminder\" must be an object");
6530
+ if (!isRecord$1(raw)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "\"reminder\" must be an object");
6495
6531
  const obj = raw;
6496
6532
  if (!Array.isArray(obj.notifications)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "\"reminder\" must have a \"notifications\" array");
6497
6533
  const notifications = obj.notifications.map((item, i) => parseReminderNotification(item, i));
@@ -6508,7 +6544,7 @@ const NotificationConfigParser = { parse: (rawText) => {
6508
6544
  } catch (error) {
6509
6545
  throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
6510
6546
  }
6511
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "Config must be a YAML object");
6547
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(NotificationErrorCode.NtInvalidConfigStructure, "Config must be a YAML object");
6512
6548
  const obj = parsed;
6513
6549
  const config = {};
6514
6550
  if (obj.general !== void 0) config.general = parseGeneralConfig(obj.general);
@@ -6699,7 +6735,7 @@ var notification_default = define({
6699
6735
  //#endregion
6700
6736
  //#region src/core/domain/plugin/services/configParser.ts
6701
6737
  function parsePluginEntry(raw, index) {
6702
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(PluginErrorCode.PlInvalidConfigStructure, `Plugin at index ${index} must be an object`);
6738
+ if (!isRecord$1(raw)) throw new BusinessRuleError(PluginErrorCode.PlInvalidConfigStructure, `Plugin at index ${index} must be an object`);
6703
6739
  const obj = raw;
6704
6740
  if (typeof obj.id !== "string" || obj.id.length === 0) throw new BusinessRuleError(PluginErrorCode.PlEmptyPluginId, `Plugin at index ${index} must have a non-empty "id" property`);
6705
6741
  return {
@@ -6716,7 +6752,7 @@ const PluginConfigParser = { parse: (rawText) => {
6716
6752
  } catch (error) {
6717
6753
  throw new BusinessRuleError(PluginErrorCode.PlInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
6718
6754
  }
6719
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(PluginErrorCode.PlInvalidConfigStructure, "Config must be a YAML object");
6755
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(PluginErrorCode.PlInvalidConfigStructure, "Config must be a YAML object");
6720
6756
  const obj = parsed;
6721
6757
  if (!Array.isArray(obj.plugins)) throw new BusinessRuleError(PluginErrorCode.PlInvalidConfigStructure, "Config must have a \"plugins\" array");
6722
6758
  return { plugins: obj.plugins.map((item, i) => parsePluginEntry(item, i)) };
@@ -6902,7 +6938,7 @@ const VALID_ENTITY_TYPES$1 = new Set([
6902
6938
  ]);
6903
6939
  const VALID_ACTION_TYPES = new Set(["PRIMARY", "SECONDARY"]);
6904
6940
  function parseProcessEntity(raw, index) {
6905
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Entity at index ${index} must be an object`);
6941
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Entity at index ${index} must be an object`);
6906
6942
  const obj = raw;
6907
6943
  if (typeof obj.type !== "string" || !VALID_ENTITY_TYPES$1.has(obj.type)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidEntityType, `Entity at index ${index} has invalid type: ${String(obj.type)}. Must be USER, GROUP, ORGANIZATION, FIELD_ENTITY, CREATOR, or CUSTOM_FIELD`);
6908
6944
  const result = { type: obj.type };
@@ -6917,7 +6953,7 @@ function parseProcessEntity(raw, index) {
6917
6953
  return withCode;
6918
6954
  }
6919
6955
  function parseAssignee(raw, stateName) {
6920
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Assignee for state "${stateName}" must be an object`);
6956
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Assignee for state "${stateName}" must be an object`);
6921
6957
  const obj = raw;
6922
6958
  if (typeof obj.type !== "string" || !VALID_ASSIGNEE_TYPES.has(obj.type)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidAssigneeType, `Assignee for state "${stateName}" has invalid type: ${String(obj.type)}. Must be ONE, ALL, or ANY`);
6923
6959
  if (!Array.isArray(obj.entities)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Assignee for state "${stateName}" must have an "entities" array`);
@@ -6928,7 +6964,7 @@ function parseAssignee(raw, stateName) {
6928
6964
  };
6929
6965
  }
6930
6966
  function parseState(raw, stateName) {
6931
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `State "${stateName}" must be an object`);
6967
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `State "${stateName}" must be an object`);
6932
6968
  const obj = raw;
6933
6969
  if (typeof obj.index !== "number") throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `State "${stateName}" must have a numeric "index" property`);
6934
6970
  if (obj.assignee === void 0 || obj.assignee === null) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `State "${stateName}" must have an "assignee" property`);
@@ -6939,13 +6975,13 @@ function parseState(raw, stateName) {
6939
6975
  };
6940
6976
  }
6941
6977
  function parseExecutableUser(raw, actionIndex) {
6942
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Action at index ${actionIndex}: executableUser must be an object`);
6978
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Action at index ${actionIndex}: executableUser must be an object`);
6943
6979
  const obj = raw;
6944
6980
  if (!Array.isArray(obj.entities)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Action at index ${actionIndex}: executableUser must have an "entities" array`);
6945
6981
  return { entities: obj.entities.map((item, i) => parseProcessEntity(item, i)) };
6946
6982
  }
6947
6983
  function parseAction(raw, index) {
6948
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Action at index ${index} must be an object`);
6984
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Action at index ${index} must be an object`);
6949
6985
  const obj = raw;
6950
6986
  if (typeof obj.name !== "string") throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Action at index ${index} must have a "name" string property`);
6951
6987
  if (typeof obj.from !== "string") throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, `Action at index ${index} must have a "from" string property`);
@@ -6973,11 +7009,11 @@ const ProcessManagementConfigParser = { parse: (rawText) => {
6973
7009
  } catch (error) {
6974
7010
  throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
6975
7011
  }
6976
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, "Config must be a YAML object");
7012
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, "Config must be a YAML object");
6977
7013
  const obj = parsed;
6978
7014
  const enable = obj.enable !== void 0 && obj.enable !== null ? Boolean(obj.enable) : false;
6979
- if (obj.states !== void 0 && obj.states !== null && (typeof obj.states !== "object" || Array.isArray(obj.states))) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, "Config \"states\" must be an object (map of state name to state definition)");
6980
- const rawStates = obj.states ?? {};
7015
+ if (obj.states !== void 0 && obj.states !== null && !isRecord$1(obj.states)) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, "Config \"states\" must be an object (map of state name to state definition)");
7016
+ const rawStates = isRecord$1(obj.states) ? obj.states : {};
6981
7017
  const states = {};
6982
7018
  for (const [name, value] of Object.entries(rawStates)) states[name] = parseState(value, name);
6983
7019
  if (!Array.isArray(obj.actions) && obj.actions !== void 0) throw new BusinessRuleError(ProcessManagementErrorCode.PmInvalidConfigStructure, "Config \"actions\" must be an array");
@@ -7306,7 +7342,7 @@ function parseBooleanField(value, fieldName, context) {
7306
7342
  throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidPermissionValue, `${context} has invalid "${fieldName}" value: ${String(value)}. Must be a boolean`);
7307
7343
  }
7308
7344
  function parseEntity(raw, index) {
7309
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, `Entity at index ${index} must be an object`);
7345
+ if (!isRecord$1(raw)) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, `Entity at index ${index} must be an object`);
7310
7346
  const obj = raw;
7311
7347
  if (typeof obj.type !== "string" || !VALID_ENTITY_TYPES.has(obj.type)) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidEntityType, `Entity at index ${index} has invalid type: ${String(obj.type)}. Must be USER, GROUP, ORGANIZATION, or FIELD_ENTITY`);
7312
7348
  if (typeof obj.code !== "string" || obj.code.length === 0) throw new BusinessRuleError(RecordPermissionErrorCode.RpEmptyEntityCode, `Entity at index ${index} must have a non-empty "code" property`);
@@ -7316,7 +7352,7 @@ function parseEntity(raw, index) {
7316
7352
  };
7317
7353
  }
7318
7354
  function parseRecordRightEntity(raw, index) {
7319
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, `Record right entity at index ${index} must be an object`);
7355
+ if (!isRecord$1(raw)) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, `Record right entity at index ${index} must be an object`);
7320
7356
  const obj = raw;
7321
7357
  const entity = parseEntity(obj.entity, index);
7322
7358
  const context = `Record right entity at index ${index}`;
@@ -7329,7 +7365,7 @@ function parseRecordRightEntity(raw, index) {
7329
7365
  };
7330
7366
  }
7331
7367
  function parseRecordRight(raw, index) {
7332
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, `Record right at index ${index} must be an object`);
7368
+ if (!isRecord$1(raw)) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, `Record right at index ${index} must be an object`);
7333
7369
  const obj = raw;
7334
7370
  if (!Array.isArray(obj.entities)) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, `Record right at index ${index} must have an "entities" array`);
7335
7371
  const entities = obj.entities.map((item, i) => parseRecordRightEntity(item, i));
@@ -7346,7 +7382,7 @@ const RecordPermissionConfigParser = { parse: (rawText) => {
7346
7382
  } catch (error) {
7347
7383
  throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
7348
7384
  }
7349
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, "Config must be a YAML object");
7385
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, "Config must be a YAML object");
7350
7386
  const obj = parsed;
7351
7387
  if (!Array.isArray(obj.rights)) throw new BusinessRuleError(RecordPermissionErrorCode.RpInvalidConfigStructure, "Config must have a \"rights\" array");
7352
7388
  return { rights: obj.rights.map((item, i) => parseRecordRight(item, i)) };
@@ -7577,7 +7613,7 @@ const VALID_PERIODIC_EVERY = new Set([
7577
7613
  "HOUR"
7578
7614
  ]);
7579
7615
  function parseGroup(raw, index) {
7580
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Group at index ${index} must be an object`);
7616
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Group at index ${index} must be an object`);
7581
7617
  const obj = raw;
7582
7618
  if (typeof obj.code !== "string" || obj.code.length === 0) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Group at index ${index} must have a non-empty "code" property`);
7583
7619
  const result = { code: obj.code };
@@ -7591,7 +7627,7 @@ function parseGroup(raw, index) {
7591
7627
  return result;
7592
7628
  }
7593
7629
  function parseAggregation(raw, index) {
7594
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Aggregation at index ${index} must be an object`);
7630
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Aggregation at index ${index} must be an object`);
7595
7631
  const obj = raw;
7596
7632
  if (typeof obj.type !== "string" || !VALID_AGGREGATION_TYPES.has(obj.type)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Aggregation at index ${index} has invalid type: ${String(obj.type)}. Must be COUNT, SUM, AVERAGE, MAX, or MIN`);
7597
7633
  const result = { type: obj.type };
@@ -7605,7 +7641,7 @@ function parseAggregation(raw, index) {
7605
7641
  return result;
7606
7642
  }
7607
7643
  function parseSort(raw, index) {
7608
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Sort at index ${index} must be an object`);
7644
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Sort at index ${index} must be an object`);
7609
7645
  const obj = raw;
7610
7646
  if (typeof obj.by !== "string" || !VALID_SORT_BY.has(obj.by)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Sort at index ${index} has invalid by: ${String(obj.by)}. Must be TOTAL, GROUP1, GROUP2, or GROUP3`);
7611
7647
  if (typeof obj.order !== "string" || !VALID_SORT_ORDER.has(obj.order)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Sort at index ${index} has invalid order: ${String(obj.order)}. Must be ASC or DESC`);
@@ -7615,7 +7651,7 @@ function parseSort(raw, index) {
7615
7651
  };
7616
7652
  }
7617
7653
  function parsePeriodicReportPeriod(raw) {
7618
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "periodicReport.period must be an object");
7654
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "periodicReport.period must be an object");
7619
7655
  const obj = raw;
7620
7656
  if (typeof obj.every !== "string" || !VALID_PERIODIC_EVERY.has(obj.every)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `periodicReport.period has invalid every: ${String(obj.every)}. Must be YEAR, QUARTER, MONTH, WEEK, DAY, or HOUR`);
7621
7657
  const every = obj.every;
@@ -7662,7 +7698,7 @@ function parsePeriodicReportPeriod(raw) {
7662
7698
  };
7663
7699
  }
7664
7700
  function parsePeriodicReport(raw) {
7665
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "periodicReport must be an object");
7701
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "periodicReport must be an object");
7666
7702
  const obj = raw;
7667
7703
  if (typeof obj.active !== "boolean") throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "periodicReport.active must be a boolean");
7668
7704
  const period = parsePeriodicReportPeriod(obj.period);
@@ -7672,7 +7708,7 @@ function parsePeriodicReport(raw) {
7672
7708
  };
7673
7709
  }
7674
7710
  function parseReportConfig(raw, reportName) {
7675
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Report "${reportName}" must be an object`);
7711
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, `Report "${reportName}" must be an object`);
7676
7712
  const obj = raw;
7677
7713
  if (typeof obj.chartType !== "string" || !VALID_CHART_TYPES.has(obj.chartType)) throw new BusinessRuleError(ReportErrorCode.RtInvalidChartType, `Report "${reportName}" has invalid chartType: ${String(obj.chartType)}. Must be BAR, COLUMN, PIE, LINE, PIVOT_TABLE, TABLE, AREA, SPLINE, or SPLINE_AREA`);
7678
7714
  let chartMode;
@@ -7711,9 +7747,9 @@ const ReportConfigParser = { parse: (rawText) => {
7711
7747
  } catch (error) {
7712
7748
  throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
7713
7749
  }
7714
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "Config must be a YAML object");
7750
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "Config must be a YAML object");
7715
7751
  const obj = parsed;
7716
- if (typeof obj.reports !== "object" || obj.reports === null) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "Config must have a \"reports\" object");
7752
+ if (!isRecord$1(obj.reports)) throw new BusinessRuleError(ReportErrorCode.RtInvalidConfigStructure, "Config must have a \"reports\" object");
7717
7753
  const rawReports = obj.reports;
7718
7754
  const reports = {};
7719
7755
  for (const [name, value] of Object.entries(rawReports)) reports[name] = parseReportConfig(value, name);
@@ -7951,7 +7987,7 @@ function isValueEqual(a, b) {
7951
7987
  if (a === null || b === null) return a === b;
7952
7988
  if (typeof a !== typeof b) return false;
7953
7989
  if (Array.isArray(a)) return isArrayEqual$1(a, b);
7954
- if (typeof a === "object") return isRecordEqual(a, b);
7990
+ if (isRecord$1(a) && isRecord$1(b)) return isRecordEqual(a, b);
7955
7991
  return false;
7956
7992
  }
7957
7993
  function isMapEqual(a, b) {
@@ -8135,8 +8171,7 @@ const DECORATION_ATTRIBUTES = new Set(["elementId"]);
8135
8171
  const GROUP_ATTRIBUTES = new Set(["openGroup", "layout"]);
8136
8172
  const SUBTABLE_ATTRIBUTES = new Set(["fields"]);
8137
8173
  function parseSize(raw) {
8138
- if (raw === void 0 || raw === null) return void 0;
8139
- if (typeof raw !== "object") return void 0;
8174
+ if (!isRecord$1(raw)) return void 0;
8140
8175
  const obj = raw;
8141
8176
  return {
8142
8177
  ...obj.width !== void 0 ? { width: String(obj.width) } : {},
@@ -8258,10 +8293,10 @@ function parseFieldDefinitionFromFlat(raw) {
8258
8293
  const base = {
8259
8294
  code: fieldCode,
8260
8295
  label: String(raw.label ?? ""),
8261
- ...raw.noLabel !== void 0 ? { noLabel: raw.noLabel } : {}
8296
+ ...typeof raw.noLabel === "boolean" ? { noLabel: raw.noLabel } : {}
8262
8297
  };
8263
8298
  if (fieldType === "SUBTABLE") {
8264
- const rawFields = raw.fields ?? [];
8299
+ const rawFields = Array.isArray(raw.fields) ? raw.fields : [];
8265
8300
  const subFields = /* @__PURE__ */ new Map();
8266
8301
  for (const subRaw of rawFields) {
8267
8302
  const subDef = parseFieldDefinitionFromFlat(subRaw);
@@ -8274,10 +8309,10 @@ function parseFieldDefinitionFromFlat(raw) {
8274
8309
  };
8275
8310
  }
8276
8311
  if (fieldType === "REFERENCE_TABLE") {
8277
- if (raw.referenceTable === void 0 || raw.referenceTable === null || typeof raw.referenceTable !== "object") throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have a "referenceTable" property`);
8312
+ if (!isRecord$1(raw.referenceTable)) throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have a "referenceTable" property`);
8278
8313
  const refTable = raw.referenceTable;
8279
- if (refTable.relatedApp === void 0 || refTable.relatedApp === null || typeof refTable.relatedApp !== "object") throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have "referenceTable.relatedApp"`);
8280
- if (refTable.condition === void 0 || refTable.condition === null || typeof refTable.condition !== "object") throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have "referenceTable.condition"`);
8314
+ if (!isRecord$1(refTable.relatedApp)) throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have "referenceTable.relatedApp"`);
8315
+ if (!isRecord$1(refTable.condition)) throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have "referenceTable.condition"`);
8281
8316
  if (!Array.isArray(refTable.displayFields)) throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have "referenceTable.displayFields" array`);
8282
8317
  const condition = refTable.condition;
8283
8318
  const displayFields = refTable.displayFields.map((f) => FieldCode.create(f));
@@ -8287,12 +8322,12 @@ function parseFieldDefinitionFromFlat(raw) {
8287
8322
  properties: { referenceTable: {
8288
8323
  relatedApp: refTable.relatedApp,
8289
8324
  condition: {
8290
- field: FieldCode.create(condition.field),
8291
- relatedField: FieldCode.create(condition.relatedField)
8325
+ field: FieldCode.create(String(condition.field ?? "")),
8326
+ relatedField: FieldCode.create(String(condition.relatedField ?? ""))
8292
8327
  },
8293
- ...refTable.filterCond !== void 0 ? { filterCond: refTable.filterCond } : {},
8328
+ ...refTable.filterCond !== void 0 ? { filterCond: String(refTable.filterCond) } : {},
8294
8329
  displayFields,
8295
- ...refTable.sort !== void 0 ? { sort: refTable.sort } : {},
8330
+ ...refTable.sort !== void 0 ? { sort: String(refTable.sort) } : {},
8296
8331
  ...refTable.size !== void 0 ? { size: String(refTable.size) } : {}
8297
8332
  } }
8298
8333
  };
@@ -8344,7 +8379,7 @@ function parseLayoutRow(raw) {
8344
8379
  if (raw.type !== "ROW") throw new BusinessRuleError(FormSchemaErrorCode.InvalidLayoutStructure, `Expected layout row type "ROW", got "${String(raw.type)}"`);
8345
8380
  return {
8346
8381
  type: "ROW",
8347
- fields: (raw.fields ?? []).map(parseLayoutElement)
8382
+ fields: (Array.isArray(raw.fields) ? raw.fields : []).map(parseLayoutElement)
8348
8383
  };
8349
8384
  }
8350
8385
  function collectFieldsFromElements(elements) {
@@ -8379,9 +8414,9 @@ function parseLayoutItem(raw) {
8379
8414
  case "GROUP": {
8380
8415
  const code = FieldCode.create(String(raw.code));
8381
8416
  const label = String(raw.label ?? "");
8382
- const noLabel = raw.noLabel !== void 0 ? raw.noLabel : void 0;
8383
- const openGroup = raw.openGroup !== void 0 ? raw.openGroup : void 0;
8384
- const rawLayout = raw.layout ?? [];
8417
+ const noLabel = typeof raw.noLabel === "boolean" ? raw.noLabel : void 0;
8418
+ const openGroup = typeof raw.openGroup === "boolean" ? raw.openGroup : void 0;
8419
+ const rawLayout = Array.isArray(raw.layout) ? raw.layout.filter(isRecord$1) : [];
8385
8420
  let groupFields = /* @__PURE__ */ new Map();
8386
8421
  const layout = [];
8387
8422
  for (const r of rawLayout) {
@@ -8414,8 +8449,8 @@ function parseLayoutItem(raw) {
8414
8449
  case "SUBTABLE": {
8415
8450
  const code = FieldCode.create(String(raw.code));
8416
8451
  const label = String(raw.label ?? "");
8417
- const noLabel = raw.noLabel !== void 0 ? raw.noLabel : void 0;
8418
- const elements = (raw.fields ?? []).map(parseLayoutElement);
8452
+ const noLabel = typeof raw.noLabel === "boolean" ? raw.noLabel : void 0;
8453
+ const elements = (Array.isArray(raw.fields) ? raw.fields : []).map(parseLayoutElement);
8419
8454
  const subFields = collectFieldsFromElements(elements);
8420
8455
  const subtableDef = {
8421
8456
  code,
@@ -8449,11 +8484,11 @@ const SchemaParser = { parse: (rawText) => {
8449
8484
  } catch {
8450
8485
  throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaFormat, "Schema text is not valid YAML/JSON");
8451
8486
  }
8452
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, "Schema must be an object");
8487
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, "Schema must be an object");
8453
8488
  const obj = parsed;
8454
8489
  if ("fields" in obj && !("layout" in obj)) throw new BusinessRuleError(FormSchemaErrorCode.InvalidSchemaStructure, "\"fields\" key detected. Schema format has changed. Please use \"capture\" to generate a new format schema.");
8455
8490
  if (!("layout" in obj) || !Array.isArray(obj.layout)) throw new BusinessRuleError(FormSchemaErrorCode.InvalidLayoutStructure, "Schema must have a \"layout\" array");
8456
- const rawLayout = obj.layout;
8491
+ const rawLayout = obj.layout.filter(isRecord$1);
8457
8492
  let fieldMap = /* @__PURE__ */ new Map();
8458
8493
  const layout = [];
8459
8494
  for (const rawItem of rawLayout) {
@@ -9317,7 +9352,7 @@ function normalizeValue(value) {
9317
9352
  if (typeof first === "string") return value;
9318
9353
  if (typeof first === "number") return value.map(String);
9319
9354
  if (typeof first === "object" && first !== null && "code" in first && Object.keys(first).length === 1) return value;
9320
- return value.map((row) => {
9355
+ return value.filter(isRecord$1).map((row) => {
9321
9356
  const normalized = {};
9322
9357
  for (const [k, v] of Object.entries(row)) normalized[k] = v === null || v === void 0 ? "" : String(v);
9323
9358
  return normalized;
@@ -9326,7 +9361,7 @@ function normalizeValue(value) {
9326
9361
  return String(value);
9327
9362
  }
9328
9363
  function parseRecord(raw, index) {
9329
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new BusinessRuleError(SeedDataErrorCode.InvalidSeedStructure, `Record at index ${index} must be an object`);
9364
+ if (!isRecord$1(raw)) throw new BusinessRuleError(SeedDataErrorCode.InvalidSeedStructure, `Record at index ${index} must be an object`);
9330
9365
  const record = {};
9331
9366
  for (const [key, value] of Object.entries(raw)) record[key] = normalizeValue(value);
9332
9367
  return record;
@@ -9339,7 +9374,7 @@ const SeedParser = { parse: (rawText) => {
9339
9374
  } catch {
9340
9375
  throw new BusinessRuleError(SeedDataErrorCode.InvalidSeedYaml, "Seed text is not valid YAML");
9341
9376
  }
9342
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(SeedDataErrorCode.InvalidSeedStructure, "Seed data must be an object");
9377
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(SeedDataErrorCode.InvalidSeedStructure, "Seed data must be an object");
9343
9378
  const obj = parsed;
9344
9379
  const key = "key" in obj && typeof obj.key === "string" ? UpsertKey.create(obj.key) : null;
9345
9380
  if (!("records" in obj) || !Array.isArray(obj.records)) throw new BusinessRuleError(SeedDataErrorCode.InvalidSeedStructure, "Seed data must have a \"records\" array");
@@ -9375,13 +9410,11 @@ function deepEqual(a, b) {
9375
9410
  if (itemA !== itemB) return false;
9376
9411
  continue;
9377
9412
  }
9378
- if (typeof itemA === "object" && typeof itemB === "object") {
9379
- const objA = itemA;
9380
- const objB = itemB;
9381
- const keysA = Object.keys(objA);
9382
- const keysB = Object.keys(objB);
9413
+ if (isRecord$1(itemA) && isRecord$1(itemB)) {
9414
+ const keysA = Object.keys(itemA);
9415
+ const keysB = Object.keys(itemB);
9383
9416
  if (keysA.length !== keysB.length) return false;
9384
- for (const key of keysA) if (String(objA[key] ?? "") !== String(objB[key] ?? "")) return false;
9417
+ for (const key of keysA) if (String(itemA[key] ?? "") !== String(itemB[key] ?? "")) return false;
9385
9418
  continue;
9386
9419
  }
9387
9420
  if (String(itemA) !== String(itemB)) return false;
@@ -9697,7 +9730,7 @@ const VALID_ROUNDING_MODES = new Set([
9697
9730
  "DOWN"
9698
9731
  ]);
9699
9732
  function parseIcon(raw) {
9700
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "icon must be an object with \"type\" and \"key\" properties");
9733
+ if (!isRecord$1(raw)) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "icon must be an object with \"type\" and \"key\" properties");
9701
9734
  const obj = raw;
9702
9735
  if (typeof obj.type !== "string" || !VALID_ICON_TYPES.has(obj.type)) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidIconType, `icon.type must be PRESET or FILE, got: ${String(obj.type)}`);
9703
9736
  if (typeof obj.key !== "string" || obj.key.length === 0) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "icon must have a non-empty \"key\" property");
@@ -9707,7 +9740,7 @@ function parseIcon(raw) {
9707
9740
  };
9708
9741
  }
9709
9742
  function parseTitleField(raw) {
9710
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "titleField must be an object with \"selectionMode\" property");
9743
+ if (!isRecord$1(raw)) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "titleField must be an object with \"selectionMode\" property");
9711
9744
  const obj = raw;
9712
9745
  if (typeof obj.selectionMode !== "string" || !VALID_SELECTION_MODES.has(obj.selectionMode)) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, `titleField.selectionMode must be AUTO or MANUAL, got: ${String(obj.selectionMode)}`);
9713
9746
  const result = { selectionMode: obj.selectionMode };
@@ -9721,7 +9754,7 @@ function parseTitleField(raw) {
9721
9754
  return result;
9722
9755
  }
9723
9756
  function parseNumberPrecision(raw) {
9724
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "numberPrecision must be an object");
9757
+ if (!isRecord$1(raw)) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "numberPrecision must be an object");
9725
9758
  const obj = raw;
9726
9759
  if (typeof obj.digits !== "number") throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "numberPrecision.digits must be a number");
9727
9760
  if (typeof obj.decimalPlaces !== "number") throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "numberPrecision.decimalPlaces must be a number");
@@ -9740,7 +9773,7 @@ const GeneralSettingsConfigParser = { parse: (rawText) => {
9740
9773
  } catch (error) {
9741
9774
  throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
9742
9775
  }
9743
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "Config must be a YAML object");
9776
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(GeneralSettingsErrorCode.GsInvalidConfigStructure, "Config must be a YAML object");
9744
9777
  const obj = parsed;
9745
9778
  let name;
9746
9779
  if (obj.name !== void 0 && obj.name !== null) {
@@ -9959,7 +9992,7 @@ var settings_default = define({
9959
9992
  //#endregion
9960
9993
  //#region src/core/domain/view/services/configParser.ts
9961
9994
  function parseViewConfig(name, raw) {
9962
- if (typeof raw !== "object" || raw === null) throw new BusinessRuleError(ViewErrorCode.VwInvalidConfigStructure, `View "${name}" must be an object`);
9995
+ if (!isRecord$1(raw)) throw new BusinessRuleError(ViewErrorCode.VwInvalidConfigStructure, `View "${name}" must be an object`);
9963
9996
  const obj = raw;
9964
9997
  if (typeof obj.type !== "string" || !VALID_VIEW_TYPES.has(obj.type)) throw new BusinessRuleError(ViewErrorCode.VwInvalidViewType, `View "${name}" has invalid type: ${String(obj.type)}. Must be LIST, CALENDAR, or CUSTOM`);
9965
9998
  return {
@@ -9989,9 +10022,9 @@ const ViewConfigParser = { parse: (rawText) => {
9989
10022
  } catch (error) {
9990
10023
  throw new BusinessRuleError(ViewErrorCode.VwInvalidConfigYaml, `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
9991
10024
  }
9992
- if (typeof parsed !== "object" || parsed === null) throw new BusinessRuleError(ViewErrorCode.VwInvalidConfigStructure, "Config must be a YAML object");
10025
+ if (!isRecord$1(parsed)) throw new BusinessRuleError(ViewErrorCode.VwInvalidConfigStructure, "Config must be a YAML object");
9993
10026
  const obj = parsed;
9994
- if (typeof obj.views !== "object" || obj.views === null || Array.isArray(obj.views)) throw new BusinessRuleError(ViewErrorCode.VwInvalidConfigStructure, "Config must have a \"views\" object");
10027
+ if (!isRecord$1(obj.views)) throw new BusinessRuleError(ViewErrorCode.VwInvalidConfigStructure, "Config must have a \"views\" object");
9995
10028
  const viewsObj = obj.views;
9996
10029
  const views = {};
9997
10030
  for (const [name, value] of Object.entries(viewsObj)) {