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

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
package/README.md CHANGED
@@ -15,6 +15,27 @@ Cancelling authorization stops the CLI login and shows a confirmation in the bro
15
15
  Use `--workspace <id>` to select an existing workspace directly.
16
16
  Credentials remain in the CLI credential directory. The browser shows a confirmation after provisioning, with a button to open the approved workspace.
17
17
 
18
+ ## Print a local schema
19
+
20
+ Run `fragment print-schema --path ./fragment.jsonc` to view the chart of accounts and entries as a tree and Markdown tables.
21
+ Use `--account <name-or-path>` or `--entry <name>` for details; these flags cannot be combined.
22
+ Account selectors accept printed template placeholders and instance IDs, such as `liabilities/customer:{{customer_id}}` or `liabilities/customer:123`.
23
+ Supports JSON and JSONC files without authentication.
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
+
18
39
  <!-- commands -->
19
40
  * [`fragment add-ledger-entry`](#fragment-add-ledger-entry)
20
41
  * [`fragment api-client create`](#fragment-api-client-create)
@@ -31,11 +52,13 @@ Credentials remain in the CLI credential directory. The browser shows a confirma
31
52
  * [`fragment init`](#fragment-init)
32
53
  * [`fragment login`](#fragment-login)
33
54
  * [`fragment migrate-ledger-entry`](#fragment-migrate-ledger-entry)
55
+ * [`fragment print-schema`](#fragment-print-schema)
34
56
  * [`fragment query ledgerAccounts`](#fragment-query-ledgeraccounts)
35
57
  * [`fragment query ledgers`](#fragment-query-ledgers)
36
58
  * [`fragment query schema`](#fragment-query-schema)
37
59
  * [`fragment query schemas`](#fragment-query-schemas)
38
60
  * [`fragment reverse-ledger-entry`](#fragment-reverse-ledger-entry)
61
+ * [`fragment simulate-scenario`](#fragment-simulate-scenario)
39
62
  * [`fragment start`](#fragment-start)
40
63
  * [`fragment store-schema`](#fragment-store-schema)
41
64
  * [`fragment token`](#fragment-token)
@@ -450,6 +473,32 @@ FLAG DESCRIPTIONS
450
473
  You may specify multiple parameters by repeating the flag.
451
474
  ```
452
475
 
476
+ ## `fragment print-schema`
477
+
478
+ Pretty-print the chart of accounts and entries in a local schema
479
+
480
+ ```
481
+ USAGE
482
+ $ fragment print-schema [-p <value>] [--account <value> | --entry <value>]
483
+
484
+ FLAGS
485
+ -p, --path=<value> [default: fragment/fragment.json] Path to a schema JSON or JSONC file
486
+ --account=<value> Show one account by name, key, or full path
487
+ --entry=<value> Show an entry type and its versions, including posting lines
488
+
489
+ DESCRIPTION
490
+ Pretty-print the chart of accounts and entries in a local schema
491
+
492
+ EXAMPLES
493
+ $ fragment print-schema --path ./fragment.jsonc
494
+
495
+ $ fragment print-schema --path ./fragment.jsonc --account assets/cash
496
+
497
+ $ fragment print-schema --account "Cash"
498
+
499
+ $ fragment print-schema --entry carrier_paid
500
+ ```
501
+
453
502
  ## `fragment query ledgerAccounts`
454
503
 
455
504
  Get accounts for ledger within your workspace by ID
@@ -548,6 +597,26 @@ EXAMPLES
548
597
  $ fragment reverse-ledger-entry
549
598
  ```
550
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
+
551
620
  ## `fragment start`
552
621
 
553
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 });
@@ -0,0 +1,38 @@
1
+ import {
2
+ init_cjs_shims
3
+ } from "./chunk-7GH3YGSC.js";
4
+
5
+ // ../../libs/path-utils/path.ts
6
+ init_cjs_shims();
7
+ var getStructuralPath = (path) => {
8
+ return path.split("/").map((part) => part.split(":")[0]).join("/");
9
+ };
10
+ var getInstanceValueByAccountPath = (path) => {
11
+ const parts = path.split("/");
12
+ const result = /* @__PURE__ */ new Map();
13
+ let workingSet = "";
14
+ for (let i = 0; i < parts.length; i++) {
15
+ const part = parts[i];
16
+ const [templateKey, templateValue] = part.split(":");
17
+ workingSet = workingSet ? `${workingSet}/${templateKey}` : templateKey;
18
+ result.set(workingSet, templateValue);
19
+ if (templateValue) {
20
+ workingSet = `${workingSet}:${templateValue}`;
21
+ }
22
+ }
23
+ return result;
24
+ };
25
+ var getSubpaths = (path) => path.split("/").reduce((acc, part) => {
26
+ const prev = acc[acc.length - 1];
27
+ const subPath = prev ? `${prev}/${part}` : part;
28
+ acc.push(subPath);
29
+ return acc;
30
+ }, []);
31
+ var getStructuralSubpaths = (path) => getSubpaths(getStructuralPath(path));
32
+
33
+ export {
34
+ getStructuralPath,
35
+ getInstanceValueByAccountPath,
36
+ getSubpaths,
37
+ getStructuralSubpaths
38
+ };
@@ -2,9 +2,6 @@ import {
2
2
  init_cjs_shims
3
3
  } from "./chunk-7GH3YGSC.js";
4
4
 
5
- // ../../libs/types/strings.ts
6
- init_cjs_shims();
7
-
8
5
  // ../../node_modules/zod/lib/index.mjs
9
6
  init_cjs_shims();
10
7
  var util;
@@ -4056,207 +4053,6 @@ var z = /* @__PURE__ */ Object.freeze({
4056
4053
  ZodError
4057
4054
  });
4058
4055
 
4059
- // ../../libs/types/strings.ts
4060
- var UNSAFE_CHARACTERS = ["#", "/", ":"];
4061
- var isUnsafeString = (value) => {
4062
- return !!UNSAFE_CHARACTERS.find((character) => {
4063
- return value.includes(character);
4064
- });
4065
- };
4066
- var unsafePathCharacters = ["#"];
4067
- var SafePathStringSchema = z.string().superRefine((value, ctx) => {
4068
- if (value === "") {
4069
- ctx.addIssue({
4070
- code: z.ZodIssueCode.custom,
4071
- message: `Path cannot be an empty string. Received ${value}`
4072
- });
4073
- }
4074
- if (value.startsWith("/") || value.endsWith("/")) {
4075
- ctx.addIssue({
4076
- code: z.ZodIssueCode.custom,
4077
- message: `Path cannot start or end with a forward slash. Received ${value}`
4078
- });
4079
- }
4080
- if (value.includes("//")) {
4081
- ctx.addIssue({
4082
- code: z.ZodIssueCode.custom,
4083
- message: `Path cannot contain consecutive forward slashes. Received ${value}`
4084
- });
4085
- }
4086
- if (unsafePathCharacters.find((character) => value.includes(character))) {
4087
- ctx.addIssue({
4088
- code: z.ZodIssueCode.custom,
4089
- message: `Path cannot contain the characters: ${unsafePathCharacters.join(
4090
- ","
4091
- )}. Received ${value}`
4092
- });
4093
- }
4094
- }).brand();
4095
- var emailRegex2 = /^[^\s@+]+@[^\s@/]+\.[^\s@/]+$/;
4096
- var EmailAddressSchema = z.string().superRefine((value, ctx) => {
4097
- if (!emailRegex2.test(value)) {
4098
- ctx.addIssue({
4099
- code: z.ZodIssueCode.custom,
4100
- message: `Invalid email address. Cannot include whitespace, +, more than one @, or @ at the end. Received ${value}`
4101
- });
4102
- }
4103
- }).brand();
4104
- var paramRegex = /{{([^{}]*?)}}/g;
4105
- var getStringParameters = (s) => [...s.matchAll(paramRegex)].map((match) => match[1].trim()).filter((param) => {
4106
- return param !== "__proto__";
4107
- });
4108
- var getStringParametersInternal = (s, params) => {
4109
- getStringParameters(s).forEach((param) => {
4110
- params.add(param);
4111
- });
4112
- };
4113
- var SafeStringSchema = z.string().refine((s) => !isUnsafeString(s) && getStringParameters(s).length === 0, {
4114
- message: `String cannot contain '#', '/', ':', or parameters in {{handlebar}} syntax`
4115
- }).brand();
4116
- var DateTimeSchema = z.string().datetime().brand();
4117
- var ParameterizedString = z.string().transform((s) => {
4118
- return s.replace(/\{(\s*)(.*?)\s*\{/g, "{$2{").replace(/\}(\s*)(.*?)\s*\}/g, "}$2}").replace(/\{\{(\s*)(.*?)\s*\}\}/g, "{{$2}}");
4119
- }).refine(
4120
- (s) => {
4121
- return /^[^{}]*({{[^{}]*}}[^{}]*)*$/m.test(s);
4122
- },
4123
- {
4124
- message: `Parameterized string must have exactly two left brackets followed by exactly two right brackets.`
4125
- }
4126
- ).refine(
4127
- (s) => {
4128
- const regex = /{{([^{}]*?)}}/g;
4129
- const matches = [...s.trim().matchAll(regex)];
4130
- return matches.every(
4131
- ([_, param]) => param !== "" && !param.includes(" ") && param[0].match(/[a-zA-Z]/)
4132
- );
4133
- },
4134
- {
4135
- message: `Parameters (e.g. {{param}}) must be a non-empty string beginning with an alphabetical character and may not include whitespace.`
4136
- }
4137
- );
4138
- var ParameterizedAmount = ({
4139
- optional,
4140
- errorMessage
4141
- } = {}) => {
4142
- const schema = optional ? ParameterizedString.optional() : ParameterizedString;
4143
- return schema.superRefine((s, ctx) => {
4144
- if (!s) {
4145
- return;
4146
- }
4147
- const withoutHandlebars = s.replace(/\{\{[^}]*\}\}/g, "");
4148
- const mathOperatorsRegex = /[*x×/÷%]/i;
4149
- const firstMathOperatorMatch = withoutHandlebars.match(mathOperatorsRegex);
4150
- if (firstMathOperatorMatch) {
4151
- const operator = firstMathOperatorMatch[0];
4152
- ctx.addIssue({
4153
- code: z.ZodIssueCode.custom,
4154
- message: errorMessage ?? `Unsupported operator "${operator}". Only + and - are allowed in expressions.`
4155
- });
4156
- return;
4157
- }
4158
- let remaining = s.trim();
4159
- const valueRegex = /^(-?\d+|\{\{[^}]*\}*\}\})/;
4160
- const plusminusRegex = /^[+-]/;
4161
- let expect = "start";
4162
- while (remaining.length > 0) {
4163
- switch (expect) {
4164
- case "start": {
4165
- const m1 = remaining.match(valueRegex);
4166
- if (m1 && m1[0].length > 0) {
4167
- expect = "plusminus";
4168
- remaining = remaining.slice(m1[0].length).trim();
4169
- continue;
4170
- }
4171
- const m2 = remaining.match(plusminusRegex);
4172
- if (m2 && m2[0].length > 0) {
4173
- expect = "value";
4174
- remaining = remaining.slice(m2[0].length).trim();
4175
- continue;
4176
- }
4177
- ctx.addIssue({
4178
- code: z.ZodIssueCode.custom,
4179
- message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expressions must start with +, -, a number or {{param}}`
4180
- });
4181
- return;
4182
- }
4183
- case "plusminus": {
4184
- const m1 = remaining.match(plusminusRegex);
4185
- if (m1 && m1[0].length > 0) {
4186
- expect = "value";
4187
- remaining = remaining.slice(m1[0].length).trim();
4188
- continue;
4189
- }
4190
- ctx.addIssue({
4191
- code: z.ZodIssueCode.custom,
4192
- message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expected + or - at this point.`
4193
- });
4194
- return;
4195
- }
4196
- case "value": {
4197
- const m1 = remaining.match(valueRegex);
4198
- if (m1 && m1[0].length > 0) {
4199
- expect = "plusminus";
4200
- remaining = remaining.slice(m1[0].length).trim();
4201
- continue;
4202
- }
4203
- ctx.addIssue({
4204
- code: z.ZodIssueCode.custom,
4205
- message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expected a number or {{param}}`
4206
- });
4207
- return;
4208
- }
4209
- default: {
4210
- return;
4211
- }
4212
- }
4213
- }
4214
- if (expect !== "plusminus") {
4215
- ctx.addIssue({
4216
- code: z.ZodIssueCode.custom,
4217
- message: errorMessage ?? "Invalid expression. Unexpected end of string."
4218
- });
4219
- }
4220
- });
4221
- };
4222
- var safe = (splits, ...values) => SafeStringSchema.parse(
4223
- splits.reduce((acc, split, i) => acc + split + (values[i] || ""), "")
4224
- );
4225
- var SfnExecutionNameSchema = SafeStringSchema.superRefine(
4226
- (val, ctx) => {
4227
- if (val.length < 1 || val.length > 80) {
4228
- ctx.addIssue({
4229
- code: z.ZodIssueCode.custom,
4230
- message: `Name must be between 1 and 80 characters long. Received: ${val.length}.`
4231
- });
4232
- return;
4233
- }
4234
- if (val.startsWith("_") || val.endsWith("_")) {
4235
- ctx.addIssue({
4236
- code: z.ZodIssueCode.custom,
4237
- message: `Name cannot start or end with an underscore.`
4238
- });
4239
- return;
4240
- }
4241
- if (!/^[a-zA-Z0-9_-]+$/.test(val)) {
4242
- ctx.addIssue({
4243
- code: z.ZodIssueCode.custom,
4244
- message: `Name can only contain alphanumeric characters, hyphens, and underscores.`
4245
- });
4246
- }
4247
- }
4248
- ).brand();
4249
- var MAX_FREEFORM_TEXT_LENGTH = 1e3;
4250
- var PlainRequestPayloadSchema = z.any().brand();
4251
- var HashedRequestPayloadSchema = z.any().brand();
4252
-
4253
4056
  export {
4254
- z,
4255
- getStringParameters,
4256
- getStringParametersInternal,
4257
- SafeStringSchema,
4258
- ParameterizedString,
4259
- ParameterizedAmount,
4260
- safe,
4261
- MAX_FREEFORM_TEXT_LENGTH
4057
+ z
4262
4058
  };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  BackCompatCheckError,
3
3
  verifySchemaAgainstFile
4
- } from "./chunk-HZNM6VFG.js";
4
+ } from "./chunk-ERS7TGXY.js";
5
5
  import {
6
6
  extractSchemaMetadata,
7
7
  isJsonParseError,
8
8
  validateSchemaStructure
9
- } from "./chunk-743236RA.js";
9
+ } from "./chunk-GKWT6QEB.js";
10
+ import {
11
+ logValidationErrors
12
+ } from "./chunk-AXYDDQ64.js";
10
13
  import {
11
14
  DEFAULT_SCHEMA_PATH
12
15
  } from "./chunk-A4BSWX5D.js";
13
- import {
14
- logValidationErrors
15
- } from "./chunk-NOFQF7LO.js";
16
16
  import {
17
17
  FragmentCommand,
18
18
  require_lib
@@ -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
+ };