Skip to content

Commit b4b1afc

Browse files
authored
fix(Initialization): add return type annotations (#198)
1 parent f1ef97e commit b4b1afc

12 files changed

+97
-57
lines changed

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"hideable"
4+
]
5+
}

docs/classes/_pages_section_d_.section.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ page.section('section1', section => {
3434
* [emailSetting](_pages_email_setting_d_.emailsetting.md)
3535
* [enumSetting](_pages_enum_setting_d_.enumsetting.md)
3636
* [imageSetting](_pages_image_setting_d_.imagesetting.md)
37+
* [imagesSetting](_pages_images_setting_d_.imagessetting.md)
3738
* [linkSetting](_pages_link_setting_d_.linksetting.md)
3839
* [modeSetting](_pages_mode_setting_d_.modesetting.md)
3940
* [numberSetting](_pages_number_setting_d_.numbersetting.md)
@@ -51,79 +52,79 @@ page.section('section1', section => {
5152

5253
### defaultRequired
5354

54-
**defaultRequired**(`id`: string): *[Section](_pages_section_d_.section.md)*
55+
**defaultRequired**(`defaultRequired`: boolean): *[Section](_pages_section_d_.section.md)*
5556

5657
Specifies that all settings in the session should default to being required
5758

5859
**Parameters:**
5960

6061
Name | Type |
6162
------ | ------ |
62-
`id` | string |
63+
`defaultRequired` | boolean |
6364

6465
**Returns:** *[Section](_pages_section_d_.section.md)*
6566

6667
___
6768

6869
### hidden
6970

70-
**hidden**(`id`: string): *[Section](_pages_section_d_.section.md)*
71+
**hidden**(`value`: boolean): *[Section](_pages_section_d_.section.md)*
7172

7273
Specifies that the section should initially be hidden
7374

7475
**Parameters:**
7576

7677
Name | Type |
7778
------ | ------ |
78-
`id` | string |
79+
`value` | boolean |
7980

8081
**Returns:** *[Section](_pages_section_d_.section.md)*
8182

8283
___
8384

8485
### hideable
8586

86-
**hideable**(`id`: string): *[Section](_pages_section_d_.section.md)*
87+
**hideable**(`value`: boolean): *[Section](_pages_section_d_.section.md)*
8788

8889
Specifies that the section should be able to be hidden (though not initially hidden)
8990

9091
**Parameters:**
9192

9293
Name | Type |
9394
------ | ------ |
94-
`id` | string |
95+
`value` | boolean |
9596

9697
**Returns:** *[Section](_pages_section_d_.section.md)*
9798

9899
___
99100

100101
### name
101102

102-
**name**(`id`: string): *[Section](_pages_section_d_.section.md)*
103+
**name**(`value`: string): *[Section](_pages_section_d_.section.md)*
103104

104105
Sets the name (label) of the section. Normally not set if the i18n framework is being used
105106

106107
**Parameters:**
107108

108109
Name | Type |
109110
------ | ------ |
110-
`id` | string |
111+
`value` | string |
111112

112113
**Returns:** *[Section](_pages_section_d_.section.md)*
113114

114115
___
115116

116117
### style
117118

118-
**style**(`id`: string): *[Section](_pages_section_d_.section.md)*
119+
**style**(`style`: [SectionStyle](../enums/_pages_section_d_.sectionstyle.md)): *[Section](_pages_section_d_.section.md)*
119120

120121
Sets the session style
121122

122123
**Parameters:**
123124

124125
Name | Type |
125126
------ | ------ |
126-
`id` | string |
127+
`style` | [SectionStyle](../enums/_pages_section_d_.sectionstyle.md) |
127128

128129
**Returns:** *[Section](_pages_section_d_.section.md)*
129130

docs/classes/_smart_app_d_.smartapp.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ ___
510510

511511
**initialized**(`callback`: function): *[SmartApp](_smart_app_d_.smartapp.md)*
512512

513-
Defines a handler to be called the first time a SmartApp is installed. If not specified then the
513+
Defines a handler to be called before configuration the first time a SmartApp is installed. If not specified then the
514514
`updated()` handler will be called on the initial installation as well as updates.
515515

516516
**Parameters:**
@@ -535,7 +535,7 @@ ___
535535

536536
**installed**(`callback`: function): *[SmartApp](_smart_app_d_.smartapp.md)*
537537

538-
Defines a handler to be called the first time a SmartApp is installed. If not specified then the
538+
Defines a handler to be called after configuration the first time a SmartApp is installed. If not specified then the
539539
`updated()` handler will be called on the initial installation as well as updates.
540540

541541
**Parameters:**

docs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const smartapp = new SmartApp()
7272
context.config.contactSensor, 'contactSensor', 'contact', 'deviceEventHandler');
7373
})
7474
```
75+
* [initialized](classes/_smart_app_d_.smartapp.md#initialized)
7576
* [installed](classes/_smart_app_d_.smartapp.md#installed)
7677
* [uninstalled](classes/_smart_app_d_.smartapp.md#uninstalled)
7778
* [updated](classes/_smart_app_d_.smartapp.md#updated)

docs/interfaces/_smart_app_d_.smartappoptions.md

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [disableCustomDisplayName](_smart_app_d_.smartappoptions.md#optional-disablecustomdisplayname)
1010
* [disableRemoveApp](_smart_app_d_.smartappoptions.md#optional-disableremoveapp)
1111
* [enableEventLogging](_smart_app_d_.smartappoptions.md#optional-enableeventlogging)
12+
* [firstPageId](_smart_app_d_.smartappoptions.md#optional-firstpageid)
1213
* [jsonSpace](_smart_app_d_.smartappoptions.md#optional-jsonspace)
1314
* [keyApiHost](_smart_app_d_.smartappoptions.md#optional-keyapihost)
1415
* [keyCacheTTL](_smart_app_d_.smartappoptions.md#optional-keycachettl)
@@ -82,6 +83,15 @@ Enables logging of all lifecycle events and responses
8283

8384
___
8485

86+
### `Optional` firstPageId
87+
88+
**firstPageId**? : *string*
89+
90+
Sets the initial configuration page to be rendered when an app is installed or updated.
91+
If not specified then the first page defined will be rendered.
92+
93+
___
94+
8595
### `Optional` jsonSpace
8696

8797
**jsonSpace**? : *number*

lib/pages/section.d.ts

+34-31
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import {Page} from './page'
2-
3-
import {BooleanSetting} from './boolean-setting'
4-
// import {ColorSetting} from './color-setting'
5-
import {DecimalSetting} from './decimal-setting'
6-
import {DeviceSetting} from './device-setting'
7-
import {EmailSetting} from './email-setting'
8-
import {EnumSetting} from './enum-setting'
9-
import {ImageSetting} from './image-setting'
10-
// import {ImagesSetting} from './images-setting'
11-
import {LinkSetting} from './link-setting'
12-
// import {MessageGroupSetting} from './message-group-setting'
13-
import {ModeSetting} from './mode-setting'
14-
import {NumberSetting} from './number-setting'
15-
import {OAuthSetting} from './oauth-setting'
16-
import {PageSetting} from './page-setting'
17-
import {ParagraphSetting} from './paragraph-setting'
18-
import {PasswordSetting} from './password-setting'
19-
import {PhoneSetting} from './phone-setting'
20-
import {SceneSetting} from './scene-setting'
21-
import {SecuritySetting} from './security-setting'
22-
import {SoundSetting} from './sound-setting'
23-
import {TextSetting} from './text-setting'
24-
import {TimeSetting} from './time-setting'
25-
import {VideoSetting} from './video-setting'
1+
import { Page } from './page'
2+
3+
import { BooleanSetting } from './boolean-setting'
4+
// import { ColorSetting } from './color-setting'
5+
import { DecimalSetting } from './decimal-setting'
6+
import { DeviceSetting } from './device-setting'
7+
import { EmailSetting } from './email-setting'
8+
import { EnumSetting } from './enum-setting'
9+
import { ImageSetting } from './image-setting'
10+
import { ImagesSetting } from './images-setting'
11+
import { LinkSetting } from './link-setting'
12+
// import { MessageGroupSetting } from './message-group-setting'
13+
import { ModeSetting } from './mode-setting'
14+
import { NumberSetting } from './number-setting'
15+
import { OAuthSetting } from './oauth-setting'
16+
import { PageSetting } from './page-setting'
17+
import { ParagraphSetting } from './paragraph-setting'
18+
import { PasswordSetting } from './password-setting'
19+
import { PhoneSetting } from './phone-setting'
20+
import { SceneSetting } from './scene-setting'
21+
import { SecuritySetting } from './security-setting'
22+
import { SoundSetting } from './sound-setting'
23+
import { TextSetting } from './text-setting'
24+
import { TimeSetting } from './time-setting'
25+
import { VideoSetting } from './video-setting'
2626

2727
export enum SectionStyle {
2828
NORMAL = 'NORMAL',
@@ -54,27 +54,27 @@ export class Section {
5454
/**
5555
* Sets the name (label) of the section. Normally not set if the i18n framework is being used
5656
*/
57-
name(id: string): Section
57+
name(value: string): Section
5858

5959
/**
6060
* Specifies that the section should initially be hidden
6161
*/
62-
hidden(id: string): Section
62+
hidden(value: boolean): Section
6363

6464
/**
6565
* Specifies that the section should be able to be hidden (though not initially hidden)
6666
*/
67-
hideable(id: string): Section
67+
hideable(value: boolean): Section
6868

6969
/**
7070
* Sets the session style
7171
*/
72-
style(id: string): Section
72+
style(style: SectionStyle): Section
7373

7474
/**
7575
* Specifies that all settings in the session should default to being required
7676
*/
77-
defaultRequired(id: string): Section
77+
defaultRequired(defaultRequired: boolean): Section
7878

7979
/**
8080
* Creates a new boolean setting
@@ -108,7 +108,10 @@ export class Section {
108108
*/
109109
imageSetting(id: string): ImageSetting
110110

111-
// imagesSetting(id: string): ImagesSetting
111+
/**
112+
* Creates a new images setting
113+
*/
114+
imagesSetting(id: string): ImagesSetting
112115

113116
/**
114117
* Creates a new link setting

lib/pages/section.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ module.exports = class Section {
334334
/**
335335
* Change how the section is presented
336336
*
337-
* @param {('NORMAL'|'FOOTER')} style Section style
337+
* @param {('NORMAL'|'SPLASH')} style Section style
338338
* @default "NORMAL"
339339
* @returns {Section} Section instance
340340
*/

lib/smart-app.d.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ export interface SmartAppOptions {
119119
* Catch and log any unhandled rejections. Defaults to true
120120
*/
121121
logUnhandledRejections?: boolean
122+
123+
/**
124+
* Sets the initial configuration page to be rendered when an app is installed or updated.
125+
* If not specified then the first page defined will be rendered.
126+
*/
127+
firstPageId?: string
122128
}
123129

124130
/**
@@ -382,7 +388,7 @@ export class SmartApp {
382388
handleOAuthCallback(request: WebHookRequest): Promise<ContextRecord>
383389

384390
/**
385-
* Defines a handler to be called the first time a SmartApp is installed. If not specified then the
391+
* Defines a handler to be called before configuration the first time a SmartApp is installed. If not specified then the
386392
* `updated()` handler will be called on the initial installation as well as updates.
387393
*/
388394
initialized(callback: (
@@ -392,7 +398,7 @@ export class SmartApp {
392398
HandlerResponse): SmartApp
393399

394400
/**
395-
* Defines a handler to be called the first time a SmartApp is installed. If not specified then the
401+
* Defines a handler to be called after configuration the first time a SmartApp is installed. If not specified then the
396402
* `updated()` handler will be called on the initial installation as well as updates.
397403
*/
398404
installed(callback: (context: SmartAppContext, installData: AppEvent.InstallData) => HandlerResponse): SmartApp

lib/smart-app.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
const i18n = require('i18n')
44
const fs = require('fs-extra')
5-
const {Mutex} = require('async-mutex')
6-
const {SmartThingsOAuthClient} = require('@smartthings/core-sdk')
5+
const { Mutex } = require('async-mutex')
6+
const { SmartThingsOAuthClient } = require('@smartthings/core-sdk')
77
const Authorizer = require('./util/authorizer')
88
const responders = require('./util/responders')
99
const SmartAppContext = require('./util/smart-app-context')
@@ -816,4 +816,3 @@ class SmartApp {
816816

817817
module.exports = SmartApp
818818
module.exports.SmartApp = SmartApp
819-

lib/util/initialization.d.ts

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
export class Initialization {
2-
firstPageId(value: string)
3-
permissions(value: string | string[])
4-
disableCustomDisplayName(value?: boolean)
5-
disableRemoveApp(value?: boolean)
2+
/***
3+
* @see {@link SmartApp.firstPageId}
4+
*/
5+
firstPageId(value: string): Initialization
6+
7+
/***
8+
* @see {@link SmartApp.permissions}
9+
*/
10+
permissions(value: string | string[]): Initialization
11+
12+
/***
13+
* @see {@link SmartApp.disableCustomDisplayName}
14+
*/
15+
disableCustomDisplayName(value?: boolean): Initialization
16+
17+
/***
18+
* @see {@link SmartApp.disableRemoveApp}
19+
*/
20+
disableRemoveApp(value?: boolean): Initialization
621
}

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/docgen-post-process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const enumsOutDir = path.join(outDir, 'enums')
1515
const interfacesInDir = path.join(srcDir, 'interfaces')
1616
const interfacesOutDir = path.join(outDir, 'interfaces')
1717

18-
function processSmartAppClass() {
18+
function processSmartAppClass() {
1919
let text = fs.readFileSync(smartAppInFile, 'UTF-8')
2020
const lines = text.split('\n')
2121
let skip = false

0 commit comments

Comments
 (0)