@conloca/content-api 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asset-manifest.d.ts +23 -0
- package/dist/asset-manifest.d.ts.map +1 -0
- package/dist/asset-manifest.js +73 -0
- package/dist/asset-operations.d.ts +159 -0
- package/dist/asset-operations.d.ts.map +1 -0
- package/dist/asset-operations.js +736 -0
- package/dist/asset-types.d.ts +56 -0
- package/dist/asset-types.d.ts.map +1 -0
- package/dist/asset-types.js +7 -0
- package/dist/base-content-index.d.ts +57 -0
- package/dist/base-content-index.d.ts.map +1 -0
- package/dist/base-content-index.js +179 -0
- package/dist/block-index.d.ts +9 -0
- package/dist/block-index.d.ts.map +1 -0
- package/dist/block-index.js +11 -0
- package/dist/blocks.d.ts +16 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +103 -0
- package/dist/cf-access.d.ts +31 -0
- package/dist/cf-access.d.ts.map +1 -0
- package/dist/cf-access.js +66 -0
- package/dist/component-registry.d.ts +50 -0
- package/dist/component-registry.d.ts.map +1 -0
- package/dist/component-registry.js +120 -0
- package/dist/{component-registry.types-CBGONnYn.d.mts → component-registry.types-C0ctF9nh.d.mts} +1 -1
- package/dist/component-registry.types-C0ctF9nh.d.mts.map +1 -0
- package/dist/component-registry.types.d.ts +11 -0
- package/dist/component-registry.types.d.ts.map +1 -0
- package/dist/component-registry.types.js +1 -0
- package/dist/content-api.interface.d.ts +64 -0
- package/dist/content-api.interface.d.ts.map +1 -0
- package/dist/content-api.interface.js +1 -0
- package/dist/content-filters.d.ts +31 -0
- package/dist/content-filters.d.ts.map +1 -0
- package/dist/content-filters.js +246 -0
- package/dist/content-index-D092_vk1.mjs +629 -0
- package/dist/content-index-D092_vk1.mjs.map +1 -0
- package/dist/content-index-D6IVMmAB.d.mts +127 -0
- package/dist/content-index-D6IVMmAB.d.mts.map +1 -0
- package/dist/content-index.d.ts +126 -0
- package/dist/content-index.d.ts.map +1 -0
- package/dist/content-index.js +418 -0
- package/dist/content-operations-DIbsxG5A.d.mts +354 -0
- package/dist/content-operations-DIbsxG5A.d.mts.map +1 -0
- package/dist/content-operations.d.ts +93 -0
- package/dist/content-operations.d.ts.map +1 -0
- package/dist/content-operations.js +275 -0
- package/dist/content-reader.d.ts +10 -0
- package/dist/content-reader.d.ts.map +1 -0
- package/dist/content-reader.js +13 -0
- package/dist/content-utils-fWNHTrPy.mjs +280 -0
- package/dist/content-utils-fWNHTrPy.mjs.map +1 -0
- package/dist/content-utils.d.ts +132 -0
- package/dist/content-utils.d.ts.map +1 -0
- package/dist/content-utils.js +352 -0
- package/dist/content-watcher.d.ts +43 -0
- package/dist/content-watcher.d.ts.map +1 -0
- package/dist/content-watcher.js +83 -0
- package/dist/{data-Db1Iv9T0.mjs → data-DquNIEnQ.mjs} +4 -2
- package/dist/{data-Db1Iv9T0.mjs.map → data-DquNIEnQ.mjs.map} +1 -1
- package/dist/data-index.d.ts +8 -0
- package/dist/data-index.d.ts.map +1 -0
- package/dist/data-index.js +7 -0
- package/dist/data.d.ts +43 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +103 -0
- package/dist/etag-utils.d.ts +77 -0
- package/dist/etag-utils.d.ts.map +1 -0
- package/dist/etag-utils.js +160 -0
- package/dist/filesystem-content-api-B1KIQJfk.mjs +2 -0
- package/dist/{filesystem-content-api-kxKY5IUw.mjs → filesystem-content-api-C0HIhqZi.mjs} +172 -1230
- package/dist/filesystem-content-api-C0HIhqZi.mjs.map +1 -0
- package/dist/{filesystem-content-api-C1TM0GLo.d.mts → filesystem-content-api-DCdNi-co.d.mts} +19 -4
- package/dist/filesystem-content-api-DCdNi-co.d.mts.map +1 -0
- package/dist/filesystem-content-api.d.ts +135 -0
- package/dist/filesystem-content-api.d.ts.map +1 -0
- package/dist/filesystem-content-api.js +2181 -0
- package/dist/git-operations.d.ts +49 -0
- package/dist/git-operations.d.ts.map +1 -0
- package/dist/git-operations.js +252 -0
- package/dist/header-parser.d.ts +37 -0
- package/dist/header-parser.d.ts.map +1 -0
- package/dist/header-parser.js +286 -0
- package/dist/in-memory-content-api.d.ts +35 -0
- package/dist/in-memory-content-api.d.ts.map +1 -0
- package/dist/in-memory-content-api.js +591 -0
- package/dist/index-DxVTFK66.d.mts +105 -0
- package/dist/index-DxVTFK66.d.mts.map +1 -0
- package/dist/index.d.mts +6 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.mjs +37 -6
- package/dist/index.mjs.map +1 -1
- package/dist/indexing.d.mts +152 -0
- package/dist/indexing.d.mts.map +1 -0
- package/dist/indexing.d.ts +5 -0
- package/dist/indexing.d.ts.map +1 -0
- package/dist/indexing.js +7 -0
- package/dist/indexing.mjs +255 -0
- package/dist/indexing.mjs.map +1 -0
- package/dist/json-whitespace-view.d.ts +32 -0
- package/dist/json-whitespace-view.d.ts.map +1 -0
- package/dist/json-whitespace-view.js +152 -0
- package/dist/middleware.d.ts +20 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +1031 -0
- package/dist/node.d.mts +10 -15
- package/dist/node.d.mts.map +1 -1
- package/dist/node.d.ts +25 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +24 -0
- package/dist/node.mjs +89 -135
- package/dist/node.mjs.map +1 -1
- package/dist/reader.d.mts +5 -8
- package/dist/reader.d.mts.map +1 -1
- package/dist/reader.d.ts +15 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +13 -0
- package/dist/reader.mjs +8 -8
- package/dist/reader.mjs.map +1 -1
- package/dist/schemas/index.d.mts +2 -90
- package/dist/schemas/index.d.ts +102 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +87 -0
- package/dist/schemas/index.mjs +2 -70
- package/dist/schemas-CFRD0FIQ.mjs +84 -0
- package/dist/schemas-CFRD0FIQ.mjs.map +1 -0
- package/dist/{site-vNtJ5jCh.mjs → site-8oaj1Q60.mjs} +21 -193
- package/dist/site-8oaj1Q60.mjs.map +1 -0
- package/dist/site-index-B_254bCc.d.mts +136 -0
- package/dist/site-index-B_254bCc.d.mts.map +1 -0
- package/dist/site-index.d.ts +60 -0
- package/dist/site-index.d.ts.map +1 -0
- package/dist/site-index.js +287 -0
- package/dist/site.d.ts +21 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +168 -0
- package/dist/{types-DWt912tu.mjs → types-DOdldbfD.mjs} +3 -2
- package/dist/types-DOdldbfD.mjs.map +1 -0
- package/dist/types-DjfhS272.d.mts +456 -0
- package/dist/types-DjfhS272.d.mts.map +1 -0
- package/dist/types.d.ts +453 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +36 -0
- package/dist/url-safe-base64.d.ts +12 -0
- package/dist/url-safe-base64.d.ts.map +1 -0
- package/dist/url-safe-base64.js +40 -0
- package/dist/url-validation.d.ts +14 -0
- package/dist/url-validation.d.ts.map +1 -0
- package/dist/url-validation.js +81 -0
- package/dist/utils/atomic-write.d.ts +6 -0
- package/dist/utils/atomic-write.d.ts.map +1 -0
- package/dist/utils/atomic-write.js +20 -0
- package/dist/utils.d.ts +46 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +70 -0
- package/dist/vite-plugin.d.ts +12 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +29 -0
- package/dist/vxjson-qHrgLGip.mjs +555 -0
- package/dist/vxjson-qHrgLGip.mjs.map +1 -0
- package/dist/vxjson-serialize-geF6qvpn.mjs +34 -0
- package/dist/vxjson-serialize-geF6qvpn.mjs.map +1 -0
- package/dist/vxjson-serialize.d.mts +17 -0
- package/dist/vxjson-serialize.d.mts.map +1 -0
- package/dist/vxjson-serialize.d.ts +14 -0
- package/dist/vxjson-serialize.d.ts.map +1 -0
- package/dist/vxjson-serialize.js +50 -0
- package/dist/vxjson-serialize.mjs +2 -0
- package/dist/vxjson.d.ts +112 -0
- package/dist/vxjson.d.ts.map +1 -0
- package/dist/vxjson.js +391 -0
- package/dist/xxhash.d.ts +10 -0
- package/dist/xxhash.d.ts.map +1 -0
- package/dist/xxhash.js +31 -0
- package/package.json +79 -17
- package/dist/component-registry.types-CBGONnYn.d.mts.map +0 -1
- package/dist/content-operations-Dv67amz3.d.mts +0 -852
- package/dist/content-operations-Dv67amz3.d.mts.map +0 -1
- package/dist/filesystem-content-api-C1TM0GLo.d.mts.map +0 -1
- package/dist/filesystem-content-api-kxKY5IUw.mjs.map +0 -1
- package/dist/schemas/index.d.mts.map +0 -1
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/site-vNtJ5jCh.mjs.map +0 -1
- package/dist/types-DWt912tu.mjs.map +0 -1
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { BlockIndex } from './block-index';
|
|
2
|
+
import { localesOf, mapSiteNames } from './content-utils';
|
|
3
|
+
import { DataIndex } from './data-index';
|
|
4
|
+
import { SiteIndex } from './site-index';
|
|
5
|
+
/**
|
|
6
|
+
* ContentIndex coordinates between per-site indexes and the block index
|
|
7
|
+
* This provides efficient filtering by routing to the appropriate specialized index
|
|
8
|
+
*/
|
|
9
|
+
// Use global registry to survive module reloads in development
|
|
10
|
+
const globalCache = globalThis.__CONLOCA_CONTENT_INDEX_CACHE__ || {};
|
|
11
|
+
if (!globalThis.__CONLOCA_CONTENT_INDEX_CACHE__) {
|
|
12
|
+
globalThis.__CONLOCA_CONTENT_INDEX_CACHE__ = globalCache;
|
|
13
|
+
}
|
|
14
|
+
export class ContentIndex {
|
|
15
|
+
sitesConfig;
|
|
16
|
+
// Use global cache instead of static cache
|
|
17
|
+
static get cache() {
|
|
18
|
+
return globalCache;
|
|
19
|
+
}
|
|
20
|
+
// Per-site indexes using V8-optimized object
|
|
21
|
+
siteIndexes;
|
|
22
|
+
// Single block index
|
|
23
|
+
blockIndex;
|
|
24
|
+
// Single data index
|
|
25
|
+
dataIndex;
|
|
26
|
+
constructor(sitesConfig) {
|
|
27
|
+
this.sitesConfig = sitesConfig;
|
|
28
|
+
// Initialize block index
|
|
29
|
+
this.blockIndex = new BlockIndex(sitesConfig.globalLocales);
|
|
30
|
+
// Initialize data index
|
|
31
|
+
this.dataIndex = new DataIndex();
|
|
32
|
+
// Initialize V8-optimized site indexes
|
|
33
|
+
this.siteIndexes = mapSiteNames(sitesConfig, (siteName) => {
|
|
34
|
+
const siteConfig = sitesConfig.sites[siteName];
|
|
35
|
+
return new SiteIndex(siteName, siteConfig.locales);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get cached index or create a new one
|
|
40
|
+
*/
|
|
41
|
+
static async getCachedOrCreate(contentRoot, sitesConfig) {
|
|
42
|
+
if (!ContentIndex.cache[contentRoot]) {
|
|
43
|
+
ContentIndex.cache[contentRoot] = new ContentIndex(sitesConfig);
|
|
44
|
+
}
|
|
45
|
+
return ContentIndex.cache[contentRoot];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clear all cached indexes
|
|
49
|
+
*/
|
|
50
|
+
static clearCache() {
|
|
51
|
+
for (const key of Object.keys(globalCache)) {
|
|
52
|
+
delete globalCache[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a new index without caching - for testing
|
|
57
|
+
*/
|
|
58
|
+
static createUncached(sitesConfig) {
|
|
59
|
+
return new ContentIndex(sitesConfig);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Add or update content in the appropriate index
|
|
63
|
+
* Updates a single locale's manifest and content cache if provided
|
|
64
|
+
*/
|
|
65
|
+
addContent(identity, localeVersion, content) {
|
|
66
|
+
// Validate that blocks and data don't have a site
|
|
67
|
+
if ((identity.kind === 'block' || identity.kind === 'data') && identity.site) {
|
|
68
|
+
throw new Error(`${identity.kind} cannot have a site property`);
|
|
69
|
+
}
|
|
70
|
+
// Validate that pages must have a site
|
|
71
|
+
if (identity.kind === 'page' && !identity.site) {
|
|
72
|
+
throw new Error('Pages must have a site property');
|
|
73
|
+
}
|
|
74
|
+
if (identity.kind === 'block') {
|
|
75
|
+
this.blockIndex.addContent(identity, localeVersion, content);
|
|
76
|
+
}
|
|
77
|
+
else if (identity.kind === 'data') {
|
|
78
|
+
this.dataIndex.addContent(identity, localeVersion, content);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const siteIndex = this.siteIndexes[identity.site];
|
|
82
|
+
if (siteIndex) {
|
|
83
|
+
siteIndex.addContent(identity, localeVersion, content);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Remove a specific locale from content
|
|
89
|
+
*/
|
|
90
|
+
removeLocale(id, locale) {
|
|
91
|
+
const manifest = this.getManifest(id);
|
|
92
|
+
if (!manifest)
|
|
93
|
+
return;
|
|
94
|
+
// Remove from the appropriate index
|
|
95
|
+
if (manifest.kind === 'block') {
|
|
96
|
+
this.blockIndex.removeLocale(id, locale);
|
|
97
|
+
}
|
|
98
|
+
else if (manifest.kind === 'data') {
|
|
99
|
+
this.dataIndex.removeLocale(id, locale);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const siteIndex = this.siteIndexes[manifest.site];
|
|
103
|
+
if (siteIndex) {
|
|
104
|
+
siteIndex.removeLocale(id, locale);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get cached content
|
|
110
|
+
*/
|
|
111
|
+
getCachedContent(id, locale) {
|
|
112
|
+
const manifest = this.getManifest(id);
|
|
113
|
+
if (!manifest)
|
|
114
|
+
return null;
|
|
115
|
+
if (manifest.kind === 'block') {
|
|
116
|
+
return this.blockIndex.getCachedContent(id, locale);
|
|
117
|
+
}
|
|
118
|
+
if (manifest.kind === 'data') {
|
|
119
|
+
return this.dataIndex.getCachedContent(id, locale);
|
|
120
|
+
}
|
|
121
|
+
const siteIndex = this.siteIndexes[manifest.site];
|
|
122
|
+
return siteIndex ? siteIndex.getCachedContent(id, locale) : null;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Remove an entry from all indexes
|
|
126
|
+
*/
|
|
127
|
+
removeEntry(id) {
|
|
128
|
+
// Try blocks first
|
|
129
|
+
this.blockIndex.removeEntry(id);
|
|
130
|
+
// Try data
|
|
131
|
+
this.dataIndex.removeEntry(id);
|
|
132
|
+
// Then try each site
|
|
133
|
+
for (const site in this.siteIndexes) {
|
|
134
|
+
const siteIndex = this.siteIndexes[site];
|
|
135
|
+
if (siteIndex) {
|
|
136
|
+
siteIndex.removeEntry(id);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get content manifest for a content ID
|
|
142
|
+
*/
|
|
143
|
+
getManifest(id) {
|
|
144
|
+
// Check blocks first
|
|
145
|
+
let manifest = this.blockIndex.getManifest(id);
|
|
146
|
+
if (manifest)
|
|
147
|
+
return manifest;
|
|
148
|
+
// Check data
|
|
149
|
+
manifest = this.dataIndex.getManifest(id);
|
|
150
|
+
if (manifest)
|
|
151
|
+
return manifest;
|
|
152
|
+
// Then check each site
|
|
153
|
+
for (const site in this.siteIndexes) {
|
|
154
|
+
const siteIndex = this.siteIndexes[site];
|
|
155
|
+
if (siteIndex) {
|
|
156
|
+
manifest = siteIndex.getManifest(id);
|
|
157
|
+
if (manifest)
|
|
158
|
+
return manifest;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get a specific locale manifest
|
|
165
|
+
*/
|
|
166
|
+
getLocaleVersion(id, locale) {
|
|
167
|
+
const manifest = this.getManifest(id);
|
|
168
|
+
if (!manifest)
|
|
169
|
+
return null;
|
|
170
|
+
return manifest.locales[locale] || null;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get site index
|
|
174
|
+
*/
|
|
175
|
+
getSiteIndex(site) {
|
|
176
|
+
return this.siteIndexes[site] || null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get block index
|
|
180
|
+
*/
|
|
181
|
+
getBlockIndex() {
|
|
182
|
+
return this.blockIndex;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Find content by pathname (delegates to site indexes)
|
|
186
|
+
*/
|
|
187
|
+
getByPathname(site, pathname, locale) {
|
|
188
|
+
const siteIndex = this.siteIndexes[site];
|
|
189
|
+
return siteIndex ? siteIndex.getByPathname(pathname, locale) : null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Find content by previous pathname (for redirects)
|
|
193
|
+
*/
|
|
194
|
+
getByPreviousPathname(site, pathname, locale) {
|
|
195
|
+
const siteIndex = this.siteIndexes[site];
|
|
196
|
+
return siteIndex ? siteIndex.getByPreviousPathname(pathname, locale) : null;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Find block by name
|
|
200
|
+
*/
|
|
201
|
+
getBlockByName(collection, name, locale) {
|
|
202
|
+
return this.blockIndex.getByName(collection, name, locale);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get data index
|
|
206
|
+
*/
|
|
207
|
+
getDataIndex() {
|
|
208
|
+
return this.dataIndex;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Find data entry by name
|
|
212
|
+
*/
|
|
213
|
+
getDataByName(collection, name, locale) {
|
|
214
|
+
return this.dataIndex.getByName(collection, name, locale);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get all collections for data
|
|
218
|
+
*/
|
|
219
|
+
getDataCollections() {
|
|
220
|
+
return this.dataIndex.collections;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* List all content (for iteration)
|
|
224
|
+
*/
|
|
225
|
+
*listAllContent() {
|
|
226
|
+
// Yield all blocks
|
|
227
|
+
yield* this.blockIndex.getAllManifests();
|
|
228
|
+
// Yield all data entries
|
|
229
|
+
yield* this.dataIndex.getAllManifests();
|
|
230
|
+
// Yield all site entries
|
|
231
|
+
for (const site in this.siteIndexes) {
|
|
232
|
+
const siteIndex = this.siteIndexes[site];
|
|
233
|
+
if (siteIndex) {
|
|
234
|
+
yield* siteIndex.getAllManifests();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Generator for all sites
|
|
240
|
+
*/
|
|
241
|
+
*allSites() {
|
|
242
|
+
for (const site in this.siteIndexes) {
|
|
243
|
+
if (this.siteIndexes[site]) {
|
|
244
|
+
yield site;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Get all collections for a site
|
|
250
|
+
*/
|
|
251
|
+
getCollectionsForSite(site) {
|
|
252
|
+
const siteIndex = this.siteIndexes[site];
|
|
253
|
+
return siteIndex ? siteIndex.collections : new Set();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get all collections for blocks
|
|
257
|
+
*/
|
|
258
|
+
getBlockCollections() {
|
|
259
|
+
return this.blockIndex.collections;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Get default locale for a site
|
|
263
|
+
*/
|
|
264
|
+
getDefaultLocale(site) {
|
|
265
|
+
// This method should only be called for pages, but handle gracefully
|
|
266
|
+
if (!site) {
|
|
267
|
+
return this.sitesConfig.globalLocales[0];
|
|
268
|
+
}
|
|
269
|
+
const siteConfig = this.sitesConfig.sites[site];
|
|
270
|
+
return siteConfig?.defaultLocale || this.sitesConfig.globalLocales[0];
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Find content missing a specific locale
|
|
274
|
+
*/
|
|
275
|
+
*findUntranslatedContent(targetLocale, options) {
|
|
276
|
+
// Always check blocks as they don't belong to any site
|
|
277
|
+
for (const manifest of this.blockIndex.getAllManifests()) {
|
|
278
|
+
if (!manifest.locales[targetLocale]) {
|
|
279
|
+
// Check if we should include unpublished content
|
|
280
|
+
if (!options?.includeUnpublished) {
|
|
281
|
+
// Need to check if any locale is published
|
|
282
|
+
let hasPublishedLocale = false;
|
|
283
|
+
for (const locale of localesOf(manifest)) {
|
|
284
|
+
if (!locale.unpublishAt || new Date(locale.unpublishAt) > new Date()) {
|
|
285
|
+
hasPublishedLocale = true;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (!hasPublishedLocale)
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
yield manifest;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Check each site
|
|
296
|
+
for (const siteName in this.siteIndexes) {
|
|
297
|
+
const siteIndex = this.siteIndexes[siteName];
|
|
298
|
+
if (!siteIndex || options?.excludeSites?.includes(siteName))
|
|
299
|
+
continue;
|
|
300
|
+
for (const manifest of siteIndex.getAllManifests()) {
|
|
301
|
+
if (!manifest.locales[targetLocale]) {
|
|
302
|
+
// Check if we should include unpublished content
|
|
303
|
+
if (!options?.includeUnpublished) {
|
|
304
|
+
let hasPublishedLocale = false;
|
|
305
|
+
for (const locale of localesOf(manifest)) {
|
|
306
|
+
if (!locale.unpublishAt || new Date(locale.unpublishAt) > new Date()) {
|
|
307
|
+
hasPublishedLocale = true;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (!hasPublishedLocale)
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
yield manifest;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Generators for efficient filtering
|
|
321
|
+
*/
|
|
322
|
+
*getManifestsForKind(kind) {
|
|
323
|
+
if (kind === 'block') {
|
|
324
|
+
yield* this.blockIndex.getAllManifests();
|
|
325
|
+
}
|
|
326
|
+
else if (kind === 'data') {
|
|
327
|
+
yield* this.dataIndex.getAllManifests();
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
for (const site in this.siteIndexes) {
|
|
331
|
+
const siteIndex = this.siteIndexes[site];
|
|
332
|
+
if (siteIndex) {
|
|
333
|
+
yield* siteIndex.getAllManifests();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
*getManifestsForSite(site) {
|
|
339
|
+
const siteIndex = this.siteIndexes[site];
|
|
340
|
+
if (siteIndex) {
|
|
341
|
+
yield* siteIndex.getAllManifests();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
*getManifestsForSiteLocale(site, locale) {
|
|
345
|
+
const siteIndex = this.siteIndexes[site];
|
|
346
|
+
if (siteIndex) {
|
|
347
|
+
yield* siteIndex.getManifestsByLocale(locale);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
*getManifestsForSiteCollection(site, collection) {
|
|
351
|
+
// For regular sites, we need to filter by collection
|
|
352
|
+
const siteIndex = this.siteIndexes[site];
|
|
353
|
+
if (siteIndex) {
|
|
354
|
+
for (const manifest of siteIndex.getAllManifests()) {
|
|
355
|
+
if (manifest.collection === collection) {
|
|
356
|
+
yield manifest;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
*getManifestsForLocale(locale) {
|
|
362
|
+
// Yield from blocks
|
|
363
|
+
yield* this.blockIndex.getManifestsByLocale(locale);
|
|
364
|
+
// Yield from data
|
|
365
|
+
yield* this.dataIndex.getManifestsByLocale(locale);
|
|
366
|
+
// Yield from all sites
|
|
367
|
+
for (const site in this.siteIndexes) {
|
|
368
|
+
const siteIndex = this.siteIndexes[site];
|
|
369
|
+
if (siteIndex) {
|
|
370
|
+
yield* siteIndex.getManifestsByLocale(locale);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
*getManifestsForCollection(collection) {
|
|
375
|
+
// Check blocks first
|
|
376
|
+
yield* this.blockIndex.getManifestsByCollection(collection);
|
|
377
|
+
// Check data
|
|
378
|
+
yield* this.dataIndex.getManifestsByCollection(collection);
|
|
379
|
+
// Then check all sites
|
|
380
|
+
for (const site in this.siteIndexes) {
|
|
381
|
+
const siteIndex = this.siteIndexes[site];
|
|
382
|
+
if (siteIndex) {
|
|
383
|
+
for (const manifest of siteIndex.getAllManifests()) {
|
|
384
|
+
if (manifest.collection === collection) {
|
|
385
|
+
yield manifest;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Get the count of indexed content entries
|
|
393
|
+
*/
|
|
394
|
+
get entryCount() {
|
|
395
|
+
let count = this.blockIndex.entryCount;
|
|
396
|
+
count += this.dataIndex.entryCount;
|
|
397
|
+
for (const site in this.siteIndexes) {
|
|
398
|
+
const siteIndex = this.siteIndexes[site];
|
|
399
|
+
if (siteIndex) {
|
|
400
|
+
count += siteIndex.entryCount;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return count;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Clear all indexes
|
|
407
|
+
*/
|
|
408
|
+
clear() {
|
|
409
|
+
this.blockIndex.clear();
|
|
410
|
+
this.dataIndex.clear();
|
|
411
|
+
for (const site in this.siteIndexes) {
|
|
412
|
+
const siteIndex = this.siteIndexes[site];
|
|
413
|
+
if (siteIndex) {
|
|
414
|
+
siteIndex.clear();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|