@ontrails/core 1.0.0-beta.2 → 1.0.0-beta.21
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/CHANGELOG.md +283 -5
- package/README.md +113 -33
- package/package.json +11 -1
- package/src/activation-provenance.ts +111 -0
- package/src/activation-source-compatibility.ts +430 -0
- package/src/activation-source-projection.ts +221 -0
- package/src/activation-source.ts +91 -0
- package/src/blob-ref.ts +51 -0
- package/src/branded.ts +1 -1
- package/src/compose-batch.ts +69 -0
- package/src/compose-schema.ts +36 -0
- package/src/context.ts +44 -10
- package/src/contour.ts +346 -0
- package/src/derive.ts +59 -18
- package/src/detours.ts +8 -0
- package/src/draft.ts +342 -0
- package/src/error-projection.ts +51 -0
- package/src/errors.ts +309 -48
- package/src/execute.ts +1577 -0
- package/src/fire.ts +1169 -0
- package/src/index.ts +477 -32
- package/src/internal/fork-ctx.ts +69 -0
- package/src/layer-projection.ts +193 -0
- package/src/layer.ts +43 -6
- package/src/observe.ts +361 -0
- package/src/path-security.ts +1 -1
- package/src/permits.ts +12 -0
- package/src/redaction/patterns.ts +6 -3
- package/src/resilience.ts +11 -11
- package/src/resource-config.ts +792 -0
- package/src/resource.ts +194 -0
- package/src/result.ts +36 -4
- package/src/run.ts +76 -0
- package/src/schedule-runtime.ts +689 -0
- package/src/schedule.ts +326 -0
- package/src/serialization.ts +119 -39
- package/src/signal-diagnostics.ts +633 -0
- package/src/signal-ref.ts +87 -0
- package/src/signal.ts +104 -0
- package/src/store/accessor-protocol.ts +56 -0
- package/src/store/index.ts +4 -0
- package/src/structured-examples.ts +248 -0
- package/src/surface-derivation.ts +91 -0
- package/src/surface-filter.ts +176 -0
- package/src/surface-versioning.ts +42 -0
- package/src/topo.ts +769 -57
- package/src/tracing.ts +345 -0
- package/src/trail.ts +1161 -29
- package/src/trails/derive-trail.ts +842 -0
- package/src/trails/index.ts +9 -0
- package/src/trails/ingest.ts +139 -0
- package/src/trails-db.ts +208 -0
- package/src/transport-error-map.ts +174 -0
- package/src/type-utils.ts +87 -0
- package/src/types.ts +254 -12
- package/src/validate-established-topo.ts +69 -0
- package/src/validate-topo.ts +442 -35
- package/src/validation.ts +152 -4
- package/src/version-marker.ts +716 -0
- package/src/version-resolution.ts +308 -0
- package/src/version-runtime.ts +120 -0
- package/src/webhook.ts +278 -0
- package/src/workspace.ts +1 -1
- package/src/zod-wrappers.ts +72 -0
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/dist/adapters.d.ts +0 -39
- package/dist/adapters.d.ts.map +0 -1
- package/dist/adapters.js +0 -2
- package/dist/adapters.js.map +0 -1
- package/dist/blob-ref.d.ts +0 -20
- package/dist/blob-ref.d.ts.map +0 -1
- package/dist/blob-ref.js +0 -22
- package/dist/blob-ref.js.map +0 -1
- package/dist/branded.d.ts +0 -36
- package/dist/branded.d.ts.map +0 -1
- package/dist/branded.js +0 -89
- package/dist/branded.js.map +0 -1
- package/dist/collections.d.ts +0 -31
- package/dist/collections.d.ts.map +0 -1
- package/dist/collections.js +0 -60
- package/dist/collections.js.map +0 -1
- package/dist/context.d.ts +0 -10
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -15
- package/dist/context.js.map +0 -1
- package/dist/derive.d.ts +0 -33
- package/dist/derive.d.ts.map +0 -1
- package/dist/derive.js +0 -122
- package/dist/derive.js.map +0 -1
- package/dist/errors.d.ts +0 -83
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -142
- package/dist/errors.js.map +0 -1
- package/dist/event.d.ts +0 -45
- package/dist/event.d.ts.map +0 -1
- package/dist/event.js +0 -17
- package/dist/event.js.map +0 -1
- package/dist/fetch.d.ts +0 -15
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js +0 -102
- package/dist/fetch.js.map +0 -1
- package/dist/guards.d.ts +0 -17
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -25
- package/dist/guards.js.map +0 -1
- package/dist/health.d.ts +0 -18
- package/dist/health.d.ts.map +0 -1
- package/dist/health.js +0 -5
- package/dist/health.js.map +0 -1
- package/dist/hike.d.ts +0 -36
- package/dist/hike.d.ts.map +0 -1
- package/dist/hike.js +0 -20
- package/dist/hike.js.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -38
- package/dist/index.js.map +0 -1
- package/dist/job.d.ts +0 -24
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -17
- package/dist/job.js.map +0 -1
- package/dist/layer.d.ts +0 -17
- package/dist/layer.d.ts.map +0 -1
- package/dist/layer.js +0 -21
- package/dist/layer.js.map +0 -1
- package/dist/path-security.d.ts +0 -28
- package/dist/path-security.d.ts.map +0 -1
- package/dist/path-security.js +0 -63
- package/dist/path-security.js.map +0 -1
- package/dist/patterns/bulk.d.ts +0 -15
- package/dist/patterns/bulk.d.ts.map +0 -1
- package/dist/patterns/bulk.js +0 -14
- package/dist/patterns/bulk.js.map +0 -1
- package/dist/patterns/change.d.ts +0 -10
- package/dist/patterns/change.d.ts.map +0 -1
- package/dist/patterns/change.js +0 -10
- package/dist/patterns/change.js.map +0 -1
- package/dist/patterns/date-range.d.ts +0 -10
- package/dist/patterns/date-range.d.ts.map +0 -1
- package/dist/patterns/date-range.js +0 -10
- package/dist/patterns/date-range.js.map +0 -1
- package/dist/patterns/index.d.ts +0 -9
- package/dist/patterns/index.d.ts.map +0 -1
- package/dist/patterns/index.js +0 -9
- package/dist/patterns/index.js.map +0 -1
- package/dist/patterns/pagination.d.ts +0 -18
- package/dist/patterns/pagination.d.ts.map +0 -1
- package/dist/patterns/pagination.js +0 -18
- package/dist/patterns/pagination.js.map +0 -1
- package/dist/patterns/progress.d.ts +0 -11
- package/dist/patterns/progress.d.ts.map +0 -1
- package/dist/patterns/progress.js +0 -11
- package/dist/patterns/progress.js.map +0 -1
- package/dist/patterns/sorting.d.ts +0 -13
- package/dist/patterns/sorting.d.ts.map +0 -1
- package/dist/patterns/sorting.js +0 -10
- package/dist/patterns/sorting.js.map +0 -1
- package/dist/patterns/status.d.ts +0 -15
- package/dist/patterns/status.d.ts.map +0 -1
- package/dist/patterns/status.js +0 -9
- package/dist/patterns/status.js.map +0 -1
- package/dist/patterns/timestamps.d.ts +0 -10
- package/dist/patterns/timestamps.d.ts.map +0 -1
- package/dist/patterns/timestamps.js +0 -10
- package/dist/patterns/timestamps.js.map +0 -1
- package/dist/redaction/index.d.ts +0 -4
- package/dist/redaction/index.d.ts.map +0 -1
- package/dist/redaction/index.js +0 -3
- package/dist/redaction/index.js.map +0 -1
- package/dist/redaction/patterns.d.ts +0 -9
- package/dist/redaction/patterns.d.ts.map +0 -1
- package/dist/redaction/patterns.js +0 -39
- package/dist/redaction/patterns.js.map +0 -1
- package/dist/redaction/redactor.d.ts +0 -27
- package/dist/redaction/redactor.d.ts.map +0 -1
- package/dist/redaction/redactor.js +0 -89
- package/dist/redaction/redactor.js.map +0 -1
- package/dist/resilience.d.ts +0 -34
- package/dist/resilience.d.ts.map +0 -1
- package/dist/resilience.js +0 -164
- package/dist/resilience.js.map +0 -1
- package/dist/result.d.ts +0 -57
- package/dist/result.d.ts.map +0 -1
- package/dist/result.js +0 -145
- package/dist/result.js.map +0 -1
- package/dist/serialization.d.ts +0 -27
- package/dist/serialization.d.ts.map +0 -1
- package/dist/serialization.js +0 -115
- package/dist/serialization.js.map +0 -1
- package/dist/topo.d.ts +0 -18
- package/dist/topo.d.ts.map +0 -1
- package/dist/topo.js +0 -74
- package/dist/topo.js.map +0 -1
- package/dist/trail.d.ts +0 -83
- package/dist/trail.d.ts.map +0 -1
- package/dist/trail.js +0 -16
- package/dist/trail.js.map +0 -1
- package/dist/types.d.ts +0 -46
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/validate-topo.d.ts +0 -24
- package/dist/validate-topo.d.ts.map +0 -1
- package/dist/validate-topo.js +0 -108
- package/dist/validate-topo.js.map +0 -1
- package/dist/validation.d.ts +0 -27
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -134
- package/dist/validation.js.map +0 -1
- package/dist/workspace.d.ts +0 -25
- package/dist/workspace.d.ts.map +0 -1
- package/dist/workspace.js +0 -57
- package/dist/workspace.js.map +0 -1
- package/src/__tests__/blob-ref.test.ts +0 -103
- package/src/__tests__/branded.test.ts +0 -148
- package/src/__tests__/collections.test.ts +0 -126
- package/src/__tests__/context.test.ts +0 -66
- package/src/__tests__/derive.test.ts +0 -159
- package/src/__tests__/errors.test.ts +0 -309
- package/src/__tests__/event.test.ts +0 -82
- package/src/__tests__/fetch.test.ts +0 -217
- package/src/__tests__/guards.test.ts +0 -102
- package/src/__tests__/hike.test.ts +0 -117
- package/src/__tests__/job.test.ts +0 -98
- package/src/__tests__/layer.test.ts +0 -224
- package/src/__tests__/path-security.test.ts +0 -114
- package/src/__tests__/patterns.test.ts +0 -273
- package/src/__tests__/redaction.test.ts +0 -244
- package/src/__tests__/resilience.test.ts +0 -246
- package/src/__tests__/result.test.ts +0 -155
- package/src/__tests__/serialization.test.ts +0 -236
- package/src/__tests__/topo.test.ts +0 -184
- package/src/__tests__/trail.test.ts +0 -179
- package/src/__tests__/validate-topo.test.ts +0 -201
- package/src/__tests__/validation.test.ts +0 -283
- package/src/__tests__/workspace.test.ts +0 -183
- package/src/adapters.ts +0 -68
- package/src/event.ts +0 -77
- package/src/health.ts +0 -23
- package/src/hike.ts +0 -77
- package/src/job.ts +0 -20
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Zod wrapper helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers walk the wrapper layers of a Zod schema (default, optional,
|
|
5
|
+
* nullable) and rebuild the schema without any default wrappers so that
|
|
6
|
+
* downstream `.partial()` calls do not silently re-materialize defaults during
|
|
7
|
+
* validation. Both `@ontrails/core/trails/derive-trail.ts` and
|
|
8
|
+
* `@ontrails/store/src/store.ts` previously shipped near-identical copies of
|
|
9
|
+
* this walk — extracting them here keeps the wrapper semantics authored in one
|
|
10
|
+
* place so the two call sites cannot drift.
|
|
11
|
+
*
|
|
12
|
+
* Canonical behavior: `optional` wrappers are intentionally dropped. Every
|
|
13
|
+
* current call site applies `.partial()` to the stripped schema, which
|
|
14
|
+
* re-introduces `optional` across the whole shape. Preserving `optional` here
|
|
15
|
+
* would be redundant at best and would produce an `OptionalOptional<T>` shape
|
|
16
|
+
* in edge cases at worst. `nullable` wrappers are preserved because nullability
|
|
17
|
+
* is a semantic constraint that `.partial()` does not reintroduce.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { z } from 'zod';
|
|
21
|
+
|
|
22
|
+
const isWrapperType = (
|
|
23
|
+
type: string
|
|
24
|
+
): type is 'default' | 'nullable' | 'optional' =>
|
|
25
|
+
type === 'default' || type === 'nullable' || type === 'optional';
|
|
26
|
+
|
|
27
|
+
const readInnerType = (schema: z.ZodType): z.ZodType =>
|
|
28
|
+
(schema.def as unknown as { innerType: z.ZodType }).innerType;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Strip `default` wrappers from a Zod type so that partial update schemas do
|
|
32
|
+
* not silently re-materialize defaults. Walks through all wrapper layers
|
|
33
|
+
* (`default`, `optional`, `nullable`), drops defaults, drops `optional` (the
|
|
34
|
+
* downstream `.partial()` reintroduces it across the whole shape), and
|
|
35
|
+
* preserves `nullable` so explicit nullability survives.
|
|
36
|
+
*/
|
|
37
|
+
export const stripDefaultWrappers = (schema: z.ZodType): z.ZodType => {
|
|
38
|
+
let current = schema;
|
|
39
|
+
let isNullable = false;
|
|
40
|
+
|
|
41
|
+
while (isWrapperType(current.def.type)) {
|
|
42
|
+
if (current.def.type === 'nullable') {
|
|
43
|
+
isNullable = true;
|
|
44
|
+
}
|
|
45
|
+
current = readInnerType(current);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return isNullable ? current.nullable() : current;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type AnyObjectSchema = z.ZodObject<Record<string, z.ZodType>>;
|
|
52
|
+
|
|
53
|
+
const asObjectSchema = (schema: z.ZodType): AnyObjectSchema =>
|
|
54
|
+
schema as unknown as AnyObjectSchema;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Apply {@link stripDefaultWrappers} to every field in a Zod object shape and
|
|
58
|
+
* return the resulting shape record. Callers typically feed the result to
|
|
59
|
+
* `.extend()` + `.partial()`.
|
|
60
|
+
*/
|
|
61
|
+
export const stripDefaultsFromShape = (
|
|
62
|
+
schema: z.ZodType
|
|
63
|
+
): Record<string, z.ZodType> => {
|
|
64
|
+
const stripped: Record<string, z.ZodType> = {};
|
|
65
|
+
const objectSchema = asObjectSchema(schema);
|
|
66
|
+
|
|
67
|
+
for (const [field, value] of Object.entries(objectSchema.shape)) {
|
|
68
|
+
stripped[field] = stripDefaultWrappers(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return stripped;
|
|
72
|
+
};
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$ tsc -b
|
package/.turbo/turbo-lint.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$ tsc --noEmit
|
package/dist/adapters.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Result } from './result.js';
|
|
2
|
-
/** Options for search queries */
|
|
3
|
-
export interface SearchOptions {
|
|
4
|
-
readonly limit?: number | undefined;
|
|
5
|
-
readonly offset?: number | undefined;
|
|
6
|
-
readonly filters?: Readonly<Record<string, unknown>> | undefined;
|
|
7
|
-
}
|
|
8
|
-
/** A single search hit */
|
|
9
|
-
export interface SearchResult {
|
|
10
|
-
readonly id: string;
|
|
11
|
-
readonly score: number;
|
|
12
|
-
readonly document: Readonly<Record<string, unknown>>;
|
|
13
|
-
}
|
|
14
|
-
/** Options for storage writes */
|
|
15
|
-
export interface StorageOptions {
|
|
16
|
-
/** Time-to-live in milliseconds */
|
|
17
|
-
readonly ttl?: number | undefined;
|
|
18
|
-
}
|
|
19
|
-
/** Full-text / vector index adapter */
|
|
20
|
-
export interface IndexAdapter {
|
|
21
|
-
index(id: string, document: Readonly<Record<string, unknown>>): Promise<Result<void, Error>>;
|
|
22
|
-
search(query: string, options?: SearchOptions): Promise<Result<readonly SearchResult[], Error>>;
|
|
23
|
-
remove(id: string): Promise<Result<void, Error>>;
|
|
24
|
-
}
|
|
25
|
-
/** Key-value storage adapter */
|
|
26
|
-
export interface StorageAdapter {
|
|
27
|
-
get(key: string): Promise<Result<unknown, Error>>;
|
|
28
|
-
set(key: string, value: unknown, options?: StorageOptions): Promise<Result<void, Error>>;
|
|
29
|
-
delete(key: string): Promise<Result<void, Error>>;
|
|
30
|
-
has(key: string): Promise<Result<boolean, Error>>;
|
|
31
|
-
}
|
|
32
|
-
/** Cache adapter with typed get/set and bulk clear */
|
|
33
|
-
export interface CacheAdapter {
|
|
34
|
-
get<T>(key: string): Promise<Result<T | undefined, Error>>;
|
|
35
|
-
set<T>(key: string, value: T, options?: StorageOptions): Promise<Result<void, Error>>;
|
|
36
|
-
delete(key: string): Promise<Result<void, Error>>;
|
|
37
|
-
clear(): Promise<Result<void, Error>>;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=adapters.d.ts.map
|
package/dist/adapters.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C,iCAAiC;AACjC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;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MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAClD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;CACnD;AAED,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3D,GAAG,CAAC,CAAC,EACH,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAClD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;CACvC"}
|
package/dist/adapters.js
DELETED
package/dist/adapters.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":""}
|
package/dist/blob-ref.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BlobRef — a frozen reference to binary data for @ontrails/core.
|
|
3
|
-
*/
|
|
4
|
-
/** Immutable reference to a blob of binary data. */
|
|
5
|
-
export interface BlobRef {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly mimeType: string;
|
|
8
|
-
readonly size: number;
|
|
9
|
-
readonly data: Uint8Array | ReadableStream<Uint8Array>;
|
|
10
|
-
}
|
|
11
|
-
/** Creates a frozen BlobRef. */
|
|
12
|
-
export declare const createBlobRef: (options: {
|
|
13
|
-
name: string;
|
|
14
|
-
mimeType: string;
|
|
15
|
-
size: number;
|
|
16
|
-
data: Uint8Array | ReadableStream<Uint8Array>;
|
|
17
|
-
}) => BlobRef;
|
|
18
|
-
/** Type guard for BlobRef-shaped values. */
|
|
19
|
-
export declare const isBlobRef: (value: unknown) => value is BlobRef;
|
|
20
|
-
//# sourceMappingURL=blob-ref.d.ts.map
|
package/dist/blob-ref.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blob-ref.d.ts","sourceRoot":"","sources":["../src/blob-ref.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oDAAoD;AACpD,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;CACxD;AAED,gCAAgC;AAChC,eAAO,MAAM,aAAa,GAAI,SAAS;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;CAC/C,KAAG,OAMA,CAAC;AAEL,4CAA4C;AAC5C,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAWnD,CAAC"}
|
package/dist/blob-ref.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BlobRef — a frozen reference to binary data for @ontrails/core.
|
|
3
|
-
*/
|
|
4
|
-
/** Creates a frozen BlobRef. */
|
|
5
|
-
export const createBlobRef = (options) => Object.freeze({
|
|
6
|
-
data: options.data,
|
|
7
|
-
mimeType: options.mimeType,
|
|
8
|
-
name: options.name,
|
|
9
|
-
size: options.size,
|
|
10
|
-
});
|
|
11
|
-
/** Type guard for BlobRef-shaped values. */
|
|
12
|
-
export const isBlobRef = (value) => {
|
|
13
|
-
if (typeof value !== 'object' || value === null) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
const obj = value;
|
|
17
|
-
return (typeof obj['name'] === 'string' &&
|
|
18
|
-
typeof obj['mimeType'] === 'string' &&
|
|
19
|
-
typeof obj['size'] === 'number' &&
|
|
20
|
-
(obj['data'] instanceof Uint8Array || obj['data'] instanceof ReadableStream));
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=blob-ref.js.map
|
package/dist/blob-ref.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blob-ref.js","sourceRoot":"","sources":["../src/blob-ref.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,gCAAgC;AAChC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAK7B,EAAW,EAAE,CACZ,MAAM,CAAC,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;IAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,IAAI,EAAE,OAAO,CAAC,IAAI;CACnB,CAAC,CAAC;AAEL,4CAA4C;AAC5C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAoB,EAAE;IAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,OAAO,CACL,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,QAAQ;QAC/B,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,QAAQ;QACnC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,QAAQ;QAC/B,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,UAAU,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,cAAc,CAAC,CAC7E,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/branded.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Branded types and validated constructors for @ontrails/core.
|
|
3
|
-
*
|
|
4
|
-
* Branded types enforce domain constraints at the type level while remaining
|
|
5
|
-
* plain primitives at runtime. Factory functions return Result so callers
|
|
6
|
-
* handle validation failures explicitly.
|
|
7
|
-
*/
|
|
8
|
-
import { ValidationError } from './errors.js';
|
|
9
|
-
import type { Result } from './result.js';
|
|
10
|
-
/** Attach a phantom tag to a base type. */
|
|
11
|
-
export type Branded<T, Tag extends string> = T & {
|
|
12
|
-
readonly __brand: Tag;
|
|
13
|
-
};
|
|
14
|
-
/** Brand a value. No validation — use factory functions for safe construction. */
|
|
15
|
-
export declare const brand: <T, Tag extends string>(_tag: Tag, value: T) => Branded<T, Tag>;
|
|
16
|
-
/** Strip the brand and recover the underlying value. */
|
|
17
|
-
export declare const unbrand: <T>(value: Branded<T, string>) => T;
|
|
18
|
-
export type UUID = Branded<string, 'UUID'>;
|
|
19
|
-
export type Email = Branded<string, 'Email'>;
|
|
20
|
-
export type NonEmptyString = Branded<string, 'NonEmptyString'>;
|
|
21
|
-
export type PositiveInt = Branded<number, 'PositiveInt'>;
|
|
22
|
-
export declare const uuid: (value: string) => Result<UUID, ValidationError>;
|
|
23
|
-
export declare const email: (value: string) => Result<Email, ValidationError>;
|
|
24
|
-
export declare const nonEmptyString: (value: string) => Result<NonEmptyString, ValidationError>;
|
|
25
|
-
export declare const positiveInt: (value: number) => Result<PositiveInt, ValidationError>;
|
|
26
|
-
/**
|
|
27
|
-
* Generate a random alphanumeric ID.
|
|
28
|
-
* Runtime-agnostic: uses `crypto.getRandomValues`.
|
|
29
|
-
*/
|
|
30
|
-
export declare const shortId: (length?: number) => string;
|
|
31
|
-
/**
|
|
32
|
-
* Produce a deterministic hex hash from an input string.
|
|
33
|
-
* Uses a simple FNV-1a 32-bit hash — good enough for non-cryptographic IDs.
|
|
34
|
-
*/
|
|
35
|
-
export declare const hashId: (input: string) => string;
|
|
36
|
-
//# sourceMappingURL=branded.d.ts.map
|
package/dist/branded.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branded.d.ts","sourceRoot":"","sources":["../src/branded.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO1C,2CAA2C;AAC3C,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC;AAE3E,kFAAkF;AAClF,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,GAAG,SAAS,MAAM,EACzC,MAAM,GAAG,EACT,OAAO,CAAC,KACP,OAAO,CAAC,CAAC,EAAE,GAAG,CAA6B,CAAC;AAE/C,wDAAwD;AACxD,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,OAAO,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KAAG,CAAe,CAAC;AAMvE,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3C,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC/D,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAezD,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,MAAM,CAAC,IAAI,EAAE,eAAe,CAShE,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,MAAM,CAAC,KAAK,EAAE,eAAe,CASlE,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,KACZ,MAAM,CAAC,cAAc,EAAE,eAAe,CAKxC,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,OAAO,MAAM,KACZ,MAAM,CAAC,WAAW,EAAE,eAAe,CASrC,CAAC;AASF;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,eAAU,KAAG,MAWpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,KAAG,MAYtC,CAAC"}
|
package/dist/branded.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Branded types and validated constructors for @ontrails/core.
|
|
3
|
-
*
|
|
4
|
-
* Branded types enforce domain constraints at the type level while remaining
|
|
5
|
-
* plain primitives at runtime. Factory functions return Result so callers
|
|
6
|
-
* handle validation failures explicitly.
|
|
7
|
-
*/
|
|
8
|
-
import { ValidationError } from './errors.js';
|
|
9
|
-
import { Result as R } from './result.js';
|
|
10
|
-
/** Brand a value. No validation — use factory functions for safe construction. */
|
|
11
|
-
export const brand = (_tag, value) => value;
|
|
12
|
-
/** Strip the brand and recover the underlying value. */
|
|
13
|
-
export const unbrand = (value) => value;
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Validation patterns
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
18
|
-
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// Factory functions — each returns Result<BrandedType, ValidationError>
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
export const uuid = (value) => {
|
|
23
|
-
if (!UUID_RE.test(value)) {
|
|
24
|
-
return R.err(new ValidationError(`Invalid UUID: "${value}"`, {
|
|
25
|
-
context: { value },
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
return R.ok(value);
|
|
29
|
-
};
|
|
30
|
-
export const email = (value) => {
|
|
31
|
-
if (!EMAIL_RE.test(value)) {
|
|
32
|
-
return R.err(new ValidationError(`Invalid email: "${value}"`, {
|
|
33
|
-
context: { value },
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
return R.ok(value);
|
|
37
|
-
};
|
|
38
|
-
export const nonEmptyString = (value) => {
|
|
39
|
-
if (value.length === 0) {
|
|
40
|
-
return R.err(new ValidationError('String must not be empty'));
|
|
41
|
-
}
|
|
42
|
-
return R.ok(value);
|
|
43
|
-
};
|
|
44
|
-
export const positiveInt = (value) => {
|
|
45
|
-
if (!Number.isInteger(value) || value <= 0) {
|
|
46
|
-
return R.err(new ValidationError(`Expected positive integer, got ${value}`, {
|
|
47
|
-
context: { value },
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
return R.ok(value);
|
|
51
|
-
};
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
// ID utilities
|
|
54
|
-
// ---------------------------------------------------------------------------
|
|
55
|
-
const ALPHANUMERIC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
56
|
-
/**
|
|
57
|
-
* Generate a random alphanumeric ID.
|
|
58
|
-
* Runtime-agnostic: uses `crypto.getRandomValues`.
|
|
59
|
-
*/
|
|
60
|
-
export const shortId = (length = 8) => {
|
|
61
|
-
const bytes = new Uint8Array(length);
|
|
62
|
-
crypto.getRandomValues(bytes);
|
|
63
|
-
let id = '';
|
|
64
|
-
for (let i = 0; i < length; i += 1) {
|
|
65
|
-
const byte = bytes[i];
|
|
66
|
-
if (byte !== undefined) {
|
|
67
|
-
id += ALPHANUMERIC[byte % ALPHANUMERIC.length];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return id;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Produce a deterministic hex hash from an input string.
|
|
74
|
-
* Uses a simple FNV-1a 32-bit hash — good enough for non-cryptographic IDs.
|
|
75
|
-
*/
|
|
76
|
-
export const hashId = (input) => {
|
|
77
|
-
// FNV offset basis
|
|
78
|
-
let hash = 2_166_136_261;
|
|
79
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
80
|
-
// oxlint-disable-next-line no-bitwise -- FNV-1a hash requires XOR
|
|
81
|
-
hash ^= input.codePointAt(i) ?? 0;
|
|
82
|
-
// FNV prime
|
|
83
|
-
hash = Math.imul(hash, 0x01_00_01_93);
|
|
84
|
-
}
|
|
85
|
-
// Convert to unsigned 32-bit then hex
|
|
86
|
-
// oxlint-disable-next-line no-bitwise, prefer-math-trunc -- unsigned right shift needed for u32 conversion (Math.trunc differs semantically)
|
|
87
|
-
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=branded.js.map
|
package/dist/branded.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branded.js","sourceRoot":"","sources":["../src/branded.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC;AAS1C,kFAAkF;AAClF,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,IAAS,EACT,KAAQ,EACS,EAAE,CAAC,KAAwB,CAAC;AAE/C,wDAAwD;AACxD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,KAAyB,EAAK,EAAE,CAAC,KAAU,CAAC;AAWvE,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,OAAO,GACX,4EAA4E,CAAC;AAE/E,MAAM,QAAQ,GAAG,4BAA4B,CAAC;AAE9C,8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,sCAAsC;IACtC,6IAA6I;IAC7I,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
package/dist/collections.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Collection utilities and type helpers for @ontrails/core.
|
|
3
|
-
*/
|
|
4
|
-
/** Recursively make every property optional. */
|
|
5
|
-
export type DeepPartial<T> = {
|
|
6
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
7
|
-
};
|
|
8
|
-
/** Flatten an intersection into a single object type for better IDE display. */
|
|
9
|
-
export type Prettify<T> = {
|
|
10
|
-
[K in keyof T]: T[K];
|
|
11
|
-
} & {};
|
|
12
|
-
/** Require at least one property from T. */
|
|
13
|
-
export type AtLeastOne<T> = {
|
|
14
|
-
[K in keyof T]-?: Pick<T, K> & Partial<Omit<T, K>>;
|
|
15
|
-
}[keyof T];
|
|
16
|
-
/** A tuple with at least one element. */
|
|
17
|
-
export type NonEmptyArray<T> = [T, ...T[]];
|
|
18
|
-
/** Narrows a readonly array to a NonEmptyArray. */
|
|
19
|
-
export declare const isNonEmptyArray: <T>(array: readonly T[]) => array is NonEmptyArray<T>;
|
|
20
|
-
/** Split an array into chunks of at most `size` elements. */
|
|
21
|
-
export declare const chunk: <T>(array: readonly T[], size: number) => T[][];
|
|
22
|
-
/**
|
|
23
|
-
* Remove duplicate items. When `key` is provided, uniqueness is determined
|
|
24
|
-
* by the return value of the key function; otherwise strict equality is used.
|
|
25
|
-
*/
|
|
26
|
-
export declare const dedupe: <T>(array: readonly T[], key?: (item: T) => unknown) => T[];
|
|
27
|
-
/** Group items by a string key. */
|
|
28
|
-
export declare const groupBy: <T>(array: readonly T[], key: (item: T) => string) => Record<string, T[]>;
|
|
29
|
-
/** Return a new sorted array based on a key function (ascending). */
|
|
30
|
-
export declare const sortBy: <T>(array: readonly T[], key: (item: T) => string | number) => T[];
|
|
31
|
-
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,gDAAgD;AAChD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,gFAAgF;AAEhF,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAExD,4CAA4C;AAC5C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACnD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,yCAAyC;AACzC,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAM3C,mDAAmD;AACnD,eAAO,MAAM,eAAe,GAAI,CAAC,EAC/B,OAAO,SAAS,CAAC,EAAE,KAClB,KAAK,IAAI,aAAa,CAAC,CAAC,CAAqB,CAAC;AAMjD,6DAA6D;AAC7D,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,OAAO,SAAS,CAAC,EAAE,EAAE,MAAM,MAAM,KAAG,CAAC,EAAE,EAS/D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,OAAO,SAAS,CAAC,EAAE,EACnB,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,KACzB,CAAC,EAcH,CAAC;AAEF,mCAAmC;AACnC,eAAO,MAAM,OAAO,GAAI,CAAC,EACvB,OAAO,SAAS,CAAC,EAAE,EACnB,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,KACvB,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAOpB,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,OAAO,SAAS,CAAC,EAAE,EACnB,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,KAChC,CAAC,EAQA,CAAC"}
|
package/dist/collections.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Collection utilities and type helpers for @ontrails/core.
|
|
3
|
-
*/
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
// Guards
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
/** Narrows a readonly array to a NonEmptyArray. */
|
|
8
|
-
export const isNonEmptyArray = (array) => array.length > 0;
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Collection functions
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
/** Split an array into chunks of at most `size` elements. */
|
|
13
|
-
export const chunk = (array, size) => {
|
|
14
|
-
if (size < 1) {
|
|
15
|
-
throw new RangeError('chunk size must be >= 1');
|
|
16
|
-
}
|
|
17
|
-
const result = [];
|
|
18
|
-
for (let i = 0; i < array.length; i += size) {
|
|
19
|
-
result.push(array.slice(i, i + size));
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Remove duplicate items. When `key` is provided, uniqueness is determined
|
|
25
|
-
* by the return value of the key function; otherwise strict equality is used.
|
|
26
|
-
*/
|
|
27
|
-
export const dedupe = (array, key) => {
|
|
28
|
-
if (!key) {
|
|
29
|
-
return [...new Set(array)];
|
|
30
|
-
}
|
|
31
|
-
const seen = new Set();
|
|
32
|
-
const result = [];
|
|
33
|
-
for (const item of array) {
|
|
34
|
-
const k = key(item);
|
|
35
|
-
if (!seen.has(k)) {
|
|
36
|
-
seen.add(k);
|
|
37
|
-
result.push(item);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
/** Group items by a string key. */
|
|
43
|
-
export const groupBy = (array, key) => {
|
|
44
|
-
const groups = {};
|
|
45
|
-
for (const item of array) {
|
|
46
|
-
const k = key(item);
|
|
47
|
-
(groups[k] ??= []).push(item);
|
|
48
|
-
}
|
|
49
|
-
return groups;
|
|
50
|
-
};
|
|
51
|
-
/** Return a new sorted array based on a key function (ascending). */
|
|
52
|
-
export const sortBy = (array, key) => [...array].toSorted((a, b) => {
|
|
53
|
-
const ka = key(a);
|
|
54
|
-
const kb = key(b);
|
|
55
|
-
if (typeof ka === 'number' && typeof kb === 'number') {
|
|
56
|
-
return ka - kb;
|
|
57
|
-
}
|
|
58
|
-
return String(ka).localeCompare(String(kb));
|
|
59
|
-
});
|
|
60
|
-
//# sourceMappingURL=collections.js.map
|
package/dist/collections.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuBH,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,mDAAmD;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAmB,EACQ,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAEjD,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,KAAK,GAAG,CAAI,KAAmB,EAAE,IAAY,EAAS,EAAE;IACnE,IAAI,IAAI,GAAG,CAAC,EAAE,CAA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C,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,KAAmB,EACnB,GAAiC,EAC5B,EAAE,CACP,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;IAC3B,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAClB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QACrD,OAAO,EAAE,GAAG,EAAE,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"}
|
package/dist/context.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TrailContext } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Create a TrailContext with sensible defaults.
|
|
4
|
-
*
|
|
5
|
-
* - `requestId` defaults to `Bun.randomUUIDv7()` (sortable v7 UUID)
|
|
6
|
-
* - `signal` defaults to a fresh, non-aborted `AbortSignal`
|
|
7
|
-
* - All other fields come from `overrides`
|
|
8
|
-
*/
|
|
9
|
-
export declare const createTrailContext: (overrides?: Partial<TrailContext>) => TrailContext;
|
|
10
|
-
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,OAAO,CAAC,YAAY,CAAC,KAChC,YAMD,CAAC"}
|
package/dist/context.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a TrailContext with sensible defaults.
|
|
3
|
-
*
|
|
4
|
-
* - `requestId` defaults to `Bun.randomUUIDv7()` (sortable v7 UUID)
|
|
5
|
-
* - `signal` defaults to a fresh, non-aborted `AbortSignal`
|
|
6
|
-
* - All other fields come from `overrides`
|
|
7
|
-
*/
|
|
8
|
-
export const createTrailContext = (overrides) => ({
|
|
9
|
-
cwd: process.cwd(),
|
|
10
|
-
env: process.env,
|
|
11
|
-
requestId: Bun.randomUUIDv7(),
|
|
12
|
-
signal: new AbortController().signal,
|
|
13
|
-
...overrides,
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,SAAiC,EACnB,EAAE,CAAC,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,GAAG,EAAE,OAAO,CAAC,GAAyC;IACtD,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE;IAC7B,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;IACpC,GAAG,SAAS;CACb,CAAC,CAAC"}
|
package/dist/derive.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema-driven field derivation for @ontrails/core
|
|
3
|
-
*
|
|
4
|
-
* Introspects Zod v4 schemas to produce a surface-agnostic Field[] descriptor
|
|
5
|
-
* that UI layers (CLI prompts, web forms, etc.) can consume.
|
|
6
|
-
*/
|
|
7
|
-
import type { z } from 'zod';
|
|
8
|
-
/** A surface-agnostic field descriptor derived from a Zod schema. */
|
|
9
|
-
export interface Field {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly type: 'string' | 'number' | 'boolean' | 'enum' | 'multiselect';
|
|
12
|
-
readonly label: string;
|
|
13
|
-
readonly required: boolean;
|
|
14
|
-
readonly default?: unknown | undefined;
|
|
15
|
-
readonly options?: readonly {
|
|
16
|
-
value: string;
|
|
17
|
-
label?: string | undefined;
|
|
18
|
-
hint?: string | undefined;
|
|
19
|
-
}[] | undefined;
|
|
20
|
-
}
|
|
21
|
-
/** Per-field overrides supplied by trail authors. */
|
|
22
|
-
export interface FieldOverride {
|
|
23
|
-
readonly label?: string | undefined;
|
|
24
|
-
readonly message?: string | undefined;
|
|
25
|
-
readonly hint?: string | undefined;
|
|
26
|
-
readonly options?: readonly {
|
|
27
|
-
value: string;
|
|
28
|
-
label: string;
|
|
29
|
-
hint?: string | undefined;
|
|
30
|
-
}[] | undefined;
|
|
31
|
-
}
|
|
32
|
-
export declare const deriveFields: (schema: z.ZodType, overrides?: Record<string, FieldOverride>) => Field[];
|
|
33
|
-
//# sourceMappingURL=derive.d.ts.map
|
package/dist/derive.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,qEAAqE;AACrE,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,aAAa,CAAC;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EACb,SAAS;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B,EAAE,GACH,SAAS,CAAC;CACf;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EACb,SAAS;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B,EAAE,GACH,SAAS,CAAC;CACf;AAmKD,eAAO,MAAM,YAAY,GACvB,QAAQ,CAAC,CAAC,OAAO,EACjB,YAAY,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KACxC,KAAK,EAeP,CAAC"}
|
package/dist/derive.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema-driven field derivation for @ontrails/core
|
|
3
|
-
*
|
|
4
|
-
* Introspects Zod v4 schemas to produce a surface-agnostic Field[] descriptor
|
|
5
|
-
* that UI layers (CLI prompts, web forms, etc.) can consume.
|
|
6
|
-
*/
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Helpers
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
/** Convert camelCase / PascalCase to "Title Case" label. */
|
|
11
|
-
const humanize = (str) => str
|
|
12
|
-
.replaceAll(/([a-z])([A-Z])/g, '$1 $2')
|
|
13
|
-
.replaceAll(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
|
|
14
|
-
.replace(/^./, (ch) => ch.toUpperCase());
|
|
15
|
-
/** Get the inner type from an optional or default wrapper. */
|
|
16
|
-
const getInnerType = (current) => current._zod.def['innerType'];
|
|
17
|
-
/** Propagate description from inner to state if present. */
|
|
18
|
-
const propagateDescription = (inner, state) => {
|
|
19
|
-
if (inner.description) {
|
|
20
|
-
state.description = inner.description;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
/** Step one level of optional/default unwrapping. Returns null if not a wrapper type. */
|
|
24
|
-
const unwrapStep = (current, state) => {
|
|
25
|
-
const defType = current._zod.def['type'];
|
|
26
|
-
if (defType !== 'optional' && defType !== 'default') {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
state.required = false;
|
|
30
|
-
if (defType === 'default') {
|
|
31
|
-
state.defaultValue = current._zod.def['defaultValue'];
|
|
32
|
-
}
|
|
33
|
-
const inner = getInnerType(current);
|
|
34
|
-
propagateDescription(inner, state);
|
|
35
|
-
return inner;
|
|
36
|
-
};
|
|
37
|
-
/** Unwrap optional / default wrappers, collecting metadata. */
|
|
38
|
-
const unwrap = (s) => {
|
|
39
|
-
const state = {
|
|
40
|
-
defaultValue: undefined,
|
|
41
|
-
description: s.description,
|
|
42
|
-
required: true,
|
|
43
|
-
};
|
|
44
|
-
let current = s;
|
|
45
|
-
// eslint-disable-next-line no-constant-condition
|
|
46
|
-
while (true) {
|
|
47
|
-
const next = unwrapStep(current, state);
|
|
48
|
-
if (next === null) {
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
current = next;
|
|
52
|
-
}
|
|
53
|
-
return { ...state, inner: current };
|
|
54
|
-
};
|
|
55
|
-
const fieldTypeByDef = {
|
|
56
|
-
array: (s) => {
|
|
57
|
-
const element = s._zod.def['element'];
|
|
58
|
-
const elementType = element._zod.def['type'];
|
|
59
|
-
if (elementType === 'enum') {
|
|
60
|
-
const entries = element._zod.def['entries'];
|
|
61
|
-
return { options: Object.values(entries), type: 'multiselect' };
|
|
62
|
-
}
|
|
63
|
-
return { options: undefined, type: 'string' };
|
|
64
|
-
},
|
|
65
|
-
boolean: () => ({ options: undefined, type: 'boolean' }),
|
|
66
|
-
enum: (s) => {
|
|
67
|
-
const entries = s._zod.def['entries'];
|
|
68
|
-
return { options: Object.values(entries), type: 'enum' };
|
|
69
|
-
},
|
|
70
|
-
number: () => ({ options: undefined, type: 'number' }),
|
|
71
|
-
string: () => ({ options: undefined, type: 'string' }),
|
|
72
|
-
};
|
|
73
|
-
/** Derive field type and raw options from the unwrapped Zod def. */
|
|
74
|
-
const deriveFieldType = (s) => {
|
|
75
|
-
const defType = s._zod.def['type'];
|
|
76
|
-
const derive = fieldTypeByDef[defType];
|
|
77
|
-
return derive ? derive(s) : { options: undefined, type: 'string' };
|
|
78
|
-
};
|
|
79
|
-
/** Build options array, merging with overrides when present. */
|
|
80
|
-
const buildOptions = (rawOptions, overrideOptions) => {
|
|
81
|
-
if (!rawOptions) {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
if (!overrideOptions) {
|
|
85
|
-
return rawOptions.map((v) => ({ value: v }));
|
|
86
|
-
}
|
|
87
|
-
const overrideMap = new Map(overrideOptions.map((o) => [o.value, o]));
|
|
88
|
-
return rawOptions.map((v) => {
|
|
89
|
-
const ov = overrideMap.get(v);
|
|
90
|
-
return ov ? { hint: ov.hint, label: ov.label, value: v } : { value: v };
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
// ---------------------------------------------------------------------------
|
|
94
|
-
// Public API
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
/**
|
|
97
|
-
* Derive a surface-agnostic Field[] from a Zod object schema.
|
|
98
|
-
*
|
|
99
|
-
* Uses Zod v4's `_zod.def` for introspection. Returns fields sorted by name.
|
|
100
|
-
*/
|
|
101
|
-
/** Derive a single field from a shape entry. */
|
|
102
|
-
const deriveField = (key, value, overrides) => {
|
|
103
|
-
const { inner, required, defaultValue, description } = unwrap(value);
|
|
104
|
-
const { type, options: rawOptions } = deriveFieldType(inner);
|
|
105
|
-
const override = overrides?.[key];
|
|
106
|
-
const label = override?.label ?? description ?? humanize(key);
|
|
107
|
-
const options = buildOptions(rawOptions, override?.options);
|
|
108
|
-
return { default: defaultValue, label, name: key, options, required, type };
|
|
109
|
-
};
|
|
110
|
-
export const deriveFields = (schema, overrides) => {
|
|
111
|
-
const s = schema;
|
|
112
|
-
if (s._zod.def['type'] !== 'object') {
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
const shape = s._zod.def['shape'];
|
|
116
|
-
if (!shape) {
|
|
117
|
-
return [];
|
|
118
|
-
}
|
|
119
|
-
const fields = Object.entries(shape).map(([key, value]) => deriveField(key, value, overrides));
|
|
120
|
-
return fields.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
121
|
-
};
|
|
122
|
-
//# sourceMappingURL=derive.js.map
|
package/dist/derive.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"derive.js","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkDH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,4DAA4D;AAC5D,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE,CACvC,GAAG;KACA,UAAU,CAAC,iBAAiB,EAAE,OAAO,CAAC;KACtC,UAAU,CAAC,uBAAuB,EAAE,OAAO,CAAC;KAC5C,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAS7C,8DAA8D;AAC9D,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAgB,EAAE,CAC3D,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAiB,CAAC;AAEhD,4DAA4D;AAC5D,MAAM,oBAAoB,GAAG,CAC3B,KAAmB,EACnB,KAA0C,EACpC,EAAE;IACR,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACtB,KAAK,CAAC,WAAW,GAA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