@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 +1 -1
- package/dist/{chunk-JD2S54X7.js → chunk-3OQW5JVJ.js} +2 -2
- package/dist/{chunk-J6HLIC77.js → chunk-5AT6KBWC.js} +1 -1
- package/dist/{chunk-4VYFUMLV.js → chunk-7GWSUHUD.js} +3 -1
- package/dist/{chunk-DJCFTORW.js → chunk-FZPNPJCH.js} +3 -3
- package/dist/{chunk-65EVYD2Y.js → chunk-ICUOG2GK.js} +2 -1
- package/dist/{chunk-BQZQLWCT.js → chunk-OP7PCXSO.js} +10 -5
- package/dist/{chunk-5PGVOMOW.js → chunk-QBU6M4SD.js} +2 -2
- package/dist/{chunk-R2HKKBEG.js → chunk-UCIW25RZ.js} +24 -301
- package/dist/chunk-VIWPVUO5.js +424 -0
- package/dist/{chunk-KNG7UK5V.js → chunk-ZNVKQ3OF.js} +153 -22
- package/dist/commands/gen-graphql.js +7 -7
- package/dist/commands/verify-schema.js +6 -6
- package/dist/commands.js +10 -10
- package/dist/graphql.js +10 -4
- package/dist/index.js +10 -10
- package/dist/queries/standard-queries.js +1 -1
- package/dist/utils/formatValidationErrors.js +2 -2
- package/dist/utils/schemaValidation.js +5 -5
- package/oclif.manifest.json +2 -2
- package/package.json +3 -3
- package/dist/chunk-NE5UNTYB.js +0 -113
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestError,
|
|
3
|
+
CurrencyMatchInputSchema,
|
|
4
|
+
CurrencyModeSchema,
|
|
5
|
+
LedgerAccountTypeSchema,
|
|
6
|
+
ParameterizedString,
|
|
7
|
+
SafeStringSchema,
|
|
8
|
+
assert_default,
|
|
9
|
+
codes,
|
|
10
|
+
getStringParametersInternal,
|
|
11
|
+
z
|
|
12
|
+
} from "./chunk-ICUOG2GK.js";
|
|
13
|
+
import {
|
|
14
|
+
init_cjs_shims
|
|
15
|
+
} from "./chunk-7GH3YGSC.js";
|
|
16
|
+
|
|
17
|
+
// ../../libs/schema-validation/parameterization.ts
|
|
18
|
+
init_cjs_shims();
|
|
19
|
+
var fillParams = (obj, params = {}, options = {
|
|
20
|
+
allowMissing: false,
|
|
21
|
+
allowMissingInChildren: true
|
|
22
|
+
}) => {
|
|
23
|
+
if (typeof obj === "string") {
|
|
24
|
+
const tokens = obj.split(/(\{\{[^{}]+?\}\})/g);
|
|
25
|
+
const missingParams = /* @__PURE__ */ new Set();
|
|
26
|
+
const result = tokens.map((token) => {
|
|
27
|
+
const match = token.match(/\{\{([^{}]+?)\}\}/);
|
|
28
|
+
if (match) {
|
|
29
|
+
const param = match[1];
|
|
30
|
+
const paramValue = params[param];
|
|
31
|
+
if (paramValue === void 0 || paramValue === null) {
|
|
32
|
+
missingParams.add(param);
|
|
33
|
+
return token;
|
|
34
|
+
}
|
|
35
|
+
return paramValue;
|
|
36
|
+
}
|
|
37
|
+
return token;
|
|
38
|
+
}).join("");
|
|
39
|
+
if (!options.allowMissing) {
|
|
40
|
+
assert_default(!missingParams.size, BadRequestError, {
|
|
41
|
+
message: `Failed to fill all parameters: ${obj} -> ${result}`,
|
|
42
|
+
code: codes.parameterization_failed
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
if (typeof obj === "object" && obj !== null) {
|
|
48
|
+
if (Array.isArray(obj)) {
|
|
49
|
+
return obj.map((value) => fillParams(value, params, options));
|
|
50
|
+
}
|
|
51
|
+
return Object.fromEntries(
|
|
52
|
+
Object.entries(obj).map(([key, value]) => [
|
|
53
|
+
key,
|
|
54
|
+
fillParams(value, params, {
|
|
55
|
+
...options,
|
|
56
|
+
allowMissing: key === "children" ? options.allowMissingInChildren : options.allowMissing
|
|
57
|
+
})
|
|
58
|
+
])
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return obj;
|
|
62
|
+
};
|
|
63
|
+
function getSchemaObjectParametersInternal(obj, parameters, includeChildren) {
|
|
64
|
+
if (typeof obj === "string") {
|
|
65
|
+
getStringParametersInternal(obj, parameters);
|
|
66
|
+
} else if (typeof obj === "object") {
|
|
67
|
+
for (const key in obj) {
|
|
68
|
+
if (key !== "templatePath" && (key !== "children" || includeChildren)) {
|
|
69
|
+
getSchemaObjectParametersInternal(
|
|
70
|
+
obj[key],
|
|
71
|
+
parameters,
|
|
72
|
+
includeChildren
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function getSchemaObjectParameters(obj, includeChildren = false) {
|
|
79
|
+
const params = /* @__PURE__ */ new Set();
|
|
80
|
+
getSchemaObjectParametersInternal(obj, params, includeChildren);
|
|
81
|
+
return Array.from(params);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ../../libs/path-utils/path.ts
|
|
85
|
+
init_cjs_shims();
|
|
86
|
+
var getStructuralPath = (path) => {
|
|
87
|
+
return path.split("/").map((part) => part.split(":")[0]).join("/");
|
|
88
|
+
};
|
|
89
|
+
var getInstanceValueByAccountPath = (path) => {
|
|
90
|
+
const parts = path.split("/");
|
|
91
|
+
const result = /* @__PURE__ */ new Map();
|
|
92
|
+
let workingSet = "";
|
|
93
|
+
for (let i = 0; i < parts.length; i++) {
|
|
94
|
+
const part = parts[i];
|
|
95
|
+
const [templateKey, templateValue] = part.split(":");
|
|
96
|
+
workingSet = workingSet ? `${workingSet}/${templateKey}` : templateKey;
|
|
97
|
+
result.set(workingSet, templateValue);
|
|
98
|
+
if (templateValue) {
|
|
99
|
+
workingSet = `${workingSet}:${templateValue}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
var getSubpaths = (path) => path.split("/").reduce((acc, part) => {
|
|
105
|
+
const prev = acc[acc.length - 1];
|
|
106
|
+
const subPath = prev ? `${prev}/${part}` : part;
|
|
107
|
+
acc.push(subPath);
|
|
108
|
+
return acc;
|
|
109
|
+
}, []);
|
|
110
|
+
var getStructuralSubpaths = (path) => getSubpaths(getStructuralPath(path));
|
|
111
|
+
|
|
112
|
+
// ../../libs/types/tx.ts
|
|
113
|
+
init_cjs_shims();
|
|
114
|
+
var SchemaTxMatchInput = z.object({
|
|
115
|
+
id: z.optional(ParameterizedString),
|
|
116
|
+
externalId: z.optional(ParameterizedString)
|
|
117
|
+
});
|
|
118
|
+
var txTypes = ["credit", "debit"];
|
|
119
|
+
var TxTypeSchema = z.enum(txTypes);
|
|
120
|
+
|
|
121
|
+
// ../../libs/types/schemas.ts
|
|
122
|
+
init_cjs_shims();
|
|
123
|
+
var LedgerMigrationStatusSchema = z.enum([
|
|
124
|
+
"queued",
|
|
125
|
+
"started",
|
|
126
|
+
"failed",
|
|
127
|
+
"completed",
|
|
128
|
+
"skipped"
|
|
129
|
+
]);
|
|
130
|
+
var SafeRecordKey = z.string().refine((v) => v !== "__proto__", "invalid parameter name");
|
|
131
|
+
var ParametersSchema = z.record(
|
|
132
|
+
SafeRecordKey,
|
|
133
|
+
z.string({
|
|
134
|
+
invalid_type_error: "Invalid parameter type. All parameters must be string-encoded values."
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
var EntryParametersSchema = z.record(
|
|
138
|
+
SafeRecordKey,
|
|
139
|
+
z.union([
|
|
140
|
+
z.string({
|
|
141
|
+
invalid_type_error: "Invalid parameter type. Parameters must be string-encoded values or arrays of objects with string values."
|
|
142
|
+
}),
|
|
143
|
+
z.array(z.record(SafeRecordKey, z.string()))
|
|
144
|
+
])
|
|
145
|
+
);
|
|
146
|
+
var ConsistencyModeSchema = z.enum(["strong", "eventual"]);
|
|
147
|
+
var ConsistencyConfigSchema = (keys, extra) => {
|
|
148
|
+
const v = z.optional(ConsistencyModeSchema);
|
|
149
|
+
const schemaObject = Object.fromEntries(
|
|
150
|
+
keys.map((key) => [key, v])
|
|
151
|
+
);
|
|
152
|
+
return z.object({ ...extra, ...schemaObject });
|
|
153
|
+
};
|
|
154
|
+
var GroupConsistencyConfig = z.object({
|
|
155
|
+
key: SafeStringSchema,
|
|
156
|
+
ownBalanceUpdates: ConsistencyModeSchema
|
|
157
|
+
});
|
|
158
|
+
var AccountConsistencyConfigSchema = z.object({
|
|
159
|
+
lines: z.optional(ConsistencyModeSchema),
|
|
160
|
+
ownBalanceUpdates: z.optional(ConsistencyModeSchema),
|
|
161
|
+
totalBalanceUpdates: z.optional(ConsistencyModeSchema),
|
|
162
|
+
groups: z.optional(z.array(GroupConsistencyConfig))
|
|
163
|
+
});
|
|
164
|
+
var SchemaCurrencyMatchInput = z.object({
|
|
165
|
+
customCurrencyId: z.string().optional(),
|
|
166
|
+
code: z.string()
|
|
167
|
+
});
|
|
168
|
+
var SchemaLinkTypeList = [
|
|
169
|
+
"IncreaseLink",
|
|
170
|
+
"UnitLink",
|
|
171
|
+
"CustomLink",
|
|
172
|
+
"StripeLink"
|
|
173
|
+
];
|
|
174
|
+
var SchemaLinkType = z.enum(SchemaLinkTypeList);
|
|
175
|
+
var SchemaExternalAccountMatchInput = z.object({
|
|
176
|
+
linkType: SchemaLinkType.optional(),
|
|
177
|
+
id: z.string().optional(),
|
|
178
|
+
externalId: z.string().optional(),
|
|
179
|
+
linkId: z.string().optional()
|
|
180
|
+
});
|
|
181
|
+
var SchemaPaymentInput = z.object({
|
|
182
|
+
enabled: z.boolean()
|
|
183
|
+
});
|
|
184
|
+
var SchemaLedgerEntityStatusSchema = z.enum([
|
|
185
|
+
"active",
|
|
186
|
+
"disabled",
|
|
187
|
+
"archived"
|
|
188
|
+
]);
|
|
189
|
+
var BaseSchemaLedgerAccountInput = z.lazy(
|
|
190
|
+
() => z.object({
|
|
191
|
+
key: z.string(),
|
|
192
|
+
name: z.string().optional(),
|
|
193
|
+
type: LedgerAccountTypeSchema.optional(),
|
|
194
|
+
currency: SchemaCurrencyMatchInput.optional(),
|
|
195
|
+
currencyMode: CurrencyModeSchema.optional(),
|
|
196
|
+
template: z.boolean().optional(),
|
|
197
|
+
clearing: z.boolean().optional(),
|
|
198
|
+
children: z.array(BaseSchemaLedgerAccountInput).optional(),
|
|
199
|
+
linkedAccount: SchemaExternalAccountMatchInput.optional(),
|
|
200
|
+
payment: SchemaPaymentInput.optional(),
|
|
201
|
+
consistencyConfig: AccountConsistencyConfigSchema.optional(),
|
|
202
|
+
status: SchemaLedgerEntityStatusSchema.optional()
|
|
203
|
+
})
|
|
204
|
+
);
|
|
205
|
+
var BaseChartOfAccounts = z.object({
|
|
206
|
+
defaultConsistencyConfig: AccountConsistencyConfigSchema.optional(),
|
|
207
|
+
defaultCurrency: z.optional(CurrencyMatchInputSchema),
|
|
208
|
+
defaultCurrencyMode: CurrencyModeSchema.optional(),
|
|
209
|
+
accounts: z.array(BaseSchemaLedgerAccountInput)
|
|
210
|
+
});
|
|
211
|
+
var SchemaCondition = z.object({
|
|
212
|
+
ownBalance: z.object({
|
|
213
|
+
eq: z.string().optional(),
|
|
214
|
+
lte: z.string().optional(),
|
|
215
|
+
gte: z.string().optional()
|
|
216
|
+
}).optional(),
|
|
217
|
+
totalBalance: z.object({
|
|
218
|
+
eq: z.string().optional(),
|
|
219
|
+
lte: z.string().optional(),
|
|
220
|
+
gte: z.string().optional()
|
|
221
|
+
}).optional()
|
|
222
|
+
});
|
|
223
|
+
var PostLinesAsSchema = z.enum([
|
|
224
|
+
"raw_lines",
|
|
225
|
+
"net_amounts",
|
|
226
|
+
"skip_zero_lines"
|
|
227
|
+
]);
|
|
228
|
+
var BaseSchemaLedgerEntryConditionInput = z.object({
|
|
229
|
+
account: z.object({ path: z.string() }).optional(),
|
|
230
|
+
postcondition: SchemaCondition.optional(),
|
|
231
|
+
precondition: SchemaCondition.optional(),
|
|
232
|
+
currency: SchemaCurrencyMatchInput.optional(),
|
|
233
|
+
repeated: z.object({
|
|
234
|
+
key: SafeStringSchema.refine((k) => k.trim().length >= 1, {
|
|
235
|
+
message: "repeated.key cannot be empty"
|
|
236
|
+
})
|
|
237
|
+
}).optional()
|
|
238
|
+
});
|
|
239
|
+
var BaseSchemaLedgerLineTagInput = z.object({
|
|
240
|
+
key: z.string(),
|
|
241
|
+
value: z.string()
|
|
242
|
+
});
|
|
243
|
+
var BaseSchemaLedgerEntryLineInput = z.object({
|
|
244
|
+
account: z.object({ path: z.string() }).optional(),
|
|
245
|
+
amount: z.string().optional(),
|
|
246
|
+
key: z.string(),
|
|
247
|
+
currency: SchemaCurrencyMatchInput.optional(),
|
|
248
|
+
description: z.string().optional(),
|
|
249
|
+
tx: SchemaTxMatchInput.optional(),
|
|
250
|
+
tags: z.array(BaseSchemaLedgerLineTagInput).optional(),
|
|
251
|
+
repeated: z.object({
|
|
252
|
+
key: SafeStringSchema.refine((k) => k.trim().length >= 1, {
|
|
253
|
+
message: "repeated.key cannot be empty"
|
|
254
|
+
})
|
|
255
|
+
}).optional()
|
|
256
|
+
});
|
|
257
|
+
var BaseSchemaLedgerEntryInput = z.object({
|
|
258
|
+
type: z.string(),
|
|
259
|
+
typeVersion: z.number().int().optional(),
|
|
260
|
+
description: z.string().optional(),
|
|
261
|
+
conditions: z.array(BaseSchemaLedgerEntryConditionInput).optional(),
|
|
262
|
+
lines: z.array(BaseSchemaLedgerEntryLineInput).optional(),
|
|
263
|
+
parameters: z.record(SafeRecordKey, z.string()).optional(),
|
|
264
|
+
tags: z.array(
|
|
265
|
+
z.object({
|
|
266
|
+
key: z.string(),
|
|
267
|
+
value: z.string()
|
|
268
|
+
})
|
|
269
|
+
).optional(),
|
|
270
|
+
groups: z.array(
|
|
271
|
+
z.object({
|
|
272
|
+
key: SafeStringSchema,
|
|
273
|
+
value: z.string()
|
|
274
|
+
})
|
|
275
|
+
).optional(),
|
|
276
|
+
status: SchemaLedgerEntityStatusSchema.optional(),
|
|
277
|
+
postLinesAs: PostLinesAsSchema.optional()
|
|
278
|
+
});
|
|
279
|
+
var BaseLedgerEntries = z.object({
|
|
280
|
+
types: z.array(BaseSchemaLedgerEntryInput)
|
|
281
|
+
});
|
|
282
|
+
var PaymentEventKey = {
|
|
283
|
+
/** Exit from the payer not yet having supplied a payment method at checkout. */
|
|
284
|
+
needs_payment_method_to_processing: "needs_payment_method_to_processing",
|
|
285
|
+
processing_to_settled: "processing_to_settled"
|
|
286
|
+
};
|
|
287
|
+
var PaymentEventKeySchema = z.nativeEnum(PaymentEventKey);
|
|
288
|
+
var PaymentTypeDirection = {
|
|
289
|
+
payin: "payin",
|
|
290
|
+
payout: "payout"
|
|
291
|
+
};
|
|
292
|
+
var PaymentTypeDirectionSchema = z.nativeEnum(PaymentTypeDirection);
|
|
293
|
+
var SystemLineKind = {
|
|
294
|
+
payment_settlement_line: "payment_settlement_line",
|
|
295
|
+
payment_fee_line: "payment_fee_line"
|
|
296
|
+
};
|
|
297
|
+
var SystemLineKindSchema = z.nativeEnum(SystemLineKind);
|
|
298
|
+
var SystemLineParameterName = {
|
|
299
|
+
payment_settlement_line: "settled_amount",
|
|
300
|
+
payment_fee_line: "fragment_fee_amount"
|
|
301
|
+
};
|
|
302
|
+
var SYSTEM_LINE_AMOUNT = {
|
|
303
|
+
[SystemLineKind.payment_settlement_line]: `{{${SystemLineParameterName.payment_settlement_line}}}`,
|
|
304
|
+
[SystemLineKind.payment_fee_line]: `-{{${SystemLineParameterName.payment_fee_line}}}`
|
|
305
|
+
};
|
|
306
|
+
var SYSTEM_PARAMETER_NAMES = new Set(
|
|
307
|
+
Object.values(SystemLineParameterName)
|
|
308
|
+
);
|
|
309
|
+
var BaseSchemaPaymentInput = z.object({
|
|
310
|
+
amount: z.string(),
|
|
311
|
+
direction: PaymentTypeDirectionSchema
|
|
312
|
+
});
|
|
313
|
+
var BaseSchemaPaymentEntryLineInput = BaseSchemaLedgerEntryLineInput.pick({
|
|
314
|
+
key: true,
|
|
315
|
+
currency: true,
|
|
316
|
+
description: true
|
|
317
|
+
}).extend({
|
|
318
|
+
account: z.object({ path: z.string() }),
|
|
319
|
+
amount: z.string(),
|
|
320
|
+
system: SystemLineKindSchema.optional()
|
|
321
|
+
});
|
|
322
|
+
var BaseSchemaPaymentEntryInput = z.object({
|
|
323
|
+
description: z.string().optional(),
|
|
324
|
+
lines: z.array(BaseSchemaPaymentEntryLineInput)
|
|
325
|
+
});
|
|
326
|
+
var SchemaPaymentTypeStatusSchema = z.enum(["active"]);
|
|
327
|
+
var BaseSchemaPaymentTypeInput = z.object({
|
|
328
|
+
type: z.string(),
|
|
329
|
+
typeVersion: z.number().int(),
|
|
330
|
+
status: SchemaPaymentTypeStatusSchema,
|
|
331
|
+
payment: BaseSchemaPaymentInput,
|
|
332
|
+
accounting: z.object({
|
|
333
|
+
needs_payment_method_to_processing: BaseSchemaPaymentEntryInput.optional(),
|
|
334
|
+
processing_to_settled: BaseSchemaPaymentEntryInput
|
|
335
|
+
})
|
|
336
|
+
});
|
|
337
|
+
var BaseSchemaPayments = z.object({
|
|
338
|
+
types: z.array(BaseSchemaPaymentTypeInput)
|
|
339
|
+
});
|
|
340
|
+
var SceneEntrySchema = z.object({
|
|
341
|
+
type: z.string(),
|
|
342
|
+
typeVersion: z.number().int().positive().optional(),
|
|
343
|
+
parameters: z.record(SafeRecordKey, z.string())
|
|
344
|
+
});
|
|
345
|
+
var ScenePaymentSchema = z.object({
|
|
346
|
+
ik: z.string(),
|
|
347
|
+
type: z.string(),
|
|
348
|
+
typeVersion: z.number().int().positive().optional(),
|
|
349
|
+
parameters: z.record(SafeRecordKey, z.string())
|
|
350
|
+
});
|
|
351
|
+
var SceneLedgerEventSchema = z.object({
|
|
352
|
+
eventType: z.literal("entry"),
|
|
353
|
+
entry: SceneEntrySchema
|
|
354
|
+
});
|
|
355
|
+
var ScenePaymentEventSchema = z.object({
|
|
356
|
+
eventType: z.literal("payment"),
|
|
357
|
+
payment: z.object({
|
|
358
|
+
ik: z.string(),
|
|
359
|
+
event: PaymentEventKeySchema
|
|
360
|
+
})
|
|
361
|
+
});
|
|
362
|
+
var SceneEventSchema = z.discriminatedUnion("eventType", [
|
|
363
|
+
SceneLedgerEventSchema,
|
|
364
|
+
ScenePaymentEventSchema
|
|
365
|
+
]);
|
|
366
|
+
var BaseScene = z.object({
|
|
367
|
+
name: z.string(),
|
|
368
|
+
events: z.array(SceneEventSchema),
|
|
369
|
+
payments: z.array(ScenePaymentSchema).optional()
|
|
370
|
+
});
|
|
371
|
+
var EntryKey = z.object({
|
|
372
|
+
type: SafeStringSchema,
|
|
373
|
+
typeVersion: z.number().int().positive()
|
|
374
|
+
});
|
|
375
|
+
var SchemaLedgerAccountMatchInput = z.object({
|
|
376
|
+
path: ParameterizedString
|
|
377
|
+
});
|
|
378
|
+
var GroupReconciliationParameters = z.object({
|
|
379
|
+
clearingAccountPath: SchemaLedgerAccountMatchInput
|
|
380
|
+
});
|
|
381
|
+
var SchemaEntryGroup = z.object({
|
|
382
|
+
key: SafeStringSchema,
|
|
383
|
+
description: z.string().optional(),
|
|
384
|
+
reconciliation: GroupReconciliationParameters.optional()
|
|
385
|
+
});
|
|
386
|
+
var BaseSchema = z.object({
|
|
387
|
+
name: z.string().optional(),
|
|
388
|
+
key: z.string(),
|
|
389
|
+
chartOfAccounts: BaseChartOfAccounts,
|
|
390
|
+
ledgerEntries: BaseLedgerEntries.optional(),
|
|
391
|
+
payments: BaseSchemaPayments.optional(),
|
|
392
|
+
groups: z.array(SchemaEntryGroup).optional(),
|
|
393
|
+
scenes: z.array(BaseScene).optional(),
|
|
394
|
+
consistencyConfig: z.optional(
|
|
395
|
+
z.object({
|
|
396
|
+
entries: ConsistencyModeSchema.optional()
|
|
397
|
+
})
|
|
398
|
+
)
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
export {
|
|
402
|
+
fillParams,
|
|
403
|
+
getSchemaObjectParameters,
|
|
404
|
+
SchemaTxMatchInput,
|
|
405
|
+
ConsistencyConfigSchema,
|
|
406
|
+
AccountConsistencyConfigSchema,
|
|
407
|
+
SchemaLedgerEntityStatusSchema,
|
|
408
|
+
BaseChartOfAccounts,
|
|
409
|
+
PostLinesAsSchema,
|
|
410
|
+
PaymentEventKey,
|
|
411
|
+
PaymentEventKeySchema,
|
|
412
|
+
PaymentTypeDirection,
|
|
413
|
+
PaymentTypeDirectionSchema,
|
|
414
|
+
SystemLineKind,
|
|
415
|
+
SystemLineKindSchema,
|
|
416
|
+
SYSTEM_LINE_AMOUNT,
|
|
417
|
+
SYSTEM_PARAMETER_NAMES,
|
|
418
|
+
SchemaPaymentTypeStatusSchema,
|
|
419
|
+
SchemaEntryGroup,
|
|
420
|
+
getStructuralPath,
|
|
421
|
+
getInstanceValueByAccountPath,
|
|
422
|
+
getSubpaths,
|
|
423
|
+
getStructuralSubpaths
|
|
424
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
standardQueries
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7GWSUHUD.js";
|
|
4
4
|
import {
|
|
5
5
|
InvalidGraphQlError
|
|
6
6
|
} from "./chunk-ZMFGVGZP.js";
|
|
7
7
|
import {
|
|
8
|
+
SYSTEM_PARAMETER_NAMES,
|
|
8
9
|
getSchemaObjectParameters,
|
|
9
10
|
getStructuralSubpaths
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VIWPVUO5.js";
|
|
11
12
|
import {
|
|
12
13
|
require_source
|
|
13
14
|
} from "./chunk-XK2D2Z44.js";
|
|
@@ -26,6 +27,16 @@ var import_chalk = __toESM(require_source(), 1);
|
|
|
26
27
|
var import_parser = __toESM(require_parser(), 1);
|
|
27
28
|
var import_printer = __toESM(require_printer(), 1);
|
|
28
29
|
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
|
|
29
40
|
var getAccountParams = (accountPath, schema) => {
|
|
30
41
|
const subpaths = getStructuralSubpaths(accountPath);
|
|
31
42
|
return subpaths.flatMap(
|
|
@@ -106,6 +117,16 @@ var schemaToEntryDefinitions = ({
|
|
|
106
117
|
];
|
|
107
118
|
});
|
|
108
119
|
};
|
|
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
|
+
}));
|
|
109
130
|
var camelCase = (value, delimiter) => {
|
|
110
131
|
return value.split(delimiter).filter((x) => !!x).map((word, index) => {
|
|
111
132
|
if (index === 0) {
|
|
@@ -188,25 +209,80 @@ __typename
|
|
|
188
209
|
}
|
|
189
210
|
${OnErrorFragment}
|
|
190
211
|
`;
|
|
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
|
+
`;
|
|
191
235
|
var isValidGraphQlName = (name) => {
|
|
192
236
|
return /^[a-zA-Z_]+[a-zA-Z0-9_]*$/.exec(name) !== null;
|
|
193
237
|
};
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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)) {
|
|
202
255
|
throw new InvalidGraphQlError(
|
|
203
|
-
`Operation name ${
|
|
204
|
-
|
|
256
|
+
`Operation name ${name} (for ${subject}: ${import_chalk.default.yellow(
|
|
257
|
+
sourceType
|
|
205
258
|
)}) is not a valid GraphQL name`
|
|
206
259
|
);
|
|
207
260
|
}
|
|
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
|
+
});
|
|
208
271
|
return readableEntryType;
|
|
209
272
|
};
|
|
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
|
+
};
|
|
210
286
|
var getPredefinedParameters = (definition) => {
|
|
211
287
|
const params = {};
|
|
212
288
|
if (definition.method === "addLedgerEntry") {
|
|
@@ -306,13 +382,64 @@ var entryDefinitionToMutation = (definition) => {
|
|
|
306
382
|
operationName
|
|
307
383
|
};
|
|
308
384
|
};
|
|
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
|
+
};
|
|
309
432
|
var generateQueriesFileContent = ({
|
|
310
433
|
definitions,
|
|
434
|
+
paymentDefinitions,
|
|
311
435
|
includeStandardQueries
|
|
312
436
|
}) => {
|
|
313
|
-
const generatedCode =
|
|
314
|
-
(def) => entryDefinitionToMutation(def).mutation
|
|
315
|
-
|
|
437
|
+
const generatedCode = [
|
|
438
|
+
...definitions.map((def) => entryDefinitionToMutation(def).mutation),
|
|
439
|
+
...paymentDefinitions.map(
|
|
440
|
+
(def) => paymentDefinitionToMutation(def).mutation
|
|
441
|
+
)
|
|
442
|
+
];
|
|
316
443
|
if (includeStandardQueries) {
|
|
317
444
|
generatedCode.push(standardQueries);
|
|
318
445
|
}
|
|
@@ -321,16 +448,17 @@ var generateQueriesFileContent = ({
|
|
|
321
448
|
};
|
|
322
449
|
var generateQueryFiles = ({
|
|
323
450
|
definitions,
|
|
451
|
+
paymentDefinitions,
|
|
324
452
|
includeStandardQueries
|
|
325
453
|
}) => {
|
|
326
|
-
const generatedCode =
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
454
|
+
const generatedCode = [
|
|
455
|
+
...definitions.map((def) => entryDefinitionToMutation(def)),
|
|
456
|
+
...paymentDefinitions.map((def) => paymentDefinitionToMutation(def))
|
|
457
|
+
].map(({ operationName, mutation }) => ({
|
|
458
|
+
content: `${mutation}
|
|
330
459
|
`,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
});
|
|
460
|
+
fileName: `${operationName}.graphql`
|
|
461
|
+
}));
|
|
334
462
|
if (includeStandardQueries) {
|
|
335
463
|
const parsedStdQueries = (0, import_parser.parse)(standardQueries);
|
|
336
464
|
parsedStdQueries.definitions.forEach((def) => {
|
|
@@ -366,11 +494,14 @@ var validateOutputName = ({
|
|
|
366
494
|
|
|
367
495
|
export {
|
|
368
496
|
schemaToEntryDefinitions,
|
|
497
|
+
schemaToPaymentDefinitions,
|
|
369
498
|
camelCase,
|
|
370
499
|
isValidGraphQlName,
|
|
371
500
|
generateGraphQlEntryType,
|
|
501
|
+
generateGraphQlPaymentType,
|
|
372
502
|
getPredefinedParameters,
|
|
373
503
|
entryDefinitionToMutation,
|
|
504
|
+
paymentDefinitionToMutation,
|
|
374
505
|
generateQueriesFileContent,
|
|
375
506
|
generateQueryFiles,
|
|
376
507
|
validateOutputName
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GenGraphQL
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-OP7PCXSO.js";
|
|
4
|
+
import "../chunk-ZNVKQ3OF.js";
|
|
5
|
+
import "../chunk-7GWSUHUD.js";
|
|
6
6
|
import "../chunk-ZMFGVGZP.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-UCIW25RZ.js";
|
|
8
|
+
import "../chunk-5AT6KBWC.js";
|
|
9
|
+
import "../chunk-VIWPVUO5.js";
|
|
10
|
+
import "../chunk-ICUOG2GK.js";
|
|
11
11
|
import "../chunk-W33MLXYW.js";
|
|
12
12
|
import "../chunk-34NLRFFT.js";
|
|
13
13
|
import "../chunk-LFCNPXLH.js";
|