@ms-cloudpack/remote-cache 0.1.3 → 0.1.4

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 (70) hide show
  1. package/README.md +2 -7
  2. package/lib/{RemoteCacheClient.d.ts → AzureRemoteCacheClient.d.ts} +5 -4
  3. package/lib/AzureRemoteCacheClient.d.ts.map +1 -0
  4. package/lib/{RemoteCacheClient.js → AzureRemoteCacheClient.js} +18 -6
  5. package/lib/AzureRemoteCacheClient.js.map +1 -0
  6. package/lib/RemoteCacheClientWithReporter.d.ts +10 -0
  7. package/lib/RemoteCacheClientWithReporter.d.ts.map +1 -0
  8. package/lib/RemoteCacheClientWithReporter.js +64 -0
  9. package/lib/RemoteCacheClientWithReporter.js.map +1 -0
  10. package/lib/authentication/acquireSasToken.d.ts +1 -1
  11. package/lib/authentication/acquireSasToken.d.ts.map +1 -1
  12. package/lib/authentication/acquireSasToken.js +3 -5
  13. package/lib/authentication/acquireSasToken.js.map +1 -1
  14. package/lib/authentication/getAuthenticatedConnectionString.d.ts.map +1 -1
  15. package/lib/authentication/getAuthenticatedConnectionString.js +8 -2
  16. package/lib/authentication/getAuthenticatedConnectionString.js.map +1 -1
  17. package/lib/authentication/getCredential.d.ts +3 -0
  18. package/lib/authentication/getCredential.d.ts.map +1 -0
  19. package/lib/authentication/getCredential.js +10 -0
  20. package/lib/authentication/getCredential.js.map +1 -0
  21. package/lib/authentication/getSasToken.d.ts +1 -1
  22. package/lib/authentication/getSasToken.d.ts.map +1 -1
  23. package/lib/authentication/getSasToken.js +2 -2
  24. package/lib/authentication/getSasToken.js.map +1 -1
  25. package/lib/createRemoteCacheClient.d.ts +7 -10
  26. package/lib/createRemoteCacheClient.d.ts.map +1 -1
  27. package/lib/createRemoteCacheClient.js +8 -10
  28. package/lib/createRemoteCacheClient.js.map +1 -1
  29. package/lib/index.d.ts +4 -4
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +1 -2
  32. package/lib/index.js.map +1 -1
  33. package/lib/types/ConnectionStringOptions.d.ts +1 -0
  34. package/lib/types/ConnectionStringOptions.d.ts.map +1 -1
  35. package/lib/types/ConnectionStringOptions.js.map +1 -1
  36. package/lib/types/RemoteCacheClient.d.ts +11 -0
  37. package/lib/types/RemoteCacheClient.d.ts.map +1 -0
  38. package/lib/types/RemoteCacheClient.js +2 -0
  39. package/lib/types/RemoteCacheClient.js.map +1 -0
  40. package/package.json +1 -3
  41. package/lib/RemoteCacheClient.d.ts.map +0 -1
  42. package/lib/RemoteCacheClient.js.map +0 -1
  43. package/lib/createDownloadTask.d.ts +0 -5
  44. package/lib/createDownloadTask.d.ts.map +0 -1
  45. package/lib/createDownloadTask.js +0 -21
  46. package/lib/createDownloadTask.js.map +0 -1
  47. package/lib/createUploadTask.d.ts +0 -5
  48. package/lib/createUploadTask.d.ts.map +0 -1
  49. package/lib/createUploadTask.js +0 -18
  50. package/lib/createUploadTask.js.map +0 -1
  51. package/lib/getPackagesToSync.d.ts +0 -4
  52. package/lib/getPackagesToSync.d.ts.map +0 -1
  53. package/lib/getPackagesToSync.js +0 -18
  54. package/lib/getPackagesToSync.js.map +0 -1
  55. package/lib/performance/markers.d.ts +0 -13
  56. package/lib/performance/markers.d.ts.map +0 -1
  57. package/lib/performance/markers.js +0 -15
  58. package/lib/performance/markers.js.map +0 -1
  59. package/lib/syncToLocal.d.ts +0 -3
  60. package/lib/syncToLocal.d.ts.map +0 -1
  61. package/lib/syncToLocal.js +0 -21
  62. package/lib/syncToLocal.js.map +0 -1
  63. package/lib/syncToRemote.d.ts +0 -15
  64. package/lib/syncToRemote.d.ts.map +0 -1
  65. package/lib/syncToRemote.js +0 -25
  66. package/lib/syncToRemote.js.map +0 -1
  67. package/lib/types/SyncContext.d.ts +0 -24
  68. package/lib/types/SyncContext.d.ts.map +0 -1
  69. package/lib/types/SyncContext.js +0 -2
  70. package/lib/types/SyncContext.js.map +0 -1
package/README.md CHANGED
@@ -5,18 +5,13 @@ This package is a wrapper around the Azure Storage SDK that provides a simple in
5
5
  ## Usage
6
6
 
7
7
  ```ts
8
- import { getAuthenticatedConnectionString, RemoteCacheClient } from '@ms-cloudpack/remote-cache';
8
+ import { createRemoteCacheClient } from '@ms-cloudpack/remote-cache';
9
9
 
10
- const connectionString = await getAuthenticatedConnectionString({
10
+ const client = await createRemoteCacheClient({
11
11
  storageAccount: 'my-storage-account',
12
12
  container: 'my-container',
13
13
  permissions: { read: true, write: false },
14
14
  });
15
15
 
16
- const client = new RemoteCacheClient({
17
- container: 'my-container',
18
- connectionString,
19
- });
20
-
21
16
  await client.downloadFolder('my-folder', 'download-it-to-this-path');
22
17
  ```
@@ -1,5 +1,6 @@
1
1
  import type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
2
- export declare class RemoteCacheClient {
2
+ import type { RemoteCacheClient, RemoteCacheClientOperationOptions } from './types/RemoteCacheClient.js';
3
+ export declare class AzureRemoteCacheClient implements RemoteCacheClient {
3
4
  private readonly logger;
4
5
  private readonly config;
5
6
  constructor({ container, connectionString }: RemoteCacheClientOptions);
@@ -9,13 +10,13 @@ export declare class RemoteCacheClient {
9
10
  * @param path - The path to the folder to upload.
10
11
  * @returns - A promise that resolves when the folder has been uploaded.
11
12
  */
12
- uploadFolder(folderName: string, path: string): Promise<void>;
13
+ uploadFolder({ folderName, path }: RemoteCacheClientOperationOptions): Promise<"success" | "not-found">;
13
14
  /**
14
15
  * Downloads the folder from the remote cache.
15
16
  * @param folderName - The name of the folder to download.
16
17
  * @param path - The path to download the folder to.
17
18
  * @returns - A promise that resolves when the folder has been downloaded.
18
19
  */
19
- downloadFolder(folderName: string, path: string): Promise<boolean>;
20
+ downloadFolder({ folderName, path }: RemoteCacheClientOperationOptions): Promise<"success" | "not-found" | "already-exist">;
20
21
  }
21
- //# sourceMappingURL=RemoteCacheClient.d.ts.map
22
+ //# sourceMappingURL=AzureRemoteCacheClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureRemoteCacheClient.d.ts","sourceRoot":"","sources":["../src/AzureRemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAGpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AAEzG,qBAAa,sBAAuB,YAAW,iBAAiB;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsD;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAKrB;gBAEU,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,wBAAwB;IAerE;;;;;OAKG;IACG,YAAY,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,iCAAiC;IAS1E;;;;;OAKG;IACG,cAAc,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,iCAAiC;CAY7E"}
@@ -1,5 +1,6 @@
1
1
  import { makeLogger, put, fetch } from 'backfill/lib/api.js';
2
- export class RemoteCacheClient {
2
+ import { existsSync } from 'fs';
3
+ export class AzureRemoteCacheClient {
3
4
  constructor({ container, connectionString }) {
4
5
  this.logger = makeLogger('mute', process.stdout, process.stderr);
5
6
  this.config = {
@@ -21,8 +22,12 @@ export class RemoteCacheClient {
21
22
  * @param path - The path to the folder to upload.
22
23
  * @returns - A promise that resolves when the folder has been uploaded.
23
24
  */
24
- uploadFolder(folderName, path) {
25
- return put(path, folderName, this.logger, this.config);
25
+ async uploadFolder({ folderName, path }) {
26
+ if (!existsSync(path)) {
27
+ return 'not-found';
28
+ }
29
+ await put(path, folderName, this.logger, this.config);
30
+ return 'success';
26
31
  }
27
32
  /**
28
33
  * Downloads the folder from the remote cache.
@@ -30,8 +35,15 @@ export class RemoteCacheClient {
30
35
  * @param path - The path to download the folder to.
31
36
  * @returns - A promise that resolves when the folder has been downloaded.
32
37
  */
33
- downloadFolder(folderName, path) {
34
- return fetch(path, folderName, this.logger, this.config);
38
+ async downloadFolder({ folderName, path }) {
39
+ if (existsSync(path)) {
40
+ return 'already-exist';
41
+ }
42
+ const result = await fetch(path, folderName, this.logger, this.config);
43
+ if (!result) {
44
+ return 'not-found';
45
+ }
46
+ return 'success';
35
47
  }
36
48
  }
37
- //# sourceMappingURL=RemoteCacheClient.js.map
49
+ //# sourceMappingURL=AzureRemoteCacheClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureRemoteCacheClient.js","sourceRoot":"","sources":["../src/AzureRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAGhC,MAAM,OAAO,sBAAsB;IASjC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAA4B;QARpD,WAAM,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAS3E,IAAI,CAAC,MAAM,GAAG;YACZ,kBAAkB,EAAE,IAAI;YACxB,mBAAmB,EAAE,EAAE;YACvB,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,kBAAkB,EAAE;gBAClB,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE;oBACP,gBAAgB;oBAChB,SAAS;iBACV;aACF;SACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,IAAI,EAAqC;QACxE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACrB,OAAO,WAAW,CAAC;SACpB;QAED,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,IAAI,EAAqC;QAC1E,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YACpB,OAAO,eAAe,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,WAAW,CAAC;SACpB;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { makeLogger, put, fetch } from 'backfill/lib/api.js';\nimport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\nimport type { AzureBlobCacheStorageConfig } from 'backfill-config';\nimport { existsSync } from 'fs';\nimport type { RemoteCacheClient, RemoteCacheClientOperationOptions } from './types/RemoteCacheClient.js';\n\nexport class AzureRemoteCacheClient implements RemoteCacheClient {\n private readonly logger = makeLogger('mute', process.stdout, process.stderr);\n private readonly config: {\n cacheStorageConfig: AzureBlobCacheStorageConfig;\n incrementalCaching: boolean;\n internalCacheFolder: string;\n outputGlob: string[];\n };\n\n constructor({ container, connectionString }: RemoteCacheClientOptions) {\n this.config = {\n incrementalCaching: true,\n internalCacheFolder: '', // not used by azure-blob\n outputGlob: ['**/*'],\n cacheStorageConfig: {\n provider: 'azure-blob',\n options: {\n connectionString,\n container,\n },\n },\n };\n }\n\n /**\n * Uploads the folder to the remote cache.\n * @param folderName - The name of the folder to upload.\n * @param path - The path to the folder to upload.\n * @returns - A promise that resolves when the folder has been uploaded.\n */\n async uploadFolder({ folderName, path }: RemoteCacheClientOperationOptions) {\n if (!existsSync(path)) {\n return 'not-found';\n }\n\n await put(path, folderName, this.logger, this.config);\n return 'success';\n }\n\n /**\n * Downloads the folder from the remote cache.\n * @param folderName - The name of the folder to download.\n * @param path - The path to download the folder to.\n * @returns - A promise that resolves when the folder has been downloaded.\n */\n async downloadFolder({ folderName, path }: RemoteCacheClientOperationOptions) {\n if (existsSync(path)) {\n return 'already-exist';\n }\n\n const result = await fetch(path, folderName, this.logger, this.config);\n if (!result) {\n return 'not-found';\n }\n\n return 'success';\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { type TaskReporter } from '@ms-cloudpack/task-reporter';
2
+ import type { RemoteCacheClient, RemoteCacheClientOperationOptions } from './types/RemoteCacheClient.js';
3
+ export declare class RemoteCacheClientWithReporter implements RemoteCacheClient {
4
+ private readonly client;
5
+ private readonly reporter;
6
+ constructor(client: RemoteCacheClient, reporter: TaskReporter);
7
+ uploadFolder(options: RemoteCacheClientOperationOptions): Promise<import("./types/RemoteCacheClient.js").RemoteCacheClientOperationResult>;
8
+ downloadFolder(options: RemoteCacheClientOperationOptions): Promise<import("./types/RemoteCacheClient.js").RemoteCacheClientOperationResult>;
9
+ }
10
+ //# sourceMappingURL=RemoteCacheClientWithReporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteCacheClientWithReporter.d.ts","sourceRoot":"","sources":["../src/RemoteCacheClientWithReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AAEzG,qBAAa,6BAA8B,YAAW,iBAAiB;IAEnE,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,YAAY;IAGnC,YAAY,CAAC,OAAO,EAAE,iCAAiC;IAgCvD,cAAc,CAAC,OAAO,EAAE,iCAAiC;CA+BhE"}
@@ -0,0 +1,64 @@
1
+ import { bulletedList } from '@ms-cloudpack/task-reporter';
2
+ export class RemoteCacheClientWithReporter {
3
+ constructor(client, reporter) {
4
+ this.client = client;
5
+ this.reporter = reporter;
6
+ }
7
+ async uploadFolder(options) {
8
+ const { folderName, path, friendlyName } = options;
9
+ const task = this.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);
10
+ const uploadResult = await this.client.uploadFolder(options);
11
+ switch (uploadResult) {
12
+ case 'success':
13
+ task.complete({
14
+ status: 'complete',
15
+ details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),
16
+ });
17
+ break;
18
+ case 'not-found':
19
+ task.complete({
20
+ status: 'skip',
21
+ message: `Not found in the local cache.`,
22
+ });
23
+ break;
24
+ case 'already-exist':
25
+ task.complete({
26
+ status: 'skip',
27
+ message: `Package is already exist in the remote cache.`,
28
+ });
29
+ break;
30
+ default:
31
+ throw new Error(`Unknown upload result: ${uploadResult}`);
32
+ }
33
+ return uploadResult;
34
+ }
35
+ async downloadFolder(options) {
36
+ const { folderName, path, friendlyName } = options;
37
+ const task = this.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);
38
+ const downloadResult = await this.client.downloadFolder(options);
39
+ switch (downloadResult) {
40
+ case 'success':
41
+ task.complete({
42
+ status: 'complete',
43
+ details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),
44
+ });
45
+ break;
46
+ case 'not-found':
47
+ task.complete({
48
+ status: 'skip',
49
+ message: `Not found in the remote cache.`,
50
+ });
51
+ break;
52
+ case 'already-exist':
53
+ task.complete({
54
+ status: 'skip',
55
+ message: `Package is already exist in the local cache.`,
56
+ });
57
+ break;
58
+ default:
59
+ throw new Error(`Unknown download result: ${downloadResult}`);
60
+ }
61
+ return downloadResult;
62
+ }
63
+ }
64
+ //# sourceMappingURL=RemoteCacheClientWithReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteCacheClientWithReporter.js","sourceRoot":"","sources":["../src/RemoteCacheClientWithReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAG9E,MAAM,OAAO,6BAA6B;IACxC,YACmB,MAAyB,EACzB,QAAsB;QADtB,WAAM,GAAN,MAAM,CAAmB;QACzB,aAAQ,GAAR,QAAQ,CAAc;IACtC,CAAC;IAEJ,KAAK,CAAC,YAAY,CAAC,OAA0C;QAC3D,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,8BAA8B,YAAY,EAAE,CAAC,CAAC;QAEjF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE7D,QAAQ,YAAY,EAAE;YACpB,KAAK,SAAS;gBACZ,IAAI,CAAC,QAAQ,CAAC;oBACZ,MAAM,EAAE,UAAU;oBAClB,OAAO,EAAE,YAAY,CAAC,CAAC,eAAe,UAAU,EAAE,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,YAAY,EAAE,CAAC,CAAC;iBAC/F,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,WAAW;gBACd,IAAI,CAAC,QAAQ,CAAC;oBACZ,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,+BAA+B;iBACzC,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,eAAe;gBAClB,IAAI,CAAC,QAAQ,CAAC;oBACZ,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,+CAA+C;iBACzD,CAAC,CAAC;gBACH,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAC;SAC7D;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAA0C;QAC7D,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,kCAAkC,YAAY,EAAE,CAAC,CAAC;QAErF,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAEjE,QAAQ,cAAc,EAAE;YACtB,KAAK,SAAS;gBACZ,IAAI,CAAC,QAAQ,CAAC;oBACZ,MAAM,EAAE,UAAU;oBAClB,OAAO,EAAE,YAAY,CAAC,CAAC,eAAe,UAAU,EAAE,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,YAAY,EAAE,CAAC,CAAC;iBAC/F,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,WAAW;gBACd,IAAI,CAAC,QAAQ,CAAC;oBACZ,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,gCAAgC;iBAC1C,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,eAAe;gBAClB,IAAI,CAAC,QAAQ,CAAC;oBACZ,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,8CAA8C;iBACxD,CAAC,CAAC;gBACH,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,cAAc,EAAE,CAAC,CAAC;SACjE;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { bulletedList, type TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { RemoteCacheClient, RemoteCacheClientOperationOptions } from './types/RemoteCacheClient.js';\n\nexport class RemoteCacheClientWithReporter implements RemoteCacheClient {\n constructor(\n private readonly client: RemoteCacheClient,\n private readonly reporter: TaskReporter,\n ) {}\n\n async uploadFolder(options: RemoteCacheClientOperationOptions) {\n const { folderName, path, friendlyName } = options;\n const task = this.reporter.addTask(`Uploading to remote cache: ${friendlyName}`);\n\n const uploadResult = await this.client.uploadFolder(options);\n\n switch (uploadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the local cache.`,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the remote cache.`,\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 { folderName, path, friendlyName } = options;\n const task = this.reporter.addTask(`Downloading from remote cache: ${friendlyName}`);\n\n const downloadResult = await this.client.downloadFolder(options);\n\n switch (downloadResult) {\n case 'success':\n task.complete({\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Name: ${friendlyName}`]),\n });\n break;\n case 'not-found':\n task.complete({\n status: 'skip',\n message: `Not found in the remote cache.`,\n });\n break;\n case 'already-exist':\n task.complete({\n status: 'skip',\n message: `Package is already exist in the local cache.`,\n });\n break;\n default:\n throw new Error(`Unknown download result: ${downloadResult}`);\n }\n\n return downloadResult;\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  import type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';
2
- export declare function acquireSasToken({ storageAccount: account, container, permissions }: ConnectionStringOptions): Promise<string>;
2
+ export declare function acquireSasToken({ storageAccount: account, container, permissions, isInteractiveLogin, }: ConnectionStringOptions): Promise<string>;
3
3
  //# sourceMappingURL=acquireSasToken.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"acquireSasToken.d.ts","sourceRoot":"","sources":["../../src/authentication/acquireSasToken.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAGnF,wBAAsB,eAAe,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,uBAAuB,mBA2BjH"}
1
+ {"version":3,"file":"acquireSasToken.d.ts","sourceRoot":"","sources":["../../src/authentication/acquireSasToken.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAInF,wBAAsB,eAAe,CAAC,EACpC,cAAc,EAAE,OAAO,EACvB,SAAS,EACT,WAAW,EACX,kBAAkB,GACnB,EAAE,uBAAuB,mBAyBzB"}
@@ -1,10 +1,8 @@
1
1
  import { BlobServiceClient, ContainerSASPermissions, SASProtocol, generateBlobSASQueryParameters, } from '@azure/storage-blob';
2
- import { InteractiveBrowserCredential } from '@azure/identity';
3
2
  import { createBlobStorageUrl } from './createBlobStorageUrl.js';
4
- export async function acquireSasToken({ storageAccount: account, container, permissions }) {
5
- const credential = new InteractiveBrowserCredential({
6
- redirectUri: 'http://localhost:1337',
7
- });
3
+ import { getCredential } from './getCredential.js';
4
+ export async function acquireSasToken({ storageAccount: account, container, permissions, isInteractiveLogin, }) {
5
+ const credential = getCredential(isInteractiveLogin);
8
6
  const blobStorage = new BlobServiceClient(createBlobStorageUrl(account), credential);
9
7
  const containerClient = blobStorage.getContainerClient(container);
10
8
  const startsOn = new Date(); // now
@@ -1 +1 @@
1
- {"version":3,"file":"acquireSasToken.js","sourceRoot":"","sources":["../../src/authentication/acquireSasToken.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,EACX,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAA2B;IAChH,MAAM,UAAU,GAAG,IAAI,4BAA4B,CAAC;QAClD,WAAW,EAAE,uBAAuB;KACrC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IACrF,MAAM,eAAe,GAAG,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM;IACnC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,mBAAmB,CAAC,CAAC,CAAC,cAAc;IAEpF,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEtF,MAAM,cAAc,GAAG,8BAA8B,CACnD;QACE,aAAa,EAAE,eAAe,CAAC,aAAa;QAC5C,WAAW,EAAE,uBAAuB,CAAC,IAAI,CAAC,WAAW,CAAC;QACtD,SAAS;QACT,QAAQ;QACR,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,iBAAiB,EAAE;QACrD,QAAQ,EAAE,WAAW,CAAC,KAAK;KAC5B,EACD,iBAAiB,EACjB,OAAO,CACR,CAAC;IAEF,OAAO,cAAc,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import {\n BlobServiceClient,\n ContainerSASPermissions,\n SASProtocol,\n generateBlobSASQueryParameters,\n} from '@azure/storage-blob';\nimport { InteractiveBrowserCredential } from '@azure/identity';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\nimport { createBlobStorageUrl } from './createBlobStorageUrl.js';\n\nexport async function acquireSasToken({ storageAccount: account, container, permissions }: ConnectionStringOptions) {\n const credential = new InteractiveBrowserCredential({\n redirectUri: 'http://localhost:1337',\n });\n const blobStorage = new BlobServiceClient(createBlobStorageUrl(account), credential);\n const containerClient = blobStorage.getContainerClient(container);\n\n const startsOn = new Date(); // now\n const twentyFourHoursInMs = 86400000;\n const expiresOn = new Date(startsOn.valueOf() + twentyFourHoursInMs); // in 24 hours\n\n const userDelegationKey = await blobStorage.getUserDelegationKey(startsOn, expiresOn);\n\n const sasQueryParams = generateBlobSASQueryParameters(\n {\n containerName: containerClient.containerName,\n permissions: ContainerSASPermissions.from(permissions),\n expiresOn,\n startsOn,\n ipRange: { start: '0.0.0.0', end: '255.255.255.255' },\n protocol: SASProtocol.Https,\n },\n userDelegationKey,\n account,\n );\n\n return sasQueryParams.toString();\n}\n"]}
1
+ {"version":3,"file":"acquireSasToken.js","sourceRoot":"","sources":["../../src/authentication/acquireSasToken.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,EACX,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,cAAc,EAAE,OAAO,EACvB,SAAS,EACT,WAAW,EACX,kBAAkB,GACM;IACxB,MAAM,UAAU,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IACrF,MAAM,eAAe,GAAG,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM;IACnC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,mBAAmB,CAAC,CAAC,CAAC,cAAc;IAEpF,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEtF,MAAM,cAAc,GAAG,8BAA8B,CACnD;QACE,aAAa,EAAE,eAAe,CAAC,aAAa;QAC5C,WAAW,EAAE,uBAAuB,CAAC,IAAI,CAAC,WAAW,CAAC;QACtD,SAAS;QACT,QAAQ;QACR,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,iBAAiB,EAAE;QACrD,QAAQ,EAAE,WAAW,CAAC,KAAK;KAC5B,EACD,iBAAiB,EACjB,OAAO,CACR,CAAC;IAEF,OAAO,cAAc,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import {\n BlobServiceClient,\n ContainerSASPermissions,\n SASProtocol,\n generateBlobSASQueryParameters,\n} from '@azure/storage-blob';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\nimport { createBlobStorageUrl } from './createBlobStorageUrl.js';\nimport { getCredential } from './getCredential.js';\n\nexport async function acquireSasToken({\n storageAccount: account,\n container,\n permissions,\n isInteractiveLogin,\n}: ConnectionStringOptions) {\n const credential = getCredential(isInteractiveLogin);\n const blobStorage = new BlobServiceClient(createBlobStorageUrl(account), credential);\n const containerClient = blobStorage.getContainerClient(container);\n\n const startsOn = new Date(); // now\n const twentyFourHoursInMs = 86400000;\n const expiresOn = new Date(startsOn.valueOf() + twentyFourHoursInMs); // in 24 hours\n\n const userDelegationKey = await blobStorage.getUserDelegationKey(startsOn, expiresOn);\n\n const sasQueryParams = generateBlobSASQueryParameters(\n {\n containerName: containerClient.containerName,\n permissions: ContainerSASPermissions.from(permissions),\n expiresOn,\n startsOn,\n ipRange: { start: '0.0.0.0', end: '255.255.255.255' },\n protocol: SASProtocol.Https,\n },\n userDelegationKey,\n account,\n );\n\n return sasQueryParams.toString();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getAuthenticatedConnectionString.d.ts","sourceRoot":"","sources":["../../src/authentication/getAuthenticatedConnectionString.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAMnF,wBAAsB,gCAAgC,CAAC,uBAAuB,EAAE,uBAAuB,mBAMtG"}
1
+ {"version":3,"file":"getAuthenticatedConnectionString.d.ts","sourceRoot":"","sources":["../../src/authentication/getAuthenticatedConnectionString.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAUnF,wBAAsB,gCAAgC,CAAC,uBAAuB,EAAE,uBAAuB,mBAUtG"}
@@ -1,10 +1,16 @@
1
1
  import { createBlobStorageUrl } from './createBlobStorageUrl.js';
2
2
  import { getSasToken } from './getSasToken.js';
3
- import { KeyRingLocalTokenCache } from './KeyRingLocalTokenCache.js';
4
3
  import { acquireSasToken } from './acquireSasToken.js';
5
4
  import { isExpired } from './isExpired.js';
5
+ async function createLocalTokenCacheLazy(connectionStringOptions) {
6
+ const { KeyRingLocalTokenCache } = await import('./KeyRingLocalTokenCache.js');
7
+ return new KeyRingLocalTokenCache(connectionStringOptions);
8
+ }
6
9
  export async function getAuthenticatedConnectionString(connectionStringOptions) {
7
- const tokenCache = new KeyRingLocalTokenCache(connectionStringOptions);
10
+ // No need to cache tokens if the user is NOT running in interactive mode.
11
+ const tokenCache = connectionStringOptions.isInteractiveLogin
12
+ ? await createLocalTokenCacheLazy(connectionStringOptions)
13
+ : undefined;
8
14
  const sasToken = await getSasToken({ connectionStringOptions }, { tokenCache, acquireSasToken, isExpired });
9
15
  const { storageAccount } = connectionStringOptions;
10
16
  return `BlobEndpoint=${createBlobStorageUrl(storageAccount)};SharedAccessSignature=${sasToken}`;
@@ -1 +1 @@
1
- {"version":3,"file":"getAuthenticatedConnectionString.js","sourceRoot":"","sources":["../../src/authentication/getAuthenticatedConnectionString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,uBAAgD;IACrG,MAAM,UAAU,GAAG,IAAI,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,EAAE,uBAAuB,EAAE,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAE5G,MAAM,EAAE,cAAc,EAAE,GAAG,uBAAuB,CAAC;IACnD,OAAO,gBAAgB,oBAAoB,CAAC,cAAc,CAAC,0BAA0B,QAAQ,EAAE,CAAC;AAClG,CAAC","sourcesContent":["import { createBlobStorageUrl } from './createBlobStorageUrl.js';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\nimport { getSasToken } from './getSasToken.js';\nimport { KeyRingLocalTokenCache } from './KeyRingLocalTokenCache.js';\nimport { acquireSasToken } from './acquireSasToken.js';\nimport { isExpired } from './isExpired.js';\n\nexport async function getAuthenticatedConnectionString(connectionStringOptions: ConnectionStringOptions) {\n const tokenCache = new KeyRingLocalTokenCache(connectionStringOptions);\n const sasToken = await getSasToken({ connectionStringOptions }, { tokenCache, acquireSasToken, isExpired });\n\n const { storageAccount } = connectionStringOptions;\n return `BlobEndpoint=${createBlobStorageUrl(storageAccount)};SharedAccessSignature=${sasToken}`;\n}\n"]}
1
+ {"version":3,"file":"getAuthenticatedConnectionString.js","sourceRoot":"","sources":["../../src/authentication/getAuthenticatedConnectionString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,KAAK,UAAU,yBAAyB,CAAC,uBAAgD;IACvF,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IAC/E,OAAO,IAAI,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,uBAAgD;IACrG,0EAA0E;IAC1E,MAAM,UAAU,GAAG,uBAAuB,CAAC,kBAAkB;QAC3D,CAAC,CAAC,MAAM,yBAAyB,CAAC,uBAAuB,CAAC;QAC1D,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,EAAE,uBAAuB,EAAE,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAE5G,MAAM,EAAE,cAAc,EAAE,GAAG,uBAAuB,CAAC;IACnD,OAAO,gBAAgB,oBAAoB,CAAC,cAAc,CAAC,0BAA0B,QAAQ,EAAE,CAAC;AAClG,CAAC","sourcesContent":["import { createBlobStorageUrl } from './createBlobStorageUrl.js';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\nimport { getSasToken } from './getSasToken.js';\nimport { acquireSasToken } from './acquireSasToken.js';\nimport { isExpired } from './isExpired.js';\n\nasync function createLocalTokenCacheLazy(connectionStringOptions: ConnectionStringOptions) {\n const { KeyRingLocalTokenCache } = await import('./KeyRingLocalTokenCache.js');\n return new KeyRingLocalTokenCache(connectionStringOptions);\n}\n\nexport async function getAuthenticatedConnectionString(connectionStringOptions: ConnectionStringOptions) {\n // No need to cache tokens if the user is NOT running in interactive mode.\n const tokenCache = connectionStringOptions.isInteractiveLogin\n ? await createLocalTokenCacheLazy(connectionStringOptions)\n : undefined;\n\n const sasToken = await getSasToken({ connectionStringOptions }, { tokenCache, acquireSasToken, isExpired });\n\n const { storageAccount } = connectionStringOptions;\n return `BlobEndpoint=${createBlobStorageUrl(storageAccount)};SharedAccessSignature=${sasToken}`;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { DefaultAzureCredential, InteractiveBrowserCredential } from '@azure/identity';
2
+ export declare function getCredential(isInteractiveLogin: boolean): InteractiveBrowserCredential | DefaultAzureCredential;
3
+ //# sourceMappingURL=getCredential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCredential.d.ts","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEvF,wBAAgB,aAAa,CAAC,kBAAkB,EAAE,OAAO,yDAOxD"}
@@ -0,0 +1,10 @@
1
+ import { DefaultAzureCredential, InteractiveBrowserCredential } from '@azure/identity';
2
+ export function getCredential(isInteractiveLogin) {
3
+ if (isInteractiveLogin) {
4
+ return new InteractiveBrowserCredential({
5
+ redirectUri: 'http://localhost:1337',
6
+ });
7
+ }
8
+ return new DefaultAzureCredential();
9
+ }
10
+ //# sourceMappingURL=getCredential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCredential.js","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEvF,MAAM,UAAU,aAAa,CAAC,kBAA2B;IACvD,IAAI,kBAAkB,EAAE;QACtB,OAAO,IAAI,4BAA4B,CAAC;YACtC,WAAW,EAAE,uBAAuB;SACrC,CAAC,CAAC;KACJ;IACD,OAAO,IAAI,sBAAsB,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { DefaultAzureCredential, InteractiveBrowserCredential } from '@azure/identity';\n\nexport function getCredential(isInteractiveLogin: boolean) {\n if (isInteractiveLogin) {\n return new InteractiveBrowserCredential({\n redirectUri: 'http://localhost:1337',\n });\n }\n return new DefaultAzureCredential();\n}\n"]}
@@ -4,7 +4,7 @@ export interface GetSasTokenOptions {
4
4
  connectionStringOptions: ConnectionStringOptions;
5
5
  }
6
6
  export interface GetSasTokenDependencies {
7
- tokenCache: LocalTokenCacheProvider;
7
+ tokenCache?: LocalTokenCacheProvider;
8
8
  acquireSasToken: (options: ConnectionStringOptions) => Promise<string>;
9
9
  isExpired: (token: string) => boolean;
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getSasToken.d.ts","sourceRoot":"","sources":["../../src/authentication/getSasToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAEnF,MAAM,WAAW,kBAAkB;IACjC,uBAAuB,EAAE,uBAAuB,CAAC;CAClD;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,uBAAuB,CAAC;IACpC,eAAe,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AAED,wBAAsB,WAAW,CAC/B,EAAE,uBAAuB,EAAE,EAAE,kBAAkB,EAC/C,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAcpE"}
1
+ {"version":3,"file":"getSasToken.d.ts","sourceRoot":"","sources":["../../src/authentication/getSasToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAEnF,MAAM,WAAW,kBAAkB;IACjC,uBAAuB,EAAE,uBAAuB,CAAC;CAClD;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,eAAe,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AAED,wBAAsB,WAAW,CAC/B,EAAE,uBAAuB,EAAE,EAAE,kBAAkB,EAC/C,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAcpE"}
@@ -1,11 +1,11 @@
1
1
  export async function getSasToken({ connectionStringOptions }, { tokenCache, acquireSasToken, isExpired }) {
2
2
  try {
3
- const localToken = tokenCache.get();
3
+ const localToken = tokenCache?.get();
4
4
  if (localToken && !isExpired(localToken)) {
5
5
  return localToken;
6
6
  }
7
7
  const token = await acquireSasToken(connectionStringOptions);
8
- tokenCache.set(token);
8
+ tokenCache?.set(token);
9
9
  return token;
10
10
  }
11
11
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"getSasToken.js","sourceRoot":"","sources":["../../src/authentication/getSasToken.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,EAAE,uBAAuB,EAAsB,EAC/C,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAA2B;IAEnE,IAAI;QACF,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;QACpC,IAAI,UAAU,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;YACxC,OAAO,UAAU,CAAC;SACnB;QAED,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,uBAAuB,CAAC,CAAC;QAC7D,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtB,OAAO,KAAK,CAAC;KACd;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;KAC/D;AACH,CAAC","sourcesContent":["import type { LocalTokenCacheProvider } from '../types/LocalTokenCacheProvider.js';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\n\nexport interface GetSasTokenOptions {\n connectionStringOptions: ConnectionStringOptions;\n}\n\nexport interface GetSasTokenDependencies {\n tokenCache: LocalTokenCacheProvider;\n acquireSasToken: (options: ConnectionStringOptions) => Promise<string>;\n isExpired: (token: string) => boolean;\n}\n\nexport async function getSasToken(\n { connectionStringOptions }: GetSasTokenOptions,\n { tokenCache, acquireSasToken, isExpired }: GetSasTokenDependencies,\n) {\n try {\n const localToken = tokenCache.get();\n if (localToken && !isExpired(localToken)) {\n return localToken;\n }\n\n const token = await acquireSasToken(connectionStringOptions);\n tokenCache.set(token);\n return token;\n } catch (error) {\n console.error(`Failed to get SAS token for storage account.`);\n }\n}\n"]}
1
+ {"version":3,"file":"getSasToken.js","sourceRoot":"","sources":["../../src/authentication/getSasToken.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,EAAE,uBAAuB,EAAsB,EAC/C,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAA2B;IAEnE,IAAI;QACF,MAAM,UAAU,GAAG,UAAU,EAAE,GAAG,EAAE,CAAC;QACrC,IAAI,UAAU,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;YACxC,OAAO,UAAU,CAAC;SACnB;QAED,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,uBAAuB,CAAC,CAAC;QAC7D,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;KACd;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;KAC/D;AACH,CAAC","sourcesContent":["import type { LocalTokenCacheProvider } from '../types/LocalTokenCacheProvider.js';\nimport type { ConnectionStringOptions } from '../types/ConnectionStringOptions.js';\n\nexport interface GetSasTokenOptions {\n connectionStringOptions: ConnectionStringOptions;\n}\n\nexport interface GetSasTokenDependencies {\n tokenCache?: LocalTokenCacheProvider;\n acquireSasToken: (options: ConnectionStringOptions) => Promise<string>;\n isExpired: (token: string) => boolean;\n}\n\nexport async function getSasToken(\n { connectionStringOptions }: GetSasTokenOptions,\n { tokenCache, acquireSasToken, isExpired }: GetSasTokenDependencies,\n) {\n try {\n const localToken = tokenCache?.get();\n if (localToken && !isExpired(localToken)) {\n return localToken;\n }\n\n const token = await acquireSasToken(connectionStringOptions);\n tokenCache?.set(token);\n return token;\n } catch (error) {\n console.error(`Failed to get SAS token for storage account.`);\n }\n}\n"]}
@@ -1,11 +1,8 @@
1
- import { RemoteCacheClient } from './RemoteCacheClient.js';
2
- import type { SyncContext } from './types/SyncContext.js';
3
- export interface ClientOptions {
4
- permissions: {
5
- read: boolean;
6
- write: boolean;
7
- };
8
- config: SyncContext['config'];
9
- }
10
- export declare function createRemoteCacheClient({ config, permissions }: ClientOptions): Promise<RemoteCacheClient>;
1
+ import type { RemoteCacheClient } from './types/RemoteCacheClient.js';
2
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
+ import type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';
4
+ export declare function createRemoteCacheClient(options: {
5
+ connectionStringOptions: ConnectionStringOptions;
6
+ reporter: TaskReporter;
7
+ }): Promise<RemoteCacheClient>;
11
8
  //# sourceMappingURL=createRemoteCacheClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRemoteCacheClient.d.ts","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE;QACX,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAC/B;AAED,wBAAsB,uBAAuB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,aAAa,8BAenF"}
1
+ {"version":3,"file":"createRemoteCacheClient.d.ts","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAElF,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,QAAQ,EAAE,YAAY,CAAC;CACxB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAe7B"}
@@ -1,16 +1,14 @@
1
- import { RemoteCacheClient } from './RemoteCacheClient.js';
1
+ import { AzureRemoteCacheClient } from './AzureRemoteCacheClient.js';
2
2
  import { getAuthenticatedConnectionString } from './authentication/getAuthenticatedConnectionString.js';
3
- export async function createRemoteCacheClient({ config, permissions }) {
4
- const { container, storageAccount } = config;
5
- const connectionString = await getAuthenticatedConnectionString({
6
- storageAccount,
7
- container,
8
- permissions,
9
- });
10
- const client = new RemoteCacheClient({
3
+ import { RemoteCacheClientWithReporter } from './RemoteCacheClientWithReporter.js';
4
+ export async function createRemoteCacheClient(options) {
5
+ const { connectionStringOptions, reporter } = options;
6
+ const { container } = connectionStringOptions;
7
+ const connectionString = await getAuthenticatedConnectionString(connectionStringOptions);
8
+ const client = new RemoteCacheClientWithReporter(new AzureRemoteCacheClient({
11
9
  container,
12
10
  connectionString,
13
- });
11
+ }), reporter);
14
12
  return client;
15
13
  }
16
14
  //# sourceMappingURL=createRemoteCacheClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRemoteCacheClient.js","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AAWxG,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAiB;IAClF,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAE7C,MAAM,gBAAgB,GAAG,MAAM,gCAAgC,CAAC;QAC9D,cAAc;QACd,SAAS;QACT,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC;QACnC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { RemoteCacheClient } from './RemoteCacheClient.js';\nimport { getAuthenticatedConnectionString } from './authentication/getAuthenticatedConnectionString.js';\nimport type { SyncContext } from './types/SyncContext.js';\n\nexport interface ClientOptions {\n permissions: {\n read: boolean;\n write: boolean;\n };\n config: SyncContext['config'];\n}\n\nexport async function createRemoteCacheClient({ config, permissions }: ClientOptions) {\n const { container, storageAccount } = config;\n\n const connectionString = await getAuthenticatedConnectionString({\n storageAccount,\n container,\n permissions,\n });\n\n const client = new RemoteCacheClient({\n container,\n connectionString,\n });\n\n return client;\n}\n"]}
1
+ {"version":3,"file":"createRemoteCacheClient.js","sourceRoot":"","sources":["../src/createRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAInF,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAG7C;IACC,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtD,MAAM,EAAE,SAAS,EAAE,GAAG,uBAAuB,CAAC;IAE9C,MAAM,gBAAgB,GAAG,MAAM,gCAAgC,CAAC,uBAAuB,CAAC,CAAC;IAEzF,MAAM,MAAM,GAAG,IAAI,6BAA6B,CAC9C,IAAI,sBAAsB,CAAC;QACzB,SAAS;QACT,gBAAgB;KACjB,CAAC,EACF,QAAQ,CACT,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { AzureRemoteCacheClient } from './AzureRemoteCacheClient.js';\nimport type { RemoteCacheClient } from './types/RemoteCacheClient.js';\nimport { getAuthenticatedConnectionString } from './authentication/getAuthenticatedConnectionString.js';\nimport { RemoteCacheClientWithReporter } from './RemoteCacheClientWithReporter.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';\n\nexport async function createRemoteCacheClient(options: {\n connectionStringOptions: ConnectionStringOptions;\n reporter: TaskReporter;\n}): Promise<RemoteCacheClient> {\n const { connectionStringOptions, reporter } = options;\n const { container } = connectionStringOptions;\n\n const connectionString = await getAuthenticatedConnectionString(connectionStringOptions);\n\n const client = new RemoteCacheClientWithReporter(\n new AzureRemoteCacheClient({\n container,\n connectionString,\n }),\n reporter,\n );\n\n return client;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { syncToLocal } from './syncToLocal.js';
2
- export { syncToRemote } from './syncToRemote.js';
3
- export type { SyncContext } from './types/SyncContext.js';
4
- export type { PackageToSync } from './types/PackageToSync.js';
1
+ export { createRemoteCacheClient } from './createRemoteCacheClient.js';
2
+ export type { RemoteCacheClient, RemoteCacheClientOperationOptions, RemoteCacheClientOperationResult, } from './types/RemoteCacheClient.js';
3
+ export type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';
4
+ export type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,YAAY,EACV,iBAAiB,EACjB,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,YAAY,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC"}
package/lib/index.js CHANGED
@@ -1,3 +1,2 @@
1
- export { syncToLocal } from './syncToLocal.js';
2
- export { syncToRemote } from './syncToRemote.js';
1
+ export { createRemoteCacheClient } from './createRemoteCacheClient.js';
3
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { syncToLocal } from './syncToLocal.js';\nexport { syncToRemote } from './syncToRemote.js';\n\nexport type { SyncContext } from './types/SyncContext.js';\nexport type { PackageToSync } from './types/PackageToSync.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export { createRemoteCacheClient } from './createRemoteCacheClient.js';\n\nexport type {\n RemoteCacheClient,\n RemoteCacheClientOperationOptions,\n RemoteCacheClientOperationResult,\n} from './types/RemoteCacheClient.js';\nexport type { ConnectionStringOptions } from './types/ConnectionStringOptions.js';\nexport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\n"]}
@@ -5,5 +5,6 @@ export interface ConnectionStringOptions {
5
5
  read: boolean;
6
6
  write: boolean;
7
7
  };
8
+ isInteractiveLogin: boolean;
8
9
  }
9
10
  //# sourceMappingURL=ConnectionStringOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionStringOptions.d.ts","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QACX,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;CACH"}
1
+ {"version":3,"file":"ConnectionStringOptions.d.ts","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QACX,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,kBAAkB,EAAE,OAAO,CAAC;CAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionStringOptions.js","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConnectionStringOptions {\n storageAccount: string;\n container: string;\n permissions: {\n read: boolean;\n write: boolean;\n };\n}\n"]}
1
+ {"version":3,"file":"ConnectionStringOptions.js","sourceRoot":"","sources":["../../src/types/ConnectionStringOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConnectionStringOptions {\n storageAccount: string;\n container: string;\n permissions: {\n read: boolean;\n write: boolean;\n };\n isInteractiveLogin: boolean;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ export type RemoteCacheClientOperationResult = 'success' | 'not-found' | 'already-exist';
2
+ export interface RemoteCacheClientOperationOptions {
3
+ folderName: string;
4
+ path: string;
5
+ friendlyName: string;
6
+ }
7
+ export interface RemoteCacheClient {
8
+ uploadFolder(options: RemoteCacheClientOperationOptions): Promise<RemoteCacheClientOperationResult>;
9
+ downloadFolder(options: RemoteCacheClientOperationOptions): Promise<RemoteCacheClientOperationResult>;
10
+ }
11
+ //# sourceMappingURL=RemoteCacheClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteCacheClient.d.ts","sourceRoot":"","sources":["../../src/types/RemoteCacheClient.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gCAAgC,GAAG,SAAS,GAAG,WAAW,GAAG,eAAe,CAAC;AAEzF,MAAM,WAAW,iCAAiC;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;IACpG,cAAc,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;CACvG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RemoteCacheClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteCacheClient.js","sourceRoot":"","sources":["../../src/types/RemoteCacheClient.ts"],"names":[],"mappings":"","sourcesContent":["export type RemoteCacheClientOperationResult = 'success' | 'not-found' | 'already-exist';\n\nexport interface RemoteCacheClientOperationOptions {\n folderName: string;\n path: string;\n friendlyName: string;\n}\n\nexport interface RemoteCacheClient {\n uploadFolder(options: RemoteCacheClientOperationOptions): Promise<RemoteCacheClientOperationResult>;\n downloadFolder(options: RemoteCacheClientOperationOptions): Promise<RemoteCacheClientOperationResult>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/remote-cache",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Manages syncing the local Cloudpack cached assets to/from a remote storage service.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,8 +29,6 @@
29
29
  "lib/**/!(*.test.*)"
30
30
  ],
31
31
  "dependencies": {
32
- "@ms-cloudpack/bundler-types": "^0.17.0",
33
- "@ms-cloudpack/package-utilities": "^5.1.1",
34
32
  "@ms-cloudpack/task-reporter": "^0.7.2",
35
33
  "@azure/identity": "^3.2.3",
36
34
  "@azure/storage-blob": "^12.15.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"RemoteCacheClient.d.ts","sourceRoot":"","sources":["../src/RemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAGpF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsD;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAKrB;gBAEU,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,wBAAwB;IAerE;;;;;OAKG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAI7C;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAGhD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"RemoteCacheClient.js","sourceRoot":"","sources":["../src/RemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI7D,MAAM,OAAO,iBAAiB;IAS5B,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAA4B;QARpD,WAAM,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAS3E,IAAI,CAAC,MAAM,GAAG;YACZ,kBAAkB,EAAE,IAAI;YACxB,mBAAmB,EAAE,EAAE;YACvB,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,kBAAkB,EAAE;gBAClB,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE;oBACP,gBAAgB;oBAChB,SAAS;iBACV;aACF;SACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,UAAkB,EAAE,IAAY;QAC3C,OAAO,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,UAAkB,EAAE,IAAY;QAC7C,OAAO,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF","sourcesContent":["import { makeLogger, put, fetch } from 'backfill/lib/api.js';\nimport type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';\nimport type { AzureBlobCacheStorageConfig } from 'backfill-config';\n\nexport class RemoteCacheClient {\n private readonly logger = makeLogger('mute', process.stdout, process.stderr);\n private readonly config: {\n cacheStorageConfig: AzureBlobCacheStorageConfig;\n incrementalCaching: boolean;\n internalCacheFolder: string;\n outputGlob: string[];\n };\n\n constructor({ container, connectionString }: RemoteCacheClientOptions) {\n this.config = {\n incrementalCaching: true,\n internalCacheFolder: '', // not used by azure-blob\n outputGlob: ['**/*'],\n cacheStorageConfig: {\n provider: 'azure-blob',\n options: {\n connectionString,\n container,\n },\n },\n };\n }\n\n /**\n * Uploads the folder to the remote cache.\n * @param folderName - The name of the folder to upload.\n * @param path - The path to the folder to upload.\n * @returns - A promise that resolves when the folder has been uploaded.\n */\n uploadFolder(folderName: string, path: string) {\n return put(path, folderName, this.logger, this.config);\n }\n\n /**\n * Downloads the folder from the remote cache.\n * @param folderName - The name of the folder to download.\n * @param path - The path to download the folder to.\n * @returns - A promise that resolves when the folder has been downloaded.\n */\n downloadFolder(folderName: string, path: string) {\n return fetch(path, folderName, this.logger, this.config);\n }\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { RemoteCacheClient } from './RemoteCacheClient.js';
2
- import type { Task } from './Task.js';
3
- import type { PackageToSync } from './types/PackageToSync.js';
4
- export declare function createDownloadTask(client: RemoteCacheClient, { folderName, packageName, path, version }: PackageToSync): Task;
5
- //# sourceMappingURL=createDownloadTask.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createDownloadTask.d.ts","sourceRoot":"","sources":["../src/createDownloadTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,iBAAiB,EACzB,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,aAAa,GACxD,IAAI,CAmBN"}
@@ -1,21 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import { bulletedList } from '@ms-cloudpack/task-reporter';
3
- export function createDownloadTask(client, { folderName, packageName, path, version }) {
4
- return {
5
- name: `Downloading ${packageName}@${version}`,
6
- execute: async () => {
7
- if (existsSync(path)) {
8
- return { status: 'skip', message: 'Package is already exist in the local cache.' };
9
- }
10
- const result = await client.downloadFolder(folderName, path);
11
- if (!result) {
12
- return { status: 'skip', message: `not found in the remote cache.` };
13
- }
14
- return {
15
- status: 'complete',
16
- details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Version: ${version}`]),
17
- };
18
- },
19
- };
20
- }
21
- //# sourceMappingURL=createDownloadTask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createDownloadTask.js","sourceRoot":"","sources":["../src/createDownloadTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,MAAM,UAAU,kBAAkB,CAChC,MAAyB,EACzB,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAiB;IAEzD,OAAO;QACL,IAAI,EAAE,eAAe,WAAW,IAAI,OAAO,EAAE;QAC7C,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;gBACpB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC;aACpF;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC7D,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;aACtE;YAED,OAAO;gBACL,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,YAAY,CAAC,CAAC,eAAe,UAAU,EAAE,EAAE,SAAS,IAAI,EAAE,EAAE,YAAY,OAAO,EAAE,CAAC,CAAC;aAC7F,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { RemoteCacheClient } from './RemoteCacheClient.js';\nimport type { Task } from './Task.js';\nimport { existsSync } from 'fs';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\nimport type { PackageToSync } from './types/PackageToSync.js';\n\nexport function createDownloadTask(\n client: RemoteCacheClient,\n { folderName, packageName, path, version }: PackageToSync,\n): Task {\n return {\n name: `Downloading ${packageName}@${version}`,\n execute: async () => {\n if (existsSync(path)) {\n return { status: 'skip', message: 'Package is already exist in the local cache.' };\n }\n\n const result = await client.downloadFolder(folderName, path);\n if (!result) {\n return { status: 'skip', message: `not found in the remote cache.` };\n }\n\n return {\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Version: ${version}`]),\n };\n },\n };\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { RemoteCacheClient } from './RemoteCacheClient.js';
2
- import type { Task } from './Task.js';
3
- import type { PackageToSync } from './types/PackageToSync.js';
4
- export declare function createUploadTask(client: RemoteCacheClient, { folderName, packageName, path, version }: PackageToSync): Task;
5
- //# sourceMappingURL=createUploadTask.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createUploadTask.d.ts","sourceRoot":"","sources":["../src/createUploadTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,aAAa,GACxD,IAAI,CAeN"}
@@ -1,18 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import { bulletedList } from '@ms-cloudpack/task-reporter';
3
- export function createUploadTask(client, { folderName, packageName, path, version }) {
4
- return {
5
- name: `Uploading ${packageName}@${version}`,
6
- execute: async () => {
7
- if (!existsSync(path)) {
8
- return { status: 'skip', message: `Not found in the local cache.` };
9
- }
10
- await client.uploadFolder(folderName, path);
11
- return {
12
- status: 'complete',
13
- details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Version: ${version}`]),
14
- };
15
- },
16
- };
17
- }
18
- //# sourceMappingURL=createUploadTask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createUploadTask.js","sourceRoot":"","sources":["../src/createUploadTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,MAAM,UAAU,gBAAgB,CAC9B,MAAyB,EACzB,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAiB;IAEzD,OAAO;QACL,IAAI,EAAE,aAAa,WAAW,IAAI,OAAO,EAAE;QAC3C,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACrB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;aACrE;YAED,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC5C,OAAO;gBACL,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,YAAY,CAAC,CAAC,eAAe,UAAU,EAAE,EAAE,SAAS,IAAI,EAAE,EAAE,YAAY,OAAO,EAAE,CAAC,CAAC;aAC7F,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { RemoteCacheClient } from './RemoteCacheClient.js';\nimport type { Task } from './Task.js';\nimport { existsSync } from 'fs';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\nimport type { PackageToSync } from './types/PackageToSync.js';\n\nexport function createUploadTask(\n client: RemoteCacheClient,\n { folderName, packageName, path, version }: PackageToSync,\n): Task {\n return {\n name: `Uploading ${packageName}@${version}`,\n execute: async () => {\n if (!existsSync(path)) {\n return { status: 'skip', message: `Not found in the local cache.` };\n }\n\n await client.uploadFolder(folderName, path);\n return {\n status: 'complete',\n details: bulletedList([`FolderName: ${folderName}`, `Path: ${path}`, `Version: ${version}`]),\n };\n },\n };\n}\n"]}
@@ -1,4 +0,0 @@
1
- import type { PackageToSync } from './types/PackageToSync.js';
2
- import type { SyncContext } from './types/SyncContext.js';
3
- export declare function getPackagesToSync({ packages, getBundleDetails, resolveMap, }: SyncContext): Promise<PackageToSync[]>;
4
- //# sourceMappingURL=getPackagesToSync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getPackagesToSync.d.ts","sourceRoot":"","sources":["../src/getPackagesToSync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,wBAAsB,iBAAiB,CAAC,EACtC,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACX,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAoBxC"}
@@ -1,18 +0,0 @@
1
- import { findResolveMapEntry } from '@ms-cloudpack/package-utilities';
2
- export async function getPackagesToSync({ packages, getBundleDetails, resolveMap, }) {
3
- const list = [];
4
- const packageEntries = Object.keys(resolveMap)
5
- .map((packageName) => findResolveMapEntry({
6
- packageName,
7
- resolveMap,
8
- }))
9
- .filter((item) => item);
10
- for (const { path: packagePath, name, version } of packageEntries) {
11
- const details = await getBundleDetails({ packagePath }, { packages });
12
- if (details.isExternal) {
13
- list.push({ ...details.outputLocation, packageName: name, version });
14
- }
15
- }
16
- return list;
17
- }
18
- //# sourceMappingURL=getPackagesToSync.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getPackagesToSync.js","sourceRoot":"","sources":["../src/getPackagesToSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAwB,MAAM,iCAAiC,CAAC;AAI5F,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACE;IACZ,MAAM,IAAI,GAAoB,EAAE,CAAC;IAEjC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;SAC3C,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACnB,mBAAmB,CAAC;QAClB,WAAW;QACX,UAAU;KACX,CAAC,CACH;SACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAsB,CAAC;IAE/C,KAAK,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,cAAc,EAAE;QACjE,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QACtE,IAAI,OAAO,CAAC,UAAU,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;SACtE;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { findResolveMapEntry, type ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport type { PackageToSync } from './types/PackageToSync.js';\nimport type { SyncContext } from './types/SyncContext.js';\n\nexport async function getPackagesToSync({\n packages,\n getBundleDetails,\n resolveMap,\n}: SyncContext): Promise<PackageToSync[]> {\n const list: PackageToSync[] = [];\n\n const packageEntries = Object.keys(resolveMap)\n .map((packageName) =>\n findResolveMapEntry({\n packageName,\n resolveMap,\n }),\n )\n .filter((item) => item) as ResolveMapEntry[];\n\n for (const { path: packagePath, name, version } of packageEntries) {\n const details = await getBundleDetails({ packagePath }, { packages });\n if (details.isExternal) {\n list.push({ ...details.outputLocation, packageName: name, version });\n }\n }\n\n return list;\n}\n"]}
@@ -1,13 +0,0 @@
1
- /**
2
- * Marks the start of the sync download/upload operations.
3
- */
4
- export declare const PerfMarkerSyncStart = "SYNC_START";
5
- /**
6
- * Measures the time it takes to complete the download sync operation.
7
- */
8
- export declare const PerfMeasurementSyncDownload = "SYNC_DOWNLOAD";
9
- /**
10
- * Measures the time it takes to complete the upload sync operation.
11
- */
12
- export declare const PerfMeasurementSyncUpload = "SYNC_UPLOAD";
13
- //# sourceMappingURL=markers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../src/performance/markers.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAIhD;;GAEG;AACH,eAAO,MAAM,2BAA2B,kBAAkB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,yBAAyB,gBAAgB,CAAC"}
@@ -1,15 +0,0 @@
1
- // Markers
2
- /**
3
- * Marks the start of the sync download/upload operations.
4
- */
5
- export const PerfMarkerSyncStart = 'SYNC_START';
6
- // Measurements
7
- /**
8
- * Measures the time it takes to complete the download sync operation.
9
- */
10
- export const PerfMeasurementSyncDownload = 'SYNC_DOWNLOAD';
11
- /**
12
- * Measures the time it takes to complete the upload sync operation.
13
- */
14
- export const PerfMeasurementSyncUpload = 'SYNC_UPLOAD';
15
- //# sourceMappingURL=markers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markers.js","sourceRoot":"","sources":["../../src/performance/markers.ts"],"names":[],"mappings":"AAAA,UAAU;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAEhD,eAAe;AAEf;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,eAAe,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,aAAa,CAAC","sourcesContent":["// Markers\n\n/**\n * Marks the start of the sync download/upload operations.\n */\nexport const PerfMarkerSyncStart = 'SYNC_START';\n\n// Measurements\n\n/**\n * Measures the time it takes to complete the download sync operation.\n */\nexport const PerfMeasurementSyncDownload = 'SYNC_DOWNLOAD';\n\n/**\n * Measures the time it takes to complete the upload sync operation.\n */\nexport const PerfMeasurementSyncUpload = 'SYNC_UPLOAD';\n"]}
@@ -1,3 +0,0 @@
1
- import type { SyncContext } from './types/SyncContext.js';
2
- export declare function syncToLocal(context: SyncContext): Promise<void>;
3
- //# sourceMappingURL=syncToLocal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncToLocal.d.ts","sourceRoot":"","sources":["../src/syncToLocal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK1D,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,iBAmBrD"}
@@ -1,21 +0,0 @@
1
- import { getPackagesToSync } from './getPackagesToSync.js';
2
- import { createDownloadTask } from './createDownloadTask.js';
3
- import { createRemoteCacheClient } from './createRemoteCacheClient.js';
4
- import { performance } from 'perf_hooks';
5
- import { PerfMarkerSyncStart, PerfMeasurementSyncDownload } from './performance/markers.js';
6
- export async function syncToLocal(context) {
7
- const { config, reporter } = context;
8
- performance.mark(PerfMarkerSyncStart);
9
- const client = await createRemoteCacheClient({ config, permissions: { read: true, write: false } });
10
- if (!client) {
11
- return;
12
- }
13
- const list = await getPackagesToSync(context);
14
- const downloads = list.map((item) => {
15
- const { name, execute } = createDownloadTask(client, item);
16
- return reporter.runTask(name, execute);
17
- });
18
- await Promise.all(downloads);
19
- performance.measure(PerfMeasurementSyncDownload, PerfMarkerSyncStart);
20
- }
21
- //# sourceMappingURL=syncToLocal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncToLocal.js","sourceRoot":"","sources":["../src/syncToLocal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5F,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAoB;IACpD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACrC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAEtC,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IACpG,IAAI,CAAC,MAAM,EAAE;QACX,OAAO;KACR;IAED,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE9C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAClC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC3D,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAE7B,WAAW,CAAC,OAAO,CAAC,2BAA2B,EAAE,mBAAmB,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import { getPackagesToSync } from './getPackagesToSync.js';\nimport { createDownloadTask } from './createDownloadTask.js';\nimport type { SyncContext } from './types/SyncContext.js';\nimport { createRemoteCacheClient } from './createRemoteCacheClient.js';\nimport { performance } from 'perf_hooks';\nimport { PerfMarkerSyncStart, PerfMeasurementSyncDownload } from './performance/markers.js';\n\nexport async function syncToLocal(context: SyncContext) {\n const { config, reporter } = context;\n performance.mark(PerfMarkerSyncStart);\n\n const client = await createRemoteCacheClient({ config, permissions: { read: true, write: false } });\n if (!client) {\n return;\n }\n\n const list = await getPackagesToSync(context);\n\n const downloads = list.map((item) => {\n const { name, execute } = createDownloadTask(client, item);\n return reporter.runTask(name, execute);\n });\n\n await Promise.all(downloads);\n\n performance.measure(PerfMeasurementSyncDownload, PerfMarkerSyncStart);\n}\n"]}
@@ -1,15 +0,0 @@
1
- import type { SyncContext } from './types/SyncContext.js';
2
- import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
- import type { PackageToSync } from './types/PackageToSync.js';
4
- /**
5
- * Syncs the packages to the remote cache.
6
- * @param syncOptions - The options for the sync command.
7
- * @param context - The task context.
8
- * @returns The number of packages synced.
9
- */
10
- export declare function syncToRemote(options: {
11
- config: SyncContext['config'];
12
- reporter: TaskReporter;
13
- packages: PackageToSync[];
14
- }): Promise<void>;
15
- //# sourceMappingURL=syncToRemote.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncToRemote.d.ts","sourceRoot":"","sources":["../src/syncToRemote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhB"}
@@ -1,25 +0,0 @@
1
- import { createUploadTask } from './createUploadTask.js';
2
- import { createRemoteCacheClient } from './createRemoteCacheClient.js';
3
- import { performance } from 'perf_hooks';
4
- import { PerfMarkerSyncStart, PerfMeasurementSyncUpload } from './performance/markers.js';
5
- /**
6
- * Syncs the packages to the remote cache.
7
- * @param syncOptions - The options for the sync command.
8
- * @param context - The task context.
9
- * @returns The number of packages synced.
10
- */
11
- export async function syncToRemote(options) {
12
- const { config, reporter, packages } = options;
13
- performance.mark(PerfMarkerSyncStart);
14
- const client = await createRemoteCacheClient({ config, permissions: { read: false, write: true } });
15
- if (!client) {
16
- return;
17
- }
18
- const uploads = packages.map((item) => {
19
- const { name, execute } = createUploadTask(client, item);
20
- return reporter.runTask(name, execute);
21
- });
22
- await Promise.all(uploads);
23
- performance.measure(PerfMeasurementSyncUpload, PerfMarkerSyncStart);
24
- }
25
- //# sourceMappingURL=syncToRemote.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncToRemote.js","sourceRoot":"","sources":["../src/syncToRemote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAI1F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAIlC;IACC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC/C,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAEtC,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACpG,IAAI,CAAC,MAAM,EAAE;QACX,OAAO;KACR;IAED,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzD,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAE3B,WAAW,CAAC,OAAO,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import { createUploadTask } from './createUploadTask.js';\nimport type { SyncContext } from './types/SyncContext.js';\nimport { createRemoteCacheClient } from './createRemoteCacheClient.js';\nimport { performance } from 'perf_hooks';\nimport { PerfMarkerSyncStart, PerfMeasurementSyncUpload } from './performance/markers.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { PackageToSync } from './types/PackageToSync.js';\n\n/**\n * Syncs the packages to the remote cache.\n * @param syncOptions - The options for the sync command.\n * @param context - The task context.\n * @returns The number of packages synced.\n */\nexport async function syncToRemote(options: {\n config: SyncContext['config'];\n reporter: TaskReporter;\n packages: PackageToSync[];\n}): Promise<void> {\n const { config, reporter, packages } = options;\n performance.mark(PerfMarkerSyncStart);\n\n const client = await createRemoteCacheClient({ config, permissions: { read: false, write: true } });\n if (!client) {\n return;\n }\n\n const uploads = packages.map((item) => {\n const { name, execute } = createUploadTask(client, item);\n return reporter.runTask(name, execute);\n });\n\n await Promise.all(uploads);\n\n performance.measure(PerfMeasurementSyncUpload, PerfMarkerSyncStart);\n}\n"]}
@@ -1,24 +0,0 @@
1
- import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
- import type { ResolveMap } from '@ms-cloudpack/package-utilities';
3
- import type { TaskReporter } from '@ms-cloudpack/task-reporter';
4
- export interface SyncContext {
5
- config: {
6
- storageAccount: string;
7
- container: string;
8
- };
9
- reporter: TaskReporter;
10
- resolveMap: ResolveMap;
11
- packages: PackageDefinitionsCache;
12
- getBundleDetails: (options: {
13
- packagePath: string;
14
- }, context: {
15
- packages: PackageDefinitionsCache;
16
- }) => Promise<{
17
- outputLocation: {
18
- folderName: string;
19
- path: string;
20
- };
21
- isExternal: boolean;
22
- }>;
23
- }
24
- //# sourceMappingURL=SyncContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyncContext.d.ts","sourceRoot":"","sources":["../../src/types/SyncContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE;QACN,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,gBAAgB,EAAE,CAChB,OAAO,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,EAChC,OAAO,EAAE;QAAE,QAAQ,EAAE,uBAAuB,CAAA;KAAE,KAC3C,OAAO,CAAC;QACX,cAAc,EAAE;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QACrD,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC,CAAC;CACJ"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SyncContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyncContext.js","sourceRoot":"","sources":["../../src/types/SyncContext.ts"],"names":[],"mappings":"","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\nexport interface SyncContext {\n config: {\n storageAccount: string;\n container: string;\n };\n reporter: TaskReporter;\n resolveMap: ResolveMap;\n packages: PackageDefinitionsCache;\n getBundleDetails: (\n options: { packagePath: string },\n context: { packages: PackageDefinitionsCache },\n ) => Promise<{\n outputLocation: { folderName: string; path: string };\n isExternal: boolean;\n }>;\n}\n"]}