@scryme/chat 2.81.6 → 2.91.1
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/dist/custom-instance.js +3 -0
- package/dist/generated/v3-client.d.ts +8 -4
- package/dist/generated/v3-client.js +9 -9
- package/dist/generated/v3-server.d.ts +5 -1
- package/dist/generated/v3-server.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sdk.js +16 -12
- package/package.json +7 -3
- package/src/__tests__/custom-message.test.ts +133 -0
- package/src/__tests__/sdk.test.ts +11 -1
- package/src/custom-instance.ts +4 -0
- package/src/generated/v3-client.ts +18 -8
- package/src/generated/v3-server.ts +8 -1
- package/src/index.ts +26 -0
- package/src/sdk.ts +20 -12
package/dist/custom-instance.js
CHANGED
|
@@ -52,6 +52,9 @@ export var AXIOS_INSTANCE = axios.create({
|
|
|
52
52
|
withCredentials: true,
|
|
53
53
|
});
|
|
54
54
|
AXIOS_INSTANCE.interceptors.request.use(function (config) {
|
|
55
|
+
if (!config.baseURL) {
|
|
56
|
+
config.baseURL = getBaseURL();
|
|
57
|
+
}
|
|
55
58
|
if (!config.headers) {
|
|
56
59
|
config.headers = {};
|
|
57
60
|
}
|
|
@@ -320,6 +320,10 @@ export type V3OAuthControllerGetToken200 = {
|
|
|
320
320
|
success?: boolean;
|
|
321
321
|
timestamp?: string;
|
|
322
322
|
};
|
|
323
|
+
export type V10GuildsControllerGetMembersParams = {
|
|
324
|
+
limit: number;
|
|
325
|
+
after: string;
|
|
326
|
+
};
|
|
323
327
|
export type V10ChannelsControllerGetMessagesParams = {
|
|
324
328
|
limit?: number;
|
|
325
329
|
before?: string;
|
|
@@ -1464,9 +1468,9 @@ export declare const useV10GuildsControllerGetChannels: <TData = Awaited<ReturnT
|
|
|
1464
1468
|
}) => UseQueryResult<TData, TError> & {
|
|
1465
1469
|
queryKey: QueryKey;
|
|
1466
1470
|
};
|
|
1467
|
-
export declare const v10GuildsControllerGetMembers: (guildId: string, options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<void>;
|
|
1468
|
-
export declare const getV10GuildsControllerGetMembersQueryKey: (guildId: string) => readonly [`/api/bot/v10/guilds/${string}/members
|
|
1469
|
-
export declare const getV10GuildsControllerGetMembersQueryOptions: <TData = Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError = ErrorType<unknown>>(guildId: string, options?: {
|
|
1471
|
+
export declare const v10GuildsControllerGetMembers: (guildId: string, params: V10GuildsControllerGetMembersParams, options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => Promise<void>;
|
|
1472
|
+
export declare const getV10GuildsControllerGetMembersQueryKey: (guildId: string, params: V10GuildsControllerGetMembersParams) => readonly [`/api/bot/v10/guilds/${string}/members`, ...V10GuildsControllerGetMembersParams[]];
|
|
1473
|
+
export declare const getV10GuildsControllerGetMembersQueryOptions: <TData = Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError = ErrorType<unknown>>(guildId: string, params: V10GuildsControllerGetMembersParams, options?: {
|
|
1470
1474
|
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError, TData>>;
|
|
1471
1475
|
request?: SecondParameter<typeof customInstance>;
|
|
1472
1476
|
}) => UseQueryOptions<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError, TData> & {
|
|
@@ -1474,7 +1478,7 @@ export declare const getV10GuildsControllerGetMembersQueryOptions: <TData = Awai
|
|
|
1474
1478
|
};
|
|
1475
1479
|
export type V10GuildsControllerGetMembersQueryResult = NonNullable<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>>;
|
|
1476
1480
|
export type V10GuildsControllerGetMembersQueryError = ErrorType<unknown>;
|
|
1477
|
-
export declare const useV10GuildsControllerGetMembers: <TData = Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError = ErrorType<unknown>>(guildId: string, options?: {
|
|
1481
|
+
export declare const useV10GuildsControllerGetMembers: <TData = Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError = ErrorType<unknown>>(guildId: string, params: V10GuildsControllerGetMembersParams, options?: {
|
|
1478
1482
|
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError, TData>>;
|
|
1479
1483
|
request?: SecondParameter<typeof customInstance>;
|
|
1480
1484
|
}) => UseQueryResult<TData, TError> & {
|
|
@@ -879,25 +879,25 @@ export var useV10GuildsControllerGetChannels = function (guildId, options) {
|
|
|
879
879
|
query.queryKey = queryOptions.queryKey;
|
|
880
880
|
return query;
|
|
881
881
|
};
|
|
882
|
-
export var v10GuildsControllerGetMembers = function (guildId, options, signal) {
|
|
883
|
-
return customInstance({ url: "/api/bot/v10/guilds/".concat(guildId, "/members"), method: 'GET', signal: signal
|
|
882
|
+
export var v10GuildsControllerGetMembers = function (guildId, params, options, signal) {
|
|
883
|
+
return customInstance({ url: "/api/bot/v10/guilds/".concat(guildId, "/members"), method: 'GET', params: params, signal: signal
|
|
884
884
|
}, options);
|
|
885
885
|
};
|
|
886
|
-
export var getV10GuildsControllerGetMembersQueryKey = function (guildId) {
|
|
887
|
-
return ["/api/bot/v10/guilds/".concat(guildId, "/members")];
|
|
886
|
+
export var getV10GuildsControllerGetMembersQueryKey = function (guildId, params) {
|
|
887
|
+
return __spreadArray(["/api/bot/v10/guilds/".concat(guildId, "/members")], (params ? [params] : []), true);
|
|
888
888
|
};
|
|
889
|
-
export var getV10GuildsControllerGetMembersQueryOptions = function (guildId, options) {
|
|
889
|
+
export var getV10GuildsControllerGetMembersQueryOptions = function (guildId, params, options) {
|
|
890
890
|
var _a;
|
|
891
891
|
var _b = options !== null && options !== void 0 ? options : {}, queryOptions = _b.query, requestOptions = _b.request;
|
|
892
|
-
var queryKey = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.queryKey) !== null && _a !== void 0 ? _a : getV10GuildsControllerGetMembersQueryKey(guildId);
|
|
892
|
+
var queryKey = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.queryKey) !== null && _a !== void 0 ? _a : getV10GuildsControllerGetMembersQueryKey(guildId, params);
|
|
893
893
|
var queryFn = function (_a) {
|
|
894
894
|
var signal = _a.signal;
|
|
895
|
-
return v10GuildsControllerGetMembers(guildId, requestOptions, signal);
|
|
895
|
+
return v10GuildsControllerGetMembers(guildId, params, requestOptions, signal);
|
|
896
896
|
};
|
|
897
897
|
return __assign({ queryKey: queryKey, queryFn: queryFn, enabled: !!(guildId) }, queryOptions);
|
|
898
898
|
};
|
|
899
|
-
export var useV10GuildsControllerGetMembers = function (guildId, options) {
|
|
900
|
-
var queryOptions = getV10GuildsControllerGetMembersQueryOptions(guildId, options);
|
|
899
|
+
export var useV10GuildsControllerGetMembers = function (guildId, params, options) {
|
|
900
|
+
var queryOptions = getV10GuildsControllerGetMembersQueryOptions(guildId, params, options);
|
|
901
901
|
var query = useQuery(queryOptions);
|
|
902
902
|
query.queryKey = queryOptions.queryKey;
|
|
903
903
|
return query;
|
|
@@ -326,6 +326,10 @@ export type V3OAuthControllerGetToken200 = {
|
|
|
326
326
|
success?: boolean;
|
|
327
327
|
timestamp?: string;
|
|
328
328
|
};
|
|
329
|
+
export type V10GuildsControllerGetMembersParams = {
|
|
330
|
+
limit: number;
|
|
331
|
+
after: string;
|
|
332
|
+
};
|
|
329
333
|
export type V10ChannelsControllerGetMessagesParams = {
|
|
330
334
|
limit?: number;
|
|
331
335
|
before?: string;
|
|
@@ -885,7 +889,7 @@ export declare const getSkyrmeChatAPI: () => {
|
|
|
885
889
|
v10ChannelsControllerDeleteMessage: (id: string, messageId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
886
890
|
v10GuildsControllerGetGuild: (guildId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
887
891
|
v10GuildsControllerGetChannels: (guildId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
888
|
-
v10GuildsControllerGetMembers: (guildId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
892
|
+
v10GuildsControllerGetMembers: (guildId: string, params: V10GuildsControllerGetMembersParams, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
889
893
|
v10GuildsControllerGetRoles: (guildId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
890
894
|
v10GuildsControllerAddMemberRole: (guildId: string, userId: string, roleId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
891
895
|
v10GuildsControllerRemoveMemberRole: (guildId: string, userId: string, roleId: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
|
|
@@ -313,8 +313,9 @@ export var getSkyrmeChatAPI = function () {
|
|
|
313
313
|
var v10GuildsControllerGetChannels = function (guildId, options) {
|
|
314
314
|
return customInstance({ url: "/api/bot/v10/guilds/".concat(guildId, "/channels"), method: 'GET' }, options);
|
|
315
315
|
};
|
|
316
|
-
var v10GuildsControllerGetMembers = function (guildId, options) {
|
|
317
|
-
return customInstance({ url: "/api/bot/v10/guilds/".concat(guildId, "/members"), method: 'GET'
|
|
316
|
+
var v10GuildsControllerGetMembers = function (guildId, params, options) {
|
|
317
|
+
return customInstance({ url: "/api/bot/v10/guilds/".concat(guildId, "/members"), method: 'GET', params: params
|
|
318
|
+
}, options);
|
|
318
319
|
};
|
|
319
320
|
var v10GuildsControllerGetRoles = function (guildId, options) {
|
|
320
321
|
return customInstance({ url: "/api/bot/v10/guilds/".concat(guildId, "/roles"), method: 'GET' }, options);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './custom-instance';
|
|
2
2
|
export * from './generated/v3-client';
|
|
3
3
|
export * from './sdk';
|
|
4
|
+
export { CustomMessageSchema, MessageNodeSchema, ConditionSchema, ValidationSchema, DataSourceSchema, CustomMessageThemeSchema, PredefinedCustomMessageTypeSchema, MessageActionSchema, createApprovalMessage, createReportMessage, createFormMessage, createTaskCardMessage, type CustomMessage, type MessageNode, type ConditionSchemaType, type ValidationSchemaType, type CustomMessageTheme, type PredefinedCustomMessageType, type MessageAction, type CreateApprovalMessageOptions, type CreateReportMessageOptions, type CreateFormMessageOptions, type CreateTaskCardMessageOptions, type FormFieldConfig, } from '@repo/shared';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './custom-instance';
|
|
2
2
|
export * from './generated/v3-client';
|
|
3
3
|
export * from './sdk';
|
|
4
|
+
export { CustomMessageSchema, MessageNodeSchema, ConditionSchema, ValidationSchema, DataSourceSchema, CustomMessageThemeSchema, PredefinedCustomMessageTypeSchema, MessageActionSchema, createApprovalMessage, createReportMessage, createFormMessage, createTaskCardMessage, } from '@repo/shared';
|
package/dist/sdk.js
CHANGED
|
@@ -217,28 +217,32 @@ var ScrymeSDK = /** @class */ (function () {
|
|
|
217
217
|
args[_i] = arguments[_i];
|
|
218
218
|
}
|
|
219
219
|
return __awaiter(_this, void 0, void 0, function () {
|
|
220
|
-
var config, arity,
|
|
220
|
+
var config, arity, cleanArgs, lastArg, isLastArgOptions, userOptions;
|
|
221
221
|
return __generator(this, function (_a) {
|
|
222
222
|
switch (_a.label) {
|
|
223
223
|
case 0: return [4 /*yield*/, this.getRequestConfig()];
|
|
224
224
|
case 1:
|
|
225
225
|
config = _a.sent();
|
|
226
226
|
arity = originalMethod.length;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
cleanArgs = __spreadArray([], args, true);
|
|
228
|
+
while (cleanArgs.length > 0 && cleanArgs[cleanArgs.length - 1] === undefined) {
|
|
229
|
+
cleanArgs.pop();
|
|
230
|
+
}
|
|
231
|
+
lastArg = cleanArgs.length > 0 ? cleanArgs[cleanArgs.length - 1] : undefined;
|
|
232
|
+
isLastArgOptions = cleanArgs.length === arity &&
|
|
233
|
+
typeof lastArg === 'object' &&
|
|
234
|
+
lastArg !== null;
|
|
235
|
+
if (isLastArgOptions) {
|
|
236
|
+
userOptions = lastArg;
|
|
237
|
+
cleanArgs[cleanArgs.length - 1] = __assign(__assign({}, userOptions), { baseURL: config.baseURL, headers: __assign(__assign({}, config.headers), userOptions.headers) });
|
|
233
238
|
}
|
|
234
239
|
else {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
newArgs.push(undefined);
|
|
240
|
+
while (cleanArgs.length < arity - 1) {
|
|
241
|
+
cleanArgs.push(undefined);
|
|
238
242
|
}
|
|
239
|
-
|
|
243
|
+
cleanArgs.push(config);
|
|
240
244
|
}
|
|
241
|
-
return [2 /*return*/, originalMethod.apply(void 0,
|
|
245
|
+
return [2 /*return*/, originalMethod.apply(void 0, cleanArgs)];
|
|
242
246
|
}
|
|
243
247
|
});
|
|
244
248
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scryme/chat",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.91.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@tanstack/react-query": "5.96.2",
|
|
31
|
-
"axios": "^1.7.9"
|
|
31
|
+
"axios": "^1.7.9",
|
|
32
|
+
"@repo/shared": "0.1.0-dev.31"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"react": "^18.0.0 || ^19.0.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
38
|
+
"@openapitools/openapi-generator-cli": "^2.13.5",
|
|
37
39
|
"@types/node": "^22.10.7",
|
|
38
40
|
"@types/react": "^19.2.14",
|
|
39
41
|
"orval": "^6.31.0",
|
|
@@ -42,7 +44,9 @@
|
|
|
42
44
|
"@repo/typescript-config": "0.1.0-dev.31"
|
|
43
45
|
},
|
|
44
46
|
"scripts": {
|
|
45
|
-
"generate": "orval",
|
|
47
|
+
"generate:ts": "orval",
|
|
48
|
+
"generate:rust": "node -e \"const pkg=require('./package.json'); require('child_process').execSync('openapi-generator-cli generate -i ../../apps/api/openapi.json -g rust -o rust --skip-validate-spec --additional-properties=packageName=scryme-sdk,packageVersion=' + pkg.version + ',useSingleRequestParameter=true', {stdio: 'inherit'})\"",
|
|
49
|
+
"generate": "pnpm generate:ts && pnpm generate:rust",
|
|
46
50
|
"build": "tsc",
|
|
47
51
|
"type-check": "tsc --noEmit",
|
|
48
52
|
"test": "vitest run"
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
CustomMessageSchema,
|
|
4
|
+
createApprovalMessage,
|
|
5
|
+
createReportMessage,
|
|
6
|
+
createFormMessage,
|
|
7
|
+
createTaskCardMessage,
|
|
8
|
+
} from '../index';
|
|
9
|
+
|
|
10
|
+
describe('Custom Message Schema & Helper Builders', () => {
|
|
11
|
+
describe('createApprovalMessage', () => {
|
|
12
|
+
it('should generate a valid CustomMessage for approvals', () => {
|
|
13
|
+
const approval = createApprovalMessage({
|
|
14
|
+
title: 'Expense Reimbursement',
|
|
15
|
+
description: '$250 travel expense request',
|
|
16
|
+
fields: [
|
|
17
|
+
{ label: 'Category', value: 'Travel' },
|
|
18
|
+
{ label: 'Amount', value: '$250.00' },
|
|
19
|
+
],
|
|
20
|
+
callbackId: 'reimbursement_123',
|
|
21
|
+
priority: 'urgent',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
expect(approval.type).toBe('APPROVAL');
|
|
25
|
+
expect(approval.context.title).toBe('Expense Reimbursement');
|
|
26
|
+
expect(approval.context.priority).toBe('urgent');
|
|
27
|
+
expect(approval.actions).toHaveLength(2);
|
|
28
|
+
expect(approval.actions?.[0].id).toBe('approve');
|
|
29
|
+
expect(approval.actions?.[1].id).toBe('reject');
|
|
30
|
+
|
|
31
|
+
const validationResult = CustomMessageSchema.safeParse(approval);
|
|
32
|
+
expect(validationResult.success).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('createReportMessage', () => {
|
|
37
|
+
it('should generate a valid CustomMessage for reports', () => {
|
|
38
|
+
const report = createReportMessage({
|
|
39
|
+
title: 'Weekly Analytics Summary',
|
|
40
|
+
reportId: 'rep-456',
|
|
41
|
+
summary: 'Traffic increased by 25% this week.',
|
|
42
|
+
metrics: [
|
|
43
|
+
{ label: 'Total Visits', value: '45,200' },
|
|
44
|
+
{ label: 'Conversion Rate', value: '3.4%' },
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(report.type).toBe('REPORT');
|
|
49
|
+
expect(report.actions?.[0].handler.url).toBe('/reports/rep-456');
|
|
50
|
+
|
|
51
|
+
const validationResult = CustomMessageSchema.safeParse(report);
|
|
52
|
+
expect(validationResult.success).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('createFormMessage', () => {
|
|
57
|
+
it('should generate a valid CustomMessage for forms and surveys', () => {
|
|
58
|
+
const form = createFormMessage({
|
|
59
|
+
title: 'User Feedback Survey',
|
|
60
|
+
description: 'Please rate your experience',
|
|
61
|
+
submitCallbackId: 'survey_submit_1',
|
|
62
|
+
fields: [
|
|
63
|
+
{
|
|
64
|
+
id: 'satisfaction',
|
|
65
|
+
label: 'Overall Satisfaction',
|
|
66
|
+
type: 'select',
|
|
67
|
+
required: true,
|
|
68
|
+
options: [
|
|
69
|
+
{ label: 'High', value: 'high' },
|
|
70
|
+
{ label: 'Medium', value: 'medium' },
|
|
71
|
+
{ label: 'Low', value: 'low' },
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'comments',
|
|
76
|
+
label: 'Additional Comments',
|
|
77
|
+
type: 'textarea',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
expect(form.type).toBe('FORM');
|
|
83
|
+
expect(form.root.children).toHaveLength(2);
|
|
84
|
+
expect(form.root.children?.[0].type).toBe('Input.Select');
|
|
85
|
+
expect(form.root.children?.[0].validation?.required).toBe(true);
|
|
86
|
+
|
|
87
|
+
const validationResult = CustomMessageSchema.safeParse(form);
|
|
88
|
+
expect(validationResult.success).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('createTaskCardMessage', () => {
|
|
93
|
+
it('should generate a valid CustomMessage for task cards', () => {
|
|
94
|
+
const taskCard = createTaskCardMessage({
|
|
95
|
+
title: 'Design System Update',
|
|
96
|
+
description: 'Refactor button component variants',
|
|
97
|
+
status: 'In Progress',
|
|
98
|
+
assignee: 'Alice',
|
|
99
|
+
dueDate: '2025-04-01',
|
|
100
|
+
callbackId: 'task_complete_99',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect(taskCard.type).toBe('TASK_CARD');
|
|
104
|
+
expect(taskCard.actions?.[0].id).toBe('complete_task');
|
|
105
|
+
|
|
106
|
+
const validationResult = CustomMessageSchema.safeParse(taskCard);
|
|
107
|
+
expect(validationResult.success).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('Customization and Theming', () => {
|
|
112
|
+
it('should validate custom message theme overrides', () => {
|
|
113
|
+
const customMessage = createApprovalMessage({
|
|
114
|
+
title: 'Custom Brand Approval',
|
|
115
|
+
fields: [],
|
|
116
|
+
callbackId: 'cb_1',
|
|
117
|
+
theme: {
|
|
118
|
+
backgroundColor: '#0f172a',
|
|
119
|
+
textColor: '#f8fafc',
|
|
120
|
+
borderColor: '#334155',
|
|
121
|
+
accentColor: '#38bdf8',
|
|
122
|
+
className: 'custom-dark-card',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(customMessage.theme?.backgroundColor).toBe('#0f172a');
|
|
127
|
+
expect(customMessage.theme?.className).toBe('custom-dark-card');
|
|
128
|
+
|
|
129
|
+
const validationResult = CustomMessageSchema.safeParse(customMessage);
|
|
130
|
+
expect(validationResult.success).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -328,7 +328,7 @@ describe('ScrymeSDK', () => {
|
|
|
328
328
|
});
|
|
329
329
|
|
|
330
330
|
describe('Nested DX Helper Namespaces', () => {
|
|
331
|
-
it('should support workspace namespace', async () => {
|
|
331
|
+
it('should support workspace namespace and correctly propagate baseURL and options when provisioning/creating', async () => {
|
|
332
332
|
const sdk = new ScrymeSDK({
|
|
333
333
|
baseURL: 'https://api.test.com',
|
|
334
334
|
token: 'active-token',
|
|
@@ -336,9 +336,17 @@ describe('ScrymeSDK', () => {
|
|
|
336
336
|
|
|
337
337
|
const listRes = await sdk.workspace.list() as any;
|
|
338
338
|
expect(listRes.success).toBe(true);
|
|
339
|
+
expect(listRes.options.baseURL).toBe('https://api.test.com');
|
|
339
340
|
|
|
340
341
|
const getRes = await sdk.workspace.get('acme') as any;
|
|
341
342
|
expect(getRes.data.workspace.slug).toBe('acme');
|
|
343
|
+
expect(getRes.options.baseURL).toBe('https://api.test.com');
|
|
344
|
+
|
|
345
|
+
const provDto = { name: 'Acme', ownerEmail: 'a@acme.com', slug: 'acme' };
|
|
346
|
+
const createRes = await sdk.workspace.create(provDto) as any;
|
|
347
|
+
expect(createRes.success).toBe(true);
|
|
348
|
+
expect(createRes.options.baseURL).toBe('https://api.test.com');
|
|
349
|
+
expect(createRes.options.headers.Authorization).toBe('Bearer active-token');
|
|
342
350
|
});
|
|
343
351
|
|
|
344
352
|
it('should support workspace channels namespace', async () => {
|
|
@@ -467,6 +475,8 @@ describe('ScrymeSDK', () => {
|
|
|
467
475
|
// m2m.workspace.provision
|
|
468
476
|
const provRes = await sdk.m2m.workspace.provision({ name: 'Acme', ownerEmail: 'a@acme.com', slug: 'acme' }) as any;
|
|
469
477
|
expect(provRes.data.name).toBe('Acme');
|
|
478
|
+
expect(provRes.options.baseURL).toBe('https://api.test.com');
|
|
479
|
+
expect(provRes.options.headers.Authorization).toBe('Bearer active-token');
|
|
470
480
|
|
|
471
481
|
// m2m.member.add
|
|
472
482
|
const addMem = await sdk.m2m.member.add('acme', { email: 'user@acme.com', role: 'admin' }) as any;
|
package/src/custom-instance.ts
CHANGED
|
@@ -401,6 +401,11 @@ export type V3OAuthControllerGetToken200 = {
|
|
|
401
401
|
timestamp?: string;
|
|
402
402
|
};
|
|
403
403
|
|
|
404
|
+
export type V10GuildsControllerGetMembersParams = {
|
|
405
|
+
limit: number;
|
|
406
|
+
after: string;
|
|
407
|
+
};
|
|
408
|
+
|
|
404
409
|
export type V10ChannelsControllerGetMessagesParams = {
|
|
405
410
|
limit?: number;
|
|
406
411
|
before?: string;
|
|
@@ -2741,32 +2746,36 @@ export const useV10GuildsControllerGetChannels = <TData = Awaited<ReturnType<typ
|
|
|
2741
2746
|
|
|
2742
2747
|
export const v10GuildsControllerGetMembers = (
|
|
2743
2748
|
guildId: string,
|
|
2749
|
+
params: V10GuildsControllerGetMembersParams,
|
|
2744
2750
|
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
2745
2751
|
) => {
|
|
2746
2752
|
|
|
2747
2753
|
|
|
2748
2754
|
return customInstance<void>(
|
|
2749
|
-
{url: `/api/bot/v10/guilds/${guildId}/members`, method: 'GET',
|
|
2755
|
+
{url: `/api/bot/v10/guilds/${guildId}/members`, method: 'GET',
|
|
2756
|
+
params, signal
|
|
2750
2757
|
},
|
|
2751
2758
|
options);
|
|
2752
2759
|
}
|
|
2753
2760
|
|
|
2754
2761
|
|
|
2755
|
-
export const getV10GuildsControllerGetMembersQueryKey = (guildId: string,
|
|
2756
|
-
|
|
2762
|
+
export const getV10GuildsControllerGetMembersQueryKey = (guildId: string,
|
|
2763
|
+
params: V10GuildsControllerGetMembersParams,) => {
|
|
2764
|
+
return [`/api/bot/v10/guilds/${guildId}/members`, ...(params ? [params]: [])] as const;
|
|
2757
2765
|
}
|
|
2758
2766
|
|
|
2759
2767
|
|
|
2760
|
-
export const getV10GuildsControllerGetMembersQueryOptions = <TData = Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError = ErrorType<unknown>>(guildId: string,
|
|
2768
|
+
export const getV10GuildsControllerGetMembersQueryOptions = <TData = Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError = ErrorType<unknown>>(guildId: string,
|
|
2769
|
+
params: V10GuildsControllerGetMembersParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
2761
2770
|
) => {
|
|
2762
2771
|
|
|
2763
2772
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
2764
2773
|
|
|
2765
|
-
const queryKey = queryOptions?.queryKey ?? getV10GuildsControllerGetMembersQueryKey(guildId);
|
|
2774
|
+
const queryKey = queryOptions?.queryKey ?? getV10GuildsControllerGetMembersQueryKey(guildId,params);
|
|
2766
2775
|
|
|
2767
2776
|
|
|
2768
2777
|
|
|
2769
|
-
const queryFn: QueryFunction<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>> = ({ signal }) => v10GuildsControllerGetMembers(guildId, requestOptions, signal);
|
|
2778
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>> = ({ signal }) => v10GuildsControllerGetMembers(guildId,params, requestOptions, signal);
|
|
2770
2779
|
|
|
2771
2780
|
|
|
2772
2781
|
|
|
@@ -2779,11 +2788,12 @@ export type V10GuildsControllerGetMembersQueryResult = NonNullable<Awaited<Retur
|
|
|
2779
2788
|
export type V10GuildsControllerGetMembersQueryError = ErrorType<unknown>
|
|
2780
2789
|
|
|
2781
2790
|
export const useV10GuildsControllerGetMembers = <TData = Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError = ErrorType<unknown>>(
|
|
2782
|
-
guildId: string,
|
|
2791
|
+
guildId: string,
|
|
2792
|
+
params: V10GuildsControllerGetMembersParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
2783
2793
|
|
|
2784
2794
|
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
2785
2795
|
|
|
2786
|
-
const queryOptions = getV10GuildsControllerGetMembersQueryOptions(guildId,options)
|
|
2796
|
+
const queryOptions = getV10GuildsControllerGetMembersQueryOptions(guildId,params,options)
|
|
2787
2797
|
|
|
2788
2798
|
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
2789
2799
|
|
|
@@ -388,6 +388,11 @@ export type V3OAuthControllerGetToken200 = {
|
|
|
388
388
|
timestamp?: string;
|
|
389
389
|
};
|
|
390
390
|
|
|
391
|
+
export type V10GuildsControllerGetMembersParams = {
|
|
392
|
+
limit: number;
|
|
393
|
+
after: string;
|
|
394
|
+
};
|
|
395
|
+
|
|
391
396
|
export type V10ChannelsControllerGetMessagesParams = {
|
|
392
397
|
limit?: number;
|
|
393
398
|
before?: string;
|
|
@@ -1366,9 +1371,11 @@ const v10GuildsControllerGetChannels = (
|
|
|
1366
1371
|
|
|
1367
1372
|
const v10GuildsControllerGetMembers = (
|
|
1368
1373
|
guildId: string,
|
|
1374
|
+
params: V10GuildsControllerGetMembersParams,
|
|
1369
1375
|
options?: SecondParameter<typeof customInstance>,) => {
|
|
1370
1376
|
return customInstance<void>(
|
|
1371
|
-
{url: `/api/bot/v10/guilds/${guildId}/members`, method: 'GET'
|
|
1377
|
+
{url: `/api/bot/v10/guilds/${guildId}/members`, method: 'GET',
|
|
1378
|
+
params
|
|
1372
1379
|
},
|
|
1373
1380
|
options);
|
|
1374
1381
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
export * from './custom-instance';
|
|
2
2
|
export * from './generated/v3-client';
|
|
3
3
|
export * from './sdk';
|
|
4
|
+
export {
|
|
5
|
+
CustomMessageSchema,
|
|
6
|
+
MessageNodeSchema,
|
|
7
|
+
ConditionSchema,
|
|
8
|
+
ValidationSchema,
|
|
9
|
+
DataSourceSchema,
|
|
10
|
+
CustomMessageThemeSchema,
|
|
11
|
+
PredefinedCustomMessageTypeSchema,
|
|
12
|
+
MessageActionSchema,
|
|
13
|
+
createApprovalMessage,
|
|
14
|
+
createReportMessage,
|
|
15
|
+
createFormMessage,
|
|
16
|
+
createTaskCardMessage,
|
|
17
|
+
type CustomMessage,
|
|
18
|
+
type MessageNode,
|
|
19
|
+
type ConditionSchemaType,
|
|
20
|
+
type ValidationSchemaType,
|
|
21
|
+
type CustomMessageTheme,
|
|
22
|
+
type PredefinedCustomMessageType,
|
|
23
|
+
type MessageAction,
|
|
24
|
+
type CreateApprovalMessageOptions,
|
|
25
|
+
type CreateReportMessageOptions,
|
|
26
|
+
type CreateFormMessageOptions,
|
|
27
|
+
type CreateTaskCardMessageOptions,
|
|
28
|
+
type FormFieldConfig,
|
|
29
|
+
} from '@repo/shared';
|
package/src/sdk.ts
CHANGED
|
@@ -751,29 +751,37 @@ export class ScrymeSDK {
|
|
|
751
751
|
return async (...args: unknown[]) => {
|
|
752
752
|
const config = await this.getRequestConfig();
|
|
753
753
|
const arity = originalMethod.length;
|
|
754
|
-
const newArgs = [...args];
|
|
755
754
|
|
|
756
|
-
//
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
755
|
+
// Strip trailing undefined values to accurately check user-provided parameters
|
|
756
|
+
const cleanArgs = [...args];
|
|
757
|
+
while (cleanArgs.length > 0 && cleanArgs[cleanArgs.length - 1] === undefined) {
|
|
758
|
+
cleanArgs.pop();
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const lastArg = cleanArgs.length > 0 ? cleanArgs[cleanArgs.length - 1] : undefined;
|
|
762
|
+
const isLastArgOptions =
|
|
763
|
+
cleanArgs.length === arity &&
|
|
764
|
+
typeof lastArg === 'object' &&
|
|
765
|
+
lastArg !== null;
|
|
766
|
+
|
|
767
|
+
if (isLastArgOptions) {
|
|
768
|
+
const userOptions = lastArg as AxiosRequestConfig;
|
|
769
|
+
cleanArgs[cleanArgs.length - 1] = {
|
|
761
770
|
...userOptions,
|
|
762
771
|
baseURL: config.baseURL,
|
|
763
772
|
headers: {
|
|
764
773
|
...config.headers,
|
|
765
|
-
...userOptions
|
|
774
|
+
...userOptions.headers,
|
|
766
775
|
},
|
|
767
776
|
};
|
|
768
777
|
} else {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
newArgs.push(undefined);
|
|
778
|
+
while (cleanArgs.length < arity - 1) {
|
|
779
|
+
cleanArgs.push(undefined);
|
|
772
780
|
}
|
|
773
|
-
|
|
781
|
+
cleanArgs.push(config);
|
|
774
782
|
}
|
|
775
783
|
|
|
776
|
-
return (originalMethod as (...a: unknown[]) => unknown)(...
|
|
784
|
+
return (originalMethod as (...a: unknown[]) => unknown)(...cleanArgs);
|
|
777
785
|
};
|
|
778
786
|
}
|
|
779
787
|
return originalMethod;
|