@okam/core-lib 1.17.3 → 2.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## 2.0.0 (Unreleased)
2
+
3
+ ### ⚠️ Breaking Changes
4
+
5
+ - **core-lib:** Removed `createCtx` and `createCtxNullable` exports. These React context utilities are now only available in `@okam/react-utils`. Update your imports:
6
+ ```typescript
7
+ // Before (no longer works)
8
+ import { createCtx, createCtxNullable } from '@okam/core-lib'
9
+
10
+ // After
11
+ import { createCtx, createCtxNullable } from '@okam/react-utils'
12
+ ```
13
+ - **core-lib:** Removed the `react-server` export condition since core-lib is now server-safe by default (no React dependencies)
14
+ - **core-lib:** Removed `@okam/react-utils` peer dependency - core-lib no longer has any React-related dependencies
15
+
16
+ ### 🚀 Features
17
+
18
+ - **core-lib:** Now fully server-safe by default - can be used in Node.js, Edge runtimes, and React Server Components without any special configuration
19
+
20
+ ---
21
+
22
+ ## 1.17.4 (2026-01-23)
23
+
24
+ This was a version bump only for core-lib to align it with other projects, there were no code changes.
25
+
1
26
  ## 1.17.2 (2026-01-21)
2
27
 
3
28
  ### 🩹 Fixes
package/README.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  This library was generated with [Nx](https://nx.dev).
4
4
 
5
+ ## Breaking Change: v2.0.0
6
+
7
+ ### React Context Utilities Removed
8
+
9
+ The React context utilities `createCtx` and `createCtxNullable` have been **removed** from `@okam/core-lib`. These utilities are now only available in `@okam/react-utils`.
10
+
11
+ **Migration:**
12
+
13
+ ```typescript
14
+ // Before (no longer works in v2.0.0)
15
+ import { createCtx, createCtxNullable } from '@okam/core-lib'
16
+
17
+ // After
18
+ import { createCtx, createCtxNullable } from '@okam/react-utils'
19
+ ```
20
+
21
+ ### Server-Safe by Default
22
+
23
+ `@okam/core-lib` is now fully server-safe and can be used in any environment without React dependencies. The `react-server` export condition has been removed since it is no longer needed - the default export is server-safe.
24
+
25
+ ## Available Exports
26
+
27
+ - `ArrayUtils` - Array manipulation utilities
28
+ - `Asserts` - Assertion helpers
29
+ - `normalizePath` - Path normalization utility
30
+ - `getNestedObjectValueOfKey` - Deep object property access
31
+ - `checkObjectProperty` - Object property checking
32
+ - `capitalizeFirstLetter` - String capitalization
33
+ - `UnPromisify` - Type utility for unwrapping Promise types
34
+ - `typeguards` - TypeScript type guards
35
+
5
36
  ## Running unit tests
6
37
 
7
38
  Run `nx test core-lib` to execute the unit tests via [Vitest](https://vitest.dev/).
package/index.d.ts CHANGED
@@ -1,8 +1,5 @@
1
1
  export { ArrayUtils } from './utils/array-utils';
2
2
  export { Asserts } from './utils/asserts';
3
- export { default as createCtx } from './utils/createContext';
4
- export { createCtxNullable } from './utils/createContext';
5
- export declare function sayHello(name: string): string;
6
3
  export { normalizePath } from './utils/normalize-path';
7
4
  export { default as getNestedObjectValueOfKey } from './utils/object-find-deep-nested';
8
5
  export { default as checkObjectProperty } from './utils/object-property';
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");function p(t,e){if([t,e].forEach((r,n)=>{if(!Number.isSafeInteger(r))throw new TypeError(`${n===0?"min":"max"} is not a valid integer`)}),e<t)throw new Error("Min cannot be greater than max");return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}class d{static getRandom(e){return e[p(0,e.length-1)]}static removeItem(e,r){const n=e.indexOf(r);return n>-1&&e.splice(n,1),e}}function b(t){if(typeof t!="string"||!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(t))return!1;try{return new Date(t).toISOString()===t}catch{return!1}}function c(t,e=!0){return typeof t=="string"&&(e?t.trim():t).length>0}function g(t){return typeof t=="object"&&t!==null&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function u(t){return typeof t=="number"&&Number.isSafeInteger(t)}function y(t){return typeof t=="number"&&!Number.isNaN(t)?!0:c(t)?!Number.isNaN(Number.parseInt(t,10)||Number.isNaN(Number.parseFloat(t))):!1}function h(t){const e=typeof t=="string"&&/^-?\d+$/.test(t)?Number.parseInt(t,10):t;return u(e)}function m(t){return u(t)&&t<600&&t>=100}class o{static isPresent(e,r){if(e==null)throw o.createException(r,"Value is null or undefined.")}static safeInteger(e,r){if(typeof e!="number"||!Number.isSafeInteger(e))throw o.createException(r,"Value is not a safe integer")}static nonEmptyString(e,r,n){if(!c(e,n??!0))throw o.createException(r)}static never(e,r){throw new Error(r??"Unexpected value")}static createException(e,r){throw typeof e=="function"?e():new Error(e??r??"Assertion did not pass.")}}function N(){const t=s.createContext(void 0);function e(){const r=s.use(t);if(r===void 0)throw new Error("useCtx must be inside a Provider");return r}return[e,t.Provider]}function P(){const t=s.createContext(void 0);function e(){const r=s.use(t);return r===void 0?{}:r}return[e,t.Provider]}function O(t){return t.split("/").reduceRight((n,i)=>n.length===0&&i===""?n:[i,...n],[]).join("/")}function x(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function l(t,e,r){const n=Object.keys(t);let i;i??=r;for(const a of n){const f=t[a];if(x(f)&&(i??=l(f,e,i)),a===e)return t[e]}return i}function w(t,e){const r=t[e];return r!=null&&typeof r=="object"&&Object.prototype.hasOwnProperty.call(t,e)?r:null}function I(t){return t.charAt(0).toUpperCase()+t.slice(1)}function j(t){return`I'm the @okam/shared-ui component telling ${t} !`}exports.ArrayUtils=d;exports.Asserts=o;exports.capitalizeFirstLetter=I;exports.checkObjectProperty=w;exports.createCtx=N;exports.createCtxNullable=P;exports.getNestedObjectValueOfKey=l;exports.isHttpStatusCode=m;exports.isIsoDateString=b;exports.isNonEmptyString=c;exports.isParsableNumeric=y;exports.isParsableSafeInteger=h;exports.isPlainObject=g;exports.isSafeInteger=u;exports.normalizePath=O;exports.sayHello=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(t,e){if([t,e].forEach((r,n)=>{if(!Number.isSafeInteger(r))throw new TypeError(`${n===0?"min":"max"} is not a valid integer`)}),e<t)throw new Error("Min cannot be greater than max");return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}class p{static getRandom(e){return e[l(0,e.length-1)]}static removeItem(e,r){const n=e.indexOf(r);return n>-1&&e.splice(n,1),e}}function b(t){if(typeof t!="string"||!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(t))return!1;try{return new Date(t).toISOString()===t}catch{return!1}}function s(t,e=!0){return typeof t=="string"&&(e?t.trim():t).length>0}function d(t){return typeof t=="object"&&t!==null&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function a(t){return typeof t=="number"&&Number.isSafeInteger(t)}function g(t){return typeof t=="number"&&!Number.isNaN(t)?!0:s(t)?!Number.isNaN(Number.parseInt(t,10)||Number.isNaN(Number.parseFloat(t))):!1}function y(t){const e=typeof t=="string"&&/^-?\d+$/.test(t)?Number.parseInt(t,10):t;return a(e)}function h(t){return a(t)&&t<600&&t>=100}class o{static isPresent(e,r){if(e==null)throw o.createException(r,"Value is null or undefined.")}static safeInteger(e,r){if(typeof e!="number"||!Number.isSafeInteger(e))throw o.createException(r,"Value is not a safe integer")}static nonEmptyString(e,r,n){if(!s(e,n??!0))throw o.createException(r)}static never(e,r){throw new Error(r??"Unexpected value")}static createException(e,r){throw typeof e=="function"?e():new Error(e??r??"Assertion did not pass.")}}function m(t){return t.split("/").reduceRight((n,i)=>n.length===0&&i===""?n:[i,...n],[]).join("/")}function N(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,e,r){const n=Object.keys(t);let i;i??=r;for(const u of n){const c=t[u];if(N(c)&&(i??=f(c,e,i)),u===e)return t[e]}return i}function O(t,e){const r=t[e];return r!=null&&typeof r=="object"&&Object.prototype.hasOwnProperty.call(t,e)?r:null}function P(t){return t.charAt(0).toUpperCase()+t.slice(1)}exports.ArrayUtils=p;exports.Asserts=o;exports.capitalizeFirstLetter=P;exports.checkObjectProperty=O;exports.getNestedObjectValueOfKey=f;exports.isHttpStatusCode=h;exports.isIsoDateString=b;exports.isNonEmptyString=s;exports.isParsableNumeric=g;exports.isParsableSafeInteger=y;exports.isPlainObject=d;exports.isSafeInteger=a;exports.normalizePath=m;
package/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { createContext as s, use as a } from "react";
2
- function p(t, e) {
1
+ function f(t, e) {
3
2
  if ([t, e].forEach((r, n) => {
4
3
  if (!Number.isSafeInteger(r))
5
4
  throw new TypeError(`${n === 0 ? "min" : "max"} is not a valid integer`);
@@ -7,16 +6,16 @@ function p(t, e) {
7
6
  throw new Error("Min cannot be greater than max");
8
7
  return t = Math.ceil(t), e = Math.floor(e), Math.floor(Math.random() * (e - t + 1)) + t;
9
8
  }
10
- class m {
9
+ class b {
11
10
  static getRandom(e) {
12
- return e[p(0, e.length - 1)];
11
+ return e[f(0, e.length - 1)];
13
12
  }
14
13
  static removeItem(e, r) {
15
14
  const n = e.indexOf(r);
16
15
  return n > -1 && e.splice(n, 1), e;
17
16
  }
18
17
  }
19
- function g(t) {
18
+ function d(t) {
20
19
  if (typeof t != "string" || !/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(t))
21
20
  return !1;
22
21
  try {
@@ -25,37 +24,37 @@ function g(t) {
25
24
  return !1;
26
25
  }
27
26
  }
28
- function f(t, e = !0) {
27
+ function c(t, e = !0) {
29
28
  return typeof t == "string" && (e ? t.trim() : t).length > 0;
30
29
  }
31
- function y(t) {
30
+ function h(t) {
32
31
  return typeof t == "object" && t !== null && t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype;
33
32
  }
34
- function l(t) {
33
+ function a(t) {
35
34
  return typeof t == "number" && Number.isSafeInteger(t);
36
35
  }
37
- function N(t) {
38
- return typeof t == "number" && !Number.isNaN(t) ? !0 : f(t) ? !Number.isNaN(Number.parseInt(t, 10) || Number.isNaN(Number.parseFloat(t))) : !1;
36
+ function g(t) {
37
+ return typeof t == "number" && !Number.isNaN(t) ? !0 : c(t) ? !Number.isNaN(Number.parseInt(t, 10) || Number.isNaN(Number.parseFloat(t))) : !1;
39
38
  }
40
- function w(t) {
39
+ function y(t) {
41
40
  const e = typeof t == "string" && /^-?\d+$/.test(t) ? Number.parseInt(t, 10) : t;
42
- return l(e);
41
+ return a(e);
43
42
  }
44
- function x(t) {
45
- return l(t) && t < 600 && t >= 100;
43
+ function m(t) {
44
+ return a(t) && t < 600 && t >= 100;
46
45
  }
47
- class i {
46
+ class o {
48
47
  static isPresent(e, r) {
49
48
  if (e == null)
50
- throw i.createException(r, "Value is null or undefined.");
49
+ throw o.createException(r, "Value is null or undefined.");
51
50
  }
52
51
  static safeInteger(e, r) {
53
52
  if (typeof e != "number" || !Number.isSafeInteger(e))
54
- throw i.createException(r, "Value is not a safe integer");
53
+ throw o.createException(r, "Value is not a safe integer");
55
54
  }
56
55
  static nonEmptyString(e, r, n) {
57
- if (!f(e, n ?? !0))
58
- throw i.createException(r);
56
+ if (!c(e, n ?? !0))
57
+ throw o.createException(r);
59
58
  }
60
59
  static never(e, r) {
61
60
  throw new Error(r ?? "Unexpected value");
@@ -64,66 +63,42 @@ class i {
64
63
  throw typeof e == "function" ? e() : new Error(e ?? r ?? "Assertion did not pass.");
65
64
  }
66
65
  }
67
- function I() {
68
- const t = s(void 0);
69
- function e() {
70
- const r = a(t);
71
- if (r === void 0)
72
- throw new Error("useCtx must be inside a Provider");
73
- return r;
74
- }
75
- return [e, t.Provider];
76
- }
77
- function O() {
78
- const t = s(void 0);
79
- function e() {
80
- const r = a(t);
81
- return r === void 0 ? {} : r;
82
- }
83
- return [e, t.Provider];
84
- }
85
- function P(t) {
86
- return t.split("/").reduceRight((n, o) => n.length === 0 && o === "" ? n : [o, ...n], []).join("/");
66
+ function N(t) {
67
+ return t.split("/").reduceRight((n, i) => n.length === 0 && i === "" ? n : [i, ...n], []).join("/");
87
68
  }
88
- function d(t) {
69
+ function l(t) {
89
70
  return typeof t == "object" && t !== null && !Array.isArray(t);
90
71
  }
91
- function b(t, e, r) {
72
+ function p(t, e, r) {
92
73
  const n = Object.keys(t);
93
- let o;
94
- o ??= r;
74
+ let i;
75
+ i ??= r;
95
76
  for (const u of n) {
96
- const c = t[u];
97
- if (d(c) && (o ??= b(c, e, o)), u === e)
77
+ const s = t[u];
78
+ if (l(s) && (i ??= p(s, e, i)), u === e)
98
79
  return t[e];
99
80
  }
100
- return o;
81
+ return i;
101
82
  }
102
- function j(t, e) {
83
+ function w(t, e) {
103
84
  const r = t[e];
104
85
  return r != null && typeof r == "object" && Object.prototype.hasOwnProperty.call(t, e) ? r : null;
105
86
  }
106
- function E(t) {
87
+ function O(t) {
107
88
  return t.charAt(0).toUpperCase() + t.slice(1);
108
89
  }
109
- function C(t) {
110
- return `I'm the @okam/shared-ui component telling ${t} !`;
111
- }
112
90
  export {
113
- m as ArrayUtils,
114
- i as Asserts,
115
- E as capitalizeFirstLetter,
116
- j as checkObjectProperty,
117
- I as createCtx,
118
- O as createCtxNullable,
119
- b as getNestedObjectValueOfKey,
120
- x as isHttpStatusCode,
121
- g as isIsoDateString,
122
- f as isNonEmptyString,
123
- N as isParsableNumeric,
124
- w as isParsableSafeInteger,
125
- y as isPlainObject,
126
- l as isSafeInteger,
127
- P as normalizePath,
128
- C as sayHello
91
+ b as ArrayUtils,
92
+ o as Asserts,
93
+ O as capitalizeFirstLetter,
94
+ w as checkObjectProperty,
95
+ p as getNestedObjectValueOfKey,
96
+ m as isHttpStatusCode,
97
+ d as isIsoDateString,
98
+ c as isNonEmptyString,
99
+ g as isParsableNumeric,
100
+ y as isParsableSafeInteger,
101
+ h as isPlainObject,
102
+ a as isSafeInteger,
103
+ N as normalizePath
129
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/core-lib",
3
- "version": "1.17.3",
3
+ "version": "2.0.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "url": "https://github.com/OKAMca/stack.git"
@@ -29,14 +29,7 @@
29
29
  "nxrelease": {
30
30
  "repositoryUrl": "https://github.com/OKAMca/stack.git"
31
31
  },
32
- "peerDependencies": {
33
- "react": "^18.0.0 || ^19.0.0"
34
- },
35
32
  "dependencies": {
36
- "@tsed/exceptions": "^8.3.1",
37
- "dequal": "^2.0.3"
38
- },
39
- "devDependencies": {
40
- "react": "^19.0.0"
33
+ "@tsed/exceptions": "^8.3.1"
41
34
  }
42
- }
35
+ }
package/hooks/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { useDeepCompareMemoize } from './use-deep-compare-memoize';
2
- export { usePromise } from './use-promise';
@@ -1,3 +0,0 @@
1
- type SupportedValue = Record<string, unknown> | string | boolean | number | null;
2
- export declare function useDeepCompareMemoize(value: SupportedValue): SupportedValue;
3
- export {};
@@ -1,13 +0,0 @@
1
- export type AsyncFnParams<TParams> = TParams;
2
- export type AsyncFnWithParams<TResult, TParams extends Record<string, unknown>> = (_variables: TParams) => Promise<TResult>;
3
- export type AsyncFnWithoutParams<TResult> = () => Promise<TResult>;
4
- export type AsyncFn<TResult, TParams extends Record<string, unknown> = Partial<Record<string, unknown>>> = AsyncFnWithParams<TResult, TParams> | AsyncFnWithoutParams<TResult>;
5
- export interface UsePromiseOptions<TResult> {
6
- initialData?: TResult;
7
- }
8
- export declare function usePromise<TResult, TVariables extends Record<string, unknown> = Partial<Record<string, unknown>>>(promise: AsyncFn<TResult, TVariables>, params: AsyncFnParams<TVariables>, options?: UsePromiseOptions<TResult>): {
9
- error: Error | null;
10
- isLoading: boolean;
11
- data: TResult | null;
12
- reload: () => void;
13
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * A helper to create a Context and Provider with no upfront default value, and
3
- * without having to check for undefined all the time.
4
- */
5
- declare function createCtx<A extends object | null>(): readonly [() => A, import('react').Provider<A | undefined>];
6
- export declare function createCtxNullable<A extends object | null>(): readonly [() => A, import('react').Provider<A | undefined>];
7
- export default createCtx;