@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.cjs CHANGED
@@ -132,6 +132,7 @@ var HttpClient = class {
132
132
  if (opts.token) headers["Authorization"] = `Bearer ${opts.token}`;
133
133
  if (opts.cookie) headers["Cookie"] = opts.cookie;
134
134
  if (opts.workspaceId) headers["X-Workspace-ID"] = opts.workspaceId;
135
+ Object.assign(headers, opts.headers ?? {});
135
136
  const fetchInit = { method: opts.method, headers, credentials: "include" };
136
137
  if (opts.body !== void 0) fetchInit.body = JSON.stringify(opts.body);
137
138
  const res = await fetch(`${this.baseUrl}${opts.path}`, fetchInit);
@@ -169,7 +170,7 @@ var AuditClient = class {
169
170
  setWorkspaceId(workspaceId) {
170
171
  this.workspaceId = workspaceId;
171
172
  }
172
- listEvents(input = {}) {
173
+ listEvents(input = {}, opts) {
173
174
  const params = new URLSearchParams();
174
175
  if (input.limit !== void 0) params.set("limit", String(input.limit));
175
176
  if (input.type) params.set("type", input.type);
@@ -182,7 +183,8 @@ var AuditClient = class {
182
183
  method: "GET",
183
184
  path: `/audit${qs ? `?${qs}` : ""}`,
184
185
  token: this.tokens.get(),
185
- workspaceId: this.workspaceId
186
+ workspaceId: this.workspaceId,
187
+ bust: opts?.bust
186
188
  });
187
189
  }
188
190
  };
@@ -309,15 +311,19 @@ var AuthClient = class {
309
311
  return this.http.request({
310
312
  method: "GET",
311
313
  path: "/auth/send-verification",
312
- token: this.tokens.get()
314
+ token: this.tokens.get(),
315
+ // A send-action on a GET route: never serve it from the cache, or a
316
+ // resend inside the TTL would silently no-op.
317
+ cache: false
313
318
  });
314
319
  }
315
320
  // ── Protected + Verified ───────────────────────────────────────────────────
316
- getUser() {
321
+ getUser(opts) {
317
322
  return this.http.request({
318
323
  method: "GET",
319
324
  path: "/users",
320
- token: this.tokens.get()
325
+ token: this.tokens.get(),
326
+ bust: opts?.bust
321
327
  });
322
328
  }
323
329
  updateProfile(input) {
@@ -396,16 +402,18 @@ var BillingClient = class {
396
402
  this.workspaceId = workspaceId;
397
403
  }
398
404
  // ── Plans — public read-only ────────────────────────────────────────────────
399
- listPlans() {
405
+ listPlans(opts) {
400
406
  return this.http.request({
401
407
  method: "GET",
402
- path: "/plans"
408
+ path: "/plans",
409
+ bust: opts?.bust
403
410
  });
404
411
  }
405
- getPlan(planId) {
412
+ getPlan(planId, opts) {
406
413
  return this.http.request({
407
414
  method: "GET",
408
- path: `/plans/${planId}`
415
+ path: `/plans/${planId}`,
416
+ bust: opts?.bust
409
417
  });
410
418
  }
411
419
  // ── Plans — admin write ──────────────────────────────────────────────────────
@@ -439,12 +447,13 @@ var BillingClient = class {
439
447
  });
440
448
  }
441
449
  // ── Subscription ─────────────────────────────────────────────────────────────
442
- getSubscription() {
450
+ getSubscription(opts) {
443
451
  return this.http.request({
444
452
  method: "GET",
445
453
  path: "/billing/subscription",
446
454
  token: this.tokens.get(),
447
- workspaceId: this.workspaceId
455
+ workspaceId: this.workspaceId,
456
+ bust: opts?.bust
448
457
  });
449
458
  }
450
459
  // ── Checkout / portal ────────────────────────────────────────────────────────
@@ -475,12 +484,13 @@ var BillingClient = class {
475
484
  workspaceId: this.workspaceId
476
485
  });
477
486
  }
478
- getUsage(metric) {
487
+ getUsage(metric, opts) {
479
488
  return this.http.request({
480
489
  method: "GET",
481
490
  path: `/billing/usage/${metric}`,
482
491
  token: this.tokens.get(),
483
- workspaceId: this.workspaceId
492
+ workspaceId: this.workspaceId,
493
+ bust: opts?.bust
484
494
  });
485
495
  }
486
496
  };
@@ -503,7 +513,7 @@ var CustomersClient = class {
503
513
  this.workspaceId = workspaceId;
504
514
  }
505
515
  // ── Core customer CRUD ───────────────────────────────────────────────────────
506
- listCustomers(input = {}) {
516
+ listCustomers(input = {}, opts) {
507
517
  const params = new URLSearchParams();
508
518
  if (input.search !== void 0) params.set("search", input.search);
509
519
  if (input.blacklisted !== void 0) params.set("blacklisted", String(input.blacklisted));
@@ -514,7 +524,8 @@ var CustomersClient = class {
514
524
  method: "GET",
515
525
  path: qs ? `/customers?${qs}` : "/customers",
516
526
  token: this.tokens.get(),
517
- workspaceId: this.workspaceId
527
+ workspaceId: this.workspaceId,
528
+ bust: opts?.bust
518
529
  });
519
530
  }
520
531
  createCustomer(input = {}) {
@@ -528,13 +539,14 @@ var CustomersClient = class {
528
539
  }
529
540
  // depth defaults to 2 server-side; pass { depth: 1 } for one level of
530
541
  // relationship expansion instead of the D2 (nested-relationships) shape.
531
- getCustomer(customerId, input = {}) {
542
+ getCustomer(customerId, input = {}, opts) {
532
543
  const qs = input.depth === 1 ? "?depth=1" : "";
533
544
  return this.http.request({
534
545
  method: "GET",
535
546
  path: `/customers/${customerId}${qs}`,
536
547
  token: this.tokens.get(),
537
- workspaceId: this.workspaceId
548
+ workspaceId: this.workspaceId,
549
+ bust: opts?.bust
538
550
  });
539
551
  }
540
552
  updateCustomer(customerId, input) {
@@ -572,12 +584,13 @@ var CustomersClient = class {
572
584
  });
573
585
  }
574
586
  // ── Emails ───────────────────────────────────────────────────────────────────
575
- listEmails(customerId) {
587
+ listEmails(customerId, opts) {
576
588
  return this.http.request({
577
589
  method: "GET",
578
590
  path: `/customers/${customerId}/emails`,
579
591
  token: this.tokens.get(),
580
- workspaceId: this.workspaceId
592
+ workspaceId: this.workspaceId,
593
+ bust: opts?.bust
581
594
  });
582
595
  }
583
596
  addEmail(customerId, input) {
@@ -617,12 +630,13 @@ var CustomersClient = class {
617
630
  });
618
631
  }
619
632
  // ── Phones ───────────────────────────────────────────────────────────────────
620
- listPhones(customerId) {
633
+ listPhones(customerId, opts) {
621
634
  return this.http.request({
622
635
  method: "GET",
623
636
  path: `/customers/${customerId}/phones`,
624
637
  token: this.tokens.get(),
625
- workspaceId: this.workspaceId
638
+ workspaceId: this.workspaceId,
639
+ bust: opts?.bust
626
640
  });
627
641
  }
628
642
  addPhone(customerId, input) {
@@ -661,12 +675,13 @@ var CustomersClient = class {
661
675
  });
662
676
  }
663
677
  // ── Addresses ────────────────────────────────────────────────────────────────
664
- listAddresses(customerId) {
678
+ listAddresses(customerId, opts) {
665
679
  return this.http.request({
666
680
  method: "GET",
667
681
  path: `/customers/${customerId}/addresses`,
668
682
  token: this.tokens.get(),
669
- workspaceId: this.workspaceId
683
+ workspaceId: this.workspaceId,
684
+ bust: opts?.bust
670
685
  });
671
686
  }
672
687
  addAddress(customerId, input) {
@@ -705,12 +720,13 @@ var CustomersClient = class {
705
720
  });
706
721
  }
707
722
  // ── Notes ────────────────────────────────────────────────────────────────────
708
- listNotes(customerId) {
723
+ listNotes(customerId, opts) {
709
724
  return this.http.request({
710
725
  method: "GET",
711
726
  path: `/customers/${customerId}/notes`,
712
727
  token: this.tokens.get(),
713
- workspaceId: this.workspaceId
728
+ workspaceId: this.workspaceId,
729
+ bust: opts?.bust
714
730
  });
715
731
  }
716
732
  createNote(customerId, body) {
@@ -740,12 +756,13 @@ var CustomersClient = class {
740
756
  });
741
757
  }
742
758
  // ── Tags ─────────────────────────────────────────────────────────────────────
743
- listTags(customerId) {
759
+ listTags(customerId, opts) {
744
760
  return this.http.request({
745
761
  method: "GET",
746
762
  path: `/customers/${customerId}/tags`,
747
763
  token: this.tokens.get(),
748
- workspaceId: this.workspaceId
764
+ workspaceId: this.workspaceId,
765
+ bust: opts?.bust
749
766
  });
750
767
  }
751
768
  addTag(customerId, tag) {
@@ -766,12 +783,13 @@ var CustomersClient = class {
766
783
  });
767
784
  }
768
785
  // ── Relationships ────────────────────────────────────────────────────────────
769
- listRelationships(customerId) {
786
+ listRelationships(customerId, opts) {
770
787
  return this.http.request({
771
788
  method: "GET",
772
789
  path: `/customers/${customerId}/relationships`,
773
790
  token: this.tokens.get(),
774
- workspaceId: this.workspaceId
791
+ workspaceId: this.workspaceId,
792
+ bust: opts?.bust
775
793
  });
776
794
  }
777
795
  addRelationship(customerId, input) {
@@ -804,12 +822,13 @@ var CustomersClient = class {
804
822
  // looked up/created implicitly by addEmail/addPhone/addAddress's `label`
805
823
  // string; these two methods are for managing the vocabulary directly
806
824
  // (e.g. an admin screen listing/pruning unused labels).
807
- listLabels(type) {
825
+ listLabels(type, opts) {
808
826
  return this.http.request({
809
827
  method: "GET",
810
828
  path: `/customers/labels?type=${type}`,
811
829
  token: this.tokens.get(),
812
- workspaceId: this.workspaceId
830
+ workspaceId: this.workspaceId,
831
+ bust: opts?.bust
813
832
  });
814
833
  }
815
834
  removeLabel(labelId) {
@@ -839,12 +858,13 @@ var WebhooksClient = class {
839
858
  setWorkspaceId(workspaceId) {
840
859
  this.workspaceId = workspaceId;
841
860
  }
842
- listEndpoints() {
861
+ listEndpoints(opts) {
843
862
  return this.http.request({
844
863
  method: "GET",
845
864
  path: "/webhooks",
846
865
  token: this.tokens.get(),
847
- workspaceId: this.workspaceId
866
+ workspaceId: this.workspaceId,
867
+ bust: opts?.bust
848
868
  });
849
869
  }
850
870
  // The response includes `secret` — shown once, at creation. There is no
@@ -858,12 +878,13 @@ var WebhooksClient = class {
858
878
  workspaceId: this.workspaceId
859
879
  });
860
880
  }
861
- getEndpoint(endpointId) {
881
+ getEndpoint(endpointId, opts) {
862
882
  return this.http.request({
863
883
  method: "GET",
864
884
  path: `/webhooks/${endpointId}`,
865
885
  token: this.tokens.get(),
866
- workspaceId: this.workspaceId
886
+ workspaceId: this.workspaceId,
887
+ bust: opts?.bust
867
888
  });
868
889
  }
869
890
  updateEndpoint(endpointId, input) {
@@ -883,12 +904,13 @@ var WebhooksClient = class {
883
904
  workspaceId: this.workspaceId
884
905
  });
885
906
  }
886
- listDeliveries(endpointId) {
907
+ listDeliveries(endpointId, opts) {
887
908
  return this.http.request({
888
909
  method: "GET",
889
910
  path: `/webhooks/${endpointId}/deliveries`,
890
911
  token: this.tokens.get(),
891
- workspaceId: this.workspaceId
912
+ workspaceId: this.workspaceId,
913
+ bust: opts?.bust
892
914
  });
893
915
  }
894
916
  testEndpoint(endpointId) {
@@ -919,11 +941,12 @@ var WorkspacesClient = class {
919
941
  this.workspaceId = workspaceId;
920
942
  }
921
943
  // ── Workspace creation + listing ─────────────────────────────────────────────
922
- listWorkspaces() {
944
+ listWorkspaces(opts) {
923
945
  return this.http.request({
924
946
  method: "GET",
925
947
  path: "/workspaces",
926
- token: this.tokens.get()
948
+ token: this.tokens.get(),
949
+ bust: opts?.bust
927
950
  });
928
951
  }
929
952
  createWorkspace(input) {
@@ -934,11 +957,12 @@ var WorkspacesClient = class {
934
957
  token: this.tokens.get()
935
958
  });
936
959
  }
937
- getWorkspace(id) {
960
+ getWorkspace(id, opts) {
938
961
  return this.http.request({
939
962
  method: "GET",
940
963
  path: `/workspaces/${id}`,
941
- token: this.tokens.get()
964
+ token: this.tokens.get(),
965
+ bust: opts?.bust
942
966
  });
943
967
  }
944
968
  updateWorkspace(input) {
@@ -968,12 +992,13 @@ var WorkspacesClient = class {
968
992
  });
969
993
  }
970
994
  // ── Roles ────────────────────────────────────────────────────────────────────
971
- listRoles() {
995
+ listRoles(opts) {
972
996
  return this.http.request({
973
997
  method: "GET",
974
998
  path: "/workspaces/roles",
975
999
  token: this.tokens.get(),
976
- workspaceId: this.workspaceId
1000
+ workspaceId: this.workspaceId,
1001
+ bust: opts?.bust
977
1002
  });
978
1003
  }
979
1004
  createRole(input) {
@@ -985,12 +1010,13 @@ var WorkspacesClient = class {
985
1010
  workspaceId: this.workspaceId
986
1011
  });
987
1012
  }
988
- getRole(roleId) {
1013
+ getRole(roleId, opts) {
989
1014
  return this.http.request({
990
1015
  method: "GET",
991
1016
  path: `/workspaces/roles/${roleId}`,
992
1017
  token: this.tokens.get(),
993
- workspaceId: this.workspaceId
1018
+ workspaceId: this.workspaceId,
1019
+ bust: opts?.bust
994
1020
  });
995
1021
  }
996
1022
  updateRole(roleId, input) {
@@ -1010,12 +1036,13 @@ var WorkspacesClient = class {
1010
1036
  workspaceId: this.workspaceId
1011
1037
  });
1012
1038
  }
1013
- getRolePermissions(roleId) {
1039
+ getRolePermissions(roleId, opts) {
1014
1040
  return this.http.request({
1015
1041
  method: "GET",
1016
1042
  path: `/workspaces/roles/${roleId}/permissions`,
1017
1043
  token: this.tokens.get(),
1018
- workspaceId: this.workspaceId
1044
+ workspaceId: this.workspaceId,
1045
+ bust: opts?.bust
1019
1046
  });
1020
1047
  }
1021
1048
  setRolePermissions(roleId, permissions) {
@@ -1028,12 +1055,13 @@ var WorkspacesClient = class {
1028
1055
  });
1029
1056
  }
1030
1057
  // ── Members ──────────────────────────────────────────────────────────────────
1031
- listMembers() {
1058
+ listMembers(opts) {
1032
1059
  return this.http.request({
1033
1060
  method: "GET",
1034
1061
  path: "/workspaces/members",
1035
1062
  token: this.tokens.get(),
1036
- workspaceId: this.workspaceId
1063
+ workspaceId: this.workspaceId,
1064
+ bust: opts?.bust
1037
1065
  });
1038
1066
  }
1039
1067
  removeMember(userId) {
@@ -1044,12 +1072,13 @@ var WorkspacesClient = class {
1044
1072
  workspaceId: this.workspaceId
1045
1073
  });
1046
1074
  }
1047
- getMemberRoles(userId) {
1075
+ getMemberRoles(userId, opts) {
1048
1076
  return this.http.request({
1049
1077
  method: "GET",
1050
1078
  path: `/workspaces/members/${userId}/roles`,
1051
1079
  token: this.tokens.get(),
1052
- workspaceId: this.workspaceId
1080
+ workspaceId: this.workspaceId,
1081
+ bust: opts?.bust
1053
1082
  });
1054
1083
  }
1055
1084
  addMemberRole(userId, roleId) {
@@ -1070,12 +1099,13 @@ var WorkspacesClient = class {
1070
1099
  });
1071
1100
  }
1072
1101
  // ── Invitations ──────────────────────────────────────────────────────────────
1073
- listInvitations() {
1102
+ listInvitations(opts) {
1074
1103
  return this.http.request({
1075
1104
  method: "GET",
1076
1105
  path: "/workspaces/invitations",
1077
1106
  token: this.tokens.get(),
1078
- workspaceId: this.workspaceId
1107
+ workspaceId: this.workspaceId,
1108
+ bust: opts?.bust
1079
1109
  });
1080
1110
  }
1081
1111
  invite(entries) {
@@ -1104,12 +1134,13 @@ var WorkspacesClient = class {
1104
1134
  });
1105
1135
  }
1106
1136
  // ── Settings ─────────────────────────────────────────────────────────────────
1107
- getSettings() {
1137
+ getSettings(opts) {
1108
1138
  return this.http.request({
1109
1139
  method: "GET",
1110
1140
  path: "/workspaces/settings",
1111
1141
  token: this.tokens.get(),
1112
- workspaceId: this.workspaceId
1142
+ workspaceId: this.workspaceId,
1143
+ bust: opts?.bust
1113
1144
  });
1114
1145
  }
1115
1146
  updateSettings(input) {
@@ -1264,9 +1295,11 @@ function envQuery(environment) {
1264
1295
  var ConfigAdminClient = class {
1265
1296
  http;
1266
1297
  adminToken;
1298
+ actorHeaders;
1267
1299
  constructor(opts) {
1268
1300
  this.http = new HttpClient(opts.baseUrl);
1269
1301
  this.adminToken = opts.adminToken;
1302
+ this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1270
1303
  }
1271
1304
  // ── Config ───────────────────────────────────────────────────────────────
1272
1305
  listConfig(environment) {
@@ -1288,14 +1321,16 @@ var ConfigAdminClient = class {
1288
1321
  method: "PUT",
1289
1322
  path: `/admin/config/${key}${envQuery(environment)}`,
1290
1323
  body: input,
1291
- token: this.adminToken
1324
+ token: this.adminToken,
1325
+ headers: this.actorHeaders
1292
1326
  });
1293
1327
  }
1294
1328
  deleteConfig(key, environment) {
1295
1329
  return this.http.request({
1296
1330
  method: "DELETE",
1297
1331
  path: `/admin/config/${key}${envQuery(environment)}`,
1298
- token: this.adminToken
1332
+ token: this.adminToken,
1333
+ headers: this.actorHeaders
1299
1334
  });
1300
1335
  }
1301
1336
  listConfigRevisions(key, environment) {
@@ -1310,7 +1345,8 @@ var ConfigAdminClient = class {
1310
1345
  method: "POST",
1311
1346
  path: `/admin/config/${key}/rollback${envQuery(environment)}`,
1312
1347
  body: input,
1313
- token: this.adminToken
1348
+ token: this.adminToken,
1349
+ headers: this.actorHeaders
1314
1350
  });
1315
1351
  }
1316
1352
  // ── Secrets (masked) ─────────────────────────────────────────────────────
@@ -1333,14 +1369,16 @@ var ConfigAdminClient = class {
1333
1369
  method: "PUT",
1334
1370
  path: `/admin/secrets/${key}${envQuery(environment)}`,
1335
1371
  body: input,
1336
- token: this.adminToken
1372
+ token: this.adminToken,
1373
+ headers: this.actorHeaders
1337
1374
  });
1338
1375
  }
1339
1376
  deleteSecret(key, environment) {
1340
1377
  return this.http.request({
1341
1378
  method: "DELETE",
1342
1379
  path: `/admin/secrets/${key}${envQuery(environment)}`,
1343
- token: this.adminToken
1380
+ token: this.adminToken,
1381
+ headers: this.actorHeaders
1344
1382
  });
1345
1383
  }
1346
1384
  listSecretRevisions(key, environment) {
@@ -1355,7 +1393,8 @@ var ConfigAdminClient = class {
1355
1393
  method: "POST",
1356
1394
  path: `/admin/secrets/${key}/rollback${envQuery(environment)}`,
1357
1395
  body: input,
1358
- token: this.adminToken
1396
+ token: this.adminToken,
1397
+ headers: this.actorHeaders
1359
1398
  });
1360
1399
  }
1361
1400
  // POST (not GET) so the decrypted value never lands in a URL or access log.
@@ -1363,7 +1402,8 @@ var ConfigAdminClient = class {
1363
1402
  return this.http.request({
1364
1403
  method: "POST",
1365
1404
  path: `/admin/secrets/${key}/reveal${envQuery(environment)}`,
1366
- token: this.adminToken
1405
+ token: this.adminToken,
1406
+ headers: this.actorHeaders
1367
1407
  });
1368
1408
  }
1369
1409
  };
@@ -1372,9 +1412,11 @@ var ConfigAdminClient = class {
1372
1412
  var CourierAdminClient = class {
1373
1413
  http;
1374
1414
  adminToken;
1415
+ actorHeaders;
1375
1416
  constructor(opts) {
1376
1417
  this.http = new HttpClient(opts.baseUrl);
1377
1418
  this.adminToken = opts.adminToken;
1419
+ this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1378
1420
  }
1379
1421
  listTemplates() {
1380
1422
  return this.http.request({
@@ -1397,7 +1439,8 @@ var CourierAdminClient = class {
1397
1439
  method: "PUT",
1398
1440
  path: `/admin/templates/${type}${q}`,
1399
1441
  body: input,
1400
- token: this.adminToken
1442
+ token: this.adminToken,
1443
+ headers: this.actorHeaders
1401
1444
  });
1402
1445
  }
1403
1446
  deleteTemplate(type, locale) {
@@ -1405,7 +1448,8 @@ var CourierAdminClient = class {
1405
1448
  return this.http.request({
1406
1449
  method: "DELETE",
1407
1450
  path: `/admin/templates/${type}${q}`,
1408
- token: this.adminToken
1451
+ token: this.adminToken,
1452
+ headers: this.actorHeaders
1409
1453
  });
1410
1454
  }
1411
1455
  listRevisions(type, locale) {
@@ -1422,7 +1466,8 @@ var CourierAdminClient = class {
1422
1466
  method: "POST",
1423
1467
  path: `/admin/templates/${type}/rollback${q}`,
1424
1468
  body: input,
1425
- token: this.adminToken
1469
+ token: this.adminToken,
1470
+ headers: this.actorHeaders
1426
1471
  });
1427
1472
  }
1428
1473
  };