@intensevisions/content-contract 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +2 -2
- package/dist/index.d.ts +482 -0
- package/dist/index.js +11 -0
- package/package.json +31 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chad Warner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@intensevisions/content-contract`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
IV Content's shared, versioned types for schemas, documents, publication perspectives, media, and owner RPCs. Keep this package dependency-light: consumers include the Workers, Studio, Next.js server clients, and migration tools. It defines wire contracts only; schema validation and persistence belong to the content engine (`packages/content-engine`) and `workers/content` in the agency monorepo.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
type RpcErrorCode = 'unauthenticated' | 'not_found' | 'unavailable' | 'invalid';
|
|
2
|
+
|
|
3
|
+
export declare const CONTENT_CONTRACT_VERSION: 1;
|
|
4
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
5
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
6
|
+
[key: string]: JsonValue;
|
|
7
|
+
};
|
|
8
|
+
export type JsonObject = {
|
|
9
|
+
[key: string]: JsonValue;
|
|
10
|
+
};
|
|
11
|
+
export type ContentFieldType = 'string' | 'text' | 'number' | 'boolean' | 'date' | 'datetime' | 'url' | 'image' | 'file' | 'reference' | 'object' | 'array' | 'richText';
|
|
12
|
+
export interface ContentFieldBase {
|
|
13
|
+
name: string;
|
|
14
|
+
title: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
hidden?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** One allowed value of a choice field: the stored value and, optionally, the words editors see. */
|
|
20
|
+
export type ContentOption = string | {
|
|
21
|
+
value: string;
|
|
22
|
+
title: string;
|
|
23
|
+
};
|
|
24
|
+
export interface ContentScalarField extends ContentFieldBase {
|
|
25
|
+
type: 'string' | 'text' | 'number' | 'boolean' | 'date' | 'datetime' | 'url';
|
|
26
|
+
/** Pre-filled in a new document. */
|
|
27
|
+
initialValue?: JsonPrimitive;
|
|
28
|
+
/** `string` fields only: the value must be one of these (a choice list). */
|
|
29
|
+
options?: ContentOption[];
|
|
30
|
+
/** How a choice list is shown: a dropdown (default) or radio buttons. */
|
|
31
|
+
layout?: 'dropdown' | 'radio';
|
|
32
|
+
validation?: {
|
|
33
|
+
min?: number;
|
|
34
|
+
max?: number;
|
|
35
|
+
pattern?: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface ContentAssetField extends ContentFieldBase {
|
|
39
|
+
type: 'image' | 'file';
|
|
40
|
+
accept?: string[];
|
|
41
|
+
/** Editable metadata stored beside `assetId`, for example alternative text and a caption. */
|
|
42
|
+
fields?: ContentField[];
|
|
43
|
+
}
|
|
44
|
+
export interface ContentReferenceField extends ContentFieldBase {
|
|
45
|
+
type: 'reference';
|
|
46
|
+
to: string[];
|
|
47
|
+
multiple?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface ContentObjectField extends ContentFieldBase {
|
|
50
|
+
type: 'object';
|
|
51
|
+
fields: ContentField[];
|
|
52
|
+
}
|
|
53
|
+
export interface ContentArrayField extends ContentFieldBase {
|
|
54
|
+
type: 'array';
|
|
55
|
+
of: ContentArrayItem[];
|
|
56
|
+
validation?: {
|
|
57
|
+
min?: number;
|
|
58
|
+
max?: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export type ContentArrayItem = {
|
|
62
|
+
type: 'string';
|
|
63
|
+
options?: ContentOption[];
|
|
64
|
+
} | {
|
|
65
|
+
type: 'text' | 'number' | 'boolean' | 'date' | 'datetime' | 'url';
|
|
66
|
+
} | {
|
|
67
|
+
type: 'image' | 'file';
|
|
68
|
+
fields?: ContentField[];
|
|
69
|
+
} | {
|
|
70
|
+
type: 'reference';
|
|
71
|
+
to: string[];
|
|
72
|
+
} | {
|
|
73
|
+
type: 'object';
|
|
74
|
+
fields: ContentField[];
|
|
75
|
+
} | {
|
|
76
|
+
type: 'richText';
|
|
77
|
+
format: 'portableText' | 'markdown';
|
|
78
|
+
};
|
|
79
|
+
export interface ContentRichTextField extends ContentFieldBase {
|
|
80
|
+
type: 'richText';
|
|
81
|
+
format: 'portableText' | 'markdown';
|
|
82
|
+
allowedMarks?: string[];
|
|
83
|
+
allowedBlocks?: string[];
|
|
84
|
+
}
|
|
85
|
+
export type ContentField = ContentScalarField | ContentAssetField | ContentReferenceField | ContentObjectField | ContentArrayField | ContentRichTextField;
|
|
86
|
+
export interface ContentSchema {
|
|
87
|
+
contractVersion: typeof CONTENT_CONTRACT_VERSION;
|
|
88
|
+
type: string;
|
|
89
|
+
title: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
schemaVersion: number;
|
|
92
|
+
fields: ContentField[];
|
|
93
|
+
titleField?: string;
|
|
94
|
+
slugField?: string;
|
|
95
|
+
singleton?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* The site page that shows a document of this type, for Studio's Preview (e.g. `/books/{slug}`; `{slug}` is the
|
|
98
|
+
* only placeholder; a singleton's is a fixed path such as `/`). Without it the type has no Preview button.
|
|
99
|
+
*/
|
|
100
|
+
previewPath?: string;
|
|
101
|
+
}
|
|
102
|
+
export type ContentStatus = 'draft' | 'published' | 'archived';
|
|
103
|
+
export type ContentPerspective = 'published' | 'draft';
|
|
104
|
+
export interface ContentDocument {
|
|
105
|
+
id: string;
|
|
106
|
+
clientSlug: string;
|
|
107
|
+
siteKey: string;
|
|
108
|
+
type: string;
|
|
109
|
+
schemaVersion: number;
|
|
110
|
+
title?: string;
|
|
111
|
+
slug?: string;
|
|
112
|
+
status: ContentStatus;
|
|
113
|
+
revision: number;
|
|
114
|
+
publishedRevision?: number;
|
|
115
|
+
data: JsonObject;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
updatedAt: string;
|
|
118
|
+
createdBy: string;
|
|
119
|
+
updatedBy: string;
|
|
120
|
+
}
|
|
121
|
+
export interface ContentRevision {
|
|
122
|
+
documentId: string;
|
|
123
|
+
revision: number;
|
|
124
|
+
schemaVersion: number;
|
|
125
|
+
title?: string | null;
|
|
126
|
+
slug?: string | null;
|
|
127
|
+
data: JsonObject;
|
|
128
|
+
actorId: string;
|
|
129
|
+
createdAt: string;
|
|
130
|
+
changeNote?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface ContentAsset {
|
|
133
|
+
id: string;
|
|
134
|
+
clientSlug: string;
|
|
135
|
+
siteKey: string;
|
|
136
|
+
kind: 'image' | 'file';
|
|
137
|
+
filename: string;
|
|
138
|
+
contentType: string;
|
|
139
|
+
size: number;
|
|
140
|
+
sha256: string;
|
|
141
|
+
alt?: string;
|
|
142
|
+
caption?: string;
|
|
143
|
+
createdAt: string;
|
|
144
|
+
createdBy: string;
|
|
145
|
+
}
|
|
146
|
+
export interface UploadContentAssetInput {
|
|
147
|
+
kind: 'image' | 'file';
|
|
148
|
+
filename: string;
|
|
149
|
+
contentType: string;
|
|
150
|
+
bytes: ArrayBuffer;
|
|
151
|
+
alt?: string;
|
|
152
|
+
caption?: string;
|
|
153
|
+
}
|
|
154
|
+
/** A staff-only rendering of any asset of the site, published or not (images resized for the editor). */
|
|
155
|
+
export interface ContentAssetPreview {
|
|
156
|
+
contentType: string;
|
|
157
|
+
filename: string;
|
|
158
|
+
bytes: ArrayBuffer;
|
|
159
|
+
}
|
|
160
|
+
export interface ContentAssetReference {
|
|
161
|
+
assetId: string;
|
|
162
|
+
alt?: string;
|
|
163
|
+
caption?: string;
|
|
164
|
+
}
|
|
165
|
+
export interface ContentActorContext {
|
|
166
|
+
/** Forwarded unchanged; the content owner verifies and authorizes it. */
|
|
167
|
+
sessionToken: string;
|
|
168
|
+
clientSlug: string;
|
|
169
|
+
siteKey: string;
|
|
170
|
+
}
|
|
171
|
+
export interface CreateContentDocumentInput {
|
|
172
|
+
type: string;
|
|
173
|
+
schemaVersion: number;
|
|
174
|
+
title?: string;
|
|
175
|
+
slug?: string;
|
|
176
|
+
data: JsonObject;
|
|
177
|
+
}
|
|
178
|
+
export interface UpdateContentDocumentInput {
|
|
179
|
+
id: string;
|
|
180
|
+
expectedRevision: number;
|
|
181
|
+
title?: string | null;
|
|
182
|
+
slug?: string | null;
|
|
183
|
+
data: JsonObject;
|
|
184
|
+
changeNote?: string;
|
|
185
|
+
}
|
|
186
|
+
export interface ContentDocumentPage {
|
|
187
|
+
documents: ContentDocument[];
|
|
188
|
+
nextCursor?: string;
|
|
189
|
+
}
|
|
190
|
+
export interface ContentSchemaPage {
|
|
191
|
+
schemas: ContentSchema[];
|
|
192
|
+
}
|
|
193
|
+
export interface ContentRevisionPage {
|
|
194
|
+
revisions: ContentRevision[];
|
|
195
|
+
}
|
|
196
|
+
export interface SanityImportSnapshot {
|
|
197
|
+
sourceId: string;
|
|
198
|
+
targetId: string;
|
|
199
|
+
type: string;
|
|
200
|
+
title?: string;
|
|
201
|
+
slug?: string;
|
|
202
|
+
data: JsonObject;
|
|
203
|
+
sourceUpdatedAt?: string;
|
|
204
|
+
}
|
|
205
|
+
export interface SanityImportDocument {
|
|
206
|
+
sourceId: string;
|
|
207
|
+
targetId: string;
|
|
208
|
+
type: string;
|
|
209
|
+
current: SanityImportSnapshot;
|
|
210
|
+
published?: SanityImportSnapshot;
|
|
211
|
+
status: 'draft' | 'published';
|
|
212
|
+
}
|
|
213
|
+
export interface SanityImportAsset {
|
|
214
|
+
sourceId: string;
|
|
215
|
+
targetId: string;
|
|
216
|
+
kind: 'image' | 'file';
|
|
217
|
+
filename: string;
|
|
218
|
+
contentType: string;
|
|
219
|
+
bytes: ArrayBuffer;
|
|
220
|
+
}
|
|
221
|
+
export interface ApplySanityImportInput {
|
|
222
|
+
documents: SanityImportDocument[];
|
|
223
|
+
assets: SanityImportAsset[];
|
|
224
|
+
}
|
|
225
|
+
export interface ApplySanityImportResult {
|
|
226
|
+
importedDocuments: number;
|
|
227
|
+
skippedDocuments: number;
|
|
228
|
+
importedAssets: number;
|
|
229
|
+
skippedAssets: number;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Publish hooks: a Standard Webhooks POST (webhook-id, webhook-timestamp, webhook-signature over
|
|
233
|
+
* "<id>.<timestamp>.<body>" with the endpoint's whsec_ secret) to the site's own address whenever a document is
|
|
234
|
+
* published or unpublished. Receivers verify the signature, dedupe on webhook-id and refresh the routes the document
|
|
235
|
+
* affects. The body is a ContentPublishEvent.
|
|
236
|
+
*/
|
|
237
|
+
export type ContentPublishEventType = 'content.published' | 'content.unpublished' | 'content.test';
|
|
238
|
+
export interface ContentPublishEvent {
|
|
239
|
+
type: ContentPublishEventType;
|
|
240
|
+
siteKey: string;
|
|
241
|
+
occurredAt: string;
|
|
242
|
+
/** Absent on content.test. */
|
|
243
|
+
document?: {
|
|
244
|
+
id: string;
|
|
245
|
+
type: string;
|
|
246
|
+
slug: string | null;
|
|
247
|
+
revision: number | null;
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export interface ContentPublishHook {
|
|
251
|
+
id: string;
|
|
252
|
+
url: string;
|
|
253
|
+
createdAt: string;
|
|
254
|
+
secretRotatedAt: string;
|
|
255
|
+
/** While the previous secret is still accepted after a rotation. */
|
|
256
|
+
previousSecretValidUntil?: string;
|
|
257
|
+
}
|
|
258
|
+
export interface ContentHookSend {
|
|
259
|
+
id: string;
|
|
260
|
+
hookId: string;
|
|
261
|
+
eventType: ContentPublishEventType;
|
|
262
|
+
documentType?: string;
|
|
263
|
+
slug?: string | null;
|
|
264
|
+
status: 'pending' | 'delivered' | 'failed';
|
|
265
|
+
attempts: number;
|
|
266
|
+
lastStatus: number | null;
|
|
267
|
+
error: string | null;
|
|
268
|
+
createdAt: string;
|
|
269
|
+
deliveredAt?: string;
|
|
270
|
+
}
|
|
271
|
+
export interface ContentPublishHookPage {
|
|
272
|
+
hooks: ContentPublishHook[];
|
|
273
|
+
/** The site's most recent sends, newest first. */
|
|
274
|
+
sends: ContentHookSend[];
|
|
275
|
+
}
|
|
276
|
+
/** The only answer that ever carries a hook's secret: right after it was created or rotated. */
|
|
277
|
+
export interface ContentPublishHookSecret {
|
|
278
|
+
hook: ContentPublishHook;
|
|
279
|
+
secret: string;
|
|
280
|
+
}
|
|
281
|
+
/** One change between a type's active version and a proposed one, in words (see content-engine compareSchemas). */
|
|
282
|
+
export interface ContentSchemaChange {
|
|
283
|
+
field: string;
|
|
284
|
+
kind: 'added' | 'removed' | 'changed';
|
|
285
|
+
mayAffectDocuments: boolean;
|
|
286
|
+
message: string;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* What registering a schema would do (a read-only check, AC-10). `compatible` and `new` register; `unchanged` is a
|
|
290
|
+
* no-op; `blocked` names why: identity changes while documents exist, a missing reference target, or documents that
|
|
291
|
+
* wouldn't be valid under the new version (fix them, or the schema, and check again).
|
|
292
|
+
*/
|
|
293
|
+
export interface ContentSchemaPlan {
|
|
294
|
+
type: string;
|
|
295
|
+
title: string;
|
|
296
|
+
status: 'new' | 'unchanged' | 'compatible' | 'blocked';
|
|
297
|
+
fromVersion?: number;
|
|
298
|
+
toVersion: number;
|
|
299
|
+
changes: ContentSchemaChange[];
|
|
300
|
+
documents: number;
|
|
301
|
+
/** Documents that wouldn't be valid (first 25, first 5 issues each). */
|
|
302
|
+
problems: Array<{
|
|
303
|
+
id: string;
|
|
304
|
+
title: string;
|
|
305
|
+
issues: Array<{
|
|
306
|
+
path: string;
|
|
307
|
+
message: string;
|
|
308
|
+
}>;
|
|
309
|
+
}>;
|
|
310
|
+
problemCount: number;
|
|
311
|
+
reasons: string[];
|
|
312
|
+
/** Types it links to that the site doesn't have yet (a manifest can register them first; their reasons are in `reasons`). */
|
|
313
|
+
missingTargets: string[];
|
|
314
|
+
/** Pass back to registerSchema: refused (`conflict`) if the type's documents changed since this check. */
|
|
315
|
+
fingerprint: string;
|
|
316
|
+
}
|
|
317
|
+
/** The plan's reason for a missing link target; Studio drops it when the same manifest registers the target first. */
|
|
318
|
+
export declare const missingTargetReason: (target: string) => string;
|
|
319
|
+
export interface ContentPreviewLink {
|
|
320
|
+
url: string;
|
|
321
|
+
expiresAt: string;
|
|
322
|
+
}
|
|
323
|
+
/** How long a preview token lets a site read drafts. */
|
|
324
|
+
export declare const CONTENT_PREVIEW_TTL_MS: number;
|
|
325
|
+
/** The signed-links kind of a preview token (signed-links signJson). */
|
|
326
|
+
export declare const CONTENT_PREVIEW_KIND = "content-preview";
|
|
327
|
+
/** Public response projection: no actor identity, draft fields, or editing metadata. */
|
|
328
|
+
export interface PublishedContentDocument {
|
|
329
|
+
id: string;
|
|
330
|
+
siteKey: string;
|
|
331
|
+
type: string;
|
|
332
|
+
schemaVersion: number;
|
|
333
|
+
title?: string;
|
|
334
|
+
slug?: string;
|
|
335
|
+
revision: number;
|
|
336
|
+
data: JsonObject;
|
|
337
|
+
publishedAt: string;
|
|
338
|
+
}
|
|
339
|
+
export interface PublishedContentDocumentPage {
|
|
340
|
+
documents: PublishedContentDocument[];
|
|
341
|
+
nextCursor?: string;
|
|
342
|
+
}
|
|
343
|
+
/** Documents asked for by id: in the order asked, ids that aren't published (or don't exist) simply absent. */
|
|
344
|
+
export interface PublishedContentDocumentList {
|
|
345
|
+
documents: PublishedContentDocument[];
|
|
346
|
+
}
|
|
347
|
+
/** At most this many ids in one by-ids request. */
|
|
348
|
+
export declare const MAX_DELIVERY_IDS = 100;
|
|
349
|
+
/** How deep `expand` follows references: 1 (the default) or 2. */
|
|
350
|
+
export declare const MAX_EXPAND_DEPTH = 2;
|
|
351
|
+
/**
|
|
352
|
+
* Reference expansion (GROQ's `->`): each selected reference id in `data` is replaced by the referenced document's
|
|
353
|
+
* published projection (a PublishedContentDocument). A single reference whose target isn't published becomes null; in a
|
|
354
|
+
* list (multiple references, arrays) it is dropped. `'*'` = every reference field of the type's active schema;
|
|
355
|
+
* otherwise field names, dotted for nested ones (`seo.ogImageRef`); naming an object or array field expands the
|
|
356
|
+
* references inside it. At depth 2 the expanded documents expand the same selection, by name, against their own
|
|
357
|
+
* schema (names they don't have are ignored); references beyond the depth stay ids. Drafts never appear.
|
|
358
|
+
*/
|
|
359
|
+
export interface ContentExpandOptions {
|
|
360
|
+
expand?: '*' | string[];
|
|
361
|
+
expandDepth?: 1 | 2;
|
|
362
|
+
}
|
|
363
|
+
/** An equality filter value: matched against the field's stored value, coerced by the field's schema type. */
|
|
364
|
+
export type ContentWhereValue = string | number | boolean;
|
|
365
|
+
export interface ContentQueryInput extends ContentExpandOptions {
|
|
366
|
+
siteKey: string;
|
|
367
|
+
type: string;
|
|
368
|
+
cursor?: string;
|
|
369
|
+
limit?: number;
|
|
370
|
+
/** Equality on top-level scalar fields of the type's schema (string, text, url, number, boolean, date, datetime). */
|
|
371
|
+
where?: Record<string, ContentWhereValue>;
|
|
372
|
+
/** A top-level scalar field, `-field` for descending; ties (and the default order) go by id. */
|
|
373
|
+
order?: string;
|
|
374
|
+
}
|
|
375
|
+
/** Content adds explicit optimistic-concurrency and role refusals to the common owner RPC outcomes. */
|
|
376
|
+
export type ContentRpc<T> = {
|
|
377
|
+
ok: true;
|
|
378
|
+
value: T;
|
|
379
|
+
}
|
|
380
|
+
/** `message`: why an expected refusal (`invalid`) was refused, in words for the developer; never internal detail. */
|
|
381
|
+
| {
|
|
382
|
+
ok: false;
|
|
383
|
+
code: RpcErrorCode | 'conflict' | 'forbidden';
|
|
384
|
+
ref?: string;
|
|
385
|
+
message?: string;
|
|
386
|
+
};
|
|
387
|
+
/** Worker service-binding surface used by Studio and the client portal. */
|
|
388
|
+
export interface ContentRuntimeRpc extends ContentAuthoringRpc {
|
|
389
|
+
}
|
|
390
|
+
/** Internal authoring surface. Every call forwards the Studio session; the owner re-verifies it. */
|
|
391
|
+
export interface ContentAuthoringRpc {
|
|
392
|
+
listSchemas(context: ContentActorContext): Promise<ContentRpc<ContentSchemaPage>>;
|
|
393
|
+
/** Read-only: what registering this schema would do (no write). */
|
|
394
|
+
planSchema(context: ContentActorContext, input: ContentSchema): Promise<ContentRpc<ContentSchemaPlan>>;
|
|
395
|
+
/**
|
|
396
|
+
* Registers a schema: a new type, or a new version of one whose existing documents all stay valid (versions are
|
|
397
|
+
* numbered by the runtime; the manifest's schemaVersion is ignored). Pass the plan's fingerprint to refuse it if the
|
|
398
|
+
* documents changed since the check (`conflict`). `invalid` when the plan is blocked.
|
|
399
|
+
*/
|
|
400
|
+
registerSchema(context: ContentActorContext, input: ContentSchema, options?: {
|
|
401
|
+
fingerprint?: string;
|
|
402
|
+
}): Promise<ContentRpc<ContentSchema>>;
|
|
403
|
+
listDocuments(context: ContentActorContext, input: {
|
|
404
|
+
type?: string;
|
|
405
|
+
status?: ContentStatus;
|
|
406
|
+
cursor?: string;
|
|
407
|
+
limit?: number;
|
|
408
|
+
}): Promise<ContentRpc<ContentDocumentPage>>;
|
|
409
|
+
getDocument(context: ContentActorContext, input: {
|
|
410
|
+
id: string;
|
|
411
|
+
}): Promise<ContentRpc<ContentDocument>>;
|
|
412
|
+
listRevisions(context: ContentActorContext, input: {
|
|
413
|
+
id: string;
|
|
414
|
+
}): Promise<ContentRpc<ContentRevisionPage>>;
|
|
415
|
+
uploadAsset(context: ContentActorContext, input: UploadContentAssetInput): Promise<ContentRpc<ContentAsset>>;
|
|
416
|
+
applySanityImport(context: ContentActorContext, input: ApplySanityImportInput): Promise<ContentRpc<ApplySanityImportResult>>;
|
|
417
|
+
createDocument(context: ContentActorContext, input: CreateContentDocumentInput): Promise<ContentRpc<ContentDocument>>;
|
|
418
|
+
updateDocument(context: ContentActorContext, input: UpdateContentDocumentInput): Promise<ContentRpc<ContentDocument>>;
|
|
419
|
+
publishDocument(context: ContentActorContext, input: {
|
|
420
|
+
id: string;
|
|
421
|
+
expectedRevision: number;
|
|
422
|
+
}): Promise<ContentRpc<ContentDocument>>;
|
|
423
|
+
unpublishDocument(context: ContentActorContext, input: {
|
|
424
|
+
id: string;
|
|
425
|
+
expectedRevision: number;
|
|
426
|
+
}): Promise<ContentRpc<ContentDocument>>;
|
|
427
|
+
restoreRevision(context: ContentActorContext, input: {
|
|
428
|
+
id: string;
|
|
429
|
+
revision: number;
|
|
430
|
+
expectedRevision: number;
|
|
431
|
+
}): Promise<ContentRpc<ContentDocument>>;
|
|
432
|
+
/** Staff only: an asset's bytes for the editor (images resized to `width`, at most 1024), published or not. */
|
|
433
|
+
previewAsset(context: ContentActorContext, input: {
|
|
434
|
+
id: string;
|
|
435
|
+
width?: number;
|
|
436
|
+
}): Promise<ContentRpc<ContentAssetPreview>>;
|
|
437
|
+
/**
|
|
438
|
+
* A private preview link for a document: the site's `/api/preview` with a signed token (an hour, this site only)
|
|
439
|
+
* and the document's page from its type's `previewPath`. The site turns on draft mode and reads drafts with it.
|
|
440
|
+
*/
|
|
441
|
+
createPreviewLink(context: ContentActorContext, input: {
|
|
442
|
+
id: string;
|
|
443
|
+
}): Promise<ContentRpc<ContentPreviewLink>>;
|
|
444
|
+
listPublishHooks(context: ContentActorContext): Promise<ContentRpc<ContentPublishHookPage>>;
|
|
445
|
+
/** secrets.manage. The URL must be https on the site's own host. */
|
|
446
|
+
addPublishHook(context: ContentActorContext, input: {
|
|
447
|
+
url: string;
|
|
448
|
+
}): Promise<ContentRpc<ContentPublishHookSecret>>;
|
|
449
|
+
/** secrets.manage. The previous secret stays valid for 24 hours. */
|
|
450
|
+
rotatePublishHookSecret(context: ContentActorContext, input: {
|
|
451
|
+
id: string;
|
|
452
|
+
}): Promise<ContentRpc<ContentPublishHookSecret>>;
|
|
453
|
+
/** secrets.manage. Drops the hook and its sends. */
|
|
454
|
+
removePublishHook(context: ContentActorContext, input: {
|
|
455
|
+
id: string;
|
|
456
|
+
}): Promise<ContentRpc<{
|
|
457
|
+
id: string;
|
|
458
|
+
}>>;
|
|
459
|
+
/** Sends a content.test event now and returns how it went. */
|
|
460
|
+
testPublishHook(context: ContentActorContext, input: {
|
|
461
|
+
id: string;
|
|
462
|
+
}): Promise<ContentRpc<ContentHookSend>>;
|
|
463
|
+
/** Sends a failed send again now (same webhook-id, so receivers dedupe). */
|
|
464
|
+
resendHookSend(context: ContentActorContext, input: {
|
|
465
|
+
id: string;
|
|
466
|
+
}): Promise<ContentRpc<ContentHookSend>>;
|
|
467
|
+
}
|
|
468
|
+
/** Public site delivery surface. Draft access is intentionally absent from this interface. */
|
|
469
|
+
export interface ContentDeliveryRpc {
|
|
470
|
+
getPublishedDocument(input: {
|
|
471
|
+
siteKey: string;
|
|
472
|
+
type: string;
|
|
473
|
+
slug: string;
|
|
474
|
+
} & ContentExpandOptions): Promise<ContentRpc<PublishedContentDocument>>;
|
|
475
|
+
/** `invalid` for an unknown or unsortable field, a bad cursor or a bad expand. */
|
|
476
|
+
queryPublishedDocuments(input: ContentQueryInput): Promise<ContentRpc<PublishedContentDocumentPage>>;
|
|
477
|
+
/** At most MAX_DELIVERY_IDS ids, any types. */
|
|
478
|
+
getPublishedDocumentsByIds(input: {
|
|
479
|
+
siteKey: string;
|
|
480
|
+
ids: string[];
|
|
481
|
+
} & ContentExpandOptions): Promise<ContentRpc<PublishedContentDocumentList>>;
|
|
482
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const CONTENT_CONTRACT_VERSION = 1;
|
|
2
|
+
/** The plan's reason for a missing link target; Studio drops it when the same manifest registers the target first. */
|
|
3
|
+
export const missingTargetReason = (target) => `It links to “${target}”, which this site doesn’t have yet: register that type first.`;
|
|
4
|
+
/** How long a preview token lets a site read drafts. */
|
|
5
|
+
export const CONTENT_PREVIEW_TTL_MS = 60 * 60 * 1000;
|
|
6
|
+
/** The signed-links kind of a preview token (signed-links signJson). */
|
|
7
|
+
export const CONTENT_PREVIEW_KIND = 'content-preview';
|
|
8
|
+
/** At most this many ids in one by-ids request. */
|
|
9
|
+
export const MAX_DELIVERY_IDS = 100;
|
|
10
|
+
/** How deep `expand` follows references: 1 (the default) or 2. */
|
|
11
|
+
export const MAX_EXPAND_DEPTH = 2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intensevisions/content-contract",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "IV Content's versioned schema, document, publication, media, and owner RPC contracts.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Intense-Visions/intensevisions.com.git",
|
|
9
|
+
"directory": "packages/content-contract"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Intense-Visions/intensevisions.com/tree/main/packages/content-contract#readme",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.18"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|