@gemies/sdk 10.15.0 → 10.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 10.17.0
4
+
5
+ ### Phone calls are switched on per country
6
+
7
+ `@gemies/sdk/calls` gains the `pstn_not_enabled` error code (phone calls are not available in that
8
+ country yet), and `CallChannelsState.own_number.status` is now `available` or `not_configured`.
9
+
10
+ ## 10.16.0
11
+
12
+ ### Phone calls a person approves
13
+
14
+ `@gemies/sdk/calls` gains the `proposed` and `expired` statuses and their events,
15
+ `proposalExpiresAt`, the `remote_hangup` and `busy` end reasons, the phone error codes, and the
16
+ shapes of the channel and caller ID routes (`CallChannelsState`, `CallerIdState`,
17
+ `StartedCallerIdVerification`). The contract and what a client still has to draw are in Gemies
18
+ `docs/calls-api.md`.
19
+
3
20
  ## 10.15.0
4
21
 
5
22
  ### A gemie can call
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "10.15.0",
3
+ "version": "10.17.0",
4
4
  "description": "The Gemies SDK: the conversation runtime, chat UI, voice calls and dictation for Oxy apps that talk to a gemie",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
package/src/calls.ts CHANGED
@@ -16,12 +16,14 @@ export const CALL_DIRECTIONS = ['outbound', 'inbound'] as const;
16
16
  export type CallDirection = (typeof CALL_DIRECTIONS)[number];
17
17
 
18
18
  export const CALL_STATUSES = [
19
+ 'proposed',
19
20
  'ringing',
20
21
  'active',
21
22
  'ended',
22
23
  'failed',
23
24
  'declined',
24
25
  'missed',
26
+ 'expired',
25
27
  ] as const;
26
28
  export type CallStatus = (typeof CALL_STATUSES)[number];
27
29
 
@@ -29,9 +31,12 @@ export const CALL_END_REASONS = [
29
31
  'gemie_hangup',
30
32
  'conversation_ended',
31
33
  'user_hangup',
34
+ 'remote_hangup',
32
35
  'declined',
36
+ 'busy',
33
37
  'missed',
34
38
  'cancelled',
39
+ 'expired',
35
40
  'max_duration',
36
41
  'idle_timeout',
37
42
  'credits_exhausted',
@@ -49,21 +54,30 @@ export const CALL_ERROR_CODES = [
49
54
  'not_found',
50
55
  'not_ringing',
51
56
  'not_live',
57
+ 'not_pending',
52
58
  'call_in_progress',
53
59
  'rate_limited',
54
60
  'voice_plan_required',
55
61
  'not_configured',
56
62
  'not_enabled',
63
+ 'caller_id_required',
64
+ 'number_not_allowed',
65
+ 'number_unavailable',
66
+ 'credits_exhausted',
67
+ 'provider_error',
68
+ 'pstn_not_enabled',
57
69
  ] as const;
58
70
  export type CallErrorCode = (typeof CALL_ERROR_CODES)[number];
59
71
 
60
72
  export const CALL_EVENTS = [
73
+ 'call.proposed',
61
74
  'call.ringing',
62
75
  'call.accepted',
63
76
  'call.declined',
64
77
  'call.missed',
65
78
  'call.ended',
66
79
  'call.failed',
80
+ 'call.expired',
67
81
  ] as const;
68
82
  export type CallEventName = (typeof CALL_EVENTS)[number];
69
83
 
@@ -82,6 +96,8 @@ export interface CallWire {
82
96
  readonly to: string | null;
83
97
  readonly from: string | null;
84
98
  readonly createdAt: string;
99
+ /** When a `proposed` call becomes `expired`. */
100
+ readonly proposalExpiresAt: string | null;
85
101
  readonly ringExpiresAt: string | null;
86
102
  readonly answeredAt: string | null;
87
103
  readonly endedAt: string | null;
@@ -105,3 +121,31 @@ export interface CallEventData {
105
121
  export interface CallErrorBody {
106
122
  readonly error: { readonly code: CallErrorCode; readonly message: string };
107
123
  }
124
+
125
+ /** `GET /calls/channels`. */
126
+ export interface CallChannelsState {
127
+ readonly app: { readonly status: 'available' };
128
+ readonly phone: {
129
+ readonly status: 'available' | 'caller_id_required' | 'not_configured';
130
+ readonly phoneNumber: string | null;
131
+ };
132
+ readonly own_number: { readonly status: 'available' | 'not_configured' };
133
+ }
134
+
135
+ /** `GET /calls/caller-id`'s `callerId`: the number the person calls from. */
136
+ export interface CallerIdState {
137
+ readonly configured: boolean;
138
+ readonly phoneNumber: string | null;
139
+ readonly pendingPhoneNumber: string | null;
140
+ readonly pendingExpiresAt: string | null;
141
+ }
142
+
143
+ /**
144
+ * `POST /calls/caller-id { phoneNumber }`: the provider rings the number, and whoever answers types
145
+ * `validationCode` on its keypad. Show the code.
146
+ */
147
+ export interface StartedCallerIdVerification {
148
+ readonly validationCode: string;
149
+ readonly phoneNumber: string;
150
+ readonly expiresAt: string;
151
+ }