@tnf-dev/core 1.0.1-10
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 +1 -0
- package/dist/cjs/client/http.cjs +1 -0
- package/dist/cjs/client/http.d.cts +21 -0
- package/dist/cjs/client/index.cjs +1 -0
- package/dist/cjs/client/index.d.cts +2 -0
- package/dist/cjs/dto/base/index.cjs +1 -0
- package/dist/cjs/dto/base/index.d.cts +1 -0
- package/dist/cjs/dto/base/record.interface.cjs +1 -0
- package/dist/cjs/dto/base/record.interface.d.cts +6 -0
- package/dist/cjs/dto/index.cjs +1 -0
- package/dist/cjs/dto/index.d.cts +4 -0
- package/dist/cjs/dto/notifications/index.cjs +1 -0
- package/dist/cjs/dto/notifications/index.d.cts +2 -0
- package/dist/cjs/dto/notifications/notification.interface.cjs +1 -0
- package/dist/cjs/dto/notifications/notification.interface.d.cts +31 -0
- package/dist/cjs/dto/request/index.cjs +1 -0
- package/dist/cjs/dto/request/index.d.cts +1 -0
- package/dist/cjs/dto/request/request.interface.cjs +1 -0
- package/dist/cjs/dto/request/request.interface.d.cts +8 -0
- package/dist/cjs/dto/response/index.cjs +1 -0
- package/dist/cjs/dto/response/index.d.cts +1 -0
- package/dist/cjs/dto/response/response.interface.cjs +1 -0
- package/dist/cjs/dto/response/response.interface.d.cts +22 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.d.cts +5 -0
- package/dist/cjs/internal/index.cjs +1 -0
- package/dist/cjs/internal/index.d.cts +1 -0
- package/dist/cjs/internal/utils/index.cjs +1 -0
- package/dist/cjs/internal/utils/index.d.cts +1 -0
- package/dist/cjs/internal/utils/request.cjs +1 -0
- package/dist/cjs/internal/utils/request.d.cts +3 -0
- package/dist/esm/client/http.d.ts +21 -0
- package/dist/esm/client/http.js +1 -0
- package/dist/esm/client/index.d.ts +2 -0
- package/dist/esm/client/index.js +1 -0
- package/dist/esm/dto/base/index.d.ts +1 -0
- package/dist/esm/dto/base/index.js +0 -0
- package/dist/esm/dto/base/record.interface.d.ts +6 -0
- package/dist/esm/dto/base/record.interface.js +0 -0
- package/dist/esm/dto/index.d.ts +4 -0
- package/dist/esm/dto/index.js +0 -0
- package/dist/esm/dto/notifications/index.d.ts +2 -0
- package/dist/esm/dto/notifications/index.js +0 -0
- package/dist/esm/dto/notifications/notification.interface.d.ts +31 -0
- package/dist/esm/dto/notifications/notification.interface.js +0 -0
- package/dist/esm/dto/request/index.d.ts +1 -0
- package/dist/esm/dto/request/index.js +0 -0
- package/dist/esm/dto/request/request.interface.d.ts +8 -0
- package/dist/esm/dto/request/request.interface.js +0 -0
- package/dist/esm/dto/response/index.d.ts +1 -0
- package/dist/esm/dto/response/index.js +0 -0
- package/dist/esm/dto/response/response.interface.d.ts +22 -0
- package/dist/esm/dto/response/response.interface.js +0 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/internal/index.d.ts +1 -0
- package/dist/esm/internal/index.js +1 -0
- package/dist/esm/internal/utils/index.d.ts +1 -0
- package/dist/esm/internal/utils/index.js +1 -0
- package/dist/esm/internal/utils/request.d.ts +3 -0
- package/dist/esm/internal/utils/request.js +1 -0
- package/package.json +48 -0
package/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# @tnf-dev/core
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var R=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var T=s=>{throw TypeError(s)};var P=(s,t)=>{for(var e in t)R(s,e,{get:t[e],enumerable:!0})},f=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of $(t))!q.call(s,r)&&r!==e&&R(s,r,{get:()=>t[r],enumerable:!(n=l(t,r))||n.enumerable});return s};var w=s=>f(R({},"__esModule",{value:!0}),s);var c=(s,t,e)=>t.has(s)||T("Cannot "+e);var a=(s,t,e)=>(c(s,t,"read from private field"),e?e.call(s):t.get(s)),g=(s,t,e)=>t.has(s)?T("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),m=(s,t,e,n)=>(c(s,t,"write to private field"),n?n.call(s,e):t.set(s,e),e),p=(s,t,e)=>(c(s,t,"access private method"),e);var U={};P(U,{HttpClient:()=>h});module.exports=w(U);var y=s=>new URLSearchParams(Object.keys(s).reduce((t,e)=>(s[e]!==void 0&&(t[e]=`${s[e]}`),t),{})).toString();var i,o,O,d,h=class{constructor(t){g(this,o);g(this,i);m(this,i,t.baseUrl)}get baseUrl(){return a(this,i)}get(t,e){return p(this,o,d).call(this,`${a(this,i)}${t}`,e)}post(t,e,n){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...n,method:"POST",body:e})}put(t,e,n){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...n,method:"PUT",body:e})}patch(t,e,n={}){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...n,method:"PATCH",body:e})}delete(t,e){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...e,method:"DELETE"})}};i=new WeakMap,o=new WeakSet,O=async function(t,{body:e,params:n,...r}={}){let u=t;n&&(u=`${t}?${y(n||{})}`);let b={...r,...e?{body:JSON.stringify(e)}:{},headers:{"Content-Type":"application/json",...r.headers}};return[u,b]},d=async function(t,e){let[n,r]=await p(this,o,O).call(this,t,e),u=await fetch(n,r);if(!u.ok)throw await u.json();return await u.json()};0&&(module.exports={HttpClient});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { BaseResponse } from '../dto/response/response.interface.cjs';
|
2
|
+
|
3
|
+
interface HttpClientOptions {
|
4
|
+
baseUrl: string;
|
5
|
+
}
|
6
|
+
interface RequestOptions extends Omit<RequestInit, 'body'> {
|
7
|
+
body?: Record<string, any>;
|
8
|
+
params?: Record<string, any>;
|
9
|
+
}
|
10
|
+
declare class HttpClient {
|
11
|
+
#private;
|
12
|
+
constructor(options: HttpClientOptions);
|
13
|
+
get baseUrl(): string;
|
14
|
+
get<T = BaseResponse>(url: string, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
15
|
+
post<T = BaseResponse>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
16
|
+
put<T = BaseResponse>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
17
|
+
patch<T = BaseResponse>(url: string, data?: Record<string, any>, options?: RequestInit): Promise<T>;
|
18
|
+
delete<T = BaseResponse>(url: string, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
19
|
+
}
|
20
|
+
|
21
|
+
export { HttpClient, type HttpClientOptions, type RequestOptions };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var R=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var T=s=>{throw TypeError(s)};var f=(s,t)=>{for(var e in t)R(s,e,{get:t[e],enumerable:!0})},P=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of $(t))!q.call(s,r)&&r!==e&&R(s,r,{get:()=>t[r],enumerable:!(n=l(t,r))||n.enumerable});return s};var w=s=>P(R({},"__esModule",{value:!0}),s);var c=(s,t,e)=>t.has(s)||T("Cannot "+e);var a=(s,t,e)=>(c(s,t,"read from private field"),e?e.call(s):t.get(s)),g=(s,t,e)=>t.has(s)?T("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),m=(s,t,e,n)=>(c(s,t,"write to private field"),n?n.call(s,e):t.set(s,e),e),p=(s,t,e)=>(c(s,t,"access private method"),e);var U={};f(U,{HttpClient:()=>h});module.exports=w(U);var y=s=>new URLSearchParams(Object.keys(s).reduce((t,e)=>(s[e]!==void 0&&(t[e]=`${s[e]}`),t),{})).toString();var i,o,O,d,h=class{constructor(t){g(this,o);g(this,i);m(this,i,t.baseUrl)}get baseUrl(){return a(this,i)}get(t,e){return p(this,o,d).call(this,`${a(this,i)}${t}`,e)}post(t,e,n){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...n,method:"POST",body:e})}put(t,e,n){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...n,method:"PUT",body:e})}patch(t,e,n={}){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...n,method:"PATCH",body:e})}delete(t,e){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...e,method:"DELETE"})}};i=new WeakMap,o=new WeakSet,O=async function(t,{body:e,params:n,...r}={}){let u=t;n&&(u=`${t}?${y(n||{})}`);let b={...r,...e?{body:JSON.stringify(e)}:{},headers:{"Content-Type":"application/json",...r.headers}};return[u,b]},d=async function(t,e){let[n,r]=await p(this,o,O).call(this,t,e),u=await fetch(n,r);if(!u.ok)throw await u.json();return await u.json()};0&&(module.exports={HttpClient});
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
@@ -0,0 +1 @@
|
|
1
|
+
export { BaseRecord } from './record.interface.cjs';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var d=(i,e,a,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of o(e))!s.call(i,r)&&r!==a&&n(i,r,{get:()=>e[r],enumerable:!(t=c(e,r))||t.enumerable});return i};var g=i=>d(n({},"__esModule",{value:!0}),i);var _={};module.exports=g(_);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export { Notification, NotificationAction, NotificationData, NotificationPayload, NotificationPrimaryAction, NotificationSecondaryAction } from './notifications/notification.interface.cjs';
|
2
|
+
export { PaginationRequest } from './request/request.interface.cjs';
|
3
|
+
export { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse } from './response/response.interface.cjs';
|
4
|
+
import './base/record.interface.cjs';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var e=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var f=(i,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of c(t))!s.call(i,o)&&o!==n&&e(i,o,{get:()=>t[o],enumerable:!(a=r(t,o))||a.enumerable});return i};var d=i=>f(e({},"__esModule",{value:!0}),i);var y={};module.exports=d(y);
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { BaseRecord } from '../base/record.interface.cjs';
|
2
|
+
|
3
|
+
interface NotificationAction {
|
4
|
+
type: 'primary' | 'secondary';
|
5
|
+
label: string;
|
6
|
+
href: string;
|
7
|
+
target?: '_blank' | '_self';
|
8
|
+
rel?: string;
|
9
|
+
}
|
10
|
+
interface NotificationPrimaryAction extends NotificationAction {
|
11
|
+
type: 'primary';
|
12
|
+
}
|
13
|
+
interface NotificationSecondaryAction extends NotificationAction {
|
14
|
+
type: 'secondary';
|
15
|
+
}
|
16
|
+
interface NotificationPayload extends Record<string, any> {
|
17
|
+
}
|
18
|
+
interface NotificationData extends Record<string, any> {
|
19
|
+
}
|
20
|
+
interface Notification extends BaseRecord {
|
21
|
+
title: string;
|
22
|
+
message: string;
|
23
|
+
isRead: boolean;
|
24
|
+
icon?: string;
|
25
|
+
primary_action?: NotificationPrimaryAction;
|
26
|
+
secondary_action?: NotificationSecondaryAction;
|
27
|
+
payload?: NotificationPayload;
|
28
|
+
data?: NotificationData;
|
29
|
+
}
|
30
|
+
|
31
|
+
export type { Notification, NotificationAction, NotificationData, NotificationPayload, NotificationPrimaryAction, NotificationSecondaryAction };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
@@ -0,0 +1 @@
|
|
1
|
+
export { PaginationRequest } from './request.interface.cjs';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var b=(n,e,m,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of a(e))!s.call(n,r)&&r!==m&&i(n,r,{get:()=>e[r],enumerable:!(t=u(e,r))||t.enumerable});return n};var g=n=>b(i({},"__esModule",{value:!0}),n);var o={};module.exports=g(o);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
@@ -0,0 +1 @@
|
|
1
|
+
export { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse } from './response.interface.cjs';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var t=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var g=(r,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of i(e))!p.call(r,s)&&s!==o&&t(r,s,{get:()=>e[s],enumerable:!(n=a(e,s))||n.enumerable});return r};var c=r=>g(t({},"__esModule",{value:!0}),r);var u={};module.exports=c(u);
|
@@ -0,0 +1,22 @@
|
|
1
|
+
interface BaseResponse<T = unknown> {
|
2
|
+
status: 'success' | 'error';
|
3
|
+
data: T;
|
4
|
+
error_message?: string;
|
5
|
+
error_code?: string;
|
6
|
+
}
|
7
|
+
interface PaginatedResponse<T> extends BaseResponse<T[]> {
|
8
|
+
pagination: {
|
9
|
+
continueCursor?: string;
|
10
|
+
total: number;
|
11
|
+
page?: number;
|
12
|
+
limit?: number;
|
13
|
+
};
|
14
|
+
}
|
15
|
+
interface SingleResponse<T> extends BaseResponse<T> {
|
16
|
+
}
|
17
|
+
interface ErrorResponse extends BaseResponse<null> {
|
18
|
+
error_message: string;
|
19
|
+
error_code: string;
|
20
|
+
}
|
21
|
+
|
22
|
+
export type { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var R=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var T=s=>{throw TypeError(s)};var q=(s,t)=>{for(var e in t)R(s,e,{get:t[e],enumerable:!0})},P=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $(t))!f.call(s,n)&&n!==e&&R(s,n,{get:()=>t[n],enumerable:!(r=l(t,n))||r.enumerable});return s};var w=s=>P(R({},"__esModule",{value:!0}),s);var c=(s,t,e)=>t.has(s)||T("Cannot "+e);var a=(s,t,e)=>(c(s,t,"read from private field"),e?e.call(s):t.get(s)),g=(s,t,e)=>t.has(s)?T("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),m=(s,t,e,r)=>(c(s,t,"write to private field"),r?r.call(s,e):t.set(s,e),e),p=(s,t,e)=>(c(s,t,"access private method"),e);var U={};q(U,{HttpClient:()=>h});module.exports=w(U);var y=s=>new URLSearchParams(Object.keys(s).reduce((t,e)=>(s[e]!==void 0&&(t[e]=`${s[e]}`),t),{})).toString();var i,o,O,d,h=class{constructor(t){g(this,o);g(this,i);m(this,i,t.baseUrl)}get baseUrl(){return a(this,i)}get(t,e){return p(this,o,d).call(this,`${a(this,i)}${t}`,e)}post(t,e,r){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...r,method:"POST",body:e})}put(t,e,r){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...r,method:"PUT",body:e})}patch(t,e,r={}){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...r,method:"PATCH",body:e})}delete(t,e){return p(this,o,d).call(this,`${a(this,i)}${t}`,{...e,method:"DELETE"})}};i=new WeakMap,o=new WeakSet,O=async function(t,{body:e,params:r,...n}={}){let u=t;r&&(u=`${t}?${y(r||{})}`);let b={...n,...e?{body:JSON.stringify(e)}:{},headers:{"Content-Type":"application/json",...n.headers}};return[u,b]},d=async function(t,e){let[r,n]=await p(this,o,O).call(this,t,e),u=await fetch(r,n);if(!u.ok)throw await u.json();return await u.json()};0&&(module.exports={HttpClient});
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { HttpClient, HttpClientOptions, RequestOptions } from './client/http.cjs';
|
2
|
+
export { Notification, NotificationAction, NotificationData, NotificationPayload, NotificationPrimaryAction, NotificationSecondaryAction } from './dto/notifications/notification.interface.cjs';
|
3
|
+
export { PaginationRequest } from './dto/request/request.interface.cjs';
|
4
|
+
export { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse } from './dto/response/response.interface.cjs';
|
5
|
+
import './dto/base/record.interface.cjs';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var n in r)o(e,n,{get:r[n],enumerable:!0})},c=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!g.call(e,t)&&t!==n&&o(e,t,{get:()=>r[t],enumerable:!(i=s(r,t))||i.enumerable});return e};var a=e=>c(o({},"__esModule",{value:!0}),e);var R={};u(R,{paramsToQueryString:()=>f});module.exports=a(R);var f=e=>new URLSearchParams(Object.keys(e).reduce((r,n)=>(e[n]!==void 0&&(r[n]=`${e[n]}`),r),{})).toString();0&&(module.exports={paramsToQueryString});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { paramsToQueryString } from './utils/request.cjs';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var n in r)o(e,n,{get:r[n],enumerable:!0})},c=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!g.call(e,t)&&t!==n&&o(e,t,{get:()=>r[t],enumerable:!(i=s(r,t))||i.enumerable});return e};var a=e=>c(o({},"__esModule",{value:!0}),e);var R={};u(R,{paramsToQueryString:()=>f});module.exports=a(R);var f=e=>new URLSearchParams(Object.keys(e).reduce((r,n)=>(e[n]!==void 0&&(r[n]=`${e[n]}`),r),{})).toString();0&&(module.exports={paramsToQueryString});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { paramsToQueryString } from './request.cjs';
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var u=(n,r)=>{for(var e in r)i(n,e,{get:r[e],enumerable:!0})},c=(n,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!g.call(n,t)&&t!==e&&i(n,t,{get:()=>r[t],enumerable:!(o=s(r,t))||o.enumerable});return n};var a=n=>c(i({},"__esModule",{value:!0}),n);var S={};u(S,{paramsToQueryString:()=>R});module.exports=a(S);var R=n=>new URLSearchParams(Object.keys(n).reduce((r,e)=>(n[e]!==void 0&&(r[e]=`${n[e]}`),r),{})).toString();0&&(module.exports={paramsToQueryString});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { BaseResponse } from '../dto/response/response.interface.js';
|
2
|
+
|
3
|
+
interface HttpClientOptions {
|
4
|
+
baseUrl: string;
|
5
|
+
}
|
6
|
+
interface RequestOptions extends Omit<RequestInit, 'body'> {
|
7
|
+
body?: Record<string, any>;
|
8
|
+
params?: Record<string, any>;
|
9
|
+
}
|
10
|
+
declare class HttpClient {
|
11
|
+
#private;
|
12
|
+
constructor(options: HttpClientOptions);
|
13
|
+
get baseUrl(): string;
|
14
|
+
get<T = BaseResponse>(url: string, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
15
|
+
post<T = BaseResponse>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
16
|
+
put<T = BaseResponse>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
17
|
+
patch<T = BaseResponse>(url: string, data?: Record<string, any>, options?: RequestInit): Promise<T>;
|
18
|
+
delete<T = BaseResponse>(url: string, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
19
|
+
}
|
20
|
+
|
21
|
+
export { HttpClient, type HttpClientOptions, type RequestOptions };
|
@@ -0,0 +1 @@
|
|
1
|
+
var o=r=>new URLSearchParams(Object.keys(r).reduce((t,e)=>(r[e]!==void 0&&(t[e]=`${r[e]}`),t),{})).toString();var a=class{#t;constructor(t){this.#t=t.baseUrl}get baseUrl(){return this.#t}async#s(t,{body:e,params:s,...i}={}){let n=t;s&&(n=`${t}?${o(s||{})}`);let p={...i,...e?{body:JSON.stringify(e)}:{},headers:{"Content-Type":"application/json",...i.headers}};return[n,p]}async#e(t,e){let[s,i]=await this.#s(t,e),n=await fetch(s,i);if(!n.ok)throw await n.json();return await n.json()}get(t,e){return this.#e(`${this.#t}${t}`,e)}post(t,e,s){return this.#e(`${this.#t}${t}`,{...s,method:"POST",body:e})}put(t,e,s){return this.#e(`${this.#t}${t}`,{...s,method:"PUT",body:e})}patch(t,e,s={}){return this.#e(`${this.#t}${t}`,{...s,method:"PATCH",body:e})}delete(t,e){return this.#e(`${this.#t}${t}`,{...e,method:"DELETE"})}};export{a as HttpClient};
|
@@ -0,0 +1 @@
|
|
1
|
+
var o=r=>new URLSearchParams(Object.keys(r).reduce((t,e)=>(r[e]!==void 0&&(t[e]=`${r[e]}`),t),{})).toString();var a=class{#t;constructor(t){this.#t=t.baseUrl}get baseUrl(){return this.#t}async#s(t,{body:e,params:s,...i}={}){let n=t;s&&(n=`${t}?${o(s||{})}`);let p={...i,...e?{body:JSON.stringify(e)}:{},headers:{"Content-Type":"application/json",...i.headers}};return[n,p]}async#e(t,e){let[s,i]=await this.#s(t,e),n=await fetch(s,i);if(!n.ok)throw await n.json();return await n.json()}get(t,e){return this.#e(`${this.#t}${t}`,e)}post(t,e,s){return this.#e(`${this.#t}${t}`,{...s,method:"POST",body:e})}put(t,e,s){return this.#e(`${this.#t}${t}`,{...s,method:"PUT",body:e})}patch(t,e,s={}){return this.#e(`${this.#t}${t}`,{...s,method:"PATCH",body:e})}delete(t,e){return this.#e(`${this.#t}${t}`,{...e,method:"DELETE"})}};export{a as HttpClient};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { BaseRecord } from './record.interface.js';
|
File without changes
|
File without changes
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export { Notification, NotificationAction, NotificationData, NotificationPayload, NotificationPrimaryAction, NotificationSecondaryAction } from './notifications/notification.interface.js';
|
2
|
+
export { PaginationRequest } from './request/request.interface.js';
|
3
|
+
export { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse } from './response/response.interface.js';
|
4
|
+
import './base/record.interface.js';
|
File without changes
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { BaseRecord } from '../base/record.interface.js';
|
2
|
+
|
3
|
+
interface NotificationAction {
|
4
|
+
type: 'primary' | 'secondary';
|
5
|
+
label: string;
|
6
|
+
href: string;
|
7
|
+
target?: '_blank' | '_self';
|
8
|
+
rel?: string;
|
9
|
+
}
|
10
|
+
interface NotificationPrimaryAction extends NotificationAction {
|
11
|
+
type: 'primary';
|
12
|
+
}
|
13
|
+
interface NotificationSecondaryAction extends NotificationAction {
|
14
|
+
type: 'secondary';
|
15
|
+
}
|
16
|
+
interface NotificationPayload extends Record<string, any> {
|
17
|
+
}
|
18
|
+
interface NotificationData extends Record<string, any> {
|
19
|
+
}
|
20
|
+
interface Notification extends BaseRecord {
|
21
|
+
title: string;
|
22
|
+
message: string;
|
23
|
+
isRead: boolean;
|
24
|
+
icon?: string;
|
25
|
+
primary_action?: NotificationPrimaryAction;
|
26
|
+
secondary_action?: NotificationSecondaryAction;
|
27
|
+
payload?: NotificationPayload;
|
28
|
+
data?: NotificationData;
|
29
|
+
}
|
30
|
+
|
31
|
+
export type { Notification, NotificationAction, NotificationData, NotificationPayload, NotificationPrimaryAction, NotificationSecondaryAction };
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
export { PaginationRequest } from './request.interface.js';
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
export { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse } from './response.interface.js';
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
interface BaseResponse<T = unknown> {
|
2
|
+
status: 'success' | 'error';
|
3
|
+
data: T;
|
4
|
+
error_message?: string;
|
5
|
+
error_code?: string;
|
6
|
+
}
|
7
|
+
interface PaginatedResponse<T> extends BaseResponse<T[]> {
|
8
|
+
pagination: {
|
9
|
+
continueCursor?: string;
|
10
|
+
total: number;
|
11
|
+
page?: number;
|
12
|
+
limit?: number;
|
13
|
+
};
|
14
|
+
}
|
15
|
+
interface SingleResponse<T> extends BaseResponse<T> {
|
16
|
+
}
|
17
|
+
interface ErrorResponse extends BaseResponse<null> {
|
18
|
+
error_message: string;
|
19
|
+
error_code: string;
|
20
|
+
}
|
21
|
+
|
22
|
+
export type { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse };
|
File without changes
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { HttpClient, HttpClientOptions, RequestOptions } from './client/http.js';
|
2
|
+
export { Notification, NotificationAction, NotificationData, NotificationPayload, NotificationPrimaryAction, NotificationSecondaryAction } from './dto/notifications/notification.interface.js';
|
3
|
+
export { PaginationRequest } from './dto/request/request.interface.js';
|
4
|
+
export { BaseResponse, ErrorResponse, PaginatedResponse, SingleResponse } from './dto/response/response.interface.js';
|
5
|
+
import './dto/base/record.interface.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
var o=n=>new URLSearchParams(Object.keys(n).reduce((t,e)=>(n[e]!==void 0&&(t[e]=`${n[e]}`),t),{})).toString();var a=class{#t;constructor(t){this.#t=t.baseUrl}get baseUrl(){return this.#t}async#s(t,{body:e,params:s,...i}={}){let r=t;s&&(r=`${t}?${o(s||{})}`);let p={...i,...e?{body:JSON.stringify(e)}:{},headers:{"Content-Type":"application/json",...i.headers}};return[r,p]}async#e(t,e){let[s,i]=await this.#s(t,e),r=await fetch(s,i);if(!r.ok)throw await r.json();return await r.json()}get(t,e){return this.#e(`${this.#t}${t}`,e)}post(t,e,s){return this.#e(`${this.#t}${t}`,{...s,method:"POST",body:e})}put(t,e,s){return this.#e(`${this.#t}${t}`,{...s,method:"PUT",body:e})}patch(t,e,s={}){return this.#e(`${this.#t}${t}`,{...s,method:"PATCH",body:e})}delete(t,e){return this.#e(`${this.#t}${t}`,{...e,method:"DELETE"})}};export{a as HttpClient};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { paramsToQueryString } from './utils/request.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
var t=r=>new URLSearchParams(Object.keys(r).reduce((n,e)=>(r[e]!==void 0&&(n[e]=`${r[e]}`),n),{})).toString();export{t as paramsToQueryString};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { paramsToQueryString } from './request.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
var t=r=>new URLSearchParams(Object.keys(r).reduce((n,e)=>(r[e]!==void 0&&(n[e]=`${r[e]}`),n),{})).toString();export{t as paramsToQueryString};
|
@@ -0,0 +1 @@
|
|
1
|
+
var t=r=>new URLSearchParams(Object.keys(r).reduce((e,n)=>(r[n]!==void 0&&(e[n]=`${r[n]}`),e),{})).toString();export{t as paramsToQueryString};
|
package/package.json
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
{
|
2
|
+
"browser": "./dist/esm/index.js",
|
3
|
+
"devDependencies": {
|
4
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
5
|
+
"tsup": "^8.5.0",
|
6
|
+
"typescript": "^5.8.3"
|
7
|
+
},
|
8
|
+
"exports": {
|
9
|
+
".": {
|
10
|
+
"browser": {
|
11
|
+
"default": "./dist/esm/index.js",
|
12
|
+
"types": "./dist/esm/index.d.ts"
|
13
|
+
},
|
14
|
+
"import": {
|
15
|
+
"default": "./dist/esm/index.js",
|
16
|
+
"types": "./dist/esm/index.d.ts"
|
17
|
+
},
|
18
|
+
"require": {
|
19
|
+
"default": "./dist/cjs/index.cjs",
|
20
|
+
"types": "./dist/cjs/index.d.cts"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"files": [
|
25
|
+
"dist"
|
26
|
+
],
|
27
|
+
"license": "MIT",
|
28
|
+
"main": "./dist/cjs/index.cjs",
|
29
|
+
"name": "@tnf-dev/core",
|
30
|
+
"private": false,
|
31
|
+
"publishConfig": {
|
32
|
+
"access": "public"
|
33
|
+
},
|
34
|
+
"repository": {
|
35
|
+
"directory": "packages/core",
|
36
|
+
"type": "git",
|
37
|
+
"url": "git+https://github.com/teknix-saas/teknify-sdk"
|
38
|
+
},
|
39
|
+
"scripts": {
|
40
|
+
"build": "NODE_ENV=production tsup && npm run check-exports",
|
41
|
+
"check-exports": "attw --pack .",
|
42
|
+
"dev": "tsup --watch"
|
43
|
+
},
|
44
|
+
"sideEffects": false,
|
45
|
+
"type": "module",
|
46
|
+
"types": "./dist/esm/index.d.ts",
|
47
|
+
"version": "1.0.1-10"
|
48
|
+
}
|