@fonderie/client 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -95,6 +95,7 @@ var HttpClient = class {
95
95
  if (opts.token) headers["Authorization"] = `Bearer ${opts.token}`;
96
96
  if (opts.cookie) headers["Cookie"] = opts.cookie;
97
97
  if (opts.workspaceId) headers["X-Workspace-ID"] = opts.workspaceId;
98
+ Object.assign(headers, opts.headers ?? {});
98
99
  const fetchInit = { method: opts.method, headers, credentials: "include" };
99
100
  if (opts.body !== void 0) fetchInit.body = JSON.stringify(opts.body);
100
101
  const res = await fetch(`${this.baseUrl}${opts.path}`, fetchInit);
@@ -132,7 +133,7 @@ var AuditClient = class {
132
133
  setWorkspaceId(workspaceId) {
133
134
  this.workspaceId = workspaceId;
134
135
  }
135
- listEvents(input = {}) {
136
+ listEvents(input = {}, opts) {
136
137
  const params = new URLSearchParams();
137
138
  if (input.limit !== void 0) params.set("limit", String(input.limit));
138
139
  if (input.type) params.set("type", input.type);
@@ -145,7 +146,8 @@ var AuditClient = class {
145
146
  method: "GET",
146
147
  path: `/audit${qs ? `?${qs}` : ""}`,
147
148
  token: this.tokens.get(),
148
- workspaceId: this.workspaceId
149
+ workspaceId: this.workspaceId,
150
+ bust: opts?.bust
149
151
  });
150
152
  }
151
153
  };
@@ -272,15 +274,19 @@ var AuthClient = class {
272
274
  return this.http.request({
273
275
  method: "GET",
274
276
  path: "/auth/send-verification",
275
- token: this.tokens.get()
277
+ token: this.tokens.get(),
278
+ // A send-action on a GET route: never serve it from the cache, or a
279
+ // resend inside the TTL would silently no-op.
280
+ cache: false
276
281
  });
277
282
  }
278
283
  // ── Protected + Verified ───────────────────────────────────────────────────
279
- getUser() {
284
+ getUser(opts) {
280
285
  return this.http.request({
281
286
  method: "GET",
282
287
  path: "/users",
283
- token: this.tokens.get()
288
+ token: this.tokens.get(),
289
+ bust: opts?.bust
284
290
  });
285
291
  }
286
292
  updateProfile(input) {
@@ -359,16 +365,18 @@ var BillingClient = class {
359
365
  this.workspaceId = workspaceId;
360
366
  }
361
367
  // ── Plans — public read-only ────────────────────────────────────────────────
362
- listPlans() {
368
+ listPlans(opts) {
363
369
  return this.http.request({
364
370
  method: "GET",
365
- path: "/plans"
371
+ path: "/plans",
372
+ bust: opts?.bust
366
373
  });
367
374
  }
368
- getPlan(planId) {
375
+ getPlan(planId, opts) {
369
376
  return this.http.request({
370
377
  method: "GET",
371
- path: `/plans/${planId}`
378
+ path: `/plans/${planId}`,
379
+ bust: opts?.bust
372
380
  });
373
381
  }
374
382
  // ── Plans — admin write ──────────────────────────────────────────────────────
@@ -402,12 +410,13 @@ var BillingClient = class {
402
410
  });
403
411
  }
404
412
  // ── Subscription ─────────────────────────────────────────────────────────────
405
- getSubscription() {
413
+ getSubscription(opts) {
406
414
  return this.http.request({
407
415
  method: "GET",
408
416
  path: "/billing/subscription",
409
417
  token: this.tokens.get(),
410
- workspaceId: this.workspaceId
418
+ workspaceId: this.workspaceId,
419
+ bust: opts?.bust
411
420
  });
412
421
  }
413
422
  // ── Checkout / portal ────────────────────────────────────────────────────────
@@ -438,12 +447,13 @@ var BillingClient = class {
438
447
  workspaceId: this.workspaceId
439
448
  });
440
449
  }
441
- getUsage(metric) {
450
+ getUsage(metric, opts) {
442
451
  return this.http.request({
443
452
  method: "GET",
444
453
  path: `/billing/usage/${metric}`,
445
454
  token: this.tokens.get(),
446
- workspaceId: this.workspaceId
455
+ workspaceId: this.workspaceId,
456
+ bust: opts?.bust
447
457
  });
448
458
  }
449
459
  };
@@ -466,7 +476,7 @@ var CustomersClient = class {
466
476
  this.workspaceId = workspaceId;
467
477
  }
468
478
  // ── Core customer CRUD ───────────────────────────────────────────────────────
469
- listCustomers(input = {}) {
479
+ listCustomers(input = {}, opts) {
470
480
  const params = new URLSearchParams();
471
481
  if (input.search !== void 0) params.set("search", input.search);
472
482
  if (input.blacklisted !== void 0) params.set("blacklisted", String(input.blacklisted));
@@ -477,7 +487,8 @@ var CustomersClient = class {
477
487
  method: "GET",
478
488
  path: qs ? `/customers?${qs}` : "/customers",
479
489
  token: this.tokens.get(),
480
- workspaceId: this.workspaceId
490
+ workspaceId: this.workspaceId,
491
+ bust: opts?.bust
481
492
  });
482
493
  }
483
494
  createCustomer(input = {}) {
@@ -491,13 +502,14 @@ var CustomersClient = class {
491
502
  }
492
503
  // depth defaults to 2 server-side; pass { depth: 1 } for one level of
493
504
  // relationship expansion instead of the D2 (nested-relationships) shape.
494
- getCustomer(customerId, input = {}) {
505
+ getCustomer(customerId, input = {}, opts) {
495
506
  const qs = input.depth === 1 ? "?depth=1" : "";
496
507
  return this.http.request({
497
508
  method: "GET",
498
509
  path: `/customers/${customerId}${qs}`,
499
510
  token: this.tokens.get(),
500
- workspaceId: this.workspaceId
511
+ workspaceId: this.workspaceId,
512
+ bust: opts?.bust
501
513
  });
502
514
  }
503
515
  updateCustomer(customerId, input) {
@@ -535,12 +547,13 @@ var CustomersClient = class {
535
547
  });
536
548
  }
537
549
  // ── Emails ───────────────────────────────────────────────────────────────────
538
- listEmails(customerId) {
550
+ listEmails(customerId, opts) {
539
551
  return this.http.request({
540
552
  method: "GET",
541
553
  path: `/customers/${customerId}/emails`,
542
554
  token: this.tokens.get(),
543
- workspaceId: this.workspaceId
555
+ workspaceId: this.workspaceId,
556
+ bust: opts?.bust
544
557
  });
545
558
  }
546
559
  addEmail(customerId, input) {
@@ -580,12 +593,13 @@ var CustomersClient = class {
580
593
  });
581
594
  }
582
595
  // ── Phones ───────────────────────────────────────────────────────────────────
583
- listPhones(customerId) {
596
+ listPhones(customerId, opts) {
584
597
  return this.http.request({
585
598
  method: "GET",
586
599
  path: `/customers/${customerId}/phones`,
587
600
  token: this.tokens.get(),
588
- workspaceId: this.workspaceId
601
+ workspaceId: this.workspaceId,
602
+ bust: opts?.bust
589
603
  });
590
604
  }
591
605
  addPhone(customerId, input) {
@@ -624,12 +638,13 @@ var CustomersClient = class {
624
638
  });
625
639
  }
626
640
  // ── Addresses ────────────────────────────────────────────────────────────────
627
- listAddresses(customerId) {
641
+ listAddresses(customerId, opts) {
628
642
  return this.http.request({
629
643
  method: "GET",
630
644
  path: `/customers/${customerId}/addresses`,
631
645
  token: this.tokens.get(),
632
- workspaceId: this.workspaceId
646
+ workspaceId: this.workspaceId,
647
+ bust: opts?.bust
633
648
  });
634
649
  }
635
650
  addAddress(customerId, input) {
@@ -668,12 +683,13 @@ var CustomersClient = class {
668
683
  });
669
684
  }
670
685
  // ── Notes ────────────────────────────────────────────────────────────────────
671
- listNotes(customerId) {
686
+ listNotes(customerId, opts) {
672
687
  return this.http.request({
673
688
  method: "GET",
674
689
  path: `/customers/${customerId}/notes`,
675
690
  token: this.tokens.get(),
676
- workspaceId: this.workspaceId
691
+ workspaceId: this.workspaceId,
692
+ bust: opts?.bust
677
693
  });
678
694
  }
679
695
  createNote(customerId, body) {
@@ -703,12 +719,13 @@ var CustomersClient = class {
703
719
  });
704
720
  }
705
721
  // ── Tags ─────────────────────────────────────────────────────────────────────
706
- listTags(customerId) {
722
+ listTags(customerId, opts) {
707
723
  return this.http.request({
708
724
  method: "GET",
709
725
  path: `/customers/${customerId}/tags`,
710
726
  token: this.tokens.get(),
711
- workspaceId: this.workspaceId
727
+ workspaceId: this.workspaceId,
728
+ bust: opts?.bust
712
729
  });
713
730
  }
714
731
  addTag(customerId, tag) {
@@ -729,12 +746,13 @@ var CustomersClient = class {
729
746
  });
730
747
  }
731
748
  // ── Relationships ────────────────────────────────────────────────────────────
732
- listRelationships(customerId) {
749
+ listRelationships(customerId, opts) {
733
750
  return this.http.request({
734
751
  method: "GET",
735
752
  path: `/customers/${customerId}/relationships`,
736
753
  token: this.tokens.get(),
737
- workspaceId: this.workspaceId
754
+ workspaceId: this.workspaceId,
755
+ bust: opts?.bust
738
756
  });
739
757
  }
740
758
  addRelationship(customerId, input) {
@@ -767,12 +785,13 @@ var CustomersClient = class {
767
785
  // looked up/created implicitly by addEmail/addPhone/addAddress's `label`
768
786
  // string; these two methods are for managing the vocabulary directly
769
787
  // (e.g. an admin screen listing/pruning unused labels).
770
- listLabels(type) {
788
+ listLabels(type, opts) {
771
789
  return this.http.request({
772
790
  method: "GET",
773
791
  path: `/customers/labels?type=${type}`,
774
792
  token: this.tokens.get(),
775
- workspaceId: this.workspaceId
793
+ workspaceId: this.workspaceId,
794
+ bust: opts?.bust
776
795
  });
777
796
  }
778
797
  removeLabel(labelId) {
@@ -802,12 +821,13 @@ var WebhooksClient = class {
802
821
  setWorkspaceId(workspaceId) {
803
822
  this.workspaceId = workspaceId;
804
823
  }
805
- listEndpoints() {
824
+ listEndpoints(opts) {
806
825
  return this.http.request({
807
826
  method: "GET",
808
827
  path: "/webhooks",
809
828
  token: this.tokens.get(),
810
- workspaceId: this.workspaceId
829
+ workspaceId: this.workspaceId,
830
+ bust: opts?.bust
811
831
  });
812
832
  }
813
833
  // The response includes `secret` — shown once, at creation. There is no
@@ -821,12 +841,13 @@ var WebhooksClient = class {
821
841
  workspaceId: this.workspaceId
822
842
  });
823
843
  }
824
- getEndpoint(endpointId) {
844
+ getEndpoint(endpointId, opts) {
825
845
  return this.http.request({
826
846
  method: "GET",
827
847
  path: `/webhooks/${endpointId}`,
828
848
  token: this.tokens.get(),
829
- workspaceId: this.workspaceId
849
+ workspaceId: this.workspaceId,
850
+ bust: opts?.bust
830
851
  });
831
852
  }
832
853
  updateEndpoint(endpointId, input) {
@@ -846,12 +867,13 @@ var WebhooksClient = class {
846
867
  workspaceId: this.workspaceId
847
868
  });
848
869
  }
849
- listDeliveries(endpointId) {
870
+ listDeliveries(endpointId, opts) {
850
871
  return this.http.request({
851
872
  method: "GET",
852
873
  path: `/webhooks/${endpointId}/deliveries`,
853
874
  token: this.tokens.get(),
854
- workspaceId: this.workspaceId
875
+ workspaceId: this.workspaceId,
876
+ bust: opts?.bust
855
877
  });
856
878
  }
857
879
  testEndpoint(endpointId) {
@@ -882,11 +904,12 @@ var WorkspacesClient = class {
882
904
  this.workspaceId = workspaceId;
883
905
  }
884
906
  // ── Workspace creation + listing ─────────────────────────────────────────────
885
- listWorkspaces() {
907
+ listWorkspaces(opts) {
886
908
  return this.http.request({
887
909
  method: "GET",
888
910
  path: "/workspaces",
889
- token: this.tokens.get()
911
+ token: this.tokens.get(),
912
+ bust: opts?.bust
890
913
  });
891
914
  }
892
915
  createWorkspace(input) {
@@ -897,11 +920,12 @@ var WorkspacesClient = class {
897
920
  token: this.tokens.get()
898
921
  });
899
922
  }
900
- getWorkspace(id) {
923
+ getWorkspace(id, opts) {
901
924
  return this.http.request({
902
925
  method: "GET",
903
926
  path: `/workspaces/${id}`,
904
- token: this.tokens.get()
927
+ token: this.tokens.get(),
928
+ bust: opts?.bust
905
929
  });
906
930
  }
907
931
  updateWorkspace(input) {
@@ -931,12 +955,13 @@ var WorkspacesClient = class {
931
955
  });
932
956
  }
933
957
  // ── Roles ────────────────────────────────────────────────────────────────────
934
- listRoles() {
958
+ listRoles(opts) {
935
959
  return this.http.request({
936
960
  method: "GET",
937
961
  path: "/workspaces/roles",
938
962
  token: this.tokens.get(),
939
- workspaceId: this.workspaceId
963
+ workspaceId: this.workspaceId,
964
+ bust: opts?.bust
940
965
  });
941
966
  }
942
967
  createRole(input) {
@@ -948,12 +973,13 @@ var WorkspacesClient = class {
948
973
  workspaceId: this.workspaceId
949
974
  });
950
975
  }
951
- getRole(roleId) {
976
+ getRole(roleId, opts) {
952
977
  return this.http.request({
953
978
  method: "GET",
954
979
  path: `/workspaces/roles/${roleId}`,
955
980
  token: this.tokens.get(),
956
- workspaceId: this.workspaceId
981
+ workspaceId: this.workspaceId,
982
+ bust: opts?.bust
957
983
  });
958
984
  }
959
985
  updateRole(roleId, input) {
@@ -973,12 +999,13 @@ var WorkspacesClient = class {
973
999
  workspaceId: this.workspaceId
974
1000
  });
975
1001
  }
976
- getRolePermissions(roleId) {
1002
+ getRolePermissions(roleId, opts) {
977
1003
  return this.http.request({
978
1004
  method: "GET",
979
1005
  path: `/workspaces/roles/${roleId}/permissions`,
980
1006
  token: this.tokens.get(),
981
- workspaceId: this.workspaceId
1007
+ workspaceId: this.workspaceId,
1008
+ bust: opts?.bust
982
1009
  });
983
1010
  }
984
1011
  setRolePermissions(roleId, permissions) {
@@ -991,12 +1018,13 @@ var WorkspacesClient = class {
991
1018
  });
992
1019
  }
993
1020
  // ── Members ──────────────────────────────────────────────────────────────────
994
- listMembers() {
1021
+ listMembers(opts) {
995
1022
  return this.http.request({
996
1023
  method: "GET",
997
1024
  path: "/workspaces/members",
998
1025
  token: this.tokens.get(),
999
- workspaceId: this.workspaceId
1026
+ workspaceId: this.workspaceId,
1027
+ bust: opts?.bust
1000
1028
  });
1001
1029
  }
1002
1030
  removeMember(userId) {
@@ -1007,12 +1035,13 @@ var WorkspacesClient = class {
1007
1035
  workspaceId: this.workspaceId
1008
1036
  });
1009
1037
  }
1010
- getMemberRoles(userId) {
1038
+ getMemberRoles(userId, opts) {
1011
1039
  return this.http.request({
1012
1040
  method: "GET",
1013
1041
  path: `/workspaces/members/${userId}/roles`,
1014
1042
  token: this.tokens.get(),
1015
- workspaceId: this.workspaceId
1043
+ workspaceId: this.workspaceId,
1044
+ bust: opts?.bust
1016
1045
  });
1017
1046
  }
1018
1047
  addMemberRole(userId, roleId) {
@@ -1033,12 +1062,13 @@ var WorkspacesClient = class {
1033
1062
  });
1034
1063
  }
1035
1064
  // ── Invitations ──────────────────────────────────────────────────────────────
1036
- listInvitations() {
1065
+ listInvitations(opts) {
1037
1066
  return this.http.request({
1038
1067
  method: "GET",
1039
1068
  path: "/workspaces/invitations",
1040
1069
  token: this.tokens.get(),
1041
- workspaceId: this.workspaceId
1070
+ workspaceId: this.workspaceId,
1071
+ bust: opts?.bust
1042
1072
  });
1043
1073
  }
1044
1074
  invite(entries) {
@@ -1067,12 +1097,13 @@ var WorkspacesClient = class {
1067
1097
  });
1068
1098
  }
1069
1099
  // ── Settings ─────────────────────────────────────────────────────────────────
1070
- getSettings() {
1100
+ getSettings(opts) {
1071
1101
  return this.http.request({
1072
1102
  method: "GET",
1073
1103
  path: "/workspaces/settings",
1074
1104
  token: this.tokens.get(),
1075
- workspaceId: this.workspaceId
1105
+ workspaceId: this.workspaceId,
1106
+ bust: opts?.bust
1076
1107
  });
1077
1108
  }
1078
1109
  updateSettings(input) {
@@ -1227,9 +1258,11 @@ function envQuery(environment) {
1227
1258
  var ConfigAdminClient = class {
1228
1259
  http;
1229
1260
  adminToken;
1261
+ actorHeaders;
1230
1262
  constructor(opts) {
1231
1263
  this.http = new HttpClient(opts.baseUrl);
1232
1264
  this.adminToken = opts.adminToken;
1265
+ this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1233
1266
  }
1234
1267
  // ── Config ───────────────────────────────────────────────────────────────
1235
1268
  listConfig(environment) {
@@ -1251,14 +1284,16 @@ var ConfigAdminClient = class {
1251
1284
  method: "PUT",
1252
1285
  path: `/admin/config/${key}${envQuery(environment)}`,
1253
1286
  body: input,
1254
- token: this.adminToken
1287
+ token: this.adminToken,
1288
+ headers: this.actorHeaders
1255
1289
  });
1256
1290
  }
1257
1291
  deleteConfig(key, environment) {
1258
1292
  return this.http.request({
1259
1293
  method: "DELETE",
1260
1294
  path: `/admin/config/${key}${envQuery(environment)}`,
1261
- token: this.adminToken
1295
+ token: this.adminToken,
1296
+ headers: this.actorHeaders
1262
1297
  });
1263
1298
  }
1264
1299
  listConfigRevisions(key, environment) {
@@ -1273,7 +1308,8 @@ var ConfigAdminClient = class {
1273
1308
  method: "POST",
1274
1309
  path: `/admin/config/${key}/rollback${envQuery(environment)}`,
1275
1310
  body: input,
1276
- token: this.adminToken
1311
+ token: this.adminToken,
1312
+ headers: this.actorHeaders
1277
1313
  });
1278
1314
  }
1279
1315
  // ── Secrets (masked) ─────────────────────────────────────────────────────
@@ -1296,14 +1332,16 @@ var ConfigAdminClient = class {
1296
1332
  method: "PUT",
1297
1333
  path: `/admin/secrets/${key}${envQuery(environment)}`,
1298
1334
  body: input,
1299
- token: this.adminToken
1335
+ token: this.adminToken,
1336
+ headers: this.actorHeaders
1300
1337
  });
1301
1338
  }
1302
1339
  deleteSecret(key, environment) {
1303
1340
  return this.http.request({
1304
1341
  method: "DELETE",
1305
1342
  path: `/admin/secrets/${key}${envQuery(environment)}`,
1306
- token: this.adminToken
1343
+ token: this.adminToken,
1344
+ headers: this.actorHeaders
1307
1345
  });
1308
1346
  }
1309
1347
  listSecretRevisions(key, environment) {
@@ -1318,7 +1356,8 @@ var ConfigAdminClient = class {
1318
1356
  method: "POST",
1319
1357
  path: `/admin/secrets/${key}/rollback${envQuery(environment)}`,
1320
1358
  body: input,
1321
- token: this.adminToken
1359
+ token: this.adminToken,
1360
+ headers: this.actorHeaders
1322
1361
  });
1323
1362
  }
1324
1363
  // POST (not GET) so the decrypted value never lands in a URL or access log.
@@ -1326,7 +1365,8 @@ var ConfigAdminClient = class {
1326
1365
  return this.http.request({
1327
1366
  method: "POST",
1328
1367
  path: `/admin/secrets/${key}/reveal${envQuery(environment)}`,
1329
- token: this.adminToken
1368
+ token: this.adminToken,
1369
+ headers: this.actorHeaders
1330
1370
  });
1331
1371
  }
1332
1372
  };
@@ -1335,9 +1375,11 @@ var ConfigAdminClient = class {
1335
1375
  var CourierAdminClient = class {
1336
1376
  http;
1337
1377
  adminToken;
1378
+ actorHeaders;
1338
1379
  constructor(opts) {
1339
1380
  this.http = new HttpClient(opts.baseUrl);
1340
1381
  this.adminToken = opts.adminToken;
1382
+ this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1341
1383
  }
1342
1384
  listTemplates() {
1343
1385
  return this.http.request({
@@ -1360,7 +1402,8 @@ var CourierAdminClient = class {
1360
1402
  method: "PUT",
1361
1403
  path: `/admin/templates/${type}${q}`,
1362
1404
  body: input,
1363
- token: this.adminToken
1405
+ token: this.adminToken,
1406
+ headers: this.actorHeaders
1364
1407
  });
1365
1408
  }
1366
1409
  deleteTemplate(type, locale) {
@@ -1368,7 +1411,8 @@ var CourierAdminClient = class {
1368
1411
  return this.http.request({
1369
1412
  method: "DELETE",
1370
1413
  path: `/admin/templates/${type}${q}`,
1371
- token: this.adminToken
1414
+ token: this.adminToken,
1415
+ headers: this.actorHeaders
1372
1416
  });
1373
1417
  }
1374
1418
  listRevisions(type, locale) {
@@ -1385,7 +1429,8 @@ var CourierAdminClient = class {
1385
1429
  method: "POST",
1386
1430
  path: `/admin/templates/${type}/rollback${q}`,
1387
1431
  body: input,
1388
- token: this.adminToken
1432
+ token: this.adminToken,
1433
+ headers: this.actorHeaders
1389
1434
  });
1390
1435
  }
1391
1436
  };