@brite-future-schools-contracts/contracts 1.0.8 → 2.0.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.
Files changed (40) hide show
  1. package/dist/chunk-AEZO7MJD.js +127 -0
  2. package/dist/chunk-AEZO7MJD.js.map +1 -0
  3. package/dist/chunk-IR6JUP6L.js +48 -0
  4. package/dist/chunk-IR6JUP6L.js.map +1 -0
  5. package/dist/chunk-PCHAGP5X.js +1 -0
  6. package/dist/contracts/index.cjs +179 -0
  7. package/dist/contracts/index.cjs.map +1 -0
  8. package/dist/contracts/index.d.cts +201 -0
  9. package/dist/contracts/index.d.ts +158 -9677
  10. package/dist/contracts/index.js +22 -1414
  11. package/dist/contracts/index.js.map +1 -1
  12. package/dist/index.cjs +222 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.cts +4 -0
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +62 -1538
  17. package/dist/index.js.map +1 -1
  18. package/dist/schemas/index.cjs +181 -0
  19. package/dist/schemas/index.cjs.map +1 -0
  20. package/dist/schemas/index.d.cts +145 -0
  21. package/dist/schemas/index.d.ts +130 -1024
  22. package/dist/schemas/index.js +42 -640
  23. package/dist/schemas/index.js.map +1 -1
  24. package/package.json +32 -59
  25. package/dist/chunk-M6LF6JUL.mjs +0 -557
  26. package/dist/chunk-M6LF6JUL.mjs.map +0 -1
  27. package/dist/chunk-VC6SCJVW.mjs +0 -935
  28. package/dist/chunk-VC6SCJVW.mjs.map +0 -1
  29. package/dist/contracts/index.d.mts +0 -9720
  30. package/dist/contracts/index.mjs +0 -36
  31. package/dist/index.d.mts +0 -4
  32. package/dist/index.mjs +0 -161
  33. package/dist/index.mjs.map +0 -1
  34. package/dist/schemas/index.d.mts +0 -1039
  35. package/dist/schemas/index.mjs +0 -129
  36. package/dist/schemas/index.mjs.map +0 -1
  37. package/src/contracts/index.ts +0 -1209
  38. package/src/index.ts +0 -2
  39. package/src/schemas/index.ts +0 -586
  40. /package/dist/{contracts/index.mjs.map → chunk-PCHAGP5X.js.map} +0 -0
@@ -0,0 +1,127 @@
1
+ // src/schemas/base.ts
2
+ import * as z from "zod";
3
+ var CuidSchema = z.string().regex(/^[a-z][a-z0-9]{24}$/, "Invalid cuid2 identifier").meta({ description: "cuid2 \u2014 prefixed, collision-resistant identifier" });
4
+ var UuidSchema = z.uuidv4().meta({ description: "RFC-4122 UUID v4" });
5
+ var IsoDatetime = z.iso.datetime();
6
+ var TimestampsSchema = z.object({
7
+ createdAt: IsoDatetime.meta({ description: "ISO-8601 creation time (UTC)" }),
8
+ updatedAt: IsoDatetime.meta({ description: "ISO-8601 last update time (UTC)" })
9
+ });
10
+ var SoftDeleteSchema = z.object({
11
+ deletedAt: IsoDatetime.nullable().meta({
12
+ description: "Set when the record is soft-deleted; null if active"
13
+ })
14
+ });
15
+ var PaginationInputSchema = z.object({
16
+ cursor: CuidSchema.optional().meta({
17
+ description: "Opaque cursor from the previous page response"
18
+ }),
19
+ limit: z.int().min(1).max(100).default(20).meta({ description: "Number of items to return (1\u2013100, default 20)" })
20
+ });
21
+ function paginatedOutputSchema(itemSchema) {
22
+ return z.object({
23
+ items: z.array(itemSchema),
24
+ nextCursor: CuidSchema.nullable().meta({
25
+ description: "Pass as `cursor` on the next request; null when no more pages"
26
+ }),
27
+ total: z.int().nonnegative().meta({ description: "Total matching records (before pagination)" })
28
+ });
29
+ }
30
+ var BranchRefSchema = z.object({
31
+ branchId: CuidSchema.meta({ description: "The branch this record belongs to" })
32
+ });
33
+
34
+ // src/schemas/auth.ts
35
+ import * as z2 from "zod";
36
+ var SessionUserRoleSchema = z2.object({
37
+ id: CuidSchema,
38
+ name: z2.string().meta({ description: "Role name, e.g. PRINCIPAL" }),
39
+ branchId: CuidSchema,
40
+ isPrimary: z2.boolean()
41
+ });
42
+ var SessionUserSubRoleSchema = z2.object({
43
+ id: CuidSchema,
44
+ name: z2.string().meta({ description: "Sub-role name, e.g. HEAD_PREFECT" }),
45
+ branchId: CuidSchema
46
+ });
47
+ var SessionUserOutputSchema = z2.object({
48
+ id: CuidSchema,
49
+ email: z2.email(),
50
+ firstName: z2.string(),
51
+ lastName: z2.string(),
52
+ activeBranchId: CuidSchema,
53
+ roles: z2.array(SessionUserRoleSchema),
54
+ subRoles: z2.array(SessionUserSubRoleSchema),
55
+ isActive: z2.boolean(),
56
+ mustChangePassword: z2.boolean()
57
+ });
58
+ var LoginInputSchema = z2.object({
59
+ email: z2.email().meta({ description: "User email address" }),
60
+ password: z2.string().min(1).meta({ description: "Plain-text password (sent over TLS)" }),
61
+ branchId: CuidSchema.optional().meta({
62
+ description: "Branch to activate on login; defaults to user primary branch"
63
+ })
64
+ });
65
+ var LoginOutputSchema = z2.object({
66
+ accessToken: z2.string().meta({ description: "Short-lived JWT (15 min)" }),
67
+ refreshToken: z2.string().meta({ description: "Long-lived opaque refresh token (7 days)" }),
68
+ expiresIn: z2.int().positive().meta({ description: "Access token TTL in seconds" }),
69
+ user: SessionUserOutputSchema
70
+ });
71
+ var RefreshTokenInputSchema = z2.object({
72
+ refreshToken: z2.string().min(1)
73
+ });
74
+ var RefreshTokenOutputSchema = z2.object({
75
+ accessToken: z2.string(),
76
+ expiresIn: z2.int().positive()
77
+ });
78
+ var LogoutInputSchema = z2.object({
79
+ refreshToken: z2.string().min(1).meta({
80
+ description: "The refresh token to revoke; also invalidated server-side"
81
+ })
82
+ });
83
+ var ChangePasswordInputSchema = z2.object({
84
+ currentPassword: z2.string().min(1),
85
+ newPassword: z2.string().min(8, { error: "Password must be at least 8 characters" }),
86
+ confirmPassword: z2.string().min(1)
87
+ }).refine((v) => v.newPassword === v.confirmPassword, {
88
+ error: "Passwords do not match",
89
+ path: ["confirmPassword"]
90
+ });
91
+ var RequestPasswordResetInputSchema = z2.object({
92
+ email: z2.email()
93
+ });
94
+ var ResetPasswordInputSchema = z2.object({
95
+ token: z2.string().min(1).meta({ description: "One-time reset token from email link" }),
96
+ newPassword: z2.string().min(8, { error: "Password must be at least 8 characters" }),
97
+ confirmPassword: z2.string().min(1)
98
+ }).refine((v) => v.newPassword === v.confirmPassword, {
99
+ error: "Passwords do not match",
100
+ path: ["confirmPassword"]
101
+ });
102
+ var SwitchBranchInputSchema = z2.object({
103
+ branchId: CuidSchema.meta({ description: "Branch to switch the active session to" })
104
+ });
105
+
106
+ export {
107
+ CuidSchema,
108
+ UuidSchema,
109
+ TimestampsSchema,
110
+ SoftDeleteSchema,
111
+ PaginationInputSchema,
112
+ paginatedOutputSchema,
113
+ BranchRefSchema,
114
+ SessionUserRoleSchema,
115
+ SessionUserSubRoleSchema,
116
+ SessionUserOutputSchema,
117
+ LoginInputSchema,
118
+ LoginOutputSchema,
119
+ RefreshTokenInputSchema,
120
+ RefreshTokenOutputSchema,
121
+ LogoutInputSchema,
122
+ ChangePasswordInputSchema,
123
+ RequestPasswordResetInputSchema,
124
+ ResetPasswordInputSchema,
125
+ SwitchBranchInputSchema
126
+ };
127
+ //# sourceMappingURL=chunk-AEZO7MJD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/base.ts","../src/schemas/auth.ts"],"sourcesContent":["/**\n * Brite Future Schools — bfs-contracts\n * Base Zod schemas: reusable primitives shared across all domain schemas.\n *\n * Phase History:\n * Phase 0.1 (2026-06-05): Initial creation\n *\n * @module src/schemas/base\n * @since Phase 0.1\n */\n\nimport * as z from 'zod'\n\n// ── ID ─────────────────────────────────────────────────────────────────────────\n\nexport const CuidSchema = z\n .string()\n .regex(/^[a-z][a-z0-9]{24}$/, 'Invalid cuid2 identifier')\n .meta({ description: 'cuid2 — prefixed, collision-resistant identifier' })\n\n// ── UUID ───────────────────────────────────────────────────────────────────────\n\nexport const UuidSchema = z\n .uuidv4()\n .meta({ description: 'RFC-4122 UUID v4' })\n\n// ── Timestamps ─────────────────────────────────────────────────────────────────\n\nconst IsoDatetime = z.iso.datetime()\n\nexport const TimestampsSchema = z.object({\n createdAt: IsoDatetime.meta({ description: 'ISO-8601 creation time (UTC)' }),\n updatedAt: IsoDatetime.meta({ description: 'ISO-8601 last update time (UTC)' }),\n})\n\n// ── Soft-delete ────────────────────────────────────────────────────────────────\n\nexport const SoftDeleteSchema = z.object({\n deletedAt: IsoDatetime.nullable().meta({\n description: 'Set when the record is soft-deleted; null if active',\n }),\n})\n\n// ── Pagination ─────────────────────────────────────────────────────────────────\n\nexport const PaginationInputSchema = z.object({\n cursor: CuidSchema.optional().meta({\n description: 'Opaque cursor from the previous page response',\n }),\n limit: z\n .int()\n .min(1)\n .max(100)\n .default(20)\n .meta({ description: 'Number of items to return (1–100, default 20)' }),\n})\n\nexport function paginatedOutputSchema<T extends z.ZodTypeAny>(itemSchema: T) {\n return z.object({\n items: z.array(itemSchema),\n nextCursor: CuidSchema.nullable().meta({\n description: 'Pass as `cursor` on the next request; null when no more pages',\n }),\n total: z\n .int()\n .nonnegative()\n .meta({ description: 'Total matching records (before pagination)' }),\n })\n}\n\n// ── Branch reference ───────────────────────────────────────────────────────────\n\nexport const BranchRefSchema = z.object({\n branchId: CuidSchema.meta({ description: 'The branch this record belongs to' }),\n})\n\n// ── Inferred types ─────────────────────────────────────────────────────────────\n\nexport type Timestamps = z.infer<typeof TimestampsSchema>\nexport type SoftDelete = z.infer<typeof SoftDeleteSchema>\nexport type PaginationInput = z.infer<typeof PaginationInputSchema>","/**\n * Brite Future Schools — bfs-contracts\n * Auth-related Zod schemas.\n *\n * Phase History:\n * Phase 0.1 (2026-06-05): Initial creation\n *\n * @module src/schemas/auth\n * @since Phase 0.1\n */\n\nimport * as z from 'zod'\nimport { CuidSchema } from './base.js'\n\n// ── Session user (defined first — referenced by LoginOutputSchema below) ───────\n\nexport const SessionUserRoleSchema = z.object({\n id: CuidSchema,\n name: z.string().meta({ description: 'Role name, e.g. PRINCIPAL' }),\n branchId: CuidSchema,\n isPrimary: z.boolean(),\n})\n\nexport const SessionUserSubRoleSchema = z.object({\n id: CuidSchema,\n name: z.string().meta({ description: 'Sub-role name, e.g. HEAD_PREFECT' }),\n branchId: CuidSchema,\n})\n\nexport const SessionUserOutputSchema = z.object({\n id: CuidSchema,\n email: z.email(),\n firstName: z.string(),\n lastName: z.string(),\n activeBranchId: CuidSchema,\n roles: z.array(SessionUserRoleSchema),\n subRoles: z.array(SessionUserSubRoleSchema),\n isActive: z.boolean(),\n mustChangePassword: z.boolean(),\n})\n\n// ── Login ──────────────────────────────────────────────────────────────────────\n\nexport const LoginInputSchema = z.object({\n email: z.email().meta({ description: 'User email address' }),\n password: z.string().min(1).meta({ description: 'Plain-text password (sent over TLS)' }),\n branchId: CuidSchema.optional().meta({\n description: 'Branch to activate on login; defaults to user primary branch',\n }),\n})\n\nexport const LoginOutputSchema = z.object({\n accessToken: z.string().meta({ description: 'Short-lived JWT (15 min)' }),\n refreshToken: z.string().meta({ description: 'Long-lived opaque refresh token (7 days)' }),\n expiresIn: z.int().positive().meta({ description: 'Access token TTL in seconds' }),\n user: SessionUserOutputSchema,\n})\n\n// ── Token refresh ──────────────────────────────────────────────────────────────\n\nexport const RefreshTokenInputSchema = z.object({\n refreshToken: z.string().min(1),\n})\n\nexport const RefreshTokenOutputSchema = z.object({\n accessToken: z.string(),\n expiresIn: z.int().positive(),\n})\n\n// ── Logout ─────────────────────────────────────────────────────────────────────\n\nexport const LogoutInputSchema = z.object({\n refreshToken: z.string().min(1).meta({\n description: 'The refresh token to revoke; also invalidated server-side',\n }),\n})\n\n// ── Password change ─────────────────────────────────────────────────────────────\n\nexport const ChangePasswordInputSchema = z\n .object({\n currentPassword: z.string().min(1),\n newPassword: z\n .string()\n .min(8, { error: 'Password must be at least 8 characters' }),\n confirmPassword: z.string().min(1),\n })\n .refine((v) => v.newPassword === v.confirmPassword, {\n error: 'Passwords do not match',\n path: ['confirmPassword'],\n })\n\n// ── Password reset ─────────────────────────────────────────────────────────────\n\nexport const RequestPasswordResetInputSchema = z.object({\n email: z.email(),\n})\n\nexport const ResetPasswordInputSchema = z\n .object({\n token: z.string().min(1).meta({ description: 'One-time reset token from email link' }),\n newPassword: z.string().min(8, { error: 'Password must be at least 8 characters' }),\n confirmPassword: z.string().min(1),\n })\n .refine((v) => v.newPassword === v.confirmPassword, {\n error: 'Passwords do not match',\n path: ['confirmPassword'],\n })\n\n// ── Branch switch ───────────────────────────────────────────────────────────────\n\nexport const SwitchBranchInputSchema = z.object({\n branchId: CuidSchema.meta({ description: 'Branch to switch the active session to' }),\n})\n\n// ── Inferred types ──────────────────────────────────────────────────────────────\n\nexport type LoginInput = z.infer<typeof LoginInputSchema>\nexport type LoginOutput = z.infer<typeof LoginOutputSchema>\nexport type SessionUserOutput = z.infer<typeof SessionUserOutputSchema>\nexport type RefreshTokenInput = z.infer<typeof RefreshTokenInputSchema>\nexport type RefreshTokenOutput = z.infer<typeof RefreshTokenOutputSchema>\nexport type ChangePasswordInput = z.infer<typeof ChangePasswordInputSchema>\nexport type SwitchBranchInput = z.infer<typeof SwitchBranchInputSchema>"],"mappings":";AAWA,YAAY,OAAO;AAIZ,IAAM,aACR,SAAO,EACP,MAAM,uBAAuB,0BAA0B,EACvD,KAAK,EAAE,aAAa,wDAAmD,CAAC;AAItE,IAAM,aACR,SAAO,EACP,KAAK,EAAE,aAAa,mBAAmB,CAAC;AAI7C,IAAM,cAAgB,MAAI,SAAS;AAE5B,IAAM,mBAAqB,SAAO;AAAA,EACrC,WAAW,YAAY,KAAK,EAAE,aAAa,+BAA+B,CAAC;AAAA,EAC3E,WAAW,YAAY,KAAK,EAAE,aAAa,kCAAkC,CAAC;AAClF,CAAC;AAIM,IAAM,mBAAqB,SAAO;AAAA,EACrC,WAAW,YAAY,SAAS,EAAE,KAAK;AAAA,IACnC,aAAa;AAAA,EACjB,CAAC;AACL,CAAC;AAIM,IAAM,wBAA0B,SAAO;AAAA,EAC1C,QAAQ,WAAW,SAAS,EAAE,KAAK;AAAA,IAC/B,aAAa;AAAA,EACjB,CAAC;AAAA,EACD,OACK,MAAI,EACJ,IAAI,CAAC,EACL,IAAI,GAAG,EACP,QAA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AAE,iBAAiB;AAAA,EAChD,OAAO;AAAA,EACP,MAAM,CAAC,iBAAiB;AAC5B,CAAC;AAIE,IAAM,0BAA4B,UAAO;AAAA,EAC5C,UAAU,WAAW,KAAK,EAAE,aAAa,yCAAyC,CAAC;AACvF,CAAC;","names":["z"]}
@@ -0,0 +1,48 @@
1
+ import {
2
+ ChangePasswordInputSchema,
3
+ LoginInputSchema,
4
+ LoginOutputSchema,
5
+ LogoutInputSchema,
6
+ RefreshTokenInputSchema,
7
+ RefreshTokenOutputSchema,
8
+ RequestPasswordResetInputSchema,
9
+ ResetPasswordInputSchema,
10
+ SessionUserOutputSchema,
11
+ SwitchBranchInputSchema
12
+ } from "./chunk-AEZO7MJD.js";
13
+
14
+ // src/contracts/auth.ts
15
+ import { oc } from "@orpc/contract";
16
+ import * as z from "zod";
17
+ var EmptyOutputSchema = z.object({}).meta({ description: "Empty success response" });
18
+ var loginContract = oc.route({ method: "POST", path: "/auth/login" }).input(LoginInputSchema).output(LoginOutputSchema);
19
+ var refreshTokenContract = oc.route({ method: "POST", path: "/auth/refresh" }).input(RefreshTokenInputSchema).output(RefreshTokenOutputSchema);
20
+ var logoutContract = oc.route({ method: "POST", path: "/auth/logout" }).input(LogoutInputSchema).output(EmptyOutputSchema);
21
+ var getMeContract = oc.route({ method: "GET", path: "/auth/me" }).output(SessionUserOutputSchema);
22
+ var changePasswordContract = oc.route({ method: "POST", path: "/auth/change-password" }).input(ChangePasswordInputSchema).output(EmptyOutputSchema);
23
+ var requestPasswordResetContract = oc.route({ method: "POST", path: "/auth/request-password-reset" }).input(RequestPasswordResetInputSchema).output(EmptyOutputSchema);
24
+ var resetPasswordContract = oc.route({ method: "POST", path: "/auth/reset-password" }).input(ResetPasswordInputSchema).output(EmptyOutputSchema);
25
+ var switchBranchContract = oc.route({ method: "POST", path: "/auth/switch-branch" }).input(SwitchBranchInputSchema).output(SessionUserOutputSchema);
26
+ var authContract = {
27
+ login: loginContract,
28
+ refreshToken: refreshTokenContract,
29
+ logout: logoutContract,
30
+ me: getMeContract,
31
+ changePassword: changePasswordContract,
32
+ requestPasswordReset: requestPasswordResetContract,
33
+ resetPassword: resetPasswordContract,
34
+ switchBranch: switchBranchContract
35
+ };
36
+
37
+ export {
38
+ loginContract,
39
+ refreshTokenContract,
40
+ logoutContract,
41
+ getMeContract,
42
+ changePasswordContract,
43
+ requestPasswordResetContract,
44
+ resetPasswordContract,
45
+ switchBranchContract,
46
+ authContract
47
+ };
48
+ //# sourceMappingURL=chunk-IR6JUP6L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/contracts/auth.ts"],"sourcesContent":["/**\n * Brite Future Schools — bfs-contracts\n * Auth oRPC contract.\n *\n * Defines the API surface for authentication. The bfs-api module\n * imports this and passes it to `implement()` — no logic lives here.\n *\n * HTTP method + path pairs follow REST conventions and feed into the\n * OpenAPI spec that oRPC generates automatically.\n *\n * Phase History:\n * Phase 0.1 (2026-06-05): Initial creation\n *\n * @module src/contracts/auth\n * @since Phase 0.1\n */\n\nimport { oc } from '@orpc/contract'\nimport * as z from 'zod'\nimport {\n ChangePasswordInputSchema,\n LoginInputSchema,\n LoginOutputSchema,\n LogoutInputSchema,\n RefreshTokenInputSchema,\n RefreshTokenOutputSchema,\n RequestPasswordResetInputSchema,\n ResetPasswordInputSchema,\n SessionUserOutputSchema,\n SwitchBranchInputSchema,\n} from '../schemas/auth.js'\n\n/** Reusable empty-success output — used by mutations that return nothing */\nconst EmptyOutputSchema = z.object({}).meta({ description: 'Empty success response' })\n\n// ── Individual procedure contracts ────────────────────────────────────────────\n\n/** Exchange email + password for access/refresh token pair */\nexport const loginContract = oc\n .route({ method: 'POST', path: '/auth/login' })\n .input(LoginInputSchema)\n .output(LoginOutputSchema)\n\n/** Exchange a refresh token for a new access token */\nexport const refreshTokenContract = oc\n .route({ method: 'POST', path: '/auth/refresh' })\n .input(RefreshTokenInputSchema)\n .output(RefreshTokenOutputSchema)\n\n/** Revoke the current refresh token and end the session */\nexport const logoutContract = oc\n .route({ method: 'POST', path: '/auth/logout' })\n .input(LogoutInputSchema)\n .output(EmptyOutputSchema)\n\n/** Return the session user object for the current access token */\nexport const getMeContract = oc\n .route({ method: 'GET', path: '/auth/me' })\n .output(SessionUserOutputSchema)\n\n/** Change password (authenticated, requires current password) */\nexport const changePasswordContract = oc\n .route({ method: 'POST', path: '/auth/change-password' })\n .input(ChangePasswordInputSchema)\n .output(EmptyOutputSchema)\n\n/** Request a password-reset email */\nexport const requestPasswordResetContract = oc\n .route({ method: 'POST', path: '/auth/request-password-reset' })\n .input(RequestPasswordResetInputSchema)\n .output(EmptyOutputSchema)\n\n/** Complete a password reset using the emailed one-time token */\nexport const resetPasswordContract = oc\n .route({ method: 'POST', path: '/auth/reset-password' })\n .input(ResetPasswordInputSchema)\n .output(EmptyOutputSchema)\n\n/** Switch the active branch within an existing session */\nexport const switchBranchContract = oc\n .route({ method: 'POST', path: '/auth/switch-branch' })\n .input(SwitchBranchInputSchema)\n .output(SessionUserOutputSchema)\n\n// ── Auth contract router ──────────────────────────────────────────────────────\n\nexport const authContract = {\n login: loginContract,\n refreshToken: refreshTokenContract,\n logout: logoutContract,\n me: getMeContract,\n changePassword: changePasswordContract,\n requestPasswordReset: requestPasswordResetContract,\n resetPassword: resetPasswordContract,\n switchBranch: switchBranchContract,\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAS,UAAU;AACnB,YAAY,OAAO;AAenB,IAAM,oBAAsB,SAAO,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,yBAAyB,CAAC;AAK9E,IAAM,gBAAgB,GAC1B,MAAM,EAAE,QAAQ,QAAQ,MAAM,cAAc,CAAC,EAC7C,MAAM,gBAAgB,EACtB,OAAO,iBAAiB;AAGpB,IAAM,uBAAuB,GACjC,MAAM,EAAE,QAAQ,QAAQ,MAAM,gBAAgB,CAAC,EAC/C,MAAM,uBAAuB,EAC7B,OAAO,wBAAwB;AAG3B,IAAM,iBAAiB,GAC3B,MAAM,EAAE,QAAQ,QAAQ,MAAM,eAAe,CAAC,EAC9C,MAAM,iBAAiB,EACvB,OAAO,iBAAiB;AAGpB,IAAM,gBAAgB,GAC1B,MAAM,EAAE,QAAQ,OAAO,MAAM,WAAW,CAAC,EACzC,OAAO,uBAAuB;AAG1B,IAAM,yBAAyB,GACnC,MAAM,EAAE,QAAQ,QAAQ,MAAM,wBAAwB,CAAC,EACvD,MAAM,yBAAyB,EAC/B,OAAO,iBAAiB;AAGpB,IAAM,+BAA+B,GACzC,MAAM,EAAE,QAAQ,QAAQ,MAAM,+BAA+B,CAAC,EAC9D,MAAM,+BAA+B,EACrC,OAAO,iBAAiB;AAGpB,IAAM,wBAAwB,GAClC,MAAM,EAAE,QAAQ,QAAQ,MAAM,uBAAuB,CAAC,EACtD,MAAM,wBAAwB,EAC9B,OAAO,iBAAiB;AAGpB,IAAM,uBAAuB,GACjC,MAAM,EAAE,QAAQ,QAAQ,MAAM,sBAAsB,CAAC,EACrD,MAAM,uBAAuB,EAC7B,OAAO,uBAAuB;AAI1B,IAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,EACP,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,cAAc;AAChB;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-PCHAGP5X.js.map
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/contracts/index.ts
31
+ var contracts_exports = {};
32
+ __export(contracts_exports, {
33
+ authContract: () => authContract,
34
+ changePasswordContract: () => changePasswordContract,
35
+ getMeContract: () => getMeContract,
36
+ loginContract: () => loginContract,
37
+ logoutContract: () => logoutContract,
38
+ refreshTokenContract: () => refreshTokenContract,
39
+ requestPasswordResetContract: () => requestPasswordResetContract,
40
+ resetPasswordContract: () => resetPasswordContract,
41
+ switchBranchContract: () => switchBranchContract
42
+ });
43
+ module.exports = __toCommonJS(contracts_exports);
44
+
45
+ // src/contracts/auth.ts
46
+ var import_contract = require("@orpc/contract");
47
+ var z3 = __toESM(require("zod"), 1);
48
+
49
+ // src/schemas/auth.ts
50
+ var z2 = __toESM(require("zod"), 1);
51
+
52
+ // src/schemas/base.ts
53
+ var z = __toESM(require("zod"), 1);
54
+ var CuidSchema = z.string().regex(/^[a-z][a-z0-9]{24}$/, "Invalid cuid2 identifier").meta({ description: "cuid2 \u2014 prefixed, collision-resistant identifier" });
55
+ var UuidSchema = z.uuidv4().meta({ description: "RFC-4122 UUID v4" });
56
+ var IsoDatetime = z.iso.datetime();
57
+ var TimestampsSchema = z.object({
58
+ createdAt: IsoDatetime.meta({ description: "ISO-8601 creation time (UTC)" }),
59
+ updatedAt: IsoDatetime.meta({ description: "ISO-8601 last update time (UTC)" })
60
+ });
61
+ var SoftDeleteSchema = z.object({
62
+ deletedAt: IsoDatetime.nullable().meta({
63
+ description: "Set when the record is soft-deleted; null if active"
64
+ })
65
+ });
66
+ var PaginationInputSchema = z.object({
67
+ cursor: CuidSchema.optional().meta({
68
+ description: "Opaque cursor from the previous page response"
69
+ }),
70
+ limit: z.int().min(1).max(100).default(20).meta({ description: "Number of items to return (1\u2013100, default 20)" })
71
+ });
72
+ var BranchRefSchema = z.object({
73
+ branchId: CuidSchema.meta({ description: "The branch this record belongs to" })
74
+ });
75
+
76
+ // src/schemas/auth.ts
77
+ var SessionUserRoleSchema = z2.object({
78
+ id: CuidSchema,
79
+ name: z2.string().meta({ description: "Role name, e.g. PRINCIPAL" }),
80
+ branchId: CuidSchema,
81
+ isPrimary: z2.boolean()
82
+ });
83
+ var SessionUserSubRoleSchema = z2.object({
84
+ id: CuidSchema,
85
+ name: z2.string().meta({ description: "Sub-role name, e.g. HEAD_PREFECT" }),
86
+ branchId: CuidSchema
87
+ });
88
+ var SessionUserOutputSchema = z2.object({
89
+ id: CuidSchema,
90
+ email: z2.email(),
91
+ firstName: z2.string(),
92
+ lastName: z2.string(),
93
+ activeBranchId: CuidSchema,
94
+ roles: z2.array(SessionUserRoleSchema),
95
+ subRoles: z2.array(SessionUserSubRoleSchema),
96
+ isActive: z2.boolean(),
97
+ mustChangePassword: z2.boolean()
98
+ });
99
+ var LoginInputSchema = z2.object({
100
+ email: z2.email().meta({ description: "User email address" }),
101
+ password: z2.string().min(1).meta({ description: "Plain-text password (sent over TLS)" }),
102
+ branchId: CuidSchema.optional().meta({
103
+ description: "Branch to activate on login; defaults to user primary branch"
104
+ })
105
+ });
106
+ var LoginOutputSchema = z2.object({
107
+ accessToken: z2.string().meta({ description: "Short-lived JWT (15 min)" }),
108
+ refreshToken: z2.string().meta({ description: "Long-lived opaque refresh token (7 days)" }),
109
+ expiresIn: z2.int().positive().meta({ description: "Access token TTL in seconds" }),
110
+ user: SessionUserOutputSchema
111
+ });
112
+ var RefreshTokenInputSchema = z2.object({
113
+ refreshToken: z2.string().min(1)
114
+ });
115
+ var RefreshTokenOutputSchema = z2.object({
116
+ accessToken: z2.string(),
117
+ expiresIn: z2.int().positive()
118
+ });
119
+ var LogoutInputSchema = z2.object({
120
+ refreshToken: z2.string().min(1).meta({
121
+ description: "The refresh token to revoke; also invalidated server-side"
122
+ })
123
+ });
124
+ var ChangePasswordInputSchema = z2.object({
125
+ currentPassword: z2.string().min(1),
126
+ newPassword: z2.string().min(8, { error: "Password must be at least 8 characters" }),
127
+ confirmPassword: z2.string().min(1)
128
+ }).refine((v) => v.newPassword === v.confirmPassword, {
129
+ error: "Passwords do not match",
130
+ path: ["confirmPassword"]
131
+ });
132
+ var RequestPasswordResetInputSchema = z2.object({
133
+ email: z2.email()
134
+ });
135
+ var ResetPasswordInputSchema = z2.object({
136
+ token: z2.string().min(1).meta({ description: "One-time reset token from email link" }),
137
+ newPassword: z2.string().min(8, { error: "Password must be at least 8 characters" }),
138
+ confirmPassword: z2.string().min(1)
139
+ }).refine((v) => v.newPassword === v.confirmPassword, {
140
+ error: "Passwords do not match",
141
+ path: ["confirmPassword"]
142
+ });
143
+ var SwitchBranchInputSchema = z2.object({
144
+ branchId: CuidSchema.meta({ description: "Branch to switch the active session to" })
145
+ });
146
+
147
+ // src/contracts/auth.ts
148
+ var EmptyOutputSchema = z3.object({}).meta({ description: "Empty success response" });
149
+ var loginContract = import_contract.oc.route({ method: "POST", path: "/auth/login" }).input(LoginInputSchema).output(LoginOutputSchema);
150
+ var refreshTokenContract = import_contract.oc.route({ method: "POST", path: "/auth/refresh" }).input(RefreshTokenInputSchema).output(RefreshTokenOutputSchema);
151
+ var logoutContract = import_contract.oc.route({ method: "POST", path: "/auth/logout" }).input(LogoutInputSchema).output(EmptyOutputSchema);
152
+ var getMeContract = import_contract.oc.route({ method: "GET", path: "/auth/me" }).output(SessionUserOutputSchema);
153
+ var changePasswordContract = import_contract.oc.route({ method: "POST", path: "/auth/change-password" }).input(ChangePasswordInputSchema).output(EmptyOutputSchema);
154
+ var requestPasswordResetContract = import_contract.oc.route({ method: "POST", path: "/auth/request-password-reset" }).input(RequestPasswordResetInputSchema).output(EmptyOutputSchema);
155
+ var resetPasswordContract = import_contract.oc.route({ method: "POST", path: "/auth/reset-password" }).input(ResetPasswordInputSchema).output(EmptyOutputSchema);
156
+ var switchBranchContract = import_contract.oc.route({ method: "POST", path: "/auth/switch-branch" }).input(SwitchBranchInputSchema).output(SessionUserOutputSchema);
157
+ var authContract = {
158
+ login: loginContract,
159
+ refreshToken: refreshTokenContract,
160
+ logout: logoutContract,
161
+ me: getMeContract,
162
+ changePassword: changePasswordContract,
163
+ requestPasswordReset: requestPasswordResetContract,
164
+ resetPassword: resetPasswordContract,
165
+ switchBranch: switchBranchContract
166
+ };
167
+ // Annotate the CommonJS export names for ESM import in node:
168
+ 0 && (module.exports = {
169
+ authContract,
170
+ changePasswordContract,
171
+ getMeContract,
172
+ loginContract,
173
+ logoutContract,
174
+ refreshTokenContract,
175
+ requestPasswordResetContract,
176
+ resetPasswordContract,
177
+ switchBranchContract
178
+ });
179
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/contracts/index.ts","../../src/contracts/auth.ts","../../src/schemas/auth.ts","../../src/schemas/base.ts"],"sourcesContent":["/**\n * Brite Future Schools — bfs-contracts\n * Contracts barrel.\n *\n * @module src/contracts/index\n * @since Phase 0.1\n */\n\nexport * from './auth.js'","/**\n * Brite Future Schools — bfs-contracts\n * Auth oRPC contract.\n *\n * Defines the API surface for authentication. The bfs-api module\n * imports this and passes it to `implement()` — no logic lives here.\n *\n * HTTP method + path pairs follow REST conventions and feed into the\n * OpenAPI spec that oRPC generates automatically.\n *\n * Phase History:\n * Phase 0.1 (2026-06-05): Initial creation\n *\n * @module src/contracts/auth\n * @since Phase 0.1\n */\n\nimport { oc } from '@orpc/contract'\nimport * as z from 'zod'\nimport {\n ChangePasswordInputSchema,\n LoginInputSchema,\n LoginOutputSchema,\n LogoutInputSchema,\n RefreshTokenInputSchema,\n RefreshTokenOutputSchema,\n RequestPasswordResetInputSchema,\n ResetPasswordInputSchema,\n SessionUserOutputSchema,\n SwitchBranchInputSchema,\n} from '../schemas/auth.js'\n\n/** Reusable empty-success output — used by mutations that return nothing */\nconst EmptyOutputSchema = z.object({}).meta({ description: 'Empty success response' })\n\n// ── Individual procedure contracts ────────────────────────────────────────────\n\n/** Exchange email + password for access/refresh token pair */\nexport const loginContract = oc\n .route({ method: 'POST', path: '/auth/login' })\n .input(LoginInputSchema)\n .output(LoginOutputSchema)\n\n/** Exchange a refresh token for a new access token */\nexport const refreshTokenContract = oc\n .route({ method: 'POST', path: '/auth/refresh' })\n .input(RefreshTokenInputSchema)\n .output(RefreshTokenOutputSchema)\n\n/** Revoke the current refresh token and end the session */\nexport const logoutContract = oc\n .route({ method: 'POST', path: '/auth/logout' })\n .input(LogoutInputSchema)\n .output(EmptyOutputSchema)\n\n/** Return the session user object for the current access token */\nexport const getMeContract = oc\n .route({ method: 'GET', path: '/auth/me' })\n .output(SessionUserOutputSchema)\n\n/** Change password (authenticated, requires current password) */\nexport const changePasswordContract = oc\n .route({ method: 'POST', path: '/auth/change-password' })\n .input(ChangePasswordInputSchema)\n .output(EmptyOutputSchema)\n\n/** Request a password-reset email */\nexport const requestPasswordResetContract = oc\n .route({ method: 'POST', path: '/auth/request-password-reset' })\n .input(RequestPasswordResetInputSchema)\n .output(EmptyOutputSchema)\n\n/** Complete a password reset using the emailed one-time token */\nexport const resetPasswordContract = oc\n .route({ method: 'POST', path: '/auth/reset-password' })\n .input(ResetPasswordInputSchema)\n .output(EmptyOutputSchema)\n\n/** Switch the active branch within an existing session */\nexport const switchBranchContract = oc\n .route({ method: 'POST', path: '/auth/switch-branch' })\n .input(SwitchBranchInputSchema)\n .output(SessionUserOutputSchema)\n\n// ── Auth contract router ──────────────────────────────────────────────────────\n\nexport const authContract = {\n login: loginContract,\n refreshToken: refreshTokenContract,\n logout: logoutContract,\n me: getMeContract,\n changePassword: changePasswordContract,\n requestPasswordReset: requestPasswordResetContract,\n resetPassword: resetPasswordContract,\n switchBranch: switchBranchContract,\n}\n","/**\n * Brite Future Schools — bfs-contracts\n * Auth-related Zod schemas.\n *\n * Phase History:\n * Phase 0.1 (2026-06-05): Initial creation\n *\n * @module src/schemas/auth\n * @since Phase 0.1\n */\n\nimport * as z from 'zod'\nimport { CuidSchema } from './base.js'\n\n// ── Session user (defined first — referenced by LoginOutputSchema below) ───────\n\nexport const SessionUserRoleSchema = z.object({\n id: CuidSchema,\n name: z.string().meta({ description: 'Role name, e.g. PRINCIPAL' }),\n branchId: CuidSchema,\n isPrimary: z.boolean(),\n})\n\nexport const SessionUserSubRoleSchema = z.object({\n id: CuidSchema,\n name: z.string().meta({ description: 'Sub-role name, e.g. HEAD_PREFECT' }),\n branchId: CuidSchema,\n})\n\nexport const SessionUserOutputSchema = z.object({\n id: CuidSchema,\n email: z.email(),\n firstName: z.string(),\n lastName: z.string(),\n activeBranchId: CuidSchema,\n roles: z.array(SessionUserRoleSchema),\n subRoles: z.array(SessionUserSubRoleSchema),\n isActive: z.boolean(),\n mustChangePassword: z.boolean(),\n})\n\n// ── Login ──────────────────────────────────────────────────────────────────────\n\nexport const LoginInputSchema = z.object({\n email: z.email().meta({ description: 'User email address' }),\n password: z.string().min(1).meta({ description: 'Plain-text password (sent over TLS)' }),\n branchId: CuidSchema.optional().meta({\n description: 'Branch to activate on login; defaults to user primary branch',\n }),\n})\n\nexport const LoginOutputSchema = z.object({\n accessToken: z.string().meta({ description: 'Short-lived JWT (15 min)' }),\n refreshToken: z.string().meta({ description: 'Long-lived opaque refresh token (7 days)' }),\n expiresIn: z.int().positive().meta({ description: 'Access token TTL in seconds' }),\n user: SessionUserOutputSchema,\n})\n\n// ── Token refresh ──────────────────────────────────────────────────────────────\n\nexport const RefreshTokenInputSchema = z.object({\n refreshToken: z.string().min(1),\n})\n\nexport const RefreshTokenOutputSchema = z.object({\n accessToken: z.string(),\n expiresIn: z.int().positive(),\n})\n\n// ── Logout ─────────────────────────────────────────────────────────────────────\n\nexport const LogoutInputSchema = z.object({\n refreshToken: z.string().min(1).meta({\n description: 'The refresh token to revoke; also invalidated server-side',\n }),\n})\n\n// ── Password change ─────────────────────────────────────────────────────────────\n\nexport const ChangePasswordInputSchema = z\n .object({\n currentPassword: z.string().min(1),\n newPassword: z\n .string()\n .min(8, { error: 'Password must be at least 8 characters' }),\n confirmPassword: z.string().min(1),\n })\n .refine((v) => v.newPassword === v.confirmPassword, {\n error: 'Passwords do not match',\n path: ['confirmPassword'],\n })\n\n// ── Password reset ─────────────────────────────────────────────────────────────\n\nexport const RequestPasswordResetInputSchema = z.object({\n email: z.email(),\n})\n\nexport const ResetPasswordInputSchema = z\n .object({\n token: z.string().min(1).meta({ description: 'One-time reset token from email link' }),\n newPassword: z.string().min(8, { error: 'Password must be at least 8 characters' }),\n confirmPassword: z.string().min(1),\n })\n .refine((v) => v.newPassword === v.confirmPassword, {\n error: 'Passwords do not match',\n path: ['confirmPassword'],\n })\n\n// ── Branch switch ───────────────────────────────────────────────────────────────\n\nexport const SwitchBranchInputSchema = z.object({\n branchId: CuidSchema.meta({ description: 'Branch to switch the active session to' }),\n})\n\n// ── Inferred types ──────────────────────────────────────────────────────────────\n\nexport type LoginInput = z.infer<typeof LoginInputSchema>\nexport type LoginOutput = z.infer<typeof LoginOutputSchema>\nexport type SessionUserOutput = z.infer<typeof SessionUserOutputSchema>\nexport type RefreshTokenInput = z.infer<typeof RefreshTokenInputSchema>\nexport type RefreshTokenOutput = z.infer<typeof RefreshTokenOutputSchema>\nexport type ChangePasswordInput = z.infer<typeof ChangePasswordInputSchema>\nexport type SwitchBranchInput = z.infer<typeof SwitchBranchInputSchema>","/**\n * Brite Future Schools — bfs-contracts\n * Base Zod schemas: reusable primitives shared across all domain schemas.\n *\n * Phase History:\n * Phase 0.1 (2026-06-05): Initial creation\n *\n * @module src/schemas/base\n * @since Phase 0.1\n */\n\nimport * as z from 'zod'\n\n// ── ID ─────────────────────────────────────────────────────────────────────────\n\nexport const CuidSchema = z\n .string()\n .regex(/^[a-z][a-z0-9]{24}$/, 'Invalid cuid2 identifier')\n .meta({ description: 'cuid2 — prefixed, collision-resistant identifier' })\n\n// ── UUID ───────────────────────────────────────────────────────────────────────\n\nexport const UuidSchema = z\n .uuidv4()\n .meta({ description: 'RFC-4122 UUID v4' })\n\n// ── Timestamps ─────────────────────────────────────────────────────────────────\n\nconst IsoDatetime = z.iso.datetime()\n\nexport const TimestampsSchema = z.object({\n createdAt: IsoDatetime.meta({ description: 'ISO-8601 creation time (UTC)' }),\n updatedAt: IsoDatetime.meta({ description: 'ISO-8601 last update time (UTC)' }),\n})\n\n// ── Soft-delete ────────────────────────────────────────────────────────────────\n\nexport const SoftDeleteSchema = z.object({\n deletedAt: IsoDatetime.nullable().meta({\n description: 'Set when the record is soft-deleted; null if active',\n }),\n})\n\n// ── Pagination ─────────────────────────────────────────────────────────────────\n\nexport const PaginationInputSchema = z.object({\n cursor: CuidSchema.optional().meta({\n description: 'Opaque cursor from the previous page response',\n }),\n limit: z\n .int()\n .min(1)\n .max(100)\n .default(20)\n .meta({ description: 'Number of items to return (1–100, default 20)' }),\n})\n\nexport function paginatedOutputSchema<T extends z.ZodTypeAny>(itemSchema: T) {\n return z.object({\n items: z.array(itemSchema),\n nextCursor: CuidSchema.nullable().meta({\n description: 'Pass as `cursor` on the next request; null when no more pages',\n }),\n total: z\n .int()\n .nonnegative()\n .meta({ description: 'Total matching records (before pagination)' }),\n })\n}\n\n// ── Branch reference ───────────────────────────────────────────────────────────\n\nexport const BranchRefSchema = z.object({\n branchId: CuidSchema.meta({ description: 'The branch this record belongs to' }),\n})\n\n// ── Inferred types ─────────────────────────────────────────────────────────────\n\nexport type Timestamps = z.infer<typeof TimestampsSchema>\nexport type S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AGpB,IAAM,gBAAgB,mBAC1B,MAAM,EAAE,QAAQ,OAAO,MAAM,WAAW,CAAC,EACzC,OAAO,uBAAuB;AAG1B,IAAM,yBAAyB,mBACnC,MAAM,EAAE,QAAQ,QAAQ,MAAM,wBAAwB,CAAC,EACvD,MAAM,yBAAyB,EAC/B,OAAO,iBAAiB;AAGpB,IAAM,+BAA+B,mBACzC,MAAM,EAAE,QAAQ,QAAQ,MAAM,+BAA+B,CAAC,EAC9D,MAAM,+BAA+B,EACrC,OAAO,iBAAiB;AAGpB,IAAM,wBAAwB,mBAClC,MAAM,EAAE,QAAQ,QAAQ,MAAM,uBAAuB,CAAC,EACtD,MAAM,wBAAwB,EAC9B,OAAO,iBAAiB;AAGpB,IAAM,uBAAuB,mBACjC,MAAM,EAAE,QAAQ,QAAQ,MAAM,sBAAsB,CAAC,EACrD,MAAM,uBAAuB,EAC7B,OAAO,uBAAuB;AAI1B,IAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,EACP,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,cAAc;AAChB;","names":["z","z"]}
@@ -0,0 +1,201 @@
1
+ import * as _orpc_contract from '@orpc/contract';
2
+ import * as z from 'zod';
3
+
4
+ /** Exchange email + password for access/refresh token pair */
5
+ declare const loginContract: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
6
+ email: z.ZodEmail;
7
+ password: z.ZodString;
8
+ branchId: z.ZodOptional<z.ZodString>;
9
+ }, z.core.$strip>, z.ZodObject<{
10
+ accessToken: z.ZodString;
11
+ refreshToken: z.ZodString;
12
+ expiresIn: z.ZodInt;
13
+ user: z.ZodObject<{
14
+ id: z.ZodString;
15
+ email: z.ZodEmail;
16
+ firstName: z.ZodString;
17
+ lastName: z.ZodString;
18
+ activeBranchId: z.ZodString;
19
+ roles: z.ZodArray<z.ZodObject<{
20
+ id: z.ZodString;
21
+ name: z.ZodString;
22
+ branchId: z.ZodString;
23
+ isPrimary: z.ZodBoolean;
24
+ }, z.core.$strip>>;
25
+ subRoles: z.ZodArray<z.ZodObject<{
26
+ id: z.ZodString;
27
+ name: z.ZodString;
28
+ branchId: z.ZodString;
29
+ }, z.core.$strip>>;
30
+ isActive: z.ZodBoolean;
31
+ mustChangePassword: z.ZodBoolean;
32
+ }, z.core.$strip>;
33
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
34
+ /** Exchange a refresh token for a new access token */
35
+ declare const refreshTokenContract: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
36
+ refreshToken: z.ZodString;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ accessToken: z.ZodString;
39
+ expiresIn: z.ZodInt;
40
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
41
+ /** Revoke the current refresh token and end the session */
42
+ declare const logoutContract: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
43
+ refreshToken: z.ZodString;
44
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
45
+ /** Return the session user object for the current access token */
46
+ declare const getMeContract: _orpc_contract.ContractProcedureBuilderWithOutput<_orpc_contract.Schema<unknown, unknown>, z.ZodObject<{
47
+ id: z.ZodString;
48
+ email: z.ZodEmail;
49
+ firstName: z.ZodString;
50
+ lastName: z.ZodString;
51
+ activeBranchId: z.ZodString;
52
+ roles: z.ZodArray<z.ZodObject<{
53
+ id: z.ZodString;
54
+ name: z.ZodString;
55
+ branchId: z.ZodString;
56
+ isPrimary: z.ZodBoolean;
57
+ }, z.core.$strip>>;
58
+ subRoles: z.ZodArray<z.ZodObject<{
59
+ id: z.ZodString;
60
+ name: z.ZodString;
61
+ branchId: z.ZodString;
62
+ }, z.core.$strip>>;
63
+ isActive: z.ZodBoolean;
64
+ mustChangePassword: z.ZodBoolean;
65
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
66
+ /** Change password (authenticated, requires current password) */
67
+ declare const changePasswordContract: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
68
+ currentPassword: z.ZodString;
69
+ newPassword: z.ZodString;
70
+ confirmPassword: z.ZodString;
71
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
72
+ /** Request a password-reset email */
73
+ declare const requestPasswordResetContract: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
74
+ email: z.ZodEmail;
75
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
76
+ /** Complete a password reset using the emailed one-time token */
77
+ declare const resetPasswordContract: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
78
+ token: z.ZodString;
79
+ newPassword: z.ZodString;
80
+ confirmPassword: z.ZodString;
81
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
82
+ /** Switch the active branch within an existing session */
83
+ declare const switchBranchContract: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
84
+ branchId: z.ZodString;
85
+ }, z.core.$strip>, z.ZodObject<{
86
+ id: z.ZodString;
87
+ email: z.ZodEmail;
88
+ firstName: z.ZodString;
89
+ lastName: z.ZodString;
90
+ activeBranchId: z.ZodString;
91
+ roles: z.ZodArray<z.ZodObject<{
92
+ id: z.ZodString;
93
+ name: z.ZodString;
94
+ branchId: z.ZodString;
95
+ isPrimary: z.ZodBoolean;
96
+ }, z.core.$strip>>;
97
+ subRoles: z.ZodArray<z.ZodObject<{
98
+ id: z.ZodString;
99
+ name: z.ZodString;
100
+ branchId: z.ZodString;
101
+ }, z.core.$strip>>;
102
+ isActive: z.ZodBoolean;
103
+ mustChangePassword: z.ZodBoolean;
104
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
105
+ declare const authContract: {
106
+ login: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
107
+ email: z.ZodEmail;
108
+ password: z.ZodString;
109
+ branchId: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strip>, z.ZodObject<{
111
+ accessToken: z.ZodString;
112
+ refreshToken: z.ZodString;
113
+ expiresIn: z.ZodInt;
114
+ user: z.ZodObject<{
115
+ id: z.ZodString;
116
+ email: z.ZodEmail;
117
+ firstName: z.ZodString;
118
+ lastName: z.ZodString;
119
+ activeBranchId: z.ZodString;
120
+ roles: z.ZodArray<z.ZodObject<{
121
+ id: z.ZodString;
122
+ name: z.ZodString;
123
+ branchId: z.ZodString;
124
+ isPrimary: z.ZodBoolean;
125
+ }, z.core.$strip>>;
126
+ subRoles: z.ZodArray<z.ZodObject<{
127
+ id: z.ZodString;
128
+ name: z.ZodString;
129
+ branchId: z.ZodString;
130
+ }, z.core.$strip>>;
131
+ isActive: z.ZodBoolean;
132
+ mustChangePassword: z.ZodBoolean;
133
+ }, z.core.$strip>;
134
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
135
+ refreshToken: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
136
+ refreshToken: z.ZodString;
137
+ }, z.core.$strip>, z.ZodObject<{
138
+ accessToken: z.ZodString;
139
+ expiresIn: z.ZodInt;
140
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
141
+ logout: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
142
+ refreshToken: z.ZodString;
143
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
144
+ me: _orpc_contract.ContractProcedureBuilderWithOutput<_orpc_contract.Schema<unknown, unknown>, z.ZodObject<{
145
+ id: z.ZodString;
146
+ email: z.ZodEmail;
147
+ firstName: z.ZodString;
148
+ lastName: z.ZodString;
149
+ activeBranchId: z.ZodString;
150
+ roles: z.ZodArray<z.ZodObject<{
151
+ id: z.ZodString;
152
+ name: z.ZodString;
153
+ branchId: z.ZodString;
154
+ isPrimary: z.ZodBoolean;
155
+ }, z.core.$strip>>;
156
+ subRoles: z.ZodArray<z.ZodObject<{
157
+ id: z.ZodString;
158
+ name: z.ZodString;
159
+ branchId: z.ZodString;
160
+ }, z.core.$strip>>;
161
+ isActive: z.ZodBoolean;
162
+ mustChangePassword: z.ZodBoolean;
163
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
164
+ changePassword: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
165
+ currentPassword: z.ZodString;
166
+ newPassword: z.ZodString;
167
+ confirmPassword: z.ZodString;
168
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
169
+ requestPasswordReset: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
170
+ email: z.ZodEmail;
171
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
172
+ resetPassword: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
173
+ token: z.ZodString;
174
+ newPassword: z.ZodString;
175
+ confirmPassword: z.ZodString;
176
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, Record<never, never>, Record<never, never>>;
177
+ switchBranch: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
178
+ branchId: z.ZodString;
179
+ }, z.core.$strip>, z.ZodObject<{
180
+ id: z.ZodString;
181
+ email: z.ZodEmail;
182
+ firstName: z.ZodString;
183
+ lastName: z.ZodString;
184
+ activeBranchId: z.ZodString;
185
+ roles: z.ZodArray<z.ZodObject<{
186
+ id: z.ZodString;
187
+ name: z.ZodString;
188
+ branchId: z.ZodString;
189
+ isPrimary: z.ZodBoolean;
190
+ }, z.core.$strip>>;
191
+ subRoles: z.ZodArray<z.ZodObject<{
192
+ id: z.ZodString;
193
+ name: z.ZodString;
194
+ branchId: z.ZodString;
195
+ }, z.core.$strip>>;
196
+ isActive: z.ZodBoolean;
197
+ mustChangePassword: z.ZodBoolean;
198
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
199
+ };
200
+
201
+ export { authContract, changePasswordContract, getMeContract, loginContract, logoutContract, refreshTokenContract, requestPasswordResetContract, resetPasswordContract, switchBranchContract };