glitch-javascript-sdk 3.6.0 → 3.7.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.
@@ -1,5 +1,9 @@
1
1
  import Route from './interface';
2
2
  declare class GameAdvertisingRoute {
3
+ /**
4
+ * Route templates for publisher game-ad inventory, telemetry, earnings, and
5
+ * site administration. Placeholders are expanded by Requests.processRoute.
6
+ */
3
7
  static routes: {
4
8
  [key: string]: Route;
5
9
  };
package/dist/index.d.ts CHANGED
@@ -1893,6 +1893,50 @@ declare class Communities {
1893
1893
  static saveInfluencerToPool<T>(community_id: string, data: object): AxiosPromise<Response<T>>;
1894
1894
  }
1895
1895
 
1896
+ /** Human-readable earning categories returned by influencer payout APIs. */
1897
+ type InfluencerPayoutSourceType = "campaign_compensation" | "ad_revenue_share" | "subscription_residual" | "manual_adjustment";
1898
+ /** Auditable metrics and creator-content attribution attached to a payout. */
1899
+ interface InfluencerPayoutBreakdown {
1900
+ label?: string;
1901
+ payment_method?: "flat" | "performance" | "hybrid";
1902
+ provider?: string;
1903
+ period_start?: string;
1904
+ period_end?: string;
1905
+ impressions?: number;
1906
+ clicks?: number;
1907
+ short_link_id?: string | null;
1908
+ short_link_click_id?: string | null;
1909
+ social_media_post_id?: string | null;
1910
+ tracking_link_label?: string | null;
1911
+ social_platform?: string | null;
1912
+ social_post_url?: string | null;
1913
+ }
1914
+ /** One campaign or advertising earning payable to the authenticated influencer. */
1915
+ interface InfluencerPayout {
1916
+ id: string;
1917
+ user_id: string;
1918
+ campaign_id: string;
1919
+ amount: number;
1920
+ currency: string;
1921
+ status: "pending" | "completed" | "failed";
1922
+ payout_date?: string | null;
1923
+ source_type: InfluencerPayoutSourceType;
1924
+ source_label: string;
1925
+ source_reference_id?: string | null;
1926
+ breakdown?: InfluencerPayoutBreakdown;
1927
+ campaign?: Record<string, any>;
1928
+ }
1929
+ /** Optional filters for the authenticated influencer's payout history. */
1930
+ interface InfluencerPayoutQuery {
1931
+ campaign_id?: string;
1932
+ month?: number;
1933
+ year?: number;
1934
+ amount?: number;
1935
+ status?: "pending" | "completed" | "failed";
1936
+ source_type?: InfluencerPayoutSourceType;
1937
+ orderBy?: "created_at" | "amount";
1938
+ orderDirection?: "asc" | "desc";
1939
+ }
1896
1940
  declare class Users {
1897
1941
  /**
1898
1942
  * List all the users.
@@ -1935,16 +1979,17 @@ declare class Users {
1935
1979
  */
1936
1980
  static getCampaignInvites<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
1937
1981
  /**
1938
- * Gets payouts from past campaings
1982
+ * Gets the authenticated influencer's payouts from campaigns and attributed
1983
+ * game advertising. Advertising revenue is returned as a separate additive
1984
+ * source with provider-period metrics and tracking-link/social-post IDs.
1939
1985
  *
1940
1986
  * @see https://api.glitch.fun/api/documentation#/Users%20Route/showMe
1941
1987
  *
1942
- * @param user_id The id of the user to update.
1943
- * @param data The data to update.
1988
+ * @param params Optional campaign, date, status, source, and ordering filters.
1944
1989
  *
1945
1990
  * @returns promise
1946
1991
  */
1947
- static getPayouts<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
1992
+ static getPayouts<T = InfluencerPayout[]>(params?: InfluencerPayoutQuery): AxiosPromise<Response<T>>;
1948
1993
  /**
1949
1994
  * Sync the current influencer's information.
1950
1995
  *
@@ -11028,25 +11073,89 @@ declare class MarketResearch {
11028
11073
  }
11029
11074
 
11030
11075
  interface GameAdEventPayload {
11076
+ /** Opaque token returned by the server-created advertising manifest. */
11031
11077
  token: string;
11078
+ /** Client idempotency UUID. Reuse is valid only within the same ad session. */
11032
11079
  event_uuid?: string;
11080
+ /** Provider that produced or attempted the event. */
11033
11081
  provider: string;
11082
+ /** Stable Glitch placement name, such as game_banner or game_video. */
11034
11083
  placement: string;
11035
- format: 'banner' | 'video' | 'interstitial' | 'rewarded' | 'other';
11036
- event_type: 'sdk_ready' | 'request_started' | 'loaded' | 'no_fill' | 'started' | 'impression' | 'viewable' | 'clicked' | 'completed' | 'skipped' | 'closed' | 'paused_game' | 'resumed_game' | 'error';
11084
+ /** Normalized creative/ad format. */
11085
+ format: 'banner' | 'video' | 'interstitial' | 'rewarded' | 'in_game_image' | 'in_game_video' | 'other';
11086
+ /** Normalized SDK/ad lifecycle event. */
11087
+ event_type: 'sdk_ready' | 'request_started' | 'loaded' | 'channel_registered' | 'measurement' | 'no_fill' | 'fallback_shown' | 'started' | 'impression' | 'viewable' | 'clicked' | 'completed' | 'skipped' | 'closed' | 'paused_game' | 'resumed_game' | 'error';
11088
+ /** Optional provider-native event or impression identifier. */
11037
11089
  provider_event_id?: string;
11090
+ /** Non-sensitive provider diagnostics and event context. */
11038
11091
  metadata?: Record<string, any>;
11092
+ /** ISO 8601 client-observed timestamp. Defaults to server receipt time. */
11039
11093
  occurred_at?: string;
11040
11094
  }
11095
+ /** Provider-neutral intrinsic-ad surface declared by a game developer. */
11096
+ interface GameInGameAdPlacement {
11097
+ id?: string;
11098
+ title_id?: string;
11099
+ provider?: 'anzu';
11100
+ placement_key: string;
11101
+ channel_name: string;
11102
+ surface_type: 'mesh' | 'sprite' | 'ui_image' | 'raw_image' | 'html' | 'electron_shell';
11103
+ scene_name?: string | null;
11104
+ aspect_ratio: number;
11105
+ allow_images: boolean;
11106
+ allow_videos: boolean;
11107
+ allow_audio?: boolean;
11108
+ is_dynamic: boolean;
11109
+ is_clickable: boolean;
11110
+ shrink_to_fit: boolean;
11111
+ fallback_media_url?: string | null;
11112
+ status: 'active' | 'disabled';
11113
+ metadata?: Record<string, any> | null;
11114
+ }
11115
+ /** Public delivery identity for a provider and runtime platform. */
11116
+ interface GameAdProviderApp {
11117
+ id?: string;
11118
+ title_id?: string | null;
11119
+ provider: 'anzu';
11120
+ platform: 'web' | 'electron_macos' | 'electron_windows' | 'electron_linux' | 'unity_webgl' | 'cocos_web' | 'construct_web';
11121
+ app_key: string;
11122
+ bundle_id?: string | null;
11123
+ mode: 'integration' | 'production';
11124
+ integration_type: 'managed' | 'direct';
11125
+ status: 'active' | 'disabled' | 'pending';
11126
+ metadata?: Record<string, any> | null;
11127
+ }
11128
+ /**
11129
+ * Typed client for platform-served game advertising.
11130
+ *
11131
+ * These endpoints manage publisher inventory displayed around playable games;
11132
+ * they are intentionally separate from APIs used to buy advertising campaigns.
11133
+ */
11041
11134
  declare class GameAdvertising {
11135
+ /** Return developer-visible ad-earnings settings for a title. */
11042
11136
  static settings<T>(title_id: string): AxiosPromise<Response<T>>;
11137
+ /** Update developer ad-earnings activation and optional title provider ID. */
11043
11138
  static updateSettings<T>(title_id: string, data: object): AxiosPromise<Response<T>>;
11139
+ /** Resolve ad eligibility and create an expiring provider manifest/session. */
11044
11140
  static createSession<T>(title_id: string, data: object): AxiosPromise<Response<T>>;
11141
+ /** Store one normalized, idempotent event for an advertising session. */
11045
11142
  static storeEvent<T>(title_id: string, session_id: string, data: GameAdEventPayload): AxiosPromise<Response<T>>;
11143
+ /** Return developer-visible estimated/finalized earnings and delivery totals. */
11046
11144
  static revenueSummary<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
11145
+ /** Return every intrinsic-ad surface configured for a title. */
11146
+ static inGamePlacements<T>(title_id: string): AxiosPromise<Response<T>>;
11147
+ /** Atomically replace a title's provider-neutral intrinsic-ad surfaces. */
11148
+ static replaceInGamePlacements<T>(title_id: string, placements: GameInGameAdPlacement[]): AxiosPromise<Response<T>>;
11149
+ /** Return site-admin delivery settings, aggregate metrics, and recent revenue. */
11047
11150
  static adminDashboard<T>(): AxiosPromise<Response<T>>;
11151
+ /** Partially update platform-wide providers and delivery frequency. */
11048
11152
  static adminUpdateSettings<T>(data: object): AxiosPromise<Response<T>>;
11153
+ /** Import or reconcile one provider revenue report row. */
11049
11154
  static adminStoreRevenue<T>(data: object): AxiosPromise<Response<T>>;
11155
+ /** Return public provider app keys and platform mappings for site admins. */
11156
+ static adminProviderApps<T>(): AxiosPromise<Response<T>>;
11157
+ /** Create or update a provider app mapping without accepting report secrets. */
11158
+ static adminUpsertProviderApp<T>(data: GameAdProviderApp): AxiosPromise<Response<T>>;
11050
11159
  }
11051
11160
 
11052
11161
  interface Route {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -4,49 +4,127 @@ import Requests from '../util/Requests';
4
4
  import Response from '../util/Response';
5
5
 
6
6
  export interface GameAdEventPayload {
7
+ /** Opaque token returned by the server-created advertising manifest. */
7
8
  token: string;
9
+ /** Client idempotency UUID. Reuse is valid only within the same ad session. */
8
10
  event_uuid?: string;
11
+ /** Provider that produced or attempted the event. */
9
12
  provider: string;
13
+ /** Stable Glitch placement name, such as game_banner or game_video. */
10
14
  placement: string;
11
- format: 'banner' | 'video' | 'interstitial' | 'rewarded' | 'other';
12
- event_type: 'sdk_ready' | 'request_started' | 'loaded' | 'no_fill' | 'started' | 'impression' | 'viewable' | 'clicked' | 'completed' | 'skipped' | 'closed' | 'paused_game' | 'resumed_game' | 'error';
15
+ /** Normalized creative/ad format. */
16
+ format: 'banner' | 'video' | 'interstitial' | 'rewarded' | 'in_game_image' | 'in_game_video' | 'other';
17
+ /** Normalized SDK/ad lifecycle event. */
18
+ event_type: 'sdk_ready' | 'request_started' | 'loaded' | 'channel_registered' | 'measurement' | 'no_fill' | 'fallback_shown' | 'started' | 'impression' | 'viewable' | 'clicked' | 'completed' | 'skipped' | 'closed' | 'paused_game' | 'resumed_game' | 'error';
19
+ /** Optional provider-native event or impression identifier. */
13
20
  provider_event_id?: string;
21
+ /** Non-sensitive provider diagnostics and event context. */
14
22
  metadata?: Record<string, any>;
23
+ /** ISO 8601 client-observed timestamp. Defaults to server receipt time. */
15
24
  occurred_at?: string;
16
25
  }
17
26
 
27
+ /** Provider-neutral intrinsic-ad surface declared by a game developer. */
28
+ export interface GameInGameAdPlacement {
29
+ id?: string;
30
+ title_id?: string;
31
+ provider?: 'anzu';
32
+ placement_key: string;
33
+ channel_name: string;
34
+ surface_type: 'mesh' | 'sprite' | 'ui_image' | 'raw_image' | 'html' | 'electron_shell';
35
+ scene_name?: string | null;
36
+ aspect_ratio: number;
37
+ allow_images: boolean;
38
+ allow_videos: boolean;
39
+ allow_audio?: boolean;
40
+ is_dynamic: boolean;
41
+ is_clickable: boolean;
42
+ shrink_to_fit: boolean;
43
+ fallback_media_url?: string | null;
44
+ status: 'active' | 'disabled';
45
+ metadata?: Record<string, any> | null;
46
+ }
47
+
48
+ /** Public delivery identity for a provider and runtime platform. */
49
+ export interface GameAdProviderApp {
50
+ id?: string;
51
+ title_id?: string | null;
52
+ provider: 'anzu';
53
+ platform: 'web' | 'electron_macos' | 'electron_windows' | 'electron_linux' | 'unity_webgl' | 'cocos_web' | 'construct_web';
54
+ app_key: string;
55
+ bundle_id?: string | null;
56
+ mode: 'integration' | 'production';
57
+ integration_type: 'managed' | 'direct';
58
+ status: 'active' | 'disabled' | 'pending';
59
+ metadata?: Record<string, any> | null;
60
+ }
61
+
62
+ /**
63
+ * Typed client for platform-served game advertising.
64
+ *
65
+ * These endpoints manage publisher inventory displayed around playable games;
66
+ * they are intentionally separate from APIs used to buy advertising campaigns.
67
+ */
18
68
  class GameAdvertising {
69
+ /** Return developer-visible ad-earnings settings for a title. */
19
70
  public static settings<T>(title_id: string): AxiosPromise<Response<T>> {
20
71
  return Requests.processRoute(GameAdvertisingRoute.routes.settings, undefined, { title_id });
21
72
  }
22
73
 
74
+ /** Update developer ad-earnings activation and optional title provider ID. */
23
75
  public static updateSettings<T>(title_id: string, data: object): AxiosPromise<Response<T>> {
24
76
  return Requests.processRoute(GameAdvertisingRoute.routes.updateSettings, data, { title_id });
25
77
  }
26
78
 
79
+ /** Resolve ad eligibility and create an expiring provider manifest/session. */
27
80
  public static createSession<T>(title_id: string, data: object): AxiosPromise<Response<T>> {
28
81
  return Requests.processRoute(GameAdvertisingRoute.routes.createSession, data, { title_id });
29
82
  }
30
83
 
84
+ /** Store one normalized, idempotent event for an advertising session. */
31
85
  public static storeEvent<T>(title_id: string, session_id: string, data: GameAdEventPayload): AxiosPromise<Response<T>> {
32
86
  return Requests.processRoute(GameAdvertisingRoute.routes.storeEvent, data, { title_id, session_id });
33
87
  }
34
88
 
89
+ /** Return developer-visible estimated/finalized earnings and delivery totals. */
35
90
  public static revenueSummary<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
36
91
  return Requests.processRoute(GameAdvertisingRoute.routes.revenueSummary, undefined, { title_id }, params);
37
92
  }
38
93
 
94
+ /** Return every intrinsic-ad surface configured for a title. */
95
+ public static inGamePlacements<T>(title_id: string): AxiosPromise<Response<T>> {
96
+ return Requests.processRoute(GameAdvertisingRoute.routes.inGamePlacements, undefined, { title_id });
97
+ }
98
+
99
+ /** Atomically replace a title's provider-neutral intrinsic-ad surfaces. */
100
+ public static replaceInGamePlacements<T>(title_id: string, placements: GameInGameAdPlacement[]): AxiosPromise<Response<T>> {
101
+ return Requests.processRoute(GameAdvertisingRoute.routes.replaceInGamePlacements, { placements }, { title_id });
102
+ }
103
+
104
+ /** Return site-admin delivery settings, aggregate metrics, and recent revenue. */
39
105
  public static adminDashboard<T>(): AxiosPromise<Response<T>> {
40
106
  return Requests.processRoute(GameAdvertisingRoute.routes.adminDashboard);
41
107
  }
42
108
 
109
+ /** Partially update platform-wide providers and delivery frequency. */
43
110
  public static adminUpdateSettings<T>(data: object): AxiosPromise<Response<T>> {
44
111
  return Requests.processRoute(GameAdvertisingRoute.routes.adminUpdateSettings, data);
45
112
  }
46
113
 
114
+ /** Import or reconcile one provider revenue report row. */
47
115
  public static adminStoreRevenue<T>(data: object): AxiosPromise<Response<T>> {
48
116
  return Requests.processRoute(GameAdvertisingRoute.routes.adminStoreRevenue, data);
49
117
  }
118
+
119
+ /** Return public provider app keys and platform mappings for site admins. */
120
+ public static adminProviderApps<T>(): AxiosPromise<Response<T>> {
121
+ return Requests.processRoute(GameAdvertisingRoute.routes.adminProviderApps);
122
+ }
123
+
124
+ /** Create or update a provider app mapping without accepting report secrets. */
125
+ public static adminUpsertProviderApp<T>(data: GameAdProviderApp): AxiosPromise<Response<T>> {
126
+ return Requests.processRoute(GameAdvertisingRoute.routes.adminUpsertProviderApp, data);
127
+ }
50
128
  }
51
129
 
52
130
  export default GameAdvertising;
package/src/api/Users.ts CHANGED
@@ -4,6 +4,54 @@ import Requests from "../util/Requests";
4
4
  import Response from "../util/Response";
5
5
  import { AxiosPromise } from "axios";
6
6
 
7
+ /** Human-readable earning categories returned by influencer payout APIs. */
8
+ export type InfluencerPayoutSourceType = "campaign_compensation" | "ad_revenue_share" | "subscription_residual" | "manual_adjustment";
9
+
10
+ /** Auditable metrics and creator-content attribution attached to a payout. */
11
+ export interface InfluencerPayoutBreakdown {
12
+ label?: string;
13
+ payment_method?: "flat" | "performance" | "hybrid";
14
+ provider?: string;
15
+ period_start?: string;
16
+ period_end?: string;
17
+ impressions?: number;
18
+ clicks?: number;
19
+ short_link_id?: string | null;
20
+ short_link_click_id?: string | null;
21
+ social_media_post_id?: string | null;
22
+ tracking_link_label?: string | null;
23
+ social_platform?: string | null;
24
+ social_post_url?: string | null;
25
+ }
26
+
27
+ /** One campaign or advertising earning payable to the authenticated influencer. */
28
+ export interface InfluencerPayout {
29
+ id: string;
30
+ user_id: string;
31
+ campaign_id: string;
32
+ amount: number;
33
+ currency: string;
34
+ status: "pending" | "completed" | "failed";
35
+ payout_date?: string | null;
36
+ source_type: InfluencerPayoutSourceType;
37
+ source_label: string;
38
+ source_reference_id?: string | null;
39
+ breakdown?: InfluencerPayoutBreakdown;
40
+ campaign?: Record<string, any>;
41
+ }
42
+
43
+ /** Optional filters for the authenticated influencer's payout history. */
44
+ export interface InfluencerPayoutQuery {
45
+ campaign_id?: string;
46
+ month?: number;
47
+ year?: number;
48
+ amount?: number;
49
+ status?: "pending" | "completed" | "failed";
50
+ source_type?: InfluencerPayoutSourceType;
51
+ orderBy?: "created_at" | "amount";
52
+ orderDirection?: "asc" | "desc";
53
+ }
54
+
7
55
  class Users {
8
56
 
9
57
  /**
@@ -62,16 +110,17 @@ class Users {
62
110
  }
63
111
 
64
112
  /**
65
- * Gets payouts from past campaings
113
+ * Gets the authenticated influencer's payouts from campaigns and attributed
114
+ * game advertising. Advertising revenue is returned as a separate additive
115
+ * source with provider-period metrics and tracking-link/social-post IDs.
66
116
  *
67
117
  * @see https://api.glitch.fun/api/documentation#/Users%20Route/showMe
68
118
  *
69
- * @param user_id The id of the user to update.
70
- * @param data The data to update.
119
+ * @param params Optional campaign, date, status, source, and ordering filters.
71
120
  *
72
121
  * @returns promise
73
122
  */
74
- public static getPayouts<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
123
+ public static getPayouts<T = InfluencerPayout[]>(params?: InfluencerPayoutQuery): AxiosPromise<Response<T>> {
75
124
 
76
125
  return Requests.processRoute(UserRoutes.routes.getPayouts, {}, undefined, params);
77
126
  }
@@ -2,15 +2,23 @@ import Route from './interface';
2
2
  import HTTP_METHODS from '../constants/HttpMethods';
3
3
 
4
4
  class GameAdvertisingRoute {
5
+ /**
6
+ * Route templates for publisher game-ad inventory, telemetry, earnings, and
7
+ * site administration. Placeholders are expanded by Requests.processRoute.
8
+ */
5
9
  public static routes: { [key: string]: Route } = {
6
10
  settings: { url: '/titles/{title_id}/advertising/settings', method: HTTP_METHODS.GET },
7
11
  updateSettings: { url: '/titles/{title_id}/advertising/settings', method: HTTP_METHODS.PUT },
8
12
  createSession: { url: '/titles/{title_id}/advertising/sessions', method: HTTP_METHODS.POST },
9
13
  storeEvent: { url: '/titles/{title_id}/advertising/sessions/{session_id}/events', method: HTTP_METHODS.POST },
10
14
  revenueSummary: { url: '/titles/{title_id}/advertising/revenue-summary', method: HTTP_METHODS.GET },
15
+ inGamePlacements: { url: '/titles/{title_id}/advertising/in-game/placements', method: HTTP_METHODS.GET },
16
+ replaceInGamePlacements: { url: '/titles/{title_id}/advertising/in-game/placements', method: HTTP_METHODS.PUT },
11
17
  adminDashboard: { url: '/admin/game-advertising', method: HTTP_METHODS.GET },
12
18
  adminUpdateSettings: { url: '/admin/game-advertising/settings', method: HTTP_METHODS.PUT },
13
19
  adminStoreRevenue: { url: '/admin/game-advertising/revenue', method: HTTP_METHODS.POST },
20
+ adminProviderApps: { url: '/admin/game-advertising/provider-apps', method: HTTP_METHODS.GET },
21
+ adminUpsertProviderApp: { url: '/admin/game-advertising/provider-apps', method: HTTP_METHODS.PUT },
14
22
  };
15
23
  }
16
24