Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .changeset/wet-cherries-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@smartthings/cli": patch
"@smartthings/cli-lib": patch
"@smartthings/cli-testlib": patch
---

update @smartthings/core-sdk to 5.0.0
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@oclif/plugin-not-found": "^2.3.1",
"@oclif/plugin-plugins": "^2.1.0",
"@smartthings/cli-lib": "^1.0.0-beta.8",
"@smartthings/core-sdk": "^4.2.0",
"@smartthings/core-sdk": "^5.0.0",
"@smartthings/plugin-cli-edge": "^1.14.1",
"aws-sdk": "^2.1144.0",
"cli-table": "^0.3.11",
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/__tests__/commands/apps.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { outputListing } from '@smartthings/cli-lib'
import { App, AppClassification, AppsEndpoint, AppType } from '@smartthings/core-sdk'
import { AppResponse, AppClassification, AppsEndpoint, AppType, PagedApp } from '@smartthings/core-sdk'
import AppsCommand from '../../commands/apps'


describe('AppsCommand', () => {
const appId = 'appId'
const app: App = { appId: appId, webhookSmartApp: { targetUrl: 'targetUrl' } }
const appList = [app]
const app = { appId: appId, webhookSmartApp: { targetUrl: 'targetUrl' } } as AppResponse
const appList = [{ appId: appId }] as PagedApp[]
const mockOutputListing = jest.mocked(outputListing)
const getSpy = jest.spyOn(AppsEndpoint.prototype, 'get').mockImplementation()
const listSpy = jest.spyOn(AppsEndpoint.prototype, 'list').mockImplementation()
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('AppsCommand', () => {
await expect(AppsCommand.run(['--verbose'])).resolves.not.toThrow()

const listApps = mockOutputListing.mock.calls[0][3]
const verboseApp = (await listApps()).pop() as App & { 'ARN/URL'?: string }
const verboseApp = (await listApps()).pop() as AppResponse & { 'ARN/URL'?: string }

expect(getSpy).toBeCalledTimes(1)
expect(getSpy).toBeCalledWith(appId)
Expand Down
39 changes: 15 additions & 24 deletions packages/cli/src/__tests__/commands/apps/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CustomCommonOutputProducer, DefaultTableGenerator, inputAndOutputItem } from '@smartthings/cli-lib'
import { AppCreationResponse, AppRequest, AppsEndpoint } from '@smartthings/core-sdk'
import { AppCreationResponse, AppCreateRequest, AppsEndpoint, AppResponse } from '@smartthings/core-sdk'
import AppCreateCommand from '../../../commands/apps/create'
import { tableFieldDefinitions } from '../../../lib/commands/apps/apps-util'
import { addPermission } from '../../../lib/aws-utils'
Expand All @@ -15,7 +15,7 @@ describe('AppCreateCommand', () => {

it('calls inputOutput with correct config', async () => {
const appCreate: AppCreationResponse = {
app: {},
app: { appName: 'app ' } as AppResponse,
oauthClientId: 'oauthClientId',
oauthClientSecret: 'oauthClientSecret',
}
Expand All @@ -37,7 +37,7 @@ describe('AppCreateCommand', () => {
})

it('calls correct create endpoint', async () => {
const appRequest: AppRequest = {}
const appRequest = { appName: 'app' } as AppCreateRequest
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, appRequest)
})
Expand All @@ -50,11 +50,11 @@ describe('AppCreateCommand', () => {
it('accepts authorize flag for lambda apps', async () => {
const arn = 'arn'
const anotherArn = 'anotherArn'
const appRequest: AppRequest = {
const appRequest = {
lambdaSmartApp: {
functions: [arn, anotherArn],
},
}
} as AppCreateRequest
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, appRequest)
})
Expand All @@ -68,9 +68,9 @@ describe('AppCreateCommand', () => {
})

it('throws error if authorize flag is used on non-lambda app', async () => {
const appRequest: AppRequest = {
const appRequest = {
webhookSmartApp: {},
}
} as AppCreateRequest
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, appRequest)
})
Expand All @@ -80,11 +80,11 @@ describe('AppCreateCommand', () => {
})

it('ignores authorize flag for lambda apps with no functions', async () => {
let appRequest: AppRequest = {
const appRequest = {
lambdaSmartApp: {
functions: [],
},
}
} as unknown as AppCreateRequest
mockInputAndOutputItem.mockImplementation(async (_command, _config, actionFunction) => {
await actionFunction(undefined, appRequest)
})
Expand All @@ -95,24 +95,15 @@ describe('AppCreateCommand', () => {
expect(createSpy).toBeCalledWith(appRequest)

createSpy.mockClear()

appRequest = {
lambdaSmartApp: {},
}

await expect(AppCreateCommand.run(['--authorize'])).resolves.not.toThrow()

expect(addPermission).not.toBeCalled()
expect(createSpy).toBeCalledWith(appRequest)
})

it('calls addPermission with principal flag', async () => {
const arn = 'arn'
const appRequest: AppRequest = {
const appRequest = {
lambdaSmartApp: {
functions: [arn],
},
}
} as AppCreateRequest
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, appRequest)
})
Expand All @@ -125,11 +116,11 @@ describe('AppCreateCommand', () => {

it('calls addPermission with statement-id flag', async () => {
const arn = 'arn'
const appRequest: AppRequest = {
const appRequest = {
lambdaSmartApp: {
functions: [arn],
},
}
} as AppCreateRequest
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, appRequest)
})
Expand All @@ -142,11 +133,11 @@ describe('AppCreateCommand', () => {

it('ignores already authorized functions', async () => {
const arn = 'arn'
const appRequest: AppRequest = {
const appRequest = {
lambdaSmartApp: {
functions: [arn],
},
}
} as AppCreateRequest
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, appRequest)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/__tests__/commands/apps/oauth.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { outputItem } from '@smartthings/cli-lib'
import { AppOAuth, AppsEndpoint } from '@smartthings/core-sdk'
import { AppOAuthResponse, AppsEndpoint } from '@smartthings/core-sdk'
import AppOauthCommand from '../../../commands/apps/oauth'
import { chooseApp } from '../../../lib/commands/apps/apps-util'

Expand Down Expand Up @@ -40,7 +40,7 @@ describe('AppOauthCommand', () => {
it('uses correct endpoint to get oauth details', async () => {
const appId = 'appId'
mockChooseApp.mockResolvedValueOnce(appId)
const appOAuth: AppOAuth = { clientName: 'test' }
const appOAuth = { clientName: 'test' } as AppOAuthResponse
getOauthSpy.mockResolvedValueOnce(appOAuth)
mockOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
return actionFunction()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inputAndOutputItem } from '@smartthings/cli-lib'
import { AppOAuth, AppsEndpoint } from '@smartthings/core-sdk'
import { GenerateAppOAuthRequest, AppsEndpoint } from '@smartthings/core-sdk'
import AppOauthGenerateCommand from '../../../../commands/apps/oauth/generate'
import { chooseApp } from '../../../../lib/commands/apps/apps-util'

Expand Down Expand Up @@ -35,7 +35,7 @@ describe('AppOauthGenerateCommand', () => {

it('uses correct endpoint to generate oauth', async () => {
const appId = 'appId'
const oAuth: AppOAuth = { clientName: 'test' }
const oAuth = { clientName: 'test' } as GenerateAppOAuthRequest
mockChooseApp.mockResolvedValueOnce(appId)
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, oAuth)
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/__tests__/commands/apps/oauth/update.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inputAndOutputItem } from '@smartthings/cli-lib'
import { AppOAuth, AppsEndpoint } from '@smartthings/core-sdk'
import { AppOAuthRequest, AppsEndpoint } from '@smartthings/core-sdk'
import AppOauthUpdateCommand from '../../../../commands/apps/oauth/update'
import { chooseApp } from '../../../../lib/commands/apps/apps-util'

Expand All @@ -23,7 +23,11 @@ describe('AppOauthUpdateCommand', () => {

it('uses correct endpoint to update oauth', async () => {
const appId = 'appId'
const oAuth: AppOAuth = { clientName: 'test' }
const oAuth: AppOAuthRequest = {
clientName: 'test',
redirectUris: [],
scope: [],
}
mockChooseApp.mockResolvedValueOnce(appId)
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, oAuth)
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/__tests__/commands/apps/register.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { selectFromList } from '@smartthings/cli-lib'
import { App, AppsEndpoint, AppType } from '@smartthings/core-sdk'
import { PagedApp, AppsEndpoint, AppType } from '@smartthings/core-sdk'
import AppRegisterCommand from '../../../commands/apps/register'


describe('AppRegisterCommand', () => {
const appId = 'appId'
const registerSpy = jest.spyOn(AppsEndpoint.prototype, 'register').mockResolvedValue({ status: '200' })
const registerSpy = jest.spyOn(AppsEndpoint.prototype, 'register').mockResolvedValue()
const listSpy = jest.spyOn(AppsEndpoint.prototype, 'list').mockImplementation()
const logSpy = jest.spyOn(AppRegisterCommand.prototype, 'log').mockImplementation()
const mockSelectFromList = jest.mocked(selectFromList)
Expand Down Expand Up @@ -41,10 +41,10 @@ describe('AppRegisterCommand', () => {
})

it('lists all app types that support registration', async () => {
const webhookApps: App[] = [{ appType: AppType.WEBHOOK_SMART_APP, webhookSmartApp: {} }]
const apiOnlyApps: App[] = [{ appType: AppType.API_ONLY, apiOnly: {} }]
const webhookApps = [{ appType: AppType.WEBHOOK_SMART_APP }] as PagedApp[]
const apiOnlyApps = [{ appType: AppType.API_ONLY }] as PagedApp[]
listSpy.mockImplementation(async (options) => {
let apps: App[] = []
let apps: PagedApp[] = []
if (options?.appType == AppType.WEBHOOK_SMART_APP) {
apps = webhookApps
} else if (options?.appType == AppType.API_ONLY) {
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/src/__tests__/commands/apps/settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CustomCommonOutputProducer, DefaultTableGenerator, outputItem } from '@smartthings/cli-lib'
import { AppsEndpoint, AppSettings } from '@smartthings/core-sdk'
import { AppsEndpoint, AppSettingsResponse } from '@smartthings/core-sdk'
import AppSettingsCommand from '../../../commands/apps/settings'
import { buildTableOutput, chooseApp } from '../../../lib/commands/apps/apps-util'

Expand All @@ -11,7 +11,9 @@ describe('AppSettingsCommand', () => {
const mockChooseApp = jest.mocked(chooseApp)
const mockOutputItem = jest.mocked(outputItem)
const settingsSpy = jest.spyOn(AppsEndpoint.prototype, 'getSettings').mockImplementation()
const appSettings: AppSettings = {}
const appSettings: AppSettingsResponse = {
settings: {},
}

beforeAll(() => {
mockChooseApp.mockResolvedValue(appId)
Expand All @@ -30,7 +32,7 @@ describe('AppSettingsCommand', () => {

it('calls outputItem with correct config', async () => {
mockOutputItem.mockImplementationOnce(async (_command, config) => {
(config as CustomCommonOutputProducer<AppSettings>).buildTableOutput(appSettings)
(config as CustomCommonOutputProducer<AppSettingsResponse>).buildTableOutput(appSettings)
return appSettings
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inputAndOutputItem } from '@smartthings/cli-lib'
import { AppsEndpoint, AppSettings } from '@smartthings/core-sdk'
import { AppsEndpoint, AppSettingsRequest } from '@smartthings/core-sdk'
import AppSettingsUpdateCommand from '../../../../commands/apps/settings/update'
import { chooseApp } from '../../../../lib/commands/apps/apps-util'

Expand All @@ -23,7 +23,7 @@ describe('AppSettingsUpdateCommand', () => {

it('uses correct endpoint to update settings', async () => {
const appId = 'appId'
const settings: AppSettings = {}
const settings: AppSettingsRequest = {}
mockChooseApp.mockResolvedValueOnce(appId)
mockInputAndOutputItem.mockImplementationOnce(async (_command, _config, actionFunction) => {
await actionFunction(undefined, settings)
Expand Down
Loading