@@ -43,7 +43,7 @@ export class DbConnect {
4343 * @param clientId recommended, client id of the Access policy for your host.
4444 * @param clientSecret recommended, client secret of the Access policy for your host.
4545 */
46- constructor ( parameters : DbConnectInit | object ) {
46+ constructor ( parameters : DbConnectOptions ) {
4747 const init = new DbConnectInit ( parameters )
4848
4949 const url = new URL ( init . host )
@@ -101,7 +101,7 @@ export class DbConnect {
101101 *
102102 * @param command required, the command to submit.
103103 */
104- public async submit ( command : Command | object ) : Promise < Response > {
104+ public async submit ( command : Command | CommandOptions ) : Promise < Response > {
105105 if ( ! ( command instanceof Command ) ) command = new Command ( command )
106106 const cmd = < Command > command
107107
@@ -116,17 +116,28 @@ export class DbConnect {
116116
117117}
118118
119+ /**
120+ * Options provided to DbConnect.
121+ *
122+ * @see DbConnect
123+ */
124+ export interface DbConnectOptions {
125+ host : string
126+ clientId ?: string
127+ clientSecret ?: string
128+ }
129+
119130/**
120131 * Initializer for DbConnect with host and credentials.
121132 *
122133 * @see DbConnect
123134 */
124- class DbConnectInit {
135+ class DbConnectInit implements DbConnectOptions {
125136 host : string
126137 clientId ?: string
127138 clientSecret ?: string
128139
129- constructor ( parameters : object ) {
140+ constructor ( parameters : DbConnectOptions ) {
130141 Object . assign ( this , parameters )
131142
132143 if ( ! this . host ) throw new TypeError ( 'host is a required argument' )
@@ -135,12 +146,34 @@ class DbConnectInit {
135146 }
136147}
137148
149+ /**
150+ * Arguments used in statement provided to Command.
151+ *
152+ * @see Command
153+ */
154+ export type CommandArgumentType = { [ key : string ] : any } | any [ ]
155+
156+ /**
157+ * Options provided to Command.
158+ *
159+ * @see Command
160+ */
161+ export interface CommandOptions {
162+ statement : string
163+ arguments ?: CommandArgumentType
164+ mode ?: Mode
165+ isolation ?: Isolation
166+ timeout ?: number
167+ cacheTtl ?: number
168+ staleTtl ?: number
169+ }
170+
138171/**
139172 * Command is a standard, non-vendor format for submitting database commands.
140173 */
141- export class Command {
174+ export class Command implements CommandOptions {
142175 readonly statement : string
143- readonly arguments : any
176+ readonly arguments : CommandArgumentType
144177 readonly mode : Mode
145178 readonly isolation : Isolation
146179 readonly timeout : number
@@ -158,7 +191,7 @@ export class Command {
158191 * @param cacheTtl number of seconds to cache responses, defaults to -1.
159192 * @param staleTtl after cacheTtl expires, number of seconds to serve stale responses.
160193 */
161- constructor ( parameters : CommandInit | object ) {
194+ constructor ( parameters : CommandOptions ) {
162195 const init = new CommandInit ( parameters )
163196
164197 Object . assign ( this , init )
@@ -170,16 +203,16 @@ export class Command {
170203 *
171204 * @see Command
172205 */
173- class CommandInit {
206+ class CommandInit implements CommandOptions {
174207 statement : string
175- arguments ?: any
208+ arguments ?: CommandArgumentType
176209 mode ?: Mode
177210 isolation ?: Isolation
178211 timeout ?: number
179212 cacheTtl ?: number
180213 staleTtl ?: number
181214
182- constructor ( parameters : object ) {
215+ constructor ( parameters : CommandOptions ) {
183216 Object . assign ( this , parameters )
184217
185218 if ( ! this . statement ) throw new TypeError ( 'statement is a required argument' )
0 commit comments