@jwilleke/ngdpbase-types 0.0.0 → 5.19.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 (304) 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 +427 -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 +188 -0
  71. package/lib/src/managers/DatabaseManager.js +590 -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/sqliteBackup.d.ts +128 -0
  158. package/lib/src/providers/sqliteBackup.js +365 -0
  159. package/lib/src/providers/sqliteLocation.d.ts +17 -0
  160. package/lib/src/providers/sqliteLocation.js +55 -0
  161. package/lib/src/providers/sqliteMigrations.d.ts +48 -0
  162. package/lib/src/providers/sqliteMigrations.js +72 -0
  163. package/lib/src/rendering/githubAlerts.d.ts +22 -0
  164. package/lib/src/rendering/htmlPolicy.d.ts +76 -0
  165. package/lib/src/rendering/markdownConverter.d.ts +73 -0
  166. package/lib/src/security/PolicyDecisionPoint.d.ts +245 -0
  167. package/lib/src/security/PolicyInformationPoint.d.ts +448 -0
  168. package/lib/src/security/pageActions.d.ts +40 -0
  169. package/lib/src/security/permissions.generated.d.ts +78 -0
  170. package/lib/src/types/Asset.d.ts +414 -0
  171. package/lib/src/types/Catalog.d.ts +61 -0
  172. package/lib/src/types/Comment.d.ts +11 -0
  173. package/lib/src/types/Config.d.ts +388 -0
  174. package/lib/src/types/Organization.d.ts +78 -0
  175. package/lib/src/types/OrganizationProvider.d.ts +38 -0
  176. package/lib/src/types/Page.d.ts +220 -0
  177. package/lib/src/types/Person.d.ts +56 -0
  178. package/lib/src/types/PersonProvider.d.ts +25 -0
  179. package/lib/src/types/Policy.d.ts +139 -0
  180. package/lib/src/types/Policy.js +17 -0
  181. package/lib/src/types/Provider.d.ts +810 -0
  182. package/lib/src/types/Role.d.ts +84 -0
  183. package/lib/src/types/RoleProvider.d.ts +35 -0
  184. package/lib/src/types/Schema.d.ts +425 -0
  185. package/lib/src/types/Share.d.ts +172 -0
  186. package/lib/src/types/Share.js +81 -0
  187. package/lib/src/types/User.d.ts +304 -0
  188. package/lib/src/types/Version.d.ts +189 -0
  189. package/lib/src/types/WikiEngine.d.ts +128 -0
  190. package/lib/src/types/express.d.ts +120 -0
  191. package/lib/src/types/express.js +1 -0
  192. package/lib/src/types/guards.d.ts +78 -0
  193. package/lib/src/types/heic-decode.d.ts +16 -0
  194. package/lib/src/types/index.d.ts +19 -0
  195. package/lib/src/types/linkedom.d.ts +77 -0
  196. package/lib/src/types/markdown-it-plugins.d.ts +21 -0
  197. package/lib/src/utils/DeltaStorage.d.ts +118 -0
  198. package/lib/src/utils/LocaleUtils.d.ts +105 -0
  199. package/lib/src/utils/LocaleUtils.js +294 -0
  200. package/lib/src/utils/PageNameMatcher.d.ts +98 -0
  201. package/lib/src/utils/PathPreflight.d.ts +38 -0
  202. package/lib/src/utils/PathPreflight.js +50 -0
  203. package/lib/src/utils/SectionUtils.d.ts +40 -0
  204. package/lib/src/utils/addonConfigLayer.d.ts +144 -0
  205. package/lib/src/utils/addonConfigLayer.js +382 -0
  206. package/lib/src/utils/addonDatabaseRules.d.ts +25 -0
  207. package/lib/src/utils/addonDatabaseRules.js +57 -0
  208. package/lib/src/utils/addonHost.d.ts +51 -0
  209. package/lib/src/utils/addonHost.js +72 -0
  210. package/lib/src/utils/addonInstaller.d.ts +109 -0
  211. package/lib/src/utils/addonLock.d.ts +37 -0
  212. package/lib/src/utils/addonLock.js +48 -0
  213. package/lib/src/utils/addonPageSync.d.ts +45 -0
  214. package/lib/src/utils/addonProvenance.d.ts +48 -0
  215. package/lib/src/utils/addonTarball.d.ts +41 -0
  216. package/lib/src/utils/addonsPathResolver.d.ts +76 -0
  217. package/lib/src/utils/addonsPathResolver.js +129 -0
  218. package/lib/src/utils/assetMetadataTags.d.ts +66 -0
  219. package/lib/src/utils/atomicWrite.d.ts +28 -0
  220. package/lib/src/utils/auditConfigChange.d.ts +57 -0
  221. package/lib/src/utils/auditEventNames.d.ts +50 -0
  222. package/lib/src/utils/auditEventNames.generated.d.ts +169 -0
  223. package/lib/src/utils/auditEventNames.generated.js +174 -0
  224. package/lib/src/utils/auditEventNames.js +49 -0
  225. package/lib/src/utils/auditEvents.d.ts +265 -0
  226. package/lib/src/utils/auditEvents.js +309 -0
  227. package/lib/src/utils/auditRegistry.d.ts +102 -0
  228. package/lib/src/utils/auditRegistry.js +168 -0
  229. package/lib/src/utils/bip39English.d.ts +2 -0
  230. package/lib/src/utils/configEnvKeys.d.ts +68 -0
  231. package/lib/src/utils/configFiles.d.ts +74 -0
  232. package/lib/src/utils/configFiles.js +150 -0
  233. package/lib/src/utils/delegation.d.ts +48 -0
  234. package/lib/src/utils/deriveUsername.d.ts +21 -0
  235. package/lib/src/utils/explainMediaPath.d.ts +123 -0
  236. package/lib/src/utils/formerTitles.d.ts +69 -0
  237. package/lib/src/utils/frontmatterAccess.d.ts +54 -0
  238. package/lib/src/utils/headlessAdminPassword.d.ts +55 -0
  239. package/lib/src/utils/imageTransform.d.ts +52 -0
  240. package/lib/src/utils/instanceEnvSecret.d.ts +51 -0
  241. package/lib/src/utils/jobSlots.d.ts +43 -0
  242. package/lib/src/utils/keywordNormalizer.d.ts +127 -0
  243. package/lib/src/utils/logger.d.ts +70 -0
  244. package/lib/src/utils/logger.js +106 -0
  245. package/lib/src/utils/magicLinkDeviceState.d.ts +95 -0
  246. package/lib/src/utils/managerUtils.d.ts +40 -0
  247. package/lib/src/utils/migrateLegacyPrivateAttachments.d.ts +15 -0
  248. package/lib/src/utils/orgFilename.d.ts +22 -0
  249. package/lib/src/utils/pageFeature.d.ts +27 -0
  250. package/lib/src/utils/pageFrontmatter.d.ts +21 -0
  251. package/lib/src/utils/pageNotes.d.ts +150 -0
  252. package/lib/src/utils/pageTitleRule.d.ts +37 -0
  253. package/lib/src/utils/pageToArticle.d.ts +59 -0
  254. package/lib/src/utils/pageUrl.d.ts +18 -0
  255. package/lib/src/utils/passwordChange.d.ts +12 -0
  256. package/lib/src/utils/passwordHash.d.ts +60 -0
  257. package/lib/src/utils/permissionCatalog.d.ts +52 -0
  258. package/lib/src/utils/pluginFormatters.d.ts +452 -0
  259. package/lib/src/utils/pluginFormatters.js +714 -0
  260. package/lib/src/utils/privateLinkRewrite.d.ts +42 -0
  261. package/lib/src/utils/privateStoreAccess.d.ts +57 -0
  262. package/lib/src/utils/privateStoreAccess.js +65 -0
  263. package/lib/src/utils/privateStoreCatalogs.d.ts +40 -0
  264. package/lib/src/utils/privateStoreCrypto.d.ts +127 -0
  265. package/lib/src/utils/privateStoreDoor.d.ts +181 -0
  266. package/lib/src/utils/privateStoreExport.d.ts +72 -0
  267. package/lib/src/utils/privateStoreFiles.d.ts +120 -0
  268. package/lib/src/utils/privateStoreMeta.d.ts +64 -0
  269. package/lib/src/utils/privateStoreMigrations.d.ts +37 -0
  270. package/lib/src/utils/privateStorePath.d.ts +259 -0
  271. package/lib/src/utils/privateStorePath.js +436 -0
  272. package/lib/src/utils/privateStoreTakeout.d.ts +76 -0
  273. package/lib/src/utils/privateStoreUnlock.d.ts +175 -0
  274. package/lib/src/utils/proxyClaim.d.ts +59 -0
  275. package/lib/src/utils/proxyClaim.js +30 -0
  276. package/lib/src/utils/redactPrivateNames.d.ts +21 -0
  277. package/lib/src/utils/redactPrivateNames.js +89 -0
  278. package/lib/src/utils/redactSecrets.d.ts +58 -0
  279. package/lib/src/utils/redactSecrets.js +171 -0
  280. package/lib/src/utils/renameLinkRewrite.d.ts +112 -0
  281. package/lib/src/utils/roleGrants.d.ts +35 -0
  282. package/lib/src/utils/safeRedirect.d.ts +32 -0
  283. package/lib/src/utils/schedule.d.ts +54 -0
  284. package/lib/src/utils/secretFileMode.d.ts +17 -0
  285. package/lib/src/utils/seededShippedPages.d.ts +45 -0
  286. package/lib/src/utils/sensitiveValues.d.ts +59 -0
  287. package/lib/src/utils/sensitiveValues.js +106 -0
  288. package/lib/src/utils/sessionEnd.d.ts +12 -0
  289. package/lib/src/utils/sessionGeneration.d.ts +24 -0
  290. package/lib/src/utils/sessionIdle.d.ts +41 -0
  291. package/lib/src/utils/sessionLimits.d.ts +68 -0
  292. package/lib/src/utils/shareLockbox.d.ts +64 -0
  293. package/lib/src/utils/sigstoreTrustedRoot.d.ts +33 -0
  294. package/lib/src/utils/sniffMime.d.ts +21 -0
  295. package/lib/src/utils/storeSearchIndex.d.ts +75 -0
  296. package/lib/src/utils/subjectMayDo.d.ts +21 -0
  297. package/lib/src/utils/systemCategoryRules.d.ts +30 -0
  298. package/lib/src/utils/systemCategoryRules.js +41 -0
  299. package/lib/src/utils/userCreateError.d.ts +62 -0
  300. package/lib/src/utils/username.d.ts +53 -0
  301. package/lib/src/utils/vaultUrlRewrite.d.ts +27 -0
  302. package/lib/src/utils/version.d.ts +84 -0
  303. package/lib/src/utils/videoFrame.d.ts +21 -0
  304. package/package.json +54 -3
@@ -0,0 +1,279 @@
1
+ /**
2
+ * MediaManager - Manages external media files (photos, videos, etc.)
3
+ *
4
+ * Provides browsing, searching, and thumbnail access for pre-existing
5
+ * media files stored on external drives. Unlike AttachmentManager, this
6
+ * manager is read-only with respect to source files and is independent
7
+ * of wiki pages. A page's media are the items whose EXIF/XMP keywords name
8
+ * it — there is no other link, and no per-item privacy: any subject that
9
+ * reaches this manager sees every item, except that a share visitor is held
10
+ * to the share's ceiling in {@link getItem} (#1427).
11
+ *
12
+ * STUB: Actual filesystem scanning is not yet wired up (Phase 4).
13
+ * The manager compiles and registers cleanly; all index queries return
14
+ * empty results until a real FileSystemMediaProvider scan is implemented.
15
+ *
16
+ * Enabled via config: ngdpbase.media.enabled = true
17
+ *
18
+ * @class MediaManager
19
+ * @extends BaseManager
20
+ */
21
+ import BaseManager from './BaseManager.js';
22
+ import type { WikiEngine } from '../types/WikiEngine.js';
23
+ import WikiContext from '../context/WikiContext.js';
24
+ import BaseMediaProvider, { MediaItem, ScanResult } from '../providers/BaseMediaProvider.js';
25
+ import type { CatalogSource, CatalogQuery, CatalogPage, CreativeWork, SchemaType, RebuildOpts } from '../types/Schema.js';
26
+ declare class MediaManager extends BaseManager implements CatalogSource {
27
+ /** CatalogSource identifier (Slice 3 of #755 / #758). */
28
+ readonly sourceId = "media";
29
+ /** Subtypes this source produces — MIME-discriminated at item level. */
30
+ readonly types: readonly SchemaType[];
31
+ /**
32
+ * On-disk schema version for media-index.json (Decision 6).
33
+ * Bump when the persisted MediaIndexEntry shape changes; current v1 is
34
+ * the post-Slice-3 (#758) shape including duration/bitrate/codecs.
35
+ */
36
+ static readonly CURRENT_SCHEMA_VERSION = 1;
37
+ readonly currentSchemaVersion = 1;
38
+ /** Active media provider (null when not yet initialized) */
39
+ private _provider;
40
+ /** The configured media folders, for the degraded-state reason (#1167). */
41
+ private mediaFolders;
42
+ /** Return the active media provider for use by AssetManager. */
43
+ get provider(): BaseMediaProvider | null;
44
+ /** Thumbnail (and transcode) cache directory */
45
+ private _thumbnailDir;
46
+ /** Handle for the periodic rescan interval timer */
47
+ constructor(engine: WikiEngine);
48
+ /**
49
+ * Initialize the MediaManager.
50
+ *
51
+ * - Creates the thumbnail directory if it does not exist.
52
+ * - Instantiates the FileSystemMediaProvider with config-driven settings.
53
+ * - Loads any existing media-index.json from disk (stub: no-op).
54
+ * - Schedules a periodic background rescan based on ngdpbase.media.scaninterval.
55
+ *
56
+ * @param config - Configuration overrides (passed by BaseManager pattern).
57
+ */
58
+ initialize(config?: Record<string, unknown>): Promise<void>;
59
+ /**
60
+ * CatalogSource.list — query media records and emit CreativeWork shapes.
61
+ *
62
+ * Currently maps `query.text` to the underlying provider's free-text search
63
+ * and applies `types` filtering MIME-side. Cursor pagination is not yet
64
+ * implemented (initial slice); `limit` caps the page size. Source-specific
65
+ * filters live in `query.filters` and are ignored by this initial impl.
66
+ */
67
+ list(query: CatalogQuery): Promise<CatalogPage>;
68
+ /**
69
+ * CatalogSource.get — fetch a single media record by stable identifier
70
+ * (the sha256-derived media id). Returns null for not-found and for
71
+ * ACL-filtered (linked private page the caller can't access).
72
+ *
73
+ * CatalogManager passes through any `WikiContext` it has via a future
74
+ * `opts.wikiContext`; for the initial slice we accept no context and
75
+ * therefore can't enforce private-page ACL here — callers that need
76
+ * permission-aware access should continue using `getItem(id, ctx)`.
77
+ */
78
+ get(identifier: string): Promise<CreativeWork | null>;
79
+ /**
80
+ * CatalogSource.rebuild — full media index rebuild. Wraps `rebuildIndex()`
81
+ * so the CatalogSource contract is honoured even though MediaManager's
82
+ * existing admin route prefers the named method.
83
+ */
84
+ rebuild(_opts?: RebuildOpts): Promise<void>;
85
+ /**
86
+ * Every media-index write goes through here (#1751): it writes, then bumps
87
+ * the media-data version, so cached renders that show media re-render.
88
+ */
89
+ private writeMedia;
90
+ /**
91
+ * Rebuild the media index from scratch.
92
+ *
93
+ * Clears the in-memory index, deletes the persisted index file, then runs a
94
+ * full scan. All items on disk are re-indexed; stale entries for deleted
95
+ * files are removed because the index starts empty.
96
+ *
97
+ * @returns ScanResult summary.
98
+ */
99
+ rebuildIndex(onProgress?: (processed: number, total: number) => void): Promise<ScanResult>;
100
+ /**
101
+ * Degraded while any configured media folder cannot be read, ready otherwise (#1167).
102
+ *
103
+ * Degraded rather than a warning, even for one folder in fourteen: the
104
+ * operator asked for those files to be indexed and they are not, which is
105
+ * what degraded means (#1155) — configured, wanted, not working.
106
+ */
107
+ private recordFolderState;
108
+ /**
109
+ * Surface scan/rebuild anomalies to admins via /admin/notifications and the
110
+ * server log (#807). Missing folders, capture-date gaps, and processing
111
+ * errors otherwise pass silently — admins only see them if they read the log.
112
+ *
113
+ * One summary notification per category (not per file) to avoid flooding the
114
+ * notification centre on a large library.
115
+ *
116
+ * @param result - The ScanResult returned by the provider.
117
+ * @param label - "Scan" or "Rebuild", for notification wording.
118
+ */
119
+ private surfaceScanNotifications;
120
+ /**
121
+ * Trigger a media folder scan.
122
+ *
123
+ * STUB: Delegates to FileSystemMediaProvider.scan() which logs a warning and
124
+ * returns an empty ScanResult. Real implementation comes in Phase 4.
125
+ *
126
+ * @param force - Pass true to force a full rescan ignoring cached mtimes.
127
+ * @returns ScanResult summary.
128
+ */
129
+ scanFolders(force?: boolean, onProgress?: (processed: number, total: number) => void): Promise<ScanResult>;
130
+ /**
131
+ * Retrieve a single media item, held to a share visitor's ceiling.
132
+ *
133
+ * With a WikiContext whose subject arrived through a share, the item must
134
+ * be covered by that share (PolicyInformationPoint.canUserAccessMediaItem);
135
+ * a refusal returns null, treated as not found.
136
+ *
137
+ * @param id - Item identifier.
138
+ * @param wikiContext - Caller's WikiContext (pass undefined for admin/internal calls).
139
+ * @returns The MediaItem or null.
140
+ */
141
+ getItem(id: string, wikiContext?: WikiContext): Promise<MediaItem | null>;
142
+ /**
143
+ * Update user-editable metadata (title, description, keywords,
144
+ * dateTimeOriginal) on a media item. Writes into the source file's
145
+ * EXIF/IPTC/XMP and refreshes the index entry.
146
+ *
147
+ * Caller is responsible for the asset-edit permission check; this method
148
+ * only enforces provider capability.
149
+ *
150
+ * @param id - Item identifier.
151
+ * @param patch - Fields to change (absent = keep, null = clear).
152
+ * @returns The refreshed MediaItem, or null if the id is unknown (or the
153
+ * edit evicted the item, e.g. an ngdpbaseignore keyword).
154
+ * @throws Error when the provider lacks the 'edit' capability, the patch is
155
+ * invalid, or the underlying write fails.
156
+ */
157
+ updateItemMetadata(id: string, patch: import('../types/Asset.js').AssetMetadataPatch): Promise<MediaItem | null>;
158
+ /**
159
+ * Explain why one absolute path is, or is not, in the media index (#848).
160
+ *
161
+ * Admin-only diagnostic for "why isn't my file showing?" — #814 reported
162
+ * media as undiscovered when in fact every missing file was correctly
163
+ * skipped by a rule that leaves no visible trace.
164
+ *
165
+ * Returns null when the configured provider cannot answer, rather than
166
+ * inventing a verdict: a different provider has different rules, and a
167
+ * confident wrong answer here sends the operator to fix the wrong thing.
168
+ */
169
+ explainPath(target: string): Promise<import('../utils/explainMediaPath.js').MediaPathExplanation | null>;
170
+ /**
171
+ * The skip report from the most recent scan (#1056).
172
+ *
173
+ * Answers "where did my file go?" across the whole library, where
174
+ * {@link explainPath} answers it for one path the operator can already name.
175
+ * Both exist because an operator who cannot find a file often cannot state
176
+ * its path either.
177
+ *
178
+ * Null when the provider keeps no report — the same reasoning as
179
+ * `explainPath`: a different provider skips for different reasons, and an
180
+ * empty report would be read as "nothing was skipped".
181
+ */
182
+ getSkipReport(): Promise<import('../utils/explainMediaPath.js').MediaSkipReport | null>;
183
+ /**
184
+ * List all media items for a given year.
185
+ *
186
+ * @param year - Four-digit year.
187
+ * @returns Array of MediaItem objects.
188
+ */
189
+ listByYear(year: number): Promise<MediaItem[]>;
190
+ /**
191
+ * How many items the year listing covers (#1741) — the number
192
+ * `getYears()` + `listByYear()` add up to, without listing them.
193
+ */
194
+ count(): Promise<number>;
195
+ /**
196
+ * List media items whose capture timestamp falls within [after, before],
197
+ * ascending by capture date (#864 — Dawarich adapter). Items without a
198
+ * capture date are excluded by the provider.
199
+ *
200
+ * @param after - Inclusive lower bound (ISO-ish string), optional.
201
+ * @param before - Inclusive upper bound (ISO-ish string), optional.
202
+ */
203
+ listByDateRange(after?: string, before?: string): Promise<MediaItem[]>;
204
+ /**
205
+ * List all media items whose EXIF/XMP keywords name a wiki page.
206
+ *
207
+ * @param pageName - Wiki page name to match against each item's keywords.
208
+ * @returns Array of MediaItem objects.
209
+ */
210
+ listByPage(pageName: string): Promise<MediaItem[]>;
211
+ /**
212
+ * List all media items whose EXIF/XMP keywords contain the given keyword.
213
+ *
214
+ * @param keyword - Exact keyword to match (e.g. "Molly's Cooking").
215
+ * @returns Array of MediaItem objects.
216
+ */
217
+ listByKeyword(keyword: string): Promise<MediaItem[]>;
218
+ /**
219
+ * #895: all distinct media keywords with item counts, for the admin keyword
220
+ * drift report. Aggregate counts only (no item data) — admin-only caller;
221
+ * counts include private items.
222
+ */
223
+ getAllKeywordCounts(): Promise<Record<string, number>>;
224
+ /**
225
+ * #917: library-wide leaf→path map from hierarchical media tags
226
+ * (HierarchicalSubject / TagsList). Empty when the provider doesn't index
227
+ * hierarchy. Consumed by #918 to preserve digiKam tag trees on write-back.
228
+ */
229
+ getKeywordLeafPaths(): Promise<Record<string, string>>;
230
+ /**
231
+ * Search media items.
232
+ *
233
+ * @param query - Search query string.
234
+ * @returns Array of MediaItem objects.
235
+ */
236
+ search(query: string): Promise<MediaItem[]>;
237
+ /**
238
+ * Find a media item by its original filename (basename).
239
+ *
240
+ * Used to resolve `media://filename.jpg` URIs in wiki page content.
241
+ * No privacy filtering is applied here — the caller (resolveAttachmentSrc)
242
+ * only uses the resulting URL; actual file delivery goes through the
243
+ * `/media/file/:id` route which enforces access control.
244
+ *
245
+ * @param filename - Basename to match (e.g. "IMG_1234.jpg").
246
+ * @returns The first matching MediaItem, or null if not found.
247
+ */
248
+ findByFilename(filename: string): Promise<MediaItem | null>;
249
+ /**
250
+ * Retrieve a thumbnail buffer for an item.
251
+ *
252
+ * @param id - Item identifier.
253
+ * @param size - Requested size string (e.g. "300x300").
254
+ * @returns JPEG buffer or null.
255
+ */
256
+ getThumbnailBuffer(id: string, size: string): Promise<Buffer | null>;
257
+ /**
258
+ * Return a transcoded full-resolution buffer for a HEIC/RAW item (#514).
259
+ * Transcoded result is cached to the thumbnail directory.
260
+ *
261
+ * @param id - Item identifier.
262
+ * @param format - Target format: 'jpeg' or 'webp'.
263
+ * @returns Transcoded buffer, or null if unavailable.
264
+ */
265
+ getTranscodedBuffer(id: string, format: 'jpeg' | 'webp'): Promise<Buffer | null>;
266
+ /**
267
+ * Return the list of years that have at least one media item, sorted
268
+ * descending (most recent first).
269
+ *
270
+ * @returns Sorted year list.
271
+ */
272
+ getYears(): Promise<number[]>;
273
+ /**
274
+ * Shut down the MediaManager, releasing provider resources. Its rescan
275
+ * job is stopped by BackgroundJobManager's shutdown handoff (#1721).
276
+ */
277
+ shutdown(): Promise<void>;
278
+ }
279
+ export default MediaManager;
@@ -0,0 +1,89 @@
1
+ import BaseManager from './BaseManager.js';
2
+ import type { WikiEngine } from '../types/WikiEngine.js';
3
+ import type { RequestHandler } from 'express';
4
+ /**
5
+ * MetricsManager - OpenTelemetry metrics with Prometheus export
6
+ *
7
+ * Provides application-level observability for page load times, index rebuild
8
+ * duration, save throughput, and HTTP request metrics. When disabled, all
9
+ * recording methods are no-ops.
10
+ *
11
+ * @class MetricsManager
12
+ * @extends BaseManager
13
+ */
14
+ declare class MetricsManager extends BaseManager {
15
+ private enabled;
16
+ private meterProvider;
17
+ private prometheusExporter;
18
+ private otlpReader;
19
+ private meter;
20
+ private prefix;
21
+ private pageViewsTotal;
22
+ private pageSavesTotal;
23
+ private pageDeletesTotal;
24
+ private searchRebuildsTotal;
25
+ private pageIndexSavesTotal;
26
+ private loginAttemptsTotal;
27
+ private httpRequestsTotal;
28
+ private cacheLookupsTotal;
29
+ private importConversionsTotal;
30
+ private pageViewDuration;
31
+ private pageSaveDuration;
32
+ private pageDeleteDuration;
33
+ private searchRebuildDuration;
34
+ private pageIndexSaveDuration;
35
+ private engineInitDuration;
36
+ private httpRequestDuration;
37
+ private processResidentMemory;
38
+ private processHeapTotal;
39
+ private processHeapUsed;
40
+ private processExternalMemory;
41
+ private processArrayBuffers;
42
+ constructor(engine: WikiEngine);
43
+ initialize(_config?: Record<string, unknown>): Promise<void>;
44
+ private createInstruments;
45
+ isEnabled(): boolean;
46
+ recordPageView(durationMs: number): void;
47
+ recordPageSave(durationMs: number): void;
48
+ recordPageDelete(durationMs: number): void;
49
+ recordSearchRebuild(durationMs: number): void;
50
+ recordPageIndexSave(durationMs: number): void;
51
+ recordLoginAttempt(): void;
52
+ recordEngineInit(durationMs: number): void;
53
+ recordHttpRequest(durationMs: number, attributes: {
54
+ method: string;
55
+ route: string;
56
+ status: string;
57
+ }): void;
58
+ /**
59
+ * Record an identity-manager cache lookup (#620). Cardinality is bounded —
60
+ * 7 caches × 2 results = 14 series — so attributes are safe.
61
+ */
62
+ recordCacheLookup(attributes: {
63
+ manager: string;
64
+ cache: string;
65
+ result: 'hit' | 'miss';
66
+ }): void;
67
+ /**
68
+ * Record an NCM / import conversion outcome (#738). Increment once per
69
+ * ConversionWarning emitted by a converter run. Cardinality is bounded
70
+ * by the size of the `kind` namespace — today ~5 kinds × 2 outcomes =
71
+ * 10 series; grows with each new structured kind. No-op when telemetry
72
+ * is disabled, matches the rest of MetricsManager's API.
73
+ *
74
+ * Called from ImportManager and (when it ships) the #685 data-ingestion
75
+ * framework — anywhere a converter run produces ConversionResult.
76
+ */
77
+ recordImportConversion(attributes: {
78
+ kind: string;
79
+ outcome: 'warning' | 'error';
80
+ }): void;
81
+ /**
82
+ * Returns a handler that serves Prometheus metrics on the main Express app.
83
+ * The PrometheusExporter runs its own HTTP server on a separate port,
84
+ * but this handler allows serving metrics through the main app as well.
85
+ */
86
+ getMetricsHandler(): RequestHandler | null;
87
+ shutdown(): Promise<void>;
88
+ }
89
+ export default MetricsManager;
@@ -0,0 +1,165 @@
1
+ import BaseManager from './BaseManager.js';
2
+ import type { WikiEngine } from '../types/WikiEngine.js';
3
+ import type { ActorContext } from '../context/ActorContext.js';
4
+ /**
5
+ * Notification object structure
6
+ */
7
+ export interface Notification {
8
+ id: string;
9
+ type: 'maintenance' | 'system' | 'user';
10
+ title: string;
11
+ message: string;
12
+ level: 'info' | 'warning' | 'error' | 'success';
13
+ targetUsers: string[];
14
+ createdAt: Date;
15
+ expiresAt: Date | null;
16
+ dismissedBy: string[];
17
+ }
18
+ /**
19
+ * Input for creating a notification
20
+ */
21
+ export interface NotificationInput {
22
+ type?: 'maintenance' | 'system' | 'user';
23
+ title?: string;
24
+ message?: string;
25
+ level?: 'info' | 'warning' | 'error' | 'success';
26
+ targetUsers?: string[];
27
+ expiresAt?: Date | null;
28
+ }
29
+ /**
30
+ * Notification statistics
31
+ */
32
+ export interface NotificationStats {
33
+ total: number;
34
+ active: number;
35
+ expired: number;
36
+ byType: Record<string, number>;
37
+ byLevel: Record<string, number>;
38
+ }
39
+ /**
40
+ * Maintenance configuration
41
+ */
42
+ export interface MaintenanceConfig {
43
+ [key: string]: unknown;
44
+ }
45
+ /**
46
+ * NotificationManager - Handles system notifications and user alerts
47
+ *
48
+ * Manages user-facing notifications and system alerts with persistent storage.
49
+ * Extends BaseManager following the modular manager pattern.
50
+ *
51
+ * @class NotificationManager
52
+ * @extends BaseManager
53
+ *
54
+ * @property {Map<string, Notification>} notifications - Active notifications by ID
55
+ * @property {number} notificationId - Auto-incrementing notification ID
56
+ * @property {string|null} storagePath - Path to notifications storage file
57
+ *
58
+ * @see {@link BaseManager} for base functionality
59
+ *
60
+ * @example
61
+ * const notificationManager = engine.getManager('NotificationManager');
62
+ * notificationManager.addNotification({ title: 'Welcome!', level: 'info' });
63
+ */
64
+ declare class NotificationManager extends BaseManager {
65
+ protected notifications: Map<string, Notification>;
66
+ protected notificationId: number;
67
+ private storagePath;
68
+ private saveInterval;
69
+ private logger;
70
+ /**
71
+ * Creates a new NotificationManager instance
72
+ *
73
+ * @constructor
74
+ * @param {any} engine - The wiki engine instance
75
+ */
76
+ constructor(engine: WikiEngine);
77
+ /**
78
+ * Initialize the notification manager
79
+ *
80
+ * @async
81
+ * @param {Record<string, unknown>} [config={}] - Configuration object
82
+ * @returns {Promise<void>}
83
+ */
84
+ initialize(config?: Record<string, unknown>): Promise<void>;
85
+ /**
86
+ * Load notifications from storage
87
+ */
88
+ private loadNotifications;
89
+ /**
90
+ * Save notifications to storage
91
+ */
92
+ private saveNotifications;
93
+ /**
94
+ * Create a new notification
95
+ * @param {NotificationInput} notification - Notification object
96
+ * @param {string} notification.type - Type of notification (maintenance, system, user)
97
+ * @param {string} notification.title - Notification title
98
+ * @param {string} notification.message - Notification message
99
+ * @param {string} notification.level - Severity level (info, warning, error, success)
100
+ * @param {Array} notification.targetUsers - Array of usernames to notify (empty for all)
101
+ * @param {Date} notification.expiresAt - When notification expires
102
+ * @returns {Promise<string>} Notification ID
103
+ */
104
+ createNotification(notification: NotificationInput): Promise<string>;
105
+ /**
106
+ * Add a notification (alias for createNotification for backward compatibility)
107
+ * @param {NotificationInput} notification - Notification object
108
+ * @returns {Promise<string>} Notification ID
109
+ */
110
+ addNotification(notification: NotificationInput): Promise<string>;
111
+ /**
112
+ * Get notifications for a specific user
113
+ * @param {string} username - Username to get notifications for
114
+ * @param {boolean} includeExpired - Include expired notifications
115
+ * @returns {Notification[]} Array of notifications
116
+ */
117
+ getUserNotifications(username: string, includeExpired?: boolean): Notification[];
118
+ /**
119
+ * Dismiss a notification for the caller.
120
+ *
121
+ * #1235: takes the caller's context, not a name, for a uniform door — the
122
+ * dismisser is `ctx.username`. Hides the banner from that one person and
123
+ * changes nothing else; recorded in the log line, not the audit trail.
124
+ * @param {string} notificationId - Notification ID
125
+ * @param ctx - Who is dismissing: the request's subject, forwarded
126
+ * @returns {Promise<boolean>} Success status
127
+ */
128
+ dismissNotification(notificationId: string, ctx: ActorContext): Promise<boolean>;
129
+ /**
130
+ * Create maintenance mode notification
131
+ * @param {boolean} enabled - Whether maintenance mode is enabled
132
+ * @param {string} adminUsername - Admin who toggled maintenance mode
133
+ * @param {MaintenanceConfig} config - Maintenance configuration
134
+ * @returns {Promise<string>} Notification ID
135
+ */
136
+ createMaintenanceNotification(enabled: boolean, adminUsername: string, _config?: MaintenanceConfig): Promise<string>;
137
+ /**
138
+ * Get all active notifications
139
+ * @param {boolean} includeExpired - Include expired notifications
140
+ * @returns {Notification[]} Array of all notifications
141
+ */
142
+ getAllNotifications(includeExpired?: boolean): Notification[];
143
+ /**
144
+ * Clean up expired notifications
145
+ */
146
+ cleanupExpiredNotifications(): Promise<void>;
147
+ /**
148
+ * Clear all active (non-expired) notifications
149
+ * @returns {Promise<number>} Number of cleared notifications
150
+ */
151
+ clearAllActive(): Promise<number>;
152
+ /**
153
+ * Get notification statistics
154
+ * @returns {NotificationStats} Statistics object
155
+ */
156
+ getStats(): NotificationStats;
157
+ private validateEscalationConfig;
158
+ private escalateByEmail;
159
+ private _doEscalateByEmail;
160
+ /**
161
+ * Shutdown the notification manager
162
+ */
163
+ shutdown(): Promise<void>;
164
+ }
165
+ export default NotificationManager;