@solana-mobile/dapp-store-publishing-tools 0.16.0 → 1.0.0

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.
Files changed (53) hide show
  1. package/lib/CoreUtils.js +0 -3
  2. package/lib/index.js +1 -0
  3. package/lib/portal/attestation.js +189 -0
  4. package/lib/portal/compat.js +3 -0
  5. package/lib/portal/index.js +5 -0
  6. package/lib/portal/signer.js +432 -0
  7. package/lib/portal/types.js +1 -0
  8. package/lib/portal/workflow/contracts.js +1 -0
  9. package/lib/portal/workflow/execution.js +493 -0
  10. package/lib/portal/workflow/ingestion.js +265 -0
  11. package/lib/portal/workflow/lifecycle.js +616 -0
  12. package/lib/portal/workflow/logging.js +8 -0
  13. package/lib/portal/workflow/source/files.js +304 -0
  14. package/lib/portal/workflow/source/preparation.js +318 -0
  15. package/lib/portal/workflow/state/bundle.js +260 -0
  16. package/lib/portal/workflow/state/checkpoints.js +53 -0
  17. package/lib/portal/workflow/state/session.js +100 -0
  18. package/lib/portal/workflow.js +1 -0
  19. package/lib/publish/PublishCoreAttestation.js +18 -17
  20. package/lib/publish/PublishCoreRemove.js +7 -89
  21. package/lib/publish/PublishCoreSubmit.js +7 -117
  22. package/lib/publish/PublishCoreSupport.js +7 -86
  23. package/lib/publish/PublishCoreUpdate.js +7 -117
  24. package/lib/publish/index.js +1 -0
  25. package/lib/schemas/releaseJsonMetadata.json +1 -2
  26. package/package.json +2 -4
  27. package/src/CoreUtils.ts +0 -6
  28. package/src/index.ts +1 -0
  29. package/src/portal/attestation.ts +76 -0
  30. package/src/portal/compat.ts +5 -0
  31. package/src/portal/index.ts +5 -0
  32. package/src/portal/signer.ts +327 -0
  33. package/src/portal/types.ts +447 -0
  34. package/src/portal/workflow/contracts.ts +108 -0
  35. package/src/portal/workflow/execution.ts +412 -0
  36. package/src/portal/workflow/ingestion.ts +187 -0
  37. package/src/portal/workflow/lifecycle.ts +435 -0
  38. package/src/portal/workflow/logging.ts +17 -0
  39. package/src/portal/workflow/source/files.ts +49 -0
  40. package/src/portal/workflow/source/preparation.ts +189 -0
  41. package/src/portal/workflow/state/bundle.ts +193 -0
  42. package/src/portal/workflow/state/checkpoints.ts +70 -0
  43. package/src/portal/workflow/state/session.ts +87 -0
  44. package/src/portal/workflow.ts +9 -0
  45. package/src/publish/PublishCoreAttestation.ts +21 -26
  46. package/src/publish/PublishCoreRemove.ts +13 -109
  47. package/src/publish/PublishCoreSubmit.ts +18 -150
  48. package/src/publish/PublishCoreSupport.ts +13 -102
  49. package/src/publish/PublishCoreUpdate.ts +17 -155
  50. package/src/publish/index.ts +2 -1
  51. package/src/schemas/releaseJsonMetadata.json +1 -2
  52. package/lib/publish/dapp_publisher_portal.js +0 -206
  53. package/src/publish/dapp_publisher_portal.ts +0 -81
@@ -0,0 +1,616 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _instanceof(left, right) {
44
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
45
+ return !!right[Symbol.hasInstance](left);
46
+ } else {
47
+ return left instanceof right;
48
+ }
49
+ }
50
+ function _object_spread(target) {
51
+ for(var i = 1; i < arguments.length; i++){
52
+ var source = arguments[i] != null ? arguments[i] : {};
53
+ var ownKeys = Object.keys(source);
54
+ if (typeof Object.getOwnPropertySymbols === "function") {
55
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
56
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
57
+ }));
58
+ }
59
+ ownKeys.forEach(function(key) {
60
+ _define_property(target, key, source[key]);
61
+ });
62
+ }
63
+ return target;
64
+ }
65
+ function _ts_generator(thisArg, body) {
66
+ var f, y, t, _ = {
67
+ label: 0,
68
+ sent: function() {
69
+ if (t[0] & 1) throw t[1];
70
+ return t[1];
71
+ },
72
+ trys: [],
73
+ ops: []
74
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
75
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
76
+ return this;
77
+ }), g;
78
+ function verb(n) {
79
+ return function(v) {
80
+ return step([
81
+ n,
82
+ v
83
+ ]);
84
+ };
85
+ }
86
+ function step(op) {
87
+ if (f) throw new TypeError("Generator is already executing.");
88
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
89
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
90
+ if (y = 0, t) op = [
91
+ op[0] & 2,
92
+ t.value
93
+ ];
94
+ switch(op[0]){
95
+ case 0:
96
+ case 1:
97
+ t = op;
98
+ break;
99
+ case 4:
100
+ _.label++;
101
+ return {
102
+ value: op[1],
103
+ done: false
104
+ };
105
+ case 5:
106
+ _.label++;
107
+ y = op[1];
108
+ op = [
109
+ 0
110
+ ];
111
+ continue;
112
+ case 7:
113
+ op = _.ops.pop();
114
+ _.trys.pop();
115
+ continue;
116
+ default:
117
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
118
+ _ = 0;
119
+ continue;
120
+ }
121
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
122
+ _.label = op[1];
123
+ break;
124
+ }
125
+ if (op[0] === 6 && _.label < t[1]) {
126
+ _.label = t[1];
127
+ t = op;
128
+ break;
129
+ }
130
+ if (t && _.label < t[2]) {
131
+ _.label = t[2];
132
+ _.ops.push(op);
133
+ break;
134
+ }
135
+ if (t[2]) _.ops.pop();
136
+ _.trys.pop();
137
+ continue;
138
+ }
139
+ op = body.call(thisArg, _);
140
+ } catch (e) {
141
+ op = [
142
+ 6,
143
+ e
144
+ ];
145
+ y = 0;
146
+ } finally{
147
+ f = t = 0;
148
+ }
149
+ if (op[0] & 5) throw op[1];
150
+ return {
151
+ value: op[0] ? op[1] : void 0,
152
+ done: true
153
+ };
154
+ }
155
+ }
156
+ import { randomUUID } from "node:crypto";
157
+ import { runPublicationWorkflow } from "./execution.js";
158
+ import { waitForIngestionSessionReady } from "./ingestion.js";
159
+ import { logWorkflowInfo } from "./logging.js";
160
+ import { hasResolvableReleaseMetadataUri, normalizePublicationBundle, validatePublicationBundle, withPublicationBundleIdentifiers } from "./state/bundle.js";
161
+ import { normalizePublicationSession } from "./state/session.js";
162
+ import { preparePublicationSource } from "./source/preparation.js";
163
+ function normalizeWorkflowError(error) {
164
+ return _instanceof(error, Error) ? error : new Error(String(error));
165
+ }
166
+ function resolvePublicationSessionLookup(input) {
167
+ if (input.publicationSessionId) {
168
+ return {
169
+ publicationSessionId: input.publicationSessionId
170
+ };
171
+ }
172
+ if (!input.releaseId) {
173
+ throw new Error("releaseId is required when publicationSessionId is absent");
174
+ }
175
+ return {
176
+ releaseId: input.releaseId
177
+ };
178
+ }
179
+ function loadPublicationSession(client, input, options) {
180
+ return _async_to_generator(function() {
181
+ var _input_publicationSessionId, _input_existingSession, publicationSession, _tmp;
182
+ return _ts_generator(this, function(_state) {
183
+ switch(_state.label){
184
+ case 0:
185
+ logWorkflowInfo(options.logger, input.startMessage, {
186
+ step: "session.load",
187
+ status: "running",
188
+ releaseId: input.releaseId,
189
+ publicationSessionId: (_input_publicationSessionId = input.publicationSessionId) !== null && _input_publicationSessionId !== void 0 ? _input_publicationSessionId : undefined
190
+ });
191
+ if (!((_input_existingSession = input.existingSession) !== null && _input_existingSession !== void 0)) return [
192
+ 3,
193
+ 1
194
+ ];
195
+ _tmp = _input_existingSession;
196
+ return [
197
+ 3,
198
+ 3
199
+ ];
200
+ case 1:
201
+ return [
202
+ 4,
203
+ client.getPublicationSession(resolvePublicationSessionLookup({
204
+ publicationSessionId: input.publicationSessionId,
205
+ releaseId: input.releaseId
206
+ }))
207
+ ];
208
+ case 2:
209
+ _tmp = normalizePublicationSession.apply(void 0, [
210
+ _state.sent()
211
+ ]);
212
+ _state.label = 3;
213
+ case 3:
214
+ publicationSession = _tmp;
215
+ logWorkflowInfo(options.logger, input.completeMessage, {
216
+ step: "session.load",
217
+ status: "complete",
218
+ releaseId: publicationSession.releaseId,
219
+ publicationSessionId: publicationSession.id,
220
+ stage: publicationSession.stage
221
+ });
222
+ return [
223
+ 2,
224
+ publicationSession
225
+ ];
226
+ }
227
+ });
228
+ })();
229
+ }
230
+ function loadPublicationBundle(client, input, options) {
231
+ return _async_to_generator(function() {
232
+ var _input_publicationSessionId, _input_ingestionSessionId, publicationBundle, _tmp;
233
+ return _ts_generator(this, function(_state) {
234
+ switch(_state.label){
235
+ case 0:
236
+ logWorkflowInfo(options.logger, "Loading publication bundle", {
237
+ step: "bundle.load",
238
+ status: "running",
239
+ releaseId: input.releaseId
240
+ });
241
+ if (!(input.existingBundle && hasResolvableReleaseMetadataUri(input.existingBundle, input.existingSession))) return [
242
+ 3,
243
+ 1
244
+ ];
245
+ _tmp = input.existingBundle;
246
+ return [
247
+ 3,
248
+ 3
249
+ ];
250
+ case 1:
251
+ return [
252
+ 4,
253
+ client.getPublicationBundle({
254
+ releaseId: input.releaseId
255
+ })
256
+ ];
257
+ case 2:
258
+ _tmp = withPublicationBundleIdentifiers.apply(void 0, [
259
+ normalizePublicationBundle.apply(void 0, [
260
+ _state.sent()
261
+ ]),
262
+ {
263
+ releaseId: input.releaseId,
264
+ publicationSessionId: (_input_publicationSessionId = input.publicationSessionId) !== null && _input_publicationSessionId !== void 0 ? _input_publicationSessionId : null,
265
+ ingestionSessionId: (_input_ingestionSessionId = input.ingestionSessionId) !== null && _input_ingestionSessionId !== void 0 ? _input_ingestionSessionId : null
266
+ }
267
+ ]);
268
+ _state.label = 3;
269
+ case 3:
270
+ publicationBundle = _tmp;
271
+ validatePublicationBundle(publicationBundle);
272
+ logWorkflowInfo(options.logger, "Publication bundle loaded", {
273
+ step: "bundle.load",
274
+ status: "complete",
275
+ releaseId: input.releaseId,
276
+ androidPackage: publicationBundle.release.androidPackage,
277
+ versionName: publicationBundle.release.versionName
278
+ });
279
+ return [
280
+ 2,
281
+ publicationBundle
282
+ ];
283
+ }
284
+ });
285
+ })();
286
+ }
287
+ function recoverPublicationResult(client, releaseId, input, options) {
288
+ return _async_to_generator(function() {
289
+ var publicationSession, _publicationSession_ingestionSessionId, publicationBundle;
290
+ return _ts_generator(this, function(_state) {
291
+ switch(_state.label){
292
+ case 0:
293
+ logWorkflowInfo(options.logger, "Recovering final publication state", {
294
+ step: "cleanup.recover",
295
+ status: "running",
296
+ releaseId: releaseId
297
+ });
298
+ return [
299
+ 4,
300
+ client.getPublicationSession({
301
+ releaseId: releaseId
302
+ })
303
+ ];
304
+ case 1:
305
+ publicationSession = normalizePublicationSession.apply(void 0, [
306
+ _state.sent()
307
+ ]);
308
+ return [
309
+ 4,
310
+ client.getPublicationBundle({
311
+ releaseId: releaseId
312
+ })
313
+ ];
314
+ case 2:
315
+ publicationBundle = withPublicationBundleIdentifiers.apply(void 0, [
316
+ normalizePublicationBundle.apply(void 0, [
317
+ _state.sent()
318
+ ]),
319
+ {
320
+ releaseId: releaseId,
321
+ publicationSessionId: publicationSession.id,
322
+ ingestionSessionId: (_publicationSession_ingestionSessionId = publicationSession.ingestionSessionId) !== null && _publicationSession_ingestionSessionId !== void 0 ? _publicationSession_ingestionSessionId : null
323
+ }
324
+ ]);
325
+ logWorkflowInfo(options.logger, "Recovered final publication state", {
326
+ step: "cleanup.recover",
327
+ status: "complete",
328
+ releaseId: releaseId,
329
+ publicationSessionId: publicationSession.id,
330
+ stage: publicationSession.stage
331
+ });
332
+ return [
333
+ 2,
334
+ runPublicationWorkflow(client, publicationBundle, input.signer, input.attestationClient, publicationSession, options.logger)
335
+ ];
336
+ }
337
+ });
338
+ })();
339
+ }
340
+ function cleanupFailedRelease(client, releaseId, error, options) {
341
+ return _async_to_generator(function() {
342
+ var _options_logger_warn, _options_logger, cleanupResult, message;
343
+ return _ts_generator(this, function(_state) {
344
+ switch(_state.label){
345
+ case 0:
346
+ if (!client.cleanupRelease) {
347
+ return [
348
+ 2,
349
+ null
350
+ ];
351
+ }
352
+ (_options_logger = options.logger) === null || _options_logger === void 0 ? void 0 : (_options_logger_warn = _options_logger.warn) === null || _options_logger_warn === void 0 ? void 0 : _options_logger_warn.call(_options_logger, "Rolling back failed publication release", {
353
+ step: "cleanup.release",
354
+ status: "running",
355
+ releaseId: releaseId,
356
+ error: error.message
357
+ });
358
+ return [
359
+ 4,
360
+ client.cleanupRelease({
361
+ releaseId: releaseId
362
+ })
363
+ ];
364
+ case 1:
365
+ cleanupResult = _state.sent();
366
+ message = cleanupResult.action === "deleted" ? "Failed publication release cleaned up" : "Publication already reached the submitted state; preserving release";
367
+ logWorkflowInfo(options.logger, message, {
368
+ step: "cleanup.release",
369
+ status: "complete",
370
+ releaseId: releaseId,
371
+ action: cleanupResult.action
372
+ });
373
+ return [
374
+ 2,
375
+ cleanupResult
376
+ ];
377
+ }
378
+ });
379
+ })();
380
+ }
381
+ export var createPublicationWorkflow = function(client) {
382
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
383
+ var _options_pollIntervalMs, _options_maxPollAttempts;
384
+ var pollOptions = {
385
+ pollIntervalMs: (_options_pollIntervalMs = options.pollIntervalMs) !== null && _options_pollIntervalMs !== void 0 ? _options_pollIntervalMs : 2500,
386
+ // Large APK ingestion can legitimately take tens of minutes once upload,
387
+ // managed-storage download, hashing, aapt2, and apksigner are included.
388
+ // Keep the default wait aligned with the portal queue headroom instead of
389
+ // failing after only ~5 minutes.
390
+ maxPollAttempts: (_options_maxPollAttempts = options.maxPollAttempts) !== null && _options_maxPollAttempts !== void 0 ? _options_maxPollAttempts : 1080
391
+ };
392
+ return {
393
+ startPublication: function startPublication(input) {
394
+ return _async_to_generator(function() {
395
+ var createdReleaseId, createdIngestionSessionId, _ingestionSession_bundle, _ingestionSession_id, _readySession_bundle, source, _input_idempotencyKey, ingestionSession, _ingestionSession_releaseId, _ref, readySession, _readySession_releaseId, _ref1, releaseId, readyPublicationSession, _readySession_publicationSessionId, readyPublicationBundle, _readySession_publicationSessionId1, publicationBundle, _readySession_publicationSessionId2, publicationSession, error, normalizedError, _failedIngestionSession_bundle, failedIngestionSession, _failedIngestionSession_releaseId, _ref2, e, cleanupResult, cleanupError, normalizedCleanupError;
396
+ return _ts_generator(this, function(_state) {
397
+ switch(_state.label){
398
+ case 0:
399
+ _state.trys.push([
400
+ 0,
401
+ 7,
402
+ ,
403
+ 18
404
+ ]);
405
+ logWorkflowInfo(options.logger, "Preparing publication source", {
406
+ step: "source.prepare",
407
+ status: "running"
408
+ });
409
+ return [
410
+ 4,
411
+ preparePublicationSource(client, input.source, options.logger)
412
+ ];
413
+ case 1:
414
+ source = _state.sent();
415
+ logWorkflowInfo(options.logger, "Creating ingestion session", {
416
+ step: "ingestion.create",
417
+ status: "running"
418
+ });
419
+ return [
420
+ 4,
421
+ client.createIngestionSession(_object_spread({
422
+ source: source,
423
+ whatsNew: input.whatsNew,
424
+ idempotencyKey: (_input_idempotencyKey = input.idempotencyKey) !== null && _input_idempotencyKey !== void 0 ? _input_idempotencyKey : randomUUID()
425
+ }, input.dappId ? {
426
+ dappId: input.dappId
427
+ } : {}))
428
+ ];
429
+ case 2:
430
+ ingestionSession = _state.sent();
431
+ createdReleaseId = (_ref = (_ingestionSession_releaseId = ingestionSession.releaseId) !== null && _ingestionSession_releaseId !== void 0 ? _ingestionSession_releaseId : (_ingestionSession_bundle = ingestionSession.bundle) === null || _ingestionSession_bundle === void 0 ? void 0 : _ingestionSession_bundle.releaseId) !== null && _ref !== void 0 ? _ref : undefined;
432
+ createdIngestionSessionId = (_ingestionSession_id = ingestionSession.id) === null || _ingestionSession_id === void 0 ? void 0 : _ingestionSession_id.trim();
433
+ if (!createdIngestionSessionId) {
434
+ throw new Error("Portal createIngestionSession did not return an ingestion session id");
435
+ }
436
+ logWorkflowInfo(options.logger, "Ingestion session created", {
437
+ step: "ingestion.create",
438
+ status: "complete",
439
+ ingestionSessionId: createdIngestionSessionId,
440
+ releaseId: createdReleaseId
441
+ });
442
+ return [
443
+ 4,
444
+ waitForIngestionSessionReady(client, createdIngestionSessionId, pollOptions, options.logger)
445
+ ];
446
+ case 3:
447
+ readySession = _state.sent();
448
+ releaseId = (_ref1 = (_readySession_releaseId = readySession.releaseId) !== null && _readySession_releaseId !== void 0 ? _readySession_releaseId : (_readySession_bundle = readySession.bundle) === null || _readySession_bundle === void 0 ? void 0 : _readySession_bundle.releaseId) !== null && _ref1 !== void 0 ? _ref1 : undefined;
449
+ if (!releaseId) {
450
+ throw new Error("Publication ingestion completed without a release identifier");
451
+ }
452
+ createdReleaseId = releaseId;
453
+ readyPublicationSession = readySession.publicationSession ? normalizePublicationSession(readySession.publicationSession) : undefined;
454
+ readyPublicationBundle = readySession.bundle ? withPublicationBundleIdentifiers(normalizePublicationBundle(readySession.bundle), {
455
+ releaseId: releaseId,
456
+ publicationSessionId: (_readySession_publicationSessionId = readySession.publicationSessionId) !== null && _readySession_publicationSessionId !== void 0 ? _readySession_publicationSessionId : null,
457
+ ingestionSessionId: readySession.id
458
+ }) : null;
459
+ return [
460
+ 4,
461
+ loadPublicationBundle(client, {
462
+ releaseId: releaseId,
463
+ publicationSessionId: (_readySession_publicationSessionId1 = readySession.publicationSessionId) !== null && _readySession_publicationSessionId1 !== void 0 ? _readySession_publicationSessionId1 : null,
464
+ ingestionSessionId: readySession.id,
465
+ existingBundle: readyPublicationBundle,
466
+ existingSession: readyPublicationSession
467
+ }, options)
468
+ ];
469
+ case 4:
470
+ publicationBundle = _state.sent();
471
+ return [
472
+ 4,
473
+ loadPublicationSession(client, {
474
+ releaseId: releaseId,
475
+ publicationSessionId: (_readySession_publicationSessionId2 = readySession.publicationSessionId) !== null && _readySession_publicationSessionId2 !== void 0 ? _readySession_publicationSessionId2 : null,
476
+ existingSession: readyPublicationSession,
477
+ startMessage: "Loading publication session",
478
+ completeMessage: "Publication session loaded"
479
+ }, options)
480
+ ];
481
+ case 5:
482
+ publicationSession = _state.sent();
483
+ return [
484
+ 4,
485
+ runPublicationWorkflow(client, publicationBundle, input.signer, input.attestationClient, publicationSession, options.logger)
486
+ ];
487
+ case 6:
488
+ return [
489
+ 2,
490
+ _state.sent()
491
+ ];
492
+ case 7:
493
+ error = _state.sent();
494
+ normalizedError = normalizeWorkflowError(error);
495
+ if (!(!createdReleaseId && createdIngestionSessionId)) return [
496
+ 3,
497
+ 11
498
+ ];
499
+ _state.label = 8;
500
+ case 8:
501
+ _state.trys.push([
502
+ 8,
503
+ 10,
504
+ ,
505
+ 11
506
+ ]);
507
+ return [
508
+ 4,
509
+ client.getIngestionSession({
510
+ sessionId: createdIngestionSessionId,
511
+ ingestionSessionId: createdIngestionSessionId
512
+ })
513
+ ];
514
+ case 9:
515
+ failedIngestionSession = _state.sent();
516
+ createdReleaseId = (_ref2 = (_failedIngestionSession_releaseId = failedIngestionSession.releaseId) !== null && _failedIngestionSession_releaseId !== void 0 ? _failedIngestionSession_releaseId : (_failedIngestionSession_bundle = failedIngestionSession.bundle) === null || _failedIngestionSession_bundle === void 0 ? void 0 : _failedIngestionSession_bundle.releaseId) !== null && _ref2 !== void 0 ? _ref2 : undefined;
517
+ return [
518
+ 3,
519
+ 11
520
+ ];
521
+ case 10:
522
+ e = _state.sent();
523
+ return [
524
+ 3,
525
+ 11
526
+ ];
527
+ case 11:
528
+ if (!createdReleaseId) {
529
+ throw normalizedError;
530
+ }
531
+ _state.label = 12;
532
+ case 12:
533
+ _state.trys.push([
534
+ 12,
535
+ 16,
536
+ ,
537
+ 17
538
+ ]);
539
+ return [
540
+ 4,
541
+ cleanupFailedRelease(client, createdReleaseId, normalizedError, options)
542
+ ];
543
+ case 13:
544
+ cleanupResult = _state.sent();
545
+ if (!((cleanupResult === null || cleanupResult === void 0 ? void 0 : cleanupResult.action) === "preservedSubmitted")) return [
546
+ 3,
547
+ 15
548
+ ];
549
+ return [
550
+ 4,
551
+ recoverPublicationResult(client, createdReleaseId, input, options)
552
+ ];
553
+ case 14:
554
+ return [
555
+ 2,
556
+ _state.sent()
557
+ ];
558
+ case 15:
559
+ return [
560
+ 3,
561
+ 17
562
+ ];
563
+ case 16:
564
+ cleanupError = _state.sent();
565
+ normalizedCleanupError = normalizeWorkflowError(cleanupError);
566
+ throw new Error("".concat(normalizedError.message, " Cleanup also failed for release ").concat(createdReleaseId, ": ").concat(normalizedCleanupError.message));
567
+ case 17:
568
+ throw normalizedError;
569
+ case 18:
570
+ return [
571
+ 2
572
+ ];
573
+ }
574
+ });
575
+ })();
576
+ },
577
+ resumePublication: function resumePublication(input) {
578
+ return _async_to_generator(function() {
579
+ var _input_publicationSessionId, publicationSession, _publicationSession_ingestionSessionId, publicationBundle;
580
+ return _ts_generator(this, function(_state) {
581
+ switch(_state.label){
582
+ case 0:
583
+ if (!input.publicationSessionId && !input.releaseId) {
584
+ throw new Error("Publication session id or release id is required to resume a publication");
585
+ }
586
+ return [
587
+ 4,
588
+ loadPublicationSession(client, {
589
+ publicationSessionId: (_input_publicationSessionId = input.publicationSessionId) !== null && _input_publicationSessionId !== void 0 ? _input_publicationSessionId : null,
590
+ releaseId: input.releaseId,
591
+ startMessage: "Loading existing publication session",
592
+ completeMessage: "Existing publication session loaded"
593
+ }, options)
594
+ ];
595
+ case 1:
596
+ publicationSession = _state.sent();
597
+ return [
598
+ 4,
599
+ loadPublicationBundle(client, {
600
+ releaseId: publicationSession.releaseId,
601
+ publicationSessionId: publicationSession.id,
602
+ ingestionSessionId: (_publicationSession_ingestionSessionId = publicationSession.ingestionSessionId) !== null && _publicationSession_ingestionSessionId !== void 0 ? _publicationSession_ingestionSessionId : null
603
+ }, options)
604
+ ];
605
+ case 2:
606
+ publicationBundle = _state.sent();
607
+ return [
608
+ 2,
609
+ runPublicationWorkflow(client, publicationBundle, input.signer, input.attestationClient, publicationSession, options.logger)
610
+ ];
611
+ }
612
+ });
613
+ })();
614
+ }
615
+ };
616
+ };
@@ -0,0 +1,8 @@
1
+ export function logWorkflowInfo(logger, message, metadata) {
2
+ var _logger_info;
3
+ logger === null || logger === void 0 ? void 0 : (_logger_info = logger.info) === null || _logger_info === void 0 ? void 0 : _logger_info.call(logger, message, metadata);
4
+ }
5
+ export function logWorkflowDebug(logger, message, metadata) {
6
+ var _logger_debug;
7
+ logger === null || logger === void 0 ? void 0 : (_logger_debug = logger.debug) === null || _logger_debug === void 0 ? void 0 : _logger_debug.call(logger, message, metadata);
8
+ }