@mdbase-dev/connect 0.1.0-beta.43 → 0.1.0-beta.45
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/application-session.d.ts +1 -0
- package/dist/application-session.js +45 -10
- package/dist/browser/integrity.json +1 -1
- package/dist/browser/mdbase-connect.min.js +2 -2
- package/dist/browser/mdbase-connect.min.js.sha384 +1 -1
- package/dist/collection-client.js +2 -1
- package/dist/operation-types.d.ts +2 -0
- package/package.json +2 -2
|
@@ -104,6 +104,7 @@ export declare class MdbaseApplicationSession<Frontmatter extends JsonObject = J
|
|
|
104
104
|
private base;
|
|
105
105
|
private stopBase?;
|
|
106
106
|
private setupAssessment;
|
|
107
|
+
private setupTypePackAdoptions;
|
|
107
108
|
private verificationGeneration;
|
|
108
109
|
private lifecycleGeneration;
|
|
109
110
|
private startOperation;
|
|
@@ -35,6 +35,7 @@ export class MdbaseApplicationSession {
|
|
|
35
35
|
base = null;
|
|
36
36
|
stopBase;
|
|
37
37
|
setupAssessment = null;
|
|
38
|
+
setupTypePackAdoptions = null;
|
|
38
39
|
verificationGeneration = 0;
|
|
39
40
|
lifecycleGeneration = 0;
|
|
40
41
|
startOperation = null;
|
|
@@ -108,10 +109,6 @@ export class MdbaseApplicationSession {
|
|
|
108
109
|
operations: operationsForSession(capabilities)
|
|
109
110
|
});
|
|
110
111
|
this.base = base;
|
|
111
|
-
this.stopBase = base.subscribe(() => {
|
|
112
|
-
if (this.base === base)
|
|
113
|
-
void this.refresh();
|
|
114
|
-
});
|
|
115
112
|
try {
|
|
116
113
|
const started = await base.start(options);
|
|
117
114
|
if (!started.ok) {
|
|
@@ -121,6 +118,10 @@ export class MdbaseApplicationSession {
|
|
|
121
118
|
if (generation !== this.lifecycleGeneration || options.signal?.aborted) {
|
|
122
119
|
throw requestAbortReason(options.signal ?? new AbortController().signal);
|
|
123
120
|
}
|
|
121
|
+
this.stopBase = base.subscribe(() => {
|
|
122
|
+
if (this.base === base)
|
|
123
|
+
void this.refresh();
|
|
124
|
+
});
|
|
124
125
|
await this.refresh(true, options);
|
|
125
126
|
if (generation !== this.lifecycleGeneration || options.signal?.aborted) {
|
|
126
127
|
throw requestAbortReason(options.signal ?? new AbortController().signal);
|
|
@@ -142,6 +143,7 @@ export class MdbaseApplicationSession {
|
|
|
142
143
|
this.application = null;
|
|
143
144
|
this.manifest = null;
|
|
144
145
|
this.setupAssessment = null;
|
|
146
|
+
this.setupTypePackAdoptions = null;
|
|
145
147
|
this.snapshot = { status: "opening", connections: [] };
|
|
146
148
|
this.listeners.clear();
|
|
147
149
|
}
|
|
@@ -218,7 +220,7 @@ export class MdbaseApplicationSession {
|
|
|
218
220
|
}
|
|
219
221
|
const assessment = this.setupAssessment;
|
|
220
222
|
const input = {
|
|
221
|
-
...this.collectionSetupInput(),
|
|
223
|
+
...this.collectionSetupInput(this.setupTypePackAdoptions ?? undefined),
|
|
222
224
|
expectedAssessmentDigest: assessment.assessmentDigest,
|
|
223
225
|
expectedCollectionRevision: assessment.collectionRevision,
|
|
224
226
|
expectedProvisionDigest: assessment.provisionDigest,
|
|
@@ -233,6 +235,7 @@ export class MdbaseApplicationSession {
|
|
|
233
235
|
if (!applied.ok)
|
|
234
236
|
return applied;
|
|
235
237
|
this.setupAssessment = null;
|
|
238
|
+
this.setupTypePackAdoptions = null;
|
|
236
239
|
await this.verifySetup(this.context(connection), ++this.verificationGeneration, requestOptions);
|
|
237
240
|
return connectSuccess(this.snapshot);
|
|
238
241
|
}
|
|
@@ -247,6 +250,7 @@ export class MdbaseApplicationSession {
|
|
|
247
250
|
this.verificationGeneration += 1;
|
|
248
251
|
const generation = this.verificationGeneration;
|
|
249
252
|
this.setupAssessment = null;
|
|
253
|
+
this.setupTypePackAdoptions = null;
|
|
250
254
|
if (current.status === "unselected") {
|
|
251
255
|
this.publish({ status: "unselected", connections: current.connections });
|
|
252
256
|
return;
|
|
@@ -282,15 +286,31 @@ export class MdbaseApplicationSession {
|
|
|
282
286
|
const manifest = this.requireManifest();
|
|
283
287
|
if (!connection || connection.collectionId !== context.collectionId)
|
|
284
288
|
return;
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
289
|
+
const initialInput = this.collectionSetupInput();
|
|
290
|
+
let outcome = options
|
|
291
|
+
? await connection.assessCollectionSetup(initialInput, options)
|
|
292
|
+
: await connection.assessCollectionSetup(initialInput);
|
|
288
293
|
if (generation !== this.verificationGeneration)
|
|
289
294
|
return;
|
|
290
295
|
if (!outcome.ok) {
|
|
291
296
|
this.publish({ status: "blocked", problem: outcome.problem, ...context });
|
|
292
297
|
return;
|
|
293
298
|
}
|
|
299
|
+
if (!outcome.value.applicable) {
|
|
300
|
+
const adoptions = reviewableTypePackAdoptions(outcome.value);
|
|
301
|
+
if (Object.keys(adoptions).length > 0) {
|
|
302
|
+
outcome = options
|
|
303
|
+
? await connection.assessCollectionSetup(this.collectionSetupInput(adoptions), options)
|
|
304
|
+
: await connection.assessCollectionSetup(this.collectionSetupInput(adoptions));
|
|
305
|
+
if (generation !== this.verificationGeneration)
|
|
306
|
+
return;
|
|
307
|
+
if (!outcome.ok) {
|
|
308
|
+
this.publish({ status: "blocked", problem: outcome.problem, ...context });
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
this.setupTypePackAdoptions = adoptions;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
294
314
|
if (generation !== this.verificationGeneration)
|
|
295
315
|
return;
|
|
296
316
|
if (outcome.value.status !== "current") {
|
|
@@ -306,7 +326,7 @@ export class MdbaseApplicationSession {
|
|
|
306
326
|
this.verificationStore.write(verificationKey(manifest, context.collectionId), verificationValue(manifest));
|
|
307
327
|
this.publish({ status: "ready", verification: "verified", ...context });
|
|
308
328
|
}
|
|
309
|
-
collectionSetupInput() {
|
|
329
|
+
collectionSetupInput(typePackAdoptions) {
|
|
310
330
|
const manifest = this.requireManifest();
|
|
311
331
|
const application = this.requireApplication();
|
|
312
332
|
return {
|
|
@@ -318,7 +338,8 @@ export class MdbaseApplicationSession {
|
|
|
318
338
|
provisions: {
|
|
319
339
|
configuration: manifest.provisions?.configuration ?? [],
|
|
320
340
|
typePacks: manifest.provisions?.type_packs ?? []
|
|
321
|
-
}
|
|
341
|
+
},
|
|
342
|
+
...(typePackAdoptions ? { typePackAdoptions } : {})
|
|
322
343
|
};
|
|
323
344
|
}
|
|
324
345
|
context(connection) {
|
|
@@ -404,6 +425,20 @@ function collectionSetupUpdate(assessment, provisions) {
|
|
|
404
425
|
reason
|
|
405
426
|
};
|
|
406
427
|
}
|
|
428
|
+
function reviewableTypePackAdoptions(assessment) {
|
|
429
|
+
const adoptions = {};
|
|
430
|
+
for (const pack of assessment.typePacks) {
|
|
431
|
+
const resources = Object.fromEntries(pack.resources
|
|
432
|
+
.filter((resource) => resource.action === "conflict"
|
|
433
|
+
&& resource.mode === "managed"
|
|
434
|
+
&& resource.currentDigest !== undefined
|
|
435
|
+
&& resource.installedDigest === undefined)
|
|
436
|
+
.map((resource) => [resource.target, resource.currentDigest]));
|
|
437
|
+
if (Object.keys(resources).length > 0)
|
|
438
|
+
adoptions[pack.desired.id] = resources;
|
|
439
|
+
}
|
|
440
|
+
return adoptions;
|
|
441
|
+
}
|
|
407
442
|
function verificationKey(manifest, collectionId) {
|
|
408
443
|
return `mdbase-application-session:v1:${manifest.id}:${collectionId}`;
|
|
409
444
|
}
|