@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
|
@@ -43,16 +43,16 @@ function resolveAbilitiesForRole(role) {
|
|
|
43
43
|
return [...MEMBER_ABILITIES];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// ../../src/core/contracts/serviceTokens.ts
|
|
47
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
48
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
49
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
50
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
51
|
-
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
52
|
-
var CORE_AUTH_TOKEN = "core.auth";
|
|
53
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
54
|
-
|
|
55
46
|
// ../../src/bootstrap/config.ts
|
|
47
|
+
import {
|
|
48
|
+
CORE_AUTH_TOKEN,
|
|
49
|
+
CORE_CACHE_TOKEN,
|
|
50
|
+
CORE_CONFIG_TOKEN,
|
|
51
|
+
CORE_EVENT_BUS_TOKEN,
|
|
52
|
+
CORE_POLICY_GATE_TOKEN,
|
|
53
|
+
CORE_QUEUE_TOKEN,
|
|
54
|
+
CORE_TOKEN_SERVICE_TOKEN
|
|
55
|
+
} from "@getstrata/core/contracts/serviceTokens.ts";
|
|
56
56
|
var APP_PORT_CONFIG_KEY = "app.port";
|
|
57
57
|
var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
|
|
58
58
|
var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
|
|
@@ -3244,112 +3244,19 @@ function createAppQueue(driver, redisUrl, failedJobs = createFailedJobService(),
|
|
|
3244
3244
|
});
|
|
3245
3245
|
}
|
|
3246
3246
|
|
|
3247
|
-
// ../../src/
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
}
|
|
3260
|
-
function assertAppDependenciesComplete(dependencies) {
|
|
3261
|
-
for (const key of requiredDependencyKeys) {
|
|
3262
|
-
getRequiredDependency(dependencies, key);
|
|
3263
|
-
}
|
|
3264
|
-
}
|
|
3265
|
-
function resolveService(dependencies, token) {
|
|
3266
|
-
return dependencies.container.resolve(token);
|
|
3267
|
-
}
|
|
3268
|
-
|
|
3269
|
-
// ../../src/core/logging/logger.ts
|
|
3270
|
-
class Logger {
|
|
3271
|
-
channel;
|
|
3272
|
-
constructor(channel = "app") {
|
|
3273
|
-
this.channel = channel;
|
|
3274
|
-
}
|
|
3275
|
-
write(level, message, context = {}) {
|
|
3276
|
-
const entry = {
|
|
3277
|
-
level,
|
|
3278
|
-
channel: this.channel,
|
|
3279
|
-
message,
|
|
3280
|
-
timestamp: new Date().toISOString(),
|
|
3281
|
-
...context
|
|
3282
|
-
};
|
|
3283
|
-
const line = JSON.stringify(entry);
|
|
3284
|
-
if (level === "error") {
|
|
3285
|
-
console.error(line);
|
|
3286
|
-
return;
|
|
3287
|
-
}
|
|
3288
|
-
console.log(line);
|
|
3289
|
-
}
|
|
3290
|
-
debug(message, context) {
|
|
3291
|
-
this.write("debug", message, context);
|
|
3292
|
-
}
|
|
3293
|
-
info(message, context) {
|
|
3294
|
-
this.write("info", message, context);
|
|
3295
|
-
}
|
|
3296
|
-
warn(message, context) {
|
|
3297
|
-
this.write("warn", message, context);
|
|
3298
|
-
}
|
|
3299
|
-
error(message, context) {
|
|
3300
|
-
this.write("error", message, context);
|
|
3301
|
-
}
|
|
3302
|
-
}
|
|
3303
|
-
var appLogger = new Logger("app");
|
|
3247
|
+
// ../../src/bootstrap/applicationRegistry.ts
|
|
3248
|
+
import {
|
|
3249
|
+
resolveApplicationAuth,
|
|
3250
|
+
resolveApplicationCache,
|
|
3251
|
+
resolveApplicationConfig,
|
|
3252
|
+
resolveApplicationDependencies,
|
|
3253
|
+
resolveApplicationEventBus,
|
|
3254
|
+
resolveApplicationLogger,
|
|
3255
|
+
resolveApplicationPolicyGate,
|
|
3256
|
+
resolveApplicationQueue,
|
|
3257
|
+
setActiveApplicationContext
|
|
3258
|
+
} from "@getstrata/core/runtime/applicationRegistry.ts";
|
|
3304
3259
|
|
|
3305
|
-
// ../../src/core/runtime/applicationRegistry.ts
|
|
3306
|
-
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
3307
|
-
var activeContext;
|
|
3308
|
-
function readStoredApplicationContext() {
|
|
3309
|
-
if (activeContext) {
|
|
3310
|
-
return activeContext;
|
|
3311
|
-
}
|
|
3312
|
-
const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
|
|
3313
|
-
if (globalContext) {
|
|
3314
|
-
activeContext = globalContext;
|
|
3315
|
-
}
|
|
3316
|
-
return activeContext;
|
|
3317
|
-
}
|
|
3318
|
-
function setActiveApplicationContext(context) {
|
|
3319
|
-
activeContext = context;
|
|
3320
|
-
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
3321
|
-
}
|
|
3322
|
-
function requireActiveApplicationContext() {
|
|
3323
|
-
const context = readStoredApplicationContext();
|
|
3324
|
-
if (!context) {
|
|
3325
|
-
throw new Error("The application context has not been bootstrapped.");
|
|
3326
|
-
}
|
|
3327
|
-
return context;
|
|
3328
|
-
}
|
|
3329
|
-
function resolveApplicationCache() {
|
|
3330
|
-
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
3331
|
-
}
|
|
3332
|
-
function resolveApplicationQueue() {
|
|
3333
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
3334
|
-
}
|
|
3335
|
-
function resolveApplicationEventBus() {
|
|
3336
|
-
return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
|
|
3337
|
-
}
|
|
3338
|
-
function resolveApplicationAuth() {
|
|
3339
|
-
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
3340
|
-
}
|
|
3341
|
-
function resolveApplicationPolicyGate() {
|
|
3342
|
-
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
3343
|
-
}
|
|
3344
|
-
function resolveApplicationConfig() {
|
|
3345
|
-
return requireActiveApplicationContext().config;
|
|
3346
|
-
}
|
|
3347
|
-
function resolveApplicationLogger() {
|
|
3348
|
-
return appLogger;
|
|
3349
|
-
}
|
|
3350
|
-
function resolveApplicationDependencies() {
|
|
3351
|
-
return requireActiveApplicationContext().dependencies;
|
|
3352
|
-
}
|
|
3353
3260
|
// ../../src/bootstrap/discoverModules.ts
|
|
3354
3261
|
import { readdirSync as readdirSync2 } from "fs";
|
|
3355
3262
|
import { join as join2 } from "path";
|
|
@@ -3704,10 +3611,92 @@ class DispatchWebhookJob extends Job {
|
|
|
3704
3611
|
}
|
|
3705
3612
|
var dispatchWebhookJob_default = DispatchWebhookJob;
|
|
3706
3613
|
|
|
3614
|
+
// ../../src/core/contracts/di.ts
|
|
3615
|
+
function getRequiredDependency(dependencies, key) {
|
|
3616
|
+
const dependency = dependencies[key];
|
|
3617
|
+
if (dependency === undefined) {
|
|
3618
|
+
throw new Error(`Required dependency "${key}" is not registered.`);
|
|
3619
|
+
}
|
|
3620
|
+
return dependency;
|
|
3621
|
+
}
|
|
3622
|
+
|
|
3623
|
+
// ../../src/core/contracts/serviceTokens.ts
|
|
3624
|
+
var CORE_POLICY_GATE_TOKEN2 = "core.policyGate";
|
|
3625
|
+
var CORE_AUTH_TOKEN2 = "core.auth";
|
|
3626
|
+
|
|
3627
|
+
// ../../src/core/logging/logger.ts
|
|
3628
|
+
class Logger {
|
|
3629
|
+
channel;
|
|
3630
|
+
constructor(channel = "app") {
|
|
3631
|
+
this.channel = channel;
|
|
3632
|
+
}
|
|
3633
|
+
write(level, message, context = {}) {
|
|
3634
|
+
const entry = {
|
|
3635
|
+
level,
|
|
3636
|
+
channel: this.channel,
|
|
3637
|
+
message,
|
|
3638
|
+
timestamp: new Date().toISOString(),
|
|
3639
|
+
...context
|
|
3640
|
+
};
|
|
3641
|
+
const line = JSON.stringify(entry);
|
|
3642
|
+
if (level === "error") {
|
|
3643
|
+
console.error(line);
|
|
3644
|
+
return;
|
|
3645
|
+
}
|
|
3646
|
+
console.log(line);
|
|
3647
|
+
}
|
|
3648
|
+
debug(message, context) {
|
|
3649
|
+
this.write("debug", message, context);
|
|
3650
|
+
}
|
|
3651
|
+
info(message, context) {
|
|
3652
|
+
this.write("info", message, context);
|
|
3653
|
+
}
|
|
3654
|
+
warn(message, context) {
|
|
3655
|
+
this.write("warn", message, context);
|
|
3656
|
+
}
|
|
3657
|
+
error(message, context) {
|
|
3658
|
+
this.write("error", message, context);
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
var appLogger = new Logger("app");
|
|
3662
|
+
|
|
3663
|
+
// ../../src/core/runtime/applicationRegistry.ts
|
|
3664
|
+
var APPLICATION_CONTEXT_KEY = Symbol.for("@getstrata/applicationContext");
|
|
3665
|
+
var activeContext;
|
|
3666
|
+
function readStoredApplicationContext() {
|
|
3667
|
+
if (activeContext) {
|
|
3668
|
+
return activeContext;
|
|
3669
|
+
}
|
|
3670
|
+
const globalContext = globalThis[APPLICATION_CONTEXT_KEY];
|
|
3671
|
+
if (globalContext) {
|
|
3672
|
+
activeContext = globalContext;
|
|
3673
|
+
}
|
|
3674
|
+
return activeContext;
|
|
3675
|
+
}
|
|
3676
|
+
function requireActiveApplicationContext() {
|
|
3677
|
+
const context = readStoredApplicationContext();
|
|
3678
|
+
if (!context) {
|
|
3679
|
+
throw new Error("The application context has not been bootstrapped.");
|
|
3680
|
+
}
|
|
3681
|
+
return context;
|
|
3682
|
+
}
|
|
3683
|
+
function resolveApplicationCache2() {
|
|
3684
|
+
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
3685
|
+
}
|
|
3686
|
+
function resolveApplicationAuth2() {
|
|
3687
|
+
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN2);
|
|
3688
|
+
}
|
|
3689
|
+
function resolveApplicationPolicyGate2() {
|
|
3690
|
+
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN2);
|
|
3691
|
+
}
|
|
3692
|
+
function resolveApplicationDependencies2() {
|
|
3693
|
+
return requireActiveApplicationContext().dependencies;
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3707
3696
|
// ../../src/bootstrap/queue/defaultJobs.ts
|
|
3708
3697
|
function registerDefaultJobs() {
|
|
3709
3698
|
jobRegistry.register("cache.invalidate-tags", () => {
|
|
3710
|
-
return new invalidateCacheTagsJob_default(
|
|
3699
|
+
return new invalidateCacheTagsJob_default(resolveApplicationCache2());
|
|
3711
3700
|
});
|
|
3712
3701
|
jobRegistry.register("webhook.dispatch", () => new dispatchWebhookJob_default);
|
|
3713
3702
|
}
|
|
@@ -385,11 +385,6 @@ function readSharedJobRegistry() {
|
|
|
385
385
|
var jobRegistry = readSharedJobRegistry();
|
|
386
386
|
|
|
387
387
|
// ../../src/core/contracts/di.ts
|
|
388
|
-
var requiredDependencyKeys = [
|
|
389
|
-
"container",
|
|
390
|
-
"cache",
|
|
391
|
-
"storage"
|
|
392
|
-
];
|
|
393
388
|
function getRequiredDependency(dependencies, key) {
|
|
394
389
|
const dependency = dependencies[key];
|
|
395
390
|
if (dependency === undefined) {
|
|
@@ -397,23 +392,10 @@ function getRequiredDependency(dependencies, key) {
|
|
|
397
392
|
}
|
|
398
393
|
return dependency;
|
|
399
394
|
}
|
|
400
|
-
function assertAppDependenciesComplete(dependencies) {
|
|
401
|
-
for (const key of requiredDependencyKeys) {
|
|
402
|
-
getRequiredDependency(dependencies, key);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
function resolveService(dependencies, token) {
|
|
406
|
-
return dependencies.container.resolve(token);
|
|
407
|
-
}
|
|
408
395
|
|
|
409
396
|
// ../../src/core/contracts/serviceTokens.ts
|
|
410
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
411
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
412
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
413
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
414
397
|
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
415
398
|
var CORE_AUTH_TOKEN = "core.auth";
|
|
416
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
417
399
|
|
|
418
400
|
// ../../src/core/logging/logger.ts
|
|
419
401
|
class Logger {
|
|
@@ -464,10 +446,6 @@ function readStoredApplicationContext() {
|
|
|
464
446
|
}
|
|
465
447
|
return activeContext;
|
|
466
448
|
}
|
|
467
|
-
function setActiveApplicationContext(context) {
|
|
468
|
-
activeContext = context;
|
|
469
|
-
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
470
|
-
}
|
|
471
449
|
function requireActiveApplicationContext() {
|
|
472
450
|
const context = readStoredApplicationContext();
|
|
473
451
|
if (!context) {
|
|
@@ -478,24 +456,12 @@ function requireActiveApplicationContext() {
|
|
|
478
456
|
function resolveApplicationCache() {
|
|
479
457
|
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
480
458
|
}
|
|
481
|
-
function resolveApplicationQueue() {
|
|
482
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
483
|
-
}
|
|
484
|
-
function resolveApplicationEventBus() {
|
|
485
|
-
return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
|
|
486
|
-
}
|
|
487
459
|
function resolveApplicationAuth() {
|
|
488
460
|
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
489
461
|
}
|
|
490
462
|
function resolveApplicationPolicyGate() {
|
|
491
463
|
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
492
464
|
}
|
|
493
|
-
function resolveApplicationConfig() {
|
|
494
|
-
return requireActiveApplicationContext().config;
|
|
495
|
-
}
|
|
496
|
-
function resolveApplicationLogger() {
|
|
497
|
-
return appLogger;
|
|
498
|
-
}
|
|
499
465
|
function resolveApplicationDependencies() {
|
|
500
466
|
return requireActiveApplicationContext().dependencies;
|
|
501
467
|
}
|
|
@@ -68,11 +68,6 @@ class PreconditionFailedError extends HttpError {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// ../../src/core/contracts/di.ts
|
|
71
|
-
var requiredDependencyKeys = [
|
|
72
|
-
"container",
|
|
73
|
-
"cache",
|
|
74
|
-
"storage"
|
|
75
|
-
];
|
|
76
71
|
function getRequiredDependency(dependencies, key) {
|
|
77
72
|
const dependency = dependencies[key];
|
|
78
73
|
if (dependency === undefined) {
|
|
@@ -80,23 +75,10 @@ function getRequiredDependency(dependencies, key) {
|
|
|
80
75
|
}
|
|
81
76
|
return dependency;
|
|
82
77
|
}
|
|
83
|
-
function assertAppDependenciesComplete(dependencies) {
|
|
84
|
-
for (const key of requiredDependencyKeys) {
|
|
85
|
-
getRequiredDependency(dependencies, key);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function resolveService(dependencies, token) {
|
|
89
|
-
return dependencies.container.resolve(token);
|
|
90
|
-
}
|
|
91
78
|
|
|
92
79
|
// ../../src/core/contracts/serviceTokens.ts
|
|
93
|
-
var CORE_CONFIG_TOKEN = "core.config";
|
|
94
|
-
var CORE_CACHE_TOKEN = "core.cache";
|
|
95
|
-
var CORE_QUEUE_TOKEN = "core.queue";
|
|
96
|
-
var CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
97
80
|
var CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
98
81
|
var CORE_AUTH_TOKEN = "core.auth";
|
|
99
|
-
var CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
100
82
|
|
|
101
83
|
// ../../src/core/logging/logger.ts
|
|
102
84
|
class Logger {
|
|
@@ -147,10 +129,6 @@ function readStoredApplicationContext() {
|
|
|
147
129
|
}
|
|
148
130
|
return activeContext;
|
|
149
131
|
}
|
|
150
|
-
function setActiveApplicationContext(context) {
|
|
151
|
-
activeContext = context;
|
|
152
|
-
globalThis[APPLICATION_CONTEXT_KEY] = context;
|
|
153
|
-
}
|
|
154
132
|
function requireActiveApplicationContext() {
|
|
155
133
|
const context = readStoredApplicationContext();
|
|
156
134
|
if (!context) {
|
|
@@ -161,24 +139,12 @@ function requireActiveApplicationContext() {
|
|
|
161
139
|
function resolveApplicationCache() {
|
|
162
140
|
return getRequiredDependency(requireActiveApplicationContext().dependencies, "cache");
|
|
163
141
|
}
|
|
164
|
-
function resolveApplicationQueue() {
|
|
165
|
-
return requireActiveApplicationContext().container.resolve(CORE_QUEUE_TOKEN);
|
|
166
|
-
}
|
|
167
|
-
function resolveApplicationEventBus() {
|
|
168
|
-
return requireActiveApplicationContext().container.resolve(CORE_EVENT_BUS_TOKEN);
|
|
169
|
-
}
|
|
170
142
|
function resolveApplicationAuth() {
|
|
171
143
|
return requireActiveApplicationContext().container.resolve(CORE_AUTH_TOKEN);
|
|
172
144
|
}
|
|
173
145
|
function resolveApplicationPolicyGate() {
|
|
174
146
|
return requireActiveApplicationContext().container.resolve(CORE_POLICY_GATE_TOKEN);
|
|
175
147
|
}
|
|
176
|
-
function resolveApplicationConfig() {
|
|
177
|
-
return requireActiveApplicationContext().config;
|
|
178
|
-
}
|
|
179
|
-
function resolveApplicationLogger() {
|
|
180
|
-
return appLogger;
|
|
181
|
-
}
|
|
182
148
|
function resolveApplicationDependencies() {
|
|
183
149
|
return requireActiveApplicationContext().dependencies;
|
|
184
150
|
}
|
|
@@ -195,6 +161,10 @@ function isEtagEnabled() {
|
|
|
195
161
|
function formatWeakEtag(digest) {
|
|
196
162
|
return `W/"${digest}"`;
|
|
197
163
|
}
|
|
164
|
+
function computeEtagFromJson(data) {
|
|
165
|
+
const digest = nonCryptographicDigest(JSON.stringify(data)).slice(0, 32);
|
|
166
|
+
return formatWeakEtag(digest);
|
|
167
|
+
}
|
|
198
168
|
function etagFromResource(resource) {
|
|
199
169
|
const version = resource.updated_at ?? resource.created_at ?? "";
|
|
200
170
|
const versionText = version instanceof Date ? version.toISOString() : version ? String(version) : "0";
|
|
@@ -409,6 +379,15 @@ function resolveRegisterRateLimit() {
|
|
|
409
379
|
}
|
|
410
380
|
|
|
411
381
|
// ../../src/bootstrap/config.ts
|
|
382
|
+
import {
|
|
383
|
+
CORE_AUTH_TOKEN as CORE_AUTH_TOKEN2,
|
|
384
|
+
CORE_CACHE_TOKEN,
|
|
385
|
+
CORE_CONFIG_TOKEN,
|
|
386
|
+
CORE_EVENT_BUS_TOKEN as CORE_EVENT_BUS_TOKEN2,
|
|
387
|
+
CORE_POLICY_GATE_TOKEN as CORE_POLICY_GATE_TOKEN2,
|
|
388
|
+
CORE_QUEUE_TOKEN as CORE_QUEUE_TOKEN2,
|
|
389
|
+
CORE_TOKEN_SERVICE_TOKEN
|
|
390
|
+
} from "@getstrata/core/contracts/serviceTokens.ts";
|
|
412
391
|
var APP_PORT_CONFIG_KEY = "app.port";
|
|
413
392
|
var CACHE_TTL_MS_CONFIG_KEY = "cache.ttlMs";
|
|
414
393
|
var CACHE_MAX_ENTRIES_CONFIG_KEY = "cache.maxEntries";
|
|
@@ -430,7 +409,7 @@ class HttpKernel {
|
|
|
430
409
|
this.dependencies = dependencies;
|
|
431
410
|
}
|
|
432
411
|
globalMiddleware() {
|
|
433
|
-
const auth = this.dependencies.container.resolve(
|
|
412
|
+
const auth = this.dependencies.container.resolve(CORE_AUTH_TOKEN2);
|
|
434
413
|
return [
|
|
435
414
|
createCorsMiddleware(),
|
|
436
415
|
createSecurityHeadersMiddleware(),
|
|
@@ -445,7 +424,7 @@ class HttpKernel {
|
|
|
445
424
|
];
|
|
446
425
|
}
|
|
447
426
|
group(name) {
|
|
448
|
-
const auth = this.dependencies.container.resolve(
|
|
427
|
+
const auth = this.dependencies.container.resolve(CORE_AUTH_TOKEN2);
|
|
449
428
|
switch (name) {
|
|
450
429
|
case "authenticated":
|
|
451
430
|
return [createRequireAuthMiddleware(auth)];
|
|
@@ -500,18 +479,18 @@ class HttpKernel {
|
|
|
500
479
|
return this.wrapWebAuthenticated(handler);
|
|
501
480
|
}
|
|
502
481
|
wrapWebAuthenticated(handler) {
|
|
503
|
-
const auth = this.dependencies.container.resolve(
|
|
482
|
+
const auth = this.dependencies.container.resolve(CORE_AUTH_TOKEN2);
|
|
504
483
|
return withMiddleware(createRequireWebAuthMiddleware(auth))(handler);
|
|
505
484
|
}
|
|
506
485
|
wrapWebAbility(ability, handler) {
|
|
507
|
-
const auth = this.dependencies.container.resolve(
|
|
486
|
+
const auth = this.dependencies.container.resolve(CORE_AUTH_TOKEN2);
|
|
508
487
|
const abilityChecker = this.dependencies.container.resolve(CORE_TOKEN_SERVICE_TOKEN);
|
|
509
488
|
const requireAbility = createRequireAbilityMiddleware(abilityChecker);
|
|
510
489
|
const middleware = [createRequireWebAuthMiddleware(auth), requireAbility(ability)];
|
|
511
490
|
return withMiddleware(...middleware)(handler);
|
|
512
491
|
}
|
|
513
492
|
wrapWebGlobalAdmin(handler) {
|
|
514
|
-
const auth = this.dependencies.container.resolve(
|
|
493
|
+
const auth = this.dependencies.container.resolve(CORE_AUTH_TOKEN2);
|
|
515
494
|
const middleware = [createRequireWebAuthMiddleware(auth), createRequireGlobalAdminMiddleware()];
|
|
516
495
|
return withMiddleware(...middleware)(handler);
|
|
517
496
|
}
|
|
@@ -535,8 +514,8 @@ class HttpKernel {
|
|
|
535
514
|
return withMiddleware(...middleware)(handler);
|
|
536
515
|
}
|
|
537
516
|
wrapPolicy(resource, action, handler) {
|
|
538
|
-
const auth = this.dependencies.container.resolve(
|
|
539
|
-
const gate = this.dependencies.container.resolve(
|
|
517
|
+
const auth = this.dependencies.container.resolve(CORE_AUTH_TOKEN2);
|
|
518
|
+
const gate = this.dependencies.container.resolve(CORE_POLICY_GATE_TOKEN2);
|
|
540
519
|
return withMiddleware(createAuthorizeMiddleware(gate, auth, resource, action))(handler);
|
|
541
520
|
}
|
|
542
521
|
wrapLogin(handler) {
|