@things-factory/ops-master 10.1.296 → 10.1.297
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/service/index.d.ts +1 -0
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/location/sites-of-system.d.ts +20 -0
- package/dist-server/service/location/sites-of-system.js +46 -0
- package/dist-server/service/material/material-revision-service.js +11 -11
- package/dist-server/service/recipe/recipe-revision-service.js +12 -12
- package/dist-server/service/test-spec/test-spec-revision-service.js +11 -11
- package/package.json +7 -6
|
@@ -35,6 +35,7 @@ export * from './asset/asset-query';
|
|
|
35
35
|
export * from './location/operational-location';
|
|
36
36
|
export * from './location/location-master';
|
|
37
37
|
export * from './location/location-query';
|
|
38
|
+
export * from './location/sites-of-system';
|
|
38
39
|
export * from './material/material-class';
|
|
39
40
|
export * from './material/material-definition';
|
|
40
41
|
export * from './material/material-revision';
|
|
@@ -40,6 +40,7 @@ tslib_1.__exportStar(require("./asset/asset-query"), exports);
|
|
|
40
40
|
tslib_1.__exportStar(require("./location/operational-location"), exports);
|
|
41
41
|
tslib_1.__exportStar(require("./location/location-master"), exports);
|
|
42
42
|
tslib_1.__exportStar(require("./location/location-query"), exports);
|
|
43
|
+
tslib_1.__exportStar(require("./location/sites-of-system"), exports);
|
|
43
44
|
tslib_1.__exportStar(require("./material/material-class"), exports);
|
|
44
45
|
tslib_1.__exportStar(require("./material/material-definition"), exports);
|
|
45
46
|
tslib_1.__exportStar(require("./material/material-revision"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EntityManager } from 'typeorm';
|
|
2
|
+
import { Domain } from '@things-factory/shell';
|
|
3
|
+
/**
|
|
4
|
+
* **The sites that run a system** - the domains that declared places of it (`OperationalLocation.system`, and a `type`
|
|
5
|
+
* when given: a yard's dock doors, a warehouse's bins). A product works only where its places are: settings to seed,
|
|
6
|
+
* to-dos to install, a sweep to run.
|
|
7
|
+
*
|
|
8
|
+
* Lifted on 2026-11-18 from the yard and the warehouse, which each walked the places at boot and in their sweeps.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sitesOfSystem(manager: EntityManager, system: string, type?: string): Promise<Domain[]>;
|
|
11
|
+
/**
|
|
12
|
+
* **At boot, for every site of a system** - in the boot's own turn (`inBootTurn`, shell: sqlite holds one connection,
|
|
13
|
+
* and two boot transactions crossing on it broke each other). A site that fails is logged and the next one runs; boot
|
|
14
|
+
* never stops half done - the next boot does it again.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* onEachSiteOfSystem('yms', 'operato-yard', async (manager, domain) => { await YARD_SETTINGS.seed(manager, domain) })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function onEachSiteOfSystem(system: string, label: string, work: (manager: EntityManager, domain: Domain) => Promise<unknown>): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sitesOfSystem = sitesOfSystem;
|
|
4
|
+
exports.onEachSiteOfSystem = onEachSiteOfSystem;
|
|
5
|
+
const shell_1 = require("@things-factory/shell");
|
|
6
|
+
const operational_location_1 = require("./operational-location");
|
|
7
|
+
/**
|
|
8
|
+
* **The sites that run a system** - the domains that declared places of it (`OperationalLocation.system`, and a `type`
|
|
9
|
+
* when given: a yard's dock doors, a warehouse's bins). A product works only where its places are: settings to seed,
|
|
10
|
+
* to-dos to install, a sweep to run.
|
|
11
|
+
*
|
|
12
|
+
* Lifted on 2026-11-18 from the yard and the warehouse, which each walked the places at boot and in their sweeps.
|
|
13
|
+
*/
|
|
14
|
+
async function sitesOfSystem(manager, system, type) {
|
|
15
|
+
const places = await manager.getRepository(operational_location_1.OperationalLocation).find({ where: { system, ...(type ? { type } : {}) }, relations: ['domain'] });
|
|
16
|
+
const byId = new Map();
|
|
17
|
+
for (const place of places)
|
|
18
|
+
if (place.domain)
|
|
19
|
+
byId.set(place.domain.id, place.domain);
|
|
20
|
+
return [...byId.values()];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* **At boot, for every site of a system** - in the boot's own turn (`inBootTurn`, shell: sqlite holds one connection,
|
|
24
|
+
* and two boot transactions crossing on it broke each other). A site that fails is logged and the next one runs; boot
|
|
25
|
+
* never stops half done - the next boot does it again.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* onEachSiteOfSystem('yms', 'operato-yard', async (manager, domain) => { await YARD_SETTINGS.seed(manager, domain) })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function onEachSiteOfSystem(system, label, work) {
|
|
32
|
+
process.on('bootstrap-module-start', () => {
|
|
33
|
+
(0, shell_1.inBootTurn)(async () => {
|
|
34
|
+
const manager = (0, shell_1.getRepository)(shell_1.Domain).manager;
|
|
35
|
+
for (const domain of await sitesOfSystem(manager, system)) {
|
|
36
|
+
try {
|
|
37
|
+
await work(manager, domain);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.warn(`[${label}] ${domain.subdomain}: boot step failed - the next boot does it again. ${error?.message ?? error}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}).catch(error => console.warn(`[${label}] could not walk the sites of ${system} at boot - ${error?.message ?? error}`));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=sites-of-system.js.map
|
|
@@ -27,7 +27,7 @@ const material_class_1 = require("./material-class");
|
|
|
27
27
|
const test_specification_1 = require("../test-spec/test-specification");
|
|
28
28
|
const material_revision_1 = require("./material-revision");
|
|
29
29
|
const approval_input_1 = require("../master-change-approval/approval-input");
|
|
30
|
-
const
|
|
30
|
+
const shell_2 = require("@things-factory/shell");
|
|
31
31
|
class MaterialDefinitionRefusal extends shell_1.Refusal {
|
|
32
32
|
constructor(code, detail) {
|
|
33
33
|
super(code, {}, detail ?? MATERIAL_DEFINITION_REFUSALS[code] ?? 'The material definition change could not be applied.');
|
|
@@ -168,7 +168,7 @@ function content(input) {
|
|
|
168
168
|
async function subject(manager, domainId, materialId) {
|
|
169
169
|
const material = await manager.findOne(material_definition_1.MaterialDefinition, {
|
|
170
170
|
where: { id: materialId, domain: { id: domainId } },
|
|
171
|
-
...(0,
|
|
171
|
+
...(0, shell_2.writeLockOn)(manager, material_definition_1.MaterialDefinition)
|
|
172
172
|
});
|
|
173
173
|
if (!material)
|
|
174
174
|
refuse('MATERIAL_NOT_FOUND');
|
|
@@ -189,7 +189,7 @@ async function subject(manager, domainId, materialId) {
|
|
|
189
189
|
async function revision(manager, domainId, revisionId, locked = true) {
|
|
190
190
|
const found = await manager.findOne(material_revision_1.MaterialDefinitionRevision, {
|
|
191
191
|
where: { id: revisionId, domain: { id: domainId } },
|
|
192
|
-
...(locked ? (0,
|
|
192
|
+
...(locked ? (0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionRevision) : {})
|
|
193
193
|
});
|
|
194
194
|
if (!found)
|
|
195
195
|
refuse('REVISION_NOT_FOUND');
|
|
@@ -229,7 +229,7 @@ async function createMaterialDefinitionDraft(manager, domainId, creatorId, asked
|
|
|
229
229
|
}
|
|
230
230
|
const previous = await manager.findOne(material_revision_1.MaterialDefinitionRevision, {
|
|
231
231
|
where: { domain: { id: domainId }, material: { id: material.id } }, order: { revisionNumber: 'DESC' },
|
|
232
|
-
...(0,
|
|
232
|
+
...(0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionRevision)
|
|
233
233
|
});
|
|
234
234
|
const revisionNumber = (previous?.revisionNumber ?? 0) + 1;
|
|
235
235
|
let baseRevisionId = null;
|
|
@@ -373,7 +373,7 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
373
373
|
text(decision.actorId, 'publisher');
|
|
374
374
|
const previousDecision = await manager.findOne(material_revision_1.MaterialDefinitionPlan, {
|
|
375
375
|
where: { domain: { id: domainId }, publishedRevision: { id: revisionId } },
|
|
376
|
-
...(0,
|
|
376
|
+
...(0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionPlan)
|
|
377
377
|
});
|
|
378
378
|
if (previousDecision)
|
|
379
379
|
return previousDecision;
|
|
@@ -383,12 +383,12 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
383
383
|
await (0, material_revision_content_1.validateMaterialReferences)(manager, domainId, draft);
|
|
384
384
|
if (await manager.findOne(material_revision_1.MaterialDefinitionBasis, {
|
|
385
385
|
where: { domain: { id: domainId }, material: { id: material.id }, businessTime: (0, typeorm_1.MoreThanOrEqual)(draft.effectiveFrom) },
|
|
386
|
-
...(0,
|
|
386
|
+
...(0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionBasis)
|
|
387
387
|
}))
|
|
388
388
|
refuse('RETROACTIVE_IMPACT');
|
|
389
389
|
const oldPlan = await manager.findOne(material_revision_1.MaterialDefinitionPlan, {
|
|
390
390
|
where: { domain: { id: domainId }, material: { id: material.id }, generation: material.planGeneration },
|
|
391
|
-
...(0,
|
|
391
|
+
...(0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionPlan)
|
|
392
392
|
});
|
|
393
393
|
if (material.planGeneration > 0 && !oldPlan)
|
|
394
394
|
refuse('PLAN_CONFLICT');
|
|
@@ -396,7 +396,7 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
396
396
|
? await manager.find(material_revision_1.MaterialDefinitionSegment, {
|
|
397
397
|
where: { domain: { id: domainId }, material: { id: material.id }, plan: { id: oldPlan.id } },
|
|
398
398
|
order: { validFrom: 'ASC' },
|
|
399
|
-
...(0,
|
|
399
|
+
...(0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionSegment)
|
|
400
400
|
})
|
|
401
401
|
: [];
|
|
402
402
|
// Do not silently erase an already approved future appointment.
|
|
@@ -445,7 +445,7 @@ async function resolveMaterialDefinition(manager, domainId, materialId, business
|
|
|
445
445
|
const plan = await manager.findOne(material_revision_1.MaterialDefinitionPlan, {
|
|
446
446
|
where: { domain: { id: domainId }, material: { id: materialId }, recordedAt: (0, typeorm_1.LessThanOrEqual)(known) },
|
|
447
447
|
order: { generation: 'DESC' },
|
|
448
|
-
...(0,
|
|
448
|
+
...(0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionPlan)
|
|
449
449
|
});
|
|
450
450
|
if (!plan)
|
|
451
451
|
refuse('NO_EFFECTIVE_REVISION');
|
|
@@ -455,7 +455,7 @@ async function resolveMaterialDefinition(manager, domainId, materialId, business
|
|
|
455
455
|
.where({ domain: { id: domainId }, material: { id: materialId }, plan: { id: plan.id } })
|
|
456
456
|
.andWhere('segment.validFrom <= :at', { at })
|
|
457
457
|
.andWhere('(segment.validTo IS NULL OR segment.validTo > :at)', { at });
|
|
458
|
-
(0,
|
|
458
|
+
(0, shell_2.lockRowsOf)(manager, query);
|
|
459
459
|
const segments = await query.getMany();
|
|
460
460
|
if (!segments.length)
|
|
461
461
|
await refuseBeforeBaseline(manager, domainId, materialId, at);
|
|
@@ -599,7 +599,7 @@ async function captureMaterialDefinitionBasis(manager, domainId, materialId, rec
|
|
|
599
599
|
await lockSubject(manager, domainId, materialId);
|
|
600
600
|
const existing = await manager.findOne(material_revision_1.MaterialDefinitionBasis, {
|
|
601
601
|
where: { domain: { id: domainId }, recordKey },
|
|
602
|
-
...(0,
|
|
602
|
+
...(0, shell_2.writeLockOn)(manager, material_revision_1.MaterialDefinitionBasis)
|
|
603
603
|
});
|
|
604
604
|
if (existing) {
|
|
605
605
|
if (existing.materialId !== materialId || existing.businessTime.getTime() !== at.getTime())
|
|
@@ -29,7 +29,7 @@ const route_definition_1 = require("./route-definition");
|
|
|
29
29
|
const recipe_revision_content_1 = require("./recipe-revision-content");
|
|
30
30
|
const recipe_revision_1 = require("./recipe-revision");
|
|
31
31
|
const approval_input_1 = require("../master-change-approval/approval-input");
|
|
32
|
-
const
|
|
32
|
+
const shell_2 = require("@things-factory/shell");
|
|
33
33
|
async function saveLines(manager, domainId, recipeId, revisionId, inputs, outputs) {
|
|
34
34
|
const header = await manager.findOneByOrFail(recipe_revision_1.RecipeRevision, { id: revisionId, domain: { id: domainId } });
|
|
35
35
|
const route = header.route ? await manager.findOneBy(route_definition_1.RouteDefinition, { domain: { id: domainId }, name: header.route }) : null;
|
|
@@ -201,7 +201,7 @@ async function assertRecipeApprovalInput(manager, domainId, input) {
|
|
|
201
201
|
async function subject(manager, domainId, recipeId) {
|
|
202
202
|
const recipe = await manager.findOne(recipe_definition_1.RecipeDefinition, {
|
|
203
203
|
where: { id: recipeId, domain: { id: domainId } },
|
|
204
|
-
...(0,
|
|
204
|
+
...(0, shell_2.writeLockOn)(manager, recipe_definition_1.RecipeDefinition)
|
|
205
205
|
});
|
|
206
206
|
if (!recipe)
|
|
207
207
|
refuse('RECIPE_NOT_FOUND');
|
|
@@ -223,7 +223,7 @@ async function revision(manager, domainId, revisionId, locked = true) {
|
|
|
223
223
|
const found = await manager.findOne(recipe_revision_1.RecipeRevision, {
|
|
224
224
|
where: { id: revisionId, domain: { id: domainId } },
|
|
225
225
|
relations: { inputs: true, outputs: true },
|
|
226
|
-
...(locked ? (0,
|
|
226
|
+
...(locked ? (0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipeRevision) : {})
|
|
227
227
|
});
|
|
228
228
|
if (!found)
|
|
229
229
|
refuse('REVISION_NOT_FOUND');
|
|
@@ -267,7 +267,7 @@ async function createRecipeDraft(manager, domainId, creatorId, asked) {
|
|
|
267
267
|
}
|
|
268
268
|
const previous = await manager.findOne(recipe_revision_1.RecipeRevision, {
|
|
269
269
|
where: { domain: { id: domainId }, recipe: { id: recipe.id } }, order: { revisionNumber: 'DESC' },
|
|
270
|
-
...(0,
|
|
270
|
+
...(0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipeRevision)
|
|
271
271
|
});
|
|
272
272
|
const revisionNumber = (previous?.revisionNumber ?? 0) + 1;
|
|
273
273
|
let baseRevisionId = null;
|
|
@@ -417,7 +417,7 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
417
417
|
text(decision.actorId, 'publisher');
|
|
418
418
|
const previousDecision = await manager.findOne(recipe_revision_1.RecipePlan, {
|
|
419
419
|
where: { domain: { id: domainId }, publishedRevision: { id: revisionId } },
|
|
420
|
-
...(0,
|
|
420
|
+
...(0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipePlan)
|
|
421
421
|
});
|
|
422
422
|
if (previousDecision)
|
|
423
423
|
return previousDecision;
|
|
@@ -426,12 +426,12 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
426
426
|
// Only replacement from effectiveFrom onward is supported in this slice, not arbitrary rescheduling.
|
|
427
427
|
if (await manager.findOne(recipe_revision_1.RecipeBasis, {
|
|
428
428
|
where: { domain: { id: domainId }, recipe: { id: recipe.id }, businessTime: (0, typeorm_1.MoreThanOrEqual)(draft.effectiveFrom) },
|
|
429
|
-
...(0,
|
|
429
|
+
...(0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipeBasis)
|
|
430
430
|
}))
|
|
431
431
|
refuse('RETROACTIVE_IMPACT');
|
|
432
432
|
const oldPlan = await manager.findOne(recipe_revision_1.RecipePlan, {
|
|
433
433
|
where: { domain: { id: domainId }, recipe: { id: recipe.id }, generation: recipe.planGeneration },
|
|
434
|
-
...(0,
|
|
434
|
+
...(0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipePlan)
|
|
435
435
|
});
|
|
436
436
|
if (recipe.planGeneration > 0 && !oldPlan)
|
|
437
437
|
refuse('PLAN_CONFLICT');
|
|
@@ -439,7 +439,7 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
439
439
|
? await manager.find(recipe_revision_1.RecipeSegment, {
|
|
440
440
|
where: { domain: { id: domainId }, recipe: { id: recipe.id }, plan: { id: oldPlan.id } },
|
|
441
441
|
order: { validFrom: 'ASC' },
|
|
442
|
-
...(0,
|
|
442
|
+
...(0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipeSegment)
|
|
443
443
|
})
|
|
444
444
|
: [];
|
|
445
445
|
// Do not silently erase an already approved future appointment.
|
|
@@ -488,7 +488,7 @@ async function resolveRecipe(manager, domainId, recipeId, businessTime, knownAt
|
|
|
488
488
|
const plan = await manager.findOne(recipe_revision_1.RecipePlan, {
|
|
489
489
|
where: { domain: { id: domainId }, recipe: { id: recipeId }, recordedAt: (0, typeorm_1.LessThanOrEqual)(known) },
|
|
490
490
|
order: { generation: 'DESC' },
|
|
491
|
-
...(0,
|
|
491
|
+
...(0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipePlan)
|
|
492
492
|
});
|
|
493
493
|
if (!plan)
|
|
494
494
|
refuse('NO_EFFECTIVE_REVISION');
|
|
@@ -498,7 +498,7 @@ async function resolveRecipe(manager, domainId, recipeId, businessTime, knownAt
|
|
|
498
498
|
.where({ domain: { id: domainId }, recipe: { id: recipeId }, plan: { id: plan.id } })
|
|
499
499
|
.andWhere('segment.validFrom <= :at', { at })
|
|
500
500
|
.andWhere('(segment.validTo IS NULL OR segment.validTo > :at)', { at });
|
|
501
|
-
(0,
|
|
501
|
+
(0, shell_2.lockRowsOf)(manager, query);
|
|
502
502
|
const segments = await query.getMany();
|
|
503
503
|
if (!segments.length)
|
|
504
504
|
await refuseBeforeBaseline(manager, domainId, recipeId, at);
|
|
@@ -652,7 +652,7 @@ async function captureRecipeBasis(manager, domainId, recipeId, recordKey, busine
|
|
|
652
652
|
await lockSubject(manager, domainId, recipeId);
|
|
653
653
|
const existing = await manager.findOne(recipe_revision_1.RecipeBasis, {
|
|
654
654
|
where: { domain: { id: domainId }, recordKey },
|
|
655
|
-
...(0,
|
|
655
|
+
...(0, shell_2.writeLockOn)(manager, recipe_revision_1.RecipeBasis)
|
|
656
656
|
});
|
|
657
657
|
if (existing) {
|
|
658
658
|
if (existing.recipeId !== recipeId || existing.businessTime.getTime() !== at.getTime())
|
|
@@ -663,7 +663,7 @@ async function captureRecipeBasis(manager, domainId, recipeId, recordKey, busine
|
|
|
663
663
|
const resolvedAt = new Date();
|
|
664
664
|
const selected = await resolveRecipe(manager, domainId, recipeId, at, resolvedAt);
|
|
665
665
|
const route = selected.revision.routeDefinitionId ? await manager.findOne(route_definition_1.RouteDefinition, {
|
|
666
|
-
where: { id: selected.revision.routeDefinitionId, domain: { id: domainId } }, ...(0,
|
|
666
|
+
where: { id: selected.revision.routeDefinitionId, domain: { id: domainId } }, ...(0, shell_2.writeLockOn)(manager, route_definition_1.RouteDefinition)
|
|
667
667
|
}) : null;
|
|
668
668
|
if (selected.revision.routeDefinitionId && (!route ||
|
|
669
669
|
(route.effectiveStart && route.effectiveStart > at) || (route.effectiveEnd && route.effectiveEnd <= at)))
|
|
@@ -25,7 +25,7 @@ const criteria_check_1 = require("./criteria-check");
|
|
|
25
25
|
const test_specification_1 = require("./test-specification");
|
|
26
26
|
const test_spec_revision_1 = require("./test-spec-revision");
|
|
27
27
|
const approval_input_1 = require("../master-change-approval/approval-input");
|
|
28
|
-
const
|
|
28
|
+
const shell_2 = require("@things-factory/shell");
|
|
29
29
|
class TestSpecificationRefusal extends shell_1.Refusal {
|
|
30
30
|
constructor(code, detail) {
|
|
31
31
|
super(code, {}, detail ?? TEST_SPECIFICATION_REFUSALS[code] ?? 'The test specification change could not be applied.');
|
|
@@ -181,7 +181,7 @@ function content(input) {
|
|
|
181
181
|
async function subject(manager, domainId, specId) {
|
|
182
182
|
const spec = await manager.findOne(test_specification_1.TestSpecification, {
|
|
183
183
|
where: { id: specId, domain: { id: domainId } },
|
|
184
|
-
...(0,
|
|
184
|
+
...(0, shell_2.writeLockOn)(manager, test_specification_1.TestSpecification)
|
|
185
185
|
});
|
|
186
186
|
if (!spec)
|
|
187
187
|
refuse('SPECIFICATION_NOT_FOUND');
|
|
@@ -202,7 +202,7 @@ async function subject(manager, domainId, specId) {
|
|
|
202
202
|
async function revision(manager, domainId, revisionId, locked = true) {
|
|
203
203
|
const found = await manager.findOne(test_spec_revision_1.TestSpecificationRevision, {
|
|
204
204
|
where: { id: revisionId, domain: { id: domainId } },
|
|
205
|
-
...(locked ? (0,
|
|
205
|
+
...(locked ? (0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationRevision) : {})
|
|
206
206
|
});
|
|
207
207
|
if (!found)
|
|
208
208
|
refuse('REVISION_NOT_FOUND');
|
|
@@ -241,7 +241,7 @@ async function createTestSpecificationDraft(manager, domainId, creatorId, asked)
|
|
|
241
241
|
}
|
|
242
242
|
const previous = await manager.findOne(test_spec_revision_1.TestSpecificationRevision, {
|
|
243
243
|
where: { domain: { id: domainId }, spec: { id: spec.id } }, order: { revisionNumber: 'DESC' },
|
|
244
|
-
...(0,
|
|
244
|
+
...(0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationRevision)
|
|
245
245
|
});
|
|
246
246
|
const revisionNumber = (previous?.revisionNumber ?? 0) + 1;
|
|
247
247
|
let baseRevisionId = null;
|
|
@@ -383,7 +383,7 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
383
383
|
text(decision.actorId, 'publisher');
|
|
384
384
|
const previousDecision = await manager.findOne(test_spec_revision_1.TestSpecificationPlan, {
|
|
385
385
|
where: { domain: { id: domainId }, publishedRevision: { id: revisionId } },
|
|
386
|
-
...(0,
|
|
386
|
+
...(0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationPlan)
|
|
387
387
|
});
|
|
388
388
|
if (previousDecision)
|
|
389
389
|
return previousDecision;
|
|
@@ -392,12 +392,12 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
392
392
|
// Only replacement from effectiveFrom onward is supported in this slice, not arbitrary rescheduling.
|
|
393
393
|
if (await manager.findOne(test_spec_revision_1.TestSpecificationBasis, {
|
|
394
394
|
where: { domain: { id: domainId }, spec: { id: spec.id }, businessTime: (0, typeorm_1.MoreThanOrEqual)(draft.effectiveFrom) },
|
|
395
|
-
...(0,
|
|
395
|
+
...(0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationBasis)
|
|
396
396
|
}))
|
|
397
397
|
refuse('RETROACTIVE_IMPACT');
|
|
398
398
|
const oldPlan = await manager.findOne(test_spec_revision_1.TestSpecificationPlan, {
|
|
399
399
|
where: { domain: { id: domainId }, spec: { id: spec.id }, generation: spec.planGeneration },
|
|
400
|
-
...(0,
|
|
400
|
+
...(0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationPlan)
|
|
401
401
|
});
|
|
402
402
|
if (spec.planGeneration > 0 && !oldPlan)
|
|
403
403
|
refuse('PLAN_CONFLICT');
|
|
@@ -405,7 +405,7 @@ async function publishRevision(manager, domainId, revisionId, decision) {
|
|
|
405
405
|
? await manager.find(test_spec_revision_1.TestSpecificationSegment, {
|
|
406
406
|
where: { domain: { id: domainId }, spec: { id: spec.id }, plan: { id: oldPlan.id } },
|
|
407
407
|
order: { validFrom: 'ASC' },
|
|
408
|
-
...(0,
|
|
408
|
+
...(0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationSegment)
|
|
409
409
|
})
|
|
410
410
|
: [];
|
|
411
411
|
// Do not silently erase an already approved future appointment.
|
|
@@ -454,7 +454,7 @@ async function resolveTestSpecification(manager, domainId, specId, businessTime,
|
|
|
454
454
|
const plan = await manager.findOne(test_spec_revision_1.TestSpecificationPlan, {
|
|
455
455
|
where: { domain: { id: domainId }, spec: { id: specId }, recordedAt: (0, typeorm_1.LessThanOrEqual)(known) },
|
|
456
456
|
order: { generation: 'DESC' },
|
|
457
|
-
...(0,
|
|
457
|
+
...(0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationPlan)
|
|
458
458
|
});
|
|
459
459
|
if (!plan)
|
|
460
460
|
refuse('NO_EFFECTIVE_REVISION');
|
|
@@ -465,7 +465,7 @@ async function resolveTestSpecification(manager, domainId, specId, businessTime,
|
|
|
465
465
|
.where({ domain: { id: domainId }, spec: { id: specId }, plan: { id: plan.id } })
|
|
466
466
|
.andWhere('segment.validFrom <= :at', { at })
|
|
467
467
|
.andWhere('(segment.validTo IS NULL OR segment.validTo > :at)', { at });
|
|
468
|
-
(0,
|
|
468
|
+
(0, shell_2.lockRowsOf)(manager, query);
|
|
469
469
|
const segments = await query.getMany();
|
|
470
470
|
if (!segments.length)
|
|
471
471
|
await refuseBeforeBaseline(manager, domainId, specId, at);
|
|
@@ -599,7 +599,7 @@ async function captureTestSpecificationBasis(manager, domainId, specId, recordKe
|
|
|
599
599
|
await lockSubject(manager, domainId, specId);
|
|
600
600
|
const existing = await manager.findOne(test_spec_revision_1.TestSpecificationBasis, {
|
|
601
601
|
where: { domain: { id: domainId }, recordKey },
|
|
602
|
-
...(0,
|
|
602
|
+
...(0, shell_2.writeLockOn)(manager, test_spec_revision_1.TestSpecificationBasis)
|
|
603
603
|
});
|
|
604
604
|
if (existing) {
|
|
605
605
|
if (existing.specId !== specId || existing.businessTime.getTime() !== at.getTime())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/ops-master",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.297",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"things-factory": true,
|
|
6
6
|
"author": "heartyoh <heartyoh@hatiolab.com>",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"@operato/shell": "^10.29.69",
|
|
43
43
|
"@operato/styles": "^10.0.0",
|
|
44
44
|
"@operato/utils": "^10.29.39",
|
|
45
|
-
"@things-factory/auth-base": "^10.1.
|
|
46
|
-
"@things-factory/env": "^10.1.
|
|
47
|
-
"@things-factory/shell": "^10.1.
|
|
48
|
-
"@things-factory/worklist": "^10.1.
|
|
45
|
+
"@things-factory/auth-base": "^10.1.297",
|
|
46
|
+
"@things-factory/env": "^10.1.297",
|
|
47
|
+
"@things-factory/shell": "^10.1.297",
|
|
48
|
+
"@things-factory/worklist": "^10.1.297"
|
|
49
49
|
},
|
|
50
50
|
"browser": "dist-client/index.js",
|
|
51
51
|
"files": [
|
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
"!**/.DS_Store"
|
|
65
65
|
],
|
|
66
66
|
"devDependencies": {
|
|
67
|
+
"@things-factory/notification": "^10.1.297",
|
|
67
68
|
"copyfiles": "^2.4.1",
|
|
68
69
|
"rimraf": "^6.1.3"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "656ec78e5adf500b3b636eb9790cfe22f2a49ba9"
|
|
71
72
|
}
|