@fragment-dev/cli 2025.11.20 → 2025.11.21

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.
@@ -18,7 +18,7 @@ import {
18
18
  } from "./chunk-HDSQSGJZ.js";
19
19
  import {
20
20
  VerifySchema
21
- } from "./chunk-FWCKEJTD.js";
21
+ } from "./chunk-WWLJSN25.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-3A46G5DN.js";
69
+ } from "./chunk-U5H3AES6.js";
70
70
  import {
71
71
  init_cjs_shims
72
72
  } from "./chunk-7GH3YGSC.js";
@@ -5775,123 +5775,201 @@ var validateUniqueByKey = ({
5775
5775
  }))
5776
5776
  );
5777
5777
  };
5778
- var validateLine = (entry, line, accountPathToAccount) => {
5779
- const validationResult = [
5780
- ...validateNonEmptySafeString({
5781
- value: line.key,
5782
- path: ["key"],
5783
- name: "key",
5784
- entityName: "Ledger Line"
5778
+ var validateLineKey = (key) => {
5779
+ return validateNonEmptySafeString({
5780
+ value: key,
5781
+ path: ["key"],
5782
+ name: "key",
5783
+ entityName: "Ledger Line"
5784
+ });
5785
+ };
5786
+ var validateLineAmount = (amount, entryType, accountPath, lineKey, entryHasTwoLines, entryHasAnyLineWithTx) => {
5787
+ const validationResults = safeGetZodErrors(
5788
+ ParameterizedAmount(),
5789
+ amount,
5790
+ ["amount"]
5791
+ );
5792
+ if (!amount && (!entryHasTwoLines || !entryHasAnyLineWithTx)) {
5793
+ validationResults.push({
5794
+ message: `Must specify amount for line. Amount may only be left blank for 2-line entries reconciling to a linked account, since Fragment can infer it from the tx amount. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
5795
+ path: ["amount"]
5796
+ });
5797
+ }
5798
+ return validationResults;
5799
+ };
5800
+ var getFullyParameterizedAccount = (accountPath, accountPathToAccount, entryParameters) => {
5801
+ const structuralPath = getStructuralPath(accountPath);
5802
+ const fullParameterizedAccount = accountPathToAccount.get(structuralPath);
5803
+ const account = fullParameterizedAccount && reparameterizeSchemaLedgerAccountInput({
5804
+ account: { ...fullParameterizedAccount, path: structuralPath },
5805
+ entryParameters,
5806
+ fillParamOptions: {
5807
+ allowMissing: true,
5808
+ allowMissingInChildren: true
5809
+ }
5810
+ });
5811
+ return account;
5812
+ };
5813
+ var validateLineAccount = (entryType, lineKey, accountPath, accountPathToAccount, entryParameters) => {
5814
+ const validationResults = safeGetZodErrors(
5815
+ ParameterizedString.refine((s) => s.length > 0, {
5816
+ message: `Ledger Line (${lineKey}) in Ledger Entry (${entryType}) must specify a Ledger Account path`
5817
+ }).refine((s) => !s.includes("#"), {
5818
+ message: `Ledger Line account path '${accountPath}' cannot contain '#'`
5785
5819
  }),
5786
- ...safeGetZodErrors(
5787
- ParameterizedString.refine((s) => s.length > 0, {
5788
- message: `Ledger Line (${line.key}) in Ledger Entry (${entry.type}) must specify a Ledger Account path`
5789
- }).refine((s) => !s.includes("#"), {
5790
- message: `Ledger Line account path '${line.account.path}' cannot contain '#'`
5791
- }),
5792
- line.account.path,
5793
- ["account", "path"]
5794
- ),
5795
- ...safeGetZodErrors(ParameterizedAmount(), line.amount, ["amount"])
5796
- ];
5797
- const accountPath = line.account.path;
5820
+ accountPath,
5821
+ ["account", "path"]
5822
+ );
5798
5823
  const structuralPath = getStructuralPath(accountPath);
5799
5824
  const instanceValueMap = getInstanceValueByAccountPath(accountPath);
5800
5825
  Array.from(instanceValueMap.keys()).forEach((ancestorPath) => {
5801
5826
  const structuralAncestorPath = getStructuralPath(ancestorPath);
5802
5827
  const ancestor = accountPathToAccount.get(structuralAncestorPath);
5803
5828
  if (!ancestor) {
5804
- validationResult.push({
5829
+ validationResults.push({
5805
5830
  path: ["account"],
5806
- message: `Entry (${entry.type}) has a line that refers to a non-existent account path (path: ${line.account.path} | line key: ${line.key})`
5831
+ message: `Entry (${entryType}) has a line that refers to a non-existent account path (path: ${accountPath} | line key: ${lineKey})`
5807
5832
  });
5808
5833
  return;
5809
5834
  }
5810
5835
  if (ancestor.template && !ancestor.linkedAccount && instanceValueMap.get(ancestorPath) === void 0) {
5811
- validationResult.push({
5836
+ validationResults.push({
5812
5837
  path: ["account"],
5813
- message: `Invalid account path for line. This line refers to a Template Account, but is missing a variable that identifies the instance of the Template Account. For example: ${ancestorPath}:{{var}}. At: (entry: ${entry.type} | line key: ${line.key} | account path: ${line.account.path}).`
5838
+ message: `Invalid account path for line. This line refers to a Template Account, but is missing a variable that identifies the instance of the Template Account. For example: ${ancestorPath}:{{var}}. At: (entry: ${entryType} | line key: ${lineKey} | account path: ${accountPath}).`
5814
5839
  });
5815
5840
  }
5816
5841
  });
5817
- const fullParameterizedAccount = accountPathToAccount.get(structuralPath);
5818
- const account = fullParameterizedAccount && reparameterizeSchemaLedgerAccountInput({
5819
- account: { ...fullParameterizedAccount, path: structuralPath },
5820
- entryParameters: entry.parameters,
5821
- fillParamOptions: {
5822
- allowMissing: true,
5823
- allowMissingInChildren: true
5824
- }
5825
- });
5842
+ const account = getFullyParameterizedAccount(
5843
+ accountPath,
5844
+ accountPathToAccount,
5845
+ entryParameters
5846
+ );
5826
5847
  if (instanceValueMap.get(structuralPath) !== void 0 && account && !account.template) {
5827
- validationResult.push({
5828
- message: `Account path may only contain variables for template accounts. (Entry: ${entry.type}'s | Line account path: ${accountPath} | Line key: ${line.key})`,
5848
+ validationResults.push({
5849
+ message: `Account path may only contain variables for template accounts. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
5829
5850
  path: ["account", "path"]
5830
5851
  });
5831
5852
  }
5832
5853
  if (instanceValueMap.get(structuralPath) === "" && account && account.template) {
5833
- validationResult.push({
5834
- message: `Instance value for template account cannot be empty. (Entry: ${entry.type}'s | Line account path: ${accountPath} | Line key: ${line.key})`,
5854
+ validationResults.push({
5855
+ message: `Instance value for template account cannot be empty. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
5835
5856
  path: ["account", "path"]
5836
5857
  });
5837
5858
  }
5838
- if (!line.amount && (entry.lines.length !== 2 || !entry.lines.some((l) => l.tx))) {
5839
- validationResult.push({
5840
- message: `Must specify amount for line. Amount may only be left blank for 2-line entries reconciling to a linked account, since Fragment can infer it from the tx amount. (Entry: ${entry.type}'s | Line account path: ${accountPath} | Line key: ${line.key})`,
5841
- path: ["amount"]
5842
- });
5843
- }
5844
- if (line.currency && account && account.currencyMode === "single" && account.currency && account.currency.code !== line.currency.code) {
5845
- if (!getSchemaObjectParameters(line.currency.code).length && getSchemaObjectParameters(account.currency.code).length) {
5846
- } else if (getSchemaObjectParameters(line.currency.code).length && !getSchemaObjectParameters(account.currency.code).length) {
5847
- validationResult.push({
5859
+ return validationResults;
5860
+ };
5861
+ var validateLineCurrency = (currency, accountPath, accountPathToAccount, entryParameters, lineKey, entryType) => {
5862
+ const validationResults = [];
5863
+ const account = getFullyParameterizedAccount(
5864
+ accountPath,
5865
+ accountPathToAccount,
5866
+ entryParameters
5867
+ );
5868
+ if (currency && account && account.currencyMode === "single" && account.currency && account.currency.code !== currency.code) {
5869
+ if (!getSchemaObjectParameters(currency.code).length && getSchemaObjectParameters(account.currency.code).length) {
5870
+ } else if (getSchemaObjectParameters(currency.code).length && !getSchemaObjectParameters(account.currency.code).length) {
5871
+ validationResults.push({
5848
5872
  path: ["currency", "code"],
5849
- message: `Currency cannot be parameterized on a line posting to a single-currency account, as '${line.currency.code}' is not always guaranteed to be '${account.currency.code}' (Entry: ${entry.type} | line key: ${line.key} | account path: ${line.account.path})`
5873
+ message: `Currency cannot be parameterized on a line posting to a single-currency account, as '${currency.code}' is not always guaranteed to be '${account.currency.code}' (Entry: ${entryType} | line key: ${lineKey} | account path: ${accountPath})`
5850
5874
  });
5851
5875
  } else {
5852
- validationResult.push({
5876
+ validationResults.push({
5853
5877
  path: ["currency", "code"],
5854
- message: `Entry ${entry.type}'s line ${accountPath} has currency ${line.currency.code}, which differs from its account's currency ${account.currency?.code}`
5878
+ message: `Entry ${entryType}'s line ${accountPath} has currency ${currency.code}, which differs from its account's currency ${account.currency?.code}`
5855
5879
  });
5856
5880
  }
5857
5881
  }
5858
- if (!line.currency && account && account.currencyMode === "multi") {
5859
- validationResult.push({
5860
- message: `Entry ${entry.type}'s line ${accountPath} must have a currency set for multi-currency account (Line key: ${line.key}, account key: ${account.key})`,
5882
+ if (!currency && account && account.currencyMode === "multi") {
5883
+ validationResults.push({
5884
+ message: `Entry ${entryType}'s line ${accountPath} must have a currency set for multi-currency account (Line key: ${lineKey}, account key: ${account.key})`,
5861
5885
  path: ["currency"]
5862
5886
  });
5863
5887
  }
5864
- if (line.currency && !SchemaCurrencyMatchInput2.safeParse(line.currency).success) {
5865
- if (line.currency.code === "CUSTOM" && !line.currency.customCurrencyId) {
5866
- validationResult.push({
5867
- message: `Line must provide custom currency ID for custom currency (Line key: ${line.key}, entry: ${entry.type})`,
5888
+ if (currency && !SchemaCurrencyMatchInput2.safeParse(currency).success) {
5889
+ if (currency.code === "CUSTOM" && !currency.customCurrencyId) {
5890
+ validationResults.push({
5891
+ message: `Line must provide custom currency ID for custom currency (Line key: ${lineKey}, entry: ${entryType})`,
5868
5892
  path: ["currency", "customCurrencyId"]
5869
5893
  });
5870
- } else if (line.currency.code !== "CUSTOM") {
5871
- validationResult.push({
5872
- message: `Currency code '${line.currency.code}' is invalid (Line key: ${line.key}, entry: ${entry.type})`,
5894
+ } else if (currency.code !== "CUSTOM") {
5895
+ validationResults.push({
5896
+ message: `Currency code '${currency.code}' is invalid (Line key: ${lineKey}, entry: ${entryType})`,
5873
5897
  path: ["currency", "code"]
5874
5898
  });
5875
5899
  }
5876
5900
  }
5877
- if (line.tx && account && !account.linkedAccount) {
5878
- validationResult.push({
5879
- message: `Cannot specify tx for an unlinked account. (Entry: ${entry.type}'s | Line account path: ${accountPath} | Line key: ${line.key})`,
5901
+ return validationResults;
5902
+ };
5903
+ var validateLineTx = (tx, accountPath, accountPathToAccount, entryParameters, lineKey, entryType) => {
5904
+ const validationResults = [];
5905
+ const account = getFullyParameterizedAccount(
5906
+ accountPath,
5907
+ accountPathToAccount,
5908
+ entryParameters
5909
+ );
5910
+ if (tx && account && !account.linkedAccount) {
5911
+ validationResults.push({
5912
+ message: `Cannot specify tx for an unlinked account. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
5880
5913
  path: ["tx"]
5881
5914
  });
5882
5915
  }
5883
- if (!line.tx && account && account.linkedAccount) {
5884
- validationResult.push({
5885
- message: `Must specify tx for a linked account. (Entry: ${entry.type}'s | Line account path: ${accountPath} | Line key: ${line.key})`,
5916
+ if (!tx && account && account.linkedAccount) {
5917
+ validationResults.push({
5918
+ message: `Must specify tx for a linked account. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
5886
5919
  path: ["tx"]
5887
5920
  });
5888
5921
  }
5889
- if (account && account.linkedAccount && line.tx && !(line.tx.externalId || line.tx.id)) {
5890
- validationResult.push({
5891
- message: `Must specify one of external ID or ID for the tx. (Entry: ${entry.type}'s | Line account path: ${accountPath} | Line key: ${line.key})`,
5922
+ if (account && account.linkedAccount && tx && !(tx.externalId || tx.id)) {
5923
+ validationResults.push({
5924
+ message: `Must specify one of external ID or ID for the tx. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
5892
5925
  path: ["tx"]
5893
5926
  });
5894
5927
  }
5928
+ return validationResults;
5929
+ };
5930
+ var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLineWithTx, line, accountPathToAccount) => {
5931
+ const validationResult = validateLineKey(line.key);
5932
+ const accountPath = line.account.path;
5933
+ const parameters = entryParameters ?? {};
5934
+ validationResult.push(
5935
+ ...validateLineAmount(
5936
+ line.amount,
5937
+ entryType,
5938
+ line.account.path,
5939
+ line.key,
5940
+ entryHasTwoLines,
5941
+ entryHasAnyLineWithTx
5942
+ )
5943
+ );
5944
+ validationResult.push(
5945
+ ...validateLineAccount(
5946
+ entryType,
5947
+ line.key,
5948
+ accountPath,
5949
+ accountPathToAccount,
5950
+ parameters
5951
+ )
5952
+ );
5953
+ validationResult.push(
5954
+ ...validateLineCurrency(
5955
+ line.currency ?? void 0,
5956
+ accountPath,
5957
+ accountPathToAccount,
5958
+ parameters,
5959
+ line.key,
5960
+ entryType
5961
+ )
5962
+ );
5963
+ validationResult.push(
5964
+ ...validateLineTx(
5965
+ line.tx ?? void 0,
5966
+ accountPath,
5967
+ accountPathToAccount,
5968
+ parameters,
5969
+ line.key,
5970
+ entryType
5971
+ )
5972
+ );
5895
5973
  return validationResult;
5896
5974
  };
5897
5975
  var isKDefined = (k, line) => {
@@ -5914,7 +5992,14 @@ var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
5914
5992
  ...line,
5915
5993
  currency: line.currency ?? line.account?.currency
5916
5994
  })).filter((line) => isKDefined("currency", line)).filter(
5917
- (line) => isKDefined("account", line) && validateLine(ledgerEntry, line, accountPathToAccount).length === 0
5995
+ (line) => isKDefined("account", line) && validateLine(
5996
+ ledgerEntry.type,
5997
+ ledgerEntry.parameters,
5998
+ ledgerEntry.lines.length === 2,
5999
+ ledgerEntry.lines.some((l) => l.tx),
6000
+ line,
6001
+ accountPathToAccount
6002
+ ).length === 0
5918
6003
  );
5919
6004
  if (lines.length < ledgerEntry.lines.length) {
5920
6005
  return [];
@@ -6304,7 +6389,10 @@ var validateEntry = (ledgerEntry, accountPathToAccount) => {
6304
6389
  errors.push(
6305
6390
  ...ledgerEntry.lines.flatMap(
6306
6391
  (line, idx) => validateLine(
6307
- ledgerEntry,
6392
+ ledgerEntry.type,
6393
+ ledgerEntry.parameters,
6394
+ ledgerEntry.lines.length === 2,
6395
+ ledgerEntry.lines.some((l) => l.tx),
6308
6396
  parameterizeSchemaLedgerLineInput({
6309
6397
  line,
6310
6398
  entryParameters: ledgerEntry.parameters
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  Schema,
9
9
  parseWithError
10
- } from "./chunk-A3GIEDNM.js";
10
+ } from "./chunk-NTPTG2JX.js";
11
11
  import {
12
12
  formatValidationErrors,
13
13
  logValidationErrors
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Schema,
3
3
  parseWithError
4
- } from "./chunk-A3GIEDNM.js";
4
+ } from "./chunk-NTPTG2JX.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-SV4X5V53.js";
5
+ } from "./chunk-UWS3TQHL.js";
6
6
  import {
7
7
  DEFAULT_SCHEMA_PATH
8
8
  } from "./chunk-A4BSWX5D.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  GenGraphQL
3
- } from "../chunk-3A46G5DN.js";
3
+ } from "../chunk-U5H3AES6.js";
4
4
  import "../chunk-IID3EAD2.js";
5
5
  import "../chunk-ODU6I44Y.js";
6
6
  import "../chunk-73ZTML2E.js";
7
- import "../chunk-A3GIEDNM.js";
7
+ import "../chunk-NTPTG2JX.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-FWCKEJTD.js";
4
- import "../chunk-SV4X5V53.js";
3
+ } from "../chunk-WWLJSN25.js";
4
+ import "../chunk-UWS3TQHL.js";
5
5
  import "../chunk-A4BSWX5D.js";
6
- import "../chunk-A3GIEDNM.js";
6
+ import "../chunk-NTPTG2JX.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-KZO23KZ2.js";
3
+ } from "./chunk-2VHWON64.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-FWCKEJTD.js";
11
- import "./chunk-SV4X5V53.js";
10
+ import "./chunk-WWLJSN25.js";
11
+ import "./chunk-UWS3TQHL.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-3A46G5DN.js";
31
+ import "./chunk-U5H3AES6.js";
32
32
  import "./chunk-IID3EAD2.js";
33
33
  import "./chunk-ODU6I44Y.js";
34
34
  import "./chunk-73ZTML2E.js";
35
- import "./chunk-A3GIEDNM.js";
35
+ import "./chunk-NTPTG2JX.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-KZO23KZ2.js";
3
+ } from "./chunk-2VHWON64.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-FWCKEJTD.js";
11
- import "./chunk-SV4X5V53.js";
10
+ import "./chunk-WWLJSN25.js";
11
+ import "./chunk-UWS3TQHL.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-3A46G5DN.js";
31
+ import "./chunk-U5H3AES6.js";
32
32
  import "./chunk-IID3EAD2.js";
33
33
  import "./chunk-ODU6I44Y.js";
34
34
  import "./chunk-73ZTML2E.js";
35
- import "./chunk-A3GIEDNM.js";
35
+ import "./chunk-NTPTG2JX.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-SV4X5V53.js";
7
- import "../chunk-A3GIEDNM.js";
6
+ } from "../chunk-UWS3TQHL.js";
7
+ import "../chunk-NTPTG2JX.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.11.20"
976
+ "version": "2025.11.21"
977
977
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fragment-dev/cli",
3
- "version": "2025.11.20",
3
+ "version": "2025.11.21",
4
4
  "description": "FRAGMENT CLI",
5
5
  "author": "hello@fragment.dev",
6
6
  "bin": {