@twin.org/data-processing-rest-client 0.0.2-next.3 → 0.0.3-next.1
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/dist/{esm/index.mjs → es/dataProcessingRestClient.js} +12 -7
- package/dist/es/dataProcessingRestClient.js.map +1 -0
- package/dist/es/index.js +4 -0
- package/dist/es/index.js.map +1 -0
- package/dist/types/dataProcessingRestClient.d.ts +6 -1
- package/dist/types/index.d.ts +1 -1
- package/docs/changelog.md +41 -0
- package/docs/reference/classes/DataProcessingRestClient.md +19 -1
- package/package.json +6 -8
- package/dist/cjs/index.cjs +0 -125
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import { BaseRestClient } from '@twin.org/api-core';
|
|
2
|
-
import { Guards, Converter, ObjectHelper, Coerce } from '@twin.org/core';
|
|
3
|
-
|
|
4
1
|
// Copyright 2024 IOTA Stiftung.
|
|
5
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { BaseRestClient } from "@twin.org/api-core";
|
|
4
|
+
import { Coerce, Converter, Guards, ObjectHelper } from "@twin.org/core";
|
|
6
5
|
/**
|
|
7
6
|
* Client for performing data processing through to REST endpoints.
|
|
8
7
|
*/
|
|
9
|
-
class DataProcessingRestClient extends BaseRestClient {
|
|
8
|
+
export class DataProcessingRestClient extends BaseRestClient {
|
|
10
9
|
/**
|
|
11
10
|
* Runtime name for the class.
|
|
12
11
|
*/
|
|
13
12
|
static CLASS_NAME = "DataProcessingRestClient";
|
|
14
13
|
/**
|
|
15
|
-
* Create a new instance of
|
|
14
|
+
* Create a new instance of DataProcessingRestClient.
|
|
16
15
|
* @param config The configuration for the client.
|
|
17
16
|
*/
|
|
18
17
|
constructor(config) {
|
|
19
18
|
super(DataProcessingRestClient.CLASS_NAME, config, "data-processing");
|
|
20
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the class name of the component.
|
|
22
|
+
* @returns The class name of the component.
|
|
23
|
+
*/
|
|
24
|
+
className() {
|
|
25
|
+
return DataProcessingRestClient.CLASS_NAME;
|
|
26
|
+
}
|
|
21
27
|
/**
|
|
22
28
|
* Set an extraction rule group.
|
|
23
29
|
* @param ruleGroup The rule group to store.
|
|
@@ -119,5 +125,4 @@ class DataProcessingRestClient extends BaseRestClient {
|
|
|
119
125
|
return response.body;
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
|
-
|
|
123
|
-
export { DataProcessingRestClient };
|
|
128
|
+
//# sourceMappingURL=dataProcessingRestClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataProcessingRestClient.js","sourceRoot":"","sources":["../../src/dataProcessingRestClient.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@twin.org/api-models\";\nimport { Coerce, Converter, Guards, ObjectHelper } from \"@twin.org/core\";\nimport type {\n\tIDataProcessingComponent,\n\tIDataProcessingConvertRequest,\n\tIDataProcessingConvertResponse,\n\tIDataProcessingExtractRequest,\n\tIDataProcessingExtractResponse,\n\tIDataProcessingRuleGroupGetRequest,\n\tIDataProcessingRuleGroupGetResponse,\n\tIDataProcessingRuleGroupListRequest,\n\tIDataProcessingRuleGroupListResponse,\n\tIDataProcessingRuleGroupRemoveRequest,\n\tIDataProcessingRuleGroupSetRequest,\n\tIRule,\n\tIRuleGroup\n} from \"@twin.org/data-processing-models\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Client for performing data processing through to REST endpoints.\n */\nexport class DataProcessingRestClient extends BaseRestClient implements IDataProcessingComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataProcessingRestClient>();\n\n\t/**\n\t * Create a new instance of DataProcessingRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(DataProcessingRestClient.CLASS_NAME, config, \"data-processing\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn DataProcessingRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Set an extraction rule group.\n\t * @param ruleGroup The rule group to store.\n\t * @returns Nothing.\n\t */\n\tpublic async ruleGroupSet(ruleGroup: IRuleGroup): Promise<void> {\n\t\tGuards.object<IRuleGroup>(DataProcessingRestClient.CLASS_NAME, nameof(ruleGroup), ruleGroup);\n\t\tGuards.stringValue(DataProcessingRestClient.CLASS_NAME, nameof(ruleGroup.id), ruleGroup.id);\n\t\tGuards.stringValue(\n\t\t\tDataProcessingRestClient.CLASS_NAME,\n\t\t\tnameof(ruleGroup.label),\n\t\t\truleGroup.label\n\t\t);\n\t\tGuards.array<IRule>(\n\t\t\tDataProcessingRestClient.CLASS_NAME,\n\t\t\tnameof(ruleGroup.rules),\n\t\t\truleGroup.rules\n\t\t);\n\n\t\tawait this.fetch<IDataProcessingRuleGroupSetRequest, INoContentResponse>(\n\t\t\t\"/rule-group/:id\",\n\t\t\t\"PUT\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tid: ruleGroup.id\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tlabel: ruleGroup.label,\n\t\t\t\t\trules: ruleGroup.rules\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Get a rule group for extraction.\n\t * @param ruleGroupId The id of the rule group to get.\n\t * @returns The rule group.\n\t */\n\tpublic async ruleGroupGet(ruleGroupId: string): Promise<IRuleGroup> {\n\t\tGuards.stringValue(DataProcessingRestClient.CLASS_NAME, nameof(ruleGroupId), ruleGroupId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIDataProcessingRuleGroupGetRequest,\n\t\t\tIDataProcessingRuleGroupGetResponse\n\t\t>(\"/rule-group/:id\", \"GET\", {\n\t\t\tpathParams: {\n\t\t\t\tid: ruleGroupId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a rule group.\n\t * @param ruleGroupId The id of the rule group to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async ruleGroupRemove(ruleGroupId: string): Promise<void> {\n\t\tGuards.stringValue(DataProcessingRestClient.CLASS_NAME, nameof(ruleGroupId), ruleGroupId);\n\n\t\tawait this.fetch<IDataProcessingRuleGroupRemoveRequest, INoContentResponse>(\n\t\t\t\"/rule-group/:id\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tid: ruleGroupId\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Extracts data from the provided input.\n\t * @param ruleGroupId The id of the rule group to use to extract data.\n\t * @param data The data to extract from.\n\t * @param overrideExtractorType An optional override for the extractor type.\n\t * @param overrideMimeType An optional override for the mime type for conversion, will auto detect if not provided.\n\t * @returns The extracted data.\n\t */\n\tpublic async extract(\n\t\truleGroupId: string,\n\t\tdata: Uint8Array,\n\t\toverrideExtractorType?: string,\n\t\toverrideMimeType?: string\n\t): Promise<unknown> {\n\t\tGuards.stringValue(DataProcessingRestClient.CLASS_NAME, nameof(ruleGroupId), ruleGroupId);\n\t\tGuards.uint8Array(DataProcessingRestClient.CLASS_NAME, nameof(data), data);\n\n\t\tconst result = await this.fetch<IDataProcessingExtractRequest, IDataProcessingExtractResponse>(\n\t\t\t\"/extract\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\truleGroupId,\n\t\t\t\t\tdata: Converter.bytesToBase64(data),\n\t\t\t\t\toverrideExtractorType,\n\t\t\t\t\toverrideMimeType\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn ObjectHelper.fromExtended(result.body);\n\t}\n\n\t/**\n\t * Converts data from the provided input to a structured JSON document.\n\t * @param data The data to convert.\n\t * @param overrideMimeType An optional override for the mime type, will auto detect if empty.\n\t * @returns The converted data.\n\t */\n\tpublic async convert(data: Uint8Array, overrideMimeType?: string): Promise<unknown> {\n\t\tGuards.uint8Array(DataProcessingRestClient.CLASS_NAME, nameof(data), data);\n\n\t\tconst result = await this.fetch<IDataProcessingConvertRequest, IDataProcessingConvertResponse>(\n\t\t\t\"/convert\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tdata: Converter.bytesToBase64(data),\n\t\t\t\t\toverrideMimeType\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn ObjectHelper.fromExtended(result.body);\n\t}\n\n\t/**\n\t * Query the rule group entries.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit Limit the number of entities to return.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tpublic async query(\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: IRuleGroup[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst response = await this.fetch<\n\t\t\tIDataProcessingRuleGroupListRequest,\n\t\t\tIDataProcessingRuleGroupListResponse\n\t\t>(\"/rule-group\", \"GET\", {\n\t\t\tquery: {\n\t\t\t\tcursor,\n\t\t\t\tlimit: Coerce.string(limit)\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,+BAA+B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataProcessingRestClient.js\";\n"]}
|
|
@@ -10,10 +10,15 @@ export declare class DataProcessingRestClient extends BaseRestClient implements
|
|
|
10
10
|
*/
|
|
11
11
|
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
|
-
* Create a new instance of
|
|
13
|
+
* Create a new instance of DataProcessingRestClient.
|
|
14
14
|
* @param config The configuration for the client.
|
|
15
15
|
*/
|
|
16
16
|
constructor(config: IBaseRestClientConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
17
22
|
/**
|
|
18
23
|
* Set an extraction rule group.
|
|
19
24
|
* @param ruleGroup The rule group to store.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./dataProcessingRestClient";
|
|
1
|
+
export * from "./dataProcessingRestClient.js";
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @twin.org/data-processing-rest-client - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.1](https://github.com/twinfoundation/data-processing/compare/data-processing-rest-client-v0.0.3-next.0...data-processing-rest-client-v0.0.3-next.1) (2025-11-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add context id features ([#25](https://github.com/twinfoundation/data-processing/issues/25)) ([2a2a955](https://github.com/twinfoundation/data-processing/commit/2a2a9559d54e8c703e97e2c05996e678416ef560))
|
|
9
|
+
* Add rule group query functionality ([#2](https://github.com/twinfoundation/data-processing/issues/2)) ([0fbbfb0](https://github.com/twinfoundation/data-processing/commit/0fbbfb065b6ecc293920b25f97ba011743105486))
|
|
10
|
+
* add validate-locales ([9af0874](https://github.com/twinfoundation/data-processing/commit/9af0874cd3f44a4cfca514dde8380f002e62337e))
|
|
11
|
+
* eslint migration to flat config ([a8138b0](https://github.com/twinfoundation/data-processing/commit/a8138b020ed58baeff162a822d4df207a6aeadc4))
|
|
12
|
+
* pass the mimeTypeOverride through the component extract method ([#9](https://github.com/twinfoundation/data-processing/issues/9)) ([a2b36de](https://github.com/twinfoundation/data-processing/commit/a2b36de5c19c56e4172d3f22b176aa83e1df84c8))
|
|
13
|
+
* update dependencies ([21b8e80](https://github.com/twinfoundation/data-processing/commit/21b8e8007c87136a09f0a8e35ffde13a07ff4711))
|
|
14
|
+
* update framework core ([96f6e80](https://github.com/twinfoundation/data-processing/commit/96f6e8016a4ef0fb873f6775e750b4ab42e9f491))
|
|
15
|
+
* use shared store mechanism ([#6](https://github.com/twinfoundation/data-processing/issues/6)) ([6009228](https://github.com/twinfoundation/data-processing/commit/600922880acef07cc2f818dee7645c342929108b))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* supporting array usage ([#20](https://github.com/twinfoundation/data-processing/issues/20)) ([d2c68cd](https://github.com/twinfoundation/data-processing/commit/d2c68cd3983622586cc073377545d6416b87a827))
|
|
21
|
+
* Update endpoint for fetching rule group list ([#3](https://github.com/twinfoundation/data-processing/issues/3)) ([919c1b4](https://github.com/twinfoundation/data-processing/commit/919c1b435e760251ca57f96ed9f701b08542f318))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Dependencies
|
|
25
|
+
|
|
26
|
+
* The following workspace dependencies were updated
|
|
27
|
+
* dependencies
|
|
28
|
+
* @twin.org/data-processing-models bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
29
|
+
|
|
30
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/data-processing/compare/data-processing-rest-client-v0.0.2-next.3...data-processing-rest-client-v0.0.2-next.4) (2025-10-22)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* supporting array usage ([#20](https://github.com/twinfoundation/data-processing/issues/20)) ([d2c68cd](https://github.com/twinfoundation/data-processing/commit/d2c68cd3983622586cc073377545d6416b87a827))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Dependencies
|
|
39
|
+
|
|
40
|
+
* The following workspace dependencies were updated
|
|
41
|
+
* dependencies
|
|
42
|
+
* @twin.org/data-processing-models bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
43
|
+
|
|
3
44
|
## [0.0.2-next.3](https://github.com/twinfoundation/data-processing/compare/data-processing-rest-client-v0.0.2-next.2...data-processing-rest-client-v0.0.2-next.3) (2025-10-09)
|
|
4
45
|
|
|
5
46
|
|
|
@@ -16,7 +16,7 @@ Client for performing data processing through to REST endpoints.
|
|
|
16
16
|
|
|
17
17
|
> **new DataProcessingRestClient**(`config`): `DataProcessingRestClient`
|
|
18
18
|
|
|
19
|
-
Create a new instance of
|
|
19
|
+
Create a new instance of DataProcessingRestClient.
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
@@ -44,6 +44,24 @@ Runtime name for the class.
|
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
47
|
+
### className()
|
|
48
|
+
|
|
49
|
+
> **className**(): `string`
|
|
50
|
+
|
|
51
|
+
Returns the class name of the component.
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`string`
|
|
56
|
+
|
|
57
|
+
The class name of the component.
|
|
58
|
+
|
|
59
|
+
#### Implementation of
|
|
60
|
+
|
|
61
|
+
`IDataProcessingComponent.className`
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
47
65
|
### ruleGroupSet()
|
|
48
66
|
|
|
49
67
|
> **ruleGroupSet**(`ruleGroup`): `Promise`\<`void`\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-processing-rest-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-next.1",
|
|
4
4
|
"description": "Data processing contract implementation which can connect to REST endpoints",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,25 +17,23 @@
|
|
|
17
17
|
"@twin.org/api-core": "next",
|
|
18
18
|
"@twin.org/api-models": "next",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
|
-
"@twin.org/data-processing-models": "0.0.
|
|
20
|
+
"@twin.org/data-processing-models": "0.0.3-next.1",
|
|
21
21
|
"@twin.org/entity": "next",
|
|
22
22
|
"@twin.org/nameof": "next",
|
|
23
23
|
"@twin.org/web": "next"
|
|
24
24
|
},
|
|
25
|
-
"main": "./dist/
|
|
26
|
-
"module": "./dist/esm/index.mjs",
|
|
25
|
+
"main": "./dist/es/index.js",
|
|
27
26
|
"types": "./dist/types/index.d.ts",
|
|
28
27
|
"exports": {
|
|
29
28
|
".": {
|
|
30
29
|
"types": "./dist/types/index.d.ts",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"import": "./dist/es/index.js",
|
|
31
|
+
"default": "./dist/es/index.js"
|
|
33
32
|
},
|
|
34
33
|
"./locales/*.json": "./locales/*.json"
|
|
35
34
|
},
|
|
36
35
|
"files": [
|
|
37
|
-
"dist/
|
|
38
|
-
"dist/esm",
|
|
36
|
+
"dist/es",
|
|
39
37
|
"dist/types",
|
|
40
38
|
"locales",
|
|
41
39
|
"docs"
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var apiCore = require('@twin.org/api-core');
|
|
4
|
-
var core = require('@twin.org/core');
|
|
5
|
-
|
|
6
|
-
// Copyright 2024 IOTA Stiftung.
|
|
7
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
8
|
-
/**
|
|
9
|
-
* Client for performing data processing through to REST endpoints.
|
|
10
|
-
*/
|
|
11
|
-
class DataProcessingRestClient extends apiCore.BaseRestClient {
|
|
12
|
-
/**
|
|
13
|
-
* Runtime name for the class.
|
|
14
|
-
*/
|
|
15
|
-
static CLASS_NAME = "DataProcessingRestClient";
|
|
16
|
-
/**
|
|
17
|
-
* Create a new instance of DataProcessingClient.
|
|
18
|
-
* @param config The configuration for the client.
|
|
19
|
-
*/
|
|
20
|
-
constructor(config) {
|
|
21
|
-
super(DataProcessingRestClient.CLASS_NAME, config, "data-processing");
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Set an extraction rule group.
|
|
25
|
-
* @param ruleGroup The rule group to store.
|
|
26
|
-
* @returns Nothing.
|
|
27
|
-
*/
|
|
28
|
-
async ruleGroupSet(ruleGroup) {
|
|
29
|
-
core.Guards.object(DataProcessingRestClient.CLASS_NAME, "ruleGroup", ruleGroup);
|
|
30
|
-
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroup.id", ruleGroup.id);
|
|
31
|
-
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroup.label", ruleGroup.label);
|
|
32
|
-
core.Guards.array(DataProcessingRestClient.CLASS_NAME, "ruleGroup.rules", ruleGroup.rules);
|
|
33
|
-
await this.fetch("/rule-group/:id", "PUT", {
|
|
34
|
-
pathParams: {
|
|
35
|
-
id: ruleGroup.id
|
|
36
|
-
},
|
|
37
|
-
body: {
|
|
38
|
-
label: ruleGroup.label,
|
|
39
|
-
rules: ruleGroup.rules
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get a rule group for extraction.
|
|
45
|
-
* @param ruleGroupId The id of the rule group to get.
|
|
46
|
-
* @returns The rule group.
|
|
47
|
-
*/
|
|
48
|
-
async ruleGroupGet(ruleGroupId) {
|
|
49
|
-
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
50
|
-
const response = await this.fetch("/rule-group/:id", "GET", {
|
|
51
|
-
pathParams: {
|
|
52
|
-
id: ruleGroupId
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return response.body;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Remove a rule group.
|
|
59
|
-
* @param ruleGroupId The id of the rule group to remove.
|
|
60
|
-
* @returns Nothing.
|
|
61
|
-
*/
|
|
62
|
-
async ruleGroupRemove(ruleGroupId) {
|
|
63
|
-
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
64
|
-
await this.fetch("/rule-group/:id", "DELETE", {
|
|
65
|
-
pathParams: {
|
|
66
|
-
id: ruleGroupId
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Extracts data from the provided input.
|
|
72
|
-
* @param ruleGroupId The id of the rule group to use to extract data.
|
|
73
|
-
* @param data The data to extract from.
|
|
74
|
-
* @param overrideExtractorType An optional override for the extractor type.
|
|
75
|
-
* @param overrideMimeType An optional override for the mime type for conversion, will auto detect if not provided.
|
|
76
|
-
* @returns The extracted data.
|
|
77
|
-
*/
|
|
78
|
-
async extract(ruleGroupId, data, overrideExtractorType, overrideMimeType) {
|
|
79
|
-
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
80
|
-
core.Guards.uint8Array(DataProcessingRestClient.CLASS_NAME, "data", data);
|
|
81
|
-
const result = await this.fetch("/extract", "POST", {
|
|
82
|
-
body: {
|
|
83
|
-
ruleGroupId,
|
|
84
|
-
data: core.Converter.bytesToBase64(data),
|
|
85
|
-
overrideExtractorType,
|
|
86
|
-
overrideMimeType
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return core.ObjectHelper.fromExtended(result.body);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Converts data from the provided input to a structured JSON document.
|
|
93
|
-
* @param data The data to convert.
|
|
94
|
-
* @param overrideMimeType An optional override for the mime type, will auto detect if empty.
|
|
95
|
-
* @returns The converted data.
|
|
96
|
-
*/
|
|
97
|
-
async convert(data, overrideMimeType) {
|
|
98
|
-
core.Guards.uint8Array(DataProcessingRestClient.CLASS_NAME, "data", data);
|
|
99
|
-
const result = await this.fetch("/convert", "POST", {
|
|
100
|
-
body: {
|
|
101
|
-
data: core.Converter.bytesToBase64(data),
|
|
102
|
-
overrideMimeType
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return core.ObjectHelper.fromExtended(result.body);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Query the rule group entries.
|
|
109
|
-
* @param cursor The cursor to request the next chunk of entities.
|
|
110
|
-
* @param limit Limit the number of entities to return.
|
|
111
|
-
* @returns All the entities for the storage matching the conditions,
|
|
112
|
-
* and a cursor which can be used to request more entities.
|
|
113
|
-
*/
|
|
114
|
-
async query(cursor, limit) {
|
|
115
|
-
const response = await this.fetch("/rule-group", "GET", {
|
|
116
|
-
query: {
|
|
117
|
-
cursor,
|
|
118
|
-
limit: core.Coerce.string(limit)
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
return response.body;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
exports.DataProcessingRestClient = DataProcessingRestClient;
|