@githonllc/avouch 0.0.0-stage → 0.1.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.
@@ -0,0 +1,304 @@
1
+ import { type Expr, type Type } from "./expr.js";
2
+ export type S = string | null;
3
+ export type QueryCite = {
4
+ doc: string;
5
+ quote: string;
6
+ };
7
+ export type QueryStamp = {
8
+ ontology: string;
9
+ git: {
10
+ commit: string;
11
+ dirty: boolean;
12
+ path: string;
13
+ } | null;
14
+ check: {
15
+ status: "not_run";
16
+ } | {
17
+ status: "pass" | "fail";
18
+ adapter: string;
19
+ schemaErrors: number;
20
+ violations: number;
21
+ waived: number;
22
+ };
23
+ };
24
+ export type QueryVerb = "list" | "action" | "object" | "result" | "writes" | "reads" | "cites";
25
+ export type QueryEnvelope = {
26
+ avouchQuery: 1;
27
+ stamp: QueryStamp;
28
+ verb: QueryVerb;
29
+ arg: string;
30
+ result: unknown;
31
+ };
32
+ export type QueryList = {
33
+ kind: "actions";
34
+ items: {
35
+ id: string;
36
+ context: S;
37
+ doc: S;
38
+ docTerm: S;
39
+ permissionKeys: string[];
40
+ }[];
41
+ } | {
42
+ kind: "objects";
43
+ items: {
44
+ id: string;
45
+ context: S;
46
+ datasource: S;
47
+ outOfScope: S;
48
+ }[];
49
+ } | {
50
+ kind: "links";
51
+ items: {
52
+ id: string;
53
+ from: S;
54
+ to: S;
55
+ cardinality: S;
56
+ via: S;
57
+ table: S;
58
+ }[];
59
+ } | {
60
+ kind: "derived";
61
+ items: {
62
+ id: string;
63
+ of: S;
64
+ type: Type | null;
65
+ docTerm: S;
66
+ hasExpr: boolean;
67
+ }[];
68
+ } | {
69
+ kind: "dispositions";
70
+ items: {
71
+ id: string;
72
+ class: S;
73
+ cite: QueryCite | null;
74
+ }[];
75
+ } | {
76
+ kind: "anchors";
77
+ items: {
78
+ doc: string;
79
+ claims: number;
80
+ }[];
81
+ } | {
82
+ kind: "gaps";
83
+ items: {
84
+ id: S;
85
+ rule: S;
86
+ kind: S;
87
+ keys: string[];
88
+ conflict: S;
89
+ proposed: S;
90
+ }[];
91
+ };
92
+ export type QueryAlt = {
93
+ keys: string[];
94
+ conditionalKeys: string[];
95
+ cite: QueryCite | null;
96
+ conditionalCite: QueryCite | null;
97
+ principals: {
98
+ kinds: string[];
99
+ cite: QueryCite | null;
100
+ } | null;
101
+ };
102
+ export type QueryRow = {
103
+ row: number | "otherwise";
104
+ when: {
105
+ passes: string;
106
+ } | {
107
+ fails: string;
108
+ } | null;
109
+ result: S;
110
+ class: S;
111
+ cites: QueryCite[];
112
+ next: unknown;
113
+ requires: {
114
+ condition: string;
115
+ must: "pass" | "fail";
116
+ specified: boolean;
117
+ }[];
118
+ blockedBy: S;
119
+ };
120
+ export type QueryAction = {
121
+ id: string;
122
+ context: S;
123
+ doc: S;
124
+ docTerm: S;
125
+ permission: {
126
+ form: "unknown";
127
+ } | {
128
+ form: "none";
129
+ reason: S;
130
+ cite: QueryCite | null;
131
+ principals: QueryAlt["principals"];
132
+ } | {
133
+ form: "keys";
134
+ alternatives: QueryAlt[];
135
+ };
136
+ idempotencyKey: {
137
+ required: boolean;
138
+ cite: QueryCite | null;
139
+ } | null;
140
+ parameters: {
141
+ name: string;
142
+ type: Type | null;
143
+ optional: boolean;
144
+ values: string[] | null;
145
+ cite: QueryCite | null;
146
+ }[];
147
+ conditions: {
148
+ id: string;
149
+ expr: Expr | null;
150
+ exprText: S;
151
+ unspecified: S;
152
+ reads: unknown[];
153
+ cites: QueryCite[];
154
+ scenarios: string[];
155
+ }[];
156
+ decision: {
157
+ order: QueryCite | null;
158
+ rows: QueryRow[];
159
+ } | null;
160
+ edits: {
161
+ prop: string;
162
+ cite: QueryCite | null;
163
+ }[];
164
+ creates: string[];
165
+ emits: string[];
166
+ linkEffects: {
167
+ link: string;
168
+ kind: "effect" | "none" | "unspecified";
169
+ text: S;
170
+ cite: QueryCite | null;
171
+ scenarios: string[];
172
+ }[];
173
+ crossContext: {
174
+ via: S;
175
+ unspecified: S;
176
+ cite: QueryCite | null;
177
+ } | null;
178
+ evidence: S;
179
+ transitions: {
180
+ object: string;
181
+ from: S;
182
+ to: S;
183
+ }[];
184
+ };
185
+ export type QueryObject = {
186
+ id: string;
187
+ context: S;
188
+ datasource: S;
189
+ doc: S;
190
+ outOfScope: S;
191
+ scope: "tenant" | "global" | "root" | null;
192
+ properties: {
193
+ name: string;
194
+ class: S;
195
+ type: Type | null;
196
+ cite: QueryCite | null;
197
+ canonicalValues: {
198
+ values: string[];
199
+ cite: QueryCite | null;
200
+ } | null;
201
+ materializedFrom: {
202
+ reads: string[];
203
+ cites: QueryCite[];
204
+ } | null;
205
+ }[];
206
+ derived: {
207
+ id: string;
208
+ type: Type | null;
209
+ docTerm: S;
210
+ exprText: S;
211
+ cite: QueryCite | null;
212
+ }[];
213
+ stateMachine: {
214
+ doc: S;
215
+ initial: S;
216
+ terminal: string[];
217
+ transitions: {
218
+ from: S;
219
+ to: S;
220
+ by: string[];
221
+ outOfScope: S;
222
+ }[];
223
+ } | null;
224
+ links: {
225
+ id: string;
226
+ end: "from" | "to";
227
+ other: S;
228
+ cardinality: S;
229
+ via: S;
230
+ }[];
231
+ writers: {
232
+ action: string;
233
+ edits: string[];
234
+ creates: boolean;
235
+ }[];
236
+ readers: {
237
+ action: string;
238
+ condition: string;
239
+ props: string[];
240
+ }[];
241
+ unanalyzed: QueryWrites["unanalyzed"];
242
+ };
243
+ export type QueryDisposition = {
244
+ disposition: string;
245
+ class: S;
246
+ cite: QueryCite | null;
247
+ rows: ({
248
+ action: string;
249
+ } & QueryRow)[];
250
+ };
251
+ export type QueryWrites = {
252
+ target: string;
253
+ kind: "property" | "derived";
254
+ unanalyzed: {
255
+ at: string;
256
+ error: string;
257
+ }[];
258
+ writers: {
259
+ action: string;
260
+ cite: QueryCite | null;
261
+ path: string[];
262
+ }[];
263
+ creators: string[];
264
+ };
265
+ export type QueryReads = {
266
+ target: string;
267
+ kind: "property" | "derived";
268
+ materialized: string[];
269
+ unanalyzed: {
270
+ at: string;
271
+ error: string;
272
+ }[];
273
+ conditions: {
274
+ action: string;
275
+ condition: string;
276
+ source: "expr" | "reads";
277
+ direct: boolean;
278
+ via: string[];
279
+ rows: number[];
280
+ }[];
281
+ derived: {
282
+ id: string;
283
+ source: "expr" | "reads";
284
+ direct: boolean;
285
+ via: string[];
286
+ }[];
287
+ };
288
+ export type QueryCites = {
289
+ anchor: string;
290
+ claims: {
291
+ path: string;
292
+ subject: string;
293
+ quote: S;
294
+ }[];
295
+ };
296
+ export declare function showExpr(e: unknown): string;
297
+ export declare function queryAction(ont: unknown, id: string): QueryAction | null;
298
+ export declare function queryDisposition(ont: unknown, id: string): QueryDisposition | null;
299
+ export declare function queryObject(ont: unknown, id: string): QueryObject | null;
300
+ export declare function queryWrites(ont: unknown, t: string): QueryWrites | null;
301
+ export declare function queryReads(ont: unknown, t: string): QueryReads | null;
302
+ export declare function queryCites(ont: unknown, anchor: string): QueryCites;
303
+ export declare const QUERY_LIST_KINDS: readonly ["actions", "objects", "links", "derived", "dispositions", "anchors", "gaps"];
304
+ export declare function queryList(ont: unknown, kind: string): QueryList | null;