payload-wordpress-migrator 0.0.22

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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +586 -0
  3. package/dist/components/BeforeDashboardClient.d.ts +14 -0
  4. package/dist/components/BeforeDashboardClient.js +225 -0
  5. package/dist/components/BeforeDashboardClient.js.map +1 -0
  6. package/dist/components/BeforeDashboardClient.module.css +175 -0
  7. package/dist/components/BeforeDashboardServer.d.ts +1 -0
  8. package/dist/components/BeforeDashboardServer.js +29 -0
  9. package/dist/components/BeforeDashboardServer.js.map +1 -0
  10. package/dist/components/ContentTypeSelect.d.ts +4 -0
  11. package/dist/components/ContentTypeSelect.js +147 -0
  12. package/dist/components/ContentTypeSelect.js.map +1 -0
  13. package/dist/components/FieldMappingConfiguration.d.ts +5 -0
  14. package/dist/components/FieldMappingConfiguration.js +361 -0
  15. package/dist/components/FieldMappingConfiguration.js.map +1 -0
  16. package/dist/components/FieldMappingConfiguration.module.css +75 -0
  17. package/dist/components/MigrationDashboardClient.d.ts +6 -0
  18. package/dist/components/MigrationDashboardClient.js +49 -0
  19. package/dist/components/MigrationDashboardClient.js.map +1 -0
  20. package/dist/components/MigrationDashboardClient.module.css +749 -0
  21. package/dist/components/SimpleFieldMapping.d.ts +5 -0
  22. package/dist/components/SimpleFieldMapping.js +437 -0
  23. package/dist/components/SimpleFieldMapping.js.map +1 -0
  24. package/dist/components/dashboard/JobActionButtons.d.ts +8 -0
  25. package/dist/components/dashboard/JobActionButtons.js +91 -0
  26. package/dist/components/dashboard/JobActionButtons.js.map +1 -0
  27. package/dist/components/dashboard/JobsTable.d.ts +6 -0
  28. package/dist/components/dashboard/JobsTable.js +86 -0
  29. package/dist/components/dashboard/JobsTable.js.map +1 -0
  30. package/dist/components/dashboard/LogViewer.d.ts +3 -0
  31. package/dist/components/dashboard/LogViewer.js +35 -0
  32. package/dist/components/dashboard/LogViewer.js.map +1 -0
  33. package/dist/components/dashboard/SiteConfigPanel.d.ts +12 -0
  34. package/dist/components/dashboard/SiteConfigPanel.js +205 -0
  35. package/dist/components/dashboard/SiteConfigPanel.js.map +1 -0
  36. package/dist/components/dashboard/StatsOverview.d.ts +5 -0
  37. package/dist/components/dashboard/StatsOverview.js +72 -0
  38. package/dist/components/dashboard/StatsOverview.js.map +1 -0
  39. package/dist/components/dashboard/index.d.ts +7 -0
  40. package/dist/components/dashboard/index.js +7 -0
  41. package/dist/components/dashboard/index.js.map +1 -0
  42. package/dist/components/dashboard/types.d.ts +46 -0
  43. package/dist/components/dashboard/types.js +2 -0
  44. package/dist/components/dashboard/types.js.map +1 -0
  45. package/dist/components/dashboard/useMigrationDashboard.d.ts +15 -0
  46. package/dist/components/dashboard/useMigrationDashboard.js +584 -0
  47. package/dist/components/dashboard/useMigrationDashboard.js.map +1 -0
  48. package/dist/exports/client.d.ts +4 -0
  49. package/dist/exports/client.js +5 -0
  50. package/dist/exports/client.js.map +1 -0
  51. package/dist/exports/rsc.d.ts +1 -0
  52. package/dist/exports/rsc.js +2 -0
  53. package/dist/exports/rsc.js.map +1 -0
  54. package/dist/index.d.ts +101 -0
  55. package/dist/index.js +443 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/utils/content/blocks.d.ts +6 -0
  58. package/dist/utils/content/blocks.js +93 -0
  59. package/dist/utils/content/blocks.js.map +1 -0
  60. package/dist/utils/content/fieldMapping.d.ts +9 -0
  61. package/dist/utils/content/fieldMapping.js +218 -0
  62. package/dist/utils/content/fieldMapping.js.map +1 -0
  63. package/dist/utils/content/index.d.ts +4 -0
  64. package/dist/utils/content/index.js +4 -0
  65. package/dist/utils/content/index.js.map +1 -0
  66. package/dist/utils/content/transformer.d.ts +5 -0
  67. package/dist/utils/content/transformer.js +323 -0
  68. package/dist/utils/content/transformer.js.map +1 -0
  69. package/dist/utils/endpoints/handlers.d.ts +9 -0
  70. package/dist/utils/endpoints/handlers.js +201 -0
  71. package/dist/utils/endpoints/handlers.js.map +1 -0
  72. package/dist/utils/endpoints/index.d.ts +2 -0
  73. package/dist/utils/endpoints/index.js +2 -0
  74. package/dist/utils/endpoints/index.js.map +1 -0
  75. package/dist/utils/fields/analyzer.d.ts +7 -0
  76. package/dist/utils/fields/analyzer.js +502 -0
  77. package/dist/utils/fields/analyzer.js.map +1 -0
  78. package/dist/utils/fields/index.d.ts +2 -0
  79. package/dist/utils/fields/index.js +2 -0
  80. package/dist/utils/fields/index.js.map +1 -0
  81. package/dist/utils/helpers/auth.d.ts +9 -0
  82. package/dist/utils/helpers/auth.js +50 -0
  83. package/dist/utils/helpers/auth.js.map +1 -0
  84. package/dist/utils/helpers/cache.d.ts +11 -0
  85. package/dist/utils/helpers/cache.js +47 -0
  86. package/dist/utils/helpers/cache.js.map +1 -0
  87. package/dist/utils/helpers/concurrency.d.ts +2 -0
  88. package/dist/utils/helpers/concurrency.js +26 -0
  89. package/dist/utils/helpers/concurrency.js.map +1 -0
  90. package/dist/utils/helpers/index.d.ts +8 -0
  91. package/dist/utils/helpers/index.js +8 -0
  92. package/dist/utils/helpers/index.js.map +1 -0
  93. package/dist/utils/helpers/objectHelpers.d.ts +3 -0
  94. package/dist/utils/helpers/objectHelpers.js +22 -0
  95. package/dist/utils/helpers/objectHelpers.js.map +1 -0
  96. package/dist/utils/helpers/rateLimiter.d.ts +10 -0
  97. package/dist/utils/helpers/rateLimiter.js +29 -0
  98. package/dist/utils/helpers/rateLimiter.js.map +1 -0
  99. package/dist/utils/helpers/responses.d.ts +3 -0
  100. package/dist/utils/helpers/responses.js +23 -0
  101. package/dist/utils/helpers/responses.js.map +1 -0
  102. package/dist/utils/helpers/wpHelpers.d.ts +6 -0
  103. package/dist/utils/helpers/wpHelpers.js +29 -0
  104. package/dist/utils/helpers/wpHelpers.js.map +1 -0
  105. package/dist/utils/lexical/constants.d.ts +37 -0
  106. package/dist/utils/lexical/constants.js +58 -0
  107. package/dist/utils/lexical/constants.js.map +1 -0
  108. package/dist/utils/lexical/htmlParser.d.ts +20 -0
  109. package/dist/utils/lexical/htmlParser.js +253 -0
  110. package/dist/utils/lexical/htmlParser.js.map +1 -0
  111. package/dist/utils/lexical/htmlToLexicalConverter.d.ts +55 -0
  112. package/dist/utils/lexical/htmlToLexicalConverter.js +999 -0
  113. package/dist/utils/lexical/htmlToLexicalConverter.js.map +1 -0
  114. package/dist/utils/lexical/index.d.ts +5 -0
  115. package/dist/utils/lexical/index.js +4 -0
  116. package/dist/utils/lexical/index.js.map +1 -0
  117. package/dist/utils/lexical/nodeFactories.d.ts +21 -0
  118. package/dist/utils/lexical/nodeFactories.js +91 -0
  119. package/dist/utils/lexical/nodeFactories.js.map +1 -0
  120. package/dist/utils/lexical/preprocessor.d.ts +4 -0
  121. package/dist/utils/lexical/preprocessor.js +302 -0
  122. package/dist/utils/lexical/preprocessor.js.map +1 -0
  123. package/dist/utils/media/download.d.ts +7 -0
  124. package/dist/utils/media/download.js +85 -0
  125. package/dist/utils/media/download.js.map +1 -0
  126. package/dist/utils/media/extraction.d.ts +12 -0
  127. package/dist/utils/media/extraction.js +58 -0
  128. package/dist/utils/media/extraction.js.map +1 -0
  129. package/dist/utils/media/import.d.ts +7 -0
  130. package/dist/utils/media/import.js +146 -0
  131. package/dist/utils/media/import.js.map +1 -0
  132. package/dist/utils/media/index.d.ts +6 -0
  133. package/dist/utils/media/index.js +6 -0
  134. package/dist/utils/media/index.js.map +1 -0
  135. package/dist/utils/media/upload.d.ts +4 -0
  136. package/dist/utils/media/upload.js +46 -0
  137. package/dist/utils/media/upload.js.map +1 -0
  138. package/dist/utils/media/validation.d.ts +8 -0
  139. package/dist/utils/media/validation.js +60 -0
  140. package/dist/utils/media/validation.js.map +1 -0
  141. package/dist/utils/migration/index.d.ts +3 -0
  142. package/dist/utils/migration/index.js +3 -0
  143. package/dist/utils/migration/index.js.map +1 -0
  144. package/dist/utils/migration/jobCrud.d.ts +4 -0
  145. package/dist/utils/migration/jobCrud.js +380 -0
  146. package/dist/utils/migration/jobCrud.js.map +1 -0
  147. package/dist/utils/migration/orchestrator.d.ts +5 -0
  148. package/dist/utils/migration/orchestrator.js +756 -0
  149. package/dist/utils/migration/orchestrator.js.map +1 -0
  150. package/dist/utils/types.d.ts +201 -0
  151. package/dist/utils/types.js +14 -0
  152. package/dist/utils/types.js.map +1 -0
  153. package/dist/utils/wordpress/client.d.ts +61 -0
  154. package/dist/utils/wordpress/client.js +365 -0
  155. package/dist/utils/wordpress/client.js.map +1 -0
  156. package/dist/utils/wordpress/index.d.ts +2 -0
  157. package/dist/utils/wordpress/index.js +2 -0
  158. package/dist/utils/wordpress/index.js.map +1 -0
  159. package/dist/utils/wordpressApi.d.ts +11 -0
  160. package/dist/utils/wordpressApi.js +25 -0
  161. package/dist/utils/wordpressApi.js.map +1 -0
  162. package/package.json +155 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sources":["../../../src/utils/helpers/auth.ts"],"sourcesContent":["/** Authentication and request parsing utilities for endpoint handlers. */\n\nimport type { PayloadRequest } from 'payload'\n\nimport type { WordPressCredentials } from '../types.js'\n\nimport { createErrorResponse } from './responses.js'\n\nexport const requireAuth = (req: PayloadRequest): Response | null => {\n if (!req.user) {\n return createErrorResponse('Authentication required', 401)\n }\n return null\n}\n\nexport const requireMigrationAccess = async (\n req: PayloadRequest,\n accessFn?: (args: { req: PayloadRequest }) => boolean | Promise<boolean>,\n): Promise<Response | null> => {\n if (!req.user) {\n return createErrorResponse('Authentication required', 401)\n }\n if (accessFn) {\n const allowed = await accessFn({ req })\n if (!allowed) {\n return createErrorResponse('Insufficient permissions for migration operations', 403)\n }\n }\n return null\n}\n\nexport const parseRequestBody = async (req: PayloadRequest): Promise<any> => {\n let body: any = {}\n\n if (req.json && typeof req.json === 'function') {\n try {\n body = await req.json()\n } catch (jsonError) {\n console.error('Failed to parse JSON from request:', jsonError)\n throw new Error('Invalid JSON in request body')\n }\n } else if (req.body) {\n body = req.body\n }\n\n return body\n}\n\nexport const validateWordPressCredentials = (body: any): WordPressCredentials => {\n const { wpPassword, wpSiteUrl, wpUsername } = body\n\n if (!wpSiteUrl || !wpUsername || !wpPassword) {\n throw new Error('Missing required fields: wpSiteUrl, wpUsername, wpPassword')\n }\n\n return { wpPassword, wpSiteUrl, wpUsername }\n}\n"],"names":["requireAuth","req","user","createErrorResponse","requireMigrationAccess","accessFn","allowed","parseRequestBody","body","json","jsonError","console","error","Error","validateWordPressCredentials","wpPassword","wpSiteUrl","wpUsername"],"mappings":";;AAQO,MAAMA,cAAc,CAACC,GAAAA,GAAAA;IAC1B,IAAI,CAACA,GAAAA,CAAIC,IAAI,EAAE;AACb,QAAA,OAAOC,oBAAoB,yBAAA,EAA2B,GAAA,CAAA;AACxD,IAAA;IACA,OAAO,IAAA;AACT;AAEO,MAAMC,sBAAAA,GAAyB,OACpCH,GAAAA,EACAI,QAAAA,GAAAA;IAEA,IAAI,CAACJ,GAAAA,CAAIC,IAAI,EAAE;AACb,QAAA,OAAOC,oBAAoB,yBAAA,EAA2B,GAAA,CAAA;AACxD,IAAA;AACA,IAAA,IAAIE,QAAAA,EAAU;QACZ,MAAMC,OAAAA,GAAU,MAAMD,QAAAA,CAAS;AAAEJ,YAAAA;AAAI,SAAA,CAAA;AACrC,QAAA,IAAI,CAACK,OAAAA,EAAS;AACZ,YAAA,OAAOH,oBAAoB,mDAAA,EAAqD,GAAA,CAAA;AAClF,QAAA;AACF,IAAA;IACA,OAAO,IAAA;AACT;AAEO,MAAMI,mBAAmB,OAAON,GAAAA,GAAAA;AACrC,IAAA,IAAIO,OAAY,EAAC;AAEjB,IAAA,IAAIP,IAAIQ,IAAI,IAAI,OAAOR,GAAAA,CAAIQ,IAAI,KAAK,UAAA,EAAY;QAC9C,IAAI;YACFD,IAAAA,GAAO,MAAMP,IAAIQ,IAAI,EAAA;AACvB,QAAA,CAAA,CAAE,OAAOC,SAAAA,EAAW;YAClBC,OAAAA,CAAQC,KAAK,CAAC,oCAAA,EAAsCF,SAAAA,CAAAA;AACpD,YAAA,MAAM,IAAIG,KAAAA,CAAM,8BAAA,CAAA;AAClB,QAAA;IACF,CAAA,MAAO,IAAIZ,GAAAA,CAAIO,IAAI,EAAE;AACnBA,QAAAA,IAAAA,GAAOP,IAAIO,IAAI;AACjB,IAAA;IAEA,OAAOA,IAAAA;AACT;AAEO,MAAMM,+BAA+B,CAACN,IAAAA,GAAAA;AAC3C,IAAA,MAAM,EAAEO,UAAU,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGT,IAAAA;AAE9C,IAAA,IAAI,CAACQ,SAAAA,IAAa,CAACC,UAAAA,IAAc,CAACF,UAAAA,EAAY;AAC5C,QAAA,MAAM,IAAIF,KAAAA,CAAM,4DAAA,CAAA;AAClB,IAAA;IAEA,OAAO;AAAEE,QAAAA,UAAAA;AAAYC,QAAAA,SAAAA;AAAWC,QAAAA;AAAW,KAAA;AAC7C;;;;"}
@@ -0,0 +1,11 @@
1
+ /** In-memory cache for migration data with time-based invalidation and LRU eviction. */
2
+ interface CacheEntry {
3
+ data: unknown;
4
+ timestamp: number;
5
+ }
6
+ export declare const invalidateMigrationCache: () => void;
7
+ export declare const getContentCache: (key?: string) => CacheEntry | null;
8
+ export declare const setContentCache: (data: unknown, key?: string) => void;
9
+ export declare const isCacheValid: (key?: string) => boolean;
10
+ export declare const cleanExpiredCache: () => void;
11
+ export {};
@@ -0,0 +1,47 @@
1
+ /** In-memory cache for migration data with time-based invalidation and LRU eviction. */ const MAX_CACHE_ENTRIES = 100;
2
+ const CACHE_DURATION = 30 * 1000 // 30 seconds
3
+ ;
4
+ const DEFAULT_KEY = 'summary';
5
+ const cacheMap = new Map();
6
+ const invalidateMigrationCache = ()=>{
7
+ cacheMap.clear();
8
+ };
9
+ const getContentCache = (key = DEFAULT_KEY)=>{
10
+ return cacheMap.get(key) ?? null;
11
+ };
12
+ const setContentCache = (data, key = DEFAULT_KEY)=>{
13
+ // Evict oldest entry if at capacity (and we're inserting a new key)
14
+ if (!cacheMap.has(key) && cacheMap.size >= MAX_CACHE_ENTRIES) {
15
+ let oldestKey;
16
+ let oldestTime = Infinity;
17
+ for (const [k, v] of cacheMap){
18
+ if (v.timestamp < oldestTime) {
19
+ oldestTime = v.timestamp;
20
+ oldestKey = k;
21
+ }
22
+ }
23
+ if (oldestKey) {
24
+ cacheMap.delete(oldestKey);
25
+ }
26
+ }
27
+ cacheMap.set(key, {
28
+ data,
29
+ timestamp: Date.now()
30
+ });
31
+ };
32
+ const isCacheValid = (key = DEFAULT_KEY)=>{
33
+ const entry = cacheMap.get(key);
34
+ if (!entry) return false;
35
+ return Date.now() - entry.timestamp < CACHE_DURATION;
36
+ };
37
+ const cleanExpiredCache = ()=>{
38
+ const now = Date.now();
39
+ for (const [key, entry] of cacheMap){
40
+ if (now - entry.timestamp >= CACHE_DURATION) {
41
+ cacheMap.delete(key);
42
+ }
43
+ }
44
+ };
45
+
46
+ export { cleanExpiredCache, getContentCache, invalidateMigrationCache, isCacheValid, setContentCache };
47
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sources":["../../../src/utils/helpers/cache.ts"],"sourcesContent":["/** In-memory cache for migration data with time-based invalidation and LRU eviction. */\n\nconst MAX_CACHE_ENTRIES = 100\nconst CACHE_DURATION = 30 * 1000 // 30 seconds\nconst DEFAULT_KEY = 'summary'\n\ninterface CacheEntry {\n data: unknown\n timestamp: number\n}\n\nconst cacheMap = new Map<string, CacheEntry>()\n\nexport const invalidateMigrationCache = () => {\n cacheMap.clear()\n}\n\nexport const getContentCache = (key: string = DEFAULT_KEY): CacheEntry | null => {\n return cacheMap.get(key) ?? null\n}\n\nexport const setContentCache = (data: unknown, key: string = DEFAULT_KEY) => {\n // Evict oldest entry if at capacity (and we're inserting a new key)\n if (!cacheMap.has(key) && cacheMap.size >= MAX_CACHE_ENTRIES) {\n let oldestKey: string | undefined\n let oldestTime = Infinity\n for (const [k, v] of cacheMap) {\n if (v.timestamp < oldestTime) {\n oldestTime = v.timestamp\n oldestKey = k\n }\n }\n if (oldestKey) {\n cacheMap.delete(oldestKey)\n }\n }\n cacheMap.set(key, { data, timestamp: Date.now() })\n}\n\nexport const isCacheValid = (key: string = DEFAULT_KEY): boolean => {\n const entry = cacheMap.get(key)\n if (!entry) return false\n return Date.now() - entry.timestamp < CACHE_DURATION\n}\n\nexport const cleanExpiredCache = () => {\n const now = Date.now()\n for (const [key, entry] of cacheMap) {\n if (now - entry.timestamp >= CACHE_DURATION) {\n cacheMap.delete(key)\n }\n }\n}\n"],"names":["MAX_CACHE_ENTRIES","CACHE_DURATION","DEFAULT_KEY","cacheMap","Map","invalidateMigrationCache","clear","getContentCache","key","get","setContentCache","data","has","size","oldestKey","oldestTime","Infinity","k","v","timestamp","delete","set","Date","now","isCacheValid","entry","cleanExpiredCache"],"mappings":"AAAA,yFAEA,MAAMA,iBAAAA,GAAoB,GAAA;AAC1B,MAAMC,cAAAA,GAAiB,EAAA,GAAK,IAAA;;AAC5B,MAAMC,WAAAA,GAAc,SAAA;AAOpB,MAAMC,WAAW,IAAIC,GAAAA,EAAAA;MAERC,wBAAAA,GAA2B,IAAA;AACtCF,IAAAA,QAAAA,CAASG,KAAK,EAAA;AAChB;AAEO,MAAMC,eAAAA,GAAkB,CAACC,GAAAA,GAAcN,WAAW,GAAA;IACvD,OAAOC,QAAAA,CAASM,GAAG,CAACD,GAAAA,CAAAA,IAAQ,IAAA;AAC9B;AAEO,MAAME,eAAAA,GAAkB,CAACC,IAAAA,EAAeH,MAAcN,WAAW,GAAA;;IAEtE,IAAI,CAACC,SAASS,GAAG,CAACJ,QAAQL,QAAAA,CAASU,IAAI,IAAIb,iBAAAA,EAAmB;QAC5D,IAAIc,SAAAA;AACJ,QAAA,IAAIC,UAAAA,GAAaC,QAAAA;AACjB,QAAA,KAAK,MAAM,CAACC,CAAAA,EAAGC,CAAAA,CAAE,IAAIf,QAAAA,CAAU;YAC7B,IAAIe,CAAAA,CAAEC,SAAS,GAAGJ,UAAAA,EAAY;AAC5BA,gBAAAA,UAAAA,GAAaG,EAAEC,SAAS;gBACxBL,SAAAA,GAAYG,CAAAA;AACd,YAAA;AACF,QAAA;AACA,QAAA,IAAIH,SAAAA,EAAW;AACbX,YAAAA,QAAAA,CAASiB,MAAM,CAACN,SAAAA,CAAAA;AAClB,QAAA;AACF,IAAA;IACAX,QAAAA,CAASkB,GAAG,CAACb,GAAAA,EAAK;AAAEG,QAAAA,IAAAA;AAAMQ,QAAAA,SAAAA,EAAWG,KAAKC,GAAG;AAAG,KAAA,CAAA;AAClD;AAEO,MAAMC,YAAAA,GAAe,CAAChB,GAAAA,GAAcN,WAAW,GAAA;IACpD,MAAMuB,KAAAA,GAAQtB,QAAAA,CAASM,GAAG,CAACD,GAAAA,CAAAA;IAC3B,IAAI,CAACiB,OAAO,OAAO,KAAA;AACnB,IAAA,OAAOH,IAAAA,CAAKC,GAAG,EAAA,GAAKE,KAAAA,CAAMN,SAAS,GAAGlB,cAAAA;AACxC;MAEayB,iBAAAA,GAAoB,IAAA;IAC/B,MAAMH,GAAAA,GAAMD,KAAKC,GAAG,EAAA;AACpB,IAAA,KAAK,MAAM,CAACf,GAAAA,EAAKiB,KAAAA,CAAM,IAAItB,QAAAA,CAAU;AACnC,QAAA,IAAIoB,GAAAA,GAAME,KAAAA,CAAMN,SAAS,IAAIlB,cAAAA,EAAgB;AAC3CE,YAAAA,QAAAA,CAASiB,MAAM,CAACZ,GAAAA,CAAAA;AAClB,QAAA;AACF,IAAA;AACF;;;;"}
@@ -0,0 +1,2 @@
1
+ /** Queue-based concurrency limiter for parallel task execution. */
2
+ export declare const createConcurrencyLimiter: (concurrency: number) => <T>(fn: () => Promise<T>) => Promise<T>;
@@ -0,0 +1,26 @@
1
+ /** Queue-based concurrency limiter for parallel task execution. */ const createConcurrencyLimiter = (concurrency)=>{
2
+ if (concurrency < 1) {
3
+ throw new Error('Concurrency must be at least 1');
4
+ }
5
+ let active = 0;
6
+ const queue = [];
7
+ const next = ()=>{
8
+ if (queue.length > 0 && active < concurrency) {
9
+ active++;
10
+ queue.shift()();
11
+ }
12
+ };
13
+ return (fn)=>new Promise((resolve, reject)=>{
14
+ const run = ()=>{
15
+ fn().then(resolve, reject).finally(()=>{
16
+ active--;
17
+ next();
18
+ });
19
+ };
20
+ queue.push(run);
21
+ next();
22
+ });
23
+ };
24
+
25
+ export { createConcurrencyLimiter };
26
+ //# sourceMappingURL=concurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrency.js","sources":["../../../src/utils/helpers/concurrency.ts"],"sourcesContent":["/** Queue-based concurrency limiter for parallel task execution. */\n\nexport const createConcurrencyLimiter = (concurrency: number) => {\n if (concurrency < 1) {\n throw new Error('Concurrency must be at least 1')\n }\n\n let active = 0\n const queue: Array<() => void> = []\n\n const next = () => {\n if (queue.length > 0 && active < concurrency) {\n active++\n queue.shift()!()\n }\n }\n\n return <T>(fn: () => Promise<T>): Promise<T> =>\n new Promise<T>((resolve, reject) => {\n const run = () => {\n fn()\n .then(resolve, reject)\n .finally(() => {\n active--\n next()\n })\n }\n queue.push(run)\n next()\n })\n}\n"],"names":["createConcurrencyLimiter","concurrency","Error","active","queue","next","length","shift","fn","Promise","resolve","reject","run","then","finally","push"],"mappings":"AAAA,oEAEO,MAAMA,wBAAAA,GAA2B,CAACC,WAAAA,GAAAA;AACvC,IAAA,IAAIA,cAAc,CAAA,EAAG;AACnB,QAAA,MAAM,IAAIC,KAAAA,CAAM,gCAAA,CAAA;AAClB,IAAA;AAEA,IAAA,IAAIC,MAAAA,GAAS,CAAA;AACb,IAAA,MAAMC,QAA2B,EAAE;AAEnC,IAAA,MAAMC,IAAAA,GAAO,IAAA;AACX,QAAA,IAAID,KAAAA,CAAME,MAAM,GAAG,CAAA,IAAKH,SAASF,WAAAA,EAAa;AAC5CE,YAAAA,MAAAA,EAAAA;AACAC,YAAAA,KAAAA,CAAMG,KAAK,EAAA,EAAA;AACb,QAAA;AACF,IAAA,CAAA;AAEA,IAAA,OAAO,CAAIC,EAAAA,GACT,IAAIC,OAAAA,CAAW,CAACC,OAAAA,EAASC,MAAAA,GAAAA;AACvB,YAAA,MAAMC,GAAAA,GAAM,IAAA;AACVJ,gBAAAA,EAAAA,EAAAA,CACGK,IAAI,CAACH,OAAAA,EAASC,MAAAA,CAAAA,CACdG,OAAO,CAAC,IAAA;AACPX,oBAAAA,MAAAA,EAAAA;AACAE,oBAAAA,IAAAA,EAAAA;AACF,gBAAA,CAAA,CAAA;AACJ,YAAA,CAAA;AACAD,YAAAA,KAAAA,CAAMW,IAAI,CAACH,GAAAA,CAAAA;AACXP,YAAAA,IAAAA,EAAAA;AACF,QAAA,CAAA,CAAA;AACJ;;;;"}
@@ -0,0 +1,8 @@
1
+ /** Barrel re-export of all general-purpose helper modules. */
2
+ export { createConcurrencyLimiter } from './concurrency.js';
3
+ export { checkRateLimit, clearAllRateLimits, resetRateLimit } from './rateLimiter.js';
4
+ export { parseRequestBody, requireAuth, requireMigrationAccess, validateWordPressCredentials } from './auth.js';
5
+ export { cleanExpiredCache, getContentCache, invalidateMigrationCache, isCacheValid, setContentCache } from './cache.js';
6
+ export { getNestedValue, setNestedValue } from './objectHelpers.js';
7
+ export { createErrorResponse, createSuccessResponse } from './responses.js';
8
+ export { constructWordPressApiUrl, createWordPressHeaders, getContentTypeEndpoint, getFieldAnalysisEndpoint, } from './wpHelpers.js';
@@ -0,0 +1,8 @@
1
+ export { createConcurrencyLimiter } from './concurrency.js';
2
+ export { checkRateLimit, clearAllRateLimits, resetRateLimit } from './rateLimiter.js';
3
+ export { parseRequestBody, requireAuth, requireMigrationAccess, validateWordPressCredentials } from './auth.js';
4
+ export { cleanExpiredCache, getContentCache, invalidateMigrationCache, isCacheValid, setContentCache } from './cache.js';
5
+ export { getNestedValue, setNestedValue } from './objectHelpers.js';
6
+ export { createErrorResponse, createSuccessResponse } from './responses.js';
7
+ export { constructWordPressApiUrl, createWordPressHeaders, getContentTypeEndpoint, getFieldAnalysisEndpoint } from './wpHelpers.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,3 @@
1
+ /** Dot-notation path accessors for nested object manipulation. */
2
+ export declare const getNestedValue: (obj: any, path: string) => any;
3
+ export declare const setNestedValue: (obj: any, path: string, value: any) => void;
@@ -0,0 +1,22 @@
1
+ /** Dot-notation path accessors for nested object manipulation. */ const getNestedValue = (obj, path)=>{
2
+ return path.split('.').reduce((current, key)=>{
3
+ return current && current[key] !== undefined ? current[key] : undefined;
4
+ }, obj);
5
+ };
6
+ const setNestedValue = (obj, path, value)=>{
7
+ const keys = path.split('.');
8
+ const lastKey = keys.pop();
9
+ if (!lastKey) {
10
+ return;
11
+ }
12
+ const target = keys.reduce((current, key)=>{
13
+ if (!current[key] || typeof current[key] !== 'object') {
14
+ current[key] = {};
15
+ }
16
+ return current[key];
17
+ }, obj);
18
+ target[lastKey] = value;
19
+ };
20
+
21
+ export { getNestedValue, setNestedValue };
22
+ //# sourceMappingURL=objectHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectHelpers.js","sources":["../../../src/utils/helpers/objectHelpers.ts"],"sourcesContent":["/** Dot-notation path accessors for nested object manipulation. */\n\nexport const getNestedValue = (obj: any, path: string): any => {\n return path.split('.').reduce((current, key) => {\n return current && current[key] !== undefined ? current[key] : undefined\n }, obj)\n}\n\nexport const setNestedValue = (obj: any, path: string, value: any): void => {\n const keys = path.split('.')\n const lastKey = keys.pop()\n\n if (!lastKey) {\n return\n }\n\n const target = keys.reduce((current, key) => {\n if (!current[key] || typeof current[key] !== 'object') {\n current[key] = {}\n }\n return current[key]\n }, obj)\n\n target[lastKey] = value\n}\n"],"names":["getNestedValue","obj","path","split","reduce","current","key","undefined","setNestedValue","value","keys","lastKey","pop","target"],"mappings":"AAAA,mEAEO,MAAMA,cAAAA,GAAiB,CAACC,GAAAA,EAAUC,IAAAA,GAAAA;AACvC,IAAA,OAAOA,KAAKC,KAAK,CAAC,KAAKC,MAAM,CAAC,CAACC,OAAAA,EAASC,GAAAA,GAAAA;QACtC,OAAOD,OAAAA,IAAWA,OAAO,CAACC,GAAAA,CAAI,KAAKC,SAAAA,GAAYF,OAAO,CAACC,GAAAA,CAAI,GAAGC,SAAAA;IAChE,CAAA,EAAGN,GAAAA,CAAAA;AACL;AAEO,MAAMO,cAAAA,GAAiB,CAACP,GAAAA,EAAUC,IAAAA,EAAcO,KAAAA,GAAAA;IACrD,MAAMC,IAAAA,GAAOR,IAAAA,CAAKC,KAAK,CAAC,GAAA,CAAA;IACxB,MAAMQ,OAAAA,GAAUD,KAAKE,GAAG,EAAA;AAExB,IAAA,IAAI,CAACD,OAAAA,EAAS;AACZ,QAAA;AACF,IAAA;AAEA,IAAA,MAAME,MAAAA,GAASH,IAAAA,CAAKN,MAAM,CAAC,CAACC,OAAAA,EAASC,GAAAA,GAAAA;QACnC,IAAI,CAACD,OAAO,CAACC,GAAAA,CAAI,IAAI,OAAOD,OAAO,CAACC,GAAAA,CAAI,KAAK,QAAA,EAAU;YACrDD,OAAO,CAACC,GAAAA,CAAI,GAAG,EAAC;AAClB,QAAA;QACA,OAAOD,OAAO,CAACC,GAAAA,CAAI;IACrB,CAAA,EAAGL,GAAAA,CAAAA;IAEHY,MAAM,CAACF,QAAQ,GAAGF,KAAAA;AACpB;;;;"}
@@ -0,0 +1,10 @@
1
+ /** Simple in-memory rate limiter for endpoint protection. */
2
+ /**
3
+ * Check if a request is within the rate limit.
4
+ * Returns true if allowed, false if rate-limited.
5
+ */
6
+ export declare const checkRateLimit: (key: string, maxAttempts?: number, windowMs?: number) => boolean;
7
+ /** Reset rate limit for a specific key (useful for testing). */
8
+ export declare const resetRateLimit: (key: string) => void;
9
+ /** Clear all rate limit records. */
10
+ export declare const clearAllRateLimits: () => void;
@@ -0,0 +1,29 @@
1
+ /** Simple in-memory rate limiter for endpoint protection. */ const attempts = new Map();
2
+ /**
3
+ * Check if a request is within the rate limit.
4
+ * Returns true if allowed, false if rate-limited.
5
+ */ const checkRateLimit = (key, maxAttempts = 10, windowMs = 60000)=>{
6
+ const now = Date.now();
7
+ const record = attempts.get(key);
8
+ if (!record || now > record.resetAt) {
9
+ attempts.set(key, {
10
+ count: 1,
11
+ resetAt: now + windowMs
12
+ });
13
+ return true;
14
+ }
15
+ if (record.count >= maxAttempts) {
16
+ return false;
17
+ }
18
+ record.count++;
19
+ return true;
20
+ };
21
+ /** Reset rate limit for a specific key (useful for testing). */ const resetRateLimit = (key)=>{
22
+ attempts.delete(key);
23
+ };
24
+ /** Clear all rate limit records. */ const clearAllRateLimits = ()=>{
25
+ attempts.clear();
26
+ };
27
+
28
+ export { checkRateLimit, clearAllRateLimits, resetRateLimit };
29
+ //# sourceMappingURL=rateLimiter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rateLimiter.js","sources":["../../../src/utils/helpers/rateLimiter.ts"],"sourcesContent":["/** Simple in-memory rate limiter for endpoint protection. */\n\nconst attempts = new Map<string, { count: number; resetAt: number }>()\n\n/**\n * Check if a request is within the rate limit.\n * Returns true if allowed, false if rate-limited.\n */\nexport const checkRateLimit = (key: string, maxAttempts = 10, windowMs = 60000): boolean => {\n const now = Date.now()\n const record = attempts.get(key)\n\n if (!record || now > record.resetAt) {\n attempts.set(key, { count: 1, resetAt: now + windowMs })\n return true\n }\n\n if (record.count >= maxAttempts) {\n return false\n }\n\n record.count++\n return true\n}\n\n/** Reset rate limit for a specific key (useful for testing). */\nexport const resetRateLimit = (key: string): void => {\n attempts.delete(key)\n}\n\n/** Clear all rate limit records. */\nexport const clearAllRateLimits = (): void => {\n attempts.clear()\n}\n"],"names":["attempts","Map","checkRateLimit","key","maxAttempts","windowMs","now","Date","record","get","resetAt","set","count","resetRateLimit","delete","clearAllRateLimits","clear"],"mappings":"AAAA,8DAEA,MAAMA,QAAAA,GAAW,IAAIC,GAAAA,EAAAA;AAErB;;;UAIaC,cAAAA,GAAiB,CAACC,KAAaC,WAAAA,GAAc,EAAE,EAAEC,QAAAA,GAAW,KAAK,GAAA;IAC5E,MAAMC,GAAAA,GAAMC,KAAKD,GAAG,EAAA;IACpB,MAAME,MAAAA,GAASR,QAAAA,CAASS,GAAG,CAACN,GAAAA,CAAAA;AAE5B,IAAA,IAAI,CAACK,MAAAA,IAAUF,GAAAA,GAAME,MAAAA,CAAOE,OAAO,EAAE;QACnCV,QAAAA,CAASW,GAAG,CAACR,GAAAA,EAAK;YAAES,KAAAA,EAAO,CAAA;AAAGF,YAAAA,OAAAA,EAASJ,GAAAA,GAAMD;AAAS,SAAA,CAAA;QACtD,OAAO,IAAA;AACT,IAAA;IAEA,IAAIG,MAAAA,CAAOI,KAAK,IAAIR,WAAAA,EAAa;QAC/B,OAAO,KAAA;AACT,IAAA;AAEAI,IAAAA,MAAAA,CAAOI,KAAK,EAAA;IACZ,OAAO,IAAA;AACT;AAEA,iEACO,MAAMC,cAAAA,GAAiB,CAACV,GAAAA,GAAAA;AAC7BH,IAAAA,QAAAA,CAASc,MAAM,CAACX,GAAAA,CAAAA;AAClB;AAEA,qCACO,MAAMY,kBAAAA,GAAqB,IAAA;AAChCf,IAAAA,QAAAA,CAASgB,KAAK,EAAA;AAChB;;;;"}
@@ -0,0 +1,3 @@
1
+ /** Standardized JSON response factories for API endpoints. */
2
+ export declare const createSuccessResponse: (data: any, status?: number) => Response;
3
+ export declare const createErrorResponse: (error: Error | string, status?: number) => Response;
@@ -0,0 +1,23 @@
1
+ /** Standardized JSON response factories for API endpoints. */ const createSuccessResponse = (data, status = 200)=>{
2
+ return new Response(JSON.stringify(data), {
3
+ headers: {
4
+ 'Content-Type': 'application/json'
5
+ },
6
+ status
7
+ });
8
+ };
9
+ const createErrorResponse = (error, status = 400)=>{
10
+ const errorMessage = error instanceof Error ? error.message : error;
11
+ return new Response(JSON.stringify({
12
+ error: errorMessage,
13
+ success: false
14
+ }), {
15
+ headers: {
16
+ 'Content-Type': 'application/json'
17
+ },
18
+ status
19
+ });
20
+ };
21
+
22
+ export { createErrorResponse, createSuccessResponse };
23
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sources":["../../../src/utils/helpers/responses.ts"],"sourcesContent":["/** Standardized JSON response factories for API endpoints. */\n\nexport const createSuccessResponse = (data: any, status = 200): Response => {\n return new Response(JSON.stringify(data), {\n headers: {\n 'Content-Type': 'application/json',\n },\n status,\n })\n}\n\nexport const createErrorResponse = (error: Error | string, status = 400): Response => {\n const errorMessage = error instanceof Error ? error.message : error\n return new Response(\n JSON.stringify({\n error: errorMessage,\n success: false,\n }),\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n status,\n },\n )\n}\n"],"names":["createSuccessResponse","data","status","Response","JSON","stringify","headers","createErrorResponse","error","errorMessage","Error","message","success"],"mappings":"AAAA,+DAEO,MAAMA,wBAAwB,CAACC,IAAAA,EAAWC,SAAS,GAAG,GAAA;AAC3D,IAAA,OAAO,IAAIC,QAAAA,CAASC,IAAAA,CAAKC,SAAS,CAACJ,IAAAA,CAAAA,EAAO;QACxCK,OAAAA,EAAS;YACP,cAAA,EAAgB;AAClB,SAAA;AACAJ,QAAAA;AACF,KAAA,CAAA;AACF;AAEO,MAAMK,mBAAAA,GAAsB,CAACC,KAAAA,EAAuBN,SAAS,GAAG,GAAA;AACrE,IAAA,MAAMO,YAAAA,GAAeD,KAAAA,YAAiBE,KAAAA,GAAQF,KAAAA,CAAMG,OAAO,GAAGH,KAAAA;AAC9D,IAAA,OAAO,IAAIL,QAAAA,CACTC,IAAAA,CAAKC,SAAS,CAAC;QACbG,KAAAA,EAAOC,YAAAA;QACPG,OAAAA,EAAS;KACX,CAAA,EACA;QACEN,OAAAA,EAAS;YACP,cAAA,EAAgB;AAClB,SAAA;AACAJ,QAAAA;AACF,KAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,6 @@
1
+ /** WordPress REST API URL construction and endpoint mapping utilities. */
2
+ import type { WordPressCredentials } from '../types.js';
3
+ export declare const constructWordPressApiUrl: (wpSiteUrl: string) => string;
4
+ export declare const createWordPressHeaders: (credentials: Pick<WordPressCredentials, "wpPassword" | "wpUsername">) => Record<string, string>;
5
+ export declare const getContentTypeEndpoint: (wpApiUrl: string, contentType: string) => string;
6
+ export declare const getFieldAnalysisEndpoint: (wpApiUrl: string, contentType: string) => string;
@@ -0,0 +1,29 @@
1
+ /** WordPress REST API URL construction and endpoint mapping utilities. */ const constructWordPressApiUrl = (wpSiteUrl)=>{
2
+ return wpSiteUrl.endsWith('/') ? `${wpSiteUrl}wp-json/wp/v2` : `${wpSiteUrl}/wp-json/wp/v2`;
3
+ };
4
+ const createWordPressHeaders = (credentials)=>({
5
+ Authorization: `Basic ${Buffer.from(`${credentials.wpUsername}:${credentials.wpPassword}`).toString('base64')}`,
6
+ 'Content-Type': 'application/json'
7
+ });
8
+ const getContentTypeEndpoint = (wpApiUrl, contentType)=>{
9
+ const endpoints = {
10
+ categories: `${wpApiUrl}/categories`,
11
+ media: `${wpApiUrl}/media`,
12
+ pages: `${wpApiUrl}/pages`,
13
+ posts: `${wpApiUrl}/posts`,
14
+ users: `${wpApiUrl}/users`
15
+ };
16
+ return endpoints[contentType] || `${wpApiUrl}/${contentType}`;
17
+ };
18
+ const getFieldAnalysisEndpoint = (wpApiUrl, contentType)=>{
19
+ const embedTypes = [
20
+ 'pages',
21
+ 'posts'
22
+ ];
23
+ const baseEndpoint = getContentTypeEndpoint(wpApiUrl, contentType);
24
+ const embedParam = embedTypes.includes(contentType) ? '&_embed=1' : '';
25
+ return `${baseEndpoint}?per_page=1${embedParam}`;
26
+ };
27
+
28
+ export { constructWordPressApiUrl, createWordPressHeaders, getContentTypeEndpoint, getFieldAnalysisEndpoint };
29
+ //# sourceMappingURL=wpHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wpHelpers.js","sources":["../../../src/utils/helpers/wpHelpers.ts"],"sourcesContent":["/** WordPress REST API URL construction and endpoint mapping utilities. */\n\nimport type { WordPressCredentials } from '../types.js'\n\nexport const constructWordPressApiUrl = (wpSiteUrl: string): string => {\n return wpSiteUrl.endsWith('/') ? `${wpSiteUrl}wp-json/wp/v2` : `${wpSiteUrl}/wp-json/wp/v2`\n}\n\nexport const createWordPressHeaders = (\n credentials: Pick<WordPressCredentials, 'wpPassword' | 'wpUsername'>,\n): Record<string, string> => ({\n Authorization: `Basic ${Buffer.from(`${credentials.wpUsername}:${credentials.wpPassword}`).toString('base64')}`,\n 'Content-Type': 'application/json',\n})\n\nexport const getContentTypeEndpoint = (wpApiUrl: string, contentType: string): string => {\n const endpoints: Record<string, string> = {\n categories: `${wpApiUrl}/categories`,\n media: `${wpApiUrl}/media`,\n pages: `${wpApiUrl}/pages`,\n posts: `${wpApiUrl}/posts`,\n users: `${wpApiUrl}/users`,\n }\n\n return endpoints[contentType] || `${wpApiUrl}/${contentType}`\n}\n\nexport const getFieldAnalysisEndpoint = (wpApiUrl: string, contentType: string): string => {\n const embedTypes = ['pages', 'posts']\n const baseEndpoint = getContentTypeEndpoint(wpApiUrl, contentType)\n const embedParam = embedTypes.includes(contentType) ? '&_embed=1' : ''\n\n return `${baseEndpoint}?per_page=1${embedParam}`\n}\n"],"names":["constructWordPressApiUrl","wpSiteUrl","endsWith","createWordPressHeaders","credentials","Authorization","Buffer","from","wpUsername","wpPassword","toString","getContentTypeEndpoint","wpApiUrl","contentType","endpoints","categories","media","pages","posts","users","getFieldAnalysisEndpoint","embedTypes","baseEndpoint","embedParam","includes"],"mappings":"AAAA,2EAIO,MAAMA,wBAAAA,GAA2B,CAACC,SAAAA,GAAAA;AACvC,IAAA,OAAOA,SAAAA,CAAUC,QAAQ,CAAC,GAAA,CAAA,GAAO,CAAA,EAAGD,SAAAA,CAAU,aAAa,CAAC,GAAG,CAAA,EAAGA,SAAAA,CAAU,cAAc,CAAC;AAC7F;AAEO,MAAME,sBAAAA,GAAyB,CACpCC,WAAAA,IAC4B;AAC5BC,QAAAA,aAAAA,EAAe,CAAC,MAAM,EAAEC,OAAOC,IAAI,CAAC,GAAGH,WAAAA,CAAYI,UAAU,CAAC,CAAC,EAAEJ,WAAAA,CAAYK,UAAU,EAAE,CAAA,CAAEC,QAAQ,CAAC,QAAA,CAAA,CAAA,CAAW;QAC/G,cAAA,EAAgB;AAClB,KAAA;AAEO,MAAMC,sBAAAA,GAAyB,CAACC,QAAAA,EAAkBC,WAAAA,GAAAA;AACvD,IAAA,MAAMC,SAAAA,GAAoC;QACxCC,UAAAA,EAAY,CAAA,EAAGH,QAAAA,CAAS,WAAW,CAAC;QACpCI,KAAAA,EAAO,CAAA,EAAGJ,QAAAA,CAAS,MAAM,CAAC;QAC1BK,KAAAA,EAAO,CAAA,EAAGL,QAAAA,CAAS,MAAM,CAAC;QAC1BM,KAAAA,EAAO,CAAA,EAAGN,QAAAA,CAAS,MAAM,CAAC;QAC1BO,KAAAA,EAAO,CAAA,EAAGP,QAAAA,CAAS,MAAM;AAC3B,KAAA;IAEA,OAAOE,SAAS,CAACD,WAAAA,CAAY,IAAI,GAAGD,QAAAA,CAAS,CAAC,EAAEC,WAAAA,CAAAA,CAAa;AAC/D;AAEO,MAAMO,wBAAAA,GAA2B,CAACR,QAAAA,EAAkBC,WAAAA,GAAAA;AACzD,IAAA,MAAMQ,UAAAA,GAAa;AAAC,QAAA,OAAA;AAAS,QAAA;AAAQ,KAAA;IACrC,MAAMC,YAAAA,GAAeX,uBAAuBC,QAAAA,EAAUC,WAAAA,CAAAA;AACtD,IAAA,MAAMU,UAAAA,GAAaF,UAAAA,CAAWG,QAAQ,CAACX,eAAe,WAAA,GAAc,EAAA;AAEpE,IAAA,OAAO,CAAA,EAAGS,YAAAA,CAAa,WAAW,EAAEC,UAAAA,CAAAA,CAAY;AAClD;;;;"}
@@ -0,0 +1,37 @@
1
+ /** Lexical format bitmasks, HTML-to-Lexical element maps, and type definitions. */
2
+ export declare const TEXT_FORMAT_BOLD = 1;
3
+ export declare const TEXT_FORMAT_ITALIC = 2;
4
+ export declare const TEXT_FORMAT_UNDERLINE = 8;
5
+ export declare const TEXT_FORMAT_STRIKETHROUGH = 4;
6
+ export declare const TEXT_FORMAT_CODE = 16;
7
+ export declare const TEXT_FORMAT_SUBSCRIPT = 32;
8
+ export declare const TEXT_FORMAT_SUPERSCRIPT = 64;
9
+ export declare const BLOCK_ELEMENT_MAP: Record<string, string>;
10
+ export declare const INLINE_FORMAT_MAP: Record<string, number>;
11
+ export declare const VOID_ELEMENTS: Set<string>;
12
+ export interface ParsedElement {
13
+ attributes: Record<string, string>;
14
+ children: (ParsedElement | string)[];
15
+ tagName: string;
16
+ textContent?: string;
17
+ }
18
+ export interface LexicalNode {
19
+ [key: string]: any;
20
+ type: string;
21
+ }
22
+ export interface TextNode extends LexicalNode {
23
+ detail: number;
24
+ format: number;
25
+ mode: string;
26
+ style: string;
27
+ text: string;
28
+ type: 'text';
29
+ version: number;
30
+ }
31
+ export interface ElementNode extends LexicalNode {
32
+ children: LexicalNode[];
33
+ direction: string;
34
+ format: string;
35
+ indent: number;
36
+ version: number;
37
+ }
@@ -0,0 +1,58 @@
1
+ /** Lexical format bitmasks, HTML-to-Lexical element maps, and type definitions. */ const TEXT_FORMAT_BOLD = 1;
2
+ const TEXT_FORMAT_ITALIC = 2;
3
+ const TEXT_FORMAT_UNDERLINE = 8;
4
+ const TEXT_FORMAT_STRIKETHROUGH = 4;
5
+ const TEXT_FORMAT_CODE = 16;
6
+ const TEXT_FORMAT_SUBSCRIPT = 32;
7
+ const TEXT_FORMAT_SUPERSCRIPT = 64;
8
+ const BLOCK_ELEMENT_MAP = {
9
+ article: 'paragraph',
10
+ blockquote: 'quote',
11
+ div: 'paragraph',
12
+ h1: 'heading',
13
+ h2: 'heading',
14
+ h3: 'heading',
15
+ h4: 'heading',
16
+ h5: 'heading',
17
+ h6: 'heading',
18
+ li: 'listitem',
19
+ ol: 'list',
20
+ p: 'paragraph',
21
+ section: 'paragraph',
22
+ ul: 'list'
23
+ };
24
+ const INLINE_FORMAT_MAP = {
25
+ b: TEXT_FORMAT_BOLD,
26
+ code: TEXT_FORMAT_CODE,
27
+ del: TEXT_FORMAT_STRIKETHROUGH,
28
+ em: TEXT_FORMAT_ITALIC,
29
+ i: TEXT_FORMAT_ITALIC,
30
+ ins: TEXT_FORMAT_UNDERLINE,
31
+ kbd: TEXT_FORMAT_CODE,
32
+ s: TEXT_FORMAT_STRIKETHROUGH,
33
+ samp: TEXT_FORMAT_CODE,
34
+ strike: TEXT_FORMAT_STRIKETHROUGH,
35
+ strong: TEXT_FORMAT_BOLD,
36
+ sub: TEXT_FORMAT_SUBSCRIPT,
37
+ sup: TEXT_FORMAT_SUPERSCRIPT,
38
+ u: TEXT_FORMAT_UNDERLINE
39
+ };
40
+ const VOID_ELEMENTS = new Set([
41
+ 'area',
42
+ 'base',
43
+ 'br',
44
+ 'col',
45
+ 'embed',
46
+ 'hr',
47
+ 'img',
48
+ 'input',
49
+ 'link',
50
+ 'meta',
51
+ 'param',
52
+ 'source',
53
+ 'track',
54
+ 'wbr'
55
+ ]);
56
+
57
+ export { BLOCK_ELEMENT_MAP, INLINE_FORMAT_MAP, TEXT_FORMAT_BOLD, TEXT_FORMAT_CODE, TEXT_FORMAT_ITALIC, TEXT_FORMAT_STRIKETHROUGH, TEXT_FORMAT_SUBSCRIPT, TEXT_FORMAT_SUPERSCRIPT, TEXT_FORMAT_UNDERLINE, VOID_ELEMENTS };
58
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../src/utils/lexical/constants.ts"],"sourcesContent":["/** Lexical format bitmasks, HTML-to-Lexical element maps, and type definitions. */\n\nexport const TEXT_FORMAT_BOLD = 1\nexport const TEXT_FORMAT_ITALIC = 2\nexport const TEXT_FORMAT_UNDERLINE = 8\nexport const TEXT_FORMAT_STRIKETHROUGH = 4\nexport const TEXT_FORMAT_CODE = 16\nexport const TEXT_FORMAT_SUBSCRIPT = 32\nexport const TEXT_FORMAT_SUPERSCRIPT = 64\n\nexport const BLOCK_ELEMENT_MAP: Record<string, string> = {\n article: 'paragraph',\n blockquote: 'quote',\n div: 'paragraph',\n h1: 'heading',\n h2: 'heading',\n h3: 'heading',\n h4: 'heading',\n h5: 'heading',\n h6: 'heading',\n li: 'listitem',\n ol: 'list',\n p: 'paragraph',\n section: 'paragraph',\n ul: 'list',\n}\n\nexport const INLINE_FORMAT_MAP: Record<string, number> = {\n b: TEXT_FORMAT_BOLD,\n code: TEXT_FORMAT_CODE,\n del: TEXT_FORMAT_STRIKETHROUGH,\n em: TEXT_FORMAT_ITALIC,\n i: TEXT_FORMAT_ITALIC,\n ins: TEXT_FORMAT_UNDERLINE,\n kbd: TEXT_FORMAT_CODE,\n s: TEXT_FORMAT_STRIKETHROUGH,\n samp: TEXT_FORMAT_CODE,\n strike: TEXT_FORMAT_STRIKETHROUGH,\n strong: TEXT_FORMAT_BOLD,\n sub: TEXT_FORMAT_SUBSCRIPT,\n sup: TEXT_FORMAT_SUPERSCRIPT,\n u: TEXT_FORMAT_UNDERLINE,\n}\n\nexport const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n])\n\nexport interface ParsedElement {\n attributes: Record<string, string>\n children: (ParsedElement | string)[]\n tagName: string\n textContent?: string\n}\n\nexport interface LexicalNode {\n [key: string]: any\n type: string\n}\n\nexport interface TextNode extends LexicalNode {\n detail: number\n format: number\n mode: string\n style: string\n text: string\n type: 'text'\n version: number\n}\n\nexport interface ElementNode extends LexicalNode {\n children: LexicalNode[]\n direction: string\n format: string\n indent: number\n version: number\n}\n"],"names":["TEXT_FORMAT_BOLD","TEXT_FORMAT_ITALIC","TEXT_FORMAT_UNDERLINE","TEXT_FORMAT_STRIKETHROUGH","TEXT_FORMAT_CODE","TEXT_FORMAT_SUBSCRIPT","TEXT_FORMAT_SUPERSCRIPT","BLOCK_ELEMENT_MAP","article","blockquote","div","h1","h2","h3","h4","h5","h6","li","ol","p","section","ul","INLINE_FORMAT_MAP","b","code","del","em","i","ins","kbd","s","samp","strike","strong","sub","sup","u","VOID_ELEMENTS","Set"],"mappings":"AAAA,oFAEO,MAAMA,gBAAAA,GAAmB;AACzB,MAAMC,qBAAqB;AAC3B,MAAMC,wBAAwB;AAC9B,MAAMC,4BAA4B;AAClC,MAAMC,mBAAmB;AACzB,MAAMC,wBAAwB;AAC9B,MAAMC,0BAA0B;MAE1BC,iBAAAA,GAA4C;IACvDC,OAAAA,EAAS,WAAA;IACTC,UAAAA,EAAY,OAAA;IACZC,GAAAA,EAAK,WAAA;IACLC,EAAAA,EAAI,SAAA;IACJC,EAAAA,EAAI,SAAA;IACJC,EAAAA,EAAI,SAAA;IACJC,EAAAA,EAAI,SAAA;IACJC,EAAAA,EAAI,SAAA;IACJC,EAAAA,EAAI,SAAA;IACJC,EAAAA,EAAI,UAAA;IACJC,EAAAA,EAAI,MAAA;IACJC,CAAAA,EAAG,WAAA;IACHC,OAAAA,EAAS,WAAA;IACTC,EAAAA,EAAI;AACN;MAEaC,iBAAAA,GAA4C;IACvDC,CAAAA,EAAGvB,gBAAAA;IACHwB,IAAAA,EAAMpB,gBAAAA;IACNqB,GAAAA,EAAKtB,yBAAAA;IACLuB,EAAAA,EAAIzB,kBAAAA;IACJ0B,CAAAA,EAAG1B,kBAAAA;IACH2B,GAAAA,EAAK1B,qBAAAA;IACL2B,GAAAA,EAAKzB,gBAAAA;IACL0B,CAAAA,EAAG3B,yBAAAA;IACH4B,IAAAA,EAAM3B,gBAAAA;IACN4B,MAAAA,EAAQ7B,yBAAAA;IACR8B,MAAAA,EAAQjC,gBAAAA;IACRkC,GAAAA,EAAK7B,qBAAAA;IACL8B,GAAAA,EAAK7B,uBAAAA;IACL8B,CAAAA,EAAGlC;AACL;AAEO,MAAMmC,aAAAA,GAAgB,IAAIC,GAAAA,CAAI;AACnC,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,IAAA;AACA,IAAA,KAAA;AACA,IAAA,OAAA;AACA,IAAA,IAAA;AACA,IAAA,KAAA;AACA,IAAA,OAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,OAAA;AACA,IAAA;CACD;;;;"}
@@ -0,0 +1,20 @@
1
+ /** Lightweight recursive-descent HTML parser for converting markup to a parsed element tree. */
2
+ import type { ParsedElement } from './constants.js';
3
+ export declare class SimpleHTMLParser {
4
+ private depth;
5
+ private html;
6
+ private position;
7
+ constructor(html: string);
8
+ private decodeHtmlEntities;
9
+ private parseAttributeName;
10
+ private parseAttributes;
11
+ private parseAttributeValue;
12
+ private parseChildren;
13
+ private parseElement;
14
+ private parseNode;
15
+ private parseTagName;
16
+ private parseText;
17
+ private skipComment;
18
+ private skipWhitespace;
19
+ parse(): ParsedElement;
20
+ }