From c11f691b964b0126e9059d40f29504c4661776ba Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 13:15:27 -0700 Subject: [PATCH 01/10] typo --- sdk/appconfiguration/app-configuration/CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/app-configuration/CHANGELOG.md b/sdk/appconfiguration/app-configuration/CHANGELOG.md index 113c9a035ed5..870cf2b693c6 100644 --- a/sdk/appconfiguration/app-configuration/CHANGELOG.md +++ b/sdk/appconfiguration/app-configuration/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0-beta.1 (Unreleased) + +- Fix issues with `select`ing fields to be returned from `listConfigurationSettings`, `listConfigurationRevisions` + and `getConfigurationSetting` where `last_modified` and `content_type` could not properly be passed in. + [PR #13258](https://github.com/Azure/azure-sdk-for-js/pull/13258) + ## 1.1.1 (Unreleased) - Fix issues with `select`ing fields to be returned from `listConfigurationSettings`, `listConfigurationRevisions` @@ -13,7 +19,7 @@ ## 1.0.1 (2020-02-19) - The underlying filter behavior has changed for `listConfigurationSettings` and `listRevisions`. - Inline documentation has been revised to accomodate it. + Inline documentation has been revised to accommodate it. ## 1.0.0 (2020-01-06) From d91c8bef8ed20a48e8832e4c04bae13f82f1cd80 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 13:15:48 -0700 Subject: [PATCH 02/10] copy syncToken code from Richard's branch --- .../app-configuration/src/appConfigurationClient.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts b/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts index 3cf42a4fa36e..f18911e15889 100644 --- a/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts +++ b/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts @@ -115,6 +115,7 @@ export interface InternalAppConfigurationClientOptions extends AppConfigurationC */ export class AppConfigurationClient { private client: AppConfiguration; + private _syncTokens: SyncTokens; // (for tests) private _trace = traceFromTracingHelpers; @@ -164,13 +165,13 @@ export class AppConfigurationClient { } } - const syncTokens = appConfigOptions.syncTokens || new SyncTokens(); + this._syncTokens = appConfigOptions.syncTokens || new SyncTokens(); this.client = new AppConfiguration( appConfigCredential, appConfigEndpoint, apiVersion, - getGeneratedClientOptions(appConfigEndpoint, syncTokens, appConfigOptions) + getGeneratedClientOptions(appConfigEndpoint, this._syncTokens, appConfigOptions) ); } @@ -496,8 +497,11 @@ export class AppConfigurationClient { } }); } -} + updateSyncToken(syncToken: string): void { + this._syncTokens.addSyncTokenFromHeaderValue(syncToken); + } +} /** * Gets the options for the generated AppConfigurationClient * @internal From c601bde6268d57c1cce954751c7135d06b048125 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 13:16:31 -0700 Subject: [PATCH 03/10] unit test for update sync token --- .../test/internal/http.spec.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts b/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts index 20cb90ff13b4..48fd528118cf 100644 --- a/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts +++ b/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts @@ -291,6 +291,38 @@ describe("http request related tests", function() { assert.equal(syncTokens.getSyncTokenHeaderValue(), "clearReadOnly=value"); }); }); + + describe("syncToken", async () => { + it("update sync token", async () => { + const syncTokens = new SyncTokens(); + syncTokens.addSyncTokenFromHeaderValue("a=value;sn=0"); + const client = new AppConfigurationClient( + "Endpoint=https://endpoint.azconfig.io;Id=abc;Secret=123", + { syncTokens } as InternalAppConfigurationClientOptions + ); + assert.equal( + client["_syncTokens"]["_currentSyncTokens"].size, + 1, + "Unexpected number of syncTokens before the `update` call" + ); + client.updateSyncToken("b=value;sn=3"); + assert.equal( + client["_syncTokens"]["_currentSyncTokens"].size, + 2, + "Unexpected number of syncTokens after the `update` call" + ); + assert.deepEqual( + client["_syncTokens"]["_currentSyncTokens"].get("a"), + { id: "a", value: "value", sequenceNumber: 0 }, + "Unexpected object present for key `a`" + ); + assert.deepEqual( + client["_syncTokens"]["_currentSyncTokens"].get("b"), + { id: "b", value: "value", sequenceNumber: 3 }, + "Unexpected object present for key `b`" + ); + }); + }); }); function splitAndSort(syncTokens: string | undefined): string { From f81f85451642faa0181d0b99404492c76b9a8d63 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 13:16:51 -0700 Subject: [PATCH 04/10] TODO: A future live test --- .../test/public/index.spec.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sdk/appconfiguration/app-configuration/test/public/index.spec.ts b/sdk/appconfiguration/app-configuration/test/public/index.spec.ts index b5981be2a6a1..b19692e415e6 100644 --- a/sdk/appconfiguration/app-configuration/test/public/index.spec.ts +++ b/sdk/appconfiguration/app-configuration/test/public/index.spec.ts @@ -1139,4 +1139,37 @@ describe("AppConfigurationClient", () => { }); }); }); + + describe("syncToken", async () => { + it("update sync token with eventgrid example", async () => { + // Supposed to be a live test + // TODO: + // - Import eventgrid + // - get sync token from eventgrid event + // - call updateSyncToken + // - call getConfigurationSetting + // - assertion/check the retrieved setting + + // get sync token from EventGrid event (example event shown, based on .net sample) + const eventGridEvent = { + key: "key for setting", + label: "label for setting", + syncToken: "opaque sync token" + }; + + // user treats token as an opaque value (note - this _does_ mutate the appconfigclient) + // however, this mutations happens regardless since the system can and does return + // sync token headers during normal operation. + client.updateSyncToken(eventGridEvent.syncToken); + + // and now retrieving the value should be consistent with what happened + // in EventGrid. + const retrievedSetting = await client.getConfigurationSetting({ + key: eventGridEvent.key, + label: eventGridEvent.label + }); + + console.log(retrievedSetting); + }); + }); }); From 328f19e3fdde44e618f8faddb475520f66cd0bf4 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 13:23:25 -0700 Subject: [PATCH 05/10] changelog --- sdk/appconfiguration/app-configuration/CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/app-configuration/CHANGELOG.md b/sdk/appconfiguration/app-configuration/CHANGELOG.md index 870cf2b693c6..6903604b32ac 100644 --- a/sdk/appconfiguration/app-configuration/CHANGELOG.md +++ b/sdk/appconfiguration/app-configuration/CHANGELOG.md @@ -2,9 +2,8 @@ ## 1.2.0-beta.1 (Unreleased) -- Fix issues with `select`ing fields to be returned from `listConfigurationSettings`, `listConfigurationRevisions` - and `getConfigurationSetting` where `last_modified` and `content_type` could not properly be passed in. - [PR #13258](https://github.com/Azure/azure-sdk-for-js/pull/13258) +- Added `updateSyncToken` method to `AppConfigurationClient` to be able to provide external synchronization tokens. + [PR #14507](https://github.com/Azure/azure-sdk-for-js/pull/14507) ## 1.1.1 (Unreleased) From 5fd38ceeea69d489cf96a477a39d7f4b03c16028 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 14:23:59 -0700 Subject: [PATCH 06/10] remove potential live test --- .../test/public/index.spec.ts | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/sdk/appconfiguration/app-configuration/test/public/index.spec.ts b/sdk/appconfiguration/app-configuration/test/public/index.spec.ts index b19692e415e6..b5981be2a6a1 100644 --- a/sdk/appconfiguration/app-configuration/test/public/index.spec.ts +++ b/sdk/appconfiguration/app-configuration/test/public/index.spec.ts @@ -1139,37 +1139,4 @@ describe("AppConfigurationClient", () => { }); }); }); - - describe("syncToken", async () => { - it("update sync token with eventgrid example", async () => { - // Supposed to be a live test - // TODO: - // - Import eventgrid - // - get sync token from eventgrid event - // - call updateSyncToken - // - call getConfigurationSetting - // - assertion/check the retrieved setting - - // get sync token from EventGrid event (example event shown, based on .net sample) - const eventGridEvent = { - key: "key for setting", - label: "label for setting", - syncToken: "opaque sync token" - }; - - // user treats token as an opaque value (note - this _does_ mutate the appconfigclient) - // however, this mutations happens regardless since the system can and does return - // sync token headers during normal operation. - client.updateSyncToken(eventGridEvent.syncToken); - - // and now retrieving the value should be consistent with what happened - // in EventGrid. - const retrievedSetting = await client.getConfigurationSetting({ - key: eventGridEvent.key, - label: eventGridEvent.label - }); - - console.log(retrievedSetting); - }); - }); }); From ceafaf1bbc5fa153ff67ac280d8842c7a0bb5e50 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 14:26:57 -0700 Subject: [PATCH 07/10] api report --- .../app-configuration/review/app-configuration.api.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/app-configuration/review/app-configuration.api.md b/sdk/appconfiguration/app-configuration/review/app-configuration.api.md index d4e7d36e40e6..e0ffc5fca784 100644 --- a/sdk/appconfiguration/app-configuration/review/app-configuration.api.md +++ b/sdk/appconfiguration/app-configuration/review/app-configuration.api.md @@ -33,7 +33,9 @@ export class AppConfigurationClient { listRevisions(options?: ListRevisionsOptions): PagedAsyncIterableIterator; setConfigurationSetting(configurationSetting: SetConfigurationSettingParam, options?: SetConfigurationSettingOptions): Promise; setReadOnly(id: ConfigurationSettingId, readOnly: boolean, options?: SetReadOnlyOptions): Promise; - } + // (undocumented) + updateSyncToken(syncToken: string): void; +} // @public export interface AppConfigurationClientOptions { From 15a910e413d6f902aac6900782ecff2be3d76c7e Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 14:28:55 -0700 Subject: [PATCH 08/10] client["_syncTokens"] -> syncTokens --- .../app-configuration/test/internal/http.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts b/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts index 48fd528118cf..1340d1c3d9c5 100644 --- a/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts +++ b/sdk/appconfiguration/app-configuration/test/internal/http.spec.ts @@ -301,23 +301,23 @@ describe("http request related tests", function() { { syncTokens } as InternalAppConfigurationClientOptions ); assert.equal( - client["_syncTokens"]["_currentSyncTokens"].size, + syncTokens["_currentSyncTokens"].size, 1, "Unexpected number of syncTokens before the `update` call" ); client.updateSyncToken("b=value;sn=3"); assert.equal( - client["_syncTokens"]["_currentSyncTokens"].size, + syncTokens["_currentSyncTokens"].size, 2, "Unexpected number of syncTokens after the `update` call" ); assert.deepEqual( - client["_syncTokens"]["_currentSyncTokens"].get("a"), + syncTokens["_currentSyncTokens"].get("a"), { id: "a", value: "value", sequenceNumber: 0 }, "Unexpected object present for key `a`" ); assert.deepEqual( - client["_syncTokens"]["_currentSyncTokens"].get("b"), + syncTokens["_currentSyncTokens"].get("b"), { id: "b", value: "value", sequenceNumber: 3 }, "Unexpected object present for key `b`" ); From d10d9ec1ee1c8bf3725decd1e5e966c715dda243 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 14:34:33 -0700 Subject: [PATCH 09/10] JSDOCs --- .../app-configuration/src/appConfigurationClient.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts b/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts index f18911e15889..b66392178f95 100644 --- a/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts +++ b/sdk/appconfiguration/app-configuration/src/appConfigurationClient.ts @@ -498,6 +498,11 @@ export class AppConfigurationClient { }); } + /** + * Adds an external synchronization token to ensure service requests receive up-to-date values. + * + * @param syncToken The synchronization token value. + */ updateSyncToken(syncToken: string): void { this._syncTokens.addSyncTokenFromHeaderValue(syncToken); } From 83c5bbc8d099c9bfc8eb43d7fc3205a7e9cbb9a3 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 25 Mar 2021 14:34:59 -0700 Subject: [PATCH 10/10] api report --- .../app-configuration/review/app-configuration.api.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/appconfiguration/app-configuration/review/app-configuration.api.md b/sdk/appconfiguration/app-configuration/review/app-configuration.api.md index e0ffc5fca784..8ff2c801fee2 100644 --- a/sdk/appconfiguration/app-configuration/review/app-configuration.api.md +++ b/sdk/appconfiguration/app-configuration/review/app-configuration.api.md @@ -33,7 +33,6 @@ export class AppConfigurationClient { listRevisions(options?: ListRevisionsOptions): PagedAsyncIterableIterator; setConfigurationSetting(configurationSetting: SetConfigurationSettingParam, options?: SetConfigurationSettingOptions): Promise; setReadOnly(id: ConfigurationSettingId, readOnly: boolean, options?: SetReadOnlyOptions): Promise; - // (undocumented) updateSyncToken(syncToken: string): void; }