@protobase/schema 0.9.0 → 0.11.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/access/resolve.d.ts +1 -0
- package/dist/address-errors.d.ts +16 -0
- package/dist/address-errors.js +59 -0
- package/dist/address-template.d.ts +16 -0
- package/dist/address-template.js +38 -0
- package/dist/app-address.d.ts +26 -0
- package/dist/app-address.js +90 -0
- package/dist/bottom-bar-errors.d.ts +14 -0
- package/dist/bottom-bar-errors.js +33 -0
- package/dist/bottom-bar.d.ts +35 -0
- package/dist/bottom-bar.js +44 -0
- package/dist/field-ref.d.ts +19 -0
- package/dist/field-ref.js +29 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +9 -1
- package/dist/layout.d.ts +11 -0
- package/dist/layout.js +14 -0
- package/dist/menu-href.js +5 -0
- package/dist/model.d.ts +94 -3
- package/dist/ref-shape.d.ts +80 -0
- package/dist/ref-shape.js +88 -0
- package/dist/refs.js +5 -1
- package/dist/user-menu.js +2 -1
- package/dist/view-actions.d.ts +10 -4
- package/dist/view-actions.js +24 -8
- package/dist/view-displays.d.ts +42 -0
- package/dist/view-displays.js +61 -0
- package/dist/view.d.ts +10 -3
- package/dist/view.js +22 -8
- package/dist/webhooks/webhook-resources.d.ts +50 -50
- package/dist/webhooks/webhook-resources.js +78 -78
- package/package.json +1 -1
|
@@ -13,28 +13,28 @@ export declare const webhookResources: (schema: string, { deliveryLog }?: {
|
|
|
13
13
|
}) => {
|
|
14
14
|
webhookDeliveryLog?: ResourceBuilder<{
|
|
15
15
|
readonly id: Field<string>;
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
16
|
+
readonly subscription_id: Field<string | number>;
|
|
17
|
+
readonly tenant_id: Field<string | null>;
|
|
18
|
+
readonly event_id: Field<string>;
|
|
19
|
+
readonly event_type: Field<string>;
|
|
20
20
|
readonly status: Field<"failed" | "delivered">;
|
|
21
21
|
readonly attempt: Field<number>;
|
|
22
|
-
readonly
|
|
22
|
+
readonly status_code: Field<number | null>;
|
|
23
23
|
readonly response: Field<string | null>;
|
|
24
|
-
readonly
|
|
24
|
+
readonly duration_ms: Field<number>;
|
|
25
25
|
readonly at: Field<string>;
|
|
26
26
|
}, Ref<"id", string>> | undefined;
|
|
27
27
|
webhookDeliveryLogView?: ViewBuilder<ResourceBuilder<{
|
|
28
28
|
readonly id: Field<string>;
|
|
29
|
-
readonly
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
32
|
-
readonly
|
|
29
|
+
readonly subscription_id: Field<string | number>;
|
|
30
|
+
readonly tenant_id: Field<string | null>;
|
|
31
|
+
readonly event_id: Field<string>;
|
|
32
|
+
readonly event_type: Field<string>;
|
|
33
33
|
readonly status: Field<"failed" | "delivered">;
|
|
34
34
|
readonly attempt: Field<number>;
|
|
35
|
-
readonly
|
|
35
|
+
readonly status_code: Field<number | null>;
|
|
36
36
|
readonly response: Field<string | null>;
|
|
37
|
-
readonly
|
|
37
|
+
readonly duration_ms: Field<number>;
|
|
38
38
|
readonly at: Field<string>;
|
|
39
39
|
}, Ref<"id", string>>> | undefined;
|
|
40
40
|
webhookSubscriptions: ResourceBuilder<{
|
|
@@ -47,18 +47,18 @@ export declare const webhookResources: (schema: string, { deliveryLog }?: {
|
|
|
47
47
|
readonly payload: Field<"full" | "thin">;
|
|
48
48
|
readonly enabled: Field<boolean>;
|
|
49
49
|
readonly secret: Field<string>;
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
54
|
-
readonly
|
|
55
|
-
readonly
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
60
|
-
readonly
|
|
61
|
-
readonly
|
|
50
|
+
readonly previous_secret: null;
|
|
51
|
+
readonly previous_secret_until: null;
|
|
52
|
+
readonly tenant_id: Field<string | null>;
|
|
53
|
+
readonly owner_id: Field<string | null>;
|
|
54
|
+
readonly disabled_reason: Field<string | null>;
|
|
55
|
+
readonly last_success_at: Field<string | null>;
|
|
56
|
+
readonly failing_since: Field<string | null>;
|
|
57
|
+
readonly created_at: Field<string>;
|
|
58
|
+
readonly updated_at: Field<string>;
|
|
59
|
+
readonly rotate_secret: Field<boolean>;
|
|
60
|
+
readonly send_test: Field<boolean>;
|
|
61
|
+
readonly resend_failed: Field<boolean>;
|
|
62
62
|
}, Ref<"id", string>>;
|
|
63
63
|
webhookSubscriptionsView: ViewBuilder<ResourceBuilder<{
|
|
64
64
|
readonly id: Field<string>;
|
|
@@ -70,43 +70,43 @@ export declare const webhookResources: (schema: string, { deliveryLog }?: {
|
|
|
70
70
|
readonly payload: Field<"full" | "thin">;
|
|
71
71
|
readonly enabled: Field<boolean>;
|
|
72
72
|
readonly secret: Field<string>;
|
|
73
|
-
readonly
|
|
74
|
-
readonly
|
|
75
|
-
readonly
|
|
76
|
-
readonly
|
|
77
|
-
readonly
|
|
78
|
-
readonly
|
|
79
|
-
readonly
|
|
80
|
-
readonly
|
|
81
|
-
readonly
|
|
82
|
-
readonly
|
|
83
|
-
readonly
|
|
84
|
-
readonly
|
|
73
|
+
readonly previous_secret: null;
|
|
74
|
+
readonly previous_secret_until: null;
|
|
75
|
+
readonly tenant_id: Field<string | null>;
|
|
76
|
+
readonly owner_id: Field<string | null>;
|
|
77
|
+
readonly disabled_reason: Field<string | null>;
|
|
78
|
+
readonly last_success_at: Field<string | null>;
|
|
79
|
+
readonly failing_since: Field<string | null>;
|
|
80
|
+
readonly created_at: Field<string>;
|
|
81
|
+
readonly updated_at: Field<string>;
|
|
82
|
+
readonly rotate_secret: Field<boolean>;
|
|
83
|
+
readonly send_test: Field<boolean>;
|
|
84
|
+
readonly resend_failed: Field<boolean>;
|
|
85
85
|
}, Ref<"id", string>>>;
|
|
86
86
|
webhookDeliveries: ResourceBuilder<{
|
|
87
87
|
readonly id: Field<string>;
|
|
88
|
-
readonly
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
91
|
-
readonly
|
|
88
|
+
readonly subscription_id: Field<string | number>;
|
|
89
|
+
readonly tenant_id: Field<string | null>;
|
|
90
|
+
readonly event_type: Field<string>;
|
|
91
|
+
readonly event_id: Field<string>;
|
|
92
92
|
readonly status: Field<"waiting" | "failed">;
|
|
93
93
|
readonly attempt: Field<number>;
|
|
94
|
-
readonly
|
|
95
|
-
readonly
|
|
96
|
-
readonly
|
|
94
|
+
readonly next_attempt: Field<string | null>;
|
|
95
|
+
readonly last_error: Field<string | null>;
|
|
96
|
+
readonly created_at: Field<string>;
|
|
97
97
|
readonly resend: Field<boolean>;
|
|
98
98
|
}, Ref<"id", string>>;
|
|
99
99
|
webhookDeliveriesView: ViewBuilder<ResourceBuilder<{
|
|
100
100
|
readonly id: Field<string>;
|
|
101
|
-
readonly
|
|
102
|
-
readonly
|
|
103
|
-
readonly
|
|
104
|
-
readonly
|
|
101
|
+
readonly subscription_id: Field<string | number>;
|
|
102
|
+
readonly tenant_id: Field<string | null>;
|
|
103
|
+
readonly event_type: Field<string>;
|
|
104
|
+
readonly event_id: Field<string>;
|
|
105
105
|
readonly status: Field<"waiting" | "failed">;
|
|
106
106
|
readonly attempt: Field<number>;
|
|
107
|
-
readonly
|
|
108
|
-
readonly
|
|
109
|
-
readonly
|
|
107
|
+
readonly next_attempt: Field<string | null>;
|
|
108
|
+
readonly last_error: Field<string | null>;
|
|
109
|
+
readonly created_at: Field<string>;
|
|
110
110
|
readonly resend: Field<boolean>;
|
|
111
111
|
}, Ref<"id", string>>>;
|
|
112
112
|
};
|
|
@@ -4,7 +4,7 @@ import { layout } from "../layout.js";
|
|
|
4
4
|
import { view } from "../view.js";
|
|
5
5
|
//#region src/webhooks/webhook-resources.ts
|
|
6
6
|
/** Webhook subscriptions: a row per subscription someone made in the admin app, scoped to their tenant. */
|
|
7
|
-
const subscriptionsResource = (schema) => resource("
|
|
7
|
+
const subscriptionsResource = (schema) => resource("webhook_subscriptions").table(`${schema}.subscriptions`).fields({
|
|
8
8
|
id: f.uuid().readOnly().dbDefault(),
|
|
9
9
|
name: f.text().min(1).max(100).filterable().sortable(),
|
|
10
10
|
events: f.text().min(1).max(2e3),
|
|
@@ -14,20 +14,20 @@ const subscriptionsResource = (schema) => resource("webhookSubscriptions").table
|
|
|
14
14
|
payload: f.enum(["full", "thin"]).default("full"),
|
|
15
15
|
enabled: f.boolean().default(true).filterable(),
|
|
16
16
|
secret: f.text().sensitive().readOnly().dbDefault(),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}).primaryKey((r) => r.id).tenant((r) => r.
|
|
30
|
-
const subscriptionsView = view("
|
|
17
|
+
previous_secret: null,
|
|
18
|
+
previous_secret_until: null,
|
|
19
|
+
tenant_id: f.text().optional().readOnly(),
|
|
20
|
+
owner_id: f.text().optional().readOnly().dbDefault(),
|
|
21
|
+
disabled_reason: f.text().optional().readOnly(),
|
|
22
|
+
last_success_at: f.timestamp().optional().readOnly().sortable(),
|
|
23
|
+
failing_since: f.timestamp().optional().readOnly(),
|
|
24
|
+
created_at: f.timestamp().readOnly().dbDefault().sortable(),
|
|
25
|
+
updated_at: f.timestamp().readOnly().dbDefault(),
|
|
26
|
+
rotate_secret: f.boolean().default(false),
|
|
27
|
+
send_test: f.boolean().default(false),
|
|
28
|
+
resend_failed: f.boolean().default(false)
|
|
29
|
+
}).primaryKey((r) => r.id).tenant((r) => r.tenant_id).owner((r) => r.owner_id).search((r) => [r.name, r.url]);
|
|
30
|
+
const subscriptionsView = view("webhook_subscriptions").names({
|
|
31
31
|
singular: "Webhook subscription",
|
|
32
32
|
plural: "Webhook subscriptions"
|
|
33
33
|
}).icon("webhook").title((r) => r.name).help("Sends the app's events to a URL as they happen, signed with Standard Webhooks. It delivers as its owner: only the records and fields they may read.").fields((r) => ({
|
|
@@ -40,18 +40,18 @@ const subscriptionsView = view("webhookSubscriptions").names({
|
|
|
40
40
|
thin: "Thin"
|
|
41
41
|
}),
|
|
42
42
|
secret: r.secret.help("Receivers check the webhook-signature header with it"),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
disabled_reason: r.disabled_reason.label("Disabled because"),
|
|
44
|
+
last_success_at: r.last_success_at.label("Last success"),
|
|
45
|
+
failing_since: r.failing_since.label("Failing since")
|
|
46
46
|
})).list((r) => ({
|
|
47
47
|
columns: [
|
|
48
48
|
r.name,
|
|
49
49
|
r.events,
|
|
50
50
|
r.url,
|
|
51
51
|
r.enabled,
|
|
52
|
-
r.
|
|
52
|
+
r.last_success_at
|
|
53
53
|
],
|
|
54
|
-
sort: [[r.
|
|
54
|
+
sort: [[r.created_at, "desc"]]
|
|
55
55
|
})).layout((r) => [
|
|
56
56
|
layout.section("Subscription", [
|
|
57
57
|
r.name,
|
|
@@ -64,38 +64,38 @@ const subscriptionsView = view("webhookSubscriptions").names({
|
|
|
64
64
|
]),
|
|
65
65
|
layout.section("Signing", [r.secret]),
|
|
66
66
|
layout.sidebar([
|
|
67
|
-
r.
|
|
68
|
-
r.
|
|
69
|
-
r.
|
|
70
|
-
r.
|
|
67
|
+
r.last_success_at,
|
|
68
|
+
r.failing_since,
|
|
69
|
+
r.disabled_reason,
|
|
70
|
+
r.created_at
|
|
71
71
|
]),
|
|
72
72
|
layout.related("Waiting and failed deliveries", {
|
|
73
|
-
resource: "
|
|
74
|
-
field: "
|
|
73
|
+
resource: "webhook_deliveries",
|
|
74
|
+
field: "subscription_id",
|
|
75
75
|
columns: [
|
|
76
|
-
"
|
|
76
|
+
"event_type",
|
|
77
77
|
"status",
|
|
78
78
|
"attempt",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
79
|
+
"next_attempt",
|
|
80
|
+
"last_error"
|
|
81
81
|
]
|
|
82
82
|
})
|
|
83
83
|
]).actions((a) => [
|
|
84
|
-
a.update("
|
|
84
|
+
a.update("send_test", {
|
|
85
85
|
label: "Send test event",
|
|
86
86
|
icon: "send",
|
|
87
|
-
set: {
|
|
87
|
+
set: { send_test: true }
|
|
88
88
|
}),
|
|
89
|
-
a.update("
|
|
89
|
+
a.update("resend_failed", {
|
|
90
90
|
label: "Resend failed",
|
|
91
91
|
icon: "rotate-ccw",
|
|
92
|
-
set: {
|
|
92
|
+
set: { resend_failed: true },
|
|
93
93
|
confirm: "Try every failed delivery of this subscription once more?"
|
|
94
94
|
}),
|
|
95
|
-
a.update("
|
|
95
|
+
a.update("rotate_secret", {
|
|
96
96
|
label: "Rotate secret",
|
|
97
97
|
icon: "key-round",
|
|
98
|
-
set: {
|
|
98
|
+
set: { rotate_secret: true },
|
|
99
99
|
confirm: "Make a new secret? The old one keeps signing too for 24 hours."
|
|
100
100
|
}),
|
|
101
101
|
a.update("disable", {
|
|
@@ -105,51 +105,51 @@ const subscriptionsView = view("webhookSubscriptions").names({
|
|
|
105
105
|
})
|
|
106
106
|
]);
|
|
107
107
|
/** The deliveries of webhook subscriptions that wait for a retry or failed for good: delivery jobs, not a table. */
|
|
108
|
-
const deliveriesResource = (schema) => resource("
|
|
108
|
+
const deliveriesResource = (schema) => resource("webhook_deliveries").table(`${schema}.deliveries`).fields({
|
|
109
109
|
id: f.uuid().readOnly(),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
subscription_id: f.relation("webhook_subscriptions").readOnly().filterable(),
|
|
111
|
+
tenant_id: f.text().optional().readOnly(),
|
|
112
|
+
event_type: f.text().readOnly().filterable().sortable(),
|
|
113
|
+
event_id: f.text().readOnly().filterable(),
|
|
114
114
|
status: f.enum(["waiting", "failed"]).readOnly().filterable(),
|
|
115
115
|
attempt: f.integer().readOnly(),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
next_attempt: f.timestamp().optional().readOnly().sortable(),
|
|
117
|
+
last_error: f.text().optional().readOnly(),
|
|
118
|
+
created_at: f.timestamp().readOnly().sortable(),
|
|
119
119
|
resend: f.boolean()
|
|
120
|
-
}).primaryKey((r) => r.id).tenant((r) => r.
|
|
120
|
+
}).primaryKey((r) => r.id).tenant((r) => r.tenant_id).access({
|
|
121
121
|
create: () => false,
|
|
122
122
|
delete: () => false
|
|
123
123
|
});
|
|
124
|
-
const deliveriesView = view("
|
|
124
|
+
const deliveriesView = view("webhook_deliveries").names({
|
|
125
125
|
singular: "Webhook delivery",
|
|
126
126
|
plural: "Webhook deliveries"
|
|
127
|
-
}).icon("send").title((r) => r.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
}).icon("send").title((r) => r.event_type).help("Deliveries that wait for their next try or failed for good. A delivery leaves the list once it succeeds.").fields((r) => ({
|
|
128
|
+
event_type: r.event_type.label("Event"),
|
|
129
|
+
event_id: r.event_id.label("Event id").format("code"),
|
|
130
|
+
next_attempt: r.next_attempt.label("Next try"),
|
|
131
|
+
last_error: r.last_error.label("Last error"),
|
|
132
132
|
attempt: r.attempt.label("Tries")
|
|
133
133
|
})).list((r) => ({
|
|
134
134
|
columns: [
|
|
135
|
-
r.
|
|
136
|
-
r.
|
|
135
|
+
r.event_type,
|
|
136
|
+
r.subscription_id,
|
|
137
137
|
r.status,
|
|
138
138
|
r.attempt,
|
|
139
|
-
r.
|
|
140
|
-
r.
|
|
139
|
+
r.next_attempt,
|
|
140
|
+
r.last_error
|
|
141
141
|
],
|
|
142
|
-
sort: [[r.
|
|
142
|
+
sort: [[r.created_at, "desc"]]
|
|
143
143
|
})).layout((r) => [layout.section("Delivery", [
|
|
144
|
-
r.
|
|
145
|
-
r.
|
|
146
|
-
r.
|
|
147
|
-
r.
|
|
144
|
+
r.subscription_id,
|
|
145
|
+
r.event_type,
|
|
146
|
+
r.event_id,
|
|
147
|
+
r.last_error
|
|
148
148
|
]), layout.sidebar([
|
|
149
149
|
r.status,
|
|
150
150
|
r.attempt,
|
|
151
|
-
r.
|
|
152
|
-
r.
|
|
151
|
+
r.next_attempt,
|
|
152
|
+
r.created_at
|
|
153
153
|
])]).actions((a) => [a.update("resend", {
|
|
154
154
|
label: "Resend",
|
|
155
155
|
icon: "rotate-ccw",
|
|
@@ -157,39 +157,39 @@ const deliveriesView = view("webhookDeliveries").names({
|
|
|
157
157
|
confirm: "Try this delivery once more, from now?"
|
|
158
158
|
})]);
|
|
159
159
|
/** Every try of every webhook subscription's deliveries, for 30 days (`deliveryLog: true`). */
|
|
160
|
-
const deliveryLogResource = (schema) => resource("
|
|
160
|
+
const deliveryLogResource = (schema) => resource("webhook_delivery_log").table(`${schema}.delivery_log`).fields({
|
|
161
161
|
id: f.bigint().readOnly(),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
subscription_id: f.relation("webhook_subscriptions").readOnly().filterable(),
|
|
163
|
+
tenant_id: f.text().optional().readOnly(),
|
|
164
|
+
event_id: f.text().readOnly().filterable(),
|
|
165
|
+
event_type: f.text().readOnly().filterable().sortable(),
|
|
166
166
|
status: f.enum(["delivered", "failed"]).readOnly().filterable(),
|
|
167
167
|
attempt: f.integer().readOnly(),
|
|
168
|
-
|
|
168
|
+
status_code: f.integer().optional().readOnly().filterable(),
|
|
169
169
|
response: f.text().optional().readOnly(),
|
|
170
|
-
|
|
170
|
+
duration_ms: f.integer().readOnly(),
|
|
171
171
|
at: f.timestamp().readOnly().filterable().sortable()
|
|
172
|
-
}).primaryKey((r) => r.id).tenant((r) => r.
|
|
172
|
+
}).primaryKey((r) => r.id).tenant((r) => r.tenant_id).access({
|
|
173
173
|
create: () => false,
|
|
174
174
|
update: () => false,
|
|
175
175
|
delete: () => false
|
|
176
176
|
});
|
|
177
|
-
const deliveryLogView = view("
|
|
177
|
+
const deliveryLogView = view("webhook_delivery_log").names({
|
|
178
178
|
singular: "Webhook delivery log entry",
|
|
179
179
|
plural: "Webhook delivery log"
|
|
180
|
-
}).icon("scroll-text").title((r) => r.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
}).icon("scroll-text").title((r) => r.event_type).fields((r) => ({
|
|
181
|
+
event_type: r.event_type.label("Event"),
|
|
182
|
+
status_code: r.status_code.label("Status code"),
|
|
183
|
+
duration_ms: r.duration_ms.label("Duration (ms)"),
|
|
184
184
|
at: r.at.label("When")
|
|
185
185
|
})).list((r) => ({
|
|
186
186
|
columns: [
|
|
187
187
|
r.at,
|
|
188
|
-
r.
|
|
189
|
-
r.
|
|
188
|
+
r.event_type,
|
|
189
|
+
r.subscription_id,
|
|
190
190
|
r.status,
|
|
191
|
-
r.
|
|
192
|
-
r.
|
|
191
|
+
r.status_code,
|
|
192
|
+
r.duration_ms
|
|
193
193
|
],
|
|
194
194
|
sort: [[r.at, "desc"]]
|
|
195
195
|
}));
|