@things-factory/dataset 6.2.161 → 6.2.163

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/dataset",
3
- "version": "6.2.161",
3
+ "version": "6.2.163",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -40,20 +40,20 @@
40
40
  "@operato/shell": "^1.0.1",
41
41
  "@operato/styles": "^1.0.0",
42
42
  "@operato/utils": "^1.0.1",
43
- "@things-factory/auth-base": "^6.2.158",
44
- "@things-factory/aws-base": "^6.2.158",
45
- "@things-factory/board-service": "^6.2.160",
43
+ "@things-factory/auth-base": "^6.2.162",
44
+ "@things-factory/aws-base": "^6.2.162",
45
+ "@things-factory/board-service": "^6.2.163",
46
46
  "@things-factory/env": "^6.2.139",
47
- "@things-factory/integration-base": "^6.2.158",
48
- "@things-factory/organization": "^6.2.160",
49
- "@things-factory/scheduler-client": "^6.2.158",
50
- "@things-factory/shell": "^6.2.158",
51
- "@things-factory/work-shift": "^6.2.158",
52
- "@things-factory/worklist": "^6.2.160",
47
+ "@things-factory/integration-base": "^6.2.163",
48
+ "@things-factory/organization": "^6.2.162",
49
+ "@things-factory/scheduler-client": "^6.2.162",
50
+ "@things-factory/shell": "^6.2.162",
51
+ "@things-factory/work-shift": "^6.2.162",
52
+ "@things-factory/worklist": "^6.2.163",
53
53
  "cron-parser": "^4.3.0",
54
54
  "moment-timezone": "^0.5.40",
55
55
  "simple-statistics": "^7.8.3",
56
56
  "statistics": "^3.3.0"
57
57
  },
58
- "gitHead": "914b1dc22c1f532dbae28088363e6ca90411eb13"
58
+ "gitHead": "9709a69dcd717d56fb6d84d0f2c6a92c22d09f0c"
59
59
  }
@@ -1,3 +1,4 @@
1
+ import { In } from 'typeorm'
1
2
  import { Activity, ActivityInstance, ActivityInstanceStatus, UpdateActivityInstanceStateAddendum } from '@things-factory/worklist'
2
3
  import { issue } from '@things-factory/worklist/dist-server/controllers/activity-instance/issue'
3
4
 
@@ -10,7 +11,7 @@ async function callback(activityInstance: ActivityInstance, addendum: UpdateActi
10
11
 
11
12
  if (state == ActivityInstanceStatus.Ended) {
12
13
  const activity = (await tx.getRepository(Activity).findOneBy({
13
- domain: { id: domain.id },
14
+ domain: domain.parentId ? In([domain.id, domain.parentId]) : { id: domain.id },
14
15
  name: 'OOC Resolve'
15
16
  })) as Activity
16
17
 
@@ -228,26 +228,31 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
228
228
  })
229
229
 
230
230
  if (scenario) {
231
- scenario.start(scenario.name + ':' + dataSet.name + ':' + dataSample.id, {
232
- dataOocId: dataOoc.id,
233
- dataSampleId: dataSample.id,
234
- dataSet: dataSet.id,
235
- data,
236
- ooc,
237
- oos,
238
- judgment,
239
- collectedAt,
240
- workDate,
241
- workShift,
242
- domain: {
243
- id: domain.id,
244
- subdomain: domain.subdomain,
245
- name: domain.name
246
- },
247
- updator: {
248
- id: user.id,
249
- email: user.email,
250
- name: user.name
231
+ scenario.start({
232
+ instanceName: scenario.name + ':' + dataSet.name + ':' + dataSample.id,
233
+ domain,
234
+ user,
235
+ variables: {
236
+ dataOocId: dataOoc.id,
237
+ dataSampleId: dataSample.id,
238
+ dataSet: dataSet.id,
239
+ data,
240
+ ooc,
241
+ oos,
242
+ judgment,
243
+ collectedAt,
244
+ workDate,
245
+ workShift,
246
+ domain: {
247
+ id: domain.id,
248
+ subdomain: domain.subdomain,
249
+ name: domain.name
250
+ },
251
+ updator: {
252
+ id: user.id,
253
+ email: user.email,
254
+ name: user.name
255
+ }
251
256
  }
252
257
  })
253
258
  } else {
@@ -256,12 +261,14 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
256
261
  }
257
262
 
258
263
  const activity = (await tx.getRepository(Activity).findOneBy({
259
- domain: { id: domain.id },
264
+ domain: domain.parentId ? { id: In([domain.id, domain.parentId]) } : { id: domain.id },
260
265
  name: 'OOC Review'
261
266
  })) as Activity
262
267
 
263
268
  if (activity) {
264
- const assignee = dataSet.supervisoryRoleId && (await tx.getRepository(Role).findOneBy({ domain: { id: domain.id }, id: dataSet.supervisoryRoleId }))
269
+ const assignee =
270
+ dataSet.supervisoryRoleId &&
271
+ (await tx.getRepository(Role).findOneBy({ domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: dataSet.supervisoryRoleId }))
265
272
 
266
273
  const assignees = dataSet.supervisoryRoleId ? [{ type: 'Role', value: dataSet.supervisoryRoleId, assignee }] : []
267
274
 
@@ -285,7 +292,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
285
292
  console.error(`Assignees are not set. So Data OOC Review task for ${dataOoc.name}(${dataOoc.id}) could not be issued.`)
286
293
  }
287
294
  } else {
288
- console.error('OOC Review Activity not installed.')
295
+ console.warn('OOC Review Activity not installed.')
289
296
  }
290
297
 
291
298
  try {
@@ -311,32 +318,37 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
311
318
  if (normalScenarioId) {
312
319
  const scenario = await tx.getRepository(Scenario).findOne({
313
320
  where: {
314
- domain: domain.parentId ? { id: In([domain.id, domain.parentId]) } : { id: domain.id },
321
+ domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },
315
322
  id: normalScenarioId
316
323
  },
317
324
  relations: ['domain', 'steps', 'updater']
318
325
  })
319
326
 
320
327
  if (scenario) {
321
- scenario.start(scenario.name + ':' + dataSet.name + ':' + dataSample.id, {
322
- dataSampleId: dataSample.id,
323
- dataSet: dataSet.id,
324
- data,
325
- ooc,
326
- oos,
327
- judgment,
328
- collectedAt,
329
- workDate,
330
- workShift,
331
- domain: {
332
- id: domain.id,
333
- subdomain: domain.subdomain,
334
- name: domain.name
335
- },
336
- updator: {
337
- id: user.id,
338
- email: user.email,
339
- name: user.name
328
+ scenario.start({
329
+ instanceName: scenario.name + ':' + dataSet.name + ':' + dataSample.id,
330
+ domain,
331
+ user,
332
+ variables: {
333
+ dataSampleId: dataSample.id,
334
+ dataSet: dataSet.id,
335
+ data,
336
+ ooc,
337
+ oos,
338
+ judgment,
339
+ collectedAt,
340
+ workDate,
341
+ workShift,
342
+ domain: {
343
+ id: domain.id,
344
+ subdomain: domain.subdomain,
345
+ name: domain.name
346
+ },
347
+ updator: {
348
+ id: user.id,
349
+ email: user.email,
350
+ name: user.name
351
+ }
340
352
  }
341
353
  })
342
354
  } else {
@@ -346,12 +358,14 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
346
358
 
347
359
  if (dataSet.requiresReview) {
348
360
  const activity = (await tx.getRepository(Activity).findOneBy({
349
- domain: { id: domain.id },
361
+ domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },
350
362
  name: 'Data Review'
351
363
  })) as Activity
352
364
 
353
365
  if (activity) {
354
- const assignee = dataSet.supervisoryRoleId && (await tx.getRepository(Role).findOneBy({ domain: { id: domain.id }, id: dataSet.supervisoryRoleId }))
366
+ const assignee =
367
+ dataSet.supervisoryRoleId &&
368
+ (await tx.getRepository(Role).findOneBy({ domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: dataSet.supervisoryRoleId }))
355
369
 
356
370
  const assignees = dataSet.supervisoryRoleId ? [{ type: 'Role', value: dataSet.supervisoryRoleId, assignee }] : []
357
371
 
@@ -23,7 +23,7 @@ export async function issueCollectData(domainId: string, dataSetId: string, cont
23
23
  })
24
24
 
25
25
  const activity = (await tx.getRepository(Activity).findOneBy({
26
- domain: { id: domain.id },
26
+ domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },
27
27
  name: 'Collect Data'
28
28
  })) as Activity
29
29
 
@@ -66,7 +66,8 @@ export class DataSetQuery {
66
66
  where: { id: user.id },
67
67
  relations: ['roles']
68
68
  })
69
- const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)
69
+
70
+ const roles = user.roles.filter(role => role.domainId === domain.id || (domain.parentId && role.domainId === domain.parentId)).map(role => role.id)
70
71
 
71
72
  if (!roles.length) {
72
73
  return { items: [], total: 0 }