@getstrata/core 0.5.17 → 0.5.18
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/auth/authContext.d.ts +1 -2
- package/dist/core/auth/membershipContext.d.ts +1 -2
- package/dist/core/http/requestMetaContext.d.ts +1 -2
- package/dist/core/runtime/asyncContextStore.d.ts +3 -0
- package/dist/core/tenant/tenantContext.d.ts +1 -2
- package/dist/core/tracing/traceContext.d.ts +1 -2
- package/dist/entries/http/csrfToken.js +15 -2
- package/dist/entries/http/webErrorResponse.js +19 -8
- package/dist/entries/http/webFormRequest.js +16 -4
- package/dist/entries/jobs/dispatchWebhookJob.js +15 -2
- package/dist/entries/queue/createAppQueue.js +2609 -226
- package/dist/entries/queue/publicQueue.js +15 -2
- package/dist/entries/queue/queueMetrics.js +2560 -228
- package/dist/entries/view.js +19 -8
- package/dist/index.js +35 -16
- package/package.json +1 -1
package/dist/entries/view.js
CHANGED
|
@@ -850,9 +850,22 @@ function getBoundDatabaseConnection() {
|
|
|
850
850
|
return boundConnectionHolder.connection;
|
|
851
851
|
}
|
|
852
852
|
|
|
853
|
-
// ../../src/core/
|
|
853
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
854
854
|
import { AsyncLocalStorage } from "async_hooks";
|
|
855
|
-
|
|
855
|
+
function createAsyncContextStore(key) {
|
|
856
|
+
const symbol = Symbol.for(key);
|
|
857
|
+
const globalRecord = globalThis;
|
|
858
|
+
const existing = globalRecord[symbol];
|
|
859
|
+
if (existing) {
|
|
860
|
+
return existing;
|
|
861
|
+
}
|
|
862
|
+
const store = new AsyncLocalStorage;
|
|
863
|
+
globalRecord[symbol] = store;
|
|
864
|
+
return store;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// ../../src/core/database/connectionContext.ts
|
|
868
|
+
var activeConnection = createAsyncContextStore("@getstrata/databaseConnectionContext");
|
|
856
869
|
function getActiveDatabaseConnection(fallback) {
|
|
857
870
|
return activeConnection.getStore() ?? fallback;
|
|
858
871
|
}
|
|
@@ -2095,6 +2108,7 @@ var db = new Proxy(function database() {}, {
|
|
|
2095
2108
|
return typeof value === "function" ? value.bind(connection) : value;
|
|
2096
2109
|
}
|
|
2097
2110
|
});
|
|
2111
|
+
var connection_default = db;
|
|
2098
2112
|
|
|
2099
2113
|
// ../../src/modules/user/apiTokenTable.ts
|
|
2100
2114
|
var apiTokenTable = defineTable({
|
|
@@ -2226,15 +2240,13 @@ function revealMfaSecret(stored) {
|
|
|
2226
2240
|
}
|
|
2227
2241
|
|
|
2228
2242
|
// ../../src/core/auth/authContext.ts
|
|
2229
|
-
|
|
2230
|
-
var authContext = new AsyncLocalStorage2;
|
|
2243
|
+
var authContext = createAsyncContextStore("@getstrata/authContext");
|
|
2231
2244
|
function currentAuthUser() {
|
|
2232
2245
|
return authContext.getStore() ?? null;
|
|
2233
2246
|
}
|
|
2234
2247
|
|
|
2235
2248
|
// ../../src/core/http/requestMetaContext.ts
|
|
2236
|
-
|
|
2237
|
-
var requestMetaContext = new AsyncLocalStorage3;
|
|
2249
|
+
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
2238
2250
|
function currentRequestMeta() {
|
|
2239
2251
|
return requestMetaContext.getStore() ?? {
|
|
2240
2252
|
ipAddress: null,
|
|
@@ -2318,8 +2330,7 @@ function verifyTotp(secret, token, window = 1) {
|
|
|
2318
2330
|
}
|
|
2319
2331
|
|
|
2320
2332
|
// ../../src/core/tenant/tenantContext.ts
|
|
2321
|
-
|
|
2322
|
-
var tenantContext = new AsyncLocalStorage4;
|
|
2333
|
+
var tenantContext = createAsyncContextStore("@getstrata/tenantContext");
|
|
2323
2334
|
function currentTenant() {
|
|
2324
2335
|
return tenantContext.getStore() ?? null;
|
|
2325
2336
|
}
|
package/dist/index.js
CHANGED
|
@@ -118,15 +118,28 @@ function resolveService(dependencies, token) {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
// ../../src/bootstrap/applicationRegistry.ts
|
|
121
|
+
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
121
122
|
var activeContext;
|
|
123
|
+
function readStoredApplicationContext() {
|
|
124
|
+
if (activeContext) {
|
|
125
|
+
return activeContext;
|
|
126
|
+
}
|
|
127
|
+
const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
|
|
128
|
+
if (globalContext) {
|
|
129
|
+
activeContext = globalContext;
|
|
130
|
+
}
|
|
131
|
+
return activeContext;
|
|
132
|
+
}
|
|
122
133
|
function setActiveApplicationContext(context) {
|
|
123
134
|
activeContext = context;
|
|
135
|
+
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
124
136
|
}
|
|
125
137
|
function requireActiveApplicationContext() {
|
|
126
|
-
|
|
138
|
+
const context = readStoredApplicationContext();
|
|
139
|
+
if (!context) {
|
|
127
140
|
throw new Error("The application context has not been bootstrapped.");
|
|
128
141
|
}
|
|
129
|
-
return
|
|
142
|
+
return context;
|
|
130
143
|
}
|
|
131
144
|
function resolveApplicationCache() {
|
|
132
145
|
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
@@ -271,9 +284,22 @@ class PreconditionFailedError extends HttpError {
|
|
|
271
284
|
}
|
|
272
285
|
}
|
|
273
286
|
|
|
274
|
-
// ../../src/core/
|
|
287
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
275
288
|
import { AsyncLocalStorage } from "async_hooks";
|
|
276
|
-
|
|
289
|
+
function createAsyncContextStore(key) {
|
|
290
|
+
const symbol = Symbol.for(key);
|
|
291
|
+
const globalRecord = globalThis;
|
|
292
|
+
const existing = globalRecord[symbol];
|
|
293
|
+
if (existing) {
|
|
294
|
+
return existing;
|
|
295
|
+
}
|
|
296
|
+
const store = new AsyncLocalStorage;
|
|
297
|
+
globalRecord[symbol] = store;
|
|
298
|
+
return store;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// ../../src/core/auth/authContext.ts
|
|
302
|
+
var authContext = createAsyncContextStore("@getstrata/authContext");
|
|
277
303
|
function runWithAuthUser(user, callback) {
|
|
278
304
|
return authContext.run(user, callback);
|
|
279
305
|
}
|
|
@@ -1029,8 +1055,7 @@ function resetBoundDatabaseConnection() {
|
|
|
1029
1055
|
}
|
|
1030
1056
|
|
|
1031
1057
|
// ../../src/core/database/connectionContext.ts
|
|
1032
|
-
|
|
1033
|
-
var activeConnection = new AsyncLocalStorage2;
|
|
1058
|
+
var activeConnection = createAsyncContextStore("@getstrata/databaseConnectionContext");
|
|
1034
1059
|
function runWithDatabaseConnection(connection, callback) {
|
|
1035
1060
|
return activeConnection.run(connection, callback);
|
|
1036
1061
|
}
|
|
@@ -2752,8 +2777,7 @@ function revealMfaSecret(stored) {
|
|
|
2752
2777
|
}
|
|
2753
2778
|
|
|
2754
2779
|
// ../../src/core/http/requestMetaContext.ts
|
|
2755
|
-
|
|
2756
|
-
var requestMetaContext = new AsyncLocalStorage3;
|
|
2780
|
+
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
2757
2781
|
function runWithRequestMeta(meta, callback) {
|
|
2758
2782
|
return requestMetaContext.run(meta, callback);
|
|
2759
2783
|
}
|
|
@@ -2840,8 +2864,7 @@ function verifyTotp(secret, token, window = 1) {
|
|
|
2840
2864
|
}
|
|
2841
2865
|
|
|
2842
2866
|
// ../../src/core/tenant/tenantContext.ts
|
|
2843
|
-
|
|
2844
|
-
var tenantContext = new AsyncLocalStorage4;
|
|
2867
|
+
var tenantContext = createAsyncContextStore("@getstrata/tenantContext");
|
|
2845
2868
|
function runWithTenant(tenant, callback) {
|
|
2846
2869
|
return tenantContext.run(tenant, callback);
|
|
2847
2870
|
}
|
|
@@ -3098,9 +3121,6 @@ class AuthManager {
|
|
|
3098
3121
|
return user;
|
|
3099
3122
|
}
|
|
3100
3123
|
}
|
|
3101
|
-
// ../../src/core/auth/membershipContext.ts
|
|
3102
|
-
import { AsyncLocalStorage as AsyncLocalStorage5 } from "async_hooks";
|
|
3103
|
-
|
|
3104
3124
|
// ../../src/modules/organization/memberRepository.ts
|
|
3105
3125
|
class OrganizationMemberRepository {
|
|
3106
3126
|
constructor() {}
|
|
@@ -3153,7 +3173,7 @@ class OrganizationMemberRepository {
|
|
|
3153
3173
|
var memberRepository_default = OrganizationMemberRepository;
|
|
3154
3174
|
|
|
3155
3175
|
// ../../src/core/auth/membershipContext.ts
|
|
3156
|
-
var membershipContext =
|
|
3176
|
+
var membershipContext = createAsyncContextStore("@getstrata/membershipContext");
|
|
3157
3177
|
var membershipRepository = new memberRepository_default;
|
|
3158
3178
|
async function runWithMembershipContext(callback) {
|
|
3159
3179
|
const user = currentAuthUser();
|
|
@@ -6504,8 +6524,7 @@ function createTenantMiddleware() {
|
|
|
6504
6524
|
};
|
|
6505
6525
|
}
|
|
6506
6526
|
// ../../src/core/tracing/traceContext.ts
|
|
6507
|
-
|
|
6508
|
-
var traceContextStorage = new AsyncLocalStorage6;
|
|
6527
|
+
var traceContextStorage = createAsyncContextStore("@getstrata/traceContext");
|
|
6509
6528
|
function runWithTraceContext(context, callback) {
|
|
6510
6529
|
return traceContextStorage.run(context, callback);
|
|
6511
6530
|
}
|