@wats/graph 0.3.16 → 0.3.18

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.
@@ -12,6 +12,13 @@ import {
12
12
  groupString,
13
13
  groupStringArray
14
14
  } from "./shared.js";
15
+ import {
16
+ normalizeGroupDetailsResponse,
17
+ normalizeGroupInviteLinkResponse,
18
+ normalizeGroupJoinRequestsResponse,
19
+ normalizeGroupMutationResponse,
20
+ normalizeListGroupsResponse
21
+ } from "./responses.js";
15
22
  function buildCreateGroupBody(body) {
16
23
  const record = groupAssertPlainRecord(body, "createGroup");
17
24
  const out = {
@@ -68,7 +75,8 @@ const createGroupRaw = defineEndpoint({
68
75
  bodyContentType: "application/json"
69
76
  });
70
77
  export const createGroup = Object.assign(async function createGroup(client, params, body, opts) {
71
- return createGroupRaw(client, { phoneNumberId: groupPathParam(params, "createGroup", "phoneNumberId") }, buildCreateGroupBody(body), opts);
78
+ const response = await createGroupRaw(client, { phoneNumberId: groupPathParam(params, "createGroup", "phoneNumberId") }, buildCreateGroupBody(body), opts);
79
+ return normalizeGroupMutationResponse(response);
72
80
  }, { definition: createGroupRaw.definition });
73
81
  const listGroupsRaw = defineEndpoint({
74
82
  method: "GET",
@@ -94,7 +102,8 @@ export const listGroups = Object.assign(async function listGroups(client, params
94
102
  if (record.before !== undefined) {
95
103
  query.before = groupString(record.before, "before", "listGroups", 4096);
96
104
  }
97
- return listGroupsRaw(client, query, body, opts);
105
+ const response = await listGroupsRaw(client, query, body, opts);
106
+ return normalizeListGroupsResponse(response);
98
107
  }, { definition: listGroupsRaw.definition });
99
108
  const getGroupRaw = defineEndpoint({
100
109
  method: "GET",
@@ -109,7 +118,8 @@ export const getGroup = Object.assign(async function getGroup(client, params, bo
109
118
  if (record.fields !== undefined) {
110
119
  query.fields = groupString(record.fields, "fields", "getGroup", 4096);
111
120
  }
112
- return getGroupRaw(client, query, body, opts);
121
+ const response = await getGroupRaw(client, query, body, opts);
122
+ return normalizeGroupDetailsResponse(response);
113
123
  }, { definition: getGroupRaw.definition });
114
124
  const updateGroupRaw = defineEndpoint({
115
125
  method: "POST",
@@ -118,7 +128,8 @@ const updateGroupRaw = defineEndpoint({
118
128
  bodyContentType: "application/json"
119
129
  });
120
130
  export const updateGroup = Object.assign(async function updateGroup(client, params, body, opts) {
121
- return updateGroupRaw(client, { groupId: groupPathParam(params, "updateGroup", "groupId") }, buildUpdateGroupBody(body), opts);
131
+ const response = await updateGroupRaw(client, { groupId: groupPathParam(params, "updateGroup", "groupId") }, buildUpdateGroupBody(body), opts);
132
+ return normalizeGroupMutationResponse(response);
122
133
  }, { definition: updateGroupRaw.definition });
123
134
  const deleteGroupRaw = defineEndpoint({
124
135
  method: "DELETE",
@@ -126,7 +137,8 @@ const deleteGroupRaw = defineEndpoint({
126
137
  params: { groupId: { in: "path", required: true } }
127
138
  });
128
139
  export const deleteGroup = Object.assign(async function deleteGroup(client, params, body, opts) {
129
- return deleteGroupRaw(client, { groupId: groupPathParam(params, "deleteGroup", "groupId") }, body, opts);
140
+ const response = await deleteGroupRaw(client, { groupId: groupPathParam(params, "deleteGroup", "groupId") }, body, opts);
141
+ return normalizeGroupMutationResponse(response);
130
142
  }, { definition: deleteGroupRaw.definition });
131
143
  const getGroupInviteLinkRaw = defineEndpoint({
132
144
  method: "GET",
@@ -134,7 +146,8 @@ const getGroupInviteLinkRaw = defineEndpoint({
134
146
  params: { groupId: { in: "path", required: true } }
135
147
  });
136
148
  export const getGroupInviteLink = Object.assign(async function getGroupInviteLink(client, params, body, opts) {
137
- return getGroupInviteLinkRaw(client, { groupId: groupPathParam(params, "getGroupInviteLink", "groupId") }, body, opts);
149
+ const response = await getGroupInviteLinkRaw(client, { groupId: groupPathParam(params, "getGroupInviteLink", "groupId") }, body, opts);
150
+ return normalizeGroupInviteLinkResponse(response);
138
151
  }, { definition: getGroupInviteLinkRaw.definition });
139
152
  const resetGroupInviteLinkRaw = defineEndpoint({
140
153
  method: "POST",
@@ -143,7 +156,8 @@ const resetGroupInviteLinkRaw = defineEndpoint({
143
156
  bodyContentType: "application/json"
144
157
  });
145
158
  export const resetGroupInviteLink = Object.assign(async function resetGroupInviteLink(client, params, body, opts) {
146
- return resetGroupInviteLinkRaw(client, { groupId: groupPathParam(params, "resetGroupInviteLink", "groupId") }, { messaging_product: "whatsapp" }, opts);
159
+ const response = await resetGroupInviteLinkRaw(client, { groupId: groupPathParam(params, "resetGroupInviteLink", "groupId") }, { messaging_product: "whatsapp" }, opts);
160
+ return normalizeGroupInviteLinkResponse(response);
147
161
  }, { definition: resetGroupInviteLinkRaw.definition });
148
162
  const listGroupJoinRequestsRaw = defineEndpoint({
149
163
  method: "GET",
@@ -165,7 +179,8 @@ export const listGroupJoinRequests = Object.assign(async function listGroupJoinR
165
179
  if (record.after !== undefined) {
166
180
  query.after = groupString(record.after, "after", "listGroupJoinRequests", 4096);
167
181
  }
168
- return listGroupJoinRequestsRaw(client, query, body, opts);
182
+ const response = await listGroupJoinRequestsRaw(client, query, body, opts);
183
+ return normalizeGroupJoinRequestsResponse(response);
169
184
  }, { definition: listGroupJoinRequestsRaw.definition });
170
185
  const approveGroupJoinRequestsRaw = defineEndpoint({
171
186
  method: "POST",
@@ -180,10 +195,12 @@ const rejectGroupJoinRequestsRaw = defineEndpoint({
180
195
  bodyContentType: "application/json"
181
196
  });
182
197
  export const approveGroupJoinRequests = Object.assign(async function approveGroupJoinRequests(client, params, body, opts) {
183
- return approveGroupJoinRequestsRaw(client, { groupId: groupPathParam(params, "approveGroupJoinRequests", "groupId") }, buildManageJoinRequestsBody(body, "approve", "approveGroupJoinRequests"), opts);
198
+ const response = await approveGroupJoinRequestsRaw(client, { groupId: groupPathParam(params, "approveGroupJoinRequests", "groupId") }, buildManageJoinRequestsBody(body, "approve", "approveGroupJoinRequests"), opts);
199
+ return normalizeGroupMutationResponse(response);
184
200
  }, { definition: approveGroupJoinRequestsRaw.definition });
185
201
  export const rejectGroupJoinRequests = Object.assign(async function rejectGroupJoinRequests(client, params, body, opts) {
186
- return rejectGroupJoinRequestsRaw(client, { groupId: groupPathParam(params, "rejectGroupJoinRequests", "groupId") }, buildManageJoinRequestsBody(body, "reject", "rejectGroupJoinRequests"), opts);
202
+ const response = await rejectGroupJoinRequestsRaw(client, { groupId: groupPathParam(params, "rejectGroupJoinRequests", "groupId") }, buildManageJoinRequestsBody(body, "reject", "rejectGroupJoinRequests"), opts);
203
+ return normalizeGroupMutationResponse(response);
187
204
  }, { definition: rejectGroupJoinRequestsRaw.definition });
188
205
  const removeGroupParticipantsRaw = defineEndpoint({
189
206
  method: "DELETE",
@@ -192,5 +209,6 @@ const removeGroupParticipantsRaw = defineEndpoint({
192
209
  bodyContentType: "application/json"
193
210
  });
194
211
  export const removeGroupParticipants = Object.assign(async function removeGroupParticipants(client, params, body, opts) {
195
- return removeGroupParticipantsRaw(client, { groupId: groupPathParam(params, "removeGroupParticipants", "groupId") }, buildRemoveParticipantsBody(body), opts);
212
+ const response = await removeGroupParticipantsRaw(client, { groupId: groupPathParam(params, "removeGroupParticipants", "groupId") }, buildRemoveParticipantsBody(body), opts);
213
+ return normalizeGroupMutationResponse(response);
196
214
  }, { definition: removeGroupParticipantsRaw.definition });
@@ -1,4 +1,5 @@
1
1
  export { approveGroupJoinRequests, createGroup, deleteGroup, getGroup, getGroupInviteLink, listGroupJoinRequests, listGroups, rejectGroupJoinRequests, removeGroupParticipants, resetGroupInviteLink, updateGroup } from "./callables.js";
2
+ export { normalizeGroupDetailsResponse, normalizeGroupInviteLinkResponse, normalizeGroupJoinRequestsResponse, normalizeGroupMutationResponse, normalizeListGroupsResponse } from "./responses.js";
2
3
  export { GROUP_DESCRIPTION_MAX_LENGTH, GROUP_MAX_JOIN_REQUESTS, GROUP_MAX_PARTICIPANTS, GROUP_SUBJECT_MAX_LENGTH } from "./shared.js";
3
4
  export type { GraphPaging } from "../waba/types.js";
4
5
  export type { CreateGroupBody, CreateGroupParams, GetGroupParams, GroupDetails, GroupIdParams, GroupInviteLinkResponse, GroupJoinApprovalMode, GroupJoinRequestWire, GroupJoinRequestsResponse, GroupMutationResponse, GroupParticipantWire, GroupSummaryWire, ListGroupJoinRequestsParams, ListGroupsParams, ListGroupsResponse, ManageGroupJoinRequestsBody, RemoveGroupParticipantsBody, UpdateGroupBody } from "./types.js";
@@ -11,6 +11,13 @@ export {
11
11
  resetGroupInviteLink,
12
12
  updateGroup
13
13
  } from "./callables.js";
14
+ export {
15
+ normalizeGroupDetailsResponse,
16
+ normalizeGroupInviteLinkResponse,
17
+ normalizeGroupJoinRequestsResponse,
18
+ normalizeGroupMutationResponse,
19
+ normalizeListGroupsResponse
20
+ } from "./responses.js";
14
21
  export {
15
22
  GROUP_DESCRIPTION_MAX_LENGTH,
16
23
  GROUP_MAX_JOIN_REQUESTS,
@@ -0,0 +1,6 @@
1
+ import type { GroupDetails, GroupInviteLinkResponse, GroupJoinRequestsResponse, GroupMutationResponse, ListGroupsResponse } from "./types.js";
2
+ export declare function normalizeGroupMutationResponse(response: GroupMutationResponse): GroupMutationResponse;
3
+ export declare function normalizeGroupDetailsResponse(response: GroupDetails): GroupDetails;
4
+ export declare function normalizeGroupInviteLinkResponse(response: GroupInviteLinkResponse): GroupInviteLinkResponse;
5
+ export declare function normalizeListGroupsResponse(response: ListGroupsResponse): ListGroupsResponse;
6
+ export declare function normalizeGroupJoinRequestsResponse(response: GroupJoinRequestsResponse): GroupJoinRequestsResponse;
@@ -0,0 +1,139 @@
1
+ function isRecord(value) {
2
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3
+ }
4
+ function compact(record) {
5
+ for (const key of Object.keys(record)) {
6
+ if (record[key] === undefined)
7
+ delete record[key];
8
+ }
9
+ return record;
10
+ }
11
+ function camelCaseKey(key) {
12
+ return key.replace(/_([a-z0-9])/g, (_match, ch) => ch.toUpperCase());
13
+ }
14
+ function normalizeJsonKeys(value) {
15
+ if (Array.isArray(value))
16
+ return value.map(normalizeJsonKeys);
17
+ if (!isRecord(value))
18
+ return value;
19
+ const out = {};
20
+ for (const [key, nested] of Object.entries(value)) {
21
+ out[camelCaseKey(key)] = normalizeJsonKeys(nested);
22
+ }
23
+ return out;
24
+ }
25
+ function normalizeParticipant(value) {
26
+ if (!isRecord(value))
27
+ return;
28
+ const out = {};
29
+ if (typeof value.waId === "string")
30
+ out.waId = value.waId;
31
+ else if (typeof value.wa_id === "string")
32
+ out.waId = value.wa_id;
33
+ return out;
34
+ }
35
+ export function normalizeGroupMutationResponse(response) {
36
+ if (!isRecord(response))
37
+ return response;
38
+ const out = {};
39
+ for (const [key, value] of Object.entries(response)) {
40
+ if (key === "request_id")
41
+ out.requestId = value;
42
+ else
43
+ out[camelCaseKey(key)] = normalizeJsonKeys(value);
44
+ }
45
+ return out;
46
+ }
47
+ export function normalizeGroupDetailsResponse(response) {
48
+ if (!isRecord(response))
49
+ return response;
50
+ const out = {};
51
+ for (const [key, value] of Object.entries(response)) {
52
+ switch (key) {
53
+ case "join_approval_mode":
54
+ out.joinApprovalMode = value;
55
+ break;
56
+ case "creation_timestamp":
57
+ out.creationTimestamp = value;
58
+ break;
59
+ case "total_participant_count":
60
+ out.totalParticipantCount = value;
61
+ break;
62
+ case "participants":
63
+ out.participants = Array.isArray(value) ? value.map(normalizeParticipant).filter(Boolean) : value;
64
+ break;
65
+ default:
66
+ out[camelCaseKey(key)] = normalizeJsonKeys(value);
67
+ }
68
+ }
69
+ return out;
70
+ }
71
+ function normalizeGroupSummary(value) {
72
+ if (!isRecord(value))
73
+ return;
74
+ const out = {};
75
+ for (const [key, nested] of Object.entries(value)) {
76
+ if (key === "created_at" || key === "createdAt")
77
+ out.createdAt = nested;
78
+ else
79
+ out[camelCaseKey(key)] = normalizeJsonKeys(nested);
80
+ }
81
+ return out;
82
+ }
83
+ function normalizeJoinRequest(value) {
84
+ if (!isRecord(value))
85
+ return;
86
+ const out = {};
87
+ for (const [key, nested] of Object.entries(value)) {
88
+ switch (key) {
89
+ case "join_request_id":
90
+ case "joinRequestId":
91
+ out.joinRequestId = nested;
92
+ break;
93
+ case "wa_id":
94
+ case "waId":
95
+ out.waId = nested;
96
+ break;
97
+ case "creation_timestamp":
98
+ case "creationTimestamp":
99
+ out.creationTimestamp = nested;
100
+ break;
101
+ default:
102
+ out[camelCaseKey(key)] = normalizeJsonKeys(nested);
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ export function normalizeGroupInviteLinkResponse(response) {
108
+ if (!isRecord(response))
109
+ return response;
110
+ const out = {};
111
+ for (const [key, value] of Object.entries(response)) {
112
+ if (key === "invite_link")
113
+ out.inviteLink = value;
114
+ else
115
+ out[camelCaseKey(key)] = normalizeJsonKeys(value);
116
+ }
117
+ return out;
118
+ }
119
+ export function normalizeListGroupsResponse(response) {
120
+ if (!isRecord(response))
121
+ return response;
122
+ const out = normalizeJsonKeys(response);
123
+ const data = response.data;
124
+ if (Array.isArray(data)) {
125
+ out.data = data.map(normalizeGroupSummary).filter(Boolean);
126
+ } else if (isRecord(data) && Array.isArray(data.groups)) {
127
+ out.data = { ...data, groups: data.groups.map(normalizeGroupSummary).filter(Boolean) };
128
+ }
129
+ return out;
130
+ }
131
+ export function normalizeGroupJoinRequestsResponse(response) {
132
+ if (!isRecord(response))
133
+ return response;
134
+ const out = normalizeJsonKeys(response);
135
+ if (Array.isArray(response.data)) {
136
+ out.data = response.data.map(normalizeJoinRequest).filter(Boolean);
137
+ }
138
+ return out;
139
+ }
@@ -6,20 +6,20 @@ import type { GraphPaging } from "../waba/types.js";
6
6
  * type in @wats/types/groups (WATS-131) at the Graph transport boundary.
7
7
  */
8
8
  export type GroupJoinApprovalMode = "auto_approve" | "approval_required";
9
- /** Wire-shaped participant as returned by Graph (`wa_id`). */
9
+ /** Public participant response. Graph wire `wa_id` is normalized to `waId`. */
10
10
  export interface GroupParticipantWire {
11
- readonly wa_id?: string;
11
+ readonly waId?: string;
12
12
  readonly [key: string]: unknown;
13
13
  }
14
- /** Group metadata response from `GET /<group-id>` (raw Graph wire). */
14
+ /** Group metadata response from `GET /<group-id>` (camelCase public shape). */
15
15
  export interface GroupDetails {
16
16
  readonly id?: string;
17
17
  readonly subject?: string;
18
18
  readonly description?: string;
19
- readonly join_approval_mode?: GroupJoinApprovalMode;
19
+ readonly joinApprovalMode?: GroupJoinApprovalMode;
20
20
  readonly suspended?: boolean;
21
- readonly creation_timestamp?: number;
22
- readonly total_participant_count?: number;
21
+ readonly creationTimestamp?: number;
22
+ readonly totalParticipantCount?: number;
23
23
  readonly participants?: readonly GroupParticipantWire[];
24
24
  readonly [key: string]: unknown;
25
25
  }
@@ -30,20 +30,20 @@ export interface GroupDetails {
30
30
  * `group_*_update` webhook.
31
31
  */
32
32
  export interface GroupMutationResponse {
33
- readonly request_id?: string;
33
+ readonly requestId?: string;
34
34
  readonly success?: boolean;
35
35
  readonly [key: string]: unknown;
36
36
  }
37
37
  /** Invite-link response from `GET /<group-id>/invite_link`. */
38
38
  export interface GroupInviteLinkResponse {
39
- readonly invite_link?: string;
39
+ readonly inviteLink?: string;
40
40
  readonly [key: string]: unknown;
41
41
  }
42
42
  /** A single group summary as returned by `GET /<phone-number-id>/groups`. */
43
43
  export interface GroupSummaryWire {
44
44
  readonly id?: string;
45
45
  readonly subject?: string;
46
- readonly created_at?: string;
46
+ readonly createdAt?: string;
47
47
  readonly [key: string]: unknown;
48
48
  }
49
49
  /** Active-groups listing from `GET /<phone-number-id>/groups`. */
@@ -56,9 +56,9 @@ export interface ListGroupsResponse {
56
56
  }
57
57
  /** A single pending join request (raw Graph wire). */
58
58
  export interface GroupJoinRequestWire {
59
- readonly join_request_id?: string;
60
- readonly wa_id?: string;
61
- readonly creation_timestamp?: number;
59
+ readonly joinRequestId?: string;
60
+ readonly waId?: string;
61
+ readonly creationTimestamp?: number;
62
62
  readonly [key: string]: unknown;
63
63
  }
64
64
  /** Join-request listing from `GET /<group-id>/join_requests`. */
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * @experimental Groups endpoint helpers may change in 0.x minors while WATS expands Groups API parity.
3
3
  */
4
- export { GROUP_DESCRIPTION_MAX_LENGTH, GROUP_MAX_JOIN_REQUESTS, GROUP_MAX_PARTICIPANTS, GROUP_SUBJECT_MAX_LENGTH, approveGroupJoinRequests, createGroup, deleteGroup, getGroup, getGroupInviteLink, listGroupJoinRequests, listGroups, rejectGroupJoinRequests, removeGroupParticipants, resetGroupInviteLink, updateGroup } from "./groups/index.js";
4
+ export { GROUP_DESCRIPTION_MAX_LENGTH, GROUP_MAX_JOIN_REQUESTS, GROUP_MAX_PARTICIPANTS, GROUP_SUBJECT_MAX_LENGTH, approveGroupJoinRequests, createGroup, deleteGroup, getGroup, getGroupInviteLink, listGroupJoinRequests, listGroups, normalizeGroupDetailsResponse, normalizeGroupInviteLinkResponse, normalizeGroupJoinRequestsResponse, normalizeGroupMutationResponse, normalizeListGroupsResponse, rejectGroupJoinRequests, removeGroupParticipants, resetGroupInviteLink, updateGroup } from "./groups/index.js";
5
5
  export type { CreateGroupBody, CreateGroupParams, GetGroupParams, GraphPaging, GroupDetails, GroupIdParams, GroupInviteLinkResponse, GroupJoinApprovalMode, GroupJoinRequestWire, GroupJoinRequestsResponse, GroupMutationResponse, GroupParticipantWire, GroupSummaryWire, ListGroupJoinRequestsParams, ListGroupsParams, ListGroupsResponse, ManageGroupJoinRequestsBody, RemoveGroupParticipantsBody, UpdateGroupBody } from "./groups/index.js";
@@ -10,6 +10,11 @@ export {
10
10
  getGroupInviteLink,
11
11
  listGroupJoinRequests,
12
12
  listGroups,
13
+ normalizeGroupDetailsResponse,
14
+ normalizeGroupInviteLinkResponse,
15
+ normalizeGroupJoinRequestsResponse,
16
+ normalizeGroupMutationResponse,
17
+ normalizeListGroupsResponse,
13
18
  rejectGroupJoinRequests,
14
19
  removeGroupParticipants,
15
20
  resetGroupInviteLink,
@@ -15,36 +15,45 @@ export class GroupClient {
15
15
  async getInfo(params, opts) {
16
16
  const scopedParams = copyOptionalParamsObject(params, "GroupClient.getInfo");
17
17
  scopedParams.groupId = this.#groupId;
18
- return getGroupEndpoint(this.#graphClient, scopedParams, undefined, opts);
18
+ const response = await getGroupEndpoint(this.#graphClient, scopedParams, undefined, opts);
19
+ return normalizeGroupDetailsResponse(response);
19
20
  }
20
21
  async update(body, opts) {
21
- return updateGroupEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
22
+ const response = await updateGroupEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
23
+ return normalizeGroupMutationResponse(response);
22
24
  }
23
25
  async delete(params, opts) {
24
26
  copyOptionalParamsObject(params, "GroupClient.delete");
25
- return deleteGroupEndpoint(this.#graphClient, { groupId: this.#groupId }, undefined, opts);
27
+ const response = await deleteGroupEndpoint(this.#graphClient, { groupId: this.#groupId }, undefined, opts);
28
+ return normalizeGroupMutationResponse(response);
26
29
  }
27
30
  async getInviteLink(params, opts) {
28
31
  copyOptionalParamsObject(params, "GroupClient.getInviteLink");
29
- return getGroupInviteLinkEndpoint(this.#graphClient, { groupId: this.#groupId }, undefined, opts);
32
+ const response = await getGroupInviteLinkEndpoint(this.#graphClient, { groupId: this.#groupId }, undefined, opts);
33
+ return normalizeGroupInviteLinkResponse(response);
30
34
  }
31
35
  async resetInviteLink(params, opts) {
32
36
  copyOptionalParamsObject(params, "GroupClient.resetInviteLink");
33
- return resetGroupInviteLinkEndpoint(this.#graphClient, { groupId: this.#groupId }, undefined, opts);
37
+ const response = await resetGroupInviteLinkEndpoint(this.#graphClient, { groupId: this.#groupId }, undefined, opts);
38
+ return normalizeGroupInviteLinkResponse(response);
34
39
  }
35
40
  async removeParticipants(body, opts) {
36
- return removeGroupParticipantsEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
41
+ const response = await removeGroupParticipantsEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
42
+ return normalizeGroupMutationResponse(response);
37
43
  }
38
44
  async getJoinRequests(params, opts) {
39
45
  const scopedParams = copyOptionalParamsObject(params, "GroupClient.getJoinRequests");
40
46
  scopedParams.groupId = this.#groupId;
41
- return listGroupJoinRequestsEndpoint(this.#graphClient, scopedParams, undefined, opts);
47
+ const response = await listGroupJoinRequestsEndpoint(this.#graphClient, scopedParams, undefined, opts);
48
+ return normalizeGroupJoinRequestsResponse(response);
42
49
  }
43
50
  async approveJoinRequests(body, opts) {
44
- return approveGroupJoinRequestsEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
51
+ const response = await approveGroupJoinRequestsEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
52
+ return normalizeGroupMutationResponse(response);
45
53
  }
46
54
  async rejectJoinRequests(body, opts) {
47
- return rejectGroupJoinRequestsEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
55
+ const response = await rejectGroupJoinRequestsEndpoint(this.#graphClient, { groupId: this.#groupId }, body, opts);
56
+ return normalizeGroupMutationResponse(response);
48
57
  }
49
58
  }
50
59
  import { assertSafePathParamValue } from "../endpoint.js";
@@ -56,6 +65,10 @@ import {
56
65
  getGroup as getGroupEndpoint,
57
66
  getGroupInviteLink as getGroupInviteLinkEndpoint,
58
67
  listGroupJoinRequests as listGroupJoinRequestsEndpoint,
68
+ normalizeGroupDetailsResponse,
69
+ normalizeGroupInviteLinkResponse,
70
+ normalizeGroupJoinRequestsResponse,
71
+ normalizeGroupMutationResponse,
59
72
  rejectGroupJoinRequests as rejectGroupJoinRequestsEndpoint,
60
73
  removeGroupParticipants as removeGroupParticipantsEndpoint,
61
74
  resetGroupInviteLink as resetGroupInviteLinkEndpoint,
@@ -16,12 +16,14 @@ export class PhoneNumberClient {
16
16
  return new GroupClient({ graphClient: this.#graphClient, groupId });
17
17
  }
18
18
  async createGroup(body, opts) {
19
- return createGroupEndpoint(this.#graphClient, { phoneNumberId: this.#phoneNumberId }, body, opts);
19
+ const response = await createGroupEndpoint(this.#graphClient, { phoneNumberId: this.#phoneNumberId }, body, opts);
20
+ return normalizeGroupMutationResponse(response);
20
21
  }
21
22
  async listGroups(params, opts) {
22
23
  const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.listGroups");
23
24
  scopedParams.phoneNumberId = this.#phoneNumberId;
24
- return listGroupsEndpoint(this.#graphClient, scopedParams, undefined, opts);
25
+ const response = await listGroupsEndpoint(this.#graphClient, scopedParams, undefined, opts);
26
+ return normalizeListGroupsResponse(response);
25
27
  }
26
28
  async getInfo(params, opts) {
27
29
  const scopedParams = copyOptionalParamsObject(params, "PhoneNumberClient.getInfo");
@@ -210,7 +212,9 @@ import {
210
212
  } from "../endpoints/calling.js";
211
213
  import {
212
214
  createGroup as createGroupEndpoint,
213
- listGroups as listGroupsEndpoint
215
+ listGroups as listGroupsEndpoint,
216
+ normalizeGroupMutationResponse,
217
+ normalizeListGroupsResponse
214
218
  } from "../endpoints/groups.js";
215
219
  import {
216
220
  buildMarkMessageAsReadPayload,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wats/graph",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",