@things-factory/integration-base 6.2.70 → 6.2.75

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.
Files changed (62) hide show
  1. package/dist-server/engine/analyzer/analyze-integration.js +2 -2
  2. package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
  3. package/dist-server/engine/connector/operato-connector.js +4 -3
  4. package/dist-server/engine/connector/operato-connector.js.map +1 -1
  5. package/dist-server/engine/scenario-engine.js +4 -3
  6. package/dist-server/engine/scenario-engine.js.map +1 -1
  7. package/dist-server/engine/task/pick-pending-scenario.js +2 -2
  8. package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
  9. package/dist-server/engine/task/stop-scenario.js +2 -2
  10. package/dist-server/engine/task/stop-scenario.js.map +1 -1
  11. package/dist-server/engine/task/sub-scenario.js +2 -2
  12. package/dist-server/engine/task/sub-scenario.js.map +1 -1
  13. package/dist-server/engine/task/switch-range-scenario.js +2 -2
  14. package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
  15. package/dist-server/engine/task/switch-scenario.js +2 -2
  16. package/dist-server/engine/task/switch-scenario.js.map +1 -1
  17. package/dist-server/routers/scenario-schedule-callback-router.js +2 -2
  18. package/dist-server/routers/scenario-schedule-callback-router.js.map +1 -1
  19. package/dist-server/routers/scenario-view-router.js +2 -2
  20. package/dist-server/routers/scenario-view-router.js.map +1 -1
  21. package/dist-server/service/index.js +1 -1
  22. package/dist-server/service/index.js.map +1 -1
  23. package/dist-server/service/scenario/index.js +2 -2
  24. package/dist-server/service/scenario/index.js.map +1 -1
  25. package/dist-server/service/scenario/scenario-mutation.js +18 -18
  26. package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
  27. package/dist-server/service/scenario/scenario-query.js +13 -12
  28. package/dist-server/service/scenario/scenario-query.js.map +1 -1
  29. package/dist-server/service/scenario/scenario-type.js +3 -118
  30. package/dist-server/service/scenario/scenario-type.js.map +1 -1
  31. package/dist-server/service/scenario/scenario.js +124 -0
  32. package/dist-server/service/scenario/scenario.js.map +1 -0
  33. package/dist-server/service/scenario-instance/scenario-instance-mutation.js +2 -2
  34. package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
  35. package/dist-server/service/step/step-mutation.js +2 -2
  36. package/dist-server/service/step/step-mutation.js.map +1 -1
  37. package/dist-server/service/step/step-query.js +3 -3
  38. package/dist-server/service/step/step-query.js.map +1 -1
  39. package/dist-server/service/step/step-type.js +4 -4
  40. package/dist-server/service/step/step-type.js.map +1 -1
  41. package/dist-server/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +2 -2
  43. package/server/engine/analyzer/analyze-integration.ts +1 -1
  44. package/server/engine/connector/operato-connector.ts +4 -3
  45. package/server/engine/scenario-engine.ts +3 -1
  46. package/server/engine/task/pick-pending-scenario.ts +1 -1
  47. package/server/engine/task/stop-scenario.ts +1 -1
  48. package/server/engine/task/sub-scenario.ts +1 -1
  49. package/server/engine/task/switch-range-scenario.ts +1 -1
  50. package/server/engine/task/switch-scenario.ts +1 -1
  51. package/server/routers/scenario-schedule-callback-router.ts +1 -1
  52. package/server/routers/scenario-view-router.ts +2 -1
  53. package/server/service/index.ts +1 -1
  54. package/server/service/scenario/index.ts +1 -1
  55. package/server/service/scenario/scenario-mutation.ts +3 -5
  56. package/server/service/scenario/scenario-query.ts +2 -1
  57. package/server/service/scenario/scenario-type.ts +3 -106
  58. package/server/service/scenario/scenario.ts +109 -0
  59. package/server/service/scenario-instance/scenario-instance-mutation.ts +1 -1
  60. package/server/service/step/step-mutation.ts +1 -1
  61. package/server/service/step/step-query.ts +1 -1
  62. package/server/service/step/step-type.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-base",
3
- "version": "6.2.70",
3
+ "version": "6.2.75",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "@types/cron": "^2.0.1"
48
48
  },
49
- "gitHead": "99c274f281e62be08a952c10cb3b8fdecba24a65"
49
+ "gitHead": "55d7ca9bf5591461d28cca4640941a3f6df93bc0"
50
50
  }
@@ -1,7 +1,7 @@
1
1
  import uniq from 'lodash/uniq'
2
2
 
3
3
  import { Domain, getRepository } from '@things-factory/shell'
4
- import { Scenario } from '../../service/scenario/scenario-type'
4
+ import { Scenario } from '../../service/scenario/scenario'
5
5
  import { Connection } from '../../service/connection/connection-type'
6
6
 
7
7
  export async function analyzeIntegration(domain: Domain) {
@@ -7,15 +7,16 @@ import { setContext } from '@apollo/client/link/context'
7
7
  import WebSocket from 'ws'
8
8
  import { createClient } from 'graphql-ws'
9
9
  import { GraphQLWsLink } from '@apollo/client/link/subscriptions'
10
- import { Observable, getMainDefinition } from '@apollo/client/utilities'
10
+ import { getMainDefinition } from '@apollo/client/utilities'
11
11
  import gql from 'graphql-tag'
12
12
 
13
13
  import { ConnectionManager } from '../connection-manager'
14
14
  import { Connector } from '../types'
15
- import { Scenario, ScenarioInstance } from '../../service'
15
+ import { Scenario } from '../../service/scenario/scenario'
16
+ import { ScenarioInstance } from '../../service/scenario-instance/scenario-instance-type'
16
17
 
17
18
  import { getRepository, GraphqlLocalClient, Domain } from '@things-factory/shell'
18
- import { PrivilegeObject, User, checkPermission } from '@things-factory/auth-base'
19
+ import { User, checkPermission } from '@things-factory/auth-base'
19
20
 
20
21
  const debug = require('debug')('things-factory:integration-base:operato-connector-subscription')
21
22
 
@@ -1,6 +1,8 @@
1
1
  import { getRepository, GraphqlLocalClient, pubsub } from '@things-factory/shell'
2
2
 
3
- import { Scenario, ScenarioInstance } from '../service'
3
+ import { Scenario } from '../service/scenario/scenario'
4
+ import { ScenarioInstance } from '../service/scenario-instance/scenario-instance-type'
5
+
4
6
  import { PendingQueue } from './pending-queue'
5
7
 
6
8
  const debug = require('debug')('things-factory:integration-base:scenario-engine')
@@ -1,7 +1,7 @@
1
1
  import { getRepository } from '@things-factory/shell'
2
2
  import { sleep } from '@things-factory/utils'
3
3
 
4
- import { Scenario } from '../../service'
4
+ import { Scenario } from '../../service/scenario/scenario'
5
5
  import { ScenarioEngine } from '../scenario-engine'
6
6
  import { TaskRegistry } from '../task-registry'
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { getRepository } from '@things-factory/shell'
2
2
 
3
- import { Scenario } from '../../service'
3
+ import { Scenario } from '../../service/scenario/scenario'
4
4
  import { ScenarioEngine } from '../../engine'
5
5
  import { TaskRegistry } from '../task-registry'
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { getRepository } from '@things-factory/shell'
2
2
  import { access, deepClone } from '@things-factory/utils'
3
3
 
4
- import { Scenario } from '../../service'
4
+ import { Scenario } from '../../service/scenario/scenario'
5
5
  import { TaskRegistry } from '../task-registry'
6
6
 
7
7
  async function SubScenario(step, context) {
@@ -1,7 +1,7 @@
1
1
  import { getRepository } from '@things-factory/shell'
2
2
  import { access, deepClone } from '@things-factory/utils'
3
3
 
4
- import { Scenario } from '../../service'
4
+ import { Scenario } from '../../service/scenario/scenario'
5
5
  import { TaskRegistry } from '../task-registry'
6
6
 
7
7
  async function SwitchRangeScenario(step, context) {
@@ -1,7 +1,7 @@
1
1
  import { getRepository } from '@things-factory/shell'
2
2
  import { access, deepClone } from '@things-factory/utils'
3
3
 
4
- import { Scenario } from '../../service'
4
+ import { Scenario } from '../../service/scenario/scenario'
5
5
  import { TaskRegistry } from '../task-registry'
6
6
 
7
7
  async function SwitchScenario(step, context) {
@@ -4,7 +4,7 @@ import { getRepository } from '@things-factory/shell'
4
4
  import { User } from '@things-factory/auth-base'
5
5
  import { ScheduleRegisterRequest } from '@things-factory/scheduler-client'
6
6
 
7
- import { Scenario } from '../service/scenario/scenario-type'
7
+ import { Scenario } from '../service/scenario/scenario'
8
8
  import { ScenarioEngine } from '../engine/scenario-engine'
9
9
 
10
10
  export const scenarioScheduleCallbackRouter = new Router()
@@ -2,7 +2,8 @@ import Router from 'koa-router'
2
2
 
3
3
  import { getRepository } from '@things-factory/shell'
4
4
 
5
- import { Scenario, Step } from '../service'
5
+ import { Scenario } from '../service/scenario/scenario'
6
+ import { Step } from '../service/step/step-type'
6
7
 
7
8
  export const scenarioViewRouter = new Router()
8
9
 
@@ -13,7 +13,7 @@ export * from './property-spec'
13
13
  export * from './task-type/task-type-type'
14
14
  export * from './connector/connector-type'
15
15
  export * from './connection/connection-type'
16
- export * from './scenario/scenario-type'
16
+ export * from './scenario/scenario'
17
17
  export * from './scenario-instance/scenario-instance-type'
18
18
  export * from './scenario-queue/scenario-queue-type'
19
19
  export * from './step/step-type'
@@ -1,4 +1,4 @@
1
- import { Scenario } from './scenario-type'
1
+ import { Scenario } from './scenario'
2
2
  import { ScenarioQuery } from './scenario-query'
3
3
  import { ScenarioMutation } from './scenario-mutation'
4
4
 
@@ -1,7 +1,6 @@
1
1
  import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
- import { EntityManager, In } from 'typeorm'
2
+ import { In } from 'typeorm'
3
3
 
4
- import { Domain } from '@things-factory/shell'
5
4
  import {
6
5
  Application,
7
6
  getCallbackBaseWithDomainContext,
@@ -10,12 +9,11 @@ import {
10
9
  } from '@things-factory/scheduler-client'
11
10
 
12
11
  import { Step } from '../step/step-type'
13
- import { NewScenario, Scenario, ScenarioPatch } from './scenario-type'
12
+ import { Scenario } from './scenario'
13
+ import { NewScenario, ScenarioPatch } from './scenario-type'
14
14
 
15
15
  const crypto = require('crypto')
16
16
 
17
- const debug = require('debug')('things-factory:integration-base:scenario-mutation')
18
-
19
17
  @Resolver(Scenario)
20
18
  export class ScenarioMutation {
21
19
  @Directive('@transaction')
@@ -7,7 +7,8 @@ import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from
7
7
  import { ScenarioEngine } from '../../engine'
8
8
  import { ScenarioInstance, ScenarioInstanceStatus } from '../scenario-instance/scenario-instance-type'
9
9
  import { Step } from '../step/step-type'
10
- import { Scenario, ScenarioList } from './scenario-type'
10
+ import { Scenario } from './scenario'
11
+ import { ScenarioList } from './scenario-type'
11
12
  import { Connection } from '../connection/connection-type'
12
13
 
13
14
  @Resolver(Scenario)
@@ -1,112 +1,9 @@
1
1
  import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
2
- import {
3
- Column,
4
- CreateDateColumn,
5
- Entity,
6
- Index,
7
- ManyToOne,
8
- OneToMany,
9
- PrimaryGeneratedColumn,
10
- RelationId,
11
- UpdateDateColumn
12
- } from 'typeorm'
13
-
14
- import { PrivilegeObject, PrivilegeInput, User } from '@things-factory/auth-base'
15
- import { Domain } from '@things-factory/shell'
16
-
17
- import { ScenarioEngine } from '../../engine'
18
- import { Step, StepPatch } from '../step/step-type'
19
-
20
- @Entity()
21
- @Index('ix_scenario_0', (scenario: Scenario) => [scenario.domain, scenario.name], { unique: true })
22
- @ObjectType()
23
- export class Scenario {
24
- @PrimaryGeneratedColumn('uuid')
25
- @Field(type => ID)
26
- id?: string
27
-
28
- @ManyToOne(type => Domain)
29
- @Field({ nullable: true })
30
- domain?: Domain
31
-
32
- @RelationId((scenario: Scenario) => scenario.domain)
33
- domainId?: string
34
-
35
- @Column()
36
- @Field()
37
- name?: string
38
-
39
- @Column({ nullable: true })
40
- @Field({ nullable: true })
41
- description?: string
42
-
43
- @Column({ nullable: true })
44
- @Field({ nullable: true })
45
- type?: string
46
2
 
47
- @Column({ nullable: true })
48
- @Field({ nullable: true, description: 'accessible and executable system-wide' })
49
- public?: boolean
3
+ import { PrivilegeInput } from '@things-factory/auth-base'
50
4
 
51
- @Column({ nullable: true })
52
- @Field({ nullable: true, description: '[will be deprecated] automatically be started when this server start' })
53
- active?: boolean
54
-
55
- @Column({ nullable: true })
56
- @Field({ nullable: true })
57
- schedule?: string
58
-
59
- @Column({ nullable: true })
60
- @Field({ nullable: true })
61
- scheduleId?: string
62
-
63
- @Column({ nullable: true })
64
- @Field({ nullable: true })
65
- timezone?: string
66
-
67
- @OneToMany(type => Step, step => step.scenario)
68
- @Field(type => [Step], { nullable: true })
69
- steps?: Step[]
70
-
71
- @Column({ type: 'simple-json', nullable: true })
72
- @Field(type => PrivilegeObject, { nullable: true })
73
- privilege?: PrivilegeObject
74
-
75
- @CreateDateColumn()
76
- @Field({ nullable: true })
77
- createdAt?: Date
78
-
79
- @UpdateDateColumn()
80
- @Field({ nullable: true })
81
- updatedAt?: Date
82
-
83
- @ManyToOne(type => User, { nullable: true })
84
- @Field({ nullable: true })
85
- creator?: User
86
-
87
- @RelationId((scenario: Scenario) => scenario.creator)
88
- creatorId?: string
89
-
90
- @ManyToOne(type => User, { nullable: true })
91
- @Field({ nullable: true })
92
- updater?: User
93
-
94
- @RelationId((scenario: Scenario) => scenario.updater)
95
- updaterId?: string
96
-
97
- async start(instanceName, variables?: any) {
98
- try {
99
- await ScenarioEngine.load(instanceName || this.name, this, { domain: this.domain, user: this.updater, variables })
100
- } catch (ex) {}
101
- }
102
-
103
- async stop(instanceName?) {
104
- try {
105
- await ScenarioEngine.unload(this.domain, instanceName || this.name)
106
- } finally {
107
- }
108
- }
109
- }
5
+ import { Scenario } from './scenario'
6
+ import { StepPatch } from '../step/step-type'
110
7
 
111
8
  @InputType()
112
9
  export class NewScenario {
@@ -0,0 +1,109 @@
1
+ import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
2
+ import {
3
+ Column,
4
+ CreateDateColumn,
5
+ Entity,
6
+ Index,
7
+ ManyToOne,
8
+ OneToMany,
9
+ PrimaryGeneratedColumn,
10
+ RelationId,
11
+ UpdateDateColumn
12
+ } from 'typeorm'
13
+
14
+ import { PrivilegeObject, PrivilegeInput, User } from '@things-factory/auth-base'
15
+ import { Domain } from '@things-factory/shell'
16
+
17
+ import { ScenarioEngine } from '../../engine'
18
+ import { Step } from '../step/step-type'
19
+
20
+ @Entity()
21
+ @Index('ix_scenario_0', (scenario: Scenario) => [scenario.domain, scenario.name], { unique: true })
22
+ @ObjectType()
23
+ export class Scenario {
24
+ @PrimaryGeneratedColumn('uuid')
25
+ @Field(type => ID)
26
+ id?: string
27
+
28
+ @ManyToOne(type => Domain)
29
+ @Field({ nullable: true })
30
+ domain?: Domain
31
+
32
+ @RelationId((scenario: Scenario) => scenario.domain)
33
+ domainId?: string
34
+
35
+ @Column()
36
+ @Field()
37
+ name?: string
38
+
39
+ @Column({ nullable: true })
40
+ @Field({ nullable: true })
41
+ description?: string
42
+
43
+ @Column({ nullable: true })
44
+ @Field({ nullable: true })
45
+ type?: string
46
+
47
+ @Column({ nullable: true })
48
+ @Field({ nullable: true, description: 'accessible and executable system-wide' })
49
+ public?: boolean
50
+
51
+ @Column({ nullable: true })
52
+ @Field({ nullable: true, description: '[will be deprecated] automatically be started when this server start' })
53
+ active?: boolean
54
+
55
+ @Column({ nullable: true })
56
+ @Field({ nullable: true })
57
+ schedule?: string
58
+
59
+ @Column({ nullable: true })
60
+ @Field({ nullable: true })
61
+ scheduleId?: string
62
+
63
+ @Column({ nullable: true })
64
+ @Field({ nullable: true })
65
+ timezone?: string
66
+
67
+ @OneToMany(type => Step, step => step.scenario)
68
+ @Field(type => [Step], { nullable: true })
69
+ steps?: Step[]
70
+
71
+ @Column({ type: 'simple-json', nullable: true })
72
+ @Field(type => PrivilegeObject, { nullable: true })
73
+ privilege?: PrivilegeObject
74
+
75
+ @CreateDateColumn()
76
+ @Field({ nullable: true })
77
+ createdAt?: Date
78
+
79
+ @UpdateDateColumn()
80
+ @Field({ nullable: true })
81
+ updatedAt?: Date
82
+
83
+ @ManyToOne(type => User, { nullable: true })
84
+ @Field({ nullable: true })
85
+ creator?: User
86
+
87
+ @RelationId((scenario: Scenario) => scenario.creator)
88
+ creatorId?: string
89
+
90
+ @ManyToOne(type => User, { nullable: true })
91
+ @Field({ nullable: true })
92
+ updater?: User
93
+
94
+ @RelationId((scenario: Scenario) => scenario.updater)
95
+ updaterId?: string
96
+
97
+ async start(instanceName, variables?: any) {
98
+ try {
99
+ await ScenarioEngine.load(instanceName || this.name, this, { domain: this.domain, user: this.updater, variables })
100
+ } catch (ex) {}
101
+ }
102
+
103
+ async stop(instanceName?) {
104
+ try {
105
+ await ScenarioEngine.unload(this.domain, instanceName || this.name)
106
+ } finally {
107
+ }
108
+ }
109
+ }
@@ -3,7 +3,7 @@ import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'
3
3
  import { getRepository, Domain, GraphqlLocalClient, ScalarObject } from '@things-factory/shell'
4
4
 
5
5
  import { ScenarioEngine } from '../../engine'
6
- import { Scenario } from '../scenario/scenario-type'
6
+ import { Scenario } from '../scenario/scenario'
7
7
  import { ScenarioInstance } from './scenario-instance-type'
8
8
  import { PrivilegeObject, User, checkPermission } from '@things-factory/auth-base'
9
9
  import { Step } from '../step/step-type'
@@ -1,7 +1,7 @@
1
1
  import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
2
  import { In } from 'typeorm'
3
3
 
4
- import { Scenario } from '../scenario/scenario-type'
4
+ import { Scenario } from '../scenario/scenario'
5
5
  import { Step, StepPatch } from './step-type'
6
6
 
7
7
  @Resolver(Step)
@@ -3,7 +3,7 @@ import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graph
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
5
5
 
6
- import { Scenario } from '../scenario/scenario-type'
6
+ import { Scenario } from '../scenario/scenario'
7
7
  import { Step, StepList } from './step-type'
8
8
 
9
9
  @Resolver(Step)
@@ -13,7 +13,7 @@ import {
13
13
  import { User } from '@things-factory/auth-base'
14
14
  import { Domain } from '@things-factory/shell'
15
15
 
16
- import { Scenario } from '../scenario/scenario-type'
16
+ import { Scenario } from '../scenario/scenario'
17
17
 
18
18
  @Entity()
19
19
  @Index('ix_step_0', (step: Step) => [step.scenario, step.sequence], { unique: true })