@delfinjs/core 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.
- package/README.md +52 -0
- package/dist/api/index.cjs +1 -0
- package/dist/api/index.js +60 -0
- package/dist/appConfig-BboO27Sg.cjs +1 -0
- package/dist/appConfig-hHCWS_gL.js +20 -0
- package/dist/auth/index.cjs +1 -0
- package/dist/auth/index.js +82 -0
- package/dist/crypto/index.cjs +1 -0
- package/dist/crypto/index.js +38 -0
- package/dist/eventBus/index.cjs +1 -0
- package/dist/eventBus/index.js +86 -0
- package/dist/helpers-CbBec0n2.js +19 -0
- package/dist/helpers-Du3u7brS.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +55 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.js +25 -0
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.js +77 -0
- package/dist/validators/index.cjs +1 -0
- package/dist/validators/index.js +26 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @delfinjs/core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic shared utilities for Delfin micro-frontend applications.
|
|
4
|
+
|
|
5
|
+
This package contains **zero framework dependencies** — it works with Vue, React, Angular, Blazor (via JS interop), or plain JavaScript/TypeScript.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @delfinjs/core
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @delfinjs/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Modules
|
|
16
|
+
|
|
17
|
+
| Import path | Description |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `@delfinjs/core` | Everything (barrel export) |
|
|
20
|
+
| `@delfinjs/core/utils` | Color converters, formatters, helpers, app config, micro-UI config loader |
|
|
21
|
+
| `@delfinjs/core/crypto` | AES encrypt/decrypt, JWT parser, credential helpers |
|
|
22
|
+
| `@delfinjs/core/eventBus` | `EventBus` singleton + `MFEventTypes` for MF communication |
|
|
23
|
+
| `@delfinjs/core/api` | `createAppApi()` — token-aware HTTP client factory (ofetch) |
|
|
24
|
+
| `@delfinjs/core/auth` | `isAuthenticated()`, `redirectToLogin()`, `receiveAuthFromUrl()` |
|
|
25
|
+
| `@delfinjs/core/validators` | Form validators (required, email, password, integer, URL, etc.) |
|
|
26
|
+
| `@delfinjs/core/types` | JSDoc types + enums (AppContentLayoutNav, ContentWidth, Skins, etc.) |
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import { formatDate, hexToRgb } from '@delfinjs/core/utils'
|
|
32
|
+
import { eventBus, MFEventTypes } from '@delfinjs/core/eventBus'
|
|
33
|
+
import { createAppApi } from '@delfinjs/core/api'
|
|
34
|
+
import { isAuthenticated } from '@delfinjs/core/auth'
|
|
35
|
+
|
|
36
|
+
// Create an API client with framework-agnostic token getter
|
|
37
|
+
const api = createAppApi({
|
|
38
|
+
baseURL: '/my-api',
|
|
39
|
+
appSlug: 'my-app',
|
|
40
|
+
getToken: () => getCookieValue('accessToken'), // your own token retrieval
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const data = await api('/endpoint')
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Building
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Produces ESM and CJS output in `dist/`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("ofetch"),s=require("../eventBus/index.cjs");var l=typeof document<"u"?document.currentScript:null;const _={};function R(){var t;return typeof window<"u"&&((t=window.__APP_CONFIG__)!=null&&t.VITE_API_BASE_URL)?window.__APP_CONFIG__.VITE_API_BASE_URL:typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:l&&l.tagName.toUpperCase()==="SCRIPT"&&l.src||new URL("api/index.cjs",document.baseURI).href}<"u"&&(_==null?void 0:_.VITE_API_BASE_URL)||"/api"}function U(t={}){const{baseURL:A,appSlug:a,headers:T,getToken:c}=typeof t=="string"?{baseURL:t,appSlug:void 0,headers:void 0,getToken:void 0}:t;let d=null,r=null;function E(){return r||(r=new Promise(e=>{const n=setTimeout(()=>{i(),r=null,e(null)},1e4),i=s.eventBus.on(s.MFEventTypes.AUTH_MICROUI_TOKEN_REFRESH_RESPONSE,({slug:u,token:o})=>{u===a&&(clearTimeout(n),i(),d=o,r=null,e(o))});s.eventBus.emit(s.MFEventTypes.AUTH_MICROUI_TOKEN_REFRESH_REQUEST,{slug:a})}),r)}const f=h.ofetch.create({baseURL:A||R(),async onRequest({options:e}){const n=d||(c==null?void 0:c())||null;e.headers={...T||{},...e.headers||{},...n?{Authorization:`Bearer ${n}`}:{}}}}),p=async(e,n)=>{var i;try{return await f(e,n)}catch(u){if(((i=u==null?void 0:u.response)==null?void 0:i.status)===401&&a){const o=await E();if(o)return f(e,{...n,headers:{...(n==null?void 0:n.headers)||{},Authorization:`Bearer ${o}`}})}throw u}};return p.setToken=e=>{d=e},p}exports.createAppApi=U;exports.getApiBaseUrl=R;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ofetch as h } from "ofetch";
|
|
2
|
+
import { eventBus as l, MFEventTypes as E } from "../eventBus/index.js";
|
|
3
|
+
const c = {};
|
|
4
|
+
function I() {
|
|
5
|
+
var t;
|
|
6
|
+
return typeof window < "u" && ((t = window.__APP_CONFIG__) != null && t.VITE_API_BASE_URL) ? window.__APP_CONFIG__.VITE_API_BASE_URL : typeof import.meta < "u" && (c == null ? void 0 : c.VITE_API_BASE_URL) || "/api";
|
|
7
|
+
}
|
|
8
|
+
function p(t = {}) {
|
|
9
|
+
const { baseURL: A, appSlug: s, headers: R, getToken: u } = typeof t == "string" ? { baseURL: t, appSlug: void 0, headers: void 0, getToken: void 0 } : t;
|
|
10
|
+
let _ = null, r = null;
|
|
11
|
+
function T() {
|
|
12
|
+
return r || (r = new Promise((e) => {
|
|
13
|
+
const n = setTimeout(() => {
|
|
14
|
+
o(), r = null, e(null);
|
|
15
|
+
}, 1e4), o = l.on(
|
|
16
|
+
E.AUTH_MICROUI_TOKEN_REFRESH_RESPONSE,
|
|
17
|
+
({ slug: i, token: a }) => {
|
|
18
|
+
i === s && (clearTimeout(n), o(), _ = a, r = null, e(a));
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
l.emit(E.AUTH_MICROUI_TOKEN_REFRESH_REQUEST, { slug: s });
|
|
22
|
+
}), r);
|
|
23
|
+
}
|
|
24
|
+
const f = h.create({
|
|
25
|
+
baseURL: A || I(),
|
|
26
|
+
async onRequest({ options: e }) {
|
|
27
|
+
const n = _ || (u == null ? void 0 : u()) || null;
|
|
28
|
+
e.headers = {
|
|
29
|
+
...R || {},
|
|
30
|
+
...e.headers || {},
|
|
31
|
+
...n ? { Authorization: `Bearer ${n}` } : {}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}), d = async (e, n) => {
|
|
35
|
+
var o;
|
|
36
|
+
try {
|
|
37
|
+
return await f(e, n);
|
|
38
|
+
} catch (i) {
|
|
39
|
+
if (((o = i == null ? void 0 : i.response) == null ? void 0 : o.status) === 401 && s) {
|
|
40
|
+
const a = await T();
|
|
41
|
+
if (a)
|
|
42
|
+
return f(e, {
|
|
43
|
+
...n,
|
|
44
|
+
headers: {
|
|
45
|
+
...(n == null ? void 0 : n.headers) || {},
|
|
46
|
+
Authorization: `Bearer ${a}`
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
throw i;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return d.setToken = (e) => {
|
|
54
|
+
_ = e;
|
|
55
|
+
}, d;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
p as createAppApi,
|
|
59
|
+
I as getApiBaseUrl
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=typeof document<"u"?document.currentScript:null;const d={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};function r(e,o){var t,f,i;if(typeof window<"u"){if(o&&((f=(t=window.__MICROUI_CONFIG__)==null?void 0:t[o])==null?void 0:f[e])!==void 0)return window.__MICROUI_CONFIG__[o][e];if(((i=window.__APP_CONFIG__)==null?void 0:i[e])!==void 0)return window.__APP_CONFIG__[e]}return typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:n&&n.tagName.toUpperCase()==="SCRIPT"&&n.src||new URL("appConfig-BboO27Sg.cjs",document.baseURI).href}<"u"?d==null?void 0:d[e]:void 0}function u(e){var i;const o=typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:n&&n.tagName.toUpperCase()==="SCRIPT"&&n.src||new URL("appConfig-BboO27Sg.cjs",document.baseURI).href}<"u"&&d||{},t=typeof window<"u"&&window.__APP_CONFIG__||{},f=typeof window<"u"&&e&&((i=window.__MICROUI_CONFIG__)==null?void 0:i[e])||{};return{...o,...t,...f}}exports.getAllAppConfig=u;exports.getAppConfig=r;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const f = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
2
|
+
function t(n, o) {
|
|
3
|
+
var d, _, i;
|
|
4
|
+
if (typeof window < "u") {
|
|
5
|
+
if (o && ((_ = (d = window.__MICROUI_CONFIG__) == null ? void 0 : d[o]) == null ? void 0 : _[n]) !== void 0)
|
|
6
|
+
return window.__MICROUI_CONFIG__[o][n];
|
|
7
|
+
if (((i = window.__APP_CONFIG__) == null ? void 0 : i[n]) !== void 0)
|
|
8
|
+
return window.__APP_CONFIG__[n];
|
|
9
|
+
}
|
|
10
|
+
return typeof import.meta < "u" ? f == null ? void 0 : f[n] : void 0;
|
|
11
|
+
}
|
|
12
|
+
function e(n) {
|
|
13
|
+
var i;
|
|
14
|
+
const o = typeof import.meta < "u" && f || {}, d = typeof window < "u" && window.__APP_CONFIG__ || {}, _ = typeof window < "u" && n && ((i = window.__MICROUI_CONFIG__) == null ? void 0 : i[n]) || {};
|
|
15
|
+
return { ...o, ...d, ..._ };
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
e as a,
|
|
19
|
+
t as g
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("cookie-es"),u=require("destr"),l=require("../appConfig-BboO27Sg.cjs");var i=typeof document<"u"?document.currentScript:null;const c={};function f(){if(typeof document>"u")return!1;const e=d.parse(document.cookie),n=e.accessToken,o=e.userData;if(n)try{const t=u.destr(decodeURIComponent(n));return!!t&&t!=="null"&&t!=="undefined"}catch{return!1}if(o)try{const t=u.destr(decodeURIComponent(o));return!!t&&typeof t=="object"&&t.id}catch{return!1}return!1}function r(){const e=l.getAppConfig("VITE_DELFIN_UI_BASE_URL");return e?e.replace(/\/+$/,""):typeof window<"u"&&window.location.hostname==="localhost"&&window.location.port!=="3000"?"http://localhost:3000":typeof window<"u"?window.location.origin:""}function w(){const e=r();try{return typeof window<"u"&&window.location.origin!==new URL(e).origin}catch{return!1}}function h(){var e;return typeof window<"u"&&((e=window.__APP_CONFIG__)!=null&&e.VITE_APP_SLUG)?window.__APP_CONFIG__.VITE_APP_SLUG:typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("auth/index.cjs",document.baseURI).href}<"u"?c==null?void 0:c.VITE_APP_SLUG:void 0}function a(e){try{const n=new URL(e);return n.searchParams.delete("_auth"),n.toString()}catch{return e}}function p(){const e=r(),n=h(),o=a(window.location.href),t=n?`&slug=${encodeURIComponent(n)}`:"";window.location.href=`${e}/auth-bridge?redirect=${encodeURIComponent(o)}${t}`}function m(){if(typeof window>"u")return;if(w()){p();return}const e=r();window.location.href=`${e}/login?redirect=${encodeURIComponent(window.location.href)}`}function U(){if(typeof window>"u")return!1;const n=new URLSearchParams(window.location.search).get("_auth");if(!n)return!1;try{const o=JSON.parse(atob(decodeURIComponent(n)));for(const[t,s]of Object.entries(o))document.cookie=d.serialize(t,s,{path:"/",maxAge:3600*24*30});return window.history.replaceState(null,"",a(window.location.href)),!0}catch{return!1}}exports.getShellUrl=r;exports.isAuthenticated=f;exports.receiveAuthFromUrl=U;exports.redirectToLogin=m;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { parse as s, serialize as u } from "cookie-es";
|
|
2
|
+
import { destr as c } from "destr";
|
|
3
|
+
import { g as f } from "../appConfig-hHCWS_gL.js";
|
|
4
|
+
const r = {};
|
|
5
|
+
function U() {
|
|
6
|
+
if (typeof document > "u") return !1;
|
|
7
|
+
const e = s(document.cookie), n = e.accessToken, t = e.userData;
|
|
8
|
+
if (n)
|
|
9
|
+
try {
|
|
10
|
+
const o = c(decodeURIComponent(n));
|
|
11
|
+
return !!o && o !== "null" && o !== "undefined";
|
|
12
|
+
} catch {
|
|
13
|
+
return !1;
|
|
14
|
+
}
|
|
15
|
+
if (t)
|
|
16
|
+
try {
|
|
17
|
+
const o = c(decodeURIComponent(t));
|
|
18
|
+
return !!o && typeof o == "object" && o.id;
|
|
19
|
+
} catch {
|
|
20
|
+
return !1;
|
|
21
|
+
}
|
|
22
|
+
return !1;
|
|
23
|
+
}
|
|
24
|
+
function i() {
|
|
25
|
+
const e = f("VITE_DELFIN_UI_BASE_URL");
|
|
26
|
+
return e ? e.replace(/\/+$/, "") : typeof window < "u" && window.location.hostname === "localhost" && window.location.port !== "3000" ? "http://localhost:3000" : typeof window < "u" ? window.location.origin : "";
|
|
27
|
+
}
|
|
28
|
+
function l() {
|
|
29
|
+
const e = i();
|
|
30
|
+
try {
|
|
31
|
+
return typeof window < "u" && window.location.origin !== new URL(e).origin;
|
|
32
|
+
} catch {
|
|
33
|
+
return !1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function w() {
|
|
37
|
+
var e;
|
|
38
|
+
return typeof window < "u" && ((e = window.__APP_CONFIG__) != null && e.VITE_APP_SLUG) ? window.__APP_CONFIG__.VITE_APP_SLUG : typeof import.meta < "u" ? r == null ? void 0 : r.VITE_APP_SLUG : void 0;
|
|
39
|
+
}
|
|
40
|
+
function a(e) {
|
|
41
|
+
try {
|
|
42
|
+
const n = new URL(e);
|
|
43
|
+
return n.searchParams.delete("_auth"), n.toString();
|
|
44
|
+
} catch {
|
|
45
|
+
return e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function p() {
|
|
49
|
+
const e = i(), n = w(), t = a(window.location.href), o = n ? `&slug=${encodeURIComponent(n)}` : "";
|
|
50
|
+
window.location.href = `${e}/auth-bridge?redirect=${encodeURIComponent(t)}${o}`;
|
|
51
|
+
}
|
|
52
|
+
function y() {
|
|
53
|
+
if (typeof window > "u") return;
|
|
54
|
+
if (l()) {
|
|
55
|
+
p();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const e = i();
|
|
59
|
+
window.location.href = `${e}/login?redirect=${encodeURIComponent(window.location.href)}`;
|
|
60
|
+
}
|
|
61
|
+
function _() {
|
|
62
|
+
if (typeof window > "u") return !1;
|
|
63
|
+
const n = new URLSearchParams(window.location.search).get("_auth");
|
|
64
|
+
if (!n) return !1;
|
|
65
|
+
try {
|
|
66
|
+
const t = JSON.parse(atob(decodeURIComponent(n)));
|
|
67
|
+
for (const [o, d] of Object.entries(t))
|
|
68
|
+
document.cookie = u(o, d, {
|
|
69
|
+
path: "/",
|
|
70
|
+
maxAge: 3600 * 24 * 30
|
|
71
|
+
});
|
|
72
|
+
return window.history.replaceState(null, "", a(window.location.href)), !0;
|
|
73
|
+
} catch {
|
|
74
|
+
return !1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
i as getShellUrl,
|
|
79
|
+
U as isAuthenticated,
|
|
80
|
+
_ as receiveAuthFromUrl,
|
|
81
|
+
y as redirectToLogin
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("crypto-js");function l(e,t){return o.AES.encrypt(e,t).toString()}function p(e,t){return o.AES.decrypt(e,t).toString(o.enc.Utf8)}function c(e){const r=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(r).split("").map(a=>`%${`00${a.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(n)}function d(e){if(!e)return new Set;try{const r=c(e).credentials;if(!Array.isArray(r))return new Set;const n=new Set;for(const a of r){const[s,i]=a.split("###");i==="1"&&s&&n.add(s)}return n}catch(t){return console.error("[credentials] Failed to parse JWT credentials:",t),new Set}}function u(e,t){return t?e.has(t):!0}exports.decrypt=p;exports.encrypt=l;exports.hasCredential=u;exports.parseCredentials=d;exports.parseJwt=c;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import a from "crypto-js";
|
|
2
|
+
function l(t, e) {
|
|
3
|
+
return a.AES.encrypt(t, e).toString();
|
|
4
|
+
}
|
|
5
|
+
function d(t, e) {
|
|
6
|
+
return a.AES.decrypt(t, e).toString(a.enc.Utf8);
|
|
7
|
+
}
|
|
8
|
+
function i(t) {
|
|
9
|
+
const r = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), n = decodeURIComponent(
|
|
10
|
+
atob(r).split("").map((o) => `%${`00${o.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")
|
|
11
|
+
);
|
|
12
|
+
return JSON.parse(n);
|
|
13
|
+
}
|
|
14
|
+
function u(t) {
|
|
15
|
+
if (!t) return /* @__PURE__ */ new Set();
|
|
16
|
+
try {
|
|
17
|
+
const r = i(t).credentials;
|
|
18
|
+
if (!Array.isArray(r)) return /* @__PURE__ */ new Set();
|
|
19
|
+
const n = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const o of r) {
|
|
21
|
+
const [c, s] = o.split("###");
|
|
22
|
+
s === "1" && c && n.add(c);
|
|
23
|
+
}
|
|
24
|
+
return n;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
return console.error("[credentials] Failed to parse JWT credentials:", e), /* @__PURE__ */ new Set();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function y(t, e) {
|
|
30
|
+
return e ? t.has(e) : !0;
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
d as decrypt,
|
|
34
|
+
l as encrypt,
|
|
35
|
+
y as hasCredential,
|
|
36
|
+
u as parseCredentials,
|
|
37
|
+
i as parseJwt
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o={AUTH_LOGIN:"mf:auth:login",AUTH_LOGOUT:"mf:auth:logout",AUTH_TOKEN_REFRESH:"mf:auth:token-refresh",AUTH_USER_UPDATE:"mf:auth:user-update",AUTH_MICROUI_TOKEN_REFRESH_REQUEST:"mf:auth:microui-token-refresh-request",AUTH_MICROUI_TOKEN_REFRESH_RESPONSE:"mf:auth:microui-token-refresh-response",NAV_ROUTE_CHANGE:"mf:nav:route-change",NAV_BREADCRUMB_UPDATE:"mf:nav:breadcrumb-update",THEME_CHANGE:"mf:theme:change",LOCALE_CHANGE:"mf:locale:change",LOADING_START:"mf:loading:start",LOADING_END:"mf:loading:end",ERROR_GLOBAL:"mf:error:global",ERROR_AUTH:"mf:error:auth",APP_MOUNTED:"mf:app:mounted",APP_UNMOUNTED:"mf:app:unmounted",APP_READY:"mf:app:ready"};class i{constructor(){this.events=new Map}on(e,t){return this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t),()=>this.off(e,t)}once(e,t){const s=(...r)=>{t(...r),this.off(e,s)};this.on(e,s)}off(e,t){this.events.has(e)&&this.events.get(e).delete(t)}emit(e,t){this.events.has(e)&&this.events.get(e).forEach(s=>{try{s(t)}catch(r){console.error(`[EventBus] Error in handler for ${e}:`,r)}}),typeof window<"u"&&window.dispatchEvent(new CustomEvent(e,{detail:t}))}clear(e){e?this.events.delete(e):this.events.clear()}}const f=new i;typeof window<"u"&&Object.values(o).forEach(n=>{window.addEventListener(n,e=>{var t;e._fromEventBus||(t=f.events.get(n))==null||t.forEach(s=>{s(e.detail)})})});exports.MFEventTypes=o;exports.eventBus=f;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const o = {
|
|
2
|
+
AUTH_LOGIN: "mf:auth:login",
|
|
3
|
+
AUTH_LOGOUT: "mf:auth:logout",
|
|
4
|
+
AUTH_TOKEN_REFRESH: "mf:auth:token-refresh",
|
|
5
|
+
AUTH_USER_UPDATE: "mf:auth:user-update",
|
|
6
|
+
AUTH_MICROUI_TOKEN_REFRESH_REQUEST: "mf:auth:microui-token-refresh-request",
|
|
7
|
+
AUTH_MICROUI_TOKEN_REFRESH_RESPONSE: "mf:auth:microui-token-refresh-response",
|
|
8
|
+
NAV_ROUTE_CHANGE: "mf:nav:route-change",
|
|
9
|
+
NAV_BREADCRUMB_UPDATE: "mf:nav:breadcrumb-update",
|
|
10
|
+
THEME_CHANGE: "mf:theme:change",
|
|
11
|
+
LOCALE_CHANGE: "mf:locale:change",
|
|
12
|
+
LOADING_START: "mf:loading:start",
|
|
13
|
+
LOADING_END: "mf:loading:end",
|
|
14
|
+
ERROR_GLOBAL: "mf:error:global",
|
|
15
|
+
ERROR_AUTH: "mf:error:auth",
|
|
16
|
+
APP_MOUNTED: "mf:app:mounted",
|
|
17
|
+
APP_UNMOUNTED: "mf:app:unmounted",
|
|
18
|
+
APP_READY: "mf:app:ready"
|
|
19
|
+
};
|
|
20
|
+
class f {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.events = /* @__PURE__ */ new Map();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Subscribe to an event.
|
|
26
|
+
* @param {string} event
|
|
27
|
+
* @param {Function} callback
|
|
28
|
+
* @returns {Function} unsubscribe
|
|
29
|
+
*/
|
|
30
|
+
on(e, t) {
|
|
31
|
+
return this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t), () => this.off(e, t);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Subscribe once.
|
|
35
|
+
* @param {string} event
|
|
36
|
+
* @param {Function} callback
|
|
37
|
+
*/
|
|
38
|
+
once(e, t) {
|
|
39
|
+
const s = (...r) => {
|
|
40
|
+
t(...r), this.off(e, s);
|
|
41
|
+
};
|
|
42
|
+
this.on(e, s);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Unsubscribe.
|
|
46
|
+
* @param {string} event
|
|
47
|
+
* @param {Function} callback
|
|
48
|
+
*/
|
|
49
|
+
off(e, t) {
|
|
50
|
+
this.events.has(e) && this.events.get(e).delete(t);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Emit an event.
|
|
54
|
+
* @param {string} event
|
|
55
|
+
* @param {*} data
|
|
56
|
+
*/
|
|
57
|
+
emit(e, t) {
|
|
58
|
+
this.events.has(e) && this.events.get(e).forEach((s) => {
|
|
59
|
+
try {
|
|
60
|
+
s(t);
|
|
61
|
+
} catch (r) {
|
|
62
|
+
console.error(`[EventBus] Error in handler for ${e}:`, r);
|
|
63
|
+
}
|
|
64
|
+
}), typeof window < "u" && window.dispatchEvent(new CustomEvent(e, { detail: t }));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Clear subscriptions.
|
|
68
|
+
* @param {string} [event] - If omitted, clears all.
|
|
69
|
+
*/
|
|
70
|
+
clear(e) {
|
|
71
|
+
e ? this.events.delete(e) : this.events.clear();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const E = new f();
|
|
75
|
+
typeof window < "u" && Object.values(o).forEach((n) => {
|
|
76
|
+
window.addEventListener(n, (e) => {
|
|
77
|
+
var t;
|
|
78
|
+
e._fromEventBus || (t = E.events.get(n)) == null || t.forEach((s) => {
|
|
79
|
+
s(e.detail);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
export {
|
|
84
|
+
o as MFEventTypes,
|
|
85
|
+
E as eventBus
|
|
86
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const s = (t) => !!(t == null || t === "" || Array.isArray(t) && t.length === 0 || typeof t == "object" && !Array.isArray(t) && Object.keys(t).length === 0), y = (t) => t == null, i = (t) => Array.isArray(t) && t.length === 0, o = (t) => t !== null && typeof t == "object" && !Array.isArray(t), c = (t) => {
|
|
2
|
+
const r = /* @__PURE__ */ new Date();
|
|
3
|
+
return t.getDate() === r.getDate() && t.getMonth() === r.getMonth() && t.getFullYear() === r.getFullYear();
|
|
4
|
+
}, n = (t) => {
|
|
5
|
+
if (t === null || typeof t != "object") return t;
|
|
6
|
+
if (Array.isArray(t)) return t.map(n);
|
|
7
|
+
const r = {};
|
|
8
|
+
for (const e in t)
|
|
9
|
+
Object.prototype.hasOwnProperty.call(t, e) && (r[e] = n(t[e]));
|
|
10
|
+
return r;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
y as a,
|
|
14
|
+
i as b,
|
|
15
|
+
o as c,
|
|
16
|
+
c as d,
|
|
17
|
+
n as e,
|
|
18
|
+
s as i
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=t=>!!(t==null||t===""||Array.isArray(t)&&t.length===0||typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0),i=t=>t==null,y=t=>Array.isArray(t)&&t.length===0,o=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),c=t=>{const r=new Date;return t.getDate()===r.getDate()&&t.getMonth()===r.getMonth()&&t.getFullYear()===r.getFullYear()},n=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(n);const r={};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=n(t[e]));return r};exports.deepClone=n;exports.isEmpty=s;exports.isEmptyArray=y;exports.isNullOrUndefined=i;exports.isObject=o;exports.isToday=c;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./utils/index.cjs"),t=require("./helpers-Du3u7brS.cjs"),l=require("./appConfig-BboO27Sg.cjs"),a=require("./crypto/index.cjs"),n=require("./eventBus/index.cjs"),d=require("./api/index.cjs"),o=require("./auth/index.cjs"),e=require("./validators/index.cjs"),i=require("./types/index.cjs");exports.formatCurrency=r.formatCurrency;exports.formatDate=r.formatDate;exports.formatNumber=r.formatNumber;exports.hexToRgb=r.hexToRgb;exports.loadAllMicroUIConfigs=r.loadAllMicroUIConfigs;exports.loadMicroUIConfig=r.loadMicroUIConfig;exports.rgbToHex=r.rgbToHex;exports.deepClone=t.deepClone;exports.isEmpty=t.isEmpty;exports.isEmptyArray=t.isEmptyArray;exports.isNullOrUndefined=t.isNullOrUndefined;exports.isObject=t.isObject;exports.isToday=t.isToday;exports.getAllAppConfig=l.getAllAppConfig;exports.getAppConfig=l.getAppConfig;exports.decrypt=a.decrypt;exports.encrypt=a.encrypt;exports.hasCredential=a.hasCredential;exports.parseCredentials=a.parseCredentials;exports.parseJwt=a.parseJwt;exports.MFEventTypes=n.MFEventTypes;exports.eventBus=n.eventBus;exports.createAppApi=d.createAppApi;exports.getApiBaseUrl=d.getApiBaseUrl;exports.getShellUrl=o.getShellUrl;exports.isAuthenticated=o.isAuthenticated;exports.receiveAuthFromUrl=o.receiveAuthFromUrl;exports.redirectToLogin=o.redirectToLogin;exports.alphaDashValidator=e.alphaDashValidator;exports.alphaValidator=e.alphaValidator;exports.betweenValidator=e.betweenValidator;exports.confirmedValidator=e.confirmedValidator;exports.emailValidator=e.emailValidator;exports.integerValidator=e.integerValidator;exports.lengthValidator=e.lengthValidator;exports.passwordValidator=e.passwordValidator;exports.regexValidator=e.regexValidator;exports.requiredValidator=e.requiredValidator;exports.urlValidator=e.urlValidator;exports.AppContentLayoutNav=i.AppContentLayoutNav;exports.ContentWidth=i.ContentWidth;exports.FooterType=i.FooterType;exports.NavbarType=i.NavbarType;exports.Skins=i.Skins;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { formatCurrency as a, formatDate as o, formatNumber as t, hexToRgb as i, loadAllMicroUIConfigs as l, loadMicroUIConfig as p, rgbToHex as d } from "./utils/index.js";
|
|
2
|
+
import { e as n, i as f, b as m, a as g, c, d as x } from "./helpers-CbBec0n2.js";
|
|
3
|
+
import { a as A, g as V } from "./appConfig-hHCWS_gL.js";
|
|
4
|
+
import { decrypt as C, encrypt as u, hasCredential as b, parseCredentials as T, parseJwt as U } from "./crypto/index.js";
|
|
5
|
+
import { MFEventTypes as N, eventBus as w } from "./eventBus/index.js";
|
|
6
|
+
import { createAppApi as F, getApiBaseUrl as M } from "./api/index.js";
|
|
7
|
+
import { getShellUrl as D, isAuthenticated as I, receiveAuthFromUrl as L, redirectToLogin as O } from "./auth/index.js";
|
|
8
|
+
import { alphaDashValidator as j, alphaValidator as k, betweenValidator as q, confirmedValidator as H, emailValidator as J, integerValidator as R, lengthValidator as W, passwordValidator as z, regexValidator as G, requiredValidator as K, urlValidator as P } from "./validators/index.js";
|
|
9
|
+
import { AppContentLayoutNav as X, ContentWidth as Y, FooterType as Z, NavbarType as _, Skins as $ } from "./types/index.js";
|
|
10
|
+
export {
|
|
11
|
+
X as AppContentLayoutNav,
|
|
12
|
+
Y as ContentWidth,
|
|
13
|
+
Z as FooterType,
|
|
14
|
+
N as MFEventTypes,
|
|
15
|
+
_ as NavbarType,
|
|
16
|
+
$ as Skins,
|
|
17
|
+
j as alphaDashValidator,
|
|
18
|
+
k as alphaValidator,
|
|
19
|
+
q as betweenValidator,
|
|
20
|
+
H as confirmedValidator,
|
|
21
|
+
F as createAppApi,
|
|
22
|
+
C as decrypt,
|
|
23
|
+
n as deepClone,
|
|
24
|
+
J as emailValidator,
|
|
25
|
+
u as encrypt,
|
|
26
|
+
w as eventBus,
|
|
27
|
+
a as formatCurrency,
|
|
28
|
+
o as formatDate,
|
|
29
|
+
t as formatNumber,
|
|
30
|
+
A as getAllAppConfig,
|
|
31
|
+
M as getApiBaseUrl,
|
|
32
|
+
V as getAppConfig,
|
|
33
|
+
D as getShellUrl,
|
|
34
|
+
b as hasCredential,
|
|
35
|
+
i as hexToRgb,
|
|
36
|
+
R as integerValidator,
|
|
37
|
+
I as isAuthenticated,
|
|
38
|
+
f as isEmpty,
|
|
39
|
+
m as isEmptyArray,
|
|
40
|
+
g as isNullOrUndefined,
|
|
41
|
+
c as isObject,
|
|
42
|
+
x as isToday,
|
|
43
|
+
W as lengthValidator,
|
|
44
|
+
l as loadAllMicroUIConfigs,
|
|
45
|
+
p as loadMicroUIConfig,
|
|
46
|
+
T as parseCredentials,
|
|
47
|
+
U as parseJwt,
|
|
48
|
+
z as passwordValidator,
|
|
49
|
+
L as receiveAuthFromUrl,
|
|
50
|
+
O as redirectToLogin,
|
|
51
|
+
G as regexValidator,
|
|
52
|
+
K as requiredValidator,
|
|
53
|
+
d as rgbToHex,
|
|
54
|
+
P as urlValidator
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={Vertical:"vertical",Horizontal:"horizontal"},e={Boxed:"boxed",Fluid:"fluid"},o={Sticky:"sticky",Static:"static",Hidden:"hidden"},i={Sticky:"sticky",Static:"static",Hidden:"hidden"},n={Default:"default",Bordered:"bordered"};exports.AppContentLayoutNav=t;exports.ContentWidth=e;exports.FooterType=i;exports.NavbarType=o;exports.Skins=n;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const t = {
|
|
2
|
+
Vertical: "vertical",
|
|
3
|
+
Horizontal: "horizontal"
|
|
4
|
+
}, e = {
|
|
5
|
+
Boxed: "boxed",
|
|
6
|
+
Fluid: "fluid"
|
|
7
|
+
}, i = {
|
|
8
|
+
Sticky: "sticky",
|
|
9
|
+
Static: "static",
|
|
10
|
+
Hidden: "hidden"
|
|
11
|
+
}, o = {
|
|
12
|
+
Sticky: "sticky",
|
|
13
|
+
Static: "static",
|
|
14
|
+
Hidden: "hidden"
|
|
15
|
+
}, d = {
|
|
16
|
+
Default: "default",
|
|
17
|
+
Bordered: "bordered"
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
t as AppContentLayoutNav,
|
|
21
|
+
e as ContentWidth,
|
|
22
|
+
o as FooterType,
|
|
23
|
+
i as NavbarType,
|
|
24
|
+
d as Skins
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../helpers-Du3u7brS.cjs"),s=require("../appConfig-BboO27Sg.cjs"),l=n=>{const t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(t,(r,i,o,c)=>i+i+o+o+c+c);const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return e?`${parseInt(e[1],16)}, ${parseInt(e[2],16)}, ${parseInt(e[3],16)}`:null},u=(n,t,e)=>{const r=i=>{const o=i.toString(16);return o.length===1?"0"+o:o};return`#${r(n)}${r(t)}${r(e)}`},d=(n,t="en-US",e={})=>{const r={year:"numeric",month:"short",day:"numeric",...e};return new Intl.DateTimeFormat(t,r).format(new Date(n))},g=(n,t="USD",e="en-US")=>new Intl.NumberFormat(e,{style:"currency",currency:t}).format(n),m=(n,t="en-US",e={})=>new Intl.NumberFormat(t,e).format(n);typeof window<"u"&&!window.__MICROUI_CONFIG__&&(window.__MICROUI_CONFIG__={});function p(n){try{return new URL(n).origin}catch{return null}}function y(n){const t=n.indexOf("{"),e=n.lastIndexOf("}");if(t===-1||e===-1)return null;try{return JSON.parse(n.slice(t,e+1))}catch{return null}}async function f(n,t){const e=p(t);if(!e)return null;try{const r=await fetch(`${e}/config.js`,{cache:"no-cache"});if(!r.ok)return null;const i=await r.text(),o=y(i);return o&&typeof window<"u"&&(window.__MICROUI_CONFIG__[n]=o),o}catch{return console.warn(`[MicroUIConfig] Failed to load config for ${n} from ${e}/config.js`),null}}async function C(n){const t=Object.entries(n);t.length!==0&&await Promise.allSettled(t.map(([e,r])=>f(e,r.remoteUrl)))}exports.deepClone=a.deepClone;exports.isEmpty=a.isEmpty;exports.isEmptyArray=a.isEmptyArray;exports.isNullOrUndefined=a.isNullOrUndefined;exports.isObject=a.isObject;exports.isToday=a.isToday;exports.getAllAppConfig=s.getAllAppConfig;exports.getAppConfig=s.getAppConfig;exports.formatCurrency=g;exports.formatDate=d;exports.formatNumber=m;exports.hexToRgb=l;exports.loadAllMicroUIConfigs=C;exports.loadMicroUIConfig=f;exports.rgbToHex=u;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { e as y, i as _, b as C, a as O, c as U, d as h } from "../helpers-CbBec0n2.js";
|
|
2
|
+
import { a as x, g as N } from "../appConfig-hHCWS_gL.js";
|
|
3
|
+
const l = (n) => {
|
|
4
|
+
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
5
|
+
n = n.replace(e, (r, a, o, i) => a + a + o + o + i + i);
|
|
6
|
+
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);
|
|
7
|
+
return t ? `${parseInt(t[1], 16)}, ${parseInt(t[2], 16)}, ${parseInt(t[3], 16)}` : null;
|
|
8
|
+
}, u = (n, e, t) => {
|
|
9
|
+
const r = (a) => {
|
|
10
|
+
const o = a.toString(16);
|
|
11
|
+
return o.length === 1 ? "0" + o : o;
|
|
12
|
+
};
|
|
13
|
+
return `#${r(n)}${r(e)}${r(t)}`;
|
|
14
|
+
}, d = (n, e = "en-US", t = {}) => {
|
|
15
|
+
const r = {
|
|
16
|
+
year: "numeric",
|
|
17
|
+
month: "short",
|
|
18
|
+
day: "numeric",
|
|
19
|
+
...t
|
|
20
|
+
};
|
|
21
|
+
return new Intl.DateTimeFormat(e, r).format(new Date(n));
|
|
22
|
+
}, m = (n, e = "USD", t = "en-US") => new Intl.NumberFormat(t, {
|
|
23
|
+
style: "currency",
|
|
24
|
+
currency: e
|
|
25
|
+
}).format(n), p = (n, e = "en-US", t = {}) => new Intl.NumberFormat(e, t).format(n);
|
|
26
|
+
typeof window < "u" && !window.__MICROUI_CONFIG__ && (window.__MICROUI_CONFIG__ = {});
|
|
27
|
+
function c(n) {
|
|
28
|
+
try {
|
|
29
|
+
return new URL(n).origin;
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function s(n) {
|
|
35
|
+
const e = n.indexOf("{"), t = n.lastIndexOf("}");
|
|
36
|
+
if (e === -1 || t === -1) return null;
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(n.slice(e, t + 1));
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function f(n, e) {
|
|
44
|
+
const t = c(e);
|
|
45
|
+
if (!t) return null;
|
|
46
|
+
try {
|
|
47
|
+
const r = await fetch(`${t}/config.js`, { cache: "no-cache" });
|
|
48
|
+
if (!r.ok) return null;
|
|
49
|
+
const a = await r.text(), o = s(a);
|
|
50
|
+
return o && typeof window < "u" && (window.__MICROUI_CONFIG__[n] = o), o;
|
|
51
|
+
} catch {
|
|
52
|
+
return console.warn(`[MicroUIConfig] Failed to load config for ${n} from ${t}/config.js`), null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function g(n) {
|
|
56
|
+
const e = Object.entries(n);
|
|
57
|
+
e.length !== 0 && await Promise.allSettled(
|
|
58
|
+
e.map(([t, r]) => f(t, r.remoteUrl))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
y as deepClone,
|
|
63
|
+
m as formatCurrency,
|
|
64
|
+
d as formatDate,
|
|
65
|
+
p as formatNumber,
|
|
66
|
+
x as getAllAppConfig,
|
|
67
|
+
N as getAppConfig,
|
|
68
|
+
l as hexToRgb,
|
|
69
|
+
_ as isEmpty,
|
|
70
|
+
C as isEmptyArray,
|
|
71
|
+
O as isNullOrUndefined,
|
|
72
|
+
U as isObject,
|
|
73
|
+
h as isToday,
|
|
74
|
+
g as loadAllMicroUIConfigs,
|
|
75
|
+
f as loadMicroUIConfig,
|
|
76
|
+
u as rgbToHex
|
|
77
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../helpers-Du3u7brS.cjs"),s=r=>i.isNullOrUndefined(r)||i.isEmptyArray(r)||r===!1?"Bu alan zorunludur":!!String(r).trim().length||"Bu alan zorunludur",o=r=>{if(i.isEmpty(r))return!0;const t=/^(?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*|".+")@(?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]|(?:[a-z\-\d]+\.)+[a-z]{2,})$/i;return Array.isArray(r)?r.every(e=>t.test(String(e)))||"Gecerli bir e-posta adresi girin":t.test(String(r))||"Gecerli bir e-posta adresi girin"},l=r=>/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%&*()]).{8,}/.test(r)||"Alan en az bir buyuk harf, kucuk harf, ozel karakter ve rakam icermeli ve en az 8 karakter uzunlugunda olmalidir",d=(r,t)=>r===t||"Sifreler eslesmedi",u=(r,t,e)=>{const a=Number(r);return Number(t)<=a&&Number(e)>=a||`${t} ve ${e} arasi bir deger girin`},g=r=>i.isEmpty(r)?!0:Array.isArray(r)?r.every(t=>/^-?\d+$/.test(String(t)))||"Bu alan tam sayi olmalidir":/^-?\d+$/.test(String(r))||"Bu alan tam sayi olmalidir",n=(r,t)=>{if(i.isEmpty(r))return!0;let e=t;return typeof e=="string"&&(e=new RegExp(e)),Array.isArray(r)?r.every(a=>n(a,e)):e.test(String(r))||"Gecersiz format"},c=r=>i.isEmpty(r)?!0:/^[A-Z]*$/i.test(String(r))||"Sadece harf karakterleri kullanilaabilir",m=r=>i.isEmpty(r)?!0:/^https?:\/\/[^\s$.?#].\S*$/.test(String(r))||"Gecersiz URL",y=(r,t)=>i.isEmpty(r)?!0:String(r).length===t||`Karakter uzunlugu ${t} karakter olmalidir`,f=r=>i.isEmpty(r)?!0:/^[\w-]*$/.test(String(r))||"Gecersiz karakter";exports.alphaDashValidator=f;exports.alphaValidator=c;exports.betweenValidator=u;exports.confirmedValidator=d;exports.emailValidator=o;exports.integerValidator=g;exports.lengthValidator=y;exports.passwordValidator=l;exports.regexValidator=n;exports.requiredValidator=s;exports.urlValidator=m;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { a as n, b as s, i } from "../helpers-CbBec0n2.js";
|
|
2
|
+
const d = (r) => n(r) || s(r) || r === !1 ? "Bu alan zorunludur" : !!String(r).trim().length || "Bu alan zorunludur", l = (r) => {
|
|
3
|
+
if (i(r)) return !0;
|
|
4
|
+
const t = /^(?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*|".+")@(?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]|(?:[a-z\-\d]+\.)+[a-z]{2,})$/i;
|
|
5
|
+
return Array.isArray(r) ? r.every((e) => t.test(String(e))) || "Gecerli bir e-posta adresi girin" : t.test(String(r)) || "Gecerli bir e-posta adresi girin";
|
|
6
|
+
}, c = (r) => /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%&*()]).{8,}/.test(r) || "Alan en az bir buyuk harf, kucuk harf, ozel karakter ve rakam icermeli ve en az 8 karakter uzunlugunda olmalidir", g = (r, t) => r === t || "Sifreler eslesmedi", f = (r, t, e) => {
|
|
7
|
+
const a = Number(r);
|
|
8
|
+
return Number(t) <= a && Number(e) >= a || `${t} ve ${e} arasi bir deger girin`;
|
|
9
|
+
}, m = (r) => i(r) ? !0 : Array.isArray(r) ? r.every((t) => /^-?\d+$/.test(String(t))) || "Bu alan tam sayi olmalidir" : /^-?\d+$/.test(String(r)) || "Bu alan tam sayi olmalidir", o = (r, t) => {
|
|
10
|
+
if (i(r)) return !0;
|
|
11
|
+
let e = t;
|
|
12
|
+
return typeof e == "string" && (e = new RegExp(e)), Array.isArray(r) ? r.every((a) => o(a, e)) : e.test(String(r)) || "Gecersiz format";
|
|
13
|
+
}, k = (r) => i(r) ? !0 : /^[A-Z]*$/i.test(String(r)) || "Sadece harf karakterleri kullanilaabilir", y = (r) => i(r) ? !0 : /^https?:\/\/[^\s$.?#].\S*$/.test(String(r)) || "Gecersiz URL", p = (r, t) => i(r) ? !0 : String(r).length === t || `Karakter uzunlugu ${t} karakter olmalidir`, z = (r) => i(r) ? !0 : /^[\w-]*$/.test(String(r)) || "Gecersiz karakter";
|
|
14
|
+
export {
|
|
15
|
+
z as alphaDashValidator,
|
|
16
|
+
k as alphaValidator,
|
|
17
|
+
f as betweenValidator,
|
|
18
|
+
g as confirmedValidator,
|
|
19
|
+
l as emailValidator,
|
|
20
|
+
m as integerValidator,
|
|
21
|
+
p as lengthValidator,
|
|
22
|
+
c as passwordValidator,
|
|
23
|
+
o as regexValidator,
|
|
24
|
+
d as requiredValidator,
|
|
25
|
+
y as urlValidator
|
|
26
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@delfinjs/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Framework-agnostic shared utilities, event bus, API client, auth helpers, validators, and types for Delfin micro-frontends",
|
|
7
|
+
"main": "./src/index.js",
|
|
8
|
+
"module": "./src/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.js",
|
|
11
|
+
"./utils": "./src/utils/index.js",
|
|
12
|
+
"./crypto": "./src/crypto/index.js",
|
|
13
|
+
"./eventBus": "./src/eventBus/index.js",
|
|
14
|
+
"./api": "./src/api/index.js",
|
|
15
|
+
"./auth": "./src/auth/index.js",
|
|
16
|
+
"./validators": "./src/validators/index.js",
|
|
17
|
+
"./types": "./src/types/index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "vite build",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"cookie-es": "^1.2.2",
|
|
29
|
+
"crypto-js": "^4.2.0",
|
|
30
|
+
"destr": "^2.0.5",
|
|
31
|
+
"ofetch": "^1.4.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"vite": "^6.3.5"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"delfin",
|
|
38
|
+
"shared",
|
|
39
|
+
"micro-frontend",
|
|
40
|
+
"utilities",
|
|
41
|
+
"event-bus",
|
|
42
|
+
"api-client"
|
|
43
|
+
],
|
|
44
|
+
"license": "UNLICENSED"
|
|
45
|
+
}
|