@curviate/sdk 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ Versioning: semantic — minor for additive changes, patch for bug fixes; no sta
7
7
 
8
8
  ---
9
9
 
10
+ ## [0.1.1] — 2026-06-22
11
+
12
+ ### Fixed
13
+
14
+ - Account-scoped write requests now send the account identifier in the request body where the API expects it. Previously the account identifier was always sent as a query parameter, regardless of the operation, which caused account-scoped write requests (sending invitations and InMail, posting and commenting, reacting, endorsing, saving leads, and the Recruiter pipeline writes) to be rejected. Read requests, body-less deletes, and filter-search requests are unaffected — they continue to carry the account identifier as a query parameter, matching the API. An account identifier you pass explicitly in a request still takes precedence and is never overwritten.
15
+
16
+ ---
17
+
10
18
  ## [0.1.0] — 2026-06-21
11
19
 
12
20
  Initial public release.
package/dist/index.d.ts CHANGED
@@ -66,12 +66,33 @@ type HttpMethod = "GET" | "HEAD" | "POST" | "PATCH" | "PUT" | "DELETE";
66
66
  * operation.
67
67
  */
68
68
 
69
+ /**
70
+ * Where the account-scoped `account_id` is injected for this call.
71
+ *
72
+ * `account_id`'s location is per-endpoint and method-dependent:
73
+ * - `"body"` — account-scoped write requests that carry a body declare
74
+ * `account_id` as a body field. The context writes it into the JSON object,
75
+ * or appends it as a form field when the body is `FormData` (multipart).
76
+ * - `"query"` — GET reads, body-less destructive verbs (DELETE), and
77
+ * filter-search POSTs (whose body is the filter set, with `account_id` in
78
+ * the query string) all carry it as a query parameter.
79
+ *
80
+ * Defaults to `"query"` so a method that omits it keeps the read-style location.
81
+ */
82
+ type AccountIdLocation = "body" | "query";
69
83
  /** Per-call request shape passed by a resource method. */
70
84
  interface RequestArgs {
71
85
  method: HttpMethod;
72
86
  path: string;
73
87
  query?: Record<string, string | number | boolean | undefined | null>;
74
88
  body?: unknown;
89
+ /**
90
+ * Where to inject the context's fixed `account_id`. Defaults to `"query"`.
91
+ * Methods whose endpoint requires `account_id` in the request body set
92
+ * `"body"`; the context then routes it into the JSON object or appends it as
93
+ * a `FormData` field, matching the body kind.
94
+ */
95
+ accountIdIn?: AccountIdLocation;
75
96
  }
76
97
  /** The bound caller a resource receives. */
77
98
  type RequestFn = <T = unknown>(args: RequestArgs) => Promise<T>;
package/dist/index.js CHANGED
@@ -242,9 +242,28 @@ async function execute(method, path, opts) {
242
242
  }
243
243
 
244
244
  // src/internal/context.ts
245
+ function injectAccountIdIntoBody(body, accountId) {
246
+ if (body instanceof FormData) {
247
+ if (!body.has("account_id")) body.append("account_id", accountId);
248
+ return body;
249
+ }
250
+ if (body !== null && typeof body === "object") {
251
+ const obj = body;
252
+ return "account_id" in obj ? obj : { account_id: accountId, ...obj };
253
+ }
254
+ return body;
255
+ }
245
256
  function createContext(config, accountId) {
246
257
  const request = (args) => {
247
- const query = accountId !== void 0 ? { account_id: accountId, ...args.query } : args.query;
258
+ const target = args.accountIdIn ?? "query";
259
+ let { query, body } = args;
260
+ if (accountId !== void 0) {
261
+ if (target === "body") {
262
+ body = injectAccountIdIntoBody(body, accountId);
263
+ } else {
264
+ query = { account_id: accountId, ...args.query };
265
+ }
266
+ }
248
267
  return execute(args.method, args.path, {
249
268
  apiKey: config.apiKey,
250
269
  baseUrl: config.baseUrl,
@@ -252,7 +271,7 @@ function createContext(config, accountId) {
252
271
  maxRetries: config.maxRetries,
253
272
  ...config.fetch ? { fetch: config.fetch } : {},
254
273
  ...query !== void 0 ? { query } : {},
255
- ...args.body !== void 0 ? { body: args.body } : {}
274
+ ...body !== void 0 ? { body } : {}
256
275
  });
257
276
  };
258
277
  return { request, accountId };
@@ -428,13 +447,15 @@ var MessagingResource = class {
428
447
  return this.ctx.request({
429
448
  method: "POST",
430
449
  path: "/v1/chats",
431
- body: buildFormData(scalars, attachments)
450
+ body: buildFormData(scalars, attachments),
451
+ accountIdIn: "body"
432
452
  });
433
453
  }
434
454
  return this.ctx.request({
435
455
  method: "POST",
436
456
  path: "/v1/chats",
437
- body: scalars
457
+ body: scalars,
458
+ accountIdIn: "body"
438
459
  });
439
460
  }
440
461
  /** Get details of a single chat. `GET /v1/chats/{chat_id}` */
@@ -462,13 +483,15 @@ var MessagingResource = class {
462
483
  return this.ctx.request({
463
484
  method: "POST",
464
485
  path: `/v1/chats/${chatId}/messages`,
465
- body: buildFormData(scalars, attachments)
486
+ body: buildFormData(scalars, attachments),
487
+ accountIdIn: "body"
466
488
  });
467
489
  }
468
490
  return this.ctx.request({
469
491
  method: "POST",
470
492
  path: `/v1/chats/${chatId}/messages`,
471
- body: scalars
493
+ body: scalars,
494
+ accountIdIn: "body"
472
495
  });
473
496
  }
474
497
  /** Trigger a re-sync of a specific chat's message history. `GET /v1/chats/{chat_id}/sync` */
@@ -516,7 +539,8 @@ var MessagingResource = class {
516
539
  return this.ctx.request({
517
540
  method: "POST",
518
541
  path: `/v1/messages/${messageId}/reactions`,
519
- body
542
+ body,
543
+ accountIdIn: "body"
520
544
  });
521
545
  }
522
546
  /** Send an InMail. `POST /v1/messages/inmail` */
@@ -524,7 +548,8 @@ var MessagingResource = class {
524
548
  return this.ctx.request({
525
549
  method: "POST",
526
550
  path: "/v1/messages/inmail",
527
- body
551
+ body,
552
+ accountIdIn: "body"
528
553
  });
529
554
  }
530
555
  /** Get the account's InMail credit balance. `GET /v1/messaging/inmail-balance` */
@@ -625,7 +650,8 @@ var ProfilesResource = class {
625
650
  return this.ctx.request({
626
651
  method: "POST",
627
652
  path: `/v1/profiles/${profileId}/endorse`,
628
- body
653
+ body,
654
+ accountIdIn: "body"
629
655
  });
630
656
  }
631
657
  };
@@ -640,7 +666,8 @@ var InvitesResource = class {
640
666
  return this.ctx.request({
641
667
  method: "POST",
642
668
  path: "/v1/invites",
643
- body
669
+ body,
670
+ accountIdIn: "body"
644
671
  });
645
672
  }
646
673
  /** List sent invitations. `GET /v1/invites/sent` */
@@ -667,7 +694,8 @@ var InvitesResource = class {
667
694
  return this.ctx.request({
668
695
  method: "POST",
669
696
  path: `/v1/invites/received/${invitationId}`,
670
- body
697
+ body,
698
+ accountIdIn: "body"
671
699
  });
672
700
  }
673
701
  /** Cancel a sent invitation. `DELETE /v1/invites/{invitation_id}` */
@@ -796,7 +824,8 @@ var PostsResource = class {
796
824
  return this.ctx.request({
797
825
  method: "POST",
798
826
  path: "/v1/posts",
799
- body: form
827
+ body: form,
828
+ accountIdIn: "body"
800
829
  });
801
830
  }
802
831
  /** Get a single post. `GET /v1/posts/{post_id}` */
@@ -822,7 +851,8 @@ var PostsResource = class {
822
851
  return this.ctx.request({
823
852
  method: "POST",
824
853
  path: `/v1/posts/${postId}/comments`,
825
- body: buildFormData2(scalars, attachments)
854
+ body: buildFormData2(scalars, attachments),
855
+ accountIdIn: "body"
826
856
  });
827
857
  }
828
858
  /** List reactions on a post. `GET /v1/posts/{post_id}/reactions` */
@@ -838,7 +868,8 @@ var PostsResource = class {
838
868
  return this.ctx.request({
839
869
  method: "POST",
840
870
  path: `/v1/posts/${postId}/reactions`,
841
- body
871
+ body,
872
+ accountIdIn: "body"
842
873
  });
843
874
  }
844
875
  };
@@ -937,13 +968,15 @@ var SalesNavigatorResource = class {
937
968
  attachments,
938
969
  voice_message,
939
970
  video_message
940
- )
971
+ ),
972
+ accountIdIn: "body"
941
973
  });
942
974
  }
943
975
  return this.ctx.request({
944
976
  method: "POST",
945
977
  path: "/v1/sales-navigator/chats",
946
- body: scalars
978
+ body: scalars,
979
+ accountIdIn: "body"
947
980
  });
948
981
  }
949
982
  /**
@@ -965,7 +998,8 @@ var SalesNavigatorResource = class {
965
998
  return this.ctx.request({
966
999
  method: "POST",
967
1000
  path: `/v1/sales-navigator/leads/${userId}`,
968
- body
1001
+ body,
1002
+ accountIdIn: "body"
969
1003
  });
970
1004
  }
971
1005
  /**
@@ -1050,13 +1084,15 @@ var RecruiterResource = class {
1050
1084
  attachments,
1051
1085
  voice_message,
1052
1086
  video_message
1053
- )
1087
+ ),
1088
+ accountIdIn: "body"
1054
1089
  });
1055
1090
  }
1056
1091
  return this.ctx.request({
1057
1092
  method: "POST",
1058
1093
  path: "/v1/recruiter/chats",
1059
- body: scalars
1094
+ body: scalars,
1095
+ accountIdIn: "body"
1060
1096
  });
1061
1097
  }
1062
1098
  /**
@@ -1121,7 +1157,8 @@ var RecruiterResource = class {
1121
1157
  return this.ctx.request({
1122
1158
  method: "POST",
1123
1159
  path: `/v1/recruiter/projects/candidates/${userId}`,
1124
- body
1160
+ body,
1161
+ accountIdIn: "body"
1125
1162
  });
1126
1163
  }
1127
1164
  /**
@@ -1132,7 +1169,8 @@ var RecruiterResource = class {
1132
1169
  return this.ctx.request({
1133
1170
  method: "POST",
1134
1171
  path: `/v1/recruiter/projects/applicants/${userId}`,
1135
- body
1172
+ body,
1173
+ accountIdIn: "body"
1136
1174
  });
1137
1175
  }
1138
1176
  /**
@@ -1143,7 +1181,8 @@ var RecruiterResource = class {
1143
1181
  return this.ctx.request({
1144
1182
  method: "POST",
1145
1183
  path: `/v1/recruiter/projects/applicants/${userId}/reject`,
1146
- body
1184
+ body,
1185
+ accountIdIn: "body"
1147
1186
  });
1148
1187
  }
1149
1188
  /**
@@ -1163,7 +1202,8 @@ var RecruiterResource = class {
1163
1202
  return this.ctx.request({
1164
1203
  method: "POST",
1165
1204
  path: "/v1/recruiter/jobs",
1166
- body
1205
+ body,
1206
+ accountIdIn: "body"
1167
1207
  });
1168
1208
  }
1169
1209
  /**
@@ -1174,7 +1214,8 @@ var RecruiterResource = class {
1174
1214
  return this.ctx.request({
1175
1215
  method: "POST",
1176
1216
  path: `/v1/recruiter/jobs/${jobId}/publish`,
1177
- body
1217
+ body,
1218
+ accountIdIn: "body"
1178
1219
  });
1179
1220
  }
1180
1221
  /**
@@ -1185,7 +1226,8 @@ var RecruiterResource = class {
1185
1226
  return this.ctx.request({
1186
1227
  method: "POST",
1187
1228
  path: `/v1/recruiter/jobs/${jobId}/checkpoint`,
1188
- body
1229
+ body,
1230
+ accountIdIn: "body"
1189
1231
  });
1190
1232
  }
1191
1233
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curviate/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK for the Curviate API.",
6
6
  "license": "MIT",