@things-factory/integration-base 6.1.96 → 6.1.98
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-server/engine/task/http-get.js +12 -0
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.js +16 -1
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/integration/concept/template-literal.ja.md +13 -0
- package/helps/integration/concept/template-literal.ko.md +13 -0
- package/helps/integration/concept/template-literal.md +13 -0
- package/helps/integration/concept/template-literal.zh.md +13 -0
- package/package.json +8 -8
- package/server/engine/task/http-get.ts +14 -0
- package/server/engine/task/http-post.ts +18 -2
@@ -0,0 +1,13 @@
|
|
1
|
+
## テンプレートリテラル(Template Literals)
|
2
|
+
|
3
|
+
テンプレートリテラルは、ES6(ECMAScript 2015)で導入された文字列の記法の拡張で、バッククオート(``)で文字列を囲むことができます。
|
4
|
+
|
5
|
+
### 文字列内挿(String Interpolation)
|
6
|
+
|
7
|
+
テンプレートリテラルを使用すると、`${変数}`の構文を使って変数を文字列に挿入することができます。
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
const name = 'Alice'
|
11
|
+
const greeting = `Hello, ${name}!`
|
12
|
+
console.log(greeting) // 出力: Hello, Alice!
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
## 템플릿 리터럴 (Template Literals)
|
2
|
+
|
3
|
+
ES6에서 도입된 문자열 표기법의 확장으로, 백틱 (`)으로 문자열을 감싸서 사용합니다.
|
4
|
+
|
5
|
+
### 변수 삽입 (String Interpolation)
|
6
|
+
|
7
|
+
템플릿 리터럴을 사용하면 `${변수}` 형식으로 변수를 문자열에 삽입할 수 있습니다.
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
const name = 'Alice'
|
11
|
+
const greeting = `Hello, ${name}!`
|
12
|
+
console.log(greeting) // 출력: Hello, Alice!
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
## Template Literals
|
2
|
+
|
3
|
+
Template literals are an extension of string notation introduced in ES6 (ECMAScript 2015) that allows strings to be enclosed in backticks (`).
|
4
|
+
|
5
|
+
### String Interpolation
|
6
|
+
|
7
|
+
With template literals, you can insert variables into strings using the `${variable}` syntax.
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
const name = 'Alice'
|
11
|
+
const greeting = `Hello, ${name}!`
|
12
|
+
console.log(greeting) // Output: Hello, Alice!
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
## 模板字面量(Template Literals)
|
2
|
+
|
3
|
+
模板字面量是在 ES6(ECMAScript 2015)中引入的一种扩展字符串表示法,允许字符串用反引号(``)括起来。
|
4
|
+
|
5
|
+
### 字符串插值(String Interpolation)
|
6
|
+
|
7
|
+
使用模板字面量,您可以使用`${变量}`语法将变量插入字符串中。
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
const name = 'Alice'
|
11
|
+
const greeting = `你好,${name}!`
|
12
|
+
console.log(greeting) // 输出:你好,Alice!
|
13
|
+
```
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-base",
|
3
|
-
"version": "6.1.
|
3
|
+
"version": "6.1.98",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -26,12 +26,12 @@
|
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
28
|
"@apollo/client": "^3.6.9",
|
29
|
-
"@things-factory/api": "^6.1.
|
30
|
-
"@things-factory/auth-base": "^6.1.
|
31
|
-
"@things-factory/env": "^6.1.
|
32
|
-
"@things-factory/oauth2-client": "^6.1.
|
33
|
-
"@things-factory/scheduler-client": "^6.1.
|
34
|
-
"@things-factory/shell": "^6.1.
|
29
|
+
"@things-factory/api": "^6.1.97",
|
30
|
+
"@things-factory/auth-base": "^6.1.97",
|
31
|
+
"@things-factory/env": "^6.1.97",
|
32
|
+
"@things-factory/oauth2-client": "^6.1.97",
|
33
|
+
"@things-factory/scheduler-client": "^6.1.97",
|
34
|
+
"@things-factory/shell": "^6.1.97",
|
35
35
|
"async-mqtt": "^2.5.0",
|
36
36
|
"chance": "^1.1.11",
|
37
37
|
"cross-fetch": "^3.0.4",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"devDependencies": {
|
47
47
|
"@types/cron": "^2.0.1"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "d4f1c879015daa09cb3b9aa5ea7316de61021d4d"
|
50
50
|
}
|
@@ -27,6 +27,20 @@ async function HttpGet(step, { logger, data, domain, variables }) {
|
|
27
27
|
|
28
28
|
path = vm.run('`' + path + '`')
|
29
29
|
|
30
|
+
requestHeaders =
|
31
|
+
requestHeaders &&
|
32
|
+
Object.entries(requestHeaders as { [key: string]: string }).reduce((sum, [key, value]) => {
|
33
|
+
sum[key] = vm.run('`' + value + '`')
|
34
|
+
return sum
|
35
|
+
}, {})
|
36
|
+
|
37
|
+
searchParams =
|
38
|
+
searchParams &&
|
39
|
+
Object.entries(searchParams as { [key: string]: string }).reduce((sum, [key, value]) => {
|
40
|
+
sum[key] = vm.run('`' + value + '`')
|
41
|
+
return sum
|
42
|
+
}, {})
|
43
|
+
|
30
44
|
var url = new URL(path, endpoint)
|
31
45
|
if (searchParams) {
|
32
46
|
Object.keys(searchParams).forEach(key => {
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import fetch from 'node-fetch'
|
2
2
|
import { URL } from 'url'
|
3
|
+
import { VM } from 'vm2'
|
3
4
|
import { access } from '@things-factory/utils'
|
4
5
|
import { TaskRegistry } from '../task-registry'
|
5
6
|
import { ConnectionManager } from '../connection-manager'
|
6
7
|
import https from 'https'
|
7
8
|
|
8
|
-
async function HttpPost(step, { logger, data, domain }) {
|
9
|
+
async function HttpPost(step, { logger, data, domain, variables }) {
|
9
10
|
var { connection: connectionName, params: stepOptions } = step
|
10
11
|
var { headers: requestHeaders, contentType, path, accessor } = stepOptions || {}
|
11
12
|
|
@@ -17,8 +18,23 @@ async function HttpPost(step, { logger, data, domain }) {
|
|
17
18
|
|
18
19
|
var { endpoint, params: connectionParams, authHeaders = {} } = connection
|
19
20
|
|
20
|
-
|
21
|
+
const vm = new VM({
|
22
|
+
sandbox: {
|
23
|
+
domain,
|
24
|
+
data,
|
25
|
+
variables
|
26
|
+
}
|
27
|
+
})
|
21
28
|
|
29
|
+
path = vm.run('`' + path + '`')
|
30
|
+
requestHeaders =
|
31
|
+
requestHeaders &&
|
32
|
+
Object.entries(requestHeaders as { [key: string]: string }).reduce((sum, [key, value]) => {
|
33
|
+
sum[key] = vm.run('`' + value + '`')
|
34
|
+
return sum
|
35
|
+
}, {})
|
36
|
+
|
37
|
+
var url = new URL(path, endpoint)
|
22
38
|
var headers = {
|
23
39
|
...authHeaders,
|
24
40
|
...requestHeaders
|