@solana-mobile/dapp-store-cli 0.16.0 → 0.16.1

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 (113) hide show
  1. package/bin/dapp-store.js +3 -1
  2. package/lib/CliSetup.js +304 -505
  3. package/lib/CliUtils.js +6 -376
  4. package/lib/__tests__/CliSetupTest.js +484 -74
  5. package/lib/cli/__tests__/parseErrors.test.js +25 -0
  6. package/lib/cli/__tests__/signer.test.js +436 -0
  7. package/lib/cli/constants.js +23 -0
  8. package/lib/cli/messages.js +21 -0
  9. package/lib/cli/parseErrors.js +41 -0
  10. package/lib/{commands/publish/PublishCliSupport.js → cli/selfUpdate.js} +72 -38
  11. package/lib/{commands/publish/PublishCliRemove.js → cli/signer.js} +35 -56
  12. package/lib/index.js +96 -5
  13. package/lib/package.json +5 -24
  14. package/lib/portal/__tests__/releaseMetadata.test.js +647 -0
  15. package/lib/portal/__tests__/translators.test.js +76 -0
  16. package/lib/portal/__tests__/workflowClient.test.js +457 -0
  17. package/lib/portal/attestationClient.js +143 -0
  18. package/lib/portal/files.js +64 -0
  19. package/lib/portal/http.js +364 -0
  20. package/lib/portal/records.js +64 -0
  21. package/lib/portal/releaseMetadata.js +748 -0
  22. package/lib/portal/translators.js +460 -0
  23. package/lib/portal/types.js +1 -0
  24. package/lib/portal/workflowClient.js +704 -0
  25. package/lib/publication/PublicationProgressReporter.js +1051 -0
  26. package/lib/publication/__tests__/PublicationProgressReporter.test.js +174 -0
  27. package/lib/{commands/ValidateCommand.js → publication/__tests__/fundingPreflight.test.js} +90 -66
  28. package/lib/publication/__tests__/publicationSummary.test.js +26 -0
  29. package/lib/publication/cliValidation.js +482 -0
  30. package/lib/publication/fundingPreflight.js +246 -0
  31. package/lib/publication/publicationSummary.js +99 -0
  32. package/lib/{commands/utils.js → publication/runPublicationWorkflow.js} +16 -46
  33. package/package.json +5 -24
  34. package/src/CliSetup.ts +370 -505
  35. package/src/CliUtils.ts +9 -233
  36. package/src/__tests__/CliSetupTest.ts +272 -120
  37. package/src/cli/__tests__/parseErrors.test.ts +34 -0
  38. package/src/cli/__tests__/signer.test.ts +359 -0
  39. package/src/cli/constants.ts +3 -0
  40. package/src/cli/messages.ts +27 -0
  41. package/src/cli/parseErrors.ts +62 -0
  42. package/src/cli/selfUpdate.ts +59 -0
  43. package/src/cli/signer.ts +38 -0
  44. package/src/index.ts +31 -4
  45. package/src/portal/__tests__/releaseMetadata.test.ts +508 -0
  46. package/src/portal/__tests__/translators.test.ts +82 -0
  47. package/src/portal/__tests__/workflowClient.test.ts +278 -0
  48. package/src/portal/attestationClient.ts +19 -0
  49. package/src/portal/files.ts +73 -0
  50. package/src/portal/http.ts +170 -0
  51. package/src/portal/records.ts +38 -0
  52. package/src/portal/releaseMetadata.ts +489 -0
  53. package/src/portal/translators.ts +750 -0
  54. package/src/portal/types.ts +27 -0
  55. package/src/portal/workflowClient.ts +575 -0
  56. package/src/publication/PublicationProgressReporter.ts +1026 -0
  57. package/src/publication/__tests__/PublicationProgressReporter.test.ts +210 -0
  58. package/src/publication/__tests__/fundingPreflight.test.ts +78 -0
  59. package/src/publication/__tests__/publicationSummary.test.ts +30 -0
  60. package/src/publication/cliValidation.ts +264 -0
  61. package/src/publication/fundingPreflight.ts +123 -0
  62. package/src/publication/publicationSummary.ts +26 -0
  63. package/src/publication/runPublicationWorkflow.ts +46 -0
  64. package/lib/commands/create/CreateCliApp.js +0 -223
  65. package/lib/commands/create/CreateCliRelease.js +0 -290
  66. package/lib/commands/create/index.js +0 -40
  67. package/lib/commands/index.js +0 -3
  68. package/lib/commands/publish/PublishCliSubmit.js +0 -208
  69. package/lib/commands/publish/PublishCliUpdate.js +0 -211
  70. package/lib/commands/publish/index.js +0 -22
  71. package/lib/commands/scaffolding/ScaffoldInit.js +0 -15
  72. package/lib/commands/scaffolding/index.js +0 -1
  73. package/lib/config/EnvVariables.js +0 -59
  74. package/lib/config/PublishDetails.js +0 -915
  75. package/lib/config/S3StorageManager.js +0 -93
  76. package/lib/config/index.js +0 -2
  77. package/lib/generated/config_obj.json +0 -1
  78. package/lib/generated/config_schema.json +0 -1
  79. package/lib/prebuild_schema/publishing_source.yaml +0 -64
  80. package/lib/prebuild_schema/schemagen.js +0 -25
  81. package/lib/upload/CachedStorageDriver.js +0 -458
  82. package/lib/upload/TurboStorageDriver.js +0 -718
  83. package/lib/upload/__tests__/CachedStorageDriver.test.js +0 -437
  84. package/lib/upload/__tests__/TurboStorageDriver.test.js +0 -17
  85. package/lib/upload/__tests__/contentGateway.test.js +0 -17
  86. package/lib/upload/contentGateway.js +0 -23
  87. package/lib/upload/index.js +0 -2
  88. package/src/commands/ValidateCommand.ts +0 -82
  89. package/src/commands/create/CreateCliApp.ts +0 -93
  90. package/src/commands/create/CreateCliRelease.ts +0 -149
  91. package/src/commands/create/index.ts +0 -47
  92. package/src/commands/index.ts +0 -3
  93. package/src/commands/publish/PublishCliRemove.ts +0 -66
  94. package/src/commands/publish/PublishCliSubmit.ts +0 -93
  95. package/src/commands/publish/PublishCliSupport.ts +0 -66
  96. package/src/commands/publish/PublishCliUpdate.ts +0 -101
  97. package/src/commands/publish/index.ts +0 -29
  98. package/src/commands/scaffolding/ScaffoldInit.ts +0 -20
  99. package/src/commands/scaffolding/index.ts +0 -1
  100. package/src/commands/utils.ts +0 -33
  101. package/src/config/EnvVariables.ts +0 -39
  102. package/src/config/PublishDetails.ts +0 -456
  103. package/src/config/S3StorageManager.ts +0 -47
  104. package/src/config/index.ts +0 -2
  105. package/src/prebuild_schema/publishing_source.yaml +0 -64
  106. package/src/prebuild_schema/schemagen.js +0 -31
  107. package/src/upload/CachedStorageDriver.ts +0 -179
  108. package/src/upload/TurboStorageDriver.ts +0 -283
  109. package/src/upload/__tests__/CachedStorageDriver.test.ts +0 -246
  110. package/src/upload/__tests__/TurboStorageDriver.test.ts +0 -15
  111. package/src/upload/__tests__/contentGateway.test.ts +0 -31
  112. package/src/upload/contentGateway.ts +0 -37
  113. package/src/upload/index.ts +0 -2
@@ -0,0 +1,460 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ function ownKeys(object, enumerableOnly) {
30
+ var keys = Object.keys(object);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var symbols = Object.getOwnPropertySymbols(object);
33
+ if (enumerableOnly) {
34
+ symbols = symbols.filter(function(sym) {
35
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
+ });
37
+ }
38
+ keys.push.apply(keys, symbols);
39
+ }
40
+ return keys;
41
+ }
42
+ function _object_spread_props(target, source) {
43
+ source = source != null ? source : {};
44
+ if (Object.getOwnPropertyDescriptors) {
45
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
+ } else {
47
+ ownKeys(Object(source)).forEach(function(key) {
48
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
+ });
50
+ }
51
+ return target;
52
+ }
53
+ import { ensureHttpsUrl, inferFileNameFromUrl, inferMimeType } from './files.js';
54
+ import { firstString, isRecord } from './records.js';
55
+ function asString(value) {
56
+ return String(value || '');
57
+ }
58
+ function optionalString(value) {
59
+ return typeof value === 'string' ? value : null;
60
+ }
61
+ function stringArray(value) {
62
+ return Array.isArray(value) ? value : [];
63
+ }
64
+ function numberOrDefault(value, fallback) {
65
+ return typeof value === 'number' ? value : fallback;
66
+ }
67
+ function buildInstallFileDetails(release, installFile) {
68
+ var url = asString(installFile.uri || release.releaseFileUrl || '');
69
+ var fileName = typeof release.releaseFileName === 'string' && release.releaseFileName || inferFileNameFromUrl(url);
70
+ return {
71
+ url: url,
72
+ fileName: fileName,
73
+ mimeType: typeof installFile.mimeType === 'string' ? installFile.mimeType : inferMimeType(fileName),
74
+ size: numberOrDefault(installFile.size, 0),
75
+ sha256: typeof installFile.sha256 === 'string' ? installFile.sha256 : null,
76
+ canonicalUrl: typeof installFile.canonicalUrl === 'string' ? installFile.canonicalUrl : url
77
+ };
78
+ }
79
+ function normalizePublicationCheckpoint(session) {
80
+ switch(session.stage){
81
+ case 'Submitted':
82
+ return 'submitted';
83
+ case 'Attested':
84
+ return 'verified';
85
+ case 'Verified':
86
+ case 'VerificationSubmitted':
87
+ return 'verified';
88
+ case 'MintSaved':
89
+ return 'mint-saved';
90
+ case 'MintSubmitted':
91
+ return 'mint-submitted';
92
+ case 'PreparedForMint':
93
+ return 'bundle-ready';
94
+ case 'Failed':
95
+ break;
96
+ default:
97
+ break;
98
+ }
99
+ if (session.hubspotTicketId) {
100
+ return 'submitted';
101
+ }
102
+ if (session.attestationRequestUniqueId) {
103
+ return 'verified';
104
+ }
105
+ if (session.verificationTransactionSignature) {
106
+ return 'verified';
107
+ }
108
+ if (session.mintTransactionSignature) {
109
+ return 'mint-submitted';
110
+ }
111
+ if (session.expectedMintAddress || session.metadataUri) {
112
+ return 'bundle-ready';
113
+ }
114
+ return 'created';
115
+ }
116
+ function normalizePublicationStatus(session) {
117
+ if (session.stage === 'Failed') {
118
+ return 'failed';
119
+ }
120
+ if (session.stage === 'Submitted' || session.hubspotTicketId) {
121
+ return 'completed';
122
+ }
123
+ return 'running';
124
+ }
125
+ export function inferPublicationSourceKind(sourceKind) {
126
+ if (sourceKind === 'externalUrl') {
127
+ return 'external';
128
+ }
129
+ return 'portal';
130
+ }
131
+ export function buildReleaseMetadataDocument(bundle, sourceKind) {
132
+ var releaseName = bundle.release.localizedName || bundle.release.releaseName || bundle.metadata.localizedName || bundle.dapp.dappName;
133
+ var shortDescription = bundle.metadata.shortDescription || bundle.release.newInVersion || '';
134
+ var longDescription = bundle.metadata.longDescription || shortDescription || bundle.dapp.description || '';
135
+ var newInVersion = bundle.metadata.newInVersion || bundle.release.newInVersion || '';
136
+ var installFile = bundle.metadata.installFile;
137
+ var image = bundle.dapp.dappIconUrl || bundle.dapp.featureGraphicUrl || bundle.dapp.bannerUrl;
138
+ if (!image) {
139
+ throw new Error('Publication bundle did not include a public app image URL.');
140
+ }
141
+ var publisherWebsite = bundle.metadata.publisherWebsite || bundle.publisher.website || bundle.dapp.appWebsite || '';
142
+ var licenseUrl = bundle.metadata.legal.licenseUrl || bundle.dapp.licenseUrl || '';
143
+ var copyrightUrl = bundle.metadata.legal.copyrightUrl || bundle.dapp.copyrightUrl || '';
144
+ var privacyPolicyUrl = bundle.metadata.legal.privacyPolicyUrl || bundle.dapp.privacyPolicyUrl || '';
145
+ var _bundle_metadata_media, _installFile_size, _bundle_release_minSdkVersion, _bundle_release_permissions, _bundle_release_locales, _ref;
146
+ return {
147
+ schema_version: '0.4.0',
148
+ name: releaseName.slice(0, 32),
149
+ description: shortDescription || longDescription || releaseName,
150
+ image: image,
151
+ properties: {
152
+ category: 'dApp',
153
+ creators: [
154
+ {
155
+ address: bundle.signerAuthority.dappWalletAddress || bundle.signerAuthority.collectionAuthority,
156
+ share: 100
157
+ }
158
+ ]
159
+ },
160
+ extensions: {
161
+ solana_dapp_store: {
162
+ publisher_details: _object_spread_props(_object_spread({
163
+ name: bundle.publisher.name
164
+ }, publisherWebsite ? {
165
+ website: ensureHttpsUrl(publisherWebsite)
166
+ } : {}), {
167
+ contact: bundle.publisher.email,
168
+ support_email: bundle.publisher.supportEmail || bundle.metadata.supportEmail || bundle.publisher.email
169
+ }),
170
+ release_details: _object_spread_props(_object_spread({
171
+ updated_on: new Date().toISOString()
172
+ }, licenseUrl ? {
173
+ license_url: ensureHttpsUrl(licenseUrl)
174
+ } : {}, copyrightUrl ? {
175
+ copyright_url: copyrightUrl
176
+ } : {}, privacyPolicyUrl ? {
177
+ privacy_policy_url: ensureHttpsUrl(privacyPolicyUrl)
178
+ } : {}), {
179
+ localized_resources: {
180
+ short_description: '5',
181
+ long_description: '1',
182
+ new_in_version: '2',
183
+ name: '4'
184
+ }
185
+ }),
186
+ media: (_bundle_metadata_media = bundle.metadata.media) !== null && _bundle_metadata_media !== void 0 ? _bundle_metadata_media : [],
187
+ files: [
188
+ {
189
+ mime: installFile.mimeType || inferMimeType(installFile.fileName),
190
+ purpose: 'install',
191
+ size: (_installFile_size = installFile.size) !== null && _installFile_size !== void 0 ? _installFile_size : 0,
192
+ sha256: installFile.sha256 || '',
193
+ uri: installFile.url
194
+ }
195
+ ],
196
+ android_details: {
197
+ android_package: bundle.release.androidPackage,
198
+ version_code: bundle.release.versionCode,
199
+ version: bundle.release.versionName,
200
+ min_sdk: (_bundle_release_minSdkVersion = bundle.release.minSdkVersion) !== null && _bundle_release_minSdkVersion !== void 0 ? _bundle_release_minSdkVersion : 1,
201
+ cert_fingerprint: bundle.release.certificateFingerprint || '',
202
+ permissions: (_bundle_release_permissions = bundle.release.permissions) !== null && _bundle_release_permissions !== void 0 ? _bundle_release_permissions : [],
203
+ locales: (_ref = (_bundle_release_locales = bundle.release.locales) !== null && _bundle_release_locales !== void 0 ? _bundle_release_locales : bundle.dapp.languages) !== null && _ref !== void 0 ? _ref : [
204
+ 'en-US'
205
+ ]
206
+ }
207
+ },
208
+ i18n: {
209
+ 'en-US': {
210
+ '1': longDescription,
211
+ '2': newInVersion,
212
+ '4': releaseName,
213
+ '5': shortDescription.slice(0, 50)
214
+ }
215
+ }
216
+ },
217
+ __origin: sourceKind
218
+ };
219
+ }
220
+ export function mapBackendBundleToPublicationBundle(backendBundle, releaseMetadataUri, sourceKind) {
221
+ var release = isRecord(backendBundle.release) ? backendBundle.release : {};
222
+ var dapp = isRecord(backendBundle.dapp) ? backendBundle.dapp : {};
223
+ var publisher = isRecord(backendBundle.publisher) ? backendBundle.publisher : {};
224
+ var installFile = isRecord(backendBundle.installFile) ? backendBundle.installFile : {};
225
+ var signerAuthority = isRecord(backendBundle.signerAuthority) ? backendBundle.signerAuthority : {};
226
+ var installFileDetails = buildInstallFileDetails(release, installFile);
227
+ var releaseName = typeof release.localizedName === 'string' && release.localizedName || typeof dapp.dappName === 'string' && dapp.dappName || 'Release update';
228
+ var shortDescription = typeof release.shortDescription === 'string' && release.shortDescription || typeof dapp.subtitle === 'string' && dapp.subtitle || asString(dapp.description || '').slice(0, 50);
229
+ var localizedShortDescription = typeof release.shortDescription === 'string' && release.shortDescription || asString(dapp.description || '').slice(0, 50);
230
+ var longDescription = typeof release.longDescription === 'string' && release.longDescription || asString(dapp.description || '');
231
+ var newInVersion = typeof release.newInVersion === 'string' && release.newInVersion || '';
232
+ return {
233
+ ingestionSessionId: asString(backendBundle.ingestionSessionId || ''),
234
+ publicationSessionId: asString(backendBundle.publicationSessionId || ''),
235
+ releaseId: asString(backendBundle.releaseId || release.id || ''),
236
+ dapp: {
237
+ id: asString(dapp.id || ''),
238
+ dappName: asString(dapp.dappName || releaseName),
239
+ subtitle: optionalString(dapp.subtitle),
240
+ description: asString(dapp.description || ''),
241
+ androidPackage: asString(dapp.androidPackage || release.androidPackage || ''),
242
+ dappIconUrl: optionalString(dapp.dappIconUrl),
243
+ dappPreviewUrls: stringArray(dapp.dappPreviewUrls),
244
+ bannerUrl: optionalString(dapp.bannerUrl),
245
+ featureGraphicUrl: optionalString(dapp.featureGraphicUrl),
246
+ editorsChoiceGraphicUrl: optionalString(dapp.editorsChoiceGraphicUrl),
247
+ appWebsite: optionalString(dapp.appWebsite),
248
+ contactEmail: optionalString(dapp.contactEmail),
249
+ supportEmail: asString(dapp.supportEmail || publisher.supportEmail || ''),
250
+ languages: stringArray(dapp.languages),
251
+ licenseUrl: optionalString(dapp.licenseUrl),
252
+ copyrightUrl: optionalString(dapp.copyrightUrl),
253
+ privacyPolicyUrl: optionalString(dapp.privacyPolicyUrl),
254
+ walletAddress: asString(dapp.walletAddress || ''),
255
+ nftMintAddress: asString(dapp.nftMintAddress || ''),
256
+ lastApprovedReleaseId: optionalString(dapp.lastApprovedReleaseId),
257
+ website: optionalString(dapp.website || dapp.appWebsite)
258
+ },
259
+ publisher: {
260
+ id: asString(publisher.id || ''),
261
+ type: publisher.type === 'organization' || publisher.type === 'individual' ? publisher.type : 'organization',
262
+ name: asString(publisher.name || ''),
263
+ website: asString(publisher.website || ''),
264
+ email: asString(publisher.email || ''),
265
+ supportEmail: asString(publisher.supportEmail || dapp.supportEmail || publisher.email || '')
266
+ },
267
+ installFile: {
268
+ uri: installFileDetails.url,
269
+ mimeType: installFileDetails.mimeType,
270
+ size: installFileDetails.size,
271
+ sha256: installFileDetails.sha256,
272
+ fileName: installFileDetails.fileName,
273
+ canonicalUrl: installFileDetails.canonicalUrl,
274
+ url: installFileDetails.url,
275
+ origin: sourceKind
276
+ },
277
+ metadata: {
278
+ localizedName: releaseName,
279
+ shortDescription: shortDescription,
280
+ longDescription: longDescription,
281
+ newInVersion: newInVersion,
282
+ publisherWebsite: optionalString(publisher.website),
283
+ supportEmail: optionalString(publisher.supportEmail),
284
+ website: optionalString(dapp.appWebsite),
285
+ locales: stringArray(dapp.languages),
286
+ legal: {
287
+ licenseUrl: optionalString(dapp.licenseUrl),
288
+ copyrightUrl: optionalString(dapp.copyrightUrl),
289
+ privacyPolicyUrl: optionalString(dapp.privacyPolicyUrl)
290
+ },
291
+ media: [],
292
+ installFile: {
293
+ url: installFileDetails.url,
294
+ fileName: installFileDetails.fileName,
295
+ mimeType: installFileDetails.mimeType,
296
+ size: installFileDetails.size,
297
+ sha256: installFileDetails.sha256,
298
+ canonicalUrl: installFileDetails.canonicalUrl,
299
+ origin: sourceKind
300
+ },
301
+ localizedStrings: [
302
+ {
303
+ locale: 'en-US',
304
+ name: releaseName,
305
+ shortDescription: localizedShortDescription,
306
+ longDescription: longDescription,
307
+ newInVersion: newInVersion
308
+ }
309
+ ],
310
+ releaseMetadataUri: releaseMetadataUri || (typeof release.nftMetadataUri === 'string' ? release.nftMetadataUri : null)
311
+ },
312
+ signerAuthority: {
313
+ dappWalletAddress: asString(signerAuthority.dappWalletAddress || signerAuthority.requiredSigner || dapp.walletAddress || ''),
314
+ collectionAuthority: asString(signerAuthority.collectionAuthority || signerAuthority.dappWalletAddress || dapp.walletAddress || ''),
315
+ appMintAddress: asString(signerAuthority.appMintAddress || dapp.nftMintAddress || ''),
316
+ sameSignerRequired: typeof signerAuthority.sameSignerRequired === 'boolean' ? signerAuthority.sameSignerRequired : true,
317
+ acceptedSignerRoles: Array.isArray(signerAuthority.acceptedSignerRoles) ? signerAuthority.acceptedSignerRoles : [
318
+ 'publisher',
319
+ 'payer'
320
+ ],
321
+ dappId: asString(dapp.id || ''),
322
+ requiredSigner: typeof signerAuthority.requiredSigner === 'string' ? signerAuthority.requiredSigner : asString(signerAuthority.dappWalletAddress || signerAuthority.collectionAuthority || dapp.walletAddress || ''),
323
+ mintSigner: typeof signerAuthority.mintSigner === 'string' ? signerAuthority.mintSigner : asString(signerAuthority.dappWalletAddress || signerAuthority.collectionAuthority || dapp.walletAddress || ''),
324
+ feePayer: optionalString(signerAuthority.feePayer)
325
+ },
326
+ release: {
327
+ id: asString(release.id || backendBundle.releaseId || ''),
328
+ dappId: asString(release.dappId || dapp.id || ''),
329
+ releaseFileUrl: optionalString(typeof release.releaseFileUrl === 'string' ? release.releaseFileUrl : installFileDetails.url),
330
+ releaseFileName: asString(typeof release.releaseFileName === 'string' ? release.releaseFileName : installFileDetails.fileName),
331
+ releaseFileSize: numberOrDefault(release.releaseFileSize || installFileDetails.size, installFileDetails.size),
332
+ releaseFileHash: typeof release.releaseFileHash === 'string' ? release.releaseFileHash : installFileDetails.sha256,
333
+ releaseName: releaseName,
334
+ versionName: typeof release.versionName === 'string' && release.versionName || asString(release.versionCode || '1'),
335
+ versionCode: numberOrDefault(release.versionCode, 1),
336
+ androidPackage: asString(release.androidPackage || dapp.androidPackage || ''),
337
+ minSdkVersion: typeof release.minSdkVersion === 'number' ? release.minSdkVersion : null,
338
+ targetSdkVersion: typeof release.targetSdkVersion === 'number' ? release.targetSdkVersion : null,
339
+ permissions: stringArray(release.permissions),
340
+ locales: stringArray(release.locales),
341
+ certificateFingerprint: typeof release.certificateFingerprint === 'string' ? release.certificateFingerprint : null,
342
+ shortDescription: typeof release.shortDescription === 'string' ? release.shortDescription : null,
343
+ longDescription: typeof release.longDescription === 'string' ? release.longDescription : null,
344
+ localizedName: typeof release.localizedName === 'string' && release.localizedName || releaseName,
345
+ newInVersion: newInVersion,
346
+ sagaFeatures: typeof release.sagaFeatures === 'string' ? release.sagaFeatures : null,
347
+ status: typeof release.status === 'string' ? release.status : undefined,
348
+ processingError: optionalString(release.processingError),
349
+ processedAt: optionalString(release.processedAt),
350
+ releaseMintAddress: optionalString(release.nftMintAddress),
351
+ releaseMetadataUri: releaseMetadataUri || (typeof release.nftMetadataUri === 'string' ? release.nftMetadataUri : null),
352
+ nftMintAddress: optionalString(release.nftMintAddress),
353
+ nftTransactionSignature: optionalString(release.nftTransactionSignature),
354
+ nftMetadataUri: optionalString(release.nftMetadataUri),
355
+ nftCluster: optionalString(release.nftCluster),
356
+ isCollectionVerified: typeof release.isCollectionVerified === 'boolean' ? release.isCollectionVerified : undefined,
357
+ uploadProvider: release.uploadProvider === 'Arweave' || release.uploadProvider === 'S3' || release.uploadProvider === 'R2' || release.uploadProvider === 'IPFS' ? release.uploadProvider : null,
358
+ uploadProviderId: optionalString(release.uploadProviderId),
359
+ publishedAt: optionalString(release.publishedAt),
360
+ rejectedAt: optionalString(release.rejectedAt),
361
+ rejectionReason: optionalString(release.rejectionReason),
362
+ submissionStatus: typeof release.submissionStatus === 'string' ? release.submissionStatus : undefined,
363
+ hubspotTicketId: optionalString(release.hubspotTicketId),
364
+ submittedAt: optionalString(release.submittedAt),
365
+ reviewStartedAt: optionalString(release.reviewStartedAt),
366
+ reviewCompletedAt: optionalString(release.reviewCompletedAt),
367
+ source: release.source === 'Portal' || release.source === 'Hubspot' ? release.source : undefined,
368
+ created: optionalString(release.created) || undefined,
369
+ updated: optionalString(release.updated) || undefined,
370
+ isLive: typeof release.isLive === 'boolean' ? release.isLive : undefined,
371
+ liveVersionComparison: typeof release.liveVersionComparison === 'string' ? release.liveVersionComparison : undefined
372
+ }
373
+ };
374
+ }
375
+ export function translateBackendPublicationSession(backendSession) {
376
+ var stage = typeof backendSession.stage === 'string' ? backendSession.stage : 'PreparedForMint';
377
+ return {
378
+ id: asString(backendSession.id || ''),
379
+ ingestionSessionId: asString(backendSession.ingestionSessionId || ''),
380
+ releaseId: asString(backendSession.releaseId || ''),
381
+ status: normalizePublicationStatus({
382
+ stage: stage,
383
+ hubspotTicketId: optionalString(backendSession.hubspotTicketId)
384
+ }),
385
+ checkpoint: normalizePublicationCheckpoint({
386
+ stage: stage,
387
+ mintTransactionSignature: optionalString(backendSession.mintTransactionSignature),
388
+ verificationTransactionSignature: optionalString(backendSession.verificationTransactionSignature),
389
+ attestationRequestUniqueId: optionalString(backendSession.attestationRequestUniqueId),
390
+ hubspotTicketId: optionalString(backendSession.hubspotTicketId),
391
+ expectedMintAddress: optionalString(backendSession.expectedMintAddress),
392
+ metadataUri: optionalString(backendSession.metadataUri)
393
+ }),
394
+ metadataUri: optionalString(backendSession.metadataUri),
395
+ releaseMintAddress: optionalString(backendSession.expectedMintAddress),
396
+ collectionMintAddress: null,
397
+ mintTransactionSignature: optionalString(backendSession.mintTransactionSignature),
398
+ verifyTransactionSignature: optionalString(backendSession.verificationTransactionSignature),
399
+ attestationRequestUniqueId: optionalString(backendSession.attestationRequestUniqueId),
400
+ attestationPayload: null,
401
+ hubspotTicketId: optionalString(backendSession.hubspotTicketId),
402
+ error: optionalString(backendSession.lastError),
403
+ created: typeof backendSession.created === 'string' ? backendSession.created : new Date().toISOString(),
404
+ updated: typeof backendSession.updated === 'string' ? backendSession.updated : new Date().toISOString(),
405
+ createdAt: typeof backendSession.created === 'string' ? backendSession.created : undefined,
406
+ updatedAt: typeof backendSession.updated === 'string' ? backendSession.updated : undefined
407
+ };
408
+ }
409
+ function translateIngestionSource(backendSession) {
410
+ var sourceKind = typeof backendSession.sourceKind === 'string' ? backendSession.sourceKind : 'portalUpload';
411
+ var sourceUrl = typeof backendSession.sourceUrl === 'string' ? backendSession.sourceUrl : '';
412
+ return {
413
+ kind: sourceKind === 'externalUrl' ? 'apk-url' : sourceKind === 'existingRelease' ? 'existingRelease' : 'apk-file',
414
+ filePath: sourceKind === 'existingRelease' ? asString(backendSession.releaseId || '') : sourceUrl,
415
+ fileName: typeof backendSession.releaseFileName === 'string' ? backendSession.releaseFileName : inferFileNameFromUrl(sourceUrl),
416
+ url: sourceUrl,
417
+ mimeType: inferMimeType(typeof backendSession.releaseFileName === 'string' ? backendSession.releaseFileName : inferFileNameFromUrl(sourceUrl)),
418
+ size: typeof backendSession.releaseFileSize === 'number' ? backendSession.releaseFileSize : undefined,
419
+ sha256: typeof backendSession.releaseFileHash === 'string' ? backendSession.releaseFileHash : undefined,
420
+ canonicalUrl: typeof backendSession.canonicalSourceUrl === 'string' ? backendSession.canonicalSourceUrl : undefined,
421
+ sourceReleaseId: asString(backendSession.releaseId || '')
422
+ };
423
+ }
424
+ export function translateBackendIngestionSession(backendSession, bundle, publicationSession) {
425
+ var sourceKind = typeof backendSession.sourceKind === 'string' ? backendSession.sourceKind : 'portalUpload';
426
+ var translatedPublicationSession = publicationSession ? translateBackendPublicationSession(publicationSession) : undefined;
427
+ var translatedBundle = bundle ? _object_spread_props(_object_spread({}, mapBackendBundleToPublicationBundle(bundle, firstString(publicationSession, [
428
+ 'metadataUri'
429
+ ]) || firstString(bundle, [
430
+ 'release.nftMetadataUri'
431
+ ]) || '', inferPublicationSourceKind(sourceKind))), {
432
+ ingestionSessionId: asString(backendSession.id || ''),
433
+ publicationSessionId: typeof backendSession.publicationSessionId === 'string' ? backendSession.publicationSessionId : (translatedPublicationSession === null || translatedPublicationSession === void 0 ? void 0 : translatedPublicationSession.id) || '',
434
+ releaseId: typeof backendSession.releaseId === 'string' ? backendSession.releaseId : firstString(bundle, [
435
+ 'release.id'
436
+ ]) || ''
437
+ }) : undefined;
438
+ var _translatedPublicationSession_id, _translatedBundle_releaseId, _ref;
439
+ return _object_spread({
440
+ id: asString(backendSession.id || ''),
441
+ dappId: asString(backendSession.dappId || ''),
442
+ idempotencyKey: asString(backendSession.idempotencyKey || ''),
443
+ source: translateIngestionSource(backendSession),
444
+ whatsNew: asString(backendSession.whatsNew || ''),
445
+ status: backendSession.status === 'Failed' ? 'failed' : backendSession.status === 'Ready' ? 'ready' : backendSession.status === 'Processing' ? 'processing' : 'created',
446
+ publicationSessionId: typeof backendSession.publicationSessionId === 'string' ? backendSession.publicationSessionId : (_translatedPublicationSession_id = translatedPublicationSession === null || translatedPublicationSession === void 0 ? void 0 : translatedPublicationSession.id) !== null && _translatedPublicationSession_id !== void 0 ? _translatedPublicationSession_id : null,
447
+ releaseId: typeof backendSession.releaseId === 'string' ? backendSession.releaseId : (_ref = (_translatedBundle_releaseId = translatedBundle === null || translatedBundle === void 0 ? void 0 : translatedBundle.releaseId) !== null && _translatedBundle_releaseId !== void 0 ? _translatedBundle_releaseId : translatedPublicationSession === null || translatedPublicationSession === void 0 ? void 0 : translatedPublicationSession.releaseId) !== null && _ref !== void 0 ? _ref : null,
448
+ processingError: optionalString(backendSession.processingError),
449
+ processingProgress: typeof backendSession.processingProgress === 'number' ? backendSession.processingProgress : null,
450
+ processingStage: optionalString(backendSession.processingStage),
451
+ processingDetail: optionalString(backendSession.processingDetail),
452
+ error: optionalString(backendSession.processingError),
453
+ createdAt: typeof backendSession.created === 'string' ? backendSession.created : undefined,
454
+ updatedAt: typeof backendSession.updated === 'string' ? backendSession.updated : undefined
455
+ }, translatedBundle ? {
456
+ bundle: translatedBundle
457
+ } : {}, translatedPublicationSession ? {
458
+ publicationSession: translatedPublicationSession
459
+ } : {});
460
+ }
@@ -0,0 +1 @@
1
+ export { };