@fragment-dev/cli 2026.8.12 → 2026.8.13-1

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-RSG3R56J.js → chunk-25RM4I6G.js} +1 -1
  2. package/dist/{chunk-5KQ5OCKA.js → chunk-2IMQAI2H.js} +1 -1
  3. package/dist/{chunk-LQZUHYYU.js → chunk-4BCQFVJS.js} +1 -1
  4. package/dist/{chunk-ILQG7D3T.js → chunk-63M7ILIN.js} +1 -1
  5. package/dist/{chunk-J5XCGVQ6.js → chunk-7FQSPYFZ.js} +1 -1
  6. package/dist/{chunk-BGEMD3HF.js → chunk-D67ACT4J.js} +357 -12
  7. package/dist/{chunk-GYHXNIWR.js → chunk-G353NPK6.js} +1 -1
  8. package/dist/{chunk-PQFLP34K.js → chunk-GXPUQEAI.js} +1 -1
  9. package/dist/{chunk-4QAIVY4H.js → chunk-HVQUC54T.js} +1 -1
  10. package/dist/{chunk-IGQSMBKU.js → chunk-ISIHYAS2.js} +19 -19
  11. package/dist/{chunk-7ZKTVCSL.js → chunk-JCJNNUTD.js} +1 -1
  12. package/dist/{chunk-KZW3FS6C.js → chunk-JDSPZQFF.js} +1 -1
  13. package/dist/{chunk-ZGSMOYIU.js → chunk-K3P7VNMI.js} +1 -1
  14. package/dist/{chunk-CTS6NEPI.js → chunk-MW6SJUWV.js} +1 -1
  15. package/dist/{chunk-7CLYUPBW.js → chunk-MXE6IHUJ.js} +1 -1
  16. package/dist/{chunk-MPWRVHST.js → chunk-QAFH3E4Q.js} +1 -1
  17. package/dist/{chunk-7DA5BUZB.js → chunk-RR6PO7KH.js} +17 -0
  18. package/dist/{chunk-F4FOZXDF.js → chunk-SI23PX53.js} +1 -1
  19. package/dist/{chunk-BMVJIALA.js → chunk-TKGH62DQ.js} +1 -1
  20. package/dist/{chunk-7LZ2UEOL.js → chunk-TUQGCEII.js} +1 -1
  21. package/dist/{chunk-REHGTHTG.js → chunk-URUHIS5X.js} +1 -1
  22. package/dist/{chunk-VPMGSMMO.js → chunk-VCANHQTI.js} +1 -1
  23. package/dist/{chunk-D3DHORM5.js → chunk-XWX7CFJN.js} +1 -1
  24. package/dist/{chunk-HRTIPO6Y.js → chunk-YVL4XU33.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 +7 -1
  48. package/dist/utils/schemaValidation.js +2 -2
  49. package/oclif.manifest.json +1 -1
  50. package/package.json +1 -1
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  Schema,
9
9
  parseWithError
10
- } from "./chunk-BGEMD3HF.js";
10
+ } from "./chunk-D67ACT4J.js";
11
11
  import {
12
12
  formatValidationErrors,
13
13
  logValidationErrors
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-W2V2ILHS.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-W2V2ILHS.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  init_cjs_shims
6
6
  } from "./chunk-7GH3YGSC.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-W2V2ILHS.js";
@@ -4651,21 +4651,31 @@ var SystemLineKind = {
4651
4651
  payment_fee_line: "payment_fee_line"
4652
4652
  };
4653
4653
  var SystemLineKindSchema = z.nativeEnum(SystemLineKind);
4654
+ var SystemLineParameterName = {
4655
+ payment_settlement_line: "payment_amount",
4656
+ payment_fee_line: "fragment_fee_amount"
4657
+ };
4658
+ var SYSTEM_LINE_AMOUNT = {
4659
+ [SystemLineKind.payment_settlement_line]: `{{${SystemLineParameterName.payment_settlement_line}}}`,
4660
+ [SystemLineKind.payment_fee_line]: `-{{${SystemLineParameterName.payment_fee_line}}}`
4661
+ };
4654
4662
  var BaseSchemaPaymentInput = z.object({
4655
4663
  amount: z.string(),
4656
4664
  direction: PaymentTypeDirectionSchema
4657
4665
  });
4658
4666
  var BaseSchemaPaymentEntryLineInput = BaseSchemaLedgerEntryLineInput.extend({
4667
+ amount: z.string(),
4659
4668
  system: SystemLineKindSchema.optional()
4660
4669
  });
4661
4670
  var BaseSchemaPaymentEntryInput = z.object({
4662
4671
  description: z.string().optional(),
4663
- lines: z.array(BaseSchemaPaymentEntryLineInput).optional()
4672
+ lines: z.array(BaseSchemaPaymentEntryLineInput)
4664
4673
  });
4674
+ var SchemaPaymentEntryStatusSchema = z.enum(["active"]);
4665
4675
  var BaseSchemaPaymentTypeInput = z.object({
4666
4676
  type: z.string(),
4667
4677
  typeVersion: z.number().int(),
4668
- status: SchemaLedgerEntityStatusSchema,
4678
+ status: SchemaPaymentEntryStatusSchema,
4669
4679
  payment: BaseSchemaPaymentInput,
4670
4680
  accounting: z.object({
4671
4681
  needs_confirmation_to_processing: BaseSchemaPaymentEntryInput.optional(),
@@ -6342,7 +6352,7 @@ var getFullyParameterizedAccount = (accountPath, accountPathToAccount, entryPara
6342
6352
  });
6343
6353
  return account;
6344
6354
  };
6345
- var validateLineAccount = (entryType, lineKey, accountPath, accountPathToAccount, entryParameters) => {
6355
+ var validateLineAccount = (entryType, lineKey, accountPath, accountPathToAccount, entryParameters, options) => {
6346
6356
  const validationResults = safeGetZodErrors(
6347
6357
  ParameterizedString.refine((s2) => s2.length > 0, {
6348
6358
  message: `Ledger Line (${lineKey}) in Ledger Entry (${entryType}) must specify a Ledger Account path`
@@ -6389,8 +6399,9 @@ var validateLineAccount = (entryType, lineKey, accountPath, accountPathToAccount
6389
6399
  });
6390
6400
  }
6391
6401
  try {
6392
- if (account && getSchemaAccountCategory(account) === "Payment" /* Payment */) {
6402
+ if (!options?.allowPaymentAccount && account && getSchemaAccountCategory(account) === "Payment" /* Payment */) {
6393
6403
  validationResults.push({
6404
+ code: "payment_account_in_ledger_entry",
6394
6405
  message: `Ledger Entries cannot post to Payment Accounts. (entry: ${entryType} | line key: ${lineKey} | account path: ${accountPath})`,
6395
6406
  path: ["account", "path"]
6396
6407
  });
@@ -6481,7 +6492,7 @@ var validateLineTx = (tx, accountPath, accountPathToAccount, entryParameters, li
6481
6492
  }
6482
6493
  return validationResults;
6483
6494
  };
6484
- var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLineWithTx, line, accountPathToAccount) => {
6495
+ var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLineWithTx, line, accountPathToAccount, options) => {
6485
6496
  const validationResult = validateLineKey(line.key);
6486
6497
  const accountPath = line.account.path;
6487
6498
  const parameters = entryParameters ?? {};
@@ -6501,7 +6512,8 @@ var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLin
6501
6512
  line.key,
6502
6513
  accountPath,
6503
6514
  accountPathToAccount,
6504
- parameters
6515
+ parameters,
6516
+ options
6505
6517
  )
6506
6518
  );
6507
6519
  validationResult.push(
@@ -6538,7 +6550,7 @@ var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLin
6538
6550
  var isKDefined = (k2, line) => {
6539
6551
  return line[k2] !== void 0;
6540
6552
  };
6541
- var validateBalancedLineGroup = (entryType, entryParameters, lines, accountPathToAccount) => {
6553
+ var validateBalancedLineGroup = (entryType, entryParameters, lines, accountPathToAccount, options) => {
6542
6554
  const parameterizedLines = lines.map(
6543
6555
  (line) => parameterizeSchemaLedgerLineInput({
6544
6556
  line,
@@ -6561,7 +6573,8 @@ var validateBalancedLineGroup = (entryType, entryParameters, lines, accountPathT
6561
6573
  lines.length === 2,
6562
6574
  lines.some((l) => l.tx),
6563
6575
  line,
6564
- accountPathToAccount
6576
+ accountPathToAccount,
6577
+ options
6565
6578
  ).length === 0
6566
6579
  );
6567
6580
  if (parameterizedLines.length < lines.length) {
@@ -6585,7 +6598,7 @@ var validateBalancedLineGroup = (entryType, entryParameters, lines, accountPathT
6585
6598
  }
6586
6599
  return [];
6587
6600
  };
6588
- var validateBalancedLines = (entryType, entryParameters, lines, accountPathToAccount) => {
6601
+ var validateBalancedLines = (entryType, entryParameters, lines, accountPathToAccount, options) => {
6589
6602
  const staticLines = lines.filter((line) => !line.repeated);
6590
6603
  const repeatedGroups = /* @__PURE__ */ new Map();
6591
6604
  lines.forEach((line) => {
@@ -6602,7 +6615,8 @@ var validateBalancedLines = (entryType, entryParameters, lines, accountPathToAcc
6602
6615
  entryType,
6603
6616
  entryParameters,
6604
6617
  staticLines,
6605
- accountPathToAccount
6618
+ accountPathToAccount,
6619
+ options
6606
6620
  )
6607
6621
  );
6608
6622
  }
@@ -6612,7 +6626,8 @@ var validateBalancedLines = (entryType, entryParameters, lines, accountPathToAcc
6612
6626
  entryType,
6613
6627
  entryParameters,
6614
6628
  groupLines,
6615
- accountPathToAccount
6629
+ accountPathToAccount,
6630
+ options
6616
6631
  ).map((error) => ({
6617
6632
  ...error,
6618
6633
  message: `[repeated key '${key}'] ${error.message}`
@@ -7445,6 +7460,285 @@ var validateGroup = (group, validatedCoA, validatedEntries, index) => {
7445
7460
  return errors;
7446
7461
  };
7447
7462
 
7463
+ // ../../libs/schema-validation/utils/transformers/payments.ts
7464
+ init_cjs_shims();
7465
+ var amountMatchesSystemLine = (amount, system) => amount === SYSTEM_LINE_AMOUNT[system];
7466
+ var getAccountCategoryOrUndefined = (account) => {
7467
+ try {
7468
+ return getSchemaAccountCategory(account);
7469
+ } catch (e2) {
7470
+ if (e2 instanceof AccountCategoryMutualExclusionError) {
7471
+ return void 0;
7472
+ }
7473
+ throw e2;
7474
+ }
7475
+ };
7476
+ var findPaymentAccountPath = (accountPathToAccount) => Array.from(accountPathToAccount.entries()).find(
7477
+ ([, account]) => getAccountCategoryOrUndefined(account) === "Payment" /* Payment */
7478
+ )?.[0];
7479
+ var fillInPaymentEntryLines = (entry, accountPathToAccount) => (entry.lines ?? []).map((line, idx) => {
7480
+ const path = line.account?.path ? getStructuralPath(line.account.path) : void 0;
7481
+ return {
7482
+ ...line,
7483
+ account: line.account ?? { path: "" },
7484
+ key: line.key ?? `line-${idx}`,
7485
+ amount: line.amount ?? "",
7486
+ currency: line.currency ?? (path ? accountPathToAccount.get(path)?.currency : void 0)
7487
+ };
7488
+ });
7489
+ var validateSystemLines = ({
7490
+ lines,
7491
+ event,
7492
+ entryIdentity,
7493
+ paymentAccountPath
7494
+ }) => {
7495
+ const errors = [];
7496
+ if (event !== PaymentEventKey.processing_to_settled) {
7497
+ lines.forEach((line, idx) => {
7498
+ if (line.system) {
7499
+ errors.push({
7500
+ path: ["lines", idx, "system"],
7501
+ message: `System lines are only allowed on the '${PaymentEventKey.processing_to_settled}' entry. (payment entry: ${entryIdentity} | line key: ${line.key})`
7502
+ });
7503
+ }
7504
+ });
7505
+ return errors;
7506
+ }
7507
+ Object.values(SystemLineKind).forEach((system) => {
7508
+ const count = lines.filter((line) => line.system === system).length;
7509
+ if (count !== 1) {
7510
+ errors.push({
7511
+ path: ["lines"],
7512
+ message: `Payment entry (${entryIdentity}) must have exactly one line with system '${system}', found ${count}.`
7513
+ });
7514
+ }
7515
+ });
7516
+ lines.forEach((line, idx) => {
7517
+ const isPaymentAccountLine = paymentAccountPath !== void 0 && getStructuralPath(line.account.path) === paymentAccountPath;
7518
+ if (line.system) {
7519
+ if (paymentAccountPath !== void 0 && !isPaymentAccountLine) {
7520
+ errors.push({
7521
+ path: ["lines", idx, "account", "path"],
7522
+ message: `System line '${line.system}' must post to the Payment Account. (payment entry: ${entryIdentity} | line key: ${line.key})`
7523
+ });
7524
+ }
7525
+ if (!amountMatchesSystemLine(line.amount, line.system)) {
7526
+ errors.push({
7527
+ path: ["lines", idx, "amount"],
7528
+ message: `System line '${line.system}' must have amount '${SYSTEM_LINE_AMOUNT[line.system]}'. (payment entry: ${entryIdentity} | line key: ${line.key})`
7529
+ });
7530
+ }
7531
+ } else if (isPaymentAccountLine) {
7532
+ errors.push({
7533
+ path: ["lines", idx, "system"],
7534
+ message: `Only system lines may post to the Payment Account. (payment entry: ${entryIdentity} | line key: ${line.key})`
7535
+ });
7536
+ }
7537
+ });
7538
+ return errors;
7539
+ };
7540
+ var validatePaymentEntry = ({
7541
+ entry,
7542
+ event,
7543
+ entryIdentity,
7544
+ accountPathToAccount,
7545
+ paymentAccountPath
7546
+ }) => {
7547
+ const errors = [];
7548
+ errors.push(...validateDescription(entry.description));
7549
+ const lines = fillInPaymentEntryLines(entry, accountPathToAccount);
7550
+ if (lines.length > MAX_ENTRY_LINES) {
7551
+ errors.push({
7552
+ path: ["lines"],
7553
+ message: `Payment entry (${entryIdentity}) has too many lines. The maximum allowed is ${MAX_ENTRY_LINES}, but this entry has ${lines.length}.`
7554
+ });
7555
+ }
7556
+ const allowPaymentAccount = event === PaymentEventKey.processing_to_settled;
7557
+ errors.push(
7558
+ ...lines.flatMap((line, idx) => {
7559
+ const lineErrors = [];
7560
+ if (line.tx) {
7561
+ lineErrors.push({
7562
+ path: ["tx"],
7563
+ message: `Payment entry lines cannot specify tx matches. (payment entry: ${entryIdentity} | line key: ${line.key})`
7564
+ });
7565
+ }
7566
+ if (line.repeated) {
7567
+ lineErrors.push({
7568
+ path: ["repeated"],
7569
+ message: `Payment entry lines cannot be repeated. (payment entry: ${entryIdentity} | line key: ${line.key})`
7570
+ });
7571
+ }
7572
+ if (line.tags?.length) {
7573
+ lineErrors.push({
7574
+ path: ["tags"],
7575
+ message: `Payment entry lines cannot specify tags. (payment entry: ${entryIdentity} | line key: ${line.key})`
7576
+ });
7577
+ }
7578
+ const account = accountPathToAccount.get(
7579
+ getStructuralPath(line.account.path)
7580
+ );
7581
+ if (account && getAccountCategoryOrUndefined(account) === "Linked" /* Linked */) {
7582
+ lineErrors.push({
7583
+ path: ["account", "path"],
7584
+ message: `Payment entry lines cannot post to Linked Accounts. (payment entry: ${entryIdentity} | line key: ${line.key})`
7585
+ });
7586
+ }
7587
+ lineErrors.push(
7588
+ ...validateLine(
7589
+ entryIdentity,
7590
+ void 0,
7591
+ lines.length === 2,
7592
+ false,
7593
+ line,
7594
+ accountPathToAccount,
7595
+ { allowPaymentAccount }
7596
+ ).filter(({ path }) => path[0] !== "tx")
7597
+ );
7598
+ return lineErrors.map(({ path, ...rest }) => ({
7599
+ path: ["lines", idx, ...path],
7600
+ ...rest
7601
+ }));
7602
+ })
7603
+ );
7604
+ errors.push(
7605
+ ...validateUniqueByKey({
7606
+ key: "key",
7607
+ items: lines,
7608
+ pathPrefix: ["lines"],
7609
+ getErrorMessage: (item) => `Payment entry (${entryIdentity}) already has a line with key '${item.key}'`
7610
+ })
7611
+ );
7612
+ errors.push(
7613
+ ...validateBalancedLines(
7614
+ entryIdentity,
7615
+ void 0,
7616
+ lines,
7617
+ accountPathToAccount,
7618
+ {
7619
+ allowPaymentAccount
7620
+ }
7621
+ )
7622
+ );
7623
+ errors.push(
7624
+ ...validateSystemLines({ lines, event, entryIdentity, paymentAccountPath })
7625
+ );
7626
+ return errors;
7627
+ };
7628
+ var validatePaymentType = ({
7629
+ paymentType,
7630
+ accountPathToAccount,
7631
+ paymentAccountPath
7632
+ }) => {
7633
+ const errors = validateNonEmptySafeString({
7634
+ value: paymentType.type,
7635
+ path: ["type"],
7636
+ name: "type",
7637
+ entityName: "Payment Type"
7638
+ });
7639
+ if (paymentType.typeVersion !== 1) {
7640
+ errors.push({
7641
+ path: ["typeVersion"],
7642
+ message: `Payment Type (${paymentType.type}) must have typeVersion 1.`
7643
+ });
7644
+ }
7645
+ if (paymentType.payment.direction !== PaymentTypeDirection.payin) {
7646
+ errors.push({
7647
+ path: ["payment", "direction"],
7648
+ message: `Payment Type (${paymentType.type}) must have direction '${PaymentTypeDirection.payin}'. Direction '${PaymentTypeDirection.payout}' is not yet supported.`
7649
+ });
7650
+ }
7651
+ if (!paymentType.payment.amount.trim()) {
7652
+ errors.push({
7653
+ path: ["payment", "amount"],
7654
+ message: `Payment Type (${paymentType.type}) must specify a payment amount.`
7655
+ });
7656
+ } else {
7657
+ errors.push(
7658
+ ...safeGetZodErrors(ParameterizedAmount(), paymentType.payment.amount, [
7659
+ "payment",
7660
+ "amount"
7661
+ ])
7662
+ );
7663
+ }
7664
+ Object.keys(paymentType.accounting).filter((event) => !(event in PaymentEventKey)).forEach((event) => {
7665
+ errors.push({
7666
+ path: ["accounting", event],
7667
+ message: `Payment Type (${paymentType.type}) has unknown accounting event '${event}'. Supported events: ${Object.values(
7668
+ PaymentEventKey
7669
+ ).join(", ")}.`
7670
+ });
7671
+ });
7672
+ if (!paymentType.accounting.processing_to_settled) {
7673
+ errors.push({
7674
+ path: ["accounting", PaymentEventKey.processing_to_settled],
7675
+ message: `Payment Type (${paymentType.type}) must define a '${PaymentEventKey.processing_to_settled}' entry.`
7676
+ });
7677
+ }
7678
+ errors.push(
7679
+ ...Object.values(PaymentEventKey).flatMap((event) => {
7680
+ const entry = paymentType.accounting[event];
7681
+ if (!entry) {
7682
+ return [];
7683
+ }
7684
+ return validatePaymentEntry({
7685
+ entry,
7686
+ event,
7687
+ entryIdentity: `${paymentType.type}.${paymentType.typeVersion}.${event}`,
7688
+ accountPathToAccount,
7689
+ paymentAccountPath
7690
+ }).map(({ path, ...rest }) => ({
7691
+ path: ["accounting", event, ...path],
7692
+ ...rest
7693
+ }));
7694
+ })
7695
+ );
7696
+ return errors;
7697
+ };
7698
+ var transformAndValidatePayments = ({
7699
+ payments,
7700
+ validatedCoA
7701
+ }) => {
7702
+ const accountPathToAccount = getStructuralPathToAccount(validatedCoA);
7703
+ const paymentAccountPath = findPaymentAccountPath(accountPathToAccount);
7704
+ const errors = [];
7705
+ if (payments.types.length > 0 && paymentAccountPath === void 0) {
7706
+ errors.push({
7707
+ path: ["types"],
7708
+ message: `Schema must contain a Payment Account to define Payment Types.`
7709
+ });
7710
+ }
7711
+ errors.push(
7712
+ ...Array.from(
7713
+ groupByMap(
7714
+ payments.types.map((paymentType, idx) => [paymentType, idx]),
7715
+ ([paymentType]) => `${paymentType.type}:${paymentType.typeVersion}`
7716
+ ).values()
7717
+ ).filter((group) => group.length > 1).flatMap(
7718
+ (group) => group.map(([paymentType, idx]) => ({
7719
+ message: `Payment Types cannot have duplicate types '${paymentType.type}'`,
7720
+ path: ["types", idx, "type"]
7721
+ }))
7722
+ )
7723
+ );
7724
+ errors.push(
7725
+ ...payments.types.flatMap(
7726
+ (paymentType, idx) => validatePaymentType({
7727
+ paymentType,
7728
+ accountPathToAccount,
7729
+ paymentAccountPath
7730
+ }).map(({ path, ...rest }) => ({
7731
+ path: ["types", idx, ...path],
7732
+ ...rest
7733
+ }))
7734
+ )
7735
+ );
7736
+ return {
7737
+ filledIn: payments,
7738
+ errors
7739
+ };
7740
+ };
7741
+
7448
7742
  // ../../libs/schema-validation/types.ts
7449
7743
  var SchemaCurrencyMatchInput2 = z.object({
7450
7744
  customCurrencyId: ParameterizedString.optional(),
@@ -7677,6 +7971,39 @@ var SchemaLedgerEntryInput = z.object({
7677
7971
  var SchemaLedgerEntriesInput = z.object({
7678
7972
  types: z.array(SchemaLedgerEntryInput)
7679
7973
  });
7974
+ var SchemaPaymentLineInput = SchemaLedgerLineInput.pick({
7975
+ key: true,
7976
+ account: true,
7977
+ currency: true,
7978
+ description: true
7979
+ }).extend({
7980
+ // Required, unlike ledger lines — payment entries have no runtime-filled
7981
+ // variant.
7982
+ amount: ParameterizedAmount(),
7983
+ system: SystemLineKindSchema.optional()
7984
+ });
7985
+ var SchemaPaymentEntryInput = z.object({
7986
+ description: ParameterizedString.optional(),
7987
+ lines: z.array(SchemaPaymentLineInput)
7988
+ });
7989
+ var SchemaPaymentTypeInput = z.object({
7990
+ type: SafeStringSchema,
7991
+ typeVersion: z.number().int().positive(),
7992
+ status: SchemaPaymentEntryStatusSchema,
7993
+ payment: z.object({
7994
+ amount: ParameterizedAmount(),
7995
+ direction: PaymentTypeDirectionSchema
7996
+ }),
7997
+ accounting: z.object({
7998
+ needs_confirmation_to_processing: SchemaPaymentEntryInput.optional(),
7999
+ processing_to_settled: SchemaPaymentEntryInput
8000
+ })
8001
+ });
8002
+ var SchemaPaymentsInput = z.object({
8003
+ types: z.array(SchemaPaymentTypeInput).min(1, {
8004
+ message: "At least one Payment Type is required. Omit `payments` to store a schema without Payment Types."
8005
+ })
8006
+ });
7680
8007
  var LedgerConsistencyConfigSchema = ConsistencyConfigSchema(
7681
8008
  ["entries"],
7682
8009
  {}
@@ -7706,11 +8033,19 @@ var Schema = z.object({
7706
8033
  ),
7707
8034
  chartOfAccounts: ChartOfAccounts,
7708
8035
  ledgerEntries: SchemaLedgerEntriesInput.optional(),
8036
+ // TODO (FRA-7422): validate payment types beyond the structural parse.
8037
+ payments: SchemaPaymentsInput.optional(),
7709
8038
  consistencyConfig: z.optional(LedgerConsistencyConfigSchema),
7710
8039
  scenes: z.array(Scene).optional(),
7711
8040
  groups: z.array(SchemaEntryGroup).optional()
7712
8041
  }).transform((schema, ctx) => {
7713
- const { chartOfAccounts, ledgerEntries, consistencyConfig, groups } = schema;
8042
+ const {
8043
+ chartOfAccounts,
8044
+ ledgerEntries,
8045
+ consistencyConfig,
8046
+ groups,
8047
+ payments
8048
+ } = schema;
7714
8049
  const { errors, filledIn: validatedLedgerEntries } = transformAndValidateEntries({
7715
8050
  ledgerEntries: ledgerEntries ?? { types: [] },
7716
8051
  validatedCoA: chartOfAccounts
@@ -7722,6 +8057,16 @@ var Schema = z.object({
7722
8057
  path
7723
8058
  })
7724
8059
  );
8060
+ transformAndValidatePayments({
8061
+ payments: payments ?? { types: [] },
8062
+ validatedCoA: chartOfAccounts
8063
+ }).errors.map((e2) => ({ ...e2, path: ["payments", ...e2.path] })).forEach(
8064
+ ({ message, path }) => ctx.addIssue({
8065
+ code: z.ZodIssueCode.custom,
8066
+ message,
8067
+ path
8068
+ })
8069
+ );
7725
8070
  if (groups && groups.length > 0) {
7726
8071
  groups.forEach((group, index) => {
7727
8072
  const groupErrors = validateGroup(
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-W2V2ILHS.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-W2V2ILHS.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  init_cjs_shims
6
6
  } from "./chunk-7GH3YGSC.js";
@@ -3,37 +3,37 @@ import {
3
3
  } from "./chunk-JFF37Z5K.js";
4
4
  import {
5
5
  Workspace
6
- } from "./chunk-ILQG7D3T.js";
6
+ } from "./chunk-63M7ILIN.js";
7
7
  import {
8
8
  QuerySchemas
9
- } from "./chunk-4QAIVY4H.js";
9
+ } from "./chunk-HVQUC54T.js";
10
10
  import {
11
11
  ReverseLedgerEntry
12
- } from "./chunk-GYHXNIWR.js";
12
+ } from "./chunk-G353NPK6.js";
13
13
  import {
14
14
  Start
15
15
  } from "./chunk-TOXMGEU7.js";
16
16
  import {
17
17
  StoreSchema
18
- } from "./chunk-VPMGSMMO.js";
18
+ } from "./chunk-VCANHQTI.js";
19
19
  import {
20
20
  Token
21
- } from "./chunk-REHGTHTG.js";
21
+ } from "./chunk-URUHIS5X.js";
22
22
  import {
23
23
  UpdateLedgerAccount
24
- } from "./chunk-7LZ2UEOL.js";
24
+ } from "./chunk-TUQGCEII.js";
25
25
  import {
26
26
  Update
27
27
  } from "./chunk-IXX2EVIM.js";
28
28
  import {
29
29
  VerifySchema
30
- } from "./chunk-7ZKTVCSL.js";
30
+ } from "./chunk-JCJNNUTD.js";
31
31
  import {
32
32
  GenGraphQL
33
- } from "./chunk-RSG3R56J.js";
33
+ } from "./chunk-25RM4I6G.js";
34
34
  import {
35
35
  GetSchema
36
- } from "./chunk-KZW3FS6C.js";
36
+ } from "./chunk-JDSPZQFF.js";
37
37
  import {
38
38
  Init
39
39
  } from "./chunk-K5RBCJWQ.js";
@@ -42,37 +42,37 @@ import {
42
42
  } from "./chunk-IYYWZCZE.js";
43
43
  import {
44
44
  MigrateLedgerEntry
45
- } from "./chunk-BMVJIALA.js";
45
+ } from "./chunk-TKGH62DQ.js";
46
46
  import {
47
47
  QueryLedgerAccounts
48
- } from "./chunk-ZGSMOYIU.js";
48
+ } from "./chunk-K3P7VNMI.js";
49
49
  import {
50
50
  QueryLedgers
51
- } from "./chunk-MPWRVHST.js";
51
+ } from "./chunk-QAFH3E4Q.js";
52
52
  import {
53
53
  GetSchema as GetSchema2
54
- } from "./chunk-LQZUHYYU.js";
54
+ } from "./chunk-4BCQFVJS.js";
55
55
  import {
56
56
  AddLedgerEntry
57
- } from "./chunk-F4FOZXDF.js";
57
+ } from "./chunk-SI23PX53.js";
58
58
  import {
59
59
  ApiClientCreate
60
60
  } from "./chunk-5JLMMFER.js";
61
61
  import {
62
62
  CreateCustomLink
63
- } from "./chunk-CTS6NEPI.js";
63
+ } from "./chunk-MW6SJUWV.js";
64
64
  import {
65
65
  CreateLedger
66
- } from "./chunk-D3DHORM5.js";
66
+ } from "./chunk-XWX7CFJN.js";
67
67
  import {
68
68
  DeleteCustomTxs
69
- } from "./chunk-J5XCGVQ6.js";
69
+ } from "./chunk-7FQSPYFZ.js";
70
70
  import {
71
71
  DeleteLedger
72
- } from "./chunk-PQFLP34K.js";
72
+ } from "./chunk-GXPUQEAI.js";
73
73
  import {
74
74
  DeleteSchema
75
- } from "./chunk-5KQ5OCKA.js";
75
+ } from "./chunk-2IMQAI2H.js";
76
76
  import {
77
77
  init_cjs_shims
78
78
  } from "./chunk-7GH3YGSC.js";
@@ -2,7 +2,7 @@ import {
2
2
  extractSchemaMetadata,
3
3
  isJsonParseError,
4
4
  validateSchemaStructure
5
- } from "./chunk-7CLYUPBW.js";
5
+ } from "./chunk-MXE6IHUJ.js";
6
6
  import {
7
7
  DEFAULT_SCHEMA_PATH
8
8
  } from "./chunk-A4BSWX5D.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-KAGCPC3G.js";
4
4
  import {
5
5
  AuthenticatedCommand
6
- } from "./chunk-HRTIPO6Y.js";
6
+ } from "./chunk-YVL4XU33.js";
7
7
  import {
8
8
  require_lib
9
9
  } from "./chunk-W2V2ILHS.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-W2V2ILHS.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthenticatedCommand
3
- } from "./chunk-HRTIPO6Y.js";
3
+ } from "./chunk-YVL4XU33.js";
4
4
  import {
5
5
  require_lib
6
6
  } from "./chunk-W2V2ILHS.js";