zephyr-agent 0.0.0-canary-20241122025316 → 0.0.0-canary-20241122175815
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/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/edge-actions/ze-upload-assets.js +1 -5
- package/dist/lib/edge-actions/ze-upload-assets.js.map +1 -1
- package/dist/lib/http/upload-file.js +30 -71
- package/dist/lib/http/upload-file.js.map +1 -1
- package/dist/lib/http/ze-http-request.d.ts +2 -2
- package/dist/lib/http/ze-http-request.js +96 -87
- package/dist/lib/http/ze-http-request.js.map +1 -1
- package/dist/package.json +4 -5
- package/dist/zephyr-engine/resolve_remote_dependency.js +4 -0
- package/dist/zephyr-engine/resolve_remote_dependency.js.map +1 -1
- package/package.json +6 -7
package/dist/index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export { get_missing_assets } from './lib/edge-hash-list/get-missing-assets';
|
|
|
12
12
|
export * from './lib/logging/picocolor';
|
|
13
13
|
export { verify_mf_config, verify_fastly_config, } from './lib/build-context/ze-util-verification';
|
|
14
14
|
export { resolve_remote_dependency } from './zephyr-engine/resolve_remote_dependency';
|
|
15
|
+
export { getAppDeployResult, setAppDeployResult, } from './lib/node-persist/app-deploy-result-cache';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolve_remote_dependency = exports.verify_fastly_config = exports.verify_mf_config = exports.get_missing_assets = exports.is_zephyr_dependency_pair = exports.ZephyrEngine = exports.zeBuildAssets = exports.zeBuildDashData = exports.buildAssetsMap = exports.logFn = exports.ze_log = exports.ZeErrors = exports.ZephyrError = exports.savePartialAssetMap = exports.removePartialAssetMap = exports.getPartialAssetMap = exports.resolveIndexHtml = exports.onIndexHtmlResolved = void 0;
|
|
3
|
+
exports.setAppDeployResult = exports.getAppDeployResult = exports.resolve_remote_dependency = exports.verify_fastly_config = exports.verify_mf_config = exports.get_missing_assets = exports.is_zephyr_dependency_pair = exports.ZephyrEngine = exports.zeBuildAssets = exports.zeBuildDashData = exports.buildAssetsMap = exports.logFn = exports.ze_log = exports.ZeErrors = exports.ZephyrError = exports.savePartialAssetMap = exports.removePartialAssetMap = exports.getPartialAssetMap = exports.resolveIndexHtml = exports.onIndexHtmlResolved = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// hack for angular
|
|
6
6
|
var resolve_index_html_1 = require("./lib/hacks/resolve-index-html");
|
|
@@ -40,4 +40,7 @@ Object.defineProperty(exports, "verify_mf_config", { enumerable: true, get: func
|
|
|
40
40
|
Object.defineProperty(exports, "verify_fastly_config", { enumerable: true, get: function () { return ze_util_verification_1.verify_fastly_config; } });
|
|
41
41
|
var resolve_remote_dependency_1 = require("./zephyr-engine/resolve_remote_dependency");
|
|
42
42
|
Object.defineProperty(exports, "resolve_remote_dependency", { enumerable: true, get: function () { return resolve_remote_dependency_1.resolve_remote_dependency; } });
|
|
43
|
+
var app_deploy_result_cache_1 = require("./lib/node-persist/app-deploy-result-cache");
|
|
44
|
+
Object.defineProperty(exports, "getAppDeployResult", { enumerable: true, get: function () { return app_deploy_result_cache_1.getAppDeployResult; } });
|
|
45
|
+
Object.defineProperty(exports, "setAppDeployResult", { enumerable: true, get: function () { return app_deploy_result_cache_1.setAppDeployResult; } });
|
|
43
46
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mBAAmB;AACnB,qEAAuF;AAA9E,yHAAA,mBAAmB,OAAA;AAAE,sHAAA,gBAAgB,OAAA;AAC9C,sBAAsB;AACtB,4EAI+C;AAH7C,wHAAA,kBAAkB,OAAA;AAClB,2HAAA,qBAAqB,OAAA;AACrB,yH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,YAAY,OAAA;AACZ,0HAAA,yBAAyB,OAAA;AAK3B,6CAA6C;AAC7C,8EAA6E;AAApE,wHAAA,kBAAkB,OAAA;AAC3B,kEAAwC;AACxC,iFAGkD;AAFhD,wHAAA,gBAAgB,OAAA;AAChB,4HAAA,oBAAoB,OAAA;AAEtB,uFAAsF;AAA7E,sIAAA,yBAAyB,OAAA;AAClC,sFAGoD;AAFlD,6HAAA,kBAAkB,OAAA;AAClB,6HAAA,kBAAkB,OAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zeUploadAssets = void 0;
|
|
4
|
-
const get_application_configuration_1 = require("../edge-requests/get-application-configuration");
|
|
5
4
|
const upload_file_1 = require("../http/upload-file");
|
|
6
5
|
const picocolor_1 = require("../logging/picocolor");
|
|
7
6
|
const logging_1 = require("../logging");
|
|
@@ -9,7 +8,7 @@ const CLOUDFLARE_BATCH_SIZE = 6;
|
|
|
9
8
|
async function zeUploadAssets(zephyr_engine, { missingAssets, assetsMap }) {
|
|
10
9
|
const count = Object.keys(assetsMap).length;
|
|
11
10
|
const logger = await zephyr_engine.logger;
|
|
12
|
-
const
|
|
11
|
+
const appConfig = await zephyr_engine.application_configuration;
|
|
13
12
|
if (missingAssets.length === 0) {
|
|
14
13
|
logger({
|
|
15
14
|
level: 'info',
|
|
@@ -20,9 +19,6 @@ async function zeUploadAssets(zephyr_engine, { missingAssets, assetsMap }) {
|
|
|
20
19
|
}
|
|
21
20
|
const start = Date.now();
|
|
22
21
|
let totalSize = 0;
|
|
23
|
-
const appConfig = await (0, get_application_configuration_1.getApplicationConfiguration)({
|
|
24
|
-
application_uid,
|
|
25
|
-
});
|
|
26
22
|
// If the target is iOS or Android, we upload the assets in a 6 request batch to avoid cloudflare worker requests limit
|
|
27
23
|
// Reference: https://developers.cloudflare.com/workers/platform/limits/#simultaneous-open-connections:~:text=Once%20an%20invocation%20has%20six%20connections%20open%2C%20it%20can%20still%20attempt%20to%20open%20additional%20connections.
|
|
28
24
|
if (zephyr_engine.env.target !== 'ios' && zephyr_engine.env.target !== 'android') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ze-upload-assets.js","sourceRoot":"","sources":["../../../src/lib/edge-actions/ze-upload-assets.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ze-upload-assets.js","sourceRoot":"","sources":["../../../src/lib/edge-actions/ze-upload-assets.ts"],"names":[],"mappings":";;;AAEA,qDAAiD;AAEjD,oDAA0D;AAC1D,wCAAoC;AAEpC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEzB,KAAK,UAAU,cAAc,CAClC,aAA2B,EAC3B,EAAE,aAAa,EAAE,SAAS,EAAyB;IAEnD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC;IAC1C,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,yBAAyB,CAAC;IAEhE,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC;YACL,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,8BAA8B;YACtC,OAAO,EAAE,wBAAwB,IAAA,iBAAK,EAAC,UAAU,CAAC,KAAK;SACxD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,uHAAuH;IACvH,6OAA6O;IAC7O,IAAI,aAAa,CAAC,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,aAAa,CAAC,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjF,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,oBAAoB,CA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IACJ,CAAC;IAED,KAAK,UAAU,aAAa,CAC1B,KAAU,EACV,SAAiB,EACjB,EAA2B;QAE3B,MAAM,OAAO,GAAQ,EAAE,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;YACjD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC;YAC5C,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AA/ED,wCA+EC"}
|
|
@@ -1,85 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uploadFile = void 0;
|
|
4
|
-
const errors_1 = require("../errors");
|
|
5
|
-
const logging_1 = require("../logging");
|
|
6
4
|
const ze_http_request_1 = require("./ze-http-request");
|
|
7
|
-
const
|
|
5
|
+
const errors_1 = require("../errors");
|
|
8
6
|
async function uploadFile({ hash, asset }, { EDGE_URL, jwt }) {
|
|
9
7
|
const type = 'file';
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!ok) {
|
|
33
|
-
// Because of `ctx.waitUntil`, the worker will continue to upload the files even if the request failed, and if we immediately throw an error the local process will be terminated, we try again here to at least have another level of effort to continue local process.
|
|
34
|
-
try {
|
|
35
|
-
(0, logging_1.ze_log)(`Failed on first time...trying to upload chunk ${chunkIndex} of file ${asset.path} of total ${totalChunks} chunks...`);
|
|
36
|
-
const [retryOk, retryCause] = await ze_http_request_1.ZeHttpRequest.from({
|
|
37
|
-
path: '/upload',
|
|
38
|
-
base: EDGE_URL,
|
|
39
|
-
query: { type, hash, filename: asset.path },
|
|
40
|
-
}, options, chunk);
|
|
41
|
-
if (!retryOk) {
|
|
42
|
-
try {
|
|
43
|
-
(0, logging_1.ze_log)(`Second time...Trying to upload chunk ${chunkIndex} of file ${asset.path} of total ${totalChunks} chunks...`);
|
|
44
|
-
await ze_http_request_1.ZeHttpRequest.from({
|
|
45
|
-
path: '/upload',
|
|
46
|
-
base: EDGE_URL,
|
|
47
|
-
query: { type, hash, filename: asset.path },
|
|
48
|
-
}, options, chunk);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_FAILED_UPLOAD, {
|
|
52
|
-
type: 'file',
|
|
53
|
-
cause: error,
|
|
54
|
-
data: {
|
|
55
|
-
chunkIndex,
|
|
56
|
-
totalChunks,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_FAILED_UPLOAD, {
|
|
61
|
-
type: 'file',
|
|
62
|
-
cause: retryCause,
|
|
63
|
-
data: {
|
|
64
|
-
chunkIndex,
|
|
65
|
-
totalChunks,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: {
|
|
11
|
+
'x-file-size': asset.size.toString(),
|
|
12
|
+
'x-file-path': asset.path,
|
|
13
|
+
can_write_jwt: jwt,
|
|
14
|
+
'Content-Type': 'application/octet-stream',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const [ok, cause] = await ze_http_request_1.ZeHttpRequest.from({
|
|
18
|
+
path: '/upload',
|
|
19
|
+
base: EDGE_URL,
|
|
20
|
+
query: { type, hash, filename: asset.path },
|
|
21
|
+
}, options, asset.buffer);
|
|
22
|
+
if (!ok) {
|
|
23
|
+
try {
|
|
24
|
+
const [ok2, cause2] = await ze_http_request_1.ZeHttpRequest.from({
|
|
25
|
+
path: '/upload',
|
|
26
|
+
base: EDGE_URL,
|
|
27
|
+
query: { type, hash, filename: asset.path },
|
|
28
|
+
}, options, asset.buffer);
|
|
29
|
+
if (!ok2) {
|
|
71
30
|
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_FAILED_UPLOAD, {
|
|
72
31
|
type: 'file',
|
|
73
|
-
cause,
|
|
74
|
-
data: {
|
|
75
|
-
error,
|
|
76
|
-
chunkIndex,
|
|
77
|
-
totalChunks,
|
|
78
|
-
},
|
|
32
|
+
cause: cause2,
|
|
79
33
|
});
|
|
80
34
|
}
|
|
81
35
|
}
|
|
82
|
-
(
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_FAILED_UPLOAD, {
|
|
38
|
+
type: 'file',
|
|
39
|
+
cause,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
83
42
|
}
|
|
84
43
|
}
|
|
85
44
|
exports.uploadFile = uploadFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../../src/lib/http/upload-file.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../../src/lib/http/upload-file.ts"],"names":[],"mappings":";;;AAGA,uDAAkD;AAClD,sCAAkD;AAO3C,KAAK,UAAU,UAAU,CAC9B,EAAE,IAAI,EAAE,KAAK,EAAmB,EAChC,EAAE,QAAQ,EAAE,GAAG,EAAuB;IAEtC,MAAM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6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import
|
|
3
|
+
import { ClientRequestArgs } from 'node:http';
|
|
4
4
|
/** Http request wrapper that returns a tuple with the response data or an error. */
|
|
5
5
|
export type HttpResponse<T> = [ok: true, error: null, data: T] | [ok: false, error: Error];
|
|
6
6
|
export type UrlString = string | URL | {
|
|
@@ -11,9 +11,9 @@ export type UrlString = string | URL | {
|
|
|
11
11
|
/** Starts a new http request */
|
|
12
12
|
export declare class ZeHttpRequest<T = void> implements PromiseLike<HttpResponse<T>> {
|
|
13
13
|
#private;
|
|
14
|
+
then: <TResult1 = HttpResponse<T>, TResult2 = never>(onfulfilled?: ((value: HttpResponse<T>) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
|
|
14
15
|
/** Creates a new http request. */
|
|
15
16
|
static from<T = void>(urlStr: UrlString, options?: ClientRequestArgs, data?: string | Buffer): ZeHttpRequest<T>;
|
|
16
|
-
then: <TResult1 = HttpResponse<T>, TResult2 = never>(onfulfilled?: ((value: HttpResponse<T>) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
|
|
17
17
|
/** Transforms `Promise<HttpResponse<T>>` into `Promise<T>` */
|
|
18
18
|
unwrap(): Promise<T>;
|
|
19
19
|
}
|
|
@@ -1,15 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _ZeHttpRequest_instances, _ZeHttpRequest_start, _ZeHttpRequest_url, _ZeHttpRequest_options, _ZeHttpRequest_data, _ZeHttpRequest_promise, _ZeHttpRequest_reject, _ZeHttpRequest_resolve, _ZeHttpRequest_request,
|
|
2
|
+
var _ZeHttpRequest_instances, _ZeHttpRequest_start, _ZeHttpRequest_url, _ZeHttpRequest_options, _ZeHttpRequest_data, _ZeHttpRequest_promise, _ZeHttpRequest_reject, _ZeHttpRequest_resolve, _ZeHttpRequest_request, _ZeHttpRequest_redact;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.ZeHttpRequest = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const http = tslib_1.__importStar(require("node:http"));
|
|
7
|
-
const https = tslib_1.__importStar(require("node:https"));
|
|
8
|
-
const consumers_1 = require("node:stream/consumers");
|
|
9
6
|
const errors_1 = require("../errors");
|
|
10
7
|
const token_1 = require("../node-persist/token");
|
|
11
8
|
const debug_1 = require("../logging/debug");
|
|
12
9
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
10
|
+
async function fetchWithRetries(url, options = {}, retries = 3) {
|
|
11
|
+
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
12
|
+
try {
|
|
13
|
+
const response = await fetch(url, options);
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
16
|
+
}
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
const error = err;
|
|
21
|
+
if (attempt === retries) {
|
|
22
|
+
(0, debug_1.ze_log)('Max retries reached. Request failed:', error.message);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
if (error.code === 'EPIPE' || error.message.includes('network')) {
|
|
26
|
+
(0, debug_1.ze_log)(`Attempt ${attempt} failed due to network issue, retrying...`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
(0, debug_1.ze_log)(`Attempt ${attempt} failed with error:`, error.message);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
throw new Error('Network error: Max retries reached');
|
|
35
|
+
}
|
|
36
|
+
/** Converts ClientRequestArgs to RequestInit */
|
|
37
|
+
function convertClientRequestArgsToRequestInit(args) {
|
|
38
|
+
const { method, headers, timeout } = args, rest = tslib_1.__rest(args, ["method", "headers", "timeout"]);
|
|
39
|
+
const requestInit = Object.assign({ method, headers: headers }, rest);
|
|
40
|
+
if (timeout) {
|
|
41
|
+
requestInit.signal = AbortSignal.timeout(timeout);
|
|
42
|
+
}
|
|
43
|
+
return requestInit;
|
|
44
|
+
}
|
|
13
45
|
/** Starts a new http request */
|
|
14
46
|
class ZeHttpRequest {
|
|
15
47
|
constructor() {
|
|
@@ -26,87 +58,13 @@ class ZeHttpRequest {
|
|
|
26
58
|
_ZeHttpRequest_promise.set(this, (0, zephyr_edge_contract_1.PromiseWithResolvers)());
|
|
27
59
|
// promise extension
|
|
28
60
|
this.then = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_promise, "f").promise.then.bind(tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_promise, "f").promise);
|
|
29
|
-
/** Handles the error when the request fails. */
|
|
30
|
-
_ZeHttpRequest_onRequestError.set(this, (cause) => {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
if ('ERR_TLS_CERT_ALTNAME_INVALID' in cause) {
|
|
33
|
-
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_reject).call(this, new errors_1.ZephyrError(errors_1.ZeErrors.ERR_TLS_CERT_ALTNAME_INVALID, {
|
|
34
|
-
cause,
|
|
35
|
-
}));
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_reject).call(this, new errors_1.ZephyrError(errors_1.ZeErrors.ERR_HTTP_ERROR, {
|
|
39
|
-
url: tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").toString(),
|
|
40
|
-
method: (_b = (_a = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_options, "f").method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : 'GET',
|
|
41
|
-
content: 'Could not send request',
|
|
42
|
-
status: '-1',
|
|
43
|
-
cause,
|
|
44
|
-
}));
|
|
45
|
-
});
|
|
46
|
-
/** Handles the response from the server. */
|
|
47
|
-
_ZeHttpRequest_onResponse.set(this, (res) => {
|
|
48
|
-
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_onResponseAsync, "f").call(this, res).catch(tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_handleUnknownError, "f"));
|
|
49
|
-
});
|
|
50
|
-
_ZeHttpRequest_handleUnknownError.set(this, (cause) => {
|
|
51
|
-
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_reject).call(this, new errors_1.ZephyrError(errors_1.ZeErrors.ERR_UNKNOWN, {
|
|
52
|
-
message: 'Could not process provided http.IncomingMessage',
|
|
53
|
-
cause,
|
|
54
|
-
}));
|
|
55
|
-
});
|
|
56
|
-
_ZeHttpRequest_onResponseAsync.set(this, async (res) => {
|
|
57
|
-
var _a, _b, _c, _d, _e;
|
|
58
|
-
if (res.statusCode === 401) {
|
|
59
|
-
// Clean the tokens and throw an error
|
|
60
|
-
await (0, token_1.cleanTokens)();
|
|
61
|
-
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_AUTH_ERROR, {
|
|
62
|
-
message: 'Unauthenticated request',
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (res.statusCode === 403) {
|
|
66
|
-
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_AUTH_FORBIDDEN_ERROR, {
|
|
67
|
-
message: 'Unauthorized request',
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const tuple = await (0, zephyr_edge_contract_1.PromiseTuple)((0, consumers_1.text)(res));
|
|
71
|
-
if (!(0, zephyr_edge_contract_1.isSuccessTuple)(tuple)) {
|
|
72
|
-
return tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_onRequestError, "f").call(this, tuple[0]);
|
|
73
|
-
}
|
|
74
|
-
const resText = tuple[1];
|
|
75
|
-
const message = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_redact).call(this, resText);
|
|
76
|
-
if (message === 'Not Implemented') {
|
|
77
|
-
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_UNKNOWN, {
|
|
78
|
-
message: 'Not implemented yet. Please get in contact with our support.',
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (res.statusCode === undefined) {
|
|
82
|
-
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_HTTP_ERROR, {
|
|
83
|
-
content: 'No status code found',
|
|
84
|
-
method: (_b = (_a = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_options, "f").method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : 'GET',
|
|
85
|
-
url: tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").toString(),
|
|
86
|
-
status: -1,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (!tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").pathname.includes('application/logs')) {
|
|
90
|
-
(0, debug_1.ze_log)(message);
|
|
91
|
-
}
|
|
92
|
-
// Only parses data if reply content is json
|
|
93
|
-
const resData = (_c = (0, zephyr_edge_contract_1.safe_json_parse)(resText)) !== null && _c !== void 0 ? _c : resText;
|
|
94
|
-
if (res.statusCode >= 300) {
|
|
95
|
-
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_HTTP_ERROR, {
|
|
96
|
-
status: res.statusCode,
|
|
97
|
-
url: tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").toString(),
|
|
98
|
-
content: resData,
|
|
99
|
-
method: (_e = (_d = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_options, "f").method) === null || _d === void 0 ? void 0 : _d.toUpperCase()) !== null && _e !== void 0 ? _e : 'GET',
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_resolve).call(this, resData);
|
|
103
|
-
});
|
|
104
61
|
}
|
|
105
62
|
/** Creates a new http request. */
|
|
106
63
|
static from(urlStr, options = {}, data) {
|
|
107
64
|
const req = new ZeHttpRequest();
|
|
108
65
|
tslib_1.__classPrivateFieldSet(req, _ZeHttpRequest_data, data, "f");
|
|
109
|
-
|
|
66
|
+
// todo: convert incoming typings to RequestInit
|
|
67
|
+
tslib_1.__classPrivateFieldSet(req, _ZeHttpRequest_options, convertClientRequestArgsToRequestInit(options), "f");
|
|
110
68
|
// Parse the url into a URL object
|
|
111
69
|
if (typeof urlStr === 'string') {
|
|
112
70
|
tslib_1.__classPrivateFieldSet(req, _ZeHttpRequest_url, new URL(urlStr), "f");
|
|
@@ -140,16 +98,67 @@ class ZeHttpRequest {
|
|
|
140
98
|
}
|
|
141
99
|
}
|
|
142
100
|
exports.ZeHttpRequest = ZeHttpRequest;
|
|
143
|
-
_ZeHttpRequest_start = new WeakMap(), _ZeHttpRequest_url = new WeakMap(), _ZeHttpRequest_options = new WeakMap(), _ZeHttpRequest_data = new WeakMap(), _ZeHttpRequest_promise = new WeakMap(),
|
|
101
|
+
_ZeHttpRequest_start = new WeakMap(), _ZeHttpRequest_url = new WeakMap(), _ZeHttpRequest_options = new WeakMap(), _ZeHttpRequest_data = new WeakMap(), _ZeHttpRequest_promise = new WeakMap(), _ZeHttpRequest_instances = new WeakSet(), _ZeHttpRequest_reject = function _ZeHttpRequest_reject(error) {
|
|
144
102
|
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_promise, "f").resolve([false, error]);
|
|
145
103
|
}, _ZeHttpRequest_resolve = function _ZeHttpRequest_resolve(data) {
|
|
146
104
|
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_promise, "f").resolve([true, null, data]);
|
|
147
|
-
}, _ZeHttpRequest_request = function _ZeHttpRequest_request() {
|
|
148
|
-
var _a;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
105
|
+
}, _ZeHttpRequest_request = async function _ZeHttpRequest_request() {
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
107
|
+
try {
|
|
108
|
+
const response = await fetchWithRetries(tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f"), Object.assign(Object.assign({}, tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_options, "f")), { body: tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_data, "f") }));
|
|
109
|
+
if (!response) {
|
|
110
|
+
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_HTTP_ERROR, {
|
|
111
|
+
content: 'No response found',
|
|
112
|
+
method: (_b = (_a = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_options, "f").method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : 'GET',
|
|
113
|
+
url: tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").toString(),
|
|
114
|
+
status: -1,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const resText = await response.text();
|
|
118
|
+
if (response.status === 401) {
|
|
119
|
+
// Clean the tokens and throw an error
|
|
120
|
+
await (0, token_1.cleanTokens)();
|
|
121
|
+
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_AUTH_ERROR, {
|
|
122
|
+
message: 'Unauthenticated request',
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (response.status === 403) {
|
|
126
|
+
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_AUTH_FORBIDDEN_ERROR, {
|
|
127
|
+
message: 'Unauthorized request',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const message = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_redact).call(this, resText);
|
|
131
|
+
if (message === 'Not Implemented') {
|
|
132
|
+
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_UNKNOWN, {
|
|
133
|
+
message: 'Not implemented yet. Please get in contact with our support.',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (response.status === undefined) {
|
|
137
|
+
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_HTTP_ERROR, {
|
|
138
|
+
content: 'No status code found',
|
|
139
|
+
method: (_d = (_c = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_options, "f").method) === null || _c === void 0 ? void 0 : _c.toUpperCase()) !== null && _d !== void 0 ? _d : 'GET',
|
|
140
|
+
url: tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").toString(),
|
|
141
|
+
status: -1,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if (!tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").pathname.includes('application/logs')) {
|
|
145
|
+
(0, debug_1.ze_log)(message);
|
|
146
|
+
}
|
|
147
|
+
// Only parses data if reply content is json
|
|
148
|
+
const resData = (_e = (0, zephyr_edge_contract_1.safe_json_parse)(resText)) !== null && _e !== void 0 ? _e : resText;
|
|
149
|
+
if (response.status >= 300) {
|
|
150
|
+
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_HTTP_ERROR, {
|
|
151
|
+
status: response.status,
|
|
152
|
+
url: tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_url, "f").toString(),
|
|
153
|
+
content: resData,
|
|
154
|
+
method: (_g = (_f = tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_options, "f").method) === null || _f === void 0 ? void 0 : _f.toUpperCase()) !== null && _g !== void 0 ? _g : 'GET',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_resolve).call(this, resData);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
tslib_1.__classPrivateFieldGet(this, _ZeHttpRequest_instances, "m", _ZeHttpRequest_reject).call(this, error);
|
|
161
|
+
}
|
|
153
162
|
}, _ZeHttpRequest_redact = function _ZeHttpRequest_redact(response) {
|
|
154
163
|
var _a, _b;
|
|
155
164
|
const str = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ze-http-request.js","sourceRoot":"","sources":["../../../src/lib/http/ze-http-request.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"ze-http-request.js","sourceRoot":"","sources":["../../../src/lib/http/ze-http-request.ts"],"names":[],"mappings":";;;;;AAAA,sCAAkD;AAClD,iDAAoD;AACpD,4CAA0C;AAC1C,+DAM8B;AAG9B,KAAK,UAAU,gBAAgB,CAC7B,GAAQ,EACR,OAAO,GAAG,EAAE,EACZ,OAAO,GAAG,CAAC;IAEX,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;QACpD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,KAAK,GAAG,GAAU,CAAC;YACzB,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;gBACxB,IAAA,cAAM,EAAC,sCAAsC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC9D,MAAM,GAAG,CAAC;YACZ,CAAC;YACD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAChE,IAAA,cAAM,EAAC,WAAW,OAAO,2CAA2C,CAAC,CAAC;YACxE,CAAC;iBAAM,CAAC;gBACN,IAAA,cAAM,EAAC,WAAW,OAAO,qBAAq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"open": "^10.1.0",
|
|
31
32
|
"socket.io-client": "^4.7.5",
|
|
32
33
|
"tslib": "^2.6.3",
|
|
33
34
|
"uuid": "^8.3.2",
|
|
34
|
-
"node-persist": "^4.0.1",
|
|
35
|
-
"debug": "^4.3.4",
|
|
36
35
|
"zephyr-edge-contract": "workspace:*"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
38
|
+
"@types/debug": "^4.1.12",
|
|
39
39
|
"@types/git-url-parse": "^9.0.3",
|
|
40
40
|
"@types/is-ci": "^3.0.4",
|
|
41
|
-
"@types/uuid": "^9.0.8",
|
|
42
41
|
"@types/node-persist": "^3.1.8",
|
|
43
|
-
"@types/
|
|
42
|
+
"@types/uuid": "^9.0.8"
|
|
44
43
|
},
|
|
45
44
|
"optionalDependencies": {
|
|
46
45
|
"wrangler": "^3.69.1"
|
|
@@ -4,10 +4,13 @@ exports.resolve_remote_dependency = void 0;
|
|
|
4
4
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
5
5
|
const token_1 = require("../lib/node-persist/token");
|
|
6
6
|
const errors_1 = require("../lib/errors");
|
|
7
|
+
const logging_1 = require("../lib/logging");
|
|
7
8
|
async function resolve_remote_dependency({ application_uid, version, platform, }) {
|
|
8
9
|
const resolveDependency = new URL(`${zephyr_edge_contract_1.ze_api_gateway.resolve}/${encodeURIComponent(application_uid)}/${encodeURIComponent(version)}`, (0, zephyr_edge_contract_1.ZE_API_ENDPOINT)());
|
|
9
10
|
if (platform) {
|
|
11
|
+
(0, logging_1.ze_log)('adding build target to resolve dependency:', platform);
|
|
10
12
|
resolveDependency.searchParams.append('build_target', platform);
|
|
13
|
+
(0, logging_1.ze_log)('URL for resolving dependency:', resolveDependency.toString());
|
|
11
14
|
}
|
|
12
15
|
try {
|
|
13
16
|
const token = await (0, token_1.getToken)();
|
|
@@ -35,6 +38,7 @@ async function resolve_remote_dependency({ application_uid, version, platform, }
|
|
|
35
38
|
}
|
|
36
39
|
const response = await res.json();
|
|
37
40
|
if (response.value) {
|
|
41
|
+
(0, logging_1.ze_log)('resolved dependency:', response.value, 'application_uid: ', application_uid, 'version: ', version);
|
|
38
42
|
return Object.assign({}, response.value, { version });
|
|
39
43
|
}
|
|
40
44
|
throw new errors_1.ZephyrError(errors_1.ZeErrors.ERR_RESOLVE_REMOTES, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve_remote_dependency.js","sourceRoot":"","sources":["../../src/zephyr-engine/resolve_remote_dependency.ts"],"names":[],"mappings":";;;AAAA,+DAAuE;AACvE,qDAAqD;AACrD,0CAAsD;
|
|
1
|
+
{"version":3,"file":"resolve_remote_dependency.js","sourceRoot":"","sources":["../../src/zephyr-engine/resolve_remote_dependency.ts"],"names":[],"mappings":";;;AAAA,+DAAuE;AACvE,qDAAqD;AACrD,0CAAsD;AACtD,4CAAwC;AAYjC,KAAK,UAAU,yBAAyB,CAAC,EAC9C,eAAe,EACf,OAAO,EACP,QAAQ,GAKT;IACC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,GAAG,qCAAc,CAAC,OAAO,IAAI,kBAAkB,CAAC,eAAe,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,EACjG,IAAA,sCAAe,GAAE,CAClB,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACb,IAAA,gBAAM,EAAC,4CAA4C,EAAE,QAAQ,CAAC,CAAC;QAC/D,iBAAiB,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAChE,IAAA,gBAAM,EAAC,+BAA+B,EAAE,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAA,gBAAQ,GAAE,CAAC;QAE/B,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,iBAAiB,EAAE;YACzC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,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oBAAW,CAAC,iBAAQ,CAAC,wCAAwC,EAAE;YACvE,IAAI,EAAE,EAAE,OAAO,EAAE;YACjB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AA7ED,8DA6EC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zephyr-agent",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20241122175815",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,24 +18,23 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
21
|
+
"debug": "^4.3.4",
|
|
22
22
|
"git-url-parse": "^15.0.0",
|
|
23
23
|
"is-ci": "^3.0.1",
|
|
24
24
|
"jose": "^5.2.4",
|
|
25
|
+
"node-persist": "^4.0.1",
|
|
25
26
|
"open": "^10.1.0",
|
|
26
27
|
"socket.io-client": "^4.7.5",
|
|
27
28
|
"tslib": "^2.6.3",
|
|
28
29
|
"uuid": "^8.3.2",
|
|
29
|
-
"
|
|
30
|
-
"debug": "^4.3.4",
|
|
31
|
-
"zephyr-edge-contract": "0.0.0-canary-20241122025316"
|
|
30
|
+
"zephyr-edge-contract": "0.0.0-canary-20241122175815"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
33
|
+
"@types/debug": "^4.1.12",
|
|
34
34
|
"@types/git-url-parse": "^9.0.3",
|
|
35
35
|
"@types/is-ci": "^3.0.4",
|
|
36
|
-
"@types/uuid": "^9.0.8",
|
|
37
36
|
"@types/node-persist": "^3.1.8",
|
|
38
|
-
"@types/
|
|
37
|
+
"@types/uuid": "^9.0.8"
|
|
39
38
|
},
|
|
40
39
|
"optionalDependencies": {
|
|
41
40
|
"wrangler": "^3.69.1"
|