@ms-cloudpack/remote-cache 0.4.7 → 0.5.1-beta.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.
- package/dist/AzureRemoteCacheClient-2PRAPCJH.js +52049 -0
- package/dist/AzureRemoteCacheClient-2PRAPCJH.js.map +7 -0
- package/dist/ReporterDecorator-BYNXV72I.js +126 -0
- package/dist/ReporterDecorator-BYNXV72I.js.map +7 -0
- package/dist/chunk-G3ME7OWS.js +49567 -0
- package/dist/chunk-G3ME7OWS.js.map +7 -0
- package/dist/chunk-GFT2G5UO.js +50 -0
- package/dist/chunk-GFT2G5UO.js.map +7 -0
- package/dist/chunk-KKZU5JW4.js +1071 -0
- package/dist/chunk-KKZU5JW4.js.map +7 -0
- package/dist/chunk-VVROC42R.js +182 -0
- package/dist/chunk-VVROC42R.js.map +7 -0
- package/dist/chunk-XKOU5VXX.js +9 -0
- package/dist/chunk-XKOU5VXX.js.map +7 -0
- package/dist/getCredential-MJEIGDVB.js +23981 -0
- package/dist/getCredential-MJEIGDVB.js.map +7 -0
- package/dist/getListOfBlobs-LKU62UR5.js +26 -0
- package/dist/getListOfBlobs-LKU62UR5.js.map +7 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +7 -0
- package/lib/AzureRemoteCacheClient.d.ts +5 -5
- package/lib/decorators/InMemoryDecorator.d.ts +2 -2
- package/lib/decorators/InMemoryDecorator.test.d.ts +2 -0
- package/lib/decorators/ReporterDecorator.d.ts +2 -2
- package/lib/decorators/RetryDecorator.d.ts +2 -2
- package/lib/decorators/RetryDecorator.test.d.ts +2 -0
- package/lib/index.d.ts +1 -1
- package/lib/types/RemoteCacheClient.d.ts +12 -3
- package/package.json +13 -13
- package/lib/AzureRemoteCacheClient.d.ts.map +0 -1
- package/lib/AzureRemoteCacheClient.js +0 -51
- package/lib/AzureRemoteCacheClient.js.map +0 -1
- package/lib/Task.d.ts.map +0 -1
- package/lib/Task.js +0 -2
- package/lib/Task.js.map +0 -1
- package/lib/authentication/getAuthenticationRecord.d.ts.map +0 -1
- package/lib/authentication/getAuthenticationRecord.js +0 -17
- package/lib/authentication/getAuthenticationRecord.js.map +0 -1
- package/lib/authentication/getAuthenticationRecordPath.d.ts.map +0 -1
- package/lib/authentication/getAuthenticationRecordPath.js +0 -10
- package/lib/authentication/getAuthenticationRecordPath.js.map +0 -1
- package/lib/authentication/getCredential.d.ts.map +0 -1
- package/lib/authentication/getCredential.js +0 -61
- package/lib/authentication/getCredential.js.map +0 -1
- package/lib/authentication/saveAuthenticationRecord.d.ts.map +0 -1
- package/lib/authentication/saveAuthenticationRecord.js +0 -17
- package/lib/authentication/saveAuthenticationRecord.js.map +0 -1
- package/lib/cache-persistance/cachePersistencePlugin.d.ts.map +0 -1
- package/lib/cache-persistance/cachePersistencePlugin.js +0 -35
- package/lib/cache-persistance/cachePersistencePlugin.js.map +0 -1
- package/lib/cache-persistance/platforms.d.ts.map +0 -1
- package/lib/cache-persistance/platforms.js +0 -109
- package/lib/cache-persistance/platforms.js.map +0 -1
- package/lib/cache-persistance/provider.d.ts.map +0 -1
- package/lib/cache-persistance/provider.js +0 -26
- package/lib/cache-persistance/provider.js.map +0 -1
- package/lib/createBlobStorageUrl.d.ts.map +0 -1
- package/lib/createBlobStorageUrl.js +0 -4
- package/lib/createBlobStorageUrl.js.map +0 -1
- package/lib/createRemoteCacheClient.d.ts.map +0 -1
- package/lib/createRemoteCacheClient.js +0 -27
- package/lib/createRemoteCacheClient.js.map +0 -1
- package/lib/decorators/InMemoryDecorator.d.ts.map +0 -1
- package/lib/decorators/InMemoryDecorator.js +0 -29
- package/lib/decorators/InMemoryDecorator.js.map +0 -1
- package/lib/decorators/ReporterDecorator.d.ts.map +0 -1
- package/lib/decorators/ReporterDecorator.js +0 -121
- package/lib/decorators/ReporterDecorator.js.map +0 -1
- package/lib/decorators/RetryDecorator.d.ts.map +0 -1
- package/lib/decorators/RetryDecorator.js +0 -27
- package/lib/decorators/RetryDecorator.js.map +0 -1
- package/lib/getListOfBlobs.d.ts.map +0 -1
- package/lib/getListOfBlobs.js +0 -15
- package/lib/getListOfBlobs.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/retry/blockListIsInvalidRetryPolicy.d.ts.map +0 -1
- package/lib/retry/blockListIsInvalidRetryPolicy.js +0 -8
- package/lib/retry/blockListIsInvalidRetryPolicy.js.map +0 -1
- package/lib/tsdoc-metadata.json +0 -11
- package/lib/types/LoginMethod.d.ts.map +0 -1
- package/lib/types/LoginMethod.js +0 -2
- package/lib/types/LoginMethod.js.map +0 -1
- package/lib/types/PackageToSync.d.ts +0 -7
- package/lib/types/PackageToSync.d.ts.map +0 -1
- package/lib/types/PackageToSync.js +0 -2
- package/lib/types/PackageToSync.js.map +0 -1
- package/lib/types/RemoteCacheClient.d.ts.map +0 -1
- package/lib/types/RemoteCacheClient.js +0 -2
- package/lib/types/RemoteCacheClient.js.map +0 -1
- package/lib/types/RemoteCacheClientOptions.d.ts.map +0 -1
- package/lib/types/RemoteCacheClientOptions.js +0 -2
- package/lib/types/RemoteCacheClientOptions.js.map +0 -1
- package/lib/types/RetryPolicy.d.ts.map +0 -1
- package/lib/types/RetryPolicy.js +0 -2
- package/lib/types/RetryPolicy.js.map +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_dist
|
|
3
|
+
} from "./chunk-G3ME7OWS.js";
|
|
4
|
+
import "./chunk-KKZU5JW4.js";
|
|
5
|
+
import {
|
|
6
|
+
__toESM
|
|
7
|
+
} from "./chunk-GFT2G5UO.js";
|
|
8
|
+
|
|
9
|
+
// src/decorators/ReporterDecorator.ts
|
|
10
|
+
var import_storage_blob = __toESM(require_dist(), 1);
|
|
11
|
+
import { bulletedList } from "@ms-cloudpack/task-reporter";
|
|
12
|
+
var isAuthErrorReported = false;
|
|
13
|
+
function reportError(telemetryClient, error) {
|
|
14
|
+
const isAuthError = error instanceof import_storage_blob.RestError && error.statusCode === 403;
|
|
15
|
+
if (isAuthError && isAuthErrorReported) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
telemetryClient.rootSpan.recordException(error);
|
|
19
|
+
isAuthErrorReported = isAuthError;
|
|
20
|
+
}
|
|
21
|
+
var ReporterDecorator = class {
|
|
22
|
+
constructor(client, context) {
|
|
23
|
+
this.client = client;
|
|
24
|
+
this.context = context;
|
|
25
|
+
}
|
|
26
|
+
buildFailureMessage({ id, friendlyName, path }, error) {
|
|
27
|
+
const list = bulletedList([
|
|
28
|
+
`Id: ${id}`,
|
|
29
|
+
`Path: ${path}`,
|
|
30
|
+
`Name: ${friendlyName}`,
|
|
31
|
+
`Error: ${error instanceof Error ? error.message : "<Unknown>"}`
|
|
32
|
+
]);
|
|
33
|
+
return `
|
|
34
|
+
${list}`;
|
|
35
|
+
}
|
|
36
|
+
async uploadFolder(options) {
|
|
37
|
+
const { id, path, friendlyName } = options;
|
|
38
|
+
const task = this.context.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);
|
|
39
|
+
let uploadResult;
|
|
40
|
+
try {
|
|
41
|
+
uploadResult = await this.client.uploadFolder(options);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (e instanceof Error) {
|
|
44
|
+
reportError(this.context.telemetryClient, e);
|
|
45
|
+
}
|
|
46
|
+
task.complete({
|
|
47
|
+
status: "fail",
|
|
48
|
+
message: this.buildFailureMessage(options, e)
|
|
49
|
+
});
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
const details = bulletedList([`Id: ${id}`, `Path: ${path}`, `Name: ${friendlyName}`]);
|
|
53
|
+
switch (uploadResult) {
|
|
54
|
+
case "success":
|
|
55
|
+
task.complete({
|
|
56
|
+
status: "complete",
|
|
57
|
+
details
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case "not-found":
|
|
61
|
+
task.complete({
|
|
62
|
+
status: "skip",
|
|
63
|
+
message: `Not found in the local cache.`,
|
|
64
|
+
details
|
|
65
|
+
});
|
|
66
|
+
break;
|
|
67
|
+
case "already-exist":
|
|
68
|
+
task.complete({
|
|
69
|
+
status: "skip",
|
|
70
|
+
message: `Package is already exist in the remote cache.`,
|
|
71
|
+
details
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
throw new Error(`Unknown upload result: ${uploadResult}`);
|
|
76
|
+
}
|
|
77
|
+
return uploadResult;
|
|
78
|
+
}
|
|
79
|
+
async downloadFolder(options) {
|
|
80
|
+
const { id, path, friendlyName } = options;
|
|
81
|
+
const task = this.context.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);
|
|
82
|
+
let downloadResult;
|
|
83
|
+
try {
|
|
84
|
+
downloadResult = await this.client.downloadFolder(options);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (e instanceof Error) {
|
|
87
|
+
reportError(this.context.telemetryClient, e);
|
|
88
|
+
}
|
|
89
|
+
task.complete({
|
|
90
|
+
status: "fail",
|
|
91
|
+
message: this.buildFailureMessage(options, e)
|
|
92
|
+
});
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
const details = bulletedList([`Id: ${id}`, `Path: ${path}`, `Name: ${friendlyName}`]);
|
|
96
|
+
switch (downloadResult) {
|
|
97
|
+
case "success":
|
|
98
|
+
task.complete({
|
|
99
|
+
status: "complete",
|
|
100
|
+
details
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
case "not-found":
|
|
104
|
+
task.complete({
|
|
105
|
+
status: "skip",
|
|
106
|
+
message: `Not found in the remote cache.`,
|
|
107
|
+
details
|
|
108
|
+
});
|
|
109
|
+
break;
|
|
110
|
+
case "already-exist":
|
|
111
|
+
task.complete({
|
|
112
|
+
status: "skip",
|
|
113
|
+
message: `Package is already exist in the local cache.`,
|
|
114
|
+
details
|
|
115
|
+
});
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
throw new Error(`Unknown download result: ${downloadResult}`);
|
|
119
|
+
}
|
|
120
|
+
return downloadResult;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
ReporterDecorator
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=ReporterDecorator-BYNXV72I.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/decorators/ReporterDecorator.ts"],
|
|
4
|
+
"sourcesContent": ["import { bulletedList, type TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type {\n RemoteCacheClient,\n RemoteCacheClientUploadOperationOptions,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from '../types/RemoteCacheClient.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { RestError } from '@azure/storage-blob';\n\nlet isAuthErrorReported: boolean = false;\n\n/**\n * Reports an error to the telemetry client. If the error is an auth error, it will be reported only once.\n * @param telemetryClient - The telemetry client to report the error to.\n * @param error - The error to report.\n */\nfunction reportError(telemetryClient: TelemetryClient, error: Error) {\n const isAuthError = error instanceof RestError && error.statusCode === 403;\n\n if (isAuthError && isAuthErrorReported) {\n return; // No need to proceed if auth error is already reported\n }\n\n telemetryClient.rootSpan.recordException(error);\n\n // Set isAuthErrorReported only if it's an auth error\n isAuthErrorReported = isAuthError;\n}\n\nexport class ReporterDecorator implements RemoteCacheClient {\n constructor(\n private readonly client: RemoteCacheClient,\n private readonly context: {\n reporter: TaskReporter;\n telemetryClient: TelemetryClient;\n },\n ) {}\n\n private buildFailureMessage({ id, friendlyName, path }: RemoteCacheClientOperationOptions, error: unknown) {\n const list = bulletedList([\n `Id: ${id}`,\n `Path: ${path}`,\n `Name: ${friendlyName}`,\n `Error: ${error instanceof Error ? error.message : '<Unknown>'}`,\n ]);\n\n return `\\n${list}`;\n }\n\n async uploadFolder(options: RemoteCacheClientUploadOperationOptions) {\n const { id, path, friendlyName } = options;\n const task = this.context.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);\n\n let uploadResult: RemoteCacheClientOperationResult;\n\n try {\n uploadResult = await this.client.uploadFolder(options);\n } catch (e) {\n if (e instanceof Error) {\n reportError(this.context.telemetryClient, e);\n }\n task.complete({\n status: 'fail',\n message: this.buildFailureMessage(options, e),\n });\n throw e;\n }\n\n const details = bulletedList([`Id: ${id}`, `Path: ${path}`, `Name: ${friendlyName}`]);\n\n switch (uploadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details,\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the local cache.`,\n details,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the remote cache.`,\n details,\n });\n break;\n default:\n throw new Error(`Unknown upload result: ${uploadResult}`);\n }\n\n return uploadResult;\n }\n\n async downloadFolder(options: RemoteCacheClientOperationOptions) {\n const { id, path, friendlyName } = options;\n const task = this.context.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);\n\n let downloadResult: RemoteCacheClientOperationResult;\n\n try {\n downloadResult = await this.client.downloadFolder(options);\n } catch (e) {\n if (e instanceof Error) {\n reportError(this.context.telemetryClient, e);\n }\n\n task.complete({\n status: 'fail',\n message: this.buildFailureMessage(options, e),\n });\n throw e;\n }\n\n const details = bulletedList([`Id: ${id}`, `Path: ${path}`, `Name: ${friendlyName}`]);\n\n switch (downloadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details,\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the remote cache.`,\n details,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the local cache.`,\n details,\n });\n break;\n default:\n throw new Error(`Unknown download result: ${downloadResult}`);\n }\n\n return downloadResult;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAQA,0BAA0B;AAR1B,SAAS,oBAAuC;AAUhD,IAAI,sBAA+B;AAOnC,SAAS,YAAY,iBAAkC,OAAc;AACnE,QAAM,cA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