@getstrata/core 0.5.16 → 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/bootstrap/membershipService.d.ts +3 -0
- package/dist/bootstrap/queue/defaultJobs.d.ts +2 -0
- package/dist/core/auth/authContext.d.ts +1 -2
- package/dist/core/auth/membershipContext.d.ts +1 -2
- package/dist/core/auth/membershipService.d.ts +1 -2
- package/dist/core/http/requestMetaContext.d.ts +1 -2
- package/dist/core/queue/createAppQueue.d.ts +3 -3
- 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 +4383 -2000
- package/dist/entries/queue/publicQueue.js +15 -2
- package/dist/entries/queue/queueMetrics.js +4016 -1684
- package/dist/entries/view.js +19 -8
- package/dist/index.js +44 -24
- package/package.json +1 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
1
|
type AuthUser = {
|
|
3
2
|
id: number | string;
|
|
4
3
|
role?: string;
|
|
5
4
|
abilities?: string[];
|
|
6
5
|
tokenId?: number;
|
|
7
6
|
};
|
|
8
|
-
declare const authContext: AsyncLocalStorage<AuthUser | null>;
|
|
7
|
+
declare const authContext: import("node:async_hooks").AsyncLocalStorage<AuthUser | null>;
|
|
9
8
|
declare function runWithAuthUser<T>(user: AuthUser | null, callback: () => T | Promise<T>): T | Promise<T>;
|
|
10
9
|
declare function currentAuthUser(): AuthUser | null;
|
|
11
10
|
export type { AuthUser };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
1
|
import OrganizationMemberRepository from "../../modules/organization/memberRepository";
|
|
3
2
|
import type { OrganizationMemberRole } from "../../modules/organization/memberTypes";
|
|
4
3
|
type MembershipContext = {
|
|
5
4
|
organizationIds: number[];
|
|
6
5
|
rolesByOrganizationId: Map<number, OrganizationMemberRole>;
|
|
7
6
|
};
|
|
8
|
-
declare const membershipContext: AsyncLocalStorage<MembershipContext>;
|
|
7
|
+
declare const membershipContext: import("node:async_hooks").AsyncLocalStorage<MembershipContext>;
|
|
9
8
|
declare const membershipRepository: OrganizationMemberRepository;
|
|
10
9
|
declare function runWithMembershipContext<T>(callback: () => T | Promise<T>): Promise<T | Promise<T>>;
|
|
11
10
|
declare function currentOrgRole(organizationId: number): OrganizationMemberRole | null;
|
|
@@ -18,7 +18,6 @@ declare class MembershipService {
|
|
|
18
18
|
}): Promise<import("../../modules/organization/memberTypes").OrganizationMemberRecord>;
|
|
19
19
|
removeMember(organizationId: number, userId: number): Promise<boolean>;
|
|
20
20
|
}
|
|
21
|
-
declare function resolveMembershipService(): MembershipService;
|
|
22
21
|
export type { MembershipRepositoryLike };
|
|
23
22
|
export default MembershipService;
|
|
24
|
-
export { resolveMembershipService };
|
|
23
|
+
export { resolveMembershipService } from "../../bootstrap/membershipService.ts";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
1
|
type RequestMeta = {
|
|
3
2
|
ipAddress: string | null;
|
|
4
3
|
userAgent: string | null;
|
|
@@ -9,7 +8,7 @@ type RequestMeta = {
|
|
|
9
8
|
} | null;
|
|
10
9
|
csrfToken?: string;
|
|
11
10
|
};
|
|
12
|
-
declare const requestMetaContext: AsyncLocalStorage<RequestMeta>;
|
|
11
|
+
declare const requestMetaContext: import("node:async_hooks").AsyncLocalStorage<RequestMeta>;
|
|
13
12
|
declare function runWithRequestMeta<T>(meta: RequestMeta, callback: () => T | Promise<T>): T | Promise<T>;
|
|
14
13
|
declare function currentRequestMeta(): RequestMeta;
|
|
15
14
|
export type { RequestMeta };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Queue } from "./index";
|
|
2
2
|
import { createFailedJobService, createQueueWorker, createTrackedJob, type FailedJobService } from "./publicQueue";
|
|
3
3
|
declare const FAILED_JOB_SERVICE_TOKEN = "core.failedJobs";
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
export { createAppQueue, createFailedJobService, createQueueWorker, createTrackedJob, FAILED_JOB_SERVICE_TOKEN,
|
|
4
|
+
declare function createAppQueue(driver: "sync" | "async" | "redis", redisUrl?: string, failedJobs?: FailedJobService, registerJobs?: () => void): Queue;
|
|
5
|
+
export { registerDefaultJobs } from "../../bootstrap/queue/defaultJobs.ts";
|
|
6
|
+
export { createAppQueue, createFailedJobService, createQueueWorker, createTrackedJob, FAILED_JOB_SERVICE_TOKEN, };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
1
|
type TenantContext = {
|
|
3
2
|
id: number;
|
|
4
3
|
slug: string;
|
|
5
4
|
plan: "free" | "pro" | "enterprise";
|
|
6
5
|
region: "eu" | "us" | "apac";
|
|
7
6
|
};
|
|
8
|
-
declare const tenantContext: AsyncLocalStorage<TenantContext>;
|
|
7
|
+
declare const tenantContext: import("node:async_hooks").AsyncLocalStorage<TenantContext>;
|
|
9
8
|
declare function runWithTenant<T>(tenant: TenantContext, callback: () => T | Promise<T>): T | Promise<T>;
|
|
10
9
|
declare function currentTenant(): TenantContext | null;
|
|
11
10
|
declare function currentTenantId(): number;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
1
|
type TraceContext = {
|
|
3
2
|
traceId: string;
|
|
4
3
|
spanId: string;
|
|
5
4
|
};
|
|
6
|
-
declare const traceContextStorage: AsyncLocalStorage<TraceContext>;
|
|
5
|
+
declare const traceContextStorage: import("node:async_hooks").AsyncLocalStorage<TraceContext>;
|
|
7
6
|
declare function runWithTraceContext<T>(context: TraceContext, callback: () => T | Promise<T>): T | Promise<T>;
|
|
8
7
|
declare function currentTraceId(): string | null;
|
|
9
8
|
export type { TraceContext };
|
|
@@ -27,9 +27,22 @@ function readRequestCookie(request, name) {
|
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
// ../../src/core/
|
|
30
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
31
31
|
import { AsyncLocalStorage } from "async_hooks";
|
|
32
|
-
|
|
32
|
+
function createAsyncContextStore(key) {
|
|
33
|
+
const symbol = Symbol.for(key);
|
|
34
|
+
const globalRecord = globalThis;
|
|
35
|
+
const existing = globalRecord[symbol];
|
|
36
|
+
if (existing) {
|
|
37
|
+
return existing;
|
|
38
|
+
}
|
|
39
|
+
const store = new AsyncLocalStorage;
|
|
40
|
+
globalRecord[symbol] = store;
|
|
41
|
+
return store;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ../../src/core/http/requestMetaContext.ts
|
|
45
|
+
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
33
46
|
function currentRequestMeta() {
|
|
34
47
|
return requestMetaContext.getStore() ?? {
|
|
35
48
|
ipAddress: null,
|
|
@@ -865,9 +865,22 @@ function getBoundDatabaseConnection() {
|
|
|
865
865
|
return boundConnectionHolder.connection;
|
|
866
866
|
}
|
|
867
867
|
|
|
868
|
-
// ../../src/core/
|
|
868
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
869
869
|
import { AsyncLocalStorage } from "async_hooks";
|
|
870
|
-
|
|
870
|
+
function createAsyncContextStore(key) {
|
|
871
|
+
const symbol = Symbol.for(key);
|
|
872
|
+
const globalRecord = globalThis;
|
|
873
|
+
const existing = globalRecord[symbol];
|
|
874
|
+
if (existing) {
|
|
875
|
+
return existing;
|
|
876
|
+
}
|
|
877
|
+
const store = new AsyncLocalStorage;
|
|
878
|
+
globalRecord[symbol] = store;
|
|
879
|
+
return store;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// ../../src/core/database/connectionContext.ts
|
|
883
|
+
var activeConnection = createAsyncContextStore("@getstrata/databaseConnectionContext");
|
|
871
884
|
function getActiveDatabaseConnection(fallback) {
|
|
872
885
|
return activeConnection.getStore() ?? fallback;
|
|
873
886
|
}
|
|
@@ -2110,6 +2123,7 @@ var db = new Proxy(function database() {}, {
|
|
|
2110
2123
|
return typeof value === "function" ? value.bind(connection) : value;
|
|
2111
2124
|
}
|
|
2112
2125
|
});
|
|
2126
|
+
var connection_default = db;
|
|
2113
2127
|
|
|
2114
2128
|
// ../../src/modules/user/apiTokenTable.ts
|
|
2115
2129
|
var apiTokenTable = defineTable({
|
|
@@ -2241,15 +2255,13 @@ function revealMfaSecret(stored) {
|
|
|
2241
2255
|
}
|
|
2242
2256
|
|
|
2243
2257
|
// ../../src/core/auth/authContext.ts
|
|
2244
|
-
|
|
2245
|
-
var authContext = new AsyncLocalStorage2;
|
|
2258
|
+
var authContext = createAsyncContextStore("@getstrata/authContext");
|
|
2246
2259
|
function currentAuthUser() {
|
|
2247
2260
|
return authContext.getStore() ?? null;
|
|
2248
2261
|
}
|
|
2249
2262
|
|
|
2250
2263
|
// ../../src/core/http/requestMetaContext.ts
|
|
2251
|
-
|
|
2252
|
-
var requestMetaContext = new AsyncLocalStorage3;
|
|
2264
|
+
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
2253
2265
|
function currentRequestMeta() {
|
|
2254
2266
|
return requestMetaContext.getStore() ?? {
|
|
2255
2267
|
ipAddress: null,
|
|
@@ -2333,8 +2345,7 @@ function verifyTotp(secret, token, window = 1) {
|
|
|
2333
2345
|
}
|
|
2334
2346
|
|
|
2335
2347
|
// ../../src/core/tenant/tenantContext.ts
|
|
2336
|
-
|
|
2337
|
-
var tenantContext = new AsyncLocalStorage4;
|
|
2348
|
+
var tenantContext = createAsyncContextStore("@getstrata/tenantContext");
|
|
2338
2349
|
function currentTenant() {
|
|
2339
2350
|
return tenantContext.getStore() ?? null;
|
|
2340
2351
|
}
|
|
@@ -106,16 +106,28 @@ function formDataToRecord(formData) {
|
|
|
106
106
|
return values;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
// ../../src/core/
|
|
109
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
110
110
|
import { AsyncLocalStorage } from "async_hooks";
|
|
111
|
-
|
|
111
|
+
function createAsyncContextStore(key) {
|
|
112
|
+
const symbol = Symbol.for(key);
|
|
113
|
+
const globalRecord = globalThis;
|
|
114
|
+
const existing = globalRecord[symbol];
|
|
115
|
+
if (existing) {
|
|
116
|
+
return existing;
|
|
117
|
+
}
|
|
118
|
+
const store = new AsyncLocalStorage;
|
|
119
|
+
globalRecord[symbol] = store;
|
|
120
|
+
return store;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ../../src/core/auth/authContext.ts
|
|
124
|
+
var authContext = createAsyncContextStore("@getstrata/authContext");
|
|
112
125
|
function currentAuthUser() {
|
|
113
126
|
return authContext.getStore() ?? null;
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
// ../../src/core/tenant/tenantContext.ts
|
|
117
|
-
|
|
118
|
-
var tenantContext = new AsyncLocalStorage2;
|
|
130
|
+
var tenantContext = createAsyncContextStore("@getstrata/tenantContext");
|
|
119
131
|
function currentTenant() {
|
|
120
132
|
return tenantContext.getStore() ?? null;
|
|
121
133
|
}
|
|
@@ -19,9 +19,22 @@ function getBoundDatabaseConnection() {
|
|
|
19
19
|
return boundConnectionHolder.connection;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// ../../src/core/
|
|
22
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
23
23
|
import { AsyncLocalStorage } from "async_hooks";
|
|
24
|
-
|
|
24
|
+
function createAsyncContextStore(key) {
|
|
25
|
+
const symbol = Symbol.for(key);
|
|
26
|
+
const globalRecord = globalThis;
|
|
27
|
+
const existing = globalRecord[symbol];
|
|
28
|
+
if (existing) {
|
|
29
|
+
return existing;
|
|
30
|
+
}
|
|
31
|
+
const store = new AsyncLocalStorage;
|
|
32
|
+
globalRecord[symbol] = store;
|
|
33
|
+
return store;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ../../src/core/database/connectionContext.ts
|
|
37
|
+
var activeConnection = createAsyncContextStore("@getstrata/databaseConnectionContext");
|
|
25
38
|
function getActiveDatabaseConnection(fallback) {
|
|
26
39
|
return activeConnection.getStore() ?? fallback;
|
|
27
40
|
}
|