@fragment-dev/cli 2026.10.29 → 2026.10.30-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.
Files changed (41) hide show
  1. package/README.md +34 -0
  2. package/dist/{chunk-GV36M6WY.js → chunk-2B4YYDGV.js} +7 -7
  3. package/dist/chunk-2QGAXOCF.js +38 -0
  4. package/dist/{chunk-RWQZFXSF.js → chunk-3SE5DFKP.js} +1 -205
  5. package/dist/{chunk-DXYJ2C6A.js → chunk-5GFLO7UI.js} +5 -5
  6. package/dist/{chunk-NOFQF7LO.js → chunk-5IXOOVRA.js} +1 -1
  7. package/dist/{chunk-YKGESMWT.js → chunk-75AAIPKL.js} +1 -12
  8. package/dist/{chunk-743236RA.js → chunk-BJCQGSYO.js} +5 -5
  9. package/dist/{chunk-XKJQ557J.js → chunk-C7BZFVCG.js} +4 -2
  10. package/dist/chunk-CBQOKKM3.js +175 -0
  11. package/dist/{chunk-2AWFI2YX.js → chunk-G7IGOKUP.js} +1 -1
  12. package/dist/chunk-HYJ6MTD2.js +41 -0
  13. package/dist/{chunk-HZNM6VFG.js → chunk-IC5FEPA7.js} +4 -4
  14. package/dist/{chunk-QJZAZHCO.js → chunk-L3PXI35O.js} +11 -36
  15. package/dist/{chunk-GCPPWOLT.js → chunk-LID4G5RM.js} +1 -1
  16. package/dist/chunk-MI5NFPWE.js +211 -0
  17. package/dist/chunk-MU3PFOFX.js +118 -0
  18. package/dist/{chunk-WNHRPKY6.js → chunk-MXOS5EPJ.js} +1 -1
  19. package/dist/{chunk-XOKV3CLM.js → chunk-RBPPQTJQ.js} +9 -5
  20. package/dist/chunk-T3RKAA7V.js +30 -0
  21. package/dist/{chunk-FP3RI3B7.js → chunk-XDLQLWN4.js} +13 -9
  22. package/dist/chunk-XGFUT3M2.js +97 -0
  23. package/dist/chunk-ZRPKEOB3.js +20 -0
  24. package/dist/commands/api-client/create.js +4 -3
  25. package/dist/commands/gen-graphql.js +10 -7
  26. package/dist/commands/login.js +4 -3
  27. package/dist/commands/print-schema.js +29 -0
  28. package/dist/commands/verify-schema.js +11 -8
  29. package/dist/commands.js +24 -16
  30. package/dist/graphql.js +7 -4
  31. package/dist/index.js +24 -16
  32. package/dist/lib/browserLogin.js +3 -2
  33. package/dist/utils/formatAccountReference.js +12 -0
  34. package/dist/utils/formatChartOfAccounts.js +16 -0
  35. package/dist/utils/formatEntries.js +16 -0
  36. package/dist/utils/formatTable.js +9 -0
  37. package/dist/utils/formatValidationErrors.js +5 -3
  38. package/dist/utils/schemaBackCompat.js +10 -7
  39. package/dist/utils/schemaValidation.js +9 -6
  40. package/oclif.manifest.json +50 -1
  41. package/package.json +2 -1
package/README.md CHANGED
@@ -15,6 +15,13 @@ 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
+
18
25
  <!-- commands -->
19
26
  * [`fragment add-ledger-entry`](#fragment-add-ledger-entry)
20
27
  * [`fragment api-client create`](#fragment-api-client-create)
@@ -31,6 +38,7 @@ Credentials remain in the CLI credential directory. The browser shows a confirma
31
38
  * [`fragment init`](#fragment-init)
32
39
  * [`fragment login`](#fragment-login)
33
40
  * [`fragment migrate-ledger-entry`](#fragment-migrate-ledger-entry)
41
+ * [`fragment print-schema`](#fragment-print-schema)
34
42
  * [`fragment query ledgerAccounts`](#fragment-query-ledgeraccounts)
35
43
  * [`fragment query ledgers`](#fragment-query-ledgers)
36
44
  * [`fragment query schema`](#fragment-query-schema)
@@ -450,6 +458,32 @@ FLAG DESCRIPTIONS
450
458
  You may specify multiple parameters by repeating the flag.
451
459
  ```
452
460
 
461
+ ## `fragment print-schema`
462
+
463
+ Pretty-print the chart of accounts and entries in a local schema
464
+
465
+ ```
466
+ USAGE
467
+ $ fragment print-schema [-p <value>] [--account <value> | --entry <value>]
468
+
469
+ FLAGS
470
+ -p, --path=<value> [default: fragment/fragment.json] Path to a schema JSON or JSONC file
471
+ --account=<value> Show one account by name, key, or full path
472
+ --entry=<value> Show an entry type and its versions, including posting lines
473
+
474
+ DESCRIPTION
475
+ Pretty-print the chart of accounts and entries in a local schema
476
+
477
+ EXAMPLES
478
+ $ fragment print-schema --path ./fragment.jsonc
479
+
480
+ $ fragment print-schema --path ./fragment.jsonc --account assets/cash
481
+
482
+ $ fragment print-schema --account "Cash"
483
+
484
+ $ fragment print-schema --entry carrier_paid
485
+ ```
486
+
453
487
  ## `fragment query ledgerAccounts`
454
488
 
455
489
  Get accounts for ledger within your workspace by ID
@@ -1,21 +1,21 @@
1
+ import {
2
+ formatValidationErrors,
3
+ logValidationErrors
4
+ } from "./chunk-5IXOOVRA.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-C7BZFVCG.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-RBPPQTJQ.js";
16
16
  import {
17
17
  BadRequestError
18
- } from "./chunk-YKGESMWT.js";
18
+ } from "./chunk-75AAIPKL.js";
19
19
  import {
20
20
  FragmentCommand,
21
21
  require_lib
@@ -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-IC5FEPA7.js";
5
5
  import {
6
6
  extractSchemaMetadata,
7
7
  isJsonParseError,
8
8
  validateSchemaStructure
9
- } from "./chunk-743236RA.js";
9
+ } from "./chunk-BJCQGSYO.js";
10
+ import {
11
+ logValidationErrors
12
+ } from "./chunk-5IXOOVRA.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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BadRequestError
3
- } from "./chunk-YKGESMWT.js";
3
+ } from "./chunk-75AAIPKL.js";
4
4
  import {
5
5
  require_source
6
6
  } from "./chunk-QDAKBUNO.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  z
3
- } from "./chunk-RWQZFXSF.js";
3
+ } from "./chunk-3SE5DFKP.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __require,
@@ -884,16 +884,6 @@ import assert from "assert";
884
884
  // ../../libs/types/index.ts
885
885
  init_cjs_shims();
886
886
 
887
- // ../../libs/types/accountTypes.ts
888
- init_cjs_shims();
889
- var ledgerAccountTypes = [
890
- "asset",
891
- "liability",
892
- "income",
893
- "expense"
894
- ];
895
- var LedgerAccountTypeSchema = z.enum(ledgerAccountTypes);
896
-
897
887
  // ../../libs/types/workspaceTypes.ts
898
888
  init_cjs_shims();
899
889
  var workspaceTypes = [
@@ -1470,7 +1460,6 @@ var codes = {
1470
1460
  export {
1471
1461
  InternalError,
1472
1462
  BadRequestError,
1473
- LedgerAccountTypeSchema,
1474
1463
  currencyCodes,
1475
1464
  CurrencyModeSchema,
1476
1465
  CurrencyMatchInputSchema,
@@ -1,13 +1,13 @@
1
+ import {
2
+ formatValidationErrors
3
+ } from "./chunk-5IXOOVRA.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-RBPPQTJQ.js";
8
8
  import {
9
9
  BadRequestError
10
- } from "./chunk-YKGESMWT.js";
10
+ } from "./chunk-75AAIPKL.js";
11
11
  import {
12
12
  init_cjs_shims
13
13
  } from "./chunk-7GH3YGSC.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-L3PXI35O.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";
@@ -0,0 +1,175 @@
1
+ import {
2
+ formatAccountReference
3
+ } from "./chunk-T3RKAA7V.js";
4
+ import {
5
+ formatTable,
6
+ getDetailRows
7
+ } from "./chunk-HYJ6MTD2.js";
8
+ import {
9
+ ChartOfAccounts
10
+ } from "./chunk-RBPPQTJQ.js";
11
+ import {
12
+ BaseSchema
13
+ } from "./chunk-L3PXI35O.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
+ };
@@ -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";
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  validateSchemaStructure
3
- } from "./chunk-743236RA.js";
3
+ } from "./chunk-BJCQGSYO.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-RBPPQTJQ.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-L3PXI35O.js";
22
22
  import {
23
23
  BadRequestError,
24
24
  InternalError,
25
25
  assert_default
26
- } from "./chunk-YKGESMWT.js";
26
+ } from "./chunk-75AAIPKL.js";
27
27
  import {
28
28
  getParsedSchemaString,
29
29
  parseJSON