@jwilleke/ngdpbase-types 0.0.0 → 5.18.0

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 (302) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +16 -2
  3. package/lib/packages/ngdpbase-types/index.d.ts +32 -0
  4. package/lib/packages/ngdpbase-types/testing.d.ts +43 -0
  5. package/lib/packages/ngdpbase-types/testing.js +53 -0
  6. package/lib/src/cache/CacheDependencies.d.ts +50 -0
  7. package/lib/src/cache/CacheDependencies.js +50 -0
  8. package/lib/src/cache/ICacheAdapter.d.ts +86 -0
  9. package/lib/src/cache/RegionCache.d.ts +171 -0
  10. package/lib/src/context/ActorContext.d.ts +48 -0
  11. package/lib/src/context/ActorContext.js +33 -0
  12. package/lib/src/context/ApiContext.d.ts +194 -0
  13. package/lib/src/context/ApiContext.js +273 -0
  14. package/lib/src/context/BaseContext.d.ts +110 -0
  15. package/lib/src/context/BaseContext.js +143 -0
  16. package/lib/src/context/JobContext.d.ts +153 -0
  17. package/lib/src/context/JobContext.js +144 -0
  18. package/lib/src/context/WikiContext.d.ts +404 -0
  19. package/lib/src/context/bootActions.d.ts +64 -0
  20. package/lib/src/context/bootActions.js +111 -0
  21. package/lib/src/converters/HtmlConverter.d.ts +70 -0
  22. package/lib/src/converters/IContentConverter.d.ts +94 -0
  23. package/lib/src/converters/JSPWikiConverter.d.ts +117 -0
  24. package/lib/src/converters/conversionWarning.d.ts +15 -0
  25. package/lib/src/converters/ncm/bridge.d.ts +22 -0
  26. package/lib/src/converters/ncm/existing.d.ts +23 -0
  27. package/lib/src/converters/ncm/fix/blocks.d.ts +89 -0
  28. package/lib/src/converters/ncm/fix/bulletMarkers.d.ts +21 -0
  29. package/lib/src/converters/ncm/fix/index.d.ts +36 -0
  30. package/lib/src/converters/ncm/fix/jspwikiBullets.d.ts +20 -0
  31. package/lib/src/converters/ncm/fix/jspwikiCodeMarkers.d.ts +38 -0
  32. package/lib/src/converters/ncm/fix/jspwikiHeadings.d.ts +25 -0
  33. package/lib/src/converters/ncm/fix/jspwikiIndent.d.ts +24 -0
  34. package/lib/src/converters/ncm/fix/jspwikiInsert.d.ts +21 -0
  35. package/lib/src/converters/ncm/fix/jspwikiItalic.d.ts +29 -0
  36. package/lib/src/converters/ncm/fix/jspwikiLinkLeftovers.d.ts +27 -0
  37. package/lib/src/converters/ncm/fix/moreInformationFooter.d.ts +25 -0
  38. package/lib/src/converters/ncm/fix/styleClosers.d.ts +25 -0
  39. package/lib/src/converters/ncm/fix/tightenLists.d.ts +30 -0
  40. package/lib/src/converters/ncm/fix/types.d.ts +33 -0
  41. package/lib/src/converters/ncm/footnotes.d.ts +39 -0
  42. package/lib/src/converters/ncm/images.d.ts +49 -0
  43. package/lib/src/converters/ncm/index.d.ts +20 -0
  44. package/lib/src/converters/ncm/links.d.ts +21 -0
  45. package/lib/src/converters/ncm/normalize.d.ts +39 -0
  46. package/lib/src/converters/ncm/placeholder.d.ts +25 -0
  47. package/lib/src/converters/ncm/tables.d.ts +36 -0
  48. package/lib/src/converters/ncm/types.d.ts +42 -0
  49. package/lib/src/http/egressPolicy.d.ts +52 -0
  50. package/lib/src/http/guardedFetch.d.ts +89 -0
  51. package/lib/src/http/guardedFetch.js +113 -0
  52. package/lib/src/http/guardedLookup.d.ts +48 -0
  53. package/lib/src/http/guardedLookup.js +73 -0
  54. package/lib/src/http/ssrf.d.ts +83 -0
  55. package/lib/src/http/ssrf.js +311 -0
  56. package/lib/src/mail/MailProvider.d.ts +36 -0
  57. package/lib/src/mail/NodemailerMailProvider.d.ts +26 -0
  58. package/lib/src/managers/AddonsManager.d.ts +691 -0
  59. package/lib/src/managers/AgentTokenManager.d.ts +269 -0
  60. package/lib/src/managers/AssetManager.d.ts +116 -0
  61. package/lib/src/managers/AttachmentManager.d.ts +1032 -0
  62. package/lib/src/managers/AuthManager.d.ts +1257 -0
  63. package/lib/src/managers/BackgroundJobManager.d.ts +434 -0
  64. package/lib/src/managers/BaseManager.d.ts +391 -0
  65. package/lib/src/managers/BaseManager.js +415 -0
  66. package/lib/src/managers/CacheManager.d.ts +159 -0
  67. package/lib/src/managers/CatalogManager.d.ts +235 -0
  68. package/lib/src/managers/CommentManager.d.ts +75 -0
  69. package/lib/src/managers/ConfigurationManager.d.ts +747 -0
  70. package/lib/src/managers/DatabaseManager.d.ts +89 -0
  71. package/lib/src/managers/DatabaseManager.js +236 -0
  72. package/lib/src/managers/EmailManager.d.ts +47 -0
  73. package/lib/src/managers/ExportManager.d.ts +129 -0
  74. package/lib/src/managers/ExportManager.js +420 -0
  75. package/lib/src/managers/FootnoteManager.d.ts +118 -0
  76. package/lib/src/managers/MediaManager.d.ts +279 -0
  77. package/lib/src/managers/MetricsManager.d.ts +89 -0
  78. package/lib/src/managers/NotificationManager.d.ts +165 -0
  79. package/lib/src/managers/OidcManager.d.ts +210 -0
  80. package/lib/src/managers/OrganizationManager.d.ts +107 -0
  81. package/lib/src/managers/PageManager.d.ts +1645 -0
  82. package/lib/src/managers/PersonManager.d.ts +48 -0
  83. package/lib/src/managers/PluginManager.d.ts +179 -0
  84. package/lib/src/managers/PluginManager.js +393 -0
  85. package/lib/src/managers/PolicyEvaluator.d.ts +213 -0
  86. package/lib/src/managers/RenderingManager.d.ts +358 -0
  87. package/lib/src/managers/RoleManager.d.ts +134 -0
  88. package/lib/src/managers/SearchManager.d.ts +402 -0
  89. package/lib/src/managers/ShareManager.d.ts +251 -0
  90. package/lib/src/managers/TemplateManager.d.ts +176 -0
  91. package/lib/src/managers/ThemeManager.d.ts +56 -0
  92. package/lib/src/managers/UserManager.d.ts +480 -0
  93. package/lib/src/managers/ValidationManager.d.ts +426 -0
  94. package/lib/src/managers/VariableManager.d.ts +145 -0
  95. package/lib/src/middleware/csrf.d.ts +3 -0
  96. package/lib/src/parsers/LinkParser.d.ts +457 -0
  97. package/lib/src/parsers/MarkupParser.d.ts +769 -0
  98. package/lib/src/parsers/context/ParseContext.d.ts +314 -0
  99. package/lib/src/parsers/data/emoji-map.d.ts +18 -0
  100. package/lib/src/parsers/dom/DOMBuilder.d.ts +210 -0
  101. package/lib/src/parsers/dom/DOMParser.d.ts +252 -0
  102. package/lib/src/parsers/dom/Tokenizer.d.ts +358 -0
  103. package/lib/src/parsers/dom/WikiDocument.d.ts +272 -0
  104. package/lib/src/parsers/dom/handlers/DOMLinkHandler.d.ts +260 -0
  105. package/lib/src/parsers/dom/handlers/DOMPluginHandler.d.ts +212 -0
  106. package/lib/src/parsers/dom/handlers/DOMVariableHandler.d.ts +171 -0
  107. package/lib/src/parsers/filters/BaseFilter.d.ts +269 -0
  108. package/lib/src/parsers/filters/FilterChain.d.ts +320 -0
  109. package/lib/src/parsers/handlers/BaseSyntaxHandler.d.ts +331 -0
  110. package/lib/src/parsers/handlers/HandlerRegistry.d.ts +225 -0
  111. package/lib/src/parsers/handlers/JSPWikiPreprocessor.d.ts +89 -0
  112. package/lib/src/parsers/handlers/LinkParserHandler.d.ts +80 -0
  113. package/lib/src/parsers/handlers/PluginSyntaxHandler.d.ts +78 -0
  114. package/lib/src/parsers/handlers/WikiFormHandler.d.ts +149 -0
  115. package/lib/src/parsers/handlers/WikiTagHandler.d.ts +125 -0
  116. package/lib/src/parsers/jspwikiTableRow.d.ts +39 -0
  117. package/lib/src/parsers/styleBlockSyntax.d.ts +14 -0
  118. package/lib/src/plugins/types.d.ts +79 -0
  119. package/lib/src/providers/AgentTokenAuthProvider.d.ts +40 -0
  120. package/lib/src/providers/AuthentikBearerAuthProvider.d.ts +75 -0
  121. package/lib/src/providers/BaseAttachmentProvider.d.ts +197 -0
  122. package/lib/src/providers/BaseAuthProvider.d.ts +220 -0
  123. package/lib/src/providers/BaseCacheProvider.d.ts +140 -0
  124. package/lib/src/providers/BaseCredentialsProvider.d.ts +84 -0
  125. package/lib/src/providers/BaseDatabaseProvider.d.ts +22 -0
  126. package/lib/src/providers/BaseDatabaseProvider.js +12 -0
  127. package/lib/src/providers/BaseLoggingProvider.d.ts +68 -0
  128. package/lib/src/providers/BaseLoggingProvider.js +37 -0
  129. package/lib/src/providers/BaseMediaProvider.d.ts +308 -0
  130. package/lib/src/providers/BasePageProvider.d.ts +337 -0
  131. package/lib/src/providers/BaseProvider.d.ts +98 -0
  132. package/lib/src/providers/BaseProvider.js +74 -0
  133. package/lib/src/providers/BaseSearchProvider.d.ts +362 -0
  134. package/lib/src/providers/BasicAttachmentProvider.d.ts +599 -0
  135. package/lib/src/providers/CloudflareAccessAuthProvider.d.ts +72 -0
  136. package/lib/src/providers/FileCredentialsProvider.d.ts +33 -0
  137. package/lib/src/providers/FileJobStateProvider.d.ts +58 -0
  138. package/lib/src/providers/FileLoggingProvider.d.ts +43 -0
  139. package/lib/src/providers/FileLoggingProvider.js +120 -0
  140. package/lib/src/providers/FileOidcAdapter.d.ts +25 -0
  141. package/lib/src/providers/FileSystemMediaProvider.d.ts +403 -0
  142. package/lib/src/providers/LunrSearchProvider.d.ts +280 -0
  143. package/lib/src/providers/MagicLinkAuthProvider.d.ts +125 -0
  144. package/lib/src/providers/NullCacheProvider.d.ts +72 -0
  145. package/lib/src/providers/OidcAuthProvider.d.ts +180 -0
  146. package/lib/src/providers/OidcBearerAuthProvider.d.ts +30 -0
  147. package/lib/src/providers/PasskeyAuthProvider.d.ts +58 -0
  148. package/lib/src/providers/PasswordAuthProvider.d.ts +20 -0
  149. package/lib/src/providers/SqliteDatabaseProvider.d.ts +55 -0
  150. package/lib/src/providers/SqliteDatabaseProvider.js +90 -0
  151. package/lib/src/providers/SqliteJobStateProvider.d.ts +41 -0
  152. package/lib/src/providers/databaseMigrations.d.ts +8 -0
  153. package/lib/src/providers/databaseMigrations.js +47 -0
  154. package/lib/src/providers/jobState.d.ts +99 -0
  155. package/lib/src/providers/lunrQueryToMiniSearch.d.ts +32 -0
  156. package/lib/src/providers/mediaFilenameDate.d.ts +22 -0
  157. package/lib/src/providers/sqliteLocation.d.ts +17 -0
  158. package/lib/src/providers/sqliteLocation.js +55 -0
  159. package/lib/src/providers/sqliteMigrations.d.ts +48 -0
  160. package/lib/src/providers/sqliteMigrations.js +72 -0
  161. package/lib/src/rendering/githubAlerts.d.ts +22 -0
  162. package/lib/src/rendering/htmlPolicy.d.ts +76 -0
  163. package/lib/src/rendering/markdownConverter.d.ts +73 -0
  164. package/lib/src/security/PolicyDecisionPoint.d.ts +245 -0
  165. package/lib/src/security/PolicyInformationPoint.d.ts +448 -0
  166. package/lib/src/security/pageActions.d.ts +40 -0
  167. package/lib/src/security/permissions.generated.d.ts +78 -0
  168. package/lib/src/types/Asset.d.ts +414 -0
  169. package/lib/src/types/Catalog.d.ts +61 -0
  170. package/lib/src/types/Comment.d.ts +11 -0
  171. package/lib/src/types/Config.d.ts +388 -0
  172. package/lib/src/types/Organization.d.ts +78 -0
  173. package/lib/src/types/OrganizationProvider.d.ts +38 -0
  174. package/lib/src/types/Page.d.ts +220 -0
  175. package/lib/src/types/Person.d.ts +56 -0
  176. package/lib/src/types/PersonProvider.d.ts +25 -0
  177. package/lib/src/types/Policy.d.ts +139 -0
  178. package/lib/src/types/Policy.js +17 -0
  179. package/lib/src/types/Provider.d.ts +810 -0
  180. package/lib/src/types/Role.d.ts +84 -0
  181. package/lib/src/types/RoleProvider.d.ts +35 -0
  182. package/lib/src/types/Schema.d.ts +425 -0
  183. package/lib/src/types/Share.d.ts +172 -0
  184. package/lib/src/types/Share.js +81 -0
  185. package/lib/src/types/User.d.ts +304 -0
  186. package/lib/src/types/Version.d.ts +189 -0
  187. package/lib/src/types/WikiEngine.d.ts +128 -0
  188. package/lib/src/types/express.d.ts +120 -0
  189. package/lib/src/types/express.js +1 -0
  190. package/lib/src/types/guards.d.ts +78 -0
  191. package/lib/src/types/heic-decode.d.ts +16 -0
  192. package/lib/src/types/index.d.ts +19 -0
  193. package/lib/src/types/linkedom.d.ts +77 -0
  194. package/lib/src/types/markdown-it-plugins.d.ts +21 -0
  195. package/lib/src/utils/DeltaStorage.d.ts +118 -0
  196. package/lib/src/utils/LocaleUtils.d.ts +105 -0
  197. package/lib/src/utils/LocaleUtils.js +294 -0
  198. package/lib/src/utils/PageNameMatcher.d.ts +98 -0
  199. package/lib/src/utils/PathPreflight.d.ts +38 -0
  200. package/lib/src/utils/PathPreflight.js +50 -0
  201. package/lib/src/utils/SectionUtils.d.ts +40 -0
  202. package/lib/src/utils/addonConfigLayer.d.ts +144 -0
  203. package/lib/src/utils/addonConfigLayer.js +382 -0
  204. package/lib/src/utils/addonDatabaseRules.d.ts +25 -0
  205. package/lib/src/utils/addonDatabaseRules.js +57 -0
  206. package/lib/src/utils/addonHost.d.ts +51 -0
  207. package/lib/src/utils/addonHost.js +72 -0
  208. package/lib/src/utils/addonInstaller.d.ts +109 -0
  209. package/lib/src/utils/addonLock.d.ts +37 -0
  210. package/lib/src/utils/addonLock.js +48 -0
  211. package/lib/src/utils/addonPageSync.d.ts +45 -0
  212. package/lib/src/utils/addonProvenance.d.ts +48 -0
  213. package/lib/src/utils/addonTarball.d.ts +41 -0
  214. package/lib/src/utils/addonsPathResolver.d.ts +76 -0
  215. package/lib/src/utils/addonsPathResolver.js +129 -0
  216. package/lib/src/utils/assetMetadataTags.d.ts +66 -0
  217. package/lib/src/utils/atomicWrite.d.ts +28 -0
  218. package/lib/src/utils/auditConfigChange.d.ts +57 -0
  219. package/lib/src/utils/auditEventNames.d.ts +50 -0
  220. package/lib/src/utils/auditEventNames.generated.d.ts +163 -0
  221. package/lib/src/utils/auditEventNames.generated.js +168 -0
  222. package/lib/src/utils/auditEventNames.js +49 -0
  223. package/lib/src/utils/auditEvents.d.ts +265 -0
  224. package/lib/src/utils/auditEvents.js +309 -0
  225. package/lib/src/utils/auditRegistry.d.ts +102 -0
  226. package/lib/src/utils/auditRegistry.js +168 -0
  227. package/lib/src/utils/bip39English.d.ts +2 -0
  228. package/lib/src/utils/configEnvKeys.d.ts +68 -0
  229. package/lib/src/utils/configFiles.d.ts +74 -0
  230. package/lib/src/utils/configFiles.js +150 -0
  231. package/lib/src/utils/delegation.d.ts +48 -0
  232. package/lib/src/utils/deriveUsername.d.ts +21 -0
  233. package/lib/src/utils/explainMediaPath.d.ts +123 -0
  234. package/lib/src/utils/formerTitles.d.ts +69 -0
  235. package/lib/src/utils/frontmatterAccess.d.ts +54 -0
  236. package/lib/src/utils/headlessAdminPassword.d.ts +55 -0
  237. package/lib/src/utils/imageTransform.d.ts +52 -0
  238. package/lib/src/utils/instanceEnvSecret.d.ts +51 -0
  239. package/lib/src/utils/jobSlots.d.ts +43 -0
  240. package/lib/src/utils/keywordNormalizer.d.ts +127 -0
  241. package/lib/src/utils/logger.d.ts +70 -0
  242. package/lib/src/utils/logger.js +106 -0
  243. package/lib/src/utils/magicLinkDeviceState.d.ts +95 -0
  244. package/lib/src/utils/managerUtils.d.ts +40 -0
  245. package/lib/src/utils/migrateLegacyPrivateAttachments.d.ts +15 -0
  246. package/lib/src/utils/orgFilename.d.ts +22 -0
  247. package/lib/src/utils/pageFeature.d.ts +27 -0
  248. package/lib/src/utils/pageFrontmatter.d.ts +21 -0
  249. package/lib/src/utils/pageNotes.d.ts +150 -0
  250. package/lib/src/utils/pageTitleRule.d.ts +37 -0
  251. package/lib/src/utils/pageToArticle.d.ts +59 -0
  252. package/lib/src/utils/pageUrl.d.ts +18 -0
  253. package/lib/src/utils/passwordChange.d.ts +12 -0
  254. package/lib/src/utils/passwordHash.d.ts +60 -0
  255. package/lib/src/utils/permissionCatalog.d.ts +52 -0
  256. package/lib/src/utils/pluginFormatters.d.ts +452 -0
  257. package/lib/src/utils/pluginFormatters.js +714 -0
  258. package/lib/src/utils/privateLinkRewrite.d.ts +42 -0
  259. package/lib/src/utils/privateStoreAccess.d.ts +57 -0
  260. package/lib/src/utils/privateStoreAccess.js +65 -0
  261. package/lib/src/utils/privateStoreCatalogs.d.ts +40 -0
  262. package/lib/src/utils/privateStoreCrypto.d.ts +127 -0
  263. package/lib/src/utils/privateStoreDoor.d.ts +181 -0
  264. package/lib/src/utils/privateStoreExport.d.ts +72 -0
  265. package/lib/src/utils/privateStoreFiles.d.ts +120 -0
  266. package/lib/src/utils/privateStoreMeta.d.ts +64 -0
  267. package/lib/src/utils/privateStoreMigrations.d.ts +37 -0
  268. package/lib/src/utils/privateStorePath.d.ts +259 -0
  269. package/lib/src/utils/privateStorePath.js +436 -0
  270. package/lib/src/utils/privateStoreTakeout.d.ts +76 -0
  271. package/lib/src/utils/privateStoreUnlock.d.ts +175 -0
  272. package/lib/src/utils/proxyClaim.d.ts +59 -0
  273. package/lib/src/utils/proxyClaim.js +30 -0
  274. package/lib/src/utils/redactPrivateNames.d.ts +21 -0
  275. package/lib/src/utils/redactPrivateNames.js +89 -0
  276. package/lib/src/utils/redactSecrets.d.ts +58 -0
  277. package/lib/src/utils/redactSecrets.js +171 -0
  278. package/lib/src/utils/renameLinkRewrite.d.ts +112 -0
  279. package/lib/src/utils/roleGrants.d.ts +35 -0
  280. package/lib/src/utils/safeRedirect.d.ts +32 -0
  281. package/lib/src/utils/schedule.d.ts +54 -0
  282. package/lib/src/utils/secretFileMode.d.ts +17 -0
  283. package/lib/src/utils/seededShippedPages.d.ts +45 -0
  284. package/lib/src/utils/sensitiveValues.d.ts +59 -0
  285. package/lib/src/utils/sensitiveValues.js +106 -0
  286. package/lib/src/utils/sessionEnd.d.ts +12 -0
  287. package/lib/src/utils/sessionGeneration.d.ts +24 -0
  288. package/lib/src/utils/sessionIdle.d.ts +41 -0
  289. package/lib/src/utils/sessionLimits.d.ts +68 -0
  290. package/lib/src/utils/shareLockbox.d.ts +64 -0
  291. package/lib/src/utils/sigstoreTrustedRoot.d.ts +33 -0
  292. package/lib/src/utils/sniffMime.d.ts +21 -0
  293. package/lib/src/utils/storeSearchIndex.d.ts +75 -0
  294. package/lib/src/utils/subjectMayDo.d.ts +21 -0
  295. package/lib/src/utils/systemCategoryRules.d.ts +30 -0
  296. package/lib/src/utils/systemCategoryRules.js +41 -0
  297. package/lib/src/utils/userCreateError.d.ts +62 -0
  298. package/lib/src/utils/username.d.ts +53 -0
  299. package/lib/src/utils/vaultUrlRewrite.d.ts +27 -0
  300. package/lib/src/utils/version.d.ts +84 -0
  301. package/lib/src/utils/videoFrame.d.ts +21 -0
  302. package/package.json +54 -3
@@ -0,0 +1,314 @@
1
+ /**
2
+ * ParseContext - Context object for markup parsing operations
3
+ *
4
+ * Provides access to page context, user information, engine managers,
5
+ * and parsing state throughout the processing pipeline.
6
+ *
7
+ * Related Issue: #55 - Core Infrastructure and Phase System
8
+ */
9
+ import CacheDependencies from '../../cache/CacheDependencies.js';
10
+ import { type PermissionSubject } from '../../managers/UserManager.js';
11
+ /**
12
+ * User context interface
13
+ */
14
+ export interface UserContext extends PermissionSubject {
15
+ /** Legacy alias some plugin code reads. */
16
+ userName?: string;
17
+ permissions?: string[];
18
+ /** A test account (#1805), from the account record; plugins enforce their own rules from it. */
19
+ isTest?: boolean;
20
+ [key: string]: unknown;
21
+ }
22
+ /**
23
+ * Request information
24
+ */
25
+ export interface RequestInfo {
26
+ method?: string;
27
+ path?: string;
28
+ ip?: string;
29
+ userAgent?: string;
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * Minimal page frontmatter for parse context (uuid is the key consumer)
34
+ */
35
+ export interface PageFrontmatter {
36
+ uuid?: string;
37
+ title?: string;
38
+ [key: string]: unknown;
39
+ }
40
+ /**
41
+ * Page context interface
42
+ */
43
+ export interface PageContext {
44
+ pageName?: string;
45
+ userName?: string;
46
+ userContext?: UserContext | null;
47
+ requestInfo?: RequestInfo | null;
48
+ pageMetadata?: PageFrontmatter | null;
49
+ [key: string]: unknown;
50
+ }
51
+ /**
52
+ * WikiEngine minimal interface (until WikiEngine.ts is fully typed)
53
+ * TODO: Replace with proper WikiEngine import once converted
54
+ */
55
+ export interface WikiEngine {
56
+ getManager<T = unknown>(name: string): T | undefined;
57
+ }
58
+ /**
59
+ * Minimal WikiContext interface for the parser side (#629).
60
+ *
61
+ * ParseContext holds a reference to its parent WikiContext so user/page-data
62
+ * fields don't have to be copied. We define a structural interface here rather
63
+ * than importing the full WikiContext class to avoid coupling the parser
64
+ * package to context internals (and to side-step circular imports).
65
+ *
66
+ * Only the fields/methods ParseContext needs to delegate are listed.
67
+ */
68
+ export interface WikiContextLike {
69
+ readonly engine: WikiEngine;
70
+ readonly pageName: string | null;
71
+ readonly userContext: UserContext | null;
72
+ readonly pageMetadata: PageFrontmatter | null;
73
+ hasPermission(action: string): Promise<boolean>;
74
+ canAccess(action: string): Promise<boolean>;
75
+ /** The non-recording affordance for display gates (#1668) — see WikiContext.mayShow. */
76
+ mayShow(action: string): Promise<boolean>;
77
+ getPrincipals(): string[];
78
+ }
79
+ /**
80
+ * Nested context structure (from WikiContext.toParseOptions())
81
+ */
82
+ export interface NestedContextOptions {
83
+ pageContext: PageContext;
84
+ engine?: WikiEngine;
85
+ /**
86
+ * #629: optional reference to the parent WikiContext. When provided,
87
+ * ParseContext getters delegate user/page-data lookups to it instead of
88
+ * the constructor-time snapshot in `pageContext`. Lets the WikiContext
89
+ * stay the single source of truth across the parse run.
90
+ */
91
+ wikiContext?: WikiContextLike;
92
+ }
93
+ /**
94
+ * Direct context structure (legacy or alternative calling pattern)
95
+ */
96
+ export type DirectContextOptions = PageContext;
97
+ /**
98
+ * Combined context options
99
+ */
100
+ export type ParseContextOptions = NestedContextOptions | DirectContextOptions;
101
+ /**
102
+ * Context summary for logging
103
+ */
104
+ export interface ContextSummary {
105
+ pageName: string;
106
+ userName: string;
107
+ authenticated: boolean;
108
+ roles: string[];
109
+ contentLength: number;
110
+ variableCount: number;
111
+ handlerResultCount: number;
112
+ processingTime: number;
113
+ phaseCount: number;
114
+ }
115
+ /**
116
+ * Error context for debugging
117
+ */
118
+ export interface ParseErrorContext {
119
+ error: string;
120
+ phase: string;
121
+ pageName: string;
122
+ userName: string;
123
+ processingTime: number;
124
+ contentLength: number;
125
+ timestamp: string;
126
+ }
127
+ /**
128
+ * Exported user context for caching
129
+ */
130
+ export interface ExportedUserContext {
131
+ isAuthenticated: boolean;
132
+ roles: string[];
133
+ permissions: string[];
134
+ }
135
+ /**
136
+ * Cached context data
137
+ */
138
+ export interface CachedContextData {
139
+ pageName: string;
140
+ userName: string;
141
+ userContext: ExportedUserContext | null;
142
+ variables: Record<string, unknown>;
143
+ metadata: Record<string, unknown>;
144
+ timestamp: number;
145
+ }
146
+ /**
147
+ * ParseContext - Context object for markup parsing operations
148
+ *
149
+ * #629 Pass 2: holds a non-nullable reference to a WikiContextLike. For HTTP
150
+ * requests this is the actual WikiContext (passed through toParseOptions);
151
+ * for tests / direct construction it's a synthesized stub from the supplied
152
+ * PageContext. Consumers should always read user/page-data via
153
+ * `parseContext.wikiContext.X` — the duplicating getters from Pass 1
154
+ * (pageName / userContext / pageMetadata) have been removed.
155
+ *
156
+ * Helpers that derive (not duplicate) from wikiContext are still here:
157
+ * userName, isAuthenticated, getUserRoles.
158
+ */
159
+ declare class ParseContext {
160
+ readonly originalContent: string;
161
+ readonly pageContext: PageContext;
162
+ readonly engine: WikiEngine;
163
+ /**
164
+ * Reference to the parent WikiContext (#629). Always non-null after
165
+ * construction — for callers without a real WikiContext, a stub is
166
+ * synthesized from the PageContext snapshot.
167
+ */
168
+ readonly wikiContext: WikiContextLike;
169
+ /**
170
+ * Request info. Built from request headers by toParseOptions; not
171
+ * duplicated from wikiContext (the stub lacks the headers anyway).
172
+ * Static after construction.
173
+ */
174
+ readonly requestInfo: RequestInfo | null;
175
+ /**
176
+ * The private titles this reader can see in the page owner's stores, by
177
+ * store id (#1457) — what a `[store/Title]` link on a PRIVATE page is
178
+ * resolved against, so the owner of a page that is not there gets a red
179
+ * link to its editor.
180
+ *
181
+ * `null` when the question does not arise: a public page, whose HTML is
182
+ * cached and shared by role and so has one appearance for everyone, or a
183
+ * page with no such link in it. A store that is ABSENT from the map is one
184
+ * this reader cannot open — not one without the page.
185
+ *
186
+ * Resolved once per parse by MarkupParser, never per link.
187
+ */
188
+ privateLinkTitles: Map<string, Set<string>> | null;
189
+ /**
190
+ * Hand finished HTML from a syntax handler to MarkupParser; write the
191
+ * returned placeholder into the content instead (#1623). The HTML is merged
192
+ * after markdown-it, so it is not mistaken for HTML the author typed and
193
+ * held to the author HTML policy. `null` outside a MarkupParser parse.
194
+ */
195
+ protectHtml: ((html: string) => string) | null;
196
+ protectedBlocks: unknown[];
197
+ syntaxTokens: unknown[];
198
+ variables: Map<string, unknown>;
199
+ handlerResults: Map<string, unknown>;
200
+ metadata: Record<string, unknown>;
201
+ /**
202
+ * #1751: the page cache's record of what this render reads. Plugins reach it
203
+ * through `context.dependsOn(topic)` (PluginManager.execute). Null when the
204
+ * page is not being cached.
205
+ */
206
+ readonly cacheDependencies: CacheDependencies | null;
207
+ private startTime;
208
+ private phaseTimings;
209
+ constructor(content: string, context: ParseContextOptions, engine: WikiEngine);
210
+ /**
211
+ * Caller's username — derivation helper over `wikiContext.userContext`.
212
+ * Returns 'anonymous' when no userContext is bound.
213
+ */
214
+ get userName(): string;
215
+ /**
216
+ * Get manager instance from engine
217
+ * @param managerName - Name of manager to retrieve
218
+ * @returns Manager instance or null
219
+ */
220
+ getManager(managerName: string): unknown;
221
+ /**
222
+ * Check if user is authenticated — derivation helper over `wikiContext.userContext`.
223
+ */
224
+ isAuthenticated(): boolean;
225
+ /**
226
+ * Get user roles — derivation helper over `wikiContext.userContext`.
227
+ */
228
+ getUserRoles(): string[];
229
+ /**
230
+ * Set variable value
231
+ * @param name - Variable name
232
+ * @param value - Variable value
233
+ */
234
+ setVariable(name: string, value: unknown): void;
235
+ /**
236
+ * Get variable value
237
+ * @param name - Variable name
238
+ * @param defaultValue - Default value if not found
239
+ * @returns Variable value
240
+ */
241
+ getVariable(name: string, defaultValue?: unknown): unknown;
242
+ /**
243
+ * Store handler result
244
+ * @param handlerId - Handler identifier
245
+ * @param result - Handler result
246
+ */
247
+ setHandlerResult(handlerId: string, result: unknown): void;
248
+ /**
249
+ * Get handler result
250
+ * @param handlerId - Handler identifier
251
+ * @returns Handler result or null
252
+ */
253
+ getHandlerResult(handlerId: string): unknown;
254
+ /**
255
+ * Set metadata value
256
+ * @param key - Metadata key
257
+ * @param value - Metadata value
258
+ */
259
+ setMetadata(key: string, value: unknown): void;
260
+ /**
261
+ * Get metadata value
262
+ * @param key - Metadata key
263
+ * @param defaultValue - Default value if not found
264
+ * @returns Metadata value
265
+ */
266
+ getMetadata(key: string, defaultValue?: unknown): unknown;
267
+ /**
268
+ * Record phase timing
269
+ * @param phaseName - Name of phase
270
+ * @param duration - Duration in milliseconds
271
+ */
272
+ recordPhaseTiming(phaseName: string, duration: number): void;
273
+ /**
274
+ * Get phase timing
275
+ * @param phaseName - Name of phase
276
+ * @returns Duration in milliseconds or 0
277
+ */
278
+ getPhaseTiming(phaseName: string): number;
279
+ /**
280
+ * Get total processing time
281
+ * @returns Total time in milliseconds
282
+ */
283
+ getTotalTime(): number;
284
+ /**
285
+ * Clone context for sub-processing
286
+ * @param overrides - Properties to override
287
+ * @returns New context instance
288
+ */
289
+ clone(overrides?: Partial<PageContext>): ParseContext;
290
+ /**
291
+ * Create error context for debugging
292
+ * @param error - Error that occurred
293
+ * @param phase - Phase where error occurred
294
+ * @returns Error context
295
+ */
296
+ createErrorContext(error: Error, phase: string): ParseErrorContext;
297
+ /**
298
+ * Get context summary for logging
299
+ * @returns Context summary
300
+ */
301
+ getSummary(): ContextSummary;
302
+ /**
303
+ * Export context data for caching
304
+ * @returns Serializable context data
305
+ */
306
+ exportForCache(): CachedContextData;
307
+ /**
308
+ * Import context data from cache
309
+ * @param data - Cached context data
310
+ */
311
+ importFromCache(data: CachedContextData): void;
312
+ }
313
+ export { ParseContext };
314
+ export default ParseContext;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Emoji shortcode map for MarkupParser Step 0.7 (Issue #512)
3
+ *
4
+ * Keys are shortcode names (without colons).
5
+ * Values are Unicode emoji characters — no image assets needed.
6
+ * Shortcode names follow the de-facto standard used by GitHub, Slack, and Twemoji.
7
+ *
8
+ * To add emojis: extend EMOJI_MAP here AND add matching entries to
9
+ * EMOJI_CLIENT_DATA in public/js/emoji-autocomplete.js (client-side picker).
10
+ */
11
+ export declare const EMOJI_MAP: Readonly<Record<string, string>>;
12
+ /** Regex matching :shortcode: patterns — used by convertEmojiShortcodes */
13
+ export declare const EMOJI_SHORTCODE_REGEX: RegExp;
14
+ /**
15
+ * Replace all :shortcode: occurrences in text with their Unicode emoji.
16
+ * Unknown shortcodes are left unchanged.
17
+ */
18
+ export declare function convertEmojiShortcodes(text: string): string;
@@ -0,0 +1,210 @@
1
+ import { TokenType } from './Tokenizer.js';
2
+ import WikiDocument from './WikiDocument.js';
3
+ /**
4
+ * DOMBuilder - Converts tokens into a WikiDocument DOM tree
5
+ *
6
+ * ============================================================================
7
+ * ARCHITECTURE NOTE (Phase 4, Issue #118):
8
+ * ============================================================================
9
+ *
10
+ * **This DOMBuilder is a REFERENCE IMPLEMENTATION and is NOT actively used
11
+ * in the current rendering pipeline.**
12
+ *
13
+ * This builder converts tokens from the Tokenizer into a WikiDocument DOM.
14
+ * It was part of the Phase 0 tokenization-based parsing approach, which has
15
+ * been superseded by the extraction-based approach in Phases 1-3.
16
+ *
17
+ * CURRENT ACTIVE APPROACH:
18
+ * ------------------------
19
+ * DOM nodes are now created directly from extracted elements using:
20
+ * - DOMVariableHandler.createNodeFromExtract()
21
+ * - DOMPluginHandler.createNodeFromExtract()
22
+ * - DOMLinkHandler.createNodeFromExtract()
23
+ * - MarkupParser.createTextNodeForEscaped()
24
+ *
25
+ * These methods create DOM nodes directly without going through tokenization.
26
+ *
27
+ * WHY THIS DOMBUILDER IS KEPT:
28
+ * ----------------------------
29
+ * - Reference for token-to-DOM conversion patterns
30
+ * - Understanding of DOM tree construction
31
+ * - May be useful for future enhancements
32
+ * - Educational value
33
+ *
34
+ * SEE ALSO:
35
+ * - Tokenizer.js - Detailed architecture notes
36
+ * - DOMParser.js - Pipeline documentation
37
+ * - MarkupParser.parseWithDOMExtraction() - Current active pipeline
38
+ * - Issue #114 - WikiDocument DOM Solution
39
+ * - Issue #118 - Architecture documentation (this change)
40
+ *
41
+ * ============================================================================
42
+ *
43
+ * ORIGINAL DESCRIPTION:
44
+ * Takes an array of tokens from the Tokenizer and builds a structured
45
+ * DOM tree in a WikiDocument. Handles nesting, formatting, and all
46
+ * JSPWiki-compatible markup elements.
47
+ *
48
+ * Key Features:
49
+ * - Converts tokens to DOM nodes
50
+ * - Handles nested structures (lists, tables)
51
+ * - Manages formatting contexts (bold, italic)
52
+ * - Creates semantic HTML elements
53
+ *
54
+ * Part of Phase 2.4 of WikiDocument DOM Migration (GitHub Issue #93)
55
+ */
56
+ /**
57
+ * Token metadata interface
58
+ */
59
+ export interface TokenMetadata {
60
+ /** Heading level (for headings) */
61
+ level?: number;
62
+ /** Variable name (for variables) */
63
+ varName?: string;
64
+ /** Link target (for links) */
65
+ link?: string;
66
+ /** Link text (for links) */
67
+ text?: string;
68
+ /** Whether list is ordered (for lists) */
69
+ ordered?: boolean;
70
+ /** Additional metadata properties */
71
+ [key: string]: unknown;
72
+ }
73
+ /**
74
+ * Token interface
75
+ */
76
+ export interface Token {
77
+ /** Token type - can be TokenType enum or string for extensibility */
78
+ type: TokenType | string;
79
+ /** Token value */
80
+ value: string;
81
+ /** Token metadata */
82
+ metadata?: TokenMetadata;
83
+ /** Line number */
84
+ line?: number;
85
+ /** Column number */
86
+ column?: number;
87
+ /** Additional properties */
88
+ [key: string]: unknown;
89
+ }
90
+ /**
91
+ * DOMBuilder class
92
+ */
93
+ declare class DOMBuilder {
94
+ /** Target WikiDocument */
95
+ private wikiDocument;
96
+ /** Current parent element */
97
+ private currentParent;
98
+ /** Stack of nested lists */
99
+ private listStack;
100
+ /** Current table context */
101
+ private tableContext;
102
+ /** Current paragraph context */
103
+ private paragraphContext;
104
+ /**
105
+ * Creates a new DOMBuilder
106
+ *
107
+ * @param wikiDocument - Target WikiDocument
108
+ */
109
+ constructor(wikiDocument: WikiDocument);
110
+ /**
111
+ * Builds a DOM tree from an array of tokens
112
+ *
113
+ * @param tokens - Array of tokens from Tokenizer
114
+ * @returns The WikiDocument with built DOM
115
+ */
116
+ buildFromTokens(tokens: Token[]): WikiDocument;
117
+ /**
118
+ * Processes a single token
119
+ *
120
+ * @param token - Token to process
121
+ */
122
+ processToken(token: Token): void;
123
+ /**
124
+ * Handles plain text tokens
125
+ */
126
+ handleText(token: Token): void;
127
+ /**
128
+ * Handles escaped text [[...]]
129
+ * This is literal text that should not be parsed
130
+ */
131
+ handleEscaped(token: Token): void;
132
+ /**
133
+ * Handles variables {$varname}
134
+ */
135
+ handleVariable(token: Token): void;
136
+ /**
137
+ * Handles plugins [{PLUGIN ...}]
138
+ * Creates inline span element to allow plugins within paragraphs
139
+ */
140
+ handlePlugin(token: Token): void;
141
+ /**
142
+ * Handles wiki tags [tag]
143
+ */
144
+ handleWikiTag(token: Token): void;
145
+ /**
146
+ * Handles links [link|text]
147
+ */
148
+ handleLink(token: Token): void;
149
+ /**
150
+ * Handles interwiki links [Wiki:Page]
151
+ */
152
+ handleInterWiki(token: Token): void;
153
+ /**
154
+ * Handles headings !, !!, !!!
155
+ */
156
+ handleHeading(token: Token): void;
157
+ /**
158
+ * Handles list items *, #
159
+ */
160
+ handleListItem(token: Token): void;
161
+ /**
162
+ * Handles table cells | cell |
163
+ */
164
+ handleTableCell(token: Token): void;
165
+ /**
166
+ * Handles bold text __text__
167
+ */
168
+ handleBold(token: Token): void;
169
+ /**
170
+ * Handles italic text ''text''
171
+ */
172
+ handleItalic(token: Token): void;
173
+ /**
174
+ * Handles inline code {{text}}
175
+ */
176
+ handleCodeInline(token: Token): void;
177
+ /**
178
+ * Handles code blocks {{{code}}}
179
+ */
180
+ handleCodeBlock(token: Token): void;
181
+ /**
182
+ * Handles HTML comments <!-- comment -->
183
+ */
184
+ handleComment(token: Token): void;
185
+ /**
186
+ * Handles newlines
187
+ */
188
+ handleNewline(_token: Token): void;
189
+ /**
190
+ * Ensures a paragraph context exists for inline content
191
+ */
192
+ ensureParagraph(): void;
193
+ /**
194
+ * Closes the current paragraph context
195
+ */
196
+ closeCurrentParagraph(): void;
197
+ /**
198
+ * Adjusts the list stack to match the desired level
199
+ */
200
+ adjustListStack(targetLevel: number, isOrdered: boolean): void;
201
+ /**
202
+ * Closes all open lists
203
+ */
204
+ closeAllLists(): void;
205
+ /**
206
+ * Closes the current table context
207
+ */
208
+ closeCurrentTable(): void;
209
+ }
210
+ export default DOMBuilder;