@indigoai-us/hq-cli 5.345.247 → 5.345.248
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 +54 -0
- package/assets/lanes-hooks/hq-lanes-drain.sh +1 -1
- package/contracts/host-canary-release.json +14 -0
- package/dist/command-catalog.generated.d.ts +1113 -0
- package/dist/command-catalog.generated.js +1370 -0
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/lanes-hold.js +7 -7
- package/dist/commands/lanes-resume.js +2 -2
- package/dist/commands/lanes-review.js +1 -1
- package/dist/commands/lanes-session-start.d.ts +1 -1
- package/dist/commands/lanes-session-start.js +3 -3
- package/dist/commands/lanes-shared.d.ts +1 -1
- package/dist/commands/lanes.d.ts +2 -2
- package/dist/commands/lanes.js +50 -50
- package/dist/commands/mesh.d.ts +25 -0
- package/dist/commands/mesh.js +48 -8
- package/dist/commands/ontology-graph.d.ts +62 -0
- package/dist/commands/ontology-graph.js +439 -0
- package/dist/index.js +1 -1
- package/dist/lanes-monitor-check-argv.d.ts +1 -1
- package/dist/lanes-monitor-check-argv.js +1 -1
- package/dist/lanes-monitor-check-fast.d.ts +1 -1
- package/dist/lanes-monitor-check-fast.js +1 -1
- package/dist/lanes-session-start-argv.d.ts +1 -1
- package/dist/lanes-session-start-argv.js +1 -1
- package/dist/lib/capacity/sign-in.d.ts +1 -1
- package/dist/lib/capacity/sign-in.js +1 -1
- package/dist/lib/daemon/hook-requests-conduct-link.js +2 -2
- package/dist/lib/daemon/lanes-monitor-state.d.ts +2 -2
- package/dist/lib/daemon/lanes-monitor-state.js +2 -2
- package/dist/lib/daemon/merge-sections.d.ts +3 -3
- package/dist/lib/daemon/merge-sections.js +7 -7
- package/dist/lib/daemon/remote-control-pools.js +1 -1
- package/dist/lib/daemon/run.js +1 -1
- package/dist/lib/daemon/state-file.d.ts +1 -1
- package/dist/lib/daemon/state-file.js +1 -1
- package/dist/lib/flag-snapshot-file.d.ts +2 -0
- package/dist/lib/flag-snapshot-file.js +118 -48
- package/dist/lib/hook-engine/canary-gate.d.ts +57 -3
- package/dist/lib/hook-engine/canary-gate.js +138 -6
- package/dist/lib/hot-channels/graph-context.d.ts +105 -0
- package/dist/lib/hot-channels/graph-context.js +377 -0
- package/dist/lib/hot-channels/signals-pass.js +27 -1
- package/dist/lib/lanes/claude-credential.d.ts +1 -1
- package/dist/lib/lanes/claude-credential.js +1 -1
- package/dist/lib/lanes/delivery-core.d.ts +1 -1
- package/dist/lib/lanes/delivery-core.js +1 -1
- package/dist/lib/lanes/delivery.d.ts +10 -10
- package/dist/lib/lanes/delivery.js +8 -8
- package/dist/lib/lanes/dropbox.d.ts +1 -1
- package/dist/lib/lanes/dropbox.js +1 -1
- package/dist/lib/lanes/hooks-install.js +2 -2
- package/dist/lib/lanes/index.d.ts +1 -1
- package/dist/lib/lanes/index.js +1 -1
- package/dist/lib/lanes/monitor.js +1 -1
- package/dist/lib/lanes/quota-notice.js +1 -1
- package/dist/lib/lanes/quota.d.ts +1 -1
- package/dist/lib/lanes/quota.js +1 -1
- package/dist/lib/lanes/repo-merge-hold.d.ts +2 -2
- package/dist/lib/lanes/repo-merge-hold.js +2 -2
- package/dist/lib/lanes/spawn.d.ts +4 -4
- package/dist/lib/lanes/spawn.js +5 -5
- package/dist/lib/mesh/live/company-flag-refresh.d.ts +61 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +159 -0
- package/dist/lib/mesh/live/company-reporting-gaps.d.ts +61 -0
- package/dist/lib/mesh/live/company-reporting-gaps.js +238 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.d.ts +156 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.js +616 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +13 -0
- package/dist/lib/mesh/live/daemon/run.js +35 -2
- package/dist/lib/mesh/live/direct-drain.js +1 -1
- package/dist/lib/mesh/live/emit.d.ts +3 -0
- package/dist/lib/mesh/live/emit.js +32 -9
- package/dist/lib/mesh/live/flush.d.ts +3 -0
- package/dist/lib/mesh/live/flush.js +115 -32
- package/dist/lib/mesh/live/liveness-carry.d.ts +1 -1
- package/dist/lib/mesh/live/liveness-carry.js +1 -1
- package/dist/lib/mesh/live/reporting-privacy.d.ts +119 -3
- package/dist/lib/mesh/live/reporting-privacy.js +235 -11
- package/dist/lib/mesh/live/spool.d.ts +17 -2
- package/dist/lib/mesh/live/spool.js +22 -6
- package/dist/lib/ontology-graph/legacy/coverage.d.ts +67 -0
- package/dist/lib/ontology-graph/legacy/coverage.js +192 -0
- package/dist/lib/ontology-graph/legacy/index.d.ts +199 -0
- package/dist/lib/ontology-graph/legacy/index.js +1150 -0
- package/dist/lib/ontology-graph/legacy/parse.d.ts +49 -0
- package/dist/lib/ontology-graph/legacy/parse.js +126 -0
- package/dist/lib/ontology-graph/legacy/report.d.ts +14 -0
- package/dist/lib/ontology-graph/legacy/report.js +254 -0
- package/dist/lib/ontology-graph/legacy/verb-map.d.ts +35 -0
- package/dist/lib/ontology-graph/legacy/verb-map.js +84 -0
- package/dist/lib/ontology-graph/lint/checks.d.ts +140 -0
- package/dist/lib/ontology-graph/lint/checks.js +717 -0
- package/dist/lib/ontology-graph/lint/coverage.d.ts +106 -0
- package/dist/lib/ontology-graph/lint/coverage.js +241 -0
- package/dist/lib/ontology-graph/lint/daily-job.d.ts +259 -0
- package/dist/lib/ontology-graph/lint/daily-job.js +595 -0
- package/dist/lib/ontology-graph/lint/index.d.ts +65 -0
- package/dist/lib/ontology-graph/lint/index.js +176 -0
- package/dist/lib/ontology-graph/model/files.d.ts +20 -0
- package/dist/lib/ontology-graph/model/files.js +89 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -0
- package/dist/lib/ontology-graph/model/index.js +100 -0
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +156 -0
- package/dist/lib/ontology-graph/model/pass-tasks.js +345 -0
- package/dist/lib/ontology-graph/model/pass.d.ts +109 -0
- package/dist/lib/ontology-graph/model/pass.js +958 -0
- package/dist/lib/ontology-graph/model/runner.d.ts +50 -0
- package/dist/lib/ontology-graph/model/runner.js +160 -0
- package/dist/lib/ontology-graph/model/step.d.ts +195 -0
- package/dist/lib/ontology-graph/model/step.js +523 -0
- package/dist/lib/ontology-graph/model/tasks.d.ts +183 -0
- package/dist/lib/ontology-graph/model/tasks.js +349 -0
- package/dist/lib/ontology-graph/not-implemented.d.ts +5 -0
- package/dist/lib/ontology-graph/not-implemented.js +8 -0
- package/dist/lib/ontology-graph/org/compare.d.ts +28 -0
- package/dist/lib/ontology-graph/org/compare.js +239 -0
- package/dist/lib/ontology-graph/org/derive.d.ts +65 -0
- package/dist/lib/ontology-graph/org/derive.js +352 -0
- package/dist/lib/ontology-graph/org/index.d.ts +73 -0
- package/dist/lib/ontology-graph/org/index.js +513 -0
- package/dist/lib/ontology-graph/org/load.d.ts +31 -0
- package/dist/lib/ontology-graph/org/load.js +476 -0
- package/dist/lib/ontology-graph/org/role.d.ts +38 -0
- package/dist/lib/ontology-graph/org/role.js +268 -0
- package/dist/lib/ontology-graph/org/structure.d.ts +63 -0
- package/dist/lib/ontology-graph/org/structure.js +437 -0
- package/dist/lib/ontology-graph/org/text.d.ts +95 -0
- package/dist/lib/ontology-graph/org/text.js +315 -0
- package/dist/lib/ontology-graph/org/types.d.ts +452 -0
- package/dist/lib/ontology-graph/org/types.js +80 -0
- package/dist/lib/ontology-graph/pages/index.d.ts +64 -0
- package/dist/lib/ontology-graph/pages/index.js +193 -0
- package/dist/lib/ontology-graph/pages/render.d.ts +142 -0
- package/dist/lib/ontology-graph/pages/render.js +682 -0
- package/dist/lib/ontology-graph/proposals/apply.d.ts +109 -0
- package/dist/lib/ontology-graph/proposals/apply.js +468 -0
- package/dist/lib/ontology-graph/proposals/group.d.ts +63 -0
- package/dist/lib/ontology-graph/proposals/group.js +232 -0
- package/dist/lib/ontology-graph/proposals/index.d.ts +173 -0
- package/dist/lib/ontology-graph/proposals/index.js +474 -0
- package/dist/lib/ontology-graph/proposals/model.d.ts +162 -0
- package/dist/lib/ontology-graph/proposals/model.js +196 -0
- package/dist/lib/ontology-graph/proposals/org-chart.d.ts +82 -0
- package/dist/lib/ontology-graph/proposals/org-chart.js +340 -0
- package/dist/lib/ontology-graph/read/brief.d.ts +26 -0
- package/dist/lib/ontology-graph/read/brief.js +251 -0
- package/dist/lib/ontology-graph/read/graph-index.d.ts +76 -0
- package/dist/lib/ontology-graph/read/graph-index.js +198 -0
- package/dist/lib/ontology-graph/read/index.d.ts +59 -0
- package/dist/lib/ontology-graph/read/index.js +792 -0
- package/dist/lib/ontology-graph/read/member.d.ts +7 -0
- package/dist/lib/ontology-graph/read/member.js +34 -0
- package/dist/lib/ontology-graph/read/names.d.ts +44 -0
- package/dist/lib/ontology-graph/read/names.js +292 -0
- package/dist/lib/ontology-graph/read/reader-setting.d.ts +19 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +62 -0
- package/dist/lib/ontology-graph/read/test-graph.d.ts +37 -0
- package/dist/lib/ontology-graph/read/test-graph.js +150 -0
- package/dist/lib/ontology-graph/replay/buffered-store.d.ts +33 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +50 -0
- package/dist/lib/ontology-graph/replay/config.d.ts +41 -0
- package/dist/lib/ontology-graph/replay/config.js +105 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +100 -0
- package/dist/lib/ontology-graph/replay/engine.js +1174 -0
- package/dist/lib/ontology-graph/replay/extractors.d.ts +59 -0
- package/dist/lib/ontology-graph/replay/extractors.js +1555 -0
- package/dist/lib/ontology-graph/replay/index.d.ts +90 -0
- package/dist/lib/ontology-graph/replay/index.js +220 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.d.ts +66 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.js +242 -0
- package/dist/lib/ontology-graph/replay/member.d.ts +19 -0
- package/dist/lib/ontology-graph/replay/member.js +65 -0
- package/dist/lib/ontology-graph/replay/mentions.d.ts +58 -0
- package/dist/lib/ontology-graph/replay/mentions.js +239 -0
- package/dist/lib/ontology-graph/replay/readers.d.ts +98 -0
- package/dist/lib/ontology-graph/replay/readers.js +1251 -0
- package/dist/lib/ontology-graph/replay/rules.d.ts +127 -0
- package/dist/lib/ontology-graph/replay/rules.js +374 -0
- package/dist/lib/ontology-graph/replay/scope.d.ts +35 -0
- package/dist/lib/ontology-graph/replay/scope.js +115 -0
- package/dist/lib/ontology-graph/replay/transcripts.d.ts +39 -0
- package/dist/lib/ontology-graph/replay/transcripts.js +224 -0
- package/dist/lib/ontology-graph/replay/util.d.ts +55 -0
- package/dist/lib/ontology-graph/replay/util.js +256 -0
- package/dist/lib/ontology-graph/resolve/entity-index.d.ts +159 -0
- package/dist/lib/ontology-graph/resolve/entity-index.js +652 -0
- package/dist/lib/ontology-graph/resolve/index.d.ts +113 -0
- package/dist/lib/ontology-graph/resolve/index.js +214 -0
- package/dist/lib/ontology-graph/resolve/machine.d.ts +34 -0
- package/dist/lib/ontology-graph/resolve/machine.js +95 -0
- package/dist/lib/ontology-graph/resolve/normalize.d.ts +35 -0
- package/dist/lib/ontology-graph/resolve/normalize.js +124 -0
- package/dist/lib/ontology-graph/resolve/org-chart.d.ts +107 -0
- package/dist/lib/ontology-graph/resolve/org-chart.js +578 -0
- package/dist/lib/ontology-graph/resolve/org-layer.d.ts +78 -0
- package/dist/lib/ontology-graph/resolve/org-layer.js +159 -0
- package/dist/lib/ontology-graph/resolve/org-seed.d.ts +141 -0
- package/dist/lib/ontology-graph/resolve/org-seed.js +631 -0
- package/dist/lib/ontology-graph/resolve/org-sources.d.ts +165 -0
- package/dist/lib/ontology-graph/resolve/org-sources.js +634 -0
- package/dist/lib/ontology-graph/resolve/roster.d.ts +76 -0
- package/dist/lib/ontology-graph/resolve/roster.js +226 -0
- package/dist/lib/ontology-graph/resolve/seed.d.ts +267 -0
- package/dist/lib/ontology-graph/resolve/seed.js +1198 -0
- package/dist/lib/ontology-graph/resolve/upsert.d.ts +58 -0
- package/dist/lib/ontology-graph/resolve/upsert.js +139 -0
- package/dist/lib/ontology-graph/resolve/writer.d.ts +128 -0
- package/dist/lib/ontology-graph/resolve/writer.js +351 -0
- package/dist/lib/ontology-graph/schema/authority.d.ts +73 -0
- package/dist/lib/ontology-graph/schema/authority.js +157 -0
- package/dist/lib/ontology-graph/schema/default-schema.d.ts +10 -0
- package/dist/lib/ontology-graph/schema/default-schema.js +242 -0
- package/dist/lib/ontology-graph/schema/grammar.d.ts +57 -0
- package/dist/lib/ontology-graph/schema/grammar.js +409 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +12 -0
- package/dist/lib/ontology-graph/schema/index.js +10 -0
- package/dist/lib/ontology-graph/schema/validate.d.ts +13 -0
- package/dist/lib/ontology-graph/schema/validate.js +132 -0
- package/dist/lib/ontology-graph/store/files.d.ts +34 -0
- package/dist/lib/ontology-graph/store/files.js +207 -0
- package/dist/lib/ontology-graph/store/fs.d.ts +30 -0
- package/dist/lib/ontology-graph/store/fs.js +101 -0
- package/dist/lib/ontology-graph/store/graph-store.d.ts +14 -0
- package/dist/lib/ontology-graph/store/graph-store.js +520 -0
- package/dist/lib/ontology-graph/store/index.d.ts +18 -0
- package/dist/lib/ontology-graph/store/index.js +15 -0
- package/dist/lib/ontology-graph/store/ingest.d.ts +37 -0
- package/dist/lib/ontology-graph/store/ingest.js +323 -0
- package/dist/lib/ontology-graph/store/paths.d.ts +114 -0
- package/dist/lib/ontology-graph/store/paths.js +232 -0
- package/dist/lib/ontology-graph/types.d.ts +1183 -0
- package/dist/lib/ontology-graph/types.js +131 -0
- package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
- package/dist/utils/frontmatter.d.ts +14 -0
- package/dist/utils/frontmatter.js +18 -0
- package/dist/utils/interactive-caller.js +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time and authority rules (design 2.3 and 2.7). Pure date and tier math, no
|
|
3
|
+
* model call and no file access.
|
|
4
|
+
*/
|
|
5
|
+
import type { AudienceKey, Contradiction, EdgeRow, EntityRef, FactRow, GraphEntityType, GraphSchema, IsoDate, RowClosure, RowId, StoredRow } from "../types.js";
|
|
6
|
+
type Stamped = FactRow | EdgeRow;
|
|
7
|
+
/** An F or E row with no `valid.to`. */
|
|
8
|
+
export declare function isOpen(row: Stamped): boolean;
|
|
9
|
+
/** `valid.from <= day < valid.to`. The closing day belongs to the newer row. */
|
|
10
|
+
export declare function rowCoversDay(row: Stamped, day: IsoDate): boolean;
|
|
11
|
+
/** True when a newer value closes the older row (role_title, stage, status, owned_by, reports_to). */
|
|
12
|
+
export declare function isSingleValued(schema: GraphSchema, type: GraphEntityType, row: Stamped): boolean;
|
|
13
|
+
/** `F:<field>` or `E:<verb>`: rows with the same key on one entity compete when single-valued. */
|
|
14
|
+
export declare function singleValueKey(row: Stamped): string;
|
|
15
|
+
/**
|
|
16
|
+
* The inverse of an edge, to be written on the edge's target. Carries the same
|
|
17
|
+
* stamps, so both directions cite the same source. Null when the verb is not
|
|
18
|
+
* in the schema.
|
|
19
|
+
*/
|
|
20
|
+
export declare function inverseEdge(schema: GraphSchema, subject: EntityRef, row: EdgeRow): {
|
|
21
|
+
entity: EntityRef;
|
|
22
|
+
row: EdgeRow;
|
|
23
|
+
} | null;
|
|
24
|
+
export interface SupersessionPlan {
|
|
25
|
+
/** Existing open rows the incoming row closes. */
|
|
26
|
+
close: {
|
|
27
|
+
id: RowId;
|
|
28
|
+
closure: RowClosure;
|
|
29
|
+
}[];
|
|
30
|
+
/**
|
|
31
|
+
* Set when the incoming row is older than an existing open row with a
|
|
32
|
+
* different value: write it already closed with these values.
|
|
33
|
+
*/
|
|
34
|
+
incomingClosed?: {
|
|
35
|
+
to: IsoDate;
|
|
36
|
+
closure: RowClosure;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Set when an open row of the same or higher authority already states the
|
|
40
|
+
* incoming value: the incoming row adds nothing and is not written, so a
|
|
41
|
+
* single-valued key never holds two open rows (correction C8).
|
|
42
|
+
*/
|
|
43
|
+
duplicateOf?: RowId;
|
|
44
|
+
contradictions: Contradiction[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* What writing `incoming` on `entity` does to the rows already there, within
|
|
48
|
+
* one audience:
|
|
49
|
+
*
|
|
50
|
+
* - Not single-valued, or no open row on the same key: nothing.
|
|
51
|
+
* - An open row of the same or higher authority states the same value:
|
|
52
|
+
* `duplicateOf` names it and the incoming row is not written. An open row
|
|
53
|
+
* of lower authority with the same value is closed by the incoming row.
|
|
54
|
+
* - Incoming is newer and has the same or higher authority: the older row is
|
|
55
|
+
* closed on the incoming row's valid-from day.
|
|
56
|
+
* - Incoming has lower authority than an open row: nothing is closed; a
|
|
57
|
+
* contradiction is reported and the incoming row is written closed on its
|
|
58
|
+
* own valid-from day, so it can be read and proposed but is never open.
|
|
59
|
+
* - Same day, same authority, different value: the same. The row that was
|
|
60
|
+
* there first stays open and the contradiction is reported.
|
|
61
|
+
* - Incoming is older than the open row and may be outranked by it: the
|
|
62
|
+
* incoming row is written closed on the open row's valid-from day.
|
|
63
|
+
*/
|
|
64
|
+
export declare function planSupersession(schema: GraphSchema, entity: EntityRef, audience: AudienceKey, existing: readonly StoredRow[], incoming: Stamped): SupersessionPlan;
|
|
65
|
+
/**
|
|
66
|
+
* The facts that answer "what is true" for one entity (design 2.7): for a
|
|
67
|
+
* single-valued field, the open row with the highest authority, then the
|
|
68
|
+
* newest; for a multi-valued field, every open row. With `asOf`, "open" means
|
|
69
|
+
* covering that day. Sorted by field, then value.
|
|
70
|
+
*/
|
|
71
|
+
export declare function effectiveFacts(schema: GraphSchema, type: GraphEntityType, rows: readonly StoredRow[], asOf?: IsoDate): StoredRow<FactRow>[];
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=authority.d.ts.map
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { originTier, parseEntityRef, rowId } from "./grammar.js";
|
|
2
|
+
/** An F or E row with no `valid.to`. */
|
|
3
|
+
export function isOpen(row) {
|
|
4
|
+
return row.valid.to === undefined;
|
|
5
|
+
}
|
|
6
|
+
/** `valid.from <= day < valid.to`. The closing day belongs to the newer row. */
|
|
7
|
+
export function rowCoversDay(row, day) {
|
|
8
|
+
return row.valid.from <= day && (row.valid.to === undefined || day < row.valid.to);
|
|
9
|
+
}
|
|
10
|
+
/** True when a newer value closes the older row (role_title, stage, status, owned_by, reports_to). */
|
|
11
|
+
export function isSingleValued(schema, type, row) {
|
|
12
|
+
if (row.kind === "F")
|
|
13
|
+
return schema.entity_types[type]?.facts[row.field]?.cardinality === "single";
|
|
14
|
+
return schema.link_types[row.verb]?.cardinality === "single";
|
|
15
|
+
}
|
|
16
|
+
/** `F:<field>` or `E:<verb>`: rows with the same key on one entity compete when single-valued. */
|
|
17
|
+
export function singleValueKey(row) {
|
|
18
|
+
return row.kind === "F" ? `F:${row.field}` : `E:${row.verb}`;
|
|
19
|
+
}
|
|
20
|
+
function sameValue(a, b) {
|
|
21
|
+
if (a.kind === "F" && b.kind === "F")
|
|
22
|
+
return a.value === b.value;
|
|
23
|
+
if (a.kind === "E" && b.kind === "E")
|
|
24
|
+
return a.target === b.target;
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The inverse of an edge, to be written on the edge's target. Carries the same
|
|
29
|
+
* stamps, so both directions cite the same source. Null when the verb is not
|
|
30
|
+
* in the schema.
|
|
31
|
+
*/
|
|
32
|
+
export function inverseEdge(schema, subject, row) {
|
|
33
|
+
const link = schema.link_types[row.verb];
|
|
34
|
+
if (!link)
|
|
35
|
+
return null;
|
|
36
|
+
return { entity: row.target, row: { ...row, verb: link.inverse, target: subject } };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What writing `incoming` on `entity` does to the rows already there, within
|
|
40
|
+
* one audience:
|
|
41
|
+
*
|
|
42
|
+
* - Not single-valued, or no open row on the same key: nothing.
|
|
43
|
+
* - An open row of the same or higher authority states the same value:
|
|
44
|
+
* `duplicateOf` names it and the incoming row is not written. An open row
|
|
45
|
+
* of lower authority with the same value is closed by the incoming row.
|
|
46
|
+
* - Incoming is newer and has the same or higher authority: the older row is
|
|
47
|
+
* closed on the incoming row's valid-from day.
|
|
48
|
+
* - Incoming has lower authority than an open row: nothing is closed; a
|
|
49
|
+
* contradiction is reported and the incoming row is written closed on its
|
|
50
|
+
* own valid-from day, so it can be read and proposed but is never open.
|
|
51
|
+
* - Same day, same authority, different value: the same. The row that was
|
|
52
|
+
* there first stays open and the contradiction is reported.
|
|
53
|
+
* - Incoming is older than the open row and may be outranked by it: the
|
|
54
|
+
* incoming row is written closed on the open row's valid-from day.
|
|
55
|
+
*/
|
|
56
|
+
export function planSupersession(schema, entity, audience, existing, incoming) {
|
|
57
|
+
const plan = { close: [], contradictions: [] };
|
|
58
|
+
const subject = parseEntityRef(entity);
|
|
59
|
+
if (!subject || !isSingleValued(schema, subject.type, incoming) || !isOpen(incoming))
|
|
60
|
+
return plan;
|
|
61
|
+
const key = singleValueKey(incoming);
|
|
62
|
+
const incomingId = rowId(incoming);
|
|
63
|
+
const incomingTier = originTier(incoming.by);
|
|
64
|
+
const competing = existing
|
|
65
|
+
.filter((stored) => stored.audience === audience && stored.row.kind !== "T")
|
|
66
|
+
.map((stored) => stored)
|
|
67
|
+
.filter((stored) => stored.id !== incomingId && isOpen(stored.row) && singleValueKey(stored.row) === key);
|
|
68
|
+
// One open row per value: a row that says what is already open adds nothing.
|
|
69
|
+
for (const same of competing.filter((stored) => sameValue(stored.row, incoming))) {
|
|
70
|
+
if (originTier(same.row.by) <= incomingTier) {
|
|
71
|
+
plan.duplicateOf = same.id;
|
|
72
|
+
return plan;
|
|
73
|
+
}
|
|
74
|
+
const on = same.row.valid.from > incoming.valid.from ? same.row.valid.from : incoming.valid.from;
|
|
75
|
+
plan.close.push({ id: same.id, closure: { on, by: incoming.src } });
|
|
76
|
+
}
|
|
77
|
+
const rivals = competing
|
|
78
|
+
.filter((stored) => !sameValue(stored.row, incoming))
|
|
79
|
+
.sort((a, b) => (a.row.valid.from < b.row.valid.from ? -1 : a.row.valid.from > b.row.valid.from ? 1 : a.id < b.id ? -1 : 1));
|
|
80
|
+
for (const rival of rivals) {
|
|
81
|
+
const rivalTier = originTier(rival.row.by);
|
|
82
|
+
const contradiction = (reason) => ({
|
|
83
|
+
entity,
|
|
84
|
+
audience,
|
|
85
|
+
key: key.slice(2),
|
|
86
|
+
kept: rival.id,
|
|
87
|
+
challenger: incomingId,
|
|
88
|
+
reason,
|
|
89
|
+
});
|
|
90
|
+
if (incomingTier > rivalTier) {
|
|
91
|
+
plan.contradictions.push(contradiction("lower_tier_challenger"));
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (rival.row.valid.from === incoming.valid.from && incomingTier === rivalTier) {
|
|
95
|
+
plan.contradictions.push(contradiction("same_day_conflict"));
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (rival.row.valid.from > incoming.valid.from) {
|
|
99
|
+
// The incoming row describes an earlier state than the open row.
|
|
100
|
+
const earliest = plan.incomingClosed?.to;
|
|
101
|
+
if (earliest === undefined || rival.row.valid.from < earliest) {
|
|
102
|
+
plan.incomingClosed = {
|
|
103
|
+
to: rival.row.valid.from,
|
|
104
|
+
closure: { on: rival.row.valid.from, by: rival.row.src },
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
plan.close.push({ id: rival.id, closure: { on: incoming.valid.from, by: incoming.src } });
|
|
110
|
+
}
|
|
111
|
+
const first = plan.contradictions[0];
|
|
112
|
+
if (first) {
|
|
113
|
+
// The challenger loses: it closes nothing and is written closed on its own day, citing the row that stands.
|
|
114
|
+
const kept = rivals.find((rival) => rival.id === first.kept);
|
|
115
|
+
plan.close = [];
|
|
116
|
+
plan.incomingClosed = { to: incoming.valid.from, closure: { on: incoming.valid.from, by: kept ? kept.row.src : incoming.src } };
|
|
117
|
+
}
|
|
118
|
+
return plan;
|
|
119
|
+
}
|
|
120
|
+
function better(a, b) {
|
|
121
|
+
const tierA = originTier(a.row.by);
|
|
122
|
+
const tierB = originTier(b.row.by);
|
|
123
|
+
if (tierA !== tierB)
|
|
124
|
+
return tierA < tierB;
|
|
125
|
+
if (a.row.valid.from !== b.row.valid.from)
|
|
126
|
+
return a.row.valid.from > b.row.valid.from;
|
|
127
|
+
if (a.row.conf !== b.row.conf)
|
|
128
|
+
return a.row.conf > b.row.conf;
|
|
129
|
+
return a.id < b.id;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The facts that answer "what is true" for one entity (design 2.7): for a
|
|
133
|
+
* single-valued field, the open row with the highest authority, then the
|
|
134
|
+
* newest; for a multi-valued field, every open row. With `asOf`, "open" means
|
|
135
|
+
* covering that day. Sorted by field, then value.
|
|
136
|
+
*/
|
|
137
|
+
export function effectiveFacts(schema, type, rows, asOf) {
|
|
138
|
+
const live = rows.filter((stored) => stored.row.kind === "F" && (asOf === undefined ? isOpen(stored.row) : rowCoversDay(stored.row, asOf)));
|
|
139
|
+
const winners = new Map();
|
|
140
|
+
const out = [];
|
|
141
|
+
for (const stored of live) {
|
|
142
|
+
if (!isSingleValued(schema, type, stored.row)) {
|
|
143
|
+
out.push(stored);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const current = winners.get(stored.row.field);
|
|
147
|
+
if (!current || better(stored, current))
|
|
148
|
+
winners.set(stored.row.field, stored);
|
|
149
|
+
}
|
|
150
|
+
out.push(...winners.values());
|
|
151
|
+
return out.sort((a, b) => a.row.field !== b.row.field
|
|
152
|
+
? a.row.field < b.row.field ? -1 : 1
|
|
153
|
+
: a.row.value !== b.row.value
|
|
154
|
+
? a.row.value < b.row.value ? -1 : 1
|
|
155
|
+
: a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=authority.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type GraphSchema } from "../types.js";
|
|
2
|
+
export declare class SchemaError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare const DEFAULT_SCHEMA: GraphSchema;
|
|
6
|
+
/** Deterministic: the same schema always renders the same bytes. */
|
|
7
|
+
export declare function renderSchemaYaml(schema?: GraphSchema): string;
|
|
8
|
+
/** Parses and checks schema.yaml. Throws SchemaError with the first problem. */
|
|
9
|
+
export declare function parseSchemaYaml(text: string): GraphSchema;
|
|
10
|
+
//# sourceMappingURL=default-schema.d.ts.map
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default schema and its schema.yaml form. `schema.yaml` in a graph folder
|
|
3
|
+
* is written from DEFAULT_SCHEMA on first use; after that the file is what the
|
|
4
|
+
* store reads, so a company can narrow the lists without a code change.
|
|
5
|
+
*/
|
|
6
|
+
import yaml from "js-yaml";
|
|
7
|
+
import { GRAPH_ENTITY_TYPES, VERBS, VERB_NAMES, } from "../types.js";
|
|
8
|
+
export class SchemaError extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(`ontology graph schema: ${message}`);
|
|
11
|
+
this.name = "SchemaError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const single = (description) => ({ cardinality: "single", ...(description ? { description } : {}) });
|
|
15
|
+
const multi = (description) => ({ cardinality: "multi", ...(description ? { description } : {}) });
|
|
16
|
+
const ENTITY_TYPES = {
|
|
17
|
+
person: {
|
|
18
|
+
facts: {
|
|
19
|
+
role_title: single("Job title"),
|
|
20
|
+
email: multi(),
|
|
21
|
+
slack_id: multi(),
|
|
22
|
+
affiliation: single("Organization the person belongs to, as text"),
|
|
23
|
+
status: single("active, left, external"),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
team: { facts: { purpose: single(), channel: multi(), status: single() } },
|
|
27
|
+
role: { facts: { title: single(), scope: single() } },
|
|
28
|
+
project: {
|
|
29
|
+
facts: {
|
|
30
|
+
status: single(),
|
|
31
|
+
stage: single(),
|
|
32
|
+
summary: single(),
|
|
33
|
+
repo: multi(),
|
|
34
|
+
started: single(),
|
|
35
|
+
target_date: single(),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
product: { facts: { status: single(), summary: single(), url: multi() } },
|
|
39
|
+
company: {
|
|
40
|
+
facts: {
|
|
41
|
+
relation: multi("customer, vendor, partner, investor, self"),
|
|
42
|
+
stage: single(),
|
|
43
|
+
crm_status: single(),
|
|
44
|
+
web_domain: multi(),
|
|
45
|
+
// The person who owns the account, as `person/<slug>`.
|
|
46
|
+
owner: single(),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
meeting: { facts: { date: single(), title: single(), channel: single() } },
|
|
50
|
+
decision: { facts: { statement: single(), status: single(), decided_on: single(), owner: single() } },
|
|
51
|
+
concept: { facts: { summary: single() } },
|
|
52
|
+
tool: { facts: { summary: single() } },
|
|
53
|
+
contact: { facts: { email: multi(), phone: multi(), title: single(), status: single() } },
|
|
54
|
+
deal: { facts: { stage: single(), status: single(), amount: single(), close_date: single() } },
|
|
55
|
+
contract: { facts: { status: single(), start_date: single(), end_date: single(), value: single() } },
|
|
56
|
+
invoice: { facts: { status: single(), amount: single(), due_date: single(), number: single() } },
|
|
57
|
+
};
|
|
58
|
+
const LEGACY_TYPED = [
|
|
59
|
+
["Works on", "works_on"],
|
|
60
|
+
["Uses", "uses"],
|
|
61
|
+
["Part of", "part_of"],
|
|
62
|
+
["Owned by", "owned_by"],
|
|
63
|
+
["Owns", "owns"],
|
|
64
|
+
["Works at", "works_at"],
|
|
65
|
+
["Leads", "leads"],
|
|
66
|
+
["Mentions", "mentions"],
|
|
67
|
+
["Reports to", "reports_to"],
|
|
68
|
+
];
|
|
69
|
+
const VERB_MAP = [
|
|
70
|
+
{ label: "Referenced in", action: "timeline" },
|
|
71
|
+
...["Debits", "Credits", "Posts", "billed_to", "Billed to", "Bill from"].map((label) => ({ label, action: "skip" })),
|
|
72
|
+
...LEGACY_TYPED.map(([label, verb]) => ({ label, action: "verb", verb, flip_if_reversed: true, conf: 0.5 })),
|
|
73
|
+
...["CEO", "Founder", "Co-founder", "CTO", "COO", "CFO"].map((label) => ({ label, action: "fact", field: "role_title", conf: 0.5 })),
|
|
74
|
+
{ label: "Related to", action: "related", verb: "related_to", conf: 0.3 },
|
|
75
|
+
];
|
|
76
|
+
export const DEFAULT_SCHEMA = {
|
|
77
|
+
version: 1,
|
|
78
|
+
entity_types: ENTITY_TYPES,
|
|
79
|
+
link_types: VERBS,
|
|
80
|
+
verb_map: VERB_MAP,
|
|
81
|
+
verb_map_default: { action: "related", verb: "related_to", conf: 0.3 },
|
|
82
|
+
refusals: {
|
|
83
|
+
min_name_length: 4,
|
|
84
|
+
generic_words: [
|
|
85
|
+
"admin", "all", "anyone", "bot", "channel", "client", "company", "customer", "everyone", "here", "team",
|
|
86
|
+
"the team", "support", "user", "users", "vendor", "partner", "investor", "manager", "owner", "someone",
|
|
87
|
+
],
|
|
88
|
+
job_titles: [
|
|
89
|
+
"ceo", "cto", "coo", "cfo", "cmo", "cpo", "founder", "co-founder", "cofounder", "president", "vp",
|
|
90
|
+
"director", "head of", "engineer", "designer", "advisor", "intern",
|
|
91
|
+
],
|
|
92
|
+
fuzzy_min_jaccard: 0.9,
|
|
93
|
+
fuzzy_min_chars: 6,
|
|
94
|
+
fuzzy_min_tokens: 2,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
const HEADER = [
|
|
98
|
+
"# Ontology graph schema. Written by `hq ontology` on first use.",
|
|
99
|
+
"# entity_types: the fact fields each type may carry. A row with an unlisted field is refused.",
|
|
100
|
+
"# link_types: the closed relationship vocabulary. Entries may be removed, not added.",
|
|
101
|
+
"# verb_map: what the legacy import does with each old relationship label.",
|
|
102
|
+
"",
|
|
103
|
+
].join("\n");
|
|
104
|
+
/** Deterministic: the same schema always renders the same bytes. */
|
|
105
|
+
export function renderSchemaYaml(schema = DEFAULT_SCHEMA) {
|
|
106
|
+
const plain = JSON.parse(JSON.stringify(schema));
|
|
107
|
+
return HEADER + yaml.dump(plain, { lineWidth: 120, noRefs: true, sortKeys: false, flowLevel: 3 });
|
|
108
|
+
}
|
|
109
|
+
function record(value, what) {
|
|
110
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
111
|
+
throw new SchemaError(`${what} must be a mapping`);
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
function typeList(value, what) {
|
|
115
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
116
|
+
throw new SchemaError(`${what} must be a list of types`);
|
|
117
|
+
for (const entry of value) {
|
|
118
|
+
if (entry !== "*" && !GRAPH_ENTITY_TYPES.includes(entry)) {
|
|
119
|
+
throw new SchemaError(`${what} names an unknown type: ${String(entry)}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
function cardinality(value, what) {
|
|
125
|
+
if (value !== "single" && value !== "multi")
|
|
126
|
+
throw new SchemaError(`${what} must be single or multi`);
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
/** Parses and checks schema.yaml. Throws SchemaError with the first problem. */
|
|
130
|
+
export function parseSchemaYaml(text) {
|
|
131
|
+
let loaded;
|
|
132
|
+
try {
|
|
133
|
+
loaded = yaml.load(text, { schema: yaml.CORE_SCHEMA });
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
throw new SchemaError(`schema.yaml is not valid YAML (${error.name})`);
|
|
137
|
+
}
|
|
138
|
+
const root = record(loaded, "schema.yaml");
|
|
139
|
+
if (root.version !== 1)
|
|
140
|
+
throw new SchemaError(`unsupported version: ${String(root.version)}`);
|
|
141
|
+
const entityTypes = {};
|
|
142
|
+
const rawTypes = record(root.entity_types, "entity_types");
|
|
143
|
+
for (const name of Object.keys(rawTypes)) {
|
|
144
|
+
if (!GRAPH_ENTITY_TYPES.includes(name))
|
|
145
|
+
throw new SchemaError(`unknown entity type: ${name}`);
|
|
146
|
+
}
|
|
147
|
+
for (const type of GRAPH_ENTITY_TYPES) {
|
|
148
|
+
const spec = record(rawTypes[type] ?? { facts: {} }, `entity_types.${type}`);
|
|
149
|
+
const facts = {};
|
|
150
|
+
for (const [field, raw] of Object.entries(record(spec.facts ?? {}, `entity_types.${type}.facts`))) {
|
|
151
|
+
if (!/^[a-z][a-z0-9_]*$/.test(field))
|
|
152
|
+
throw new SchemaError(`entity_types.${type}: bad field name ${field}`);
|
|
153
|
+
const fieldSpec = record(raw, `entity_types.${type}.facts.${field}`);
|
|
154
|
+
facts[field] = {
|
|
155
|
+
cardinality: cardinality(fieldSpec.cardinality, `entity_types.${type}.facts.${field}.cardinality`),
|
|
156
|
+
...(typeof fieldSpec.description === "string" ? { description: fieldSpec.description } : {}),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
entityTypes[type] = { ...(typeof spec.description === "string" ? { description: spec.description } : {}), facts };
|
|
160
|
+
}
|
|
161
|
+
const linkTypes = {};
|
|
162
|
+
for (const [name, raw] of Object.entries(record(root.link_types, "link_types"))) {
|
|
163
|
+
if (!VERB_NAMES.includes(name)) {
|
|
164
|
+
throw new SchemaError(`link_types.${name} is not in the closed vocabulary`);
|
|
165
|
+
}
|
|
166
|
+
const verb = name;
|
|
167
|
+
const spec = record(raw, `link_types.${name}`);
|
|
168
|
+
if (spec.inverse !== VERBS[verb].inverse)
|
|
169
|
+
throw new SchemaError(`link_types.${name}.inverse must be ${VERBS[verb].inverse}`);
|
|
170
|
+
if (spec.class !== VERBS[verb].class)
|
|
171
|
+
throw new SchemaError(`link_types.${name}.class must be ${VERBS[verb].class}`);
|
|
172
|
+
linkTypes[verb] = {
|
|
173
|
+
inverse: VERBS[verb].inverse,
|
|
174
|
+
class: VERBS[verb].class,
|
|
175
|
+
subjects: typeList(spec.subjects, `link_types.${name}.subjects`),
|
|
176
|
+
objects: typeList(spec.objects, `link_types.${name}.objects`),
|
|
177
|
+
cardinality: cardinality(spec.cardinality, `link_types.${name}.cardinality`),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
for (const verb of Object.keys(linkTypes)) {
|
|
181
|
+
if (!linkTypes[linkTypes[verb].inverse]) {
|
|
182
|
+
throw new SchemaError(`link_types.${verb} is listed without its inverse ${linkTypes[verb].inverse}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const verbMap = [];
|
|
186
|
+
if (!Array.isArray(root.verb_map))
|
|
187
|
+
throw new SchemaError("verb_map must be a list");
|
|
188
|
+
for (const [index, raw] of root.verb_map.entries()) {
|
|
189
|
+
const entry = record(raw, `verb_map[${index}]`);
|
|
190
|
+
const action = entry.action;
|
|
191
|
+
if (typeof entry.label !== "string" || entry.label.trim() === "")
|
|
192
|
+
throw new SchemaError(`verb_map[${index}].label is missing`);
|
|
193
|
+
if (action !== "verb" && action !== "timeline" && action !== "fact" && action !== "skip" && action !== "related") {
|
|
194
|
+
throw new SchemaError(`verb_map[${index}].action is not known: ${String(action)}`);
|
|
195
|
+
}
|
|
196
|
+
if ((action === "verb" || action === "related") && !(typeof entry.verb === "string" && entry.verb in linkTypes)) {
|
|
197
|
+
throw new SchemaError(`verb_map[${index}].verb is not in link_types: ${String(entry.verb)}`);
|
|
198
|
+
}
|
|
199
|
+
if (action === "fact" && typeof entry.field !== "string")
|
|
200
|
+
throw new SchemaError(`verb_map[${index}].field is missing`);
|
|
201
|
+
verbMap.push({
|
|
202
|
+
label: entry.label,
|
|
203
|
+
action,
|
|
204
|
+
...(typeof entry.verb === "string" ? { verb: entry.verb } : {}),
|
|
205
|
+
...(typeof entry.field === "string" ? { field: entry.field } : {}),
|
|
206
|
+
...(typeof entry.flip_if_reversed === "boolean" ? { flip_if_reversed: entry.flip_if_reversed } : {}),
|
|
207
|
+
...(typeof entry.conf === "number" ? { conf: entry.conf } : {}),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const fallback = record(root.verb_map_default ?? DEFAULT_SCHEMA.verb_map_default, "verb_map_default");
|
|
211
|
+
const refusals = record(root.refusals, "refusals");
|
|
212
|
+
const words = (value, what) => {
|
|
213
|
+
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string"))
|
|
214
|
+
throw new SchemaError(`${what} must be a list of text`);
|
|
215
|
+
return value;
|
|
216
|
+
};
|
|
217
|
+
const number = (value, what) => {
|
|
218
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
219
|
+
throw new SchemaError(`${what} must be a number`);
|
|
220
|
+
return value;
|
|
221
|
+
};
|
|
222
|
+
return {
|
|
223
|
+
version: 1,
|
|
224
|
+
entity_types: entityTypes,
|
|
225
|
+
link_types: linkTypes,
|
|
226
|
+
verb_map: verbMap,
|
|
227
|
+
verb_map_default: {
|
|
228
|
+
action: "related",
|
|
229
|
+
verb: "related_to",
|
|
230
|
+
conf: typeof fallback.conf === "number" ? fallback.conf : DEFAULT_SCHEMA.verb_map_default.conf,
|
|
231
|
+
},
|
|
232
|
+
refusals: {
|
|
233
|
+
min_name_length: number(refusals.min_name_length, "refusals.min_name_length"),
|
|
234
|
+
generic_words: words(refusals.generic_words, "refusals.generic_words"),
|
|
235
|
+
job_titles: words(refusals.job_titles, "refusals.job_titles"),
|
|
236
|
+
fuzzy_min_jaccard: number(refusals.fuzzy_min_jaccard, "refusals.fuzzy_min_jaccard"),
|
|
237
|
+
fuzzy_min_chars: number(refusals.fuzzy_min_chars, "refusals.fuzzy_min_chars"),
|
|
238
|
+
fuzzy_min_tokens: number(refusals.fuzzy_min_tokens, "refusals.fuzzy_min_tokens"),
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=default-schema.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type AudienceKey, type Confidence, type EntityRef, type GraphEntityType, type GraphRow, type IsoDate, type Origin, type ParsedOrigin, type ParsedSourceRef, type RowId, type RowRefusal, type RowRefusalCode, type SourceRef } from "../types.js";
|
|
2
|
+
export declare class RowGrammarError extends Error {
|
|
3
|
+
readonly code: RowRefusalCode;
|
|
4
|
+
constructor(code: RowRefusalCode, message: string);
|
|
5
|
+
}
|
|
6
|
+
export type RowParseResult = {
|
|
7
|
+
ok: true;
|
|
8
|
+
row: GraphRow;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
refusal: RowRefusal;
|
|
12
|
+
};
|
|
13
|
+
/** True for a real calendar day written `YYYY-MM-DD`. */
|
|
14
|
+
export declare function isIsoDate(value: unknown): value is IsoDate;
|
|
15
|
+
/** `company`, `local` or 16 lower-case hex. */
|
|
16
|
+
export declare function isAudienceKey(value: unknown): value is AudienceKey;
|
|
17
|
+
/** Lower-case, ASCII, dash-separated. Returns "" when nothing usable is left. */
|
|
18
|
+
export declare function slugify(name: string): string;
|
|
19
|
+
export declare function entityRef(type: GraphEntityType, slug: string): EntityRef;
|
|
20
|
+
export declare function isEntityRef(value: unknown): value is EntityRef;
|
|
21
|
+
export declare function parseEntityRef(value: string): {
|
|
22
|
+
type: GraphEntityType;
|
|
23
|
+
slug: string;
|
|
24
|
+
} | null;
|
|
25
|
+
export declare function parseSourceRef(value: string): ParsedSourceRef | null;
|
|
26
|
+
export declare function isSourceRef(value: unknown): value is SourceRef;
|
|
27
|
+
export declare function parseOrigin(value: string): ParsedOrigin | null;
|
|
28
|
+
export declare function isOrigin(value: unknown): value is Origin;
|
|
29
|
+
export declare function formatOrigin(origin: ParsedOrigin): Origin;
|
|
30
|
+
/** Authority tier, 1 (human) to 5 (legacy). An unreadable origin ranks last. */
|
|
31
|
+
export declare function originTier(by: string): 1 | 2 | 3 | 4 | 5;
|
|
32
|
+
/** Two decimals: `0.50`, `1.00`. */
|
|
33
|
+
export declare function formatConf(conf: Confidence): string;
|
|
34
|
+
export declare function escapeText(text: string): string;
|
|
35
|
+
export declare function unescapeText(text: string): string;
|
|
36
|
+
/** The markdown line for a row, without a trailing newline. */
|
|
37
|
+
export declare function formatRow(row: GraphRow): string;
|
|
38
|
+
/** True when the line starts like a row (`- F `, `- E `, `- T `). */
|
|
39
|
+
export declare function isRowLine(line: string): boolean;
|
|
40
|
+
/** Parses one row line. Throws RowGrammarError with a refusal code. */
|
|
41
|
+
export declare function parseRow(line: string): GraphRow;
|
|
42
|
+
export declare function tryParseRow(line: string): RowParseResult;
|
|
43
|
+
/**
|
|
44
|
+
* 12 hex. Built from what the row says and where it came from, not from
|
|
45
|
+
* `valid.to`, `learned`, `conf`, `was` or `closed`, and for a T row not from
|
|
46
|
+
* its optional `by`: the same fact from the same
|
|
47
|
+
* source on the same day is the same row however often it is replayed, and a
|
|
48
|
+
* row keeps its id when it is closed.
|
|
49
|
+
*/
|
|
50
|
+
export declare function rowId(row: GraphRow): RowId;
|
|
51
|
+
/**
|
|
52
|
+
* File order: F rows, then E rows, then T rows. F by field, E by verb then
|
|
53
|
+
* target, both then by valid from, source and origin. T rows oldest first.
|
|
54
|
+
* Uses code-unit comparison so the order is the same on every machine.
|
|
55
|
+
*/
|
|
56
|
+
export declare function compareRows(a: GraphRow, b: GraphRow): number;
|
|
57
|
+
//# sourceMappingURL=grammar.d.ts.map
|