@things-factory/figure-library 10.1.154 → 10.1.156
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-client/pages/figure-library-page.d.ts +20 -58
- package/dist-client/pages/figure-library-page.js +189 -672
- package/dist-client/pages/figure-library-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/figure-card-meta.d.ts +19 -0
- package/dist-client/viewparts/figure-card-meta.js +122 -0
- package/dist-client/viewparts/figure-card-meta.js.map +1 -0
- package/dist-client/viewparts/figure-releases-popup.d.ts +34 -0
- package/dist-client/viewparts/figure-releases-popup.js +400 -0
- package/dist-client/viewparts/figure-releases-popup.js.map +1 -0
- package/dist-client/viewparts/release-pair.d.ts +9 -0
- package/dist-client/viewparts/release-pair.js +15 -0
- package/dist-client/viewparts/release-pair.js.map +1 -0
- package/dist-server/service/figure-library-release/figure-library-release.d.ts +5 -3
- package/dist-server/service/figure-library-release/figure-library-release.js +13 -3
- package/dist-server/service/figure-library-release/figure-library-release.js.map +1 -1
- package/dist-server/service/figure-library-resolver.d.ts +9 -9
- package/dist-server/service/figure-library-resolver.js +66 -69
- package/dist-server/service/figure-library-resolver.js.map +1 -1
- package/dist-server/service/figure-library-types.d.ts +17 -4
- package/dist-server/service/figure-library-types.js +63 -15
- package/dist-server/service/figure-library-types.js.map +1 -1
- package/dist-server/service/figure-type-map/figure-type-map-entry.d.ts +5 -4
- package/dist-server/service/figure-type-map/figure-type-map-entry.js +8 -14
- package/dist-server/service/figure-type-map/figure-type-map-entry.js.map +1 -1
- package/dist-server/service/index.d.ts +2 -3
- package/dist-server/service/index.js +2 -3
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/library/blueprints.d.ts +3 -8
- package/dist-server/service/library/blueprints.js +5 -6
- package/dist-server/service/library/blueprints.js.map +1 -1
- package/dist-server/service/library/carriers.d.ts +8 -11
- package/dist-server/service/library/carriers.js +8 -14
- package/dist-server/service/library/carriers.js.map +1 -1
- package/dist-server/service/library/derived.d.ts +5 -3
- package/dist-server/service/library/derived.js +4 -3
- package/dist-server/service/library/derived.js.map +1 -1
- package/dist-server/service/library/figures.d.ts +46 -0
- package/dist-server/service/library/figures.js +91 -0
- package/dist-server/service/library/figures.js.map +1 -0
- package/dist-server/service/library/import.d.ts +1 -1
- package/dist-server/service/library/import.js +5 -3
- package/dist-server/service/library/import.js.map +1 -1
- package/dist-server/service/library/inspection.d.ts +1 -48
- package/dist-server/service/library/inspection.js +3 -80
- package/dist-server/service/library/inspection.js.map +1 -1
- package/dist-server/service/library/type-map.d.ts +10 -22
- package/dist-server/service/library/type-map.js +44 -108
- package/dist-server/service/library/type-map.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -10
- package/translations/en.json +26 -47
- package/translations/es.json +26 -47
- package/translations/ja.json +26 -47
- package/translations/ko.json +26 -47
- package/translations/ms.json +26 -47
- package/translations/zh.json +26 -47
- package/dist-server/service/figure-type-map/figure-type-map.d.ts +0 -34
- package/dist-server/service/figure-type-map/figure-type-map.js +0 -120
- package/dist-server/service/figure-type-map/figure-type-map.js.map +0 -1
|
@@ -1,133 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fullNameOf = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.assertLines = assertLines;
|
|
8
|
-
exports.saveCandidate = saveCandidate;
|
|
9
|
-
exports.putIntoCandidate = putIntoCandidate;
|
|
10
|
-
exports.activate = activate;
|
|
11
|
-
const typeorm_1 = require("typeorm");
|
|
4
|
+
exports.linesOf = linesOf;
|
|
5
|
+
exports.chooseRelease = chooseRelease;
|
|
6
|
+
exports.putIntoTypeMap = putIntoTypeMap;
|
|
12
7
|
const figure_model_1 = require("@hatiolab/figure-model");
|
|
13
8
|
const shell_1 = require("@things-factory/shell");
|
|
14
9
|
const figure_library_release_1 = require("../figure-library-release/figure-library-release");
|
|
15
|
-
const figure_type_map_1 = require("../figure-type-map/figure-type-map");
|
|
16
10
|
const figure_type_map_entry_1 = require("../figure-type-map/figure-type-map-entry");
|
|
17
11
|
/** The full name a release is the release of. */
|
|
18
12
|
const fullNameOf = (release) => (0, figure_model_1.formatFigureName)({ namespace: release.namespace, type: release.type });
|
|
19
13
|
exports.fullNameOf = fullNameOf;
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
/** The domain's type map: one line per full name, with the release it draws with. */
|
|
15
|
+
function linesOf(tx, domain) {
|
|
16
|
+
return tx.getRepository(figure_type_map_entry_1.FigureTypeMapEntry).find({ where: { domain: { id: domain.id } }, relations: { release: true }, order: { name: 'ASC' } });
|
|
22
17
|
}
|
|
23
|
-
function
|
|
24
|
-
return tx.getRepository(figure_type_map_entry_1.FigureTypeMapEntry).
|
|
18
|
+
function lineOf(tx, domain, name) {
|
|
19
|
+
return tx.getRepository(figure_type_map_entry_1.FigureTypeMapEntry).findOne({ where: { domain: { id: domain.id }, name }, relations: { release: true } });
|
|
25
20
|
}
|
|
26
21
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
22
|
+
* Makes `releaseId` the release `name` draws with (ADR-0114 결정 15): a release of this domain's library, and the
|
|
23
|
+
* release of that very name. Refused by the first fault, named.
|
|
29
24
|
*/
|
|
30
|
-
async function
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
const last = await tx
|
|
35
|
-
.getRepository(figure_type_map_1.FigureTypeMap)
|
|
36
|
-
.createQueryBuilder('map')
|
|
37
|
-
.withDeleted()
|
|
38
|
-
.where('map.domain_id = :domain', { domain: domain.id })
|
|
39
|
-
.orderBy('map.version', 'DESC')
|
|
40
|
-
.getOne();
|
|
41
|
-
const version = (last?.version ?? 0) + 1;
|
|
42
|
-
const candidate = await tx.getRepository(figure_type_map_1.FigureTypeMap).save({
|
|
43
|
-
domain,
|
|
44
|
-
name: `R${version}`,
|
|
45
|
-
version,
|
|
46
|
-
revision: 1,
|
|
47
|
-
state: figure_type_map_1.FigureTypeMapState.CANDIDATE,
|
|
48
|
-
creator: user,
|
|
49
|
-
updater: user
|
|
50
|
-
});
|
|
51
|
-
const active = await mapOfState(tx, domain, figure_type_map_1.FigureTypeMapState.ACTIVE);
|
|
52
|
-
if (active) {
|
|
53
|
-
const lines = await entriesOf(tx, active);
|
|
54
|
-
await tx.getRepository(figure_type_map_entry_1.FigureTypeMapEntry).save(lines.map(line => ({ domain, typeMap: candidate, name: line.name, release: { id: line.releaseId }, creator: user, updater: user })));
|
|
25
|
+
async function chooseRelease(tx, domain, user, name, releaseId) {
|
|
26
|
+
const release = await tx.getRepository(figure_library_release_1.FigureLibraryRelease).findOne({ where: { id: releaseId } });
|
|
27
|
+
if (!release) {
|
|
28
|
+
throw new shell_1.Refusal('figure-type-map-missing-release', { name }, 'the release chosen for {name} is not in the library.');
|
|
55
29
|
}
|
|
56
|
-
|
|
30
|
+
if (release.domainId !== domain.id) {
|
|
31
|
+
throw new shell_1.Refusal('figure-type-map-foreign-release', { name }, 'the release chosen for {name} belongs to another domain.');
|
|
32
|
+
}
|
|
33
|
+
if ((0, exports.fullNameOf)(release) !== name) {
|
|
34
|
+
throw new shell_1.Refusal('figure-type-map-name-mismatch', { name, ref: release.ref }, '{ref} is not a release of {name}.');
|
|
35
|
+
}
|
|
36
|
+
if (!release.formatSupported) {
|
|
37
|
+
throw new shell_1.Refusal('figure-type-map-format-unsupported', { name, ref: release.ref }, '{ref} is in a format this server cannot draw.');
|
|
38
|
+
}
|
|
39
|
+
return await setLine(tx, domain, user, name, release);
|
|
57
40
|
}
|
|
58
41
|
/**
|
|
59
|
-
*
|
|
60
|
-
* release of
|
|
42
|
+
* What an import does to the type map (ADR-0114 결정 7, amended 2026-10-12): the newest release this server can draw is
|
|
43
|
+
* the one in use. A release of a name the map does not have adds its line; a drawable release newer than the one a line
|
|
44
|
+
* draws with moves the line to it; an older one leaves it. A release in a format this server cannot read never takes
|
|
45
|
+
* over: a name that has only such releases keeps a line with no release, so it is listed and boards are told why.
|
|
61
46
|
*/
|
|
62
|
-
async function
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
const ids = [...new Set(lines.map(line => line.releaseId))];
|
|
71
|
-
const releases = ids.length ? await tx.getRepository(figure_library_release_1.FigureLibraryRelease).find({ where: { id: (0, typeorm_1.In)(ids) } }) : [];
|
|
72
|
-
const byId = new Map(releases.map(release => [release.id, release]));
|
|
73
|
-
for (const line of lines) {
|
|
74
|
-
const release = byId.get(line.releaseId);
|
|
75
|
-
if (!release) {
|
|
76
|
-
throw new shell_1.Refusal('figure-type-map-missing-release', { name: line.name }, 'the release chosen for {name} is not in the library.');
|
|
77
|
-
}
|
|
78
|
-
if (release.domainId !== domain.id) {
|
|
79
|
-
throw new shell_1.Refusal('figure-type-map-foreign-release', { name: line.name }, 'the release chosen for {name} belongs to another domain.');
|
|
80
|
-
}
|
|
81
|
-
if ((0, exports.fullNameOf)(release) !== line.name) {
|
|
82
|
-
throw new shell_1.Refusal('figure-type-map-name-mismatch', { name: line.name, ref: release.ref }, '{ref} is not a release of {name}.');
|
|
83
|
-
}
|
|
47
|
+
async function putIntoTypeMap(tx, domain, user, release) {
|
|
48
|
+
const name = (0, exports.fullNameOf)(release);
|
|
49
|
+
const line = await lineOf(tx, domain, name);
|
|
50
|
+
if (!release.formatSupported) {
|
|
51
|
+
if (!line)
|
|
52
|
+
await setLine(tx, domain, user, name, null);
|
|
53
|
+
return;
|
|
84
54
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
async function saveCandidate(tx, domain, user, lines, description) {
|
|
89
|
-
await assertLines(tx, domain, lines);
|
|
90
|
-
const candidate = (await candidateOf(tx, domain, user, true));
|
|
91
|
-
await tx.getRepository(figure_type_map_entry_1.FigureTypeMapEntry).delete({ typeMap: { id: candidate.id } });
|
|
92
|
-
await tx.getRepository(figure_type_map_entry_1.FigureTypeMapEntry).save(lines.map(line => ({ domain, typeMap: candidate, name: line.name, release: { id: line.releaseId }, creator: user, updater: user })));
|
|
93
|
-
return await bumpRevision(tx, candidate, user, description);
|
|
55
|
+
if (line?.release && line.release.version >= release.version)
|
|
56
|
+
return;
|
|
57
|
+
await setLine(tx, domain, user, name, release);
|
|
94
58
|
}
|
|
95
|
-
|
|
96
|
-
async function putIntoCandidate(tx, domain, user, release) {
|
|
97
|
-
const candidate = (await candidateOf(tx, domain, user, true));
|
|
98
|
-
const name = (0, exports.fullNameOf)(release);
|
|
59
|
+
async function setLine(tx, domain, user, name, release) {
|
|
99
60
|
const repository = tx.getRepository(figure_type_map_entry_1.FigureTypeMapEntry);
|
|
100
|
-
const line = await
|
|
61
|
+
const line = await lineOf(tx, domain, name);
|
|
62
|
+
const target = release ? { id: release.id } : null;
|
|
101
63
|
if (line)
|
|
102
|
-
await repository.update({ id: line.id }, { release:
|
|
64
|
+
await repository.update({ id: line.id }, { release: target, updater: user });
|
|
103
65
|
else
|
|
104
|
-
await repository.save({ domain,
|
|
105
|
-
await
|
|
106
|
-
}
|
|
107
|
-
async function bumpRevision(tx, map, user, description) {
|
|
108
|
-
await tx
|
|
109
|
-
.getRepository(figure_type_map_1.FigureTypeMap)
|
|
110
|
-
.update({ id: map.id }, { revision: (map.revision ?? 0) + 1, updater: user, ...(description !== undefined ? { description } : {}) });
|
|
111
|
-
return await tx.getRepository(figure_type_map_1.FigureTypeMap).findOneOrFail({ where: { id: map.id } });
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Makes a release ACTIVE in one transaction: the candidate after a check, or an ARCHIVED one to roll back. The active
|
|
115
|
-
* one before becomes ARCHIVED; a candidate left aside by a roll back stays a candidate (ADR-0114 결정 6).
|
|
116
|
-
*/
|
|
117
|
-
async function activate(tx, domain, user, version) {
|
|
118
|
-
const repository = tx.getRepository(figure_type_map_1.FigureTypeMap);
|
|
119
|
-
const map = await repository.findOne({ where: { domain: { id: domain.id }, version } });
|
|
120
|
-
if (!map)
|
|
121
|
-
throw new shell_1.Refusal('figure-type-map-not-found', { version }, 'there is no type map R{version}.');
|
|
122
|
-
if (map.state === figure_type_map_1.FigureTypeMapState.ACTIVE)
|
|
123
|
-
return map;
|
|
124
|
-
const active = await mapOfState(tx, domain, figure_type_map_1.FigureTypeMapState.ACTIVE);
|
|
125
|
-
if (active)
|
|
126
|
-
await repository.update({ id: active.id }, { state: figure_type_map_1.FigureTypeMapState.ARCHIVED, updater: user });
|
|
127
|
-
await repository.update({ id: map.id }, { state: figure_type_map_1.FigureTypeMapState.ACTIVE, activatedAt: new Date(), activator: user, updater: user });
|
|
128
|
-
const actives = await repository.count({ where: { domain: { id: domain.id }, state: figure_type_map_1.FigureTypeMapState.ACTIVE } });
|
|
129
|
-
if (actives !== 1)
|
|
130
|
-
throw new shell_1.Refusal('figure-type-map-raced', { version }, 'another activation ran at the same time. try again.');
|
|
131
|
-
return await repository.findOneOrFail({ where: { id: map.id } });
|
|
66
|
+
await repository.save({ domain, name, release: target, creator: user, updater: user });
|
|
67
|
+
return (await lineOf(tx, domain, name));
|
|
132
68
|
}
|
|
133
69
|
//# sourceMappingURL=type-map.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-map.js","sourceRoot":"","sources":["../../../server/service/library/type-map.ts"],"names":[],"mappings":";;;AAeA,gCAEC;AAED,8BAEC;AAMD,kCA8BC;AAWD,kCA4BC;AAGD,sCAcC;AAGD,4CAQC;AAaD,4BAaC;AAtJD,qCAA2C;AAE3C,yDAAyD;AACzD,iDAA+C;AAE/C,6FAAuF;AACvF,wEAAsF;AACtF,oFAA6E;AAI7E,iDAAiD;AAC1C,MAAM,UAAU,GAAG,CAAC,OAAyD,EAAE,EAAE,CACtF,IAAA,+BAAgB,EAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,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AAE,EAAE,EAAE,KAAK,EAAE,oCAAkB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAClH,IAAI,OAAO,KAAK,CAAC;QAAE,MAAM,IAAI,eAAO,CAAC,uBAAuB,EAAE,EAAE,OAAO,EAAE,EAAE,qDAAqD,CAAC,CAAA;IACjI,OAAO,MAAM,UAAU,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AAClE,CAAC","sourcesContent":["import { EntityManager, In } from 'typeorm'\n\nimport { formatFigureName } from '@hatiolab/figure-model'\nimport { Refusal } from '@things-factory/shell'\n\nimport { FigureLibraryRelease } from '../figure-library-release/figure-library-release'\nimport { FigureTypeMap, FigureTypeMapState } from '../figure-type-map/figure-type-map'\nimport { FigureTypeMapEntry } from '../figure-type-map/figure-type-map-entry'\n\ntype Domain = { id: string }\n\n/** The full name a release is the release of. */\nexport const fullNameOf = (release: Pick<FigureLibraryRelease, 'namespace' | 'type'>) =>\n formatFigureName({ namespace: release.namespace, type: release.type })\n\nexport function mapOfState(tx: EntityManager, domain: Domain, state: FigureTypeMapState): Promise<FigureTypeMap | null> {\n return tx.getRepository(FigureTypeMap).findOne({ where: { domain: { id: domain.id }, state } })\n}\n\nexport function entriesOf(tx: EntityManager, map: FigureTypeMap): Promise<FigureTypeMapEntry[]> {\n return tx.getRepository(FigureTypeMapEntry).find({ where: { typeMap: { id: map.id } }, relations: { release: true }, order: { name: 'ASC' } })\n}\n\n/**\n * The domain's candidate. With `create`, a domain without one gets a new release numbered after the last, holding the\n * active map's lines (ADR-0114 결정 6: editing starts from what draws now).\n */\nexport async function candidateOf(tx: EntityManager, domain: Domain, user: unknown, create: boolean): Promise<FigureTypeMap | null> {\n const found = await mapOfState(tx, domain, FigureTypeMapState.CANDIDATE)\n if (found || !create) return found\n\n const last = await tx\n .getRepository(FigureTypeMap)\n .createQueryBuilder('map')\n .withDeleted()\n .where('map.domain_id = :domain', { domain: domain.id })\n .orderBy('map.version', 'DESC')\n .getOne()\n const version = (last?.version ?? 0) + 1\n const candidate = await tx.getRepository(FigureTypeMap).save({\n domain,\n name: `R${version}`,\n version,\n revision: 1,\n state: FigureTypeMapState.CANDIDATE,\n creator: user,\n updater: user\n } as Partial<FigureTypeMap>)\n\n const active = await mapOfState(tx, domain, FigureTypeMapState.ACTIVE)\n if (active) {\n const lines = await entriesOf(tx, active)\n await tx.getRepository(FigureTypeMapEntry).save(\n lines.map(line => ({ domain, typeMap: candidate, name: line.name, release: { id: line.releaseId }, creator: user, updater: user }))\n )\n }\n return candidate\n}\n\nexport interface CandidateLine {\n name: string\n releaseId: string\n}\n\n/**\n * Checks lines against the library (ADR-0114 결정 15): one line per name, a release of this domain's library, and the\n * release of that very name. Refused whole by the first fault, named.\n */\nexport async function assertLines(tx: EntityManager, domain: Domain, lines: readonly CandidateLine[]): Promise<Map<string, FigureLibraryRelease>> {\n const seen = new Set<string>()\n for (const line of lines) {\n if (seen.has(line.name)) {\n throw new Refusal('figure-type-map-duplicate', { name: line.name }, '{name} appears more than once in the type map.')\n }\n seen.add(line.name)\n }\n const ids = [...new Set(lines.map(line => line.releaseId))]\n const releases = ids.length ? await tx.getRepository(FigureLibraryRelease).find({ where: { id: In(ids) } }) : []\n const byId = new Map(releases.map(release => [release.id!, release]))\n for (const line of lines) {\n const release = byId.get(line.releaseId)\n if (!release) {\n throw new Refusal('figure-type-map-missing-release', { name: line.name }, 'the release chosen for {name} is not in the library.')\n }\n if (release.domainId !== domain.id) {\n throw new Refusal('figure-type-map-foreign-release', { name: line.name }, 'the release chosen for {name} belongs to another domain.')\n }\n if (fullNameOf(release) !== line.name) {\n throw new Refusal(\n 'figure-type-map-name-mismatch',\n { name: line.name, ref: release.ref },\n '{ref} is not a release of {name}.'\n )\n }\n }\n return byId\n}\n\n/** Replaces the candidate's lines; each save raises the revision an open preview compares (결정 12). */\nexport async function saveCandidate(\n tx: EntityManager,\n domain: Domain,\n user: unknown,\n lines: readonly CandidateLine[],\n description?: string\n): Promise<FigureTypeMap> {\n await assertLines(tx, domain, lines)\n const candidate = (await candidateOf(tx, domain, user, true))!\n await tx.getRepository(FigureTypeMapEntry).delete({ typeMap: { id: candidate.id } })\n await tx.getRepository(FigureTypeMapEntry).save(\n lines.map(line => ({ domain, typeMap: candidate, name: line.name, release: { id: line.releaseId }, creator: user, updater: user }))\n )\n return await bumpRevision(tx, candidate, user, description)\n}\n\n/** Puts an imported release into the candidate: a new line, or its figure's line moved to it (결정 7). */\nexport async function putIntoCandidate(tx: EntityManager, domain: Domain, user: unknown, release: FigureLibraryRelease): Promise<void> {\n const candidate = (await candidateOf(tx, domain, user, true))!\n const name = fullNameOf(release)\n const repository = tx.getRepository(FigureTypeMapEntry)\n const line = await repository.findOne({ where: { typeMap: { id: candidate.id }, name } })\n if (line) await repository.update({ id: line.id }, { release: { id: release.id }, updater: user } as any)\n else await repository.save({ domain, typeMap: candidate, name, release: { id: release.id }, creator: user, updater: user })\n await bumpRevision(tx, candidate, user)\n}\n\nasync function bumpRevision(tx: EntityManager, map: FigureTypeMap, user: unknown, description?: string): Promise<FigureTypeMap> {\n await tx\n .getRepository(FigureTypeMap)\n .update({ id: map.id }, { revision: (map.revision ?? 0) + 1, updater: user, ...(description !== undefined ? { description } : {}) } as any)\n return await tx.getRepository(FigureTypeMap).findOneOrFail({ where: { id: map.id } })\n}\n\n/**\n * Makes a release ACTIVE in one transaction: the candidate after a check, or an ARCHIVED one to roll back. The active\n * one before becomes ARCHIVED; a candidate left aside by a roll back stays a candidate (ADR-0114 결정 6).\n */\nexport async function activate(tx: EntityManager, domain: Domain, user: unknown, version: number): Promise<FigureTypeMap> {\n const repository = tx.getRepository(FigureTypeMap)\n const map = await repository.findOne({ where: { domain: { id: domain.id }, version } })\n if (!map) throw new Refusal('figure-type-map-not-found', { version }, 'there is no type map R{version}.')\n if (map.state === FigureTypeMapState.ACTIVE) return map\n\n const active = await mapOfState(tx, domain, FigureTypeMapState.ACTIVE)\n if (active) await repository.update({ id: active.id }, { state: FigureTypeMapState.ARCHIVED, updater: user } as any)\n await repository.update({ id: map.id }, { state: FigureTypeMapState.ACTIVE, activatedAt: new Date(), activator: user, updater: user } as any)\n\n const actives = await repository.count({ where: { domain: { id: domain.id }, state: FigureTypeMapState.ACTIVE } })\n if (actives !== 1) throw new Refusal('figure-type-map-raced', { version }, 'another activation ran at the same time. try again.')\n return await repository.findOneOrFail({ where: { id: map.id } })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"type-map.js","sourceRoot":"","sources":["../../../server/service/library/type-map.ts"],"names":[],"mappings":";;;AAeA,0BAEC;AAUD,sCAeC;AAQD,wCASC;AAzDD,yDAAyD;AACzD,iDAA+C;AAE/C,6FAAuF;AACvF,oFAA6E;AAI7E,iDAAiD;AAC1C,MAAM,UAAU,GAAG,CAAC,OAAyD,EAAE,EAAE,CACtF,IAAA,+BAAgB,EAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;AAD3D,QAAA,UAAU,cACiD;AAExE,qFAAqF;AACrF,SAAgB,OAAO,CAAC,EAAiB,EAAE,MAAc;IACvD,OAAO,EAAE,CAAC,aAAa,CAAC,0CAAkB,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;AAClJ,CAAC;AAED,SAAS,MAAM,CAAC,EAAiB,EAAE,MAAc,EAAE,IAAY;IAC7D,OAAO,EAAE,CAAC,aAAa,CAAC,0CAAkB,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAA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OAAO,CAAC,MAAM,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAE,CAAA;AAC1C,CAAC","sourcesContent":["import { EntityManager } from 'typeorm'\n\nimport { formatFigureName } from '@hatiolab/figure-model'\nimport { Refusal } from '@things-factory/shell'\n\nimport { FigureLibraryRelease } from '../figure-library-release/figure-library-release'\nimport { FigureTypeMapEntry } from '../figure-type-map/figure-type-map-entry'\n\ntype Domain = { id: string }\n\n/** The full name a release is the release of. */\nexport const fullNameOf = (release: Pick<FigureLibraryRelease, 'namespace' | 'type'>) =>\n formatFigureName({ namespace: release.namespace, type: release.type })\n\n/** The domain's type map: one line per full name, with the release it draws with. */\nexport function linesOf(tx: EntityManager, domain: Domain): Promise<FigureTypeMapEntry[]> {\n return tx.getRepository(FigureTypeMapEntry).find({ where: { domain: { id: domain.id } }, relations: { release: true }, order: { name: 'ASC' } })\n}\n\nfunction lineOf(tx: EntityManager, domain: Domain, name: string): Promise<FigureTypeMapEntry | null> {\n return tx.getRepository(FigureTypeMapEntry).findOne({ where: { domain: { id: domain.id }, name }, relations: { release: true } })\n}\n\n/**\n * Makes `releaseId` the release `name` draws with (ADR-0114 결정 15): a release of this domain's library, and the\n * release of that very name. Refused by the first fault, named.\n */\nexport async function chooseRelease(tx: EntityManager, domain: Domain, user: unknown, name: string, releaseId: string): Promise<FigureTypeMapEntry> {\n const release = await tx.getRepository(FigureLibraryRelease).findOne({ where: { id: releaseId } })\n if (!release) {\n throw new Refusal('figure-type-map-missing-release', { name }, 'the release chosen for {name} is not in the library.')\n }\n if (release.domainId !== domain.id) {\n throw new Refusal('figure-type-map-foreign-release', { name }, 'the release chosen for {name} belongs to another domain.')\n }\n if (fullNameOf(release) !== name) {\n throw new Refusal('figure-type-map-name-mismatch', { name, ref: release.ref }, '{ref} is not a release of {name}.')\n }\n if (!release.formatSupported) {\n throw new Refusal('figure-type-map-format-unsupported', { name, ref: release.ref }, '{ref} is in a format this server cannot draw.')\n }\n return await setLine(tx, domain, user, name, release)\n}\n\n/**\n * What an import does to the type map (ADR-0114 결정 7, amended 2026-10-12): the newest release this server can draw is\n * the one in use. A release of a name the map does not have adds its line; a drawable release newer than the one a line\n * draws with moves the line to it; an older one leaves it. A release in a format this server cannot read never takes\n * over: a name that has only such releases keeps a line with no release, so it is listed and boards are told why.\n */\nexport async function putIntoTypeMap(tx: EntityManager, domain: Domain, user: unknown, release: FigureLibraryRelease): Promise<void> {\n const name = fullNameOf(release)\n const line = await lineOf(tx, domain, name)\n if (!release.formatSupported) {\n if (!line) await setLine(tx, domain, user, name, null)\n return\n }\n if (line?.release && line.release.version >= release.version) return\n await setLine(tx, domain, user, name, release)\n}\n\nasync function setLine(tx: EntityManager, domain: Domain, user: unknown, name: string, release: FigureLibraryRelease | null): Promise<FigureTypeMapEntry> {\n const repository = tx.getRepository(FigureTypeMapEntry)\n const line = await lineOf(tx, domain, name)\n const target = release ? { id: release.id } : null\n if (line) await repository.update({ id: line.id }, { release: target, updater: user } as any)\n else await repository.save({ domain, name, release: target, creator: user, updater: user } as Partial<FigureTypeMapEntry>)\n return (await lineOf(tx, domain, name))!\n}\n"]}
|