Skip to content

Commit b3571fb

Browse files
authored
Add support for change feed schema V3, V4 and V5 (Azure#21270)
1 parent 469bb2e commit b3571fb

14 files changed

+981
-11
lines changed

sdk/storage/storage-blob-changefeed/recordings/node/change_feed_event_schema_test/recording_event_schema_v1_test.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/storage-blob-changefeed/recordings/node/change_feed_event_schema_test/recording_event_schema_v3_test.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/storage-blob-changefeed/recordings/node/change_feed_event_schema_test/recording_event_schema_v4_test.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/storage-blob-changefeed/recordings/node/change_feed_event_schema_test/recording_event_schema_v5_test.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/storage-blob-changefeed/review/storage-blob-changefeed.api.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { StoragePipelineOptions } from '@azure/storage-blob';
1313
import { StorageSharedKeyCredential } from '@azure/storage-blob';
1414
import { TokenCredential } from '@azure/core-http';
1515

16+
// @public
17+
export type AccessTier = "P4" | "P6" | "P10" | "P15" | "P20" | "P30" | "P40" | "P50" | "P60" | "P70" | "P80" | "Hot" | "Cool" | "Archive";
18+
1619
// @public
1720
export class BlobChangeFeedClient {
1821
constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions);
@@ -29,20 +32,33 @@ export interface BlobChangeFeedEvent {
2932
eventType: BlobChangeFeedEventType;
3033
id: string;
3134
metadataVersion: string;
35+
schemaVersion?: number;
3236
subject: string;
3337
topic: string;
3438
}
3539

3640
// @public
3741
export interface BlobChangeFeedEventData {
3842
api: string;
43+
blobAccessTier?: AccessTier;
3944
blobType: BlobType;
45+
blobVersion?: string;
4046
clientRequestId: string;
47+
containerVersion?: string;
4148
contentLength: number;
49+
contentOffset?: number;
4250
contentType: string;
51+
destinationUrl?: string;
4352
etag: string;
53+
isRecursive?: boolean;
54+
longRunningOperationInfo?: BlobOperationResult;
55+
previousInfo?: ChangeFeedEventPreviousInfo;
4456
requestId: string;
4557
sequencer: string;
58+
snapshot?: string;
59+
sourceUrl?: string;
60+
updatedBlobProperties?: UpdatedBlobProperties;
61+
updatedBlobTags?: BlobTagsChange;
4662
url: string;
4763
}
4864

@@ -54,7 +70,7 @@ export class BlobChangeFeedEventPage {
5470
}
5571

5672
// @public
57-
export type BlobChangeFeedEventType = "UnspecifiedEventType" | "BlobCreated" | "BlobDeleted" | "BlobPropertiesUpdated" | "BlobSnapshotCreated" | "Control" | "BlobTierChanged" | "BlobAsyncOperationInitiated" | "BlobMetadataUpdated";
73+
export type BlobChangeFeedEventType = "UnspecifiedEventType" | "BlobCreated" | "BlobDeleted" | "BlobPropertiesUpdated" | "BlobSnapshotCreated" | "Control" | "BlobTierChanged" | "BlobAsyncOperationInitiated" | "BlobMetadataUpdated" | "RestorePointMarkerCreated";
5874

5975
// @public
6076
export interface BlobChangeFeedListChangesOptions extends CommonOptions {
@@ -63,12 +79,43 @@ export interface BlobChangeFeedListChangesOptions extends CommonOptions {
6379
start?: Date;
6480
}
6581

82+
// @public
83+
export interface BlobOperationResult {
84+
copyId?: string;
85+
destinationAccessTier?: AccessTier;
86+
isAsync: boolean;
87+
}
88+
89+
// @public
90+
export interface BlobPropertyChange {
91+
newValue: string;
92+
oldValue: string;
93+
propertyName: string;
94+
}
95+
96+
// @public
97+
export interface BlobTagsChange {
98+
newTags: Record<string, string>;
99+
oldTags: Record<string, string>;
100+
}
101+
66102
// @public
67103
export type BlobType = "BlockBlob" | "AppendBlob" | "PageBlob";
68104

105+
// @public
106+
export interface ChangeFeedEventPreviousInfo {
107+
isBlobSoftDeleted: boolean;
108+
newBlobVersion?: string;
109+
oldBlobVersion?: string;
110+
previousTier?: AccessTier;
111+
softDeleteSnapshot?: string;
112+
}
113+
69114
// @public
70115
export function newPipeline(credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, pipelineOptions?: StoragePipelineOptions): Pipeline;
71116

117+
// @public
118+
export type UpdatedBlobProperties = Record<string, BlobPropertyChange>;
72119

73120
// (No @packageDocumentation comment for this package)
74121

sdk/storage/storage-blob-changefeed/src/Chunk.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { BlobChangeFeedEvent } from "./models/BlobChangeFeedEvent";
66
import { CommonOptions } from "@azure/storage-blob";
77
import { AbortSignalLike } from "@azure/core-http";
88
import { AvroParseOptions } from "../../storage-internal-avro/src/AvroReader";
9+
import { rawEventToBlobChangeFeedEvent } from "./utils/utils.common";
910

1011
/**
1112
* Options to configure {@link Chunk.getChange} operation.
@@ -66,14 +67,7 @@ export class Chunk {
6667
return undefined;
6768
}
6869

69-
if (eventRaw.eventTime) {
70-
eventRaw.eventTime = new Date(eventRaw.eventTime);
71-
}
72-
if (eventRaw.eTag) {
73-
eventRaw.etag = eventRaw.eTag;
74-
delete eventRaw.eTag;
75-
}
76-
return eventRaw as BlobChangeFeedEvent;
70+
return rawEventToBlobChangeFeedEvent(eventRaw);
7771
}
7872
}
7973
}

sdk/storage/storage-blob-changefeed/src/models/BlobChangeFeedEvent.ts

Lines changed: 171 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export type BlobChangeFeedEventType =
1515
| "Control"
1616
| "BlobTierChanged"
1717
| "BlobAsyncOperationInitiated"
18-
| "BlobMetadataUpdated";
18+
| "BlobMetadataUpdated"
19+
| "RestorePointMarkerCreated";
1920

2021
/**
2122
* Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation.
@@ -57,6 +58,11 @@ export interface BlobChangeFeedEvent {
5758
*/
5859
dataVersion?: string;
5960

61+
/**
62+
* The schema version of the data object. The publisher defines the schema version.
63+
*/
64+
schemaVersion?: number;
65+
6066
/**
6167
* The schema version of the event metadata. Event Grid defines the schema of the top-level properties. Event Grid provides this value.
6268
*/
@@ -68,6 +74,104 @@ export interface BlobChangeFeedEvent {
6874
*/
6975
export type BlobType = "BlockBlob" | "AppendBlob" | "PageBlob";
7076

77+
/**
78+
* The AccessTier.
79+
*/
80+
export type AccessTier =
81+
| "P4"
82+
| "P6"
83+
| "P10"
84+
| "P15"
85+
| "P20"
86+
| "P30"
87+
| "P40"
88+
| "P50"
89+
| "P60"
90+
| "P70"
91+
| "P80"
92+
| "Hot"
93+
| "Cool"
94+
| "Archive";
95+
96+
/**
97+
* A blob property that was updated.
98+
*/
99+
export interface BlobPropertyChange {
100+
/**
101+
* The name of the property that was updated.
102+
*/
103+
propertyName: string;
104+
/**
105+
* The previous value of the property.
106+
*/
107+
oldValue: string;
108+
/**
109+
* The new value of the property.
110+
*/
111+
newValue: string;
112+
}
113+
/**
114+
* Blob properties that were updated during an event.
115+
*/
116+
export type UpdatedBlobProperties = Record<string, BlobPropertyChange>;
117+
/**
118+
* Previous info for Change Feed Event.
119+
*/
120+
export interface ChangeFeedEventPreviousInfo {
121+
/**
122+
* Soft delete snapshot.
123+
*/
124+
softDeleteSnapshot?: string;
125+
/**
126+
* If the blob was soft deleted.
127+
*/
128+
isBlobSoftDeleted: boolean;
129+
/**
130+
* Blob version.
131+
*/
132+
newBlobVersion?: string;
133+
/**
134+
* Last version.
135+
*/
136+
oldBlobVersion?: string;
137+
/**
138+
* Previous Access Tier
139+
*/
140+
previousTier?: AccessTier;
141+
}
142+
143+
/**
144+
* ChangeFeedEvent AsyncOperationInfo
145+
*/
146+
export interface BlobOperationResult {
147+
/**
148+
* Destination access tier.
149+
*/
150+
destinationAccessTier?: AccessTier;
151+
/**
152+
* If the operation was async.
153+
*/
154+
isAsync: boolean;
155+
/**
156+
* Copy Id.
157+
*/
158+
copyId?: string;
159+
}
160+
161+
/**
162+
* Blob tags that were updated as part of the change feed event.
163+
*/
164+
export interface BlobTagsChange {
165+
/**
166+
* Previous Tags.
167+
*/
168+
oldTags: Record<string, string>;
169+
/**
170+
* New Tags.
171+
*/
172+
newTags: Record<string, string>;
173+
}
174+
71175
/**
72176
* Change feed Blob storage event data.
73177
*/
@@ -106,6 +210,13 @@ export interface BlobChangeFeedEventData {
106210
*/
107211
contentLength: number;
108212

213+
/**
214+
* The offset in bytes of a write operation taken at the point where the event-triggering application completed
215+
* writing to the file.
216+
* Appears only for events triggered on blob storage accounts that have a hierarchical namespace.
217+
*/
218+
contentOffset?: number;
219+
109220
/**
110221
* The type of blob.
111222
*/
@@ -117,9 +228,68 @@ export interface BlobChangeFeedEventData {
117228
*/
118229
url: string;
119230

231+
/**
232+
* The url of the file that will exist after the operation completes. For example, if a file is renamed,
233+
* the destinationUrl property contains the url of the new file name.
234+
* Appears only for events triggered on blob storage accounts that have a hierarchical namespace.
235+
*/
236+
destinationUrl?: string;
237+
238+
/**
239+
* The url of the file that exists prior to the operation. For example, if a file is renamed, the sourceUrl
240+
* contains the url of the original file name prior to the rename operation.
241+
* Appears only for events triggered on blob storage accounts that have a hierarchical namespace.
242+
*/
243+
sourceUrl?: string;
244+
245+
/**
246+
* True to perform the operation on all child directories; otherwise False.
247+
* Appears only for events triggered on blob storage accounts that have a hierarchical namespace.
248+
*/
249+
isRecursive?: boolean;
250+
120251
/**
121252
* An opaque string value representing the logical sequence of events for any particular blob name.
122253
* Users can use standard string comparison to understand the relative sequence of two events on the same blob name.
123254
*/
124255
sequencer: string;
256+
257+
/**
258+
* Previous info for the blob.
259+
*/
260+
previousInfo?: ChangeFeedEventPreviousInfo;
261+
262+
/**
263+
* Blob properties that were updated during this event.
264+
*/
265+
updatedBlobProperties?: UpdatedBlobProperties;
266+
267+
/**
268+
* Blob tags that were updated during this event.
269+
*/
270+
updatedBlobTags?: BlobTagsChange;
271+
272+
/**
273+
* The Snapshot associated with the event.
274+
*/
275+
snapshot?: string;
276+
277+
/**
278+
* Version of the blob.
279+
*/
280+
blobVersion?: string;
281+
282+
/**
283+
* Version of the container the blob is in.
284+
*/
285+
containerVersion?: string;
286+
287+
/**
288+
* Access Tier of the blob.
289+
*/
290+
blobAccessTier?: AccessTier;
291+
/**
292+
* AsyncOperationInfo
293+
*/
294+
longRunningOperationInfo?: BlobOperationResult;
125295
}

0 commit comments

Comments
 (0)