oiu-core 0.0.26 → 0.0.28
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/dist/components/ErrorCode/index.d.ts.map +1 -1
- package/dist/{index-DsBrGEJj.js → index-DZ3rREg7.js} +1 -1
- package/dist/{main-CNHFtjCH.js → main-iElb4SaI.js} +4 -3
- package/dist/main.js +1 -1
- package/dist/redux/slices/errorSlice.d.ts +24 -2
- package/dist/redux/slices/errorSlice.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/ErrorCode/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAW,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAiB,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI1E,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/ErrorCode/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAW,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAiB,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI1E,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AACF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,cAAc,UAQvD;yBARe,SAAS;sBAiBA,SAAS,QAAQ,MAAM,UAAU,UAAU,CAAC,QAAQ,CAAC,WAAW,OAAO,EAAE"}
|
|
@@ -6997,11 +6997,12 @@ const $p = {
|
|
|
6997
6997
|
}), xc = (e) => e[Dc];
|
|
6998
6998
|
function ui({ code: e, args: t }) {
|
|
6999
6999
|
const r = tr(), n = Re((i) => xc(i).errors), o = ui.text(r, e, n, t);
|
|
7000
|
-
return t ? Qo(o, t) : o;
|
|
7000
|
+
return t && o ? Qo(o, t) : o;
|
|
7001
7001
|
}
|
|
7002
7002
|
ui.text = (e, t, r, ...n) => {
|
|
7003
7003
|
const o = r[t];
|
|
7004
|
-
|
|
7004
|
+
if (o)
|
|
7005
|
+
return n && n.length !== 0 ? Qo(o, ...n) : o;
|
|
7005
7006
|
};
|
|
7006
7007
|
const _m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
7007
7008
|
__proto__: null,
|
|
@@ -7039,7 +7040,7 @@ function Hp({ className: e, children: t, getPermissionFor: r, defaultAbility: n
|
|
|
7039
7040
|
var Fc = /* @__PURE__ */ ((e) => (e[e.Always = 1] = "Always", e[e.Never = 2] = "Never", e[e.RedirectIfFails = 3] = "RedirectIfFails", e))(Fc || {});
|
|
7040
7041
|
const kp = () => import(
|
|
7041
7042
|
/* @vite-ignore */
|
|
7042
|
-
"./index-
|
|
7043
|
+
"./index-DZ3rREg7.js"
|
|
7043
7044
|
);
|
|
7044
7045
|
async function Up(e, t, r) {
|
|
7045
7046
|
return (await kp()).default(e, t, r);
|
package/dist/main.js
CHANGED
|
@@ -2,16 +2,36 @@ import { Action } from '@reduxjs/toolkit';
|
|
|
2
2
|
export type Code = number;
|
|
3
3
|
export type ErrorText = string;
|
|
4
4
|
export type MSId = number;
|
|
5
|
+
/**
|
|
6
|
+
* Represent a bad response body coming from the backend. When an endpoint is requested and there is a validation error or any other error, the backend return
|
|
7
|
+
* a response with the status code and a body with the format of `IBadResModel`, this is used to load the error codes in the redux store and then use them in the app.
|
|
8
|
+
* Key is the field name and value is an array of error codes. Error codes are in the format of code:arg1:arg2, where code is the error code and arg1, arg2 are the arguments
|
|
9
|
+
* to format the error message.
|
|
10
|
+
* @example { email: ['4:30', '9'] } where 4 has attached "maximum length is {0}" and 9 is the parameter to format the code message resulting in "maximum length is 30".
|
|
11
|
+
* Code 9 mean is required so the message will be "This field is required".
|
|
12
|
+
* Those code number are just examples and the real meaning is defined in the backend, will change from different projects.
|
|
13
|
+
*/
|
|
14
|
+
export interface IBadResModel {
|
|
15
|
+
[key: string]: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Represent the error coming from the backend, this is the format returning for the /helps/errors endpoint.
|
|
19
|
+
*/
|
|
5
20
|
export interface IErrorModel {
|
|
6
21
|
code: Code;
|
|
7
22
|
name: string;
|
|
8
23
|
description: ErrorText;
|
|
9
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Payload of the action to merge the error codes in the redux store, this is used to load the error codes in the redux store and then use them in the app.
|
|
27
|
+
*/
|
|
10
28
|
type ErrorPayload = {
|
|
11
29
|
service: MSId;
|
|
12
30
|
errors?: IErrorModel[];
|
|
13
31
|
};
|
|
14
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Error store, this is the format of the error store in the redux, it contains the list of the services Id wich the codes already get loaded and a list of the error codes and their corresponding descriptions. This is used to load the error codes in the redux store and then use them in the app.
|
|
34
|
+
*/
|
|
15
35
|
export type ErrorStore = {
|
|
16
36
|
/** List of the services Id wich the codes already get loaded */
|
|
17
37
|
loaded: Record<MSId, boolean>;
|
|
@@ -21,7 +41,9 @@ export type ErrorStore = {
|
|
|
21
41
|
type MergeErrorAction = Action<string> & {
|
|
22
42
|
payload: ErrorPayload;
|
|
23
43
|
};
|
|
24
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Slice to manage the error codes in the redux store, this is used to load the error codes in the redux store and then use them in the app. The main action is pushErrors wich merge the new error codes with the existing ones in the store, but only if the service Id was not loaded before, this is to avoid loading the same error codes multiple times.
|
|
46
|
+
*/
|
|
25
47
|
export declare const errorSlice: import("@reduxjs/toolkit").Slice<ErrorStore, {
|
|
26
48
|
pushErrors(state: import("immer").WritableDraft<ErrorStore>, action: MergeErrorAction): void;
|
|
27
49
|
}, "error", "error", import("@reduxjs/toolkit").SliceSelectors<ErrorStore>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorSlice.d.ts","sourceRoot":"","sources":["../../../lib/redux/slices/errorSlice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,kBAAkB,CAAC;AAIvD,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,SAAS,CAAC;CAC1B;AAED,KAAK,YAAY,GAAG;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAA;AACD
|
|
1
|
+
{"version":3,"file":"errorSlice.d.ts","sourceRoot":"","sources":["../../../lib/redux/slices/errorSlice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,kBAAkB,CAAC;AAIvD,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B;AACD;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,KAAK,YAAY,GAAG;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAA;AACD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACrB,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9B,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;CACnC,CAAC;AACF,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG;IAAE,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC;AASnE;;GAEG;AACH,eAAO,MAAM,UAAU;yEAIW,gBAAgB;2EAchD,CAAC;AAEH;;;;GAIG;AAEH,eAAO,MAAM,aAAa,GAAI,OAAO,GAAG,KAA4B,UAAU,CAAC"}
|