@ygracs/xobj-lib-js 0.2.4 → 0.2.6-b
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/CHANGELOG.md +8 -0
- package/doc/xObj.md +80 -26
- package/index.d.ts +76 -0
- package/index.js +11 -2
- package/lib/xObj-defs.d.ts +142 -0
- package/lib/xObj-defs.js +100 -43
- package/lib/xObj-errors.d.ts +41 -0
- package/lib/xObj-errors.js +71 -0
- package/lib/xObj-lib.d.ts +297 -0
- package/lib/xObj-lib.js +94 -101
- package/package.json +13 -6
package/CHANGELOG.md
CHANGED
package/doc/xObj.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.46|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|2025-
|
|
3
|
+
>|date:|2025-12-14|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -36,6 +36,58 @@ The behavior for `letterCase` settings defined in the table below:
|
|
|
36
36
|
| `lower` | the resulting string must to be present in lower case |
|
|
37
37
|
| any other values | the resulting string will be not transformed |
|
|
38
38
|
|
|
39
|
+
<a name="typedef+xml2jsParseOptions"></a>
|
|
40
|
+
#### `xml2jsParseOptions` - parser options set
|
|
41
|
+
|
|
42
|
+
This options set is an `object` which defines how an 'XML'-string transforms into a 'JS'-object.
|
|
43
|
+
|
|
44
|
+
| option name | value type | optional | description |
|
|
45
|
+
|:---|---|---:|:---|
|
|
46
|
+
| `compact` | `boolean` | `yes` ||
|
|
47
|
+
| `declarationKey` | `string` | `yes` ||
|
|
48
|
+
| `attributesKey` | `string` | `yes` ||
|
|
49
|
+
| `textKey` | `string` | `yes` ||
|
|
50
|
+
| `commentKey` | `string` | `yes` ||
|
|
51
|
+
| `cdataKey` | `string` | `yes` ||
|
|
52
|
+
| `nameKey` | `string` | `yes` ||
|
|
53
|
+
| `typeKey` | `string` | `yes` ||
|
|
54
|
+
| `parentKey` | `string` | `yes` ||
|
|
55
|
+
| `elementsKey` | `string` | `yes` ||
|
|
56
|
+
| `ignoreDeclaration` | `boolean` | `yes` ||
|
|
57
|
+
| `ignoreDocType` | `boolean` | `yes` ||
|
|
58
|
+
| `ignoreInstraction` | `boolean` | `yes` ||
|
|
59
|
+
| `ignoreText` | `boolean` | `yes` ||
|
|
60
|
+
| `ignoreComment` | `boolean` | `yes` ||
|
|
61
|
+
| `ignoreCData` | `boolean` | `yes` ||
|
|
62
|
+
| `addParent` | `boolean` | `yes` ||
|
|
63
|
+
| `trim` | `boolean` | `yes` ||
|
|
64
|
+
|
|
65
|
+
<a name="typedef+js2xmlParseOptions"></a>
|
|
66
|
+
#### `js2xmlParseOptions` - parser options set
|
|
67
|
+
|
|
68
|
+
This options set is an `object` which defines how a 'JS'-object transforms into an 'XML'-string.
|
|
69
|
+
|
|
70
|
+
| option name | value type | optional | description |
|
|
71
|
+
|:---|---|---:|:---|
|
|
72
|
+
| `compact` | `boolean` | `yes` ||
|
|
73
|
+
| `declarationKey` | `string` | `yes` ||
|
|
74
|
+
| `attributesKey` | `string` | `yes` ||
|
|
75
|
+
| `textKey` | `string` | `yes` ||
|
|
76
|
+
| `commentKey` | `string` | `yes` ||
|
|
77
|
+
| `cdataKey` | `string` | `yes` ||
|
|
78
|
+
| `nameKey` | `string` | `yes` ||
|
|
79
|
+
| `typeKey` | `string` | `yes` ||
|
|
80
|
+
| `parentKey` | `string` | `yes` ||
|
|
81
|
+
| `elementsKey` | `string` | `yes` ||
|
|
82
|
+
| `ignoreDeclaration` | `boolean` | `yes` ||
|
|
83
|
+
| `ignoreDocType` | `boolean` | `yes` ||
|
|
84
|
+
| `ignoreInstraction` | `boolean` | `yes` ||
|
|
85
|
+
| `ignoreText` | `boolean` | `yes` ||
|
|
86
|
+
| `ignoreComment` | `boolean` | `yes` ||
|
|
87
|
+
| `ignoreCData` | `boolean` | `yes` ||
|
|
88
|
+
| `fullTagEmptyElement` | `boolean` | `yes` ||
|
|
89
|
+
| `spaces` | `number` | `yes` ||
|
|
90
|
+
|
|
39
91
|
### Base constants
|
|
40
92
|
|
|
41
93
|
|name|type|value|
|
|
@@ -50,28 +102,30 @@ This constant object provided by the module contains a default settings of optio
|
|
|
50
102
|
|
|
51
103
|
The settings listed in the table below:
|
|
52
104
|
|
|
53
|
-
|name|type|value|
|
|
54
|
-
|
|
55
|
-
|compact
|
|
56
|
-
|declarationKey
|
|
57
|
-
|attributesKey
|
|
58
|
-
|textKey
|
|
59
|
-
|commentKey
|
|
60
|
-
|cdataKey
|
|
61
|
-
|nameKey
|
|
62
|
-
|typeKey
|
|
63
|
-
|parentKey
|
|
64
|
-
|elementsKey
|
|
65
|
-
|ignoreDeclaration
|
|
66
|
-
|ignoreDocType
|
|
67
|
-
|ignoreInstractions
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
105
|
+
| name | value type | value | description |
|
|
106
|
+
|:---|---|---:|:---|
|
|
107
|
+
| `compact` | `boolean` | `true` ||
|
|
108
|
+
| `declarationKey` | `string` | `__decl` ||
|
|
109
|
+
| `attributesKey` | `string` | `__attr` ||
|
|
110
|
+
| `textKey` | `string` | `__text` ||
|
|
111
|
+
| `commentKey` | `string` | `__note` ||
|
|
112
|
+
| `cdataKey` | `string` | `__cdata` ||
|
|
113
|
+
| `nameKey` | `string` | `__name` ||
|
|
114
|
+
| `typeKey` | `string` | `__type` ||
|
|
115
|
+
| `parentKey` | `string` | `parent` ||
|
|
116
|
+
| `elementsKey` | `string` | `items` ||
|
|
117
|
+
| `ignoreDeclaration` | `boolean` | `false` ||
|
|
118
|
+
| `ignoreDocType` | `boolean` | `false` ||
|
|
119
|
+
| `ignoreInstractions` | `boolean` | `false` | \<*deprecated*> (*use `ignoreInstraction` instead*) |
|
|
120
|
+
| `ignoreInstraction` | `boolean` | `false` ||
|
|
121
|
+
| `ignoreText` | `boolean` | `false` ||
|
|
122
|
+
| `ignoreComments` | `boolean` | `false` | \<*deprecated*> (*use `ignoreComment` instead*) |
|
|
123
|
+
| `ignoreComment` | `boolean` | `false` ||
|
|
124
|
+
| `ignoreCData` | `boolean` | `false` ||
|
|
125
|
+
| `fullTagEmptyElement` | `boolean` | `true` ||
|
|
126
|
+
| `addParent` | `boolean` | `false` ||
|
|
127
|
+
| `trim` | `boolean` | `true` ||
|
|
128
|
+
| `spaces` | `number` | `2` ||
|
|
75
129
|
|
|
76
130
|
### Base functions for read an object parameter value
|
|
77
131
|
|
|
@@ -1176,14 +1230,14 @@ The class constructor receives an arguments listed below:
|
|
|
1176
1230
|
|
|
1177
1231
|
| property type | read only | description |
|
|
1178
1232
|
|---|---|:---|
|
|
1179
|
-
| `
|
|
1233
|
+
| `xml2jsParseOptions` | yes | returns an options for an XML-to-JS converter |
|
|
1180
1234
|
|
|
1181
1235
|
<a name="TXmlContentParseOptions+js2xml"></a>
|
|
1182
1236
|
###### **js2xml**
|
|
1183
1237
|
|
|
1184
1238
|
| property type | read only | description |
|
|
1185
1239
|
|---|---|:---|
|
|
1186
|
-
| `
|
|
1240
|
+
| `js2xmlParseOptions` | yes | returns an options for a JS-to-XML converter |
|
|
1187
1241
|
|
|
1188
1242
|
<a name="TXmlContentParseOptions+reservedKeys"></a>
|
|
1189
1243
|
###### **reservedKeys**
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
declare const _exports: {
|
|
2
|
+
readXObjParamRaw: typeof import("./lib/xObj-lib").readXObjParamRaw;
|
|
3
|
+
readXObjParam: typeof import("./lib/xObj-lib").readXObjParam;
|
|
4
|
+
readXObjParamAsBool: typeof import("./lib/xObj-lib").readXObjParamAsBool;
|
|
5
|
+
readXObjParamAsNum: typeof import("./lib/xObj-lib").readXObjParamAsNum;
|
|
6
|
+
readXObjParamEx: typeof import("./lib/xObj-lib").readXObjParamEx;
|
|
7
|
+
readXObjParamAsIndex: typeof import("./lib/xObj-lib").readXObjParamAsIndex;
|
|
8
|
+
writeXObjParamRaw: typeof import("./lib/xObj-lib").writeXObjParamRaw;
|
|
9
|
+
writeXObjParam: typeof import("./lib/xObj-lib").writeXObjParam;
|
|
10
|
+
writeXObjParamAsBool: typeof import("./lib/xObj-lib").writeXObjParamAsBool;
|
|
11
|
+
writeXObjParamAsNum: typeof import("./lib/xObj-lib").writeXObjParamAsNum;
|
|
12
|
+
writeXObjParamAsIndex: typeof import("./lib/xObj-lib").writeXObjParamAsIndex;
|
|
13
|
+
writeXObjParamEx: typeof import("./lib/xObj-lib").writeXObjParamEx;
|
|
14
|
+
readXObjAttrRaw: typeof import("./lib/xObj-lib").readXObjAttrRaw;
|
|
15
|
+
readXObjAttr: typeof import("./lib/xObj-lib").readXObjAttr;
|
|
16
|
+
readXObjAttrAsBool: typeof import("./lib/xObj-lib").readXObjAttrAsBool;
|
|
17
|
+
readXObjAttrAsNum: typeof import("./lib/xObj-lib").readXObjAttrAsNum;
|
|
18
|
+
readXObjAttrEx: typeof import("./lib/xObj-lib").readXObjAttrEx;
|
|
19
|
+
readXObjAttrAsIndex: typeof import("./lib/xObj-lib").readXObjAttrAsIndex;
|
|
20
|
+
writeXObjAttrRaw: typeof import("./lib/xObj-lib").writeXObjAttrRaw;
|
|
21
|
+
writeXObjAttr: typeof import("./lib/xObj-lib").writeXObjAttr;
|
|
22
|
+
writeXObjAttrAsBool: typeof import("./lib/xObj-lib").writeXObjAttrAsBool;
|
|
23
|
+
writeXObjAttrAsNum: typeof import("./lib/xObj-lib").writeXObjAttrAsNum;
|
|
24
|
+
writeXObjAttrAsIndex: typeof import("./lib/xObj-lib").writeXObjAttrAsIndex;
|
|
25
|
+
writeXObjAttrEx: typeof import("./lib/xObj-lib").writeXObjAttrEx;
|
|
26
|
+
getXObjAttributes: typeof import("./lib/xObj-lib").getXObjAttributes;
|
|
27
|
+
checkXObjAttribute: typeof import("./lib/xObj-lib").checkXObjAttribute;
|
|
28
|
+
deleteXObjAttribute: typeof import("./lib/xObj-lib").deleteXObjAttribute;
|
|
29
|
+
renameXObjAttribute: typeof import("./lib/xObj-lib").renameXObjAttribute;
|
|
30
|
+
getXObjElement: typeof import("./lib/xObj-lib").getXObjElement;
|
|
31
|
+
addXObjElement: typeof import("./lib/xObj-lib").addXObjElement;
|
|
32
|
+
insertXObjElement: typeof import("./lib/xObj-lib").insertXObjElement;
|
|
33
|
+
insertXObjElementEx: typeof import("./lib/xObj-lib").insertXObjElementEx;
|
|
34
|
+
deleteXObjElement: typeof import("./lib/xObj-lib").deleteXObjElement;
|
|
35
|
+
deleteXObjElementEx: typeof import("./lib/xObj-lib").deleteXObjElementEx;
|
|
36
|
+
renameXObjElement: typeof import("./lib/xObj-lib").renameXObjElement;
|
|
37
|
+
evalXObjEName: typeof import("./lib/xObj-lib").evalXObjEName;
|
|
38
|
+
insertXObjEList: typeof import("./lib/xObj-lib").insertXObjEList;
|
|
39
|
+
insertXObjEListEx: typeof import("./lib/xObj-lib").insertXObjEListEx;
|
|
40
|
+
evalKeyName: typeof import("./lib/xObj-lib").evalKeyName;
|
|
41
|
+
genXObjENameDescr: typeof import("./lib/xObj-lib").genXObjENameDescr;
|
|
42
|
+
insertXObjElements: typeof import("./lib/xObj-lib").insertXObjElements;
|
|
43
|
+
insertXObjEChain: typeof import("./lib/xObj-lib").insertXObjEChain;
|
|
44
|
+
TXmlContentParseOptions: typeof TXmlContentParseOptions;
|
|
45
|
+
DEF_XML_PARSE_OPTIONS: typeof DEF_XML_PARSE_OPTIONS;
|
|
46
|
+
XOBJ_DEF_TNAMES: typeof XOBJ_DEF_TNAMES;
|
|
47
|
+
EvalKeyNameError: typeof EvalKeyNameError;
|
|
48
|
+
|
|
49
|
+
xml2jsParseOptions: xml2jsParseOptions;
|
|
50
|
+
js2xmlParseOptions: js2xmlParseOptions;
|
|
51
|
+
OPT_parserOptions: OPT_parserOptions;
|
|
52
|
+
|
|
53
|
+
XObjENameDescr: XObjENameDescr;
|
|
54
|
+
OPT_inselops_L: OPT_inselops_L;
|
|
55
|
+
OPT_inselops_S: OPT_inselops_S;
|
|
56
|
+
RVAL_reason: RVAL_reason;
|
|
57
|
+
RVAL_emodif: RVAL_emodif;
|
|
58
|
+
VCOR_evalkname: VCOR_evalkname;
|
|
59
|
+
};
|
|
60
|
+
export = _exports;
|
|
61
|
+
import { TXmlContentParseOptions } from "./lib/xObj-defs";
|
|
62
|
+
import { DEF_XML_PARSE_OPTIONS } from "./lib/xObj-defs";
|
|
63
|
+
import { XOBJ_DEF_TNAMES } from "./lib/xObj-defs";
|
|
64
|
+
import { EvalKeyNameError } from "./lib/xObj-errors";
|
|
65
|
+
|
|
66
|
+
import type {
|
|
67
|
+
xml2jsParseOptions, js2xmlParseOptions,
|
|
68
|
+
OPT_parserOptions,
|
|
69
|
+
} from "./lib/xObj-defs";
|
|
70
|
+
|
|
71
|
+
import type {
|
|
72
|
+
XObjENameDescr,
|
|
73
|
+
OPT_inselops_L, OPT_inselops_S,
|
|
74
|
+
RVAL_reason, RVAL_emodif,
|
|
75
|
+
VCOR_evalkname,
|
|
76
|
+
} from "./lib/xObj-lib";
|
package/index.js
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.014-20251228]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
TXmlContentParseOptions,
|
|
7
7
|
DEF_XML_PARSE_OPTIONS,
|
|
8
|
+
XOBJ_DEF_TNAMES,
|
|
8
9
|
} = require('./lib/xObj-defs');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const {
|
|
12
|
+
EvalKeyNameError,
|
|
13
|
+
} = require('./lib/xObj-errors');
|
|
14
|
+
|
|
15
|
+
// === module inner block ===
|
|
11
16
|
|
|
12
17
|
// === module main block ===
|
|
13
18
|
|
|
14
19
|
// === module exports block ===
|
|
15
20
|
|
|
16
21
|
module.exports = require('./lib/xObj-lib');
|
|
22
|
+
|
|
17
23
|
module.exports.TXmlContentParseOptions = TXmlContentParseOptions;
|
|
18
24
|
module.exports.DEF_XML_PARSE_OPTIONS = DEF_XML_PARSE_OPTIONS;
|
|
25
|
+
module.exports.XOBJ_DEF_TNAMES = XOBJ_DEF_TNAMES;
|
|
26
|
+
|
|
27
|
+
module.exports.EvalKeyNameError = EvalKeyNameError;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A parser options settings
|
|
3
|
+
*/
|
|
4
|
+
export type OPT_parserOptions = {
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
declarationKey?: string;
|
|
7
|
+
attributesKey?: string;
|
|
8
|
+
textKey?: string;
|
|
9
|
+
commentKey?: string;
|
|
10
|
+
cdataKey?: string;
|
|
11
|
+
nameKey?: string;
|
|
12
|
+
typeKey?: string;
|
|
13
|
+
parentKey?: string;
|
|
14
|
+
elementsKey?: string;
|
|
15
|
+
ignoreDeclaration?: boolean;
|
|
16
|
+
ignoreDocType?: boolean;
|
|
17
|
+
ignoreInstraction?: boolean;
|
|
18
|
+
ignoreText?: boolean;
|
|
19
|
+
ignoreComment?: boolean;
|
|
20
|
+
ignoreCData?: boolean;
|
|
21
|
+
fullTagEmptyElement?: boolean;
|
|
22
|
+
addParent?: boolean;
|
|
23
|
+
trim?: boolean;
|
|
24
|
+
spaces?: any;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A parser options to convert an 'XML'-string into a 'JS'-object
|
|
28
|
+
*/
|
|
29
|
+
export type xml2jsParseOptions = {
|
|
30
|
+
compact?: boolean;
|
|
31
|
+
declarationKey?: string;
|
|
32
|
+
attributesKey?: string;
|
|
33
|
+
textKey?: string;
|
|
34
|
+
commentKey?: string;
|
|
35
|
+
cdataKey?: string;
|
|
36
|
+
nameKey?: string;
|
|
37
|
+
typeKey?: string;
|
|
38
|
+
parentKey?: string;
|
|
39
|
+
elementsKey?: string;
|
|
40
|
+
ignoreDeclaration?: boolean;
|
|
41
|
+
ignoreDocType?: boolean;
|
|
42
|
+
ignoreInstraction?: boolean;
|
|
43
|
+
ignoreText?: boolean;
|
|
44
|
+
ignoreComment?: boolean;
|
|
45
|
+
ignoreCData?: boolean;
|
|
46
|
+
addParent?: boolean;
|
|
47
|
+
trim?: boolean;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A parser options to convert a 'JS'-object into an 'XML'-string
|
|
51
|
+
*/
|
|
52
|
+
export type js2xmlParseOptions = {
|
|
53
|
+
compact?: boolean;
|
|
54
|
+
declarationKey?: string;
|
|
55
|
+
attributesKey?: string;
|
|
56
|
+
textKey?: string;
|
|
57
|
+
commentKey?: string;
|
|
58
|
+
cdataKey?: string;
|
|
59
|
+
nameKey?: string;
|
|
60
|
+
typeKey?: string;
|
|
61
|
+
parentKey?: string;
|
|
62
|
+
elementsKey?: string;
|
|
63
|
+
ignoreDeclaration?: boolean;
|
|
64
|
+
ignoreDocType?: boolean;
|
|
65
|
+
ignoreInstraction?: boolean;
|
|
66
|
+
ignoreText?: boolean;
|
|
67
|
+
ignoreComment?: boolean;
|
|
68
|
+
ignoreCData?: boolean;
|
|
69
|
+
fullTagEmptyElement?: boolean;
|
|
70
|
+
spaces?: any;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const XOBJ_DEF_PARAM_TNAME: "__text";
|
|
74
|
+
export const XOBJ_DEF_ATTR_TNAME: "__attr";
|
|
75
|
+
export namespace XOBJ_DEF_TNAMES {
|
|
76
|
+
export { XOBJ_DEF_PARAM_TNAME };
|
|
77
|
+
export { XOBJ_DEF_ATTR_TNAME };
|
|
78
|
+
export { XOBJ_DEF_DECL_TNAME };
|
|
79
|
+
export { XOBJ_DEF_CDATA_TNAME };
|
|
80
|
+
}
|
|
81
|
+
export namespace DEF_XML_PARSE_OPTIONS {
|
|
82
|
+
export let compact: boolean;
|
|
83
|
+
export { XOBJ_DEF_DECL_TNAME as declarationKey };
|
|
84
|
+
export { XOBJ_DEF_ATTR_TNAME as attributesKey };
|
|
85
|
+
export { XOBJ_DEF_PARAM_TNAME as textKey };
|
|
86
|
+
export let commentKey: string;
|
|
87
|
+
export { XOBJ_DEF_CDATA_TNAME as cdataKey };
|
|
88
|
+
export let nameKey: string;
|
|
89
|
+
export let typeKey: string;
|
|
90
|
+
export let parentKey: string;
|
|
91
|
+
export let elementsKey: string;
|
|
92
|
+
export let ignoreDeclaration: boolean;
|
|
93
|
+
export let ignoreDocType: boolean;
|
|
94
|
+
/** @deprecated */
|
|
95
|
+
export let ignoreInstractions: boolean;
|
|
96
|
+
export let ignoreInstraction: boolean;
|
|
97
|
+
export let ignoreText: boolean;
|
|
98
|
+
/** @deprecated */
|
|
99
|
+
export let ignoreComments: boolean;
|
|
100
|
+
export let ignoreComment: boolean;
|
|
101
|
+
export let ignoreCData: boolean;
|
|
102
|
+
export let fullTagEmptyElement: boolean;
|
|
103
|
+
export let addParent: boolean;
|
|
104
|
+
export let trim: boolean;
|
|
105
|
+
export let spaces: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @classdesc Implements a container that provide a functionality to work
|
|
110
|
+
* with options for an XML-parser
|
|
111
|
+
*/
|
|
112
|
+
export class TXmlContentParseOptions {
|
|
113
|
+
/**
|
|
114
|
+
* Creates a container instance
|
|
115
|
+
*/
|
|
116
|
+
static createNewOptionsSet(opt?: any): OPT_parserOptions;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a container instance
|
|
119
|
+
*/
|
|
120
|
+
constructor(param?: any);
|
|
121
|
+
/**
|
|
122
|
+
* Contains a set of a current settings
|
|
123
|
+
*/
|
|
124
|
+
get settings(): OPT_parserOptions;
|
|
125
|
+
/**
|
|
126
|
+
* Contains a set of a settings for converting an 'XML' to 'JS'-object
|
|
127
|
+
*/
|
|
128
|
+
get xml2js(): xml2jsParseOptions;
|
|
129
|
+
/**
|
|
130
|
+
* Contains a set of a settings for converting an 'JS'-object to 'XML'
|
|
131
|
+
*/
|
|
132
|
+
get js2xml(): js2xmlParseOptions;
|
|
133
|
+
/**
|
|
134
|
+
* Contains a set of a reserved key words
|
|
135
|
+
*/
|
|
136
|
+
get reservedKeys(): Set<string>;
|
|
137
|
+
#private;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare const XOBJ_DEF_DECL_TNAME: "__decl";
|
|
141
|
+
declare const XOBJ_DEF_CDATA_TNAME: "__cdata";
|
|
142
|
+
export {};
|
package/lib/xObj-defs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.068-20251229]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
isPlainObject,
|
|
7
7
|
} = require('@ygracs/bsfoc-lib-js');
|
|
8
8
|
|
|
9
|
-
// === module
|
|
9
|
+
// === module inner block ===
|
|
10
10
|
|
|
11
11
|
// === module main block ===
|
|
12
12
|
|
|
@@ -16,52 +16,62 @@ const {
|
|
|
16
16
|
|
|
17
17
|
const XOBJ_DEF_PARAM_TNAME = '__text';
|
|
18
18
|
const XOBJ_DEF_ATTR_TNAME = '__attr';
|
|
19
|
+
const XOBJ_DEF_DECL_TNAME = '__decl';
|
|
20
|
+
const XOBJ_DEF_CDATA_TNAME = '__cdata';
|
|
19
21
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const XOBJ_TE_NSTR_EMSG = `${XOBJ_TE_INVARG_EMSG} (a string expected)`;
|
|
26
|
-
const XOBJ_TE_NSTR_ECODE = 'ERR_XOBJ_NSTR';
|
|
27
|
-
const XOBJ_TE_NPOBJ_EMSG = `${XOBJ_TE_INVARG_EMSG} (a plain object expected)`;
|
|
28
|
-
const XOBJ_TE_NPOBJ_ECODE = 'ERR_XOBJ_NPOBJ';
|
|
29
|
-
const XOBJ_TE_ANES_EMSG = '<attr_name> must be a non-empty string';
|
|
30
|
-
const XOBJ_TE_ANES_ECODE = 'ERR_XOBJ_INVARG_ATTR';
|
|
31
|
-
const XOBJ_TE_KNES_EMSG = '<key_name> must be a non-empty string';
|
|
32
|
-
const XOBJ_TE_KNES_ECODE = 'ERR_XOBJ_INVARG_KEY';
|
|
33
|
-
|
|
34
|
-
const XOBJ_ECODE_TABLE = {
|
|
35
|
-
XOBJ_TE_NOBJ_EMSG,
|
|
36
|
-
XOBJ_TE_NOBJ_ECODE,
|
|
37
|
-
XOBJ_TE_NARR_EMSG,
|
|
38
|
-
XOBJ_TE_NARR_ECODE,
|
|
39
|
-
XOBJ_TE_NSTR_EMSG,
|
|
40
|
-
XOBJ_TE_NSTR_ECODE,
|
|
41
|
-
XOBJ_TE_NPOBJ_EMSG,
|
|
42
|
-
XOBJ_TE_NPOBJ_ECODE,
|
|
43
|
-
XOBJ_TE_ANES_EMSG,
|
|
44
|
-
XOBJ_TE_ANES_ECODE,
|
|
45
|
-
XOBJ_TE_KNES_EMSG,
|
|
46
|
-
XOBJ_TE_KNES_ECODE,
|
|
22
|
+
const XOBJ_DEF_TNAMES = {
|
|
23
|
+
XOBJ_DEF_PARAM_TNAME,
|
|
24
|
+
XOBJ_DEF_ATTR_TNAME,
|
|
25
|
+
XOBJ_DEF_DECL_TNAME,
|
|
26
|
+
XOBJ_DEF_CDATA_TNAME,
|
|
47
27
|
};
|
|
48
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A parser options settings
|
|
31
|
+
* @typedef {Object} OPT_parserOptions
|
|
32
|
+
* @property {boolean} [compact]
|
|
33
|
+
* @property {string} [declarationKey]
|
|
34
|
+
* @property {string} [attributesKey]
|
|
35
|
+
* @property {string} [textKey]
|
|
36
|
+
* @property {string} [commentKey]
|
|
37
|
+
* @property {string} [cdataKey]
|
|
38
|
+
* @property {string} [nameKey]
|
|
39
|
+
* @property {string} [typeKey]
|
|
40
|
+
* @property {string} [parentKey]
|
|
41
|
+
* @property {string} [elementsKey]
|
|
42
|
+
* @property {boolean} [ignoreDeclaration]
|
|
43
|
+
* @property {boolean} [ignoreDocType]
|
|
44
|
+
* @property {boolean} [ignoreInstraction]
|
|
45
|
+
* @property {boolean} [ignoreText]
|
|
46
|
+
* @property {boolean} [ignoreComment]
|
|
47
|
+
* @property {boolean} [ignoreCData]
|
|
48
|
+
* @property {boolean} [fullTagEmptyElement]
|
|
49
|
+
* @property {boolean} [addParent]
|
|
50
|
+
* @property {boolean} [trim]
|
|
51
|
+
* @property {any} [spaces]
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/** @type {OPT_parserOptions} */
|
|
49
55
|
const DEF_XML_PARSE_OPTIONS = {
|
|
50
56
|
compact: true,
|
|
51
|
-
declarationKey:
|
|
57
|
+
declarationKey: XOBJ_DEF_DECL_TNAME,
|
|
52
58
|
attributesKey: XOBJ_DEF_ATTR_TNAME,
|
|
53
59
|
textKey: XOBJ_DEF_PARAM_TNAME,
|
|
54
60
|
commentKey: '__note',
|
|
55
|
-
cdataKey:
|
|
61
|
+
cdataKey: XOBJ_DEF_CDATA_TNAME,
|
|
56
62
|
nameKey: '__name',
|
|
57
63
|
typeKey: '__type',
|
|
58
64
|
parentKey: 'parent',
|
|
59
65
|
elementsKey: 'items',
|
|
60
66
|
ignoreDeclaration: false,
|
|
61
67
|
ignoreDocType: false,
|
|
68
|
+
/** @deprecated */
|
|
62
69
|
ignoreInstractions: false,
|
|
70
|
+
ignoreInstraction: false,
|
|
63
71
|
ignoreText: false,
|
|
72
|
+
/** @deprecated */
|
|
64
73
|
ignoreComments: false,
|
|
74
|
+
ignoreComment: false,
|
|
65
75
|
ignoreCData: false,
|
|
66
76
|
fullTagEmptyElement: true,
|
|
67
77
|
addParent: false,
|
|
@@ -77,13 +87,59 @@ const DEF_XML_PARSE_OPTIONS = {
|
|
|
77
87
|
* (* class definitions *)
|
|
78
88
|
*/
|
|
79
89
|
|
|
90
|
+
/**
|
|
91
|
+
* A parser options to convert an 'XML'-string into a 'JS'-object
|
|
92
|
+
* @typedef {Object} xml2jsParseOptions
|
|
93
|
+
* @property {boolean} [compact]
|
|
94
|
+
* @property {string} [declarationKey]
|
|
95
|
+
* @property {string} [attributesKey]
|
|
96
|
+
* @property {string} [textKey]
|
|
97
|
+
* @property {string} [commentKey]
|
|
98
|
+
* @property {string} [cdataKey]
|
|
99
|
+
* @property {string} [nameKey]
|
|
100
|
+
* @property {string} [typeKey]
|
|
101
|
+
* @property {string} [parentKey]
|
|
102
|
+
* @property {string} [elementsKey]
|
|
103
|
+
* @property {boolean} [ignoreDeclaration]
|
|
104
|
+
* @property {boolean} [ignoreDocType]
|
|
105
|
+
* @property {boolean} [ignoreInstraction]
|
|
106
|
+
* @property {boolean} [ignoreText]
|
|
107
|
+
* @property {boolean} [ignoreComment]
|
|
108
|
+
* @property {boolean} [ignoreCData]
|
|
109
|
+
* @property {boolean} [addParent]
|
|
110
|
+
* @property {boolean} [trim]
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A parser options to convert a 'JS'-object into an 'XML'-string
|
|
115
|
+
* @typedef {Object} js2xmlParseOptions
|
|
116
|
+
* @property {boolean} [compact]
|
|
117
|
+
* @property {string} [declarationKey]
|
|
118
|
+
* @property {string} [attributesKey]
|
|
119
|
+
* @property {string} [textKey]
|
|
120
|
+
* @property {string} [commentKey]
|
|
121
|
+
* @property {string} [cdataKey]
|
|
122
|
+
* @property {string} [nameKey]
|
|
123
|
+
* @property {string} [typeKey]
|
|
124
|
+
* @property {string} [parentKey]
|
|
125
|
+
* @property {string} [elementsKey]
|
|
126
|
+
* @property {boolean} [ignoreDeclaration]
|
|
127
|
+
* @property {boolean} [ignoreDocType]
|
|
128
|
+
* @property {boolean} [ignoreInstraction]
|
|
129
|
+
* @property {boolean} [ignoreText]
|
|
130
|
+
* @property {boolean} [ignoreComment]
|
|
131
|
+
* @property {boolean} [ignoreCData]
|
|
132
|
+
* @property {boolean} [fullTagEmptyElement]
|
|
133
|
+
* @property {any} [spaces]
|
|
134
|
+
*/
|
|
135
|
+
|
|
80
136
|
/**
|
|
81
137
|
* @classdesc Implements a container that provide a functionality to work
|
|
82
138
|
* with options for an XML-parser
|
|
83
139
|
*/
|
|
84
140
|
class TXmlContentParseOptions {
|
|
85
|
-
/** @type {
|
|
86
|
-
#_options
|
|
141
|
+
/** @type {OPT_parserOptions} */
|
|
142
|
+
#_options;
|
|
87
143
|
|
|
88
144
|
/**
|
|
89
145
|
* Creates a container instance
|
|
@@ -95,7 +151,7 @@ class TXmlContentParseOptions {
|
|
|
95
151
|
|
|
96
152
|
/**
|
|
97
153
|
* Contains a set of a current settings
|
|
98
|
-
* @type {
|
|
154
|
+
* @type {OPT_parserOptions}
|
|
99
155
|
*/
|
|
100
156
|
get settings() {
|
|
101
157
|
return this.#_options;
|
|
@@ -103,7 +159,7 @@ class TXmlContentParseOptions {
|
|
|
103
159
|
|
|
104
160
|
/**
|
|
105
161
|
* Contains a set of a settings for converting an 'XML' to 'JS'-object
|
|
106
|
-
* @type {
|
|
162
|
+
* @type {xml2jsParseOptions}
|
|
107
163
|
*/
|
|
108
164
|
get xml2js() {
|
|
109
165
|
let _settings = this.#_options;
|
|
@@ -120,9 +176,9 @@ class TXmlContentParseOptions {
|
|
|
120
176
|
elementsKey: _settings.elementsKey,
|
|
121
177
|
ignoreDeclaration: _settings.ignoreDeclaration,
|
|
122
178
|
ignoreDocType: _settings.ignoreDocType,
|
|
123
|
-
ignoreInstraction: _settings.
|
|
179
|
+
ignoreInstraction: _settings.ignoreInstraction,
|
|
124
180
|
ignoreText: _settings.ignoreText,
|
|
125
|
-
ignoreComment: _settings.
|
|
181
|
+
ignoreComment: _settings.ignoreComment,
|
|
126
182
|
ignoreCData: _settings.ignoreCData,
|
|
127
183
|
addParent: _settings.addParent,
|
|
128
184
|
trim: _settings.trim,
|
|
@@ -131,7 +187,7 @@ class TXmlContentParseOptions {
|
|
|
131
187
|
|
|
132
188
|
/**
|
|
133
189
|
* Contains a set of a settings for converting an 'JS'-object to 'XML'
|
|
134
|
-
* @type {
|
|
190
|
+
* @type {js2xmlParseOptions}
|
|
135
191
|
*/
|
|
136
192
|
get js2xml() {
|
|
137
193
|
let _settings = this.#_options;
|
|
@@ -148,9 +204,9 @@ class TXmlContentParseOptions {
|
|
|
148
204
|
elementsKey: _settings.elementsKey,
|
|
149
205
|
ignoreDeclaration: _settings.ignoreDeclaration,
|
|
150
206
|
ignoreDocType: _settings.ignoreDocType,
|
|
151
|
-
ignoreInstraction: _settings.
|
|
207
|
+
ignoreInstraction: _settings.ignoreInstraction,
|
|
152
208
|
ignoreText: _settings.ignoreText,
|
|
153
|
-
ignoreComment: _settings.
|
|
209
|
+
ignoreComment: _settings.ignoreComment,
|
|
154
210
|
ignoreCData: _settings.ignoreCData,
|
|
155
211
|
fullTagEmptyElement: _settings.fullTagEmptyElement,
|
|
156
212
|
spaces: _settings.spaces,
|
|
@@ -189,6 +245,7 @@ class TXmlContentParseOptions {
|
|
|
189
245
|
/**
|
|
190
246
|
* Creates a container instance
|
|
191
247
|
* @param {any} [opt] - some initial options set
|
|
248
|
+
* @returns {OPT_parserOptions}
|
|
192
249
|
* @static
|
|
193
250
|
*/
|
|
194
251
|
static createNewOptionsSet(opt) {
|
|
@@ -212,9 +269,9 @@ class TXmlContentParseOptions {
|
|
|
212
269
|
elementsKey: opt.elementsKey,
|
|
213
270
|
ignoreDeclaration: opt.ignoreDeclaration,
|
|
214
271
|
ignoreDocType: opt.ignoreDocType,
|
|
215
|
-
|
|
272
|
+
ignoreInstraction: opt.ignoreInstraction,
|
|
216
273
|
ignoreText: opt.ignoreText,
|
|
217
|
-
|
|
274
|
+
ignoreComment: opt.ignoreComment,
|
|
218
275
|
ignoreCData: opt.ignoreCData,
|
|
219
276
|
fullTagEmptyElement: opt.fullTagEmptyElement,
|
|
220
277
|
addParent: opt.addParent,
|
|
@@ -229,7 +286,7 @@ class TXmlContentParseOptions {
|
|
|
229
286
|
|
|
230
287
|
module.exports.XOBJ_DEF_PARAM_TNAME = XOBJ_DEF_PARAM_TNAME;
|
|
231
288
|
module.exports.XOBJ_DEF_ATTR_TNAME = XOBJ_DEF_ATTR_TNAME;
|
|
232
|
-
module.exports.
|
|
289
|
+
module.exports.XOBJ_DEF_TNAMES = XOBJ_DEF_TNAMES;
|
|
233
290
|
module.exports.DEF_XML_PARSE_OPTIONS = DEF_XML_PARSE_OPTIONS;
|
|
234
291
|
|
|
235
292
|
module.exports.TXmlContentParseOptions = TXmlContentParseOptions;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export namespace XOBJ_ECODE_TABLE {
|
|
2
|
+
export { XOBJ_TE_NOBJ_EMSG };
|
|
3
|
+
export { XOBJ_TE_NOBJ_ECODE };
|
|
4
|
+
export { XOBJ_TE_NARR_EMSG };
|
|
5
|
+
export { XOBJ_TE_NARR_ECODE };
|
|
6
|
+
export { XOBJ_TE_NSTR_EMSG };
|
|
7
|
+
export { XOBJ_TE_NSTR_ECODE };
|
|
8
|
+
export { XOBJ_TE_NPOBJ_EMSG };
|
|
9
|
+
export { XOBJ_TE_NPOBJ_ECODE };
|
|
10
|
+
export { XOBJ_TE_ANES_EMSG };
|
|
11
|
+
export { XOBJ_TE_ANES_ECODE };
|
|
12
|
+
export { XOBJ_TE_KNES_EMSG };
|
|
13
|
+
export { XOBJ_TE_KNES_ECODE };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @classdesc Extends a base `TypeError` object to provide some information
|
|
17
|
+
* on the errors thrown when a key name evaluation failed
|
|
18
|
+
*/
|
|
19
|
+
export class EvalKeyNameError extends TypeError {
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new instance
|
|
22
|
+
*/
|
|
23
|
+
constructor(msg: string, options?: any);
|
|
24
|
+
/**
|
|
25
|
+
* Represents an error code
|
|
26
|
+
*/
|
|
27
|
+
code: string;
|
|
28
|
+
}
|
|
29
|
+
declare const XOBJ_TE_NOBJ_EMSG: "invalid argument (an object expected)";
|
|
30
|
+
declare const XOBJ_TE_NOBJ_ECODE: "ERR_XOBJ_NOBJ";
|
|
31
|
+
declare const XOBJ_TE_NARR_EMSG: "invalid argument (an array expected)";
|
|
32
|
+
declare const XOBJ_TE_NARR_ECODE: "ERR_XOBJ_NARR";
|
|
33
|
+
declare const XOBJ_TE_NSTR_EMSG: "invalid argument (a string expected)";
|
|
34
|
+
declare const XOBJ_TE_NSTR_ECODE: "ERR_XOBJ_NSTR";
|
|
35
|
+
declare const XOBJ_TE_NPOBJ_EMSG: "invalid argument (a plain object expected)";
|
|
36
|
+
declare const XOBJ_TE_NPOBJ_ECODE: "ERR_XOBJ_NPOBJ";
|
|
37
|
+
declare const XOBJ_TE_ANES_EMSG: "<attr_name> must be a non-empty string";
|
|
38
|
+
declare const XOBJ_TE_ANES_ECODE: "ERR_XOBJ_INVARG_ATTR";
|
|
39
|
+
declare const XOBJ_TE_KNES_EMSG: "<key_name> must be a non-empty string";
|
|
40
|
+
declare const XOBJ_TE_KNES_ECODE: "ERR_XOBJ_INVARG_KEY";
|
|
41
|
+
export {};
|