174 lines
6.3 KiB
TypeScript
174 lines
6.3 KiB
TypeScript
// 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';
|
|
import type { PlayerProfile } from './player.js';
|
|
import type { GetProjectStorageResponse, UpdateProjectStorageRequest } from './project-storage.js';
|
|
import type { CreateResourceRowRequest, ListResourceRowsResponse, ResourceRow, UpdateResourceRowRequest } from './resources.js';
|
|
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: (
|
|
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),
|
|
|
|
createResourceRow: (
|
|
t: Transport,
|
|
path: { slug: string },
|
|
body: CreateResourceRowRequest,
|
|
): Promise<ResourceRow> =>
|
|
t.request<ResourceRow>('POST', `/sdk/v1/resources/${enc(path.slug)}`, body),
|
|
|
|
deleteResourceRow: (
|
|
t: Transport,
|
|
path: { slug: string; id: string },
|
|
): Promise<void> =>
|
|
t.request<void>('DELETE', `/sdk/v1/resources/${enc(path.slug)}/${enc(path.id)}`),
|
|
|
|
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: (
|
|
t: Transport,
|
|
path: { slug: string; id: string },
|
|
): Promise<ResourceRow> =>
|
|
t.request<ResourceRow>('GET', `/sdk/v1/resources/${enc(path.slug)}/${enc(path.id)}`),
|
|
|
|
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: (
|
|
t: Transport,
|
|
path: { slug: string },
|
|
query?: { _q?: string; _sort?: string; _order?: string; _start?: number; _end?: number },
|
|
): Promise<ListResourceRowsResponse> =>
|
|
t.request<ListResourceRowsResponse>('GET', `/sdk/v1/resources/${enc(path.slug)}${qs([['_q', query?._q], ['_sort', query?._sort], ['_order', query?._order], ['_start', query?._start], ['_end', query?._end]])}`),
|
|
|
|
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),
|
|
|
|
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),
|
|
|
|
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: (
|
|
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),
|
|
|
|
updateStorage: (
|
|
t: Transport,
|
|
body: UpdateStorageRequest,
|
|
): Promise<void> =>
|
|
t.request<void>('PUT', '/sdk/v1/storage', body),
|
|
|
|
};
|