@twin.org/data-processing-rest-client 0.0.2-next.2 → 0.0.2-next.4
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/cjs/index.cjs +18 -23
- package/dist/esm/index.mjs +19 -24
- package/dist/types/{dataProcessingClient.d.ts → dataProcessingRestClient.d.ts} +6 -6
- package/dist/types/index.d.ts +1 -1
- package/docs/changelog.md +28 -0
- package/docs/reference/classes/{DataProcessingClient.md → DataProcessingRestClient.md} +9 -13
- package/docs/reference/index.md +1 -1
- package/package.json +19 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,22 +8,17 @@ var core = require('@twin.org/core');
|
|
|
8
8
|
/**
|
|
9
9
|
* Client for performing data processing through to REST endpoints.
|
|
10
10
|
*/
|
|
11
|
-
class
|
|
11
|
+
class DataProcessingRestClient extends apiCore.BaseRestClient {
|
|
12
12
|
/**
|
|
13
13
|
* Runtime name for the class.
|
|
14
|
-
* @internal
|
|
15
14
|
*/
|
|
16
|
-
static
|
|
15
|
+
static CLASS_NAME = "DataProcessingRestClient";
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
CLASS_NAME = DataProcessingClient._CLASS_NAME;
|
|
21
|
-
/**
|
|
22
|
-
* Create a new instance of DataProcessingClient.
|
|
17
|
+
* Create a new instance of DataProcessingRestClient.
|
|
23
18
|
* @param config The configuration for the client.
|
|
24
19
|
*/
|
|
25
20
|
constructor(config) {
|
|
26
|
-
super(
|
|
21
|
+
super(DataProcessingRestClient.CLASS_NAME, config, "data-processing");
|
|
27
22
|
}
|
|
28
23
|
/**
|
|
29
24
|
* Set an extraction rule group.
|
|
@@ -31,10 +26,10 @@ class DataProcessingClient extends apiCore.BaseRestClient {
|
|
|
31
26
|
* @returns Nothing.
|
|
32
27
|
*/
|
|
33
28
|
async ruleGroupSet(ruleGroup) {
|
|
34
|
-
core.Guards.object(
|
|
35
|
-
core.Guards.stringValue(
|
|
36
|
-
core.Guards.stringValue(
|
|
37
|
-
core.Guards.array(
|
|
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);
|
|
38
33
|
await this.fetch("/rule-group/:id", "PUT", {
|
|
39
34
|
pathParams: {
|
|
40
35
|
id: ruleGroup.id
|
|
@@ -51,7 +46,7 @@ class DataProcessingClient extends apiCore.BaseRestClient {
|
|
|
51
46
|
* @returns The rule group.
|
|
52
47
|
*/
|
|
53
48
|
async ruleGroupGet(ruleGroupId) {
|
|
54
|
-
core.Guards.stringValue(
|
|
49
|
+
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
55
50
|
const response = await this.fetch("/rule-group/:id", "GET", {
|
|
56
51
|
pathParams: {
|
|
57
52
|
id: ruleGroupId
|
|
@@ -65,7 +60,7 @@ class DataProcessingClient extends apiCore.BaseRestClient {
|
|
|
65
60
|
* @returns Nothing.
|
|
66
61
|
*/
|
|
67
62
|
async ruleGroupRemove(ruleGroupId) {
|
|
68
|
-
core.Guards.stringValue(
|
|
63
|
+
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
69
64
|
await this.fetch("/rule-group/:id", "DELETE", {
|
|
70
65
|
pathParams: {
|
|
71
66
|
id: ruleGroupId
|
|
@@ -81,8 +76,8 @@ class DataProcessingClient extends apiCore.BaseRestClient {
|
|
|
81
76
|
* @returns The extracted data.
|
|
82
77
|
*/
|
|
83
78
|
async extract(ruleGroupId, data, overrideExtractorType, overrideMimeType) {
|
|
84
|
-
core.Guards.stringValue(
|
|
85
|
-
core.Guards.uint8Array(
|
|
79
|
+
core.Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
80
|
+
core.Guards.uint8Array(DataProcessingRestClient.CLASS_NAME, "data", data);
|
|
86
81
|
const result = await this.fetch("/extract", "POST", {
|
|
87
82
|
body: {
|
|
88
83
|
ruleGroupId,
|
|
@@ -100,7 +95,7 @@ class DataProcessingClient extends apiCore.BaseRestClient {
|
|
|
100
95
|
* @returns The converted data.
|
|
101
96
|
*/
|
|
102
97
|
async convert(data, overrideMimeType) {
|
|
103
|
-
core.Guards.uint8Array(
|
|
98
|
+
core.Guards.uint8Array(DataProcessingRestClient.CLASS_NAME, "data", data);
|
|
104
99
|
const result = await this.fetch("/convert", "POST", {
|
|
105
100
|
body: {
|
|
106
101
|
data: core.Converter.bytesToBase64(data),
|
|
@@ -111,20 +106,20 @@ class DataProcessingClient extends apiCore.BaseRestClient {
|
|
|
111
106
|
}
|
|
112
107
|
/**
|
|
113
108
|
* Query the rule group entries.
|
|
114
|
-
* @param cursor The cursor to request the next
|
|
115
|
-
* @param
|
|
109
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
110
|
+
* @param limit Limit the number of entities to return.
|
|
116
111
|
* @returns All the entities for the storage matching the conditions,
|
|
117
112
|
* and a cursor which can be used to request more entities.
|
|
118
113
|
*/
|
|
119
|
-
async query(cursor,
|
|
114
|
+
async query(cursor, limit) {
|
|
120
115
|
const response = await this.fetch("/rule-group", "GET", {
|
|
121
116
|
query: {
|
|
122
117
|
cursor,
|
|
123
|
-
|
|
118
|
+
limit: core.Coerce.string(limit)
|
|
124
119
|
}
|
|
125
120
|
});
|
|
126
121
|
return response.body;
|
|
127
122
|
}
|
|
128
123
|
}
|
|
129
124
|
|
|
130
|
-
exports.
|
|
125
|
+
exports.DataProcessingRestClient = DataProcessingRestClient;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { BaseRestClient } from '@twin.org/api-core';
|
|
2
|
-
import { Guards, Converter, ObjectHelper } from '@twin.org/core';
|
|
2
|
+
import { Guards, Converter, ObjectHelper, Coerce } from '@twin.org/core';
|
|
3
3
|
|
|
4
4
|
// Copyright 2024 IOTA Stiftung.
|
|
5
5
|
// SPDX-License-Identifier: Apache-2.0.
|
|
6
6
|
/**
|
|
7
7
|
* Client for performing data processing through to REST endpoints.
|
|
8
8
|
*/
|
|
9
|
-
class
|
|
9
|
+
class DataProcessingRestClient extends BaseRestClient {
|
|
10
10
|
/**
|
|
11
11
|
* Runtime name for the class.
|
|
12
|
-
* @internal
|
|
13
12
|
*/
|
|
14
|
-
static
|
|
13
|
+
static CLASS_NAME = "DataProcessingRestClient";
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
CLASS_NAME = DataProcessingClient._CLASS_NAME;
|
|
19
|
-
/**
|
|
20
|
-
* Create a new instance of DataProcessingClient.
|
|
15
|
+
* Create a new instance of DataProcessingRestClient.
|
|
21
16
|
* @param config The configuration for the client.
|
|
22
17
|
*/
|
|
23
18
|
constructor(config) {
|
|
24
|
-
super(
|
|
19
|
+
super(DataProcessingRestClient.CLASS_NAME, config, "data-processing");
|
|
25
20
|
}
|
|
26
21
|
/**
|
|
27
22
|
* Set an extraction rule group.
|
|
@@ -29,10 +24,10 @@ class DataProcessingClient extends BaseRestClient {
|
|
|
29
24
|
* @returns Nothing.
|
|
30
25
|
*/
|
|
31
26
|
async ruleGroupSet(ruleGroup) {
|
|
32
|
-
Guards.object(
|
|
33
|
-
Guards.stringValue(
|
|
34
|
-
Guards.stringValue(
|
|
35
|
-
Guards.array(
|
|
27
|
+
Guards.object(DataProcessingRestClient.CLASS_NAME, "ruleGroup", ruleGroup);
|
|
28
|
+
Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroup.id", ruleGroup.id);
|
|
29
|
+
Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroup.label", ruleGroup.label);
|
|
30
|
+
Guards.array(DataProcessingRestClient.CLASS_NAME, "ruleGroup.rules", ruleGroup.rules);
|
|
36
31
|
await this.fetch("/rule-group/:id", "PUT", {
|
|
37
32
|
pathParams: {
|
|
38
33
|
id: ruleGroup.id
|
|
@@ -49,7 +44,7 @@ class DataProcessingClient extends BaseRestClient {
|
|
|
49
44
|
* @returns The rule group.
|
|
50
45
|
*/
|
|
51
46
|
async ruleGroupGet(ruleGroupId) {
|
|
52
|
-
Guards.stringValue(
|
|
47
|
+
Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
53
48
|
const response = await this.fetch("/rule-group/:id", "GET", {
|
|
54
49
|
pathParams: {
|
|
55
50
|
id: ruleGroupId
|
|
@@ -63,7 +58,7 @@ class DataProcessingClient extends BaseRestClient {
|
|
|
63
58
|
* @returns Nothing.
|
|
64
59
|
*/
|
|
65
60
|
async ruleGroupRemove(ruleGroupId) {
|
|
66
|
-
Guards.stringValue(
|
|
61
|
+
Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
67
62
|
await this.fetch("/rule-group/:id", "DELETE", {
|
|
68
63
|
pathParams: {
|
|
69
64
|
id: ruleGroupId
|
|
@@ -79,8 +74,8 @@ class DataProcessingClient extends BaseRestClient {
|
|
|
79
74
|
* @returns The extracted data.
|
|
80
75
|
*/
|
|
81
76
|
async extract(ruleGroupId, data, overrideExtractorType, overrideMimeType) {
|
|
82
|
-
Guards.stringValue(
|
|
83
|
-
Guards.uint8Array(
|
|
77
|
+
Guards.stringValue(DataProcessingRestClient.CLASS_NAME, "ruleGroupId", ruleGroupId);
|
|
78
|
+
Guards.uint8Array(DataProcessingRestClient.CLASS_NAME, "data", data);
|
|
84
79
|
const result = await this.fetch("/extract", "POST", {
|
|
85
80
|
body: {
|
|
86
81
|
ruleGroupId,
|
|
@@ -98,7 +93,7 @@ class DataProcessingClient extends BaseRestClient {
|
|
|
98
93
|
* @returns The converted data.
|
|
99
94
|
*/
|
|
100
95
|
async convert(data, overrideMimeType) {
|
|
101
|
-
Guards.uint8Array(
|
|
96
|
+
Guards.uint8Array(DataProcessingRestClient.CLASS_NAME, "data", data);
|
|
102
97
|
const result = await this.fetch("/convert", "POST", {
|
|
103
98
|
body: {
|
|
104
99
|
data: Converter.bytesToBase64(data),
|
|
@@ -109,20 +104,20 @@ class DataProcessingClient extends BaseRestClient {
|
|
|
109
104
|
}
|
|
110
105
|
/**
|
|
111
106
|
* Query the rule group entries.
|
|
112
|
-
* @param cursor The cursor to request the next
|
|
113
|
-
* @param
|
|
107
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
108
|
+
* @param limit Limit the number of entities to return.
|
|
114
109
|
* @returns All the entities for the storage matching the conditions,
|
|
115
110
|
* and a cursor which can be used to request more entities.
|
|
116
111
|
*/
|
|
117
|
-
async query(cursor,
|
|
112
|
+
async query(cursor, limit) {
|
|
118
113
|
const response = await this.fetch("/rule-group", "GET", {
|
|
119
114
|
query: {
|
|
120
115
|
cursor,
|
|
121
|
-
|
|
116
|
+
limit: Coerce.string(limit)
|
|
122
117
|
}
|
|
123
118
|
});
|
|
124
119
|
return response.body;
|
|
125
120
|
}
|
|
126
121
|
}
|
|
127
122
|
|
|
128
|
-
export {
|
|
123
|
+
export { DataProcessingRestClient };
|
|
@@ -4,13 +4,13 @@ import type { IDataProcessingComponent, IRuleGroup } from "@twin.org/data-proces
|
|
|
4
4
|
/**
|
|
5
5
|
* Client for performing data processing through to REST endpoints.
|
|
6
6
|
*/
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class DataProcessingRestClient extends BaseRestClient implements IDataProcessingComponent {
|
|
8
8
|
/**
|
|
9
9
|
* Runtime name for the class.
|
|
10
10
|
*/
|
|
11
|
-
readonly CLASS_NAME: string;
|
|
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);
|
|
@@ -50,12 +50,12 @@ export declare class DataProcessingClient extends BaseRestClient implements IDat
|
|
|
50
50
|
convert(data: Uint8Array, overrideMimeType?: string): Promise<unknown>;
|
|
51
51
|
/**
|
|
52
52
|
* Query the rule group entries.
|
|
53
|
-
* @param cursor The cursor to request the next
|
|
54
|
-
* @param
|
|
53
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
54
|
+
* @param limit Limit the number of entities to return.
|
|
55
55
|
* @returns All the entities for the storage matching the conditions,
|
|
56
56
|
* and a cursor which can be used to request more entities.
|
|
57
57
|
*/
|
|
58
|
-
query(cursor?: string,
|
|
58
|
+
query(cursor?: string, limit?: number): Promise<{
|
|
59
59
|
/**
|
|
60
60
|
* The entities, which can be partial if a limited keys list was provided.
|
|
61
61
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./dataProcessingRestClient";
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/data-processing-rest-client - Changelog
|
|
2
2
|
|
|
3
|
+
## [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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* supporting array usage ([#20](https://github.com/twinfoundation/data-processing/issues/20)) ([d2c68cd](https://github.com/twinfoundation/data-processing/commit/d2c68cd3983622586cc073377545d6416b87a827))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/data-processing-models bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
16
|
+
|
|
17
|
+
## [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add validate-locales ([9af0874](https://github.com/twinfoundation/data-processing/commit/9af0874cd3f44a4cfca514dde8380f002e62337e))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/data-processing-models bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
30
|
+
|
|
3
31
|
## [0.0.2-next.2](https://github.com/twinfoundation/data-processing/compare/data-processing-rest-client-v0.0.2-next.1...data-processing-rest-client-v0.0.2-next.2) (2025-08-29)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Class:
|
|
1
|
+
# Class: DataProcessingRestClient
|
|
2
2
|
|
|
3
3
|
Client for performing data processing through to REST endpoints.
|
|
4
4
|
|
|
@@ -14,9 +14,9 @@ Client for performing data processing through to REST endpoints.
|
|
|
14
14
|
|
|
15
15
|
### Constructor
|
|
16
16
|
|
|
17
|
-
> **new
|
|
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
|
|
|
@@ -28,7 +28,7 @@ The configuration for the client.
|
|
|
28
28
|
|
|
29
29
|
#### Returns
|
|
30
30
|
|
|
31
|
-
`
|
|
31
|
+
`DataProcessingRestClient`
|
|
32
32
|
|
|
33
33
|
#### Overrides
|
|
34
34
|
|
|
@@ -38,14 +38,10 @@ The configuration for the client.
|
|
|
38
38
|
|
|
39
39
|
### CLASS\_NAME
|
|
40
40
|
|
|
41
|
-
> `readonly` **CLASS\_NAME**: `string`
|
|
41
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
42
42
|
|
|
43
43
|
Runtime name for the class.
|
|
44
44
|
|
|
45
|
-
#### Implementation of
|
|
46
|
-
|
|
47
|
-
`IDataProcessingComponent.CLASS_NAME`
|
|
48
|
-
|
|
49
45
|
## Methods
|
|
50
46
|
|
|
51
47
|
### ruleGroupSet()
|
|
@@ -204,7 +200,7 @@ The converted data.
|
|
|
204
200
|
|
|
205
201
|
### query()
|
|
206
202
|
|
|
207
|
-
> **query**(`cursor?`, `
|
|
203
|
+
> **query**(`cursor?`, `limit?`): `Promise`\<\{ `entities`: `IRuleGroup`[]; `cursor?`: `string`; \}\>
|
|
208
204
|
|
|
209
205
|
Query the rule group entries.
|
|
210
206
|
|
|
@@ -214,13 +210,13 @@ Query the rule group entries.
|
|
|
214
210
|
|
|
215
211
|
`string`
|
|
216
212
|
|
|
217
|
-
The cursor to request the next
|
|
213
|
+
The cursor to request the next chunk of entities.
|
|
218
214
|
|
|
219
|
-
#####
|
|
215
|
+
##### limit?
|
|
220
216
|
|
|
221
217
|
`number`
|
|
222
218
|
|
|
223
|
-
|
|
219
|
+
Limit the number of entities to return.
|
|
224
220
|
|
|
225
221
|
#### Returns
|
|
226
222
|
|
package/docs/reference/index.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-processing-rest-client",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.4",
|
|
4
4
|
"description": "Data processing contract implementation which can connect to REST endpoints",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
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.2-next.
|
|
20
|
+
"@twin.org/data-processing-models": "0.0.2-next.4",
|
|
21
21
|
"@twin.org/entity": "next",
|
|
22
22
|
"@twin.org/nameof": "next",
|
|
23
23
|
"@twin.org/web": "next"
|
|
@@ -39,5 +39,21 @@
|
|
|
39
39
|
"dist/types",
|
|
40
40
|
"locales",
|
|
41
41
|
"docs"
|
|
42
|
-
]
|
|
42
|
+
],
|
|
43
|
+
"keywords": [
|
|
44
|
+
"twin",
|
|
45
|
+
"trade",
|
|
46
|
+
"iota",
|
|
47
|
+
"framework",
|
|
48
|
+
"blockchain",
|
|
49
|
+
"data-processing",
|
|
50
|
+
"data",
|
|
51
|
+
"processing",
|
|
52
|
+
"transformation",
|
|
53
|
+
"conversion"
|
|
54
|
+
],
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "git+https://github.com/twinfoundation/data-processing/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://twindev.org"
|
|
43
59
|
}
|