@inblog/cli 0.2.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.
@@ -0,0 +1,514 @@
1
+ interface JsonApiResource {
2
+ type: string;
3
+ id: string;
4
+ attributes: Record<string, any>;
5
+ relationships?: Record<string, {
6
+ data: {
7
+ type: string;
8
+ id: string;
9
+ } | {
10
+ type: string;
11
+ id: string;
12
+ }[] | null;
13
+ }>;
14
+ links?: {
15
+ self: string;
16
+ };
17
+ }
18
+ interface JsonApiResponse<T = JsonApiResource | JsonApiResource[]> {
19
+ jsonapi: {
20
+ version: '1.0';
21
+ };
22
+ data: T;
23
+ included?: JsonApiResource[];
24
+ meta?: Record<string, any>;
25
+ links?: {
26
+ self: string;
27
+ next?: string;
28
+ prev?: string;
29
+ first?: string;
30
+ last?: string;
31
+ };
32
+ }
33
+ interface JsonApiError {
34
+ status: string;
35
+ code: string;
36
+ title: string;
37
+ detail?: string;
38
+ meta?: Record<string, any>;
39
+ }
40
+ interface JsonApiErrorResponse {
41
+ jsonapi: {
42
+ version: '1.0';
43
+ };
44
+ errors: JsonApiError[];
45
+ }
46
+ interface Post {
47
+ id: string;
48
+ title: string;
49
+ slug: string;
50
+ description: string | null;
51
+ content_html: string | null;
52
+ content_type: 'tiptap' | 'notion';
53
+ published: boolean;
54
+ published_at: string | null;
55
+ image: {
56
+ url: string;
57
+ blurhash?: string;
58
+ created_at?: string;
59
+ } | null;
60
+ canonical_url: string | null;
61
+ notion_url: string | null;
62
+ meta_title: string | null;
63
+ meta_description: string | null;
64
+ cta_text: string | null;
65
+ cta_link: string | null;
66
+ cta_color: string | null;
67
+ cta_text_color: string | null;
68
+ custom_scripts: {
69
+ head_start_script: string | null;
70
+ head_end_script: string | null;
71
+ body_start_script: string | null;
72
+ body_end_script: string | null;
73
+ json_ld_script: string | null;
74
+ } | null;
75
+ tags?: Tag[];
76
+ authors?: Author[];
77
+ }
78
+ interface Tag {
79
+ id: string;
80
+ name: string;
81
+ slug: string;
82
+ priority: number;
83
+ }
84
+ interface Author {
85
+ id: string;
86
+ author_name: string;
87
+ avatar_url: string | null;
88
+ }
89
+ interface Blog {
90
+ id: number;
91
+ title: string;
92
+ subdomain: string;
93
+ description: string | null;
94
+ custom_domain: string | null;
95
+ custom_domain_verified: boolean;
96
+ custom_subdirectory: string | null;
97
+ logo: string | null;
98
+ logo_url: string | null;
99
+ favicon: string | null;
100
+ og_image: string | null;
101
+ blog_language: string;
102
+ timezone_diff: number;
103
+ plan: string;
104
+ ga_measurement_id: string | null;
105
+ is_search_console_connected: boolean;
106
+ search_console_url: string | null;
107
+ created_at: string;
108
+ updated_at: string;
109
+ }
110
+ interface Redirect {
111
+ id: string;
112
+ from_path: string;
113
+ to_path: string;
114
+ redirect_type: 307 | 308;
115
+ created_at: string;
116
+ updated_at: string;
117
+ }
118
+ interface Form {
119
+ id: string;
120
+ title: string;
121
+ form_setting: any;
122
+ magnet_type: string | null;
123
+ magnet_url: string | null;
124
+ magnet_file_src: string | null;
125
+ submit_email_setting: any;
126
+ thx_msg_setting: any;
127
+ created_at: string;
128
+ response_count: number;
129
+ }
130
+ interface FormResponse {
131
+ id: string;
132
+ email: string;
133
+ response: any;
134
+ country: string | null;
135
+ city: string | null;
136
+ region: string | null;
137
+ timezone: string | null;
138
+ language: string | null;
139
+ created_at: string;
140
+ }
141
+ interface PostCreateInput {
142
+ title: string;
143
+ slug?: string;
144
+ description?: string;
145
+ content_html?: string;
146
+ published?: boolean;
147
+ published_at?: string;
148
+ image?: {
149
+ url: string;
150
+ blurhash?: string;
151
+ created_at?: string;
152
+ };
153
+ canonical_url?: string;
154
+ notion_url?: string;
155
+ meta_title?: string;
156
+ meta_description?: string;
157
+ cta_text?: string;
158
+ cta_link?: string;
159
+ cta_color?: string;
160
+ cta_text_color?: string;
161
+ tag_ids?: number[];
162
+ author_ids?: string[];
163
+ }
164
+ interface PostUpdateInput {
165
+ title?: string;
166
+ slug?: string;
167
+ description?: string;
168
+ content_html?: string;
169
+ published?: boolean;
170
+ published_at?: string;
171
+ image?: {
172
+ url: string;
173
+ blurhash?: string;
174
+ created_at?: string;
175
+ } | null;
176
+ canonical_url?: string | null;
177
+ notion_url?: string;
178
+ meta_title?: string | null;
179
+ meta_description?: string | null;
180
+ cta_text?: string | null;
181
+ cta_link?: string | null;
182
+ cta_color?: string | null;
183
+ cta_text_color?: string | null;
184
+ }
185
+ interface TagCreateInput {
186
+ name: string;
187
+ slug?: string;
188
+ priority?: number;
189
+ }
190
+ interface TagUpdateInput {
191
+ name?: string;
192
+ slug?: string;
193
+ priority?: number;
194
+ }
195
+ interface RedirectCreateInput {
196
+ from_path: string;
197
+ to_path: string;
198
+ redirect_type?: 307 | 308;
199
+ }
200
+ interface RedirectUpdateInput {
201
+ from_path?: string;
202
+ to_path?: string;
203
+ redirect_type?: 307 | 308;
204
+ }
205
+ interface BlogUpdateInput {
206
+ title?: string;
207
+ description?: string;
208
+ blog_language?: string;
209
+ timezone_diff?: number;
210
+ logo?: string;
211
+ favicon?: string;
212
+ og_image?: string;
213
+ ga_measurement_id?: string;
214
+ }
215
+ interface AuthorUpdateInput {
216
+ author_name?: string;
217
+ avatar_url?: string | null;
218
+ }
219
+ interface PaginationOptions {
220
+ page?: number;
221
+ limit?: number;
222
+ }
223
+ interface PostListOptions extends PaginationOptions {
224
+ sort?: string;
225
+ order?: 'asc' | 'desc';
226
+ filter?: {
227
+ slug?: string;
228
+ published?: boolean;
229
+ published_at_gte?: string;
230
+ published_at_lte?: string;
231
+ tag_id?: number;
232
+ author_id?: string;
233
+ content_type?: 'tiptap' | 'notion';
234
+ };
235
+ include?: string[];
236
+ }
237
+ interface TagListOptions {
238
+ include?: string[];
239
+ }
240
+ interface AuthorListOptions extends PaginationOptions {
241
+ include?: string[];
242
+ }
243
+ interface RedirectListOptions extends PaginationOptions {
244
+ }
245
+ interface FormListOptions extends PaginationOptions {
246
+ }
247
+ interface FormResponseListOptions extends PaginationOptions {
248
+ filter?: {
249
+ form_id?: string;
250
+ };
251
+ }
252
+
253
+ /**
254
+ * Flatten a JSON:API resource into a plain object.
255
+ * Merges id + attributes + resolved relationships.
256
+ */
257
+ declare function flattenResource(resource: JsonApiResource, included?: JsonApiResource[]): Record<string, any>;
258
+ /**
259
+ * Deserialize a JSON:API response into flat object(s).
260
+ */
261
+ declare function deserialize<T = Record<string, any>>(response: JsonApiResponse<JsonApiResource>): T;
262
+ declare function deserialize<T = Record<string, any>>(response: JsonApiResponse<JsonApiResource[]>): T[];
263
+ /**
264
+ * Extract pagination meta from a JSON:API response.
265
+ */
266
+ declare function extractMeta(response: JsonApiResponse): {
267
+ total?: number;
268
+ page?: number;
269
+ limit?: number;
270
+ hasNext: boolean;
271
+ };
272
+
273
+ declare class InblogApiError extends Error {
274
+ status: number;
275
+ code: string;
276
+ title: string;
277
+ detail?: string;
278
+ constructor(status: number, code: string, title: string, detail?: string);
279
+ }
280
+ interface ClientOptions {
281
+ apiKey?: string;
282
+ accessToken?: string;
283
+ baseUrl?: string;
284
+ blogId?: number;
285
+ blogSubdomain?: string;
286
+ }
287
+ declare class InblogClient {
288
+ private apiKey?;
289
+ private accessToken?;
290
+ private baseUrl;
291
+ private blogId?;
292
+ private blogSubdomain?;
293
+ private tokenRefresher?;
294
+ constructor(options: ClientOptions);
295
+ setTokenRefresher(fn: () => Promise<string | null>): void;
296
+ private readHeaders;
297
+ private writeHeaders;
298
+ private resolveToken;
299
+ private buildUrl;
300
+ private handleResponse;
301
+ get<T = Record<string, any>>(path: string, params?: Record<string, any>): Promise<{
302
+ data: T;
303
+ meta: ReturnType<typeof extractMeta>;
304
+ }>;
305
+ list<T = Record<string, any>>(path: string, params?: Record<string, any>): Promise<{
306
+ data: T[];
307
+ meta: ReturnType<typeof extractMeta>;
308
+ }>;
309
+ create<T = Record<string, any>>(path: string, type: string, attributes: Record<string, any>, params?: Record<string, any>): Promise<{
310
+ data: T;
311
+ meta: ReturnType<typeof extractMeta>;
312
+ }>;
313
+ update<T = Record<string, any>>(path: string, type: string, id: string, attributes: Record<string, any>): Promise<{
314
+ data: T;
315
+ meta: ReturnType<typeof extractMeta>;
316
+ }>;
317
+ delete(path: string): Promise<void>;
318
+ post<T = Record<string, any>>(path: string, body?: any): Promise<{
319
+ data: T;
320
+ meta: ReturnType<typeof extractMeta>;
321
+ }>;
322
+ patch<T = Record<string, any>>(path: string, body?: any): Promise<{
323
+ data: T;
324
+ meta: ReturnType<typeof extractMeta>;
325
+ }>;
326
+ /**
327
+ * Raw GET — for non-JSON:API endpoints that return plain JSON.
328
+ */
329
+ rawGet(path: string, params?: Record<string, any>): Promise<any>;
330
+ /**
331
+ * Raw POST — for non-JSON:API endpoints.
332
+ */
333
+ rawPost(path: string, body?: any): Promise<any>;
334
+ /**
335
+ * Raw PATCH — for non-JSON:API endpoints.
336
+ */
337
+ rawPatch(path: string, body?: any): Promise<any>;
338
+ /**
339
+ * Raw DELETE — for non-JSON:API endpoints.
340
+ */
341
+ rawDelete(path: string): Promise<any>;
342
+ private handleRawResponse;
343
+ }
344
+
345
+ declare class PostsEndpoint {
346
+ private client;
347
+ constructor(client: InblogClient);
348
+ list(options?: PostListOptions): Promise<{
349
+ data: Post[];
350
+ meta: ReturnType<typeof extractMeta>;
351
+ }>;
352
+ get(id: string, include?: string[]): Promise<{
353
+ data: Post;
354
+ meta: ReturnType<typeof extractMeta>;
355
+ }>;
356
+ create(input: PostCreateInput): Promise<{
357
+ data: Post;
358
+ meta: ReturnType<typeof extractMeta>;
359
+ }>;
360
+ update(id: string, input: PostUpdateInput): Promise<{
361
+ data: Post;
362
+ meta: ReturnType<typeof extractMeta>;
363
+ }>;
364
+ delete(id: string): Promise<void>;
365
+ publish(id: string): Promise<{
366
+ data: Post;
367
+ meta: ReturnType<typeof extractMeta>;
368
+ }>;
369
+ unpublish(id: string): Promise<{
370
+ data: Post;
371
+ meta: ReturnType<typeof extractMeta>;
372
+ }>;
373
+ schedule(id: string, scheduledAt: string): Promise<{
374
+ data: Post;
375
+ meta: ReturnType<typeof extractMeta>;
376
+ }>;
377
+ listTags(postId: string): Promise<{
378
+ data: Tag[];
379
+ meta: ReturnType<typeof extractMeta>;
380
+ }>;
381
+ addTags(postId: string, tagIds: number[]): Promise<{
382
+ data: Post;
383
+ meta: ReturnType<typeof extractMeta>;
384
+ }>;
385
+ removeTag(postId: string, tagId: string): Promise<void>;
386
+ listAuthors(postId: string): Promise<{
387
+ data: Author[];
388
+ meta: ReturnType<typeof extractMeta>;
389
+ }>;
390
+ addAuthors(postId: string, authorIds: string[]): Promise<{
391
+ data: Post;
392
+ meta: ReturnType<typeof extractMeta>;
393
+ }>;
394
+ removeAuthor(postId: string, authorId: string): Promise<void>;
395
+ }
396
+
397
+ declare class TagsEndpoint {
398
+ private client;
399
+ constructor(client: InblogClient);
400
+ list(options?: TagListOptions): Promise<{
401
+ data: Tag[];
402
+ meta: ReturnType<typeof extractMeta>;
403
+ }>;
404
+ get(id: string): Promise<{
405
+ data: Tag;
406
+ meta: ReturnType<typeof extractMeta>;
407
+ }>;
408
+ create(input: TagCreateInput): Promise<{
409
+ data: Tag;
410
+ meta: ReturnType<typeof extractMeta>;
411
+ }>;
412
+ update(id: string, input: TagUpdateInput): Promise<{
413
+ data: Tag;
414
+ meta: ReturnType<typeof extractMeta>;
415
+ }>;
416
+ delete(id: string): Promise<void>;
417
+ }
418
+
419
+ declare class AuthorsEndpoint {
420
+ private client;
421
+ constructor(client: InblogClient);
422
+ list(options?: AuthorListOptions): Promise<{
423
+ data: Author[];
424
+ meta: ReturnType<typeof extractMeta>;
425
+ }>;
426
+ get(id: string): Promise<{
427
+ data: Author;
428
+ meta: ReturnType<typeof extractMeta>;
429
+ }>;
430
+ update(id: string, input: AuthorUpdateInput): Promise<{
431
+ data: Author;
432
+ meta: ReturnType<typeof extractMeta>;
433
+ }>;
434
+ }
435
+
436
+ declare class BlogsEndpoint {
437
+ private client;
438
+ constructor(client: InblogClient);
439
+ me(): Promise<{
440
+ data: Blog;
441
+ meta: ReturnType<typeof extractMeta>;
442
+ }>;
443
+ update(subdomain: string, input: BlogUpdateInput): Promise<{
444
+ data: Blog;
445
+ meta: ReturnType<typeof extractMeta>;
446
+ }>;
447
+ domainConnect(domain: string): Promise<any>;
448
+ domainStatus(): Promise<any>;
449
+ domainDisconnect(): Promise<any>;
450
+ getCustomUi(): Promise<any>;
451
+ updateCustomUi(input: Record<string, any>): Promise<any>;
452
+ }
453
+
454
+ declare class RedirectsEndpoint {
455
+ private client;
456
+ constructor(client: InblogClient);
457
+ list(options?: RedirectListOptions): Promise<{
458
+ data: Redirect[];
459
+ meta: ReturnType<typeof extractMeta>;
460
+ }>;
461
+ get(id: string): Promise<{
462
+ data: Redirect;
463
+ meta: ReturnType<typeof extractMeta>;
464
+ }>;
465
+ create(input: RedirectCreateInput): Promise<{
466
+ data: Redirect;
467
+ meta: ReturnType<typeof extractMeta>;
468
+ }>;
469
+ update(id: string, input: RedirectUpdateInput): Promise<{
470
+ data: Redirect;
471
+ meta: ReturnType<typeof extractMeta>;
472
+ }>;
473
+ delete(id: string): Promise<void>;
474
+ }
475
+
476
+ declare class FormsEndpoint {
477
+ private client;
478
+ constructor(client: InblogClient);
479
+ list(options?: FormListOptions): Promise<{
480
+ data: Form[];
481
+ meta: ReturnType<typeof extractMeta>;
482
+ }>;
483
+ get(id: string): Promise<{
484
+ data: Form;
485
+ meta: ReturnType<typeof extractMeta>;
486
+ }>;
487
+ }
488
+ declare class FormResponsesEndpoint {
489
+ private client;
490
+ constructor(client: InblogClient);
491
+ list(options?: FormResponseListOptions): Promise<{
492
+ data: FormResponse[];
493
+ meta: ReturnType<typeof extractMeta>;
494
+ }>;
495
+ get(id: string): Promise<{
496
+ data: FormResponse;
497
+ meta: ReturnType<typeof extractMeta>;
498
+ }>;
499
+ }
500
+
501
+ /**
502
+ * Build a JSON:API request body (simplified format).
503
+ * The inblog API accepts both wrapped and unwrapped formats;
504
+ * we use the simplified format: { type, attributes }.
505
+ */
506
+ declare function serialize(type: string, attributes: Record<string, any>, id?: string): {
507
+ data: {
508
+ type: string;
509
+ id?: string;
510
+ attributes: Record<string, any>;
511
+ };
512
+ };
513
+
514
+ export { type Author, type AuthorListOptions, type AuthorUpdateInput, AuthorsEndpoint, type Blog, type BlogUpdateInput, BlogsEndpoint, type ClientOptions, type Form, type FormListOptions, type FormResponse, type FormResponseListOptions, FormResponsesEndpoint, FormsEndpoint, InblogApiError, InblogClient, type JsonApiError, type JsonApiErrorResponse, type JsonApiResource, type JsonApiResponse, type PaginationOptions, type Post, type PostCreateInput, type PostListOptions, type PostUpdateInput, PostsEndpoint, type Redirect, type RedirectCreateInput, type RedirectListOptions, type RedirectUpdateInput, RedirectsEndpoint, type Tag, type TagCreateInput, type TagListOptions, type TagUpdateInput, TagsEndpoint, deserialize, extractMeta, flattenResource, serialize };