@exaudeus/workrail 0.11.0 → 0.13.0
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/application/services/enhanced-loop-validator.js +3 -3
- package/dist/application/services/step-output-decoder.d.ts +6 -0
- package/dist/application/services/step-output-decoder.js +49 -0
- package/dist/application/services/validation-engine.d.ts +9 -0
- package/dist/application/services/validation-engine.js +142 -18
- package/dist/application/services/workflow-interpreter.d.ts +1 -1
- package/dist/application/services/workflow-interpreter.js +147 -81
- package/dist/application/services/workflow-service.d.ts +2 -0
- package/dist/application/services/workflow-service.js +3 -3
- package/dist/application/use-cases/validate-step-output.d.ts +2 -0
- package/dist/config/feature-flags.js +1 -1
- package/dist/di/container.js +88 -0
- package/dist/di/tokens.d.ts +16 -0
- package/dist/di/tokens.js +16 -0
- package/dist/domain/execution/state.d.ts +6 -6
- package/dist/domain/workflow-id-policy.d.ts +17 -0
- package/dist/domain/workflow-id-policy.js +57 -0
- package/dist/infrastructure/storage/enhanced-multi-source-workflow-storage.js +33 -6
- package/dist/infrastructure/storage/file-workflow-storage.js +3 -1
- package/dist/infrastructure/storage/schema-validating-workflow-storage.js +13 -8
- package/dist/manifest.json +329 -161
- package/dist/mcp/error-mapper.d.ts +3 -8
- package/dist/mcp/error-mapper.js +41 -19
- package/dist/mcp/handlers/session.js +25 -11
- package/dist/mcp/handlers/v2-execution-helpers.d.ts +99 -0
- package/dist/mcp/handlers/v2-execution-helpers.js +249 -0
- package/dist/mcp/handlers/v2-execution.d.ts +4 -0
- package/dist/mcp/handlers/v2-execution.js +1044 -0
- package/dist/mcp/handlers/v2-workflow.js +21 -16
- package/dist/mcp/handlers/workflow.js +21 -12
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +4 -1
- package/dist/mcp/output-schemas.d.ts +411 -4
- package/dist/mcp/output-schemas.js +57 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +96 -65
- package/dist/mcp/tool-descriptions.js +32 -15
- package/dist/mcp/tools.js +26 -14
- package/dist/mcp/types/tool-description-types.d.ts +1 -1
- package/dist/mcp/types/tool-description-types.js +7 -5
- package/dist/mcp/types.d.ts +40 -3
- package/dist/mcp/types.js +32 -3
- package/dist/mcp/v2/tool-registry.js +16 -1
- package/dist/mcp/v2/tools.d.ts +45 -0
- package/dist/mcp/v2/tools.js +21 -1
- package/dist/mcp/validation/workflow-next-prevalidate.d.ts +2 -3
- package/dist/mcp/validation/workflow-next-prevalidate.js +38 -27
- package/dist/v2/durable-core/constants.d.ts +15 -0
- package/dist/v2/durable-core/constants.js +18 -0
- package/dist/v2/durable-core/domain/ack-advance-append-plan.d.ts +32 -0
- package/dist/v2/durable-core/domain/ack-advance-append-plan.js +95 -0
- package/dist/v2/durable-core/domain/loop-runtime.d.ts +50 -0
- package/dist/v2/durable-core/domain/loop-runtime.js +95 -0
- package/dist/v2/durable-core/domain/notes-markdown.d.ts +4 -0
- package/dist/v2/durable-core/domain/notes-markdown.js +46 -0
- package/dist/v2/durable-core/domain/outputs.d.ts +12 -0
- package/dist/v2/durable-core/domain/outputs.js +18 -0
- package/dist/v2/durable-core/ids/index.d.ts +2 -0
- package/dist/v2/durable-core/ids/index.js +4 -0
- package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +100 -6
- package/dist/v2/durable-core/schemas/compiled-workflow/index.js +18 -3
- package/dist/v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.d.ts +113 -113
- package/dist/v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.js +11 -10
- package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +7129 -0
- package/dist/v2/durable-core/schemas/export-bundle/index.js +82 -0
- package/dist/v2/durable-core/schemas/lib/decision-trace-ref.d.ts +80 -0
- package/dist/v2/durable-core/schemas/lib/decision-trace-ref.js +38 -0
- package/dist/v2/durable-core/schemas/lib/dedupe-key.d.ts +8 -0
- package/dist/v2/durable-core/schemas/lib/dedupe-key.js +28 -0
- package/dist/v2/durable-core/schemas/lib/utf8-bounded-string.d.ts +6 -0
- package/dist/v2/durable-core/schemas/lib/utf8-bounded-string.js +12 -0
- package/dist/v2/durable-core/schemas/session/events.d.ts +238 -62
- package/dist/v2/durable-core/schemas/session/events.js +74 -29
- package/dist/v2/durable-core/schemas/session/manifest.d.ts +3 -3
- package/dist/v2/durable-core/schemas/session/manifest.js +6 -1
- package/dist/v2/durable-core/schemas/session/preferences.d.ts +5 -0
- package/dist/v2/durable-core/schemas/session/preferences.js +6 -0
- package/dist/v2/durable-core/schemas/session/session-health.d.ts +3 -0
- package/dist/v2/durable-core/tokens/index.d.ts +2 -1
- package/dist/v2/durable-core/tokens/index.js +4 -4
- package/dist/v2/durable-core/tokens/payloads.d.ts +4 -4
- package/dist/v2/durable-core/tokens/token-codec.d.ts +3 -2
- package/dist/v2/durable-core/tokens/token-codec.js +12 -6
- package/dist/v2/durable-core/tokens/token-signer.d.ts +3 -2
- package/dist/v2/durable-core/tokens/token-signer.js +8 -9
- package/dist/v2/infra/local/base64url/index.d.ts +5 -0
- package/dist/v2/infra/local/base64url/index.js +48 -0
- package/dist/v2/infra/local/fs/index.js +8 -4
- package/dist/v2/infra/local/keyring/index.d.ts +5 -1
- package/dist/v2/infra/local/keyring/index.js +41 -32
- package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +6 -4
- package/dist/v2/infra/local/pinned-workflow-store/index.js +50 -62
- package/dist/v2/infra/local/random-entropy/index.d.ts +4 -0
- package/dist/v2/infra/local/random-entropy/index.js +10 -0
- package/dist/v2/infra/local/session-lock/index.d.ts +3 -1
- package/dist/v2/infra/local/session-lock/index.js +5 -4
- package/dist/v2/infra/local/session-store/index.d.ts +0 -1
- package/dist/v2/infra/local/session-store/index.js +372 -282
- package/dist/v2/infra/local/snapshot-store/index.js +20 -25
- package/dist/v2/infra/local/time-clock/index.d.ts +5 -0
- package/dist/v2/infra/local/time-clock/index.js +12 -0
- package/dist/v2/infra/local/utf8/index.d.ts +5 -0
- package/dist/v2/infra/local/utf8/index.js +12 -0
- package/dist/v2/ports/base64url.port.d.ts +12 -0
- package/dist/v2/ports/base64url.port.js +2 -0
- package/dist/v2/ports/pinned-workflow-store.port.d.ts +3 -3
- package/dist/v2/ports/random-entropy.port.d.ts +3 -0
- package/dist/v2/ports/random-entropy.port.js +2 -0
- package/dist/v2/ports/session-event-log-store.port.d.ts +1 -1
- package/dist/v2/ports/session-lock.port.d.ts +1 -1
- package/dist/v2/ports/time-clock.port.d.ts +4 -0
- package/dist/v2/ports/time-clock.port.js +2 -0
- package/dist/v2/ports/utf8.port.d.ts +3 -0
- package/dist/v2/ports/utf8.port.js +2 -0
- package/dist/v2/projections/node-outputs.js +28 -11
- package/dist/v2/projections/preferences.d.ts +1 -2
- package/dist/v2/projections/preferences.js +11 -4
- package/dist/v2/projections/run-dag.js +40 -28
- package/dist/v2/projections/run-status-signals.d.ts +1 -2
- package/dist/v2/read-only/v1-to-v2-shim.d.ts +6 -1
- package/dist/v2/read-only/v1-to-v2-shim.js +16 -4
- package/dist/v2/usecases/execution-session-gate.d.ts +3 -2
- package/dist/v2/usecases/execution-session-gate.js +81 -85
- package/package.json +4 -1
- package/spec/workflow.schema.json +2 -2
- package/workflows/coding-task-workflow-agentic.json +498 -78
- package/workflows/design-thinking-workflow-autonomous.agentic.json +1 -1
- package/workflows/design-thinking-workflow.json +1 -1
- package/workflows/relocation-workflow-us.json +430 -0
- package/dist/v2/durable-core/tokens/base64url.d.ts +0 -7
- package/dist/v2/durable-core/tokens/base64url.js +0 -16
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManifestRecordV1Schema = exports.DomainEventV1Schema = exports.ExecutionSnapshotFileV1Schema = exports.BundleImportErrorSchema = exports.BundleImportErrorCodeSchema = exports.ExportBundleV1Schema = exports.SessionContentsV1Schema = exports.ProducerInfoV1Schema = exports.IntegrityManifestV1Schema = exports.IntegrityEntryV1Schema = void 0;
|
|
4
|
+
exports.importCollisionPolicy = importCollisionPolicy;
|
|
5
|
+
exports.importValidationOrder = importValidationOrder;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const constants_js_1 = require("../../constants.js");
|
|
8
|
+
const index_js_1 = require("../execution-snapshot/index.js");
|
|
9
|
+
const events_js_1 = require("../session/events.js");
|
|
10
|
+
const index_js_2 = require("../session/index.js");
|
|
11
|
+
const Sha256DigestSchema = zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.regex(constants_js_1.SHA256_DIGEST_PATTERN, 'Expected sha256:<64 hex chars>')
|
|
14
|
+
.describe('SHA-256 digest in format sha256:<64 lowercase hex>');
|
|
15
|
+
exports.IntegrityEntryV1Schema = zod_1.z.object({
|
|
16
|
+
path: zod_1.z.string().min(1).describe('Location within bundle (e.g., "session/events")'),
|
|
17
|
+
sha256: Sha256DigestSchema.describe('JCS canonical JSON + SHA-256'),
|
|
18
|
+
bytes: zod_1.z.number().int().nonnegative().describe('Byte length of JCS canonical UTF-8'),
|
|
19
|
+
});
|
|
20
|
+
exports.IntegrityManifestV1Schema = zod_1.z.object({
|
|
21
|
+
kind: zod_1.z.literal('sha256_manifest_v1').describe('Integrity scheme identifier'),
|
|
22
|
+
entries: zod_1.z
|
|
23
|
+
.array(exports.IntegrityEntryV1Schema)
|
|
24
|
+
.min(1)
|
|
25
|
+
.describe('Integrity entries for each major artifact path'),
|
|
26
|
+
});
|
|
27
|
+
exports.ProducerInfoV1Schema = zod_1.z.object({
|
|
28
|
+
appVersion: zod_1.z.string().min(1).describe('Application version that produced the bundle'),
|
|
29
|
+
appliedConfigHash: Sha256DigestSchema.optional().describe('Optional: hash of applied config'),
|
|
30
|
+
});
|
|
31
|
+
const SnapshotsMapV1Schema = zod_1.z
|
|
32
|
+
.record(zod_1.z.string().min(1).describe('SnapshotRef (sha256:<digest>)'), index_js_1.ExecutionSnapshotFileV1Schema)
|
|
33
|
+
.describe('Content-addressed snapshot storage');
|
|
34
|
+
const PinnedWorkflowsMapV1Schema = zod_1.z
|
|
35
|
+
.record(zod_1.z.string().min(1).describe('WorkflowHash (sha256:<digest>)'), zod_1.z.unknown().describe('CompiledWorkflowV1 or equivalent snapshot'))
|
|
36
|
+
.describe('Pinned workflow definitions by hash');
|
|
37
|
+
exports.SessionContentsV1Schema = zod_1.z.object({
|
|
38
|
+
sessionId: zod_1.z.string().min(1).describe('Stable session identifier'),
|
|
39
|
+
events: zod_1.z
|
|
40
|
+
.array(events_js_1.DomainEventV1Schema)
|
|
41
|
+
.describe('Ordered session events by ascending eventIndex'),
|
|
42
|
+
manifest: zod_1.z
|
|
43
|
+
.array(index_js_2.ManifestRecordV1Schema)
|
|
44
|
+
.describe('Ordered manifest records by ascending manifestIndex'),
|
|
45
|
+
snapshots: SnapshotsMapV1Schema.describe('Content-addressed snapshot CAS'),
|
|
46
|
+
pinnedWorkflows: PinnedWorkflowsMapV1Schema.describe('Pinned workflow definitions'),
|
|
47
|
+
});
|
|
48
|
+
exports.ExportBundleV1Schema = zod_1.z.object({
|
|
49
|
+
bundleSchemaVersion: zod_1.z.literal(1).describe('Bundle format version (1)'),
|
|
50
|
+
bundleId: zod_1.z.string().min(1).describe('Stable bundle identifier'),
|
|
51
|
+
exportedAt: zod_1.z.string().datetime().describe('ISO 8601 timestamp (informational only)'),
|
|
52
|
+
producer: exports.ProducerInfoV1Schema.describe('Informational producer metadata'),
|
|
53
|
+
integrity: exports.IntegrityManifestV1Schema.describe('Corruption detection manifest'),
|
|
54
|
+
session: exports.SessionContentsV1Schema.describe('Session durable truth'),
|
|
55
|
+
});
|
|
56
|
+
exports.BundleImportErrorCodeSchema = zod_1.z.enum([
|
|
57
|
+
'BUNDLE_INVALID_FORMAT',
|
|
58
|
+
'BUNDLE_UNSUPPORTED_VERSION',
|
|
59
|
+
'BUNDLE_INTEGRITY_FAILED',
|
|
60
|
+
'BUNDLE_MISSING_SNAPSHOT',
|
|
61
|
+
'BUNDLE_MISSING_PINNED_WORKFLOW',
|
|
62
|
+
'BUNDLE_EVENT_ORDER_INVALID',
|
|
63
|
+
'BUNDLE_MANIFEST_ORDER_INVALID',
|
|
64
|
+
]);
|
|
65
|
+
exports.BundleImportErrorSchema = zod_1.z.object({
|
|
66
|
+
code: exports.BundleImportErrorCodeSchema,
|
|
67
|
+
message: zod_1.z.string().min(1).describe('Human-readable error message'),
|
|
68
|
+
retry: zod_1.z.enum(['yes', 'no']).describe('Whether caller should retry'),
|
|
69
|
+
details: zod_1.z.record(zod_1.z.unknown()).optional().describe('Additional debugging context'),
|
|
70
|
+
});
|
|
71
|
+
function importCollisionPolicy(args) {
|
|
72
|
+
return 'import_as_new';
|
|
73
|
+
}
|
|
74
|
+
function importValidationOrder() {
|
|
75
|
+
return ['schema', 'integrity', 'ordering', 'references'];
|
|
76
|
+
}
|
|
77
|
+
var index_js_3 = require("../execution-snapshot/index.js");
|
|
78
|
+
Object.defineProperty(exports, "ExecutionSnapshotFileV1Schema", { enumerable: true, get: function () { return index_js_3.ExecutionSnapshotFileV1Schema; } });
|
|
79
|
+
var events_js_2 = require("../session/events.js");
|
|
80
|
+
Object.defineProperty(exports, "DomainEventV1Schema", { enumerable: true, get: function () { return events_js_2.DomainEventV1Schema; } });
|
|
81
|
+
var index_js_4 = require("../session/index.js");
|
|
82
|
+
Object.defineProperty(exports, "ManifestRecordV1Schema", { enumerable: true, get: function () { return index_js_4.ManifestRecordV1Schema; } });
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DecisionTraceRefKindSchema: z.ZodEnum<["step_id", "loop_id", "condition_id", "iteration"]>;
|
|
3
|
+
export type DecisionTraceRefKind = z.infer<typeof DecisionTraceRefKindSchema>;
|
|
4
|
+
export declare const DecisionTraceRefV1Schema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
5
|
+
kind: z.ZodLiteral<"step_id">;
|
|
6
|
+
stepId: z.ZodString;
|
|
7
|
+
}, "strict", z.ZodTypeAny, {
|
|
8
|
+
kind: "step_id";
|
|
9
|
+
stepId: string;
|
|
10
|
+
}, {
|
|
11
|
+
kind: "step_id";
|
|
12
|
+
stepId: string;
|
|
13
|
+
}>, z.ZodObject<{
|
|
14
|
+
kind: z.ZodLiteral<"loop_id">;
|
|
15
|
+
loopId: z.ZodString;
|
|
16
|
+
}, "strict", z.ZodTypeAny, {
|
|
17
|
+
kind: "loop_id";
|
|
18
|
+
loopId: string;
|
|
19
|
+
}, {
|
|
20
|
+
kind: "loop_id";
|
|
21
|
+
loopId: string;
|
|
22
|
+
}>, z.ZodObject<{
|
|
23
|
+
kind: z.ZodLiteral<"condition_id">;
|
|
24
|
+
conditionId: z.ZodString;
|
|
25
|
+
}, "strict", z.ZodTypeAny, {
|
|
26
|
+
kind: "condition_id";
|
|
27
|
+
conditionId: string;
|
|
28
|
+
}, {
|
|
29
|
+
kind: "condition_id";
|
|
30
|
+
conditionId: string;
|
|
31
|
+
}>, z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"iteration">;
|
|
33
|
+
value: z.ZodNumber;
|
|
34
|
+
}, "strict", z.ZodTypeAny, {
|
|
35
|
+
value: number;
|
|
36
|
+
kind: "iteration";
|
|
37
|
+
}, {
|
|
38
|
+
value: number;
|
|
39
|
+
kind: "iteration";
|
|
40
|
+
}>]>;
|
|
41
|
+
export type DecisionTraceRefV1 = z.infer<typeof DecisionTraceRefV1Schema>;
|
|
42
|
+
export declare const MAX_DECISION_TRACE_REFS_PER_ENTRY = 10;
|
|
43
|
+
export declare const DecisionTraceRefsV1Schema: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
44
|
+
kind: z.ZodLiteral<"step_id">;
|
|
45
|
+
stepId: z.ZodString;
|
|
46
|
+
}, "strict", z.ZodTypeAny, {
|
|
47
|
+
kind: "step_id";
|
|
48
|
+
stepId: string;
|
|
49
|
+
}, {
|
|
50
|
+
kind: "step_id";
|
|
51
|
+
stepId: string;
|
|
52
|
+
}>, z.ZodObject<{
|
|
53
|
+
kind: z.ZodLiteral<"loop_id">;
|
|
54
|
+
loopId: z.ZodString;
|
|
55
|
+
}, "strict", z.ZodTypeAny, {
|
|
56
|
+
kind: "loop_id";
|
|
57
|
+
loopId: string;
|
|
58
|
+
}, {
|
|
59
|
+
kind: "loop_id";
|
|
60
|
+
loopId: string;
|
|
61
|
+
}>, z.ZodObject<{
|
|
62
|
+
kind: z.ZodLiteral<"condition_id">;
|
|
63
|
+
conditionId: z.ZodString;
|
|
64
|
+
}, "strict", z.ZodTypeAny, {
|
|
65
|
+
kind: "condition_id";
|
|
66
|
+
conditionId: string;
|
|
67
|
+
}, {
|
|
68
|
+
kind: "condition_id";
|
|
69
|
+
conditionId: string;
|
|
70
|
+
}>, z.ZodObject<{
|
|
71
|
+
kind: z.ZodLiteral<"iteration">;
|
|
72
|
+
value: z.ZodNumber;
|
|
73
|
+
}, "strict", z.ZodTypeAny, {
|
|
74
|
+
value: number;
|
|
75
|
+
kind: "iteration";
|
|
76
|
+
}, {
|
|
77
|
+
value: number;
|
|
78
|
+
kind: "iteration";
|
|
79
|
+
}>]>, "many">>;
|
|
80
|
+
export type DecisionTraceRefsV1 = z.infer<typeof DecisionTraceRefsV1Schema>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DecisionTraceRefsV1Schema = exports.MAX_DECISION_TRACE_REFS_PER_ENTRY = exports.DecisionTraceRefV1Schema = exports.DecisionTraceRefKindSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_js_1 = require("../../constants.js");
|
|
6
|
+
exports.DecisionTraceRefKindSchema = zod_1.z.enum([
|
|
7
|
+
'step_id',
|
|
8
|
+
'loop_id',
|
|
9
|
+
'condition_id',
|
|
10
|
+
'iteration',
|
|
11
|
+
]);
|
|
12
|
+
const StepIdRefSchema = zod_1.z.object({
|
|
13
|
+
kind: zod_1.z.literal('step_id'),
|
|
14
|
+
stepId: zod_1.z.string().regex(constants_js_1.DELIMITER_SAFE_ID_PATTERN, 'stepId must be delimiter-safe: [a-z0-9_-]+'),
|
|
15
|
+
}).strict();
|
|
16
|
+
const LoopIdRefSchema = zod_1.z.object({
|
|
17
|
+
kind: zod_1.z.literal('loop_id'),
|
|
18
|
+
loopId: zod_1.z.string().regex(constants_js_1.DELIMITER_SAFE_ID_PATTERN, 'loopId must be delimiter-safe: [a-z0-9_-]+'),
|
|
19
|
+
}).strict();
|
|
20
|
+
const ConditionIdRefSchema = zod_1.z.object({
|
|
21
|
+
kind: zod_1.z.literal('condition_id'),
|
|
22
|
+
conditionId: zod_1.z.string().regex(constants_js_1.DELIMITER_SAFE_ID_PATTERN, 'conditionId must be delimiter-safe: [a-z0-9_-]+'),
|
|
23
|
+
}).strict();
|
|
24
|
+
const IterationRefSchema = zod_1.z.object({
|
|
25
|
+
kind: zod_1.z.literal('iteration'),
|
|
26
|
+
value: zod_1.z.number().int().nonnegative(),
|
|
27
|
+
}).strict();
|
|
28
|
+
exports.DecisionTraceRefV1Schema = zod_1.z.discriminatedUnion('kind', [
|
|
29
|
+
StepIdRefSchema,
|
|
30
|
+
LoopIdRefSchema,
|
|
31
|
+
ConditionIdRefSchema,
|
|
32
|
+
IterationRefSchema,
|
|
33
|
+
]);
|
|
34
|
+
exports.MAX_DECISION_TRACE_REFS_PER_ENTRY = 10;
|
|
35
|
+
exports.DecisionTraceRefsV1Schema = zod_1.z
|
|
36
|
+
.array(exports.DecisionTraceRefV1Schema)
|
|
37
|
+
.max(exports.MAX_DECISION_TRACE_REFS_PER_ENTRY)
|
|
38
|
+
.optional();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Brand } from '../../../../runtime/brand.js';
|
|
3
|
+
export type DedupeKeyV1 = Brand<string, 'v2.DedupeKeyV1'>;
|
|
4
|
+
export declare const DEDUPE_KEY_PATTERN: RegExp;
|
|
5
|
+
export declare const MAX_DEDUPE_KEY_LENGTH = 256;
|
|
6
|
+
export declare const DedupeKeyV1Schema: z.ZodString;
|
|
7
|
+
export declare function buildDedupeKey(kind: string, parts: readonly string[]): DedupeKeyV1;
|
|
8
|
+
export declare function isValidDedupeKey(value: string): value is DedupeKeyV1;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DedupeKeyV1Schema = exports.MAX_DEDUPE_KEY_LENGTH = exports.DEDUPE_KEY_PATTERN = void 0;
|
|
4
|
+
exports.buildDedupeKey = buildDedupeKey;
|
|
5
|
+
exports.isValidDedupeKey = isValidDedupeKey;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.DEDUPE_KEY_PATTERN = /^[a-z0-9_:>-]+$/;
|
|
8
|
+
exports.MAX_DEDUPE_KEY_LENGTH = 256;
|
|
9
|
+
exports.DedupeKeyV1Schema = zod_1.z
|
|
10
|
+
.string()
|
|
11
|
+
.min(1)
|
|
12
|
+
.max(exports.MAX_DEDUPE_KEY_LENGTH)
|
|
13
|
+
.regex(exports.DEDUPE_KEY_PATTERN, 'dedupeKey must be ASCII-safe: [a-z0-9_:->]+');
|
|
14
|
+
function buildDedupeKey(kind, parts) {
|
|
15
|
+
const key = [kind, ...parts].join(':');
|
|
16
|
+
if (!exports.DEDUPE_KEY_PATTERN.test(key)) {
|
|
17
|
+
throw new Error(`Invalid dedupeKey: "${key}" does not match pattern ${exports.DEDUPE_KEY_PATTERN}`);
|
|
18
|
+
}
|
|
19
|
+
if (key.length > exports.MAX_DEDUPE_KEY_LENGTH) {
|
|
20
|
+
throw new Error(`Invalid dedupeKey: "${key}" exceeds max length ${exports.MAX_DEDUPE_KEY_LENGTH}`);
|
|
21
|
+
}
|
|
22
|
+
return key;
|
|
23
|
+
}
|
|
24
|
+
function isValidDedupeKey(value) {
|
|
25
|
+
return (value.length > 0 &&
|
|
26
|
+
value.length <= exports.MAX_DEDUPE_KEY_LENGTH &&
|
|
27
|
+
exports.DEDUPE_KEY_PATTERN.test(value));
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.utf8BoundedString = utf8BoundedString;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function utf8BoundedString(opts) {
|
|
6
|
+
const encoder = new TextEncoder();
|
|
7
|
+
let schema = zod_1.z.string();
|
|
8
|
+
if (opts.minLength !== undefined && opts.minLength > 0) {
|
|
9
|
+
schema = schema.min(opts.minLength);
|
|
10
|
+
}
|
|
11
|
+
return schema.refine((s) => encoder.encode(s).length <= opts.maxBytes, { message: `${opts.label} exceeds ${opts.maxBytes} UTF-8 bytes` });
|
|
12
|
+
}
|