@ms-cloudpack/remote-cache 0.8.15 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AzureRemoteCacheClient-RYQX2JZE.js → AzureRemoteCacheClient-WCVYZSMD.js} +86 -31
- package/dist/{getListOfBlobs-6GZGACOS.js → getListOfBlobs-WLTPEMDF.js} +4 -2
- package/dist/index.js +2 -2
- package/lib/AzureRemoteCacheClient.d.ts +2 -2
- package/lib/createCacheStorageConfig.d.ts +4 -0
- package/lib/index.d.ts +1 -1
- package/package.json +7 -3
|
@@ -1167,8 +1167,8 @@ var require_graceful_fs = __commonJS({
|
|
|
1167
1167
|
fs2.createReadStream = createReadStream;
|
|
1168
1168
|
fs2.createWriteStream = createWriteStream;
|
|
1169
1169
|
var fs$readFile = fs2.readFile;
|
|
1170
|
-
fs2.readFile =
|
|
1171
|
-
function
|
|
1170
|
+
fs2.readFile = readFile2;
|
|
1171
|
+
function readFile2(path, options, cb) {
|
|
1172
1172
|
if (typeof options === "function")
|
|
1173
1173
|
cb = options, options = null;
|
|
1174
1174
|
return go$readFile(path, options, cb);
|
|
@@ -1184,7 +1184,7 @@ var require_graceful_fs = __commonJS({
|
|
|
1184
1184
|
}
|
|
1185
1185
|
__name(go$readFile, "go$readFile");
|
|
1186
1186
|
}
|
|
1187
|
-
__name(
|
|
1187
|
+
__name(readFile2, "readFile");
|
|
1188
1188
|
var fs$writeFile = fs2.writeFile;
|
|
1189
1189
|
fs2.writeFile = writeFile;
|
|
1190
1190
|
function writeFile(path, data, options, cb) {
|
|
@@ -3009,7 +3009,7 @@ var require_package16 = __commonJS({
|
|
|
3009
3009
|
} catch (_) {
|
|
3010
3010
|
_fs = __require("fs");
|
|
3011
3011
|
}
|
|
3012
|
-
function
|
|
3012
|
+
function readFile2(file, options, callback) {
|
|
3013
3013
|
if (callback == null) {
|
|
3014
3014
|
callback = options;
|
|
3015
3015
|
options = {};
|
|
@@ -3040,7 +3040,7 @@ var require_package16 = __commonJS({
|
|
|
3040
3040
|
callback(null, obj);
|
|
3041
3041
|
});
|
|
3042
3042
|
}
|
|
3043
|
-
__name(
|
|
3043
|
+
__name(readFile2, "readFile");
|
|
3044
3044
|
function readFileSync(file, options) {
|
|
3045
3045
|
options = options || {};
|
|
3046
3046
|
if (typeof options === "string") {
|
|
@@ -3111,7 +3111,7 @@ var require_package16 = __commonJS({
|
|
|
3111
3111
|
}
|
|
3112
3112
|
__name(stripBom, "stripBom");
|
|
3113
3113
|
var jsonfile = {
|
|
3114
|
-
readFile,
|
|
3114
|
+
readFile: readFile2,
|
|
3115
3115
|
readFileSync,
|
|
3116
3116
|
writeFile,
|
|
3117
3117
|
writeFileSync
|
|
@@ -18516,7 +18516,7 @@ var require_package40 = __commonJS({
|
|
|
18516
18516
|
}
|
|
18517
18517
|
const file = _ref22;
|
|
18518
18518
|
if (yield exists(file)) {
|
|
18519
|
-
return
|
|
18519
|
+
return readFile2(file);
|
|
18520
18520
|
}
|
|
18521
18521
|
}
|
|
18522
18522
|
return null;
|
|
@@ -18535,7 +18535,7 @@ var require_package40 = __commonJS({
|
|
|
18535
18535
|
})();
|
|
18536
18536
|
let readJsonAndFile = exports2.readJsonAndFile = (() => {
|
|
18537
18537
|
var _ref24 = (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* (loc) {
|
|
18538
|
-
const file = yield
|
|
18538
|
+
const file = yield readFile2(loc);
|
|
18539
18539
|
try {
|
|
18540
18540
|
return {
|
|
18541
18541
|
object: (0, (_map || _load_map()).default)(JSON.parse(stripBOM(file))),
|
|
@@ -18775,7 +18775,7 @@ var require_package40 = __commonJS({
|
|
|
18775
18775
|
}, "getFirstSuitableFolder");
|
|
18776
18776
|
})();
|
|
18777
18777
|
exports2.copy = copy;
|
|
18778
|
-
exports2.readFile =
|
|
18778
|
+
exports2.readFile = readFile2;
|
|
18779
18779
|
exports2.readFileRaw = readFileRaw;
|
|
18780
18780
|
exports2.normalizeOS = normalizeOS;
|
|
18781
18781
|
var _fs;
|
|
@@ -18886,10 +18886,10 @@ var require_package40 = __commonJS({
|
|
|
18886
18886
|
});
|
|
18887
18887
|
}
|
|
18888
18888
|
__name(_readFile, "_readFile");
|
|
18889
|
-
function
|
|
18889
|
+
function readFile2(loc) {
|
|
18890
18890
|
return _readFile(loc, "utf8").then(normalizeOS);
|
|
18891
18891
|
}
|
|
18892
|
-
__name(
|
|
18892
|
+
__name(readFile2, "readFile");
|
|
18893
18893
|
function readFileRaw(loc) {
|
|
18894
18894
|
return _readFile(loc, "binary");
|
|
18895
18895
|
}
|
|
@@ -31334,7 +31334,7 @@ var require_async7 = __commonJS({
|
|
|
31334
31334
|
opts = normalizeOptions(x, opts);
|
|
31335
31335
|
var isFile = opts.isFile || defaultIsFile;
|
|
31336
31336
|
var isDirectory = opts.isDirectory || defaultIsDir;
|
|
31337
|
-
var
|
|
31337
|
+
var readFile2 = opts.readFile || fs.readFile;
|
|
31338
31338
|
var realpath = opts.realpath || defaultRealpath;
|
|
31339
31339
|
var packageIterator = opts.packageIterator;
|
|
31340
31340
|
var extensions = opts.extensions || [".js"];
|
|
@@ -31452,7 +31452,7 @@ var require_async7 = __commonJS({
|
|
|
31452
31452
|
var pkgfile = path.join(pkgdir, "package.json");
|
|
31453
31453
|
isFile(pkgfile, function(err2, ex) {
|
|
31454
31454
|
if (!ex) return loadpkg(path.dirname(dir), cb2);
|
|
31455
|
-
|
|
31455
|
+
readFile2(pkgfile, function(err3, body) {
|
|
31456
31456
|
if (err3) cb2(err3);
|
|
31457
31457
|
try {
|
|
31458
31458
|
var pkg = JSON.parse(body);
|
|
@@ -31480,7 +31480,7 @@ var require_async7 = __commonJS({
|
|
|
31480
31480
|
isFile(pkgfile, function(err2, ex) {
|
|
31481
31481
|
if (err2) return cb2(err2);
|
|
31482
31482
|
if (!ex) return loadAsFile(path.join(x2, "index"), fpkg, cb2);
|
|
31483
|
-
|
|
31483
|
+
readFile2(pkgfile, function(err3, body) {
|
|
31484
31484
|
if (err3) return cb2(err3);
|
|
31485
31485
|
try {
|
|
31486
31486
|
var pkg = JSON.parse(body);
|
|
@@ -39601,7 +39601,7 @@ var require_buffer_list = __commonJS({
|
|
|
39601
39601
|
}, "clear")
|
|
39602
39602
|
}, {
|
|
39603
39603
|
key: "join",
|
|
39604
|
-
value: /* @__PURE__ */ __name(function
|
|
39604
|
+
value: /* @__PURE__ */ __name(function join2(s) {
|
|
39605
39605
|
if (this.length === 0) return "";
|
|
39606
39606
|
var p = this.head;
|
|
39607
39607
|
var ret = "" + p.data;
|
|
@@ -44880,8 +44880,8 @@ var require_CacheStorage = __commonJS({
|
|
|
44880
44880
|
}
|
|
44881
44881
|
};
|
|
44882
44882
|
__name(_CacheStorage, "CacheStorage");
|
|
44883
|
-
var
|
|
44884
|
-
exports.CacheStorage =
|
|
44883
|
+
var CacheStorage2 = _CacheStorage;
|
|
44884
|
+
exports.CacheStorage = CacheStorage2;
|
|
44885
44885
|
}
|
|
44886
44886
|
});
|
|
44887
44887
|
|
|
@@ -44965,8 +44965,8 @@ var require_AzureBlobCacheStorage = __commonJS({
|
|
|
44965
44965
|
maxBuffers: 5
|
|
44966
44966
|
};
|
|
44967
44967
|
async function createBlobClient(connectionString, containerName, blobName, credential) {
|
|
44968
|
-
const { BlobServiceClient } = await Promise.resolve().then(() => __importStar(require_dist()));
|
|
44969
|
-
const blobServiceClient = credential ? new
|
|
44968
|
+
const { BlobServiceClient: BlobServiceClient2 } = await Promise.resolve().then(() => __importStar(require_dist()));
|
|
44969
|
+
const blobServiceClient = credential ? new BlobServiceClient2(connectionString, credential) : BlobServiceClient2.fromConnectionString(connectionString);
|
|
44970
44970
|
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
44971
44971
|
const blobClient = containerClient.getBlobClient(blobName);
|
|
44972
44972
|
return blobClient;
|
|
@@ -47246,7 +47246,7 @@ var require_lib14 = __commonJS({
|
|
|
47246
47246
|
__name(isCustomProvider, "isCustomProvider");
|
|
47247
47247
|
exports.isCustomProvider = isCustomProvider;
|
|
47248
47248
|
var memo = /* @__PURE__ */ new Map();
|
|
47249
|
-
function
|
|
47249
|
+
function getCacheStorageProvider2(cacheStorageConfig, internalCacheFolder, logger, cwd, incrementalCaching = false) {
|
|
47250
47250
|
let cacheStorage;
|
|
47251
47251
|
if (isCustomProvider(cacheStorageConfig)) {
|
|
47252
47252
|
try {
|
|
@@ -47272,8 +47272,8 @@ var require_lib14 = __commonJS({
|
|
|
47272
47272
|
memo.set(key, cacheStorage);
|
|
47273
47273
|
return cacheStorage;
|
|
47274
47274
|
}
|
|
47275
|
-
__name(
|
|
47276
|
-
exports.getCacheStorageProvider =
|
|
47275
|
+
__name(getCacheStorageProvider2, "getCacheStorageProvider");
|
|
47276
|
+
exports.getCacheStorageProvider = getCacheStorageProvider2;
|
|
47277
47277
|
}
|
|
47278
47278
|
});
|
|
47279
47279
|
|
|
@@ -47356,21 +47356,76 @@ var require_api = __commonJS({
|
|
|
47356
47356
|
// src/AzureRemoteCacheClient.ts
|
|
47357
47357
|
var import_api = __toESM(require_api(), 1);
|
|
47358
47358
|
import { existsSync } from "fs";
|
|
47359
|
+
|
|
47360
|
+
// src/createCacheStorageConfig.ts
|
|
47361
|
+
var import_backfill_cache = __toESM(require_lib14(), 1);
|
|
47362
|
+
var import_storage_blob = __toESM(require_dist(), 1);
|
|
47363
|
+
import { join } from "path";
|
|
47364
|
+
import { readFile } from "fs/promises";
|
|
47365
|
+
import { lookup } from "mime-types";
|
|
47366
|
+
var _CustomAzureCacheStorage = class _CustomAzureCacheStorage extends import_backfill_cache.CacheStorage {
|
|
47367
|
+
constructor({ container, storageAccount, credential }, logger, cwd) {
|
|
47368
|
+
super(logger, cwd);
|
|
47369
|
+
this.logger = logger;
|
|
47370
|
+
this.cwd = cwd;
|
|
47371
|
+
const connectionString = createBlobStorageUrl(storageAccount);
|
|
47372
|
+
const blobStorageClient = new import_storage_blob.BlobServiceClient(connectionString, credential);
|
|
47373
|
+
this.containerClient = blobStorageClient.getContainerClient(container);
|
|
47374
|
+
const internalCacheFolder = "";
|
|
47375
|
+
this.tarStorage = (0, import_backfill_cache.getCacheStorageProvider)(
|
|
47376
|
+
{
|
|
47377
|
+
provider: "azure-blob",
|
|
47378
|
+
options: {
|
|
47379
|
+
connectionString,
|
|
47380
|
+
credential,
|
|
47381
|
+
container
|
|
47382
|
+
}
|
|
47383
|
+
},
|
|
47384
|
+
internalCacheFolder,
|
|
47385
|
+
logger,
|
|
47386
|
+
cwd
|
|
47387
|
+
);
|
|
47388
|
+
}
|
|
47389
|
+
_fetch(hash) {
|
|
47390
|
+
return this.tarStorage.fetch(hash);
|
|
47391
|
+
}
|
|
47392
|
+
async _put(hash, filesToCache) {
|
|
47393
|
+
await Promise.all([
|
|
47394
|
+
// Combine all the files in a tarball and upload it to the blob storage
|
|
47395
|
+
this.tarStorage.put(hash, filesToCache),
|
|
47396
|
+
// Upload the individual files to the blob storage
|
|
47397
|
+
...filesToCache.map(async (file) => {
|
|
47398
|
+
const filePath = join(this.cwd, file);
|
|
47399
|
+
const content = await readFile(filePath, { encoding: "utf-8" });
|
|
47400
|
+
const blockBlobClient = this.containerClient.getBlockBlobClient(`${hash}/${file}`);
|
|
47401
|
+
return blockBlobClient.upload(content, content.length, {
|
|
47402
|
+
blobHTTPHeaders: {
|
|
47403
|
+
blobContentType: lookup(file) || "application/octet-stream"
|
|
47404
|
+
}
|
|
47405
|
+
});
|
|
47406
|
+
})
|
|
47407
|
+
]);
|
|
47408
|
+
}
|
|
47409
|
+
};
|
|
47410
|
+
__name(_CustomAzureCacheStorage, "CustomAzureCacheStorage");
|
|
47411
|
+
var CustomAzureCacheStorage = _CustomAzureCacheStorage;
|
|
47412
|
+
function createCacheStorageConfig(remoteCacheClientOptions) {
|
|
47413
|
+
return {
|
|
47414
|
+
name: "Custom Azure Cache Storage",
|
|
47415
|
+
provider: /* @__PURE__ */ __name((logger, cwd) => new CustomAzureCacheStorage(remoteCacheClientOptions, logger, cwd), "provider")
|
|
47416
|
+
};
|
|
47417
|
+
}
|
|
47418
|
+
__name(createCacheStorageConfig, "createCacheStorageConfig");
|
|
47419
|
+
|
|
47420
|
+
// src/AzureRemoteCacheClient.ts
|
|
47359
47421
|
var _AzureRemoteCacheClient = class _AzureRemoteCacheClient {
|
|
47360
|
-
constructor(
|
|
47422
|
+
constructor(remoteCacheClientOptions) {
|
|
47361
47423
|
this.logger = (0, import_api.makeLogger)("mute", process.stdout, process.stderr);
|
|
47362
47424
|
this.config = {
|
|
47363
47425
|
incrementalCaching: true,
|
|
47364
47426
|
internalCacheFolder: "",
|
|
47365
47427
|
// not used by azure-blob
|
|
47366
|
-
cacheStorageConfig:
|
|
47367
|
-
provider: "azure-blob",
|
|
47368
|
-
options: {
|
|
47369
|
-
connectionString: createBlobStorageUrl(storageAccount),
|
|
47370
|
-
credential,
|
|
47371
|
-
container
|
|
47372
|
-
}
|
|
47373
|
-
}
|
|
47428
|
+
cacheStorageConfig: createCacheStorageConfig(remoteCacheClientOptions)
|
|
47374
47429
|
};
|
|
47375
47430
|
}
|
|
47376
47431
|
/**
|
|
@@ -22,8 +22,10 @@ async function getListOfBlobs({ container, storageAccount, credential }) {
|
|
|
22
22
|
const blobStorageClient = new import_storage_blob.BlobServiceClient(createBlobStorageUrl(storageAccount), credential);
|
|
23
23
|
const containerClient = blobStorageClient.getContainerClient(container);
|
|
24
24
|
const blobs = /* @__PURE__ */ new Set();
|
|
25
|
-
for await (const blob of containerClient.
|
|
26
|
-
|
|
25
|
+
for await (const blob of containerClient.listBlobsByHierarchy("/")) {
|
|
26
|
+
if (blob.kind === "blob") {
|
|
27
|
+
blobs.add(blob.name);
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
return blobs;
|
|
29
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -97,9 +97,9 @@ async function createRemoteCacheClient(params) {
|
|
|
97
97
|
const { context, options } = params;
|
|
98
98
|
const { container, loginMethod, storageAccount, cachePath, tenantId } = options;
|
|
99
99
|
const { getCredential } = await import("./getCredential-TGHZRNZU.js");
|
|
100
|
-
const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-
|
|
100
|
+
const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-WCVYZSMD.js");
|
|
101
101
|
const { ReporterDecorator } = await import("./ReporterDecorator-V2YEIC5V.js");
|
|
102
|
-
const { getListOfBlobs } = await import("./getListOfBlobs-
|
|
102
|
+
const { getListOfBlobs } = await import("./getListOfBlobs-WLTPEMDF.js");
|
|
103
103
|
const credential = await getCredential(
|
|
104
104
|
{ loginMethod, cachePath, tenantId },
|
|
105
105
|
{ ...context, azureLogger: azureLogEventHandler }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
|
|
2
1
|
import type { RemoteCacheClient, RemoteCacheClientOperationOptions, RemoteCacheClientUploadOperationOptions } from './types/RemoteCacheClient.js';
|
|
2
|
+
import type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
|
|
3
3
|
export declare class AzureRemoteCacheClient implements RemoteCacheClient {
|
|
4
4
|
private readonly logger;
|
|
5
5
|
private readonly config;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(remoteCacheClientOptions: RemoteCacheClientOptions);
|
|
7
7
|
/**
|
|
8
8
|
* Uploads the folder to the remote cache.
|
|
9
9
|
* @param id - The unique identifier of the asset to upload.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
|
|
2
|
+
import type { CustomStorageConfig } from 'backfill-config';
|
|
3
|
+
export declare function createCacheStorageConfig(remoteCacheClientOptions: RemoteCacheClientOptions): CustomStorageConfig;
|
|
4
|
+
//# sourceMappingURL=createCacheStorageConfig.d.ts.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createRemoteCacheClient, type CreateRemoteCacheClientParams } from './createRemoteCacheClient.js';
|
|
2
|
-
export type { RemoteCacheClient, RemoteCacheClientUploadOperationOptions
|
|
2
|
+
export type { RemoteCacheClient, RemoteCacheClientUploadOperationOptions, RemoteCacheClientOperationOptions, RemoteCacheClientOperationResult, } from './types/RemoteCacheClient.js';
|
|
3
3
|
export type { LoginMethod } from './types/LoginMethod.js';
|
|
4
4
|
export type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/remote-cache",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Manages syncing the local Cloudpack cached assets to/from a remote storage service.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"lib/**/*.d.ts"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@ms-cloudpack/common-types": "^0.
|
|
30
|
+
"@ms-cloudpack/common-types": "^0.23.0",
|
|
31
31
|
"@ms-cloudpack/retry": "^0.1.2",
|
|
32
32
|
"@ms-cloudpack/task-reporter": "^0.14.5",
|
|
33
33
|
"@ms-cloudpack/telemetry": "^0.6.3",
|
|
34
34
|
"@napi-rs/keyring": "^1.0.0",
|
|
35
|
+
"mime-types": "^2.0.0",
|
|
35
36
|
"node-dpapi-prebuilt": "^1.0.3"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
@@ -42,7 +43,10 @@
|
|
|
42
43
|
"@azure/storage-blob": "^12.17.0",
|
|
43
44
|
"@ms-cloudpack/eslint-plugin-internal": "*",
|
|
44
45
|
"@ms-cloudpack/scripts": "*",
|
|
46
|
+
"@types/mime-types": "^2.0.0",
|
|
45
47
|
"backfill": "^6.2.1",
|
|
46
|
-
"backfill-
|
|
48
|
+
"backfill-cache": "^5.8.1",
|
|
49
|
+
"backfill-config": "^6.4.1",
|
|
50
|
+
"backfill-logger": "^5.2.1"
|
|
47
51
|
}
|
|
48
52
|
}
|