@arquimedes.co/eureka-forms 3.0.35 → 3.0.37

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.
@@ -85,13 +85,13 @@ export var calcValuesStore = function (orgInfo, form, originalValues, postview,
85
85
  case 0:
86
86
  step = form.steps[idValue];
87
87
  if (!step) return [3 /*break*/, 2];
88
+ if (!values.sections[step.idSection])
89
+ values.sections[step.idSection] = {};
88
90
  return [4 /*yield*/, mapOriginalValue(orgInfo, step, originalValues[step.id], values, form)];
89
91
  case 1:
90
92
  value = _b.sent();
91
93
  if (value !== undefined) {
92
94
  if (!((_a = form.hiddenSteps) === null || _a === void 0 ? void 0 : _a.includes(step.id))) {
93
- if (!values.sections[step.idSection])
94
- values.sections[step.idSection] = {};
95
95
  values.sections[step.idSection][step.id] = value;
96
96
  }
97
97
  else {
@@ -6,13 +6,7 @@ export declare const ApiSelectorApi: import("@reduxjs/toolkit/query").Api<import
6
6
  timeout?: number | undefined;
7
7
  method?: string | undefined;
8
8
  body?: any;
9
- params?: any; /**
10
- * Gets the normalized URL key (base + path without query params)
11
- * For URLs containing REACT_APP_DOMAIN, groups by path segments:
12
- * - 3+ segments: use all but last (e.g., /sinco/bitakora/ENDPOINT -> /sinco/bitakora/)
13
- * - 2 segments: use first only (e.g., /sinco/bitakora -> /sinco/)
14
- * - 1 segment: use first only (e.g., /sinco -> /sinco/)
15
- */
9
+ params?: any;
16
10
  headers?: Record<string, any> | undefined;
17
11
  }, unknown, unknown, {}, {}>, {
18
12
  fetchApiSelectorOptions: import("@reduxjs/toolkit/query").QueryDefinition<{
@@ -23,13 +17,7 @@ export declare const ApiSelectorApi: import("@reduxjs/toolkit/query").Api<import
23
17
  timeout?: number | undefined;
24
18
  method?: string | undefined;
25
19
  body?: any;
26
- params?: any; /**
27
- * Gets the normalized URL key (base + path without query params)
28
- * For URLs containing REACT_APP_DOMAIN, groups by path segments:
29
- * - 3+ segments: use all but last (e.g., /sinco/bitakora/ENDPOINT -> /sinco/bitakora/)
30
- * - 2 segments: use first only (e.g., /sinco/bitakora -> /sinco/)
31
- * - 1 segment: use first only (e.g., /sinco -> /sinco/)
32
- */
20
+ params?: any;
33
21
  headers?: Record<string, any> | undefined;
34
22
  }, unknown, unknown, {}, {}>, never, any[], "api">;
35
23
  }, "api", never, typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/dist/query/react").reactHooksModuleName>;
@@ -41,13 +29,7 @@ export declare const useFetchApiSelectorOptionsQuery: import("@reduxjs/toolkit/d
41
29
  timeout?: number | undefined;
42
30
  method?: string | undefined;
43
31
  body?: any;
44
- params?: any; /**
45
- * Gets the normalized URL key (base + path without query params)
46
- * For URLs containing REACT_APP_DOMAIN, groups by path segments:
47
- * - 3+ segments: use all but last (e.g., /sinco/bitakora/ENDPOINT -> /sinco/bitakora/)
48
- * - 2 segments: use first only (e.g., /sinco/bitakora -> /sinco/)
49
- * - 1 segment: use first only (e.g., /sinco -> /sinco/)
50
- */
32
+ params?: any;
51
33
  headers?: Record<string, any> | undefined;
52
34
  }, unknown, unknown, {}, {}>, never, any[], "api">>;
53
35
  /**
@@ -38,14 +38,15 @@ import { RootApi } from '../Utils/_api';
38
38
  import widgetInstance from '../Utils/AxiosWidget';
39
39
  import axiosInstance from '../Utils/AxiosAPI';
40
40
  /**
41
- * Queue manager to throttle requests per URL using a time-window approach
42
- * Limits total number of requests per time window regardless of response time
41
+ * Queue manager to throttle requests per URL ensuring minimum time between requests
42
+ * Ensures at least 0.5 second between request starts
43
43
  */
44
44
  var RequestThrottleManager = /** @class */ (function () {
45
45
  function RequestThrottleManager() {
46
- this.requestTimestamps = new Map();
47
- this.MAX_REQUESTS_PER_WINDOW = 1; // Max 1 request per time window
48
- this.TIME_WINDOW_MS = 1000; // 1 second time window
46
+ this.queues = new Map();
47
+ this.processing = new Map();
48
+ this.lastRequestTime = new Map();
49
+ this.MIN_TIME_BETWEEN_REQUESTS_MS = 500; // Minimum 0.5 seconds between requests
49
50
  }
50
51
  /**
51
52
  * Gets the normalized URL key (base + path without query params)
@@ -89,7 +90,7 @@ var RequestThrottleManager = /** @class */ (function () {
89
90
  }
90
91
  };
91
92
  /**
92
- * Executes a request with throttling based on time window
93
+ * Executes a request with throttling using a simple queue
93
94
  */
94
95
  RequestThrottleManager.prototype.executeRequest = function (url, requestFn) {
95
96
  return __awaiter(this, void 0, void 0, function () {
@@ -98,80 +99,70 @@ var RequestThrottleManager = /** @class */ (function () {
98
99
  switch (_a.label) {
99
100
  case 0:
100
101
  urlKey = this.getUrlKey(url);
101
- // Wait until we can make the request
102
- return [4 /*yield*/, this.waitForSlot(urlKey)];
102
+ // Wait for our turn in the queue
103
+ return [4 /*yield*/, this.waitInQueue(urlKey)];
103
104
  case 1:
104
- // Wait until we can make the request
105
+ // Wait for our turn in the queue
105
106
  _a.sent();
106
- // Record the request timestamp
107
- this.recordRequest(urlKey);
107
+ // Record when we're starting the request
108
+ this.lastRequestTime.set(urlKey, Date.now());
109
+ _a.label = 2;
110
+ case 2:
111
+ _a.trys.push([2, , 4, 5]);
108
112
  return [4 /*yield*/, requestFn()];
109
- case 2:
110
- // Execute the request (no need for try-finally since we already recorded it)
113
+ case 3:
114
+ // Execute the request
111
115
  return [2 /*return*/, _a.sent()];
116
+ case 4:
117
+ // Process next request in queue, waiting if necessary
118
+ this.scheduleNextRequest(urlKey);
119
+ return [7 /*endfinally*/];
120
+ case 5: return [2 /*return*/];
112
121
  }
113
122
  });
114
123
  });
115
124
  };
116
125
  /**
117
- * Cleans up old timestamps outside the time window
126
+ * Adds request to queue and waits for its turn
118
127
  */
119
- RequestThrottleManager.prototype.cleanupOldTimestamps = function (urlKey) {
120
- var timestamps = this.requestTimestamps.get(urlKey) || [];
121
- var now = Date.now();
122
- var cutoff = now - this.TIME_WINDOW_MS;
123
- // Filter out timestamps older than the time window
124
- var validTimestamps = timestamps.filter(function (ts) { return ts > cutoff; });
125
- if (validTimestamps.length > 0) {
126
- this.requestTimestamps.set(urlKey, validTimestamps);
127
- }
128
- else {
129
- this.requestTimestamps.delete(urlKey);
130
- }
128
+ RequestThrottleManager.prototype.waitInQueue = function (urlKey) {
129
+ var _this = this;
130
+ return new Promise(function (resolve) {
131
+ var queue = _this.queues.get(urlKey) || [];
132
+ queue.push({ resolve: resolve, timestamp: Date.now() });
133
+ _this.queues.set(urlKey, queue);
134
+ // If not already processing this queue, start processing
135
+ if (!_this.processing.get(urlKey)) {
136
+ _this.processQueue(urlKey);
137
+ }
138
+ });
131
139
  };
132
140
  /**
133
- * Records a new request timestamp
141
+ * Processes the next request in the queue
134
142
  */
135
- RequestThrottleManager.prototype.recordRequest = function (urlKey) {
136
- var timestamps = this.requestTimestamps.get(urlKey) || [];
137
- timestamps.push(Date.now());
138
- this.requestTimestamps.set(urlKey, timestamps);
143
+ RequestThrottleManager.prototype.processQueue = function (urlKey) {
144
+ var queue = this.queues.get(urlKey) || [];
145
+ if (queue.length === 0) {
146
+ this.processing.set(urlKey, false);
147
+ return;
148
+ }
149
+ this.processing.set(urlKey, true);
150
+ var resolve = queue.shift().resolve;
151
+ this.queues.set(urlKey, queue);
152
+ // Resolve immediately to allow request to proceed
153
+ resolve();
139
154
  };
140
155
  /**
141
- * Waits until a slot is available in the time window
156
+ * Schedules the next request in queue, waiting if necessary to maintain minimum time between requests
142
157
  */
143
- RequestThrottleManager.prototype.waitForSlot = function (urlKey) {
144
- return __awaiter(this, void 0, void 0, function () {
145
- var timestamps, oldestTimestamp, now, timeUntilSlotAvailable;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0:
149
- // Clean up old timestamps first
150
- this.cleanupOldTimestamps(urlKey);
151
- timestamps = this.requestTimestamps.get(urlKey) || [];
152
- if (timestamps.length < this.MAX_REQUESTS_PER_WINDOW) {
153
- // Slot available, can proceed immediately
154
- return [2 /*return*/, Promise.resolve()];
155
- }
156
- oldestTimestamp = timestamps[0];
157
- now = Date.now();
158
- timeUntilSlotAvailable = oldestTimestamp + this.TIME_WINDOW_MS - now;
159
- if (!(timeUntilSlotAvailable > 0)) return [3 /*break*/, 2];
160
- // Wait for the slot to become available
161
- return [4 /*yield*/, new Promise(function (resolve) {
162
- return setTimeout(resolve, timeUntilSlotAvailable + 10);
163
- })];
164
- case 1:
165
- // Wait for the slot to become available
166
- _a.sent(); // +10ms buffer
167
- // Recursively check again (in case multiple requests are queued)
168
- return [2 /*return*/, this.waitForSlot(urlKey)];
169
- case 2:
170
- // Slot should be available now
171
- return [2 /*return*/, Promise.resolve()];
172
- }
173
- });
174
- });
158
+ RequestThrottleManager.prototype.scheduleNextRequest = function (urlKey) {
159
+ var _this = this;
160
+ var lastTime = this.lastRequestTime.get(urlKey) || 0;
161
+ var timeSinceLastRequest = Date.now() - lastTime;
162
+ var waitTime = Math.max(0, this.MIN_TIME_BETWEEN_REQUESTS_MS - timeSinceLastRequest);
163
+ setTimeout(function () {
164
+ _this.processQueue(urlKey);
165
+ }, waitTime);
175
166
  };
176
167
  return RequestThrottleManager;
177
168
  }());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version": "3.0.35",
4
+ "version": "3.0.37",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",