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
6 changes: 6 additions & 0 deletions .changeset/long-dryers-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@smartthings/cli": patch
"@smartthings/cli-lib": patch
---

Add userEmail field to ST Schema apps
22 changes: 11 additions & 11 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 @@ -71,7 +71,7 @@
"@oclif/plugin-not-found": "^2.3.1",
"@oclif/plugin-plugins": "^2.1.0",
"@smartthings/cli-lib": "^1.0.0-beta.11",
"@smartthings/core-sdk": "^5.0.0",
"@smartthings/core-sdk": "^5.1.0",
"@smartthings/plugin-cli-edge": "^1.14.1",
"aws-sdk": "^2.1175.0",
"inquirer": "^8.2.4",
Expand Down
14 changes: 8 additions & 6 deletions packages/cli/src/__tests__/commands/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('SchemaCommand', () => {
{ prop: 'lambdaArnCN', skipEmpty: true },
{ prop: 'lambdaArnEU', skipEmpty: true },
{ prop: 'webhookUrl', skipEmpty: true },
{ prop: 'userEmail', skipEmpty: true },
],
primaryKeyName: 'endpointAppId',
sortKeyName: 'appName',
Expand All @@ -50,23 +51,24 @@ describe('SchemaCommand', () => {
})

it('adds ARN/URL to return values for lambda and webhooks', async () => {
const lambda: SchemaApp = {
const lambda = {
endpointAppId: 'lambdaAppId',
hostingType: 'lambda',
lambdaArn: 'ARN',
}
const webhook: SchemaApp = {
} as SchemaApp
const webhook = {
endpointAppId: 'webhookAppId',
hostingType: 'webhook',
webhookUrl: 'URL',
}
} as SchemaApp

listSpy.mockResolvedValueOnce([lambda, webhook])

await expect(SchemaCommand.run([])).resolves.not.toThrow()

const listFunction = outputListingMock.mock.calls[0][3] as ListDataFunction<SchemaApp & { 'ARN/URL': string }>

const expected: SchemaApp & { 'ARN/URL': string }[] = [
const expected = [
{
...lambda,
'ARN/URL': 'ARN',
Expand All @@ -87,7 +89,7 @@ describe('SchemaCommand', () => {

const getFunction = outputListingMock.mock.calls[0][4]

const schemaApp: SchemaApp = { endpointAppId: 'schemaAppId' }
const schemaApp = { endpointAppId: 'schemaAppId' } as SchemaApp
getSpy.mockResolvedValueOnce(schemaApp)

await expect(getFunction('schemaAppId')).resolves.toStrictEqual(schemaApp)
Expand Down
24 changes: 12 additions & 12 deletions packages/cli/src/__tests__/commands/schema/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ describe('SchemaAppCreateCommand', () => {
}
createSpy.mockResolvedValueOnce(schemaCreateResponse)

const schemaAppRequest: SchemaAppRequest = {
const schemaAppRequest = {
appName: 'schemaApp',
}
} as SchemaAppRequest

const actionFunction = inputAndOutputItemMock.mock.calls[0][2]

Expand All @@ -53,14 +53,14 @@ describe('SchemaAppCreateCommand', () => {
}
createSpy.mockResolvedValueOnce(schemaCreateResponse)

const schemaAppRequest: SchemaAppRequest = {
const schemaAppRequest = {
appName: 'schemaApp',
hostingType: 'lambda',
lambdaArn: 'lambdaArn',
lambdaArnCN: 'lambdaArnCN',
lambdaArnEU: 'lambdaArnEU',
lambdaArnAP: 'lambdaArnAP',
}
} as SchemaAppRequest

const actionFunction = inputAndOutputItemMock.mock.calls[0][2]

Expand All @@ -79,9 +79,9 @@ describe('SchemaAppCreateCommand', () => {

const actionFunction = inputAndOutputItemMock.mock.calls[0][2]

const schemaAppRequest: SchemaAppRequest = {
const schemaAppRequest = {
hostingType: 'webhook',
}
} as SchemaAppRequest

await expect(actionFunction(undefined, schemaAppRequest)).rejects.toThrow('Authorization is not applicable to WebHook schema connectors')
expect(createSpy).not.toBeCalled()
Expand All @@ -90,10 +90,10 @@ describe('SchemaAppCreateCommand', () => {
it('ignores authorize flag for lambda apps with no ARNs', async () => {
await expect(SchemaAppCreateCommand.run(['--authorize'])).resolves.not.toThrow()

const schemaAppRequest: SchemaAppRequest = {
const schemaAppRequest = {
appName: 'schemaApp',
hostingType: 'lambda',
}
} as SchemaAppRequest

const actionFunction = inputAndOutputItemMock.mock.calls[0][2]

Expand All @@ -107,11 +107,11 @@ describe('SchemaAppCreateCommand', () => {
const principal = 'principal'
await expect(SchemaAppCreateCommand.run(['--authorize', `--principal=${principal}`])).resolves.not.toThrow()

const schemaAppRequest: SchemaAppRequest = {
const schemaAppRequest = {
appName: 'schemaApp',
hostingType: 'lambda',
lambdaArn: 'lambdaArn',
}
} as SchemaAppRequest

const actionFunction = inputAndOutputItemMock.mock.calls[0][2]

Expand All @@ -124,11 +124,11 @@ describe('SchemaAppCreateCommand', () => {
const statementId = 'statementId'
await expect(SchemaAppCreateCommand.run(['--authorize', `--statement-id=${statementId}`])).resolves.not.toThrow()

const schemaAppRequest: SchemaAppRequest = {
const schemaAppRequest = {
appName: 'schemaApp',
hostingType: 'lambda',
lambdaArn: 'lambdaArn',
}
} as SchemaAppRequest

const actionFunction = inputAndOutputItemMock.mock.calls[0][2]

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/__tests__/commands/schema/regenerate.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { outputItem, selectFromList } from '@smartthings/cli-lib'
import { SchemaEndpoint, SchemaCreateResponse } from '@smartthings/core-sdk'
import { SchemaEndpoint, SchemaCreateResponse, SchemaApp } from '@smartthings/core-sdk'
import SchemaAppRegenerateCommand from '../../../commands/schema/regenerate'


Expand Down Expand Up @@ -29,7 +29,7 @@ describe('SchemaAppRegenerateCommand', () => {
})

it('calls correct list endpoint', async () => {
const list = [{ appName: 'schemaApp' }]
const list = [{ appName: 'schemaApp' } as SchemaApp]
listSpy.mockResolvedValueOnce(list)

await expect(SchemaAppRegenerateCommand.run(['schemaAppId'])).resolves.not.toThrow()
Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/__tests__/commands/schema/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ describe('SchemaUpdateCommand', () => {
const listSpy = jest.spyOn(SchemaEndpoint.prototype, 'list')
const logSpy = jest.spyOn(SchemaUpdateCommand.prototype, 'log').mockImplementation()

const schemaAppRequest: SchemaAppRequest = { appName: 'schemaApp' }
const schemaAppRequest = { appName: 'schemaApp' } as SchemaAppRequest
const inputItemMock = jest.mocked(inputItem).mockResolvedValue([schemaAppRequest, IOFormat.JSON])
const addSchemaPermissionMock = jest.mocked(addSchemaPermission)
const selectFromListMock = jest.mocked(selectFromList).mockResolvedValue('schemaAppId')

it('prompts user to select schema app', async () => {
const schemaAppList: SchemaApp[] = [{ appName: 'schemaApp' }]
const schemaAppList = [{ appName: 'schemaApp' } as SchemaApp]
listSpy.mockResolvedValueOnce(schemaAppList)

await expect(SchemaUpdateCommand.run(['schemaAppId'])).resolves.not.toThrow()
Expand Down Expand Up @@ -63,14 +63,14 @@ describe('SchemaUpdateCommand', () => {
})

it('accepts authorize flag for lambda apps', async () => {
const schemaAppRequest: SchemaAppRequest = {
const schemaAppRequest = {
appName: 'schemaApp',
hostingType: 'lambda',
lambdaArn: 'lambdaArn',
lambdaArnCN: 'lambdaArnCN',
lambdaArnEU: 'lambdaArnEU',
lambdaArnAP: 'lambdaArnAP',
}
} as SchemaAppRequest

inputItemMock.mockResolvedValueOnce([schemaAppRequest, IOFormat.JSON])

Expand All @@ -84,10 +84,10 @@ describe('SchemaUpdateCommand', () => {
})

it('throws error if authorize flag is used on non-lambda app', async () => {
const webhookSchemaRequest: SchemaAppRequest = {
const webhookSchemaRequest = {
appName: 'webhookApp',
hostingType: 'webhook',
}
} as SchemaAppRequest

inputItemMock.mockResolvedValueOnce([webhookSchemaRequest, IOFormat.JSON])

Expand All @@ -96,10 +96,10 @@ describe('SchemaUpdateCommand', () => {
})

it('ignores authorize flag for lambda apps with no ARNs', async () => {
const noArnSchemaRequest: SchemaAppRequest = {
const noArnSchemaRequest = {
appName: 'schemaApp',
hostingType: 'lambda',
}
} as SchemaAppRequest

inputItemMock.mockResolvedValueOnce([noArnSchemaRequest, IOFormat.JSON])

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class SchemaCommand extends APICommand<typeof SchemaCommand.flags
{ prop: 'lambdaArnCN', skipEmpty: true },
{ prop: 'lambdaArnEU', skipEmpty: true },
{ prop: 'webhookUrl', skipEmpty: true },
{ prop: 'userEmail', skipEmpty: true },
],
primaryKeyName: 'endpointAppId',
sortKeyName: 'appName',
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@log4js-node/log4js-api": "^1.0.2",
"@oclif/core": "^1.9.9",
"@smartthings/core-sdk": "^5.0.0",
"@smartthings/core-sdk": "^5.1.0",
"@types/eventsource": "^1.1.9",
"axios": "^0.21.4",
"chalk": "^4.1.2",
Expand Down