@fonderie/client 0.29.2 → 0.31.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.
@@ -285,6 +285,8 @@ new AdminClient(opts: IAdminClientOptions): AdminClient
285
285
  .adminLog(query?: IAdminLogQuery): Promise<IApiResponse<IAdminLogPage>>
286
286
  .issueToken(input: IAdminIssueTokenInput): Promise<IApiResponse<IAdminIssuedToken>>
287
287
  .revokeToken(id: string): Promise<IApiResponse<undefined>>
288
+ .migrations(): Promise<IApiResponse<IAdminMigrationsReport>>
289
+ .applyMigrations(module: string, expect: readonly string[]): Promise<IApiResponse<IAdminMigrationModule>>
288
290
 
289
291
  interface IAuthAdminClientOptions {
290
292
  baseUrl: string;
@@ -298,7 +300,13 @@ interface IAdminLoginHistoryQuery {
298
300
  cursor?: string;
299
301
  }
300
302
 
303
+ interface IAdminUsersQuery {
304
+ limit?: number;
305
+ cursor?: string;
306
+ }
307
+
301
308
  new AuthAdminClient(opts: IAuthAdminClientOptions): AuthAdminClient
309
+ .listUsers(query?: IAdminUsersQuery): Promise<IApiResponse<IAdminUserPageResult>>
302
310
  .findUser(email: string): Promise<IApiResponse<IAdminUserDTO>>
303
311
  .getUser(id: string): Promise<IApiResponse<IAdminUserDTO>>
304
312
  .listUserSessions(id: string): Promise<IApiResponse<ISessionDTO[]>>
@@ -320,11 +328,17 @@ interface IAdminLedgerQuery {
320
328
  cursor?: string;
321
329
  }
322
330
 
331
+ interface IAdminSubscriptionsQuery {
332
+ limit?: number;
333
+ cursor?: string;
334
+ }
335
+
323
336
  new BillingAdminClient(opts: IBillingAdminClientOptions): BillingAdminClient
324
337
  .catalog(): Promise<IApiResponse<IAdminCatalog>>
325
338
  .createPlan(input: IAdminPlanInput & { name: string; }): Promise<IApiResponse<IPlanDTO>>
326
339
  .updatePlan(planId: string, input: IAdminPlanInput): Promise<IApiResponse<IPlanDTO>>
327
340
  .deletePlan(planId: string): Promise<IApiResponse<undefined>>
341
+ .listSubscriptions(query?: IAdminSubscriptionsQuery): Promise<IApiResponse<IAdminSubscriptionPage>>
328
342
  .subscription(type: SubscriberType, id: string): Promise<IApiResponse<IAdminSubscriptionDTO>>
329
343
  .wallet(type: SubscriberType, id: string, currency?: string | undefined): Promise<IApiResponse<IAdminWalletDTO>>
330
344
  .walletLedger(type: SubscriberType, id: string, query?: IAdminLedgerQuery): Promise<IApiResponse<IAdminWalletLedgerPage>>
@@ -357,6 +371,20 @@ interface ICourierAdminClientOptions {
357
371
  actor?: string;
358
372
  }
359
373
 
374
+ interface IPreviewTemplateInput {
375
+ text: string;
376
+ subject?: string;
377
+ html?: string;
378
+ data?: Record<string, unknown>;
379
+ }
380
+
381
+ interface IRenderedTemplateResult {
382
+ subject?: string;
383
+ html?: string;
384
+ text: string;
385
+ variables: string[];
386
+ }
387
+
360
388
  interface IRollbackTemplateInput {
361
389
  toVersion: number;
362
390
  }
@@ -376,6 +404,7 @@ new CourierAdminClient(opts: ICourierAdminClientOptions): CourierAdminClient
376
404
  .deleteTemplate(type: string, locale?: string | null | undefined): Promise<IApiResponse<undefined>>
377
405
  .listRevisions(type: string, locale?: string | null | undefined): Promise<IApiResponse<ITemplateRevision[]>>
378
406
  .rollback(type: string, input: IRollbackTemplateInput, locale?: string | null | undefined): Promise<IApiResponse<ITemplateEntry>>
407
+ .previewTemplate(type: string, input: IPreviewTemplateInput, locale?: string | null | undefined): Promise<IApiResponse<IRenderedTemplateResult>>
379
408
 
380
409
  interface IAddAddressInput {
381
410
  countryIso: string;
@@ -662,6 +691,11 @@ interface ILoginEventDTO {
662
691
  createdAt: string;
663
692
  }
664
693
 
694
+ interface IAdminUserPageResult {
695
+ users: IAdminUserDTO[];
696
+ nextCursor: string | null;
697
+ }
698
+
665
699
  interface ILoginHistoryPageResult {
666
700
  events: ILoginEventDTO[];
667
701
  nextCursor: string | null;
@@ -829,6 +863,26 @@ interface IAdminIssuedToken extends IAdminTokenRecord {
829
863
  token: string;
830
864
  }
831
865
 
866
+ type MigrationImpact = 'additive' | 'destructive';
867
+
868
+ interface IAdminPendingMigration {
869
+ file: string;
870
+ impact: MigrationImpact;
871
+ destructive: string[];
872
+ }
873
+
874
+ interface IAdminMigrationModule {
875
+ name: string;
876
+ pending: IAdminPendingMigration[];
877
+ blockedBy: string | null;
878
+ appliable: boolean;
879
+ }
880
+
881
+ interface IAdminMigrationsReport {
882
+ everApplied: boolean;
883
+ modules: IAdminMigrationModule[];
884
+ }
885
+
832
886
  interface IAdminUserDTO extends IUserDTO {
833
887
  deletedAt: string | null;
834
888
  }
@@ -859,6 +913,11 @@ interface IAdminWalletDTO extends IWalletDTO {
859
913
  updatedAt: string | null;
860
914
  }
861
915
 
916
+ interface IAdminSubscriptionPage {
917
+ subscriptions: IAdminSubscriptionDTO[];
918
+ nextCursor: string | null;
919
+ }
920
+
862
921
  interface IAdminWalletLedgerPage {
863
922
  currency: string;
864
923
  entries: IWalletTransactionDTO[];
package/dist/index.cjs CHANGED
@@ -1828,6 +1828,26 @@ var AdminClient = class {
1828
1828
  revokeToken(id) {
1829
1829
  return this.call("DELETE", `/access/tokens/${encodeURIComponent(id)}`);
1830
1830
  }
1831
+ // What each module is waiting on, with every pending file's impact. Empty
1832
+ // when the deployment did not hand its migration sequence to the surface.
1833
+ migrations() {
1834
+ return this.get("/migrations");
1835
+ }
1836
+ /**
1837
+ * Apply one module's pending migrations — all of them, or none.
1838
+ *
1839
+ * `expect` is the pending list you were shown, in order. If it no longer
1840
+ * matches, the server refuses with 409 MIGRATIONS_CHANGED rather than
1841
+ * applying something nobody reviewed. Also refuses 409 when an earlier
1842
+ * module is behind, and 422 when any pending file deletes data.
1843
+ */
1844
+ applyMigrations(module2, expect) {
1845
+ return this.call(
1846
+ "POST",
1847
+ `/migrations/${encodeURIComponent(module2)}/apply`,
1848
+ { expect }
1849
+ );
1850
+ }
1831
1851
  };
1832
1852
 
1833
1853
  // src/modules/auth-admin.ts
@@ -1850,6 +1870,15 @@ var AuthAdminClient = class {
1850
1870
  headers: this.actorHeaders
1851
1871
  });
1852
1872
  }
1873
+ // A page of users, newest first. The same route as findUser — with an email
1874
+ // it looks one up, without one it lists.
1875
+ listUsers(query = {}) {
1876
+ const q = new URLSearchParams();
1877
+ if (query.limit) q.set("limit", String(query.limit));
1878
+ if (query.cursor) q.set("cursor", query.cursor);
1879
+ const qs = q.toString();
1880
+ return this.call("GET", qs ? `?${qs}` : "");
1881
+ }
1853
1882
  findUser(email) {
1854
1883
  return this.call("GET", `?email=${encodeURIComponent(email)}`);
1855
1884
  }
@@ -1917,6 +1946,15 @@ var BillingAdminClient = class {
1917
1946
  deletePlan(planId) {
1918
1947
  return this.call("DELETE", `/plans/${encodeURIComponent(planId)}`);
1919
1948
  }
1949
+ // A page of subscribers, newest first. The lookup below still answers for a
1950
+ // known subscriber; this is for finding one you cannot name.
1951
+ listSubscriptions(query = {}) {
1952
+ const q = new URLSearchParams();
1953
+ if (query.limit) q.set("limit", String(query.limit));
1954
+ if (query.cursor) q.set("cursor", query.cursor);
1955
+ const qs = q.toString();
1956
+ return this.call("GET", `/subscriptions${qs ? `?${qs}` : ""}`);
1957
+ }
1920
1958
  subscription(type, id) {
1921
1959
  return this.call("GET", `/subscriptions${this.sub(type, id)}`);
1922
1960
  }
@@ -2055,6 +2093,22 @@ var CourierAdminClient = class {
2055
2093
  })
2056
2094
  );
2057
2095
  }
2096
+ // Renders content you are HOLDING, not what is stored — so an editor can
2097
+ // show the change before it is saved. Server-side on purpose: the shell and
2098
+ // the variable substitution are the resolver's, and a preview rendered any
2099
+ // other way would not be the mail that sends.
2100
+ previewTemplate(type, input, locale) {
2101
+ const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
2102
+ return this.http.request(
2103
+ this.rebase({
2104
+ method: "POST",
2105
+ path: `/admin/templates/${encodeURIComponent(type)}/preview${q}`,
2106
+ body: input,
2107
+ token: this.adminToken,
2108
+ headers: this.actorHeaders
2109
+ })
2110
+ );
2111
+ }
2058
2112
  };
2059
2113
 
2060
2114
  // src/types.ts