@fragment-dev/cli 2025.12.8 → 2025.12.12

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.
@@ -4415,6 +4415,334 @@ var require_cjs = __commonJS({
4415
4415
  }
4416
4416
  });
4417
4417
 
4418
+ // ../../node_modules/@amccarthy1/typed-env/dist/cjs/boolean.js
4419
+ var require_boolean = __commonJS({
4420
+ "../../node_modules/@amccarthy1/typed-env/dist/cjs/boolean.js"(exports) {
4421
+ "use strict";
4422
+ init_cjs_shims();
4423
+ var __assign = exports && exports.__assign || function() {
4424
+ __assign = Object.assign || function(t) {
4425
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4426
+ s = arguments[i];
4427
+ for (var p in s)
4428
+ if (Object.prototype.hasOwnProperty.call(s, p))
4429
+ t[p] = s[p];
4430
+ }
4431
+ return t;
4432
+ };
4433
+ return __assign.apply(this, arguments);
4434
+ };
4435
+ Object.defineProperty(exports, "__esModule", { value: true });
4436
+ exports.BoolVar = void 0;
4437
+ var invalidValueMessage = "Value did not match a valid boolean format!";
4438
+ var trueValues = /* @__PURE__ */ new Set(["true", "t", "1", "yes", "y", "on"]);
4439
+ var falseValues = /* @__PURE__ */ new Set(["false", "f", "0", "no", "n", "off"]);
4440
+ var parser = function(value) {
4441
+ var norm = value.toLowerCase();
4442
+ if (trueValues.has(norm))
4443
+ return true;
4444
+ if (falseValues.has(norm))
4445
+ return false;
4446
+ throw new Error(invalidValueMessage);
4447
+ };
4448
+ function BoolVar2(props) {
4449
+ if (props === void 0) {
4450
+ props = {};
4451
+ }
4452
+ return __assign({ parser }, props);
4453
+ }
4454
+ exports.BoolVar = BoolVar2;
4455
+ }
4456
+ });
4457
+
4458
+ // ../../node_modules/@amccarthy1/typed-env/dist/cjs/date.js
4459
+ var require_date = __commonJS({
4460
+ "../../node_modules/@amccarthy1/typed-env/dist/cjs/date.js"(exports) {
4461
+ "use strict";
4462
+ init_cjs_shims();
4463
+ var __assign = exports && exports.__assign || function() {
4464
+ __assign = Object.assign || function(t) {
4465
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4466
+ s = arguments[i];
4467
+ for (var p in s)
4468
+ if (Object.prototype.hasOwnProperty.call(s, p))
4469
+ t[p] = s[p];
4470
+ }
4471
+ return t;
4472
+ };
4473
+ return __assign.apply(this, arguments);
4474
+ };
4475
+ Object.defineProperty(exports, "__esModule", { value: true });
4476
+ exports.DateVar = void 0;
4477
+ function DateVar(props) {
4478
+ if (props === void 0) {
4479
+ props = {};
4480
+ }
4481
+ var parser = function(value) {
4482
+ var dateValue = new Date(value);
4483
+ if (dateValue.toString() === "Invalid Date") {
4484
+ throw new Error("Value did not match a valid date format!");
4485
+ }
4486
+ return dateValue;
4487
+ };
4488
+ return __assign({ parser }, props);
4489
+ }
4490
+ exports.DateVar = DateVar;
4491
+ }
4492
+ });
4493
+
4494
+ // ../../node_modules/@amccarthy1/typed-env/dist/cjs/enum.js
4495
+ var require_enum = __commonJS({
4496
+ "../../node_modules/@amccarthy1/typed-env/dist/cjs/enum.js"(exports) {
4497
+ "use strict";
4498
+ init_cjs_shims();
4499
+ var __assign = exports && exports.__assign || function() {
4500
+ __assign = Object.assign || function(t) {
4501
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4502
+ s = arguments[i];
4503
+ for (var p in s)
4504
+ if (Object.prototype.hasOwnProperty.call(s, p))
4505
+ t[p] = s[p];
4506
+ }
4507
+ return t;
4508
+ };
4509
+ return __assign.apply(this, arguments);
4510
+ };
4511
+ var __rest = exports && exports.__rest || function(s, e) {
4512
+ var t = {};
4513
+ for (var p in s)
4514
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4515
+ t[p] = s[p];
4516
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
4517
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
4518
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
4519
+ t[p[i]] = s[p[i]];
4520
+ }
4521
+ return t;
4522
+ };
4523
+ Object.defineProperty(exports, "__esModule", { value: true });
4524
+ exports.EnumVar = void 0;
4525
+ function EnumVar(_a) {
4526
+ var options = _a.options, props = __rest(_a, ["options"]);
4527
+ var parser = function(value) {
4528
+ if (!options.includes(value))
4529
+ throw new Error("Value did not match one of ".concat(options));
4530
+ return value;
4531
+ };
4532
+ return __assign({ parser }, props);
4533
+ }
4534
+ exports.EnumVar = EnumVar;
4535
+ }
4536
+ });
4537
+
4538
+ // ../../node_modules/@amccarthy1/typed-env/dist/cjs/integer.js
4539
+ var require_integer = __commonJS({
4540
+ "../../node_modules/@amccarthy1/typed-env/dist/cjs/integer.js"(exports) {
4541
+ "use strict";
4542
+ init_cjs_shims();
4543
+ var __assign = exports && exports.__assign || function() {
4544
+ __assign = Object.assign || function(t) {
4545
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4546
+ s = arguments[i];
4547
+ for (var p in s)
4548
+ if (Object.prototype.hasOwnProperty.call(s, p))
4549
+ t[p] = s[p];
4550
+ }
4551
+ return t;
4552
+ };
4553
+ return __assign.apply(this, arguments);
4554
+ };
4555
+ Object.defineProperty(exports, "__esModule", { value: true });
4556
+ exports.IntVar = void 0;
4557
+ var invalidIntMessage = "Value is not an integer!";
4558
+ function IntVar(props) {
4559
+ if (props === void 0) {
4560
+ props = {};
4561
+ }
4562
+ var parser = function(value) {
4563
+ if (value.trim() === "") {
4564
+ throw new Error(invalidIntMessage);
4565
+ }
4566
+ var numberValue = Number(value);
4567
+ if (!Number.isInteger(numberValue))
4568
+ throw new Error(invalidIntMessage);
4569
+ return numberValue;
4570
+ };
4571
+ return __assign({ parser }, props);
4572
+ }
4573
+ exports.IntVar = IntVar;
4574
+ }
4575
+ });
4576
+
4577
+ // ../../node_modules/@amccarthy1/typed-env/dist/cjs/string.js
4578
+ var require_string = __commonJS({
4579
+ "../../node_modules/@amccarthy1/typed-env/dist/cjs/string.js"(exports) {
4580
+ "use strict";
4581
+ init_cjs_shims();
4582
+ var __assign = exports && exports.__assign || function() {
4583
+ __assign = Object.assign || function(t) {
4584
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4585
+ s = arguments[i];
4586
+ for (var p in s)
4587
+ if (Object.prototype.hasOwnProperty.call(s, p))
4588
+ t[p] = s[p];
4589
+ }
4590
+ return t;
4591
+ };
4592
+ return __assign.apply(this, arguments);
4593
+ };
4594
+ var __rest = exports && exports.__rest || function(s, e) {
4595
+ var t = {};
4596
+ for (var p in s)
4597
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4598
+ t[p] = s[p];
4599
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
4600
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
4601
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
4602
+ t[p[i]] = s[p[i]];
4603
+ }
4604
+ return t;
4605
+ };
4606
+ Object.defineProperty(exports, "__esModule", { value: true });
4607
+ exports.StringVar = void 0;
4608
+ function StringVar(_a) {
4609
+ if (_a === void 0) {
4610
+ _a = {};
4611
+ }
4612
+ var pattern = _a.pattern, props = __rest(_a, ["pattern"]);
4613
+ var parser = function(value) {
4614
+ if (pattern) {
4615
+ if (!pattern.exec(value))
4616
+ throw new Error("Did not match pattern ".concat(pattern));
4617
+ }
4618
+ return value;
4619
+ };
4620
+ return __assign({ parser }, props);
4621
+ }
4622
+ exports.StringVar = StringVar;
4623
+ }
4624
+ });
4625
+
4626
+ // ../../node_modules/@amccarthy1/typed-env/dist/cjs/env.js
4627
+ var require_env = __commonJS({
4628
+ "../../node_modules/@amccarthy1/typed-env/dist/cjs/env.js"(exports) {
4629
+ "use strict";
4630
+ init_cjs_shims();
4631
+ var __assign = exports && exports.__assign || function() {
4632
+ __assign = Object.assign || function(t) {
4633
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4634
+ s = arguments[i];
4635
+ for (var p in s)
4636
+ if (Object.prototype.hasOwnProperty.call(s, p))
4637
+ t[p] = s[p];
4638
+ }
4639
+ return t;
4640
+ };
4641
+ return __assign.apply(this, arguments);
4642
+ };
4643
+ var __rest = exports && exports.__rest || function(s, e) {
4644
+ var t = {};
4645
+ for (var p in s)
4646
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4647
+ t[p] = s[p];
4648
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
4649
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
4650
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
4651
+ t[p[i]] = s[p[i]];
4652
+ }
4653
+ return t;
4654
+ };
4655
+ Object.defineProperty(exports, "__esModule", { value: true });
4656
+ exports.TypedEnv = exports.nullable = exports.optional = void 0;
4657
+ var parseValue = function(_a, env) {
4658
+ var _b;
4659
+ var key = _a[0], declaration = _a[1];
4660
+ var envVarName = (_b = declaration.variable) !== null && _b !== void 0 ? _b : key;
4661
+ var envValue = env[envVarName];
4662
+ if (typeof envValue === "undefined") {
4663
+ if (!Object.prototype.hasOwnProperty.apply(declaration, ["defaultValue"])) {
4664
+ throw new Error("No value specified for ".concat(envVarName));
4665
+ }
4666
+ if (declaration.validator)
4667
+ declaration.validator(declaration.defaultValue);
4668
+ return [key, declaration.defaultValue];
4669
+ }
4670
+ try {
4671
+ var value = declaration.parser(envValue);
4672
+ if (declaration.validator)
4673
+ declaration.validator(value);
4674
+ return [key, value];
4675
+ } catch (error) {
4676
+ throw new Error("Error while parsing env var ".concat(envVarName, ": ").concat(error));
4677
+ }
4678
+ };
4679
+ function optional(_a) {
4680
+ var parser = _a.parser, defaultValue = _a.defaultValue, validator = _a.validator, others = __rest(_a, ["parser", "defaultValue", "validator"]);
4681
+ return __assign({ parser, defaultValue: defaultValue || void 0, validator: validator && function(value) {
4682
+ if (typeof value !== "undefined") {
4683
+ validator(value);
4684
+ }
4685
+ } }, others);
4686
+ }
4687
+ exports.optional = optional;
4688
+ function nullable(_a) {
4689
+ var parser = _a.parser, defaultValue = _a.defaultValue, validator = _a.validator, others = __rest(_a, ["parser", "defaultValue", "validator"]);
4690
+ return __assign({ parser, defaultValue: defaultValue || null, validator: validator && function(value) {
4691
+ if (value !== null) {
4692
+ validator(value);
4693
+ }
4694
+ } }, others);
4695
+ }
4696
+ exports.nullable = nullable;
4697
+ function TypedEnv2(schema, values) {
4698
+ var env = values !== null && values !== void 0 ? values : process.env;
4699
+ var result = Object.fromEntries(Object.entries(schema).map(function(_a) {
4700
+ var key = _a[0], declaration = _a[1];
4701
+ return parseValue([key, declaration], env);
4702
+ }));
4703
+ return result;
4704
+ }
4705
+ exports.TypedEnv = TypedEnv2;
4706
+ }
4707
+ });
4708
+
4709
+ // ../../node_modules/@amccarthy1/typed-env/dist/cjs/index.js
4710
+ var require_cjs2 = __commonJS({
4711
+ "../../node_modules/@amccarthy1/typed-env/dist/cjs/index.js"(exports) {
4712
+ "use strict";
4713
+ init_cjs_shims();
4714
+ Object.defineProperty(exports, "__esModule", { value: true });
4715
+ exports.TypedEnv = exports.optional = exports.StringVar = exports.IntVar = exports.EnumVar = exports.DateVar = exports.BoolVar = void 0;
4716
+ var boolean_1 = require_boolean();
4717
+ Object.defineProperty(exports, "BoolVar", { enumerable: true, get: function() {
4718
+ return boolean_1.BoolVar;
4719
+ } });
4720
+ var date_1 = require_date();
4721
+ Object.defineProperty(exports, "DateVar", { enumerable: true, get: function() {
4722
+ return date_1.DateVar;
4723
+ } });
4724
+ var enum_1 = require_enum();
4725
+ Object.defineProperty(exports, "EnumVar", { enumerable: true, get: function() {
4726
+ return enum_1.EnumVar;
4727
+ } });
4728
+ var integer_1 = require_integer();
4729
+ Object.defineProperty(exports, "IntVar", { enumerable: true, get: function() {
4730
+ return integer_1.IntVar;
4731
+ } });
4732
+ var string_1 = require_string();
4733
+ Object.defineProperty(exports, "StringVar", { enumerable: true, get: function() {
4734
+ return string_1.StringVar;
4735
+ } });
4736
+ var env_1 = require_env();
4737
+ Object.defineProperty(exports, "optional", { enumerable: true, get: function() {
4738
+ return env_1.optional;
4739
+ } });
4740
+ Object.defineProperty(exports, "TypedEnv", { enumerable: true, get: function() {
4741
+ return env_1.TypedEnv;
4742
+ } });
4743
+ }
4744
+ });
4745
+
4418
4746
  // ../../libs/zod-utils/src/index.ts
4419
4747
  init_cjs_shims();
4420
4748
  var import_zod_validation_error = __toESM(require_cjs(), 1);
@@ -4506,6 +4834,7 @@ var GroupConsistencyConfig = z.object({
4506
4834
  var AccountConsistencyConfigSchema = z.object({
4507
4835
  lines: z.optional(ConsistencyModeSchema),
4508
4836
  ownBalanceUpdates: z.optional(ConsistencyModeSchema),
4837
+ totalBalanceUpdates: z.optional(ConsistencyModeSchema),
4509
4838
  groups: z.optional(z.array(GroupConsistencyConfig))
4510
4839
  });
4511
4840
  var SchemaCurrencyMatchInput = z.object({
@@ -4556,6 +4885,11 @@ var SchemaCondition = z.object({
4556
4885
  eq: z.string().optional(),
4557
4886
  lte: z.string().optional(),
4558
4887
  gte: z.string().optional()
4888
+ }).optional(),
4889
+ totalBalance: z.object({
4890
+ eq: z.string().optional(),
4891
+ lte: z.string().optional(),
4892
+ gte: z.string().optional()
4559
4893
  }).optional()
4560
4894
  });
4561
4895
  var BaseSchemaLedgerEntryConditionInput = z.object({
@@ -4645,17 +4979,29 @@ init_cjs_shims();
4645
4979
 
4646
4980
  // ../../libs/schema-validation/utils/consistencyValidation.ts
4647
4981
  init_cjs_shims();
4982
+ var import_typed_env = __toESM(require_cjs2(), 1);
4983
+ var canSetTotalBalanceConsistency = () => (0, import_typed_env.TypedEnv)({
4984
+ ENABLE_TOTAL_BALANCE_CONSISTENCY: (0, import_typed_env.BoolVar)({ defaultValue: false })
4985
+ }).ENABLE_TOTAL_BALANCE_CONSISTENCY;
4648
4986
  var validateAccountConsistencySettings = ({
4649
4987
  lines,
4650
4988
  ownBalanceUpdates,
4989
+ totalBalanceUpdates,
4651
4990
  groups
4652
4991
  }) => {
4653
4992
  const errors = [];
4654
4993
  const validationResult = AccountConsistencyConfigSchema.safeParse({
4655
4994
  lines,
4656
4995
  ownBalanceUpdates,
4996
+ totalBalanceUpdates,
4657
4997
  groups
4658
4998
  });
4999
+ if (!canSetTotalBalanceConsistency() && totalBalanceUpdates) {
5000
+ errors.push({
5001
+ message: `Setting 'totalBalanceUpdates' is disallowed.`,
5002
+ path: ["totalBalanceUpdates"]
5003
+ });
5004
+ }
4659
5005
  if (!validationResult.success) {
4660
5006
  validationResult.error.errors.forEach((error) => {
4661
5007
  errors.push({
@@ -4984,7 +5330,10 @@ var fillInDefaultsAndInferMetadata = ({
4984
5330
  const defaultCurrencyMode = defaultCurrencyModeInput ?? "single";
4985
5331
  const defaultConsistencyConfig = {
4986
5332
  lines: defaultConsistencyConfigInput?.lines ?? "eventual",
4987
- ownBalanceUpdates: defaultConsistencyConfigInput?.ownBalanceUpdates ?? "eventual"
5333
+ ownBalanceUpdates: defaultConsistencyConfigInput?.ownBalanceUpdates ?? "eventual",
5334
+ // TODO(FRA-6306): Make totalBalanceUpdates required and set a default
5335
+ // totalBalanceUpdates: defaultConsistencyConfigInput?.totalBalanceUpdates ?? 'eventual',
5336
+ totalBalanceUpdates: defaultConsistencyConfigInput?.totalBalanceUpdates
4988
5337
  };
4989
5338
  const inferAccountMetadata = ({
4990
5339
  account,
@@ -5008,6 +5357,7 @@ var fillInDefaultsAndInferMetadata = ({
5008
5357
  const partialConsistencyConfig = account.consistencyConfig ?? {};
5009
5358
  const newConsistencyConfig = {
5010
5359
  ownBalanceUpdates: partialConsistencyConfig.ownBalanceUpdates ?? fallbackDefaultConsistencyMode.ownBalanceUpdates,
5360
+ totalBalanceUpdates: partialConsistencyConfig.totalBalanceUpdates ?? fallbackDefaultConsistencyMode.totalBalanceUpdates,
5011
5361
  lines: partialConsistencyConfig.lines ?? fallbackDefaultConsistencyMode.lines,
5012
5362
  groups: partialConsistencyConfig.groups ?? fallbackDefaultConsistencyMode.groups
5013
5363
  };
@@ -5145,7 +5495,10 @@ var transformAndValidateCoA = ({
5145
5495
  const coaConsistencyConfig = coa.defaultConsistencyConfig ?? {};
5146
5496
  const defaultConsistencyConfig = {
5147
5497
  ownBalanceUpdates: coaConsistencyConfig.ownBalanceUpdates ?? "eventual",
5148
- lines: coaConsistencyConfig.lines ?? "eventual"
5498
+ lines: coaConsistencyConfig.lines ?? "eventual",
5499
+ // TODO(FRA-6306): Make totalBalanceUpdates required and set a default
5500
+ // totalBalanceUpdates: coaConsistencyConfig.totalBalanceUpdates ?? 'eventual',
5501
+ totalBalanceUpdates: coaConsistencyConfig.totalBalanceUpdates
5149
5502
  };
5150
5503
  const { errors: accountErrors, filledIn } = transformAndValidateAccounts({
5151
5504
  defaultConsistencyConfig,
@@ -5998,11 +6351,11 @@ var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLin
5998
6351
  var isKDefined = (k, line) => {
5999
6352
  return line[k] !== void 0;
6000
6353
  };
6001
- var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
6002
- const lines = ledgerEntry.lines.map(
6354
+ var validateBalancedLines = (entryType, entryParameters, lines, accountPathToAccount) => {
6355
+ const parameterizedLines = lines.map(
6003
6356
  (line) => parameterizeSchemaLedgerLineInput({
6004
6357
  line,
6005
- entryParameters: ledgerEntry.parameters
6358
+ entryParameters
6006
6359
  })
6007
6360
  ).map((line) => ({
6008
6361
  ...line,
@@ -6016,21 +6369,21 @@ var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
6016
6369
  currency: line.currency ?? line.account?.currency
6017
6370
  })).filter((line) => isKDefined("currency", line)).filter(
6018
6371
  (line) => isKDefined("account", line) && validateLine(
6019
- ledgerEntry.type,
6020
- ledgerEntry.parameters,
6021
- ledgerEntry.lines.length === 2,
6022
- ledgerEntry.lines.some((l) => l.tx),
6372
+ entryType,
6373
+ entryParameters,
6374
+ lines.length === 2,
6375
+ lines.some((l) => l.tx),
6023
6376
  line,
6024
6377
  accountPathToAccount
6025
6378
  ).length === 0
6026
6379
  );
6027
- if (lines.length < ledgerEntry.lines.length) {
6380
+ if (parameterizedLines.length < lines.length) {
6028
6381
  return [];
6029
6382
  }
6030
6383
  try {
6031
6384
  assertBalancedLinesSchemas({
6032
- lines,
6033
- entryType: ledgerEntry.type
6385
+ lines: parameterizedLines,
6386
+ entryType
6034
6387
  });
6035
6388
  } catch (e) {
6036
6389
  if (e instanceof Error) {
@@ -6045,12 +6398,12 @@ var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
6045
6398
  }
6046
6399
  return [];
6047
6400
  };
6048
- var validateEntryConditions = (entry, accountPathToAccount) => {
6401
+ var validateEntryConditions = (entryConditions, staticParameters, entryType, accountPathToAccount) => {
6049
6402
  const errors = [];
6050
- const conditions = entry.conditions.map(
6403
+ const conditions = entryConditions.map(
6051
6404
  (condition) => parameterizeSchemaLedgerEntryConditionInput({
6052
6405
  condition,
6053
- entryParameters: entry.parameters,
6406
+ entryParameters: staticParameters,
6054
6407
  fillParamOptions: {
6055
6408
  allowMissing: true,
6056
6409
  allowMissingInChildren: true
@@ -6065,7 +6418,7 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6065
6418
  ...fullyParameterizedMatchedAccount,
6066
6419
  path: condition.account.path
6067
6420
  },
6068
- entryParameters: entry.parameters,
6421
+ entryParameters: staticParameters,
6069
6422
  fillParamOptions: {
6070
6423
  allowMissing: true,
6071
6424
  allowMissingInChildren: true
@@ -6074,7 +6427,7 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6074
6427
  if (matchedAccount?.linkedAccount) {
6075
6428
  errors.push({
6076
6429
  path: ["conditions", idx, "account", "path"],
6077
- message: `You may not specify a condition on a Linked Ledger Account. Error occurred at (path: ${condition.account.path} | entry: ${entry.type})`
6430
+ message: `You may not specify a condition on a Linked Ledger Account. Error occurred at (path: ${condition.account.path} | entry: ${entryType})`
6078
6431
  });
6079
6432
  }
6080
6433
  const instanceValueMap = getInstanceValueByAccountPath(
@@ -6086,27 +6439,27 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6086
6439
  if (!ancestor) {
6087
6440
  errors.push({
6088
6441
  path: ["conditions", idx, "account"],
6089
- message: `Condition refers to a non-existent account path. Error occurred at (path: ${condition.account.path} | entry: ${entry.type})`
6442
+ message: `Condition refers to a non-existent account path. Error occurred at (path: ${condition.account.path} | entry: ${entryType})`
6090
6443
  });
6091
6444
  return;
6092
6445
  }
6093
6446
  if (ancestor.template && !instanceValueMap.get(ancestorPath)) {
6094
6447
  errors.push({
6095
6448
  path: ["coniditions", idx, "account"],
6096
- message: `Invalid account path for condition. This condition refers to a Template Account, but is missing a variable that identifies the instance of the Template Account. For example: ${ancestorPath}:{{var}}. Error occurred at (path: ${condition.account.path} | entry: ${entry.type})`
6449
+ message: `Invalid account path for condition. This condition refers to a Template Account, but is missing a variable that identifies the instance of the Template Account. For example: ${ancestorPath}:{{var}}. Error occurred at (path: ${condition.account.path} | entry: ${entryType})`
6097
6450
  });
6098
6451
  }
6099
6452
  });
6100
6453
  if (matchedAccount?.currencyMode === "multi" && condition.currency === void 0) {
6101
6454
  errors.push({
6102
6455
  path: ["conditions", idx, "currency"],
6103
- message: `You must specify a currency for a condition on a multi-currency Ledger Account. Error occurred at (${condition.account.path} | entry: ${entry.type})`
6456
+ message: `You must specify a currency for a condition on a multi-currency Ledger Account. Error occurred at (${condition.account.path} | entry: ${entryType})`
6104
6457
  });
6105
6458
  }
6106
6459
  if (matchedAccount?.currencyMode === "single" && condition.currency !== void 0 && condition.currency?.code !== matchedAccount.currency?.code) {
6107
6460
  errors.push({
6108
6461
  path: ["conditions", idx, "currency", "code"],
6109
- message: `The currency you specified on a condition (${condition.currency?.code === "CUSTOM" ? condition.currency.customCurrencyId : condition.currency.code}) differs from the currency of the Ledger Account it applies to. Error occurred at (${matchedAccount.currency?.code} | entry: ${entry.type})`
6462
+ message: `The currency you specified on a condition (${condition.currency?.code === "CUSTOM" ? condition.currency.customCurrencyId : condition.currency.code}) differs from the currency of the Ledger Account it applies to. Error occurred at (${matchedAccount.currency?.code} | entry: ${entryType})`
6110
6463
  });
6111
6464
  }
6112
6465
  ["precondition", "postcondition"].forEach((condType) => {
@@ -6115,11 +6468,11 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6115
6468
  ...safeGetZodErrors(
6116
6469
  ParameterizedAmount({
6117
6470
  optional: true,
6118
- errorMessage: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entry.type})`
6471
+ errorMessage: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entryType})`
6119
6472
  }).refine(
6120
6473
  (str) => typeof str === "string" ? str.length > 0 : true,
6121
6474
  {
6122
- message: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entry.type}).`
6475
+ message: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entryType}).`
6123
6476
  }
6124
6477
  ),
6125
6478
  condition?.[condType]?.ownBalance?.[prop],
@@ -6127,6 +6480,32 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6127
6480
  )
6128
6481
  );
6129
6482
  });
6483
+ if (condition?.[condType]?.totalBalance) {
6484
+ if (!canSetTotalBalanceConsistency()) {
6485
+ errors.push({
6486
+ path: ["conditions", idx, condType, "totalBalance"],
6487
+ message: `Setting 'totalBalance' conditions is disallowed. Error occurred at (entry: ${entryType})`
6488
+ });
6489
+ } else {
6490
+ ["gte", "lte", "eq"].forEach((prop) => {
6491
+ errors.push(
6492
+ ...safeGetZodErrors(
6493
+ ParameterizedAmount({
6494
+ optional: true,
6495
+ errorMessage: `Invalid expression '${condition?.[condType]?.totalBalance?.[prop]}' provided to condition ${condType}.totalBalance.${prop} (entry: ${entryType})`
6496
+ }).refine(
6497
+ (str) => typeof str === "string" ? str.length > 0 : true,
6498
+ {
6499
+ message: `Invalid expression '${condition?.[condType]?.totalBalance?.[prop]}' provided to condition ${condType}.totalBalance.${prop} (entry: ${entryType}).`
6500
+ }
6501
+ ),
6502
+ condition?.[condType]?.totalBalance?.[prop],
6503
+ ["conditions", idx, condType, "totalBalance", prop]
6504
+ )
6505
+ );
6506
+ });
6507
+ }
6508
+ }
6130
6509
  });
6131
6510
  });
6132
6511
  return errors;
@@ -6224,6 +6603,15 @@ var validateTags = (tags) => {
6224
6603
  var validateGroups = (groups) => {
6225
6604
  const errors = [];
6226
6605
  const keyValues = /* @__PURE__ */ new Map();
6606
+ groups.forEach(({ key }, i) => {
6607
+ const keyResult = SafeStringSchema.safeParse(key);
6608
+ if (!keyResult.success) {
6609
+ errors.push({
6610
+ path: ["groups", i, "key"],
6611
+ message: `Group key '${key}' cannot contain '#', '/', ':', or parameters in {{handlebar}} syntax`
6612
+ });
6613
+ }
6614
+ });
6227
6615
  groups.forEach(({ key, value }, i) => {
6228
6616
  if (!value || !key) {
6229
6617
  errors.push({
@@ -6294,11 +6682,11 @@ var validateGroups = (groups) => {
6294
6682
  }
6295
6683
  return errors;
6296
6684
  };
6297
- var validateConsistentBalanceUpdates = (ledgerEntry, accountPathToAccount) => {
6298
- const groupsInEntry = new Set(ledgerEntry.groups.map(({ key }) => key));
6685
+ var validateConsistentBalanceUpdates = (lines, groups, accountPathToAccount) => {
6686
+ const groupsInEntry = new Set(groups.map(({ key }) => key));
6299
6687
  const lineMessages = [];
6300
6688
  const uniqueBalancesUpdated = /* @__PURE__ */ new Set();
6301
- ledgerEntry.lines.forEach((line, idx) => {
6689
+ lines.forEach((line, idx) => {
6302
6690
  const templatePath = line.account.path;
6303
6691
  const structuralPath = getStructuralPath(templatePath);
6304
6692
  const account = accountPathToAccount.get(structuralPath);
@@ -6310,10 +6698,9 @@ var validateConsistentBalanceUpdates = (ledgerEntry, accountPathToAccount) => {
6310
6698
  uniqueBalancesUpdated.add(`ownBalance:${balanceKey}`);
6311
6699
  }
6312
6700
  account?.consistencyConfig.groups?.forEach(({ key, ownBalanceUpdates }) => {
6313
- const safeKey = safe`${key}`;
6314
- if (groupsInEntry.has(safeKey) && ownBalanceUpdates === "strong") {
6315
- balanceUpdates.push(`group key "${safeKey}" ownBalance`);
6316
- uniqueBalancesUpdated.add(`group:${safeKey}:${balanceKey}`);
6701
+ if (groupsInEntry.has(key) && ownBalanceUpdates === "strong") {
6702
+ balanceUpdates.push(`group key "${key}" ownBalance`);
6703
+ uniqueBalancesUpdated.add(`group:${key}:${balanceKey}`);
6317
6704
  }
6318
6705
  });
6319
6706
  if (balanceUpdates.length > 0) {
@@ -6356,38 +6743,38 @@ var validateParameters = (parameters) => {
6356
6743
  };
6357
6744
  var normalizeRegex = /{{\s*([^{}\s]*)\s*}}/g;
6358
6745
  var normalizeParameterizedString = (value) => value.replace(normalizeRegex, "{{$1}}");
6359
- var validateEntryAndAccountStatus = (ledgerEntry, accountPathToAccount) => {
6746
+ var validateEntryAndAccountStatus = ({
6747
+ lines,
6748
+ lineAccountStatuses,
6749
+ conditions,
6750
+ conditionAccountStatuses,
6751
+ entryStatus,
6752
+ entryType,
6753
+ entryVersion
6754
+ }) => {
6360
6755
  const errors = [];
6361
- const isEntryActive = getEntryStatus(ledgerEntry) === "active";
6362
- ledgerEntry.lines.forEach((line) => {
6363
- const structuralPath = getStructuralPath(line.account.path);
6364
- const account = accountPathToAccount.get(structuralPath);
6365
- if (!account)
6366
- return;
6367
- const accountStatus = getAccountStatus(account);
6756
+ const isEntryActive = entryStatus === "active";
6757
+ lines.forEach((line) => {
6758
+ const accountStatus = getAccountStatus({
6759
+ status: lineAccountStatuses.get(line.account.path)
6760
+ });
6368
6761
  if (accountStatus !== "active" && isEntryActive) {
6369
6762
  errors.push({
6370
6763
  code: "invalid_account_status",
6371
6764
  path: ["status"],
6372
- message: `Entry (${ledgerEntry.type} V${getEntryTypeVersion(
6373
- ledgerEntry
6374
- )}) has a line that refers to an account with status '${account.status}'. Only active accounts can be used in entries.`
6765
+ message: `Entry (${entryType} V${entryVersion}) has a line that refers to an account with status '${accountStatus}'. Only active accounts can be used in entries.`
6375
6766
  });
6376
6767
  }
6377
6768
  });
6378
- ledgerEntry.conditions.forEach((condition) => {
6379
- const structuralPath = getStructuralPath(condition.account.path);
6380
- const account = accountPathToAccount.get(structuralPath);
6381
- if (!account)
6382
- return;
6383
- const accountStatus = getAccountStatus(account);
6769
+ conditions.forEach((condition) => {
6770
+ const accountStatus = getAccountStatus({
6771
+ status: conditionAccountStatuses.get(condition.account.path)
6772
+ });
6384
6773
  if (accountStatus !== "active" && isEntryActive) {
6385
6774
  errors.push({
6386
6775
  code: "invalid_account_status",
6387
6776
  path: ["status"],
6388
- message: `Entry (${ledgerEntry.type} V${getEntryTypeVersion(
6389
- ledgerEntry
6390
- )}) has a condition that refers to an account with status '${account.status}'. Only active accounts can be used in entries.`
6777
+ message: `Entry (${entryType} V${entryVersion}) has a condition that refers to an account with status '${accountStatus}'. Only active accounts can be used in entries.`
6391
6778
  });
6392
6779
  }
6393
6780
  });
@@ -6407,7 +6794,25 @@ var validateEntry = (ledgerEntry, accountPathToAccount) => {
6407
6794
  });
6408
6795
  }
6409
6796
  errors.push(
6410
- ...validateEntryAndAccountStatus(ledgerEntry, accountPathToAccount)
6797
+ ...validateEntryAndAccountStatus({
6798
+ lines: ledgerEntry.lines,
6799
+ lineAccountStatuses: new Map(
6800
+ ledgerEntry.lines.map((line) => [
6801
+ line.account.path,
6802
+ accountPathToAccount.get(getStructuralPath(line.account.path))?.status
6803
+ ])
6804
+ ),
6805
+ conditions: ledgerEntry.conditions,
6806
+ conditionAccountStatuses: new Map(
6807
+ ledgerEntry.conditions.map((condition) => [
6808
+ condition.account.path,
6809
+ accountPathToAccount.get(getStructuralPath(condition.account.path))?.status
6810
+ ])
6811
+ ),
6812
+ entryStatus: getEntryStatus(ledgerEntry),
6813
+ entryType: ledgerEntry.type,
6814
+ entryVersion: getEntryTypeVersion(ledgerEntry)
6815
+ })
6411
6816
  );
6412
6817
  errors.push(
6413
6818
  ...ledgerEntry.lines.flatMap(
@@ -6438,10 +6843,28 @@ var validateEntry = (ledgerEntry, accountPathToAccount) => {
6438
6843
  getErrorMessage: (line) => `Entry (${ledgerEntry.type}) already has a line with key '${line.key}'`
6439
6844
  })
6440
6845
  );
6441
- errors.push(...validateBalancedLines(ledgerEntry, accountPathToAccount));
6442
- errors.push(...validateEntryConditions(ledgerEntry, accountPathToAccount));
6443
6846
  errors.push(
6444
- ...validateConsistentBalanceUpdates(ledgerEntry, accountPathToAccount)
6847
+ ...validateBalancedLines(
6848
+ ledgerEntry.type,
6849
+ ledgerEntry.parameters,
6850
+ ledgerEntry.lines,
6851
+ accountPathToAccount
6852
+ )
6853
+ );
6854
+ errors.push(
6855
+ ...validateEntryConditions(
6856
+ ledgerEntry.conditions,
6857
+ ledgerEntry.parameters,
6858
+ ledgerEntry.type,
6859
+ accountPathToAccount
6860
+ )
6861
+ );
6862
+ errors.push(
6863
+ ...validateConsistentBalanceUpdates(
6864
+ ledgerEntry.lines,
6865
+ ledgerEntry.groups,
6866
+ accountPathToAccount
6867
+ )
6445
6868
  );
6446
6869
  errors.push(...validateParameters(ledgerEntry.parameters));
6447
6870
  const lineTxs = ledgerEntry.lines.flatMap(
@@ -6761,7 +7184,8 @@ var SchemaInt96ConditionInput = z.object({
6761
7184
  gte: ParameterizedString.optional()
6762
7185
  });
6763
7186
  var SchemaConditionInput = z.object({
6764
- ownBalance: SchemaInt96ConditionInput.optional()
7187
+ ownBalance: SchemaInt96ConditionInput.optional(),
7188
+ totalBalance: SchemaInt96ConditionInput.optional()
6765
7189
  });
6766
7190
  var SchemaLedgerEntryConditionInput = z.object({
6767
7191
  account: z.object({
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  Schema,
9
9
  parseWithError
10
- } from "./chunk-DVQTOSJ7.js";
10
+ } from "./chunk-23GA7SWI.js";
11
11
  import {
12
12
  formatValidationErrors,
13
13
  logValidationErrors
@@ -18,7 +18,7 @@ import {
18
18
  } from "./chunk-HDSQSGJZ.js";
19
19
  import {
20
20
  VerifySchema
21
- } from "./chunk-ZANZ6QKR.js";
21
+ } from "./chunk-UWZOOSXG.js";
22
22
  import {
23
23
  Workspace
24
24
  } from "./chunk-NCIRJV5V.js";
@@ -66,7 +66,7 @@ import {
66
66
  } from "./chunk-SJKYZPKQ.js";
67
67
  import {
68
68
  GenGraphQL
69
- } from "./chunk-TJKXJDVH.js";
69
+ } from "./chunk-BHKDLH3S.js";
70
70
  import {
71
71
  init_cjs_shims
72
72
  } from "./chunk-7GH3YGSC.js";
@@ -2,7 +2,7 @@ import {
2
2
  extractSchemaMetadata,
3
3
  isJsonParseError,
4
4
  validateSchemaStructure
5
- } from "./chunk-FRC5ARKM.js";
5
+ } from "./chunk-Y5NKOPGQ.js";
6
6
  import {
7
7
  DEFAULT_SCHEMA_PATH
8
8
  } from "./chunk-A4BSWX5D.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Schema,
3
3
  parseWithError
4
- } from "./chunk-DVQTOSJ7.js";
4
+ } from "./chunk-23GA7SWI.js";
5
5
  import {
6
6
  formatValidationErrors
7
7
  } from "./chunk-SZXF2QTY.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  GenGraphQL
3
- } from "../chunk-TJKXJDVH.js";
3
+ } from "../chunk-BHKDLH3S.js";
4
4
  import "../chunk-IID3EAD2.js";
5
5
  import "../chunk-ODU6I44Y.js";
6
6
  import "../chunk-73ZTML2E.js";
7
- import "../chunk-DVQTOSJ7.js";
7
+ import "../chunk-23GA7SWI.js";
8
8
  import "../chunk-SZXF2QTY.js";
9
9
  import "../chunk-5BKPV3GD.js";
10
10
  import "../chunk-KTCLACRS.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  VerifySchema
3
- } from "../chunk-ZANZ6QKR.js";
4
- import "../chunk-FRC5ARKM.js";
3
+ } from "../chunk-UWZOOSXG.js";
4
+ import "../chunk-Y5NKOPGQ.js";
5
5
  import "../chunk-A4BSWX5D.js";
6
- import "../chunk-DVQTOSJ7.js";
6
+ import "../chunk-23GA7SWI.js";
7
7
  import "../chunk-SZXF2QTY.js";
8
8
  import "../chunk-5BKPV3GD.js";
9
9
  import "../chunk-KTCLACRS.js";
package/dist/commands.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  COMMANDS
3
- } from "./chunk-YL2F6DQE.js";
3
+ } from "./chunk-MCDP3VCZ.js";
4
4
  import "./chunk-XTMYKL3N.js";
5
5
  import "./chunk-T3TNAOFS.js";
6
6
  import "./chunk-R7QCNENW.js";
7
7
  import "./chunk-G3K3FJ7S.js";
8
8
  import "./chunk-EXS5ZS4O.js";
9
9
  import "./chunk-HDSQSGJZ.js";
10
- import "./chunk-ZANZ6QKR.js";
11
- import "./chunk-FRC5ARKM.js";
10
+ import "./chunk-UWZOOSXG.js";
11
+ import "./chunk-Y5NKOPGQ.js";
12
12
  import "./chunk-A4BSWX5D.js";
13
13
  import "./chunk-NCIRJV5V.js";
14
14
  import "./chunk-ZXWT4UIL.js";
@@ -28,11 +28,11 @@ import "./chunk-GBHTHL6T.js";
28
28
  import "./chunk-SJKYZPKQ.js";
29
29
  import "./chunk-SHTFFJEV.js";
30
30
  import "./chunk-7N2Q46HP.js";
31
- import "./chunk-TJKXJDVH.js";
31
+ import "./chunk-BHKDLH3S.js";
32
32
  import "./chunk-IID3EAD2.js";
33
33
  import "./chunk-ODU6I44Y.js";
34
34
  import "./chunk-73ZTML2E.js";
35
- import "./chunk-DVQTOSJ7.js";
35
+ import "./chunk-23GA7SWI.js";
36
36
  import "./chunk-SZXF2QTY.js";
37
37
  import "./chunk-5BKPV3GD.js";
38
38
  import "./chunk-KTCLACRS.js";
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  COMMANDS
3
- } from "./chunk-YL2F6DQE.js";
3
+ } from "./chunk-MCDP3VCZ.js";
4
4
  import "./chunk-XTMYKL3N.js";
5
5
  import "./chunk-T3TNAOFS.js";
6
6
  import "./chunk-R7QCNENW.js";
7
7
  import "./chunk-G3K3FJ7S.js";
8
8
  import "./chunk-EXS5ZS4O.js";
9
9
  import "./chunk-HDSQSGJZ.js";
10
- import "./chunk-ZANZ6QKR.js";
11
- import "./chunk-FRC5ARKM.js";
10
+ import "./chunk-UWZOOSXG.js";
11
+ import "./chunk-Y5NKOPGQ.js";
12
12
  import "./chunk-A4BSWX5D.js";
13
13
  import "./chunk-NCIRJV5V.js";
14
14
  import "./chunk-ZXWT4UIL.js";
@@ -28,11 +28,11 @@ import "./chunk-GBHTHL6T.js";
28
28
  import "./chunk-SJKYZPKQ.js";
29
29
  import "./chunk-SHTFFJEV.js";
30
30
  import "./chunk-7N2Q46HP.js";
31
- import "./chunk-TJKXJDVH.js";
31
+ import "./chunk-BHKDLH3S.js";
32
32
  import "./chunk-IID3EAD2.js";
33
33
  import "./chunk-ODU6I44Y.js";
34
34
  import "./chunk-73ZTML2E.js";
35
- import "./chunk-DVQTOSJ7.js";
35
+ import "./chunk-23GA7SWI.js";
36
36
  import "./chunk-SZXF2QTY.js";
37
37
  import "./chunk-5BKPV3GD.js";
38
38
  import "./chunk-KTCLACRS.js";
@@ -3,8 +3,8 @@ import {
3
3
  extractSchemaMetadata,
4
4
  isJsonParseError,
5
5
  validateSchemaStructure
6
- } from "../chunk-FRC5ARKM.js";
7
- import "../chunk-DVQTOSJ7.js";
6
+ } from "../chunk-Y5NKOPGQ.js";
7
+ import "../chunk-23GA7SWI.js";
8
8
  import "../chunk-SZXF2QTY.js";
9
9
  import "../chunk-5BKPV3GD.js";
10
10
  import "../chunk-KTCLACRS.js";
@@ -973,5 +973,5 @@
973
973
  "help": "Generate GraphQL queries from your Schema for your SDK."
974
974
  }
975
975
  },
976
- "version": "2025.12.8"
976
+ "version": "2025.12.12"
977
977
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fragment-dev/cli",
3
- "version": "2025.12.8",
3
+ "version": "2025.12.12",
4
4
  "description": "FRAGMENT CLI",
5
5
  "author": "hello@fragment.dev",
6
6
  "bin": {