@sudobility/screenwriter_types 0.1.1 → 0.1.2
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/dist/admin/index.d.ts +1 -1
- package/dist/index.js +4386 -33
- package/dist/index.js.map +1 -0
- package/dist/keys.js +29 -0
- package/dist/keys.js.map +1 -0
- package/dist/test.js +95 -0
- package/dist/test.js.map +1 -0
- package/package.json +5 -4
- package/dist/account/index.js +0 -274
- package/dist/admin/index.js +0 -20
- package/dist/ai/index.js +0 -179
- package/dist/api/envelope.js +0 -140
- package/dist/api/pagination.js +0 -9
- package/dist/api/routes.js +0 -306
- package/dist/assets/index.js +0 -452
- package/dist/collab/index.js +0 -211
- package/dist/commands/index.js +0 -20
- package/dist/credits/index.js +0 -7
- package/dist/formats/index.js +0 -26
- package/dist/ids/index.js +0 -2
- package/dist/io/index.js +0 -161
- package/dist/jobs/index.js +0 -138
- package/dist/keys/index.js +0 -22
- package/dist/lifecycle/index.js +0 -148
- package/dist/me/index.js +0 -18
- package/dist/packets/index.js +0 -312
- package/dist/projects/index.js +0 -75
- package/dist/public/index.js +0 -25
- package/dist/reads/index.js +0 -118
- package/dist/reports/index.js +0 -466
- package/dist/sharing/index.js +0 -91
- package/dist/sync/codec.js +0 -91
- package/dist/sync/index.js +0 -262
- package/dist/sync/permissions.js +0 -11
- package/dist/templates/index.js +0 -70
- package/dist/tenancy/index.js +0 -102
- package/dist/test/index.js +0 -88
- package/dist/versions/index.js +0 -107
package/dist/formats/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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/ids/index.js
DELETED
package/dist/io/index.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { documentKindSchema } from '../projects/index.js';
|
|
3
|
-
import { docSourceSchema } from '../reads/index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Imports, exports and batch watermark as jobs, plus the upload port they share (slice B16; spec 05 §6.18, §6.1 `uploads`,
|
|
6
|
-
* §13). The synchronous `POST /projects/:pid/documents/import`, `POST /documents/:did/export` and `GET /formats` (see
|
|
7
|
-
* `formats/`) stay until the app migrates.
|
|
8
|
-
*
|
|
9
|
-
* Formats are exactly what `writing_formats` has today: import Fountain, FDX and Fade In; export Fountain, FDX and the plain
|
|
10
|
-
* JSON backup. PDF, DOCX, Celtx, Scrivener and OCR answer `IMPORT_FORMAT_UNSUPPORTED` / `EXPORT_FORMAT_UNSUPPORTED` /
|
|
11
|
-
* `OCR_UNAVAILABLE`; nothing fakes them.
|
|
12
|
-
*/
|
|
13
|
-
/** Formats `POST /imports` accepts (a job kind `import.<format>` exists for each). */
|
|
14
|
-
export const JOB_IMPORT_FORMATS = ['fountain', 'fdx', 'fadein'];
|
|
15
|
-
/** Formats an export job produces (`export.<format>`). */
|
|
16
|
-
export const JOB_EXPORT_FORMATS = ['fountain', 'fdx', 'json'];
|
|
17
|
-
/** `POST /documents/export-combined` takes these (spec 05: pdf, fdx, fountain; pdf is not built). */
|
|
18
|
-
export const COMBINED_EXPORT_FORMATS = ['fdx', 'fountain'];
|
|
19
|
-
/** At most this many documents in one combined export (the job's `sources` cap). */
|
|
20
|
-
export const COMBINED_EXPORT_MAX_DOCUMENTS = 20;
|
|
21
|
-
/** At most this many recipients in one batch watermark (spec 05 §6.18). */
|
|
22
|
-
export const BATCH_WATERMARK_MAX_RECIPIENTS = 500;
|
|
23
|
-
// ─── uploads (spec 05 §6.1 `uploads`, §8) ─────────────────────────────────────
|
|
24
|
-
export const UPLOAD_PURPOSES = ['state', 'watermark_lookup', 'import'];
|
|
25
|
-
const sha256HexSchema = z
|
|
26
|
-
.string()
|
|
27
|
-
.regex(/^[0-9a-fA-F]{64}$/, 'sha256Hex must be 64 hex characters');
|
|
28
|
-
/**
|
|
29
|
-
* `POST /uploads/state`. `purpose` defaults to `state` (a Yjs state blob); `watermark_lookup` is a leaked file for
|
|
30
|
-
* `POST /workspaces/:wid/watermark-lookup`. `import` uploads are created by `POST /imports`, never here.
|
|
31
|
-
*/
|
|
32
|
-
export const uploadStateRequestSchema = z.object({
|
|
33
|
-
sizeBytes: z.number().int().min(1),
|
|
34
|
-
sha256Hex: sha256HexSchema,
|
|
35
|
-
purpose: z.enum(['state', 'watermark_lookup']).default('state'),
|
|
36
|
-
});
|
|
37
|
-
// ─── imports ─────────────────────────────────────────────────────────────────
|
|
38
|
-
export const importOptionsSchema = z.object({
|
|
39
|
-
templateId: z.string().min(1).optional(),
|
|
40
|
-
/** `auto`: OCR a PDF without a text layer; `force`; `off`. No OCR exists yet: `force` is `OCR_UNAVAILABLE`. */
|
|
41
|
-
ocr: z.enum(['auto', 'force', 'off']).default('auto'),
|
|
42
|
-
ocrLanguage: z.string().min(2).max(16).optional(),
|
|
43
|
-
title: z.string().trim().min(1).max(200).optional(),
|
|
44
|
-
kind: documentKindSchema.optional(),
|
|
45
|
-
language: z.string().max(16).optional(),
|
|
46
|
-
});
|
|
47
|
-
const importFileFields = {
|
|
48
|
-
filename: z.string().min(1).max(500),
|
|
49
|
-
sizeBytes: z.number().int().min(1),
|
|
50
|
-
sha256Hex: sha256HexSchema,
|
|
51
|
-
/** Auto-detected from the uploaded bytes when omitted. */
|
|
52
|
-
format: z.string().min(1).max(32).optional(),
|
|
53
|
-
options: importOptionsSchema.optional(),
|
|
54
|
-
};
|
|
55
|
-
/** `POST /imports`: one of `targetProjectId` (import as a new document) or `templateTarget` (a template file, `POST /templates/import {importId}`). */
|
|
56
|
-
export const importCreateSchema = z
|
|
57
|
-
.object({
|
|
58
|
-
targetProjectId: z.string().min(1).optional(),
|
|
59
|
-
templateTarget: z
|
|
60
|
-
.object({
|
|
61
|
-
scope: z.enum(['user', 'workspace']),
|
|
62
|
-
workspaceId: z.string().min(1).optional(),
|
|
63
|
-
})
|
|
64
|
-
.refine((v) => v.scope !== 'workspace' || !!v.workspaceId, {
|
|
65
|
-
message: 'workspaceId is required for a workspace template',
|
|
66
|
-
path: ['workspaceId'],
|
|
67
|
-
})
|
|
68
|
-
.optional(),
|
|
69
|
-
...importFileFields,
|
|
70
|
-
})
|
|
71
|
-
.refine((v) => (v.targetProjectId ? 1 : 0) + (v.templateTarget ? 1 : 0) === 1, {
|
|
72
|
-
message: 'Send exactly one of targetProjectId and templateTarget',
|
|
73
|
-
path: ['targetProjectId'],
|
|
74
|
-
});
|
|
75
|
-
/** `POST /documents/:did/import-over`: the document is the route's. */
|
|
76
|
-
export const importOverSchema = z.object(importFileFields);
|
|
77
|
-
/** Input stored on `import.<format>` jobs (spec 05 §13). `newDocumentId` is minted at start so a retried run cannot make two documents. */
|
|
78
|
-
export const importJobInputSchema = z.object({
|
|
79
|
-
importId: z.string().min(1),
|
|
80
|
-
targetProjectId: z.string().min(1),
|
|
81
|
-
newDocumentId: z.string().min(1),
|
|
82
|
-
filename: z.string().min(1).max(500),
|
|
83
|
-
options: importOptionsSchema.optional(),
|
|
84
|
-
});
|
|
85
|
-
/** Input stored on `doc.importOver` jobs. */
|
|
86
|
-
export const importOverJobInputSchema = z.object({
|
|
87
|
-
importId: z.string().min(1),
|
|
88
|
-
documentId: z.string().min(1),
|
|
89
|
-
filename: z.string().min(1).max(500),
|
|
90
|
-
options: importOptionsSchema.optional(),
|
|
91
|
-
});
|
|
92
|
-
/** Name of the per-document (import) or per-file (export) conversion report output. */
|
|
93
|
-
export const CONVERSION_REPORT_OUTPUT = 'conversion-report.json';
|
|
94
|
-
// ─── exports ─────────────────────────────────────────────────────────────────
|
|
95
|
-
/** Visible watermark. `text` tokens: `{recipient}`, `{email}`, `{company}`, `{title}`, `{date}`. */
|
|
96
|
-
export const watermarkStyleSchema = z.object({
|
|
97
|
-
text: z.string().min(1).max(200).default('{recipient}'),
|
|
98
|
-
opacity: z.number().min(0.05).max(1).optional(),
|
|
99
|
-
position: z
|
|
100
|
-
.enum(['diagonalAscending', 'diagonalDescending', 'horizontal'])
|
|
101
|
-
.optional(),
|
|
102
|
-
});
|
|
103
|
-
export const batchWatermarkSchema = z.object({
|
|
104
|
-
recipients: z
|
|
105
|
-
.array(z.object({
|
|
106
|
-
name: z.string().trim().min(1).max(200),
|
|
107
|
-
email: z.string().trim().min(1).max(320).optional(),
|
|
108
|
-
company: z.string().trim().min(1).max(200).optional(),
|
|
109
|
-
}))
|
|
110
|
-
.min(1)
|
|
111
|
-
.max(BATCH_WATERMARK_MAX_RECIPIENTS),
|
|
112
|
-
visible: watermarkStyleSchema.optional(),
|
|
113
|
-
/** Forensic mark. Only a PDF writer can embed one; text formats carry the export code as a visible note (see the API notes). */
|
|
114
|
-
invisible: z.boolean().default(false),
|
|
115
|
-
/** `email` needs the notification slice (B12): refused with `VALIDATION` until then. */
|
|
116
|
-
deliver: z.enum(['download', 'email']).default('download'),
|
|
117
|
-
emailMessage: z.string().max(2000).optional(),
|
|
118
|
-
});
|
|
119
|
-
export const exportOptionsSchema = z.object({
|
|
120
|
-
/** Download name without extension (default: the document title). */
|
|
121
|
-
filename: z.string().trim().min(1).max(120).optional(),
|
|
122
|
-
batchWatermark: batchWatermarkSchema.optional(),
|
|
123
|
-
});
|
|
124
|
-
/** `POST /documents/:did/exports`. `format` is validated by the server (`EXPORT_FORMAT_UNSUPPORTED` for anything but fountain, fdx, json). */
|
|
125
|
-
export const exportCreateSchema = z.object({
|
|
126
|
-
format: z.string().min(1).max(32),
|
|
127
|
-
source: docSourceSchema.optional(),
|
|
128
|
-
options: exportOptionsSchema.optional(),
|
|
129
|
-
});
|
|
130
|
-
/** `POST /documents/export-combined`: the first document's title page and template, bodies concatenated in the order given. */
|
|
131
|
-
export const exportCombinedSchema = z.object({
|
|
132
|
-
documentIds: z
|
|
133
|
-
.array(z.string().min(1))
|
|
134
|
-
.min(1)
|
|
135
|
-
.max(COMBINED_EXPORT_MAX_DOCUMENTS),
|
|
136
|
-
format: z.string().min(1).max(32),
|
|
137
|
-
options: exportOptionsSchema.omit({ batchWatermark: true }).optional(),
|
|
138
|
-
});
|
|
139
|
-
/** Input stored on `export.<format>` and `watermark.batch` jobs. */
|
|
140
|
-
export const exportJobInputSchema = z.object({
|
|
141
|
-
format: z.enum(JOB_EXPORT_FORMATS),
|
|
142
|
-
documentIds: z
|
|
143
|
-
.array(z.string().min(1))
|
|
144
|
-
.max(COMBINED_EXPORT_MAX_DOCUMENTS)
|
|
145
|
-
.optional(),
|
|
146
|
-
source: docSourceSchema.optional(),
|
|
147
|
-
options: exportOptionsSchema.optional(),
|
|
148
|
-
});
|
|
149
|
-
// ─── watermark lookup ────────────────────────────────────────────────────────
|
|
150
|
-
/** Prefix of an export code as printed in a file: `FWX-` + 26 base32 characters (128 random bits). */
|
|
151
|
-
export const EXPORT_CODE_PREFIX = 'FWX-';
|
|
152
|
-
/** `{exportId}` or `{pdfUploadKey}` (a leaked file uploaded through `/uploads/state` with `purpose: "watermark_lookup"`). */
|
|
153
|
-
export const watermarkLookupSchema = z
|
|
154
|
-
.object({
|
|
155
|
-
exportId: z.string().trim().min(8).max(64).optional(),
|
|
156
|
-
pdfUploadKey: z.string().min(1).max(100).optional(),
|
|
157
|
-
})
|
|
158
|
-
.refine((v) => (v.exportId ? 1 : 0) + (v.pdfUploadKey ? 1 : 0) === 1, {
|
|
159
|
-
message: 'Send exactly one of exportId and pdfUploadKey',
|
|
160
|
-
path: ['exportId'],
|
|
161
|
-
});
|
package/dist/jobs/index.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { cursorQuerySchema } from '../api/pagination.js';
|
|
3
|
-
/**
|
|
4
|
-
* Generic jobs (spec 05 §6.19, §13; slice B9). A job is one row of `jobs`; `ai_jobs` rows are mirrored as `ai.*`
|
|
5
|
-
* jobs (decision D21a) so `/ai/jobs/:id` and `/jobs/:id` read the same job.
|
|
6
|
-
*/
|
|
7
|
-
export const JOB_STATUSES = [
|
|
8
|
-
'queued',
|
|
9
|
-
'running',
|
|
10
|
-
'succeeded',
|
|
11
|
-
'failed',
|
|
12
|
-
'cancelled',
|
|
13
|
-
];
|
|
14
|
-
export const TERMINAL_JOB_STATUSES = [
|
|
15
|
-
'succeeded',
|
|
16
|
-
'failed',
|
|
17
|
-
'cancelled',
|
|
18
|
-
];
|
|
19
|
-
export const isTerminalJobStatus = (s) => TERMINAL_JOB_STATUSES.includes(s);
|
|
20
|
-
export const JOB_LANES = [
|
|
21
|
-
'ai',
|
|
22
|
-
'interactive',
|
|
23
|
-
'bulk',
|
|
24
|
-
'system',
|
|
25
|
-
'provider',
|
|
26
|
-
];
|
|
27
|
-
/**
|
|
28
|
-
* Closed vocabulary of job kinds, `<family>.<variant>` (R10). Every kind has a `job_kind_config` row; a kind
|
|
29
|
-
* without a registered runner is seeded disabled and `POST /jobs` answers `JOB_KIND_DISABLED`. Extend by adding a
|
|
30
|
-
* member here and a row in `screenwriter_api/src/services/jobs/kinds.ts`. `test.*` kinds exist only to prove the
|
|
31
|
-
* framework and are enabled only under `AI_TEST_MODE=1`.
|
|
32
|
-
*/
|
|
33
|
-
export const JOB_KINDS = [
|
|
34
|
-
'ai.review',
|
|
35
|
-
'ai.polish',
|
|
36
|
-
'ai.describe',
|
|
37
|
-
'export.pdf',
|
|
38
|
-
'export.fdx',
|
|
39
|
-
'export.fountain',
|
|
40
|
-
'export.fadein',
|
|
41
|
-
'export.fadewright',
|
|
42
|
-
'export.json',
|
|
43
|
-
'export.docx',
|
|
44
|
-
'watermark.batch',
|
|
45
|
-
'import.fdx',
|
|
46
|
-
'import.fountain',
|
|
47
|
-
'import.fadein',
|
|
48
|
-
'import.pdf',
|
|
49
|
-
'import.ocr',
|
|
50
|
-
'import.celtx',
|
|
51
|
-
'import.scrivener',
|
|
52
|
-
'import.fdxt',
|
|
53
|
-
'report.render',
|
|
54
|
-
'doc.applyTemplate',
|
|
55
|
-
'doc.importOver',
|
|
56
|
-
'doc.snapshotOpen',
|
|
57
|
-
'doc.versionRestore',
|
|
58
|
-
'doc.compare',
|
|
59
|
-
'doc.normalize',
|
|
60
|
-
'doc.renormalize',
|
|
61
|
-
'doc.compact',
|
|
62
|
-
'snapshot.project',
|
|
63
|
-
'project.duplicate',
|
|
64
|
-
'asset.derive',
|
|
65
|
-
'account.export',
|
|
66
|
-
'system.emailSend',
|
|
67
|
-
'system.emailDigest',
|
|
68
|
-
'system.writingReminder',
|
|
69
|
-
'system.pushSend',
|
|
70
|
-
'system.purge',
|
|
71
|
-
'system.retentionSweep',
|
|
72
|
-
'template.thumbnail',
|
|
73
|
-
// reserved for media adapters (spec 11 §6.2): registered, seeded disabled
|
|
74
|
-
'image.generate',
|
|
75
|
-
'image.edit',
|
|
76
|
-
'image.upscale',
|
|
77
|
-
'image.turnaround',
|
|
78
|
-
'video.generate',
|
|
79
|
-
'video.extend',
|
|
80
|
-
'video.upscale',
|
|
81
|
-
'video.lipSync',
|
|
82
|
-
'voice.tts',
|
|
83
|
-
'voice.cloneProfile',
|
|
84
|
-
'voice.change',
|
|
85
|
-
'music.generate',
|
|
86
|
-
'sfx.generate',
|
|
87
|
-
'audio.isolate',
|
|
88
|
-
'model3d.generate',
|
|
89
|
-
'model3d.convert',
|
|
90
|
-
'model3d.rig',
|
|
91
|
-
'storyboard.generate',
|
|
92
|
-
'animatic.assemble',
|
|
93
|
-
'timeline.export',
|
|
94
|
-
// framework tests
|
|
95
|
-
'test.echo',
|
|
96
|
-
'test.flaky',
|
|
97
|
-
];
|
|
98
|
-
export const jobKindSchema = z.enum(JOB_KINDS);
|
|
99
|
-
/** The `ai.*` kind an `AiTask` mirrors as (its `subkind` is the task itself). */
|
|
100
|
-
export function aiKindForTask(task) {
|
|
101
|
-
return task.startsWith('polish') ? 'ai.polish' : 'ai.review';
|
|
102
|
-
}
|
|
103
|
-
export const isAiKind = (kind) => kind.startsWith('ai.');
|
|
104
|
-
export const jobSourceSchema = z.object({
|
|
105
|
-
documentId: z.string().min(1),
|
|
106
|
-
snapshotId: z.string().min(1).optional(),
|
|
107
|
-
targetKind: z.string().min(1).max(40),
|
|
108
|
-
targetId: z.string().min(1).max(100),
|
|
109
|
-
});
|
|
110
|
-
/** `POST /jobs`. `idempotencyKey` (or the `Idempotency-Key` header) makes a retried create return the original job. */
|
|
111
|
-
export const jobCreateSchema = z.object({
|
|
112
|
-
kind: jobKindSchema,
|
|
113
|
-
input: z.record(z.string(), z.unknown()).default({}),
|
|
114
|
-
sources: z.array(jobSourceSchema).max(20).default([]),
|
|
115
|
-
idempotencyKey: z.string().min(1).max(128).optional(),
|
|
116
|
-
maxCredits: z.number().int().min(0).optional(),
|
|
117
|
-
dryRun: z.boolean().optional(),
|
|
118
|
-
});
|
|
119
|
-
/** `?kind=` is exact (`export.pdf`) or a family prefix ending in a dot (`ai.`). */
|
|
120
|
-
export const jobListQuerySchema = cursorQuerySchema.extend({
|
|
121
|
-
documentId: z.string().min(1).optional(),
|
|
122
|
-
kind: z
|
|
123
|
-
.string()
|
|
124
|
-
.regex(/^[A-Za-z0-9]+(\.[A-Za-z0-9]*)?$/)
|
|
125
|
-
.optional(),
|
|
126
|
-
status: z.enum(JOB_STATUSES).optional(),
|
|
127
|
-
});
|
|
128
|
-
/** `GET /jobs/:jobId?wait=N` long-polls up to N seconds (max 120) until status or progress stage changes. */
|
|
129
|
-
export const JOB_WAIT_MAX_S = 120;
|
|
130
|
-
export const jobGetQuerySchema = z.object({
|
|
131
|
-
wait: z.coerce.number().int().min(0).max(JOB_WAIT_MAX_S).optional(),
|
|
132
|
-
});
|
|
133
|
-
/** Header carrying `sha256=<hex HMAC-SHA256(secret, raw body)>` on a provider webhook. */
|
|
134
|
-
export const JOB_WEBHOOK_SIGNATURE_HEADER = 'X-Webhook-Signature';
|
|
135
|
-
/** The generic `Idempotency-Key` header (spec 05 §6.25). Values are 1-128 characters. */
|
|
136
|
-
export const IDEMPOTENCY_HEADER = 'Idempotency-Key';
|
|
137
|
-
export const IDEMPOTENT_REPLAY_HEADER = 'Idempotent-Replayed';
|
|
138
|
-
export const idempotencyKeySchema = z.string().min(1).max(128);
|
package/dist/keys/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/** Personal API keys (`fwk_`), spec 05 4.2 and 6.5. */
|
|
3
|
-
export const API_KEY_SCOPES = ['read', 'read_write'];
|
|
4
|
-
export const apiKeyScopeSchema = z.enum(API_KEY_SCOPES);
|
|
5
|
-
/** At most this many active (unrevoked) keys per user. */
|
|
6
|
-
export const API_KEY_MAX_ACTIVE = 25;
|
|
7
|
-
/** `fwk_` + 8-char public prefix + `_` + 32 bytes base64url secret. */
|
|
8
|
-
export const API_KEY_FORMAT_RE = /^fwk_([a-z0-9]{8})_([A-Za-z0-9_-]{43})$/;
|
|
9
|
-
export const apiKeyCreateSchema = z.object({
|
|
10
|
-
name: z.string().trim().min(1).max(60),
|
|
11
|
-
workspaceId: z.string().min(1),
|
|
12
|
-
scope: apiKeyScopeSchema,
|
|
13
|
-
ai: z.boolean().default(false),
|
|
14
|
-
expiresInDays: z.number().int().min(1).max(365).optional(),
|
|
15
|
-
});
|
|
16
|
-
export const apiKeyUpdateSchema = z.object({
|
|
17
|
-
name: z.string().trim().min(1).max(60).optional(),
|
|
18
|
-
ai: z.boolean().optional(),
|
|
19
|
-
});
|
|
20
|
-
/** Sent by API clients so command transactions record the right origin (`fadewright-mcp/<version>`). */
|
|
21
|
-
export const CLIENT_HEADER = 'X-Client';
|
|
22
|
-
export const MCP_CLIENT_NAME = 'fadewright-mcp';
|
package/dist/lifecycle/index.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { cursorQuerySchema } from '../api/pagination.js';
|
|
3
|
-
import { documentKindSchema } from '../projects/index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Project, document and template lifecycle, workspace settings (slice B14; spec 05 §6.2, §6.6, §6.7, §6.26).
|
|
6
|
-
* Folders, move / duplicate / purge / apply template, the workspace documents list and trash, the Shared Bin, the workspace
|
|
7
|
-
* defaults and the batch-watermark contacts. Template CRUD types live in `templates/`.
|
|
8
|
-
*/
|
|
9
|
-
/** Trashed items are purged (`system.purge`) this many days after they were trashed (spec 05 §17). */
|
|
10
|
-
export const TRASH_RETENTION_DAYS = 30;
|
|
11
|
-
// ─── project folders (`pfd_`, §6.6) ───────────────────────────────────────────
|
|
12
|
-
/** A folder may sit at most this deep (`FOLDER_DEPTH`): the root's children are depth 1. */
|
|
13
|
-
export const FOLDER_MAX_DEPTH = 8;
|
|
14
|
-
export const projectFolderCreateSchema = z.object({
|
|
15
|
-
name: z.string().trim().min(1).max(120),
|
|
16
|
-
parentFolderId: z.string().min(1).optional(),
|
|
17
|
-
});
|
|
18
|
-
export const projectFolderUpdateSchema = z.object({
|
|
19
|
-
name: z.string().trim().min(1).max(120).optional(),
|
|
20
|
-
/** `null` moves the folder to the project root. */
|
|
21
|
-
parentFolderId: z.string().min(1).nullable().optional(),
|
|
22
|
-
position: z.number().finite().optional(),
|
|
23
|
-
});
|
|
24
|
-
/** `DELETE /project-folders/:fid?moveContentsTo=<fid>|root`; without it the contents move up to the folder's own parent. */
|
|
25
|
-
export const projectFolderDeleteQuerySchema = z.object({
|
|
26
|
-
moveContentsTo: z.string().min(1).optional(),
|
|
27
|
-
});
|
|
28
|
-
// ─── projects: purge and duplicate ────────────────────────────────────────────
|
|
29
|
-
export const projectPurgeSchema = z.object({ confirmName: z.string() });
|
|
30
|
-
export const projectDuplicateSchema = z.object({
|
|
31
|
-
name: z.string().trim().min(1).max(200),
|
|
32
|
-
targetWorkspaceId: z.string().min(1).optional(),
|
|
33
|
-
includeSnapshots: z.boolean().default(false),
|
|
34
|
-
/** Re-links the source's asset links onto the copy (B11); a no-op when the target is a different workspace. */
|
|
35
|
-
includeAssets: z.boolean().default(false),
|
|
36
|
-
});
|
|
37
|
-
// ─── documents: move, duplicate, apply template ───────────────────────────────
|
|
38
|
-
export const documentMoveSchema = z.object({
|
|
39
|
-
targetProjectId: z.string().min(1),
|
|
40
|
-
folderId: z.string().min(1).nullable().optional(),
|
|
41
|
-
});
|
|
42
|
-
export const documentDuplicateSchema = z.object({
|
|
43
|
-
title: z.string().trim().min(1).max(200),
|
|
44
|
-
targetProjectId: z.string().min(1).optional(),
|
|
45
|
-
includeSnapshots: z.boolean().default(false),
|
|
46
|
-
includeAssets: z.boolean().default(false),
|
|
47
|
-
});
|
|
48
|
-
/** `POST /documents/:did/template`. `templateVersion` defaults to the template's latest. */
|
|
49
|
-
export const documentApplyTemplateSchema = z.object({
|
|
50
|
-
templateId: z.string().min(1),
|
|
51
|
-
templateVersion: z.number().int().min(1).optional(),
|
|
52
|
-
/** Old style id -> style id of the new template, for styles the new template has no counterpart of. */
|
|
53
|
-
mapping: z.record(z.string(), z.string()).optional(),
|
|
54
|
-
dryRun: z.boolean().optional(),
|
|
55
|
-
});
|
|
56
|
-
// ─── workspace documents and trash ────────────────────────────────────────────
|
|
57
|
-
const boolQuery = z.enum(['true', 'false']).transform((v) => v === 'true');
|
|
58
|
-
/** `GET /workspaces/:wid/documents`: across every project; `starred` is the caller's own stars (`document_stars`). */
|
|
59
|
-
export const workspaceDocumentsQuerySchema = cursorQuerySchema.extend({
|
|
60
|
-
q: z.string().max(200).optional(),
|
|
61
|
-
kind: documentKindSchema.optional(),
|
|
62
|
-
trashed: boolQuery.optional(),
|
|
63
|
-
starred: boolQuery.optional(),
|
|
64
|
-
label: z.string().max(40).optional(),
|
|
65
|
-
});
|
|
66
|
-
export const TRASH_ITEM_TYPES = ['project', 'document', 'asset'];
|
|
67
|
-
/** `confirm` must be `EMPTY`: anything else is the server's `CONFIRMATION_MISMATCH`, not a schema error. */
|
|
68
|
-
export const trashEmptySchema = z.object({ confirm: z.string() });
|
|
69
|
-
/** The `system.purge` job's input (also what a purge job row shows in its `requestSummary`). */
|
|
70
|
-
export const purgeInputSchema = z.object({
|
|
71
|
-
workspaceId: z.string().optional(),
|
|
72
|
-
projectId: z.string().optional(),
|
|
73
|
-
documentId: z.string().optional(),
|
|
74
|
-
});
|
|
75
|
-
// ─── Shared Bin (`bin_`, §6.26) ───────────────────────────────────────────────
|
|
76
|
-
/** Serialised size cap of one snippet (`LIMIT_EXCEEDED`). */
|
|
77
|
-
export const PROJECT_BIN_ITEM_MAX_BYTES = 2 * 1024 * 1024;
|
|
78
|
-
export const projectBinCreateSchema = z.object({
|
|
79
|
-
id: z.string().startsWith('bin_').optional(),
|
|
80
|
-
title: z.string().trim().min(1).max(200).optional(),
|
|
81
|
-
elements: z.array(z.record(z.string(), z.unknown())).min(1),
|
|
82
|
-
sourceDocumentId: z.string().min(1).optional(),
|
|
83
|
-
});
|
|
84
|
-
// ─── workspace defaults (§6.26) ───────────────────────────────────────────────
|
|
85
|
-
export const DEFAULT_PROJECT_ROLES = [
|
|
86
|
-
'admin',
|
|
87
|
-
'writer',
|
|
88
|
-
'commenter',
|
|
89
|
-
'viewer',
|
|
90
|
-
];
|
|
91
|
-
const looseItems = (max) => z.array(z.looseObject({})).max(max);
|
|
92
|
-
/**
|
|
93
|
-
* What *New document* copies into a document of the workspace (then the two diverge, spec 01 §5.4) and *Save as workspace
|
|
94
|
-
* worksheet* writes to. The lists are open objects owned by spec 09 features.
|
|
95
|
-
*/
|
|
96
|
-
export const workspaceDefaultsSchema = z.object({
|
|
97
|
-
tagCategories: looseItems(200).default([]),
|
|
98
|
-
revisionColourSets: looseItems(100).default([]),
|
|
99
|
-
noteTypes: looseItems(100).default([]),
|
|
100
|
-
worksheets: looseItems(200).default([]),
|
|
101
|
-
/** The role newly created projects grant workspace members who have none (F-SET-009). */
|
|
102
|
-
defaultProjectRole: z.enum(DEFAULT_PROJECT_ROLES).nullable().default(null),
|
|
103
|
-
});
|
|
104
|
-
/** Serialised size cap of the defaults document (`LIMIT_EXCEEDED`). */
|
|
105
|
-
export const WORKSPACE_DEFAULTS_MAX_BYTES = 256 * 1024;
|
|
106
|
-
export const workspaceDefaultsPutSchema = workspaceDefaultsSchema.extend({
|
|
107
|
-
baseUpdatedAt: z.string().min(1),
|
|
108
|
-
});
|
|
109
|
-
// ─── contacts (`ctc_`, §6.26) ─────────────────────────────────────────────────
|
|
110
|
-
export const WORKSPACE_CONTACTS_BATCH_MAX = 500;
|
|
111
|
-
const contactFields = {
|
|
112
|
-
name: z.string().trim().min(1).max(200),
|
|
113
|
-
company: z.string().trim().max(200).nullable().optional(),
|
|
114
|
-
email: z.string().trim().max(320).nullable().optional(),
|
|
115
|
-
};
|
|
116
|
-
export const workspaceContactInputSchema = z.object({
|
|
117
|
-
id: z.string().startsWith('ctc_').optional(),
|
|
118
|
-
...contactFields,
|
|
119
|
-
});
|
|
120
|
-
/** More than `WORKSPACE_CONTACTS_BATCH_MAX` entries is the server's `LIMIT_EXCEEDED`, not a schema error. */
|
|
121
|
-
export const workspaceContactsCreateSchema = z.object({
|
|
122
|
-
contacts: z.array(workspaceContactInputSchema).min(1),
|
|
123
|
-
});
|
|
124
|
-
export const workspaceContactPatchSchema = z.object({
|
|
125
|
-
name: contactFields.name.optional(),
|
|
126
|
-
company: contactFields.company,
|
|
127
|
-
email: contactFields.email,
|
|
128
|
-
});
|
|
129
|
-
export const workspaceContactsQuerySchema = cursorQuerySchema.extend({
|
|
130
|
-
q: z.string().max(200).optional(),
|
|
131
|
-
});
|
|
132
|
-
// ─── job inputs (`project.duplicate`, `doc.applyTemplate`, `template.thumbnail`; `system.purge` is `purgeInputSchema`) ───
|
|
133
|
-
export const projectDuplicateJobInputSchema = z.object({
|
|
134
|
-
projectId: z.string().min(1),
|
|
135
|
-
name: z.string().min(1),
|
|
136
|
-
targetWorkspaceId: z.string().min(1),
|
|
137
|
-
includeSnapshots: z.boolean(),
|
|
138
|
-
includeAssets: z.boolean(),
|
|
139
|
-
});
|
|
140
|
-
export const applyTemplateJobInputSchema = z.object({
|
|
141
|
-
templateId: z.string().min(1),
|
|
142
|
-
templateVersion: z.number().int().min(1),
|
|
143
|
-
mapping: z.record(z.string(), z.string()).optional(),
|
|
144
|
-
});
|
|
145
|
-
export const templateThumbnailInputSchema = z.object({
|
|
146
|
-
templateId: z.string().min(1),
|
|
147
|
-
version: z.number().int().min(1),
|
|
148
|
-
});
|
package/dist/me/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export const UI_LANGUAGES = [
|
|
3
|
-
'en',
|
|
4
|
-
'es',
|
|
5
|
-
'fr',
|
|
6
|
-
'de',
|
|
7
|
-
'pt',
|
|
8
|
-
'it',
|
|
9
|
-
'ja',
|
|
10
|
-
'zh',
|
|
11
|
-
];
|
|
12
|
-
export const meUpdateSchema = z.object({
|
|
13
|
-
displayName: z.string().trim().min(1).max(120).optional(),
|
|
14
|
-
avatarAssetId: z.string().nullable().optional(),
|
|
15
|
-
locale: z.string().min(2).max(35).optional(),
|
|
16
|
-
uiLanguage: z.enum(UI_LANGUAGES).optional(),
|
|
17
|
-
timeZone: z.string().min(1).max(64).optional(),
|
|
18
|
-
});
|