@storyblok/management-api-client 0.1.5 → 0.1.7
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/README.md +2 -2
- package/dist/client/client.js +7 -5
- package/dist/client/client.js.map +1 -1
- package/dist/client/client.mjs +7 -5
- package/dist/client/client.mjs.map +1 -1
- package/dist/generated/assets/types.gen.d.mts +7 -3
- package/dist/generated/assets/types.gen.d.ts +7 -3
- package/dist/generated/assets/types.gen.js.map +1 -1
- package/dist/generated/assets/types.gen.mjs.map +1 -1
- package/dist/generated/components/types.gen.d.mts +8 -4
- package/dist/generated/components/types.gen.d.ts +8 -4
- package/dist/generated/components/types.gen.js.map +1 -1
- package/dist/generated/components/types.gen.mjs.map +1 -1
- package/dist/generated/datasources/types.gen.d.mts +18 -2
- package/dist/generated/datasources/types.gen.d.ts +18 -2
- 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 +7 -3
- package/dist/generated/internal_tags/types.gen.d.ts +7 -3
- 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/stories/types.gen.d.mts +10 -3
- package/dist/generated/stories/types.gen.d.ts +10 -3
- package/dist/generated/stories/types.gen.js.map +1 -1
- package/dist/generated/stories/types.gen.mjs.map +1 -1
- package/dist/utils/calculate-retry-delay.js +20 -0
- package/dist/utils/calculate-retry-delay.js.map +1 -0
- package/dist/utils/calculate-retry-delay.mjs +19 -0
- package/dist/utils/calculate-retry-delay.mjs.map +1 -0
- package/dist/utils/delay.js +7 -0
- package/dist/utils/delay.js.map +1 -0
- package/dist/utils/delay.mjs +6 -0
- package/dist/utils/delay.mjs.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ The client includes built-in retry handling for rate limits and network errors:
|
|
|
140
140
|
|
|
141
141
|
```typescript
|
|
142
142
|
// The client automatically handles retries with these defaults:
|
|
143
|
-
// - maxRetries:
|
|
143
|
+
// - maxRetries: 12
|
|
144
144
|
// - retryDelay: 1000ms
|
|
145
145
|
// - Respects retry-after headers from 429 responses
|
|
146
146
|
|
|
@@ -148,7 +148,7 @@ const stories = await client.stories.list({
|
|
|
148
148
|
path: { space_id: 123456 },
|
|
149
149
|
query: { per_page: 10 }
|
|
150
150
|
});
|
|
151
|
-
// If rate limited, will automatically retry up to
|
|
151
|
+
// If rate limited, will automatically retry up to 12 times
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
## Runtime Configuration
|
package/dist/client/client.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_utils = require('./utils.js');
|
|
3
|
+
const require_calculate_retry_delay = require('../utils/calculate-retry-delay.js');
|
|
4
|
+
const require_delay = require('../utils/delay.js');
|
|
3
5
|
const __storyblok_region_helper = require_rolldown_runtime.__toESM(require("@storyblok/region-helper"));
|
|
4
6
|
|
|
5
7
|
//#region src/client/client.ts
|
|
@@ -38,7 +40,7 @@ const createClient = (config) => {
|
|
|
38
40
|
for (const fn of interceptors.request._fns) if (fn) request$1 = await fn(request$1, opts);
|
|
39
41
|
const _fetch = opts.fetch;
|
|
40
42
|
let response = await executeWithRetry(_fetch, url, requestInit, {
|
|
41
|
-
maxRetries:
|
|
43
|
+
maxRetries: 12,
|
|
42
44
|
retryDelay: 1e3
|
|
43
45
|
});
|
|
44
46
|
for (const fn of interceptors.response._fns) if (fn) response = await fn(response, request$1, opts);
|
|
@@ -96,15 +98,15 @@ const createClient = (config) => {
|
|
|
96
98
|
const response = await fetchFn(request$1);
|
|
97
99
|
if (response.status === 429 && attempt < retryConfig.maxRetries) {
|
|
98
100
|
const retryAfter = response.headers.get("retry-after");
|
|
99
|
-
const
|
|
100
|
-
await
|
|
101
|
+
const retryDelay = retryAfter ? parseInt(retryAfter) * 1e3 : require_calculate_retry_delay.calculateRetryDelay(attempt, retryConfig.retryDelay);
|
|
102
|
+
await require_delay.delay(retryDelay);
|
|
101
103
|
return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);
|
|
102
104
|
}
|
|
103
105
|
return response;
|
|
104
106
|
} catch (error) {
|
|
105
107
|
if (attempt < retryConfig.maxRetries) {
|
|
106
|
-
const delay = retryConfig.retryDelay;
|
|
107
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
108
|
+
const delay$1 = retryConfig.retryDelay;
|
|
109
|
+
await new Promise((resolve) => setTimeout(resolve, delay$1));
|
|
108
110
|
return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);
|
|
109
111
|
}
|
|
110
112
|
throw error;
|
|
@@ -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 to infer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number, opts.region);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n } else if (!_config.baseUrl && 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,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,UAAoB,KAAK,OAAO;AACtE,OAAI,QACF,KAAK,8DAA+B,QAAQ,QAAQ;EAEvD,WAAU,CAAC,QAAQ,WAAW,KAAK,QAClC,KAAK,8DAA+B,KAAK,QAAQ,QAAQ;AAG3D,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,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AC,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"}
|
|
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","calculateRetryDelay","delay"],"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';\nimport { calculateRetryDelay } from \"../utils/calculate-retry-delay\";\nimport { delay } from \"../utils/delay\";\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 to infer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number, opts.region);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n } else if (!_config.baseUrl && 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: 12,\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 retryDelay = retryAfter ? parseInt(retryAfter) * 1000 : calculateRetryDelay(attempt, retryConfig.retryDelay);\n await delay(retryDelay);\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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EAAS,EAAC;CAC7D;AACF"}
|
package/dist/client/client.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams } from "./utils.mjs";
|
|
2
|
+
import { calculateRetryDelay } from "../utils/calculate-retry-delay.mjs";
|
|
3
|
+
import { delay } from "../utils/delay.mjs";
|
|
2
4
|
import { getManagementBaseUrl, getRegion } from "@storyblok/region-helper";
|
|
3
5
|
|
|
4
6
|
//#region src/client/client.ts
|
|
@@ -37,7 +39,7 @@ const createClient = (config) => {
|
|
|
37
39
|
for (const fn of interceptors.request._fns) if (fn) request$1 = await fn(request$1, opts);
|
|
38
40
|
const _fetch = opts.fetch;
|
|
39
41
|
let response = await executeWithRetry(_fetch, url, requestInit, {
|
|
40
|
-
maxRetries:
|
|
42
|
+
maxRetries: 12,
|
|
41
43
|
retryDelay: 1e3
|
|
42
44
|
});
|
|
43
45
|
for (const fn of interceptors.response._fns) if (fn) response = await fn(response, request$1, opts);
|
|
@@ -95,15 +97,15 @@ const createClient = (config) => {
|
|
|
95
97
|
const response = await fetchFn(request$1);
|
|
96
98
|
if (response.status === 429 && attempt < retryConfig.maxRetries) {
|
|
97
99
|
const retryAfter = response.headers.get("retry-after");
|
|
98
|
-
const
|
|
99
|
-
await
|
|
100
|
+
const retryDelay = retryAfter ? parseInt(retryAfter) * 1e3 : calculateRetryDelay(attempt, retryConfig.retryDelay);
|
|
101
|
+
await delay(retryDelay);
|
|
100
102
|
return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);
|
|
101
103
|
}
|
|
102
104
|
return response;
|
|
103
105
|
} catch (error) {
|
|
104
106
|
if (attempt < retryConfig.maxRetries) {
|
|
105
|
-
const delay = retryConfig.retryDelay;
|
|
106
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
107
|
+
const delay$1 = retryConfig.retryDelay;
|
|
108
|
+
await new Promise((resolve) => setTimeout(resolve, delay$1));
|
|
107
109
|
return executeWithRetry(fetchFn, url, requestInit, retryConfig, attempt + 1);
|
|
108
110
|
}
|
|
109
111
|
throw error;
|
|
@@ -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 to infer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number, opts.region);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n } else if (!_config.baseUrl && 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,MAA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AAY;IAErE,MAAM,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"}
|
|
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","delay"],"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';\nimport { calculateRetryDelay } from \"../utils/calculate-retry-delay\";\nimport { delay } from \"../utils/delay\";\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 to infer the region\n if (!_config.baseUrl && options.path?.space_id) {\n const region = getRegion(options.path.space_id as number, opts.region);\n if (region) {\n opts.baseUrl = getManagementBaseUrl(region, 'https');\n }\n } else if (!_config.baseUrl && 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: 12,\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 retryDelay = retryAfter ? parseInt(retryAfter) * 1000 : calculateRetryDelay(attempt, retryConfig.retryDelay);\n await delay(retryDelay);\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":";;;;;;AAmBA,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;AAGD,MAAI,CAAC,QAAQ,WAAW,QAAQ,MAAM,UAAU;GAC9C,MAAM,SAAS,UAAU,QAAQ,KAAK,UAAoB,KAAK,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O,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"}
|
|
@@ -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, Page, 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, PerPage, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses };
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
5
|
* A single asset object
|
|
@@ -138,6 +138,10 @@ type SpaceId = number | string;
|
|
|
138
138
|
* Page number for pagination. Default is 1.
|
|
139
139
|
*/
|
|
140
140
|
type Page = number;
|
|
141
|
+
/**
|
|
142
|
+
* Number of items per page. Default is 25.
|
|
143
|
+
*/
|
|
144
|
+
type PerPage = number;
|
|
141
145
|
/**
|
|
142
146
|
* The ID of the asset (can be integer or string)
|
|
143
147
|
*/
|
|
@@ -156,7 +160,7 @@ type ListData = {
|
|
|
156
160
|
*/
|
|
157
161
|
page?: number;
|
|
158
162
|
/**
|
|
159
|
-
* Number of
|
|
163
|
+
* Number of items per page. Default is 25.
|
|
160
164
|
*/
|
|
161
165
|
per_page?: number;
|
|
162
166
|
/**
|
|
@@ -607,5 +611,5 @@ type ClientOptions = {
|
|
|
607
611
|
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 & {});
|
|
608
612
|
};
|
|
609
613
|
//#endregion
|
|
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 };
|
|
614
|
+
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, PerPage, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses, types_gen_d_exports };
|
|
611
615
|
//# 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, Page, 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, PerPage, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses };
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
5
|
* A single asset object
|
|
@@ -138,6 +138,10 @@ type SpaceId = number | string;
|
|
|
138
138
|
* Page number for pagination. Default is 1.
|
|
139
139
|
*/
|
|
140
140
|
type Page = number;
|
|
141
|
+
/**
|
|
142
|
+
* Number of items per page. Default is 25.
|
|
143
|
+
*/
|
|
144
|
+
type PerPage = number;
|
|
141
145
|
/**
|
|
142
146
|
* The ID of the asset (can be integer or string)
|
|
143
147
|
*/
|
|
@@ -156,7 +160,7 @@ type ListData = {
|
|
|
156
160
|
*/
|
|
157
161
|
page?: number;
|
|
158
162
|
/**
|
|
159
|
-
* Number of
|
|
163
|
+
* Number of items per page. Default is 25.
|
|
160
164
|
*/
|
|
161
165
|
per_page?: number;
|
|
162
166
|
/**
|
|
@@ -607,5 +611,5 @@ type ClientOptions = {
|
|
|
607
611
|
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 & {});
|
|
608
612
|
};
|
|
609
613
|
//#endregion
|
|
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 };
|
|
614
|
+
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, PerPage, SignedResponseObject, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, UploadData, UploadErrors, UploadResponse, UploadResponses, types_gen_d_exports };
|
|
611
615
|
//# 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 * 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
|
+
{"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 * Number of items per page. Default is 25.\n */\nexport type PerPage = 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 items per page. Default is 25.\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 * 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
|
+
{"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 * Number of items per page. Default is 25.\n */\nexport type PerPage = 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 items per page. Default is 25.\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,5 +1,5 @@
|
|
|
1
1
|
declare namespace types_gen_d_exports {
|
|
2
|
-
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses };
|
|
2
|
+
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, PerPage, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses };
|
|
3
3
|
}
|
|
4
4
|
type Component = Component2;
|
|
5
5
|
/**
|
|
@@ -353,6 +353,10 @@ type SpaceId = number | string;
|
|
|
353
353
|
* Page number for pagination. Default is 1.
|
|
354
354
|
*/
|
|
355
355
|
type Page = number;
|
|
356
|
+
/**
|
|
357
|
+
* Number of items per page. Default is 25.
|
|
358
|
+
*/
|
|
359
|
+
type PerPage = number;
|
|
356
360
|
/**
|
|
357
361
|
* The ID of the component (can be integer or string)
|
|
358
362
|
*/
|
|
@@ -371,7 +375,7 @@ type ListData = {
|
|
|
371
375
|
*/
|
|
372
376
|
page?: number;
|
|
373
377
|
/**
|
|
374
|
-
* Number of
|
|
378
|
+
* Number of items per page. Default is 25.
|
|
375
379
|
*/
|
|
376
380
|
per_page?: number;
|
|
377
381
|
/**
|
|
@@ -737,7 +741,7 @@ type VersionsData = {
|
|
|
737
741
|
*/
|
|
738
742
|
page?: number;
|
|
739
743
|
/**
|
|
740
|
-
* Number of
|
|
744
|
+
* Number of items per page. Default is 25.
|
|
741
745
|
*/
|
|
742
746
|
per_page?: number;
|
|
743
747
|
/**
|
|
@@ -877,5 +881,5 @@ type ClientOptions = {
|
|
|
877
881
|
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 & {});
|
|
878
882
|
};
|
|
879
883
|
//#endregion
|
|
880
|
-
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses, types_gen_d_exports };
|
|
884
|
+
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, PerPage, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses, types_gen_d_exports };
|
|
881
885
|
//# sourceMappingURL=types.gen.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace types_gen_d_exports {
|
|
2
|
-
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses };
|
|
2
|
+
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, PerPage, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses };
|
|
3
3
|
}
|
|
4
4
|
type Component = Component2;
|
|
5
5
|
/**
|
|
@@ -353,6 +353,10 @@ type SpaceId = number | string;
|
|
|
353
353
|
* Page number for pagination. Default is 1.
|
|
354
354
|
*/
|
|
355
355
|
type Page = number;
|
|
356
|
+
/**
|
|
357
|
+
* Number of items per page. Default is 25.
|
|
358
|
+
*/
|
|
359
|
+
type PerPage = number;
|
|
356
360
|
/**
|
|
357
361
|
* The ID of the component (can be integer or string)
|
|
358
362
|
*/
|
|
@@ -371,7 +375,7 @@ type ListData = {
|
|
|
371
375
|
*/
|
|
372
376
|
page?: number;
|
|
373
377
|
/**
|
|
374
|
-
* Number of
|
|
378
|
+
* Number of items per page. Default is 25.
|
|
375
379
|
*/
|
|
376
380
|
per_page?: number;
|
|
377
381
|
/**
|
|
@@ -737,7 +741,7 @@ type VersionsData = {
|
|
|
737
741
|
*/
|
|
738
742
|
page?: number;
|
|
739
743
|
/**
|
|
740
|
-
* Number of
|
|
744
|
+
* Number of items per page. Default is 25.
|
|
741
745
|
*/
|
|
742
746
|
per_page?: number;
|
|
743
747
|
/**
|
|
@@ -877,5 +881,5 @@ type ClientOptions = {
|
|
|
877
881
|
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 & {});
|
|
878
882
|
};
|
|
879
883
|
//#endregion
|
|
880
|
-
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses, types_gen_d_exports };
|
|
884
|
+
export { BulkMoveData, BulkMoveErrors, BulkMoveResponse, BulkMoveResponses, ClientOptions, Component, Component2, ComponentId, ComponentSchemaField, ComponentVersion, CreateData, CreateErrors, CreateResponse, CreateResponses, DeleteComponentData, DeleteComponentErrors, DeleteComponentResponse, DeleteComponentResponses, GetData, GetErrors, GetResponse, GetResponses, ListData, ListErrors, ListResponse, ListResponses, Page, PerPage, RenameAttributeData, RenameAttributeErrors, RenameAttributeResponse, RenameAttributeResponses, RestoreData, RestoreErrors, RestoreResponse, RestoreResponses, RestoreVersionData, RestoreVersionErrors, RestoreVersionResponse, RestoreVersionResponses, SpaceId, UpdateData, UpdateErrors, UpdateResponse, UpdateResponses, VersionData, VersionErrors, VersionResponse, VersionResponses, VersionsData, VersionsErrors, VersionsResponse, VersionsResponses, types_gen_d_exports };
|
|
881
885
|
//# sourceMappingURL=types.gen.d.ts.map
|