@outseta/react 0.4.18 → 0.4.19
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.4.
|
|
3
|
+
"version": "0.4.19",
|
|
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.3.
|
|
21
|
+
"@outseta/api-client": "0.3.25"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -9017,6 +9017,11 @@ export type DefinitionGetAllDefinitions200 = {
|
|
|
9017
9017
|
items?: Definition[];
|
|
9018
9018
|
};
|
|
9019
9019
|
|
|
9020
|
+
/**
|
|
9021
|
+
* @nullable
|
|
9022
|
+
*/
|
|
9023
|
+
export type PublicEmailListAddSubscriptionBody = EmailListPerson | null;
|
|
9024
|
+
|
|
9020
9025
|
export type AuthGetTokenParams = {
|
|
9021
9026
|
/**
|
|
9022
9027
|
* @nullable
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
AuthResendTwoFactorParams,
|
|
14
14
|
AuthSwitchTwoFactorMechanismParams,
|
|
15
15
|
AuthVerifyTwoFactorRecoveryParams,
|
|
16
|
+
PublicEmailListAddSubscriptionBody,
|
|
16
17
|
TokenPayload,
|
|
17
18
|
TokenTwoFactorEnrollmentBeginEmailParams,
|
|
18
19
|
TokenTwoFactorEnrollmentBeginTotpParams,
|
|
@@ -26,12 +27,107 @@ import type {
|
|
|
26
27
|
|
|
27
28
|
import { customFetch } from '../../mutator';
|
|
28
29
|
|
|
30
|
+
// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
|
|
31
|
+
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <
|
|
32
|
+
T,
|
|
33
|
+
>() => T extends Y ? 1 : 2
|
|
34
|
+
? A
|
|
35
|
+
: B;
|
|
36
|
+
|
|
37
|
+
type WritableKeys<T> = {
|
|
38
|
+
[P in keyof T]-?: IfEquals<
|
|
39
|
+
{ [Q in P]: T[P] },
|
|
40
|
+
{ -readonly [Q in P]: T[P] },
|
|
41
|
+
P
|
|
42
|
+
>;
|
|
43
|
+
}[keyof T];
|
|
44
|
+
|
|
45
|
+
type UnionToIntersection<U> =
|
|
46
|
+
(U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never;
|
|
47
|
+
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
|
|
48
|
+
|
|
49
|
+
type Writable<T> = Pick<T, WritableKeys<T>>;
|
|
50
|
+
type NonReadonly<T> = [T] extends [UnionToIntersection<T>] ? {
|
|
51
|
+
[P in keyof Writable<T>]: T[P] extends object
|
|
52
|
+
? NonReadonly<NonNullable<T[P]>>
|
|
53
|
+
: T[P];
|
|
54
|
+
} : DistributeReadOnlyOverUnions<T>;
|
|
55
|
+
|
|
56
|
+
|
|
29
57
|
|
|
30
58
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
31
59
|
|
|
32
60
|
|
|
33
61
|
|
|
34
62
|
/**
|
|
63
|
+
* This endpoint does not require authentication. The email list must be public, and the
|
|
64
|
+
subscription is subject to bot protection and the list's double opt-in settings.
|
|
65
|
+
* @summary Publicly subscribe a person to an email list.
|
|
66
|
+
*/
|
|
67
|
+
export const publicEmailListAddSubscription = (
|
|
68
|
+
emailListUid: string | null,
|
|
69
|
+
publicEmailListAddSubscriptionBody: NonReadonly<PublicEmailListAddSubscriptionBody>,
|
|
70
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
71
|
+
) => {
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
return customFetch<Blob>(
|
|
75
|
+
{url: `/api/v1/public/email/lists/${emailListUid}/subscriptions`, method: 'POST',
|
|
76
|
+
headers: {'Content-Type': 'application/json', },
|
|
77
|
+
data: publicEmailListAddSubscriptionBody,
|
|
78
|
+
responseType: 'blob', signal
|
|
79
|
+
},
|
|
80
|
+
options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export const getPublicEmailListAddSubscriptionMutationOptions = <TError = void,
|
|
86
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof publicEmailListAddSubscription>>, TError,{emailListUid: string | null;data: NonReadonly<PublicEmailListAddSubscriptionBody>}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
87
|
+
): UseMutationOptions<Awaited<ReturnType<typeof publicEmailListAddSubscription>>, TError,{emailListUid: string | null;data: NonReadonly<PublicEmailListAddSubscriptionBody>}, TContext> => {
|
|
88
|
+
|
|
89
|
+
const mutationKey = ['publicEmailListAddSubscription'];
|
|
90
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
91
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
92
|
+
options
|
|
93
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
94
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof publicEmailListAddSubscription>>, {emailListUid: string | null;data: NonReadonly<PublicEmailListAddSubscriptionBody>}> = (props) => {
|
|
100
|
+
const {emailListUid,data} = props ?? {};
|
|
101
|
+
|
|
102
|
+
return publicEmailListAddSubscription(emailListUid,data,requestOptions)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
return { mutationFn, ...mutationOptions }}
|
|
109
|
+
|
|
110
|
+
export type PublicEmailListAddSubscriptionMutationResult = NonNullable<Awaited<ReturnType<typeof publicEmailListAddSubscription>>>
|
|
111
|
+
export type PublicEmailListAddSubscriptionMutationBody = NonReadonly<PublicEmailListAddSubscriptionBody>
|
|
112
|
+
export type PublicEmailListAddSubscriptionMutationError = void
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @summary Publicly subscribe a person to an email list.
|
|
116
|
+
*/
|
|
117
|
+
export const usePublicEmailListAddSubscription = <TError = void,
|
|
118
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof publicEmailListAddSubscription>>, TError,{emailListUid: string | null;data: NonReadonly<PublicEmailListAddSubscriptionBody>}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
119
|
+
): UseMutationResult<
|
|
120
|
+
Awaited<ReturnType<typeof publicEmailListAddSubscription>>,
|
|
121
|
+
TError,
|
|
122
|
+
{emailListUid: string | null;data: NonReadonly<PublicEmailListAddSubscriptionBody>},
|
|
123
|
+
TContext
|
|
124
|
+
> => {
|
|
125
|
+
|
|
126
|
+
const mutationOptions = getPublicEmailListAddSubscriptionMutationOptions(options);
|
|
127
|
+
|
|
128
|
+
return useMutation(mutationOptions);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
35
131
|
* Authenticates a user and returns a JWT access token (plus a refresh token).
|
|
36
132
|
|
|
37
133
|
Post a JSON body with the user's credentials:
|