@presscomm/types-pn3wp 2.3.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/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v22.9.0
package/index.ts ADDED
@@ -0,0 +1,506 @@
1
+ /**
2
+ * @strict
3
+ */
4
+ export type tLeggiAnche = {
5
+ photoUrl: boolean | tUrlAbsoluteString;
6
+ argomento: string;
7
+ title: string;
8
+ url: tUrlRelativeString;
9
+ };
10
+
11
+ /**
12
+ * @strict
13
+ */
14
+ type tCopertina = {
15
+ og_image: tUrlAbsoluteString;
16
+ /**
17
+ * <img> HTML tag
18
+ * */
19
+ source_url: tImgTag;
20
+ /**
21
+ * absolute URL
22
+ * */
23
+ cover_url: string;
24
+ bck_code: string;
25
+ multiple_thumb?: Record<string, tImgTag>;
26
+ media_details: unknown;
27
+ };
28
+
29
+ /**
30
+ * @strict
31
+ */
32
+ export type tAppoggio = {
33
+ titolo: string;
34
+ link: string;
35
+ };
36
+
37
+ /**
38
+ * @strict
39
+ */
40
+ export type tVideoOrGallery = {
41
+ video: {
42
+ YT: tUrlAbsoluteString;
43
+ FB: tUrlAbsoluteString;
44
+ Vimeo: tUrlAbsoluteString;
45
+ Correlati: tUrlAbsoluteString;
46
+ };
47
+ photogallery: tNumericString;
48
+ };
49
+
50
+ /**
51
+ * @strict
52
+ */
53
+ type tMediaDetails = {
54
+ file: string;
55
+ width: number;
56
+ height: number;
57
+ filesize: number;
58
+ mime_type: string;
59
+ source_url: tUrlAbsoluteString;
60
+ };
61
+
62
+ /**
63
+ * @strict
64
+ */
65
+ type tImageMeta = {
66
+ aperture: string;
67
+ credit: string;
68
+ camera: string;
69
+ caption: string;
70
+ created_timestamp: string;
71
+ copyright: string;
72
+ focal_length: string;
73
+ iso: string;
74
+ shutter_speed: string;
75
+ title: string;
76
+ orientation: string;
77
+ keywords: string[];
78
+ };
79
+
80
+ /**
81
+ * @strict
82
+ */
83
+ export interface tYoastSeoData {
84
+ title: string;
85
+ description?: string;
86
+ canonical?: tUrlAbsoluteString;
87
+ robots: {
88
+ index: "index" | "noindex";
89
+ follow: "follow" | "nofollow";
90
+ "max-snippet"?: string;
91
+ "max-image-preview"?: string;
92
+ "max-video-preview"?: string;
93
+ };
94
+ og_image?: {url: tUrlAbsoluteString}[];
95
+ og_locale: string;
96
+ og_type: "website" | "article" | "profile";
97
+ og_title: string;
98
+ og_description?: string;
99
+ og_url: string;
100
+ og_site_name: string;
101
+ article_modified_time?: string;
102
+ article_published_time?: string;
103
+ twitter_card: string;
104
+ twitter_misc?: any;
105
+ schema?: any;
106
+ }
107
+
108
+ /**
109
+ * @strict
110
+ */
111
+ export type tPostTypes =
112
+ | "post"
113
+ | "page"
114
+ | "video"
115
+ | "fotogallery"
116
+ | "pubbliredazionale"
117
+ | "evento"
118
+ | "necrologio";
119
+
120
+ /**
121
+ * @strict
122
+ */
123
+ export type tTaxonomySlugs =
124
+ | "category"
125
+ | "category-video"
126
+ | "category-fotogallery"
127
+ | "post_cat_citta"
128
+ | "post_tag_personaggi"
129
+ | "category-evento"
130
+ | "category-cittaevento"
131
+ | "tag";
132
+
133
+ /**
134
+ * Object type for the "type" object in the route /wp/v2/types.
135
+ * @strict
136
+ */
137
+ type tType = {
138
+ name: string;
139
+ slug: string;
140
+ icon: string;
141
+ rest_base: string;
142
+ rest_namespace: "wp/v2";
143
+ template: string[];
144
+ template_lock: boolean;
145
+ yoast_head_json: tYoastSeoData;
146
+ yoast_head: string;
147
+ _links: tLinks;
148
+ };
149
+
150
+ type tSimpleLocalAvatar = {
151
+ media_id: number;
152
+ blog_id: number;
153
+ full: tUrlAbsoluteString;
154
+ 192: tUrlAbsoluteString;
155
+ 96: tUrlAbsoluteString;
156
+ 128: tUrlAbsoluteString;
157
+ 64: tUrlAbsoluteString;
158
+ 52: tUrlAbsoluteString;
159
+ 26: tUrlAbsoluteString;
160
+ 32: tUrlAbsoluteString;
161
+ 24: tUrlAbsoluteString;
162
+ 48: tUrlAbsoluteString;
163
+ 100: tUrlAbsoluteString;
164
+ 50: tUrlAbsoluteString;
165
+ 600: tUrlAbsoluteString;
166
+ 300: tUrlAbsoluteString;
167
+ 500: tUrlAbsoluteString;
168
+ }
169
+
170
+ /**
171
+ * @strict
172
+ */
173
+ export interface tAuthor {
174
+ /** Identificatore univoco per l'utente. */
175
+ id: number;
176
+ /** Visualizza il nome dell'utente. */
177
+ name: string;
178
+ /** Website URL dell'utente. */
179
+ url: tUrlAbsoluteString;
180
+ /** La descrizione dell'utente. */
181
+ description: string;
182
+ /** URL autore dell'utente. */
183
+ link: string;
184
+ /** Un identificatore alfanumerico per l'utente. */
185
+ slug: string;
186
+ /** Avatar images urls */
187
+ avatar_urls: {
188
+ 24: tUrlAbsoluteString;
189
+ 48: tUrlAbsoluteString;
190
+ 96: tUrlAbsoluteString;
191
+ 128?: tUrlAbsoluteString;
192
+ };
193
+ simple_local_avatar: tSimpleLocalAvatar;
194
+ /**
195
+ * SEO HTML from Yoast
196
+ * */
197
+ yoast_head: string;
198
+
199
+ /**
200
+ * SEO JSON from Yoast
201
+ * */
202
+ yoast_head_json: tYoastSeoData;
203
+
204
+ user_meta: Record<string, string | number>[];
205
+ _links: tLinks;
206
+ }
207
+
208
+ export interface tAuthorNecro extends tAuthor {
209
+ user_meta: {
210
+ phone: string;
211
+ email: string;
212
+ description: string;
213
+ };
214
+ }
215
+
216
+ export interface tFeaturedMedia extends tPostBase {
217
+ type: "attachment";
218
+ strillo: string;
219
+ didascalia: string;
220
+ appoggi: tAppoggio[];
221
+ video_o_gallery: tVideoOrGallery;
222
+ caption: {
223
+ rendered: string;
224
+ };
225
+ alt_text: string;
226
+ media_type: "image" | "video";
227
+ mime_type: string;
228
+ media_details: {
229
+ width: number;
230
+ height: number;
231
+ file: tUrlRelativeString;
232
+ filesize: number;
233
+ sizes: {
234
+ medium: tMediaDetails;
235
+ thumbnail: tMediaDetails;
236
+ full: tMediaDetails;
237
+ };
238
+ image_meta: tImageMeta;
239
+ };
240
+ source_url: tUrlAbsoluteString;
241
+ }
242
+
243
+ /**
244
+ * Object type for the term object embedded with post_types requests _embedded["wp:term"]
245
+ * @strict
246
+ */
247
+ export type tTerm = {
248
+ /** Identificativo unico per il termine. */
249
+ id: number;
250
+ /** L'URL del termine. */
251
+ link: string;
252
+ /** Il titolo HTML del termine. */
253
+ name: string;
254
+ /** Un identificatore alfanumerico per il termine, unico nella sua tipologia. */
255
+ slug: string;
256
+ /** Attribuzione del tipo per il termine. */
257
+ taxonomy: tTaxonomySlugs;
258
+ /**
259
+ * SEO HTML from Yoast
260
+ * */
261
+ yoast_head: string;
262
+
263
+ /**
264
+ * SEO JSON from Yoast
265
+ * */
266
+ yoast_head_json: tYoastSeoData;
267
+ /**
268
+ * Only defined for taxonomy = category
269
+ * */
270
+ image_cat?: string;
271
+ _links: tLinks;
272
+ };
273
+
274
+ type tLinks = Record<string, Array<{ href: string }>>;
275
+
276
+ type tUrlAbsoluteString = string;
277
+
278
+ type tUrlRelativeString = string;
279
+
280
+ type tCommaSeparatedString = string;
281
+
282
+ // type tNumericString = `${number}`;
283
+ type tNumericString = string;
284
+
285
+ type tImgTag = string;
286
+
287
+ /**
288
+ * @strict
289
+ */
290
+ type tTestata = {
291
+ colore_testata: string;
292
+ testo_scuro: boolean;
293
+ };
294
+
295
+ /**
296
+ * Object type for the "post" object in the route /wp/v2/posts.
297
+ * @strict
298
+ */
299
+ interface tPostBase {
300
+ /** La data di pubblicazione dell'articolo, nel fuso orario del sito. */
301
+ date: string | null;
302
+ /** La data di pubblicazione dell'articolo, nel fuso orario GMT. */
303
+ date_gmt: string | null;
304
+ /** L'identificatore univoco globale (GUID) dell'articolo. */
305
+ guid: {
306
+ /** GUID dell'articolo, trasformato per la visualizzazione. */
307
+ rendered: string;
308
+ };
309
+ /** ID univoco per l'articolo. */
310
+ id: number;
311
+ /** URL all'articolo. */
312
+ link: tUrlRelativeString;
313
+ /** La data di ultima modifica dell'articolo, nel fuso orario del sito. */
314
+ modified: string;
315
+ /** La data di ultima modifica dell'articolo, nel fuso orario GMT. */
316
+ modified_gmt: string;
317
+ /** Un identificatore alfanumerico per l'articolo unico di questo tipo. */
318
+ slug: string;
319
+ /** Uno stato con nome per l'articolo. */
320
+ status: "publish" | "future" | "draft" | "pending" | "private";
321
+ /** Tipo di articolo. */
322
+ type: string;
323
+ /** Una password per proteggere l'accesso al contenuto e al riassunto. */
324
+ password?: string;
325
+ /** Il titolo dell'articolo. */
326
+ title: {
327
+ /** Titolo HTML per l'articolo, trasformato per la visualizzazione. */
328
+ rendered: string;
329
+ };
330
+ /** Il contenuto dell'articolo. */
331
+ content: {
332
+ /** Contenuto HTML dell'articolo, trasformato per essere visualizzato. */
333
+ rendered: string;
334
+ /** Se il contenuto è protetto da password oppure no. */
335
+ protected: boolean;
336
+ };
337
+ /** L'ID dell'autore dell'articolo. */
338
+ author: number;
339
+ /** Il riassunto dell'articolo. */
340
+ excerpt: {
341
+ /** Riassunto HTML per l'articolo, trasformato per essere visualizzato. */
342
+ rendered: string;
343
+ /** Indica se il riassunto sia protetto da password. */
344
+ protected: boolean;
345
+ };
346
+ /** L'id del media in evidenza per l'articolo. */
347
+ featured_media: number;
348
+ /** Se i commenti sono aperti o meno per l'articolo. */
349
+ comment_status: "open" | "closed";
350
+ /** Se l'articolo si possa pingare o meno. */
351
+ ping_status: "open" | "closed";
352
+ /** Il file del tema da utilizzare per visualizzare l'articolo. */
353
+ template: string;
354
+ /** I termini assegnati all'articolo nella tassonomia category. */
355
+ categories: number[];
356
+ /**
357
+ * SEO HTML from Yoast
358
+ * */
359
+ yoast_head: string;
360
+
361
+ /**
362
+ * SEO JSON from Yoast
363
+ * */
364
+ yoast_head_json: tYoastSeoData;
365
+
366
+ copertina: tCopertina;
367
+
368
+ sezione: tCommaSeparatedString;
369
+
370
+ post_meta: tPostBaseMeta;
371
+
372
+ /**
373
+ * Array of css class names used in block editor
374
+ * */
375
+ class_list: string[];
376
+
377
+ _embedded: {
378
+ type: tType[];
379
+ /**
380
+ * Array of author ids
381
+ * */
382
+ author: tAuthor[];
383
+ /**
384
+ * Array of array object to fetch terms
385
+ * */
386
+ "wp:term": Array<Array<tTerm>>;
387
+ };
388
+ _links: tLinks;
389
+ }
390
+
391
+ interface tPostBaseMeta {
392
+ _estimated_reading_time: tNumericString[];
393
+ }
394
+
395
+ /**
396
+ * @strict
397
+ */
398
+ interface tUser {
399
+ ID: number;
400
+ displayName: string;
401
+ userNicename: string;
402
+ hasAdminAccess: boolean;
403
+ }
404
+
405
+ interface tPostMeta extends tPostBaseMeta {
406
+ argomento: string[];
407
+ firma_come: tNumericString[];
408
+ "firma-personalizzata": string[];
409
+ hide_ads: tNumericString[];
410
+ _yoast_wpseo_primary_category: tNumericString[];
411
+ id_leggi_anche: tCommaSeparatedString[];
412
+ foto: tCommaSeparatedString[];
413
+ }
414
+
415
+ interface tPubbliredazionaleMeta extends tPostBaseMeta {
416
+ "data-fine-pubblicazione": tNumericString[];
417
+ argomento: string[];
418
+ firma_come: tNumericString[];
419
+ _yoast_wpseo_primary_category: tNumericString[];
420
+ /**
421
+ * HEX color
422
+ * */
423
+ colore_testata?: string[];
424
+ colore_titolo?: "1"[];
425
+ foto: tCommaSeparatedString[];
426
+ foto_d_archivio: tNumericString[];
427
+ disable_label_paid_content?: "1";
428
+ }
429
+
430
+ interface tAnnuncioFamigliaMeta extends tPostBaseMeta {
431
+ "data-fine-pubblicazione": tNumericString[];
432
+ "data-visibile": tNumericString[];
433
+ intestazione: string[];
434
+ sottonome: string[];
435
+ anni: tNumericString[];
436
+ "comune-decesso": string[];
437
+ ringraziamento: tNumericString[];
438
+ }
439
+
440
+ export interface tPost extends tPostBase {
441
+ type: "post";
442
+ /** I termini assegnati all'articolo nella tassonomia post_tag. */
443
+ tags: number[];
444
+ post_cat_citta: number[];
445
+ post_tag_personaggi: number[];
446
+ strillo: string;
447
+ didascalia: string;
448
+ appoggi: tAppoggio[];
449
+ video_o_gallery: tVideoOrGallery;
450
+ photogallery_list: tUrlAbsoluteString[];
451
+ photogallery_title: string;
452
+ photogallery_link: tUrlRelativeString;
453
+ post_meta: tPostMeta;
454
+ leggiAnche: tLeggiAnche[];
455
+ /** Il formato per l’articolo. */
456
+ format:
457
+ | "standard"
458
+ | "aside"
459
+ | "chat"
460
+ | "gallery"
461
+ | "link"
462
+ | "image"
463
+ | "quote"
464
+ | "status"
465
+ | "video"
466
+ | "audio";
467
+ /** Se l'articolo sia da trattare come in evidenza o meno. */
468
+ sticky: boolean;
469
+ /** used by post_meta registered with add_post_meta */
470
+ meta: number[];
471
+ }
472
+
473
+ export interface tAnnuncioFamiglia extends Omit<tPostBase, "_embedded"> {
474
+ type: "annuncio-famiglia";
475
+ post_meta: tAnnuncioFamigliaMeta;
476
+ _embedded: {
477
+ type: tPostTypes[];
478
+ /**
479
+ * Array of author ids
480
+ * */
481
+ author: tAuthorNecro[];
482
+ /**
483
+ * Array of array object to fetch terms
484
+ * */
485
+ "wp:featuredmedia": tFeaturedMedia[];
486
+ };
487
+ }
488
+
489
+ export interface tPubbliredazionale extends tPostBase {
490
+ type: "pubbliredazionale";
491
+ tags: number[];
492
+ post_cat_citta: number[];
493
+ post_tag_personaggi: number[];
494
+ strillo: string;
495
+ didascalia: string;
496
+ appoggi: [Record<string, never>, Record<string, never>];
497
+ video_o_gallery: tVideoOrGallery;
498
+ photogallery_list: tUrlAbsoluteString[];
499
+ photogallery_title: string;
500
+ photogallery_link: tUrlRelativeString;
501
+ testata: tTestata;
502
+ leggiAnche: tLeggiAnche[];
503
+ post_meta: tPubbliredazionaleMeta;
504
+ }
505
+
506
+ export interface tPage extends tPostBase { }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@presscomm/types-pn3wp",
3
+ "version": "2.3.1",
4
+ "description": "Typescript types for PN3 Wordpress",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build-schema": "ts-to-zod index.d.ts schemaZod.ts",
8
+ "build-schema:no-validation": "ts-to-zod index.d.ts schemaZod.ts --skipValidation",
9
+ "watch:build-schema": "chokidar index.d.ts -c 'pnpm build-schema'"
10
+ },
11
+ "types": "index.d.ts",
12
+ "exports": {
13
+ ".": "./index.ts",
14
+ "./schema": "./schemaZod.ts",
15
+ "./widget": "./widgetTypes.ts"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://bitbucket.org/presscommtech/types-pn3wp.git"
20
+ },
21
+ "keywords": [
22
+ "typescript"
23
+ ],
24
+ "author": "alessandro stoppato",
25
+ "license": "ISC",
26
+ "bugs": {
27
+ "url": "https://bitbucket.org/presscommtech/types-pn3wp/issues"
28
+ },
29
+ "homepage": "https://bitbucket.org/presscommtech/types-pn3wp#readme",
30
+ "devDependencies": {
31
+ "chokidar-cli": "^3.0.0",
32
+ "ts-to-zod": "^4.0.1",
33
+ "typescript": "^5.9.3"
34
+ },
35
+ "dependencies": {
36
+ "zod": "^4.1.12"
37
+ }
38
+ }
package/schemaZod.ts ADDED
@@ -0,0 +1,395 @@
1
+ // Generated by ts-to-zod
2
+ import { z } from "zod";
3
+
4
+ const tUrlAbsoluteStringSchema = z.string();
5
+
6
+ const tUrlRelativeStringSchema = z.string();
7
+
8
+ const tImgTagSchema = z.string();
9
+
10
+ const tAppoggioSchema = z.strictObject({
11
+ titolo: z.string(),
12
+ link: z.string(),
13
+ });
14
+
15
+ const tNumericStringSchema = z.string();
16
+
17
+ const tMediaDetailsSchema = z.strictObject({
18
+ file: z.string(),
19
+ width: z.number(),
20
+ height: z.number(),
21
+ filesize: z.number(),
22
+ mime_type: z.string(),
23
+ source_url: tUrlAbsoluteStringSchema,
24
+ });
25
+
26
+ const tImageMetaSchema = z.strictObject({
27
+ aperture: z.string(),
28
+ credit: z.string(),
29
+ camera: z.string(),
30
+ caption: z.string(),
31
+ created_timestamp: z.string(),
32
+ copyright: z.string(),
33
+ focal_length: z.string(),
34
+ iso: z.string(),
35
+ shutter_speed: z.string(),
36
+ title: z.string(),
37
+ orientation: z.string(),
38
+ keywords: z.array(z.string()),
39
+ });
40
+
41
+ export const tYoastSeoDataSchema = z.strictObject({
42
+ title: z.string(),
43
+ description: z.string().optional(),
44
+ canonical: tUrlAbsoluteStringSchema.optional(),
45
+ robots: z.object({
46
+ index: z.union([z.literal("index"), z.literal("noindex")]),
47
+ follow: z.union([z.literal("follow"), z.literal("nofollow")]),
48
+ "max-snippet": z.string().optional(),
49
+ "max-image-preview": z.string().optional(),
50
+ "max-video-preview": z.string().optional(),
51
+ }),
52
+ og_image: z
53
+ .array(
54
+ z.object({
55
+ url: tUrlAbsoluteStringSchema,
56
+ }),
57
+ )
58
+ .optional(),
59
+ og_locale: z.string(),
60
+ og_type: z.union([
61
+ z.literal("website"),
62
+ z.literal("article"),
63
+ z.literal("profile"),
64
+ ]),
65
+ og_title: z.string(),
66
+ og_description: z.string().optional(),
67
+ og_url: z.string(),
68
+ og_site_name: z.string(),
69
+ article_modified_time: z.string().optional(),
70
+ article_published_time: z.string().optional(),
71
+ twitter_card: z.string(),
72
+ twitter_misc: z.any().optional(),
73
+ schema: z.any().optional(),
74
+ });
75
+
76
+ export const tPostTypesSchema = z.union([
77
+ z.literal("post"),
78
+ z.literal("page"),
79
+ z.literal("video"),
80
+ z.literal("fotogallery"),
81
+ z.literal("pubbliredazionale"),
82
+ z.literal("evento"),
83
+ z.literal("necrologio"),
84
+ ]);
85
+
86
+ export const tTaxonomySlugsSchema = z.union([
87
+ z.literal("category"),
88
+ z.literal("category-video"),
89
+ z.literal("category-fotogallery"),
90
+ z.literal("post_cat_citta"),
91
+ z.literal("post_tag_personaggi"),
92
+ z.literal("category-evento"),
93
+ z.literal("category-cittaevento"),
94
+ z.literal("tag"),
95
+ ]);
96
+
97
+ const tLinksSchema = z.record(
98
+ z.string(),
99
+ z.array(
100
+ z.object({
101
+ href: z.string(),
102
+ }),
103
+ ),
104
+ );
105
+
106
+ const tSimpleLocalAvatarSchema = z.object({
107
+ media_id: z.number(),
108
+ blog_id: z.number(),
109
+ full: tUrlAbsoluteStringSchema,
110
+ 192: tUrlAbsoluteStringSchema,
111
+ 96: tUrlAbsoluteStringSchema,
112
+ 128: tUrlAbsoluteStringSchema,
113
+ 64: tUrlAbsoluteStringSchema,
114
+ 52: tUrlAbsoluteStringSchema,
115
+ 26: tUrlAbsoluteStringSchema,
116
+ 32: tUrlAbsoluteStringSchema,
117
+ 24: tUrlAbsoluteStringSchema,
118
+ 48: tUrlAbsoluteStringSchema,
119
+ 100: tUrlAbsoluteStringSchema,
120
+ 50: tUrlAbsoluteStringSchema,
121
+ 600: tUrlAbsoluteStringSchema,
122
+ 300: tUrlAbsoluteStringSchema,
123
+ 500: tUrlAbsoluteStringSchema,
124
+ });
125
+
126
+ export const tAuthorSchema = z.strictObject({
127
+ id: z.number(),
128
+ name: z.string(),
129
+ url: tUrlAbsoluteStringSchema,
130
+ description: z.string(),
131
+ link: z.string(),
132
+ slug: z.string(),
133
+ avatar_urls: z.object({
134
+ 24: tUrlAbsoluteStringSchema,
135
+ 48: tUrlAbsoluteStringSchema,
136
+ 96: tUrlAbsoluteStringSchema,
137
+ 128: tUrlAbsoluteStringSchema.optional(),
138
+ }),
139
+ simple_local_avatar: tSimpleLocalAvatarSchema,
140
+ yoast_head: z.string(),
141
+ yoast_head_json: tYoastSeoDataSchema,
142
+ user_meta: z.array(z.record(z.string(), z.union([z.string(), z.number()]))),
143
+ _links: tLinksSchema,
144
+ });
145
+
146
+ export const tAuthorNecroSchema = tAuthorSchema.extend({
147
+ user_meta: z.object({
148
+ phone: z.string(),
149
+ email: z.string(),
150
+ description: z.string(),
151
+ }),
152
+ });
153
+
154
+ const tVideoOrGallerySchema = z.strictObject({
155
+ video: z.object({
156
+ YT: tUrlAbsoluteStringSchema,
157
+ FB: tUrlAbsoluteStringSchema,
158
+ Vimeo: tUrlAbsoluteStringSchema,
159
+ Correlati: tUrlAbsoluteStringSchema,
160
+ }),
161
+ photogallery: tNumericStringSchema,
162
+ });
163
+
164
+ export const tTermSchema = z.strictObject({
165
+ id: z.number(),
166
+ link: z.string(),
167
+ name: z.string(),
168
+ slug: z.string(),
169
+ taxonomy: tTaxonomySlugsSchema,
170
+ yoast_head: z.string(),
171
+ yoast_head_json: tYoastSeoDataSchema,
172
+ image_cat: z.string().optional(),
173
+ _links: tLinksSchema,
174
+ });
175
+
176
+ const tCommaSeparatedStringSchema = z.string();
177
+
178
+ const tTestataSchema = z.strictObject({
179
+ colore_testata: z.string(),
180
+ testo_scuro: z.boolean(),
181
+ });
182
+
183
+ const tCopertinaSchema = z.strictObject({
184
+ og_image: tUrlAbsoluteStringSchema,
185
+ source_url: tImgTagSchema,
186
+ cover_url: z.string(),
187
+ bck_code: z.string(),
188
+ multiple_thumb: z.record(z.string(), tImgTagSchema).optional(),
189
+ media_details: z.unknown(),
190
+ });
191
+
192
+ const tPostBaseMetaSchema = z.object({
193
+ _estimated_reading_time: z.array(tNumericStringSchema),
194
+ });
195
+
196
+ const tTypeSchema = z.strictObject({
197
+ name: z.string(),
198
+ slug: z.string(),
199
+ icon: z.string(),
200
+ rest_base: z.string(),
201
+ rest_namespace: z.literal("wp/v2"),
202
+ template: z.array(z.string()),
203
+ template_lock: z.boolean(),
204
+ yoast_head_json: tYoastSeoDataSchema,
205
+ yoast_head: z.string(),
206
+ _links: tLinksSchema,
207
+ });
208
+
209
+ const tUserSchema = z.strictObject({
210
+ ID: z.number(),
211
+ displayName: z.string(),
212
+ userNicename: z.string(),
213
+ hasAdminAccess: z.boolean(),
214
+ });
215
+
216
+ const tPostMetaSchema = tPostBaseMetaSchema.extend({
217
+ argomento: z.array(z.string()),
218
+ firma_come: z.array(tNumericStringSchema),
219
+ "firma-personalizzata": z.array(z.string()),
220
+ hide_ads: z.array(tNumericStringSchema),
221
+ _yoast_wpseo_primary_category: z.array(tNumericStringSchema),
222
+ id_leggi_anche: z.array(tCommaSeparatedStringSchema),
223
+ foto: z.array(tCommaSeparatedStringSchema),
224
+ });
225
+
226
+ const tPubbliredazionaleMetaSchema = tPostBaseMetaSchema.extend({
227
+ "data-fine-pubblicazione": z.array(tNumericStringSchema),
228
+ argomento: z.array(z.string()),
229
+ firma_come: z.array(tNumericStringSchema),
230
+ _yoast_wpseo_primary_category: z.array(tNumericStringSchema),
231
+ colore_testata: z.array(z.string()).optional(),
232
+ colore_titolo: z.array(z.literal("1")).optional(),
233
+ foto: z.array(tCommaSeparatedStringSchema),
234
+ foto_d_archivio: z.array(tNumericStringSchema),
235
+ disable_label_paid_content: z.literal("1").optional(),
236
+ });
237
+
238
+ const tAnnuncioFamigliaMetaSchema = tPostBaseMetaSchema.extend({
239
+ "data-fine-pubblicazione": z.array(tNumericStringSchema),
240
+ "data-visibile": z.array(tNumericStringSchema),
241
+ intestazione: z.array(z.string()),
242
+ sottonome: z.array(z.string()),
243
+ anni: z.array(tNumericStringSchema),
244
+ "comune-decesso": z.array(z.string()),
245
+ ringraziamento: z.array(tNumericStringSchema),
246
+ });
247
+
248
+ const tPostBaseSchema = z.strictObject({
249
+ date: z.string().nullable(),
250
+ date_gmt: z.string().nullable(),
251
+ guid: z.object({
252
+ rendered: z.string(),
253
+ }),
254
+ id: z.number(),
255
+ link: tUrlRelativeStringSchema,
256
+ modified: z.string(),
257
+ modified_gmt: z.string(),
258
+ slug: z.string(),
259
+ status: z.union([
260
+ z.literal("publish"),
261
+ z.literal("future"),
262
+ z.literal("draft"),
263
+ z.literal("pending"),
264
+ z.literal("private"),
265
+ ]),
266
+ type: z.string(),
267
+ password: z.string().optional(),
268
+ title: z.object({
269
+ rendered: z.string(),
270
+ }),
271
+ content: z.object({
272
+ rendered: z.string(),
273
+ protected: z.boolean(),
274
+ }),
275
+ author: z.number(),
276
+ excerpt: z.object({
277
+ rendered: z.string(),
278
+ protected: z.boolean(),
279
+ }),
280
+ featured_media: z.number(),
281
+ comment_status: z.union([z.literal("open"), z.literal("closed")]),
282
+ ping_status: z.union([z.literal("open"), z.literal("closed")]),
283
+ template: z.string(),
284
+ categories: z.array(z.number()),
285
+ yoast_head: z.string(),
286
+ yoast_head_json: tYoastSeoDataSchema,
287
+ copertina: tCopertinaSchema,
288
+ sezione: tCommaSeparatedStringSchema,
289
+ post_meta: tPostBaseMetaSchema,
290
+ class_list: z.array(z.string()),
291
+ _embedded: z.object({
292
+ type: z.array(tTypeSchema),
293
+ author: z.array(tAuthorSchema),
294
+ "wp:term": z.array(z.array(tTermSchema)),
295
+ }),
296
+ _links: tLinksSchema,
297
+ });
298
+
299
+ export const tLeggiAncheSchema = z.strictObject({
300
+ photoUrl: z.union([z.boolean(), tUrlAbsoluteStringSchema]),
301
+ argomento: z.string(),
302
+ title: z.string(),
303
+ url: tUrlRelativeStringSchema,
304
+ });
305
+
306
+ export const tFeaturedMediaSchema = tPostBaseSchema.extend({
307
+ type: z.literal("attachment"),
308
+ strillo: z.string(),
309
+ didascalia: z.string(),
310
+ appoggi: z.array(tAppoggioSchema),
311
+ video_o_gallery: tVideoOrGallerySchema,
312
+ caption: z.object({
313
+ rendered: z.string(),
314
+ }),
315
+ alt_text: z.string(),
316
+ media_type: z.union([z.literal("image"), z.literal("video")]),
317
+ mime_type: z.string(),
318
+ media_details: z.object({
319
+ width: z.number(),
320
+ height: z.number(),
321
+ file: tUrlRelativeStringSchema,
322
+ filesize: z.number(),
323
+ sizes: z.object({
324
+ medium: tMediaDetailsSchema,
325
+ thumbnail: tMediaDetailsSchema,
326
+ full: tMediaDetailsSchema,
327
+ }),
328
+ image_meta: tImageMetaSchema,
329
+ }),
330
+ source_url: tUrlAbsoluteStringSchema,
331
+ });
332
+
333
+ export const tPubbliredazionaleSchema = tPostBaseSchema.extend({
334
+ type: z.literal("pubbliredazionale"),
335
+ tags: z.array(z.number()),
336
+ post_cat_citta: z.array(z.number()),
337
+ post_tag_personaggi: z.array(z.number()),
338
+ strillo: z.string(),
339
+ didascalia: z.string(),
340
+ appoggi: z.tuple([
341
+ z.record(z.string(), z.never()),
342
+ z.record(z.string(), z.never()),
343
+ ]),
344
+ video_o_gallery: tVideoOrGallerySchema,
345
+ photogallery_list: z.array(tUrlAbsoluteStringSchema),
346
+ photogallery_title: z.string(),
347
+ photogallery_link: tUrlRelativeStringSchema,
348
+ testata: tTestataSchema,
349
+ leggiAnche: z.array(tLeggiAncheSchema),
350
+ post_meta: tPubbliredazionaleMetaSchema,
351
+ });
352
+
353
+ export const tPageSchema = tPostBaseSchema;
354
+
355
+ export const tPostSchema = tPostBaseSchema.extend({
356
+ type: z.literal("post"),
357
+ tags: z.array(z.number()),
358
+ post_cat_citta: z.array(z.number()),
359
+ post_tag_personaggi: z.array(z.number()),
360
+ strillo: z.string(),
361
+ didascalia: z.string(),
362
+ appoggi: z.array(tAppoggioSchema),
363
+ video_o_gallery: tVideoOrGallerySchema,
364
+ photogallery_list: z.array(tUrlAbsoluteStringSchema),
365
+ photogallery_title: z.string(),
366
+ photogallery_link: tUrlRelativeStringSchema,
367
+ post_meta: tPostMetaSchema,
368
+ leggiAnche: z.array(tLeggiAncheSchema),
369
+ format: z.union([
370
+ z.literal("standard"),
371
+ z.literal("aside"),
372
+ z.literal("chat"),
373
+ z.literal("gallery"),
374
+ z.literal("link"),
375
+ z.literal("image"),
376
+ z.literal("quote"),
377
+ z.literal("status"),
378
+ z.literal("video"),
379
+ z.literal("audio"),
380
+ ]),
381
+ sticky: z.boolean(),
382
+ meta: z.array(z.number()),
383
+ });
384
+
385
+ export const tAnnuncioFamigliaSchema = tPostBaseSchema
386
+ .omit({ _embedded: true })
387
+ .extend({
388
+ type: z.literal("annuncio-famiglia"),
389
+ post_meta: tAnnuncioFamigliaMetaSchema,
390
+ _embedded: z.object({
391
+ type: z.array(tPostTypesSchema),
392
+ author: z.array(tAuthorNecroSchema),
393
+ "wp:featuredmedia": z.array(tFeaturedMediaSchema),
394
+ }),
395
+ });
package/widgetTypes.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { tPost, tAppoggio, tVideoOrGallery } from ".";
2
+
3
+ type tSidebars =
4
+ | "home_breaking_box_2"
5
+ | "home_breaking_box_3"
6
+ | "home_breaking_box_4"
7
+ | "common_before_footer"
8
+ | "common_inside_footer"
9
+ | "common_ads_header"
10
+ | "common_desktop_header"
11
+ | "common_mobile_header"
12
+ | "common_archive_incontent"
13
+ | "home_sidebar_apertura"
14
+ | "single_post_sidebar"
15
+ | "single_post_incontent"
16
+ | "single_post_below_photo"
17
+ | "single_post_below_content"
18
+ | "single_video_incontent"
19
+ | "single_fotogallery_incontent"
20
+ | "page_standard"
21
+ | "page_video_home_incontent"
22
+ | "page_photogallery_home_incontent"
23
+ | "page_evento_home_incontent"
24
+ | "category_incontent"
25
+ | "single_necrologio_sidebar";
26
+
27
+ interface tPayloadAds {
28
+ name: string;
29
+ slot: string;
30
+ priority: number;
31
+ provider: "admanager" | "pct";
32
+ mobSize: number[];
33
+ deskSize: number[];
34
+ }
35
+
36
+ interface tWidgetBase {
37
+ id: string;
38
+ id_base: string;
39
+ sidebar: tSidebars;
40
+ rendered: string;
41
+ payloadAds: null | "" | [] | tPayloadAds[];
42
+ nameWidget: null | string;
43
+ blockType: null | "ads_widget";
44
+ _links: Record<string, Array<{ href: string }>>;
45
+ }
46
+
47
+ export interface tEditorialiWidgetData extends tWidgetBase {
48
+ settings: {
49
+ title: string,
50
+ layout: "layout_4" | "layout_8",
51
+ taxonomy: "category" | "tag" | "",
52
+ selection_ID: string,
53
+ background_color: string,
54
+ text_color: string,
55
+ accent_color: string,
56
+ lines_color: string,
57
+ see_more: string,
58
+ id_taxonomy: string,
59
+ },
60
+ payloadContent: tPost[]
61
+ }
62
+
63
+ export interface tBreakingTopPayload {
64
+ id: "string",
65
+ title: {
66
+ rendered: string;
67
+ },
68
+ date: {
69
+ date : string,
70
+ timezone_type: number,
71
+ timezone : string
72
+ },
73
+ copertina: {
74
+ og_image : string,
75
+ source_url : string,
76
+ coverUrl : string,
77
+ bck_code : string
78
+ }
79
+ excerpt: {
80
+ rendered: string
81
+ },
82
+ appoggi : tAppoggio[],
83
+ strillo: string,
84
+ author: {
85
+ id : string,
86
+ link : string,
87
+ image : string,
88
+ name : string
89
+ },
90
+ link : string,
91
+ slug : string,
92
+ video_o_gallery : tVideoOrGallery,
93
+ numeroFotoGallery : null
94
+ luogoEvento : null
95
+ dataInizioEvento : null
96
+ dataFineEvento : null
97
+ tipoDoublePost : null
98
+ titoloRubrica : null
99
+ linkRubrica : null
100
+ imgRubrica : null
101
+ meteoCittaHome : null
102
+ meteoProvincia : null
103
+ meteoFuoriProvincia : null,
104
+ type : "post"
105
+ }