diff --git a/.changeset/spicy-buckets-count.md b/.changeset/spicy-buckets-count.md new file mode 100644 index 00000000..b4c3e155 --- /dev/null +++ b/.changeset/spicy-buckets-count.md @@ -0,0 +1,6 @@ +--- +"@twilio-labs/serverless-api": minor +"@twilio-labs/plugin-serverless": minor +--- + +Adding UiEditable param to createService diff --git a/packages/plugin-serverless/src/utils.js b/packages/plugin-serverless/src/utils.js index a9fbc85a..20359871 100644 --- a/packages/plugin-serverless/src/utils.js +++ b/packages/plugin-serverless/src/utils.js @@ -80,6 +80,7 @@ function createExternalCliOptions(flags, twilioClient) { const pluginInfo = { version: pkgJson.version, name: pkgJson.name, + uiEditable: pkgJson.uiEditable, }; if ( diff --git a/packages/serverless-api/src/api/services.ts b/packages/serverless-api/src/api/services.ts index 55f41b6f..81c0eefe 100644 --- a/packages/serverless-api/src/api/services.ts +++ b/packages/serverless-api/src/api/services.ts @@ -14,11 +14,13 @@ const log = debug('twilio-serverless-api:services'); * @export * @param {string} serviceName the unique name for the service * @param {TwilioServerlessApiClient} client API client + * @param {boolean} uiEditable Whether the Service's properties and subresources can be edited via the UI. The default value is false. * @returns {Promise} */ export async function createService( serviceName: string, - client: TwilioServerlessApiClient + client: TwilioServerlessApiClient, + uiEditable: boolean = false ): Promise { try { const resp = await client.request('post', 'Services', { @@ -26,9 +28,10 @@ export async function createService( UniqueName: serviceName, FriendlyName: serviceName, IncludeCredentials: true, + UiEditable: uiEditable, }, }); - const service = (resp.body as unknown) as ServiceResource; + const service = resp.body as unknown as ServiceResource; return service.sid; } catch (err) { @@ -82,7 +85,7 @@ export async function getService( ): Promise { try { const resp = await client.request('get', `Services/${sid}`); - return (resp.body as unknown) as ServiceResource; + return resp.body as unknown as ServiceResource; } catch (err) { log('%O', new ClientApiError(err)); throw err; diff --git a/packages/serverless-api/src/client.ts b/packages/serverless-api/src/client.ts index e674eae2..1774cea8 100644 --- a/packages/serverless-api/src/client.ts +++ b/packages/serverless-api/src/client.ts @@ -507,13 +507,8 @@ export class TwilioServerlessApiClient extends events.EventEmitter { */ async activateBuild(activateConfig: ActivateConfig): Promise { try { - let { - buildSid, - targetEnvironment, - serviceSid, - sourceEnvironment, - env, - } = activateConfig; + let { buildSid, targetEnvironment, serviceSid, sourceEnvironment, env } = + activateConfig; if (!buildSid && !sourceEnvironment) { const error = new Error( @@ -630,7 +625,11 @@ export class TwilioServerlessApiClient extends events.EventEmitter { message: 'Creating Service', }); try { - serviceSid = await createService(config.serviceName, this); + serviceSid = await createService( + config.serviceName, + this, + config.uiEditable + ); } catch (err) { const alternativeServiceSid = await findServiceSid( config.serviceName, diff --git a/packages/serverless-api/src/types/deploy.ts b/packages/serverless-api/src/types/deploy.ts index 3a2c353b..d9404ea6 100644 --- a/packages/serverless-api/src/types/deploy.ts +++ b/packages/serverless-api/src/types/deploy.ts @@ -47,6 +47,10 @@ type DeployProjectConfigBase = { * Version of Node.js to deploy with in Twilio Runtime. Can be "node18" */ runtime?: string; + /** + * Whether the Service's properties and subresources can be edited via the UI. The default value is false. + */ + uiEditable?: boolean; }; /** diff --git a/packages/serverless-api/src/types/serverless-api.ts b/packages/serverless-api/src/types/serverless-api.ts index b3a301a0..af9d92d1 100644 --- a/packages/serverless-api/src/types/serverless-api.ts +++ b/packages/serverless-api/src/types/serverless-api.ts @@ -48,6 +48,7 @@ export interface ServiceResource extends UpdateableResourceBase { unique_name: string; include_credentials: boolean; friendly_name: string; + ui_editable?: boolean; } export interface ServiceList extends BaseList<'services'> {