@ctil/gql 1.0.12 → 1.0.13

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/index.cjs CHANGED
@@ -2749,6 +2749,7 @@ __export(index_exports, {
2749
2749
  getBrowserDeviceInfo: () => getBrowserDeviceInfo,
2750
2750
  getClient: () => getClient,
2751
2751
  getDeviceInfo: () => getDeviceInfo,
2752
+ getRateLimitConfig: () => getRateLimitConfig,
2752
2753
  gql: () => gql,
2753
2754
  initGraphQLClient: () => initGraphQLClient,
2754
2755
  mutation: () => mutation,
@@ -2759,6 +2760,7 @@ __export(index_exports, {
2759
2760
  setEndpoint: () => setEndpoint,
2760
2761
  setHeader: () => setHeader,
2761
2762
  setHeaders: () => setHeaders,
2763
+ setRateLimitConfig: () => setRateLimitConfig,
2762
2764
  setToken: () => setToken,
2763
2765
  sms: () => sms,
2764
2766
  useInterceptor: () => useInterceptor
@@ -4172,8 +4174,8 @@ function buildGraphQLGetFilePreview(resourceId) {
4172
4174
  // src/rateLimit/rateLimitConfig.ts
4173
4175
  var rateLimitConfig = {
4174
4176
  defaultRules: {
4175
- query: { max: 10, window: 1, debounce: 0 },
4176
- mutation: { max: 3, window: 1, debounce: 200 }
4177
+ query: { max: 20, window: 1, debounce: 0 },
4178
+ mutation: { max: 10, window: 1, debounce: 200 }
4177
4179
  },
4178
4180
  custom: {
4179
4181
  login: { max: 1, window: 5, debounce: 0 },
@@ -4182,11 +4184,18 @@ var rateLimitConfig = {
4182
4184
  };
4183
4185
 
4184
4186
  // src/rateLimit/rateLimit.ts
4187
+ var globalConfig = rateLimitConfig;
4188
+ function setRateLimitConfig(newConfig) {
4189
+ globalConfig = newConfig;
4190
+ }
4191
+ function getRateLimitConfig() {
4192
+ return globalConfig;
4193
+ }
4185
4194
  var trackers = /* @__PURE__ */ new Map();
4186
4195
  function getRule(operateName, type, config) {
4187
4196
  return config.custom?.[operateName] || config.defaultRules[type];
4188
4197
  }
4189
- function rateLimit(operateName, type, fn, config = rateLimitConfig) {
4198
+ function rateLimit(operateName, type, fn, config = globalConfig) {
4190
4199
  const rule = getRule(operateName, type, config);
4191
4200
  const now = Date.now();
4192
4201
  const key = `${type}::${operateName}`;
@@ -4241,7 +4250,7 @@ var auth = {
4241
4250
  setLoginInfo(result.login, input.remember);
4242
4251
  clearCache();
4243
4252
  return result;
4244
- }, rateLimitConfig);
4253
+ });
4245
4254
  },
4246
4255
  async refreshToken(input) {
4247
4256
  return rateLimit("refreshToken", "mutation", async () => {
@@ -4250,7 +4259,7 @@ var auth = {
4250
4259
  setLoginInfo(result.refreshToken, input.remember);
4251
4260
  clearCache();
4252
4261
  return result;
4253
- }, rateLimitConfig);
4262
+ });
4254
4263
  },
4255
4264
  async register(input) {
4256
4265
  return rateLimit("registerUser", "mutation", async () => {
@@ -4258,7 +4267,7 @@ var auth = {
4258
4267
  const result = await execute({ query: query2, variables });
4259
4268
  clearCache();
4260
4269
  return result;
4261
- }, rateLimitConfig);
4270
+ });
4262
4271
  },
4263
4272
  async logout() {
4264
4273
  return rateLimit("logout", "mutation", async () => {
@@ -4267,7 +4276,7 @@ var auth = {
4267
4276
  removeLoginInfo();
4268
4277
  clearCache();
4269
4278
  return result;
4270
- }, rateLimitConfig);
4279
+ });
4271
4280
  },
4272
4281
  async logoutAllDevices() {
4273
4282
  return rateLimit("logoutAllDevices", "mutation", async () => {
@@ -4276,7 +4285,7 @@ var auth = {
4276
4285
  removeLoginInfo();
4277
4286
  clearCache();
4278
4287
  return result;
4279
- }, rateLimitConfig);
4288
+ });
4280
4289
  },
4281
4290
  async logoutDevice(deviceId) {
4282
4291
  return rateLimit("logoutDevice", "mutation", async () => {
@@ -4287,7 +4296,7 @@ var auth = {
4287
4296
  }
4288
4297
  clearCache();
4289
4298
  return result;
4290
- }, rateLimitConfig);
4299
+ });
4291
4300
  }
4292
4301
  };
4293
4302
 
@@ -4741,7 +4750,7 @@ var oss = {
4741
4750
  const { query: query2, variables } = buildGraphQLUploadPresignedUrl(presignedInput);
4742
4751
  const result = await execute({ query: query2, variables });
4743
4752
  return result;
4744
- }, rateLimitConfig);
4753
+ });
4745
4754
  console.log("presignedResult====>", presignedResult);
4746
4755
  if (!presignedResult.uploadPresignedUrl) throw new Error("\u83B7\u53D6\u9884\u7B7E\u540D URL \u5931\u8D25");
4747
4756
  const { uploadUrl, uploadHeaders, downloadUrl, resourceId, contentType, originalFileName } = presignedResult.uploadPresignedUrl;
@@ -4802,7 +4811,7 @@ var oss = {
4802
4811
  const { query: query2, variables } = buildGraphQLUploadPresignedUrl(presignedInput);
4803
4812
  const result = await execute({ query: query2, variables });
4804
4813
  return result;
4805
- }, rateLimitConfig);
4814
+ });
4806
4815
  if (!presignedResult.uploadPresignedUrl) throw new Error("\u83B7\u53D6\u9884\u7B7E\u540D URL \u5931\u8D25");
4807
4816
  const { uploadUrl, uploadHeaders, downloadUrl, resourceId, contentType, originalFileName } = presignedResult.uploadPresignedUrl;
4808
4817
  const headers = {};
@@ -4830,7 +4839,7 @@ var oss = {
4830
4839
  const { query: query2, variables } = buildGraphQLGetFilePreview(resourceId);
4831
4840
  const result = await execute({ query: query2, variables });
4832
4841
  return result;
4833
- }, rateLimitConfig);
4842
+ });
4834
4843
  }
4835
4844
  };
4836
4845
  // Annotate the CommonJS export names for ESM import in node:
@@ -4840,6 +4849,7 @@ var oss = {
4840
4849
  getBrowserDeviceInfo,
4841
4850
  getClient,
4842
4851
  getDeviceInfo,
4852
+ getRateLimitConfig,
4843
4853
  gql,
4844
4854
  initGraphQLClient,
4845
4855
  mutation,
@@ -4850,6 +4860,7 @@ var oss = {
4850
4860
  setEndpoint,
4851
4861
  setHeader,
4852
4862
  setHeaders,
4863
+ setRateLimitConfig,
4853
4864
  setToken,
4854
4865
  sms,
4855
4866
  useInterceptor