@storyblok/management-api-client 0.1.1 → 0.1.3
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/client/client.d.mts +1 -1
- package/dist/client/client.d.ts +1 -1
- package/dist/client/client.js +2 -2
- package/dist/client/client.js.map +1 -1
- package/dist/client/client.mjs +2 -2
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/types.d.mts +7 -0
- package/dist/client/types.d.ts +7 -0
- package/dist/generated/assets/types.gen.d.mts +14 -2
- package/dist/generated/assets/types.gen.d.ts +14 -2
- package/dist/generated/assets/types.gen.js.map +1 -1
- package/dist/generated/assets/types.gen.mjs.map +1 -1
- package/dist/generated/component_folders/types.gen.d.mts +8 -28
- package/dist/generated/component_folders/types.gen.d.ts +8 -28
- package/dist/generated/component_folders/types.gen.js.map +1 -1
- package/dist/generated/component_folders/types.gen.mjs.map +1 -1
- package/dist/generated/components/types.gen.d.mts +19 -7
- package/dist/generated/components/types.gen.d.ts +19 -7
- package/dist/generated/components/types.gen.js.map +1 -1
- package/dist/generated/components/types.gen.mjs.map +1 -1
- package/dist/generated/datasource_entries/types.gen.d.mts +26 -42
- package/dist/generated/datasource_entries/types.gen.d.ts +26 -42
- package/dist/generated/datasource_entries/types.gen.js.map +1 -1
- package/dist/generated/datasource_entries/types.gen.mjs.map +1 -1
- package/dist/generated/datasources/types.gen.d.mts +13 -59
- package/dist/generated/datasources/types.gen.d.ts +13 -59
- package/dist/generated/datasources/types.gen.js.map +1 -1
- package/dist/generated/datasources/types.gen.mjs.map +1 -1
- package/dist/generated/internal_tags/types.gen.d.mts +14 -2
- package/dist/generated/internal_tags/types.gen.d.ts +14 -2
- package/dist/generated/internal_tags/types.gen.js.map +1 -1
- package/dist/generated/internal_tags/types.gen.mjs.map +1 -1
- package/dist/generated/presets/types.gen.d.mts +10 -80
- package/dist/generated/presets/types.gen.d.ts +10 -80
- package/dist/generated/presets/types.gen.js.map +1 -1
- package/dist/generated/presets/types.gen.mjs.map +1 -1
- package/dist/generated/spaces/types.gen.d.mts +71 -0
- package/dist/generated/spaces/types.gen.d.ts +71 -0
- package/dist/generated/spaces/types.gen.js.map +1 -1
- package/dist/generated/spaces/types.gen.mjs.map +1 -1
- package/dist/generated/stories/types.gen.d.mts +30 -17
- package/dist/generated/stories/types.gen.d.ts +30 -17
- package/dist/generated/stories/types.gen.js.map +1 -1
- package/dist/generated/stories/types.gen.mjs.map +1 -1
- package/dist/generated/users/types.gen.d.mts +10 -113
- package/dist/generated/users/types.gen.d.ts +10 -113
- package/dist/generated/users/types.gen.js.map +1 -1
- package/dist/generated/users/types.gen.mjs.map +1 -1
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/client/client.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client, Config } from "./types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/client/client.d.ts
|
|
4
|
-
declare const createClient: (config
|
|
4
|
+
declare const createClient: (config: Config) => Client;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { createClient };
|
|
7
7
|
//# sourceMappingURL=client.d.mts.map
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client, Config } from "./types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/client/client.d.ts
|
|
4
|
-
declare const createClient: (config
|
|
4
|
+
declare const createClient: (config: Config) => Client;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { createClient };
|
|
7
7
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client/client.js
CHANGED
|
@@ -3,7 +3,7 @@ const require_utils = require('./utils.js');
|
|
|
3
3
|
const __storyblok_region_helper = require_rolldown_runtime.__toESM(require("@storyblok/region-helper"));
|
|
4
4
|
|
|
5
5
|
//#region src/client/client.ts
|
|
6
|
-
const createClient = (config
|
|
6
|
+
const createClient = (config) => {
|
|
7
7
|
let _config = require_utils.mergeConfigs(require_utils.createConfig(), config);
|
|
8
8
|
const getConfig = () => ({ ..._config });
|
|
9
9
|
const setConfig = (config$1) => {
|
|
@@ -21,7 +21,7 @@ const createClient = (config = {}) => {
|
|
|
21
21
|
if (!_config.baseUrl && options.path?.space_id) {
|
|
22
22
|
const region = (0, __storyblok_region_helper.getRegion)(options.path.space_id);
|
|
23
23
|
if (region) opts.baseUrl = (0, __storyblok_region_helper.getManagementBaseUrl)(region, "https");
|
|
24
|
-
}
|
|
24
|
+
} else if (opts.region) opts.baseUrl = (0, __storyblok_region_helper.getManagementBaseUrl)(opts.region, "https");
|
|
25
25
|
if (opts.security) await require_utils.setAuthParams({
|
|
26
26
|
...opts,
|
|
27
27
|
security: opts.security
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["config: Config","mergeConfigs","createConfig","config","createInterceptors","request: Client['request']","mergeHeaders","setAuthParams","buildUrl","requestInit: ReqInit","request","getParseAs","data: any","jsonError: unknown","fetchFn: any","url: string","retryConfig: { maxRetries: number; retryDelay: number }","attempt: number"],"sources":["../../src/client/client.ts"],"sourcesContent":["import { getManagementBaseUrl, getRegion } from '@storyblok/region-helper';\nimport type { Client, Config, RequestOptions } from './types';\nimport {\n buildUrl,\n createConfig,\n createInterceptors,\n getParseAs,\n mergeConfigs,\n mergeHeaders,\n setAuthParams,\n} from './utils';\n\ntype ReqInit = Omit<RequestInit, 'body' | 'headers'> & {\n body?: any;\n headers: ReturnType<typeof mergeHeaders>;\n};\n\nexport const createClient = (config: Config = {}): Client => {\n let _config = mergeConfigs(createConfig(), config);\n\n const getConfig = (): Config => ({ ..._config });\n\n const setConfig = (config: Config): Config => {\n _config = mergeConfigs(_config, config);\n return getConfig();\n };\n\n const interceptors = createInterceptors<\n Request,\n Response,\n unknown,\n RequestOptions\n >();\n\n const request: Client['request'] = async (options) => {\n const opts = {\n ..._config,\n ...options,\n fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,\n headers: mergeHeaders(_config.headers, options.headers),\n };\n\n // If the baseUrl is not set and we have a space_id, we can attempt toinfer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n }\n\n if (opts.security) {\n await setAuthParams({\n ...opts,\n security: opts.security,\n });\n }\n\n if (opts.requestValidator) {\n await opts.requestValidator(opts);\n }\n\n if (opts.body && opts.bodySerializer) {\n opts.body = opts.bodySerializer(opts.body);\n }\n\n // remove Content-Type header if body is empty to avoid sending invalid requests\n if (opts.body === undefined || opts.body === '') {\n opts.headers.delete('Content-Type');\n }\n\n const url = buildUrl(opts);\n const requestInit: ReqInit = {\n redirect: 'follow',\n ...opts,\n };\n\n let request = new Request(url, requestInit);\n\n for (const fn of interceptors.request._fns) {\n if (fn) {\n request = await fn(request, opts);\n }\n }\n\n // fetch must be assigned here, otherwise it would throw the error:\n // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation\n const _fetch = opts.fetch!;\n \n // Execute with retry logic by recreating the request for each attempt\n let response = await executeWithRetry(_fetch, url, requestInit, {\n maxRetries: 3,\n retryDelay: 1000\n });\n\n for (const fn of interceptors.response._fns) {\n if (fn) {\n response = await fn(response, request, opts);\n }\n }\n\n const result = {\n request,\n response,\n };\n\n if (response.ok) {\n if (\n response.status === 204 ||\n response.headers.get('Content-Length') === '0'\n ) {\n return opts.responseStyle === 'data'\n ? {}\n : {\n data: {},\n ...result,\n };\n }\n\n const parseAs =\n (opts.parseAs === 'auto'\n ? getParseAs(response.headers.get('Content-Type'))\n : opts.parseAs) ?? 'json';\n\n let data: any;\n switch (parseAs) {\n case 'arrayBuffer':\n case 'blob':\n case 'formData':\n case 'json':\n case 'text':\n data = await response[parseAs]();\n break;\n case 'stream':\n return opts.responseStyle === 'data'\n ? response.body\n : {\n data: response.body,\n ...result,\n };\n }\n\n if (parseAs === 'json') {\n if (opts.responseValidator) {\n await opts.responseValidator(data);\n }\n\n if (opts.responseTransformer) {\n data = await opts.responseTransformer(data);\n }\n }\n\n return opts.responseStyle === 'data'\n ? data\n : {\n data,\n ...result,\n };\n }\n\n const textError = await response.text();\n let jsonError: unknown;\n\n try {\n jsonError = JSON.parse(textError);\n } catch {\n // noop\n }\n\n const error = jsonError ?? textError;\n let finalError = error;\n\n for (const fn of interceptors.error._fns) {\n if (fn) {\n finalError = (await fn(error, response, request, opts)) as string;\n }\n }\n\n finalError = finalError || ({} as string);\n\n if (opts.throwOnError) {\n throw finalError;\n }\n\n // TODO: we probably want to return error and improve types\n return opts.responseStyle === 'data'\n ? undefined\n : {\n error: finalError,\n ...result,\n };\n };\n\n // Helper function to execute fetch with retry logic\n async function executeWithRetry(\n fetchFn: any,\n url: string,\n requestInit: ReqInit,\n retryConfig: { maxRetries: number; retryDelay: number },\n attempt: number = 0\n ): Promise<Response> {\n try {\n const request = new Request(url, requestInit);\n const response = await fetchFn(request);\n \n if (response.status === 429 && attempt < retryConfig.maxRetries) {\n const retryAfter = response.headers.get('retry-after');\n const delay = retryAfter ? parseInt(retryAfter) * 1000 : retryConfig.retryDelay;\n \n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n return response;\n } catch (error) {\n // If it's a network error and we haven't exceeded retries, try again\n if (attempt < retryConfig.maxRetries) {\n const delay = retryConfig.retryDelay;\n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n throw error;\n }\n }\n\n return {\n buildUrl,\n connect: (options) => request({ ...options, method: 'CONNECT' }),\n delete: (options) => request({ ...options, method: 'DELETE' }),\n get: (options) => request({ ...options, method: 'GET' }),\n getConfig,\n head: (options) => request({ ...options, method: 'HEAD' }),\n interceptors,\n options: (options) => request({ ...options, method: 'OPTIONS' }),\n patch: (options) => request({ ...options, method: 'PATCH' }),\n post: (options) => request({ ...options, method: 'POST' }),\n put: (options) => request({ ...options, method: 'PUT' }),\n request,\n setConfig,\n trace: (options) => request({ ...options, method: 'TRACE' }),\n };\n};\n"],"mappings":";;;;;AAiBA,MAAa,eAAe,CAACA,SAAiB,CAAE,MAAa;CAC3D,IAAI,UAAUC,2BAAaC,4BAAc,EAAE,OAAO;CAElD,MAAM,YAAY,OAAe,EAAE,GAAG,QAAS;CAE/C,MAAM,YAAY,CAACF,aAA2B;EAC5C,UAAUC,2BAAa,SAASE,SAAO;AACvC,SAAO,WAAW;CACnB;CAED,MAAM,eAAeC,kCAKlB;CAEH,MAAMC,UAA6B,OAAO,YAAY;EACpD,MAAM,OAAO;GACX,GAAG;GACH,GAAG;GACH,OAAO,QAAQ,SAAS,QAAQ,SAAS,WAAW;GACpD,SAASC,2BAAa,QAAQ,SAAS,QAAQ,QAAQ;EACxD;AAGD,MAAI,CAAC,QAAQ,WAAW,QAAQ,MAAM,UAAU;GAC9C,MAAM,kDAAmB,QAAQ,KAAK,SAAmB;AACzD,OAAI,QACF,KAAK,8DAA+B,QAAQ,QAAQ;EAEvD;AAED,MAAI,KAAK,UACP,MAAMC,4BAAc;GAClB,GAAG;GACH,UAAU,KAAK;EAChB,EAAC;AAGJ,MAAI,KAAK,kBACP,MAAM,KAAK,iBAAiB,KAAK;AAGnC,MAAI,KAAK,QAAQ,KAAK,gBACpB,KAAK,OAAO,KAAK,eAAe,KAAK,KAAK;AAI5C,MAAI,KAAK,SAAS,UAAa,KAAK,SAAS,IAC3C,KAAK,QAAQ,OAAO,eAAe;EAGrC,MAAM,MAAMC,uBAAS,KAAK;EAC1B,MAAMC,cAAuB;GAC3B,UAAU;GACV,GAAG;EACJ;EAED,IAAIC,YAAU,IAAI,QAAQ,KAAK;AAE/B,OAAK,MAAM,MAAM,aAAa,QAAQ,KACpC,KAAI,IACFA,YAAU,MAAM,GAAGA,WAAS,KAAK;EAMrC,MAAM,SAAS,KAAK;EAGpB,IA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D;EACA;EACA,OAAO,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAS,EAAC;CAC7D;AACF"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["config: Config","mergeConfigs","createConfig","config","createInterceptors","request: Client['request']","mergeHeaders","setAuthParams","buildUrl","requestInit: ReqInit","request","getParseAs","data: any","jsonError: unknown","fetchFn: any","url: string","retryConfig: { maxRetries: number; retryDelay: number }","attempt: number"],"sources":["../../src/client/client.ts"],"sourcesContent":["import { getManagementBaseUrl, getRegion } from '@storyblok/region-helper';\nimport type { Client, Config, RequestOptions } from './types';\nimport {\n buildUrl,\n createConfig,\n createInterceptors,\n getParseAs,\n mergeConfigs,\n mergeHeaders,\n setAuthParams,\n} from './utils';\n\ntype ReqInit = Omit<RequestInit, 'body' | 'headers'> & {\n body?: any;\n headers: ReturnType<typeof mergeHeaders>;\n};\n\nexport const createClient = (config: Config): Client => {\n let _config = mergeConfigs(createConfig(), config);\n\n const getConfig = (): Config => ({ ..._config });\n\n const setConfig = (config: Config): Config => {\n _config = mergeConfigs(_config, config);\n return getConfig();\n };\n\n const interceptors = createInterceptors<\n Request,\n Response,\n unknown,\n RequestOptions\n >();\n\n const request: Client['request'] = async (options) => {\n const opts = {\n ..._config,\n ...options,\n fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,\n headers: mergeHeaders(_config.headers, options.headers),\n };\n\n\n // If the baseUrl is not set and we have a space_id, we can attempt toinfer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n } else if (opts.region) {\n opts.baseUrl = getManagementBaseUrl(opts.region, 'https');\n }\n\n if (opts.security) {\n await setAuthParams({\n ...opts,\n security: opts.security,\n });\n }\n\n if (opts.requestValidator) {\n await opts.requestValidator(opts);\n }\n\n if (opts.body && opts.bodySerializer) {\n opts.body = opts.bodySerializer(opts.body);\n }\n\n // remove Content-Type header if body is empty to avoid sending invalid requests\n if (opts.body === undefined || opts.body === '') {\n opts.headers.delete('Content-Type');\n }\n\n const url = buildUrl(opts);\n const requestInit: ReqInit = {\n redirect: 'follow',\n ...opts,\n };\n\n let request = new Request(url, requestInit);\n\n for (const fn of interceptors.request._fns) {\n if (fn) {\n request = await fn(request, opts);\n }\n }\n\n // fetch must be assigned here, otherwise it would throw the error:\n // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation\n const _fetch = opts.fetch!;\n \n // Execute with retry logic by recreating the request for each attempt\n let response = await executeWithRetry(_fetch, url, requestInit, {\n maxRetries: 3,\n retryDelay: 1000\n });\n\n for (const fn of interceptors.response._fns) {\n if (fn) {\n response = await fn(response, request, opts);\n }\n }\n\n const result = {\n request,\n response,\n };\n\n if (response.ok) {\n if (\n response.status === 204 ||\n response.headers.get('Content-Length') === '0'\n ) {\n return opts.responseStyle === 'data'\n ? {}\n : {\n data: {},\n ...result,\n };\n }\n\n const parseAs =\n (opts.parseAs === 'auto'\n ? getParseAs(response.headers.get('Content-Type'))\n : opts.parseAs) ?? 'json';\n\n let data: any;\n switch (parseAs) {\n case 'arrayBuffer':\n case 'blob':\n case 'formData':\n case 'json':\n case 'text':\n data = await response[parseAs]();\n break;\n case 'stream':\n return opts.responseStyle === 'data'\n ? response.body\n : {\n data: response.body,\n ...result,\n };\n }\n\n if (parseAs === 'json') {\n if (opts.responseValidator) {\n await opts.responseValidator(data);\n }\n\n if (opts.responseTransformer) {\n data = await opts.responseTransformer(data);\n }\n }\n\n return opts.responseStyle === 'data'\n ? data\n : {\n data,\n ...result,\n };\n }\n\n const textError = await response.text();\n let jsonError: unknown;\n\n try {\n jsonError = JSON.parse(textError);\n } catch {\n // noop\n }\n\n const error = jsonError ?? textError;\n let finalError = error;\n\n for (const fn of interceptors.error._fns) {\n if (fn) {\n finalError = (await fn(error, response, request, opts)) as string;\n }\n }\n\n finalError = finalError || ({} as string);\n\n if (opts.throwOnError) {\n throw finalError;\n }\n\n // TODO: we probably want to return error and improve types\n return opts.responseStyle === 'data'\n ? undefined\n : {\n error: finalError,\n ...result,\n };\n };\n\n // Helper function to execute fetch with retry logic\n async function executeWithRetry(\n fetchFn: any,\n url: string,\n requestInit: ReqInit,\n retryConfig: { maxRetries: number; retryDelay: number },\n attempt: number = 0\n ): Promise<Response> {\n try {\n const request = new Request(url, requestInit);\n const response = await fetchFn(request);\n \n if (response.status === 429 && attempt < retryConfig.maxRetries) {\n const retryAfter = response.headers.get('retry-after');\n const delay = retryAfter ? parseInt(retryAfter) * 1000 : retryConfig.retryDelay;\n \n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n return response;\n } catch (error) {\n // If it's a network error and we haven't exceeded retries, try again\n if (attempt < retryConfig.maxRetries) {\n const delay = retryConfig.retryDelay;\n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n throw error;\n }\n }\n\n return {\n buildUrl,\n connect: (options) => request({ ...options, method: 'CONNECT' }),\n delete: (options) => request({ ...options, method: 'DELETE' }),\n get: (options) => request({ ...options, method: 'GET' }),\n getConfig,\n head: (options) => request({ ...options, method: 'HEAD' }),\n interceptors,\n options: (options) => request({ ...options, method: 'OPTIONS' }),\n patch: (options) => request({ ...options, method: 'PATCH' }),\n post: (options) => request({ ...options, method: 'POST' }),\n put: (options) => request({ ...options, method: 'PUT' }),\n request,\n setConfig,\n trace: (options) => request({ ...options, method: 'TRACE' }),\n };\n};\n"],"mappings":";;;;;AAiBA,MAAa,eAAe,CAACA,WAA2B;CACtD,IAAI,UAAUC,2BAAaC,4BAAc,EAAE,OAAO;CAElD,MAAM,YAAY,OAAe,EAAE,GAAG,QAAS;CAE/C,MAAM,YAAY,CAACF,aAA2B;EAC5C,UAAUC,2BAAa,SAASE,SAAO;AACvC,SAAO,WAAW;CACnB;CAED,MAAM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M,IAAI,QAAQ,aAAW,WAAW,SAAS,MAAM;AAGvD,WAAO,iBAAiB,SAAS,KAAK,aAAa,aAAa,UAAU,EAAE;GAC7E;AAED,UAAO;EACR,SAAQ,OAAO;AAEd,OAAI,UAAU,YAAY,YAAY;IACpC,MAAM,QAAQ,YAAY;IAC1B,MAAM,IAAI,QAAQ,aAAW,WAAW,SAAS,MAAM;AAGvD,WAAO,iBAAiB,SAAS,KAAK,aAAa,aAAa,UAAU,EAAE;GAC7E;AAED,SAAM;EACP;CACF;AAED,QAAO;EACL;EACA,SAAS,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAW,EAAC;EAChE,QAAQ,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAU,EAAC;EAC9D,KAAK,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAO,EAAC;EACxD;EACA,MAAM,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAQ,EAAC;EAC1D;EACA,SAAS,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAW,EAAC;EAChE,OAAO,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAS,EAAC;EAC5D,MAAM,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAQ,EAAC;EAC1D,KAAK,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAO,EAAC;EACxD;EACA;EACA,OAAO,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAS,EAAC;CAC7D;AACF"}
|
package/dist/client/client.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, m
|
|
|
2
2
|
import { getManagementBaseUrl, getRegion } from "@storyblok/region-helper";
|
|
3
3
|
|
|
4
4
|
//#region src/client/client.ts
|
|
5
|
-
const createClient = (config
|
|
5
|
+
const createClient = (config) => {
|
|
6
6
|
let _config = mergeConfigs(createConfig(), config);
|
|
7
7
|
const getConfig = () => ({ ..._config });
|
|
8
8
|
const setConfig = (config$1) => {
|
|
@@ -20,7 +20,7 @@ const createClient = (config = {}) => {
|
|
|
20
20
|
if (!_config.baseUrl && options.path?.space_id) {
|
|
21
21
|
const region = getRegion(options.path.space_id);
|
|
22
22
|
if (region) opts.baseUrl = getManagementBaseUrl(region, "https");
|
|
23
|
-
}
|
|
23
|
+
} else if (opts.region) opts.baseUrl = getManagementBaseUrl(opts.region, "https");
|
|
24
24
|
if (opts.security) await setAuthParams({
|
|
25
25
|
...opts,
|
|
26
26
|
security: opts.security
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":["config: Config","config","request: Client['request']","requestInit: ReqInit","request","data: any","jsonError: unknown","fetchFn: any","url: string","retryConfig: { maxRetries: number; retryDelay: number }","attempt: number"],"sources":["../../src/client/client.ts"],"sourcesContent":["import { getManagementBaseUrl, getRegion } from '@storyblok/region-helper';\nimport type { Client, Config, RequestOptions } from './types';\nimport {\n buildUrl,\n createConfig,\n createInterceptors,\n getParseAs,\n mergeConfigs,\n mergeHeaders,\n setAuthParams,\n} from './utils';\n\ntype ReqInit = Omit<RequestInit, 'body' | 'headers'> & {\n body?: any;\n headers: ReturnType<typeof mergeHeaders>;\n};\n\nexport const createClient = (config: Config = {}): Client => {\n let _config = mergeConfigs(createConfig(), config);\n\n const getConfig = (): Config => ({ ..._config });\n\n const setConfig = (config: Config): Config => {\n _config = mergeConfigs(_config, config);\n return getConfig();\n };\n\n const interceptors = createInterceptors<\n Request,\n Response,\n unknown,\n RequestOptions\n >();\n\n const request: Client['request'] = async (options) => {\n const opts = {\n ..._config,\n ...options,\n fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,\n headers: mergeHeaders(_config.headers, options.headers),\n };\n\n // If the baseUrl is not set and we have a space_id, we can attempt toinfer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n }\n\n if (opts.security) {\n await setAuthParams({\n ...opts,\n security: opts.security,\n });\n }\n\n if (opts.requestValidator) {\n await opts.requestValidator(opts);\n }\n\n if (opts.body && opts.bodySerializer) {\n opts.body = opts.bodySerializer(opts.body);\n }\n\n // remove Content-Type header if body is empty to avoid sending invalid requests\n if (opts.body === undefined || opts.body === '') {\n opts.headers.delete('Content-Type');\n }\n\n const url = buildUrl(opts);\n const requestInit: ReqInit = {\n redirect: 'follow',\n ...opts,\n };\n\n let request = new Request(url, requestInit);\n\n for (const fn of interceptors.request._fns) {\n if (fn) {\n request = await fn(request, opts);\n }\n }\n\n // fetch must be assigned here, otherwise it would throw the error:\n // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation\n const _fetch = opts.fetch!;\n \n // Execute with retry logic by recreating the request for each attempt\n let response = await executeWithRetry(_fetch, url, requestInit, {\n maxRetries: 3,\n retryDelay: 1000\n });\n\n for (const fn of interceptors.response._fns) {\n if (fn) {\n response = await fn(response, request, opts);\n }\n }\n\n const result = {\n request,\n response,\n };\n\n if (response.ok) {\n if (\n response.status === 204 ||\n response.headers.get('Content-Length') === '0'\n ) {\n return opts.responseStyle === 'data'\n ? {}\n : {\n data: {},\n ...result,\n };\n }\n\n const parseAs =\n (opts.parseAs === 'auto'\n ? getParseAs(response.headers.get('Content-Type'))\n : opts.parseAs) ?? 'json';\n\n let data: any;\n switch (parseAs) {\n case 'arrayBuffer':\n case 'blob':\n case 'formData':\n case 'json':\n case 'text':\n data = await response[parseAs]();\n break;\n case 'stream':\n return opts.responseStyle === 'data'\n ? response.body\n : {\n data: response.body,\n ...result,\n };\n }\n\n if (parseAs === 'json') {\n if (opts.responseValidator) {\n await opts.responseValidator(data);\n }\n\n if (opts.responseTransformer) {\n data = await opts.responseTransformer(data);\n }\n }\n\n return opts.responseStyle === 'data'\n ? data\n : {\n data,\n ...result,\n };\n }\n\n const textError = await response.text();\n let jsonError: unknown;\n\n try {\n jsonError = JSON.parse(textError);\n } catch {\n // noop\n }\n\n const error = jsonError ?? textError;\n let finalError = error;\n\n for (const fn of interceptors.error._fns) {\n if (fn) {\n finalError = (await fn(error, response, request, opts)) as string;\n }\n }\n\n finalError = finalError || ({} as string);\n\n if (opts.throwOnError) {\n throw finalError;\n }\n\n // TODO: we probably want to return error and improve types\n return opts.responseStyle === 'data'\n ? undefined\n : {\n error: finalError,\n ...result,\n };\n };\n\n // Helper function to execute fetch with retry logic\n async function executeWithRetry(\n fetchFn: any,\n url: string,\n requestInit: ReqInit,\n retryConfig: { maxRetries: number; retryDelay: number },\n attempt: number = 0\n ): Promise<Response> {\n try {\n const request = new Request(url, requestInit);\n const response = await fetchFn(request);\n \n if (response.status === 429 && attempt < retryConfig.maxRetries) {\n const retryAfter = response.headers.get('retry-after');\n const delay = retryAfter ? parseInt(retryAfter) * 1000 : retryConfig.retryDelay;\n \n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n return response;\n } catch (error) {\n // If it's a network error and we haven't exceeded retries, try again\n if (attempt < retryConfig.maxRetries) {\n const delay = retryConfig.retryDelay;\n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n throw error;\n }\n }\n\n return {\n buildUrl,\n connect: (options) => request({ ...options, method: 'CONNECT' }),\n delete: (options) => request({ ...options, method: 'DELETE' }),\n get: (options) => request({ ...options, method: 'GET' }),\n getConfig,\n head: (options) => request({ ...options, method: 'HEAD' }),\n interceptors,\n options: (options) => request({ ...options, method: 'OPTIONS' }),\n patch: (options) => request({ ...options, method: 'PATCH' }),\n post: (options) => request({ ...options, method: 'POST' }),\n put: (options) => request({ ...options, method: 'PUT' }),\n request,\n setConfig,\n trace: (options) => request({ ...options, method: 'TRACE' }),\n };\n};\n"],"mappings":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estInit: ReqInit","request","data: any","jsonError: unknown","fetchFn: any","url: string","retryConfig: { maxRetries: number; retryDelay: number }","attempt: number"],"sources":["../../src/client/client.ts"],"sourcesContent":["import { getManagementBaseUrl, getRegion } from '@storyblok/region-helper';\nimport type { Client, Config, RequestOptions } from './types';\nimport {\n buildUrl,\n createConfig,\n createInterceptors,\n getParseAs,\n mergeConfigs,\n mergeHeaders,\n setAuthParams,\n} from './utils';\n\ntype ReqInit = Omit<RequestInit, 'body' | 'headers'> & {\n body?: any;\n headers: ReturnType<typeof mergeHeaders>;\n};\n\nexport const createClient = (config: Config): Client => {\n let _config = mergeConfigs(createConfig(), config);\n\n const getConfig = (): Config => ({ ..._config });\n\n const setConfig = (config: Config): Config => {\n _config = mergeConfigs(_config, config);\n return getConfig();\n };\n\n const interceptors = createInterceptors<\n Request,\n Response,\n unknown,\n RequestOptions\n >();\n\n const request: Client['request'] = async (options) => {\n const opts = {\n ..._config,\n ...options,\n fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,\n headers: mergeHeaders(_config.headers, options.headers),\n };\n\n\n // If the baseUrl is not set and we have a space_id, we can attempt toinfer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n } else if (opts.region) {\n opts.baseUrl = getManagementBaseUrl(opts.region, 'https');\n }\n\n if (opts.security) {\n await setAuthParams({\n ...opts,\n security: opts.security,\n });\n }\n\n if (opts.requestValidator) {\n await opts.requestValidator(opts);\n }\n\n if (opts.body && opts.bodySerializer) {\n opts.body = opts.bodySerializer(opts.body);\n }\n\n // remove Content-Type header if body is empty to avoid sending invalid requests\n if (opts.body === undefined || opts.body === '') {\n opts.headers.delete('Content-Type');\n }\n\n const url = buildUrl(opts);\n const requestInit: ReqInit = {\n redirect: 'follow',\n ...opts,\n };\n\n let request = new Request(url, requestInit);\n\n for (const fn of interceptors.request._fns) {\n if (fn) {\n request = await fn(request, opts);\n }\n }\n\n // fetch must be assigned here, otherwise it would throw the error:\n // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation\n const _fetch = opts.fetch!;\n \n // Execute with retry logic by recreating the request for each attempt\n let response = await executeWithRetry(_fetch, url, requestInit, {\n maxRetries: 3,\n retryDelay: 1000\n });\n\n for (const fn of interceptors.response._fns) {\n if (fn) {\n response = await fn(response, request, opts);\n }\n }\n\n const result = {\n request,\n response,\n };\n\n if (response.ok) {\n if (\n response.status === 204 ||\n response.headers.get('Content-Length') === '0'\n ) {\n return opts.responseStyle === 'data'\n ? {}\n : {\n data: {},\n ...result,\n };\n }\n\n const parseAs =\n (opts.parseAs === 'auto'\n ? getParseAs(response.headers.get('Content-Type'))\n : opts.parseAs) ?? 'json';\n\n let data: any;\n switch (parseAs) {\n case 'arrayBuffer':\n case 'blob':\n case 'formData':\n case 'json':\n case 'text':\n data = await response[parseAs]();\n break;\n case 'stream':\n return opts.responseStyle === 'data'\n ? response.body\n : {\n data: response.body,\n ...result,\n };\n }\n\n if (parseAs === 'json') {\n if (opts.responseValidator) {\n await opts.responseValidator(data);\n }\n\n if (opts.responseTransformer) {\n data = await opts.responseTransformer(data);\n }\n }\n\n return opts.responseStyle === 'data'\n ? data\n : {\n data,\n ...result,\n };\n }\n\n const textError = await response.text();\n let jsonError: unknown;\n\n try {\n jsonError = JSON.parse(textError);\n } catch {\n // noop\n }\n\n const error = jsonError ?? textError;\n let finalError = error;\n\n for (const fn of interceptors.error._fns) {\n if (fn) {\n finalError = (await fn(error, response, request, opts)) as string;\n }\n }\n\n finalError = finalError || ({} as string);\n\n if (opts.throwOnError) {\n throw finalError;\n }\n\n // TODO: we probably want to return error and improve types\n return opts.responseStyle === 'data'\n ? undefined\n : {\n error: finalError,\n ...result,\n };\n };\n\n // Helper function to execute fetch with retry logic\n async function executeWithRetry(\n fetchFn: any,\n url: string,\n requestInit: ReqInit,\n retryConfig: { maxRetries: number; retryDelay: number },\n attempt: number = 0\n ): Promise<Response> {\n try {\n const request = new Request(url, requestInit);\n const response = await fetchFn(request);\n \n if (response.status === 429 && attempt < retryConfig.maxRetries) {\n const retryAfter = response.headers.get('retry-after');\n const delay = retryAfter ? parseInt(retryAfter) * 1000 : retryConfig.retryDelay;\n \n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n return response;\n } catch (error) {\n // If it's a network error and we haven't exceeded retries, try again\n if (attempt < retryConfig.maxRetries) {\n const delay = retryConfig.retryDelay;\n await new Promise(resolve => setTimeout(resolve, delay));\n \n // Use the original unconsumed request for retry\n return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);\n }\n \n throw error;\n }\n }\n\n return {\n buildUrl,\n connect: (options) => request({ ...options, method: 'CONNECT' }),\n delete: (options) => request({ ...options, method: 'DELETE' }),\n get: (options) => request({ ...options, method: 'GET' }),\n getConfig,\n head: (options) => request({ ...options, method: 'HEAD' }),\n interceptors,\n options: (options) => request({ ...options, method: 'OPTIONS' }),\n patch: (options) => request({ ...options, method: 'PATCH' }),\n post: (options) => request({ ...options, method: 'POST' }),\n put: (options) => request({ ...options, method: 'PUT' }),\n request,\n setConfig,\n trace: (options) => request({ ...options, method: 'TRACE' }),\n };\n};\n"],"mappings":";;;;AAiBA,MAAa,eAAe,CAACA,WAA2B;CACtD,IAAI,UAAU,aAAa,cAAc,EAAE,OAAO;CAElD,MAAM,YAAY,OAAe,EAAE,GAAG,QAAS;CAE/C,MAAM,YAAY,CAACA,aAA2B;EAC5C,UAAU,aAAa,SAASC,SAAO;AACvC,SAAO,WAAW;CACnB;CAED,MAAM,eAAe,oBAKlB;CAEH,MAAMC,UAA6B,OAAO,YAAY;EACpD,MAAM,OAAO;GACX,GAAG;GACH,GAAG;GACH,OAAO,QAAQ,SAAS,QAAQ,SAAS,WAAW;GACpD,SAAS,aAAa,QAAQ,SAAS,QAAQ,QAAQ;EACxD;AAID,MAAI,CAAC,QAAQ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M,IAAI,QAAQ,aAAW,WAAW,SAAS,MAAM;AAGvD,WAAO,iBAAiB,SAAS,KAAK,aAAa,aAAa,UAAU,EAAE;GAC7E;AAED,SAAM;EACP;CACF;AAED,QAAO;EACL;EACA,SAAS,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAW,EAAC;EAChE,QAAQ,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAU,EAAC;EAC9D,KAAK,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAO,EAAC;EACxD;EACA,MAAM,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAQ,EAAC;EAC1D;EACA,SAAS,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAW,EAAC;EAChE,OAAO,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAS,EAAC;EAC5D,MAAM,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAQ,EAAC;EAC1D,KAAK,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAO,EAAC;EACxD;EACA;EACA,OAAO,CAAC,YAAY,QAAQ;GAAE,GAAG;GAAS,QAAQ;EAAS,EAAC;CAC7D;AACF"}
|
package/dist/client/types.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Auth } from "../core/auth.mjs";
|
|
2
2
|
import { Client, Config } from "../core/types.mjs";
|
|
3
3
|
import { Middleware } from "./utils.mjs";
|
|
4
|
+
import { Region } from "@storyblok/region-helper";
|
|
4
5
|
|
|
5
6
|
//#region src/client/types.d.ts
|
|
6
7
|
type ResponseStyle = 'data' | 'fields';
|
|
@@ -44,6 +45,12 @@ interface Config$1<T extends ClientOptions = ClientOptions> extends Omit<Request
|
|
|
44
45
|
* @default false
|
|
45
46
|
*/
|
|
46
47
|
throwOnError?: T['throwOnError'];
|
|
48
|
+
/**
|
|
49
|
+
* Fallback region to use for any requests that cannot infer the region from the path
|
|
50
|
+
*
|
|
51
|
+
* @default 'eu'
|
|
52
|
+
*/
|
|
53
|
+
region?: Region;
|
|
47
54
|
}
|
|
48
55
|
interface RequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config$1<{
|
|
49
56
|
responseStyle: TResponseStyle;
|
package/dist/client/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Auth } from "../core/auth.js";
|
|
2
2
|
import { Client, Config } from "../core/types.js";
|
|
3
3
|
import { Middleware } from "./utils.js";
|
|
4
|
+
import { Region } from "@storyblok/region-helper";
|
|
4
5
|
|
|
5
6
|
//#region src/client/types.d.ts
|
|
6
7
|
type ResponseStyle = 'data' | 'fields';
|
|
@@ -44,6 +45,12 @@ interface Config$1<T extends ClientOptions = ClientOptions> extends Omit<Request
|
|
|
44
45
|
* @default false
|
|
45
46
|
*/
|
|
46
47
|
throwOnError?: T['throwOnError'];
|
|
48
|
+
/**
|
|
49
|
+
* Fallback region to use for any requests that cannot infer the region from the path
|
|
50
|
+
*
|
|
51
|
+
* @default 'eu'
|
|
52
|
+
*/
|
|
53
|
+
region?: Region;
|
|
47
54
|
}
|
|
48
55
|
interface RequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config$1<{
|
|
49
56
|
responseStyle: TResponseStyle;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace types_gen_d_exports {
|
|
2
|
-
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses };
|
|
2
|
+
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses };
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
5
|
* A single asset object
|
|
@@ -134,6 +134,10 @@ type SignedResponseObject = {
|
|
|
134
134
|
* The ID of the Storyblok space (can be integer or string)
|
|
135
135
|
*/
|
|
136
136
|
type SpaceId = number | string;
|
|
137
|
+
/**
|
|
138
|
+
* Page number for pagination. Default is 1.
|
|
139
|
+
*/
|
|
140
|
+
type Page = number;
|
|
137
141
|
/**
|
|
138
142
|
* The ID of the asset (can be integer or string)
|
|
139
143
|
*/
|
|
@@ -147,6 +151,14 @@ type ListData = {
|
|
|
147
151
|
space_id: number | string;
|
|
148
152
|
};
|
|
149
153
|
query?: {
|
|
154
|
+
/**
|
|
155
|
+
* Page number for pagination. Default is 1.
|
|
156
|
+
*/
|
|
157
|
+
page?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Number of assets per page. Default is 25, maximum is 100.
|
|
160
|
+
*/
|
|
161
|
+
per_page?: number;
|
|
150
162
|
/**
|
|
151
163
|
* Provide the numeric id of a folder to filter the assets by a specific folder. Use value -1 to retrieve deleted assets.
|
|
152
164
|
*/
|
|
@@ -595,5 +607,5 @@ type ClientOptions = {
|
|
|
595
607
|
baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});
|
|
596
608
|
};
|
|
597
609
|
//#endregion
|
|
598
|
-
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses, types_gen_d_exports };
|
|
610
|
+
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses, types_gen_d_exports };
|
|
599
611
|
//# sourceMappingURL=types.gen.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace types_gen_d_exports {
|
|
2
|
-
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses };
|
|
2
|
+
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses };
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
5
|
* A single asset object
|
|
@@ -134,6 +134,10 @@ type SignedResponseObject = {
|
|
|
134
134
|
* The ID of the Storyblok space (can be integer or string)
|
|
135
135
|
*/
|
|
136
136
|
type SpaceId = number | string;
|
|
137
|
+
/**
|
|
138
|
+
* Page number for pagination. Default is 1.
|
|
139
|
+
*/
|
|
140
|
+
type Page = number;
|
|
137
141
|
/**
|
|
138
142
|
* The ID of the asset (can be integer or string)
|
|
139
143
|
*/
|
|
@@ -147,6 +151,14 @@ type ListData = {
|
|
|
147
151
|
space_id: number | string;
|
|
148
152
|
};
|
|
149
153
|
query?: {
|
|
154
|
+
/**
|
|
155
|
+
* Page number for pagination. Default is 1.
|
|
156
|
+
*/
|
|
157
|
+
page?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Number of assets per page. Default is 25, maximum is 100.
|
|
160
|
+
*/
|
|
161
|
+
per_page?: number;
|
|
150
162
|
/**
|
|
151
163
|
* Provide the numeric id of a folder to filter the assets by a specific folder. Use value -1 to retrieve deleted assets.
|
|
152
164
|
*/
|
|
@@ -595,5 +607,5 @@ type ClientOptions = {
|
|
|
595
607
|
baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});
|
|
596
608
|
};
|
|
597
609
|
//#endregion
|
|
598
|
-
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses, types_gen_d_exports };
|
|
610
|
+
export { Asset, AssetId, BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, BulkRestoreData, BulkRestoreErrors, BulkRestoreResponse, BulkRestoreResponses, ClientOptions, DeleteData, DeleteErrors, DeleteManyData, DeleteManyErrors, DeleteManyResponse, DeleteManyResponses, DeleteResponse, DeleteResponses, FinalizeData, FinalizeErrors, FinalizeResponse, FinalizeResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses, types_gen_d_exports };
|
|
599
611
|
//# sourceMappingURL=types.gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.gen.js","names":[],"sources":["../../../src/generated/assets/types.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\n/**\n * A single asset object\n */\nexport type Asset = {\n /**\n * The numeric ID\n */\n id?: number;\n /**\n * Full path of the asset, including the file name\n */\n filename?: string;\n /**\n * Space ID in which the asset is connected\n */\n space_id?: number;\n /**\n * Creation date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n created_at?: string;\n /**\n * Latest update date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n updated_at?: string;\n /**\n * Represents a File object when uploading an asset. Returns null when retrieving asset details.\n */\n file?: {\n [key: string]: unknown;\n };\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Deleted date (Format YYYY-mm-dd HH:MM)\n */\n deleted_at?: string;\n /**\n * The file name of the asset\n */\n short_filename?: string;\n /**\n * The MIME type of the asset\n */\n content_type?: string;\n /**\n * The content length in bytes\n */\n content_length?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * List of objects containing the details of tags used for the asset\n */\n internal_tags_list?: Array<{\n /**\n * Id of the tag\n */\n id?: number;\n /**\n * Name of the tag\n */\n name?: string;\n }>;\n /**\n * Defines if the asset is locked for any changes\n */\n locked?: boolean;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * Signed response object returned from the upload request\n */\nexport type SignedResponseObject = {\n /**\n * The ID of the signed response object\n */\n id?: string;\n /**\n * The URL to post the file to\n */\n post_url?: string;\n /**\n * Form fields to include in the upload request\n */\n fields?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * The ID of the Storyblok space (can be integer or string)\n */\nexport type SpaceId = number | string;\n\n/**\n * The ID of the asset (can be integer or string)\n */\nexport type AssetId = number | string;\n\nexport type ListData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: {\n /**\n * Provide the numeric id of a folder to filter the assets by a specific folder. Use value -1 to retrieve deleted assets.\n */\n in_folder?: number;\n /**\n * Sort assets by specific attribute and order\n */\n sort_by?: 'created_at:asc' | 'created_at:desc' | 'updated_at:asc' | 'updated_at:desc' | 'short_filename:asc' | 'short_filename:desc';\n /**\n * If \"1\" it only displays private assets\n */\n is_private?: boolean;\n /**\n * Provide a search term to filter a specific file by the filename\n */\n search?: string;\n /**\n * Filter by the alt text of an asset\n */\n by_alt?: string;\n /**\n * Filter by the copyright of an asset\n */\n by_copyright?: string;\n /**\n * Filter by the title of an asset\n */\n by_title?: string;\n /**\n * Filter by specific tag(s). Multiple tags can be provided as a comma-separated string (treated like an OR operator).\n */\n with_tags?: string;\n };\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type ListErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type ListResponses = {\n /**\n * List of assets\n */\n 200: {\n assets?: Array<Asset>;\n };\n};\n\nexport type ListResponse = ListResponses[keyof ListResponses];\n\nexport type UploadData = {\n body: {\n /**\n * The filename of the asset to upload\n */\n filename: string;\n /**\n * The size of the asset (e.g., \"400X500\")\n */\n size: string;\n /**\n * Optional asset folder ID to place the asset in\n */\n asset_folder_id?: number;\n /**\n * Must be set to 1 to validate the upload\n */\n validate_upload: 1;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type UploadErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type UploadResponses = {\n /**\n * Signed response object for upload\n */\n 200: SignedResponseObject;\n};\n\nexport type UploadResponse = UploadResponses[keyof UploadResponses];\n\nexport type DeleteData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type DeleteErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type DeleteResponses = {\n /**\n * Asset deleted\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type DeleteResponse = DeleteResponses[keyof DeleteResponses];\n\nexport type GetData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type GetErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type GetResponses = {\n /**\n * Asset details\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type GetResponse = GetResponses[keyof GetResponses];\n\nexport type UpdateData = {\n body: {\n /**\n * A single asset object with updatable properties\n */\n asset?: {\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n };\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type UpdateErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type UpdateResponses = {\n /**\n * Asset updated\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type UpdateResponse = UpdateResponses[keyof UpdateResponses];\n\nexport type FinalizeData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID from the signed response object\n */\n signed_response_object_id: string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{signed_response_object_id}/finish_upload';\n};\n\nexport type FinalizeErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type FinalizeResponses = {\n /**\n * Upload finalized successfully\n */\n 200: {\n /**\n * Success message indicating the upload was finalized\n */\n message?: string;\n };\n};\n\nexport type FinalizeResponse = FinalizeResponses[keyof FinalizeResponses];\n\nexport type DeleteManyData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_destroy';\n};\n\nexport type DeleteManyErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type DeleteManyResponses = {\n /**\n * Assets deleted successfully\n */\n 200: {\n /**\n * Success message indicating which assets were deleted\n */\n message?: string;\n };\n};\n\nexport type DeleteManyResponse = DeleteManyResponses[keyof DeleteManyResponses];\n\nexport type BulkMoveData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id: number;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_update';\n};\n\nexport type BulkMoveErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkMoveResponses = {\n /**\n * Assets moved successfully\n */\n 200: {\n /**\n * Success message indicating which assets were moved\n */\n message?: string;\n };\n};\n\nexport type BulkMoveResponse = BulkMoveResponses[keyof BulkMoveResponses];\n\nexport type BulkRestoreData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_restore';\n};\n\nexport type BulkRestoreErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkRestoreResponses = {\n /**\n * Assets restored successfully\n */\n 200: {\n /**\n * Success message indicating which assets were restored\n */\n message?: string;\n };\n};\n\nexport type BulkRestoreResponse = BulkRestoreResponses[keyof BulkRestoreResponses];\n\nexport type ClientOptions = {\n baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});\n};"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.gen.js","names":[],"sources":["../../../src/generated/assets/types.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\n/**\n * A single asset object\n */\nexport type Asset = {\n /**\n * The numeric ID\n */\n id?: number;\n /**\n * Full path of the asset, including the file name\n */\n filename?: string;\n /**\n * Space ID in which the asset is connected\n */\n space_id?: number;\n /**\n * Creation date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n created_at?: string;\n /**\n * Latest update date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n updated_at?: string;\n /**\n * Represents a File object when uploading an asset. Returns null when retrieving asset details.\n */\n file?: {\n [key: string]: unknown;\n };\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Deleted date (Format YYYY-mm-dd HH:MM)\n */\n deleted_at?: string;\n /**\n * The file name of the asset\n */\n short_filename?: string;\n /**\n * The MIME type of the asset\n */\n content_type?: string;\n /**\n * The content length in bytes\n */\n content_length?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * List of objects containing the details of tags used for the asset\n */\n internal_tags_list?: Array<{\n /**\n * Id of the tag\n */\n id?: number;\n /**\n * Name of the tag\n */\n name?: string;\n }>;\n /**\n * Defines if the asset is locked for any changes\n */\n locked?: boolean;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * Signed response object returned from the upload request\n */\nexport type SignedResponseObject = {\n /**\n * The ID of the signed response object\n */\n id?: string;\n /**\n * The URL to post the file to\n */\n post_url?: string;\n /**\n * Form fields to include in the upload request\n */\n fields?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * The ID of the Storyblok space (can be integer or string)\n */\nexport type SpaceId = number | string;\n\n/**\n * Page number for pagination. Default is 1.\n */\nexport type Page = number;\n\n/**\n * The ID of the asset (can be integer or string)\n */\nexport type AssetId = number | string;\n\nexport type ListData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: {\n /**\n * Page number for pagination. Default is 1.\n */\n page?: number;\n /**\n * Number of assets per page. Default is 25, maximum is 100.\n */\n per_page?: number;\n /**\n * Provide the numeric id of a folder to filter the assets by a specific folder. Use value -1 to retrieve deleted assets.\n */\n in_folder?: number;\n /**\n * Sort assets by specific attribute and order\n */\n sort_by?: 'created_at:asc' | 'created_at:desc' | 'updated_at:asc' | 'updated_at:desc' | 'short_filename:asc' | 'short_filename:desc';\n /**\n * If \"1\" it only displays private assets\n */\n is_private?: boolean;\n /**\n * Provide a search term to filter a specific file by the filename\n */\n search?: string;\n /**\n * Filter by the alt text of an asset\n */\n by_alt?: string;\n /**\n * Filter by the copyright of an asset\n */\n by_copyright?: string;\n /**\n * Filter by the title of an asset\n */\n by_title?: string;\n /**\n * Filter by specific tag(s). Multiple tags can be provided as a comma-separated string (treated like an OR operator).\n */\n with_tags?: string;\n };\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type ListErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type ListResponses = {\n /**\n * List of assets\n */\n 200: {\n assets?: Array<Asset>;\n };\n};\n\nexport type ListResponse = ListResponses[keyof ListResponses];\n\nexport type UploadData = {\n body: {\n /**\n * The filename of the asset to upload\n */\n filename: string;\n /**\n * The size of the asset (e.g., \"400X500\")\n */\n size: string;\n /**\n * Optional asset folder ID to place the asset in\n */\n asset_folder_id?: number;\n /**\n * Must be set to 1 to validate the upload\n */\n validate_upload: 1;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type UploadErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type UploadResponses = {\n /**\n * Signed response object for upload\n */\n 200: SignedResponseObject;\n};\n\nexport type UploadResponse = UploadResponses[keyof UploadResponses];\n\nexport type DeleteData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type DeleteErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type DeleteResponses = {\n /**\n * Asset deleted\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type DeleteResponse = DeleteResponses[keyof DeleteResponses];\n\nexport type GetData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type GetErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type GetResponses = {\n /**\n * Asset details\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type GetResponse = GetResponses[keyof GetResponses];\n\nexport type UpdateData = {\n body: {\n /**\n * A single asset object with updatable properties\n */\n asset?: {\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n };\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type UpdateErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type UpdateResponses = {\n /**\n * Asset updated\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type UpdateResponse = UpdateResponses[keyof UpdateResponses];\n\nexport type FinalizeData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID from the signed response object\n */\n signed_response_object_id: string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{signed_response_object_id}/finish_upload';\n};\n\nexport type FinalizeErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type FinalizeResponses = {\n /**\n * Upload finalized successfully\n */\n 200: {\n /**\n * Success message indicating the upload was finalized\n */\n message?: string;\n };\n};\n\nexport type FinalizeResponse = FinalizeResponses[keyof FinalizeResponses];\n\nexport type DeleteManyData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_destroy';\n};\n\nexport type DeleteManyErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type DeleteManyResponses = {\n /**\n * Assets deleted successfully\n */\n 200: {\n /**\n * Success message indicating which assets were deleted\n */\n message?: string;\n };\n};\n\nexport type DeleteManyResponse = DeleteManyResponses[keyof DeleteManyResponses];\n\nexport type BulkMoveData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id: number;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_update';\n};\n\nexport type BulkMoveErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkMoveResponses = {\n /**\n * Assets moved successfully\n */\n 200: {\n /**\n * Success message indicating which assets were moved\n */\n message?: string;\n };\n};\n\nexport type BulkMoveResponse = BulkMoveResponses[keyof BulkMoveResponses];\n\nexport type BulkRestoreData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_restore';\n};\n\nexport type BulkRestoreErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkRestoreResponses = {\n /**\n * Assets restored successfully\n */\n 200: {\n /**\n * Success message indicating which assets were restored\n */\n message?: string;\n };\n};\n\nexport type BulkRestoreResponse = BulkRestoreResponses[keyof BulkRestoreResponses];\n\nexport type ClientOptions = {\n baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});\n};"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.gen.mjs","names":[],"sources":["../../../src/generated/assets/types.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\n/**\n * A single asset object\n */\nexport type Asset = {\n /**\n * The numeric ID\n */\n id?: number;\n /**\n * Full path of the asset, including the file name\n */\n filename?: string;\n /**\n * Space ID in which the asset is connected\n */\n space_id?: number;\n /**\n * Creation date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n created_at?: string;\n /**\n * Latest update date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n updated_at?: string;\n /**\n * Represents a File object when uploading an asset. Returns null when retrieving asset details.\n */\n file?: {\n [key: string]: unknown;\n };\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Deleted date (Format YYYY-mm-dd HH:MM)\n */\n deleted_at?: string;\n /**\n * The file name of the asset\n */\n short_filename?: string;\n /**\n * The MIME type of the asset\n */\n content_type?: string;\n /**\n * The content length in bytes\n */\n content_length?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * List of objects containing the details of tags used for the asset\n */\n internal_tags_list?: Array<{\n /**\n * Id of the tag\n */\n id?: number;\n /**\n * Name of the tag\n */\n name?: string;\n }>;\n /**\n * Defines if the asset is locked for any changes\n */\n locked?: boolean;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * Signed response object returned from the upload request\n */\nexport type SignedResponseObject = {\n /**\n * The ID of the signed response object\n */\n id?: string;\n /**\n * The URL to post the file to\n */\n post_url?: string;\n /**\n * Form fields to include in the upload request\n */\n fields?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * The ID of the Storyblok space (can be integer or string)\n */\nexport type SpaceId = number | string;\n\n/**\n * The ID of the asset (can be integer or string)\n */\nexport type AssetId = number | string;\n\nexport type ListData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: {\n /**\n * Provide the numeric id of a folder to filter the assets by a specific folder. Use value -1 to retrieve deleted assets.\n */\n in_folder?: number;\n /**\n * Sort assets by specific attribute and order\n */\n sort_by?: 'created_at:asc' | 'created_at:desc' | 'updated_at:asc' | 'updated_at:desc' | 'short_filename:asc' | 'short_filename:desc';\n /**\n * If \"1\" it only displays private assets\n */\n is_private?: boolean;\n /**\n * Provide a search term to filter a specific file by the filename\n */\n search?: string;\n /**\n * Filter by the alt text of an asset\n */\n by_alt?: string;\n /**\n * Filter by the copyright of an asset\n */\n by_copyright?: string;\n /**\n * Filter by the title of an asset\n */\n by_title?: string;\n /**\n * Filter by specific tag(s). Multiple tags can be provided as a comma-separated string (treated like an OR operator).\n */\n with_tags?: string;\n };\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type ListErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type ListResponses = {\n /**\n * List of assets\n */\n 200: {\n assets?: Array<Asset>;\n };\n};\n\nexport type ListResponse = ListResponses[keyof ListResponses];\n\nexport type UploadData = {\n body: {\n /**\n * The filename of the asset to upload\n */\n filename: string;\n /**\n * The size of the asset (e.g., \"400X500\")\n */\n size: string;\n /**\n * Optional asset folder ID to place the asset in\n */\n asset_folder_id?: number;\n /**\n * Must be set to 1 to validate the upload\n */\n validate_upload: 1;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type UploadErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type UploadResponses = {\n /**\n * Signed response object for upload\n */\n 200: SignedResponseObject;\n};\n\nexport type UploadResponse = UploadResponses[keyof UploadResponses];\n\nexport type DeleteData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type DeleteErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type DeleteResponses = {\n /**\n * Asset deleted\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type DeleteResponse = DeleteResponses[keyof DeleteResponses];\n\nexport type GetData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type GetErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type GetResponses = {\n /**\n * Asset details\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type GetResponse = GetResponses[keyof GetResponses];\n\nexport type UpdateData = {\n body: {\n /**\n * A single asset object with updatable properties\n */\n asset?: {\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n };\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type UpdateErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type UpdateResponses = {\n /**\n * Asset updated\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type UpdateResponse = UpdateResponses[keyof UpdateResponses];\n\nexport type FinalizeData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID from the signed response object\n */\n signed_response_object_id: string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{signed_response_object_id}/finish_upload';\n};\n\nexport type FinalizeErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type FinalizeResponses = {\n /**\n * Upload finalized successfully\n */\n 200: {\n /**\n * Success message indicating the upload was finalized\n */\n message?: string;\n };\n};\n\nexport type FinalizeResponse = FinalizeResponses[keyof FinalizeResponses];\n\nexport type DeleteManyData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_destroy';\n};\n\nexport type DeleteManyErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type DeleteManyResponses = {\n /**\n * Assets deleted successfully\n */\n 200: {\n /**\n * Success message indicating which assets were deleted\n */\n message?: string;\n };\n};\n\nexport type DeleteManyResponse = DeleteManyResponses[keyof DeleteManyResponses];\n\nexport type BulkMoveData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id: number;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_update';\n};\n\nexport type BulkMoveErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkMoveResponses = {\n /**\n * Assets moved successfully\n */\n 200: {\n /**\n * Success message indicating which assets were moved\n */\n message?: string;\n };\n};\n\nexport type BulkMoveResponse = BulkMoveResponses[keyof BulkMoveResponses];\n\nexport type BulkRestoreData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_restore';\n};\n\nexport type BulkRestoreErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkRestoreResponses = {\n /**\n * Assets restored successfully\n */\n 200: {\n /**\n * Success message indicating which assets were restored\n */\n message?: string;\n };\n};\n\nexport type BulkRestoreResponse = BulkRestoreResponses[keyof BulkRestoreResponses];\n\nexport type ClientOptions = {\n baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});\n};"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.gen.mjs","names":[],"sources":["../../../src/generated/assets/types.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\n/**\n * A single asset object\n */\nexport type Asset = {\n /**\n * The numeric ID\n */\n id?: number;\n /**\n * Full path of the asset, including the file name\n */\n filename?: string;\n /**\n * Space ID in which the asset is connected\n */\n space_id?: number;\n /**\n * Creation date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n created_at?: string;\n /**\n * Latest update date (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n updated_at?: string;\n /**\n * Represents a File object when uploading an asset. Returns null when retrieving asset details.\n */\n file?: {\n [key: string]: unknown;\n };\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Deleted date (Format YYYY-mm-dd HH:MM)\n */\n deleted_at?: string;\n /**\n * The file name of the asset\n */\n short_filename?: string;\n /**\n * The MIME type of the asset\n */\n content_type?: string;\n /**\n * The content length in bytes\n */\n content_length?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * List of objects containing the details of tags used for the asset\n */\n internal_tags_list?: Array<{\n /**\n * Id of the tag\n */\n id?: number;\n /**\n * Name of the tag\n */\n name?: string;\n }>;\n /**\n * Defines if the asset is locked for any changes\n */\n locked?: boolean;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * Signed response object returned from the upload request\n */\nexport type SignedResponseObject = {\n /**\n * The ID of the signed response object\n */\n id?: string;\n /**\n * The URL to post the file to\n */\n post_url?: string;\n /**\n * Form fields to include in the upload request\n */\n fields?: {\n [key: string]: unknown;\n };\n};\n\n/**\n * The ID of the Storyblok space (can be integer or string)\n */\nexport type SpaceId = number | string;\n\n/**\n * Page number for pagination. Default is 1.\n */\nexport type Page = number;\n\n/**\n * The ID of the asset (can be integer or string)\n */\nexport type AssetId = number | string;\n\nexport type ListData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: {\n /**\n * Page number for pagination. Default is 1.\n */\n page?: number;\n /**\n * Number of assets per page. Default is 25, maximum is 100.\n */\n per_page?: number;\n /**\n * Provide the numeric id of a folder to filter the assets by a specific folder. Use value -1 to retrieve deleted assets.\n */\n in_folder?: number;\n /**\n * Sort assets by specific attribute and order\n */\n sort_by?: 'created_at:asc' | 'created_at:desc' | 'updated_at:asc' | 'updated_at:desc' | 'short_filename:asc' | 'short_filename:desc';\n /**\n * If \"1\" it only displays private assets\n */\n is_private?: boolean;\n /**\n * Provide a search term to filter a specific file by the filename\n */\n search?: string;\n /**\n * Filter by the alt text of an asset\n */\n by_alt?: string;\n /**\n * Filter by the copyright of an asset\n */\n by_copyright?: string;\n /**\n * Filter by the title of an asset\n */\n by_title?: string;\n /**\n * Filter by specific tag(s). Multiple tags can be provided as a comma-separated string (treated like an OR operator).\n */\n with_tags?: string;\n };\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type ListErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type ListResponses = {\n /**\n * List of assets\n */\n 200: {\n assets?: Array<Asset>;\n };\n};\n\nexport type ListResponse = ListResponses[keyof ListResponses];\n\nexport type UploadData = {\n body: {\n /**\n * The filename of the asset to upload\n */\n filename: string;\n /**\n * The size of the asset (e.g., \"400X500\")\n */\n size: string;\n /**\n * Optional asset folder ID to place the asset in\n */\n asset_folder_id?: number;\n /**\n * Must be set to 1 to validate the upload\n */\n validate_upload: 1;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets';\n};\n\nexport type UploadErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type UploadResponses = {\n /**\n * Signed response object for upload\n */\n 200: SignedResponseObject;\n};\n\nexport type UploadResponse = UploadResponses[keyof UploadResponses];\n\nexport type DeleteData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type DeleteErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type DeleteResponses = {\n /**\n * Asset deleted\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type DeleteResponse = DeleteResponses[keyof DeleteResponses];\n\nexport type GetData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type GetErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type GetResponses = {\n /**\n * Asset details\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type GetResponse = GetResponses[keyof GetResponses];\n\nexport type UpdateData = {\n body: {\n /**\n * A single asset object with updatable properties\n */\n asset?: {\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id?: number;\n /**\n * Alt text for the asset (default language)\n */\n alt?: string;\n /**\n * Copyright text for the asset (default language)\n */\n copyright?: string;\n /**\n * Title of the asset (default language)\n */\n title?: string;\n /**\n * Source text for the asset (default language)\n */\n source?: string;\n /**\n * Date when the asset should expire (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n expire_at?: string;\n /**\n * The focus point of the image (Only for image assets)\n */\n focus?: string;\n /**\n * List of ids of the tags assigned to the asset\n */\n internal_tag_ids?: Array<string>;\n /**\n * Date when the asset should be made public (Format yyyy-MM-dd'T'HH:mm:ssZ)\n */\n publish_at?: string;\n /**\n * Defines if the asset should be inaccessable to the public\n */\n is_private?: boolean;\n /**\n * Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode. This field should be used for updating the metadata including the default ones (alt, title, source, copyright)\n */\n meta_data?: {\n [key: string]: unknown;\n };\n };\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID of the asset (can be integer or string)\n */\n asset_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{asset_id}';\n};\n\nexport type UpdateErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type UpdateResponses = {\n /**\n * Asset updated\n */\n 200: {\n asset?: Asset;\n };\n};\n\nexport type UpdateResponse = UpdateResponses[keyof UpdateResponses];\n\nexport type FinalizeData = {\n body?: never;\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n /**\n * The ID from the signed response object\n */\n signed_response_object_id: string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/{signed_response_object_id}/finish_upload';\n};\n\nexport type FinalizeErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Asset not found\n */\n 404: unknown;\n};\n\nexport type FinalizeResponses = {\n /**\n * Upload finalized successfully\n */\n 200: {\n /**\n * Success message indicating the upload was finalized\n */\n message?: string;\n };\n};\n\nexport type FinalizeResponse = FinalizeResponses[keyof FinalizeResponses];\n\nexport type DeleteManyData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_destroy';\n};\n\nexport type DeleteManyErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type DeleteManyResponses = {\n /**\n * Assets deleted successfully\n */\n 200: {\n /**\n * Success message indicating which assets were deleted\n */\n message?: string;\n };\n};\n\nexport type DeleteManyResponse = DeleteManyResponses[keyof DeleteManyResponses];\n\nexport type BulkMoveData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n /**\n * Id of the folder containing this asset\n */\n asset_folder_id: number;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_update';\n};\n\nexport type BulkMoveErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkMoveResponses = {\n /**\n * Assets moved successfully\n */\n 200: {\n /**\n * Success message indicating which assets were moved\n */\n message?: string;\n };\n};\n\nexport type BulkMoveResponse = BulkMoveResponses[keyof BulkMoveResponses];\n\nexport type BulkRestoreData = {\n body: {\n /**\n * Array of numeric asset IDs\n */\n ids: Array<number>;\n };\n path: {\n /**\n * The ID of the Storyblok space (can be integer or string)\n */\n space_id: number | string;\n };\n query?: never;\n url: '/v1/spaces/{space_id}/assets/bulk_restore';\n};\n\nexport type BulkRestoreErrors = {\n /**\n * Bad request\n */\n 400: unknown;\n /**\n * Unauthorized\n */\n 401: unknown;\n /**\n * Space not found\n */\n 404: unknown;\n};\n\nexport type BulkRestoreResponses = {\n /**\n * Assets restored successfully\n */\n 200: {\n /**\n * Success message indicating which assets were restored\n */\n message?: string;\n };\n};\n\nexport type BulkRestoreResponse = BulkRestoreResponses[keyof BulkRestoreResponses];\n\nexport type ClientOptions = {\n baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});\n};"],"mappings":""}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
declare namespace types_gen_d_exports {
|
|
2
|
-
export { ClientOptions, ComponentFolder,
|
|
2
|
+
export { ClientOptions, ComponentFolder, ComponentGroupId, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteData, DeleteErrors, DeleteResponse, DeleteResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses };
|
|
3
3
|
}
|
|
4
4
|
type ComponentFolder = {
|
|
5
5
|
/**
|
|
6
6
|
* The id of the component folder
|
|
7
7
|
*/
|
|
8
|
-
id
|
|
8
|
+
readonly id: number;
|
|
9
9
|
/**
|
|
10
10
|
* The name of the component folder
|
|
11
11
|
*/
|
|
12
|
-
name
|
|
12
|
+
name: string;
|
|
13
13
|
/**
|
|
14
14
|
* The UUID of the component folder
|
|
15
15
|
*/
|
|
16
|
-
uuid
|
|
16
|
+
readonly uuid: string;
|
|
17
17
|
/**
|
|
18
18
|
* ID of the parent folder
|
|
19
19
|
*/
|
|
@@ -21,27 +21,7 @@ type ComponentFolder = {
|
|
|
21
21
|
/**
|
|
22
22
|
* The UUID of the parent folder
|
|
23
23
|
*/
|
|
24
|
-
parent_uuid?: string;
|
|
25
|
-
};
|
|
26
|
-
type ComponentFolderInput = {
|
|
27
|
-
/**
|
|
28
|
-
* Name of the group
|
|
29
|
-
*/
|
|
30
|
-
name: string;
|
|
31
|
-
/**
|
|
32
|
-
* ID of the parent folder
|
|
33
|
-
*/
|
|
34
|
-
parent_id?: number;
|
|
35
|
-
};
|
|
36
|
-
type ComponentFolderUpdateInput = {
|
|
37
|
-
/**
|
|
38
|
-
* Name of the group
|
|
39
|
-
*/
|
|
40
|
-
name?: string;
|
|
41
|
-
/**
|
|
42
|
-
* ID of the parent folder
|
|
43
|
-
*/
|
|
44
|
-
parent_id?: number;
|
|
24
|
+
readonly parent_uuid?: string;
|
|
45
25
|
};
|
|
46
26
|
/**
|
|
47
27
|
* The ID of the Storyblok space (can be integer or string)
|
|
@@ -96,7 +76,7 @@ type ListResponses = {
|
|
|
96
76
|
type ListResponse = ListResponses[keyof ListResponses];
|
|
97
77
|
type CreateData = {
|
|
98
78
|
body: {
|
|
99
|
-
component_group?:
|
|
79
|
+
component_group?: ComponentFolder;
|
|
100
80
|
};
|
|
101
81
|
path: {
|
|
102
82
|
/**
|
|
@@ -206,7 +186,7 @@ type GetResponses = {
|
|
|
206
186
|
type GetResponse = GetResponses[keyof GetResponses];
|
|
207
187
|
type UpdateData = {
|
|
208
188
|
body: {
|
|
209
|
-
component_group?:
|
|
189
|
+
component_group?: ComponentFolder;
|
|
210
190
|
};
|
|
211
191
|
path: {
|
|
212
192
|
/**
|
|
@@ -248,5 +228,5 @@ type ClientOptions = {
|
|
|
248
228
|
baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});
|
|
249
229
|
};
|
|
250
230
|
//#endregion
|
|
251
|
-
export { ClientOptions, ComponentFolder,
|
|
231
|
+
export { ClientOptions, ComponentFolder, ComponentGroupId, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteData, DeleteErrors, DeleteResponse, DeleteResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, types_gen_d_exports };
|
|
252
232
|
//# sourceMappingURL=types.gen.d.mts.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
declare namespace types_gen_d_exports {
|
|
2
|
-
export { ClientOptions, ComponentFolder,
|
|
2
|
+
export { ClientOptions, ComponentFolder, ComponentGroupId, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteData, DeleteErrors, DeleteResponse, DeleteResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses };
|
|
3
3
|
}
|
|
4
4
|
type ComponentFolder = {
|
|
5
5
|
/**
|
|
6
6
|
* The id of the component folder
|
|
7
7
|
*/
|
|
8
|
-
id
|
|
8
|
+
readonly id: number;
|
|
9
9
|
/**
|
|
10
10
|
* The name of the component folder
|
|
11
11
|
*/
|
|
12
|
-
name
|
|
12
|
+
name: string;
|
|
13
13
|
/**
|
|
14
14
|
* The UUID of the component folder
|
|
15
15
|
*/
|
|
16
|
-
uuid
|
|
16
|
+
readonly uuid: string;
|
|
17
17
|
/**
|
|
18
18
|
* ID of the parent folder
|
|
19
19
|
*/
|
|
@@ -21,27 +21,7 @@ type ComponentFolder = {
|
|
|
21
21
|
/**
|
|
22
22
|
* The UUID of the parent folder
|
|
23
23
|
*/
|
|
24
|
-
parent_uuid?: string;
|
|
25
|
-
};
|
|
26
|
-
type ComponentFolderInput = {
|
|
27
|
-
/**
|
|
28
|
-
* Name of the group
|
|
29
|
-
*/
|
|
30
|
-
name: string;
|
|
31
|
-
/**
|
|
32
|
-
* ID of the parent folder
|
|
33
|
-
*/
|
|
34
|
-
parent_id?: number;
|
|
35
|
-
};
|
|
36
|
-
type ComponentFolderUpdateInput = {
|
|
37
|
-
/**
|
|
38
|
-
* Name of the group
|
|
39
|
-
*/
|
|
40
|
-
name?: string;
|
|
41
|
-
/**
|
|
42
|
-
* ID of the parent folder
|
|
43
|
-
*/
|
|
44
|
-
parent_id?: number;
|
|
24
|
+
readonly parent_uuid?: string;
|
|
45
25
|
};
|
|
46
26
|
/**
|
|
47
27
|
* The ID of the Storyblok space (can be integer or string)
|
|
@@ -96,7 +76,7 @@ type ListResponses = {
|
|
|
96
76
|
type ListResponse = ListResponses[keyof ListResponses];
|
|
97
77
|
type CreateData = {
|
|
98
78
|
body: {
|
|
99
|
-
component_group?:
|
|
79
|
+
component_group?: ComponentFolder;
|
|
100
80
|
};
|
|
101
81
|
path: {
|
|
102
82
|
/**
|
|
@@ -206,7 +186,7 @@ type GetResponses = {
|
|
|
206
186
|
type GetResponse = GetResponses[keyof GetResponses];
|
|
207
187
|
type UpdateData = {
|
|
208
188
|
body: {
|
|
209
|
-
component_group?:
|
|
189
|
+
component_group?: ComponentFolder;
|
|
210
190
|
};
|
|
211
191
|
path: {
|
|
212
192
|
/**
|
|
@@ -248,5 +228,5 @@ type ClientOptions = {
|
|
|
248
228
|
baseUrl: 'https://mapi.storyblok.com' | 'https://api-us.storyblok.com' | 'https://api-ca.storyblok.com' | 'https://api-ap.storyblok.com' | 'https://app.storyblok.cn' | (string & {});
|
|
249
229
|
};
|
|
250
230
|
//#endregion
|
|
251
|
-
export { ClientOptions, ComponentFolder,
|
|
231
|
+
export { ClientOptions, ComponentFolder, ComponentGroupId, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteData, DeleteErrors, DeleteResponse, DeleteResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, types_gen_d_exports };
|
|
252
232
|
//# sourceMappingURL=types.gen.d.ts.map
|