Skip to content

Commit

Permalink
[Cosmos] Make changeFeed and query options optional. Fix #6232 Fix #6277
Browse files Browse the repository at this point in the history
  • Loading branch information
southpolesteve authored Nov 21, 2019
1 parent f8c7cc4 commit bf3c15b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions sdk/cosmosdb/cosmos/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.4.3

- Makes changeFeed and query options optional. Fix #6232 Fix #6277 (#6273)

## 3.4.2

- Fixes bug where the query may throw a 410 error during a split operation. Instead, throw 503 (#6074)
Expand Down
10 changes: 5 additions & 5 deletions sdk/cosmosdb/cosmos/review/cosmos.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,26 +561,26 @@ export class ItemResponse<T extends ItemDefinition> extends ResourceResponse<T &
// @public
export class Items {
constructor(container: Container, clientContext: ClientContext);
changeFeed(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator<any>;
changeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
changeFeed<T>(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator<T>;
changeFeed<T>(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
changeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
// (undocumented)
readonly container: Container;
create<T extends ItemDefinition = any>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>;
query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
query<T>(query: string | SqlQuerySpec, options: FeedOptions): QueryIterator<T>;
query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
readAll(options?: FeedOptions): QueryIterator<ItemDefinition>;
readAll<T extends ItemDefinition>(options?: FeedOptions): QueryIterator<T>;
// Warning: (ae-forgotten-export) The symbol "ChangeFeedOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ChangeFeedIterator" needs to be exported by the entry point index.d.ts
//
// @deprecated
readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator<any>;
readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
// @deprecated
readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
// @deprecated
readChangeFeed<T>(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator<T>;
readChangeFeed<T>(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
// @deprecated
readChangeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
upsert(body: any, options?: RequestOptions): Promise<ItemResponse<ItemDefinition>>;
Expand Down
12 changes: 6 additions & 6 deletions sdk/cosmosdb/cosmos/src/client/Item/Items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Items {
* const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll();
* ```
*/
public query<T>(query: string | SqlQuerySpec, options: FeedOptions): QueryIterator<T>;
public query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
public query<T>(query: string | SqlQuerySpec, options: FeedOptions = {}): QueryIterator<T> {
const path = getPathFromLink(this.container.url, ResourceType.item);
const id = getIdFromLink(this.container.url);
Expand Down Expand Up @@ -115,7 +115,7 @@ export class Items {
*/
public readChangeFeed(
partitionKey: string | number | boolean,
changeFeedOptions: ChangeFeedOptions
changeFeedOptions?: ChangeFeedOptions
): ChangeFeedIterator<any>;
/**
* Create a `ChangeFeedIterator` to iterate over pages of changes
Expand All @@ -133,7 +133,7 @@ export class Items {
*/
public readChangeFeed<T>(
partitionKey: string | number | boolean,
changeFeedOptions: ChangeFeedOptions
changeFeedOptions?: ChangeFeedOptions
): ChangeFeedIterator<T>;
/**
* Create a `ChangeFeedIterator` to iterate over pages of changes
Expand Down Expand Up @@ -169,7 +169,7 @@ export class Items {
*/
public changeFeed(
partitionKey: string | number | boolean,
changeFeedOptions: ChangeFeedOptions
changeFeedOptions?: ChangeFeedOptions
): ChangeFeedIterator<any>;
/**
* Create a `ChangeFeedIterator` to iterate over pages of changes
Expand All @@ -185,7 +185,7 @@ export class Items {
*/
public changeFeed<T>(
partitionKey: string | number | boolean,
changeFeedOptions: ChangeFeedOptions
changeFeedOptions?: ChangeFeedOptions
): ChangeFeedIterator<T>;
/**
* Create a `ChangeFeedIterator` to iterate over pages of changes
Expand All @@ -209,7 +209,7 @@ export class Items {
}

if (!changeFeedOptions) {
throw new Error("changeFeedOptions must be a valid object");
changeFeedOptions = {};
}

const path = getPathFromLink(this.container.url, ResourceType.item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe("Change Feed Iterator", function() {
});

it("should fetch new items only", async function() {
const iterator = container.items.changeFeed("0", {});
const iterator = container.items.changeFeed("0");

const { result: items, headers } = await iterator.fetchNext();
assert(headers.etag, "change feed response should have etag header");
Expand Down

0 comments on commit bf3c15b

Please sign in to comment.