@oxyhq/crowdsource-contracts 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.
- package/README.md +129 -0
- package/dist/case-envelope.d.ts +1130 -0
- package/dist/case-envelope.d.ts.map +1 -0
- package/dist/case-envelope.js +383 -0
- package/dist/case-envelope.js.map +1 -0
- package/dist/decisions.d.ts +353 -0
- package/dist/decisions.d.ts.map +1 -0
- package/dist/decisions.js +198 -0
- package/dist/decisions.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +43 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +83 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/policies.d.ts +286 -0
- package/dist/policies.d.ts.map +1 -0
- package/dist/policies.js +178 -0
- package/dist/policies.js.map +1 -0
- package/dist/primitives.d.ts +185 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +231 -0
- package/dist/primitives.js.map +1 -0
- package/dist/reputation-events.d.ts +349 -0
- package/dist/reputation-events.d.ts.map +1 -0
- package/dist/reputation-events.js +128 -0
- package/dist/reputation-events.js.map +1 -0
- package/dist/resources.d.ts +484 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +436 -0
- package/dist/resources.js.map +1 -0
- package/dist/reviews.d.ts +276 -0
- package/dist/reviews.d.ts.map +1 -0
- package/dist/reviews.js +144 -0
- package/dist/reviews.js.map +1 -0
- package/dist/taxonomy.d.ts +266 -0
- package/dist/taxonomy.d.ts.map +1 -0
- package/dist/taxonomy.js +282 -0
- package/dist/taxonomy.js.map +1 -0
- package/dist/webhooks.d.ts +604 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +192 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +56 -0
- package/src/case-envelope.ts +433 -0
- package/src/decisions.ts +216 -0
- package/src/index.ts +45 -0
- package/src/json-schema.ts +89 -0
- package/src/policies.ts +203 -0
- package/src/primitives.ts +283 -0
- package/src/reputation-events.ts +144 -0
- package/src/resources.ts +489 -0
- package/src/reviews.ts +159 -0
- package/src/taxonomy.ts +313 -0
- package/src/webhooks.ts +215 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resources and relations — the universal content unit (§5.2–§5.7).
|
|
3
|
+
*
|
|
4
|
+
* "Applications send data, never executable code" (§5.2). Everything in this
|
|
5
|
+
* module follows from that one sentence:
|
|
6
|
+
*
|
|
7
|
+
* * The resource union is CLOSED and discriminated on `type`, and each
|
|
8
|
+
* variant declares exactly which fields it may carry. There is no free-form
|
|
9
|
+
* branch, so there is no place to put a rendering instruction.
|
|
10
|
+
* * Every object is `.strict()`. In the outbound direction an unknown field
|
|
11
|
+
* is harmless forward compatibility (§10.11); inbound it is not. A field
|
|
12
|
+
* that is silently dropped is context an application believes it sent and a
|
|
13
|
+
* jury never sees — which is how a case gets decided on incomplete material
|
|
14
|
+
* — and a field that is silently kept is a rendering input nobody reviewed.
|
|
15
|
+
* §10.11 makes exactly this exception: unknown fields must not break
|
|
16
|
+
* clients "except where the schema forbids them for safety".
|
|
17
|
+
* * A media type must agree with its resource type, so an `image` cannot
|
|
18
|
+
* declare `text/html` and be handed to something that trusts the label.
|
|
19
|
+
* * §5.7 custom payloads are bounded JSON with no `$`-prefixed keys, which
|
|
20
|
+
* removes every JSON Schema reference mechanism at once — `$ref` to a
|
|
21
|
+
* remote document IS the "remote component" §5.7 forbids, and resolving one
|
|
22
|
+
* is an SSRF against CrowdSource itself.
|
|
23
|
+
*
|
|
24
|
+
* What is deliberately NOT here: any filter on the CONTENT of text fields. The
|
|
25
|
+
* material under review is hostile by definition — a harassment report quotes
|
|
26
|
+
* the harassment, a phishing report quotes the phishing link. A lexical
|
|
27
|
+
* blocklist would reject the evidence and protect nothing, because the contract
|
|
28
|
+
* has no field whose value is ever interpreted as markup or code.
|
|
29
|
+
*/
|
|
30
|
+
import { z } from 'zod';
|
|
31
|
+
/** A resource id, unique within one envelope (§5.2 `id`). */
|
|
32
|
+
export declare const ResourceIdSchema: z.ZodString;
|
|
33
|
+
export type ResourceId = z.infer<typeof ResourceIdSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* A pseudonymous reference to an actor, resolved within one envelope.
|
|
36
|
+
*
|
|
37
|
+
* Never a real identity: §13.5 requires a pseudonymous principal wherever one
|
|
38
|
+
* suffices. `principalBindings` is the only place a ref is tied to anything,
|
|
39
|
+
* and even there it is tied to a binding proof id, not to a name.
|
|
40
|
+
*/
|
|
41
|
+
export declare const PrincipalRefSchema: z.ZodString;
|
|
42
|
+
export type PrincipalRef = z.infer<typeof PrincipalRefSchema>;
|
|
43
|
+
/** §5.2 `role`: why this resource is in the case. */
|
|
44
|
+
export declare const RESOURCE_ROLES: readonly ["subject", "attachment", "context", "parent", "quoted", "evidence", "metadata", "policy_context"];
|
|
45
|
+
export declare const ResourceRoleSchema: z.ZodEnum<{
|
|
46
|
+
metadata: "metadata";
|
|
47
|
+
subject: "subject";
|
|
48
|
+
attachment: "attachment";
|
|
49
|
+
context: "context";
|
|
50
|
+
parent: "parent";
|
|
51
|
+
quoted: "quoted";
|
|
52
|
+
evidence: "evidence";
|
|
53
|
+
policy_context: "policy_context";
|
|
54
|
+
}>;
|
|
55
|
+
export type ResourceRole = z.infer<typeof ResourceRoleSchema>;
|
|
56
|
+
/** §5.3 standard resource types. */
|
|
57
|
+
export declare const RESOURCE_TYPES: readonly ["text", "image", "video", "audio", "document", "link", "profile", "conversation", "listing", "location", "metadata", "custom"];
|
|
58
|
+
export declare const ResourceTypeSchema: z.ZodEnum<{
|
|
59
|
+
custom: "custom";
|
|
60
|
+
metadata: "metadata";
|
|
61
|
+
link: "link";
|
|
62
|
+
text: "text";
|
|
63
|
+
image: "image";
|
|
64
|
+
video: "video";
|
|
65
|
+
audio: "audio";
|
|
66
|
+
document: "document";
|
|
67
|
+
profile: "profile";
|
|
68
|
+
conversation: "conversation";
|
|
69
|
+
listing: "listing";
|
|
70
|
+
location: "location";
|
|
71
|
+
}>;
|
|
72
|
+
export type ResourceType = z.infer<typeof ResourceTypeSchema>;
|
|
73
|
+
/** §5.3 text formatting. Never HTML: `markdown_subset` is a subset for a reason. */
|
|
74
|
+
export declare const TEXT_FORMATTINGS: readonly ["plain", "markdown_subset"];
|
|
75
|
+
export declare const TextFormattingSchema: z.ZodEnum<{
|
|
76
|
+
plain: "plain";
|
|
77
|
+
markdown_subset: "markdown_subset";
|
|
78
|
+
}>;
|
|
79
|
+
export type TextFormatting = z.infer<typeof TextFormattingSchema>;
|
|
80
|
+
/**
|
|
81
|
+
* A reference to bytes held outside the envelope (§5.2 `asset`).
|
|
82
|
+
*
|
|
83
|
+
* Exactly one of `uploadId` and `url` — never both, never neither. Two
|
|
84
|
+
* locations for one piece of evidence means two answers to "what exactly did
|
|
85
|
+
* the jury look at", and §5.6 requires the case to pin the exact version that
|
|
86
|
+
* was reported. `sha256` is required for the same reason: it is what makes the
|
|
87
|
+
* answer verifiable after the application has deleted the original.
|
|
88
|
+
*/
|
|
89
|
+
export declare const AssetRefSchema: z.ZodObject<{
|
|
90
|
+
uploadId: z.ZodOptional<z.ZodString>;
|
|
91
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
92
|
+
mimeType: z.ZodString;
|
|
93
|
+
sha256: z.ZodString;
|
|
94
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
}, z.core.$strict>;
|
|
99
|
+
export type AssetRef = z.infer<typeof AssetRefSchema>;
|
|
100
|
+
/**
|
|
101
|
+
* One resource (§5.2).
|
|
102
|
+
*
|
|
103
|
+
* A discriminated union rather than one object with everything optional: the
|
|
104
|
+
* latter would accept an `image` with inline text and no asset, which is not a
|
|
105
|
+
* resource anybody can review.
|
|
106
|
+
*/
|
|
107
|
+
export declare const ResourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
108
|
+
type: z.ZodLiteral<"text">;
|
|
109
|
+
data: z.ZodObject<{
|
|
110
|
+
text: z.ZodString;
|
|
111
|
+
formatting: z.ZodOptional<z.ZodEnum<{
|
|
112
|
+
plain: "plain";
|
|
113
|
+
markdown_subset: "markdown_subset";
|
|
114
|
+
}>>;
|
|
115
|
+
}, z.core.$strict>;
|
|
116
|
+
sha256: z.ZodString;
|
|
117
|
+
id: z.ZodString;
|
|
118
|
+
role: z.ZodEnum<{
|
|
119
|
+
metadata: "metadata";
|
|
120
|
+
subject: "subject";
|
|
121
|
+
attachment: "attachment";
|
|
122
|
+
context: "context";
|
|
123
|
+
parent: "parent";
|
|
124
|
+
quoted: "quoted";
|
|
125
|
+
evidence: "evidence";
|
|
126
|
+
policy_context: "policy_context";
|
|
127
|
+
}>;
|
|
128
|
+
language: z.ZodOptional<z.ZodString>;
|
|
129
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
130
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
131
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
133
|
+
type: z.ZodLiteral<"image">;
|
|
134
|
+
asset: z.ZodObject<{
|
|
135
|
+
uploadId: z.ZodOptional<z.ZodString>;
|
|
136
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
137
|
+
mimeType: z.ZodString;
|
|
138
|
+
sha256: z.ZodString;
|
|
139
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
140
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
141
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strict>;
|
|
144
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
role: z.ZodEnum<{
|
|
147
|
+
metadata: "metadata";
|
|
148
|
+
subject: "subject";
|
|
149
|
+
attachment: "attachment";
|
|
150
|
+
context: "context";
|
|
151
|
+
parent: "parent";
|
|
152
|
+
quoted: "quoted";
|
|
153
|
+
evidence: "evidence";
|
|
154
|
+
policy_context: "policy_context";
|
|
155
|
+
}>;
|
|
156
|
+
language: z.ZodOptional<z.ZodString>;
|
|
157
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
158
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
159
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
160
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
161
|
+
type: z.ZodLiteral<"video">;
|
|
162
|
+
asset: z.ZodObject<{
|
|
163
|
+
uploadId: z.ZodOptional<z.ZodString>;
|
|
164
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
165
|
+
mimeType: z.ZodString;
|
|
166
|
+
sha256: z.ZodString;
|
|
167
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
168
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
170
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
171
|
+
}, z.core.$strict>;
|
|
172
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
173
|
+
timeRange: z.ZodOptional<z.ZodObject<{
|
|
174
|
+
startSeconds: z.ZodNumber;
|
|
175
|
+
endSeconds: z.ZodNumber;
|
|
176
|
+
}, z.core.$strict>>;
|
|
177
|
+
}, z.core.$strict>>;
|
|
178
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
179
|
+
id: z.ZodString;
|
|
180
|
+
role: z.ZodEnum<{
|
|
181
|
+
metadata: "metadata";
|
|
182
|
+
subject: "subject";
|
|
183
|
+
attachment: "attachment";
|
|
184
|
+
context: "context";
|
|
185
|
+
parent: "parent";
|
|
186
|
+
quoted: "quoted";
|
|
187
|
+
evidence: "evidence";
|
|
188
|
+
policy_context: "policy_context";
|
|
189
|
+
}>;
|
|
190
|
+
language: z.ZodOptional<z.ZodString>;
|
|
191
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
192
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
193
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
194
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
195
|
+
type: z.ZodLiteral<"audio">;
|
|
196
|
+
asset: z.ZodObject<{
|
|
197
|
+
uploadId: z.ZodOptional<z.ZodString>;
|
|
198
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
199
|
+
mimeType: z.ZodString;
|
|
200
|
+
sha256: z.ZodString;
|
|
201
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
205
|
+
}, z.core.$strict>;
|
|
206
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
207
|
+
transcript: z.ZodOptional<z.ZodString>;
|
|
208
|
+
}, z.core.$strict>>;
|
|
209
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
210
|
+
id: z.ZodString;
|
|
211
|
+
role: z.ZodEnum<{
|
|
212
|
+
metadata: "metadata";
|
|
213
|
+
subject: "subject";
|
|
214
|
+
attachment: "attachment";
|
|
215
|
+
context: "context";
|
|
216
|
+
parent: "parent";
|
|
217
|
+
quoted: "quoted";
|
|
218
|
+
evidence: "evidence";
|
|
219
|
+
policy_context: "policy_context";
|
|
220
|
+
}>;
|
|
221
|
+
language: z.ZodOptional<z.ZodString>;
|
|
222
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
223
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
224
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
225
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
226
|
+
type: z.ZodLiteral<"document">;
|
|
227
|
+
asset: z.ZodObject<{
|
|
228
|
+
uploadId: z.ZodOptional<z.ZodString>;
|
|
229
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
230
|
+
mimeType: z.ZodString;
|
|
231
|
+
sha256: z.ZodString;
|
|
232
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
235
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
}, z.core.$strict>;
|
|
237
|
+
data: z.ZodObject<{
|
|
238
|
+
title: z.ZodString;
|
|
239
|
+
extractedText: z.ZodOptional<z.ZodString>;
|
|
240
|
+
}, z.core.$strict>;
|
|
241
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
242
|
+
id: z.ZodString;
|
|
243
|
+
role: z.ZodEnum<{
|
|
244
|
+
metadata: "metadata";
|
|
245
|
+
subject: "subject";
|
|
246
|
+
attachment: "attachment";
|
|
247
|
+
context: "context";
|
|
248
|
+
parent: "parent";
|
|
249
|
+
quoted: "quoted";
|
|
250
|
+
evidence: "evidence";
|
|
251
|
+
policy_context: "policy_context";
|
|
252
|
+
}>;
|
|
253
|
+
language: z.ZodOptional<z.ZodString>;
|
|
254
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
255
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
256
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
257
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
258
|
+
type: z.ZodLiteral<"link">;
|
|
259
|
+
data: z.ZodObject<{
|
|
260
|
+
url: z.ZodURL;
|
|
261
|
+
title: z.ZodOptional<z.ZodString>;
|
|
262
|
+
resolvedHost: z.ZodOptional<z.ZodString>;
|
|
263
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
264
|
+
}, z.core.$strict>;
|
|
265
|
+
sha256: z.ZodString;
|
|
266
|
+
id: z.ZodString;
|
|
267
|
+
role: z.ZodEnum<{
|
|
268
|
+
metadata: "metadata";
|
|
269
|
+
subject: "subject";
|
|
270
|
+
attachment: "attachment";
|
|
271
|
+
context: "context";
|
|
272
|
+
parent: "parent";
|
|
273
|
+
quoted: "quoted";
|
|
274
|
+
evidence: "evidence";
|
|
275
|
+
policy_context: "policy_context";
|
|
276
|
+
}>;
|
|
277
|
+
language: z.ZodOptional<z.ZodString>;
|
|
278
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
279
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
280
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
281
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
282
|
+
type: z.ZodLiteral<"profile">;
|
|
283
|
+
data: z.ZodObject<{
|
|
284
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
285
|
+
bio: z.ZodOptional<z.ZodString>;
|
|
286
|
+
avatarRef: z.ZodOptional<z.ZodString>;
|
|
287
|
+
claims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
288
|
+
}, z.core.$strict>;
|
|
289
|
+
sha256: z.ZodString;
|
|
290
|
+
id: z.ZodString;
|
|
291
|
+
role: z.ZodEnum<{
|
|
292
|
+
metadata: "metadata";
|
|
293
|
+
subject: "subject";
|
|
294
|
+
attachment: "attachment";
|
|
295
|
+
context: "context";
|
|
296
|
+
parent: "parent";
|
|
297
|
+
quoted: "quoted";
|
|
298
|
+
evidence: "evidence";
|
|
299
|
+
policy_context: "policy_context";
|
|
300
|
+
}>;
|
|
301
|
+
language: z.ZodOptional<z.ZodString>;
|
|
302
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
303
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
304
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
305
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
306
|
+
type: z.ZodLiteral<"conversation">;
|
|
307
|
+
data: z.ZodObject<{
|
|
308
|
+
messageResourceIds: z.ZodArray<z.ZodString>;
|
|
309
|
+
}, z.core.$strict>;
|
|
310
|
+
sha256: z.ZodString;
|
|
311
|
+
id: z.ZodString;
|
|
312
|
+
role: z.ZodEnum<{
|
|
313
|
+
metadata: "metadata";
|
|
314
|
+
subject: "subject";
|
|
315
|
+
attachment: "attachment";
|
|
316
|
+
context: "context";
|
|
317
|
+
parent: "parent";
|
|
318
|
+
quoted: "quoted";
|
|
319
|
+
evidence: "evidence";
|
|
320
|
+
policy_context: "policy_context";
|
|
321
|
+
}>;
|
|
322
|
+
language: z.ZodOptional<z.ZodString>;
|
|
323
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
324
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
325
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
326
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
327
|
+
type: z.ZodLiteral<"listing">;
|
|
328
|
+
data: z.ZodObject<{
|
|
329
|
+
title: z.ZodString;
|
|
330
|
+
description: z.ZodOptional<z.ZodString>;
|
|
331
|
+
price: z.ZodOptional<z.ZodNumber>;
|
|
332
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
333
|
+
sellerRef: z.ZodOptional<z.ZodString>;
|
|
334
|
+
mediaRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
335
|
+
}, z.core.$strict>;
|
|
336
|
+
sha256: z.ZodString;
|
|
337
|
+
id: z.ZodString;
|
|
338
|
+
role: z.ZodEnum<{
|
|
339
|
+
metadata: "metadata";
|
|
340
|
+
subject: "subject";
|
|
341
|
+
attachment: "attachment";
|
|
342
|
+
context: "context";
|
|
343
|
+
parent: "parent";
|
|
344
|
+
quoted: "quoted";
|
|
345
|
+
evidence: "evidence";
|
|
346
|
+
policy_context: "policy_context";
|
|
347
|
+
}>;
|
|
348
|
+
language: z.ZodOptional<z.ZodString>;
|
|
349
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
350
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
351
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
352
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
353
|
+
type: z.ZodLiteral<"location">;
|
|
354
|
+
data: z.ZodObject<{
|
|
355
|
+
label: z.ZodOptional<z.ZodString>;
|
|
356
|
+
latitude: z.ZodOptional<z.ZodNumber>;
|
|
357
|
+
longitude: z.ZodOptional<z.ZodNumber>;
|
|
358
|
+
}, z.core.$strict>;
|
|
359
|
+
sha256: z.ZodString;
|
|
360
|
+
id: z.ZodString;
|
|
361
|
+
role: z.ZodEnum<{
|
|
362
|
+
metadata: "metadata";
|
|
363
|
+
subject: "subject";
|
|
364
|
+
attachment: "attachment";
|
|
365
|
+
context: "context";
|
|
366
|
+
parent: "parent";
|
|
367
|
+
quoted: "quoted";
|
|
368
|
+
evidence: "evidence";
|
|
369
|
+
policy_context: "policy_context";
|
|
370
|
+
}>;
|
|
371
|
+
language: z.ZodOptional<z.ZodString>;
|
|
372
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
373
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
374
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
375
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
376
|
+
type: z.ZodLiteral<"metadata">;
|
|
377
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
378
|
+
sha256: z.ZodString;
|
|
379
|
+
id: z.ZodString;
|
|
380
|
+
role: z.ZodEnum<{
|
|
381
|
+
metadata: "metadata";
|
|
382
|
+
subject: "subject";
|
|
383
|
+
attachment: "attachment";
|
|
384
|
+
context: "context";
|
|
385
|
+
parent: "parent";
|
|
386
|
+
quoted: "quoted";
|
|
387
|
+
evidence: "evidence";
|
|
388
|
+
policy_context: "policy_context";
|
|
389
|
+
}>;
|
|
390
|
+
language: z.ZodOptional<z.ZodString>;
|
|
391
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
392
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
393
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
394
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
395
|
+
type: z.ZodLiteral<"custom">;
|
|
396
|
+
schemaId: z.ZodString;
|
|
397
|
+
payload: z.ZodRecord<z.ZodString, z.ZodType<import("./primitives").CustomPayloadValue, unknown, z.core.$ZodTypeInternals<import("./primitives").CustomPayloadValue, unknown>>>;
|
|
398
|
+
sha256: z.ZodString;
|
|
399
|
+
id: z.ZodString;
|
|
400
|
+
role: z.ZodEnum<{
|
|
401
|
+
metadata: "metadata";
|
|
402
|
+
subject: "subject";
|
|
403
|
+
attachment: "attachment";
|
|
404
|
+
context: "context";
|
|
405
|
+
parent: "parent";
|
|
406
|
+
quoted: "quoted";
|
|
407
|
+
evidence: "evidence";
|
|
408
|
+
policy_context: "policy_context";
|
|
409
|
+
}>;
|
|
410
|
+
language: z.ZodOptional<z.ZodString>;
|
|
411
|
+
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
412
|
+
authorPrincipalRef: z.ZodOptional<z.ZodString>;
|
|
413
|
+
sensitivity: z.ZodOptional<z.ZodString>;
|
|
414
|
+
}, z.core.$strict>], "type">;
|
|
415
|
+
export type Resource = z.infer<typeof ResourceSchema>;
|
|
416
|
+
/** §5.5 relation types. */
|
|
417
|
+
export declare const RELATION_TYPES: readonly ["has_attachment", "replies_to", "quotes", "authored_by", "contextualizes", "previous_version", "contains", "refers_to"];
|
|
418
|
+
export declare const RelationTypeSchema: z.ZodEnum<{
|
|
419
|
+
has_attachment: "has_attachment";
|
|
420
|
+
replies_to: "replies_to";
|
|
421
|
+
quotes: "quotes";
|
|
422
|
+
authored_by: "authored_by";
|
|
423
|
+
contextualizes: "contextualizes";
|
|
424
|
+
previous_version: "previous_version";
|
|
425
|
+
contains: "contains";
|
|
426
|
+
refers_to: "refers_to";
|
|
427
|
+
}>;
|
|
428
|
+
export type RelationType = z.infer<typeof RelationTypeSchema>;
|
|
429
|
+
/**
|
|
430
|
+
* Relation types whose `to` names a principal rather than a resource.
|
|
431
|
+
*
|
|
432
|
+
* §5.5 defines `authored_by` as "a resource was created by a principal", so its
|
|
433
|
+
* target is a `principalRef`. Every other relation in the table joins two
|
|
434
|
+
* resources. No example in the plan exercises `authored_by`, so this reading is
|
|
435
|
+
* recorded here rather than assumed: it is what makes §5.5's "the backend must
|
|
436
|
+
* validate that every referenced id exists in the envelope" checkable at all,
|
|
437
|
+
* since the two id spaces are separate.
|
|
438
|
+
*/
|
|
439
|
+
export declare const PRINCIPAL_TARGETED_RELATION_TYPES: readonly ["authored_by"];
|
|
440
|
+
/**
|
|
441
|
+
* A relation (§5.5).
|
|
442
|
+
*
|
|
443
|
+
* `from` and `to` are only shape-checked here. Whether they RESOLVE is decided
|
|
444
|
+
* by `CaseEnvelopeSchema`, which is the smallest scope that can see both the
|
|
445
|
+
* resource list and the principal list.
|
|
446
|
+
*/
|
|
447
|
+
export declare const RelationSchema: z.ZodObject<{
|
|
448
|
+
from: z.ZodString;
|
|
449
|
+
type: z.ZodEnum<{
|
|
450
|
+
has_attachment: "has_attachment";
|
|
451
|
+
replies_to: "replies_to";
|
|
452
|
+
quotes: "quotes";
|
|
453
|
+
authored_by: "authored_by";
|
|
454
|
+
contextualizes: "contextualizes";
|
|
455
|
+
previous_version: "previous_version";
|
|
456
|
+
contains: "contains";
|
|
457
|
+
refers_to: "refers_to";
|
|
458
|
+
}>;
|
|
459
|
+
to: z.ZodString;
|
|
460
|
+
}, z.core.$strict>;
|
|
461
|
+
export type Relation = z.infer<typeof RelationSchema>;
|
|
462
|
+
/**
|
|
463
|
+
* A custom resource schema an application registers (§5.7).
|
|
464
|
+
*
|
|
465
|
+
* `jsonSchema` reuses the custom-payload grammar, which forbids `$`-prefixed
|
|
466
|
+
* keys. That single restriction removes `$ref`, `$dynamicRef`, `$recursiveRef`
|
|
467
|
+
* and `$id` in one move — every mechanism by which a registered schema could
|
|
468
|
+
* point at a document CrowdSource would then have to fetch. §5.7's "no remote
|
|
469
|
+
* components" is not a rendering rule alone; a remote `$ref` is also an SSRF
|
|
470
|
+
* with a tenant holding the pen.
|
|
471
|
+
*
|
|
472
|
+
* The cost is `$defs`, `$schema` and `$comment`, which flat custom-field
|
|
473
|
+
* schemas do not need. Recursive tenant schemas are not supported and are not
|
|
474
|
+
* meant to be.
|
|
475
|
+
*/
|
|
476
|
+
export declare const ResourceSchemaRegistrationSchema: z.ZodObject<{
|
|
477
|
+
schemaId: z.ZodString;
|
|
478
|
+
version: z.ZodString;
|
|
479
|
+
title: z.ZodString;
|
|
480
|
+
description: z.ZodOptional<z.ZodString>;
|
|
481
|
+
jsonSchema: z.ZodRecord<z.ZodString, z.ZodType<import("./primitives").CustomPayloadValue, unknown, z.core.$ZodTypeInternals<import("./primitives").CustomPayloadValue, unknown>>>;
|
|
482
|
+
}, z.core.$strict>;
|
|
483
|
+
export type ResourceSchemaRegistration = z.infer<typeof ResourceSchemaRegistrationSchema>;
|
|
484
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,aAAmB,CAAC;AACjD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,aAAmB,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,qDAAqD;AACrD,eAAO,MAAM,cAAc,6GASjB,CAAC;AACX,eAAO,MAAM,kBAAkB;;;;;;;;;EAAyB,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,oCAAoC;AACpC,eAAO,MAAM,cAAc,0IAajB,CAAC;AACX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;EAAyB,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,uCAAwC,CAAC;AACtE,eAAO,MAAM,oBAAoB;;;EAA2B,CAAC;AAC7D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;;;;;;;;;kBAqBvB,CAAC;AACL,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAoRtD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAazB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,2BAA2B;AAC3B,eAAO,MAAM,cAAc,mIASjB,CAAC;AACX,eAAO,MAAM,kBAAkB;;;;;;;;;EAAyB,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;;;;;;GASG;AACH,eAAO,MAAM,iCAAiC,0BAA2B,CAAC;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;kBAIzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC;;;;;;kBAM3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
|