@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.
Files changed (187) hide show
  1. package/dist/asset-manifest.d.ts +23 -0
  2. package/dist/asset-manifest.d.ts.map +1 -0
  3. package/dist/asset-manifest.js +73 -0
  4. package/dist/asset-operations.d.ts +159 -0
  5. package/dist/asset-operations.d.ts.map +1 -0
  6. package/dist/asset-operations.js +736 -0
  7. package/dist/asset-types.d.ts +56 -0
  8. package/dist/asset-types.d.ts.map +1 -0
  9. package/dist/asset-types.js +7 -0
  10. package/dist/base-content-index.d.ts +57 -0
  11. package/dist/base-content-index.d.ts.map +1 -0
  12. package/dist/base-content-index.js +179 -0
  13. package/dist/block-index.d.ts +9 -0
  14. package/dist/block-index.d.ts.map +1 -0
  15. package/dist/block-index.js +11 -0
  16. package/dist/blocks.d.ts +16 -0
  17. package/dist/blocks.d.ts.map +1 -0
  18. package/dist/blocks.js +103 -0
  19. package/dist/cf-access.d.ts +31 -0
  20. package/dist/cf-access.d.ts.map +1 -0
  21. package/dist/cf-access.js +66 -0
  22. package/dist/component-registry.d.ts +50 -0
  23. package/dist/component-registry.d.ts.map +1 -0
  24. package/dist/component-registry.js +120 -0
  25. package/dist/{component-registry.types-CBGONnYn.d.mts → component-registry.types-C0ctF9nh.d.mts} +1 -1
  26. package/dist/component-registry.types-C0ctF9nh.d.mts.map +1 -0
  27. package/dist/component-registry.types.d.ts +11 -0
  28. package/dist/component-registry.types.d.ts.map +1 -0
  29. package/dist/component-registry.types.js +1 -0
  30. package/dist/content-api.interface.d.ts +64 -0
  31. package/dist/content-api.interface.d.ts.map +1 -0
  32. package/dist/content-api.interface.js +1 -0
  33. package/dist/content-filters.d.ts +31 -0
  34. package/dist/content-filters.d.ts.map +1 -0
  35. package/dist/content-filters.js +246 -0
  36. package/dist/content-index-D092_vk1.mjs +629 -0
  37. package/dist/content-index-D092_vk1.mjs.map +1 -0
  38. package/dist/content-index-D6IVMmAB.d.mts +127 -0
  39. package/dist/content-index-D6IVMmAB.d.mts.map +1 -0
  40. package/dist/content-index.d.ts +126 -0
  41. package/dist/content-index.d.ts.map +1 -0
  42. package/dist/content-index.js +418 -0
  43. package/dist/content-operations-DIbsxG5A.d.mts +354 -0
  44. package/dist/content-operations-DIbsxG5A.d.mts.map +1 -0
  45. package/dist/content-operations.d.ts +93 -0
  46. package/dist/content-operations.d.ts.map +1 -0
  47. package/dist/content-operations.js +275 -0
  48. package/dist/content-reader.d.ts +10 -0
  49. package/dist/content-reader.d.ts.map +1 -0
  50. package/dist/content-reader.js +13 -0
  51. package/dist/content-utils-fWNHTrPy.mjs +280 -0
  52. package/dist/content-utils-fWNHTrPy.mjs.map +1 -0
  53. package/dist/content-utils.d.ts +132 -0
  54. package/dist/content-utils.d.ts.map +1 -0
  55. package/dist/content-utils.js +352 -0
  56. package/dist/content-watcher.d.ts +43 -0
  57. package/dist/content-watcher.d.ts.map +1 -0
  58. package/dist/content-watcher.js +83 -0
  59. package/dist/{data-Db1Iv9T0.mjs → data-DquNIEnQ.mjs} +4 -2
  60. package/dist/{data-Db1Iv9T0.mjs.map → data-DquNIEnQ.mjs.map} +1 -1
  61. package/dist/data-index.d.ts +8 -0
  62. package/dist/data-index.d.ts.map +1 -0
  63. package/dist/data-index.js +7 -0
  64. package/dist/data.d.ts +43 -0
  65. package/dist/data.d.ts.map +1 -0
  66. package/dist/data.js +103 -0
  67. package/dist/etag-utils.d.ts +77 -0
  68. package/dist/etag-utils.d.ts.map +1 -0
  69. package/dist/etag-utils.js +160 -0
  70. package/dist/filesystem-content-api-B1KIQJfk.mjs +2 -0
  71. package/dist/{filesystem-content-api-kxKY5IUw.mjs → filesystem-content-api-C0HIhqZi.mjs} +172 -1230
  72. package/dist/filesystem-content-api-C0HIhqZi.mjs.map +1 -0
  73. package/dist/{filesystem-content-api-C1TM0GLo.d.mts → filesystem-content-api-DCdNi-co.d.mts} +19 -4
  74. package/dist/filesystem-content-api-DCdNi-co.d.mts.map +1 -0
  75. package/dist/filesystem-content-api.d.ts +135 -0
  76. package/dist/filesystem-content-api.d.ts.map +1 -0
  77. package/dist/filesystem-content-api.js +2181 -0
  78. package/dist/git-operations.d.ts +49 -0
  79. package/dist/git-operations.d.ts.map +1 -0
  80. package/dist/git-operations.js +252 -0
  81. package/dist/header-parser.d.ts +37 -0
  82. package/dist/header-parser.d.ts.map +1 -0
  83. package/dist/header-parser.js +286 -0
  84. package/dist/in-memory-content-api.d.ts +35 -0
  85. package/dist/in-memory-content-api.d.ts.map +1 -0
  86. package/dist/in-memory-content-api.js +591 -0
  87. package/dist/index-DxVTFK66.d.mts +105 -0
  88. package/dist/index-DxVTFK66.d.mts.map +1 -0
  89. package/dist/index.d.mts +6 -5
  90. package/dist/index.d.mts.map +1 -1
  91. package/dist/index.d.ts +19 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +16 -0
  94. package/dist/index.mjs +37 -6
  95. package/dist/index.mjs.map +1 -1
  96. package/dist/indexing.d.mts +152 -0
  97. package/dist/indexing.d.mts.map +1 -0
  98. package/dist/indexing.d.ts +5 -0
  99. package/dist/indexing.d.ts.map +1 -0
  100. package/dist/indexing.js +7 -0
  101. package/dist/indexing.mjs +255 -0
  102. package/dist/indexing.mjs.map +1 -0
  103. package/dist/json-whitespace-view.d.ts +32 -0
  104. package/dist/json-whitespace-view.d.ts.map +1 -0
  105. package/dist/json-whitespace-view.js +152 -0
  106. package/dist/middleware.d.ts +20 -0
  107. package/dist/middleware.d.ts.map +1 -0
  108. package/dist/middleware.js +1031 -0
  109. package/dist/node.d.mts +10 -15
  110. package/dist/node.d.mts.map +1 -1
  111. package/dist/node.d.ts +25 -0
  112. package/dist/node.d.ts.map +1 -0
  113. package/dist/node.js +24 -0
  114. package/dist/node.mjs +89 -135
  115. package/dist/node.mjs.map +1 -1
  116. package/dist/reader.d.mts +5 -8
  117. package/dist/reader.d.mts.map +1 -1
  118. package/dist/reader.d.ts +15 -0
  119. package/dist/reader.d.ts.map +1 -0
  120. package/dist/reader.js +13 -0
  121. package/dist/reader.mjs +8 -8
  122. package/dist/reader.mjs.map +1 -1
  123. package/dist/schemas/index.d.mts +2 -90
  124. package/dist/schemas/index.d.ts +102 -0
  125. package/dist/schemas/index.d.ts.map +1 -0
  126. package/dist/schemas/index.js +87 -0
  127. package/dist/schemas/index.mjs +2 -70
  128. package/dist/schemas-CFRD0FIQ.mjs +84 -0
  129. package/dist/schemas-CFRD0FIQ.mjs.map +1 -0
  130. package/dist/{site-vNtJ5jCh.mjs → site-8oaj1Q60.mjs} +21 -193
  131. package/dist/site-8oaj1Q60.mjs.map +1 -0
  132. package/dist/site-index-B_254bCc.d.mts +136 -0
  133. package/dist/site-index-B_254bCc.d.mts.map +1 -0
  134. package/dist/site-index.d.ts +60 -0
  135. package/dist/site-index.d.ts.map +1 -0
  136. package/dist/site-index.js +287 -0
  137. package/dist/site.d.ts +21 -0
  138. package/dist/site.d.ts.map +1 -0
  139. package/dist/site.js +168 -0
  140. package/dist/{types-DWt912tu.mjs → types-DOdldbfD.mjs} +3 -2
  141. package/dist/types-DOdldbfD.mjs.map +1 -0
  142. package/dist/types-DjfhS272.d.mts +456 -0
  143. package/dist/types-DjfhS272.d.mts.map +1 -0
  144. package/dist/types.d.ts +453 -0
  145. package/dist/types.d.ts.map +1 -0
  146. package/dist/types.js +36 -0
  147. package/dist/url-safe-base64.d.ts +12 -0
  148. package/dist/url-safe-base64.d.ts.map +1 -0
  149. package/dist/url-safe-base64.js +40 -0
  150. package/dist/url-validation.d.ts +14 -0
  151. package/dist/url-validation.d.ts.map +1 -0
  152. package/dist/url-validation.js +81 -0
  153. package/dist/utils/atomic-write.d.ts +6 -0
  154. package/dist/utils/atomic-write.d.ts.map +1 -0
  155. package/dist/utils/atomic-write.js +20 -0
  156. package/dist/utils.d.ts +46 -0
  157. package/dist/utils.d.ts.map +1 -0
  158. package/dist/utils.js +70 -0
  159. package/dist/vite-plugin.d.ts +12 -0
  160. package/dist/vite-plugin.d.ts.map +1 -0
  161. package/dist/vite-plugin.js +29 -0
  162. package/dist/vxjson-qHrgLGip.mjs +555 -0
  163. package/dist/vxjson-qHrgLGip.mjs.map +1 -0
  164. package/dist/vxjson-serialize-geF6qvpn.mjs +34 -0
  165. package/dist/vxjson-serialize-geF6qvpn.mjs.map +1 -0
  166. package/dist/vxjson-serialize.d.mts +17 -0
  167. package/dist/vxjson-serialize.d.mts.map +1 -0
  168. package/dist/vxjson-serialize.d.ts +14 -0
  169. package/dist/vxjson-serialize.d.ts.map +1 -0
  170. package/dist/vxjson-serialize.js +50 -0
  171. package/dist/vxjson-serialize.mjs +2 -0
  172. package/dist/vxjson.d.ts +112 -0
  173. package/dist/vxjson.d.ts.map +1 -0
  174. package/dist/vxjson.js +391 -0
  175. package/dist/xxhash.d.ts +10 -0
  176. package/dist/xxhash.d.ts.map +1 -0
  177. package/dist/xxhash.js +31 -0
  178. package/package.json +79 -17
  179. package/dist/component-registry.types-CBGONnYn.d.mts.map +0 -1
  180. package/dist/content-operations-Dv67amz3.d.mts +0 -852
  181. package/dist/content-operations-Dv67amz3.d.mts.map +0 -1
  182. package/dist/filesystem-content-api-C1TM0GLo.d.mts.map +0 -1
  183. package/dist/filesystem-content-api-kxKY5IUw.mjs.map +0 -1
  184. package/dist/schemas/index.d.mts.map +0 -1
  185. package/dist/schemas/index.mjs.map +0 -1
  186. package/dist/site-vNtJ5jCh.mjs.map +0 -1
  187. package/dist/types-DWt912tu.mjs.map +0 -1
@@ -0,0 +1,275 @@
1
+ import sortKeys from 'sort-keys';
2
+ import { generateContentId, isContentPublished, normalizeAndValidatePathname } from './content-utils';
3
+ /**
4
+ * Validate and prepare metadata for storage
5
+ * Ensures title exists and metadata doesn't exceed 4KB
6
+ */
7
+ export function validateAndPrepareMetadata(meta) {
8
+ // Ensure title is present
9
+ if (!meta.title) {
10
+ return {
11
+ valid: false,
12
+ error: 'Title is required in metadata',
13
+ };
14
+ }
15
+ const sortedMeta = sortKeys(meta, { deep: true }); // We've validated title exists
16
+ const metaJson = JSON.stringify(sortedMeta, null, 2);
17
+ const metaSize = new TextEncoder().encode(metaJson).length;
18
+ if (metaSize > 4088) {
19
+ // Leave 8 bytes for safety
20
+ return {
21
+ valid: false,
22
+ error: `Metadata exceeds 4KB limit (${metaSize} bytes)`,
23
+ };
24
+ }
25
+ return {
26
+ valid: true,
27
+ sortedMeta,
28
+ size: metaSize,
29
+ };
30
+ }
31
+ /**
32
+ * Build pathname history update
33
+ */
34
+ export function buildPathnameHistory(oldPathname, newPathname, isPublished, now) {
35
+ const history = {};
36
+ if (oldPathname && newPathname && oldPathname !== newPathname && isPublished) {
37
+ history[oldPathname] = now;
38
+ }
39
+ return history;
40
+ }
41
+ /**
42
+ * Build a locale manifest
43
+ */
44
+ export function buildLocaleVersion(params) {
45
+ const manifest = {
46
+ locale: params.locale,
47
+ etag: params.etag,
48
+ created: params.created,
49
+ modified: params.modified,
50
+ meta: params.meta,
51
+ };
52
+ // Add optional fields only if they exist
53
+ if (params.publishAt) {
54
+ manifest.publishAt = params.publishAt;
55
+ }
56
+ if (params.unpublishAt) {
57
+ manifest.unpublishAt = params.unpublishAt;
58
+ }
59
+ if (params.pathname && params.kind === 'page') {
60
+ manifest.pathname = params.pathname;
61
+ }
62
+ if (params.name && (params.kind === 'block' || params.kind === 'data')) {
63
+ manifest.name = params.name;
64
+ }
65
+ if (params.previousPathnames && Object.keys(params.previousPathnames).length > 0) {
66
+ manifest.previousPathnames = params.previousPathnames;
67
+ }
68
+ return manifest;
69
+ }
70
+ /**
71
+ * Update publish dates on a locale manifest
72
+ */
73
+ export function updatePublishDates(manifest, data) {
74
+ // Handle publishAt
75
+ if ('publishAt' in data) {
76
+ if (data.publishAt && typeof data.publishAt === 'string') {
77
+ manifest.publishAt = data.publishAt;
78
+ }
79
+ else {
80
+ // Explicitly delete the field when value is falsy
81
+ delete manifest.publishAt;
82
+ }
83
+ }
84
+ // Handle unpublishAt
85
+ if ('unpublishAt' in data) {
86
+ if (data.unpublishAt && typeof data.unpublishAt === 'string') {
87
+ manifest.unpublishAt = data.unpublishAt;
88
+ }
89
+ else {
90
+ // Explicitly delete the field when value is falsy
91
+ delete manifest.unpublishAt;
92
+ }
93
+ }
94
+ }
95
+ /**
96
+ * Validate content creation data
97
+ */
98
+ export function validateCreateContent(data, sites, blocks, dataApi) {
99
+ // Validate metadata for all locales
100
+ for (const localeData of Object.values(data.locales)) {
101
+ const meta = { ...data.meta, ...localeData.meta };
102
+ const validation = validateAndPrepareMetadata(meta);
103
+ if (!validation.valid) {
104
+ return {
105
+ valid: false,
106
+ error: validation.error,
107
+ reason: 'metadata_too_large',
108
+ };
109
+ }
110
+ }
111
+ // Validate pathname for pages
112
+ if (data.kind === 'page') {
113
+ if (!data.site) {
114
+ return {
115
+ valid: false,
116
+ error: 'Site is required for pages',
117
+ };
118
+ }
119
+ const site = sites[data.site];
120
+ if (!site) {
121
+ return {
122
+ valid: false,
123
+ error: `Site ${data.site} not found`,
124
+ };
125
+ }
126
+ for (const [locale, localeData] of Object.entries(data.locales)) {
127
+ const pathname = localeData.pathname;
128
+ // Pathname is required for pages
129
+ if (!pathname) {
130
+ return {
131
+ valid: false,
132
+ error: `Pathname is required for pages (locale: ${locale})`,
133
+ };
134
+ }
135
+ // Validate and normalize pathname shape. The normalized value is
136
+ // written back to localeData so the rest of the create flow (file
137
+ // writes, indexing) sees the cleaned form.
138
+ const validation = normalizeAndValidatePathname(pathname);
139
+ if (!validation.valid) {
140
+ return {
141
+ valid: false,
142
+ error: `Invalid pathname for locale ${locale}: ${validation.message}`,
143
+ reason: 'invalid_pathname',
144
+ };
145
+ }
146
+ localeData.pathname = validation.value;
147
+ const normalized = validation.value;
148
+ // Check if pathname is already taken
149
+ const existingId = site.getPathnameConflict(normalized, locale);
150
+ if (existingId) {
151
+ return {
152
+ valid: false,
153
+ error: `Pathname ${normalized} already exists`,
154
+ reason: 'pathname_taken',
155
+ existingId,
156
+ };
157
+ }
158
+ // Check if pathname is in redirects
159
+ if (site.isPathnameInRedirects(normalized, locale)) {
160
+ return {
161
+ valid: false,
162
+ error: `Pathname ${normalized} is already in use as a redirect`,
163
+ reason: 'pathname_in_redirects',
164
+ };
165
+ }
166
+ }
167
+ }
168
+ // Validate block name uniqueness
169
+ if (data.kind === 'block') {
170
+ if (!data.name) {
171
+ return {
172
+ valid: false,
173
+ error: 'Block name is required',
174
+ reason: 'invalid_name',
175
+ };
176
+ }
177
+ // Validate block name format
178
+ if (!blocks.isBlockNameValid(data.name)) {
179
+ return {
180
+ valid: false,
181
+ error: `Invalid block name: ${data.name}. Block names must contain only alphanumeric characters, hyphens, and underscores.`,
182
+ reason: 'invalid_name',
183
+ };
184
+ }
185
+ // Check if name is already taken in any locale
186
+ const existingId = blocks.getNameConflict(data.collection, data.name);
187
+ if (existingId) {
188
+ return {
189
+ valid: false,
190
+ error: `Block name ${data.name} already exists in collection ${data.collection}`,
191
+ reason: 'name_taken',
192
+ existingId,
193
+ };
194
+ }
195
+ }
196
+ // Validate data entry name uniqueness
197
+ if (data.kind === 'data' && dataApi) {
198
+ if (!data.name) {
199
+ return {
200
+ valid: false,
201
+ error: 'Data name is required',
202
+ reason: 'invalid_name',
203
+ };
204
+ }
205
+ // Validate data name format
206
+ if (!dataApi.isDataNameValid(data.name)) {
207
+ return {
208
+ valid: false,
209
+ error: `Invalid data name: ${data.name}. Data names must contain only alphanumeric characters, hyphens, and underscores.`,
210
+ reason: 'invalid_name',
211
+ };
212
+ }
213
+ // Check if name is already taken in any locale
214
+ const existingId = dataApi.getNameConflict(data.collection, data.name);
215
+ if (existingId) {
216
+ return {
217
+ valid: false,
218
+ error: `Data name ${data.name} already exists in collection ${data.collection}`,
219
+ reason: 'name_taken',
220
+ existingId,
221
+ };
222
+ }
223
+ }
224
+ return { valid: true };
225
+ }
226
+ /**
227
+ * Generate a new content ID
228
+ */
229
+ /**
230
+ * Check if content is published
231
+ */
232
+ export { generateContentId, isContentPublished };
233
+ /**
234
+ * Update scope bit flags
235
+ * Can be combined with bitwise OR and checked with bitwise AND
236
+ */
237
+ export const UPDATE_SCOPE = {
238
+ NONE: 0, // 00
239
+ META: 1 << 0, // 01
240
+ CONTENT: 1 << 1, // 10
241
+ BOTH: 3, // 11 (META | CONTENT)
242
+ };
243
+ /**
244
+ * Determine what parts of content are being updated
245
+ * Returns bit flags that can be checked with bitwise AND
246
+ *
247
+ * Example usage:
248
+ * ```
249
+ * const scope = analyzeUpdateScope(data);
250
+ * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }
251
+ * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }
252
+ * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }
253
+ * ```
254
+ */
255
+ export function analyzeUpdateScope(data) {
256
+ let scope = UPDATE_SCOPE.NONE;
257
+ // Note: pathname is NOT considered a metadata change because:
258
+ // - For pages, pathname is derived from file path, not stored in metadata
259
+ // - Pathname changes don't affect the metadata hash in the ETag
260
+ if (data.meta !== undefined || data.publishAt !== undefined || data.unpublishAt !== undefined) {
261
+ scope |= UPDATE_SCOPE.META;
262
+ }
263
+ if (data.content !== undefined) {
264
+ scope |= UPDATE_SCOPE.CONTENT;
265
+ }
266
+ return scope;
267
+ }
268
+ /**
269
+ * Determine whether the modified timestamp should be updated
270
+ * Updates for ANY change - either metadata or content
271
+ */
272
+ export function shouldUpdateModifiedTimestamp(data) {
273
+ const scope = analyzeUpdateScope(data);
274
+ return scope !== UPDATE_SCOPE.NONE;
275
+ }
@@ -0,0 +1,10 @@
1
+ import type { ContentAPIOptions } from './types';
2
+ export type ContentReaderOptions = ContentAPIOptions;
3
+ /**
4
+ * Creates a read-oriented content API instance for build-time consumers.
5
+ *
6
+ * The filesystem implementation is loaded lazily so build tooling does not
7
+ * eagerly traverse native hashing dependencies through the reader entrypoint.
8
+ */
9
+ export declare function createContentAPI(options: ContentReaderOptions): Promise<import("./filesystem-content-api").FileSystemContentAPI>;
10
+ //# sourceMappingURL=content-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-reader.d.ts","sourceRoot":"","sources":["../src/content-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAErD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,oEAOnE"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Creates a read-oriented content API instance for build-time consumers.
3
+ *
4
+ * The filesystem implementation is loaded lazily so build tooling does not
5
+ * eagerly traverse native hashing dependencies through the reader entrypoint.
6
+ */
7
+ export async function createContentAPI(options) {
8
+ const { FileSystemContentAPI: ReaderAPI } = await import('./filesystem-content-api');
9
+ return ReaderAPI.create({
10
+ ...options,
11
+ canvasDir: options.canvasDir || './canvas',
12
+ });
13
+ }
@@ -0,0 +1,280 @@
1
+ import { nanoid } from "nanoid";
2
+ import yaml, { Document, isScalar } from "yaml";
3
+ //#region src/content-utils.ts
4
+ const FRONTMATTER_KEY_ORDER = [
5
+ "title",
6
+ "category",
7
+ "description",
8
+ "id",
9
+ "created",
10
+ "modified",
11
+ "publishAt",
12
+ "unpublishAt"
13
+ ];
14
+ const ISO_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
15
+ function* localesOf(manifest) {
16
+ for (const value of Object.values(manifest.locales)) if (value) yield value;
17
+ }
18
+ /**
19
+ * Pure utility functions for content operations
20
+ * These functions don't depend on any class state and can be shared
21
+ * between FileSystemContentAPI, InMemoryContentAPI, and other implementations
22
+ */
23
+ /**
24
+ * Check if content is published based on publishAt/unpublishAt dates
25
+ */
26
+ function isContentPublished(localeVersion, now = /* @__PURE__ */ new Date()) {
27
+ if (localeVersion.publishAt) {
28
+ const publishDate = new Date(localeVersion.publishAt);
29
+ if (!isNaN(publishDate.getTime()) && publishDate > now) return false;
30
+ }
31
+ if (localeVersion.unpublishAt) {
32
+ const unpublishDate = new Date(localeVersion.unpublishAt);
33
+ if (!isNaN(unpublishDate.getTime()) && unpublishDate < now) return false;
34
+ }
35
+ return true;
36
+ }
37
+ /**
38
+ * Validate that metadata doesn't exceed 4KB when serialized
39
+ * This ensures efficient indexing as per the specification
40
+ */
41
+ function isMetadataTooLarge(meta) {
42
+ return new TextEncoder().encode(JSON.stringify(meta)).length > 4096;
43
+ }
44
+ /**
45
+ * Extract block name from various sources
46
+ * Used when displaying blocks in the UI
47
+ */
48
+ function extractBlockName(source) {
49
+ if (source.includes("/") && !source.includes(".")) {
50
+ const parts = source.split("/");
51
+ return parts[parts.length - 1];
52
+ }
53
+ if (source.includes(".")) {
54
+ const match = source.match(/^(.+?)\.([a-z]{2})?\.(mdx|vxjson)$/);
55
+ if (match) return match[1];
56
+ return source.replace(/\.[^.]+$/, "");
57
+ }
58
+ if (source.startsWith("vx-")) return `block-${source.substring(3, 8)}`;
59
+ return source;
60
+ }
61
+ /**
62
+ * Validate block name according to the specification
63
+ * - Cannot contain dots (reserved for locale separator)
64
+ * - Cannot contain slashes (would create subdirectories)
65
+ * - Cannot contain spaces (for clean filenames)
66
+ * - Must have at least one character
67
+ */
68
+ function isValidBlockName(name) {
69
+ if (!name || name.length === 0) return false;
70
+ if (name.includes(".")) return false;
71
+ if (name.includes("/")) return false;
72
+ if (name.includes(" ")) return false;
73
+ return true;
74
+ }
75
+ /**
76
+ * Format file size for display with human-readable units
77
+ * @example formatFileSize(1536) // "1.5 KB"
78
+ */
79
+ function formatFileSize(bytes) {
80
+ if (bytes < 1024) return `${bytes} B`;
81
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
82
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
83
+ }
84
+ /**
85
+ * Calculate metadata size in bytes
86
+ */
87
+ function getMetadataSize(meta) {
88
+ return new TextEncoder().encode(JSON.stringify(meta)).length;
89
+ }
90
+ /**
91
+ * Check if a pathname is valid
92
+ * - Must start with /
93
+ * - Cannot contain spaces (should be URL-encoded)
94
+ * - Cannot contain special characters that would break URLs
95
+ */
96
+ function isValidPathname(pathname) {
97
+ if (!pathname || !pathname.startsWith("/")) return false;
98
+ if (pathname.includes(" ")) return false;
99
+ if (pathname.includes("?") || pathname.includes("#")) return false;
100
+ return true;
101
+ }
102
+ /**
103
+ * Normalize a pathname to ensure consistency
104
+ * - Ensure it starts with /
105
+ * - Remove trailing slashes (except for root)
106
+ * - Collapse multiple slashes
107
+ */
108
+ function normalizePathname(pathname) {
109
+ if (!pathname) return "/";
110
+ let normalized = pathname;
111
+ if (!normalized.startsWith("/")) normalized = `/${normalized}`;
112
+ normalized = normalized.replace(/\/+/g, "/");
113
+ if (normalized !== "/" && normalized.endsWith("/")) normalized = normalized.slice(0, -1);
114
+ return normalized;
115
+ }
116
+ /**
117
+ * Validate the shape of a CMS pathname and normalize it for storage.
118
+ *
119
+ * Silently fixes harmless slips (missing leading slash, doubled slashes,
120
+ * trailing slash) and rejects malformed inputs with a specific reason so
121
+ * the UI can show a helpful error message.
122
+ *
123
+ * Accepted chars: a–z, 0–9, `-`, `_`, `/`. Mixed case, accents, spaces,
124
+ * `?`, `#`, `\`, and traversal segments (`.`, `..`) are rejected.
125
+ */
126
+ function normalizeAndValidatePathname(input) {
127
+ const raw = (input ?? "").trim();
128
+ if (raw === "") return {
129
+ value: "",
130
+ valid: false,
131
+ reason: "empty",
132
+ message: "Path is required"
133
+ };
134
+ if (/\s/.test(raw)) return {
135
+ value: raw,
136
+ valid: false,
137
+ reason: "whitespace",
138
+ message: "Path cannot contain spaces"
139
+ };
140
+ if (/[?#\\]/.test(raw)) return {
141
+ value: raw,
142
+ valid: false,
143
+ reason: "forbidden_char",
144
+ message: "Path cannot contain `?`, `#`, or `\\`"
145
+ };
146
+ if (/[\x00-\x1F\x7F]/.test(raw)) return {
147
+ value: raw,
148
+ valid: false,
149
+ reason: "control_char",
150
+ message: "Path cannot contain control characters"
151
+ };
152
+ if (/[A-Z]/.test(raw)) return {
153
+ value: raw,
154
+ valid: false,
155
+ reason: "uppercase",
156
+ message: "Path must be lowercase"
157
+ };
158
+ if (/[^\x00-\x7F]/.test(raw)) return {
159
+ value: raw,
160
+ valid: false,
161
+ reason: "non_ascii",
162
+ message: "Path can only contain a–z, 0–9, `-`, `_`, `/`"
163
+ };
164
+ let value = raw;
165
+ if (!value.startsWith("/")) value = "/" + value;
166
+ value = value.replace(/\/+/g, "/");
167
+ if (value !== "/" && value.endsWith("/")) value = value.slice(0, -1);
168
+ if (value !== "/") {
169
+ for (const seg of value.slice(1).split("/")) if (seg === "." || seg === "..") return {
170
+ value,
171
+ valid: false,
172
+ reason: "traversal_segment",
173
+ message: "Path cannot contain `.` or `..` segments"
174
+ };
175
+ }
176
+ if (!/^[a-z0-9\-_/]*$/.test(value)) return {
177
+ value,
178
+ valid: false,
179
+ reason: "disallowed_char",
180
+ message: "Path can only contain a–z, 0–9, `-`, `_`, `/`"
181
+ };
182
+ return {
183
+ value,
184
+ valid: true
185
+ };
186
+ }
187
+ /**
188
+ * Generate a content ID in the standard format
189
+ * IDs are prefixed with "vx-" followed by 8 random characters
190
+ */
191
+ function generateContentId() {
192
+ return `vx-${nanoid(8)}`;
193
+ }
194
+ /**
195
+ * Get the current date/time in ISO format
196
+ * Used for timestamps in content files
197
+ */
198
+ function getCurrentISODate() {
199
+ return (/* @__PURE__ */ new Date()).toISOString();
200
+ }
201
+ /**
202
+ * Parse a date string safely
203
+ * Returns null if invalid
204
+ */
205
+ function parseDate(dateStr) {
206
+ if (!dateStr) return null;
207
+ try {
208
+ const date = new Date(dateStr);
209
+ if (isNaN(date.getTime())) return null;
210
+ return date;
211
+ } catch {
212
+ return null;
213
+ }
214
+ }
215
+ /**
216
+ * Creates a V8-optimized object by mapping site names to values.
217
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
218
+ *
219
+ * @param sitesConfig - Sites configuration containing site names
220
+ * @param factory - Function that creates the value for each site
221
+ * @returns Object with all sites initialized in alphabetical order
222
+ */
223
+ function mapSiteNames(sitesConfig, factory) {
224
+ const obj = {};
225
+ for (const siteName of Object.keys(sitesConfig.sites)) obj[siteName] = factory(siteName);
226
+ return obj;
227
+ }
228
+ /**
229
+ * Creates a V8-optimized object by mapping locale names to values.
230
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
231
+ *
232
+ * @param locales - Array of locale codes
233
+ * @param factory - Function that creates the value for each locale
234
+ * @returns Object with all locales initialized in array order
235
+ */
236
+ function mapLocales(locales, factory) {
237
+ const obj = {};
238
+ for (const locale of locales) obj[locale] = factory(locale);
239
+ return obj;
240
+ }
241
+ /**
242
+ * Resolves a publish date value to a valid string or undefined.
243
+ * Handles various input types including null, false, and empty strings.
244
+ *
245
+ * @param updateValue - The value being updated (string | null | false | undefined)
246
+ * @param currentValue - The current value to fall back to if updateValue is undefined
247
+ * @returns A valid date string or undefined
248
+ */
249
+ function resolvePublishDate(updateValue, currentValue) {
250
+ if (updateValue !== void 0) return updateValue && typeof updateValue === "string" ? updateValue : void 0;
251
+ return currentValue;
252
+ }
253
+ /**
254
+ * Serializes MDX content with frontmatter.
255
+ * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
256
+ * consistent MDX output that includes frontmatter for variable access.
257
+ *
258
+ * @param frontmatterData - The frontmatter data to serialize
259
+ * @param mdxContent - The MDX content (without frontmatter)
260
+ * @returns Complete MDX file content with frontmatter
261
+ */
262
+ function serializeMdxWithFrontmatter(frontmatterData, mdxContent) {
263
+ const ordered = {};
264
+ const normalize = (value) => {
265
+ if (value instanceof Date) return value.toISOString();
266
+ return value;
267
+ };
268
+ for (const key of FRONTMATTER_KEY_ORDER) if (key in frontmatterData) ordered[key] = normalize(frontmatterData[key]);
269
+ for (const key of Object.keys(frontmatterData).sort()) if (!(key in ordered)) ordered[key] = normalize(frontmatterData[key]);
270
+ const doc = new Document(ordered);
271
+ yaml.visit(doc, { Scalar(_key, node) {
272
+ if (isScalar(node) && typeof node.value === "string" && ISO_TIMESTAMP_RE.test(node.value)) node.type = "QUOTE_SINGLE";
273
+ } });
274
+ const body = mdxContent.replace(/^\n+/, "");
275
+ return `---\n${doc.toString()}---\n\n${body}`;
276
+ }
277
+ //#endregion
278
+ export { serializeMdxWithFrontmatter as _, getMetadataSize as a, isValidBlockName as c, mapLocales as d, mapSiteNames as f, resolvePublishDate as g, parseDate as h, getCurrentISODate as i, isValidPathname as l, normalizePathname as m, formatFileSize as n, isContentPublished as o, normalizeAndValidatePathname as p, generateContentId as r, isMetadataTooLarge as s, extractBlockName as t, localesOf as u };
279
+
280
+ //# sourceMappingURL=content-utils-fWNHTrPy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-utils-fWNHTrPy.mjs","names":[],"sources":["../src/content-utils.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport yaml, { Document, isScalar } from 'yaml';\nimport type { ContentMeta, LocaleVersion } from './types';\n\n// Pinned key order at the top of every .mdx frontmatter block. Anything not\n// listed here is appended after, sorted alphabetically for determinism. Without\n// this, the JS object insertion order in the update path leaks into the file\n// and every save reshuffles the YAML keys, producing diff noise unrelated to\n// the author's edit.\nconst FRONTMATTER_KEY_ORDER = [\n 'title',\n 'category',\n 'description',\n 'id',\n 'created',\n 'modified',\n 'publishAt',\n 'unpublishAt',\n] as const;\n\n// ISO 8601 timestamps were authored with single quotes in the canonical\n// fixtures (e.g. `created: '2026-05-07T18:07:39.049Z'`). yaml.stringify defaults\n// to a plain (unquoted) scalar for strings that aren't ambiguous, which strips\n// the quotes on every round-trip. We re-apply the single-quote style for any\n// scalar value that looks like an ISO 8601 timestamp.\nconst ISO_TIMESTAMP_RE = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$/;\n\nexport function* localesOf<T>(manifest: { locales: Record<string, T | undefined> }): Generator<T> {\n for (const value of Object.values(manifest.locales)) {\n if (value) yield value;\n }\n}\n\n/**\n * Pure utility functions for content operations\n * These functions don't depend on any class state and can be shared\n * between FileSystemContentAPI, InMemoryContentAPI, and other implementations\n */\n\n/**\n * Check if content is published based on publishAt/unpublishAt dates\n */\nexport function isContentPublished(\n localeVersion: Pick<LocaleVersion, 'publishAt' | 'unpublishAt'>,\n now = new Date(),\n): boolean {\n if (localeVersion.publishAt) {\n const publishDate = new Date(localeVersion.publishAt);\n // Check for invalid dates (e.g., from empty strings or invalid values)\n if (!isNaN(publishDate.getTime()) && publishDate > now) return false;\n }\n\n if (localeVersion.unpublishAt) {\n const unpublishDate = new Date(localeVersion.unpublishAt);\n // Check for invalid dates (e.g., from empty strings or invalid values)\n if (!isNaN(unpublishDate.getTime()) && unpublishDate < now) return false;\n }\n\n return true;\n}\n\n/**\n * Validate that metadata doesn't exceed 4KB when serialized\n * This ensures efficient indexing as per the specification\n */\nexport function isMetadataTooLarge(meta: ContentMeta): boolean {\n const size = new TextEncoder().encode(JSON.stringify(meta)).length;\n return size > 4096;\n}\n\n/**\n * Extract block name from various sources\n * Used when displaying blocks in the UI\n */\nexport function extractBlockName(source: string): string {\n // If it's a collection/name path, extract the name part\n if (source.includes('/') && !source.includes('.')) {\n const parts = source.split('/');\n return parts[parts.length - 1];\n }\n\n // If it's a filename, extract the base name\n if (source.includes('.')) {\n const match = source.match(/^(.+?)\\.([a-z]{2})?\\.(mdx|vxjson)$/);\n if (match) {\n return match[1];\n }\n // Fallback: remove any extension\n return source.replace(/\\.[^.]+$/, '');\n }\n\n // If it's an ID, create a simple name\n if (source.startsWith('vx-')) {\n return `block-${source.substring(3, 8)}`;\n }\n\n // Otherwise return as-is\n return source;\n}\n\n/**\n * Validate block name according to the specification\n * - Cannot contain dots (reserved for locale separator)\n * - Cannot contain slashes (would create subdirectories)\n * - Cannot contain spaces (for clean filenames)\n * - Must have at least one character\n */\nexport function isValidBlockName(name: string): boolean {\n if (!name || name.length === 0) return false;\n if (name.includes('.')) return false;\n if (name.includes('/')) return false;\n if (name.includes(' ')) return false;\n return true;\n}\n\n/**\n * Format file size for display with human-readable units\n * @example formatFileSize(1536) // \"1.5 KB\"\n */\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/**\n * Calculate metadata size in bytes\n */\nexport function getMetadataSize(meta: ContentMeta): number {\n return new TextEncoder().encode(JSON.stringify(meta)).length;\n}\n\n/**\n * Check if a pathname is valid\n * - Must start with /\n * - Cannot contain spaces (should be URL-encoded)\n * - Cannot contain special characters that would break URLs\n */\nexport function isValidPathname(pathname: string): boolean {\n if (!pathname || !pathname.startsWith('/')) return false;\n if (pathname.includes(' ')) return false;\n if (pathname.includes('?') || pathname.includes('#')) return false;\n return true;\n}\n\n/**\n * Normalize a pathname to ensure consistency\n * - Ensure it starts with /\n * - Remove trailing slashes (except for root)\n * - Collapse multiple slashes\n */\nexport function normalizePathname(pathname: string): string {\n if (!pathname) return '/';\n\n let normalized = pathname;\n\n // Ensure it starts with /\n if (!normalized.startsWith('/')) {\n normalized = `/${normalized}`;\n }\n\n // Collapse multiple slashes\n normalized = normalized.replace(/\\/+/g, '/');\n\n // Remove trailing slash unless it's the root\n if (normalized !== '/' && normalized.endsWith('/')) {\n normalized = normalized.slice(0, -1);\n }\n\n return normalized;\n}\n\n/**\n * Reasons a pathname can be rejected. Each maps to a specific user-facing\n * error message so the UI can highlight the exact problem.\n */\nexport type PathnameValidationReason =\n | 'empty'\n | 'whitespace'\n | 'forbidden_char'\n | 'control_char'\n | 'uppercase'\n | 'non_ascii'\n | 'traversal_segment'\n | 'disallowed_char';\n\nexport interface PathnameValidationResult {\n /** When valid: the normalized pathname. When invalid: the raw (trimmed) input. */\n value: string;\n valid: boolean;\n reason?: PathnameValidationReason;\n message?: string;\n}\n\n/**\n * Validate the shape of a CMS pathname and normalize it for storage.\n *\n * Silently fixes harmless slips (missing leading slash, doubled slashes,\n * trailing slash) and rejects malformed inputs with a specific reason so\n * the UI can show a helpful error message.\n *\n * Accepted chars: a–z, 0–9, `-`, `_`, `/`. Mixed case, accents, spaces,\n * `?`, `#`, `\\`, and traversal segments (`.`, `..`) are rejected.\n */\nexport function normalizeAndValidatePathname(input: string | undefined | null): PathnameValidationResult {\n const raw = (input ?? '').trim();\n\n if (raw === '') {\n return { value: '', valid: false, reason: 'empty', message: 'Path is required' };\n }\n\n // Pre-normalize character checks — run on the raw input so the error\n // matches what the user actually typed.\n if (/\\s/.test(raw)) {\n return { value: raw, valid: false, reason: 'whitespace', message: 'Path cannot contain spaces' };\n }\n if (/[?#\\\\]/.test(raw)) {\n return { value: raw, valid: false, reason: 'forbidden_char', message: 'Path cannot contain `?`, `#`, or `\\\\`' };\n }\n // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional control-char detection\n if (/[\\x00-\\x1F\\x7F]/.test(raw)) {\n return { value: raw, valid: false, reason: 'control_char', message: 'Path cannot contain control characters' };\n }\n if (/[A-Z]/.test(raw)) {\n return { value: raw, valid: false, reason: 'uppercase', message: 'Path must be lowercase' };\n }\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ASCII-only enforcement\n if (/[^\\x00-\\x7F]/.test(raw)) {\n return {\n value: raw,\n valid: false,\n reason: 'non_ascii',\n message: 'Path can only contain a–z, 0–9, `-`, `_`, `/`',\n };\n }\n\n // Normalize: add leading slash, collapse //, strip trailing slash.\n let value = raw;\n if (!value.startsWith('/')) value = '/' + value;\n value = value.replace(/\\/+/g, '/');\n if (value !== '/' && value.endsWith('/')) value = value.slice(0, -1);\n\n // Segment-level check: `.` and `..` are never valid path segments.\n // Run before the generic disallowed-char check so the user gets the\n // more specific \"traversal\" message.\n if (value !== '/') {\n for (const seg of value.slice(1).split('/')) {\n if (seg === '.' || seg === '..') {\n return {\n value,\n valid: false,\n reason: 'traversal_segment',\n message: 'Path cannot contain `.` or `..` segments',\n };\n }\n }\n }\n\n // Final allowed-chars check — catches stray dots and anything else.\n if (!/^[a-z0-9\\-_/]*$/.test(value)) {\n return {\n value,\n valid: false,\n reason: 'disallowed_char',\n message: 'Path can only contain a–z, 0–9, `-`, `_`, `/`',\n };\n }\n\n return { value, valid: true };\n}\n\n/**\n * Generate a content ID in the standard format\n * IDs are prefixed with \"vx-\" followed by 8 random characters\n */\nexport function generateContentId(): string {\n return `vx-${nanoid(8)}`;\n}\n\n/**\n * Get the current date/time in ISO format\n * Used for timestamps in content files\n */\nexport function getCurrentISODate(): string {\n return new Date().toISOString();\n}\n\n/**\n * Parse a date string safely\n * Returns null if invalid\n */\nexport function parseDate(dateStr: string | undefined): Date | null {\n if (!dateStr) return null;\n\n try {\n const date = new Date(dateStr);\n if (isNaN(date.getTime())) return null;\n return date;\n } catch {\n return null;\n }\n}\n\n/**\n * Creates a V8-optimized object by mapping site names to values.\n * Ensures all objects have the same hidden class by adding properties in consistent order.\n *\n * @param sitesConfig - Sites configuration containing site names\n * @param factory - Function that creates the value for each site\n * @returns Object with all sites initialized in alphabetical order\n */\nexport function mapSiteNames<T>(\n sitesConfig: { sites: Record<string, any> },\n factory: (siteName: string) => T,\n): Record<string, T> {\n const obj: Record<string, T> = {};\n // Object.keys returns keys in insertion order, which is stable for a given object\n for (const siteName of Object.keys(sitesConfig.sites)) {\n obj[siteName] = factory(siteName);\n }\n return obj;\n}\n\n/**\n * Creates a V8-optimized object by mapping locale names to values.\n * Ensures all objects have the same hidden class by adding properties in consistent order.\n *\n * @param locales - Array of locale codes\n * @param factory - Function that creates the value for each locale\n * @returns Object with all locales initialized in array order\n */\nexport function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T> {\n const obj: Record<string, T> = {};\n for (const locale of locales) {\n obj[locale] = factory(locale);\n }\n return obj;\n}\n\n/**\n * Resolves a publish date value to a valid string or undefined.\n * Handles various input types including null, false, and empty strings.\n *\n * @param updateValue - The value being updated (string | null | false | undefined)\n * @param currentValue - The current value to fall back to if updateValue is undefined\n * @returns A valid date string or undefined\n */\nexport function resolvePublishDate(\n updateValue: string | null | false | undefined,\n currentValue: string | undefined,\n): string | undefined {\n // If updateValue is explicitly provided (including null/false), use it\n if (updateValue !== undefined) {\n // Only return string values, treat null/false/empty as undefined\n return updateValue && typeof updateValue === 'string' ? updateValue : undefined;\n }\n // Otherwise keep the current value\n return currentValue;\n}\n\n/**\n * Serializes MDX content with frontmatter.\n * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure\n * consistent MDX output that includes frontmatter for variable access.\n *\n * @param frontmatterData - The frontmatter data to serialize\n * @param mdxContent - The MDX content (without frontmatter)\n * @returns Complete MDX file content with frontmatter\n */\nexport function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string {\n const ordered: Record<string, unknown> = {};\n const normalize = (value: unknown): unknown => {\n // gray-matter's default js-yaml schema parses ISO timestamps into JS Date\n // objects. Convert back to strings so the QUOTE_SINGLE visitor below can\n // restore the canonical single-quoted form on write.\n if (value instanceof Date) return value.toISOString();\n return value;\n };\n for (const key of FRONTMATTER_KEY_ORDER) {\n if (key in frontmatterData) ordered[key] = normalize(frontmatterData[key]);\n }\n for (const key of Object.keys(frontmatterData).sort()) {\n if (!(key in ordered)) ordered[key] = normalize(frontmatterData[key]);\n }\n\n const doc = new Document(ordered);\n yaml.visit(doc, {\n Scalar(_key, node) {\n if (isScalar(node) && typeof node.value === 'string' && ISO_TIMESTAMP_RE.test(node.value)) {\n node.type = 'QUOTE_SINGLE';\n }\n },\n });\n\n // Strip any leading newlines from the body. The serializer always emits\n // exactly one blank line between the closing `---` and the body, so a\n // caller-side leading `\\n` (gray-matter leaves one in the content slice when\n // it strips frontmatter) would compound into multiple blank lines and drift\n // the diff on every save.\n const body = mdxContent.replace(/^\\n+/, '');\n\n return `---\\n${doc.toString()}---\\n\\n${body}`;\n}\n"],"mappings":";;;AASA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF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