From 8613e6aa227a05948564031fd823381da63fdfdd Mon Sep 17 00:00:00 2001 From: anitarua Date: Wed, 28 Aug 2024 16:43:38 -0700 Subject: [PATCH 1/4] chore: update readme and examples for default credential provider and new topics callbacks --- README.template.md | 10 +++++++ examples/nodejs/cache/basic.ts | 2 -- examples/nodejs/cache/dictionary.ts | 6 ---- .../doc-example-files/cheat-sheet-main.ts | 3 +- examples/nodejs/cache/leaderboard.ts | 3 -- examples/nodejs/cache/package-lock.json | 16 +++++----- examples/nodejs/cache/package.json | 2 +- examples/nodejs/cache/readme.ts | 3 +- examples/nodejs/storage/basic.ts | 1 - .../doc-example-files/cheat-sheet-main.ts | 3 +- examples/nodejs/storage/package-lock.json | 16 +++++----- examples/nodejs/storage/package.json | 2 +- .../doc-example-files/cheat-sheet-main.ts | 1 - examples/nodejs/topics/package-lock.json | 22 +++++++------- examples/nodejs/topics/package.json | 2 +- examples/nodejs/topics/topic-publish.ts | 1 - examples/nodejs/topics/topic-subscribe.ts | 12 ++++++++ examples/web/cache/basic.ts | 2 -- examples/web/cache/dictionary.ts | 6 ---- examples/web/cache/package-lock.json | 30 +++++++++---------- examples/web/cache/package.json | 2 +- 21 files changed, 71 insertions(+), 74 deletions(-) diff --git a/README.template.md b/README.template.md index d5a588815..dbbc7daa1 100644 --- a/README.template.md +++ b/README.template.md @@ -16,6 +16,16 @@ is best suited for a particular environment: {% include "./examples/nodejs/cache/readme.ts" %} ``` +You'll need a Momento API key to authenticate with Momento. You can get one from the [Momento Console](https://console.gomomento.com/caches). + +By default, Momento clients use a `CredentialProvider` that expects an environment variable named `MOMENTO_API_KEY` + +```bash +export MOMENTO_API_KEY= +``` + +Note: it is best practice to put the API key into something like AWS Secret Manager or GCP Secret Manager instead of an environment variable for enhanced security. See [these docs](https://docs.momentohq.com/cache/develop#instantiating-credential-providers-using-momento-api-keys) for more information about instantiating your own `CredentialProvider`. + ## Getting Started and Documentation Documentation is available on the [Momento Docs website](https://docs.momentohq.com). For information specific to a diff --git a/examples/nodejs/cache/basic.ts b/examples/nodejs/cache/basic.ts index 3f2760bf4..e0c8800ec 100644 --- a/examples/nodejs/cache/basic.ts +++ b/examples/nodejs/cache/basic.ts @@ -1,7 +1,6 @@ import { CacheClient, Configurations, - CredentialProvider, CreateCacheResponse, CacheSetResponse, CacheGetResponse, @@ -10,7 +9,6 @@ import { async function main() { const momento = await CacheClient.create({ configuration: Configurations.Laptop.v1(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), defaultTtlSeconds: 60, }); diff --git a/examples/nodejs/cache/dictionary.ts b/examples/nodejs/cache/dictionary.ts index 864524201..9c0ce5004 100644 --- a/examples/nodejs/cache/dictionary.ts +++ b/examples/nodejs/cache/dictionary.ts @@ -9,17 +9,12 @@ import { Configurations, CreateCacheResponse, DefaultMomentoLoggerFactory, - EnvMomentoTokenProvider, MomentoLoggerFactory, } from '@gomomento/sdk'; const cacheName = 'cache'; const dictionaryName = 'dictionary'; -const credentialsProvider = new EnvMomentoTokenProvider({ - environmentVariableName: 'MOMENTO_API_KEY', -}); - const loggerFactory: MomentoLoggerFactory = new DefaultMomentoLoggerFactory(); const defaultTtl = 60; @@ -28,7 +23,6 @@ let momento: CacheClient; const main = async () => { momento = await CacheClient.create({ configuration: Configurations.Laptop.v1(loggerFactory), - credentialProvider: credentialsProvider, defaultTtlSeconds: defaultTtl, }); diff --git a/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts b/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts index b9a2f8471..2852c23ad 100644 --- a/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts +++ b/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts @@ -1,10 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import {CacheClient, Configurations, CredentialProvider} from '@gomomento/sdk'; +import {CacheClient, Configurations} from '@gomomento/sdk'; async function main() { const cacheClient = await CacheClient.create({ configuration: Configurations.Laptop.v1(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), defaultTtlSeconds: 60, }); } diff --git a/examples/nodejs/cache/leaderboard.ts b/examples/nodejs/cache/leaderboard.ts index cea6a039b..f1d152dd1 100644 --- a/examples/nodejs/cache/leaderboard.ts +++ b/examples/nodejs/cache/leaderboard.ts @@ -1,7 +1,6 @@ import { PreviewLeaderboardClient, LeaderboardConfigurations, - CredentialProvider, CacheClient, Configurations, LeaderboardOrder, @@ -21,7 +20,6 @@ async function main() { const loggerFactory = new DefaultMomentoLoggerFactory(DefaultMomentoLoggerLevel.TRACE); const cacheClient = await CacheClient.create({ configuration: Configurations.Laptop.v1(loggerFactory), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), defaultTtlSeconds: 60, }); @@ -39,7 +37,6 @@ async function main() { const client = new PreviewLeaderboardClient({ configuration: LeaderboardConfigurations.Laptop.v1(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), }); // Create a leaderboard with given cache and leaderboard names diff --git a/examples/nodejs/cache/package-lock.json b/examples/nodejs/cache/package-lock.json index bbf6cbe63..1f292ff42 100644 --- a/examples/nodejs/cache/package-lock.json +++ b/examples/nodejs/cache/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@gomomento/sdk": "^1.97.0" + "@gomomento/sdk": "^1.98.1" }, "devDependencies": { "@types/node": "16.11.4", @@ -62,12 +62,12 @@ } }, "node_modules/@gomomento/sdk": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.97.0.tgz", - "integrity": "sha512-PuBYIzIYilwQmpKLcdrIhyyktzTLHxh7VJn0K443nDPQeQ/a425xUG5YTl5ex7yK9DsFhi/ZZ0qOYLv3P2z68g==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.98.1.tgz", + "integrity": "sha512-++bcF5E65IATkmt0mQmilRz5eJXrvr9YPBg12F1JNxfL9mXXPmNfD3AKJQalKGX8tlmCrEwQ5MSJVkIgw/KNOQ==", "dependencies": { "@gomomento/generated-types": "0.113.0", - "@gomomento/sdk-core": "1.97.0", + "@gomomento/sdk-core": "1.98.1", "@grpc/grpc-js": "1.10.9", "@types/google-protobuf": "3.15.10", "google-protobuf": "3.21.2", @@ -78,9 +78,9 @@ } }, "node_modules/@gomomento/sdk-core": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.97.0.tgz", - "integrity": "sha512-on/peptoTRjmzAcltLrmQXzndtVfygi0xWUARcuJbOlMIEcoKvhr25w+YBXtEBHhq3rjefpkIXtFKqJWz2mfPg==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.98.1.tgz", + "integrity": "sha512-QHQRmpIeNwuNBJ9ugb6GdcoBw3UDM+id0FgAzLvzu9cI/+y7lgXl9kerWjWMEULAWgpL6bcZrfrQTlNuuMOJEw==", "dependencies": { "buffer": "6.0.3", "jwt-decode": "3.1.2" diff --git a/examples/nodejs/cache/package.json b/examples/nodejs/cache/package.json index 1de3f8a76..e16f955fb 100644 --- a/examples/nodejs/cache/package.json +++ b/examples/nodejs/cache/package.json @@ -33,7 +33,7 @@ "typescript": "4.9.5" }, "dependencies": { - "@gomomento/sdk": "^1.97.0" + "@gomomento/sdk": "^1.98.1" }, "engines": { "node": ">=10.4.0" diff --git a/examples/nodejs/cache/readme.ts b/examples/nodejs/cache/readme.ts index 7f2d62f3b..1f639b014 100644 --- a/examples/nodejs/cache/readme.ts +++ b/examples/nodejs/cache/readme.ts @@ -1,9 +1,8 @@ -import {CacheClient, CacheGetResponse, Configurations, CredentialProvider} from '@gomomento/sdk'; +import {CacheClient, CacheGetResponse, Configurations} from '@gomomento/sdk'; async function main() { const cacheClient = await CacheClient.create({ configuration: Configurations.Laptop.v1(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), defaultTtlSeconds: 60, }); diff --git a/examples/nodejs/storage/basic.ts b/examples/nodejs/storage/basic.ts index cf81d325f..4fa27f2dc 100644 --- a/examples/nodejs/storage/basic.ts +++ b/examples/nodejs/storage/basic.ts @@ -10,7 +10,6 @@ import { async function main() { const storageClient = new PreviewStorageClient({ configuration: StorageConfigurations.Laptop.latest(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), }); const storeName = 'my-store'; diff --git a/examples/nodejs/storage/doc-example-files/cheat-sheet-main.ts b/examples/nodejs/storage/doc-example-files/cheat-sheet-main.ts index f6ecb917a..c2f646fd7 100644 --- a/examples/nodejs/storage/doc-example-files/cheat-sheet-main.ts +++ b/examples/nodejs/storage/doc-example-files/cheat-sheet-main.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import {CredentialProvider, PreviewStorageClient, StorageConfigurations} from '@gomomento/sdk'; +import {PreviewStorageClient, StorageConfigurations} from '@gomomento/sdk'; const storageClient = new PreviewStorageClient({ configuration: StorageConfigurations.Laptop.latest(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), }); diff --git a/examples/nodejs/storage/package-lock.json b/examples/nodejs/storage/package-lock.json index dabb125f6..ca5b958b1 100644 --- a/examples/nodejs/storage/package-lock.json +++ b/examples/nodejs/storage/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@gomomento/sdk": "^1.97.0" + "@gomomento/sdk": "^1.98.1" }, "devDependencies": { "@types/node": "16.11.4", @@ -62,12 +62,12 @@ } }, "node_modules/@gomomento/sdk": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.97.0.tgz", - "integrity": "sha512-PuBYIzIYilwQmpKLcdrIhyyktzTLHxh7VJn0K443nDPQeQ/a425xUG5YTl5ex7yK9DsFhi/ZZ0qOYLv3P2z68g==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.98.1.tgz", + "integrity": "sha512-++bcF5E65IATkmt0mQmilRz5eJXrvr9YPBg12F1JNxfL9mXXPmNfD3AKJQalKGX8tlmCrEwQ5MSJVkIgw/KNOQ==", "dependencies": { "@gomomento/generated-types": "0.113.0", - "@gomomento/sdk-core": "1.97.0", + "@gomomento/sdk-core": "1.98.1", "@grpc/grpc-js": "1.10.9", "@types/google-protobuf": "3.15.10", "google-protobuf": "3.21.2", @@ -78,9 +78,9 @@ } }, "node_modules/@gomomento/sdk-core": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.97.0.tgz", - "integrity": "sha512-on/peptoTRjmzAcltLrmQXzndtVfygi0xWUARcuJbOlMIEcoKvhr25w+YBXtEBHhq3rjefpkIXtFKqJWz2mfPg==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.98.1.tgz", + "integrity": "sha512-QHQRmpIeNwuNBJ9ugb6GdcoBw3UDM+id0FgAzLvzu9cI/+y7lgXl9kerWjWMEULAWgpL6bcZrfrQTlNuuMOJEw==", "dependencies": { "buffer": "6.0.3", "jwt-decode": "3.1.2" diff --git a/examples/nodejs/storage/package.json b/examples/nodejs/storage/package.json index d79c918d1..258cc07d0 100644 --- a/examples/nodejs/storage/package.json +++ b/examples/nodejs/storage/package.json @@ -28,7 +28,7 @@ "typescript": "4.9.5" }, "dependencies": { - "@gomomento/sdk": "^1.97.0" + "@gomomento/sdk": "^1.98.1" }, "engines": { "node": ">=10.4.0" diff --git a/examples/nodejs/topics/doc-example-files/cheat-sheet-main.ts b/examples/nodejs/topics/doc-example-files/cheat-sheet-main.ts index 131ab126e..793a55193 100644 --- a/examples/nodejs/topics/doc-example-files/cheat-sheet-main.ts +++ b/examples/nodejs/topics/doc-example-files/cheat-sheet-main.ts @@ -4,7 +4,6 @@ import {TopicClient, TopicConfigurations, CredentialProvider} from '@gomomento/s function main() { const cacheClient = new TopicClient({ configuration: TopicConfigurations.Default.latest(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), }); } diff --git a/examples/nodejs/topics/package-lock.json b/examples/nodejs/topics/package-lock.json index 2c219162e..ca76da7b5 100644 --- a/examples/nodejs/topics/package-lock.json +++ b/examples/nodejs/topics/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@gomomento/sdk": "^1.97.0" + "@gomomento/sdk": "^1.98.1" }, "devDependencies": { "@types/node": "^16.11.4", @@ -59,12 +59,12 @@ } }, "node_modules/@gomomento/sdk": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.97.0.tgz", - "integrity": "sha512-PuBYIzIYilwQmpKLcdrIhyyktzTLHxh7VJn0K443nDPQeQ/a425xUG5YTl5ex7yK9DsFhi/ZZ0qOYLv3P2z68g==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.98.1.tgz", + "integrity": "sha512-++bcF5E65IATkmt0mQmilRz5eJXrvr9YPBg12F1JNxfL9mXXPmNfD3AKJQalKGX8tlmCrEwQ5MSJVkIgw/KNOQ==", "dependencies": { "@gomomento/generated-types": "0.113.0", - "@gomomento/sdk-core": "1.97.0", + "@gomomento/sdk-core": "1.98.1", "@grpc/grpc-js": "1.10.9", "@types/google-protobuf": "3.15.10", "google-protobuf": "3.21.2", @@ -75,9 +75,9 @@ } }, "node_modules/@gomomento/sdk-core": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.97.0.tgz", - "integrity": "sha512-on/peptoTRjmzAcltLrmQXzndtVfygi0xWUARcuJbOlMIEcoKvhr25w+YBXtEBHhq3rjefpkIXtFKqJWz2mfPg==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.98.1.tgz", + "integrity": "sha512-QHQRmpIeNwuNBJ9ugb6GdcoBw3UDM+id0FgAzLvzu9cI/+y7lgXl9kerWjWMEULAWgpL6bcZrfrQTlNuuMOJEw==", "dependencies": { "buffer": "6.0.3", "jwt-decode": "3.1.2" @@ -2939,9 +2939,9 @@ } }, "node_modules/protobufjs": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.3.2.tgz", - "integrity": "sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz", + "integrity": "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==", "hasInstallScript": true, "dependencies": { "@protobufjs/aspromise": "^1.1.2", diff --git a/examples/nodejs/topics/package.json b/examples/nodejs/topics/package.json index d0a75b6d9..81d92f34a 100644 --- a/examples/nodejs/topics/package.json +++ b/examples/nodejs/topics/package.json @@ -28,6 +28,6 @@ "typescript": "4.9.5" }, "dependencies": { - "@gomomento/sdk": "^1.97.0" + "@gomomento/sdk": "^1.98.1" } } diff --git a/examples/nodejs/topics/topic-publish.ts b/examples/nodejs/topics/topic-publish.ts index e61dee3b0..646ffe2fe 100644 --- a/examples/nodejs/topics/topic-publish.ts +++ b/examples/nodejs/topics/topic-publish.ts @@ -11,7 +11,6 @@ async function main() { const [cacheName, topicName, value] = clargs; const momento = new TopicClient({ configuration: TopicConfigurations.Default.latest(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), }); await ensureCacheExists(cacheName); diff --git a/examples/nodejs/topics/topic-subscribe.ts b/examples/nodejs/topics/topic-subscribe.ts index 6b43cc300..13ded7641 100644 --- a/examples/nodejs/topics/topic-subscribe.ts +++ b/examples/nodejs/topics/topic-subscribe.ts @@ -5,6 +5,8 @@ import { CredentialProvider, TopicConfigurations, TopicSubscribeResponse, + TopicDiscontinuity, + TopicHeartbeat, } from '@gomomento/sdk'; import {ensureCacheExists} from './utils/cache'; @@ -26,6 +28,8 @@ async function main() { const response = await momento.subscribe(cacheName, topicName, { onItem: handleItem, onError: handleError, + onDiscontinuity: handleDiscontinuity, + onHeartbeat: handleHeartbeat, }); switch (response.type) { @@ -57,6 +61,14 @@ function handleError(error: TopicSubscribe.Error) { //subscription.unsubscribe(); } +function handleDiscontinuity(discontinuity: TopicDiscontinuity) { + console.log('Discontinuity received from topic subscription'); +} + +function handleHeartbeat(heartbeat: TopicHeartbeat) { + console.log('Heartbeat received from topic subscription'); +} + main() .then(() => { console.log('success!!'); diff --git a/examples/web/cache/basic.ts b/examples/web/cache/basic.ts index 177a6168f..fed41cb5c 100644 --- a/examples/web/cache/basic.ts +++ b/examples/web/cache/basic.ts @@ -1,7 +1,6 @@ import { CacheClient, Configurations, - CredentialProvider, CreateCacheResponse, CacheSetResponse, CacheGetResponse, @@ -14,7 +13,6 @@ async function main() { initJSDom(); const momento = new CacheClient({ configuration: Configurations.Laptop.v1(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), defaultTtlSeconds: 60, }); diff --git a/examples/web/cache/dictionary.ts b/examples/web/cache/dictionary.ts index e3cf3ebf4..1c50eab6b 100644 --- a/examples/web/cache/dictionary.ts +++ b/examples/web/cache/dictionary.ts @@ -9,7 +9,6 @@ import { Configurations, CreateCacheResponse, DefaultMomentoLoggerFactory, - EnvMomentoTokenProvider, MomentoLoggerFactory, } from '@gomomento/sdk-web'; import {initJSDom} from './utils/jsdom'; @@ -17,16 +16,11 @@ import {initJSDom} from './utils/jsdom'; const cacheName = 'cache'; const dictionaryName = 'dictionary'; -const credentialsProvider = new EnvMomentoTokenProvider({ - environmentVariableName: 'MOMENTO_API_KEY', -}); - const loggerFactory: MomentoLoggerFactory = new DefaultMomentoLoggerFactory(); const defaultTtl = 60; const momento = new CacheClient({ configuration: Configurations.Laptop.v1(loggerFactory), - credentialProvider: credentialsProvider, defaultTtlSeconds: defaultTtl, }); diff --git a/examples/web/cache/package-lock.json b/examples/web/cache/package-lock.json index 7c30fd99a..40a30d25c 100644 --- a/examples/web/cache/package-lock.json +++ b/examples/web/cache/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@gomomento/sdk-web": "^1.97.0", + "@gomomento/sdk-web": "^1.98.1", "jsdom": "22.1.0" }, "devDependencies": { @@ -91,9 +91,9 @@ } }, "node_modules/@gomomento/sdk-core": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.97.0.tgz", - "integrity": "sha512-on/peptoTRjmzAcltLrmQXzndtVfygi0xWUARcuJbOlMIEcoKvhr25w+YBXtEBHhq3rjefpkIXtFKqJWz2mfPg==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.98.1.tgz", + "integrity": "sha512-QHQRmpIeNwuNBJ9ugb6GdcoBw3UDM+id0FgAzLvzu9cI/+y7lgXl9kerWjWMEULAWgpL6bcZrfrQTlNuuMOJEw==", "dependencies": { "buffer": "6.0.3", "jwt-decode": "3.1.2" @@ -103,12 +103,12 @@ } }, "node_modules/@gomomento/sdk-web": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-web/-/sdk-web-1.97.0.tgz", - "integrity": "sha512-SwWsxCRB5G+tAhc6nZEpvV9HuIGYuqxe8jl+5fyX6/DKinRF3MvUYfv07ZRIv5097Y250mhYF+lYUGbZS3q4yw==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-web/-/sdk-web-1.98.1.tgz", + "integrity": "sha512-VJ/wVdZDJcqqui2HTF8WLn/sTPq2sylmCAd2MWdMqISz4pa0qOLc/qc7/3KLalBK+Wsqo9pXZvknJtNei+mNNA==", "dependencies": { "@gomomento/generated-types-webtext": "0.113.0", - "@gomomento/sdk-core": "1.97.0", + "@gomomento/sdk-core": "1.98.1", "@types/google-protobuf": "3.15.6", "google-protobuf": "3.21.2", "grpc-web": "1.4.2", @@ -3475,21 +3475,21 @@ } }, "@gomomento/sdk-core": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.97.0.tgz", - "integrity": "sha512-on/peptoTRjmzAcltLrmQXzndtVfygi0xWUARcuJbOlMIEcoKvhr25w+YBXtEBHhq3rjefpkIXtFKqJWz2mfPg==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.98.1.tgz", + "integrity": "sha512-QHQRmpIeNwuNBJ9ugb6GdcoBw3UDM+id0FgAzLvzu9cI/+y7lgXl9kerWjWMEULAWgpL6bcZrfrQTlNuuMOJEw==", "requires": { "buffer": "6.0.3", "jwt-decode": "3.1.2" } }, "@gomomento/sdk-web": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-web/-/sdk-web-1.97.0.tgz", - "integrity": "sha512-SwWsxCRB5G+tAhc6nZEpvV9HuIGYuqxe8jl+5fyX6/DKinRF3MvUYfv07ZRIv5097Y250mhYF+lYUGbZS3q4yw==", + "version": "1.98.1", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-web/-/sdk-web-1.98.1.tgz", + "integrity": "sha512-VJ/wVdZDJcqqui2HTF8WLn/sTPq2sylmCAd2MWdMqISz4pa0qOLc/qc7/3KLalBK+Wsqo9pXZvknJtNei+mNNA==", "requires": { "@gomomento/generated-types-webtext": "0.113.0", - "@gomomento/sdk-core": "1.97.0", + "@gomomento/sdk-core": "1.98.1", "@types/google-protobuf": "3.15.6", "google-protobuf": "3.21.2", "grpc-web": "1.4.2", diff --git a/examples/web/cache/package.json b/examples/web/cache/package.json index 76bea79ff..e38dba606 100644 --- a/examples/web/cache/package.json +++ b/examples/web/cache/package.json @@ -29,7 +29,7 @@ "typescript": "4.9.5" }, "dependencies": { - "@gomomento/sdk-web": "^1.97.0", + "@gomomento/sdk-web": "^1.98.1", "jsdom": "22.1.0" } } From 1ad14d5101df2939aab6d24aabdf7110e9806a0f Mon Sep 17 00:00:00 2001 From: anitarua Date: Wed, 28 Aug 2024 16:47:30 -0700 Subject: [PATCH 2/4] fix lint errors --- examples/nodejs/cache/basic.ts | 8 +------- examples/web/cache/basic.ts | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/examples/nodejs/cache/basic.ts b/examples/nodejs/cache/basic.ts index e0c8800ec..86d06f6dc 100644 --- a/examples/nodejs/cache/basic.ts +++ b/examples/nodejs/cache/basic.ts @@ -1,10 +1,4 @@ -import { - CacheClient, - Configurations, - CreateCacheResponse, - CacheSetResponse, - CacheGetResponse, -} from '@gomomento/sdk'; +import {CacheClient, Configurations, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk'; async function main() { const momento = await CacheClient.create({ diff --git a/examples/web/cache/basic.ts b/examples/web/cache/basic.ts index fed41cb5c..47902dd79 100644 --- a/examples/web/cache/basic.ts +++ b/examples/web/cache/basic.ts @@ -1,10 +1,4 @@ -import { - CacheClient, - Configurations, - CreateCacheResponse, - CacheSetResponse, - CacheGetResponse, -} from '@gomomento/sdk-web'; +import {CacheClient, Configurations, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk-web'; import {initJSDom} from './utils/jsdom'; async function main() { From 38e70409b8d82b4312f6dbb0ac9f2578fd5cb640 Mon Sep 17 00:00:00 2001 From: anitarua Date: Thu, 29 Aug 2024 10:53:28 -0700 Subject: [PATCH 3/4] revert dictionary file changes, omit optional config in basic files too --- examples/nodejs/cache/basic.ts | 3 +-- examples/nodejs/cache/dictionary.ts | 6 ++++++ .../nodejs/cache/doc-example-files/cheat-sheet-main.ts | 3 +-- examples/nodejs/cache/readme.ts | 3 +-- examples/nodejs/storage/basic.ts | 6 +----- examples/nodejs/topics/topic-publish.ts | 6 ++---- examples/nodejs/topics/topic-subscribe.ts | 7 +------ examples/web/cache/basic.ts | 3 +-- examples/web/cache/dictionary.ts | 6 ++++++ 9 files changed, 20 insertions(+), 23 deletions(-) diff --git a/examples/nodejs/cache/basic.ts b/examples/nodejs/cache/basic.ts index 86d06f6dc..c550756c0 100644 --- a/examples/nodejs/cache/basic.ts +++ b/examples/nodejs/cache/basic.ts @@ -1,8 +1,7 @@ -import {CacheClient, Configurations, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk'; +import {CacheClient, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk'; async function main() { const momento = await CacheClient.create({ - configuration: Configurations.Laptop.v1(), defaultTtlSeconds: 60, }); diff --git a/examples/nodejs/cache/dictionary.ts b/examples/nodejs/cache/dictionary.ts index 9c0ce5004..864524201 100644 --- a/examples/nodejs/cache/dictionary.ts +++ b/examples/nodejs/cache/dictionary.ts @@ -9,12 +9,17 @@ import { Configurations, CreateCacheResponse, DefaultMomentoLoggerFactory, + EnvMomentoTokenProvider, MomentoLoggerFactory, } from '@gomomento/sdk'; const cacheName = 'cache'; const dictionaryName = 'dictionary'; +const credentialsProvider = new EnvMomentoTokenProvider({ + environmentVariableName: 'MOMENTO_API_KEY', +}); + const loggerFactory: MomentoLoggerFactory = new DefaultMomentoLoggerFactory(); const defaultTtl = 60; @@ -23,6 +28,7 @@ let momento: CacheClient; const main = async () => { momento = await CacheClient.create({ configuration: Configurations.Laptop.v1(loggerFactory), + credentialProvider: credentialsProvider, defaultTtlSeconds: defaultTtl, }); diff --git a/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts b/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts index 2852c23ad..d9ffbbdcf 100644 --- a/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts +++ b/examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import {CacheClient, Configurations} from '@gomomento/sdk'; +import {CacheClient} from '@gomomento/sdk'; async function main() { const cacheClient = await CacheClient.create({ - configuration: Configurations.Laptop.v1(), defaultTtlSeconds: 60, }); } diff --git a/examples/nodejs/cache/readme.ts b/examples/nodejs/cache/readme.ts index 1f639b014..4a18c2de4 100644 --- a/examples/nodejs/cache/readme.ts +++ b/examples/nodejs/cache/readme.ts @@ -1,8 +1,7 @@ -import {CacheClient, CacheGetResponse, Configurations} from '@gomomento/sdk'; +import {CacheClient, CacheGetResponse} from '@gomomento/sdk'; async function main() { const cacheClient = await CacheClient.create({ - configuration: Configurations.Laptop.v1(), defaultTtlSeconds: 60, }); diff --git a/examples/nodejs/storage/basic.ts b/examples/nodejs/storage/basic.ts index 4fa27f2dc..0d7d3fa08 100644 --- a/examples/nodejs/storage/basic.ts +++ b/examples/nodejs/storage/basic.ts @@ -1,16 +1,12 @@ import { CreateStoreResponse, - CredentialProvider, PreviewStorageClient, - StorageConfigurations, StorageGetResponse, StoragePutResponse, } from '@gomomento/sdk'; async function main() { - const storageClient = new PreviewStorageClient({ - configuration: StorageConfigurations.Laptop.latest(), - }); + const storageClient = new PreviewStorageClient({}); const storeName = 'my-store'; const createStoreResponse = await storageClient.createStore(storeName); diff --git a/examples/nodejs/topics/topic-publish.ts b/examples/nodejs/topics/topic-publish.ts index 646ffe2fe..84acff74e 100644 --- a/examples/nodejs/topics/topic-publish.ts +++ b/examples/nodejs/topics/topic-publish.ts @@ -1,4 +1,4 @@ -import {TopicClient, CredentialProvider, TopicConfigurations, TopicPublishResponse} from '@gomomento/sdk'; +import {TopicClient, TopicPublishResponse} from '@gomomento/sdk'; import {ensureCacheExists} from './utils/cache'; @@ -9,9 +9,7 @@ async function main() { return; } const [cacheName, topicName, value] = clargs; - const momento = new TopicClient({ - configuration: TopicConfigurations.Default.latest(), - }); + const momento = new TopicClient({}); await ensureCacheExists(cacheName); diff --git a/examples/nodejs/topics/topic-subscribe.ts b/examples/nodejs/topics/topic-subscribe.ts index 13ded7641..587a6b9cf 100644 --- a/examples/nodejs/topics/topic-subscribe.ts +++ b/examples/nodejs/topics/topic-subscribe.ts @@ -2,8 +2,6 @@ import { TopicClient, TopicItem, TopicSubscribe, - CredentialProvider, - TopicConfigurations, TopicSubscribeResponse, TopicDiscontinuity, TopicHeartbeat, @@ -17,10 +15,7 @@ async function main() { return; } const [cacheName, topicName] = clargs; - const momento = new TopicClient({ - configuration: TopicConfigurations.Default.latest(), - credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), - }); + const momento = new TopicClient({}); await ensureCacheExists(cacheName); diff --git a/examples/web/cache/basic.ts b/examples/web/cache/basic.ts index 47902dd79..b69e2000b 100644 --- a/examples/web/cache/basic.ts +++ b/examples/web/cache/basic.ts @@ -1,4 +1,4 @@ -import {CacheClient, Configurations, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk-web'; +import {CacheClient, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk-web'; import {initJSDom} from './utils/jsdom'; async function main() { @@ -6,7 +6,6 @@ async function main() { // that will allow us to use it in a node.js program. initJSDom(); const momento = new CacheClient({ - configuration: Configurations.Laptop.v1(), defaultTtlSeconds: 60, }); diff --git a/examples/web/cache/dictionary.ts b/examples/web/cache/dictionary.ts index 1c50eab6b..e3cf3ebf4 100644 --- a/examples/web/cache/dictionary.ts +++ b/examples/web/cache/dictionary.ts @@ -9,6 +9,7 @@ import { Configurations, CreateCacheResponse, DefaultMomentoLoggerFactory, + EnvMomentoTokenProvider, MomentoLoggerFactory, } from '@gomomento/sdk-web'; import {initJSDom} from './utils/jsdom'; @@ -16,11 +17,16 @@ import {initJSDom} from './utils/jsdom'; const cacheName = 'cache'; const dictionaryName = 'dictionary'; +const credentialsProvider = new EnvMomentoTokenProvider({ + environmentVariableName: 'MOMENTO_API_KEY', +}); + const loggerFactory: MomentoLoggerFactory = new DefaultMomentoLoggerFactory(); const defaultTtl = 60; const momento = new CacheClient({ configuration: Configurations.Laptop.v1(loggerFactory), + credentialProvider: credentialsProvider, defaultTtlSeconds: defaultTtl, }); From 9fc65aafdd41eed0f1d81c21e0331462a12b213b Mon Sep 17 00:00:00 2001 From: anitarua Date: Thu, 29 Aug 2024 10:58:02 -0700 Subject: [PATCH 4/4] edits in storage and leaderboards examples --- examples/nodejs/cache/leaderboard.ts | 8 +++----- examples/nodejs/storage/basic.ts | 7 +------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/examples/nodejs/cache/leaderboard.ts b/examples/nodejs/cache/leaderboard.ts index f1d152dd1..d13eb8466 100644 --- a/examples/nodejs/cache/leaderboard.ts +++ b/examples/nodejs/cache/leaderboard.ts @@ -15,8 +15,8 @@ import { } from '@gomomento/sdk'; async function main() { - // NOTE: trace logging to view leaderboard interactions; might want to disable in production to save log noise and - // switch to ERROR or info + // NOTE: you can use TRACE level logging to view leaderboard interactions, but you likely want to + // disable that in production to save log noise by switching to ERROR or INFO level instead. const loggerFactory = new DefaultMomentoLoggerFactory(DefaultMomentoLoggerLevel.TRACE); const cacheClient = await CacheClient.create({ configuration: Configurations.Laptop.v1(loggerFactory), @@ -35,9 +35,7 @@ async function main() { throw createCacheResponse.innerException(); } - const client = new PreviewLeaderboardClient({ - configuration: LeaderboardConfigurations.Laptop.v1(), - }); + const client = new PreviewLeaderboardClient({}); // Create a leaderboard with given cache and leaderboard names const leaderboard = client.leaderboard('my-cache', 'my-leaderboard'); diff --git a/examples/nodejs/storage/basic.ts b/examples/nodejs/storage/basic.ts index 0d7d3fa08..d599f6136 100644 --- a/examples/nodejs/storage/basic.ts +++ b/examples/nodejs/storage/basic.ts @@ -1,9 +1,4 @@ -import { - CreateStoreResponse, - PreviewStorageClient, - StorageGetResponse, - StoragePutResponse, -} from '@gomomento/sdk'; +import {CreateStoreResponse, PreviewStorageClient, StorageGetResponse, StoragePutResponse} from '@gomomento/sdk'; async function main() { const storageClient = new PreviewStorageClient({});