@fragment-dev/cli 2025.11.19 → 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.
Files changed (50) hide show
  1. package/dist/{chunk-LAOHNXFN.js → chunk-2VHWON64.js} +19 -19
  2. package/dist/{chunk-UXTOXY2F.js → chunk-7N2Q46HP.js} +6 -0
  3. package/dist/{chunk-65EPGXM5.js → chunk-DD3MOZDA.js} +1 -1
  4. package/dist/{chunk-IWMNMIA6.js → chunk-EJ2G2JEJ.js} +1 -1
  5. package/dist/{chunk-GRMPAF2X.js → chunk-EXS5ZS4O.js} +1 -1
  6. package/dist/{chunk-LCVLN3SZ.js → chunk-G3K3FJ7S.js} +1 -1
  7. package/dist/{chunk-YGEYBIHA.js → chunk-GBHTHL6T.js} +1 -1
  8. package/dist/{chunk-ZQHWOO25.js → chunk-M6SFKLXU.js} +1 -1
  9. package/dist/{chunk-H3DG2EYM.js → chunk-N4SWSXTR.js} +1 -1
  10. package/dist/{chunk-O5U5EZDT.js → chunk-N6JOCCTG.js} +1 -1
  11. package/dist/{chunk-3LSL4JNW.js → chunk-NCIRJV5V.js} +1 -1
  12. package/dist/{chunk-SEXV6TUY.js → chunk-NTPTG2JX.js} +305 -152
  13. package/dist/{chunk-6Z6OR4JK.js → chunk-OBJHIIXG.js} +1 -1
  14. package/dist/{chunk-3BFX3ZQM.js → chunk-R7QCNENW.js} +1 -1
  15. package/dist/{chunk-IVDQ4PQW.js → chunk-SHTFFJEV.js} +1 -1
  16. package/dist/{chunk-VRHCYGEJ.js → chunk-SJKYZPKQ.js} +1 -1
  17. package/dist/{chunk-BQJEXZ3Z.js → chunk-SQRQUPQM.js} +1 -1
  18. package/dist/{chunk-LWYIMR7B.js → chunk-SXJZMK5W.js} +1 -1
  19. package/dist/{chunk-JVO2IFFR.js → chunk-U5H3AES6.js} +1 -1
  20. package/dist/{chunk-P2FYO77R.js → chunk-UWS3TQHL.js} +1 -1
  21. package/dist/{chunk-J4ZTYY6X.js → chunk-WWLJSN25.js} +1 -1
  22. package/dist/{chunk-HLAM7IYL.js → chunk-WYGN3U5V.js} +1 -1
  23. package/dist/{chunk-ZDE3DZ3I.js → chunk-XTMYKL3N.js} +1 -1
  24. package/dist/{chunk-UOIGY3UB.js → chunk-ZXWT4UIL.js} +1 -1
  25. package/dist/commands/add-ledger-entry.js +3 -3
  26. package/dist/commands/create-custom-link.js +3 -3
  27. package/dist/commands/create-ledger.js +3 -3
  28. package/dist/commands/delete-custom-txs.js +3 -3
  29. package/dist/commands/delete-ledger.js +3 -3
  30. package/dist/commands/delete-schema.js +3 -3
  31. package/dist/commands/gen-graphql.js +2 -2
  32. package/dist/commands/get-schema.js +3 -3
  33. package/dist/commands/migrate-ledger-entry.js +3 -3
  34. package/dist/commands/query/ledgerAccounts.js +3 -3
  35. package/dist/commands/query/ledgers.js +3 -3
  36. package/dist/commands/query/schema.js +3 -3
  37. package/dist/commands/query/schemas.js +3 -3
  38. package/dist/commands/reverse-ledger-entry.js +3 -3
  39. package/dist/commands/store-schema.js +3 -3
  40. package/dist/commands/token.js +3 -3
  41. package/dist/commands/update-ledger-account.js +3 -3
  42. package/dist/commands/verify-schema.js +3 -3
  43. package/dist/commands/workspace.js +3 -3
  44. package/dist/commands.js +24 -24
  45. package/dist/index.js +24 -24
  46. package/dist/lib/authenticatedCommand.js +2 -2
  47. package/dist/lib/sdk.js +3 -1
  48. package/dist/utils/schemaValidation.js +2 -2
  49. package/oclif.manifest.json +1 -1
  50. package/package.json +1 -1
@@ -4736,6 +4736,123 @@ var getEntryTypeVersion = ({
4736
4736
 
4737
4737
  // ../../libs/schema-validation/utils/transformers/account.ts
4738
4738
  init_cjs_shims();
4739
+ var validateAccountCurrency = ({
4740
+ currency,
4741
+ currencyMode,
4742
+ key,
4743
+ name,
4744
+ path
4745
+ }) => {
4746
+ const errors = [];
4747
+ if (currency && currencyMode === "multi") {
4748
+ errors.push({
4749
+ message: `Currency cannot be set for a multi-currency Ledger Account (key: ${key}, name: ${name})`,
4750
+ path: [...path, "currency"]
4751
+ });
4752
+ }
4753
+ if (currency && !SchemaCurrencyMatchInput2.safeParse(currency).success) {
4754
+ if (currency.code === "CUSTOM" && !currency.customCurrencyId) {
4755
+ errors.push({
4756
+ message: `Must provide custom currency ID for custom currency (key: ${key}, name: ${name})`,
4757
+ path: [...path, "currency", "customCurrencyId"]
4758
+ });
4759
+ } else if (currency.code !== "CUSTOM") {
4760
+ errors.push({
4761
+ message: `Currency code '${currency.code}' is invalid (key: ${key}, name: ${name})`,
4762
+ path: [...path, "currency", "code"]
4763
+ });
4764
+ }
4765
+ }
4766
+ return errors;
4767
+ };
4768
+ var validateAccountLinkedAccount = ({
4769
+ linkedAccount,
4770
+ children,
4771
+ template,
4772
+ isTemplateChild,
4773
+ key,
4774
+ name,
4775
+ path
4776
+ }) => {
4777
+ const errors = [];
4778
+ if (!linkedAccount) {
4779
+ return errors;
4780
+ }
4781
+ if ((children ?? []).length > 0) {
4782
+ errors.push({
4783
+ message: `Linked Ledger Accounts cannot have children (key: ${key}, name: ${name})`,
4784
+ path: [...path, "children"]
4785
+ });
4786
+ }
4787
+ const { id, linkId, externalId } = linkedAccount;
4788
+ if (!id && !(externalId && linkId)) {
4789
+ errors.push({
4790
+ message: `Linked Ledger Accounts must specify both External ID + Link ID or the Fragment ID. (key: ${key}, name: ${name})`,
4791
+ path: [...path, "linkedAccount"]
4792
+ });
4793
+ }
4794
+ const doesNotExistOrNoParams = (arg) => arg === void 0 || getSchemaObjectParameters(arg).length === 0;
4795
+ if ((isTemplateChild || template) && [id, linkId, externalId].every(doesNotExistOrNoParams)) {
4796
+ errors.push({
4797
+ message: `Template accounts (and their children) cannot have linkedAccount properties hardcoded. You must provide parameters in the ExternalAccountMatchInput. (key: ${key}, name: ${name})`,
4798
+ path: [...path, "linkedAccount"]
4799
+ });
4800
+ }
4801
+ if (id) {
4802
+ errors.push(
4803
+ ...safeGetZodErrors(ParameterizedString, id, [
4804
+ ...path,
4805
+ "linkedAccount",
4806
+ "id"
4807
+ ])
4808
+ );
4809
+ }
4810
+ if (linkId) {
4811
+ errors.push(
4812
+ ...safeGetZodErrors(ParameterizedString, linkId, [
4813
+ ...path,
4814
+ "linkedAccount",
4815
+ "linkId"
4816
+ ])
4817
+ );
4818
+ }
4819
+ if (externalId) {
4820
+ errors.push(
4821
+ ...safeGetZodErrors(ParameterizedString, externalId, [
4822
+ ...path,
4823
+ "linkedAccount",
4824
+ "externalId"
4825
+ ])
4826
+ );
4827
+ }
4828
+ return errors;
4829
+ };
4830
+ var validateAccountClearing = ({
4831
+ clearing,
4832
+ linkedAccount,
4833
+ children,
4834
+ key,
4835
+ name,
4836
+ path
4837
+ }) => {
4838
+ const errors = [];
4839
+ if (!clearing) {
4840
+ return errors;
4841
+ }
4842
+ if (linkedAccount) {
4843
+ errors.push({
4844
+ message: `Clearing accounts cannot be Linked Ledger Accounts (key: ${key}, name: ${name})`,
4845
+ path: [...path, "clearing"]
4846
+ });
4847
+ }
4848
+ if ((children ?? []).length > 0) {
4849
+ errors.push({
4850
+ message: `Clearing accounts cannot have children (key: ${key}, name: ${name})`,
4851
+ path: [...path, "clearing"]
4852
+ });
4853
+ }
4854
+ return errors;
4855
+ };
4739
4856
  var validateAccount = ({
4740
4857
  account,
4741
4858
  path,
@@ -4777,88 +4894,36 @@ var validateAccount = ({
4777
4894
  path: [...path, "type"]
4778
4895
  });
4779
4896
  }
4780
- if (account.linkedAccount) {
4781
- if ((account.children ?? []).length > 0) {
4782
- errors.push({
4783
- message: `Linked Ledger Accounts cannot have children (key: ${account.key}, name: ${account.name})`,
4784
- path: [...path, "children"]
4785
- });
4786
- }
4787
- const { id, linkId, externalId } = account.linkedAccount;
4788
- if (!id && !(externalId && linkId)) {
4789
- errors.push({
4790
- message: `Linked Ledger Accounts must specify both External ID + Link ID or the Fragment ID. (key: ${account.key}, name: ${account.name})`,
4791
- path: [...path, "linkedAccount"]
4792
- });
4793
- }
4794
- const doesNotExistOrNoParams = (arg) => arg === void 0 || getSchemaObjectParameters(arg).length === 0;
4795
- if ((isTemplateChild || account.template) && [id, linkId, externalId].every(doesNotExistOrNoParams)) {
4796
- errors.push({
4797
- message: `Template accounts (and their children) cannot have linkedAccount properties hardcoded. You must provide parameters in the ExternalAccountMatchInput. (key: ${account.key}, name: ${account.name})`,
4798
- path: [...path, "linkedAccount"]
4799
- });
4800
- }
4801
- if (id) {
4802
- errors.push(
4803
- ...safeGetZodErrors(ParameterizedString, id, [
4804
- ...path,
4805
- "linkedAccount",
4806
- "id"
4807
- ])
4808
- );
4809
- }
4810
- if (linkId) {
4811
- errors.push(
4812
- ...safeGetZodErrors(ParameterizedString, linkId, [
4813
- ...path,
4814
- "linkedAccount",
4815
- "linkId"
4816
- ])
4817
- );
4818
- }
4819
- if (externalId) {
4820
- errors.push(
4821
- ...safeGetZodErrors(ParameterizedString, externalId, [
4822
- ...path,
4823
- "linkedAccount",
4824
- "externalId"
4825
- ])
4826
- );
4827
- }
4828
- }
4829
- if (account.currency && account.currencyMode === "multi") {
4830
- errors.push({
4831
- message: `Currency cannot be set for a multi-currency Ledger Account (key: ${account.key}, name: ${account.name})`,
4832
- path: [...path, "currency"]
4833
- });
4834
- }
4835
- if (account.currency && !SchemaCurrencyMatchInput2.safeParse(account.currency).success) {
4836
- if (account.currency.code === "CUSTOM" && !account.currency.customCurrencyId) {
4837
- errors.push({
4838
- message: `Must provide custom currency ID for custom currency (key: ${account.key}, name: ${account.name})`,
4839
- path: [...path, "currency", "customCurrencyId"]
4840
- });
4841
- } else if (account.currency.code !== "CUSTOM") {
4842
- errors.push({
4843
- message: `Currency code '${account.currency.code}' is invalid (key: ${account.key}, name: ${account.name})`,
4844
- path: [...path, "currency", "code"]
4845
- });
4846
- }
4847
- }
4848
- if (account.clearing) {
4849
- if (account.linkedAccount) {
4850
- errors.push({
4851
- message: `Clearing accounts cannot be Linked Ledger Accounts (key: ${account.key}, name: ${account.name})`,
4852
- path: [...path, "clearing"]
4853
- });
4854
- }
4855
- if ((account.children ?? []).length > 0) {
4856
- errors.push({
4857
- message: `Clearing accounts cannot have children (key: ${account.key}, name: ${account.name})`,
4858
- path: [...path, "clearing"]
4859
- });
4860
- }
4861
- }
4897
+ errors.push(
4898
+ ...validateAccountLinkedAccount({
4899
+ linkedAccount: account.linkedAccount,
4900
+ children: account.children,
4901
+ template: account.template,
4902
+ isTemplateChild,
4903
+ key: account.key,
4904
+ name: account.name,
4905
+ path
4906
+ })
4907
+ );
4908
+ errors.push(
4909
+ ...validateAccountCurrency({
4910
+ currency: account.currency,
4911
+ currencyMode: account.currencyMode,
4912
+ key: account.key,
4913
+ name: account.name,
4914
+ path
4915
+ })
4916
+ );
4917
+ errors.push(
4918
+ ...validateAccountClearing({
4919
+ clearing: account.clearing,
4920
+ linkedAccount: account.linkedAccount,
4921
+ children: account.children,
4922
+ key: account.key,
4923
+ name: account.name,
4924
+ path
4925
+ })
4926
+ );
4862
4927
  const accountConsistencyErrors = account.consistencyConfig ? validateAccountConsistencySettings(account.consistencyConfig) : { errors: [] };
4863
4928
  errors.push(...accountConsistencyErrors.errors);
4864
4929
  const status = getAccountStatus(account);
@@ -5710,123 +5775,201 @@ var validateUniqueByKey = ({
5710
5775
  }))
5711
5776
  );
5712
5777
  };
5713
- var validateLine = (entry, line, accountPathToAccount) => {
5714
- const validationResult = [
5715
- ...validateNonEmptySafeString({
5716
- value: line.key,
5717
- path: ["key"],
5718
- name: "key",
5719
- 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 '#'`
5720
5819
  }),
5721
- ...safeGetZodErrors(
5722
- ParameterizedString.refine((s) => s.length > 0, {
5723
- message: `Ledger Line (${line.key}) in Ledger Entry (${entry.type}) must specify a Ledger Account path`
5724
- }).refine((s) => !s.includes("#"), {
5725
- message: `Ledger Line account path '${line.account.path}' cannot contain '#'`
5726
- }),
5727
- line.account.path,
5728
- ["account", "path"]
5729
- ),
5730
- ...safeGetZodErrors(ParameterizedAmount(), line.amount, ["amount"])
5731
- ];
5732
- const accountPath = line.account.path;
5820
+ accountPath,
5821
+ ["account", "path"]
5822
+ );
5733
5823
  const structuralPath = getStructuralPath(accountPath);
5734
5824
  const instanceValueMap = getInstanceValueByAccountPath(accountPath);
5735
5825
  Array.from(instanceValueMap.keys()).forEach((ancestorPath) => {
5736
5826
  const structuralAncestorPath = getStructuralPath(ancestorPath);
5737
5827
  const ancestor = accountPathToAccount.get(structuralAncestorPath);
5738
5828
  if (!ancestor) {
5739
- validationResult.push({
5829
+ validationResults.push({
5740
5830
  path: ["account"],
5741
- 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})`
5742
5832
  });
5743
5833
  return;
5744
5834
  }
5745
5835
  if (ancestor.template && !ancestor.linkedAccount && instanceValueMap.get(ancestorPath) === void 0) {
5746
- validationResult.push({
5836
+ validationResults.push({
5747
5837
  path: ["account"],
5748
- 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}).`
5749
5839
  });
5750
5840
  }
5751
5841
  });
5752
- const fullParameterizedAccount = accountPathToAccount.get(structuralPath);
5753
- const account = fullParameterizedAccount && reparameterizeSchemaLedgerAccountInput({
5754
- account: { ...fullParameterizedAccount, path: structuralPath },
5755
- entryParameters: entry.parameters,
5756
- fillParamOptions: {
5757
- allowMissing: true,
5758
- allowMissingInChildren: true
5759
- }
5760
- });
5842
+ const account = getFullyParameterizedAccount(
5843
+ accountPath,
5844
+ accountPathToAccount,
5845
+ entryParameters
5846
+ );
5761
5847
  if (instanceValueMap.get(structuralPath) !== void 0 && account && !account.template) {
5762
- validationResult.push({
5763
- 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})`,
5764
5850
  path: ["account", "path"]
5765
5851
  });
5766
5852
  }
5767
5853
  if (instanceValueMap.get(structuralPath) === "" && account && account.template) {
5768
- validationResult.push({
5769
- 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})`,
5770
5856
  path: ["account", "path"]
5771
5857
  });
5772
5858
  }
5773
- if (!line.amount && (entry.lines.length !== 2 || !entry.lines.some((l) => l.tx))) {
5774
- validationResult.push({
5775
- 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})`,
5776
- path: ["amount"]
5777
- });
5778
- }
5779
- if (line.currency && account && account.currencyMode === "single" && account.currency && account.currency.code !== line.currency.code) {
5780
- if (!getSchemaObjectParameters(line.currency.code).length && getSchemaObjectParameters(account.currency.code).length) {
5781
- } else if (getSchemaObjectParameters(line.currency.code).length && !getSchemaObjectParameters(account.currency.code).length) {
5782
- 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({
5783
5872
  path: ["currency", "code"],
5784
- 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})`
5785
5874
  });
5786
5875
  } else {
5787
- validationResult.push({
5876
+ validationResults.push({
5788
5877
  path: ["currency", "code"],
5789
- 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}`
5790
5879
  });
5791
5880
  }
5792
5881
  }
5793
- if (!line.currency && account && account.currencyMode === "multi") {
5794
- validationResult.push({
5795
- 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})`,
5796
5885
  path: ["currency"]
5797
5886
  });
5798
5887
  }
5799
- if (line.currency && !SchemaCurrencyMatchInput2.safeParse(line.currency).success) {
5800
- if (line.currency.code === "CUSTOM" && !line.currency.customCurrencyId) {
5801
- validationResult.push({
5802
- 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})`,
5803
5892
  path: ["currency", "customCurrencyId"]
5804
5893
  });
5805
- } else if (line.currency.code !== "CUSTOM") {
5806
- validationResult.push({
5807
- 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})`,
5808
5897
  path: ["currency", "code"]
5809
5898
  });
5810
5899
  }
5811
5900
  }
5812
- if (line.tx && account && !account.linkedAccount) {
5813
- validationResult.push({
5814
- 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})`,
5815
5913
  path: ["tx"]
5816
5914
  });
5817
5915
  }
5818
- if (!line.tx && account && account.linkedAccount) {
5819
- validationResult.push({
5820
- 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})`,
5821
5919
  path: ["tx"]
5822
5920
  });
5823
5921
  }
5824
- if (account && account.linkedAccount && line.tx && !(line.tx.externalId || line.tx.id)) {
5825
- validationResult.push({
5826
- 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})`,
5827
5925
  path: ["tx"]
5828
5926
  });
5829
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
+ );
5830
5973
  return validationResult;
5831
5974
  };
5832
5975
  var isKDefined = (k, line) => {
@@ -5849,7 +5992,14 @@ var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
5849
5992
  ...line,
5850
5993
  currency: line.currency ?? line.account?.currency
5851
5994
  })).filter((line) => isKDefined("currency", line)).filter(
5852
- (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
5853
6003
  );
5854
6004
  if (lines.length < ledgerEntry.lines.length) {
5855
6005
  return [];
@@ -6239,7 +6389,10 @@ var validateEntry = (ledgerEntry, accountPathToAccount) => {
6239
6389
  errors.push(
6240
6390
  ...ledgerEntry.lines.flatMap(
6241
6391
  (line, idx) => validateLine(
6242
- ledgerEntry,
6392
+ ledgerEntry.type,
6393
+ ledgerEntry.parameters,
6394
+ ledgerEntry.lines.length === 2,
6395
+ ledgerEntry.lines.some((l) => l.tx),
6243
6396
  parameterizeSchemaLedgerLineInput({
6244
6397
  line,
6245
6398
  entryParameters: ledgerEntry.parameters
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-IVDQ4PQW.js";
3
+ } from "./chunk-SHTFFJEV.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-IH6BCA6S.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-IVDQ4PQW.js";
3
+ } from "./chunk-SHTFFJEV.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-IH6BCA6S.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getSdk
3
- } from "./chunk-UXTOXY2F.js";
3
+ } from "./chunk-7N2Q46HP.js";
4
4
  import {
5
5
  FragmentCommand,
6
6
  GraphQLClient,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-IVDQ4PQW.js";
3
+ } from "./chunk-SHTFFJEV.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-IH6BCA6S.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-IVDQ4PQW.js";
3
+ } from "./chunk-SHTFFJEV.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-IH6BCA6S.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-IVDQ4PQW.js";
3
+ } from "./chunk-SHTFFJEV.js";
4
4
  import {
5
5
  init_cjs_shims
6
6
  } from "./chunk-7GH3YGSC.js";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  Schema,
9
9
  parseWithError
10
- } from "./chunk-SEXV6TUY.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-SEXV6TUY.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-P2FYO77R.js";
5
+ } from "./chunk-UWS3TQHL.js";
6
6
  import {
7
7
  DEFAULT_SCHEMA_PATH
8
8
  } from "./chunk-A4BSWX5D.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-IVDQ4PQW.js";
3
+ } from "./chunk-SHTFFJEV.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-IH6BCA6S.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-IVDQ4PQW.js";
3
+ } from "./chunk-SHTFFJEV.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-IH6BCA6S.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-JEFROCJ4.js";
4
4
  import {
5
5
  AuthenticatedCommand
6
- } from "./chunk-IVDQ4PQW.js";
6
+ } from "./chunk-SHTFFJEV.js";
7
7
  import {
8
8
  require_lib
9
9
  } from "./chunk-IH6BCA6S.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AddLedgerEntry
3
- } from "../chunk-BQJEXZ3Z.js";
4
- import "../chunk-IVDQ4PQW.js";
5
- import "../chunk-UXTOXY2F.js";
3
+ } from "../chunk-SQRQUPQM.js";
4
+ import "../chunk-SHTFFJEV.js";
5
+ import "../chunk-7N2Q46HP.js";
6
6
  import "../chunk-IH6BCA6S.js";
7
7
  import "../chunk-UDU5PBTV.js";
8
8
  import "../chunk-LJSFUVJW.js";