@ms-cloudpack/remote-cache 0.5.0 → 0.5.1-beta.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 (87) hide show
  1. package/dist/AzureRemoteCacheClient-P6C5CPLP.js +52049 -0
  2. package/dist/AzureRemoteCacheClient-P6C5CPLP.js.map +7 -0
  3. package/dist/ReporterDecorator-UXMG3OO4.js +126 -0
  4. package/dist/ReporterDecorator-UXMG3OO4.js.map +7 -0
  5. package/dist/chunk-AUZ3RYOM.js +50 -0
  6. package/dist/chunk-AUZ3RYOM.js.map +7 -0
  7. package/dist/chunk-K2IPVVHZ.js +1071 -0
  8. package/dist/chunk-K2IPVVHZ.js.map +7 -0
  9. package/dist/chunk-PSEJWW4L.js +182 -0
  10. package/dist/chunk-PSEJWW4L.js.map +7 -0
  11. package/dist/chunk-W7TAYQ7C.js +49567 -0
  12. package/dist/chunk-W7TAYQ7C.js.map +7 -0
  13. package/dist/chunk-XKOU5VXX.js +9 -0
  14. package/dist/chunk-XKOU5VXX.js.map +7 -0
  15. package/dist/getCredential-VTEUQWIA.js +23981 -0
  16. package/dist/getCredential-VTEUQWIA.js.map +7 -0
  17. package/dist/getListOfBlobs-OTB3VIVC.js +26 -0
  18. package/dist/getListOfBlobs-OTB3VIVC.js.map +7 -0
  19. package/dist/index.js +93 -0
  20. package/dist/index.js.map +7 -0
  21. package/lib/decorators/InMemoryDecorator.test.d.ts +2 -0
  22. package/lib/decorators/RetryDecorator.test.d.ts +2 -0
  23. package/package.json +13 -12
  24. package/lib/AzureRemoteCacheClient.d.ts.map +0 -1
  25. package/lib/AzureRemoteCacheClient.js +0 -51
  26. package/lib/AzureRemoteCacheClient.js.map +0 -1
  27. package/lib/Task.d.ts.map +0 -1
  28. package/lib/Task.js +0 -2
  29. package/lib/Task.js.map +0 -1
  30. package/lib/authentication/getAuthenticationRecord.d.ts.map +0 -1
  31. package/lib/authentication/getAuthenticationRecord.js +0 -17
  32. package/lib/authentication/getAuthenticationRecord.js.map +0 -1
  33. package/lib/authentication/getAuthenticationRecordPath.d.ts.map +0 -1
  34. package/lib/authentication/getAuthenticationRecordPath.js +0 -10
  35. package/lib/authentication/getAuthenticationRecordPath.js.map +0 -1
  36. package/lib/authentication/getCredential.d.ts.map +0 -1
  37. package/lib/authentication/getCredential.js +0 -61
  38. package/lib/authentication/getCredential.js.map +0 -1
  39. package/lib/authentication/saveAuthenticationRecord.d.ts.map +0 -1
  40. package/lib/authentication/saveAuthenticationRecord.js +0 -17
  41. package/lib/authentication/saveAuthenticationRecord.js.map +0 -1
  42. package/lib/cache-persistance/cachePersistencePlugin.d.ts.map +0 -1
  43. package/lib/cache-persistance/cachePersistencePlugin.js +0 -35
  44. package/lib/cache-persistance/cachePersistencePlugin.js.map +0 -1
  45. package/lib/cache-persistance/platforms.d.ts.map +0 -1
  46. package/lib/cache-persistance/platforms.js +0 -109
  47. package/lib/cache-persistance/platforms.js.map +0 -1
  48. package/lib/cache-persistance/provider.d.ts.map +0 -1
  49. package/lib/cache-persistance/provider.js +0 -26
  50. package/lib/cache-persistance/provider.js.map +0 -1
  51. package/lib/createBlobStorageUrl.d.ts.map +0 -1
  52. package/lib/createBlobStorageUrl.js +0 -4
  53. package/lib/createBlobStorageUrl.js.map +0 -1
  54. package/lib/createRemoteCacheClient.d.ts.map +0 -1
  55. package/lib/createRemoteCacheClient.js +0 -27
  56. package/lib/createRemoteCacheClient.js.map +0 -1
  57. package/lib/decorators/InMemoryDecorator.d.ts.map +0 -1
  58. package/lib/decorators/InMemoryDecorator.js +0 -29
  59. package/lib/decorators/InMemoryDecorator.js.map +0 -1
  60. package/lib/decorators/ReporterDecorator.d.ts.map +0 -1
  61. package/lib/decorators/ReporterDecorator.js +0 -121
  62. package/lib/decorators/ReporterDecorator.js.map +0 -1
  63. package/lib/decorators/RetryDecorator.d.ts.map +0 -1
  64. package/lib/decorators/RetryDecorator.js +0 -27
  65. package/lib/decorators/RetryDecorator.js.map +0 -1
  66. package/lib/getListOfBlobs.d.ts.map +0 -1
  67. package/lib/getListOfBlobs.js +0 -15
  68. package/lib/getListOfBlobs.js.map +0 -1
  69. package/lib/index.d.ts.map +0 -1
  70. package/lib/index.js +0 -2
  71. package/lib/index.js.map +0 -1
  72. package/lib/retry/blockListIsInvalidRetryPolicy.d.ts.map +0 -1
  73. package/lib/retry/blockListIsInvalidRetryPolicy.js +0 -8
  74. package/lib/retry/blockListIsInvalidRetryPolicy.js.map +0 -1
  75. package/lib/tsdoc-metadata.json +0 -11
  76. package/lib/types/LoginMethod.d.ts.map +0 -1
  77. package/lib/types/LoginMethod.js +0 -2
  78. package/lib/types/LoginMethod.js.map +0 -1
  79. package/lib/types/RemoteCacheClient.d.ts.map +0 -1
  80. package/lib/types/RemoteCacheClient.js +0 -2
  81. package/lib/types/RemoteCacheClient.js.map +0 -1
  82. package/lib/types/RemoteCacheClientOptions.d.ts.map +0 -1
  83. package/lib/types/RemoteCacheClientOptions.js +0 -2
  84. package/lib/types/RemoteCacheClientOptions.js.map +0 -1
  85. package/lib/types/RetryPolicy.d.ts.map +0 -1
  86. package/lib/types/RetryPolicy.js +0 -2
  87. package/lib/types/RetryPolicy.js.map +0 -1
@@ -0,0 +1,126 @@
1
+ import {
2
+ require_dist
3
+ } from "./chunk-W7TAYQ7C.js";
4
+ import "./chunk-K2IPVVHZ.js";
5
+ import {
6
+ __toESM
7
+ } from "./chunk-AUZ3RYOM.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-UXMG3OO4.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,cAAc,iBAAiB,iCAAa,MAAM,eAAe;AAEvE,MAAI,eAAe,qBAAqB;AACtC;AAAA,EACF;AAEA,kBAAgB,SAAS,gBAAgB,KAAK;AAG9C,wBAAsB;AACxB;AAEO,IAAM,oBAAN,MAAqD;AAAA,EAC1D,YACmB,QACA,SAIjB;AALiB;AACA;AAAA,EAIhB;AAAA,EAEK,oBAAoB,EAAE,IAAI,cAAc,KAAK,GAAsC,OAAgB;AACzG,UAAM,OAAO,aAAa;AAAA,MACxB,OAAO,EAAE;AAAA,MACT,SAAS,IAAI;AAAA,MACb,SAAS,YAAY;AAAA,MACrB,UAAU,iBAAiB,QAAQ,MAAM,UAAU,WAAW;AAAA,IAChE,CAAC;AAED,WAAO;AAAA,EAAK,IAAI;AAAA,EAClB;AAAA,EAEA,MAAM,aAAa,SAAkD;AACnE,UAAM,EAAE,IAAI,MAAM,aAAa,IAAI;AACnC,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,8BAA8B,YAAY,EAAE;AAEvF,QAAI;AAEJ,QAAI;AACF,qBAAe,MAAM,KAAK,OAAO,aAAa,OAAO;AAAA,IACvD,SAAS,GAAG;AACV,UAAI,aAAa,OAAO;AACtB,oBAAY,KAAK,QAAQ,iBAAiB,CAAC;AAAA,MAC7C;AACA,WAAK,SAAS;AAAA,QACZ,QAAQ;AAAA,QACR,SAAS,KAAK,oBAAoB,SAAS,CAAC;AAAA,MAC9C,CAAC;AACD,YAAM;AAAA,IACR;AAEA,UAAM,UAAU,aAAa,CAAC,OAAO,EAAE,IAAI,SAAS,IAAI,IAAI,SAAS,YAAY,EAAE,CAAC;AAEpF,YAAQ,cAAc;AAAA,M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,IAAI,MAAM,4BAA4B,cAAc,EAAE;AAAA,IAChE;AAEA,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined")
11
+ return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __esm = (fn, res) => function __init() {
15
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
+ };
17
+ var __commonJS = (cb, mod) => function __require2() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
+ // If the importer is in node compatibility mode or this is not an ESM
34
+ // file that has been converted to a CommonJS file using a Babel-
35
+ // compatible transform (i.e. "__esModule" has not been set), then set
36
+ // "default" to the CommonJS "module.exports" for node compatibility.
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+
42
+ export {
43
+ __require,
44
+ __esm,
45
+ __commonJS,
46
+ __export,
47
+ __toESM,
48
+ __toCommonJS
49
+ };
50
+ //# sourceMappingURL=chunk-AUZ3RYOM.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }