@ms-cloudpack/remote-cache 0.5.1-beta.1 → 0.5.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 (88) hide show
  1. package/lib/AzureRemoteCacheClient.d.ts.map +1 -0
  2. package/lib/AzureRemoteCacheClient.js +51 -0
  3. package/lib/AzureRemoteCacheClient.js.map +1 -0
  4. package/lib/Task.d.ts.map +1 -0
  5. package/lib/Task.js +2 -0
  6. package/lib/Task.js.map +1 -0
  7. package/lib/authentication/getAuthenticationRecord.d.ts.map +1 -0
  8. package/lib/authentication/getAuthenticationRecord.js +17 -0
  9. package/lib/authentication/getAuthenticationRecord.js.map +1 -0
  10. package/lib/authentication/getAuthenticationRecordPath.d.ts.map +1 -0
  11. package/lib/authentication/getAuthenticationRecordPath.js +10 -0
  12. package/lib/authentication/getAuthenticationRecordPath.js.map +1 -0
  13. package/lib/authentication/getCredential.d.ts.map +1 -0
  14. package/lib/authentication/getCredential.js +61 -0
  15. package/lib/authentication/getCredential.js.map +1 -0
  16. package/lib/authentication/saveAuthenticationRecord.d.ts.map +1 -0
  17. package/lib/authentication/saveAuthenticationRecord.js +17 -0
  18. package/lib/authentication/saveAuthenticationRecord.js.map +1 -0
  19. package/lib/cache-persistance/cachePersistencePlugin.d.ts.map +1 -0
  20. package/lib/cache-persistance/cachePersistencePlugin.js +35 -0
  21. package/lib/cache-persistance/cachePersistencePlugin.js.map +1 -0
  22. package/lib/cache-persistance/platforms.d.ts.map +1 -0
  23. package/lib/cache-persistance/platforms.js +109 -0
  24. package/lib/cache-persistance/platforms.js.map +1 -0
  25. package/lib/cache-persistance/provider.d.ts.map +1 -0
  26. package/lib/cache-persistance/provider.js +26 -0
  27. package/lib/cache-persistance/provider.js.map +1 -0
  28. package/lib/createBlobStorageUrl.d.ts.map +1 -0
  29. package/lib/createBlobStorageUrl.js +4 -0
  30. package/lib/createBlobStorageUrl.js.map +1 -0
  31. package/lib/createRemoteCacheClient.d.ts.map +1 -0
  32. package/lib/createRemoteCacheClient.js +27 -0
  33. package/lib/createRemoteCacheClient.js.map +1 -0
  34. package/lib/decorators/InMemoryDecorator.d.ts.map +1 -0
  35. package/lib/decorators/InMemoryDecorator.js +29 -0
  36. package/lib/decorators/InMemoryDecorator.js.map +1 -0
  37. package/lib/decorators/ReporterDecorator.d.ts +1 -1
  38. package/lib/decorators/ReporterDecorator.d.ts.map +1 -0
  39. package/lib/decorators/ReporterDecorator.js +126 -0
  40. package/lib/decorators/ReporterDecorator.js.map +1 -0
  41. package/lib/decorators/RetryDecorator.d.ts.map +1 -0
  42. package/lib/decorators/RetryDecorator.js +27 -0
  43. package/lib/decorators/RetryDecorator.js.map +1 -0
  44. package/lib/getListOfBlobs.d.ts.map +1 -0
  45. package/lib/getListOfBlobs.js +15 -0
  46. package/lib/getListOfBlobs.js.map +1 -0
  47. package/lib/index.d.ts.map +1 -0
  48. package/lib/index.js +2 -0
  49. package/lib/index.js.map +1 -0
  50. package/lib/retry/blockListIsInvalidRetryPolicy.d.ts.map +1 -0
  51. package/lib/retry/blockListIsInvalidRetryPolicy.js +8 -0
  52. package/lib/retry/blockListIsInvalidRetryPolicy.js.map +1 -0
  53. package/lib/tsdoc-metadata.json +11 -0
  54. package/lib/types/LoginMethod.d.ts.map +1 -0
  55. package/lib/types/LoginMethod.js +2 -0
  56. package/lib/types/LoginMethod.js.map +1 -0
  57. package/lib/types/RemoteCacheClient.d.ts.map +1 -0
  58. package/lib/types/RemoteCacheClient.js +2 -0
  59. package/lib/types/RemoteCacheClient.js.map +1 -0
  60. package/lib/types/RemoteCacheClientOptions.d.ts.map +1 -0
  61. package/lib/types/RemoteCacheClientOptions.js +2 -0
  62. package/lib/types/RemoteCacheClientOptions.js.map +1 -0
  63. package/lib/types/RetryPolicy.d.ts.map +1 -0
  64. package/lib/types/RetryPolicy.js +2 -0
  65. package/lib/types/RetryPolicy.js.map +1 -0
  66. package/package.json +13 -14
  67. package/dist/AzureRemoteCacheClient-P6C5CPLP.js +0 -52049
  68. package/dist/AzureRemoteCacheClient-P6C5CPLP.js.map +0 -7
  69. package/dist/ReporterDecorator-UXMG3OO4.js +0 -126
  70. package/dist/ReporterDecorator-UXMG3OO4.js.map +0 -7
  71. package/dist/chunk-AUZ3RYOM.js +0 -50
  72. package/dist/chunk-AUZ3RYOM.js.map +0 -7
  73. package/dist/chunk-K2IPVVHZ.js +0 -1071
  74. package/dist/chunk-K2IPVVHZ.js.map +0 -7
  75. package/dist/chunk-PSEJWW4L.js +0 -182
  76. package/dist/chunk-PSEJWW4L.js.map +0 -7
  77. package/dist/chunk-W7TAYQ7C.js +0 -49567
  78. package/dist/chunk-W7TAYQ7C.js.map +0 -7
  79. package/dist/chunk-XKOU5VXX.js +0 -9
  80. package/dist/chunk-XKOU5VXX.js.map +0 -7
  81. package/dist/getCredential-VTEUQWIA.js +0 -23981
  82. package/dist/getCredential-VTEUQWIA.js.map +0 -7
  83. package/dist/getListOfBlobs-OTB3VIVC.js +0 -26
  84. package/dist/getListOfBlobs-OTB3VIVC.js.map +0 -7
  85. package/dist/index.js +0 -93
  86. package/dist/index.js.map +0 -7
  87. package/lib/decorators/InMemoryDecorator.test.d.ts +0 -2
  88. package/lib/decorators/RetryDecorator.test.d.ts +0 -2
@@ -1,26 +0,0 @@
1
- import {
2
- createBlobStorageUrl
3
- } from "./chunk-XKOU5VXX.js";
4
- import {
5
- require_dist
6
- } from "./chunk-W7TAYQ7C.js";
7
- import "./chunk-K2IPVVHZ.js";
8
- import {
9
- __toESM
10
- } from "./chunk-AUZ3RYOM.js";
11
-
12
- // src/getListOfBlobs.ts
13
- var import_storage_blob = __toESM(require_dist(), 1);
14
- async function getListOfBlobs({ container, storageAccount, credential }) {
15
- const blobStorageClient = new import_storage_blob.BlobServiceClient(createBlobStorageUrl(storageAccount), credential);
16
- const containerClient = blobStorageClient.getContainerClient(container);
17
- const blobs = /* @__PURE__ */ new Set();
18
- for await (const blob of containerClient.listBlobsFlat()) {
19
- blobs.add(blob.name);
20
- }
21
- return blobs;
22
- }
23
- export {
24
- getListOfBlobs
25
- };
26
- //# sourceMappingURL=getListOfBlobs-OTB3VIVC.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/getListOfBlobs.ts"],
4
- "sourcesContent": ["import { createBlobStorageUrl } from './createBlobStorageUrl.js';\nimport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\nimport { BlobServiceClient } from '@azure/storage-blob';\n\n/**\n * Gets all the blobs in the remote cache.\n */\nexport async function getListOfBlobs({ container, storageAccount, credential }: RemoteCacheClientOptions) {\n const blobStorageClient = new BlobServiceClient(createBlobStorageUrl(storageAccount), credential);\n const containerClient = blobStorageClient.getContainerClient(container);\n const blobs = new Set<string>();\n for await (const blob of containerClient.listBlobsFlat()) {\n blobs.add(blob.name);\n }\n return blobs;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;AAEA,0BAAkC;AAKlC,eAAsB,eAAe,EAAE,WAAW,gBAAgB,WAAW,GAA6B;AACxG,QAAM,oBAAoB,IAAI,sCAAkB,qBAAqB,cAAc,GAAG,UAAU;AAChG,QAAM,kBAAkB,kBAAkB,mBAAmB,SAAS;AACtE,QAAM,QAAQ,oBAAI,IAAY;AAC9B,mBAAiB,QAAQ,gBAAgB,cAAc,GAAG;AACxD,UAAM,IAAI,KAAK,IAAI;AAAA,EACrB;AACA,SAAO;AACT;",
6
- "names": []
7
- }
package/dist/index.js DELETED
@@ -1,93 +0,0 @@
1
- import "./chunk-AUZ3RYOM.js";
2
-
3
- // src/decorators/InMemoryDecorator.ts
4
- var InMemoryDecorator = class {
5
- constructor(options) {
6
- this.cacheClient = options.cacheClient;
7
- this.list = options.getList();
8
- }
9
- async uploadFolder(options) {
10
- if ((await this.list).has(options.id)) {
11
- return "already-exist";
12
- }
13
- const result = await this.cacheClient.uploadFolder(options);
14
- if (result === "success") {
15
- (await this.list).add(options.id);
16
- }
17
- return result;
18
- }
19
- async downloadFolder(options) {
20
- if (!(await this.list).has(options.id)) {
21
- return "not-found";
22
- }
23
- return this.cacheClient.downloadFolder(options);
24
- }
25
- };
26
-
27
- // src/decorators/RetryDecorator.ts
28
- var RetryDecorator = class {
29
- constructor(options) {
30
- this.cacheClient = options.cacheClient;
31
- this.retryManager = options.retryManager;
32
- }
33
- printRetryContext(operationName, options, retryContext) {
34
- if (retryContext) {
35
- console.warn(
36
- `Retrying ${operationName} ${options.friendlyName} ... [${retryContext.retryAttempt}/${retryContext.maxRetries}]`
37
- );
38
- }
39
- }
40
- async uploadFolder(options) {
41
- return this.retryManager.retry((retryContext) => {
42
- this.printRetryContext("upload", options, retryContext);
43
- return this.cacheClient.uploadFolder(options);
44
- });
45
- }
46
- async downloadFolder(options) {
47
- return this.retryManager.retry((retryContext) => {
48
- this.printRetryContext("download", options, retryContext);
49
- return this.cacheClient.downloadFolder(options);
50
- });
51
- }
52
- };
53
-
54
- // src/retry/blockListIsInvalidRetryPolicy.ts
55
- var blockListIsInvalidRetryPolicy = {
56
- maxRetries: 1,
57
- handle: (error) => {
58
- return error instanceof Error && error.message.indexOf("The specified block list is invalid.") > -1;
59
- },
60
- wait: () => 0
61
- };
62
-
63
- // src/createRemoteCacheClient.ts
64
- import { RetryManager } from "@ms-cloudpack/retry";
65
- async function createRemoteCacheClient(params) {
66
- const { context, options } = params;
67
- const { container, loginMethod, storageAccount, cachePath } = options;
68
- const { getCredential } = await import("./getCredential-VTEUQWIA.js");
69
- const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-P6C5CPLP.js");
70
- const { ReporterDecorator } = await import("./ReporterDecorator-UXMG3OO4.js");
71
- const { getListOfBlobs } = await import("./getListOfBlobs-OTB3VIVC.js");
72
- const credential = await getCredential(loginMethod, cachePath);
73
- const remoteCacheClientOptions = {
74
- storageAccount,
75
- container,
76
- credential
77
- };
78
- const client = new ReporterDecorator(
79
- new RetryDecorator({
80
- retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),
81
- cacheClient: new InMemoryDecorator({
82
- cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),
83
- getList: () => getListOfBlobs(remoteCacheClientOptions)
84
- })
85
- }),
86
- context
87
- );
88
- return client;
89
- }
90
- export {
91
- createRemoteCacheClient
92
- };
93
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/decorators/InMemoryDecorator.ts", "../src/decorators/RetryDecorator.ts", "../src/retry/blockListIsInvalidRetryPolicy.ts", "../src/createRemoteCacheClient.ts"],
4
- "sourcesContent": ["import type {\n RemoteCacheClient,\n RemoteCacheClientUploadOperationOptions,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from '../types/RemoteCacheClient.js';\n\n/**\n * A decorator for a RemoteCacheClient that keeps a list of remote resources locally.\n */\nexport class InMemoryDecorator implements RemoteCacheClient {\n private readonly cacheClient: RemoteCacheClient;\n private readonly list: Promise<Set<string>>;\n\n constructor(options: { cacheClient: RemoteCacheClient; getList: () => Promise<Set<string>> }) {\n this.cacheClient = options.cacheClient;\n this.list = options.getList();\n }\n\n async uploadFolder(options: RemoteCacheClientUploadOperationOptions): Promise<RemoteCacheClientOperationResult> {\n if ((await this.list).has(options.id)) {\n // This resource already exists in the remote cache, no need to upload it again.\n return 'already-exist';\n }\n\n const result = await this.cacheClient.uploadFolder(options);\n\n if (result === 'success') {\n // The upload is successful, add the resource to the list.\n (await this.list).add(options.id);\n }\n\n return result;\n }\n\n async downloadFolder(options: RemoteCacheClientOperationOptions): Promise<RemoteCacheClientOperationResult> {\n if (!(await this.list).has(options.id)) {\n // This resource doesn't exist in the remote cache, can't download it.\n return 'not-found';\n }\n\n return this.cacheClient.downloadFolder(options);\n }\n}\n", "import type {\n RemoteCacheClient,\n RemoteCacheClientUploadOperationOptions,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from '../types/RemoteCacheClient.js';\nimport type { RetryManager } from '@ms-cloudpack/retry';\n\n/**\n * A decorator that retries the upload/download operation if it fails.\n */\nexport class RetryDecorator implements RemoteCacheClient {\n private readonly cacheClient: RemoteCacheClient;\n private readonly retryManager: RetryManager;\n\n constructor(options: { cacheClient: RemoteCacheClient; retryManager: RetryManager }) {\n this.cacheClient = options.cacheClient;\n this.retryManager = options.retryManager;\n }\n\n private printRetryContext(\n operationName: string,\n options: RemoteCacheClientOperationOptions,\n retryContext?: { retryAttempt: number; maxRetries: number },\n ) {\n if (retryContext) {\n console.warn(\n `Retrying ${operationName} ${options.friendlyName} ... [${retryContext.retryAttempt}/${retryContext.maxRetries}]`,\n );\n }\n }\n\n async uploadFolder(options: RemoteCacheClientUploadOperationOptions): Promise<RemoteCacheClientOperationResult> {\n return this.retryManager.retry((retryContext) => {\n this.printRetryContext('upload', options, retryContext);\n return this.cacheClient.uploadFolder(options);\n });\n }\n\n async downloadFolder(options: RemoteCacheClientOperationOptions): Promise<RemoteCacheClientOperationResult> {\n return this.retryManager.retry((retryContext) => {\n this.printRetryContext('download', options, retryContext);\n return this.cacheClient.downloadFolder(options);\n });\n }\n}\n", "import type { RetryPolicy } from '../types/RetryPolicy.js';\n\nexport const blockListIsInvalidRetryPolicy: RetryPolicy = {\n maxRetries: 1,\n handle: (error) => {\n return error instanceof Error && error.message.indexOf('The specified block list is invalid.') > -1;\n },\n wait: () => 0,\n};\n", "import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport { InMemoryDecorator } from './decorators/InMemoryDecorator.js';\nimport type { RemoteCacheClient } from './types/RemoteCacheClient.js';\nimport { RetryDecorator } from './decorators/RetryDecorator.js';\nimport { blockListIsInvalidRetryPolicy } from './retry/blockListIsInvalidRetryPolicy.js';\nimport { RetryManager } from '@ms-cloudpack/retry';\nimport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { LoginMethod } from './types/LoginMethod.js';\n\nexport interface CreateRemoteCacheClientParams {\n options: {\n storageAccount: string;\n container: string;\n loginMethod: LoginMethod;\n cachePath: string;\n };\n context: {\n reporter: TaskReporter;\n telemetryClient: TelemetryClient;\n };\n}\n\nexport async function createRemoteCacheClient(params: CreateRemoteCacheClientParams): Promise<RemoteCacheClient> {\n const { context, options } = params;\n const { container, loginMethod, storageAccount, cachePath } = options;\n\n const { getCredential } = await import('./authentication/getCredential.js');\n const { AzureRemoteCacheClient } = await import('./AzureRemoteCacheClient.js');\n const { ReporterDecorator } = await import('./decorators/ReporterDecorator.js');\n const { getListOfBlobs } = await import('./getListOfBlobs.js');\n\n const credential = await getCredential(loginMethod, cachePath);\n\n const remoteCacheClientOptions: RemoteCacheClientOptions = {\n storageAccount,\n container,\n credential,\n };\n\n const client = new ReporterDecorator(\n new RetryDecorator({\n retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),\n cacheClient: new InMemoryDecorator({\n cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),\n getList: () => getListOfBlobs(remoteCacheClientOptions),\n }),\n }),\n context,\n );\n\n return client;\n}\n"],
5
- "mappings": ";;;AAUO,IAAM,oBAAN,MAAqD;AAAA,EAI1D,YAAY,SAAkF;AAC5F,SAAK,cAAc,QAAQ;AAC3B,SAAK,OAAO,QAAQ,QAAQ;AAAA,EAC9B;AAAA,EAEA,MAAM,aAAa,SAA6F;AAC9G,SAAK,MAAM,KAAK,MAAM,IAAI,QAAQ,EAAE,GAAG;AAErC,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,MAAM,KAAK,YAAY,aAAa,OAAO;AAE1D,QAAI,WAAW,WAAW;AAExB,OAAC,MAAM,KAAK,MAAM,IAAI,QAAQ,EAAE;AAAA,IAClC;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,eAAe,SAAuF;AAC1G,QAAI,EAAE,MAAM,KAAK,MAAM,IAAI,QAAQ,EAAE,GAAG;AAEtC,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,YAAY,eAAe,OAAO;AAAA,EAChD;AAC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