@ontrails/core 0.2.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/CHANGELOG.md +849 -0
- package/README.md +190 -0
- package/package.json +36 -0
- package/src/activation-provenance.ts +116 -0
- package/src/activation-source-compatibility.ts +430 -0
- package/src/activation-source-derivation.ts +227 -0
- package/src/activation-source.ts +93 -0
- package/src/blob-ref.ts +90 -0
- package/src/branded.ts +135 -0
- package/src/collections.ts +99 -0
- package/src/compose-batch.ts +69 -0
- package/src/compose-schema.ts +36 -0
- package/src/context.ts +66 -0
- package/src/derive.ts +485 -0
- package/src/detours.ts +8 -0
- package/src/diagnostics.ts +21 -0
- package/src/draft.ts +350 -0
- package/src/entity.ts +346 -0
- package/src/error-rendering.ts +87 -0
- package/src/errors.ts +483 -0
- package/src/execute.ts +1577 -0
- package/src/fetch.ts +138 -0
- package/src/fire.ts +1172 -0
- package/src/glob.ts +81 -0
- package/src/guards.ts +37 -0
- package/src/index.ts +704 -0
- package/src/internal/fork-ctx.ts +69 -0
- package/src/layer-field-rendering.ts +193 -0
- package/src/layer.ts +81 -0
- package/src/observe.ts +361 -0
- package/src/path-scope.ts +66 -0
- package/src/path-security.ts +98 -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/permits.ts +12 -0
- package/src/queue.ts +163 -0
- package/src/redaction/index.ts +3 -0
- package/src/redaction/patterns.ts +50 -0
- package/src/redaction/redactor.ts +178 -0
- package/src/resilience.ts +234 -0
- package/src/resource-config.ts +804 -0
- package/src/resource.ts +194 -0
- package/src/result.ts +212 -0
- package/src/run.ts +76 -0
- package/src/runtime-builtins.ts +69 -0
- package/src/schedule-runtime.ts +689 -0
- package/src/schedule.ts +326 -0
- package/src/serialization.ts +265 -0
- package/src/sha256.ts +136 -0
- package/src/signal-diagnostics.ts +633 -0
- package/src/signal-ref.ts +111 -0
- package/src/signal.ts +104 -0
- package/src/store/accessor-protocol.ts +56 -0
- package/src/store/index.ts +4 -0
- package/src/structured-examples.ts +248 -0
- package/src/surface-derivation.ts +91 -0
- package/src/surface-filter.ts +101 -0
- package/src/surface-overlay.ts +694 -0
- package/src/surface-versioning.ts +42 -0
- package/src/topo.ts +835 -0
- package/src/tracing.ts +346 -0
- package/src/trail-id-glob.ts +15 -0
- package/src/trail.ts +1351 -0
- package/src/trails/derive-trail.ts +835 -0
- package/src/trails/index.ts +9 -0
- package/src/trails/ingest.ts +152 -0
- package/src/trails-db.ts +212 -0
- package/src/transport-error-map.ts +163 -0
- package/src/type-utils.ts +87 -0
- package/src/types.ts +300 -0
- package/src/validate-established-topo.ts +73 -0
- package/src/validate-topo.ts +725 -0
- package/src/validation.ts +330 -0
- package/src/version-marker.ts +716 -0
- package/src/version-resolution.ts +308 -0
- package/src/version-runtime.ts +120 -0
- package/src/webhook.ts +461 -0
- package/src/workspace.ts +244 -0
- package/src/zod-wrappers.ts +72 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Intent, Trail } from './trail.js';
|
|
2
|
+
import { matchesAnyTrailIdGlob, matchesTrailIdGlob } from './trail-id-glob.js';
|
|
3
|
+
import type { SurfaceSelectionOptions } from './surface-derivation.js';
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Public types
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
export type SurfaceFilterOptions = SurfaceSelectionOptions;
|
|
10
|
+
|
|
11
|
+
export const matchesTrailPattern = (
|
|
12
|
+
trailId: string,
|
|
13
|
+
pattern: string
|
|
14
|
+
): boolean => matchesTrailIdGlob(trailId, pattern);
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Surface filtering
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
const matchesAnyPattern = (
|
|
21
|
+
trailId: string,
|
|
22
|
+
patterns: readonly string[] | undefined
|
|
23
|
+
): boolean => matchesAnyTrailIdGlob(trailId, patterns);
|
|
24
|
+
|
|
25
|
+
const isExplicitInternalInclude = (
|
|
26
|
+
trailId: string,
|
|
27
|
+
include: readonly string[] | undefined
|
|
28
|
+
): boolean => include !== undefined && include.includes(trailId);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the effective visibility for a trail.
|
|
32
|
+
*
|
|
33
|
+
* Returns `'internal'` when either the explicit `visibility` field is
|
|
34
|
+
* `'internal'` or the legacy `meta.internal === true` convention is set.
|
|
35
|
+
* Honoring the legacy flag keeps trails authored before the visibility
|
|
36
|
+
* field was introduced (e.g. `meta: { internal: true }`) off surfaces.
|
|
37
|
+
*
|
|
38
|
+
* The runtime always fills in `visibility: 'public'` when the spec did not
|
|
39
|
+
* declare it, so we cannot distinguish explicit `'public'` from the default.
|
|
40
|
+
* This means a trail that sets both `meta.internal = true` and
|
|
41
|
+
* `visibility: 'public'` will still be treated as internal — that
|
|
42
|
+
* combination has never been a documented override and, if the author
|
|
43
|
+
* really means "public", they should remove the legacy flag.
|
|
44
|
+
*/
|
|
45
|
+
const effectiveVisibility = (
|
|
46
|
+
trail: Trail<unknown, unknown, unknown>
|
|
47
|
+
): 'public' | 'internal' => {
|
|
48
|
+
if (trail.visibility === 'internal') {
|
|
49
|
+
return 'internal';
|
|
50
|
+
}
|
|
51
|
+
return trail.meta?.['internal'] === true ? 'internal' : 'public';
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const isVisibleToSurfaces = (
|
|
55
|
+
trail: Trail<unknown, unknown, unknown>,
|
|
56
|
+
include: readonly string[] | undefined
|
|
57
|
+
): boolean =>
|
|
58
|
+
effectiveVisibility(trail) !== 'internal' ||
|
|
59
|
+
isExplicitInternalInclude(trail.id, include);
|
|
60
|
+
|
|
61
|
+
const passesIncludeFilter = (
|
|
62
|
+
trailId: string,
|
|
63
|
+
include: readonly string[] | undefined
|
|
64
|
+
): boolean =>
|
|
65
|
+
include === undefined ||
|
|
66
|
+
include.length === 0 ||
|
|
67
|
+
matchesAnyPattern(trailId, include);
|
|
68
|
+
|
|
69
|
+
const passesIntentFilter = (
|
|
70
|
+
trail: Trail<unknown, unknown, unknown>,
|
|
71
|
+
intent: readonly Intent[] | undefined
|
|
72
|
+
): boolean =>
|
|
73
|
+
intent === undefined || intent.length === 0 || intent.includes(trail.intent);
|
|
74
|
+
|
|
75
|
+
export const shouldIncludeTrailForSurface = (
|
|
76
|
+
trail: Trail<unknown, unknown, unknown>,
|
|
77
|
+
options: SurfaceFilterOptions = {}
|
|
78
|
+
): boolean => {
|
|
79
|
+
if (trail.activationSources.length > 0) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { exclude, include, intent } = options;
|
|
84
|
+
if (!isVisibleToSurfaces(trail, include)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (matchesAnyPattern(trail.id, exclude)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
passesIncludeFilter(trail.id, include) && passesIntentFilter(trail, intent)
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const filterSurfaceTrails = (
|
|
98
|
+
trails: readonly Trail<unknown, unknown, unknown>[],
|
|
99
|
+
options: SurfaceFilterOptions = {}
|
|
100
|
+
): Trail<unknown, unknown, unknown>[] =>
|
|
101
|
+
trails.filter((trail) => shouldIncludeTrailForSurface(trail, options));
|