@curviate/cli 0.47.0 → 0.48.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +174 -1
  2. package/README.md +101 -87
  3. package/dist/{account-RFJ63QYL.js → account-WKQHMM7P.js} +39 -29
  4. package/dist/chunk-AYKKXGTR.js +1141 -0
  5. package/dist/{chunk-TC4ZPUWI.js → chunk-CVMSQ3OF.js} +19 -80
  6. package/dist/{chunk-HOQ7EUHJ.js → chunk-FDJMAF7D.js} +1 -0
  7. package/dist/chunk-GQKC6E5K.js +36 -0
  8. package/dist/{chunk-V3MVOVQT.js → chunk-MKGVNDMJ.js} +8 -1
  9. package/dist/chunk-NNV2OYEF.js +23 -0
  10. package/dist/{chunk-UJOTQPL6.js → chunk-OHXYFICP.js} +47 -14
  11. package/dist/{chunk-PD2I5TYC.js → chunk-Q63IIPL2.js} +2 -2
  12. package/dist/chunk-TSOIZBBU.js +41 -0
  13. package/dist/{chunk-ERBYEC5P.js → chunk-Y7K4UBFC.js} +1 -1
  14. package/dist/{chunk-FXYK2GTO.js → chunk-YFXLXION.js} +37 -32
  15. package/dist/chunk-ZYURL5VK.js +83 -0
  16. package/dist/cli.js +76 -97
  17. package/dist/{comment-MCXE7B7V.js → comment-7IQ6ZOJF.js} +27 -22
  18. package/dist/{company-EUUN372H.js → company-RD7RDGSA.js} +55 -50
  19. package/dist/{config-K4G3VSBA.js → config-EYBNYRGK.js} +13 -5
  20. package/dist/{connect-2AL7XVJO.js → connect-HVXT67A6.js} +35 -31
  21. package/dist/core-6XYGUNAY.js +46 -0
  22. package/dist/{doctor-WPYI7X2T.js → doctor-HUXQERLQ.js} +8 -4
  23. package/dist/document-AUUCGST2.js +27 -0
  24. package/dist/{draft-G65DVXT7.js → draft-DFO22K6Q.js} +26 -21
  25. package/dist/examples-64YT5V5K.js +53 -0
  26. package/dist/{feed-HV24WME4.js → feed-JWP6ANPI.js} +13 -9
  27. package/dist/{group-HADXNVJW.js → group-SIQFJEZV.js} +15 -11
  28. package/dist/{inbox-G3EE54OB.js → inbox-MMIMCA5O.js} +21 -17
  29. package/dist/{inboxes-237XOBTP.js → inboxes-RND3D4C7.js} +16 -12
  30. package/dist/{job-LIN6RWD7.js → job-ACFKBLFK.js} +29 -25
  31. package/dist/{login-OHAHNBRW.js → login-ZOB5KVKQ.js} +10 -5
  32. package/dist/{message-U2O2JQSW.js → message-OFK6UVXR.js} +9 -7
  33. package/dist/{notification-3VG32LWM.js → notification-KKGAZU7M.js} +17 -13
  34. package/dist/{post-ECDK2KJL.js → post-A5SBCFB2.js} +33 -28
  35. package/dist/{profile-JOHS6SDW.js → profile-4SOOQZ4K.js} +45 -41
  36. package/dist/{recruiter-7VXEIXN3.js → recruiter-YN73STDP.js} +123 -120
  37. package/dist/{sales-nav-K4BMBH7R.js → sales-nav-JXF5RY2K.js} +38 -32
  38. package/dist/{search-C2UYO6PI.js → search-JAL242A2.js} +58 -48
  39. package/dist/{setup-GYEZFDEN.js → setup-WICWH4JG.js} +13 -8
  40. package/dist/{webhook-KCOQOH7D.js → webhook-UGKVYWBC.js} +34 -36
  41. package/package.json +1 -1
  42. package/dist/chunk-KJ24DIAJ.js +0 -60
  43. package/dist/examples-IJL3A6SZ.js +0 -18
@@ -0,0 +1,1141 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ editDistance
4
+ } from "./chunk-FDJMAF7D.js";
5
+ import {
6
+ isStdinToken
7
+ } from "./chunk-ZYURL5VK.js";
8
+
9
+ // src/lib/document.ts
10
+ import { closeSync, openSync, readSync, statSync } from "fs";
11
+
12
+ // src/schemas/documents.json
13
+ var documents_default = {
14
+ "core recruiter job create": {
15
+ type: "object",
16
+ properties: {
17
+ job_title: {
18
+ type: "object",
19
+ properties: {
20
+ id: {
21
+ type: "string",
22
+ minLength: 1
23
+ },
24
+ name: {
25
+ type: "string",
26
+ minLength: 1
27
+ }
28
+ },
29
+ required: [
30
+ "id",
31
+ "name"
32
+ ],
33
+ additionalProperties: false
34
+ },
35
+ company: {
36
+ oneOf: [
37
+ {
38
+ type: "object",
39
+ properties: {
40
+ id: {
41
+ type: "string",
42
+ minLength: 1
43
+ }
44
+ },
45
+ required: [
46
+ "id"
47
+ ],
48
+ additionalProperties: false
49
+ },
50
+ {
51
+ type: "object",
52
+ properties: {
53
+ name: {
54
+ type: "string",
55
+ minLength: 1
56
+ }
57
+ },
58
+ required: [
59
+ "name"
60
+ ],
61
+ additionalProperties: false
62
+ }
63
+ ]
64
+ },
65
+ workplace_type: {
66
+ type: "string",
67
+ enum: [
68
+ "ON_SITE",
69
+ "HYBRID",
70
+ "REMOTE"
71
+ ]
72
+ },
73
+ location: {
74
+ type: "string",
75
+ minLength: 1
76
+ },
77
+ employment_status: {
78
+ type: "string",
79
+ enum: [
80
+ "FULL_TIME",
81
+ "PART_TIME",
82
+ "CONTRACT",
83
+ "TEMPORARY",
84
+ "OTHER",
85
+ "VOLUNTEER",
86
+ "INTERNSHIP"
87
+ ]
88
+ },
89
+ seniority_level: {
90
+ type: "string",
91
+ enum: [
92
+ "INTERNSHIP",
93
+ "ENTRY_LEVEL",
94
+ "ASSOCIATE",
95
+ "MID_SENIOR_LEVEL",
96
+ "DIRECTOR",
97
+ "EXECUTIVE",
98
+ "NOT_APPLICABLE"
99
+ ]
100
+ },
101
+ description: {
102
+ type: "string",
103
+ minLength: 200
104
+ },
105
+ industry: {
106
+ type: "array",
107
+ items: {
108
+ type: "string",
109
+ minLength: 1
110
+ }
111
+ },
112
+ job_function: {
113
+ type: "array",
114
+ items: {
115
+ type: "string",
116
+ minLength: 1
117
+ }
118
+ },
119
+ apply_method: {
120
+ oneOf: [
121
+ {
122
+ type: "object",
123
+ properties: {
124
+ method: {
125
+ type: "string",
126
+ const: "linkedin"
127
+ },
128
+ notification_email: {
129
+ type: "string"
130
+ },
131
+ resume_required: {
132
+ type: "boolean"
133
+ }
134
+ },
135
+ required: [
136
+ "method",
137
+ "notification_email"
138
+ ],
139
+ additionalProperties: false
140
+ },
141
+ {
142
+ type: "object",
143
+ properties: {
144
+ method: {
145
+ type: "string",
146
+ const: "external"
147
+ },
148
+ website_url: {
149
+ type: "string",
150
+ minLength: 1
151
+ }
152
+ },
153
+ required: [
154
+ "method",
155
+ "website_url"
156
+ ],
157
+ additionalProperties: false
158
+ }
159
+ ],
160
+ discriminator: {
161
+ propertyName: "method",
162
+ mapping: {
163
+ linkedin: "#/oneOf/0",
164
+ external: "#/oneOf/1"
165
+ }
166
+ }
167
+ },
168
+ skills: {
169
+ type: "array",
170
+ items: {
171
+ type: "string",
172
+ minLength: 1
173
+ }
174
+ },
175
+ include_poster_info: {
176
+ type: "boolean"
177
+ },
178
+ tracking_pixel_url: {
179
+ type: "string",
180
+ minLength: 1
181
+ },
182
+ company_job_id: {
183
+ type: "string",
184
+ minLength: 1
185
+ },
186
+ screening_questions: {
187
+ type: "array",
188
+ items: {
189
+ type: "object",
190
+ properties: {
191
+ question: {
192
+ type: "string",
193
+ minLength: 1
194
+ },
195
+ answer_type: {
196
+ type: "string",
197
+ minLength: 1
198
+ },
199
+ qualification_required: {
200
+ type: "boolean"
201
+ }
202
+ },
203
+ required: [
204
+ "question",
205
+ "answer_type"
206
+ ],
207
+ additionalProperties: false
208
+ }
209
+ },
210
+ salary: {
211
+ type: "object",
212
+ properties: {
213
+ currency: {
214
+ type: "string",
215
+ minLength: 1
216
+ },
217
+ pay_frequency: {
218
+ type: "string",
219
+ enum: [
220
+ "YEARLY",
221
+ "MONTHLY",
222
+ "HOURLY"
223
+ ]
224
+ },
225
+ min: {
226
+ type: "number",
227
+ minimum: 0
228
+ },
229
+ max: {
230
+ type: "number",
231
+ minimum: 0
232
+ }
233
+ },
234
+ required: [
235
+ "currency",
236
+ "pay_frequency",
237
+ "min",
238
+ "max"
239
+ ],
240
+ additionalProperties: false
241
+ },
242
+ additional_compensation: {
243
+ type: "object",
244
+ properties: {
245
+ currency: {
246
+ type: "string",
247
+ minLength: 1
248
+ },
249
+ pay_frequency: {
250
+ type: "string",
251
+ enum: [
252
+ "YEARLY",
253
+ "MONTHLY",
254
+ "HOURLY"
255
+ ]
256
+ },
257
+ min: {
258
+ type: "number",
259
+ minimum: 0
260
+ },
261
+ max: {
262
+ type: "number",
263
+ minimum: 0
264
+ }
265
+ },
266
+ required: [
267
+ "currency",
268
+ "pay_frequency",
269
+ "min",
270
+ "max"
271
+ ],
272
+ additionalProperties: false
273
+ },
274
+ rejection_settings: {
275
+ type: "object",
276
+ properties: {
277
+ send_rejection_notification: {
278
+ type: "boolean"
279
+ },
280
+ rejection_template: {
281
+ type: "string",
282
+ minLength: 1
283
+ },
284
+ reject_unqualified_applicants: {
285
+ type: "boolean"
286
+ },
287
+ reject_out_of_country_applicants: {
288
+ type: "boolean"
289
+ }
290
+ },
291
+ required: [
292
+ "send_rejection_notification"
293
+ ],
294
+ additionalProperties: false
295
+ },
296
+ project_name: {
297
+ type: "string",
298
+ minLength: 1
299
+ }
300
+ },
301
+ required: [
302
+ "job_title",
303
+ "company",
304
+ "workplace_type",
305
+ "location",
306
+ "employment_status",
307
+ "seniority_level",
308
+ "description",
309
+ "industry",
310
+ "job_function",
311
+ "apply_method",
312
+ "project_name"
313
+ ],
314
+ additionalProperties: false
315
+ },
316
+ "core recruiter project-job create": {
317
+ type: "object",
318
+ properties: {
319
+ job_title: {
320
+ type: "object",
321
+ properties: {
322
+ id: {
323
+ type: "string",
324
+ minLength: 1
325
+ },
326
+ name: {
327
+ type: "string",
328
+ minLength: 1
329
+ }
330
+ },
331
+ required: [
332
+ "id",
333
+ "name"
334
+ ],
335
+ additionalProperties: false
336
+ },
337
+ company: {
338
+ oneOf: [
339
+ {
340
+ type: "object",
341
+ properties: {
342
+ id: {
343
+ type: "string",
344
+ minLength: 1
345
+ }
346
+ },
347
+ required: [
348
+ "id"
349
+ ],
350
+ additionalProperties: false
351
+ },
352
+ {
353
+ type: "object",
354
+ properties: {
355
+ name: {
356
+ type: "string",
357
+ minLength: 1
358
+ }
359
+ },
360
+ required: [
361
+ "name"
362
+ ],
363
+ additionalProperties: false
364
+ }
365
+ ]
366
+ },
367
+ workplace_type: {
368
+ type: "string",
369
+ enum: [
370
+ "ON_SITE",
371
+ "HYBRID",
372
+ "REMOTE"
373
+ ]
374
+ },
375
+ location: {
376
+ type: "string",
377
+ minLength: 1
378
+ },
379
+ employment_status: {
380
+ type: "string",
381
+ enum: [
382
+ "FULL_TIME",
383
+ "PART_TIME",
384
+ "CONTRACT",
385
+ "TEMPORARY",
386
+ "OTHER",
387
+ "VOLUNTEER",
388
+ "INTERNSHIP"
389
+ ]
390
+ },
391
+ seniority_level: {
392
+ type: "string",
393
+ enum: [
394
+ "INTERNSHIP",
395
+ "ENTRY_LEVEL",
396
+ "ASSOCIATE",
397
+ "MID_SENIOR_LEVEL",
398
+ "DIRECTOR",
399
+ "EXECUTIVE",
400
+ "NOT_APPLICABLE"
401
+ ]
402
+ },
403
+ description: {
404
+ type: "string",
405
+ minLength: 200
406
+ },
407
+ industry: {
408
+ type: "array",
409
+ items: {
410
+ type: "string",
411
+ minLength: 1
412
+ }
413
+ },
414
+ job_function: {
415
+ type: "array",
416
+ items: {
417
+ type: "string",
418
+ minLength: 1
419
+ }
420
+ },
421
+ apply_method: {
422
+ oneOf: [
423
+ {
424
+ type: "object",
425
+ properties: {
426
+ method: {
427
+ type: "string",
428
+ const: "linkedin"
429
+ },
430
+ notification_email: {
431
+ type: "string"
432
+ },
433
+ resume_required: {
434
+ type: "boolean"
435
+ }
436
+ },
437
+ required: [
438
+ "method",
439
+ "notification_email"
440
+ ],
441
+ additionalProperties: false
442
+ },
443
+ {
444
+ type: "object",
445
+ properties: {
446
+ method: {
447
+ type: "string",
448
+ const: "external"
449
+ },
450
+ website_url: {
451
+ type: "string",
452
+ minLength: 1
453
+ }
454
+ },
455
+ required: [
456
+ "method",
457
+ "website_url"
458
+ ],
459
+ additionalProperties: false
460
+ }
461
+ ],
462
+ discriminator: {
463
+ propertyName: "method",
464
+ mapping: {
465
+ linkedin: "#/oneOf/0",
466
+ external: "#/oneOf/1"
467
+ }
468
+ }
469
+ },
470
+ skills: {
471
+ type: "array",
472
+ items: {
473
+ type: "string",
474
+ minLength: 1
475
+ }
476
+ },
477
+ include_poster_info: {
478
+ type: "boolean"
479
+ },
480
+ tracking_pixel_url: {
481
+ type: "string",
482
+ minLength: 1
483
+ },
484
+ company_job_id: {
485
+ type: "string",
486
+ minLength: 1
487
+ },
488
+ screening_questions: {
489
+ type: "array",
490
+ items: {
491
+ type: "object",
492
+ properties: {
493
+ question: {
494
+ type: "string",
495
+ minLength: 1
496
+ },
497
+ answer_type: {
498
+ type: "string",
499
+ minLength: 1
500
+ },
501
+ qualification_required: {
502
+ type: "boolean"
503
+ }
504
+ },
505
+ required: [
506
+ "question",
507
+ "answer_type"
508
+ ],
509
+ additionalProperties: false
510
+ }
511
+ },
512
+ salary: {
513
+ type: "object",
514
+ properties: {
515
+ currency: {
516
+ type: "string",
517
+ minLength: 1
518
+ },
519
+ pay_frequency: {
520
+ type: "string",
521
+ enum: [
522
+ "YEARLY",
523
+ "MONTHLY",
524
+ "HOURLY"
525
+ ]
526
+ },
527
+ min: {
528
+ type: "number",
529
+ minimum: 0
530
+ },
531
+ max: {
532
+ type: "number",
533
+ minimum: 0
534
+ }
535
+ },
536
+ required: [
537
+ "currency",
538
+ "pay_frequency",
539
+ "min",
540
+ "max"
541
+ ],
542
+ additionalProperties: false
543
+ },
544
+ additional_compensation: {
545
+ type: "object",
546
+ properties: {
547
+ currency: {
548
+ type: "string",
549
+ minLength: 1
550
+ },
551
+ pay_frequency: {
552
+ type: "string",
553
+ enum: [
554
+ "YEARLY",
555
+ "MONTHLY",
556
+ "HOURLY"
557
+ ]
558
+ },
559
+ min: {
560
+ type: "number",
561
+ minimum: 0
562
+ },
563
+ max: {
564
+ type: "number",
565
+ minimum: 0
566
+ }
567
+ },
568
+ required: [
569
+ "currency",
570
+ "pay_frequency",
571
+ "min",
572
+ "max"
573
+ ],
574
+ additionalProperties: false
575
+ },
576
+ rejection_settings: {
577
+ type: "object",
578
+ properties: {
579
+ send_rejection_notification: {
580
+ type: "boolean"
581
+ },
582
+ rejection_template: {
583
+ type: "string",
584
+ minLength: 1
585
+ },
586
+ reject_unqualified_applicants: {
587
+ type: "boolean"
588
+ },
589
+ reject_out_of_country_applicants: {
590
+ type: "boolean"
591
+ }
592
+ },
593
+ required: [
594
+ "send_rejection_notification"
595
+ ],
596
+ additionalProperties: false
597
+ }
598
+ },
599
+ required: [
600
+ "job_title",
601
+ "company",
602
+ "workplace_type",
603
+ "location",
604
+ "employment_status",
605
+ "seniority_level",
606
+ "description",
607
+ "industry",
608
+ "job_function",
609
+ "apply_method"
610
+ ],
611
+ additionalProperties: false
612
+ },
613
+ "core recruiter project-job update": {
614
+ type: "object",
615
+ properties: {
616
+ job_title: {
617
+ type: "object",
618
+ properties: {
619
+ id: {
620
+ type: "string",
621
+ minLength: 1
622
+ },
623
+ name: {
624
+ type: "string",
625
+ minLength: 1
626
+ }
627
+ },
628
+ required: [
629
+ "id",
630
+ "name"
631
+ ],
632
+ additionalProperties: false
633
+ },
634
+ company: {
635
+ oneOf: [
636
+ {
637
+ type: "object",
638
+ properties: {
639
+ id: {
640
+ type: "string",
641
+ minLength: 1
642
+ }
643
+ },
644
+ required: [
645
+ "id"
646
+ ],
647
+ additionalProperties: false
648
+ },
649
+ {
650
+ type: "object",
651
+ properties: {
652
+ name: {
653
+ type: "string",
654
+ minLength: 1
655
+ }
656
+ },
657
+ required: [
658
+ "name"
659
+ ],
660
+ additionalProperties: false
661
+ }
662
+ ]
663
+ },
664
+ workplace_type: {
665
+ type: "string",
666
+ enum: [
667
+ "ON_SITE",
668
+ "HYBRID",
669
+ "REMOTE"
670
+ ]
671
+ },
672
+ location: {
673
+ type: "string",
674
+ minLength: 1
675
+ },
676
+ employment_status: {
677
+ type: "string",
678
+ enum: [
679
+ "FULL_TIME",
680
+ "PART_TIME",
681
+ "CONTRACT",
682
+ "TEMPORARY",
683
+ "OTHER",
684
+ "VOLUNTEER",
685
+ "INTERNSHIP"
686
+ ]
687
+ },
688
+ seniority_level: {
689
+ type: "string",
690
+ enum: [
691
+ "INTERNSHIP",
692
+ "ENTRY_LEVEL",
693
+ "ASSOCIATE",
694
+ "MID_SENIOR_LEVEL",
695
+ "DIRECTOR",
696
+ "EXECUTIVE",
697
+ "NOT_APPLICABLE"
698
+ ]
699
+ },
700
+ description: {
701
+ type: "string",
702
+ minLength: 200
703
+ },
704
+ industry: {
705
+ type: "array",
706
+ items: {
707
+ type: "string",
708
+ minLength: 1
709
+ }
710
+ },
711
+ job_function: {
712
+ type: "array",
713
+ items: {
714
+ type: "string",
715
+ minLength: 1
716
+ }
717
+ },
718
+ apply_method: {
719
+ oneOf: [
720
+ {
721
+ type: "object",
722
+ properties: {
723
+ method: {
724
+ type: "string",
725
+ const: "linkedin"
726
+ },
727
+ notification_email: {
728
+ type: "string"
729
+ },
730
+ resume_required: {
731
+ type: "boolean"
732
+ }
733
+ },
734
+ required: [
735
+ "method",
736
+ "notification_email"
737
+ ],
738
+ additionalProperties: false
739
+ },
740
+ {
741
+ type: "object",
742
+ properties: {
743
+ method: {
744
+ type: "string",
745
+ const: "external"
746
+ },
747
+ website_url: {
748
+ type: "string",
749
+ minLength: 1
750
+ }
751
+ },
752
+ required: [
753
+ "method",
754
+ "website_url"
755
+ ],
756
+ additionalProperties: false
757
+ }
758
+ ],
759
+ discriminator: {
760
+ propertyName: "method",
761
+ mapping: {
762
+ linkedin: "#/oneOf/0",
763
+ external: "#/oneOf/1"
764
+ }
765
+ }
766
+ },
767
+ skills: {
768
+ type: "array",
769
+ items: {
770
+ type: "string",
771
+ minLength: 1
772
+ }
773
+ },
774
+ include_poster_info: {
775
+ type: "boolean"
776
+ },
777
+ tracking_pixel_url: {
778
+ type: "string",
779
+ minLength: 1
780
+ },
781
+ company_job_id: {
782
+ type: "string",
783
+ minLength: 1
784
+ },
785
+ screening_questions: {
786
+ type: "array",
787
+ items: {
788
+ type: "object",
789
+ properties: {
790
+ question: {
791
+ type: "string",
792
+ minLength: 1
793
+ },
794
+ answer_type: {
795
+ type: "string",
796
+ minLength: 1
797
+ },
798
+ qualification_required: {
799
+ type: "boolean"
800
+ }
801
+ },
802
+ required: [
803
+ "question",
804
+ "answer_type"
805
+ ],
806
+ additionalProperties: false
807
+ }
808
+ },
809
+ salary: {
810
+ type: "object",
811
+ properties: {
812
+ currency: {
813
+ type: "string",
814
+ minLength: 1
815
+ },
816
+ pay_frequency: {
817
+ type: "string",
818
+ enum: [
819
+ "YEARLY",
820
+ "MONTHLY",
821
+ "HOURLY"
822
+ ]
823
+ },
824
+ min: {
825
+ type: "number",
826
+ minimum: 0
827
+ },
828
+ max: {
829
+ type: "number",
830
+ minimum: 0
831
+ }
832
+ },
833
+ required: [
834
+ "currency",
835
+ "pay_frequency",
836
+ "min",
837
+ "max"
838
+ ],
839
+ additionalProperties: false
840
+ },
841
+ additional_compensation: {
842
+ type: "object",
843
+ properties: {
844
+ currency: {
845
+ type: "string",
846
+ minLength: 1
847
+ },
848
+ pay_frequency: {
849
+ type: "string",
850
+ enum: [
851
+ "YEARLY",
852
+ "MONTHLY",
853
+ "HOURLY"
854
+ ]
855
+ },
856
+ min: {
857
+ type: "number",
858
+ minimum: 0
859
+ },
860
+ max: {
861
+ type: "number",
862
+ minimum: 0
863
+ }
864
+ },
865
+ required: [
866
+ "currency",
867
+ "pay_frequency",
868
+ "min",
869
+ "max"
870
+ ],
871
+ additionalProperties: false
872
+ },
873
+ rejection_settings: {
874
+ type: "object",
875
+ properties: {
876
+ send_rejection_notification: {
877
+ type: "boolean"
878
+ },
879
+ rejection_template: {
880
+ type: "string",
881
+ minLength: 1
882
+ },
883
+ reject_unqualified_applicants: {
884
+ type: "boolean"
885
+ },
886
+ reject_out_of_country_applicants: {
887
+ type: "boolean"
888
+ }
889
+ },
890
+ required: [
891
+ "send_rejection_notification"
892
+ ],
893
+ additionalProperties: false
894
+ }
895
+ },
896
+ additionalProperties: false
897
+ }
898
+ };
899
+
900
+ // src/lib/document.ts
901
+ var ENFORCED = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties", "enum", "const", "minLength", "maxLength", "minimum", "maximum", "items", "minItems", "maxItems", "oneOf"]);
902
+ var ANNOTATIONS = /* @__PURE__ */ new Set(["description", "title", "default", "discriminator"]);
903
+ function documentSchema(key) {
904
+ const s = documents_default[key];
905
+ if (!s) throw new Error(`no document schema for ${key}`);
906
+ return s;
907
+ }
908
+ var MAX_DOCUMENT_BYTES = 5 * 1024 * 1024;
909
+ var TOO_LARGE = (flag) => `--${flag}: larger than ${MAX_DOCUMENT_BYTES / 1024 / 1024} MiB, the most a document may be.`;
910
+ function readCapped(fd) {
911
+ const chunks = [];
912
+ let total = 0;
913
+ const buf = Buffer.alloc(64 * 1024);
914
+ for (; ; ) {
915
+ let n;
916
+ try {
917
+ n = readSync(fd, buf, 0, buf.length, null);
918
+ } catch (err) {
919
+ if (err.code === "EAGAIN") continue;
920
+ if (err.code === "EOF") break;
921
+ throw err;
922
+ }
923
+ if (n === 0) break;
924
+ total += n;
925
+ if (total > MAX_DOCUMENT_BYTES) return null;
926
+ chunks.push(Buffer.from(buf.subarray(0, n)));
927
+ }
928
+ return Buffer.concat(chunks);
929
+ }
930
+ async function readStdinCapped(flag = "file") {
931
+ const chunks = [];
932
+ let total = 0;
933
+ for await (const chunk of process.stdin) {
934
+ const b = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
935
+ total += b.length;
936
+ if (total > MAX_DOCUMENT_BYTES) usage(TOO_LARGE(flag));
937
+ chunks.push(b);
938
+ }
939
+ return decode(flag, Buffer.concat(chunks)).replace(/\n+$/, "");
940
+ }
941
+ function decode(flag, bytes) {
942
+ if (bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) usage(`--${flag}: starts with a byte order mark (BOM). Save it as UTF-8 without a BOM.`);
943
+ try {
944
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
945
+ } catch {
946
+ usage(`--${flag}: not valid UTF-8. Save it as UTF-8.`);
947
+ }
948
+ }
949
+ function usage(message) {
950
+ process.stderr.write(`error: ${message}
951
+ `);
952
+ process.exit(2);
953
+ }
954
+ async function readFileFlag(flag, value, io = {}) {
955
+ const v = value.trimStart();
956
+ if (v.startsWith("{") || v.startsWith("[")) {
957
+ usage(`--${flag} takes a path or -, not inline JSON. Pass the document on stdin: --${flag} - <<'EOF' ... EOF`);
958
+ }
959
+ let text;
960
+ if (isStdinToken(value)) {
961
+ const second = Object.entries(io.others ?? {}).find(([k, o]) => k !== flag && k !== "_" && isStdinToken(o));
962
+ if (second) usage(`--${flag} - and --${second[0]} - both read stdin. Only one input can come from stdin.`);
963
+ if (io.stdinIsTTY ?? process.stdin.isTTY) usage(`--${flag} -: stdin is a terminal. Pipe the document in or use a heredoc: --${flag} - <<'EOF' ... EOF`);
964
+ text = await (io.readStdin ?? (() => readStdinCapped(flag)))();
965
+ if (Buffer.byteLength(text) > MAX_DOCUMENT_BYTES) usage(TOO_LARGE(flag));
966
+ } else {
967
+ let isDir = false;
968
+ try {
969
+ isDir = statSync(value).isDirectory();
970
+ } catch {
971
+ usage(`--${flag}: no such file: ${value}`);
972
+ }
973
+ if (isDir) usage(`--${flag}: ${value} is a directory, not a file.`);
974
+ let bytes;
975
+ try {
976
+ const fd = openSync(value, "r");
977
+ try {
978
+ bytes = readCapped(fd);
979
+ } finally {
980
+ closeSync(fd);
981
+ }
982
+ } catch (err) {
983
+ usage(`--${flag}: cannot read ${value}: ${err.code ?? "read error"}.`);
984
+ }
985
+ if (bytes === null) usage(TOO_LARGE(flag));
986
+ text = decode(flag, bytes);
987
+ }
988
+ if (text.trim() === "") usage(`--${flag}: empty input.`);
989
+ return text;
990
+ }
991
+ function parseDocument(flag, text) {
992
+ try {
993
+ return JSON.parse(text);
994
+ } catch (err) {
995
+ const msg = err instanceof Error ? err.message : "";
996
+ const lc = /line (\d+) column (\d+)/.exec(msg);
997
+ const pos = /position (\d+)/.exec(msg);
998
+ let at = "";
999
+ if (lc) at = ` at line ${lc[1]}, column ${lc[2]}`;
1000
+ else {
1001
+ const before = text.slice(0, pos ? Number(pos[1]) : text.length).split("\n");
1002
+ at = ` at line ${before.length}, column ${before[before.length - 1].length + 1}`;
1003
+ }
1004
+ usage(`--${flag}: not valid JSON${at}.`);
1005
+ }
1006
+ }
1007
+ var own = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
1008
+ var typeOf = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
1009
+ var isType = (v, t) => t === "integer" ? Number.isInteger(v) : t === "number" ? typeof v === "number" : typeOf(v) === t;
1010
+ var join = (path, key) => path ? `${path}.${key}` : String(key);
1011
+ function assertKnown(schema) {
1012
+ for (const k of Object.keys(schema)) {
1013
+ if (!ENFORCED.has(k) && !ANNOTATIONS.has(k) && !k.startsWith("x-")) throw new Error(`document schema keyword not supported by the validator: ${k}`);
1014
+ }
1015
+ }
1016
+ function validate(schema, value, path = "") {
1017
+ assertKnown(schema);
1018
+ const at = path || "(document)";
1019
+ const out = [];
1020
+ if (Array.isArray(schema["oneOf"])) {
1021
+ const branches = schema["oneOf"];
1022
+ const disc = schema["discriminator"]?.propertyName;
1023
+ if (disc && value && typeof value === "object" && own(value, disc)) {
1024
+ const tag = value[disc];
1025
+ const hit = branches.find((b) => b["properties"]?.[disc]?.["const"] === tag);
1026
+ if (hit) return validate(hit, value, path);
1027
+ const tags = branches.map((b) => b["properties"]?.[disc]?.["const"]).join(", ");
1028
+ return [{ path: join(path, disc), rule: `must be one of ${tags}` }];
1029
+ }
1030
+ const results = branches.map((b) => validate(b, value, path));
1031
+ if (results.some((r) => r.length === 0)) return [];
1032
+ return [{ path: at, rule: `must match one of: ${branches.map(shape).join(" | ")}` }];
1033
+ }
1034
+ const t = schema["type"];
1035
+ if (t && !isType(value, t)) return [{ path: at, rule: `must be ${t === "array" || t === "object" || t === "integer" ? "an" : "a"} ${t}` }];
1036
+ if ("const" in schema && value !== schema["const"]) out.push({ path: at, rule: `must be ${JSON.stringify(schema["const"])}` });
1037
+ if (Array.isArray(schema["enum"]) && !schema["enum"].includes(value)) out.push({ path: at, rule: `must be one of ${schema["enum"].join(", ")}` });
1038
+ if (typeof value === "string") {
1039
+ if (typeof schema["minLength"] === "number" && value.length < schema["minLength"]) out.push({ path: at, rule: schema["minLength"] === 1 ? "must not be empty" : `must be at least ${schema["minLength"]} characters` });
1040
+ if (typeof schema["maxLength"] === "number" && value.length > schema["maxLength"]) out.push({ path: at, rule: `must be at most ${schema["maxLength"]} characters` });
1041
+ }
1042
+ if (typeof value === "number") {
1043
+ if (typeof schema["minimum"] === "number" && value < schema["minimum"]) out.push({ path: at, rule: `must be at least ${schema["minimum"]}` });
1044
+ if (typeof schema["maximum"] === "number" && value > schema["maximum"]) out.push({ path: at, rule: `must be at most ${schema["maximum"]}` });
1045
+ }
1046
+ if (Array.isArray(value)) {
1047
+ if (typeof schema["minItems"] === "number" && value.length < schema["minItems"]) out.push({ path: at, rule: `must have at least ${schema["minItems"]} items` });
1048
+ if (typeof schema["maxItems"] === "number" && value.length > schema["maxItems"]) out.push({ path: at, rule: `must have at most ${schema["maxItems"]} items` });
1049
+ if (schema["items"]) value.forEach((item, i) => out.push(...validate(schema["items"], item, join(path, i))));
1050
+ }
1051
+ if (value && typeof value === "object" && !Array.isArray(value)) {
1052
+ const props = schema["properties"] ?? {};
1053
+ const obj = value;
1054
+ for (const key of Object.keys(obj)) {
1055
+ if (own(props, key)) out.push(...validate(props[key], obj[key], join(path, key)));
1056
+ else if (schema["additionalProperties"] === false) {
1057
+ const near = Object.keys(props).filter((p) => editDistance(key, p) <= 2).sort((a, b) => editDistance(key, a) - editDistance(key, b))[0];
1058
+ out.push({ path: join(path, key), rule: "unknown field", ...near ? { suggestion: near } : {} });
1059
+ }
1060
+ }
1061
+ for (const req of schema["required"] ?? []) {
1062
+ if (!own(obj, req)) out.push({ path: join(path, req), rule: "required" });
1063
+ }
1064
+ }
1065
+ return out;
1066
+ }
1067
+ function shape(s) {
1068
+ const req = s["required"] ?? Object.keys(s["properties"] ?? {});
1069
+ return `{${req.join(", ")}}`;
1070
+ }
1071
+ function reportIssues(issues, json, out = process) {
1072
+ const line = (i) => `${i.path}: ${i.rule}${i.suggestion ? ` (did you mean ${i.suggestion}?)` : ""}`;
1073
+ const message = `The document has ${issues.length} problem${issues.length === 1 ? "" : "s"}.`;
1074
+ if (json) out.stdout.write(JSON.stringify({ error: { code: "INVALID_REQUEST", message, errors: issues } }) + "\n");
1075
+ out.stderr.write(`error: ${message}
1076
+ ${issues.map((i) => ` ${line(i)}
1077
+ `).join("")}`);
1078
+ process.exit(2);
1079
+ }
1080
+ function ruleOf(s) {
1081
+ if (Array.isArray(s["oneOf"])) return `one of ${s["oneOf"].map(shape).join(" | ")}`;
1082
+ const r = [];
1083
+ if (Array.isArray(s["enum"])) r.push(`one of ${s["enum"].join(", ")}`);
1084
+ if ("const" in s) r.push(`exactly ${JSON.stringify(s["const"])}`);
1085
+ if (typeof s["minLength"] === "number" && s["minLength"] > 1) r.push(`at least ${s["minLength"]} characters`);
1086
+ if (s["minLength"] === 1) r.push("non-empty");
1087
+ if (typeof s["maxLength"] === "number") r.push(`at most ${s["maxLength"]} characters`);
1088
+ if (typeof s["minimum"] === "number") r.push(`at least ${s["minimum"]}`);
1089
+ if (typeof s["maximum"] === "number") r.push(`at most ${s["maximum"]}`);
1090
+ if (typeof s["minItems"] === "number") r.push(`at least ${s["minItems"]} items`);
1091
+ if (typeof s["maxItems"] === "number") r.push(`at most ${s["maxItems"]} items`);
1092
+ return r.join("; ");
1093
+ }
1094
+ var typeName = (s) => Array.isArray(s["oneOf"]) ? "object" : s["type"] === "array" && s["items"] ? `${typeName(s["items"])}[]` : String(s["type"] ?? "any");
1095
+ function renderDocument(key) {
1096
+ const rows = /* @__PURE__ */ new Map();
1097
+ const walk = (s, prefix, when, branches = 1) => {
1098
+ const props = s["properties"] ?? {};
1099
+ const req = new Set(s["required"] ?? []);
1100
+ for (const [name, p] of Object.entries(props)) {
1101
+ const path = prefix ? `${prefix}.${name}` : name;
1102
+ const row = rows.get(path) ?? { type: typeName(p), req: [], def: "", rules: [], branches };
1103
+ rows.set(path, row);
1104
+ row.req.push(req.has(name) ? when ? `required ${when}` : "required" : "optional");
1105
+ if ("default" in p) row.def = `default ${JSON.stringify(p["default"])}`;
1106
+ row.rules.push(ruleOf(p));
1107
+ if (p["type"] === "object" && p["properties"]) walk(p, path);
1108
+ const oneOf = p["oneOf"] ?? [];
1109
+ const disc = p["discriminator"]?.propertyName;
1110
+ for (const b of oneOf) {
1111
+ const tag = disc ? b["properties"]?.[disc]?.["const"] : void 0;
1112
+ walk(b, path, tag !== void 0 ? `if ${disc} is ${JSON.stringify(tag)}` : `in ${shape(b)}`, oneOf.length);
1113
+ }
1114
+ const items = p["items"];
1115
+ if (items?.["type"] === "object") walk(items, `${path}[]`);
1116
+ }
1117
+ };
1118
+ walk(documentSchema(key), "");
1119
+ const merged = [...rows].map(([path, r]) => {
1120
+ const everywhere = r.req.length === r.branches && r.req.every((q) => q.startsWith("required"));
1121
+ const req = everywhere ? "required" : [...new Set(r.req)].join(", ");
1122
+ const consts = r.rules.map((x) => /^exactly (".*")$/.exec(x)?.[1]);
1123
+ const rule = r.rules.length > 1 && consts.every(Boolean) ? `one of ${[...new Set(consts.map((c) => JSON.parse(c)))].join(", ")}` : [...new Set(r.rules.filter(Boolean))].join(" | ");
1124
+ return [path, r.type, req, r.def, rule];
1125
+ });
1126
+ const widths = [0, 1, 2].map((c) => Math.max(...merged.map((r) => r[c].length)));
1127
+ return merged.map((r) => [r[0].padEnd(widths[0]), r[1].padEnd(widths[1]), r[2].padEnd(widths[2]), r[3], r[4]].filter(Boolean).join(" ").trimEnd());
1128
+ }
1129
+
1130
+ export {
1131
+ ENFORCED,
1132
+ ANNOTATIONS,
1133
+ documentSchema,
1134
+ MAX_DOCUMENT_BYTES,
1135
+ readStdinCapped,
1136
+ readFileFlag,
1137
+ parseDocument,
1138
+ validate,
1139
+ reportIssues,
1140
+ renderDocument
1141
+ };