wcz-layout 8.0.2 → 8.0.4

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.
Files changed (68) hide show
  1. package/dist/Approval-BSQHVGsm.js +133 -0
  2. package/dist/Approval-BSQHVGsm.js.map +1 -0
  3. package/dist/{DialogsContext-D5A8xncJ.js → DialogsContext-DkePghS6.js} +1 -1
  4. package/dist/{DialogsContext-D5A8xncJ.js.map → DialogsContext-DkePghS6.js.map} +1 -1
  5. package/dist/Email-D2SPExbn.js +20 -0
  6. package/dist/Email-D2SPExbn.js.map +1 -0
  7. package/dist/FileMeta--27aYkPB.js +19 -0
  8. package/dist/FileMeta--27aYkPB.js.map +1 -0
  9. package/dist/{FileMeta-fQnJ6uFX.d.ts → FileMeta-CQz1TMre.d.ts} +1 -1
  10. package/dist/{NotificationContext-DBTYc5z-.js → NotificationContext-FQRaNZRx.js} +1 -1
  11. package/dist/{NotificationContext-DBTYc5z-.js.map → NotificationContext-FQRaNZRx.js.map} +1 -1
  12. package/dist/{RouterListItemButton-rcdkgOXQ.js → RouterListItemButton-p9U4Z0SW.js} +1 -1
  13. package/dist/{RouterListItemButton-rcdkgOXQ.js.map → RouterListItemButton-p9U4Z0SW.js.map} +1 -1
  14. package/dist/{User-C21DoZOa.d.ts → User-B92WOpE2.d.ts} +1 -1
  15. package/dist/components.d.ts +12 -11
  16. package/dist/components.js +342 -303
  17. package/dist/components.js.map +1 -1
  18. package/dist/data/client.d.ts +3081 -0
  19. package/dist/data/client.js +188 -0
  20. package/dist/data/client.js.map +1 -0
  21. package/dist/data/server.d.ts +20 -0
  22. package/dist/data/server.js +24 -0
  23. package/dist/data/server.js.map +1 -0
  24. package/dist/env-Dgbk8SQN.js +31 -0
  25. package/dist/env-Dgbk8SQN.js.map +1 -0
  26. package/dist/file-BHdm6ob1.js +151 -0
  27. package/dist/file-BHdm6ob1.js.map +1 -0
  28. package/dist/file-DNF9kxdN.js +100 -0
  29. package/dist/file-DNF9kxdN.js.map +1 -0
  30. package/dist/hooks.d.ts +1 -1
  31. package/dist/hooks.js +3 -3
  32. package/dist/hooks.js.map +1 -1
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.js +17 -16
  35. package/dist/index.js.map +1 -1
  36. package/dist/middleware.d.ts +1 -1
  37. package/dist/middleware.js +2 -1
  38. package/dist/middleware.js.map +1 -1
  39. package/dist/models.d.ts +35 -6
  40. package/dist/models.js +4 -118
  41. package/dist/models.js.map +1 -1
  42. package/dist/{msalClient-MNN6BwL6.d.ts → msalClient-DZjYT_QJ.d.ts} +2 -2
  43. package/dist/msalServer-coQaBOlr.js +47 -0
  44. package/dist/msalServer-coQaBOlr.js.map +1 -0
  45. package/dist/peoplesoft-B9kmi9rI.d.ts +1081 -0
  46. package/dist/peoplesoft-CYSlmcwI.js +174 -0
  47. package/dist/peoplesoft-CYSlmcwI.js.map +1 -0
  48. package/dist/{queryClient-CAJR3qjE.js → queryClient-1OJ5Va3i.js} +1 -1
  49. package/dist/{queryClient-CAJR3qjE.js.map → queryClient-1OJ5Va3i.js.map} +1 -1
  50. package/dist/{useDialogs-BaxhulU9.js → useDialogs-BQEh6of8.js} +8 -8
  51. package/dist/useDialogs-BQEh6of8.js.map +1 -0
  52. package/dist/{utils-CqQKSaSs.js → utils-B7LPctqx.js} +8 -37
  53. package/dist/utils-B7LPctqx.js.map +1 -0
  54. package/dist/{utils-BBQ5S6oM.d.ts → utils-BM8-Efdl.d.ts} +2 -2
  55. package/dist/utils.d.ts +2 -2
  56. package/dist/utils.js +2 -46
  57. package/dist/vite.js.map +1 -1
  58. package/package.json +21 -14
  59. package/skills/auth/SKILL.md +268 -268
  60. package/dist/FileMeta-D9HyhrGi.js +0 -42
  61. package/dist/FileMeta-D9HyhrGi.js.map +0 -1
  62. package/dist/queries-JPqCc5Tb.js +0 -551
  63. package/dist/queries-JPqCc5Tb.js.map +0 -1
  64. package/dist/query.d.ts +0 -3052
  65. package/dist/query.js +0 -3
  66. package/dist/useDialogs-BaxhulU9.js.map +0 -1
  67. package/dist/utils-CqQKSaSs.js.map +0 -1
  68. package/dist/utils.js.map +0 -1
@@ -0,0 +1,188 @@
1
+ import { t as queryClient } from "../queryClient-1OJ5Va3i.js";
2
+ import { a as fileQueryOptions, c as updateFileMetaMutationOptions, i as fileMetasQueryOptions, l as useUploadFile, n as deleteFileMutationOptions, o as fileThumbnailQueryOptions, r as downloadFileMutationOptions, s as openFileMutationOptions, t as batchDeleteFilesMutationOptions } from "../file-DNF9kxdN.js";
3
+ import { C as createApproval, D as withdrawApproval, E as resubmitApproval, S as cancelApproval, T as getApprovals, _ as getPreviousEmployeeIds, a as getActiveEmployees, c as getDepartmentEmployees, d as getEmployeeByEmployeeId, f as getEmployeeGeneralManager, g as getEmployees, h as getEmployeeSupervisor, l as getDepartmentManager, m as getEmployeeSubordinates, o as getCompanyGeneralManager, p as getEmployeeManager, s as getDepartmentById, u as getDepartments, v as searchEmployees, w as getApproval, x as approveApproval } from "../peoplesoft-CYSlmcwI.js";
4
+ import { mutationOptions, queryOptions } from "@tanstack/react-query";
5
+ //#region src/queries/client/approval.ts
6
+ const QUERY_KEY$1 = "approval";
7
+ const approvalsQueryOptions = (params) => queryOptions({
8
+ queryKey: [QUERY_KEY$1, params],
9
+ queryFn: () => getApprovals({ data: params })
10
+ });
11
+ const approvalQueryOptions = (params) => queryOptions({
12
+ queryKey: [QUERY_KEY$1, params],
13
+ queryFn: () => getApproval({ data: params })
14
+ });
15
+ const createApprovalMutationOptions = () => mutationOptions({
16
+ mutationFn: (data) => createApproval({ data }),
17
+ onSettled: () => queryClient.invalidateQueries({
18
+ queryKey: [QUERY_KEY$1],
19
+ exact: false
20
+ })
21
+ });
22
+ const approveApprovalMutationOptions = () => mutationOptions({
23
+ mutationFn: (data) => approveApproval({ data }),
24
+ onSettled: () => queryClient.invalidateQueries({
25
+ queryKey: [QUERY_KEY$1],
26
+ exact: false
27
+ })
28
+ });
29
+ const resubmitApprovalMutationOptions = () => mutationOptions({
30
+ mutationFn: (data) => resubmitApproval({ data }),
31
+ onSettled: () => queryClient.invalidateQueries({
32
+ queryKey: [QUERY_KEY$1],
33
+ exact: false
34
+ })
35
+ });
36
+ const withdrawApprovalMutationOptions = () => mutationOptions({
37
+ mutationFn: (data) => withdrawApproval({ data }),
38
+ onSettled: () => queryClient.invalidateQueries({
39
+ queryKey: [QUERY_KEY$1],
40
+ exact: false
41
+ })
42
+ });
43
+ const cancelApprovalMutationOptions = () => mutationOptions({
44
+ mutationFn: (data) => cancelApproval({ data }),
45
+ onSettled: () => queryClient.invalidateQueries({
46
+ queryKey: [QUERY_KEY$1],
47
+ exact: false
48
+ })
49
+ });
50
+ //#endregion
51
+ //#region src/queries/client/peoplesoft.ts
52
+ const QUERY_KEY = "ps";
53
+ const DAY = 1e3 * 60 * 60 * 24;
54
+ const baseOptions = {
55
+ staleTime: DAY,
56
+ gcTime: DAY,
57
+ refetchOnWindowFocus: false
58
+ };
59
+ const employeesSearchQueryOptions = (params) => queryOptions({
60
+ queryKey: [
61
+ QUERY_KEY,
62
+ "employee",
63
+ "search",
64
+ params
65
+ ],
66
+ queryFn: () => searchEmployees({ data: params }),
67
+ ...baseOptions
68
+ });
69
+ const employeesQueryOptions = () => queryOptions({
70
+ queryKey: [QUERY_KEY, "employee"],
71
+ queryFn: () => getEmployees(),
72
+ ...baseOptions
73
+ });
74
+ const activeEmployeesQueryOptions = () => queryOptions({
75
+ queryKey: [
76
+ QUERY_KEY,
77
+ "employee",
78
+ "active"
79
+ ],
80
+ queryFn: () => getActiveEmployees(),
81
+ ...baseOptions
82
+ });
83
+ const employeeByIdQueryOptions = (params) => queryOptions({
84
+ queryKey: [
85
+ QUERY_KEY,
86
+ "employee",
87
+ params
88
+ ],
89
+ queryFn: () => getEmployeeByEmployeeId({ data: params }),
90
+ ...baseOptions
91
+ });
92
+ const previousEmployeeIdsQueryOptions = () => queryOptions({
93
+ queryKey: [
94
+ QUERY_KEY,
95
+ "employee",
96
+ "previousIds"
97
+ ],
98
+ queryFn: () => getPreviousEmployeeIds(),
99
+ ...baseOptions
100
+ });
101
+ const employeeSupervisorQueryOptions = (params) => queryOptions({
102
+ queryKey: [
103
+ QUERY_KEY,
104
+ "employee",
105
+ "supervisor",
106
+ params
107
+ ],
108
+ queryFn: () => getEmployeeSupervisor({ data: params }),
109
+ ...baseOptions
110
+ });
111
+ const employeeSubordinatesQueryOptions = (params) => queryOptions({
112
+ queryKey: [
113
+ QUERY_KEY,
114
+ "employee",
115
+ "subordinates",
116
+ params
117
+ ],
118
+ queryFn: () => getEmployeeSubordinates({ data: params }),
119
+ ...baseOptions
120
+ });
121
+ const employeeManagerQueryOptions = (params) => queryOptions({
122
+ queryKey: [
123
+ QUERY_KEY,
124
+ "employee",
125
+ "manager",
126
+ params
127
+ ],
128
+ queryFn: () => getEmployeeManager({ data: params }),
129
+ ...baseOptions
130
+ });
131
+ const employeeGeneralManagerQueryOptions = (params) => queryOptions({
132
+ queryKey: [
133
+ QUERY_KEY,
134
+ "employee",
135
+ "generalManager",
136
+ params
137
+ ],
138
+ queryFn: () => getEmployeeGeneralManager({ data: params }),
139
+ ...baseOptions
140
+ });
141
+ const departmentsQueryOptions = () => queryOptions({
142
+ queryKey: [QUERY_KEY, "department"],
143
+ queryFn: () => getDepartments(),
144
+ ...baseOptions
145
+ });
146
+ const departmentByIdQueryOptions = (params) => queryOptions({
147
+ queryKey: [
148
+ QUERY_KEY,
149
+ "department",
150
+ params
151
+ ],
152
+ queryFn: () => getDepartmentById({ data: params }),
153
+ ...baseOptions
154
+ });
155
+ const departmentManagerQueryOptions = (params) => queryOptions({
156
+ queryKey: [
157
+ QUERY_KEY,
158
+ "department",
159
+ "manager",
160
+ params
161
+ ],
162
+ queryFn: () => getDepartmentManager({ data: params }),
163
+ ...baseOptions
164
+ });
165
+ const departmentEmployeesQueryOptions = (params) => queryOptions({
166
+ queryKey: [
167
+ QUERY_KEY,
168
+ "department",
169
+ "employees",
170
+ params
171
+ ],
172
+ queryFn: () => getDepartmentEmployees({ data: params }),
173
+ ...baseOptions
174
+ });
175
+ const companyGeneralManagerQueryOptions = (params) => queryOptions({
176
+ queryKey: [
177
+ QUERY_KEY,
178
+ "company",
179
+ "generalManager",
180
+ params
181
+ ],
182
+ queryFn: () => getCompanyGeneralManager({ data: params }),
183
+ ...baseOptions
184
+ });
185
+ //#endregion
186
+ export { activeEmployeesQueryOptions, approvalQueryOptions, approvalsQueryOptions, approveApprovalMutationOptions, batchDeleteFilesMutationOptions, cancelApprovalMutationOptions, companyGeneralManagerQueryOptions, createApprovalMutationOptions, deleteFileMutationOptions, departmentByIdQueryOptions, departmentEmployeesQueryOptions, departmentManagerQueryOptions, departmentsQueryOptions, downloadFileMutationOptions, employeeByIdQueryOptions, employeeGeneralManagerQueryOptions, employeeManagerQueryOptions, employeeSubordinatesQueryOptions, employeeSupervisorQueryOptions, employeesQueryOptions, employeesSearchQueryOptions, fileMetasQueryOptions, fileQueryOptions, fileThumbnailQueryOptions, openFileMutationOptions, previousEmployeeIdsQueryOptions, queryClient, resubmitApprovalMutationOptions, updateFileMetaMutationOptions, useUploadFile, withdrawApprovalMutationOptions };
187
+
188
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":["mutationOptions","queryOptions","z","queryClient","ApproveApprovalSchema","CancelApprovalSchema","CreateApprovalSchema","ResubmitApprovalSchema","WithdrawApprovalSchema","GetApprovalSchema","GetApprovalsSchema","approveApproval","cancelApproval","createApproval","getApproval","getApprovals","resubmitApproval","withdrawApproval","QUERY_KEY","approvalsQueryOptions","params","input","queryKey","queryFn","data","approvalQueryOptions","createApprovalMutationOptions","mutationFn","onSettled","invalidateQueries","exact","approveApprovalMutationOptions","resubmitApprovalMutationOptions","withdrawApprovalMutationOptions","cancelApprovalMutationOptions","queryOptions","z","CompanyCodeSchema","DepartmentIdSchema","EmployeeIdSchema","getActiveEmployees","getCompanyGeneralManager","getDepartmentById","getDepartmentEmployees","getDepartmentManager","getDepartments","getEmployeeByEmployeeId","getEmployeeGeneralManager","getEmployeeManager","getEmployees","getEmployeeSubordinates","getEmployeeSupervisor","getPreviousEmployeeIds","searchEmployees","SearchEmployeesSchema","QUERY_KEY","DAY","baseOptions","staleTime","gcTime","refetchOnWindowFocus","employeesSearchQueryOptions","params","infer","queryKey","queryFn","data","employeesQueryOptions","activeEmployeesQueryOptions","employeeByIdQueryOptions","previousEmployeeIdsQueryOptions","employeeSupervisorQueryOptions","employeeSubordinatesQueryOptions","employeeManagerQueryOptions","employeeGeneralManagerQueryOptions","departmentsQueryOptions","departmentByIdQueryOptions","departmentManagerQueryOptions","departmentEmployeesQueryOptions","companyGeneralManagerQueryOptions"],"sources":["../../src/queries/client/approval.ts","../../src/queries/client/peoplesoft.ts"],"sourcesContent":["import { mutationOptions, queryOptions } from \"@tanstack/react-query\";\nimport type { z } from \"zod\";\nimport { queryClient } from \"~/lib/queryClient\";\nimport {\n ApproveApprovalSchema,\n CancelApprovalSchema,\n CreateApprovalSchema,\n ResubmitApprovalSchema,\n WithdrawApprovalSchema,\n} from \"~/models/approval/Approval\";\nimport type { GetApprovalSchema, GetApprovalsSchema } from \"~/queries/server/approval\";\nimport {\n approveApproval,\n cancelApproval,\n createApproval,\n getApproval,\n getApprovals,\n resubmitApproval,\n withdrawApproval,\n} from \"~/queries/server/approval\";\n\nconst QUERY_KEY = \"approval\";\n\nexport const approvalsQueryOptions = (params: z.input<typeof GetApprovalsSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, params],\n queryFn: () => getApprovals({ data: params }),\n });\n\nexport const approvalQueryOptions = (params: z.input<typeof GetApprovalSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, params],\n queryFn: () => getApproval({ data: params }),\n });\n\nexport const createApprovalMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof CreateApprovalSchema>) => createApproval({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY], exact: false }),\n });\n\nexport const approveApprovalMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof ApproveApprovalSchema>) => approveApproval({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY], exact: false }),\n });\n\nexport const resubmitApprovalMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof ResubmitApprovalSchema>) => resubmitApproval({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY], exact: false }),\n });\n\nexport const withdrawApprovalMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof WithdrawApprovalSchema>) => withdrawApproval({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY], exact: false }),\n });\n\nexport const cancelApprovalMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof CancelApprovalSchema>) => cancelApproval({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY], exact: false }),\n });\n","import { queryOptions } from \"@tanstack/react-query\";\nimport z from \"zod\";\nimport {\n CompanyCodeSchema,\n DepartmentIdSchema,\n EmployeeIdSchema,\n getActiveEmployees,\n getCompanyGeneralManager,\n getDepartmentById,\n getDepartmentEmployees,\n getDepartmentManager,\n getDepartments,\n getEmployeeByEmployeeId,\n getEmployeeGeneralManager,\n getEmployeeManager,\n getEmployees,\n getEmployeeSubordinates,\n getEmployeeSupervisor,\n getPreviousEmployeeIds,\n searchEmployees,\n SearchEmployeesSchema,\n} from \"~/queries/server/peoplesoft\";\n\nconst QUERY_KEY = \"ps\";\nconst DAY = 1000 * 60 * 60 * 24;\n\nconst baseOptions = {\n staleTime: DAY,\n gcTime: DAY,\n refetchOnWindowFocus: false,\n};\n\nexport const employeesSearchQueryOptions = (params: z.infer<typeof SearchEmployeesSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", \"search\", params],\n queryFn: () => searchEmployees({ data: params }),\n ...baseOptions,\n });\n\nexport const employeesQueryOptions = () =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\"],\n queryFn: () => getEmployees(),\n ...baseOptions,\n });\n\nexport const activeEmployeesQueryOptions = () =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", \"active\"],\n queryFn: () => getActiveEmployees(),\n ...baseOptions,\n });\n\nexport const employeeByIdQueryOptions = (params: z.infer<typeof EmployeeIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", params],\n queryFn: () => getEmployeeByEmployeeId({ data: params }),\n ...baseOptions,\n });\n\nexport const previousEmployeeIdsQueryOptions = () =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", \"previousIds\"],\n queryFn: () => getPreviousEmployeeIds(),\n ...baseOptions,\n });\n\nexport const employeeSupervisorQueryOptions = (params: z.infer<typeof EmployeeIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", \"supervisor\", params],\n queryFn: () => getEmployeeSupervisor({ data: params }),\n ...baseOptions,\n });\n\nexport const employeeSubordinatesQueryOptions = (params: z.infer<typeof EmployeeIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", \"subordinates\", params],\n queryFn: () => getEmployeeSubordinates({ data: params }),\n ...baseOptions,\n });\n\nexport const employeeManagerQueryOptions = (params: z.infer<typeof EmployeeIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", \"manager\", params],\n queryFn: () => getEmployeeManager({ data: params }),\n ...baseOptions,\n });\n\nexport const employeeGeneralManagerQueryOptions = (params: z.infer<typeof EmployeeIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"employee\", \"generalManager\", params],\n queryFn: () => getEmployeeGeneralManager({ data: params }),\n ...baseOptions,\n });\n\nexport const departmentsQueryOptions = () =>\n queryOptions({\n queryKey: [QUERY_KEY, \"department\"],\n queryFn: () => getDepartments(),\n ...baseOptions,\n });\n\nexport const departmentByIdQueryOptions = (params: z.infer<typeof DepartmentIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"department\", params],\n queryFn: () => getDepartmentById({ data: params }),\n ...baseOptions,\n });\n\nexport const departmentManagerQueryOptions = (params: z.infer<typeof DepartmentIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"department\", \"manager\", params],\n queryFn: () => getDepartmentManager({ data: params }),\n ...baseOptions,\n });\n\nexport const departmentEmployeesQueryOptions = (params: z.infer<typeof DepartmentIdSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"department\", \"employees\", params],\n queryFn: () => getDepartmentEmployees({ data: params }),\n ...baseOptions,\n });\n\nexport const companyGeneralManagerQueryOptions = (params: z.infer<typeof CompanyCodeSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"company\", \"generalManager\", params],\n queryFn: () => getCompanyGeneralManager({ data: params }),\n ...baseOptions,\n });\n"],"mappings":";;;;;AAqBA,MAAMkB,cAAY;AAElB,MAAaC,yBAAyBC,WACpCnB,aAAa;CACXqB,UAAU,CAACJ,aAAWE,OAAO;CAC7BG,eAAeR,aAAa,EAAES,MAAMJ,QAAQ,CAAA;CAC7C,CAAC;AAEJ,MAAaK,wBAAwBL,WACnCnB,aAAa;CACXqB,UAAU,CAACJ,aAAWE,OAAO;CAC7BG,eAAeT,YAAY,EAAEU,MAAMJ,QAAQ,CAAA;CAC5C,CAAC;AAEJ,MAAaM,sCACX1B,gBAAgB;CACd2B,aAAaH,SAA+CX,eAAe,EAAEW,MAAM,CAAC;CACpFI,iBAAiBzB,YAAY0B,kBAAkB;EAAEP,UAAU,CAACJ,YAAU;EAAEY,OAAO;EAAO,CAAA;CACvF,CAAC;AAEJ,MAAaC,uCACX/B,gBAAgB;CACd2B,aAAaH,SAAgDb,gBAAgB,EAAEa,MAAM,CAAC;CACtFI,iBAAiBzB,YAAY0B,kBAAkB;EAAEP,UAAU,CAACJ,YAAU;EAAEY,OAAO;EAAO,CAAA;CACvF,CAAC;AAEJ,MAAaE,wCACXhC,gBAAgB;CACd2B,aAAaH,SAAiDR,iBAAiB,EAAEQ,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AQ,CAAC;CACvD,GAAGL;CACJ,CAAC;AAEJ,MAAasB,qCAAqCjB,WAChD3B,aAAa;CACX6B,UAAU;EAACT;EAAW;EAAW;EAAkBO;EAAO;CAC1DG,eAAexB,yBAAyB,EAAEyB,MAAMJ,QAAQ,CAAC;CACzD,GAAGL;CACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { A as UpdateFileMetaSchema, B as uploadFile, C as createApproval, D as withdrawApproval, E as resubmitApproval, F as downloadFile, I as getFile, L as getFileMetas, M as UploadFileResult, N as batchDeleteFiles, O as FileSchema, P as deleteFile, R as getFileThumbnail, S as cancelApproval, T as getApprovals, _ as getPreviousEmployeeIds, a as getActiveEmployees, b as GetApprovalsSchema, c as getDepartmentEmployees, d as getEmployeeByEmployeeId, f as getEmployeeGeneralManager, g as getEmployees, h as getEmployeeSupervisor, i as SearchEmployeesSchema, j as UploadFileMetaSchema, k as GetFileMetasSchema, l as getDepartmentManager, m as getEmployeeSubordinates, n as DepartmentIdSchema, o as getCompanyGeneralManager, p as getEmployeeManager, r as EmployeeIdSchema, s as getDepartmentById, t as CompanyCodeSchema, u as getDepartments, v as searchEmployees, w as getApproval, x as approveApproval, y as GetApprovalSchema, z as updateFileMeta } from "../peoplesoft-B9kmi9rI.js";
2
+ import * as _$zod from "zod";
3
+ import * as _$_tanstack_start_client_core0 from "@tanstack/start-client-core";
4
+ import * as _$zod_v4_core0 from "zod/v4/core";
5
+
6
+ //#region src/queries/server/email.d.ts
7
+ declare const sendEmail: _$_tanstack_start_client_core0.RequiredFetcher<undefined, _$zod.ZodObject<{
8
+ subject: _$zod.ZodString;
9
+ body: _$zod.ZodString;
10
+ to: _$zod.ZodArray<_$zod.ZodEmail>;
11
+ bcc: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodEmail>>;
12
+ cc: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodEmail>>;
13
+ attachments: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
14
+ appName: _$zod.ZodString;
15
+ subId: _$zod.ZodUUID;
16
+ }, _$zod_v4_core0.$strip>>>;
17
+ }, _$zod_v4_core0.$strip>, Promise<void>>;
18
+ //#endregion
19
+ export { CompanyCodeSchema, DepartmentIdSchema, EmployeeIdSchema, FileSchema, GetApprovalSchema, GetApprovalsSchema, GetFileMetasSchema, SearchEmployeesSchema, UpdateFileMetaSchema, UploadFileMetaSchema, UploadFileResult, approveApproval, batchDeleteFiles, cancelApproval, createApproval, deleteFile, downloadFile, getActiveEmployees, getApproval, getApprovals, getCompanyGeneralManager, getDepartmentById, getDepartmentEmployees, getDepartmentManager, getDepartments, getEmployeeByEmployeeId, getEmployeeGeneralManager, getEmployeeManager, getEmployeeSubordinates, getEmployeeSupervisor, getEmployees, getFile, getFileMetas, getFileThumbnail, getPreviousEmployeeIds, resubmitApproval, searchEmployees, sendEmail, updateFileMeta, uploadFile, withdrawApproval };
20
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { n as serverEnv } from "../env-Dgbk8SQN.js";
2
+ import { a as batchDeleteFiles, c as getFile, d as updateFileMeta, f as uploadFile, i as UploadFileMetaSchema, l as getFileMetas, n as GetFileMetasSchema, o as deleteFile, p as createExternalApi, r as UpdateFileMetaSchema, s as downloadFile, t as FileSchema, u as getFileThumbnail } from "../file-BHdm6ob1.js";
3
+ import { t as EmailSchema } from "../Email-D2SPExbn.js";
4
+ import { C as createApproval, D as withdrawApproval, E as resubmitApproval, S as cancelApproval, T as getApprovals, _ as getPreviousEmployeeIds, a as getActiveEmployees, b as GetApprovalsSchema, c as getDepartmentEmployees, d as getEmployeeByEmployeeId, f as getEmployeeGeneralManager, g as getEmployees, h as getEmployeeSupervisor, i as SearchEmployeesSchema, l as getDepartmentManager, m as getEmployeeSubordinates, n as DepartmentIdSchema, o as getCompanyGeneralManager, p as getEmployeeManager, r as EmployeeIdSchema, s as getDepartmentById, t as CompanyCodeSchema, u as getDepartments, v as searchEmployees, w as getApproval, x as approveApproval, y as GetApprovalSchema } from "../peoplesoft-CYSlmcwI.js";
5
+ import { createServerFn, createServerOnlyFn } from "@tanstack/react-start";
6
+ //#region src/queries/server/email.ts
7
+ let emailApi = null;
8
+ const getEmailApi = createServerOnlyFn(() => {
9
+ const baseUrl = serverEnv.EMAIL_BASE_URL;
10
+ if (!baseUrl) throw new Error("EMAIL_BASE_URL is not defined in server environment variables.");
11
+ emailApi ??= createExternalApi(baseUrl, "email");
12
+ return emailApi;
13
+ });
14
+ const sendEmail = createServerFn({ method: "POST" }).inputValidator(EmailSchema).handler(async ({ data }) => {
15
+ await getEmailApi().request({
16
+ url: "/",
17
+ method: "POST",
18
+ data
19
+ });
20
+ });
21
+ //#endregion
22
+ export { CompanyCodeSchema, DepartmentIdSchema, EmployeeIdSchema, FileSchema, GetApprovalSchema, GetApprovalsSchema, GetFileMetasSchema, SearchEmployeesSchema, UpdateFileMetaSchema, UploadFileMetaSchema, approveApproval, batchDeleteFiles, cancelApproval, createApproval, deleteFile, downloadFile, getActiveEmployees, getApproval, getApprovals, getCompanyGeneralManager, getDepartmentById, getDepartmentEmployees, getDepartmentManager, getDepartments, getEmployeeByEmployeeId, getEmployeeGeneralManager, getEmployeeManager, getEmployeeSubordinates, getEmployeeSupervisor, getEmployees, getFile, getFileMetas, getFileThumbnail, getPreviousEmployeeIds, resubmitApproval, searchEmployees, sendEmail, updateFileMeta, uploadFile, withdrawApproval };
23
+
24
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","names":["createServerFn","createServerOnlyFn","AxiosInstance","serverEnv","EmailSchema","createExternalApi","emailApi","getEmailApi","baseUrl","EMAIL_BASE_URL","Error","sendEmail","method","inputValidator","handler","data","api","request","url"],"sources":["../../src/queries/server/email.ts"],"sourcesContent":["import { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\nimport type { AxiosInstance } from \"axios\";\nimport { serverEnv } from \"~/env\";\nimport { EmailSchema } from \"~/models/email/Email\";\nimport { createExternalApi } from \"~/queries/server/externalApi\";\n\nlet emailApi: AxiosInstance | null = null;\nconst getEmailApi = createServerOnlyFn((): AxiosInstance => {\n const baseUrl = serverEnv.EMAIL_BASE_URL;\n if (!baseUrl) throw new Error(\"EMAIL_BASE_URL is not defined in server environment variables.\");\n emailApi ??= createExternalApi(baseUrl, \"email\");\n return emailApi;\n});\n\nexport const sendEmail = createServerFn({ method: \"POST\" })\n .inputValidator(EmailSchema)\n .handler(async ({ data }) => {\n const api = getEmailApi();\n await api.request<void>({\n url: \"/\",\n method: \"POST\",\n data,\n });\n });\n"],"mappings":";;;;;;AAMA,IAAIM,WAAiC;AACrC,MAAMC,cAAcN,yBAAwC;CAC1D,MAAMO,UAAUL,UAAUM;AAC1B,KAAI,CAACD,QAAS,OAAM,IAAIE,MAAM,iEAAiE;AAC/FJ,cAAaD,kBAAkBG,SAAS,QAAQ;AAChD,QAAOF;EACP;AAEF,MAAaK,YAAYX,eAAe,EAAEY,QAAQ,QAAQ,CAAC,CACxDC,eAAeT,YAAY,CAC3BU,QAAQ,OAAO,EAAEC,WAAW;AAE3B,OADYR,aACH,CAACU,QAAc;EACtBC,KAAK;EACLN,QAAQ;EACRG;EACD,CAAC;EACF"}
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { createEnv } from "@t3-oss/env-core";
3
+ //#region src/env.ts
4
+ const clientEnv = createEnv({
5
+ clientPrefix: "VITE_",
6
+ client: {
7
+ VITE_ENTRA_CLIENT_ID: z.string(),
8
+ VITE_ENTRA_TENANT_ID: z.string(),
9
+ VITE_APP_TITLE: z.string(),
10
+ VITE_MUI_LICENSE_KEY: z.string()
11
+ },
12
+ runtimeEnv: import.meta.env,
13
+ emptyStringAsUndefined: true
14
+ });
15
+ const serverEnv = createEnv({
16
+ server: {
17
+ ENTRA_CLIENT_ID: z.string(),
18
+ ENTRA_TENANT_ID: z.string(),
19
+ ENTRA_CLIENT_SECRET: z.string(),
20
+ FILE_BASE_URL: z.string().min(1).optional(),
21
+ APPROVAL_BASE_URL: z.string().min(1).optional(),
22
+ PS_BASE_URL: z.string().min(1).optional(),
23
+ EMAIL_BASE_URL: z.string().min(1).optional()
24
+ },
25
+ runtimeEnv: process.env,
26
+ emptyStringAsUndefined: true
27
+ });
28
+ //#endregion
29
+ export { serverEnv as n, clientEnv as t };
30
+
31
+ //# sourceMappingURL=env-Dgbk8SQN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-Dgbk8SQN.js","names":["createEnv","z","clientEnv","clientPrefix","client","VITE_ENTRA_CLIENT_ID","string","VITE_ENTRA_TENANT_ID","VITE_APP_TITLE","VITE_MUI_LICENSE_KEY","runtimeEnv","import","meta","env","emptyStringAsUndefined","serverEnv","server","ENTRA_CLIENT_ID","ENTRA_TENANT_ID","ENTRA_CLIENT_SECRET","FILE_BASE_URL","min","optional","APPROVAL_BASE_URL","PS_BASE_URL","EMAIL_BASE_URL","process"],"sources":["../src/env.ts"],"sourcesContent":["import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const clientEnv = createEnv({\n clientPrefix: \"VITE_\",\n client: {\n VITE_ENTRA_CLIENT_ID: z.string(),\n VITE_ENTRA_TENANT_ID: z.string(),\n VITE_APP_TITLE: z.string(),\n VITE_MUI_LICENSE_KEY: z.string(),\n },\n runtimeEnv: import.meta.env,\n emptyStringAsUndefined: true,\n});\n\nexport const serverEnv = createEnv({\n server: {\n ENTRA_CLIENT_ID: z.string(),\n ENTRA_TENANT_ID: z.string(),\n ENTRA_CLIENT_SECRET: z.string(),\n FILE_BASE_URL: z.string().min(1).optional(),\n APPROVAL_BASE_URL: z.string().min(1).optional(),\n PS_BASE_URL: z.string().min(1).optional(),\n EMAIL_BASE_URL: z.string().min(1).optional(),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n});\n"],"mappings":";;;AAGA,MAAaE,YAAYF,UAAU;CACjCG,cAAc;CACdC,QAAQ;EACNC,sBAAsBJ,EAAEK,QAAQ;EAChCC,sBAAsBN,EAAEK,QAAQ;EAChCE,gBAAgBP,EAAEK,QAAQ;EAC1BG,sBAAsBR,EAAEK,QAAO;EAChC;CACDI,YAAYC,OAAOC,KAAKC;CACxBC,wBAAwB;CACzB,CAAC;AAEF,MAAaC,YAAYf,UAAU;CACjCgB,QAAQ;EACNC,iBAAiBhB,EAAEK,QAAQ;EAC3BY,iBAAiBjB,EAAEK,QAAQ;EAC3Ba,qBAAqBlB,EAAEK,QAAQ;EAC/Bc,eAAenB,EAAEK,QAAQ,CAACe,IAAI,EAAE,CAACC,UAAU;EAC3CC,mBAAmBtB,EAAEK,QAAQ,CAACe,IAAI,EAAE,CAACC,UAAU;EAC/CE,aAAavB,EAAEK,QAAQ,CAACe,IAAI,EAAE,CAACC,UAAU;EACzCG,gBAAgBxB,EAAEK,QAAQ,CAACe,IAAI,EAAE,CAACC,UAAS;EAC5C;CACDZ,YAAYgB,QAAQb;CACpBC,wBAAwB;CACzB,CAAC"}
@@ -0,0 +1,151 @@
1
+ import { n as serverEnv } from "./env-Dgbk8SQN.js";
2
+ import { t as getAppToken } from "./msalServer-coQaBOlr.js";
3
+ import { t as FileMetaSchema } from "./FileMeta--27aYkPB.js";
4
+ import { z } from "zod";
5
+ import { createServerFn, createServerOnlyFn } from "@tanstack/react-start";
6
+ import axios from "axios";
7
+ import { uuidv7 } from "uuidv7";
8
+ import { Upload } from "tus-js-client";
9
+ //#region src/queries/server/externalApi.ts
10
+ function createExternalApi(baseURL, scopeKey) {
11
+ const api = axios.create({ baseURL });
12
+ api.interceptors.request.use(async (config) => {
13
+ const accessToken = await getAppToken(scopeKey);
14
+ config.headers.set("Authorization", `Bearer ${accessToken}`);
15
+ return config;
16
+ });
17
+ return api;
18
+ }
19
+ //#endregion
20
+ //#region src/queries/server/file.ts
21
+ let fileApi = null;
22
+ const getFileApi = createServerOnlyFn(() => {
23
+ const baseUrl = serverEnv.FILE_BASE_URL;
24
+ if (!baseUrl) throw new Error("FILE_BASE_URL is not defined in server environment variables.");
25
+ fileApi ??= createExternalApi(baseUrl, "file");
26
+ return fileApi;
27
+ });
28
+ const GetFileMetasSchema = z.object({
29
+ appName: z.string().min(1).max(255),
30
+ subId: z.uuid()
31
+ });
32
+ const FileSchema = z.object({
33
+ appName: z.string().min(1).max(255),
34
+ id: z.uuid()
35
+ });
36
+ const UpdateFileMetaSchema = FileMetaSchema.extend({ fileName: z.string().min(1).max(255) });
37
+ const DeleteFileSchema = FileSchema;
38
+ const BatchDeleteFilesSchema = GetFileMetasSchema;
39
+ const UploadFileMetaSchema = z.object({
40
+ appName: z.string().min(1).max(255),
41
+ subId: z.uuid(),
42
+ file: z.instanceof(File)
43
+ });
44
+ const getFileMetas = createServerFn({ method: "GET" }).inputValidator(GetFileMetasSchema).handler(async ({ data }) => {
45
+ const api = getFileApi();
46
+ const queryParams = new URLSearchParams();
47
+ queryParams.append("appName", data.appName);
48
+ queryParams.append("subId", data.subId);
49
+ return api.request({
50
+ url: `/v1/meta?${queryParams.toString()}`,
51
+ method: "GET"
52
+ }).then((r) => r.data);
53
+ });
54
+ const getFileThumbnail = createServerFn({ method: "GET" }).inputValidator(FileSchema).handler(async ({ data }) => {
55
+ const api = getFileApi();
56
+ const queryParams = new URLSearchParams();
57
+ queryParams.append("appName", data.appName);
58
+ queryParams.append("id", data.id);
59
+ const response = await api.request({
60
+ url: `/v1/thumbnail?${queryParams.toString()}`,
61
+ method: "GET",
62
+ responseType: "arraybuffer"
63
+ });
64
+ return new Response(response.data, { headers: { "Content-Type": response.headers["content-type"] } });
65
+ });
66
+ const getFile = createServerFn({ method: "GET" }).inputValidator(FileSchema).handler(async ({ data }) => {
67
+ const api = getFileApi();
68
+ const queryParams = new URLSearchParams();
69
+ queryParams.append("appName", data.appName);
70
+ queryParams.append("id", data.id);
71
+ const response = await api.request({
72
+ url: `/v1?${queryParams.toString()}`,
73
+ method: "GET",
74
+ responseType: "arraybuffer"
75
+ });
76
+ return new Response(response.data, { headers: { "Content-Type": response.headers["content-type"] } });
77
+ });
78
+ const downloadFile = createServerFn({ method: "GET" }).inputValidator(FileSchema).handler(async ({ data }) => {
79
+ const api = getFileApi();
80
+ const queryParams = new URLSearchParams();
81
+ queryParams.append("appName", data.appName);
82
+ queryParams.append("id", data.id);
83
+ const response = await api.request({
84
+ url: `/v1/download?${queryParams.toString()}`,
85
+ method: "GET",
86
+ responseType: "arraybuffer"
87
+ });
88
+ return new Response(response.data, { headers: { "Content-Type": response.headers["content-type"] } });
89
+ });
90
+ const updateFileMeta = createServerFn({ method: "POST" }).inputValidator(UpdateFileMetaSchema).handler(async ({ data }) => {
91
+ const api = getFileApi();
92
+ const queryParams = new URLSearchParams();
93
+ queryParams.append("appName", data.appName);
94
+ queryParams.append("id", data.id);
95
+ return api.request({
96
+ url: `/v1/meta?${queryParams.toString()}`,
97
+ method: "PUT",
98
+ data
99
+ }).then((r) => r.data);
100
+ });
101
+ const deleteFile = createServerFn({ method: "POST" }).inputValidator(DeleteFileSchema).handler(async ({ data }) => {
102
+ const api = getFileApi();
103
+ const queryParams = new URLSearchParams();
104
+ queryParams.append("appName", data.appName);
105
+ queryParams.append("id", data.id);
106
+ return api.request({
107
+ url: `/v1?${queryParams.toString()}`,
108
+ method: "DELETE"
109
+ }).then((r) => r.data);
110
+ });
111
+ const batchDeleteFiles = createServerFn({ method: "POST" }).inputValidator(BatchDeleteFilesSchema).handler(async ({ data }) => {
112
+ const api = getFileApi();
113
+ const queryParams = new URLSearchParams();
114
+ queryParams.append("appName", data.appName);
115
+ queryParams.append("subId", data.subId);
116
+ return api.request({
117
+ url: `/v1?${queryParams.toString()}`,
118
+ method: "DELETE"
119
+ }).then((r) => r.data);
120
+ });
121
+ const uploadFile = createServerFn({ method: "POST" }).inputValidator(UploadFileMetaSchema).handler(async ({ data }) => {
122
+ const accessToken = await getAppToken("file");
123
+ const buffer = Buffer.from(await data.file.arrayBuffer());
124
+ const id = uuidv7();
125
+ await new Promise((resolve, reject) => {
126
+ new Upload(buffer, {
127
+ endpoint: `${serverEnv.FILE_BASE_URL}/v1/upload`,
128
+ chunkSize: 1048576,
129
+ metadata: {
130
+ id,
131
+ appName: data.appName,
132
+ subId: data.subId,
133
+ fileName: data.file.name,
134
+ fileExtension: data.file.type
135
+ },
136
+ headers: { Authorization: `Bearer ${accessToken}` },
137
+ onError: reject,
138
+ onSuccess: () => resolve()
139
+ }).start();
140
+ });
141
+ return {
142
+ id,
143
+ appName: data.appName,
144
+ subId: data.subId,
145
+ fileName: data.file.name
146
+ };
147
+ });
148
+ //#endregion
149
+ export { batchDeleteFiles as a, getFile as c, updateFileMeta as d, uploadFile as f, UploadFileMetaSchema as i, getFileMetas as l, GetFileMetasSchema as n, deleteFile as o, createExternalApi as p, UpdateFileMetaSchema as r, downloadFile as s, FileSchema as t, getFileThumbnail as u };
150
+
151
+ //# sourceMappingURL=file-BHdm6ob1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-BHdm6ob1.js","names":["AxiosInstance","axios","scopes","definedScopes","getAppToken","ScopeKey","createExternalApi","baseURL","scopeKey","api","create","interceptors","request","use","config","accessToken","headers","set","createServerFn","createServerOnlyFn","AxiosInstance","Upload","uuidv7","z","serverEnv","getAppToken","FileMeta","FileMetaSchema","createExternalApi","fileApi","getFileApi","baseUrl","FILE_BASE_URL","Error","GetFileMetasSchema","object","appName","string","min","max","subId","uuid","FileSchema","id","UpdateFileMetaSchema","extend","fileName","DeleteFileSchema","BatchDeleteFilesSchema","UploadFileResult","UploadFileMetaSchema","file","instanceof","File","getFileMetas","method","inputValidator","handler","data","api","queryParams","URLSearchParams","append","request","Array","url","toString","then","r","getFileThumbnail","response","ArrayBuffer","responseType","Response","headers","getFile","downloadFile","updateFileMeta","deleteFile","batchDeleteFiles","uploadFile","Promise","accessToken","buffer","Buffer","from","arrayBuffer","resolve","reject","upload","endpoint","chunkSize","metadata","name","fileExtension","type","Authorization","onError","onSuccess","start"],"sources":["../src/queries/server/externalApi.ts","../src/queries/server/file.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\nimport axios from \"axios\";\nimport type { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { getAppToken } from \"~/lib/auth/msalServer\";\n\ntype ScopeKey = keyof typeof definedScopes;\n\nexport function createExternalApi(baseURL: string, scopeKey: ScopeKey): AxiosInstance {\n const api = axios.create({ baseURL });\n\n api.interceptors.request.use(async (config) => {\n const accessToken = await getAppToken(scopeKey);\n config.headers.set(\"Authorization\", `Bearer ${accessToken}`);\n return config;\n });\n\n return api;\n}\n","import { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\nimport type { AxiosInstance } from \"axios\";\nimport { Upload } from \"tus-js-client\";\nimport { uuidv7 } from \"uuidv7\";\nimport { z } from \"zod\";\nimport { serverEnv } from \"~/env\";\nimport { getAppToken } from \"~/lib/auth/msalServer\";\nimport type { FileMeta } from \"~/models/file/FileMeta\";\nimport { FileMetaSchema } from \"~/models/file/FileMeta\";\nimport { createExternalApi } from \"~/queries/server/externalApi\";\n\nlet fileApi: AxiosInstance | null = null;\nconst getFileApi = createServerOnlyFn((): AxiosInstance => {\n const baseUrl = serverEnv.FILE_BASE_URL;\n if (!baseUrl) throw new Error(\"FILE_BASE_URL is not defined in server environment variables.\");\n fileApi ??= createExternalApi(baseUrl, \"file\");\n return fileApi;\n});\n\nexport const GetFileMetasSchema = z.object({\n appName: z.string().min(1).max(255),\n subId: z.uuid(),\n});\n\nexport const FileSchema = z.object({\n appName: z.string().min(1).max(255),\n id: z.uuid(),\n});\n\nexport const UpdateFileMetaSchema = FileMetaSchema.extend({\n fileName: z.string().min(1).max(255),\n});\n\nconst DeleteFileSchema = FileSchema;\n\nconst BatchDeleteFilesSchema = GetFileMetasSchema;\n\nexport interface UploadFileResult {\n id: string;\n appName: string;\n subId: string;\n fileName: string;\n}\n\nexport const UploadFileMetaSchema = z.object({\n appName: z.string().min(1).max(255),\n subId: z.uuid(),\n file: z.instanceof(File),\n});\n\nexport const getFileMetas = createServerFn({ method: \"GET\" })\n .inputValidator(GetFileMetasSchema)\n .handler(async ({ data }) => {\n const api = getFileApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", data.appName);\n queryParams.append(\"subId\", data.subId);\n\n return api\n .request<Array<FileMeta>>({\n url: `/v1/meta?${queryParams.toString()}`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getFileThumbnail = createServerFn({ method: \"GET\" })\n .inputValidator(FileSchema)\n .handler(async ({ data }) => {\n const api = getFileApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", data.appName);\n queryParams.append(\"id\", data.id);\n\n const response = await api.request<ArrayBuffer>({\n url: `/v1/thumbnail?${queryParams.toString()}`,\n method: \"GET\",\n responseType: \"arraybuffer\",\n });\n\n return new Response(response.data, {\n headers: {\n \"Content-Type\": response.headers[\"content-type\"] as string,\n },\n });\n });\n\nexport const getFile = createServerFn({ method: \"GET\" })\n .inputValidator(FileSchema)\n .handler(async ({ data }) => {\n const api = getFileApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", data.appName);\n queryParams.append(\"id\", data.id);\n\n const response = await api.request<ArrayBuffer>({\n url: `/v1?${queryParams.toString()}`,\n method: \"GET\",\n responseType: \"arraybuffer\",\n });\n\n return new Response(response.data, {\n headers: {\n \"Content-Type\": response.headers[\"content-type\"] as string,\n },\n });\n });\n\nexport const downloadFile = createServerFn({ method: \"GET\" })\n .inputValidator(FileSchema)\n .handler(async ({ data }) => {\n const api = getFileApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", data.appName);\n queryParams.append(\"id\", data.id);\n\n const response = await api.request<ArrayBuffer>({\n url: `/v1/download?${queryParams.toString()}`,\n method: \"GET\",\n responseType: \"arraybuffer\",\n });\n\n return new Response(response.data, {\n headers: {\n \"Content-Type\": response.headers[\"content-type\"] as string,\n },\n });\n });\n\nexport const updateFileMeta = createServerFn({ method: \"POST\" })\n .inputValidator(UpdateFileMetaSchema)\n .handler(async ({ data }) => {\n const api = getFileApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", data.appName);\n queryParams.append(\"id\", data.id);\n\n return api\n .request({ url: `/v1/meta?${queryParams.toString()}`, method: \"PUT\", data })\n .then((r) => r.data);\n });\n\nexport const deleteFile = createServerFn({ method: \"POST\" })\n .inputValidator(DeleteFileSchema)\n .handler(async ({ data }) => {\n const api = getFileApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", data.appName);\n queryParams.append(\"id\", data.id);\n\n return api\n .request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" })\n .then((r) => r.data);\n });\n\nexport const batchDeleteFiles = createServerFn({ method: \"POST\" })\n .inputValidator(BatchDeleteFilesSchema)\n .handler(async ({ data }) => {\n const api = getFileApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", data.appName);\n queryParams.append(\"subId\", data.subId);\n\n return api\n .request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" })\n .then((r) => r.data);\n });\n\nexport const uploadFile = createServerFn({ method: \"POST\" })\n .inputValidator(UploadFileMetaSchema)\n .handler(async ({ data }): Promise<UploadFileResult> => {\n const accessToken = await getAppToken(\"file\");\n const buffer = Buffer.from(await data.file.arrayBuffer());\n const id = uuidv7();\n\n await new Promise<void>((resolve, reject) => {\n const upload = new Upload(buffer, {\n endpoint: `${serverEnv.FILE_BASE_URL}/v1/upload`,\n chunkSize: 1_048_576,\n metadata: {\n id,\n appName: data.appName,\n subId: data.subId,\n fileName: data.file.name,\n fileExtension: data.file.type,\n },\n headers: { Authorization: `Bearer ${accessToken}` },\n onError: reject,\n onSuccess: () => resolve(),\n });\n upload.start();\n });\n\n return { id, appName: data.appName, subId: data.subId, fileName: data.file.name };\n });\n"],"mappings":";;;;;;;;;AAOA,SAAgBM,kBAAkBC,SAAiBC,UAAmC;CACpF,MAAMC,MAAMR,MAAMS,OAAO,EAAEH,SAAS,CAAC;AAErCE,KAAIE,aAAaC,QAAQC,IAAI,OAAOC,WAAW;EAC7C,MAAMC,cAAc,MAAM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EAAEC,WAAW;CAC3B,MAAMC,MAAM7B,YAAY;CACxB,MAAM8B,cAAc,IAAIC,iBAAiB;AACzCD,aAAYE,OAAO,WAAWJ,KAAKtB,QAAQ;AAC3CwB,aAAYE,OAAO,SAASJ,KAAKlB,MAAM;AAEvC,QAAOmB,IACJI,QAAQ;EAAEE,KAAK,OAAOL,YAAYM,UAAU;EAAIX,QAAQ;EAAU,CAAC,CACnEY,MAAMC,MAAMA,EAAEV,KAAK;EACtB;AAEJ,MAAasB,aAAa9D,eAAe,EAAEqC,QAAQ,QAAQ,CAAC,CACzDC,eAAeN,qBAAqB,CACpCO,QAAQ,OAAO,EAAEC,WAAsC;CACtD,MAAMwB,cAAc,MAAMzD,YAAY,OAAO;CAC7C,MAAM0D,SAASC,OAAOC,KAAK,MAAM3B,KAAKP,KAAKmC,aAAa,CAAC;CACzD,MAAM3C,KAAKrB,QAAQ;AAEnB,OAAM,IAAI2D,SAAeM,SAASC,WAAW;AAe3CC,MAdmBpE,OAAO8D,QAAQ;GAChCO,UAAU,GAAGlE,UAAUQ,cAAa;GACpC2D,WAAW;GACXC,UAAU;IACRjD;IACAP,SAASsB,KAAKtB;IACdI,OAAOkB,KAAKlB;IACZM,UAAUY,KAAKP,KAAK0C;IACpBC,eAAepC,KAAKP,KAAK4C;IAC1B;GACDrB,SAAS,EAAEsB,eAAe,UAAUd,eAAe;GACnDe,SAAST;GACTU,iBAAiBX,SAAQ;GAC1B,CACK,CAACY,OAAO;GACd;AAEF,QAAO;EAAExD;EAAIP,SAASsB,KAAKtB;EAASI,OAAOkB,KAAKlB;EAAOM,UAAUY,KAAKP,KAAK0C;EAAM;EACjF"}
@@ -0,0 +1,100 @@
1
+ import { t as queryClient } from "./queryClient-1OJ5Va3i.js";
2
+ import { a as batchDeleteFiles, c as getFile, d as updateFileMeta, f as uploadFile, l as getFileMetas, o as deleteFile, s as downloadFile, u as getFileThumbnail } from "./file-BHdm6ob1.js";
3
+ import { mutationOptions, queryOptions } from "@tanstack/react-query";
4
+ import saveAs from "file-saver";
5
+ //#region src/queries/client/file.ts
6
+ const QUERY_KEY = "file";
7
+ const HOUR = 1e3 * 60 * 60;
8
+ const baseOptions = {
9
+ staleTime: HOUR,
10
+ gcTime: HOUR,
11
+ refetchOnWindowFocus: false
12
+ };
13
+ async function responseToObjectUrl(response) {
14
+ const blob = await response.blob();
15
+ return URL.createObjectURL(blob);
16
+ }
17
+ const fileMetasQueryOptions = (params) => queryOptions({
18
+ queryKey: [
19
+ QUERY_KEY,
20
+ "meta",
21
+ params.appName,
22
+ params.subId
23
+ ],
24
+ queryFn: () => getFileMetas({ data: params }),
25
+ ...baseOptions
26
+ });
27
+ const fileThumbnailQueryOptions = (params) => queryOptions({
28
+ queryKey: [
29
+ QUERY_KEY,
30
+ "thumbnail",
31
+ params.appName,
32
+ params.id
33
+ ],
34
+ queryFn: async () => responseToObjectUrl(await getFileThumbnail({ data: params })),
35
+ enabled: !!params.id,
36
+ ...baseOptions
37
+ });
38
+ const fileQueryOptions = (params) => queryOptions({
39
+ queryKey: [
40
+ QUERY_KEY,
41
+ params.appName,
42
+ params.id
43
+ ],
44
+ queryFn: async () => responseToObjectUrl(await getFile({ data: params })),
45
+ enabled: !!params.id,
46
+ ...baseOptions
47
+ });
48
+ const downloadFileMutationOptions = () => mutationOptions({ mutationFn: async (data) => {
49
+ saveAs(await (await downloadFile({ data })).blob(), `${data.fileName}.${data.fileExtension}`);
50
+ } });
51
+ const openFileMutationOptions = () => mutationOptions({ mutationFn: async (data) => {
52
+ const response = await getFile({ data });
53
+ window.open(await responseToObjectUrl(response));
54
+ } });
55
+ const updateFileMetaMutationOptions = () => mutationOptions({
56
+ mutationFn: (data) => updateFileMeta({ data }),
57
+ onSettled: () => queryClient.invalidateQueries({
58
+ queryKey: [QUERY_KEY, "meta"],
59
+ exact: false
60
+ })
61
+ });
62
+ const deleteFileMutationOptions = () => mutationOptions({
63
+ mutationFn: (data) => deleteFile({ data }),
64
+ onSettled: () => queryClient.invalidateQueries({
65
+ queryKey: [QUERY_KEY, "meta"],
66
+ exact: false
67
+ })
68
+ });
69
+ const batchDeleteFilesMutationOptions = () => mutationOptions({
70
+ mutationFn: (data) => batchDeleteFiles({ data }),
71
+ onSettled: () => queryClient.invalidateQueries({
72
+ queryKey: [QUERY_KEY, "meta"],
73
+ exact: false
74
+ })
75
+ });
76
+ const useUploadFile = ({ onSuccess, onError } = {}) => {
77
+ const mutate = async (data) => {
78
+ if (!data.subId) throw new Error("subId is required for file upload");
79
+ try {
80
+ const result = await uploadFile({ data });
81
+ queryClient.invalidateQueries({
82
+ queryKey: [
83
+ QUERY_KEY,
84
+ "meta",
85
+ data.appName,
86
+ data.subId
87
+ ],
88
+ exact: false
89
+ });
90
+ onSuccess?.(result);
91
+ } catch (error) {
92
+ onError?.(error);
93
+ }
94
+ };
95
+ return { mutate };
96
+ };
97
+ //#endregion
98
+ export { fileQueryOptions as a, updateFileMetaMutationOptions as c, fileMetasQueryOptions as i, useUploadFile as l, deleteFileMutationOptions as n, fileThumbnailQueryOptions as o, downloadFileMutationOptions as r, openFileMutationOptions as s, batchDeleteFilesMutationOptions as t };
99
+
100
+ //# sourceMappingURL=file-DNF9kxdN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-DNF9kxdN.js","names":["mutationOptions","queryOptions","saveAs","z","queryClient","batchDeleteFiles","deleteFile","downloadFile","getFile","getFileMetas","getFileThumbnail","updateFileMeta","uploadFile","FileSchema","GetFileMetasSchema","UpdateFileMetaSchema","UploadFileMetaSchema","QUERY_KEY","HOUR","baseOptions","staleTime","gcTime","refetchOnWindowFocus","responseToObjectUrl","response","Response","Promise","blob","URL","createObjectURL","fileMetasQueryOptions","params","input","queryKey","appName","subId","queryFn","data","fileThumbnailQueryOptions","id","enabled","fileQueryOptions","downloadFileMutationOptions","mutationFn","fileName","fileExtension","openFileMutationOptions","Error","window","open","updateFileMetaMutationOptions","onSettled","invalidateQueries","exact","deleteFileMutationOptions","batchDeleteFilesMutationOptions","UseUploadFileProps","onSuccess","result","Awaited","ReturnType","onError","error","useUploadFile","mutate"],"sources":["../src/queries/client/file.ts"],"sourcesContent":["import { mutationOptions, queryOptions } from \"@tanstack/react-query\";\nimport saveAs from \"file-saver\";\nimport type { z } from \"zod\";\nimport { queryClient } from \"~/lib/queryClient\";\nimport {\n batchDeleteFiles,\n deleteFile,\n downloadFile,\n getFile,\n getFileMetas,\n getFileThumbnail,\n updateFileMeta,\n uploadFile,\n} from \"~/queries/server/file\";\nimport type {\n FileSchema,\n GetFileMetasSchema,\n UpdateFileMetaSchema,\n UploadFileMetaSchema,\n} from \"~/queries/server/file\";\n\nconst QUERY_KEY = \"file\";\nconst HOUR = 1000 * 60 * 60;\n\nconst baseOptions = {\n staleTime: HOUR,\n gcTime: HOUR,\n refetchOnWindowFocus: false,\n};\n\nasync function responseToObjectUrl(response: Response): Promise<string> {\n const blob = await response.blob();\n return URL.createObjectURL(blob);\n}\n\nexport const fileMetasQueryOptions = (params: z.input<typeof GetFileMetasSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"meta\", params.appName, params.subId],\n queryFn: () => getFileMetas({ data: params }),\n ...baseOptions,\n });\n\nexport const fileThumbnailQueryOptions = (params: z.input<typeof FileSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"thumbnail\", params.appName, params.id],\n queryFn: async () => responseToObjectUrl(await getFileThumbnail({ data: params })),\n enabled: !!params.id,\n ...baseOptions,\n });\n\nexport const fileQueryOptions = (params: z.input<typeof FileSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, params.appName, params.id],\n queryFn: async () => responseToObjectUrl(await getFile({ data: params })),\n enabled: !!params.id,\n ...baseOptions,\n });\n\nexport const downloadFileMutationOptions = () =>\n mutationOptions({\n mutationFn: async (\n data: z.input<typeof FileSchema> & { fileName: string; fileExtension: string },\n ) => {\n const response = await downloadFile({ data });\n saveAs(await response.blob(), `${data.fileName}.${data.fileExtension}`);\n },\n });\n\nexport const openFileMutationOptions = () =>\n mutationOptions<void, Error, z.input<typeof FileSchema>>({\n mutationFn: async (data) => {\n const response = await getFile({ data });\n window.open(await responseToObjectUrl(response));\n },\n });\n\nexport const updateFileMetaMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof UpdateFileMetaSchema>) => updateFileMeta({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, \"meta\"], exact: false }),\n });\n\nexport const deleteFileMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof FileSchema>) => deleteFile({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, \"meta\"], exact: false }),\n });\n\nexport const batchDeleteFilesMutationOptions = () =>\n mutationOptions({\n mutationFn: (data: z.input<typeof GetFileMetasSchema>) => batchDeleteFiles({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, \"meta\"], exact: false }),\n });\n\ninterface UseUploadFileProps {\n onSuccess?: (result: Awaited<ReturnType<typeof uploadFile>>) => void;\n onError?: (error: Error) => void;\n}\n\nexport const useUploadFile = ({ onSuccess, onError }: UseUploadFileProps = {}) => {\n const mutate = async (data: z.input<typeof UploadFileMetaSchema>) => {\n if (!data.subId) throw new Error(\"subId is required for file upload\");\n\n try {\n const result = await uploadFile({ data });\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEY, \"meta\", data.appName, data.subId],\n exact: false,\n });\n onSuccess?.(result);\n } catch (error) {\n onError?.(error as Error);\n }\n };\n\n return { mutate };\n};\n"],"mappings":";;;;;AAqBA,MAAMiB,YAAY;AAClB,MAAMC,OAAO,MAAO,KAAK;AAEzB,MAAMC,cAAc;CAClBC,WAAWF;CACXG,QAAQH;CACRI,sBAAsB;CACvB;AAED,eAAeC,oBAAoBC,UAAqC;CACtE,MAAMG,OAAO,MAAMH,SAASG,MAAM;AAClC,QAAOC,IAAIC,gBAAgBF,KAAK;;AAGlC,MAAaG,yBAAyBC,WACpC9B,aAAa;CACXgC,UAAU;EAAChB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;CACtEc,iBAAiB/C,YAAYgD,kBAAkB;EAAEnB,UAAU,CAAChB,WAAW,OAAO;EAAEoC,OAAO;EAAO,CAAA;CAC/F,CAAC;AAEJ,MAAaE,wCACXvD,gBAAgB;CACd2C,aAAaN,SAA6ChC,iBAAiB,EAAEgC,MAAM,CAAC;CACpFc,iBAAiB/C,YAAYgD,kBAAkB;EAAEnB,UAAU,CAAChB,WAAW,OAAO;EAAEoC,OAAO;EAAO,CAAA;CAC/F,CAAC;AAOJ,MAAaU,iBAAiB,EAAEN,WAAWI,YAAgC,EAAE,KAAK;CAChF,MAAMG,SAAS,OAAO3B,SAA+C;AACnE,MAAI,CAACA,KAAKF,MAAO,OAAM,IAAIY,MAAM,oCAAoC;AAErE,MAAI;GACF,MAAMW,SAAS,MAAM9C,WAAW,EAAEyB,MAAM,CAAC;AACzCjC,eAAYgD,kBAAkB;IAC5BnB,UAAU;KAAChB;KAAW;KAAQoB,KAAKH;KAASG,KAAKF;KAAM;IACvDkB,OAAO;IACR,CAAC;AACFI,eAAYC,OAAO;WACZI,OAAO;AACdD,aAAUC,MAAe;;;AAI7B,QAAO,EAAEE,QAAQ"}
package/dist/hooks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as FormOmittedProps } from "./utils-BBQ5S6oM.js";
1
+ import { t as FormOmittedProps } from "./utils-BM8-Efdl.js";
2
2
  import { AutocompleteProps, ButtonProps, CheckboxProps, RadioGroupProps, SliderProps, SwitchProps, TextFieldProps } from "@mui/material";
3
3
  import * as _$react from "react";
4
4
  import { FC, ReactNode } from "react";
package/dist/hooks.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as getFieldStatus } from "./utils-CqQKSaSs.js";
2
- import { t as NotificationContext } from "./NotificationContext-DBTYc5z-.js";
3
- import { t as useDialogs } from "./useDialogs-BaxhulU9.js";
1
+ import { a as getFieldStatus } from "./utils-B7LPctqx.js";
2
+ import { t as NotificationContext } from "./NotificationContext-FQRaNZRx.js";
3
+ import { t as useDialogs } from "./useDialogs-BQEh6of8.js";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import { Autocomplete, Button, Checkbox, FormControl, FormControlLabel, FormHelperText, FormLabel, Radio, RadioGroup, Slider, Switch, TextField } from "@mui/material";
6
6
  import { useContext, useEffect, useRef } from "react";