diff --git a/.changeset/empty-jars-doubt.md b/.changeset/empty-jars-doubt.md new file mode 100644 index 000000000..d68684520 --- /dev/null +++ b/.changeset/empty-jars-doubt.md @@ -0,0 +1,5 @@ +--- +"@smartthings/cli": patch +--- + +Update scopes available when creating an API Access Smart App. diff --git a/src/lib/command/util/smartapps-input-primitives.ts b/src/lib/command/util/smartapps-input-primitives.ts index 0db875ac3..b4ee60c27 100644 --- a/src/lib/command/util/smartapps-input-primitives.ts +++ b/src/lib/command/util/smartapps-input-primitives.ts @@ -2,23 +2,62 @@ import { localhostOrHTTPSValidate } from '../../validate-util.js' import { arrayDef, CheckboxChoice, checkboxDef, stringDef } from '../../item-input/index.js' -const availableScopes = [ - 'r:devices:*', - 'w:devices:*', - 'x:devices:*', - 'r:hubs:*', - 'r:locations:*', - 'w:locations:*', - 'x:locations:*', - 'r:scenes:*', - 'x:scenes:*', - 'r:rules:*', - 'w:rules:*', - 'r:installedapps', - 'w:installedapps', +type ScopeInfo = { scope: string; description: string } + +const availableScopes: ScopeInfo[] = [ + { + scope: 'r:devices:*', + description: 'Read a specific device or all devices.', + }, + { + scope: 'w:devices:*', + description: 'Write to a specific device or all devices.', + }, + { + scope: 'x:devices:*', + description: 'Execute commands on a specific device or all devices.', + }, + { + scope: 'r:hubs:*', + description: 'Read a specific hub or all hubs.', + }, + { + scope: 'r:locations:*', + description: 'Read all locations. An installed app can only read the location it is installed in.', + }, + { + scope: 'w:locations:*', + description: 'Write all locations.', + }, + { + scope: 'x:locations:*', + description: 'Change the mode of a location.', + }, + { + scope: 'r:scenes:*', + description: 'Read a specific scene or all scenes.', + }, + { + scope: 'x:scenes:*', + description: 'Execute a specific scene or all scenes.', + }, + { + scope: 'r:rules:*', + description: 'Read one or all rules.', + }, + { + scope: 'w:rules:*', + description: 'Write one or all rules.', + }, + { + scope: 'sse', + description: 'Read and Write permissions required to use the SSE Subscription API.', + }, ] -export const oauthAppScopeDef = checkboxDef('Scopes', availableScopes, { +const scopeItems = availableScopes.map(({ scope, description }) => ({ name: `${scope} - ${description}`, value: scope })) + +export const oauthAppScopeDef = checkboxDef('Scopes', scopeItems, { helpText: 'More information on OAuth 2 Scopes can be found at:\n' + ' https://www.oauth.com/oauth2-servers/scope/\n\n' + 'To determine which scopes you need for the application, see documentation for the' + @@ -43,5 +82,5 @@ export const corsDomainsDef = arrayDef( { minItems: 0, maxItems: 10, helpText: corsDomainsHelpText }, ) -export const smartAppHelpText = 'More information on writing SmartApps can be found at\n' + - ' https://developer.smartthings.com/docs/connected-services/smartapp-basics' +export const smartAppHelpText = 'More information on writing API Access Smart Apps can be found at\n' + + ' https://developer.smartthings.com/docs/service-integrations/get-started'