@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,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collaboration DTOs (spec 05 §6.15 notes/mentions/chat/activity, §6.16 notifications, §6.24 devices/push,
|
|
3
|
+
* §6.26 `writingReminder` prefs; slice B12). Tables: `note_mentions`, `document_chat_messages`, `activity_events`,
|
|
4
|
+
* `notifications`, `devices`.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { cursorQuerySchema } from '../api/pagination.js';
|
|
8
|
+
// ─── Notification kinds and prefs (§6.16, §6.26) ────────────────────────────
|
|
9
|
+
export const NOTIFICATION_KINDS = [
|
|
10
|
+
'mention',
|
|
11
|
+
'note_reply',
|
|
12
|
+
'note_on_my_document',
|
|
13
|
+
'snapshot_comment',
|
|
14
|
+
'chat_mention',
|
|
15
|
+
'invitation',
|
|
16
|
+
'share_granted',
|
|
17
|
+
'snapshot_opened_by_collaborator',
|
|
18
|
+
'job_finished',
|
|
19
|
+
'job_failed',
|
|
20
|
+
'ai_suggestions_ready',
|
|
21
|
+
'ai_refunded',
|
|
22
|
+
'export_ready',
|
|
23
|
+
'watermark_batch_sent',
|
|
24
|
+
'writing_reminder',
|
|
25
|
+
'credits_low',
|
|
26
|
+
'purchase_completed',
|
|
27
|
+
'account_deletion_scheduled',
|
|
28
|
+
];
|
|
29
|
+
export const NOTIFICATION_EMAIL_MODES = ['immediate', 'digest', 'off'];
|
|
30
|
+
/** Kinds that default to an immediate email (the rest default to `digest` or `off`; see `defaultNotificationKindPrefs`). */
|
|
31
|
+
const DEFAULT_IMMEDIATE_EMAIL = new Set([
|
|
32
|
+
'mention',
|
|
33
|
+
'note_reply',
|
|
34
|
+
'chat_mention',
|
|
35
|
+
'invitation',
|
|
36
|
+
'share_granted',
|
|
37
|
+
'job_failed',
|
|
38
|
+
'export_ready',
|
|
39
|
+
'watermark_batch_sent',
|
|
40
|
+
'credits_low',
|
|
41
|
+
'purchase_completed',
|
|
42
|
+
'account_deletion_scheduled',
|
|
43
|
+
]);
|
|
44
|
+
const DEFAULT_DIGEST_EMAIL = new Set([
|
|
45
|
+
'snapshot_comment',
|
|
46
|
+
'note_on_my_document',
|
|
47
|
+
'ai_suggestions_ready',
|
|
48
|
+
'ai_refunded',
|
|
49
|
+
'snapshot_opened_by_collaborator',
|
|
50
|
+
]);
|
|
51
|
+
/** Kinds a person is not plausibly interrupted for, off by default: no email, no push. */
|
|
52
|
+
const DEFAULT_QUIET = new Set([
|
|
53
|
+
'job_finished',
|
|
54
|
+
'writing_reminder',
|
|
55
|
+
]);
|
|
56
|
+
/** Every kind gets a sane default; a person may override any of `inApp`/`push`/`email` per kind. */
|
|
57
|
+
export function defaultNotificationKindPrefs(kind) {
|
|
58
|
+
const email = DEFAULT_IMMEDIATE_EMAIL.has(kind)
|
|
59
|
+
? 'immediate'
|
|
60
|
+
: DEFAULT_DIGEST_EMAIL.has(kind)
|
|
61
|
+
? 'digest'
|
|
62
|
+
: 'off';
|
|
63
|
+
return { inApp: true, push: !DEFAULT_QUIET.has(kind), email };
|
|
64
|
+
}
|
|
65
|
+
export function defaultNotificationPrefs() {
|
|
66
|
+
return {
|
|
67
|
+
kinds: Object.fromEntries(NOTIFICATION_KINDS.map((k) => [k, defaultNotificationKindPrefs(k)])),
|
|
68
|
+
writingReminderTime: null,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const notificationKindPrefsPatchSchema = z.object({
|
|
72
|
+
inApp: z.boolean().optional(),
|
|
73
|
+
push: z.boolean().optional(),
|
|
74
|
+
email: z.enum(NOTIFICATION_EMAIL_MODES).optional(),
|
|
75
|
+
});
|
|
76
|
+
const HHMM_RE = /^([01]\d|2[0-3]):[0-5]\d$/;
|
|
77
|
+
/** `PUT /me/notification-prefs`: a sparse per-kind patch (only the kinds/fields given change) plus the reminder time. */
|
|
78
|
+
export const notificationPrefsSchema = z.object({
|
|
79
|
+
kinds: z
|
|
80
|
+
.record(z.string(), notificationKindPrefsPatchSchema)
|
|
81
|
+
.refine((obj) => Object.keys(obj).every((k) => NOTIFICATION_KINDS.includes(k)), {
|
|
82
|
+
message: 'unknown notification kind',
|
|
83
|
+
})
|
|
84
|
+
.optional(),
|
|
85
|
+
writingReminderTime: z
|
|
86
|
+
.string()
|
|
87
|
+
.regex(HHMM_RE, 'writingReminderTime must be HH:MM (24h, local)')
|
|
88
|
+
.nullable()
|
|
89
|
+
.optional(),
|
|
90
|
+
});
|
|
91
|
+
/** `{...current, ...update}` per kind (a patch's fields win); `writingReminderTime` replaces whole. */
|
|
92
|
+
export function mergeNotificationPrefs(current, update) {
|
|
93
|
+
const kinds = { ...current.kinds };
|
|
94
|
+
for (const [k, patch] of Object.entries(update.kinds ?? {})) {
|
|
95
|
+
const kind = k;
|
|
96
|
+
kinds[kind] = {
|
|
97
|
+
...(kinds[kind] ?? defaultNotificationKindPrefs(kind)),
|
|
98
|
+
...patch,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
kinds,
|
|
103
|
+
writingReminderTime: update.writingReminderTime === undefined
|
|
104
|
+
? current.writingReminderTime
|
|
105
|
+
: update.writingReminderTime,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const boolQuery = z.enum(['true', 'false']).transform((v) => v === 'true');
|
|
109
|
+
export const notificationsQuerySchema = cursorQuerySchema.extend({
|
|
110
|
+
unread: boolQuery.optional(),
|
|
111
|
+
});
|
|
112
|
+
export const notificationsReadSchema = z
|
|
113
|
+
.object({
|
|
114
|
+
ids: z.array(z.string().min(1)).max(200).optional(),
|
|
115
|
+
all: z.literal(true).optional(),
|
|
116
|
+
before: z.iso.datetime({ offset: true }).optional(),
|
|
117
|
+
})
|
|
118
|
+
.refine((v) => v.ids !== undefined || v.all !== undefined || v.before !== undefined, {
|
|
119
|
+
message: 'one of ids, all or before is required',
|
|
120
|
+
});
|
|
121
|
+
// ─── Chat (§6.15, §8.7 `document_chat_messages`) ────────────────────────────
|
|
122
|
+
export const CHAT_BODY_MAX = 4000;
|
|
123
|
+
export const CHAT_EDIT_WINDOW_MINUTES = 15;
|
|
124
|
+
/** Y.Doc notes use plain `mentions: string[]` (user ids, no offset/length: writing_core's simplification); chat mirrors it in the DTO for consistency with the spec's shape, offset/length optional. */
|
|
125
|
+
export const mentionRefSchema = z.object({
|
|
126
|
+
userId: z.string().min(1),
|
|
127
|
+
offset: z.number().int().min(0).optional(),
|
|
128
|
+
length: z.number().int().min(1).optional(),
|
|
129
|
+
});
|
|
130
|
+
export const chatMessageCreateSchema = z.object({
|
|
131
|
+
clientMessageId: z
|
|
132
|
+
.string()
|
|
133
|
+
.min(8)
|
|
134
|
+
.max(64)
|
|
135
|
+
.regex(/^msg_[0-9A-Za-z]+$/, 'clientMessageId must be a msg_ prefixed id'),
|
|
136
|
+
body: z.string().trim().min(1).max(CHAT_BODY_MAX),
|
|
137
|
+
mentions: z.array(mentionRefSchema).max(50).optional(),
|
|
138
|
+
});
|
|
139
|
+
export const chatMessageUpdateSchema = z.object({
|
|
140
|
+
body: z.string().trim().min(1).max(CHAT_BODY_MAX),
|
|
141
|
+
});
|
|
142
|
+
export const chatQuerySchema = cursorQuerySchema.extend({
|
|
143
|
+
before: z.iso.datetime({ offset: true }).optional(),
|
|
144
|
+
});
|
|
145
|
+
// ─── Activity (§6.15, §8.7 `activity_events`) ───────────────────────────────
|
|
146
|
+
export const ACTIVITY_KINDS = [
|
|
147
|
+
'document.created',
|
|
148
|
+
'document.renamed',
|
|
149
|
+
'document.moved',
|
|
150
|
+
'document.trashed',
|
|
151
|
+
'document.restored',
|
|
152
|
+
'session.edited',
|
|
153
|
+
'snapshot.created',
|
|
154
|
+
'snapshot.opened',
|
|
155
|
+
'snapshot.forked',
|
|
156
|
+
'version.restored',
|
|
157
|
+
'template.applied',
|
|
158
|
+
'import.over',
|
|
159
|
+
'revision.setCreated',
|
|
160
|
+
'locks.changed',
|
|
161
|
+
'changes.decided',
|
|
162
|
+
'ai.jobCompleted',
|
|
163
|
+
'ai.suggestionsDecided',
|
|
164
|
+
'share.granted',
|
|
165
|
+
'share.linkCreated',
|
|
166
|
+
'member.joined',
|
|
167
|
+
'member.left',
|
|
168
|
+
'mcp.commandsApplied',
|
|
169
|
+
];
|
|
170
|
+
export const ACTOR_KINDS = ['user', 'mcp', 'api', 'ai', 'system'];
|
|
171
|
+
const csvList = (v) => typeof v === 'string'
|
|
172
|
+
? v
|
|
173
|
+
.split(',')
|
|
174
|
+
.map((s) => s.trim())
|
|
175
|
+
.filter(Boolean)
|
|
176
|
+
: v;
|
|
177
|
+
export const activityQuerySchema = cursorQuerySchema.extend({
|
|
178
|
+
kinds: z.preprocess(csvList, z.array(z.string())).optional(),
|
|
179
|
+
});
|
|
180
|
+
export const workspaceActivityQuerySchema = cursorQuerySchema.extend({
|
|
181
|
+
projectId: z.string().min(1).optional(),
|
|
182
|
+
});
|
|
183
|
+
// ─── Devices, push tokens (§6.24) ────────────────────────────────────────────
|
|
184
|
+
export const DEVICE_PLATFORMS = [
|
|
185
|
+
'web',
|
|
186
|
+
'ios',
|
|
187
|
+
'ipados',
|
|
188
|
+
'android',
|
|
189
|
+
'macos',
|
|
190
|
+
'windows',
|
|
191
|
+
];
|
|
192
|
+
export const PUSH_PLATFORMS = ['apns', 'fcm', 'wns', 'webpush'];
|
|
193
|
+
export const deviceCreateSchema = z.object({
|
|
194
|
+
id: z
|
|
195
|
+
.string()
|
|
196
|
+
.min(8)
|
|
197
|
+
.max(64)
|
|
198
|
+
.regex(/^dev_[0-9A-Za-z]+$/, 'id must be a dev_ prefixed id'),
|
|
199
|
+
installId: z.string().min(1).max(128),
|
|
200
|
+
displayName: z.string().trim().min(1).max(80),
|
|
201
|
+
platform: z.enum(DEVICE_PLATFORMS),
|
|
202
|
+
appVersion: z.string().min(1).max(40),
|
|
203
|
+
});
|
|
204
|
+
export const deviceUpdateSchema = z.object({
|
|
205
|
+
displayName: z.string().trim().min(1).max(80),
|
|
206
|
+
});
|
|
207
|
+
export const pushTokenSetSchema = z.object({
|
|
208
|
+
platform: z.enum(PUSH_PLATFORMS),
|
|
209
|
+
token: z.string().min(1).max(4096),
|
|
210
|
+
environment: z.enum(['production', 'sandbox']).optional(),
|
|
211
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A writing_core command as plain JSON. The command bodies are typed by
|
|
4
|
+
* writing_core; here they are opaque records until the API validates them.
|
|
5
|
+
*/
|
|
6
|
+
export type WritingCommandJson = Record<string, unknown>;
|
|
7
|
+
export declare const COMMAND_BATCH_MAX = 500;
|
|
8
|
+
export declare const commandBatchRequestSchema: z.ZodObject<{
|
|
9
|
+
commands: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
+
baseEpoch: z.ZodNumber;
|
|
11
|
+
expectedHashes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type CommandBatchRequest = z.infer<typeof commandBatchRequestSchema>;
|
|
15
|
+
export interface CommandWarning {
|
|
16
|
+
index: number;
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CommandEffects {
|
|
21
|
+
/** Elements the batch created, changed and removed (sorted ids). */
|
|
22
|
+
createdIds: string[];
|
|
23
|
+
changedIds: string[];
|
|
24
|
+
deletedIds: string[];
|
|
25
|
+
/** Fresh content hashes (spec 11 4.2) of every created or changed element. */
|
|
26
|
+
newHashes: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `POST /documents/:did/commands` response (thin B5 version). A `dryRun` returns the same shape
|
|
30
|
+
* with `applied: 0` and `dryRun: true`: the effects the batch WOULD have, nothing changed.
|
|
31
|
+
* `expectedHashes` keys are element or scene ids; a mismatch is 409 `CONTENT_CHANGED` with
|
|
32
|
+
* `details.ids`.
|
|
33
|
+
*/
|
|
34
|
+
export interface CommandBatchResponse {
|
|
35
|
+
applied: number;
|
|
36
|
+
epoch: number;
|
|
37
|
+
dryRun?: boolean;
|
|
38
|
+
effects: CommandEffects;
|
|
39
|
+
warnings: CommandWarning[];
|
|
40
|
+
}
|
|
41
|
+
/** `COMMAND_INVALID` (422) `details`. `reason` is a writing_core ReasonCode (or `exception`). */
|
|
42
|
+
export interface CommandInvalidDetails {
|
|
43
|
+
index: number;
|
|
44
|
+
reason: string;
|
|
45
|
+
detail?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
export declare const SCENE_BATCH_MAX = 20;
|
|
48
|
+
export declare const ELEMENT_BATCH_MAX = 500;
|
|
49
|
+
export interface OutlineScene {
|
|
50
|
+
id: string;
|
|
51
|
+
/** Formatted scene number label, or null when unnumbered. */
|
|
52
|
+
number: string | null;
|
|
53
|
+
heading: string;
|
|
54
|
+
omitted: boolean;
|
|
55
|
+
synopsis: string;
|
|
56
|
+
elementCount: number;
|
|
57
|
+
contentHash: string;
|
|
58
|
+
}
|
|
59
|
+
export interface OutlineResponse {
|
|
60
|
+
scenes: OutlineScene[];
|
|
61
|
+
}
|
|
62
|
+
export interface ElementRead {
|
|
63
|
+
id: string;
|
|
64
|
+
styleId: string;
|
|
65
|
+
styleName: string;
|
|
66
|
+
/** The style's role (`sceneHeading`, `action`, `character`, `dialogue`, ...), for callers that must not guess from names. */
|
|
67
|
+
styleRole?: string;
|
|
68
|
+
text: string;
|
|
69
|
+
contentHash: string;
|
|
70
|
+
}
|
|
71
|
+
export interface SceneRead {
|
|
72
|
+
id: string;
|
|
73
|
+
number: string | null;
|
|
74
|
+
heading: string;
|
|
75
|
+
synopsis: string;
|
|
76
|
+
contentHash: string;
|
|
77
|
+
elements: ElementRead[];
|
|
78
|
+
}
|
|
79
|
+
export declare const elementsBatchRequestSchema: z.ZodObject<{
|
|
80
|
+
elementIds: z.ZodArray<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export type ElementsBatchRequest = z.infer<typeof elementsBatchRequestSchema>;
|
|
83
|
+
export interface ElementsBatchResponse {
|
|
84
|
+
elements: ElementRead[];
|
|
85
|
+
}
|
|
86
|
+
export declare const scenesBatchRequestSchema: z.ZodObject<{
|
|
87
|
+
sceneIds: z.ZodArray<z.ZodString>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
export type ScenesBatchRequest = z.infer<typeof scenesBatchRequestSchema>;
|
|
90
|
+
export interface ScenesBatchResponse {
|
|
91
|
+
scenes: SceneRead[];
|
|
92
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const COMMAND_BATCH_MAX = 500;
|
|
3
|
+
export const commandBatchRequestSchema = z.object({
|
|
4
|
+
commands: z
|
|
5
|
+
.array(z.record(z.string(), z.unknown()))
|
|
6
|
+
.min(1)
|
|
7
|
+
.max(COMMAND_BATCH_MAX),
|
|
8
|
+
baseEpoch: z.number().int().min(0),
|
|
9
|
+
expectedHashes: z.record(z.string(), z.string()).optional(),
|
|
10
|
+
dryRun: z.boolean().optional(),
|
|
11
|
+
});
|
|
12
|
+
// ---- Scene and element reads (spec 05 6.7.1, live document) ----
|
|
13
|
+
export const SCENE_BATCH_MAX = 20;
|
|
14
|
+
export const ELEMENT_BATCH_MAX = 500;
|
|
15
|
+
export const elementsBatchRequestSchema = z.object({
|
|
16
|
+
elementIds: z.array(z.string().min(1)).min(1).max(ELEMENT_BATCH_MAX),
|
|
17
|
+
});
|
|
18
|
+
export const scenesBatchRequestSchema = z.object({
|
|
19
|
+
sceneIds: z.array(z.string().min(1)).min(1).max(SCENE_BATCH_MAX),
|
|
20
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Credits (spec 05 §6.20, spec 06 §10): a thin re-export of `@sudobility/types`' generic consumables
|
|
4
|
+
* shapes, plus the two things specific to Fadewright — the priced product catalog and the purchase
|
|
5
|
+
* handoff for platforms that cannot buy in-app (spec 05 §6.21).
|
|
6
|
+
*
|
|
7
|
+
* The ledger itself (`consumable_balances/_purchases/_usages`) is `@sudobility/consumables_service`'s,
|
|
8
|
+
* called in-process from `screenwriter_api` exactly as `music_api` does; this module never redefines it.
|
|
9
|
+
*/
|
|
10
|
+
export type { ConsumableBalanceResponse, ConsumablePurchaseRecord, ConsumablePurchaseRequest, ConsumableSource, ConsumableUsageRecord, ConsumableUseRequest, ConsumableUseResponse, } from '@sudobility/types';
|
|
11
|
+
export declare const CONSUMABLE_SOURCES: readonly ["web", "apple", "google", "free"];
|
|
12
|
+
/** `GET /consumables/products`: the priced catalog (`CREDIT_PRODUCTS`, spec 06 §10.1). */
|
|
13
|
+
export interface CreditProduct {
|
|
14
|
+
productId: string;
|
|
15
|
+
credits: number;
|
|
16
|
+
}
|
|
17
|
+
/** `POST /purchases/handoff` (spec 05 §6.21): lets a platform with no in-app purchase (Windows) send the user to the web to buy. */
|
|
18
|
+
export declare const purchaseHandoffRequestSchema: z.ZodObject<{
|
|
19
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
20
|
+
returnTo: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type PurchaseHandoffRequest = z.infer<typeof purchaseHandoffRequestSchema>;
|
|
23
|
+
export interface PurchaseHandoffResponse {
|
|
24
|
+
handoffUrl: string;
|
|
25
|
+
expiresAt: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CONSUMABLE_SOURCES = ['web', 'apple', 'google', 'free'];
|
|
3
|
+
/** `POST /purchases/handoff` (spec 05 §6.21): lets a platform with no in-app purchase (Windows) send the user to the web to buy. */
|
|
4
|
+
export const purchaseHandoffRequestSchema = z.object({
|
|
5
|
+
productId: z.string().optional(),
|
|
6
|
+
returnTo: z.string().min(1).max(2000),
|
|
7
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DocumentMeta } from '../projects/index.js';
|
|
3
|
+
/** Import and export over HTTP (synchronous; spec 05 §6.18 minus the job framework). */
|
|
4
|
+
/** Formats the server can import: ids of `writing_formats`. */
|
|
5
|
+
export declare const IMPORT_FORMAT_IDS: readonly ["fountain", "fdx", "fadein"];
|
|
6
|
+
export declare const EXPORT_FORMAT_IDS: readonly ["fountain", "fdx", "json"];
|
|
7
|
+
export type ExportFormatId = (typeof EXPORT_FORMAT_IDS)[number];
|
|
8
|
+
/** Default `IMPORT_MAX_BYTES`: 100 MiB of decoded file bytes. */
|
|
9
|
+
export declare const IMPORT_MAX_BYTES_DEFAULT: number;
|
|
10
|
+
/** Mirror of `writing_formats` `Diagnostic` (this package cannot depend on it). */
|
|
11
|
+
export interface ConversionDiagnostic {
|
|
12
|
+
code: string;
|
|
13
|
+
severity: 'info' | 'warn' | 'loss' | 'error';
|
|
14
|
+
message: string;
|
|
15
|
+
feature: string;
|
|
16
|
+
count: number;
|
|
17
|
+
locations?: {
|
|
18
|
+
elementIndex?: number;
|
|
19
|
+
sourceLine?: number;
|
|
20
|
+
sourcePath?: string;
|
|
21
|
+
}[];
|
|
22
|
+
}
|
|
23
|
+
/** Mirror of `writing_formats` `ConversionReport` (spec 04 §3.1). */
|
|
24
|
+
export interface ConversionReport {
|
|
25
|
+
direction: 'import' | 'export';
|
|
26
|
+
format: string;
|
|
27
|
+
sourceVersion?: string;
|
|
28
|
+
diagnostics: ConversionDiagnostic[];
|
|
29
|
+
stats: {
|
|
30
|
+
elements: number;
|
|
31
|
+
scenes: number;
|
|
32
|
+
pages?: number;
|
|
33
|
+
durationMs: number;
|
|
34
|
+
};
|
|
35
|
+
confidence?: number;
|
|
36
|
+
summary: {
|
|
37
|
+
info: number;
|
|
38
|
+
warn: number;
|
|
39
|
+
loss: number;
|
|
40
|
+
error: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** `POST /projects/:pid/documents/import` (idempotent on `id`, like document create). */
|
|
44
|
+
export declare const documentImportSchema: z.ZodObject<{
|
|
45
|
+
id: z.ZodOptional<z.ZodString>;
|
|
46
|
+
filename: z.ZodString;
|
|
47
|
+
contentB64: z.ZodString;
|
|
48
|
+
title: z.ZodOptional<z.ZodString>;
|
|
49
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
outline: "outline";
|
|
51
|
+
script: "script";
|
|
52
|
+
bible: "bible";
|
|
53
|
+
treatment: "treatment";
|
|
54
|
+
other: "other";
|
|
55
|
+
}>>;
|
|
56
|
+
templateId: z.ZodOptional<z.ZodString>;
|
|
57
|
+
language: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export type DocumentImportRequest = z.infer<typeof documentImportSchema>;
|
|
60
|
+
export interface DocumentImportResult {
|
|
61
|
+
document: DocumentMeta;
|
|
62
|
+
report: ConversionReport;
|
|
63
|
+
/** Detected source format id. */
|
|
64
|
+
format: string;
|
|
65
|
+
}
|
|
66
|
+
/** `POST /documents/:did/export` */
|
|
67
|
+
export declare const documentExportSchema: z.ZodObject<{
|
|
68
|
+
format: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type DocumentExportRequest = {
|
|
71
|
+
format: ExportFormatId;
|
|
72
|
+
};
|
|
73
|
+
export interface DocumentExportResult {
|
|
74
|
+
filename: string;
|
|
75
|
+
mimeType: string;
|
|
76
|
+
contentB64: string;
|
|
77
|
+
report: ConversionReport;
|
|
78
|
+
format: ExportFormatId;
|
|
79
|
+
}
|
|
80
|
+
/** `GET /formats` */
|
|
81
|
+
export interface FormatInfo {
|
|
82
|
+
id: string;
|
|
83
|
+
label: string;
|
|
84
|
+
extensions: string[];
|
|
85
|
+
canImport: boolean;
|
|
86
|
+
canExport: boolean;
|
|
87
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { documentKindSchema } from '../projects/index.js';
|
|
3
|
+
/** Import and export over HTTP (synchronous; spec 05 §6.18 minus the job framework). */
|
|
4
|
+
/** Formats the server can import: ids of `writing_formats`. */
|
|
5
|
+
export const IMPORT_FORMAT_IDS = ['fountain', 'fdx', 'fadein'];
|
|
6
|
+
export const EXPORT_FORMAT_IDS = ['fountain', 'fdx', 'json'];
|
|
7
|
+
/** Default `IMPORT_MAX_BYTES`: 100 MiB of decoded file bytes. */
|
|
8
|
+
export const IMPORT_MAX_BYTES_DEFAULT = 100 * 1024 * 1024;
|
|
9
|
+
/** `POST /projects/:pid/documents/import` (idempotent on `id`, like document create). */
|
|
10
|
+
export const documentImportSchema = z.object({
|
|
11
|
+
/** Client-generated `doc_...`; import is idempotent on it. */
|
|
12
|
+
id: z.string().startsWith('doc_').optional(),
|
|
13
|
+
/** Only a hint: the format is detected from the content. */
|
|
14
|
+
filename: z.string().min(1).max(500),
|
|
15
|
+
/** Base64 of the file bytes. */
|
|
16
|
+
contentB64: z.string(),
|
|
17
|
+
/** Defaults to the file's title page title, then the filename. */
|
|
18
|
+
title: z.string().trim().min(1).max(200).optional(),
|
|
19
|
+
kind: documentKindSchema.optional(),
|
|
20
|
+
templateId: z.string().optional(),
|
|
21
|
+
language: z.string().max(16).optional(),
|
|
22
|
+
});
|
|
23
|
+
/** `POST /documents/:did/export` */
|
|
24
|
+
export const documentExportSchema = z.object({
|
|
25
|
+
format: z.string().min(1).max(32),
|
|
26
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sudobility/screenwriter_types
|
|
3
|
+
* Shared types and Zod schemas for the Fadewright frontend and backend.
|
|
4
|
+
* Import from the package root only.
|
|
5
|
+
*/
|
|
6
|
+
export * from './api/envelope.js';
|
|
7
|
+
export * from './api/pagination.js';
|
|
8
|
+
export * from './api/routes.js';
|
|
9
|
+
export * from './ids/index.js';
|
|
10
|
+
export * from './tenancy/index.js';
|
|
11
|
+
export * from './sharing/index.js';
|
|
12
|
+
export * from './projects/index.js';
|
|
13
|
+
export * from './lifecycle/index.js';
|
|
14
|
+
export * from './me/index.js';
|
|
15
|
+
export * from './account/index.js';
|
|
16
|
+
export * from './templates/index.js';
|
|
17
|
+
export * from './versions/index.js';
|
|
18
|
+
export * from './commands/index.js';
|
|
19
|
+
export * from './formats/index.js';
|
|
20
|
+
export * from './io/index.js';
|
|
21
|
+
export * from './keys/index.js';
|
|
22
|
+
export * from './ai/index.js';
|
|
23
|
+
export * from './jobs/index.js';
|
|
24
|
+
export * from './reads/index.js';
|
|
25
|
+
export * from './reports/index.js';
|
|
26
|
+
export * from './packets/index.js';
|
|
27
|
+
export * from './assets/index.js';
|
|
28
|
+
export * from './collab/index.js';
|
|
29
|
+
export * from './credits/index.js';
|
|
30
|
+
export * from './public/index.js';
|
|
31
|
+
export * from './admin/index.js';
|
|
32
|
+
export * from './sync/index.js';
|
|
33
|
+
export * from './sync/codec.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sudobility/screenwriter_types
|
|
3
|
+
* Shared types and Zod schemas for the Fadewright frontend and backend.
|
|
4
|
+
* Import from the package root only.
|
|
5
|
+
*/
|
|
6
|
+
export * from './api/envelope.js';
|
|
7
|
+
export * from './api/pagination.js';
|
|
8
|
+
export * from './api/routes.js';
|
|
9
|
+
export * from './ids/index.js';
|
|
10
|
+
export * from './tenancy/index.js';
|
|
11
|
+
export * from './sharing/index.js';
|
|
12
|
+
export * from './projects/index.js';
|
|
13
|
+
export * from './lifecycle/index.js';
|
|
14
|
+
export * from './me/index.js';
|
|
15
|
+
export * from './account/index.js';
|
|
16
|
+
export * from './templates/index.js';
|
|
17
|
+
export * from './versions/index.js';
|
|
18
|
+
export * from './commands/index.js';
|
|
19
|
+
export * from './formats/index.js';
|
|
20
|
+
export * from './io/index.js';
|
|
21
|
+
export * from './keys/index.js';
|
|
22
|
+
export * from './ai/index.js';
|
|
23
|
+
export * from './jobs/index.js';
|
|
24
|
+
export * from './reads/index.js';
|
|
25
|
+
export * from './reports/index.js';
|
|
26
|
+
export * from './packets/index.js';
|
|
27
|
+
export * from './assets/index.js';
|
|
28
|
+
export * from './collab/index.js';
|
|
29
|
+
export * from './credits/index.js';
|
|
30
|
+
export * from './public/index.js';
|
|
31
|
+
export * from './admin/index.js';
|
|
32
|
+
export * from './sync/index.js';
|
|
33
|
+
export * from './sync/codec.js';
|