@fonoster/apiserver 0.54.1 → 0.56.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/core/services.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ declare const services: Promise<[{
|
|
|
143
143
|
listApiKeys: (call: {
|
|
144
144
|
request: unknown;
|
|
145
145
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
146
|
-
|
|
146
|
+
rotateApiKey: (call: {
|
|
147
147
|
request: unknown;
|
|
148
148
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
149
149
|
exchangeApiKey: (call: {
|
|
@@ -362,6 +362,9 @@ declare const services: Promise<[{
|
|
|
362
362
|
resendWebhookDelivery: (call: {
|
|
363
363
|
request: unknown;
|
|
364
364
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
365
|
+
getWebhookDelivery: (call: {
|
|
366
|
+
request: unknown;
|
|
367
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
365
368
|
};
|
|
366
369
|
}, {
|
|
367
370
|
definition: {
|
|
@@ -13,7 +13,7 @@ exports.SYNCED_SERVICES = [
|
|
|
13
13
|
"Credentials",
|
|
14
14
|
"Webhooks"
|
|
15
15
|
];
|
|
16
|
-
const WRITE = /^(create|update|delete|rotate|
|
|
16
|
+
const WRITE = /^(create|update|delete|rotate|resend)/;
|
|
17
17
|
/**
|
|
18
18
|
* Wraps the write handlers of the synced services so a successful write marks the workspace's
|
|
19
19
|
* config changed (the config sync publishes a new version for private workspaces).
|
|
@@ -34,4 +34,7 @@ export declare function createWebhooksHandlers(db: WebhooksDb, config?: Webhooks
|
|
|
34
34
|
resendWebhookDelivery: (call: {
|
|
35
35
|
request: unknown;
|
|
36
36
|
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
37
|
+
getWebhookDelivery: (call: {
|
|
38
|
+
request: unknown;
|
|
39
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
37
40
|
};
|
|
@@ -61,7 +61,8 @@ function toDelivery(row) {
|
|
|
61
61
|
lastStatus: (_a = row.lastStatus) !== null && _a !== void 0 ? _a : 0,
|
|
62
62
|
lastAttemptAt: seconds(row.lastAttemptAt),
|
|
63
63
|
nextAttemptAt: row.status === "pending" ? seconds(row.nextAttemptAt) : 0,
|
|
64
|
-
createdAt: seconds(row.createdAt)
|
|
64
|
+
createdAt: seconds(row.createdAt),
|
|
65
|
+
event: JSON.stringify(row.event)
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
/** Checks the URL (HTTPS) and event types the same way the dispatcher does. */
|
|
@@ -182,15 +183,24 @@ function createWebhooksHandlers(db, config = {}) {
|
|
|
182
183
|
});
|
|
183
184
|
callback(null, { items: rows.map(toDelivery) });
|
|
184
185
|
});
|
|
185
|
-
|
|
186
|
-
const resendWebhookDelivery = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const accessKeyId = workspace(call);
|
|
188
|
-
const { ref } = call.request;
|
|
186
|
+
const findDelivery = (ref, accessKeyId) => __awaiter(this, void 0, void 0, function* () {
|
|
189
187
|
const row = yield db.webhookDelivery.findFirst({
|
|
190
188
|
where: { ref, accessKeyId }
|
|
191
189
|
});
|
|
192
190
|
if (!row)
|
|
193
191
|
throw notFound(`delivery not found: ${ref}`);
|
|
192
|
+
return row;
|
|
193
|
+
});
|
|
194
|
+
/** One delivery of the caller's workspace, with the event it sends. */
|
|
195
|
+
const getWebhookDelivery = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
const row = yield findDelivery(call.request.ref, workspace(call));
|
|
197
|
+
callback(null, toDelivery(row));
|
|
198
|
+
});
|
|
199
|
+
/** Sends again now with the original event id and a fresh signature (W6). */
|
|
200
|
+
const resendWebhookDelivery = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const accessKeyId = workspace(call);
|
|
202
|
+
const { ref } = call.request;
|
|
203
|
+
yield findDelivery(ref, accessKeyId);
|
|
194
204
|
const store = yield common_1.Webhooks.PrismaWebhookStore.open(db);
|
|
195
205
|
yield store.loadDeliveries({ id: ref, workspaceRef: accessKeyId }, 1);
|
|
196
206
|
const dispatcher = new common_1.Webhooks.WebhookDispatcher({
|
|
@@ -212,6 +222,7 @@ function createWebhooksHandlers(db, config = {}) {
|
|
|
212
222
|
deleteWebhook: (0, common_1.withErrorHandling)(deleteWebhook),
|
|
213
223
|
rotateWebhookSecret: (0, common_1.withErrorHandling)(rotateWebhookSecret),
|
|
214
224
|
listWebhookDeliveries: (0, common_1.withErrorHandling)(listWebhookDeliveries),
|
|
215
|
-
resendWebhookDelivery: (0, common_1.withErrorHandling)(resendWebhookDelivery)
|
|
225
|
+
resendWebhookDelivery: (0, common_1.withErrorHandling)(resendWebhookDelivery),
|
|
226
|
+
getWebhookDelivery: (0, common_1.withErrorHandling)(getWebhookDelivery)
|
|
216
227
|
};
|
|
217
228
|
}
|
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ declare function buildWebhooksService(db: WebhooksDb): {
|
|
|
31
31
|
resendWebhookDelivery: (call: {
|
|
32
32
|
request: unknown;
|
|
33
33
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
34
|
+
getWebhookDelivery: (call: {
|
|
35
|
+
request: unknown;
|
|
36
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
export { buildWebhooksService };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"fonoster-owner": "./dist/bin/owner.js"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@fonoster/authz": "^0.
|
|
27
|
-
"@fonoster/autopilot": "^0.
|
|
28
|
-
"@fonoster/callrecord": "^0.
|
|
29
|
-
"@fonoster/common": "^0.
|
|
30
|
-
"@fonoster/identity": "^0.
|
|
31
|
-
"@fonoster/logger": "^0.
|
|
32
|
-
"@fonoster/sipnet": "^0.
|
|
33
|
-
"@fonoster/types": "^0.
|
|
26
|
+
"@fonoster/authz": "^0.56.0",
|
|
27
|
+
"@fonoster/autopilot": "^0.56.0",
|
|
28
|
+
"@fonoster/callrecord": "^0.56.0",
|
|
29
|
+
"@fonoster/common": "^0.56.0",
|
|
30
|
+
"@fonoster/identity": "^0.56.0",
|
|
31
|
+
"@fonoster/logger": "^0.56.0",
|
|
32
|
+
"@fonoster/sipnet": "^0.56.0",
|
|
33
|
+
"@fonoster/types": "^0.56.0",
|
|
34
34
|
"@grpc/grpc-js": "~1.14.6",
|
|
35
35
|
"@prisma/client": "^6.19.1",
|
|
36
36
|
"@routr/common": "^2.24.0",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@fonoster/ops": "^0.
|
|
65
|
+
"@fonoster/ops": "^0.56.0",
|
|
66
66
|
"@types/express": "^5.0.6",
|
|
67
67
|
"@types/jsonwebtoken": "^9.0.10",
|
|
68
68
|
"@types/uuid": "^10.0.0",
|
|
69
69
|
"@types/validator": "^13.15.10"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "a11544fd543733c1ce472d4b235d48b5d1255496",
|
|
72
72
|
"prisma": {
|
|
73
73
|
"seed": "tsx src/core/seed.ts"
|
|
74
74
|
}
|