Files
rudder-js-sdk/src/generated/api.ts
T

173 lines
6.1 KiB
TypeScript
Raw Normal View History

2026-08-12 14:02:25 +03:00
// Code generated by apigen. DO NOT EDIT.
import type { LinkViaAppleRequest, LinkViaCustomRequest, LinkViaGoogleRequest, LoginViaAppleRequest, LoginViaAppleResponse, LoginViaCustomRequest, LoginViaCustomResponse, LoginViaDeviceRequest, LoginViaDeviceResponse, LoginViaGoogleRequest, LoginViaGoogleResponse, RefreshAccessTokenRequest, RefreshAccessTokenResponse, UnlinkIdentityRequest } from './auth.js';
import type { ListCatalogCurrenciesResponse } from './catalog.js';
import type { CallModuleFunctionClientResponse, CallModuleFunctionRequest } from './modules.js';
2026-08-12 14:02:25 +03:00
import type { PlayerProfile } from './player.js';
import type { GetProjectStorageResponse, UpdateProjectStorageRequest } from './project-storage.js';
import type { CreateResourceRowRequest, ListResourceRowsResponse, ResourceRow, UpdateResourceRowRequest } from './resources.js';
2026-08-12 14:02:25 +03:00
import type { GetStorageResponse, UpdateStorageRequest } from './storage.js';
/** The minimal transport contract the generated API functions call through. */
export interface Transport {
request<TResponse>(method: string, path: string, body?: unknown): Promise<TResponse>;
}
function enc(value: string | number): string {
return encodeURIComponent(String(value));
}
function qs(
params: Array<[string, string | number | boolean | null | undefined]>,
): string {
const parts: string[] = [];
for (const [key, value] of params) {
if (value !== null && value !== undefined && value !== '') {
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
}
}
return parts.length === 0 ? '' : `?${parts.join('&')}`;
}
/** Typed request functions, one per SDK operation. */
export const api = {
callModuleFunction: (
2026-08-12 14:02:25 +03:00
t: Transport,
path: { module: string; fn: string },
body: CallModuleFunctionRequest,
): Promise<CallModuleFunctionClientResponse> =>
t.request<CallModuleFunctionClientResponse>('POST', `/sdk/v1/modules/${enc(path.module)}/${enc(path.fn)}`, body),
2026-08-12 14:02:25 +03:00
createResourceRow: (
2026-08-12 14:02:25 +03:00
t: Transport,
path: { slug: string },
body: CreateResourceRowRequest,
): Promise<ResourceRow> =>
t.request<ResourceRow>('POST', `/sdk/v1/resources/${enc(path.slug)}`, body),
2026-08-12 14:02:25 +03:00
deleteResourceRow: (
2026-08-12 14:02:25 +03:00
t: Transport,
path: { slug: string; id: string },
): Promise<void> =>
t.request<void>('DELETE', `/sdk/v1/resources/${enc(path.slug)}/${enc(path.id)}`),
2026-08-12 14:02:25 +03:00
deleteStorage: (
t: Transport,
query?: { type?: string },
): Promise<void> =>
t.request<void>('DELETE', `/sdk/v1/storage${qs([['type', query?.type]])}`),
getPlayerInformation: (
t: Transport,
): Promise<PlayerProfile> =>
t.request<PlayerProfile>('GET', '/sdk/v1/player/information'),
getProjectStorage: (
t: Transport,
query?: { types?: string; limit?: number; cursor?: string },
): Promise<GetProjectStorageResponse> =>
t.request<GetProjectStorageResponse>('GET', `/sdk/v1/project-storage${qs([['types', query?.types], ['limit', query?.limit], ['cursor', query?.cursor]])}`),
getResourceRow: (
2026-08-12 14:02:25 +03:00
t: Transport,
path: { slug: string; id: string },
): Promise<ResourceRow> =>
t.request<ResourceRow>('GET', `/sdk/v1/resources/${enc(path.slug)}/${enc(path.id)}`),
2026-08-12 14:02:25 +03:00
getRevisions: (
t: Transport,
): Promise<{ [key: string]: number }> =>
t.request<{ [key: string]: number }>('GET', '/sdk/v1/sync'),
getStorage: (
t: Transport,
query?: { types?: string; limit?: number; cursor?: string },
): Promise<GetStorageResponse> =>
t.request<GetStorageResponse>('GET', `/sdk/v1/storage${qs([['types', query?.types], ['limit', query?.limit], ['cursor', query?.cursor]])}`),
linkViaApple: (
t: Transport,
body: LinkViaAppleRequest,
): Promise<void> =>
t.request<void>('POST', '/sdk/v1/authorization/apple/link', body),
linkViaCustom: (
t: Transport,
body: LinkViaCustomRequest,
): Promise<void> =>
t.request<void>('POST', '/sdk/v1/authorization/custom/link', body),
linkViaGoogle: (
t: Transport,
body: LinkViaGoogleRequest,
): Promise<void> =>
t.request<void>('POST', '/sdk/v1/authorization/google/link', body),
listCatalogCurrencies: (
t: Transport,
): Promise<ListCatalogCurrenciesResponse> =>
t.request<ListCatalogCurrenciesResponse>('GET', '/sdk/v1/catalog'),
listResourceRows: (
2026-08-12 14:02:25 +03:00
t: Transport,
path: { slug: string },
): Promise<ListResourceRowsResponse> =>
t.request<ListResourceRowsResponse>('GET', `/sdk/v1/resources/${enc(path.slug)}`),
2026-08-12 14:02:25 +03:00
loginViaApple: (
t: Transport,
body: LoginViaAppleRequest,
): Promise<LoginViaAppleResponse> =>
t.request<LoginViaAppleResponse>('POST', '/sdk/v1/authorization/apple', body),
loginViaCustom: (
t: Transport,
body: LoginViaCustomRequest,
): Promise<LoginViaCustomResponse> =>
t.request<LoginViaCustomResponse>('POST', '/sdk/v1/authorization/custom', body),
2026-08-12 14:02:25 +03:00
loginViaDevice: (
t: Transport,
body: LoginViaDeviceRequest,
): Promise<LoginViaDeviceResponse> =>
t.request<LoginViaDeviceResponse>('POST', '/sdk/v1/authorization/device', body),
loginViaGoogle: (
t: Transport,
body: LoginViaGoogleRequest,
): Promise<LoginViaGoogleResponse> =>
t.request<LoginViaGoogleResponse>('POST', '/sdk/v1/authorization/google', body),
2026-08-12 14:02:25 +03:00
refreshAccessToken: (
t: Transport,
body: RefreshAccessTokenRequest,
): Promise<RefreshAccessTokenResponse> =>
t.request<RefreshAccessTokenResponse>('POST', '/sdk/v1/authorization/refresh', body),
unlinkIdentity: (
t: Transport,
body: UnlinkIdentityRequest,
): Promise<void> =>
t.request<void>('POST', '/sdk/v1/authorization/unlink', body),
updateProjectStorage: (
t: Transport,
body: UpdateProjectStorageRequest,
): Promise<void> =>
t.request<void>('PUT', '/sdk/v1/project-storage', body),
updateResourceRow: (
2026-08-12 14:02:25 +03:00
t: Transport,
path: { slug: string; id: string },
body: UpdateResourceRowRequest,
): Promise<ResourceRow> =>
t.request<ResourceRow>('PATCH', `/sdk/v1/resources/${enc(path.slug)}/${enc(path.id)}`, body),
2026-08-12 14:02:25 +03:00
updateStorage: (
t: Transport,
body: UpdateStorageRequest,
): Promise<void> =>
t.request<void>('PUT', '/sdk/v1/storage', body),
};