@curviate/cli 0.48.0 → 0.50.0-next.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 (70) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +47 -6
  3. package/dist/{account-WKQHMM7P.js → account-KGCGUYKF.js} +668 -116
  4. package/dist/analytics-HRAD4ABO.js +27 -0
  5. package/dist/beta-consent-364JI6IL.js +81 -0
  6. package/dist/billing-3SSVRS2Y.js +124 -0
  7. package/dist/{chunk-Q63IIPL2.js → chunk-25MO7BYN.js} +4 -4
  8. package/dist/{chunk-76SWLAZ6.js → chunk-2W4RN5ON.js} +59 -1
  9. package/dist/chunk-5S3MJVI5.js +22 -0
  10. package/dist/chunk-67S4JHZZ.js +339 -0
  11. package/dist/chunk-73DJ3KNE.js +54 -0
  12. package/dist/chunk-CQGDMARG.js +525 -0
  13. package/dist/{chunk-Y7K4UBFC.js → chunk-DOHBOYXN.js} +1 -1
  14. package/dist/{chunk-TSOIZBBU.js → chunk-DSGKYZDK.js} +1 -1
  15. package/dist/{chunk-YLSJ4HKU.js → chunk-ENBIMEKS.js} +26 -1
  16. package/dist/{chunk-LCGXJGPB.js → chunk-GHMRPX5H.js} +7 -1
  17. package/dist/chunk-GOICALYQ.js +28 -0
  18. package/dist/chunk-L4CIJT6F.js +144 -0
  19. package/dist/{chunk-PQWDDSV7.js → chunk-L7JH3W56.js} +1 -1
  20. package/dist/{chunk-YFXLXION.js → chunk-OE6YFYUM.js} +85 -10
  21. package/dist/chunk-PPGKQJKU.js +38 -0
  22. package/dist/{chunk-MKGVNDMJ.js → chunk-QM57YDJE.js} +13 -201
  23. package/dist/{chunk-CVMSQ3OF.js → chunk-RYWWSZUH.js} +17 -3
  24. package/dist/chunk-T6GBS5SS.js +58 -0
  25. package/dist/{chunk-AYKKXGTR.js → chunk-TE3WBPW6.js} +392 -14
  26. package/dist/chunk-UL53T4O6.js +52 -0
  27. package/dist/chunk-UWQPX4AE.js +20 -0
  28. package/dist/{chunk-OHXYFICP.js → chunk-YXVF5UST.js} +77 -4
  29. package/dist/cli.js +35 -17
  30. package/dist/{comment-7IQ6ZOJF.js → comment-5JKGNYOY.js} +90 -11
  31. package/dist/{company-RD7RDGSA.js → company-TXST2VXW.js} +65 -15
  32. package/dist/{config-EYBNYRGK.js → config-TVIQUVNK.js} +53 -4
  33. package/dist/{connect-HVXT67A6.js → connect-RBL6U4KV.js} +63 -18
  34. package/dist/contact-YAHC5QFX.js +32 -0
  35. package/dist/contact-groups-DKOIBC57.js +399 -0
  36. package/dist/contact-import-ITSJQV7K.js +336 -0
  37. package/dist/core-PWMJPPRG.js +46 -0
  38. package/dist/do-not-contact-WDYIBWYA.js +200 -0
  39. package/dist/{doctor-HUXQERLQ.js → doctor-F7JLPTED.js} +65 -11
  40. package/dist/{document-AUUCGST2.js → document-BHYAUJ6F.js} +1 -1
  41. package/dist/{draft-DFO22K6Q.js → draft-TDJJUXLH.js} +60 -14
  42. package/dist/enrollment-Q6UOKHPY.js +484 -0
  43. package/dist/{examples-64YT5V5K.js → examples-DQSVIIXZ.js} +2 -2
  44. package/dist/{exit-codes-AW6KHDDN.js → exit-codes-7DBETBDT.js} +1 -1
  45. package/dist/export-HIJSCJS6.js +96 -0
  46. package/dist/{feed-JWP6ANPI.js → feed-W56ZTA4Z.js} +13 -10
  47. package/dist/{group-SIQFJEZV.js → group-AUALYK5H.js} +18 -10
  48. package/dist/{inbox-MMIMCA5O.js → inbox-HLZR2ZPV.js} +31 -12
  49. package/dist/{inboxes-RND3D4C7.js → inboxes-IZTRD6FE.js} +14 -10
  50. package/dist/incoming-ULB2RNV4.js +218 -0
  51. package/dist/{job-ACFKBLFK.js → job-55IKS6LP.js} +65 -13
  52. package/dist/{login-ZOB5KVKQ.js → login-DPZ6CXNO.js} +13 -4
  53. package/dist/{message-OFK6UVXR.js → message-J44YKRDS.js} +9 -7
  54. package/dist/motion-SQI5F2EK.js +868 -0
  55. package/dist/network-K4QD7APQ.js +235 -0
  56. package/dist/{notification-KKGAZU7M.js → notification-SEDXZHXO.js} +38 -11
  57. package/dist/notifications-HGIBRUNQ.js +231 -0
  58. package/dist/{post-A5SBCFB2.js → post-L467SKIG.js} +92 -12
  59. package/dist/{profile-4SOOQZ4K.js → profile-A2N6RMR2.js} +79 -23
  60. package/dist/{recruiter-YN73STDP.js → recruiter-AR75RHBO.js} +132 -21
  61. package/dist/{sales-nav-JXF5RY2K.js → sales-nav-C2AYFXPV.js} +73 -18
  62. package/dist/{search-JAL242A2.js → search-Z4DZIG4X.js} +55 -23
  63. package/dist/{setup-WICWH4JG.js → setup-45BEVX6B.js} +69 -17
  64. package/dist/team-6QWY4IFP.js +450 -0
  65. package/dist/tier-2HS3BXDF.js +61 -0
  66. package/dist/unibox-DHUKG65Z.js +402 -0
  67. package/dist/{webhook-UGKVYWBC.js → webhook-Q53WUAI2.js} +273 -45
  68. package/package.json +2 -2
  69. package/dist/chunk-GQKC6E5K.js +0 -36
  70. package/dist/core-6XYGUNAY.js +0 -46
@@ -15,6 +15,10 @@ var GLOBAL_FLAGS = {
15
15
  type: "string",
16
16
  description: "Account id for account-scoped commands. Optional when exactly one account is connected, and required with --preview."
17
17
  },
18
+ team: {
19
+ type: "string",
20
+ description: "Team to act in (tnt_...), sent with every request. Overrides CURVIATE_TEAM and the profile's team. Needed with a key that works in all your Teams; a Team key acts only in its own Team."
21
+ },
18
22
  "base-url": {
19
23
  type: "string",
20
24
  description: "Override the API base URL."
@@ -70,13 +74,14 @@ var GLOBAL_FLAGS = {
70
74
  // cannot express an optional-valued boolean without silently opting in).
71
75
  beta: {
72
76
  type: "boolean",
73
- description: "Allow beta operations for THIS call only (--beta, --beta=false). A gated operation refuses BETA_NOT_ENABLED (exit 5) until a human enables beta in Settings, or you pass --beta for this call. Persists nothing."
77
+ description: "Allow beta operations for THIS call only (--beta, --beta=false). A gated operation refuses BETA_NOT_ENABLED (exit 5) until beta is enabled for the Team (`curviate beta update --enabled true`, an Owner; `PATCH /v1/tenant/beta`), or you pass --beta for this call. Persists nothing."
74
78
  }
75
79
  };
76
80
  var NON_STREAM_FLAGS = {
77
81
  "api-key": GLOBAL_FLAGS["api-key"],
78
82
  profile: GLOBAL_FLAGS.profile,
79
83
  account: GLOBAL_FLAGS.account,
84
+ team: GLOBAL_FLAGS.team,
80
85
  "base-url": GLOBAL_FLAGS["base-url"],
81
86
  timeout: GLOBAL_FLAGS.timeout,
82
87
  json: GLOBAL_FLAGS.json,
@@ -91,6 +96,7 @@ var WRITE_FLAGS = {
91
96
  "api-key": GLOBAL_FLAGS["api-key"],
92
97
  profile: GLOBAL_FLAGS.profile,
93
98
  account: GLOBAL_FLAGS.account,
99
+ team: GLOBAL_FLAGS.team,
94
100
  "base-url": GLOBAL_FLAGS["base-url"],
95
101
  timeout: GLOBAL_FLAGS.timeout,
96
102
  json: GLOBAL_FLAGS.json,
@@ -102,6 +108,7 @@ var READ_SINGLE_FLAGS = {
102
108
  "api-key": GLOBAL_FLAGS["api-key"],
103
109
  profile: GLOBAL_FLAGS.profile,
104
110
  account: GLOBAL_FLAGS.account,
111
+ team: GLOBAL_FLAGS.team,
105
112
  "base-url": GLOBAL_FLAGS["base-url"],
106
113
  timeout: GLOBAL_FLAGS.timeout,
107
114
  json: GLOBAL_FLAGS.json,
@@ -127,8 +134,13 @@ var STATE_WRITES = {
127
134
  "curviate account checkpoint solve": "curviate account checkpoint poll <account_id>",
128
135
  "curviate account checkpoint poll": "curviate account checkpoint poll <account_id>",
129
136
  "curviate account checkpoint request": "curviate account checkpoint poll <account_id>",
130
- "curviate account connect-session poll": "curviate account connect-session poll --session <session_id>"
137
+ "curviate account connect-session poll": "curviate account connect-session poll --session <session_id>",
138
+ // Its answer says whether the Step was resumed, and what to wait for.
139
+ "curviate enrollment retry": "curviate enrollment get <enrollment_id>"
131
140
  };
141
+ var teamFlag;
142
+ var setTeamFlag = (v) => void (teamFlag = typeof v === "string" ? v : void 0);
143
+ var getTeamFlag = () => teamFlag;
132
144
 
133
145
  // src/lib/beta.ts
134
146
  var BETA_CONSENT_HEADER = "X-Curviate-Beta";
@@ -210,5 +222,7 @@ export {
210
222
  isPoll,
211
223
  getWriteKind,
212
224
  getRecheck,
213
- STATE_WRITES
225
+ STATE_WRITES,
226
+ setTeamFlag,
227
+ getTeamFlag
214
228
  };
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ renderError,
4
+ renderUnexpectedError
5
+ } from "./chunk-QM57YDJE.js";
6
+ import {
7
+ createClient,
8
+ resolveEffectiveConfig
9
+ } from "./chunk-YXVF5UST.js";
10
+
11
+ // src/lib/root-command.ts
12
+ var outputOpts = (f) => ({
13
+ json: (f.json ?? false) || !process.stdout.isTTY,
14
+ isTTY: process.stdout.isTTY ?? false,
15
+ fields: f.fields,
16
+ verbose: f.verbose
17
+ });
18
+ function usage(message) {
19
+ process.stderr.write(`error: ${message}
20
+ `);
21
+ process.exit(2);
22
+ }
23
+ async function rootClient(f) {
24
+ const cfg = await resolveEffectiveConfig({ apiKey: f["api-key"], baseUrl: f["base-url"], timeout: f.timeout, profile: f.profile });
25
+ if (!cfg.apiKey) {
26
+ process.stderr.write("error: no API key, run `curviate login` or pass --api-key.\n");
27
+ process.exit(3);
28
+ }
29
+ try {
30
+ return createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
31
+ } catch (err) {
32
+ return fail(err, f);
33
+ }
34
+ }
35
+ async function fail(err, f) {
36
+ const { CurviateError } = await import("@curviate/sdk");
37
+ if (err instanceof CurviateError) {
38
+ const { getExitCode } = await import("./exit-codes-7DBETBDT.js");
39
+ renderError(err, outputOpts(f), process);
40
+ process.exit(getExitCode(err));
41
+ }
42
+ renderUnexpectedError(err, process);
43
+ process.exit(1);
44
+ }
45
+ function listFlag(flag, raw) {
46
+ if (raw === void 0) return [];
47
+ const ids = [].concat(raw).flatMap((v) => v.split(",")).map((s) => s.trim());
48
+ if (ids.length === 0 || ids.some((s) => s === "")) usage(`--${flag} was given an empty value. Pass one or more ids, comma-separated or with --${flag} repeated.`);
49
+ return ids;
50
+ }
51
+
52
+ export {
53
+ outputOpts,
54
+ usage,
55
+ rootClient,
56
+ fail,
57
+ listFlag
58
+ };
@@ -894,11 +894,386 @@ var documents_default = {
894
894
  }
895
895
  },
896
896
  additionalProperties: false
897
+ },
898
+ "motion create": {
899
+ type: "object",
900
+ properties: {
901
+ name: {
902
+ type: "string",
903
+ minLength: 1,
904
+ maxLength: 100
905
+ },
906
+ contact_list_ids: {
907
+ type: "array",
908
+ items: {
909
+ type: "string",
910
+ minLength: 1,
911
+ maxLength: 64
912
+ }
913
+ },
914
+ exclusion_list_ids: {
915
+ type: "array",
916
+ items: {
917
+ type: "string",
918
+ minLength: 1,
919
+ maxLength: 64
920
+ }
921
+ },
922
+ account_ids: {
923
+ type: "array",
924
+ items: {
925
+ type: "string",
926
+ minLength: 1,
927
+ maxLength: 64
928
+ }
929
+ },
930
+ schedule: {
931
+ type: "object",
932
+ properties: {
933
+ timezone: {
934
+ type: "string",
935
+ maxLength: 64,
936
+ nullable: true
937
+ },
938
+ days: {
939
+ type: "array",
940
+ items: {
941
+ type: "string",
942
+ enum: [
943
+ "mon",
944
+ "tue",
945
+ "wed",
946
+ "thu",
947
+ "fri",
948
+ "sat",
949
+ "sun"
950
+ ]
951
+ }
952
+ },
953
+ hours: {
954
+ type: "object",
955
+ properties: {
956
+ start: {
957
+ type: "string"
958
+ },
959
+ end: {
960
+ type: "string"
961
+ }
962
+ },
963
+ required: [
964
+ "start",
965
+ "end"
966
+ ],
967
+ additionalProperties: false
968
+ },
969
+ start_at: {
970
+ type: "string",
971
+ nullable: true
972
+ },
973
+ end_at: {
974
+ type: "string",
975
+ nullable: true
976
+ }
977
+ },
978
+ additionalProperties: false
979
+ },
980
+ settings: {
981
+ type: "object",
982
+ properties: {
983
+ accounts_per_contact: {
984
+ type: "integer",
985
+ minimum: 1,
986
+ maximum: 10
987
+ },
988
+ assign: {
989
+ type: "string",
990
+ enum: [
991
+ "auto",
992
+ "even",
993
+ "already_connected"
994
+ ]
995
+ },
996
+ new_enrollments_per_account_per_day: {
997
+ type: "integer",
998
+ minimum: 1,
999
+ maximum: 1e3
1000
+ },
1001
+ exclude: {
1002
+ type: "object",
1003
+ properties: {
1004
+ other_motions: {
1005
+ type: "boolean"
1006
+ },
1007
+ known_chats: {
1008
+ type: "boolean"
1009
+ }
1010
+ },
1011
+ additionalProperties: false
1012
+ },
1013
+ acceptance_floor: {
1014
+ type: "object",
1015
+ properties: {
1016
+ percent: {
1017
+ type: "integer",
1018
+ minimum: 0,
1019
+ maximum: 100
1020
+ },
1021
+ min_invites: {
1022
+ type: "integer",
1023
+ minimum: 10,
1024
+ maximum: 1e3
1025
+ }
1026
+ },
1027
+ additionalProperties: false,
1028
+ nullable: true
1029
+ },
1030
+ variables: {
1031
+ type: "object",
1032
+ additionalProperties: {
1033
+ type: "string",
1034
+ minLength: 1,
1035
+ nullable: true
1036
+ }
1037
+ },
1038
+ on_reply_elsewhere: {
1039
+ type: "string",
1040
+ enum: [
1041
+ "stop",
1042
+ "continue"
1043
+ ]
1044
+ },
1045
+ withdraw_on_reply_elsewhere: {
1046
+ type: "boolean"
1047
+ },
1048
+ account_gap: {
1049
+ type: "string"
1050
+ },
1051
+ stop_on_engagement: {
1052
+ type: "boolean"
1053
+ }
1054
+ },
1055
+ additionalProperties: false
1056
+ },
1057
+ where: {
1058
+ type: "array",
1059
+ items: {}
1060
+ },
1061
+ sequence: {}
1062
+ },
1063
+ required: [
1064
+ "name"
1065
+ ],
1066
+ additionalProperties: false,
1067
+ "x-curviate-response-only": [
1068
+ "object",
1069
+ "id",
1070
+ "status",
1071
+ "pause_reason",
1072
+ "sequence_version",
1073
+ "sequence_revision",
1074
+ "sequence_updated_by_user_id",
1075
+ "counts",
1076
+ "warnings",
1077
+ "created_by_user_id",
1078
+ "created_at",
1079
+ "updated_at",
1080
+ "started_at",
1081
+ "completed_at",
1082
+ "archived_at"
1083
+ ]
1084
+ },
1085
+ "motion update": {
1086
+ type: "object",
1087
+ properties: {
1088
+ name: {
1089
+ type: "string",
1090
+ minLength: 1,
1091
+ maxLength: 100
1092
+ },
1093
+ contact_list_ids: {
1094
+ type: "array",
1095
+ items: {
1096
+ type: "string",
1097
+ minLength: 1,
1098
+ maxLength: 64
1099
+ }
1100
+ },
1101
+ exclusion_list_ids: {
1102
+ type: "array",
1103
+ items: {
1104
+ type: "string",
1105
+ minLength: 1,
1106
+ maxLength: 64
1107
+ }
1108
+ },
1109
+ account_ids: {
1110
+ type: "array",
1111
+ items: {
1112
+ type: "string",
1113
+ minLength: 1,
1114
+ maxLength: 64
1115
+ }
1116
+ },
1117
+ schedule: {
1118
+ type: "object",
1119
+ properties: {
1120
+ timezone: {
1121
+ type: "string",
1122
+ maxLength: 64,
1123
+ nullable: true
1124
+ },
1125
+ days: {
1126
+ type: "array",
1127
+ items: {
1128
+ type: "string",
1129
+ enum: [
1130
+ "mon",
1131
+ "tue",
1132
+ "wed",
1133
+ "thu",
1134
+ "fri",
1135
+ "sat",
1136
+ "sun"
1137
+ ]
1138
+ }
1139
+ },
1140
+ hours: {
1141
+ type: "object",
1142
+ properties: {
1143
+ start: {
1144
+ type: "string"
1145
+ },
1146
+ end: {
1147
+ type: "string"
1148
+ }
1149
+ },
1150
+ required: [
1151
+ "start",
1152
+ "end"
1153
+ ],
1154
+ additionalProperties: false
1155
+ },
1156
+ start_at: {
1157
+ type: "string",
1158
+ nullable: true
1159
+ },
1160
+ end_at: {
1161
+ type: "string",
1162
+ nullable: true
1163
+ }
1164
+ },
1165
+ additionalProperties: false
1166
+ },
1167
+ settings: {
1168
+ type: "object",
1169
+ properties: {
1170
+ accounts_per_contact: {
1171
+ type: "integer",
1172
+ minimum: 1,
1173
+ maximum: 10
1174
+ },
1175
+ assign: {
1176
+ type: "string",
1177
+ enum: [
1178
+ "auto",
1179
+ "even",
1180
+ "already_connected"
1181
+ ]
1182
+ },
1183
+ new_enrollments_per_account_per_day: {
1184
+ type: "integer",
1185
+ minimum: 1,
1186
+ maximum: 1e3
1187
+ },
1188
+ exclude: {
1189
+ type: "object",
1190
+ properties: {
1191
+ other_motions: {
1192
+ type: "boolean"
1193
+ },
1194
+ known_chats: {
1195
+ type: "boolean"
1196
+ }
1197
+ },
1198
+ additionalProperties: false
1199
+ },
1200
+ acceptance_floor: {
1201
+ type: "object",
1202
+ properties: {
1203
+ percent: {
1204
+ type: "integer",
1205
+ minimum: 0,
1206
+ maximum: 100
1207
+ },
1208
+ min_invites: {
1209
+ type: "integer",
1210
+ minimum: 10,
1211
+ maximum: 1e3
1212
+ }
1213
+ },
1214
+ additionalProperties: false,
1215
+ nullable: true
1216
+ },
1217
+ variables: {
1218
+ type: "object",
1219
+ additionalProperties: {
1220
+ type: "string",
1221
+ minLength: 1,
1222
+ nullable: true
1223
+ }
1224
+ },
1225
+ on_reply_elsewhere: {
1226
+ type: "string",
1227
+ enum: [
1228
+ "stop",
1229
+ "continue"
1230
+ ]
1231
+ },
1232
+ withdraw_on_reply_elsewhere: {
1233
+ type: "boolean"
1234
+ },
1235
+ account_gap: {
1236
+ type: "string"
1237
+ },
1238
+ stop_on_engagement: {
1239
+ type: "boolean"
1240
+ }
1241
+ },
1242
+ additionalProperties: false
1243
+ },
1244
+ where: {
1245
+ type: "array",
1246
+ items: {}
1247
+ },
1248
+ sequence: {},
1249
+ if_sequence_revision: {
1250
+ type: "integer",
1251
+ minimum: 0
1252
+ }
1253
+ },
1254
+ additionalProperties: false,
1255
+ "x-curviate-response-only": [
1256
+ "object",
1257
+ "id",
1258
+ "status",
1259
+ "pause_reason",
1260
+ "sequence_version",
1261
+ "sequence_revision",
1262
+ "sequence_updated_by_user_id",
1263
+ "counts",
1264
+ "warnings",
1265
+ "created_by_user_id",
1266
+ "created_at",
1267
+ "updated_at",
1268
+ "started_at",
1269
+ "completed_at",
1270
+ "archived_at"
1271
+ ]
897
1272
  }
898
1273
  };
899
1274
 
900
1275
  // src/lib/document.ts
901
- var ENFORCED = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties", "enum", "const", "minLength", "maxLength", "minimum", "maximum", "items", "minItems", "maxItems", "oneOf"]);
1276
+ var ENFORCED = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties", "enum", "const", "minLength", "maxLength", "minimum", "maximum", "items", "minItems", "maxItems", "oneOf", "nullable"]);
902
1277
  var ANNOTATIONS = /* @__PURE__ */ new Set(["description", "title", "default", "discriminator"]);
903
1278
  function documentSchema(key) {
904
1279
  const s = documents_default[key];
@@ -906,8 +1281,8 @@ function documentSchema(key) {
906
1281
  return s;
907
1282
  }
908
1283
  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) {
1284
+ var TOO_LARGE = (flag, max = MAX_DOCUMENT_BYTES) => `--${flag}: larger than ${max / 1024 / 1024} MiB, the most a document may be.`;
1285
+ function readCapped(fd, max = MAX_DOCUMENT_BYTES) {
911
1286
  const chunks = [];
912
1287
  let total = 0;
913
1288
  const buf = Buffer.alloc(64 * 1024);
@@ -922,24 +1297,26 @@ function readCapped(fd) {
922
1297
  }
923
1298
  if (n === 0) break;
924
1299
  total += n;
925
- if (total > MAX_DOCUMENT_BYTES) return null;
1300
+ if (total > max) return null;
926
1301
  chunks.push(Buffer.from(buf.subarray(0, n)));
927
1302
  }
928
1303
  return Buffer.concat(chunks);
929
1304
  }
930
- async function readStdinCapped(flag = "file") {
1305
+ async function readStdinCapped(flag = "file", allowBom = false, max = MAX_DOCUMENT_BYTES) {
931
1306
  const chunks = [];
932
1307
  let total = 0;
933
1308
  for await (const chunk of process.stdin) {
934
1309
  const b = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
935
1310
  total += b.length;
936
- if (total > MAX_DOCUMENT_BYTES) usage(TOO_LARGE(flag));
1311
+ if (total > max) usage(TOO_LARGE(flag, max));
937
1312
  chunks.push(b);
938
1313
  }
939
- return decode(flag, Buffer.concat(chunks)).replace(/\n+$/, "");
1314
+ return decode(flag, Buffer.concat(chunks), allowBom).replace(/\n+$/, "");
940
1315
  }
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.`);
1316
+ function decode(flag, bytes, allowBom = false) {
1317
+ const bom = bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191;
1318
+ if (bom && allowBom) bytes = bytes.subarray(3);
1319
+ else if (bom) usage(`--${flag}: starts with a byte order mark (BOM). Save it as UTF-8 without a BOM.`);
943
1320
  try {
944
1321
  return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
945
1322
  } catch {
@@ -961,8 +1338,8 @@ async function readFileFlag(flag, value, io = {}) {
961
1338
  const second = Object.entries(io.others ?? {}).find(([k, o]) => k !== flag && k !== "_" && isStdinToken(o));
962
1339
  if (second) usage(`--${flag} - and --${second[0]} - both read stdin. Only one input can come from stdin.`);
963
1340
  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));
1341
+ text = await (io.readStdin ?? (() => readStdinCapped(flag, io.allowBom, io.maxBytes)))();
1342
+ if (Buffer.byteLength(text) > (io.maxBytes ?? MAX_DOCUMENT_BYTES)) usage(TOO_LARGE(flag, io.maxBytes));
966
1343
  } else {
967
1344
  let isDir = false;
968
1345
  try {
@@ -975,15 +1352,15 @@ async function readFileFlag(flag, value, io = {}) {
975
1352
  try {
976
1353
  const fd = openSync(value, "r");
977
1354
  try {
978
- bytes = readCapped(fd);
1355
+ bytes = readCapped(fd, io.maxBytes);
979
1356
  } finally {
980
1357
  closeSync(fd);
981
1358
  }
982
1359
  } catch (err) {
983
1360
  usage(`--${flag}: cannot read ${value}: ${err.code ?? "read error"}.`);
984
1361
  }
985
- if (bytes === null) usage(TOO_LARGE(flag));
986
- text = decode(flag, bytes);
1362
+ if (bytes === null) usage(TOO_LARGE(flag, io.maxBytes));
1363
+ text = decode(flag, bytes, io.allowBom);
987
1364
  }
988
1365
  if (text.trim() === "") usage(`--${flag}: empty input.`);
989
1366
  return text;
@@ -1031,6 +1408,7 @@ function validate(schema, value, path = "") {
1031
1408
  if (results.some((r) => r.length === 0)) return [];
1032
1409
  return [{ path: at, rule: `must match one of: ${branches.map(shape).join(" | ")}` }];
1033
1410
  }
1411
+ if (value === null && schema["nullable"] === true) return out;
1034
1412
  const t = schema["type"];
1035
1413
  if (t && !isType(value, t)) return [{ path: at, rule: `must be ${t === "array" || t === "object" || t === "integer" ? "an" : "a"} ${t}` }];
1036
1414
  if ("const" in schema && value !== schema["const"]) out.push({ path: at, rule: `must be ${JSON.stringify(schema["const"])}` });
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fail,
4
+ outputOpts
5
+ } from "./chunk-T6GBS5SS.js";
6
+
7
+ // src/lib/chunks.ts
8
+ async function sendInChunks(ids, size, send, f) {
9
+ const chunks = [];
10
+ for (let k = 0; k < ids.length; k += size) chunks.push(ids.slice(k, k + size));
11
+ return sendChunked(chunks, send, f, "ids");
12
+ }
13
+ async function sendChunked(chunks, send, f, unit) {
14
+ const total = chunks.length;
15
+ const all = chunks.reduce((n, c) => n + c.length, 0);
16
+ const done = [];
17
+ let accepted = 0;
18
+ for (let k = 0; k < total; k++) {
19
+ const chunk = chunks[k];
20
+ try {
21
+ done.push(await send(chunk));
22
+ accepted += chunk.length;
23
+ } catch (err) {
24
+ const { CurviateError } = await import("@curviate/sdk");
25
+ const progress = {
26
+ chunks: { sent: k, total },
27
+ items: { accepted, total: all },
28
+ failed_chunk: { index: k + 1, first_row: accepted + 1, last_row: accepted + chunk.length }
29
+ };
30
+ if (!(err instanceof CurviateError)) {
31
+ process.stderr.write(`Chunk ${k + 1} of ${total} failed; ${accepted} of ${all} ${unit} were sent before it. Nothing after it was sent.
32
+ `);
33
+ return fail(err, f);
34
+ }
35
+ const { getExitCode } = await import("./exit-codes-7DBETBDT.js");
36
+ const e = err.toJSON();
37
+ if (outputOpts(f).json) process.stdout.write(JSON.stringify({ error: e, progress }) + "\n");
38
+ process.stderr.write(
39
+ `error [${e.code}] ${e.message}
40
+ Chunk ${k + 1} of ${total} failed (${unit} ${progress.failed_chunk.first_row} to ${progress.failed_chunk.last_row}); ${accepted} of ${all} ${unit} were sent before it. Nothing after it was sent.
41
+ `
42
+ );
43
+ process.exit(getExitCode(err));
44
+ }
45
+ }
46
+ return done;
47
+ }
48
+
49
+ export {
50
+ sendInChunks,
51
+ sendChunked
52
+ };
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/lib/help-errors.ts
4
+ var AS_ACCOUNT = {
5
+ ACCOUNT_NOT_FOUND: "the Account is not in your Team.",
6
+ LINKEDIN_AUTH_FAILED: "LinkedIn no longer accepts the Account's sign-in: reconnect it.",
7
+ ACCOUNT_RESTRICTED: "LinkedIn restricts the Account from this action."
8
+ };
9
+ var BUDGET = {
10
+ BUDGET_EXHAUSTED: "the Account's limit for this action is used up; nothing reached LinkedIn. `curviate account get <account_id>` shows when it resets."
11
+ };
12
+ var TARGET = {
13
+ RESOURCE_NOT_FOUND: "the target does not exist, or the Account cannot see it."
14
+ };
15
+
16
+ export {
17
+ AS_ACCOUNT,
18
+ BUDGET,
19
+ TARGET
20
+ };