avouch 0.1.22
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/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +356 -0
- package/SPEC.md +379 -0
- package/dist/cli/avouch.d.ts +2 -0
- package/dist/cli/avouch.js +68 -0
- package/dist/cli/check.d.ts +86 -0
- package/dist/cli/check.js +333 -0
- package/dist/cli/facts.d.ts +3 -0
- package/dist/cli/facts.js +157 -0
- package/dist/cli/gate.d.ts +3 -0
- package/dist/cli/gate.js +149 -0
- package/dist/cli/init.d.ts +21 -0
- package/dist/cli/init.js +282 -0
- package/dist/cli/jsonl.d.ts +5 -0
- package/dist/cli/jsonl.js +20 -0
- package/dist/cli/query.d.ts +2 -0
- package/dist/cli/query.js +138 -0
- package/dist/cli/reconcile.d.ts +9 -0
- package/dist/cli/reconcile.js +131 -0
- package/dist/src/checker.d.ts +3 -0
- package/dist/src/checker.js +1136 -0
- package/dist/src/contract.d.ts +135 -0
- package/dist/src/contract.js +3 -0
- package/dist/src/coverage.d.ts +65 -0
- package/dist/src/coverage.js +237 -0
- package/dist/src/evaluate.d.ts +66 -0
- package/dist/src/evaluate.js +535 -0
- package/dist/src/expr.d.ts +209 -0
- package/dist/src/expr.js +497 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +11 -0
- package/dist/src/ledger.d.ts +96 -0
- package/dist/src/ledger.js +241 -0
- package/dist/src/markdown.d.ts +66 -0
- package/dist/src/markdown.js +701 -0
- package/dist/src/patch.d.ts +6 -0
- package/dist/src/patch.js +37 -0
- package/dist/src/query.d.ts +333 -0
- package/dist/src/query.js +739 -0
- package/dist/src/reconcile.d.ts +61 -0
- package/dist/src/reconcile.js +151 -0
- package/dist/src/stage1-check.d.ts +31 -0
- package/dist/src/stage1-check.js +329 -0
- package/dist/src/touched.d.ts +1 -0
- package/dist/src/touched.js +9 -0
- package/dist/src/unknown.d.ts +10 -0
- package/dist/src/unknown.js +173 -0
- package/docs/adapter-guide.md +187 -0
- package/docs/markdown-convention.md +635 -0
- package/ontology.schema.json +1757 -0
- package/package.json +57 -0
- package/templates/agents-block.md +12 -0
- package/vocab.ttl +524 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export type Scalar = "enum" | "timestamp" | "duration" | "date" | "timezone" | "id" | "integer" | "number" | "boolean" | "string" | {
|
|
2
|
+
ref: string;
|
|
3
|
+
};
|
|
4
|
+
export type Type = Scalar | {
|
|
5
|
+
set: Scalar;
|
|
6
|
+
};
|
|
7
|
+
export declare const SCALAR_TYPE_NAMES: readonly ["enum", "timestamp", "duration", "date", "timezone", "id", "integer", "number", "boolean", "string"];
|
|
8
|
+
export declare const EXPR_NODES: readonly ["ref", "lit", "plus", "dateIn", "derived", "eq", "neq", "lt", "lte", "gt", "gte", "and", "or", "not", "in", "subsetOf", "isNull", "isNotNull", "exists", "none", "all", "nav"];
|
|
9
|
+
export type Lit = string | number | (string | number)[];
|
|
10
|
+
export type Nav = {
|
|
11
|
+
nav: {
|
|
12
|
+
from: {
|
|
13
|
+
ref: string;
|
|
14
|
+
};
|
|
15
|
+
link: string;
|
|
16
|
+
dir: "forward" | "reverse";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type Quantifier = {
|
|
20
|
+
as: string;
|
|
21
|
+
in: Nav;
|
|
22
|
+
where?: Expr;
|
|
23
|
+
};
|
|
24
|
+
export type ValueExpr = {
|
|
25
|
+
ref: string;
|
|
26
|
+
} | {
|
|
27
|
+
lit: Lit;
|
|
28
|
+
} | {
|
|
29
|
+
plus: [Expr, Expr];
|
|
30
|
+
} | {
|
|
31
|
+
dateIn: [Expr, Expr];
|
|
32
|
+
} | {
|
|
33
|
+
derived: {
|
|
34
|
+
id: string;
|
|
35
|
+
of: {
|
|
36
|
+
ref: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type PredicateExpr = {
|
|
41
|
+
eq: [Expr, Expr];
|
|
42
|
+
} | {
|
|
43
|
+
neq: [Expr, Expr];
|
|
44
|
+
} | {
|
|
45
|
+
lt: [Expr, Expr];
|
|
46
|
+
} | {
|
|
47
|
+
lte: [Expr, Expr];
|
|
48
|
+
} | {
|
|
49
|
+
gt: [Expr, Expr];
|
|
50
|
+
} | {
|
|
51
|
+
gte: [Expr, Expr];
|
|
52
|
+
} | {
|
|
53
|
+
and: Expr[];
|
|
54
|
+
} | {
|
|
55
|
+
or: Expr[];
|
|
56
|
+
} | {
|
|
57
|
+
not: [Expr];
|
|
58
|
+
} | {
|
|
59
|
+
in: [Expr, Expr];
|
|
60
|
+
} | {
|
|
61
|
+
subsetOf: [Expr, Expr];
|
|
62
|
+
} | {
|
|
63
|
+
isNull: [Expr];
|
|
64
|
+
} | {
|
|
65
|
+
isNotNull: [Expr];
|
|
66
|
+
} | {
|
|
67
|
+
exists: Quantifier;
|
|
68
|
+
} | {
|
|
69
|
+
none: Quantifier;
|
|
70
|
+
} | {
|
|
71
|
+
all: Quantifier;
|
|
72
|
+
};
|
|
73
|
+
export type Expr = ValueExpr | PredicateExpr;
|
|
74
|
+
export declare const DISPOSITION_CLASSES: readonly ["rejected", "recorded", "pending", "applied"];
|
|
75
|
+
export type DispositionClass = (typeof DISPOSITION_CLASSES)[number];
|
|
76
|
+
export declare const INVOCATION_RESULTS: readonly ["REPLAYED", "IDEMPOTENCY_CONFLICT", "INVALID_BINDING", "SCOPE_DENIED", "PERMISSION_DENIED"];
|
|
77
|
+
export type Principals = {
|
|
78
|
+
kinds: string[];
|
|
79
|
+
cite?: unknown;
|
|
80
|
+
};
|
|
81
|
+
export type Alt = {
|
|
82
|
+
keys: string[];
|
|
83
|
+
conditional_keys?: string[];
|
|
84
|
+
conditional_when?: Expr;
|
|
85
|
+
principals?: Principals;
|
|
86
|
+
};
|
|
87
|
+
export type Permission = "unknown" | {
|
|
88
|
+
none: string;
|
|
89
|
+
principals?: Principals;
|
|
90
|
+
} | Alt | {
|
|
91
|
+
any_of: Alt[];
|
|
92
|
+
};
|
|
93
|
+
export type DecisionRow = {
|
|
94
|
+
when: {
|
|
95
|
+
passes: string;
|
|
96
|
+
} | {
|
|
97
|
+
fails: string;
|
|
98
|
+
};
|
|
99
|
+
result: string;
|
|
100
|
+
next?: unknown;
|
|
101
|
+
};
|
|
102
|
+
export type Decision = {
|
|
103
|
+
hitPolicy: "first";
|
|
104
|
+
rows: DecisionRow[];
|
|
105
|
+
otherwise?: {
|
|
106
|
+
result: string;
|
|
107
|
+
next?: unknown;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export type Condition = {
|
|
111
|
+
id: string;
|
|
112
|
+
expr?: Expr;
|
|
113
|
+
unspecified?: string;
|
|
114
|
+
};
|
|
115
|
+
export type ActionType = {
|
|
116
|
+
parameters?: Record<string, {
|
|
117
|
+
type?: Type;
|
|
118
|
+
optional?: true;
|
|
119
|
+
values?: string[];
|
|
120
|
+
projectedFrom?: string[];
|
|
121
|
+
unresolved?: "domain";
|
|
122
|
+
}>;
|
|
123
|
+
permission: Permission;
|
|
124
|
+
conditions: Condition[];
|
|
125
|
+
decision?: Decision;
|
|
126
|
+
};
|
|
127
|
+
export declare function projectedFields(p: {
|
|
128
|
+
type?: unknown;
|
|
129
|
+
projectedFrom?: unknown;
|
|
130
|
+
}): string[] | null;
|
|
131
|
+
export declare function resolvesInDomain(p: {
|
|
132
|
+
type?: unknown;
|
|
133
|
+
optional?: unknown;
|
|
134
|
+
projectedFrom?: unknown;
|
|
135
|
+
unresolved?: unknown;
|
|
136
|
+
}): boolean;
|
|
137
|
+
export interface Stage1Ontology {
|
|
138
|
+
scope?: {
|
|
139
|
+
by: string;
|
|
140
|
+
global?: {
|
|
141
|
+
type: string;
|
|
142
|
+
}[];
|
|
143
|
+
root?: {
|
|
144
|
+
type: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
dispositions?: Record<string, {
|
|
148
|
+
class: DispositionClass;
|
|
149
|
+
}>;
|
|
150
|
+
objectTypes: Record<string, {
|
|
151
|
+
datasource: string;
|
|
152
|
+
properties: Record<string, {
|
|
153
|
+
type?: Type;
|
|
154
|
+
from?: {
|
|
155
|
+
field: string;
|
|
156
|
+
key: string;
|
|
157
|
+
};
|
|
158
|
+
}>;
|
|
159
|
+
}>;
|
|
160
|
+
linkTypes: {
|
|
161
|
+
id: string;
|
|
162
|
+
from: string;
|
|
163
|
+
to: string;
|
|
164
|
+
via: string;
|
|
165
|
+
table?: string;
|
|
166
|
+
}[];
|
|
167
|
+
derivedProperties?: Record<string, {
|
|
168
|
+
of: string;
|
|
169
|
+
type?: Type;
|
|
170
|
+
expr?: Expr;
|
|
171
|
+
}>;
|
|
172
|
+
actionTypes: Record<string, ActionType>;
|
|
173
|
+
}
|
|
174
|
+
export declare class ExprError extends Error {
|
|
175
|
+
readonly path: string;
|
|
176
|
+
constructor(path: string, msg: string);
|
|
177
|
+
}
|
|
178
|
+
export interface ExprReads {
|
|
179
|
+
reads: {
|
|
180
|
+
prop: string;
|
|
181
|
+
lit?: string;
|
|
182
|
+
}[];
|
|
183
|
+
literals: (string | number)[];
|
|
184
|
+
undefinedDerived: Set<string>;
|
|
185
|
+
}
|
|
186
|
+
export declare const newReads: () => ExprReads;
|
|
187
|
+
export type ExprContext = {
|
|
188
|
+
action?: string;
|
|
189
|
+
self?: string;
|
|
190
|
+
locals: Record<string, string>;
|
|
191
|
+
collect?: ExprReads;
|
|
192
|
+
nested?: boolean;
|
|
193
|
+
};
|
|
194
|
+
export declare const RESERVED_NAMES: readonly ["now", "actor", "self"];
|
|
195
|
+
export declare const DATE_RE: RegExp;
|
|
196
|
+
export declare const TIMESTAMP_MIN = -62135510400000;
|
|
197
|
+
export declare const TIMESTAMP_MAX = 253402214399999;
|
|
198
|
+
export declare const isObj: (x: unknown) => x is Record<string, any>;
|
|
199
|
+
export declare const own: <V>(r: Readonly<Record<string, V>> | undefined, k: string) => V | undefined;
|
|
200
|
+
export declare function typeEquals(a: Type | "string", b: Type | "string"): boolean;
|
|
201
|
+
export declare function validTimezone(v: string): boolean;
|
|
202
|
+
export declare function fitsType(v: unknown, t: Type | "string"): boolean;
|
|
203
|
+
export declare function objectBinding(ont: Stage1Ontology, name: string, ctx: ExprContext): string | undefined;
|
|
204
|
+
export declare function isPureLink(ont: Stage1Ontology, link: Stage1Ontology["linkTypes"][number]): boolean;
|
|
205
|
+
export declare function navType(ont: Stage1Ontology, n: unknown, ctx: ExprContext, at: string): string;
|
|
206
|
+
export declare function checkPredicate(ont: Stage1Ontology, expr: unknown, ctx: ExprContext): void;
|
|
207
|
+
export declare function checkPermissionWhen(ont: Stage1Ontology, expr: unknown, action: string, collect?: ExprReads): void;
|
|
208
|
+
export declare function derivedPropertyType(ont: Stage1Ontology, id: string, collect?: ExprReads): Type;
|
|
209
|
+
export declare function valueType(ont: Stage1Ontology, expr: unknown, ctx: ExprContext, expected?: Type): Type;
|