@conloca/content-api-client 0.1.12 → 0.1.14
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/index.d.mts +91 -69
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +46 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{test-helpers-4tYApvzp.d.mts → test-helpers-CVEhY7aJ.d.mts} +2 -1
- package/dist/test-helpers-CVEhY7aJ.d.mts.map +1 -0
- package/dist/{test-helpers-CFATqjhm.mjs → test-helpers-DNN1aglz.mjs} +3 -2
- package/dist/test-helpers-DNN1aglz.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +6 -6
- package/dist/test-helpers-4tYApvzp.d.mts.map +0 -1
- package/dist/test-helpers-CFATqjhm.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
import { t as API_ROUTES } from "./test-helpers-
|
|
2
|
-
import
|
|
1
|
+
import { t as API_ROUTES } from "./test-helpers-CVEhY7aJ.mjs";
|
|
2
|
+
import * as _conloca_content_api0 from "@conloca/content-api";
|
|
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";
|
|
3
4
|
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
4
5
|
|
|
5
6
|
//#region src/client.d.ts
|
|
6
|
-
interface GitStatus {
|
|
7
|
-
hasChanges: boolean;
|
|
8
|
-
changedFiles: number;
|
|
9
|
-
ahead: number;
|
|
10
|
-
behind: number;
|
|
11
|
-
branch: string;
|
|
12
|
-
isRepo: boolean;
|
|
13
|
-
}
|
|
14
|
-
interface GitCommitResult {
|
|
15
|
-
success: boolean;
|
|
16
|
-
commit?: string;
|
|
17
|
-
summary?: string;
|
|
18
|
-
error?: string;
|
|
19
|
-
}
|
|
20
|
-
interface GitPushResult {
|
|
21
|
-
success: boolean;
|
|
22
|
-
error?: string;
|
|
23
|
-
}
|
|
24
|
-
interface GitPullResult {
|
|
25
|
-
success: boolean;
|
|
26
|
-
summary?: string;
|
|
27
|
-
error?: string;
|
|
28
|
-
}
|
|
29
7
|
interface ContentAPIClientOptions {
|
|
30
8
|
baseUrl?: string;
|
|
31
9
|
fetch?: typeof fetch;
|
|
@@ -34,57 +12,61 @@ declare class ContentAPIClient {
|
|
|
34
12
|
private baseUrl;
|
|
35
13
|
private fetch;
|
|
36
14
|
constructor(options?: ContentAPIClientOptions);
|
|
15
|
+
private encodeAssetPath;
|
|
37
16
|
private fetchAPI;
|
|
38
17
|
getContent(id: string): Promise<ContentEntry$1 | null>;
|
|
39
18
|
getLocalized(id: string, locale: string): Promise<LocalizedEntry$1 | null>;
|
|
40
|
-
createContent(data: CreateContentInput
|
|
41
|
-
updateLocalized(input: UpdateLocaleInput
|
|
42
|
-
deleteContent(id: string, etag: string): Promise<DeleteResult
|
|
19
|
+
createContent(data: CreateContentInput): Promise<CreateResult>;
|
|
20
|
+
updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult$1>;
|
|
21
|
+
deleteContent(id: string, etag: string): Promise<DeleteResult>;
|
|
43
22
|
deleteLocalized(input: {
|
|
44
23
|
id: string;
|
|
45
24
|
locale: string;
|
|
46
25
|
etag: string;
|
|
47
|
-
}): Promise<DeleteResult
|
|
48
|
-
getSitePages(site: string, locale?: string): Promise<ContentListResult
|
|
26
|
+
}): Promise<DeleteResult>;
|
|
27
|
+
getSitePages(site: string, locale?: string): Promise<ContentListResult>;
|
|
49
28
|
getPageByPathname(site: string, pathname: string, locale?: string): Promise<ContentManifest$1 | null>;
|
|
50
29
|
isPathnameAvailable(site: string, pathname: string, excludeId?: string): Promise<boolean>;
|
|
51
|
-
movePage(site: string, id: string, pathname: string, locale: string, etag: string): Promise<MoveResult
|
|
52
|
-
getBlocks(collection?: string, locale?: string): Promise<ContentListResult
|
|
30
|
+
movePage(site: string, id: string, pathname: string, locale: string, etag: string): Promise<MoveResult>;
|
|
31
|
+
getBlocks(collection?: string, locale?: string): Promise<ContentListResult>;
|
|
53
32
|
getBlockByName(name: string, collection?: string, locale?: string): Promise<ContentManifest$1 | null>;
|
|
54
|
-
getData(collection?: string, locale?: string): Promise<ContentListResult
|
|
33
|
+
getData(collection?: string, locale?: string): Promise<ContentListResult>;
|
|
55
34
|
getDataByName(name: string, collection: string, locale?: string): Promise<ContentManifest$1 | null>;
|
|
56
35
|
isDataNameAvailable(name: string, collection: string, excludeId?: string): Promise<boolean>;
|
|
57
36
|
getDataCollections(): Promise<string[]>;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
getDataContext(pageId: string): Promise<{
|
|
38
|
+
dataContext: DataContext$1;
|
|
39
|
+
}>;
|
|
40
|
+
listAllContent(filters?: GlobalFilters): Promise<ContentListResult>;
|
|
41
|
+
findUntranslatedContent(targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean): Promise<ContentListResult>;
|
|
42
|
+
getSitesConfig(): Promise<SitesConfig$1>;
|
|
43
|
+
batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult>;
|
|
44
|
+
getGitStatus(): Promise<GitStatus$1>;
|
|
45
|
+
commitChanges(message?: string): Promise<GitCommitResult$1>;
|
|
46
|
+
pushChanges(): Promise<GitPushResult$1>;
|
|
47
|
+
pullChanges(): Promise<GitPullResult$1>;
|
|
66
48
|
listAssets(): Promise<{
|
|
67
|
-
assets: AssetEntry$
|
|
49
|
+
assets: AssetEntry$1[];
|
|
68
50
|
}>;
|
|
69
|
-
getAsset(filename: string): Promise<AssetEntry$
|
|
51
|
+
getAsset(filename: string): Promise<AssetEntry$1 | null>;
|
|
70
52
|
uploadAsset(formData: FormData): Promise<{
|
|
71
53
|
success: true;
|
|
72
|
-
asset: AssetEntry$
|
|
54
|
+
asset: AssetEntry$1;
|
|
73
55
|
}>;
|
|
74
56
|
importAssetUrl(url: string, alt?: string, folder?: string): Promise<{
|
|
75
57
|
success: true;
|
|
76
|
-
asset: AssetEntry$
|
|
58
|
+
asset: AssetEntry$1;
|
|
77
59
|
}>;
|
|
78
60
|
deleteAsset(filename: string): Promise<{
|
|
79
61
|
success: boolean;
|
|
80
62
|
}>;
|
|
81
|
-
listFolder(path?: string): Promise<FolderListing$
|
|
63
|
+
listFolder(path?: string): Promise<FolderListing$1>;
|
|
82
64
|
createFolder(path: string): Promise<void>;
|
|
83
65
|
updateAssetMetadata(filename: string, updates: {
|
|
84
66
|
alt?: string;
|
|
85
67
|
tags?: string[];
|
|
86
|
-
}): Promise<AssetEntry$
|
|
87
|
-
getAssetUsage(filename: string): Promise<AssetUsage$
|
|
68
|
+
}): Promise<AssetEntry$1>;
|
|
69
|
+
getAssetUsage(filename: string): Promise<AssetUsage$1[]>;
|
|
88
70
|
moveAssets(filenames: string[], sourceFolder: string, targetFolder: string): Promise<{
|
|
89
71
|
success: boolean;
|
|
90
72
|
moved?: number;
|
|
@@ -123,24 +105,48 @@ declare class StaleWriteError extends APIClientError {
|
|
|
123
105
|
//#region src/hooks.d.ts
|
|
124
106
|
declare function getContentAPIClient(): ContentAPIClient;
|
|
125
107
|
declare function setContentAPIClient(client: ContentAPIClient): void;
|
|
126
|
-
declare function useContent(id: string): _tanstack_react_query0.UseQueryResult<
|
|
127
|
-
declare function useLocalizedContent(id: string, locale: string): _tanstack_react_query0.UseQueryResult<
|
|
128
|
-
declare function useCreateContent(): _tanstack_react_query0.UseMutationResult<
|
|
129
|
-
|
|
108
|
+
declare function useContent(id: string): _tanstack_react_query0.UseQueryResult<ContentEntry$1 | null, Error>;
|
|
109
|
+
declare function useLocalizedContent(id: string, locale: string): _tanstack_react_query0.UseQueryResult<LocalizedEntry$1 | null, Error>;
|
|
110
|
+
declare function useCreateContent(): _tanstack_react_query0.UseMutationResult<_conloca_content_api0.CreateResult | {
|
|
111
|
+
fullContent: ContentEntry$1 | null;
|
|
112
|
+
success: boolean;
|
|
113
|
+
id?: string;
|
|
114
|
+
etag?: string;
|
|
115
|
+
created?: Date;
|
|
116
|
+
reason?: "already_exists" | "write_error" | "invalid_name" | "name_taken" | "pathname_taken" | "pathname_in_redirects" | "metadata_too_large";
|
|
117
|
+
error?: Error;
|
|
118
|
+
existingId?: string;
|
|
119
|
+
}, Error, CreateContentInput, unknown>;
|
|
120
|
+
declare function useUpdateLocalized(): _tanstack_react_query0.UseMutationResult<_conloca_content_api0.UpdateResult | {
|
|
121
|
+
updatedContent: LocalizedEntry$1 | null;
|
|
122
|
+
success: boolean;
|
|
123
|
+
etag?: string;
|
|
124
|
+
modified?: Date;
|
|
125
|
+
reason?: "not_found" | "stale_write" | "write_error";
|
|
126
|
+
error?: Error;
|
|
127
|
+
currentEtag?: string;
|
|
128
|
+
conflictDetails?: {
|
|
129
|
+
metaChanged: boolean;
|
|
130
|
+
contentChanged: boolean;
|
|
131
|
+
currentMeta?: _conloca_content_api0.ContentMeta;
|
|
132
|
+
currentContent?: _conloca_content_api0.ContentData;
|
|
133
|
+
localContent?: _conloca_content_api0.ContentData;
|
|
134
|
+
};
|
|
135
|
+
}, Error, UpdateLocaleInput, unknown>;
|
|
130
136
|
interface DeleteContentArgs {
|
|
131
137
|
id: string;
|
|
132
138
|
etag: string;
|
|
133
139
|
locale?: string;
|
|
134
140
|
}
|
|
135
|
-
declare function useDeleteContent(): _tanstack_react_query0.UseMutationResult<DeleteResult, Error, DeleteContentArgs, unknown>;
|
|
141
|
+
declare function useDeleteContent(): _tanstack_react_query0.UseMutationResult<_conloca_content_api0.DeleteResult, Error, DeleteContentArgs, unknown>;
|
|
136
142
|
interface DeleteLocalizedArgs {
|
|
137
143
|
id: string;
|
|
138
144
|
locale: string;
|
|
139
145
|
etag: string;
|
|
140
146
|
}
|
|
141
|
-
declare function useDeleteLocalized(): _tanstack_react_query0.UseMutationResult<DeleteResult, Error, DeleteLocalizedArgs, unknown>;
|
|
147
|
+
declare function useDeleteLocalized(): _tanstack_react_query0.UseMutationResult<_conloca_content_api0.DeleteResult, Error, DeleteLocalizedArgs, unknown>;
|
|
142
148
|
declare function useSitePages(site: string, locale?: string): _tanstack_react_query0.UseQueryResult<ContentListResult, Error>;
|
|
143
|
-
declare function usePageByPathname(site: string, pathname: string, locale?: string): _tanstack_react_query0.UseQueryResult<
|
|
149
|
+
declare function usePageByPathname(site: string, pathname: string, locale?: string): _tanstack_react_query0.UseQueryResult<ContentManifest$1 | null, Error>;
|
|
144
150
|
declare function usePathnameAvailability(site: string, pathname: string, excludeId?: string): _tanstack_react_query0.UseQueryResult<{
|
|
145
151
|
available: boolean;
|
|
146
152
|
}, Error>;
|
|
@@ -151,18 +157,21 @@ interface MovePageArgs {
|
|
|
151
157
|
locale?: string;
|
|
152
158
|
etag: string;
|
|
153
159
|
}
|
|
154
|
-
declare function useMovePage(): _tanstack_react_query0.UseMutationResult<MoveResult, Error, MovePageArgs, unknown>;
|
|
160
|
+
declare function useMovePage(): _tanstack_react_query0.UseMutationResult<_conloca_content_api0.MoveResult, Error, MovePageArgs, unknown>;
|
|
155
161
|
declare function useBlocks(collection?: string, locale?: string): _tanstack_react_query0.UseQueryResult<ContentListResult, Error>;
|
|
156
|
-
declare function useBlockByName(name: string, collection?: string, locale?: string): _tanstack_react_query0.UseQueryResult<
|
|
162
|
+
declare function useBlockByName(name: string, collection?: string, locale?: string): _tanstack_react_query0.UseQueryResult<ContentManifest$1 | null, Error>;
|
|
157
163
|
declare function useData(collection?: string, locale?: string): _tanstack_react_query0.UseQueryResult<ContentListResult, Error>;
|
|
158
|
-
declare function useDataByName(name: string, collection: string, locale?: string): _tanstack_react_query0.UseQueryResult<
|
|
164
|
+
declare function useDataByName(name: string, collection: string, locale?: string): _tanstack_react_query0.UseQueryResult<ContentManifest$1 | null, Error>;
|
|
159
165
|
declare function useDataNameAvailability(name: string, collection: string, excludeId?: string): _tanstack_react_query0.UseQueryResult<{
|
|
160
166
|
available: boolean;
|
|
161
167
|
}, Error>;
|
|
162
168
|
declare function useDataCollections(): _tanstack_react_query0.UseQueryResult<string[], Error>;
|
|
169
|
+
declare function useDataContext(pageId?: string): _tanstack_react_query0.UseQueryResult<{
|
|
170
|
+
dataContext: _conloca_content_api0.DataContext;
|
|
171
|
+
}, Error>;
|
|
163
172
|
declare function useAllContent(filters?: GlobalFilters): _tanstack_react_query0.UseQueryResult<ContentListResult, Error>;
|
|
164
173
|
declare function useUntranslatedContent(targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean): _tanstack_react_query0.UseQueryResult<ContentListResult, Error>;
|
|
165
|
-
declare function useSitesConfig(): _tanstack_react_query0.UseQueryResult<SitesConfig, Error>;
|
|
174
|
+
declare function useSitesConfig(): _tanstack_react_query0.UseQueryResult<_conloca_content_api0.SitesConfig, Error>;
|
|
166
175
|
declare function useCurrentUser(): _tanstack_react_query0.UseQueryResult<{
|
|
167
176
|
authenticated: boolean;
|
|
168
177
|
user?: {
|
|
@@ -170,22 +179,31 @@ declare function useCurrentUser(): _tanstack_react_query0.UseQueryResult<{
|
|
|
170
179
|
sub: string;
|
|
171
180
|
};
|
|
172
181
|
}, Error>;
|
|
173
|
-
declare function useBatchUpdate(): _tanstack_react_query0.UseMutationResult<
|
|
182
|
+
declare function useBatchUpdate(): _tanstack_react_query0.UseMutationResult<_conloca_content_api0.BatchResult | {
|
|
183
|
+
updatedContents: {
|
|
184
|
+
index: number;
|
|
185
|
+
content: LocalizedEntry$1;
|
|
186
|
+
}[];
|
|
187
|
+
operations: _conloca_content_api0.BatchOperationResult[];
|
|
188
|
+
success: boolean;
|
|
189
|
+
failed: number;
|
|
190
|
+
updated: number;
|
|
191
|
+
}, Error, UpdateLocaleInput[], unknown>;
|
|
174
192
|
declare function useGitStatus(): _tanstack_react_query0.UseQueryResult<GitStatus, Error>;
|
|
175
193
|
declare function useCommitChanges(): _tanstack_react_query0.UseMutationResult<GitCommitResult, Error, string | undefined, unknown>;
|
|
176
194
|
declare function usePushChanges(): _tanstack_react_query0.UseMutationResult<GitPushResult, Error, void, unknown>;
|
|
177
195
|
declare function usePullChanges(): _tanstack_react_query0.UseMutationResult<GitPullResult, Error, void, unknown>;
|
|
178
196
|
declare function useAssets(): _tanstack_react_query0.UseQueryResult<{
|
|
179
|
-
assets:
|
|
197
|
+
assets: _conloca_content_api0.AssetEntry[];
|
|
180
198
|
}, Error>;
|
|
181
|
-
declare function useAsset(filename: string): _tanstack_react_query0.UseQueryResult<
|
|
199
|
+
declare function useAsset(filename: string): _tanstack_react_query0.UseQueryResult<_conloca_content_api0.AssetEntry | null, Error>;
|
|
182
200
|
declare function useUploadAsset(): _tanstack_react_query0.UseMutationResult<{
|
|
183
201
|
success: true;
|
|
184
|
-
asset:
|
|
202
|
+
asset: _conloca_content_api0.AssetEntry;
|
|
185
203
|
}, Error, FormData, unknown>;
|
|
186
204
|
declare function useImportAssetUrl(): _tanstack_react_query0.UseMutationResult<{
|
|
187
205
|
success: true;
|
|
188
|
-
asset:
|
|
206
|
+
asset: _conloca_content_api0.AssetEntry;
|
|
189
207
|
}, Error, {
|
|
190
208
|
url: string;
|
|
191
209
|
alt?: string;
|
|
@@ -194,18 +212,22 @@ declare function useImportAssetUrl(): _tanstack_react_query0.UseMutationResult<{
|
|
|
194
212
|
declare function useDeleteAsset(): _tanstack_react_query0.UseMutationResult<{
|
|
195
213
|
success: boolean;
|
|
196
214
|
}, Error, string, unknown>;
|
|
197
|
-
declare function
|
|
215
|
+
declare function useBulkDeleteAssets(): _tanstack_react_query0.UseMutationResult<{
|
|
216
|
+
successCount: number;
|
|
217
|
+
failCount: number;
|
|
218
|
+
}, Error, string[], unknown>;
|
|
219
|
+
declare function useAssetFolders(path?: string): _tanstack_react_query0.UseQueryResult<_conloca_content_api0.FolderListing, Error>;
|
|
198
220
|
declare function useCreateFolder(): _tanstack_react_query0.UseMutationResult<void, Error, string, unknown>;
|
|
199
|
-
declare function useUpdateAssetMetadata(): _tanstack_react_query0.UseMutationResult<AssetEntry, Error, {
|
|
221
|
+
declare function useUpdateAssetMetadata(): _tanstack_react_query0.UseMutationResult<_conloca_content_api0.AssetEntry, Error, {
|
|
200
222
|
filename: string;
|
|
201
223
|
updates: {
|
|
202
224
|
alt?: string;
|
|
203
225
|
tags?: string[];
|
|
204
226
|
};
|
|
205
227
|
}, unknown>;
|
|
206
|
-
declare function useAssetUsage(filename: string | null): _tanstack_react_query0.UseQueryResult<AssetUsage[], Error>;
|
|
228
|
+
declare function useAssetUsage(filename: string | null): _tanstack_react_query0.UseQueryResult<_conloca_content_api0.AssetUsage[], Error>;
|
|
207
229
|
declare function useFolderTree(): _tanstack_react_query0.UseQueryResult<{
|
|
208
|
-
tree:
|
|
230
|
+
tree: _conloca_content_api0.FolderTreeNode[];
|
|
209
231
|
}, Error>;
|
|
210
232
|
declare function useMoveAssets(): _tanstack_react_query0.UseMutationResult<{
|
|
211
233
|
success: boolean;
|
|
@@ -217,5 +239,5 @@ declare function useMoveAssets(): _tanstack_react_query0.UseMutationResult<{
|
|
|
217
239
|
targetFolder: string;
|
|
218
240
|
}, unknown>;
|
|
219
241
|
//#endregion
|
|
220
|
-
export { APIClientError, API_ROUTES, type AssetEntry
|
|
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 };
|
|
221
243
|
//# 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":";;;;;;UA4BiB,uBAAA;EACf,OAAA;EACA,KAAA,UAAe,KAAA;AAAA;AAAA,cAGJ,gBAAA;EAAA,QACH,OAAA;EAAA,QACA,KAAA;cAEI,OAAA,GAAS,uBAAA;EAAA,QAab,eAAA;EAAA,QAOM,QAAA;EAgDR,UAAA,CAAW,EAAA,WAAa,OAAA,CAAQ,cAAA;EAgBhC,YAAA,CAAa,EAAA,UAAY,MAAA,WA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KiC,GAAA;IAAc,IAAA;EAAA;AAAA;AAAA,iBASrE,aAAA,CAAc,QAAA,kBAAuB,sBAAA,CAAA,cAAA,CAAxB,qBAAA,CAAwB,UAAA,IAAA,KAAA;AAAA,iBAWrC,aAAA,CAAA,0BAAa,cAAA;QAAA,qBAAA,CAAA,cAAA;AAAA;iBAUb,aAAA,CAAA,GAAa,sBAAA,CAAA,iBAAA;;;;GAAA,KAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as API_ROUTES } from "./test-helpers-
|
|
2
|
-
import { ErrorCodes, ErrorCodes as ErrorCodes$1, localesOf } from "@conloca/content-api";
|
|
1
|
+
import { t as API_ROUTES } from "./test-helpers-DNN1aglz.mjs";
|
|
2
|
+
import { ErrorCodes, ErrorCodes as ErrorCodes$1, blockEditableSchema, dataEditableSchema, formatFileSize, localesOf } from "@conloca/content-api";
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
|
|
5
5
|
//#region src/client.ts
|
|
@@ -12,6 +12,9 @@ var ContentAPIClient = class {
|
|
|
12
12
|
else this.fetch = fetch;
|
|
13
13
|
this.baseUrl = options.baseUrl || "/__conloca/api";
|
|
14
14
|
}
|
|
15
|
+
encodeAssetPath(filename) {
|
|
16
|
+
return filename.split("/").map((s) => encodeURIComponent(s)).join("/");
|
|
17
|
+
}
|
|
15
18
|
async fetchAPI(url, options) {
|
|
16
19
|
const response = await this.fetch(url, {
|
|
17
20
|
...options,
|
|
@@ -184,6 +187,9 @@ var ContentAPIClient = class {
|
|
|
184
187
|
async getDataCollections() {
|
|
185
188
|
return (await this.fetchAPI(`${this.baseUrl}/data/collections`)).collections;
|
|
186
189
|
}
|
|
190
|
+
async getDataContext(pageId) {
|
|
191
|
+
return this.fetchAPI(`${this.baseUrl}/data-context?pageId=${pageId}`);
|
|
192
|
+
}
|
|
187
193
|
async listAllContent(filters) {
|
|
188
194
|
const params = new URLSearchParams();
|
|
189
195
|
if (filters?.site) params.set("site", filters.site);
|
|
@@ -239,7 +245,7 @@ var ContentAPIClient = class {
|
|
|
239
245
|
}
|
|
240
246
|
async getAsset(filename) {
|
|
241
247
|
try {
|
|
242
|
-
const response = await this.fetch(`${this.baseUrl}/assets/${
|
|
248
|
+
const response = await this.fetch(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`);
|
|
243
249
|
if (response.status === 404) return null;
|
|
244
250
|
if (!response.ok) throw new Error(`Failed to fetch asset: ${response.statusText}`);
|
|
245
251
|
return await response.json();
|
|
@@ -273,7 +279,7 @@ var ContentAPIClient = class {
|
|
|
273
279
|
});
|
|
274
280
|
}
|
|
275
281
|
async deleteAsset(filename) {
|
|
276
|
-
return this.fetchAPI(`${this.baseUrl}/assets/${
|
|
282
|
+
return this.fetchAPI(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`, { method: "DELETE" });
|
|
277
283
|
}
|
|
278
284
|
async listFolder(path = "/") {
|
|
279
285
|
const params = new URLSearchParams({ path });
|
|
@@ -287,13 +293,13 @@ var ContentAPIClient = class {
|
|
|
287
293
|
});
|
|
288
294
|
}
|
|
289
295
|
async updateAssetMetadata(filename, updates) {
|
|
290
|
-
return this.fetchAPI(`${this.baseUrl}/assets/${
|
|
296
|
+
return this.fetchAPI(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`, {
|
|
291
297
|
method: "PATCH",
|
|
292
298
|
body: JSON.stringify(updates)
|
|
293
299
|
});
|
|
294
300
|
}
|
|
295
301
|
async getAssetUsage(filename) {
|
|
296
|
-
return this.fetchAPI(`${this.baseUrl}/assets/${
|
|
302
|
+
return this.fetchAPI(`${this.baseUrl}/assets/usage/${this.encodeAssetPath(filename)}`);
|
|
297
303
|
}
|
|
298
304
|
async moveAssets(filenames, sourceFolder, targetFolder) {
|
|
299
305
|
return this.fetchAPI(`${this.baseUrl}/assets/move`, {
|
|
@@ -405,6 +411,7 @@ const queryKeys = {
|
|
|
405
411
|
excludeId
|
|
406
412
|
],
|
|
407
413
|
dataCollections: () => ["data", "collections"],
|
|
414
|
+
dataContext: (pageId) => ["data-context", pageId],
|
|
408
415
|
allContent: (filters) => [
|
|
409
416
|
"content",
|
|
410
417
|
"all",
|
|
@@ -772,6 +779,14 @@ function useDataCollections() {
|
|
|
772
779
|
queryFn: () => client.getDataCollections()
|
|
773
780
|
});
|
|
774
781
|
}
|
|
782
|
+
function useDataContext(pageId) {
|
|
783
|
+
const client = getContentAPIClient();
|
|
784
|
+
return useQuery({
|
|
785
|
+
queryKey: queryKeys.dataContext(pageId),
|
|
786
|
+
queryFn: () => client.getDataContext(pageId),
|
|
787
|
+
enabled: !!pageId
|
|
788
|
+
});
|
|
789
|
+
}
|
|
775
790
|
function useAllContent(filters) {
|
|
776
791
|
const client = getContentAPIClient();
|
|
777
792
|
return useQuery({
|
|
@@ -972,6 +987,30 @@ function useDeleteAsset() {
|
|
|
972
987
|
}
|
|
973
988
|
});
|
|
974
989
|
}
|
|
990
|
+
function useBulkDeleteAssets() {
|
|
991
|
+
const client = getContentAPIClient();
|
|
992
|
+
const queryClient = useQueryClient();
|
|
993
|
+
return useMutation({
|
|
994
|
+
mutationFn: async (filenames) => {
|
|
995
|
+
let successCount = 0;
|
|
996
|
+
let failCount = 0;
|
|
997
|
+
for (const filename of filenames) try {
|
|
998
|
+
await client.deleteAsset(filename);
|
|
999
|
+
successCount++;
|
|
1000
|
+
} catch {
|
|
1001
|
+
failCount++;
|
|
1002
|
+
}
|
|
1003
|
+
return {
|
|
1004
|
+
successCount,
|
|
1005
|
+
failCount
|
|
1006
|
+
};
|
|
1007
|
+
},
|
|
1008
|
+
onSettled: () => {
|
|
1009
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.assets() });
|
|
1010
|
+
queryClient.invalidateQueries({ queryKey: ["asset-folders"] });
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
975
1014
|
function useAssetFolders(path) {
|
|
976
1015
|
const client = getContentAPIClient();
|
|
977
1016
|
return useQuery({
|
|
@@ -1031,5 +1070,5 @@ function useMoveAssets() {
|
|
|
1031
1070
|
}
|
|
1032
1071
|
|
|
1033
1072
|
//#endregion
|
|
1034
|
-
export { APIClientError, API_ROUTES, ContentAPIClient, ErrorCodes, StaleWriteError, getContentAPIClient, localesOf, setContentAPIClient, useAllContent, useAsset, useAssetFolders, useAssetUsage, useAssets, useBatchUpdate, useBlockByName, useBlocks, useCommitChanges, useContent, useCreateContent, useCreateFolder, useCurrentUser, useData, useDataByName, useDataCollections, useDataNameAvailability, useDeleteAsset, useDeleteContent, useDeleteLocalized, useFolderTree, useGitStatus, useImportAssetUrl, useLocalizedContent, useMoveAssets, useMovePage, usePageByPathname, usePathnameAvailability, usePullChanges, usePushChanges, useSitePages, useSitesConfig, useUntranslatedContent, useUpdateAssetMetadata, useUpdateLocalized, useUploadAsset };
|
|
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 };
|
|
1035
1074
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["ErrorCodes"],"sources":["../src/client.ts","../src/hooks.tsx"],"sourcesContent":["import type {\n APIError,\n AssetEntry,\n AssetUsage,\n BatchResult,\n ContentEntry,\n ContentListResult,\n ContentManifest,\n CreateContentInput,\n CreateResult,\n DeleteResult,\n ErrorCode,\n FolderListing,\n FolderTreeNode,\n GlobalFilters,\n LocalizedEntry,\n MoveResult,\n SitesConfig,\n UpdateLocaleInput,\n UpdateResult,\n} from '@conloca/content-api';\nimport { ErrorCodes } from '@conloca/content-api';\n\n// Git operation types\nexport interface GitStatus {\n hasChanges: boolean;\n changedFiles: number;\n ahead: number;\n behind: number;\n branch: string;\n isRepo: boolean;\n}\n\nexport interface GitCommitResult {\n success: boolean;\n commit?: string;\n summary?: string;\n error?: string;\n}\n\nexport interface GitPushResult {\n success: boolean;\n error?: string;\n}\n\nexport interface GitPullResult {\n success: boolean;\n summary?: string;\n error?: string;\n}\n\nexport interface ContentAPIClientOptions {\n baseUrl?: string;\n fetch?: typeof fetch;\n}\n\nexport class ContentAPIClient {\n private baseUrl: string;\n private fetch: typeof fetch;\n\n constructor(options: ContentAPIClientOptions = {}) {\n // Bind fetch to maintain its context\n if (options.fetch) {\n this.fetch = options.fetch;\n } else if (typeof globalThis !== 'undefined' && globalThis.fetch) {\n // Use globalThis for better compatibility\n this.fetch = globalThis.fetch.bind(globalThis);\n } else {\n this.fetch = fetch;\n }\n this.baseUrl = options.baseUrl || '/__conloca/api';\n }\n\n private async fetchAPI<T>(url: string, options?: RequestInit): Promise<T> {\n const response = await this.fetch(url, {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options?.headers,\n },\n });\n\n if (!response.ok) {\n let errorData: any;\n try {\n errorData = await response.json();\n } catch {\n // If JSON parsing fails, throw generic error\n throw new Error(`API error: ${response.status} ${response.statusText}`);\n }\n\n // Check if it's an APIError format\n if (errorData?.error?.code) {\n const apiError = errorData as APIError;\n\n // Special handling for stale writes\n if (apiError.error.code === ErrorCodes.STALE_WRITE) {\n throw new StaleWriteError({\n code: apiError.error.code,\n message: apiError.error.message,\n currentEtag: apiError.error.details?.currentEtag,\n });\n }\n\n // Create a proper error with code and details\n const error = new APIClientError(\n apiError.error.message,\n apiError.error.code as ErrorCode,\n apiError.error.details,\n );\n throw error;\n }\n\n // Fallback for non-standard error responses\n throw new Error(`API error: ${response.status} ${response.statusText}`);\n }\n\n return (await response.json()) as Promise<T>;\n }\n\n // Core content operations\n async getContent(id: string): Promise<ContentEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/content/${id}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch content: ${response.statusText}`);\n }\n return (await response.json()) as ContentEntry;\n } catch (error) {\n console.error('Error fetching content:', error);\n throw error;\n }\n }\n\n async getLocalized(id: string, locale: string): Promise<LocalizedEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/content/${id}/${locale}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch localized content: ${response.statusText}`);\n }\n return (await response.json()) as LocalizedEntry;\n } catch (error) {\n console.error('Error fetching localized content:', error);\n throw error;\n }\n }\n\n async createContent(data: CreateContentInput): Promise<CreateResult> {\n return this.fetchAPI<CreateResult>(`${this.baseUrl}/content`, {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n async updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult> {\n const { id, locale, data, etag } = input;\n const params = new URLSearchParams({ locale, etag });\n return this.fetchAPI<UpdateResult>(`${this.baseUrl}/content/${id}?${params}`, {\n method: 'PUT',\n body: JSON.stringify(data),\n });\n }\n\n async deleteContent(id: string, etag: string): Promise<DeleteResult> {\n return this.fetchAPI<DeleteResult>(`${this.baseUrl}/content/${id}`, {\n method: 'DELETE',\n headers: {\n 'If-Match': etag,\n },\n });\n }\n\n async deleteLocalized(input: { id: string; locale: string; etag: string }): Promise<DeleteResult> {\n return this.fetchAPI<DeleteResult>(`${this.baseUrl}/content/${input.id}?locale=${input.locale}`, {\n method: 'DELETE',\n headers: {\n 'If-Match': input.etag,\n },\n });\n }\n\n // Site operations\n async getSitePages(site: string, locale?: string): Promise<ContentListResult> {\n const url = locale ? `${this.baseUrl}/${site}/pages?locale=${locale}` : `${this.baseUrl}/${site}/pages`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getPageByPathname(site: string, pathname: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const url = locale\n ? `${this.baseUrl}/sites/${site}/pathname${pathname}?locale=${locale}`\n : `${this.baseUrl}/sites/${site}/pathname${pathname}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch page: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching page by pathname:', error);\n throw error;\n }\n }\n\n async isPathnameAvailable(site: string, pathname: string, excludeId?: string): Promise<boolean> {\n const params = new URLSearchParams({\n pathname,\n ...(excludeId && { excludeId }),\n });\n\n const response = await this.fetch(`${this.baseUrl}/${site}/pathname-available?${params}`);\n if (!response.ok) {\n throw new Error(`Failed to check pathname availability: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { available: boolean };\n return data.available;\n }\n\n async movePage(site: string, id: string, pathname: string, locale: string, etag: string): Promise<MoveResult> {\n return this.fetchAPI<MoveResult>(`${this.baseUrl}/${site}/move`, {\n method: 'POST',\n body: JSON.stringify({ id, pathname, locale, etag }),\n });\n }\n\n // Block operations\n async getBlocks(collection?: string, locale?: string): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/blocks${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getBlockByName(name: string, collection?: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/blocks/${name}${params.toString() ? `?${params}` : ''}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch block: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching block by name:', error);\n throw error;\n }\n }\n\n // Data operations\n async getData(collection?: string, locale?: string): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/data${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getDataByName(name: string, collection: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const params = new URLSearchParams();\n params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/data/${name}?${params}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch data entry: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching data entry by name:', error);\n throw error;\n }\n }\n\n async isDataNameAvailable(name: string, collection: string, excludeId?: string): Promise<boolean> {\n const params = new URLSearchParams({\n name,\n collection,\n ...(excludeId && { excludeId }),\n });\n\n const response = await this.fetch(`${this.baseUrl}/data/name-available?${params}`);\n if (!response.ok) {\n throw new Error(`Failed to check data name availability: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { available: boolean };\n return data.available;\n }\n\n async getDataCollections(): Promise<string[]> {\n const response = await this.fetchAPI<{ collections: string[] }>(`${this.baseUrl}/data/collections`);\n return response.collections;\n }\n\n // Global operations\n async listAllContent(filters?: GlobalFilters): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (filters?.site) params.set('site', filters.site);\n if (filters?.collection) params.set('collection', filters.collection);\n if (filters?.locales?.length) params.set('locales', filters.locales.join(','));\n if (filters?.type) params.set('type', filters.type);\n if (filters?.published !== undefined) params.set('published', String(filters.published));\n if (filters?.kind) params.set('kind', filters.kind);\n if (filters?.localization) params.set('localization', filters.localization);\n if (filters?.missingLocales?.length) params.set('missingLocales', filters.missingLocales.join(','));\n\n const url = `${this.baseUrl}/content${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async findUntranslatedContent(\n targetLocale: string,\n excludeSites?: string[],\n includeUnpublished?: boolean,\n ): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (excludeSites?.length) params.set('excludeSites', excludeSites.join(','));\n if (includeUnpublished) params.set('includeUnpublished', 'true');\n\n const url = `${this.baseUrl}/untranslated/${targetLocale}${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getSitesConfig(): Promise<SitesConfig> {\n return this.fetchAPI<SitesConfig>(`${this.baseUrl}/sites`);\n }\n\n // Batch operations\n async batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult> {\n return this.fetchAPI<BatchResult>(`${this.baseUrl}/content/batch`, {\n method: 'POST',\n body: JSON.stringify({ operations }),\n });\n }\n\n // Git operations\n async getGitStatus(): Promise<GitStatus> {\n return this.fetchAPI<GitStatus>(`${this.baseUrl}/git/status`);\n }\n\n async commitChanges(message?: string): Promise<GitCommitResult> {\n return this.fetchAPI<GitCommitResult>(`${this.baseUrl}/git/commit`, {\n method: 'POST',\n body: JSON.stringify(message ? { message } : {}),\n });\n }\n\n async pushChanges(): Promise<GitPushResult> {\n return this.fetchAPI<GitPushResult>(`${this.baseUrl}/git/push`, {\n method: 'POST',\n body: JSON.stringify({}),\n });\n }\n\n async pullChanges(): Promise<GitPullResult> {\n return this.fetchAPI<GitPullResult>(`${this.baseUrl}/git/pull`, {\n method: 'POST',\n body: JSON.stringify({}),\n });\n }\n\n // Asset operations\n async listAssets(): Promise<{ assets: AssetEntry[] }> {\n return this.fetchAPI<{ assets: AssetEntry[] }>(`${this.baseUrl}/assets`);\n }\n\n async getAsset(filename: string): Promise<AssetEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/assets/${encodeURIComponent(filename)}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch asset: ${response.statusText}`);\n }\n return (await response.json()) as AssetEntry;\n } catch (error) {\n console.error('Error fetching asset:', error);\n throw error;\n }\n }\n\n async uploadAsset(formData: FormData): Promise<{ success: true; asset: AssetEntry }> {\n const response = await this.fetch(`${this.baseUrl}/assets/upload`, {\n method: 'POST',\n body: formData,\n // No Content-Type header — browser sets multipart boundary automatically\n });\n\n if (!response.ok) {\n let errorData: { error?: { message?: string } } | undefined;\n try {\n errorData = (await response.json()) as { error?: { message?: string } };\n } catch {\n // ignore\n }\n throw new Error(errorData?.error?.message || `Upload failed: ${response.status} ${response.statusText}`);\n }\n\n return (await response.json()) as { success: true; asset: AssetEntry };\n }\n\n async importAssetUrl(url: string, alt?: string, folder?: string): Promise<{ success: true; asset: AssetEntry }> {\n return this.fetchAPI<{ success: true; asset: AssetEntry }>(`${this.baseUrl}/assets/import-url`, {\n method: 'POST',\n body: JSON.stringify({ url, alt, folder }),\n });\n }\n\n async deleteAsset(filename: string): Promise<{ success: boolean }> {\n return this.fetchAPI<{ success: boolean }>(`${this.baseUrl}/assets/${encodeURIComponent(filename)}`, {\n method: 'DELETE',\n });\n }\n\n // Folder operations\n async listFolder(path = '/'): Promise<FolderListing> {\n const params = new URLSearchParams({ path });\n return this.fetchAPI<FolderListing>(`${this.baseUrl}/assets/folders?${params}`);\n }\n\n async createFolder(path: string): Promise<void> {\n await this.fetch(`${this.baseUrl}/assets/folders`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ path }),\n });\n }\n\n // Asset metadata operations\n async updateAssetMetadata(filename: string, updates: { alt?: string; tags?: string[] }): Promise<AssetEntry> {\n return this.fetchAPI<AssetEntry>(`${this.baseUrl}/assets/${encodeURIComponent(filename)}`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n // Asset usage tracking\n async getAssetUsage(filename: string): Promise<AssetUsage[]> {\n return this.fetchAPI<AssetUsage[]>(`${this.baseUrl}/assets/${encodeURIComponent(filename)}/usage`);\n }\n\n // Move assets between folders\n async moveAssets(\n filenames: string[],\n sourceFolder: string,\n targetFolder: string,\n ): Promise<{ success: boolean; moved?: number; error?: string }> {\n return this.fetchAPI<{ success: boolean; moved?: number; error?: string }>(`${this.baseUrl}/assets/move`, {\n method: 'POST',\n body: JSON.stringify({ filenames, sourceFolder, targetFolder }),\n });\n }\n\n // Get folder tree structure\n async getFolderTree(): Promise<{ tree: FolderTreeNode[] }> {\n return this.fetchAPI<{ tree: FolderTreeNode[] }>(`${this.baseUrl}/assets/folder-tree`);\n }\n\n // Auth operations\n async getCurrentUser(): Promise<{ authenticated: boolean; user?: { email: string; sub: string } }> {\n const response = await this.fetch(`${this.baseUrl}/auth/user`);\n if (!response.ok) {\n return { authenticated: false };\n }\n return response.json() as Promise<{ authenticated: boolean; user?: { email: string; sub: string } }>;\n }\n}\n\n// Custom error for API responses\nexport class APIClientError extends Error {\n constructor(\n message: string,\n public code: ErrorCode,\n public details?: any,\n ) {\n super(message);\n this.name = 'APIClientError';\n }\n}\n\n// Custom error for stale writes\nexport class StaleWriteError extends APIClientError {\n constructor(public data: { code: ErrorCode; message: string; currentEtag?: string }) {\n super(data.message, data.code, { currentEtag: data.currentEtag });\n this.name = 'StaleWriteError';\n }\n\n get currentEtag(): string | undefined {\n return this.details?.currentEtag;\n }\n}\n","import type {\n ContentEntry,\n ContentListResult,\n ContentManifest,\n CreateContentInput,\n GlobalFilters,\n LocalizedEntry,\n UpdateLocaleInput,\n} from '@conloca/content-api';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport {\n APIClientError,\n ContentAPIClient,\n type GitCommitResult,\n type GitPullResult,\n type GitPushResult,\n type GitStatus,\n StaleWriteError,\n} from './client';\n\n// Global client instance\nlet globalClient: ContentAPIClient | null = null;\n\nexport function getContentAPIClient(): ContentAPIClient {\n if (!globalClient) {\n globalClient = new ContentAPIClient();\n }\n return globalClient;\n}\n\nexport function setContentAPIClient(client: ContentAPIClient): void {\n globalClient = client;\n}\n\n// ===== Type Guards =====\nfunction isContentListResult(value: unknown): value is ContentListResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'items' in value &&\n 'total' in value &&\n Array.isArray((value as { items: unknown }).items) &&\n typeof (value as { total: unknown }).total === 'number'\n );\n}\n\n// ===== Query Keys =====\nconst queryKeys = {\n currentUser: () => ['auth', 'user'] as const,\n gitStatus: () => ['git', 'status'] as const,\n content: (id: string) => ['content', id] as const,\n localized: (id: string, locale: string) => ['content', id, locale] as const,\n sitePages: (site: string, locale?: string) => ['sites', site, 'pages', locale] as const,\n pageByPathname: (site: string, pathname: string, locale?: string) =>\n ['sites', site, 'pathname', pathname, locale] as const,\n pathnameAvailability: (site: string, pathname: string, excludeId?: string) =>\n ['sites', site, 'pathname-availability', pathname, excludeId] as const,\n blocks: (collection?: string, locale?: string) => ['blocks', collection, locale] as const,\n blockByName: (name: string, collection?: string, locale?: string) => ['blocks', name, collection, locale] as const,\n data: (collection?: string, locale?: string) => ['data', collection, locale] as const,\n dataByName: (name: string, collection: string, locale?: string) => ['data', name, collection, locale] as const,\n dataNameAvailability: (name: string, collection: string, excludeId?: string) =>\n ['data', 'name-availability', name, collection, excludeId] as const,\n dataCollections: () => ['data', 'collections'] as const,\n allContent: (filters?: GlobalFilters) => ['content', 'all', filters] as const,\n untranslatedContent: (targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean) =>\n ['content', 'untranslated', targetLocale, excludeSites, includeUnpublished] as const,\n sitesConfig: () => ['sites', 'config'] as const,\n assets: () => ['assets'] as const,\n asset: (filename: string) => ['assets', filename] as const,\n assetFolders: (path?: string) => ['asset-folders', path] as const,\n assetUsage: (filename: string | null) => ['asset-usage', filename] as const,\n folderTree: () => ['folder-tree'] as const,\n};\n\n// ===== Core Content Hooks =====\n\nexport function useContent(id: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.content(id),\n queryFn: () => client.getContent(id),\n enabled: !!id,\n });\n}\n\nexport function useLocalizedContent(id: string, locale: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.localized(id, locale),\n queryFn: () => client.getLocalized(id, locale),\n enabled: !!id && !!locale,\n });\n}\n\n// ===== Mutation Hooks =====\n\nexport function useCreateContent() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (data: CreateContentInput) => {\n const result = await client.createContent(data);\n if (result.success && result.id) {\n // Fetch the full content to get server-generated data\n const fullContent = await client.getContent(result.id);\n return { ...result, fullContent };\n }\n return result;\n },\n onSuccess: (result, variables) => {\n if (result.success && result.id && 'fullContent' in result && result.fullContent) {\n // Cache the server's response\n queryClient.setQueryData(queryKeys.content(result.id), result.fullContent);\n\n // Update list queries by adding the new item from server data\n const newManifest: ContentManifest = {\n id: result.fullContent.id,\n type: result.fullContent.type,\n kind: result.fullContent.kind,\n site: result.fullContent.site,\n collection: result.fullContent.collection,\n locales: Object.entries(result.fullContent.locales).reduce(\n (acc, [locale, localeData]) => {\n const { content, ...manifestData } = localeData;\n acc[locale] = manifestData;\n return acc;\n },\n {} as ContentManifest['locales'],\n ),\n };\n\n if (variables.kind === 'page' && variables.site) {\n queryClient.setQueriesData(\n { queryKey: queryKeys.sitePages(variables.site) },\n (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: [...old.items, newManifest],\n total: old.total + 1,\n };\n },\n );\n } else if (variables.kind === 'block') {\n // Invalidate all block queries to ensure the new block appears everywhere\n queryClient.invalidateQueries({ queryKey: ['blocks'] });\n } else if (variables.kind === 'data') {\n // Invalidate all data queries to ensure the new data entry appears everywhere\n queryClient.invalidateQueries({ queryKey: ['data'] });\n }\n }\n },\n });\n}\n\nexport function useUpdateLocalized() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (input: UpdateLocaleInput) => {\n const result = await client.updateLocalized(input);\n if (result.success) {\n // Fetch the updated localized content to get server-processed data\n const updatedContent = await client.getLocalized(input.id, input.locale);\n return { ...result, updatedContent };\n }\n return result;\n },\n onSuccess: (result, variables) => {\n if (result.success && 'updatedContent' in result && result.updatedContent) {\n // Update the localized content query with server data\n queryClient.setQueryData(queryKeys.localized(variables.id, variables.locale), result.updatedContent);\n\n // Update the full content entry\n queryClient.setQueryData(queryKeys.content(variables.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n return {\n ...old,\n locales: {\n ...old.locales,\n [variables.locale]: result.updatedContent!.localized,\n },\n };\n });\n\n // Update list queries to reflect the server data\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: old.items.map((item) =>\n item.id === variables.id\n ? {\n ...item,\n locales: {\n ...item.locales,\n [variables.locale]: {\n locale: result.updatedContent!.localized.locale,\n etag: result.updatedContent!.localized.etag,\n created: result.updatedContent!.localized.created,\n modified: result.updatedContent!.localized.modified,\n pathname: result.updatedContent!.localized.pathname,\n previousPathnames: result.updatedContent!.localized.previousPathnames,\n name: result.updatedContent!.localized.name,\n publishAt: result.updatedContent!.localized.publishAt,\n unpublishAt: result.updatedContent!.localized.unpublishAt,\n meta: result.updatedContent!.localized.meta,\n },\n },\n }\n : item,\n ),\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n }\n },\n });\n}\n\ninterface DeleteContentArgs {\n id: string;\n etag: string;\n locale?: string;\n}\n\nexport function useDeleteContent() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ id, etag, locale }: DeleteContentArgs) => {\n // If locale is provided, it's a locale-specific delete\n if (locale) {\n return client.deleteLocalized({ id, locale, etag });\n }\n // Otherwise, delete entire content\n return client.deleteContent(id, etag);\n },\n onSuccess: (result, variables) => {\n if (result.success) {\n if (variables.locale) {\n // For locale-specific deletion, update the content entry to remove the locale\n queryClient.setQueryData(queryKeys.content(variables.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n const locale = variables.locale!;\n const { [locale]: _, ...remainingLocales } = old.locales;\n return {\n ...old,\n locales: remainingLocales,\n };\n });\n\n // Update list queries to remove the locale from the item\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const locale = variables.locale!;\n return {\n ...old,\n items: old.items\n .map((item) => {\n if (item.id === variables.id) {\n const { [locale]: _, ...remainingLocales } = item.locales;\n return {\n ...item,\n locales: remainingLocales,\n };\n }\n return item;\n })\n .filter((item) => Object.keys(item.locales).length > 0), // Remove items with no locales\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['content', 'all'], exact: false }, updateListQueries);\n } else {\n // For full deletion, remove from cache\n queryClient.removeQueries({ queryKey: queryKeys.content(variables.id) });\n queryClient.removeQueries({ queryKey: ['content', variables.id], exact: false });\n\n // Update list queries by removing the deleted item\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update block lists\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update data lists\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update all content queries\n queryClient.setQueriesData(\n { queryKey: ['content', 'all'], exact: false },\n (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n },\n );\n }\n }\n },\n });\n}\n\ninterface DeleteLocalizedArgs {\n id: string;\n locale: string;\n etag: string;\n}\n\nexport function useDeleteLocalized() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ id, locale, etag }: DeleteLocalizedArgs) => client.deleteLocalized({ id, locale, etag }),\n onSuccess: (result, variables) => {\n if (result.success) {\n // Invalidate specific locale query\n queryClient.invalidateQueries({\n queryKey: queryKeys.localized(variables.id, variables.locale),\n });\n // Invalidate the full content query\n queryClient.invalidateQueries({ queryKey: queryKeys.content(variables.id) });\n }\n },\n });\n}\n\n// ===== Site Hooks =====\n\nexport function useSitePages(site: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.sitePages(site, locale),\n queryFn: () => client.getSitePages(site, locale),\n });\n}\n\nexport function usePageByPathname(site: string, pathname: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.pageByPathname(site, pathname, locale),\n queryFn: () => client.getPageByPathname(site, pathname, locale),\n enabled: !!pathname,\n });\n}\n\nexport function usePathnameAvailability(site: string, pathname: string, excludeId?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.pathnameAvailability(site, pathname, excludeId),\n queryFn: async () => {\n const available = await client.isPathnameAvailable(site, pathname, excludeId);\n return { available };\n },\n enabled: !!site && !!pathname,\n // For pathname validation, we want immediate feedback\n staleTime: 0,\n gcTime: 0,\n });\n}\n\ninterface MovePageArgs {\n site: string;\n id: string;\n pathname: string;\n locale?: string;\n etag: string;\n}\n\nexport function useMovePage() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ site, id, pathname, locale = 'en', etag }: MovePageArgs) =>\n client.movePage(site, id, pathname, locale, etag),\n onSuccess: (result, variables) => {\n if (result.moved) {\n // Invalidate site pages and content queries\n queryClient.invalidateQueries({ queryKey: ['sites', variables.site] });\n queryClient.invalidateQueries({ queryKey: queryKeys.content(variables.id) });\n }\n },\n });\n}\n\n// ===== Block Hooks =====\n\nexport function useBlocks(collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.blocks(collection, locale),\n queryFn: () => client.getBlocks(collection, locale),\n });\n}\n\nexport function useBlockByName(name: string, collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.blockByName(name, collection, locale),\n queryFn: () => client.getBlockByName(name, collection, locale),\n enabled: !!name,\n });\n}\n\n// ===== Data Hooks =====\n\nexport function useData(collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.data(collection, locale),\n queryFn: () => client.getData(collection, locale),\n });\n}\n\nexport function useDataByName(name: string, collection: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataByName(name, collection, locale),\n queryFn: () => client.getDataByName(name, collection, locale),\n enabled: !!name && !!collection,\n });\n}\n\nexport function useDataNameAvailability(name: string, collection: string, excludeId?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataNameAvailability(name, collection, excludeId),\n queryFn: async () => {\n const available = await client.isDataNameAvailable(name, collection, excludeId);\n return { available };\n },\n enabled: !!name && !!collection,\n staleTime: 0,\n gcTime: 0,\n });\n}\n\nexport function useDataCollections() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataCollections(),\n queryFn: () => client.getDataCollections(),\n });\n}\n\n// ===== Global Hooks =====\n\nexport function useAllContent(filters?: GlobalFilters) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.allContent(filters),\n queryFn: () => client.listAllContent(filters),\n });\n}\n\nexport function useUntranslatedContent(targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.untranslatedContent(targetLocale, excludeSites, includeUnpublished),\n queryFn: () => client.findUntranslatedContent(targetLocale, excludeSites, includeUnpublished),\n });\n}\n\nexport function useSitesConfig() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.sitesConfig(),\n queryFn: () => client.getSitesConfig(),\n });\n}\n\n// ===== Auth Hooks =====\n\nexport function useCurrentUser() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.currentUser(),\n queryFn: () => client.getCurrentUser(),\n staleTime: 60000, // Cache for 1 minute (user doesn't change often)\n });\n}\n\n// ===== Batch Operations =====\n\nexport function useBatchUpdate() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (operations: UpdateLocaleInput[]) => {\n const result = await client.batchUpdate(operations);\n\n // Fetch updated content for successful operations\n if (result.operations && result.updated > 0) {\n const updatedContents = await Promise.all(\n result.operations.map(async (opResult, index) => {\n if (opResult.updated) {\n const op = operations[index];\n const updated = await client.getLocalized(op.id, op.locale);\n return { index, content: updated };\n }\n return null;\n }),\n );\n\n return {\n ...result,\n updatedContents: updatedContents.filter(\n (item): item is { index: number; content: LocalizedEntry } => item !== null,\n ),\n };\n }\n\n return result;\n },\n onSuccess: (result, variables) => {\n if ('updatedContents' in result && result.updatedContents) {\n // Update caches with the fetched server data\n result.updatedContents.forEach(({ index, content }) => {\n if (!content) return;\n\n const operation = variables[index!];\n\n // Update localized content\n queryClient.setQueryData(queryKeys.localized(operation.id, operation.locale), content);\n\n // Update full content entry\n queryClient.setQueryData(queryKeys.content(operation.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n return {\n ...old,\n locales: {\n ...old.locales,\n [operation.locale]: content.localized,\n },\n };\n });\n });\n\n // Update list queries with server data\n const updatedMap = new Map(\n result.updatedContents.map(({ index, content }) => {\n const op = variables[index!];\n return [op.id + ':' + op.locale, content];\n }),\n );\n\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: old.items.map((item) => {\n const hasUpdate = Object.keys(item.locales).some((locale) => updatedMap.has(item.id + ':' + locale));\n\n if (hasUpdate) {\n const newLocales = { ...item.locales };\n Object.keys(newLocales).forEach((locale) => {\n const updated = updatedMap.get(item.id + ':' + locale);\n if (updated) {\n const { content, ...manifestData } = updated.localized;\n newLocales[locale] = manifestData;\n }\n });\n return { ...item, locales: newLocales };\n }\n\n return item;\n }),\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n }\n },\n });\n}\n\n// ===== Git Hooks =====\n\nexport function useGitStatus() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.gitStatus(),\n queryFn: () => client.getGitStatus(),\n refetchInterval: 10000,\n staleTime: 5000,\n });\n}\n\nexport function useCommitChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: (message: string | undefined) => client.commitChanges(message),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\nexport function usePushChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: () => client.pushChanges(),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\nexport function usePullChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: () => client.pullChanges(),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\n// ===== Asset Hooks =====\n\nexport function useAssets() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.assets(),\n queryFn: () => client.listAssets(),\n });\n}\n\nexport function useAsset(filename: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.asset(filename),\n queryFn: () => client.getAsset(filename),\n enabled: !!filename,\n });\n}\n\nexport function useUploadAsset() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (formData: FormData) => client.uploadAsset(formData),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useImportAssetUrl() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ url, alt, folder }: { url: string; alt?: string; folder?: string }) =>\n client.importAssetUrl(url, alt, folder),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useDeleteAsset() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (filename: string) => client.deleteAsset(filename),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\n// ===== Media Library Hooks =====\n\nexport function useAssetFolders(path?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.assetFolders(path),\n queryFn: () => client.listFolder(path),\n });\n}\n\nexport function useCreateFolder() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (path: string) => client.createFolder(path),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useUpdateAssetMetadata() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ filename, updates }: { filename: string; updates: { alt?: string; tags?: string[] } }) =>\n client.updateAssetMetadata(filename, updates),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useAssetUsage(filename: string | null) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.assetUsage(filename),\n queryFn: () => client.getAssetUsage(filename!),\n enabled: !!filename,\n staleTime: 60_000, // Cache usage for 1 minute to avoid repeated VXJSON scans\n });\n}\n\nexport function useFolderTree() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.folderTree(),\n queryFn: () => client.getFolderTree(),\n staleTime: 30_000, // Cache for 30 seconds\n });\n}\n\nexport function useMoveAssets() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({\n filenames,\n sourceFolder,\n targetFolder,\n }: {\n filenames: string[];\n sourceFolder: string;\n targetFolder: string;\n }) => client.moveAssets(filenames, sourceFolder, targetFolder),\n onSuccess: () => {\n // Invalidate all folder-related queries to refresh counts and listings\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n queryClient.invalidateQueries({ queryKey: queryKeys.folderTree() });\n },\n });\n}\n\n// Re-export for convenience\nexport { ContentAPIClient, StaleWriteError, APIClientError };\nexport type { GitStatus, GitCommitResult, GitPushResult, GitPullResult };\n"],"mappings":";;;;;AAwDA,IAAa,mBAAb,MAA8B;CAC5B,AAAQ;CACR,AAAQ;CAER,YAAY,UAAmC,EAAE,EAAE;AAEjD,MAAI,QAAQ,MACV,MAAK,QAAQ,QAAQ;WACZ,OAAO,eAAe,eAAe,WAAW,MAEzD,MAAK,QAAQ,WAAW,MAAM,KAAK,WAAW;MAE9C,MAAK,QAAQ;AAEf,OAAK,UAAU,QAAQ,WAAW;;CAGpC,MAAc,SAAY,KAAa,SAAmC;EACxE,MAA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yBAAyB;CACvC,MAAM,SAAS,qBAAqB;CACpC,MAAM,cAAc,gBAAgB;AAEpC,QAAO,YAAY;EACjB,aAAa,EAAE,UAAU,cACvB,OAAO,oBAAoB,UAAU,QAAQ;EAC/C,iBAAiB;AACf,eAAY,kBAAkB,EAAE,UAAU,UAAU,QAAQ,EAAE,CAAC;AAC/D,eAAY,kBAAkB,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC;;EAEjE,CAAC;;AAGJ,SAAgB,cAAc,UAAyB;CACrD,MAAM,SAAS,qBAAqB;AAEpC,QAAO,SAAS;EACd,UAAU,UAAU,WAAW,SAAS;EACxC,eAAe,OAAO,cAAc,SAAU;EAC9C,SAAS,CAAC,CAAC;EACX,WAAW;EACZ,CAAC;;AAGJ,SAAgB,gBAAgB;CAC9B,MAAM,SAAS,qBAAqB;AAEpC,QAAO,SAAS;EACd,UAAU,UAAU,YAAY;EAChC,eAAe,OAAO,eAAe;EACrC,WAAW;EACZ,CAAC;;AAGJ,SAAgB,gBAAgB;CAC9B,MAAM,SAAS,qBAAqB;CACpC,MAAM,cAAc,gBAAgB;AAEpC,QAAO,YAAY;EACjB,aAAa,EACX,WACA,cACA,mBAKI,OAAO,WAAW,WAAW,cAAc,aAAa;EAC9D,iBAAiB;AAEf,eAAY,kBAAkB,EAAE,UAAU,UAAU,QAAQ,EAAE,CAAC;AAC/D,eAAY,kBAAkB,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC;AAC9D,eAAY,kBAAkB,EAAE,UAAU,UAAU,YAAY,EAAE,CAAC;;EAEtE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ErrorCodes"],"sources":["../src/client.ts","../src/hooks.tsx"],"sourcesContent":["import type {\n APIError,\n AssetEntry,\n AssetUsage,\n BatchResult,\n ContentEntry,\n ContentListResult,\n ContentManifest,\n CreateContentInput,\n CreateResult,\n DataContext,\n DeleteResult,\n ErrorCode,\n FolderListing,\n FolderTreeNode,\n GitCommitResult,\n GitPullResult,\n GitPushResult,\n GitStatus,\n GlobalFilters,\n LocalizedEntry,\n MoveResult,\n SitesConfig,\n UpdateLocaleInput,\n UpdateResult,\n} from '@conloca/content-api';\nimport { ErrorCodes } from '@conloca/content-api';\n\nexport interface ContentAPIClientOptions {\n baseUrl?: string;\n fetch?: typeof fetch;\n}\n\nexport class ContentAPIClient {\n private baseUrl: string;\n private fetch: typeof fetch;\n\n constructor(options: ContentAPIClientOptions = {}) {\n // Bind fetch to maintain its context\n if (options.fetch) {\n this.fetch = options.fetch;\n } else if (typeof globalThis !== 'undefined' && globalThis.fetch) {\n // Use globalThis for better compatibility\n this.fetch = globalThis.fetch.bind(globalThis);\n } else {\n this.fetch = fetch;\n }\n this.baseUrl = options.baseUrl || '/__conloca/api';\n }\n\n private encodeAssetPath(filename: string): string {\n return filename\n .split('/')\n .map((s) => encodeURIComponent(s))\n .join('/');\n }\n\n private async fetchAPI<T>(url: string, options?: RequestInit): Promise<T> {\n const response = await this.fetch(url, {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options?.headers,\n },\n });\n\n if (!response.ok) {\n let errorData: any;\n try {\n errorData = await response.json();\n } catch {\n // If JSON parsing fails, throw generic error\n throw new Error(`API error: ${response.status} ${response.statusText}`);\n }\n\n // Check if it's an APIError format\n if (errorData?.error?.code) {\n const apiError = errorData as APIError;\n\n // Special handling for stale writes\n if (apiError.error.code === ErrorCodes.STALE_WRITE) {\n throw new StaleWriteError({\n code: apiError.error.code,\n message: apiError.error.message,\n currentEtag: apiError.error.details?.currentEtag,\n });\n }\n\n // Create a proper error with code and details\n const error = new APIClientError(\n apiError.error.message,\n apiError.error.code as ErrorCode,\n apiError.error.details,\n );\n throw error;\n }\n\n // Fallback for non-standard error responses\n throw new Error(`API error: ${response.status} ${response.statusText}`);\n }\n\n return (await response.json()) as Promise<T>;\n }\n\n // Core content operations\n async getContent(id: string): Promise<ContentEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/content/${id}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch content: ${response.statusText}`);\n }\n return (await response.json()) as ContentEntry;\n } catch (error) {\n console.error('Error fetching content:', error);\n throw error;\n }\n }\n\n async getLocalized(id: string, locale: string): Promise<LocalizedEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/content/${id}/${locale}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch localized content: ${response.statusText}`);\n }\n return (await response.json()) as LocalizedEntry;\n } catch (error) {\n console.error('Error fetching localized content:', error);\n throw error;\n }\n }\n\n async createContent(data: CreateContentInput): Promise<CreateResult> {\n return this.fetchAPI<CreateResult>(`${this.baseUrl}/content`, {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n async updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult> {\n const { id, locale, data, etag } = input;\n const params = new URLSearchParams({ locale, etag });\n return this.fetchAPI<UpdateResult>(`${this.baseUrl}/content/${id}?${params}`, {\n method: 'PUT',\n body: JSON.stringify(data),\n });\n }\n\n async deleteContent(id: string, etag: string): Promise<DeleteResult> {\n return this.fetchAPI<DeleteResult>(`${this.baseUrl}/content/${id}`, {\n method: 'DELETE',\n headers: {\n 'If-Match': etag,\n },\n });\n }\n\n async deleteLocalized(input: { id: string; locale: string; etag: string }): Promise<DeleteResult> {\n return this.fetchAPI<DeleteResult>(`${this.baseUrl}/content/${input.id}?locale=${input.locale}`, {\n method: 'DELETE',\n headers: {\n 'If-Match': input.etag,\n },\n });\n }\n\n // Site operations\n async getSitePages(site: string, locale?: string): Promise<ContentListResult> {\n const url = locale ? `${this.baseUrl}/${site}/pages?locale=${locale}` : `${this.baseUrl}/${site}/pages`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getPageByPathname(site: string, pathname: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const url = locale\n ? `${this.baseUrl}/sites/${site}/pathname${pathname}?locale=${locale}`\n : `${this.baseUrl}/sites/${site}/pathname${pathname}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch page: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching page by pathname:', error);\n throw error;\n }\n }\n\n async isPathnameAvailable(site: string, pathname: string, excludeId?: string): Promise<boolean> {\n const params = new URLSearchParams({\n pathname,\n ...(excludeId && { excludeId }),\n });\n\n const response = await this.fetch(`${this.baseUrl}/${site}/pathname-available?${params}`);\n if (!response.ok) {\n throw new Error(`Failed to check pathname availability: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { available: boolean };\n return data.available;\n }\n\n async movePage(site: string, id: string, pathname: string, locale: string, etag: string): Promise<MoveResult> {\n return this.fetchAPI<MoveResult>(`${this.baseUrl}/${site}/move`, {\n method: 'POST',\n body: JSON.stringify({ id, pathname, locale, etag }),\n });\n }\n\n // Block operations\n async getBlocks(collection?: string, locale?: string): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/blocks${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getBlockByName(name: string, collection?: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/blocks/${name}${params.toString() ? `?${params}` : ''}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch block: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching block by name:', error);\n throw error;\n }\n }\n\n // Data operations\n async getData(collection?: string, locale?: string): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/data${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getDataByName(name: string, collection: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const params = new URLSearchParams();\n params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/data/${name}?${params}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch data entry: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching data entry by name:', error);\n throw error;\n }\n }\n\n async isDataNameAvailable(name: string, collection: string, excludeId?: string): Promise<boolean> {\n const params = new URLSearchParams({\n name,\n collection,\n ...(excludeId && { excludeId }),\n });\n\n const response = await this.fetch(`${this.baseUrl}/data/name-available?${params}`);\n if (!response.ok) {\n throw new Error(`Failed to check data name availability: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { available: boolean };\n return data.available;\n }\n\n async getDataCollections(): Promise<string[]> {\n const response = await this.fetchAPI<{ collections: string[] }>(`${this.baseUrl}/data/collections`);\n return response.collections;\n }\n\n // Data context operations\n async getDataContext(pageId: string): Promise<{ dataContext: DataContext }> {\n return this.fetchAPI<{ dataContext: DataContext }>(`${this.baseUrl}/data-context?pageId=${pageId}`);\n }\n\n // Global operations\n async listAllContent(filters?: GlobalFilters): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (filters?.site) params.set('site', filters.site);\n if (filters?.collection) params.set('collection', filters.collection);\n if (filters?.locales?.length) params.set('locales', filters.locales.join(','));\n if (filters?.type) params.set('type', filters.type);\n if (filters?.published !== undefined) params.set('published', String(filters.published));\n if (filters?.kind) params.set('kind', filters.kind);\n if (filters?.localization) params.set('localization', filters.localization);\n if (filters?.missingLocales?.length) params.set('missingLocales', filters.missingLocales.join(','));\n\n const url = `${this.baseUrl}/content${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async findUntranslatedContent(\n targetLocale: string,\n excludeSites?: string[],\n includeUnpublished?: boolean,\n ): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (excludeSites?.length) params.set('excludeSites', excludeSites.join(','));\n if (includeUnpublished) params.set('includeUnpublished', 'true');\n\n const url = `${this.baseUrl}/untranslated/${targetLocale}${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getSitesConfig(): Promise<SitesConfig> {\n return this.fetchAPI<SitesConfig>(`${this.baseUrl}/sites`);\n }\n\n // Batch operations\n async batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult> {\n return this.fetchAPI<BatchResult>(`${this.baseUrl}/content/batch`, {\n method: 'POST',\n body: JSON.stringify({ operations }),\n });\n }\n\n // Git operations\n async getGitStatus(): Promise<GitStatus> {\n return this.fetchAPI<GitStatus>(`${this.baseUrl}/git/status`);\n }\n\n async commitChanges(message?: string): Promise<GitCommitResult> {\n return this.fetchAPI<GitCommitResult>(`${this.baseUrl}/git/commit`, {\n method: 'POST',\n body: JSON.stringify(message ? { message } : {}),\n });\n }\n\n async pushChanges(): Promise<GitPushResult> {\n return this.fetchAPI<GitPushResult>(`${this.baseUrl}/git/push`, {\n method: 'POST',\n body: JSON.stringify({}),\n });\n }\n\n async pullChanges(): Promise<GitPullResult> {\n return this.fetchAPI<GitPullResult>(`${this.baseUrl}/git/pull`, {\n method: 'POST',\n body: JSON.stringify({}),\n });\n }\n\n // Asset operations\n async listAssets(): Promise<{ assets: AssetEntry[] }> {\n return this.fetchAPI<{ assets: AssetEntry[] }>(`${this.baseUrl}/assets`);\n }\n\n async getAsset(filename: string): Promise<AssetEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch asset: ${response.statusText}`);\n }\n return (await response.json()) as AssetEntry;\n } catch (error) {\n console.error('Error fetching asset:', error);\n throw error;\n }\n }\n\n async uploadAsset(formData: FormData): Promise<{ success: true; asset: AssetEntry }> {\n const response = await this.fetch(`${this.baseUrl}/assets/upload`, {\n method: 'POST',\n body: formData,\n // No Content-Type header — browser sets multipart boundary automatically\n });\n\n if (!response.ok) {\n let errorData: { error?: { message?: string } } | undefined;\n try {\n errorData = (await response.json()) as { error?: { message?: string } };\n } catch {\n // ignore\n }\n throw new Error(errorData?.error?.message || `Upload failed: ${response.status} ${response.statusText}`);\n }\n\n return (await response.json()) as { success: true; asset: AssetEntry };\n }\n\n async importAssetUrl(url: string, alt?: string, folder?: string): Promise<{ success: true; asset: AssetEntry }> {\n return this.fetchAPI<{ success: true; asset: AssetEntry }>(`${this.baseUrl}/assets/import-url`, {\n method: 'POST',\n body: JSON.stringify({ url, alt, folder }),\n });\n }\n\n async deleteAsset(filename: string): Promise<{ success: boolean }> {\n return this.fetchAPI<{ success: boolean }>(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`, {\n method: 'DELETE',\n });\n }\n\n // Folder operations\n async listFolder(path = '/'): Promise<FolderListing> {\n const params = new URLSearchParams({ path });\n return this.fetchAPI<FolderListing>(`${this.baseUrl}/assets/folders?${params}`);\n }\n\n async createFolder(path: string): Promise<void> {\n await this.fetch(`${this.baseUrl}/assets/folders`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ path }),\n });\n }\n\n // Asset metadata operations\n async updateAssetMetadata(filename: string, updates: { alt?: string; tags?: string[] }): Promise<AssetEntry> {\n return this.fetchAPI<AssetEntry>(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n // Asset usage tracking\n async getAssetUsage(filename: string): Promise<AssetUsage[]> {\n return this.fetchAPI<AssetUsage[]>(`${this.baseUrl}/assets/usage/${this.encodeAssetPath(filename)}`);\n }\n\n // Move assets between folders\n async moveAssets(\n filenames: string[],\n sourceFolder: string,\n targetFolder: string,\n ): Promise<{ success: boolean; moved?: number; error?: string }> {\n return this.fetchAPI<{ success: boolean; moved?: number; error?: string }>(`${this.baseUrl}/assets/move`, {\n method: 'POST',\n body: JSON.stringify({ filenames, sourceFolder, targetFolder }),\n });\n }\n\n // Get folder tree structure\n async getFolderTree(): Promise<{ tree: FolderTreeNode[] }> {\n return this.fetchAPI<{ tree: FolderTreeNode[] }>(`${this.baseUrl}/assets/folder-tree`);\n }\n\n // Auth operations\n async getCurrentUser(): Promise<{ authenticated: boolean; user?: { email: string; sub: string } }> {\n const response = await this.fetch(`${this.baseUrl}/auth/user`);\n if (!response.ok) {\n return { authenticated: false };\n }\n return response.json() as Promise<{ authenticated: boolean; user?: { email: string; sub: string } }>;\n }\n}\n\n// Custom error for API responses\nexport class APIClientError extends Error {\n constructor(\n message: string,\n public code: ErrorCode,\n public details?: any,\n ) {\n super(message);\n this.name = 'APIClientError';\n }\n}\n\n// Custom error for stale writes\nexport class StaleWriteError extends APIClientError {\n constructor(public data: { code: ErrorCode; message: string; currentEtag?: string }) {\n super(data.message, data.code, { currentEtag: data.currentEtag });\n this.name = 'StaleWriteError';\n }\n\n get currentEtag(): string | undefined {\n return this.details?.currentEtag;\n }\n}\n","import type {\n ContentEntry,\n ContentListResult,\n ContentManifest,\n CreateContentInput,\n GitCommitResult,\n GitPullResult,\n GitPushResult,\n GitStatus,\n GlobalFilters,\n LocalizedEntry,\n UpdateLocaleInput,\n} from '@conloca/content-api';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { APIClientError, ContentAPIClient, StaleWriteError } from './client';\n\n// Global client instance\nlet globalClient: ContentAPIClient | null = null;\n\nexport function getContentAPIClient(): ContentAPIClient {\n if (!globalClient) {\n globalClient = new ContentAPIClient();\n }\n return globalClient;\n}\n\nexport function setContentAPIClient(client: ContentAPIClient): void {\n globalClient = client;\n}\n\n// ===== Type Guards =====\nfunction isContentListResult(value: unknown): value is ContentListResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'items' in value &&\n 'total' in value &&\n Array.isArray((value as { items: unknown }).items) &&\n typeof (value as { total: unknown }).total === 'number'\n );\n}\n\n// ===== Query Keys =====\nconst queryKeys = {\n currentUser: () => ['auth', 'user'] as const,\n gitStatus: () => ['git', 'status'] as const,\n content: (id: string) => ['content', id] as const,\n localized: (id: string, locale: string) => ['content', id, locale] as const,\n sitePages: (site: string, locale?: string) => ['sites', site, 'pages', locale] as const,\n pageByPathname: (site: string, pathname: string, locale?: string) =>\n ['sites', site, 'pathname', pathname, locale] as const,\n pathnameAvailability: (site: string, pathname: string, excludeId?: string) =>\n ['sites', site, 'pathname-availability', pathname, excludeId] as const,\n blocks: (collection?: string, locale?: string) => ['blocks', collection, locale] as const,\n blockByName: (name: string, collection?: string, locale?: string) => ['blocks', name, collection, locale] as const,\n data: (collection?: string, locale?: string) => ['data', collection, locale] as const,\n dataByName: (name: string, collection: string, locale?: string) => ['data', name, collection, locale] as const,\n dataNameAvailability: (name: string, collection: string, excludeId?: string) =>\n ['data', 'name-availability', name, collection, excludeId] as const,\n dataCollections: () => ['data', 'collections'] as const,\n dataContext: (pageId?: string) => ['data-context', pageId] as const,\n allContent: (filters?: GlobalFilters) => ['content', 'all', filters] as const,\n untranslatedContent: (targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean) =>\n ['content', 'untranslated', targetLocale, excludeSites, includeUnpublished] as const,\n sitesConfig: () => ['sites', 'config'] as const,\n assets: () => ['assets'] as const,\n asset: (filename: string) => ['assets', filename] as const,\n assetFolders: (path?: string) => ['asset-folders', path] as const,\n assetUsage: (filename: string | null) => ['asset-usage', filename] as const,\n folderTree: () => ['folder-tree'] as const,\n};\n\n// ===== Core Content Hooks =====\n\nexport function useContent(id: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.content(id),\n queryFn: () => client.getContent(id),\n enabled: !!id,\n });\n}\n\nexport function useLocalizedContent(id: string, locale: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.localized(id, locale),\n queryFn: () => client.getLocalized(id, locale),\n enabled: !!id && !!locale,\n });\n}\n\n// ===== Mutation Hooks =====\n\nexport function useCreateContent() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (data: CreateContentInput) => {\n const result = await client.createContent(data);\n if (result.success && result.id) {\n // Fetch the full content to get server-generated data\n const fullContent = await client.getContent(result.id);\n return { ...result, fullContent };\n }\n return result;\n },\n onSuccess: (result, variables) => {\n if (result.success && result.id && 'fullContent' in result && result.fullContent) {\n // Cache the server's response\n queryClient.setQueryData(queryKeys.content(result.id), result.fullContent);\n\n // Update list queries by adding the new item from server data\n const newManifest: ContentManifest = {\n id: result.fullContent.id,\n type: result.fullContent.type,\n kind: result.fullContent.kind,\n site: result.fullContent.site,\n collection: result.fullContent.collection,\n locales: Object.entries(result.fullContent.locales).reduce(\n (acc, [locale, localeData]) => {\n const { content, ...manifestData } = localeData;\n acc[locale] = manifestData;\n return acc;\n },\n {} as ContentManifest['locales'],\n ),\n };\n\n if (variables.kind === 'page' && variables.site) {\n queryClient.setQueriesData(\n { queryKey: queryKeys.sitePages(variables.site) },\n (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: [...old.items, newManifest],\n total: old.total + 1,\n };\n },\n );\n } else if (variables.kind === 'block') {\n // Invalidate all block queries to ensure the new block appears everywhere\n queryClient.invalidateQueries({ queryKey: ['blocks'] });\n } else if (variables.kind === 'data') {\n // Invalidate all data queries to ensure the new data entry appears everywhere\n queryClient.invalidateQueries({ queryKey: ['data'] });\n }\n }\n },\n });\n}\n\nexport function useUpdateLocalized() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (input: UpdateLocaleInput) => {\n const result = await client.updateLocalized(input);\n if (result.success) {\n // Fetch the updated localized content to get server-processed data\n const updatedContent = await client.getLocalized(input.id, input.locale);\n return { ...result, updatedContent };\n }\n return result;\n },\n onSuccess: (result, variables) => {\n if (result.success && 'updatedContent' in result && result.updatedContent) {\n // Update the localized content query with server data\n queryClient.setQueryData(queryKeys.localized(variables.id, variables.locale), result.updatedContent);\n\n // Update the full content entry\n queryClient.setQueryData(queryKeys.content(variables.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n return {\n ...old,\n locales: {\n ...old.locales,\n [variables.locale]: result.updatedContent!.localized,\n },\n };\n });\n\n // Update list queries to reflect the server data\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: old.items.map((item) =>\n item.id === variables.id\n ? {\n ...item,\n locales: {\n ...item.locales,\n [variables.locale]: {\n locale: result.updatedContent!.localized.locale,\n etag: result.updatedContent!.localized.etag,\n created: result.updatedContent!.localized.created,\n modified: result.updatedContent!.localized.modified,\n pathname: result.updatedContent!.localized.pathname,\n previousPathnames: result.updatedContent!.localized.previousPathnames,\n name: result.updatedContent!.localized.name,\n publishAt: result.updatedContent!.localized.publishAt,\n unpublishAt: result.updatedContent!.localized.unpublishAt,\n meta: result.updatedContent!.localized.meta,\n },\n },\n }\n : item,\n ),\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n }\n },\n });\n}\n\ninterface DeleteContentArgs {\n id: string;\n etag: string;\n locale?: string;\n}\n\nexport function useDeleteContent() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ id, etag, locale }: DeleteContentArgs) => {\n // If locale is provided, it's a locale-specific delete\n if (locale) {\n return client.deleteLocalized({ id, locale, etag });\n }\n // Otherwise, delete entire content\n return client.deleteContent(id, etag);\n },\n onSuccess: (result, variables) => {\n if (result.success) {\n if (variables.locale) {\n // For locale-specific deletion, update the content entry to remove the locale\n queryClient.setQueryData(queryKeys.content(variables.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n const locale = variables.locale!;\n const { [locale]: _, ...remainingLocales } = old.locales;\n return {\n ...old,\n locales: remainingLocales,\n };\n });\n\n // Update list queries to remove the locale from the item\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const locale = variables.locale!;\n return {\n ...old,\n items: old.items\n .map((item) => {\n if (item.id === variables.id) {\n const { [locale]: _, ...remainingLocales } = item.locales;\n return {\n ...item,\n locales: remainingLocales,\n };\n }\n return item;\n })\n .filter((item) => Object.keys(item.locales).length > 0), // Remove items with no locales\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['content', 'all'], exact: false }, updateListQueries);\n } else {\n // For full deletion, remove from cache\n queryClient.removeQueries({ queryKey: queryKeys.content(variables.id) });\n queryClient.removeQueries({ queryKey: ['content', variables.id], exact: false });\n\n // Update list queries by removing the deleted item\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update block lists\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update data lists\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update all content queries\n queryClient.setQueriesData(\n { queryKey: ['content', 'all'], exact: false },\n (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n },\n );\n }\n }\n },\n });\n}\n\ninterface DeleteLocalizedArgs {\n id: string;\n locale: string;\n etag: string;\n}\n\nexport function useDeleteLocalized() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ id, locale, etag }: DeleteLocalizedArgs) => client.deleteLocalized({ id, locale, etag }),\n onSuccess: (result, variables) => {\n if (result.success) {\n // Invalidate specific locale query\n queryClient.invalidateQueries({\n queryKey: queryKeys.localized(variables.id, variables.locale),\n });\n // Invalidate the full content query\n queryClient.invalidateQueries({ queryKey: queryKeys.content(variables.id) });\n }\n },\n });\n}\n\n// ===== Site Hooks =====\n\nexport function useSitePages(site: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.sitePages(site, locale),\n queryFn: () => client.getSitePages(site, locale),\n });\n}\n\nexport function usePageByPathname(site: string, pathname: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.pageByPathname(site, pathname, locale),\n queryFn: () => client.getPageByPathname(site, pathname, locale),\n enabled: !!pathname,\n });\n}\n\nexport function usePathnameAvailability(site: string, pathname: string, excludeId?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.pathnameAvailability(site, pathname, excludeId),\n queryFn: async () => {\n const available = await client.isPathnameAvailable(site, pathname, excludeId);\n return { available };\n },\n enabled: !!site && !!pathname,\n // For pathname validation, we want immediate feedback\n staleTime: 0,\n gcTime: 0,\n });\n}\n\ninterface MovePageArgs {\n site: string;\n id: string;\n pathname: string;\n locale?: string;\n etag: string;\n}\n\nexport function useMovePage() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ site, id, pathname, locale = 'en', etag }: MovePageArgs) =>\n client.movePage(site, id, pathname, locale, etag),\n onSuccess: (result, variables) => {\n if (result.moved) {\n // Invalidate site pages and content queries\n queryClient.invalidateQueries({ queryKey: ['sites', variables.site] });\n queryClient.invalidateQueries({ queryKey: queryKeys.content(variables.id) });\n }\n },\n });\n}\n\n// ===== Block Hooks =====\n\nexport function useBlocks(collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.blocks(collection, locale),\n queryFn: () => client.getBlocks(collection, locale),\n });\n}\n\nexport function useBlockByName(name: string, collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.blockByName(name, collection, locale),\n queryFn: () => client.getBlockByName(name, collection, locale),\n enabled: !!name,\n });\n}\n\n// ===== Data Hooks =====\n\nexport function useData(collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.data(collection, locale),\n queryFn: () => client.getData(collection, locale),\n });\n}\n\nexport function useDataByName(name: string, collection: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataByName(name, collection, locale),\n queryFn: () => client.getDataByName(name, collection, locale),\n enabled: !!name && !!collection,\n });\n}\n\nexport function useDataNameAvailability(name: string, collection: string, excludeId?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataNameAvailability(name, collection, excludeId),\n queryFn: async () => {\n const available = await client.isDataNameAvailable(name, collection, excludeId);\n return { available };\n },\n enabled: !!name && !!collection,\n staleTime: 0,\n gcTime: 0,\n });\n}\n\nexport function useDataCollections() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataCollections(),\n queryFn: () => client.getDataCollections(),\n });\n}\n\n// ===== Data Context Hooks =====\n\nexport function useDataContext(pageId?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataContext(pageId),\n queryFn: () => client.getDataContext(pageId!),\n enabled: !!pageId,\n });\n}\n\n// ===== Global Hooks =====\n\nexport function useAllContent(filters?: GlobalFilters) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.allContent(filters),\n queryFn: () => client.listAllContent(filters),\n });\n}\n\nexport function useUntranslatedContent(targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.untranslatedContent(targetLocale, excludeSites, includeUnpublished),\n queryFn: () => client.findUntranslatedContent(targetLocale, excludeSites, includeUnpublished),\n });\n}\n\nexport function useSitesConfig() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.sitesConfig(),\n queryFn: () => client.getSitesConfig(),\n });\n}\n\n// ===== Auth Hooks =====\n\nexport function useCurrentUser() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.currentUser(),\n queryFn: () => client.getCurrentUser(),\n staleTime: 60000, // Cache for 1 minute (user doesn't change often)\n });\n}\n\n// ===== Batch Operations =====\n\nexport function useBatchUpdate() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (operations: UpdateLocaleInput[]) => {\n const result = await client.batchUpdate(operations);\n\n // Fetch updated content for successful operations\n if (result.operations && result.updated > 0) {\n const updatedContents = await Promise.all(\n result.operations.map(async (opResult, index) => {\n if (opResult.updated) {\n const op = operations[index];\n const updated = await client.getLocalized(op.id, op.locale);\n return { index, content: updated };\n }\n return null;\n }),\n );\n\n return {\n ...result,\n updatedContents: updatedContents.filter(\n (item): item is { index: number; content: LocalizedEntry } => item !== null,\n ),\n };\n }\n\n return result;\n },\n onSuccess: (result, variables) => {\n if ('updatedContents' in result && result.updatedContents) {\n // Update caches with the fetched server data\n result.updatedContents.forEach(({ index, content }) => {\n if (!content) return;\n\n const operation = variables[index!];\n\n // Update localized content\n queryClient.setQueryData(queryKeys.localized(operation.id, operation.locale), content);\n\n // Update full content entry\n queryClient.setQueryData(queryKeys.content(operation.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n return {\n ...old,\n locales: {\n ...old.locales,\n [operation.locale]: content.localized,\n },\n };\n });\n });\n\n // Update list queries with server data\n const updatedMap = new Map(\n result.updatedContents.map(({ index, content }) => {\n const op = variables[index!];\n return [op.id + ':' + op.locale, content];\n }),\n );\n\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: old.items.map((item) => {\n const hasUpdate = Object.keys(item.locales).some((locale) => updatedMap.has(item.id + ':' + locale));\n\n if (hasUpdate) {\n const newLocales = { ...item.locales };\n Object.keys(newLocales).forEach((locale) => {\n const updated = updatedMap.get(item.id + ':' + locale);\n if (updated) {\n const { content, ...manifestData } = updated.localized;\n newLocales[locale] = manifestData;\n }\n });\n return { ...item, locales: newLocales };\n }\n\n return item;\n }),\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n }\n },\n });\n}\n\n// ===== Git Hooks =====\n\nexport function useGitStatus() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.gitStatus(),\n queryFn: () => client.getGitStatus(),\n refetchInterval: 10000,\n staleTime: 5000,\n });\n}\n\nexport function useCommitChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: (message: string | undefined) => client.commitChanges(message),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\nexport function usePushChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: () => client.pushChanges(),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\nexport function usePullChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: () => client.pullChanges(),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\n// ===== Asset Hooks =====\n\nexport function useAssets() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.assets(),\n queryFn: () => client.listAssets(),\n });\n}\n\nexport function useAsset(filename: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.asset(filename),\n queryFn: () => client.getAsset(filename),\n enabled: !!filename,\n });\n}\n\nexport function useUploadAsset() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (formData: FormData) => client.uploadAsset(formData),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useImportAssetUrl() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ url, alt, folder }: { url: string; alt?: string; folder?: string }) =>\n client.importAssetUrl(url, alt, folder),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useDeleteAsset() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (filename: string) => client.deleteAsset(filename),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useBulkDeleteAssets() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (filenames: string[]) => {\n let successCount = 0;\n let failCount = 0;\n for (const filename of filenames) {\n try {\n await client.deleteAsset(filename);\n successCount++;\n } catch {\n failCount++;\n }\n }\n return { successCount, failCount };\n },\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\n// ===== Media Library Hooks =====\n\nexport function useAssetFolders(path?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.assetFolders(path),\n queryFn: () => client.listFolder(path),\n });\n}\n\nexport function useCreateFolder() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (path: string) => client.createFolder(path),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useUpdateAssetMetadata() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ filename, updates }: { filename: string; updates: { alt?: string; tags?: string[] } }) =>\n client.updateAssetMetadata(filename, updates),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useAssetUsage(filename: string | null) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.assetUsage(filename),\n queryFn: () => client.getAssetUsage(filename!),\n enabled: !!filename,\n staleTime: 60_000, // Cache usage for 1 minute to avoid repeated VXJSON scans\n });\n}\n\nexport function useFolderTree() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.folderTree(),\n queryFn: () => client.getFolderTree(),\n staleTime: 30_000, // Cache for 30 seconds\n });\n}\n\nexport function useMoveAssets() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({\n filenames,\n sourceFolder,\n targetFolder,\n }: {\n filenames: string[];\n sourceFolder: string;\n targetFolder: string;\n }) => client.moveAssets(filenames, sourceFolder, targetFolder),\n onSuccess: () => {\n // Invalidate all folder-related queries to refresh counts and listings\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n queryClient.invalidateQueries({ queryKey: queryKeys.folderTree() });\n },\n });\n}\n\n// Re-export for convenience\nexport { ContentAPIClient, StaleWriteError, API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AM,SAAS,qBAAqB;CACpC,MAAM,cAAc,gBAAgB;AAEpC,QAAO,YAAY;EACjB,aAAa,EAAE,UAAU,cACvB,OAAO,oBAAoB,UAAU,QAAQ;EAC/C,iBAAiB;AACf,eAAY,kBAAkB,EAAE,UAAU,UAAU,QAAQ,EAAE,CAAC;AAC/D,eAAY,kBAAkB,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC;;EAEjE,CAAC;;AAGJ,SAAgB,cAAc,UAAyB;CACrD,MAAM,SAAS,qBAAqB;AAEpC,QAAO,SAAS;EACd,UAAU,UAAU,WAAW,SAAS;EACxC,eAAe,OAAO,cAAc,SAAU;EAC9C,SAAS,CAAC,CAAC;EACX,WAAW;EACZ,CAAC;;AAGJ,SAAgB,gBAAgB;CAC9B,MAAM,SAAS,qBAAqB;AAEpC,QAAO,SAAS;EACd,UAAU,UAAU,YAAY;EAChC,eAAe,OAAO,eAAe;EACrC,WAAW;EACZ,CAAC;;AAGJ,SAAgB,gBAAgB;CAC9B,MAAM,SAAS,qBAAqB;CACpC,MAAM,cAAc,gBAAgB;AAEpC,QAAO,YAAY;EACjB,aAAa,EACX,WACA,cACA,mBAKI,OAAO,WAAW,WAAW,cAAc,aAAa;EAC9D,iBAAiB;AAEf,eAAY,kBAAkB,EAAE,UAAU,UAAU,QAAQ,EAAE,CAAC;AAC/D,eAAY,kBAAkB,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC;AAC9D,eAAY,kBAAkB,EAAE,UAAU,UAAU,YAAY,EAAE,CAAC;;EAEtE,CAAC"}
|
|
@@ -18,6 +18,7 @@ declare const API_ROUTES: {
|
|
|
18
18
|
readonly COLLECTIONS: "/content/collections";
|
|
19
19
|
readonly BATCH_UPDATE: "/content/batch";
|
|
20
20
|
readonly FIND_UNTRANSLATED: "/content/find-untranslated";
|
|
21
|
+
readonly DATA_CONTEXT: "/data-context";
|
|
21
22
|
};
|
|
22
23
|
interface MockResponse {
|
|
23
24
|
status?: number;
|
|
@@ -90,4 +91,4 @@ declare function setupFetchMock(mockFn: (impl?: any) => any): {
|
|
|
90
91
|
};
|
|
91
92
|
//#endregion
|
|
92
93
|
export { jsonResponse as a, mockContentManifest as c, mockLocalizedEntry as d, mockUpdateResult as f, createMockFetch as i, mockCreateResult as l, MockAPIResponses as n, mockBatchResult as o, setupFetchMock as p, MockResponse as r, mockContentEntry as s, API_ROUTES as t, mockDeleteResult as u };
|
|
93
|
-
//# sourceMappingURL=test-helpers-
|
|
94
|
+
//# sourceMappingURL=test-helpers-CVEhY7aJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-helpers-CVEhY7aJ.d.mts","names":[],"sources":["../src/test-helpers.ts"],"mappings":";;;;;AAkBA;;;;;cAAa,UAAA;EAAA;;;2CAImB,MAAA;EAAA;;;;;;;UASf,YAAA;EACf,MAAA;EACA,OAAA,GAAU,MAAA;EACV,IAAA;AAAA;;;;;iBAOc,eAAA,CAAgB,MAAA,GAAS,IAAA;;;;iBAOzB,YAAA,CAAa,IAAA,OAAW,OAAA;EAAW,MAAA;EAAiB,OAAA,GAAU,MAAA;AAAA,IAAgC,QAAA;;AAA9G;;iBAagB,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBA2BrD,mBAAA,CAAoB,SAAA,GAAY,OAAA,CAAQ,eAAA,IAAmB,eAAA;;;;iBA0B3D,kBAAA,CAAmB,SAAA,GAAY,OAAA,CAAQ,cAAA,IAAkB,cAAA;;AArDzE;;iBA8EgB,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBAarD,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBAYrD,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBAUrD,eAAA,CAAgB,SAAA,GAAY,OAAA,CAAQ,WAAA,IAAe,WAAA;;;;cAatD,gBAAA;EAAA,QACS,SAAA;cAAA,SAAA;EAEpB,cAAA,CAAe,OAAA,EAAS,YAAA,SAAqB,MAAA;EAS7C,gBAAA,CAAiB,KAAA,EAAO,cAAA,SAAuB,MAAA;EAS/C,eAAA,CAAgB,KAAA,EAAO,eAAA,IAAmB,MAAA;EAK1C,iBAAA,CAAkB,MAAA,EAAQ,YAAA,EAAc,MAAA;EAaxC,iBAAA,CAAkB,MAAA,EAAQ,YAAA,EAAc,MAAA;EAaxC,iBAAA,CAAkB,MAAA,EAAQ,YAAA,EAAc,MAAA;EAKxC,cAAA,CAAe,WAAA;EAgBf,SAAA,CAAU,OAAA,UAAiB,MAAA;EAK3B,gBAAA,CAAA;AAAA;;;;;iBAUc,cAAA,CAAe,MAAA,GAAS,IAAA;;aAAV,gBAAA;AAAA"}
|
|
@@ -15,7 +15,8 @@ const API_ROUTES = {
|
|
|
15
15
|
BLOCKS: "/blocks",
|
|
16
16
|
COLLECTIONS: "/content/collections",
|
|
17
17
|
BATCH_UPDATE: "/content/batch",
|
|
18
|
-
FIND_UNTRANSLATED: "/content/find-untranslated"
|
|
18
|
+
FIND_UNTRANSLATED: "/content/find-untranslated",
|
|
19
|
+
DATA_CONTEXT: "/data-context"
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Creates a mock fetch function for testing
|
|
@@ -216,4 +217,4 @@ function setupFetchMock(mockFn) {
|
|
|
216
217
|
|
|
217
218
|
//#endregion
|
|
218
219
|
export { mockBatchResult as a, mockCreateResult as c, mockUpdateResult as d, setupFetchMock as f, jsonResponse as i, mockDeleteResult as l, MockAPIResponses as n, mockContentEntry as o, createMockFetch as r, mockContentManifest as s, API_ROUTES as t, mockLocalizedEntry as u };
|
|
219
|
-
//# sourceMappingURL=test-helpers-
|
|
220
|
+
//# sourceMappingURL=test-helpers-DNN1aglz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-helpers-DNN1aglz.mjs","names":[],"sources":["../src/test-helpers.ts"],"sourcesContent":["import type {\n BatchResult,\n ContentEntry,\n ContentManifest,\n CreateResult,\n DeleteResult,\n LocalizedEntry,\n UpdateResult,\n} from '@conloca/content-api';\n\n/**\n * Test helpers for mocking Content API Client\n */\n\n/**\n * API route patterns used by the content API\n * These match the routes defined in content-api/src/middleware.ts\n */\nexport const API_ROUTES = {\n SITES: '/sites',\n ALL_CONTENT: '/content',\n CONTENT_BY_ID: (id: string) => `/content/${id}`,\n LOCALIZED_CONTENT: (id: string, locale: string) => `/content/${id}/${locale}`,\n SITE_PAGES: (site: string) => `/${site}/pages`,\n BLOCKS: '/blocks',\n COLLECTIONS: '/content/collections',\n BATCH_UPDATE: '/content/batch',\n FIND_UNTRANSLATED: '/content/find-untranslated',\n DATA_CONTEXT: '/data-context',\n} as const;\n\nexport interface MockResponse {\n status?: number;\n headers?: Record<string, string>;\n body?: any;\n}\n\n/**\n * Creates a mock fetch function for testing\n * Note: This requires a mock function from your test framework (e.g., bun:test, jest, vitest)\n */\nexport function createMockFetch(mockFn: (impl?: any) => any) {\n return mockFn(() => Promise.resolve(new Response()));\n}\n\n/**\n * Creates a Response object with JSON body\n */\nexport function jsonResponse(body: any, options: { status?: number; headers?: Record<string, string> } = {}): Response {\n return new Response(JSON.stringify(body), {\n status: options.status || 200,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n}\n\n/**\n * Creates a mock ContentEntry\n */\nexport function mockContentEntry(overrides?: Partial<ContentEntry>): ContentEntry {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n locales: {\n en: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n content: { puckData: {} },\n },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock ContentManifest\n */\nexport function mockContentManifest(overrides?: Partial<ContentManifest>): ContentManifest {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n locales: {\n en: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock LocalizedEntry\n */\nexport function mockLocalizedEntry(overrides?: Partial<LocalizedEntry>): LocalizedEntry {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n localized: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n content: { puckData: {} },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock CreateResult\n */\nexport function mockCreateResult(overrides?: Partial<CreateResult>): CreateResult {\n return {\n success: true,\n id: 'new-id',\n etag: 'newMetaHash.newContentHash',\n created: new Date('2024-01-01T00:00:00.000Z'),\n ...overrides,\n };\n}\n\n/**\n * Creates a mock UpdateResult\n */\nexport function mockUpdateResult(overrides?: Partial<UpdateResult>): UpdateResult {\n return {\n success: true,\n etag: 'updatedMetaHash.updatedContentHash',\n modified: new Date('2024-01-01T00:00:00.000Z'),\n ...overrides,\n };\n}\n\n/**\n * Creates a mock DeleteResult\n */\nexport function mockDeleteResult(overrides?: Partial<DeleteResult>): DeleteResult {\n return {\n success: true,\n ...overrides,\n };\n}\n\n/**\n * Creates a mock BatchResult\n */\nexport function mockBatchResult(overrides?: Partial<BatchResult>): BatchResult {\n return {\n operations: [],\n success: true,\n updated: 0,\n failed: 0,\n ...overrides,\n };\n}\n\n/**\n * Mock helper for setting up common API responses\n */\nexport class MockAPIResponses {\n constructor(private fetchMock: any) {}\n\n mockGetContent(content: ContentEntry | null, status = 200) {\n if (content) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(content, { status }));\n } else {\n this.fetchMock.mockResolvedValueOnce(new Response('Not found', { status: 404 }));\n }\n return this;\n }\n\n mockGetLocalized(entry: LocalizedEntry | null, status = 200) {\n if (entry) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(entry, { status }));\n } else {\n this.fetchMock.mockResolvedValueOnce(new Response('Not found', { status: 404 }));\n }\n return this;\n }\n\n mockListContent(items: ContentManifest[], status = 200) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse({ items }, { status }));\n return this;\n }\n\n mockCreateContent(result: CreateResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n ...result,\n created: result.created?.toISOString(),\n },\n { status },\n ),\n );\n return this;\n }\n\n mockUpdateContent(result: UpdateResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n ...result,\n modified: result.modified?.toISOString(),\n },\n { status },\n ),\n );\n return this;\n }\n\n mockDeleteContent(result: DeleteResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(result, { status }));\n return this;\n }\n\n mockStaleWrite(currentEtag: string) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n error: {\n code: 'STALE_WRITE',\n message: 'Content has been modified',\n details: { currentEtag },\n },\n },\n { status: 412 },\n ),\n );\n return this;\n }\n\n mockError(message: string, status = 500) {\n this.fetchMock.mockResolvedValueOnce(new Response(message, { status }));\n return this;\n }\n\n mockNetworkError() {\n this.fetchMock.mockRejectedValueOnce(new Error('Network error'));\n return this;\n }\n}\n\n/**\n * Setup fetch mock with helper\n * @param mockFn - Mock function from your test framework (e.g., mock from bun:test)\n */\nexport function setupFetchMock(mockFn: (impl?: any) => any) {\n const fetchMock = createMockFetch(mockFn);\n global.fetch = fetchMock as any;\n return {\n fetchMock,\n responses: new MockAPIResponses(fetchMock),\n };\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,aAAa;CACxB,OAAO;CACP,aAAa;CACb,gBAAgB,OAAe,YAAY;CAC3C,oBA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AAQ,CACX,CACF;AACD,SAAO;;CAGT,kBAAkB,QAAsB,SAAS,KAAK;AACpD,OAAK,UAAU,sBAAsB,aAAa,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACtE,SAAO;;CAGT,eAAe,aAAqB;AAClC,OAAK,UAAU,sBACb,aACE,EACE,OAAO;GACL,MAAM;GACN,SAAS;GACT,SAAS,EAAE,aAAa;GACzB,EACF,EACD,EAAE,QAAQ,KAAK,CAChB,CACF;AACD,SAAO;;CAGT,UAAU,SAAiB,SAAS,KAAK;AACvC,OAAK,UAAU,sBAAsB,IAAI,SAAS,SAAS,EAAE,QAAQ,CAAC,CAAC;AACvE,SAAO;;CAGT,mBAAmB;AACjB,OAAK,UAAU,sCAAsB,IAAI,MAAM,gBAAgB,CAAC;AAChE,SAAO;;;;;;;AAQX,SAAgB,eAAe,QAA6B;CAC1D,MAAM,YAAY,gBAAgB,OAAO;AACzC,QAAO,QAAQ;AACf,QAAO;EACL;EACA,WAAW,IAAI,iBAAiB,UAAU;EAC3C"}
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as jsonResponse, c as mockContentManifest, d as mockLocalizedEntry, f as mockUpdateResult, i as createMockFetch, l as mockCreateResult, n as MockAPIResponses, o as mockBatchResult, p as setupFetchMock, r as MockResponse, s as mockContentEntry, t as API_ROUTES, u as mockDeleteResult } from "./test-helpers-
|
|
1
|
+
import { a as jsonResponse, c as mockContentManifest, d as mockLocalizedEntry, f as mockUpdateResult, i as createMockFetch, l as mockCreateResult, n as MockAPIResponses, o as mockBatchResult, p as setupFetchMock, r as MockResponse, s as mockContentEntry, t as API_ROUTES, u as mockDeleteResult } from "./test-helpers-CVEhY7aJ.mjs";
|
|
2
2
|
export { API_ROUTES, MockAPIResponses, MockResponse, createMockFetch, jsonResponse, mockBatchResult, mockContentEntry, mockContentManifest, mockCreateResult, mockDeleteResult, mockLocalizedEntry, mockUpdateResult, setupFetchMock };
|
package/dist/testing.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as mockBatchResult, c as mockCreateResult, d as mockUpdateResult, f as setupFetchMock, i as jsonResponse, l as mockDeleteResult, n as MockAPIResponses, o as mockContentEntry, r as createMockFetch, s as mockContentManifest, t as API_ROUTES, u as mockLocalizedEntry } from "./test-helpers-
|
|
1
|
+
import { a as mockBatchResult, c as mockCreateResult, d as mockUpdateResult, f as setupFetchMock, i as jsonResponse, l as mockDeleteResult, n as MockAPIResponses, o as mockContentEntry, r as createMockFetch, s as mockContentManifest, t as API_ROUTES, u as mockLocalizedEntry } from "./test-helpers-DNN1aglz.mjs";
|
|
2
2
|
|
|
3
3
|
export { API_ROUTES, MockAPIResponses, createMockFetch, jsonResponse, mockBatchResult, mockContentEntry, mockContentManifest, mockCreateResult, mockDeleteResult, mockLocalizedEntry, mockUpdateResult, setupFetchMock };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conloca/content-api-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/conloca/
|
|
10
|
-
"directory": "
|
|
9
|
+
"url": "git+https://github.com/conloca/conloca.git",
|
|
10
|
+
"directory": "content-api-client"
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/index.mjs",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"test": "tsc-bun-test"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@conloca/content-api": "^0.1.
|
|
39
|
+
"@conloca/content-api": "^0.1.13",
|
|
40
40
|
"@tanstack/react-query": "^5.90.21",
|
|
41
41
|
"tslib": "^2.8.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"react": "19.
|
|
45
|
-
"react-dom": "19.
|
|
44
|
+
"react": "^19.0.0",
|
|
45
|
+
"react-dom": "^19.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@happy-dom/global-registrator": "^20.6.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers-4tYApvzp.d.mts","names":[],"sources":["../src/test-helpers.ts"],"mappings":";;;;;AAkBA;;;;;cAAa,UAAA;EAAA;;;2CAImB,MAAA;EAAA;;;;;;UAQf,YAAA;EACf,MAAA;EACA,OAAA,GAAU,MAAA;EACV,IAAA;AAAA;;;;;iBAOc,eAAA,CAAgB,MAAA,GAAS,IAAA;;;;iBAOzB,YAAA,CAAa,IAAA,OAAW,OAAA;EAAW,MAAA;EAAiB,OAAA,GAAU,MAAA;AAAA,IAAgC,QAAA;;AAA9G;;iBAagB,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBA2BrD,mBAAA,CAAoB,SAAA,GAAY,OAAA,CAAQ,eAAA,IAAmB,eAAA;;;;iBA0B3D,kBAAA,CAAmB,SAAA,GAAY,OAAA,CAAQ,cAAA,IAAkB,cAAA;;AArDzE;;iBA8EgB,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBAarD,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBAYrD,gBAAA,CAAiB,SAAA,GAAY,OAAA,CAAQ,YAAA,IAAgB,YAAA;;;;iBAUrD,eAAA,CAAgB,SAAA,GAAY,OAAA,CAAQ,WAAA,IAAe,WAAA;;;;cAatD,gBAAA;EAAA,QACS,SAAA;cAAA,SAAA;EAEpB,cAAA,CAAe,OAAA,EAAS,YAAA,SAAqB,MAAA;EAS7C,gBAAA,CAAiB,KAAA,EAAO,cAAA,SAAuB,MAAA;EAS/C,eAAA,CAAgB,KAAA,EAAO,eAAA,IAAmB,MAAA;EAK1C,iBAAA,CAAkB,MAAA,EAAQ,YAAA,EAAc,MAAA;EAaxC,iBAAA,CAAkB,MAAA,EAAQ,YAAA,EAAc,MAAA;EAaxC,iBAAA,CAAkB,MAAA,EAAQ,YAAA,EAAc,MAAA;EAKxC,cAAA,CAAe,WAAA;EAgBf,SAAA,CAAU,OAAA,UAAiB,MAAA;EAK3B,gBAAA,CAAA;AAAA;;;;;iBAUc,cAAA,CAAe,MAAA,GAAS,IAAA;;aAAV,gBAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers-CFATqjhm.mjs","names":[],"sources":["../src/test-helpers.ts"],"sourcesContent":["import type {\n BatchResult,\n ContentEntry,\n ContentManifest,\n CreateResult,\n DeleteResult,\n LocalizedEntry,\n UpdateResult,\n} from '@conloca/content-api';\n\n/**\n * Test helpers for mocking Content API Client\n */\n\n/**\n * API route patterns used by the content API\n * These match the routes defined in content-api/src/middleware.ts\n */\nexport const API_ROUTES = {\n SITES: '/sites',\n ALL_CONTENT: '/content',\n CONTENT_BY_ID: (id: string) => `/content/${id}`,\n LOCALIZED_CONTENT: (id: string, locale: string) => `/content/${id}/${locale}`,\n SITE_PAGES: (site: string) => `/${site}/pages`,\n BLOCKS: '/blocks',\n COLLECTIONS: '/content/collections',\n BATCH_UPDATE: '/content/batch',\n FIND_UNTRANSLATED: '/content/find-untranslated',\n} as const;\n\nexport interface MockResponse {\n status?: number;\n headers?: Record<string, string>;\n body?: any;\n}\n\n/**\n * Creates a mock fetch function for testing\n * Note: This requires a mock function from your test framework (e.g., bun:test, jest, vitest)\n */\nexport function createMockFetch(mockFn: (impl?: any) => any) {\n return mockFn(() => Promise.resolve(new Response()));\n}\n\n/**\n * Creates a Response object with JSON body\n */\nexport function jsonResponse(body: any, options: { status?: number; headers?: Record<string, string> } = {}): Response {\n return new Response(JSON.stringify(body), {\n status: options.status || 200,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n}\n\n/**\n * Creates a mock ContentEntry\n */\nexport function mockContentEntry(overrides?: Partial<ContentEntry>): ContentEntry {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n locales: {\n en: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n content: { puckData: {} },\n },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock ContentManifest\n */\nexport function mockContentManifest(overrides?: Partial<ContentManifest>): ContentManifest {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n locales: {\n en: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock LocalizedEntry\n */\nexport function mockLocalizedEntry(overrides?: Partial<LocalizedEntry>): LocalizedEntry {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n localized: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n content: { puckData: {} },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock CreateResult\n */\nexport function mockCreateResult(overrides?: Partial<CreateResult>): CreateResult {\n return {\n success: true,\n id: 'new-id',\n etag: 'newMetaHash.newContentHash',\n created: new Date('2024-01-01T00:00:00.000Z'),\n ...overrides,\n };\n}\n\n/**\n * Creates a mock UpdateResult\n */\nexport function mockUpdateResult(overrides?: Partial<UpdateResult>): UpdateResult {\n return {\n success: true,\n etag: 'updatedMetaHash.updatedContentHash',\n modified: new Date('2024-01-01T00:00:00.000Z'),\n ...overrides,\n };\n}\n\n/**\n * Creates a mock DeleteResult\n */\nexport function mockDeleteResult(overrides?: Partial<DeleteResult>): DeleteResult {\n return {\n success: true,\n ...overrides,\n };\n}\n\n/**\n * Creates a mock BatchResult\n */\nexport function mockBatchResult(overrides?: Partial<BatchResult>): BatchResult {\n return {\n operations: [],\n success: true,\n updated: 0,\n failed: 0,\n ...overrides,\n };\n}\n\n/**\n * Mock helper for setting up common API responses\n */\nexport class MockAPIResponses {\n constructor(private fetchMock: any) {}\n\n mockGetContent(content: ContentEntry | null, status = 200) {\n if (content) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(content, { status }));\n } else {\n this.fetchMock.mockResolvedValueOnce(new Response('Not found', { status: 404 }));\n }\n return this;\n }\n\n mockGetLocalized(entry: LocalizedEntry | null, status = 200) {\n if (entry) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(entry, { status }));\n } else {\n this.fetchMock.mockResolvedValueOnce(new Response('Not found', { status: 404 }));\n }\n return this;\n }\n\n mockListContent(items: ContentManifest[], status = 200) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse({ items }, { status }));\n return this;\n }\n\n mockCreateContent(result: CreateResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n ...result,\n created: result.created?.toISOString(),\n },\n { status },\n ),\n );\n return this;\n }\n\n mockUpdateContent(result: UpdateResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n ...result,\n modified: result.modified?.toISOString(),\n },\n { status },\n ),\n );\n return this;\n }\n\n mockDeleteContent(result: DeleteResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(result, { status }));\n return this;\n }\n\n mockStaleWrite(currentEtag: string) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n error: {\n code: 'STALE_WRITE',\n message: 'Content has been modified',\n details: { currentEtag },\n },\n },\n { status: 412 },\n ),\n );\n return this;\n }\n\n mockError(message: string, status = 500) {\n this.fetchMock.mockResolvedValueOnce(new Response(message, { status }));\n return this;\n }\n\n mockNetworkError() {\n this.fetchMock.mockRejectedValueOnce(new Error('Network error'));\n return this;\n }\n}\n\n/**\n * Setup fetch mock with helper\n * @param mockFn - Mock function from your test framework (e.g., mock from bun:test)\n */\nexport function setupFetchMock(mockFn: (impl?: any) => any) {\n const fetchMock = createMockFetch(mockFn);\n global.fetch = fetchMock as any;\n return {\n fetchMock,\n responses: new MockAPIResponses(fetchMock),\n };\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,aAAa;CACxB,OAAO;CACP,aAAa;CACb,gBAAgB,OAAe,YAAY;CAC3C,oBAAoB,IAAY,WAAmB,YAAY,GAAG,GAAG;CACrE,aAAa,SAAiB,IAAI,KAAK;CACvC,QAAQ;CACR,aAAa;CACb,cAAc;CACd,mBAAmB;CACpB;;;;;AAYD,SAAgB,gBAAgB,QAA6B;AAC3D,QAAO,aAAa,QAAQ,QAAQ,IAAI,UAAU,CAAC,CAAC;;;;;AAMtD,SAAgB,aAAa,MAAW,UAAiE,EAAE,EAAY;AACrH,QAAO,IAAI,SAAS,KAAK,UAAU,KAAK,EAAE;EACxC,QAAQ,QAAQ,UAAU;EAC1B,SAAS;GACP,gBAAgB;GAChB,GAAG,QAAQ;GACZ;EACF,CAAC;;;;;AAMJ,SAAgB,iBAAiB,WAAiD;AAChF,QAAO;EACL,IAAI;EACJ,MAAM;EACN,YAAY;EACZ,MAAM;EACN,MAAM;EACN,SAAS,EACP,IAAI;GACF,QAAQ;GACR,MAAM;GACN,SAAS;GACT,UAAU;GACV,UAAU;GACV,MAAM,EACJ,OAAO,aACR;GACD,SAAS,EAAE,UAAU,EAAE,EAAE;GAC1B,EACF;EACD,GAAG;EACJ;;;;;AAMH,SAAgB,oBAAoB,WAAuD;AACzF,QAAO;EACL,IAAI;EACJ,MAAM;EACN,YAAY;EACZ,MAAM;EACN,MAAM;EACN,SAAS,EACP,IAAI;GACF,QAAQ;GACR,MAAM;GACN,SAAS;GACT,UAAU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