@microsoft/agents-hosting-storage-blob 0.6.17-g5d9066ba37 → 0.6.18
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/src/blobsStorage.js
CHANGED
|
@@ -39,9 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.BlobsStorage = void 0;
|
|
40
40
|
const z = __importStar(require("zod"));
|
|
41
41
|
const consumers_1 = __importDefault(require("stream/consumers"));
|
|
42
|
+
const core_auth_1 = require("@azure/core-auth");
|
|
42
43
|
const storage_blob_1 = require("@azure/storage-blob");
|
|
43
44
|
const blobsTranscriptStore_1 = require("./blobsTranscriptStore");
|
|
44
45
|
const ignoreError_1 = require("./ignoreError");
|
|
46
|
+
const logger_1 = require("@microsoft/agents-activity/logger");
|
|
47
|
+
const logger = (0, logger_1.debug)('agents:blob-storage');
|
|
45
48
|
/**
|
|
46
49
|
* A class that implements the Storage interface using Azure Blob Storage.
|
|
47
50
|
* Provides persistence for bot state data using Azure's Blob Storage service.
|
|
@@ -77,6 +80,7 @@ class BlobsStorage {
|
|
|
77
80
|
this._concurrency = 1;
|
|
78
81
|
}
|
|
79
82
|
}
|
|
83
|
+
logger.info(`BlobsStorage initialized with container: ${containerName}, url: ${url}, credential: ${(0, core_auth_1.isTokenCredential)(credential) ? 'TokenCredential' : 'SharedKey/Anonymous'}`);
|
|
80
84
|
}
|
|
81
85
|
toJSON() {
|
|
82
86
|
return { name: 'BlobsStorage' };
|
|
@@ -109,6 +113,7 @@ class BlobsStorage {
|
|
|
109
113
|
}
|
|
110
114
|
const parsed = (await consumers_1.default.json(readableStreamBody));
|
|
111
115
|
result.value = { ...parsed, eTag };
|
|
116
|
+
logger.debug(`Read blob: ${key}, eTag: ${eTag}`);
|
|
112
117
|
return result;
|
|
113
118
|
}));
|
|
114
119
|
return results.reduce((acc, { key, value }) => (value ? { ...acc, [key]: value } : acc), {});
|
|
@@ -127,6 +132,7 @@ class BlobsStorage {
|
|
|
127
132
|
try {
|
|
128
133
|
const blob = this._containerClient.getBlockBlobClient((0, blobsTranscriptStore_1.sanitizeBlobKey)(key));
|
|
129
134
|
const serialized = JSON.stringify(change);
|
|
135
|
+
logger.debug(`Writing blob: ${key}, eTag: ${eTag}, size: ${serialized.length}`);
|
|
130
136
|
return await blob.upload(serialized, serialized.length, {
|
|
131
137
|
conditions: typeof eTag === 'string' && eTag !== '*' ? { ifMatch: eTag } : {},
|
|
132
138
|
blobHTTPHeaders: { blobContentType: 'application/json' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobsStorage.js","sourceRoot":"","sources":["../../src/blobsStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,iEAA8C;
|
|
1
|
+
{"version":3,"file":"blobsStorage.js","sourceRoot":"","sources":["../../src/blobsStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,iEAA8C;AAC9C,gDAAqE;AACrE,sDAK4B;AAE5B,iEAAwD;AACxD,+CAA8D;AAC9D,8DAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,qBAAqB,CAAC,CAAA;AAY3C;;;GAGG;AACH,MAAa,YAAY;IAKvB;;;;;;;;OAQG;IACH,YACE,aAAqB,EACrB,gBAAyB,EACzB,OAA6B,EAC7B,GAAG,GAAG,EAAE,EACR,UAA+E;QAjBhE,iBAAY,GAAG,QAAQ,CAAA;QAmBtC,IAAI,GAAG,KAAK,EAAE,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACrC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;gBAClC,GAAG;aACJ,CAAC,CAAA;YAEF,IAAI,CAAC,gBAAgB,GAAG,IAAI,8BAA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AM,CAAC;oBACN,MAAM,GAAG,CAAA;gBACX,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAE,IAAc;QAC1B,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;QAEvD,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;QAExB,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,yBAAW,EAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAA,sCAAe,EAAC,GAAG,CAAC,CAAC,EAAE,IAAA,+BAAiB,EAAC,GAAG,CAAC,CAAC,CAAC,CAC/G,CAAA;IACH,CAAC;CACF;AApJD,oCAoJC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting-storage-blob",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.18",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"types": "dist/src/index.d.ts",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@azure/storage-blob": "^12.27.0",
|
|
20
|
-
"@microsoft/agents-hosting": "0.6.
|
|
20
|
+
"@microsoft/agents-hosting": "0.6.18"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"files": [
|
package/src/blobsStorage.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod'
|
|
2
2
|
import StreamConsumers from 'stream/consumers'
|
|
3
|
-
import { TokenCredential } from '@azure/core-auth'
|
|
3
|
+
import { isTokenCredential, TokenCredential } from '@azure/core-auth'
|
|
4
4
|
import {
|
|
5
5
|
AnonymousCredential,
|
|
6
6
|
ContainerClient,
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
import { Storage, StoreItems } from '@microsoft/agents-hosting'
|
|
11
11
|
import { sanitizeBlobKey } from './blobsTranscriptStore'
|
|
12
12
|
import { ignoreError, isStatusCodeError } from './ignoreError'
|
|
13
|
+
import { debug } from '@microsoft/agents-activity/logger'
|
|
14
|
+
|
|
15
|
+
const logger = debug('agents:blob-storage')
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Options for configuring the BlobsStorage.
|
|
@@ -72,6 +75,7 @@ export class BlobsStorage implements Storage {
|
|
|
72
75
|
this._concurrency = 1
|
|
73
76
|
}
|
|
74
77
|
}
|
|
78
|
+
logger.info(`BlobsStorage initialized with container: ${containerName}, url: ${url}, credential: ${isTokenCredential(credential) ? 'TokenCredential' : 'SharedKey/Anonymous'}`)
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
private toJSON (): unknown {
|
|
@@ -116,7 +120,7 @@ export class BlobsStorage implements Storage {
|
|
|
116
120
|
|
|
117
121
|
const parsed = (await StreamConsumers.json(readableStreamBody)) as any
|
|
118
122
|
result.value = { ...parsed, eTag }
|
|
119
|
-
|
|
123
|
+
logger.debug(`Read blob: ${key}, eTag: ${eTag}`)
|
|
120
124
|
return result
|
|
121
125
|
}))
|
|
122
126
|
|
|
@@ -140,6 +144,7 @@ export class BlobsStorage implements Storage {
|
|
|
140
144
|
try {
|
|
141
145
|
const blob = this._containerClient.getBlockBlobClient(sanitizeBlobKey(key))
|
|
142
146
|
const serialized = JSON.stringify(change)
|
|
147
|
+
logger.debug(`Writing blob: ${key}, eTag: ${eTag}, size: ${serialized.length}`)
|
|
143
148
|
return await blob.upload(serialized, serialized.length, {
|
|
144
149
|
conditions: typeof eTag === 'string' && eTag !== '*' ? { ifMatch: eTag } : {},
|
|
145
150
|
blobHTTPHeaders: { blobContentType: 'application/json' },
|