@fragment-dev/cli 2025.12.8 → 2025.12.10

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Schema,
3
3
  parseWithError
4
- } from "./chunk-DVQTOSJ7.js";
4
+ } from "./chunk-NU3YK2Y7.js";
5
5
  import {
6
6
  formatValidationErrors
7
7
  } from "./chunk-SZXF2QTY.js";
@@ -2,7 +2,7 @@ import {
2
2
  extractSchemaMetadata,
3
3
  isJsonParseError,
4
4
  validateSchemaStructure
5
- } from "./chunk-FRC5ARKM.js";
5
+ } from "./chunk-3Y3YHT3P.js";
6
6
  import {
7
7
  DEFAULT_SCHEMA_PATH
8
8
  } from "./chunk-A4BSWX5D.js";
@@ -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-5UCVIAYX.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-G5J4QE4W.js";
70
70
  import {
71
71
  init_cjs_shims
72
72
  } from "./chunk-7GH3YGSC.js";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  Schema,
9
9
  parseWithError
10
- } from "./chunk-DVQTOSJ7.js";
10
+ } from "./chunk-NU3YK2Y7.js";
11
11
  import {
12
12
  formatValidationErrors,
13
13
  logValidationErrors
@@ -5998,11 +5998,11 @@ var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLin
5998
5998
  var isKDefined = (k, line) => {
5999
5999
  return line[k] !== void 0;
6000
6000
  };
6001
- var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
6002
- const lines = ledgerEntry.lines.map(
6001
+ var validateBalancedLines = (entryType, entryParameters, lines, accountPathToAccount) => {
6002
+ const parameterizedLines = lines.map(
6003
6003
  (line) => parameterizeSchemaLedgerLineInput({
6004
6004
  line,
6005
- entryParameters: ledgerEntry.parameters
6005
+ entryParameters
6006
6006
  })
6007
6007
  ).map((line) => ({
6008
6008
  ...line,
@@ -6016,21 +6016,21 @@ var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
6016
6016
  currency: line.currency ?? line.account?.currency
6017
6017
  })).filter((line) => isKDefined("currency", line)).filter(
6018
6018
  (line) => isKDefined("account", line) && validateLine(
6019
- ledgerEntry.type,
6020
- ledgerEntry.parameters,
6021
- ledgerEntry.lines.length === 2,
6022
- ledgerEntry.lines.some((l) => l.tx),
6019
+ entryType,
6020
+ entryParameters,
6021
+ lines.length === 2,
6022
+ lines.some((l) => l.tx),
6023
6023
  line,
6024
6024
  accountPathToAccount
6025
6025
  ).length === 0
6026
6026
  );
6027
- if (lines.length < ledgerEntry.lines.length) {
6027
+ if (parameterizedLines.length < lines.length) {
6028
6028
  return [];
6029
6029
  }
6030
6030
  try {
6031
6031
  assertBalancedLinesSchemas({
6032
- lines,
6033
- entryType: ledgerEntry.type
6032
+ lines: parameterizedLines,
6033
+ entryType
6034
6034
  });
6035
6035
  } catch (e) {
6036
6036
  if (e instanceof Error) {
@@ -6045,12 +6045,12 @@ var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
6045
6045
  }
6046
6046
  return [];
6047
6047
  };
6048
- var validateEntryConditions = (entry, accountPathToAccount) => {
6048
+ var validateEntryConditions = (entryConditions, staticParameters, entryType, accountPathToAccount) => {
6049
6049
  const errors = [];
6050
- const conditions = entry.conditions.map(
6050
+ const conditions = entryConditions.map(
6051
6051
  (condition) => parameterizeSchemaLedgerEntryConditionInput({
6052
6052
  condition,
6053
- entryParameters: entry.parameters,
6053
+ entryParameters: staticParameters,
6054
6054
  fillParamOptions: {
6055
6055
  allowMissing: true,
6056
6056
  allowMissingInChildren: true
@@ -6065,7 +6065,7 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6065
6065
  ...fullyParameterizedMatchedAccount,
6066
6066
  path: condition.account.path
6067
6067
  },
6068
- entryParameters: entry.parameters,
6068
+ entryParameters: staticParameters,
6069
6069
  fillParamOptions: {
6070
6070
  allowMissing: true,
6071
6071
  allowMissingInChildren: true
@@ -6074,7 +6074,7 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6074
6074
  if (matchedAccount?.linkedAccount) {
6075
6075
  errors.push({
6076
6076
  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})`
6077
+ message: `You may not specify a condition on a Linked Ledger Account. Error occurred at (path: ${condition.account.path} | entry: ${entryType})`
6078
6078
  });
6079
6079
  }
6080
6080
  const instanceValueMap = getInstanceValueByAccountPath(
@@ -6086,27 +6086,27 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6086
6086
  if (!ancestor) {
6087
6087
  errors.push({
6088
6088
  path: ["conditions", idx, "account"],
6089
- message: `Condition refers to a non-existent account path. Error occurred at (path: ${condition.account.path} | entry: ${entry.type})`
6089
+ message: `Condition refers to a non-existent account path. Error occurred at (path: ${condition.account.path} | entry: ${entryType})`
6090
6090
  });
6091
6091
  return;
6092
6092
  }
6093
6093
  if (ancestor.template && !instanceValueMap.get(ancestorPath)) {
6094
6094
  errors.push({
6095
6095
  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})`
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: ${entryType})`
6097
6097
  });
6098
6098
  }
6099
6099
  });
6100
6100
  if (matchedAccount?.currencyMode === "multi" && condition.currency === void 0) {
6101
6101
  errors.push({
6102
6102
  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})`
6103
+ message: `You must specify a currency for a condition on a multi-currency Ledger Account. Error occurred at (${condition.account.path} | entry: ${entryType})`
6104
6104
  });
6105
6105
  }
6106
6106
  if (matchedAccount?.currencyMode === "single" && condition.currency !== void 0 && condition.currency?.code !== matchedAccount.currency?.code) {
6107
6107
  errors.push({
6108
6108
  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})`
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: ${entryType})`
6110
6110
  });
6111
6111
  }
6112
6112
  ["precondition", "postcondition"].forEach((condType) => {
@@ -6115,11 +6115,11 @@ var validateEntryConditions = (entry, accountPathToAccount) => {
6115
6115
  ...safeGetZodErrors(
6116
6116
  ParameterizedAmount({
6117
6117
  optional: true,
6118
- errorMessage: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entry.type})`
6118
+ errorMessage: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entryType})`
6119
6119
  }).refine(
6120
6120
  (str) => typeof str === "string" ? str.length > 0 : true,
6121
6121
  {
6122
- message: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entry.type}).`
6122
+ message: `Invalid expression '${condition?.[condType]?.ownBalance?.[prop]}' provided to condition ${condType}.ownBalance.${prop} (entry: ${entryType}).`
6123
6123
  }
6124
6124
  ),
6125
6125
  condition?.[condType]?.ownBalance?.[prop],
@@ -6224,6 +6224,15 @@ var validateTags = (tags) => {
6224
6224
  var validateGroups = (groups) => {
6225
6225
  const errors = [];
6226
6226
  const keyValues = /* @__PURE__ */ new Map();
6227
+ groups.forEach(({ key }, i) => {
6228
+ const keyResult = SafeStringSchema.safeParse(key);
6229
+ if (!keyResult.success) {
6230
+ errors.push({
6231
+ path: ["groups", i, "key"],
6232
+ message: `Group key '${key}' cannot contain '#', '/', ':', or parameters in {{handlebar}} syntax`
6233
+ });
6234
+ }
6235
+ });
6227
6236
  groups.forEach(({ key, value }, i) => {
6228
6237
  if (!value || !key) {
6229
6238
  errors.push({
@@ -6294,11 +6303,11 @@ var validateGroups = (groups) => {
6294
6303
  }
6295
6304
  return errors;
6296
6305
  };
6297
- var validateConsistentBalanceUpdates = (ledgerEntry, accountPathToAccount) => {
6298
- const groupsInEntry = new Set(ledgerEntry.groups.map(({ key }) => key));
6306
+ var validateConsistentBalanceUpdates = (lines, groups, accountPathToAccount) => {
6307
+ const groupsInEntry = new Set(groups.map(({ key }) => key));
6299
6308
  const lineMessages = [];
6300
6309
  const uniqueBalancesUpdated = /* @__PURE__ */ new Set();
6301
- ledgerEntry.lines.forEach((line, idx) => {
6310
+ lines.forEach((line, idx) => {
6302
6311
  const templatePath = line.account.path;
6303
6312
  const structuralPath = getStructuralPath(templatePath);
6304
6313
  const account = accountPathToAccount.get(structuralPath);
@@ -6310,10 +6319,9 @@ var validateConsistentBalanceUpdates = (ledgerEntry, accountPathToAccount) => {
6310
6319
  uniqueBalancesUpdated.add(`ownBalance:${balanceKey}`);
6311
6320
  }
6312
6321
  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}`);
6322
+ if (groupsInEntry.has(key) && ownBalanceUpdates === "strong") {
6323
+ balanceUpdates.push(`group key "${key}" ownBalance`);
6324
+ uniqueBalancesUpdated.add(`group:${key}:${balanceKey}`);
6317
6325
  }
6318
6326
  });
6319
6327
  if (balanceUpdates.length > 0) {
@@ -6356,38 +6364,38 @@ var validateParameters = (parameters) => {
6356
6364
  };
6357
6365
  var normalizeRegex = /{{\s*([^{}\s]*)\s*}}/g;
6358
6366
  var normalizeParameterizedString = (value) => value.replace(normalizeRegex, "{{$1}}");
6359
- var validateEntryAndAccountStatus = (ledgerEntry, accountPathToAccount) => {
6367
+ var validateEntryAndAccountStatus = ({
6368
+ lines,
6369
+ lineAccountStatuses,
6370
+ conditions,
6371
+ conditionAccountStatuses,
6372
+ entryStatus,
6373
+ entryType,
6374
+ entryVersion
6375
+ }) => {
6360
6376
  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);
6377
+ const isEntryActive = entryStatus === "active";
6378
+ lines.forEach((line) => {
6379
+ const accountStatus = getAccountStatus({
6380
+ status: lineAccountStatuses.get(line.account.path)
6381
+ });
6368
6382
  if (accountStatus !== "active" && isEntryActive) {
6369
6383
  errors.push({
6370
6384
  code: "invalid_account_status",
6371
6385
  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.`
6386
+ 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
6387
  });
6376
6388
  }
6377
6389
  });
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);
6390
+ conditions.forEach((condition) => {
6391
+ const accountStatus = getAccountStatus({
6392
+ status: conditionAccountStatuses.get(condition.account.path)
6393
+ });
6384
6394
  if (accountStatus !== "active" && isEntryActive) {
6385
6395
  errors.push({
6386
6396
  code: "invalid_account_status",
6387
6397
  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.`
6398
+ 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
6399
  });
6392
6400
  }
6393
6401
  });
@@ -6407,7 +6415,25 @@ var validateEntry = (ledgerEntry, accountPathToAccount) => {
6407
6415
  });
6408
6416
  }
6409
6417
  errors.push(
6410
- ...validateEntryAndAccountStatus(ledgerEntry, accountPathToAccount)
6418
+ ...validateEntryAndAccountStatus({
6419
+ lines: ledgerEntry.lines,
6420
+ lineAccountStatuses: new Map(
6421
+ ledgerEntry.lines.map((line) => [
6422
+ line.account.path,
6423
+ accountPathToAccount.get(getStructuralPath(line.account.path))?.status
6424
+ ])
6425
+ ),
6426
+ conditions: ledgerEntry.conditions,
6427
+ conditionAccountStatuses: new Map(
6428
+ ledgerEntry.conditions.map((condition) => [
6429
+ condition.account.path,
6430
+ accountPathToAccount.get(getStructuralPath(condition.account.path))?.status
6431
+ ])
6432
+ ),
6433
+ entryStatus: getEntryStatus(ledgerEntry),
6434
+ entryType: ledgerEntry.type,
6435
+ entryVersion: getEntryTypeVersion(ledgerEntry)
6436
+ })
6411
6437
  );
6412
6438
  errors.push(
6413
6439
  ...ledgerEntry.lines.flatMap(
@@ -6438,10 +6464,28 @@ var validateEntry = (ledgerEntry, accountPathToAccount) => {
6438
6464
  getErrorMessage: (line) => `Entry (${ledgerEntry.type}) already has a line with key '${line.key}'`
6439
6465
  })
6440
6466
  );
6441
- errors.push(...validateBalancedLines(ledgerEntry, accountPathToAccount));
6442
- errors.push(...validateEntryConditions(ledgerEntry, accountPathToAccount));
6443
6467
  errors.push(
6444
- ...validateConsistentBalanceUpdates(ledgerEntry, accountPathToAccount)
6468
+ ...validateBalancedLines(
6469
+ ledgerEntry.type,
6470
+ ledgerEntry.parameters,
6471
+ ledgerEntry.lines,
6472
+ accountPathToAccount
6473
+ )
6474
+ );
6475
+ errors.push(
6476
+ ...validateEntryConditions(
6477
+ ledgerEntry.conditions,
6478
+ ledgerEntry.parameters,
6479
+ ledgerEntry.type,
6480
+ accountPathToAccount
6481
+ )
6482
+ );
6483
+ errors.push(
6484
+ ...validateConsistentBalanceUpdates(
6485
+ ledgerEntry.lines,
6486
+ ledgerEntry.groups,
6487
+ accountPathToAccount
6488
+ )
6445
6489
  );
6446
6490
  errors.push(...validateParameters(ledgerEntry.parameters));
6447
6491
  const lineTxs = ledgerEntry.lines.flatMap(
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  GenGraphQL
3
- } from "../chunk-TJKXJDVH.js";
3
+ } from "../chunk-G5J4QE4W.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-NU3YK2Y7.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-5UCVIAYX.js";
4
+ import "../chunk-3Y3YHT3P.js";
5
5
  import "../chunk-A4BSWX5D.js";
6
- import "../chunk-DVQTOSJ7.js";
6
+ import "../chunk-NU3YK2Y7.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-FZZ7OBKS.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-5UCVIAYX.js";
11
+ import "./chunk-3Y3YHT3P.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-G5J4QE4W.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-NU3YK2Y7.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-FZZ7OBKS.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-5UCVIAYX.js";
11
+ import "./chunk-3Y3YHT3P.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-G5J4QE4W.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-NU3YK2Y7.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-3Y3YHT3P.js";
7
+ import "../chunk-NU3YK2Y7.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.10"
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.10",
4
4
  "description": "FRAGMENT CLI",
5
5
  "author": "hello@fragment.dev",
6
6
  "bin": {