@microsoft/agents-hosting-storage-blob 0.2.14 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,7 +9,13 @@ export declare function maybeCast<T>(value: unknown, ctor?: {
|
|
|
9
9
|
* Options for configuring the BlobsTranscriptStore.
|
|
10
10
|
*/
|
|
11
11
|
export interface BlobsTranscriptStoreOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Optional pipeline options for configuring the Azure Blob Storage client.
|
|
14
|
+
*/
|
|
12
15
|
storagePipelineOptions?: StoragePipelineOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Indicates whether to decode the transcript key when retrieving transcripts.
|
|
18
|
+
*/
|
|
13
19
|
decodeTranscriptKey?: boolean;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
@@ -20,10 +26,44 @@ export declare class BlobsTranscriptStore implements TranscriptStore {
|
|
|
20
26
|
private readonly _concurrency;
|
|
21
27
|
private _initializePromise?;
|
|
22
28
|
private _isDecodeTranscriptKey?;
|
|
29
|
+
/**
|
|
30
|
+
* Constructs a new instance of the BlobsTranscriptStore class.
|
|
31
|
+
* @param connectionString - The connection string for the Azure Blob Storage account.
|
|
32
|
+
* @param containerName - The name of the container to use for storing transcripts.
|
|
33
|
+
* @param options - Optional configuration options for the store.
|
|
34
|
+
* @param blobServiceUri - Optional URI for the blob service.
|
|
35
|
+
* @param tokenCredential - Optional credentials for authenticating with the blob service.
|
|
36
|
+
*/
|
|
23
37
|
constructor(connectionString: string, containerName: string, options?: BlobsTranscriptStoreOptions, blobServiceUri?: string, tokenCredential?: StorageSharedKeyCredential | AnonymousCredential);
|
|
24
38
|
private _initialize;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves transcript activities for a specific conversation.
|
|
41
|
+
* @param channelId - The ID of the channel.
|
|
42
|
+
* @param conversationId - The ID of the conversation.
|
|
43
|
+
* @param continuationToken - Optional token for paginated results.
|
|
44
|
+
* @param startDate - Optional start date to filter activities.
|
|
45
|
+
* @returns A promise resolving to a paged result of activities.
|
|
46
|
+
*/
|
|
25
47
|
getTranscriptActivities(channelId: string, conversationId: string, continuationToken?: string, startDate?: Date): Promise<PagedResult<Activity>>;
|
|
48
|
+
/**
|
|
49
|
+
* Lists all transcripts for a specific channel.
|
|
50
|
+
* @param channelId - The ID of the channel.
|
|
51
|
+
* @param continuationToken - Optional token for paginated results.
|
|
52
|
+
* @returns A promise resolving to a paged result of transcript information.
|
|
53
|
+
*/
|
|
26
54
|
listTranscripts(channelId: string, continuationToken?: string): Promise<PagedResult<TranscriptInfo>>;
|
|
55
|
+
/**
|
|
56
|
+
* Deletes all transcripts for a specific conversation.
|
|
57
|
+
* @param channelId - The ID of the channel.
|
|
58
|
+
* @param conversationId - The ID of the conversation.
|
|
59
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
60
|
+
*/
|
|
27
61
|
deleteTranscript(channelId: string, conversationId: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Logs an activity to the transcript store.
|
|
64
|
+
* @param activity - The activity to log.
|
|
65
|
+
* @param options - Optional configuration options for the operation.
|
|
66
|
+
* @returns A promise that resolves when the activity is logged.
|
|
67
|
+
*/
|
|
28
68
|
logActivity(activity: Activity, options?: BlobsTranscriptStoreOptions): Promise<void>;
|
|
29
69
|
}
|
|
@@ -42,15 +42,31 @@ exports.maybeCast = maybeCast;
|
|
|
42
42
|
const z = __importStar(require("zod"));
|
|
43
43
|
const consumers_1 = __importDefault(require("stream/consumers"));
|
|
44
44
|
const storage_blob_1 = require("@azure/storage-blob");
|
|
45
|
+
/**
|
|
46
|
+
* Formats a Date object into a hexadecimal string representing ticks.
|
|
47
|
+
* @param timestamp - The Date object to format.
|
|
48
|
+
* @returns A string representing the formatted ticks.
|
|
49
|
+
*/
|
|
45
50
|
function formatTicks(timestamp) {
|
|
46
51
|
const epochTicks = 621355968000000000;
|
|
47
52
|
const ticksPerMillisecond = 10000;
|
|
48
53
|
const ticks = epochTicks + timestamp.getTime() * ticksPerMillisecond;
|
|
49
54
|
return ticks.toString(16);
|
|
50
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Generates a sanitized prefix for a channel.
|
|
58
|
+
* @param channelId - The ID of the channel.
|
|
59
|
+
* @returns A sanitized string prefix for the channel.
|
|
60
|
+
*/
|
|
51
61
|
function getChannelPrefix(channelId) {
|
|
52
62
|
return sanitizeBlobKey(`${channelId}/`);
|
|
53
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Generates a sanitized prefix for a conversation within a channel.
|
|
66
|
+
* @param channelId - The ID of the channel.
|
|
67
|
+
* @param conversationId - The ID of the conversation.
|
|
68
|
+
* @returns A sanitized string prefix for the conversation.
|
|
69
|
+
*/
|
|
54
70
|
function getConversationPrefix(channelId, conversationId) {
|
|
55
71
|
return sanitizeBlobKey(`${channelId}/${conversationId}`);
|
|
56
72
|
}
|
|
@@ -89,6 +105,14 @@ const MAX_PAGE_SIZE = 20;
|
|
|
89
105
|
* A class that implements the TranscriptStore interface using Azure Blob Storage.
|
|
90
106
|
*/
|
|
91
107
|
class BlobsTranscriptStore {
|
|
108
|
+
/**
|
|
109
|
+
* Constructs a new instance of the BlobsTranscriptStore class.
|
|
110
|
+
* @param connectionString - The connection string for the Azure Blob Storage account.
|
|
111
|
+
* @param containerName - The name of the container to use for storing transcripts.
|
|
112
|
+
* @param options - Optional configuration options for the store.
|
|
113
|
+
* @param blobServiceUri - Optional URI for the blob service.
|
|
114
|
+
* @param tokenCredential - Optional credentials for authenticating with the blob service.
|
|
115
|
+
*/
|
|
92
116
|
constructor(connectionString, containerName, options, blobServiceUri = '', tokenCredential) {
|
|
93
117
|
this._concurrency = Infinity;
|
|
94
118
|
this._isDecodeTranscriptKey = false;
|
|
@@ -119,6 +143,14 @@ class BlobsTranscriptStore {
|
|
|
119
143
|
}
|
|
120
144
|
return this._initializePromise;
|
|
121
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves transcript activities for a specific conversation.
|
|
148
|
+
* @param channelId - The ID of the channel.
|
|
149
|
+
* @param conversationId - The ID of the conversation.
|
|
150
|
+
* @param continuationToken - Optional token for paginated results.
|
|
151
|
+
* @param startDate - Optional start date to filter activities.
|
|
152
|
+
* @returns A promise resolving to a paged result of activities.
|
|
153
|
+
*/
|
|
122
154
|
async getTranscriptActivities(channelId, conversationId, continuationToken, startDate) {
|
|
123
155
|
var _a, _b, _c, _d;
|
|
124
156
|
z.object({ channelId: z.string(), conversationId: z.string() }).parse({ channelId, conversationId });
|
|
@@ -164,6 +196,12 @@ class BlobsTranscriptStore {
|
|
|
164
196
|
items: result.reduce((acc, activity) => (activity ? acc.concat(activity) : acc), []),
|
|
165
197
|
};
|
|
166
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Lists all transcripts for a specific channel.
|
|
201
|
+
* @param channelId - The ID of the channel.
|
|
202
|
+
* @param continuationToken - Optional token for paginated results.
|
|
203
|
+
* @returns A promise resolving to a paged result of transcript information.
|
|
204
|
+
*/
|
|
167
205
|
async listTranscripts(channelId, continuationToken) {
|
|
168
206
|
var _a, _b, _c, _d;
|
|
169
207
|
z.object({ channelId: z.string() }).parse({ channelId });
|
|
@@ -196,6 +234,12 @@ class BlobsTranscriptStore {
|
|
|
196
234
|
items: result !== null && result !== void 0 ? result : [],
|
|
197
235
|
};
|
|
198
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Deletes all transcripts for a specific conversation.
|
|
239
|
+
* @param channelId - The ID of the channel.
|
|
240
|
+
* @param conversationId - The ID of the conversation.
|
|
241
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
242
|
+
*/
|
|
199
243
|
async deleteTranscript(channelId, conversationId) {
|
|
200
244
|
var _a, _b, _c;
|
|
201
245
|
z.object({ channelId: z.string(), conversationId: z.string() }).parse({ channelId, conversationId });
|
|
@@ -216,6 +260,12 @@ class BlobsTranscriptStore {
|
|
|
216
260
|
page = await iter.next();
|
|
217
261
|
}
|
|
218
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Logs an activity to the transcript store.
|
|
265
|
+
* @param activity - The activity to log.
|
|
266
|
+
* @param options - Optional configuration options for the operation.
|
|
267
|
+
* @returns A promise that resolves when the activity is logged.
|
|
268
|
+
*/
|
|
219
269
|
async logActivity(activity, options) {
|
|
220
270
|
var _a, _b, _c, _d;
|
|
221
271
|
z.object({ activity: z.record(z.unknown()) }).parse({ activity });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobsTranscriptStore.js","sourceRoot":"","sources":["../../src/blobsTranscriptStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"blobsTranscriptStore.js","sourceRoot":"","sources":["../../src/blobsTranscriptStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,0CAeC;AAED,8BAMC;AAnFD,uCAAwB;AACxB,iEAA8C;AAG9C,sDAO4B;AAG5B;;;;GAIG;AACH,SAAS,WAAW,CAAE,SAAe;IACnC,MAAM,UAAU,GAAG,kBAAkB,CAAA;IACrC,MAAM,mBAAmB,GAAG,KAAK,CAAA;IACjC,MAAM,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC,OAAO,EAAE,GAAG,mBAAmB,CAAA;IACpE,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAE,SAAiB;IAC1C,OAAO,eAAe,CAAC,GAAG,SAAS,GAAG,CAAC,CAAA;AACzC,CAAC;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAE,SAAiB,EAAE,cAAsB;IACvE,OAAO,eAAe,CAAC,GAAG,SAAS,IAAI,cAAc,EAAE,CAAC,CAAA;AAC1D,CAAC;AAED,SAAS,UAAU,CAAE,QAAkB,EAAE,OAAqC;;IAC5E,IAAI,CAAC,CAAC,QAAQ,CA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,CAAC,CAAA;IAChE,CAAC;CACF;AAzPD,oDAyPC"}
|
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.
|
|
4
|
+
"version": "0.4.1",
|
|
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.
|
|
20
|
+
"@microsoft/agents-hosting": "0.4.1"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"files": [
|
|
@@ -12,6 +12,11 @@ import {
|
|
|
12
12
|
} from '@azure/storage-blob'
|
|
13
13
|
import { TranscriptStore, PagedResult, TranscriptInfo } from '@microsoft/agents-hosting'
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Formats a Date object into a hexadecimal string representing ticks.
|
|
17
|
+
* @param timestamp - The Date object to format.
|
|
18
|
+
* @returns A string representing the formatted ticks.
|
|
19
|
+
*/
|
|
15
20
|
function formatTicks (timestamp: Date): string {
|
|
16
21
|
const epochTicks = 621355968000000000
|
|
17
22
|
const ticksPerMillisecond = 10000
|
|
@@ -19,10 +24,21 @@ function formatTicks (timestamp: Date): string {
|
|
|
19
24
|
return ticks.toString(16)
|
|
20
25
|
}
|
|
21
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Generates a sanitized prefix for a channel.
|
|
29
|
+
* @param channelId - The ID of the channel.
|
|
30
|
+
* @returns A sanitized string prefix for the channel.
|
|
31
|
+
*/
|
|
22
32
|
function getChannelPrefix (channelId: string): string {
|
|
23
33
|
return sanitizeBlobKey(`${channelId}/`)
|
|
24
34
|
}
|
|
25
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Generates a sanitized prefix for a conversation within a channel.
|
|
38
|
+
* @param channelId - The ID of the channel.
|
|
39
|
+
* @param conversationId - The ID of the conversation.
|
|
40
|
+
* @returns A sanitized string prefix for the conversation.
|
|
41
|
+
*/
|
|
26
42
|
function getConversationPrefix (channelId: string, conversationId: string): string {
|
|
27
43
|
return sanitizeBlobKey(`${channelId}/${conversationId}`)
|
|
28
44
|
}
|
|
@@ -73,7 +89,14 @@ const MAX_PAGE_SIZE = 20
|
|
|
73
89
|
* Options for configuring the BlobsTranscriptStore.
|
|
74
90
|
*/
|
|
75
91
|
export interface BlobsTranscriptStoreOptions {
|
|
92
|
+
/**
|
|
93
|
+
* Optional pipeline options for configuring the Azure Blob Storage client.
|
|
94
|
+
*/
|
|
76
95
|
storagePipelineOptions?: StoragePipelineOptions;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Indicates whether to decode the transcript key when retrieving transcripts.
|
|
99
|
+
*/
|
|
77
100
|
decodeTranscriptKey?: boolean;
|
|
78
101
|
}
|
|
79
102
|
|
|
@@ -86,6 +109,14 @@ export class BlobsTranscriptStore implements TranscriptStore {
|
|
|
86
109
|
private _initializePromise?: Promise<unknown>
|
|
87
110
|
private _isDecodeTranscriptKey?: boolean = false
|
|
88
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Constructs a new instance of the BlobsTranscriptStore class.
|
|
114
|
+
* @param connectionString - The connection string for the Azure Blob Storage account.
|
|
115
|
+
* @param containerName - The name of the container to use for storing transcripts.
|
|
116
|
+
* @param options - Optional configuration options for the store.
|
|
117
|
+
* @param blobServiceUri - Optional URI for the blob service.
|
|
118
|
+
* @param tokenCredential - Optional credentials for authenticating with the blob service.
|
|
119
|
+
*/
|
|
89
120
|
constructor (
|
|
90
121
|
connectionString: string,
|
|
91
122
|
containerName: string,
|
|
@@ -134,6 +165,14 @@ export class BlobsTranscriptStore implements TranscriptStore {
|
|
|
134
165
|
return this._initializePromise
|
|
135
166
|
}
|
|
136
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Retrieves transcript activities for a specific conversation.
|
|
170
|
+
* @param channelId - The ID of the channel.
|
|
171
|
+
* @param conversationId - The ID of the conversation.
|
|
172
|
+
* @param continuationToken - Optional token for paginated results.
|
|
173
|
+
* @param startDate - Optional start date to filter activities.
|
|
174
|
+
* @returns A promise resolving to a paged result of activities.
|
|
175
|
+
*/
|
|
137
176
|
async getTranscriptActivities (
|
|
138
177
|
channelId: string,
|
|
139
178
|
conversationId: string,
|
|
@@ -202,6 +241,12 @@ export class BlobsTranscriptStore implements TranscriptStore {
|
|
|
202
241
|
}
|
|
203
242
|
}
|
|
204
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Lists all transcripts for a specific channel.
|
|
246
|
+
* @param channelId - The ID of the channel.
|
|
247
|
+
* @param continuationToken - Optional token for paginated results.
|
|
248
|
+
* @returns A promise resolving to a paged result of transcript information.
|
|
249
|
+
*/
|
|
205
250
|
async listTranscripts (channelId: string, continuationToken?: string): Promise<PagedResult<TranscriptInfo>> {
|
|
206
251
|
z.object({ channelId: z.string() }).parse({ channelId })
|
|
207
252
|
|
|
@@ -242,6 +287,12 @@ export class BlobsTranscriptStore implements TranscriptStore {
|
|
|
242
287
|
}
|
|
243
288
|
}
|
|
244
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Deletes all transcripts for a specific conversation.
|
|
292
|
+
* @param channelId - The ID of the channel.
|
|
293
|
+
* @param conversationId - The ID of the conversation.
|
|
294
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
295
|
+
*/
|
|
245
296
|
async deleteTranscript (channelId: string, conversationId: string): Promise<void> {
|
|
246
297
|
z.object({ channelId: z.string(), conversationId: z.string() }).parse({ channelId, conversationId })
|
|
247
298
|
|
|
@@ -270,6 +321,12 @@ export class BlobsTranscriptStore implements TranscriptStore {
|
|
|
270
321
|
}
|
|
271
322
|
}
|
|
272
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Logs an activity to the transcript store.
|
|
326
|
+
* @param activity - The activity to log.
|
|
327
|
+
* @param options - Optional configuration options for the operation.
|
|
328
|
+
* @returns A promise that resolves when the activity is logged.
|
|
329
|
+
*/
|
|
273
330
|
async logActivity (activity: Activity, options?: BlobsTranscriptStoreOptions): Promise<void> {
|
|
274
331
|
z.object({ activity: z.record(z.unknown()) }).parse({ activity })
|
|
275
332
|
|