rura 1.1.0 → 1.1.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/index.d.ts +211 -0
- package/package.json +2 -2
- package/dist/types/export/index.d.ts +0 -9
- package/dist/types/export/index.d.ts.map +0 -1
- package/dist/types/src/hooks/create-hook.d.ts +0 -18
- package/dist/types/src/hooks/create-hook.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -3
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/internal.d.ts +0 -2
- package/dist/types/src/hooks/internal.d.ts.map +0 -1
- package/dist/types/src/hooks/types.d.ts +0 -52
- package/dist/types/src/hooks/types.d.ts.map +0 -1
- package/dist/types/src/hooks/utils/is-async-hook.d.ts +0 -2
- package/dist/types/src/hooks/utils/is-async-hook.d.ts.map +0 -1
- package/dist/types/src/pipeline/create/create-pipeline-async.d.ts +0 -20
- package/dist/types/src/pipeline/create/create-pipeline-async.d.ts.map +0 -1
- package/dist/types/src/pipeline/create/create-pipeline-base.d.ts +0 -2
- package/dist/types/src/pipeline/create/create-pipeline-base.d.ts.map +0 -1
- package/dist/types/src/pipeline/create/create-pipeline.d.ts +0 -21
- package/dist/types/src/pipeline/create/create-pipeline.d.ts.map +0 -1
- package/dist/types/src/pipeline/create/index.d.ts +0 -3
- package/dist/types/src/pipeline/create/index.d.ts.map +0 -1
- package/dist/types/src/pipeline/create/utils/assert-sync-hook.d.ts +0 -2
- package/dist/types/src/pipeline/create/utils/assert-sync-hook.d.ts.map +0 -1
- package/dist/types/src/pipeline/create/utils/log-pipeline-hooks.d.ts +0 -2
- package/dist/types/src/pipeline/create/utils/log-pipeline-hooks.d.ts.map +0 -1
- package/dist/types/src/pipeline/index.d.ts +0 -4
- package/dist/types/src/pipeline/index.d.ts.map +0 -1
- package/dist/types/src/pipeline/run/index.d.ts +0 -3
- package/dist/types/src/pipeline/run/index.d.ts.map +0 -1
- package/dist/types/src/pipeline/run/run-async.d.ts +0 -21
- package/dist/types/src/pipeline/run/run-async.d.ts.map +0 -1
- package/dist/types/src/pipeline/run/run.d.ts +0 -22
- package/dist/types/src/pipeline/run/run.d.ts.map +0 -1
- package/dist/types/src/pipeline/types.d.ts +0 -28
- package/dist/types/src/pipeline/types.d.ts.map +0 -1
- package/dist/types/src/rura.d.ts +0 -28
- package/dist/types/src/rura.d.ts.map +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rura — The hook pipeline
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates a synchronous hook.
|
|
9
|
+
*
|
|
10
|
+
* The hook executes without awaiting.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare function createHook<Ctx = unknown, Out = unknown>(name: string, run: RuraHookSync<Ctx, Out>["run"], order?: number): RuraHookSync<Ctx, Out>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates an asynchronous hook.
|
|
18
|
+
*
|
|
19
|
+
* The hook executes via `await`.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function createHookAsync<Ctx = unknown, Out = unknown>(name: string, run: RuraHookAsync<Ctx, Out>["run"], order?: number): RuraHookAsync<Ctx, Out>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Creates a synchronous Rura pipeline.
|
|
27
|
+
*
|
|
28
|
+
* The returned pipeline:
|
|
29
|
+
* - Executes hooks sequentially using a synchronous strategy.
|
|
30
|
+
* - Rejects asynchronous hooks at registration time.
|
|
31
|
+
* - Preserves deterministic ordering based on `order`.
|
|
32
|
+
*
|
|
33
|
+
* This variant guarantees that `run()` returns immediately
|
|
34
|
+
* without producing a Promise.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare function createPipeline<Ctx = unknown, Out = unknown>(hooks?: RuraHookSync<Ctx, Out>[]): {
|
|
39
|
+
use: (hook: RuraHookSync<Ctx, Out>) => /*elided*/ any;
|
|
40
|
+
getHooks: () => RuraHookSync<Ctx, Out>[];
|
|
41
|
+
logHooks: () => void;
|
|
42
|
+
run: (ctx: Ctx) => RuraResult<Ctx, Out>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates an asynchronous Rura pipeline.
|
|
47
|
+
*
|
|
48
|
+
* The returned pipeline:
|
|
49
|
+
* - Executes hooks sequentially using an async strategy.
|
|
50
|
+
* - Accepts any RuraHook, including sync and async variants.
|
|
51
|
+
* - Preserves deterministic ordering based on `order`.
|
|
52
|
+
*
|
|
53
|
+
* This variant guarantees that `run()` returns a Promise.
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export declare function createPipelineAsync<Ctx = unknown, Out = unknown>(hooks?: RuraHook<Ctx, Out>[]): {
|
|
58
|
+
use: (hook: RuraHook<Ctx, Out>) => /*elided*/ any;
|
|
59
|
+
getHooks: () => RuraHook<Ctx, Out>[];
|
|
60
|
+
logHooks: () => void;
|
|
61
|
+
run: (ctx: Ctx) => Promise<RuraResult<Ctx, Out>>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Executes a synchronous Rura pipeline.
|
|
66
|
+
*
|
|
67
|
+
* Hooks are executed sequentially in the given order.
|
|
68
|
+
*
|
|
69
|
+
* Execution contract:
|
|
70
|
+
* - Each hook receives the same `ctx` reference.
|
|
71
|
+
* - If a hook returns `{ early: true, output }`,
|
|
72
|
+
* execution stops immediately and that result is returned.
|
|
73
|
+
* - If no hook triggers early termination, a normal result
|
|
74
|
+
* `{ early: false, ctx }` is returned.
|
|
75
|
+
*
|
|
76
|
+
* This function is strictly synchronous:
|
|
77
|
+
* - It does not produce a Promise.
|
|
78
|
+
* - Only `RuraHookSync` hooks are allowed.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export declare function run<Ctx = unknown, Out = unknown>(ctx: Ctx, hooks: RuraHookSync<Ctx, Out>[]): RuraResult<Ctx, Out>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Executes an asynchronous Rura pipeline.
|
|
86
|
+
*
|
|
87
|
+
* Hooks are awaited sequentially in the provided order.
|
|
88
|
+
*
|
|
89
|
+
* Execution contract:
|
|
90
|
+
* - Each hook receives the same `ctx` reference.
|
|
91
|
+
* - Hooks may be synchronous or asynchronous.
|
|
92
|
+
* - If a hook resolves to `{ early: true, output }`,
|
|
93
|
+
* execution stops immediately and that result is returned.
|
|
94
|
+
* - If no hook triggers early termination, a normal result
|
|
95
|
+
* `{ early: false, ctx }` is returned.
|
|
96
|
+
*
|
|
97
|
+
* This function always returns a Promise.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export declare function runAsync<Ctx = unknown, Out = unknown>(ctx: Ctx, hooks: RuraHook<Ctx, Out>[]): Promise<RuraResult<Ctx, Out>>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Rura public API namespace.
|
|
105
|
+
*
|
|
106
|
+
* Provides a cohesive entry point for:
|
|
107
|
+
*
|
|
108
|
+
* - Hook factories (`createHook`, `createHookAsync`)
|
|
109
|
+
* - Direct executors (`run`, `runAsync`)
|
|
110
|
+
* - Pipeline constructors (`createPipeline`, `createPipelineAsync`)
|
|
111
|
+
*
|
|
112
|
+
* This object contains no additional logic —
|
|
113
|
+
* it simply exposes the stable, public surface of Rura.
|
|
114
|
+
*
|
|
115
|
+
* The namespace is frozen to prevent runtime mutation.
|
|
116
|
+
*
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export declare const rura: Readonly<{
|
|
120
|
+
createHook: typeof createHook;
|
|
121
|
+
createHookAsync: typeof createHookAsync;
|
|
122
|
+
run: typeof run;
|
|
123
|
+
runAsync: typeof runAsync;
|
|
124
|
+
createPipeline: typeof createPipeline;
|
|
125
|
+
createPipelineAsync: typeof createPipelineAsync;
|
|
126
|
+
}>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Union of all hook variants supported by the Rura pipeline.
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
export declare type RuraHook<Ctx = unknown, Out = unknown> = RuraHookSync<Ctx, Out> | RuraHookAsync<Ctx, Out>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Asynchronous hook.
|
|
137
|
+
*
|
|
138
|
+
* Executed via `await`.
|
|
139
|
+
* The provided `ctx` may be mutated.
|
|
140
|
+
* Resolving with an early signal terminates the pipeline.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare interface RuraHookAsync<Ctx, Out> extends RuraHookBase {
|
|
145
|
+
run(ctx: Ctx): Promise<void | {
|
|
146
|
+
early: true;
|
|
147
|
+
output: Out;
|
|
148
|
+
}>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Base contract for all Rura hooks.
|
|
153
|
+
*
|
|
154
|
+
* A hook is an ordered execution unit within a pipeline.
|
|
155
|
+
* The `name` uniquely identifies the hook.
|
|
156
|
+
* The optional `order` controls execution priority (lower values run first).
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export declare interface RuraHookBase {
|
|
161
|
+
/** Unique hook identifier. */
|
|
162
|
+
name: string;
|
|
163
|
+
/** Execution priority. Lower values run earlier. */
|
|
164
|
+
order?: number;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Synchronous hook.
|
|
169
|
+
*
|
|
170
|
+
* Executed without awaiting.
|
|
171
|
+
* The provided `ctx` may be mutated.
|
|
172
|
+
* Returning an early signal terminates the pipeline.
|
|
173
|
+
*
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
export declare interface RuraHookSync<Ctx, Out> extends RuraHookBase {
|
|
177
|
+
run(ctx: Ctx): void | {
|
|
178
|
+
early: true;
|
|
179
|
+
output: Out;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Result of a Rura pipeline execution.
|
|
185
|
+
*
|
|
186
|
+
* This type represents the final outcome of running a pipeline,
|
|
187
|
+
* either through `run` or `runAsync`.
|
|
188
|
+
*
|
|
189
|
+
* Execution semantics:
|
|
190
|
+
* - `ctx` always refers to the same context object that was
|
|
191
|
+
* passed into the pipeline. Hooks may mutate it in place.
|
|
192
|
+
* - When `early` is `true`, execution stopped before all hooks
|
|
193
|
+
* completed, and `output` contains the early-return value.
|
|
194
|
+
* - When `early` is `false`, all hooks were executed and no
|
|
195
|
+
* early termination occurred. In this case, `output` is not present.
|
|
196
|
+
*
|
|
197
|
+
* The `early` field acts as a discriminant for safe narrowing.
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
export declare type RuraResult<Ctx, Out> = {
|
|
202
|
+
early: true;
|
|
203
|
+
ctx: Ctx;
|
|
204
|
+
output: Out;
|
|
205
|
+
} | {
|
|
206
|
+
early: false;
|
|
207
|
+
ctx: Ctx;
|
|
208
|
+
output?: never;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rura",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "The hook pipeline",
|
|
5
5
|
"author": "Yiming Liao",
|
|
6
6
|
"homepage": "https://github.com/yiming-liao/rura#readme",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"module": "./dist/index.js",
|
|
38
38
|
"types": "./dist/types/export/index.d.ts",
|
|
39
39
|
"files": [
|
|
40
|
-
"dist",
|
|
40
|
+
"dist/index.*",
|
|
41
41
|
"README.md",
|
|
42
42
|
"LICENSE"
|
|
43
43
|
],
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rura — The hook pipeline.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
export { rura } from "../src/rura";
|
|
7
|
-
export { createHook, createHookAsync, type RuraHookBase, type RuraHookSync, type RuraHookAsync, type RuraHook, } from "../src/hooks";
|
|
8
|
-
export { createPipeline, createPipelineAsync, run, runAsync, type RuraResult, } from "../src/pipeline";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../export/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,OAAO,EACL,UAAU,EACV,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,GAAG,EACH,QAAQ,EACR,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { RuraHookAsync, RuraHookSync } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a synchronous hook.
|
|
4
|
-
*
|
|
5
|
-
* The hook executes without awaiting.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare function createHook<Ctx = unknown, Out = unknown>(name: string, run: RuraHookSync<Ctx, Out>["run"], order?: number): RuraHookSync<Ctx, Out>;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an asynchronous hook.
|
|
12
|
-
*
|
|
13
|
-
* The hook executes via `await`.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export declare function createHookAsync<Ctx = unknown, Out = unknown>(name: string, run: RuraHookAsync<Ctx, Out>["run"], order?: number): RuraHookAsync<Ctx, Out>;
|
|
18
|
-
//# sourceMappingURL=create-hook.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-hook.d.ts","sourceRoot":"","sources":["../../../../src/hooks/create-hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG3D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACrD,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,EAClC,KAAK,CAAC,EAAE,MAAM,GACb,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAQxB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EAC1D,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,EACnC,KAAK,CAAC,EAAE,MAAM,GACb,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CASzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,QAAQ,GACT,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal.ts"],"names":[],"mappings":""}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base contract for all Rura hooks.
|
|
3
|
-
*
|
|
4
|
-
* A hook is an ordered execution unit within a pipeline.
|
|
5
|
-
* The `name` uniquely identifies the hook.
|
|
6
|
-
* The optional `order` controls execution priority (lower values run first).
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export interface RuraHookBase {
|
|
11
|
-
/** Unique hook identifier. */
|
|
12
|
-
name: string;
|
|
13
|
-
/** Execution priority. Lower values run earlier. */
|
|
14
|
-
order?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Synchronous hook.
|
|
18
|
-
*
|
|
19
|
-
* Executed without awaiting.
|
|
20
|
-
* The provided `ctx` may be mutated.
|
|
21
|
-
* Returning an early signal terminates the pipeline.
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export interface RuraHookSync<Ctx, Out> extends RuraHookBase {
|
|
26
|
-
run(ctx: Ctx): void | {
|
|
27
|
-
early: true;
|
|
28
|
-
output: Out;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Asynchronous hook.
|
|
33
|
-
*
|
|
34
|
-
* Executed via `await`.
|
|
35
|
-
* The provided `ctx` may be mutated.
|
|
36
|
-
* Resolving with an early signal terminates the pipeline.
|
|
37
|
-
*
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export interface RuraHookAsync<Ctx, Out> extends RuraHookBase {
|
|
41
|
-
run(ctx: Ctx): Promise<void | {
|
|
42
|
-
early: true;
|
|
43
|
-
output: Out;
|
|
44
|
-
}>;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Union of all hook variants supported by the Rura pipeline.
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export type RuraHook<Ctx = unknown, Out = unknown> = RuraHookSync<Ctx, Out> | RuraHookAsync<Ctx, Out>;
|
|
52
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/hooks/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY,CAAC,GAAG,EAAE,GAAG,CAAE,SAAQ,YAAY;IAC1D,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC;CACpD;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa,CAAC,GAAG,EAAE,GAAG,CAAE,SAAQ,YAAY;IAC3D,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,GAAG;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CAC7D;AAED;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,IAC7C,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GACtB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-async-hook.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/utils/is-async-hook.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { RuraHook } from "../../hooks";
|
|
2
|
-
/**
|
|
3
|
-
* Creates an asynchronous Rura pipeline.
|
|
4
|
-
*
|
|
5
|
-
* The returned pipeline:
|
|
6
|
-
* - Executes hooks sequentially using an async strategy.
|
|
7
|
-
* - Accepts any RuraHook, including sync and async variants.
|
|
8
|
-
* - Preserves deterministic ordering based on `order`.
|
|
9
|
-
*
|
|
10
|
-
* This variant guarantees that `run()` returns a Promise.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare function createPipelineAsync<Ctx = unknown, Out = unknown>(hooks?: RuraHook<Ctx, Out>[]): {
|
|
15
|
-
use: (hook: RuraHook<Ctx, Out>) => /*elided*/ any;
|
|
16
|
-
getHooks: () => RuraHook<Ctx, Out>[];
|
|
17
|
-
logHooks: () => void;
|
|
18
|
-
run: (ctx: Ctx) => Promise<import("..").RuraResult<Ctx, Out>>;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=create-pipeline-async.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-pipeline-async.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/create/create-pipeline-async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EAC9D,KAAK,GAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAO;;;;;EAOjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-pipeline-base.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/create/create-pipeline-base.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type RuraHookSync } from "../../hooks";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a synchronous Rura pipeline.
|
|
4
|
-
*
|
|
5
|
-
* The returned pipeline:
|
|
6
|
-
* - Executes hooks sequentially using a synchronous strategy.
|
|
7
|
-
* - Rejects asynchronous hooks at registration time.
|
|
8
|
-
* - Preserves deterministic ordering based on `order`.
|
|
9
|
-
*
|
|
10
|
-
* This variant guarantees that `run()` returns immediately
|
|
11
|
-
* without producing a Promise.
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export declare function createPipeline<Ctx = unknown, Out = unknown>(hooks?: RuraHookSync<Ctx, Out>[]): {
|
|
16
|
-
use: (hook: RuraHookSync<Ctx, Out>) => /*elided*/ any;
|
|
17
|
-
getHooks: () => RuraHookSync<Ctx, Out>[];
|
|
18
|
-
logHooks: () => void;
|
|
19
|
-
run: (ctx: Ctx) => import("..").RuraResult<Ctx, Out>;
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=create-pipeline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-pipeline.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/create/create-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACzD,KAAK,GAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EAAO;;;;;EAOrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/create/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-sync-hook.d.ts","sourceRoot":"","sources":["../../../../../../src/pipeline/create/utils/assert-sync-hook.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-pipeline-hooks.d.ts","sourceRoot":"","sources":["../../../../../../src/pipeline/create/utils/log-pipeline-hooks.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/run/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { RuraHook } from "../../hooks";
|
|
2
|
-
import type { RuraResult } from "../../pipeline/types";
|
|
3
|
-
/**
|
|
4
|
-
* Executes an asynchronous Rura pipeline.
|
|
5
|
-
*
|
|
6
|
-
* Hooks are awaited sequentially in the provided order.
|
|
7
|
-
*
|
|
8
|
-
* Execution contract:
|
|
9
|
-
* - Each hook receives the same `ctx` reference.
|
|
10
|
-
* - Hooks may be synchronous or asynchronous.
|
|
11
|
-
* - If a hook resolves to `{ early: true, output }`,
|
|
12
|
-
* execution stops immediately and that result is returned.
|
|
13
|
-
* - If no hook triggers early termination, a normal result
|
|
14
|
-
* `{ early: false, ctx }` is returned.
|
|
15
|
-
*
|
|
16
|
-
* This function always returns a Promise.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export declare function runAsync<Ctx = unknown, Out = unknown>(ctx: Ctx, hooks: RuraHook<Ctx, Out>[]): Promise<RuraResult<Ctx, Out>>;
|
|
21
|
-
//# sourceMappingURL=run-async.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-async.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/run/run-async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EACzD,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAC1B,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAiB/B"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { RuraHookSync } from "../../hooks";
|
|
2
|
-
import type { RuraResult } from "../../pipeline/types";
|
|
3
|
-
/**
|
|
4
|
-
* Executes a synchronous Rura pipeline.
|
|
5
|
-
*
|
|
6
|
-
* Hooks are executed sequentially in the given order.
|
|
7
|
-
*
|
|
8
|
-
* Execution contract:
|
|
9
|
-
* - Each hook receives the same `ctx` reference.
|
|
10
|
-
* - If a hook returns `{ early: true, output }`,
|
|
11
|
-
* execution stops immediately and that result is returned.
|
|
12
|
-
* - If no hook triggers early termination, a normal result
|
|
13
|
-
* `{ early: false, ctx }` is returned.
|
|
14
|
-
*
|
|
15
|
-
* This function is strictly synchronous:
|
|
16
|
-
* - It does not produce a Promise.
|
|
17
|
-
* - Only `RuraHookSync` hooks are allowed.
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export declare function run<Ctx = unknown, Out = unknown>(ctx: Ctx, hooks: RuraHookSync<Ctx, Out>[]): RuraResult<Ctx, Out>;
|
|
22
|
-
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../../src/pipeline/run/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,GAAG,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,EAC9C,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAC9B,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAiBtB"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Result of a Rura pipeline execution.
|
|
3
|
-
*
|
|
4
|
-
* This type represents the final outcome of running a pipeline,
|
|
5
|
-
* either through `run` or `runAsync`.
|
|
6
|
-
*
|
|
7
|
-
* Execution semantics:
|
|
8
|
-
* - `ctx` always refers to the same context object that was
|
|
9
|
-
* passed into the pipeline. Hooks may mutate it in place.
|
|
10
|
-
* - When `early` is `true`, execution stopped before all hooks
|
|
11
|
-
* completed, and `output` contains the early-return value.
|
|
12
|
-
* - When `early` is `false`, all hooks were executed and no
|
|
13
|
-
* early termination occurred. In this case, `output` is not present.
|
|
14
|
-
*
|
|
15
|
-
* The `early` field acts as a discriminant for safe narrowing.
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export type RuraResult<Ctx, Out> = {
|
|
20
|
-
early: true;
|
|
21
|
-
ctx: Ctx;
|
|
22
|
-
output: Out;
|
|
23
|
-
} | {
|
|
24
|
-
early: false;
|
|
25
|
-
ctx: Ctx;
|
|
26
|
-
output?: never;
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,UAAU,CAAC,GAAG,EAAE,GAAG,IAC3B;IACE,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,GAAG,CAAC;CACb,GACD;IACE,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CAAC"}
|
package/dist/types/src/rura.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createHook, createHookAsync } from "./hooks";
|
|
2
|
-
import { createPipeline, createPipelineAsync } from "./pipeline/create";
|
|
3
|
-
import { run, runAsync } from "./pipeline/run";
|
|
4
|
-
/**
|
|
5
|
-
* Rura public API namespace.
|
|
6
|
-
*
|
|
7
|
-
* Provides a cohesive entry point for:
|
|
8
|
-
*
|
|
9
|
-
* - Hook factories (`createHook`, `createHookAsync`)
|
|
10
|
-
* - Direct executors (`run`, `runAsync`)
|
|
11
|
-
* - Pipeline constructors (`createPipeline`, `createPipelineAsync`)
|
|
12
|
-
*
|
|
13
|
-
* This object contains no additional logic —
|
|
14
|
-
* it simply exposes the stable, public surface of Rura.
|
|
15
|
-
*
|
|
16
|
-
* The namespace is frozen to prevent runtime mutation.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export declare const rura: Readonly<{
|
|
21
|
-
createHook: typeof createHook;
|
|
22
|
-
createHookAsync: typeof createHookAsync;
|
|
23
|
-
run: typeof run;
|
|
24
|
-
runAsync: typeof runAsync;
|
|
25
|
-
createPipeline: typeof createPipeline;
|
|
26
|
-
createPipelineAsync: typeof createPipelineAsync;
|
|
27
|
-
}>;
|
|
28
|
-
//# sourceMappingURL=rura.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rura.d.ts","sourceRoot":"","sources":["../../../src/rura.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,IAAI;;;;;;;EAYf,CAAC"}
|