@things-factory/figure-service 10.1.291 → 10.1.296
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/capability-module/capability-module-entity.d.ts +20 -0
- package/dist-server/service/capability-module/capability-module-entity.js +112 -11
- package/dist-server/service/capability-module/capability-module-resolver.js +7 -6
- package/dist-server/service/capability-module/capability-module-store.d.ts +4 -6
- package/dist-server/service/capability-module/capability-module-store.js +12 -23
- package/dist-server/service/capability-module/capability-release-check.js +16 -5
- package/dist-server/service/figure/figure-format.d.ts +15 -4
- package/dist-server/service/figure/figure-format.js +4 -3
- package/dist-server/service/figure/figure-mutation.js +2 -2
- package/dist-server/service/figure/figure-query.js +5 -5
- package/dist-server/service/figure/figure-tools.js +2 -2
- package/dist-server/service/index.d.ts +2 -2
- package/dist-server/service/install-key/figure-install-key.d.ts +9 -0
- package/dist-server/service/install-key/figure-install-key.js +28 -15
- package/package.json +13 -9
- package/translations/en.json +2 -2
- package/translations/es.json +2 -2
- package/translations/ja.json +2 -2
- package/translations/ko.json +2 -2
- package/translations/ms.json +2 -2
- package/translations/zh.json +2 -2
|
@@ -16,8 +16,11 @@ export declare class FigureCapabilityModule {
|
|
|
16
16
|
capabilities?: string[];
|
|
17
17
|
current?: boolean;
|
|
18
18
|
createdAt?: Date;
|
|
19
|
+
updatedAt?: Date;
|
|
19
20
|
creator?: User;
|
|
20
21
|
creatorId?: string;
|
|
22
|
+
updater?: User;
|
|
23
|
+
updaterId?: string;
|
|
21
24
|
}
|
|
22
25
|
/** A provider a domain chose (ADR-0172 decision 5): its modeller loads it and its releases are checked by it. */
|
|
23
26
|
export declare class FigureCapabilityUse {
|
|
@@ -26,7 +29,11 @@ export declare class FigureCapabilityUse {
|
|
|
26
29
|
domainId?: string;
|
|
27
30
|
provider?: string;
|
|
28
31
|
createdAt?: Date;
|
|
32
|
+
updatedAt?: Date;
|
|
29
33
|
creator?: User;
|
|
34
|
+
creatorId?: string;
|
|
35
|
+
updater?: User;
|
|
36
|
+
updaterId?: string;
|
|
30
37
|
}
|
|
31
38
|
/**
|
|
32
39
|
* The choice lists a domain's own provider pushed with its module (ADR-0172 amendment 2, decisions 19 and 20): the
|
|
@@ -35,9 +42,15 @@ export declare class FigureCapabilityUse {
|
|
|
35
42
|
export declare class FigureCapabilityChoiceLists {
|
|
36
43
|
readonly id?: string;
|
|
37
44
|
domain?: Domain;
|
|
45
|
+
domainId?: string;
|
|
38
46
|
provider?: string;
|
|
39
47
|
choices?: Record<string, unknown[]>;
|
|
48
|
+
createdAt?: Date;
|
|
40
49
|
updatedAt?: Date;
|
|
50
|
+
creator?: User;
|
|
51
|
+
creatorId?: string;
|
|
52
|
+
updater?: User;
|
|
53
|
+
updaterId?: string;
|
|
41
54
|
}
|
|
42
55
|
/**
|
|
43
56
|
* What an install key may push besides reading released figures (ADR-0172 decision 14): the capability module of one
|
|
@@ -46,7 +59,14 @@ export declare class FigureCapabilityChoiceLists {
|
|
|
46
59
|
export declare class FigureInstallKeyCapability {
|
|
47
60
|
readonly id?: string;
|
|
48
61
|
domain?: Domain;
|
|
62
|
+
domainId?: string;
|
|
49
63
|
/** The install key (an appliance) */
|
|
50
64
|
applianceId?: string;
|
|
51
65
|
provider?: string;
|
|
66
|
+
createdAt?: Date;
|
|
67
|
+
updatedAt?: Date;
|
|
68
|
+
creator?: User;
|
|
69
|
+
creatorId?: string;
|
|
70
|
+
updater?: User;
|
|
71
|
+
updaterId?: string;
|
|
52
72
|
}
|
|
@@ -59,6 +59,11 @@ tslib_1.__decorate([
|
|
|
59
59
|
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was registered.' }),
|
|
60
60
|
tslib_1.__metadata("design:type", Date)
|
|
61
61
|
], FigureCapabilityModule.prototype, "createdAt", void 0);
|
|
62
|
+
tslib_1.__decorate([
|
|
63
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
64
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was last changed.' }),
|
|
65
|
+
tslib_1.__metadata("design:type", Date)
|
|
66
|
+
], FigureCapabilityModule.prototype, "updatedAt", void 0);
|
|
62
67
|
tslib_1.__decorate([
|
|
63
68
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
64
69
|
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who registered it.' }),
|
|
@@ -68,9 +73,18 @@ tslib_1.__decorate([
|
|
|
68
73
|
(0, typeorm_1.RelationId)((m) => m.creator),
|
|
69
74
|
tslib_1.__metadata("design:type", String)
|
|
70
75
|
], FigureCapabilityModule.prototype, "creatorId", void 0);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
78
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it.' }),
|
|
79
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
80
|
+
], FigureCapabilityModule.prototype, "updater", void 0);
|
|
81
|
+
tslib_1.__decorate([
|
|
82
|
+
(0, typeorm_1.RelationId)((m) => m.updater),
|
|
83
|
+
tslib_1.__metadata("design:type", String)
|
|
84
|
+
], FigureCapabilityModule.prototype, "updaterId", void 0);
|
|
71
85
|
exports.FigureCapabilityModule = FigureCapabilityModule = tslib_1.__decorate([
|
|
72
|
-
(0, typeorm_1.Entity)(),
|
|
73
|
-
(0, typeorm_1.Index)('ix_figure_capability_module_0', (m) => [m.provider, m.version, m.domain]),
|
|
86
|
+
(0, typeorm_1.Entity)('figure_capability_modules'),
|
|
87
|
+
(0, typeorm_1.Index)('ix_figure_capability_module_0', (m) => [m.provider, m.version, m.domain], { unique: true }),
|
|
74
88
|
(0, typeorm_1.Index)('ix_figure_capability_module_1', (m) => [m.sha256]),
|
|
75
89
|
(0, type_graphql_1.ObjectType)({ description: "One version of a capability module: a provider's descriptors in one ESM file." })
|
|
76
90
|
], FigureCapabilityModule);
|
|
@@ -85,6 +99,7 @@ tslib_1.__decorate([
|
|
|
85
99
|
], FigureCapabilityUse.prototype, "id", void 0);
|
|
86
100
|
tslib_1.__decorate([
|
|
87
101
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
102
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { description: 'The domain that uses it.' }),
|
|
88
103
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
89
104
|
], FigureCapabilityUse.prototype, "domain", void 0);
|
|
90
105
|
tslib_1.__decorate([
|
|
@@ -98,15 +113,34 @@ tslib_1.__decorate([
|
|
|
98
113
|
], FigureCapabilityUse.prototype, "provider", void 0);
|
|
99
114
|
tslib_1.__decorate([
|
|
100
115
|
(0, typeorm_1.CreateDateColumn)(),
|
|
101
|
-
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was
|
|
116
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was made.' }),
|
|
102
117
|
tslib_1.__metadata("design:type", Date)
|
|
103
118
|
], FigureCapabilityUse.prototype, "createdAt", void 0);
|
|
119
|
+
tslib_1.__decorate([
|
|
120
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
121
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was last changed.' }),
|
|
122
|
+
tslib_1.__metadata("design:type", Date)
|
|
123
|
+
], FigureCapabilityUse.prototype, "updatedAt", void 0);
|
|
104
124
|
tslib_1.__decorate([
|
|
105
125
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
126
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who made it.' }),
|
|
106
127
|
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
107
128
|
], FigureCapabilityUse.prototype, "creator", void 0);
|
|
129
|
+
tslib_1.__decorate([
|
|
130
|
+
(0, typeorm_1.RelationId)((u) => u.creator),
|
|
131
|
+
tslib_1.__metadata("design:type", String)
|
|
132
|
+
], FigureCapabilityUse.prototype, "creatorId", void 0);
|
|
133
|
+
tslib_1.__decorate([
|
|
134
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
135
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it.' }),
|
|
136
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
137
|
+
], FigureCapabilityUse.prototype, "updater", void 0);
|
|
138
|
+
tslib_1.__decorate([
|
|
139
|
+
(0, typeorm_1.RelationId)((u) => u.updater),
|
|
140
|
+
tslib_1.__metadata("design:type", String)
|
|
141
|
+
], FigureCapabilityUse.prototype, "updaterId", void 0);
|
|
108
142
|
exports.FigureCapabilityUse = FigureCapabilityUse = tslib_1.__decorate([
|
|
109
|
-
(0, typeorm_1.Entity)(),
|
|
143
|
+
(0, typeorm_1.Entity)('figure_capability_uses'),
|
|
110
144
|
(0, typeorm_1.Index)('ix_figure_capability_use_0', (u) => [u.domain, u.provider], { unique: true }),
|
|
111
145
|
(0, type_graphql_1.ObjectType)({ description: 'A capability provider a domain uses.' })
|
|
112
146
|
], FigureCapabilityUse);
|
|
@@ -119,27 +153,59 @@ let FigureCapabilityChoiceLists = class FigureCapabilityChoiceLists {
|
|
|
119
153
|
exports.FigureCapabilityChoiceLists = FigureCapabilityChoiceLists;
|
|
120
154
|
tslib_1.__decorate([
|
|
121
155
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
156
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier.' }),
|
|
122
157
|
tslib_1.__metadata("design:type", String)
|
|
123
158
|
], FigureCapabilityChoiceLists.prototype, "id", void 0);
|
|
124
159
|
tslib_1.__decorate([
|
|
125
160
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
161
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { description: 'The domain whose provider pushed them.' }),
|
|
126
162
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
127
163
|
], FigureCapabilityChoiceLists.prototype, "domain", void 0);
|
|
164
|
+
tslib_1.__decorate([
|
|
165
|
+
(0, typeorm_1.RelationId)((c) => c.domain),
|
|
166
|
+
tslib_1.__metadata("design:type", String)
|
|
167
|
+
], FigureCapabilityChoiceLists.prototype, "domainId", void 0);
|
|
128
168
|
tslib_1.__decorate([
|
|
129
169
|
(0, typeorm_1.Column)(),
|
|
170
|
+
(0, type_graphql_1.Field)({ description: 'The provider.' }),
|
|
130
171
|
tslib_1.__metadata("design:type", String)
|
|
131
172
|
], FigureCapabilityChoiceLists.prototype, "provider", void 0);
|
|
132
173
|
tslib_1.__decorate([
|
|
133
174
|
(0, typeorm_1.Column)('simple-json'),
|
|
134
175
|
tslib_1.__metadata("design:type", Object)
|
|
135
176
|
], FigureCapabilityChoiceLists.prototype, "choices", void 0);
|
|
177
|
+
tslib_1.__decorate([
|
|
178
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
179
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was made.' }),
|
|
180
|
+
tslib_1.__metadata("design:type", Date)
|
|
181
|
+
], FigureCapabilityChoiceLists.prototype, "createdAt", void 0);
|
|
136
182
|
tslib_1.__decorate([
|
|
137
183
|
(0, typeorm_1.UpdateDateColumn)(),
|
|
184
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was last changed.' }),
|
|
138
185
|
tslib_1.__metadata("design:type", Date)
|
|
139
186
|
], FigureCapabilityChoiceLists.prototype, "updatedAt", void 0);
|
|
187
|
+
tslib_1.__decorate([
|
|
188
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
189
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who made it.' }),
|
|
190
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
191
|
+
], FigureCapabilityChoiceLists.prototype, "creator", void 0);
|
|
192
|
+
tslib_1.__decorate([
|
|
193
|
+
(0, typeorm_1.RelationId)((c) => c.creator),
|
|
194
|
+
tslib_1.__metadata("design:type", String)
|
|
195
|
+
], FigureCapabilityChoiceLists.prototype, "creatorId", void 0);
|
|
196
|
+
tslib_1.__decorate([
|
|
197
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
198
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it.' }),
|
|
199
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
200
|
+
], FigureCapabilityChoiceLists.prototype, "updater", void 0);
|
|
201
|
+
tslib_1.__decorate([
|
|
202
|
+
(0, typeorm_1.RelationId)((c) => c.updater),
|
|
203
|
+
tslib_1.__metadata("design:type", String)
|
|
204
|
+
], FigureCapabilityChoiceLists.prototype, "updaterId", void 0);
|
|
140
205
|
exports.FigureCapabilityChoiceLists = FigureCapabilityChoiceLists = tslib_1.__decorate([
|
|
141
|
-
(0, typeorm_1.Entity)(),
|
|
142
|
-
(0, typeorm_1.Index)('
|
|
206
|
+
(0, typeorm_1.Entity)('figure_capability_choice_lists'),
|
|
207
|
+
(0, typeorm_1.Index)('ix_figure_capability_choice_list_0', (c) => [c.domain, c.provider], { unique: true }),
|
|
208
|
+
(0, type_graphql_1.ObjectType)({ description: "The choice lists a domain's provider pushed with its module." })
|
|
143
209
|
], FigureCapabilityChoiceLists);
|
|
144
210
|
/**
|
|
145
211
|
* What an install key may push besides reading released figures (ADR-0172 decision 14): the capability module of one
|
|
@@ -150,24 +216,59 @@ let FigureInstallKeyCapability = class FigureInstallKeyCapability {
|
|
|
150
216
|
exports.FigureInstallKeyCapability = FigureInstallKeyCapability;
|
|
151
217
|
tslib_1.__decorate([
|
|
152
218
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
219
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier.' }),
|
|
153
220
|
tslib_1.__metadata("design:type", String)
|
|
154
221
|
], FigureInstallKeyCapability.prototype, "id", void 0);
|
|
155
222
|
tslib_1.__decorate([
|
|
156
223
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
224
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { description: 'The domain the key is of.' }),
|
|
225
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
160
226
|
], FigureInstallKeyCapability.prototype, "domain", void 0);
|
|
227
|
+
tslib_1.__decorate([
|
|
228
|
+
(0, typeorm_1.RelationId)((g) => g.domain),
|
|
229
|
+
tslib_1.__metadata("design:type", String)
|
|
230
|
+
], FigureInstallKeyCapability.prototype, "domainId", void 0);
|
|
161
231
|
tslib_1.__decorate([
|
|
162
232
|
(0, typeorm_1.Column)(),
|
|
233
|
+
(0, type_graphql_1.Field)({ description: 'The install key (an appliance).' }),
|
|
163
234
|
tslib_1.__metadata("design:type", String)
|
|
164
235
|
], FigureInstallKeyCapability.prototype, "applianceId", void 0);
|
|
165
236
|
tslib_1.__decorate([
|
|
166
237
|
(0, typeorm_1.Column)(),
|
|
238
|
+
(0, type_graphql_1.Field)({ description: 'The provider whose module it may push.' }),
|
|
167
239
|
tslib_1.__metadata("design:type", String)
|
|
168
240
|
], FigureInstallKeyCapability.prototype, "provider", void 0);
|
|
241
|
+
tslib_1.__decorate([
|
|
242
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
243
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was made.' }),
|
|
244
|
+
tslib_1.__metadata("design:type", Date)
|
|
245
|
+
], FigureInstallKeyCapability.prototype, "createdAt", void 0);
|
|
246
|
+
tslib_1.__decorate([
|
|
247
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
248
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was last changed.' }),
|
|
249
|
+
tslib_1.__metadata("design:type", Date)
|
|
250
|
+
], FigureInstallKeyCapability.prototype, "updatedAt", void 0);
|
|
251
|
+
tslib_1.__decorate([
|
|
252
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
253
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who made it.' }),
|
|
254
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
255
|
+
], FigureInstallKeyCapability.prototype, "creator", void 0);
|
|
256
|
+
tslib_1.__decorate([
|
|
257
|
+
(0, typeorm_1.RelationId)((g) => g.creator),
|
|
258
|
+
tslib_1.__metadata("design:type", String)
|
|
259
|
+
], FigureInstallKeyCapability.prototype, "creatorId", void 0);
|
|
260
|
+
tslib_1.__decorate([
|
|
261
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
262
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it.' }),
|
|
263
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
264
|
+
], FigureInstallKeyCapability.prototype, "updater", void 0);
|
|
265
|
+
tslib_1.__decorate([
|
|
266
|
+
(0, typeorm_1.RelationId)((g) => g.updater),
|
|
267
|
+
tslib_1.__metadata("design:type", String)
|
|
268
|
+
], FigureInstallKeyCapability.prototype, "updaterId", void 0);
|
|
169
269
|
exports.FigureInstallKeyCapability = FigureInstallKeyCapability = tslib_1.__decorate([
|
|
170
|
-
(0, typeorm_1.Entity)(),
|
|
171
|
-
(0, typeorm_1.Index)('ix_figure_install_key_capability_0', (g) => [g.applianceId], { unique: true })
|
|
270
|
+
(0, typeorm_1.Entity)('figure_install_key_capabilities'),
|
|
271
|
+
(0, typeorm_1.Index)('ix_figure_install_key_capability_0', (g) => [g.applianceId], { unique: true }),
|
|
272
|
+
(0, type_graphql_1.ObjectType)({ description: 'The capability provider an install key may push.' })
|
|
172
273
|
], FigureInstallKeyCapability);
|
|
173
274
|
//# sourceMappingURL=capability-module-entity.js.map
|
|
@@ -95,13 +95,14 @@ let FigureCapabilityModuleResolver = class FigureCapabilityModuleResolver {
|
|
|
95
95
|
return (0, capability_module_store_js_1.registerCapabilityModule)(tx, { bytes: await bytesOf(file), owner: null, asker: domain, user });
|
|
96
96
|
}
|
|
97
97
|
async setCurrentFigureCapabilityModule(provider, version, context) {
|
|
98
|
-
const { tx } = context.state;
|
|
99
|
-
return (0, capability_module_store_js_1.setCurrentCapabilityModule)(tx, provider, version);
|
|
98
|
+
const { tx, user } = context.state;
|
|
99
|
+
return (0, capability_module_store_js_1.setCurrentCapabilityModule)(tx, provider, version, user);
|
|
100
100
|
}
|
|
101
101
|
/*
|
|
102
102
|
* A consuming app's push over its figure server link (ADR-0172 amendment 1, decisions 13-15): the caller is an install
|
|
103
|
-
* key's user, whose key the domain owner issued with the capability provider it may push
|
|
104
|
-
* domain's, chosen
|
|
103
|
+
* key's user, whose key the domain owner issued with the capability provider it may push -- such a key's role holds
|
|
104
|
+
* `figure-capability-push` mutation, and its grant row names the provider. The module becomes this domain's, chosen
|
|
105
|
+
* here at once.
|
|
105
106
|
*/
|
|
106
107
|
async pushFigureCapabilityModule(source, context, choices) {
|
|
107
108
|
const { domain, user, tx } = context.state;
|
|
@@ -114,7 +115,7 @@ let FigureCapabilityModuleResolver = class FigureCapabilityModuleResolver {
|
|
|
114
115
|
throw new shell_1.Refusal('figure-capability-module-too-large', { max: capability_module_store_js_1.MODULE_MAX_BYTES }, 'a capability module is at most {max} bytes.');
|
|
115
116
|
const m = await (0, capability_module_store_js_1.registerCapabilityModule)(tx, { bytes, owner: domain, asker: domain, user, provider: grant.provider });
|
|
116
117
|
if (choices)
|
|
117
|
-
await (0, capability_module_store_js_1.keepCapabilityChoices)(tx, domain, m.provider, choices);
|
|
118
|
+
await (0, capability_module_store_js_1.keepCapabilityChoices)(tx, domain, m.provider, choices, user);
|
|
118
119
|
return { provider: m.provider, version: m.version, sha256: m.sha256, capabilities: m.capabilities ?? [] };
|
|
119
120
|
}
|
|
120
121
|
};
|
|
@@ -179,7 +180,7 @@ tslib_1.__decorate([
|
|
|
179
180
|
], FigureCapabilityModuleResolver.prototype, "setCurrentFigureCapabilityModule", null);
|
|
180
181
|
tslib_1.__decorate([
|
|
181
182
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
182
|
-
(0, type_graphql_1.Directive)('@privilege(category: "figure-
|
|
183
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-capability-push", privilege: "mutation")'),
|
|
183
184
|
(0, type_graphql_1.Mutation)(returns => FigureCapabilityModuleRef, { description: "Pushes the caller app's capability module to this domain, with an install key that may push it." }),
|
|
184
185
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('source', { description: 'The module file, as text.' })),
|
|
185
186
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -61,7 +61,7 @@ export declare function registerCapabilityModule(tx: Tx, input: {
|
|
|
61
61
|
* version when only the lists changed. Refused when they break the shape or name another provider's capability.
|
|
62
62
|
* Answers whether they were written.
|
|
63
63
|
*/
|
|
64
|
-
export declare function keepCapabilityChoices(tx: Tx, domain: Domain, provider: string, choices: unknown): Promise<boolean>;
|
|
64
|
+
export declare function keepCapabilityChoices(tx: Tx, domain: Domain, provider: string, choices: unknown, user?: Actor): Promise<boolean>;
|
|
65
65
|
/**
|
|
66
66
|
* The choice lists of the providers a domain uses, by `<capability>.<setting>` (decision 21): those its own providers
|
|
67
67
|
* pushed. A system provider has none.
|
|
@@ -70,7 +70,7 @@ export declare function chosenCapabilityChoices(tx: Tx, domain: {
|
|
|
70
70
|
id: string;
|
|
71
71
|
}): Promise<FigureCapabilityChoices>;
|
|
72
72
|
/** Makes one kept version of a system provider its current one again (a step back). */
|
|
73
|
-
export declare function setCurrentCapabilityModule(tx: Tx, provider: string, version: string): Promise<FigureCapabilityModule>;
|
|
73
|
+
export declare function setCurrentCapabilityModule(tx: Tx, provider: string, version: string, user?: Actor): Promise<FigureCapabilityModule>;
|
|
74
74
|
/** Uses a provider in a domain, or stops using it (decision 5). Refused for a provider nobody registered for it. */
|
|
75
75
|
export declare function chooseProvider(tx: Tx, domain: Domain, provider: string, on: boolean, user: Actor): Promise<boolean>;
|
|
76
76
|
/** The modules a domain uses: the current version of every provider it chose. A parent's choice is not inherited. */
|
|
@@ -95,15 +95,13 @@ export declare function chosenModuleBytes(tx: Tx, domain: {
|
|
|
95
95
|
id: string;
|
|
96
96
|
}, sha256: string, files?: ThumbnailFiles): Promise<Buffer | undefined>;
|
|
97
97
|
/**
|
|
98
|
-
* Loads the modules a domain uses, for the release check
|
|
98
|
+
* Loads the modules a domain uses and answers their descriptors, for the caller to give the release check (decision 9): each file from the data folder, or from
|
|
99
99
|
* attachment-base when the folder does not have it yet. A module that does not load is left out, and the figure's
|
|
100
100
|
* capabilities of it are then not verified -- the check blocks them.
|
|
101
101
|
*/
|
|
102
102
|
export declare function prepareCapabilityModules(tx: Tx, domain: {
|
|
103
103
|
id: string;
|
|
104
104
|
}, files?: ThumbnailFiles, folder?: string): Promise<Map<string, FigureCapabilityDescriptor>>;
|
|
105
|
-
/**
|
|
106
|
-
export declare const preparedDescriptors: (domainId?: string) => ReadonlyMap<string, FigureCapabilityDescriptor>;
|
|
107
|
-
/** For tests: forget loaded and prepared modules. */
|
|
105
|
+
/** For tests: forget loaded modules. */
|
|
108
106
|
export declare function forgetCapabilityModules(): void;
|
|
109
107
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.moduleFolder = exports.MODULE_MAX_BYTES = exports.MODULE_MIMETYPE = exports.MODULE_REF_TYPE = void 0;
|
|
4
4
|
exports.useModuleFolder = useModuleFolder;
|
|
5
5
|
exports.loadModuleBytes = loadModuleBytes;
|
|
6
6
|
exports.moduleContractOf = moduleContractOf;
|
|
@@ -57,11 +57,6 @@ function useModuleFolder(folder) {
|
|
|
57
57
|
folderInUse = folder;
|
|
58
58
|
return before;
|
|
59
59
|
}
|
|
60
|
-
/*
|
|
61
|
-
* Node's own require, which loads an ES module (22.12+): taken from the built-in module so that a loader in front of
|
|
62
|
-
* this file's `require` (a test runner's) does not stand between the file and Node.
|
|
63
|
-
*/
|
|
64
|
-
const nodeRequire = process.getBuiltinModule?.('node:module')?.createRequire(__filename) ?? require;
|
|
65
60
|
/* Loaded modules by hash: the content is its hash, so a loaded one never changes. */
|
|
66
61
|
const loaded = new Map();
|
|
67
62
|
/**
|
|
@@ -84,7 +79,7 @@ function loadModuleBytes(sha256, bytes, folder) {
|
|
|
84
79
|
(0, fs_1.writeFileSync)(partial, bytes);
|
|
85
80
|
(0, fs_1.renameSync)(partial, file);
|
|
86
81
|
}
|
|
87
|
-
const module =
|
|
82
|
+
const module = (0, env_1.requireModuleFile)(file);
|
|
88
83
|
loaded.set(sha256, module);
|
|
89
84
|
return module;
|
|
90
85
|
}
|
|
@@ -169,7 +164,7 @@ async function registerCapabilityModule(tx, input, files = (0, figure_thumbnail_
|
|
|
169
164
|
});
|
|
170
165
|
}
|
|
171
166
|
for (const v of versions.filter(v => v.current))
|
|
172
|
-
await repo.save({ ...v, current: false });
|
|
167
|
+
await repo.save({ ...v, current: false, updater: byId(input.user) });
|
|
173
168
|
const saved = await repo.save({
|
|
174
169
|
domain: input.owner,
|
|
175
170
|
provider,
|
|
@@ -177,7 +172,8 @@ async function registerCapabilityModule(tx, input, files = (0, figure_thumbnail_
|
|
|
177
172
|
sha256,
|
|
178
173
|
capabilities: module.capabilities.map(d => d.name),
|
|
179
174
|
current: true,
|
|
180
|
-
creator: byId(input.user)
|
|
175
|
+
creator: byId(input.user),
|
|
176
|
+
updater: byId(input.user)
|
|
181
177
|
});
|
|
182
178
|
if (input.owner)
|
|
183
179
|
await chooseProvider(tx, input.owner, provider, true, input.user);
|
|
@@ -189,7 +185,7 @@ async function registerCapabilityModule(tx, input, files = (0, figure_thumbnail_
|
|
|
189
185
|
* version when only the lists changed. Refused when they break the shape or name another provider's capability.
|
|
190
186
|
* Answers whether they were written.
|
|
191
187
|
*/
|
|
192
|
-
async function keepCapabilityChoices(tx, domain, provider, choices) {
|
|
188
|
+
async function keepCapabilityChoices(tx, domain, provider, choices, user) {
|
|
193
189
|
const issues = (0, figure_model_1.capabilityChoicesIssues)(choices, provider);
|
|
194
190
|
if (issues.length)
|
|
195
191
|
throw new shell_1.Refusal('figure-capability-choices-invalid', { issues: issues.slice(0, 5).join(' · ') }, 'the choice lists cannot be taken: {issues}');
|
|
@@ -197,7 +193,7 @@ async function keepCapabilityChoices(tx, domain, provider, choices) {
|
|
|
197
193
|
const found = await repo.findOne({ where: { domain: { id: domain.id }, provider } });
|
|
198
194
|
if (found && (0, figure_thumbnail_store_js_1.sha256Of)(Buffer.from(JSON.stringify(found.choices ?? {}))) === (0, figure_thumbnail_store_js_1.sha256Of)(Buffer.from(JSON.stringify(choices))))
|
|
199
195
|
return false;
|
|
200
|
-
await repo.save({ ...(found ?? { domain, provider }), choices });
|
|
196
|
+
await repo.save({ ...(found ?? { domain, provider, creator: byId(user) }), choices, updater: byId(user) });
|
|
201
197
|
return true;
|
|
202
198
|
}
|
|
203
199
|
/**
|
|
@@ -210,7 +206,7 @@ async function chosenCapabilityChoices(tx, domain) {
|
|
|
210
206
|
return Object.assign({}, ...rows.filter(r => providers.has(r.provider)).map(r => r.choices ?? {}));
|
|
211
207
|
}
|
|
212
208
|
/** Makes one kept version of a system provider its current one again (a step back). */
|
|
213
|
-
async function setCurrentCapabilityModule(tx, provider, version) {
|
|
209
|
+
async function setCurrentCapabilityModule(tx, provider, version, user) {
|
|
214
210
|
const repo = tx.getRepository(capability_module_entity_js_1.FigureCapabilityModule);
|
|
215
211
|
const versions = await repo.find({ where: { provider, domain: (0, typeorm_1.IsNull)() } });
|
|
216
212
|
const target = versions.find(v => v.version === version);
|
|
@@ -218,7 +214,7 @@ async function setCurrentCapabilityModule(tx, provider, version) {
|
|
|
218
214
|
throw new shell_1.Refusal('figure-capability-module-not-found', { provider, version }, 'there is no {provider} {version}.');
|
|
219
215
|
for (const v of versions)
|
|
220
216
|
if (v.current !== (v === target))
|
|
221
|
-
await repo.save({ ...v, current: v === target });
|
|
217
|
+
await repo.save({ ...v, current: v === target, updater: byId(user) });
|
|
222
218
|
return { ...target, current: true };
|
|
223
219
|
}
|
|
224
220
|
/** Uses a provider in a domain, or stops using it (decision 5). Refused for a provider nobody registered for it. */
|
|
@@ -234,7 +230,7 @@ async function chooseProvider(tx, domain, provider, on, user) {
|
|
|
234
230
|
return true;
|
|
235
231
|
if (!(await currentOf(tx, domain, provider)))
|
|
236
232
|
throw new shell_1.Refusal('figure-capability-provider-unknown', { provider }, 'no capability module of {provider} is registered.');
|
|
237
|
-
await uses.save({ domain, provider, creator: byId(user) });
|
|
233
|
+
await uses.save({ domain, provider, creator: byId(user), updater: byId(user) });
|
|
238
234
|
return true;
|
|
239
235
|
}
|
|
240
236
|
/**
|
|
@@ -281,10 +277,8 @@ async function chosenModuleBytes(tx, domain, sha256, files = (0, figure_thumbnai
|
|
|
281
277
|
const kept = await moduleAttachmentOf(tx, sha256);
|
|
282
278
|
return kept ? Buffer.from(await files.read(kept.path)) : undefined;
|
|
283
279
|
}
|
|
284
|
-
/* The descriptors each domain's release check reads, made ready before the check (which is synchronous) runs. */
|
|
285
|
-
const prepared = new Map();
|
|
286
280
|
/**
|
|
287
|
-
* Loads the modules a domain uses, for the release check
|
|
281
|
+
* Loads the modules a domain uses and answers their descriptors, for the caller to give the release check (decision 9): each file from the data folder, or from
|
|
288
282
|
* attachment-base when the folder does not have it yet. A module that does not load is left out, and the figure's
|
|
289
283
|
* capabilities of it are then not verified -- the check blocks them.
|
|
290
284
|
*/
|
|
@@ -311,15 +305,10 @@ async function prepareCapabilityModules(tx, domain, files = (0, figure_thumbnail
|
|
|
311
305
|
console.warn(`[figure] capability module ${m.provider} ${m.version} did not load: ${e?.message ?? e}`);
|
|
312
306
|
}
|
|
313
307
|
}
|
|
314
|
-
prepared.set(domain.id, descriptors);
|
|
315
308
|
return descriptors;
|
|
316
309
|
}
|
|
317
|
-
/**
|
|
318
|
-
const preparedDescriptors = (domainId) => (domainId && prepared.get(domainId)) || new Map();
|
|
319
|
-
exports.preparedDescriptors = preparedDescriptors;
|
|
320
|
-
/** For tests: forget loaded and prepared modules. */
|
|
310
|
+
/** For tests: forget loaded modules. */
|
|
321
311
|
function forgetCapabilityModules() {
|
|
322
312
|
loaded.clear();
|
|
323
|
-
prepared.clear();
|
|
324
313
|
}
|
|
325
314
|
//# sourceMappingURL=capability-module-store.js.map
|
|
@@ -4,7 +4,15 @@ exports.capabilityFindings = capabilityFindings;
|
|
|
4
4
|
exports.capabilityReleaseCheck = capabilityReleaseCheck;
|
|
5
5
|
const figure_model_1 = require("@hatiolab/figure-model");
|
|
6
6
|
const figure_format_js_1 = require("../figure/figure-format.js");
|
|
7
|
-
|
|
7
|
+
/** Words joined as the language joins a list: "A, B and C", or "A or B". */
|
|
8
|
+
function list(lang, type, words) {
|
|
9
|
+
try {
|
|
10
|
+
return new Intl.ListFormat(lang, { type }).format(words);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return new Intl.ListFormat('en', { type }).format(words);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
8
16
|
/** The findings for a figure's consumer capabilities, by these descriptors, in these words. */
|
|
9
17
|
function capabilityFindings(asset, descriptors, say, lang = 'en') {
|
|
10
18
|
const names = (asset.document.capabilities.names ?? []).filter(figure_model_1.isFigureConsumerCapability);
|
|
@@ -26,7 +34,10 @@ function capabilityFindings(asset, descriptors, say, lang = 'en') {
|
|
|
26
34
|
};
|
|
27
35
|
}
|
|
28
36
|
if (issue.code === 'CAPABILITY_NEEDS') {
|
|
29
|
-
|
|
37
|
+
/* Said from `needs` in the reader's words: each group as "this or that", the groups as a list. The verdict's
|
|
38
|
+
`reasons` are a log's words. */
|
|
39
|
+
const word = (need) => (need === 'item' ? say('figure.gate.capability-needs.item', {}, "'Used as an item'") : label(need));
|
|
40
|
+
const needs = list(lang, 'conjunction', (issue.needs ?? []).map(group => list(lang, 'disjunction', group.map(word))));
|
|
30
41
|
return {
|
|
31
42
|
code: 'capability-needs',
|
|
32
43
|
message: say('figure.gate.capability-needs.message', { name, needs }, `The capability '${name}' needs ${needs}.`),
|
|
@@ -49,9 +60,9 @@ function capabilityFindings(asset, descriptors, say, lang = 'en') {
|
|
|
49
60
|
function capabilityReleaseCheck(input) {
|
|
50
61
|
const t = input.t;
|
|
51
62
|
const say = (key, params, english) => (t ? t(key, { ...params, defaultValue: english, interpolation: { escapeValue: false } }) : english);
|
|
52
|
-
/* The language
|
|
53
|
-
const lang =
|
|
54
|
-
return capabilityFindings(input.asset,
|
|
63
|
+
/* The reader's language (the request's), for the module's own words. */
|
|
64
|
+
const lang = input.lng || 'en';
|
|
65
|
+
return capabilityFindings(input.asset, input.capabilities ?? new Map(), say, lang);
|
|
55
66
|
}
|
|
56
67
|
(0, figure_format_js_1.registerFigureReleaseCheck)(capabilityReleaseCheck);
|
|
57
68
|
//# sourceMappingURL=capability-release-check.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FigureAsset, FigureContractChange, FigureReleaseMetrics, FigureTopView } from '@hatiolab/figure-model';
|
|
1
|
+
import type { FigureAsset, FigureCapabilityDescriptor, FigureContractChange, FigureReleaseMetrics, FigureTopView } from '@hatiolab/figure-model';
|
|
2
2
|
import type { FigureFinding } from './figure-type.js';
|
|
3
3
|
/** The version the format stamps on its own source. */
|
|
4
4
|
export declare const FIGURE_ASSET_VERSION = "figure-asset-1";
|
|
@@ -51,6 +51,13 @@ export interface FigureReleaseCheckInput {
|
|
|
51
51
|
domain?: {
|
|
52
52
|
id: string;
|
|
53
53
|
};
|
|
54
|
+
/** The reader's language, the one `t` speaks: for words a module carries per language (ADR-0172 decision 7). */
|
|
55
|
+
lng?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The descriptors of the capability providers the releasing domain uses (`prepareCapabilityModules`), given by the
|
|
58
|
+
* caller: a figure's consumer capabilities are checked by them, and are not verified when none are given.
|
|
59
|
+
*/
|
|
60
|
+
capabilities?: ReadonlyMap<string, FigureCapabilityDescriptor>;
|
|
54
61
|
}
|
|
55
62
|
/**
|
|
56
63
|
* A check an app adds to releasing (LV figure-server design G10): findings in the gate's own shape, blocking or said.
|
|
@@ -83,9 +90,13 @@ export declare function inspectSource(sourceJson?: string | null, releasedJson?:
|
|
|
83
90
|
rowType?: string,
|
|
84
91
|
/** The row's category, for an app's release checks (G10). */
|
|
85
92
|
rowCategory?: string | null,
|
|
86
|
-
/** The releasing domain, for the capability check (ADR-0172 decision 9). */
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
/** The releasing domain, for the capability check (ADR-0172 decision 9), and the reader's language. */
|
|
94
|
+
releasing?: {
|
|
95
|
+
domain?: {
|
|
96
|
+
id: string;
|
|
97
|
+
};
|
|
98
|
+
lng?: string;
|
|
99
|
+
capabilities?: ReadonlyMap<string, FigureCapabilityDescriptor>;
|
|
89
100
|
}): Inspection;
|
|
90
101
|
/**
|
|
91
102
|
* What a release records about itself (ADR-0104 decision 5): the format its asset is written in, what it measured
|
|
@@ -169,8 +169,9 @@ function inspectSource(sourceJson, releasedJson, t,
|
|
|
169
169
|
rowType,
|
|
170
170
|
/** The row's category, for an app's release checks (G10). */
|
|
171
171
|
rowCategory,
|
|
172
|
-
/** The releasing domain, for the capability check (ADR-0172 decision 9). */
|
|
173
|
-
|
|
172
|
+
/** The releasing domain, for the capability check (ADR-0172 decision 9), and the reader's language. */
|
|
173
|
+
releasing = {}) {
|
|
174
|
+
const { domain, lng, capabilities } = releasing;
|
|
174
175
|
if (!sourceJson) {
|
|
175
176
|
return { blocked: true, findings: [{ code: 'no-source', message: '저장된 정본이 없다. 저장하면 발행할 수 있다', blocking: true }] };
|
|
176
177
|
}
|
|
@@ -219,7 +220,7 @@ domain) {
|
|
|
219
220
|
findings.push(...itemFindings(asset, say));
|
|
220
221
|
if (releasedJson)
|
|
221
222
|
findings.push(...figureContractFindings(asset, releasedJson, say));
|
|
222
|
-
findings.push(...appFindings({ asset: asset, type: rowType, category: rowCategory, t, domain }));
|
|
223
|
+
findings.push(...appFindings({ asset: asset, type: rowType, category: rowCategory, t, domain, lng, capabilities }));
|
|
223
224
|
return { blocked: findings.some(finding => finding.blocking), findings };
|
|
224
225
|
}
|
|
225
226
|
const PLANE_ENGLISH = {
|
|
@@ -340,8 +340,8 @@ let FigureMutation = class FigureMutation {
|
|
|
340
340
|
.orderBy('history.version', 'DESC')
|
|
341
341
|
.limit(1)
|
|
342
342
|
.getOne();
|
|
343
|
-
await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, context.state.domain);
|
|
344
|
-
const inspection = (0, figure_format_js_1.inspectSource)(figure.source, released?.source, context.t, figure.type, figure.category, context.state.domain);
|
|
343
|
+
const capabilities = await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, context.state.domain);
|
|
344
|
+
const inspection = (0, figure_format_js_1.inspectSource)(figure.source, released?.source, context.t, figure.type, figure.category, { domain: context.state.domain, lng: context.lng, capabilities });
|
|
345
345
|
if (inspection.blocked) {
|
|
346
346
|
const reasons = inspection.findings
|
|
347
347
|
.filter(finding => finding.blocking)
|
|
@@ -198,8 +198,8 @@ let FigureQuery = class FigureQuery {
|
|
|
198
198
|
.orderBy('history.version', 'DESC')
|
|
199
199
|
.limit(1)
|
|
200
200
|
.getOne();
|
|
201
|
-
await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, context.state.domain);
|
|
202
|
-
return (0, figure_format_js_1.inspectSource)(figure.source, released?.source, context.t, figure.type, figure.category, context.state.domain);
|
|
201
|
+
const capabilities = await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, context.state.domain);
|
|
202
|
+
return (0, figure_format_js_1.inspectSource)(figure.source, released?.source, context.t, figure.type, figure.category, { domain: context.state.domain, lng: context.lng, capabilities });
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
205
|
* The same judgement for a source that has not been saved — what the modeller shows **while** the author edits.
|
|
@@ -211,9 +211,9 @@ let FigureQuery = class FigureQuery {
|
|
|
211
211
|
*/
|
|
212
212
|
async inspectFigureDraft(source, context, id) {
|
|
213
213
|
const { domain } = context.state;
|
|
214
|
-
await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, domain);
|
|
214
|
+
const capabilities = await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, domain);
|
|
215
215
|
if (!id)
|
|
216
|
-
return (0, figure_format_js_1.inspectSource)(source, null, context.t, undefined, undefined, domain);
|
|
216
|
+
return (0, figure_format_js_1.inspectSource)(source, null, context.t, undefined, undefined, { domain, lng: context.lng, capabilities });
|
|
217
217
|
const figure = await (0, shell_1.getRepository)(figure_js_1.Figure).findOne({
|
|
218
218
|
where: { domain: { id: (0, typeorm_1.In)([domain.id, domain.parentId].filter(Boolean)) }, id },
|
|
219
219
|
select: { id: true, type: true, category: true }
|
|
@@ -226,7 +226,7 @@ let FigureQuery = class FigureQuery {
|
|
|
226
226
|
.orderBy('history.version', 'DESC')
|
|
227
227
|
.limit(1)
|
|
228
228
|
.getOne();
|
|
229
|
-
return (0, figure_format_js_1.inspectSource)(source, released?.source, context.t, figure.type, figure.category, domain);
|
|
229
|
+
return (0, figure_format_js_1.inspectSource)(source, released?.source, context.t, figure.type, figure.category, { domain, lng: context.lng, capabilities });
|
|
230
230
|
}
|
|
231
231
|
/** The categories this server allows (G5), or null when a category is free text: the modeller offers them to choose from. */
|
|
232
232
|
async figureCategories() {
|
|
@@ -429,9 +429,9 @@ function figureToolSpecs() {
|
|
|
429
429
|
return missingFigureTarget();
|
|
430
430
|
const current = sourceForTool(row, ctx?.host);
|
|
431
431
|
const { inspectSource, getRepository } = getDeps();
|
|
432
|
-
await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository }, { id: domainId });
|
|
432
|
+
const capabilities = await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository }, { id: domainId });
|
|
433
433
|
/* Inspected whole, here; only what the model is told is held to its budget. */
|
|
434
|
-
return { ...findingsWithinBudget(inspectSource(current.source ? JSON.stringify(current.source) : null, null, undefined, row.type, row.category, { id: domainId })), draft: current.draft };
|
|
434
|
+
return { ...findingsWithinBudget(inspectSource(current.source ? JSON.stringify(current.source) : null, null, undefined, row.type, row.category, { domain: { id: domainId }, capabilities })), draft: current.draft };
|
|
435
435
|
}
|
|
436
436
|
},
|
|
437
437
|
{
|
|
@@ -5,11 +5,11 @@ export * from './figure/figure-history.js';
|
|
|
5
5
|
export * from './figure-recipe/figure-recipe-type.js';
|
|
6
6
|
export { recipeTemplates, inLanguage, RECIPE_DIR } from './figure-recipe/figure-recipe-templates.js';
|
|
7
7
|
import { FigureInstallKeyResolver } from './install-key/figure-install-key.js';
|
|
8
|
-
import {
|
|
8
|
+
import { FigureCapabilityUse } from './capability-module/capability-module-entity.js';
|
|
9
9
|
import { FigureCapabilityModuleResolver } from './capability-module/capability-module-resolver.js';
|
|
10
10
|
import './capability-module/capability-release-check.js';
|
|
11
11
|
export * from './install-key/figure-install-key.js';
|
|
12
|
-
export declare const entities: (typeof import("./figure/figure.js").Figure | typeof import("./figure/figure-history.js").FigureHistory | typeof FigureCapabilityUse | typeof
|
|
12
|
+
export declare const entities: (typeof import("./figure/figure.js").Figure | typeof import("./figure/figure-history.js").FigureHistory | typeof FigureCapabilityUse | typeof import("./figure/figure-replaced-draft.js").FigureReplacedDraft | typeof import("./figure/figure-proposal-record.js").FigureProposalRecord | typeof import("./figure/figure-namespace-entity.js").FigureNamespace)[];
|
|
13
13
|
export declare const subscribers: typeof import("./figure/event-subscriber.js").FigureHistoryEntitySubscriber[];
|
|
14
14
|
export declare const schema: {
|
|
15
15
|
resolverClasses: (typeof import("./figure/figure-query.js").FigureQuery | typeof import("./figure/figure-mutation.js").FigureMutation | typeof import("./figure/figure-namespace-resolver.js").FigureNamespaceResolver | typeof import("./figure-recipe/figure-recipe-resolver.js").FigureRecipeTemplateQuery | typeof FigureInstallKeyResolver | typeof FigureCapabilityModuleResolver)[];
|
|
@@ -4,6 +4,8 @@ import { Role, User } from '@things-factory/auth-base';
|
|
|
4
4
|
export declare const INSTALL_KEY_MODEL = "figure-install-key";
|
|
5
5
|
/** The role every install key's user holds, made the first time a key is issued. */
|
|
6
6
|
export declare const INSTALL_KEY_ROLE = "figure-install-reader";
|
|
7
|
+
/** The role a key that may push a capability module holds instead. */
|
|
8
|
+
export declare const INSTALL_KEY_PUSHER_ROLE = "figure-install-pusher";
|
|
7
9
|
export declare class FigureInstallKey {
|
|
8
10
|
id: string;
|
|
9
11
|
name: string;
|
|
@@ -18,6 +20,13 @@ export declare class IssuedFigureInstallKey extends FigureInstallKey {
|
|
|
18
20
|
export declare function installReaderRole(tx: EntityManager, domain: {
|
|
19
21
|
id: string;
|
|
20
22
|
}, user: User): Promise<Role>;
|
|
23
|
+
/**
|
|
24
|
+
* The role a key that may push a capability module holds (ADR-0172 decision 14): reading released figures, and the
|
|
25
|
+
* `figure-capability-push` mutation its push asks. Which provider it pushes is its grant row's. Made once per domain.
|
|
26
|
+
*/
|
|
27
|
+
export declare function installPusherRole(tx: EntityManager, domain: {
|
|
28
|
+
id: string;
|
|
29
|
+
}, user: User): Promise<Role>;
|
|
21
30
|
export declare function installKeysOf(tx: EntityManager, domain: {
|
|
22
31
|
id: string;
|
|
23
32
|
}): Promise<FigureInstallKey[]>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FigureInstallKeyResolver = exports.IssuedFigureInstallKey = exports.FigureInstallKey = exports.INSTALL_KEY_ROLE = exports.INSTALL_KEY_MODEL = void 0;
|
|
3
|
+
exports.FigureInstallKeyResolver = exports.IssuedFigureInstallKey = exports.FigureInstallKey = exports.INSTALL_KEY_PUSHER_ROLE = exports.INSTALL_KEY_ROLE = exports.INSTALL_KEY_MODEL = void 0;
|
|
4
4
|
exports.installReaderRole = installReaderRole;
|
|
5
|
+
exports.installPusherRole = installPusherRole;
|
|
5
6
|
exports.installKeysOf = installKeysOf;
|
|
6
7
|
exports.issueInstallKey = issueInstallKey;
|
|
7
8
|
exports.revokeInstallKey = revokeInstallKey;
|
|
@@ -22,6 +23,8 @@ const capability_module_entity_js_1 = require("../capability-module/capability-m
|
|
|
22
23
|
exports.INSTALL_KEY_MODEL = 'figure-install-key';
|
|
23
24
|
/** The role every install key's user holds, made the first time a key is issued. */
|
|
24
25
|
exports.INSTALL_KEY_ROLE = 'figure-install-reader';
|
|
26
|
+
/** The role a key that may push a capability module holds instead. */
|
|
27
|
+
exports.INSTALL_KEY_PUSHER_ROLE = 'figure-install-pusher';
|
|
25
28
|
let FigureInstallKey = class FigureInstallKey {
|
|
26
29
|
};
|
|
27
30
|
exports.FigureInstallKey = FigureInstallKey;
|
|
@@ -60,21 +63,31 @@ exports.IssuedFigureInstallKey = IssuedFigureInstallKey = tslib_1.__decorate([
|
|
|
60
63
|
], IssuedFigureInstallKey);
|
|
61
64
|
/** The role install keys hold: `figure-published` query only. Made once per domain. */
|
|
62
65
|
async function installReaderRole(tx, domain, user) {
|
|
66
|
+
return await installKeyRole(tx, domain, user, exports.INSTALL_KEY_ROLE, 'Board servers installing figures (ADR-0114): reads released figures only', [['figure-published', 'query']]);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The role a key that may push a capability module holds (ADR-0172 decision 14): reading released figures, and the
|
|
70
|
+
* `figure-capability-push` mutation its push asks. Which provider it pushes is its grant row's. Made once per domain.
|
|
71
|
+
*/
|
|
72
|
+
async function installPusherRole(tx, domain, user) {
|
|
73
|
+
return await installKeyRole(tx, domain, user, exports.INSTALL_KEY_PUSHER_ROLE, "Consuming app servers (ADR-0172): read released figures and push their capability module", [
|
|
74
|
+
['figure-published', 'query'],
|
|
75
|
+
['figure-capability-push', 'mutation']
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
async function installKeyRole(tx, domain, user, name, description, grants) {
|
|
63
79
|
const roles = tx.getRepository(auth_base_1.Role);
|
|
64
|
-
const found = await roles.findOne({ where: { domain: { id: domain.id }, name
|
|
80
|
+
const found = await roles.findOne({ where: { domain: { id: domain.id }, name }, relations: { privileges: true } });
|
|
65
81
|
if (found)
|
|
66
82
|
return found;
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
creator: user,
|
|
76
|
-
updater: user
|
|
77
|
-
});
|
|
83
|
+
const privileges = [];
|
|
84
|
+
for (const [category, privilege] of grants) {
|
|
85
|
+
const one = await tx.getRepository(auth_base_1.Privilege).findOne({ where: { category, name: privilege } });
|
|
86
|
+
if (!one)
|
|
87
|
+
throw new shell_1.Refusal('figure-install-key-privilege-missing', { category, privilege }, 'This server has no {category} {privilege} privilege for install keys.');
|
|
88
|
+
privileges.push(one);
|
|
89
|
+
}
|
|
90
|
+
return await roles.save({ domain, name, description, privileges, creator: user, updater: user });
|
|
78
91
|
}
|
|
79
92
|
const keyOf = (appliance) => ({
|
|
80
93
|
id: appliance.id,
|
|
@@ -110,12 +123,12 @@ capabilityProvider) {
|
|
|
110
123
|
model: exports.INSTALL_KEY_MODEL,
|
|
111
124
|
description: 'Board server install key (ADR-0114)'
|
|
112
125
|
});
|
|
113
|
-
const role = await installReaderRole(tx, domain, user);
|
|
126
|
+
const role = provider ? await installPusherRole(tx, domain, user) : await installReaderRole(tx, domain, user);
|
|
114
127
|
const shadow = await tx.getRepository(auth_base_1.User).findOne({ where: { reference: appliance.id, userType: 'appliance' }, relations: { roles: true } });
|
|
115
128
|
shadow.roles = [role];
|
|
116
129
|
await tx.getRepository(auth_base_1.User).save(shadow);
|
|
117
130
|
if (provider)
|
|
118
|
-
await tx.getRepository(capability_module_entity_js_1.FigureInstallKeyCapability).save({ domain, applianceId: appliance.id, provider });
|
|
131
|
+
await tx.getRepository(capability_module_entity_js_1.FigureInstallKeyCapability).save({ domain, applianceId: appliance.id, provider, creator: user, updater: user });
|
|
119
132
|
const issued = await (0, auth_base_1.issueApplianceSecret)(tx, domain, user, appliance.id);
|
|
120
133
|
return { ...keyOf({ ...issued, updater: user }), ...(provider ? { capabilityProvider: provider } : {}), token: issued.accessToken };
|
|
121
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/figure-service",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.296",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"@things-factory:registry": "https://registry.npmjs.org"
|
|
@@ -38,24 +38,28 @@
|
|
|
38
38
|
"clean": "npm run clean:server",
|
|
39
39
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration",
|
|
40
40
|
"build:templates": "node scripts/build-templates.mts",
|
|
41
|
-
"test:templates": "node --test scripts/templates.test.mts"
|
|
41
|
+
"test:templates": "node --test scripts/templates.test.mts",
|
|
42
|
+
"test": "node --test test/conventions.test.mjs"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"@hatiolab/figure-model": "^0.12.16",
|
|
45
46
|
"@operato/typeorm-history": "^10.0.0",
|
|
46
|
-
"@things-factory/ai-client-base": "^10.1.
|
|
47
|
-
"@things-factory/attachment-base": "^10.1.
|
|
48
|
-
"@things-factory/auth-base": "^10.1.
|
|
49
|
-
"@things-factory/env": "^10.1.
|
|
50
|
-
"@things-factory/setting-base": "^10.1.
|
|
51
|
-
"@things-factory/shell": "^10.1.
|
|
47
|
+
"@things-factory/ai-client-base": "^10.1.296",
|
|
48
|
+
"@things-factory/attachment-base": "^10.1.296",
|
|
49
|
+
"@things-factory/auth-base": "^10.1.296",
|
|
50
|
+
"@things-factory/env": "^10.1.296",
|
|
51
|
+
"@things-factory/setting-base": "^10.1.296",
|
|
52
|
+
"@things-factory/shell": "^10.1.296",
|
|
52
53
|
"graphql-scalars": "^1.22.4",
|
|
53
54
|
"graphql-upload": "^15.0.2",
|
|
54
55
|
"jszip": "^3.10.1",
|
|
55
56
|
"koa-router": "^7.4.0"
|
|
56
57
|
},
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "0cd4b6207e4dfc557157f86630d82aed423b1dde",
|
|
58
59
|
"engines": {
|
|
59
60
|
"node": ">=22.12"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@things-factory/conventions": "^10.1.281"
|
|
60
64
|
}
|
|
61
65
|
}
|
package/translations/en.json
CHANGED
|
@@ -204,16 +204,16 @@
|
|
|
204
204
|
"error.figure-install-key-name-missing": "Name the key - what board server it is for.",
|
|
205
205
|
"error.figure-install-key-name-too-long": "A key name is at most {max} characters.",
|
|
206
206
|
"error.figure-install-key-not-found": "There is no such install key.",
|
|
207
|
-
"error.figure-install-key-privilege-missing": "This server has no privilege
|
|
207
|
+
"error.figure-install-key-privilege-missing": "This server has no {category} {privilege} privilege for install keys.",
|
|
208
208
|
"figure.progress.propose.draft": "Writing the figure (request {call})…",
|
|
209
209
|
"figure.progress.propose.retry": "The kernel refused it: asking again with the reasons (request {call})…",
|
|
210
210
|
"figure.progress.propose.revise": "Looking at what was measured and revising (request {call})…",
|
|
211
211
|
"figure.progress.propose.recover": "The revision was refused: asking again with the reasons (request {call})…",
|
|
212
|
-
"figure.gate.capability-language": "en",
|
|
213
212
|
"figure.gate.capability-unverified.message": "The capability '{name}' is of the provider {provider}, which this domain does not use.",
|
|
214
213
|
"figure.gate.capability-unverified.why": "A release promises only what was checked. A capability this domain cannot check is not released.",
|
|
215
214
|
"figure.gate.capability-unverified.how": "Use {provider} in Settings > capability providers, or turn the capability off in the capability tab.",
|
|
216
215
|
"figure.gate.capability-needs.message": "The capability '{name}' needs {needs}.",
|
|
216
|
+
"figure.gate.capability-needs.item": "'Used as an item'",
|
|
217
217
|
"figure.gate.capability-needs.how": "Turn on {needs} in the capability tab, or turn the capability off.",
|
|
218
218
|
"figure.gate.capability-settings.message": "The settings of '{name}' cannot be applied. {reasons}",
|
|
219
219
|
"figure.gate.capability-settings.how": "Fix the settings in the capability tab.",
|
package/translations/es.json
CHANGED
|
@@ -204,12 +204,12 @@
|
|
|
204
204
|
"error.figure-install-key-name-missing": "Indique el nombre de la clave: el servidor de tableros que la usará.",
|
|
205
205
|
"error.figure-install-key-name-too-long": "El nombre de la clave tiene como máximo {max} caracteres.",
|
|
206
206
|
"error.figure-install-key-not-found": "No existe esa clave de instalación.",
|
|
207
|
-
"error.figure-install-key-privilege-missing": "Este servidor no tiene el
|
|
208
|
-
"figure.gate.capability-language": "es",
|
|
207
|
+
"error.figure-install-key-privilege-missing": "Este servidor no tiene el privilegio {category} {privilege} para las claves de instalación.",
|
|
209
208
|
"figure.gate.capability-unverified.message": "The capability '{name}' is of the provider {provider}, which this domain does not use.",
|
|
210
209
|
"figure.gate.capability-unverified.why": "A release promises only what was checked. A capability this domain cannot check is not released.",
|
|
211
210
|
"figure.gate.capability-unverified.how": "Use {provider} in Settings > capability providers, or turn the capability off in the capability tab.",
|
|
212
211
|
"figure.gate.capability-needs.message": "The capability '{name}' needs {needs}.",
|
|
212
|
+
"figure.gate.capability-needs.item": "'Se usa como artículo'",
|
|
213
213
|
"figure.gate.capability-needs.how": "Turn on {needs} in the capability tab, or turn the capability off.",
|
|
214
214
|
"figure.gate.capability-settings.message": "The settings of '{name}' cannot be applied. {reasons}",
|
|
215
215
|
"figure.gate.capability-settings.how": "Fix the settings in the capability tab.",
|
package/translations/ja.json
CHANGED
|
@@ -204,12 +204,12 @@
|
|
|
204
204
|
"error.figure-install-key-name-missing": "キー名を入力してください。このキーを使うボードサーバー名を入力します。",
|
|
205
205
|
"error.figure-install-key-name-too-long": "キー名は {max} 文字以内で入力してください。",
|
|
206
206
|
"error.figure-install-key-not-found": "該当するインストールキーがありません。",
|
|
207
|
-
"error.figure-install-key-privilege-missing": "
|
|
208
|
-
"figure.gate.capability-language": "ja",
|
|
207
|
+
"error.figure-install-key-privilege-missing": "このサーバーにはインストールキーに与える {category} {privilege} 権限がありません。",
|
|
209
208
|
"figure.gate.capability-unverified.message": "The capability '{name}' is of the provider {provider}, which this domain does not use.",
|
|
210
209
|
"figure.gate.capability-unverified.why": "A release promises only what was checked. A capability this domain cannot check is not released.",
|
|
211
210
|
"figure.gate.capability-unverified.how": "Use {provider} in Settings > capability providers, or turn the capability off in the capability tab.",
|
|
212
211
|
"figure.gate.capability-needs.message": "The capability '{name}' needs {needs}.",
|
|
212
|
+
"figure.gate.capability-needs.item": "「アイテムとして使う」",
|
|
213
213
|
"figure.gate.capability-needs.how": "Turn on {needs} in the capability tab, or turn the capability off.",
|
|
214
214
|
"figure.gate.capability-settings.message": "The settings of '{name}' cannot be applied. {reasons}",
|
|
215
215
|
"figure.gate.capability-settings.how": "Fix the settings in the capability tab.",
|
package/translations/ko.json
CHANGED
|
@@ -204,16 +204,16 @@
|
|
|
204
204
|
"error.figure-install-key-name-missing": "키 이름을 입력하세요. 이 키를 사용할 보드 서버를 적으면 됩니다.",
|
|
205
205
|
"error.figure-install-key-name-too-long": "키 이름은 {max}자 이하로 입력하세요.",
|
|
206
206
|
"error.figure-install-key-not-found": "해당 설치 키가 없습니다.",
|
|
207
|
-
"error.figure-install-key-privilege-missing": "이
|
|
207
|
+
"error.figure-install-key-privilege-missing": "이 서버에는 설치 키에 줄 {category} {privilege} 권한이 없습니다.",
|
|
208
208
|
"figure.progress.propose.draft": "피규어를 쓰는 중 ({call}번째 요청)…",
|
|
209
209
|
"figure.progress.propose.retry": "커널이 거절해 이유를 붙여 다시 요청하는 중 ({call}번째 요청)…",
|
|
210
210
|
"figure.progress.propose.revise": "만든 모델을 잰 결과를 보고 고치는 중 ({call}번째 요청)…",
|
|
211
211
|
"figure.progress.propose.recover": "고친 답이 거절되어 이유를 붙여 다시 요청하는 중 ({call}번째 요청)…",
|
|
212
|
-
"figure.gate.capability-language": "ko",
|
|
213
212
|
"figure.gate.capability-unverified.message": "'{name}' 능력은 {provider} 제공자의 능력이며, 이 사업장은 {provider} 제공자를 사용하지 않습니다.",
|
|
214
213
|
"figure.gate.capability-unverified.why": "발행은 검사를 통과한 내용만 약속합니다. 이 사업장에서 검사할 수 없는 능력은 발행하지 않습니다.",
|
|
215
214
|
"figure.gate.capability-unverified.how": "설정 > 능력 제공자에서 {provider}을(를) 사용으로 바꾸거나, 능력 탭에서 이 능력을 끄세요.",
|
|
216
215
|
"figure.gate.capability-needs.message": "'{name}' 능력에는 {needs}이(가) 필요합니다.",
|
|
216
|
+
"figure.gate.capability-needs.item": "「아이템으로 쓴다」",
|
|
217
217
|
"figure.gate.capability-needs.how": "능력 탭에서 {needs}을(를) 켜거나 이 능력을 끄세요.",
|
|
218
218
|
"figure.gate.capability-settings.message": "'{name}' 능력의 설정을 적용할 수 없습니다. {reasons}",
|
|
219
219
|
"figure.gate.capability-settings.how": "능력 탭에서 설정을 고치세요.",
|
package/translations/ms.json
CHANGED
|
@@ -204,12 +204,12 @@
|
|
|
204
204
|
"error.figure-install-key-name-missing": "Namakan kunci - pelayan papan yang akan menggunakannya.",
|
|
205
205
|
"error.figure-install-key-name-too-long": "Nama kunci paling banyak {max} aksara.",
|
|
206
206
|
"error.figure-install-key-not-found": "Tiada kunci pemasangan sedemikian.",
|
|
207
|
-
"error.figure-install-key-privilege-missing": "Pelayan ini tiada keistimewaan untuk
|
|
208
|
-
"figure.gate.capability-language": "ms",
|
|
207
|
+
"error.figure-install-key-privilege-missing": "Pelayan ini tiada keistimewaan {category} {privilege} untuk kunci pemasangan.",
|
|
209
208
|
"figure.gate.capability-unverified.message": "The capability '{name}' is of the provider {provider}, which this domain does not use.",
|
|
210
209
|
"figure.gate.capability-unverified.why": "A release promises only what was checked. A capability this domain cannot check is not released.",
|
|
211
210
|
"figure.gate.capability-unverified.how": "Use {provider} in Settings > capability providers, or turn the capability off in the capability tab.",
|
|
212
211
|
"figure.gate.capability-needs.message": "The capability '{name}' needs {needs}.",
|
|
212
|
+
"figure.gate.capability-needs.item": "'Digunakan sebagai item'",
|
|
213
213
|
"figure.gate.capability-needs.how": "Turn on {needs} in the capability tab, or turn the capability off.",
|
|
214
214
|
"figure.gate.capability-settings.message": "The settings of '{name}' cannot be applied. {reasons}",
|
|
215
215
|
"figure.gate.capability-settings.how": "Fix the settings in the capability tab.",
|
package/translations/zh.json
CHANGED
|
@@ -204,12 +204,12 @@
|
|
|
204
204
|
"error.figure-install-key-name-missing": "请输入密钥名称,即使用该密钥的看板服务器。",
|
|
205
205
|
"error.figure-install-key-name-too-long": "密钥名称最多 {max} 个字符。",
|
|
206
206
|
"error.figure-install-key-not-found": "没有该安装密钥。",
|
|
207
|
-
"error.figure-install-key-privilege-missing": "
|
|
208
|
-
"figure.gate.capability-language": "zh",
|
|
207
|
+
"error.figure-install-key-privilege-missing": "此服务器没有可授予安装密钥的 {category} {privilege} 权限。",
|
|
209
208
|
"figure.gate.capability-unverified.message": "The capability '{name}' is of the provider {provider}, which this domain does not use.",
|
|
210
209
|
"figure.gate.capability-unverified.why": "A release promises only what was checked. A capability this domain cannot check is not released.",
|
|
211
210
|
"figure.gate.capability-unverified.how": "Use {provider} in Settings > capability providers, or turn the capability off in the capability tab.",
|
|
212
211
|
"figure.gate.capability-needs.message": "The capability '{name}' needs {needs}.",
|
|
212
|
+
"figure.gate.capability-needs.item": "「用作物品」",
|
|
213
213
|
"figure.gate.capability-needs.how": "Turn on {needs} in the capability tab, or turn the capability off.",
|
|
214
214
|
"figure.gate.capability-settings.message": "The settings of '{name}' cannot be applied. {reasons}",
|
|
215
215
|
"figure.gate.capability-settings.how": "Fix the settings in the capability tab.",
|