@@ -17,7 +17,7 @@ import Context from './context.ts';
17
17
*/
18
18
export default class Tpy {
19
19
/**
20
- * The specified deployment ID used for deployment ID entries as a default .
20
+ * A default deployment ID used to occupy `deploymentID` parameter entries .
21
21
*/
22
22
readonly deploymentID ?: StringifiedNumber ;
23
23
private readonly token : string ;
@@ -95,7 +95,7 @@ export default class Tpy {
95
95
* Gets the deployment information.
96
96
*
97
97
* @param deploymentID The ID of the deployment to get. If empty, the function
98
- * will use the set deploymentID in the class. (`this.deploymentID`)
98
+ * will use the set { @linkcode Tpy. deploymentID} in the class.
99
99
*/
100
100
async getDeployment ( deploymentID ?: StringifiedNumber ) {
101
101
const dID = deploymentID || this . deploymentID ;
@@ -120,16 +120,27 @@ export default class Tpy {
120
120
* Makes a POST request to publish a deployment; returns details
121
121
* of the new deployment.
122
122
*
123
- * @param id The script/deployment ID to publish to.
123
+ * @param deploymentID The script/deployment ID to publish to. If empty, the function
124
+ * will use the set {@linkcode Tpy.deploymentID} in the class.
124
125
* @param body Project specifications.
125
126
*/
126
127
async publishDeployment (
127
- id : StringifiedNumber ,
128
128
body : Deployment . POST . Request < false > ,
129
+ deploymentID ?: StringifiedNumber ,
129
130
) {
131
+ const dID = deploymentID || this . deploymentID ;
132
+ if ( ! ( dID ) ) {
133
+ throw new TpyError (
134
+ 'Missing or Invalid Required Parameter' ,
135
+ parametersPrompt ( 'missing' , [ 'deploymentID' , 'this.deploymentID' ] ) ,
136
+ [ 'deploymentID' , 'this.deploymentID' ] . join ( ', ' ) ,
137
+ dID ,
138
+ ) ;
139
+ }
140
+
130
141
return await this . httpRaw < Deployment . POST . Response > (
131
- new Context ( { deploymentID : id } ) ,
132
- `/deployments/${ id } ` ,
142
+ new Context ( { deploymentID : dID } ) ,
143
+ `/deployments/${ dID } ` ,
133
144
'POST' ,
134
145
{
135
146
body : JSON . stringify ( body ) ,
@@ -165,15 +176,17 @@ export default class Tpy {
165
176
/**
166
177
* Connects to the Pylon workbench WebSocket.
167
178
*
168
- * @param id The deployment ID to follow the WebSocket when it disconnects.
179
+ * @param deploymentID The deployment ID to follow the WebSocket when it disconnects. If empty, the function
180
+ * will use the set {@linkcode Tpy.deploymentID} in the class.
169
181
*/
170
- connectSocket ( id : StringifiedNumber ) {
171
- return new TpyWs ( this , id ) ;
182
+ connectSocket ( deploymentID : StringifiedNumber ) {
183
+ return new TpyWs ( this , deploymentID ) ;
172
184
}
173
185
174
186
/**
175
187
* Gets all the namespaces under the given deployment ID.
176
- * @param deploymentID The deployment ID to look under.
188
+ * @param deploymentID The deployment ID to look under. If empty, the function
189
+ * will use the set {@linkcode Tpy.deploymentID} in the class.
177
190
*/
178
191
async getNamespaces ( deploymentID ?: StringifiedNumber ) {
179
192
const dID = deploymentID || this . deploymentID ;
@@ -193,8 +206,9 @@ export default class Tpy {
193
206
194
207
/**
195
208
* Gets all the namespace items under the given deployment ID.
196
- * @param deploymentID The deployment ID to look under.
197
209
* @param namespace The namespace to look under.
210
+ * @param deploymentID The deployment ID to look under. If empty, the function
211
+ * will use the set {@linkcode Tpy.deploymentID} in the class.
198
212
*
199
213
* @template T The type of the `value` object inside {@linkcode Pylon.KV.GET.ItemsFlattened}.
200
214
*/
@@ -238,8 +252,9 @@ export default class Tpy {
238
252
239
253
/**
240
254
* Creates a new {@link TpyKV} instantiation, much like the Pylon SDK's KVNamespace class.
241
- * @param deploymentID The deployment ID to look under.
242
255
* @param namespace The namespace to look under.
256
+ * @param deploymentID The deployment ID to look under. If empty, the function
257
+ * will use the set {@linkcode Tpy.deploymentID} in the class.
243
258
*/
244
259
KV (
245
260
namespace : string ,
0 commit comments