@fragment-dev/cli 2026.10.30-1 → 2026.10.30-13

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 (54) hide show
  1. package/README.md +69 -0
  2. package/bin/dev.js +1 -1
  3. package/bin/run.js +3 -1
  4. package/dist/chunk-2QGAXOCF.js +38 -0
  5. package/dist/{chunk-RWQZFXSF.js → chunk-3SE5DFKP.js} +1 -205
  6. package/dist/{chunk-DXYJ2C6A.js → chunk-4CPAGLCS.js} +5 -5
  7. package/dist/chunk-4E5LH6UM.js +46 -0
  8. package/dist/{chunk-XOKV3CLM.js → chunk-6CHMI6QB.js} +1149 -103
  9. package/dist/{chunk-NOFQF7LO.js → chunk-AXYDDQ64.js} +1 -1
  10. package/dist/{chunk-XKJQ557J.js → chunk-C3IGD3FR.js} +4 -2
  11. package/dist/{chunk-HZNM6VFG.js → chunk-ERS7TGXY.js} +4 -4
  12. package/dist/chunk-EXTVHTGU.js +88 -0
  13. package/dist/{chunk-FP3RI3B7.js → chunk-FTALVA4K.js} +20 -12
  14. package/dist/{chunk-2AWFI2YX.js → chunk-G7IGOKUP.js} +1 -1
  15. package/dist/{chunk-743236RA.js → chunk-GKWT6QEB.js} +5 -5
  16. package/dist/{chunk-GV36M6WY.js → chunk-HOYPQHWF.js} +7 -7
  17. package/dist/chunk-HYJ6MTD2.js +41 -0
  18. package/dist/chunk-JSWKMWBO.js +175 -0
  19. package/dist/{chunk-GCPPWOLT.js → chunk-LID4G5RM.js} +1 -1
  20. package/dist/chunk-MI5NFPWE.js +211 -0
  21. package/dist/{chunk-WNHRPKY6.js → chunk-MXOS5EPJ.js} +1 -1
  22. package/dist/chunk-N2SKO3MO.js +97 -0
  23. package/dist/chunk-NSEYKDYC.js +398 -0
  24. package/dist/chunk-OCE3DJ2V.js +76 -0
  25. package/dist/chunk-POIPF2YW.js +609 -0
  26. package/dist/chunk-PW3XYURG.js +4917 -0
  27. package/dist/chunk-T3RKAA7V.js +30 -0
  28. package/dist/{chunk-QJZAZHCO.js → chunk-WRHRJO7G.js} +16 -38
  29. package/dist/{chunk-YKGESMWT.js → chunk-WSFEOM2D.js} +1 -217
  30. package/dist/chunk-XKVEOJUH.js +85 -0
  31. package/dist/chunk-ZRPKEOB3.js +20 -0
  32. package/dist/commands/api-client/create.js +4 -3
  33. package/dist/commands/gen-graphql.js +11 -7
  34. package/dist/commands/login.js +4 -3
  35. package/dist/commands/print-schema.js +31 -0
  36. package/dist/commands/simulate-scenario.js +31 -0
  37. package/dist/commands/verify-schema.js +12 -8
  38. package/dist/commands.js +31 -17
  39. package/dist/graphql.js +8 -4
  40. package/dist/index.js +31 -17
  41. package/dist/lib/browserLogin.js +3 -2
  42. package/dist/utils/formatAccountHierarchy.js +11 -0
  43. package/dist/utils/formatAccountReference.js +12 -0
  44. package/dist/utils/formatBalance.js +11 -0
  45. package/dist/utils/formatChartOfAccounts.js +18 -0
  46. package/dist/utils/formatEntries.js +17 -0
  47. package/dist/utils/formatScenarioAccountBalances.js +18 -0
  48. package/dist/utils/formatScenarioBalances.js +19 -0
  49. package/dist/utils/formatTable.js +9 -0
  50. package/dist/utils/formatValidationErrors.js +6 -3
  51. package/dist/utils/schemaBackCompat.js +11 -7
  52. package/dist/utils/schemaValidation.js +10 -6
  53. package/oclif.manifest.json +92 -1
  54. package/package.json +8 -2
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BadRequestError
3
- } from "./chunk-YKGESMWT.js";
3
+ } from "./chunk-WSFEOM2D.js";
4
4
  import {
5
5
  require_source
6
6
  } from "./chunk-QDAKBUNO.js";
@@ -6,9 +6,11 @@ import {
6
6
  } from "./chunk-UQALZFPK.js";
7
7
  import {
8
8
  SYSTEM_PARAMETER_NAMES,
9
- getSchemaObjectParameters,
9
+ getSchemaObjectParameters
10
+ } from "./chunk-WRHRJO7G.js";
11
+ import {
10
12
  getStructuralSubpaths
11
- } from "./chunk-QJZAZHCO.js";
13
+ } from "./chunk-2QGAXOCF.js";
12
14
  import {
13
15
  require_source
14
16
  } from "./chunk-QDAKBUNO.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  validateSchemaStructure
3
- } from "./chunk-743236RA.js";
3
+ } from "./chunk-GKWT6QEB.js";
4
4
  import {
5
5
  ChartOfAccounts,
6
6
  MIN_SCHEMA_LEDGER_ENTRY_DISABLED_DURATION_SECONDS,
@@ -13,17 +13,17 @@ import {
13
13
  parseWithError,
14
14
  stringify,
15
15
  z
16
- } from "./chunk-XOKV3CLM.js";
16
+ } from "./chunk-6CHMI6QB.js";
17
17
  import {
18
18
  PaymentAccountingEventKey,
19
19
  VALID_LEDGER_ACCOUNT_STATUS_TRANSITIONS,
20
20
  getSchemaObjectParameters
21
- } from "./chunk-QJZAZHCO.js";
21
+ } from "./chunk-WRHRJO7G.js";
22
22
  import {
23
23
  BadRequestError,
24
24
  InternalError,
25
25
  assert_default
26
- } from "./chunk-YKGESMWT.js";
26
+ } from "./chunk-WSFEOM2D.js";
27
27
  import {
28
28
  getParsedSchemaString,
29
29
  parseJSON
@@ -0,0 +1,88 @@
1
+ import {
2
+ formatTable,
3
+ getDetailRows
4
+ } from "./chunk-HYJ6MTD2.js";
5
+ import {
6
+ formatAccountHierarchy
7
+ } from "./chunk-4E5LH6UM.js";
8
+ import {
9
+ ChartOfAccounts
10
+ } from "./chunk-6CHMI6QB.js";
11
+ import {
12
+ BaseSchema
13
+ } from "./chunk-WRHRJO7G.js";
14
+ import {
15
+ getStructuralPath
16
+ } from "./chunk-2QGAXOCF.js";
17
+ import {
18
+ init_cjs_shims
19
+ } from "./chunk-7GH3YGSC.js";
20
+
21
+ // src/utils/formatChartOfAccounts.ts
22
+ init_cjs_shims();
23
+ var PrintableSchema = BaseSchema.pick({
24
+ key: true,
25
+ name: true,
26
+ chartOfAccounts: true
27
+ });
28
+ var formatAccountKey = (account) => account.template ? `${account.key}:{{${account.key}_id}}` : account.key;
29
+ var formatAccountDetails = (account) => {
30
+ const { key, path, children, ...settings } = account;
31
+ const rows = getDetailRows(
32
+ {
33
+ Account: key,
34
+ Path: path,
35
+ ...settings,
36
+ Children: children?.map((child) => child.key).join(", ") || "[]"
37
+ },
38
+ ""
39
+ ).map(([field, value]) => [
40
+ field.replace(/^consistencyConfig\.lines$/, "Lines Consistency").replace(/^consistencyConfig\.groups/, "Groups Consistency"),
41
+ value
42
+ ]);
43
+ return formatTable(rows, []);
44
+ };
45
+ var formatChartOfAccounts = ({
46
+ schema: schemaInput,
47
+ account: selector
48
+ }) => {
49
+ const schema = PrintableSchema.parse(schemaInput);
50
+ const { accounts, accountPathToAccount } = ChartOfAccounts.parse(
51
+ schema.chartOfAccounts
52
+ );
53
+ const schemaName = schema.name ?? schema.key;
54
+ const heading = `${schemaName.charAt(0).toUpperCase()}${schemaName.slice(
55
+ 1
56
+ )}
57
+
58
+ Chart of Accounts`;
59
+ if (selector === void 0) {
60
+ return [
61
+ heading,
62
+ ...accounts.length === 0 ? ["(no accounts)"] : formatAccountHierarchy({ accounts, formatLabel: formatAccountKey })
63
+ ].join("\n");
64
+ }
65
+ const accountValues = [...accountPathToAccount.values()];
66
+ const hasNameMatch = accountValues.some(
67
+ (account) => account.name === selector
68
+ );
69
+ const structuralSelector = hasNameMatch ? selector : getStructuralPath(selector);
70
+ const exactAccount = accountPathToAccount.get(selector) ?? accountPathToAccount.get(structuralSelector);
71
+ const matches = exactAccount ? [exactAccount] : accountValues.filter(
72
+ (account) => account.key === structuralSelector || account.name === selector
73
+ );
74
+ if (matches.length === 0) {
75
+ throw new Error(`Account "${selector}" was not found.`);
76
+ }
77
+ if (matches.length > 1) {
78
+ throw new Error(
79
+ `Account "${selector}" is ambiguous. Use a full path: ${matches.map((account) => account.path).join(", ")}`
80
+ );
81
+ }
82
+ const details = matches[0];
83
+ return formatAccountDetails(details);
84
+ };
85
+
86
+ export {
87
+ formatChartOfAccounts
88
+ };
@@ -1,15 +1,27 @@
1
+ import {
2
+ Update
3
+ } from "./chunk-MVAJNY4X.js";
4
+ import {
5
+ VerifySchema
6
+ } from "./chunk-4CPAGLCS.js";
1
7
  import {
2
8
  Version
3
9
  } from "./chunk-VCN774BB.js";
4
10
  import {
5
11
  Workspace
6
12
  } from "./chunk-M2C3IDIY.js";
13
+ import {
14
+ GetSchema as GetSchema2
15
+ } from "./chunk-FJHK32F7.js";
7
16
  import {
8
17
  QuerySchemas
9
18
  } from "./chunk-WDUCGD5M.js";
10
19
  import {
11
20
  ReverseLedgerEntry
12
21
  } from "./chunk-LR3ZGFUV.js";
22
+ import {
23
+ SimulateScenario
24
+ } from "./chunk-XKVEOJUH.js";
13
25
  import {
14
26
  Start
15
27
  } from "./chunk-DF3U6ZLT.js";
@@ -22,15 +34,9 @@ import {
22
34
  import {
23
35
  UpdateLedgerAccount
24
36
  } from "./chunk-N66WU3TN.js";
25
- import {
26
- Update
27
- } from "./chunk-MVAJNY4X.js";
28
- import {
29
- VerifySchema
30
- } from "./chunk-DXYJ2C6A.js";
31
37
  import {
32
38
  GenGraphQL
33
- } from "./chunk-GV36M6WY.js";
39
+ } from "./chunk-HOYPQHWF.js";
34
40
  import {
35
41
  GetSchema
36
42
  } from "./chunk-HOGDV2YN.js";
@@ -39,25 +45,25 @@ import {
39
45
  } from "./chunk-XWCVZGAX.js";
40
46
  import {
41
47
  Login
42
- } from "./chunk-WNHRPKY6.js";
48
+ } from "./chunk-MXOS5EPJ.js";
43
49
  import {
44
50
  MigrateLedgerEntry
45
51
  } from "./chunk-WKMNNG4S.js";
52
+ import {
53
+ PrintSchema
54
+ } from "./chunk-N2SKO3MO.js";
46
55
  import {
47
56
  QueryLedgerAccounts
48
57
  } from "./chunk-RPKBDFB4.js";
49
58
  import {
50
59
  QueryLedgers
51
60
  } from "./chunk-RGB7H5GE.js";
52
- import {
53
- GetSchema as GetSchema2
54
- } from "./chunk-FJHK32F7.js";
55
61
  import {
56
62
  AddLedgerEntry
57
63
  } from "./chunk-5MNVNPOL.js";
58
64
  import {
59
65
  ApiClientCreate
60
- } from "./chunk-2AWFI2YX.js";
66
+ } from "./chunk-G7IGOKUP.js";
61
67
  import {
62
68
  CreateCustomLink
63
69
  } from "./chunk-GSRBM4QF.js";
@@ -95,6 +101,8 @@ var COMMANDS = {
95
101
  init: Init,
96
102
  "store-schema": StoreSchema,
97
103
  "verify-schema": VerifySchema,
104
+ "print-schema": PrintSchema,
105
+ "simulate-scenario": SimulateScenario,
98
106
  "get-schema": GetSchema,
99
107
  // Mutations
100
108
  "add-ledger-entry": AddLedgerEntry,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  provisionApiClientFromDashboard,
3
3
  startWorkspaceSelectionServer
4
- } from "./chunk-GCPPWOLT.js";
4
+ } from "./chunk-LID4G5RM.js";
5
5
  import {
6
6
  defaultBrowserAuthDeps
7
7
  } from "./chunk-TWNWTJEF.js";
@@ -1,13 +1,13 @@
1
+ import {
2
+ formatValidationErrors
3
+ } from "./chunk-AXYDDQ64.js";
1
4
  import {
2
5
  Schema,
3
6
  parseWithError
4
- } from "./chunk-XOKV3CLM.js";
5
- import {
6
- formatValidationErrors
7
- } from "./chunk-NOFQF7LO.js";
7
+ } from "./chunk-6CHMI6QB.js";
8
8
  import {
9
9
  BadRequestError
10
- } from "./chunk-YKGESMWT.js";
10
+ } from "./chunk-WSFEOM2D.js";
11
11
  import {
12
12
  init_cjs_shims
13
13
  } from "./chunk-7GH3YGSC.js";
@@ -1,21 +1,21 @@
1
+ import {
2
+ formatValidationErrors,
3
+ logValidationErrors
4
+ } from "./chunk-AXYDDQ64.js";
1
5
  import {
2
6
  generateQueriesFileContent,
3
7
  generateQueryFiles,
4
8
  schemaToEntryDefinitions,
5
9
  schemaToPaymentDefinitions,
6
10
  validateOutputName
7
- } from "./chunk-XKJQ557J.js";
11
+ } from "./chunk-C3IGD3FR.js";
8
12
  import {
9
13
  Schema,
10
14
  parseWithError
11
- } from "./chunk-XOKV3CLM.js";
12
- import {
13
- formatValidationErrors,
14
- logValidationErrors
15
- } from "./chunk-NOFQF7LO.js";
15
+ } from "./chunk-6CHMI6QB.js";
16
16
  import {
17
17
  BadRequestError
18
- } from "./chunk-YKGESMWT.js";
18
+ } from "./chunk-WSFEOM2D.js";
19
19
  import {
20
20
  FragmentCommand,
21
21
  require_lib
@@ -0,0 +1,41 @@
1
+ import {
2
+ init_cjs_shims
3
+ } from "./chunk-7GH3YGSC.js";
4
+
5
+ // src/utils/formatTable.ts
6
+ init_cjs_shims();
7
+ var getDetailRows = (value, path) => {
8
+ if (Array.isArray(value)) {
9
+ return value.length === 0 ? [[path, "[]"]] : value.flatMap(
10
+ (item, index) => getDetailRows(item, `${path}[${index}]`)
11
+ );
12
+ }
13
+ if (value !== null && typeof value === "object") {
14
+ return Object.entries(value).flatMap(
15
+ ([key, item]) => getDetailRows(item, path ? `${path}.${key}` : key)
16
+ );
17
+ }
18
+ return value === void 0 ? [] : [[path, String(value)]];
19
+ };
20
+ var escapeTableCell = (value) => value.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>");
21
+ var formatTable = (inputRows, minimumColumnWidths) => {
22
+ const rows = inputRows.map((row) => row.map(escapeTableCell));
23
+ const widths = rows[0].map(
24
+ (_, index) => Math.max(
25
+ 3,
26
+ minimumColumnWidths[index] ?? 0,
27
+ ...rows.map((row) => row[index].length)
28
+ )
29
+ );
30
+ const formatRow = (row) => `| ${row.map((value, index) => value.padEnd(widths[index])).join(" | ")} |`;
31
+ return [
32
+ formatRow(rows[0]),
33
+ formatRow(widths.map((width) => "-".repeat(width))),
34
+ ...rows.slice(1).map(formatRow)
35
+ ].join("\n");
36
+ };
37
+
38
+ export {
39
+ getDetailRows,
40
+ formatTable
41
+ };
@@ -0,0 +1,175 @@
1
+ import {
2
+ formatTable,
3
+ getDetailRows
4
+ } from "./chunk-HYJ6MTD2.js";
5
+ import {
6
+ formatAccountReference
7
+ } from "./chunk-T3RKAA7V.js";
8
+ import {
9
+ ChartOfAccounts
10
+ } from "./chunk-6CHMI6QB.js";
11
+ import {
12
+ BaseSchema
13
+ } from "./chunk-WRHRJO7G.js";
14
+ import {
15
+ init_cjs_shims
16
+ } from "./chunk-7GH3YGSC.js";
17
+
18
+ // src/utils/formatEntries.ts
19
+ init_cjs_shims();
20
+ var PrintableEntries = BaseSchema.pick({
21
+ ledgerEntries: true,
22
+ chartOfAccounts: true
23
+ });
24
+ var lineColumnWidths = [0, 28, 0];
25
+ var conditionLabels = {
26
+ ownBalance: "Own",
27
+ totalBalance: "Total",
28
+ gte: ">=",
29
+ lte: "<=",
30
+ eq: "="
31
+ };
32
+ var formatCurrency = (currency) => currency ? [currency.code, currency.customCurrencyId].filter(Boolean).join(":") : "(inherited)";
33
+ var getConditionRows = (condition, accounts, hasRepeatedConditions) => {
34
+ const account = formatAccountReference({
35
+ path: condition.account?.path,
36
+ accounts
37
+ });
38
+ const currency = formatCurrency(condition.currency);
39
+ const repetition = hasRepeatedConditions ? [condition.repeated?.key ?? "\u2014"] : [];
40
+ const rows = [
41
+ { when: "Pre", predicate: condition.precondition },
42
+ { when: "Post", predicate: condition.postcondition }
43
+ ].flatMap(
44
+ ({ when, predicate }) => getDetailRows(predicate, "").map(([field, value]) => {
45
+ const [balance, operator] = field.split(".");
46
+ return [
47
+ when,
48
+ account,
49
+ `${conditionLabels[balance] ?? balance} ${conditionLabels[operator] ?? operator} ${value} ${currency}`,
50
+ ...repetition
51
+ ];
52
+ })
53
+ );
54
+ return rows.length ? rows : [["\u2014", account, "\u2014", ...repetition]];
55
+ };
56
+ var getLineRows = (lines, accounts) => (lines ?? []).map((line) => [
57
+ formatAccountReference({ path: line.account?.path, accounts }),
58
+ line.amount ?? "\u2014",
59
+ formatCurrency(line.currency)
60
+ ]);
61
+ var formatLines = (lines, accounts) => lines?.length ? formatTable(
62
+ [["Account", "Amount", "Currency"], ...getLineRows(lines, accounts)],
63
+ lineColumnWidths
64
+ ) : "(no lines)";
65
+ var formatEntry = (entry, accounts) => {
66
+ const {
67
+ type,
68
+ description,
69
+ parameters,
70
+ groups,
71
+ typeVersion,
72
+ status,
73
+ lines,
74
+ conditions,
75
+ tags
76
+ } = entry;
77
+ const hasRepeatedConditions = conditions?.some((condition) => condition.repeated !== void 0) ?? false;
78
+ const lineSettings = (lines ?? []).flatMap((line) => {
79
+ const properties = Object.fromEntries(
80
+ Object.entries(line).filter(
81
+ ([field]) => !["key", "account", "amount", "currency", "description"].includes(
82
+ field
83
+ )
84
+ )
85
+ );
86
+ return getDetailRows(properties, `lines.${line.key}`);
87
+ });
88
+ return [
89
+ formatTable(
90
+ getDetailRows(
91
+ {
92
+ Entry: type,
93
+ description,
94
+ parameters,
95
+ ...groups?.length ? { groups } : {},
96
+ typeVersion,
97
+ status
98
+ },
99
+ ""
100
+ ),
101
+ []
102
+ ),
103
+ "",
104
+ "---",
105
+ "",
106
+ "Lines",
107
+ formatLines(lines, accounts),
108
+ ...lineSettings.length ? ["", "---", "", "Line Settings", formatTable(lineSettings, [])] : [],
109
+ "",
110
+ "---",
111
+ "",
112
+ "Conditions",
113
+ conditions?.length ? formatTable(
114
+ [
115
+ [
116
+ "When",
117
+ "Account",
118
+ "Condition",
119
+ ...hasRepeatedConditions ? ["Repeated"] : []
120
+ ],
121
+ ...conditions.flatMap(
122
+ (condition) => getConditionRows(condition, accounts, hasRepeatedConditions)
123
+ )
124
+ ],
125
+ []
126
+ ) : "(no conditions)",
127
+ "",
128
+ "---",
129
+ "",
130
+ "Tags",
131
+ tags?.length ? formatTable(
132
+ [["Key", "Value"], ...tags.map((tag) => [tag.key, tag.value])],
133
+ []
134
+ ) : "(no tags)"
135
+ ].join("\n");
136
+ };
137
+ var formatEntries = ({
138
+ schema,
139
+ entry: selector
140
+ }) => {
141
+ const parsedSchema = PrintableEntries.parse(schema);
142
+ const entries = parsedSchema.ledgerEntries?.types ?? [];
143
+ if (selector === void 0) {
144
+ if (entries.length === 0) {
145
+ return "Entries\n(no entries)";
146
+ }
147
+ const { accountPathToAccount: accountPathToAccount2 } = ChartOfAccounts.parse(
148
+ parsedSchema.chartOfAccounts
149
+ );
150
+ return [
151
+ "Entries",
152
+ entries.map(
153
+ (entry) => [
154
+ `**${entry.type}**`,
155
+ "",
156
+ entry.description ?? "\u2014",
157
+ "",
158
+ formatLines(entry.lines, accountPathToAccount2)
159
+ ].join("\n")
160
+ ).join("\n\n---\n\n")
161
+ ].join("\n");
162
+ }
163
+ const matches = entries.filter((entry) => entry.type === selector);
164
+ if (matches.length === 0) {
165
+ throw new Error(`Entry "${selector}" was not found.`);
166
+ }
167
+ const { accountPathToAccount } = ChartOfAccounts.parse(
168
+ parsedSchema.chartOfAccounts
169
+ );
170
+ return matches.map((entry) => formatEntry(entry, accountPathToAccount)).join("\n\n---\n\n");
171
+ };
172
+
173
+ export {
174
+ formatEntries
175
+ };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-TWNWTJEF.js";
5
5
  import {
6
6
  SafeStringSchema
7
- } from "./chunk-RWQZFXSF.js";
7
+ } from "./chunk-MI5NFPWE.js";
8
8
  import {
9
9
  init_cjs_shims
10
10
  } from "./chunk-7GH3YGSC.js";