@ontrails/core 1.0.0-beta.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/.turbo/turbo-build.log +1 -0
- package/.turbo/turbo-lint.log +3 -0
- package/.turbo/turbo-typecheck.log +1 -0
- package/CHANGELOG.md +15 -0
- package/README.md +179 -0
- package/dist/adapters.d.ts +39 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +2 -0
- package/dist/adapters.js.map +1 -0
- package/dist/blob-ref.d.ts +20 -0
- package/dist/blob-ref.d.ts.map +1 -0
- package/dist/blob-ref.js +22 -0
- package/dist/blob-ref.js.map +1 -0
- package/dist/branded.d.ts +36 -0
- package/dist/branded.d.ts.map +1 -0
- package/dist/branded.js +89 -0
- package/dist/branded.js.map +1 -0
- package/dist/collections.d.ts +31 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +60 -0
- package/dist/collections.js.map +1 -0
- package/dist/context.d.ts +10 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +15 -0
- package/dist/context.js.map +1 -0
- package/dist/derive.d.ts +33 -0
- package/dist/derive.d.ts.map +1 -0
- package/dist/derive.js +122 -0
- package/dist/derive.js.map +1 -0
- package/dist/errors.d.ts +83 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +142 -0
- package/dist/errors.js.map +1 -0
- package/dist/event.d.ts +45 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +17 -0
- package/dist/event.js.map +1 -0
- package/dist/fetch.d.ts +15 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +102 -0
- package/dist/fetch.js.map +1 -0
- package/dist/guards.d.ts +17 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +25 -0
- package/dist/guards.js.map +1 -0
- package/dist/health.d.ts +18 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +5 -0
- package/dist/health.js.map +1 -0
- package/dist/hike.d.ts +36 -0
- package/dist/hike.d.ts.map +1 -0
- package/dist/hike.js +20 -0
- package/dist/hike.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/job.d.ts +24 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +17 -0
- package/dist/job.js.map +1 -0
- package/dist/layer.d.ts +17 -0
- package/dist/layer.d.ts.map +1 -0
- package/dist/layer.js +21 -0
- package/dist/layer.js.map +1 -0
- package/dist/path-security.d.ts +28 -0
- package/dist/path-security.d.ts.map +1 -0
- package/dist/path-security.js +63 -0
- package/dist/path-security.js.map +1 -0
- package/dist/patterns/bulk.d.ts +15 -0
- package/dist/patterns/bulk.d.ts.map +1 -0
- package/dist/patterns/bulk.js +14 -0
- package/dist/patterns/bulk.js.map +1 -0
- package/dist/patterns/change.d.ts +10 -0
- package/dist/patterns/change.d.ts.map +1 -0
- package/dist/patterns/change.js +10 -0
- package/dist/patterns/change.js.map +1 -0
- package/dist/patterns/date-range.d.ts +10 -0
- package/dist/patterns/date-range.d.ts.map +1 -0
- package/dist/patterns/date-range.js +10 -0
- package/dist/patterns/date-range.js.map +1 -0
- package/dist/patterns/index.d.ts +9 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +9 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/pagination.d.ts +18 -0
- package/dist/patterns/pagination.d.ts.map +1 -0
- package/dist/patterns/pagination.js +18 -0
- package/dist/patterns/pagination.js.map +1 -0
- package/dist/patterns/progress.d.ts +11 -0
- package/dist/patterns/progress.d.ts.map +1 -0
- package/dist/patterns/progress.js +11 -0
- package/dist/patterns/progress.js.map +1 -0
- package/dist/patterns/sorting.d.ts +13 -0
- package/dist/patterns/sorting.d.ts.map +1 -0
- package/dist/patterns/sorting.js +10 -0
- package/dist/patterns/sorting.js.map +1 -0
- package/dist/patterns/status.d.ts +15 -0
- package/dist/patterns/status.d.ts.map +1 -0
- package/dist/patterns/status.js +9 -0
- package/dist/patterns/status.js.map +1 -0
- package/dist/patterns/timestamps.d.ts +10 -0
- package/dist/patterns/timestamps.d.ts.map +1 -0
- package/dist/patterns/timestamps.js +10 -0
- package/dist/patterns/timestamps.js.map +1 -0
- package/dist/redaction/index.d.ts +4 -0
- package/dist/redaction/index.d.ts.map +1 -0
- package/dist/redaction/index.js +3 -0
- package/dist/redaction/index.js.map +1 -0
- package/dist/redaction/patterns.d.ts +9 -0
- package/dist/redaction/patterns.d.ts.map +1 -0
- package/dist/redaction/patterns.js +39 -0
- package/dist/redaction/patterns.js.map +1 -0
- package/dist/redaction/redactor.d.ts +27 -0
- package/dist/redaction/redactor.d.ts.map +1 -0
- package/dist/redaction/redactor.js +89 -0
- package/dist/redaction/redactor.js.map +1 -0
- package/dist/resilience.d.ts +34 -0
- package/dist/resilience.d.ts.map +1 -0
- package/dist/resilience.js +164 -0
- package/dist/resilience.js.map +1 -0
- package/dist/result.d.ts +57 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +145 -0
- package/dist/result.js.map +1 -0
- package/dist/serialization.d.ts +27 -0
- package/dist/serialization.d.ts.map +1 -0
- package/dist/serialization.js +115 -0
- package/dist/serialization.js.map +1 -0
- package/dist/topo.d.ts +18 -0
- package/dist/topo.d.ts.map +1 -0
- package/dist/topo.js +74 -0
- package/dist/topo.js.map +1 -0
- package/dist/trail.d.ts +83 -0
- package/dist/trail.d.ts.map +1 -0
- package/dist/trail.js +16 -0
- package/dist/trail.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validate-topo.d.ts +24 -0
- package/dist/validate-topo.d.ts.map +1 -0
- package/dist/validate-topo.js +108 -0
- package/dist/validate-topo.js.map +1 -0
- package/dist/validation.d.ts +27 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +134 -0
- package/dist/validation.js.map +1 -0
- package/dist/workspace.d.ts +25 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +57 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +21 -0
- package/src/__tests__/blob-ref.test.ts +103 -0
- package/src/__tests__/branded.test.ts +148 -0
- package/src/__tests__/collections.test.ts +126 -0
- package/src/__tests__/context.test.ts +66 -0
- package/src/__tests__/derive.test.ts +159 -0
- package/src/__tests__/errors.test.ts +309 -0
- package/src/__tests__/event.test.ts +82 -0
- package/src/__tests__/fetch.test.ts +217 -0
- package/src/__tests__/guards.test.ts +102 -0
- package/src/__tests__/hike.test.ts +117 -0
- package/src/__tests__/job.test.ts +98 -0
- package/src/__tests__/layer.test.ts +224 -0
- package/src/__tests__/path-security.test.ts +114 -0
- package/src/__tests__/patterns.test.ts +273 -0
- package/src/__tests__/redaction.test.ts +244 -0
- package/src/__tests__/resilience.test.ts +246 -0
- package/src/__tests__/result.test.ts +155 -0
- package/src/__tests__/serialization.test.ts +236 -0
- package/src/__tests__/topo.test.ts +184 -0
- package/src/__tests__/trail.test.ts +179 -0
- package/src/__tests__/validate-topo.test.ts +201 -0
- package/src/__tests__/validation.test.ts +283 -0
- package/src/__tests__/workspace.test.ts +183 -0
- package/src/adapters.ts +68 -0
- package/src/blob-ref.ts +39 -0
- package/src/branded.ts +135 -0
- package/src/collections.ts +99 -0
- package/src/context.ts +18 -0
- package/src/derive.ts +223 -0
- package/src/errors.ts +196 -0
- package/src/event.ts +77 -0
- package/src/fetch.ts +138 -0
- package/src/guards.ts +37 -0
- package/src/health.ts +23 -0
- package/src/hike.ts +77 -0
- package/src/index.ts +158 -0
- package/src/job.ts +20 -0
- package/src/layer.ts +44 -0
- package/src/path-security.ts +90 -0
- package/src/patterns/bulk.ts +16 -0
- package/src/patterns/change.ts +12 -0
- package/src/patterns/date-range.ts +12 -0
- package/src/patterns/index.ts +8 -0
- package/src/patterns/pagination.ts +22 -0
- package/src/patterns/progress.ts +13 -0
- package/src/patterns/sorting.ts +14 -0
- package/src/patterns/status.ts +11 -0
- package/src/patterns/timestamps.ts +12 -0
- package/src/redaction/index.ts +3 -0
- package/src/redaction/patterns.ts +47 -0
- package/src/redaction/redactor.ts +178 -0
- package/src/resilience.ts +234 -0
- package/src/result.ts +180 -0
- package/src/serialization.ts +183 -0
- package/src/topo.ts +123 -0
- package/src/trail.ts +130 -0
- package/src/types.ts +58 -0
- package/src/validate-topo.ts +151 -0
- package/src/validation.ts +182 -0
- package/src/workspace.ts +77 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/health.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../src/health.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E"}
|
package/dist/hike.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hike — a composition that follows trails.
|
|
3
|
+
*/
|
|
4
|
+
import type { Trail, TrailSpec } from './trail.js';
|
|
5
|
+
export interface HikeSpec<I, O> extends TrailSpec<I, O> {
|
|
6
|
+
readonly follows: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export interface Hike<I, O> extends Omit<Trail<I, O>, 'kind'> {
|
|
9
|
+
readonly kind: 'hike';
|
|
10
|
+
readonly follows: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a hike definition.
|
|
14
|
+
*
|
|
15
|
+
* A hike is a composition that declares which trails it follows.
|
|
16
|
+
* Returns a frozen object with `kind: "hike"` and all spec fields.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // ID as first argument
|
|
21
|
+
* const onboard = hike("entity.onboard", {
|
|
22
|
+
* follows: ["entity.add", "entity.relate"],
|
|
23
|
+
* input: z.object({ name: z.string() }),
|
|
24
|
+
* implementation: (input, ctx) => Result.ok(...),
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Full spec object (programmatic)
|
|
28
|
+
* const onboard = hike({ id: "entity.onboard", follows: [...], ... });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function hike<I, O>(id: string, spec: HikeSpec<I, O>): Hike<I, O>;
|
|
32
|
+
export declare function hike<I, O>(spec: HikeSpec<I, O> & {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
}): Hike<I, O>;
|
|
35
|
+
export type AnyHike = Hike<any, any>;
|
|
36
|
+
//# sourceMappingURL=hike.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hike.d.ts","sourceRoot":"","sources":["../src/hike.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOnD,MAAM,WAAW,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IACrD,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAMD,MAAM,WAAW,IAAI,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EACvB,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC7C,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AA0Bd,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
|
package/dist/hike.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hike — a composition that follows trails.
|
|
3
|
+
*/
|
|
4
|
+
export function hike(idOrSpec, maybeSpec) {
|
|
5
|
+
const resolved = typeof idOrSpec === 'string'
|
|
6
|
+
? { id: idOrSpec, spec: maybeSpec }
|
|
7
|
+
: { id: idOrSpec.id, spec: idOrSpec };
|
|
8
|
+
if (!resolved.spec) {
|
|
9
|
+
throw new TypeError('hike() requires a spec when an id is provided');
|
|
10
|
+
}
|
|
11
|
+
const { follows, implementation, ...rest } = resolved.spec;
|
|
12
|
+
return Object.freeze({
|
|
13
|
+
...rest,
|
|
14
|
+
follows: Object.freeze([...follows]),
|
|
15
|
+
id: resolved.id,
|
|
16
|
+
implementation: async (input, ctx) => await implementation(input, ctx),
|
|
17
|
+
kind: 'hike',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=hike.js.map
|
package/dist/hike.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hike.js","sourceRoot":"","sources":["../src/hike.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiDH,MAAM,UAAU,IAAI,CAClB,QAA6D,EAC7D,SAA0B;IAE1B,MAAM,QAAQ,GACZ,OAAO,QAAQ,KAAK,QAAQ;QAC1B,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;QACnC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAE1C,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3D,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,IAAI;QACP,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;QACpC,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,cAAc,EAAE,KAAK,EAAE,KAAQ,EAAE,GAAiB,EAAE,EAAE,CACpD,MAAM,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC;QAClC,IAAI,EAAE,MAAe;KACtB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { Result } from './result.js';
|
|
2
|
+
export { TrailsError, ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, AuthError, CancelledError, exitCodeMap, statusCodeMap, jsonRpcCodeMap, retryableMap, isRetryable, isTrailsError, } from './errors.js';
|
|
3
|
+
export type { ErrorCategory } from './errors.js';
|
|
4
|
+
export type { Implementation, TrailContext, FollowFn, ProgressCallback, ProgressEvent, Logger, Surface, } from './types.js';
|
|
5
|
+
export { createTrailContext } from './context.js';
|
|
6
|
+
export { trail } from './trail.js';
|
|
7
|
+
export type { AnyTrail, Trail, TrailSpec, TrailExample } from './trail.js';
|
|
8
|
+
export { hike } from './hike.js';
|
|
9
|
+
export type { AnyHike, Hike, HikeSpec } from './hike.js';
|
|
10
|
+
export { event } from './event.js';
|
|
11
|
+
export type { AnyEvent, Event, EventSpec } from './event.js';
|
|
12
|
+
export { topo } from './topo.js';
|
|
13
|
+
export type { Topo } from './topo.js';
|
|
14
|
+
export { validateTopo } from './validate-topo.js';
|
|
15
|
+
export type { TopoIssue } from './validate-topo.js';
|
|
16
|
+
export { composeLayers } from './layer.js';
|
|
17
|
+
export type { Layer } from './layer.js';
|
|
18
|
+
export type { HealthStatus, HealthResult } from './health.js';
|
|
19
|
+
export type { IndexAdapter, StorageAdapter, CacheAdapter, SearchOptions, SearchResult, StorageOptions, } from './adapters.js';
|
|
20
|
+
export { deriveFields } from './derive.js';
|
|
21
|
+
export type { Field, FieldOverride } from './derive.js';
|
|
22
|
+
export { validateInput, validateOutput, formatZodIssues, zodToJsonSchema, } from './validation.js';
|
|
23
|
+
export { serializeError, deserializeError } from './serialization.js';
|
|
24
|
+
export type { SerializedError } from './serialization.js';
|
|
25
|
+
export { retry, withTimeout, shouldRetry, getBackoffDelay, } from './resilience.js';
|
|
26
|
+
export type { RetryOptions } from './resilience.js';
|
|
27
|
+
export { brand, unbrand, uuid, email, nonEmptyString, positiveInt, shortId, hashId, } from './branded.js';
|
|
28
|
+
export type { Branded, UUID, Email, NonEmptyString, PositiveInt, } from './branded.js';
|
|
29
|
+
export { securePath, isPathSafe, resolveSafePath } from './path-security.js';
|
|
30
|
+
export { findWorkspaceRoot, isInsideWorkspace, getRelativePath, } from './workspace.js';
|
|
31
|
+
export { isDefined, isNonEmptyString, isPlainObject, hasProperty, assertNever, } from './guards.js';
|
|
32
|
+
export { chunk, dedupe, groupBy, sortBy, isNonEmptyArray, } from './collections.js';
|
|
33
|
+
export type { NonEmptyArray, DeepPartial, Prettify, AtLeastOne, } from './collections.js';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Result
|
|
2
|
+
export { Result } from './result.js';
|
|
3
|
+
// Errors
|
|
4
|
+
export { TrailsError, ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, AuthError, CancelledError, exitCodeMap, statusCodeMap, jsonRpcCodeMap, retryableMap, isRetryable, isTrailsError, } from './errors.js';
|
|
5
|
+
// Context factory
|
|
6
|
+
export { createTrailContext } from './context.js';
|
|
7
|
+
// Trail
|
|
8
|
+
export { trail } from './trail.js';
|
|
9
|
+
// Hike
|
|
10
|
+
export { hike } from './hike.js';
|
|
11
|
+
// Event
|
|
12
|
+
export { event } from './event.js';
|
|
13
|
+
// Topo
|
|
14
|
+
export { topo } from './topo.js';
|
|
15
|
+
// Topo validation
|
|
16
|
+
export { validateTopo } from './validate-topo.js';
|
|
17
|
+
// Layer
|
|
18
|
+
export { composeLayers } from './layer.js';
|
|
19
|
+
// Derive
|
|
20
|
+
export { deriveFields } from './derive.js';
|
|
21
|
+
// Validation
|
|
22
|
+
export { validateInput, validateOutput, formatZodIssues, zodToJsonSchema, } from './validation.js';
|
|
23
|
+
// Serialization
|
|
24
|
+
export { serializeError, deserializeError } from './serialization.js';
|
|
25
|
+
// Resilience
|
|
26
|
+
export { retry, withTimeout, shouldRetry, getBackoffDelay, } from './resilience.js';
|
|
27
|
+
// Fetch — fromFetch is available as Result.fromFetch()
|
|
28
|
+
// Branded types
|
|
29
|
+
export { brand, unbrand, uuid, email, nonEmptyString, positiveInt, shortId, hashId, } from './branded.js';
|
|
30
|
+
// Path Security
|
|
31
|
+
export { securePath, isPathSafe, resolveSafePath } from './path-security.js';
|
|
32
|
+
// Workspace
|
|
33
|
+
export { findWorkspaceRoot, isInsideWorkspace, getRelativePath, } from './workspace.js';
|
|
34
|
+
// Guards
|
|
35
|
+
export { isDefined, isNonEmptyString, isPlainObject, hasProperty, assertNever, } from './guards.js';
|
|
36
|
+
// Collections
|
|
37
|
+
export { chunk, dedupe, groupBy, sortBy, isNonEmptyArray, } from './collections.js';
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,SAAS;AACT,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AAcrB,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,QAAQ;AACR,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO;AACP,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,QAAQ;AACR,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO;AACP,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,QAAQ;AACR,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAgB3C,SAAS;AACT,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,aAAa;AACb,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,gBAAgB;AAChB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtE,aAAa;AACb,OAAO,EACL,KAAK,EACL,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,uDAAuD;AAEvD,gBAAgB;AAChB,OAAO,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,cAAc,EACd,WAAW,EACX,OAAO,EACP,MAAM,GACP,MAAM,cAAc,CAAC;AAStB,gBAAgB;AAChB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE7E,YAAY;AACZ,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,SAAS;AACT,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,cAAc;AACd,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
package/dist/job.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Proof: job-style output schema composes from existing pattern helpers.
|
|
4
|
+
* No dedicated `kind: "job"` needed — regular trails with status+progress output work.
|
|
5
|
+
*/
|
|
6
|
+
export declare const jobOutputSchema: z.ZodObject<{
|
|
7
|
+
completedAt: z.ZodOptional<z.ZodString>;
|
|
8
|
+
error: z.ZodOptional<z.ZodString>;
|
|
9
|
+
jobId: z.ZodString;
|
|
10
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
11
|
+
startedAt: z.ZodOptional<z.ZodString>;
|
|
12
|
+
status: z.ZodEnum<{
|
|
13
|
+
cancelled: "cancelled";
|
|
14
|
+
pending: "pending";
|
|
15
|
+
running: "running";
|
|
16
|
+
completed: "completed";
|
|
17
|
+
failed: "failed";
|
|
18
|
+
}>;
|
|
19
|
+
current: z.ZodNumber;
|
|
20
|
+
percentage: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
total: z.ZodNumber;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type JobOutput = z.infer<typeof jobOutputSchema>;
|
|
24
|
+
//# sourceMappingURL=job.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;iBAQ1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
package/dist/job.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { progressFields } from './patterns/progress.js';
|
|
3
|
+
import { statusFields } from './patterns/status.js';
|
|
4
|
+
/**
|
|
5
|
+
* Proof: job-style output schema composes from existing pattern helpers.
|
|
6
|
+
* No dedicated `kind: "job"` needed — regular trails with status+progress output work.
|
|
7
|
+
*/
|
|
8
|
+
export const jobOutputSchema = z.object({
|
|
9
|
+
...progressFields().shape,
|
|
10
|
+
...statusFields().shape,
|
|
11
|
+
completedAt: z.string().optional(),
|
|
12
|
+
error: z.string().optional(),
|
|
13
|
+
jobId: z.string(),
|
|
14
|
+
result: z.unknown().optional(),
|
|
15
|
+
startedAt: z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=job.js.map
|
package/dist/job.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.js","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,GAAG,cAAc,EAAE,CAAC,KAAK;IACzB,GAAG,YAAY,EAAE,CAAC,KAAK;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC"}
|
package/dist/layer.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Trail } from './trail.js';
|
|
2
|
+
import type { Implementation } from './types.js';
|
|
3
|
+
/** A composable middleware that wraps trail implementations */
|
|
4
|
+
export interface Layer {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description?: string | undefined;
|
|
7
|
+
/** Wrap a trail's implementation, returning a new implementation */
|
|
8
|
+
wrap<I, O>(trail: Trail<I, O>, implementation: Implementation<I, O>): Implementation<I, O>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Apply layers outermost-first: layers[0] wraps layers[1] wraps ... wraps
|
|
12
|
+
* the base implementation.
|
|
13
|
+
*
|
|
14
|
+
* An empty layers array returns the implementation unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export declare const composeLayers: <I, O>(layers: readonly Layer[], trail: Trail<I, O>, implementation: Implementation<I, O>) => Implementation<I, O>;
|
|
17
|
+
//# sourceMappingURL=layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer.d.ts","sourceRoot":"","sources":["../src/layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,+DAA+D;AAC/D,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1C,oEAAoE;IACpE,IAAI,CAAC,CAAC,EAAE,CAAC,EACP,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,cAAc,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GACnC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACzB;AAMD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,EAChC,QAAQ,SAAS,KAAK,EAAE,EACxB,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,gBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,KACnC,cAAc,CAAC,CAAC,EAAE,CAAC,CAUrB,CAAC"}
|
package/dist/layer.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Composition
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
/**
|
|
5
|
+
* Apply layers outermost-first: layers[0] wraps layers[1] wraps ... wraps
|
|
6
|
+
* the base implementation.
|
|
7
|
+
*
|
|
8
|
+
* An empty layers array returns the implementation unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export const composeLayers = (layers, trail, implementation) => {
|
|
11
|
+
// Fold right so layers[0] is the outermost wrapper
|
|
12
|
+
let result = implementation;
|
|
13
|
+
for (let i = layers.length - 1; i >= 0; i -= 1) {
|
|
14
|
+
const layer = layers[i];
|
|
15
|
+
if (layer) {
|
|
16
|
+
result = layer.wrap(trail, result);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer.js","sourceRoot":"","sources":["../src/layer.ts"],"names":[],"mappings":"AAmBA,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAAwB,EACxB,KAAkB,EAClB,cAAoC,EACd,EAAE;IACxB,mDAAmD;IACnD,IAAI,MAAM,GAAG,cAAc,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path security utilities for preventing path traversal attacks.
|
|
3
|
+
*
|
|
4
|
+
* All functions are runtime-agnostic (Node / Bun compatible).
|
|
5
|
+
*/
|
|
6
|
+
import { PermissionError } from './errors.js';
|
|
7
|
+
import { Result } from './result.js';
|
|
8
|
+
/**
|
|
9
|
+
* Resolves `userPath` relative to `basePath` and ensures it stays within
|
|
10
|
+
* the base directory. Returns the resolved absolute path on success, or a
|
|
11
|
+
* `PermissionError` if the path escapes.
|
|
12
|
+
*
|
|
13
|
+
* Uses lexical path comparison (not `realpath`). Does not follow symlinks —
|
|
14
|
+
* if an attacker can create symlinks inside `basePath`, those could point
|
|
15
|
+
* outside the base. Use `realpath` before calling in symlink-sensitive environments.
|
|
16
|
+
*/
|
|
17
|
+
export declare const securePath: (basePath: string, userPath: string) => Result<string, PermissionError>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns `true` if `userPath` (resolved against `basePath`) stays within
|
|
20
|
+
* `basePath`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isPathSafe: (basePath: string, userPath: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Joins multiple path segments, resolves them against `basePath`, and
|
|
25
|
+
* validates the result stays within the base directory.
|
|
26
|
+
*/
|
|
27
|
+
export declare const resolveSafePath: (basePath: string, ...segments: string[]) => Result<string, PermissionError>;
|
|
28
|
+
//# sourceMappingURL=path-security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-security.d.ts","sourceRoot":"","sources":["../src/path-security.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmBrC;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,MAAM,CAAC,MAAM,EAAE,eAAe,CAgBhC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,KAAG,OAI/D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,GAAG,UAAU,MAAM,EAAE,KACpB,MAAM,CAAC,MAAM,EAAE,eAAe,CAchC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path security utilities for preventing path traversal attacks.
|
|
3
|
+
*
|
|
4
|
+
* All functions are runtime-agnostic (Node / Bun compatible).
|
|
5
|
+
*/
|
|
6
|
+
import { resolve, relative, normalize, isAbsolute } from 'node:path';
|
|
7
|
+
import { PermissionError } from './errors.js';
|
|
8
|
+
import { Result } from './result.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Internal
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/** Returns true when `target` is equal to or a descendant of `base`. */
|
|
13
|
+
const isWithin = (base, target) => {
|
|
14
|
+
const rel = relative(base, target);
|
|
15
|
+
// Empty string means they are the same directory.
|
|
16
|
+
// A relative path starting with ".." means it escapes.
|
|
17
|
+
// An absolute path means a completely different tree.
|
|
18
|
+
return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
|
|
19
|
+
};
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Public API
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* Resolves `userPath` relative to `basePath` and ensures it stays within
|
|
25
|
+
* the base directory. Returns the resolved absolute path on success, or a
|
|
26
|
+
* `PermissionError` if the path escapes.
|
|
27
|
+
*
|
|
28
|
+
* Uses lexical path comparison (not `realpath`). Does not follow symlinks —
|
|
29
|
+
* if an attacker can create symlinks inside `basePath`, those could point
|
|
30
|
+
* outside the base. Use `realpath` before calling in symlink-sensitive environments.
|
|
31
|
+
*/
|
|
32
|
+
export const securePath = (basePath, userPath) => {
|
|
33
|
+
const base = resolve(basePath);
|
|
34
|
+
const resolved = resolve(base, userPath);
|
|
35
|
+
if (!isWithin(base, resolved)) {
|
|
36
|
+
return Result.err(new PermissionError(`Path traversal detected: "${userPath}" escapes "${basePath}"`, {
|
|
37
|
+
context: { basePath: base, resolved, userPath },
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
return Result.ok(resolved);
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Returns `true` if `userPath` (resolved against `basePath`) stays within
|
|
44
|
+
* `basePath`.
|
|
45
|
+
*/
|
|
46
|
+
export const isPathSafe = (basePath, userPath) => {
|
|
47
|
+
const base = resolve(basePath);
|
|
48
|
+
const resolved = resolve(base, userPath);
|
|
49
|
+
return isWithin(base, resolved);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Joins multiple path segments, resolves them against `basePath`, and
|
|
53
|
+
* validates the result stays within the base directory.
|
|
54
|
+
*/
|
|
55
|
+
export const resolveSafePath = (basePath, ...segments) => {
|
|
56
|
+
const base = resolve(basePath);
|
|
57
|
+
const joined = resolve(base, ...segments.map((s) => normalize(s)));
|
|
58
|
+
if (!isWithin(base, joined)) {
|
|
59
|
+
return Result.err(new PermissionError(`Path traversal detected: segments escape "${basePath}"`, { context: { basePath: base, resolved: joined, segments } }));
|
|
60
|
+
}
|
|
61
|
+
return Result.ok(joined);
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=path-security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-security.js","sourceRoot":"","sources":["../src/path-security.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E,wEAAwE;AACxE,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,MAAc,EAAW,EAAE;IACzD,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnC,kDAAkD;IAClD,uDAAuD;IACvD,sDAAsD;IACtD,OAAO,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,QAAgB,EAChB,QAAgB,EACiB,EAAE;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEzC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,eAAe,CACjB,6BAA6B,QAAQ,cAAc,QAAQ,GAAG,EAC9D;YACE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE;SAChD,CACF,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,QAAgB,EAAW,EAAE;IACxE,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACzC,OAAO,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,QAAgB,EAChB,GAAG,QAAkB,EACY,EAAE;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,eAAe,CACjB,6CAA6C,QAAQ,GAAG,EACxD,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAC5D,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bulk operation schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Bulk operation output wrapper for a given item schema. */
|
|
6
|
+
export declare const bulkOutput: <T>(itemSchema: z.ZodType<T>) => z.ZodObject<{
|
|
7
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
8
|
+
index: z.ZodNumber;
|
|
9
|
+
message: z.ZodString;
|
|
10
|
+
}, z.core.$strip>>>;
|
|
11
|
+
failed: z.ZodNumber;
|
|
12
|
+
items: z.ZodArray<z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>>;
|
|
13
|
+
succeeded: z.ZodNumber;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
//# sourceMappingURL=bulk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulk.d.ts","sourceRoot":"","sources":["../../src/patterns/bulk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6DAA6D;AAC7D,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;;;;iBAQlD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bulk operation schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Bulk operation output wrapper for a given item schema. */
|
|
6
|
+
export const bulkOutput = (itemSchema) => z.object({
|
|
7
|
+
errors: z
|
|
8
|
+
.array(z.object({ index: z.number(), message: z.string() }))
|
|
9
|
+
.optional(),
|
|
10
|
+
failed: z.number(),
|
|
11
|
+
items: z.array(itemSchema),
|
|
12
|
+
succeeded: z.number(),
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=bulk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulk.js","sourceRoot":"","sources":["../../src/patterns/bulk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAI,UAAwB,EAAE,EAAE,CACxD,CAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SAC3D,QAAQ,EAAE;IACb,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change-tracking schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Before/after change output for a given schema. */
|
|
6
|
+
export declare const changeOutput: <T>(schema: z.ZodType<T>) => z.ZodObject<{
|
|
7
|
+
after: z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>;
|
|
8
|
+
before: z.ZodOptional<z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
//# sourceMappingURL=change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../../src/patterns/change.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qDAAqD;AACrD,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;iBAIhD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change-tracking schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Before/after change output for a given schema. */
|
|
6
|
+
export const changeOutput = (schema) => z.object({
|
|
7
|
+
after: schema,
|
|
8
|
+
before: schema.optional(),
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change.js","sourceRoot":"","sources":["../../src/patterns/change.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,MAAoB,EAAE,EAAE,CACtD,CAAC,CAAC,MAAM,CAAC;IACP,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;CAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date-range schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Optional since/until date-range fields. */
|
|
6
|
+
export declare const dateRangeFields: () => z.ZodObject<{
|
|
7
|
+
since: z.ZodOptional<z.ZodString>;
|
|
8
|
+
until: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
//# sourceMappingURL=date-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-range.d.ts","sourceRoot":"","sources":["../../src/patterns/date-range.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8CAA8C;AAC9C,eAAO,MAAM,eAAe;;;iBAIxB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date-range schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Optional since/until date-range fields. */
|
|
6
|
+
export const dateRangeFields = () => z.object({
|
|
7
|
+
since: z.string().optional(),
|
|
8
|
+
until: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=date-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-range.js","sourceRoot":"","sources":["../../src/patterns/date-range.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAClC,CAAC,CAAC,MAAM,CAAC;IACP,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { paginationFields, paginatedOutput } from './pagination.js';
|
|
2
|
+
export { bulkOutput } from './bulk.js';
|
|
3
|
+
export { timestampFields } from './timestamps.js';
|
|
4
|
+
export { dateRangeFields } from './date-range.js';
|
|
5
|
+
export { sortFields } from './sorting.js';
|
|
6
|
+
export { statusFields } from './status.js';
|
|
7
|
+
export { changeOutput } from './change.js';
|
|
8
|
+
export { progressFields } from './progress.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/patterns/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { paginationFields, paginatedOutput } from './pagination.js';
|
|
2
|
+
export { bulkOutput } from './bulk.js';
|
|
3
|
+
export { timestampFields } from './timestamps.js';
|
|
4
|
+
export { dateRangeFields } from './date-range.js';
|
|
5
|
+
export { sortFields } from './sorting.js';
|
|
6
|
+
export { statusFields } from './status.js';
|
|
7
|
+
export { changeOutput } from './change.js';
|
|
8
|
+
export { progressFields } from './progress.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/patterns/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Common pagination input fields. */
|
|
6
|
+
export declare const paginationFields: () => z.ZodObject<{
|
|
7
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
8
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
/** Paginated output wrapper for a given item schema. */
|
|
12
|
+
export declare const paginatedOutput: <T>(itemSchema: z.ZodType<T>) => z.ZodObject<{
|
|
13
|
+
hasMore: z.ZodBoolean;
|
|
14
|
+
items: z.ZodArray<z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>>;
|
|
15
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
16
|
+
total: z.ZodNumber;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/patterns/pagination.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sCAAsC;AACtC,eAAO,MAAM,gBAAgB;;;;iBAKzB,CAAC;AAEL,wDAAwD;AACxD,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;iBAMvD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Common pagination input fields. */
|
|
6
|
+
export const paginationFields = () => z.object({
|
|
7
|
+
cursor: z.string().optional(),
|
|
8
|
+
limit: z.number().optional().default(20),
|
|
9
|
+
offset: z.number().optional().default(0),
|
|
10
|
+
});
|
|
11
|
+
/** Paginated output wrapper for a given item schema. */
|
|
12
|
+
export const paginatedOutput = (itemSchema) => z.object({
|
|
13
|
+
hasMore: z.boolean(),
|
|
14
|
+
items: z.array(itemSchema),
|
|
15
|
+
nextCursor: z.string().optional(),
|
|
16
|
+
total: z.number(),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/patterns/pagination.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sCAAsC;AACtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,CAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACxC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAEL,wDAAwD;AACxD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAI,UAAwB,EAAE,EAAE,CAC7D,CAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IAC1B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Progress tracking fields. */
|
|
6
|
+
export declare const progressFields: () => z.ZodObject<{
|
|
7
|
+
current: z.ZodNumber;
|
|
8
|
+
percentage: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
total: z.ZodNumber;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/patterns/progress.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gCAAgC;AAChC,eAAO,MAAM,cAAc;;;;iBAKvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Progress tracking fields. */
|
|
6
|
+
export const progressFields = () => z.object({
|
|
7
|
+
current: z.number(),
|
|
8
|
+
percentage: z.number().optional(),
|
|
9
|
+
total: z.number(),
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/patterns/progress.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CACjC,CAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sorting schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Sort fields constrained to a set of allowed column names. */
|
|
6
|
+
export declare const sortFields: <const T extends string>(allowedFields: [T, ...T[]]) => z.ZodObject<{
|
|
7
|
+
sortBy: z.ZodOptional<z.ZodEnum<{ [k_1 in T]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>>;
|
|
8
|
+
sortOrder: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
asc: "asc";
|
|
10
|
+
desc: "desc";
|
|
11
|
+
}>>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
//# sourceMappingURL=sorting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting.d.ts","sourceRoot":"","sources":["../../src/patterns/sorting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gEAAgE;AAChE,eAAO,MAAM,UAAU,GAAI,KAAK,CAAC,CAAC,SAAS,MAAM,EAC/C,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;;;;;;iBAKxB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sorting schema helpers for @ontrails/core/patterns
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Sort fields constrained to a set of allowed column names. */
|
|
6
|
+
export const sortFields = (allowedFields) => z.object({
|
|
7
|
+
sortBy: z.enum(allowedFields).optional(),
|
|
8
|
+
sortOrder: z.enum(['asc', 'desc']).optional().default('asc'),
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=sorting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting.js","sourceRoot":"","sources":["../../src/patterns/sorting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,aAA0B,EAC1B,EAAE,CACF,CAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE;IACxC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CAC7D,CAAC,CAAC"}
|