glitch-javascript-sdk 3.8.0 → 3.8.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/dist/index.d.ts CHANGED
@@ -6966,6 +6966,95 @@ declare class Media {
6966
6966
  static process<T>(media_id: string, data: VideoProcessRequest): AxiosPromise<Response<T>>;
6967
6967
  }
6968
6968
 
6969
+ type DiscordMediaType = 'all' | 'image' | 'video' | 'gif';
6970
+ type DiscordMediaAuthorType = 'all' | 'user' | 'bot' | 'webhook';
6971
+ interface DiscordMediaSearchParams {
6972
+ cursor?: string;
6973
+ channel_id?: string;
6974
+ search?: string;
6975
+ search_scope?: 'content' | 'filename';
6976
+ media_type?: DiscordMediaType;
6977
+ author_type?: DiscordMediaAuthorType;
6978
+ date_from?: string;
6979
+ date_to?: string;
6980
+ sort_order?: 'asc' | 'desc';
6981
+ include_imported?: boolean;
6982
+ include_unsupported?: boolean;
6983
+ include_nsfw?: boolean;
6984
+ }
6985
+ interface DiscordMediaAttachment {
6986
+ id: string;
6987
+ filename: string;
6988
+ title?: string | null;
6989
+ description?: string | null;
6990
+ mime_type: string;
6991
+ media_type: 'image' | 'video';
6992
+ size: number;
6993
+ url?: string | null;
6994
+ proxy_url?: string | null;
6995
+ width?: number | null;
6996
+ height?: number | null;
6997
+ duration_secs?: number | null;
6998
+ supported: boolean;
6999
+ unsupported_reason?: string | null;
7000
+ already_imported: boolean;
7001
+ imported_title_update_id?: string | null;
7002
+ imported_media_id?: string | null;
7003
+ duplicate_import: boolean;
7004
+ }
7005
+ interface DiscordMediaMessage {
7006
+ id: string;
7007
+ channel_id: string;
7008
+ content: string;
7009
+ timestamp?: string | null;
7010
+ edited_timestamp?: string | null;
7011
+ jump_url: string;
7012
+ author: {
7013
+ id?: string | null;
7014
+ username: string;
7015
+ avatar?: string | null;
7016
+ bot: boolean;
7017
+ };
7018
+ webhook_id?: string | null;
7019
+ attachments: DiscordMediaAttachment[];
7020
+ }
7021
+ interface DiscordMediaSearchResponse {
7022
+ items: DiscordMediaMessage[];
7023
+ total_results: number;
7024
+ next_cursor?: string | null;
7025
+ indexing: boolean;
7026
+ retry_after?: number | null;
7027
+ }
7028
+ interface DiscordMediaImportGroup {
7029
+ channel_id: string;
7030
+ message_id: string;
7031
+ attachment_ids: string[];
7032
+ }
7033
+ interface DiscordMediaImportRequest {
7034
+ groups: DiscordMediaImportGroup[];
7035
+ }
7036
+ interface DiscordMediaImportAttachmentResult {
7037
+ status: 'imported' | 'duplicate' | 'failed';
7038
+ channel_id: string;
7039
+ message_id: string;
7040
+ attachment_id: string;
7041
+ media_id?: string;
7042
+ title_update_id?: string;
7043
+ reason?: string;
7044
+ }
7045
+ interface DiscordMediaImportResponse {
7046
+ imported_count: number;
7047
+ duplicate_count: number;
7048
+ failed_count: number;
7049
+ updates: Array<{
7050
+ id: string;
7051
+ title?: string | null;
7052
+ scheduled_status: 'pending';
7053
+ schedule_for_social: false;
7054
+ media_count: number;
7055
+ }>;
7056
+ attachments: DiscordMediaImportAttachmentResult[];
7057
+ }
6969
7058
  declare class Scheduler {
6970
7059
  /**
6971
7060
  * List promotion schedules.
@@ -7276,6 +7365,17 @@ declare class Scheduler {
7276
7365
  * @returns promise
7277
7366
  */
7278
7367
  static getDiscordChannels<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
7368
+ /**
7369
+ * Search image and video attachments in the connected Discord server.
7370
+ * This call only returns remote candidates; it does not copy files into the
7371
+ * Library and does not create or schedule social posts.
7372
+ */
7373
+ static searchDiscordMedia<T = DiscordMediaSearchResponse>(scheduler_id: string, params?: DiscordMediaSearchParams): AxiosPromise<Response<T>>;
7374
+ /**
7375
+ * Import explicitly selected Discord attachments as pending, unscheduled
7376
+ * Library updates. Attachments selected from one message stay grouped.
7377
+ */
7378
+ static importDiscordMedia<T = DiscordMediaImportResponse>(scheduler_id: string, data: DiscordMediaImportRequest, params?: Record<string, any>): AxiosPromise<Response<T>>;
7279
7379
  /**
7280
7380
  * Clear Google Ads OAuth credentials from a promotion schedule.
7281
7381
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "types": "dist/index.d.ts",
15
15
  "scripts": {
16
- "test": "node scripts/test-game-advertising-routes.cjs",
16
+ "test": "node scripts/test-game-advertising-routes.cjs && node scripts/test-discord-media-routes.cjs",
17
17
  "build": "rm -Rf dist && rollup -c --bundleConfigAsCjs",
18
18
  "build-docs": "rm -rf docs && typedoc --tsconfig tsconfig.json src/"
19
19
  },
@@ -3,6 +3,104 @@ import Requests from "../util/Requests";
3
3
  import Response from "../util/Response";
4
4
  import { AxiosPromise } from "axios";
5
5
 
6
+ export type DiscordMediaType = 'all' | 'image' | 'video' | 'gif';
7
+ export type DiscordMediaAuthorType = 'all' | 'user' | 'bot' | 'webhook';
8
+
9
+ export interface DiscordMediaSearchParams {
10
+ cursor?: string;
11
+ channel_id?: string;
12
+ search?: string;
13
+ search_scope?: 'content' | 'filename';
14
+ media_type?: DiscordMediaType;
15
+ author_type?: DiscordMediaAuthorType;
16
+ date_from?: string;
17
+ date_to?: string;
18
+ sort_order?: 'asc' | 'desc';
19
+ include_imported?: boolean;
20
+ include_unsupported?: boolean;
21
+ include_nsfw?: boolean;
22
+ }
23
+
24
+ export interface DiscordMediaAttachment {
25
+ id: string;
26
+ filename: string;
27
+ title?: string | null;
28
+ description?: string | null;
29
+ mime_type: string;
30
+ media_type: 'image' | 'video';
31
+ size: number;
32
+ url?: string | null;
33
+ proxy_url?: string | null;
34
+ width?: number | null;
35
+ height?: number | null;
36
+ duration_secs?: number | null;
37
+ supported: boolean;
38
+ unsupported_reason?: string | null;
39
+ already_imported: boolean;
40
+ imported_title_update_id?: string | null;
41
+ imported_media_id?: string | null;
42
+ duplicate_import: boolean;
43
+ }
44
+
45
+ export interface DiscordMediaMessage {
46
+ id: string;
47
+ channel_id: string;
48
+ content: string;
49
+ timestamp?: string | null;
50
+ edited_timestamp?: string | null;
51
+ jump_url: string;
52
+ author: {
53
+ id?: string | null;
54
+ username: string;
55
+ avatar?: string | null;
56
+ bot: boolean;
57
+ };
58
+ webhook_id?: string | null;
59
+ attachments: DiscordMediaAttachment[];
60
+ }
61
+
62
+ export interface DiscordMediaSearchResponse {
63
+ items: DiscordMediaMessage[];
64
+ total_results: number;
65
+ next_cursor?: string | null;
66
+ indexing: boolean;
67
+ retry_after?: number | null;
68
+ }
69
+
70
+ export interface DiscordMediaImportGroup {
71
+ channel_id: string;
72
+ message_id: string;
73
+ attachment_ids: string[];
74
+ }
75
+
76
+ export interface DiscordMediaImportRequest {
77
+ groups: DiscordMediaImportGroup[];
78
+ }
79
+
80
+ export interface DiscordMediaImportAttachmentResult {
81
+ status: 'imported' | 'duplicate' | 'failed';
82
+ channel_id: string;
83
+ message_id: string;
84
+ attachment_id: string;
85
+ media_id?: string;
86
+ title_update_id?: string;
87
+ reason?: string;
88
+ }
89
+
90
+ export interface DiscordMediaImportResponse {
91
+ imported_count: number;
92
+ duplicate_count: number;
93
+ failed_count: number;
94
+ updates: Array<{
95
+ id: string;
96
+ title?: string | null;
97
+ scheduled_status: 'pending';
98
+ schedule_for_social: false;
99
+ media_count: number;
100
+ }>;
101
+ attachments: DiscordMediaImportAttachmentResult[];
102
+ }
103
+
6
104
  class Scheduler {
7
105
  /**
8
106
  * List promotion schedules.
@@ -431,6 +529,30 @@ class Scheduler {
431
529
  return Requests.processRoute(SchedulerRoute.routes.getDiscordChannels, {}, { scheduler_id }, params);
432
530
  }
433
531
 
532
+ /**
533
+ * Search image and video attachments in the connected Discord server.
534
+ * This call only returns remote candidates; it does not copy files into the
535
+ * Library and does not create or schedule social posts.
536
+ */
537
+ public static searchDiscordMedia<T = DiscordMediaSearchResponse>(
538
+ scheduler_id: string,
539
+ params?: DiscordMediaSearchParams
540
+ ): AxiosPromise<Response<T>> {
541
+ return Requests.processRoute(SchedulerRoute.routes.searchDiscordMedia, {}, { scheduler_id }, params);
542
+ }
543
+
544
+ /**
545
+ * Import explicitly selected Discord attachments as pending, unscheduled
546
+ * Library updates. Attachments selected from one message stay grouped.
547
+ */
548
+ public static importDiscordMedia<T = DiscordMediaImportResponse>(
549
+ scheduler_id: string,
550
+ data: DiscordMediaImportRequest,
551
+ params?: Record<string, any>
552
+ ): AxiosPromise<Response<T>> {
553
+ return Requests.processRoute(SchedulerRoute.routes.importDiscordMedia, data, { scheduler_id }, params);
554
+ }
555
+
434
556
  /**
435
557
  * Clear Google Ads OAuth credentials from a promotion schedule.
436
558
  *
@@ -50,6 +50,8 @@ class SchedulerRoute {
50
50
  getRedditSubredditFlairs: { url: '/schedulers/{scheduler_id}/reddit/subreddits/{subreddit}/flairs', method: HTTP_METHODS.GET },
51
51
  getRedditSubredditRules: { url: '/schedulers/{scheduler_id}/reddit/subreddits/{subreddit}/rules', method: HTTP_METHODS.GET },
52
52
  getDiscordChannels: { url: '/schedulers/{scheduler_id}/discord/channels', method: HTTP_METHODS.GET },
53
+ searchDiscordMedia: { url: '/schedulers/{scheduler_id}/discord/media', method: HTTP_METHODS.GET },
54
+ importDiscordMedia: { url: '/schedulers/{scheduler_id}/discord/media/import', method: HTTP_METHODS.POST },
53
55
 
54
56
  crossPromoteListRelationships: {
55
57
  url: '/schedulers/{scheduler_id}/crosspromote/relationships',