@fragment-dev/cli 2026.9.10-13 → 2026.9.10-3

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 Ledger Entry type and each Payment type in your ledger Schema.
293
+ This command generates a GraphQL query for each entry 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
@@ -1256,9 +1256,7 @@ mutation CreatePayment(
1256
1256
  payment {
1257
1257
  clientSecret
1258
1258
  ik
1259
- ledger {
1260
- id
1261
- }
1259
+ ledgerId
1262
1260
  status
1263
1261
  amount
1264
1262
  type
@@ -27,10 +27,10 @@ import {
27
27
  } from "./chunk-PISSWWTD.js";
28
28
  import {
29
29
  VerifySchema
30
- } from "./chunk-NLJM26T4.js";
30
+ } from "./chunk-JD2S54X7.js";
31
31
  import {
32
32
  GenGraphQL
33
- } from "./chunk-OAO4AP7N.js";
33
+ } from "./chunk-BQZQLWCT.js";
34
34
  import {
35
35
  GetSchema
36
36
  } from "./chunk-T2BBIXGB.js";
@@ -7089,8 +7089,7 @@ 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",
7093
- reserved_prefix: "ik_reserved_prefix"
7092
+ duplicate_ik_in_batch: "ik_duplicate_ik_in_batch"
7094
7093
  },
7095
7094
  ledger: {
7096
7095
  not_found: "ledger_not_found",
@@ -7120,8 +7119,7 @@ var codes = {
7120
7119
  missing_parameters: "payment_missing_parameters",
7121
7120
  unknown_parameters: "payment_unknown_parameters",
7122
7121
  reserved_parameters: "payment_reserved_parameters",
7123
- invalid_request: "payment_invalid_request",
7124
- confirmation_rejected: "payment_confirmation_rejected"
7122
+ invalid_request: "payment_invalid_request"
7125
7123
  },
7126
7124
  payment_account: {
7127
7125
  direct_posting_disallowed: `payment_account_direct_posting_disallowed`,
@@ -2,20 +2,19 @@ import {
2
2
  generateQueriesFileContent,
3
3
  generateQueryFiles,
4
4
  schemaToEntryDefinitions,
5
- schemaToPaymentDefinitions,
6
5
  validateOutputName
7
- } from "./chunk-FYVAWYYH.js";
6
+ } from "./chunk-KNG7UK5V.js";
8
7
  import {
9
8
  Schema,
10
9
  parseWithError
11
- } from "./chunk-LEJQJ3T3.js";
10
+ } from "./chunk-R2HKKBEG.js";
12
11
  import {
13
12
  formatValidationErrors,
14
13
  logValidationErrors
15
- } from "./chunk-KDXCKOCB.js";
14
+ } from "./chunk-J6HLIC77.js";
16
15
  import {
17
16
  BadRequestError
18
- } from "./chunk-N2R7NRAP.js";
17
+ } from "./chunk-65EVYD2Y.js";
19
18
  import {
20
19
  FragmentCommand,
21
20
  require_lib
@@ -42,7 +41,7 @@ var GenGraphQL = class _GenGraphQL extends FragmentCommand {
42
41
  this.summary = "Generate GraphQL queries from your Schema for your SDK.";
43
42
  }
44
43
  static {
45
- this.description = `This command generates a GraphQL query for each Ledger Entry type and each Payment type in your ledger Schema.
44
+ this.description = `This command generates a GraphQL query for each entry type in your ledger Schema.
46
45
  Use this command with Fragment SDKs to create type-safe code to update your ledger.`;
47
46
  }
48
47
  static {
@@ -138,12 +137,8 @@ ${import_chalk.default.gray("Schema file:")} ${path}`);
138
137
  schema: validatedSchema,
139
138
  includeRuntimeArgs: flags["include-runtime-args"]
140
139
  });
141
- const paymentDefinitions = schemaToPaymentDefinitions({
142
- schema: validatedSchema
143
- });
144
140
  const generateQueryParams = {
145
141
  definitions: entryDefinitions,
146
- paymentDefinitions,
147
142
  includeStandardQueries: flags["include-standard-queries"]
148
143
  };
149
144
  if (flags["output-file-per-query"]) {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Schema,
3
3
  parseWithError
4
- } from "./chunk-LEJQJ3T3.js";
4
+ } from "./chunk-R2HKKBEG.js";
5
5
  import {
6
6
  formatValidationErrors
7
- } from "./chunk-KDXCKOCB.js";
7
+ } from "./chunk-J6HLIC77.js";
8
8
  import {
9
9
  BadRequestError
10
- } from "./chunk-N2R7NRAP.js";
10
+ } from "./chunk-65EVYD2Y.js";
11
11
  import {
12
12
  init_cjs_shims
13
13
  } from "./chunk-7GH3YGSC.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BadRequestError
3
- } from "./chunk-N2R7NRAP.js";
3
+ } from "./chunk-65EVYD2Y.js";
4
4
  import {
5
5
  require_source
6
6
  } from "./chunk-XK2D2Z44.js";
@@ -2,13 +2,13 @@ import {
2
2
  extractSchemaMetadata,
3
3
  isJsonParseError,
4
4
  validateSchemaStructure
5
- } from "./chunk-IMRC5SWK.js";
5
+ } from "./chunk-DJCFTORW.js";
6
6
  import {
7
7
  DEFAULT_SCHEMA_PATH
8
8
  } from "./chunk-A4BSWX5D.js";
9
9
  import {
10
10
  logValidationErrors
11
- } from "./chunk-KDXCKOCB.js";
11
+ } from "./chunk-J6HLIC77.js";
12
12
  import {
13
13
  FragmentCommand,
14
14
  require_lib
@@ -1,14 +1,13 @@
1
1
  import {
2
2
  standardQueries
3
- } from "./chunk-7GWSUHUD.js";
3
+ } from "./chunk-4VYFUMLV.js";
4
4
  import {
5
5
  InvalidGraphQlError
6
6
  } from "./chunk-ZMFGVGZP.js";
7
7
  import {
8
- SYSTEM_PARAMETER_NAMES,
9
8
  getSchemaObjectParameters,
10
9
  getStructuralSubpaths
11
- } from "./chunk-MHYCVJGZ.js";
10
+ } from "./chunk-NE5UNTYB.js";
12
11
  import {
13
12
  require_source
14
13
  } from "./chunk-XK2D2Z44.js";
@@ -27,16 +26,6 @@ var import_chalk = __toESM(require_source(), 1);
27
26
  var import_parser = __toESM(require_parser(), 1);
28
27
  var import_printer = __toESM(require_printer(), 1);
29
28
  import { statSync, existsSync } from "node:fs";
30
-
31
- // ../../libs/schema-validation/utils/paymentTypes.ts
32
- init_cjs_shims();
33
- var getRequiredPaymentParameters = (paymentType) => new Set(
34
- getSchemaObjectParameters(paymentType, true).filter(
35
- (name) => !SYSTEM_PARAMETER_NAMES.has(name)
36
- )
37
- );
38
-
39
- // src/graphql.ts
40
29
  var getAccountParams = (accountPath, schema) => {
41
30
  const subpaths = getStructuralSubpaths(accountPath);
42
31
  return subpaths.flatMap(
@@ -117,16 +106,6 @@ var schemaToEntryDefinitions = ({
117
106
  ];
118
107
  });
119
108
  };
120
- var schemaToPaymentDefinitions = ({
121
- schema
122
- }) => (schema.payments?.types ?? []).map((paymentType) => ({
123
- paymentType: paymentType.type,
124
- typeVersion: paymentType.typeVersion,
125
- direction: paymentType.payment.direction,
126
- // The same helper `createPayment` validates against, so the generated
127
- // variables are exactly the parameters the API accepts.
128
- parameters: Array.from(getRequiredPaymentParameters(paymentType))
129
- }));
130
109
  var camelCase = (value, delimiter) => {
131
110
  return value.split(delimiter).filter((x) => !!x).map((word, index) => {
132
111
  if (index === 0) {
@@ -209,80 +188,25 @@ __typename
209
188
  }
210
189
  ${OnErrorFragment}
211
190
  `;
212
- var PaymentFragment = `
213
- ik
214
- ledger {
215
- id
216
- ik
217
- }
218
- type
219
- typeVersion
220
- status
221
- amount
222
- mode
223
- clientSecret
224
- created
225
- `;
226
- var CreatePaymentFragment = `
227
- __typename
228
- ... on CreatePaymentResult {
229
- payment {
230
- ${PaymentFragment}
231
- }
232
- }
233
- ${OnErrorFragment}
234
- `;
235
191
  var isValidGraphQlName = (name) => {
236
192
  return /^[a-zA-Z_]+[a-zA-Z0-9_]*$/.exec(name) !== null;
237
193
  };
238
- var toPascalCaseGraphQlName = (value) => camelCase(camelCase(value, "_"), "-").split("").map((ch, idx) => {
239
- if (idx === 0) {
240
- return ch.toUpperCase();
241
- }
242
- return ch;
243
- }).join("").replace(/\s+/g, "_").replace(/\./g, "_").replace(/[^a-zA-Z0-9_]/g, "").replace(/^(\d)/, "_$1");
244
- var versionSuffix = (typeVersion) => typeof typeVersion === "number" && typeVersion > 1 ? `_v${typeVersion}` : "";
245
- var OperationSubject = {
246
- entry: "entry",
247
- paymentType: "payment type"
248
- };
249
- var assertValidOperationName = ({
250
- name,
251
- subject,
252
- sourceType
253
- }) => {
254
- if (!isValidGraphQlName(name)) {
194
+ var generateGraphQlEntryType = (entryType, typeVersion) => {
195
+ const readableEntryType = camelCase(camelCase(entryType, "_"), "-").split("").map((ch, idx) => {
196
+ if (idx === 0) {
197
+ return ch.toUpperCase();
198
+ }
199
+ return ch;
200
+ }).join("").replace(/\s+/g, "_").replace(/\./g, "_").replace(/[^a-zA-Z0-9_]/g, "").replace(/^(\d)/, "_$1").concat(typeVersion && typeVersion > 1 ? `_v${typeVersion}` : "");
201
+ if (!isValidGraphQlName(readableEntryType)) {
255
202
  throw new InvalidGraphQlError(
256
- `Operation name ${name} (for ${subject}: ${import_chalk.default.yellow(
257
- sourceType
203
+ `Operation name ${readableEntryType} (for entry: ${import_chalk.default.yellow(
204
+ entryType
258
205
  )}) is not a valid GraphQL name`
259
206
  );
260
207
  }
261
- };
262
- var generateGraphQlEntryType = (entryType, typeVersion) => {
263
- const readableEntryType = toPascalCaseGraphQlName(entryType).concat(
264
- versionSuffix(typeVersion)
265
- );
266
- assertValidOperationName({
267
- name: readableEntryType,
268
- subject: OperationSubject.entry,
269
- sourceType: entryType
270
- });
271
208
  return readableEntryType;
272
209
  };
273
- var generateGraphQlPaymentType = ({
274
- paymentType,
275
- direction,
276
- typeVersion
277
- }) => {
278
- const readablePaymentType = toPascalCaseGraphQlName(paymentType).concat(toPascalCaseGraphQlName(direction)).concat(versionSuffix(typeVersion));
279
- assertValidOperationName({
280
- name: readablePaymentType,
281
- subject: OperationSubject.paymentType,
282
- sourceType: paymentType
283
- });
284
- return readablePaymentType;
285
- };
286
210
  var getPredefinedParameters = (definition) => {
287
211
  const params = {};
288
212
  if (definition.method === "addLedgerEntry") {
@@ -382,64 +306,13 @@ var entryDefinitionToMutation = (definition) => {
382
306
  operationName
383
307
  };
384
308
  };
385
- var paymentPredefinedParameters = {
386
- ik: "SafeString!",
387
- ledgerIk: "SafeString!"
388
- };
389
- var paymentDefinitionToMutation = (definition) => {
390
- const { paymentType, typeVersion, direction, parameters } = definition;
391
- parameters.forEach((param) => {
392
- if (!isValidGraphQlName(param)) {
393
- throw new InvalidGraphQlError(
394
- `Parameter name ${param} is not a valid GraphQL name`
395
- );
396
- }
397
- });
398
- const operationName = `CreatePayment${generateGraphQlPaymentType({
399
- paymentType,
400
- direction,
401
- typeVersion
402
- })}`;
403
- const varArgs = [
404
- ...Object.entries(paymentPredefinedParameters).map(
405
- ([name, type]) => `$${name}: ${type}`
406
- ),
407
- ...parameters.filter(
408
- (p) => !Object.prototype.hasOwnProperty.call(paymentPredefinedParameters, p)
409
- ).map((p) => `$${p}: String!`)
410
- ].join(",\n");
411
- const command = [
412
- `mutation ${operationName} (`,
413
- `${varArgs}) {`,
414
- `createPayment(`,
415
- `ik: $ik,`,
416
- `ledger: { ik: $ledgerIk },`,
417
- `payment: {`,
418
- `type: "${paymentType}",`,
419
- `typeVersion: ${typeVersion},`
420
- ];
421
- if (parameters.length > 0) {
422
- command.push(`parameters: {`);
423
- command.push(parameters.map((p) => `${p}: $${p}`).join("\n"));
424
- command.push(`}`);
425
- }
426
- command.push(`}) { ${CreatePaymentFragment} } }`);
427
- return {
428
- mutation: (0, import_printer.print)((0, import_parser.parse)(command.join(""))),
429
- operationName
430
- };
431
- };
432
309
  var generateQueriesFileContent = ({
433
310
  definitions,
434
- paymentDefinitions,
435
311
  includeStandardQueries
436
312
  }) => {
437
- const generatedCode = [
438
- ...definitions.map((def) => entryDefinitionToMutation(def).mutation),
439
- ...paymentDefinitions.map(
440
- (def) => paymentDefinitionToMutation(def).mutation
441
- )
442
- ];
313
+ const generatedCode = definitions.map(
314
+ (def) => entryDefinitionToMutation(def).mutation
315
+ );
443
316
  if (includeStandardQueries) {
444
317
  generatedCode.push(standardQueries);
445
318
  }
@@ -448,17 +321,16 @@ var generateQueriesFileContent = ({
448
321
  };
449
322
  var generateQueryFiles = ({
450
323
  definitions,
451
- paymentDefinitions,
452
324
  includeStandardQueries
453
325
  }) => {
454
- const generatedCode = [
455
- ...definitions.map((def) => entryDefinitionToMutation(def)),
456
- ...paymentDefinitions.map((def) => paymentDefinitionToMutation(def))
457
- ].map(({ operationName, mutation }) => ({
458
- content: `${mutation}
326
+ const generatedCode = definitions.map((def) => {
327
+ const { operationName, mutation } = entryDefinitionToMutation(def);
328
+ return {
329
+ content: `${mutation}
459
330
  `,
460
- fileName: `${operationName}.graphql`
461
- }));
331
+ fileName: `${operationName}.graphql`
332
+ };
333
+ });
462
334
  if (includeStandardQueries) {
463
335
  const parsedStdQueries = (0, import_parser.parse)(standardQueries);
464
336
  parsedStdQueries.definitions.forEach((def) => {
@@ -494,14 +366,11 @@ var validateOutputName = ({
494
366
 
495
367
  export {
496
368
  schemaToEntryDefinitions,
497
- schemaToPaymentDefinitions,
498
369
  camelCase,
499
370
  isValidGraphQlName,
500
371
  generateGraphQlEntryType,
501
- generateGraphQlPaymentType,
502
372
  getPredefinedParameters,
503
373
  entryDefinitionToMutation,
504
- paymentDefinitionToMutation,
505
374
  generateQueriesFileContent,
506
375
  generateQueryFiles,
507
376
  validateOutputName
@@ -0,0 +1,113 @@
1
+ import {
2
+ BadRequestError,
3
+ assert_default,
4
+ codes,
5
+ getStringParametersInternal
6
+ } from "./chunk-65EVYD2Y.js";
7
+ import {
8
+ init_cjs_shims
9
+ } from "./chunk-7GH3YGSC.js";
10
+
11
+ // ../../libs/schema-validation/parameterization.ts
12
+ init_cjs_shims();
13
+ var fillParams = (obj, params = {}, options = {
14
+ allowMissing: false,
15
+ allowMissingInChildren: true
16
+ }) => {
17
+ if (typeof obj === "string") {
18
+ const tokens = obj.split(/(\{\{[^{}]+?\}\})/g);
19
+ const missingParams = /* @__PURE__ */ new Set();
20
+ const result = tokens.map((token) => {
21
+ const match = token.match(/\{\{([^{}]+?)\}\}/);
22
+ if (match) {
23
+ const param = match[1];
24
+ const paramValue = params[param];
25
+ if (paramValue === void 0 || paramValue === null) {
26
+ missingParams.add(param);
27
+ return token;
28
+ }
29
+ return paramValue;
30
+ }
31
+ return token;
32
+ }).join("");
33
+ if (!options.allowMissing) {
34
+ assert_default(!missingParams.size, BadRequestError, {
35
+ message: `Failed to fill all parameters: ${obj} -> ${result}`,
36
+ code: codes.parameterization_failed
37
+ });
38
+ }
39
+ return result;
40
+ }
41
+ if (typeof obj === "object" && obj !== null) {
42
+ if (Array.isArray(obj)) {
43
+ return obj.map((value) => fillParams(value, params, options));
44
+ }
45
+ return Object.fromEntries(
46
+ Object.entries(obj).map(([key, value]) => [
47
+ key,
48
+ fillParams(value, params, {
49
+ ...options,
50
+ allowMissing: key === "children" ? options.allowMissingInChildren : options.allowMissing
51
+ })
52
+ ])
53
+ );
54
+ }
55
+ return obj;
56
+ };
57
+ function getSchemaObjectParametersInternal(obj, parameters, includeChildren) {
58
+ if (typeof obj === "string") {
59
+ getStringParametersInternal(obj, parameters);
60
+ } else if (typeof obj === "object") {
61
+ for (const key in obj) {
62
+ if (key !== "templatePath" && (key !== "children" || includeChildren)) {
63
+ getSchemaObjectParametersInternal(
64
+ obj[key],
65
+ parameters,
66
+ includeChildren
67
+ );
68
+ }
69
+ }
70
+ }
71
+ }
72
+ function getSchemaObjectParameters(obj, includeChildren = false) {
73
+ const params = /* @__PURE__ */ new Set();
74
+ getSchemaObjectParametersInternal(obj, params, includeChildren);
75
+ return Array.from(params);
76
+ }
77
+
78
+ // ../../libs/path-utils/path.ts
79
+ init_cjs_shims();
80
+ var getStructuralPath = (path) => {
81
+ return path.split("/").map((part) => part.split(":")[0]).join("/");
82
+ };
83
+ var getInstanceValueByAccountPath = (path) => {
84
+ const parts = path.split("/");
85
+ const result = /* @__PURE__ */ new Map();
86
+ let workingSet = "";
87
+ for (let i = 0; i < parts.length; i++) {
88
+ const part = parts[i];
89
+ const [templateKey, templateValue] = part.split(":");
90
+ workingSet = workingSet ? `${workingSet}/${templateKey}` : templateKey;
91
+ result.set(workingSet, templateValue);
92
+ if (templateValue) {
93
+ workingSet = `${workingSet}:${templateValue}`;
94
+ }
95
+ }
96
+ return result;
97
+ };
98
+ var getSubpaths = (path) => path.split("/").reduce((acc, part) => {
99
+ const prev = acc[acc.length - 1];
100
+ const subPath = prev ? `${prev}/${part}` : part;
101
+ acc.push(subPath);
102
+ return acc;
103
+ }, []);
104
+ var getStructuralSubpaths = (path) => getSubpaths(getStructuralPath(path));
105
+
106
+ export {
107
+ fillParams,
108
+ getSchemaObjectParameters,
109
+ getStructuralPath,
110
+ getInstanceValueByAccountPath,
111
+ getSubpaths,
112
+ getStructuralSubpaths
113
+ };