@pallasoft/ps-utilities 2.1.0 → 2.3.0

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.
@@ -0,0 +1,8 @@
1
+ export interface DebouncedCall<Args extends unknown[]> {
2
+ cancel: () => void;
3
+ flush: () => void;
4
+ run: (...args: Args) => void;
5
+ }
6
+ export declare class DebounceService {
7
+ static create<Args extends unknown[]>(action: (...args: Args) => void, waitMs: number): DebouncedCall<Args>;
8
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DebounceService = void 0;
4
+ var DebounceService = /** @class */ (function () {
5
+ function DebounceService() {
6
+ }
7
+ DebounceService.create = function (action, waitMs) {
8
+ var timer = null;
9
+ var pending = null;
10
+ var clear = function () {
11
+ if (timer !== null)
12
+ clearTimeout(timer);
13
+ timer = null;
14
+ };
15
+ return {
16
+ cancel: function () {
17
+ clear();
18
+ pending = null;
19
+ },
20
+ flush: function () {
21
+ if (pending === null)
22
+ return;
23
+ var args = pending;
24
+ clear();
25
+ pending = null;
26
+ action.apply(void 0, args);
27
+ },
28
+ run: function () {
29
+ var args = [];
30
+ for (var _i = 0; _i < arguments.length; _i++) {
31
+ args[_i] = arguments[_i];
32
+ }
33
+ pending = args;
34
+ clear();
35
+ timer = setTimeout(function () {
36
+ timer = null;
37
+ pending = null;
38
+ action.apply(void 0, args);
39
+ }, waitMs);
40
+ },
41
+ };
42
+ };
43
+ return DebounceService;
44
+ }());
45
+ exports.DebounceService = DebounceService;
@@ -2,6 +2,7 @@ export interface CreateApiClientOptions {
2
2
  apiKey?: string;
3
3
  apiKeyHeader?: string;
4
4
  baseURL?: string;
5
+ headers?: Record<string, string>;
5
6
  }
6
7
  export interface PsHttpRequestConfig {
7
8
  headers?: Record<string, string>;
@@ -49,7 +49,7 @@ var HttpService = /** @class */ (function () {
49
49
  HttpService.createApiClient = function (options) {
50
50
  var _this = this;
51
51
  if (options === void 0) { options = {}; }
52
- var apiKey = options.apiKey, _a = options.apiKeyHeader, apiKeyHeader = _a === void 0 ? 'X-API-Key' : _a, baseURL = options.baseURL;
52
+ var apiKey = options.apiKey, _a = options.apiKeyHeader, apiKeyHeader = _a === void 0 ? 'X-API-Key' : _a, baseURL = options.baseURL, defaultHeaders = options.headers;
53
53
  var request = function (method, url, data, config) { return __awaiter(_this, void 0, void 0, function () {
54
54
  var fullUrl, sendsBinaryBody, headers, body, response, responseData, error;
55
55
  return __generator(this, function (_a) {
@@ -60,6 +60,8 @@ var HttpService = /** @class */ (function () {
60
60
  headers = sendsBinaryBody
61
61
  ? {}
62
62
  : { 'Content-Type': 'application/json' };
63
+ if (defaultHeaders)
64
+ Object.assign(headers, defaultHeaders);
63
65
  if (apiKey)
64
66
  headers[apiKeyHeader] = apiKey;
65
67
  if (config === null || config === void 0 ? void 0 : config.headers)
@@ -1 +1,2 @@
1
+ export * from './debounce-service';
1
2
  export * from './http-service';
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./debounce-service"), exports);
17
18
  __exportStar(require("./http-service"), exports);
@@ -0,0 +1,3 @@
1
+ export interface EncryptedValuePayload {
2
+ value: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-utilities",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",