@things-factory/figure-library 10.1.121
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/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/figure-library-page.d.ts +78 -0
- package/dist-client/pages/figure-library-page.js +781 -0
- package/dist-client/pages/figure-library-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +8 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/index.d.ts +2 -0
- package/dist-server/index.js +6 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/routers/figure-library-file-router.d.ts +5 -0
- package/dist-server/routers/figure-library-file-router.js +43 -0
- package/dist-server/routers/figure-library-file-router.js.map +1 -0
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/routes.js +16 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/figure-library-release/figure-library-release.d.ts +54 -0
- package/dist-server/service/figure-library-release/figure-library-release.js +206 -0
- package/dist-server/service/figure-library-release/figure-library-release.js.map +1 -0
- package/dist-server/service/figure-library-resolver.d.ts +20 -0
- package/dist-server/service/figure-library-resolver.js +196 -0
- package/dist-server/service/figure-library-resolver.js.map +1 -0
- package/dist-server/service/figure-library-types.d.ts +23 -0
- package/dist-server/service/figure-library-types.js +85 -0
- package/dist-server/service/figure-library-types.js.map +1 -0
- package/dist-server/service/figure-type-map/figure-type-map-entry.d.ts +23 -0
- package/dist-server/service/figure-type-map/figure-type-map-entry.js +98 -0
- package/dist-server/service/figure-type-map/figure-type-map-entry.js.map +1 -0
- package/dist-server/service/figure-type-map/figure-type-map.d.ts +34 -0
- package/dist-server/service/figure-type-map/figure-type-map.js +120 -0
- package/dist-server/service/figure-type-map/figure-type-map.js.map +1 -0
- package/dist-server/service/index.d.ts +20 -0
- package/dist-server/service/index.js +28 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/library/blueprints.d.ts +28 -0
- package/dist-server/service/library/blueprints.js +53 -0
- package/dist-server/service/library/blueprints.js.map +1 -0
- package/dist-server/service/library/board-walk.d.ts +1 -0
- package/dist-server/service/library/board-walk.js +31 -0
- package/dist-server/service/library/board-walk.js.map +1 -0
- package/dist-server/service/library/derived.d.ts +16 -0
- package/dist-server/service/library/derived.js +45 -0
- package/dist-server/service/library/derived.js.map +1 -0
- package/dist-server/service/library/import.d.ts +30 -0
- package/dist-server/service/library/import.js +116 -0
- package/dist-server/service/library/import.js.map +1 -0
- package/dist-server/service/library/inspection.d.ts +63 -0
- package/dist-server/service/library/inspection.js +144 -0
- package/dist-server/service/library/inspection.js.map +1 -0
- package/dist-server/service/library/library-files.d.ts +32 -0
- package/dist-server/service/library/library-files.js +58 -0
- package/dist-server/service/library/library-files.js.map +1 -0
- package/dist-server/service/library/type-map.d.ts +35 -0
- package/dist-server/service/library/type-map.js +133 -0
- package/dist-server/service/library/type-map.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +51 -0
- package/things-factory.config.js +13 -0
- package/translations/en.json +98 -0
- package/translations/ko.json +98 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const env_1 = require("@things-factory/env");
|
|
4
|
+
const shell_1 = require("@things-factory/shell");
|
|
5
|
+
const figure_library_file_router_1 = require("./routers/figure-library-file-router");
|
|
6
|
+
/* With subdomains the domain is in the host name; otherwise in the path, as figure-service and board-service do. */
|
|
7
|
+
const isPathBaseDomain = !env_1.config.get('subdomain');
|
|
8
|
+
process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
|
|
9
|
+
if (isPathBaseDomain) {
|
|
10
|
+
domainPrivateRouter.use(`/${(0, shell_1.getRoutePrefixForDomainType)()}/:domain`, figure_library_file_router_1.figureLibraryFileRouter.routes(), figure_library_file_router_1.figureLibraryFileRouter.allowedMethods());
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
domainPrivateRouter.use('', figure_library_file_router_1.figureLibraryFileRouter.routes(), figure_library_file_router_1.figureLibraryFileRouter.allowedMethods());
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAC5C,iDAAmE;AAEnE,qFAA8E;AAE9E,oHAAoH;AACpH,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAEjD,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,IAAI,gBAAgB,EAAE,CAAC;QACrB,mBAAmB,CAAC,GAAG,CAAC,IAAI,IAAA,mCAA2B,GAAE,UAAU,EAAE,oDAAuB,CAAC,MAAM,EAAE,EAAE,oDAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;IAClJ,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,oDAAuB,CAAC,MAAM,EAAE,EAAE,oDAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;IACzG,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { config } from '@things-factory/env'\nimport { getRoutePrefixForDomainType } from '@things-factory/shell'\n\nimport { figureLibraryFileRouter } from './routers/figure-library-file-router'\n\n/* With subdomains the domain is in the host name; otherwise in the path, as figure-service and board-service do. */\nconst isPathBaseDomain = !config.get('subdomain')\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use(`/${getRoutePrefixForDomainType()}/:domain`, figureLibraryFileRouter.routes(), figureLibraryFileRouter.allowedMethods())\n } else {\n domainPrivateRouter.use('', figureLibraryFileRouter.routes(), figureLibraryFileRouter.allowedMethods())\n }\n})\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base';
|
|
2
|
+
import { Domain } from '@things-factory/shell';
|
|
3
|
+
/** A file a release depends on, as its package listed it. */
|
|
4
|
+
export interface FigureLibraryDependency {
|
|
5
|
+
hash: string;
|
|
6
|
+
role: string;
|
|
7
|
+
size: number;
|
|
8
|
+
contentType: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A released figure this board server imported (ADR-0114 결정 3).
|
|
12
|
+
*
|
|
13
|
+
* The release data is immutable: the server that authored it never changes a release, so a row is added once and never
|
|
14
|
+
* rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` are derived, recomputed when this
|
|
15
|
+
* server's kernel is another version than the one that checked them. There is no delete path.
|
|
16
|
+
*/
|
|
17
|
+
export declare class FigureLibraryRelease {
|
|
18
|
+
readonly id?: string;
|
|
19
|
+
domain?: Domain;
|
|
20
|
+
domainId?: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
ref: string;
|
|
24
|
+
namespace: string;
|
|
25
|
+
type: string;
|
|
26
|
+
version: number;
|
|
27
|
+
names?: Record<string, string>;
|
|
28
|
+
category?: string;
|
|
29
|
+
source: string;
|
|
30
|
+
contentHash: string;
|
|
31
|
+
assetFormat: string;
|
|
32
|
+
kernelVersion?: string;
|
|
33
|
+
metrics?: string;
|
|
34
|
+
topView?: string;
|
|
35
|
+
changes?: string;
|
|
36
|
+
formatSupported: boolean;
|
|
37
|
+
checkedKernel?: string;
|
|
38
|
+
width?: number;
|
|
39
|
+
depth?: number;
|
|
40
|
+
dependencies?: FigureLibraryDependency[];
|
|
41
|
+
deprecated: boolean;
|
|
42
|
+
supersededBy?: string;
|
|
43
|
+
sourceUrl?: string;
|
|
44
|
+
sourceDomain?: string;
|
|
45
|
+
packageName?: string;
|
|
46
|
+
releasedAt?: Date;
|
|
47
|
+
createdAt?: Date;
|
|
48
|
+
updatedAt?: Date;
|
|
49
|
+
deletedAt?: Date;
|
|
50
|
+
creator?: User;
|
|
51
|
+
creatorId?: string;
|
|
52
|
+
updater?: User;
|
|
53
|
+
updaterId?: string;
|
|
54
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FigureLibraryRelease = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const graphql_scalars_1 = require("graphql-scalars");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const shell_1 = require("@things-factory/shell");
|
|
10
|
+
/**
|
|
11
|
+
* A released figure this board server imported (ADR-0114 결정 3).
|
|
12
|
+
*
|
|
13
|
+
* The release data is immutable: the server that authored it never changes a release, so a row is added once and never
|
|
14
|
+
* rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` are derived, recomputed when this
|
|
15
|
+
* server's kernel is another version than the one that checked them. There is no delete path.
|
|
16
|
+
*/
|
|
17
|
+
let FigureLibraryRelease = class FigureLibraryRelease {
|
|
18
|
+
};
|
|
19
|
+
exports.FigureLibraryRelease = FigureLibraryRelease;
|
|
20
|
+
tslib_1.__decorate([
|
|
21
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
22
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier.' }),
|
|
23
|
+
tslib_1.__metadata("design:type", String)
|
|
24
|
+
], FigureLibraryRelease.prototype, "id", void 0);
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
27
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain that imported the release.' }),
|
|
28
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
29
|
+
], FigureLibraryRelease.prototype, "domain", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, typeorm_1.RelationId)((release) => release.domain),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], FigureLibraryRelease.prototype, "domainId", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, typeorm_1.Column)(),
|
|
36
|
+
(0, type_graphql_1.Field)({ description: 'Display name of the figure at this release.' }),
|
|
37
|
+
tslib_1.__metadata("design:type", String)
|
|
38
|
+
], FigureLibraryRelease.prototype, "name", void 0);
|
|
39
|
+
tslib_1.__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
41
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Description of the figure at this release.' }),
|
|
42
|
+
tslib_1.__metadata("design:type", String)
|
|
43
|
+
], FigureLibraryRelease.prototype, "description", void 0);
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
(0, typeorm_1.Column)(),
|
|
46
|
+
(0, type_graphql_1.Field)({ description: 'Release reference {namespace}/{type}@{version}.' }),
|
|
47
|
+
tslib_1.__metadata("design:type", String)
|
|
48
|
+
], FigureLibraryRelease.prototype, "ref", void 0);
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, typeorm_1.Column)(),
|
|
51
|
+
(0, type_graphql_1.Field)({ description: 'Namespace of the full name.' }),
|
|
52
|
+
tslib_1.__metadata("design:type", String)
|
|
53
|
+
], FigureLibraryRelease.prototype, "namespace", void 0);
|
|
54
|
+
tslib_1.__decorate([
|
|
55
|
+
(0, typeorm_1.Column)(),
|
|
56
|
+
(0, type_graphql_1.Field)({ description: 'Type of the full name.' }),
|
|
57
|
+
tslib_1.__metadata("design:type", String)
|
|
58
|
+
], FigureLibraryRelease.prototype, "type", void 0);
|
|
59
|
+
tslib_1.__decorate([
|
|
60
|
+
(0, typeorm_1.Column)(),
|
|
61
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Release version.' }),
|
|
62
|
+
tslib_1.__metadata("design:type", Number)
|
|
63
|
+
], FigureLibraryRelease.prototype, "version", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true, default: null }),
|
|
66
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'Display names by language.' }),
|
|
67
|
+
tslib_1.__metadata("design:type", Object)
|
|
68
|
+
], FigureLibraryRelease.prototype, "names", void 0);
|
|
69
|
+
tslib_1.__decorate([
|
|
70
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
71
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Category of the figure at this release.' }),
|
|
72
|
+
tslib_1.__metadata("design:type", String)
|
|
73
|
+
], FigureLibraryRelease.prototype, "category", void 0);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({ ...(0, shell_1.longTextColumn)() }),
|
|
76
|
+
(0, type_graphql_1.Field)({ description: 'The released source, as the authoring server released it.' }),
|
|
77
|
+
tslib_1.__metadata("design:type", String)
|
|
78
|
+
], FigureLibraryRelease.prototype, "source", void 0);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, typeorm_1.Column)({ length: 64 }),
|
|
81
|
+
(0, type_graphql_1.Field)({ description: 'SHA-256 of the source. Same reference and hash is the same release.' }),
|
|
82
|
+
tslib_1.__metadata("design:type", String)
|
|
83
|
+
], FigureLibraryRelease.prototype, "contentHash", void 0);
|
|
84
|
+
tslib_1.__decorate([
|
|
85
|
+
(0, typeorm_1.Column)(),
|
|
86
|
+
(0, type_graphql_1.Field)({ description: 'The format the source declares (figure-asset-1).' }),
|
|
87
|
+
tslib_1.__metadata("design:type", String)
|
|
88
|
+
], FigureLibraryRelease.prototype, "assetFormat", void 0);
|
|
89
|
+
tslib_1.__decorate([
|
|
90
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
91
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Kernel version that released it on the authoring server.' }),
|
|
92
|
+
tslib_1.__metadata("design:type", String)
|
|
93
|
+
], FigureLibraryRelease.prototype, "kernelVersion", void 0);
|
|
94
|
+
tslib_1.__decorate([
|
|
95
|
+
(0, typeorm_1.Column)({ nullable: true, ...(0, shell_1.longTextColumn)() }),
|
|
96
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'What the release measured, as JSON text.' }),
|
|
97
|
+
tslib_1.__metadata("design:type", String)
|
|
98
|
+
], FigureLibraryRelease.prototype, "metrics", void 0);
|
|
99
|
+
tslib_1.__decorate([
|
|
100
|
+
(0, typeorm_1.Column)({ nullable: true, ...(0, shell_1.longTextColumn)() }),
|
|
101
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Top view of the release, as JSON text.' }),
|
|
102
|
+
tslib_1.__metadata("design:type", String)
|
|
103
|
+
], FigureLibraryRelease.prototype, "topView", void 0);
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, typeorm_1.Column)({ nullable: true, ...(0, shell_1.longTextColumn)() }),
|
|
106
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Contract changes against its previous release, as JSON text.' }),
|
|
107
|
+
tslib_1.__metadata("design:type", String)
|
|
108
|
+
], FigureLibraryRelease.prototype, "changes", void 0);
|
|
109
|
+
tslib_1.__decorate([
|
|
110
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
111
|
+
(0, type_graphql_1.Field)({ description: 'Derived: whether this server kernel reads the source.' }),
|
|
112
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
113
|
+
], FigureLibraryRelease.prototype, "formatSupported", void 0);
|
|
114
|
+
tslib_1.__decorate([
|
|
115
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
116
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Derived: kernel version that checked the source here.' }),
|
|
117
|
+
tslib_1.__metadata("design:type", String)
|
|
118
|
+
], FigureLibraryRelease.prototype, "checkedKernel", void 0);
|
|
119
|
+
tslib_1.__decorate([
|
|
120
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true }),
|
|
121
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Derived: authored width (size.x) in mm. Null when unread.' }),
|
|
122
|
+
tslib_1.__metadata("design:type", Number)
|
|
123
|
+
], FigureLibraryRelease.prototype, "width", void 0);
|
|
124
|
+
tslib_1.__decorate([
|
|
125
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true }),
|
|
126
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Derived: authored depth (size.z) in mm. Null when unread.' }),
|
|
127
|
+
tslib_1.__metadata("design:type", Number)
|
|
128
|
+
], FigureLibraryRelease.prototype, "depth", void 0);
|
|
129
|
+
tslib_1.__decorate([
|
|
130
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true, default: null }),
|
|
131
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'Files the release depends on: [{ hash, role, size, contentType }].' }),
|
|
132
|
+
tslib_1.__metadata("design:type", Array)
|
|
133
|
+
], FigureLibraryRelease.prototype, "dependencies", void 0);
|
|
134
|
+
tslib_1.__decorate([
|
|
135
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
136
|
+
(0, type_graphql_1.Field)({ description: 'Retired at the authoring server.' }),
|
|
137
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
138
|
+
], FigureLibraryRelease.prototype, "deprecated", void 0);
|
|
139
|
+
tslib_1.__decorate([
|
|
140
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
141
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Full name to use instead of a retired figure.' }),
|
|
142
|
+
tslib_1.__metadata("design:type", String)
|
|
143
|
+
], FigureLibraryRelease.prototype, "supersededBy", void 0);
|
|
144
|
+
tslib_1.__decorate([
|
|
145
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
146
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Address of the figure server the package came from.' }),
|
|
147
|
+
tslib_1.__metadata("design:type", String)
|
|
148
|
+
], FigureLibraryRelease.prototype, "sourceUrl", void 0);
|
|
149
|
+
tslib_1.__decorate([
|
|
150
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
151
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Domain of the figure server the package came from.' }),
|
|
152
|
+
tslib_1.__metadata("design:type", String)
|
|
153
|
+
], FigureLibraryRelease.prototype, "sourceDomain", void 0);
|
|
154
|
+
tslib_1.__decorate([
|
|
155
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
156
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'File name of the package it was imported from.' }),
|
|
157
|
+
tslib_1.__metadata("design:type", String)
|
|
158
|
+
], FigureLibraryRelease.prototype, "packageName", void 0);
|
|
159
|
+
tslib_1.__decorate([
|
|
160
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
161
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When the authoring server released it.' }),
|
|
162
|
+
tslib_1.__metadata("design:type", Date)
|
|
163
|
+
], FigureLibraryRelease.prototype, "releasedAt", void 0);
|
|
164
|
+
tslib_1.__decorate([
|
|
165
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
166
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Creation timestamp (when it was imported).' }),
|
|
167
|
+
tslib_1.__metadata("design:type", Date)
|
|
168
|
+
], FigureLibraryRelease.prototype, "createdAt", void 0);
|
|
169
|
+
tslib_1.__decorate([
|
|
170
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
171
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Last update timestamp.' }),
|
|
172
|
+
tslib_1.__metadata("design:type", Date)
|
|
173
|
+
], FigureLibraryRelease.prototype, "updatedAt", void 0);
|
|
174
|
+
tslib_1.__decorate([
|
|
175
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
|
176
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Soft-delete timestamp. Releases are not deleted.' }),
|
|
177
|
+
tslib_1.__metadata("design:type", Date)
|
|
178
|
+
], FigureLibraryRelease.prototype, "deletedAt", void 0);
|
|
179
|
+
tslib_1.__decorate([
|
|
180
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
181
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'The user who imported it.' }),
|
|
182
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
183
|
+
], FigureLibraryRelease.prototype, "creator", void 0);
|
|
184
|
+
tslib_1.__decorate([
|
|
185
|
+
(0, typeorm_1.RelationId)((release) => release.creator),
|
|
186
|
+
tslib_1.__metadata("design:type", String)
|
|
187
|
+
], FigureLibraryRelease.prototype, "creatorId", void 0);
|
|
188
|
+
tslib_1.__decorate([
|
|
189
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
190
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'The user who last updated it.' }),
|
|
191
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
192
|
+
], FigureLibraryRelease.prototype, "updater", void 0);
|
|
193
|
+
tslib_1.__decorate([
|
|
194
|
+
(0, typeorm_1.RelationId)((release) => release.updater),
|
|
195
|
+
tslib_1.__metadata("design:type", String)
|
|
196
|
+
], FigureLibraryRelease.prototype, "updaterId", void 0);
|
|
197
|
+
exports.FigureLibraryRelease = FigureLibraryRelease = tslib_1.__decorate([
|
|
198
|
+
(0, typeorm_1.Entity)(),
|
|
199
|
+
(0, typeorm_1.Index)('ix_figure_library_release_1', (release) => [release.domain, release.ref], {
|
|
200
|
+
unique: true,
|
|
201
|
+
where: '"deleted_at" IS NULL'
|
|
202
|
+
}),
|
|
203
|
+
(0, typeorm_1.Index)('ix_figure_library_release_2', (release) => [release.domain, release.namespace, release.type]),
|
|
204
|
+
(0, type_graphql_1.ObjectType)({ description: 'A released figure imported into this board server, one row per release reference.' })
|
|
205
|
+
], FigureLibraryRelease);
|
|
206
|
+
//# sourceMappingURL=figure-library-release.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-library-release.js","sourceRoot":"","sources":["../../../server/service/figure-library-release/figure-library-release.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAgE;AAChE,qDAA6C;AAE7C,yDAAgD;AAChD,iDAA8D;AAU9D;;;;;;GAMG;AAQI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CA6IhC,CAAA;AA7IY,oDAAoB;AAGtB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;;gDACrC;AAIpB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;sCACvF,cAAM;oDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;sDAC7C;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;;kDAC1D;AAIZ;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,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,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;sCAC5E,gBAAI;qDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;uDAC7C;+BA5IP,oBAAoB;IAPhC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,6BAA6B,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;QACtG,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,eAAK,EAAC,6BAA6B,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1H,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,mFAAmF,EAAE,CAAC;GACpG,oBAAoB,CA6IhC","sourcesContent":["import {\n Column,\n CreateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, longTextColumn } from '@things-factory/shell'\n\n/** A file a release depends on, as its package listed it. */\nexport interface FigureLibraryDependency {\n hash: string\n role: string\n size: number\n contentType: string\n}\n\n/**\n * A released figure this board server imported (ADR-0114 결정 3).\n *\n * The release data is immutable: the server that authored it never changes a release, so a row is added once and never\n * rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` are derived, recomputed when this\n * server's kernel is another version than the one that checked them. There is no delete path.\n */\n@Entity()\n@Index('ix_figure_library_release_1', (release: FigureLibraryRelease) => [release.domain, release.ref], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@Index('ix_figure_library_release_2', (release: FigureLibraryRelease) => [release.domain, release.namespace, release.type])\n@ObjectType({ description: 'A released figure imported into this board server, one row per release reference.' })\nexport class FigureLibraryRelease {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier.' })\n readonly id?: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain that imported the release.' })\n domain?: Domain\n\n @RelationId((release: FigureLibraryRelease) => release.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'Display name of the figure at this release.' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Description of the figure at this release.' })\n description?: string\n\n @Column()\n @Field({ description: 'Release reference {namespace}/{type}@{version}.' })\n ref: string\n\n @Column()\n @Field({ description: 'Namespace of the full name.' })\n namespace: string\n\n @Column()\n @Field({ description: 'Type of the full name.' })\n type: string\n\n @Column()\n @Field(type => Int, { description: 'Release version.' })\n version: number\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Display names by language.' })\n names?: Record<string, string>\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Category of the figure at this release.' })\n category?: string\n\n @Column({ ...longTextColumn() })\n @Field({ description: 'The released source, as the authoring server released it.' })\n source: string\n\n @Column({ length: 64 })\n @Field({ description: 'SHA-256 of the source. Same reference and hash is the same release.' })\n contentHash: string\n\n @Column()\n @Field({ description: 'The format the source declares (figure-asset-1).' })\n assetFormat: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Kernel version that released it on the authoring server.' })\n kernelVersion?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'What the release measured, as JSON text.' })\n metrics?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'Top view of the release, as JSON text.' })\n topView?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'Contract changes against its previous release, as JSON text.' })\n changes?: string\n\n @Column({ default: false })\n @Field({ description: 'Derived: whether this server kernel reads the source.' })\n formatSupported: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Derived: kernel version that checked the source here.' })\n checkedKernel?: string\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Derived: authored width (size.x) in mm. Null when unread.' })\n width?: number\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Derived: authored depth (size.z) in mm. Null when unread.' })\n depth?: number\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Files the release depends on: [{ hash, role, size, contentType }].' })\n dependencies?: FigureLibraryDependency[]\n\n @Column({ default: false })\n @Field({ description: 'Retired at the authoring server.' })\n deprecated: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Full name to use instead of a retired figure.' })\n supersededBy?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Address of the figure server the package came from.' })\n sourceUrl?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Domain of the figure server the package came from.' })\n sourceDomain?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'File name of the package it was imported from.' })\n packageName?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When the authoring server released it.' })\n releasedAt?: Date\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Creation timestamp (when it was imported).' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Last update timestamp.' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'Soft-delete timestamp. Releases are not deleted.' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who imported it.' })\n creator?: User\n\n @RelationId((release: FigureLibraryRelease) => release.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who last updated it.' })\n updater?: User\n\n @RelationId((release: FigureLibraryRelease) => release.updater)\n updaterId?: string\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
|
|
2
|
+
import { ListParam } from '@things-factory/shell';
|
|
3
|
+
import { FigureTypeMap, FigureTypeMapState } from './figure-type-map/figure-type-map';
|
|
4
|
+
import { FigureTypeMapEntry } from './figure-type-map/figure-type-map-entry';
|
|
5
|
+
import { FigureImportResult, FigureLibraryReleaseList, FigureTypeMapLineInput } from './figure-library-types';
|
|
6
|
+
/**
|
|
7
|
+
* The library and the type map of a board server (ADR-0114). Reading is `figure-library` query; changing is its
|
|
8
|
+
* mutation. Boards ask `figureBlueprints` under `figure-published`, the door every figure consumer asks through.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FigureLibraryResolver {
|
|
11
|
+
figureLibraryReleases(params: ListParam, context: ResolverContext): Promise<FigureLibraryReleaseList>;
|
|
12
|
+
figureTypeMaps(context: ResolverContext): Promise<FigureTypeMap[]>;
|
|
13
|
+
figureTypeMapEntries(version: number, context: ResolverContext): Promise<FigureTypeMapEntry[]>;
|
|
14
|
+
figureTypeMapCheck(context: ResolverContext): Promise<any>;
|
|
15
|
+
figureBoardRequirements(boardId: string, context: ResolverContext): Promise<any>;
|
|
16
|
+
figureBlueprints(types: string[], context: ResolverContext, map?: FigureTypeMapState): Promise<any>;
|
|
17
|
+
importFigurePackage(file: FileUpload, context: ResolverContext): Promise<FigureImportResult>;
|
|
18
|
+
saveFigureTypeMapCandidate(lines: FigureTypeMapLineInput[], context: ResolverContext, description?: string): Promise<FigureTypeMap>;
|
|
19
|
+
activateFigureTypeMap(version: number, context: ResolverContext): Promise<FigureTypeMap>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FigureLibraryResolver = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const graphql_scalars_1 = require("graphql-scalars");
|
|
7
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const shell_1 = require("@things-factory/shell");
|
|
10
|
+
const figure_library_release_1 = require("./figure-library-release/figure-library-release");
|
|
11
|
+
const figure_type_map_1 = require("./figure-type-map/figure-type-map");
|
|
12
|
+
const figure_type_map_entry_1 = require("./figure-type-map/figure-type-map-entry");
|
|
13
|
+
const figure_library_types_1 = require("./figure-library-types");
|
|
14
|
+
const blueprints_1 = require("./library/blueprints");
|
|
15
|
+
const import_1 = require("./library/import");
|
|
16
|
+
const inspection_1 = require("./library/inspection");
|
|
17
|
+
const type_map_1 = require("./library/type-map");
|
|
18
|
+
/**
|
|
19
|
+
* A refusal in the asker's language as plain text: a board draws it on a canvas, not into HTML, so the values in it
|
|
20
|
+
* (a name with `/`) are not escaped.
|
|
21
|
+
*/
|
|
22
|
+
function plainTextOf(refusal, context) {
|
|
23
|
+
return context.t
|
|
24
|
+
? context.t((0, shell_1.refusalKey)(refusal.code), { ...refusal.params, defaultValue: refusal.message, interpolation: { escapeValue: false } })
|
|
25
|
+
: refusal.message;
|
|
26
|
+
}
|
|
27
|
+
/** The most bytes one package upload may carry. */
|
|
28
|
+
const PACKAGE_MAX_BYTES = 64 * 1024 * 1024;
|
|
29
|
+
async function bytesOf(file) {
|
|
30
|
+
const chunks = [];
|
|
31
|
+
let size = 0;
|
|
32
|
+
for await (const chunk of file.createReadStream()) {
|
|
33
|
+
size += chunk.length;
|
|
34
|
+
if (size > PACKAGE_MAX_BYTES)
|
|
35
|
+
throw new shell_1.Refusal('figure-package-too-large', { max: PACKAGE_MAX_BYTES }, 'a figure package is at most {max} bytes.');
|
|
36
|
+
chunks.push(Buffer.from(chunk));
|
|
37
|
+
}
|
|
38
|
+
return Buffer.concat(chunks);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The library and the type map of a board server (ADR-0114). Reading is `figure-library` query; changing is its
|
|
42
|
+
* mutation. Boards ask `figureBlueprints` under `figure-published`, the door every figure consumer asks through.
|
|
43
|
+
*/
|
|
44
|
+
let FigureLibraryResolver = class FigureLibraryResolver {
|
|
45
|
+
async figureLibraryReleases(params, context) {
|
|
46
|
+
const { domain, tx } = context.state;
|
|
47
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
48
|
+
repository: (0, shell_1.getRepository)(figure_library_release_1.FigureLibraryRelease, tx),
|
|
49
|
+
params,
|
|
50
|
+
domain,
|
|
51
|
+
alias: 'release',
|
|
52
|
+
searchables: ['ref', 'name', 'description', 'category']
|
|
53
|
+
});
|
|
54
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
55
|
+
const manager = tx ?? (0, shell_1.getRepository)(figure_library_release_1.FigureLibraryRelease).manager;
|
|
56
|
+
for (const item of items)
|
|
57
|
+
await (0, inspection_1.freshen)(manager, item);
|
|
58
|
+
return { items, total };
|
|
59
|
+
}
|
|
60
|
+
async figureTypeMaps(context) {
|
|
61
|
+
const { domain } = context.state;
|
|
62
|
+
return await (0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).find({ where: { domain: { id: domain.id } }, order: { version: 'DESC' } });
|
|
63
|
+
}
|
|
64
|
+
async figureTypeMapEntries(version, context) {
|
|
65
|
+
const { domain } = context.state;
|
|
66
|
+
const map = await (0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).findOne({ where: { domain: { id: domain.id }, version } });
|
|
67
|
+
return map ? await (0, type_map_1.entriesOf)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, map) : [];
|
|
68
|
+
}
|
|
69
|
+
async figureTypeMapCheck(context) {
|
|
70
|
+
const { domain } = context.state;
|
|
71
|
+
return await (0, inspection_1.typeMapCheck)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain);
|
|
72
|
+
}
|
|
73
|
+
async figureBoardRequirements(boardId, context) {
|
|
74
|
+
const { domain } = context.state;
|
|
75
|
+
return await (0, inspection_1.boardRequirements)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain, boardId);
|
|
76
|
+
}
|
|
77
|
+
async figureBlueprints(types, context, map) {
|
|
78
|
+
const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
|
|
79
|
+
const state = map === figure_type_map_1.FigureTypeMapState.CANDIDATE ? figure_type_map_1.FigureTypeMapState.CANDIDATE : figure_type_map_1.FigureTypeMapState.ACTIVE;
|
|
80
|
+
if (state === figure_type_map_1.FigureTypeMapState.CANDIDATE) {
|
|
81
|
+
const allowed = await (0, auth_base_1.checkPermission)({ category: 'figure-library', privilege: 'mutation', owner: true }, user, domain, unsafeIP, prohibitedPrivileges);
|
|
82
|
+
if (!allowed)
|
|
83
|
+
throw new shell_1.Refusal('figure-type-map-preview-denied', {}, 'previewing the candidate type map needs the right to change it.');
|
|
84
|
+
}
|
|
85
|
+
return await (0, blueprints_1.blueprintsOf)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain, types, state, refusal => plainTextOf(refusal, context));
|
|
86
|
+
}
|
|
87
|
+
async importFigurePackage(file, context) {
|
|
88
|
+
const { domain, user, tx } = context.state;
|
|
89
|
+
const upload = await file;
|
|
90
|
+
(0, import_1.assertPackageName)(upload.filename);
|
|
91
|
+
return await (0, import_1.importFigurePackage)(tx, domain, user, await bytesOf(upload), upload.filename);
|
|
92
|
+
}
|
|
93
|
+
async saveFigureTypeMapCandidate(lines, context, description) {
|
|
94
|
+
const { domain, user, tx } = context.state;
|
|
95
|
+
return await (0, type_map_1.saveCandidate)(tx, domain, user, lines, description);
|
|
96
|
+
}
|
|
97
|
+
async activateFigureTypeMap(version, context) {
|
|
98
|
+
const { domain, user, tx } = context.state;
|
|
99
|
+
return await (0, type_map_1.activate)(tx, domain, user, version);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.FigureLibraryResolver = FigureLibraryResolver;
|
|
103
|
+
tslib_1.__decorate([
|
|
104
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
|
|
105
|
+
(0, type_graphql_1.Query)(returns => figure_library_types_1.FigureLibraryReleaseList, { description: 'Lists the releases imported into this domain.' }),
|
|
106
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
107
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
108
|
+
tslib_1.__metadata("design:type", Function),
|
|
109
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
110
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
111
|
+
], FigureLibraryResolver.prototype, "figureLibraryReleases", null);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
|
|
114
|
+
(0, type_graphql_1.Query)(returns => [figure_type_map_1.FigureTypeMap], { description: 'The type map releases of this domain, newest first.' }),
|
|
115
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
116
|
+
tslib_1.__metadata("design:type", Function),
|
|
117
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
118
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
119
|
+
], FigureLibraryResolver.prototype, "figureTypeMaps", null);
|
|
120
|
+
tslib_1.__decorate([
|
|
121
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
|
|
122
|
+
(0, type_graphql_1.Query)(returns => [figure_type_map_entry_1.FigureTypeMapEntry], { description: 'The lines of one type map release, with the release each draws with.' }),
|
|
123
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('version', type => type_graphql_1.Int)),
|
|
124
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
125
|
+
tslib_1.__metadata("design:type", Function),
|
|
126
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
127
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
128
|
+
], FigureLibraryResolver.prototype, "figureTypeMapEntries", null);
|
|
129
|
+
tslib_1.__decorate([
|
|
130
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
|
|
131
|
+
(0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, {
|
|
132
|
+
nullable: true,
|
|
133
|
+
description: 'The check before activation: the candidate against the active map and every board of the domain. Null without a candidate.'
|
|
134
|
+
}),
|
|
135
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
136
|
+
tslib_1.__metadata("design:type", Function),
|
|
137
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
138
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
139
|
+
], FigureLibraryResolver.prototype, "figureTypeMapCheck", null);
|
|
140
|
+
tslib_1.__decorate([
|
|
141
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
|
|
142
|
+
(0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'What one board needs from the active type map: each figure, its status and node count.' }),
|
|
143
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('boardId')),
|
|
144
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
145
|
+
tslib_1.__metadata("design:type", Function),
|
|
146
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
147
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
148
|
+
], FigureLibraryResolver.prototype, "figureBoardRequirements", null);
|
|
149
|
+
tslib_1.__decorate([
|
|
150
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-published", privilege: "query", domainOwnerGranted: true)'),
|
|
151
|
+
(0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, {
|
|
152
|
+
description: 'Figures a board asks for together by full name {namespace}/{type}, answered from one type map release: { release: { version, revision }, items: [{ type, ref, asset }], refused: [{ type, code, message }] }.'
|
|
153
|
+
}),
|
|
154
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('types', type => [String], { description: 'Full figure names {namespace}/{type}. At most 500.' })),
|
|
155
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
156
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('map', type => figure_type_map_1.FigureTypeMapState, { nullable: true, description: 'ACTIVE (default) or CANDIDATE for a preview.' })),
|
|
157
|
+
tslib_1.__metadata("design:type", Function),
|
|
158
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
|
|
159
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
160
|
+
], FigureLibraryResolver.prototype, "figureBlueprints", null);
|
|
161
|
+
tslib_1.__decorate([
|
|
162
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
163
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
|
|
164
|
+
(0, type_graphql_1.Mutation)(returns => figure_library_types_1.FigureImportResult, { description: 'Imports a figure package into this domain library and its candidate type map.' }),
|
|
165
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('file', () => GraphQLUpload_js_1.default)),
|
|
166
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
167
|
+
tslib_1.__metadata("design:type", Function),
|
|
168
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
169
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
170
|
+
], FigureLibraryResolver.prototype, "importFigurePackage", null);
|
|
171
|
+
tslib_1.__decorate([
|
|
172
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
173
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
|
|
174
|
+
(0, type_graphql_1.Mutation)(returns => figure_type_map_1.FigureTypeMap, { description: 'Replaces the lines of the candidate type map. Each save raises its revision.' }),
|
|
175
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('lines', type => [figure_library_types_1.FigureTypeMapLineInput])),
|
|
176
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
177
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('description', { nullable: true })),
|
|
178
|
+
tslib_1.__metadata("design:type", Function),
|
|
179
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
|
|
180
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
181
|
+
], FigureLibraryResolver.prototype, "saveFigureTypeMapCandidate", null);
|
|
182
|
+
tslib_1.__decorate([
|
|
183
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
184
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
|
|
185
|
+
(0, type_graphql_1.Mutation)(returns => figure_type_map_1.FigureTypeMap, { description: 'Activates a type map release: the candidate, or an archived one to roll back.' }),
|
|
186
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('version', type => type_graphql_1.Int)),
|
|
187
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
188
|
+
tslib_1.__metadata("design:type", Function),
|
|
189
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
190
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
191
|
+
], FigureLibraryResolver.prototype, "activateFigureTypeMap", null);
|
|
192
|
+
exports.FigureLibraryResolver = FigureLibraryResolver = tslib_1.__decorate([
|
|
193
|
+
(0, type_graphql_1.Resolver)(),
|
|
194
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
195
|
+
], FigureLibraryResolver);
|
|
196
|
+
//# sourceMappingURL=figure-library-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-library-resolver.js","sourceRoot":"","sources":["../../server/service/figure-library-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAAuG;AACvG,qDAA6C;AAE7C,+FAA2D;AAE3D,yDAA2D;AAC3D,iDAAmI;AAEnI,4FAAsF;AACtF,uEAAqF;AACrF,mFAA4E;AAC5E,iEAA6G;AAC7G,qDAAmD;AACnD,6CAAyE;AACzE,qDAA+E;AAC/E,iDAAuE;AAEvE;;;GAGG;AACH,SAAS,WAAW,CAAC,OAAgB,EAAE,OAAY;IACjD,OAAO,OAAO,CAAC,CAAC;QACd,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,kBAAU,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC;QAClI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;AACrB,CAAC;AAED,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAE1C,KAAK,UAAU,OAAO,CAAC,IAAgB;IACrC,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAClD,IAAI,IAAI,KAAK,CAAC,MAAM,CAAA;QACpB,IAAI,IAAI,GAAG,iBAAiB;YAAE,MAAM,IAAI,eAAO,CAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE,EAAE,0CAA0C,CAAC,CAAA;QACnJ,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC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C,OAAO,CAAC,EAAE,CAAC,+BAAa,EAAE,EAAE,WAAW,EAAE,8EAA8E,EAAE,CAAC;IAEjI,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,6CAAsB,CAAC,CAAC,CAAA;IAC9C,mBAAA,IAAA,kBAAG,GAAE,CAAA;IACL,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;;uEAIxC;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,yFAAyF,CAAC;IACpG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,+BAAa,EAAE,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;IACxG,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IAAmB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;kEAG/E;gCAlGU,qBAAqB;IAFjC,IAAA,uBAAQ,GAAE;IACV,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,qBAAqB,CAmGjC","sourcesContent":["import { Arg, Args, Ctx, Directive, Int, Mutation, Query, Resolver, UseMiddleware } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\nimport type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\n\nimport { checkPermission } from '@things-factory/auth-base'\nimport { getQueryBuilderFromListParams, getRepository, ListParam, Refusal, refusalKey, SpeakRefusals } 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'\nimport { FigureImportResult, FigureLibraryReleaseList, FigureTypeMapLineInput } from './figure-library-types'\nimport { blueprintsOf } from './library/blueprints'\nimport { assertPackageName, importFigurePackage } from './library/import'\nimport { boardRequirements, freshen, typeMapCheck } from './library/inspection'\nimport { activate, entriesOf, saveCandidate } from './library/type-map'\n\n/**\n * A refusal in the asker's language as plain text: a board draws it on a canvas, not into HTML, so the values in it\n * (a name with `/`) are not escaped.\n */\nfunction plainTextOf(refusal: Refusal, context: any): string {\n return context.t\n ? context.t(refusalKey(refusal.code), { ...refusal.params, defaultValue: refusal.message, interpolation: { escapeValue: false } })\n : refusal.message\n}\n\n/** The most bytes one package upload may carry. */\nconst PACKAGE_MAX_BYTES = 64 * 1024 * 1024\n\nasync function bytesOf(file: FileUpload): Promise<Buffer> {\n const chunks: Buffer[] = []\n let size = 0\n for await (const chunk of file.createReadStream()) {\n size += chunk.length\n if (size > PACKAGE_MAX_BYTES) throw new Refusal('figure-package-too-large', { max: PACKAGE_MAX_BYTES }, 'a figure package is at most {max} bytes.')\n chunks.push(Buffer.from(chunk))\n }\n return Buffer.concat(chunks)\n}\n\n/**\n * The library and the type map of a board server (ADR-0114). Reading is `figure-library` query; changing is its\n * mutation. Boards ask `figureBlueprints` under `figure-published`, the door every figure consumer asks through.\n */\n@Resolver()\n@UseMiddleware(SpeakRefusals)\nexport class FigureLibraryResolver {\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => FigureLibraryReleaseList, { description: 'Lists the releases imported into this domain.' })\n async figureLibraryReleases(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<FigureLibraryReleaseList> {\n const { domain, tx } = context.state\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(FigureLibraryRelease, tx),\n params,\n domain,\n alias: 'release',\n searchables: ['ref', 'name', 'description', 'category']\n })\n const [items, total] = await queryBuilder.getManyAndCount()\n const manager = tx ?? getRepository(FigureLibraryRelease).manager\n for (const item of items) await freshen(manager, item)\n return { items, total }\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [FigureTypeMap], { description: 'The type map releases of this domain, newest first.' })\n async figureTypeMaps(@Ctx() context: ResolverContext): Promise<FigureTypeMap[]> {\n const { domain } = context.state\n return await getRepository(FigureTypeMap).find({ where: { domain: { id: domain.id } }, order: { version: 'DESC' } })\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [FigureTypeMapEntry], { description: 'The lines of one type map release, with the release each draws with.' })\n async figureTypeMapEntries(@Arg('version', type => Int) version: number, @Ctx() context: ResolverContext): Promise<FigureTypeMapEntry[]> {\n const { domain } = context.state\n const map = await getRepository(FigureTypeMap).findOne({ where: { domain: { id: domain.id }, version } })\n return map ? await entriesOf(getRepository(FigureTypeMap).manager, map) : []\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, {\n nullable: true,\n description: 'The check before activation: the candidate against the active map and every board of the domain. Null without a candidate.'\n })\n async figureTypeMapCheck(@Ctx() context: ResolverContext): Promise<any> {\n const { domain } = context.state\n return await typeMapCheck(getRepository(FigureTypeMap).manager, domain)\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, { nullable: true, description: 'What one board needs from the active type map: each figure, its status and node count.' })\n async figureBoardRequirements(@Arg('boardId') boardId: string, @Ctx() context: ResolverContext): Promise<any> {\n const { domain } = context.state\n return await boardRequirements(getRepository(FigureTypeMap).manager, domain, boardId)\n }\n\n @Directive('@privilege(category: \"figure-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, {\n description:\n 'Figures a board asks for together by full name {namespace}/{type}, answered from one type map release: { release: { version, revision }, items: [{ type, ref, asset }], refused: [{ type, code, message }] }.'\n })\n async figureBlueprints(\n @Arg('types', type => [String], { description: 'Full figure names {namespace}/{type}. At most 500.' }) types: string[],\n @Ctx() context: ResolverContext,\n @Arg('map', type => FigureTypeMapState, { nullable: true, description: 'ACTIVE (default) or CANDIDATE for a preview.' })\n map?: FigureTypeMapState\n ): Promise<any> {\n const { domain, user, unsafeIP, prohibitedPrivileges } = context.state\n const state = map === FigureTypeMapState.CANDIDATE ? FigureTypeMapState.CANDIDATE : FigureTypeMapState.ACTIVE\n if (state === FigureTypeMapState.CANDIDATE) {\n const allowed = await checkPermission({ category: 'figure-library', privilege: 'mutation', owner: true }, user, domain, unsafeIP, prohibitedPrivileges)\n if (!allowed) throw new Refusal('figure-type-map-preview-denied', {}, 'previewing the candidate type map needs the right to change it.')\n }\n return await blueprintsOf(getRepository(FigureTypeMap).manager, domain, types, state, refusal => plainTextOf(refusal, context))\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureImportResult, { description: 'Imports a figure package into this domain library and its candidate type map.' })\n async importFigurePackage(@Arg('file', () => GraphQLUpload) file: FileUpload, @Ctx() context: ResolverContext): Promise<FigureImportResult> {\n const { domain, user, tx } = context.state\n const upload = await file\n assertPackageName(upload.filename)\n return await importFigurePackage(tx, domain, user, await bytesOf(upload), upload.filename)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureTypeMap, { description: 'Replaces the lines of the candidate type map. Each save raises its revision.' })\n async saveFigureTypeMapCandidate(\n @Arg('lines', type => [FigureTypeMapLineInput]) lines: FigureTypeMapLineInput[],\n @Ctx() context: ResolverContext,\n @Arg('description', { nullable: true }) description?: string\n ): Promise<FigureTypeMap> {\n const { domain, user, tx } = context.state\n return await saveCandidate(tx, domain, user, lines, description)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureTypeMap, { description: 'Activates a type map release: the candidate, or an archived one to roll back.' })\n async activateFigureTypeMap(@Arg('version', type => Int) version: number, @Ctx() context: ResolverContext): Promise<FigureTypeMap> {\n const { domain, user, tx } = context.state\n return await activate(tx, domain, user, version)\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FigureLibraryRelease } from './figure-library-release/figure-library-release';
|
|
2
|
+
export declare class FigureLibraryReleaseList {
|
|
3
|
+
items: FigureLibraryRelease[];
|
|
4
|
+
total: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class FigureTypeMapLineInput {
|
|
7
|
+
name: string;
|
|
8
|
+
releaseId: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class FigureImportOutcome {
|
|
11
|
+
ref: string;
|
|
12
|
+
outcome: string;
|
|
13
|
+
code?: string;
|
|
14
|
+
differs?: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare class FigureImportProblem {
|
|
17
|
+
code: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class FigureImportResult {
|
|
21
|
+
problems: FigureImportProblem[];
|
|
22
|
+
outcomes: FigureImportOutcome[];
|
|
23
|
+
}
|