@tagsamurai/gsts-api-services 1.0.1-alpha.1

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 './main'
2
+ export {}
@@ -0,0 +1,49 @@
1
+ import p from "axios";
2
+ const P = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_APP_GLOBAL_SETTINGS_API: "https://dev-api.global-settings.tagsamurai.com" }, c = (e = "APP_API") => P["VITE_" + e], g = (e = {}, s = !1) => {
3
+ const { env: t = "APP_API", prefix: o = "", headers: r = {}, ...n } = e, l = `${c(t)}${o}`, i = JSON.parse(localStorage.getItem("user") ?? "{}"), f = i.jwt ?? i.token ?? "";
4
+ return p.create({
5
+ ...n,
6
+ baseURL: l,
7
+ headers: s ? r : {
8
+ "Content-Type": "application/json",
9
+ Authorization: `Bearer ${f}`,
10
+ ...r
11
+ }
12
+ });
13
+ }, S = (e) => {
14
+ if (!e || typeof e == "string")
15
+ return;
16
+ const s = {};
17
+ return Object.keys(e).forEach((t) => {
18
+ Array.isArray(e[t]) ? e[t].length > 0 && Object.assign(s, {
19
+ [t]: JSON.stringify(e[t])
20
+ }) : e[t] !== void 0 && Object.assign(s, {
21
+ [t]: e[t]
22
+ });
23
+ }), s;
24
+ }, u = (e, s, t) => {
25
+ if (!e) return;
26
+ const o = c("APP_UTILITY_API"), r = e.startsWith("http") ? e : `${o}/files/${e.replace(/^\/+/, "")}`;
27
+ if (s || t) {
28
+ const n = new URLSearchParams();
29
+ return s && n.set("width", s.toString()), t && n.set("height", (t == null ? void 0 : t.toString()) ?? s.toString()), `${r}?${n.toString()}`;
30
+ }
31
+ return r;
32
+ }, _ = g({
33
+ env: "APP_GLOBAL_SETTINGS_API",
34
+ prefix: "/v1/global-settings/user"
35
+ }), I = {
36
+ postResendUserEmail: (e) => _.post("/resend-email", e)
37
+ }, a = g({
38
+ prefix: "/utility/change-log"
39
+ }), L = {
40
+ getChangelogs: (e) => a.get("", { params: e }),
41
+ getChangelogOptions: (e) => a.get("/options", { params: e })
42
+ };
43
+ export {
44
+ L as ChangelogServices,
45
+ I as SettingUserGlobalServices,
46
+ c as getBaseURL,
47
+ u as getImageURL,
48
+ S as queryParamsStringfy
49
+ };
@@ -0,0 +1 @@
1
+ System.register(["axios"],function(r,A){"use strict";var c;return{setters:[i=>{c=i.default}],execute:function(){const i={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_GLOBAL_SETTINGS_API:"https://dev-api.global-settings.tagsamurai.com"},g=r("getBaseURL",(e="APP_API")=>i["VITE_"+e]),l=(e={},s=!1)=>{const{env:t="APP_API",prefix:a="",headers:n={},...o}=e,P=`${g(t)}${a}`,f=JSON.parse(localStorage.getItem("user")??"{}"),_=f.jwt??f.token??"";return c.create({...o,baseURL:P,headers:s?n:{"Content-Type":"application/json",Authorization:`Bearer ${_}`,...n}})},I=r("queryParamsStringfy",e=>{if(!e||typeof e=="string")return;const s={};return Object.keys(e).forEach(t=>{Array.isArray(e[t])?e[t].length>0&&Object.assign(s,{[t]:JSON.stringify(e[t])}):e[t]!==void 0&&Object.assign(s,{[t]:e[t]})}),s}),p=r("getImageURL",(e,s,t)=>{if(!e)return;const a=g("APP_UTILITY_API"),n=e.startsWith("http")?e:`${a}/files/${e.replace(/^\/+/,"")}`;if(s||t){const o=new URLSearchParams;return s&&o.set("width",s.toString()),t&&o.set("height",(t==null?void 0:t.toString())??s.toString()),`${n}?${o.toString()}`}return n}),S=l({env:"APP_GLOBAL_SETTINGS_API",prefix:"/v1/global-settings/user"}),L=r("SettingUserGlobalServices",{postResendUserEmail:e=>S.post("/resend-email",e)}),u=l({prefix:"/utility/change-log"}),v=r("ChangelogServices",{getChangelogs:e=>u.get("",{params:e}),getChangelogOptions:e=>u.get("/options",{params:e})})}}});
package/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { default as SettingUserGlobalServices } from './src/services/settingUserGlobal.service';
2
+ export { default as ChangelogServices } from './src/services/changelog.service';
3
+ export { getImageURL, getBaseURL, queryParamsStringfy } from './src/utils';
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@tagsamurai/gsts-api-services",
3
+ "version": "1.0.1-alpha.1",
4
+ "author": "developer.tagsamurai",
5
+ "description": "Global Settings Tag Samurai Services Library",
6
+ "module": "./api-services.es.js",
7
+ "types": "./main.d.ts",
8
+ "exports": {
9
+ ".": "./api-services.es.js",
10
+ "./src": "./src"
11
+ }
12
+ }
@@ -0,0 +1,21 @@
1
+ import { ChangelogOptionFilter, ChangelogType } from '../types/changelog.type';
2
+ import { FetchListResponse, FetchOptionResponse } from '../types/fetchResponse.type';
3
+ export type ChangelogResponse = FetchListResponse<ChangelogType>;
4
+ export type ChangelogOptionResponse = FetchOptionResponse<ChangelogOptionFilter>;
5
+ export type ChangelogFilterQuery = {
6
+ object?: string;
7
+ objectName?: string;
8
+ field?: string;
9
+ action?: string;
10
+ modifiedBy?: string;
11
+ createdAt?: string;
12
+ userId?: string;
13
+ modifiedById?: string;
14
+ };
15
+ export type ChangelogOptionQuery = {
16
+ actionOptions?: boolean;
17
+ modifiedByOptions?: boolean;
18
+ fieldOptions?: boolean;
19
+ objectNameOptions?: boolean;
20
+ object?: string;
21
+ };
@@ -0,0 +1,7 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ChangelogFilterQuery, ChangelogOptionQuery, ChangelogOptionResponse, ChangelogResponse } from '../dto/changelog.dto';
3
+ declare const ChangelogServices: {
4
+ getChangelogs: (params?: ChangelogFilterQuery) => Promise<AxiosResponse<ChangelogResponse>>;
5
+ getChangelogOptions: (params?: ChangelogOptionQuery) => Promise<AxiosResponse<ChangelogOptionResponse>>;
6
+ };
7
+ export default ChangelogServices;
@@ -0,0 +1,7 @@
1
+ import { AxiosResponse } from 'axios';
2
+ declare const SettingUserGlobalServices: {
3
+ postResendUserEmail: (body: {
4
+ email: string[];
5
+ }) => Promise<AxiosResponse>;
6
+ };
7
+ export default SettingUserGlobalServices;
@@ -0,0 +1,21 @@
1
+ import { MultiSelectOption } from './options.type';
2
+ export type ChangelogType = {
3
+ _id: string;
4
+ action: string;
5
+ field: string;
6
+ oldValue?: string;
7
+ newValue?: string;
8
+ modifiedBy?: string;
9
+ modifiedById?: string;
10
+ object: string;
11
+ objectId: string;
12
+ objectName: string;
13
+ createdAt: string;
14
+ updatedAt: string;
15
+ };
16
+ export type ChangelogOptionFilter = {
17
+ actionOptions?: MultiSelectOption[];
18
+ modifiedByOptions?: MultiSelectOption[];
19
+ fieldOptions?: MultiSelectOption[];
20
+ objectNameOptions?: MultiSelectOption[];
21
+ };
@@ -0,0 +1,5 @@
1
+ export type ChildGroup = {
2
+ groupHeader: string;
3
+ groupItems: Data[];
4
+ };
5
+ export type Data = Record<string, unknown>;
@@ -0,0 +1,36 @@
1
+ import { Data } from './dataTable.type';
2
+ import { MultiSelectOption } from './options.type';
3
+ export type FetchListResponse<T = Data> = {
4
+ status: number;
5
+ message: string;
6
+ data: {
7
+ data: T[];
8
+ totalRecords: number;
9
+ };
10
+ };
11
+ export type ShortFetchListResponse<T = Data> = {
12
+ status: number;
13
+ message: string;
14
+ data: T[];
15
+ };
16
+ export type FetchDetailResponse<T = Data> = {
17
+ status: number;
18
+ message: string;
19
+ data: T;
20
+ };
21
+ export type FetchResponse = {
22
+ status: number;
23
+ message: string;
24
+ };
25
+ export type FilterOptions<Opt = Record<string, boolean>> = Record<keyof Opt, MultiSelectOption[]>;
26
+ export type FetchOptionResponse<Opt = Record<string, boolean>> = {
27
+ message: string;
28
+ data: FilterOptions<Opt>;
29
+ };
30
+ export type StatusMessageResponse = {
31
+ status: number;
32
+ message: string;
33
+ };
34
+ export type QueryParams = {
35
+ [key: string]: string | number | boolean | string[] | number[] | boolean[] | Date | undefined | null;
36
+ };
@@ -0,0 +1,13 @@
1
+ export type OptionValue = string | number | boolean | Record<string, unknown>;
2
+ export type DropdownOption = {
3
+ label: string;
4
+ value?: OptionValue;
5
+ visible?: boolean;
6
+ icon?: string;
7
+ };
8
+ export type MultiSelectOption = {
9
+ label: string;
10
+ value?: OptionValue;
11
+ visible?: boolean;
12
+ icon?: string;
13
+ };
@@ -0,0 +1,19 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from 'axios';
2
+ export interface APIRequestConfig extends Omit<AxiosRequestConfig, 'env'> {
3
+ /**
4
+ * Retrieves the base URL from environment variables.
5
+ *
6
+ * @param env - The environment variable name.
7
+ * @default 'APP_EXAMPLE_API'
8
+ */
9
+ env?: string;
10
+ /**
11
+ * The endpoint prefix that appears on every endpoint.
12
+ * This could include API base paths or versioning groups for endpoints.
13
+ * Prefixes must include leading forward slashes.
14
+ *
15
+ * @example '/api', '/v2'
16
+ */
17
+ prefix?: string;
18
+ }
19
+ export declare const createAxiosInstance: (config?: APIRequestConfig, useDifferentHeaders?: boolean) => AxiosInstance;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Retrieves the base URL from environment variables.
3
+ *
4
+ * @param {string} [env='APP_API'] - The environment variable name without the platform prefix.
5
+ * @returns The base URL for the specified environment.
6
+ * @example 'APP_EXAMPLE_API'
7
+ */
8
+ export declare const getBaseURL: (env?: string) => string | undefined;
@@ -0,0 +1 @@
1
+ export declare const getImageURL: (name?: string | null, width?: number, height?: number) => string | undefined;
@@ -0,0 +1,4 @@
1
+ export { createAxiosInstance } from './createInstance.util';
2
+ export { queryParamsStringfy } from './queryParamsStringify.util';
3
+ export { getImageURL } from './getImageURL.util';
4
+ export { getBaseURL } from './getBaseURL.util';
@@ -0,0 +1,9 @@
1
+ import { QueryParams } from '../types/fetchResponse.type';
2
+ export interface QueryParamsStringfy {
3
+ [key: string]: string;
4
+ }
5
+ /**
6
+ * This Function will turn all array query params to string
7
+ * using JSON Stringfy
8
+ */
9
+ export declare const queryParamsStringfy: (data: QueryParams | undefined) => QueryParamsStringfy | undefined;