oiu-core 0.1.4 → 0.1.6

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/README.md CHANGED
@@ -137,3 +137,7 @@ export default defineConfig([
137
137
  },
138
138
  ])
139
139
  ```
140
+ ## Publish NPM
141
+ 1. npm login
142
+ 2. npm run build
143
+ 3. npm publish
@@ -1,15 +1,15 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { MongoAbility } from '@casl/ability';
3
3
  import { Identity, Permission } from './_type';
4
- export type PermissionFn = (identity?: Identity) => {
4
+ export type PermissionFn<TIdentity extends Identity> = (identity?: TIdentity) => {
5
5
  allowed: Permission[];
6
6
  denied: Permission[];
7
7
  };
8
- export type AuthorizationProviderProps = PropsWithChildren<{
8
+ export type AuthorizationProviderProps<TIdentity extends Identity> = PropsWithChildren<{
9
9
  /** Optional CSS class name to apply to the Wait component wrapper */
10
10
  className?: string;
11
11
  /** Get permission for the current identity */
12
- getPermissionFor: PermissionFn;
12
+ getPermissionFor: PermissionFn<TIdentity>;
13
13
  /** Default ability to be use */
14
14
  defaultAbility?: MongoAbility;
15
15
  }>;
@@ -18,5 +18,5 @@ export type AuthorizationProviderProps = PropsWithChildren<{
18
18
  * @param param0
19
19
  * @returns
20
20
  */
21
- export declare function AuthorizationProvider({ className, children, getPermissionFor, defaultAbility }: AuthorizationProviderProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function AuthorizationProvider<TIdentity extends Identity>({ className, children, getPermissionFor, defaultAbility }: AuthorizationProviderProps<TIdentity>): import("react/jsx-runtime").JSX.Element;
22
22
  //# sourceMappingURL=AuthorizationProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthorizationProvider.d.ts","sourceRoot":"","sources":["../../lib/auth/AuthorizationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AAGxE,OAAO,EAAsC,YAAY,EAAE,MAAM,eA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AAY,CAAC;CACjC,CAAC,CAAC;AACH;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,QAAQ,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,0BAA0B,CAAC,SAAS,CAAC,2CA0CjK"}
@@ -9,7 +9,7 @@ export declare function useAuthentication(): IAuthService;
9
9
  * Retrieve the current identity in the system
10
10
  * @returns {Identity | undefined} The current identity
11
11
  */
12
- export declare function useIdentity(): Identity | undefined;
12
+ export declare function useIdentity<TIdentity extends Identity = Identity>(): TIdentity | undefined;
13
13
  /** Function to check if the user has the permission */
14
14
  export type AllowedFn = (permission: Permission) => boolean;
15
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/auth/utils.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAM3F,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM7D;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAKhD;AACD;;;GAGG;AACH,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAElD;AAED,uDAAuD;AACvD,MAAM,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC;AAC5D;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAc5B,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAGvD;AAQD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC;IACzC,gCAAgC;IAChC,UAAU,EAAE,UAAU,CAAC;CAC1B,CAAC,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,OAAO,iEAAmC,YAAY,6CAQjE,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/auth/utils.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAM3F,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM7D;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAKhD;AACD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ,KAAK,SAAS,GAAG,SAAS,CAE1F;AAED,uDAAuD;AACvD,MAAM,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC;AAC5D;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAc5B,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAGvD;AAQD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC;IACzC,gCAAgC;IAChC,UAAU,EAAE,UAAU,CAAC;CAC1B,CAAC,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,OAAO,iEAAmC,YAAY,6CAQjE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { A as Re, P as f, a as $, d as Ue } from "./main-DDVh2kVN.js";
1
+ import { A as Re, P as f, a as $, d as Ue } from "./main-FBHPIaGD.js";
2
2
  class j extends Error {
3
3
  }
4
4
  j.prototype.name = "InvalidTokenError";
@@ -19318,7 +19318,7 @@ function UR({ className: e, children: t, getPermissionFor: r, defaultAbility: n
19318
19318
  var zv = /* @__PURE__ */ ((e) => (e[e.Always = 1] = "Always", e[e.Never = 2] = "Never", e[e.RedirectIfFails = 3] = "RedirectIfFails", e))(zv || {});
19319
19319
  const WR = () => import(
19320
19320
  /* @vite-ignore */
19321
- "./index-YSAkS2Gn.js"
19321
+ "./index-DBhagcq9.js"
19322
19322
  );
19323
19323
  async function GR(e, t, r) {
19324
19324
  return (await WR()).default(e, t, r);
@@ -19340,6 +19340,23 @@ const FN = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
19340
19340
  }, Symbol.toStringTag, { value: "Module" }));
19341
19341
  var qv = /* @__PURE__ */ ((e) => (e[e.Info = 1] = "Info", e[e.Error = 2] = "Error", e[e.Warning = 3] = "Warning", e[e.Success = 4] = "Success", e))(qv || {});
19342
19342
  Promise.delay = (e) => new Promise((t) => setTimeout(t, e));
19343
+ Promise.waitUntil = (e, t) => {
19344
+ const r = t?.timeoutMs ?? 1e4, n = t?.intervalMs ?? 25, o = t?.timeoutMessage ?? "Timed out waiting for condition";
19345
+ return new Promise((i, s) => {
19346
+ const a = Date.now(), c = () => {
19347
+ if (e()) {
19348
+ i();
19349
+ return;
19350
+ }
19351
+ if (Date.now() - a >= r) {
19352
+ s(new Error(o));
19353
+ return;
19354
+ }
19355
+ setTimeout(c, n);
19356
+ };
19357
+ c();
19358
+ });
19359
+ };
19343
19360
  var Oa, Np;
19344
19361
  function Zn() {
19345
19362
  return Np || (Np = 1, Oa = TypeError), Oa;
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as e, b as t, h as u, j as i, c as n, e as o, f as h, u as c, g } from "./main-DDVh2kVN.js";
1
+ import { i as e, b as t, h as u, j as i, c as n, e as o, f as h, u as c, g } from "./main-FBHPIaGD.js";
2
2
  export {
3
3
  e as auth,
4
4
  t as components,
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../lib/utils/promise.ts"],"names":[],"mappings":"AAKA,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../lib/utils/promise.ts"],"names":[],"mappings":"AAqCA,eAAe,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oiu-core",
3
3
  "private": false,
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"