zitejs 0.10.0-start.2 → 0.10.0-start.21
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/dist/cjs/auth/actions.d.ts +28 -0
- package/dist/cjs/auth/actions.js +93 -0
- package/dist/cjs/auth/client.d.ts +357 -0
- package/dist/cjs/auth/client.js +66 -0
- package/dist/cjs/auth/index.d.ts +2 -249
- package/dist/cjs/auth/index.js +11 -108
- package/dist/cjs/auth/index.test.js +48 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/auth/profileUpdates.d.ts +9 -0
- package/dist/cjs/auth/profileUpdates.js +11 -0
- package/dist/cjs/backend/index.d.ts +121 -3
- package/dist/cjs/backend/index.test.js +58 -0
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +9 -8
- package/dist/cjs/check/index.d.ts +45 -1
- package/dist/cjs/check/index.js +198 -109
- package/dist/cjs/check/start/problem.d.ts +11 -0
- package/dist/cjs/check/start/problem.js +5 -0
- package/dist/cjs/check/start/routeTree.d.ts +9 -0
- package/dist/cjs/check/start/routeTree.js +111 -0
- package/dist/cjs/check/start/sourceRules.d.ts +8 -0
- package/dist/cjs/check/start/sourceRules.js +1159 -0
- package/dist/cjs/check/start/tsgo.d.ts +2 -0
- package/dist/cjs/check/start/tsgo.js +35 -0
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/client/index.d.ts +24 -0
- package/dist/cjs/dev/index.js +14 -4
- package/dist/cjs/integrations/rules.d.ts +13 -0
- package/dist/cjs/integrations/rules.js +31 -0
- package/dist/cjs/integrations/rules.test.js +1 -0
- package/dist/cjs/internal/appMode.d.ts +3 -0
- package/dist/cjs/internal/appMode.js +15 -0
- package/dist/cjs/runtime/index.d.ts +64 -25
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +33 -0
- package/dist/cjs/start/entries.d.ts +10 -4
- package/dist/cjs/start/entries.js +23 -6
- package/dist/cjs/steps/index.d.ts +78 -0
- package/dist/cjs/steps/index.js +507 -0
- package/dist/cjs/steps/index.test.d.ts +1 -0
- package/dist/cjs/steps/index.test.js +635 -0
- package/dist/cjs/sync/index.js +2 -1
- package/dist/cjs/sync/lib.d.ts +10 -3
- package/dist/cjs/sync/lib.js +44 -25
- package/dist/cjs/sync/lib.test.js +116 -36
- package/dist/cjs/types/fields.d.ts +8 -1
- package/dist/cjs/types/fields.js +7 -1
- package/dist/cjs/types/tables.d.ts +16 -0
- package/dist/cjs/upload/index.js +12 -2
- package/dist/cjs/upload/index.test.js +39 -0
- package/dist/cjs/vite/index.js +8 -3
- package/dist/cjs/vite/index.test.js +10 -2
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +55 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +62 -0
- package/dist/esm/auth/index.d.ts +2 -249
- package/dist/esm/auth/index.js +2 -103
- package/dist/esm/auth/index.test.js +48 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/auth/profileUpdates.d.ts +9 -0
- package/dist/esm/auth/profileUpdates.js +6 -0
- package/dist/esm/backend/index.d.ts +121 -3
- package/dist/esm/backend/index.test.js +58 -0
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +8 -8
- package/dist/esm/check/index.d.ts +45 -1
- package/dist/esm/check/index.js +198 -113
- package/dist/esm/check/start/problem.d.ts +11 -0
- package/dist/esm/check/start/problem.js +1 -0
- package/dist/esm/check/start/routeTree.d.ts +9 -0
- package/dist/esm/check/start/routeTree.js +70 -0
- package/dist/esm/check/start/sourceRules.d.ts +8 -0
- package/dist/esm/check/start/sourceRules.js +1156 -0
- package/dist/esm/check/start/tsgo.d.ts +2 -0
- package/dist/esm/check/start/tsgo.js +29 -0
- package/dist/esm/cli.js +1 -1
- package/dist/esm/client/index.d.ts +24 -0
- package/dist/esm/dev/index.js +16 -6
- package/dist/esm/integrations/rules.d.ts +13 -0
- package/dist/esm/integrations/rules.js +31 -0
- package/dist/esm/integrations/rules.test.js +1 -0
- package/dist/esm/internal/appMode.d.ts +3 -0
- package/dist/esm/internal/appMode.js +10 -0
- package/dist/esm/runtime/index.d.ts +64 -25
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +31 -0
- package/dist/esm/start/aiUsage.d.ts +23 -0
- package/dist/esm/start/aiUsage.js +146 -0
- package/dist/esm/start/airtable/arrayFields.d.ts +10 -0
- package/dist/esm/start/airtable/arrayFields.js +30 -0
- package/dist/esm/start/airtable/dispatch.d.ts +54 -0
- package/dist/esm/start/airtable/dispatch.js +483 -0
- package/dist/esm/start/airtable/formulas.d.ts +70 -0
- package/dist/esm/start/airtable/formulas.js +260 -0
- package/dist/esm/start/airtable/index.d.ts +8 -0
- package/dist/esm/start/airtable/index.js +54 -0
- package/dist/esm/start/authHooks.d.ts +7 -0
- package/dist/esm/start/authHooks.js +10 -0
- package/dist/esm/start/authHooksModule.d.ts +1 -0
- package/dist/esm/start/authHooksModule.js +3 -0
- package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
- package/dist/esm/start/clientErrorMessage.test.js +105 -0
- package/dist/esm/start/credentials.d.ts +2 -0
- package/dist/esm/start/credentials.js +2 -0
- package/dist/esm/start/data/baseRunner.d.ts +92 -0
- package/dist/esm/start/data/baseRunner.js +83 -0
- package/dist/esm/start/data/dispatch.d.ts +16 -0
- package/dist/esm/start/data/dispatch.js +198 -0
- package/dist/esm/start/data/index.d.ts +15 -0
- package/dist/esm/start/data/index.js +58 -0
- package/dist/esm/start/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/data/transformations.d.ts +97 -0
- package/dist/esm/start/data/transformations.js +262 -0
- package/dist/esm/start/data/types.d.ts +91 -0
- package/dist/esm/start/data/types.js +14 -0
- package/dist/esm/start/describe.d.ts +42 -5
- package/dist/esm/start/describe.js +77 -23
- package/dist/esm/start/entries.d.ts +10 -4
- package/dist/esm/start/entries.js +21 -5
- package/dist/esm/start/errors.d.ts +63 -0
- package/dist/esm/start/errors.js +146 -0
- package/dist/esm/start/errors.test.d.ts +1 -0
- package/dist/esm/start/errors.test.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -0
- package/dist/esm/start/factories.test-d.js +20 -0
- package/dist/esm/start/host.d.ts +2 -2
- package/dist/esm/start/index.d.ts +32 -27
- package/dist/esm/start/index.js +79 -47
- package/dist/esm/start/instance.d.ts +4 -4
- package/dist/esm/start/instance.js +54 -11
- package/dist/esm/start/outbound.d.ts +11 -0
- package/dist/esm/start/outbound.js +400 -0
- package/dist/esm/start/previewClaim.d.ts +7 -0
- package/dist/esm/start/previewClaim.js +23 -0
- package/dist/esm/start/problems.js +1 -1
- package/dist/esm/start/quiet.d.ts +2 -0
- package/dist/esm/start/quiet.js +27 -0
- package/dist/esm/start/redactSecrets.d.ts +15 -0
- package/dist/esm/start/redactSecrets.js +154 -0
- package/dist/esm/start/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/redactSecrets.test.js +151 -0
- package/dist/esm/start/registration.d.ts +13 -0
- package/dist/esm/start/registration.js +21 -0
- package/dist/esm/start/registrationHash.d.ts +22 -0
- package/dist/esm/start/registrationHash.js +470 -0
- package/dist/esm/start/router.d.ts +25 -4
- package/dist/esm/start/router.js +169 -11
- package/dist/esm/start/runLog.d.ts +7 -4
- package/dist/esm/start/runLog.js +64 -6
- package/dist/esm/start/scope.d.ts +4 -4
- package/dist/esm/start/server.d.ts +40 -36
- package/dist/esm/start/server.js +322 -49
- package/dist/esm/start/steps.d.ts +28 -0
- package/dist/esm/start/steps.js +97 -0
- package/dist/esm/start/types.d.ts +179 -6
- package/dist/esm/start/version.d.ts +1 -0
- package/dist/esm/start/version.js +2 -0
- package/dist/esm/start/vite.js +91 -14
- package/dist/esm/start/worker.d.ts +6 -0
- package/dist/esm/start/worker.js +12 -0
- package/dist/esm/start/workflow.d.ts +46 -12
- package/dist/esm/start/workflow.js +10 -3
- package/dist/esm/start/workflow.test-d.js +50 -8
- package/dist/esm/start/workflowModules.js +1 -1
- package/dist/esm/start/workflowRun.d.ts +26 -8
- package/dist/esm/start/workflowRun.js +39 -8
- package/dist/esm/steps/index.d.ts +78 -0
- package/dist/esm/steps/index.js +502 -0
- package/dist/esm/steps/index.test.d.ts +1 -0
- package/dist/esm/steps/index.test.js +633 -0
- package/dist/esm/sync/index.js +2 -1
- package/dist/esm/sync/lib.d.ts +10 -3
- package/dist/esm/sync/lib.js +44 -25
- package/dist/esm/sync/lib.test.js +116 -36
- package/dist/esm/types/fields.d.ts +8 -1
- package/dist/esm/types/fields.js +6 -0
- package/dist/esm/types/tables.d.ts +16 -0
- package/dist/esm/upload/index.js +12 -2
- package/dist/esm/upload/index.test.js +39 -0
- package/dist/esm/vite/index.js +8 -3
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +37 -16
- package/dist/cjs/start/problems.d.ts +0 -19
- package/dist/cjs/start/problems.js +0 -11
package/dist/cjs/auth/index.d.ts
CHANGED
|
@@ -1,252 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
user: import("better-auth/react").StripEmptyObjects<{
|
|
4
|
-
id: string;
|
|
5
|
-
createdAt: Date;
|
|
6
|
-
updatedAt: Date;
|
|
7
|
-
email: string;
|
|
8
|
-
emailVerified: boolean;
|
|
9
|
-
name: string;
|
|
10
|
-
image?: string | null | undefined;
|
|
11
|
-
} & {} & {
|
|
12
|
-
firstName?: string | null | undefined;
|
|
13
|
-
lastName?: string | null | undefined;
|
|
14
|
-
}>;
|
|
15
|
-
session: import("better-auth/react").StripEmptyObjects<{
|
|
16
|
-
id: string;
|
|
17
|
-
createdAt: Date;
|
|
18
|
-
updatedAt: Date;
|
|
19
|
-
userId: string;
|
|
20
|
-
expiresAt: Date;
|
|
21
|
-
token: string;
|
|
22
|
-
ipAddress?: string | null | undefined;
|
|
23
|
-
userAgent?: string | null | undefined;
|
|
24
|
-
} & {} & {}>;
|
|
25
|
-
} | null;
|
|
26
|
-
isPending: boolean;
|
|
27
|
-
isRefetching: boolean;
|
|
28
|
-
error: import("@better-fetch/fetch").BetterFetchError | null;
|
|
29
|
-
refetch: (queryParams?: {
|
|
30
|
-
query?: import("better-auth/types").SessionQueryParams;
|
|
31
|
-
} | undefined) => Promise<void>;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* `loginWithRedirect` and `logout` are returned as well as exported. The
|
|
35
|
-
* pre-monorepo `useAuth()` returned them, so app code that destructures them
|
|
36
|
-
* from the hook is common — and returning them here means the legacy compat
|
|
37
|
-
* shim is the only thing that has to know that, not every migrated app.
|
|
38
|
-
*/
|
|
39
|
-
export declare function useAuth(): {
|
|
40
|
-
user: User | null;
|
|
41
|
-
isLoading: boolean;
|
|
42
|
-
loginWithRedirect: typeof loginWithRedirect;
|
|
43
|
-
logout: typeof logout;
|
|
44
|
-
};
|
|
45
|
-
export declare const signIn: {
|
|
46
|
-
magicLink: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
47
|
-
email: string;
|
|
48
|
-
name?: string | undefined;
|
|
49
|
-
callbackURL?: string | undefined;
|
|
50
|
-
newUserCallbackURL?: string | undefined;
|
|
51
|
-
errorCallbackURL?: string | undefined;
|
|
52
|
-
metadata?: Record<string, any> | undefined;
|
|
53
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
54
|
-
email: string;
|
|
55
|
-
name?: string | undefined;
|
|
56
|
-
callbackURL?: string | undefined;
|
|
57
|
-
newUserCallbackURL?: string | undefined;
|
|
58
|
-
errorCallbackURL?: string | undefined;
|
|
59
|
-
metadata?: Record<string, any> | undefined;
|
|
60
|
-
} & {
|
|
61
|
-
fetchOptions?: FetchOptions | undefined;
|
|
62
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
|
|
63
|
-
status: boolean;
|
|
64
|
-
}, {
|
|
65
|
-
code?: string | undefined;
|
|
66
|
-
message?: string | undefined;
|
|
67
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
68
|
-
} & {
|
|
69
|
-
social: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
70
|
-
provider: "salesforce" | "slack" | "linear" | "notion" | "linkedin" | "github" | "dropbox" | (string & {}) | "huggingface" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "spotify" | "twitch" | "twitter" | "kick" | "gitlab" | "tiktok" | "reddit" | "roblox" | "vk" | "zoom" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
|
|
71
|
-
callbackURL?: string | undefined;
|
|
72
|
-
newUserCallbackURL?: string | undefined;
|
|
73
|
-
errorCallbackURL?: string | undefined;
|
|
74
|
-
disableRedirect?: boolean | undefined;
|
|
75
|
-
idToken?: {
|
|
76
|
-
token: string;
|
|
77
|
-
nonce?: string | undefined;
|
|
78
|
-
accessToken?: string | undefined;
|
|
79
|
-
refreshToken?: string | undefined;
|
|
80
|
-
expiresAt?: number | undefined;
|
|
81
|
-
user?: {
|
|
82
|
-
name?: {
|
|
83
|
-
firstName?: string | undefined;
|
|
84
|
-
lastName?: string | undefined;
|
|
85
|
-
} | undefined;
|
|
86
|
-
email?: string | undefined;
|
|
87
|
-
} | undefined;
|
|
88
|
-
} | undefined;
|
|
89
|
-
scopes?: string[] | undefined;
|
|
90
|
-
requestSignUp?: boolean | undefined;
|
|
91
|
-
loginHint?: string | undefined;
|
|
92
|
-
additionalData?: Record<string, any> | undefined;
|
|
93
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
94
|
-
provider: "salesforce" | "slack" | "linear" | "notion" | "linkedin" | "github" | "dropbox" | (string & {}) | "huggingface" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "spotify" | "twitch" | "twitter" | "kick" | "gitlab" | "tiktok" | "reddit" | "roblox" | "vk" | "zoom" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
|
|
95
|
-
callbackURL?: string | undefined;
|
|
96
|
-
newUserCallbackURL?: string | undefined;
|
|
97
|
-
errorCallbackURL?: string | undefined;
|
|
98
|
-
disableRedirect?: boolean | undefined;
|
|
99
|
-
idToken?: {
|
|
100
|
-
token: string;
|
|
101
|
-
nonce?: string | undefined;
|
|
102
|
-
accessToken?: string | undefined;
|
|
103
|
-
refreshToken?: string | undefined;
|
|
104
|
-
expiresAt?: number | undefined;
|
|
105
|
-
user?: {
|
|
106
|
-
name?: {
|
|
107
|
-
firstName?: string | undefined;
|
|
108
|
-
lastName?: string | undefined;
|
|
109
|
-
} | undefined;
|
|
110
|
-
email?: string | undefined;
|
|
111
|
-
} | undefined;
|
|
112
|
-
} | undefined;
|
|
113
|
-
scopes?: string[] | undefined;
|
|
114
|
-
requestSignUp?: boolean | undefined;
|
|
115
|
-
loginHint?: string | undefined;
|
|
116
|
-
additionalData?: Record<string, any> | undefined;
|
|
117
|
-
} & {
|
|
118
|
-
fetchOptions?: FetchOptions | undefined;
|
|
119
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
|
|
120
|
-
redirect: boolean;
|
|
121
|
-
url: string;
|
|
122
|
-
} | (Omit<{
|
|
123
|
-
redirect: boolean;
|
|
124
|
-
token: string;
|
|
125
|
-
url: undefined;
|
|
126
|
-
user: {
|
|
127
|
-
id: string;
|
|
128
|
-
createdAt: Date;
|
|
129
|
-
updatedAt: Date;
|
|
130
|
-
email: string;
|
|
131
|
-
emailVerified: boolean;
|
|
132
|
-
name: string;
|
|
133
|
-
image?: string | null | undefined | undefined;
|
|
134
|
-
};
|
|
135
|
-
}, "user"> & {
|
|
136
|
-
user: import("better-auth/react").StripEmptyObjects<{
|
|
137
|
-
id: string;
|
|
138
|
-
createdAt: Date;
|
|
139
|
-
updatedAt: Date;
|
|
140
|
-
email: string;
|
|
141
|
-
emailVerified: boolean;
|
|
142
|
-
name: string;
|
|
143
|
-
image?: string | null | undefined;
|
|
144
|
-
} & {} & {
|
|
145
|
-
firstName?: string | null | undefined;
|
|
146
|
-
lastName?: string | null | undefined;
|
|
147
|
-
}>;
|
|
148
|
-
}), {
|
|
149
|
-
code?: string | undefined;
|
|
150
|
-
message?: string | undefined;
|
|
151
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
152
|
-
} & {
|
|
153
|
-
email: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
154
|
-
email: string;
|
|
155
|
-
password: string;
|
|
156
|
-
callbackURL?: string | undefined;
|
|
157
|
-
rememberMe?: boolean | undefined;
|
|
158
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
159
|
-
email: string;
|
|
160
|
-
password: string;
|
|
161
|
-
callbackURL?: string | undefined;
|
|
162
|
-
rememberMe?: boolean | undefined;
|
|
163
|
-
} & {
|
|
164
|
-
fetchOptions?: FetchOptions | undefined;
|
|
165
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<Omit<{
|
|
166
|
-
redirect: boolean;
|
|
167
|
-
token: string;
|
|
168
|
-
url?: string | undefined;
|
|
169
|
-
user: {
|
|
170
|
-
id: string;
|
|
171
|
-
createdAt: Date;
|
|
172
|
-
updatedAt: Date;
|
|
173
|
-
email: string;
|
|
174
|
-
emailVerified: boolean;
|
|
175
|
-
name: string;
|
|
176
|
-
image?: string | null | undefined | undefined;
|
|
177
|
-
};
|
|
178
|
-
}, "user"> & {
|
|
179
|
-
user: import("better-auth/react").StripEmptyObjects<{
|
|
180
|
-
id: string;
|
|
181
|
-
createdAt: Date;
|
|
182
|
-
updatedAt: Date;
|
|
183
|
-
email: string;
|
|
184
|
-
emailVerified: boolean;
|
|
185
|
-
name: string;
|
|
186
|
-
image?: string | null | undefined;
|
|
187
|
-
} & {} & {
|
|
188
|
-
firstName?: string | null | undefined;
|
|
189
|
-
lastName?: string | null | undefined;
|
|
190
|
-
}>;
|
|
191
|
-
}, {
|
|
192
|
-
code?: string | undefined;
|
|
193
|
-
message?: string | undefined;
|
|
194
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
195
|
-
};
|
|
196
|
-
export declare const signOut: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
|
|
197
|
-
query?: Record<string, any> | undefined;
|
|
198
|
-
fetchOptions?: FetchOptions | undefined;
|
|
199
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
|
|
200
|
-
success: boolean;
|
|
201
|
-
}, {
|
|
202
|
-
code?: string | undefined;
|
|
203
|
-
message?: string | undefined;
|
|
204
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
205
|
-
export declare const signUp: {
|
|
206
|
-
email: (data: {
|
|
207
|
-
email: string;
|
|
208
|
-
password: string;
|
|
209
|
-
name: string;
|
|
210
|
-
[key: string]: unknown;
|
|
211
|
-
}) => Promise<{
|
|
212
|
-
error?: {
|
|
213
|
-
message?: string;
|
|
214
|
-
} | null;
|
|
215
|
-
data?: unknown;
|
|
216
|
-
}>;
|
|
217
|
-
};
|
|
218
|
-
export declare function loginWithRedirect(opts?: {
|
|
219
|
-
redirectUrl?: string;
|
|
220
|
-
/**
|
|
221
|
-
* @deprecated Ignored. There is one sign-in screen now — the server works out
|
|
222
|
-
* from the email whether it's a sign-in or a sign-up. Still accepted, because
|
|
223
|
-
* app source written before that change would otherwise stop typechecking on
|
|
224
|
-
* its next build, and a typecheck error fails the build outright.
|
|
225
|
-
*/
|
|
226
|
-
initialView?: 'login' | 'signup';
|
|
227
|
-
}): void;
|
|
228
|
-
export declare function logout(opts?: {
|
|
229
|
-
returnTo?: string;
|
|
230
|
-
}): void;
|
|
231
|
-
export declare function updateProfile(data: {
|
|
232
|
-
name?: string;
|
|
233
|
-
firstName?: string;
|
|
234
|
-
lastName?: string;
|
|
235
|
-
image?: string;
|
|
236
|
-
}): Promise<{
|
|
237
|
-
data: {
|
|
238
|
-
status: boolean;
|
|
239
|
-
};
|
|
240
|
-
error: null;
|
|
241
|
-
} | {
|
|
242
|
-
data: null;
|
|
243
|
-
error: {
|
|
244
|
-
code?: string | undefined | undefined;
|
|
245
|
-
message?: string | undefined | undefined;
|
|
246
|
-
status: number;
|
|
247
|
-
statusText: string;
|
|
248
|
-
};
|
|
249
|
-
}>;
|
|
1
|
+
export { useSession, useAuth, signIn, signOut, signUp, } from './client.js';
|
|
2
|
+
export { loginWithRedirect, logout, updateProfile } from './actions.js';
|
|
250
3
|
/**
|
|
251
4
|
* An `interface`, not a type alias, so a migrated app can widen it by
|
|
252
5
|
* declaration merging (`.zite/user-extensions.d.ts`). A legacy user-sync app's
|
package/dist/cjs/auth/index.js
CHANGED
|
@@ -1,110 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signUp = exports.signOut = exports.signIn = exports.useSession = void 0;
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
baseURL: '',
|
|
15
|
-
plugins: [
|
|
16
|
-
(0, plugins_1.magicLinkClient)(),
|
|
17
|
-
(0, plugins_1.inferAdditionalFields)({
|
|
18
|
-
user: {
|
|
19
|
-
firstName: { type: 'string', required: false },
|
|
20
|
-
lastName: { type: 'string', required: false },
|
|
21
|
-
},
|
|
22
|
-
}),
|
|
23
|
-
],
|
|
24
|
-
});
|
|
25
|
-
exports.useSession = authClient.useSession;
|
|
26
|
-
/**
|
|
27
|
-
* An internal app has no signed-out state — SSO runs before the bundle — so an
|
|
28
|
-
* empty session means it died underneath the app. Only `internal`: elsewhere a
|
|
29
|
-
* signed-out visitor is legitimate.
|
|
30
|
-
*/
|
|
31
|
-
function shouldRedirectSignedOut(isPending, hasUser) {
|
|
32
|
-
if (isPending || hasUser)
|
|
33
|
-
return false;
|
|
34
|
-
if ((0, config_js_1.getAccessMode)() !== 'internal')
|
|
35
|
-
return false;
|
|
36
|
-
if (typeof window === 'undefined')
|
|
37
|
-
return false;
|
|
38
|
-
// `loginWithRedirect` won't navigate from an auth page, so claiming a
|
|
39
|
-
// redirect here would hang `isLoading` forever.
|
|
40
|
-
return !window.location.pathname.startsWith('/auth/');
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* `loginWithRedirect` and `logout` are returned as well as exported. The
|
|
44
|
-
* pre-monorepo `useAuth()` returned them, so app code that destructures them
|
|
45
|
-
* from the hook is common — and returning them here means the legacy compat
|
|
46
|
-
* shim is the only thing that has to know that, not every migrated app.
|
|
47
|
-
*/
|
|
48
|
-
function useAuth() {
|
|
49
|
-
const { data, isPending } = (0, exports.useSession)();
|
|
50
|
-
const user = data?.user ?? null;
|
|
51
|
-
const redirecting = shouldRedirectSignedOut(isPending, user !== null);
|
|
52
|
-
(0, react_1.useEffect)(() => {
|
|
53
|
-
if (redirecting)
|
|
54
|
-
loginWithRedirect();
|
|
55
|
-
}, [redirecting]);
|
|
56
|
-
return {
|
|
57
|
-
user,
|
|
58
|
-
// Loading, not signed out: the signed-out branch is the empty screen this
|
|
59
|
-
// exists to prevent.
|
|
60
|
-
isLoading: isPending || redirecting,
|
|
61
|
-
loginWithRedirect,
|
|
62
|
-
logout,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
exports.signIn = authClient.signIn;
|
|
66
|
-
exports.signOut = authClient.signOut;
|
|
67
|
-
exports.signUp = authClient.signUp;
|
|
68
|
-
function loginWithRedirect(opts) {
|
|
69
|
-
if (window.location.pathname.startsWith('/auth/'))
|
|
70
|
-
return;
|
|
71
|
-
// Default to wherever the user already is, so a deep link survives the round
|
|
72
|
-
// trip through login without every app having to remember to pass it. Pass
|
|
73
|
-
// `redirectUrl` only to send them somewhere else instead.
|
|
74
|
-
//
|
|
75
|
-
// Resolved to an absolute URL either way, on purpose: better-auth
|
|
76
|
-
// character-checks a *relative* callbackURL — an encoded space, a fragment or
|
|
77
|
-
// any non-ASCII in the path fails its regex and the destination is dropped —
|
|
78
|
-
// but never inspects the path of an absolute one. Normalising here means a
|
|
79
|
-
// caller can pass whichever form reads best without having to know that.
|
|
80
|
-
const target = new URL(opts?.redirectUrl ?? window.location.href, window.location.href);
|
|
81
|
-
// Say nothing when there's nothing to say. The sign-in page already returns
|
|
82
|
-
// people to the app root when it isn't told otherwise, so naming the root
|
|
83
|
-
// spells out the default — and puts an encoded copy of the app's own URL in
|
|
84
|
-
// the address bar of every logged-out visitor to the front page, which is the
|
|
85
|
-
// common case. Only pass a destination when it IS one.
|
|
86
|
-
const isRoot = target.pathname === '/' && target.search === '' && target.hash === '';
|
|
87
|
-
const params = new URLSearchParams();
|
|
88
|
-
if (!isRoot)
|
|
89
|
-
params.set('redirectUrl', target.toString());
|
|
90
|
-
// The editor preview rides its usageToken on the app URL; the sign-in page
|
|
91
|
-
// only shows its editor surface ("Preview as" picker) when that token reaches
|
|
92
|
-
// it. Capturing the current URL carries it implicitly — but an explicit
|
|
93
|
-
// `redirectUrl` names a bare path, and would silently drop it. Forward it
|
|
94
|
-
// top-level either way, so how the app phrases its redirect can't decide
|
|
95
|
-
// whether the editor gets a preview. Published visitors never have one.
|
|
96
|
-
const usageToken = new URL(window.location.href).searchParams.get(constants_js_1.USAGE_TOKEN_QUERY_PARAM) ??
|
|
97
|
-
window._ziteUsageToken;
|
|
98
|
-
if (usageToken)
|
|
99
|
-
params.set(constants_js_1.USAGE_TOKEN_QUERY_PARAM, usageToken);
|
|
100
|
-
const query = params.toString();
|
|
101
|
-
window.location.href = query ? `/auth/login?${query}` : '/auth/login';
|
|
102
|
-
}
|
|
103
|
-
function logout(opts) {
|
|
104
|
-
(0, exports.signOut)().then(() => {
|
|
105
|
-
window.location.href = opts?.returnTo || '/';
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function updateProfile(data) {
|
|
109
|
-
return authClient.updateUser(data);
|
|
110
|
-
}
|
|
3
|
+
exports.updateProfile = exports.logout = exports.loginWithRedirect = exports.signUp = exports.signOut = exports.signIn = exports.useAuth = exports.useSession = void 0;
|
|
4
|
+
var client_js_1 = require("./client.js");
|
|
5
|
+
Object.defineProperty(exports, "useSession", { enumerable: true, get: function () { return client_js_1.useSession; } });
|
|
6
|
+
Object.defineProperty(exports, "useAuth", { enumerable: true, get: function () { return client_js_1.useAuth; } });
|
|
7
|
+
Object.defineProperty(exports, "signIn", { enumerable: true, get: function () { return client_js_1.signIn; } });
|
|
8
|
+
Object.defineProperty(exports, "signOut", { enumerable: true, get: function () { return client_js_1.signOut; } });
|
|
9
|
+
Object.defineProperty(exports, "signUp", { enumerable: true, get: function () { return client_js_1.signUp; } });
|
|
10
|
+
var actions_js_1 = require("./actions.js");
|
|
11
|
+
Object.defineProperty(exports, "loginWithRedirect", { enumerable: true, get: function () { return actions_js_1.loginWithRedirect; } });
|
|
12
|
+
Object.defineProperty(exports, "logout", { enumerable: true, get: function () { return actions_js_1.logout; } });
|
|
13
|
+
Object.defineProperty(exports, "updateProfile", { enumerable: true, get: function () { return actions_js_1.updateProfile; } });
|
|
@@ -187,3 +187,51 @@ function redirectParamOf(href) {
|
|
|
187
187
|
(0, vitest_1.expect)(params.get('usageToken')).toBeNull();
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
|
+
// AUTH-03: what the platform's auth routes receive from the client, on the app's own origin.
|
|
191
|
+
(0, vitest_1.describe)("the client's calls", () => {
|
|
192
|
+
const calls = () => {
|
|
193
|
+
const sent = [];
|
|
194
|
+
vitest_1.vi.stubGlobal('fetch', vitest_1.vi.fn(async (input, init) => {
|
|
195
|
+
const request = new Request(new URL(String(input instanceof Request ? input.url : input), 'https://app.zite.so'), init);
|
|
196
|
+
sent.push({
|
|
197
|
+
path: new URL(request.url).pathname,
|
|
198
|
+
method: request.method,
|
|
199
|
+
body: request.method === 'POST' ? await request.json().catch(() => null) : null,
|
|
200
|
+
});
|
|
201
|
+
return Response.json({});
|
|
202
|
+
}));
|
|
203
|
+
return sent;
|
|
204
|
+
};
|
|
205
|
+
(0, vitest_1.it)('sign in by link, sign out and edit the profile on /api/auth', async () => {
|
|
206
|
+
const sent = calls();
|
|
207
|
+
// The client takes its fetch when the module loads.
|
|
208
|
+
vitest_1.vi.resetModules();
|
|
209
|
+
const { signIn, signOut, updateProfile } = await Promise.resolve().then(() => __importStar(require('./index.js')));
|
|
210
|
+
await signIn.magicLink({ email: 'ada@x.co' });
|
|
211
|
+
await signOut();
|
|
212
|
+
await updateProfile({ firstName: 'Ada' });
|
|
213
|
+
(0, vitest_1.expect)(sent).toEqual([
|
|
214
|
+
{ path: '/api/auth/sign-in/magic-link', method: 'POST', body: vitest_1.expect.objectContaining({ email: 'ada@x.co' }) },
|
|
215
|
+
{ path: '/api/auth/sign-out', method: 'POST', body: vitest_1.expect.anything() },
|
|
216
|
+
{ path: '/api/auth/update-user', method: 'POST', body: { firstName: 'Ada' } },
|
|
217
|
+
]);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
(0, vitest_1.describe)('a profile edit', () => {
|
|
221
|
+
(0, vitest_1.afterEach)(() => vitest_1.vi.unstubAllGlobals());
|
|
222
|
+
(0, vitest_1.it)("tells a Start app's router once the platform saved it, and not when it refused", async () => {
|
|
223
|
+
let status = 400;
|
|
224
|
+
vitest_1.vi.stubGlobal('fetch', vitest_1.vi.fn(async () => Response.json(status === 200 ? { status: true } : { message: 'no' }, { status })));
|
|
225
|
+
// The client takes its fetch when the module loads.
|
|
226
|
+
vitest_1.vi.resetModules();
|
|
227
|
+
const { updateProfile } = await Promise.resolve().then(() => __importStar(require('./index.js')));
|
|
228
|
+
const { onProfileUpdated } = await Promise.resolve().then(() => __importStar(require('./profileUpdates.js')));
|
|
229
|
+
const told = vitest_1.vi.fn();
|
|
230
|
+
onProfileUpdated(told);
|
|
231
|
+
(0, vitest_1.expect)((await updateProfile({ firstName: 'Ada' })).error).not.toBeNull();
|
|
232
|
+
(0, vitest_1.expect)(told).not.toHaveBeenCalled();
|
|
233
|
+
status = 200;
|
|
234
|
+
(0, vitest_1.expect)((await updateProfile({ firstName: 'Ada' })).error).toBeNull();
|
|
235
|
+
(0, vitest_1.expect)(told).toHaveBeenCalledWith({ firstName: 'Ada' });
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PREVIEW_CLAIM_PARAM = "zite_preview";
|
|
2
|
+
/**
|
|
3
|
+
* An editor preview's access in the browser, which the host keeps on the URL because the editor's frame may drop its
|
|
4
|
+
* cookie (WebKit drops even Partitioned ones). Read once, before a Start app's router hides it, and shared by
|
|
5
|
+
* `zitejs/start` and `zitejs/auth` so sign-in keeps it either way. A classic app's URL never carries one.
|
|
6
|
+
*/
|
|
7
|
+
export declare const browserPreviewClaim: () => string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.browserPreviewClaim = exports.PREVIEW_CLAIM_PARAM = void 0;
|
|
4
|
+
// The host's name for it (apps/zite-host/src/previewClaim.ts).
|
|
5
|
+
exports.PREVIEW_CLAIM_PARAM = 'zite_preview';
|
|
6
|
+
let captured;
|
|
7
|
+
/**
|
|
8
|
+
* An editor preview's access in the browser, which the host keeps on the URL because the editor's frame may drop its
|
|
9
|
+
* cookie (WebKit drops even Partitioned ones). Read once, before a Start app's router hides it, and shared by
|
|
10
|
+
* `zitejs/start` and `zitejs/auth` so sign-in keeps it either way. A classic app's URL never carries one.
|
|
11
|
+
*/
|
|
12
|
+
const browserPreviewClaim = () => {
|
|
13
|
+
captured ??= new URL(window.location.href).searchParams.get(exports.PREVIEW_CLAIM_PARAM);
|
|
14
|
+
return captured ?? undefined;
|
|
15
|
+
};
|
|
16
|
+
exports.browserPreviewClaim = browserPreviewClaim;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ProfileChanges = {
|
|
2
|
+
name?: string;
|
|
3
|
+
firstName?: string;
|
|
4
|
+
lastName?: string;
|
|
5
|
+
image?: string;
|
|
6
|
+
};
|
|
7
|
+
/** @internal A Start app's router, in the browser, so a profile edit shows without a reload. */
|
|
8
|
+
export declare const onProfileUpdated: (next: (changes: ProfileChanges) => void) => void;
|
|
9
|
+
export declare const profileUpdated: (changes: ProfileChanges) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.profileUpdated = exports.onProfileUpdated = void 0;
|
|
4
|
+
let listener;
|
|
5
|
+
/** @internal A Start app's router, in the browser, so a profile edit shows without a reload. */
|
|
6
|
+
const onProfileUpdated = (next) => {
|
|
7
|
+
listener = next;
|
|
8
|
+
};
|
|
9
|
+
exports.onProfileUpdated = onProfileUpdated;
|
|
10
|
+
const profileUpdated = (changes) => listener?.(changes);
|
|
11
|
+
exports.profileUpdated = profileUpdated;
|
|
@@ -23,6 +23,8 @@ export type ZiteTrigger = {
|
|
|
23
23
|
paused?: boolean;
|
|
24
24
|
every?: never;
|
|
25
25
|
events?: never;
|
|
26
|
+
table?: never;
|
|
27
|
+
form?: never;
|
|
26
28
|
} | {
|
|
27
29
|
/**
|
|
28
30
|
* The connection's name in `zite.config.json`, for a provider whose
|
|
@@ -37,6 +39,8 @@ export type ZiteTrigger = {
|
|
|
37
39
|
label?: string;
|
|
38
40
|
paused?: boolean;
|
|
39
41
|
every?: never;
|
|
42
|
+
table?: never;
|
|
43
|
+
form?: never;
|
|
40
44
|
} | {
|
|
41
45
|
/** `<n>m` (1–59) or `<n>h` (1–23). What makes the trigger a poll. */
|
|
42
46
|
every: string;
|
|
@@ -46,6 +50,78 @@ export type ZiteTrigger = {
|
|
|
46
50
|
label?: string;
|
|
47
51
|
paused?: boolean;
|
|
48
52
|
events?: never;
|
|
53
|
+
table?: never;
|
|
54
|
+
form?: never;
|
|
55
|
+
} | {
|
|
56
|
+
/**
|
|
57
|
+
* A table in the project's own database, as `zite.<table>` names it.
|
|
58
|
+
* Every write to it reaches the trigger, from apps, forms, imports, the
|
|
59
|
+
* database view and other automations; nothing is registered.
|
|
60
|
+
*/
|
|
61
|
+
table: string;
|
|
62
|
+
on: ZiteDatabaseTriggerEvent[];
|
|
63
|
+
/** Narrows `"updated"` to updates that changed one of these fields. */
|
|
64
|
+
fields?: string[];
|
|
65
|
+
/** The sentence the editor shows, e.g. "When an order ships". */
|
|
66
|
+
label?: string;
|
|
67
|
+
paused?: boolean;
|
|
68
|
+
integration?: never;
|
|
69
|
+
every?: never;
|
|
70
|
+
events?: never;
|
|
71
|
+
form?: never;
|
|
72
|
+
} | {
|
|
73
|
+
/**
|
|
74
|
+
* One of the project's own Fillout forms, by its name as the project
|
|
75
|
+
* lists it, or its id. Each finished live submission fires the
|
|
76
|
+
* endpoint; nothing is registered.
|
|
77
|
+
*/
|
|
78
|
+
form: string;
|
|
79
|
+
on: "submitted"[];
|
|
80
|
+
/** The sentence the editor shows, e.g. "When someone fills in the intake form". */
|
|
81
|
+
label?: string;
|
|
82
|
+
paused?: boolean;
|
|
83
|
+
integration?: never;
|
|
84
|
+
every?: never;
|
|
85
|
+
events?: never;
|
|
86
|
+
table?: never;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* What a form trigger's run gets as `input`: one submission. `answers` is
|
|
90
|
+
* keyed by question name, `answersById` by question id; `submission` is the
|
|
91
|
+
* whole export, as the Fillout API returns it (`questions`, `calculations`,
|
|
92
|
+
* `urlParameters`, …). Two questions with the same label are named
|
|
93
|
+
* `Email` and `Email (1)` in an order the form doesn't show, so read those by
|
|
94
|
+
* id.
|
|
95
|
+
*/
|
|
96
|
+
export type ZiteFormTriggerInput = {
|
|
97
|
+
event: "submitted";
|
|
98
|
+
form: string;
|
|
99
|
+
formId: string;
|
|
100
|
+
submissionId: string;
|
|
101
|
+
submittedAt: string | null;
|
|
102
|
+
answers: Record<string, unknown>;
|
|
103
|
+
answersById: Record<string, unknown>;
|
|
104
|
+
submission: Record<string, unknown> & {
|
|
105
|
+
submissionId: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export type ZiteDatabaseTriggerEvent = "created" | "updated" | "deleted";
|
|
109
|
+
/**
|
|
110
|
+
* What a database trigger's run gets as `input`: one changed record. Field
|
|
111
|
+
* keys are the SDK's, as `zite.<table>.findOne` returns them; cast `record`
|
|
112
|
+
* and `previous` to the table's generated `<Table>RecordType` from
|
|
113
|
+
* `zitejs/db` to type their fields.
|
|
114
|
+
*/
|
|
115
|
+
export type ZiteDatabaseTriggerInput<TRecord extends Record<string, unknown> = Record<string, unknown>> = {
|
|
116
|
+
event: ZiteDatabaseTriggerEvent;
|
|
117
|
+
table: string;
|
|
118
|
+
recordId: string;
|
|
119
|
+
/** Null on `"deleted"`, which leaves only `recordId`, and if it was deleted before the run read it. */
|
|
120
|
+
record: TRecord | null;
|
|
121
|
+
/** The record before an `"updated"`; null otherwise, and on a very large bulk write. */
|
|
122
|
+
previous: TRecord | null;
|
|
123
|
+
/** What an `"updated"` changed; on a very large bulk write, what the write changed across its records. */
|
|
124
|
+
changedFields: string[];
|
|
49
125
|
};
|
|
50
126
|
/**
|
|
51
127
|
* What a provider trigger's `subscribe` export receives. Write it as
|
|
@@ -115,10 +191,20 @@ export type ZiteTriggerDeliveryRun = ZiteTriggerRun & ZiteTriggerDeliveryInfo;
|
|
|
115
191
|
export type ZiteTriggerContext<TTrigger> = TTrigger extends {
|
|
116
192
|
every: string;
|
|
117
193
|
} ? ZiteTriggerRun : TTrigger extends {
|
|
194
|
+
table: string;
|
|
195
|
+
} | {
|
|
196
|
+
form: string;
|
|
197
|
+
} ? ZiteTriggerDeliveryInfo : TTrigger extends {
|
|
118
198
|
events: string[];
|
|
119
199
|
} ? ZiteTriggerDeliveryInfo : TTrigger extends {
|
|
120
200
|
integration: string;
|
|
121
201
|
} ? ZiteTriggerDeliveryRun : never;
|
|
202
|
+
/** A database or form trigger's runs get the change or submission as `input`. */
|
|
203
|
+
export type ZiteEndpointInput<TInput, TTrigger> = TTrigger extends {
|
|
204
|
+
table: string;
|
|
205
|
+
} ? ZiteDatabaseTriggerInput : TTrigger extends {
|
|
206
|
+
form: string;
|
|
207
|
+
} ? ZiteFormTriggerInput : TInput;
|
|
122
208
|
export interface ZiteRequestContext {
|
|
123
209
|
user: {
|
|
124
210
|
id: string;
|
|
@@ -215,13 +301,15 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream ext
|
|
|
215
301
|
*/
|
|
216
302
|
validatesInput?: boolean;
|
|
217
303
|
execute: (params: {
|
|
218
|
-
input: TInput
|
|
304
|
+
input: ZiteEndpointInput<TInput, TTrigger>;
|
|
219
305
|
/**
|
|
220
306
|
* Durable steps. `step.run(name, fn)` runs `fn` once per logical run:
|
|
221
307
|
* its result is saved before anything after it executes, and when a
|
|
222
308
|
* failed run is resumed, completed steps return their saved results
|
|
223
309
|
* instead of re-running their side effects. Names must be unique within
|
|
224
|
-
* a run, and results must be plain JSON data under 256KB.
|
|
310
|
+
* a run, and results must be plain JSON data under 256KB. In a run
|
|
311
|
+
* fired by a schedule, webhook or trigger, `step.sleep` pauses the run
|
|
312
|
+
* and a failed step is tried again.
|
|
225
313
|
*/
|
|
226
314
|
step: ZiteStep;
|
|
227
315
|
context: TSchedule extends ZiteSchedule ? ZiteRequestContext | ZiteScheduledContext : TWebhook extends ZiteWebhook ? ZiteRequestContext | ZiteScheduledContext : TTrigger extends ZiteTrigger ? ZiteRequestContext | ZiteScheduledContext : ZiteRequestContext;
|
|
@@ -240,8 +328,38 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream ext
|
|
|
240
328
|
* it would matter, and give a step inside a loop the item's id in its name.
|
|
241
329
|
*/
|
|
242
330
|
export interface ZiteStep {
|
|
243
|
-
|
|
331
|
+
/**
|
|
332
|
+
* In a run fired by a schedule, webhook or trigger, a step that throws is
|
|
333
|
+
* tried again `retries` more times (default 3, at most 10), 30 seconds,
|
|
334
|
+
* 2 minutes, then 10 minutes apart. Elsewhere its error fails the request.
|
|
335
|
+
* Once its tries are spent the code gets its error, and later calls of the
|
|
336
|
+
* run throw it there again, rebuilt as an `Error` with its `name`,
|
|
337
|
+
* `message` and plain fields such as `code` or `status`, so branch on
|
|
338
|
+
* those rather than on `instanceof`. A result over 256KB, or one JSON
|
|
339
|
+
* can't hold such as a cycle, fails the step without a retry.
|
|
340
|
+
*/
|
|
341
|
+
run<T>(name: string, fn: () => Promise<T> | T, options?: ZiteStepOptions): Promise<T>;
|
|
342
|
+
/**
|
|
343
|
+
* Pause the run for `duration`: `"30s"`, `"15m"`, `"2h"`, `"3d"`, `"1w"`,
|
|
344
|
+
* or milliseconds, at most 30 days. Only a run fired by a schedule, webhook
|
|
345
|
+
* or trigger can wait; an editor test run goes straight past, and a request
|
|
346
|
+
* from the app throws.
|
|
347
|
+
*
|
|
348
|
+
* The run continues in a later call, which runs `execute` again from the
|
|
349
|
+
* top: finished steps return their saved results, and code outside a step
|
|
350
|
+
* runs again, so keep side effects inside steps. Call it between steps, not
|
|
351
|
+
* inside a step's code: a step can't pause halfway, so a sleep there throws.
|
|
352
|
+
*/
|
|
353
|
+
sleep(name: string, duration: ZiteStepDuration): Promise<void>;
|
|
354
|
+
/** Pause the run until `when`, at most 30 days ahead. See {@link ZiteStep.sleep}. */
|
|
355
|
+
sleepUntil(name: string, when: Date | string): Promise<void>;
|
|
356
|
+
}
|
|
357
|
+
export interface ZiteStepOptions {
|
|
358
|
+
/** How many more times to try the step after it throws: 0 to 10, default 3. */
|
|
359
|
+
retries?: number;
|
|
244
360
|
}
|
|
361
|
+
/** Milliseconds, or a number with a unit: `ms`, `s`, `m`, `h`, `d` or `w`. */
|
|
362
|
+
export type ZiteStepDuration = number | `${number}${"ms" | "s" | "m" | "h" | "d" | "w"}`;
|
|
245
363
|
/**
|
|
246
364
|
* Create an endpoint definition, parsing `input` against `inputSchema` before
|
|
247
365
|
* `execute` runs. Nothing downstream parses it — the worker calls `execute` on
|