@verbatims/sdk 1.6.14 → 1.6.16
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/README.md +31 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +1 -0
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/search.d.ts +29 -5
- package/dist/resources/search.d.ts.map +1 -1
- package/dist/resources/search.js +21 -6
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/social.d.ts +272 -0
- package/dist/resources/social.d.ts.map +1 -0
- package/dist/resources/social.js +153 -0
- package/dist/resources/social.js.map +1 -0
- package/dist/types.d.ts +110 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +20 -0
- package/src/resources/__tests__/resources.test.ts +250 -0
- package/src/resources/index.ts +1 -0
- package/src/resources/search.ts +25 -7
- package/src/resources/social.ts +190 -0
- package/src/types.ts +127 -0
package/src/resources/search.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { apiResponseSchema } from '../types'
|
|
|
4
4
|
import { paginate } from '../pagination'
|
|
5
5
|
import type { SearchParams } from '../types'
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const searchAuthorRefSchema = z.object({
|
|
8
8
|
id: z.number(),
|
|
9
9
|
name: z.string(),
|
|
10
10
|
fictional: z.boolean().optional(),
|
|
@@ -12,24 +12,42 @@ const searchAuthorSchema = z.object({
|
|
|
12
12
|
job: z.string().nullable().optional(),
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const searchQuoteRefSchema = z.object({
|
|
16
16
|
id: z.number(),
|
|
17
17
|
name: z.string(),
|
|
18
18
|
type: z.string().optional(),
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const searchQuoteItemSchema = z.object({
|
|
22
22
|
id: z.number(),
|
|
23
23
|
content: z.string(),
|
|
24
24
|
language: z.string(),
|
|
25
|
-
author:
|
|
26
|
-
reference:
|
|
25
|
+
author: searchAuthorRefSchema.nullable().optional(),
|
|
26
|
+
reference: searchQuoteRefSchema.nullable().optional(),
|
|
27
27
|
created_at: z.string().nullable(),
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const searchAuthorItemSchema = z.object({
|
|
31
|
+
id: z.number(),
|
|
32
|
+
name: z.string(),
|
|
33
|
+
image_url: z.string().nullable().optional(),
|
|
34
|
+
job: z.string().nullable().optional(),
|
|
35
|
+
type: z.literal('author').optional(),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const searchReferenceItemSchema = z.object({
|
|
39
|
+
id: z.number(),
|
|
40
|
+
name: z.string(),
|
|
41
|
+
type: z.string().optional(),
|
|
42
|
+
image_url: z.string().nullable().optional(),
|
|
43
|
+
entity_type: z.literal('reference').optional(),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const searchResultSchema = z.union([searchQuoteItemSchema, searchAuthorItemSchema, searchReferenceItemSchema])
|
|
47
|
+
|
|
48
|
+
type SearchResultItem = z.infer<typeof searchResultSchema>
|
|
31
49
|
|
|
32
|
-
const searchResponseSchema = apiResponseSchema(z.array(
|
|
50
|
+
const searchResponseSchema = apiResponseSchema(z.array(searchResultSchema))
|
|
33
51
|
|
|
34
52
|
export class SearchResource {
|
|
35
53
|
constructor(private client: VerbatimsClient) {}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { z } from 'zod/v4'
|
|
2
|
+
import type { VerbatimsClient } from '../client'
|
|
3
|
+
import { apiResponseSchema } from '../types'
|
|
4
|
+
import { paginate } from '../pagination'
|
|
5
|
+
import type {
|
|
6
|
+
SocialQueueItem,
|
|
7
|
+
ListSocialQueueParams,
|
|
8
|
+
ListSocialPostsParams,
|
|
9
|
+
AddToSocialQueueData,
|
|
10
|
+
AddRandomToSocialQueueData,
|
|
11
|
+
ClearSocialQueueData,
|
|
12
|
+
ReorderSocialQueueData,
|
|
13
|
+
RunSocialAutopostData,
|
|
14
|
+
} from '../types'
|
|
15
|
+
|
|
16
|
+
const socialQueueStatsSchema = z.object({
|
|
17
|
+
queued: z.number(),
|
|
18
|
+
processing: z.number(),
|
|
19
|
+
posted: z.number(),
|
|
20
|
+
failed: z.number(),
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const socialResolvedContentSchema = z.object({
|
|
24
|
+
source_type: z.string(),
|
|
25
|
+
source_id: z.number(),
|
|
26
|
+
primary_text: z.string().nullable(),
|
|
27
|
+
secondary_text: z.string().nullable(),
|
|
28
|
+
canonical_path: z.string().nullable(),
|
|
29
|
+
title: z.string().nullable(),
|
|
30
|
+
subtitle: z.string().nullable(),
|
|
31
|
+
language: z.string().nullable(),
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const socialQueueItemSchema = z.object({
|
|
35
|
+
id: z.number(),
|
|
36
|
+
quote_id: z.number(),
|
|
37
|
+
source_type: z.string(),
|
|
38
|
+
source_id: z.number(),
|
|
39
|
+
platform: z.enum(['x', 'bluesky', 'instagram', 'threads', 'facebook', 'pinterest']),
|
|
40
|
+
status: z.enum(['queued', 'processing', 'posted', 'failed']),
|
|
41
|
+
position: z.number(),
|
|
42
|
+
scheduled_for: z.string().nullable(),
|
|
43
|
+
created_at: z.string().nullable(),
|
|
44
|
+
updated_at: z.string().nullable(),
|
|
45
|
+
published_post_url: z.string().nullable(),
|
|
46
|
+
published_external_post_id: z.string().nullable(),
|
|
47
|
+
published_posted_at: z.string().nullable(),
|
|
48
|
+
error_message: z.string().nullable(),
|
|
49
|
+
quote_posts_count: z.number(),
|
|
50
|
+
quote_text: z.string().nullable(),
|
|
51
|
+
quote_language: z.string().nullable(),
|
|
52
|
+
author_name: z.string().nullable(),
|
|
53
|
+
reference_name: z.string().nullable(),
|
|
54
|
+
resolved_content: socialResolvedContentSchema.nullable(),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const socialPostSchema = z.object({
|
|
58
|
+
id: z.number(),
|
|
59
|
+
quote_id: z.number(),
|
|
60
|
+
source_type: z.string(),
|
|
61
|
+
source_id: z.number(),
|
|
62
|
+
queue_id: z.number().nullable(),
|
|
63
|
+
platform: z.enum(['x', 'bluesky', 'instagram', 'threads', 'facebook', 'pinterest']),
|
|
64
|
+
status: z.enum(['success', 'failed']),
|
|
65
|
+
post_text: z.string().nullable(),
|
|
66
|
+
post_url: z.string().nullable(),
|
|
67
|
+
external_post_id: z.string().nullable(),
|
|
68
|
+
error_message: z.string().nullable(),
|
|
69
|
+
posted_at: z.string().nullable(),
|
|
70
|
+
created_at: z.string().nullable(),
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const socialPlatformSchema = z.object({
|
|
74
|
+
platform: z.enum(['x', 'bluesky', 'instagram', 'threads', 'facebook', 'pinterest']),
|
|
75
|
+
label: z.string(),
|
|
76
|
+
enabled: z.boolean(),
|
|
77
|
+
queue: socialQueueStatsSchema,
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
const queuedItemSchema = z.object({
|
|
81
|
+
id: z.number(),
|
|
82
|
+
quote_id: z.number(),
|
|
83
|
+
source_type: z.string(),
|
|
84
|
+
source_id: z.number(),
|
|
85
|
+
position: z.number(),
|
|
86
|
+
status: z.enum(['queued', 'processing', 'posted', 'failed']).optional(),
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const socialQueueListResponseSchema = apiResponseSchema(z.object({
|
|
90
|
+
queue: z.array(socialQueueItemSchema),
|
|
91
|
+
stats: socialQueueStatsSchema,
|
|
92
|
+
}))
|
|
93
|
+
|
|
94
|
+
const socialPostsListResponseSchema = apiResponseSchema(z.object({
|
|
95
|
+
posts: z.array(socialPostSchema),
|
|
96
|
+
}))
|
|
97
|
+
|
|
98
|
+
const socialPlatformsResponseSchema = apiResponseSchema(z.array(socialPlatformSchema))
|
|
99
|
+
|
|
100
|
+
const enqueueResponseSchema = apiResponseSchema(z.array(queuedItemSchema)).extend({
|
|
101
|
+
count: z.number().optional(),
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
const deleteQueueItemResponseSchema = apiResponseSchema(z.object({
|
|
105
|
+
deleted: z.literal(true),
|
|
106
|
+
id: z.number(),
|
|
107
|
+
sourceType: z.string(),
|
|
108
|
+
sourceId: z.number(),
|
|
109
|
+
}))
|
|
110
|
+
|
|
111
|
+
const clearQueueResponseSchema = apiResponseSchema(z.object({
|
|
112
|
+
deleted: z.literal(true),
|
|
113
|
+
platform: z.string(),
|
|
114
|
+
deletedCount: z.number(),
|
|
115
|
+
sourceTypes: z.array(z.object({
|
|
116
|
+
sourceType: z.string(),
|
|
117
|
+
count: z.number(),
|
|
118
|
+
})),
|
|
119
|
+
}))
|
|
120
|
+
|
|
121
|
+
const reorderQueueResponseSchema = apiResponseSchema(z.object({
|
|
122
|
+
moved: z.boolean(),
|
|
123
|
+
id: z.number().optional(),
|
|
124
|
+
sourceType: z.string().optional(),
|
|
125
|
+
sourceId: z.number().optional(),
|
|
126
|
+
position: z.number().optional(),
|
|
127
|
+
}))
|
|
128
|
+
|
|
129
|
+
const requeueQueueItemResponseSchema = apiResponseSchema(z.object({
|
|
130
|
+
requeued: z.literal(true),
|
|
131
|
+
id: z.number(),
|
|
132
|
+
}))
|
|
133
|
+
|
|
134
|
+
export class SocialResource {
|
|
135
|
+
constructor(private client: VerbatimsClient) {}
|
|
136
|
+
|
|
137
|
+
async listPlatforms() {
|
|
138
|
+
return this.client.get('/social/platforms', {}, socialPlatformsResponseSchema)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async listQueue(params?: ListSocialQueueParams) {
|
|
142
|
+
return this.client.get('/social/queue', { params: params as Record<string, unknown> }, socialQueueListResponseSchema)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
paginateQueue(params?: ListSocialQueueParams): AsyncGenerator<SocialQueueItem> {
|
|
146
|
+
return paginate<SocialQueueItem>((page) =>
|
|
147
|
+
this.listQueue({ ...params, page }).then(r => ({
|
|
148
|
+
data: r.data?.queue,
|
|
149
|
+
pagination: r.pagination,
|
|
150
|
+
}))
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async getQueueItem(id: number) {
|
|
155
|
+
return this.client.get(`/social/queue/${id}`, {}, apiResponseSchema(socialQueueItemSchema))
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async addToQueue(data: AddToSocialQueueData) {
|
|
159
|
+
return this.client.post('/social/queue', data, {}, enqueueResponseSchema)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async addRandomToQueue(data: AddRandomToSocialQueueData) {
|
|
163
|
+
return this.client.post('/social/queue/bulk-random', data, {}, enqueueResponseSchema)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async removeQueueItem(id: number) {
|
|
167
|
+
return this.client.delete(`/social/queue/${id}`, {}, deleteQueueItemResponseSchema)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async clearQueue(data: ClearSocialQueueData) {
|
|
171
|
+
return this.client.post('/social/queue/clear', data, {}, clearQueueResponseSchema)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async reorderQueueItem(data: ReorderSocialQueueData) {
|
|
175
|
+
return this.client.post('/social/queue/reorder', data, {}, reorderQueueResponseSchema)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async runNow(data?: RunSocialAutopostData) {
|
|
179
|
+
return this.client.post('/social/queue/run-now', data ?? {}, {}, apiResponseSchema(z.record(z.string(), z.unknown())))
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async requeueQueueItem(id: number) {
|
|
183
|
+
return this.client.post(`/social/queue/${id}/requeue`, {}, {}, requeueQueueItemResponseSchema)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async listPosts(params?: ListSocialPostsParams) {
|
|
187
|
+
return this.client.get('/social/posts', { params: params as Record<string, unknown> }, socialPostsListResponseSchema)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
package/src/types.ts
CHANGED
|
@@ -451,3 +451,130 @@ export interface ThemeSuggestionsQuery {
|
|
|
451
451
|
tags?: string
|
|
452
452
|
language?: string
|
|
453
453
|
}
|
|
454
|
+
|
|
455
|
+
// --- Social queue / auto-post types ---
|
|
456
|
+
|
|
457
|
+
export type SocialPlatform = 'x' | 'bluesky' | 'instagram' | 'threads' | 'facebook' | 'pinterest'
|
|
458
|
+
export type SocialQueueStatus = 'queued' | 'processing' | 'posted' | 'failed'
|
|
459
|
+
export type SocialPostStatus = 'success' | 'failed'
|
|
460
|
+
|
|
461
|
+
export interface SocialQueueStats {
|
|
462
|
+
queued: number
|
|
463
|
+
processing: number
|
|
464
|
+
posted: number
|
|
465
|
+
failed: number
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface SocialPlatformInfo {
|
|
469
|
+
platform: SocialPlatform
|
|
470
|
+
label: string
|
|
471
|
+
enabled: boolean
|
|
472
|
+
queue: SocialQueueStats
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export interface SocialResolvedContent {
|
|
476
|
+
source_type: string
|
|
477
|
+
source_id: number
|
|
478
|
+
primary_text: string | null
|
|
479
|
+
secondary_text: string | null
|
|
480
|
+
canonical_path: string | null
|
|
481
|
+
title: string | null
|
|
482
|
+
subtitle: string | null
|
|
483
|
+
language: string | null
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export interface SocialQueueItem {
|
|
487
|
+
id: number
|
|
488
|
+
quote_id: number
|
|
489
|
+
source_type: string
|
|
490
|
+
source_id: number
|
|
491
|
+
platform: SocialPlatform
|
|
492
|
+
status: SocialQueueStatus
|
|
493
|
+
position: number
|
|
494
|
+
scheduled_for: string | null
|
|
495
|
+
created_at: string | null
|
|
496
|
+
updated_at: string | null
|
|
497
|
+
published_post_url: string | null
|
|
498
|
+
published_external_post_id: string | null
|
|
499
|
+
published_posted_at: string | null
|
|
500
|
+
error_message: string | null
|
|
501
|
+
quote_posts_count: number
|
|
502
|
+
quote_text: string | null
|
|
503
|
+
quote_language: string | null
|
|
504
|
+
author_name: string | null
|
|
505
|
+
reference_name: string | null
|
|
506
|
+
resolved_content: SocialResolvedContent | null
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export interface SocialPost {
|
|
510
|
+
id: number
|
|
511
|
+
quote_id: number
|
|
512
|
+
source_type: string
|
|
513
|
+
source_id: number
|
|
514
|
+
queue_id: number | null
|
|
515
|
+
platform: SocialPlatform
|
|
516
|
+
status: SocialPostStatus
|
|
517
|
+
post_text: string | null
|
|
518
|
+
post_url: string | null
|
|
519
|
+
external_post_id: string | null
|
|
520
|
+
error_message: string | null
|
|
521
|
+
posted_at: string | null
|
|
522
|
+
created_at: string | null
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export interface QueuedSocialItem {
|
|
526
|
+
id: number
|
|
527
|
+
quote_id: number
|
|
528
|
+
source_type: string
|
|
529
|
+
source_id: number
|
|
530
|
+
position: number
|
|
531
|
+
status?: SocialQueueStatus
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export interface ListSocialQueueParams {
|
|
535
|
+
page?: number
|
|
536
|
+
limit?: number
|
|
537
|
+
platform?: SocialPlatform
|
|
538
|
+
status?: SocialQueueStatus | 'active'
|
|
539
|
+
search?: string
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export interface ListSocialPostsParams {
|
|
543
|
+
page?: number
|
|
544
|
+
limit?: number
|
|
545
|
+
platform?: SocialPlatform
|
|
546
|
+
status?: SocialPostStatus
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export interface AddToSocialQueueData {
|
|
550
|
+
quote_ids: number[]
|
|
551
|
+
platform?: SocialPlatform
|
|
552
|
+
scheduled_for?: string | null
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export interface AddRandomToSocialQueueData {
|
|
556
|
+
platform?: SocialPlatform
|
|
557
|
+
count?: number
|
|
558
|
+
language?: string
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export interface ClearSocialQueueData {
|
|
562
|
+
platform: SocialPlatform
|
|
563
|
+
confirm: boolean
|
|
564
|
+
scope?: 'all' | 'finished'
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export interface ReorderSocialQueueData {
|
|
568
|
+
id: number
|
|
569
|
+
direction?: 'up' | 'down'
|
|
570
|
+
before_id?: number | null
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export interface RunSocialAutopostData {
|
|
574
|
+
platform?: SocialPlatform
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export interface SocialQueueListResult {
|
|
578
|
+
queue: SocialQueueItem[]
|
|
579
|
+
stats: SocialQueueStats
|
|
580
|
+
}
|