@scryme/chat 2.85.1 → 2.91.2

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.
@@ -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' }, options);
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/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, newArgs, userOptions;
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
- newArgs = __spreadArray([], args, true);
228
- // Orval generated functions accept `options` as their last parameter.
229
- // If the user provided options, we merge them with our default request config.
230
- if (args.length >= arity && typeof args[args.length - 1] === 'object') {
231
- userOptions = args[args.length - 1];
232
- newArgs[args.length - 1] = __assign(__assign({}, userOptions), { baseURL: config.baseURL, headers: __assign(__assign({}, config.headers), userOptions === null || userOptions === void 0 ? void 0 : userOptions.headers) });
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
- // Otherwise, we pad missing parameters with undefined and append our config as the options object.
236
- while (newArgs.length < arity - 1) {
237
- newArgs.push(undefined);
240
+ while (cleanArgs.length < arity - 1) {
241
+ cleanArgs.push(undefined);
238
242
  }
239
- newArgs.push(config);
243
+ cleanArgs.push(config);
240
244
  }
241
- return [2 /*return*/, originalMethod.apply(void 0, newArgs)];
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.85.1",
3
+ "version": "2.91.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "scripts": {
47
47
  "generate:ts": "orval",
48
- "generate:rust": "openapi-generator-cli generate -i ../../apps/api/openapi.json -g rust -o rust --skip-validate-spec --additional-properties=packageName=scryme-sdk,packageVersion=2.81.5,useSingleRequestParameter=true",
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
49
  "generate": "pnpm generate:ts && pnpm generate:rust",
50
50
  "build": "tsc",
51
51
  "type-check": "tsc --noEmit",
@@ -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;
@@ -56,6 +56,10 @@ export const AXIOS_INSTANCE = axios.create({
56
56
  });
57
57
 
58
58
  AXIOS_INSTANCE.interceptors.request.use(config => {
59
+ if (!config.baseURL) {
60
+ config.baseURL = getBaseURL();
61
+ }
62
+
59
63
  if (!config.headers) {
60
64
  config.headers = {} as any;
61
65
  }
@@ -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', signal
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
- return [`/api/bot/v10/guilds/${guildId}/members`] as const;
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, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
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, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof v10GuildsControllerGetMembers>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
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/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
- // Orval generated functions accept `options` as their last parameter.
757
- // If the user provided options, we merge them with our default request config.
758
- if (args.length >= arity && typeof args[args.length - 1] === 'object') {
759
- const userOptions = args[args.length - 1] as AxiosRequestConfig;
760
- newArgs[args.length - 1] = {
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?.headers,
774
+ ...userOptions.headers,
766
775
  },
767
776
  };
768
777
  } else {
769
- // Otherwise, we pad missing parameters with undefined and append our config as the options object.
770
- while (newArgs.length < arity - 1) {
771
- newArgs.push(undefined);
778
+ while (cleanArgs.length < arity - 1) {
779
+ cleanArgs.push(undefined);
772
780
  }
773
- newArgs.push(config);
781
+ cleanArgs.push(config);
774
782
  }
775
783
 
776
- return (originalMethod as (...a: unknown[]) => unknown)(...newArgs);
784
+ return (originalMethod as (...a: unknown[]) => unknown)(...cleanArgs);
777
785
  };
778
786
  }
779
787
  return originalMethod;