@azure/communication-phone-numbers 1.3.0-beta.1 → 1.3.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -195,16 +195,11 @@ export class SipRoutingClient {
195
195
  return __asyncGenerator(this, arguments, function* listRoutesPagingAll_1() {
196
196
  var _a, e_1, _b, _c;
197
197
  try {
198
- for (var _d = true, _e = __asyncValues(this.listRoutesPagingPage(options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
198
+ for (var _d = true, _e = __asyncValues(this.listRoutesPagingPage(options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
199
199
  _c = _f.value;
200
200
  _d = false;
201
- try {
202
- const page = _c;
203
- yield __await(yield* __asyncDelegator(__asyncValues(page)));
204
- }
205
- finally {
206
- _d = true;
207
- }
201
+ const page = _c;
202
+ yield __await(yield* __asyncDelegator(__asyncValues(page)));
208
203
  }
209
204
  }
210
205
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -220,16 +215,11 @@ export class SipRoutingClient {
220
215
  return __asyncGenerator(this, arguments, function* listTrunksPagingAll_1() {
221
216
  var _a, e_2, _b, _c;
222
217
  try {
223
- for (var _d = true, _e = __asyncValues(this.listTrunksPagingPage(options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
218
+ for (var _d = true, _e = __asyncValues(this.listTrunksPagingPage(options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
224
219
  _c = _f.value;
225
220
  _d = false;
226
- try {
227
- const page = _c;
228
- yield __await(yield* __asyncDelegator(__asyncValues(page)));
229
- }
230
- finally {
231
- _d = true;
232
- }
221
+ const page = _c;
222
+ yield __await(yield* __asyncDelegator(__asyncValues(page)));
233
223
  }
234
224
  }
235
225
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1 +1 @@
1
- {"version":3,"file":"sipRoutingClient.js","sourceRoot":"","sources":["../../src/sipRoutingClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,E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B,CAAC,OAA2B,CAAC,CAAA,CAAC;YAC5E,oBAAM,SAAS,CAAA,CAAC;QAClB,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { logger } from \"./utils\";\nimport { SipRoutingClient as SipRoutingGeneratedClient } from \"./generated/src/siprouting/sipRoutingClient\";\nimport { SipConfigurationUpdate, SipRoutingError } from \"./generated/src/siprouting/models\";\nimport { ListSipRoutesOptions, ListSipTrunksOptions, SipTrunk, SipTrunkRoute } from \"./models\";\nimport { transformFromRestModel, transformIntoRestModel } from \"./mappers\";\nimport { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"./generated/src/tracing\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nexport * from \"./models\";\n\n/**\n * Client options used to configure the SipRoutingClient API requests.\n */\nexport interface SipRoutingClientOptions extends CommonClientOptions {}\n\n/**\n * Checks whether the type of a value is SipClientOptions or not.\n *\n * @param options - The value being checked.\n */\nconst isSipClientOptions = (options: any): options is SipRoutingClientOptions =>\n options && !isKeyCredential(options) && !isTokenCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services SIP Routing Administration.\n */\nexport class SipRoutingClient {\n /**\n * A reference to the auto-generated SipRouting HTTP client.\n */\n private readonly client: SipRoutingGeneratedClient;\n\n /**\n * Initializes a new instance of the SipRoutingClient class using a connection string.\n *\n * @param connectionString - Connection string to connect to an Azure Communication Service resource. (eg: endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret)\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: SipRoutingClientOptions);\n\n /**\n * Initializes a new instance of the SipRoutingClient class using an Azure KeyCredential.\n *\n * @param endpoint - The endpoint of the service (eg: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: SipRoutingClientOptions\n );\n\n /**\n * Initializes a new instance of the SipRoutingClient class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: SipRoutingClientOptions\n );\n\n public constructor(\n connectionStringOrUrl: string,\n credentialOrOptions?: KeyCredential | TokenCredential | SipRoutingClientOptions,\n maybeOptions: SipRoutingClientOptions = {}\n ) {\n const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);\n const options = isSipClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new SipRoutingGeneratedClient(url, {\n endpoint: url,\n ...internalPipelineOptions,\n });\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Lists the SIP trunks.\n * @param options - The options parameters.\n */\n public listTrunks(options: ListSipTrunksOptions = {}): PagedAsyncIterableIterator<SipTrunk> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"SipRoutingClient-listTrunks\",\n options\n );\n\n try {\n const iter = this.listTrunksPagingAll({ ...updatedOptions });\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return this.listTrunksPagingPage({ ...updatedOptions });\n },\n };\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Gets the SIP trunk.\n * @param fqdn - The trunk's FQDN.\n * @param options - The options parameters.\n */\n public async getTrunk(fqdn: string, options: OperationOptions = {}): Promise<SipTrunk> {\n return tracingClient.withSpan(\"SipRoutingClient-getTrunk\", options, async (updatedOptions) => {\n const trunks = await this.getTrunksInternal(updatedOptions);\n const trunk = trunks.find((value: SipTrunk) => value.fqdn === fqdn);\n if (trunk) {\n return trunk;\n }\n throw { code: \"NotFound\", message: \"Not Found\" } as SipRoutingError;\n });\n }\n\n /**\n * Lists the SIP trunk routes.\n * @param options - The options parameters.\n */\n public listRoutes(options: ListSipRoutesOptions = {}): PagedAsyncIterableIterator<SipTrunkRoute> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"SipRoutingClient-listRoutes\",\n options\n );\n\n try {\n const iter = this.listRoutesPagingAll({ ...updatedOptions });\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return this.listRoutesPagingPage({ ...updatedOptions });\n },\n };\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Sets the SIP trunks.\n * @param trunks - The SIP trunks to be set.\n * @param options - The options parameters.\n */\n public async setTrunks(trunks: SipTrunk[], options: OperationOptions = {}): Promise<SipTrunk[]> {\n return tracingClient.withSpan(\"SipRoutingClient-setTrunks\", options, async (updatedOptions) => {\n const patch: SipConfigurationUpdate = { trunks: transformIntoRestModel(trunks) };\n let config = await this.client.sipRouting.get(updatedOptions);\n const storedFqdns = transformFromRestModel(config.trunks).map((trunk) => trunk.fqdn);\n const setFqdns = trunks.map((trunk) => trunk.fqdn);\n storedFqdns.forEach((storedFqdn) => {\n const shouldDeleteStoredTrunk = !setFqdns.find((value) => value === storedFqdn);\n if (shouldDeleteStoredTrunk) {\n patch.trunks![storedFqdn] = null;\n }\n });\n\n const isPatchNeeded = Object.keys(patch.trunks!).length > 0;\n if (isPatchNeeded) {\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n config = await this.client.sipRouting.update(payload);\n }\n\n return transformFromRestModel(config.trunks);\n });\n }\n\n /**\n * Sets the SIP trunk.\n * @param trunk - The SIP trunk to be set.\n * @param options - The options parameters.\n */\n public async setTrunk(trunk: SipTrunk, options: OperationOptions = {}): Promise<SipTrunk> {\n return tracingClient.withSpan(\"SipRoutingClient-setTrunk\", options, async (updatedOptions) => {\n const patch: SipConfigurationUpdate = {\n trunks: transformIntoRestModel([trunk]),\n };\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n const config = await this.client.sipRouting.update(payload);\n const storedTrunk = transformFromRestModel(config.trunks).find(\n (value: SipTrunk) => value.fqdn === trunk.fqdn\n );\n if (storedTrunk) {\n return storedTrunk;\n }\n\n throw { code: \"NotFound\", message: \"Not Found\" } as SipRoutingError;\n });\n }\n\n /**\n * Sets the SIP trunk routes.\n * @param routes - The SIP trunk routes to be set.\n * @param options - The options parameters.\n */\n public async setRoutes(\n routes: SipTrunkRoute[],\n options: OperationOptions = {}\n ): Promise<SipTrunkRoute[]> {\n return tracingClient.withSpan(\"SipRoutingClient-setRoutes\", options, async (updatedOptions) => {\n const patch: SipConfigurationUpdate = {\n routes: routes,\n };\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n const config = await this.client.sipRouting.update(payload);\n const storedRoutes = config.routes || (await this.getRoutesInternal(updatedOptions));\n return storedRoutes;\n });\n }\n\n /**\n * Deletes the SIP trunk.\n * @param fqdn - The trunk's FQDN.\n * @param options - The options parameters.\n */\n public async deleteTrunk(fqdn: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"SipRoutingClient-deleteTrunk\",\n options,\n async (updatedOptions) => {\n const trunks: any = {};\n trunks[fqdn] = null;\n const patch: SipConfigurationUpdate = {\n trunks: trunks,\n };\n\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n await this.client.sipRouting.update(payload);\n }\n );\n }\n\n private async getRoutesInternal(options: OperationOptions): Promise<SipTrunkRoute[]> {\n const config = await this.client.sipRouting.get(options);\n return config.routes || [];\n }\n\n private async getTrunksInternal(options: OperationOptions): Promise<SipTrunk[]> {\n const config = await this.client.sipRouting.get(options);\n return transformFromRestModel(config.trunks);\n }\n\n private async *listRoutesPagingAll(\n options?: ListSipRoutesOptions\n ): AsyncIterableIterator<SipTrunkRoute> {\n for await (const page of this.listRoutesPagingPage(options)) {\n yield* page;\n }\n }\n\n private async *listTrunksPagingAll(\n options?: ListSipTrunksOptions\n ): AsyncIterableIterator<SipTrunk> {\n for await (const page of this.listTrunksPagingPage(options)) {\n yield* page;\n }\n }\n\n private async *listTrunksPagingPage(\n options: ListSipTrunksOptions = {}\n ): AsyncIterableIterator<SipTrunk[]> {\n const apiResult = await this.getTrunksInternal(options as OperationOptions);\n yield apiResult;\n }\n\n private async *listRoutesPagingPage(\n options: ListSipRoutesOptions = {}\n ): AsyncIterableIterator<SipTrunkRoute[]> {\n const apiResult = await this.getRoutesInternal(options as OperationOptions);\n yield apiResult;\n }\n}\n"]}
1
+ {"version":3,"file":"sipRoutingClient.js","sourceRoot":"","sources":["../../src/sipRoutingClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,gBAAgB,IAAI,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAG5G,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,cAAc,UAAU,CAAC;AAOzB;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,OAAY,EAAsC,EAAE,CAC9E,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,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OAAO,CAAC,CAAA,IAAA,+DAAE;oBAApC,cAAkC;oBAAlC,WAAkC;oBAAhD,MAAM,IAAI,KAAA,CAAA;oBACnB,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAAI,CAAA,CAAA,CAAA,CAAC;iBACb;;;;;;;;;QACH,CAAC;KAAA;IAEc,mBAAmB,CAChC,OAA8B;;;;gBAE9B,KAAyB,eAAA,KAAA,cAAA,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA,IAAA,+DAAE;oBAApC,cAAkC;oBAAlC,WAAkC;oBAAhD,MAAM,IAAI,KAAA,CAAA;oBACnB,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAAI,CAAA,CAAA,CAAA,CAAC;iBACb;;;;;;;;;QACH,CAAC;KAAA;IAEc,oBAAoB,CACjC,UAAgC,EAAE;;YAElC,MAAM,SAAS,GAAG,cAAM,IAAI,CAAC,iBAAiB,CAAC,OAA2B,CAAC,CAAA,CAAC;YAC5E,oBAAM,SAAS,CAAA,CAAC;QAClB,CAAC;KAAA;IAEc,oBAAoB,CACjC,UAAgC,EAAE;;YAElC,MAAM,SAAS,GAAG,cAAM,IAAI,CAAC,iBAAiB,CAAC,OAA2B,CAAC,CAAA,CAAC;YAC5E,oBAAM,SAAS,CAAA,CAAC;QAClB,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { logger } from \"./utils\";\nimport { SipRoutingClient as SipRoutingGeneratedClient } from \"./generated/src/siprouting/sipRoutingClient\";\nimport { SipConfigurationUpdate, SipRoutingError } from \"./generated/src/siprouting/models\";\nimport { ListSipRoutesOptions, ListSipTrunksOptions, SipTrunk, SipTrunkRoute } from \"./models\";\nimport { transformFromRestModel, transformIntoRestModel } from \"./mappers\";\nimport { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"./generated/src/tracing\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nexport * from \"./models\";\n\n/**\n * Client options used to configure the SipRoutingClient API requests.\n */\nexport interface SipRoutingClientOptions extends CommonClientOptions {}\n\n/**\n * Checks whether the type of a value is SipClientOptions or not.\n *\n * @param options - The value being checked.\n */\nconst isSipClientOptions = (options: any): options is SipRoutingClientOptions =>\n options && !isKeyCredential(options) && !isTokenCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services SIP Routing Administration.\n */\nexport class SipRoutingClient {\n /**\n * A reference to the auto-generated SipRouting HTTP client.\n */\n private readonly client: SipRoutingGeneratedClient;\n\n /**\n * Initializes a new instance of the SipRoutingClient class using a connection string.\n *\n * @param connectionString - Connection string to connect to an Azure Communication Service resource. (eg: endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret)\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: SipRoutingClientOptions);\n\n /**\n * Initializes a new instance of the SipRoutingClient class using an Azure KeyCredential.\n *\n * @param endpoint - The endpoint of the service (eg: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: SipRoutingClientOptions\n );\n\n /**\n * Initializes a new instance of the SipRoutingClient class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: SipRoutingClientOptions\n );\n\n public constructor(\n connectionStringOrUrl: string,\n credentialOrOptions?: KeyCredential | TokenCredential | SipRoutingClientOptions,\n maybeOptions: SipRoutingClientOptions = {}\n ) {\n const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);\n const options = isSipClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new SipRoutingGeneratedClient(url, {\n endpoint: url,\n ...internalPipelineOptions,\n });\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Lists the SIP trunks.\n * @param options - The options parameters.\n */\n public listTrunks(options: ListSipTrunksOptions = {}): PagedAsyncIterableIterator<SipTrunk> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"SipRoutingClient-listTrunks\",\n options\n );\n\n try {\n const iter = this.listTrunksPagingAll({ ...updatedOptions });\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return this.listTrunksPagingPage({ ...updatedOptions });\n },\n };\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Gets the SIP trunk.\n * @param fqdn - The trunk's FQDN.\n * @param options - The options parameters.\n */\n public async getTrunk(fqdn: string, options: OperationOptions = {}): Promise<SipTrunk> {\n return tracingClient.withSpan(\"SipRoutingClient-getTrunk\", options, async (updatedOptions) => {\n const trunks = await this.getTrunksInternal(updatedOptions);\n const trunk = trunks.find((value: SipTrunk) => value.fqdn === fqdn);\n if (trunk) {\n return trunk;\n }\n throw { code: \"NotFound\", message: \"Not Found\" } as SipRoutingError;\n });\n }\n\n /**\n * Lists the SIP trunk routes.\n * @param options - The options parameters.\n */\n public listRoutes(options: ListSipRoutesOptions = {}): PagedAsyncIterableIterator<SipTrunkRoute> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"SipRoutingClient-listRoutes\",\n options\n );\n\n try {\n const iter = this.listRoutesPagingAll({ ...updatedOptions });\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return this.listRoutesPagingPage({ ...updatedOptions });\n },\n };\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Sets the SIP trunks.\n * @param trunks - The SIP trunks to be set.\n * @param options - The options parameters.\n */\n public async setTrunks(trunks: SipTrunk[], options: OperationOptions = {}): Promise<SipTrunk[]> {\n return tracingClient.withSpan(\"SipRoutingClient-setTrunks\", options, async (updatedOptions) => {\n const patch: SipConfigurationUpdate = { trunks: transformIntoRestModel(trunks) };\n let config = await this.client.sipRouting.get(updatedOptions);\n const storedFqdns = transformFromRestModel(config.trunks).map((trunk) => trunk.fqdn);\n const setFqdns = trunks.map((trunk) => trunk.fqdn);\n storedFqdns.forEach((storedFqdn) => {\n const shouldDeleteStoredTrunk = !setFqdns.find((value) => value === storedFqdn);\n if (shouldDeleteStoredTrunk) {\n patch.trunks![storedFqdn] = null;\n }\n });\n\n const isPatchNeeded = Object.keys(patch.trunks!).length > 0;\n if (isPatchNeeded) {\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n config = await this.client.sipRouting.update(payload);\n }\n\n return transformFromRestModel(config.trunks);\n });\n }\n\n /**\n * Sets the SIP trunk.\n * @param trunk - The SIP trunk to be set.\n * @param options - The options parameters.\n */\n public async setTrunk(trunk: SipTrunk, options: OperationOptions = {}): Promise<SipTrunk> {\n return tracingClient.withSpan(\"SipRoutingClient-setTrunk\", options, async (updatedOptions) => {\n const patch: SipConfigurationUpdate = {\n trunks: transformIntoRestModel([trunk]),\n };\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n const config = await this.client.sipRouting.update(payload);\n const storedTrunk = transformFromRestModel(config.trunks).find(\n (value: SipTrunk) => value.fqdn === trunk.fqdn\n );\n if (storedTrunk) {\n return storedTrunk;\n }\n\n throw { code: \"NotFound\", message: \"Not Found\" } as SipRoutingError;\n });\n }\n\n /**\n * Sets the SIP trunk routes.\n * @param routes - The SIP trunk routes to be set.\n * @param options - The options parameters.\n */\n public async setRoutes(\n routes: SipTrunkRoute[],\n options: OperationOptions = {}\n ): Promise<SipTrunkRoute[]> {\n return tracingClient.withSpan(\"SipRoutingClient-setRoutes\", options, async (updatedOptions) => {\n const patch: SipConfigurationUpdate = {\n routes: routes,\n };\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n const config = await this.client.sipRouting.update(payload);\n const storedRoutes = config.routes || (await this.getRoutesInternal(updatedOptions));\n return storedRoutes;\n });\n }\n\n /**\n * Deletes the SIP trunk.\n * @param fqdn - The trunk's FQDN.\n * @param options - The options parameters.\n */\n public async deleteTrunk(fqdn: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"SipRoutingClient-deleteTrunk\",\n options,\n async (updatedOptions) => {\n const trunks: any = {};\n trunks[fqdn] = null;\n const patch: SipConfigurationUpdate = {\n trunks: trunks,\n };\n\n const payload = {\n ...updatedOptions,\n ...patch,\n };\n await this.client.sipRouting.update(payload);\n }\n );\n }\n\n private async getRoutesInternal(options: OperationOptions): Promise<SipTrunkRoute[]> {\n const config = await this.client.sipRouting.get(options);\n return config.routes || [];\n }\n\n private async getTrunksInternal(options: OperationOptions): Promise<SipTrunk[]> {\n const config = await this.client.sipRouting.get(options);\n return transformFromRestModel(config.trunks);\n }\n\n private async *listRoutesPagingAll(\n options?: ListSipRoutesOptions\n ): AsyncIterableIterator<SipTrunkRoute> {\n for await (const page of this.listRoutesPagingPage(options)) {\n yield* page;\n }\n }\n\n private async *listTrunksPagingAll(\n options?: ListSipTrunksOptions\n ): AsyncIterableIterator<SipTrunk> {\n for await (const page of this.listTrunksPagingPage(options)) {\n yield* page;\n }\n }\n\n private async *listTrunksPagingPage(\n options: ListSipTrunksOptions = {}\n ): AsyncIterableIterator<SipTrunk[]> {\n const apiResult = await this.getTrunksInternal(options as OperationOptions);\n yield apiResult;\n }\n\n private async *listRoutesPagingPage(\n options: ListSipRoutesOptions = {}\n ): AsyncIterableIterator<SipTrunkRoute[]> {\n const apiResult = await this.getRoutesInternal(options as OperationOptions);\n yield apiResult;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/communication-phone-numbers",
3
- "version": "1.3.0-beta.1",
3
+ "version": "1.3.0-beta.2",
4
4
  "description": "SDK for Azure Communication service which facilitates phone number management.",
5
5
  "sdk-type": "client",
6
6
  "main": "dist/index.js",
@@ -48,7 +48,7 @@
48
48
  "author": "Microsoft Corporation",
49
49
  "license": "MIT",
50
50
  "engines": {
51
- "node": ">=14.0.0"
51
+ "node": ">=18.0.0"
52
52
  },
53
53
  "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-phone-numbers/",
54
54
  "repository": "github:Azure/azure-sdk-for-js",
@@ -78,12 +78,12 @@
78
78
  "@azure/test-utils": "^1.0.0",
79
79
  "@azure-tools/test-credential": "^1.0.0",
80
80
  "@azure-tools/test-recorder": "^3.0.0",
81
- "@azure/identity": "^2.0.1",
81
+ "@azure/identity": "^3.3.0",
82
82
  "@microsoft/api-extractor": "^7.31.1",
83
83
  "@types/chai": "^4.1.6",
84
- "@types/mocha": "^7.0.2",
85
- "@types/sinon": "^9.0.4",
86
- "@types/node": "^14.0.0",
84
+ "@types/mocha": "^10.0.0",
85
+ "@types/sinon": "^17.0.0",
86
+ "@types/node": "^18.0.0",
87
87
  "@types/uuid": "^8.0.0",
88
88
  "chai": "^4.2.0",
89
89
  "cross-env": "^7.0.2",
@@ -100,12 +100,14 @@
100
100
  "karma-sourcemap-loader": "^0.3.8",
101
101
  "karma": "^6.2.0",
102
102
  "mocha-junit-reporter": "^2.0.0",
103
- "mocha": "^7.1.1",
104
- "nyc": "^15.0.0",
103
+ "mocha": "^10.0.0",
104
+ "c8": "^8.0.0",
105
105
  "prettier": "^2.5.1",
106
106
  "rimraf": "^3.0.0",
107
- "sinon": "^9.0.2",
108
- "typescript": "~5.0.0"
107
+ "sinon": "^17.0.0",
108
+ "typescript": "~5.2.0",
109
+ "ts-node": "^10.0.0",
110
+ "esm": "^3.2.18"
109
111
  },
110
112
  "//metadata": {
111
113
  "constantPaths": [
@@ -146,7 +148,8 @@
146
148
  },
147
149
  "skip": [
148
150
  "purchasePhoneNumber.js",
149
- "releasePhoneNumber.js"
151
+ "releasePhoneNumber.js",
152
+ "manageSipRoutingConfiguration.js"
150
153
  ]
151
154
  }
152
155
  }
@@ -103,9 +103,13 @@ export declare interface OperatorDetails {
103
103
  export declare interface OperatorInformation {
104
104
  /** E.164 formatted string representation of the phone number */
105
105
  phoneNumber?: string;
106
+ /** National format of the phone number */
107
+ nationalFormat?: string;
108
+ /** International format of the phone number */
109
+ internationalFormat?: string;
106
110
  /** Type of service associated with the phone number */
107
111
  numberType?: OperatorNumberType;
108
- /** ISO country code associated with the phone number. */
112
+ /** ISO 3166-1 two character ('alpha-2') code associated with the phone number. */
109
113
  isoCountryCode?: string;
110
114
  /** Represents metadata describing the operator of a phone number */
111
115
  operatorDetails?: OperatorDetails;
@@ -540,6 +544,7 @@ export declare interface SearchAvailablePhoneNumbersRequest extends PhoneNumberS
540
544
  * Additional options for the search operator information request.
541
545
  */
542
546
  export declare interface SearchOperatorInformationOptions extends OperationOptions {
547
+ formatOnly: boolean;
543
548
  }
544
549
 
545
550
  /**