@aionis/doc-module-json-transform 0.1.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.
- package/CHANGELOG.md +6 -0
- package/README.md +51 -0
- package/index.mjs +53 -0
- package/package.json +31 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @aionis/doc-module-json-transform
|
|
2
|
+
|
|
3
|
+
Official Aionis Doc module that deterministically selects a subset of keys from an input object.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @aionis/doc-module-json-transform@0.1.0
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Input
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"value": {
|
|
16
|
+
"product": "Aionis",
|
|
17
|
+
"mode": "standalone",
|
|
18
|
+
"ignored": true
|
|
19
|
+
},
|
|
20
|
+
"pick": ["mode", "product"]
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Output
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"result": {
|
|
29
|
+
"mode": "standalone",
|
|
30
|
+
"product": "Aionis"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Exports
|
|
36
|
+
|
|
37
|
+
1. `manifest`
|
|
38
|
+
2. `handler`
|
|
39
|
+
|
|
40
|
+
## Module ID
|
|
41
|
+
|
|
42
|
+
`json.transform.v1`
|
|
43
|
+
|
|
44
|
+
## Registry Entry
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"module": "json.transform.v1",
|
|
49
|
+
"package": "@aionis/doc-module-json-transform"
|
|
50
|
+
}
|
|
51
|
+
```
|
package/index.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const manifest = {
|
|
2
|
+
module: "json.transform.v1",
|
|
3
|
+
version: "1.0.0",
|
|
4
|
+
title: "JSON Transform",
|
|
5
|
+
description: "Select a stable subset of object keys from an input record.",
|
|
6
|
+
deterministic: true,
|
|
7
|
+
required_capabilities: ["direct_execution"],
|
|
8
|
+
input_contract: {
|
|
9
|
+
kind: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
value: {
|
|
12
|
+
kind: "object",
|
|
13
|
+
additional_properties: true
|
|
14
|
+
},
|
|
15
|
+
pick: {
|
|
16
|
+
kind: "array",
|
|
17
|
+
items: { kind: "string" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
required: ["value", "pick"],
|
|
21
|
+
additional_properties: false
|
|
22
|
+
},
|
|
23
|
+
output_contract: {
|
|
24
|
+
kind: "object",
|
|
25
|
+
properties: {
|
|
26
|
+
result: {
|
|
27
|
+
kind: "object",
|
|
28
|
+
additional_properties: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
required: ["result"],
|
|
32
|
+
additional_properties: false
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export async function handler(input) {
|
|
37
|
+
const source = input && typeof input === "object" && input.value && typeof input.value === "object" ? input.value : {};
|
|
38
|
+
const pick = input && typeof input === "object" && Array.isArray(input.pick) ? input.pick : [];
|
|
39
|
+
const result = {};
|
|
40
|
+
|
|
41
|
+
for (const key of pick) {
|
|
42
|
+
if (typeof key === "string" && Object.prototype.hasOwnProperty.call(source, key)) {
|
|
43
|
+
result[key] = source[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
kind: "module_result",
|
|
49
|
+
output: {
|
|
50
|
+
result
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aionis/doc-module-json-transform",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Aionis Doc module for deterministic object key selection.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.mjs",
|
|
12
|
+
"README.md",
|
|
13
|
+
"CHANGELOG.md"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.0.0"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"aionis-doc",
|
|
23
|
+
"module",
|
|
24
|
+
"json"
|
|
25
|
+
],
|
|
26
|
+
"author": "Aionis Core",
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"pack:dry-run": "npm pack --dry-run --cache /tmp/aionis-npm-cache"
|
|
30
|
+
}
|
|
31
|
+
}
|