@withwiz/toolkit 0.2.6 → 0.2.8

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.
@@ -1,19 +1,6 @@
1
1
  import {
2
- JWTClientManager,
3
- clearStoredTokens,
4
- clearTokens,
5
- createApiHeaders,
6
- createAuthHeader,
7
- decodeJWTPayload,
8
- extractUserFromToken,
9
- getStoredTokens,
10
- getTokenExpirationString,
11
- getTokenIssuedAtString,
12
- getTokenRemainingTime,
13
- isTokenExpired,
14
- isTokenExpiringSoon,
15
- storeTokens
16
- } from "../chunk-XRRPEBKB.js";
2
+ OAuthManager
3
+ } from "../chunk-V5K5FYU7.js";
17
4
  import {
18
5
  DEFAULT_PASSWORD_CONFIG,
19
6
  createPasswordHasher,
@@ -33,8 +20,21 @@ import {
33
20
  TokenGenerator
34
21
  } from "../chunk-GDWEDUHO.js";
35
22
  import {
36
- OAuthManager
37
- } from "../chunk-V5K5FYU7.js";
23
+ JWTClientManager,
24
+ clearStoredTokens,
25
+ clearTokens,
26
+ createApiHeaders,
27
+ createAuthHeader,
28
+ decodeJWTPayload,
29
+ extractUserFromToken,
30
+ getStoredTokens,
31
+ getTokenExpirationString,
32
+ getTokenIssuedAtString,
33
+ getTokenRemainingTime,
34
+ isTokenExpired,
35
+ isTokenExpiringSoon,
36
+ storeTokens
37
+ } from "../chunk-XRRPEBKB.js";
38
38
  import {
39
39
  OAuthProvider,
40
40
  PasswordStrength,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-AOZVTVJG.js";
4
4
  import {
5
5
  rateLimitMiddleware
6
- } from "./chunk-SNSLMP6S.js";
6
+ } from "./chunk-QMZ75GBU.js";
7
7
  import {
8
8
  responseLoggerMiddleware
9
9
  } from "./chunk-M5LIX3TD.js";
@@ -9,14 +9,29 @@ import {
9
9
  } from "./chunk-5A2L6TXD.js";
10
10
 
11
11
  // src/middleware/rate-limit.ts
12
- var _rateLimitAdapter = null;
13
- var _adapterWarningLogged = false;
12
+ var GLOBAL_KEY = "__withwiz_rateLimitAdapter__";
13
+ var GLOBAL_WARN_KEY = "__withwiz_rateLimitWarningLogged__";
14
+ function _getAdapter() {
15
+ var _a;
16
+ return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
17
+ }
18
+ function _setAdapter(adapter) {
19
+ globalThis[GLOBAL_KEY] = adapter;
20
+ }
21
+ function _isWarningLogged() {
22
+ var _a;
23
+ return (_a = globalThis[GLOBAL_WARN_KEY]) != null ? _a : false;
24
+ }
25
+ function _setWarningLogged(value) {
26
+ globalThis[GLOBAL_WARN_KEY] = value;
27
+ }
14
28
  function setRateLimitAdapter(adapter) {
15
- const isInitialSetup = _rateLimitAdapter === null;
16
- const previousTypes = _rateLimitAdapter ? Object.keys(_rateLimitAdapter.rateLimiters).join(", ") : "none";
29
+ const current = _getAdapter();
30
+ const isInitialSetup = current === null;
31
+ const previousTypes = current ? Object.keys(current.rateLimiters).join(", ") : "none";
17
32
  const newTypes = Object.keys(adapter.rateLimiters).join(", ");
18
- _rateLimitAdapter = adapter;
19
- _adapterWarningLogged = false;
33
+ _setAdapter(adapter);
34
+ _setWarningLogged(false);
20
35
  if (isInitialSetup) {
21
36
  logger.info(
22
37
  `[Rate Limit Middleware] \u2705 Initialized with types: [${newTypes}]`
@@ -28,13 +43,14 @@ function setRateLimitAdapter(adapter) {
28
43
  }
29
44
  }
30
45
  function getRateLimitAdapter() {
31
- if (!_rateLimitAdapter && !_adapterWarningLogged) {
46
+ const adapter = _getAdapter();
47
+ if (!adapter && !_isWarningLogged()) {
32
48
  logger.warn(
33
49
  "[Rate Limit Middleware] Adapter not configured. Rate limiting is DISABLED.\nTo enable: Call setRateLimitAdapter() in instrumentation.ts"
34
50
  );
35
- _adapterWarningLogged = true;
51
+ _setWarningLogged(true);
36
52
  }
37
- return _rateLimitAdapter;
53
+ return adapter;
38
54
  }
39
55
  function createRateLimitMiddleware(type) {
40
56
  return async (context, next) => {
@@ -1,18 +1,18 @@
1
- import {
2
- DataTableBody
3
- } from "./chunk-7IY3RQQL.js";
4
- import {
5
- DataTableBulkActions
6
- } from "./chunk-MAATEX2R.js";
7
1
  import {
8
2
  DataTableFilters
9
- } from "./chunk-LJEGM4OO.js";
3
+ } from "./chunk-X2UP5PNN.js";
10
4
  import {
11
5
  DataTablePagination
12
6
  } from "./chunk-IPXPCBDO.js";
13
7
  import {
14
8
  DataTableSearch
15
9
  } from "./chunk-TH45RVP7.js";
10
+ import {
11
+ DataTableBody
12
+ } from "./chunk-7IY3RQQL.js";
13
+ import {
14
+ DataTableBulkActions
15
+ } from "./chunk-MAATEX2R.js";
16
16
  import {
17
17
  DEFAULT_LABELS
18
18
  } from "./chunk-NY5QXT33.js";
@@ -28,8 +28,10 @@ import {
28
28
  } from "./chunk-ORMEWXMH.js";
29
29
 
30
30
  // src/components/ui/data-table/DataTable.tsx
31
- import { useState, useEffect, useMemo } from "react";
31
+ import { useState, useEffect, useMemo, useRef } from "react";
32
32
  import { jsx, jsxs } from "react/jsx-runtime";
33
+ var EMPTY_ARRAY = [];
34
+ var EMPTY_OBJECT = {};
33
35
  function DataTable({
34
36
  data,
35
37
  columns,
@@ -37,14 +39,14 @@ function DataTable({
37
39
  error = null,
38
40
  pagination,
39
41
  sort,
40
- bulkActions = [],
41
- filters = [],
42
- filterValues = {},
42
+ bulkActions = EMPTY_ARRAY,
43
+ filters = EMPTY_ARRAY,
44
+ filterValues = EMPTY_OBJECT,
43
45
  onFilterChange,
44
46
  onClearFilters,
45
47
  selectable = false,
46
48
  onSelectionChange,
47
- selectedIds = [],
49
+ selectedIds = EMPTY_ARRAY,
48
50
  getRowId,
49
51
  className,
50
52
  emptyMessage = "No data",
@@ -58,11 +60,24 @@ function DataTable({
58
60
  labels: customLabels,
59
61
  syncWithUrl = false
60
62
  }) {
61
- const labels = __spreadValues(__spreadValues({}, DEFAULT_LABELS), customLabels);
62
- const [localSelectedIds, setLocalSelectedIds] = useState(selectedIds);
63
+ const customLabelsRef = useRef(customLabels);
64
+ const labelsRef = useRef(__spreadValues(__spreadValues({}, DEFAULT_LABELS), customLabels));
65
+ if (customLabelsRef.current !== customLabels) {
66
+ customLabelsRef.current = customLabels;
67
+ labelsRef.current = __spreadValues(__spreadValues({}, DEFAULT_LABELS), customLabels);
68
+ }
69
+ const labels = labelsRef.current;
70
+ const [localSelectedIds, setLocalSelectedIds] = useState(
71
+ selectedIds
72
+ );
63
73
  const [bulkActionLoading, setBulkActionLoading] = useState(null);
74
+ const prevSelectedIdsRef = useRef(JSON.stringify(selectedIds));
64
75
  useEffect(() => {
65
- setLocalSelectedIds(selectedIds);
76
+ const serialized = JSON.stringify(selectedIds);
77
+ if (serialized !== prevSelectedIdsRef.current) {
78
+ prevSelectedIdsRef.current = serialized;
79
+ setLocalSelectedIds(selectedIds);
80
+ }
66
81
  }, [selectedIds]);
67
82
  const hasActiveFilters = useMemo(() => {
68
83
  if (searchValue && searchValue.trim()) return true;
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  DataTable
3
- } from "../../chunk-M2S3OMKX.js";
4
- import "../../chunk-7IY3RQQL.js";
5
- import "../../chunk-MAATEX2R.js";
6
- import "../../chunk-LJEGM4OO.js";
3
+ } from "../../chunk-RPWEGUUS.js";
4
+ import "../../chunk-X2UP5PNN.js";
7
5
  import "../../chunk-IPXPCBDO.js";
8
6
  import "../../chunk-TH45RVP7.js";
7
+ import "../../chunk-7IY3RQQL.js";
8
+ import "../../chunk-MAATEX2R.js";
9
9
  import "../../chunk-NY5QXT33.js";
10
+ import "../../chunk-34WAGUT5.js";
11
+ import "../../chunk-L25BNU3E.js";
12
+ import "../../chunk-RJUVBBZG.js";
10
13
  import "../../chunk-IJEZ7G7S.js";
11
14
  import "../../chunk-YJWLWUFK.js";
12
15
  import "../../chunk-WDUFQFDP.js";
13
- import "../../chunk-34WAGUT5.js";
14
16
  import "../../chunk-F6LCSFSU.js";
15
- import "../../chunk-L25BNU3E.js";
16
- import "../../chunk-RJUVBBZG.js";
17
17
  import "../../chunk-62FLBG6B.js";
18
18
  import "../../chunk-ORMEWXMH.js";
19
19
  export {
@@ -1,20 +1,20 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTable
4
- } from "../../../chunk-M2S3OMKX.js";
5
- import "../../../chunk-7IY3RQQL.js";
6
- import "../../../chunk-MAATEX2R.js";
7
- import "../../../chunk-LJEGM4OO.js";
4
+ } from "../../../chunk-RPWEGUUS.js";
5
+ import "../../../chunk-X2UP5PNN.js";
8
6
  import "../../../chunk-IPXPCBDO.js";
9
7
  import "../../../chunk-TH45RVP7.js";
8
+ import "../../../chunk-7IY3RQQL.js";
9
+ import "../../../chunk-MAATEX2R.js";
10
10
  import "../../../chunk-NY5QXT33.js";
11
+ import "../../../chunk-34WAGUT5.js";
12
+ import "../../../chunk-L25BNU3E.js";
13
+ import "../../../chunk-RJUVBBZG.js";
11
14
  import "../../../chunk-IJEZ7G7S.js";
12
15
  import "../../../chunk-YJWLWUFK.js";
13
16
  import "../../../chunk-WDUFQFDP.js";
14
- import "../../../chunk-34WAGUT5.js";
15
17
  import "../../../chunk-F6LCSFSU.js";
16
- import "../../../chunk-L25BNU3E.js";
17
- import "../../../chunk-RJUVBBZG.js";
18
18
  import "../../../chunk-62FLBG6B.js";
19
19
  import "../../../chunk-ORMEWXMH.js";
20
20
  export {
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTableFilters
4
- } from "../../../chunk-LJEGM4OO.js";
5
- import "../../../chunk-IJEZ7G7S.js";
6
- import "../../../chunk-WDUFQFDP.js";
4
+ } from "../../../chunk-X2UP5PNN.js";
7
5
  import "../../../chunk-L25BNU3E.js";
8
6
  import "../../../chunk-RJUVBBZG.js";
7
+ import "../../../chunk-IJEZ7G7S.js";
8
+ import "../../../chunk-WDUFQFDP.js";
9
9
  import "../../../chunk-62FLBG6B.js";
10
10
  import "../../../chunk-ORMEWXMH.js";
11
11
  export {
@@ -4,7 +4,7 @@ import {
4
4
  withCustomApi,
5
5
  withOptionalAuthApi,
6
6
  withPublicApi
7
- } from "../chunk-HWX3INO5.js";
7
+ } from "../chunk-3GEQQ4VL.js";
8
8
  import {
9
9
  MiddlewareChain
10
10
  } from "../chunk-AOZVTVJG.js";
@@ -12,7 +12,7 @@ import {
12
12
  createRateLimitMiddleware,
13
13
  rateLimitMiddleware,
14
14
  setRateLimitAdapter
15
- } from "../chunk-SNSLMP6S.js";
15
+ } from "../chunk-QMZ75GBU.js";
16
16
  import {
17
17
  responseLoggerMiddleware
18
18
  } from "../chunk-M5LIX3TD.js";
@@ -2,7 +2,7 @@ import {
2
2
  createRateLimitMiddleware,
3
3
  rateLimitMiddleware,
4
4
  setRateLimitAdapter
5
- } from "../chunk-SNSLMP6S.js";
5
+ } from "../chunk-QMZ75GBU.js";
6
6
  import "../chunk-KXXROUA5.js";
7
7
  import "../chunk-SNVGJPPX.js";
8
8
  import "../chunk-5A2L6TXD.js";
@@ -4,9 +4,9 @@ import {
4
4
  withCustomApi,
5
5
  withOptionalAuthApi,
6
6
  withPublicApi
7
- } from "../chunk-HWX3INO5.js";
7
+ } from "../chunk-3GEQQ4VL.js";
8
8
  import "../chunk-AOZVTVJG.js";
9
- import "../chunk-SNSLMP6S.js";
9
+ import "../chunk-QMZ75GBU.js";
10
10
  import "../chunk-M5LIX3TD.js";
11
11
  import "../chunk-NJXCFTOE.js";
12
12
  import "../chunk-74MSBKYW.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withwiz/toolkit",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Shared utility library for withwiz projects",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,3 +1,9 @@
1
+ import {
2
+ Button
3
+ } from "./chunk-L25BNU3E.js";
4
+ import {
5
+ Input
6
+ } from "./chunk-RJUVBBZG.js";
1
7
  import {
2
8
  Label
3
9
  } from "./chunk-IJEZ7G7S.js";
@@ -8,12 +14,6 @@ import {
8
14
  SelectTrigger,
9
15
  SelectValue
10
16
  } from "./chunk-WDUFQFDP.js";
11
- import {
12
- Button
13
- } from "./chunk-L25BNU3E.js";
14
- import {
15
- Input
16
- } from "./chunk-RJUVBBZG.js";
17
17
  import {
18
18
  cn
19
19
  } from "./chunk-62FLBG6B.js";