@sudobility/screenwriter_types 0.1.1
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/CLAUDE.md +50 -0
- package/README.md +34 -0
- package/dist/account/index.d.ts +440 -0
- package/dist/account/index.js +274 -0
- package/dist/admin/index.d.ts +95 -0
- package/dist/admin/index.js +20 -0
- package/dist/ai/index.d.ts +564 -0
- package/dist/ai/index.js +179 -0
- package/dist/api/envelope.d.ts +33 -0
- package/dist/api/envelope.js +140 -0
- package/dist/api/pagination.d.ts +7 -0
- package/dist/api/pagination.js +9 -0
- package/dist/api/routes.d.ts +273 -0
- package/dist/api/routes.js +306 -0
- package/dist/assets/index.d.ts +722 -0
- package/dist/assets/index.js +452 -0
- package/dist/collab/index.d.ts +214 -0
- package/dist/collab/index.js +211 -0
- package/dist/commands/index.d.ts +92 -0
- package/dist/commands/index.js +20 -0
- package/dist/credits/index.d.ts +26 -0
- package/dist/credits/index.js +7 -0
- package/dist/formats/index.d.ts +87 -0
- package/dist/formats/index.js +26 -0
- package/dist/ids/index.d.ts +2 -0
- package/dist/ids/index.js +2 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +33 -0
- package/dist/io/index.d.ts +395 -0
- package/dist/io/index.js +161 -0
- package/dist/jobs/index.d.ts +278 -0
- package/dist/jobs/index.js +138 -0
- package/dist/keys/index.d.ts +53 -0
- package/dist/keys/index.js +22 -0
- package/dist/lifecycle/index.d.ts +263 -0
- package/dist/lifecycle/index.js +148 -0
- package/dist/me/index.d.ts +35 -0
- package/dist/me/index.js +18 -0
- package/dist/packets/index.d.ts +887 -0
- package/dist/packets/index.js +312 -0
- package/dist/projects/index.d.ts +201 -0
- package/dist/projects/index.js +75 -0
- package/dist/public/index.d.ts +95 -0
- package/dist/public/index.js +25 -0
- package/dist/reads/index.d.ts +387 -0
- package/dist/reads/index.js +118 -0
- package/dist/reports/index.d.ts +168 -0
- package/dist/reports/index.js +466 -0
- package/dist/sharing/index.d.ts +256 -0
- package/dist/sharing/index.js +91 -0
- package/dist/sync/codec.d.ts +7 -0
- package/dist/sync/codec.js +91 -0
- package/dist/sync/index.d.ts +382 -0
- package/dist/sync/index.js +262 -0
- package/dist/sync/permissions.d.ts +22 -0
- package/dist/sync/permissions.js +11 -0
- package/dist/templates/index.d.ts +1699 -0
- package/dist/templates/index.js +70 -0
- package/dist/tenancy/index.d.ts +116 -0
- package/dist/tenancy/index.js +102 -0
- package/dist/test/index.d.ts +8 -0
- package/dist/test/index.js +88 -0
- package/dist/versions/index.d.ts +335 -0
- package/dist/versions/index.js +107 -0
- package/package.json +62 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** `POST /public/purchases/handoff/redeem`: exchanges a handoff token for a Firebase custom token (same uid), so the web page signs in without a password. */
|
|
3
|
+
export const purchaseHandoffRedeemSchema = z.object({
|
|
4
|
+
token: z.string().min(1),
|
|
5
|
+
});
|
|
6
|
+
// ---- Telemetry (spec 05 §6.24) ----
|
|
7
|
+
export const telemetryEventSchema = z.object({
|
|
8
|
+
name: z.string().min(1).max(120),
|
|
9
|
+
ts: z.string(),
|
|
10
|
+
/** Allow-listed, flat properties only: no script text, no free-form nesting. */
|
|
11
|
+
properties: z
|
|
12
|
+
.record(z.string(), z.union([z.string().max(500), z.number(), z.boolean(), z.null()]))
|
|
13
|
+
.optional(),
|
|
14
|
+
});
|
|
15
|
+
export const clientErrorReportSchema = z.object({
|
|
16
|
+
message: z.string().min(1).max(2000),
|
|
17
|
+
stack: z.string().max(8000).optional(),
|
|
18
|
+
context: z
|
|
19
|
+
.record(z.string(), z.union([z.string().max(500), z.number(), z.boolean(), z.null()]))
|
|
20
|
+
.optional(),
|
|
21
|
+
});
|
|
22
|
+
export const telemetryRequestSchema = z.object({
|
|
23
|
+
events: z.array(telemetryEventSchema).max(100),
|
|
24
|
+
errors: z.array(clientErrorReportSchema).max(20).optional(),
|
|
25
|
+
});
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection-backed reads (spec 05 §6.7.1, §6.7.2, §6.12, §6.14, §6.15, §6.17), slice B10.
|
|
3
|
+
* The Y.Doc is canonical; these are the shapes the API returns for entities, tags, notes, beats, the Bin,
|
|
4
|
+
* revisions, tracked changes, alternates, title page, statistics, shots, locators and search.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/** Query encoding of a `SourceRef` (spec 05 §6.7.1): `live`, `snapshot:<snapshotId>` or `version:<versionId>`. */
|
|
8
|
+
export declare const sourceParamSchema: z.ZodString;
|
|
9
|
+
/** JSON-body source on a document route: the document is implied by the route (spec 03 `SourceRef` without `documentId`). */
|
|
10
|
+
export declare const docSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
11
|
+
kind: z.ZodLiteral<"live">;
|
|
12
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
13
|
+
kind: z.ZodLiteral<"snapshot">;
|
|
14
|
+
snapshotId: z.ZodString;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
kind: z.ZodLiteral<"version">;
|
|
17
|
+
versionId: z.ZodString;
|
|
18
|
+
}, z.core.$strip>], "kind">;
|
|
19
|
+
export type DocSource = z.infer<typeof docSourceSchema>;
|
|
20
|
+
export declare const sourceQuerySchema: z.ZodObject<{
|
|
21
|
+
source: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type SourceQuery = z.infer<typeof sourceQuerySchema>;
|
|
24
|
+
export declare function sourceParamOf(ref: DocSource | undefined): string | undefined;
|
|
25
|
+
export declare const entityListQuerySchema: z.ZodObject<{
|
|
26
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
27
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
28
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
29
|
+
q: z.ZodOptional<z.ZodString>;
|
|
30
|
+
source: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type EntityListQuery = z.infer<typeof entityListQuerySchema>;
|
|
33
|
+
export interface EntitySummary {
|
|
34
|
+
id: string;
|
|
35
|
+
kind: string;
|
|
36
|
+
name: string;
|
|
37
|
+
aliases: string[];
|
|
38
|
+
color: string | null;
|
|
39
|
+
sceneCount: number;
|
|
40
|
+
firstSceneId: string | null;
|
|
41
|
+
/** Characters only. */
|
|
42
|
+
dialogueCount?: number;
|
|
43
|
+
}
|
|
44
|
+
/** A character's age or a location's version (spec 01 §5.8.1), read raw from the Y.Doc. */
|
|
45
|
+
export interface EntityVariantSummary {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
ageValue: number | null;
|
|
49
|
+
setting: string | null;
|
|
50
|
+
sortKey: string;
|
|
51
|
+
appearances: {
|
|
52
|
+
id: string;
|
|
53
|
+
label: string;
|
|
54
|
+
}[];
|
|
55
|
+
}
|
|
56
|
+
export interface EntityDetail extends EntitySummary {
|
|
57
|
+
description: string;
|
|
58
|
+
fields: Record<string, unknown>;
|
|
59
|
+
attributes: Record<string, unknown>;
|
|
60
|
+
categoryId: string | null;
|
|
61
|
+
origin: string;
|
|
62
|
+
retain: boolean;
|
|
63
|
+
scenes: {
|
|
64
|
+
id: string;
|
|
65
|
+
number: string | null;
|
|
66
|
+
}[];
|
|
67
|
+
tagsByScene: Record<string, string[]>;
|
|
68
|
+
/** Asset links arrive with slice B11: always empty until then. */
|
|
69
|
+
assetLinks: {
|
|
70
|
+
assetLinkId: string;
|
|
71
|
+
role: string;
|
|
72
|
+
}[];
|
|
73
|
+
contentHash: string;
|
|
74
|
+
variants: EntityVariantSummary[];
|
|
75
|
+
worksheetIds: string[];
|
|
76
|
+
}
|
|
77
|
+
export declare const entityUsageQuerySchema: z.ZodObject<{
|
|
78
|
+
variantId: z.ZodOptional<z.ZodString>;
|
|
79
|
+
source: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export type EntityUsageQuery = z.infer<typeof entityUsageQuerySchema>;
|
|
82
|
+
export interface SceneRef {
|
|
83
|
+
id: string;
|
|
84
|
+
number: string | null;
|
|
85
|
+
heading?: string;
|
|
86
|
+
synopsis?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* What blocks deleting an entity and what the character and location lists show behind *Show usages*
|
|
90
|
+
* (spec 09 F-TAG-017, F-TAG-021). `total` = cues + headings + tags + arcBeats + noteMentions + assetLinks
|
|
91
|
+
* (`sceneLinks` is the informational scene presence and is not counted).
|
|
92
|
+
*/
|
|
93
|
+
export interface EntityUsage {
|
|
94
|
+
total: number;
|
|
95
|
+
cues: {
|
|
96
|
+
elementId: string;
|
|
97
|
+
sceneId: string | null;
|
|
98
|
+
sceneNumber: string | null;
|
|
99
|
+
page: string | null;
|
|
100
|
+
variantId: string | null;
|
|
101
|
+
}[];
|
|
102
|
+
headings: {
|
|
103
|
+
sceneId: string;
|
|
104
|
+
sceneNumber: string | null;
|
|
105
|
+
page: string | null;
|
|
106
|
+
variantId: string | null;
|
|
107
|
+
}[];
|
|
108
|
+
sceneLinks: SceneRef[];
|
|
109
|
+
tags: {
|
|
110
|
+
tagId: string;
|
|
111
|
+
categoryId: string;
|
|
112
|
+
sceneId: string | null;
|
|
113
|
+
}[];
|
|
114
|
+
arcBeats: SceneRef[];
|
|
115
|
+
noteMentions: {
|
|
116
|
+
noteId: string;
|
|
117
|
+
}[];
|
|
118
|
+
assetLinks: {
|
|
119
|
+
assetLinkId: string;
|
|
120
|
+
role: string;
|
|
121
|
+
}[];
|
|
122
|
+
byVariant: Record<string, number>;
|
|
123
|
+
/** Uses (cues for a character, headings for a location) that name no variant. */
|
|
124
|
+
unassigned: number;
|
|
125
|
+
}
|
|
126
|
+
export declare const entityDialogueQuerySchema: z.ZodObject<{
|
|
127
|
+
sceneIds: z.ZodOptional<z.ZodString>;
|
|
128
|
+
source: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
/** Dialogue Tuner view (spec 05 §6.7.1). */
|
|
131
|
+
export interface DialogueSceneView {
|
|
132
|
+
sceneId: string;
|
|
133
|
+
sceneNumber: string | null;
|
|
134
|
+
elements: {
|
|
135
|
+
id: string;
|
|
136
|
+
styleId: string;
|
|
137
|
+
text: string;
|
|
138
|
+
contentHash: string;
|
|
139
|
+
}[];
|
|
140
|
+
}
|
|
141
|
+
export interface TagCategoryRow {
|
|
142
|
+
id: string;
|
|
143
|
+
key: string | null;
|
|
144
|
+
name: string;
|
|
145
|
+
color: string;
|
|
146
|
+
entityKind: string;
|
|
147
|
+
}
|
|
148
|
+
export declare const tagsQuerySchema: z.ZodObject<{
|
|
149
|
+
sceneId: z.ZodOptional<z.ZodString>;
|
|
150
|
+
categoryId: z.ZodOptional<z.ZodString>;
|
|
151
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
152
|
+
source: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
export interface TagRow {
|
|
155
|
+
id: string;
|
|
156
|
+
categoryId: string;
|
|
157
|
+
entityId: string;
|
|
158
|
+
elementId: string;
|
|
159
|
+
range: {
|
|
160
|
+
index: number;
|
|
161
|
+
length: number;
|
|
162
|
+
} | null;
|
|
163
|
+
text: string;
|
|
164
|
+
sceneId: string | null;
|
|
165
|
+
}
|
|
166
|
+
export declare const notesQuerySchema: z.ZodObject<{
|
|
167
|
+
sceneId: z.ZodOptional<z.ZodString>;
|
|
168
|
+
type: z.ZodOptional<z.ZodString>;
|
|
169
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
170
|
+
resolved: "resolved";
|
|
171
|
+
open: "open";
|
|
172
|
+
}>>;
|
|
173
|
+
source: z.ZodOptional<z.ZodString>;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export interface NoteSummary {
|
|
176
|
+
id: string;
|
|
177
|
+
anchor: {
|
|
178
|
+
kind: string;
|
|
179
|
+
elementId?: string;
|
|
180
|
+
beatId?: string;
|
|
181
|
+
};
|
|
182
|
+
sceneId: string | null;
|
|
183
|
+
/** The note type's name (falls back to its id). */
|
|
184
|
+
type: string | null;
|
|
185
|
+
typeId: string | null;
|
|
186
|
+
color: string | null;
|
|
187
|
+
title: string;
|
|
188
|
+
body: string;
|
|
189
|
+
author: string | null;
|
|
190
|
+
createdAt: number | null;
|
|
191
|
+
replies: {
|
|
192
|
+
id: string;
|
|
193
|
+
author: string;
|
|
194
|
+
body: string;
|
|
195
|
+
at: number;
|
|
196
|
+
}[];
|
|
197
|
+
status: 'open' | 'resolved';
|
|
198
|
+
contentHash: string;
|
|
199
|
+
}
|
|
200
|
+
export interface BeatRow {
|
|
201
|
+
id: string;
|
|
202
|
+
title: string;
|
|
203
|
+
body: string;
|
|
204
|
+
color: string | null;
|
|
205
|
+
x: number | null;
|
|
206
|
+
y: number | null;
|
|
207
|
+
links: {
|
|
208
|
+
id: string;
|
|
209
|
+
to: string;
|
|
210
|
+
label: string;
|
|
211
|
+
}[];
|
|
212
|
+
sceneId?: string;
|
|
213
|
+
}
|
|
214
|
+
export interface BinRow {
|
|
215
|
+
id: string;
|
|
216
|
+
title: string;
|
|
217
|
+
preview: string;
|
|
218
|
+
createdAt: number;
|
|
219
|
+
}
|
|
220
|
+
export interface RevisionsView {
|
|
221
|
+
sets: {
|
|
222
|
+
id: string;
|
|
223
|
+
name: string;
|
|
224
|
+
color: string;
|
|
225
|
+
mark: string;
|
|
226
|
+
fullDraft: boolean;
|
|
227
|
+
date: number | null;
|
|
228
|
+
}[];
|
|
229
|
+
activeSetId: string | null;
|
|
230
|
+
revisionMode: boolean;
|
|
231
|
+
trackChanges: boolean;
|
|
232
|
+
}
|
|
233
|
+
export declare const changesQuerySchema: z.ZodObject<{
|
|
234
|
+
authorId: z.ZodOptional<z.ZodString>;
|
|
235
|
+
sceneId: z.ZodOptional<z.ZodString>;
|
|
236
|
+
source: z.ZodOptional<z.ZodString>;
|
|
237
|
+
}, z.core.$strip>;
|
|
238
|
+
export interface ChangeRow {
|
|
239
|
+
id: string;
|
|
240
|
+
kind: 'insert' | 'delete' | 'style' | 'fmt';
|
|
241
|
+
authorId: string;
|
|
242
|
+
at: number;
|
|
243
|
+
elementId: string;
|
|
244
|
+
before: string;
|
|
245
|
+
after: string;
|
|
246
|
+
}
|
|
247
|
+
/** The element's own text is the active alternate (index 0); the inactive ones follow. */
|
|
248
|
+
export interface AlternatesView {
|
|
249
|
+
activeIndex: number;
|
|
250
|
+
alternates: {
|
|
251
|
+
id: string;
|
|
252
|
+
text: string;
|
|
253
|
+
}[];
|
|
254
|
+
}
|
|
255
|
+
export interface TitlePageRead {
|
|
256
|
+
fields: Record<string, string>;
|
|
257
|
+
elements: {
|
|
258
|
+
id: string;
|
|
259
|
+
styleId: string;
|
|
260
|
+
text: string;
|
|
261
|
+
field: string | null;
|
|
262
|
+
}[];
|
|
263
|
+
computed: Record<string, unknown>;
|
|
264
|
+
}
|
|
265
|
+
export interface StatsRead {
|
|
266
|
+
pages: number;
|
|
267
|
+
eighths: number;
|
|
268
|
+
scenes: number;
|
|
269
|
+
words: number;
|
|
270
|
+
elementsByStyle: Record<string, number>;
|
|
271
|
+
estRuntimeMin: number;
|
|
272
|
+
intExt: Record<string, number>;
|
|
273
|
+
dayNight: Record<string, number>;
|
|
274
|
+
dialoguePct: number;
|
|
275
|
+
}
|
|
276
|
+
export interface ShotRow {
|
|
277
|
+
id: string;
|
|
278
|
+
index: number;
|
|
279
|
+
sceneId: string;
|
|
280
|
+
label: string;
|
|
281
|
+
description: string;
|
|
282
|
+
elementRange: {
|
|
283
|
+
startElementId: string;
|
|
284
|
+
endElementId: string;
|
|
285
|
+
} | null;
|
|
286
|
+
camera: Record<string, unknown>;
|
|
287
|
+
estDurationSec: number | null;
|
|
288
|
+
attributes: Record<string, unknown>;
|
|
289
|
+
contentHash: string;
|
|
290
|
+
}
|
|
291
|
+
export declare const fountainQuerySchema: z.ZodObject<{
|
|
292
|
+
sceneIds: z.ZodOptional<z.ZodString>;
|
|
293
|
+
fromSceneId: z.ZodOptional<z.ZodString>;
|
|
294
|
+
source: z.ZodOptional<z.ZodString>;
|
|
295
|
+
}, z.core.$strip>;
|
|
296
|
+
/** `GET /documents/:did/fountain` truncates at this many bytes and sets `X-Next-From-Scene`. */
|
|
297
|
+
export declare const FOUNTAIN_MAX_BYTES = 1000000;
|
|
298
|
+
export declare const LOCATOR_KINDS: readonly ["scene", "element", "shot", "entity", "page"];
|
|
299
|
+
export type LocatorKind = (typeof LOCATOR_KINDS)[number];
|
|
300
|
+
export type ResolveResult = {
|
|
301
|
+
status: 'resolved';
|
|
302
|
+
kind: LocatorKind;
|
|
303
|
+
id: string;
|
|
304
|
+
label: string;
|
|
305
|
+
} | {
|
|
306
|
+
status: 'ambiguous';
|
|
307
|
+
kind: LocatorKind;
|
|
308
|
+
candidates: {
|
|
309
|
+
id: string;
|
|
310
|
+
label: string;
|
|
311
|
+
score: number;
|
|
312
|
+
}[];
|
|
313
|
+
} | {
|
|
314
|
+
status: 'not_found';
|
|
315
|
+
kind: LocatorKind;
|
|
316
|
+
suggestions: {
|
|
317
|
+
id: string;
|
|
318
|
+
label: string;
|
|
319
|
+
}[];
|
|
320
|
+
};
|
|
321
|
+
export declare const RESOLVE_BATCH_MAX = 200;
|
|
322
|
+
export declare const resolveBatchSchema: z.ZodObject<{
|
|
323
|
+
locators: z.ZodArray<z.ZodString>;
|
|
324
|
+
snapshotId: z.ZodOptional<z.ZodString>;
|
|
325
|
+
}, z.core.$strip>;
|
|
326
|
+
export type ResolveBatchRequest = z.infer<typeof resolveBatchSchema>;
|
|
327
|
+
/** `GET /documents/:did/resolve?ref=&snapshotId=`. */
|
|
328
|
+
export declare const resolveOneQuerySchema: z.ZodObject<{
|
|
329
|
+
ref: z.ZodString;
|
|
330
|
+
snapshotId: z.ZodOptional<z.ZodString>;
|
|
331
|
+
}, z.core.$strip>;
|
|
332
|
+
export declare const SEARCH_HIT_TYPES: readonly ["document", "scene", "element", "entity", "note", "asset"];
|
|
333
|
+
export type SearchHitType = (typeof SEARCH_HIT_TYPES)[number];
|
|
334
|
+
export declare const searchQuerySchema: z.ZodObject<{
|
|
335
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
336
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
337
|
+
q: z.ZodString;
|
|
338
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
339
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
340
|
+
documentId: z.ZodOptional<z.ZodString>;
|
|
341
|
+
types: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodEnum<{
|
|
342
|
+
scene: "scene";
|
|
343
|
+
document: "document";
|
|
344
|
+
asset: "asset";
|
|
345
|
+
note: "note";
|
|
346
|
+
element: "element";
|
|
347
|
+
entity: "entity";
|
|
348
|
+
}>>, unknown>>;
|
|
349
|
+
styleIds: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodString>, unknown>>;
|
|
350
|
+
characterId: z.ZodOptional<z.ZodString>;
|
|
351
|
+
language: z.ZodOptional<z.ZodString>;
|
|
352
|
+
}, z.core.$strip>;
|
|
353
|
+
export type SearchQuery = z.infer<typeof searchQuerySchema>;
|
|
354
|
+
/** `GET /documents/:did/search` (in-document find, spec 05 §6.7.1). */
|
|
355
|
+
export declare const documentSearchQuerySchema: z.ZodObject<{
|
|
356
|
+
q: z.ZodString;
|
|
357
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
358
|
+
text: "text";
|
|
359
|
+
regex: "regex";
|
|
360
|
+
}>>;
|
|
361
|
+
styles: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodString>, unknown>>;
|
|
362
|
+
characters: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodString>, unknown>>;
|
|
363
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
364
|
+
source: z.ZodOptional<z.ZodString>;
|
|
365
|
+
}, z.core.$strip>;
|
|
366
|
+
export type DocumentSearchQuery = z.infer<typeof documentSearchQuerySchema>;
|
|
367
|
+
export interface DocumentSearchHit {
|
|
368
|
+
sceneId: string | null;
|
|
369
|
+
sceneNumber: string | null;
|
|
370
|
+
elementId: string;
|
|
371
|
+
styleId: string;
|
|
372
|
+
snippet: string;
|
|
373
|
+
page: string | null;
|
|
374
|
+
}
|
|
375
|
+
export interface SearchHit {
|
|
376
|
+
type: SearchHitType;
|
|
377
|
+
documentId: string | null;
|
|
378
|
+
projectId: string;
|
|
379
|
+
targetId: string;
|
|
380
|
+
title: string;
|
|
381
|
+
/** At most 240 characters; `marks` are `[start, end)` ranges into it (never HTML). */
|
|
382
|
+
snippet: string;
|
|
383
|
+
marks: [number, number][];
|
|
384
|
+
sceneNumber?: string | null;
|
|
385
|
+
pageNumber?: string | null;
|
|
386
|
+
rank: number;
|
|
387
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection-backed reads (spec 05 §6.7.1, §6.7.2, §6.12, §6.14, §6.15, §6.17), slice B10.
|
|
3
|
+
* The Y.Doc is canonical; these are the shapes the API returns for entities, tags, notes, beats, the Bin,
|
|
4
|
+
* revisions, tracked changes, alternates, title page, statistics, shots, locators and search.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { cursorQuerySchema } from '../api/pagination.js';
|
|
8
|
+
// ─── ?source= ───────────────────────────────────────────────────────────────
|
|
9
|
+
/** Query encoding of a `SourceRef` (spec 05 §6.7.1): `live`, `snapshot:<snapshotId>` or `version:<versionId>`. */
|
|
10
|
+
export const sourceParamSchema = z
|
|
11
|
+
.string()
|
|
12
|
+
.regex(/^(live|snapshot:[A-Za-z0-9_-]+|version:[A-Za-z0-9_-]+)$/, 'source must be live, snapshot:<id> or version:<id>');
|
|
13
|
+
/** JSON-body source on a document route: the document is implied by the route (spec 03 `SourceRef` without `documentId`). */
|
|
14
|
+
export const docSourceSchema = z.discriminatedUnion('kind', [
|
|
15
|
+
z.object({ kind: z.literal('live') }),
|
|
16
|
+
z.object({ kind: z.literal('snapshot'), snapshotId: z.string().min(1) }),
|
|
17
|
+
z.object({ kind: z.literal('version'), versionId: z.string().min(1) }),
|
|
18
|
+
]);
|
|
19
|
+
export const sourceQuerySchema = z.object({
|
|
20
|
+
source: sourceParamSchema.optional(),
|
|
21
|
+
});
|
|
22
|
+
export function sourceParamOf(ref) {
|
|
23
|
+
if (!ref || ref.kind === 'live')
|
|
24
|
+
return undefined;
|
|
25
|
+
return ref.kind === 'snapshot'
|
|
26
|
+
? `snapshot:${ref.snapshotId}`
|
|
27
|
+
: `version:${ref.versionId}`;
|
|
28
|
+
}
|
|
29
|
+
// ─── Entities (spec 05 §6.12) ───────────────────────────────────────────────
|
|
30
|
+
export const entityListQuerySchema = cursorQuerySchema.extend({
|
|
31
|
+
kind: z.string().min(1).optional(),
|
|
32
|
+
q: z.string().min(1).max(200).optional(),
|
|
33
|
+
source: sourceParamSchema.optional(),
|
|
34
|
+
});
|
|
35
|
+
export const entityUsageQuerySchema = z.object({
|
|
36
|
+
variantId: z.string().min(1).optional(),
|
|
37
|
+
source: sourceParamSchema.optional(),
|
|
38
|
+
});
|
|
39
|
+
export const entityDialogueQuerySchema = z.object({
|
|
40
|
+
sceneIds: z.string().optional(),
|
|
41
|
+
source: sourceParamSchema.optional(),
|
|
42
|
+
});
|
|
43
|
+
export const tagsQuerySchema = z.object({
|
|
44
|
+
sceneId: z.string().optional(),
|
|
45
|
+
categoryId: z.string().optional(),
|
|
46
|
+
entityId: z.string().optional(),
|
|
47
|
+
source: sourceParamSchema.optional(),
|
|
48
|
+
});
|
|
49
|
+
export const notesQuerySchema = z.object({
|
|
50
|
+
sceneId: z.string().optional(),
|
|
51
|
+
type: z.string().optional(),
|
|
52
|
+
status: z.enum(['open', 'resolved']).optional(),
|
|
53
|
+
source: sourceParamSchema.optional(),
|
|
54
|
+
});
|
|
55
|
+
export const changesQuerySchema = z.object({
|
|
56
|
+
authorId: z.string().optional(),
|
|
57
|
+
sceneId: z.string().optional(),
|
|
58
|
+
source: sourceParamSchema.optional(),
|
|
59
|
+
});
|
|
60
|
+
export const fountainQuerySchema = z.object({
|
|
61
|
+
sceneIds: z.string().optional(),
|
|
62
|
+
fromSceneId: z.string().optional(),
|
|
63
|
+
source: sourceParamSchema.optional(),
|
|
64
|
+
});
|
|
65
|
+
/** `GET /documents/:did/fountain` truncates at this many bytes and sets `X-Next-From-Scene`. */
|
|
66
|
+
export const FOUNTAIN_MAX_BYTES = 1_000_000;
|
|
67
|
+
// ─── Locators (spec 11 §1.3, spec 05 §6.7.2) ────────────────────────────────
|
|
68
|
+
export const LOCATOR_KINDS = [
|
|
69
|
+
'scene',
|
|
70
|
+
'element',
|
|
71
|
+
'shot',
|
|
72
|
+
'entity',
|
|
73
|
+
'page',
|
|
74
|
+
];
|
|
75
|
+
export const RESOLVE_BATCH_MAX = 200;
|
|
76
|
+
export const resolveBatchSchema = z.object({
|
|
77
|
+
locators: z.array(z.string().min(1).max(500)).min(1).max(RESOLVE_BATCH_MAX),
|
|
78
|
+
snapshotId: z.string().min(1).optional(),
|
|
79
|
+
});
|
|
80
|
+
/** `GET /documents/:did/resolve?ref=&snapshotId=`. */
|
|
81
|
+
export const resolveOneQuerySchema = z.object({
|
|
82
|
+
ref: z.string().min(1).max(500),
|
|
83
|
+
snapshotId: z.string().min(1).optional(),
|
|
84
|
+
});
|
|
85
|
+
// ─── Search (spec 05 §6.17) ─────────────────────────────────────────────────
|
|
86
|
+
export const SEARCH_HIT_TYPES = [
|
|
87
|
+
'document',
|
|
88
|
+
'scene',
|
|
89
|
+
'element',
|
|
90
|
+
'entity',
|
|
91
|
+
'note',
|
|
92
|
+
'asset',
|
|
93
|
+
];
|
|
94
|
+
const csv = (v) => typeof v === 'string'
|
|
95
|
+
? v
|
|
96
|
+
.split(',')
|
|
97
|
+
.map((s) => s.trim())
|
|
98
|
+
.filter(Boolean)
|
|
99
|
+
: v;
|
|
100
|
+
export const searchQuerySchema = cursorQuerySchema.extend({
|
|
101
|
+
q: z.string().min(1).max(200),
|
|
102
|
+
workspaceId: z.string().min(1).optional(),
|
|
103
|
+
projectId: z.string().min(1).optional(),
|
|
104
|
+
documentId: z.string().min(1).optional(),
|
|
105
|
+
types: z.preprocess(csv, z.array(z.enum(SEARCH_HIT_TYPES)).min(1)).optional(),
|
|
106
|
+
styleIds: z.preprocess(csv, z.array(z.string()).min(1)).optional(),
|
|
107
|
+
characterId: z.string().min(1).optional(),
|
|
108
|
+
language: z.string().min(2).max(35).optional(),
|
|
109
|
+
});
|
|
110
|
+
/** `GET /documents/:did/search` (in-document find, spec 05 §6.7.1). */
|
|
111
|
+
export const documentSearchQuerySchema = z.object({
|
|
112
|
+
q: z.string().min(1).max(500),
|
|
113
|
+
mode: z.enum(['text', 'regex']).default('text'),
|
|
114
|
+
styles: z.preprocess(csv, z.array(z.string()).min(1)).optional(),
|
|
115
|
+
characters: z.preprocess(csv, z.array(z.string()).min(1)).optional(),
|
|
116
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
117
|
+
source: sourceParamSchema.optional(),
|
|
118
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reports (spec 09 §10 F-RPT-000..018, spec 05 §6.18), slice B10.
|
|
3
|
+
*
|
|
4
|
+
* `REPORT_KINDS` belongs in `writing_core` (spec 09 R25) but Tasks 29-35 have not landed there; until they do the
|
|
5
|
+
* vocabulary, the options and the columns live here so the API, the client and MCP share one declaration.
|
|
6
|
+
* A report is a list of tables; CSV, HTML and PDF are all rendered from those same tables, which is what
|
|
7
|
+
* F-RPT-000's acceptance ("CSV and PDF contain the same rows") rests on.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export declare const REPORT_KINDS: readonly ["scene", "location", "character", "cast", "dialogue", "script", "text", "notes", "synopsis", "revisions", "tags", "statistics", "inclusivity", "presentProgressive", "dayOutOfDays", "shotList", "structure", "characterArcs"];
|
|
11
|
+
export type ReportKind = (typeof REPORT_KINDS)[number];
|
|
12
|
+
export declare const REPORT_FORMATS: readonly ["json", "csv", "pdf", "html"];
|
|
13
|
+
export type ReportFormat = (typeof REPORT_FORMATS)[number];
|
|
14
|
+
/** Documents up to this many pages run a report inline; larger ones answer with a `report.render` job (spec 05 §6.18). */
|
|
15
|
+
export declare const REPORT_SYNC_MAX_PAGES = 200;
|
|
16
|
+
export interface ReportOptionDef {
|
|
17
|
+
name: string;
|
|
18
|
+
type: 'boolean' | 'number' | 'string' | 'enum' | 'stringList';
|
|
19
|
+
default?: boolean | number | string | string[];
|
|
20
|
+
values?: readonly string[];
|
|
21
|
+
min?: number;
|
|
22
|
+
max?: number;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ReportColumn {
|
|
27
|
+
id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
align?: 'left' | 'right';
|
|
30
|
+
}
|
|
31
|
+
export type ReportCell = string | number | null;
|
|
32
|
+
export type ReportRow = Record<string, ReportCell>;
|
|
33
|
+
export interface ReportTable {
|
|
34
|
+
id: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
columns: ReportColumn[];
|
|
37
|
+
rows: ReportRow[];
|
|
38
|
+
/** Optional totals row, rendered last (CSV, HTML and PDF all include it). */
|
|
39
|
+
footer?: ReportRow;
|
|
40
|
+
}
|
|
41
|
+
export interface ReportResult {
|
|
42
|
+
kind: ReportKind;
|
|
43
|
+
title: string;
|
|
44
|
+
documentId: string;
|
|
45
|
+
/** `live`, `snapshot:<id>` or `version:<id>`. */
|
|
46
|
+
source: string;
|
|
47
|
+
options: Record<string, unknown>;
|
|
48
|
+
tables: ReportTable[];
|
|
49
|
+
/** Set when the report does not apply (e.g. present-progressive in a language without the construction). */
|
|
50
|
+
notice?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ReportKindInfo {
|
|
53
|
+
kind: ReportKind;
|
|
54
|
+
featureId: string;
|
|
55
|
+
title: string;
|
|
56
|
+
/** False until the report is built; running it answers 501 `REPORT_KIND_UNAVAILABLE`. */
|
|
57
|
+
available: boolean;
|
|
58
|
+
unavailableReason?: string;
|
|
59
|
+
options: ReportOptionDef[];
|
|
60
|
+
/** Column ids of the main table(s), in order. */
|
|
61
|
+
columns: ReportColumn[];
|
|
62
|
+
formats: readonly ReportFormat[];
|
|
63
|
+
}
|
|
64
|
+
interface ReportDef {
|
|
65
|
+
featureId: string;
|
|
66
|
+
title: string;
|
|
67
|
+
options: ReportOptionDef[];
|
|
68
|
+
columns: ReportColumn[];
|
|
69
|
+
unavailable?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Column and option declarations. The tables a report returns use exactly these column ids. */
|
|
72
|
+
export declare const REPORT_DEFS: Record<ReportKind, ReportDef>;
|
|
73
|
+
export declare function reportKindInfos(): ReportKindInfo[];
|
|
74
|
+
export declare const isReportKind: (v: unknown) => v is ReportKind;
|
|
75
|
+
export type ParsedReportOptions = {
|
|
76
|
+
ok: true;
|
|
77
|
+
options: Record<string, unknown>;
|
|
78
|
+
} | {
|
|
79
|
+
ok: false;
|
|
80
|
+
issues: {
|
|
81
|
+
path: string;
|
|
82
|
+
message: string;
|
|
83
|
+
}[];
|
|
84
|
+
};
|
|
85
|
+
/** Validates and defaults `raw` against the kind's option declarations (unknown keys are refused). */
|
|
86
|
+
export declare function parseReportOptions(kind: ReportKind, raw: unknown): ParsedReportOptions;
|
|
87
|
+
/** `GET /documents/:did/reports/:kind?source=&options=<json>`. */
|
|
88
|
+
export declare const reportGetQuerySchema: z.ZodObject<{
|
|
89
|
+
source: z.ZodOptional<z.ZodString>;
|
|
90
|
+
options: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
export type ReportGetQuery = z.infer<typeof reportGetQuerySchema>;
|
|
93
|
+
/** `POST /documents/:did/reports`. `json` answers the result; the other formats a `report.render` job. */
|
|
94
|
+
export declare const reportCreateSchema: z.ZodObject<{
|
|
95
|
+
kind: z.ZodEnum<{
|
|
96
|
+
scene: "scene";
|
|
97
|
+
script: "script";
|
|
98
|
+
structure: "structure";
|
|
99
|
+
character: "character";
|
|
100
|
+
dialogue: "dialogue";
|
|
101
|
+
text: "text";
|
|
102
|
+
location: "location";
|
|
103
|
+
cast: "cast";
|
|
104
|
+
notes: "notes";
|
|
105
|
+
synopsis: "synopsis";
|
|
106
|
+
revisions: "revisions";
|
|
107
|
+
tags: "tags";
|
|
108
|
+
statistics: "statistics";
|
|
109
|
+
inclusivity: "inclusivity";
|
|
110
|
+
presentProgressive: "presentProgressive";
|
|
111
|
+
dayOutOfDays: "dayOutOfDays";
|
|
112
|
+
shotList: "shotList";
|
|
113
|
+
characterArcs: "characterArcs";
|
|
114
|
+
}>;
|
|
115
|
+
source: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
116
|
+
kind: z.ZodLiteral<"live">;
|
|
117
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
118
|
+
kind: z.ZodLiteral<"snapshot">;
|
|
119
|
+
snapshotId: z.ZodString;
|
|
120
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
121
|
+
kind: z.ZodLiteral<"version">;
|
|
122
|
+
versionId: z.ZodString;
|
|
123
|
+
}, z.core.$strip>], "kind">>;
|
|
124
|
+
options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
125
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
126
|
+
json: "json";
|
|
127
|
+
csv: "csv";
|
|
128
|
+
pdf: "pdf";
|
|
129
|
+
html: "html";
|
|
130
|
+
}>>;
|
|
131
|
+
}, z.core.$strip>;
|
|
132
|
+
export type ReportCreateRequest = z.infer<typeof reportCreateSchema>;
|
|
133
|
+
/** The `input` of a `report.render` job (`sources[0]` is the document). */
|
|
134
|
+
export declare const reportRenderInputSchema: z.ZodObject<{
|
|
135
|
+
kind: z.ZodEnum<{
|
|
136
|
+
scene: "scene";
|
|
137
|
+
script: "script";
|
|
138
|
+
structure: "structure";
|
|
139
|
+
character: "character";
|
|
140
|
+
dialogue: "dialogue";
|
|
141
|
+
text: "text";
|
|
142
|
+
location: "location";
|
|
143
|
+
cast: "cast";
|
|
144
|
+
notes: "notes";
|
|
145
|
+
synopsis: "synopsis";
|
|
146
|
+
revisions: "revisions";
|
|
147
|
+
tags: "tags";
|
|
148
|
+
statistics: "statistics";
|
|
149
|
+
inclusivity: "inclusivity";
|
|
150
|
+
presentProgressive: "presentProgressive";
|
|
151
|
+
dayOutOfDays: "dayOutOfDays";
|
|
152
|
+
shotList: "shotList";
|
|
153
|
+
characterArcs: "characterArcs";
|
|
154
|
+
}>;
|
|
155
|
+
source: z.ZodDefault<z.ZodString>;
|
|
156
|
+
options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
157
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
158
|
+
json: "json";
|
|
159
|
+
csv: "csv";
|
|
160
|
+
pdf: "pdf";
|
|
161
|
+
html: "html";
|
|
162
|
+
}>>;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
export type ReportRenderInput = z.infer<typeof reportRenderInputSchema>;
|
|
165
|
+
export declare const cellText: (v: ReportCell) => string;
|
|
166
|
+
/** CSV of every table (a title line and a blank line between tables when there is more than one). RFC 4180 quoting, CRLF. */
|
|
167
|
+
export declare function reportToCsv(result: Pick<ReportResult, 'tables'>): string;
|
|
168
|
+
export {};
|