Skip to content

Commit 0ed4648

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 0f94091 commit 0ed4648

File tree

4 files changed

+200
-87
lines changed

4 files changed

+200
-87
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "laravel-nova-devtool",
33
"description": "Laravel Nova DevTool",
4-
"types": "types/index.d.ts",
4+
"types": "types/nova.d.ts",
55
"devDependencies": {
66
"@inertiajs/vue3": "^1.0.0",
77
"axios": "^1.7.4",

types/form.d.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import type { AxiosInstance, AxiosResponse } from 'axios'
2+
3+
export type FormData = {
4+
[key: string]: any;
5+
}
6+
7+
type FormOptions = {
8+
http?: AxiosInstance;
9+
resetOnSuccess?: boolean;
10+
onSuccess?: Function;
11+
onFail?: Function;
12+
}
13+
14+
export declare type Form = {
15+
create: (data?: FormData) => Form;
16+
17+
processing: boolean;
18+
successful: boolean;
19+
errors: Errors;
20+
__http: AxiosInstance;
21+
22+
delete: (url: string) => Promise<any>;
23+
patch: (url: string) => Promise<any>;
24+
post: (url: string) => Promise<any>;
25+
put: (url: string) => Promise<any>;
26+
submit: (requestType: string, url: string) => Promise<any>;
27+
28+
getError: (field: string) => string | null;
29+
getErrors: (field: string) => string[];
30+
31+
hasError: (field: string) => boolean;
32+
hasFiles(): () => boolean;
33+
hasFilesDeep: (object: any | any[]) => boolean;
34+
35+
clear: () => void;
36+
data: () => FormData;
37+
only: (fields: any[]) => FormData;
38+
populate: (data: FormData) => Form;
39+
reset: () => void;
40+
setInitialValues: (values: FormData) => void;
41+
42+
onFail: (error: AxiosResponse) => void;
43+
onSuccess: (data: any) => void;
44+
45+
withData: (data: FormData) => Form;
46+
withErrors: (errors: ErrorCollection) => Form;
47+
withOptions: (options: FormOptions) => Form;
48+
49+
[key: string]: any;
50+
}
51+
52+
export type ErrorCollection = {
53+
[key: string]: string[];
54+
}
55+
56+
export declare type Errors = {
57+
errors: ErrorCollection;
58+
59+
all: () => ErrorCollection;
60+
any: (keys?: string[]) => ErrorCollection;
61+
clear: (field: string | null) => void;
62+
first: (field: string) => string | null;
63+
get: (field: string) => string[];
64+
has: (field: string) => boolean;
65+
record: (errors?: ErrorCollection) => void;
66+
}

types/index.d.ts

Lines changed: 0 additions & 86 deletions
This file was deleted.

types/nova.d.ts

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import type {
2+
App as VueApp,
3+
Component as VueComponent
4+
} from 'vue'
5+
import type { Router } from '@inertiajs/core'
6+
import type { AxiosInstance } from 'axios'
7+
import type { Store } from 'vuex'
8+
import type { Form } from './form'
9+
import type { Menu } from './menu'
10+
11+
type State = {
12+
baseUri: string;
13+
currentUser: any;
14+
mainMenu: any[];
15+
userMenu: any[];
16+
resources: any[];
17+
version: string;
18+
mainMenuShown: boolean;
19+
canLeaveForm: boolean;
20+
canLeaveModal: boolean;
21+
pushStateWasTriggered: boolean;
22+
validLicense: true;
23+
[key: string]: any;
24+
}
25+
26+
type BootingCallback = ((app: VueApp, store: Store<State>) => void);
27+
28+
type Color = {
29+
[key: string]: string;
30+
}
31+
32+
export type AppConfig = {
33+
algoliaApiKey?: any;
34+
algoliaAppId?: any;
35+
appName: string;
36+
base: string;
37+
brandColors: Color[];
38+
brandColorsCSS: string;
39+
customLoginPath: boolean;
40+
customLogoutPath: boolean;
41+
debounce: number;
42+
footer: string;
43+
forgotPasswordPath: string | boolean;
44+
globalSearchEnabled: boolean;
45+
hasGloballySearchableResources: boolean;
46+
initialPath: string;
47+
locale: string;
48+
logo?: string;
49+
mainMenu: Menu[];
50+
notificationCenterEnabled: boolean;
51+
notificationPollingInterval: number;
52+
pagination: string;
53+
resetPasswordPath: boolean;
54+
resources: Resource[];
55+
rtlEnabled: boolean;
56+
themeSwitcherEnabled: boolean;
57+
timezone: string;
58+
translations: Translations;
59+
userId: number;
60+
userMenu: Menu[];
61+
userTimezone?: any;
62+
version: string;
63+
withAuthentication: boolean;
64+
withPasswordReset: boolean;
65+
[key: string]: any;
66+
}
67+
68+
type Resource = {
69+
uriKey: string;
70+
label: string;
71+
singularLabel: string;
72+
createButtonLabel: string;
73+
updateButtonLabel: string;
74+
authorizedToCreate: boolean;
75+
searchable: boolean;
76+
perPageOptions: number[];
77+
tableStyle: string;
78+
showColumnBorders: boolean;
79+
debounce: number;
80+
clickAction: string;
81+
};
82+
83+
type Translations = {
84+
[key: string]: string;
85+
}
86+
87+
export declare type NovaApp = {
88+
pages: {[key: string]: VueComponent | string};
89+
$router: Router;
90+
readonly appConfig: AppConfig;
91+
store: Store<State>;
92+
93+
boot: () => void;
94+
booting: (callback: BootingCallback) => void;
95+
booted: (callback: BootingCallback) => void;
96+
config: (key: string) => any;
97+
countdown(): Promise<void>;
98+
form: (data: {[key: string]: any}) => Form;
99+
hasSecurityFeatures(): boolean;
100+
liftOff: () => void;
101+
missingResource: (uriKey: string) => boolean;
102+
redirectToLogin: () => void;
103+
url: (path: string, parameters: any) => string;
104+
105+
request: (options: Object) => AxiosInstance;
106+
107+
inertia: (name: string, component: VueComponent | string) => void;
108+
visit: (path: ({ url: string; remote: boolean; } | string), options?: Object) => void;
109+
110+
component: (name: string, component: VueComponent | string) => void;
111+
hasComponent: (name: string) => boolean;
112+
113+
debug: (message: any, type?: string) => void;
114+
log: (message: string, type?: string) => void;
115+
116+
error: (message: string) => void;
117+
info: (message: string) => void;
118+
success: (message: string) => void;
119+
warning: (message: string) => void;
120+
121+
formatNumber: (number: number, format: any | string) => string;
122+
123+
$emit: (event: string, ...args: any[]) => void;
124+
$on: (event: string, callback: Function, ctx?: any) => void;
125+
$once: (event: string, callback: Function, ctx?: any) => void;
126+
$off: (event: string, callback?: Function) => void;
127+
}
128+
129+
declare global {
130+
interface Window {
131+
Nova: NovaApp;
132+
}
133+
}

0 commit comments

Comments
 (0)