@rolino/contracts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/index.cjs +824 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2203 -0
- package/dist/index.d.ts +2203 -0
- package/dist/index.js +724 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var API_VERSION = "v1";
|
|
4
|
+
var CONTRACT_VERSION = "0.12.0";
|
|
5
|
+
var RequestMetadataSchema = z.object({
|
|
6
|
+
requestId: z.string().min(1)
|
|
7
|
+
});
|
|
8
|
+
var ApiErrorCodeSchema = z.enum([
|
|
9
|
+
"AUTH_REQUIRED",
|
|
10
|
+
"FORBIDDEN",
|
|
11
|
+
"NOT_FOUND",
|
|
12
|
+
"FEATURE_DISABLED",
|
|
13
|
+
"BILLING_REQUIRED",
|
|
14
|
+
"LIMIT_REACHED",
|
|
15
|
+
"VALIDATION_ERROR",
|
|
16
|
+
"CONFLICT",
|
|
17
|
+
"RATE_LIMITED",
|
|
18
|
+
"INTERNAL_ERROR"
|
|
19
|
+
]);
|
|
20
|
+
var ApiProblemSchema = z.object({
|
|
21
|
+
error: z.object({
|
|
22
|
+
code: ApiErrorCodeSchema,
|
|
23
|
+
message: z.string().min(1),
|
|
24
|
+
details: z.record(z.string(), z.unknown()).optional()
|
|
25
|
+
}),
|
|
26
|
+
meta: RequestMetadataSchema
|
|
27
|
+
});
|
|
28
|
+
function successEnvelopeSchema(data) {
|
|
29
|
+
return z.object({
|
|
30
|
+
data,
|
|
31
|
+
meta: RequestMetadataSchema
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
var CapabilityIdSchema = z.enum([
|
|
35
|
+
"identity:read",
|
|
36
|
+
"projects:read",
|
|
37
|
+
"projects:write",
|
|
38
|
+
"posts:read",
|
|
39
|
+
"posts:write",
|
|
40
|
+
"posts:schedule",
|
|
41
|
+
"posts:publish",
|
|
42
|
+
"integrations:read",
|
|
43
|
+
"calendar:read"
|
|
44
|
+
]);
|
|
45
|
+
var CapabilitySchema = z.object({
|
|
46
|
+
id: CapabilityIdSchema,
|
|
47
|
+
available: z.boolean(),
|
|
48
|
+
reason: z.enum([
|
|
49
|
+
"AVAILABLE",
|
|
50
|
+
"AUTH_REQUIRED",
|
|
51
|
+
"SCOPE_REQUIRED",
|
|
52
|
+
"FEATURE_DISABLED"
|
|
53
|
+
])
|
|
54
|
+
});
|
|
55
|
+
var ApiMetaSchema = z.object({
|
|
56
|
+
name: z.literal("Rolino"),
|
|
57
|
+
serverVersion: z.string().min(1),
|
|
58
|
+
apiVersion: z.literal(API_VERSION),
|
|
59
|
+
contractVersion: z.literal(CONTRACT_VERSION),
|
|
60
|
+
authentication: z.object({
|
|
61
|
+
browserSession: z.boolean(),
|
|
62
|
+
cliBrowserAuthorization: z.boolean(),
|
|
63
|
+
apiKey: z.boolean(),
|
|
64
|
+
remoteOAuth: z.boolean()
|
|
65
|
+
}),
|
|
66
|
+
mcp: z.object({
|
|
67
|
+
stdio: z.boolean(),
|
|
68
|
+
streamableHttp: z.boolean(),
|
|
69
|
+
remoteStatus: z.enum(["AVAILABLE", "AUTH_GATE"])
|
|
70
|
+
}),
|
|
71
|
+
capabilities: z.array(CapabilitySchema)
|
|
72
|
+
});
|
|
73
|
+
var ApiMetaResponseSchema = successEnvelopeSchema(ApiMetaSchema);
|
|
74
|
+
var AuthenticationKindSchema = z.enum(["session", "api_key"]);
|
|
75
|
+
var ActorSchema = z.object({
|
|
76
|
+
user: z.object({
|
|
77
|
+
id: z.string().min(1),
|
|
78
|
+
name: z.string(),
|
|
79
|
+
email: z.string().email()
|
|
80
|
+
}),
|
|
81
|
+
organization: z.object({
|
|
82
|
+
id: z.string().min(1),
|
|
83
|
+
name: z.string().min(1),
|
|
84
|
+
role: z.string().min(1)
|
|
85
|
+
}),
|
|
86
|
+
authentication: z.object({
|
|
87
|
+
kind: AuthenticationKindSchema,
|
|
88
|
+
credentialId: z.string().min(1).nullable()
|
|
89
|
+
}),
|
|
90
|
+
capabilities: z.array(CapabilityIdSchema)
|
|
91
|
+
});
|
|
92
|
+
var WhoAmIResponseSchema = successEnvelopeSchema(ActorSchema);
|
|
93
|
+
var Base64UrlSecretSchema = z.string().min(43).max(128).regex(/^[A-Za-z0-9_-]+$/);
|
|
94
|
+
var CLI_BROWSER_AUTHORIZATION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
95
|
+
var CliAuthorizationExchangeRequestSchema = z.object({
|
|
96
|
+
code: Base64UrlSecretSchema,
|
|
97
|
+
codeVerifier: Base64UrlSecretSchema
|
|
98
|
+
});
|
|
99
|
+
var CliAuthorizationCredentialSchema = z.object({
|
|
100
|
+
token: z.string().min(1),
|
|
101
|
+
tokenType: z.literal("Bearer"),
|
|
102
|
+
expiresAt: z.string().datetime(),
|
|
103
|
+
organization: z.object({
|
|
104
|
+
id: z.string().min(1),
|
|
105
|
+
name: z.string().min(1)
|
|
106
|
+
}),
|
|
107
|
+
capabilities: z.array(CapabilityIdSchema)
|
|
108
|
+
});
|
|
109
|
+
var CliAuthorizationExchangeResponseSchema = successEnvelopeSchema(
|
|
110
|
+
CliAuthorizationCredentialSchema
|
|
111
|
+
);
|
|
112
|
+
var CliAuthorizationRevokeDataSchema = z.object({
|
|
113
|
+
revoked: z.literal(true)
|
|
114
|
+
});
|
|
115
|
+
var CliAuthorizationRevokeResponseSchema = successEnvelopeSchema(
|
|
116
|
+
CliAuthorizationRevokeDataSchema
|
|
117
|
+
);
|
|
118
|
+
var CapabilitiesDataSchema = z.object({
|
|
119
|
+
capabilities: z.array(CapabilitySchema)
|
|
120
|
+
});
|
|
121
|
+
var CapabilitiesResponseSchema = successEnvelopeSchema(CapabilitiesDataSchema);
|
|
122
|
+
var ProjectTypeSchema = z.enum([
|
|
123
|
+
"PRODUCT",
|
|
124
|
+
"LAUNCH",
|
|
125
|
+
"EVENT",
|
|
126
|
+
"CONTENT_SERIES",
|
|
127
|
+
"CLIENT",
|
|
128
|
+
"BRAND",
|
|
129
|
+
"INTERNAL"
|
|
130
|
+
]);
|
|
131
|
+
var ProjectWebsiteUrlSchema = z.string().trim().min(1).max(2e3).url().refine((value) => {
|
|
132
|
+
try {
|
|
133
|
+
const url = new URL(value);
|
|
134
|
+
return (url.protocol === "http:" || url.protocol === "https:") && !url.username && !url.password;
|
|
135
|
+
} catch {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
}, "websiteUrl must be an absolute http or https URL without credentials");
|
|
139
|
+
var ProjectCreateInputSchema = z.object({
|
|
140
|
+
name: z.string().trim().min(1).max(100),
|
|
141
|
+
type: ProjectTypeSchema.default("PRODUCT"),
|
|
142
|
+
websiteUrl: ProjectWebsiteUrlSchema.optional(),
|
|
143
|
+
description: z.string().trim().min(1).max(2e3).optional()
|
|
144
|
+
}).strict();
|
|
145
|
+
var ProjectSchema = z.object({
|
|
146
|
+
id: z.string().min(1),
|
|
147
|
+
organizationId: z.string().min(1),
|
|
148
|
+
name: z.string().min(1),
|
|
149
|
+
slug: z.string().min(1),
|
|
150
|
+
type: ProjectTypeSchema,
|
|
151
|
+
status: z.enum(["ACTIVE", "PAUSED", "ARCHIVED"]),
|
|
152
|
+
websiteUrl: z.string().url().nullable(),
|
|
153
|
+
description: z.string().nullable(),
|
|
154
|
+
createdAt: z.string().datetime(),
|
|
155
|
+
updatedAt: z.string().datetime()
|
|
156
|
+
});
|
|
157
|
+
var ProjectListQuerySchema = z.object({
|
|
158
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
159
|
+
cursor: z.string().min(1).optional()
|
|
160
|
+
});
|
|
161
|
+
var ProjectListDataSchema = z.object({
|
|
162
|
+
items: z.array(ProjectSchema),
|
|
163
|
+
page: z.object({
|
|
164
|
+
limit: z.number().int().min(1).max(100),
|
|
165
|
+
nextCursor: z.string().min(1).nullable()
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
var ProjectListResponseSchema = successEnvelopeSchema(ProjectListDataSchema);
|
|
169
|
+
var ProjectResponseSchema = successEnvelopeSchema(ProjectSchema);
|
|
170
|
+
var PostStatusSchema = z.enum([
|
|
171
|
+
"DRAFT",
|
|
172
|
+
"SCHEDULED",
|
|
173
|
+
"ACTION_REQUIRED",
|
|
174
|
+
"PUBLISHING",
|
|
175
|
+
"PUBLISHED",
|
|
176
|
+
"PARTIALLY_PUBLISHED",
|
|
177
|
+
"FAILED"
|
|
178
|
+
]);
|
|
179
|
+
var PlatformPostStatusSchema = z.enum([
|
|
180
|
+
"DRAFT",
|
|
181
|
+
"SCHEDULED",
|
|
182
|
+
"PREPARING",
|
|
183
|
+
"ACTION_REQUIRED",
|
|
184
|
+
"PUBLISHING",
|
|
185
|
+
"PUBLISHED",
|
|
186
|
+
"FAILED"
|
|
187
|
+
]);
|
|
188
|
+
var PostMediaSchema = z.object({
|
|
189
|
+
id: z.string().min(1),
|
|
190
|
+
type: z.enum(["IMAGE", "VIDEO"]),
|
|
191
|
+
url: z.string().url(),
|
|
192
|
+
mimeType: z.string().min(1),
|
|
193
|
+
width: z.number().int().positive().nullable(),
|
|
194
|
+
height: z.number().int().positive().nullable(),
|
|
195
|
+
durationMs: z.number().int().nonnegative().nullable(),
|
|
196
|
+
thumbnailUrl: z.string().url().nullable(),
|
|
197
|
+
altText: z.string().nullable(),
|
|
198
|
+
position: z.number().int().nonnegative()
|
|
199
|
+
});
|
|
200
|
+
var MediaAssetSchema = z.object({
|
|
201
|
+
id: z.string().min(1),
|
|
202
|
+
type: z.enum(["IMAGE", "VIDEO"]),
|
|
203
|
+
url: z.string().url(),
|
|
204
|
+
thumbnailUrl: z.string().url().nullable(),
|
|
205
|
+
originalFileName: z.string().nullable(),
|
|
206
|
+
mimeType: z.string().min(1),
|
|
207
|
+
sizeBytes: z.number().int().positive().nullable(),
|
|
208
|
+
width: z.number().int().positive().nullable(),
|
|
209
|
+
height: z.number().int().positive().nullable(),
|
|
210
|
+
durationMs: z.number().int().nonnegative().nullable(),
|
|
211
|
+
createdAt: z.string().datetime()
|
|
212
|
+
});
|
|
213
|
+
var MediaAssetListQuerySchema = z.object({
|
|
214
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
215
|
+
cursor: z.string().min(1).optional(),
|
|
216
|
+
type: z.enum(["IMAGE", "VIDEO"]).optional(),
|
|
217
|
+
query: z.string().trim().min(1).max(100).optional()
|
|
218
|
+
});
|
|
219
|
+
var MediaAssetListDataSchema = z.object({
|
|
220
|
+
items: z.array(MediaAssetSchema),
|
|
221
|
+
page: z.object({
|
|
222
|
+
limit: z.number().int().min(1).max(100),
|
|
223
|
+
nextCursor: z.string().min(1).nullable()
|
|
224
|
+
})
|
|
225
|
+
});
|
|
226
|
+
var MediaAssetListResponseSchema = successEnvelopeSchema(MediaAssetListDataSchema);
|
|
227
|
+
var MediaAssetUploadInputSchema = z.object({
|
|
228
|
+
fileName: z.string().trim().min(1).max(255),
|
|
229
|
+
contentType: z.string().trim().min(1).max(100),
|
|
230
|
+
fileSize: z.number().int().positive()
|
|
231
|
+
}).strict();
|
|
232
|
+
var MediaAssetUploadPreparationSchema = z.object({
|
|
233
|
+
uploadUrl: z.string().url(),
|
|
234
|
+
storageKey: z.string().min(1),
|
|
235
|
+
expiresAt: z.string().datetime(),
|
|
236
|
+
headers: z.record(z.string(), z.string()),
|
|
237
|
+
maxFileSize: z.number().int().positive()
|
|
238
|
+
});
|
|
239
|
+
var MediaAssetUploadPreparationResponseSchema = successEnvelopeSchema(MediaAssetUploadPreparationSchema);
|
|
240
|
+
var MediaAssetUploadCompleteInputSchema = MediaAssetUploadInputSchema.extend({
|
|
241
|
+
storageKey: z.string().min(1),
|
|
242
|
+
width: z.number().int().positive().max(1e5).nullable().optional(),
|
|
243
|
+
height: z.number().int().positive().max(1e5).nullable().optional(),
|
|
244
|
+
durationMs: z.number().int().nonnegative().max(864e5).nullable().optional()
|
|
245
|
+
}).strict();
|
|
246
|
+
var MediaAssetResponseSchema = successEnvelopeSchema(MediaAssetSchema);
|
|
247
|
+
var PostDestinationSchema = z.object({
|
|
248
|
+
provider: z.enum(["INSTAGRAM", "TIKTOK", "YOUTUBE", "BLUESKY"]),
|
|
249
|
+
status: PlatformPostStatusSchema,
|
|
250
|
+
captionOverride: z.string().nullable(),
|
|
251
|
+
scheduledAt: z.string().datetime().nullable(),
|
|
252
|
+
publishedAt: z.string().datetime().nullable(),
|
|
253
|
+
remoteUrl: z.string().url().nullable(),
|
|
254
|
+
attemptCount: z.number().int().nonnegative()
|
|
255
|
+
});
|
|
256
|
+
var PublishingProviderSchema = z.enum([
|
|
257
|
+
"INSTAGRAM",
|
|
258
|
+
"TIKTOK",
|
|
259
|
+
"YOUTUBE",
|
|
260
|
+
"BLUESKY"
|
|
261
|
+
]);
|
|
262
|
+
var PUBLISHING_PROVIDER_COUNT = PublishingProviderSchema.options.length;
|
|
263
|
+
var PostSchema = z.object({
|
|
264
|
+
id: z.string().min(1),
|
|
265
|
+
projectId: z.string().min(1),
|
|
266
|
+
version: z.number().int().positive(),
|
|
267
|
+
campaign: z.object({
|
|
268
|
+
id: z.string().min(1),
|
|
269
|
+
title: z.string().min(1)
|
|
270
|
+
}).nullable(),
|
|
271
|
+
caption: z.string(),
|
|
272
|
+
status: PostStatusSchema,
|
|
273
|
+
scheduledAt: z.string().datetime().nullable(),
|
|
274
|
+
timezone: z.string().nullable(),
|
|
275
|
+
publishedAt: z.string().datetime().nullable(),
|
|
276
|
+
createdAt: z.string().datetime(),
|
|
277
|
+
updatedAt: z.string().datetime(),
|
|
278
|
+
media: z.array(PostMediaSchema),
|
|
279
|
+
destinations: z.array(PostDestinationSchema)
|
|
280
|
+
});
|
|
281
|
+
var PostListQuerySchema = z.object({
|
|
282
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
283
|
+
cursor: z.string().min(1).optional(),
|
|
284
|
+
status: PostStatusSchema.optional()
|
|
285
|
+
});
|
|
286
|
+
var PostListDataSchema = z.object({
|
|
287
|
+
items: z.array(PostSchema),
|
|
288
|
+
page: z.object({
|
|
289
|
+
limit: z.number().int().min(1).max(100),
|
|
290
|
+
nextCursor: z.string().min(1).nullable()
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
var PostListResponseSchema = successEnvelopeSchema(PostListDataSchema);
|
|
294
|
+
var PostResponseSchema = successEnvelopeSchema(PostSchema);
|
|
295
|
+
var TikTokPostSettingsSchema = z.object({
|
|
296
|
+
postMode: z.enum(["DIRECT_POST", "MEDIA_UPLOAD"]).default("DIRECT_POST"),
|
|
297
|
+
privacyLevel: z.string().trim().min(1).max(100).nullable().default(null),
|
|
298
|
+
allowComment: z.boolean().default(false),
|
|
299
|
+
allowDuet: z.boolean().default(false),
|
|
300
|
+
allowStitch: z.boolean().default(false),
|
|
301
|
+
commercialContentEnabled: z.boolean().default(false),
|
|
302
|
+
promotesOwnBrand: z.boolean().default(false),
|
|
303
|
+
promotesThirdParty: z.boolean().default(false),
|
|
304
|
+
isAiGenerated: z.boolean().default(false),
|
|
305
|
+
videoCoverTimestampMs: z.number().int().nonnegative().nullable().default(null),
|
|
306
|
+
consentedAt: z.union([z.string().datetime(), z.literal("")]).default("")
|
|
307
|
+
}).strict();
|
|
308
|
+
function youtubeTagLength(tags) {
|
|
309
|
+
return tags.reduce((total, tag, index) => total + (index ? 1 : 0) + tag.length + (tag.includes(" ") ? 2 : 0), 0);
|
|
310
|
+
}
|
|
311
|
+
var YouTubePostSettingsSchema = z.object({
|
|
312
|
+
title: z.string().trim().min(1).max(100).refine(
|
|
313
|
+
(value) => !/[<>]/.test(value),
|
|
314
|
+
"YouTube titles cannot contain angle brackets."
|
|
315
|
+
),
|
|
316
|
+
categoryId: z.string().trim().regex(/^\d+$/).max(20),
|
|
317
|
+
privacyStatus: z.enum(["PUBLIC", "UNLISTED", "PRIVATE"]),
|
|
318
|
+
madeForKids: z.boolean(),
|
|
319
|
+
containsSyntheticMedia: z.boolean().default(false),
|
|
320
|
+
notifySubscribers: z.boolean().default(true),
|
|
321
|
+
tags: z.array(z.string().trim().min(1).max(500)).max(50).refine(
|
|
322
|
+
(tags) => new Set(tags).size === tags.length,
|
|
323
|
+
"YouTube tags must be unique."
|
|
324
|
+
).refine(
|
|
325
|
+
(tags) => youtubeTagLength(tags) <= 500,
|
|
326
|
+
"YouTube tags exceed the 500-character aggregate limit."
|
|
327
|
+
).default([])
|
|
328
|
+
}).strict();
|
|
329
|
+
var blueskyGraphemeSegmenter = new Intl.Segmenter("en", {
|
|
330
|
+
granularity: "grapheme"
|
|
331
|
+
});
|
|
332
|
+
var BlueskyCaptionSchema = z.string().max(3e3).refine(
|
|
333
|
+
(value) => Array.from(blueskyGraphemeSegmenter.segment(value)).length <= 300,
|
|
334
|
+
"Bluesky captions cannot exceed 300 graphemes."
|
|
335
|
+
);
|
|
336
|
+
var utf8Encoder = new TextEncoder();
|
|
337
|
+
var YouTubeDescriptionSchema = z.string().max(5e3).refine(
|
|
338
|
+
(value) => utf8Encoder.encode(value).length <= 5e3,
|
|
339
|
+
"YouTube descriptions cannot exceed 5,000 UTF-8 bytes."
|
|
340
|
+
);
|
|
341
|
+
var DraftCaptionOverridesSchema = z.object({
|
|
342
|
+
INSTAGRAM: z.string().max(2200).nullable().optional(),
|
|
343
|
+
TIKTOK: z.string().max(2200).nullable().optional(),
|
|
344
|
+
YOUTUBE: YouTubeDescriptionSchema.nullable().optional(),
|
|
345
|
+
BLUESKY: BlueskyCaptionSchema.nullable().optional()
|
|
346
|
+
}).strict().default({});
|
|
347
|
+
var DraftPostInputSchema = z.object({
|
|
348
|
+
caption: z.string().max(2200).transform((value) => value.trim()).default(""),
|
|
349
|
+
platforms: z.array(PublishingProviderSchema).max(PUBLISHING_PROVIDER_COUNT).refine(
|
|
350
|
+
(providers) => new Set(providers).size === providers.length,
|
|
351
|
+
"Publishing destinations must be unique."
|
|
352
|
+
).default([]),
|
|
353
|
+
mediaAssetIds: z.array(z.string().trim().min(1).max(200)).max(10).refine(
|
|
354
|
+
(ids) => new Set(ids).size === ids.length,
|
|
355
|
+
"Media asset IDs must be unique."
|
|
356
|
+
).default([]),
|
|
357
|
+
captionOverrides: DraftCaptionOverridesSchema,
|
|
358
|
+
tiktokSettings: TikTokPostSettingsSchema.nullable().default(null),
|
|
359
|
+
youtubeSettings: YouTubePostSettingsSchema.nullable().default(null)
|
|
360
|
+
}).strict().superRefine((input, context) => {
|
|
361
|
+
if (input.caption.length === 0 && input.mediaAssetIds.length === 0) {
|
|
362
|
+
context.addIssue({
|
|
363
|
+
code: "custom",
|
|
364
|
+
path: ["caption"],
|
|
365
|
+
message: "A draft requires a caption or at least one media asset."
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (input.tiktokSettings && !input.platforms.includes("TIKTOK")) {
|
|
369
|
+
context.addIssue({
|
|
370
|
+
code: "custom",
|
|
371
|
+
path: ["tiktokSettings"],
|
|
372
|
+
message: "TikTok settings require the TIKTOK destination."
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (input.youtubeSettings && !input.platforms.includes("YOUTUBE")) {
|
|
376
|
+
context.addIssue({
|
|
377
|
+
code: "custom",
|
|
378
|
+
path: ["youtubeSettings"],
|
|
379
|
+
message: "YouTube settings require the YOUTUBE destination."
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
if (input.platforms.includes("YOUTUBE") && !input.youtubeSettings) {
|
|
383
|
+
context.addIssue({
|
|
384
|
+
code: "custom",
|
|
385
|
+
path: ["youtubeSettings"],
|
|
386
|
+
message: "YouTube settings are required for the YOUTUBE destination."
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
if (input.platforms.includes("YOUTUBE") && input.captionOverrides.YOUTUBE == null && utf8Encoder.encode(input.caption).length > 5e3) {
|
|
390
|
+
context.addIssue({
|
|
391
|
+
code: "custom",
|
|
392
|
+
path: ["caption"],
|
|
393
|
+
message: "YouTube descriptions cannot exceed 5,000 UTF-8 bytes."
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (input.platforms.includes("BLUESKY") && input.captionOverrides.BLUESKY == null && Array.from(blueskyGraphemeSegmenter.segment(input.caption)).length > 300) {
|
|
397
|
+
context.addIssue({
|
|
398
|
+
code: "custom",
|
|
399
|
+
path: ["caption"],
|
|
400
|
+
message: "Bluesky captions cannot exceed 300 graphemes."
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
var IntegrationConnectionStatusSchema = z.enum([
|
|
405
|
+
"PENDING",
|
|
406
|
+
"CONNECTED",
|
|
407
|
+
"ERROR",
|
|
408
|
+
"EXPIRED",
|
|
409
|
+
"DISCONNECTED"
|
|
410
|
+
]);
|
|
411
|
+
var ProviderHealthStatusSchema = z.enum([
|
|
412
|
+
"pass",
|
|
413
|
+
"blocking",
|
|
414
|
+
"unknown"
|
|
415
|
+
]);
|
|
416
|
+
var IntegrationHealthSchema = z.object({
|
|
417
|
+
provider: PublishingProviderSchema,
|
|
418
|
+
connectionStatus: IntegrationConnectionStatusSchema,
|
|
419
|
+
connected: z.boolean(),
|
|
420
|
+
account: z.object({
|
|
421
|
+
username: z.string().nullable(),
|
|
422
|
+
displayName: z.string().nullable(),
|
|
423
|
+
avatarUrl: z.string().url().nullable()
|
|
424
|
+
}),
|
|
425
|
+
grantedScopes: z.array(z.string()),
|
|
426
|
+
expiresAt: z.string().datetime().nullable(),
|
|
427
|
+
health: z.object({
|
|
428
|
+
status: ProviderHealthStatusSchema,
|
|
429
|
+
checkedAt: z.string().datetime().nullable(),
|
|
430
|
+
code: z.string().min(1),
|
|
431
|
+
message: z.string().min(1),
|
|
432
|
+
isStale: z.boolean(),
|
|
433
|
+
requiresAction: z.boolean(),
|
|
434
|
+
refreshRecommended: z.boolean()
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
var IntegrationHealthListDataSchema = z.object({
|
|
438
|
+
items: z.array(IntegrationHealthSchema).max(PUBLISHING_PROVIDER_COUNT).refine(
|
|
439
|
+
(items) => new Set(items.map((item) => item.provider)).size === items.length,
|
|
440
|
+
"Provider health items must be unique."
|
|
441
|
+
)
|
|
442
|
+
});
|
|
443
|
+
var IntegrationHealthListResponseSchema = successEnvelopeSchema(
|
|
444
|
+
IntegrationHealthListDataSchema
|
|
445
|
+
);
|
|
446
|
+
var ReadinessStatusSchema = z.enum([
|
|
447
|
+
"checking",
|
|
448
|
+
"pass",
|
|
449
|
+
"warning",
|
|
450
|
+
"blocking",
|
|
451
|
+
"unknown"
|
|
452
|
+
]);
|
|
453
|
+
var ReadinessActionSchema = z.object({
|
|
454
|
+
kind: z.enum([
|
|
455
|
+
"reconnect",
|
|
456
|
+
"replace_media",
|
|
457
|
+
"review_settings",
|
|
458
|
+
"edit_caption",
|
|
459
|
+
"refresh_health"
|
|
460
|
+
]),
|
|
461
|
+
provider: PublishingProviderSchema.optional()
|
|
462
|
+
});
|
|
463
|
+
var PostReadinessCheckSchema = z.object({
|
|
464
|
+
key: z.string().min(1),
|
|
465
|
+
id: z.enum([
|
|
466
|
+
"connection",
|
|
467
|
+
"permissions",
|
|
468
|
+
"media",
|
|
469
|
+
"caption",
|
|
470
|
+
"tiktok_settings",
|
|
471
|
+
"youtube_settings",
|
|
472
|
+
"storage",
|
|
473
|
+
"schedule_lead",
|
|
474
|
+
"token_health",
|
|
475
|
+
"media_duration",
|
|
476
|
+
"provider_health"
|
|
477
|
+
]),
|
|
478
|
+
provider: PublishingProviderSchema.nullable(),
|
|
479
|
+
mediaId: z.string().min(1).optional(),
|
|
480
|
+
status: ReadinessStatusSchema,
|
|
481
|
+
source: z.enum(["local", "live"]),
|
|
482
|
+
checkedAt: z.string().datetime().nullable(),
|
|
483
|
+
message: z.string().min(1),
|
|
484
|
+
code: z.string().min(1),
|
|
485
|
+
action: ReadinessActionSchema.nullable()
|
|
486
|
+
});
|
|
487
|
+
var PostReadinessSchema = z.object({
|
|
488
|
+
checks: z.array(PostReadinessCheckSchema),
|
|
489
|
+
accounts: z.array(z.object({
|
|
490
|
+
provider: PublishingProviderSchema,
|
|
491
|
+
connected: z.boolean(),
|
|
492
|
+
username: z.string().nullable(),
|
|
493
|
+
avatarUrl: z.string().url().nullable(),
|
|
494
|
+
requiresAction: z.boolean()
|
|
495
|
+
})),
|
|
496
|
+
hasBlockingChecks: z.boolean(),
|
|
497
|
+
requiresLiveRefresh: z.array(PublishingProviderSchema),
|
|
498
|
+
liveHealthCheckedAt: z.string().datetime().nullable()
|
|
499
|
+
});
|
|
500
|
+
var PostReadinessResponseSchema = successEnvelopeSchema(
|
|
501
|
+
PostReadinessSchema
|
|
502
|
+
);
|
|
503
|
+
var PostScheduleInputSchema = z.object({
|
|
504
|
+
scheduledAt: z.string().datetime({ offset: true }),
|
|
505
|
+
timezone: z.string().trim().min(1).max(100).refine((timezone) => {
|
|
506
|
+
try {
|
|
507
|
+
new Intl.DateTimeFormat("en", { timeZone: timezone }).format();
|
|
508
|
+
return true;
|
|
509
|
+
} catch {
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
}, "timezone must be a valid IANA timezone")
|
|
513
|
+
}).strict();
|
|
514
|
+
var PostScheduleExecuteInputSchema = PostScheduleInputSchema.extend({
|
|
515
|
+
confirmationToken: z.string().trim().min(1).max(200)
|
|
516
|
+
}).strict();
|
|
517
|
+
var PostSchedulePreviewSchema = z.object({
|
|
518
|
+
operation: z.literal("posts.schedule.execute"),
|
|
519
|
+
post: z.object({
|
|
520
|
+
id: z.string().min(1),
|
|
521
|
+
projectId: z.string().min(1),
|
|
522
|
+
version: z.number().int().positive(),
|
|
523
|
+
status: PostStatusSchema
|
|
524
|
+
}),
|
|
525
|
+
schedule: PostScheduleInputSchema,
|
|
526
|
+
destinations: z.array(PublishingProviderSchema).min(1).max(PUBLISHING_PROVIDER_COUNT),
|
|
527
|
+
providerReconciliation: z.object({
|
|
528
|
+
provider: z.literal("YOUTUBE"),
|
|
529
|
+
required: z.boolean(),
|
|
530
|
+
message: z.string().min(1)
|
|
531
|
+
}).nullable().optional(),
|
|
532
|
+
readiness: PostReadinessSchema,
|
|
533
|
+
confirmation: z.object({
|
|
534
|
+
token: z.string().min(1),
|
|
535
|
+
expiresAt: z.string().datetime()
|
|
536
|
+
})
|
|
537
|
+
});
|
|
538
|
+
var PostSchedulePreviewResponseSchema = successEnvelopeSchema(
|
|
539
|
+
PostSchedulePreviewSchema
|
|
540
|
+
);
|
|
541
|
+
var PostSchedulePendingSchema = z.object({
|
|
542
|
+
status: z.literal("PENDING"),
|
|
543
|
+
postId: z.string().min(1),
|
|
544
|
+
provider: z.literal("YOUTUBE"),
|
|
545
|
+
mutationId: z.string().min(1),
|
|
546
|
+
operation: z.enum(["SCHEDULE", "CANCEL"]),
|
|
547
|
+
message: z.string().min(1)
|
|
548
|
+
});
|
|
549
|
+
var PostScheduleExecuteResultSchema = z.union([
|
|
550
|
+
PostSchema,
|
|
551
|
+
PostSchedulePendingSchema
|
|
552
|
+
]);
|
|
553
|
+
var PostScheduleExecuteResponseSchema = successEnvelopeSchema(
|
|
554
|
+
PostScheduleExecuteResultSchema
|
|
555
|
+
);
|
|
556
|
+
var PostPublishInputSchema = z.object({
|
|
557
|
+
destinations: z.array(PublishingProviderSchema).min(1).max(PUBLISHING_PROVIDER_COUNT).refine(
|
|
558
|
+
(destinations) => new Set(destinations).size === destinations.length,
|
|
559
|
+
"destinations must not contain duplicates"
|
|
560
|
+
)
|
|
561
|
+
}).strict();
|
|
562
|
+
var PostPublishExecuteInputSchema = PostPublishInputSchema.extend({
|
|
563
|
+
confirmationToken: z.string().trim().min(1).max(200)
|
|
564
|
+
}).strict();
|
|
565
|
+
var PostPublishPreviewSchema = z.object({
|
|
566
|
+
operation: z.literal("posts.publish.execute"),
|
|
567
|
+
post: z.object({
|
|
568
|
+
id: z.string().min(1),
|
|
569
|
+
projectId: z.string().min(1),
|
|
570
|
+
version: z.number().int().positive(),
|
|
571
|
+
status: PostStatusSchema
|
|
572
|
+
}),
|
|
573
|
+
destinations: PostPublishInputSchema.shape.destinations,
|
|
574
|
+
readiness: PostReadinessSchema,
|
|
575
|
+
confirmation: z.object({
|
|
576
|
+
token: z.string().min(1),
|
|
577
|
+
expiresAt: z.string().datetime()
|
|
578
|
+
})
|
|
579
|
+
});
|
|
580
|
+
var PostPublishPreviewResponseSchema = successEnvelopeSchema(
|
|
581
|
+
PostPublishPreviewSchema
|
|
582
|
+
);
|
|
583
|
+
var CalendarEventSchema = z.object({
|
|
584
|
+
postId: z.string().min(1),
|
|
585
|
+
projectId: z.string().min(1),
|
|
586
|
+
title: z.string().min(1),
|
|
587
|
+
caption: z.string(),
|
|
588
|
+
status: PostStatusSchema.exclude(["DRAFT"]),
|
|
589
|
+
scheduledAt: z.string().datetime(),
|
|
590
|
+
timezone: z.string().nullable(),
|
|
591
|
+
campaign: z.object({
|
|
592
|
+
id: z.string().min(1),
|
|
593
|
+
title: z.string().min(1)
|
|
594
|
+
}).nullable(),
|
|
595
|
+
thumbnailUrl: z.string().url().nullable(),
|
|
596
|
+
destinations: z.array(z.object({
|
|
597
|
+
provider: PublishingProviderSchema,
|
|
598
|
+
status: PlatformPostStatusSchema
|
|
599
|
+
}))
|
|
600
|
+
});
|
|
601
|
+
var CalendarListQuerySchema = z.object({
|
|
602
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
603
|
+
cursor: z.string().min(1).optional(),
|
|
604
|
+
from: z.string().datetime().optional(),
|
|
605
|
+
to: z.string().datetime().optional()
|
|
606
|
+
}).superRefine((value, context) => {
|
|
607
|
+
if (value.from === void 0 !== (value.to === void 0)) {
|
|
608
|
+
context.addIssue({
|
|
609
|
+
code: "custom",
|
|
610
|
+
path: value.from === void 0 ? ["from"] : ["to"],
|
|
611
|
+
message: "from and to must be provided together"
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
if (value.from && value.to) {
|
|
615
|
+
const from = Date.parse(value.from);
|
|
616
|
+
const to = Date.parse(value.to);
|
|
617
|
+
if (from >= to) {
|
|
618
|
+
context.addIssue({
|
|
619
|
+
code: "custom",
|
|
620
|
+
path: ["to"],
|
|
621
|
+
message: "to must be later than from"
|
|
622
|
+
});
|
|
623
|
+
} else if (to - from > 366 * 24 * 60 * 60 * 1e3) {
|
|
624
|
+
context.addIssue({
|
|
625
|
+
code: "custom",
|
|
626
|
+
path: ["to"],
|
|
627
|
+
message: "calendar ranges cannot exceed 366 days"
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
var CalendarListDataSchema = z.object({
|
|
633
|
+
items: z.array(CalendarEventSchema),
|
|
634
|
+
page: z.object({
|
|
635
|
+
limit: z.number().int().min(1).max(100),
|
|
636
|
+
nextCursor: z.string().min(1).nullable()
|
|
637
|
+
}),
|
|
638
|
+
window: z.object({
|
|
639
|
+
from: z.string().datetime(),
|
|
640
|
+
to: z.string().datetime()
|
|
641
|
+
})
|
|
642
|
+
});
|
|
643
|
+
var CalendarListResponseSchema = successEnvelopeSchema(
|
|
644
|
+
CalendarListDataSchema
|
|
645
|
+
);
|
|
646
|
+
export {
|
|
647
|
+
API_VERSION,
|
|
648
|
+
ActorSchema,
|
|
649
|
+
ApiErrorCodeSchema,
|
|
650
|
+
ApiMetaResponseSchema,
|
|
651
|
+
ApiMetaSchema,
|
|
652
|
+
ApiProblemSchema,
|
|
653
|
+
AuthenticationKindSchema,
|
|
654
|
+
CLI_BROWSER_AUTHORIZATION_TIMEOUT_MS,
|
|
655
|
+
CONTRACT_VERSION,
|
|
656
|
+
CalendarEventSchema,
|
|
657
|
+
CalendarListDataSchema,
|
|
658
|
+
CalendarListQuerySchema,
|
|
659
|
+
CalendarListResponseSchema,
|
|
660
|
+
CapabilitiesDataSchema,
|
|
661
|
+
CapabilitiesResponseSchema,
|
|
662
|
+
CapabilityIdSchema,
|
|
663
|
+
CapabilitySchema,
|
|
664
|
+
CliAuthorizationCredentialSchema,
|
|
665
|
+
CliAuthorizationExchangeRequestSchema,
|
|
666
|
+
CliAuthorizationExchangeResponseSchema,
|
|
667
|
+
CliAuthorizationRevokeDataSchema,
|
|
668
|
+
CliAuthorizationRevokeResponseSchema,
|
|
669
|
+
DraftPostInputSchema,
|
|
670
|
+
IntegrationConnectionStatusSchema,
|
|
671
|
+
IntegrationHealthListDataSchema,
|
|
672
|
+
IntegrationHealthListResponseSchema,
|
|
673
|
+
IntegrationHealthSchema,
|
|
674
|
+
MediaAssetListDataSchema,
|
|
675
|
+
MediaAssetListQuerySchema,
|
|
676
|
+
MediaAssetListResponseSchema,
|
|
677
|
+
MediaAssetResponseSchema,
|
|
678
|
+
MediaAssetSchema,
|
|
679
|
+
MediaAssetUploadCompleteInputSchema,
|
|
680
|
+
MediaAssetUploadInputSchema,
|
|
681
|
+
MediaAssetUploadPreparationResponseSchema,
|
|
682
|
+
MediaAssetUploadPreparationSchema,
|
|
683
|
+
PUBLISHING_PROVIDER_COUNT,
|
|
684
|
+
PlatformPostStatusSchema,
|
|
685
|
+
PostDestinationSchema,
|
|
686
|
+
PostListDataSchema,
|
|
687
|
+
PostListQuerySchema,
|
|
688
|
+
PostListResponseSchema,
|
|
689
|
+
PostMediaSchema,
|
|
690
|
+
PostPublishExecuteInputSchema,
|
|
691
|
+
PostPublishInputSchema,
|
|
692
|
+
PostPublishPreviewResponseSchema,
|
|
693
|
+
PostPublishPreviewSchema,
|
|
694
|
+
PostReadinessCheckSchema,
|
|
695
|
+
PostReadinessResponseSchema,
|
|
696
|
+
PostReadinessSchema,
|
|
697
|
+
PostResponseSchema,
|
|
698
|
+
PostScheduleExecuteInputSchema,
|
|
699
|
+
PostScheduleExecuteResponseSchema,
|
|
700
|
+
PostScheduleExecuteResultSchema,
|
|
701
|
+
PostScheduleInputSchema,
|
|
702
|
+
PostSchedulePendingSchema,
|
|
703
|
+
PostSchedulePreviewResponseSchema,
|
|
704
|
+
PostSchedulePreviewSchema,
|
|
705
|
+
PostSchema,
|
|
706
|
+
PostStatusSchema,
|
|
707
|
+
ProjectCreateInputSchema,
|
|
708
|
+
ProjectListDataSchema,
|
|
709
|
+
ProjectListQuerySchema,
|
|
710
|
+
ProjectListResponseSchema,
|
|
711
|
+
ProjectResponseSchema,
|
|
712
|
+
ProjectSchema,
|
|
713
|
+
ProjectTypeSchema,
|
|
714
|
+
ProviderHealthStatusSchema,
|
|
715
|
+
PublishingProviderSchema,
|
|
716
|
+
ReadinessActionSchema,
|
|
717
|
+
ReadinessStatusSchema,
|
|
718
|
+
RequestMetadataSchema,
|
|
719
|
+
TikTokPostSettingsSchema,
|
|
720
|
+
WhoAmIResponseSchema,
|
|
721
|
+
YouTubePostSettingsSchema,
|
|
722
|
+
successEnvelopeSchema
|
|
723
|
+
};
|
|
724
|
+
//# sourceMappingURL=index.js.map
|