Skip to content

Commit 6e17a94

Browse files
Devon-Whitecassieembdiego-signalwire
authored
Convert Fabric APIs to TypeSpec (#373)
* Initial push * Convert all Fabric api spec to TypeSpec * add newline * Update main.tsp * Update responses.tsp * Update main.tsp * Update core.tsp * Update errors.tsp * Update requests.tsp * Push audit edits (in-progress) * Update specs/signalwire-rest/fabric-api/dialogflow-agents/addresses/models/core.tsp Co-authored-by: Cassie <[email protected]> * Add enums for Ciphers, Codecs, and Encryption in globally_shared specs - Introduced Ciphers enum with various AES cipher options. - Added Codecs enum for audio and video codecs including PCMU, PCMA, G722, G729, OPUS, VP8, and H264. - Created Encryption enum to define encryption requirements: Required, Optional, and Default. * edits * edits * edits * edits * edits * Add global constants and SIP endpoint enums - Introduced a new constant for the server URL in const.tsp. - Added an enumeration for CallHandlerType in enums.tsp, defining various call handling options. - Add pagination response for many list endpoints * Refactor API tags and documentation for SignalWire Fabric API - Introduced a new tags.tsp file to centralize tag definitions and metadata for various API endpoints. - Updated multiple API specifications to replace hardcoded tag strings with constants from the new tags.tsp file. - Enhanced OpenAPI documentation by adding summaries and descriptions for various endpoints, improving clarity and usability. - Added external documentation links for each tag to facilitate developer access to relevant resources. - Ensured consistent naming conventions across all API tags to improve readability and maintainability. * Fix bad summary * Conference Room edits * add missing fps property to conference rooms * Add redirects * Add status callback fields to CXML and SWML Scripts endpoints (#387) * Add status callback fields to CXML and SWML Scripts endpoints * Update core.tsp * Update specs/signalwire-rest/fabric-api/cxml-scripts/models/requests.tsp * Update specs/signalwire-rest/fabric-api/cxml-scripts/models/requests.tsp * Update specs/signalwire-rest/fabric-api/swml-scripts/models/requests.tsp * Update specs/signalwire-rest/fabric-api/swml-scripts/models/requests.tsp --------- Co-authored-by: Devon <[email protected]> * recompile spec after additions * Update specs/signalwire-rest/fabric-api/cxml-applications/models/requests.tsp Co-authored-by: Cassie <[email protected]> * Update specs/signalwire-rest/fabric-api/cxml-applications/models/core.tsp Co-authored-by: Cassie <[email protected]> * Update specs/signalwire-rest/fabric-api/cxml-applications/models/core.tsp Co-authored-by: Cassie <[email protected]> * Update specs/signalwire-rest/fabric-api/cxml-applications/models/requests.tsp Co-authored-by: Cassie <[email protected]> * Update specs/signalwire-rest/fabric-api/cxml-applications/models/requests.tsp Co-authored-by: Cassie <[email protected]> * Update specs/signalwire-rest/fabric-api/cxml-applications/models/responses.tsp Co-authored-by: Cassie <[email protected]> * Update specs/signalwire-rest/fabric-api/cxml-applications/models/responses.tsp Co-authored-by: Cassie <[email protected]> * Ran TypeSpec formatter * Ran formatter, and recompiled spec --------- Co-authored-by: Cassie <[email protected]> Co-authored-by: diego-signalwire <[email protected]>
1 parent f8d6d2a commit 6e17a94

File tree

257 files changed

+16337
-4278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+16337
-4278
lines changed

.cursor/rules/openapi-comparison-prompt.md

Lines changed: 457 additions & 0 deletions
Large diffs are not rendered by default.

.cursor/rules/typespec.md

Lines changed: 649 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
],
1010
"scripts": {
1111
"build": "yarn --cwd website build",
12+
"serve": "yarn --cwd website serve",
1213
"start": "yarn --cwd website start",
1314
"start-fresh": "yarn --cwd website start-fresh",
1415
"build:website": "yarn --cwd website build",

specs/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
"build:fabric-api": "cd ./signalwire-rest/fabric-api && tsp compile . && cd ../../",
1111
"build:logs-api": "cd ./signalwire-rest/logs-api && tsp compile . && cd ../../",
1212
"clean": "echo 'Skipping clean step'",
13-
"prebuild": "yarn clean"
13+
"prebuild": "yarn clean",
14+
"format": "tsp format **/*.tsp",
15+
"format:check": "tsp format --check **/*.tsp"
1416
},
1517
"dependencies": {
16-
"@typespec/compiler": "1.0.0",
17-
"@typespec/http": "1.0.0",
18-
"@typespec/openapi": "1.0.0",
19-
"@typespec/openapi3": "1.0.0",
20-
"@typespec/rest": "0.70.0"
18+
"@typespec/compiler": "1.1.0",
19+
"@typespec/http": "1.1.0",
20+
"@typespec/openapi": "1.1.0",
21+
"@typespec/openapi3": "1.1.0",
22+
"@typespec/rest": "0.71.0"
2123
},
2224
"devDependencies": {
2325
"typescript": "^5.5.4"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const SERVER_URL = "signalwire.com/api";
2+
3+
const TERMS_OF_SERVICE = "https://signalwire.com/legal/signalwire-cloud-agreement";
4+
5+
const CONTACT_NAME = "SignalWire";
6+
7+
const CONTACT_URL = "https://support.signalwire.com/portal/en/newticket?departmentId=1029313000000006907&layoutId=1029313000000074011";
8+
9+
const CONTACT_EMAIL = "[email protected]";
10+
11+
const LICENSE_URL = "https://github.com/signalwire/docs/blob/main/LICENSE";
12+
13+
const LICENSE_NAME = "MIT";
14+
15+
const CONTACT_INFO = #{
16+
name: CONTACT_NAME,
17+
url: CONTACT_URL,
18+
email: CONTACT_EMAIL,
19+
};
20+
21+
const LICENSE_INFO = #{ name: LICENSE_NAME, url: LICENSE_URL };
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
enum Ciphers {
2+
AEAD_AES_256_GCM_8: "AEAD_AES_256_GCM_8",
3+
AES_256_CM_HMAC_SHA1_80: "AES_256_CM_HMAC_SHA1_80",
4+
AES_CM_128_HMAC_SHA1_80: "AES_CM_128_HMAC_SHA1_80",
5+
AES_256_CM_HMAC_SHA1_32: "AES_256_CM_HMAC_SHA1_32",
6+
AES_CM_128_HMAC_SHA1_32: "AES_CM_128_HMAC_SHA1_32",
7+
}
8+
9+
enum Codecs {
10+
PCMU: "PCMU",
11+
PCMA: "PCMA",
12+
G722: "G722",
13+
G729: "G729",
14+
OPUS: "OPUS",
15+
VP8: "VP8",
16+
H264: "H264",
17+
}
18+
19+
enum Encryption {
20+
Required: "required",
21+
Optional: "optional",
22+
Default: "default",
23+
}

specs/signalwire-rest/calling-api/calls/main.tsp

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,57 @@ import "./models/requests.tsp";
44
import "./models/responses.tsp";
55
import "./models/examples.tsp";
66

7-
87
using TypeSpec.Http;
98
using Types.StatusCodes;
109

1110
@route("/calls")
1211
namespace CallingAPI.Calls {
13-
14-
@tag("Calls")
15-
@friendlyName("Calls")
16-
interface Calls {
17-
18-
@summary("Create a Call")
19-
@doc("To create a new call, you send a `POST` request to the Call resource with a payload including a `dial` command and additional nested `params`.")
20-
create(@body request: CallCreateRequest):
21-
{ @statusCode statusCode: 201; @body call: CallResponse; } |
22-
StatusCode401 |
23-
StatusCode404 |
24-
CallCreate422Error;
25-
26-
27-
@summary("Update a Call")
28-
@doc("To update an existing call, you send a `PUT` request to the Call resource with a payload including a `command` and additional nested `params`.")
29-
@opExample(#{parameters: holdCallExample}, #{title: "Hold active call", description: "Put an active AI call on hold, pausing the conversation"})
30-
@opExample(#{parameters: unholdCallExample}, #{title: "Unhold active call", description: "Resume an AI call that was previously put on hold"})
31-
@opExample(#{parameters: aiMessageExample}, #{title: "Inject AI message", description: "Send a message to the AI conversation to modify behavior or add context"})
32-
//@opExample(#{parameters: #{request: #{command: "update", params: #{id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", url: "https://example.com/swml", fallback_url: "https://example.com/fallback"}}}}, #{title: "Update active call", description: "Modify an active call's behavior using new SWML instructions"})
33-
@put update(@body request: CallUpdateRequest):
34-
{ @statusCode statusCode: 200; @body call: CallResponse; } |
35-
StatusCode401 |
36-
StatusCode404 |
37-
CallUpdate422Error;
38-
}
39-
40-
41-
42-
43-
}
12+
@tag("Calls")
13+
@friendlyName("Calls")
14+
interface Calls {
15+
@summary("Create a Call")
16+
@doc("To create a new call, you send a `POST` request to the Call resource with a payload including a `dial` command and additional nested `params`.")
17+
create(@body request: CallCreateRequest):
18+
| {
19+
@statusCode statusCode: 201;
20+
@body call: CallResponse;
21+
}
22+
| StatusCode401
23+
| StatusCode404
24+
| CallCreate422Error;
25+
26+
@summary("Update a Call")
27+
@doc("To update an existing call, you send a `PUT` request to the Call resource with a payload including a `command` and additional nested `params`.")
28+
@opExample(
29+
#{ parameters: holdCallExample },
30+
#{
31+
title: "Hold active call",
32+
description: "Put an active AI call on hold, pausing the conversation",
33+
}
34+
)
35+
@opExample(
36+
#{ parameters: unholdCallExample },
37+
#{
38+
title: "Unhold active call",
39+
description: "Resume an AI call that was previously put on hold",
40+
}
41+
)
42+
@opExample(
43+
#{ parameters: aiMessageExample },
44+
#{
45+
title: "Inject AI message",
46+
description: "Send a message to the AI conversation to modify behavior or add context",
47+
}
48+
)
49+
//@opExample(#{parameters: #{request: #{command: "update", params: #{id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", url: "https://example.com/swml", fallback_url: "https://example.com/fallback"}}}}, #{title: "Update active call", description: "Modify an active call's behavior using new SWML instructions"})
50+
@put
51+
update(@body request: CallUpdateRequest):
52+
| {
53+
@statusCode statusCode: 200;
54+
@body call: CallResponse;
55+
}
56+
| StatusCode401
57+
| StatusCode404
58+
| CallUpdate422Error;
59+
}
60+
}
Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,52 @@
11
model Call {
2+
@doc("The unique identifier of the call on SignalWire. This can be used to update the call programmatically.")
3+
@example("3fa85f64-5717-4562-b3fc-2c963f66afa6")
4+
id: string;
25

3-
@doc("The unique identifier of the call on SignalWire. This can be used to update the call programmatically.")
4-
@example("3fa85f64-5717-4562-b3fc-2c963f66afa6")
5-
id: string;
6+
@doc("The origin number or address.")
7+
@example("sip:[email protected]")
8+
from: string;
69

7-
@doc("The origin number or address.")
8-
@example("sip:from-sip@example-112233445566.sip.signalwire.com")
9-
from: string;
10+
@doc("The destination number or address.")
11+
@example("sip:from-sip@example-112233445567.sip.signalwire.com")
12+
to: string;
1013

11-
@doc("The destination number or address.")
12-
@example("sip:[email protected]")
13-
to: string;
14+
@doc("The direction of the call.")
15+
@example("outbound-api")
16+
direction: "outbound-api";
1417

15-
@doc("The direction of the call.")
16-
@example("outbound-api")
17-
direction: "outbound-api";
18+
@doc("The status of the call.")
19+
@example("queued")
20+
status: "answered" | "queued" | "initiated" | "ringing" | "ending" | "ended";
1821

19-
@doc("The status of the call.")
20-
@example("queued")
21-
status: "answered" | "queued" | "initiated" | "ringing" | "ending" | "ended";
22+
@doc("The duration of the call in seconds.")
23+
@example(60)
24+
duration: integer;
2225

23-
@doc("The duration of the call in seconds.")
24-
@example(60)
25-
duration: integer;
26+
@doc("The duration of the call in milliseconds.")
27+
@example(60000)
28+
duration_ms: integer;
2629

27-
@doc("The duration of the call in milliseconds.")
28-
@example(60000)
29-
duration_ms: integer;
30+
@doc("The billable duration of the call in seconds.")
31+
@example(60)
32+
billable_duration: integer;
3033

31-
@doc("The billable duration of the call in seconds.")
32-
@example(60)
33-
billable_duration: integer;
34+
@doc("Source of this call.")
35+
@example("realtime_api")
36+
source: "realtime_api";
3437

35-
@doc("Source of this call.")
36-
@example("realtime_api")
37-
source: "realtime_api";
38-
39-
@doc("Type of this call.")
40-
@example("relay_sip_call")
41-
type: "relay_pstn_call" | "relay_sip_call" | "relay_webrtc_call" ;
42-
43-
@doc("Details on charges associated with this call.")
44-
charge: ChargeDetails[];
38+
@doc("Type of this call.")
39+
@example("relay_sip_call")
40+
type: "relay_pstn_call" | "relay_sip_call" | "relay_webrtc_call";
4541

42+
@doc("Details on charges associated with this call.")
43+
charge: ChargeDetails[];
4644
}
4745

48-
4946
model ChargeDetails {
47+
@doc("Description for this charge.")
48+
description: string;
5049

51-
@doc("Description for this charge.")
52-
description: string;
53-
54-
@doc("Charged amount.")
55-
amount: integer;
56-
57-
}
50+
@doc("Charged amount.")
51+
amount: integer;
52+
}
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
11
/**
22
* Operation examples for the Calling API
3-
*
3+
*
44
* These examples can be imported and used with @opExample decorator on operations
55
*/
6-
76
const callId = "3fa85f64-5717-4562-b3fc-2c963f66afa6";
87

98
// Hangup Call Examples
109
const hangupCallExample = #{
1110
request: #{
1211
id: callId,
1312
command: "calling.end",
14-
params: #{
15-
reason: "hangup"
16-
}
17-
}
13+
params: #{ reason: "hangup" },
14+
},
1815
};
1916

2017
const holdCallExample = #{
21-
request: #{
22-
id: callId,
23-
command: "calling.ai_hold",
24-
params: #{}
25-
}
18+
request: #{ id: callId, command: "calling.ai_hold", params: #{} },
2619
};
2720

2821
const unholdCallExample = #{
29-
request: #{
30-
id: callId,
31-
command: "calling.ai_unhold",
32-
params: #{}
33-
}
22+
request: #{ id: callId, command: "calling.ai_unhold", params: #{} },
3423
};
3524

3625
const aiMessageExample = #{
@@ -39,9 +28,9 @@ const aiMessageExample = #{
3928
command: "calling.ai_message",
4029
params: #{
4130
role: "system",
42-
message_text: "You are now in expert mode. Provide detailed technical responses and use industry terminology."
43-
}
44-
}
31+
message_text: "You are now in expert mode. Provide detailed technical responses and use industry terminology.",
32+
},
33+
},
4534
};
4635

4736
const updateCallExample = #{
@@ -50,7 +39,7 @@ const updateCallExample = #{
5039
params: #{
5140
id: callId,
5241
url: "https://example.com/swml",
53-
fallback_url: "https://example.com/fallback"
54-
}
55-
}
42+
fallback_url: "https://example.com/fallback",
43+
},
44+
},
5645
};

0 commit comments

Comments
 (0)