@webitel/api-services 26.12.27 → 26.12.29
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/package.json +1 -1
- package/src/api/clients/gateways/__tests__/gateways.spec.ts +46 -0
- package/src/api/clients/gateways/gateways.ts +9 -7
- package/src/gen/_models/listSpacesParams.ts +5 -0
- package/src/gen/_models/webitelKbArticlesMoveArticleBody.ts +10 -2
- package/src/gen-wire/_models/listSpacesParams.ts +5 -0
- package/src/gen-wire/_models/webitelKbArticlesMoveArticleBody.ts +10 -2
- package/src/gen-wire/articles/articles.zod.ts +12 -2
- package/src/gen-wire/spaces/spaces.zod.ts +6 -0
- package/types/.tsbuildinfo +1 -1
- package/types/gen/_models/listSpacesParams.d.ts +5 -0
- package/types/gen/_models/webitelKbArticlesMoveArticleBody.d.ts +10 -2
- package/types/gen-wire/_models/listSpacesParams.d.ts +5 -0
- package/types/gen-wire/_models/webitelKbArticlesMoveArticleBody.d.ts +10 -2
- package/types/gen-wire/articles/articles.zod.d.ts +1 -0
- package/types/gen-wire/spaces/spaces.zod.d.ts +1 -0
package/package.json
CHANGED
|
@@ -94,6 +94,52 @@ describe('GatewaysAPI', () => {
|
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
// [Claude] the save responses are partial, the card gets the gateway read back
|
|
98
|
+
it('reads the gateway back after add and update', async () => {
|
|
99
|
+
instance.post.mockResolvedValue({
|
|
100
|
+
data: {
|
|
101
|
+
id: '7',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
instance.get.mockResolvedValue({
|
|
105
|
+
data: {
|
|
106
|
+
id: '7',
|
|
107
|
+
name: 'gw',
|
|
108
|
+
register: true,
|
|
109
|
+
account: 'user',
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const added = await GatewaysAPI.add({
|
|
114
|
+
itemInstance: {
|
|
115
|
+
...common,
|
|
116
|
+
register: true,
|
|
117
|
+
account: 'user',
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
expect(instance.get).toHaveBeenCalledWith('/sip/gateways/7');
|
|
121
|
+
expect(added).toMatchObject({
|
|
122
|
+
id: '7',
|
|
123
|
+
name: 'gw',
|
|
124
|
+
register: true,
|
|
125
|
+
account: 'user',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const updated = await GatewaysAPI.update({
|
|
129
|
+
itemId: '7',
|
|
130
|
+
itemInstance: {
|
|
131
|
+
...common,
|
|
132
|
+
register: true,
|
|
133
|
+
account: 'user',
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
expect(instance.get).toHaveBeenLastCalledWith('/sip/gateways/7');
|
|
137
|
+
expect(updated).toMatchObject({
|
|
138
|
+
id: '7',
|
|
139
|
+
account: 'user',
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
97
143
|
it('patches the changed field only', async () => {
|
|
98
144
|
await GatewaysAPI.patch({
|
|
99
145
|
id: '5',
|
|
@@ -152,17 +152,19 @@ const toRequestItem = (item: ApiParams) =>
|
|
|
152
152
|
]);
|
|
153
153
|
|
|
154
154
|
const addGateway = async ({ itemInstance }: AddItemParams) => {
|
|
155
|
+
let id: string | number;
|
|
155
156
|
try {
|
|
156
157
|
const response = await instance.post(baseUrl, toRequestItem(itemInstance));
|
|
157
|
-
|
|
158
|
-
snakeToCamel(),
|
|
159
|
-
]);
|
|
158
|
+
id = response.data.id;
|
|
160
159
|
} catch (err) {
|
|
161
160
|
throw applyTransform(err, [
|
|
162
161
|
translateError,
|
|
163
162
|
notify,
|
|
164
163
|
]);
|
|
165
164
|
}
|
|
165
|
+
return getGateway({
|
|
166
|
+
itemId: id,
|
|
167
|
+
});
|
|
166
168
|
};
|
|
167
169
|
const updateGateway = async ({
|
|
168
170
|
itemInstance,
|
|
@@ -170,16 +172,16 @@ const updateGateway = async ({
|
|
|
170
172
|
}: UpdateItemParams) => {
|
|
171
173
|
const url = `${baseUrl}/${id}`;
|
|
172
174
|
try {
|
|
173
|
-
|
|
174
|
-
return applyTransform(response.data, [
|
|
175
|
-
snakeToCamel(),
|
|
176
|
-
]);
|
|
175
|
+
await instance.put(url, toRequestItem(itemInstance));
|
|
177
176
|
} catch (err) {
|
|
178
177
|
throw applyTransform(err, [
|
|
179
178
|
translateError,
|
|
180
179
|
notify,
|
|
181
180
|
]);
|
|
182
181
|
}
|
|
182
|
+
return getGateway({
|
|
183
|
+
itemId: id,
|
|
184
|
+
});
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
/** [Claude] a patch carries only the changed fields, so the type is unknown here */
|
|
@@ -34,4 +34,9 @@ export type ListSpacesParams = {
|
|
|
34
34
|
* - SPACE_STATE_INACTIVE: Articles are kept but excluded from search and suggestions.
|
|
35
35
|
*/
|
|
36
36
|
state?: ListSpacesState;
|
|
37
|
+
/**
|
|
38
|
+
* Optional language filter, at most 50 tags; matches the base language of
|
|
39
|
+
* any of them.
|
|
40
|
+
*/
|
|
41
|
+
languages?: string[];
|
|
37
42
|
};
|
|
@@ -6,9 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* MoveArticleRequest reparents an article.
|
|
9
|
+
* MoveArticleRequest reparents an article, possibly into another space.
|
|
10
10
|
*/
|
|
11
11
|
export interface WebitelKbArticlesMoveArticleBody {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* New parent id; 0 to move to top level. The article moves into the space
|
|
14
|
+
* of the parent.
|
|
15
|
+
*/
|
|
13
16
|
newParentId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Target space id of the same language for a move to top level; 0 keeps
|
|
19
|
+
* the current space. With a new parent it may only repeat its space.
|
|
20
|
+
*/
|
|
21
|
+
newSpaceId?: string;
|
|
14
22
|
}
|
|
@@ -34,4 +34,9 @@ export type ListSpacesParams = {
|
|
|
34
34
|
* - SPACE_STATE_INACTIVE: Articles are kept but excluded from search and suggestions.
|
|
35
35
|
*/
|
|
36
36
|
state?: ListSpacesState;
|
|
37
|
+
/**
|
|
38
|
+
* Optional language filter, at most 50 tags; matches the base language of
|
|
39
|
+
* any of them.
|
|
40
|
+
*/
|
|
41
|
+
languages?: string[];
|
|
37
42
|
};
|
|
@@ -6,9 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* MoveArticleRequest reparents an article.
|
|
9
|
+
* MoveArticleRequest reparents an article, possibly into another space.
|
|
10
10
|
*/
|
|
11
11
|
export interface WebitelKbArticlesMoveArticleBody {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* New parent id; 0 to move to top level. The article moves into the space
|
|
14
|
+
* of the parent.
|
|
15
|
+
*/
|
|
13
16
|
new_parent_id?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Target space id of the same language for a move to top level; 0 keeps
|
|
19
|
+
* the current space. With a new parent it may only repeat its space.
|
|
20
|
+
*/
|
|
21
|
+
new_space_id?: string;
|
|
14
22
|
}
|
|
@@ -2041,9 +2041,19 @@ export const MoveArticleBody = zod
|
|
|
2041
2041
|
new_parent_id: zod
|
|
2042
2042
|
.string()
|
|
2043
2043
|
.optional()
|
|
2044
|
-
.describe(
|
|
2044
|
+
.describe(
|
|
2045
|
+
'New parent id; 0 to move to top level. The article moves into the space\nof the parent.',
|
|
2046
|
+
),
|
|
2047
|
+
new_space_id: zod
|
|
2048
|
+
.string()
|
|
2049
|
+
.optional()
|
|
2050
|
+
.describe(
|
|
2051
|
+
'Target space id of the same language for a move to top level; 0 keeps\nthe current space. With a new parent it may only repeat its space.',
|
|
2052
|
+
),
|
|
2045
2053
|
})
|
|
2046
|
-
.describe(
|
|
2054
|
+
.describe(
|
|
2055
|
+
'MoveArticleRequest reparents an article, possibly into another space.',
|
|
2056
|
+
);
|
|
2047
2057
|
|
|
2048
2058
|
export const moveArticleResponseIndexStateDefault = `INDEX_STATE_UNSPECIFIED`;
|
|
2049
2059
|
export const moveArticleResponseStateDefault = `ARTICLE_STATE_UNSPECIFIED`;
|
|
@@ -574,6 +574,12 @@ export const ListSpacesQueryParams = zod.object({
|
|
|
574
574
|
.describe(
|
|
575
575
|
'Optional state filter.\n\n - SPACE_STATE_ACTIVE: Articles of the space are retrievable.\n - SPACE_STATE_INACTIVE: Articles are kept but excluded from search and suggestions.',
|
|
576
576
|
),
|
|
577
|
+
languages: zod
|
|
578
|
+
.array(zod.string())
|
|
579
|
+
.optional()
|
|
580
|
+
.describe(
|
|
581
|
+
'Optional language filter, at most 50 tags; matches the base language of\nany of them.',
|
|
582
|
+
),
|
|
577
583
|
});
|
|
578
584
|
|
|
579
585
|
export const listSpacesResponseItemsItemStateDefault = `SPACE_STATE_UNSPECIFIED`;
|