@storyblok/api-client 1.0.0-alpha.1 → 1.0.0-alpha.2
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 +3 -1
- package/dist/client.cjs +7 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +302 -68
- package/dist/client.d.mts +302 -68
- package/dist/client.mjs +7 -4
- package/dist/client.mjs.map +1 -1
- package/dist/generated/capi/_internal.gen.d.cts +120 -0
- package/dist/generated/capi/_internal.gen.d.mts +120 -0
- package/dist/generated/{shared → capi}/client/client.gen.cjs +1 -1
- package/dist/generated/capi/client/client.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/client/client.gen.mjs +1 -1
- package/dist/generated/capi/client/client.gen.mjs.map +1 -0
- package/dist/generated/{shared → capi}/client/types.gen.d.cts +1 -1
- package/dist/generated/{shared → capi}/client/types.gen.d.mts +1 -1
- package/dist/generated/{shared → capi}/client/utils.gen.cjs +1 -1
- package/dist/generated/capi/client/utils.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/client/utils.gen.d.cts +1 -1
- package/dist/generated/{shared → capi}/client/utils.gen.d.mts +1 -1
- package/dist/generated/{shared → capi}/client/utils.gen.mjs +1 -1
- package/dist/generated/capi/client/utils.gen.mjs.map +1 -0
- package/dist/generated/capi/client.gen.cjs +10 -0
- package/dist/generated/capi/client.gen.cjs.map +1 -0
- package/dist/generated/capi/client.gen.mjs +10 -0
- package/dist/generated/capi/client.gen.mjs.map +1 -0
- package/dist/generated/{shared → capi}/core/auth.gen.cjs +1 -1
- package/dist/generated/capi/core/auth.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/core/auth.gen.d.cts +1 -1
- package/dist/generated/{shared → capi}/core/auth.gen.d.mts +1 -1
- package/dist/generated/{shared → capi}/core/auth.gen.mjs +1 -1
- package/dist/generated/capi/core/auth.gen.mjs.map +1 -0
- package/dist/generated/{shared → capi}/core/bodySerializer.gen.cjs +1 -1
- package/dist/generated/capi/core/bodySerializer.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/core/bodySerializer.gen.d.cts +1 -1
- package/dist/generated/{shared → capi}/core/bodySerializer.gen.d.mts +1 -1
- package/dist/generated/{shared → capi}/core/bodySerializer.gen.mjs +1 -1
- package/dist/generated/capi/core/bodySerializer.gen.mjs.map +1 -0
- package/dist/generated/{shared → capi}/core/params.gen.cjs +1 -1
- package/dist/generated/capi/core/params.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/core/params.gen.mjs +1 -1
- package/dist/generated/capi/core/params.gen.mjs.map +1 -0
- package/dist/generated/{shared → capi}/core/pathSerializer.gen.cjs +1 -1
- package/dist/generated/capi/core/pathSerializer.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/core/pathSerializer.gen.d.cts +1 -1
- package/dist/generated/{shared → capi}/core/pathSerializer.gen.d.mts +1 -1
- package/dist/generated/{shared → capi}/core/pathSerializer.gen.mjs +1 -1
- package/dist/generated/capi/core/pathSerializer.gen.mjs.map +1 -0
- package/dist/generated/{shared → capi}/core/serverSentEvents.gen.cjs +1 -1
- package/dist/generated/capi/core/serverSentEvents.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/core/serverSentEvents.gen.d.cts +1 -1
- package/dist/generated/{shared → capi}/core/serverSentEvents.gen.d.mts +1 -1
- package/dist/generated/{shared → capi}/core/serverSentEvents.gen.mjs +1 -1
- package/dist/generated/capi/core/serverSentEvents.gen.mjs.map +1 -0
- package/dist/generated/{shared → capi}/core/types.gen.d.cts +1 -1
- package/dist/generated/{shared → capi}/core/types.gen.d.mts +1 -1
- package/dist/generated/{shared → capi}/core/utils.gen.cjs +1 -1
- package/dist/generated/capi/core/utils.gen.cjs.map +1 -0
- package/dist/generated/{shared → capi}/core/utils.gen.mjs +1 -1
- package/dist/generated/capi/core/utils.gen.mjs.map +1 -0
- package/dist/generated/capi/sdk.gen.cjs +141 -0
- package/dist/generated/capi/sdk.gen.cjs.map +1 -0
- package/dist/generated/capi/sdk.gen.mjs +133 -0
- package/dist/generated/capi/sdk.gen.mjs.map +1 -0
- package/dist/generated/capi/types-aliased.gen.d.cts +181 -0
- package/dist/generated/capi/types-aliased.gen.d.mts +181 -0
- package/dist/generated/capi/types.gen.d.cts +919 -0
- package/dist/generated/capi/types.gen.d.mts +919 -0
- package/dist/generated/mapi/_internal.gen.d.cts +146 -0
- package/dist/generated/mapi/_internal.gen.d.mts +146 -0
- package/dist/generated/mapi/types.gen.d.cts +293 -0
- package/dist/generated/mapi/types.gen.d.mts +293 -0
- package/dist/generated/overlay/_internal.gen.d.cts +831 -0
- package/dist/generated/overlay/_internal.gen.d.mts +831 -0
- package/dist/generated/types/_utils.d.cts +7 -0
- package/dist/generated/types/_utils.d.mts +7 -0
- package/dist/generated/types/block.d.cts +29 -0
- package/dist/generated/types/block.d.mts +29 -0
- package/dist/generated/types/field.d.cts +64 -0
- package/dist/generated/types/field.d.mts +64 -0
- package/dist/generated/types/story.d.cts +19 -0
- package/dist/generated/types/story.d.mts +19 -0
- package/dist/index.d.cts +6 -3
- package/dist/index.d.mts +6 -3
- package/dist/resources/datasource-entries.cjs +2 -2
- package/dist/resources/datasource-entries.cjs.map +1 -1
- package/dist/resources/datasource-entries.mjs +2 -2
- package/dist/resources/datasource-entries.mjs.map +1 -1
- package/dist/resources/datasources.cjs +4 -4
- package/dist/resources/datasources.cjs.map +1 -1
- package/dist/resources/datasources.mjs +4 -4
- package/dist/resources/datasources.mjs.map +1 -1
- package/dist/resources/experiments.cjs +26 -0
- package/dist/resources/experiments.cjs.map +1 -0
- package/dist/resources/experiments.mjs +26 -0
- package/dist/resources/experiments.mjs.map +1 -0
- package/dist/resources/links.cjs +2 -2
- package/dist/resources/links.cjs.map +1 -1
- package/dist/resources/links.mjs +2 -2
- package/dist/resources/links.mjs.map +1 -1
- package/dist/resources/spaces.cjs +4 -4
- package/dist/resources/spaces.cjs.map +1 -1
- package/dist/resources/spaces.mjs +4 -4
- package/dist/resources/spaces.mjs.map +1 -1
- package/dist/resources/stories.cjs +10 -8
- package/dist/resources/stories.cjs.map +1 -1
- package/dist/resources/stories.d.cts +16 -13
- package/dist/resources/stories.d.mts +16 -13
- package/dist/resources/stories.mjs +10 -8
- package/dist/resources/stories.mjs.map +1 -1
- package/dist/resources/tags.cjs +2 -2
- package/dist/resources/tags.cjs.map +1 -1
- package/dist/resources/tags.mjs +2 -2
- package/dist/resources/tags.mjs.map +1 -1
- package/dist/utils/fetch-rel-uuids.cjs +2 -2
- package/dist/utils/fetch-rel-uuids.cjs.map +1 -1
- package/dist/utils/fetch-rel-uuids.mjs +2 -2
- package/dist/utils/fetch-rel-uuids.mjs.map +1 -1
- package/dist/utils/inline-relations.cjs.map +1 -1
- package/dist/utils/inline-relations.mjs.map +1 -1
- package/package.json +13 -19
- package/dist/generated/datasource_entries/client.gen.cjs +0 -10
- package/dist/generated/datasource_entries/client.gen.cjs.map +0 -1
- package/dist/generated/datasource_entries/client.gen.mjs +0 -10
- package/dist/generated/datasource_entries/client.gen.mjs.map +0 -1
- package/dist/generated/datasource_entries/sdk.gen.cjs +0 -21
- package/dist/generated/datasource_entries/sdk.gen.cjs.map +0 -1
- package/dist/generated/datasource_entries/sdk.gen.mjs +0 -21
- package/dist/generated/datasource_entries/sdk.gen.mjs.map +0 -1
- package/dist/generated/datasource_entries/types.gen.d.cts +0 -52
- package/dist/generated/datasource_entries/types.gen.d.mts +0 -52
- package/dist/generated/datasources/client.gen.cjs +0 -10
- package/dist/generated/datasources/client.gen.cjs.map +0 -1
- package/dist/generated/datasources/client.gen.mjs +0 -10
- package/dist/generated/datasources/client.gen.mjs.map +0 -1
- package/dist/generated/datasources/sdk.gen.cjs +0 -36
- package/dist/generated/datasources/sdk.gen.cjs.map +0 -1
- package/dist/generated/datasources/sdk.gen.mjs +0 -35
- package/dist/generated/datasources/sdk.gen.mjs.map +0 -1
- package/dist/generated/datasources/types.gen.d.cts +0 -82
- package/dist/generated/datasources/types.gen.d.mts +0 -82
- package/dist/generated/links/client.gen.cjs +0 -10
- package/dist/generated/links/client.gen.cjs.map +0 -1
- package/dist/generated/links/client.gen.mjs +0 -10
- package/dist/generated/links/client.gen.mjs.map +0 -1
- package/dist/generated/links/sdk.gen.cjs +0 -21
- package/dist/generated/links/sdk.gen.cjs.map +0 -1
- package/dist/generated/links/sdk.gen.mjs +0 -21
- package/dist/generated/links/sdk.gen.mjs.map +0 -1
- package/dist/generated/links/types.gen.d.cts +0 -125
- package/dist/generated/links/types.gen.d.mts +0 -125
- package/dist/generated/shared/client/client.gen.cjs.map +0 -1
- package/dist/generated/shared/client/client.gen.mjs.map +0 -1
- package/dist/generated/shared/client/utils.gen.cjs.map +0 -1
- package/dist/generated/shared/client/utils.gen.mjs.map +0 -1
- package/dist/generated/shared/core/auth.gen.cjs.map +0 -1
- package/dist/generated/shared/core/auth.gen.mjs.map +0 -1
- package/dist/generated/shared/core/bodySerializer.gen.cjs.map +0 -1
- package/dist/generated/shared/core/bodySerializer.gen.mjs.map +0 -1
- package/dist/generated/shared/core/params.gen.cjs.map +0 -1
- package/dist/generated/shared/core/params.gen.mjs.map +0 -1
- package/dist/generated/shared/core/pathSerializer.gen.cjs.map +0 -1
- package/dist/generated/shared/core/pathSerializer.gen.mjs.map +0 -1
- package/dist/generated/shared/core/serverSentEvents.gen.cjs.map +0 -1
- package/dist/generated/shared/core/serverSentEvents.gen.mjs.map +0 -1
- package/dist/generated/shared/core/utils.gen.cjs.map +0 -1
- package/dist/generated/shared/core/utils.gen.mjs.map +0 -1
- package/dist/generated/spaces/client.gen.cjs +0 -10
- package/dist/generated/spaces/client.gen.cjs.map +0 -1
- package/dist/generated/spaces/client.gen.mjs +0 -10
- package/dist/generated/spaces/client.gen.mjs.map +0 -1
- package/dist/generated/spaces/sdk.gen.cjs +0 -21
- package/dist/generated/spaces/sdk.gen.cjs.map +0 -1
- package/dist/generated/spaces/sdk.gen.mjs +0 -21
- package/dist/generated/spaces/sdk.gen.mjs.map +0 -1
- package/dist/generated/spaces/types.gen.d.cts +0 -26
- package/dist/generated/spaces/types.gen.d.mts +0 -26
- package/dist/generated/stories/client.gen.cjs +0 -10
- package/dist/generated/stories/client.gen.cjs.map +0 -1
- package/dist/generated/stories/client.gen.mjs +0 -10
- package/dist/generated/stories/client.gen.mjs.map +0 -1
- package/dist/generated/stories/index.d.mts +0 -1
- package/dist/generated/stories/sdk.gen.cjs +0 -36
- package/dist/generated/stories/sdk.gen.cjs.map +0 -1
- package/dist/generated/stories/sdk.gen.d.mts +0 -1
- package/dist/generated/stories/sdk.gen.mjs +0 -35
- package/dist/generated/stories/sdk.gen.mjs.map +0 -1
- package/dist/generated/stories/types.gen.d.cts +0 -607
- package/dist/generated/stories/types.gen.d.mts +0 -607
- package/dist/generated/tags/client.gen.cjs +0 -10
- package/dist/generated/tags/client.gen.cjs.map +0 -1
- package/dist/generated/tags/client.gen.mjs +0 -10
- package/dist/generated/tags/client.gen.mjs.map +0 -1
- package/dist/generated/tags/sdk.gen.cjs +0 -21
- package/dist/generated/tags/sdk.gen.cjs.map +0 -1
- package/dist/generated/tags/sdk.gen.mjs +0 -21
- package/dist/generated/tags/sdk.gen.mjs.map +0 -1
- package/dist/generated/tags/types.gen.d.cts +0 -29
- package/dist/generated/tags/types.gen.d.mts +0 -29
- /package/dist/generated/{shared → capi}/client/client.gen.d.mts +0 -0
- /package/dist/generated/{shared → capi}/client/index.cjs +0 -0
- /package/dist/generated/{shared → capi}/client/index.d.mts +0 -0
- /package/dist/generated/{shared → capi}/client/index.mjs +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-relations.cjs","names":["fetchMissingRelations"],"sources":["../../src/utils/inline-relations.ts"],"sourcesContent":["import type { Client } from '../generated/
|
|
1
|
+
{"version":3,"file":"inline-relations.cjs","names":["fetchMissingRelations"],"sources":["../../src/utils/inline-relations.ts"],"sourcesContent":["import type { Client } from '../generated/capi/client';\nimport type { Story } from '../generated/types/story';\nimport type { StoryWithInlinedRelations } from '../resources/stories';\nimport { fetchMissingRelations } from './fetch-rel-uuids';\nimport type { ThrottleManager } from './rate-limit';\n\ntype RelationPath = `${string}.${string}`;\n\ninterface ComponentNode {\n _uid: string;\n component: string;\n [key: string]: unknown;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst isComponentNode = (value: Record<string, unknown>): value is ComponentNode =>\n typeof value.component === 'string' && typeof value._uid === 'string';\n\n/**\n * Decodes a string if it appears to be URL-encoded.\n * Detects common encoded characters (%2C for comma, %20 for space, etc.)\n */\nconst decodeIfEncoded = (value: string): string => {\n // Check if the string contains URL-encoded characters (% followed by hex digits)\n if (/%[0-9A-F]{2}/i.test(value)) {\n try {\n return decodeURIComponent(value);\n }\n catch {\n // If decoding fails (malformed encoding), return original\n return value;\n }\n }\n return value;\n};\n\nconst inlineStoryContentInternal = <TStory extends Story | StoryWithInlinedRelations>(\n story: TStory,\n relationPaths: ReadonlySet<RelationPath>,\n relationMap: ReadonlyMap<string, TStory>,\n resolved: Map<string, TStory>,\n): TStory => {\n const existingStory = resolved.get(story.uuid);\n if (existingStory) {\n return existingStory;\n }\n\n const clonedStory = structuredClone(story);\n resolved.set(story.uuid, clonedStory);\n // resolveNode returns `unknown` to handle arbitrary JSON trees; shape is preserved at runtime.\n clonedStory.content = resolveNode(clonedStory.content, relationMap, relationPaths, resolved) as Story['content'];\n return clonedStory;\n};\n\nfunction resolveNode<TStory extends Story | StoryWithInlinedRelations>(\n value: unknown,\n relationMap: ReadonlyMap<string, TStory>,\n relationPaths: ReadonlySet<RelationPath>,\n resolved: Map<string, TStory>,\n): unknown {\n if (Array.isArray(value)) {\n return value.map(item => resolveNode(item, relationMap, relationPaths, resolved));\n }\n\n if (!isRecord(value)) {\n return value;\n }\n\n if (isComponentNode(value)) {\n for (const [fieldName, fieldValue] of Object.entries(value)) {\n if (fieldName === 'component' || fieldName === '_uid') {\n continue;\n }\n\n const relationPath: RelationPath = `${value.component}.${fieldName}`;\n value[fieldName] = relationPaths.has(relationPath)\n ? resolveFieldValue(fieldValue, relationMap, relationPaths, resolved)\n : resolveNode(fieldValue, relationMap, relationPaths, resolved);\n }\n\n return value;\n }\n\n for (const [fieldName, fieldValue] of Object.entries(value)) {\n value[fieldName] = resolveNode(fieldValue, relationMap, relationPaths, resolved);\n }\n\n return value;\n}\n\nexport const parseResolveRelations = (query: Record<string, unknown>): RelationPath[] => {\n if (typeof query.resolve_relations !== 'string') {\n return [];\n }\n\n // Decode URL-encoded strings to handle pre-encoded input\n const resolveRelations = decodeIfEncoded(query.resolve_relations);\n\n return resolveRelations\n .split(',')\n .map(path => path.trim())\n .filter((path): path is RelationPath => {\n const [component = '', field = '', ...rest] = path.split('.');\n return component.length > 0 && field.length > 0 && rest.length === 0;\n });\n};\n\nexport const buildRelationMap = (rels: Array<Story> | undefined): Map<string, Story> => {\n const relationMap = new Map<string, Story>();\n\n for (const story of rels ?? []) {\n relationMap.set(story.uuid, story);\n }\n\n return relationMap;\n};\n\nfunction resolveFieldValue<TStory extends Story | StoryWithInlinedRelations>(\n value: unknown,\n relationMap: ReadonlyMap<string, TStory>,\n relationPaths: ReadonlySet<RelationPath>,\n resolved: Map<string, TStory>,\n): unknown {\n if (typeof value === 'string') {\n const relatedStory = relationMap.get(value);\n if (!relatedStory) {\n return value;\n }\n\n return inlineStoryContentInternal(relatedStory, relationPaths, relationMap, resolved);\n }\n\n if (Array.isArray(value)) {\n return value.map(item => resolveFieldValue(item, relationMap, relationPaths, resolved));\n }\n\n return resolveNode(value, relationMap, relationPaths, resolved);\n}\n\nexport const inlineStoryContent = <TStory extends Story | StoryWithInlinedRelations>(\n story: TStory,\n relationPaths: RelationPath[],\n relationMap: ReadonlyMap<string, TStory>,\n): TStory => {\n const normalizedPaths = new Set(relationPaths);\n const resolved = new Map<string, TStory>();\n return inlineStoryContentInternal(story, normalizedPaths, relationMap, resolved);\n};\n\nexport const inlineStoriesContent = <TStory extends Story | StoryWithInlinedRelations>(\n stories: Array<TStory>,\n relationPaths: RelationPath[],\n relationMap: ReadonlyMap<string, TStory>,\n): Array<TStory> => {\n const normalizedPaths = new Set(relationPaths);\n const resolved = new Map<string, TStory>();\n return stories.map(story => inlineStoryContentInternal(story, normalizedPaths, relationMap, resolved));\n};\n\ninterface ResolveRelationMapOptions {\n client: Client;\n throttleManager: ThrottleManager;\n}\n\nexport interface ResolvedRelations {\n relationPaths: RelationPath[];\n relationMap: Map<string, Story>;\n}\n\n/**\n * Parses relation paths from the request query, builds a relation map from the\n * response's `rels`, and fetches any additional relations referenced by `rel_uuids`.\n *\n * Returns `null` when there is nothing to inline (no `resolve_relations` in the query).\n */\nexport const resolveRelationMap = async (\n responseData: { rels?: Story[]; rel_uuids?: string[] },\n requestQuery: Record<string, unknown>,\n { client, throttleManager }: ResolveRelationMapOptions,\n): Promise<ResolvedRelations | null> => {\n const relationPaths = parseResolveRelations(requestQuery);\n if (relationPaths.length === 0) {\n return null;\n }\n\n const relationMap = buildRelationMap(responseData.rels);\n if (responseData.rel_uuids?.length) {\n const missingUuids = responseData.rel_uuids.filter(uuid => !relationMap.has(uuid));\n if (missingUuids.length > 0) {\n const fetchedRelations = await fetchMissingRelations({\n client,\n uuids: missingUuids,\n baseQuery: requestQuery,\n throttleManager,\n });\n for (const relationStory of fetchedRelations) {\n relationMap.set(relationStory.uuid, relationStory);\n }\n }\n }\n\n return { relationPaths, relationMap };\n};\n"],"mappings":";;;AAcA,MAAM,YAAY,UAChB,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM;AAEtE,MAAM,mBAAmB,UACvB,OAAO,MAAM,cAAc,YAAY,OAAO,MAAM,SAAS;;;;;AAM/D,MAAM,mBAAmB,UAA0B;AAEjD,KAAI,gBAAgB,KAAK,MAAM,CAC7B,KAAI;AACF,SAAO,mBAAmB,MAAM;SAE5B;AAEJ,SAAO;;AAGX,QAAO;;AAGT,MAAM,8BACJ,OACA,eACA,aACA,aACW;CACX,MA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["../../src/utils/inline-relations.ts"],"sourcesContent":["import type { Client } from '../generated/
|
|
1
|
+
{"version":3,"file":"inline-relations.mjs","names":[],"sources":["../../src/utils/inline-relations.ts"],"sourcesContent":["import type { Client } from '../generated/capi/client';\nimport type { Story } from '../generated/types/story';\nimport type { StoryWithInlinedRelations } from '../resources/stories';\nimport { fetchMissingRelations } from './fetch-rel-uuids';\nimport type { ThrottleManager } from './rate-limit';\n\ntype RelationPath = `${string}.${string}`;\n\ninterface ComponentNode {\n _uid: string;\n component: string;\n [key: string]: unknown;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst isComponentNode = (value: Record<string, unknown>): value is ComponentNode =>\n typeof value.component === 'string' && typeof value._uid === 'string';\n\n/**\n * Decodes a string if it appears to be URL-encoded.\n * Detects common encoded characters (%2C for comma, %20 for space, etc.)\n */\nconst decodeIfEncoded = (value: string): string => {\n // Check if the string contains URL-encoded characters (% followed by hex digits)\n if (/%[0-9A-F]{2}/i.test(value)) {\n try {\n return decodeURIComponent(value);\n }\n catch {\n // If decoding fails (malformed encoding), return original\n return value;\n }\n }\n return value;\n};\n\nconst inlineStoryContentInternal = <TStory extends Story | StoryWithInlinedRelations>(\n story: TStory,\n relationPaths: ReadonlySet<RelationPath>,\n relationMap: ReadonlyMap<string, TStory>,\n resolved: Map<string, TStory>,\n): TStory => {\n const existingStory = resolved.get(story.uuid);\n if (existingStory) {\n return existingStory;\n }\n\n const clonedStory = structuredClone(story);\n resolved.set(story.uuid, clonedStory);\n // resolveNode returns `unknown` to handle arbitrary JSON trees; shape is preserved at runtime.\n clonedStory.content = resolveNode(clonedStory.content, relationMap, relationPaths, resolved) as Story['content'];\n return clonedStory;\n};\n\nfunction resolveNode<TStory extends Story | StoryWithInlinedRelations>(\n value: unknown,\n relationMap: ReadonlyMap<string, TStory>,\n relationPaths: ReadonlySet<RelationPath>,\n resolved: Map<string, TStory>,\n): unknown {\n if (Array.isArray(value)) {\n return value.map(item => resolveNode(item, relationMap, relationPaths, resolved));\n }\n\n if (!isRecord(value)) {\n return value;\n }\n\n if (isComponentNode(value)) {\n for (const [fieldName, fieldValue] of Object.entries(value)) {\n if (fieldName === 'component' || fieldName === '_uid') {\n continue;\n }\n\n const relationPath: RelationPath = `${value.component}.${fieldName}`;\n value[fieldName] = relationPaths.has(relationPath)\n ? resolveFieldValue(fieldValue, relationMap, relationPaths, resolved)\n : resolveNode(fieldValue, relationMap, relationPaths, resolved);\n }\n\n return value;\n }\n\n for (const [fieldName, fieldValue] of Object.entries(value)) {\n value[fieldName] = resolveNode(fieldValue, relationMap, relationPaths, resolved);\n }\n\n return value;\n}\n\nexport const parseResolveRelations = (query: Record<string, unknown>): RelationPath[] => {\n if (typeof query.resolve_relations !== 'string') {\n return [];\n }\n\n // Decode URL-encoded strings to handle pre-encoded input\n const resolveRelations = decodeIfEncoded(query.resolve_relations);\n\n return resolveRelations\n .split(',')\n .map(path => path.trim())\n .filter((path): path is RelationPath => {\n const [component = '', field = '', ...rest] = path.split('.');\n return component.length > 0 && field.length > 0 && rest.length === 0;\n });\n};\n\nexport const buildRelationMap = (rels: Array<Story> | undefined): Map<string, Story> => {\n const relationMap = new Map<string, Story>();\n\n for (const story of rels ?? []) {\n relationMap.set(story.uuid, story);\n }\n\n return relationMap;\n};\n\nfunction resolveFieldValue<TStory extends Story | StoryWithInlinedRelations>(\n value: unknown,\n relationMap: ReadonlyMap<string, TStory>,\n relationPaths: ReadonlySet<RelationPath>,\n resolved: Map<string, TStory>,\n): unknown {\n if (typeof value === 'string') {\n const relatedStory = relationMap.get(value);\n if (!relatedStory) {\n return value;\n }\n\n return inlineStoryContentInternal(relatedStory, relationPaths, relationMap, resolved);\n }\n\n if (Array.isArray(value)) {\n return value.map(item => resolveFieldValue(item, relationMap, relationPaths, resolved));\n }\n\n return resolveNode(value, relationMap, relationPaths, resolved);\n}\n\nexport const inlineStoryContent = <TStory extends Story | StoryWithInlinedRelations>(\n story: TStory,\n relationPaths: RelationPath[],\n relationMap: ReadonlyMap<string, TStory>,\n): TStory => {\n const normalizedPaths = new Set(relationPaths);\n const resolved = new Map<string, TStory>();\n return inlineStoryContentInternal(story, normalizedPaths, relationMap, resolved);\n};\n\nexport const inlineStoriesContent = <TStory extends Story | StoryWithInlinedRelations>(\n stories: Array<TStory>,\n relationPaths: RelationPath[],\n relationMap: ReadonlyMap<string, TStory>,\n): Array<TStory> => {\n const normalizedPaths = new Set(relationPaths);\n const resolved = new Map<string, TStory>();\n return stories.map(story => inlineStoryContentInternal(story, normalizedPaths, relationMap, resolved));\n};\n\ninterface ResolveRelationMapOptions {\n client: Client;\n throttleManager: ThrottleManager;\n}\n\nexport interface ResolvedRelations {\n relationPaths: RelationPath[];\n relationMap: Map<string, Story>;\n}\n\n/**\n * Parses relation paths from the request query, builds a relation map from the\n * response's `rels`, and fetches any additional relations referenced by `rel_uuids`.\n *\n * Returns `null` when there is nothing to inline (no `resolve_relations` in the query).\n */\nexport const resolveRelationMap = async (\n responseData: { rels?: Story[]; rel_uuids?: string[] },\n requestQuery: Record<string, unknown>,\n { client, throttleManager }: ResolveRelationMapOptions,\n): Promise<ResolvedRelations | null> => {\n const relationPaths = parseResolveRelations(requestQuery);\n if (relationPaths.length === 0) {\n return null;\n }\n\n const relationMap = buildRelationMap(responseData.rels);\n if (responseData.rel_uuids?.length) {\n const missingUuids = responseData.rel_uuids.filter(uuid => !relationMap.has(uuid));\n if (missingUuids.length > 0) {\n const fetchedRelations = await fetchMissingRelations({\n client,\n uuids: missingUuids,\n baseQuery: requestQuery,\n throttleManager,\n });\n for (const relationStory of fetchedRelations) {\n relationMap.set(relationStory.uuid, relationStory);\n }\n }\n }\n\n return { relationPaths, relationMap };\n};\n"],"mappings":";;;AAcA,MAAM,YAAY,UAChB,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM;AAEtE,MAAM,mBAAmB,UACvB,OAAO,MAAM,cAAc,YAAY,OAAO,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AO;IACP,WAAW;IACX;IACD,CAAC;AACF,QAAK,MAAM,iBAAiB,iBAC1B,aAAY,IAAI,cAAc,MAAM,cAAc;;;AAKxD,QAAO;EAAE;EAAe;EAAa"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/api-client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Storyblok Content Delivery API Client",
|
|
7
7
|
"author": "",
|
|
@@ -31,43 +31,38 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"ky": "^1.14.3",
|
|
34
|
-
"@storyblok/region-helper": "1.4.
|
|
35
|
-
"@storyblok/schema": "1.0.0-alpha.0"
|
|
34
|
+
"@storyblok/region-helper": "1.4.1"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@hey-api/openapi-ts": "^0.92.3",
|
|
39
|
-
"@msw/source": "^0.6.1",
|
|
40
37
|
"@types/node": "^24.11.0",
|
|
41
|
-
"dotenv": "^17.3.1",
|
|
42
38
|
"eslint": "^9.39.2",
|
|
43
|
-
"glob": "^13.0.6",
|
|
44
39
|
"msw": "^2.12.9",
|
|
45
40
|
"pathe": "^2.0.3",
|
|
46
41
|
"tsdown": "^0.20.3",
|
|
47
42
|
"tsx": "^4.21.0",
|
|
48
43
|
"vitest": "^4.1.3",
|
|
49
|
-
"@storyblok/
|
|
50
|
-
"@storyblok/
|
|
51
|
-
"@storyblok/openapi": "
|
|
44
|
+
"@storyblok/management-api-client": "1.0.0-alpha.2",
|
|
45
|
+
"@storyblok/eslint-config": "0.5.1",
|
|
46
|
+
"@storyblok/openapi-codegen": "0.0.1"
|
|
52
47
|
},
|
|
53
48
|
"nx": {
|
|
54
49
|
"targets": {
|
|
55
50
|
"generate": {
|
|
56
|
-
"
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
],
|
|
61
|
-
"target": "build"
|
|
62
|
-
}
|
|
51
|
+
"inputs": [
|
|
52
|
+
"{projectRoot}/scripts/generate.ts",
|
|
53
|
+
"{projectRoot}/package.json",
|
|
54
|
+
"openapiCodegen"
|
|
63
55
|
],
|
|
64
56
|
"outputs": [
|
|
65
57
|
"{projectRoot}/src/generated/**"
|
|
58
|
+
],
|
|
59
|
+
"cache": true,
|
|
60
|
+
"dependsOn": [
|
|
61
|
+
"@storyblok/openapi-codegen:build"
|
|
66
62
|
]
|
|
67
63
|
},
|
|
68
64
|
"build": {
|
|
69
65
|
"dependsOn": [
|
|
70
|
-
"generate",
|
|
71
66
|
"^build"
|
|
72
67
|
],
|
|
73
68
|
"outputs": [
|
|
@@ -81,7 +76,6 @@
|
|
|
81
76
|
"build": "tsdown",
|
|
82
77
|
"test": "vitest run",
|
|
83
78
|
"test:types": "tsc --noEmit --skipLibCheck",
|
|
84
|
-
"test:e2e": "vitest run -c vitest.config.e2e.ts",
|
|
85
79
|
"coverage": "vitest run --coverage",
|
|
86
80
|
"lint": "eslint .",
|
|
87
81
|
"lint:fix": "eslint . --fix"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const require_utils_gen = require('../shared/client/utils.gen.cjs');
|
|
2
|
-
const require_client_gen = require('../shared/client/client.gen.cjs');
|
|
3
|
-
require('../shared/client/index.cjs');
|
|
4
|
-
|
|
5
|
-
//#region src/generated/datasource_entries/client.gen.ts
|
|
6
|
-
const client = require_client_gen.createClient(require_utils_gen.createConfig({ baseUrl: "https://api.storyblok.com" }));
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
exports.client = client;
|
|
10
|
-
//# sourceMappingURL=client.gen.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.gen.cjs","names":["createClient","createConfig"],"sources":["../../../src/generated/datasource_entries/client.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport { type ClientOptions, type Config, createClient, createConfig } from '../shared/client';\nimport type { ClientOptions as ClientOptions2 } from './types.gen';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;\n\nexport const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'https://api.storyblok.com' }));\n"],"mappings":";;;;;AAeA,MAAa,SAASA,gCAAaC,+BAA6B,EAAE,SAAS,6BAA6B,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createConfig } from "../shared/client/utils.gen.mjs";
|
|
2
|
-
import { createClient } from "../shared/client/client.gen.mjs";
|
|
3
|
-
import "../shared/client/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/generated/datasource_entries/client.gen.ts
|
|
6
|
-
const client = createClient(createConfig({ baseUrl: "https://api.storyblok.com" }));
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { client };
|
|
10
|
-
//# sourceMappingURL=client.gen.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.gen.mjs","names":[],"sources":["../../../src/generated/datasource_entries/client.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport { type ClientOptions, type Config, createClient, createConfig } from '../shared/client';\nimport type { ClientOptions as ClientOptions2 } from './types.gen';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;\n\nexport const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'https://api.storyblok.com' }));\n"],"mappings":";;;;;AAeA,MAAa,SAAS,aAAa,aAA6B,EAAE,SAAS,6BAA6B,CAAC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const require_client_gen = require('./client.gen.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/generated/datasource_entries/sdk.gen.ts
|
|
4
|
-
/**
|
|
5
|
-
* Retrieve Multiple Datasource Entries
|
|
6
|
-
*
|
|
7
|
-
* Returns an array of all datasource entries. The API response can be filtered using the query parameters.
|
|
8
|
-
*/
|
|
9
|
-
const list = (options) => (options?.client ?? require_client_gen.client).get({
|
|
10
|
-
security: [{
|
|
11
|
-
in: "query",
|
|
12
|
-
name: "token",
|
|
13
|
-
type: "apiKey"
|
|
14
|
-
}],
|
|
15
|
-
url: "/v2/cdn/datasource_entries",
|
|
16
|
-
...options
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.list = list;
|
|
21
|
-
//# sourceMappingURL=sdk.gen.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.gen.cjs","names":["client"],"sources":["../../../src/generated/datasource_entries/sdk.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { Client, Options as Options2, TDataShape } from '../shared/client';\nimport { client } from './client.gen';\nimport type { ListData, ListErrors, ListResponses } from './types.gen';\n\nexport type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Retrieve Multiple Datasource Entries\n *\n * Returns an array of all datasource entries. The API response can be filtered using the query parameters.\n */\nexport const list = <ThrowOnError extends boolean = false>(options?: Options<ListData, ThrowOnError>) => (options?.client ?? client).get<ListResponses, ListErrors, ThrowOnError>({\n security: [{\n in: 'query',\n name: 'token',\n type: 'apiKey'\n }],\n url: '/v2/cdn/datasource_entries',\n ...options\n});\n"],"mappings":";;;;;;;;AAyBA,MAAa,QAA8C,aAA+C,SAAS,UAAUA,2BAAQ,IAA6C;CAC9K,UAAU,CAAC;EACH,IAAI;EACJ,MAAM;EACN,MAAM;EACT,CAAC;CACN,KAAK;CACL,GAAG;CACN,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { client } from "./client.gen.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/generated/datasource_entries/sdk.gen.ts
|
|
4
|
-
/**
|
|
5
|
-
* Retrieve Multiple Datasource Entries
|
|
6
|
-
*
|
|
7
|
-
* Returns an array of all datasource entries. The API response can be filtered using the query parameters.
|
|
8
|
-
*/
|
|
9
|
-
const list = (options) => (options?.client ?? client).get({
|
|
10
|
-
security: [{
|
|
11
|
-
in: "query",
|
|
12
|
-
name: "token",
|
|
13
|
-
type: "apiKey"
|
|
14
|
-
}],
|
|
15
|
-
url: "/v2/cdn/datasource_entries",
|
|
16
|
-
...options
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { list };
|
|
21
|
-
//# sourceMappingURL=sdk.gen.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.gen.mjs","names":[],"sources":["../../../src/generated/datasource_entries/sdk.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { Client, Options as Options2, TDataShape } from '../shared/client';\nimport { client } from './client.gen';\nimport type { ListData, ListErrors, ListResponses } from './types.gen';\n\nexport type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Retrieve Multiple Datasource Entries\n *\n * Returns an array of all datasource entries. The API response can be filtered using the query parameters.\n */\nexport const list = <ThrowOnError extends boolean = false>(options?: Options<ListData, ThrowOnError>) => (options?.client ?? client).get<ListResponses, ListErrors, ThrowOnError>({\n security: [{\n in: 'query',\n name: 'token',\n type: 'apiKey'\n }],\n url: '/v2/cdn/datasource_entries',\n ...options\n});\n"],"mappings":";;;;;;;;AAyBA,MAAa,QAA8C,aAA+C,SAAS,UAAU,QAAQ,IAA6C;CAC9K,UAAU,CAAC;EACH,IAAI;EACJ,MAAM;EACN,MAAM;EACT,CAAC;CACN,KAAK;CACL,GAAG;CACN,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
//#region src/generated/datasource_entries/types.gen.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Storyblok datasource entry object for the Content Delivery API
|
|
4
|
-
*/
|
|
5
|
-
type DatasourceEntryCapi = {
|
|
6
|
-
/**
|
|
7
|
-
* Unique identifier of the datasource entry
|
|
8
|
-
*/
|
|
9
|
-
id: number;
|
|
10
|
-
/**
|
|
11
|
-
* Display name of the datasource entry
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* Value of the datasource entry
|
|
16
|
-
*/
|
|
17
|
-
value: string;
|
|
18
|
-
/**
|
|
19
|
-
* Dimension value of the datasource entry (null if no dimension is specified)
|
|
20
|
-
*/
|
|
21
|
-
dimension_value?: string | null;
|
|
22
|
-
};
|
|
23
|
-
type ListData = {
|
|
24
|
-
body?: never;
|
|
25
|
-
path?: never;
|
|
26
|
-
query?: {
|
|
27
|
-
/**
|
|
28
|
-
* Slug of the datasource to filter by
|
|
29
|
-
*/
|
|
30
|
-
datasource?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Datasource dimension
|
|
33
|
-
*/
|
|
34
|
-
dimension?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Page number for pagination
|
|
37
|
-
*/
|
|
38
|
-
page?: number;
|
|
39
|
-
/**
|
|
40
|
-
* Number of entries per page (default 25, max 1000)
|
|
41
|
-
*/
|
|
42
|
-
per_page?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Cached version Unix timestamp for cache invalidation
|
|
45
|
-
*/
|
|
46
|
-
cv?: number;
|
|
47
|
-
};
|
|
48
|
-
url: '/v2/cdn/datasource_entries';
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
51
|
-
export { DatasourceEntryCapi, ListData };
|
|
52
|
-
//# sourceMappingURL=types.gen.d.cts.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
//#region src/generated/datasource_entries/types.gen.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Storyblok datasource entry object for the Content Delivery API
|
|
4
|
-
*/
|
|
5
|
-
type DatasourceEntryCapi = {
|
|
6
|
-
/**
|
|
7
|
-
* Unique identifier of the datasource entry
|
|
8
|
-
*/
|
|
9
|
-
id: number;
|
|
10
|
-
/**
|
|
11
|
-
* Display name of the datasource entry
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* Value of the datasource entry
|
|
16
|
-
*/
|
|
17
|
-
value: string;
|
|
18
|
-
/**
|
|
19
|
-
* Dimension value of the datasource entry (null if no dimension is specified)
|
|
20
|
-
*/
|
|
21
|
-
dimension_value?: string | null;
|
|
22
|
-
};
|
|
23
|
-
type ListData = {
|
|
24
|
-
body?: never;
|
|
25
|
-
path?: never;
|
|
26
|
-
query?: {
|
|
27
|
-
/**
|
|
28
|
-
* Slug of the datasource to filter by
|
|
29
|
-
*/
|
|
30
|
-
datasource?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Datasource dimension
|
|
33
|
-
*/
|
|
34
|
-
dimension?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Page number for pagination
|
|
37
|
-
*/
|
|
38
|
-
page?: number;
|
|
39
|
-
/**
|
|
40
|
-
* Number of entries per page (default 25, max 1000)
|
|
41
|
-
*/
|
|
42
|
-
per_page?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Cached version Unix timestamp for cache invalidation
|
|
45
|
-
*/
|
|
46
|
-
cv?: number;
|
|
47
|
-
};
|
|
48
|
-
url: '/v2/cdn/datasource_entries';
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
51
|
-
export { DatasourceEntryCapi, ListData };
|
|
52
|
-
//# sourceMappingURL=types.gen.d.mts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const require_utils_gen = require('../shared/client/utils.gen.cjs');
|
|
2
|
-
const require_client_gen = require('../shared/client/client.gen.cjs');
|
|
3
|
-
require('../shared/client/index.cjs');
|
|
4
|
-
|
|
5
|
-
//#region src/generated/datasources/client.gen.ts
|
|
6
|
-
const client = require_client_gen.createClient(require_utils_gen.createConfig({ baseUrl: "https://api.storyblok.com" }));
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
exports.client = client;
|
|
10
|
-
//# sourceMappingURL=client.gen.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.gen.cjs","names":["createClient","createConfig"],"sources":["../../../src/generated/datasources/client.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport { type ClientOptions, type Config, createClient, createConfig } from '../shared/client';\nimport type { ClientOptions as ClientOptions2 } from './types.gen';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;\n\nexport const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'https://api.storyblok.com' }));\n"],"mappings":";;;;;AAeA,MAAa,SAASA,gCAAaC,+BAA6B,EAAE,SAAS,6BAA6B,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createConfig } from "../shared/client/utils.gen.mjs";
|
|
2
|
-
import { createClient } from "../shared/client/client.gen.mjs";
|
|
3
|
-
import "../shared/client/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/generated/datasources/client.gen.ts
|
|
6
|
-
const client = createClient(createConfig({ baseUrl: "https://api.storyblok.com" }));
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { client };
|
|
10
|
-
//# sourceMappingURL=client.gen.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.gen.mjs","names":[],"sources":["../../../src/generated/datasources/client.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport { type ClientOptions, type Config, createClient, createConfig } from '../shared/client';\nimport type { ClientOptions as ClientOptions2 } from './types.gen';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;\n\nexport const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'https://api.storyblok.com' }));\n"],"mappings":";;;;;AAeA,MAAa,SAAS,aAAa,aAA6B,EAAE,SAAS,6BAA6B,CAAC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const require_client_gen = require('./client.gen.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/generated/datasources/sdk.gen.ts
|
|
4
|
-
/**
|
|
5
|
-
* Retrieve Multiple Datasources
|
|
6
|
-
*
|
|
7
|
-
* Returns an array of all datasources with pagination support.
|
|
8
|
-
*/
|
|
9
|
-
const list = (options) => (options?.client ?? require_client_gen.client).get({
|
|
10
|
-
security: [{
|
|
11
|
-
in: "query",
|
|
12
|
-
name: "token",
|
|
13
|
-
type: "apiKey"
|
|
14
|
-
}],
|
|
15
|
-
url: "/v2/cdn/datasources",
|
|
16
|
-
...options
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve One Datasource
|
|
20
|
-
*
|
|
21
|
-
* Returns a single datasource object for the specified ID
|
|
22
|
-
*/
|
|
23
|
-
const get = (options) => (options.client ?? require_client_gen.client).get({
|
|
24
|
-
security: [{
|
|
25
|
-
in: "query",
|
|
26
|
-
name: "token",
|
|
27
|
-
type: "apiKey"
|
|
28
|
-
}],
|
|
29
|
-
url: "/v2/cdn/datasources/{id}",
|
|
30
|
-
...options
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
exports.get = get;
|
|
35
|
-
exports.list = list;
|
|
36
|
-
//# sourceMappingURL=sdk.gen.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.gen.cjs","names":["client"],"sources":["../../../src/generated/datasources/sdk.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { Client, Options as Options2, TDataShape } from '../shared/client';\nimport { client } from './client.gen';\nimport type { GetData, GetErrors, GetResponses, ListData, ListErrors, ListResponses } from './types.gen';\n\nexport type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Retrieve Multiple Datasources\n *\n * Returns an array of all datasources with pagination support.\n */\nexport const list = <ThrowOnError extends boolean = false>(options?: Options<ListData, ThrowOnError>) => (options?.client ?? client).get<ListResponses, ListErrors, ThrowOnError>({\n security: [{\n in: 'query',\n name: 'token',\n type: 'apiKey'\n }],\n url: '/v2/cdn/datasources',\n ...options\n});\n\n/**\n * Retrieve One Datasource\n *\n * Returns a single datasource object for the specified ID\n */\nexport const get = <ThrowOnError extends boolean = false>(options: Options<GetData, ThrowOnError>) => (options.client ?? client).get<GetResponses, GetErrors, ThrowOnError>({\n security: [{\n in: 'query',\n name: 'token',\n type: 'apiKey'\n }],\n url: '/v2/cdn/datasources/{id}',\n ...options\n});\n"],"mappings":";;;;;;;;AAyBA,MAAa,QAA8C,aAA+C,SAAS,UAAUA,2BAAQ,IAA6C;CAC9K,UAAU,CAAC;EACH,IAAI;EACJ,MAAM;EACN,MAAM;EACT,CAAC;CACN,KAAK;CACL,GAAG;CACN,CAAC;;;;;;AAOF,MAAa,OAA6C,aAA6C,QAAQ,UAAUA,2BAAQ,IAA2C;CACxK,UAAU,CAAC;EACH,IAAI;EACJ,MAAM;EACN,MAAM;EACT,CAAC;CACN,KAAK;CACL,GAAG;CACN,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { client } from "./client.gen.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/generated/datasources/sdk.gen.ts
|
|
4
|
-
/**
|
|
5
|
-
* Retrieve Multiple Datasources
|
|
6
|
-
*
|
|
7
|
-
* Returns an array of all datasources with pagination support.
|
|
8
|
-
*/
|
|
9
|
-
const list = (options) => (options?.client ?? client).get({
|
|
10
|
-
security: [{
|
|
11
|
-
in: "query",
|
|
12
|
-
name: "token",
|
|
13
|
-
type: "apiKey"
|
|
14
|
-
}],
|
|
15
|
-
url: "/v2/cdn/datasources",
|
|
16
|
-
...options
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve One Datasource
|
|
20
|
-
*
|
|
21
|
-
* Returns a single datasource object for the specified ID
|
|
22
|
-
*/
|
|
23
|
-
const get = (options) => (options.client ?? client).get({
|
|
24
|
-
security: [{
|
|
25
|
-
in: "query",
|
|
26
|
-
name: "token",
|
|
27
|
-
type: "apiKey"
|
|
28
|
-
}],
|
|
29
|
-
url: "/v2/cdn/datasources/{id}",
|
|
30
|
-
...options
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
export { get, list };
|
|
35
|
-
//# sourceMappingURL=sdk.gen.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.gen.mjs","names":[],"sources":["../../../src/generated/datasources/sdk.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { Client, Options as Options2, TDataShape } from '../shared/client';\nimport { client } from './client.gen';\nimport type { GetData, GetErrors, GetResponses, ListData, ListErrors, ListResponses } from './types.gen';\n\nexport type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Retrieve Multiple Datasources\n *\n * Returns an array of all datasources with pagination support.\n */\nexport const list = <ThrowOnError extends boolean = false>(options?: Options<ListData, ThrowOnError>) => (options?.client ?? client).get<ListResponses, ListErrors, ThrowOnError>({\n security: [{\n in: 'query',\n name: 'token',\n type: 'apiKey'\n }],\n url: '/v2/cdn/datasources',\n ...options\n});\n\n/**\n * Retrieve One Datasource\n *\n * Returns a single datasource object for the specified ID\n */\nexport const get = <ThrowOnError extends boolean = false>(options: Options<GetData, ThrowOnError>) => (options.client ?? client).get<GetResponses, GetErrors, ThrowOnError>({\n security: [{\n in: 'query',\n name: 'token',\n type: 'apiKey'\n }],\n url: '/v2/cdn/datasources/{id}',\n ...options\n});\n"],"mappings":";;;;;;;;AAyBA,MAAa,QAA8C,aAA+C,SAAS,UAAU,QAAQ,IAA6C;CAC9K,UAAU,CAAC;EACH,IAAI;EACJ,MAAM;EACN,MAAM;EACT,CAAC;CACN,KAAK;CACL,GAAG;CACN,CAAC;;;;;;AAOF,MAAa,OAA6C,aAA6C,QAAQ,UAAU,QAAQ,IAA2C;CACxK,UAAU,CAAC;EACH,IAAI;EACJ,MAAM;EACN,MAAM;EACT,CAAC;CACN,KAAK;CACL,GAAG;CACN,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//#region src/generated/datasources/types.gen.d.ts
|
|
2
|
-
type DatasourceCapi = {
|
|
3
|
-
/**
|
|
4
|
-
* Unique identifier for the datasource
|
|
5
|
-
*/
|
|
6
|
-
id: number;
|
|
7
|
-
/**
|
|
8
|
-
* Name of the datasource
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
/**
|
|
12
|
-
* Slug of the datasource
|
|
13
|
-
*/
|
|
14
|
-
slug: string;
|
|
15
|
-
/**
|
|
16
|
-
* Array of datasource dimensions
|
|
17
|
-
*/
|
|
18
|
-
dimensions: Array<{
|
|
19
|
-
/**
|
|
20
|
-
* Unique identifier for the dimension
|
|
21
|
-
*/
|
|
22
|
-
id?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Name of the dimension
|
|
25
|
-
*/
|
|
26
|
-
name?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Entry value of the dimension
|
|
29
|
-
*/
|
|
30
|
-
entry_value?: string;
|
|
31
|
-
/**
|
|
32
|
-
* ID of the parent datasource
|
|
33
|
-
*/
|
|
34
|
-
datasource_id?: number;
|
|
35
|
-
/**
|
|
36
|
-
* Creation timestamp
|
|
37
|
-
*/
|
|
38
|
-
created_at?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Last update timestamp
|
|
41
|
-
*/
|
|
42
|
-
updated_at?: string;
|
|
43
|
-
}>;
|
|
44
|
-
};
|
|
45
|
-
type ListData = {
|
|
46
|
-
body?: never;
|
|
47
|
-
path?: never;
|
|
48
|
-
query?: {
|
|
49
|
-
/**
|
|
50
|
-
* Page number for pagination
|
|
51
|
-
*/
|
|
52
|
-
page?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Number of datasources per page (default 25, max 1000)
|
|
55
|
-
*/
|
|
56
|
-
per_page?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Cached version Unix timestamp for cache invalidation
|
|
59
|
-
*/
|
|
60
|
-
cv?: number;
|
|
61
|
-
};
|
|
62
|
-
url: '/v2/cdn/datasources';
|
|
63
|
-
};
|
|
64
|
-
type GetData = {
|
|
65
|
-
body?: never;
|
|
66
|
-
path: {
|
|
67
|
-
/**
|
|
68
|
-
* Datasource identifier (numeric ID)
|
|
69
|
-
*/
|
|
70
|
-
id: number;
|
|
71
|
-
};
|
|
72
|
-
query?: {
|
|
73
|
-
/**
|
|
74
|
-
* Cached version Unix timestamp for cache invalidation
|
|
75
|
-
*/
|
|
76
|
-
cv?: number;
|
|
77
|
-
};
|
|
78
|
-
url: '/v2/cdn/datasources/{id}';
|
|
79
|
-
};
|
|
80
|
-
//#endregion
|
|
81
|
-
export { DatasourceCapi, GetData, ListData };
|
|
82
|
-
//# sourceMappingURL=types.gen.d.cts.map
|