@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.
- package/LICENSE +201 -0
- package/README.md +16 -2
- package/lib/packages/ngdpbase-types/index.d.ts +32 -0
- package/lib/packages/ngdpbase-types/testing.d.ts +43 -0
- package/lib/packages/ngdpbase-types/testing.js +53 -0
- package/lib/src/cache/CacheDependencies.d.ts +50 -0
- package/lib/src/cache/CacheDependencies.js +50 -0
- package/lib/src/cache/ICacheAdapter.d.ts +86 -0
- package/lib/src/cache/RegionCache.d.ts +171 -0
- package/lib/src/context/ActorContext.d.ts +48 -0
- package/lib/src/context/ActorContext.js +33 -0
- package/lib/src/context/ApiContext.d.ts +194 -0
- package/lib/src/context/ApiContext.js +273 -0
- package/lib/src/context/BaseContext.d.ts +110 -0
- package/lib/src/context/BaseContext.js +143 -0
- package/lib/src/context/JobContext.d.ts +153 -0
- package/lib/src/context/JobContext.js +144 -0
- package/lib/src/context/WikiContext.d.ts +404 -0
- package/lib/src/context/bootActions.d.ts +64 -0
- package/lib/src/context/bootActions.js +111 -0
- package/lib/src/converters/HtmlConverter.d.ts +70 -0
- package/lib/src/converters/IContentConverter.d.ts +94 -0
- package/lib/src/converters/JSPWikiConverter.d.ts +117 -0
- package/lib/src/converters/conversionWarning.d.ts +15 -0
- package/lib/src/converters/ncm/bridge.d.ts +22 -0
- package/lib/src/converters/ncm/existing.d.ts +23 -0
- package/lib/src/converters/ncm/fix/blocks.d.ts +89 -0
- package/lib/src/converters/ncm/fix/bulletMarkers.d.ts +21 -0
- package/lib/src/converters/ncm/fix/index.d.ts +36 -0
- package/lib/src/converters/ncm/fix/jspwikiBullets.d.ts +20 -0
- package/lib/src/converters/ncm/fix/jspwikiCodeMarkers.d.ts +38 -0
- package/lib/src/converters/ncm/fix/jspwikiHeadings.d.ts +25 -0
- package/lib/src/converters/ncm/fix/jspwikiIndent.d.ts +24 -0
- package/lib/src/converters/ncm/fix/jspwikiInsert.d.ts +21 -0
- package/lib/src/converters/ncm/fix/jspwikiItalic.d.ts +29 -0
- package/lib/src/converters/ncm/fix/jspwikiLinkLeftovers.d.ts +27 -0
- package/lib/src/converters/ncm/fix/moreInformationFooter.d.ts +25 -0
- package/lib/src/converters/ncm/fix/styleClosers.d.ts +25 -0
- package/lib/src/converters/ncm/fix/tightenLists.d.ts +30 -0
- package/lib/src/converters/ncm/fix/types.d.ts +33 -0
- package/lib/src/converters/ncm/footnotes.d.ts +39 -0
- package/lib/src/converters/ncm/images.d.ts +49 -0
- package/lib/src/converters/ncm/index.d.ts +20 -0
- package/lib/src/converters/ncm/links.d.ts +21 -0
- package/lib/src/converters/ncm/normalize.d.ts +39 -0
- package/lib/src/converters/ncm/placeholder.d.ts +25 -0
- package/lib/src/converters/ncm/tables.d.ts +36 -0
- package/lib/src/converters/ncm/types.d.ts +42 -0
- package/lib/src/http/egressPolicy.d.ts +52 -0
- package/lib/src/http/guardedFetch.d.ts +89 -0
- package/lib/src/http/guardedFetch.js +113 -0
- package/lib/src/http/guardedLookup.d.ts +48 -0
- package/lib/src/http/guardedLookup.js +73 -0
- package/lib/src/http/ssrf.d.ts +83 -0
- package/lib/src/http/ssrf.js +311 -0
- package/lib/src/mail/MailProvider.d.ts +36 -0
- package/lib/src/mail/NodemailerMailProvider.d.ts +26 -0
- package/lib/src/managers/AddonsManager.d.ts +691 -0
- package/lib/src/managers/AgentTokenManager.d.ts +269 -0
- package/lib/src/managers/AssetManager.d.ts +116 -0
- package/lib/src/managers/AttachmentManager.d.ts +1032 -0
- package/lib/src/managers/AuthManager.d.ts +1257 -0
- package/lib/src/managers/BackgroundJobManager.d.ts +434 -0
- package/lib/src/managers/BaseManager.d.ts +391 -0
- package/lib/src/managers/BaseManager.js +415 -0
- package/lib/src/managers/CacheManager.d.ts +159 -0
- package/lib/src/managers/CatalogManager.d.ts +235 -0
- package/lib/src/managers/CommentManager.d.ts +75 -0
- package/lib/src/managers/ConfigurationManager.d.ts +747 -0
- package/lib/src/managers/DatabaseManager.d.ts +89 -0
- package/lib/src/managers/DatabaseManager.js +236 -0
- package/lib/src/managers/EmailManager.d.ts +47 -0
- package/lib/src/managers/ExportManager.d.ts +129 -0
- package/lib/src/managers/ExportManager.js +420 -0
- package/lib/src/managers/FootnoteManager.d.ts +118 -0
- package/lib/src/managers/MediaManager.d.ts +279 -0
- package/lib/src/managers/MetricsManager.d.ts +89 -0
- package/lib/src/managers/NotificationManager.d.ts +165 -0
- package/lib/src/managers/OidcManager.d.ts +210 -0
- package/lib/src/managers/OrganizationManager.d.ts +107 -0
- package/lib/src/managers/PageManager.d.ts +1645 -0
- package/lib/src/managers/PersonManager.d.ts +48 -0
- package/lib/src/managers/PluginManager.d.ts +179 -0
- package/lib/src/managers/PluginManager.js +393 -0
- package/lib/src/managers/PolicyEvaluator.d.ts +213 -0
- package/lib/src/managers/RenderingManager.d.ts +358 -0
- package/lib/src/managers/RoleManager.d.ts +134 -0
- package/lib/src/managers/SearchManager.d.ts +402 -0
- package/lib/src/managers/ShareManager.d.ts +251 -0
- package/lib/src/managers/TemplateManager.d.ts +176 -0
- package/lib/src/managers/ThemeManager.d.ts +56 -0
- package/lib/src/managers/UserManager.d.ts +480 -0
- package/lib/src/managers/ValidationManager.d.ts +426 -0
- package/lib/src/managers/VariableManager.d.ts +145 -0
- package/lib/src/middleware/csrf.d.ts +3 -0
- package/lib/src/parsers/LinkParser.d.ts +457 -0
- package/lib/src/parsers/MarkupParser.d.ts +769 -0
- package/lib/src/parsers/context/ParseContext.d.ts +314 -0
- package/lib/src/parsers/data/emoji-map.d.ts +18 -0
- package/lib/src/parsers/dom/DOMBuilder.d.ts +210 -0
- package/lib/src/parsers/dom/DOMParser.d.ts +252 -0
- package/lib/src/parsers/dom/Tokenizer.d.ts +358 -0
- package/lib/src/parsers/dom/WikiDocument.d.ts +272 -0
- package/lib/src/parsers/dom/handlers/DOMLinkHandler.d.ts +260 -0
- package/lib/src/parsers/dom/handlers/DOMPluginHandler.d.ts +212 -0
- package/lib/src/parsers/dom/handlers/DOMVariableHandler.d.ts +171 -0
- package/lib/src/parsers/filters/BaseFilter.d.ts +269 -0
- package/lib/src/parsers/filters/FilterChain.d.ts +320 -0
- package/lib/src/parsers/handlers/BaseSyntaxHandler.d.ts +331 -0
- package/lib/src/parsers/handlers/HandlerRegistry.d.ts +225 -0
- package/lib/src/parsers/handlers/JSPWikiPreprocessor.d.ts +89 -0
- package/lib/src/parsers/handlers/LinkParserHandler.d.ts +80 -0
- package/lib/src/parsers/handlers/PluginSyntaxHandler.d.ts +78 -0
- package/lib/src/parsers/handlers/WikiFormHandler.d.ts +149 -0
- package/lib/src/parsers/handlers/WikiTagHandler.d.ts +125 -0
- package/lib/src/parsers/jspwikiTableRow.d.ts +39 -0
- package/lib/src/parsers/styleBlockSyntax.d.ts +14 -0
- package/lib/src/plugins/types.d.ts +79 -0
- package/lib/src/providers/AgentTokenAuthProvider.d.ts +40 -0
- package/lib/src/providers/AuthentikBearerAuthProvider.d.ts +75 -0
- package/lib/src/providers/BaseAttachmentProvider.d.ts +197 -0
- package/lib/src/providers/BaseAuthProvider.d.ts +220 -0
- package/lib/src/providers/BaseCacheProvider.d.ts +140 -0
- package/lib/src/providers/BaseCredentialsProvider.d.ts +84 -0
- package/lib/src/providers/BaseDatabaseProvider.d.ts +22 -0
- package/lib/src/providers/BaseDatabaseProvider.js +12 -0
- package/lib/src/providers/BaseLoggingProvider.d.ts +68 -0
- package/lib/src/providers/BaseLoggingProvider.js +37 -0
- package/lib/src/providers/BaseMediaProvider.d.ts +308 -0
- package/lib/src/providers/BasePageProvider.d.ts +337 -0
- package/lib/src/providers/BaseProvider.d.ts +98 -0
- package/lib/src/providers/BaseProvider.js +74 -0
- package/lib/src/providers/BaseSearchProvider.d.ts +362 -0
- package/lib/src/providers/BasicAttachmentProvider.d.ts +599 -0
- package/lib/src/providers/CloudflareAccessAuthProvider.d.ts +72 -0
- package/lib/src/providers/FileCredentialsProvider.d.ts +33 -0
- package/lib/src/providers/FileJobStateProvider.d.ts +58 -0
- package/lib/src/providers/FileLoggingProvider.d.ts +43 -0
- package/lib/src/providers/FileLoggingProvider.js +120 -0
- package/lib/src/providers/FileOidcAdapter.d.ts +25 -0
- package/lib/src/providers/FileSystemMediaProvider.d.ts +403 -0
- package/lib/src/providers/LunrSearchProvider.d.ts +280 -0
- package/lib/src/providers/MagicLinkAuthProvider.d.ts +125 -0
- package/lib/src/providers/NullCacheProvider.d.ts +72 -0
- package/lib/src/providers/OidcAuthProvider.d.ts +180 -0
- package/lib/src/providers/OidcBearerAuthProvider.d.ts +30 -0
- package/lib/src/providers/PasskeyAuthProvider.d.ts +58 -0
- package/lib/src/providers/PasswordAuthProvider.d.ts +20 -0
- package/lib/src/providers/SqliteDatabaseProvider.d.ts +55 -0
- package/lib/src/providers/SqliteDatabaseProvider.js +90 -0
- package/lib/src/providers/SqliteJobStateProvider.d.ts +41 -0
- package/lib/src/providers/databaseMigrations.d.ts +8 -0
- package/lib/src/providers/databaseMigrations.js +47 -0
- package/lib/src/providers/jobState.d.ts +99 -0
- package/lib/src/providers/lunrQueryToMiniSearch.d.ts +32 -0
- package/lib/src/providers/mediaFilenameDate.d.ts +22 -0
- package/lib/src/providers/sqliteLocation.d.ts +17 -0
- package/lib/src/providers/sqliteLocation.js +55 -0
- package/lib/src/providers/sqliteMigrations.d.ts +48 -0
- package/lib/src/providers/sqliteMigrations.js +72 -0
- package/lib/src/rendering/githubAlerts.d.ts +22 -0
- package/lib/src/rendering/htmlPolicy.d.ts +76 -0
- package/lib/src/rendering/markdownConverter.d.ts +73 -0
- package/lib/src/security/PolicyDecisionPoint.d.ts +245 -0
- package/lib/src/security/PolicyInformationPoint.d.ts +448 -0
- package/lib/src/security/pageActions.d.ts +40 -0
- package/lib/src/security/permissions.generated.d.ts +78 -0
- package/lib/src/types/Asset.d.ts +414 -0
- package/lib/src/types/Catalog.d.ts +61 -0
- package/lib/src/types/Comment.d.ts +11 -0
- package/lib/src/types/Config.d.ts +388 -0
- package/lib/src/types/Organization.d.ts +78 -0
- package/lib/src/types/OrganizationProvider.d.ts +38 -0
- package/lib/src/types/Page.d.ts +220 -0
- package/lib/src/types/Person.d.ts +56 -0
- package/lib/src/types/PersonProvider.d.ts +25 -0
- package/lib/src/types/Policy.d.ts +139 -0
- package/lib/src/types/Policy.js +17 -0
- package/lib/src/types/Provider.d.ts +810 -0
- package/lib/src/types/Role.d.ts +84 -0
- package/lib/src/types/RoleProvider.d.ts +35 -0
- package/lib/src/types/Schema.d.ts +425 -0
- package/lib/src/types/Share.d.ts +172 -0
- package/lib/src/types/Share.js +81 -0
- package/lib/src/types/User.d.ts +304 -0
- package/lib/src/types/Version.d.ts +189 -0
- package/lib/src/types/WikiEngine.d.ts +128 -0
- package/lib/src/types/express.d.ts +120 -0
- package/lib/src/types/express.js +1 -0
- package/lib/src/types/guards.d.ts +78 -0
- package/lib/src/types/heic-decode.d.ts +16 -0
- package/lib/src/types/index.d.ts +19 -0
- package/lib/src/types/linkedom.d.ts +77 -0
- package/lib/src/types/markdown-it-plugins.d.ts +21 -0
- package/lib/src/utils/DeltaStorage.d.ts +118 -0
- package/lib/src/utils/LocaleUtils.d.ts +105 -0
- package/lib/src/utils/LocaleUtils.js +294 -0
- package/lib/src/utils/PageNameMatcher.d.ts +98 -0
- package/lib/src/utils/PathPreflight.d.ts +38 -0
- package/lib/src/utils/PathPreflight.js +50 -0
- package/lib/src/utils/SectionUtils.d.ts +40 -0
- package/lib/src/utils/addonConfigLayer.d.ts +144 -0
- package/lib/src/utils/addonConfigLayer.js +382 -0
- package/lib/src/utils/addonDatabaseRules.d.ts +25 -0
- package/lib/src/utils/addonDatabaseRules.js +57 -0
- package/lib/src/utils/addonHost.d.ts +51 -0
- package/lib/src/utils/addonHost.js +72 -0
- package/lib/src/utils/addonInstaller.d.ts +109 -0
- package/lib/src/utils/addonLock.d.ts +37 -0
- package/lib/src/utils/addonLock.js +48 -0
- package/lib/src/utils/addonPageSync.d.ts +45 -0
- package/lib/src/utils/addonProvenance.d.ts +48 -0
- package/lib/src/utils/addonTarball.d.ts +41 -0
- package/lib/src/utils/addonsPathResolver.d.ts +76 -0
- package/lib/src/utils/addonsPathResolver.js +129 -0
- package/lib/src/utils/assetMetadataTags.d.ts +66 -0
- package/lib/src/utils/atomicWrite.d.ts +28 -0
- package/lib/src/utils/auditConfigChange.d.ts +57 -0
- package/lib/src/utils/auditEventNames.d.ts +50 -0
- package/lib/src/utils/auditEventNames.generated.d.ts +163 -0
- package/lib/src/utils/auditEventNames.generated.js +168 -0
- package/lib/src/utils/auditEventNames.js +49 -0
- package/lib/src/utils/auditEvents.d.ts +265 -0
- package/lib/src/utils/auditEvents.js +309 -0
- package/lib/src/utils/auditRegistry.d.ts +102 -0
- package/lib/src/utils/auditRegistry.js +168 -0
- package/lib/src/utils/bip39English.d.ts +2 -0
- package/lib/src/utils/configEnvKeys.d.ts +68 -0
- package/lib/src/utils/configFiles.d.ts +74 -0
- package/lib/src/utils/configFiles.js +150 -0
- package/lib/src/utils/delegation.d.ts +48 -0
- package/lib/src/utils/deriveUsername.d.ts +21 -0
- package/lib/src/utils/explainMediaPath.d.ts +123 -0
- package/lib/src/utils/formerTitles.d.ts +69 -0
- package/lib/src/utils/frontmatterAccess.d.ts +54 -0
- package/lib/src/utils/headlessAdminPassword.d.ts +55 -0
- package/lib/src/utils/imageTransform.d.ts +52 -0
- package/lib/src/utils/instanceEnvSecret.d.ts +51 -0
- package/lib/src/utils/jobSlots.d.ts +43 -0
- package/lib/src/utils/keywordNormalizer.d.ts +127 -0
- package/lib/src/utils/logger.d.ts +70 -0
- package/lib/src/utils/logger.js +106 -0
- package/lib/src/utils/magicLinkDeviceState.d.ts +95 -0
- package/lib/src/utils/managerUtils.d.ts +40 -0
- package/lib/src/utils/migrateLegacyPrivateAttachments.d.ts +15 -0
- package/lib/src/utils/orgFilename.d.ts +22 -0
- package/lib/src/utils/pageFeature.d.ts +27 -0
- package/lib/src/utils/pageFrontmatter.d.ts +21 -0
- package/lib/src/utils/pageNotes.d.ts +150 -0
- package/lib/src/utils/pageTitleRule.d.ts +37 -0
- package/lib/src/utils/pageToArticle.d.ts +59 -0
- package/lib/src/utils/pageUrl.d.ts +18 -0
- package/lib/src/utils/passwordChange.d.ts +12 -0
- package/lib/src/utils/passwordHash.d.ts +60 -0
- package/lib/src/utils/permissionCatalog.d.ts +52 -0
- package/lib/src/utils/pluginFormatters.d.ts +452 -0
- package/lib/src/utils/pluginFormatters.js +714 -0
- package/lib/src/utils/privateLinkRewrite.d.ts +42 -0
- package/lib/src/utils/privateStoreAccess.d.ts +57 -0
- package/lib/src/utils/privateStoreAccess.js +65 -0
- package/lib/src/utils/privateStoreCatalogs.d.ts +40 -0
- package/lib/src/utils/privateStoreCrypto.d.ts +127 -0
- package/lib/src/utils/privateStoreDoor.d.ts +181 -0
- package/lib/src/utils/privateStoreExport.d.ts +72 -0
- package/lib/src/utils/privateStoreFiles.d.ts +120 -0
- package/lib/src/utils/privateStoreMeta.d.ts +64 -0
- package/lib/src/utils/privateStoreMigrations.d.ts +37 -0
- package/lib/src/utils/privateStorePath.d.ts +259 -0
- package/lib/src/utils/privateStorePath.js +436 -0
- package/lib/src/utils/privateStoreTakeout.d.ts +76 -0
- package/lib/src/utils/privateStoreUnlock.d.ts +175 -0
- package/lib/src/utils/proxyClaim.d.ts +59 -0
- package/lib/src/utils/proxyClaim.js +30 -0
- package/lib/src/utils/redactPrivateNames.d.ts +21 -0
- package/lib/src/utils/redactPrivateNames.js +89 -0
- package/lib/src/utils/redactSecrets.d.ts +58 -0
- package/lib/src/utils/redactSecrets.js +171 -0
- package/lib/src/utils/renameLinkRewrite.d.ts +112 -0
- package/lib/src/utils/roleGrants.d.ts +35 -0
- package/lib/src/utils/safeRedirect.d.ts +32 -0
- package/lib/src/utils/schedule.d.ts +54 -0
- package/lib/src/utils/secretFileMode.d.ts +17 -0
- package/lib/src/utils/seededShippedPages.d.ts +45 -0
- package/lib/src/utils/sensitiveValues.d.ts +59 -0
- package/lib/src/utils/sensitiveValues.js +106 -0
- package/lib/src/utils/sessionEnd.d.ts +12 -0
- package/lib/src/utils/sessionGeneration.d.ts +24 -0
- package/lib/src/utils/sessionIdle.d.ts +41 -0
- package/lib/src/utils/sessionLimits.d.ts +68 -0
- package/lib/src/utils/shareLockbox.d.ts +64 -0
- package/lib/src/utils/sigstoreTrustedRoot.d.ts +33 -0
- package/lib/src/utils/sniffMime.d.ts +21 -0
- package/lib/src/utils/storeSearchIndex.d.ts +75 -0
- package/lib/src/utils/subjectMayDo.d.ts +21 -0
- package/lib/src/utils/systemCategoryRules.d.ts +30 -0
- package/lib/src/utils/systemCategoryRules.js +41 -0
- package/lib/src/utils/userCreateError.d.ts +62 -0
- package/lib/src/utils/username.d.ts +53 -0
- package/lib/src/utils/vaultUrlRewrite.d.ts +27 -0
- package/lib/src/utils/version.d.ts +84 -0
- package/lib/src/utils/videoFrame.d.ts +21 -0
- package/package.json +54 -3
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOMPluginHandler - DOM-based plugin execution handler
|
|
3
|
+
*
|
|
4
|
+
* Replaces string-based regex plugin processing with DOM queries.
|
|
5
|
+
* Processes wiki plugins by querying WikiDocument for .wiki-plugin elements
|
|
6
|
+
* and executing them through PluginManager.
|
|
7
|
+
*
|
|
8
|
+
* Part of Phase 4 of WikiDocument DOM Migration (GitHub Issue #107)
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* In wiki markup: [{PluginName param=value}]
|
|
12
|
+
* These are tokenized as PLUGIN tokens and become .wiki-plugin elements
|
|
13
|
+
* This handler executes them and replaces with rendered output
|
|
14
|
+
*/
|
|
15
|
+
import type WikiDocument from '../WikiDocument.js';
|
|
16
|
+
import type { LinkedomElement } from '../WikiDocument.js';
|
|
17
|
+
/**
|
|
18
|
+
* Plugin execution context
|
|
19
|
+
*/
|
|
20
|
+
export interface PluginContext {
|
|
21
|
+
/** Page name */
|
|
22
|
+
pageName: string;
|
|
23
|
+
/** User name */
|
|
24
|
+
userName: string;
|
|
25
|
+
/** User context information */
|
|
26
|
+
userContext?: {
|
|
27
|
+
username?: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
fullName?: string;
|
|
30
|
+
roles?: string[];
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
};
|
|
33
|
+
/** Request information */
|
|
34
|
+
requestInfo?: {
|
|
35
|
+
method?: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
};
|
|
40
|
+
/** Page front matter metadata (uuid, title, etc.) */
|
|
41
|
+
pageMetadata?: unknown;
|
|
42
|
+
/** WikiEngine reference */
|
|
43
|
+
engine: unknown;
|
|
44
|
+
/** WikiContext reference */
|
|
45
|
+
wikiContext?: unknown;
|
|
46
|
+
/** Plugin parameters */
|
|
47
|
+
parameters: Record<string, string>;
|
|
48
|
+
/** Plugin body content (for body plugins) */
|
|
49
|
+
bodyContent: string | null;
|
|
50
|
+
/** Plugin name */
|
|
51
|
+
pluginName: string;
|
|
52
|
+
/** WikiDocument reference */
|
|
53
|
+
wikiDocument?: WikiDocument;
|
|
54
|
+
/** Plugin DOM element */
|
|
55
|
+
pluginElement?: LinkedomElement | null;
|
|
56
|
+
/** Link graph for plugins like ReferringPagesPlugin */
|
|
57
|
+
linkGraph?: Record<string, unknown>;
|
|
58
|
+
/** Page context (nested structure) */
|
|
59
|
+
pageContext?: {
|
|
60
|
+
pageName?: string;
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
};
|
|
63
|
+
/** Additional context properties */
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parsed plugin information
|
|
68
|
+
*/
|
|
69
|
+
export interface PluginInfo {
|
|
70
|
+
/** Plugin name */
|
|
71
|
+
pluginName: string;
|
|
72
|
+
/** Plugin parameters */
|
|
73
|
+
parameters: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Plugin manager interface
|
|
77
|
+
*/
|
|
78
|
+
interface PluginManager {
|
|
79
|
+
/** Execute a plugin */
|
|
80
|
+
execute(pluginName: string, pageName: string, parameters: Record<string, string>, context: PluginContext): Promise<string | null>;
|
|
81
|
+
/** Additional manager methods */
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* WikiEngine interface (minimal)
|
|
86
|
+
*/
|
|
87
|
+
interface WikiEngine {
|
|
88
|
+
/** Get a manager by name */
|
|
89
|
+
getManager(name: string): unknown;
|
|
90
|
+
/** Additional engine properties */
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Extracted element from JSPWiki syntax extraction
|
|
95
|
+
*/
|
|
96
|
+
export interface ExtractedPluginElement {
|
|
97
|
+
/** Element type */
|
|
98
|
+
type: string;
|
|
99
|
+
/** Plugin inner content (e.g., "TableOfContents" or "Search query='wiki'") */
|
|
100
|
+
inner: string;
|
|
101
|
+
/** Unique ID for tracking */
|
|
102
|
+
id: number;
|
|
103
|
+
/** Original text */
|
|
104
|
+
originalText?: string;
|
|
105
|
+
/** Start index in content */
|
|
106
|
+
startIndex?: number;
|
|
107
|
+
/** End index in content */
|
|
108
|
+
endIndex?: number;
|
|
109
|
+
/** Additional properties */
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Information about a single plugin
|
|
114
|
+
*/
|
|
115
|
+
export interface PluginInstanceInfo {
|
|
116
|
+
/** Plugin name */
|
|
117
|
+
name: string;
|
|
118
|
+
/** Plugin parameters */
|
|
119
|
+
parameters: Record<string, string>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Statistics about plugin processing
|
|
123
|
+
*/
|
|
124
|
+
export interface PluginStatistics {
|
|
125
|
+
/** Total number of plugins in document */
|
|
126
|
+
totalPlugins: number;
|
|
127
|
+
/** Number of unique plugins */
|
|
128
|
+
uniqueCount: number;
|
|
129
|
+
/** Array of unique plugin names */
|
|
130
|
+
uniquePlugins: string[];
|
|
131
|
+
/** Array of plugin instances */
|
|
132
|
+
plugins: PluginInstanceInfo[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* DOMPluginHandler class
|
|
136
|
+
*/
|
|
137
|
+
declare class DOMPluginHandler {
|
|
138
|
+
/** WikiEngine instance */
|
|
139
|
+
private engine;
|
|
140
|
+
/** PluginManager instance (loaded dynamically) */
|
|
141
|
+
protected pluginManager: PluginManager | null;
|
|
142
|
+
/**
|
|
143
|
+
* Creates a new DOMPluginHandler
|
|
144
|
+
*
|
|
145
|
+
* @param {WikiEngine} engine - WikiEngine instance
|
|
146
|
+
*/
|
|
147
|
+
constructor(engine: WikiEngine);
|
|
148
|
+
/**
|
|
149
|
+
* Initializes the handler
|
|
150
|
+
*/
|
|
151
|
+
initialize(): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Processes plugins in a WikiDocument
|
|
154
|
+
*
|
|
155
|
+
* Queries for .wiki-plugin elements and executes them.
|
|
156
|
+
* This is the DOM-based equivalent of PluginSyntaxHandler.process()
|
|
157
|
+
*
|
|
158
|
+
* @param {WikiDocument} wikiDocument - The WikiDocument to process
|
|
159
|
+
* @param {PluginContext} context - Rendering context
|
|
160
|
+
* @returns {Promise<WikiDocument>} Updated WikiDocument
|
|
161
|
+
*/
|
|
162
|
+
processPlugins(wikiDocument: WikiDocument, context: PluginContext): Promise<WikiDocument>;
|
|
163
|
+
/**
|
|
164
|
+
* Parses plugin content string into name and parameters
|
|
165
|
+
*
|
|
166
|
+
* @param {string} pluginContent - Plugin content (e.g., "TableOfContents max=3")
|
|
167
|
+
* @returns {PluginInfo | null} { pluginName, parameters } or null if invalid
|
|
168
|
+
*/
|
|
169
|
+
parsePluginContent(pluginContent: string): PluginInfo | null;
|
|
170
|
+
/**
|
|
171
|
+
* Parses parameter string into object
|
|
172
|
+
*
|
|
173
|
+
* @param {string} paramString - Parameter string (e.g., "max=3 show=true")
|
|
174
|
+
* @returns {Record<string, string>} Parsed parameters
|
|
175
|
+
*/
|
|
176
|
+
parseParameters(paramString: string): Record<string, string>;
|
|
177
|
+
/**
|
|
178
|
+
* Executes a plugin through PluginManager
|
|
179
|
+
*
|
|
180
|
+
* @param {string} pluginName - Name of the plugin
|
|
181
|
+
* @param {Record<string, string>} parameters - Plugin parameters
|
|
182
|
+
* @param {PluginContext} context - Rendering context
|
|
183
|
+
* @param {unknown} pluginElement - The plugin DOM element
|
|
184
|
+
* @returns {Promise<string | null>} Plugin output HTML or null
|
|
185
|
+
*/
|
|
186
|
+
executePlugin(pluginName: string, parameters: Record<string, string>, context: PluginContext, pluginElement: unknown): Promise<string | null>;
|
|
187
|
+
/**
|
|
188
|
+
* Creates a DOM node from an extracted plugin element
|
|
189
|
+
*
|
|
190
|
+
* This method is part of the Phase 2 extraction-based parsing (Issue #114).
|
|
191
|
+
* It creates a plugin node from a pre-extracted element and executes the plugin.
|
|
192
|
+
*
|
|
193
|
+
* @param {ExtractedPluginElement} element - Extracted element from extractJSPWikiSyntax()
|
|
194
|
+
* @param {PluginContext} context - Rendering context
|
|
195
|
+
* @param {WikiDocument} wikiDocument - WikiDocument to create node in
|
|
196
|
+
* @returns {Promise<Element>} DOM node for the plugin
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* const element = { type: 'plugin', inner: 'TableOfContents', id: 1, ... };
|
|
200
|
+
* const node = await handler.createNodeFromExtract(element, context, wikiDoc);
|
|
201
|
+
* // Returns: <span class="wiki-plugin" data-plugin="TableOfContents">...plugin output...</span>
|
|
202
|
+
*/
|
|
203
|
+
createNodeFromExtract(element: ExtractedPluginElement, context: PluginContext, wikiDocument: WikiDocument): Promise<LinkedomElement>;
|
|
204
|
+
/**
|
|
205
|
+
* Gets statistics about plugin processing
|
|
206
|
+
*
|
|
207
|
+
* @param {WikiDocument} wikiDocument - Document to analyze
|
|
208
|
+
* @returns {PluginStatistics} Statistics
|
|
209
|
+
*/
|
|
210
|
+
getStatistics(wikiDocument: WikiDocument): PluginStatistics;
|
|
211
|
+
}
|
|
212
|
+
export default DOMPluginHandler;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOMVariableHandler - DOM-based variable expansion handler
|
|
3
|
+
*
|
|
4
|
+
* Replaces string-based regex variable expansion with DOM queries.
|
|
5
|
+
* Processes wiki variables by querying WikiDocument for .wiki-variable elements
|
|
6
|
+
* and resolving their values through VariableManager.
|
|
7
|
+
*
|
|
8
|
+
* Part of Phase 3 of WikiDocument DOM Migration (GitHub Issue #93)
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* In wiki markup: {$username}, {$pagename}, {$date}, etc.
|
|
12
|
+
* These are tokenized as VARIABLE tokens and become .wiki-variable elements
|
|
13
|
+
* This handler resolves them to actual values
|
|
14
|
+
*/
|
|
15
|
+
import type WikiDocument from '../WikiDocument.js';
|
|
16
|
+
import type { LinkedomElement } from '../WikiDocument.js';
|
|
17
|
+
/**
|
|
18
|
+
* Context for variable resolution
|
|
19
|
+
*/
|
|
20
|
+
export interface VariableContext {
|
|
21
|
+
/** Page name */
|
|
22
|
+
pageName?: string;
|
|
23
|
+
/** User context information */
|
|
24
|
+
userContext?: {
|
|
25
|
+
username?: string;
|
|
26
|
+
email?: string;
|
|
27
|
+
fullName?: string;
|
|
28
|
+
roles?: string[];
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
/** Request information */
|
|
32
|
+
requestInfo?: {
|
|
33
|
+
method?: string;
|
|
34
|
+
path?: string;
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
/** Page context (nested structure from WikiContext) */
|
|
39
|
+
pageContext?: VariableContext;
|
|
40
|
+
/** WikiEngine reference */
|
|
41
|
+
engine?: unknown;
|
|
42
|
+
/** Additional context properties */
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Variable handler function type
|
|
47
|
+
*/
|
|
48
|
+
export type VariableHandler = (context: VariableContext) => string | number | Promise<string | number>;
|
|
49
|
+
/**
|
|
50
|
+
* Variable manager interface
|
|
51
|
+
*/
|
|
52
|
+
interface VariableManager {
|
|
53
|
+
/** Map of variable handlers */
|
|
54
|
+
variableHandlers: Map<string, VariableHandler>;
|
|
55
|
+
/** Additional manager methods */
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* WikiEngine interface (minimal)
|
|
60
|
+
*/
|
|
61
|
+
interface WikiEngine {
|
|
62
|
+
/** Get a manager by name */
|
|
63
|
+
getManager(name: string): unknown;
|
|
64
|
+
/** Additional engine properties */
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Extracted element from JSPWiki syntax extraction
|
|
69
|
+
*/
|
|
70
|
+
export interface ExtractedElement {
|
|
71
|
+
/** Element type */
|
|
72
|
+
type: string;
|
|
73
|
+
/** Variable name (may include $ prefix) */
|
|
74
|
+
varName: string;
|
|
75
|
+
/** Unique ID for tracking */
|
|
76
|
+
id: number;
|
|
77
|
+
/** Original text */
|
|
78
|
+
originalText?: string;
|
|
79
|
+
/** Start index in content */
|
|
80
|
+
startIndex?: number;
|
|
81
|
+
/** End index in content */
|
|
82
|
+
endIndex?: number;
|
|
83
|
+
/** Additional properties */
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Information about a single variable
|
|
88
|
+
*/
|
|
89
|
+
export interface VariableInfo {
|
|
90
|
+
/** Variable name */
|
|
91
|
+
name: string;
|
|
92
|
+
/** Whether the variable was successfully resolved */
|
|
93
|
+
resolved: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Statistics about variable processing
|
|
97
|
+
*/
|
|
98
|
+
export interface VariableStatistics {
|
|
99
|
+
/** Total number of variables in document */
|
|
100
|
+
totalVariables: number;
|
|
101
|
+
/** Number of unique variables */
|
|
102
|
+
uniqueCount: number;
|
|
103
|
+
/** Array of unique variable names */
|
|
104
|
+
uniqueVariables: string[];
|
|
105
|
+
/** Array of variable information */
|
|
106
|
+
variables: VariableInfo[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* DOMVariableHandler class
|
|
110
|
+
*/
|
|
111
|
+
declare class DOMVariableHandler {
|
|
112
|
+
/** WikiEngine instance */
|
|
113
|
+
private engine;
|
|
114
|
+
/** VariableManager instance (loaded dynamically) */
|
|
115
|
+
protected variableManager: VariableManager | null;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a new DOMVariableHandler
|
|
118
|
+
*
|
|
119
|
+
* @param {WikiEngine} engine - WikiEngine instance
|
|
120
|
+
*/
|
|
121
|
+
constructor(engine: WikiEngine);
|
|
122
|
+
/**
|
|
123
|
+
* Initializes the handler
|
|
124
|
+
*/
|
|
125
|
+
initialize(): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Processes variables in a WikiDocument
|
|
128
|
+
*
|
|
129
|
+
* Queries for .wiki-variable elements and resolves their values.
|
|
130
|
+
* This is the DOM-based equivalent of VariableManager.expandVariables()
|
|
131
|
+
*
|
|
132
|
+
* @param {WikiDocument} wikiDocument - The WikiDocument to process
|
|
133
|
+
* @param {VariableContext} context - Rendering context
|
|
134
|
+
* @returns {Promise<WikiDocument>} Updated WikiDocument
|
|
135
|
+
*/
|
|
136
|
+
processVariables(wikiDocument: WikiDocument, context: VariableContext): Promise<WikiDocument>;
|
|
137
|
+
/**
|
|
138
|
+
* Resolves a variable name to its value
|
|
139
|
+
*
|
|
140
|
+
* @param {string} varName - Variable name (without {$ })
|
|
141
|
+
* @param {VariableContext} context - Rendering context
|
|
142
|
+
* @returns {string | number | null} Variable value or null if not found
|
|
143
|
+
*/
|
|
144
|
+
resolveVariable(varName: string, context: VariableContext): string | number | null;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a DOM node from an extracted variable element
|
|
147
|
+
*
|
|
148
|
+
* This method is part of the Phase 2 extraction-based parsing (Issue #114).
|
|
149
|
+
* It creates a variable node from a pre-extracted element instead of
|
|
150
|
+
* parsing it from tokens.
|
|
151
|
+
*
|
|
152
|
+
* @param {ExtractedElement} element - Extracted element from extractJSPWikiSyntax()
|
|
153
|
+
* @param {VariableContext} context - Rendering context
|
|
154
|
+
* @param {WikiDocument} wikiDocument - WikiDocument to create node in
|
|
155
|
+
* @returns {Promise<Element>} DOM node for the variable
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* const element = { type: 'variable', varName: '$username', id: 0, ... };
|
|
159
|
+
* const node = await handler.createNodeFromExtract(element, context, wikiDoc);
|
|
160
|
+
* // Returns: <span class="wiki-variable" data-variable="username">JohnDoe</span>
|
|
161
|
+
*/
|
|
162
|
+
createNodeFromExtract(element: ExtractedElement, context: VariableContext, wikiDocument: WikiDocument): Promise<LinkedomElement>;
|
|
163
|
+
/**
|
|
164
|
+
* Gets statistics about variable processing
|
|
165
|
+
*
|
|
166
|
+
* @param {WikiDocument} wikiDocument - Document to analyze
|
|
167
|
+
* @returns {VariableStatistics} Statistics
|
|
168
|
+
*/
|
|
169
|
+
getStatistics(wikiDocument: WikiDocument): VariableStatistics;
|
|
170
|
+
}
|
|
171
|
+
export default DOMVariableHandler;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import type ParseContext from '../context/ParseContext.js';
|
|
2
|
+
import type { FilterValidationError } from './FilterChain.js';
|
|
3
|
+
/**
|
|
4
|
+
* BaseFilter - Abstract base class for all content filters with modular configuration
|
|
5
|
+
*
|
|
6
|
+
* Provides the foundation for content filtering with complete modularity through
|
|
7
|
+
* app-default-config.json and app-custom-config.json configuration support.
|
|
8
|
+
*
|
|
9
|
+
* Design Principles:
|
|
10
|
+
* - Complete configuration modularity and reusability
|
|
11
|
+
* - Zero hardcoded values - everything configurable
|
|
12
|
+
* - Consistent interface across all filter types
|
|
13
|
+
* - Performance monitoring and error handling
|
|
14
|
+
* - Security-first design with configurable validation
|
|
15
|
+
*
|
|
16
|
+
* Related Issue: Phase 4 - Filter Pipeline Core
|
|
17
|
+
* Epic: #41 - Implement JSPWikiMarkupParser for Complete Enhancement Support
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Pipeline phase a filter operates in (#614).
|
|
21
|
+
*
|
|
22
|
+
* - `'markup'` (default) — runs on raw markdown/JSPWiki content before
|
|
23
|
+
* markdown rendering. ValidationFilter, SpamFilter operate here.
|
|
24
|
+
* - `'html'` — runs on rendered HTML after markdown-it. SecurityFilter
|
|
25
|
+
* (XSS prevention, dangerous-tag stripping, attribute allow-listing)
|
|
26
|
+
* operates here, since its rules target HTML constructs that don't
|
|
27
|
+
* exist in raw markdown.
|
|
28
|
+
*/
|
|
29
|
+
export type FilterPhase = 'markup' | 'html';
|
|
30
|
+
/**
|
|
31
|
+
* Filter configuration options
|
|
32
|
+
*/
|
|
33
|
+
export interface FilterOptions {
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
cacheResults?: boolean;
|
|
37
|
+
cacheTTL?: number;
|
|
38
|
+
version?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
category?: string;
|
|
41
|
+
phase?: FilterPhase;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Filter performance statistics
|
|
45
|
+
*/
|
|
46
|
+
export interface FilterStats {
|
|
47
|
+
executionCount: number;
|
|
48
|
+
totalTime: number;
|
|
49
|
+
errorCount: number;
|
|
50
|
+
lastExecuted: Date | null;
|
|
51
|
+
averageTime: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Filter configuration (from config files)
|
|
55
|
+
*/
|
|
56
|
+
export interface FilterConfig {
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
priority: number;
|
|
59
|
+
timeout: number;
|
|
60
|
+
cacheResults: boolean;
|
|
61
|
+
cacheTTL: number;
|
|
62
|
+
reportErrors: boolean;
|
|
63
|
+
logLevel: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Filter metadata
|
|
67
|
+
*/
|
|
68
|
+
export interface FilterMetadata {
|
|
69
|
+
id: string;
|
|
70
|
+
version: string;
|
|
71
|
+
description: string;
|
|
72
|
+
category: string;
|
|
73
|
+
priority: number;
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
options: Required<FilterOptions>;
|
|
76
|
+
stats: FilterStats & {
|
|
77
|
+
filterId: string;
|
|
78
|
+
priority: number;
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
initialized: boolean;
|
|
81
|
+
category: string;
|
|
82
|
+
};
|
|
83
|
+
configuration: FilterConfig | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Filter error context
|
|
87
|
+
*/
|
|
88
|
+
export interface FilterErrorContext {
|
|
89
|
+
filterId: string;
|
|
90
|
+
error: string;
|
|
91
|
+
stack?: string;
|
|
92
|
+
contentLength: number;
|
|
93
|
+
contentPreview: string;
|
|
94
|
+
context: {
|
|
95
|
+
pageName?: string;
|
|
96
|
+
userName?: string;
|
|
97
|
+
};
|
|
98
|
+
stats: FilterStats;
|
|
99
|
+
timestamp: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Configuration summary
|
|
103
|
+
*/
|
|
104
|
+
export interface ConfigurationSummary {
|
|
105
|
+
filterId: string;
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
priority: number;
|
|
108
|
+
configuration: FilterConfig | null;
|
|
109
|
+
configurationSource: 'loaded' | 'defaults';
|
|
110
|
+
options: Required<FilterOptions>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Initialization context (minimal interface for unconverted dependencies)
|
|
114
|
+
*/
|
|
115
|
+
export interface FilterInitializationContext {
|
|
116
|
+
engine?: {
|
|
117
|
+
getManager(name: string): unknown;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* ParseContext re-export — the real class from `../context/ParseContext.js`.
|
|
122
|
+
* Kept as a re-export so existing filters can keep their
|
|
123
|
+
* `import { ParseContext }` paths unchanged. (#629 Pass 2)
|
|
124
|
+
*/
|
|
125
|
+
export type { ParseContext };
|
|
126
|
+
/**
|
|
127
|
+
* BaseFilter - Abstract base class for all content filters
|
|
128
|
+
*/
|
|
129
|
+
declare abstract class BaseFilter {
|
|
130
|
+
priority: number;
|
|
131
|
+
readonly filterId: string;
|
|
132
|
+
readonly version: string;
|
|
133
|
+
readonly description: string;
|
|
134
|
+
readonly category: string;
|
|
135
|
+
readonly phase: FilterPhase;
|
|
136
|
+
protected options: Required<FilterOptions>;
|
|
137
|
+
protected stats: FilterStats;
|
|
138
|
+
protected enabled: boolean;
|
|
139
|
+
protected initialized: boolean;
|
|
140
|
+
protected config: FilterConfig | null;
|
|
141
|
+
/**
|
|
142
|
+
* Create a content filter
|
|
143
|
+
* @param priority - Filter priority (0-1000, higher = executed first)
|
|
144
|
+
* @param options - Filter configuration options
|
|
145
|
+
*/
|
|
146
|
+
constructor(priority?: number, options?: FilterOptions);
|
|
147
|
+
/**
|
|
148
|
+
* Initialize filter with modular configuration
|
|
149
|
+
* @param context - Initialization context
|
|
150
|
+
*/
|
|
151
|
+
initialize(context?: FilterInitializationContext): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Load configuration from app-default-config.json and app-custom-config.json
|
|
154
|
+
* @param context - Initialization context
|
|
155
|
+
*/
|
|
156
|
+
protected loadModularConfiguration(context: FilterInitializationContext): void;
|
|
157
|
+
/**
|
|
158
|
+
* Get filter type for configuration lookup (override in subclasses)
|
|
159
|
+
* @returns Filter type for configuration
|
|
160
|
+
*/
|
|
161
|
+
protected getFilterType(): string | null;
|
|
162
|
+
/**
|
|
163
|
+
* Custom initialization logic (override in subclasses)
|
|
164
|
+
* @param _context - Initialization context
|
|
165
|
+
*/
|
|
166
|
+
protected onInitialize(_context: FilterInitializationContext): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Main filter processing method - MUST be implemented by subclasses
|
|
169
|
+
* @param content - Content to filter
|
|
170
|
+
* @param context - Parse context
|
|
171
|
+
* @returns Filtered content
|
|
172
|
+
*/
|
|
173
|
+
abstract process(content: string, context: ParseContext): Promise<string>;
|
|
174
|
+
/**
|
|
175
|
+
* Rule violations that must BLOCK a page save — MUST be implemented by
|
|
176
|
+
* subclasses (#1037).
|
|
177
|
+
*
|
|
178
|
+
* Abstract on purpose. `FilterChain.collectErrors()` calls this on every
|
|
179
|
+
* enabled filter, but skipped any filter that did not define it, so a filter
|
|
180
|
+
* could opt out of save-time enforcement by simply not having the method —
|
|
181
|
+
* invisibly, with nothing to grep for. SecurityFilter and SpamFilter both
|
|
182
|
+
* did exactly that, which is why a page containing `<script>` saved cleanly
|
|
183
|
+
* while a filter that would have caught it was enabled and running.
|
|
184
|
+
*
|
|
185
|
+
* Declaring it here turns that silence into a compile error. A filter that
|
|
186
|
+
* genuinely blocks nothing returns `[]` — one explicit line stating a
|
|
187
|
+
* position, rather than an absence nobody notices.
|
|
188
|
+
*
|
|
189
|
+
* Note the input: at save time this receives the page SOURCE, not rendered
|
|
190
|
+
* HTML, regardless of the filter's `phase`. A filter whose `process()` works
|
|
191
|
+
* on rendered output must not reuse that logic here — assuming otherwise is
|
|
192
|
+
* what made SecurityFilter's `preventXSS()` entity-encode whole documents.
|
|
193
|
+
*
|
|
194
|
+
* Only `severity: 'error'` belongs here. Warnings are surfaced at render
|
|
195
|
+
* time and must never stop a save.
|
|
196
|
+
*
|
|
197
|
+
* @param content - The page source about to be written
|
|
198
|
+
* @param context - Parse context (pageName, userName, engine)
|
|
199
|
+
* @returns Blocking violations; empty when the content is acceptable
|
|
200
|
+
*/
|
|
201
|
+
abstract collectErrors(content: string, context: ParseContext): Promise<FilterValidationError[]>;
|
|
202
|
+
/**
|
|
203
|
+
* Execute filter with performance tracking and error handling
|
|
204
|
+
* @param content - Content to process
|
|
205
|
+
* @param context - Parse context
|
|
206
|
+
* @returns Processed content
|
|
207
|
+
*/
|
|
208
|
+
execute(content: string, context: ParseContext): Promise<string>;
|
|
209
|
+
/**
|
|
210
|
+
* Create error context for debugging (modular error handling)
|
|
211
|
+
* @param error - The error that occurred
|
|
212
|
+
* @param content - Content being processed
|
|
213
|
+
* @param context - Parse context
|
|
214
|
+
* @returns Error context
|
|
215
|
+
*/
|
|
216
|
+
protected createErrorContext(error: Error, content: string, context: ParseContext): FilterErrorContext;
|
|
217
|
+
/**
|
|
218
|
+
* Enable the filter
|
|
219
|
+
*/
|
|
220
|
+
enable(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Disable the filter
|
|
223
|
+
*/
|
|
224
|
+
disable(): void;
|
|
225
|
+
/**
|
|
226
|
+
* Check if filter is enabled
|
|
227
|
+
* @returns True if enabled
|
|
228
|
+
*/
|
|
229
|
+
isEnabled(): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Get filter statistics
|
|
232
|
+
* @returns Filter statistics
|
|
233
|
+
*/
|
|
234
|
+
getStats(): FilterStats & {
|
|
235
|
+
filterId: string;
|
|
236
|
+
priority: number;
|
|
237
|
+
enabled: boolean;
|
|
238
|
+
initialized: boolean;
|
|
239
|
+
category: string;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Reset filter statistics
|
|
243
|
+
*/
|
|
244
|
+
resetStats(): void;
|
|
245
|
+
/**
|
|
246
|
+
* Get filter metadata
|
|
247
|
+
* @returns Filter metadata
|
|
248
|
+
*/
|
|
249
|
+
getMetadata(): FilterMetadata;
|
|
250
|
+
/**
|
|
251
|
+
* Get configuration summary for debugging (modular introspection)
|
|
252
|
+
* @returns Configuration summary
|
|
253
|
+
*/
|
|
254
|
+
getConfigurationSummary(): ConfigurationSummary;
|
|
255
|
+
/**
|
|
256
|
+
* Clean up filter resources (optional override)
|
|
257
|
+
*/
|
|
258
|
+
shutdown(): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Custom shutdown logic (override in subclasses)
|
|
261
|
+
*/
|
|
262
|
+
protected onShutdown(): Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* String representation of filter
|
|
265
|
+
* @returns String representation
|
|
266
|
+
*/
|
|
267
|
+
toString(): string;
|
|
268
|
+
}
|
|
269
|
+
export default BaseFilter;
|