glitch-javascript-sdk 3.2.9 → 3.2.10

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,440 @@
1
+ import PrDirectoryRoutes from "../routes/PrDirectoryRoutes";
2
+ import Requests from "../util/Requests";
3
+ import Response from "../util/Response";
4
+ import { AxiosPromise } from "axios";
5
+
6
+ /**
7
+ * Allowed outlet types in the PR directory.
8
+ */
9
+ export type PrPublicationType = "blog" | "podcast" | "publication";
10
+
11
+ /**
12
+ * Eligibility state for a PR outlet.
13
+ */
14
+ export type PrEligibilityStatus = "eligible" | "ineligible" | "needs_review" | "duplicate" | "archived";
15
+
16
+ /**
17
+ * Verification state used by PR outlets, people, links, and contact points.
18
+ */
19
+ export type PrVerificationStatus = "unverified" | "verified" | "stale" | "blocked" | "failed" | "needs_review";
20
+
21
+ /**
22
+ * Email health status stored on the outlet-level PR email field.
23
+ */
24
+ export type PrEmailStatus = "unknown" | "verified" | "bounced" | "missing" | "needs_review";
25
+
26
+ /**
27
+ * Contact verification state for normalized contact points.
28
+ */
29
+ export type PrContactVerificationStatus =
30
+ | "unverified"
31
+ | "verified"
32
+ | "stale"
33
+ | "bounced"
34
+ | "invalid"
35
+ | "blocked"
36
+ | "needs_review";
37
+
38
+ /**
39
+ * Link refresh status for evidence URLs.
40
+ */
41
+ export type PrLinkStatus = "unverified" | "ok" | "redirected" | "broken" | "blocked" | "failed" | "stale";
42
+
43
+ /**
44
+ * Filters accepted by `/pr/publications` and `/pr/report`.
45
+ *
46
+ * Tag filters are human-readable slugs from `/pr/tags`. The backend accepts
47
+ * format, genre, platform, and audience as namespace-specific tag filters so
48
+ * frontend screens can expose simple controls without knowing pivot table
49
+ * details.
50
+ */
51
+ export interface PrPublicationSearchParams {
52
+ q?: string;
53
+ type?: PrPublicationType;
54
+ eligibility_status?: PrEligibilityStatus;
55
+ verification_status?: PrVerificationStatus;
56
+ dedicated_to_gaming?: boolean;
57
+ has_email?: boolean;
58
+ country?: string;
59
+ language?: string;
60
+ canonical_domain?: string;
61
+ tag?: string;
62
+ format?: string;
63
+ genre?: string;
64
+ platform?: string;
65
+ audience?: string;
66
+ sort?: "name" | "-name" | "type" | "-type" | "eligibility_status" | "-eligibility_status" | "verification_status" | "-verification_status" | "last_verified_at" | "-last_verified_at" | "updated_at" | "-updated_at" | string;
67
+ page?: number;
68
+ per_page?: number;
69
+ }
70
+
71
+ /**
72
+ * Filters accepted by `/pr/people`.
73
+ */
74
+ export interface PrPeopleSearchParams {
75
+ q?: string;
76
+ publication_id?: string;
77
+ role_category?: string;
78
+ is_active?: boolean;
79
+ verification_status?: PrVerificationStatus;
80
+ has_email?: boolean;
81
+ tag?: string;
82
+ role?: string;
83
+ sort?: "name" | "-name" | "verification_status" | "-verification_status" | "last_verified_at" | "-last_verified_at" | "updated_at" | "-updated_at" | string;
84
+ page?: number;
85
+ per_page?: number;
86
+ }
87
+
88
+ /**
89
+ * Filters accepted by `/pr/tags`.
90
+ */
91
+ export interface PrTagSearchParams {
92
+ namespace?: string;
93
+ q?: string;
94
+ }
95
+
96
+ /**
97
+ * Query parameters accepted by `/titles/{title_id}/pr/matches`.
98
+ *
99
+ * The title matcher uses the title profile plus optional human-readable search
100
+ * context to rank eligible outlets and explain why each outlet is a fit.
101
+ */
102
+ export interface PrTitleMatchParams extends PrPublicationSearchParams {
103
+ genres?: string[];
104
+ platforms?: string[];
105
+ audiences?: string[];
106
+ limit?: number;
107
+ }
108
+
109
+ /**
110
+ * Request body accepted by `/admin/pr/verification/queue`.
111
+ */
112
+ export interface PrQueueVerificationRequest {
113
+ due?: boolean;
114
+ limit?: number;
115
+ link_ids?: string[];
116
+ }
117
+
118
+ /**
119
+ * A normalized metadata tag used to filter and match PR outlets, people, and
120
+ * roles.
121
+ */
122
+ export interface PrTag {
123
+ id: string;
124
+ namespace: string;
125
+ slug: string;
126
+ label: string;
127
+ description?: string | null;
128
+ pivot?: {
129
+ confidence?: number | null;
130
+ source?: string | null;
131
+ source_link_id?: string | null;
132
+ verified_at?: string | null;
133
+ metadata?: Record<string, any> | null;
134
+ };
135
+ metadata?: Record<string, any>;
136
+ created_at?: string | null;
137
+ updated_at?: string | null;
138
+ }
139
+
140
+ /**
141
+ * A refreshable evidence URL that supports an outlet, person, role, or contact
142
+ * point.
143
+ */
144
+ export interface PrLink {
145
+ id: string;
146
+ linkable_type?: string | null;
147
+ linkable_id?: string | null;
148
+ link_type: string;
149
+ url: string;
150
+ canonical_url?: string | null;
151
+ final_url?: string | null;
152
+ domain?: string | null;
153
+ priority: number;
154
+ http_status?: number | null;
155
+ status: PrLinkStatus;
156
+ content_type?: string | null;
157
+ content_hash?: string | null;
158
+ etag?: string | null;
159
+ last_modified_at?: string | null;
160
+ last_checked_at?: string | null;
161
+ next_check_at?: string | null;
162
+ last_error?: string | null;
163
+ is_source_of_truth: boolean;
164
+ metadata?: Record<string, any>;
165
+ created_at?: string | null;
166
+ updated_at?: string | null;
167
+ }
168
+
169
+ /**
170
+ * A normalized way to reach an outlet, person, or publication role.
171
+ */
172
+ export interface PrContactPoint {
173
+ id: string;
174
+ contactable_type: string;
175
+ contactable_id: string;
176
+ pr_link_id?: string | null;
177
+ contact_type: "email" | "linkedin" | "x" | "bluesky" | "contact_form" | string;
178
+ label?: string | null;
179
+ value: string;
180
+ normalized_value: string;
181
+ verification_status: PrContactVerificationStatus;
182
+ confidence?: number | null;
183
+ is_primary: boolean;
184
+ first_seen_at?: string | null;
185
+ last_seen_at?: string | null;
186
+ source_link?: PrLink | null;
187
+ metadata?: Record<string, any>;
188
+ created_at?: string | null;
189
+ updated_at?: string | null;
190
+ }
191
+
192
+ /**
193
+ * The role a PR person has at one publication, blog, or podcast.
194
+ */
195
+ export interface PublicationPerson {
196
+ id: string;
197
+ publication_id: string;
198
+ pr_person_id: string;
199
+ source_link_id?: string | null;
200
+ role_title?: string | null;
201
+ role_category?: string | null;
202
+ email?: string | null;
203
+ email_status: "unknown" | "verified" | "bounced" | "invalid" | "needs_review";
204
+ is_primary_contact: boolean;
205
+ is_current: boolean;
206
+ confidence?: number | null;
207
+ started_at?: string | null;
208
+ ended_at?: string | null;
209
+ last_verified_at?: string | null;
210
+ source_notes?: string | null;
211
+ person?: PrPerson | null;
212
+ publication?: PrPublication | null;
213
+ source_link?: PrLink | null;
214
+ contact_points?: PrContactPoint[];
215
+ tags?: PrTag[];
216
+ metadata?: Record<string, any>;
217
+ created_at?: string | null;
218
+ updated_at?: string | null;
219
+ }
220
+
221
+ /**
222
+ * A gaming-focused publication, independent blog, or podcast in the PR
223
+ * directory.
224
+ */
225
+ export interface PrPublication {
226
+ id: string;
227
+ name: string;
228
+ slug?: string | null;
229
+ type: PrPublicationType;
230
+ url?: string | null;
231
+ canonical_domain?: string | null;
232
+ description?: string | null;
233
+ main_pr_email?: string | null;
234
+ main_pr_email_status: PrEmailStatus;
235
+ dedicated_to_gaming: boolean;
236
+ eligibility_status: PrEligibilityStatus;
237
+ exclusion_reason?: string | null;
238
+ language?: string | null;
239
+ country?: string | null;
240
+ network_or_owner?: string | null;
241
+ verification_status: PrVerificationStatus;
242
+ last_verified_at?: string | null;
243
+ next_verification_at?: string | null;
244
+ source_imported_at?: string | null;
245
+ people_count?: number;
246
+ contact_points_count?: number;
247
+ links_count?: number;
248
+ people?: PublicationPerson[];
249
+ contact_points?: PrContactPoint[];
250
+ links?: PrLink[];
251
+ tags?: PrTag[];
252
+ metadata?: Record<string, any>;
253
+ created_at?: string | null;
254
+ updated_at?: string | null;
255
+ }
256
+
257
+ /**
258
+ * A journalist, editor, podcast host, producer, contributor, or other PR
259
+ * contact associated with one or more gaming-focused outlets.
260
+ */
261
+ export interface PrPerson {
262
+ id: string;
263
+ name: string;
264
+ slug?: string | null;
265
+ bio?: string | null;
266
+ location?: string | null;
267
+ linkedin_url?: string | null;
268
+ x_url?: string | null;
269
+ bluesky_url?: string | null;
270
+ website_url?: string | null;
271
+ is_active: boolean;
272
+ verification_status: PrVerificationStatus;
273
+ last_verified_at?: string | null;
274
+ next_verification_at?: string | null;
275
+ roles_count?: number;
276
+ contact_points_count?: number;
277
+ links_count?: number;
278
+ roles?: PublicationPerson[];
279
+ contact_points?: PrContactPoint[];
280
+ links?: PrLink[];
281
+ tags?: PrTag[];
282
+ metadata?: Record<string, any>;
283
+ created_at?: string | null;
284
+ updated_at?: string | null;
285
+ }
286
+
287
+ /**
288
+ * Aggregate PR directory health metrics returned by `/pr/report`.
289
+ */
290
+ export interface PrDirectoryReport {
291
+ generated_at: string;
292
+ publications: {
293
+ total: number;
294
+ by_type: Record<string, number>;
295
+ by_eligibility_status: Record<string, number>;
296
+ by_verification_status: Record<string, number>;
297
+ dedicated_to_gaming: number;
298
+ with_email: number;
299
+ due_for_verification: number;
300
+ };
301
+ people: {
302
+ total: number;
303
+ active: number;
304
+ with_email: number;
305
+ by_verification_status: Record<string, number>;
306
+ };
307
+ links: {
308
+ total: number;
309
+ by_type: Record<string, number>;
310
+ by_status: Record<string, number>;
311
+ due_for_check: number;
312
+ };
313
+ contacts: {
314
+ total: number;
315
+ by_type: Record<string, number>;
316
+ by_status: Record<string, number>;
317
+ };
318
+ tags: {
319
+ total: number;
320
+ by_namespace: Record<string, number>;
321
+ };
322
+ }
323
+
324
+ /**
325
+ * A ranked title-to-outlet match with evidence, contact route, and plain-English
326
+ * explanation.
327
+ */
328
+ export interface PrTitleMatch {
329
+ publication: PrPublication;
330
+ score: number;
331
+ matched_tags: string[];
332
+ best_contact_path?: Record<string, any> | null;
333
+ why: string[];
334
+ risks: string[];
335
+ evidence_links: PrLink[];
336
+ }
337
+
338
+ /**
339
+ * Response body returned after queueing PR verification jobs.
340
+ */
341
+ export interface PrQueueVerificationResponse {
342
+ queued: number;
343
+ }
344
+
345
+ /**
346
+ * SDK wrapper for the PR Directory API.
347
+ *
348
+ * The PR directory is read-friendly by default: public endpoints expose
349
+ * searchable publications, people, tags, and reporting metrics. Authenticated
350
+ * title admins can request title-specific PR matches, and site admins can queue
351
+ * monthly-style verification jobs.
352
+ */
353
+ class PrDirectory {
354
+ /**
355
+ * Search gaming-focused PR publications, independent blogs, and podcasts.
356
+ *
357
+ * @example
358
+ * ```ts
359
+ * Glitch.api.PrDirectory.listPublications({
360
+ * q: "indie RPG",
361
+ * has_email: true,
362
+ * eligibility_status: "eligible",
363
+ * sort: "-last_verified_at",
364
+ * });
365
+ * ```
366
+ */
367
+ public static listPublications<T = PrPublication[]>(params?: PrPublicationSearchParams): AxiosPromise<Response<T>> {
368
+ return Requests.processRoute(PrDirectoryRoutes.routes.listPublications, {}, {}, params);
369
+ }
370
+
371
+ /**
372
+ * Retrieve one PR publication profile with loaded people, contact points,
373
+ * evidence links, and tags.
374
+ */
375
+ public static viewPublication<T = PrPublication>(publication_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
376
+ return Requests.processRoute(PrDirectoryRoutes.routes.viewPublication, {}, { publication_id }, params);
377
+ }
378
+
379
+ /**
380
+ * Search PR people and roles across all known publications.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * Glitch.api.PrDirectory.listPeople({
385
+ * q: "reviews editor",
386
+ * has_email: true,
387
+ * role_category: "editor",
388
+ * });
389
+ * ```
390
+ */
391
+ public static listPeople<T = PrPerson[]>(params?: PrPeopleSearchParams): AxiosPromise<Response<T>> {
392
+ return Requests.processRoute(PrDirectoryRoutes.routes.listPeople, {}, {}, params);
393
+ }
394
+
395
+ /**
396
+ * Retrieve one PR person profile with their outlet roles, profile links,
397
+ * contact points, and metadata tags.
398
+ */
399
+ public static viewPerson<T = PrPerson>(person_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
400
+ return Requests.processRoute(PrDirectoryRoutes.routes.viewPerson, {}, { person_id }, params);
401
+ }
402
+
403
+ /**
404
+ * List the normalized tag vocabulary used for PR search, filters, matching,
405
+ * and reporting.
406
+ */
407
+ public static listTags<T = PrTag[]>(params?: PrTagSearchParams): AxiosPromise<Response<T>> {
408
+ return Requests.processRoute(PrDirectoryRoutes.routes.listTags, {}, {}, params);
409
+ }
410
+
411
+ /**
412
+ * Get aggregate PR directory reporting metrics. Publication filters can be
413
+ * supplied to scope the outlet portion of the report.
414
+ */
415
+ public static report<T = PrDirectoryReport>(params?: PrPublicationSearchParams): AxiosPromise<Response<T>> {
416
+ return Requests.processRoute(PrDirectoryRoutes.routes.report, {}, {}, params);
417
+ }
418
+
419
+ /**
420
+ * Match a registered game title to PR outlets. Requires an auth token for a
421
+ * user who can administer the requested title.
422
+ */
423
+ public static titleMatches<T = PrTitleMatch[]>(title_id: string, params?: PrTitleMatchParams): AxiosPromise<Response<T>> {
424
+ return Requests.processRoute(PrDirectoryRoutes.routes.titleMatches, {}, { title_id }, params);
425
+ }
426
+
427
+ /**
428
+ * Queue PR verification jobs. Requires a site-admin auth token.
429
+ *
430
+ * @example
431
+ * ```ts
432
+ * Glitch.api.PrDirectory.queueVerification({ due: true, limit: 250 });
433
+ * ```
434
+ */
435
+ public static queueVerification<T = PrQueueVerificationResponse>(data?: PrQueueVerificationRequest, params?: Record<string, any>): AxiosPromise<Response<T>> {
436
+ return Requests.processRoute(PrDirectoryRoutes.routes.queueVerification, data || {}, {}, params);
437
+ }
438
+ }
439
+
440
+ export default PrDirectory;
package/src/api/index.ts CHANGED
@@ -46,6 +46,7 @@ import Crm from "./Crm";
46
46
  import Multiplayer from "./Multiplayer";
47
47
  import ServerOperations from "./ServerOperations";
48
48
  import Agents from "./Agents";
49
+ import PrDirectory from "./PrDirectory";
49
50
 
50
51
  export {Ads};
51
52
  export {AccessKeys};
@@ -95,3 +96,4 @@ export {Crm};
95
96
  export {Multiplayer};
96
97
  export {ServerOperations};
97
98
  export {Agents};
99
+ export {PrDirectory};
package/src/index.ts CHANGED
@@ -50,6 +50,7 @@ import {Crm} from './api';
50
50
  import {Multiplayer} from './api';
51
51
  import {ServerOperations} from './api';
52
52
  import {Agents} from './api';
53
+ import {PrDirectory} from './api';
53
54
 
54
55
  import Requests from "./util/Requests";
55
56
  import Parser from "./util/Parser";
@@ -129,6 +130,7 @@ class Glitch {
129
130
  Multiplayer : Multiplayer,
130
131
  ServerOperations : ServerOperations,
131
132
  Agents : Agents,
133
+ PrDirectory : PrDirectory,
132
134
  }
133
135
 
134
136
  public static util = {
@@ -0,0 +1,25 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ /**
5
+ * Route declarations for the PR Directory API.
6
+ *
7
+ * These mirror the Laravel routes under `/api/pr/*` and the title-scoped
8
+ * matcher route under `/api/titles/{title_id}/pr/matches`. Keeping the URL
9
+ * templates in one place lets the SDK methods stay small and consistent with
10
+ * the rest of the package's route-wrapper pattern.
11
+ */
12
+ class PrDirectoryRoutes {
13
+ public static routes: { [key: string]: Route } = {
14
+ listPublications: { url: "/pr/publications", method: HTTP_METHODS.GET },
15
+ viewPublication: { url: "/pr/publications/{publication_id}", method: HTTP_METHODS.GET },
16
+ listPeople: { url: "/pr/people", method: HTTP_METHODS.GET },
17
+ viewPerson: { url: "/pr/people/{person_id}", method: HTTP_METHODS.GET },
18
+ listTags: { url: "/pr/tags", method: HTTP_METHODS.GET },
19
+ report: { url: "/pr/report", method: HTTP_METHODS.GET },
20
+ titleMatches: { url: "/titles/{title_id}/pr/matches", method: HTTP_METHODS.GET },
21
+ queueVerification: { url: "/admin/pr/verification/queue", method: HTTP_METHODS.POST },
22
+ };
23
+ }
24
+
25
+ export default PrDirectoryRoutes;