@fragment-dev/cli 2026.10.30-3 → 2026.10.30-7

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 (40) hide show
  1. package/README.md +35 -0
  2. package/bin/dev.js +1 -1
  3. package/bin/run.js +3 -1
  4. package/dist/{chunk-5GFLO7UI.js → chunk-4CPAGLCS.js} +3 -3
  5. package/dist/chunk-4E5LH6UM.js +46 -0
  6. package/dist/{chunk-RBPPQTJQ.js → chunk-6CHMI6QB.js} +1144 -102
  7. package/dist/{chunk-5IXOOVRA.js → chunk-AXYDDQ64.js} +1 -1
  8. package/dist/{chunk-C7BZFVCG.js → chunk-C3IGD3FR.js} +1 -1
  9. package/dist/{chunk-IC5FEPA7.js → chunk-ERS7TGXY.js} +4 -4
  10. package/dist/{chunk-MU3PFOFX.js → chunk-EXTVHTGU.js} +6 -36
  11. package/dist/{chunk-XDLQLWN4.js → chunk-FTALVA4K.js} +10 -6
  12. package/dist/{chunk-BJCQGSYO.js → chunk-GKWT6QEB.js} +3 -3
  13. package/dist/{chunk-2B4YYDGV.js → chunk-HOYPQHWF.js} +4 -4
  14. package/dist/{chunk-CBQOKKM3.js → chunk-JSWKMWBO.js} +5 -5
  15. package/dist/{chunk-XGFUT3M2.js → chunk-N2SKO3MO.js} +2 -2
  16. package/dist/chunk-NSEYKDYC.js +398 -0
  17. package/dist/chunk-OCE3DJ2V.js +76 -0
  18. package/dist/chunk-POIPF2YW.js +609 -0
  19. package/dist/chunk-PW3XYURG.js +4917 -0
  20. package/dist/{chunk-L3PXI35O.js → chunk-WRHRJO7G.js} +6 -3
  21. package/dist/{chunk-75AAIPKL.js → chunk-WSFEOM2D.js} +0 -205
  22. package/dist/chunk-XKVEOJUH.js +85 -0
  23. package/dist/commands/gen-graphql.js +7 -6
  24. package/dist/commands/print-schema.js +9 -7
  25. package/dist/commands/simulate-scenario.js +31 -0
  26. package/dist/commands/verify-schema.js +8 -7
  27. package/dist/commands.js +21 -15
  28. package/dist/graphql.js +4 -3
  29. package/dist/index.js +21 -15
  30. package/dist/utils/formatAccountHierarchy.js +11 -0
  31. package/dist/utils/formatBalance.js +11 -0
  32. package/dist/utils/formatChartOfAccounts.js +7 -5
  33. package/dist/utils/formatEntries.js +6 -5
  34. package/dist/utils/formatScenarioAccountBalances.js +18 -0
  35. package/dist/utils/formatScenarioBalances.js +19 -0
  36. package/dist/utils/formatValidationErrors.js +3 -2
  37. package/dist/utils/schemaBackCompat.js +7 -6
  38. package/dist/utils/schemaValidation.js +6 -5
  39. package/oclif.manifest.json +43 -1
  40. package/package.json +7 -2
package/README.md CHANGED
@@ -22,6 +22,20 @@ Use `--account <name-or-path>` or `--entry <name>` for details; these flags cann
22
22
  Account selectors accept printed template placeholders and instance IDs, such as `liabilities/customer:{{customer_id}}` or `liabilities/customer:123`.
23
23
  Supports JSON and JSONC files without authentication.
24
24
 
25
+ ## Simulate a scenario
26
+
27
+ Run `fragment simulate-scenario --path ./fragment.jsonc --scenario "Customer payment" --step 1` to view balances after a scenario step.
28
+ Steps start at 1; step 0 is not allowed. Steps beyond the scenario's last event are rejected.
29
+ The output lists all scenario entries and marks the selected entry with ➡️.
30
+ Entries through the selected step show account paths with account-type squares and formatted posting amounts.
31
+ Later steps show only their entry names.
32
+ Account balances use the chart’s box characters and nesting, with balances after each account key.
33
+ Parent balances include their children. Unused scenario accounts are omitted.
34
+ Accounts used by later steps remain visible at zero until they are posted to. Template instances show their actual IDs after the colon.
35
+ Balances include entries through the selected step, grouped by account and currency. Balances use each currency’s precision and comma separators, enclosed in square brackets after the account.
36
+ A failed entry reports its step and reason instead of printing balances.
37
+ JSON and JSONC files are supported without authentication.
38
+
25
39
  <!-- commands -->
26
40
  * [`fragment add-ledger-entry`](#fragment-add-ledger-entry)
27
41
  * [`fragment api-client create`](#fragment-api-client-create)
@@ -44,6 +58,7 @@ Supports JSON and JSONC files without authentication.
44
58
  * [`fragment query schema`](#fragment-query-schema)
45
59
  * [`fragment query schemas`](#fragment-query-schemas)
46
60
  * [`fragment reverse-ledger-entry`](#fragment-reverse-ledger-entry)
61
+ * [`fragment simulate-scenario`](#fragment-simulate-scenario)
47
62
  * [`fragment start`](#fragment-start)
48
63
  * [`fragment store-schema`](#fragment-store-schema)
49
64
  * [`fragment token`](#fragment-token)
@@ -582,6 +597,26 @@ EXAMPLES
582
597
  $ fragment reverse-ledger-entry
583
598
  ```
584
599
 
600
+ ## `fragment simulate-scenario`
601
+
602
+ Simulate account balances after a scenario step
603
+
604
+ ```
605
+ USAGE
606
+ $ fragment simulate-scenario --scenario <value> --step <value> [-p <value>]
607
+
608
+ FLAGS
609
+ -p, --path=<value> [default: fragment/fragment.json] Path to a schema JSON or JSONC file
610
+ --scenario=<value> (required) Scenario name from the schema
611
+ --step=<value> (required) Step to include (1-based). Step 0 is not allowed
612
+
613
+ DESCRIPTION
614
+ Simulate account balances after a scenario step
615
+
616
+ EXAMPLES
617
+ $ fragment simulate-scenario --path ./fragment.jsonc --scenario "Customer payment" --step 1
618
+ ```
619
+
585
620
  ## `fragment start`
586
621
 
587
622
  Develop your chart of accounts locally
package/bin/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
1
+ #!/usr/bin/env -S node --import tsx --no-warnings=ExperimentalWarning
2
2
 
3
3
  import { execute } from '@oclif/core';
4
4
 
package/bin/run.js CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { execute } from '@oclif/core';
3
+ import { execute, settings } from '@oclif/core';
4
4
 
5
+ // NODE_ENV=development otherwise makes oclif prefer source when tsx is installed.
6
+ settings.enableAutoTranspile = false;
5
7
  await execute({ dir: import.meta.url });
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  BackCompatCheckError,
3
3
  verifySchemaAgainstFile
4
- } from "./chunk-IC5FEPA7.js";
4
+ } from "./chunk-ERS7TGXY.js";
5
5
  import {
6
6
  extractSchemaMetadata,
7
7
  isJsonParseError,
8
8
  validateSchemaStructure
9
- } from "./chunk-BJCQGSYO.js";
9
+ } from "./chunk-GKWT6QEB.js";
10
10
  import {
11
11
  logValidationErrors
12
- } from "./chunk-5IXOOVRA.js";
12
+ } from "./chunk-AXYDDQ64.js";
13
13
  import {
14
14
  DEFAULT_SCHEMA_PATH
15
15
  } from "./chunk-A4BSWX5D.js";
@@ -0,0 +1,46 @@
1
+ import {
2
+ getAccountSquare
3
+ } from "./chunk-T3RKAA7V.js";
4
+ import {
5
+ init_cjs_shims
6
+ } from "./chunk-7GH3YGSC.js";
7
+
8
+ // src/utils/formatAccountHierarchy.ts
9
+ init_cjs_shims();
10
+
11
+ // ../../libs/types/boxChars.ts
12
+ init_cjs_shims();
13
+ var BoxCharacters = {
14
+ VERTICAL_LINE: "\u2502",
15
+ RIGHT_TOP_ELBOW: "\u250C\u2574",
16
+ RIGHT_BOTTOM_ELBOW: "\u2514\u2574",
17
+ LEFT_BOTTOM_ELBOW: "\u2576\u2518",
18
+ RIGHT_TEE: "\u251C\u2574",
19
+ LEFT_TEE: "\u2576\u2524",
20
+ EMPTY: ""
21
+ };
22
+
23
+ // src/utils/formatAccountHierarchy.ts
24
+ var formatAccountHierarchy = ({
25
+ accounts,
26
+ formatLabel
27
+ }) => {
28
+ const formatRow = (account, prefix) => `${getAccountSquare(account.type)} ${prefix}${formatLabel(account)}`;
29
+ const formatChildren = (children, prefix) => children.flatMap((account, index) => {
30
+ const isLast = index === children.length - 1;
31
+ const connector = isLast ? BoxCharacters.RIGHT_BOTTOM_ELBOW : BoxCharacters.RIGHT_TEE;
32
+ const continuation = isLast ? " " : `${BoxCharacters.VERTICAL_LINE} `;
33
+ return [
34
+ formatRow(account, `${prefix}${connector} `),
35
+ ...formatChildren(account.children ?? [], prefix + continuation)
36
+ ];
37
+ });
38
+ return accounts.flatMap((account) => [
39
+ formatRow(account, ""),
40
+ ...formatChildren(account.children ?? [], "")
41
+ ]);
42
+ };
43
+
44
+ export {
45
+ formatAccountHierarchy
46
+ };