@adguard/dnr-converter 1.1.1 → 2.0.0-beta.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.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Describes an error when the metadata rules of a serialized ruleset are
3
+ * missing, malformed or do not form valid JSON.
4
+ */ class InvalidMetadataChunksError extends Error {
5
+ /**
6
+ * Describes an error when the metadata rules of a serialized ruleset
7
+ * cannot be read. The message names the rule set and the reason.
8
+ *
9
+ * @param rulesetId Rule set id whose metadata could not be read.
10
+ * @param reason Why the metadata cannot be read.
11
+ * @param cause Basic error, describes why the metadata is unreadable.
12
+ */ constructor(rulesetId, reason, cause){
13
+ super(`Cannot read metadata of rule set '${rulesetId}': ${reason}`, {
14
+ cause
15
+ });
16
+ this.name = this.constructor.name;
17
+ this.rulesetId = rulesetId;
18
+ // For proper work of the "instanceof" operator
19
+ Object.setPrototypeOf(this, InvalidMetadataChunksError.prototype);
20
+ }
21
+ }
22
+
23
+ export { InvalidMetadataChunksError };
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export { Ruleset } from './ruleset/ruleset.js';
4
4
  export { RulesetWithSourceMap } from './ruleset/ruleset-with-source-map.js';
5
5
  export { Filter } from './filter/filter.js';
6
6
  export { RulesHashMap } from './ruleset/rules-hash-map.js';
7
+ export { parseCompactRuleset } from './ruleset/compact-ruleset.js';
7
8
  export { METADATA_RULESET_ID, MetadataRuleset } from './ruleset/metadata-ruleset.js';
8
9
  export { Rule } from './rule/rule.js';
9
10
  export { RuleDeclarativeValidator } from './rule/rule-validator.js';
@@ -14,6 +15,7 @@ export { RULESET_NAME_PREFIX, extractRulesetId, getRulesetId, getRulesetPath } f
14
15
  export { FilterConverter } from './filter-converter/filter-converter.js';
15
16
  export { UnavailableFilterSourceError } from './errors/unavailable-sources-errors/unavailable-filter-source-error.js';
16
17
  export { UnavailableRulesetSourceError } from './errors/unavailable-sources-errors/unavailable-ruleset-source-error.js';
18
+ export { InvalidMetadataChunksError } from './errors/metadata-errors/invalid-metadata-chunks-error.js';
17
19
  export { ResourceType } from './declarative-rule/rule-condition.js';
18
20
  export { RuleActionType } from './declarative-rule/rule-action.js';
19
21
  export { EmptyDomainsError } from './errors/conversion-errors/empty-domains-error.js';
@@ -1,3 +1,145 @@
1
- var version = "1.1.1";
1
+ var name = "@adguard/dnr-converter";
2
+ var description = "A converter that transforms adblock-style filtering rules into rules compatible with the Declarative Net Request (DNR) API.";
3
+ var main = "dist/index.js";
4
+ var module$1 = "dist/index.js";
5
+ var types = "dist/types/src/index.d.ts";
6
+ var type = "module";
7
+ var sideEffects = false;
8
+ var files = [
9
+ "dist"
10
+ ];
11
+ var exports$1 = {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ types: "./dist/types/src/index.d.ts"
15
+ },
16
+ "./cli": {
17
+ types: "./dist/types/cli/index.d.ts",
18
+ "default": "./dist/cli.cjs"
19
+ }
20
+ };
21
+ var bin = {
22
+ "dnr-converter": "dist/cli.cjs"
23
+ };
24
+ var typesVersions = {
25
+ "*": {
26
+ "*": [
27
+ "dist/types/src/index.d.ts"
28
+ ],
29
+ cli: [
30
+ "dist/types/cli/index.d.ts"
31
+ ]
32
+ }
33
+ };
34
+ var author = "Adguard Software Ltd.";
35
+ var repository = {
36
+ type: "git",
37
+ url: "git+https://github.com/AdGuardSoftwareLimited/ext-tsurlfilter.git",
38
+ directory: "packages/dnr-converter"
39
+ };
40
+ var license = "GPL-3.0-only";
41
+ var engines = {
42
+ node: ">=22"
43
+ };
44
+ var bugs = {
45
+ url: "https://github.com/AdguardTeam/tsurlfilter/issues"
46
+ };
47
+ var homepage = "https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/dnr-converter#readme";
48
+ var scripts = {
49
+ lint: "pnpm lint:code && pnpm lint:types && pnpm lint:md",
50
+ "lint:code": "eslint --cache --ignore-path .gitignore .",
51
+ "lint:types": "tsc",
52
+ "lint:md": "markdownlint .",
53
+ start: "rollup -c rollup.config.ts --configPlugin typescript -w",
54
+ build: "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
55
+ "docs:examples": "tsx tasks/generate-examples.ts",
56
+ test: "vitest run",
57
+ "test:light": "vitest run --exclude \"**/*benchmark*.test.ts\"",
58
+ "test:watch": "vitest run --watch",
59
+ "test:ci": "vitest run --no-cache --reporter default --reporter junit --outputFile=./tests-reports/dnr-converter.xml",
60
+ "test:coverage": "vitest run --coverage",
61
+ "test:smoke": "(cd test/smoke/esm && pnpm test) && (cd test/smoke/exports && pnpm test)",
62
+ "test:prod": "pnpm lint && pnpm test:smoke && pnpm test -- --no-cache",
63
+ "test:debug": "vitest run --inspect --no-file-parallelism --watch",
64
+ precommit: "lint-staged",
65
+ prepublishOnly: "pnpm build",
66
+ tgz: "pnpm pack --out dnr-converter.tgz"
67
+ };
68
+ var peerDependencies = {
69
+ "@adguard/re2-wasm": "1.2.0"
70
+ };
71
+ var dependencies = {
72
+ "@adguard/agtree": "workspace:^",
73
+ "@adguard/logger": "workspace:^",
74
+ "@adguard/scriptlets": "catalog:",
75
+ commander: "catalog:",
76
+ punycode: "catalog:",
77
+ valibot: "catalog:"
78
+ };
79
+ var devDependencies = {
80
+ "@adguard/eslint-plugin-logger-context": "workspace:^",
81
+ "@adguard/tsurlfilter": "workspace:^",
82
+ "@rollup/plugin-commonjs": "catalog:",
83
+ "@rollup/plugin-json": "catalog:",
84
+ "@rollup/plugin-node-resolve": "catalog:",
85
+ "@rollup/plugin-swc": "catalog:",
86
+ "@rollup/plugin-typescript": "catalog:",
87
+ "@types/chrome": "catalog:",
88
+ "@types/node": "catalog:",
89
+ "@types/punycode": "catalog:",
90
+ "@typescript-eslint/eslint-plugin": "catalog:",
91
+ "@typescript-eslint/parser": "catalog:",
92
+ "@vitest/coverage-v8": "catalog:",
93
+ eslint: "catalog:",
94
+ "eslint-config-airbnb-base": "catalog:",
95
+ "eslint-config-airbnb-typescript": "catalog:",
96
+ "eslint-plugin-boundaries": "catalog:",
97
+ "eslint-plugin-import": "catalog:",
98
+ "eslint-plugin-import-newlines": "catalog:",
99
+ "eslint-plugin-jsdoc": "catalog:",
100
+ "eslint-plugin-n": "catalog:",
101
+ "lint-staged": "catalog:",
102
+ markdownlint: "catalog:",
103
+ "markdownlint-cli": "catalog:",
104
+ rimraf: "catalog:",
105
+ rollup: "catalog:",
106
+ "rollup-plugin-copy": "catalog:",
107
+ "rollup-plugin-dts": "catalog:",
108
+ "rollup-plugin-node-externals": "catalog:",
109
+ tsd: "catalog:",
110
+ tsx: "catalog:",
111
+ typescript: "catalog:",
112
+ vitest: "catalog:"
113
+ };
114
+ var version = "2.0.0-beta.0";
115
+ var packageJson = {
116
+ name: name,
117
+ description: description,
118
+ main: main,
119
+ module: module$1,
120
+ types: types,
121
+ type: type,
122
+ sideEffects: sideEffects,
123
+ files: files,
124
+ exports: exports$1,
125
+ bin: bin,
126
+ typesVersions: typesVersions,
127
+ author: author,
128
+ repository: repository,
129
+ license: license,
130
+ engines: engines,
131
+ bugs: bugs,
132
+ homepage: homepage,
133
+ scripts: scripts,
134
+ "lint-staged": {
135
+ "{src,cli,test,tasks}/**/*.ts": [
136
+ "eslint"
137
+ ]
138
+ },
139
+ peerDependencies: peerDependencies,
140
+ dependencies: dependencies,
141
+ devDependencies: devDependencies,
142
+ version: version
143
+ };
2
144
 
3
- export { version };
145
+ export { author, bin, bugs, packageJson as default, dependencies, description, devDependencies, engines, exports$1 as exports, files, homepage, license, main, module$1 as module, name, peerDependencies, repository, scripts, sideEffects, type, types, typesVersions, version };
@@ -0,0 +1,32 @@
1
+ import { MetadataRules } from './metadata-rule.js';
2
+
3
+ /**
4
+ * Reads a parsed filter ruleset file: joins the leading metadata rules,
5
+ * parses the metadata once and returns it with the ordinary rules and the
6
+ * number of metadata rules. The payload is taken as the envelope written by
7
+ * {@link RulesetWithSourceMap.serializeCompact} without further checks, and
8
+ * ordinary rules are returned as parsed; both are validated later by
9
+ * {@link RulesetWithSourceMap.fromCompact} or
10
+ * {@link RulesetWithSourceMap.deserialize} and the ruleset content provider.
11
+ *
12
+ * @param rulesetId Rule set id, used in error messages.
13
+ * @param parsedRuleset Parsed JSON content of a `ruleset_N.json` file.
14
+ *
15
+ * @returns Envelope fields, ordinary rules and metadata rule count.
16
+ *
17
+ * @throws {InvalidMetadataChunksError} If `parsedRuleset` is not an array,
18
+ * has no leading metadata rule, has a metadata rule without a string `chunk`,
19
+ * or if the joined fragments are not valid JSON.
20
+ */ function parseCompactRuleset(rulesetId, parsedRuleset) {
21
+ const { payload, declarativeRules, metadataRulesCount } = MetadataRules.read(rulesetId, parsedRuleset);
22
+ const { metadata, lazyMetadata, filterContent } = payload;
23
+ return {
24
+ metadata,
25
+ lazyMetadata,
26
+ filterContent,
27
+ declarativeRules,
28
+ metadataRulesCount
29
+ };
30
+ }
31
+
32
+ export { parseCompactRuleset };
@@ -0,0 +1,178 @@
1
+ import { TAB } from '../utils/string.js';
2
+
3
+ /**
4
+ * Maximum size in UTF-8 bytes of one serialized `metadata` value of a
5
+ * metadata rule, including JSON escaping and the `{"chunk":...}` wrapper.
6
+ */ const MAX_METADATA_VALUE_BYTES = 65536;
7
+ /**
8
+ * Key of the fragment inside the `metadata` value of a metadata rule.
9
+ */ const CHUNK_KEY = 'chunk';
10
+ /**
11
+ * Nesting depth of the `metadata` value inside a serialized ruleset file:
12
+ * the rules array (0) contains rule objects (1) that contain the value (2).
13
+ * Pretty printing indents every nested line by this many tabs.
14
+ */ const METADATA_VALUE_DEPTH = 2;
15
+ /**
16
+ * Code unit of the double quote character.
17
+ */ const QUOTE = 0x22;
18
+ /**
19
+ * Code unit of the backslash character.
20
+ */ const BACKSLASH = 0x5c;
21
+ /**
22
+ * First code unit that JSON.stringify does not escape.
23
+ */ const SPACE = 0x20;
24
+ /**
25
+ * First code unit of the surrogate range.
26
+ */ const SURROGATE_START = 0xd800;
27
+ /**
28
+ * Last code unit of the surrogate range.
29
+ */ const SURROGATE_END = 0xdfff;
30
+ /**
31
+ * First code point that UTF-8 encodes in two bytes.
32
+ */ const TWO_BYTE_UTF8_START = 0x80;
33
+ /**
34
+ * First code point that UTF-8 encodes in three bytes.
35
+ */ const THREE_BYTE_UTF8_START = 0x800;
36
+ /**
37
+ * Number of UTF-8 bytes of a surrogate pair.
38
+ */ const SURROGATE_PAIR_BYTES = 4;
39
+ /**
40
+ * Control characters that JSON.stringify writes as two-character escapes
41
+ * (`\b`, `\t`, `\n`, `\f`, `\r`). Other control characters become `\u00XX`.
42
+ */ const SHORT_ESCAPES = new Set([
43
+ 0x08,
44
+ 0x09,
45
+ 0x0a,
46
+ 0x0c,
47
+ 0x0d
48
+ ]);
49
+ /**
50
+ * Shared encoder for byte measurements.
51
+ */ const utf8Encoder = new TextEncoder();
52
+ /**
53
+ * Byte accounting, splitting of serialized metadata into fragments and id
54
+ * allocation for metadata rules.
55
+ */ class MetadataChunks {
56
+ /**
57
+ * Returns the size of a string in UTF-8 bytes.
58
+ *
59
+ * @param str String to measure.
60
+ *
61
+ * @returns Number of UTF-8 bytes.
62
+ */ static utf8ByteLength(str) {
63
+ return utf8Encoder.encode(str).length;
64
+ }
65
+ /**
66
+ * Returns the number of UTF-8 bytes that one UTF-16 code unit occupies once
67
+ * `JSON.stringify` has escaped it inside a string literal. A code unit of a
68
+ * surrogate pair must not be passed here: pairs cost four bytes and are
69
+ * handled by the caller.
70
+ *
71
+ * @param codeUnit UTF-16 code unit.
72
+ *
73
+ * @returns Escaped size in bytes.
74
+ */ static escapedByteCost(codeUnit) {
75
+ if (codeUnit === QUOTE || codeUnit === BACKSLASH) {
76
+ return 2;
77
+ }
78
+ if (codeUnit < SPACE) {
79
+ return SHORT_ESCAPES.has(codeUnit) ? 2 : 6;
80
+ }
81
+ // A lone surrogate is written as `\uXXXX`.
82
+ if (codeUnit >= SURROGATE_START && codeUnit <= SURROGATE_END) {
83
+ return 6;
84
+ }
85
+ if (codeUnit < TWO_BYTE_UTF8_START) {
86
+ return 1;
87
+ }
88
+ if (codeUnit < THREE_BYTE_UTF8_START) {
89
+ return 2;
90
+ }
91
+ return 3;
92
+ }
93
+ /**
94
+ * Renders the `metadata` value of a metadata rule exactly as it appears in a
95
+ * serialized ruleset file, so that its byte size can be measured.
96
+ *
97
+ * @param chunk Fragment stored in the value.
98
+ * @param pretty Whether the file is pretty printed with {@link TAB} indents.
99
+ *
100
+ * @returns The value as written to the file.
101
+ */ static renderValue(chunk, pretty) {
102
+ const chunkJson = JSON.stringify(chunk);
103
+ if (!pretty) {
104
+ return `{"${CHUNK_KEY}":${chunkJson}}`;
105
+ }
106
+ const inner = TAB.repeat(METADATA_VALUE_DEPTH + 1);
107
+ const outer = TAB.repeat(METADATA_VALUE_DEPTH);
108
+ return `{\n${inner}"${CHUNK_KEY}": ${chunkJson}\n${outer}}`;
109
+ }
110
+ /**
111
+ * Splits a serialized payload into ordered fragments such that the
112
+ * `metadata` value rendered from each fragment (see
113
+ * {@link MetadataChunks.renderValue}) is at most {@link MAX_METADATA_VALUE_BYTES}.
114
+ * Fragments are cut on code-point boundaries, so a surrogate pair is never
115
+ * split. The result is a pure function of the input: identical payloads
116
+ * produce identical fragments.
117
+ *
118
+ * @param payload Serialized metadata (JSON text).
119
+ * @param pretty Whether the ruleset file is pretty printed.
120
+ *
121
+ * @returns Ordered fragments whose concatenation is `payload`.
122
+ *
123
+ * @throws Error if a rendered fragment exceeds the bound. This cannot happen
124
+ * unless {@link MetadataChunks.escapedByteCost} disagrees with `JSON.stringify`.
125
+ */ static split(payload, pretty) {
126
+ const budget = MAX_METADATA_VALUE_BYTES - MetadataChunks.utf8ByteLength(MetadataChunks.renderValue('', pretty));
127
+ const fragments = [];
128
+ let start = 0;
129
+ let bytes = 0;
130
+ let i = 0;
131
+ // Iterating a string yields code points: a surrogate pair comes as one
132
+ // two-unit string, a lone surrogate as one unit that `escapedByteCost`
133
+ // prices as a `\uXXXX` escape.
134
+ for (const char of payload){
135
+ const cost = char.length === 2 ? SURROGATE_PAIR_BYTES : MetadataChunks.escapedByteCost(char.charCodeAt(0));
136
+ if (bytes + cost > budget) {
137
+ fragments.push(payload.slice(start, i));
138
+ start = i;
139
+ bytes = 0;
140
+ }
141
+ bytes += cost;
142
+ i += char.length;
143
+ }
144
+ fragments.push(payload.slice(start));
145
+ // Measure the real output as a guard against the cost table drifting
146
+ // from the engine's escaping rules.
147
+ for (const fragment of fragments){
148
+ const size = MetadataChunks.utf8ByteLength(MetadataChunks.renderValue(fragment, pretty));
149
+ if (size > MAX_METADATA_VALUE_BYTES) {
150
+ throw new Error(`Metadata chunk of ${size} bytes exceeds ${MAX_METADATA_VALUE_BYTES} bytes ` + '(internal error: byte accounting disagrees with JSON.stringify)');
151
+ }
152
+ }
153
+ return fragments;
154
+ }
155
+ /**
156
+ * Allocates ids for metadata rules: the smallest positive integers that no
157
+ * other rule of the ruleset uses, in increasing order. Ordinary rule ids are
158
+ * stable hashes of the rule text and are never changed to make room.
159
+ *
160
+ * @param count Number of ids to allocate.
161
+ * @param usedIds Ids taken by ordinary rules and by unsafe rules stored in
162
+ * the metadata.
163
+ *
164
+ * @returns Allocated ids, one per metadata rule.
165
+ */ static allocateIds(count, usedIds) {
166
+ const ids = [];
167
+ let candidate = 1;
168
+ while(ids.length < count){
169
+ if (!usedIds.has(candidate)) {
170
+ ids.push(candidate);
171
+ }
172
+ candidate += 1;
173
+ }
174
+ return ids;
175
+ }
176
+ }
177
+
178
+ export { CHUNK_KEY, MAX_METADATA_VALUE_BYTES, MetadataChunks };
@@ -1,35 +1,107 @@
1
+ import { getErrorMessage } from '../utils/error.js';
2
+ import { serializeJson } from '../utils/string.js';
3
+ import { MetadataChunks, CHUNK_KEY } from './metadata-chunks.js';
1
4
  import { ResourceType } from '../declarative-rule/rule-condition.js';
2
5
  import { RuleActionType } from '../declarative-rule/rule-action.js';
6
+ import { InvalidMetadataChunksError } from '../errors/metadata-errors/invalid-metadata-chunks-error.js';
3
7
 
4
8
  /**
5
- * Metadata rule ID. Always the first rule in the rule set.
6
- */ const METADATA_RULE_ID = 1;
7
- /**
8
- * Metadata key in the rule object.
9
- */ const METADATA_KEY = 'metadata';
10
- /**
11
- * Dummy rule URL that should not match any request.
9
+ * Dummy rule URL that should not match any request. It is also the marker
10
+ * that identifies metadata rules when a ruleset is read.
12
11
  */ const DUMMY_RULE_URL = 'dummy.rule.adguard.com';
13
12
  /**
14
- * Creates a declarative rule with metadata.
15
- *
16
- * @param content Metadata rule configuration.
17
- *
18
- * @returns Declarative rule object with metadata.
19
- */ const createMetadataRule = (content)=>{
20
- return {
21
- id: METADATA_RULE_ID,
22
- action: {
23
- type: RuleActionType.Block
24
- },
25
- condition: {
26
- urlFilter: DUMMY_RULE_URL,
27
- resourceTypes: [
28
- ResourceType.XmlHttpRequest
29
- ]
30
- },
31
- [METADATA_KEY]: content
32
- };
33
- };
13
+ * Writes and reads metadata rules.
14
+ */ class MetadataRules {
15
+ /**
16
+ * Checks whether a parsed rule is a metadata rule: an object whose
17
+ * `condition.urlFilter` is the dummy URL marker and that has an own
18
+ * `metadata` property. Ordinary converted rules never carry `metadata`, so a
19
+ * converted rule for the marker host without that property is an ordinary
20
+ * rule.
21
+ *
22
+ * @param rule Parsed rule.
23
+ *
24
+ * @returns `true` if the rule is a metadata rule.
25
+ */ static isMetadataRule(rule) {
26
+ return typeof rule === 'object' && rule !== null && rule.condition?.urlFilter === DUMMY_RULE_URL && Object.hasOwn(rule, 'metadata');
27
+ }
28
+ /**
29
+ * Serializes a metadata payload and wraps its fragments into metadata rules.
30
+ * Every rule's `metadata` value fits the per-value size bound in the given
31
+ * formatting mode.
32
+ *
33
+ * @param payload Metadata object; must be JSON serializable.
34
+ * @param usedIds Ids taken by ordinary rules and by unsafe rules stored in
35
+ * the metadata; metadata rules get the smallest ids outside this set.
36
+ * @param pretty Whether the ruleset file will be pretty printed.
37
+ *
38
+ * @returns Metadata rules in fragment order.
39
+ */ static create(payload, usedIds, pretty) {
40
+ const fragments = MetadataChunks.split(serializeJson(payload), pretty);
41
+ const ids = MetadataChunks.allocateIds(fragments.length, usedIds);
42
+ return fragments.map((chunk, i)=>({
43
+ id: ids[i],
44
+ action: {
45
+ type: RuleActionType.Block
46
+ },
47
+ condition: {
48
+ urlFilter: DUMMY_RULE_URL,
49
+ resourceTypes: [
50
+ ResourceType.XmlHttpRequest
51
+ ]
52
+ },
53
+ metadata: {
54
+ [CHUNK_KEY]: chunk
55
+ }
56
+ }));
57
+ }
58
+ /**
59
+ * Reads the metadata rules of a parsed ruleset: takes the leading run of
60
+ * metadata rules (see {@link MetadataRules.isMetadataRule}), joins their fragments in order
61
+ * and parses the result once. Metadata rule ids are ignored. A rule with the
62
+ * marker `urlFilter` but without a `metadata` property is an ordinary rule.
63
+ *
64
+ * @param rulesetId Rule set id, used in error messages.
65
+ * @param rules Parsed content of a ruleset file.
66
+ *
67
+ * @returns Parsed payload, the remaining rules and the number of metadata
68
+ * rules.
69
+ *
70
+ * @throws {InvalidMetadataChunksError} If `rules` is not an array, has no
71
+ * leading metadata rule, has a metadata rule without a string `chunk`, or if
72
+ * the joined fragments are not valid JSON.
73
+ */ static read(rulesetId, rules) {
74
+ if (!Array.isArray(rules)) {
75
+ throw new InvalidMetadataChunksError(rulesetId, 'expected an array of declarative rules');
76
+ }
77
+ const fragments = [];
78
+ let index = 0;
79
+ for (const rule of rules){
80
+ if (!MetadataRules.isMetadataRule(rule)) {
81
+ break;
82
+ }
83
+ const chunk = rule.metadata?.[CHUNK_KEY];
84
+ if (typeof chunk !== 'string') {
85
+ throw new InvalidMetadataChunksError(rulesetId, `"metadata.${CHUNK_KEY}" of metadata rule #${index} is not a string`);
86
+ }
87
+ fragments.push(chunk);
88
+ index += 1;
89
+ }
90
+ if (fragments.length === 0) {
91
+ throw new InvalidMetadataChunksError(rulesetId, 'no metadata rules found at the beginning of the rule set');
92
+ }
93
+ let payload;
94
+ try {
95
+ payload = JSON.parse(fragments.join(''));
96
+ } catch (e) {
97
+ throw new InvalidMetadataChunksError(rulesetId, `metadata chunks do not form valid JSON: ${getErrorMessage(e)}`, e);
98
+ }
99
+ return {
100
+ payload,
101
+ declarativeRules: rules.slice(index),
102
+ metadataRulesCount: index
103
+ };
104
+ }
105
+ }
34
106
 
35
- export { createMetadataRule };
107
+ export { MetadataRules };