@okam/core-lib 1.15.1 → 1.17.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 ADDED
@@ -0,0 +1,255 @@
1
+ ## 1.17.0 (2025-07-24)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **directus-next:** /api/redirect route handler to fetch + cache directus redirects ([c21b953](https://github.com/OKAMca/stack/commit/c21b953))
6
+
7
+ ### 🩹 Fixes
8
+
9
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
10
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
11
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
12
+
13
+ ### ❤️ Thank You
14
+
15
+ - Marie-Maxime Tanguay
16
+ - Pierre-Olivier Clerson @poclerson
17
+
18
+ ## 1.15.0 (2024-10-04)
19
+
20
+
21
+ ### 🚀 Features
22
+
23
+ - updates & cleanup packages and dependancies ([#210](https://github.com/OKAMca/stack/pull/210))
24
+
25
+
26
+ ### ❤️ Thank You
27
+
28
+ - Marie-Maxime Tanguay @marie-maxime
29
+
30
+ ## 1.14.0 (2024-07-25)
31
+
32
+
33
+ ### 🚀 Features
34
+
35
+ - generator for block & component ([#161](https://github.com/OKAMca/stack/pull/161))
36
+
37
+
38
+ ### ❤️ Thank You
39
+
40
+ - Jérôme Trottier
41
+ - Marie-Maxime Tanguay @marie-maxime
42
+ - Pierre-Olivier Clerson @poclerson
43
+
44
+ ## 1.13.4 (2024-07-16)
45
+
46
+
47
+ ### 🩹 Fixes
48
+
49
+ - **publish:** add building packages step to workflow ([c9ce442](https://github.com/OKAMca/stack/commit/c9ce442))
50
+
51
+
52
+ ### ❤️ Thank You
53
+
54
+ - Jérôme Trottier
55
+ - Pierre-Olivier Clerson @poclerson
56
+ - yanmorinokamca @yanmorinokamca
57
+
58
+ ## [1.13.3](https://github.com/OKAMca/stack/compare/core-lib-v1.13.2...core-lib-v1.13.3) (2024-06-25)
59
+
60
+
61
+ ### Bug Fixes
62
+
63
+ * **block-directus:** add server only to get block props ([330e76f](https://github.com/OKAMca/stack/commit/330e76f7fee53634bfb991e813060f0e8f1a0cb6))
64
+
65
+ ## [1.13.2](https://github.com/OKAMca/stack/compare/core-lib-v1.13.1...core-lib-v1.13.2) (2024-06-14)
66
+
67
+
68
+ ### Bug Fixes
69
+
70
+ * aria labelled by ([6380791](https://github.com/OKAMca/stack/commit/63807918a253462211c35f1119acff64c093027d))
71
+
72
+ ## [1.13.1](https://github.com/OKAMca/stack/compare/core-lib-v1.13.0...core-lib-v1.13.1) (2024-06-11)
73
+
74
+
75
+ ### Bug Fixes
76
+
77
+ * publishing for new libs ([#126](https://github.com/OKAMca/stack/issues/126)) ([8750ea6](https://github.com/OKAMca/stack/commit/8750ea643fa22ca06979c8d4030fa2a2d865b86f))
78
+
79
+ # [1.13.0](https://github.com/OKAMca/stack/compare/core-lib-v1.12.0...core-lib-v1.13.0) (2024-06-11)
80
+
81
+
82
+ ### Features
83
+
84
+ * STACK-72-Lib-Create-directus-block ([#115](https://github.com/OKAMca/stack/issues/115)) ([c07db82](https://github.com/OKAMca/stack/commit/c07db82d3b2a483e737e8d0dd07074cfa0b82152))
85
+
86
+ # [1.12.0](https://github.com/OKAMca/stack/compare/core-lib-v1.11.2...core-lib-v1.12.0) (2024-05-30)
87
+
88
+
89
+ ### Features
90
+
91
+ * alerts component ([35ee942](https://github.com/OKAMca/stack/commit/35ee942432edc38d9dd7be9c81992bbe314fba61))
92
+
93
+ ## [1.11.2](https://github.com/OKAMca/stack/compare/core-lib-v1.11.1...core-lib-v1.11.2) (2024-05-29)
94
+
95
+
96
+ ### Bug Fixes
97
+
98
+ * select do not work on in nextjs app ([5b04406](https://github.com/OKAMca/stack/commit/5b044064c4f0818255e0b65b8959b2a58f74176f))
99
+
100
+ ## [1.11.1](https://github.com/OKAMca/stack/compare/core-lib-v1.11.0...core-lib-v1.11.1) (2024-04-04)
101
+
102
+
103
+ ### Bug Fixes
104
+
105
+ * **packages:** merge with main ([5611d64](https://github.com/OKAMca/stack/commit/5611d64950b4b262b95041a36658a84a5b0fdcd0))
106
+
107
+ # [1.11.0](https://github.com/OKAMca/stack/compare/core-lib-v1.10.2...core-lib-v1.11.0) (2024-04-02)
108
+
109
+
110
+ ### Features
111
+
112
+ * component accordion closed items should not be focusable via keyboard ([c027cda](https://github.com/OKAMca/stack/commit/c027cda3f39faeb269026e45d56a4f4c35c7498d))
113
+
114
+ ## [1.10.2](https://github.com/OKAMca/stack/compare/core-lib-v1.10.1...core-lib-v1.10.2) (2024-04-01)
115
+
116
+
117
+ ### Bug Fixes
118
+
119
+ * checkbox group should pass the state to its provider ([#104](https://github.com/OKAMca/stack/issues/104)) ([c4f09bf](https://github.com/OKAMca/stack/commit/c4f09bfd1d084e9148b7a602e672ff8b346e52d6))
120
+
121
+ ## [1.10.1](https://github.com/OKAMca/stack/compare/core-lib-v1.10.0...core-lib-v1.10.1) (2024-03-25)
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * stack UI should export checkbox group ([c331644](https://github.com/OKAMca/stack/commit/c331644a3565f32ecd6327786224eadcd4731ee9))
127
+
128
+ # [1.10.0](https://github.com/OKAMca/stack/compare/core-lib-v1.9.1...core-lib-v1.10.0) (2024-03-05)
129
+
130
+
131
+ ### Features
132
+
133
+ * add storybook a11y addon ([4287a66](https://github.com/OKAMca/stack/commit/4287a6614543527dae3b5ee2c87f7db8bcd8a725))
134
+
135
+ ## [1.9.1](https://github.com/OKAMca/stack/compare/core-lib-v1.9.0...core-lib-v1.9.1) (2024-03-05)
136
+
137
+
138
+ ### Bug Fixes
139
+
140
+ * pass state to provider ([fe67cf9](https://github.com/OKAMca/stack/commit/fe67cf93a4495571abdadfb427d5a36475b13700))
141
+
142
+ # [1.9.0](https://github.com/OKAMca/stack/compare/core-lib-v1.8.1...core-lib-v1.9.0) (2024-02-09)
143
+
144
+
145
+ ### Features
146
+
147
+ * add gql query ([#73](https://github.com/OKAMca/stack/issues/73)) ([27faaaa](https://github.com/OKAMca/stack/commit/27faaaa3b810412235a09d412acf7aa8a4b3221f))
148
+
149
+ ## [1.8.1](https://github.com/OKAMca/stack/compare/core-lib-v1.8.0...core-lib-v1.8.1) (2023-12-22)
150
+
151
+
152
+ ### Bug Fixes
153
+
154
+ * publish command path ([4f17a81](https://github.com/OKAMca/stack/commit/4f17a81b99181e55e40050896ce92584cf2a7366))
155
+
156
+ # [1.8.0](https://github.com/OKAMca/stack/compare/core-lib-v1.7.1...core-lib-v1.8.0) (2023-12-22)
157
+
158
+
159
+ ### Features
160
+
161
+ * add new libs ([#71](https://github.com/OKAMca/stack/issues/71)) ([f75cf73](https://github.com/OKAMca/stack/commit/f75cf73414e97cdb3210b1371111029403a80c1a))
162
+
163
+ ## [1.7.1](https://github.com/OKAMca/stack/compare/core-lib-v1.7.0...core-lib-v1.7.1) (2023-12-21)
164
+
165
+ ### Bug Fixes
166
+
167
+ - lint issue ([#70](https://github.com/OKAMca/stack/issues/70)) ([abd6026](https://github.com/OKAMca/stack/commit/abd6026f94bd78aee6131148195af16a9f9b0bb0))
168
+
169
+ # [1.7.0](https://github.com/OKAMca/stack/compare/core-lib-v1.6.0...core-lib-v1.7.0) (2023-12-14)
170
+
171
+ ### Bug Fixes
172
+
173
+ - conflicts ([3b8c3b0](https://github.com/OKAMca/stack/commit/3b8c3b09b3d12c55c1ee2a580503b7ffbf4f9b7f))
174
+
175
+ ### Features
176
+
177
+ - cleanup ([b8597b3](https://github.com/OKAMca/stack/commit/b8597b32bfb1cfb4765d0e9e8a730adb8fa942d2))
178
+ - multi level menu ([3fc9381](https://github.com/OKAMca/stack/commit/3fc9381ac206c1c329e888fe2dd94bf063dcd71b))
179
+
180
+ # [1.6.0](https://github.com/OKAMca/stack/compare/core-lib-v1.5.0...core-lib-v1.6.0) (2023-11-27)
181
+
182
+ ### Features
183
+
184
+ - image with thumbhash ([bbc7f90](https://github.com/OKAMca/stack/commit/bbc7f903f0a8b36f7776d7a595e613e0645a57c5))
185
+
186
+ # [1.5.0](https://github.com/OKAMca/stack/compare/core-lib-v1.4.1...core-lib-v1.5.0) (2023-11-06)
187
+
188
+ ### Features
189
+
190
+ - Carousel Component ([#11](https://github.com/OKAMca/stack/issues/11)) ([cef5b80](https://github.com/OKAMca/stack/commit/cef5b805632683004513cf3950b2c88e01d2c3a7))
191
+
192
+ ## [1.4.1](https://github.com/OKAMca/stack/compare/core-lib-v1.4.0...core-lib-v1.4.1) (2023-09-27)
193
+
194
+ ### Bug Fixes
195
+
196
+ - add missing social media icons ([b45ecf0](https://github.com/OKAMca/stack/commit/b45ecf0618fbdbde7a7c2379121e6777ba8a07ec))
197
+
198
+ # [1.4.0](https://github.com/OKAMca/stack/compare/core-lib-v1.3.0...core-lib-v1.4.0) (2023-09-26)
199
+
200
+ ### Features
201
+
202
+ - focus on clickable elements ([d0c651a](https://github.com/OKAMca/stack/commit/d0c651a55ee65c97a87b266a218a19263d364781))
203
+
204
+ # [1.3.0](https://github.com/OKAMca/stack/compare/core-lib-v1.2.0...core-lib-v1.3.0) (2023-09-05)
205
+
206
+ ### Features
207
+
208
+ - upgraded react-aria + react-aria/i18n ([8519af3](https://github.com/OKAMca/stack/commit/8519af3242223daeeab3d028a5ce79455b6c4bf5))
209
+
210
+ # [1.2.0](https://github.com/OKAMca/stack/compare/core-lib-v1.1.3...core-lib-v1.2.0) (2023-08-24)
211
+
212
+ ### Features
213
+
214
+ - change compiler to rollup with swc ([3be08f4](https://github.com/OKAMca/stack/commit/3be08f4c323b1e8333ac670ca7b8ece3035ff18e))
215
+
216
+ ## [1.1.3](https://github.com/OKAMca/stack/compare/core-lib-v1.1.2...core-lib-v1.1.3) (2023-08-23)
217
+
218
+ ### Bug Fixes
219
+
220
+ - console errors ([#28](https://github.com/OKAMca/stack/issues/28)) ([21208e2](https://github.com/OKAMca/stack/commit/21208e262bd8528c128f0220e17de9caddf0bd81))
221
+
222
+ ## [1.1.2](https://github.com/OKAMca/stack/compare/core-lib-v1.1.1...core-lib-v1.1.2) (2023-08-18)
223
+
224
+ ### Bug Fixes
225
+
226
+ - upgraded react-stately, react-types/shared ([61b109e](https://github.com/OKAMca/stack/commit/61b109e51cc5c841a920dd7e5ea34c94f4b02741))
227
+
228
+ ## [1.1.1](https://github.com/OKAMca/stack/compare/core-lib-v1.1.0...core-lib-v1.1.1) (2023-08-17)
229
+
230
+ ### Bug Fixes
231
+
232
+ - app router use-client components ([#26](https://github.com/OKAMca/stack/issues/26)) ([ebcd662](https://github.com/OKAMca/stack/commit/ebcd662ce7cd358e9beb23849925c124167670eb))
233
+
234
+ # [1.1.0](https://github.com/OKAMca/stack/compare/core-lib-v1.0.1...core-lib-v1.1.0) (2023-07-19)
235
+
236
+ ### Features
237
+
238
+ - add Box component ([#10](https://github.com/OKAMca/stack/issues/10)) ([933a153](https://github.com/OKAMca/stack/commit/933a1531fd8badb6bcfa8f42b77e9ed4ee1b62d3))
239
+
240
+ ## [1.0.1](https://github.com/OKAMca/stack/compare/core-lib-v1.0.0...core-lib-v1.0.1) (2023-07-07)
241
+
242
+ ### Bug Fixes
243
+
244
+ - changed building in publish instead of releas ([eee8f51](https://github.com/OKAMca/stack/commit/eee8f512987c444143bdfd73fe833840681d1c43))
245
+
246
+ # 1.0.0 (2023-07-06)
247
+
248
+ ### Bug Fixes
249
+
250
+ - lint setup ([7208af0](https://github.com/OKAMca/stack/commit/7208af0e8bb55ba72935ed215efd19db37994a79))
251
+ - linter ([d89dda6](https://github.com/OKAMca/stack/commit/d89dda6294b36b0effd253317ac2733c0143dac6))
252
+
253
+ ### Features
254
+
255
+ - init pacakges ([bb8d1f1](https://github.com/OKAMca/stack/commit/bb8d1f1ff042fda17e2f81f0770be6654e70897f))
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # core-lib
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running unit tests
6
+
7
+ Run `nx test core-lib` to execute the unit tests via [Vitest](https://vitest.dev/).
@@ -0,0 +1,3 @@
1
+ export { JsonApiResponseFactory } from './json-api-response.factory';
2
+ export type { JsonApiResponse, JsonApiErrorResponse, JsonApiSuccessResponse, JsonApiResponseMeta, JsonApiError, } from './json-api-response.types';
3
+ export { isJsonApiErrorResponse, isJsonApiResponse, isJsonApiSuccessResponse } from './json-api.typeguard';
@@ -0,0 +1,6 @@
1
+ import type { Exception } from '@tsed/exceptions';
2
+ import type { JsonApiError } from './json-api-response.types';
3
+ export declare class JsonApiErrorFactory {
4
+ static fromCatchVariable: (error: unknown, defaultHttpStatus?: number) => JsonApiError;
5
+ static fromTsedException: (exception: Exception | Error | string, defaultHttpStatus?: number) => JsonApiError;
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { JsonApiError, JsonApiErrorResponse, JsonApiSuccessResponse } from './json-api-response.types';
2
+ export declare class JsonApiResponseFactory {
3
+ static fromError: (errors: string | JsonApiError | JsonApiError[], httpStatus?: number) => JsonApiErrorResponse;
4
+ static fromSuccess: <T>(data: T, metadata?: JsonApiSuccessResponse<T>["meta"]) => JsonApiSuccessResponse<T>;
5
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @link https://jsonapi.org/format/#errors
3
+ */
4
+ export type JsonApiError = {
5
+ /** a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization. */
6
+ title: string;
7
+ /** a unique identifier for this particular occurrence of the problem. */
8
+ id?: string | number;
9
+ /** the HTTP status code applicable to this problem, expressed as a string value. */
10
+ status?: number;
11
+ /** an application-specific error code, expressed as a string value. */
12
+ code?: string;
13
+ /** a human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be localized. */
14
+ detail?: string;
15
+ /** a string indicating which URI query parameter caused the error. */
16
+ parameter?: string;
17
+ /** a meta object containing non-standard meta-information about the error. */
18
+ meta?: Record<string, unknown>;
19
+ };
20
+ export type JsonApiErrorResponse = {
21
+ success: false;
22
+ errors: JsonApiError[];
23
+ };
24
+ export type JsonApiResponseMeta = {
25
+ meta?: {
26
+ cacheHit?: boolean;
27
+ } & Record<string, string | number | boolean | Record<string, unknown>>;
28
+ };
29
+ export type JsonApiSuccessResponse<T> = {
30
+ success: true;
31
+ data: T;
32
+ } & JsonApiResponseMeta;
33
+ export type JsonApiResponse<T> = JsonApiErrorResponse | JsonApiSuccessResponse<T>;
@@ -0,0 +1,4 @@
1
+ import type { JsonApiErrorResponse, JsonApiResponse, JsonApiSuccessResponse } from './json-api-response.types';
2
+ export declare const isJsonApiResponse: <T = unknown>(val: unknown) => val is JsonApiResponse<T>;
3
+ export declare const isJsonApiSuccessResponse: <T = unknown>(val: unknown) => val is JsonApiSuccessResponse<T>;
4
+ export declare const isJsonApiErrorResponse: (val: unknown) => val is JsonApiErrorResponse;
@@ -0,0 +1,2 @@
1
+ export { usePromise } from './use-promise';
2
+ export { useDeepCompareMemoize } from './use-deep-compare-memoize';
@@ -0,0 +1,3 @@
1
+ type SupportedValue = Record<string, unknown> | string | boolean | number | null;
2
+ export declare function useDeepCompareMemoize(value: SupportedValue): SupportedValue;
3
+ export {};
@@ -0,0 +1,13 @@
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
+ };
package/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export { createCtxNullable } from './utils/createContext';
8
8
  export { default as getNestedObjectValueOfKey } from './utils/object-find-deep-nested';
9
9
  export { default as checkObjectProperty } from './utils/object-property';
10
10
  export { capitalizeFirstLetter } from './utils/string-transform';
11
+ export { normalizePath } from './utils/normalize-path';
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),p=e=>{if(typeof e!="string"||!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(e))return!1;try{return new Date(e).toISOString()===e}catch{return!1}},c=(e,t=!0)=>typeof e=="string"&&(t?e.trim():e).length>0,b=e=>typeof e=="object"&&e!==null&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype,a=e=>typeof e=="number"&&Number.isSafeInteger(e),d=e=>typeof e=="number"&&!Number.isNaN(e)?!0:c(e)?!Number.isNaN(Number.parseInt(e,10)||Number.isNaN(Number.parseFloat(e))):!1,g=e=>{const t=typeof e=="string"&&/^-?\d+$/.test(e)?Number.parseInt(e,10):e;return a(t)},y=e=>a(e)&&e<600&&e>=100;class o{static isPresent(t,r){if(t==null)throw o.createException(r,"Value is null or undefined.")}static safeInteger(t,r){if(typeof t!="number"||!Number.isSafeInteger(t))throw o.createException(r,"Value is not a safe integer")}static nonEmptyString(t,r,n){if(!c(t,n??!0))throw o.createException(r)}static never(t,r){throw new Error(r??"Unexpected value")}static createException(t,r){throw typeof t=="string"||t===void 0?new Error(t??r??"Assertion did not pass."):t()}}function h(e,t){if([e,t].forEach((r,n)=>{if(!Number.isSafeInteger(r))throw new Error(`${n===0?"min":"max"} is not a valid integer`)}),t<e)throw new Error("Min cannot be greater than max");return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}class N{static getRandom(t){return t[h(0,t.length-1)]}static removeItem(t,r){const n=t.indexOf(r);return n>-1&&t.splice(n,1),t}}function m(){const e=s.createContext(void 0);function t(){const r=s.useContext(e);if(r===void 0)throw new Error("useCtx must be inside a Provider");return r}return[t,e.Provider]}function x(){const e=s.createContext(void 0);function t(){const r=s.useContext(e);return r===void 0?{}:r}return[t,e.Provider]}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function f(e,t,r){const n=Object.keys(e);let i;i||(i=r);for(const u of n){const l=e[u];if(O(l)&&(i||(i=f(l,t,i))),u===t)return e[t]}return i}const w=(e,t)=>{const r=e[t];return r!=null&&typeof r=="object"&&Object.prototype.hasOwnProperty.call(e,t)?r:null};function I(e){return e.charAt(0).toUpperCase()+e.slice(1)}const P=e=>`I'm the @okam/shared-ui component telling ${e} !`;exports.ArrayUtils=N;exports.Asserts=o;exports.capitalizeFirstLetter=I;exports.checkObjectProperty=w;exports.createCtx=m;exports.createCtxNullable=x;exports.getNestedObjectValueOfKey=f;exports.isHttpStatusCode=y;exports.isIsoDateString=p;exports.isNonEmptyString=c;exports.isParsableNumeric=d;exports.isParsableSafeInteger=g;exports.isPlainObject=b;exports.isSafeInteger=a;exports.sayHello=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),d=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}},c=(t,e=!0)=>typeof t=="string"&&(e?t.trim():t).length>0,p=t=>typeof t=="object"&&t!==null&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype,a=t=>typeof t=="number"&&Number.isSafeInteger(t),b=t=>typeof t=="number"&&!Number.isNaN(t)?!0:c(t)?!Number.isNaN(Number.parseInt(t,10)||Number.isNaN(Number.parseFloat(t))):!1,g=t=>{const e=typeof t=="string"&&/^-?\d+$/.test(t)?Number.parseInt(t,10):t;return a(e)},h=t=>a(t)&&t<600&&t>=100;class i{static isPresent(e,r){if(e==null)throw i.createException(r,"Value is null or undefined.")}static safeInteger(e,r){if(typeof e!="number"||!Number.isSafeInteger(e))throw i.createException(r,"Value is not a safe integer")}static nonEmptyString(e,r,n){if(!c(e,n??!0))throw i.createException(r)}static never(e,r){throw new Error(r??"Unexpected value")}static createException(e,r){throw typeof e=="string"||e===void 0?new Error(e??r??"Assertion did not pass."):e()}}function y(t,e){if([t,e].forEach((r,n)=>{if(!Number.isSafeInteger(r))throw new Error(`${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 m{static getRandom(e){return e[y(0,e.length-1)]}static removeItem(e,r){const n=e.indexOf(r);return n>-1&&e.splice(n,1),e}}function N(){const t=s.createContext(void 0);function e(){const r=s.useContext(t);if(r===void 0)throw new Error("useCtx must be inside a Provider");return r}return[e,t.Provider]}function x(){const t=s.createContext(void 0);function e(){const r=s.useContext(t);return r===void 0?{}:r}return[e,t.Provider]}function P(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,e,r){const n=Object.keys(t);let o;o||(o=r);for(const u of n){const l=t[u];if(P(l)&&(o||(o=f(l,e,o))),u===e)return t[e]}return o}const O=(t,e)=>{const r=t[e];return r!=null&&typeof r=="object"&&Object.prototype.hasOwnProperty.call(t,e)?r:null};function w(t){return t.charAt(0).toUpperCase()+t.slice(1)}function I(t){return t.split("/").reduceRight((n,o)=>n.length===0&&o===""?n:[o,...n],[]).join("/")}const j=t=>`I'm the @okam/shared-ui component telling ${t} !`;exports.ArrayUtils=m;exports.Asserts=i;exports.capitalizeFirstLetter=w;exports.checkObjectProperty=O;exports.createCtx=N;exports.createCtxNullable=x;exports.getNestedObjectValueOfKey=f;exports.isHttpStatusCode=h;exports.isIsoDateString=d;exports.isNonEmptyString=c;exports.isParsableNumeric=b;exports.isParsableSafeInteger=g;exports.isPlainObject=p;exports.isSafeInteger=a;exports.normalizePath=I;exports.sayHello=j;
package/index.mjs CHANGED
@@ -7,10 +7,10 @@ const h = (t) => {
7
7
  } catch {
8
8
  return !1;
9
9
  }
10
- }, a = (t, e = !0) => typeof t == "string" && (e ? t.trim() : t).length > 0, g = (t) => typeof t == "object" && t !== null && t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype, f = (t) => typeof t == "number" && Number.isSafeInteger(t), y = (t) => typeof t == "number" && !Number.isNaN(t) ? !0 : a(t) ? !Number.isNaN(Number.parseInt(t, 10) || Number.isNaN(Number.parseFloat(t))) : !1, N = (t) => {
10
+ }, a = (t, e = !0) => typeof t == "string" && (e ? t.trim() : t).length > 0, g = (t) => typeof t == "object" && t !== null && t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype, f = (t) => typeof t == "number" && Number.isSafeInteger(t), m = (t) => typeof t == "number" && !Number.isNaN(t) ? !0 : a(t) ? !Number.isNaN(Number.parseInt(t, 10) || Number.isNaN(Number.parseFloat(t))) : !1, y = (t) => {
11
11
  const e = typeof t == "string" && /^-?\d+$/.test(t) ? Number.parseInt(t, 10) : t;
12
12
  return f(e);
13
- }, m = (t) => f(t) && t < 600 && t >= 100;
13
+ }, N = (t) => f(t) && t < 600 && t >= 100;
14
14
  class i {
15
15
  static isPresent(e, r) {
16
16
  if (e == null)
@@ -80,28 +80,32 @@ function d(t, e, r) {
80
80
  }
81
81
  return o;
82
82
  }
83
- const O = (t, e) => {
83
+ const P = (t, e) => {
84
84
  const r = t[e];
85
85
  return r != null && typeof r == "object" && Object.prototype.hasOwnProperty.call(t, e) ? r : null;
86
86
  };
87
- function C(t) {
87
+ function O(t) {
88
88
  return t.charAt(0).toUpperCase() + t.slice(1);
89
89
  }
90
- const j = (t) => `I'm the @okam/shared-ui component telling ${t} !`;
90
+ function j(t) {
91
+ return t.split("/").reduceRight((n, o) => n.length === 0 && o === "" ? n : [o, ...n], []).join("/");
92
+ }
93
+ const C = (t) => `I'm the @okam/shared-ui component telling ${t} !`;
91
94
  export {
92
95
  x as ArrayUtils,
93
96
  i as Asserts,
94
- C as capitalizeFirstLetter,
95
- O as checkObjectProperty,
97
+ O as capitalizeFirstLetter,
98
+ P as checkObjectProperty,
96
99
  w as createCtx,
97
100
  I as createCtxNullable,
98
101
  d as getNestedObjectValueOfKey,
99
- m as isHttpStatusCode,
102
+ N as isHttpStatusCode,
100
103
  h as isIsoDateString,
101
104
  a as isNonEmptyString,
102
- y as isParsableNumeric,
103
- N as isParsableSafeInteger,
105
+ m as isParsableNumeric,
106
+ y as isParsableSafeInteger,
104
107
  g as isPlainObject,
105
108
  f as isSafeInteger,
106
- j as sayHello
109
+ j as normalizePath,
110
+ C as sayHello
107
111
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/core-lib",
3
- "version": "1.15.1",
3
+ "version": "1.17.0",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "license": "MIT",
@@ -24,5 +24,10 @@
24
24
  },
25
25
  "nxrelease": {
26
26
  "repositoryUrl": "https://github.com/OKAMca/stack.git"
27
+ },
28
+ "dependencies": {
29
+ "@tsed/exceptions": "^8.3.1",
30
+ "dequal": "^2.0.3",
31
+ "react": "18.3.1"
27
32
  }
28
33
  }
@@ -0,0 +1 @@
1
+ export declare function normalizePath(path: string): string;
@@ -0,0 +1,4 @@
1
+ export declare class StringConvert {
2
+ static toSafeInteger: (value: string | unknown) => number | null;
3
+ static toFloat: (value: string | unknown) => number | null;
4
+ }
@@ -0,0 +1,4 @@
1
+ export type Maybe<T> = T | null;
2
+ export declare function isNonNullable<T>(x: T): x is NonNullable<T>;
3
+ export declare function maybeWithDefault<T>(x: Maybe<T>, defaultValue: NonNullable<T>): NonNullable<T>;
4
+ export declare function unknownToString(str: string | unknown): string;
@@ -1,8 +1,8 @@
1
1
  export type IsoDateString = string;
2
- export declare const isIsoDateString: (dateStr: unknown) => dateStr is string;
2
+ export declare const isIsoDateString: (dateStr: unknown) => dateStr is IsoDateString;
3
3
  export declare const isNonEmptyString: (v: unknown, trim?: boolean) => v is string;
4
4
  export declare const isPlainObject: <T = unknown, K extends string | number = string>(v: unknown) => v is Record<K, T>;
5
5
  export declare const isSafeInteger: (v: unknown) => v is number;
6
- export declare const isParsableNumeric: (v: unknown) => v is string | number;
7
- export declare const isParsableSafeInteger: (v: unknown) => v is string | number;
6
+ export declare const isParsableNumeric: (v: unknown) => v is number | string;
7
+ export declare const isParsableSafeInteger: (v: unknown) => v is number | string;
8
8
  export declare const isHttpStatusCode: (v: unknown) => v is number;