@webitel/api-services 26.8.82 → 26.8.84
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
CHANGED
|
@@ -52,7 +52,13 @@ const getTeamFlowsList = async (params: ApiParams) => {
|
|
|
52
52
|
// the generated param is `q`; `search` is what the datalist store sends
|
|
53
53
|
q: search,
|
|
54
54
|
sort,
|
|
55
|
-
|
|
55
|
+
// [Claude] list renders a link to the schema, so `schema` is always requested
|
|
56
|
+
fields: [
|
|
57
|
+
...new Set([
|
|
58
|
+
...(fields ?? []),
|
|
59
|
+
'schema',
|
|
60
|
+
]),
|
|
61
|
+
],
|
|
56
62
|
enabled,
|
|
57
63
|
id,
|
|
58
64
|
},
|
|
@@ -109,44 +109,57 @@ const getUsersList = async (params: ApiParams) => {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
const userItemDefaultObject = {
|
|
113
|
+
roles: [],
|
|
114
|
+
license: [],
|
|
115
|
+
devices: [],
|
|
116
|
+
device: {},
|
|
117
|
+
generateDevice: false,
|
|
118
|
+
variables: [
|
|
119
|
+
{
|
|
120
|
+
key: '',
|
|
121
|
+
value: '',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// [Claude] shared by get/add/update: the card shows the add/update response without re-fetching the user
|
|
127
|
+
const itemResponseHandler = (item: ApiParams) => {
|
|
128
|
+
const copy = deepCopy(item);
|
|
129
|
+
if (copy.license) {
|
|
130
|
+
copy.license.forEach((item: ApiParams) => {
|
|
131
|
+
item.name = item.prod;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (copy.profile) {
|
|
135
|
+
copy.variables = Object.keys(copy.profile).map((key) => ({
|
|
136
|
+
key,
|
|
137
|
+
value: copy.profile[key],
|
|
138
|
+
}));
|
|
139
|
+
} else {
|
|
140
|
+
copy.variables = [
|
|
120
141
|
{
|
|
121
142
|
key: '',
|
|
122
143
|
value: '',
|
|
123
144
|
},
|
|
124
|
-
]
|
|
125
|
-
}
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
return copy;
|
|
148
|
+
};
|
|
126
149
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}));
|
|
139
|
-
} else {
|
|
140
|
-
copy.variables = [
|
|
141
|
-
{
|
|
142
|
-
key: '',
|
|
143
|
-
value: '',
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
}
|
|
147
|
-
return copy;
|
|
148
|
-
};
|
|
150
|
+
// [Claude] add/update responses echo license as `{ id }` only (see preRequestHandler) — take names from the sent item
|
|
151
|
+
const restoreLicenseNames =
|
|
152
|
+
(sentLicense: ApiParams[] = []) =>
|
|
153
|
+
(item: ApiParams) => ({
|
|
154
|
+
...item,
|
|
155
|
+
license: item.license.map((license: ApiParams) => ({
|
|
156
|
+
...license,
|
|
157
|
+
name:
|
|
158
|
+
license.name ?? sentLicense.find(({ id }) => id === license.id)?.name,
|
|
159
|
+
})),
|
|
160
|
+
});
|
|
149
161
|
|
|
162
|
+
const getUser = async ({ itemId: id }: GetItemParams) => {
|
|
150
163
|
const url = `${baseUrl}/${id}`;
|
|
151
164
|
|
|
152
165
|
try {
|
|
@@ -155,7 +168,7 @@ const getUser = async ({ itemId: id }: GetItemParams) => {
|
|
|
155
168
|
snakeToCamel([
|
|
156
169
|
'profile',
|
|
157
170
|
]),
|
|
158
|
-
merge(
|
|
171
|
+
merge(userItemDefaultObject),
|
|
159
172
|
itemResponseHandler,
|
|
160
173
|
]);
|
|
161
174
|
} catch (err) {
|
|
@@ -215,6 +228,9 @@ const addUser = async ({ itemInstance }: AddItemParams) => {
|
|
|
215
228
|
snakeToCamel([
|
|
216
229
|
'profile',
|
|
217
230
|
]),
|
|
231
|
+
merge(userItemDefaultObject),
|
|
232
|
+
itemResponseHandler,
|
|
233
|
+
restoreLicenseNames(itemInstance.license),
|
|
218
234
|
]);
|
|
219
235
|
} catch (err) {
|
|
220
236
|
throw applyTransform(err, [
|
|
@@ -247,6 +263,9 @@ const updateUser = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
|
247
263
|
snakeToCamel([
|
|
248
264
|
'profile',
|
|
249
265
|
]),
|
|
266
|
+
merge(userItemDefaultObject),
|
|
267
|
+
itemResponseHandler,
|
|
268
|
+
restoreLicenseNames(itemInstance.license),
|
|
250
269
|
]);
|
|
251
270
|
} catch (err) {
|
|
252
271
|
throw applyTransform(err, [
|