@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,134 @@
1
+ import BaseManager from './BaseManager.js';
2
+ import type { WikiEngine } from '../types/WikiEngine.js';
3
+ import type { Role, RoleUpdate } from '../types/Role.js';
4
+ import type { RoleProvider } from '../types/RoleProvider.js';
5
+ import { type ActorContext } from '../context/ActorContext.js';
6
+ import type { JobContext } from '../context/JobContext.js';
7
+ declare class RoleManager extends BaseManager {
8
+ readonly description = "Canonical OrganizationRole records (#617 follow-up)";
9
+ private provider;
10
+ private providerClass?;
11
+ private memberCache;
12
+ private byOrgPositionCache;
13
+ private metricsRef;
14
+ constructor(engine: WikiEngine);
15
+ initialize(config?: Record<string, unknown>): Promise<void>;
16
+ /**
17
+ * Strip the catalogue copy from role records written before #1431 step 1
18
+ * (operator, 2026-09-21).
19
+ *
20
+ * A record holds MEMBERSHIP only. Records created earlier also carried a
21
+ * copy of the role's catalogue entry — `roleName`, `description`,
22
+ * `issystem`, `icon`, `color` — and a `permissions` list under
23
+ * `additionalProperty`, taken at create time, never updated and never read.
24
+ * Configuration declares the role's settings and the policies decide what
25
+ * it permits, so the copy was a second source that had already drifted
26
+ * (jimstest's `admin` listed 17 permissions against the 21 granted).
27
+ *
28
+ * Runs at every start and does nothing once a store is clean, so every
29
+ * install created before the change is cleaned, not just one. Only the copy
30
+ * goes: `@id`, `namedPosition`, `organization` and `member` are untouched,
31
+ * as is any other `additionalProperty` entry.
32
+ */
33
+ private stripCatalogueCopies;
34
+ /** Provider accessor, mainly for tests. */
35
+ getProvider(): RoleProvider | null;
36
+ getById(id: string): Promise<Role | null>;
37
+ getByOrgAndPosition(organizationId: string, namedPosition: string): Promise<Role | null>;
38
+ listByMember(personId: string): Promise<Role[]>;
39
+ list(): Promise<Role[]>;
40
+ create(role: Role): Promise<Role>;
41
+ update(id: string, patch: RoleUpdate): Promise<Role | null>;
42
+ delete(id: string): Promise<boolean>;
43
+ /**
44
+ * Clear all caches. Called on every write (create/update/delete) — the
45
+ * simplest correct invalidation strategy. Per-key invalidation is an
46
+ * optimization that can come later if measurement shows it matters.
47
+ * Public so callers (e.g., admin "rebuild" tools) can force a cache miss.
48
+ */
49
+ invalidateCache(): void;
50
+ /**
51
+ * A user's base role names: the `namedPosition` of every role record whose
52
+ * `member[]` holds the user's Person `@id` (#617).
53
+ *
54
+ * The pseudo-roles `'Authenticated'` and `'All'` are NOT added here — the
55
+ * caller adds those when constructing `userContext.roles`.
56
+ *
57
+ * Returns `[]` when PersonManager is unavailable, the user has no Person
58
+ * record, no record lists them, or the lookup throws.
59
+ */
60
+ resolveUserRoles(username: string): Promise<string[]>;
61
+ /**
62
+ * The `required-aal` levels the OPERATOR set in their own config (#448,
63
+ * #1523), as opposed to the shipped defaults. An operator's level that no
64
+ * factor can reach refuses the boot; a shipped default that cannot be reached
65
+ * only degrades, so an upgrade never locks an instance out.
66
+ */
67
+ operatorRequiredAal(): Record<string, 1 | 2 | 3>;
68
+ /**
69
+ * The roles that set their own idle timeout (#1546): role name → minutes,
70
+ * from each definition's optional `idle-timeout-minutes`. Only positive
71
+ * numbers count; empty when no role sets one, which is the shipped default.
72
+ */
73
+ roleIdleTimeouts(): Record<string, number>;
74
+ /**
75
+ * The assurance level each role requires of a sign-in (#1523): role name →
76
+ * AAL 1–3, from each definition's `required-aal`. A role without one (or
77
+ * `anonymous`) requires nothing beyond being signed in.
78
+ */
79
+ roleRequiredAal(): Record<string, 1 | 2 | 3>;
80
+ hasRole(username: string, roleName: string): Promise<boolean>;
81
+ /** Assign one role to an existing account, and record it (#1204). */
82
+ assignRole(username: string, roleName: string, ctx: ActorContext): Promise<boolean>;
83
+ /** Remove one role from an existing account, and record it (#1204). */
84
+ removeRole(username: string, roleName: string, ctx: ActorContext): Promise<boolean>;
85
+ /**
86
+ * Make the user's memberships go from `oldRoles` to `newRoles`. Used by
87
+ * UserManager when an account is created or edited; the account write
88
+ * records its own audit event, so this records none.
89
+ */
90
+ applyRoleDiff(username: string, oldRoles: string[], newRoles: string[]): Promise<void>;
91
+ /**
92
+ * Give `roleName` to every account in `usernames`, once (#1539).
93
+ *
94
+ * For a role every account must hold — `ngdpbase.user.account-roles` — that
95
+ * arrives on an instance which already has people. The role's record not
96
+ * existing is the record that it was never given: this adds every account,
97
+ * which creates the record, and from then on finds the record and does
98
+ * nothing, so an admin's later removal from one person stands. Each grant is
99
+ * a role change and is recorded as one, under the system context `ctx`,
100
+ * deferred until the audit sink is up when this runs at boot.
101
+ *
102
+ * @returns how many accounts were given the role (0 once it has been given)
103
+ */
104
+ grantToEveryAccountOnce(roleName: string, usernames: readonly string[], ctx: JobContext): Promise<number>;
105
+ /** Remove a deleted account's Person from every role it held. */
106
+ removeAllMemberships(username: string): Promise<void>;
107
+ /**
108
+ * Add the user's Person `@id` to the role record for (installOrg, roleName).
109
+ * Idempotent: a no-op when the Person is already a member.
110
+ *
111
+ * Failures are logged, not thrown — account writes must succeed even when
112
+ * role storage is degraded. #1027: every abandon path says why, because a
113
+ * silent one is indistinguishable from success.
114
+ */
115
+ private addMember;
116
+ private removeMember;
117
+ /**
118
+ * The role record for (installOrg, namedPosition), created when missing.
119
+ *
120
+ * #1429/#1431: the record holds __membership only__. It used to snapshot
121
+ * the catalogue entry too (display name, description, and `permissions`),
122
+ * a copy later catalogue edits never updated and nothing read. What a role
123
+ * permits is the policies, resolved at the moment of each decision.
124
+ */
125
+ private getOrCreateRoleRecord;
126
+ /** The account must exist; membership of a missing account is refused. */
127
+ private requireAccount;
128
+ /** #1204: a role assigned or removed is a user-edit; what the account may do changed. */
129
+ private recordRoleChange;
130
+ private requireProvider;
131
+ private getMetrics;
132
+ private normalizeProviderName;
133
+ }
134
+ export default RoleManager;
@@ -0,0 +1,402 @@
1
+ import BaseManager, { BackupData } from './BaseManager.js';
2
+ import { WikiEngine } from '../types/WikiEngine.js';
3
+ /**
4
+ * Search result structure
5
+ */
6
+ interface SearchResult {
7
+ name: string;
8
+ title?: string;
9
+ content?: string;
10
+ excerpt?: string;
11
+ score: number;
12
+ metadata?: Record<string, unknown>;
13
+ category?: string;
14
+ userKeywords?: string[];
15
+ [key: string]: unknown;
16
+ }
17
+ /**
18
+ * Search options
19
+ */
20
+ interface SearchOptions {
21
+ maxResults?: number;
22
+ offset?: number;
23
+ searchIn?: string[];
24
+ boost?: Record<string, number>;
25
+ /** WikiContext for the current request — used to filter private search results */
26
+ wikiContext?: WikiContext;
27
+ [key: string]: unknown;
28
+ }
29
+ /**
30
+ * Advanced search options
31
+ */
32
+ interface AdvancedSearchOptions {
33
+ query?: string;
34
+ categories?: string[];
35
+ /** #706: knowledge-role values to filter by (source / citation / concept). */
36
+ knowledgeRoles?: string[];
37
+ userKeywords?: string[];
38
+ searchIn?: string[];
39
+ maxResults?: number;
40
+ offset?: number;
41
+ /** #643 / #774: date range (inclusive, whole-day). */
42
+ dateRange?: {
43
+ from?: string;
44
+ to?: string;
45
+ };
46
+ /** #774: which date field `dateRange` filters on. Default `'modified'`. */
47
+ dateField?: 'modified' | 'created';
48
+ [key: string]: unknown;
49
+ }
50
+ /**
51
+ * Search statistics structure
52
+ */
53
+ interface SearchStatistics {
54
+ totalDocuments: number;
55
+ indexSize: number;
56
+ averageDocumentLength: number;
57
+ totalCategories: number;
58
+ totalUserKeywords: number;
59
+ [key: string]: unknown;
60
+ }
61
+ /**
62
+ * Page data for indexing
63
+ */
64
+ interface PageData {
65
+ name: string;
66
+ title?: string;
67
+ content?: string;
68
+ metadata?: Record<string, unknown>;
69
+ category?: string;
70
+ userKeywords?: string[];
71
+ [key: string]: unknown;
72
+ }
73
+ /**
74
+ * WikiContext interface
75
+ */
76
+ interface WikiContext {
77
+ userContext?: {
78
+ username?: string;
79
+ [key: string]: unknown;
80
+ };
81
+ [key: string]: unknown;
82
+ }
83
+ /**
84
+ * SearchManager - Handles search indexing and querying
85
+ *
86
+ * Similar to JSPWiki's SearchManager, this manager provides full-text search
87
+ * capabilities through a pluggable provider system. Supports different search
88
+ * backends (Lunr.js, Elasticsearch, etc.) via provider abstraction.
89
+ *
90
+ * Key features:
91
+ * - Pluggable search provider system
92
+ * - Full-text indexing of page content and metadata
93
+ * - Configurable search ranking and filtering
94
+ * - Automatic index rebuilding
95
+ * - Provider abstraction for different search engines
96
+ *
97
+ * Follows the provider pattern established in AttachmentManager, PageManager,
98
+ * CacheManager, and AuditManager for pluggable search backends.
99
+ *
100
+ * Configuration (all lowercase):
101
+ * - ngdpbase.search.enabled - Enable/disable search
102
+ * - ngdpbase.search.provider.default - Default provider name
103
+ * - ngdpbase.search.provider - Active provider name
104
+ * - ngdpbase.search.provider.lunr.* - LunrSearchProvider settings
105
+ *
106
+ * @class SearchManager
107
+ * @extends BaseManager
108
+ *
109
+ * @property {BaseSearchProvider|null} provider - The active search provider
110
+ * @property {string|null} providerClass - The class name of the loaded provider
111
+ *
112
+ * @see {@link BaseManager} for base functionality
113
+ * @see {@link LunrSearchProvider} for default provider implementation
114
+ *
115
+ * @example
116
+ * const searchManager = engine.getManager('SearchManager');
117
+ * const results = await searchManager.search('hello world');
118
+ * console.log(`Found ${results.length} pages`);
119
+ *
120
+ * Related: GitHub Issue #102 - Configuration reorganization
121
+ */
122
+ declare class SearchManager extends BaseManager {
123
+ private provider;
124
+ private providerClass;
125
+ /**
126
+ * Creates a new SearchManager instance
127
+ *
128
+ * @constructor
129
+ * @param {WikiEngine} engine - The wiki engine instance
130
+ */
131
+ constructor(engine: WikiEngine);
132
+ /**
133
+ * Initialize the SearchManager and load the configured provider
134
+ *
135
+ * Loads the search provider, builds the initial search index, and prepares
136
+ * the search system for queries.
137
+ *
138
+ * @async
139
+ * @param {Record<string, unknown>} [config={}] - Configuration object (unused, reads from ConfigurationManager)
140
+ * @returns {Promise<void>}
141
+ * @throws {Error} If ConfigurationManager is not available or provider fails to load
142
+ *
143
+ * @example
144
+ * await searchManager.initialize();
145
+ * console.log('Search system ready');
146
+ */
147
+ initialize(config?: Record<string, unknown>): Promise<void>;
148
+ /**
149
+ * Normalize provider name to PascalCase class name
150
+ *
151
+ * @param {string} providerName - Provider name from config (e.g., 'lunrsearchprovider')
152
+ * @returns {string} PascalCase class name (e.g., 'LunrSearchProvider')
153
+ * @private
154
+ */
155
+ private normalizeProviderName;
156
+ /**
157
+ * Load the search provider dynamically
158
+ *
159
+ * @private
160
+ * @returns {Promise<void>}
161
+ * @throws {Error} If provider loading fails completely
162
+ */
163
+ private loadProvider;
164
+ /**
165
+ * Build search index from all pages
166
+ *
167
+ * @returns {Promise<void>}
168
+ * @throws {Error} If index building fails
169
+ */
170
+ buildSearchIndex(): Promise<void>;
171
+ /**
172
+ * Search for pages using WikiContext
173
+ *
174
+ * Performs a search using WikiContext as the single source of truth for user information.
175
+ * Logs search queries with user context for analytics and audit purposes.
176
+ *
177
+ * @async
178
+ * @param {WikiContext} wikiContext - The wiki context containing user info
179
+ * @param {string} query - Search query
180
+ * @param {SearchOptions} [options={}] - Additional search options
181
+ * @returns {Promise<SearchResult[]>} Search results
182
+ * @throws {Error} If wikiContext is not provided
183
+ *
184
+ * @example
185
+ * const results = await searchManager.searchWithContext(wikiContext, 'hello world');
186
+ * console.log(`Found ${results.length} pages`);
187
+ */
188
+ searchWithContext(wikiContext: WikiContext, query: string, options?: SearchOptions): Promise<SearchResult[]>;
189
+ /**
190
+ * Public results, plus the requester's own private pages (#1458).
191
+ *
192
+ * The private matches come from the page door, which reads each of the
193
+ * REQUESTER'S OWN readable stores with their context — never from a store
194
+ * file read here, and never for anyone else's container: another user's
195
+ * search, and an admin's, reach none of them. A locked encrypted store
196
+ * yields nothing rather than an error.
197
+ *
198
+ * A private row carries the page's private name, so `pageUrl` links to it.
199
+ */
200
+ private mergeOwnPrivateResults;
201
+ /**
202
+ * Advanced search with WikiContext
203
+ *
204
+ * Performs advanced search with multiple criteria using WikiContext as the single source
205
+ * of truth. Logs detailed search parameters with user context for analytics.
206
+ *
207
+ * @async
208
+ * @param {WikiContext} wikiContext - The wiki context containing user info
209
+ * @param {AdvancedSearchOptions} [options={}] - Search options
210
+ * @returns {Promise<SearchResult[]>} Search results
211
+ * @throws {Error} If wikiContext is not provided
212
+ *
213
+ * @example
214
+ * const results = await searchManager.advancedSearchWithContext(wikiContext, {
215
+ * query: 'tutorial',
216
+ * categories: ['Documentation'],
217
+ * maxResults: 20
218
+ * });
219
+ */
220
+ advancedSearchWithContext(wikiContext: WikiContext, options?: AdvancedSearchOptions): Promise<SearchResult[]>;
221
+ /**
222
+ * Search for pages matching the query
223
+ *
224
+ * @param {string} query - Search query
225
+ * @param {SearchOptions} options - Search options
226
+ * @returns {Promise<SearchResult[]>} Search results
227
+ * @deprecated Use searchWithContext() with WikiContext instead
228
+ */
229
+ search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
230
+ /**
231
+ * Advanced search with multiple criteria support
232
+ *
233
+ * @param {AdvancedSearchOptions} options - Search options
234
+ * @returns {Promise<SearchResult[]>} Search results
235
+ * @deprecated Use advancedSearchWithContext() with WikiContext instead
236
+ */
237
+ advancedSearch(options?: AdvancedSearchOptions): Promise<SearchResult[]>;
238
+ /**
239
+ * Suggest similar pages based on content
240
+ *
241
+ * @param {string} pageName - Source page name
242
+ * @param {number} limit - Maximum suggestions
243
+ * @returns {Promise<SearchResult[]>} Suggested pages
244
+ */
245
+ suggestSimilarPages(pageName: string, limit?: number): Promise<SearchResult[]>;
246
+ /**
247
+ * Get search suggestions for autocomplete
248
+ *
249
+ * @param {string} partial - Partial search term
250
+ * @returns {Promise<string[]>} Suggested completions
251
+ */
252
+ getSuggestions(partial: string): Promise<string[]>;
253
+ /**
254
+ * Rebuild search index (called after page changes)
255
+ *
256
+ * @returns {Promise<void>}
257
+ */
258
+ rebuildIndex(): Promise<void>;
259
+ /**
260
+ * #724: true rebuild FROM DISK — clears the index + persisted cache and
261
+ * re-scans every page, so entries for deleted pages ("ghosts") are
262
+ * dropped by construction. This is the "Rebuild" to rebuildIndex()'s
263
+ * "Reindex" (mirrors media.rebuild vs media.rescan). Providers that lack
264
+ * a disk-reconciling rebuild fall back to the normal index build.
265
+ *
266
+ * @returns {Promise<void>}
267
+ */
268
+ rebuildFromDisk(): Promise<void>;
269
+ /**
270
+ * Add/update a page in the search index
271
+ *
272
+ * @param {string} pageName - Page name
273
+ * @param {PageData} pageData - Page data
274
+ * @returns {Promise<void>}
275
+ */
276
+ updatePageInIndex(pageName: string, pageData: PageData): Promise<void>;
277
+ /**
278
+ * Remove a page from the search index
279
+ *
280
+ * @param {string} pageName - Page name to remove
281
+ * @returns {Promise<void>}
282
+ */
283
+ removePageFromIndex(pageName: string): Promise<void>;
284
+ /**
285
+ * Search by multiple categories
286
+ *
287
+ * @param {string[]} categories - Array of category names to search
288
+ * @returns {Promise<SearchResult[]>} Search results
289
+ */
290
+ searchByCategories(categories: string[]): Promise<SearchResult[]>;
291
+ /**
292
+ * Search by multiple user keywords
293
+ *
294
+ * @param {string[]} keywords - Array of user keywords to search
295
+ * @returns {Promise<SearchResult[]>} Search results
296
+ */
297
+ searchByUserKeywordsList(keywords: string[]): Promise<SearchResult[]>;
298
+ /**
299
+ * Get all unique categories from indexed documents
300
+ *
301
+ * @returns {Promise<string[]>} List of categories
302
+ */
303
+ getAllCategories(): Promise<string[]>;
304
+ /**
305
+ * Get all unique user keywords from indexed documents
306
+ *
307
+ * @returns {Promise<string[]>} List of user keywords
308
+ */
309
+ getAllUserKeywords(): Promise<string[]>;
310
+ /**
311
+ * Return all systemKeywords present in the search index (union across all pages).
312
+ * Used to populate the "Browse / Filter by System Keyword" UI (#509).
313
+ * Returns [] if the active provider does not support this operation (e.g. Lunr).
314
+ */
315
+ getAllSystemKeywords(): Promise<string[]>;
316
+ /**
317
+ * Search pages that have all of the given system keywords.
318
+ * Returns [] if provider does not support systemKeywords filtering.
319
+ */
320
+ searchBySystemKeywordsList(keywords: string[]): Promise<SearchResult[]>;
321
+ /**
322
+ * Get systemKeywords stored in the search index for a specific page.
323
+ * Returns auto-tagged terms added by TaggingService at index time (#507).
324
+ * Returns [] if the active provider does not support this operation.
325
+ */
326
+ getPageSystemKeywords(pageName: string): Promise<string[]>;
327
+ /**
328
+ * Search by category only
329
+ *
330
+ * @param {string} category - Category to search for
331
+ * @returns {Promise<SearchResult[]>} Pages in category
332
+ */
333
+ searchByCategory(category: string): Promise<SearchResult[]>;
334
+ /**
335
+ * Search by user keywords only
336
+ *
337
+ * @param {string} keyword - Keyword to search for
338
+ * @returns {Promise<SearchResult[]>} Pages with keyword
339
+ */
340
+ searchByUserKeywords(keyword: string): Promise<SearchResult[]>;
341
+ getAllDocuments(): Promise<SearchResult[]>;
342
+ /**
343
+ * Get search statistics
344
+ *
345
+ * @returns {Promise<SearchStatistics>} Search statistics
346
+ */
347
+ getStatistics(): Promise<SearchStatistics>;
348
+ /**
349
+ * Get the total number of indexed documents
350
+ *
351
+ * @returns {Promise<number>} Number of documents
352
+ */
353
+ getDocumentCount(): Promise<number>;
354
+ /**
355
+ * Search by keywords
356
+ *
357
+ * @param {string[]} keywords - Keywords to search for
358
+ * @returns {Promise<SearchResult[]>} Search results
359
+ */
360
+ searchByKeywords(keywords: string[]): Promise<SearchResult[]>;
361
+ /**
362
+ * Add page to search index
363
+ *
364
+ * @param {PageData} page - Page object to add
365
+ * @returns {Promise<void>}
366
+ */
367
+ addToIndex(page: PageData): Promise<void>;
368
+ /**
369
+ * Remove page from search index
370
+ *
371
+ * @param {string} pageName - Name of page to remove
372
+ * @returns {Promise<void>}
373
+ */
374
+ removeFromIndex(pageName: string): Promise<void>;
375
+ /**
376
+ * Perform multi-criteria search
377
+ *
378
+ * @param {AdvancedSearchOptions} criteria - Search criteria object
379
+ * @returns {Promise<SearchResult[]>} Search results
380
+ */
381
+ multiSearch(criteria: AdvancedSearchOptions): Promise<SearchResult[]>;
382
+ /**
383
+ * Backup search configuration and state
384
+ *
385
+ * @returns {Promise<BackupData>} Backup data
386
+ */
387
+ backup(): Promise<BackupData>;
388
+ /**
389
+ * Restore search from backup
390
+ *
391
+ * @param {BackupData} backupData - Backup data
392
+ * @returns {Promise<void>}
393
+ */
394
+ restore(backupData: BackupData): Promise<void>;
395
+ /**
396
+ * Shutdown search manager and close provider
397
+ *
398
+ * @returns {Promise<void>}
399
+ */
400
+ shutdown(): Promise<void>;
401
+ }
402
+ export default SearchManager;