@fonderie/client 0.29.2 → 0.30.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.
@@ -298,7 +298,13 @@ interface IAdminLoginHistoryQuery {
298
298
  cursor?: string;
299
299
  }
300
300
 
301
+ interface IAdminUsersQuery {
302
+ limit?: number;
303
+ cursor?: string;
304
+ }
305
+
301
306
  new AuthAdminClient(opts: IAuthAdminClientOptions): AuthAdminClient
307
+ .listUsers(query?: IAdminUsersQuery): Promise<IApiResponse<IAdminUserPageResult>>
302
308
  .findUser(email: string): Promise<IApiResponse<IAdminUserDTO>>
303
309
  .getUser(id: string): Promise<IApiResponse<IAdminUserDTO>>
304
310
  .listUserSessions(id: string): Promise<IApiResponse<ISessionDTO[]>>
@@ -320,11 +326,17 @@ interface IAdminLedgerQuery {
320
326
  cursor?: string;
321
327
  }
322
328
 
329
+ interface IAdminSubscriptionsQuery {
330
+ limit?: number;
331
+ cursor?: string;
332
+ }
333
+
323
334
  new BillingAdminClient(opts: IBillingAdminClientOptions): BillingAdminClient
324
335
  .catalog(): Promise<IApiResponse<IAdminCatalog>>
325
336
  .createPlan(input: IAdminPlanInput & { name: string; }): Promise<IApiResponse<IPlanDTO>>
326
337
  .updatePlan(planId: string, input: IAdminPlanInput): Promise<IApiResponse<IPlanDTO>>
327
338
  .deletePlan(planId: string): Promise<IApiResponse<undefined>>
339
+ .listSubscriptions(query?: IAdminSubscriptionsQuery): Promise<IApiResponse<IAdminSubscriptionPage>>
328
340
  .subscription(type: SubscriberType, id: string): Promise<IApiResponse<IAdminSubscriptionDTO>>
329
341
  .wallet(type: SubscriberType, id: string, currency?: string | undefined): Promise<IApiResponse<IAdminWalletDTO>>
330
342
  .walletLedger(type: SubscriberType, id: string, query?: IAdminLedgerQuery): Promise<IApiResponse<IAdminWalletLedgerPage>>
@@ -357,6 +369,20 @@ interface ICourierAdminClientOptions {
357
369
  actor?: string;
358
370
  }
359
371
 
372
+ interface IPreviewTemplateInput {
373
+ text: string;
374
+ subject?: string;
375
+ html?: string;
376
+ data?: Record<string, unknown>;
377
+ }
378
+
379
+ interface IRenderedTemplateResult {
380
+ subject?: string;
381
+ html?: string;
382
+ text: string;
383
+ variables: string[];
384
+ }
385
+
360
386
  interface IRollbackTemplateInput {
361
387
  toVersion: number;
362
388
  }
@@ -376,6 +402,7 @@ new CourierAdminClient(opts: ICourierAdminClientOptions): CourierAdminClient
376
402
  .deleteTemplate(type: string, locale?: string | null | undefined): Promise<IApiResponse<undefined>>
377
403
  .listRevisions(type: string, locale?: string | null | undefined): Promise<IApiResponse<ITemplateRevision[]>>
378
404
  .rollback(type: string, input: IRollbackTemplateInput, locale?: string | null | undefined): Promise<IApiResponse<ITemplateEntry>>
405
+ .previewTemplate(type: string, input: IPreviewTemplateInput, locale?: string | null | undefined): Promise<IApiResponse<IRenderedTemplateResult>>
379
406
 
380
407
  interface IAddAddressInput {
381
408
  countryIso: string;
@@ -662,6 +689,11 @@ interface ILoginEventDTO {
662
689
  createdAt: string;
663
690
  }
664
691
 
692
+ interface IAdminUserPageResult {
693
+ users: IAdminUserDTO[];
694
+ nextCursor: string | null;
695
+ }
696
+
665
697
  interface ILoginHistoryPageResult {
666
698
  events: ILoginEventDTO[];
667
699
  nextCursor: string | null;
@@ -859,6 +891,11 @@ interface IAdminWalletDTO extends IWalletDTO {
859
891
  updatedAt: string | null;
860
892
  }
861
893
 
894
+ interface IAdminSubscriptionPage {
895
+ subscriptions: IAdminSubscriptionDTO[];
896
+ nextCursor: string | null;
897
+ }
898
+
862
899
  interface IAdminWalletLedgerPage {
863
900
  currency: string;
864
901
  entries: IWalletTransactionDTO[];
package/dist/index.cjs CHANGED
@@ -1850,6 +1850,15 @@ var AuthAdminClient = class {
1850
1850
  headers: this.actorHeaders
1851
1851
  });
1852
1852
  }
1853
+ // A page of users, newest first. The same route as findUser — with an email
1854
+ // it looks one up, without one it lists.
1855
+ listUsers(query = {}) {
1856
+ const q = new URLSearchParams();
1857
+ if (query.limit) q.set("limit", String(query.limit));
1858
+ if (query.cursor) q.set("cursor", query.cursor);
1859
+ const qs = q.toString();
1860
+ return this.call("GET", qs ? `?${qs}` : "");
1861
+ }
1853
1862
  findUser(email) {
1854
1863
  return this.call("GET", `?email=${encodeURIComponent(email)}`);
1855
1864
  }
@@ -1917,6 +1926,15 @@ var BillingAdminClient = class {
1917
1926
  deletePlan(planId) {
1918
1927
  return this.call("DELETE", `/plans/${encodeURIComponent(planId)}`);
1919
1928
  }
1929
+ // A page of subscribers, newest first. The lookup below still answers for a
1930
+ // known subscriber; this is for finding one you cannot name.
1931
+ listSubscriptions(query = {}) {
1932
+ const q = new URLSearchParams();
1933
+ if (query.limit) q.set("limit", String(query.limit));
1934
+ if (query.cursor) q.set("cursor", query.cursor);
1935
+ const qs = q.toString();
1936
+ return this.call("GET", `/subscriptions${qs ? `?${qs}` : ""}`);
1937
+ }
1920
1938
  subscription(type, id) {
1921
1939
  return this.call("GET", `/subscriptions${this.sub(type, id)}`);
1922
1940
  }
@@ -2055,6 +2073,22 @@ var CourierAdminClient = class {
2055
2073
  })
2056
2074
  );
2057
2075
  }
2076
+ // Renders content you are HOLDING, not what is stored — so an editor can
2077
+ // show the change before it is saved. Server-side on purpose: the shell and
2078
+ // the variable substitution are the resolver's, and a preview rendered any
2079
+ // other way would not be the mail that sends.
2080
+ previewTemplate(type, input, locale) {
2081
+ const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
2082
+ return this.http.request(
2083
+ this.rebase({
2084
+ method: "POST",
2085
+ path: `/admin/templates/${encodeURIComponent(type)}/preview${q}`,
2086
+ body: input,
2087
+ token: this.adminToken,
2088
+ headers: this.actorHeaders
2089
+ })
2090
+ );
2091
+ }
2058
2092
  };
2059
2093
 
2060
2094
  // src/types.ts