@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.
- package/README.md +34 -0
- package/dist/{chunk-GV36M6WY.js → chunk-2B4YYDGV.js} +7 -7
- package/dist/chunk-2QGAXOCF.js +38 -0
- package/dist/{chunk-RWQZFXSF.js → chunk-3SE5DFKP.js} +1 -205
- package/dist/{chunk-DXYJ2C6A.js → chunk-5GFLO7UI.js} +5 -5
- package/dist/{chunk-NOFQF7LO.js → chunk-5IXOOVRA.js} +1 -1
- package/dist/{chunk-YKGESMWT.js → chunk-75AAIPKL.js} +1 -12
- package/dist/{chunk-743236RA.js → chunk-BJCQGSYO.js} +5 -5
- package/dist/{chunk-XKJQ557J.js → chunk-C7BZFVCG.js} +4 -2
- package/dist/chunk-CBQOKKM3.js +175 -0
- package/dist/{chunk-2AWFI2YX.js → chunk-G7IGOKUP.js} +1 -1
- package/dist/chunk-HYJ6MTD2.js +41 -0
- package/dist/{chunk-HZNM6VFG.js → chunk-IC5FEPA7.js} +4 -4
- package/dist/{chunk-QJZAZHCO.js → chunk-L3PXI35O.js} +11 -36
- package/dist/{chunk-GCPPWOLT.js → chunk-LID4G5RM.js} +1 -1
- package/dist/chunk-MI5NFPWE.js +211 -0
- package/dist/chunk-MU3PFOFX.js +118 -0
- package/dist/{chunk-WNHRPKY6.js → chunk-MXOS5EPJ.js} +1 -1
- package/dist/{chunk-XOKV3CLM.js → chunk-RBPPQTJQ.js} +9 -5
- package/dist/chunk-T3RKAA7V.js +30 -0
- package/dist/{chunk-FP3RI3B7.js → chunk-XDLQLWN4.js} +13 -9
- package/dist/chunk-XGFUT3M2.js +97 -0
- package/dist/chunk-ZRPKEOB3.js +20 -0
- package/dist/commands/api-client/create.js +4 -3
- package/dist/commands/gen-graphql.js +10 -7
- package/dist/commands/login.js +4 -3
- package/dist/commands/print-schema.js +29 -0
- package/dist/commands/verify-schema.js +11 -8
- package/dist/commands.js +24 -16
- package/dist/graphql.js +7 -4
- package/dist/index.js +24 -16
- package/dist/lib/browserLogin.js +3 -2
- package/dist/utils/formatAccountReference.js +12 -0
- package/dist/utils/formatChartOfAccounts.js +16 -0
- package/dist/utils/formatEntries.js +16 -0
- package/dist/utils/formatTable.js +9 -0
- package/dist/utils/formatValidationErrors.js +5 -3
- package/dist/utils/schemaBackCompat.js +10 -7
- package/dist/utils/schemaValidation.js +9 -6
- package/oclif.manifest.json +50 -1
- package/package.json +2 -1
|
@@ -2,16 +2,20 @@ import {
|
|
|
2
2
|
BadRequestError,
|
|
3
3
|
CurrencyMatchInputSchema,
|
|
4
4
|
CurrencyModeSchema,
|
|
5
|
-
LedgerAccountTypeSchema,
|
|
6
5
|
assert_default,
|
|
7
6
|
codes
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-75AAIPKL.js";
|
|
8
|
+
import {
|
|
9
|
+
LedgerAccountTypeSchema
|
|
10
|
+
} from "./chunk-ZRPKEOB3.js";
|
|
9
11
|
import {
|
|
10
12
|
ParameterizedString,
|
|
11
13
|
SafeStringSchema,
|
|
12
|
-
getStringParametersInternal
|
|
14
|
+
getStringParametersInternal
|
|
15
|
+
} from "./chunk-MI5NFPWE.js";
|
|
16
|
+
import {
|
|
13
17
|
z
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-3SE5DFKP.js";
|
|
15
19
|
import {
|
|
16
20
|
init_cjs_shims
|
|
17
21
|
} from "./chunk-7GH3YGSC.js";
|
|
@@ -83,33 +87,8 @@ function getSchemaObjectParameters(obj, includeChildren = false) {
|
|
|
83
87
|
return Array.from(params);
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
// ../../libs/
|
|
90
|
+
// ../../libs/types/schemas.ts
|
|
87
91
|
init_cjs_shims();
|
|
88
|
-
var getStructuralPath = (path) => {
|
|
89
|
-
return path.split("/").map((part) => part.split(":")[0]).join("/");
|
|
90
|
-
};
|
|
91
|
-
var getInstanceValueByAccountPath = (path) => {
|
|
92
|
-
const parts = path.split("/");
|
|
93
|
-
const result = /* @__PURE__ */ new Map();
|
|
94
|
-
let workingSet = "";
|
|
95
|
-
for (let i = 0; i < parts.length; i++) {
|
|
96
|
-
const part = parts[i];
|
|
97
|
-
const [templateKey, templateValue] = part.split(":");
|
|
98
|
-
workingSet = workingSet ? `${workingSet}/${templateKey}` : templateKey;
|
|
99
|
-
result.set(workingSet, templateValue);
|
|
100
|
-
if (templateValue) {
|
|
101
|
-
workingSet = `${workingSet}:${templateValue}`;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
105
|
-
};
|
|
106
|
-
var getSubpaths = (path) => path.split("/").reduce((acc, part) => {
|
|
107
|
-
const prev = acc[acc.length - 1];
|
|
108
|
-
const subPath = prev ? `${prev}/${part}` : part;
|
|
109
|
-
acc.push(subPath);
|
|
110
|
-
return acc;
|
|
111
|
-
}, []);
|
|
112
|
-
var getStructuralSubpaths = (path) => getSubpaths(getStructuralPath(path));
|
|
113
92
|
|
|
114
93
|
// ../../libs/types/tx.ts
|
|
115
94
|
init_cjs_shims();
|
|
@@ -121,7 +100,6 @@ var txTypes = ["credit", "debit"];
|
|
|
121
100
|
var TxTypeSchema = z.enum(txTypes);
|
|
122
101
|
|
|
123
102
|
// ../../libs/types/schemas.ts
|
|
124
|
-
init_cjs_shims();
|
|
125
103
|
var LedgerMigrationStatusSchema = z.enum([
|
|
126
104
|
"queued",
|
|
127
105
|
"started",
|
|
@@ -440,9 +418,6 @@ export {
|
|
|
440
418
|
SYSTEM_PARAMETER_NAMES,
|
|
441
419
|
SchemaPaymentTypeStatusSchema,
|
|
442
420
|
SchemaEntryGroup,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
getInstanceValueByAccountPath,
|
|
446
|
-
getSubpaths,
|
|
447
|
-
getStructuralSubpaths
|
|
421
|
+
BaseSchema,
|
|
422
|
+
VALID_LEDGER_ACCOUNT_STATUS_TRANSITIONS
|
|
448
423
|
};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {
|
|
2
|
+
z
|
|
3
|
+
} from "./chunk-3SE5DFKP.js";
|
|
4
|
+
import {
|
|
5
|
+
init_cjs_shims
|
|
6
|
+
} from "./chunk-7GH3YGSC.js";
|
|
7
|
+
|
|
8
|
+
// ../../libs/types/strings.ts
|
|
9
|
+
init_cjs_shims();
|
|
10
|
+
var UNSAFE_CHARACTERS = ["#", "/", ":"];
|
|
11
|
+
var isUnsafeString = (value) => {
|
|
12
|
+
return !!UNSAFE_CHARACTERS.find((character) => {
|
|
13
|
+
return value.includes(character);
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var unsafePathCharacters = ["#"];
|
|
17
|
+
var SafePathStringSchema = z.string().superRefine((value, ctx) => {
|
|
18
|
+
if (value === "") {
|
|
19
|
+
ctx.addIssue({
|
|
20
|
+
code: z.ZodIssueCode.custom,
|
|
21
|
+
message: `Path cannot be an empty string. Received ${value}`
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (value.startsWith("/") || value.endsWith("/")) {
|
|
25
|
+
ctx.addIssue({
|
|
26
|
+
code: z.ZodIssueCode.custom,
|
|
27
|
+
message: `Path cannot start or end with a forward slash. Received ${value}`
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (value.includes("//")) {
|
|
31
|
+
ctx.addIssue({
|
|
32
|
+
code: z.ZodIssueCode.custom,
|
|
33
|
+
message: `Path cannot contain consecutive forward slashes. Received ${value}`
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (unsafePathCharacters.find((character) => value.includes(character))) {
|
|
37
|
+
ctx.addIssue({
|
|
38
|
+
code: z.ZodIssueCode.custom,
|
|
39
|
+
message: `Path cannot contain the characters: ${unsafePathCharacters.join(
|
|
40
|
+
","
|
|
41
|
+
)}. Received ${value}`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}).brand();
|
|
45
|
+
var emailRegex = /^[^\s@+]+@[^\s@/]+\.[^\s@/]+$/;
|
|
46
|
+
var EmailAddressSchema = z.string().superRefine((value, ctx) => {
|
|
47
|
+
if (!emailRegex.test(value)) {
|
|
48
|
+
ctx.addIssue({
|
|
49
|
+
code: z.ZodIssueCode.custom,
|
|
50
|
+
message: `Invalid email address. Cannot include whitespace, +, more than one @, or @ at the end. Received ${value}`
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}).brand();
|
|
54
|
+
var paramRegex = /{{([^{}]*?)}}/g;
|
|
55
|
+
var getStringParameters = (s) => [...s.matchAll(paramRegex)].map((match) => match[1].trim()).filter((param) => {
|
|
56
|
+
return param !== "__proto__";
|
|
57
|
+
});
|
|
58
|
+
var getStringParametersInternal = (s, params) => {
|
|
59
|
+
getStringParameters(s).forEach((param) => {
|
|
60
|
+
params.add(param);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
var SafeStringSchema = z.string().refine((s) => !isUnsafeString(s) && getStringParameters(s).length === 0, {
|
|
64
|
+
message: `String cannot contain '#', '/', ':', or parameters in {{handlebar}} syntax`
|
|
65
|
+
}).brand();
|
|
66
|
+
var DateTimeSchema = z.string().datetime().brand();
|
|
67
|
+
var ParameterizedString = z.string().transform((s) => {
|
|
68
|
+
return s.replace(/\{(\s*)(.*?)\s*\{/g, "{$2{").replace(/\}(\s*)(.*?)\s*\}/g, "}$2}").replace(/\{\{(\s*)(.*?)\s*\}\}/g, "{{$2}}");
|
|
69
|
+
}).refine(
|
|
70
|
+
(s) => {
|
|
71
|
+
return /^[^{}]*({{[^{}]*}}[^{}]*)*$/m.test(s);
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
message: `Parameterized string must have exactly two left brackets followed by exactly two right brackets.`
|
|
75
|
+
}
|
|
76
|
+
).refine(
|
|
77
|
+
(s) => {
|
|
78
|
+
const regex = /{{([^{}]*?)}}/g;
|
|
79
|
+
const matches = [...s.trim().matchAll(regex)];
|
|
80
|
+
return matches.every(
|
|
81
|
+
([_, param]) => param !== "" && !param.includes(" ") && param[0].match(/[a-zA-Z]/)
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
message: `Parameters (e.g. {{param}}) must be a non-empty string beginning with an alphabetical character and may not include whitespace.`
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
var ParameterizedAmount = ({
|
|
89
|
+
optional,
|
|
90
|
+
errorMessage
|
|
91
|
+
} = {}) => {
|
|
92
|
+
const schema = optional ? ParameterizedString.optional() : ParameterizedString;
|
|
93
|
+
return schema.superRefine((s, ctx) => {
|
|
94
|
+
if (!s) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const withoutHandlebars = s.replace(/\{\{[^}]*\}\}/g, "");
|
|
98
|
+
const mathOperatorsRegex = /[*x×/÷%]/i;
|
|
99
|
+
const firstMathOperatorMatch = withoutHandlebars.match(mathOperatorsRegex);
|
|
100
|
+
if (firstMathOperatorMatch) {
|
|
101
|
+
const operator = firstMathOperatorMatch[0];
|
|
102
|
+
ctx.addIssue({
|
|
103
|
+
code: z.ZodIssueCode.custom,
|
|
104
|
+
message: errorMessage ?? `Unsupported operator "${operator}". Only + and - are allowed in expressions.`
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
let remaining = s.trim();
|
|
109
|
+
const valueRegex = /^(-?\d+|\{\{[^}]*\}*\}\})/;
|
|
110
|
+
const plusminusRegex = /^[+-]/;
|
|
111
|
+
let expect = "start";
|
|
112
|
+
while (remaining.length > 0) {
|
|
113
|
+
switch (expect) {
|
|
114
|
+
case "start": {
|
|
115
|
+
const m1 = remaining.match(valueRegex);
|
|
116
|
+
if (m1 && m1[0].length > 0) {
|
|
117
|
+
expect = "plusminus";
|
|
118
|
+
remaining = remaining.slice(m1[0].length).trim();
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const m2 = remaining.match(plusminusRegex);
|
|
122
|
+
if (m2 && m2[0].length > 0) {
|
|
123
|
+
expect = "value";
|
|
124
|
+
remaining = remaining.slice(m2[0].length).trim();
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
ctx.addIssue({
|
|
128
|
+
code: z.ZodIssueCode.custom,
|
|
129
|
+
message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expressions must start with +, -, a number or {{param}}`
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
case "plusminus": {
|
|
134
|
+
const m1 = remaining.match(plusminusRegex);
|
|
135
|
+
if (m1 && m1[0].length > 0) {
|
|
136
|
+
expect = "value";
|
|
137
|
+
remaining = remaining.slice(m1[0].length).trim();
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
ctx.addIssue({
|
|
141
|
+
code: z.ZodIssueCode.custom,
|
|
142
|
+
message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expected + or - at this point.`
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
case "value": {
|
|
147
|
+
const m1 = remaining.match(valueRegex);
|
|
148
|
+
if (m1 && m1[0].length > 0) {
|
|
149
|
+
expect = "plusminus";
|
|
150
|
+
remaining = remaining.slice(m1[0].length).trim();
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
ctx.addIssue({
|
|
154
|
+
code: z.ZodIssueCode.custom,
|
|
155
|
+
message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expected a number or {{param}}`
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
default: {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (expect !== "plusminus") {
|
|
165
|
+
ctx.addIssue({
|
|
166
|
+
code: z.ZodIssueCode.custom,
|
|
167
|
+
message: errorMessage ?? "Invalid expression. Unexpected end of string."
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
var safe = (splits, ...values) => SafeStringSchema.parse(
|
|
173
|
+
splits.reduce((acc, split, i) => acc + split + (values[i] || ""), "")
|
|
174
|
+
);
|
|
175
|
+
var SfnExecutionNameSchema = SafeStringSchema.superRefine(
|
|
176
|
+
(val, ctx) => {
|
|
177
|
+
if (val.length < 1 || val.length > 80) {
|
|
178
|
+
ctx.addIssue({
|
|
179
|
+
code: z.ZodIssueCode.custom,
|
|
180
|
+
message: `Name must be between 1 and 80 characters long. Received: ${val.length}.`
|
|
181
|
+
});
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (val.startsWith("_") || val.endsWith("_")) {
|
|
185
|
+
ctx.addIssue({
|
|
186
|
+
code: z.ZodIssueCode.custom,
|
|
187
|
+
message: `Name cannot start or end with an underscore.`
|
|
188
|
+
});
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(val)) {
|
|
192
|
+
ctx.addIssue({
|
|
193
|
+
code: z.ZodIssueCode.custom,
|
|
194
|
+
message: `Name can only contain alphanumeric characters, hyphens, and underscores.`
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
).brand();
|
|
199
|
+
var MAX_FREEFORM_TEXT_LENGTH = 1e3;
|
|
200
|
+
var PlainRequestPayloadSchema = z.any().brand();
|
|
201
|
+
var HashedRequestPayloadSchema = z.any().brand();
|
|
202
|
+
|
|
203
|
+
export {
|
|
204
|
+
getStringParameters,
|
|
205
|
+
getStringParametersInternal,
|
|
206
|
+
SafeStringSchema,
|
|
207
|
+
ParameterizedString,
|
|
208
|
+
ParameterizedAmount,
|
|
209
|
+
safe,
|
|
210
|
+
MAX_FREEFORM_TEXT_LENGTH
|
|
211
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAccountSquare
|
|
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
|
+
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
|
+
|
|
24
|
+
// ../../libs/types/boxChars.ts
|
|
25
|
+
init_cjs_shims();
|
|
26
|
+
var BoxCharacters = {
|
|
27
|
+
VERTICAL_LINE: "\u2502",
|
|
28
|
+
RIGHT_TOP_ELBOW: "\u250C\u2574",
|
|
29
|
+
RIGHT_BOTTOM_ELBOW: "\u2514\u2574",
|
|
30
|
+
LEFT_BOTTOM_ELBOW: "\u2576\u2518",
|
|
31
|
+
RIGHT_TEE: "\u251C\u2574",
|
|
32
|
+
LEFT_TEE: "\u2576\u2524",
|
|
33
|
+
EMPTY: ""
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/utils/formatChartOfAccounts.ts
|
|
37
|
+
var PrintableSchema = BaseSchema.pick({
|
|
38
|
+
key: true,
|
|
39
|
+
name: true,
|
|
40
|
+
chartOfAccounts: true
|
|
41
|
+
});
|
|
42
|
+
var formatAccountKey = (account) => account.template ? `${account.key}:{{${account.key}_id}}` : account.key;
|
|
43
|
+
var formatAccountRow = (account, prefix) => {
|
|
44
|
+
const square = getAccountSquare(account.type);
|
|
45
|
+
return `${square} ${prefix}${formatAccountKey(account)}`;
|
|
46
|
+
};
|
|
47
|
+
var formatAccountTree = (accounts, prefix) => accounts.flatMap((account, index) => {
|
|
48
|
+
const isLast = index === accounts.length - 1;
|
|
49
|
+
const connector = isLast ? BoxCharacters.RIGHT_BOTTOM_ELBOW : BoxCharacters.RIGHT_TEE;
|
|
50
|
+
const continuation = isLast ? " " : `${BoxCharacters.VERTICAL_LINE} `;
|
|
51
|
+
return [
|
|
52
|
+
formatAccountRow(account, `${prefix}${connector} `),
|
|
53
|
+
...formatAccountTree(account.children ?? [], prefix + continuation)
|
|
54
|
+
];
|
|
55
|
+
});
|
|
56
|
+
var formatAccountDetails = (account) => {
|
|
57
|
+
const { key, path, children, ...settings } = account;
|
|
58
|
+
const rows = getDetailRows(
|
|
59
|
+
{
|
|
60
|
+
Account: key,
|
|
61
|
+
Path: path,
|
|
62
|
+
...settings,
|
|
63
|
+
Children: children?.map((child) => child.key).join(", ") || "[]"
|
|
64
|
+
},
|
|
65
|
+
""
|
|
66
|
+
).map(([field, value]) => [
|
|
67
|
+
field.replace(/^consistencyConfig\.lines$/, "Lines Consistency").replace(/^consistencyConfig\.groups/, "Groups Consistency"),
|
|
68
|
+
value
|
|
69
|
+
]);
|
|
70
|
+
return formatTable(rows, []);
|
|
71
|
+
};
|
|
72
|
+
var formatChartOfAccounts = ({
|
|
73
|
+
schema: schemaInput,
|
|
74
|
+
account: selector
|
|
75
|
+
}) => {
|
|
76
|
+
const schema = PrintableSchema.parse(schemaInput);
|
|
77
|
+
const { accounts, accountPathToAccount } = ChartOfAccounts.parse(
|
|
78
|
+
schema.chartOfAccounts
|
|
79
|
+
);
|
|
80
|
+
const schemaName = schema.name ?? schema.key;
|
|
81
|
+
const heading = `${schemaName.charAt(0).toUpperCase()}${schemaName.slice(
|
|
82
|
+
1
|
|
83
|
+
)}
|
|
84
|
+
|
|
85
|
+
Chart of Accounts`;
|
|
86
|
+
if (selector === void 0) {
|
|
87
|
+
return [
|
|
88
|
+
heading,
|
|
89
|
+
...accounts.length === 0 ? ["(no accounts)"] : accounts.flatMap((account) => [
|
|
90
|
+
formatAccountRow(account, ""),
|
|
91
|
+
...formatAccountTree(account.children ?? [], "")
|
|
92
|
+
])
|
|
93
|
+
].join("\n");
|
|
94
|
+
}
|
|
95
|
+
const accountValues = [...accountPathToAccount.values()];
|
|
96
|
+
const hasNameMatch = accountValues.some(
|
|
97
|
+
(account) => account.name === selector
|
|
98
|
+
);
|
|
99
|
+
const structuralSelector = hasNameMatch ? selector : getStructuralPath(selector);
|
|
100
|
+
const exactAccount = accountPathToAccount.get(selector) ?? accountPathToAccount.get(structuralSelector);
|
|
101
|
+
const matches = exactAccount ? [exactAccount] : accountValues.filter(
|
|
102
|
+
(account) => account.key === structuralSelector || account.name === selector
|
|
103
|
+
);
|
|
104
|
+
if (matches.length === 0) {
|
|
105
|
+
throw new Error(`Account "${selector}" was not found.`);
|
|
106
|
+
}
|
|
107
|
+
if (matches.length > 1) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Account "${selector}" is ambiguous. Use a full path: ${matches.map((account) => account.path).join(", ")}`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const details = matches[0];
|
|
113
|
+
return formatAccountDetails(details);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
formatChartOfAccounts
|
|
118
|
+
};
|
|
@@ -17,12 +17,14 @@ import {
|
|
|
17
17
|
SystemLineKind,
|
|
18
18
|
SystemLineKindSchema,
|
|
19
19
|
fillParams,
|
|
20
|
+
getSchemaObjectParameters
|
|
21
|
+
} from "./chunk-L3PXI35O.js";
|
|
22
|
+
import {
|
|
20
23
|
getInstanceValueByAccountPath,
|
|
21
|
-
getSchemaObjectParameters,
|
|
22
24
|
getStructuralPath,
|
|
23
25
|
getStructuralSubpaths,
|
|
24
26
|
getSubpaths
|
|
25
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-2QGAXOCF.js";
|
|
26
28
|
import {
|
|
27
29
|
BadRequestError,
|
|
28
30
|
CurrencyMatchInputSchema,
|
|
@@ -30,16 +32,18 @@ import {
|
|
|
30
32
|
assertIsError,
|
|
31
33
|
assert_default,
|
|
32
34
|
currencyCodes
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-75AAIPKL.js";
|
|
34
36
|
import {
|
|
35
37
|
MAX_FREEFORM_TEXT_LENGTH,
|
|
36
38
|
ParameterizedAmount,
|
|
37
39
|
ParameterizedString,
|
|
38
40
|
SafeStringSchema,
|
|
39
41
|
getStringParameters,
|
|
40
|
-
safe
|
|
42
|
+
safe
|
|
43
|
+
} from "./chunk-MI5NFPWE.js";
|
|
44
|
+
import {
|
|
41
45
|
z
|
|
42
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-3SE5DFKP.js";
|
|
43
47
|
import {
|
|
44
48
|
__commonJS,
|
|
45
49
|
__toESM,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getStructuralPath
|
|
3
|
+
} from "./chunk-2QGAXOCF.js";
|
|
4
|
+
import {
|
|
5
|
+
LedgerAccountTypeSchema
|
|
6
|
+
} from "./chunk-ZRPKEOB3.js";
|
|
7
|
+
import {
|
|
8
|
+
init_cjs_shims
|
|
9
|
+
} from "./chunk-7GH3YGSC.js";
|
|
10
|
+
|
|
11
|
+
// src/utils/formatAccountReference.ts
|
|
12
|
+
init_cjs_shims();
|
|
13
|
+
var accountSquares = {
|
|
14
|
+
[LedgerAccountTypeSchema.enum.asset]: "\u{1F7E9}",
|
|
15
|
+
[LedgerAccountTypeSchema.enum.liability]: "\u{1F7E5}",
|
|
16
|
+
[LedgerAccountTypeSchema.enum.income]: "\u{1F7E6}",
|
|
17
|
+
[LedgerAccountTypeSchema.enum.expense]: "\u{1F7E8}"
|
|
18
|
+
};
|
|
19
|
+
var getAccountSquare = (type) => type ? accountSquares[type] : "\u2B1C";
|
|
20
|
+
var formatAccountReference = ({
|
|
21
|
+
path,
|
|
22
|
+
accounts
|
|
23
|
+
}) => path === void 0 ? "\u2014" : `${getAccountSquare(
|
|
24
|
+
accounts.get(getStructuralPath(path))?.type
|
|
25
|
+
)} ${path}`;
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
getAccountSquare,
|
|
29
|
+
formatAccountReference
|
|
30
|
+
};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VerifySchema
|
|
3
|
+
} from "./chunk-5GFLO7UI.js";
|
|
1
4
|
import {
|
|
2
5
|
Version
|
|
3
6
|
} from "./chunk-VCN774BB.js";
|
|
4
7
|
import {
|
|
5
8
|
Workspace
|
|
6
9
|
} from "./chunk-M2C3IDIY.js";
|
|
10
|
+
import {
|
|
11
|
+
GetSchema as GetSchema2
|
|
12
|
+
} from "./chunk-FJHK32F7.js";
|
|
7
13
|
import {
|
|
8
14
|
QuerySchemas
|
|
9
15
|
} from "./chunk-WDUCGD5M.js";
|
|
@@ -25,12 +31,9 @@ import {
|
|
|
25
31
|
import {
|
|
26
32
|
Update
|
|
27
33
|
} from "./chunk-MVAJNY4X.js";
|
|
28
|
-
import {
|
|
29
|
-
VerifySchema
|
|
30
|
-
} from "./chunk-DXYJ2C6A.js";
|
|
31
34
|
import {
|
|
32
35
|
GenGraphQL
|
|
33
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-2B4YYDGV.js";
|
|
34
37
|
import {
|
|
35
38
|
GetSchema
|
|
36
39
|
} from "./chunk-HOGDV2YN.js";
|
|
@@ -39,25 +42,25 @@ import {
|
|
|
39
42
|
} from "./chunk-XWCVZGAX.js";
|
|
40
43
|
import {
|
|
41
44
|
Login
|
|
42
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-MXOS5EPJ.js";
|
|
43
46
|
import {
|
|
44
47
|
MigrateLedgerEntry
|
|
45
48
|
} from "./chunk-WKMNNG4S.js";
|
|
49
|
+
import {
|
|
50
|
+
PrintSchema
|
|
51
|
+
} from "./chunk-XGFUT3M2.js";
|
|
46
52
|
import {
|
|
47
53
|
QueryLedgerAccounts
|
|
48
54
|
} from "./chunk-RPKBDFB4.js";
|
|
49
55
|
import {
|
|
50
56
|
QueryLedgers
|
|
51
57
|
} from "./chunk-RGB7H5GE.js";
|
|
52
|
-
import {
|
|
53
|
-
GetSchema as GetSchema2
|
|
54
|
-
} from "./chunk-FJHK32F7.js";
|
|
55
58
|
import {
|
|
56
59
|
AddLedgerEntry
|
|
57
60
|
} from "./chunk-5MNVNPOL.js";
|
|
58
61
|
import {
|
|
59
62
|
ApiClientCreate
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-G7IGOKUP.js";
|
|
61
64
|
import {
|
|
62
65
|
CreateCustomLink
|
|
63
66
|
} from "./chunk-GSRBM4QF.js";
|
|
@@ -95,6 +98,7 @@ var COMMANDS = {
|
|
|
95
98
|
init: Init,
|
|
96
99
|
"store-schema": StoreSchema,
|
|
97
100
|
"verify-schema": VerifySchema,
|
|
101
|
+
"print-schema": PrintSchema,
|
|
98
102
|
"get-schema": GetSchema,
|
|
99
103
|
// Mutations
|
|
100
104
|
"add-ledger-entry": AddLedgerEntry,
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatChartOfAccounts
|
|
3
|
+
} from "./chunk-MU3PFOFX.js";
|
|
4
|
+
import {
|
|
5
|
+
formatEntries
|
|
6
|
+
} from "./chunk-CBQOKKM3.js";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_SCHEMA_PATH
|
|
9
|
+
} from "./chunk-A4BSWX5D.js";
|
|
10
|
+
import {
|
|
11
|
+
FragmentCommand,
|
|
12
|
+
require_lib
|
|
13
|
+
} from "./chunk-VPOARVKJ.js";
|
|
14
|
+
import {
|
|
15
|
+
getParsedSchemaString,
|
|
16
|
+
parseJSON
|
|
17
|
+
} from "./chunk-QZNZYG2G.js";
|
|
18
|
+
import {
|
|
19
|
+
__toESM,
|
|
20
|
+
init_cjs_shims
|
|
21
|
+
} from "./chunk-7GH3YGSC.js";
|
|
22
|
+
|
|
23
|
+
// src/commands/print-schema.ts
|
|
24
|
+
init_cjs_shims();
|
|
25
|
+
var import_core = __toESM(require_lib(), 1);
|
|
26
|
+
var PrintSchema = class _PrintSchema extends FragmentCommand {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.run = async () => {
|
|
30
|
+
const { flags } = await this.parse(_PrintSchema);
|
|
31
|
+
const schemaString = getParsedSchemaString({
|
|
32
|
+
command: this,
|
|
33
|
+
schemaPath: flags.path,
|
|
34
|
+
silenceNonErrorLogging: true,
|
|
35
|
+
requireEnvVariables: false
|
|
36
|
+
});
|
|
37
|
+
const [schema, parseError] = parseJSON(schemaString);
|
|
38
|
+
if (parseError) {
|
|
39
|
+
this.error(`Failed to parse ${flags.path}: ${parseError.message}`, {
|
|
40
|
+
exit: 1
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
if (flags.entry !== void 0) {
|
|
45
|
+
this.log(formatEntries({ schema, entry: flags.entry }));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (flags.account !== void 0) {
|
|
49
|
+
this.log(formatChartOfAccounts({ schema, account: flags.account }));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.log(
|
|
53
|
+
[
|
|
54
|
+
formatChartOfAccounts({ schema, account: void 0 }),
|
|
55
|
+
formatEntries({ schema, entry: void 0 })
|
|
56
|
+
].join("\n\n")
|
|
57
|
+
);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
this.error(error instanceof Error ? error.message : String(error), {
|
|
60
|
+
exit: 1
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
static {
|
|
66
|
+
this.description = "Pretty-print the chart of accounts and entries in a local schema";
|
|
67
|
+
}
|
|
68
|
+
static {
|
|
69
|
+
this.examples = [
|
|
70
|
+
"<%= config.bin %> <%= command.id %> --path ./fragment.jsonc",
|
|
71
|
+
"<%= config.bin %> <%= command.id %> --path ./fragment.jsonc --account assets/cash",
|
|
72
|
+
'<%= config.bin %> <%= command.id %> --account "Cash"',
|
|
73
|
+
"<%= config.bin %> <%= command.id %> --entry carrier_paid"
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
static {
|
|
77
|
+
this.flags = {
|
|
78
|
+
path: import_core.Flags.string({
|
|
79
|
+
char: "p",
|
|
80
|
+
description: "Path to a schema JSON or JSONC file",
|
|
81
|
+
default: DEFAULT_SCHEMA_PATH
|
|
82
|
+
}),
|
|
83
|
+
account: import_core.Flags.string({
|
|
84
|
+
description: "Show one account by name, key, or full path",
|
|
85
|
+
exclusive: ["entry"]
|
|
86
|
+
}),
|
|
87
|
+
entry: import_core.Flags.string({
|
|
88
|
+
description: "Show an entry type and its versions, including posting lines",
|
|
89
|
+
exclusive: ["account"]
|
|
90
|
+
})
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
PrintSchema
|
|
97
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
z
|
|
3
|
+
} from "./chunk-3SE5DFKP.js";
|
|
4
|
+
import {
|
|
5
|
+
init_cjs_shims
|
|
6
|
+
} from "./chunk-7GH3YGSC.js";
|
|
7
|
+
|
|
8
|
+
// ../../libs/types/accountTypes.ts
|
|
9
|
+
init_cjs_shims();
|
|
10
|
+
var ledgerAccountTypes = [
|
|
11
|
+
"asset",
|
|
12
|
+
"liability",
|
|
13
|
+
"income",
|
|
14
|
+
"expense"
|
|
15
|
+
];
|
|
16
|
+
var LedgerAccountTypeSchema = z.enum(ledgerAccountTypes);
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
LedgerAccountTypeSchema
|
|
20
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiClientCreate
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-G7IGOKUP.js";
|
|
4
|
+
import "../../chunk-LID4G5RM.js";
|
|
5
5
|
import "../../chunk-TWNWTJEF.js";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-MI5NFPWE.js";
|
|
7
|
+
import "../../chunk-3SE5DFKP.js";
|
|
7
8
|
import "../../chunk-VPOARVKJ.js";
|
|
8
9
|
import "../../chunk-IDAIGTVO.js";
|
|
9
10
|
import "../../chunk-QZNZYG2G.js";
|