@ontrails/core 1.0.0-beta.0 → 1.0.0-beta.10
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +109 -0
- package/README.md +101 -131
- package/dist/derive.d.ts +1 -1
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +4 -1
- package/dist/derive.js.map +1 -1
- package/dist/dispatch.d.ts +27 -0
- package/dist/dispatch.d.ts.map +1 -0
- package/dist/dispatch.js +34 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/event.d.ts +2 -2
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +1 -1
- package/dist/event.js.map +1 -1
- package/dist/execute.d.ts +30 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +64 -0
- package/dist/execute.js.map +1 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/patterns/status.d.ts +1 -1
- package/dist/result.d.ts +11 -11
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +15 -4
- package/dist/result.js.map +1 -1
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +45 -7
- package/dist/serialization.js.map +1 -1
- package/dist/topo.d.ts +4 -4
- package/dist/topo.d.ts.map +1 -1
- package/dist/topo.js +12 -16
- package/dist/topo.js.map +1 -1
- package/dist/trail.d.ts +16 -10
- package/dist/trail.d.ts.map +1 -1
- package/dist/trail.js +4 -2
- package/dist/trail.js.map +1 -1
- package/dist/type-utils.d.ts +24 -0
- package/dist/type-utils.d.ts.map +1 -0
- package/dist/type-utils.js +12 -0
- package/dist/type-utils.js.map +1 -0
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/validate-topo.d.ts +2 -2
- package/dist/validate-topo.d.ts.map +1 -1
- package/dist/validate-topo.js +59 -9
- package/dist/validate-topo.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/context.test.ts +4 -5
- package/src/__tests__/derive.test.ts +44 -0
- package/src/__tests__/dispatch.test.ts +154 -0
- package/src/__tests__/event.test.ts +5 -5
- package/src/__tests__/execute.test.ts +208 -0
- package/src/__tests__/layer.test.ts +11 -111
- package/src/__tests__/serialization.test.ts +166 -1
- package/src/__tests__/topo.test.ts +101 -79
- package/src/__tests__/trail.test.ts +73 -35
- package/src/__tests__/type-utils.test.ts +90 -0
- package/src/__tests__/validate-topo.test.ts +97 -20
- package/src/derive.ts +12 -2
- package/src/dispatch.ts +54 -0
- package/src/event.ts +3 -3
- package/src/execute.ts +96 -0
- package/src/index.ts +22 -18
- package/src/result.ts +29 -15
- package/src/serialization.ts +56 -11
- package/src/topo.ts +18 -23
- package/src/trail.ts +24 -13
- package/src/type-utils.ts +45 -0
- package/src/types.ts +1 -3
- package/src/validate-topo.ts +70 -10
- package/tsconfig.tsbuildinfo +1 -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/src/__tests__/hike.test.ts +0 -117
- package/src/__tests__/job.test.ts +0 -98
- package/src/adapters.ts +0 -68
- package/src/health.ts +0 -23
- package/src/hike.ts +0 -77
- package/src/job.ts +0 -20
package/src/adapters.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { Result } from './result.js';
|
|
2
|
-
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Shared option types
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
/** Options for search queries */
|
|
8
|
-
export interface SearchOptions {
|
|
9
|
-
readonly limit?: number | undefined;
|
|
10
|
-
readonly offset?: number | undefined;
|
|
11
|
-
readonly filters?: Readonly<Record<string, unknown>> | undefined;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** A single search hit */
|
|
15
|
-
export interface SearchResult {
|
|
16
|
-
readonly id: string;
|
|
17
|
-
readonly score: number;
|
|
18
|
-
readonly document: Readonly<Record<string, unknown>>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Options for storage writes */
|
|
22
|
-
export interface StorageOptions {
|
|
23
|
-
/** Time-to-live in milliseconds */
|
|
24
|
-
readonly ttl?: number | undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
// Adapter port interfaces
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
|
|
31
|
-
/** Full-text / vector index adapter */
|
|
32
|
-
export interface IndexAdapter {
|
|
33
|
-
index(
|
|
34
|
-
id: string,
|
|
35
|
-
document: Readonly<Record<string, unknown>>
|
|
36
|
-
): Promise<Result<void, Error>>;
|
|
37
|
-
|
|
38
|
-
search(
|
|
39
|
-
query: string,
|
|
40
|
-
options?: SearchOptions
|
|
41
|
-
): Promise<Result<readonly SearchResult[], Error>>;
|
|
42
|
-
|
|
43
|
-
remove(id: string): Promise<Result<void, Error>>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Key-value storage adapter */
|
|
47
|
-
export interface StorageAdapter {
|
|
48
|
-
get(key: string): Promise<Result<unknown, Error>>;
|
|
49
|
-
set(
|
|
50
|
-
key: string,
|
|
51
|
-
value: unknown,
|
|
52
|
-
options?: StorageOptions
|
|
53
|
-
): Promise<Result<void, Error>>;
|
|
54
|
-
delete(key: string): Promise<Result<void, Error>>;
|
|
55
|
-
has(key: string): Promise<Result<boolean, Error>>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Cache adapter with typed get/set and bulk clear */
|
|
59
|
-
export interface CacheAdapter {
|
|
60
|
-
get<T>(key: string): Promise<Result<T | undefined, Error>>;
|
|
61
|
-
set<T>(
|
|
62
|
-
key: string,
|
|
63
|
-
value: T,
|
|
64
|
-
options?: StorageOptions
|
|
65
|
-
): Promise<Result<void, Error>>;
|
|
66
|
-
delete(key: string): Promise<Result<void, Error>>;
|
|
67
|
-
clear(): Promise<Result<void, Error>>;
|
|
68
|
-
}
|
package/src/health.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// Health check types
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
|
|
5
|
-
/** Aggregate health status */
|
|
6
|
-
export type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
|
|
7
|
-
|
|
8
|
-
/** Individual component check result */
|
|
9
|
-
export interface HealthCheck {
|
|
10
|
-
readonly status: HealthStatus;
|
|
11
|
-
readonly message?: string | undefined;
|
|
12
|
-
/** Latency in milliseconds */
|
|
13
|
-
readonly latency?: number | undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Full health report returned by a health endpoint */
|
|
17
|
-
export interface HealthResult {
|
|
18
|
-
readonly status: HealthStatus;
|
|
19
|
-
readonly checks: Readonly<Record<string, HealthCheck>>;
|
|
20
|
-
readonly version?: string | undefined;
|
|
21
|
-
/** Uptime in seconds */
|
|
22
|
-
readonly uptime?: number | undefined;
|
|
23
|
-
}
|
package/src/hike.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hike — a composition that follows trails.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { Trail, TrailSpec } from './trail.js';
|
|
6
|
-
import type { TrailContext } from './types.js';
|
|
7
|
-
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
// Spec (input to the factory)
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
export interface HikeSpec<I, O> extends TrailSpec<I, O> {
|
|
13
|
-
readonly follows: readonly string[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
// Shape (output of the factory)
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
export interface Hike<I, O> extends Omit<Trail<I, O>, 'kind'> {
|
|
21
|
-
readonly kind: 'hike';
|
|
22
|
-
readonly follows: readonly string[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
// Factory
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Create a hike definition.
|
|
31
|
-
*
|
|
32
|
-
* A hike is a composition that declares which trails it follows.
|
|
33
|
-
* Returns a frozen object with `kind: "hike"` and all spec fields.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* // ID as first argument
|
|
38
|
-
* const onboard = hike("entity.onboard", {
|
|
39
|
-
* follows: ["entity.add", "entity.relate"],
|
|
40
|
-
* input: z.object({ name: z.string() }),
|
|
41
|
-
* implementation: (input, ctx) => Result.ok(...),
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* // Full spec object (programmatic)
|
|
45
|
-
* const onboard = hike({ id: "entity.onboard", follows: [...], ... });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export function hike<I, O>(id: string, spec: HikeSpec<I, O>): Hike<I, O>;
|
|
49
|
-
export function hike<I, O>(
|
|
50
|
-
spec: HikeSpec<I, O> & { readonly id: string }
|
|
51
|
-
): Hike<I, O>;
|
|
52
|
-
export function hike<I, O>(
|
|
53
|
-
idOrSpec: string | (HikeSpec<I, O> & { readonly id: string }),
|
|
54
|
-
maybeSpec?: HikeSpec<I, O>
|
|
55
|
-
): Hike<I, O> {
|
|
56
|
-
const resolved =
|
|
57
|
-
typeof idOrSpec === 'string'
|
|
58
|
-
? { id: idOrSpec, spec: maybeSpec }
|
|
59
|
-
: { id: idOrSpec.id, spec: idOrSpec };
|
|
60
|
-
|
|
61
|
-
if (!resolved.spec) {
|
|
62
|
-
throw new TypeError('hike() requires a spec when an id is provided');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const { follows, implementation, ...rest } = resolved.spec;
|
|
66
|
-
return Object.freeze({
|
|
67
|
-
...rest,
|
|
68
|
-
follows: Object.freeze([...follows]),
|
|
69
|
-
id: resolved.id,
|
|
70
|
-
implementation: async (input: I, ctx: TrailContext) =>
|
|
71
|
-
await implementation(input, ctx),
|
|
72
|
-
kind: 'hike' as const,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// oxlint-disable-next-line no-explicit-any -- existential type; see AnyTrail
|
|
77
|
-
export type AnyHike = Hike<any, any>;
|
package/src/job.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { progressFields } from './patterns/progress.js';
|
|
4
|
-
import { statusFields } from './patterns/status.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Proof: job-style output schema composes from existing pattern helpers.
|
|
8
|
-
* No dedicated `kind: "job"` needed — regular trails with status+progress output work.
|
|
9
|
-
*/
|
|
10
|
-
export const jobOutputSchema = z.object({
|
|
11
|
-
...progressFields().shape,
|
|
12
|
-
...statusFields().shape,
|
|
13
|
-
completedAt: z.string().optional(),
|
|
14
|
-
error: z.string().optional(),
|
|
15
|
-
jobId: z.string(),
|
|
16
|
-
result: z.unknown().optional(),
|
|
17
|
-
startedAt: z.string().optional(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export type JobOutput = z.infer<typeof jobOutputSchema>;
|