@dyrected/core 2.7.0 → 2.7.1
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/chunk-2UXLA4YN.js +3139 -0
- package/dist/chunk-5U2WRCNH.js +3140 -0
- package/dist/chunk-AKYYGMFS.js +3365 -0
- package/dist/chunk-EJG6AMYB.js +3537 -0
- package/dist/chunk-FRSJJO27.js +519 -0
- package/dist/chunk-G43REXPX.js +3147 -0
- package/dist/chunk-GFKBPBJJ.js +3637 -0
- package/dist/chunk-LFGSRQLX.js +3568 -0
- package/dist/chunk-NNZRYF3U.js +3537 -0
- package/dist/chunk-PYE2JSY4.js +3568 -0
- package/dist/chunk-QCXLDKZO.js +3272 -0
- package/dist/chunk-UKUEKTAO.js +513 -0
- package/dist/chunk-VM43G3IG.js +506 -0
- package/dist/chunk-VWJKFZQU.js +3139 -0
- package/dist/chunk-YSSHLGQ6.js +3139 -0
- package/dist/chunk-Z7CFUYVP.js +3653 -0
- package/dist/index.cjs +984 -82
- package/dist/index.d.cts +197 -1
- package/dist/index.d.ts +197 -1
- package/dist/index.js +67 -1
- package/dist/observability-CNM4QFE4.js +34 -0
- package/dist/observability-KCMTV7GO.js +34 -0
- package/dist/observability-L5BORBB2.js +34 -0
- package/dist/server.cjs +1268 -888
- package/dist/server.d.cts +28 -3
- package/dist/server.d.ts +28 -3
- package/dist/server.js +38 -33
- package/package.json +1 -1
package/dist/server.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as hono_types from 'hono/types';
|
|
2
2
|
import * as hono from 'hono';
|
|
3
|
-
import {
|
|
3
|
+
import { Context, Hono } from 'hono';
|
|
4
4
|
import { Logger } from 'pino';
|
|
5
|
-
import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-ChsrBB7p.cjs';
|
|
5
|
+
import { D as DyrectedConfig, at as DyrectedObservabilityConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-ChsrBB7p.cjs';
|
|
6
6
|
import { JWTPayload } from 'jose';
|
|
7
7
|
import { Tracer, Counter, Attributes, Histogram, Span } from '@opentelemetry/api';
|
|
8
8
|
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
|
|
@@ -20,6 +20,7 @@ interface CollectionTokenPayload extends JWTPayload {
|
|
|
20
20
|
authSource?: 'local' | 'external';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
type RequestVars = DyrectedContext["Variables"];
|
|
23
24
|
interface ResolvedObservabilityConfig {
|
|
24
25
|
requestLogging: {
|
|
25
26
|
enabled: boolean;
|
|
@@ -100,6 +101,30 @@ interface DyrectedObservabilityRuntime {
|
|
|
100
101
|
recordEmailSendFailure: (attributes?: Attributes) => void;
|
|
101
102
|
recordWorkflowHookFailure: (attributes?: Attributes) => void;
|
|
102
103
|
}
|
|
104
|
+
declare function resolveObservabilityConfig(config?: DyrectedObservabilityConfig): ResolvedObservabilityConfig;
|
|
105
|
+
declare function createObservabilityRuntime(config: DyrectedConfig): DyrectedObservabilityRuntime;
|
|
106
|
+
declare function bindObservabilityRuntime(config: DyrectedConfig, runtime: DyrectedObservabilityRuntime): void;
|
|
107
|
+
declare function getObservabilityRuntime(config: Pick<DyrectedConfig, "logger"> | undefined): DyrectedObservabilityRuntime | undefined;
|
|
108
|
+
declare function getConfigLogger(config: Pick<DyrectedConfig, "logger"> | undefined, component: string): Logger;
|
|
109
|
+
declare function getRequestLogger(c: Context<DyrectedContext>, component?: string): Logger;
|
|
110
|
+
declare function buildRequestLogger(runtime: DyrectedObservabilityRuntime, vars: RequestVars, requestId?: string): Logger;
|
|
111
|
+
declare function shouldSampleRequest(requestId: string | undefined, statusCode: number, sampling: ResolvedObservabilityConfig["sampling"], kind: "log" | "trace" | "body"): boolean;
|
|
112
|
+
declare function redactHeaders(headers: Record<string, string>, observability: ResolvedObservabilityConfig): Record<string, string>;
|
|
113
|
+
declare function captureRequestBody(request: Request, observability: ResolvedObservabilityConfig): Promise<RequestBodyCapture>;
|
|
114
|
+
declare function redactBody(value: unknown, redactPaths: string[]): unknown;
|
|
115
|
+
declare function createRequestSpan(runtime: DyrectedObservabilityRuntime, name: string, attributes: Attributes): RequestTraceContext | undefined;
|
|
116
|
+
declare function endRequestSpan(requestTrace: RequestTraceContext | undefined, statusCode: number, error?: unknown): void;
|
|
117
|
+
declare function attachRequestMetrics(runtime: DyrectedObservabilityRuntime, args: {
|
|
118
|
+
method: string;
|
|
119
|
+
route: string;
|
|
120
|
+
statusCode: number;
|
|
121
|
+
durationMs: number;
|
|
122
|
+
}): void;
|
|
123
|
+
declare function renderPrometheusMetrics(exporter: PrometheusExporter): Promise<{
|
|
124
|
+
body: string;
|
|
125
|
+
headers: Record<string, string>;
|
|
126
|
+
statusCode: number;
|
|
127
|
+
}>;
|
|
103
128
|
|
|
104
129
|
interface DyrectedContext {
|
|
105
130
|
Variables: {
|
|
@@ -532,4 +557,4 @@ declare class PreviewController {
|
|
|
532
557
|
}, 401, "json">)>;
|
|
533
558
|
}
|
|
534
559
|
|
|
535
|
-
export { AuthController, CollectionController, type DyrectedContext, GlobalController, MediaController, PreviewController, createDyrectedApp, registerRoutes };
|
|
560
|
+
export { AuthController, CollectionController, type DyrectedContext, type DyrectedObservabilityRuntime, GlobalController, MediaController, PreviewController, type RequestBodyCapture, type RequestTraceContext, type ResolvedObservabilityConfig, attachRequestMetrics, bindObservabilityRuntime, buildRequestLogger, captureRequestBody, createDyrectedApp, createObservabilityRuntime, createRequestSpan, endRequestSpan, getConfigLogger, getObservabilityRuntime, getRequestLogger, redactBody, redactHeaders, registerRoutes, renderPrometheusMetrics, resolveObservabilityConfig, shouldSampleRequest };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as hono_types from 'hono/types';
|
|
2
2
|
import * as hono from 'hono';
|
|
3
|
-
import {
|
|
3
|
+
import { Context, Hono } from 'hono';
|
|
4
4
|
import { Logger } from 'pino';
|
|
5
|
-
import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-ChsrBB7p.js';
|
|
5
|
+
import { D as DyrectedConfig, at as DyrectedObservabilityConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-ChsrBB7p.js';
|
|
6
6
|
import { JWTPayload } from 'jose';
|
|
7
7
|
import { Tracer, Counter, Attributes, Histogram, Span } from '@opentelemetry/api';
|
|
8
8
|
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
|
|
@@ -20,6 +20,7 @@ interface CollectionTokenPayload extends JWTPayload {
|
|
|
20
20
|
authSource?: 'local' | 'external';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
type RequestVars = DyrectedContext["Variables"];
|
|
23
24
|
interface ResolvedObservabilityConfig {
|
|
24
25
|
requestLogging: {
|
|
25
26
|
enabled: boolean;
|
|
@@ -100,6 +101,30 @@ interface DyrectedObservabilityRuntime {
|
|
|
100
101
|
recordEmailSendFailure: (attributes?: Attributes) => void;
|
|
101
102
|
recordWorkflowHookFailure: (attributes?: Attributes) => void;
|
|
102
103
|
}
|
|
104
|
+
declare function resolveObservabilityConfig(config?: DyrectedObservabilityConfig): ResolvedObservabilityConfig;
|
|
105
|
+
declare function createObservabilityRuntime(config: DyrectedConfig): DyrectedObservabilityRuntime;
|
|
106
|
+
declare function bindObservabilityRuntime(config: DyrectedConfig, runtime: DyrectedObservabilityRuntime): void;
|
|
107
|
+
declare function getObservabilityRuntime(config: Pick<DyrectedConfig, "logger"> | undefined): DyrectedObservabilityRuntime | undefined;
|
|
108
|
+
declare function getConfigLogger(config: Pick<DyrectedConfig, "logger"> | undefined, component: string): Logger;
|
|
109
|
+
declare function getRequestLogger(c: Context<DyrectedContext>, component?: string): Logger;
|
|
110
|
+
declare function buildRequestLogger(runtime: DyrectedObservabilityRuntime, vars: RequestVars, requestId?: string): Logger;
|
|
111
|
+
declare function shouldSampleRequest(requestId: string | undefined, statusCode: number, sampling: ResolvedObservabilityConfig["sampling"], kind: "log" | "trace" | "body"): boolean;
|
|
112
|
+
declare function redactHeaders(headers: Record<string, string>, observability: ResolvedObservabilityConfig): Record<string, string>;
|
|
113
|
+
declare function captureRequestBody(request: Request, observability: ResolvedObservabilityConfig): Promise<RequestBodyCapture>;
|
|
114
|
+
declare function redactBody(value: unknown, redactPaths: string[]): unknown;
|
|
115
|
+
declare function createRequestSpan(runtime: DyrectedObservabilityRuntime, name: string, attributes: Attributes): RequestTraceContext | undefined;
|
|
116
|
+
declare function endRequestSpan(requestTrace: RequestTraceContext | undefined, statusCode: number, error?: unknown): void;
|
|
117
|
+
declare function attachRequestMetrics(runtime: DyrectedObservabilityRuntime, args: {
|
|
118
|
+
method: string;
|
|
119
|
+
route: string;
|
|
120
|
+
statusCode: number;
|
|
121
|
+
durationMs: number;
|
|
122
|
+
}): void;
|
|
123
|
+
declare function renderPrometheusMetrics(exporter: PrometheusExporter): Promise<{
|
|
124
|
+
body: string;
|
|
125
|
+
headers: Record<string, string>;
|
|
126
|
+
statusCode: number;
|
|
127
|
+
}>;
|
|
103
128
|
|
|
104
129
|
interface DyrectedContext {
|
|
105
130
|
Variables: {
|
|
@@ -532,4 +557,4 @@ declare class PreviewController {
|
|
|
532
557
|
}, 401, "json">)>;
|
|
533
558
|
}
|
|
534
559
|
|
|
535
|
-
export { AuthController, CollectionController, type DyrectedContext, GlobalController, MediaController, PreviewController, createDyrectedApp, registerRoutes };
|
|
560
|
+
export { AuthController, CollectionController, type DyrectedContext, type DyrectedObservabilityRuntime, GlobalController, MediaController, PreviewController, type RequestBodyCapture, type RequestTraceContext, type ResolvedObservabilityConfig, attachRequestMetrics, bindObservabilityRuntime, buildRequestLogger, captureRequestBody, createDyrectedApp, createObservabilityRuntime, createRequestSpan, endRequestSpan, getConfigLogger, getObservabilityRuntime, getRequestLogger, redactBody, redactHeaders, registerRoutes, renderPrometheusMetrics, resolveObservabilityConfig, shouldSampleRequest };
|
package/dist/server.js
CHANGED
|
@@ -4,25 +4,15 @@ import {
|
|
|
4
4
|
assertValidDeclarativeAccessInConfig,
|
|
5
5
|
assertValidDeclarativeHooksInConfig,
|
|
6
6
|
assertValidPreviewUrlsInConfig,
|
|
7
|
-
attachRequestMetrics,
|
|
8
|
-
bindObservabilityRuntime,
|
|
9
|
-
buildRequestLogger,
|
|
10
7
|
canViewWorkflowDraft,
|
|
11
|
-
captureRequestBody,
|
|
12
8
|
collectConfigDiagnostics,
|
|
13
|
-
createObservabilityRuntime,
|
|
14
|
-
createRequestSpan,
|
|
15
9
|
createWorkflowDocument,
|
|
16
|
-
endRequestSpan,
|
|
17
10
|
executeFieldAfterRead,
|
|
18
11
|
executeFieldBeforeChange,
|
|
19
12
|
generateOpenApi,
|
|
20
13
|
getAdminAuthCollection,
|
|
21
14
|
getAuthSession,
|
|
22
|
-
getConfigLogger,
|
|
23
|
-
getObservabilityRuntime,
|
|
24
15
|
getPublicAdminAuthConfig,
|
|
25
|
-
getRequestLogger,
|
|
26
16
|
initializeWorkflowDocument,
|
|
27
17
|
isAuthSessionActive,
|
|
28
18
|
issueAuthSessionToken,
|
|
@@ -30,18 +20,32 @@ import {
|
|
|
30
20
|
mergeDynamicConfig,
|
|
31
21
|
normalizeConfig,
|
|
32
22
|
publishedStateName,
|
|
33
|
-
redactHeaders,
|
|
34
|
-
renderPrometheusMetrics,
|
|
35
23
|
revokeAllAuthSessions,
|
|
36
24
|
revokeAuthSession,
|
|
37
25
|
runCollectionHooks,
|
|
38
26
|
saveWorkflowDraft,
|
|
39
|
-
shouldSampleRequest,
|
|
40
27
|
signCollectionToken,
|
|
41
28
|
touchAuthSession,
|
|
42
29
|
transitionWorkflow,
|
|
43
30
|
verifyCollectionToken
|
|
44
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YSSHLGQ6.js";
|
|
32
|
+
import {
|
|
33
|
+
attachRequestMetrics,
|
|
34
|
+
bindObservabilityRuntime,
|
|
35
|
+
buildRequestLogger,
|
|
36
|
+
captureRequestBody,
|
|
37
|
+
createObservabilityRuntime,
|
|
38
|
+
createRequestSpan,
|
|
39
|
+
endRequestSpan,
|
|
40
|
+
getConfigLogger,
|
|
41
|
+
getObservabilityRuntime,
|
|
42
|
+
getRequestLogger,
|
|
43
|
+
redactBody,
|
|
44
|
+
redactHeaders,
|
|
45
|
+
renderPrometheusMetrics,
|
|
46
|
+
resolveObservabilityConfig,
|
|
47
|
+
shouldSampleRequest
|
|
48
|
+
} from "./chunk-FRSJJO27.js";
|
|
45
49
|
|
|
46
50
|
// src/app.ts
|
|
47
51
|
import { Hono } from "hono";
|
|
@@ -436,11 +440,7 @@ async function evaluateAccess(expression, context) {
|
|
|
436
440
|
}
|
|
437
441
|
return !!result;
|
|
438
442
|
} catch (err) {
|
|
439
|
-
|
|
440
|
-
err,
|
|
441
|
-
msg: "Jexl evaluation failed",
|
|
442
|
-
expression
|
|
443
|
-
});
|
|
443
|
+
console.error("[dyrected:access] Failed to evaluate access expression:", err);
|
|
444
444
|
return false;
|
|
445
445
|
}
|
|
446
446
|
}
|
|
@@ -458,20 +458,14 @@ async function resolveAccess(config, access, args) {
|
|
|
458
458
|
try {
|
|
459
459
|
return await access(args);
|
|
460
460
|
} catch (err) {
|
|
461
|
-
|
|
462
|
-
err,
|
|
463
|
-
msg: "Functional access check failed"
|
|
464
|
-
});
|
|
461
|
+
console.error("[dyrected:access] Functional access check failed:", err);
|
|
465
462
|
return false;
|
|
466
463
|
}
|
|
467
464
|
}
|
|
468
465
|
if (isNamedAccessPolicy(access)) {
|
|
469
466
|
const policy = config.accessPolicies?.[access.policy];
|
|
470
467
|
if (policy === void 0) {
|
|
471
|
-
|
|
472
|
-
msg: "Unknown access policy",
|
|
473
|
-
policy: access.policy
|
|
474
|
-
});
|
|
468
|
+
console.error(`[dyrected:access] Unknown access policy "${access.policy}"`);
|
|
475
469
|
return false;
|
|
476
470
|
}
|
|
477
471
|
if (typeof policy === "string" || typeof policy === "boolean") {
|
|
@@ -481,11 +475,7 @@ async function resolveAccess(config, access, args) {
|
|
|
481
475
|
const resolver = policy;
|
|
482
476
|
return await resolver({ ...args, params: access.params });
|
|
483
477
|
} catch (err) {
|
|
484
|
-
|
|
485
|
-
err,
|
|
486
|
-
msg: "Access policy failed",
|
|
487
|
-
policy: access.policy
|
|
488
|
-
});
|
|
478
|
+
console.error(`[dyrected:access] Access policy "${access.policy}" failed:`, err);
|
|
489
479
|
return false;
|
|
490
480
|
}
|
|
491
481
|
}
|
|
@@ -5189,6 +5179,21 @@ export {
|
|
|
5189
5179
|
GlobalController,
|
|
5190
5180
|
MediaController,
|
|
5191
5181
|
PreviewController,
|
|
5182
|
+
attachRequestMetrics,
|
|
5183
|
+
bindObservabilityRuntime,
|
|
5184
|
+
buildRequestLogger,
|
|
5185
|
+
captureRequestBody,
|
|
5192
5186
|
createDyrectedApp,
|
|
5193
|
-
|
|
5187
|
+
createObservabilityRuntime,
|
|
5188
|
+
createRequestSpan,
|
|
5189
|
+
endRequestSpan,
|
|
5190
|
+
getConfigLogger,
|
|
5191
|
+
getObservabilityRuntime,
|
|
5192
|
+
getRequestLogger,
|
|
5193
|
+
redactBody,
|
|
5194
|
+
redactHeaders,
|
|
5195
|
+
registerRoutes,
|
|
5196
|
+
renderPrometheusMetrics,
|
|
5197
|
+
resolveObservabilityConfig,
|
|
5198
|
+
shouldSampleRequest
|
|
5194
5199
|
};
|