@outseta/react 0.5.1 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outseta/react",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "React hooks and components for the Outseta API",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@outseta/api-client": "0.4.1"
21
+ "@outseta/api-client": "0.4.3"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^18.0.0 || ^19.0.0"
@@ -821,6 +821,8 @@ export type StripeInvoiceAllOf = {
821
821
  /** @nullable */
822
822
  CustomerId?: string | null;
823
823
  /** @nullable */
824
+ EffectiveDate?: string | null;
825
+ /** @nullable */
824
826
  PaymentStatus?: string | null;
825
827
  /** @nullable */
826
828
  StripeCreditNotes?: StripeCreditNote[] | null;
@@ -1405,6 +1407,12 @@ export type StripeProductFamilyAllOf = {
1405
1407
  IsActive?: boolean;
1406
1408
  IsDefault?: boolean;
1407
1409
  /** @nullable */
1410
+ BillingCycleAnchorDayOfMonth?: number | null;
1411
+ /** @nullable */
1412
+ BillingCycleAnchorHour?: number | null;
1413
+ /** @nullable */
1414
+ BillingCycleAnchorMonth?: number | null;
1415
+ /** @nullable */
1408
1416
  StripeProducts?: StripeProduct[] | null;
1409
1417
  [key: string]: unknown | null;
1410
1418
  };
@@ -1503,6 +1511,8 @@ export type StripeSubscriptionAllOf = {
1503
1511
  /** @nullable */
1504
1512
  ApplicationFeePercent?: number | null;
1505
1513
  /** @nullable */
1514
+ BillingCycleAnchor?: string | null;
1515
+ /** @nullable */
1506
1516
  CancelAt?: string | null;
1507
1517
  CancelAtPeriodEnd?: boolean;
1508
1518
  /** @nullable */
@@ -1540,14 +1550,14 @@ export type StripeSubscriptionAllOf = {
1540
1550
  /** @nullable */
1541
1551
  AccountUid?: string | null;
1542
1552
  /** @nullable */
1543
- BillingCycleAnchor?: string | null;
1544
- /** @nullable */
1545
1553
  CollectionMethod?: string | null;
1546
1554
  /** @nullable */
1547
1555
  CustomerId?: string | null;
1548
1556
  /** @nullable */
1549
1557
  DaysUntilDue?: number | null;
1550
1558
  /** @nullable */
1559
+ PaymentUrl?: string | null;
1560
+ /** @nullable */
1551
1561
  ScheduleId?: string | null;
1552
1562
  /** @nullable */
1553
1563
  StripeDiscountIds?: string[] | null;
@@ -3745,6 +3755,42 @@ export const ActivityType = {
3745
3755
  DiscordUserRemovedFromServer: 503,
3746
3756
  } as const;
3747
3757
 
3758
+ export type TemplateAllOf = {
3759
+ /**
3760
+ * @minLength 1
3761
+ * @maxLength 250
3762
+ */
3763
+ Name: string;
3764
+ /**
3765
+ * @maxLength 1000
3766
+ * @nullable
3767
+ */
3768
+ Subject?: string | null;
3769
+ /** @minLength 1 */
3770
+ Body: string;
3771
+ /** @nullable */
3772
+ Design?: string | null;
3773
+ /**
3774
+ * @maxLength 1000
3775
+ * @nullable
3776
+ */
3777
+ Description?: string | null;
3778
+ /**
3779
+ * @maxLength 50
3780
+ * @nullable
3781
+ */
3782
+ SystemName?: string | null;
3783
+ IsInternal?: boolean;
3784
+ /** @nullable */
3785
+ AvailableTokens?: string | null;
3786
+ /** @nullable */
3787
+ RequiredTokens?: string | null;
3788
+ /** @nullable */
3789
+ Tag?: string | null;
3790
+ };
3791
+
3792
+ export type Template = AbstractQcountBean & TemplateAllOf;
3793
+
3748
3794
  /**
3749
3795
  * @nullable
3750
3796
  */
@@ -3801,41 +3847,34 @@ export type TemplateEmailInstanceAllOf = {
3801
3847
 
3802
3848
  export type TemplateEmailInstance = AbstractQcountBean & TemplateEmailInstanceAllOf;
3803
3849
 
3804
- export type TemplateAllOf = {
3805
- /**
3806
- * @minLength 1
3807
- * @maxLength 250
3808
- */
3809
- Name: string;
3850
+ /**
3851
+ * The fields of an email template that an update may change. Every field is optional:
3852
+ a field left out keeps its current value.
3853
+ */
3854
+ export interface UpdateTemplateRequest {
3855
+ /** The HTML of the template. May use Liquid tokens, for example {{ Person.FirstName }},
3856
+ and must keep every token in the template's RequiredTokens. Cannot be null. */
3857
+ Body?: string;
3810
3858
  /**
3811
- * @maxLength 1000
3859
+ * What the template is for. Cannot be changed for a system email.
3812
3860
  * @nullable
3813
3861
  */
3814
- Subject?: string | null;
3815
- /** @minLength 1 */
3816
- Body: string;
3817
- /** @nullable */
3818
- Design?: string | null;
3862
+ Description?: string | null;
3819
3863
  /**
3820
- * @maxLength 1000
3864
+ * The design of the template in the drag-and-drop editor, as JSON. Send null with a new
3865
+ Body so the editor opens the new Body as HTML instead of the old design.
3821
3866
  * @nullable
3822
3867
  */
3823
- Description?: string | null;
3868
+ Design?: string | null;
3869
+ /** The name of the template, shown in the Outseta app. Cannot be changed for a system
3870
+ email. Cannot be null. */
3871
+ Name?: string;
3824
3872
  /**
3825
- * @maxLength 50
3873
+ * The subject line of the email. May use Liquid tokens, for example {{ CompanyName }}.
3826
3874
  * @nullable
3827
3875
  */
3828
- SystemName?: string | null;
3829
- IsInternal?: boolean;
3830
- /** @nullable */
3831
- AvailableTokens?: string | null;
3832
- /** @nullable */
3833
- RequiredTokens?: string | null;
3834
- /** @nullable */
3835
- Tag?: string | null;
3836
- };
3837
-
3838
- export type Template = AbstractQcountBean & TemplateAllOf;
3876
+ Subject?: string | null;
3877
+ }
3839
3878
 
3840
3879
  export interface SendTemplateEmailRequest {
3841
3880
  /**
@@ -5733,6 +5772,8 @@ export type AccountWebhookEntityStripeInvoicesItem = {
5733
5772
  /** @nullable */
5734
5773
  CustomerId?: string | null;
5735
5774
  /** @nullable */
5775
+ EffectiveDate?: string | null;
5776
+ /** @nullable */
5736
5777
  PaymentStatus?: string | null;
5737
5778
  /** @nullable */
5738
5779
  StripePaymentMethodId?: string | null;
@@ -5795,6 +5836,8 @@ export type AccountWebhookEntityStripeSubscriptionsItem = {
5795
5836
  /** @nullable */
5796
5837
  ApplicationFeePercent?: number | null;
5797
5838
  /** @nullable */
5839
+ BillingCycleAnchor?: string | null;
5840
+ /** @nullable */
5798
5841
  CancelAt?: string | null;
5799
5842
  CancelAtPeriodEnd?: boolean;
5800
5843
  /**
@@ -5822,14 +5865,14 @@ export type AccountWebhookEntityStripeSubscriptionsItem = {
5822
5865
  /** @nullable */
5823
5866
  AccountUid?: string | null;
5824
5867
  /** @nullable */
5825
- BillingCycleAnchor?: string | null;
5826
- /** @nullable */
5827
5868
  CollectionMethod?: string | null;
5828
5869
  /** @nullable */
5829
5870
  CustomerId?: string | null;
5830
5871
  /** @nullable */
5831
5872
  DaysUntilDue?: number | null;
5832
5873
  /** @nullable */
5874
+ PaymentUrl?: string | null;
5875
+ /** @nullable */
5833
5876
  ScheduleId?: string | null;
5834
5877
  /** @nullable */
5835
5878
  StripeDiscountIds?: string[] | null;
@@ -7548,6 +7591,8 @@ export type AccountWebhookEntityPrimaryStripeSubscription = {
7548
7591
  /** @nullable */
7549
7592
  ApplicationFeePercent?: number | null;
7550
7593
  /** @nullable */
7594
+ BillingCycleAnchor?: string | null;
7595
+ /** @nullable */
7551
7596
  CancelAt?: string | null;
7552
7597
  CancelAtPeriodEnd?: boolean;
7553
7598
  /**
@@ -7575,14 +7620,14 @@ export type AccountWebhookEntityPrimaryStripeSubscription = {
7575
7620
  /** @nullable */
7576
7621
  AccountUid?: string | null;
7577
7622
  /** @nullable */
7578
- BillingCycleAnchor?: string | null;
7579
- /** @nullable */
7580
7623
  CollectionMethod?: string | null;
7581
7624
  /** @nullable */
7582
7625
  CustomerId?: string | null;
7583
7626
  /** @nullable */
7584
7627
  DaysUntilDue?: number | null;
7585
7628
  /** @nullable */
7629
+ PaymentUrl?: string | null;
7630
+ /** @nullable */
7586
7631
  ScheduleId?: string | null;
7587
7632
  /** @nullable */
7588
7633
  StripeDiscountIds?: string[] | null;
@@ -9814,6 +9859,22 @@ export type CategoryGetAllCategories200 = {
9814
9859
  items?: Category[];
9815
9860
  };
9816
9861
 
9862
+ export type TemplateGetAllTemplatesParams = {
9863
+ /**
9864
+ * Requested page size. The server caps it at 100, or 25 when requested fields expand child objects or require additional queries; metadata.limit reports the applied value. Use offset=1 for the second page.
9865
+ */
9866
+ limit?: LimitParameter;
9867
+ /**
9868
+ * Zero-based page number, not a record offset. With limit=50, the second page is offset=1; offset=50 is page index 50 (records 2501-2550).
9869
+ */
9870
+ offset?: OffsetParameter;
9871
+ };
9872
+
9873
+ export type TemplateGetAllTemplates200 = {
9874
+ metadata?: CollectionMetadata;
9875
+ items?: Template[];
9876
+ };
9877
+
9817
9878
  export type TemplateGetAllTemplateEmailsParams = {
9818
9879
  /**
9819
9880
  * Requested page size. The server caps it at 100, or 25 when requested fields expand child objects or require additional queries; metadata.limit reports the applied value. Use offset=1 for the second page.
@@ -14,12 +14,16 @@ import type {
14
14
  } from '../../query';
15
15
 
16
16
  import type {
17
+ Template,
17
18
  TemplateEmailInstance,
18
19
  TemplateGetAllTemplateEmails200,
19
20
  TemplateGetAllTemplateEmailsParams,
21
+ TemplateGetAllTemplates200,
22
+ TemplateGetAllTemplatesParams,
20
23
  TemplateGetTemplateEmails200,
21
24
  TemplateGetTemplateEmailsParams,
22
- TemplateSendTemplateEmailBody
25
+ TemplateSendTemplateEmailBody,
26
+ UpdateTemplateRequest
23
27
  } from '../outsetaAPI.schemas';
24
28
 
25
29
  import { customFetch } from '../../mutator';
@@ -29,6 +33,91 @@ type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
29
33
 
30
34
 
31
35
 
36
+ /**
37
+ * The list holds the templates from Email > Email templates (Tag template), the email
38
+ layouts (Tag layout), the broadcast wrapper (Tag wrapper), the saved support replies
39
+ (Tag savedReply) and the system emails Outseta sends, such as the registration
40
+ confirmation (Tag email). A system email has a SystemName, which never changes. Filter
41
+ with Tag=email or SystemName to find one.
42
+
43
+ Body and Design are left out to keep the list small, except that a system email the
44
+ account never edited carries its default Body. Read a template with the get endpoint to
45
+ see its Body and Design.
46
+
47
+ A system email the account never edited is not stored yet. It is listed with a Uid
48
+ that starts with int_, which can be used like any other Uid. Saving the system email
49
+ stores the account's own copy, which has a regular Uid from then on. An int_ Uid can
50
+ change when Outseta adds system emails, so keep the SystemName rather than the int_ Uid.
51
+
52
+ Internal system emails that accounts cannot change are not listed.
53
+ * @summary The email templates, layouts and system emails of the account.
54
+ */
55
+ export const templateGetAllTemplates = (
56
+ params?: TemplateGetAllTemplatesParams,
57
+ options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
58
+ ) => {
59
+
60
+
61
+ return customFetch<TemplateGetAllTemplates200>(
62
+ {url: `/api/v1/templates`, method: 'GET',
63
+ params, signal
64
+ },
65
+ options);
66
+ }
67
+
68
+
69
+
70
+
71
+ export const getTemplateGetAllTemplatesQueryKey = (params?: TemplateGetAllTemplatesParams,) => {
72
+ return [
73
+ `/api/v1/templates`, ...(params ? [params]: [])
74
+ ] as const;
75
+ }
76
+
77
+
78
+ export const getTemplateGetAllTemplatesQueryOptions = <TData = Awaited<ReturnType<typeof templateGetAllTemplates>>, TError = void>(params?: TemplateGetAllTemplatesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof templateGetAllTemplates>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
79
+ ) => {
80
+
81
+ const {query: queryOptions, request: requestOptions} = options ?? {};
82
+
83
+ const queryKey = queryOptions?.queryKey ?? getTemplateGetAllTemplatesQueryKey(params);
84
+
85
+
86
+
87
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof templateGetAllTemplates>>> = ({ signal }) => templateGetAllTemplates(params, requestOptions, signal);
88
+
89
+
90
+
91
+
92
+
93
+ return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof templateGetAllTemplates>>, TError, TData> & { queryKey: QueryKey }
94
+ }
95
+
96
+ export type TemplateGetAllTemplatesQueryResult = NonNullable<Awaited<ReturnType<typeof templateGetAllTemplates>>>
97
+ export type TemplateGetAllTemplatesQueryError = void
98
+
99
+
100
+ /**
101
+ * @summary The email templates, layouts and system emails of the account.
102
+ */
103
+
104
+ export function useTemplateGetAllTemplates<TData = Awaited<ReturnType<typeof templateGetAllTemplates>>, TError = void>(
105
+ params?: TemplateGetAllTemplatesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof templateGetAllTemplates>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
106
+
107
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
108
+
109
+ const queryOptions = getTemplateGetAllTemplatesQueryOptions(params,options)
110
+
111
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
112
+
113
+ query.queryKey = queryOptions.queryKey ;
114
+
115
+ return query;
116
+ }
117
+
118
+
119
+
120
+
32
121
  /**
33
122
  * Filter with personUid to see what one person was sent, or with templateUid to
34
123
  restrict the results to a single template.
@@ -176,6 +265,170 @@ export function useTemplateGetTemplateEmails<TData = Awaited<ReturnType<typeof t
176
265
 
177
266
 
178
267
  /**
268
+ * Body is the HTML of the email; Subject and Body may use Liquid tokens such as
269
+ {{ Person.FirstName }}. AvailableTokens lists the tokens Outseta fills in for a system
270
+ email, and RequiredTokens the ones its Body must keep (for example ConfirmationUrl in the
271
+ registration confirmation).
272
+
273
+ Design is the drag-and-drop editor's design of the template as JSON, or null for a
274
+ template that is plain HTML. System emails have no Design.
275
+
276
+ A system email the account never edited returns its default content under its int_ Uid
277
+ from the list endpoint.
278
+ * @summary Get an email template, layout or system email, with its Body and Design.
279
+ */
280
+ export const templateGetTemplate = (
281
+ templateUid: string | null,
282
+ options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
283
+ ) => {
284
+
285
+
286
+ return customFetch<Template>(
287
+ {url: `/api/v1/templates/${templateUid}`, method: 'GET', signal
288
+ },
289
+ options);
290
+ }
291
+
292
+
293
+
294
+
295
+ export const getTemplateGetTemplateQueryKey = (templateUid?: string | null,) => {
296
+ return [
297
+ `/api/v1/templates/${templateUid}`
298
+ ] as const;
299
+ }
300
+
301
+
302
+ export const getTemplateGetTemplateQueryOptions = <TData = Awaited<ReturnType<typeof templateGetTemplate>>, TError = void>(templateUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof templateGetTemplate>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
303
+ ) => {
304
+
305
+ const {query: queryOptions, request: requestOptions} = options ?? {};
306
+
307
+ const queryKey = queryOptions?.queryKey ?? getTemplateGetTemplateQueryKey(templateUid);
308
+
309
+
310
+
311
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof templateGetTemplate>>> = ({ signal }) => templateGetTemplate(templateUid, requestOptions, signal);
312
+
313
+
314
+
315
+
316
+
317
+ return { queryKey, queryFn, enabled: !!(templateUid), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof templateGetTemplate>>, TError, TData> & { queryKey: QueryKey }
318
+ }
319
+
320
+ export type TemplateGetTemplateQueryResult = NonNullable<Awaited<ReturnType<typeof templateGetTemplate>>>
321
+ export type TemplateGetTemplateQueryError = void
322
+
323
+
324
+ /**
325
+ * @summary Get an email template, layout or system email, with its Body and Design.
326
+ */
327
+
328
+ export function useTemplateGetTemplate<TData = Awaited<ReturnType<typeof templateGetTemplate>>, TError = void>(
329
+ templateUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof templateGetTemplate>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
330
+
331
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
332
+
333
+ const queryOptions = getTemplateGetTemplateQueryOptions(templateUid,options)
334
+
335
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
336
+
337
+ query.queryKey = queryOptions.queryKey ;
338
+
339
+ return query;
340
+ }
341
+
342
+
343
+
344
+
345
+ /**
346
+ * Send only the fields to change, usually Subject and Body. Fields left out of the request
347
+ keep their current values; a field sent as null is cleared. The Uid in the request body
348
+ is ignored.
349
+
350
+ Subject and Body must be valid Liquid, and Body must keep every token in RequiredTokens
351
+ (for example ConfirmationUrl in the registration confirmation); otherwise the update is
352
+ rejected with a validation error. The Name, Description and SystemName of a system email
353
+ cannot be changed.
354
+
355
+ A template with a Design (made in the drag-and-drop editor of Email > Email templates)
356
+ opens in the editor from its Design, not its Body. To change the Body of such a
357
+ template, send Design as null as well: the editor then opens the new Body as HTML.
358
+ Otherwise the editor keeps showing the old design, and saving the template there
359
+ replaces the new Body. System emails have no Design.
360
+
361
+ A system email the account never edited has a Uid that starts with int_. Updating it
362
+ stores the account's own copy, with the default content for the fields left out, and
363
+ returns it with its new Uid. From then on Outseta sends the copy; the int_ Uid
364
+ returns 404.
365
+
366
+ On an Outseta account that is not verified yet, updating a system email pauses all email
367
+ sending of the account, as it does in the Outseta app.
368
+ * @summary Update an email template, layout or system email.
369
+ */
370
+ export const templateUpdateTemplate = (
371
+ templateUid: string | null,
372
+ updateTemplateRequest: UpdateTemplateRequest,
373
+ options?: SecondParameter<typeof customFetch>,) => {
374
+
375
+
376
+ return customFetch<Template>(
377
+ {url: `/api/v1/templates/${templateUid}`, method: 'PUT',
378
+ headers: {'Content-Type': 'application/json', },
379
+ data: updateTemplateRequest
380
+ },
381
+ options);
382
+ }
383
+
384
+
385
+
386
+ export const getTemplateUpdateTemplateMutationOptions = <TError = void,
387
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof templateUpdateTemplate>>, TError,{templateUid: string | null;data: UpdateTemplateRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
388
+ ): UseMutationOptions<Awaited<ReturnType<typeof templateUpdateTemplate>>, TError,{templateUid: string | null;data: UpdateTemplateRequest}, TContext> => {
389
+
390
+ const mutationKey = ['templateUpdateTemplate'];
391
+ const {mutation: mutationOptions, request: requestOptions} = options ?
392
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
393
+ options
394
+ : {...options, mutation: {...options.mutation, mutationKey}}
395
+ : {mutation: { mutationKey, }, request: undefined};
396
+
397
+
398
+
399
+
400
+ const mutationFn: MutationFunction<Awaited<ReturnType<typeof templateUpdateTemplate>>, {templateUid: string | null;data: UpdateTemplateRequest}> = (props) => {
401
+ const {templateUid,data} = props ?? {};
402
+
403
+ return templateUpdateTemplate(templateUid,data,requestOptions)
404
+ }
405
+
406
+
407
+
408
+
409
+ return { mutationFn, ...mutationOptions }}
410
+
411
+ export type TemplateUpdateTemplateMutationResult = NonNullable<Awaited<ReturnType<typeof templateUpdateTemplate>>>
412
+ export type TemplateUpdateTemplateMutationBody = UpdateTemplateRequest
413
+ export type TemplateUpdateTemplateMutationError = void
414
+
415
+ /**
416
+ * @summary Update an email template, layout or system email.
417
+ */
418
+ export const useTemplateUpdateTemplate = <TError = void,
419
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof templateUpdateTemplate>>, TError,{templateUid: string | null;data: UpdateTemplateRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
420
+ ): UseMutationResult<
421
+ Awaited<ReturnType<typeof templateUpdateTemplate>>,
422
+ TError,
423
+ {templateUid: string | null;data: UpdateTemplateRequest},
424
+ TContext
425
+ > => {
426
+
427
+ const mutationOptions = getTemplateUpdateTemplateMutationOptions(options);
428
+
429
+ return useMutation(mutationOptions);
430
+ }
431
+ /**
179
432
  * The email is merge-rendered for the person and sent immediately. No broadcast
180
433
  is created. People who have bounced, unsubscribed or reported spam are not sent
181
434
  the email. Only templates from Email > Email templates can be sent.