arca-siradig 1.0.0
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/LICENSE +15 -0
- package/README.md +311 -0
- package/dist/src/arca/deductions.d.ts +71 -0
- package/dist/src/arca/deductions.js +636 -0
- package/dist/src/arca/employees.d.ts +10 -0
- package/dist/src/arca/employees.js +80 -0
- package/dist/src/arca/form.d.ts +39 -0
- package/dist/src/arca/form.js +143 -0
- package/dist/src/arca/http.d.ts +14 -0
- package/dist/src/arca/http.js +108 -0
- package/dist/src/arca/menu.d.ts +6 -0
- package/dist/src/arca/menu.js +36 -0
- package/dist/src/arca/personal-data.d.ts +4 -0
- package/dist/src/arca/personal-data.js +62 -0
- package/dist/src/arca/persons.d.ts +11 -0
- package/dist/src/arca/persons.js +115 -0
- package/dist/src/arca/receipt-types.d.ts +4 -0
- package/dist/src/arca/receipt-types.js +39 -0
- package/dist/src/arca/session.d.ts +27 -0
- package/dist/src/arca/session.js +165 -0
- package/dist/src/arca/submission.d.ts +22 -0
- package/dist/src/arca/submission.js +140 -0
- package/dist/src/arca/submitted-forms.d.ts +12 -0
- package/dist/src/arca/submitted-forms.js +54 -0
- package/dist/src/cli/errors.d.ts +1 -0
- package/dist/src/cli/errors.js +11 -0
- package/dist/src/cli/help.d.ts +6 -0
- package/dist/src/cli/help.js +301 -0
- package/dist/src/cli/index.d.ts +2 -0
- package/dist/src/cli/index.js +810 -0
- package/dist/src/cli/options.d.ts +120 -0
- package/dist/src/cli/options.js +419 -0
- package/dist/src/cli/prompts.d.ts +9 -0
- package/dist/src/cli/prompts.js +99 -0
- package/dist/src/cli/render.d.ts +13 -0
- package/dist/src/cli/render.js +262 -0
- package/dist/src/cli/structured-output.d.ts +4 -0
- package/dist/src/cli/structured-output.js +92 -0
- package/dist/src/files/pdf.d.ts +3 -0
- package/dist/src/files/pdf.js +43 -0
- package/dist/src/files/private.d.ts +4 -0
- package/dist/src/files/private.js +21 -0
- package/dist/src/security/errors.d.ts +2 -0
- package/dist/src/security/errors.js +22 -0
- package/dist/src/session/store.d.ts +15 -0
- package/dist/src/session/store.js +35 -0
- package/dist/src/types.d.ts +106 -0
- package/dist/src/types.js +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
const PERSON_OPTION = ["--person <id|name>", "Override the stored person selection"];
|
|
2
|
+
const FORMAT_OPTION = ["--format <text|json>", "Output format (default: text)"];
|
|
3
|
+
const PERIOD_OPTION = ["--period <YYYY>", "Fiscal year; required for changes"];
|
|
4
|
+
const GLOBAL_OPTIONS = [
|
|
5
|
+
["-h, --help", "Show command help"],
|
|
6
|
+
["--headless <true|false>", "Run without a visible browser (default: true)"],
|
|
7
|
+
];
|
|
8
|
+
const HELP_PAGES = {
|
|
9
|
+
root: {
|
|
10
|
+
usage: "arca-siradig [options] <command>",
|
|
11
|
+
description: "Manage ARCA SiRADIG sessions, people and fiscal forms.",
|
|
12
|
+
commands: [
|
|
13
|
+
["login", "Log into ARCA and store the session"],
|
|
14
|
+
["logout", "Remove the stored session"],
|
|
15
|
+
["persons <command>", "List people or select a person"],
|
|
16
|
+
["personal-data <command>", "Read personal data"],
|
|
17
|
+
["employees <command>", "Read employer data"],
|
|
18
|
+
["form <command>", "Inspect, print or submit a fiscal form"],
|
|
19
|
+
],
|
|
20
|
+
options: [["-i, --interactive", "Start the interactive read-only workflow"]],
|
|
21
|
+
notes: ["Run arca-siradig <command> --help for command details."],
|
|
22
|
+
examples: [
|
|
23
|
+
{ description: "Log in", args: ["login"] },
|
|
24
|
+
{ description: "Read a form summary", args: ["form", "summary", "--period=2026"] },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
login: {
|
|
28
|
+
usage: "arca-siradig login [options]",
|
|
29
|
+
description: "Log into ARCA and store the session. Missing credentials are prompted for.",
|
|
30
|
+
options: [
|
|
31
|
+
["--cuit <cuit>", "ARCA CUIT/CUIL"],
|
|
32
|
+
["--password <password>", "ARCA tax password"],
|
|
33
|
+
],
|
|
34
|
+
notes: [
|
|
35
|
+
"Prefer the password prompt. --password values may appear in shell history and process arguments.",
|
|
36
|
+
],
|
|
37
|
+
examples: [
|
|
38
|
+
{ description: "Enter credentials interactively", args: ["login"] },
|
|
39
|
+
{ description: "Log in with a visible browser", args: ["login", "--headless=false"] },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
logout: {
|
|
43
|
+
usage: "arca-siradig logout",
|
|
44
|
+
description: "Remove the stored session from ~/.arca-siradig/session.json.",
|
|
45
|
+
examples: [{ description: "Remove the local session", args: ["logout"] }],
|
|
46
|
+
},
|
|
47
|
+
persons: {
|
|
48
|
+
usage: "arca-siradig persons <command> [options]",
|
|
49
|
+
description: "Manage people and the stored person selection.",
|
|
50
|
+
commands: [
|
|
51
|
+
["list", "List the available people"],
|
|
52
|
+
["select <id|name>", "Select a person by the listed ID or name"],
|
|
53
|
+
],
|
|
54
|
+
options: [["--format <text|json>", "Output format for list (default: text)"]],
|
|
55
|
+
notes: ["The listed selection ID may be an internal index, rather than a CUIT."],
|
|
56
|
+
examples: [
|
|
57
|
+
{ description: "List people", args: ["persons", "list"] },
|
|
58
|
+
{ description: "Select a person by ID", args: ["persons", "select", "0"] },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
"personal-data": {
|
|
62
|
+
usage: "arca-siradig personal-data <command> [options]",
|
|
63
|
+
description: "Read personal data for the selected person.",
|
|
64
|
+
commands: [["show [person]", "Show the personal data sections visible in SiRADIG"]],
|
|
65
|
+
options: [PERSON_OPTION, FORMAT_OPTION],
|
|
66
|
+
examples: [{ description: "Show personal data", args: ["personal-data", "show"] }],
|
|
67
|
+
},
|
|
68
|
+
employees: {
|
|
69
|
+
usage: "arca-siradig employees <command> [options]",
|
|
70
|
+
description: "Read employer information for the selected person.",
|
|
71
|
+
commands: [
|
|
72
|
+
["list [person]", "List employers"],
|
|
73
|
+
["show --employee-cuit <cuit>", "Show one employer by CUIT"],
|
|
74
|
+
],
|
|
75
|
+
options: [
|
|
76
|
+
PERSON_OPTION,
|
|
77
|
+
["--employee-cuit <cuit>", "Employer CUIT; required for show"],
|
|
78
|
+
FORMAT_OPTION,
|
|
79
|
+
],
|
|
80
|
+
examples: [
|
|
81
|
+
{ description: "List employers", args: ["employees", "list"] },
|
|
82
|
+
{
|
|
83
|
+
description: "Show an employer",
|
|
84
|
+
args: ["employees", "show", "--employee-cuit=30000000001"],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
form: {
|
|
89
|
+
usage: "arca-siradig form <command> [options]",
|
|
90
|
+
description: "Inspect, print or submit the selected person's fiscal form draft.",
|
|
91
|
+
commands: [
|
|
92
|
+
["show", "Show the represented person and selected fiscal year"],
|
|
93
|
+
["summary", "Read the official draft preview"],
|
|
94
|
+
["print --path <file|folder>", "Download the official draft PDF"],
|
|
95
|
+
["submit --period <YYYY>", "Send the form; prompts to accept or cancel"],
|
|
96
|
+
["deductions <command>", "List, inspect, add or remove deductions"],
|
|
97
|
+
],
|
|
98
|
+
options: [
|
|
99
|
+
PERSON_OPTION,
|
|
100
|
+
PERIOD_OPTION,
|
|
101
|
+
["--path <file|folder>", "PDF destination; required for print"],
|
|
102
|
+
["--aceptar", "Confirm Generar Presentación without a prompt; submit only"],
|
|
103
|
+
["--format <text|json>", "Output format for show, summary and submit (default: text)"],
|
|
104
|
+
],
|
|
105
|
+
notes: [
|
|
106
|
+
"Read commands may omit --period and report ARCA's selected fiscal year.",
|
|
107
|
+
"Directory destinations use f572-<year>-borrador.pdf. Existing filenames get (1), (2), etc.",
|
|
108
|
+
"Submission requires --period. Without an interactive terminal, --aceptar is also required.",
|
|
109
|
+
"Run arca-siradig form deductions --help for deduction commands.",
|
|
110
|
+
],
|
|
111
|
+
examples: [
|
|
112
|
+
{ description: "Read a draft summary", args: ["form", "summary", "--period=2026"] },
|
|
113
|
+
{
|
|
114
|
+
description: "Save the draft PDF in the current directory",
|
|
115
|
+
args: ["form", "print", "--period=2026", "--path=./"],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
description: "Review and confirm submission interactively",
|
|
119
|
+
args: ["form", "submit", "--period=2026"],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
deductions: {
|
|
124
|
+
usage: "arca-siradig form deductions <command> [options]",
|
|
125
|
+
description: "Read deductions or update the selected fiscal form draft.",
|
|
126
|
+
commands: [
|
|
127
|
+
["list", "List deductions for the selected person"],
|
|
128
|
+
["list-receipt-types", "List the receipt type catalog"],
|
|
129
|
+
["show <id>", "Show one deduction by ID"],
|
|
130
|
+
["add-item", "Add a monthly deduction item"],
|
|
131
|
+
["add-item-receipt", "Add a receipt to a deduction"],
|
|
132
|
+
["remove-item-receipt", "Remove a medical expense receipt"],
|
|
133
|
+
],
|
|
134
|
+
options: [
|
|
135
|
+
PERIOD_OPTION,
|
|
136
|
+
PERSON_OPTION,
|
|
137
|
+
["--type <type>", "Deduction type; required for add-item and add-item-receipt"],
|
|
138
|
+
["--cuit <cuit>", "Provider CUIT; required for changes"],
|
|
139
|
+
["--month <1-12>", "Month number; required for add-item and add-item-receipt"],
|
|
140
|
+
["--amount <amount>", "Amount; required for add-item and add-item-receipt"],
|
|
141
|
+
["--date <YYYY-MM-DD>", "Receipt date; required for add-item-receipt"],
|
|
142
|
+
["--receipt-type <id>", "Receipt type ID; required for add-item-receipt"],
|
|
143
|
+
["--number <value>", "Receipt number; required for adding or removing receipts"],
|
|
144
|
+
["--reimbursed-amount <amount>", "Required for medical expense receipts (gastos-medicos)"],
|
|
145
|
+
["--format <text|json>", "Output format for list, show and receipt types (default: text)"],
|
|
146
|
+
],
|
|
147
|
+
notes: [
|
|
148
|
+
"Changes require --period. Receipt dates must belong to that fiscal year.",
|
|
149
|
+
"The receipt type catalog does not accept --period.",
|
|
150
|
+
"remove-item-receipt currently supports gastos-medicos; --type defaults to that type.",
|
|
151
|
+
],
|
|
152
|
+
examples: [
|
|
153
|
+
{ description: "List deductions", args: ["form", "deductions", "list", "--period=2026"] },
|
|
154
|
+
{ description: "List receipt types", args: ["form", "deductions", "list-receipt-types"] },
|
|
155
|
+
{ description: "Show a deduction", args: ["form", "deductions", "show", "123"] },
|
|
156
|
+
{
|
|
157
|
+
description: "Add a monthly item",
|
|
158
|
+
args: [
|
|
159
|
+
"form",
|
|
160
|
+
"deductions",
|
|
161
|
+
"add-item",
|
|
162
|
+
"--period=2026",
|
|
163
|
+
"--type",
|
|
164
|
+
"cuotas-medico-asistenciales",
|
|
165
|
+
"--cuit=30000000001",
|
|
166
|
+
"--month=3",
|
|
167
|
+
"--amount=1234",
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
description: "Add a receipt to a monthly deduction",
|
|
172
|
+
args: [
|
|
173
|
+
"form",
|
|
174
|
+
"deductions",
|
|
175
|
+
"add-item-receipt",
|
|
176
|
+
"--period=2026",
|
|
177
|
+
"--type",
|
|
178
|
+
"cuotas-medico-asistenciales",
|
|
179
|
+
"--cuit=30000000001",
|
|
180
|
+
"--month=3",
|
|
181
|
+
"--amount=1234",
|
|
182
|
+
"--receipt-type=6",
|
|
183
|
+
"--date=2026-03-12",
|
|
184
|
+
"--number=0000300000222",
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
description: "Add a medical expense receipt",
|
|
189
|
+
args: [
|
|
190
|
+
"form",
|
|
191
|
+
"deductions",
|
|
192
|
+
"add-item-receipt",
|
|
193
|
+
"--period=2026",
|
|
194
|
+
"--type=gastos-medicos",
|
|
195
|
+
"--cuit=30000000001",
|
|
196
|
+
"--month=5",
|
|
197
|
+
"--amount=28000",
|
|
198
|
+
"--reimbursed-amount=0",
|
|
199
|
+
"--receipt-type=6",
|
|
200
|
+
"--date=2026-05-22",
|
|
201
|
+
"--number=0000300000222",
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
description: "Remove a medical expense receipt",
|
|
206
|
+
args: [
|
|
207
|
+
"form",
|
|
208
|
+
"deductions",
|
|
209
|
+
"remove-item-receipt",
|
|
210
|
+
"--period=2026",
|
|
211
|
+
"--cuit=30000000001",
|
|
212
|
+
"--number=0000300000428",
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
export function renderHelp(topic, options = {}) {
|
|
219
|
+
const page = HELP_PAGES[topic];
|
|
220
|
+
const width = Math.max(20, Math.floor(options.width ?? 100));
|
|
221
|
+
const styled = (text, code) => options.color ? `\u001b[${code}m${text}\u001b[0m` : text;
|
|
222
|
+
const globals = topic === "logout" ? GLOBAL_OPTIONS.slice(0, 1) : GLOBAL_OPTIONS;
|
|
223
|
+
const sections = [
|
|
224
|
+
{ title: "Commands", rows: page.commands ?? [] },
|
|
225
|
+
{ title: "Options", rows: page.options ?? [] },
|
|
226
|
+
{ title: "Global Options", rows: globals },
|
|
227
|
+
];
|
|
228
|
+
const labelWidth = Math.max(...sections.flatMap((section) => section.rows.map(([label]) => label.length)));
|
|
229
|
+
const descriptionColumn = 4 + labelWidth + 2;
|
|
230
|
+
const stacked = width - descriptionColumn < 24;
|
|
231
|
+
const lines = [styled(`ARCA SiRADIG CLI ${options.version ?? "1.0.0"}`, "38;5;245")];
|
|
232
|
+
const append = (text, indent, style) => {
|
|
233
|
+
for (const line of wrapHelpText(text, width - indent))
|
|
234
|
+
lines.push(" ".repeat(indent) + (style ? styled(line, style) : line));
|
|
235
|
+
};
|
|
236
|
+
lines.push("");
|
|
237
|
+
append(page.usage, 2);
|
|
238
|
+
lines.push("");
|
|
239
|
+
append(page.description, 2);
|
|
240
|
+
for (const section of sections) {
|
|
241
|
+
if (!section.rows.length)
|
|
242
|
+
continue;
|
|
243
|
+
lines.push("", ` ${styled(`${section.title}:`, "38;5;245")}`);
|
|
244
|
+
for (const [label, description] of section.rows) {
|
|
245
|
+
if (stacked) {
|
|
246
|
+
append(label, 4);
|
|
247
|
+
append(description, 6);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const wrapped = wrapHelpText(description, width - descriptionColumn);
|
|
251
|
+
// Calculate padding on plain labels before adding ANSI color codes.
|
|
252
|
+
lines.push(` ${styled(label, "97")}${" ".repeat(labelWidth - label.length + 2)}${wrapped[0]}`);
|
|
253
|
+
for (const continuation of wrapped.slice(1))
|
|
254
|
+
lines.push(" ".repeat(descriptionColumn) + continuation);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (page.notes?.length) {
|
|
258
|
+
lines.push("", ` ${styled("Notes:", "38;5;245")}`);
|
|
259
|
+
for (const note of page.notes)
|
|
260
|
+
append(note, 4);
|
|
261
|
+
}
|
|
262
|
+
if (page.examples?.length) {
|
|
263
|
+
lines.push("", ` ${styled("Examples:", "38;5;245")}`);
|
|
264
|
+
for (const [index, example] of page.examples.entries()) {
|
|
265
|
+
if (index)
|
|
266
|
+
lines.push("");
|
|
267
|
+
append(example.description, 4);
|
|
268
|
+
for (const line of renderExample(example.args, width))
|
|
269
|
+
lines.push(styled(line, "38;5;151"));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return lines.join("\n");
|
|
273
|
+
}
|
|
274
|
+
function wrapHelpText(text, width) {
|
|
275
|
+
const lines = [];
|
|
276
|
+
let line = "";
|
|
277
|
+
for (const word of text.split(/\s+/).filter(Boolean)) {
|
|
278
|
+
if (line && line.length + word.length + 1 > width) {
|
|
279
|
+
lines.push(line);
|
|
280
|
+
line = "";
|
|
281
|
+
}
|
|
282
|
+
// Preserve long option names and paths rather than breaking a CLI argument.
|
|
283
|
+
line += `${line ? " " : ""}${word}`;
|
|
284
|
+
}
|
|
285
|
+
if (line)
|
|
286
|
+
lines.push(line);
|
|
287
|
+
return lines;
|
|
288
|
+
}
|
|
289
|
+
function renderExample(args, width) {
|
|
290
|
+
const lines = [];
|
|
291
|
+
let line = " $";
|
|
292
|
+
for (const argument of ["arca-siradig", ...args]) {
|
|
293
|
+
if (line.length + argument.length + 1 > width - 2 && line.trim() !== "$") {
|
|
294
|
+
lines.push(`${line} \\`);
|
|
295
|
+
line = " ";
|
|
296
|
+
}
|
|
297
|
+
line += ` ${argument}`;
|
|
298
|
+
}
|
|
299
|
+
lines.push(line);
|
|
300
|
+
return lines;
|
|
301
|
+
}
|