@solana-mobile/dapp-store-cli 0.15.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.
- package/bin/dapp-store.js +3 -1
- package/lib/CliSetup.js +304 -505
- package/lib/CliUtils.js +6 -376
- package/lib/__tests__/CliSetupTest.js +484 -74
- package/lib/cli/__tests__/parseErrors.test.js +25 -0
- package/lib/cli/__tests__/signer.test.js +436 -0
- package/lib/cli/constants.js +23 -0
- package/lib/cli/messages.js +21 -0
- package/lib/cli/parseErrors.js +41 -0
- package/lib/{commands/publish/PublishCliSupport.js → cli/selfUpdate.js} +72 -38
- package/lib/{commands/publish/PublishCliRemove.js → cli/signer.js} +35 -56
- package/lib/index.js +96 -5
- package/lib/package.json +5 -24
- package/lib/portal/__tests__/releaseMetadata.test.js +647 -0
- package/lib/portal/__tests__/translators.test.js +76 -0
- package/lib/portal/__tests__/workflowClient.test.js +457 -0
- package/lib/portal/attestationClient.js +143 -0
- package/lib/portal/files.js +64 -0
- package/lib/portal/http.js +364 -0
- package/lib/portal/records.js +64 -0
- package/lib/portal/releaseMetadata.js +748 -0
- package/lib/portal/translators.js +460 -0
- package/lib/portal/types.js +1 -0
- package/lib/portal/workflowClient.js +704 -0
- package/lib/publication/PublicationProgressReporter.js +1051 -0
- package/lib/publication/__tests__/PublicationProgressReporter.test.js +174 -0
- package/lib/{commands/ValidateCommand.js → publication/__tests__/fundingPreflight.test.js} +90 -66
- package/lib/publication/__tests__/publicationSummary.test.js +26 -0
- package/lib/publication/cliValidation.js +482 -0
- package/lib/publication/fundingPreflight.js +246 -0
- package/lib/publication/publicationSummary.js +99 -0
- package/lib/{commands/utils.js → publication/runPublicationWorkflow.js} +16 -46
- package/package.json +5 -24
- package/src/CliSetup.ts +370 -505
- package/src/CliUtils.ts +9 -233
- package/src/__tests__/CliSetupTest.ts +272 -120
- package/src/cli/__tests__/parseErrors.test.ts +34 -0
- package/src/cli/__tests__/signer.test.ts +359 -0
- package/src/cli/constants.ts +3 -0
- package/src/cli/messages.ts +27 -0
- package/src/cli/parseErrors.ts +62 -0
- package/src/cli/selfUpdate.ts +59 -0
- package/src/cli/signer.ts +38 -0
- package/src/index.ts +31 -4
- package/src/portal/__tests__/releaseMetadata.test.ts +508 -0
- package/src/portal/__tests__/translators.test.ts +82 -0
- package/src/portal/__tests__/workflowClient.test.ts +278 -0
- package/src/portal/attestationClient.ts +19 -0
- package/src/portal/files.ts +73 -0
- package/src/portal/http.ts +170 -0
- package/src/portal/records.ts +38 -0
- package/src/portal/releaseMetadata.ts +489 -0
- package/src/portal/translators.ts +750 -0
- package/src/portal/types.ts +27 -0
- package/src/portal/workflowClient.ts +575 -0
- package/src/publication/PublicationProgressReporter.ts +1026 -0
- package/src/publication/__tests__/PublicationProgressReporter.test.ts +210 -0
- package/src/publication/__tests__/fundingPreflight.test.ts +78 -0
- package/src/publication/__tests__/publicationSummary.test.ts +30 -0
- package/src/publication/cliValidation.ts +264 -0
- package/src/publication/fundingPreflight.ts +123 -0
- package/src/publication/publicationSummary.ts +26 -0
- package/src/publication/runPublicationWorkflow.ts +46 -0
- package/lib/commands/create/CreateCliApp.js +0 -223
- package/lib/commands/create/CreateCliRelease.js +0 -290
- package/lib/commands/create/index.js +0 -40
- package/lib/commands/index.js +0 -3
- package/lib/commands/publish/PublishCliSubmit.js +0 -208
- package/lib/commands/publish/PublishCliUpdate.js +0 -211
- package/lib/commands/publish/index.js +0 -22
- package/lib/commands/scaffolding/ScaffoldInit.js +0 -15
- package/lib/commands/scaffolding/index.js +0 -1
- package/lib/config/EnvVariables.js +0 -59
- package/lib/config/PublishDetails.js +0 -915
- package/lib/config/S3StorageManager.js +0 -93
- package/lib/config/index.js +0 -2
- package/lib/generated/config_obj.json +0 -1
- package/lib/generated/config_schema.json +0 -1
- package/lib/prebuild_schema/publishing_source.yaml +0 -64
- package/lib/prebuild_schema/schemagen.js +0 -25
- package/lib/upload/CachedStorageDriver.js +0 -293
- package/lib/upload/TurboStorageDriver.js +0 -718
- package/lib/upload/index.js +0 -2
- package/src/commands/ValidateCommand.ts +0 -82
- package/src/commands/create/CreateCliApp.ts +0 -93
- package/src/commands/create/CreateCliRelease.ts +0 -149
- package/src/commands/create/index.ts +0 -47
- package/src/commands/index.ts +0 -3
- package/src/commands/publish/PublishCliRemove.ts +0 -66
- package/src/commands/publish/PublishCliSubmit.ts +0 -93
- package/src/commands/publish/PublishCliSupport.ts +0 -66
- package/src/commands/publish/PublishCliUpdate.ts +0 -101
- package/src/commands/publish/index.ts +0 -29
- package/src/commands/scaffolding/ScaffoldInit.ts +0 -20
- package/src/commands/scaffolding/index.ts +0 -1
- package/src/commands/utils.ts +0 -33
- package/src/config/EnvVariables.ts +0 -39
- package/src/config/PublishDetails.ts +0 -456
- package/src/config/S3StorageManager.ts +0 -47
- package/src/config/index.ts +0 -2
- package/src/prebuild_schema/publishing_source.yaml +0 -64
- package/src/prebuild_schema/schemagen.js +0 -31
- package/src/upload/CachedStorageDriver.ts +0 -99
- package/src/upload/TurboStorageDriver.ts +0 -277
- package/src/upload/index.ts +0 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export function ensureHttpsUrl(url) {
|
|
2
|
+
var trimmed = url.trim();
|
|
3
|
+
if (!trimmed) {
|
|
4
|
+
return trimmed;
|
|
5
|
+
}
|
|
6
|
+
if (trimmed.startsWith("https://")) {
|
|
7
|
+
return trimmed;
|
|
8
|
+
}
|
|
9
|
+
if (trimmed.startsWith("http://")) {
|
|
10
|
+
return trimmed.replace(/^http:\/\//, "https://");
|
|
11
|
+
}
|
|
12
|
+
return "https://".concat(trimmed);
|
|
13
|
+
}
|
|
14
|
+
export function inferFileNameFromUrl(url) {
|
|
15
|
+
try {
|
|
16
|
+
var pathname = new URL(url).pathname;
|
|
17
|
+
var basename = pathname.split("/").filter(Boolean).pop();
|
|
18
|
+
return basename || "app-release.apk";
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return "app-release.apk";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function inferFileExtension(fileName) {
|
|
24
|
+
var _fileName_split_pop;
|
|
25
|
+
var extension = ((_fileName_split_pop = fileName.split(".").pop()) === null || _fileName_split_pop === void 0 ? void 0 : _fileName_split_pop.trim().toLowerCase()) || "apk";
|
|
26
|
+
return extension.replace(/[^a-z0-9]/g, "") || "apk";
|
|
27
|
+
}
|
|
28
|
+
export function ensureApkFileName(fileName) {
|
|
29
|
+
return /\.apk$/i.test(fileName) ? fileName : "".concat(fileName, ".apk");
|
|
30
|
+
}
|
|
31
|
+
export function inferMimeType(fileName) {
|
|
32
|
+
var extension = inferFileExtension(fileName);
|
|
33
|
+
switch(extension){
|
|
34
|
+
case "apk":
|
|
35
|
+
return "application/vnd.android.package-archive";
|
|
36
|
+
case "json":
|
|
37
|
+
return "application/json";
|
|
38
|
+
case "png":
|
|
39
|
+
return "image/png";
|
|
40
|
+
case "jpg":
|
|
41
|
+
case "jpeg":
|
|
42
|
+
return "image/jpeg";
|
|
43
|
+
case "webp":
|
|
44
|
+
return "image/webp";
|
|
45
|
+
case "gif":
|
|
46
|
+
return "image/gif";
|
|
47
|
+
case "svg":
|
|
48
|
+
return "image/svg+xml";
|
|
49
|
+
case "mp4":
|
|
50
|
+
return "video/mp4";
|
|
51
|
+
case "webm":
|
|
52
|
+
return "video/webm";
|
|
53
|
+
case "mov":
|
|
54
|
+
return "video/quicktime";
|
|
55
|
+
default:
|
|
56
|
+
return "application/octet-stream";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function toBase64(buffer) {
|
|
60
|
+
return Buffer.from(buffer).toString("base64");
|
|
61
|
+
}
|
|
62
|
+
export function fromBase64(value) {
|
|
63
|
+
return new Uint8Array(Buffer.from(value, "base64"));
|
|
64
|
+
}
|
|
@@ -0,0 +1,364 @@
|
|
|
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 _instanceof(left, right) {
|
|
31
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
32
|
+
return !!right[Symbol.hasInstance](left);
|
|
33
|
+
} else {
|
|
34
|
+
return left instanceof right;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function _type_of(obj) {
|
|
38
|
+
"@swc/helpers - typeof";
|
|
39
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
40
|
+
}
|
|
41
|
+
function _ts_generator(thisArg, body) {
|
|
42
|
+
var f, y, t, _ = {
|
|
43
|
+
label: 0,
|
|
44
|
+
sent: function() {
|
|
45
|
+
if (t[0] & 1) throw t[1];
|
|
46
|
+
return t[1];
|
|
47
|
+
},
|
|
48
|
+
trys: [],
|
|
49
|
+
ops: []
|
|
50
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
51
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
52
|
+
return this;
|
|
53
|
+
}), g;
|
|
54
|
+
function verb(n) {
|
|
55
|
+
return function(v) {
|
|
56
|
+
return step([
|
|
57
|
+
n,
|
|
58
|
+
v
|
|
59
|
+
]);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function step(op) {
|
|
63
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
64
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
65
|
+
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;
|
|
66
|
+
if (y = 0, t) op = [
|
|
67
|
+
op[0] & 2,
|
|
68
|
+
t.value
|
|
69
|
+
];
|
|
70
|
+
switch(op[0]){
|
|
71
|
+
case 0:
|
|
72
|
+
case 1:
|
|
73
|
+
t = op;
|
|
74
|
+
break;
|
|
75
|
+
case 4:
|
|
76
|
+
_.label++;
|
|
77
|
+
return {
|
|
78
|
+
value: op[1],
|
|
79
|
+
done: false
|
|
80
|
+
};
|
|
81
|
+
case 5:
|
|
82
|
+
_.label++;
|
|
83
|
+
y = op[1];
|
|
84
|
+
op = [
|
|
85
|
+
0
|
|
86
|
+
];
|
|
87
|
+
continue;
|
|
88
|
+
case 7:
|
|
89
|
+
op = _.ops.pop();
|
|
90
|
+
_.trys.pop();
|
|
91
|
+
continue;
|
|
92
|
+
default:
|
|
93
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
94
|
+
_ = 0;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
98
|
+
_.label = op[1];
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
102
|
+
_.label = t[1];
|
|
103
|
+
t = op;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
if (t && _.label < t[2]) {
|
|
107
|
+
_.label = t[2];
|
|
108
|
+
_.ops.push(op);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (t[2]) _.ops.pop();
|
|
112
|
+
_.trys.pop();
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
op = body.call(thisArg, _);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
op = [
|
|
118
|
+
6,
|
|
119
|
+
e
|
|
120
|
+
];
|
|
121
|
+
y = 0;
|
|
122
|
+
} finally{
|
|
123
|
+
f = t = 0;
|
|
124
|
+
}
|
|
125
|
+
if (op[0] & 5) throw op[1];
|
|
126
|
+
return {
|
|
127
|
+
value: op[0] ? op[1] : void 0,
|
|
128
|
+
done: true
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function _ts_values(o) {
|
|
133
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
134
|
+
if (m) return m.call(o);
|
|
135
|
+
if (o && typeof o.length === "number") return {
|
|
136
|
+
next: function() {
|
|
137
|
+
if (o && i >= o.length) o = void 0;
|
|
138
|
+
return {
|
|
139
|
+
value: o && o[i++],
|
|
140
|
+
done: !o
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
145
|
+
}
|
|
146
|
+
import { isRecord, readDeep } from './records.js';
|
|
147
|
+
function unwrapPortalResult(result, fallbackMessage) {
|
|
148
|
+
if (isRecord(result) && '_tag' in result) {
|
|
149
|
+
var tagged = result;
|
|
150
|
+
if (tagged._tag === 'Left') {
|
|
151
|
+
throw new Error(tagged.left.message || fallbackMessage);
|
|
152
|
+
}
|
|
153
|
+
return tagged.right;
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
export function callPortalProcedure(config, procedure, input) {
|
|
158
|
+
var method = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 'mutation';
|
|
159
|
+
return _async_to_generator(function() {
|
|
160
|
+
var baseUrl, url, headers, response, text, payload, preview, normalizedPayload, error, nested, left, _readDeep, result;
|
|
161
|
+
return _ts_generator(this, function(_state) {
|
|
162
|
+
switch(_state.label){
|
|
163
|
+
case 0:
|
|
164
|
+
baseUrl = config.apiBaseUrl.replace(/\/$/, '');
|
|
165
|
+
url = new URL("".concat(baseUrl, "/trpc/").concat(procedure));
|
|
166
|
+
headers = {
|
|
167
|
+
accept: 'application/json',
|
|
168
|
+
'x-api-key': config.apiKey
|
|
169
|
+
};
|
|
170
|
+
if (!(method === 'query')) return [
|
|
171
|
+
3,
|
|
172
|
+
2
|
|
173
|
+
];
|
|
174
|
+
if (input !== undefined) {
|
|
175
|
+
url.searchParams.set('input', JSON.stringify(input));
|
|
176
|
+
}
|
|
177
|
+
return [
|
|
178
|
+
4,
|
|
179
|
+
fetch(url, {
|
|
180
|
+
method: 'GET',
|
|
181
|
+
headers: headers
|
|
182
|
+
})
|
|
183
|
+
];
|
|
184
|
+
case 1:
|
|
185
|
+
response = _state.sent();
|
|
186
|
+
return [
|
|
187
|
+
3,
|
|
188
|
+
4
|
|
189
|
+
];
|
|
190
|
+
case 2:
|
|
191
|
+
headers['content-type'] = 'application/json';
|
|
192
|
+
return [
|
|
193
|
+
4,
|
|
194
|
+
fetch(url, {
|
|
195
|
+
method: 'POST',
|
|
196
|
+
headers: headers,
|
|
197
|
+
body: input === undefined ? undefined : JSON.stringify(input)
|
|
198
|
+
})
|
|
199
|
+
];
|
|
200
|
+
case 3:
|
|
201
|
+
response = _state.sent();
|
|
202
|
+
_state.label = 4;
|
|
203
|
+
case 4:
|
|
204
|
+
return [
|
|
205
|
+
4,
|
|
206
|
+
response.text()
|
|
207
|
+
];
|
|
208
|
+
case 5:
|
|
209
|
+
text = _state.sent();
|
|
210
|
+
try {
|
|
211
|
+
payload = text.length > 0 ? JSON.parse(text) : null;
|
|
212
|
+
} catch (e) {
|
|
213
|
+
preview = text.replace(/\s+/g, ' ').trim().slice(0, 180) || '[empty]';
|
|
214
|
+
throw new Error("Failed to parse portal response from ".concat(procedure, ": ").concat(preview));
|
|
215
|
+
}
|
|
216
|
+
normalizedPayload = isRecord(payload) && '0' in payload ? payload['0'] : payload;
|
|
217
|
+
if (!response.ok) {
|
|
218
|
+
if (isRecord(normalizedPayload)) {
|
|
219
|
+
error = readDeep(normalizedPayload, 'error.message');
|
|
220
|
+
if (typeof error === 'string' && error.length > 0) {
|
|
221
|
+
throw new Error("".concat(procedure, ": ").concat(error));
|
|
222
|
+
}
|
|
223
|
+
nested = readDeep(normalizedPayload, 'result.data');
|
|
224
|
+
if (isRecord(nested) && nested._tag === 'Left') {
|
|
225
|
+
left = nested;
|
|
226
|
+
if (left.left.message) {
|
|
227
|
+
throw new Error("".concat(procedure, ": ").concat(left.left.message));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
throw new Error("".concat(procedure, ": Portal request failed with status ").concat(response.status));
|
|
232
|
+
}
|
|
233
|
+
result = (_readDeep = readDeep(normalizedPayload, 'result.data')) !== null && _readDeep !== void 0 ? _readDeep : readDeep(normalizedPayload, 'result');
|
|
234
|
+
return [
|
|
235
|
+
2,
|
|
236
|
+
unwrapPortalResult(result, "Portal request failed for ".concat(procedure))
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
})();
|
|
241
|
+
}
|
|
242
|
+
function isRetryableCreateIngestionSessionError(error) {
|
|
243
|
+
var message = _instanceof(error, Error) ? error.message.toLowerCase() : String(error).toLowerCase();
|
|
244
|
+
return message.includes('failed to parse portal response from publication.createingestionsession') || message.includes('gateway timeout') || message.includes('bad gateway') || message.includes('service unavailable') || message.includes('unexpected token <');
|
|
245
|
+
}
|
|
246
|
+
export function callCreateIngestionSessionWithRetry(config, input) {
|
|
247
|
+
return _async_to_generator(function() {
|
|
248
|
+
var _loop, lastError, attempt, _ret;
|
|
249
|
+
return _ts_generator(this, function(_state) {
|
|
250
|
+
switch(_state.label){
|
|
251
|
+
case 0:
|
|
252
|
+
_loop = function(attempt) {
|
|
253
|
+
var _tmp, error;
|
|
254
|
+
return _ts_generator(this, function(_state) {
|
|
255
|
+
switch(_state.label){
|
|
256
|
+
case 0:
|
|
257
|
+
_state.trys.push([
|
|
258
|
+
0,
|
|
259
|
+
2,
|
|
260
|
+
,
|
|
261
|
+
4
|
|
262
|
+
]);
|
|
263
|
+
_tmp = {};
|
|
264
|
+
return [
|
|
265
|
+
4,
|
|
266
|
+
callPortalProcedure(config, 'publication.createIngestionSession', input, 'mutation')
|
|
267
|
+
];
|
|
268
|
+
case 1:
|
|
269
|
+
return [
|
|
270
|
+
2,
|
|
271
|
+
(_tmp.v = _state.sent(), _tmp)
|
|
272
|
+
];
|
|
273
|
+
case 2:
|
|
274
|
+
error = _state.sent();
|
|
275
|
+
lastError = error;
|
|
276
|
+
if (!isRetryableCreateIngestionSessionError(error) || attempt === 2) {
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
return [
|
|
280
|
+
4,
|
|
281
|
+
new Promise(function(resolve) {
|
|
282
|
+
return setTimeout(resolve, 1500 * (attempt + 1));
|
|
283
|
+
})
|
|
284
|
+
];
|
|
285
|
+
case 3:
|
|
286
|
+
_state.sent();
|
|
287
|
+
return [
|
|
288
|
+
3,
|
|
289
|
+
4
|
|
290
|
+
];
|
|
291
|
+
case 4:
|
|
292
|
+
return [
|
|
293
|
+
2
|
|
294
|
+
];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
attempt = 0;
|
|
299
|
+
_state.label = 1;
|
|
300
|
+
case 1:
|
|
301
|
+
if (!(attempt < 3)) return [
|
|
302
|
+
3,
|
|
303
|
+
4
|
|
304
|
+
];
|
|
305
|
+
return [
|
|
306
|
+
5,
|
|
307
|
+
_ts_values(_loop(attempt))
|
|
308
|
+
];
|
|
309
|
+
case 2:
|
|
310
|
+
_ret = _state.sent();
|
|
311
|
+
if (_type_of(_ret) === "object") return [
|
|
312
|
+
2,
|
|
313
|
+
_ret.v
|
|
314
|
+
];
|
|
315
|
+
_state.label = 3;
|
|
316
|
+
case 3:
|
|
317
|
+
attempt += 1;
|
|
318
|
+
return [
|
|
319
|
+
3,
|
|
320
|
+
1
|
|
321
|
+
];
|
|
322
|
+
case 4:
|
|
323
|
+
throw _instanceof(lastError, Error) ? lastError : new Error('Failed to create ingestion session');
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
})();
|
|
327
|
+
}
|
|
328
|
+
export function uploadBytes(uploadUrl, body, contentType) {
|
|
329
|
+
return _async_to_generator(function() {
|
|
330
|
+
var response, preview;
|
|
331
|
+
return _ts_generator(this, function(_state) {
|
|
332
|
+
switch(_state.label){
|
|
333
|
+
case 0:
|
|
334
|
+
return [
|
|
335
|
+
4,
|
|
336
|
+
fetch(uploadUrl, {
|
|
337
|
+
method: 'PUT',
|
|
338
|
+
headers: {
|
|
339
|
+
'content-type': contentType
|
|
340
|
+
},
|
|
341
|
+
body: body
|
|
342
|
+
})
|
|
343
|
+
];
|
|
344
|
+
case 1:
|
|
345
|
+
response = _state.sent();
|
|
346
|
+
if (!!response.ok) return [
|
|
347
|
+
3,
|
|
348
|
+
3
|
|
349
|
+
];
|
|
350
|
+
return [
|
|
351
|
+
4,
|
|
352
|
+
response.text()
|
|
353
|
+
];
|
|
354
|
+
case 2:
|
|
355
|
+
preview = _state.sent().replace(/\s+/g, ' ').trim();
|
|
356
|
+
throw new Error("Failed to upload file to the portal: ".concat(preview || response.statusText));
|
|
357
|
+
case 3:
|
|
358
|
+
return [
|
|
359
|
+
2
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
})();
|
|
364
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _type_of(obj) {
|
|
2
|
+
"@swc/helpers - typeof";
|
|
3
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
+
}
|
|
5
|
+
export function isRecord(value) {
|
|
6
|
+
return (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null;
|
|
7
|
+
}
|
|
8
|
+
export function asRecord(value) {
|
|
9
|
+
return isRecord(value) ? value : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function readDeep(value, propertyPath) {
|
|
12
|
+
var parts = propertyPath.split('.');
|
|
13
|
+
var current = value;
|
|
14
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
15
|
+
try {
|
|
16
|
+
for(var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
17
|
+
var part = _step.value;
|
|
18
|
+
if (!isRecord(current)) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
current = current[part];
|
|
22
|
+
}
|
|
23
|
+
} catch (err) {
|
|
24
|
+
_didIteratorError = true;
|
|
25
|
+
_iteratorError = err;
|
|
26
|
+
} finally{
|
|
27
|
+
try {
|
|
28
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
29
|
+
_iterator.return();
|
|
30
|
+
}
|
|
31
|
+
} finally{
|
|
32
|
+
if (_didIteratorError) {
|
|
33
|
+
throw _iteratorError;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return current;
|
|
38
|
+
}
|
|
39
|
+
export function firstString(value, paths) {
|
|
40
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
41
|
+
try {
|
|
42
|
+
for(var _iterator = paths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
43
|
+
var propertyPath = _step.value;
|
|
44
|
+
var candidate = readDeep(value, propertyPath);
|
|
45
|
+
if (typeof candidate === 'string' && candidate.trim().length > 0) {
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} catch (err) {
|
|
50
|
+
_didIteratorError = true;
|
|
51
|
+
_iteratorError = err;
|
|
52
|
+
} finally{
|
|
53
|
+
try {
|
|
54
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
55
|
+
_iterator.return();
|
|
56
|
+
}
|
|
57
|
+
} finally{
|
|
58
|
+
if (_didIteratorError) {
|
|
59
|
+
throw _iteratorError;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|