wcz-layout 10.0.0 → 10.1.2
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/dist/{AggregatedCell-BtKC5-m6.mjs → AggregatedCell-C7nAQyMO.mjs} +15 -2
- package/dist/AggregatedCell-C7nAQyMO.mjs.map +1 -0
- package/dist/{Approval-C-hF4jbT.mjs → Approval-DoD-GRRH.mjs} +18 -14
- package/dist/Approval-DoD-GRRH.mjs.map +1 -0
- package/dist/{Employee-DbdStvU0.d.mts → Employee-N9fRSnIl.d.mts} +30 -14
- package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
- package/dist/{LayoutTable-4DLs-NI-.d.mts → LayoutTable-DX9IaO8V.d.mts} +205 -197
- package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -1
- package/dist/{approval-DFExxyAJ.mjs → approval-DiNOXd4B.mjs} +4 -4
- package/dist/approval-DiNOXd4B.mjs.map +1 -0
- package/dist/auth.mjs +4 -4
- package/dist/components.d.mts +1 -1
- package/dist/components.mjs +47 -21
- package/dist/components.mjs.map +1 -1
- package/dist/{createApi-CLYWCzR2.mjs → createApi-DGJJ4I_R.mjs} +3 -3
- package/dist/{createApi-CLYWCzR2.mjs.map → createApi-DGJJ4I_R.mjs.map} +1 -1
- package/dist/data/client.d.mts +183 -64
- package/dist/data/client.mjs +5 -5
- package/dist/data/client.mjs.map +1 -1
- package/dist/data/server.d.mts +1 -1
- package/dist/data/server.mjs +4 -4
- package/dist/{file-aSQto2rw.mjs → file-C14fhUeg.mjs} +4 -4
- package/dist/{file-aSQto2rw.mjs.map → file-C14fhUeg.mjs.map} +1 -1
- package/dist/{file-CZwQfvTU.mjs → file-C5BOj1q8.mjs} +4 -4
- package/dist/file-C5BOj1q8.mjs.map +1 -0
- package/dist/hooks.d.mts +1 -1
- package/dist/hooks.mjs +461 -452
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.mjs +2 -2
- package/dist/middleware.mjs.map +1 -1
- package/dist/models.d.mts +22 -2
- package/dist/models.mjs +1 -1
- package/dist/{peoplesoft-BY_75WTS.d.mts → peoplesoft-BIdTNshE.d.mts} +2 -3
- package/dist/{peoplesoft-CQnc01Hc.mjs → peoplesoft-BkJMCcHb.mjs} +3 -3
- package/dist/peoplesoft-BkJMCcHb.mjs.map +1 -0
- package/dist/{providers-Dbl95AxR.mjs → providers-DrairEO2.mjs} +2 -2
- package/dist/providers-DrairEO2.mjs.map +1 -0
- package/dist/{tokens-D8CVIFTb.mjs → tokens-BLRreL1j.mjs} +3 -3
- package/dist/tokens-BLRreL1j.mjs.map +1 -0
- package/dist/{utils-KaM5VMTJ.mjs → utils-BUpDoqme.mjs} +13 -13
- package/dist/utils-BUpDoqme.mjs.map +1 -0
- package/dist/utils.mjs +1 -1
- package/package.json +16 -14
- package/skills/ai/SKILL.md +59 -0
- package/skills/client-db/SKILL.md +47 -43
- package/skills/db-schema/SKILL.md +6 -0
- package/skills/dialogs/SKILL.md +8 -6
- package/skills/forms/SKILL.md +19 -1
- package/skills/general/SKILL.md +21 -19
- package/skills/general/references/exports.md +6 -3
- package/skills/migrations/versions/migrate-v10-to-v11.md +1 -0
- package/skills/migrations/versions/migrate-v9-to-v10.md +26 -25
- package/skills/routing/SKILL.md +7 -4
- package/skills/server-functions/SKILL.md +8 -5
- package/skills/services/SKILL.md +1 -1
- package/skills/services/docs/approval.md +258 -257
- package/skills/services/docs/peoplesoft.md +4 -0
- package/skills/start/SKILL.md +3 -2
- package/skills/start/steps/02-project-name-setup.md +1 -1
- package/skills/start/steps/07-vault-setup.md +5 -4
- package/skills/table/SKILL.md +20 -31
- package/dist/AggregatedCell-BtKC5-m6.mjs.map +0 -1
- package/dist/Approval-C-hF4jbT.mjs.map +0 -1
- package/dist/approval-DFExxyAJ.mjs.map +0 -1
- package/dist/file-CZwQfvTU.mjs.map +0 -1
- package/dist/peoplesoft-CQnc01Hc.mjs.map +0 -1
- package/dist/providers-Dbl95AxR.mjs.map +0 -1
- package/dist/tokens-D8CVIFTb.mjs.map +0 -1
- package/dist/utils-KaM5VMTJ.mjs.map +0 -1
- package/skills/unslop/SKILL.md +0 -80
- /package/skills/start/steps/{10-gitlab-ci.md → 09-gitlab-ci.md} +0 -0
- /package/skills/start/steps/{09-commit.md → 10-commit.md} +0 -0
package/dist/middleware.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as getProviderByIssuer } from "./providers-
|
|
2
|
-
import { f as getSessionUser, i as buildUser, s as hasPermission } from "./utils-
|
|
1
|
+
import { n as getProviderByIssuer } from "./providers-DrairEO2.mjs";
|
|
2
|
+
import { f as getSessionUser, i as buildUser, s as hasPermission } from "./utils-BUpDoqme.mjs";
|
|
3
3
|
import { z as z$1 } from "zod";
|
|
4
4
|
import { createCsrfMiddleware, createMiddleware } from "@tanstack/react-start";
|
|
5
5
|
import * as jose from "jose";
|
package/dist/middleware.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.mjs","names":["createMiddleware","jose","permissions","getProviderByIssuer","getSessionUser","buildUser","hasPermission","TokenPayload","User","verifyBearer","token","Promise","provider","decodeJwt","iss","Error","payload","jwtVerify","jwks","issuer","audience","id","resolveUser","request","Request","authHeader","headers","get","startsWith","substring","length","error","Response","json","message","status","userMiddleware","server","user","next","context","authMiddleware","permissionKey","middleware","name","createMiddleware","z","validationMiddleware","schema","ZodType","T","server","next","request","json","result","safeParse","success","fieldErrors","flattenError","error","firstFieldName","Object","keys","firstErrorMessage","name","charAt","toUpperCase","slice","message","replace","toLowerCase","Response","status","context","data"],"sources":["../src/middleware/authMiddleware.ts","../src/middleware/validationMiddleware.ts","../src/middleware/csrfMiddleware.ts"],"sourcesContent":["import { createMiddleware } from \"@tanstack/react-start\";\nimport * as jose from \"jose\";\nimport type { permissions } from \"virtual:wcz-layout\";\nimport { getProviderByIssuer } from \"~/lib/auth/providers\";\nimport { getSessionUser } from \"~/lib/auth/user\";\nimport { buildUser, hasPermission } from \"~/lib/utils\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { User } from \"~/models/User\";\n\n/**\n * Verifies a Bearer JWT from a sibling service. The unverified `iss` only selects\n * which provider to check against — the real check pins that provider's JWKS,\n * issuer and (where the provider has one) audience.\n */\nasync function verifyBearer(token: string): Promise<User> {\n const provider = getProviderByIssuer(jose.decodeJwt(token).iss);\n if (!provider) throw new Error(\"Unauthorized: Unknown token issuer\");\n\n const { payload } = await jose.jwtVerify(token, provider.jwks, {\n issuer: provider.issuer,\n audience: provider.audience,\n });\n return buildUser(payload as TokenPayload, provider.id);\n}\n\nasync function resolveUser(request: Request): Promise<User | null> {\n const authHeader = request.headers.get(\"Authorization\");\n\n if (authHeader?.startsWith(\"Bearer \")) {\n try {\n return await verifyBearer(authHeader.substring(\"Bearer \".length));\n } catch (error) {\n throw Response.json(\n { message: error instanceof Error ? error.message : \"Unauthorized: Invalid access token\" },\n { status: 401 },\n );\n }\n }\n\n return getSessionUser();\n}\n\n/**\n * Puts the caller in `context.user` — Bearer or cookie, `null` when anonymous —\n * without requiring one. Deliberately a single instance, not a factory:\n * `flattenMiddlewares` dedupes by object identity, so every middleware that\n * declares this one as a dependency shares one resolution per request.\n */\nexport const userMiddleware = createMiddleware().server<{ user: User | null }>(\n async ({ next, request }) => next({ context: { user: await resolveUser(request) } }),\n);\n\n/**\n * Server-function guard, the counterpart to `requireAuth` on routes.\n *\n * - `authMiddleware()` — 401 unless a user is signed in (cookie or Bearer).\n * - `authMiddleware(\"admin\")` — also 403 unless they hold that permission.\n */\nexport const authMiddleware = (permissionKey?: keyof typeof permissions) =>\n createMiddleware()\n .middleware([userMiddleware])\n .server<{ user: User }>(async ({ next, context: { user } }) => {\n if (!user)\n throw Response.json({ message: \"Unauthorized: User not signed in\" }, { status: 401 });\n\n if (permissionKey && !hasPermission(user, permissionKey))\n throw Response.json(\n { message: `Forbidden: User ${user.name} is not authorized to access this resource` },\n { status: 403 },\n );\n\n return next({ context: { user } });\n });\n","import { createMiddleware } from \"@tanstack/react-start\";\nimport { z } from \"zod\";\n\nexport const validationMiddleware = <T>(schema: z.ZodType<T>) =>\n createMiddleware().server(async ({ next, request }) => {\n const json = await request.json();\n const result = schema.safeParse(json);\n if (!result.success) {\n const { fieldErrors } = z.flattenError(result.error);\n const firstFieldName = Object.keys(fieldErrors)[0];\n const firstErrorMessage = fieldErrors[firstFieldName as keyof typeof fieldErrors]?.[0];\n\n if (firstFieldName && firstErrorMessage) {\n const name = firstFieldName.charAt(0).toUpperCase() + firstFieldName.slice(1);\n const message = firstErrorMessage.replace(/^Invalid input:\\s*/i, \"\").toLowerCase();\n return Response.json({ message: `${name} - ${message}` }, { status: 400 });\n }\n\n return Response.json({ message: \"Validation failed\" }, { status: 400 });\n }\n return await next({ context: { data: result.data } });\n });\n","import { createCsrfMiddleware } from \"@tanstack/react-start\";\n\nexport const csrfMiddleware = createCsrfMiddleware({\n filter: (ctx) => ctx.handlerType === \"serverFn\",\n});\n"],"mappings":";;;;;;;;;;;AAcA,eAAeS,aAAaC,OAA8B;CACxD,MAAME,WAAWT,oBAAoBF,KAAKY,UAAUH,KAAK,CAAC,CAACI,GAAG;CAC9D,IAAI,CAACF,UAAU,MAAM,IAAIG,MAAM,oCAAoC;CAEnE,MAAM,EAAEC,YAAY,MAAMf,KAAKgB,UAAUP,OAAOE,SAASM,MAAM;EAC7DC,QAAQP,SAASO;EACjBC,UAAUR,SAASQ;CACrB,CAAC;CACD,OAAOf,UAAUW,SAAyBJ,SAASS,EAAE;AACvD;AAEA,eAAeC,YAAYC,SAAwC;CACjE,MAAME,aAAaF,QAAQG,QAAQC,IAAI,eAAe;CAEtD,IAAIF,YAAYG,WAAW,SAAS,GAClC,IAAI;EACF,OAAO,MAAMnB,aAAagB,WAAWI,UAAU,CAAgB,CAAC;CAClE,SAASE,OAAO;EACd,MAAMC,SAASC,KACb,EAAEC,SAASH,iBAAi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AAkBM,QAAQ,uBAAuB,EAAE,CAAC,CAACC,YAAY;GACjF,OAAOC,SAASlB,KAAK,EAAEe,SAAS,GAAGJ,KAAI,KAAMI,UAAU,GAAG,EAAEI,QAAQ,IAAI,CAAC;EAC3E;EAEA,OAAOD,SAASlB,KAAK,EAAEe,SAAS,oBAAoB,GAAG,EAAEI,QAAQ,IAAI,CAAC;CACxE;CACA,OAAO,MAAMrB,KAAK,EAAEsB,SAAS,EAAEC,MAAMpB,OAAOoB,KAAK,EAAE,CAAC;AACtD,CAAC;;;ACnBH,MAAa,iBAAiB,qBAAqB,EACjD,SAAS,QAAQ,IAAI,gBAAgB,WACvC,CAAC"}
|
|
1
|
+
{"version":3,"file":"middleware.mjs","names":["createMiddleware","jose","permissions","getProviderByIssuer","getSessionUser","buildUser","hasPermission","TokenPayload","User","verifyBearer","token","Promise","provider","decodeJwt","iss","Error","payload","jwtVerify","jwks","issuer","audience","id","resolveUser","request","Request","authHeader","headers","get","startsWith","substring","length","error","Response","json","message","status","userMiddleware","server","user","next","context","authMiddleware","permissionKey","middleware","name","createMiddleware","z","validationMiddleware","schema","ZodType","T","server","next","request","json","result","safeParse","success","fieldErrors","flattenError","error","firstFieldName","Object","keys","firstErrorMessage","name","charAt","toUpperCase","slice","message","replace","toLowerCase","Response","status","context","data","z"],"sources":["../src/middleware/authMiddleware.ts","../src/middleware/validationMiddleware.ts","../src/middleware/csrfMiddleware.ts"],"sourcesContent":["import { createMiddleware } from \"@tanstack/react-start\";\nimport * as jose from \"jose\";\nimport type { permissions } from \"virtual:wcz-layout\";\nimport { getProviderByIssuer } from \"~/lib/auth/providers\";\nimport { getSessionUser } from \"~/lib/auth/user\";\nimport { buildUser, hasPermission } from \"~/lib/utils\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { User } from \"~/models/User\";\n\n/**\n * Verifies a Bearer JWT from a sibling service. The unverified `iss` only selects\n * which provider to check against — the real check pins that provider's JWKS,\n * issuer and (where the provider has one) audience.\n */\nasync function verifyBearer(token: string): Promise<User> {\n const provider = getProviderByIssuer(jose.decodeJwt(token).iss);\n if (!provider) throw new Error(\"Unauthorized: Unknown token issuer\");\n\n const { payload } = await jose.jwtVerify(token, provider.jwks, {\n issuer: provider.issuer,\n audience: provider.audience,\n });\n return buildUser(payload as TokenPayload, provider.id);\n}\n\nasync function resolveUser(request: Request): Promise<User | null> {\n const authHeader = request.headers.get(\"Authorization\");\n\n if (authHeader?.startsWith(\"Bearer \")) {\n try {\n return await verifyBearer(authHeader.substring(\"Bearer \".length));\n } catch (error) {\n throw Response.json(\n { message: error instanceof Error ? error.message : \"Unauthorized: Invalid access token\" },\n { status: 401 },\n );\n }\n }\n\n return getSessionUser();\n}\n\n/**\n * Puts the caller in `context.user` — Bearer or cookie, `null` when anonymous —\n * without requiring one. Deliberately a single instance, not a factory:\n * `flattenMiddlewares` dedupes by object identity, so every middleware that\n * declares this one as a dependency shares one resolution per request.\n */\nexport const userMiddleware = createMiddleware().server<{ user: User | null }>(\n async ({ next, request }) => next({ context: { user: await resolveUser(request) } }),\n);\n\n/**\n * Server-function guard, the counterpart to `requireAuth` on routes.\n *\n * - `authMiddleware()` — 401 unless a user is signed in (cookie or Bearer).\n * - `authMiddleware(\"admin\")` — also 403 unless they hold that permission.\n */\nexport const authMiddleware = (permissionKey?: keyof typeof permissions) =>\n createMiddleware()\n .middleware([userMiddleware])\n .server<{ user: User }>(async ({ next, context: { user } }) => {\n if (!user)\n throw Response.json({ message: \"Unauthorized: User not signed in\" }, { status: 401 });\n\n if (permissionKey && !hasPermission(user, permissionKey))\n throw Response.json(\n { message: `Forbidden: User ${user.name} is not authorized to access this resource` },\n { status: 403 },\n );\n\n return next({ context: { user } });\n });\n","import { createMiddleware } from \"@tanstack/react-start\";\nimport { z } from \"zod\";\n\nexport const validationMiddleware = <T>(schema: z.ZodType<T>) =>\n createMiddleware().server(async ({ next, request }) => {\n const json = await request.json();\n const result = schema.safeParse(json);\n if (!result.success) {\n const { fieldErrors } = z.flattenError(result.error);\n const firstFieldName = Object.keys(fieldErrors)[0];\n const firstErrorMessage = fieldErrors[firstFieldName as keyof typeof fieldErrors]?.[0];\n\n if (firstFieldName && firstErrorMessage) {\n const name = firstFieldName.charAt(0).toUpperCase() + firstFieldName.slice(1);\n const message = firstErrorMessage.replace(/^Invalid input:\\s*/i, \"\").toLowerCase();\n return Response.json({ message: `${name} - ${message}` }, { status: 400 });\n }\n\n return Response.json({ message: \"Validation failed\" }, { status: 400 });\n }\n return await next({ context: { data: result.data } });\n });\n","import { createCsrfMiddleware } from \"@tanstack/react-start\";\n\nexport const csrfMiddleware = createCsrfMiddleware({\n filter: (ctx) => ctx.handlerType === \"serverFn\",\n});\n"],"mappings":";;;;;;;;;;;AAcA,eAAeS,aAAaC,OAA8B;CACxD,MAAME,WAAWT,oBAAoBF,KAAKY,UAAUH,KAAK,CAAC,CAACI,GAAG;CAC9D,IAAI,CAACF,UAAU,MAAM,IAAIG,MAAM,oCAAoC;CAEnE,MAAM,EAAEC,YAAY,MAAMf,KAAKgB,UAAUP,OAAOE,SAASM,MAAM;EAC7DC,QAAQP,SAASO;EACjBC,UAAUR,SAASQ;CACrB,CAAC;CACD,OAAOf,UAAUW,SAAyBJ,SAASS,EAAE;AACvD;AAEA,eAAeC,YAAYC,SAAwC;CACjE,MAAME,aAAaF,QAAQG,QAAQC,IAAI,eAAe;CAEtD,IAAIF,YAAYG,WAAW,SAAS,GAClC,IAAI;EACF,OAAO,MAAMnB,aAAagB,WAAWI,UAAU,CAAgB,CAAC;CAClE,SAASE,OAAO;EACd,MAAMC,SAASC,KACb,EAAEC,SAASH,iBAAiBhB,QAAQgB,MAAMG,UAAU,qCAAqC,GACzF,EAAEC,QAAQ,IAAI,CAChB;CACF;CAGF,OAAO/B,eAAe;AACxB;;;;;;;AAQA,MAAagC,iBAAiBpC,iBAAiB,CAAC,CAACqC,OAC/C,OAAO,EAAEE,MAAMhB,cAAcgB,KAAK,EAAEC,SAAS,EAAEF,MAAM,MAAMh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,CAAC;CACxE;CACA,OAAO,MAAMrB,KAAK,EAAEsB,SAAS,EAAEC,MAAMpB,OAAOoB,KAAK,EAAE,CAAC;AACtD,CAAC;;;ACnBH,MAAa,iBAAiB,qBAAqB,EACjD,SAAS,QAAQ,IAAI,gBAAgB,WACvC,CAAC"}
|
package/dist/models.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as User, t as ProviderId } from "./User-D4__w1I1.mjs";
|
|
2
2
|
import { n as FileMetaSchema, t as FileMeta } from "./FileMeta-Be9viU7D.mjs";
|
|
3
|
-
import { a as Approval, c as ApproveApprovalSchema, d as CreateApproval, f as CreateApprovalSchema, g as WithdrawApprovalSchema, h as WithdrawApproval, i as DepartmentSchema, l as CancelApproval, m as ResubmitApprovalSchema, n as EmployeeSchema, o as ApprovalSchema, p as ResubmitApproval, r as Department, s as ApproveApproval, t as Employee, u as CancelApprovalSchema } from "./Employee-
|
|
3
|
+
import { a as Approval, c as ApproveApprovalSchema, d as CreateApproval, f as CreateApprovalSchema, g as WithdrawApprovalSchema, h as WithdrawApproval, i as DepartmentSchema, l as CancelApproval, m as ResubmitApprovalSchema, n as EmployeeSchema, o as ApprovalSchema, p as ResubmitApproval, r as Department, s as ApproveApproval, t as Employee, u as CancelApprovalSchema } from "./Employee-N9fRSnIl.mjs";
|
|
4
4
|
import { n as EmailSchema, t as Email } from "./Email-CKUxOURX.mjs";
|
|
5
5
|
import z, { z as z$1 } from "zod";
|
|
6
6
|
//#region src/models/email/EmailAttachment.d.ts
|
|
@@ -131,6 +131,13 @@ export declare const ApprovalFlowSchema: z$1.ZodObject<{
|
|
|
131
131
|
name: string;
|
|
132
132
|
email: string;
|
|
133
133
|
} | undefined;
|
|
134
|
+
proxies: {
|
|
135
|
+
proxy: {
|
|
136
|
+
employeeId: string;
|
|
137
|
+
name: string;
|
|
138
|
+
email: string;
|
|
139
|
+
};
|
|
140
|
+
}[];
|
|
134
141
|
result?: "Approved" | "Cancelled" | "FutureApproval" | "NotAvailable" | "Rejected" | "Skipped" | "WaitingForApproval" | "Withdrawn" | undefined;
|
|
135
142
|
resultDate?: Date | undefined;
|
|
136
143
|
resultComment?: string | undefined;
|
|
@@ -148,6 +155,13 @@ export declare const ApprovalFlowSchema: z$1.ZodObject<{
|
|
|
148
155
|
name: string;
|
|
149
156
|
email: string;
|
|
150
157
|
} | undefined;
|
|
158
|
+
proxies: {
|
|
159
|
+
proxy: {
|
|
160
|
+
employeeId: string;
|
|
161
|
+
name: string;
|
|
162
|
+
email: string;
|
|
163
|
+
};
|
|
164
|
+
}[];
|
|
151
165
|
result?: "Approved" | "Cancelled" | "FutureApproval" | "NotAvailable" | "Rejected" | "Skipped" | "WaitingForApproval" | "Withdrawn" | undefined;
|
|
152
166
|
resultDate?: Date | undefined;
|
|
153
167
|
resultComment?: string | undefined;
|
|
@@ -171,6 +185,13 @@ export declare const ApprovalFlowStepSchema: z$1.ZodObject<{
|
|
|
171
185
|
name: z$1.ZodString;
|
|
172
186
|
email: z$1.ZodEmail;
|
|
173
187
|
}, z$1.core.$strip>>;
|
|
188
|
+
proxies: z$1.ZodArray<z$1.ZodObject<{
|
|
189
|
+
proxy: z$1.ZodObject<{
|
|
190
|
+
employeeId: z$1.ZodString;
|
|
191
|
+
name: z$1.ZodString;
|
|
192
|
+
email: z$1.ZodEmail;
|
|
193
|
+
}, z$1.core.$strip>;
|
|
194
|
+
}, z$1.core.$strip>>;
|
|
174
195
|
result: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodEnum<{
|
|
175
196
|
Approved: "Approved";
|
|
176
197
|
Cancelled: "Cancelled";
|
|
@@ -196,7 +217,6 @@ declare const ApprovalRequestType: z.ZodEnum<{
|
|
|
196
217
|
declare const ApprovalStatus: z.ZodEnum<{
|
|
197
218
|
Approved: "Approved";
|
|
198
219
|
Cancelled: "Cancelled";
|
|
199
|
-
PartiallyApproved: "PartiallyApproved";
|
|
200
220
|
Rejected: "Rejected";
|
|
201
221
|
WaitingForApproval: "WaitingForApproval";
|
|
202
222
|
Withdrawn: "Withdrawn";
|
package/dist/models.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as FileMetaSchema } from "./FileMeta-DDqUju1Y.mjs";
|
|
2
2
|
import { n as EmailAttachmentSchema, t as EmailSchema } from "./Email-BzQQkbe9.mjs";
|
|
3
|
-
import { a as ResubmitApprovalSchema, d as ApprovalFlowSchema, f as ApprovalEmployeeSchema, h as ApprovalCoRequestorSchema, i as CreateApprovalSchema, l as ApprovalFlowStepSchema, m as ApprovalCoRequestorPrincipalSchema, n as ApproveApprovalSchema, o as WithdrawApprovalSchema, p as ApprovalCoRequestorPermissionsSchema, r as CancelApprovalSchema, s as HqApprovalRequestSchema, t as ApprovalSchema } from "./Approval-
|
|
3
|
+
import { a as ResubmitApprovalSchema, d as ApprovalFlowSchema, f as ApprovalEmployeeSchema, h as ApprovalCoRequestorSchema, i as CreateApprovalSchema, l as ApprovalFlowStepSchema, m as ApprovalCoRequestorPrincipalSchema, n as ApproveApprovalSchema, o as WithdrawApprovalSchema, p as ApprovalCoRequestorPermissionsSchema, r as CancelApprovalSchema, s as HqApprovalRequestSchema, t as ApprovalSchema } from "./Approval-DoD-GRRH.mjs";
|
|
4
4
|
import z from "zod";
|
|
5
5
|
//#region src/models/peoplesoft/EmployeeCategoryGroup.ts
|
|
6
6
|
const EmployeeCategoryGroup = z.enum([
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as FileMeta } from "./FileMeta-Be9viU7D.mjs";
|
|
2
|
-
import { a as Approval, c as ApproveApprovalSchema, f as CreateApprovalSchema, g as WithdrawApprovalSchema, m as ResubmitApprovalSchema, r as Department, t as Employee, u as CancelApprovalSchema } from "./Employee-
|
|
2
|
+
import { a as Approval, c as ApproveApprovalSchema, f as CreateApprovalSchema, g as WithdrawApprovalSchema, m as ResubmitApprovalSchema, r as Department, t as Employee, u as CancelApprovalSchema } from "./Employee-N9fRSnIl.mjs";
|
|
3
3
|
import { z as z$1 } from "zod";
|
|
4
4
|
//#region src/data/server/file.d.ts
|
|
5
5
|
declare const GetFileMetasSchema: z$1.ZodObject<{
|
|
@@ -74,7 +74,6 @@ declare const GetApprovalsSchema: z$1.ZodObject<{
|
|
|
74
74
|
status: z$1.ZodOptional<z$1.ZodEnum<{
|
|
75
75
|
Approved: "Approved";
|
|
76
76
|
Cancelled: "Cancelled";
|
|
77
|
-
PartiallyApproved: "PartiallyApproved";
|
|
78
77
|
Rejected: "Rejected";
|
|
79
78
|
WaitingForApproval: "WaitingForApproval";
|
|
80
79
|
Withdrawn: "Withdrawn";
|
|
@@ -165,4 +164,4 @@ declare const getCompanyGeneralManager: ({ data }: {
|
|
|
165
164
|
}) => Promise<Employee>;
|
|
166
165
|
//#endregion
|
|
167
166
|
export { UpdateFileMetaSchema as A, uploadFile as B, createApproval as C, withdrawApproval as D, resubmitApproval as E, downloadFile as F, getFile as I, getFileMetas as L, UploadFileResult as M, batchDeleteFiles as N, FileSchema as O, deleteFile as P, getFileThumbnail as R, cancelApproval as S, getApprovals as T, getPreviousEmployeeIds as _, getActiveEmployees as a, GetApprovalsSchema as b, getDepartmentEmployees as c, getEmployeeByEmployeeId as d, getEmployeeGeneralManager as f, getEmployees as g, getEmployeeSupervisor as h, SearchEmployeesSchema as i, UploadFileMetaSchema as j, GetFileMetasSchema as k, getDepartmentManager as l, getEmployeeSubordinates as m, DepartmentIdSchema as n, getCompanyGeneralManager as o, getEmployeeManager as p, EmployeeIdSchema as r, getDepartmentById as s, CompanyCodeSchema as t, getDepartments as u, searchEmployees as v, getApproval as w, approveApproval as x, GetApprovalSchema as y, updateFileMeta as z };
|
|
168
|
-
//# sourceMappingURL=peoplesoft-
|
|
167
|
+
//# sourceMappingURL=peoplesoft-BIdTNshE.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as __exportAll } from "./providers-
|
|
2
|
-
import { t as createApi } from "./createApi-
|
|
1
|
+
import { a as __exportAll } from "./providers-DrairEO2.mjs";
|
|
2
|
+
import { t as createApi } from "./createApi-DGJJ4I_R.mjs";
|
|
3
3
|
import { z as z$1 } from "zod";
|
|
4
4
|
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
5
5
|
//#region src/data/server/peoplesoft.ts
|
|
@@ -142,4 +142,4 @@ const getCompanyGeneralManager = createServerOnlyFn(async ({ data }) => {
|
|
|
142
142
|
//#endregion
|
|
143
143
|
export { getPreviousEmployeeIds as _, getActiveEmployees as a, getDepartmentEmployees as c, getEmployeeByEmployeeId as d, getEmployeeGeneralManager as f, getEmployees as g, getEmployeeSupervisor as h, SearchEmployeesSchema as i, getDepartmentManager as l, getEmployeeSubordinates as m, DepartmentIdSchema as n, getCompanyGeneralManager as o, getEmployeeManager as p, EmployeeIdSchema as r, getDepartmentById as s, CompanyCodeSchema as t, getDepartments as u, peoplesoft_exports as v, searchEmployees as y };
|
|
144
144
|
|
|
145
|
-
//# sourceMappingURL=peoplesoft-
|
|
145
|
+
//# sourceMappingURL=peoplesoft-BkJMCcHb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peoplesoft-BkJMCcHb.mjs","names":["createServerOnlyFn","z","createApi","Department","Employee","SearchEmployeesSchema","object","searchTerm","string","min","EmployeeIdSchema","employeeId","DepartmentIdSchema","departmentId","CompanyCodeSchema","companyCode","peoplesoftApi","baseURL","scopeKey","searchEmployees","data","input","Promise","Array","parse","api","employees","request","url","encodeURIComponent","method","getEmployees","getActiveEmployees","getEmployeeByEmployeeId","employee","getPreviousEmployeeIds","getEmployeeSupervisor","getEmployeeSubordinates","getEmployeeManager","getEmployeeGeneralManager","getDepartments","departments","getDepartmentById","department","getDepartmentManager","getDepartmentEmployees","getCompanyGeneralManager","z"],"sources":["../src/data/server/peoplesoft.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport { z } from \"zod\";\nimport { createApi } from \"~/lib/createApi\";\nimport type { Department } from \"~/models/peoplesoft/Department\";\nimport type { Employee } from \"~/models/peoplesoft/Employee\";\n\nexport const SearchEmployeesSchema = z.object({\n searchTerm: z.string().min(1),\n});\n\nexport const EmployeeIdSchema = z.object({\n employeeId: z.string().min(1),\n});\n\nexport const DepartmentIdSchema = z.object({\n departmentId: z.string().min(1),\n});\n\nexport const CompanyCodeSchema = z.object({\n companyCode: z.string().min(1),\n});\n\nconst peoplesoftApi = () => createApi({ baseURL: \"PEOPLESOFT_BASE_URL\", scopeKey: \"peoplesoft\" });\n\nexport const searchEmployees = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof SearchEmployeesSchema> }): Promise<Array<Employee>> => {\n const input = SearchEmployeesSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee?search=${encodeURIComponent(input.searchTerm)}`,\n method: \"GET\",\n });\n return employees;\n },\n);\n\nexport const getEmployees = createServerOnlyFn(async (): Promise<Array<Employee>> => {\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/all`,\n method: \"GET\",\n });\n return employees;\n});\n\nexport const getActiveEmployees = createServerOnlyFn(async (): Promise<Array<Employee>> => {\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/active`,\n method: \"GET\",\n });\n return employees;\n});\n\nexport const getEmployeeByEmployeeId = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getPreviousEmployeeIds = createServerOnlyFn(async (): Promise<Array<Employee>> => {\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/previousIds`,\n method: \"GET\",\n });\n return employees;\n});\n\nexport const getEmployeeSupervisor = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/supervisor`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getEmployeeSubordinates = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Array<Employee>> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/subordinates`,\n method: \"GET\",\n });\n return employees;\n },\n);\n\nexport const getEmployeeManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/manager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getEmployeeGeneralManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/generalManager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getDepartments = createServerOnlyFn(async (): Promise<Array<Department>> => {\n const api = await peoplesoftApi();\n const { data: departments } = await api.request<Array<Department>>({\n url: `/v1/department/all`,\n method: \"GET\",\n });\n return departments;\n});\n\nexport const getDepartmentById = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof DepartmentIdSchema> }): Promise<Department> => {\n const input = DepartmentIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: department } = await api.request<Department>({\n url: `/v1/department/${encodeURIComponent(input.departmentId)}`,\n method: \"GET\",\n });\n return department;\n },\n);\n\nexport const getDepartmentManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof DepartmentIdSchema> }): Promise<Employee> => {\n const input = DepartmentIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/department/${encodeURIComponent(input.departmentId)}/manager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getDepartmentEmployees = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof DepartmentIdSchema> }): Promise<Array<Employee>> => {\n const input = DepartmentIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/department/${encodeURIComponent(input.departmentId)}/employees`,\n method: \"GET\",\n });\n return employees;\n },\n);\n\nexport const getCompanyGeneralManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof CompanyCodeSchema> }): Promise<Employee> => {\n const input = CompanyCodeSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/company/${encodeURIComponent(input.companyCode)}/generalManager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAaK,wBAAwBJ,IAAEK,OAAO,EAC5CC,YAAYN,IAAEO,OAAO,CAAC,CAACC,IAAI,CAAC,EAC9B,CAAC;AAED,MAAaC,mBAAmBT,IAAEK,OAAO,EACvCK,YAAYV,IAAEO,OAAO,CAAC,CAACC,IAAI,CAAC,EAC9B,CAAC;AAED,MAAaG,qBAAqBX,IAAEK,OAAO,EACzCO,cAAcZ,IAAEO,OAAO,CAAC,CAACC,IAAI,CAAC,EAChC,CAAC;AAED,MAAaK,oBAAoBb,IAAEK,OAAO,EACxCS,aAAad,IAAEO,OAAO,CAAC,CAACC,IAAI,CAAC,EAC/B,CAAC;AAED,MAAMO,sBAAsBd,UAAU;CAAEe,SAAS;CAAuBC,UAAU;AAAa,CAAC;AAEhG,MAAaC,kBAAkBnB,mBAC7B,OAAO,EAAEoB,WAAs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C,mBAAmBR,MAAMR,YAAY;EAC5DiB,QAAQ;CACV,CAAC;CACD,OAAOa;AACT,CACF;AAEA,MAAaC,uBAAuB5C,mBAClC,OAAO,EAAEoB,WAA4E;CACnF,MAAMC,QAAQT,mBAAmBY,MAAMJ,IAAI;CAE3C,MAAM,EAAEA,MAAMc,aAAa,OAAMT,MADfT,cAAc,EAAA,CACKW,QAAkB;EACrDC,KAAK,kBAAkBC,mBAAmBR,MAAMR,YAAY,EAAC;EAC7DiB,QAAQ;CACV,CAAC;CACD,OAAOI;AACT,CACF;AAEA,MAAaW,yBAAyB7C,mBACpC,OAAO,EAAEoB,WAAmF;CAC1F,MAAMC,QAAQT,mBAAmBY,MAAMJ,IAAI;CAE3C,MAAM,EAAEA,MAAMM,cAAc,OAAMD,MADhBT,cAAc,EAAA,CACMW,QAAyB;EAC7DC,KAAK,kBAAkBC,mBAAmBR,MAAMR,YAAY,EAAC;EAC7DiB,QAAQ;CACV,CAAC;CACD,OAAOJ;AACT,CACF;AAEA,MAAaoB,2BAA2B9C,mBACtC,OAAO,EAAEoB,WAA2E;CAClF,MAAMC,QAAQP,kBAAkBU,MAAMJ,IAAI;CAE1C,MAAM,EAAEA,MAAMc,aAAa,OAAMT,MADfT,cAAc,EAAA,CACKW,QAAkB;EACrDC,KAAK,eAAeC,mBAAmBR,MAAMN,WAAW,EAAC;EACzDe,QAAQ;CACV,CAAC;CACD,OAAOI;AACT,CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as serverEnv } from "./utils-
|
|
1
|
+
import { _ as serverEnv } from "./utils-BUpDoqme.mjs";
|
|
2
2
|
import "node:module";
|
|
3
3
|
import { scopes } from "virtual:wcz-layout";
|
|
4
4
|
import * as jose from "jose";
|
|
@@ -71,4 +71,4 @@ const getProviderByIssuer = (issuer) => providers.find((candidate) => candidate.
|
|
|
71
71
|
//#endregion
|
|
72
72
|
export { __exportAll as a, providers_exports as i, getProviderByIssuer as n, providers as r, getProvider as t };
|
|
73
73
|
|
|
74
|
-
//# sourceMappingURL=providers-
|
|
74
|
+
//# sourceMappingURL=providers-DrairEO2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers-DrairEO2.mjs","names":["jose","scopes","definedScopes","serverEnv","Scope","ProviderId","Provider","id","label","clientId","clientSecret","issuer","authorizeEndpoint","tokenEndpoint","loginScopes","ReadonlyArray","audience","jwks","ReturnType","createRemoteJWKSet","logoutUrl","returnTo","entraAuthority","ENTRA_TENANT_ID","entra","ENTRA_CLIENT_ID","ENTRA_CLIENT_SECRET","URL","encodeURIComponent","awsResourceScopes","Set","Object","values","Record","map","entry","undefined","aws","filter","scope","buildAws","AWS_ISSUER","AWS_DOMAIN","AWS_CLIENT_ID","AWS_CLIENT_SECRET","providers","getProvider","provider","find","candidate","Error","getProviderByIssuer","definedScopes"],"sources":["../src/lib/auth/providers.ts"],"sourcesContent":["import * as jose from \"jose\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { serverEnv } from \"~/env\";\nimport type { Scope } from \"~/models/Scopes\";\nimport type { ProviderId } from \"~/models/User\";\n\n/**\n * Identity providers, server-side only. Entra is always present; AWS registers\n * itself when its env vars are set, so an Entra-only app is unchanged and the\n * login page renders a single button.\n */\nexport interface Provider {\n id: ProviderId;\n label: string;\n clientId: string;\n clientSecret: string;\n /** The `iss` claim, used to pick the right provider for an incoming Bearer. */\n issuer: string;\n authorizeEndpoint: string;\n tokenEndpoint: string;\n loginScopes: ReadonlyArray<string>;\n /**\n * Expected `aud` for incoming Bearer JWTs. Undefined for Cognito: its access\n * tokens carry `client_id`, not `aud`, so the user pool itself is the trust\n * boundary — any client in the pool is accepted.\n * ponytail: pool-wide trust; add a client_id allowlist if other pools' clients\n * could ever reach this app.\n */\n audience?: string;\n jwks: ReturnType<typeof jose.createRemoteJWKSet>;\n logoutUrl: (returnTo: string) => string;\n}\n\nconst entraAuthority = `https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}`;\n\nconst entra: Provider = {\n id: \"entra\",\n label: \"Microsoft\",\n clientId: serverEnv.ENTRA_CLIENT_ID,\n clientSecret: serverEnv.ENTRA_CLIENT_SECRET,\n issuer: `${entraAuthority}/v2.0`,\n authorizeEndpoint: `${entraAuthority}/oauth2/v2.0/authorize`,\n tokenEndpoint: `${entraAuthority}/oauth2/v2.0/token`,\n // `offline_access` yields the multi-resource refresh token every delegated API\n // token is minted from; `User.Read` covers the Graph profile photo.\n loginScopes: [\"openid\", \"profile\", \"offline_access\", \"User.Read\"],\n audience: serverEnv.ENTRA_CLIENT_ID,\n jwks: jose.createRemoteJWKSet(new URL(`${entraAuthority}/discovery/v2.0/keys`)),\n logoutUrl: (returnTo) =>\n `${entraAuthority}/oauth2/v2.0/logout?post_logout_redirect_uri=${encodeURIComponent(returnTo)}`,\n};\n\n/**\n * Cognito cannot widen scopes after login, so every AWS scope the app will ever\n * ask for has to be requested up front. Derived from `scopes.ts` rather than\n * configured separately, so the two can't drift.\n */\nconst awsResourceScopes = [\n ...new Set(\n Object.values(definedScopes as Record<string, Scope>)\n .map((entry) => (typeof entry === \"string\" ? undefined : entry.aws))\n .filter((scope) => scope !== undefined),\n ),\n];\n\nconst buildAws = (): Provider | null => {\n const { AWS_ISSUER, AWS_DOMAIN, AWS_CLIENT_ID, AWS_CLIENT_SECRET } = serverEnv;\n if (!AWS_ISSUER || !AWS_DOMAIN || !AWS_CLIENT_ID || !AWS_CLIENT_SECRET) return null;\n\n return {\n id: \"aws\",\n label: \"AWS\",\n clientId: AWS_CLIENT_ID,\n clientSecret: AWS_CLIENT_SECRET,\n issuer: AWS_ISSUER,\n authorizeEndpoint: `${AWS_DOMAIN}/oauth2/authorize`,\n tokenEndpoint: `${AWS_DOMAIN}/oauth2/token`,\n loginScopes: [\"openid\", \"email\", \"phone\"], // TODO: [\"openid\", \"email\", \"phone\", ...awsResourceScopes]\n jwks: jose.createRemoteJWKSet(new URL(`${AWS_ISSUER}/.well-known/jwks.json`)),\n logoutUrl: (returnTo) =>\n `${AWS_DOMAIN}/logout?client_id=${AWS_CLIENT_ID}&logout_uri=${encodeURIComponent(returnTo)}`,\n };\n};\n\nconst aws = buildAws();\n\nexport const providers: ReadonlyArray<Provider> = aws ? [entra, aws] : [entra];\n\nexport const getProvider = (id: ProviderId): Provider => {\n const provider = providers.find((candidate) => candidate.id === id);\n if (!provider) throw new Error(`Identity provider \"${id}\" is not configured.`);\n return provider;\n};\n\nexport const getProviderByIssuer = (issuer: string | undefined): Provider | undefined =>\n providers.find((candidate) => candidate.issuer === issuer);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAMsB,iBAAiB,qCAAqCnB,UAAUoB;AAEtE,MAAMC,QAAkB;CACtBjB,IAAI;CACJC,OAAO;CACPC,UAAUN,UAAUsB;CACpBf,cAAcP,UAAUuB;CACxBf,QAAQ,GAAGW,eAAc;CACzBV,mBAAmB,GAAGU,eAAc;CACpCT,eAAe,GAAGS,eAAc;CAGhCR,aAAa;EAAC;EAAU;EAAW;EAAkB;CAAW;CAChEE,UAAUb,UAAUsB;CACpBR,MAAMjB,KAAKmB,mBAAmB,IAAIQ,IAAI,GAAGL,eAAc,qBAAsB,CAAC;CAC9EF,YAAYC,aACV,GAAGC,eAAc,+CAAgDM,mBAAmBP,QAAQ;AAChG;AAO0B,CACxB,GAAG,IAAIS,IACLC,OAAOC,OAAO9B,MAAsC,CAAC,CAClDgC,KAAKC,UAAW,OAAOA,UAAU,WAAWC,KAAAA,IAAYD,MAAME,GAAI,CAAC,CACnEC,QAAQC,UAAUA,UAAUH,KAAAA,CAAS,CAC1C,CAAC;AAGH,MAAMI,iBAAkC;CACtC,MAAM,EAAEC,YAAYC,YAAYC,eAAeC,sBAAsBzC;CACrE,IAAI,CAACsC,cAAc,CAACC,cAAc,CAACC,iBAAiB,CAACC,mBAAmB,OAAO;CAE/E,OAAO;EACLrC,IAAI;EACJC,OAAO;EACPC,UAAUkC;EACVjC,cAAckC;EACdjC,QAAQ8B;EACR7B,mBAAmB,GAAG8B,WAAU;EAChC7B,eAAe,GAAG6B,WAAU;EAC5B5B,aAAa;GAAC;GAAU;GAAS;EAAO;EACxCG,MAAMjB,KAAKmB,mBAAmB,IAAIQ,IAAI,GAAGc,WAAU,uBAAwB,CAAC;EAC5ErB,YAAYC,aACV,GAAGqB,WAAU,oBAAqBC,cAAa,cAAef,mBAAmBP,QAAQ;CAC7F;AACF;AAEA,MAAMgB,MAAMG,SAAS;AAErB,MAAaK,YAAqCR,MAAM,CAACb,OAAOa,GAAG,IAAI,CAACb,KAAK;AAE7E,MAAasB,eAAevC,OAA6B;CACvD,MAAMwC,WAAWF,UAAUG,MAAMC,cAAcA,UAAU1C,OAAOA,EAAE;CAClE,IAAI,CAACwC,UAAU,MAAM,IAAIG,MAAM,sBAAsB3C,GAAE,qBAAsB;CAC7E,OAAOwC;AACT;AAEA,MAAaI,uBAAuBxC,WAClCkC,UAAUG,MAAMC,cAAcA,UAAUtC,WAAWA,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as getProvider } from "./providers-
|
|
2
|
-
import { g as getAppSession } from "./utils-
|
|
1
|
+
import { t as getProvider } from "./providers-DrairEO2.mjs";
|
|
2
|
+
import { g as getAppSession } from "./utils-BUpDoqme.mjs";
|
|
3
3
|
import { scopes } from "virtual:wcz-layout";
|
|
4
4
|
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -140,4 +140,4 @@ const getAppToken = createServerOnlyFn(async (scopeKey) => {
|
|
|
140
140
|
//#endregion
|
|
141
141
|
export { createState as a, createPkce as i, getAppToken as n, exchangeCode as o, buildAuthUrl as r, getAccessToken as t };
|
|
142
142
|
|
|
143
|
-
//# sourceMappingURL=tokens-
|
|
143
|
+
//# sourceMappingURL=tokens-BLRreL1j.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens-BLRreL1j.mjs","names":["createHash","randomBytes","randomUUID","Provider","SessionExpiredError","Error","TokenResponse","access_token","refresh_token","id_token","expires_in","base64url","bytes","Buffer","toString","createPkce","verifier","challenge","update","digest","createState","isSessionDead","error","suberror","requestToken","provider","body","Record","Promise","credentials","from","clientId","clientSecret","response","fetch","tokenEndpoint","method","headers","authorization","URLSearchParams","client_id","payload","json","ok","message","error_description","status","id","buildAuthUrl","opts","redirectUri","state","url","URL","authorizeEndpoint","search","response_type","redirect_uri","scope","loginScopes","join","code_challenge","code_challenge_method","exchangeCode","code","codeVerifier","grant_type","code_verifier","refreshTokens","refreshToken","clientCredentials","createServerOnlyFn","scopes","definedScopes","Scope","ProviderId","SessionExpiredError","clientCredentials","refreshTokens","getProvider","getAppSession","ScopeKey","resolveScope","key","provider","entry","scope","undefined","Error","getAccessToken","scopeKey","Promise","session","providerId","refreshToken","data","result","refresh_token","update","access_token","error","clear","Response","json","message","status","appTokens","Map","token","expiresAt","getAppToken","cached","get","Date","now","defaultScope","slice","lastIndexOf","set","expires_in","definedScopes"],"sources":["../src/lib/auth/oidc.ts","../src/lib/auth/tokens.ts"],"sourcesContent":["import { createHash, randomBytes, randomUUID } from \"node:crypto\";\nimport type { Provider } from \"./providers\";\n\n/**\n * The whole OAuth2/OIDC surface this app needs, as plain form POSTs. Both Entra\n * and Cognito are ordinary OIDC servers, so a second provider is a config object\n * (see `providers.ts`) rather than a second integration.\n */\n\n/** The refresh token is expired/revoked — the user must sign in interactively. */\nexport class SessionExpiredError extends Error {}\n\nexport interface TokenResponse {\n access_token: string;\n refresh_token?: string;\n id_token?: string;\n expires_in: number;\n}\n\nconst base64url = (bytes: Buffer): string => bytes.toString(\"base64url\");\n\n/** PKCE verifier + S256 challenge for the authorization-code flow. */\nexport const createPkce = (): { verifier: string; challenge: string } => {\n const verifier = base64url(randomBytes(32));\n return { verifier, challenge: base64url(createHash(\"sha256\").update(verifier).digest()) };\n};\n\nexport const createState = (): string => randomUUID();\n\n/**\n * Revocation, inactivity expiry and Conditional Access sign-in frequency all\n * surface as `invalid_grant` or `interaction_required` — the session is dead and\n * only an interactive login helps. Missing consent (Entra AADSTS65001) looks the\n * same but is a configuration bug, so it is left to surface as-is.\n */\nconst isSessionDead = (error: { error?: string; suberror?: string }): boolean =>\n (error.error === \"invalid_grant\" || error.error === \"interaction_required\") &&\n error.suberror !== \"consent_required\";\n\nasync function requestToken(\n provider: Provider,\n body: Record<string, string>,\n): Promise<TokenResponse> {\n const credentials = Buffer.from(`${provider.clientId}:${provider.clientSecret}`).toString(\n \"base64\",\n );\n const response = await fetch(provider.tokenEndpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/x-www-form-urlencoded\",\n // Both providers accept client_secret_basic; it keeps the secret out of the body.\n authorization: `Basic ${credentials}`,\n },\n body: new URLSearchParams({ client_id: provider.clientId, ...body }),\n });\n\n const payload = (await response.json()) as TokenResponse &\n Record<\"error\" | \"error_description\" | \"suberror\", string | undefined>;\n if (response.ok) return payload;\n\n const message = payload.error_description ?? payload.error ?? `HTTP ${response.status}`;\n if (isSessionDead(payload)) throw new SessionExpiredError(message);\n throw new Error(`[${provider.id}] ${message}`);\n}\n\n/** First leg of the auth-code flow: the URL to redirect the browser to. */\nexport function buildAuthUrl(\n provider: Provider,\n opts: { redirectUri: string; state: string; challenge: string },\n): string {\n const url = new URL(provider.authorizeEndpoint);\n url.search = new URLSearchParams({\n client_id: provider.clientId,\n response_type: \"code\",\n redirect_uri: opts.redirectUri,\n state: opts.state,\n scope: provider.loginScopes.join(\" \"),\n code_challenge: opts.challenge,\n code_challenge_method: \"S256\",\n }).toString();\n return url.toString();\n}\n\n/** Second leg: exchange the code for tokens. The refresh token is in the body. */\nexport const exchangeCode = (\n provider: Provider,\n opts: { code: string; redirectUri: string; codeVerifier: string },\n): Promise<TokenResponse> =>\n requestToken(provider, {\n grant_type: \"authorization_code\",\n code: opts.code,\n redirect_uri: opts.redirectUri,\n code_verifier: opts.codeVerifier,\n });\n\n/**\n * Delegated token for `scope`. Entra mints a token for any resource from its\n * multi-resource refresh token; Cognito can only narrow within the scopes already\n * registered on the app client, and ignores the rest.\n */\nexport const refreshTokens = (\n provider: Provider,\n opts: { refreshToken: string; scope: string },\n): Promise<TokenResponse> =>\n requestToken(provider, {\n grant_type: \"refresh_token\",\n refresh_token: opts.refreshToken,\n scope: opts.scope,\n });\n\n/** App-only token: no user context, for background jobs. */\nexport const clientCredentials = (\n provider: Provider,\n opts: { scope: string },\n): Promise<TokenResponse> =>\n requestToken(provider, { grant_type: \"client_credentials\", scope: opts.scope });\n","import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport type { Scope } from \"~/models/Scopes\";\nimport type { ProviderId } from \"~/models/User\";\nimport { SessionExpiredError, clientCredentials, refreshTokens } from \"./oidc\";\nimport { getProvider } from \"./providers\";\nimport { getAppSession } from \"./session\";\n\nexport type ScopeKey = keyof typeof definedScopes;\n\n/**\n * A scope entry is either a bare string (Entra) or `{ entra, aws }`. Throwing on a\n * missing entry fails at the call site instead of sending a token the API rejects.\n */\nexport const resolveScope = (key: ScopeKey, provider: ProviderId): string => {\n const entry: Scope = definedScopes[key];\n const scope =\n typeof entry === \"string\" ? (provider === \"entra\" ? entry : undefined) : entry[provider];\n\n if (!scope) throw new Error(`No \"${key}\" scope is configured for the \"${provider}\" provider.`);\n return scope;\n};\n\n/**\n * Delegated access token for the signed-in user, minted from the session refresh\n * token. Providers that rotate the refresh token return a new one, which is\n * persisted back. Server-only — stripped from the client bundle.\n */\nexport const getAccessToken = createServerOnlyFn(async (scopeKey: ScopeKey): Promise<string> => {\n const session = await getAppSession();\n const { provider: providerId, refreshToken } = session.data;\n if (!providerId || !refreshToken) throw new Error(\"No active session. User not signed in.\");\n\n try {\n const result = await refreshTokens(getProvider(providerId), {\n refreshToken,\n scope: resolveScope(scopeKey, providerId),\n });\n if (result.refresh_token && result.refresh_token !== refreshToken)\n await session.update({ refreshToken: result.refresh_token });\n return result.access_token;\n } catch (error) {\n // Revoked/expired refresh token: clear the dead session and answer 401 so the\n // client can redirect to /login, instead of surfacing a 500.\n if (error instanceof SessionExpiredError) {\n await session.clear();\n throw Response.json(\n { message: \"Unauthorized: Session expired, sign in again\" },\n { status: 401 },\n );\n }\n throw error;\n }\n});\n\n// MSAL used to cache these in memory; without it, a small TTL map keeps parity.\nconst appTokens = new Map<ScopeKey, { token: string; expiresAt: number }>();\n\n/**\n * Client-credentials (app-only) token, for background jobs with no user.\n * Entra-only: the AWS population signs in interactively, so a Cognito app client\n * for M2M has no caller yet (and Cognito bills M2M per token request).\n */\nexport const getAppToken = createServerOnlyFn(async (scopeKey: ScopeKey): Promise<string> => {\n const cached = appTokens.get(scopeKey);\n if (cached && cached.expiresAt > Date.now()) return cached.token;\n\n // Entra client credentials only accept `<resource>/.default`, not user scopes.\n const scope = resolveScope(scopeKey, \"entra\");\n const defaultScope = `${scope.slice(0, scope.lastIndexOf(\"/\"))}/.default`;\n\n const result = await clientCredentials(getProvider(\"entra\"), { scope: defaultScope });\n appTokens.set(scopeKey, {\n token: result.access_token,\n expiresAt: Date.now() + (result.expires_in - 60) * 1000,\n });\n return result.access_token;\n});\n"],"mappings":";;;;;;;;;;;;AAUA,IAAaI,sBAAb,cAAyCC,MAAM,CAAA;AAS/C,MAAMM,aAAaC,UAA0BA,MAAME,SAAS,WAAW;;AAGvE,MAAaC,mBAA4D;CACvE,MAAMC,WAAWL,UAAUV,YAAY,EAAE,CAAC;CAC1C,OAAO;EAAEe;EAAUC,WAAWN,UAAUX,WAAW,QAAQ,CAAC,CAACkB,OAAOF,QAAQ,CAAC,CAACG,OAAO,CAAC;CAAE;AAC1F;AAEA,MAAaC,oBAA4BlB,WAAW;;;;;;;AAQpD,MAAMmB,iBAAiBC,WACpBA,MAAMA,UAAU,mBAAmBA,MAAMA,UAAU,2BACpDA,MAAMC,aAAa;AAErB,eAAeC,aACbC,UACAC,MACwB;CACxB,MAAMG,cAAchB,OAAOiB,KAAK,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M+B,YAAY,GAAG,CAAC,EAAC;CAE9D,MAAMrB,SAAS,MAAMnB,kBAAkBE,YAAY,OAAO,GAAG,EAAEO,OAAO6B,aAAa,CAAC;CACpFT,UAAUY,IAAI5B,UAAU;EACtBkB,OAAOZ,OAAOG;EACdU,WAAWI,KAAKC,IAAI,KAAKlB,OAAOuB,aAAa,MAAM;CACrD,CAAC;CACD,OAAOvB,OAAOG;AAChB,CAAC"}
|
|
@@ -79,20 +79,20 @@ createEnv({
|
|
|
79
79
|
});
|
|
80
80
|
const serverEnv = createEnv({
|
|
81
81
|
server: {
|
|
82
|
-
ENTRA_CLIENT_ID: z$1.string()
|
|
83
|
-
ENTRA_TENANT_ID: z$1.string()
|
|
84
|
-
ENTRA_CLIENT_SECRET: z$1.string()
|
|
82
|
+
ENTRA_CLIENT_ID: z$1.string(),
|
|
83
|
+
ENTRA_TENANT_ID: z$1.string(),
|
|
84
|
+
ENTRA_CLIENT_SECRET: z$1.string(),
|
|
85
85
|
AWS_ISSUER: z$1.url().optional(),
|
|
86
86
|
AWS_DOMAIN: z$1.url().optional(),
|
|
87
|
-
AWS_CLIENT_ID: z$1.string().
|
|
88
|
-
AWS_CLIENT_SECRET: z$1.string().
|
|
87
|
+
AWS_CLIENT_ID: z$1.string().optional(),
|
|
88
|
+
AWS_CLIENT_SECRET: z$1.string().optional(),
|
|
89
89
|
SESSION_SECRET: z$1.string().min(32),
|
|
90
|
-
FILE_BASE_URL: z$1.string().
|
|
91
|
-
APPROVAL_BASE_URL: z$1.string().
|
|
92
|
-
PEOPLESOFT_BASE_URL: z$1.string().
|
|
93
|
-
EMAIL_BASE_URL: z$1.string().
|
|
94
|
-
AI_BASE_URL: z$1.string().
|
|
95
|
-
AI_SUBSCRIPTION_KEY: z$1.string().
|
|
90
|
+
FILE_BASE_URL: z$1.string().optional(),
|
|
91
|
+
APPROVAL_BASE_URL: z$1.string().optional(),
|
|
92
|
+
PEOPLESOFT_BASE_URL: z$1.string().optional(),
|
|
93
|
+
EMAIL_BASE_URL: z$1.string().optional(),
|
|
94
|
+
AI_BASE_URL: z$1.string().optional(),
|
|
95
|
+
AI_SUBSCRIPTION_KEY: z$1.string().optional()
|
|
96
96
|
},
|
|
97
97
|
runtimeEnv: process.env,
|
|
98
98
|
emptyStringAsUndefined: true
|
|
@@ -118,7 +118,7 @@ const getSessionUser = createServerFn({ method: "GET" }).handler(async () => {
|
|
|
118
118
|
});
|
|
119
119
|
/** The identity providers the server offers, for the login page. */
|
|
120
120
|
const getLoginProviders = createServerFn({ method: "GET" }).handler(async () => {
|
|
121
|
-
const { providers } = await import("./providers-
|
|
121
|
+
const { providers } = await import("./providers-DrairEO2.mjs").then((n) => n.i);
|
|
122
122
|
return providers.map(({ id, label }) => ({
|
|
123
123
|
id,
|
|
124
124
|
label
|
|
@@ -280,4 +280,4 @@ const hasPermission = (user, key) => user ? permissions[key].some((group) => use
|
|
|
280
280
|
//#endregion
|
|
281
281
|
export { serverEnv as _, foldForSearch as a, withOfflineFallback as b, isTestEnv as c, sanitizeReturnTo as d, getSessionUser as f, getAppSession as g, userQueryOptions as h, buildUser as i, requireAuth as l, loginProvidersQueryOptions as m, WISTRON_PRIMARY_COLOR as n, getFieldStatus as o, getUser as p, WISTRON_SECONDARY_COLOR as r, hasPermission as s, Platform as t, rootRouteHead as u, OFFLINE_PHOTO_KEY as v, clearSessionSnapshot as y };
|
|
282
282
|
|
|
283
|
-
//# sourceMappingURL=utils-
|
|
283
|
+
//# sourceMappingURL=utils-BUpDoqme.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-BUpDoqme.mjs","names":["OFFLINE_USER_KEY","OFFLINE_PHOTO_KEY","GRACE_PERIOD","Cached","value","T","savedAt","recall","key","localStorage","raw","getItem","JSON","parse","Date","now","removeItem","remember","undefined","setItem","stringify","isOfflineFailure","error","navigator","onLine","TypeError","withOfflineFallback","fetchFresh","Promise","fresh","clearSessionSnapshot","String","window","addEventListener","event","location","href","createEnv","z","clientEnv","clientPrefix","client","runtimeEnv","import","meta","env","emptyStringAsUndefined","serverEnv","server","ENTRA_CLIENT_ID","string","ENTRA_TENANT_ID","ENTRA_CLIENT_SECRET","AWS_ISSUER","url","optional","AWS_DOMAIN","AWS_CLIENT_ID","AWS_CLIENT_SECRET","SESSION_SECRET","min","FILE_BASE_URL","APPROVAL_BASE_URL","PEOPLESOFT_BASE_URL","EMAIL_BASE_URL","AI_BASE_URL","AI_SUBSCRIPTION_KEY","process","z","useSession","serverEnv","ProviderId","User","AppSessionData","provider","refreshToken","user","pkceVerifier","state","returnTo","AppSession","Awaited","ReturnType","getAppSession","Promise","getSession","name","password","SESSION_SECRET","queryOptions","createServerFn","QueryClientParam","ProviderId","User","OFFLINE_USER_KEY","withOfflineFallback","getAppSession","getSessionUser","method","handler","Promise","session","data","user","getLoginProviders","Array","id","label","providers","map","loginProvidersQueryOptions","queryKey","queryFn","staleTime","userQueryOptions","Infinity","networkMode","refetchOnReconnect","getUser","queryClient","import","meta","env","SSR","ensureQueryData","AnyFieldApi","redirect","ParsedLocation","manifest","permissions","QueryClientParam","TokenPayload","ProviderId","User","getUser","WISTRON_PRIMARY_COLOR","WISTRON_SECONDARY_COLOR","Platform","isAndroid","test","userAgent","isIOS","isWindows","isMacOS","navigator","RootRouteHeadOptions","rootRouteHead","options","meta","charSet","name","content","title","links","rel","sizes","href","type","GuardArgs","location","context","requireAuth","permissionKey","user","queryClient","encodeURIComponent","reloadDocument","hasPermission","Error","NON_PRODUCTION","isTestEnv","origin","split","slice","join","FormOmittedProps","getFieldStatus","field","state","isTouched","hasError","errors","length","helperText","message","sanitizeReturnTo","value","toKebabCase","str","replaceAll","toLowerCase","foldForSearch","String","normalize","permissionGroups","Set","Object","values","flat","buildUser","payload","provider","email","preferred_username","department","toUpperCase","employeeId","companyName","groups","filter","group","has","key","some","includes"],"sources":["../src/lib/auth/offline.ts","../src/env.ts","../src/lib/auth/session.ts","../src/lib/auth/user.ts","../src/lib/utils.ts"],"sourcesContent":["/**\n * Offline fallback for identity. The refresh token never leaves the sealed\n * httpOnly cookie — what is cached here is only the display snapshot (user\n * claims and avatar) so the UI and offline route permissions can still work\n * while the server is unreachable. Server requests remain independently\n * authorized. At-rest protection is the device's OS login and disk encryption.\n */\n\nexport const OFFLINE_USER_KEY = \"auth-user\";\nexport const OFFLINE_PHOTO_KEY = \"auth-photo\";\n\n/** One shift — matches Intune's default offline grace period. */\nconst GRACE_PERIOD = 12 * 60 * 60 * 1000;\n\ntype Cached<T> = { value: T; savedAt: number };\n\nconst recall = <T>(key: string): T | null => {\n if (typeof localStorage === \"undefined\") return null;\n try {\n const raw = localStorage.getItem(key);\n if (!raw) return null;\n const { value, savedAt } = JSON.parse(raw) as Cached<T>;\n if (Date.now() - savedAt > GRACE_PERIOD) {\n localStorage.removeItem(key);\n return null;\n }\n return value;\n } catch {\n localStorage.removeItem(key);\n return null;\n }\n};\n\nconst remember = (key: string, value: unknown): void => {\n if (typeof localStorage === \"undefined\") return;\n try {\n if (value === null || value === undefined) localStorage.removeItem(key);\n else localStorage.setItem(key, JSON.stringify({ value, savedAt: Date.now() }));\n } catch {\n // Storage full or blocked — the offline fallback is best-effort.\n }\n};\n\nconst isOfflineFailure = (error: unknown): boolean =>\n (typeof navigator !== \"undefined\" && !navigator.onLine) || error instanceof TypeError;\n\n/**\n * Answers from the server when reachable, remembering the result; when the call\n * has a transport failure, replays the last result instead, for up to\n * {@link GRACE_PERIOD} since it was last confirmed.\n *\n * Cached values are untrusted client state. Server authorization must never\n * depend on them.\n */\nexport const withOfflineFallback = async <T>(\n key: string,\n fetchFresh: () => Promise<T>,\n): Promise<T | null> => {\n try {\n const fresh = await fetchFresh();\n remember(key, fresh);\n return fresh;\n } catch (error) {\n if (!isOfflineFailure(error)) throw error;\n return recall<T>(key);\n }\n};\n\n/** Drops the cached identity. Call on logout, before leaving the page. */\nexport const clearSessionSnapshot = (): void => {\n if (typeof localStorage === \"undefined\") return;\n localStorage.removeItem(OFFLINE_USER_KEY);\n localStorage.removeItem(OFFLINE_PHOTO_KEY);\n localStorage.setItem(\"auth-logout\", String(Date.now()));\n};\n\nif (typeof window !== \"undefined\")\n window.addEventListener(\"storage\", (event) => {\n if (event.key === \"auth-logout\") location.href = \"/auth/logout\";\n });\n","import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const clientEnv = createEnv({\n clientPrefix: \"VITE_\",\n client: {},\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 AWS_ISSUER: z.url().optional(),\n AWS_DOMAIN: z.url().optional(),\n AWS_CLIENT_ID: z.string().optional(),\n AWS_CLIENT_SECRET: z.string().optional(),\n SESSION_SECRET: z.string().min(32),\n FILE_BASE_URL: z.string().optional(),\n APPROVAL_BASE_URL: z.string().optional(),\n PEOPLESOFT_BASE_URL: z.string().optional(),\n EMAIL_BASE_URL: z.string().optional(),\n AI_BASE_URL: z.string().optional(),\n AI_SUBSCRIPTION_KEY: z.string().optional(),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n});\n","import type { useSession } from \"@tanstack/react-start/server\";\nimport { serverEnv } from \"~/env\";\nimport type { ProviderId, User } from \"~/models/User\";\n\nexport interface AppSessionData {\n /** Which identity provider signed this user in. */\n provider?: ProviderId;\n /** The only token persisted; delegated access tokens are minted from it. */\n refreshToken?: string;\n user?: User;\n /** Transient, only between /auth/login and /auth/callback. */\n pkceVerifier?: string;\n state?: string;\n returnTo?: string;\n}\n\n/** `SessionManager` is not re-exported upstream, so name it through `useSession`. */\nexport type AppSession = Awaited<ReturnType<typeof useSession<AppSessionData>>>;\n\nexport const getAppSession = async (): Promise<AppSession> => {\n // Dynamic import: `@tanstack/react-start/server` is the server entry and drags\n // in the SSR renderer (`react-dom/server`). Keep it out of the client graph —\n // this helper is only ever called server-side, and all callers already await it.\n // Aliased off the `use*` name so it isn't mistaken for a React hook (it's a\n // server session helper, not a hook).\n const { useSession: getSession } = await import(\"@tanstack/react-start/server\");\n\n return getSession<AppSessionData>({\n name: \"session\",\n password: serverEnv.SESSION_SECRET,\n });\n};\n","import { queryOptions } from \"@tanstack/react-query\";\nimport { createServerFn } from \"@tanstack/react-start\";\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\nimport type { ProviderId, User } from \"~/models/User\";\nimport { OFFLINE_USER_KEY, withOfflineFallback } from \"./offline\";\nimport { getAppSession } from \"./session\";\n\n/**\n * Reads the signed-in user from the session cookie, or null. As a server function\n * it runs in-process when called on the server (SSR, middleware) and as an RPC\n * when called from the client — so it doubles as the client `queryFn`.\n */\nexport const getSessionUser = createServerFn({ method: \"GET\" }).handler(\n async (): Promise<User | null> => {\n const session = await getAppSession();\n return session.data.user ?? null;\n },\n);\n\n/** The identity providers the server offers, for the login page. */\nexport const getLoginProviders = createServerFn({ method: \"GET\" }).handler(\n async (): Promise<Array<{ id: ProviderId; label: string }>> => {\n // Dynamic import: `providers` reads `serverEnv` and must not reach the client.\n const { providers } = await import(\"./providers\");\n return providers.map(({ id, label }) => ({ id, label }));\n },\n);\n\n/**\n * Feeds `LoginForm`. Server config, not per-user, so it is safe to prime on the\n * server — the `/login` route's loader does that to avoid a flash of empty card.\n */\nexport const loginProvidersQueryOptions = queryOptions({\n queryKey: [\"auth\", \"providers\"],\n queryFn: () => getLoginProviders(),\n staleTime: \"static\",\n});\n\n/**\n * Client-side query for the signed-in user. Shared between `getUser` (route\n * `beforeLoad`) and the always-mounted observer in `LayoutProvider` — the\n * observer is what seeds the offline snapshot on the very first page load\n * (`beforeLoad` does not re-run after SSR hydration) and what makes\n * `refetchOnReconnect` fire once connectivity returns.\n */\nexport const userQueryOptions = queryOptions({\n queryKey: [\"auth\", \"user\"],\n queryFn: () => withOfflineFallback(OFFLINE_USER_KEY, () => getSessionUser()),\n staleTime: Infinity,\n // Default \"online\" pauses the query (never calling queryFn) once the browser\n // reports no connection — which is exactly when the fallback is needed.\n networkMode: \"offlineFirst\",\n // Back online: re-confirm the session and re-stamp the snapshot's grace period.\n refetchOnReconnect: \"always\",\n});\n\nexport const getUser = ({ queryClient }: QueryClientParam): Promise<User | null> => {\n if (import.meta.env.SSR) return getSessionUser();\n\n return queryClient.ensureQueryData(userQueryOptions);\n};\n","import type { AnyFieldApi } from \"@tanstack/react-form\";\nimport { redirect } from \"@tanstack/react-router\";\nimport type { ParsedLocation } from \"@tanstack/react-router\";\nimport { manifest, permissions } from \"virtual:wcz-layout\";\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { ProviderId, User } from \"~/models/User\";\nimport { getUser } from \"./auth/user\";\n\nexport const WISTRON_PRIMARY_COLOR = \"#00506E\";\nexport const WISTRON_SECONDARY_COLOR = \"#64DC00\";\n\nexport class Platform {\n static get isAndroid() {\n return /android/i.test(this.userAgent);\n }\n static get isIOS() {\n return /iPad|iPhone|iPod/.test(this.userAgent);\n }\n static get isWindows() {\n return /windows/i.test(this.userAgent);\n }\n static get isMacOS() {\n return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);\n }\n\n private static get userAgent() {\n return typeof navigator === \"undefined\" ? \"\" : navigator.userAgent;\n }\n}\n\ninterface RootRouteHeadOptions {\n manifest?: string;\n}\n\nexport const rootRouteHead = (options?: RootRouteHeadOptions) => ({\n meta: [\n { charSet: \"utf-8\" },\n { name: \"viewport\", content: \"width=device-width, initial-scale=1\" },\n { title: manifest.name },\n { name: \"og:type\", content: \"website\" },\n { name: \"og:title\", content: manifest.name },\n { name: \"og:image\", content: \"/favicon-32x32.png\" },\n ],\n links: [\n { rel: \"apple-touch-icon\", sizes: \"180x180\", href: \"/apple-touch-icon.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"32x32\", href: \"/favicon-32x32.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"16x16\", href: \"/favicon-16x16.png\" },\n { rel: \"manifest\", href: options?.manifest || \"/manifest.json\" },\n { rel: \"icon\", href: \"/favicon.ico\" },\n ],\n});\n\ntype GuardArgs = { location: ParsedLocation; context: QueryClientParam };\n\n/**\n * Route guard for `beforeLoad`. Routes are public by default; add this to close one.\n *\n * - `requireAuth()` — signed in with any provider. The only gate a population\n * without permission groups (e.g. AWS users) can pass.\n * - `requireAuth(\"admin\")` — signed in *and* in a group listed under that key.\n *\n * `reloadDocument` is required: `/auth/login` is a component-less server route and\n * must be reached with a full-document navigation. It starts the login directly when\n * only one provider is registered, otherwise it forwards to the `/login` chooser.\n */\nexport const requireAuth = (permissionKey?: keyof typeof permissions) => {\n return async ({ location, context }: GuardArgs) => {\n const user = await getUser({ queryClient: context.queryClient });\n\n if (!user)\n throw redirect({\n href: `/auth/login?returnTo=${encodeURIComponent(location.href)}`,\n reloadDocument: true,\n });\n\n if (permissionKey && !hasPermission(user, permissionKey))\n throw new Error(\"You do not have permission to access this page.\");\n\n return { user };\n };\n};\n\n/* Internal Utils */\nconst NON_PRODUCTION = /(?:^|[.-])(?:dev|qas|uat|test)(?:[.-]|$)/i;\n\n/** True only for a dev/qas/uat/test domain — localhost and production are not. */\nexport const isTestEnv = (origin: string | undefined) =>\n NON_PRODUCTION.test((origin ?? \"\").split(\".\").slice(1).join(\".\"));\n\nexport type FormOmittedProps =\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"renderInput\"\n | \"type\"\n | \"aria-label\";\n\nexport const getFieldStatus = (field: AnyFieldApi) => {\n const { meta } = field.state;\n\n const isTouched = meta.isTouched;\n const hasError = !!meta.errors.length;\n const helperText = meta.errors[0]?.message;\n\n return { isTouched, hasError, helperText };\n};\n\n/**\n * Only same-origin paths are allowed, so `returnTo` cannot become an open\n * redirect. Backslash counts as a separator too: browsers normalize `/\\evil`\n * to the protocol-relative `//evil`.\n */\nexport const sanitizeReturnTo = (value: string | null | undefined): string =>\n value && /^\\/(?![/\\\\])/.test(value) ? value : \"/\";\n\nexport const toKebabCase = (str: string): string => {\n return str\n .replaceAll(/([a-z])([A-Z])/g, \"$1-$2\")\n .replaceAll(/[\\s_]+/g, \"-\")\n .replaceAll(/[^a-zA-Z0-9-]/g, \"\")\n .toLowerCase()\n .replaceAll(/-+/g, \"-\")\n .replaceAll(/(^-|-$)/g, \"\");\n};\n\nexport const foldForSearch = (value: unknown): string =>\n String(value ?? \"\")\n .toLowerCase()\n .normalize(\"NFD\")\n .replaceAll(/[\\u{300}-\\u{36F}]/gu, \"\")\n .normalize(\"NFC\");\n\nconst permissionGroups = new Set<string>(Object.values(permissions).flat());\n\n/**\n * Maps id/access-token claims to the serializable `User`. Groups are trimmed to\n * those named in `permissions.ts` — an unfiltered group list would blow the\n * cookie. Cognito's claim names differ, so both are read.\n */\nexport const buildUser = (payload: TokenPayload, provider: ProviderId): User => ({\n provider,\n name: (payload.name ?? payload[\"cognito:username\"] ?? \"\").split(\"/\")[0],\n email: (payload.preferred_username ?? payload.email ?? \"\").toLowerCase(),\n department: payload.department?.toUpperCase() || \"\",\n employeeId: (payload.employeeId ?? payload[\"cognito:username\"] ?? \"\").toUpperCase(),\n companyName: payload.companyName || \"\",\n groups:\n (payload.groups ?? payload[\"cognito:groups\"])?.filter((group) => permissionGroups.has(group)) ??\n [],\n});\n\nexport const hasPermission = (user: User | null, key: keyof typeof permissions): boolean =>\n user ? permissions[key].some((group) => user.groups.includes(group)) : false;\n"],"mappings":";;;;;;;;;;;;;;AAQA,MAAaA,mBAAmB;AAChC,MAAaC,oBAAoB;;AAGjC,MAAMC,eAAe;AAIrB,MAAMK,UAAaC,QAA0B;CAC3C,IAAI,OAAOC,iBAAiB,aAAa,OAAO;CAChD,IAAI;EACF,MAAMC,MAAMD,aAAaE,QAAQH,GAAG;EACpC,IAAI,CAACE,KAAK,OAAO;EACjB,MAAM,EAAEN,OAAOE,YAAYM,KAAKC,MAAMH,GAAG;EACzC,IAAII,KAAK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AO1E,MAAaC,aAAaC,SAAuBC,cAAgC;CAC/EA;CACAnD,OAAOkD,QAAQlD,QAAQkD,QAAQ,uBAAuB,GAAA,CAAI5B,MAAM,GAAG,CAAC,CAAC;CACrE8B,QAAQF,QAAQG,sBAAsBH,QAAQE,SAAS,GAAA,CAAIZ,YAAY;CACvEc,YAAYJ,QAAQI,YAAYC,YAAY,KAAK;CACjDC,aAAaN,QAAQM,cAAcN,QAAQ,uBAAuB,GAAA,CAAIK,YAAY;CAClFE,aAAaP,QAAQO,eAAe;CACpCC,SACGR,QAAQQ,UAAUR,QAAQ,kBAAA,EAAoBS,QAAQC,UAAUhB,iBAAiBiB,IAAID,KAAK,CAAC,KAC5F,CAAA;AACJ;AAEA,MAAa3C,iBAAiBJ,MAAmBiD,QAC/CjD,OAAOlC,YAAYmF,IAAI,CAACC,MAAMH,UAAU/C,KAAK6C,OAAOM,SAASJ,KAAK,CAAC,IAAI"}
|
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as requireAuth, s as hasPermission, t as Platform } from "./utils-
|
|
1
|
+
import { l as requireAuth, s as hasPermission, t as Platform } from "./utils-BUpDoqme.mjs";
|
|
2
2
|
import i18next, { t } from "i18next";
|
|
3
3
|
import { createEnv } from "@t3-oss/env-core";
|
|
4
4
|
import { uuidv7 } from "uuidv7";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wcz-layout",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tanstack-intent"
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"i18next": "^26.4.2",
|
|
73
73
|
"i18next-browser-languagedetector": "^8.2.1",
|
|
74
74
|
"jose": "^6.2.12",
|
|
75
|
-
"react-dropzone": "^20.1.
|
|
76
|
-
"react-i18next": "^17.0.
|
|
75
|
+
"react-dropzone": "^20.1.2",
|
|
76
|
+
"react-i18next": "^17.0.16",
|
|
77
77
|
"react-intersection-observer": "^11.0.1",
|
|
78
78
|
"react-number-format": "^5.4.5",
|
|
79
79
|
"tus-js-client": "^4.3.1",
|
|
@@ -82,21 +82,22 @@
|
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@arethetypeswrong/core": "^0.18.5",
|
|
84
84
|
"@rolldown/plugin-babel": "^0.2.4",
|
|
85
|
-
"@tanstack/ai": "^0.
|
|
86
|
-
"@tanstack/ai-client": "^0.
|
|
87
|
-
"@tanstack/ai-openai": "^0.
|
|
88
|
-
"@tanstack/highlight": "^
|
|
89
|
-
"@tanstack/intent": "^0.
|
|
85
|
+
"@tanstack/ai": "^0.65.1",
|
|
86
|
+
"@tanstack/ai-client": "^0.38.0",
|
|
87
|
+
"@tanstack/ai-openai": "^0.27.0",
|
|
88
|
+
"@tanstack/highlight": "^1.0.0",
|
|
89
|
+
"@tanstack/intent": "^0.5.5",
|
|
90
|
+
"@tanstack/react-pacer": "^0.24.1",
|
|
90
91
|
"@types/node": "^24.10.13",
|
|
91
92
|
"@types/react": "^19.3.0",
|
|
92
93
|
"@types/react-dom": "^19.3.0",
|
|
93
|
-
"@vitejs/plugin-react": "^6.1.
|
|
94
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
94
95
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
95
96
|
"nitro": "npm:nitro-nightly@latest",
|
|
96
|
-
"publint": "^0.3.
|
|
97
|
+
"publint": "^0.3.25",
|
|
97
98
|
"typescript": "^7.0.2",
|
|
98
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@
|
|
99
|
-
"vite-plus": "
|
|
99
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
|
|
100
|
+
"vite-plus": "1.1.0"
|
|
100
101
|
},
|
|
101
102
|
"peerDependencies": {
|
|
102
103
|
"@emotion/cache": "11.x",
|
|
@@ -109,6 +110,7 @@
|
|
|
109
110
|
"@tanstack/react-db": "0.x",
|
|
110
111
|
"@tanstack/react-form": "1.x",
|
|
111
112
|
"@tanstack/react-hotkeys": "0.x",
|
|
113
|
+
"@tanstack/react-pacer": "0.x",
|
|
112
114
|
"@tanstack/react-query": "5.x",
|
|
113
115
|
"@tanstack/react-router": "1.x",
|
|
114
116
|
"@tanstack/react-router-ssr-query": "1.x",
|
|
@@ -122,7 +124,7 @@
|
|
|
122
124
|
"zod": "4.x"
|
|
123
125
|
},
|
|
124
126
|
"overrides": {
|
|
125
|
-
"vite": "
|
|
127
|
+
"vite": "$vite"
|
|
126
128
|
},
|
|
127
|
-
"packageManager": "npm@12.0
|
|
129
|
+
"packageManager": "npm@12.2.0"
|
|
128
130
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ai
|
|
3
|
+
description: "Use when adding LLM features (chat, streamed text, structured output, tools, media generation)"
|
|
4
|
+
metadata:
|
|
5
|
+
type: convention
|
|
6
|
+
library: wcz-layout
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
> Mechanics are covered by TanStack's own `@tanstack/ai` skills.
|
|
10
|
+
> This skill adds the wcz-layout conventions on top of that.
|
|
11
|
+
|
|
12
|
+
## Rules
|
|
13
|
+
|
|
14
|
+
- The gateway needs three server-side inputs:
|
|
15
|
+
- Ensure that required env are present: `AI_BASE_URL` (`z.url()`) and `AI_SUBSCRIPTION_KEY` (`z.string()`) in `src/env.ts`.
|
|
16
|
+
- Ensure that `cognitiveServices: "https://cognitiveservices.azure.com/.default"` is added to
|
|
17
|
+
`src/lib/auth/scopes.ts` and pass `getAppToken("cognitiveServices")` as the API key.
|
|
18
|
+
- The subscription key sent as the `Ocp-Apim-Subscription-Key` header.
|
|
19
|
+
- Build the adapter in one place, `src/server/ai.ts`, and call it per request. `getAppToken`
|
|
20
|
+
caches and refreshes the token.
|
|
21
|
+
- Use server functions, not `/api/chat` routes (overrides the upstream examples). `useChat` and the
|
|
22
|
+
generation hooks take `fetcher` instead of `connection`; the server function returns
|
|
23
|
+
`toServerSentEventsResponse(...)`. Add an `api/` route only when a public API is required.
|
|
24
|
+
- Stream everything a user waits on. Use `useChat` for conversations and generation hooks for
|
|
25
|
+
media. For a typed result, combine `outputSchema` and `stream: true` with
|
|
26
|
+
`useChat({ fetcher, outputSchema })`, render `partial` as it fills in.
|
|
27
|
+
- Render chat text with `@tanstack/markdown` (install if missing): `<Markdown>` from
|
|
28
|
+
`@tanstack/markdown/react` with `extensions={[streamingMarkdownExtension()]}` from
|
|
29
|
+
`@tanstack/markdown/extensions/streaming`.
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// src/server/ai.ts
|
|
35
|
+
import { createOpenaiChat } from "@tanstack/ai-openai";
|
|
36
|
+
import { getAppToken } from "wcz-layout/auth";
|
|
37
|
+
import { serverEnv } from "~/env";
|
|
38
|
+
|
|
39
|
+
export const aiText = async () =>
|
|
40
|
+
createOpenaiChat("gpt-5.5", await getAppToken("cognitiveServices"), {
|
|
41
|
+
baseURL: serverEnv.AI_BASE_URL,
|
|
42
|
+
defaultHeaders: { "Ocp-Apim-Subscription-Key": serverEnv.AI_SUBSCRIPTION_KEY },
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// src/server/actions/chat.ts
|
|
46
|
+
export const chatFn = createServerFn({ method: "POST" })
|
|
47
|
+
.validator(z.object({ messages: z.array(z.custom<UIMessage>()) }))
|
|
48
|
+
.middleware([authMiddleware()])
|
|
49
|
+
.handler(async ({ data }) =>
|
|
50
|
+
toServerSentEventsResponse(
|
|
51
|
+
chat({ adapter: await aiText(), messages: data.messages, systemPrompts: [SYSTEM_PROMPT] }),
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// component
|
|
56
|
+
const { messages, sendMessage, isLoading, stop } = useChat({
|
|
57
|
+
fetcher: ({ messages }, { signal }) => chatFn({ data: { messages }, signal }),
|
|
58
|
+
});
|
|
59
|
+
```
|