@getstrata/bootstrap 0.2.13 → 0.2.16
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/bootstrap/http/securedRouteModelBinding.d.ts +2 -11
- package/dist/bootstrap/membershipService.d.ts +1 -3
- package/dist/core/auth/membershipService.d.ts +1 -1
- package/dist/core/auth/resolveMembershipService.d.ts +3 -0
- package/dist/core/http/securedRouteModelBinding.d.ts +11 -2
- package/dist/core/queue/createAppQueue.d.ts +0 -1
- package/dist/core/queue/jobRegistry.d.ts +0 -1
- package/dist/entries/context.js +128 -119
- package/dist/entries/http/securedRouteModelBinding.js +100 -99
- package/dist/entries/membershipService.js +100 -99
- package/dist/entries/providers.js +214 -205
- package/dist/entries/queue/defaultJobs.js +12 -2
- package/dist/framework/public-api.d.ts +0 -1
- package/dist/index.js +82 -73
- package/package.json +2 -2
- package/dist/core/cache/modelCacheTags.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -3582,7 +3582,6 @@ var failedJobService_default = FailedJobService;
|
|
|
3582
3582
|
|
|
3583
3583
|
// ../../src/core/queue/jobRegistry.ts
|
|
3584
3584
|
class JobRegistry {
|
|
3585
|
-
constructor() {}
|
|
3586
3585
|
factories = new Map;
|
|
3587
3586
|
instances = new WeakMap;
|
|
3588
3587
|
register(name, factory) {
|
|
@@ -3606,7 +3605,17 @@ class JobRegistry {
|
|
|
3606
3605
|
return [...this.factories.keys()];
|
|
3607
3606
|
}
|
|
3608
3607
|
}
|
|
3609
|
-
var
|
|
3608
|
+
var JOB_REGISTRY_KEY = Symbol.for("@getstrata/jobRegistry");
|
|
3609
|
+
function readSharedJobRegistry() {
|
|
3610
|
+
const globalRegistry = globalThis[JOB_REGISTRY_KEY];
|
|
3611
|
+
if (globalRegistry) {
|
|
3612
|
+
return globalRegistry;
|
|
3613
|
+
}
|
|
3614
|
+
const registry = new JobRegistry;
|
|
3615
|
+
globalThis[JOB_REGISTRY_KEY] = registry;
|
|
3616
|
+
return registry;
|
|
3617
|
+
}
|
|
3618
|
+
var jobRegistry = readSharedJobRegistry();
|
|
3610
3619
|
|
|
3611
3620
|
// ../../src/core/queue/jobRunner.ts
|
|
3612
3621
|
async function runQueueJob(envelope, failedJobs) {
|
|
@@ -3722,75 +3731,6 @@ function createProductionQueue(driver, options = {}) {
|
|
|
3722
3731
|
return new ResilientQueue(failedJobs, driver === "async");
|
|
3723
3732
|
}
|
|
3724
3733
|
|
|
3725
|
-
// ../../src/core/jobs/dispatchWebhookJob.ts
|
|
3726
|
-
import { createHmac as createHmac2 } from "crypto";
|
|
3727
|
-
class DispatchWebhookJob extends Job {
|
|
3728
|
-
maxAttempts = 3;
|
|
3729
|
-
backoffMs = 2000;
|
|
3730
|
-
async handle(payload) {
|
|
3731
|
-
const rows = await repositoryConnection`
|
|
3732
|
-
SELECT id, url, secret
|
|
3733
|
-
FROM webhook
|
|
3734
|
-
WHERE id = ${payload.webhookId} AND active = TRUE
|
|
3735
|
-
LIMIT 1
|
|
3736
|
-
`;
|
|
3737
|
-
const webhook = rows[0];
|
|
3738
|
-
if (!webhook) {
|
|
3739
|
-
return;
|
|
3740
|
-
}
|
|
3741
|
-
const body = JSON.stringify({ event: payload.event, payload: payload.payload });
|
|
3742
|
-
const signature = createHmac2("sha256", webhook.secret).update(body).digest("hex");
|
|
3743
|
-
assertSafeOutboundUrl(webhook.url, { allowHttp: appConfig.env !== "production" });
|
|
3744
|
-
let responseStatus = null;
|
|
3745
|
-
let errorMessage = null;
|
|
3746
|
-
try {
|
|
3747
|
-
const response = await safeFetch(webhook.url, {
|
|
3748
|
-
method: "POST",
|
|
3749
|
-
headers: {
|
|
3750
|
-
"content-type": "application/json",
|
|
3751
|
-
"x-workhub-signature": signature
|
|
3752
|
-
},
|
|
3753
|
-
body
|
|
3754
|
-
}, { allowHttp: appConfig.env !== "production" });
|
|
3755
|
-
responseStatus = response.status;
|
|
3756
|
-
if (!response.ok) {
|
|
3757
|
-
throw new Error(`Webhook delivery failed with status ${response.status}.`);
|
|
3758
|
-
}
|
|
3759
|
-
} catch (error) {
|
|
3760
|
-
errorMessage = error instanceof Error ? error.message : String(error);
|
|
3761
|
-
await repositoryConnection`
|
|
3762
|
-
INSERT INTO webhook_delivery (webhook_id, event, payload, response_status, error)
|
|
3763
|
-
VALUES (
|
|
3764
|
-
${webhook.id},
|
|
3765
|
-
${payload.event},
|
|
3766
|
-
${JSON.stringify(payload.payload)}::jsonb,
|
|
3767
|
-
${responseStatus},
|
|
3768
|
-
${errorMessage}
|
|
3769
|
-
)
|
|
3770
|
-
`;
|
|
3771
|
-
throw error instanceof Error ? error : new Error(errorMessage);
|
|
3772
|
-
}
|
|
3773
|
-
await repositoryConnection`
|
|
3774
|
-
INSERT INTO webhook_delivery (webhook_id, event, payload, response_status)
|
|
3775
|
-
VALUES (
|
|
3776
|
-
${webhook.id},
|
|
3777
|
-
${payload.event},
|
|
3778
|
-
${JSON.stringify(payload.payload)}::jsonb,
|
|
3779
|
-
${responseStatus}
|
|
3780
|
-
)
|
|
3781
|
-
`;
|
|
3782
|
-
}
|
|
3783
|
-
}
|
|
3784
|
-
var dispatchWebhookJob_default = DispatchWebhookJob;
|
|
3785
|
-
|
|
3786
|
-
// ../../src/bootstrap/queue/defaultJobs.ts
|
|
3787
|
-
function registerDefaultJobs() {
|
|
3788
|
-
jobRegistry.register("cache.invalidate-tags", () => {
|
|
3789
|
-
return new invalidateCacheTagsJob_default(resolveApplicationCache());
|
|
3790
|
-
});
|
|
3791
|
-
jobRegistry.register("webhook.dispatch", () => new dispatchWebhookJob_default);
|
|
3792
|
-
}
|
|
3793
|
-
|
|
3794
3734
|
// ../../src/core/queue/createAppQueue.ts
|
|
3795
3735
|
var FAILED_JOB_SERVICE_TOKEN = "core.failedJobs";
|
|
3796
3736
|
function createAppQueue(driver, redisUrl, failedJobs = createFailedJobService(), registerJobs) {
|
|
@@ -3896,6 +3836,75 @@ var policyProvider = {
|
|
|
3896
3836
|
};
|
|
3897
3837
|
var policy_default = policyProvider;
|
|
3898
3838
|
|
|
3839
|
+
// ../../src/core/jobs/dispatchWebhookJob.ts
|
|
3840
|
+
import { createHmac as createHmac2 } from "crypto";
|
|
3841
|
+
class DispatchWebhookJob extends Job {
|
|
3842
|
+
maxAttempts = 3;
|
|
3843
|
+
backoffMs = 2000;
|
|
3844
|
+
async handle(payload) {
|
|
3845
|
+
const rows = await repositoryConnection`
|
|
3846
|
+
SELECT id, url, secret
|
|
3847
|
+
FROM webhook
|
|
3848
|
+
WHERE id = ${payload.webhookId} AND active = TRUE
|
|
3849
|
+
LIMIT 1
|
|
3850
|
+
`;
|
|
3851
|
+
const webhook = rows[0];
|
|
3852
|
+
if (!webhook) {
|
|
3853
|
+
return;
|
|
3854
|
+
}
|
|
3855
|
+
const body = JSON.stringify({ event: payload.event, payload: payload.payload });
|
|
3856
|
+
const signature = createHmac2("sha256", webhook.secret).update(body).digest("hex");
|
|
3857
|
+
assertSafeOutboundUrl(webhook.url, { allowHttp: appConfig.env !== "production" });
|
|
3858
|
+
let responseStatus = null;
|
|
3859
|
+
let errorMessage = null;
|
|
3860
|
+
try {
|
|
3861
|
+
const response = await safeFetch(webhook.url, {
|
|
3862
|
+
method: "POST",
|
|
3863
|
+
headers: {
|
|
3864
|
+
"content-type": "application/json",
|
|
3865
|
+
"x-workhub-signature": signature
|
|
3866
|
+
},
|
|
3867
|
+
body
|
|
3868
|
+
}, { allowHttp: appConfig.env !== "production" });
|
|
3869
|
+
responseStatus = response.status;
|
|
3870
|
+
if (!response.ok) {
|
|
3871
|
+
throw new Error(`Webhook delivery failed with status ${response.status}.`);
|
|
3872
|
+
}
|
|
3873
|
+
} catch (error) {
|
|
3874
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
3875
|
+
await repositoryConnection`
|
|
3876
|
+
INSERT INTO webhook_delivery (webhook_id, event, payload, response_status, error)
|
|
3877
|
+
VALUES (
|
|
3878
|
+
${webhook.id},
|
|
3879
|
+
${payload.event},
|
|
3880
|
+
${JSON.stringify(payload.payload)}::jsonb,
|
|
3881
|
+
${responseStatus},
|
|
3882
|
+
${errorMessage}
|
|
3883
|
+
)
|
|
3884
|
+
`;
|
|
3885
|
+
throw error instanceof Error ? error : new Error(errorMessage);
|
|
3886
|
+
}
|
|
3887
|
+
await repositoryConnection`
|
|
3888
|
+
INSERT INTO webhook_delivery (webhook_id, event, payload, response_status)
|
|
3889
|
+
VALUES (
|
|
3890
|
+
${webhook.id},
|
|
3891
|
+
${payload.event},
|
|
3892
|
+
${JSON.stringify(payload.payload)}::jsonb,
|
|
3893
|
+
${responseStatus}
|
|
3894
|
+
)
|
|
3895
|
+
`;
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
var dispatchWebhookJob_default = DispatchWebhookJob;
|
|
3899
|
+
|
|
3900
|
+
// ../../src/bootstrap/queue/defaultJobs.ts
|
|
3901
|
+
function registerDefaultJobs() {
|
|
3902
|
+
jobRegistry.register("cache.invalidate-tags", () => {
|
|
3903
|
+
return new invalidateCacheTagsJob_default(resolveApplicationCache());
|
|
3904
|
+
});
|
|
3905
|
+
jobRegistry.register("webhook.dispatch", () => new dispatchWebhookJob_default);
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3899
3908
|
// ../../src/bootstrap/providers/queue.ts
|
|
3900
3909
|
var queueProvider = {
|
|
3901
3910
|
name: "core.queue",
|
|
@@ -4840,7 +4849,7 @@ function parsePositiveIntParam(value, name = "id") {
|
|
|
4840
4849
|
return parsed;
|
|
4841
4850
|
}
|
|
4842
4851
|
|
|
4843
|
-
// ../../src/
|
|
4852
|
+
// ../../src/core/http/securedRouteModelBinding.ts
|
|
4844
4853
|
function isMutatingPolicyAction(action) {
|
|
4845
4854
|
return action === "update" || action === "delete";
|
|
4846
4855
|
}
|
|
@@ -5021,7 +5030,7 @@ class MembershipService {
|
|
|
5021
5030
|
}
|
|
5022
5031
|
var membershipService_default = MembershipService;
|
|
5023
5032
|
|
|
5024
|
-
// ../../src/
|
|
5033
|
+
// ../../src/core/auth/resolveMembershipService.ts
|
|
5025
5034
|
function resolveMembershipService() {
|
|
5026
5035
|
const dependencies = resolveApplicationDependencies();
|
|
5027
5036
|
if (dependencies.container.has("core.membership")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getstrata/bootstrap",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Strata application bootstrap — HttpKernel, DI, web session helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
|
-
"@getstrata/core": "^0.5.
|
|
92
|
+
"@getstrata/core": "^0.5.24",
|
|
93
93
|
"typescript": "^5.9.0"
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { cacheTagsForModelWrite, discoverModelTableNames, } from "../../bootstrap/cache/modelCacheTags.ts";
|