@trypattern/sdk 0.1.21 → 0.1.23
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 +83 -1
- package/dist/cli/data.d.ts +5 -0
- package/dist/cli/data.js +273 -0
- package/dist/cli/publishing.d.ts +9 -2
- package/dist/cli/publishing.js +7 -7
- package/dist/cli/updates.d.ts +4 -0
- package/dist/cli/updates.js +68 -0
- package/dist/components/Badge.d.ts +1 -1
- package/dist/components/Badge.js +18 -0
- package/dist/components/ButtonBody.d.ts +1 -1
- package/dist/components/ButtonBody.js +43 -0
- package/dist/patternAccess.d.ts +2 -0
- package/dist/patternAccess.js +2 -1
- package/dist/publishWire.d.ts +355 -1
- package/dist/publishWire.js +66 -1
- package/dist/server/changes.d.ts +18 -0
- package/dist/server/changes.js +113 -0
- package/dist/server/createServer.d.ts +38 -0
- package/dist/server/database.d.ts +38 -0
- package/dist/server/database.js +2 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/patternViewer.js +4 -1
- package/dist/server/session.d.ts +1 -0
- package/dist/server/session.js +3 -0
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ export function ButtonBody({ children, variant = 'primary', tone = variant === '
|
|
|
27
27
|
const toneKeys = {
|
|
28
28
|
neutral: 'Neutral',
|
|
29
29
|
brand: 'Brand',
|
|
30
|
+
positive: 'Positive',
|
|
30
31
|
danger: 'Danger'
|
|
31
32
|
};
|
|
32
33
|
const styles = stylex.create({
|
|
@@ -130,6 +131,10 @@ const looks = stylex.create({
|
|
|
130
131
|
color: colors.onBrandSolidForeground,
|
|
131
132
|
backgroundColor: colors.brandSolid
|
|
132
133
|
},
|
|
134
|
+
primaryPositive: {
|
|
135
|
+
color: colors.onPositiveSolidForeground,
|
|
136
|
+
backgroundColor: colors.positiveSolid
|
|
137
|
+
},
|
|
133
138
|
primaryDanger: {
|
|
134
139
|
color: colors.onDangerSolidForeground,
|
|
135
140
|
backgroundColor: colors.dangerSolid
|
|
@@ -144,6 +149,11 @@ const looks = stylex.create({
|
|
|
144
149
|
backgroundColor: colors.componentOnContainerStrong,
|
|
145
150
|
boxShadow: shadows.default
|
|
146
151
|
},
|
|
152
|
+
secondaryPositive: {
|
|
153
|
+
color: colors.positiveForeground,
|
|
154
|
+
backgroundColor: colors.componentOnContainerStrong,
|
|
155
|
+
boxShadow: shadows.default
|
|
156
|
+
},
|
|
147
157
|
secondaryDanger: {
|
|
148
158
|
color: colors.dangerForeground,
|
|
149
159
|
backgroundColor: colors.componentOnContainerStrong,
|
|
@@ -157,6 +167,10 @@ const looks = stylex.create({
|
|
|
157
167
|
color: colors.onBrandSubtleForeground,
|
|
158
168
|
backgroundColor: colors.brandSubtle
|
|
159
169
|
},
|
|
170
|
+
tertiaryPositive: {
|
|
171
|
+
color: colors.onPositiveSubtleForeground,
|
|
172
|
+
backgroundColor: colors.positiveSubtle
|
|
173
|
+
},
|
|
160
174
|
tertiaryDanger: {
|
|
161
175
|
color: colors.dangerForeground,
|
|
162
176
|
backgroundColor: colors.dangerSubtle
|
|
@@ -169,6 +183,10 @@ const looks = stylex.create({
|
|
|
169
183
|
color: colors.brandForeground,
|
|
170
184
|
backgroundColor: 'transparent'
|
|
171
185
|
},
|
|
186
|
+
transparentPositive: {
|
|
187
|
+
color: colors.positiveForeground,
|
|
188
|
+
backgroundColor: 'transparent'
|
|
189
|
+
},
|
|
172
190
|
transparentDanger: {
|
|
173
191
|
color: colors.dangerForeground,
|
|
174
192
|
backgroundColor: 'transparent'
|
|
@@ -189,6 +207,13 @@ const hovers = stylex.create({
|
|
|
189
207
|
':active': colors.brandSolidActive
|
|
190
208
|
}
|
|
191
209
|
},
|
|
210
|
+
primaryPositive: {
|
|
211
|
+
backgroundColor: {
|
|
212
|
+
default: colors.positiveSolid,
|
|
213
|
+
':hover': colors.positiveSolidHover,
|
|
214
|
+
':active': colors.positiveSolidHover
|
|
215
|
+
}
|
|
216
|
+
},
|
|
192
217
|
primaryDanger: {
|
|
193
218
|
backgroundColor: {
|
|
194
219
|
default: colors.dangerSolid,
|
|
@@ -208,6 +233,12 @@ const hovers = stylex.create({
|
|
|
208
233
|
':hover': colors.componentOnContainerStrongHover
|
|
209
234
|
}
|
|
210
235
|
},
|
|
236
|
+
secondaryPositive: {
|
|
237
|
+
backgroundColor: {
|
|
238
|
+
default: colors.componentOnContainerStrong,
|
|
239
|
+
':hover': colors.componentOnContainerStrongHover
|
|
240
|
+
}
|
|
241
|
+
},
|
|
211
242
|
secondaryDanger: {
|
|
212
243
|
backgroundColor: {
|
|
213
244
|
default: colors.componentOnContainerStrong,
|
|
@@ -227,6 +258,12 @@ const hovers = stylex.create({
|
|
|
227
258
|
':hover': colors.brandSubtleHover
|
|
228
259
|
}
|
|
229
260
|
},
|
|
261
|
+
tertiaryPositive: {
|
|
262
|
+
backgroundColor: {
|
|
263
|
+
default: colors.positiveSubtle,
|
|
264
|
+
':hover': colors.positiveSubtleHover
|
|
265
|
+
}
|
|
266
|
+
},
|
|
230
267
|
tertiaryDanger: {
|
|
231
268
|
backgroundColor: {
|
|
232
269
|
default: colors.dangerSubtle,
|
|
@@ -250,6 +287,12 @@ const hovers = stylex.create({
|
|
|
250
287
|
':hover': colors.transparentHover
|
|
251
288
|
}
|
|
252
289
|
},
|
|
290
|
+
transparentPositive: {
|
|
291
|
+
backgroundColor: {
|
|
292
|
+
default: 'transparent',
|
|
293
|
+
':hover': colors.positiveSubtleHover
|
|
294
|
+
}
|
|
295
|
+
},
|
|
253
296
|
transparentDanger: {
|
|
254
297
|
backgroundColor: {
|
|
255
298
|
default: 'transparent',
|
package/dist/patternAccess.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const TABLES_READ = "tables:read";
|
|
3
3
|
export declare const MEDIA_WRITE = "media:write";
|
|
4
|
+
export declare const TABLES_WRITE = "tables:write";
|
|
4
5
|
export declare const ASSERTION_SECONDS = 60;
|
|
5
6
|
export declare const NEXT_PAGE_HEADER = "x-pattern-next";
|
|
6
7
|
export declare const assertionKey: z.ZodObject<{
|
|
@@ -14,6 +15,7 @@ export type AssertionKey = z.output<typeof assertionKey>;
|
|
|
14
15
|
declare const assertionScope: z.ZodEnum<{
|
|
15
16
|
"tables:read": "tables:read";
|
|
16
17
|
"media:write": "media:write";
|
|
18
|
+
"tables:write": "tables:write";
|
|
17
19
|
}>;
|
|
18
20
|
export type AssertionScope = z.output<typeof assertionScope>;
|
|
19
21
|
export declare function signAssertion(key: AssertionKey, { sub, aud, scope }: {
|
package/dist/patternAccess.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export const TABLES_READ = 'tables:read';
|
|
3
3
|
export const MEDIA_WRITE = 'media:write';
|
|
4
|
+
export const TABLES_WRITE = 'tables:write';
|
|
4
5
|
export const ASSERTION_SECONDS = 60;
|
|
5
6
|
export const NEXT_PAGE_HEADER = 'x-pattern-next';
|
|
6
7
|
const CLOCK_SKEW_SECONDS = 30;
|
|
@@ -12,7 +13,7 @@ export const assertionKey = z.object({
|
|
|
12
13
|
x: z.string(),
|
|
13
14
|
d: z.string()
|
|
14
15
|
});
|
|
15
|
-
const assertionScope = z.enum([TABLES_READ, MEDIA_WRITE]);
|
|
16
|
+
const assertionScope = z.enum([TABLES_READ, TABLES_WRITE, MEDIA_WRITE]);
|
|
16
17
|
const assertionHeader = z.object({
|
|
17
18
|
alg: z.literal('EdDSA'),
|
|
18
19
|
typ: z.literal('JWT'),
|
package/dist/publishWire.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { appTitle } from './appTitle.ts';
|
|
3
3
|
export { appTitle };
|
|
4
|
-
export { ASSERTION_SECONDS, MEDIA_WRITE, NEXT_PAGE_HEADER, TABLES_READ, assertionKey, signAssertion } from './patternAccess.ts';
|
|
4
|
+
export { ASSERTION_SECONDS, MEDIA_WRITE, NEXT_PAGE_HEADER, TABLES_READ, TABLES_WRITE, assertionKey, signAssertion } from './patternAccess.ts';
|
|
5
5
|
export type { AssertionKey, AssertionScope } from './patternAccess.ts';
|
|
6
6
|
export declare const DASHBOARD_URL = "https://onpattern.app";
|
|
7
7
|
export declare const APPS_DOMAIN = "onpattern.app";
|
|
@@ -320,6 +320,94 @@ export declare const databaseRows: z.ZodObject<{
|
|
|
320
320
|
next: z.ZodNullable<z.ZodString>;
|
|
321
321
|
}, z.core.$strip>;
|
|
322
322
|
export type DatabaseRows = z.output<typeof databaseRows>;
|
|
323
|
+
export declare const CHANGE_SET_ROWS = 300;
|
|
324
|
+
export declare const dataChange: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
325
|
+
op: z.ZodLiteral<"add">;
|
|
326
|
+
table: z.ZodString;
|
|
327
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
328
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
329
|
+
op: z.ZodLiteral<"update">;
|
|
330
|
+
table: z.ZodString;
|
|
331
|
+
id: z.ZodString;
|
|
332
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
333
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
334
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
335
|
+
op: z.ZodLiteral<"remove">;
|
|
336
|
+
table: z.ZodString;
|
|
337
|
+
id: z.ZodString;
|
|
338
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
339
|
+
}, z.core.$strip>], "op">;
|
|
340
|
+
export type DataChange = z.output<typeof dataChange>;
|
|
341
|
+
export declare const changeOutcome: z.ZodObject<{
|
|
342
|
+
status: z.ZodEnum<{
|
|
343
|
+
failed: "failed";
|
|
344
|
+
applied: "applied";
|
|
345
|
+
skipped: "skipped";
|
|
346
|
+
}>;
|
|
347
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
348
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
349
|
+
}, z.core.$strip>;
|
|
350
|
+
export type ChangeOutcome = z.output<typeof changeOutcome>;
|
|
351
|
+
export declare const changeReply: z.ZodObject<{
|
|
352
|
+
outcomes: z.ZodArray<z.ZodObject<{
|
|
353
|
+
status: z.ZodEnum<{
|
|
354
|
+
failed: "failed";
|
|
355
|
+
applied: "applied";
|
|
356
|
+
skipped: "skipped";
|
|
357
|
+
}>;
|
|
358
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
359
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
360
|
+
}, z.core.$strip>>;
|
|
361
|
+
}, z.core.$strip>;
|
|
362
|
+
export declare const changeSetStatus: z.ZodEnum<{
|
|
363
|
+
declined: "declined";
|
|
364
|
+
waiting: "waiting";
|
|
365
|
+
applied: "applied";
|
|
366
|
+
expired: "expired";
|
|
367
|
+
undone: "undone";
|
|
368
|
+
}>;
|
|
369
|
+
export declare const changeSet: z.ZodObject<{
|
|
370
|
+
id: z.ZodString;
|
|
371
|
+
status: z.ZodEnum<{
|
|
372
|
+
declined: "declined";
|
|
373
|
+
waiting: "waiting";
|
|
374
|
+
applied: "applied";
|
|
375
|
+
expired: "expired";
|
|
376
|
+
undone: "undone";
|
|
377
|
+
}>;
|
|
378
|
+
title: z.ZodString;
|
|
379
|
+
asked: z.ZodString;
|
|
380
|
+
device: z.ZodString;
|
|
381
|
+
createdAt: z.ZodString;
|
|
382
|
+
decidedAt: z.ZodNullable<z.ZodString>;
|
|
383
|
+
undoneAt: z.ZodNullable<z.ZodString>;
|
|
384
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
385
|
+
op: z.ZodLiteral<"add">;
|
|
386
|
+
table: z.ZodString;
|
|
387
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
388
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
389
|
+
op: z.ZodLiteral<"update">;
|
|
390
|
+
table: z.ZodString;
|
|
391
|
+
id: z.ZodString;
|
|
392
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
393
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
394
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
395
|
+
op: z.ZodLiteral<"remove">;
|
|
396
|
+
table: z.ZodString;
|
|
397
|
+
id: z.ZodString;
|
|
398
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
399
|
+
}, z.core.$strip>], "op">>;
|
|
400
|
+
outcomes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
401
|
+
status: z.ZodEnum<{
|
|
402
|
+
failed: "failed";
|
|
403
|
+
applied: "applied";
|
|
404
|
+
skipped: "skipped";
|
|
405
|
+
}>;
|
|
406
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
407
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
408
|
+
}, z.core.$strip>>>;
|
|
409
|
+
}, z.core.$strip>;
|
|
410
|
+
export type ChangeSet = z.output<typeof changeSet>;
|
|
323
411
|
export declare const publishServices: {
|
|
324
412
|
readonly apps: {
|
|
325
413
|
readonly list: NoInfer<import("./services.ts").ServiceCall<"/apps", {}, z.ZodArray<z.ZodObject<{
|
|
@@ -647,6 +735,272 @@ export declare const publishServices: {
|
|
|
647
735
|
next: z.ZodNullable<z.ZodString>;
|
|
648
736
|
}, z.core.$strip>>>;
|
|
649
737
|
};
|
|
738
|
+
readonly changes: {
|
|
739
|
+
readonly list: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/changes", {}, z.ZodArray<z.ZodObject<{
|
|
740
|
+
id: z.ZodString;
|
|
741
|
+
status: z.ZodEnum<{
|
|
742
|
+
declined: "declined";
|
|
743
|
+
waiting: "waiting";
|
|
744
|
+
applied: "applied";
|
|
745
|
+
expired: "expired";
|
|
746
|
+
undone: "undone";
|
|
747
|
+
}>;
|
|
748
|
+
title: z.ZodString;
|
|
749
|
+
asked: z.ZodString;
|
|
750
|
+
device: z.ZodString;
|
|
751
|
+
createdAt: z.ZodString;
|
|
752
|
+
decidedAt: z.ZodNullable<z.ZodString>;
|
|
753
|
+
undoneAt: z.ZodNullable<z.ZodString>;
|
|
754
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
755
|
+
op: z.ZodLiteral<"add">;
|
|
756
|
+
table: z.ZodString;
|
|
757
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
758
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
759
|
+
op: z.ZodLiteral<"update">;
|
|
760
|
+
table: z.ZodString;
|
|
761
|
+
id: z.ZodString;
|
|
762
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
763
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
764
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
765
|
+
op: z.ZodLiteral<"remove">;
|
|
766
|
+
table: z.ZodString;
|
|
767
|
+
id: z.ZodString;
|
|
768
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
769
|
+
}, z.core.$strip>], "op">>;
|
|
770
|
+
outcomes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
771
|
+
status: z.ZodEnum<{
|
|
772
|
+
failed: "failed";
|
|
773
|
+
applied: "applied";
|
|
774
|
+
skipped: "skipped";
|
|
775
|
+
}>;
|
|
776
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
777
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
778
|
+
}, z.core.$strip>>>;
|
|
779
|
+
}, z.core.$strip>>>>;
|
|
780
|
+
readonly read: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/changes/:id", {}, z.ZodObject<{
|
|
781
|
+
id: z.ZodString;
|
|
782
|
+
status: z.ZodEnum<{
|
|
783
|
+
declined: "declined";
|
|
784
|
+
waiting: "waiting";
|
|
785
|
+
applied: "applied";
|
|
786
|
+
expired: "expired";
|
|
787
|
+
undone: "undone";
|
|
788
|
+
}>;
|
|
789
|
+
title: z.ZodString;
|
|
790
|
+
asked: z.ZodString;
|
|
791
|
+
device: z.ZodString;
|
|
792
|
+
createdAt: z.ZodString;
|
|
793
|
+
decidedAt: z.ZodNullable<z.ZodString>;
|
|
794
|
+
undoneAt: z.ZodNullable<z.ZodString>;
|
|
795
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
796
|
+
op: z.ZodLiteral<"add">;
|
|
797
|
+
table: z.ZodString;
|
|
798
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
799
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
800
|
+
op: z.ZodLiteral<"update">;
|
|
801
|
+
table: z.ZodString;
|
|
802
|
+
id: z.ZodString;
|
|
803
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
804
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
805
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
806
|
+
op: z.ZodLiteral<"remove">;
|
|
807
|
+
table: z.ZodString;
|
|
808
|
+
id: z.ZodString;
|
|
809
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
810
|
+
}, z.core.$strip>], "op">>;
|
|
811
|
+
outcomes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
812
|
+
status: z.ZodEnum<{
|
|
813
|
+
failed: "failed";
|
|
814
|
+
applied: "applied";
|
|
815
|
+
skipped: "skipped";
|
|
816
|
+
}>;
|
|
817
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
818
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
819
|
+
}, z.core.$strip>>>;
|
|
820
|
+
}, z.core.$strip>>>;
|
|
821
|
+
readonly create: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/changes", {
|
|
822
|
+
asked: z.ZodString;
|
|
823
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
824
|
+
op: z.ZodLiteral<"add">;
|
|
825
|
+
table: z.ZodString;
|
|
826
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
827
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
828
|
+
op: z.ZodLiteral<"update">;
|
|
829
|
+
table: z.ZodString;
|
|
830
|
+
id: z.ZodString;
|
|
831
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
832
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
833
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
834
|
+
op: z.ZodLiteral<"remove">;
|
|
835
|
+
table: z.ZodString;
|
|
836
|
+
id: z.ZodString;
|
|
837
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
838
|
+
}, z.core.$strip>], "op">>;
|
|
839
|
+
}, z.ZodObject<{
|
|
840
|
+
id: z.ZodString;
|
|
841
|
+
status: z.ZodEnum<{
|
|
842
|
+
declined: "declined";
|
|
843
|
+
waiting: "waiting";
|
|
844
|
+
applied: "applied";
|
|
845
|
+
expired: "expired";
|
|
846
|
+
undone: "undone";
|
|
847
|
+
}>;
|
|
848
|
+
title: z.ZodString;
|
|
849
|
+
asked: z.ZodString;
|
|
850
|
+
device: z.ZodString;
|
|
851
|
+
createdAt: z.ZodString;
|
|
852
|
+
decidedAt: z.ZodNullable<z.ZodString>;
|
|
853
|
+
undoneAt: z.ZodNullable<z.ZodString>;
|
|
854
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
855
|
+
op: z.ZodLiteral<"add">;
|
|
856
|
+
table: z.ZodString;
|
|
857
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
858
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
859
|
+
op: z.ZodLiteral<"update">;
|
|
860
|
+
table: z.ZodString;
|
|
861
|
+
id: z.ZodString;
|
|
862
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
863
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
864
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
865
|
+
op: z.ZodLiteral<"remove">;
|
|
866
|
+
table: z.ZodString;
|
|
867
|
+
id: z.ZodString;
|
|
868
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
869
|
+
}, z.core.$strip>], "op">>;
|
|
870
|
+
outcomes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
871
|
+
status: z.ZodEnum<{
|
|
872
|
+
failed: "failed";
|
|
873
|
+
applied: "applied";
|
|
874
|
+
skipped: "skipped";
|
|
875
|
+
}>;
|
|
876
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
877
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
878
|
+
}, z.core.$strip>>>;
|
|
879
|
+
}, z.core.$strip>>>;
|
|
880
|
+
readonly approve: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/changes/:id/approve", {}, z.ZodObject<{
|
|
881
|
+
id: z.ZodString;
|
|
882
|
+
status: z.ZodEnum<{
|
|
883
|
+
declined: "declined";
|
|
884
|
+
waiting: "waiting";
|
|
885
|
+
applied: "applied";
|
|
886
|
+
expired: "expired";
|
|
887
|
+
undone: "undone";
|
|
888
|
+
}>;
|
|
889
|
+
title: z.ZodString;
|
|
890
|
+
asked: z.ZodString;
|
|
891
|
+
device: z.ZodString;
|
|
892
|
+
createdAt: z.ZodString;
|
|
893
|
+
decidedAt: z.ZodNullable<z.ZodString>;
|
|
894
|
+
undoneAt: z.ZodNullable<z.ZodString>;
|
|
895
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
896
|
+
op: z.ZodLiteral<"add">;
|
|
897
|
+
table: z.ZodString;
|
|
898
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
899
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
900
|
+
op: z.ZodLiteral<"update">;
|
|
901
|
+
table: z.ZodString;
|
|
902
|
+
id: z.ZodString;
|
|
903
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
904
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
905
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
906
|
+
op: z.ZodLiteral<"remove">;
|
|
907
|
+
table: z.ZodString;
|
|
908
|
+
id: z.ZodString;
|
|
909
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
910
|
+
}, z.core.$strip>], "op">>;
|
|
911
|
+
outcomes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
912
|
+
status: z.ZodEnum<{
|
|
913
|
+
failed: "failed";
|
|
914
|
+
applied: "applied";
|
|
915
|
+
skipped: "skipped";
|
|
916
|
+
}>;
|
|
917
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
918
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
919
|
+
}, z.core.$strip>>>;
|
|
920
|
+
}, z.core.$strip>>>;
|
|
921
|
+
readonly decline: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/changes/:id/decline", {}, z.ZodObject<{
|
|
922
|
+
id: z.ZodString;
|
|
923
|
+
status: z.ZodEnum<{
|
|
924
|
+
declined: "declined";
|
|
925
|
+
waiting: "waiting";
|
|
926
|
+
applied: "applied";
|
|
927
|
+
expired: "expired";
|
|
928
|
+
undone: "undone";
|
|
929
|
+
}>;
|
|
930
|
+
title: z.ZodString;
|
|
931
|
+
asked: z.ZodString;
|
|
932
|
+
device: z.ZodString;
|
|
933
|
+
createdAt: z.ZodString;
|
|
934
|
+
decidedAt: z.ZodNullable<z.ZodString>;
|
|
935
|
+
undoneAt: z.ZodNullable<z.ZodString>;
|
|
936
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
937
|
+
op: z.ZodLiteral<"add">;
|
|
938
|
+
table: z.ZodString;
|
|
939
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
940
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
941
|
+
op: z.ZodLiteral<"update">;
|
|
942
|
+
table: z.ZodString;
|
|
943
|
+
id: z.ZodString;
|
|
944
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
945
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
946
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
947
|
+
op: z.ZodLiteral<"remove">;
|
|
948
|
+
table: z.ZodString;
|
|
949
|
+
id: z.ZodString;
|
|
950
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
951
|
+
}, z.core.$strip>], "op">>;
|
|
952
|
+
outcomes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
953
|
+
status: z.ZodEnum<{
|
|
954
|
+
failed: "failed";
|
|
955
|
+
applied: "applied";
|
|
956
|
+
skipped: "skipped";
|
|
957
|
+
}>;
|
|
958
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
959
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
960
|
+
}, z.core.$strip>>>;
|
|
961
|
+
}, z.core.$strip>>>;
|
|
962
|
+
readonly undo: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/changes/:id/undo", {}, z.ZodObject<{
|
|
963
|
+
id: z.ZodString;
|
|
964
|
+
status: z.ZodEnum<{
|
|
965
|
+
declined: "declined";
|
|
966
|
+
waiting: "waiting";
|
|
967
|
+
applied: "applied";
|
|
968
|
+
expired: "expired";
|
|
969
|
+
undone: "undone";
|
|
970
|
+
}>;
|
|
971
|
+
title: z.ZodString;
|
|
972
|
+
asked: z.ZodString;
|
|
973
|
+
device: z.ZodString;
|
|
974
|
+
createdAt: z.ZodString;
|
|
975
|
+
decidedAt: z.ZodNullable<z.ZodString>;
|
|
976
|
+
undoneAt: z.ZodNullable<z.ZodString>;
|
|
977
|
+
changes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
978
|
+
op: z.ZodLiteral<"add">;
|
|
979
|
+
table: z.ZodString;
|
|
980
|
+
row: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
981
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
982
|
+
op: z.ZodLiteral<"update">;
|
|
983
|
+
table: z.ZodString;
|
|
984
|
+
id: z.ZodString;
|
|
985
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
986
|
+
after: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
987
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
988
|
+
op: z.ZodLiteral<"remove">;
|
|
989
|
+
table: z.ZodString;
|
|
990
|
+
id: z.ZodString;
|
|
991
|
+
before: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
992
|
+
}, z.core.$strip>], "op">>;
|
|
993
|
+
outcomes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
994
|
+
status: z.ZodEnum<{
|
|
995
|
+
failed: "failed";
|
|
996
|
+
applied: "applied";
|
|
997
|
+
skipped: "skipped";
|
|
998
|
+
}>;
|
|
999
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
1000
|
+
row: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1001
|
+
}, z.core.$strip>>>;
|
|
1002
|
+
}, z.core.$strip>>>;
|
|
1003
|
+
};
|
|
650
1004
|
readonly logins: {
|
|
651
1005
|
readonly read: NoInfer<import("./services.ts").ServiceCall<"/cli/logins/:approval", {}, z.ZodObject<{
|
|
652
1006
|
code: z.ZodString;
|
package/dist/publishWire.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { appTitle } from "./appTitle.js";
|
|
3
3
|
export { appTitle };
|
|
4
|
-
export { ASSERTION_SECONDS, MEDIA_WRITE, NEXT_PAGE_HEADER, TABLES_READ, assertionKey, signAssertion } from "./patternAccess.js";
|
|
4
|
+
export { ASSERTION_SECONDS, MEDIA_WRITE, NEXT_PAGE_HEADER, TABLES_READ, TABLES_WRITE, assertionKey, signAssertion } from "./patternAccess.js";
|
|
5
5
|
import { call, defineServices } from "./services.js";
|
|
6
6
|
export const DASHBOARD_URL = 'https://onpattern.app';
|
|
7
7
|
export const APPS_DOMAIN = 'onpattern.app';
|
|
@@ -256,6 +256,50 @@ export const databaseRows = z.object({
|
|
|
256
256
|
rows: z.array(databaseRow),
|
|
257
257
|
next: z.string().nullable()
|
|
258
258
|
});
|
|
259
|
+
export const CHANGE_SET_ROWS = 300;
|
|
260
|
+
const tableName = z.string().regex(/^[a-zA-Z][a-zA-Z0-9]*$/);
|
|
261
|
+
const rowId = z.string().min(1).max(200);
|
|
262
|
+
export const dataChange = z.discriminatedUnion('op', [
|
|
263
|
+
z.object({ op: z.literal('add'), table: tableName, row: databaseRow }),
|
|
264
|
+
z.object({
|
|
265
|
+
op: z.literal('update'),
|
|
266
|
+
table: tableName,
|
|
267
|
+
id: rowId,
|
|
268
|
+
before: databaseRow,
|
|
269
|
+
after: databaseRow
|
|
270
|
+
}),
|
|
271
|
+
z.object({
|
|
272
|
+
op: z.literal('remove'),
|
|
273
|
+
table: tableName,
|
|
274
|
+
id: rowId,
|
|
275
|
+
before: databaseRow
|
|
276
|
+
})
|
|
277
|
+
]);
|
|
278
|
+
export const changeOutcome = z.object({
|
|
279
|
+
status: z.enum(['applied', 'skipped', 'failed']),
|
|
280
|
+
reason: z.string().nullable(),
|
|
281
|
+
row: databaseRow.nullable()
|
|
282
|
+
});
|
|
283
|
+
export const changeReply = z.object({ outcomes: z.array(changeOutcome) });
|
|
284
|
+
export const changeSetStatus = z.enum([
|
|
285
|
+
'waiting',
|
|
286
|
+
'applied',
|
|
287
|
+
'declined',
|
|
288
|
+
'expired',
|
|
289
|
+
'undone'
|
|
290
|
+
]);
|
|
291
|
+
export const changeSet = z.object({
|
|
292
|
+
id: z.string(),
|
|
293
|
+
status: changeSetStatus,
|
|
294
|
+
title: z.string(),
|
|
295
|
+
asked: z.string(),
|
|
296
|
+
device: z.string(),
|
|
297
|
+
createdAt: z.string(),
|
|
298
|
+
decidedAt: z.string().nullable(),
|
|
299
|
+
undoneAt: z.string().nullable(),
|
|
300
|
+
changes: z.array(dataChange),
|
|
301
|
+
outcomes: z.array(changeOutcome).nullable()
|
|
302
|
+
});
|
|
259
303
|
export const publishServices = defineServices({
|
|
260
304
|
apps: {
|
|
261
305
|
list: call({ get: '/apps', reply: z.array(appSummary) }),
|
|
@@ -332,6 +376,27 @@ export const publishServices = defineServices({
|
|
|
332
376
|
reply: databaseRows
|
|
333
377
|
})
|
|
334
378
|
},
|
|
379
|
+
changes: {
|
|
380
|
+
list: call({ get: '/apps/:name/changes', reply: z.array(changeSet) }),
|
|
381
|
+
read: call({ get: '/apps/:name/changes/:id', reply: changeSet }),
|
|
382
|
+
create: call({
|
|
383
|
+
post: '/apps/:name/changes',
|
|
384
|
+
input: {
|
|
385
|
+
asked: z.string().trim().min(1).max(1000),
|
|
386
|
+
changes: z.array(dataChange).min(1).max(CHANGE_SET_ROWS)
|
|
387
|
+
},
|
|
388
|
+
reply: changeSet
|
|
389
|
+
}),
|
|
390
|
+
approve: call({
|
|
391
|
+
post: '/apps/:name/changes/:id/approve',
|
|
392
|
+
reply: changeSet
|
|
393
|
+
}),
|
|
394
|
+
decline: call({
|
|
395
|
+
post: '/apps/:name/changes/:id/decline',
|
|
396
|
+
reply: changeSet
|
|
397
|
+
}),
|
|
398
|
+
undo: call({ post: '/apps/:name/changes/:id/undo', reply: changeSet })
|
|
399
|
+
},
|
|
335
400
|
logins: {
|
|
336
401
|
read: call({ get: '/cli/logins/:approval', reply: loginToApprove }),
|
|
337
402
|
approve: call({
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { Tables } from '../table.ts';
|
|
3
|
+
import type { ServerEnv } from './env.ts';
|
|
4
|
+
export declare function applyChanges<Group extends Tables>(c: Context<ServerEnv>, tables: Group): Promise<(Response & import("hono").TypedResponse<{
|
|
5
|
+
error: string;
|
|
6
|
+
}, 401, "json">) | (Response & import("hono").TypedResponse<{
|
|
7
|
+
error: string;
|
|
8
|
+
}, 403, "json">) | (Response & import("hono").TypedResponse<{
|
|
9
|
+
error: string;
|
|
10
|
+
}, 400, "json">) | (Response & import("hono").TypedResponse<{
|
|
11
|
+
outcomes: {
|
|
12
|
+
status: "failed" | "applied" | "skipped";
|
|
13
|
+
reason: string | null;
|
|
14
|
+
row: {
|
|
15
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
16
|
+
} | null;
|
|
17
|
+
}[];
|
|
18
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|