@conloca/content-api-client 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +94 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +434 -0
- package/dist/hooks.d.ts +139 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +715 -0
- package/dist/index.d.mts +66 -75
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +39 -7
- package/dist/index.mjs.map +1 -1
- package/dist/lib/content-api-client.d.ts +2 -0
- package/dist/lib/content-api-client.d.ts.map +1 -0
- package/dist/lib/content-api-client.js +3 -0
- package/dist/{test-helpers-DNN1aglz.mjs → test-helpers-BFyjmKzv.mjs} +4 -3
- package/dist/test-helpers-BFyjmKzv.mjs.map +1 -0
- package/dist/{test-helpers-CVEhY7aJ.d.mts → test-helpers-B_YQhpE2.d.mts} +2 -3
- package/dist/test-helpers-B_YQhpE2.d.mts.map +1 -0
- package/dist/test-helpers.d.ts +90 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +236 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +7 -0
- package/dist/testing.mjs +2 -3
- package/package.json +58 -13
- package/dist/test-helpers-CVEhY7aJ.d.mts.map +0 -1
- package/dist/test-helpers-DNN1aglz.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { t as API_ROUTES } from "./test-helpers-
|
|
2
|
-
import
|
|
3
|
-
import { AssetEntry, AssetEntry as AssetEntry$1, AssetUsage, AssetUsage as AssetUsage$1, BatchResult, BlockEditable, ContentData, ContentEntry, ContentEntry as ContentEntry$1, ContentIdentity, ContentListResult, ContentManifest, ContentManifest as ContentManifest$1, ContentType, CreateContentInput, CreateResult, DataCollectionEntry, DataContext, DataContext as DataContext$1, DataEditable, DeleteResult, ErrorCode, ErrorCodes, FolderListing, FolderListing as FolderListing$1, FolderTreeNode, FolderTreeNode as FolderTreeNode$1, GitCommitResult, GitCommitResult as GitCommitResult$1, GitPullResult, GitPullResult as GitPullResult$1, GitPushResult, GitPushResult as GitPushResult$1, GitStatus, GitStatus as GitStatus$1, GlobalFilters, LocaleVersion, LocalizedEntry, LocalizedEntry as LocalizedEntry$1, LocalizedManifest, MoveResult, PageReference, SitesConfig, SitesConfig as SitesConfig$1, UpdateLocaleInput, UpdateResult, UpdateResult as UpdateResult$1, blockEditableSchema, dataEditableSchema, formatFileSize, localesOf } from "@conloca/content-api";
|
|
4
|
-
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
5
|
-
|
|
1
|
+
import { t as API_ROUTES } from "./test-helpers-B_YQhpE2.mjs";
|
|
2
|
+
import { AssetEntry, AssetEntry as AssetEntry$1, AssetUsage, AssetUsage as AssetUsage$1, BatchResult, BlockEditable, ContentData, ContentEntry, ContentEntry as ContentEntry$1, ContentIdentity, ContentListResult, ContentManifest, ContentManifest as ContentManifest$1, ContentType, CreateContentInput, CreateResult, CreateResult as CreateResult$1, DataCollectionEntry, DataContext, DataContext as DataContext$1, DataEditable, DeleteResult, DeleteResult as DeleteResult$1, ErrorCode, ErrorCodes, FolderListing, FolderListing as FolderListing$1, FolderTreeNode, FolderTreeNode as FolderTreeNode$1, GitCommitResult, GitCommitResult as GitCommitResult$1, GitPullResult, GitPullResult as GitPullResult$1, GitPushResult, GitPushResult as GitPushResult$1, GitStatus, GitStatus as GitStatus$1, GlobalFilters, LocaleVersion, LocalizedEntry, LocalizedEntry as LocalizedEntry$1, LocalizedManifest, MDXCompileResponse, MDXCompileResponse as MDXCompileResponse$1, MoveResult, PageReference, PathnameValidationReason, PathnameValidationResult, SitesConfig, SitesConfig as SitesConfig$1, UpdateLocaleInput, UpdateResult, UpdateResult as UpdateResult$1, blockEditableSchema, dataEditableSchema, formatFileSize, localesOf, normalizeAndValidatePathname } from "@conloca/content-api";
|
|
6
3
|
//#region src/client.d.ts
|
|
7
4
|
interface ContentAPIClientOptions {
|
|
8
5
|
baseUrl?: string;
|
|
@@ -16,20 +13,21 @@ declare class ContentAPIClient {
|
|
|
16
13
|
private fetchAPI;
|
|
17
14
|
getContent(id: string): Promise<ContentEntry$1 | null>;
|
|
18
15
|
getLocalized(id: string, locale: string): Promise<LocalizedEntry$1 | null>;
|
|
19
|
-
createContent(data: CreateContentInput): Promise<CreateResult>;
|
|
16
|
+
createContent(data: CreateContentInput): Promise<CreateResult$1>;
|
|
20
17
|
updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult$1>;
|
|
21
|
-
deleteContent(id: string, etag: string): Promise<DeleteResult>;
|
|
18
|
+
deleteContent(id: string, etag: string): Promise<DeleteResult$1>;
|
|
22
19
|
deleteLocalized(input: {
|
|
23
20
|
id: string;
|
|
24
21
|
locale: string;
|
|
25
22
|
etag: string;
|
|
26
|
-
}): Promise<DeleteResult>;
|
|
23
|
+
}): Promise<DeleteResult$1>;
|
|
27
24
|
getSitePages(site: string, locale?: string): Promise<ContentListResult>;
|
|
28
25
|
getPageByPathname(site: string, pathname: string, locale?: string): Promise<ContentManifest$1 | null>;
|
|
29
26
|
isPathnameAvailable(site: string, pathname: string, excludeId?: string): Promise<boolean>;
|
|
30
27
|
movePage(site: string, id: string, pathname: string, locale: string, etag: string): Promise<MoveResult>;
|
|
31
28
|
getBlocks(collection?: string, locale?: string): Promise<ContentListResult>;
|
|
32
29
|
getBlockByName(name: string, collection?: string, locale?: string): Promise<ContentManifest$1 | null>;
|
|
30
|
+
compileMDX(mdxContent: string): Promise<MDXCompileResponse$1>;
|
|
33
31
|
getData(collection?: string, locale?: string): Promise<ContentListResult>;
|
|
34
32
|
getDataByName(name: string, collection: string, locale?: string): Promise<ContentManifest$1 | null>;
|
|
35
33
|
isDataNameAvailable(name: string, collection: string, excludeId?: string): Promise<boolean>;
|
|
@@ -49,14 +47,8 @@ declare class ContentAPIClient {
|
|
|
49
47
|
assets: AssetEntry$1[];
|
|
50
48
|
}>;
|
|
51
49
|
getAsset(filename: string): Promise<AssetEntry$1 | null>;
|
|
52
|
-
uploadAsset(formData: FormData): Promise<
|
|
53
|
-
|
|
54
|
-
asset: AssetEntry$1;
|
|
55
|
-
}>;
|
|
56
|
-
importAssetUrl(url: string, alt?: string, folder?: string): Promise<{
|
|
57
|
-
success: true;
|
|
58
|
-
asset: AssetEntry$1;
|
|
59
|
-
}>;
|
|
50
|
+
uploadAsset(formData: FormData): Promise<AssetEntry$1>;
|
|
51
|
+
importAssetUrl(url: string, alt?: string, folder?: string): Promise<AssetEntry$1>;
|
|
60
52
|
deleteAsset(filename: string): Promise<{
|
|
61
53
|
success: boolean;
|
|
62
54
|
}>;
|
|
@@ -105,19 +97,24 @@ declare class StaleWriteError extends APIClientError {
|
|
|
105
97
|
//#region src/hooks.d.ts
|
|
106
98
|
declare function getContentAPIClient(): ContentAPIClient;
|
|
107
99
|
declare function setContentAPIClient(client: ContentAPIClient): void;
|
|
108
|
-
declare function useContent(id: string):
|
|
109
|
-
declare function useLocalizedContent(id: string, locale: string):
|
|
110
|
-
|
|
100
|
+
declare function useContent(id: string): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentEntry$1 | null>, Error>;
|
|
101
|
+
declare function useLocalizedContent(id: string, locale: string): import("@tanstack/react-query").UseQueryResult<NoInfer<LocalizedEntry$1 | null>, Error>;
|
|
102
|
+
interface UseCompileMDXOptions {
|
|
103
|
+
mdxContent: string | null;
|
|
104
|
+
cacheKey?: string;
|
|
105
|
+
}
|
|
106
|
+
declare function useCompileMDX({ mdxContent, cacheKey }: UseCompileMDXOptions): import("@tanstack/react-query").UseQueryResult<NoInfer<MDXCompileResponse$1>, Error>;
|
|
107
|
+
declare function useCreateContent(): import("@tanstack/react-query").UseMutationResult<import("@conloca/content-api").CreateResult | {
|
|
111
108
|
fullContent: ContentEntry$1 | null;
|
|
112
109
|
success: boolean;
|
|
113
110
|
id?: string;
|
|
114
111
|
etag?: string;
|
|
115
112
|
created?: Date;
|
|
116
|
-
reason?: "already_exists" | "write_error" | "invalid_name" | "name_taken" | "pathname_taken" | "pathname_in_redirects" | "metadata_too_large";
|
|
113
|
+
reason?: "already_exists" | "write_error" | "invalid_name" | "invalid_pathname" | "name_taken" | "pathname_taken" | "pathname_in_redirects" | "metadata_too_large";
|
|
117
114
|
error?: Error;
|
|
118
115
|
existingId?: string;
|
|
119
116
|
}, Error, CreateContentInput, unknown>;
|
|
120
|
-
declare function useUpdateLocalized():
|
|
117
|
+
declare function useUpdateLocalized(): import("@tanstack/react-query").UseMutationResult<import("@conloca/content-api").UpdateResult | {
|
|
121
118
|
updatedContent: LocalizedEntry$1 | null;
|
|
122
119
|
success: boolean;
|
|
123
120
|
etag?: string;
|
|
@@ -128,9 +125,9 @@ declare function useUpdateLocalized(): _tanstack_react_query0.UseMutationResult<
|
|
|
128
125
|
conflictDetails?: {
|
|
129
126
|
metaChanged: boolean;
|
|
130
127
|
contentChanged: boolean;
|
|
131
|
-
currentMeta?:
|
|
132
|
-
currentContent?:
|
|
133
|
-
localContent?:
|
|
128
|
+
currentMeta?: import("@conloca/content-api").ContentMeta;
|
|
129
|
+
currentContent?: import("@conloca/content-api").ContentData;
|
|
130
|
+
localContent?: import("@conloca/content-api").ContentData;
|
|
134
131
|
};
|
|
135
132
|
}, Error, UpdateLocaleInput, unknown>;
|
|
136
133
|
interface DeleteContentArgs {
|
|
@@ -138,18 +135,18 @@ interface DeleteContentArgs {
|
|
|
138
135
|
etag: string;
|
|
139
136
|
locale?: string;
|
|
140
137
|
}
|
|
141
|
-
declare function useDeleteContent():
|
|
138
|
+
declare function useDeleteContent(): import("@tanstack/react-query").UseMutationResult<import("@conloca/content-api").DeleteResult, Error, DeleteContentArgs, unknown>;
|
|
142
139
|
interface DeleteLocalizedArgs {
|
|
143
140
|
id: string;
|
|
144
141
|
locale: string;
|
|
145
142
|
etag: string;
|
|
146
143
|
}
|
|
147
|
-
declare function useDeleteLocalized():
|
|
148
|
-
declare function useSitePages(site: string, locale?: string):
|
|
149
|
-
declare function usePageByPathname(site: string, pathname: string, locale?: string):
|
|
150
|
-
declare function usePathnameAvailability(site: string, pathname: string, excludeId?: string):
|
|
144
|
+
declare function useDeleteLocalized(): import("@tanstack/react-query").UseMutationResult<import("@conloca/content-api").DeleteResult, Error, DeleteLocalizedArgs, unknown>;
|
|
145
|
+
declare function useSitePages(site: string, locale?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentListResult>, Error>;
|
|
146
|
+
declare function usePageByPathname(site: string, pathname: string, locale?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentManifest$1 | null>, Error>;
|
|
147
|
+
declare function usePathnameAvailability(site: string, pathname: string, excludeId?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
151
148
|
available: boolean;
|
|
152
|
-
}
|
|
149
|
+
}>, Error>;
|
|
153
150
|
interface MovePageArgs {
|
|
154
151
|
site: string;
|
|
155
152
|
id: string;
|
|
@@ -157,79 +154,73 @@ interface MovePageArgs {
|
|
|
157
154
|
locale?: string;
|
|
158
155
|
etag: string;
|
|
159
156
|
}
|
|
160
|
-
declare function useMovePage():
|
|
161
|
-
declare function useBlocks(collection?: string, locale?: string):
|
|
162
|
-
declare function useBlockByName(name: string, collection?: string, locale?: string):
|
|
163
|
-
declare function useData(collection?: string, locale?: string):
|
|
164
|
-
declare function useDataByName(name: string, collection: string, locale?: string):
|
|
165
|
-
declare function useDataNameAvailability(name: string, collection: string, excludeId?: string):
|
|
157
|
+
declare function useMovePage(): import("@tanstack/react-query").UseMutationResult<import("@conloca/content-api").MoveResult, Error, MovePageArgs, unknown>;
|
|
158
|
+
declare function useBlocks(collection?: string, locale?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentListResult>, Error>;
|
|
159
|
+
declare function useBlockByName(name: string, collection?: string, locale?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentManifest$1 | null>, Error>;
|
|
160
|
+
declare function useData(collection?: string, locale?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentListResult>, Error>;
|
|
161
|
+
declare function useDataByName(name: string, collection: string, locale?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentManifest$1 | null>, Error>;
|
|
162
|
+
declare function useDataNameAvailability(name: string, collection: string, excludeId?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
166
163
|
available: boolean;
|
|
167
|
-
}
|
|
168
|
-
declare function useDataCollections():
|
|
169
|
-
declare function useDataContext(pageId?: string):
|
|
170
|
-
dataContext:
|
|
171
|
-
}
|
|
172
|
-
declare function useAllContent(filters?: GlobalFilters):
|
|
173
|
-
declare function useUntranslatedContent(targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean):
|
|
174
|
-
declare function useSitesConfig():
|
|
175
|
-
declare function useCurrentUser():
|
|
164
|
+
}>, Error>;
|
|
165
|
+
declare function useDataCollections(): import("@tanstack/react-query").UseQueryResult<NoInfer<string[]>, Error>;
|
|
166
|
+
declare function useDataContext(pageId?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
167
|
+
dataContext: DataContext$1;
|
|
168
|
+
}>, Error>;
|
|
169
|
+
declare function useAllContent(filters?: GlobalFilters): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentListResult>, Error>;
|
|
170
|
+
declare function useUntranslatedContent(targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean): import("@tanstack/react-query").UseQueryResult<NoInfer<ContentListResult>, Error>;
|
|
171
|
+
declare function useSitesConfig(): import("@tanstack/react-query").UseQueryResult<NoInfer<SitesConfig$1>, Error>;
|
|
172
|
+
declare function useCurrentUser(): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
176
173
|
authenticated: boolean;
|
|
177
174
|
user?: {
|
|
178
175
|
email: string;
|
|
179
176
|
sub: string;
|
|
180
177
|
};
|
|
181
|
-
}
|
|
182
|
-
declare function useBatchUpdate():
|
|
178
|
+
}>, Error>;
|
|
179
|
+
declare function useBatchUpdate(): import("@tanstack/react-query").UseMutationResult<import("@conloca/content-api").BatchResult | {
|
|
183
180
|
updatedContents: {
|
|
184
181
|
index: number;
|
|
185
182
|
content: LocalizedEntry$1;
|
|
186
183
|
}[];
|
|
187
|
-
operations:
|
|
184
|
+
operations: import("@conloca/content-api").BatchOperationResult[];
|
|
188
185
|
success: boolean;
|
|
189
186
|
failed: number;
|
|
190
187
|
updated: number;
|
|
191
188
|
}, Error, UpdateLocaleInput[], unknown>;
|
|
192
|
-
declare function useGitStatus():
|
|
193
|
-
declare function useCommitChanges():
|
|
194
|
-
declare function usePushChanges():
|
|
195
|
-
declare function usePullChanges():
|
|
196
|
-
declare function useAssets():
|
|
197
|
-
assets:
|
|
198
|
-
}
|
|
199
|
-
declare function useAsset(filename: string):
|
|
200
|
-
declare function useUploadAsset():
|
|
201
|
-
|
|
202
|
-
asset: _conloca_content_api0.AssetEntry;
|
|
203
|
-
}, Error, FormData, unknown>;
|
|
204
|
-
declare function useImportAssetUrl(): _tanstack_react_query0.UseMutationResult<{
|
|
205
|
-
success: true;
|
|
206
|
-
asset: _conloca_content_api0.AssetEntry;
|
|
207
|
-
}, Error, {
|
|
189
|
+
declare function useGitStatus(): import("@tanstack/react-query").UseQueryResult<NoInfer<GitStatus>, Error>;
|
|
190
|
+
declare function useCommitChanges(): import("@tanstack/react-query").UseMutationResult<GitCommitResult, Error, string | undefined, unknown>;
|
|
191
|
+
declare function usePushChanges(): import("@tanstack/react-query").UseMutationResult<GitPushResult, Error, void, unknown>;
|
|
192
|
+
declare function usePullChanges(): import("@tanstack/react-query").UseMutationResult<GitPullResult, Error, void, unknown>;
|
|
193
|
+
declare function useAssets(): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
194
|
+
assets: AssetEntry$1[];
|
|
195
|
+
}>, Error>;
|
|
196
|
+
declare function useAsset(filename: string): import("@tanstack/react-query").UseQueryResult<NoInfer<AssetEntry$1 | null>, Error>;
|
|
197
|
+
declare function useUploadAsset(): import("@tanstack/react-query").UseMutationResult<AssetEntry$1, Error, FormData, unknown>;
|
|
198
|
+
declare function useImportAssetUrl(): import("@tanstack/react-query").UseMutationResult<AssetEntry$1, Error, {
|
|
208
199
|
url: string;
|
|
209
200
|
alt?: string;
|
|
210
201
|
folder?: string;
|
|
211
202
|
}, unknown>;
|
|
212
|
-
declare function useDeleteAsset():
|
|
203
|
+
declare function useDeleteAsset(): import("@tanstack/react-query").UseMutationResult<{
|
|
213
204
|
success: boolean;
|
|
214
205
|
}, Error, string, unknown>;
|
|
215
|
-
declare function useBulkDeleteAssets():
|
|
206
|
+
declare function useBulkDeleteAssets(): import("@tanstack/react-query").UseMutationResult<{
|
|
216
207
|
successCount: number;
|
|
217
208
|
failCount: number;
|
|
218
209
|
}, Error, string[], unknown>;
|
|
219
|
-
declare function useAssetFolders(path?: string):
|
|
220
|
-
declare function useCreateFolder():
|
|
221
|
-
declare function useUpdateAssetMetadata():
|
|
210
|
+
declare function useAssetFolders(path?: string): import("@tanstack/react-query").UseQueryResult<NoInfer<FolderListing$1>, Error>;
|
|
211
|
+
declare function useCreateFolder(): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|
|
212
|
+
declare function useUpdateAssetMetadata(): import("@tanstack/react-query").UseMutationResult<AssetEntry$1, Error, {
|
|
222
213
|
filename: string;
|
|
223
214
|
updates: {
|
|
224
215
|
alt?: string;
|
|
225
216
|
tags?: string[];
|
|
226
217
|
};
|
|
227
218
|
}, unknown>;
|
|
228
|
-
declare function useAssetUsage(filename: string | null):
|
|
229
|
-
declare function useFolderTree():
|
|
230
|
-
tree:
|
|
231
|
-
}
|
|
232
|
-
declare function useMoveAssets():
|
|
219
|
+
declare function useAssetUsage(filename: string | null): import("@tanstack/react-query").UseQueryResult<NoInfer<AssetUsage$1[]>, Error>;
|
|
220
|
+
declare function useFolderTree(): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
221
|
+
tree: FolderTreeNode$1[];
|
|
222
|
+
}>, Error>;
|
|
223
|
+
declare function useMoveAssets(): import("@tanstack/react-query").UseMutationResult<{
|
|
233
224
|
success: boolean;
|
|
234
225
|
moved?: number;
|
|
235
226
|
error?: string;
|
|
@@ -239,5 +230,5 @@ declare function useMoveAssets(): _tanstack_react_query0.UseMutationResult<{
|
|
|
239
230
|
targetFolder: string;
|
|
240
231
|
}, unknown>;
|
|
241
232
|
//#endregion
|
|
242
|
-
export { APIClientError, API_ROUTES, type AssetEntry, type AssetUsage, type BlockEditable, ContentAPIClient, ContentAPIClientOptions, type ContentData, type ContentEntry, type ContentIdentity, type ContentManifest, type ContentType, type DataCollectionEntry, type DataContext, type DataEditable, ErrorCodes, type FolderListing, type FolderTreeNode, type GitCommitResult, type GitPullResult, type GitPushResult, type GitStatus, type LocaleVersion, type LocalizedEntry, type LocalizedManifest, type PageReference, type SitesConfig, StaleWriteError, type UpdateResult, blockEditableSchema, dataEditableSchema, formatFileSize, getContentAPIClient, localesOf, setContentAPIClient, useAllContent, useAsset, useAssetFolders, useAssetUsage, useAssets, useBatchUpdate, useBlockByName, useBlocks, useBulkDeleteAssets, useCommitChanges, useContent, useCreateContent, useCreateFolder, useCurrentUser, useData, useDataByName, useDataCollections, useDataContext, useDataNameAvailability, useDeleteAsset, useDeleteContent, useDeleteLocalized, useFolderTree, useGitStatus, useImportAssetUrl, useLocalizedContent, useMoveAssets, useMovePage, usePageByPathname, usePathnameAvailability, usePullChanges, usePushChanges, useSitePages, useSitesConfig, useUntranslatedContent, useUpdateAssetMetadata, useUpdateLocalized, useUploadAsset };
|
|
233
|
+
export { APIClientError, API_ROUTES, type AssetEntry, type AssetUsage, type BlockEditable, ContentAPIClient, ContentAPIClientOptions, type ContentData, type ContentEntry, type ContentIdentity, type ContentManifest, type ContentType, type CreateResult, type DataCollectionEntry, type DataContext, type DataEditable, type DeleteResult, ErrorCodes, type FolderListing, type FolderTreeNode, type GitCommitResult, type GitPullResult, type GitPushResult, type GitStatus, type LocaleVersion, type LocalizedEntry, type LocalizedManifest, type MDXCompileResponse, type PageReference, type PathnameValidationReason, type PathnameValidationResult, type SitesConfig, StaleWriteError, type UpdateResult, UseCompileMDXOptions, blockEditableSchema, dataEditableSchema, formatFileSize, getContentAPIClient, localesOf, normalizeAndValidatePathname, setContentAPIClient, useAllContent, useAsset, useAssetFolders, useAssetUsage, useAssets, useBatchUpdate, useBlockByName, useBlocks, useBulkDeleteAssets, useCommitChanges, useCompileMDX, useContent, useCreateContent, useCreateFolder, useCurrentUser, useData, useDataByName, useDataCollections, useDataContext, useDataNameAvailability, useDeleteAsset, useDeleteContent, useDeleteLocalized, useFolderTree, useGitStatus, useImportAssetUrl, useLocalizedContent, useMoveAssets, useMovePage, usePageByPathname, usePathnameAvailability, usePullChanges, usePushChanges, useSitePages, useSitesConfig, useUntranslatedContent, useUpdateAssetMetadata, useUpdateLocalized, useUploadAsset };
|
|
243
234
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/client.ts","../src/hooks.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/client.ts","../src/hooks.tsx"],"mappings":";;;UA6BiB;EACf;EACA,eAAe;;cAGJ;UACH;UACA;EAEI,YAAA,UAAS;UAab;UAOM;EAgDR,WAAW,aAAa,QAAQ;EAgBhC,aAAa,YAAY,iBAAiB,QAAQ;EAgBlD,cAAc,MAAM,qBAAqB,QAAQ;EAOjD,gBAAgB,OAAO,oBAAoB,QAAQ;EASnD,cAAc,YAAY,eAAe,QAAQ;EASjD,gBAAgB;IAAS;IAAY;IAAgB;MAAiB,QAAQ;EAU9E,aAAa,cAAc,kBAAkB,QAAQ;EAKrD,kBAAkB,cAAc,kBAAkB,kBAAkB,QAAQ;EAmB5E,oBAAoB,cAAc,kBAAkB,qBAAq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YhB,kDAAc,kBAAA,eAAA;iBAYd,kDAAc,kBAAA,eAAA;iBAcd,6CAAS,eAAA;EAGG,QAAA;IAI3B;iBAEe,SAAS,mDAAgB,eAAA,QAAA,sBAAA;iBAUzB,kDAAc,kBAAA,cAAA,OAAA;iBAad,qDAAiB,kBAAA,cAAA;EAKa;EAAc;EAAiB;;iBAS7D,kDAAc;;GAW7B;iBAEe,uDAAmB;;;GAuBlC;iBAIe,gBAAgB,gDAAa,eAAA,QAAA,kBAAA;iBAS7B,mDAAe,wBAAA;iBAYf,0DAAsB,kBAAA,cAAA;EAKc;EAAiB;IAAE;IAAc;;;iBASrE,cAAc,0DAAuB,eAAA,QAAA,iBAAA;iBAWrC,iDAAa,eAAA;EAGH,MAAA;IAKzB;iBAEe,iDAAa;;;;GAAb;EAUC;EACG;EACA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { AssetEntry, AssetUsage, BlockEditable, ContentData, ContentEntry, ContentIdentity, ContentManifest, ContentType, CreateResult, DataCollectionEntry, DataContext, DataEditable, DeleteResult, FolderListing, FolderTreeNode, LocaleVersion, LocalizedEntry, LocalizedManifest, MDXCompileResponse, PageReference, PathnameValidationReason, PathnameValidationResult, SitesConfig, UpdateResult, } from '@conloca/content-api';
|
|
2
|
+
export { blockEditableSchema, dataEditableSchema, ErrorCodes, formatFileSize, localesOf, normalizeAndValidatePathname, } from '@conloca/content-api';
|
|
3
|
+
export * from './client';
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
export { API_ROUTES } from './test-helpers';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,wBAAwB,EACxB,WAAW,EACX,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,SAAS,EACT,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Runtime re-exports for cms-spa layer compliance
|
|
2
|
+
export { blockEditableSchema, dataEditableSchema, ErrorCodes, formatFileSize, localesOf, normalizeAndValidatePathname, } from '@conloca/content-api';
|
|
3
|
+
export * from './client';
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
export { API_ROUTES } from './test-helpers';
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as API_ROUTES } from "./test-helpers-
|
|
2
|
-
import { ErrorCodes, ErrorCodes as ErrorCodes$1, blockEditableSchema, dataEditableSchema, formatFileSize, localesOf } from "@conloca/content-api";
|
|
1
|
+
import { t as API_ROUTES } from "./test-helpers-BFyjmKzv.mjs";
|
|
2
|
+
import { ErrorCodes, ErrorCodes as ErrorCodes$1, blockEditableSchema, dataEditableSchema, formatFileSize, localesOf, normalizeAndValidatePathname } from "@conloca/content-api";
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
|
|
5
4
|
//#region src/client.ts
|
|
6
5
|
var ContentAPIClient = class {
|
|
7
6
|
baseUrl;
|
|
@@ -152,6 +151,12 @@ var ContentAPIClient = class {
|
|
|
152
151
|
throw error;
|
|
153
152
|
}
|
|
154
153
|
}
|
|
154
|
+
async compileMDX(mdxContent) {
|
|
155
|
+
return this.fetchAPI(`${this.baseUrl}/mdx/compile`, {
|
|
156
|
+
method: "POST",
|
|
157
|
+
body: JSON.stringify({ mdxContent })
|
|
158
|
+
});
|
|
159
|
+
}
|
|
155
160
|
async getData(collection, locale) {
|
|
156
161
|
const params = new URLSearchParams();
|
|
157
162
|
if (collection) params.set("collection", collection);
|
|
@@ -321,6 +326,8 @@ var ContentAPIClient = class {
|
|
|
321
326
|
}
|
|
322
327
|
};
|
|
323
328
|
var APIClientError = class extends Error {
|
|
329
|
+
code;
|
|
330
|
+
details;
|
|
324
331
|
constructor(message, code, details) {
|
|
325
332
|
super(message);
|
|
326
333
|
this.code = code;
|
|
@@ -329,6 +336,7 @@ var APIClientError = class extends Error {
|
|
|
329
336
|
}
|
|
330
337
|
};
|
|
331
338
|
var StaleWriteError = class extends APIClientError {
|
|
339
|
+
data;
|
|
332
340
|
constructor(data) {
|
|
333
341
|
super(data.message, data.code, { currentEtag: data.currentEtag });
|
|
334
342
|
this.data = data;
|
|
@@ -338,7 +346,6 @@ var StaleWriteError = class extends APIClientError {
|
|
|
338
346
|
return this.details?.currentEtag;
|
|
339
347
|
}
|
|
340
348
|
};
|
|
341
|
-
|
|
342
349
|
//#endregion
|
|
343
350
|
//#region src/hooks.tsx
|
|
344
351
|
let globalClient = null;
|
|
@@ -352,6 +359,15 @@ function setContentAPIClient(client) {
|
|
|
352
359
|
function isContentListResult(value) {
|
|
353
360
|
return typeof value === "object" && value !== null && "items" in value && "total" in value && Array.isArray(value.items) && typeof value.total === "number";
|
|
354
361
|
}
|
|
362
|
+
function hashString(value) {
|
|
363
|
+
let hash = 0;
|
|
364
|
+
for (let index = 0; index < value.length; index++) {
|
|
365
|
+
const char = value.charCodeAt(index);
|
|
366
|
+
hash = (hash << 5) - hash + char;
|
|
367
|
+
hash |= 0;
|
|
368
|
+
}
|
|
369
|
+
return hash.toString(36);
|
|
370
|
+
}
|
|
355
371
|
const queryKeys = {
|
|
356
372
|
currentUser: () => ["auth", "user"],
|
|
357
373
|
gitStatus: () => ["git", "status"],
|
|
@@ -429,7 +445,12 @@ const queryKeys = {
|
|
|
429
445
|
asset: (filename) => ["assets", filename],
|
|
430
446
|
assetFolders: (path) => ["asset-folders", path],
|
|
431
447
|
assetUsage: (filename) => ["asset-usage", filename],
|
|
432
|
-
folderTree: () => ["folder-tree"]
|
|
448
|
+
folderTree: () => ["folder-tree"],
|
|
449
|
+
mdxCompile: (cacheKey) => [
|
|
450
|
+
"mdx",
|
|
451
|
+
"compile",
|
|
452
|
+
cacheKey
|
|
453
|
+
]
|
|
433
454
|
};
|
|
434
455
|
function useContent(id) {
|
|
435
456
|
const client = getContentAPIClient();
|
|
@@ -447,6 +468,17 @@ function useLocalizedContent(id, locale) {
|
|
|
447
468
|
enabled: !!id && !!locale
|
|
448
469
|
});
|
|
449
470
|
}
|
|
471
|
+
function useCompileMDX({ mdxContent, cacheKey }) {
|
|
472
|
+
const client = getContentAPIClient();
|
|
473
|
+
const resolvedCacheKey = cacheKey || (mdxContent ? `mdx-${hashString(mdxContent)}` : "mdx-empty");
|
|
474
|
+
return useQuery({
|
|
475
|
+
queryKey: queryKeys.mdxCompile(resolvedCacheKey),
|
|
476
|
+
queryFn: () => client.compileMDX(mdxContent),
|
|
477
|
+
enabled: !!mdxContent,
|
|
478
|
+
retry: false,
|
|
479
|
+
staleTime: Number.POSITIVE_INFINITY
|
|
480
|
+
});
|
|
481
|
+
}
|
|
450
482
|
function useCreateContent() {
|
|
451
483
|
const client = getContentAPIClient();
|
|
452
484
|
const queryClient = useQueryClient();
|
|
@@ -1068,7 +1100,7 @@ function useMoveAssets() {
|
|
|
1068
1100
|
}
|
|
1069
1101
|
});
|
|
1070
1102
|
}
|
|
1071
|
-
|
|
1072
1103
|
//#endregion
|
|
1073
|
-
export { APIClientError, API_ROUTES, ContentAPIClient, ErrorCodes, StaleWriteError, blockEditableSchema, dataEditableSchema, formatFileSize, getContentAPIClient, localesOf, setContentAPIClient, useAllContent, useAsset, useAssetFolders, useAssetUsage, useAssets, useBatchUpdate, useBlockByName, useBlocks, useBulkDeleteAssets, useCommitChanges, useContent, useCreateContent, useCreateFolder, useCurrentUser, useData, useDataByName, useDataCollections, useDataContext, useDataNameAvailability, useDeleteAsset, useDeleteContent, useDeleteLocalized, useFolderTree, useGitStatus, useImportAssetUrl, useLocalizedContent, useMoveAssets, useMovePage, usePageByPathname, usePathnameAvailability, usePullChanges, usePushChanges, useSitePages, useSitesConfig, useUntranslatedContent, useUpdateAssetMetadata, useUpdateLocalized, useUploadAsset };
|
|
1104
|
+
export { APIClientError, API_ROUTES, ContentAPIClient, ErrorCodes, StaleWriteError, blockEditableSchema, dataEditableSchema, formatFileSize, getContentAPIClient, localesOf, normalizeAndValidatePathname, setContentAPIClient, useAllContent, useAsset, useAssetFolders, useAssetUsage, useAssets, useBatchUpdate, useBlockByName, useBlocks, useBulkDeleteAssets, useCommitChanges, useCompileMDX, useContent, useCreateContent, useCreateFolder, useCurrentUser, useData, useDataByName, useDataCollections, useDataContext, useDataNameAvailability, useDeleteAsset, useDeleteContent, useDeleteLocalized, useFolderTree, useGitStatus, useImportAssetUrl, useLocalizedContent, useMoveAssets, useMovePage, usePageByPathname, usePathnameAvailability, usePullChanges, usePushChanges, useSitePages, useSitesConfig, useUntranslatedContent, useUpdateAssetMetadata, useUpdateLocalized, useUploadAsset };
|
|
1105
|
+
|
|
1074
1106
|
//# sourceMappingURL=index.mjs.map
|