@fragment-dev/cli 2026.9.10-1 → 2026.9.10-12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -290,7 +290,7 @@ FLAGS
290
290
  DESCRIPTION
291
291
  Generate GraphQL queries from your Schema for your SDK.
292
292
 
293
- This command generates a GraphQL query for each entry type in your ledger Schema.
293
+ This command generates a GraphQL query for each Ledger Entry type and each Payment type in your ledger Schema.
294
294
  Use this command with Fragment SDKs to create type-safe code to update your ledger.
295
295
 
296
296
  EXAMPLES
@@ -2,13 +2,13 @@ import {
2
2
  extractSchemaMetadata,
3
3
  isJsonParseError,
4
4
  validateSchemaStructure
5
- } from "./chunk-DJCFTORW.js";
5
+ } from "./chunk-FZPNPJCH.js";
6
6
  import {
7
7
  DEFAULT_SCHEMA_PATH
8
8
  } from "./chunk-A4BSWX5D.js";
9
9
  import {
10
10
  logValidationErrors
11
- } from "./chunk-J6HLIC77.js";
11
+ } from "./chunk-5AT6KBWC.js";
12
12
  import {
13
13
  FragmentCommand,
14
14
  require_lib
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BadRequestError
3
- } from "./chunk-65EVYD2Y.js";
3
+ } from "./chunk-ICUOG2GK.js";
4
4
  import {
5
5
  require_source
6
6
  } from "./chunk-XK2D2Z44.js";
@@ -1256,7 +1256,9 @@ mutation CreatePayment(
1256
1256
  payment {
1257
1257
  clientSecret
1258
1258
  ik
1259
- ledgerId
1259
+ ledger {
1260
+ id
1261
+ }
1260
1262
  status
1261
1263
  amount
1262
1264
  type
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Schema,
3
3
  parseWithError
4
- } from "./chunk-R2HKKBEG.js";
4
+ } from "./chunk-UCIW25RZ.js";
5
5
  import {
6
6
  formatValidationErrors
7
- } from "./chunk-J6HLIC77.js";
7
+ } from "./chunk-5AT6KBWC.js";
8
8
  import {
9
9
  BadRequestError
10
- } from "./chunk-65EVYD2Y.js";
10
+ } from "./chunk-ICUOG2GK.js";
11
11
  import {
12
12
  init_cjs_shims
13
13
  } from "./chunk-7GH3YGSC.js";
@@ -7089,7 +7089,8 @@ var codes = {
7089
7089
  request_body_mismatch: "ik_request_body_mismatch",
7090
7090
  concurrent_reverse_ledger_entry_request: "ik_concurrent_reverse_ledger_entry_request",
7091
7091
  repost_not_enabled: "ik_repost_not_enabled",
7092
- duplicate_ik_in_batch: "ik_duplicate_ik_in_batch"
7092
+ duplicate_ik_in_batch: "ik_duplicate_ik_in_batch",
7093
+ reserved_prefix: "ik_reserved_prefix"
7093
7094
  },
7094
7095
  ledger: {
7095
7096
  not_found: "ledger_not_found",
@@ -2,19 +2,20 @@ import {
2
2
  generateQueriesFileContent,
3
3
  generateQueryFiles,
4
4
  schemaToEntryDefinitions,
5
+ schemaToPaymentDefinitions,
5
6
  validateOutputName
6
- } from "./chunk-KNG7UK5V.js";
7
+ } from "./chunk-ZNVKQ3OF.js";
7
8
  import {
8
9
  Schema,
9
10
  parseWithError
10
- } from "./chunk-R2HKKBEG.js";
11
+ } from "./chunk-UCIW25RZ.js";
11
12
  import {
12
13
  formatValidationErrors,
13
14
  logValidationErrors
14
- } from "./chunk-J6HLIC77.js";
15
+ } from "./chunk-5AT6KBWC.js";
15
16
  import {
16
17
  BadRequestError
17
- } from "./chunk-65EVYD2Y.js";
18
+ } from "./chunk-ICUOG2GK.js";
18
19
  import {
19
20
  FragmentCommand,
20
21
  require_lib
@@ -41,7 +42,7 @@ var GenGraphQL = class _GenGraphQL extends FragmentCommand {
41
42
  this.summary = "Generate GraphQL queries from your Schema for your SDK.";
42
43
  }
43
44
  static {
44
- this.description = `This command generates a GraphQL query for each entry type in your ledger Schema.
45
+ this.description = `This command generates a GraphQL query for each Ledger Entry type and each Payment type in your ledger Schema.
45
46
  Use this command with Fragment SDKs to create type-safe code to update your ledger.`;
46
47
  }
47
48
  static {
@@ -137,8 +138,12 @@ ${import_chalk.default.gray("Schema file:")} ${path}`);
137
138
  schema: validatedSchema,
138
139
  includeRuntimeArgs: flags["include-runtime-args"]
139
140
  });
141
+ const paymentDefinitions = schemaToPaymentDefinitions({
142
+ schema: validatedSchema
143
+ });
140
144
  const generateQueryParams = {
141
145
  definitions: entryDefinitions,
146
+ paymentDefinitions,
142
147
  includeStandardQueries: flags["include-standard-queries"]
143
148
  };
144
149
  if (flags["output-file-per-query"]) {
@@ -27,10 +27,10 @@ import {
27
27
  } from "./chunk-PISSWWTD.js";
28
28
  import {
29
29
  VerifySchema
30
- } from "./chunk-JD2S54X7.js";
30
+ } from "./chunk-3OQW5JVJ.js";
31
31
  import {
32
32
  GenGraphQL
33
- } from "./chunk-BQZQLWCT.js";
33
+ } from "./chunk-OP7PCXSO.js";
34
34
  import {
35
35
  GetSchema
36
36
  } from "./chunk-T2BBIXGB.js";
@@ -1,17 +1,31 @@
1
1
  import {
2
+ AccountConsistencyConfigSchema,
3
+ BaseChartOfAccounts,
4
+ ConsistencyConfigSchema,
5
+ PaymentEventKey,
6
+ PaymentEventKeySchema,
7
+ PaymentTypeDirection,
8
+ PaymentTypeDirectionSchema,
9
+ PostLinesAsSchema,
10
+ SYSTEM_LINE_AMOUNT,
11
+ SYSTEM_PARAMETER_NAMES,
12
+ SchemaEntryGroup,
13
+ SchemaLedgerEntityStatusSchema,
14
+ SchemaPaymentTypeStatusSchema,
15
+ SchemaTxMatchInput,
16
+ SystemLineKind,
17
+ SystemLineKindSchema,
2
18
  fillParams,
3
19
  getInstanceValueByAccountPath,
4
20
  getSchemaObjectParameters,
5
21
  getStructuralPath,
6
22
  getStructuralSubpaths,
7
23
  getSubpaths
8
- } from "./chunk-NE5UNTYB.js";
24
+ } from "./chunk-VIWPVUO5.js";
9
25
  import {
10
26
  BadRequestError,
11
27
  CurrencyMatchInputSchema,
12
- CurrencyModeSchema,
13
28
  InternalError,
14
- LedgerAccountTypeSchema,
15
29
  MAX_FREEFORM_TEXT_LENGTH,
16
30
  ParameterizedAmount,
17
31
  ParameterizedString,
@@ -23,7 +37,7 @@ import {
23
37
  mapValues_default,
24
38
  safe,
25
39
  z
26
- } from "./chunk-65EVYD2Y.js";
40
+ } from "./chunk-ICUOG2GK.js";
27
41
  import {
28
42
  __commonJS,
29
43
  __toESM,
@@ -4466,297 +4480,6 @@ var safeGetZodErrors = (schema, value, pathPrefix) => {
4466
4480
  // ../../libs/schema-validation/types.ts
4467
4481
  init_cjs_shims();
4468
4482
 
4469
- // ../../libs/types/schemas.ts
4470
- init_cjs_shims();
4471
-
4472
- // ../../libs/types/tx.ts
4473
- init_cjs_shims();
4474
- var SchemaTxMatchInput = z.object({
4475
- id: z.optional(ParameterizedString),
4476
- externalId: z.optional(ParameterizedString)
4477
- });
4478
- var txTypes = ["credit", "debit"];
4479
- var TxTypeSchema = z.enum(txTypes);
4480
-
4481
- // ../../libs/types/schemas.ts
4482
- var LedgerMigrationStatusSchema = z.enum([
4483
- "queued",
4484
- "started",
4485
- "failed",
4486
- "completed",
4487
- "skipped"
4488
- ]);
4489
- var SafeRecordKey = z.string().refine((v2) => v2 !== "__proto__", "invalid parameter name");
4490
- var ParametersSchema = z.record(
4491
- SafeRecordKey,
4492
- z.string({
4493
- invalid_type_error: "Invalid parameter type. All parameters must be string-encoded values."
4494
- })
4495
- );
4496
- var EntryParametersSchema = z.record(
4497
- SafeRecordKey,
4498
- z.union([
4499
- z.string({
4500
- invalid_type_error: "Invalid parameter type. Parameters must be string-encoded values or arrays of objects with string values."
4501
- }),
4502
- z.array(z.record(SafeRecordKey, z.string()))
4503
- ])
4504
- );
4505
- var ConsistencyModeSchema = z.enum(["strong", "eventual"]);
4506
- var ConsistencyConfigSchema = (keys, extra) => {
4507
- const v2 = z.optional(ConsistencyModeSchema);
4508
- const schemaObject = Object.fromEntries(
4509
- keys.map((key) => [key, v2])
4510
- );
4511
- return z.object({ ...extra, ...schemaObject });
4512
- };
4513
- var GroupConsistencyConfig = z.object({
4514
- key: SafeStringSchema,
4515
- ownBalanceUpdates: ConsistencyModeSchema
4516
- });
4517
- var AccountConsistencyConfigSchema = z.object({
4518
- lines: z.optional(ConsistencyModeSchema),
4519
- ownBalanceUpdates: z.optional(ConsistencyModeSchema),
4520
- totalBalanceUpdates: z.optional(ConsistencyModeSchema),
4521
- groups: z.optional(z.array(GroupConsistencyConfig))
4522
- });
4523
- var SchemaCurrencyMatchInput = z.object({
4524
- customCurrencyId: z.string().optional(),
4525
- code: z.string()
4526
- });
4527
- var SchemaLinkTypeList = [
4528
- "IncreaseLink",
4529
- "UnitLink",
4530
- "CustomLink",
4531
- "StripeLink"
4532
- ];
4533
- var SchemaLinkType = z.enum(SchemaLinkTypeList);
4534
- var SchemaExternalAccountMatchInput = z.object({
4535
- linkType: SchemaLinkType.optional(),
4536
- id: z.string().optional(),
4537
- externalId: z.string().optional(),
4538
- linkId: z.string().optional()
4539
- });
4540
- var SchemaPaymentInput = z.object({
4541
- enabled: z.boolean()
4542
- });
4543
- var SchemaLedgerEntityStatusSchema = z.enum([
4544
- "active",
4545
- "disabled",
4546
- "archived"
4547
- ]);
4548
- var BaseSchemaLedgerAccountInput = z.lazy(
4549
- () => z.object({
4550
- key: z.string(),
4551
- name: z.string().optional(),
4552
- type: LedgerAccountTypeSchema.optional(),
4553
- currency: SchemaCurrencyMatchInput.optional(),
4554
- currencyMode: CurrencyModeSchema.optional(),
4555
- template: z.boolean().optional(),
4556
- clearing: z.boolean().optional(),
4557
- children: z.array(BaseSchemaLedgerAccountInput).optional(),
4558
- linkedAccount: SchemaExternalAccountMatchInput.optional(),
4559
- payment: SchemaPaymentInput.optional(),
4560
- consistencyConfig: AccountConsistencyConfigSchema.optional(),
4561
- status: SchemaLedgerEntityStatusSchema.optional()
4562
- })
4563
- );
4564
- var BaseChartOfAccounts = z.object({
4565
- defaultConsistencyConfig: AccountConsistencyConfigSchema.optional(),
4566
- defaultCurrency: z.optional(CurrencyMatchInputSchema),
4567
- defaultCurrencyMode: CurrencyModeSchema.optional(),
4568
- accounts: z.array(BaseSchemaLedgerAccountInput)
4569
- });
4570
- var SchemaCondition = z.object({
4571
- ownBalance: z.object({
4572
- eq: z.string().optional(),
4573
- lte: z.string().optional(),
4574
- gte: z.string().optional()
4575
- }).optional(),
4576
- totalBalance: z.object({
4577
- eq: z.string().optional(),
4578
- lte: z.string().optional(),
4579
- gte: z.string().optional()
4580
- }).optional()
4581
- });
4582
- var PostLinesAsSchema = z.enum([
4583
- "raw_lines",
4584
- "net_amounts",
4585
- "skip_zero_lines"
4586
- ]);
4587
- var BaseSchemaLedgerEntryConditionInput = z.object({
4588
- account: z.object({ path: z.string() }).optional(),
4589
- postcondition: SchemaCondition.optional(),
4590
- precondition: SchemaCondition.optional(),
4591
- currency: SchemaCurrencyMatchInput.optional(),
4592
- repeated: z.object({
4593
- key: SafeStringSchema.refine((k2) => k2.trim().length >= 1, {
4594
- message: "repeated.key cannot be empty"
4595
- })
4596
- }).optional()
4597
- });
4598
- var BaseSchemaLedgerLineTagInput = z.object({
4599
- key: z.string(),
4600
- value: z.string()
4601
- });
4602
- var BaseSchemaLedgerEntryLineInput = z.object({
4603
- account: z.object({ path: z.string() }).optional(),
4604
- amount: z.string().optional(),
4605
- key: z.string(),
4606
- currency: SchemaCurrencyMatchInput.optional(),
4607
- description: z.string().optional(),
4608
- tx: SchemaTxMatchInput.optional(),
4609
- tags: z.array(BaseSchemaLedgerLineTagInput).optional(),
4610
- repeated: z.object({
4611
- key: SafeStringSchema.refine((k2) => k2.trim().length >= 1, {
4612
- message: "repeated.key cannot be empty"
4613
- })
4614
- }).optional()
4615
- });
4616
- var BaseSchemaLedgerEntryInput = z.object({
4617
- type: z.string(),
4618
- typeVersion: z.number().int().optional(),
4619
- description: z.string().optional(),
4620
- conditions: z.array(BaseSchemaLedgerEntryConditionInput).optional(),
4621
- lines: z.array(BaseSchemaLedgerEntryLineInput).optional(),
4622
- parameters: z.record(SafeRecordKey, z.string()).optional(),
4623
- tags: z.array(
4624
- z.object({
4625
- key: z.string(),
4626
- value: z.string()
4627
- })
4628
- ).optional(),
4629
- groups: z.array(
4630
- z.object({
4631
- key: SafeStringSchema,
4632
- value: z.string()
4633
- })
4634
- ).optional(),
4635
- status: SchemaLedgerEntityStatusSchema.optional(),
4636
- postLinesAs: PostLinesAsSchema.optional()
4637
- });
4638
- var BaseLedgerEntries = z.object({
4639
- types: z.array(BaseSchemaLedgerEntryInput)
4640
- });
4641
- var PaymentEventKey = {
4642
- /** Exit from the payer not yet having supplied a payment method at checkout. */
4643
- needs_payment_method_to_processing: "needs_payment_method_to_processing",
4644
- processing_to_settled: "processing_to_settled"
4645
- };
4646
- var PaymentEventKeySchema = z.nativeEnum(PaymentEventKey);
4647
- var PaymentTypeDirection = {
4648
- payin: "payin",
4649
- payout: "payout"
4650
- };
4651
- var PaymentTypeDirectionSchema = z.nativeEnum(PaymentTypeDirection);
4652
- var SystemLineKind = {
4653
- payment_settlement_line: "payment_settlement_line",
4654
- payment_fee_line: "payment_fee_line"
4655
- };
4656
- var SystemLineKindSchema = z.nativeEnum(SystemLineKind);
4657
- var SystemLineParameterName = {
4658
- payment_settlement_line: "settled_amount",
4659
- payment_fee_line: "fragment_fee_amount"
4660
- };
4661
- var SYSTEM_LINE_AMOUNT = {
4662
- [SystemLineKind.payment_settlement_line]: `{{${SystemLineParameterName.payment_settlement_line}}}`,
4663
- [SystemLineKind.payment_fee_line]: `-{{${SystemLineParameterName.payment_fee_line}}}`
4664
- };
4665
- var SYSTEM_PARAMETER_NAMES = new Set(
4666
- Object.values(SystemLineParameterName)
4667
- );
4668
- var BaseSchemaPaymentInput = z.object({
4669
- amount: z.string(),
4670
- direction: PaymentTypeDirectionSchema
4671
- });
4672
- var BaseSchemaPaymentEntryLineInput = BaseSchemaLedgerEntryLineInput.pick({
4673
- key: true,
4674
- currency: true,
4675
- description: true
4676
- }).extend({
4677
- account: z.object({ path: z.string() }),
4678
- amount: z.string(),
4679
- system: SystemLineKindSchema.optional()
4680
- });
4681
- var BaseSchemaPaymentEntryInput = z.object({
4682
- description: z.string().optional(),
4683
- lines: z.array(BaseSchemaPaymentEntryLineInput)
4684
- });
4685
- var SchemaPaymentTypeStatusSchema = z.enum(["active"]);
4686
- var BaseSchemaPaymentTypeInput = z.object({
4687
- type: z.string(),
4688
- typeVersion: z.number().int(),
4689
- status: SchemaPaymentTypeStatusSchema,
4690
- payment: BaseSchemaPaymentInput,
4691
- accounting: z.object({
4692
- needs_payment_method_to_processing: BaseSchemaPaymentEntryInput.optional(),
4693
- processing_to_settled: BaseSchemaPaymentEntryInput
4694
- })
4695
- });
4696
- var BaseSchemaPayments = z.object({
4697
- types: z.array(BaseSchemaPaymentTypeInput)
4698
- });
4699
- var SceneEntrySchema = z.object({
4700
- type: z.string(),
4701
- typeVersion: z.number().int().positive().optional(),
4702
- parameters: z.record(SafeRecordKey, z.string())
4703
- });
4704
- var ScenePaymentSchema = z.object({
4705
- ik: z.string(),
4706
- type: z.string(),
4707
- typeVersion: z.number().int().positive().optional(),
4708
- parameters: z.record(SafeRecordKey, z.string())
4709
- });
4710
- var SceneLedgerEventSchema = z.object({
4711
- eventType: z.literal("entry"),
4712
- entry: SceneEntrySchema
4713
- });
4714
- var ScenePaymentEventSchema = z.object({
4715
- eventType: z.literal("payment"),
4716
- payment: z.object({
4717
- ik: z.string(),
4718
- event: PaymentEventKeySchema
4719
- })
4720
- });
4721
- var SceneEventSchema = z.discriminatedUnion("eventType", [
4722
- SceneLedgerEventSchema,
4723
- ScenePaymentEventSchema
4724
- ]);
4725
- var BaseScene = z.object({
4726
- name: z.string(),
4727
- events: z.array(SceneEventSchema),
4728
- payments: z.array(ScenePaymentSchema).optional()
4729
- });
4730
- var EntryKey = z.object({
4731
- type: SafeStringSchema,
4732
- typeVersion: z.number().int().positive()
4733
- });
4734
- var SchemaLedgerAccountMatchInput = z.object({
4735
- path: ParameterizedString
4736
- });
4737
- var GroupReconciliationParameters = z.object({
4738
- clearingAccountPath: SchemaLedgerAccountMatchInput
4739
- });
4740
- var SchemaEntryGroup = z.object({
4741
- key: SafeStringSchema,
4742
- description: z.string().optional(),
4743
- reconciliation: GroupReconciliationParameters.optional()
4744
- });
4745
- var BaseSchema = z.object({
4746
- name: z.string().optional(),
4747
- key: z.string(),
4748
- chartOfAccounts: BaseChartOfAccounts,
4749
- ledgerEntries: BaseLedgerEntries.optional(),
4750
- payments: BaseSchemaPayments.optional(),
4751
- groups: z.array(SchemaEntryGroup).optional(),
4752
- scenes: z.array(BaseScene).optional(),
4753
- consistencyConfig: z.optional(
4754
- z.object({
4755
- entries: ConsistencyModeSchema.optional()
4756
- })
4757
- )
4758
- });
4759
-
4760
4483
  // ../../libs/schema-validation/utils/transformers/coa.ts
4761
4484
  init_cjs_shims();
4762
4485
 
@@ -4874,7 +4597,7 @@ var validateDefaultCurrencySettings = ({
4874
4597
  message: `Default currency customCurrencyId cannot be parameterized`,
4875
4598
  path: ["defaultCurrency", "customCurrencyId"]
4876
4599
  });
4877
- } else if (!SchemaCurrencyMatchInput2.safeParse(defaultCurrency).success) {
4600
+ } else if (!SchemaCurrencyMatchInput.safeParse(defaultCurrency).success) {
4878
4601
  if (defaultCurrency.code === "CUSTOM" && !defaultCurrency.customCurrencyId) {
4879
4602
  errors.push({
4880
4603
  message: `Must provide custom currency ID for custom currency`,
@@ -5195,7 +4918,7 @@ var validateAccountCurrency = ({
5195
4918
  path: [...path, "currency"]
5196
4919
  });
5197
4920
  }
5198
- if (currency && !SchemaCurrencyMatchInput2.safeParse(currency).success) {
4921
+ if (currency && !SchemaCurrencyMatchInput.safeParse(currency).success) {
5199
4922
  if (currency.code === "CUSTOM" && !currency.customCurrencyId) {
5200
4923
  errors.push({
5201
4924
  message: `Must provide custom currency ID for custom currency (key: ${key}, name: ${name})`,
@@ -6508,7 +6231,7 @@ var validateLineCurrency = (currency, accountPath, accountPathToAccount, entryPa
6508
6231
  path: ["currency"]
6509
6232
  });
6510
6233
  }
6511
- if (currency && !SchemaCurrencyMatchInput2.safeParse(currency).success) {
6234
+ if (currency && !SchemaCurrencyMatchInput.safeParse(currency).success) {
6512
6235
  if (currency.code === "CUSTOM" && !currency.customCurrencyId) {
6513
6236
  validationResults.push({
6514
6237
  message: `Line must provide custom currency ID for custom currency (Line key: ${lineKey}, entry: ${entryType})`,
@@ -7872,7 +7595,7 @@ var transformAndValidatePayments = ({
7872
7595
  };
7873
7596
 
7874
7597
  // ../../libs/schema-validation/types.ts
7875
- var SchemaCurrencyMatchInput2 = z.object({
7598
+ var SchemaCurrencyMatchInput = z.object({
7876
7599
  customCurrencyId: ParameterizedString.optional(),
7877
7600
  code: ParameterizedString.refine(
7878
7601
  (str) => {
@@ -7953,7 +7676,7 @@ var SchemaLedgerLineInput = z.object({
7953
7676
  }),
7954
7677
  amount: ParameterizedAmount().optional(),
7955
7678
  key: SafeStringSchema,
7956
- currency: z.optional(SchemaCurrencyMatchInput2),
7679
+ currency: z.optional(SchemaCurrencyMatchInput),
7957
7680
  description: ParameterizedString.optional(),
7958
7681
  tx: SchemaTxMatchInput.optional(),
7959
7682
  tags: z.array(SchemaLedgerLineTagInput).optional(),
@@ -8042,7 +7765,7 @@ var SchemaLedgerEntryConditionInput = z.object({
8042
7765
  }),
8043
7766
  postcondition: SchemaConditionInput.optional(),
8044
7767
  precondition: SchemaConditionInput.optional(),
8045
- currency: SchemaCurrencyMatchInput2.optional(),
7768
+ currency: SchemaCurrencyMatchInput.optional(),
8046
7769
  repeated: z.object({
8047
7770
  key: SafeStringSchema.refine((k2) => k2.trim().length >= 1, {
8048
7771
  message: "repeated.key cannot be empty"