@ontrails/core 1.0.0-beta.3 → 1.0.0-beta.32

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.
Files changed (249) hide show
  1. package/CHANGELOG.md +323 -8
  2. package/README.md +114 -33
  3. package/package.json +11 -1
  4. package/src/activation-provenance.ts +111 -0
  5. package/src/activation-source-compatibility.ts +430 -0
  6. package/src/activation-source-projection.ts +221 -0
  7. package/src/activation-source.ts +91 -0
  8. package/src/blob-ref.ts +51 -0
  9. package/src/branded.ts +1 -1
  10. package/src/compose-batch.ts +69 -0
  11. package/src/compose-schema.ts +36 -0
  12. package/src/context.ts +44 -10
  13. package/src/contour.ts +346 -0
  14. package/src/derive.ts +250 -19
  15. package/src/detours.ts +8 -0
  16. package/src/diagnostics.ts +21 -0
  17. package/src/draft.ts +350 -0
  18. package/src/error-projection.ts +51 -0
  19. package/src/errors.ts +335 -48
  20. package/src/execute.ts +1577 -0
  21. package/src/fire.ts +1169 -0
  22. package/src/glob.ts +81 -0
  23. package/src/index.ts +526 -35
  24. package/src/internal/fork-ctx.ts +69 -0
  25. package/src/layer-projection.ts +193 -0
  26. package/src/layer.ts +43 -6
  27. package/src/observe.ts +361 -0
  28. package/src/path-scope.ts +66 -0
  29. package/src/path-security.ts +1 -1
  30. package/src/permits.ts +12 -0
  31. package/src/redaction/patterns.ts +6 -3
  32. package/src/resilience.ts +11 -11
  33. package/src/resource-config.ts +792 -0
  34. package/src/resource.ts +194 -0
  35. package/src/result.ts +18 -0
  36. package/src/run.ts +76 -0
  37. package/src/schedule-runtime.ts +689 -0
  38. package/src/schedule.ts +326 -0
  39. package/src/serialization.ts +92 -55
  40. package/src/signal-diagnostics.ts +633 -0
  41. package/src/signal-ref.ts +87 -0
  42. package/src/signal.ts +104 -0
  43. package/src/store/accessor-protocol.ts +56 -0
  44. package/src/store/index.ts +4 -0
  45. package/src/structured-examples.ts +248 -0
  46. package/src/surface-derivation.ts +91 -0
  47. package/src/surface-filter.ts +101 -0
  48. package/src/surface-versioning.ts +42 -0
  49. package/src/topo.ts +769 -67
  50. package/src/tracing.ts +345 -0
  51. package/src/trail-id-glob.ts +15 -0
  52. package/src/trail.ts +1168 -30
  53. package/src/trails/derive-trail.ts +842 -0
  54. package/src/trails/index.ts +9 -0
  55. package/src/trails/ingest.ts +139 -0
  56. package/src/trails-db.ts +206 -0
  57. package/src/transport-error-map.ts +174 -0
  58. package/src/type-utils.ts +87 -0
  59. package/src/types.ts +254 -12
  60. package/src/validate-established-topo.ts +69 -0
  61. package/src/validate-topo.ts +414 -56
  62. package/src/validation.ts +152 -4
  63. package/src/version-marker.ts +716 -0
  64. package/src/version-resolution.ts +308 -0
  65. package/src/version-runtime.ts +120 -0
  66. package/src/webhook.ts +278 -0
  67. package/src/workspace.ts +162 -1
  68. package/src/zod-wrappers.ts +72 -0
  69. package/.turbo/turbo-build.log +0 -1
  70. package/.turbo/turbo-lint.log +0 -3
  71. package/.turbo/turbo-typecheck.log +0 -1
  72. package/dist/adapters.d.ts +0 -39
  73. package/dist/adapters.d.ts.map +0 -1
  74. package/dist/adapters.js +0 -2
  75. package/dist/adapters.js.map +0 -1
  76. package/dist/blob-ref.d.ts +0 -20
  77. package/dist/blob-ref.d.ts.map +0 -1
  78. package/dist/blob-ref.js +0 -22
  79. package/dist/blob-ref.js.map +0 -1
  80. package/dist/branded.d.ts +0 -36
  81. package/dist/branded.d.ts.map +0 -1
  82. package/dist/branded.js +0 -89
  83. package/dist/branded.js.map +0 -1
  84. package/dist/collections.d.ts +0 -31
  85. package/dist/collections.d.ts.map +0 -1
  86. package/dist/collections.js +0 -60
  87. package/dist/collections.js.map +0 -1
  88. package/dist/context.d.ts +0 -10
  89. package/dist/context.d.ts.map +0 -1
  90. package/dist/context.js +0 -15
  91. package/dist/context.js.map +0 -1
  92. package/dist/derive.d.ts +0 -33
  93. package/dist/derive.d.ts.map +0 -1
  94. package/dist/derive.js +0 -125
  95. package/dist/derive.js.map +0 -1
  96. package/dist/errors.d.ts +0 -83
  97. package/dist/errors.d.ts.map +0 -1
  98. package/dist/errors.js +0 -142
  99. package/dist/errors.js.map +0 -1
  100. package/dist/event.d.ts +0 -45
  101. package/dist/event.d.ts.map +0 -1
  102. package/dist/event.js +0 -17
  103. package/dist/event.js.map +0 -1
  104. package/dist/fetch.d.ts +0 -15
  105. package/dist/fetch.d.ts.map +0 -1
  106. package/dist/fetch.js +0 -102
  107. package/dist/fetch.js.map +0 -1
  108. package/dist/guards.d.ts +0 -17
  109. package/dist/guards.d.ts.map +0 -1
  110. package/dist/guards.js +0 -25
  111. package/dist/guards.js.map +0 -1
  112. package/dist/health.d.ts +0 -18
  113. package/dist/health.d.ts.map +0 -1
  114. package/dist/health.js +0 -5
  115. package/dist/health.js.map +0 -1
  116. package/dist/hike.d.ts +0 -36
  117. package/dist/hike.d.ts.map +0 -1
  118. package/dist/hike.js +0 -20
  119. package/dist/hike.js.map +0 -1
  120. package/dist/index.d.ts +0 -36
  121. package/dist/index.d.ts.map +0 -1
  122. package/dist/index.js +0 -40
  123. package/dist/index.js.map +0 -1
  124. package/dist/job.d.ts +0 -24
  125. package/dist/job.d.ts.map +0 -1
  126. package/dist/job.js +0 -17
  127. package/dist/job.js.map +0 -1
  128. package/dist/layer.d.ts +0 -17
  129. package/dist/layer.d.ts.map +0 -1
  130. package/dist/layer.js +0 -21
  131. package/dist/layer.js.map +0 -1
  132. package/dist/path-security.d.ts +0 -28
  133. package/dist/path-security.d.ts.map +0 -1
  134. package/dist/path-security.js +0 -63
  135. package/dist/path-security.js.map +0 -1
  136. package/dist/patterns/bulk.d.ts +0 -15
  137. package/dist/patterns/bulk.d.ts.map +0 -1
  138. package/dist/patterns/bulk.js +0 -14
  139. package/dist/patterns/bulk.js.map +0 -1
  140. package/dist/patterns/change.d.ts +0 -10
  141. package/dist/patterns/change.d.ts.map +0 -1
  142. package/dist/patterns/change.js +0 -10
  143. package/dist/patterns/change.js.map +0 -1
  144. package/dist/patterns/date-range.d.ts +0 -10
  145. package/dist/patterns/date-range.d.ts.map +0 -1
  146. package/dist/patterns/date-range.js +0 -10
  147. package/dist/patterns/date-range.js.map +0 -1
  148. package/dist/patterns/index.d.ts +0 -9
  149. package/dist/patterns/index.d.ts.map +0 -1
  150. package/dist/patterns/index.js +0 -9
  151. package/dist/patterns/index.js.map +0 -1
  152. package/dist/patterns/pagination.d.ts +0 -18
  153. package/dist/patterns/pagination.d.ts.map +0 -1
  154. package/dist/patterns/pagination.js +0 -18
  155. package/dist/patterns/pagination.js.map +0 -1
  156. package/dist/patterns/progress.d.ts +0 -11
  157. package/dist/patterns/progress.d.ts.map +0 -1
  158. package/dist/patterns/progress.js +0 -11
  159. package/dist/patterns/progress.js.map +0 -1
  160. package/dist/patterns/sorting.d.ts +0 -13
  161. package/dist/patterns/sorting.d.ts.map +0 -1
  162. package/dist/patterns/sorting.js +0 -10
  163. package/dist/patterns/sorting.js.map +0 -1
  164. package/dist/patterns/status.d.ts +0 -15
  165. package/dist/patterns/status.d.ts.map +0 -1
  166. package/dist/patterns/status.js +0 -9
  167. package/dist/patterns/status.js.map +0 -1
  168. package/dist/patterns/timestamps.d.ts +0 -10
  169. package/dist/patterns/timestamps.d.ts.map +0 -1
  170. package/dist/patterns/timestamps.js +0 -10
  171. package/dist/patterns/timestamps.js.map +0 -1
  172. package/dist/redaction/index.d.ts +0 -4
  173. package/dist/redaction/index.d.ts.map +0 -1
  174. package/dist/redaction/index.js +0 -3
  175. package/dist/redaction/index.js.map +0 -1
  176. package/dist/redaction/patterns.d.ts +0 -9
  177. package/dist/redaction/patterns.d.ts.map +0 -1
  178. package/dist/redaction/patterns.js +0 -39
  179. package/dist/redaction/patterns.js.map +0 -1
  180. package/dist/redaction/redactor.d.ts +0 -27
  181. package/dist/redaction/redactor.d.ts.map +0 -1
  182. package/dist/redaction/redactor.js +0 -89
  183. package/dist/redaction/redactor.js.map +0 -1
  184. package/dist/resilience.d.ts +0 -34
  185. package/dist/resilience.d.ts.map +0 -1
  186. package/dist/resilience.js +0 -164
  187. package/dist/resilience.js.map +0 -1
  188. package/dist/result.d.ts +0 -57
  189. package/dist/result.d.ts.map +0 -1
  190. package/dist/result.js +0 -156
  191. package/dist/result.js.map +0 -1
  192. package/dist/serialization.d.ts +0 -27
  193. package/dist/serialization.d.ts.map +0 -1
  194. package/dist/serialization.js +0 -153
  195. package/dist/serialization.js.map +0 -1
  196. package/dist/topo.d.ts +0 -18
  197. package/dist/topo.d.ts.map +0 -1
  198. package/dist/topo.js +0 -80
  199. package/dist/topo.js.map +0 -1
  200. package/dist/trail.d.ts +0 -83
  201. package/dist/trail.d.ts.map +0 -1
  202. package/dist/trail.js +0 -16
  203. package/dist/trail.js.map +0 -1
  204. package/dist/types.d.ts +0 -46
  205. package/dist/types.d.ts.map +0 -1
  206. package/dist/types.js +0 -2
  207. package/dist/types.js.map +0 -1
  208. package/dist/validate-topo.d.ts +0 -24
  209. package/dist/validate-topo.d.ts.map +0 -1
  210. package/dist/validate-topo.js +0 -156
  211. package/dist/validate-topo.js.map +0 -1
  212. package/dist/validation.d.ts +0 -27
  213. package/dist/validation.d.ts.map +0 -1
  214. package/dist/validation.js +0 -134
  215. package/dist/validation.js.map +0 -1
  216. package/dist/workspace.d.ts +0 -25
  217. package/dist/workspace.d.ts.map +0 -1
  218. package/dist/workspace.js +0 -57
  219. package/dist/workspace.js.map +0 -1
  220. package/src/__tests__/blob-ref.test.ts +0 -103
  221. package/src/__tests__/branded.test.ts +0 -148
  222. package/src/__tests__/collections.test.ts +0 -126
  223. package/src/__tests__/context.test.ts +0 -66
  224. package/src/__tests__/derive.test.ts +0 -203
  225. package/src/__tests__/errors.test.ts +0 -309
  226. package/src/__tests__/event.test.ts +0 -82
  227. package/src/__tests__/fetch.test.ts +0 -217
  228. package/src/__tests__/guards.test.ts +0 -102
  229. package/src/__tests__/hike.test.ts +0 -117
  230. package/src/__tests__/job.test.ts +0 -98
  231. package/src/__tests__/layer.test.ts +0 -224
  232. package/src/__tests__/path-security.test.ts +0 -114
  233. package/src/__tests__/patterns.test.ts +0 -273
  234. package/src/__tests__/redaction.test.ts +0 -244
  235. package/src/__tests__/resilience.test.ts +0 -246
  236. package/src/__tests__/result.test.ts +0 -155
  237. package/src/__tests__/serialization.test.ts +0 -401
  238. package/src/__tests__/topo.test.ts +0 -220
  239. package/src/__tests__/trail.test.ts +0 -179
  240. package/src/__tests__/validate-topo.test.ts +0 -280
  241. package/src/__tests__/validation.test.ts +0 -283
  242. package/src/__tests__/workspace.test.ts +0 -183
  243. package/src/adapters.ts +0 -68
  244. package/src/event.ts +0 -77
  245. package/src/health.ts +0 -23
  246. package/src/hike.ts +0 -77
  247. package/src/job.ts +0 -20
  248. package/tsconfig.json +0 -9
  249. package/tsconfig.tsbuildinfo +0 -1
package/dist/guards.js DELETED
@@ -1,25 +0,0 @@
1
- /**
2
- * Type guards and assertion helpers for @ontrails/core.
3
- */
4
- /** Narrows `T | null | undefined` to `T`. */
5
- export const isDefined = (value) => value !== null && value !== undefined;
6
- /** Returns true when `value` is a string with length > 0. */
7
- export const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
8
- /** Returns true when `value` is a plain object (not an array, Date, etc.). */
9
- export const isPlainObject = (value) => {
10
- if (typeof value !== 'object' || value === null) {
11
- return false;
12
- }
13
- const proto = Object.getPrototypeOf(value);
14
- return proto === Object.prototype || proto === null;
15
- };
16
- /** Checks that `obj` is an object with the given key present. */
17
- export const hasProperty = (obj, key) => typeof obj === 'object' && obj !== null && key in obj;
18
- /**
19
- * Exhaustive switch helper. Place in the `default` branch to get a compile
20
- * error when a union case is unhandled.
21
- */
22
- export const assertNever = (value) => {
23
- throw new Error(`Unexpected value: ${String(value)}`);
24
- };
25
- //# sourceMappingURL=guards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,KAA4B,EAAc,EAAE,CACvE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAExC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAmB,EAAE,CACnE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAEhD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAc,EACoB,EAAE;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAY,CAAC;IACtD,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC,CAAC;AAEF,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAY,EACZ,GAAM,EACqB,EAAE,CAC7B,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAY,EAAS,EAAE;IACjD,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC,CAAC"}
package/dist/health.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /** Aggregate health status */
2
- export type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
3
- /** Individual component check result */
4
- export interface HealthCheck {
5
- readonly status: HealthStatus;
6
- readonly message?: string | undefined;
7
- /** Latency in milliseconds */
8
- readonly latency?: number | undefined;
9
- }
10
- /** Full health report returned by a health endpoint */
11
- export interface HealthResult {
12
- readonly status: HealthStatus;
13
- readonly checks: Readonly<Record<string, HealthCheck>>;
14
- readonly version?: string | undefined;
15
- /** Uptime in seconds */
16
- readonly uptime?: number | undefined;
17
- }
18
- //# sourceMappingURL=health.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../src/health.ts"],"names":[],"mappings":"AAIA,8BAA8B;AAC9B,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;AAEhE,wCAAwC;AACxC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,wBAAwB;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC"}
package/dist/health.js DELETED
@@ -1,5 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Health check types
3
- // ---------------------------------------------------------------------------
4
- export {};
5
- //# sourceMappingURL=health.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"health.js","sourceRoot":"","sources":["../src/health.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E"}
package/dist/hike.d.ts DELETED
@@ -1,36 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,20 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
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 DELETED
@@ -1,36 +0,0 @@
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 { createBlobRef, isBlobRef } from './blob-ref.js';
32
- export type { BlobRef } from './blob-ref.js';
33
- export { isDefined, isNonEmptyString, isPlainObject, hasProperty, assertNever, } from './guards.js';
34
- export { chunk, dedupe, groupBy, sortBy, isNonEmptyArray, } from './collections.js';
35
- export type { NonEmptyArray, DeepPartial, Prettify, AtLeastOne, } from './collections.js';
36
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,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,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,YAAY,EACV,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,aAAa,E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AM,oBAAoB,CAAC;AAG1D,OAAO,EACL,KAAK,EACL,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAKpD,OAAO,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,cAAc,EACd,WAAW,EACX,OAAO,EACP,MAAM,GACP,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,OAAO,EACP,IAAI,EACJ,KAAK,EACL,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,aAAa,EACb,WAAW,EACX,QAAQ,EACR,UAAU,GACX,MAAM,kBAAkB,CAAC"}
package/dist/index.js DELETED
@@ -1,40 +0,0 @@
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
- // Blob
35
- export { createBlobRef, isBlobRef } from './blob-ref.js';
36
- // Guards
37
- export { isDefined, isNonEmptyString, isPlainObject, hasProperty, assertNever, } from './guards.js';
38
- // Collections
39
- export { chunk, dedupe, groupBy, sortBy, isNonEmptyArray, } from './collections.js';
40
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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,cAA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ACd,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
package/dist/job.d.ts DELETED
@@ -1,24 +0,0 @@
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
package/dist/job.d.ts.map DELETED
@@ -1 +0,0 @@
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 DELETED
@@ -1,17 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
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 DELETED
@@ -1,17 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,21 +0,0 @@
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
package/dist/layer.js.map DELETED
@@ -1 +0,0 @@
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"}
@@ -1,28 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,63 +0,0 @@
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
@@ -1 +0,0 @@
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,kD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AC/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"}
@@ -1,15 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,11 +0,0 @@
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