1- type X2jOptions = {
1+ type ProcessEntitiesOptions = {
2+ /**
3+ * Whether to enable entity processing
4+ *
5+ * Defaults to `true`
6+ */
7+ enabled ?: boolean ;
8+
9+ /**
10+ * Maximum size in characters for a single entity definition
11+ *
12+ * Defaults to `10000`
13+ */
14+ maxEntitySize ?: number ;
15+
16+ /**
17+ * Maximum depth for nested entity references (reserved for future use)
18+ *
19+ * Defaults to `10`
20+ */
21+ maxExpansionDepth ?: number ;
22+
23+ /**
24+ * Maximum total number of entity expansions allowed
25+ *
26+ * Defaults to `1000`
27+ */
28+ maxTotalExpansions ?: number ;
29+
30+ /**
31+ * Maximum total expanded content length in characters
32+ *
33+ * Defaults to `100000`
34+ */
35+ maxExpandedLength ?: number ;
36+
37+ /**
38+ * Array of tag names where entity replacement is allowed.
39+ * If null, entities are replaced in all tags.
40+ *
41+ * Defaults to `null`
42+ */
43+ allowedTags ?: string [ ] | null ;
44+
45+ /**
46+ * Custom filter function to determine if entities should be replaced in a tag
47+ *
48+ * @param tagName - The name of the current tag
49+ * @param jPath - The jPath of the current tag
50+ * @returns `true` to allow entity replacement, `false` to skip
51+ *
52+ * Defaults to `null`
53+ */
54+ tagFilter ?: ( ( tagName : string , jPath : string ) => boolean ) | null ;
55+ } ;
56+
57+ export type X2jOptions = {
258 /**
359 * Preserve the order of tags in resulting JS object
460 *
@@ -10,7 +66,7 @@ type X2jOptions = {
1066 * Give a prefix to the attribute name in the resulting JS object
1167 *
1268 * Defaults to '@_'
13- */
69+ */
1470 attributeNamePrefix ?: string ;
1571
1672 /**
@@ -64,7 +120,7 @@ type X2jOptions = {
64120 parseTagValue ?: boolean ;
65121
66122 /**
67- * Whether to parse tag value with `strnum` package
123+ * Whether to parse attribute value with `strnum` package
68124 *
69125 * Defaults to `false`
70126 */
@@ -161,9 +217,15 @@ type X2jOptions = {
161217 /**
162218 * Whether to process default and DOCTYPE entities
163219 *
220+ * When `true` - enables entity processing with default limits
221+ *
222+ * When `false` - disables all entity processing
223+ *
224+ * When `ProcessEntitiesOptions` - enables entity processing with custom configuration
225+ *
164226 * Defaults to `true`
165227 */
166- processEntities ?: boolean ;
228+ processEntities ?: boolean | ProcessEntitiesOptions ;
167229
168230 /**
169231 * Whether to process HTML entities
@@ -209,7 +271,7 @@ type X2jOptions = {
209271 *
210272 * Defaults to `(tagName, jPath, attrs) => tagName`
211273 */
212- updateTag ?: ( tagName : string , jPath : string , attrs : { [ k : string ] : string } ) => string | boolean ;
274+ updateTag ?: ( tagName : string , jPath : string , attrs : { [ k : string ] : string } ) => string | boolean ;
213275
214276 /**
215277 * If true, adds a Symbol to all object nodes, accessible by {@link XMLParser.getMetaDataSymbol} with
@@ -232,7 +294,7 @@ type validationOptions = {
232294 * Defaults to `false`
233295 */
234296 allowBooleanAttributes ?: boolean ;
235-
297+
236298 /**
237299 * List of tags without closing tags
238300 *
@@ -246,7 +308,7 @@ type XmlBuilderOptions = {
246308 * Give a prefix to the attribute name in the resulting JS object
247309 *
248310 * Defaults to '@_'
249- */
311+ */
250312 attributeNamePrefix ?: string ;
251313
252314 /**
@@ -393,20 +455,20 @@ type XmlBuilderOptions = {
393455 oneListGroup ?: boolean ;
394456} ;
395457
396- type ESchema = string | object | Array < string | object > ;
458+ type ESchema = string | object | Array < string | object > ;
397459
398460type ValidationError = {
399- err : {
461+ err : {
400462 code : string ;
401463 msg : string ,
402464 line : number ,
403- col : number
465+ col : number
404466 } ;
405467} ;
406468
407469declare class XMLParser {
408470 constructor ( options ?: X2jOptions ) ;
409- parse ( xmlData : string | Uint8Array , validationOptions ?: validationOptions | boolean ) : any ;
471+ parse ( xmlData : string | Uint8Array , validationOptions ?: validationOptions | boolean ) : any ;
410472 /**
411473 * Add Entity which is not by default supported by this library
412474 * @param entityIdentifier {string} Eg: 'ent' for &ent;
@@ -424,10 +486,10 @@ declare class XMLParser {
424486 * The XMLMetaData property is only present when {@link X2jOptions.captureMetaData}
425487 * is true in the options.
426488 */
427- static getMetaDataSymbol ( ) : Symbol ;
489+ static getMetaDataSymbol ( ) : Symbol ;
428490}
429491
430- declare class XMLValidator {
492+ declare class XMLValidator {
431493 static validate ( xmlData : string , options ?: validationOptions ) : true | ValidationError ;
432494}
433495
@@ -458,6 +520,7 @@ declare namespace fxp {
458520 ValidationError ,
459521 strnumOptions ,
460522 validationOptions ,
523+ ProcessEntitiesOptions ,
461524 }
462525}
463526
0 commit comments