@getstrata/bootstrap 0.2.22 → 0.2.23
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/applicationRegistry.d.ts +1 -1
- package/dist/bootstrap/buildModuleRoutes.d.ts +10 -0
- package/dist/bootstrap/config.d.ts +1 -1
- package/dist/bootstrap/contracts.d.ts +4 -4
- package/dist/bootstrap/public-api.d.ts +2 -0
- package/dist/entries/applicationRegistry.js +12 -115
- package/dist/entries/buildModuleRoutes.js +626 -0
- package/dist/entries/config.js +9 -9
- package/dist/entries/context.js +114 -178
- package/dist/entries/contracts.js +10 -85
- package/dist/entries/createWebRoutes.js +9 -9
- package/dist/entries/dependencies.js +114 -178
- package/dist/entries/http/securedRouteModelBinding.js +4 -34
- package/dist/entries/httpKernel.js +9 -9
- package/dist/entries/membershipService.js +0 -34
- package/dist/entries/providers/view.js +9 -9
- package/dist/entries/providers.js +104 -115
- package/dist/entries/queue/defaultJobs.js +0 -34
- package/dist/entries/web/routing.js +20 -41
- package/dist/index.js +1670 -1659
- package/package.json +9 -4
- package/dist/cli/commands/scheduleRun.d.ts +0 -3
- package/dist/config/app.d.ts +0 -10
- package/dist/config/auth.d.ts +0 -7
- package/dist/config/contentSecurityPolicy.d.ts +0 -5
- package/dist/config/cors.d.ts +0 -9
- package/dist/config/database.d.ts +0 -10
- package/dist/config/features.d.ts +0 -18
- package/dist/config/frontend.d.ts +0 -6
- package/dist/config/queue.d.ts +0 -8
- package/dist/config/rateLimit.d.ts +0 -10
- package/dist/config/uploads.d.ts +0 -5
- package/dist/core/admin/formatValue.d.ts +0 -3
- package/dist/core/admin/index.d.ts +0 -3
- package/dist/core/admin/registry.d.ts +0 -11
- package/dist/core/admin/types.d.ts +0 -24
- package/dist/core/audit/exportAuditLogs.d.ts +0 -8
- package/dist/core/audit/siemFormatter.d.ts +0 -30
- package/dist/core/auth/abilityChecker.d.ts +0 -6
- package/dist/core/auth/accessControl.d.ts +0 -8
- package/dist/core/auth/authContext.d.ts +0 -11
- package/dist/core/auth/guard.d.ts +0 -36
- package/dist/core/auth/membershipContext.d.ts +0 -15
- package/dist/core/auth/membershipContextMiddleware.d.ts +0 -3
- package/dist/core/auth/membershipMiddleware.d.ts +0 -2
- package/dist/core/auth/membershipScope.d.ts +0 -16
- package/dist/core/auth/membershipService.d.ts +0 -23
- package/dist/core/auth/oauth/oidcProvider.d.ts +0 -18
- package/dist/core/auth/oauth/providers.d.ts +0 -22
- package/dist/core/auth/oauth/samlProvider.d.ts +0 -9
- package/dist/core/auth/oauth/types.d.ts +0 -11
- package/dist/core/auth/password.d.ts +0 -3
- package/dist/core/auth/policy.d.ts +0 -15
- package/dist/core/auth/resolveMembershipService.d.ts +0 -3
- package/dist/core/auth/scimAuthMiddleware.d.ts +0 -3
- package/dist/core/auth/sessionCookie.d.ts +0 -6
- package/dist/core/auth/sessionGuard.d.ts +0 -9
- package/dist/core/auth/tokenHash.d.ts +0 -3
- package/dist/core/cache/createCacheStore.d.ts +0 -11
- package/dist/core/cache/redisCacheStore.d.ts +0 -23
- package/dist/core/cache/repository.d.ts +0 -17
- package/dist/core/cache/simpleCache.d.ts +0 -23
- package/dist/core/cache/simpleCacheStore.d.ts +0 -16
- package/dist/core/cache/store.d.ts +0 -12
- package/dist/core/cache/taggedCache.d.ts +0 -9
- package/dist/core/cache/tags.d.ts +0 -11
- package/dist/core/config/envSchema.d.ts +0 -12
- package/dist/core/contracts/container.d.ts +0 -30
- package/dist/core/contracts/di.d.ts +0 -31
- package/dist/core/contracts/serviceContainer.d.ts +0 -1
- package/dist/core/contracts/serviceTokens.d.ts +0 -8
- package/dist/core/crypto/fieldEncryption.d.ts +0 -13
- package/dist/core/crypto/mfaSecret.d.ts +0 -3
- package/dist/core/crypto/nonCryptographicHash.d.ts +0 -2
- package/dist/core/database/baseRepository.d.ts +0 -67
- package/dist/core/database/bindConnection.d.ts +0 -3
- package/dist/core/database/boundConnection.d.ts +0 -5
- package/dist/core/database/connection.d.ts +0 -7
- package/dist/core/database/connectionContext.d.ts +0 -8
- package/dist/core/database/defaultConnection.d.ts +0 -6
- package/dist/core/database/errors.d.ts +0 -12
- package/dist/core/database/index.d.ts +0 -18
- package/dist/core/database/migrations/advisoryLock.d.ts +0 -6
- package/dist/core/database/migrations/runner.d.ts +0 -25
- package/dist/core/database/migrations/types.d.ts +0 -15
- package/dist/core/database/model.d.ts +0 -57
- package/dist/core/database/query.d.ts +0 -63
- package/dist/core/database/queryProxy.d.ts +0 -3
- package/dist/core/database/relationships.d.ts +0 -100
- package/dist/core/database/repositoryConnection.d.ts +0 -4
- package/dist/core/database/repositoryQuery.d.ts +0 -38
- package/dist/core/database/schema/blueprint.d.ts +0 -47
- package/dist/core/database/schema/columnDefinition.d.ts +0 -36
- package/dist/core/database/schema/driver.d.ts +0 -8
- package/dist/core/database/schema/errors.d.ts +0 -4
- package/dist/core/database/schema/grammars/compileStatements.d.ts +0 -8
- package/dist/core/database/schema/grammars/createGrammar.d.ts +0 -4
- package/dist/core/database/schema/grammars/grammar.d.ts +0 -10
- package/dist/core/database/schema/grammars/index.d.ts +0 -7
- package/dist/core/database/schema/grammars/mysqlGrammar.d.ts +0 -2
- package/dist/core/database/schema/grammars/postgresGrammar.d.ts +0 -2
- package/dist/core/database/schema/grammars/sqliteGrammar.d.ts +0 -2
- package/dist/core/database/schema/index.d.ts +0 -12
- package/dist/core/database/schema/schema.d.ts +0 -21
- package/dist/core/database/seeders/runner.d.ts +0 -6
- package/dist/core/database/seeders/types.d.ts +0 -8
- package/dist/core/database/table.d.ts +0 -13
- package/dist/core/database/transaction.d.ts +0 -3
- package/dist/core/database/types.d.ts +0 -66
- package/dist/core/database/whereBuilder.d.ts +0 -17
- package/dist/core/errors/http.d.ts +0 -33
- package/dist/core/events/eventBus.d.ts +0 -10
- package/dist/core/events/index.d.ts +0 -4
- package/dist/core/facades/index.d.ts +0 -10
- package/dist/core/http/authMiddleware.d.ts +0 -5
- package/dist/core/http/authorizeMiddleware.d.ts +0 -5
- package/dist/core/http/bodySizeLimitMiddleware.d.ts +0 -4
- package/dist/core/http/conditionalResponse.d.ts +0 -2
- package/dist/core/http/contentNegotiation.d.ts +0 -2
- package/dist/core/http/cookies.d.ts +0 -4
- package/dist/core/http/corsMiddleware.d.ts +0 -3
- package/dist/core/http/csrfMiddleware.d.ts +0 -3
- package/dist/core/http/csrfProtection.d.ts +0 -12
- package/dist/core/http/csrfToken.d.ts +0 -14
- package/dist/core/http/etag.d.ts +0 -18
- package/dist/core/http/flashMiddleware.d.ts +0 -3
- package/dist/core/http/flashSession.d.ts +0 -12
- package/dist/core/http/formRequest.d.ts +0 -10
- package/dist/core/http/index.d.ts +0 -27
- package/dist/core/http/loginThrottleMiddleware.d.ts +0 -11
- package/dist/core/http/memoryThrottleMiddleware.d.ts +0 -9
- package/dist/core/http/metricsMiddleware.d.ts +0 -4
- package/dist/core/http/middleware.d.ts +0 -8
- package/dist/core/http/pagination.d.ts +0 -11
- package/dist/core/http/parseFormBody.d.ts +0 -6
- package/dist/core/http/parseMultipartUpload.d.ts +0 -10
- package/dist/core/http/requestMetaContext.d.ts +0 -15
- package/dist/core/http/requireAbilityMiddleware.d.ts +0 -4
- package/dist/core/http/requireAuthMiddleware.d.ts +0 -4
- package/dist/core/http/requireGlobalAdminMiddleware.d.ts +0 -3
- package/dist/core/http/requireWebAuthMiddleware.d.ts +0 -4
- package/dist/core/http/resources.d.ts +0 -7
- package/dist/core/http/route.d.ts +0 -6
- package/dist/core/http/routeMiddleware.d.ts +0 -3
- package/dist/core/http/routeModelBinding.d.ts +0 -3
- package/dist/core/http/scimThrottleMiddleware.d.ts +0 -9
- package/dist/core/http/securedRouteModelBinding.d.ts +0 -11
- package/dist/core/http/securityHeadersMiddleware.d.ts +0 -3
- package/dist/core/http/throttleMiddleware.d.ts +0 -11
- package/dist/core/http/validation.d.ts +0 -23
- package/dist/core/http/webErrorResponse.d.ts +0 -5
- package/dist/core/http/webFormRequest.d.ts +0 -7
- package/dist/core/jobs/dispatchWebhookJob.d.ts +0 -13
- package/dist/core/jobs/invalidateCacheTagsJob.d.ts +0 -12
- package/dist/core/lifecycle/gracefulShutdown.d.ts +0 -6
- package/dist/core/logging/logger.d.ts +0 -17
- package/dist/core/logging/requestLoggingMiddleware.d.ts +0 -3
- package/dist/core/mail/mailer.d.ts +0 -38
- package/dist/core/mail/markdownMail.d.ts +0 -15
- package/dist/core/mail/markdownMailable.d.ts +0 -12
- package/dist/core/metrics/prometheus.d.ts +0 -26
- package/dist/core/notifications/dispatcher.d.ts +0 -13
- package/dist/core/notifications/index.d.ts +0 -3
- package/dist/core/notifications/notification.d.ts +0 -7
- package/dist/core/notifications/types.d.ts +0 -25
- package/dist/core/openapi/registeredRoute.d.ts +0 -6
- package/dist/core/pagination/index.d.ts +0 -27
- package/dist/core/queue/createAppQueue.d.ts +0 -5
- package/dist/core/queue/failedJobRepository.d.ts +0 -6
- package/dist/core/queue/failedJobService.d.ts +0 -16
- package/dist/core/queue/failedJobTable.d.ts +0 -3
- package/dist/core/queue/index.d.ts +0 -19
- package/dist/core/queue/jobRegistry.d.ts +0 -13
- package/dist/core/queue/jobRunner.d.ts +0 -9
- package/dist/core/queue/publicQueue.d.ts +0 -16
- package/dist/core/queue/queueMetrics.d.ts +0 -15
- package/dist/core/queue/redisQueue.d.ts +0 -29
- package/dist/core/queue/resilientQueue.d.ts +0 -9
- package/dist/core/queue/types.d.ts +0 -8
- package/dist/core/runtime/applicationRegistry.d.ts +0 -17
- package/dist/core/runtime/asyncContextStore.d.ts +0 -3
- package/dist/core/scheduler/schedule.d.ts +0 -15
- package/dist/core/security/publicReads.d.ts +0 -3
- package/dist/core/security/safeFetch.d.ts +0 -10
- package/dist/core/security/safeUrl.d.ts +0 -20
- package/dist/core/security/scimTenantTokens.d.ts +0 -3
- package/dist/core/security/securityEvents.d.ts +0 -6
- package/dist/core/security/timingSafeCompare.d.ts +0 -2
- package/dist/core/security/tokenExpiry.d.ts +0 -2
- package/dist/core/security/totp.d.ts +0 -3
- package/dist/core/storage/storage.d.ts +0 -44
- package/dist/core/tenant/databaseTenantContext.d.ts +0 -2
- package/dist/core/tenant/resolveTenant.d.ts +0 -3
- package/dist/core/tenant/tenantContext.d.ts +0 -13
- package/dist/core/tenant/tenantDatabaseScope.d.ts +0 -8
- package/dist/core/tenant/tenantMiddleware.d.ts +0 -6
- package/dist/core/tracing/otel.d.ts +0 -26
- package/dist/core/tracing/traceContext.d.ts +0 -9
- package/dist/core/tracing/tracingMiddleware.d.ts +0 -3
- package/dist/core/validation/rules.d.ts +0 -17
- package/dist/core/view/etaViewEngine.d.ts +0 -15
- package/dist/core/view/htmlResponse.d.ts +0 -6
- package/dist/core/view/index.d.ts +0 -5
- package/dist/core/view/viewEngine.d.ts +0 -6
- package/dist/core/view/webLayoutData.d.ts +0 -17
- package/dist/db/connection/createConnection.d.ts +0 -6
- package/dist/db/connection/index.d.ts +0 -11
- package/dist/domain/abilities.d.ts +0 -5
- package/dist/domain/auth.d.ts +0 -4
- package/dist/domain/scim.d.ts +0 -9
- package/dist/domain/workhub.d.ts +0 -35
- package/dist/framework/public-api.d.ts +0 -116
- package/dist/modules/organization/memberRepository.d.ts +0 -14
- package/dist/modules/organization/memberTypes.d.ts +0 -9
- package/dist/modules/organization/repository.d.ts +0 -14
- package/dist/modules/organization/table.d.ts +0 -3
- package/dist/modules/organization/types.d.ts +0 -10
- package/dist/modules/scim/controller.d.ts +0 -16
- package/dist/modules/scim/scimResponse.d.ts +0 -10
- package/dist/modules/scim/service.d.ts +0 -214
- package/dist/modules/user/apiTokenRepository.d.ts +0 -8
- package/dist/modules/user/apiTokenTable.d.ts +0 -3
- package/dist/modules/user/authService.d.ts +0 -23
- package/dist/modules/user/notificationRepository.d.ts +0 -6
- package/dist/modules/user/notificationService.d.ts +0 -25
- package/dist/modules/user/notificationTable.d.ts +0 -3
- package/dist/modules/user/notificationTypes.d.ts +0 -12
- package/dist/modules/user/oauthIdentityRepository.d.ts +0 -9
- package/dist/modules/user/provider.d.ts +0 -11
- package/dist/modules/user/repository.d.ts +0 -13
- package/dist/modules/user/table.d.ts +0 -3
- package/dist/modules/user/tokenService.d.ts +0 -29
- package/dist/modules/user/types.d.ts +0 -46
- package/dist/types/services.d.ts +0 -16
|
@@ -1,183 +1,28 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// ../../src/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
function assertAppDependenciesComplete(dependencies) {
|
|
16
|
-
for (const key of requiredDependencyKeys) {
|
|
17
|
-
getRequiredDependency(dependencies, key);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function resolveService(dependencies, token) {
|
|
21
|
-
return dependencies.container.resolve(token);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ../../src/core/contracts/serviceTokens.ts
|
|
25
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
26
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
27
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
28
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
29
|
-
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
30
|
-
var CORE_AUTH_TOKEN = "core.auth";
|
|
31
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
32
|
-
|
|
33
|
-
// ../../src/core/logging/logger.ts
|
|
34
|
-
class Logger {
|
|
35
|
-
channel;
|
|
36
|
-
constructor(channel = "app") {
|
|
37
|
-
this.channel = channel;
|
|
38
|
-
}
|
|
39
|
-
write(level, message, context = {}) {
|
|
40
|
-
const entry = {
|
|
41
|
-
level,
|
|
42
|
-
channel: this.channel,
|
|
43
|
-
message,
|
|
44
|
-
timestamp: new Date().toISOString(),
|
|
45
|
-
...context
|
|
46
|
-
};
|
|
47
|
-
const line = JSON.stringify(entry);
|
|
48
|
-
if (level === "error") {
|
|
49
|
-
console.error(line);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
console.log(line);
|
|
53
|
-
}
|
|
54
|
-
debug(message, context) {
|
|
55
|
-
this.write("debug", message, context);
|
|
56
|
-
}
|
|
57
|
-
info(message, context) {
|
|
58
|
-
this.write("info", message, context);
|
|
59
|
-
}
|
|
60
|
-
warn(message, context) {
|
|
61
|
-
this.write("warn", message, context);
|
|
62
|
-
}
|
|
63
|
-
error(message, context) {
|
|
64
|
-
this.write("error", message, context);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
var appLogger = new Logger("app");
|
|
2
|
+
// ../../src/bootstrap/applicationRegistry.ts
|
|
3
|
+
import {
|
|
4
|
+
resolveApplicationAuth,
|
|
5
|
+
resolveApplicationCache,
|
|
6
|
+
resolveApplicationConfig,
|
|
7
|
+
resolveApplicationDependencies,
|
|
8
|
+
resolveApplicationEventBus,
|
|
9
|
+
resolveApplicationLogger,
|
|
10
|
+
resolveApplicationPolicyGate,
|
|
11
|
+
resolveApplicationQueue,
|
|
12
|
+
setActiveApplicationContext
|
|
13
|
+
} from "@getstrata/core/runtime/applicationRegistry.ts";
|
|
68
14
|
|
|
69
|
-
// ../../src/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
return activeContext;
|
|
81
|
-
}
|
|
82
|
-
function setActiveApplicationContext(context) {
|
|
83
|
-
activeContext = context;
|
|
84
|
-
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
85
|
-
}
|
|
86
|
-
function requireActiveApplicationContext() {
|
|
87
|
-
const context = readStoredApplicationContext();
|
|
88
|
-
if (!context) {
|
|
89
|
-
throw new Error("The application context has not been bootstrapped.");
|
|
90
|
-
}
|
|
91
|
-
return context;
|
|
92
|
-
}
|
|
93
|
-
function resolveApplicationCache() {
|
|
94
|
-
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
95
|
-
}
|
|
96
|
-
function resolveApplicationQueue() {
|
|
97
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
98
|
-
}
|
|
99
|
-
function resolveApplicationEventBus() {
|
|
100
|
-
return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
|
|
101
|
-
}
|
|
102
|
-
function resolveApplicationAuth() {
|
|
103
|
-
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
104
|
-
}
|
|
105
|
-
function resolveApplicationPolicyGate() {
|
|
106
|
-
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
107
|
-
}
|
|
108
|
-
function resolveApplicationConfig() {
|
|
109
|
-
return requireActiveApplicationContext().config;
|
|
110
|
-
}
|
|
111
|
-
function resolveApplicationLogger() {
|
|
112
|
-
return appLogger;
|
|
113
|
-
}
|
|
114
|
-
function resolveApplicationDependencies() {
|
|
115
|
-
return requireActiveApplicationContext().dependencies;
|
|
116
|
-
}
|
|
117
|
-
// ../../src/core/contracts/container.ts
|
|
118
|
-
class ServiceContainer {
|
|
119
|
-
services = new Map;
|
|
120
|
-
singletonFactories = new Map;
|
|
121
|
-
bindings = new Map;
|
|
122
|
-
set(key, value) {
|
|
123
|
-
this.singletonFactories.delete(key);
|
|
124
|
-
this.bindings.delete(key);
|
|
125
|
-
this.services.set(key, value);
|
|
126
|
-
return value;
|
|
127
|
-
}
|
|
128
|
-
singleton(key, factory) {
|
|
129
|
-
this.bindings.delete(key);
|
|
130
|
-
this.services.delete(key);
|
|
131
|
-
this.singletonFactories.set(key, factory);
|
|
132
|
-
}
|
|
133
|
-
bind(key, factory) {
|
|
134
|
-
this.singletonFactories.delete(key);
|
|
135
|
-
this.services.delete(key);
|
|
136
|
-
this.bindings.set(key, factory);
|
|
137
|
-
}
|
|
138
|
-
get(key) {
|
|
139
|
-
if (this.services.has(key)) {
|
|
140
|
-
return this.services.get(key);
|
|
141
|
-
}
|
|
142
|
-
const singletonFactory = this.singletonFactories.get(key);
|
|
143
|
-
if (singletonFactory) {
|
|
144
|
-
const value = singletonFactory(this);
|
|
145
|
-
this.services.set(key, value);
|
|
146
|
-
return value;
|
|
147
|
-
}
|
|
148
|
-
const binding = this.bindings.get(key);
|
|
149
|
-
if (binding) {
|
|
150
|
-
return binding(this);
|
|
151
|
-
}
|
|
152
|
-
throw new Error(`Service "${key}" is not registered.`);
|
|
153
|
-
}
|
|
154
|
-
resolve(key) {
|
|
155
|
-
return this.get(key);
|
|
156
|
-
}
|
|
157
|
-
has(key) {
|
|
158
|
-
return this.services.has(key) || this.singletonFactories.has(key) || this.bindings.has(key);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
15
|
+
// ../../src/bootstrap/contracts.ts
|
|
16
|
+
import {
|
|
17
|
+
ConfigStore,
|
|
18
|
+
ServiceContainer
|
|
19
|
+
} from "@getstrata/core/contracts/container";
|
|
20
|
+
import {
|
|
21
|
+
assertAppDependenciesComplete,
|
|
22
|
+
getRequiredDependency,
|
|
23
|
+
resolveService
|
|
24
|
+
} from "@getstrata/core/contracts/di";
|
|
161
25
|
|
|
162
|
-
class ConfigStore {
|
|
163
|
-
values = new Map;
|
|
164
|
-
set(key, value) {
|
|
165
|
-
this.values.set(key, value);
|
|
166
|
-
return value;
|
|
167
|
-
}
|
|
168
|
-
get(key) {
|
|
169
|
-
return this.values.get(key);
|
|
170
|
-
}
|
|
171
|
-
require(key) {
|
|
172
|
-
if (!this.values.has(key)) {
|
|
173
|
-
throw new Error(`Config key "${key}" is not defined.`);
|
|
174
|
-
}
|
|
175
|
-
return this.values.get(key);
|
|
176
|
-
}
|
|
177
|
-
has(key) {
|
|
178
|
-
return this.values.has(key);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
26
|
// ../../src/bootstrap/discoverModules.ts
|
|
182
27
|
import { readdirSync } from "fs";
|
|
183
28
|
import { join } from "path";
|
|
@@ -282,6 +127,15 @@ function resolveAbilitiesForRole(role) {
|
|
|
282
127
|
}
|
|
283
128
|
|
|
284
129
|
// ../../src/bootstrap/config.ts
|
|
130
|
+
import {
|
|
131
|
+
CORE_AUTH_TOKEN,
|
|
132
|
+
CORE_CACHE_TOKEN,
|
|
133
|
+
CORE_CONFIG_TOKEN,
|
|
134
|
+
CORE_EVENT_BUS_TOKEN,
|
|
135
|
+
CORE_POLICY_GATE_TOKEN,
|
|
136
|
+
CORE_QUEUE_TOKEN,
|
|
137
|
+
CORE_TOKEN_SERVICE_TOKEN
|
|
138
|
+
} from "@getstrata/core/contracts/serviceTokens.ts";
|
|
285
139
|
var APP_PORT_CONFIG_KEY = "app.port";
|
|
286
140
|
var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
|
|
287
141
|
var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
|
|
@@ -3767,10 +3621,92 @@ class DispatchWebhookJob extends Job {
|
|
|
3767
3621
|
}
|
|
3768
3622
|
var dispatchWebhookJob_default = DispatchWebhookJob;
|
|
3769
3623
|
|
|
3624
|
+
// ../../src/core/contracts/di.ts
|
|
3625
|
+
function getRequiredDependency2(dependencies, key) {
|
|
3626
|
+
const dependency = dependencies[key];
|
|
3627
|
+
if (dependency === undefined) {
|
|
3628
|
+
throw new Error(`Required dependency "${key}" is not registered.`);
|
|
3629
|
+
}
|
|
3630
|
+
return dependency;
|
|
3631
|
+
}
|
|
3632
|
+
|
|
3633
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
3634
|
+
var CORE_POLICY_GATE_TOKEN2 = "core.policyGate";
|
|
3635
|
+
var CORE_AUTH_TOKEN2 = "core.auth";
|
|
3636
|
+
|
|
3637
|
+
// ../../src/core/logging/logger.ts
|
|
3638
|
+
class Logger {
|
|
3639
|
+
channel;
|
|
3640
|
+
constructor(channel = "app") {
|
|
3641
|
+
this.channel = channel;
|
|
3642
|
+
}
|
|
3643
|
+
write(level, message, context = {}) {
|
|
3644
|
+
const entry = {
|
|
3645
|
+
level,
|
|
3646
|
+
channel: this.channel,
|
|
3647
|
+
message,
|
|
3648
|
+
timestamp: new Date().toISOString(),
|
|
3649
|
+
...context
|
|
3650
|
+
};
|
|
3651
|
+
const line = JSON.stringify(entry);
|
|
3652
|
+
if (level === "error") {
|
|
3653
|
+
console.error(line);
|
|
3654
|
+
return;
|
|
3655
|
+
}
|
|
3656
|
+
console.log(line);
|
|
3657
|
+
}
|
|
3658
|
+
debug(message, context) {
|
|
3659
|
+
this.write("debug", message, context);
|
|
3660
|
+
}
|
|
3661
|
+
info(message, context) {
|
|
3662
|
+
this.write("info", message, context);
|
|
3663
|
+
}
|
|
3664
|
+
warn(message, context) {
|
|
3665
|
+
this.write("warn", message, context);
|
|
3666
|
+
}
|
|
3667
|
+
error(message, context) {
|
|
3668
|
+
this.write("error", message, context);
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
var appLogger = new Logger("app");
|
|
3672
|
+
|
|
3673
|
+
// ../../src/core/runtime/applicationRegistry.ts
|
|
3674
|
+
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
3675
|
+
var activeContext;
|
|
3676
|
+
function readStoredApplicationContext() {
|
|
3677
|
+
if (activeContext) {
|
|
3678
|
+
return activeContext;
|
|
3679
|
+
}
|
|
3680
|
+
const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
|
|
3681
|
+
if (globalContext) {
|
|
3682
|
+
activeContext = globalContext;
|
|
3683
|
+
}
|
|
3684
|
+
return activeContext;
|
|
3685
|
+
}
|
|
3686
|
+
function requireActiveApplicationContext() {
|
|
3687
|
+
const context = readStoredApplicationContext();
|
|
3688
|
+
if (!context) {
|
|
3689
|
+
throw new Error("The application context has not been bootstrapped.");
|
|
3690
|
+
}
|
|
3691
|
+
return context;
|
|
3692
|
+
}
|
|
3693
|
+
function resolveApplicationCache2() {
|
|
3694
|
+
return getRequiredDependency2(requireActiveApplicationContext().dependencies, "cache");
|
|
3695
|
+
}
|
|
3696
|
+
function resolveApplicationAuth2() {
|
|
3697
|
+
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN2);
|
|
3698
|
+
}
|
|
3699
|
+
function resolveApplicationPolicyGate2() {
|
|
3700
|
+
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN2);
|
|
3701
|
+
}
|
|
3702
|
+
function resolveApplicationDependencies2() {
|
|
3703
|
+
return requireActiveApplicationContext().dependencies;
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3770
3706
|
// ../../src/bootstrap/queue/defaultJobs.ts
|
|
3771
3707
|
function registerDefaultJobs() {
|
|
3772
3708
|
jobRegistry.register("cache.invalidate-tags", () => {
|
|
3773
|
-
return new invalidateCacheTagsJob_default(
|
|
3709
|
+
return new invalidateCacheTagsJob_default(resolveApplicationCache2());
|
|
3774
3710
|
});
|
|
3775
3711
|
jobRegistry.register("webhook.dispatch", () => new dispatchWebhookJob_default);
|
|
3776
3712
|
}
|
|
@@ -65,11 +65,6 @@ class PreconditionFailedError extends HttpError {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// ../../src/core/contracts/di.ts
|
|
68
|
-
var requiredDependencyKeys = [
|
|
69
|
-
"container",
|
|
70
|
-
"cache",
|
|
71
|
-
"storage"
|
|
72
|
-
];
|
|
73
68
|
function getRequiredDependency(dependencies, key) {
|
|
74
69
|
const dependency = dependencies[key];
|
|
75
70
|
if (dependency === undefined) {
|
|
@@ -77,23 +72,10 @@ function getRequiredDependency(dependencies, key) {
|
|
|
77
72
|
}
|
|
78
73
|
return dependency;
|
|
79
74
|
}
|
|
80
|
-
function assertAppDependenciesComplete(dependencies) {
|
|
81
|
-
for (const key of requiredDependencyKeys) {
|
|
82
|
-
getRequiredDependency(dependencies, key);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function resolveService(dependencies, token) {
|
|
86
|
-
return dependencies.container.resolve(token);
|
|
87
|
-
}
|
|
88
75
|
|
|
89
76
|
// ../../src/core/contracts/serviceTokens.ts
|
|
90
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
91
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
92
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
93
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
94
77
|
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
95
78
|
var CORE_AUTH_TOKEN = "core.auth";
|
|
96
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
97
79
|
|
|
98
80
|
// ../../src/core/logging/logger.ts
|
|
99
81
|
class Logger {
|
|
@@ -144,10 +126,6 @@ function readStoredApplicationContext() {
|
|
|
144
126
|
}
|
|
145
127
|
return activeContext;
|
|
146
128
|
}
|
|
147
|
-
function setActiveApplicationContext(context) {
|
|
148
|
-
activeContext = context;
|
|
149
|
-
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
150
|
-
}
|
|
151
129
|
function requireActiveApplicationContext() {
|
|
152
130
|
const context = readStoredApplicationContext();
|
|
153
131
|
if (!context) {
|
|
@@ -158,24 +136,12 @@ function requireActiveApplicationContext() {
|
|
|
158
136
|
function resolveApplicationCache() {
|
|
159
137
|
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
160
138
|
}
|
|
161
|
-
function resolveApplicationQueue() {
|
|
162
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
163
|
-
}
|
|
164
|
-
function resolveApplicationEventBus() {
|
|
165
|
-
return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
|
|
166
|
-
}
|
|
167
139
|
function resolveApplicationAuth() {
|
|
168
140
|
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
169
141
|
}
|
|
170
142
|
function resolveApplicationPolicyGate() {
|
|
171
143
|
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
172
144
|
}
|
|
173
|
-
function resolveApplicationConfig() {
|
|
174
|
-
return requireActiveApplicationContext().config;
|
|
175
|
-
}
|
|
176
|
-
function resolveApplicationLogger() {
|
|
177
|
-
return appLogger;
|
|
178
|
-
}
|
|
179
145
|
function resolveApplicationDependencies() {
|
|
180
146
|
return requireActiveApplicationContext().dependencies;
|
|
181
147
|
}
|
|
@@ -192,6 +158,10 @@ function isEtagEnabled() {
|
|
|
192
158
|
function formatWeakEtag(digest) {
|
|
193
159
|
return `W/"${digest}"`;
|
|
194
160
|
}
|
|
161
|
+
function computeEtagFromJson(data) {
|
|
162
|
+
const digest = nonCryptographicDigest(JSON.stringify(data)).slice(0, 32);
|
|
163
|
+
return formatWeakEtag(digest);
|
|
164
|
+
}
|
|
195
165
|
function etagFromResource(resource) {
|
|
196
166
|
const version = resource.updated_at ?? resource.created_at ?? "";
|
|
197
167
|
const versionText = version instanceof Date ? version.toISOString() : version ? String(version) : "0";
|
|
@@ -74,16 +74,16 @@ function resolveRegisterRateLimit() {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// ../../src/core/contracts/serviceTokens.ts
|
|
78
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
79
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
80
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
81
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
82
|
-
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
83
|
-
var CORE_AUTH_TOKEN = "core.auth";
|
|
84
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
85
|
-
|
|
86
77
|
// ../../src/bootstrap/config.ts
|
|
78
|
+
import {
|
|
79
|
+
CORE_AUTH_TOKEN,
|
|
80
|
+
CORE_CACHE_TOKEN,
|
|
81
|
+
CORE_CONFIG_TOKEN,
|
|
82
|
+
CORE_EVENT_BUS_TOKEN,
|
|
83
|
+
CORE_POLICY_GATE_TOKEN,
|
|
84
|
+
CORE_QUEUE_TOKEN,
|
|
85
|
+
CORE_TOKEN_SERVICE_TOKEN
|
|
86
|
+
} from "@getstrata/core/contracts/serviceTokens.ts";
|
|
87
87
|
var APP_PORT_CONFIG_KEY = "app.port";
|
|
88
88
|
var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
|
|
89
89
|
var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// ../../src/core/contracts/di.ts
|
|
3
|
-
var requiredDependencyKeys = [
|
|
4
|
-
"container",
|
|
5
|
-
"cache",
|
|
6
|
-
"storage"
|
|
7
|
-
];
|
|
8
3
|
function getRequiredDependency(dependencies, key) {
|
|
9
4
|
const dependency = dependencies[key];
|
|
10
5
|
if (dependency === undefined) {
|
|
@@ -12,23 +7,10 @@ function getRequiredDependency(dependencies, key) {
|
|
|
12
7
|
}
|
|
13
8
|
return dependency;
|
|
14
9
|
}
|
|
15
|
-
function assertAppDependenciesComplete(dependencies) {
|
|
16
|
-
for (const key of requiredDependencyKeys) {
|
|
17
|
-
getRequiredDependency(dependencies, key);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function resolveService(dependencies, token) {
|
|
21
|
-
return dependencies.container.resolve(token);
|
|
22
|
-
}
|
|
23
10
|
|
|
24
11
|
// ../../src/core/contracts/serviceTokens.ts
|
|
25
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
26
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
27
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
28
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
29
12
|
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
30
13
|
var CORE_AUTH_TOKEN = "core.auth";
|
|
31
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
32
14
|
|
|
33
15
|
// ../../src/core/logging/logger.ts
|
|
34
16
|
class Logger {
|
|
@@ -79,10 +61,6 @@ function readStoredApplicationContext() {
|
|
|
79
61
|
}
|
|
80
62
|
return activeContext;
|
|
81
63
|
}
|
|
82
|
-
function setActiveApplicationContext(context) {
|
|
83
|
-
activeContext = context;
|
|
84
|
-
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
85
|
-
}
|
|
86
64
|
function requireActiveApplicationContext() {
|
|
87
65
|
const context = readStoredApplicationContext();
|
|
88
66
|
if (!context) {
|
|
@@ -93,24 +71,12 @@ function requireActiveApplicationContext() {
|
|
|
93
71
|
function resolveApplicationCache() {
|
|
94
72
|
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
95
73
|
}
|
|
96
|
-
function resolveApplicationQueue() {
|
|
97
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
98
|
-
}
|
|
99
|
-
function resolveApplicationEventBus() {
|
|
100
|
-
return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
|
|
101
|
-
}
|
|
102
74
|
function resolveApplicationAuth() {
|
|
103
75
|
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
104
76
|
}
|
|
105
77
|
function resolveApplicationPolicyGate() {
|
|
106
78
|
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
107
79
|
}
|
|
108
|
-
function resolveApplicationConfig() {
|
|
109
|
-
return requireActiveApplicationContext().config;
|
|
110
|
-
}
|
|
111
|
-
function resolveApplicationLogger() {
|
|
112
|
-
return appLogger;
|
|
113
|
-
}
|
|
114
80
|
function resolveApplicationDependencies() {
|
|
115
81
|
return requireActiveApplicationContext().dependencies;
|
|
116
82
|
}
|
|
@@ -79,16 +79,16 @@ function htmlResponse(html, init = {}) {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
// ../../src/core/contracts/serviceTokens.ts
|
|
83
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
84
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
85
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
86
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
87
|
-
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
88
|
-
var CORE_AUTH_TOKEN = "core.auth";
|
|
89
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
90
|
-
|
|
91
82
|
// ../../src/bootstrap/config.ts
|
|
83
|
+
import {
|
|
84
|
+
CORE_AUTH_TOKEN,
|
|
85
|
+
CORE_CACHE_TOKEN,
|
|
86
|
+
CORE_CONFIG_TOKEN,
|
|
87
|
+
CORE_EVENT_BUS_TOKEN,
|
|
88
|
+
CORE_POLICY_GATE_TOKEN,
|
|
89
|
+
CORE_QUEUE_TOKEN,
|
|
90
|
+
CORE_TOKEN_SERVICE_TOKEN
|
|
91
|
+
} from "@getstrata/core/contracts/serviceTokens.ts";
|
|
92
92
|
var APP_PORT_CONFIG_KEY = "app.port";
|
|
93
93
|
var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
|
|
94
94
|
var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
|