@ms-cloudpack/remote-cache 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/AzureRemoteCacheClient-NEV2XCF7.js +49446 -0
  2. package/dist/ReporterDecorator-SNBYNGOT.js +134 -0
  3. package/dist/chunk-4P62L7ZZ.js +1530 -0
  4. package/dist/chunk-KFSFZYG6.js +49961 -0
  5. package/dist/chunk-R2VDVRDZ.js +15 -0
  6. package/dist/chunk-TQLTL4XO.js +65 -0
  7. package/dist/getCredential-QMMPE77Q.js +24525 -0
  8. package/dist/getListOfBlobs-E5OFG2MF.js +29 -0
  9. package/dist/index.js +109 -0
  10. package/lib/decorators/InMemoryDecorator.test.d.ts +2 -0
  11. package/lib/decorators/RetryDecorator.test.d.ts +2 -0
  12. package/package.json +13 -11
  13. package/lib/AzureRemoteCacheClient.d.ts.map +0 -1
  14. package/lib/AzureRemoteCacheClient.js +0 -51
  15. package/lib/AzureRemoteCacheClient.js.map +0 -1
  16. package/lib/Task.d.ts.map +0 -1
  17. package/lib/Task.js +0 -2
  18. package/lib/Task.js.map +0 -1
  19. package/lib/authentication/getAuthenticationRecord.d.ts.map +0 -1
  20. package/lib/authentication/getAuthenticationRecord.js +0 -17
  21. package/lib/authentication/getAuthenticationRecord.js.map +0 -1
  22. package/lib/authentication/getAuthenticationRecordPath.d.ts.map +0 -1
  23. package/lib/authentication/getAuthenticationRecordPath.js +0 -10
  24. package/lib/authentication/getAuthenticationRecordPath.js.map +0 -1
  25. package/lib/authentication/getCredential.d.ts.map +0 -1
  26. package/lib/authentication/getCredential.js +0 -61
  27. package/lib/authentication/getCredential.js.map +0 -1
  28. package/lib/authentication/saveAuthenticationRecord.d.ts.map +0 -1
  29. package/lib/authentication/saveAuthenticationRecord.js +0 -17
  30. package/lib/authentication/saveAuthenticationRecord.js.map +0 -1
  31. package/lib/createBlobStorageUrl.d.ts.map +0 -1
  32. package/lib/createBlobStorageUrl.js +0 -4
  33. package/lib/createBlobStorageUrl.js.map +0 -1
  34. package/lib/createRemoteCacheClient.d.ts.map +0 -1
  35. package/lib/createRemoteCacheClient.js +0 -27
  36. package/lib/createRemoteCacheClient.js.map +0 -1
  37. package/lib/decorators/InMemoryDecorator.d.ts.map +0 -1
  38. package/lib/decorators/InMemoryDecorator.js +0 -29
  39. package/lib/decorators/InMemoryDecorator.js.map +0 -1
  40. package/lib/decorators/ReporterDecorator.d.ts.map +0 -1
  41. package/lib/decorators/ReporterDecorator.js +0 -126
  42. package/lib/decorators/ReporterDecorator.js.map +0 -1
  43. package/lib/decorators/RetryDecorator.d.ts.map +0 -1
  44. package/lib/decorators/RetryDecorator.js +0 -27
  45. package/lib/decorators/RetryDecorator.js.map +0 -1
  46. package/lib/getListOfBlobs.d.ts.map +0 -1
  47. package/lib/getListOfBlobs.js +0 -15
  48. package/lib/getListOfBlobs.js.map +0 -1
  49. package/lib/index.d.ts.map +0 -1
  50. package/lib/index.js +0 -2
  51. package/lib/index.js.map +0 -1
  52. package/lib/retry/blockListIsInvalidRetryPolicy.d.ts.map +0 -1
  53. package/lib/retry/blockListIsInvalidRetryPolicy.js +0 -8
  54. package/lib/retry/blockListIsInvalidRetryPolicy.js.map +0 -1
  55. package/lib/tsdoc-metadata.json +0 -11
  56. package/lib/types/LoginMethod.d.ts.map +0 -1
  57. package/lib/types/LoginMethod.js +0 -2
  58. package/lib/types/LoginMethod.js.map +0 -1
  59. package/lib/types/RemoteCacheClient.d.ts.map +0 -1
  60. package/lib/types/RemoteCacheClient.js +0 -2
  61. package/lib/types/RemoteCacheClient.js.map +0 -1
  62. package/lib/types/RemoteCacheClientOptions.d.ts.map +0 -1
  63. package/lib/types/RemoteCacheClientOptions.js +0 -2
  64. package/lib/types/RemoteCacheClientOptions.js.map +0 -1
  65. package/lib/types/RetryPolicy.d.ts.map +0 -1
  66. package/lib/types/RetryPolicy.js +0 -2
  67. package/lib/types/RetryPolicy.js.map +0 -1
@@ -0,0 +1,134 @@
1
+ import {
2
+ require_dist
3
+ } from "./chunk-KFSFZYG6.js";
4
+ import "./chunk-4P62L7ZZ.js";
5
+ import {
6
+ __name,
7
+ __toESM,
8
+ init_esbuildCjsShims
9
+ } from "./chunk-TQLTL4XO.js";
10
+
11
+ // src/decorators/ReporterDecorator.ts
12
+ init_esbuildCjsShims();
13
+ var import_storage_blob = __toESM(require_dist(), 1);
14
+ import { bulletedList } from "@ms-cloudpack/task-reporter";
15
+ var isAuthErrorReported = false;
16
+ function reportError(telemetryClient, error) {
17
+ const isAuthError = error instanceof import_storage_blob.RestError && error.statusCode === 403;
18
+ if (isAuthError && isAuthErrorReported) {
19
+ return;
20
+ }
21
+ telemetryClient.rootSpan.recordException(error);
22
+ isAuthErrorReported = isAuthError;
23
+ }
24
+ __name(reportError, "reportError");
25
+ var _ReporterDecorator = class _ReporterDecorator {
26
+ constructor(client, context) {
27
+ this.client = client;
28
+ this.context = context;
29
+ }
30
+ buildFailureResult({ id, friendlyName, path }, error) {
31
+ const list = bulletedList([
32
+ `Id: ${id}`,
33
+ `Path: ${path}`,
34
+ `Name: ${friendlyName}`,
35
+ `Error: ${error instanceof Error ? error.message : String(error)}`
36
+ ]);
37
+ const result = {
38
+ status: "fail",
39
+ message: `
40
+ ${list}`
41
+ };
42
+ if (error instanceof Error && error.stack) {
43
+ result.details = error.stack.includes(error.message) ? error.stack.split(error.message)[1] : error.stack;
44
+ }
45
+ return result;
46
+ }
47
+ async uploadFolder(options) {
48
+ const { id, path, friendlyName } = options;
49
+ const task = this.context.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);
50
+ let uploadResult;
51
+ try {
52
+ uploadResult = await this.client.uploadFolder(options);
53
+ } catch (e) {
54
+ task.complete(this.buildFailureResult(options, e));
55
+ if (e instanceof Error) {
56
+ reportError(this.context.telemetryClient, e);
57
+ e.stack = void 0;
58
+ }
59
+ throw e;
60
+ }
61
+ const details = bulletedList([`Id: ${id}`, `Path: ${path}`, `Name: ${friendlyName}`]);
62
+ switch (uploadResult) {
63
+ case "success":
64
+ task.complete({
65
+ status: "complete",
66
+ details
67
+ });
68
+ break;
69
+ case "not-found":
70
+ task.complete({
71
+ status: "skip",
72
+ message: `Not found in the local cache.`,
73
+ details
74
+ });
75
+ break;
76
+ case "already-exist":
77
+ task.complete({
78
+ status: "skip",
79
+ message: `Package is already exist in the remote cache.`,
80
+ details
81
+ });
82
+ break;
83
+ default:
84
+ throw new Error(`Unknown upload result: ${uploadResult}`);
85
+ }
86
+ return uploadResult;
87
+ }
88
+ async downloadFolder(options) {
89
+ const { id, path, friendlyName } = options;
90
+ const task = this.context.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);
91
+ let downloadResult;
92
+ try {
93
+ downloadResult = await this.client.downloadFolder(options);
94
+ } catch (e) {
95
+ task.complete(this.buildFailureResult(options, e));
96
+ if (e instanceof Error) {
97
+ reportError(this.context.telemetryClient, e);
98
+ e.stack = void 0;
99
+ }
100
+ throw e;
101
+ }
102
+ const details = bulletedList([`Id: ${id}`, `Path: ${path}`, `Name: ${friendlyName}`]);
103
+ switch (downloadResult) {
104
+ case "success":
105
+ task.complete({
106
+ status: "complete",
107
+ details
108
+ });
109
+ break;
110
+ case "not-found":
111
+ task.complete({
112
+ status: "skip",
113
+ message: `Not found in the remote cache.`,
114
+ details
115
+ });
116
+ break;
117
+ case "already-exist":
118
+ task.complete({
119
+ status: "skip",
120
+ message: `Package is already exist in the local cache.`,
121
+ details
122
+ });
123
+ break;
124
+ default:
125
+ throw new Error(`Unknown download result: ${downloadResult}`);
126
+ }
127
+ return downloadResult;
128
+ }
129
+ };
130
+ __name(_ReporterDecorator, "ReporterDecorator");
131
+ var ReporterDecorator = _ReporterDecorator;
132
+ export {
133
+ ReporterDecorator
134
+ };