@soat/cli 0.0.1 → 0.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, Terezinha Tech Operations (ttoss)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/soat CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('../dist/index.js');
2
+ import('../dist/esm/index.js');
package/dist/esm/index.js CHANGED
@@ -1,33 +1,921 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
2
7
 
3
8
  // src/index.ts
9
+ import input from "@inquirer/input";
10
+ import password from "@inquirer/password";
11
+ import * as sdk from "@soat/sdk";
4
12
  import { program } from "commander";
5
13
 
6
14
  // package.json
7
15
  var package_default = {
8
- name: "soat",
9
- version: "0.0.1",
16
+ name: "@soat/cli",
17
+ version: "0.4.3",
18
+ type: "module",
10
19
  scripts: {
11
- build: "tsup",
12
- test: "jest --projects tests/unit"
20
+ generate: "tsx scripts/generate.ts",
21
+ build: "pnpm generate && tsup"
13
22
  },
14
23
  dependencies: {
15
- commander: "^14.0.2"
24
+ "@inquirer/input": "^5.0.12",
25
+ "@inquirer/password": "^5.0.12",
26
+ "@soat/sdk": "workspace:*",
27
+ "@ttoss/logger": "^0.8.10",
28
+ commander: "^14.0.3"
16
29
  },
17
30
  devDependencies: {
18
- "@ttoss/config": "^1.35.12",
31
+ "@ttoss/config": "^1.37.10",
19
32
  "@types/jest": "^30.0.0",
20
- jest: "^30.2.0",
33
+ "@types/js-yaml": "^4.0.9",
34
+ jest: "^30.3.0",
35
+ "js-yaml": "^4.1.1",
21
36
  tsup: "^8.5.1",
22
37
  tsx: "^4.21.0"
23
38
  },
24
- files: ["dist"],
25
- bin: "./bin/soat"
39
+ files: ["dist", "bin"],
40
+ repository: {
41
+ type: "git",
42
+ url: "https://github.com/ttoss/soat"
43
+ },
44
+ bin: "./bin/soat",
45
+ publishConfig: {
46
+ access: "public",
47
+ provenance: true
48
+ }
49
+ };
50
+
51
+ // src/config.ts
52
+ import * as fs from "fs";
53
+ import * as os from "os";
54
+ import * as path from "path";
55
+ import { createClient, createConfig } from "@soat/sdk";
56
+ var CONFIG_FILE = path.join(os.homedir(), ".soat", "config.json");
57
+ var readConfig = /* @__PURE__ */__name(() => {
58
+ try {
59
+ return JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
60
+ } catch {
61
+ return {};
62
+ }
63
+ }, "readConfig");
64
+ var writeProfile = /* @__PURE__ */__name((name, profile) => {
65
+ const config = readConfig();
66
+ config[name] = profile;
67
+ fs.mkdirSync(path.dirname(CONFIG_FILE), {
68
+ recursive: true
69
+ });
70
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
71
+ }, "writeProfile");
72
+ var resolveClient = /* @__PURE__ */__name(profileName => {
73
+ const envBaseUrl = process.env["SOAT_BASE_URL"];
74
+ const envToken = process.env["SOAT_TOKEN"];
75
+ if (envBaseUrl && envToken) {
76
+ return createClient(createConfig({
77
+ baseUrl: envBaseUrl,
78
+ headers: {
79
+ Authorization: `Bearer ${envToken}`
80
+ }
81
+ }));
82
+ }
83
+ if (envBaseUrl && !envToken) {
84
+ return createClient(createConfig({
85
+ baseUrl: envBaseUrl
86
+ }));
87
+ }
88
+ const name = profileName ?? process.env["SOAT_PROFILE"] ?? "default";
89
+ const config = readConfig();
90
+ const profile = config[name];
91
+ if (!profile) {
92
+ console.error(`Profile "${name}" not found. Run: soat configure${name !== "default" ? ` --profile ${name}` : ""}`);
93
+ process.exit(1);
94
+ }
95
+ return createClient(createConfig({
96
+ baseUrl: profile.baseUrl,
97
+ headers: {
98
+ Authorization: `Bearer ${profile.token}`
99
+ }
100
+ }));
101
+ }, "resolveClient");
102
+
103
+ // src/generated/routes.ts
104
+ var routes = {
105
+ "list-actors": {
106
+ serviceClass: "Actors",
107
+ operationId: "listActors",
108
+ pathParams: [],
109
+ queryParams: ["project_id", "external_id", "limit", "offset"]
110
+ },
111
+ "create-actor": {
112
+ serviceClass: "Actors",
113
+ operationId: "createActor",
114
+ pathParams: [],
115
+ queryParams: []
116
+ },
117
+ "get-actor": {
118
+ serviceClass: "Actors",
119
+ operationId: "getActor",
120
+ pathParams: ["id"],
121
+ queryParams: []
122
+ },
123
+ "update-actor": {
124
+ serviceClass: "Actors",
125
+ operationId: "updateActor",
126
+ pathParams: ["id"],
127
+ queryParams: []
128
+ },
129
+ "delete-actor": {
130
+ serviceClass: "Actors",
131
+ operationId: "deleteActor",
132
+ pathParams: ["id"],
133
+ queryParams: []
134
+ },
135
+ "get-actor-tags": {
136
+ serviceClass: "Actors",
137
+ operationId: "getActorTags",
138
+ pathParams: ["id"],
139
+ queryParams: []
140
+ },
141
+ "replace-actor-tags": {
142
+ serviceClass: "Actors",
143
+ operationId: "replaceActorTags",
144
+ pathParams: ["id"],
145
+ queryParams: []
146
+ },
147
+ "merge-actor-tags": {
148
+ serviceClass: "Actors",
149
+ operationId: "mergeActorTags",
150
+ pathParams: ["id"],
151
+ queryParams: []
152
+ },
153
+ "list-agent-tools": {
154
+ serviceClass: "AgentTools",
155
+ operationId: "listAgentTools",
156
+ pathParams: [],
157
+ queryParams: ["project_id"]
158
+ },
159
+ "create-agent-tool": {
160
+ serviceClass: "AgentTools",
161
+ operationId: "createAgentTool",
162
+ pathParams: [],
163
+ queryParams: []
164
+ },
165
+ "get-agent-tool": {
166
+ serviceClass: "AgentTools",
167
+ operationId: "getAgentTool",
168
+ pathParams: ["toolId"],
169
+ queryParams: []
170
+ },
171
+ "update-agent-tool": {
172
+ serviceClass: "AgentTools",
173
+ operationId: "updateAgentTool",
174
+ pathParams: ["toolId"],
175
+ queryParams: []
176
+ },
177
+ "delete-agent-tool": {
178
+ serviceClass: "AgentTools",
179
+ operationId: "deleteAgentTool",
180
+ pathParams: ["toolId"],
181
+ queryParams: []
182
+ },
183
+ "list-agent-traces": {
184
+ serviceClass: "AgentTraces",
185
+ operationId: "listAgentTraces",
186
+ pathParams: [],
187
+ queryParams: ["project_id", "limit", "offset"]
188
+ },
189
+ "get-agent-trace": {
190
+ serviceClass: "AgentTraces",
191
+ operationId: "getAgentTrace",
192
+ pathParams: ["traceId"],
193
+ queryParams: []
194
+ },
195
+ "list-agents": {
196
+ serviceClass: "Agents",
197
+ operationId: "listAgents",
198
+ pathParams: [],
199
+ queryParams: ["project_id"]
200
+ },
201
+ "create-agent": {
202
+ serviceClass: "Agents",
203
+ operationId: "createAgent",
204
+ pathParams: [],
205
+ queryParams: []
206
+ },
207
+ "get-agent": {
208
+ serviceClass: "Agents",
209
+ operationId: "getAgent",
210
+ pathParams: ["agentId"],
211
+ queryParams: []
212
+ },
213
+ "update-agent": {
214
+ serviceClass: "Agents",
215
+ operationId: "updateAgent",
216
+ pathParams: ["agentId"],
217
+ queryParams: []
218
+ },
219
+ "delete-agent": {
220
+ serviceClass: "Agents",
221
+ operationId: "deleteAgent",
222
+ pathParams: ["agentId"],
223
+ queryParams: []
224
+ },
225
+ "create-agent-generation": {
226
+ serviceClass: "Agents",
227
+ operationId: "createAgentGeneration",
228
+ pathParams: ["agentId"],
229
+ queryParams: []
230
+ },
231
+ "submit-agent-tool-outputs": {
232
+ serviceClass: "Agents",
233
+ operationId: "submitAgentToolOutputs",
234
+ pathParams: ["agentId", "generationId"],
235
+ queryParams: []
236
+ },
237
+ "create-agent-actor": {
238
+ serviceClass: "Agents",
239
+ operationId: "createAgentActor",
240
+ pathParams: ["agentId"],
241
+ queryParams: []
242
+ },
243
+ "list-ai-providers": {
244
+ serviceClass: "AIProviders",
245
+ operationId: "listAiProviders",
246
+ pathParams: [],
247
+ queryParams: ["project_id", "limit", "offset"]
248
+ },
249
+ "create-ai-provider": {
250
+ serviceClass: "AIProviders",
251
+ operationId: "createAiProvider",
252
+ pathParams: [],
253
+ queryParams: []
254
+ },
255
+ "get-ai-provider": {
256
+ serviceClass: "AIProviders",
257
+ operationId: "getAiProvider",
258
+ pathParams: ["aiProviderId"],
259
+ queryParams: []
260
+ },
261
+ "update-ai-provider": {
262
+ serviceClass: "AIProviders",
263
+ operationId: "updateAiProvider",
264
+ pathParams: ["aiProviderId"],
265
+ queryParams: []
266
+ },
267
+ "delete-ai-provider": {
268
+ serviceClass: "AIProviders",
269
+ operationId: "deleteAiProvider",
270
+ pathParams: ["aiProviderId"],
271
+ queryParams: []
272
+ },
273
+ "create-api-key": {
274
+ serviceClass: "APIKeys",
275
+ operationId: "createApiKey",
276
+ pathParams: [],
277
+ queryParams: []
278
+ },
279
+ "get-api-key": {
280
+ serviceClass: "APIKeys",
281
+ operationId: "getApiKey",
282
+ pathParams: ["id"],
283
+ queryParams: []
284
+ },
285
+ "update-api-key": {
286
+ serviceClass: "APIKeys",
287
+ operationId: "updateApiKey",
288
+ pathParams: ["id"],
289
+ queryParams: []
290
+ },
291
+ "delete-api-key": {
292
+ serviceClass: "APIKeys",
293
+ operationId: "deleteApiKey",
294
+ pathParams: ["id"],
295
+ queryParams: []
296
+ },
297
+ "list-chats": {
298
+ serviceClass: "Chats",
299
+ operationId: "listChats",
300
+ pathParams: [],
301
+ queryParams: ["project_id"]
302
+ },
303
+ "create-chat": {
304
+ serviceClass: "Chats",
305
+ operationId: "createChat",
306
+ pathParams: [],
307
+ queryParams: []
308
+ },
309
+ "get-chat": {
310
+ serviceClass: "Chats",
311
+ operationId: "getChat",
312
+ pathParams: ["chatId"],
313
+ queryParams: []
314
+ },
315
+ "delete-chat": {
316
+ serviceClass: "Chats",
317
+ operationId: "deleteChat",
318
+ pathParams: ["chatId"],
319
+ queryParams: []
320
+ },
321
+ "create-chat-completion-for-chat": {
322
+ serviceClass: "Chats",
323
+ operationId: "createChatCompletionForChat",
324
+ pathParams: ["chatId"],
325
+ queryParams: []
326
+ },
327
+ "create-chat-completion": {
328
+ serviceClass: "Chats",
329
+ operationId: "createChatCompletion",
330
+ pathParams: [],
331
+ queryParams: []
332
+ },
333
+ "create-chat-actor": {
334
+ serviceClass: "Chats",
335
+ operationId: "createChatActor",
336
+ pathParams: ["chatId"],
337
+ queryParams: []
338
+ },
339
+ "list-conversations": {
340
+ serviceClass: "Conversations",
341
+ operationId: "listConversations",
342
+ pathParams: [],
343
+ queryParams: ["project_id", "actor_id", "limit", "offset"]
344
+ },
345
+ "create-conversation": {
346
+ serviceClass: "Conversations",
347
+ operationId: "createConversation",
348
+ pathParams: [],
349
+ queryParams: []
350
+ },
351
+ "get-conversation": {
352
+ serviceClass: "Conversations",
353
+ operationId: "getConversation",
354
+ pathParams: ["id"],
355
+ queryParams: []
356
+ },
357
+ "update-conversation": {
358
+ serviceClass: "Conversations",
359
+ operationId: "updateConversation",
360
+ pathParams: ["id"],
361
+ queryParams: []
362
+ },
363
+ "delete-conversation": {
364
+ serviceClass: "Conversations",
365
+ operationId: "deleteConversation",
366
+ pathParams: ["id"],
367
+ queryParams: []
368
+ },
369
+ "list-conversation-messages": {
370
+ serviceClass: "Conversations",
371
+ operationId: "listConversationMessages",
372
+ pathParams: ["id"],
373
+ queryParams: ["limit", "offset"]
374
+ },
375
+ "add-conversation-message": {
376
+ serviceClass: "Conversations",
377
+ operationId: "addConversationMessage",
378
+ pathParams: ["id"],
379
+ queryParams: []
380
+ },
381
+ "generate-conversation-message": {
382
+ serviceClass: "Conversations",
383
+ operationId: "generateConversationMessage",
384
+ pathParams: ["id"],
385
+ queryParams: []
386
+ },
387
+ "list-conversation-actors": {
388
+ serviceClass: "Conversations",
389
+ operationId: "listConversationActors",
390
+ pathParams: ["id"],
391
+ queryParams: []
392
+ },
393
+ "remove-conversation-message": {
394
+ serviceClass: "Conversations",
395
+ operationId: "removeConversationMessage",
396
+ pathParams: ["id", "documentId"],
397
+ queryParams: []
398
+ },
399
+ "get-conversation-tags": {
400
+ serviceClass: "Conversations",
401
+ operationId: "getConversationTags",
402
+ pathParams: ["id"],
403
+ queryParams: []
404
+ },
405
+ "replace-conversation-tags": {
406
+ serviceClass: "Conversations",
407
+ operationId: "replaceConversationTags",
408
+ pathParams: ["id"],
409
+ queryParams: []
410
+ },
411
+ "merge-conversation-tags": {
412
+ serviceClass: "Conversations",
413
+ operationId: "mergeConversationTags",
414
+ pathParams: ["id"],
415
+ queryParams: []
416
+ },
417
+ "list-documents": {
418
+ serviceClass: "Documents",
419
+ operationId: "listDocuments",
420
+ pathParams: [],
421
+ queryParams: ["project_id"]
422
+ },
423
+ "create-document": {
424
+ serviceClass: "Documents",
425
+ operationId: "createDocument",
426
+ pathParams: [],
427
+ queryParams: []
428
+ },
429
+ "get-document": {
430
+ serviceClass: "Documents",
431
+ operationId: "getDocument",
432
+ pathParams: ["id"],
433
+ queryParams: []
434
+ },
435
+ "update-document": {
436
+ serviceClass: "Documents",
437
+ operationId: "updateDocument",
438
+ pathParams: ["id"],
439
+ queryParams: []
440
+ },
441
+ "delete-document": {
442
+ serviceClass: "Documents",
443
+ operationId: "deleteDocument",
444
+ pathParams: ["id"],
445
+ queryParams: []
446
+ },
447
+ "get-document-tags": {
448
+ serviceClass: "Documents",
449
+ operationId: "getDocumentTags",
450
+ pathParams: ["id"],
451
+ queryParams: []
452
+ },
453
+ "replace-document-tags": {
454
+ serviceClass: "Documents",
455
+ operationId: "replaceDocumentTags",
456
+ pathParams: ["id"],
457
+ queryParams: []
458
+ },
459
+ "merge-document-tags": {
460
+ serviceClass: "Documents",
461
+ operationId: "mergeDocumentTags",
462
+ pathParams: ["id"],
463
+ queryParams: []
464
+ },
465
+ "search-documents": {
466
+ serviceClass: "Documents",
467
+ operationId: "searchDocuments",
468
+ pathParams: [],
469
+ queryParams: []
470
+ },
471
+ "list-files": {
472
+ serviceClass: "Files",
473
+ operationId: "listFiles",
474
+ pathParams: [],
475
+ queryParams: ["limit", "offset"]
476
+ },
477
+ "create-file": {
478
+ serviceClass: "Files",
479
+ operationId: "createFile",
480
+ pathParams: [],
481
+ queryParams: []
482
+ },
483
+ "upload-file": {
484
+ serviceClass: "Files",
485
+ operationId: "uploadFile",
486
+ pathParams: [],
487
+ queryParams: []
488
+ },
489
+ "upload-file-base64": {
490
+ serviceClass: "Files",
491
+ operationId: "uploadFileBase64",
492
+ pathParams: [],
493
+ queryParams: []
494
+ },
495
+ "get-file": {
496
+ serviceClass: "Files",
497
+ operationId: "getFile",
498
+ pathParams: ["id"],
499
+ queryParams: []
500
+ },
501
+ "delete-file": {
502
+ serviceClass: "Files",
503
+ operationId: "deleteFile",
504
+ pathParams: ["id"],
505
+ queryParams: []
506
+ },
507
+ "download-file": {
508
+ serviceClass: "Files",
509
+ operationId: "downloadFile",
510
+ pathParams: ["id"],
511
+ queryParams: []
512
+ },
513
+ "update-file-metadata": {
514
+ serviceClass: "Files",
515
+ operationId: "updateFileMetadata",
516
+ pathParams: ["id"],
517
+ queryParams: []
518
+ },
519
+ "download-file-base64": {
520
+ serviceClass: "Files",
521
+ operationId: "downloadFileBase64",
522
+ pathParams: ["id"],
523
+ queryParams: []
524
+ },
525
+ "get-file-tags": {
526
+ serviceClass: "Files",
527
+ operationId: "getFileTags",
528
+ pathParams: ["id"],
529
+ queryParams: []
530
+ },
531
+ "replace-file-tags": {
532
+ serviceClass: "Files",
533
+ operationId: "replaceFileTags",
534
+ pathParams: ["id"],
535
+ queryParams: []
536
+ },
537
+ "merge-file-tags": {
538
+ serviceClass: "Files",
539
+ operationId: "mergeFileTags",
540
+ pathParams: ["id"],
541
+ queryParams: []
542
+ },
543
+ "list-policies": {
544
+ serviceClass: "Policies",
545
+ operationId: "listPolicies",
546
+ pathParams: [],
547
+ queryParams: []
548
+ },
549
+ "create-policy": {
550
+ serviceClass: "Policies",
551
+ operationId: "createPolicy",
552
+ pathParams: [],
553
+ queryParams: []
554
+ },
555
+ "get-policy": {
556
+ serviceClass: "Policies",
557
+ operationId: "getPolicy",
558
+ pathParams: ["policyId"],
559
+ queryParams: []
560
+ },
561
+ "update-policy": {
562
+ serviceClass: "Policies",
563
+ operationId: "updatePolicy",
564
+ pathParams: ["policyId"],
565
+ queryParams: []
566
+ },
567
+ "delete-policy": {
568
+ serviceClass: "Policies",
569
+ operationId: "deletePolicy",
570
+ pathParams: ["policyId"],
571
+ queryParams: []
572
+ },
573
+ "create-project": {
574
+ serviceClass: "Projects",
575
+ operationId: "createProject",
576
+ pathParams: [],
577
+ queryParams: []
578
+ },
579
+ "get-project": {
580
+ serviceClass: "Projects",
581
+ operationId: "getProject",
582
+ pathParams: ["projectId"],
583
+ queryParams: []
584
+ },
585
+ "delete-project": {
586
+ serviceClass: "Projects",
587
+ operationId: "deleteProject",
588
+ pathParams: ["projectId"],
589
+ queryParams: []
590
+ },
591
+ "list-secrets": {
592
+ serviceClass: "Secrets",
593
+ operationId: "listSecrets",
594
+ pathParams: [],
595
+ queryParams: ["project_id", "limit", "offset"]
596
+ },
597
+ "create-secret": {
598
+ serviceClass: "Secrets",
599
+ operationId: "createSecret",
600
+ pathParams: [],
601
+ queryParams: []
602
+ },
603
+ "get-secret": {
604
+ serviceClass: "Secrets",
605
+ operationId: "getSecret",
606
+ pathParams: ["secretId"],
607
+ queryParams: []
608
+ },
609
+ "update-secret": {
610
+ serviceClass: "Secrets",
611
+ operationId: "updateSecret",
612
+ pathParams: ["secretId"],
613
+ queryParams: []
614
+ },
615
+ "delete-secret": {
616
+ serviceClass: "Secrets",
617
+ operationId: "deleteSecret",
618
+ pathParams: ["secretId"],
619
+ queryParams: []
620
+ },
621
+ "list-agent-sessions": {
622
+ serviceClass: "Sessions",
623
+ operationId: "listAgentSessions",
624
+ pathParams: [],
625
+ queryParams: ["actor_id", "status", "limit", "offset"]
626
+ },
627
+ "create-agent-session": {
628
+ serviceClass: "Sessions",
629
+ operationId: "createAgentSession",
630
+ pathParams: [],
631
+ queryParams: []
632
+ },
633
+ "get-agent-session": {
634
+ serviceClass: "Sessions",
635
+ operationId: "getAgentSession",
636
+ pathParams: [],
637
+ queryParams: []
638
+ },
639
+ "update-session": {
640
+ serviceClass: "Sessions",
641
+ operationId: "updateSession",
642
+ pathParams: [],
643
+ queryParams: []
644
+ },
645
+ "delete-agent-session": {
646
+ serviceClass: "Sessions",
647
+ operationId: "deleteAgentSession",
648
+ pathParams: [],
649
+ queryParams: []
650
+ },
651
+ "list-agent-session-messages": {
652
+ serviceClass: "Sessions",
653
+ operationId: "listAgentSessionMessages",
654
+ pathParams: [],
655
+ queryParams: ["limit", "offset"]
656
+ },
657
+ "add-session-message": {
658
+ serviceClass: "Sessions",
659
+ operationId: "addSessionMessage",
660
+ pathParams: [],
661
+ queryParams: []
662
+ },
663
+ "generate-session-response": {
664
+ serviceClass: "Sessions",
665
+ operationId: "generateSessionResponse",
666
+ pathParams: [],
667
+ queryParams: ["async"]
668
+ },
669
+ "submit-session-tool-outputs": {
670
+ serviceClass: "Sessions",
671
+ operationId: "submitSessionToolOutputs",
672
+ pathParams: [],
673
+ queryParams: []
674
+ },
675
+ "get-session-tags": {
676
+ serviceClass: "Sessions",
677
+ operationId: "getSessionTags",
678
+ pathParams: [],
679
+ queryParams: []
680
+ },
681
+ "replace-session-tags": {
682
+ serviceClass: "Sessions",
683
+ operationId: "replaceSessionTags",
684
+ pathParams: [],
685
+ queryParams: []
686
+ },
687
+ "merge-session-tags": {
688
+ serviceClass: "Sessions",
689
+ operationId: "mergeSessionTags",
690
+ pathParams: [],
691
+ queryParams: []
692
+ },
693
+ "list-users": {
694
+ serviceClass: "Users",
695
+ operationId: "listUsers",
696
+ pathParams: [],
697
+ queryParams: []
698
+ },
699
+ "create-user": {
700
+ serviceClass: "Users",
701
+ operationId: "createUser",
702
+ pathParams: [],
703
+ queryParams: []
704
+ },
705
+ "get-user": {
706
+ serviceClass: "Users",
707
+ operationId: "getUser",
708
+ pathParams: ["id"],
709
+ queryParams: []
710
+ },
711
+ "delete-user": {
712
+ serviceClass: "Users",
713
+ operationId: "deleteUser",
714
+ pathParams: ["id"],
715
+ queryParams: []
716
+ },
717
+ "bootstrap-user": {
718
+ serviceClass: "Users",
719
+ operationId: "bootstrapUser",
720
+ pathParams: [],
721
+ queryParams: []
722
+ },
723
+ "login-user": {
724
+ serviceClass: "Users",
725
+ operationId: "loginUser",
726
+ pathParams: [],
727
+ queryParams: []
728
+ },
729
+ "get-user-policies": {
730
+ serviceClass: "Users",
731
+ operationId: "getUserPolicies",
732
+ pathParams: ["userId"],
733
+ queryParams: []
734
+ },
735
+ "attach-user-policies": {
736
+ serviceClass: "Users",
737
+ operationId: "attachUserPolicies",
738
+ pathParams: ["userId"],
739
+ queryParams: []
740
+ },
741
+ "list-webhooks": {
742
+ serviceClass: "Webhooks",
743
+ operationId: "listWebhooks",
744
+ pathParams: ["projectId"],
745
+ queryParams: []
746
+ },
747
+ "create-webhook": {
748
+ serviceClass: "Webhooks",
749
+ operationId: "createWebhook",
750
+ pathParams: ["projectId"],
751
+ queryParams: []
752
+ },
753
+ "get-webhook": {
754
+ serviceClass: "Webhooks",
755
+ operationId: "getWebhook",
756
+ pathParams: ["projectId", "webhookId"],
757
+ queryParams: []
758
+ },
759
+ "update-webhook": {
760
+ serviceClass: "Webhooks",
761
+ operationId: "updateWebhook",
762
+ pathParams: ["projectId", "webhookId"],
763
+ queryParams: []
764
+ },
765
+ "delete-webhook": {
766
+ serviceClass: "Webhooks",
767
+ operationId: "deleteWebhook",
768
+ pathParams: ["projectId", "webhookId"],
769
+ queryParams: []
770
+ },
771
+ "list-webhook-deliveries": {
772
+ serviceClass: "Webhooks",
773
+ operationId: "listWebhookDeliveries",
774
+ pathParams: ["projectId", "webhookId"],
775
+ queryParams: ["limit", "offset"]
776
+ },
777
+ "get-webhook-delivery": {
778
+ serviceClass: "Webhooks",
779
+ operationId: "getWebhookDelivery",
780
+ pathParams: ["projectId", "webhookId", "deliveryId"],
781
+ queryParams: []
782
+ },
783
+ "rotate-webhook-secret": {
784
+ serviceClass: "Webhooks",
785
+ operationId: "rotateWebhookSecret",
786
+ pathParams: ["projectId", "webhookId"],
787
+ queryParams: []
788
+ }
26
789
  };
27
790
 
28
791
  // src/index.ts
29
- program.name("soat").description("SOAT CLI - Command Line Interface for SOAT").version(package_default.version);
30
- program.action(() => {
31
- console.log("Work is in progress");
792
+ var kebabToCamel = /* @__PURE__ */__name(s => {
793
+ return s.replace(/-([a-z])/g, (_, c) => {
794
+ return c.toUpperCase();
795
+ });
796
+ }, "kebabToCamel");
797
+ var parseUnknown = /* @__PURE__ */__name(args => {
798
+ const result = {};
799
+ for (let i = 0; i < args.length; i++) {
800
+ const arg = args[i];
801
+ if (arg?.startsWith("--")) {
802
+ const key = arg.slice(2);
803
+ const val = args[i + 1];
804
+ if (val !== void 0 && !val.startsWith("--")) {
805
+ result[key] = val;
806
+ i++;
807
+ } else {
808
+ result[key] = "true";
809
+ }
810
+ }
811
+ }
812
+ return result;
813
+ }, "parseUnknown");
814
+ var parseFlagValue = /* @__PURE__ */__name(value => {
815
+ const trimmed = value.trim();
816
+ if (trimmed.startsWith("{") || trimmed.startsWith("[") || trimmed === "true" || trimmed === "false" || trimmed === "null" || /^-?\d+(\.\d+)?$/.test(trimmed)) {
817
+ try {
818
+ return JSON.parse(trimmed);
819
+ } catch {
820
+ return value;
821
+ }
822
+ }
823
+ return value;
824
+ }, "parseFlagValue");
825
+ var normalizeSymbol = /* @__PURE__ */__name(name => {
826
+ return name.toLowerCase().replace(/[^a-z0-9]/g, "");
827
+ }, "normalizeSymbol");
828
+ var resolveServiceClass = /* @__PURE__ */__name(serviceClassName => {
829
+ const sdkExports = sdk;
830
+ const exactMatch = sdkExports[serviceClassName];
831
+ if (exactMatch) return exactMatch;
832
+ const normalizedTarget = normalizeSymbol(serviceClassName);
833
+ const fuzzyMatches = Object.entries(sdkExports).filter(([exportName, value]) => {
834
+ return Boolean(value) && normalizeSymbol(exportName) === normalizedTarget;
835
+ });
836
+ if (fuzzyMatches.length === 1) {
837
+ return fuzzyMatches[0][1];
838
+ }
839
+ return void 0;
840
+ }, "resolveServiceClass");
841
+ program.name("soat").description("SOAT CLI").version(package_default.version).option("-p, --profile <name>", "config profile to use");
842
+ program.command("configure").description("Save credentials to a named profile (~/.soat/config.json)").option("-p, --profile <name>", "profile name", "default").action(async opts => {
843
+ const baseUrl = await input({
844
+ message: "Base URL:"
845
+ });
846
+ const token = await password({
847
+ message: "Token (hidden):"
848
+ });
849
+ writeProfile(opts.profile, {
850
+ baseUrl,
851
+ token
852
+ });
853
+ console.log(`Profile "${opts.profile}" saved.`);
854
+ });
855
+ program.command("list-commands").description("List all available API commands").action(() => {
856
+ const pad = Math.max(...Object.keys(routes).map(k => {
857
+ return k.length;
858
+ }));
859
+ for (const [cmd, r] of Object.entries(routes).sort()) {
860
+ console.log(` ${cmd.padEnd(pad)} ${r.serviceClass}.${r.operationId}`);
861
+ }
862
+ });
863
+ program.argument("[command]", "API command in kebab-case (e.g. list-actors)").argument("[args...]").allowUnknownOption().action(async commandName => {
864
+ if (!commandName) {
865
+ program.help();
866
+ return;
867
+ }
868
+ const route = routes[commandName];
869
+ if (!route) {
870
+ console.error(`Unknown command: ${commandName}`);
871
+ console.error(`Run "soat list-commands" to see all available commands.`);
872
+ process.exit(1);
873
+ }
874
+ const rawIdx = process.argv.indexOf(commandName);
875
+ const rawArgs = rawIdx >= 0 ? process.argv.slice(rawIdx + 1) : [];
876
+ const flags = parseUnknown(rawArgs);
877
+ const pathArgs = {};
878
+ const queryArgs = {};
879
+ const bodyArgs = {};
880
+ for (const [flagKey, val] of Object.entries(flags)) {
881
+ if (flagKey === "profile") continue;
882
+ const camel = kebabToCamel(flagKey);
883
+ const parsedValue = parseFlagValue(val);
884
+ if (route.pathParams.includes(flagKey)) {
885
+ pathArgs[camel] = parsedValue;
886
+ } else if (route.queryParams.includes(flagKey)) {
887
+ queryArgs[camel] = parsedValue;
888
+ } else {
889
+ bodyArgs[camel] = parsedValue;
890
+ }
891
+ }
892
+ const profileOpt = flags["profile"] ?? program.opts().profile;
893
+ const client = resolveClient(profileOpt);
894
+ const serviceClass = resolveServiceClass(route.serviceClass);
895
+ if (!serviceClass) {
896
+ console.error(`SDK class "${route.serviceClass}" not found.`);
897
+ process.exit(1);
898
+ }
899
+ const method = serviceClass[route.operationId];
900
+ if (typeof method !== "function") {
901
+ console.error(`Method "${route.operationId}" not found on ${route.serviceClass}.`);
902
+ process.exit(1);
903
+ }
904
+ const callOpts = {
905
+ client
906
+ };
907
+ if (Object.keys(pathArgs).length) callOpts["path"] = pathArgs;
908
+ if (Object.keys(queryArgs).length) callOpts["query"] = queryArgs;
909
+ if (Object.keys(bodyArgs).length) callOpts["body"] = bodyArgs;
910
+ const result = await method(callOpts);
911
+ if (result.error) {
912
+ const status = result.response && "status" in result.response ? result.response.status : void 0;
913
+ console.error(JSON.stringify({
914
+ status,
915
+ error: result.error
916
+ }, null, 2));
917
+ process.exit(1);
918
+ }
919
+ console.log(JSON.stringify(result.data, null, 2));
32
920
  });
33
921
  program.parse();
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "@soat/cli",
3
- "version": "0.0.1",
4
- "scripts": {
5
- "build": "tsup",
6
- "test": "jest --projects tests/unit"
7
- },
3
+ "version": "0.4.3",
4
+ "type": "module",
8
5
  "dependencies": {
9
- "@ttoss/logger": "^0.7.1",
10
- "commander": "^14.0.2"
6
+ "@inquirer/input": "^5.0.12",
7
+ "@inquirer/password": "^5.0.12",
8
+ "@ttoss/logger": "^0.8.10",
9
+ "commander": "^14.0.3",
10
+ "@soat/sdk": "0.4.3"
11
11
  },
12
12
  "devDependencies": {
13
- "@ttoss/config": "^1.35.12",
13
+ "@ttoss/config": "^1.37.10",
14
14
  "@types/jest": "^30.0.0",
15
- "jest": "^30.2.0",
15
+ "@types/js-yaml": "^4.0.9",
16
+ "jest": "^30.3.0",
17
+ "js-yaml": "^4.1.1",
16
18
  "tsup": "^8.5.1",
17
19
  "tsx": "^4.21.0"
18
20
  },
@@ -20,8 +22,17 @@
20
22
  "dist",
21
23
  "bin"
22
24
  ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/ttoss/soat"
28
+ },
23
29
  "bin": "./bin/soat",
24
30
  "publishConfig": {
25
- "access": "public"
31
+ "access": "public",
32
+ "provenance": true
33
+ },
34
+ "scripts": {
35
+ "generate": "tsx scripts/generate.ts",
36
+ "build": "pnpm generate && tsup"
26
37
  }
27
- }
38
+ }
package/dist/index.d.mts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/index.js DELETED
@@ -1,34 +0,0 @@
1
- /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- "use strict";
3
-
4
- // src/index.ts
5
- var import_commander = require("commander");
6
-
7
- // package.json
8
- var package_default = {
9
- name: "soat",
10
- version: "0.0.1",
11
- scripts: {
12
- build: "tsup",
13
- test: "jest --projects tests/unit"
14
- },
15
- dependencies: {
16
- commander: "^14.0.2"
17
- },
18
- devDependencies: {
19
- "@ttoss/config": "^1.35.12",
20
- "@types/jest": "^30.0.0",
21
- jest: "^30.2.0",
22
- tsup: "^8.5.1",
23
- tsx: "^4.21.0"
24
- },
25
- files: ["dist"],
26
- bin: "./bin/soat"
27
- };
28
-
29
- // src/index.ts
30
- import_commander.program.name("soat").description("SOAT CLI - Command Line Interface for SOAT").version(package_default.version);
31
- import_commander.program.action(() => {
32
- console.log("Work is in progress");
33
- });
34
- import_commander.program.parse();