@outseta/react 0.5.2 → 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.
|
|
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.
|
|
21
|
+
"@outseta/api-client": "0.4.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -3755,6 +3755,42 @@ export const ActivityType = {
|
|
|
3755
3755
|
DiscordUserRemovedFromServer: 503,
|
|
3756
3756
|
} as const;
|
|
3757
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
|
+
|
|
3758
3794
|
/**
|
|
3759
3795
|
* @nullable
|
|
3760
3796
|
*/
|
|
@@ -3811,41 +3847,34 @@ export type TemplateEmailInstanceAllOf = {
|
|
|
3811
3847
|
|
|
3812
3848
|
export type TemplateEmailInstance = AbstractQcountBean & TemplateEmailInstanceAllOf;
|
|
3813
3849
|
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
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;
|
|
3820
3858
|
/**
|
|
3821
|
-
*
|
|
3859
|
+
* What the template is for. Cannot be changed for a system email.
|
|
3822
3860
|
* @nullable
|
|
3823
3861
|
*/
|
|
3824
|
-
|
|
3825
|
-
/** @minLength 1 */
|
|
3826
|
-
Body: string;
|
|
3827
|
-
/** @nullable */
|
|
3828
|
-
Design?: string | null;
|
|
3862
|
+
Description?: string | null;
|
|
3829
3863
|
/**
|
|
3830
|
-
*
|
|
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.
|
|
3831
3866
|
* @nullable
|
|
3832
3867
|
*/
|
|
3833
|
-
|
|
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;
|
|
3834
3872
|
/**
|
|
3835
|
-
*
|
|
3873
|
+
* The subject line of the email. May use Liquid tokens, for example {{ CompanyName }}.
|
|
3836
3874
|
* @nullable
|
|
3837
3875
|
*/
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
/** @nullable */
|
|
3841
|
-
AvailableTokens?: string | null;
|
|
3842
|
-
/** @nullable */
|
|
3843
|
-
RequiredTokens?: string | null;
|
|
3844
|
-
/** @nullable */
|
|
3845
|
-
Tag?: string | null;
|
|
3846
|
-
};
|
|
3847
|
-
|
|
3848
|
-
export type Template = AbstractQcountBean & TemplateAllOf;
|
|
3876
|
+
Subject?: string | null;
|
|
3877
|
+
}
|
|
3849
3878
|
|
|
3850
3879
|
export interface SendTemplateEmailRequest {
|
|
3851
3880
|
/**
|
|
@@ -9830,6 +9859,22 @@ export type CategoryGetAllCategories200 = {
|
|
|
9830
9859
|
items?: Category[];
|
|
9831
9860
|
};
|
|
9832
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
|
+
|
|
9833
9878
|
export type TemplateGetAllTemplateEmailsParams = {
|
|
9834
9879
|
/**
|
|
9835
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.
|