@trypattern/sdk 0.1.8 → 0.1.9
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/cli/app.js +1 -1
- package/dist/cli/publishing.js +1 -1
- package/dist/components/AppFrame.d.ts +2 -1
- package/dist/components/AppFrame.js +2 -2
- package/dist/components/Appear.d.ts +4 -1
- package/dist/components/Appear.js +82 -3
- package/dist/components/Link.js +8 -3
- package/dist/components/ListRow.d.ts +2 -1
- package/dist/components/ListRow.js +7 -4
- package/dist/components/Sidebar.js +2 -1
- package/dist/patternAccess.d.ts +21 -0
- package/dist/patternAccess.js +110 -0
- package/dist/publishWire.d.ts +316 -0
- package/dist/publishWire.js +107 -0
- package/dist/server/createServer.d.ts +87 -3
- package/dist/server/createServer.js +6 -0
- package/dist/server/database.d.ts +74 -0
- package/dist/server/database.js +93 -0
- package/dist/server/keyset.d.ts +13 -0
- package/dist/server/keyset.js +52 -0
- package/dist/server/patternKeys.d.ts +1 -0
- package/dist/server/patternKeys.js +3 -0
- package/dist/server/patternViewer.d.ts +6 -0
- package/dist/server/patternViewer.js +27 -0
- package/dist/server/services.js +1 -1
- package/dist/server/tables.d.ts +16 -3
- package/dist/server/tables.js +15 -6
- package/dist/serviceClients.js +3 -5
- package/package.json +1 -1
package/dist/publishWire.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { appTitle } from './appTitle.ts';
|
|
3
3
|
export { appTitle };
|
|
4
|
+
export { ASSERTION_SECONDS, NEXT_PAGE_HEADER, TABLES_READ, assertionKey, signTablesAssertion } from './patternAccess.ts';
|
|
5
|
+
export type { AssertionKey } from './patternAccess.ts';
|
|
4
6
|
export declare const DASHBOARD_URL = "https://onpattern.app";
|
|
5
7
|
export declare const APPS_DOMAIN = "onpattern.app";
|
|
6
8
|
export declare const UPLOAD_LIMIT_BYTES: number;
|
|
@@ -116,6 +118,176 @@ export declare const connection: z.ZodObject<{
|
|
|
116
118
|
connectedAt: z.ZodString;
|
|
117
119
|
}, z.core.$strip>;
|
|
118
120
|
export type Connection = z.output<typeof connection>;
|
|
121
|
+
export declare const DOMAIN_ENDINGS: readonly ["com", "ca", "co", "org", "net", "app", "dev", "shop"];
|
|
122
|
+
export declare const DOMAIN_PRICE_LIMIT_USD = 30;
|
|
123
|
+
export declare const domainName: z.ZodString;
|
|
124
|
+
export declare const domainChoice: z.ZodObject<{
|
|
125
|
+
domain: z.ZodString;
|
|
126
|
+
priceUsd: z.ZodNullable<z.ZodString>;
|
|
127
|
+
isAvailable: z.ZodBoolean;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export type DomainChoice = z.output<typeof domainChoice>;
|
|
130
|
+
export declare const domainSteps: readonly ["register", "address", "sign-in", "reachable"];
|
|
131
|
+
export declare const domainSummary: z.ZodObject<{
|
|
132
|
+
domain: z.ZodString;
|
|
133
|
+
priceUsd: z.ZodString;
|
|
134
|
+
status: z.ZodEnum<{
|
|
135
|
+
failed: "failed";
|
|
136
|
+
live: "live";
|
|
137
|
+
working: "working";
|
|
138
|
+
}>;
|
|
139
|
+
step: z.ZodEnum<{
|
|
140
|
+
address: "address";
|
|
141
|
+
"sign-in": "sign-in";
|
|
142
|
+
register: "register";
|
|
143
|
+
reachable: "reachable";
|
|
144
|
+
}>;
|
|
145
|
+
error: z.ZodNullable<z.ZodString>;
|
|
146
|
+
startedAt: z.ZodString;
|
|
147
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
148
|
+
finishedAt: z.ZodNullable<z.ZodString>;
|
|
149
|
+
}, z.core.$strip>;
|
|
150
|
+
export type DomainSummary = z.output<typeof domainSummary>;
|
|
151
|
+
export declare const mailboxSummary: z.ZodObject<{
|
|
152
|
+
address: z.ZodString;
|
|
153
|
+
destination: z.ZodString;
|
|
154
|
+
status: z.ZodEnum<{
|
|
155
|
+
failed: "failed";
|
|
156
|
+
ready: "ready";
|
|
157
|
+
verifying: "verifying";
|
|
158
|
+
}>;
|
|
159
|
+
error: z.ZodNullable<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
export type MailboxSummary = z.output<typeof mailboxSummary>;
|
|
162
|
+
export declare const mailboxLocalPart: z.ZodString;
|
|
163
|
+
export declare const DATABASE_PAGE_ROWS = 100;
|
|
164
|
+
export declare const databaseTable: z.ZodObject<{
|
|
165
|
+
name: z.ZodString;
|
|
166
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
167
|
+
access: z.ZodObject<{
|
|
168
|
+
read: z.ZodEnum<{
|
|
169
|
+
anyone: "anyone";
|
|
170
|
+
signedIn: "signedIn";
|
|
171
|
+
owner: "owner";
|
|
172
|
+
admin: "admin";
|
|
173
|
+
server: "server";
|
|
174
|
+
}>;
|
|
175
|
+
create: z.ZodEnum<{
|
|
176
|
+
anyone: "anyone";
|
|
177
|
+
signedIn: "signedIn";
|
|
178
|
+
owner: "owner";
|
|
179
|
+
admin: "admin";
|
|
180
|
+
server: "server";
|
|
181
|
+
}>;
|
|
182
|
+
update: z.ZodEnum<{
|
|
183
|
+
anyone: "anyone";
|
|
184
|
+
signedIn: "signedIn";
|
|
185
|
+
owner: "owner";
|
|
186
|
+
admin: "admin";
|
|
187
|
+
server: "server";
|
|
188
|
+
}>;
|
|
189
|
+
delete: z.ZodEnum<{
|
|
190
|
+
anyone: "anyone";
|
|
191
|
+
signedIn: "signedIn";
|
|
192
|
+
owner: "owner";
|
|
193
|
+
admin: "admin";
|
|
194
|
+
server: "server";
|
|
195
|
+
}>;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
public: z.ZodArray<z.ZodString>;
|
|
198
|
+
rowCount: z.ZodNumber;
|
|
199
|
+
isBuiltIn: z.ZodBoolean;
|
|
200
|
+
}, z.core.$strip>;
|
|
201
|
+
export type DatabaseTable = z.output<typeof databaseTable>;
|
|
202
|
+
export declare const appSchema: z.ZodObject<{
|
|
203
|
+
tables: z.ZodArray<z.ZodObject<{
|
|
204
|
+
name: z.ZodString;
|
|
205
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
206
|
+
access: z.ZodObject<{
|
|
207
|
+
read: z.ZodEnum<{
|
|
208
|
+
anyone: "anyone";
|
|
209
|
+
signedIn: "signedIn";
|
|
210
|
+
owner: "owner";
|
|
211
|
+
admin: "admin";
|
|
212
|
+
server: "server";
|
|
213
|
+
}>;
|
|
214
|
+
create: z.ZodEnum<{
|
|
215
|
+
anyone: "anyone";
|
|
216
|
+
signedIn: "signedIn";
|
|
217
|
+
owner: "owner";
|
|
218
|
+
admin: "admin";
|
|
219
|
+
server: "server";
|
|
220
|
+
}>;
|
|
221
|
+
update: z.ZodEnum<{
|
|
222
|
+
anyone: "anyone";
|
|
223
|
+
signedIn: "signedIn";
|
|
224
|
+
owner: "owner";
|
|
225
|
+
admin: "admin";
|
|
226
|
+
server: "server";
|
|
227
|
+
}>;
|
|
228
|
+
delete: z.ZodEnum<{
|
|
229
|
+
anyone: "anyone";
|
|
230
|
+
signedIn: "signedIn";
|
|
231
|
+
owner: "owner";
|
|
232
|
+
admin: "admin";
|
|
233
|
+
server: "server";
|
|
234
|
+
}>;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
public: z.ZodArray<z.ZodString>;
|
|
237
|
+
rowCount: z.ZodNumber;
|
|
238
|
+
isBuiltIn: z.ZodBoolean;
|
|
239
|
+
}, z.core.$strip>>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
export declare const databaseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
242
|
+
status: z.ZodLiteral<"ready">;
|
|
243
|
+
tables: z.ZodArray<z.ZodObject<{
|
|
244
|
+
name: z.ZodString;
|
|
245
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
246
|
+
access: z.ZodObject<{
|
|
247
|
+
read: z.ZodEnum<{
|
|
248
|
+
anyone: "anyone";
|
|
249
|
+
signedIn: "signedIn";
|
|
250
|
+
owner: "owner";
|
|
251
|
+
admin: "admin";
|
|
252
|
+
server: "server";
|
|
253
|
+
}>;
|
|
254
|
+
create: z.ZodEnum<{
|
|
255
|
+
anyone: "anyone";
|
|
256
|
+
signedIn: "signedIn";
|
|
257
|
+
owner: "owner";
|
|
258
|
+
admin: "admin";
|
|
259
|
+
server: "server";
|
|
260
|
+
}>;
|
|
261
|
+
update: z.ZodEnum<{
|
|
262
|
+
anyone: "anyone";
|
|
263
|
+
signedIn: "signedIn";
|
|
264
|
+
owner: "owner";
|
|
265
|
+
admin: "admin";
|
|
266
|
+
server: "server";
|
|
267
|
+
}>;
|
|
268
|
+
delete: z.ZodEnum<{
|
|
269
|
+
anyone: "anyone";
|
|
270
|
+
signedIn: "signedIn";
|
|
271
|
+
owner: "owner";
|
|
272
|
+
admin: "admin";
|
|
273
|
+
server: "server";
|
|
274
|
+
}>;
|
|
275
|
+
}, z.core.$strip>;
|
|
276
|
+
public: z.ZodArray<z.ZodString>;
|
|
277
|
+
rowCount: z.ZodNumber;
|
|
278
|
+
isBuiltIn: z.ZodBoolean;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
281
|
+
status: z.ZodLiteral<"outdated">;
|
|
282
|
+
}, z.core.$strip>], "status">;
|
|
283
|
+
export type DatabaseSchema = z.output<typeof databaseSchema>;
|
|
284
|
+
export declare const databaseRow: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
285
|
+
export type DatabaseRow = z.output<typeof databaseRow>;
|
|
286
|
+
export declare const databaseRows: z.ZodObject<{
|
|
287
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
288
|
+
next: z.ZodNullable<z.ZodString>;
|
|
289
|
+
}, z.core.$strip>;
|
|
290
|
+
export type DatabaseRows = z.output<typeof databaseRows>;
|
|
119
291
|
export declare const publishServices: {
|
|
120
292
|
readonly apps: {
|
|
121
293
|
readonly list: NoInfer<import("./services.ts").ServiceCall<"/apps", {}, z.ZodArray<z.ZodObject<{
|
|
@@ -295,6 +467,150 @@ export declare const publishServices: {
|
|
|
295
467
|
ok: z.ZodBoolean;
|
|
296
468
|
}, z.core.$strip>>>;
|
|
297
469
|
};
|
|
470
|
+
readonly domains: {
|
|
471
|
+
readonly search: NoInfer<import("./services.ts").ServiceCall<"/domains", {
|
|
472
|
+
query: z.ZodString;
|
|
473
|
+
}, z.ZodArray<z.ZodObject<{
|
|
474
|
+
domain: z.ZodString;
|
|
475
|
+
priceUsd: z.ZodNullable<z.ZodString>;
|
|
476
|
+
isAvailable: z.ZodBoolean;
|
|
477
|
+
}, z.core.$strip>>>>;
|
|
478
|
+
readonly read: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/domain", {}, z.ZodNullable<z.ZodObject<{
|
|
479
|
+
domain: z.ZodString;
|
|
480
|
+
priceUsd: z.ZodString;
|
|
481
|
+
status: z.ZodEnum<{
|
|
482
|
+
failed: "failed";
|
|
483
|
+
live: "live";
|
|
484
|
+
working: "working";
|
|
485
|
+
}>;
|
|
486
|
+
step: z.ZodEnum<{
|
|
487
|
+
address: "address";
|
|
488
|
+
"sign-in": "sign-in";
|
|
489
|
+
register: "register";
|
|
490
|
+
reachable: "reachable";
|
|
491
|
+
}>;
|
|
492
|
+
error: z.ZodNullable<z.ZodString>;
|
|
493
|
+
startedAt: z.ZodString;
|
|
494
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
495
|
+
finishedAt: z.ZodNullable<z.ZodString>;
|
|
496
|
+
}, z.core.$strip>>>>;
|
|
497
|
+
readonly buy: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/domain", {
|
|
498
|
+
domain: z.ZodString;
|
|
499
|
+
priceUsd: z.ZodString;
|
|
500
|
+
}, z.ZodObject<{
|
|
501
|
+
domain: z.ZodString;
|
|
502
|
+
priceUsd: z.ZodString;
|
|
503
|
+
status: z.ZodEnum<{
|
|
504
|
+
failed: "failed";
|
|
505
|
+
live: "live";
|
|
506
|
+
working: "working";
|
|
507
|
+
}>;
|
|
508
|
+
step: z.ZodEnum<{
|
|
509
|
+
address: "address";
|
|
510
|
+
"sign-in": "sign-in";
|
|
511
|
+
register: "register";
|
|
512
|
+
reachable: "reachable";
|
|
513
|
+
}>;
|
|
514
|
+
error: z.ZodNullable<z.ZodString>;
|
|
515
|
+
startedAt: z.ZodString;
|
|
516
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
517
|
+
finishedAt: z.ZodNullable<z.ZodString>;
|
|
518
|
+
}, z.core.$strip>>>;
|
|
519
|
+
readonly retry: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/domain/retry", {}, z.ZodObject<{
|
|
520
|
+
domain: z.ZodString;
|
|
521
|
+
priceUsd: z.ZodString;
|
|
522
|
+
status: z.ZodEnum<{
|
|
523
|
+
failed: "failed";
|
|
524
|
+
live: "live";
|
|
525
|
+
working: "working";
|
|
526
|
+
}>;
|
|
527
|
+
step: z.ZodEnum<{
|
|
528
|
+
address: "address";
|
|
529
|
+
"sign-in": "sign-in";
|
|
530
|
+
register: "register";
|
|
531
|
+
reachable: "reachable";
|
|
532
|
+
}>;
|
|
533
|
+
error: z.ZodNullable<z.ZodString>;
|
|
534
|
+
startedAt: z.ZodString;
|
|
535
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
536
|
+
finishedAt: z.ZodNullable<z.ZodString>;
|
|
537
|
+
}, z.core.$strip>>>;
|
|
538
|
+
};
|
|
539
|
+
readonly mailboxes: {
|
|
540
|
+
readonly read: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/mailbox", {}, z.ZodNullable<z.ZodObject<{
|
|
541
|
+
address: z.ZodString;
|
|
542
|
+
destination: z.ZodString;
|
|
543
|
+
status: z.ZodEnum<{
|
|
544
|
+
failed: "failed";
|
|
545
|
+
ready: "ready";
|
|
546
|
+
verifying: "verifying";
|
|
547
|
+
}>;
|
|
548
|
+
error: z.ZodNullable<z.ZodString>;
|
|
549
|
+
}, z.core.$strip>>>>;
|
|
550
|
+
readonly create: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/mailbox", {
|
|
551
|
+
localPart: z.ZodString;
|
|
552
|
+
destination: z.ZodEmail;
|
|
553
|
+
}, z.ZodObject<{
|
|
554
|
+
address: z.ZodString;
|
|
555
|
+
destination: z.ZodString;
|
|
556
|
+
status: z.ZodEnum<{
|
|
557
|
+
failed: "failed";
|
|
558
|
+
ready: "ready";
|
|
559
|
+
verifying: "verifying";
|
|
560
|
+
}>;
|
|
561
|
+
error: z.ZodNullable<z.ZodString>;
|
|
562
|
+
}, z.core.$strip>>>;
|
|
563
|
+
};
|
|
564
|
+
readonly database: {
|
|
565
|
+
readonly schema: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/database", {}, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
566
|
+
status: z.ZodLiteral<"ready">;
|
|
567
|
+
tables: z.ZodArray<z.ZodObject<{
|
|
568
|
+
name: z.ZodString;
|
|
569
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
570
|
+
access: z.ZodObject<{
|
|
571
|
+
read: z.ZodEnum<{
|
|
572
|
+
anyone: "anyone";
|
|
573
|
+
signedIn: "signedIn";
|
|
574
|
+
owner: "owner";
|
|
575
|
+
admin: "admin";
|
|
576
|
+
server: "server";
|
|
577
|
+
}>;
|
|
578
|
+
create: z.ZodEnum<{
|
|
579
|
+
anyone: "anyone";
|
|
580
|
+
signedIn: "signedIn";
|
|
581
|
+
owner: "owner";
|
|
582
|
+
admin: "admin";
|
|
583
|
+
server: "server";
|
|
584
|
+
}>;
|
|
585
|
+
update: z.ZodEnum<{
|
|
586
|
+
anyone: "anyone";
|
|
587
|
+
signedIn: "signedIn";
|
|
588
|
+
owner: "owner";
|
|
589
|
+
admin: "admin";
|
|
590
|
+
server: "server";
|
|
591
|
+
}>;
|
|
592
|
+
delete: z.ZodEnum<{
|
|
593
|
+
anyone: "anyone";
|
|
594
|
+
signedIn: "signedIn";
|
|
595
|
+
owner: "owner";
|
|
596
|
+
admin: "admin";
|
|
597
|
+
server: "server";
|
|
598
|
+
}>;
|
|
599
|
+
}, z.core.$strip>;
|
|
600
|
+
public: z.ZodArray<z.ZodString>;
|
|
601
|
+
rowCount: z.ZodNumber;
|
|
602
|
+
isBuiltIn: z.ZodBoolean;
|
|
603
|
+
}, z.core.$strip>>;
|
|
604
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
605
|
+
status: z.ZodLiteral<"outdated">;
|
|
606
|
+
}, z.core.$strip>], "status">>>;
|
|
607
|
+
readonly rows: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/database/:table", {
|
|
608
|
+
after: z.ZodOptional<z.ZodString>;
|
|
609
|
+
}, z.ZodObject<{
|
|
610
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
611
|
+
next: z.ZodNullable<z.ZodString>;
|
|
612
|
+
}, z.core.$strip>>>;
|
|
613
|
+
};
|
|
298
614
|
readonly logins: {
|
|
299
615
|
readonly read: NoInfer<import("./services.ts").ServiceCall<"/cli/logins/:approval", {}, z.ZodObject<{
|
|
300
616
|
code: z.ZodString;
|
package/dist/publishWire.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { appTitle } from "./appTitle.js";
|
|
3
3
|
export { appTitle };
|
|
4
|
+
export { ASSERTION_SECONDS, NEXT_PAGE_HEADER, TABLES_READ, assertionKey, signTablesAssertion } from "./patternAccess.js";
|
|
4
5
|
import { call, defineServices } from "./services.js";
|
|
5
6
|
export const DASHBOARD_URL = 'https://onpattern.app';
|
|
6
7
|
export const APPS_DOMAIN = 'onpattern.app';
|
|
@@ -139,6 +140,79 @@ export const connection = z.object({
|
|
|
139
140
|
label: z.string(),
|
|
140
141
|
connectedAt: z.string()
|
|
141
142
|
});
|
|
143
|
+
export const DOMAIN_ENDINGS = [
|
|
144
|
+
'com',
|
|
145
|
+
'ca',
|
|
146
|
+
'co',
|
|
147
|
+
'org',
|
|
148
|
+
'net',
|
|
149
|
+
'app',
|
|
150
|
+
'dev',
|
|
151
|
+
'shop'
|
|
152
|
+
];
|
|
153
|
+
export const DOMAIN_PRICE_LIMIT_USD = 30;
|
|
154
|
+
export const domainName = z
|
|
155
|
+
.string()
|
|
156
|
+
.trim()
|
|
157
|
+
.toLowerCase()
|
|
158
|
+
.regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/);
|
|
159
|
+
export const domainChoice = z.object({
|
|
160
|
+
domain: z.string(),
|
|
161
|
+
priceUsd: z.string().nullable(),
|
|
162
|
+
isAvailable: z.boolean()
|
|
163
|
+
});
|
|
164
|
+
export const domainSteps = [
|
|
165
|
+
'register',
|
|
166
|
+
'address',
|
|
167
|
+
'sign-in',
|
|
168
|
+
'reachable'
|
|
169
|
+
];
|
|
170
|
+
export const domainSummary = z.object({
|
|
171
|
+
domain: z.string(),
|
|
172
|
+
priceUsd: z.string(),
|
|
173
|
+
status: z.enum(['working', 'live', 'failed']),
|
|
174
|
+
step: z.enum(domainSteps),
|
|
175
|
+
error: z.string().nullable(),
|
|
176
|
+
startedAt: z.string(),
|
|
177
|
+
checkedAt: z.string().nullable(),
|
|
178
|
+
finishedAt: z.string().nullable()
|
|
179
|
+
});
|
|
180
|
+
export const mailboxSummary = z.object({
|
|
181
|
+
address: z.string(),
|
|
182
|
+
destination: z.string(),
|
|
183
|
+
status: z.enum(['verifying', 'ready', 'failed']),
|
|
184
|
+
error: z.string().nullable()
|
|
185
|
+
});
|
|
186
|
+
export const mailboxLocalPart = z
|
|
187
|
+
.string()
|
|
188
|
+
.trim()
|
|
189
|
+
.toLowerCase()
|
|
190
|
+
.regex(/^[a-z0-9]([a-z0-9._-]{0,62}[a-z0-9])?$/);
|
|
191
|
+
export const DATABASE_PAGE_ROWS = 100;
|
|
192
|
+
const accessLevel = z.enum(['anyone', 'signedIn', 'owner', 'admin', 'server']);
|
|
193
|
+
export const databaseTable = z.object({
|
|
194
|
+
name: z.string(),
|
|
195
|
+
schema: z.record(z.string(), z.unknown()),
|
|
196
|
+
access: z.object({
|
|
197
|
+
read: accessLevel,
|
|
198
|
+
create: accessLevel,
|
|
199
|
+
update: accessLevel,
|
|
200
|
+
delete: accessLevel
|
|
201
|
+
}),
|
|
202
|
+
public: z.array(z.string()),
|
|
203
|
+
rowCount: z.number(),
|
|
204
|
+
isBuiltIn: z.boolean()
|
|
205
|
+
});
|
|
206
|
+
export const appSchema = z.object({ tables: z.array(databaseTable) });
|
|
207
|
+
export const databaseSchema = z.discriminatedUnion('status', [
|
|
208
|
+
z.object({ status: z.literal('ready'), tables: z.array(databaseTable) }),
|
|
209
|
+
z.object({ status: z.literal('outdated') })
|
|
210
|
+
]);
|
|
211
|
+
export const databaseRow = z.record(z.string(), z.unknown());
|
|
212
|
+
export const databaseRows = z.object({
|
|
213
|
+
rows: z.array(databaseRow),
|
|
214
|
+
next: z.string().nullable()
|
|
215
|
+
});
|
|
142
216
|
export const publishServices = defineServices({
|
|
143
217
|
apps: {
|
|
144
218
|
list: call({ get: '/apps', reply: z.array(appSummary) }),
|
|
@@ -182,6 +256,39 @@ export const publishServices = defineServices({
|
|
|
182
256
|
reply: z.object({ ok: z.boolean() })
|
|
183
257
|
})
|
|
184
258
|
},
|
|
259
|
+
domains: {
|
|
260
|
+
search: call({
|
|
261
|
+
get: '/domains',
|
|
262
|
+
input: { query: z.string() },
|
|
263
|
+
reply: z.array(domainChoice)
|
|
264
|
+
}),
|
|
265
|
+
read: call({ get: '/apps/:name/domain', reply: domainSummary.nullable() }),
|
|
266
|
+
buy: call({
|
|
267
|
+
post: '/apps/:name/domain',
|
|
268
|
+
input: { domain: domainName, priceUsd: z.string() },
|
|
269
|
+
reply: domainSummary
|
|
270
|
+
}),
|
|
271
|
+
retry: call({ post: '/apps/:name/domain/retry', reply: domainSummary })
|
|
272
|
+
},
|
|
273
|
+
mailboxes: {
|
|
274
|
+
read: call({
|
|
275
|
+
get: '/apps/:name/mailbox',
|
|
276
|
+
reply: mailboxSummary.nullable()
|
|
277
|
+
}),
|
|
278
|
+
create: call({
|
|
279
|
+
post: '/apps/:name/mailbox',
|
|
280
|
+
input: { localPart: mailboxLocalPart, destination: z.email() },
|
|
281
|
+
reply: mailboxSummary
|
|
282
|
+
})
|
|
283
|
+
},
|
|
284
|
+
database: {
|
|
285
|
+
schema: call({ get: '/apps/:name/database', reply: databaseSchema }),
|
|
286
|
+
rows: call({
|
|
287
|
+
get: '/apps/:name/database/:table',
|
|
288
|
+
input: { after: z.string().optional() },
|
|
289
|
+
reply: databaseRows
|
|
290
|
+
})
|
|
291
|
+
},
|
|
185
292
|
logins: {
|
|
186
293
|
read: call({ get: '/cli/logins/:approval', reply: loginToApprove }),
|
|
187
294
|
approve: call({
|
|
@@ -172,8 +172,90 @@ export declare function createServer<Group extends Tables, Bindings extends Serv
|
|
|
172
172
|
};
|
|
173
173
|
};
|
|
174
174
|
}) | import("hono/types").MergeSchemaPath<{
|
|
175
|
+
"/schema": {
|
|
176
|
+
$get: {
|
|
177
|
+
input: {};
|
|
178
|
+
output: {
|
|
179
|
+
error: string;
|
|
180
|
+
};
|
|
181
|
+
outputFormat: "json";
|
|
182
|
+
status: 401;
|
|
183
|
+
} | {
|
|
184
|
+
input: {};
|
|
185
|
+
output: {
|
|
186
|
+
error: string;
|
|
187
|
+
};
|
|
188
|
+
outputFormat: "json";
|
|
189
|
+
status: 403;
|
|
190
|
+
} | {
|
|
191
|
+
input: {};
|
|
192
|
+
output: {
|
|
193
|
+
tables: {
|
|
194
|
+
name: string;
|
|
195
|
+
schema: {
|
|
196
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
197
|
+
};
|
|
198
|
+
access: {
|
|
199
|
+
read: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
200
|
+
create: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
201
|
+
update: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
202
|
+
delete: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
203
|
+
};
|
|
204
|
+
public: string[];
|
|
205
|
+
rowCount: number;
|
|
206
|
+
isBuiltIn: boolean;
|
|
207
|
+
}[];
|
|
208
|
+
};
|
|
209
|
+
outputFormat: "json";
|
|
210
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
} & {
|
|
214
|
+
"/tables/users": {
|
|
215
|
+
$get: {
|
|
216
|
+
input: {};
|
|
217
|
+
output: {
|
|
218
|
+
error: string;
|
|
219
|
+
};
|
|
220
|
+
outputFormat: "json";
|
|
221
|
+
status: 401;
|
|
222
|
+
} | {
|
|
223
|
+
input: {};
|
|
224
|
+
output: {
|
|
225
|
+
error: string;
|
|
226
|
+
};
|
|
227
|
+
outputFormat: "json";
|
|
228
|
+
status: 403;
|
|
229
|
+
} | {
|
|
230
|
+
input: {};
|
|
231
|
+
output: readonly {
|
|
232
|
+
readonly [x: string]: import("hono/utils/types").JSONValue;
|
|
233
|
+
}[];
|
|
234
|
+
outputFormat: "json";
|
|
235
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
236
|
+
} | {
|
|
237
|
+
input: {};
|
|
238
|
+
output: {
|
|
239
|
+
error: string;
|
|
240
|
+
};
|
|
241
|
+
outputFormat: "json";
|
|
242
|
+
status: 400;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}, "/api"> | import("hono/types").MergeSchemaPath<{
|
|
175
246
|
"/:table": {
|
|
176
247
|
$get: {
|
|
248
|
+
input: {
|
|
249
|
+
param: {
|
|
250
|
+
table: string;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
output: readonly {
|
|
254
|
+
readonly [x: string]: import("hono/utils/types").JSONValue;
|
|
255
|
+
}[];
|
|
256
|
+
outputFormat: "json";
|
|
257
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
258
|
+
} | {
|
|
177
259
|
input: {
|
|
178
260
|
param: {
|
|
179
261
|
table: string;
|
|
@@ -190,9 +272,11 @@ export declare function createServer<Group extends Tables, Bindings extends Serv
|
|
|
190
272
|
table: string;
|
|
191
273
|
};
|
|
192
274
|
};
|
|
193
|
-
output: {
|
|
275
|
+
output: {
|
|
276
|
+
error: string;
|
|
277
|
+
};
|
|
194
278
|
outputFormat: "json";
|
|
195
|
-
status:
|
|
279
|
+
status: 404;
|
|
196
280
|
} | {
|
|
197
281
|
input: {
|
|
198
282
|
param: {
|
|
@@ -203,7 +287,7 @@ export declare function createServer<Group extends Tables, Bindings extends Serv
|
|
|
203
287
|
error: string;
|
|
204
288
|
};
|
|
205
289
|
outputFormat: "json";
|
|
206
|
-
status:
|
|
290
|
+
status: 400;
|
|
207
291
|
};
|
|
208
292
|
};
|
|
209
293
|
} & {
|
|
@@ -3,6 +3,8 @@ import { csrf } from 'hono/csrf';
|
|
|
3
3
|
import { adminEmails } from "../access.js";
|
|
4
4
|
import { appTitle } from "../appTitle.js";
|
|
5
5
|
import { auth, devSignIn } from "./auth.js";
|
|
6
|
+
import { serveDatabase } from "./database.js";
|
|
7
|
+
import { attachPatternViewer, bearerOf } from "./patternViewer.js";
|
|
6
8
|
import { forgetSession, issuePass, needsRecheck, readPass, rememberUser } from "./session.js";
|
|
7
9
|
import { renewSession } from "./sessions.js";
|
|
8
10
|
import { readTitle, writeTitle } from "./settings.js";
|
|
@@ -19,6 +21,9 @@ function knowAdmins(admins) {
|
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
async function attachViewer(c, next) {
|
|
24
|
+
const bearer = bearerOf(c);
|
|
25
|
+
if (bearer !== undefined)
|
|
26
|
+
return attachPatternViewer(c, next, bearer);
|
|
22
27
|
if (PUBLIC_PATHS.some((path) => c.req.path.startsWith(path)))
|
|
23
28
|
return next();
|
|
24
29
|
const isOptional = c.req.path === APP_PATH ||
|
|
@@ -76,6 +81,7 @@ export function createServer({ tables, admins, routes }) {
|
|
|
76
81
|
rememberUser(c, user);
|
|
77
82
|
return c.json({ ...user, isAdmin: viewer?.isAdmin ?? false }, 200);
|
|
78
83
|
})
|
|
84
|
+
.route('/', serveDatabase(tables))
|
|
79
85
|
.route('/tables', serveTables(tables));
|
|
80
86
|
const own = routes;
|
|
81
87
|
return (own === undefined ? server : server.route('/', own)).notFound((c) => c.json({ error: `No route for ${c.req.path}` }, 404));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Tables } from '../table.ts';
|
|
2
|
+
import type { ServerEnv } from './env.ts';
|
|
3
|
+
export declare function serveDatabase<Group extends Tables>(tables: Group): import("hono/hono-base").HonoBase<ServerEnv, {
|
|
4
|
+
"/schema": {
|
|
5
|
+
$get: {
|
|
6
|
+
input: {};
|
|
7
|
+
output: {
|
|
8
|
+
error: string;
|
|
9
|
+
};
|
|
10
|
+
outputFormat: "json";
|
|
11
|
+
status: 401;
|
|
12
|
+
} | {
|
|
13
|
+
input: {};
|
|
14
|
+
output: {
|
|
15
|
+
error: string;
|
|
16
|
+
};
|
|
17
|
+
outputFormat: "json";
|
|
18
|
+
status: 403;
|
|
19
|
+
} | {
|
|
20
|
+
input: {};
|
|
21
|
+
output: {
|
|
22
|
+
tables: {
|
|
23
|
+
name: string;
|
|
24
|
+
schema: {
|
|
25
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
26
|
+
};
|
|
27
|
+
access: {
|
|
28
|
+
read: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
29
|
+
create: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
30
|
+
update: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
31
|
+
delete: "anyone" | "signedIn" | "owner" | "admin" | "server";
|
|
32
|
+
};
|
|
33
|
+
public: string[];
|
|
34
|
+
rowCount: number;
|
|
35
|
+
isBuiltIn: boolean;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
outputFormat: "json";
|
|
39
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
} & {
|
|
43
|
+
"/tables/users": {
|
|
44
|
+
$get: {
|
|
45
|
+
input: {};
|
|
46
|
+
output: {
|
|
47
|
+
error: string;
|
|
48
|
+
};
|
|
49
|
+
outputFormat: "json";
|
|
50
|
+
status: 401;
|
|
51
|
+
} | {
|
|
52
|
+
input: {};
|
|
53
|
+
output: {
|
|
54
|
+
error: string;
|
|
55
|
+
};
|
|
56
|
+
outputFormat: "json";
|
|
57
|
+
status: 403;
|
|
58
|
+
} | {
|
|
59
|
+
input: {};
|
|
60
|
+
output: readonly {
|
|
61
|
+
readonly [x: string]: import("hono/utils/types").JSONValue;
|
|
62
|
+
}[];
|
|
63
|
+
outputFormat: "json";
|
|
64
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
65
|
+
} | {
|
|
66
|
+
input: {};
|
|
67
|
+
output: {
|
|
68
|
+
error: string;
|
|
69
|
+
};
|
|
70
|
+
outputFormat: "json";
|
|
71
|
+
status: 400;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}, "/", "/tables/users">;
|