@andrew.verdyanwar/microfrontend-types 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,4 @@
1
+ export * from "./components/card";
2
+ export * from "./components/button";
3
+ export * from "./hooks";
4
+ export * from "./api";
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components/card"), exports);
18
+ __exportStar(require("./components/button"), exports);
19
+ __exportStar(require("./hooks"), exports);
20
+ __exportStar(require("./api"), exports);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@andrew.verdyanwar/microfrontend-types",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript definitions for microfrontend components and utilities",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "src"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "dev": "tsc --watch",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "devDependencies": {
17
+ "typescript": "^5.0.0",
18
+ "@types/react": "^18.0.0"
19
+ },
20
+ "keywords": [
21
+ "typescript",
22
+ "microfrontend",
23
+ "types",
24
+ "definitions"
25
+ ],
26
+ "author": "Wasco Energy",
27
+ "license": "ISC",
28
+ "packageManager": "pnpm@10.14.0"
29
+ }
@@ -0,0 +1,16 @@
1
+ declare module "wtr/apis" {
2
+ import { SidebarItem, ApiResponse } from "container/hooks";
3
+
4
+ export interface MenuAPI {
5
+ /**
6
+ * Retrieves menu access permissions for a specific application
7
+ * @param applicationId - The ID of the application to get menu access for
8
+ * @returns Promise resolving to ApiResponse containing array of SidebarItem
9
+ */
10
+ getMenuAccess: (
11
+ applicationId: string,
12
+ ) => Promise<ApiResponse<SidebarItem[]>>;
13
+ }
14
+
15
+ export declare const menuAPI: MenuAPI;
16
+ }
package/src/api.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ declare module "container/hooks" {
2
+ import { AxiosInstance } from "axios";
3
+
4
+ export const apiClient: AxiosInstance;
5
+
6
+ export type PagingRequest = {
7
+ page: number;
8
+ take: number;
9
+ search?: string;
10
+ sortBy?: string;
11
+ sortOrder?: "asc" | "desc";
12
+ };
13
+ export type Paging = {
14
+ page: number;
15
+ take: number;
16
+ total_record: number;
17
+ };
18
+
19
+ export type ApiResponse<T> = {
20
+ requestId: string;
21
+ data: T;
22
+ paging?: Paging;
23
+ };
24
+ }
@@ -0,0 +1,62 @@
1
+ declare module "container/hooks" {
2
+ // Application type
3
+ export type Application = {
4
+ id: string;
5
+ parent_id: string;
6
+ name: string;
7
+ icon: string;
8
+ link: string;
9
+ color: string;
10
+ description: string;
11
+ };
12
+
13
+ // Application store state
14
+ interface ApplicationState {
15
+ applications: Application[];
16
+ application: Application | null;
17
+ desciplineId: string;
18
+ isLoading: boolean;
19
+ error: string | null;
20
+ }
21
+
22
+ // Application store actions
23
+ interface ApplicationActions {
24
+ setApplications: (applications: Application[]) => void;
25
+ setApplication: (application: Application) => void;
26
+ setDescipline: (desciplineId: string) => void;
27
+ clearApplications: () => void;
28
+ clearApplication: () => void;
29
+ clearDescipline: () => void;
30
+ setLoading: (loading: boolean) => void;
31
+ getApplicationState: () => {
32
+ applications: Application[];
33
+ application: Application | null;
34
+ };
35
+ }
36
+
37
+ type ApplicationStore = ApplicationState & ApplicationActions;
38
+
39
+ // Zustand store interface for applications
40
+ interface ZustandApplicationStore {
41
+ (): ApplicationStore;
42
+ getState: () => ApplicationStore;
43
+ setState: (
44
+ partial:
45
+ | Partial<ApplicationStore>
46
+ | ((state: ApplicationStore) => Partial<ApplicationStore>),
47
+ ) => void;
48
+ subscribe: (
49
+ listener: (state: ApplicationStore, prevState: ApplicationStore) => void,
50
+ ) => () => void;
51
+ persist: {
52
+ setOptions: (options: any) => void;
53
+ clearStorage: () => void;
54
+ rehydrate: () => void;
55
+ hasHydrated: () => boolean;
56
+ onHydrate: (fn: (state: ApplicationStore) => void) => () => void;
57
+ onFinishHydration: (fn: (state: ApplicationStore) => void) => () => void;
58
+ };
59
+ }
60
+
61
+ export const useApplicationStore: ZustandApplicationStore;
62
+ }
@@ -0,0 +1,46 @@
1
+ declare module "container/components" {
2
+ import { ComponentProps } from "react";
3
+ export interface ButtonVariants {
4
+ variant?:
5
+ | "default"
6
+ | "destructive"
7
+ | "outline"
8
+ | "secondaryCn"
9
+ | "ghost"
10
+ | "primary"
11
+ | "primaryOutline"
12
+ | "primaryGhost"
13
+ | "primarySoft"
14
+ | "secondary"
15
+ | "secondaryOutline"
16
+ | "secondaryGhost"
17
+ | "secondarySoft"
18
+ | "success"
19
+ | "successOutline"
20
+ | "successGhost"
21
+ | "successSoft"
22
+ | "warning"
23
+ | "warningOutline"
24
+ | "warningGhost"
25
+ | "warningSoft"
26
+ | "danger"
27
+ | "dangerOutline"
28
+ | "dangerGhost"
29
+ | "dangerSoft"
30
+ | "info"
31
+ | "infoOutline"
32
+ | "infoGhost"
33
+ | "infoSoft"
34
+ | "link";
35
+ size?: "default" | "sm" | "lg" | "icon";
36
+ }
37
+
38
+ export interface ButtonProps
39
+ extends ComponentProps<"button">,
40
+ ButtonVariants {
41
+ asChild?: boolean;
42
+ }
43
+
44
+ export const Button: React.ComponentType<ButtonProps>;
45
+ export const buttonVariants: any;
46
+ }
@@ -0,0 +1,46 @@
1
+ declare module "container/components" {
2
+ import { ComponentProps } from "react";
3
+
4
+ // Wasco Card Component Types
5
+ export interface WascoCardProps extends ComponentProps<"div"> {
6
+ className?: string;
7
+ }
8
+
9
+ export interface WascoCardHeaderProps extends ComponentProps<"div"> {
10
+ className?: string;
11
+ }
12
+
13
+ export interface WascoCardHeaderTitleProps extends ComponentProps<"h2"> {
14
+ className?: string;
15
+ }
16
+
17
+ export interface WascoCardHeaderActionProps extends ComponentProps<"div"> {
18
+ className?: string;
19
+ }
20
+
21
+ export interface WascoCardContentProps extends ComponentProps<"div"> {
22
+ className?: string;
23
+ }
24
+
25
+ export interface WascoCardFooterProps extends ComponentProps<"div"> {
26
+ className?: string;
27
+ }
28
+
29
+ // Component declarations
30
+ export function WascoCard(props: WascoCardProps): React.ReactElement;
31
+ export function WascoCardHeader(
32
+ props: WascoCardHeaderProps,
33
+ ): React.ReactElement;
34
+ export function WascoCardHeaderTitle(
35
+ props: WascoCardHeaderTitleProps,
36
+ ): React.ReactElement;
37
+ export function WascoCardHeaderAction(
38
+ props: WascoCardHeaderActionProps,
39
+ ): React.ReactElement;
40
+ export function WascoCardContent(
41
+ props: WascoCardContentProps,
42
+ ): React.ReactElement;
43
+ export function WascoCardFooter(
44
+ props: WascoCardFooterProps,
45
+ ): React.ReactElement;
46
+ }
@@ -0,0 +1,23 @@
1
+ declare module "container/components" {
2
+ import { ComponentType } from "react";
3
+ import { ColumnDef } from "@tanstack/react-table";
4
+
5
+ interface ServerDataTableProps<TData = any, TValue = any> {
6
+ columns?: ColumnDef<TData, TValue>[];
7
+ title?: string;
8
+ useQueryHook?: () => any;
9
+ onSelectionChange?: () => any;
10
+ }
11
+
12
+ const ServerDataTable: ComponentType<ServerDataTableProps>;
13
+ export const ServerDataTable;
14
+
15
+ export interface DataTableColumnHeaderProps<TData, TValue>
16
+ extends React.HTMLAttributes<HTMLDivElement> {
17
+ column: Column<TData, TValue>;
18
+ title: string;
19
+ }
20
+ export function DataTableColumnHeader<TData, TValue>(
21
+ props: DataTableColumnHeaderProps<TData, TValue>,
22
+ ): React.ReactElement;
23
+ }
@@ -0,0 +1,6 @@
1
+ declare module "container/components" {
2
+ import { ComponentType } from "react";
3
+
4
+ const LoadingSpinner: ComponentType;
5
+ export const LoadingSpinner;
6
+ }
@@ -0,0 +1,19 @@
1
+ declare module "container/components" {
2
+ import { ColumnDef, RowData } from "@tanstack/react-table";
3
+
4
+ declare module "@tanstack/react-table" {
5
+ interface ColumnMeta<TData extends RowData, TValue> {
6
+ className?: string;
7
+ title?: string;
8
+ }
9
+ }
10
+
11
+ export interface DataTableProps<T> {
12
+ columns: ColumnDef<T>[];
13
+ data: T[];
14
+ }
15
+
16
+ export declare function TableCustom<T>(
17
+ props: DataTableProps<T>,
18
+ ): React.ReactElement;
19
+ }
@@ -0,0 +1,11 @@
1
+ declare module "container/components" {
2
+ import { Table } from "@tanstack/react-table";
3
+
4
+ export interface DataTablePaginationProps<TData> {
5
+ table: Table<TData>;
6
+ }
7
+
8
+ export declare function TablePagination<TData>(
9
+ props: DataTablePaginationProps<TData>,
10
+ ): React.ReactElement;
11
+ }
@@ -0,0 +1,10 @@
1
+ declare module "container/components" {
2
+ export interface TooltipContainerProps {
3
+ message: string;
4
+ children: React.ReactNode;
5
+ }
6
+
7
+ export function TooltipContainer(
8
+ props: TooltipContainerProps,
9
+ ): React.ReactElement;
10
+ }
package/src/hooks.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ declare module "container/hooks" {
2
+ export function useTableQuery<T>(props: {
3
+ queryKey: string[];
4
+ queryFn: (paging: any) => Promise<any>;
5
+ enabled?: boolean;
6
+ }): {
7
+ data?: { data: T[]; paging?: any };
8
+ isLoading: boolean;
9
+ error: any;
10
+ refetch: () => void;
11
+ prefetchNextPage: () => void;
12
+ // Add other react-query properties as needed
13
+ isFetching: boolean;
14
+ isError: boolean;
15
+ isSuccess: boolean;
16
+ };
17
+
18
+ interface TableStoreState {
19
+ page: number;
20
+ take: number;
21
+ sorting: any[];
22
+ filters: { search: string };
23
+ rowSelection: any;
24
+ columnVisibility: any;
25
+ setPaging: (params: { page?: number; take?: number }) => void;
26
+ setSorting: (sorting: any) => void;
27
+ setFilters: (filters: any) => void;
28
+ setRowSelection: (selection: any) => void;
29
+ setColumnVisibility: (visibility: any) => void;
30
+ resetTable: () => void;
31
+ getPagingRequest: () => any;
32
+ }
33
+
34
+ // Define the Zustand store interface
35
+ interface ZustandTableStore {
36
+ (): TableStoreState;
37
+ getState: () => TableStoreState;
38
+ setState: (
39
+ partial:
40
+ | Partial<TableStoreState>
41
+ | ((state: TableStoreState) => Partial<TableStoreState>),
42
+ ) => void;
43
+ subscribe: (
44
+ listener: (state: TableStoreState, prevState: TableStoreState) => void,
45
+ ) => () => void;
46
+ }
47
+
48
+ export const useTableStore: ZustandTableStore;
49
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ // Definitions for Node.js modules that are not specific to any version of TypeScript:
2
+ /// <reference path="components/card.d.ts" />
3
+ /// <reference path="components/button.d.ts" />
4
+ /// <reference path="components/datable.d.ts" />
5
+ /// <reference path="components/loading.d.ts" />
6
+ /// <reference path="components/table-custom.d.ts" />
7
+ /// <reference path="components/table-paging.d.ts" />
8
+ /// <reference path="components/tooltip-container.d.ts" />
9
+ /// <reference path="utils/colorMapping.d.ts" />
10
+ /// <reference path="utils/iconMapping.d.ts" />
11
+ /// <reference path="utils/alertMapping.d.ts" />
12
+ /// <reference path="utils/toastMapping.d.ts" />
13
+ /// <reference path="utils/dateFormating.d.ts" />
14
+ /// <reference path="api/menu.d.ts" />
15
+ /// <reference path="stores/useProjectStore.d.ts" />
16
+ /// <reference path="hooks.d.ts" />
17
+ /// <reference path="api.d.ts" />
18
+ /// <reference path="sidebar.d.ts" />
19
+ /// <reference path="application.d.ts" />
20
+ //
21
+
22
+ export * from "./components/card";
23
+ export * from "./components/button";
24
+ export * from "./components/datable";
25
+ export * from "./components/loading";
26
+ export * from "./components/table-custom";
27
+ export * from "./components/table-paging";
28
+ export * from "./components/tooltip-container";
29
+ export * from "./utils/colorMapping";
30
+ export * from "./utils/iconMapping";
31
+ export * from "./utils/alertMapping";
32
+ export * from "./utils/toastMapping";
33
+ export * from "./utils/dateFormating";
34
+ export * from "./api/menu";
35
+ export * from "./stores/useProjectStore";
36
+ export * from "./hooks";
37
+ export * from "./api";
38
+ export * from "./sidebar";
39
+ export * from "./application";
@@ -0,0 +1,62 @@
1
+ declare module "container/hooks" {
2
+ // Sidebar types
3
+ export interface SidebarItem {
4
+ name: string;
5
+ icon: string;
6
+ link: string;
7
+ children?: {
8
+ name: string;
9
+ icon: string;
10
+ link: string;
11
+ }[];
12
+ }
13
+
14
+ export interface SidebarProps {
15
+ isOpen: boolean;
16
+ onToggle: () => void;
17
+ activeItem: string;
18
+ onItemSelect: (item: SidebarItem) => void;
19
+ expandedItems: string[];
20
+ onToggleExpanded: (item: string) => void;
21
+ }
22
+
23
+ // Sidebar store state and actions
24
+ interface SideBarState {
25
+ activeItem: string;
26
+ expandedItems: string[];
27
+ sidebarItems: SidebarItem[];
28
+ }
29
+
30
+ interface SideBarActions {
31
+ setActiveItem: (item: string) => void;
32
+ setSidebarItem: (items: SidebarItem[]) => void;
33
+ setExpandedItems: (item: string) => void;
34
+ clearExpandedItems: () => void;
35
+ }
36
+
37
+ type SidebarStore = SideBarState & SideBarActions;
38
+
39
+ // Zustand store interface for sidebar
40
+ interface ZustandSidebarStore {
41
+ (): SidebarStore;
42
+ getState: () => SidebarStore;
43
+ setState: (
44
+ partial:
45
+ | Partial<SidebarStore>
46
+ | ((state: SidebarStore) => Partial<SidebarStore>),
47
+ ) => void;
48
+ subscribe: (
49
+ listener: (state: SidebarStore, prevState: SidebarStore) => void,
50
+ ) => () => void;
51
+ persist: {
52
+ setOptions: (options: any) => void;
53
+ clearStorage: () => void;
54
+ rehydrate: () => void;
55
+ hasHydrated: () => boolean;
56
+ onHydrate: (fn: (state: SidebarStore) => void) => () => void;
57
+ onFinishHydration: (fn: (state: SidebarStore) => void) => () => void;
58
+ };
59
+ }
60
+
61
+ export const useSidebarStore: ZustandSidebarStore;
62
+ }
@@ -0,0 +1,64 @@
1
+ declare module "wtr/stores" {
2
+ import { Module } from "@/types/project";
3
+
4
+ export interface ModuleState {
5
+ module: Module | null;
6
+ modules: Module[];
7
+ openModuleForm: boolean;
8
+ isLoading: boolean;
9
+ error: string | null;
10
+ }
11
+
12
+ export interface ModuleActions {
13
+ /**
14
+ * Sets the current active module
15
+ * @param module - The module to set as current
16
+ */
17
+ setModule: (module: Module) => void;
18
+
19
+ /**
20
+ * Sets the array of modules
21
+ * @param modules - Array of modules to set in the store
22
+ */
23
+ setModules: (modules: Module[]) => void;
24
+
25
+ /**
26
+ * Toggles the module form open/close state
27
+ * @param open - Boolean to control form visibility
28
+ */
29
+ toggleModuleFrom: (open: boolean) => void;
30
+
31
+ /**
32
+ * Clears the current active module
33
+ */
34
+ clearModule: () => void;
35
+
36
+ /**
37
+ * Clears all modules from the store
38
+ */
39
+ clearModules: () => void;
40
+
41
+ /**
42
+ * Sets the loading state
43
+ * @param loading - Boolean to indicate loading state
44
+ */
45
+ setLoading: (loading: boolean) => void;
46
+
47
+ /**
48
+ * Gets the current module state (active module and modules array)
49
+ * @returns Object containing current module and modules array
50
+ */
51
+ getModuleState: () => {
52
+ module: Module | null;
53
+ modules: Module[];
54
+ };
55
+ }
56
+
57
+ export type ModuleStore = ModuleState & ModuleActions;
58
+
59
+ /**
60
+ * Zustand store for managing module state
61
+ * Includes middleware: devtools, immer, subscribeWithSelector
62
+ */
63
+ export declare const useModuleStore: () => ModuleStore;
64
+ }
@@ -0,0 +1,36 @@
1
+ declare module "wtr/stores" {
2
+ import { Project } from "@/types/project";
3
+
4
+ export interface ProjectState {
5
+ project: Project | null;
6
+ }
7
+
8
+ export interface ProjectActions {
9
+ /**
10
+ * Sets the current project in the store
11
+ * @param project - The project to set as current
12
+ */
13
+ setProject: (project: Project) => void;
14
+
15
+ /**
16
+ * Clears the current project from the store
17
+ */
18
+ clearProject: () => void;
19
+
20
+ /**
21
+ * Gets the current project state
22
+ * @returns Object containing the current project or null
23
+ */
24
+ getProjectState: () => {
25
+ project: Project | null;
26
+ };
27
+ }
28
+
29
+ export type ProjectStore = ProjectState & ProjectActions;
30
+
31
+ /**
32
+ * Zustand store for managing project state with persistence and devtools
33
+ * Includes middleware: devtools, persist, immer, subscribeWithSelector
34
+ */
35
+ export declare const useProjectStore: () => ProjectStore;
36
+ }
@@ -0,0 +1,9 @@
1
+ declare module "container/utils" {
2
+ import { SweetAlertResult } from "sweetalert2";
3
+
4
+ export const confirmationAlert: (
5
+ message: string,
6
+ ) => Promise<SweetAlertResult>;
7
+
8
+ export const newAlert: (message: string) => Promise<SweetAlertResult>;
9
+ }
@@ -0,0 +1,3 @@
1
+ declare module "container/utils" {
2
+ export const getColor: (color: string) => string;
3
+ }
@@ -0,0 +1,22 @@
1
+ declare module "container/utils" {
2
+ /**
3
+ * Formats a Date object to dd/mm/yyyy string format
4
+ * @param date - The Date object to format
5
+ * @returns Formatted date string in dd/mm/yyyy format, or empty string if date is falsy
6
+ */
7
+ export declare const formatDate: (date: Date) => string;
8
+
9
+ /**
10
+ * Parses a dd/mm/yyyy string to a Date object
11
+ * @param dateString - The date string in dd/mm/yyyy format to parse
12
+ * @returns Date object if parsing is successful, null otherwise
13
+ */
14
+ export declare const parseDate: (dateString: string) => Date | null;
15
+
16
+ /**
17
+ * Formats a Date object to yyyy-mm-dd string format
18
+ * @param date - The Date object to format
19
+ * @returns Formatted date string in yyyy-mm-dd format, or empty string if date is falsy
20
+ */
21
+ export declare const parseDateToDb: (date: Date) => Date;
22
+ }
@@ -0,0 +1,5 @@
1
+ declare module "container/utils" {
2
+ import { type LucideIcon } from "lucide-react";
3
+
4
+ export const getIconComponent: (iconName: string) => LucideIcon;
5
+ }
@@ -0,0 +1,4 @@
1
+ declare module "container/utils" {
2
+ export const showSuccessMessage: (message: string) => void;
3
+ export const showErrorMessage: (message: string) => void;
4
+ }