@azure/storage-blob-changefeed 12.0.0-alpha.20250530.1 → 12.0.0-alpha.20250613.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.
- package/dist/browser/BlobChangeFeedClient.d.ts +1 -1
- package/dist/browser/BlobChangeFeedClient.js +1 -1
- package/dist/browser/BlobChangeFeedClient.js.map +1 -1
- package/dist/browser/models/BlobChangeFeedEvent.d.ts +1 -1
- package/dist/browser/models/BlobChangeFeedEvent.js.map +1 -1
- package/dist/commonjs/BlobChangeFeedClient.d.ts +1 -1
- package/dist/commonjs/BlobChangeFeedClient.js +1 -1
- package/dist/commonjs/BlobChangeFeedClient.js.map +1 -1
- package/dist/commonjs/models/BlobChangeFeedEvent.d.ts +1 -1
- package/dist/commonjs/models/BlobChangeFeedEvent.js.map +1 -1
- package/dist/esm/BlobChangeFeedClient.d.ts +1 -1
- package/dist/esm/BlobChangeFeedClient.js +1 -1
- package/dist/esm/BlobChangeFeedClient.js.map +1 -1
- package/dist/esm/models/BlobChangeFeedEvent.d.ts +1 -1
- package/dist/esm/models/BlobChangeFeedEvent.js.map +1 -1
- package/dist/react-native/BlobChangeFeedClient.d.ts +1 -1
- package/dist/react-native/BlobChangeFeedClient.js +1 -1
- package/dist/react-native/BlobChangeFeedClient.js.map +1 -1
- package/dist/react-native/models/BlobChangeFeedEvent.d.ts +1 -1
- package/dist/react-native/models/BlobChangeFeedEvent.js.map +1 -1
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ export interface BlobChangeFeedClientOptions {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* BlobChangeFeedClient.
|
|
40
|
-
* @see https://learn.microsoft.com/
|
|
40
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
41
41
|
*/
|
|
42
42
|
export declare class BlobChangeFeedClient {
|
|
43
43
|
/**
|
|
@@ -41,7 +41,7 @@ function appendUserAgentPrefix(options) {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* BlobChangeFeedClient.
|
|
44
|
-
* @see https://learn.microsoft.com/
|
|
44
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
45
45
|
*/
|
|
46
46
|
export class BlobChangeFeedClient {
|
|
47
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedClient.js","sourceRoot":"","sources":["../../src/BlobChangeFeedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAI9E;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAWlC;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,UAA+E,EAC/E,kBAA0C,EAAE;IAE5C,OAAO,WAAW,CAAC,UAAU,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgC;IAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAC3D,OAAO,CAAC,gBAAgB,CAAC,eAAe,GAAG,EAAE,CAAC;IAChD,CAAC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AAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;gBACD,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;oBACzB,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAI,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAChC,oBAAM,SAAS,CAAA,CAAC;gBAClB,CAAC;qBAAM,CAAC;oBACN,6BAAO;gBACT,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+EG;IACI,WAAW,CAChB,UAA4C,EAAE;QAE9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO;YACL;;eAEG;YACH,KAAK,CAAC,IAAI;gBACR,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD;;eAEG;YACH,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD;;eAEG;YACH,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE;gBACtC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedClient.js","sourceRoot":"","sources":["../../src/BlobChangeFeedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAI9E;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAWlC;QACE,IAAI,CAAC,MA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KAAK,CAAC,IAAI;gBACR,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD;;eAEG;YACH,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD;;eAEG;YACH,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE;gBACtC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export type BlobChangeFeedEventType = "UnspecifiedEventType" | "BlobCreated" | "BlobDeleted" | "BlobPropertiesUpdated" | "BlobSnapshotCreated" | "Control" | "BlobTierChanged" | "BlobAsyncOperationInitiated" | "BlobMetadataUpdated" | "RestorePointMarkerCreated";
|
|
5
5
|
/**
|
|
6
6
|
* Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.
|
|
7
|
-
* @see https://learn.microsoft.com/
|
|
7
|
+
* @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties
|
|
8
8
|
*/
|
|
9
9
|
export interface BlobChangeFeedEvent {
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties\n */\nexport interface BlobChangeFeedEvent {\n /**\n * Full resource path to the event source. This field is not writeable. Event Grid provides this value.\n */\n topic: string;\n\n /**\n * Publisher-defined path to the event subject.\n */\n subject: string;\n\n /**\n * One of the registered event types for this event source.\n */\n eventType: BlobChangeFeedEventType;\n\n /**\n * The time the event is generated based on the provider's UTC time.\n */\n eventTime: Date;\n\n /**\n * Unique identifier for the event.\n */\n id: string; // GUID\n\n /**\n * Blob storage event data.\n */\n data: BlobChangeFeedEventData;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n dataVersion?: string;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n schemaVersion?: number;\n\n /**\n * The schema version of the event metadata. Event Grid defines the schema of the top-level properties. Event Grid provides this value.\n */\n metadataVersion: string;\n}\n\n/**\n * The type of blob.\n */\nexport type BlobType = \"BlockBlob\" | \"AppendBlob\" | \"PageBlob\";\n\n/**\n * The AccessTier.\n */\nexport type AccessTier =\n | \"P4\"\n | \"P6\"\n | \"P10\"\n | \"P15\"\n | \"P20\"\n | \"P30\"\n | \"P40\"\n | \"P50\"\n | \"P60\"\n | \"P70\"\n | \"P80\"\n | \"Hot\"\n | \"Cool\"\n | \"Archive\";\n\n/**\n * A blob property that was updated.\n */\nexport interface BlobPropertyChange {\n /**\n * The name of the property that was updated.\n */\n propertyName: string;\n /**\n * The previous value of the property.\n */\n oldValue: string;\n /**\n * The new value of the property.\n */\n newValue: string;\n}\n/**\n * Blob properties that were updated during an event.\n */\nexport type UpdatedBlobProperties = Record<string, BlobPropertyChange>;\n/**\n * Previous info for Change Feed Event.\n */\nexport interface ChangeFeedEventPreviousInfo {\n /**\n * Soft delete snapshot.\n */\n softDeleteSnapshot?: string;\n /**\n * If the blob was soft deleted.\n */\n isBlobSoftDeleted: boolean;\n /**\n * Blob version.\n */\n newBlobVersion?: string;\n /**\n * Last version.\n */\n oldBlobVersion?: string;\n /**\n * Previous Access Tier\n */\n previousTier?: AccessTier;\n}\n\n/**\n * ChangeFeedEvent AsyncOperationInfo\n */\nexport interface BlobOperationResult {\n /**\n * Destination access tier.\n */\n destinationAccessTier?: AccessTier;\n /**\n * If the operation was async.\n */\n isAsync: boolean;\n /**\n * Copy Id.\n */\n copyId?: string;\n}\n\n/**\n * Blob tags that were updated as part of the change feed event.\n */\nexport interface BlobTagsChange {\n /**\n * Previous Tags.\n */\n oldTags: Record<string, string>;\n /**\n * New Tags.\n */\n newTags: Record<string, string>;\n}\n\n/**\n * Change feed Blob storage event data.\n */\nexport interface BlobChangeFeedEventData {\n /**\n * The operation that triggered the event.\n */\n api: string;\n\n /**\n * A client-provided request id for the storage API operation. This id can be used to\n * correlate to Azure Storage diagnostic logs using the \"client-request-id\" field in the logs,\n * and can be provided in client requests using the \"x-ms-client-request-id\" header.\n */\n clientRequestId: string; // GUID\n\n /**\n * Service-generated request id for the storage API operation. Can be used to correlate to Azure Storage\n * diagnostic logs using the \"request-id-header\" field in the logs and is returned from initiating API call\n * in the 'x-ms-request-id' header.\n */\n requestId: string; // GUID\n\n /**\n * The value that you can use to perform operations conditionally.\n */\n etag: string;\n\n /**\n * The content type specified for the blob.\n */\n contentType: string;\n\n /**\n * The size of the blob in bytes.\n */\n contentLength: number;\n\n /**\n * The offset in bytes of a write operation taken at the point where the event-triggering application completed\n * writing to the file.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n contentOffset?: number;\n\n /**\n * The type of blob.\n */\n blobType: BlobType;\n\n /**\n * The path to the blob. If the client uses a Blob REST API, then the url has this structure:\n * <storage-account-name>.blob.core.windows.net/<container-name>/<file-name>.\n */\n url: string;\n\n /**\n * The url of the file that will exist after the operation completes. For example, if a file is renamed,\n * the destinationUrl property contains the url of the new file name.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n destinationUrl?: string;\n\n /**\n * The url of the file that exists prior to the operation. For example, if a file is renamed, the sourceUrl\n * contains the url of the original file name prior to the rename operation.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n sourceUrl?: string;\n\n /**\n * True to perform the operation on all child directories; otherwise False.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n isRecursive?: boolean;\n\n /**\n * An opaque string value representing the logical sequence of events for any particular blob name.\n * Users can use standard string comparison to understand the relative sequence of two events on the same blob name.\n */\n sequencer: string;\n\n /**\n * Previous info for the blob.\n */\n previousInfo?: ChangeFeedEventPreviousInfo;\n\n /**\n * Blob properties that were updated during this event.\n */\n updatedBlobProperties?: UpdatedBlobProperties;\n\n /**\n * Blob tags that were updated during this event.\n */\n updatedBlobTags?: BlobTagsChange;\n\n /**\n * The Snapshot associated with the event.\n */\n snapshot?: string;\n\n /**\n * Version of the blob.\n */\n blobVersion?: string;\n\n /**\n * Version of the container the blob is in.\n */\n containerVersion?: string;\n\n /**\n * Access Tier of the blob.\n */\n blobAccessTier?: AccessTier;\n /**\n * AsyncOperationInfo\n */\n longRunningOperationInfo?: BlobOperationResult;\n}\n"]}
|
|
@@ -37,7 +37,7 @@ export interface BlobChangeFeedClientOptions {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* BlobChangeFeedClient.
|
|
40
|
-
* @see https://learn.microsoft.com/
|
|
40
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
41
41
|
*/
|
|
42
42
|
export declare class BlobChangeFeedClient {
|
|
43
43
|
/**
|
|
@@ -46,7 +46,7 @@ function appendUserAgentPrefix(options) {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* BlobChangeFeedClient.
|
|
49
|
-
* @see https://learn.microsoft.com/
|
|
49
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
50
50
|
*/
|
|
51
51
|
class BlobChangeFeedClient {
|
|
52
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedClient.js","sourceRoot":"","sources":["../../src/BlobChangeFeedClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA2ClC,kCAKC;;AAzCD,sDAAkE;AAGlE,iEAA2D;AAE3D,uDAA8E;AAI9E;;GAEG;AACH,MAAa,uBAAuB;IAWlC;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACF;AAfD,0DAeC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CACzB,UAA+E,EAC/E,kBAA0C,EAAE;IAE5C,OAAO,WAAW,CAAC,UAAU,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgC;IAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,EAAE,CAAC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AC;IACJ,CAAC;CACF;AArSD,oDAqSC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedClient.js","sourceRoot":"","sources":["../../src/BlobChangeFeedClient.ts"],"names":[],"mappings":";AAAA,u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;;;;;;;;;;;;;;;;;;;;OA+EG;IACI,WAAW,CAChB,UAA4C,EAAE;QAE9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO;YACL;;eAEG;YACH,KAAK,CAAC,IAAI;gBACR,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD;;eAEG;YACH,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD;;eAEG;YACH,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE;gBACtC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AArSD,oDAqSC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export type BlobChangeFeedEventType = "UnspecifiedEventType" | "BlobCreated" | "BlobDeleted" | "BlobPropertiesUpdated" | "BlobSnapshotCreated" | "Control" | "BlobTierChanged" | "BlobAsyncOperationInitiated" | "BlobMetadataUpdated" | "RestorePointMarkerCreated";
|
|
5
5
|
/**
|
|
6
6
|
* Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.
|
|
7
|
-
* @see https://learn.microsoft.com/
|
|
7
|
+
* @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties
|
|
8
8
|
*/
|
|
9
9
|
export interface BlobChangeFeedEvent {
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties\n */\nexport interface BlobChangeFeedEvent {\n /**\n * Full resource path to the event source. This field is not writeable. Event Grid provides this value.\n */\n topic: string;\n\n /**\n * Publisher-defined path to the event subject.\n */\n subject: string;\n\n /**\n * One of the registered event types for this event source.\n */\n eventType: BlobChangeFeedEventType;\n\n /**\n * The time the event is generated based on the provider's UTC time.\n */\n eventTime: Date;\n\n /**\n * Unique identifier for the event.\n */\n id: string; // GUID\n\n /**\n * Blob storage event data.\n */\n data: BlobChangeFeedEventData;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n dataVersion?: string;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n schemaVersion?: number;\n\n /**\n * The schema version of the event metadata. Event Grid defines the schema of the top-level properties. Event Grid provides this value.\n */\n metadataVersion: string;\n}\n\n/**\n * The type of blob.\n */\nexport type BlobType = \"BlockBlob\" | \"AppendBlob\" | \"PageBlob\";\n\n/**\n * The AccessTier.\n */\nexport type AccessTier =\n | \"P4\"\n | \"P6\"\n | \"P10\"\n | \"P15\"\n | \"P20\"\n | \"P30\"\n | \"P40\"\n | \"P50\"\n | \"P60\"\n | \"P70\"\n | \"P80\"\n | \"Hot\"\n | \"Cool\"\n | \"Archive\";\n\n/**\n * A blob property that was updated.\n */\nexport interface BlobPropertyChange {\n /**\n * The name of the property that was updated.\n */\n propertyName: string;\n /**\n * The previous value of the property.\n */\n oldValue: string;\n /**\n * The new value of the property.\n */\n newValue: string;\n}\n/**\n * Blob properties that were updated during an event.\n */\nexport type UpdatedBlobProperties = Record<string, BlobPropertyChange>;\n/**\n * Previous info for Change Feed Event.\n */\nexport interface ChangeFeedEventPreviousInfo {\n /**\n * Soft delete snapshot.\n */\n softDeleteSnapshot?: string;\n /**\n * If the blob was soft deleted.\n */\n isBlobSoftDeleted: boolean;\n /**\n * Blob version.\n */\n newBlobVersion?: string;\n /**\n * Last version.\n */\n oldBlobVersion?: string;\n /**\n * Previous Access Tier\n */\n previousTier?: AccessTier;\n}\n\n/**\n * ChangeFeedEvent AsyncOperationInfo\n */\nexport interface BlobOperationResult {\n /**\n * Destination access tier.\n */\n destinationAccessTier?: AccessTier;\n /**\n * If the operation was async.\n */\n isAsync: boolean;\n /**\n * Copy Id.\n */\n copyId?: string;\n}\n\n/**\n * Blob tags that were updated as part of the change feed event.\n */\nexport interface BlobTagsChange {\n /**\n * Previous Tags.\n */\n oldTags: Record<string, string>;\n /**\n * New Tags.\n */\n newTags: Record<string, string>;\n}\n\n/**\n * Change feed Blob storage event data.\n */\nexport interface BlobChangeFeedEventData {\n /**\n * The operation that triggered the event.\n */\n api: string;\n\n /**\n * A client-provided request id for the storage API operation. This id can be used to\n * correlate to Azure Storage diagnostic logs using the \"client-request-id\" field in the logs,\n * and can be provided in client requests using the \"x-ms-client-request-id\" header.\n */\n clientRequestId: string; // GUID\n\n /**\n * Service-generated request id for the storage API operation. Can be used to correlate to Azure Storage\n * diagnostic logs using the \"request-id-header\" field in the logs and is returned from initiating API call\n * in the 'x-ms-request-id' header.\n */\n requestId: string; // GUID\n\n /**\n * The value that you can use to perform operations conditionally.\n */\n etag: string;\n\n /**\n * The content type specified for the blob.\n */\n contentType: string;\n\n /**\n * The size of the blob in bytes.\n */\n contentLength: number;\n\n /**\n * The offset in bytes of a write operation taken at the point where the event-triggering application completed\n * writing to the file.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n contentOffset?: number;\n\n /**\n * The type of blob.\n */\n blobType: BlobType;\n\n /**\n * The path to the blob. If the client uses a Blob REST API, then the url has this structure:\n * <storage-account-name>.blob.core.windows.net/<container-name>/<file-name>.\n */\n url: string;\n\n /**\n * The url of the file that will exist after the operation completes. For example, if a file is renamed,\n * the destinationUrl property contains the url of the new file name.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n destinationUrl?: string;\n\n /**\n * The url of the file that exists prior to the operation. For example, if a file is renamed, the sourceUrl\n * contains the url of the original file name prior to the rename operation.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n sourceUrl?: string;\n\n /**\n * True to perform the operation on all child directories; otherwise False.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n isRecursive?: boolean;\n\n /**\n * An opaque string value representing the logical sequence of events for any particular blob name.\n * Users can use standard string comparison to understand the relative sequence of two events on the same blob name.\n */\n sequencer: string;\n\n /**\n * Previous info for the blob.\n */\n previousInfo?: ChangeFeedEventPreviousInfo;\n\n /**\n * Blob properties that were updated during this event.\n */\n updatedBlobProperties?: UpdatedBlobProperties;\n\n /**\n * Blob tags that were updated during this event.\n */\n updatedBlobTags?: BlobTagsChange;\n\n /**\n * The Snapshot associated with the event.\n */\n snapshot?: string;\n\n /**\n * Version of the blob.\n */\n blobVersion?: string;\n\n /**\n * Version of the container the blob is in.\n */\n containerVersion?: string;\n\n /**\n * Access Tier of the blob.\n */\n blobAccessTier?: AccessTier;\n /**\n * AsyncOperationInfo\n */\n longRunningOperationInfo?: BlobOperationResult;\n}\n"]}
|
|
@@ -37,7 +37,7 @@ export interface BlobChangeFeedClientOptions {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* BlobChangeFeedClient.
|
|
40
|
-
* @see https://learn.microsoft.com/
|
|
40
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
41
41
|
*/
|
|
42
42
|
export declare class BlobChangeFeedClient {
|
|
43
43
|
/**
|
|
@@ -41,7 +41,7 @@ function appendUserAgentPrefix(options) {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* BlobChangeFeedClient.
|
|
44
|
-
* @see https://learn.microsoft.com/
|
|
44
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
45
45
|
*/
|
|
46
46
|
export class BlobChangeFeedClient {
|
|
47
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedClient.js","sourceRoot":"","sources":["../../src/BlobChangeFeedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAI9E;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAWlC;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,iBAAiB,GA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AE,CAAC;YACrB,CAAC;YACD;;eAEG;YACH,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD;;eAEG;YACH,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE;gBACtC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedClient.js","sourceRoot":"","sources":["../../src/BlobChangeFeedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAI9E;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAWlC;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,UAA+E,EAC/E,kBAA0C,EAAE;IAE5C,OAAO,WAAW,CAAC,UAAU,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgC;IAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAC3D,OAAO,CAAC,gBAAgB,CAAC,eAAe,GAAG,EAAE,CAAC;IAChD,CAAC;SAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe,KAAK,EAAE,EAAE,CAAC;QA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,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;oBACzB,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAI,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAChC,oBAAM,SAAS,CAAA,CAAC;gBAClB,CAAC;qBAAM,CAAC;oBACN,6BAAO;gBACT,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+EG;IACI,WAAW,CAChB,UAA4C,EAAE;QAE9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO;YACL;;eAEG;YACH,KAAK,CAAC,IAAI;gBACR,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD;;eAEG;YACH,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD;;eAEG;YACH,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE;gBACtC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export type BlobChangeFeedEventType = "UnspecifiedEventType" | "BlobCreated" | "BlobDeleted" | "BlobPropertiesUpdated" | "BlobSnapshotCreated" | "Control" | "BlobTierChanged" | "BlobAsyncOperationInitiated" | "BlobMetadataUpdated" | "RestorePointMarkerCreated";
|
|
5
5
|
/**
|
|
6
6
|
* Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.
|
|
7
|
-
* @see https://learn.microsoft.com/
|
|
7
|
+
* @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties
|
|
8
8
|
*/
|
|
9
9
|
export interface BlobChangeFeedEvent {
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties\n */\nexport interface BlobChangeFeedEvent {\n /**\n * Full resource path to the event source. This field is not writeable. Event Grid provides this value.\n */\n topic: string;\n\n /**\n * Publisher-defined path to the event subject.\n */\n subject: string;\n\n /**\n * One of the registered event types for this event source.\n */\n eventType: BlobChangeFeedEventType;\n\n /**\n * The time the event is generated based on the provider's UTC time.\n */\n eventTime: Date;\n\n /**\n * Unique identifier for the event.\n */\n id: string; // GUID\n\n /**\n * Blob storage event data.\n */\n data: BlobChangeFeedEventData;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n dataVersion?: string;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n schemaVersion?: number;\n\n /**\n * The schema version of the event metadata. Event Grid defines the schema of the top-level properties. Event Grid provides this value.\n */\n metadataVersion: string;\n}\n\n/**\n * The type of blob.\n */\nexport type BlobType = \"BlockBlob\" | \"AppendBlob\" | \"PageBlob\";\n\n/**\n * The AccessTier.\n */\nexport type AccessTier =\n | \"P4\"\n | \"P6\"\n | \"P10\"\n | \"P15\"\n | \"P20\"\n | \"P30\"\n | \"P40\"\n | \"P50\"\n | \"P60\"\n | \"P70\"\n | \"P80\"\n | \"Hot\"\n | \"Cool\"\n | \"Archive\";\n\n/**\n * A blob property that was updated.\n */\nexport interface BlobPropertyChange {\n /**\n * The name of the property that was updated.\n */\n propertyName: string;\n /**\n * The previous value of the property.\n */\n oldValue: string;\n /**\n * The new value of the property.\n */\n newValue: string;\n}\n/**\n * Blob properties that were updated during an event.\n */\nexport type UpdatedBlobProperties = Record<string, BlobPropertyChange>;\n/**\n * Previous info for Change Feed Event.\n */\nexport interface ChangeFeedEventPreviousInfo {\n /**\n * Soft delete snapshot.\n */\n softDeleteSnapshot?: string;\n /**\n * If the blob was soft deleted.\n */\n isBlobSoftDeleted: boolean;\n /**\n * Blob version.\n */\n newBlobVersion?: string;\n /**\n * Last version.\n */\n oldBlobVersion?: string;\n /**\n * Previous Access Tier\n */\n previousTier?: AccessTier;\n}\n\n/**\n * ChangeFeedEvent AsyncOperationInfo\n */\nexport interface BlobOperationResult {\n /**\n * Destination access tier.\n */\n destinationAccessTier?: AccessTier;\n /**\n * If the operation was async.\n */\n isAsync: boolean;\n /**\n * Copy Id.\n */\n copyId?: string;\n}\n\n/**\n * Blob tags that were updated as part of the change feed event.\n */\nexport interface BlobTagsChange {\n /**\n * Previous Tags.\n */\n oldTags: Record<string, string>;\n /**\n * New Tags.\n */\n newTags: Record<string, string>;\n}\n\n/**\n * Change feed Blob storage event data.\n */\nexport interface BlobChangeFeedEventData {\n /**\n * The operation that triggered the event.\n */\n api: string;\n\n /**\n * A client-provided request id for the storage API operation. This id can be used to\n * correlate to Azure Storage diagnostic logs using the \"client-request-id\" field in the logs,\n * and can be provided in client requests using the \"x-ms-client-request-id\" header.\n */\n clientRequestId: string; // GUID\n\n /**\n * Service-generated request id for the storage API operation. Can be used to correlate to Azure Storage\n * diagnostic logs using the \"request-id-header\" field in the logs and is returned from initiating API call\n * in the 'x-ms-request-id' header.\n */\n requestId: string; // GUID\n\n /**\n * The value that you can use to perform operations conditionally.\n */\n etag: string;\n\n /**\n * The content type specified for the blob.\n */\n contentType: string;\n\n /**\n * The size of the blob in bytes.\n */\n contentLength: number;\n\n /**\n * The offset in bytes of a write operation taken at the point where the event-triggering application completed\n * writing to the file.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n contentOffset?: number;\n\n /**\n * The type of blob.\n */\n blobType: BlobType;\n\n /**\n * The path to the blob. If the client uses a Blob REST API, then the url has this structure:\n * <storage-account-name>.blob.core.windows.net/<container-name>/<file-name>.\n */\n url: string;\n\n /**\n * The url of the file that will exist after the operation completes. For example, if a file is renamed,\n * the destinationUrl property contains the url of the new file name.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n destinationUrl?: string;\n\n /**\n * The url of the file that exists prior to the operation. For example, if a file is renamed, the sourceUrl\n * contains the url of the original file name prior to the rename operation.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n sourceUrl?: string;\n\n /**\n * True to perform the operation on all child directories; otherwise False.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n isRecursive?: boolean;\n\n /**\n * An opaque string value representing the logical sequence of events for any particular blob name.\n * Users can use standard string comparison to understand the relative sequence of two events on the same blob name.\n */\n sequencer: string;\n\n /**\n * Previous info for the blob.\n */\n previousInfo?: ChangeFeedEventPreviousInfo;\n\n /**\n * Blob properties that were updated during this event.\n */\n updatedBlobProperties?: UpdatedBlobProperties;\n\n /**\n * Blob tags that were updated during this event.\n */\n updatedBlobTags?: BlobTagsChange;\n\n /**\n * The Snapshot associated with the event.\n */\n snapshot?: string;\n\n /**\n * Version of the blob.\n */\n blobVersion?: string;\n\n /**\n * Version of the container the blob is in.\n */\n containerVersion?: string;\n\n /**\n * Access Tier of the blob.\n */\n blobAccessTier?: AccessTier;\n /**\n * AsyncOperationInfo\n */\n longRunningOperationInfo?: BlobOperationResult;\n}\n"]}
|
|
@@ -37,7 +37,7 @@ export interface BlobChangeFeedClientOptions {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* BlobChangeFeedClient.
|
|
40
|
-
* @see https://learn.microsoft.com/
|
|
40
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
41
41
|
*/
|
|
42
42
|
export declare class BlobChangeFeedClient {
|
|
43
43
|
/**
|
|
@@ -41,7 +41,7 @@ function appendUserAgentPrefix(options) {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* BlobChangeFeedClient.
|
|
44
|
-
* @see https://learn.microsoft.com/
|
|
44
|
+
* @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
|
|
45
45
|
*/
|
|
46
46
|
export class BlobChangeFeedClient {
|
|
47
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedClient.js","sourceR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M,SAAS,CAAA,CAAC;gBAClB,CAAC;qBAAM,CAAC;oBACN,6BAAO;gBACT,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+EG;IACI,WAAW,CAChB,UAA4C,EAAE;QAE9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO;YACL;;eAEG;YACH,KAAK,CAAC,IAAI;gBACR,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD;;eAEG;YACH,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD;;eAEG;YACH,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE;gBACtC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedClient.js","sourceRoot":"","sources":["../../src/BlobChangeFeedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAI9E;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAWlC;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,UAA+E,EAC/E,kBAA0C,EAAE;IAE5C,OAAO,WAAW,CAAC,UAAU,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgC;IAC7D,IAAI,CA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AAW,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n StoragePipelineOptions,\n StorageSharedKeyCredential,\n AnonymousCredential,\n} from \"@azure/storage-blob\";\nimport { BlobServiceClient, Pipeline } from \"@azure/storage-blob\";\nimport type { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport type { BlobChangeFeedEvent } from \"./models/BlobChangeFeedEvent.js\";\nimport { ChangeFeedFactory } from \"./ChangeFeedFactory.js\";\nimport type { ChangeFeed } from \"./ChangeFeed.js\";\nimport { CHANGE_FEED_MAX_PAGE_SIZE, SDK_VERSION } from \"./utils/constants.js\";\nimport type { BlobChangeFeedListChangesOptions } from \"./models/models.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.\n */\nexport class BlobChangeFeedEventPage {\n /**\n * Array of {@link BlobChangeFeedEvent}.\n */\n public events: BlobChangeFeedEvent[];\n\n /**\n * The token that keeps track of where to continue the iterator.\n */\n public continuationToken: string;\n\n constructor() {\n this.events = [];\n this.continuationToken = \"\";\n }\n}\n\n/**\n * Creates a new Pipeline object with Credential provided.\n *\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param pipelineOptions - Optional. Options.\n * @returns A new Pipeline object.\n */\nexport function newPipeline(\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n pipelineOptions: StoragePipelineOptions = {},\n): Pipeline {\n return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));\n}\n\nfunction appendUserAgentPrefix(options?: StoragePipelineOptions): StoragePipelineOptions {\n if (!options) {\n options = {};\n }\n if (options.userAgentOptions === undefined) {\n options.userAgentOptions = {};\n }\n\n if (options.userAgentOptions.userAgentPrefix === undefined) {\n options.userAgentOptions.userAgentPrefix = \"\";\n } else if (options.userAgentOptions.userAgentPrefix !== \"\") {\n options.userAgentOptions.userAgentPrefix += \" \";\n }\n options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;\n return options;\n}\n\n/**\n * Blob Change Feed client options.\n */\nexport interface BlobChangeFeedClientOptions {\n /**\n * The maximum length of an transfer in bytes.\n */\n maximumTransferSize?: number;\n}\n\n/**\n * BlobChangeFeedClient.\n * @see https://learn.microsoft.com/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal\n */\nexport class BlobChangeFeedClient {\n /**\n * blobServiceClient provided by `@azure/storage-blob` package.\n */\n private blobServiceClient: BlobServiceClient;\n private changeFeedFactory: ChangeFeedFactory;\n private changeFeedClientOptions: BlobChangeFeedClientOptions;\n\n /**\n *\n * Creates an instance of BlobChangeFeedClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public static fromConnectionString(\n connectionString: string,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n // Static method to construct an object, the option is for the object not for the method.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ): BlobChangeFeedClient {\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);\n return new BlobChangeFeedClient(\n blobServiceClient.url,\n blobServiceClient.credential,\n appendUserAgentPrefix(options),\n changeFeedClientOptions,\n );\n }\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Optional. Options to configure the HTTP pipeline.\n *\n * Example using DefaultAzureCredential from `@azure/identity`:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n * ```\n *\n * Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * // Enter your storage account name and shared key\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * // Use StorageSharedKeyCredential with storage account and account key\n * // StorageSharedKeyCredential is only available in Node.js runtime, not in browsers\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * // When using AnonymousCredential, following url should include a valid SAS or support public access\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n * ```\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n );\n\n /**\n * Creates an instance of BlobChangeFeedClient.\n *\n * @param url - A Client string pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: Pipeline);\n constructor(\n urlOrClient: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | Pipeline,\n // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */\n options?: StoragePipelineOptions,\n changeFeedClientOptions?: BlobChangeFeedClientOptions,\n ) {\n this.changeFeedClientOptions = changeFeedClientOptions || {};\n this.changeFeedFactory = new ChangeFeedFactory(\n this.changeFeedClientOptions.maximumTransferSize,\n );\n\n if (credentialOrPipeline instanceof Pipeline) {\n this.blobServiceClient = new BlobServiceClient(urlOrClient, credentialOrPipeline);\n } else {\n this.blobServiceClient = new BlobServiceClient(\n urlOrClient,\n credentialOrPipeline,\n appendUserAgentPrefix(options),\n );\n }\n }\n\n private async *getChange(\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEvent> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n undefined,\n options,\n );\n\n while (changeFeed.hasNext()) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n yield event;\n } else {\n return;\n }\n }\n }\n\n // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.\n private async *getPage(\n continuationToken?: string,\n maxPageSize?: number,\n options: BlobChangeFeedListChangesOptions = {},\n ): AsyncIterableIterator<BlobChangeFeedEventPage> {\n const changeFeed: ChangeFeed = await this.changeFeedFactory.create(\n this.blobServiceClient,\n continuationToken,\n options,\n );\n\n if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {\n maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;\n }\n while (changeFeed.hasNext()) {\n const eventPage = new BlobChangeFeedEventPage();\n while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {\n const event = await changeFeed.getChange({\n abortSignal: options.abortSignal,\n tracingOptions: options.tracingOptions,\n });\n if (event) {\n eventPage.events.push(event);\n }\n }\n if (changeFeed.hasNext()) {\n eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());\n }\n if (eventPage.events.length > 0) {\n yield eventPage;\n } else {\n return;\n }\n }\n }\n\n /**\n * Returns an async iterable iterator to list all the change feed events\n * in the specified account.\n *\n * .byPage() returns an async iterable iterator to list the change feed events in pages.\n *\n * Example using `for await` syntax:\n *\n * ```ts snippet:ReadmeSampleListChanges\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * // Use for await to iterate through the change feed\n * for await (const event of changeFeedClient.listChanges()) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n *\n * // Use `byPage` to iterate through the change feed\n * for await (const page of changeFeedClient.listChanges().byPage()) {\n * console.log(`Page: ${JSON.stringify(page)}`);\n * for (const event of page.events) {\n * console.log(`Event: ${event.eventType}`);\n * console.log(`Event time: ${event.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(event.data)}`);\n * }\n * }\n * ```\n *\n * Example using paging with a marker:\n *\n * ```ts snippet:ReadmeSampleListChanges_Continuation\n * import { StorageSharedKeyCredential } from \"@azure/storage-blob\";\n * import { BlobChangeFeedClient } from \"@azure/storage-blob-changefeed\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n * const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);\n * const changeFeedClient = new BlobChangeFeedClient(\n * `https://${account}.blob.core.windows.net`,\n * sharedKeyCredential,\n * );\n *\n * let iterator = changeFeedClient.listChanges().byPage({ maxPageSize: 2 });\n * let response = (await iterator.next()).value;\n * // Prints 2 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * // Gets next marker\n * let marker = response.continuationToken;\n * // Passing next marker as continuationToken\n * iterator = changeFeedClient.listChanges().byPage({ continuationToken: marker, maxPageSize: 10 });\n * response = (await iterator.next()).value;\n * // Prints 10 page ranges\n * if (response.pageRange) {\n * for (const pageRange of response.pageRange) {\n * console.log(`Event: ${pageRange.eventType}`);\n * console.log(`Event time: ${pageRange.eventTime}`);\n * console.log(`Event data: ${JSON.stringify(pageRange.data)}`);\n * }\n * }\n * ```\n *\n * @param options - Options to list change feed events.\n * @returns An asyncIterableIterator that supports paging.\n */\n public listChanges(\n options: BlobChangeFeedListChangesOptions = {},\n ): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage> {\n const iter = this.getChange(options);\n return {\n /**\n * The next method, part of the iteration protocol\n */\n async next() {\n return iter.next();\n },\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator]() {\n return this;\n },\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings: PageSettings = {}) => {\n return this.getPage(settings.continuationToken, settings.maxPageSize, options);\n },\n };\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export type BlobChangeFeedEventType = "UnspecifiedEventType" | "BlobCreated" | "BlobDeleted" | "BlobPropertiesUpdated" | "BlobSnapshotCreated" | "Control" | "BlobTierChanged" | "BlobAsyncOperationInitiated" | "BlobMetadataUpdated" | "RestorePointMarkerCreated";
|
|
5
5
|
/**
|
|
6
6
|
* Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.
|
|
7
|
-
* @see https://learn.microsoft.com/
|
|
7
|
+
* @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties
|
|
8
8
|
*/
|
|
9
9
|
export interface BlobChangeFeedEvent {
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/
|
|
1
|
+
{"version":3,"file":"BlobChangeFeedEvent.js","sourceRoot":"","sources":["../../../src/models/BlobChangeFeedEvent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// https://msazure.visualstudio.com/One/_git/Storage-XStore?path=%2Fsrc%2FXTable%2FNotifications%2Flib%2FBlobChangeEventv4.json&version=GBmaster\n\n/**\n * Change feed event record types.\n */\nexport type BlobChangeFeedEventType =\n | \"UnspecifiedEventType\"\n | \"BlobCreated\"\n | \"BlobDeleted\"\n | \"BlobPropertiesUpdated\"\n | \"BlobSnapshotCreated\"\n | \"Control\"\n | \"BlobTierChanged\"\n | \"BlobAsyncOperationInitiated\"\n | \"BlobMetadataUpdated\"\n | \"RestorePointMarkerCreated\";\n\n/**\n * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.\n * @see https://learn.microsoft.com/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties\n */\nexport interface BlobChangeFeedEvent {\n /**\n * Full resource path to the event source. This field is not writeable. Event Grid provides this value.\n */\n topic: string;\n\n /**\n * Publisher-defined path to the event subject.\n */\n subject: string;\n\n /**\n * One of the registered event types for this event source.\n */\n eventType: BlobChangeFeedEventType;\n\n /**\n * The time the event is generated based on the provider's UTC time.\n */\n eventTime: Date;\n\n /**\n * Unique identifier for the event.\n */\n id: string; // GUID\n\n /**\n * Blob storage event data.\n */\n data: BlobChangeFeedEventData;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n dataVersion?: string;\n\n /**\n * The schema version of the data object. The publisher defines the schema version.\n */\n schemaVersion?: number;\n\n /**\n * The schema version of the event metadata. Event Grid defines the schema of the top-level properties. Event Grid provides this value.\n */\n metadataVersion: string;\n}\n\n/**\n * The type of blob.\n */\nexport type BlobType = \"BlockBlob\" | \"AppendBlob\" | \"PageBlob\";\n\n/**\n * The AccessTier.\n */\nexport type AccessTier =\n | \"P4\"\n | \"P6\"\n | \"P10\"\n | \"P15\"\n | \"P20\"\n | \"P30\"\n | \"P40\"\n | \"P50\"\n | \"P60\"\n | \"P70\"\n | \"P80\"\n | \"Hot\"\n | \"Cool\"\n | \"Archive\";\n\n/**\n * A blob property that was updated.\n */\nexport interface BlobPropertyChange {\n /**\n * The name of the property that was updated.\n */\n propertyName: string;\n /**\n * The previous value of the property.\n */\n oldValue: string;\n /**\n * The new value of the property.\n */\n newValue: string;\n}\n/**\n * Blob properties that were updated during an event.\n */\nexport type UpdatedBlobProperties = Record<string, BlobPropertyChange>;\n/**\n * Previous info for Change Feed Event.\n */\nexport interface ChangeFeedEventPreviousInfo {\n /**\n * Soft delete snapshot.\n */\n softDeleteSnapshot?: string;\n /**\n * If the blob was soft deleted.\n */\n isBlobSoftDeleted: boolean;\n /**\n * Blob version.\n */\n newBlobVersion?: string;\n /**\n * Last version.\n */\n oldBlobVersion?: string;\n /**\n * Previous Access Tier\n */\n previousTier?: AccessTier;\n}\n\n/**\n * ChangeFeedEvent AsyncOperationInfo\n */\nexport interface BlobOperationResult {\n /**\n * Destination access tier.\n */\n destinationAccessTier?: AccessTier;\n /**\n * If the operation was async.\n */\n isAsync: boolean;\n /**\n * Copy Id.\n */\n copyId?: string;\n}\n\n/**\n * Blob tags that were updated as part of the change feed event.\n */\nexport interface BlobTagsChange {\n /**\n * Previous Tags.\n */\n oldTags: Record<string, string>;\n /**\n * New Tags.\n */\n newTags: Record<string, string>;\n}\n\n/**\n * Change feed Blob storage event data.\n */\nexport interface BlobChangeFeedEventData {\n /**\n * The operation that triggered the event.\n */\n api: string;\n\n /**\n * A client-provided request id for the storage API operation. This id can be used to\n * correlate to Azure Storage diagnostic logs using the \"client-request-id\" field in the logs,\n * and can be provided in client requests using the \"x-ms-client-request-id\" header.\n */\n clientRequestId: string; // GUID\n\n /**\n * Service-generated request id for the storage API operation. Can be used to correlate to Azure Storage\n * diagnostic logs using the \"request-id-header\" field in the logs and is returned from initiating API call\n * in the 'x-ms-request-id' header.\n */\n requestId: string; // GUID\n\n /**\n * The value that you can use to perform operations conditionally.\n */\n etag: string;\n\n /**\n * The content type specified for the blob.\n */\n contentType: string;\n\n /**\n * The size of the blob in bytes.\n */\n contentLength: number;\n\n /**\n * The offset in bytes of a write operation taken at the point where the event-triggering application completed\n * writing to the file.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n contentOffset?: number;\n\n /**\n * The type of blob.\n */\n blobType: BlobType;\n\n /**\n * The path to the blob. If the client uses a Blob REST API, then the url has this structure:\n * <storage-account-name>.blob.core.windows.net/<container-name>/<file-name>.\n */\n url: string;\n\n /**\n * The url of the file that will exist after the operation completes. For example, if a file is renamed,\n * the destinationUrl property contains the url of the new file name.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n destinationUrl?: string;\n\n /**\n * The url of the file that exists prior to the operation. For example, if a file is renamed, the sourceUrl\n * contains the url of the original file name prior to the rename operation.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n sourceUrl?: string;\n\n /**\n * True to perform the operation on all child directories; otherwise False.\n * Appears only for events triggered on blob storage accounts that have a hierarchical namespace.\n */\n isRecursive?: boolean;\n\n /**\n * An opaque string value representing the logical sequence of events for any particular blob name.\n * Users can use standard string comparison to understand the relative sequence of two events on the same blob name.\n */\n sequencer: string;\n\n /**\n * Previous info for the blob.\n */\n previousInfo?: ChangeFeedEventPreviousInfo;\n\n /**\n * Blob properties that were updated during this event.\n */\n updatedBlobProperties?: UpdatedBlobProperties;\n\n /**\n * Blob tags that were updated during this event.\n */\n updatedBlobTags?: BlobTagsChange;\n\n /**\n * The Snapshot associated with the event.\n */\n snapshot?: string;\n\n /**\n * Version of the blob.\n */\n blobVersion?: string;\n\n /**\n * Version of the container the blob is in.\n */\n containerVersion?: string;\n\n /**\n * Access Tier of the blob.\n */\n blobAccessTier?: AccessTier;\n /**\n * AsyncOperationInfo\n */\n longRunningOperationInfo?: BlobOperationResult;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/storage-blob-changefeed",
|
|
3
3
|
"sdk-type": "client",
|
|
4
|
-
"version": "12.0.0-alpha.
|
|
4
|
+
"version": "12.0.0-alpha.20250613.1",
|
|
5
5
|
"description": "Microsoft Azure Storage SDK for JavaScript - Blob Change Feed",
|
|
6
6
|
"main": "./dist/commonjs/index.js",
|
|
7
7
|
"module": "./dist/esm/index.js",
|