@dazl/internal-api-client 1.21.2 → 1.22.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.
- package/dist/client/client.gen.d.ts.map +1 -1
- package/dist/client/client.gen.js +103 -119
- package/dist/client/client.gen.js.map +1 -1
- package/dist/client/types.gen.d.ts +4 -2
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/client/utils.gen.d.ts +5 -1
- package/dist/client/utils.gen.d.ts.map +1 -1
- package/dist/client/utils.gen.js.map +1 -1
- package/dist/db/generated-types.d.ts +16 -6
- package/dist/db/generated-types.d.ts.map +1 -1
- package/dist/feature-toggles-config.d.ts +12 -0
- package/dist/feature-toggles-config.d.ts.map +1 -0
- package/dist/feature-toggles-config.js +8 -0
- package/dist/feature-toggles-config.js.map +1 -0
- package/dist/types.gen.d.ts +4 -0
- package/dist/types.gen.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/client/client.gen.ts +111 -129
- package/src/client/types.gen.ts +4 -2
- package/src/client/utils.gen.ts +4 -2
- package/src/db/generated-types.ts +16 -6
- package/src/feature-toggles-config.ts +19 -0
- package/src/types.gen.ts +4 -0
package/src/client/client.gen.ts
CHANGED
|
@@ -75,171 +75,154 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
const request: Client['request'] = async (options) => {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
redirect: 'follow',
|
|
81
|
-
...opts,
|
|
82
|
-
body: getValidRequestBody(opts),
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
let request = new Request(url, requestInit);
|
|
86
|
-
|
|
87
|
-
for (const fn of interceptors.request.fns) {
|
|
88
|
-
if (fn) {
|
|
89
|
-
request = await fn(request, opts);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
78
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
79
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
92
80
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const _fetch = opts.fetch!;
|
|
96
|
-
let response: Response;
|
|
81
|
+
let request: Request | undefined;
|
|
82
|
+
let response: Response | undefined;
|
|
97
83
|
|
|
98
84
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
const { opts, url } = await beforeRequest(options);
|
|
86
|
+
const requestInit: ReqInit = {
|
|
87
|
+
redirect: 'follow',
|
|
88
|
+
...opts,
|
|
89
|
+
body: getValidRequestBody(opts),
|
|
90
|
+
};
|
|
103
91
|
|
|
104
|
-
|
|
92
|
+
request = new Request(url, requestInit);
|
|
93
|
+
|
|
94
|
+
for (const fn of interceptors.request.fns) {
|
|
105
95
|
if (fn) {
|
|
106
|
-
|
|
96
|
+
request = await fn(request, opts);
|
|
107
97
|
}
|
|
108
98
|
}
|
|
109
99
|
|
|
110
|
-
|
|
100
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
101
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
102
|
+
const _fetch = opts.fetch!;
|
|
111
103
|
|
|
112
|
-
|
|
113
|
-
throw finalError;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Return error response
|
|
117
|
-
return opts.responseStyle === 'data'
|
|
118
|
-
? undefined
|
|
119
|
-
: {
|
|
120
|
-
error: finalError,
|
|
121
|
-
request,
|
|
122
|
-
response: undefined as any,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
104
|
+
response = await _fetch(request);
|
|
125
105
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
106
|
+
for (const fn of interceptors.response.fns) {
|
|
107
|
+
if (fn) {
|
|
108
|
+
response = await fn(response, request, opts);
|
|
109
|
+
}
|
|
129
110
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const result = {
|
|
133
|
-
request,
|
|
134
|
-
response,
|
|
135
|
-
};
|
|
136
111
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
112
|
+
const result = {
|
|
113
|
+
request,
|
|
114
|
+
response,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
if (response.ok) {
|
|
118
|
+
const parseAs =
|
|
119
|
+
(opts.parseAs === 'auto'
|
|
120
|
+
? getParseAs(response.headers.get('Content-Type'))
|
|
121
|
+
: opts.parseAs) ?? 'json';
|
|
122
|
+
|
|
123
|
+
if (response.status === 204 || response.headers.get('Content-Length') === '0') {
|
|
124
|
+
let emptyData: any;
|
|
125
|
+
switch (parseAs) {
|
|
126
|
+
case 'arrayBuffer':
|
|
127
|
+
case 'blob':
|
|
128
|
+
case 'text':
|
|
129
|
+
emptyData = await response[parseAs]();
|
|
130
|
+
break;
|
|
131
|
+
case 'formData':
|
|
132
|
+
emptyData = new FormData();
|
|
133
|
+
break;
|
|
134
|
+
case 'stream':
|
|
135
|
+
emptyData = response.body;
|
|
136
|
+
break;
|
|
137
|
+
case 'json':
|
|
138
|
+
default:
|
|
139
|
+
emptyData = {};
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return opts.responseStyle === 'data'
|
|
143
|
+
? emptyData
|
|
144
|
+
: {
|
|
145
|
+
data: emptyData,
|
|
146
|
+
...result,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
142
149
|
|
|
143
|
-
|
|
144
|
-
let emptyData: any;
|
|
150
|
+
let data: any;
|
|
145
151
|
switch (parseAs) {
|
|
146
152
|
case 'arrayBuffer':
|
|
147
153
|
case 'blob':
|
|
154
|
+
case 'formData':
|
|
148
155
|
case 'text':
|
|
149
|
-
|
|
156
|
+
data = await response[parseAs]();
|
|
150
157
|
break;
|
|
151
|
-
case '
|
|
152
|
-
|
|
158
|
+
case 'json': {
|
|
159
|
+
// Some servers return 200 with no Content-Length and empty body.
|
|
160
|
+
// response.json() would throw; read as text and parse if non-empty.
|
|
161
|
+
const text = await response.text();
|
|
162
|
+
data = text ? JSON.parse(text) : {};
|
|
153
163
|
break;
|
|
164
|
+
}
|
|
154
165
|
case 'stream':
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
return opts.responseStyle === 'data'
|
|
167
|
+
? response.body
|
|
168
|
+
: {
|
|
169
|
+
data: response.body,
|
|
170
|
+
...result,
|
|
171
|
+
};
|
|
161
172
|
}
|
|
173
|
+
|
|
174
|
+
if (parseAs === 'json') {
|
|
175
|
+
if (opts.responseValidator) {
|
|
176
|
+
await opts.responseValidator(data);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (opts.responseTransformer) {
|
|
180
|
+
data = await opts.responseTransformer(data);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
162
184
|
return opts.responseStyle === 'data'
|
|
163
|
-
?
|
|
185
|
+
? data
|
|
164
186
|
: {
|
|
165
|
-
data
|
|
187
|
+
data,
|
|
166
188
|
...result,
|
|
167
189
|
};
|
|
168
190
|
}
|
|
169
191
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
break;
|
|
178
|
-
case 'json': {
|
|
179
|
-
// Some servers return 200 with no Content-Length and empty body.
|
|
180
|
-
// response.json() would throw; read as text and parse if non-empty.
|
|
181
|
-
const text = await response.text();
|
|
182
|
-
data = text ? JSON.parse(text) : {};
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
case 'stream':
|
|
186
|
-
return opts.responseStyle === 'data'
|
|
187
|
-
? response.body
|
|
188
|
-
: {
|
|
189
|
-
data: response.body,
|
|
190
|
-
...result,
|
|
191
|
-
};
|
|
192
|
+
const textError = await response.text();
|
|
193
|
+
let jsonError: unknown;
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
jsonError = JSON.parse(textError);
|
|
197
|
+
} catch {
|
|
198
|
+
// noop
|
|
192
199
|
}
|
|
193
200
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
201
|
+
throw jsonError ?? textError;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
let finalError = error;
|
|
198
204
|
|
|
199
|
-
|
|
200
|
-
|
|
205
|
+
for (const fn of interceptors.error.fns) {
|
|
206
|
+
if (fn) {
|
|
207
|
+
finalError = await fn(finalError, response, request, options as ResolvedRequestOptions);
|
|
201
208
|
}
|
|
202
209
|
}
|
|
203
210
|
|
|
204
|
-
|
|
205
|
-
? data
|
|
206
|
-
: {
|
|
207
|
-
data,
|
|
208
|
-
...result,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const textError = await response.text();
|
|
213
|
-
let jsonError: unknown;
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
jsonError = JSON.parse(textError);
|
|
217
|
-
} catch {
|
|
218
|
-
// noop
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const error = jsonError ?? textError;
|
|
222
|
-
let finalError = error;
|
|
211
|
+
finalError = finalError || {};
|
|
223
212
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
finalError = (await fn(error, response, request, opts)) as string;
|
|
213
|
+
if (throwOnError) {
|
|
214
|
+
throw finalError;
|
|
227
215
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
finalError = finalError || ({} as string);
|
|
231
216
|
|
|
232
|
-
|
|
233
|
-
|
|
217
|
+
// TODO: we probably want to return error and improve types
|
|
218
|
+
return responseStyle === 'data'
|
|
219
|
+
? undefined
|
|
220
|
+
: {
|
|
221
|
+
error: finalError,
|
|
222
|
+
request,
|
|
223
|
+
response,
|
|
224
|
+
};
|
|
234
225
|
}
|
|
235
|
-
|
|
236
|
-
// TODO: we probably want to return error and improve types
|
|
237
|
-
return opts.responseStyle === 'data'
|
|
238
|
-
? undefined
|
|
239
|
-
: {
|
|
240
|
-
error: finalError,
|
|
241
|
-
...result,
|
|
242
|
-
};
|
|
243
226
|
};
|
|
244
227
|
|
|
245
228
|
const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
@@ -250,7 +233,6 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
250
233
|
return createSseClient({
|
|
251
234
|
...opts,
|
|
252
235
|
body: opts.body as BodyInit | null | undefined,
|
|
253
|
-
headers: opts.headers as unknown as Record<string, string>,
|
|
254
236
|
method,
|
|
255
237
|
onRequest: async (url, init) => {
|
|
256
238
|
let request = new Request(url, init);
|
package/src/client/types.gen.ts
CHANGED
|
@@ -127,8 +127,10 @@ export type RequestResult<
|
|
|
127
127
|
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
128
128
|
}
|
|
129
129
|
) & {
|
|
130
|
-
request
|
|
131
|
-
|
|
130
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
131
|
+
request?: Request;
|
|
132
|
+
/** response may be undefined, because error may be from building the request object itself or from a network error */
|
|
133
|
+
response?: Response;
|
|
132
134
|
}
|
|
133
135
|
>;
|
|
134
136
|
|
package/src/client/utils.gen.ts
CHANGED
|
@@ -218,8 +218,10 @@ export const mergeHeaders = (
|
|
|
218
218
|
|
|
219
219
|
type ErrInterceptor<Err, Res, Req, Options> = (
|
|
220
220
|
error: Err,
|
|
221
|
-
response
|
|
222
|
-
|
|
221
|
+
/** response may be undefined due to a network error where no response object is produced */
|
|
222
|
+
response: Res | undefined,
|
|
223
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
224
|
+
request: Req | undefined,
|
|
223
225
|
options: Options,
|
|
224
226
|
) => Err | Promise<Err>;
|
|
225
227
|
|
|
@@ -46,18 +46,22 @@ export interface AdminAction {
|
|
|
46
46
|
targetDazlUserId: string | null;
|
|
47
47
|
targetProjectId: string | null;
|
|
48
48
|
targetUserId: number | null;
|
|
49
|
+
updatedAt: Generated<Timestamp>;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export interface CreditBalance {
|
|
52
53
|
balance: Generated<number>;
|
|
54
|
+
createdAt: Generated<Timestamp>;
|
|
53
55
|
dazlUserId: string;
|
|
54
56
|
priceId: string | null;
|
|
55
|
-
updatedAt: Timestamp
|
|
57
|
+
updatedAt: Generated<Timestamp>;
|
|
56
58
|
userId: number;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
export interface CreditTransaction {
|
|
62
|
+
createdAt: Generated<Timestamp>;
|
|
60
63
|
id: string;
|
|
64
|
+
updatedAt: Generated<Timestamp>;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
export interface Deploy {
|
|
@@ -69,6 +73,7 @@ export interface Deploy {
|
|
|
69
73
|
productionURL: string | null;
|
|
70
74
|
projectId: string;
|
|
71
75
|
publishedAt: Timestamp | null;
|
|
76
|
+
updatedAt: Generated<Timestamp>;
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
export interface EncryptedValue {
|
|
@@ -90,7 +95,7 @@ export interface GitHubUser {
|
|
|
90
95
|
accessToken: string | null;
|
|
91
96
|
createdAt: Generated<Timestamp>;
|
|
92
97
|
refreshToken: string | null;
|
|
93
|
-
updatedAt: Timestamp
|
|
98
|
+
updatedAt: Generated<Timestamp>;
|
|
94
99
|
userDazlId: string;
|
|
95
100
|
username: string;
|
|
96
101
|
}
|
|
@@ -111,9 +116,11 @@ export interface Media {
|
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
export interface NetlifyAccount {
|
|
119
|
+
createdAt: Generated<Timestamp>;
|
|
114
120
|
netlifyAccountId: string;
|
|
115
121
|
netlifySlug: string;
|
|
116
122
|
typeId: string | null;
|
|
123
|
+
updatedAt: Generated<Timestamp>;
|
|
117
124
|
userId: string;
|
|
118
125
|
}
|
|
119
126
|
|
|
@@ -128,6 +135,7 @@ export interface Project {
|
|
|
128
135
|
members: Json | null;
|
|
129
136
|
name: string;
|
|
130
137
|
originTemplateId: string | null;
|
|
138
|
+
updatedAt: Generated<Timestamp>;
|
|
131
139
|
userId: number;
|
|
132
140
|
}
|
|
133
141
|
|
|
@@ -147,7 +155,7 @@ export interface ProjectOnGitHub {
|
|
|
147
155
|
installationId: number;
|
|
148
156
|
projectId: string;
|
|
149
157
|
repoFullName: string;
|
|
150
|
-
updatedAt: Timestamp
|
|
158
|
+
updatedAt: Generated<Timestamp>;
|
|
151
159
|
}
|
|
152
160
|
|
|
153
161
|
export interface StripePrice {
|
|
@@ -159,7 +167,7 @@ export interface StripePrice {
|
|
|
159
167
|
lookupKey: string | null;
|
|
160
168
|
productId: string;
|
|
161
169
|
unitAmount: number;
|
|
162
|
-
updatedAt: Timestamp
|
|
170
|
+
updatedAt: Generated<Timestamp>;
|
|
163
171
|
}
|
|
164
172
|
|
|
165
173
|
export interface StripeProduct {
|
|
@@ -167,7 +175,7 @@ export interface StripeProduct {
|
|
|
167
175
|
createdAt: Generated<Timestamp>;
|
|
168
176
|
id: string;
|
|
169
177
|
name: string;
|
|
170
|
-
updatedAt: Timestamp
|
|
178
|
+
updatedAt: Generated<Timestamp>;
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
export interface Template {
|
|
@@ -183,6 +191,7 @@ export interface Template {
|
|
|
183
191
|
preserveEnvFile: Generated<boolean>;
|
|
184
192
|
screenshot: string | null;
|
|
185
193
|
sharedWith: Json | null;
|
|
194
|
+
updatedAt: Generated<Timestamp>;
|
|
186
195
|
usageCount: Generated<number>;
|
|
187
196
|
userId: number;
|
|
188
197
|
}
|
|
@@ -196,6 +205,7 @@ export interface User {
|
|
|
196
205
|
name: string;
|
|
197
206
|
picture: string | null;
|
|
198
207
|
stripeCustomerId: string | null;
|
|
208
|
+
updatedAt: Generated<Timestamp>;
|
|
199
209
|
}
|
|
200
210
|
|
|
201
211
|
export interface UserKeyValue {
|
|
@@ -212,7 +222,7 @@ export interface UserKeyValue {
|
|
|
212
222
|
export interface UserSettings {
|
|
213
223
|
createdAt: Generated<Timestamp>;
|
|
214
224
|
settings: Json;
|
|
215
|
-
updatedAt: Timestamp
|
|
225
|
+
updatedAt: Generated<Timestamp>;
|
|
216
226
|
userId: string;
|
|
217
227
|
}
|
|
218
228
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* this file is copyied into the SDK
|
|
3
|
+
* DO NOT IMPORT INTO THIS FILE.
|
|
4
|
+
*/
|
|
5
|
+
export type ToggleScope = "RemoteAndEditor" | "SiteAndEditor";
|
|
6
|
+
|
|
7
|
+
export interface FeatureToggleConfig {
|
|
8
|
+
scope: ToggleScope;
|
|
9
|
+
canClose: boolean;
|
|
10
|
+
owner: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const featureTogglesConfig: Record<string, FeatureToggleConfig> = {
|
|
14
|
+
test: {
|
|
15
|
+
scope: "SiteAndEditor",
|
|
16
|
+
canClose: true,
|
|
17
|
+
owner: "testOwner",
|
|
18
|
+
},
|
|
19
|
+
};
|
package/src/types.gen.ts
CHANGED
|
@@ -83,6 +83,7 @@ export type Deployment = {
|
|
|
83
83
|
createdAt: string;
|
|
84
84
|
customDomain: string | null;
|
|
85
85
|
customDomainStatus: 'success' | 'pending' | 'error' | null;
|
|
86
|
+
updatedAt: string;
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
export type ProjectRaw = {
|
|
@@ -219,6 +220,7 @@ export type TemplateRaw = {
|
|
|
219
220
|
email: string;
|
|
220
221
|
}> | null;
|
|
221
222
|
screenshotUrl?: string | null;
|
|
223
|
+
updatedAt: string;
|
|
222
224
|
};
|
|
223
225
|
|
|
224
226
|
export type UploadConfiguration = {
|
|
@@ -401,6 +403,7 @@ export type UserRaw = {
|
|
|
401
403
|
id: number;
|
|
402
404
|
createdAt: string;
|
|
403
405
|
picture: string | null;
|
|
406
|
+
updatedAt: string;
|
|
404
407
|
} & {
|
|
405
408
|
dazlId: string;
|
|
406
409
|
name: string;
|
|
@@ -522,6 +525,7 @@ export type UpdateCreditsInput = {
|
|
|
522
525
|
export type FeatureToggle = {
|
|
523
526
|
name: string;
|
|
524
527
|
scope: 'RemoteAndEditor' | 'SiteAndEditor';
|
|
528
|
+
updatedAt: string;
|
|
525
529
|
};
|
|
526
530
|
|
|
527
531
|
export type PurgeUserAccountInput = {
|