@zvonimirsun/iszy-common 1.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.
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './utils';
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ const r = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
2
+ function i(n) {
3
+ let t = "";
4
+ do
5
+ t = r.charAt(Number(n % 62n)) + t, n = n / 62n;
6
+ while (n > 0n);
7
+ return t;
8
+ }
9
+ const U = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\v\f\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x01-\x09\v\f\x0E-\x7F])\*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2}|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\v\f\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\v\f\x0E-\x7F])+)\])$/, h = /^1[3-9]\d{9}$/, e = [];
10
+ for (let n = 0; n < 256; ++n)
11
+ e.push((n + 256).toString(16).slice(1));
12
+ function a(n, t = 0) {
13
+ return (e[n[t + 0]] + e[n[t + 1]] + e[n[t + 2]] + e[n[t + 3]] + "-" + e[n[t + 4]] + e[n[t + 5]] + "-" + e[n[t + 6]] + e[n[t + 7]] + "-" + e[n[t + 8]] + e[n[t + 9]] + "-" + e[n[t + 10]] + e[n[t + 11]] + e[n[t + 12]] + e[n[t + 13]] + e[n[t + 14]] + e[n[t + 15]]).toLowerCase();
14
+ }
15
+ let d;
16
+ const g = new Uint8Array(16);
17
+ function s() {
18
+ if (!d) {
19
+ if (typeof crypto > "u" || !crypto.getRandomValues)
20
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
21
+ d = crypto.getRandomValues.bind(crypto);
22
+ }
23
+ return d(g);
24
+ }
25
+ const l = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), u = { randomUUID: l };
26
+ function y(n, t, o) {
27
+ var c;
28
+ if (u.randomUUID && !n)
29
+ return u.randomUUID();
30
+ n = n || {};
31
+ const x = n.random ?? ((c = n.rng) == null ? void 0 : c.call(n)) ?? s();
32
+ if (x.length < 16)
33
+ throw new Error("Random bytes length must be >= 16");
34
+ return x[6] = x[6] & 15 | 64, x[8] = x[8] & 63 | 128, a(x);
35
+ }
36
+ function E() {
37
+ return y();
38
+ }
39
+ function b(n) {
40
+ n = n || E();
41
+ const t = n.replace(/-/g, ""), o = BigInt(`0x${t.substring(0, 16)}`), x = BigInt(`0x${t.substring(16, 32)}`), c = o ^ x;
42
+ return i(c).substring(0, 6);
43
+ }
44
+ export {
45
+ U as REGEX_EMAIL,
46
+ h as REGEX_MOBILE_PHONE,
47
+ i as base62Encode,
48
+ b as encodeUUID,
49
+ E as getUUID
50
+ };
@@ -0,0 +1,8 @@
1
+ import type { RawRole } from './role';
2
+ export interface RawGroup {
3
+ id?: number;
4
+ name: string;
5
+ alias: string;
6
+ parentId?: number;
7
+ roles?: RawRole[];
8
+ }
@@ -0,0 +1 @@
1
+ export * from './user';
@@ -0,0 +1,4 @@
1
+ export interface RawPrivilege {
2
+ id?: number;
3
+ type: string;
4
+ }
@@ -0,0 +1,8 @@
1
+ import type { RawPrivilege } from './privilege';
2
+ export interface RawRole {
3
+ id?: number;
4
+ name: string;
5
+ alias: string;
6
+ desc?: string;
7
+ privileges?: RawPrivilege[];
8
+ }
@@ -0,0 +1,21 @@
1
+ import type { RawGroup } from './group';
2
+ import type { RawPrivilege } from './privilege';
3
+ import type { RawRole } from './role';
4
+ export interface RawUser {
5
+ userId: number;
6
+ userName: string;
7
+ nickName: string;
8
+ passwd: string;
9
+ passwdSalt?: string;
10
+ mobile?: string;
11
+ email?: string;
12
+ roles?: RawRole[];
13
+ groups?: RawGroup[];
14
+ status: number;
15
+ createBy: number;
16
+ updateBy: number;
17
+ privileges?: RawPrivilege[];
18
+ github?: string;
19
+ linuxdo?: string;
20
+ }
21
+ export type PublicUser = Omit<RawUser, 'passwd' | 'passwdSalt'>;
@@ -0,0 +1,2 @@
1
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
2
+ export type OptionalExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;
@@ -0,0 +1,2 @@
1
+ export * from './auth';
2
+ export * from './common';
@@ -0,0 +1 @@
1
+ export declare function base62Encode(num: bigint): string;
@@ -0,0 +1,3 @@
1
+ export * from './base62';
2
+ export * from './regexUtils';
3
+ export * from './uuid';
@@ -0,0 +1,2 @@
1
+ export declare const REGEX_EMAIL: RegExp;
2
+ export declare const REGEX_MOBILE_PHONE: RegExp;
@@ -0,0 +1,2 @@
1
+ export declare function getUUID(): string;
2
+ export declare function encodeUUID(uuid?: string): string;
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@zvonimirsun/iszy-common",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ },
10
+ "./*": "./*"
11
+ },
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "./dist"
17
+ ],
18
+ "dependencies": {
19
+ "uuid": "^11.1.0"
20
+ },
21
+ "devDependencies": {
22
+ "@antfu/eslint-config": "^4.11.0",
23
+ "eslint": "^9.23.0",
24
+ "taze": "^19.0.4",
25
+ "typescript": "~5.7.2",
26
+ "vite": "^6.2.0"
27
+ },
28
+ "scripts": {
29
+ "dev": "vite",
30
+ "build": "vite build && tsc -p tsconfig.build.json",
31
+ "lint": "eslint .",
32
+ "lint:fix": "eslint . --fix",
33
+ "preview": "vite preview",
34
+ "up": "taze minor -I"
35
+ }
36
+ }