@things-factory/integration-base 6.1.146 → 6.1.152

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-base",
3
- "version": "6.1.146",
3
+ "version": "6.1.152",
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.146",
30
- "@things-factory/auth-base": "^6.1.146",
29
+ "@things-factory/api": "^6.1.152",
30
+ "@things-factory/auth-base": "^6.1.152",
31
31
  "@things-factory/env": "^6.1.145",
32
- "@things-factory/oauth2-client": "^6.1.146",
33
- "@things-factory/scheduler-client": "^6.1.146",
34
- "@things-factory/shell": "^6.1.145",
32
+ "@things-factory/oauth2-client": "^6.1.152",
33
+ "@things-factory/scheduler-client": "^6.1.152",
34
+ "@things-factory/shell": "^6.1.152",
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": "aa259261bbad566fd57b59848372675ca09329ce"
49
+ "gitHead": "9d0c8827cb25f037bcb4270ea53dcd95f73b2722"
50
50
  }
@@ -156,4 +156,26 @@ export class ConnectionMutation {
156
156
  : ConnectionStatus.DISCONNECTED
157
157
  }
158
158
  }
159
+
160
+ @Directive('@transaction')
161
+ // @Directive('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true)')
162
+ @Mutation(returns => Boolean, { description: 'To import multiple connections' })
163
+ async importConnections(
164
+ @Arg('connections', type => [ConnectionPatch]) connections: Connection[],
165
+ @Ctx() context: ResolverContext
166
+ ): Promise<boolean> {
167
+ const { tx, domain, user } = context.state
168
+
169
+ await Promise.all(
170
+ connections.map(async (connection: Connection) => {
171
+ await tx.getRepository(Connection).save({
172
+ ...connection,
173
+ domain,
174
+ updater: user
175
+ })
176
+ })
177
+ )
178
+
179
+ return true
180
+ }
159
181
  }
@@ -186,8 +186,8 @@ export class ConnectionPatch {
186
186
  @Field({ nullable: true })
187
187
  params?: string
188
188
 
189
- @Field()
190
- cuFlag: string
189
+ @Field({ nullable: true })
190
+ cuFlag?: string
191
191
  }
192
192
 
193
193
  @ObjectType()
@@ -147,17 +147,24 @@ export class ScenarioMutation {
147
147
  @Arg('scenarios', type => [ScenarioPatch]) scenarios: Scenario[],
148
148
  @Ctx() context: ResolverContext
149
149
  ): Promise<boolean> {
150
- const tx: EntityManager = context.state.tx
151
- const domain: Domain = context.state.domain
150
+ const { domain, user, tx } = context.state
151
+
152
152
  await Promise.all(
153
153
  scenarios.map(async (scenario: Scenario) => {
154
- const createdScenario: Scenario = await tx.getRepository(Scenario).save({ domain, ...scenario })
154
+ const savedScenario: Scenario = await tx.getRepository(Scenario).save({
155
+ domain,
156
+ ...scenario,
157
+ updater: user
158
+ })
155
159
  if (scenario.steps?.length) {
156
160
  await tx.getRepository(Step).save(
157
161
  scenario.steps.map((step: Step) => {
158
- step.domain = domain
159
- step.scenario = createdScenario
160
- return step
162
+ return {
163
+ ...step,
164
+ domain,
165
+ scenario: savedScenario,
166
+ updater: user
167
+ }
161
168
  })
162
169
  )
163
170
  }