export type CreateTranslationKeyRequestV2 = {key: string, namespace?: string | undefined, description?: string | undefined, codeDescription?: string | undefined, charactersLimit?: number | undefined, lock?: boolean | undefined, deprecated?: boolean | undefined, tags?: Array | undefined, attributes?: {[key: string]: unknown} | undefined}; export type CreateApiApiV1TranslationKeysArgs = {body: CreateTranslationKeyRequestV2}; export type CreateApiApiV1TranslationKeysOptions = {baseUrl?: string | undefined, ProjectAPIKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create translation key * * POST /api/v1/translation-keys */ export const createApiApiV1TranslationKeys = async (args: CreateApiApiV1TranslationKeysArgs, options?: CreateApiApiV1TranslationKeysOptions) => { const {baseUrl = "https://api.simplelocalize.io", fetch: fetchFn = fetch, ProjectAPIKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ProjectAPIKey !== undefined) headers.set("X-SimpleLocalize-Token", ProjectAPIKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/translation-keys${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };