@esb-market-contracts/admin-backend 1.8.44 → 1.8.45
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/index.d.ts +3 -1
- package/index.js +2 -1
- package/package.json +8 -2
- package/schemas.d.ts +34 -0
- package/schemas.js +314 -0
package/index.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ export type * from './api';
|
|
|
2
2
|
export type * from './enums';
|
|
3
3
|
export type * from './types';
|
|
4
4
|
export type * from './constants';
|
|
5
|
+
export type * from './schemas';
|
|
5
6
|
export * from './enums';
|
|
6
|
-
export * from './constants';
|
|
7
|
+
export * from './constants';
|
|
8
|
+
export * from './schemas';
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esb-market-contracts/admin-backend",
|
|
3
3
|
"description": "Shared TypeScript contract definitions for admin-backend.",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.45",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
"types.d.ts",
|
|
16
16
|
"types.js",
|
|
17
17
|
"constants.d.ts",
|
|
18
|
-
"constants.js"
|
|
18
|
+
"constants.js",
|
|
19
|
+
"schemas.d.ts",
|
|
20
|
+
"schemas.js"
|
|
19
21
|
],
|
|
20
22
|
"exports": {
|
|
21
23
|
".": {
|
|
@@ -37,6 +39,10 @@
|
|
|
37
39
|
"./constants": {
|
|
38
40
|
"types": "./constants.d.ts",
|
|
39
41
|
"default": "./constants.js"
|
|
42
|
+
},
|
|
43
|
+
"./schemas": {
|
|
44
|
+
"types": "./schemas.d.ts",
|
|
45
|
+
"default": "./schemas.js"
|
|
40
46
|
}
|
|
41
47
|
},
|
|
42
48
|
"types": "./index.d.ts"
|
package/schemas.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export declare const sessionPayloadSchema: z.ZodObject<{
|
|
6
|
+
employee: z.ZodObject<{
|
|
7
|
+
id: z.ZodInt;
|
|
8
|
+
status: z.ZodEnum<{
|
|
9
|
+
active: "active";
|
|
10
|
+
suspended: "suspended";
|
|
11
|
+
}>;
|
|
12
|
+
updatedAt: z.ZodNullable<z.ZodDate>;
|
|
13
|
+
createdAt: z.ZodDate;
|
|
14
|
+
email: z.ZodString;
|
|
15
|
+
fullName: z.ZodString;
|
|
16
|
+
grants: z.ZodArray<z.ZodEnum<{
|
|
17
|
+
"employee.create": "employee.create";
|
|
18
|
+
"employee.read": "employee.read";
|
|
19
|
+
"employee.update": "employee.update";
|
|
20
|
+
"inventory.create": "inventory.create";
|
|
21
|
+
"inventory.read": "inventory.read";
|
|
22
|
+
"inventory.update": "inventory.update";
|
|
23
|
+
"inventory.write_off": "inventory.write_off";
|
|
24
|
+
"category.create": "category.create";
|
|
25
|
+
"category.read": "category.read";
|
|
26
|
+
"category.update": "category.update";
|
|
27
|
+
}>>;
|
|
28
|
+
}, {
|
|
29
|
+
out: {};
|
|
30
|
+
in: {};
|
|
31
|
+
}>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
|
|
34
|
+
export {};
|
package/schemas.js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// src/app/flows/authentication/authentication.schemas.ts
|
|
2
|
+
import { z as z7 } from "zod";
|
|
3
|
+
|
|
4
|
+
// src/app/domain/(iam)/employees/employees.audit.ts
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
var employeesAuditEvents = {
|
|
7
|
+
"employee.created": z.object({ targetEmployeeId: z.number() }),
|
|
8
|
+
"employee.suspended": z.object({ targetEmployeeId: z.number() }),
|
|
9
|
+
"employee.activated": z.object({ targetEmployeeId: z.number() }),
|
|
10
|
+
"employee.passwordReset": z.object({ targetEmployeeId: z.number() })
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/app/domain/(iam)/employees/employees.enums.ts
|
|
14
|
+
import { createStringEnumRecord } from "@kalutskii/foundation";
|
|
15
|
+
import { pgEnum } from "drizzle-orm/pg-core";
|
|
16
|
+
var employeeStatusesArray = ["active", "suspended"];
|
|
17
|
+
var employeeStatusPGEnum = pgEnum("employee_status", employeeStatusesArray);
|
|
18
|
+
var employeeStatusesRecord = createStringEnumRecord(employeeStatusesArray);
|
|
19
|
+
|
|
20
|
+
// src/app/domain/(iam)/employees/employees.errors.ts
|
|
21
|
+
import { HTTPException } from "hono/http-exception";
|
|
22
|
+
|
|
23
|
+
// src/app/domain/(iam)/employees/employees.repository.ts
|
|
24
|
+
import { sqlWhere as sqlWhere2 } from "@kalutskii/foundation";
|
|
25
|
+
|
|
26
|
+
// src/drizzle/drizzle.database.ts
|
|
27
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
28
|
+
import postgres from "postgres";
|
|
29
|
+
|
|
30
|
+
// src/app/domain/(backoffice)/assets/assets.relations.ts
|
|
31
|
+
import { defineRelationsPart } from "drizzle-orm";
|
|
32
|
+
|
|
33
|
+
// src/app/domain/(backoffice)/assets/assets.drizzle.ts
|
|
34
|
+
import { sql } from "drizzle-orm";
|
|
35
|
+
import { check, index, pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
|
|
36
|
+
|
|
37
|
+
// src/app/domain/(backoffice)/assets/assets.enums.ts
|
|
38
|
+
import { createStringEnumRecord as createStringEnumRecord2 } from "@kalutskii/foundation";
|
|
39
|
+
import { pgEnum as pgEnum2 } from "drizzle-orm/pg-core";
|
|
40
|
+
var assetStatusesArray = ["active", "written_off"];
|
|
41
|
+
var assetStatusPGEnum = pgEnum2("asset_status", assetStatusesArray);
|
|
42
|
+
var assetStatusesRecord = createStringEnumRecord2(assetStatusesArray);
|
|
43
|
+
|
|
44
|
+
// src/app/domain/(backoffice)/assets/assets.drizzle.ts
|
|
45
|
+
var assetsTable = pgTable("assets", {
|
|
46
|
+
id: serial("id").primaryKey(),
|
|
47
|
+
name: text("name").notNull(),
|
|
48
|
+
assetCode: text("asset_code").notNull().unique(),
|
|
49
|
+
// AST-00001
|
|
50
|
+
serialNumber: text("serial_number"),
|
|
51
|
+
// Any unique serial number
|
|
52
|
+
notes: text("notes"),
|
|
53
|
+
// Optional notes or description for the asset item.
|
|
54
|
+
status: assetStatusPGEnum("status").notNull().default("active"),
|
|
55
|
+
imageSource: text("image_source"),
|
|
56
|
+
// Optional image source or URL for the asset item.
|
|
57
|
+
writtenOffAt: timestamp("written_off_at"),
|
|
58
|
+
updatedAt: timestamp("updated_at").$onUpdateFn(() => /* @__PURE__ */ new Date()),
|
|
59
|
+
createdAt: timestamp("created_at").notNull().defaultNow()
|
|
60
|
+
}, (table) => [
|
|
61
|
+
// Ensure `name` and `assetCode` are not empty.
|
|
62
|
+
check("assets_name_check", sql`length(trim(${table.name})) > 0`),
|
|
63
|
+
check("assets_code_check", sql`length(trim(${table.assetCode})) > 0`),
|
|
64
|
+
// Ensure written-off asset items have a write-off timestamp.
|
|
65
|
+
check("assets_write_off_check", sql`${table.status} != 'written_off' OR (${table.writtenOffAt} IS NOT NULL)`),
|
|
66
|
+
// Indexes for efficient filtering by `status` and `serialNumber`.
|
|
67
|
+
index("assets_status_idx").on(table.status),
|
|
68
|
+
index("assets_serial_number_idx").on(table.serialNumber)
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
// src/app/domain/(backoffice)/assets/assets.relations.ts
|
|
72
|
+
var assetsRelationsPart = defineRelationsPart({ assetsTable }, () => ({
|
|
73
|
+
assetsTable: {}
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.relations.ts
|
|
77
|
+
import { defineRelationsPart as defineRelationsPart2 } from "drizzle-orm";
|
|
78
|
+
|
|
79
|
+
// src/app/domain/(iam)/employees/employees.drizzle.ts
|
|
80
|
+
import { sql as sql2 } from "drizzle-orm";
|
|
81
|
+
import { check as check2, index as index2, pgTable as pgTable2, serial as serial2, text as text2, timestamp as timestamp2 } from "drizzle-orm/pg-core";
|
|
82
|
+
var employeesTable = pgTable2("employees", {
|
|
83
|
+
id: serial2("id").primaryKey(),
|
|
84
|
+
email: text2("email").notNull().unique(),
|
|
85
|
+
fullName: text2("full_name").notNull(),
|
|
86
|
+
passwordDigest: text2("password_digest").notNull(),
|
|
87
|
+
status: employeeStatusPGEnum("status").notNull().default("active"),
|
|
88
|
+
updatedAt: timestamp2("updated_at").$onUpdateFn(() => /* @__PURE__ */ new Date()),
|
|
89
|
+
createdAt: timestamp2("created_at").notNull().defaultNow()
|
|
90
|
+
}, (table) => [
|
|
91
|
+
// Ensure `email` is not empty and matches a basic email regex pattern.
|
|
92
|
+
check2("employees_email_check", sql2`${table.email} ~* '^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$'`),
|
|
93
|
+
// Indexes for efficient querying by `passwordDigest`, and `status` columns.
|
|
94
|
+
index2("employees_password_digest_idx").on(table.passwordDigest),
|
|
95
|
+
index2("employees_status_idx").on(table.status)
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.drizzle.ts
|
|
99
|
+
import { sql as sql3 } from "drizzle-orm";
|
|
100
|
+
import { check as check3, index as index3, integer, jsonb, pgTable as pgTable3, serial as serial3, text as text3, timestamp as timestamp3 } from "drizzle-orm/pg-core";
|
|
101
|
+
var auditLogsTable = pgTable3("audit_logs", {
|
|
102
|
+
id: serial3("id").primaryKey(),
|
|
103
|
+
event: text3("event").notNull().$type(),
|
|
104
|
+
actorEmployeeId: integer("actor_employee_id").references(() => employeesTable.id, {
|
|
105
|
+
onDelete: "set null"
|
|
106
|
+
}),
|
|
107
|
+
payload: jsonb("payload").notNull(),
|
|
108
|
+
createdAt: timestamp3("created_at").notNull().defaultNow()
|
|
109
|
+
}, (table) => [
|
|
110
|
+
// Ensure `event` and `payload` are not empty.
|
|
111
|
+
check3("audit_event_check", sql3`${table.event} != ''`),
|
|
112
|
+
check3("audit_payload_check", sql3`jsonb_typeof(${table.payload}) = 'object'`),
|
|
113
|
+
// Indexes for efficient querying by `actorEmployeeId`, `event`, and `createdAt` columns.
|
|
114
|
+
index3("audit_logs_actor_employee_id_idx").on(table.actorEmployeeId),
|
|
115
|
+
index3("audit_logs_event_idx").on(table.event),
|
|
116
|
+
index3("audit_logs_created_at_idx").on(table.createdAt)
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.relations.ts
|
|
120
|
+
var auditLogsRelationsPart = defineRelationsPart2({ auditLogsTable, employeesTable }, (r) => ({
|
|
121
|
+
auditLogsTable: {
|
|
122
|
+
employee: r.one.employeesTable({
|
|
123
|
+
from: r.auditLogsTable.actorEmployeeId,
|
|
124
|
+
to: r.employeesTable.id
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
// src/app/domain/(iam)/employees/employees.relations.ts
|
|
130
|
+
import { defineRelationsPart as defineRelationsPart3 } from "drizzle-orm";
|
|
131
|
+
|
|
132
|
+
// src/app/domain/(iam)/permissions/permissions.drizzle.ts
|
|
133
|
+
import { integer as integer2, pgTable as pgTable4, serial as serial4, text as text4, timestamp as timestamp4, unique } from "drizzle-orm/pg-core";
|
|
134
|
+
var permissionsTable = pgTable4("permissions", {
|
|
135
|
+
id: serial4("id").primaryKey(),
|
|
136
|
+
grant: text4("grant").notNull().$type(),
|
|
137
|
+
employeeId: integer2("employee_id").notNull().references(() => employeesTable.id, { onDelete: "cascade" }),
|
|
138
|
+
createdAt: timestamp4("created_at").notNull().defaultNow()
|
|
139
|
+
}, (table) => [
|
|
140
|
+
// Unique constraint on (`employeeId`, `grant`) to prevent duplicate records for the same employee.
|
|
141
|
+
unique("permissions_employee_id_grant_unique").on(table.employeeId, table.grant)
|
|
142
|
+
]);
|
|
143
|
+
|
|
144
|
+
// src/app/domain/(iam)/sessions/sessions.drizzle.ts
|
|
145
|
+
import { sql as sql4 } from "drizzle-orm";
|
|
146
|
+
import { check as check4, index as index4, integer as integer3, pgTable as pgTable5, serial as serial5, text as text5, timestamp as timestamp5 } from "drizzle-orm/pg-core";
|
|
147
|
+
var sessionsTable = pgTable5("sessions", {
|
|
148
|
+
id: serial5("id").primaryKey(),
|
|
149
|
+
employeeId: integer3("employee_id").notNull().references(() => employeesTable.id, { onDelete: "cascade" }),
|
|
150
|
+
refreshTokenDigest: text5("refresh_token_digest").notNull().unique(),
|
|
151
|
+
createdAt: timestamp5("created_at").notNull().defaultNow(),
|
|
152
|
+
expiresAt: timestamp5("expires_at").notNull(),
|
|
153
|
+
revokedAt: timestamp5("revoked_at")
|
|
154
|
+
}, (table) => [
|
|
155
|
+
// Ensure `expiresAt` is always greater than `createdAt`.
|
|
156
|
+
check4("sessions_expires_at_check", sql4`${table.expiresAt} > ${table.createdAt}`),
|
|
157
|
+
// Indexes for efficient querying by `employeeId` and `expiresAt` columns.
|
|
158
|
+
index4("sessions_employee_id_idx").on(table.employeeId),
|
|
159
|
+
index4("sessions_expires_at_idx").on(table.expiresAt)
|
|
160
|
+
]);
|
|
161
|
+
|
|
162
|
+
// src/app/domain/(iam)/employees/employees.relations.ts
|
|
163
|
+
var employeesRelationsPart = defineRelationsPart3({ auditLogsTable, employeesTable, permissionsTable, sessionsTable }, (r) => ({
|
|
164
|
+
employeesTable: {
|
|
165
|
+
auditLogs: r.many.auditLogsTable({
|
|
166
|
+
from: r.employeesTable.id,
|
|
167
|
+
to: r.auditLogsTable.actorEmployeeId
|
|
168
|
+
}),
|
|
169
|
+
permissions: r.many.permissionsTable({
|
|
170
|
+
from: r.employeesTable.id,
|
|
171
|
+
to: r.permissionsTable.employeeId
|
|
172
|
+
}),
|
|
173
|
+
sessions: r.many.sessionsTable({
|
|
174
|
+
from: r.employeesTable.id,
|
|
175
|
+
to: r.sessionsTable.employeeId
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
// src/app/domain/(iam)/permissions/permissions.relations.ts
|
|
181
|
+
import { defineRelationsPart as defineRelationsPart4 } from "drizzle-orm";
|
|
182
|
+
var permissionsRelationsPart = defineRelationsPart4({ permissionsTable, employeesTable }, (r) => ({
|
|
183
|
+
permissionsTable: {
|
|
184
|
+
employee: r.one.employeesTable({
|
|
185
|
+
from: r.permissionsTable.employeeId,
|
|
186
|
+
to: r.employeesTable.id
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
}));
|
|
190
|
+
|
|
191
|
+
// src/app/domain/(iam)/sessions/sessions.relations.ts
|
|
192
|
+
import { defineRelationsPart as defineRelationsPart5 } from "drizzle-orm";
|
|
193
|
+
var sessionsRelationsPart = defineRelationsPart5({ sessionsTable, employeesTable }, (r) => ({
|
|
194
|
+
sessionsTable: {
|
|
195
|
+
employee: r.one.employeesTable({
|
|
196
|
+
from: r.sessionsTable.employeeId,
|
|
197
|
+
to: r.employeesTable.id
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
}));
|
|
201
|
+
|
|
202
|
+
// src/app/domain/domain.registry.ts
|
|
203
|
+
var domainRelationsRegistry = {
|
|
204
|
+
...assetsRelationsPart,
|
|
205
|
+
...auditLogsRelationsPart,
|
|
206
|
+
...employeesRelationsPart,
|
|
207
|
+
...permissionsRelationsPart,
|
|
208
|
+
...sessionsRelationsPart
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/internal/env.config.ts
|
|
212
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
213
|
+
import { z as z2 } from "zod";
|
|
214
|
+
var env = createEnv({
|
|
215
|
+
server: {
|
|
216
|
+
// Database settings for Drizzle ORM
|
|
217
|
+
DRIZZLE_DB_URL: z2.url().min(8).max(256),
|
|
218
|
+
DRIZZLE_MIGRATIONS_FOLDER: z2.string().min(1).max(256),
|
|
219
|
+
// Bun server settings
|
|
220
|
+
BUN_SERVER_PORT: z2.coerce.number().int().positive().min(1).max(65535),
|
|
221
|
+
BUN_SERVER_HOST: z2.string().min(1).max(64).optional().default("0.0.0.0"),
|
|
222
|
+
// Ecosystem variables
|
|
223
|
+
ESB_MARKET_SPACE_JWT_SECRET: z2.string().min(32).max(256),
|
|
224
|
+
ESB_MARKET_SPACE_RENDER_BACKEND_HOST: z2.url().min(4).max(256),
|
|
225
|
+
// Google Cloud Storage project and destination bucket
|
|
226
|
+
GOOGLE_CLOUD_PROJECT_ID: z2.string().min(1).max(256),
|
|
227
|
+
GOOGLE_CLOUD_STORAGE_BUCKET: z2.string().min(1).max(256),
|
|
228
|
+
// Peripheral settings, usually not required in the environment
|
|
229
|
+
PRODUCTION: z2.boolean().default(process.env.NODE_ENV === "production"),
|
|
230
|
+
DEVELOPMENT: z2.boolean().default(process.env.NODE_ENV === "development"),
|
|
231
|
+
DEFAULT_TIMEZONE: z2.string().min(4).max(256).optional().default("Asia/Tbilisi")
|
|
232
|
+
},
|
|
233
|
+
runtimeEnv: process.env,
|
|
234
|
+
emptyStringAsUndefined: true
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// src/drizzle/drizzle.database.ts
|
|
238
|
+
var sql5 = postgres(env.DRIZZLE_DB_URL, { max: 10, idle_timeout: 20, connect_timeout: 10, prepare: false });
|
|
239
|
+
var db = drizzle({ client: sql5, relations: domainRelationsRegistry });
|
|
240
|
+
|
|
241
|
+
// src/app/domain/(iam)/permissions/permissions.audit.ts
|
|
242
|
+
import { z as z4 } from "zod";
|
|
243
|
+
|
|
244
|
+
// src/app/domain/(iam)/permissions/permissions.enums.ts
|
|
245
|
+
import { createStringEnumRecord as createStringEnumRecord3 } from "@kalutskii/foundation";
|
|
246
|
+
import { z as z3 } from "zod";
|
|
247
|
+
var grantsArray = [
|
|
248
|
+
"employee.create",
|
|
249
|
+
"employee.read",
|
|
250
|
+
"employee.update",
|
|
251
|
+
"inventory.create",
|
|
252
|
+
"inventory.read",
|
|
253
|
+
"inventory.update",
|
|
254
|
+
"inventory.write_off",
|
|
255
|
+
"category.create",
|
|
256
|
+
"category.read",
|
|
257
|
+
"category.update"
|
|
258
|
+
];
|
|
259
|
+
var grantsZodArray = z3.array(z3.enum(grantsArray));
|
|
260
|
+
var grantsRecord = createStringEnumRecord3(grantsArray);
|
|
261
|
+
|
|
262
|
+
// src/app/domain/(iam)/permissions/permissions.audit.ts
|
|
263
|
+
var permissionsAuditEvents = {
|
|
264
|
+
"permissions.updated": z4.object({ targetEmployeeId: z4.number(), updatedGrants: grantsZodArray })
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/app/domain/(iam)/permissions/permissions.repository.ts
|
|
268
|
+
import { sqlWhere } from "@kalutskii/foundation";
|
|
269
|
+
|
|
270
|
+
// src/app/domain/(iam)/permissions/permissions.schemas.ts
|
|
271
|
+
import { zodAtLeastOne } from "@kalutskii/foundation";
|
|
272
|
+
import { createSelectSchema } from "drizzle-orm/zod";
|
|
273
|
+
import { z as z5 } from "zod";
|
|
274
|
+
var permissionEntitySchema = createSelectSchema(permissionsTable);
|
|
275
|
+
var permissionSchema = permissionEntitySchema.omit({ grant: true }).extend({ grant: z5.enum(grantsArray) });
|
|
276
|
+
var permissionInsertSchema = permissionSchema.omit({ id: true, createdAt: true }).strict();
|
|
277
|
+
var permissionSelectSchema = permissionSchema.pick({ employeeId: true });
|
|
278
|
+
var permissionBulkSelectSchema = z5.object({
|
|
279
|
+
// Pagination not included, as there are no endpoints of `Permission` search.
|
|
280
|
+
where: zodAtLeastOne(permissionSchema.pick({ employeeId: true, grant: true }).partial())
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// src/app/domain/(iam)/employees/employees.schemas.ts
|
|
284
|
+
import { zodAtLeastOne as zodAtLeastOne2 } from "@kalutskii/foundation";
|
|
285
|
+
import { createSelectSchema as createSelectSchema2 } from "drizzle-orm/zod";
|
|
286
|
+
import { z as z6 } from "zod";
|
|
287
|
+
var employeeEntitySchema = createSelectSchema2(employeesTable);
|
|
288
|
+
var employeeSchema = employeeEntitySchema.extend({ grants: grantsZodArray });
|
|
289
|
+
var employeeInsertSchema = employeeSchema.pick({ email: true, fullName: true, passwordDigest: true }).strict();
|
|
290
|
+
var employeeSelectSchema = zodAtLeastOne2(employeeSchema.pick({ id: true, email: true }).partial());
|
|
291
|
+
var employeeSearchSchema = z6.object({ where: employeeSchema.pick({ status: true }).partial().optional() });
|
|
292
|
+
var employeeUpdateSchema = zodAtLeastOne2(
|
|
293
|
+
// We allow updating only the `passwordDigest` and `status` fields.
|
|
294
|
+
employeeSchema.pick({ passwordDigest: true, status: true }).partial()
|
|
295
|
+
);
|
|
296
|
+
var employeeEmailShape = z6.email().max(255);
|
|
297
|
+
var employeePasswordShape = z6.string().min(8).max(128);
|
|
298
|
+
var employeeIdentifierShape = employeeSchema.shape.id;
|
|
299
|
+
|
|
300
|
+
// src/app/flows/authentication/authentication.schemas.ts
|
|
301
|
+
var signinPayloadSchema = z7.object({
|
|
302
|
+
email: employeeEmailShape,
|
|
303
|
+
// We do not store the password in the database, but we validate
|
|
304
|
+
// it here to ensure that the employee provides a valid password.
|
|
305
|
+
password: z7.string().min(8).max(128)
|
|
306
|
+
}).strict();
|
|
307
|
+
var sessionPayloadSchema = z7.object({
|
|
308
|
+
// Password digest is omitted from the `Employee` intentionally
|
|
309
|
+
// to avoid leaking sensitive information in the API response.
|
|
310
|
+
employee: employeeSchema.omit({ passwordDigest: true })
|
|
311
|
+
});
|
|
312
|
+
export {
|
|
313
|
+
sessionPayloadSchema
|
|
314
|
+
};
|