Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
27efba0
feat: working on refactoring registerinternalplugin
May 15, 2025
f0c343d
Merge branch 'next' of github.com:webex/webex-js-sdk into next
May 20, 2025
fd40b71
fix: services v2 init
May 20, 2025
1a11594
Merge branch 'next' into deregister-plugin
johnsoter13 May 20, 2025
beaa887
fix: removed other code
May 20, 2025
4ac71eb
Merge branch 'deregister-plugin' of github.com:johnsoter13/webex-js-s…
May 20, 2025
759a26c
fix: remove more references
May 21, 2025
da174b3
fix: add test file
May 22, 2025
ea07ef9
fix: working on fixture
May 22, 2025
690f919
fix: updated some initial values
May 22, 2025
bc47e42
feat: working on service catalog
May 22, 2025
fabd01e
chore: working on service catalog
May 23, 2025
2838952
fix: file structure
May 23, 2025
84c3d8a
fix: updated imports
May 23, 2025
23ae908
fix: merge conflicts
May 23, 2025
d09cd8c
fix: tests commented and unnecessary files deleted
May 23, 2025
fc09765
feat: updated formathostmap
May 27, 2025
a5cc16b
chore: complete service reword
May 27, 2025
97ff212
chore: working on servicedetails tests
May 28, 2025
97a5a4a
feat: tests for service details
May 29, 2025
6f29f4c
fix: updated with next, removed some unused files
May 29, 2025
3a9e253
fix: updated some imports
May 29, 2025
e026b39
fix: removed merge comments
May 29, 2025
b6cb126
fix: updated comments
May 30, 2025
4d56bd4
fix: updated structures a bit
May 30, 2025
ecc9074
fix: updated comments
May 30, 2025
35cd006
fix: merge conflicts
May 30, 2025
dad42b2
fix: updates before integration tests
May 30, 2025
4504e34
feat: updated integration tests
May 30, 2025
1e05a51
feat: tests
Jun 2, 2025
f5c0f7e
Merge branch 'next' into host-catalog-v2
johnsoter13 Jun 2, 2025
c21f252
fix: removed commented out test files
Jun 2, 2025
465ec4c
Merge branch 'host-catalog-v2' of github.com:johnsoter13/webex-js-sdk…
Jun 2, 2025
cc67551
fix: updated with upstream
Jun 2, 2025
c050fe0
feat: tests and renaming
Jun 3, 2025
05177a8
fix: updated file name and references
Jun 3, 2025
281b094
chore: working on integration tests for markfailedurl
Jun 3, 2025
0b5100d
fix: merge with next
Jun 3, 2025
06f4245
fix: rebase with next
Jun 3, 2025
ebd0762
feat: service-catalog before tests
Jun 3, 2025
4a527b5
Merge branch 'next' into service-url
robstax Jun 4, 2025
fc6e289
fix: integration tests
Jun 4, 2025
bcac005
fix: ts refactor
Jun 4, 2025
bac7c5a
Merge branch 'next' into service-url
johnsoter13 Jun 4, 2025
f21a252
feat: unit tests complete
Jun 4, 2025
52f0df1
Merge branch 'next' into service-catalog-v2
johnsoter13 Jun 4, 2025
55973de
feat: services done before tests
Jun 5, 2025
6246433
feat: initial unit tests implemented
Jun 5, 2025
dfa8661
chore: working on integration tests
Jun 5, 2025
54ae1c1
Merge branch 'next' into service-catalog-v2
johnsoter13 Jun 6, 2025
eafaa33
fix: merge conflicts
Jun 9, 2025
1d0e119
Merge branch 'service-catalog-v2' of github.com:johnsoter13/webex-js-…
Jun 9, 2025
4c8e5fa
fix: review comments
Jun 9, 2025
a785ea8
fix: updated, before tests
Jun 9, 2025
dc3a7c0
fix: integration test
Jun 9, 2025
c33df88
fix: testing
Jun 9, 2025
2f54211
fix: working on integration tests
Jun 9, 2025
e690590
feat: tests
Jun 10, 2025
869afd5
fix: integration tests
Jun 10, 2025
f8cff22
fix: updated test
Jun 10, 2025
422729f
fix: updated tests
Jun 10, 2025
530f05f
fix: revert file
Jun 10, 2025
0036e6f
Merge branch 'next' into service-catalog-v2
johnsoter13 Jun 10, 2025
a0b23ea
fix: wrong function called
Jun 10, 2025
250ef82
Merge branch 'service-catalog-v2' of github.com:johnsoter13/webex-js-…
Jun 10, 2025
925b3d3
Merge branch 'service-catalog-v2' into services-v2
Jun 11, 2025
a943a21
fix: more integration tests
Jun 11, 2025
a090219
fix: working on tests
Jun 11, 2025
857caf5
feat: tests finished
Jun 16, 2025
3cd534d
fix: uncommented tests
Jun 16, 2025
d7469d6
Merge branch 'next' into services-v2
johnsoter13 Jun 16, 2025
1fbcd14
Merge branch 'next' of github.com:webex/webex-js-sdk into services-v2
Jun 16, 2025
7eecdc1
Merge branch 'services-v2' of github.com:johnsoter13/webex-js-sdk int…
Jun 16, 2025
d54046b
fix: uncommented another test
Jun 16, 2025
b798b7c
fix: revert tests to next
Jun 16, 2025
52145fe
fix: removed duplicate interceptors
Jun 16, 2025
433ca69
fix: testing pipeline
Jun 17, 2025
179a0d4
fix: added back service-catalog test
Jun 17, 2025
f67ca67
fix: tests
Jun 17, 2025
247c9ac
Merge branch 'next' of github.com:webex/webex-js-sdk into services-v2
Jun 17, 2025
021c83f
fix: test
Jun 17, 2025
7ca9938
Merge branch 'services-v2' of github.com:johnsoter13/webex-js-sdk int…
Jun 17, 2025
d731eef
fix: pr comments
Jun 18, 2025
c431be5
fix: more pr comments
Jun 18, 2025
e1d9e44
Merge branch 'next' into services-v2
johnsoter13 Jun 18, 2025
33b1178
Merge branch 'next' into services-v2
johnsoter13 Jun 23, 2025
5be1a1b
Merge branch 'next' of github.com:webex/webex-js-sdk into services-cl…
Jun 23, 2025
671adad
fix: refactoring shared files
Jun 24, 2025
576763e
Merge branch 'services-v2' into services-cleanup
Jun 24, 2025
bc46c94
feat: files refactored
Jun 24, 2025
36ec472
fix: types and pr comments
Jun 24, 2025
45a019f
Merge branch 'next' into services-v2
johnsoter13 Jun 25, 2025
3f8597d
Merge branch 'next' into services-v2
johnsoter13 Jun 25, 2025
668d848
fix: updated a test value
Jun 25, 2025
1086c00
Merge branch 'services-v2' of github.com:johnsoter13/webex-js-sdk int…
Jun 25, 2025
be4b6c0
fix: merge with master
Jun 26, 2025
f8c5d3b
fix: merge conflicts and pr comments
Jun 26, 2025
fa8f43c
fix: updated imports
Jun 26, 2025
ff738e0
Merge branch 'next' into services-cleanup
johnsoter13 Jul 7, 2025
11e7aa5
feat: added refetch logic based on cache mercury event
Jul 11, 2025
4fe40e5
Merge branch 'next' into mercury-part-2
johnsoter13 Jul 14, 2025
6b5ddca
Merge branch 'next' into mercury-part-2
johnsoter13 Jul 21, 2025
f476be6
Merge branch 'next' into mercury-part-2
johnsoter13 Jul 22, 2025
f13f309
fix: test
Jul 22, 2025
b382a4b
Merge branch 'mercury-part-2' of github.com:johnsoter13/webex-js-sdk …
Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/@webex/internal-plugin-mercury/src/mercury.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ const Mercury = WebexPlugin.extend({
this.webex.internal.feature.updateFeature(envelope.data.featureToggle);
}
});

// subject to change
this.on('event:u2c.cache-invalidation', (envelope) => {
if (
typeof this.webex.internal.services?.invalidateCache === 'function' &&
envelope &&
envelope.data
) {
this.webex.internal.services.invalidateCache(envelope.data?.timestamp);
}
});
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('plugin-mercury', () => {
webex.internal.services = {
convertUrlToPriorityHostUrl: sinon.stub().returns(Promise.resolve('ws://example-2.com')),
markFailedUrl: sinon.stub().returns(Promise.resolve()),
invalidateCache: sinon.stub(),
};
webex.internal.metrics.submitClientMetrics = sinon.stub();
webex.internal.newMetrics.callDiagnosticMetrics.setMercuryConnectedStatus = sinon.stub();
Expand Down Expand Up @@ -162,6 +163,11 @@ describe('plugin-mercury', () => {
},
},
};
const cacheInvalidationEventEnvelope = {
data: {
timestamp: '1',
},
};

assert.isFalse(mercury.connected, 'Mercury is not connected');
assert.isTrue(mercury.connecting, 'Mercury is connecting');
Expand All @@ -176,18 +182,25 @@ describe('plugin-mercury', () => {
webex.internal.feature.updateFeature,
envelope.data.featureToggle
);
mercury._emit('event:u2c.cache-invalidation', cacheInvalidationEventEnvelope);
assert.calledOnceWithExactly(
webex.internal.services.invalidateCache,
cacheInvalidationEventEnvelope.data.timestamp
);
sinon.restore();
});
});

it('connects to Mercury but does not call updateFeature', () => {
it('connects to Mercury but does not call updateFeature or invalidateCache', () => {
webex.internal.feature.updateFeature = sinon.stub();
const promise = mercury.connect();
const envelope = {};

return promise.then(() => {
mercury._emit('event:featureToggle_update', envelope);
mercury._emit('event:u2c.cache-invalidation', envelope);
assert.notCalled(webex.internal.feature.updateFeature);
assert.notCalled(webex.internal.services.invalidateCache);
sinon.restore();
});
});
Expand Down
30 changes: 29 additions & 1 deletion packages/@webex/webex-core/src/lib/services-v2/services-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const Services = WebexPlugin.extend({

_services: [],

_timestamp: 0,

/**
* @private
* Get the current catalog based on the assocaited
Expand Down Expand Up @@ -122,6 +124,15 @@ const Services = WebexPlugin.extend({
this._services = unionBy(services, this._services, 'id');
},

/**
* saves the timestamp of the last catalog update
* @param {number} timestamp
* @returns {void}
*/
_updateTimestamp(timestamp: number): void {
this._timestamp = timestamp;
},

/**
* Update a list of `serviceUrls` to the most current
* catalog via the defined `discoveryUrl` then returns the current
Expand Down Expand Up @@ -698,10 +709,11 @@ const Services = WebexPlugin.extend({
* catalog endpoint.
* @returns {Array<Service>}
*/
_formatReceivedHostmap({services, activeServices}) {
_formatReceivedHostmap({services, activeServices, timestamp}) {
const formattedHostmap = services.map((service) => this._formatHostMapEntry(service));
this._updateActiveServices(activeServices);
this._updateServices(services);
this._updateTimestamp(timestamp);

return formattedHostmap;
},
Expand Down Expand Up @@ -821,6 +833,22 @@ const Services = WebexPlugin.extend({
return newUrl.href;
},

/**
* @param {number} timestamp - the timestamp to compare against
* @returns {Promise<void>}
*/
invalidateCache(timestamp: number): Promise<void> {
if (timestamp > this._timestamp) {
this.logger.info('services: invalidating cache, timestamp is newer than current timestamp');

return this.updateServices({forceRefresh: true});
}

this.logger.info('services: not invalidating cache, timestamp is older than current timestamp');

return Promise.resolve();
},

/**
* @private
* Simplified method wrapper for sending a request to get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import WebexCore, {
import testUsers from '@webex/test-helper-test-users';
import uuid from 'uuid';
import sinon from 'sinon';
import {formattedServiceHostmapEntryConv} from '../../../fixtures/host-catalog-v2';
import {
formattedServiceHostmapEntryConv,
serviceHostmapV2,
} from '../../../fixtures/host-catalog-v2';

// /* eslint-disable no-underscore-dangle */
describe('webex-core', () => {
Expand Down Expand Up @@ -494,6 +497,28 @@ describe('webex-core', () => {
});
});

describe('#invalidateCache', () => {
let requestStub;

beforeEach(() => {
services._formatReceivedHostmap(serviceHostmapV2);
});

afterEach(() => {
requestStub.restore();
});

it('fetches new catalog when timestamp is newer than current timestamp', () => {
requestStub = sinon
.stub(webex.internal.newMetrics.callDiagnosticLatencies, 'measureLatency')
.returns(Promise.resolve());

services.invalidateCache(Date.now());

assert.calledOnce(requestStub);
});
});

describe('#updateServices()', () => {
it('returns a Promise that and resolves on success', (done) => {
const servicesPromise = services.updateServices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,32 @@ describe('webex-core', () => {
});
});

describe('#invalidateCache', () => {
let serviceHostmap;
let formattedHM;

beforeEach(() => {
serviceHostmap = serviceHostmapV2;
formattedHM = services._formatReceivedHostmap(serviceHostmap);
});

it('makes request to fetch when timestamp is newer', async () => {
services.updateServices = sinon.stub();

await services.invalidateCache(Date.now());

assert.calledWith(services.updateServices, {forceRefresh: true});
});

it('does not make request when timestamp is older', async () => {
services.updateServices = sinon.stub();

await services.invalidateCache(0);

assert.notCalled(services.updateServices);
});
});

describe('#updateCatalog', () => {
it('updates the catalog', async () => {
const serviceGroup = 'postauth';
Expand Down
Loading