@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,810 @@
1
+ import type { StoreFileIO } from '../utils/privateStoreFiles.js';
2
+ import type { UserCatalogPage } from '../utils/privateStoreCatalogs.js';
3
+ import type { StoreSearchDocument } from '../utils/storeSearchIndex.js';
4
+ import type { ActorContext } from '../context/ActorContext.js';
5
+ /**
6
+ * Provider type definitions for ngdpbase
7
+ *
8
+ * This module defines interfaces for all provider types (page, user, attachment,
9
+ * search, cache, audit) following JSPWiki's provider pattern for pluggable backends.
10
+ */
11
+ import { WikiPage, PageFrontmatter, PageInfo, PageSaveOptions, PageSearchResult, PageListOptions } from './Page.js';
12
+ import { VersionManifest, VersionContent, VersionDiff, VersionHistoryEntry } from './Version.js';
13
+ import { User, UserUpdateData, UserSession } from './User.js';
14
+ /**
15
+ * Provider information returned by getProviderInfo()
16
+ */
17
+ export interface ProviderInfo {
18
+ /** Provider name */
19
+ name: string;
20
+ /** Provider version */
21
+ version: string;
22
+ /** Provider description */
23
+ description?: string;
24
+ /** Provider features */
25
+ features?: string[];
26
+ }
27
+ /**
28
+ * Base provider interface
29
+ *
30
+ * All providers must implement this interface.
31
+ */
32
+ export interface BaseProvider {
33
+ /**
34
+ * Initialize the provider
35
+ * @returns Promise that resolves when initialization is complete
36
+ */
37
+ initialize(): Promise<void>;
38
+ /**
39
+ * Shutdown the provider (optional)
40
+ * @returns Promise that resolves when shutdown is complete
41
+ */
42
+ shutdown?(): Promise<void>;
43
+ /**
44
+ * Get provider information
45
+ * @returns Provider metadata
46
+ */
47
+ getProviderInfo?(): ProviderInfo;
48
+ /**
49
+ * Backup provider data
50
+ * @returns Promise resolving to backup data
51
+ */
52
+ backup?(): Promise<Record<string, unknown>>;
53
+ /**
54
+ * Restore provider data from backup
55
+ * @param backupData - Backup data from backup() method
56
+ * @returns Promise that resolves when restore is complete
57
+ */
58
+ restore?(backupData: Record<string, unknown>): Promise<void>;
59
+ }
60
+ /**
61
+ * Options for {@link PageProvider.getRecentChanges}.
62
+ */
63
+ export interface RecentChangesOptions {
64
+ /** Maximum number of entries to return after filtering. Default 50. */
65
+ limit?: number;
66
+ /** Only include pages modified at or after this cutoff. */
67
+ since?: Date | string;
68
+ /**
69
+ * Caller principals (typically `[...userContext.roles, userContext.username]`).
70
+ * Used to evaluate audience visibility for private pages. If omitted (anonymous),
71
+ * private pages are excluded.
72
+ *
73
+ * #1116: this is the ONLY visibility input. A caller supplies facts about who
74
+ * is asking, never the conclusion — the provider derives the admin bypass
75
+ * from an `admin` principal itself. The old `includeAll` boolean was the
76
+ * conclusion handed over, and any caller could pass `true`.
77
+ */
78
+ principals?: string[];
79
+ }
80
+ /**
81
+ * One page in a private store, as {@link PageProvider.listPrivateStorePages}
82
+ * reports it (#1457): where it is, and what it is called there.
83
+ */
84
+ export interface PrivateStorePageRef {
85
+ owner: string;
86
+ store: string;
87
+ title: string;
88
+ uuid: string;
89
+ }
90
+ /**
91
+ * Options for {@link PageProvider.getPagesByCreator} (#640).
92
+ */
93
+ export interface GetPagesByCreatorOptions {
94
+ /** Maximum number of entries returned. Default 1000 (intent: full per-user list). */
95
+ limit?: number;
96
+ /** Only include pages where `isPrivate === true`. */
97
+ onlyPrivate?: boolean;
98
+ /** Sort order. Default `lastModified-desc`. */
99
+ sortBy?: 'lastModified-desc' | 'title-asc';
100
+ /**
101
+ * Only include pages carrying at least ONE of these `system-keywords` (#1004).
102
+ * Matched case-insensitively. Omitted or empty means no keyword filter.
103
+ *
104
+ * Read from page frontmatter, not from a denormalised index field: the page
105
+ * index has no system-keywords column, and adding one would leave every
106
+ * pre-existing page invisible to this filter until its next save (the #1003
107
+ * failure mode). Frontmatter is the source of truth and needs no back-fill.
108
+ */
109
+ systemKeywords?: string[];
110
+ }
111
+ /**
112
+ * Options for {@link PageProvider.getPagesByEditor} / {@link PageProvider.getPagesSharedWith} (#640 Phase 2).
113
+ */
114
+ export interface PagesScanOptions {
115
+ /** Maximum number of entries returned. Default 1000. */
116
+ limit?: number;
117
+ /** Sort order. Default `lastModified-desc`. */
118
+ sortBy?: 'lastModified-desc' | 'title-asc';
119
+ }
120
+ /**
121
+ * Single entry returned by {@link PageProvider.getRecentChanges}.
122
+ *
123
+ * Fields beyond `title`/`uuid`/`lastModified` are best-effort: providers populate what
124
+ * they have. Consumers should treat optional fields as advisory.
125
+ */
126
+ /** Where a save put a page (#1462). */
127
+ export interface SavedPage {
128
+ /** The page's name now: its title, or `private/{owner}/{store}/{title}` (#1456). */
129
+ name: string;
130
+ uuid: string;
131
+ }
132
+ export interface RecentChangeEntry {
133
+ title: string;
134
+ uuid: string;
135
+ lastModified: string;
136
+ author?: string;
137
+ editor?: string;
138
+ currentVersion?: number;
139
+ hasVersions?: boolean;
140
+ isPrivate?: boolean;
141
+ creator?: string;
142
+ /**
143
+ * The page's name, where it is not its title: a private page's
144
+ * `private/{owner}/{store}/{title}` (#1456). Link with it.
145
+ */
146
+ name?: string;
147
+ }
148
+ /**
149
+ * Page provider interface
150
+ *
151
+ * Defines the contract for page storage backends (filesystem, database, etc.).
152
+ */
153
+ export interface PageProvider extends BaseProvider {
154
+ /**
155
+ * Get complete page with content and metadata
156
+ * @param identifier - Page UUID, title, or slug
157
+ * @returns Page object or null if not found
158
+ */
159
+ getPage(identifier: string, ctx: ActorContext): Promise<WikiPage | null>;
160
+ /**
161
+ * Get only page content (without metadata)
162
+ * @param identifier - Page UUID, title, or slug
163
+ * @returns Markdown content
164
+ */
165
+ getPageContent(identifier: string, ctx: ActorContext): Promise<string>;
166
+ /**
167
+ * Get only page metadata (without content)
168
+ * @param identifier - Page UUID, title, or slug
169
+ * @returns Metadata object or null if not found
170
+ */
171
+ getPageMetadata(identifier: string, ctx: ActorContext): Promise<PageFrontmatter | null>;
172
+ /**
173
+ * Save page content and metadata
174
+ * @param pageName - Page title
175
+ * @param content - Markdown content
176
+ * @param metadata - Frontmatter metadata
177
+ * @param options - Save options
178
+ * @returns Where the page landed (#1462): the provider decides placement,
179
+ * so it is the one that can say — a private page's name is its path.
180
+ */
181
+ savePage(pageName: string, content: string, metadata: Partial<PageFrontmatter> | undefined, ctx: ActorContext, options?: PageSaveOptions): Promise<SavedPage>;
182
+ /**
183
+ * Delete a page
184
+ * @param identifier - Page UUID or title
185
+ * @param ctx - Who is deleting (#1179): names the deleter on the tombstone
186
+ * (#947) and reaches a private store's keys (#1382). Was
187
+ * providers written before soft delete stay compatible.
188
+ * @returns True if deleted, false if not found
189
+ */
190
+ deletePage(identifier: string, ctx: ActorContext): Promise<boolean>;
191
+ /**
192
+ * At unlock (#1456): move the owner's sealed pages from the user-level
193
+ * catalog into each encrypted store's own page index. Optional capability —
194
+ * only a provider that keeps private stores has one.
195
+ */
196
+ adoptUserPageCatalog?(ctx: ActorContext): Promise<number>;
197
+ /**
198
+ * Every private page in the stores `ctx` can read (#1457), for a migration
199
+ * that must visit them. `owner` narrows it to one user's stores; without it
200
+ * every user with a private container is walked.
201
+ *
202
+ * What comes back is what the context may already read: a sealed store
203
+ * whose key this context does not hold contributes nothing, so a system
204
+ * context sees the unencrypted stores and an owner's own context sees
205
+ * theirs. Optional capability, like the catalog adoption above.
206
+ */
207
+ listPrivateStorePages?(ctx: ActorContext, owner?: string): Promise<PrivateStorePageRef[]>;
208
+ /**
209
+ * One owner's private stores as `ctx` can read them (#1457), by store id.
210
+ *
211
+ * A store whose index this context cannot open — sealed, and no key — is
212
+ * ABSENT from the map. A store it can open but which holds no page is
213
+ * present and empty. That difference is the whole point of this shape:
214
+ * "cannot say" is not "not there", and a caller that renders an answer must
215
+ * not turn the first into the second.
216
+ */
217
+ readablePrivateStores?(owner: string, ctx: ActorContext): Promise<Map<string, PrivateStorePageRef[]>>;
218
+ /**
219
+ * A store's own saved search index (#1458). Optional capability, like the
220
+ * store page index above: only a provider that keeps private stores has one.
221
+ *
222
+ * The provider owns the store's bytes — it seals them when the store is
223
+ * sealed and refuses a locked one — and decides nothing about who may ask.
224
+ * The page door does that, with the requester's context, before calling.
225
+ */
226
+ updateStoreSearchDocument?(ctx: ActorContext, owner: string, store: string, document: StoreSearchDocument): Promise<void>;
227
+ removeStoreSearchDocument?(ctx: ActorContext, owner: string, store: string, uuid: string): Promise<boolean>;
228
+ readStoreSearchDocuments?(ctx: ActorContext, owner: string, store: string): Promise<Record<string, StoreSearchDocument>>;
229
+ writeStoreSearchDocuments?(ctx: ActorContext, owner: string, store: string, documents: Record<string, StoreSearchDocument>): Promise<void>;
230
+ /** False means the store has no search index yet and one must be built from its pages. */
231
+ hasStoreSearchIndex?(owner: string, store: string): Promise<boolean>;
232
+ /**
233
+ * A store's own trash (#1459). Optional capability, like the store page and
234
+ * search indexes above, and reached the same way: the provider owns the
235
+ * store's bytes and refuses a sealed store it has no key for; the page door
236
+ * decides who may ask, with the requester's context, before calling.
237
+ */
238
+ listStoreDeletedPages?(ctx: ActorContext, owner: string): Promise<StoreDeletedEntry[]>;
239
+ restoreStorePage?(ctx: ActorContext, owner: string, store: string, uuid: string): Promise<StoreRestoreResult>;
240
+ purgeStorePage?(ctx: ActorContext, owner: string, store: string, uuid: string): Promise<boolean>;
241
+ /**
242
+ * Expire the tombstones past the retention window in every store `ctx` can
243
+ * open. A background job holds no key, so it reaches the unencrypted stores
244
+ * only; a sealed store's trash expires in its owner's own session (#1459).
245
+ *
246
+ * Returns WHAT it purged, not how many: the provider owns the bytes and the
247
+ * caller owns the audit record, so the caller needs the entries.
248
+ */
249
+ purgeExpiredStoreTrash?(ctx: ActorContext, owner?: string): Promise<StoreDeletedEntry[]>;
250
+ /**
251
+ * Read a page's file exactly as stored — frontmatter and body, unparsed and
252
+ * unsanitised. Optional capability: only providers backed by a filesystem can
253
+ * offer it, so callers must feature-detect rather than assume.
254
+ *
255
+ * Declared here rather than asserted at the call site. It was previously
256
+ * widened inline with `as PageProvider & { getRawFile?: ... }`, which
257
+ * typescript-eslint 8.65 flags as an unnecessary assertion and its autofixer
258
+ * removes — breaking the build, because the assertion was in fact
259
+ * load-bearing. Putting the optional member on the interface where it belongs
260
+ * satisfies both the compiler and the rule, instead of picking a side.
261
+ *
262
+ * @param identifier - UUID, slug, or title
263
+ * @returns The file path and raw contents, or null when unsupported/unknown
264
+ */
265
+ getRawFile?(identifier: string): Promise<{
266
+ filePath: string;
267
+ content: string;
268
+ } | null>;
269
+ /**
270
+ * Evict a single page from the provider's in-memory content/metadata cache.
271
+ * @param identifier - UUID, slug, or title
272
+ * @returns resolved page title if an entry was evicted, null otherwise
273
+ */
274
+ invalidatePageCache(identifier: string): string | null;
275
+ /**
276
+ * Look up a page's UUID by any identifier (UUID, slug, or title).
277
+ * @param identifier - UUID, slug, or title
278
+ * @param ctx - who is asking (#1418): the owner's unlocked sealed-store pages resolve only through it
279
+ * @returns UUID string or null if not found
280
+ */
281
+ getPageUUID(identifier: string, ctx: ActorContext): string | null;
282
+ /**
283
+ * Check if page exists
284
+ * @param identifier - Page UUID or title
285
+ * @returns True if page exists
286
+ */
287
+ pageExists(identifier: string, ctx: ActorContext): boolean;
288
+ /**
289
+ * Whether a page uuid is in the trash (#1403). Optional: a provider without
290
+ * soft delete has no trash, and callers treat its absence as false.
291
+ *
292
+ * @param uuid - Page UUID
293
+ * @returns True if the uuid has a trash entry
294
+ */
295
+ isPageDeleted?(uuid: string): boolean;
296
+ /**
297
+ * Bring a trashed page back with its history (#947). Optional: a provider
298
+ * without soft delete has nothing to restore.
299
+ *
300
+ * @param uuid - Page UUID
301
+ */
302
+ restoreDeletedPage?(uuid: string): Promise<{
303
+ ok: true;
304
+ title: string;
305
+ } | {
306
+ ok: false;
307
+ reason: string;
308
+ detail?: string;
309
+ }>;
310
+ /**
311
+ * Get all page titles
312
+ * @returns Sorted array of page titles
313
+ */
314
+ getAllPages(): Promise<string[]>;
315
+ /**
316
+ * Get all page titles (explicit alias for getAllPages)
317
+ * Prefer this for new code that only needs page names.
318
+ * @returns Sorted array of page titles
319
+ */
320
+ getAllPageNames(): Promise<string[]>;
321
+ /**
322
+ * Get all page info objects
323
+ * @param options - List options
324
+ * @returns Array of page info objects
325
+ */
326
+ getAllPageInfo(options?: PageListOptions): Promise<PageInfo[]>;
327
+ /**
328
+ * Find page by various identifiers
329
+ * @param identifier - UUID, title, or slug
330
+ * @returns Canonical page title or null
331
+ */
332
+ findPage(identifier: string): string | null;
333
+ /**
334
+ * Get a page by its UUID
335
+ * @param uuid - Page UUID
336
+ * @returns Page or null if not found
337
+ */
338
+ getPageByUUID(uuid: string, ctx: ActorContext): Promise<WikiPage | null>;
339
+ /**
340
+ * Get a page by its slug
341
+ * @param slug - URL-friendly slug
342
+ * @returns Page or null if not found
343
+ */
344
+ getPageBySlug(slug: string, ctx: ActorContext): Promise<WikiPage | null>;
345
+ /**
346
+ * Refresh page cache
347
+ * @returns Promise that resolves when refresh is complete
348
+ */
349
+ refreshPageList(): Promise<void>;
350
+ /**
351
+ * Return pages most recently modified, sorted descending by lastModified.
352
+ *
353
+ * Visibility (#635): private pages are filtered out unless one of the caller's
354
+ * principals is the page creator OR appears in the page's frontmatter audience.
355
+ * An `admin` principal bypasses the filter — derived here, never passed as a
356
+ * flag (#1116).
357
+ *
358
+ * Source-of-truth: providers MUST read from in-memory state (e.g., pageIndex /
359
+ * pageCache) — direct disk reads were what motivated this API.
360
+ */
361
+ getRecentChanges(ctx: ActorContext, options?: RecentChangesOptions): Promise<RecentChangeEntry[]>;
362
+ /**
363
+ * Return pages owned by the given user (#640).
364
+ *
365
+ * "Owned" matches by `author` or `creator` field — pageIndex keeps these in
366
+ * lockstep on save. The visibility filter is intentionally NOT applied here
367
+ * because by definition a user can see their own pages: the route handler
368
+ * verifies that `username === currentUser.username` before calling this.
369
+ *
370
+ * Source-of-truth: providers MUST read from in-memory state (pageIndex /
371
+ * pageCache). Reuses {@link RecentChangeEntry} shape since the relevant fields
372
+ * overlap.
373
+ */
374
+ getPagesByCreator(username: string, ctx: ActorContext, options?: GetPagesByCreatorOptions): Promise<RecentChangeEntry[]>;
375
+ /**
376
+ * Return pages most recently edited by the given user (#640 Phase 2).
377
+ * Match by `editor` — separate from `author`/`creator` because edits change
378
+ * editor but not author. Visibility filter NOT applied (caller asks about
379
+ * own activity).
380
+ */
381
+ getPagesByEditor(username: string, ctx: ActorContext, options?: PagesScanOptions): Promise<RecentChangeEntry[]>;
382
+ /**
383
+ * Return pages whose frontmatter audience contains any of the given
384
+ * principals — i.e., pages explicitly shared with the user (#640 Phase 2).
385
+ * Excludes pages the user already owns (those show up under `getPagesByCreator`).
386
+ */
387
+ getPagesSharedWith(principals: string[], options?: PagesScanOptions): Promise<RecentChangeEntry[]>;
388
+ }
389
+ /**
390
+ * Versioning page provider interface
391
+ *
392
+ * Extended page provider with version history capabilities.
393
+ */
394
+ export interface VersioningPageProvider extends PageProvider {
395
+ /**
396
+ * Get version history for a page
397
+ * @param identifier - Page UUID or title
398
+ * @param limit - Maximum number of versions to return
399
+ * @returns Array of version history entries
400
+ */
401
+ getVersionHistory(identifier: string, ctx: ActorContext, limit?: number): Promise<VersionHistoryEntry[]>;
402
+ /**
403
+ * Get specific version content
404
+ * @param identifier - Page UUID or title
405
+ * @param version - Version number
406
+ * @returns Version content object
407
+ */
408
+ getVersion(identifier: string, version: number): Promise<VersionContent | null>;
409
+ /**
410
+ * Get version manifest
411
+ * @param identifier - Page UUID or title
412
+ * @returns Version manifest object
413
+ */
414
+ getVersionManifest(identifier: string): Promise<VersionManifest | null>;
415
+ /**
416
+ * Compare two versions
417
+ * @param identifier - Page UUID or title
418
+ * @param fromVersion - Old version number
419
+ * @param toVersion - New version number
420
+ * @returns Version diff object
421
+ */
422
+ compareVersions(identifier: string, fromVersion: number, toVersion: number, ctx: ActorContext): Promise<VersionDiff | null>;
423
+ /**
424
+ * Delete old versions based on retention policy
425
+ * @param identifier - Page UUID or title
426
+ * @returns Number of versions deleted
427
+ */
428
+ cleanupVersions(identifier: string): Promise<number>;
429
+ /**
430
+ * Compress old versions
431
+ * @param identifier - Page UUID or title
432
+ * @param olderThanDays - Compress versions older than N days
433
+ * @returns Number of versions compressed
434
+ */
435
+ compressVersions(identifier: string, olderThanDays?: number): Promise<number>;
436
+ }
437
+ /**
438
+ * User provider interface
439
+ *
440
+ * Defines the contract for user storage backends.
441
+ */
442
+ export interface UserProvider extends BaseProvider {
443
+ /**
444
+ * Get user by username
445
+ * @param username - Username
446
+ * @returns User object or null if not found
447
+ */
448
+ getUser(username: string): Promise<User | null>;
449
+ /**
450
+ * Get user by email
451
+ * @param email - Email address
452
+ * @returns User object or null if not found
453
+ */
454
+ getUserByEmail(email: string): Promise<User | null>;
455
+ /**
456
+ * Get all users
457
+ * @returns Map of username to user objects
458
+ */
459
+ getAllUsers(): Promise<Map<string, User>>;
460
+ /**
461
+ * Create new user
462
+ * @param userData - User object with all fields populated
463
+ * @returns Created user object
464
+ */
465
+ createUser(userData: User): Promise<User>;
466
+ /**
467
+ * Update user
468
+ * @param username - Username
469
+ * @param updates - Partial user data to update
470
+ * @returns Updated user object
471
+ */
472
+ updateUser(username: string, updates: UserUpdateData): Promise<User>;
473
+ /**
474
+ * Delete user
475
+ * @param username - Username
476
+ * @returns True if deleted, false if not found
477
+ */
478
+ deleteUser(username: string): Promise<boolean>;
479
+ /**
480
+ * Validate user credentials
481
+ * @param username - Username
482
+ * @param password - Plain text password
483
+ * @returns User object if valid, null if invalid
484
+ */
485
+ validateCredentials(username: string, password: string): Promise<User | null>;
486
+ /**
487
+ * Create session
488
+ * @param sessionId - Session ID
489
+ * @param sessionData - Session data object
490
+ * @returns Promise that resolves when session is created
491
+ */
492
+ createSession(sessionId: string, sessionData: UserSession): Promise<void>;
493
+ /**
494
+ * Get session
495
+ * @param sessionId - Session ID
496
+ * @returns Session object or null if not found/expired
497
+ */
498
+ getSession(sessionId: string): Promise<UserSession | null>;
499
+ /**
500
+ * Delete session
501
+ * @param sessionId - Session ID
502
+ * @returns True if deleted, false if not found
503
+ */
504
+ deleteSession(sessionId: string): Promise<boolean>;
505
+ /**
506
+ * Clean up expired sessions
507
+ * @returns Number of sessions deleted
508
+ */
509
+ cleanupExpiredSessions(): Promise<number>;
510
+ /**
511
+ * Check if user exists
512
+ * @param username - Username to check
513
+ * @returns True if user exists
514
+ */
515
+ userExists(username: string): Promise<boolean>;
516
+ /**
517
+ * Get all usernames
518
+ * @returns Array of usernames
519
+ */
520
+ getAllUsernames(): Promise<string[]>;
521
+ /**
522
+ * Get all active sessions
523
+ * @returns Map of session ID to session data
524
+ */
525
+ getAllSessions(): Promise<Map<string, UserSession>>;
526
+ }
527
+ /**
528
+ * Attachment metadata
529
+ */
530
+ export interface AttachmentMetadata {
531
+ /** Attachment ID (UUID) */
532
+ id: string;
533
+ /** Filename */
534
+ filename: string;
535
+ /** Page UUID this attachment belongs to */
536
+ pageUuid: string;
537
+ /** MIME type */
538
+ mimeType: string;
539
+ /** File size in bytes */
540
+ size: number;
541
+ /** Upload timestamp (ISO 8601) */
542
+ uploadedAt: string;
543
+ /** Uploader user ID */
544
+ uploadedBy: string;
545
+ /** File path */
546
+ filePath: string;
547
+ /** Description */
548
+ description?: string;
549
+ /** Additional metadata */
550
+ [key: string]: unknown;
551
+ }
552
+ /**
553
+ * A file in a private store (#1400, #1460, docs/private-stores.md
554
+ * "Stores are self-contained"). Listed in the store's OWN index, beside
555
+ * `store.json` — never in the global `attachment-metadata.json` — and sealed
556
+ * with the store DEK when the store is encrypted. #1460: every private store
557
+ * keeps its files this way, encrypted or not.
558
+ */
559
+ export interface StoreFileEntry {
560
+ /**
561
+ * The file's id, and the base of its name on disk. A random UUID for a new
562
+ * upload; a record #1460's migration moved out of the shared index keeps the
563
+ * id it already had, because that id is its `/attachments/{id}` URL on every
564
+ * page that references it.
565
+ */
566
+ id: string;
567
+ /**
568
+ * Name on disk inside `{store}/attachments/`: `{id}{ext}` for a new upload,
569
+ * and for a migrated file the name it already had — #1460 moves bytes, it
570
+ * does not rename them. Says nothing about the file either way.
571
+ */
572
+ fileName: string;
573
+ /** The name it was uploaded with. Only inside the store's index. */
574
+ name: string;
575
+ encodingFormat: string;
576
+ contentSize: number;
577
+ /** SHA-256 of the plaintext: duplicate detection within this store only. */
578
+ fingerprint: string;
579
+ description: string;
580
+ author?: string;
581
+ dateCreated: string;
582
+ dateModified: string;
583
+ /** Pages the file was uploaded onto. */
584
+ mentions: string[];
585
+ }
586
+ /**
587
+ * A page in a private store (#1456): its entry in the store's OWN page index,
588
+ * beside `store.json` — never in the global `page-index.json`. The same shape
589
+ * the user-level sealed catalogue used (#1385), which the store index replaces.
590
+ */
591
+ export type StorePageEntry = UserCatalogPage;
592
+ /**
593
+ * A deleted page in a private store (#1459): its entry in the store's OWN
594
+ * trash record, `{store}/deleted-index.json`, beside the page index and
595
+ * written through the same store I/O — so it is sealed exactly when the store
596
+ * is, and a deleted private page is recorded nowhere else. Never in the global
597
+ * `page-index.json` and never in `pages/deleted/`.
598
+ *
599
+ * It is the live index entry it was, plus who removed it and when: restore
600
+ * puts that entry straight back, so nothing about the page has to be guessed
601
+ * or re-derived from the file.
602
+ */
603
+ export interface StoreDeletedEntry extends StorePageEntry {
604
+ /** When the page was deleted (ISO 8601) */
605
+ deletedAt: string;
606
+ /** Username that deleted it */
607
+ deletedBy: string;
608
+ }
609
+ /** Why a restore from a store's trash was refused (#1459). */
610
+ export type StoreRestoreFailure = 'not-found' | 'title-conflict' | 'file-missing' | 'error';
611
+ export type StoreRestoreResult = {
612
+ ok: true;
613
+ title: string;
614
+ name: string;
615
+ } | {
616
+ ok: false;
617
+ reason: StoreRestoreFailure;
618
+ detail?: string;
619
+ };
620
+ /**
621
+ * A private store as the attachment provider is handed it: whose it is, which
622
+ * store, and the I/O the caller's key allows (plain, or sealed with the store
623
+ * DEK). The provider stores and reads; it never decides who may, and never
624
+ * chooses whether to encrypt — the I/O already carries that.
625
+ */
626
+ export interface StoreFileLocation {
627
+ owner: string;
628
+ store: string;
629
+ io: StoreFileIO;
630
+ }
631
+ /**
632
+ * Attachment provider interface
633
+ *
634
+ * Defines the contract for attachment storage backends.
635
+ */
636
+ export interface AttachmentProvider extends BaseProvider {
637
+ /**
638
+ * Get attachment
639
+ * @param attachmentId - Attachment ID
640
+ * @returns File buffer and metadata
641
+ */
642
+ getAttachment(attachmentId: string): Promise<{
643
+ buffer: Buffer;
644
+ metadata: AttachmentMetadata;
645
+ } | null>;
646
+ /**
647
+ * Get attachment metadata
648
+ * @param attachmentId - Attachment ID
649
+ * @returns Attachment metadata or null
650
+ */
651
+ getAttachmentMetadata(attachmentId: string): Promise<AttachmentMetadata | null>;
652
+ /**
653
+ * List attachments for a page
654
+ * @param pageUuid - Page UUID
655
+ * @returns Array of attachment metadata
656
+ */
657
+ listAttachments(pageUuid: string): Promise<AttachmentMetadata[]>;
658
+ /**
659
+ * Delete attachment
660
+ * @param attachmentId - Attachment ID
661
+ * @returns True if deleted, false if not found
662
+ */
663
+ deleteAttachment(attachmentId: string): Promise<boolean>;
664
+ /**
665
+ * Delete all attachments for a page
666
+ * @param pageUuid - Page UUID
667
+ * @returns Number of attachments deleted
668
+ */
669
+ deletePageAttachments(pageUuid: string): Promise<number>;
670
+ }
671
+ /**
672
+ * Search provider interface
673
+ *
674
+ * Defines the contract for search backends (Lunr, Elasticsearch, etc.).
675
+ */
676
+ export interface SearchProvider extends BaseProvider {
677
+ /**
678
+ * Index a page
679
+ * @param page - Page to index
680
+ * @returns Promise that resolves when indexing is complete
681
+ */
682
+ indexPage(page: WikiPage): Promise<void>;
683
+ /**
684
+ * Remove page from index
685
+ * @param identifier - Page UUID or title
686
+ * @returns Promise that resolves when removal is complete
687
+ */
688
+ removePage(identifier: string): Promise<void>;
689
+ /**
690
+ * Search pages
691
+ * @param query - Search query
692
+ * @param options - Search options
693
+ * @returns Array of search results
694
+ */
695
+ search(query: string, options?: {
696
+ limit?: number;
697
+ offset?: number;
698
+ }): Promise<PageSearchResult[]>;
699
+ /**
700
+ * Get search suggestions
701
+ * @param query - Partial search query
702
+ * @param limit - Maximum suggestions to return
703
+ * @returns Array of suggestions
704
+ */
705
+ getSuggestions(query: string, limit?: number): Promise<string[]>;
706
+ /**
707
+ * Rebuild entire search index
708
+ * @returns Promise that resolves when rebuild is complete
709
+ */
710
+ rebuildIndex(): Promise<void>;
711
+ }
712
+ /**
713
+ * Cache provider interface
714
+ *
715
+ * Defines the contract for caching backends (in-memory, Redis, etc.).
716
+ */
717
+ export interface CacheProvider extends BaseProvider {
718
+ /**
719
+ * Get value from cache
720
+ * @param key - Cache key
721
+ * @returns Cached value or null if not found/expired
722
+ */
723
+ get<T = unknown>(key: string): Promise<T | null>;
724
+ /**
725
+ * Set value in cache
726
+ * @param key - Cache key
727
+ * @param value - Value to cache
728
+ * @param ttl - Time to live in seconds (optional)
729
+ * @returns Promise that resolves when value is cached
730
+ */
731
+ set<T = unknown>(key: string, value: T, ttl?: number): Promise<void>;
732
+ /**
733
+ * Delete value from cache
734
+ * @param key - Cache key
735
+ * @returns True if deleted, false if not found
736
+ */
737
+ delete(key: string): Promise<boolean>;
738
+ /**
739
+ * Clear all cached values
740
+ * @returns Promise that resolves when cache is cleared
741
+ */
742
+ clear(): Promise<void>;
743
+ /**
744
+ * Check if key exists in cache
745
+ * @param key - Cache key
746
+ * @returns True if key exists and not expired
747
+ */
748
+ has(key: string): Promise<boolean>;
749
+ }
750
+ /**
751
+ * Audit event
752
+ */
753
+ export interface AuditEvent {
754
+ /** Event ID (UUID) */
755
+ id: string;
756
+ /** Event type */
757
+ type: string;
758
+ /** Actor (user ID or 'system') */
759
+ actor: string;
760
+ /** Target resource */
761
+ target: string;
762
+ /** Action performed */
763
+ action: string;
764
+ /** Event timestamp (ISO 8601) */
765
+ timestamp: string;
766
+ /** IP address */
767
+ ipAddress?: string;
768
+ /** User agent */
769
+ userAgent?: string;
770
+ /** Additional event data */
771
+ data?: Record<string, unknown>;
772
+ /** Event result (success, failure) */
773
+ result: 'success' | 'failure';
774
+ /** Error message if failed */
775
+ error?: string;
776
+ }
777
+ /**
778
+ * Audit provider interface
779
+ *
780
+ * Defines the contract for audit logging backends.
781
+ */
782
+ export interface AuditProvider extends BaseProvider {
783
+ /**
784
+ * Log audit event
785
+ * @param event - Audit event
786
+ * @returns Promise that resolves when event is logged
787
+ */
788
+ logEvent(event: Omit<AuditEvent, 'id' | 'timestamp'>): Promise<void>;
789
+ /**
790
+ * Query audit events
791
+ * @param filters - Filter criteria
792
+ * @returns Array of audit events
793
+ */
794
+ queryEvents(filters: {
795
+ type?: string;
796
+ actor?: string;
797
+ target?: string;
798
+ action?: string;
799
+ startDate?: string;
800
+ endDate?: string;
801
+ limit?: number;
802
+ offset?: number;
803
+ }): Promise<AuditEvent[]>;
804
+ /**
805
+ * Delete old audit events
806
+ * @param olderThanDays - Delete events older than N days
807
+ * @returns Number of events deleted
808
+ */
809
+ cleanupOldEvents(olderThanDays: number): Promise<number>;
810
+ }