@things-factory/integration-base 6.0.5 → 6.0.10

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,13 @@
1
+ # Random Task
2
+
3
+ 무작위 데이터를 생성하는 태스크이다.
4
+ 지정된 형식(format)의 무작위 데이터를 지정된 갯수(count)만큼 배열로 생성한다.
5
+
6
+ - 무작위데이터 생성방법은 [Chance Document](https://chancejs.com)를 따른다.
7
+
8
+ ## parameters
9
+
10
+ - format
11
+ - 생성될 무작위 데이터의 형식을 지정한다.
12
+ - count
13
+ - 생성될 무작위 데이터의 갯수를 지정한다.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-base",
3
- "version": "6.0.5",
3
+ "version": "6.0.10",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -25,12 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@apollo/client": "^3.6.9",
28
- "@things-factory/api": "^6.0.5",
29
- "@things-factory/auth-base": "^6.0.5",
30
- "@things-factory/env": "^6.0.5",
31
- "@things-factory/oauth2-client": "^6.0.5",
32
- "@things-factory/shell": "^6.0.5",
28
+ "@things-factory/api": "^6.0.7",
29
+ "@things-factory/auth-base": "^6.0.7",
30
+ "@things-factory/env": "^6.0.7",
31
+ "@things-factory/oauth2-client": "^6.0.7",
32
+ "@things-factory/shell": "^6.0.7",
33
33
  "async-mqtt": "^2.5.0",
34
+ "chance": "^1.1.11",
34
35
  "cron": "^1.7.2",
35
36
  "cross-fetch": "^3.0.4",
36
37
  "ieee754": "^1.2.1",
@@ -40,5 +41,5 @@
40
41
  "promise-socket": "^7.0.0",
41
42
  "vm2": "3.9.11"
42
43
  },
43
- "gitHead": "af75b451e62cdeeab8b42ff3c49a213cd1ad1ea5"
44
+ "gitHead": "3c57782afe1c216525d9d42b6e5c4969c177eaea"
44
45
  }
@@ -30,3 +30,4 @@ import './throw'
30
30
  import './variables'
31
31
  import './floating-point'
32
32
  import './socket-listener'
33
+ import './random'
@@ -0,0 +1,50 @@
1
+ import { TaskRegistry } from '../task-registry'
2
+ import Chance from 'chance'
3
+
4
+ const formats = [
5
+ 'bool,character,floating,integer,letter,natural,string',
6
+ 'paragraph,sentence,syllable,word',
7
+ 'age,birthday,cf,cpf,first,gender,last,name,prefix,ssn,suffix',
8
+ 'android_id,apple_token,bb_pin,wp7_anid,wp8_anid2,avatar,color',
9
+ 'company,domain,email,fbid,google_analytics,hashtag,ip,ipv6,klout,profession,tld,twitter,url',
10
+ 'address,altitude,areacode,city,coordinates,country,depth,geohash,latitude,longitude,phone,postal,province,state,street,zip',
11
+ 'ampm,date,hammertime,hour,millisecond,minute,month,second,timestamp,timezone,weekday,year',
12
+ 'cc,cc_type,currency,currency_pair,dollar,euro,exp,exp_month,exp_year',
13
+ 'coin,d4,d6,d8,d10,d12,d20,d30,d100,guid,hash'
14
+ ]
15
+ .join(',')
16
+ .split(',')
17
+
18
+ async function Random(step, { logger, publish, data }) {
19
+ var {
20
+ params: { format = 'integer', count = 1 }
21
+ } = step
22
+
23
+ const chance = new Chance()
24
+
25
+ return {
26
+ data: chance.n(chance[format], count)
27
+ }
28
+ }
29
+
30
+ Random.parameterSpec = [
31
+ {
32
+ type: 'select',
33
+ label: 'format',
34
+ name: 'format',
35
+ property: {
36
+ options: formats.map(format => ({ display: format, value: format }))
37
+ }
38
+ },
39
+ {
40
+ type: 'number',
41
+ label: 'count',
42
+ name: 'count',
43
+ placeholder: '1'
44
+ }
45
+ ]
46
+
47
+ Random.connectorFree = true
48
+ Random.help = 'integration/task/random'
49
+
50
+ TaskRegistry.registerTaskHandler('random', Random)