@esb-market-contracts/admin-backend 1.3.1 → 1.4.1
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/api.d.ts +7 -87
- package/enums.d.ts +4 -5
- package/enums.js +6 -7
- package/index.d.ts +3 -2
- package/index.js +2 -1
- package/package.json +8 -8
- package/schemas.d.ts +23 -0
- package/schemas.js +243 -0
- package/types.d.ts +0 -143
- package/types.js +0 -1
package/api.d.ts
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
declare const authRouter: import("hono/hono-base").HonoBase<
|
|
4
|
-
"/iam/authentication/
|
|
5
|
-
$
|
|
3
|
+
declare const authRouter: import("hono/hono-base").HonoBase<{}, {
|
|
4
|
+
"/iam/authentication/authorize": {
|
|
5
|
+
$post: {
|
|
6
6
|
input: {};
|
|
7
7
|
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
8
|
-
|
|
9
|
-
expiresAt: string;
|
|
10
|
-
user: {
|
|
11
|
-
id: number;
|
|
12
|
-
email: string;
|
|
13
|
-
fullName: string;
|
|
14
|
-
status: "active" | "inactive" | "suspended";
|
|
15
|
-
lastLoginAt: string | null;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
8
|
+
[x: string]: never;
|
|
18
9
|
}>;
|
|
19
10
|
outputFormat: "json";
|
|
20
11
|
status: 200;
|
|
21
12
|
};
|
|
22
13
|
};
|
|
23
14
|
} & {
|
|
24
|
-
"/iam/authentication/
|
|
15
|
+
"/iam/authentication/refresh": {
|
|
25
16
|
$post: {
|
|
26
|
-
input: {
|
|
27
|
-
json: {
|
|
28
|
-
email: string;
|
|
29
|
-
password: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
17
|
+
input: {};
|
|
32
18
|
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
33
|
-
|
|
19
|
+
accessToken: string;
|
|
34
20
|
}>;
|
|
35
21
|
outputFormat: "json";
|
|
36
22
|
status: 200;
|
|
@@ -49,71 +35,5 @@ declare const authRouter: import("hono/hono-base").HonoBase<import("hono/types")
|
|
|
49
35
|
};
|
|
50
36
|
}, "/iam/authentication", "/iam/authentication/logout">;
|
|
51
37
|
export type AuthRouter = typeof authRouter;
|
|
52
|
-
declare const employeesRouter: import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
|
|
53
|
-
"/iam/employees/table-metadata": {
|
|
54
|
-
$get: {
|
|
55
|
-
input: {};
|
|
56
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
57
|
-
filters: {
|
|
58
|
-
statuses: {
|
|
59
|
-
label: string;
|
|
60
|
-
value: string;
|
|
61
|
-
}[];
|
|
62
|
-
roles: {
|
|
63
|
-
label: string;
|
|
64
|
-
value: string;
|
|
65
|
-
}[];
|
|
66
|
-
};
|
|
67
|
-
sorting: {
|
|
68
|
-
fields: {
|
|
69
|
-
label: string;
|
|
70
|
-
value: string;
|
|
71
|
-
}[];
|
|
72
|
-
default: {
|
|
73
|
-
field: string;
|
|
74
|
-
direction: "desc" | "asc";
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
pagination: {
|
|
78
|
-
defaultLimit: number;
|
|
79
|
-
availableLimits: number[];
|
|
80
|
-
};
|
|
81
|
-
}>;
|
|
82
|
-
outputFormat: "json";
|
|
83
|
-
status: 200;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
} & {
|
|
87
|
-
"/iam/employees": {
|
|
88
|
-
$get: {
|
|
89
|
-
input: {};
|
|
90
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
91
|
-
items: {
|
|
92
|
-
id: number;
|
|
93
|
-
email: string;
|
|
94
|
-
fullName: string;
|
|
95
|
-
status: "active" | "inactive" | "suspended";
|
|
96
|
-
lastLoginAt: string | null;
|
|
97
|
-
updatedAt: string;
|
|
98
|
-
createdAt: string;
|
|
99
|
-
roles: {
|
|
100
|
-
id: number;
|
|
101
|
-
name: string;
|
|
102
|
-
code: string;
|
|
103
|
-
}[];
|
|
104
|
-
}[];
|
|
105
|
-
meta: {
|
|
106
|
-
page: number;
|
|
107
|
-
limit: number;
|
|
108
|
-
total: number;
|
|
109
|
-
totalPages: number;
|
|
110
|
-
};
|
|
111
|
-
}>;
|
|
112
|
-
outputFormat: "json";
|
|
113
|
-
status: 200;
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
}, "/iam/employees", "/iam/employees">;
|
|
117
|
-
export type EmployeesRouter = typeof employeesRouter;
|
|
118
38
|
|
|
119
39
|
export {};
|
package/enums.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
export declare const
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"ORDERS.DELETE": "orders.delete";
|
|
3
|
+
export declare const PBACPermissions: {
|
|
4
|
+
"EMPLOYEE.CREATE": "employee.create";
|
|
5
|
+
"EMPLOYEE.READ": "employee.read";
|
|
6
|
+
"EMPLOYEE.UPDATE": "employee.update";
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
export {};
|
package/enums.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
function createStringEnumObject(values) {
|
|
1
|
+
// src/utilities/enums.utilities.ts
|
|
2
|
+
function createStringEnumRecord(values) {
|
|
4
3
|
return Object.fromEntries(values.map((value) => [value.toUpperCase(), value]));
|
|
5
4
|
}
|
|
6
5
|
|
|
7
|
-
// src/app/domain/(iam)/permissions/permissions.enums.ts
|
|
8
|
-
var
|
|
9
|
-
var
|
|
6
|
+
// src/app/domain/(iam)/employees-permissions/employees-permissions.enums.ts
|
|
7
|
+
var PBACPermissionItems = ["employee.create", "employee.read", "employee.update"];
|
|
8
|
+
var PBACPermissions = createStringEnumRecord(PBACPermissionItems);
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
PBACPermissions
|
|
12
11
|
};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './enums.js';
|
|
1
|
+
export * from './enums.js';
|
|
2
|
+
export * from './schemas.js';
|
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.
|
|
4
|
+
"version": "1.4.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"index.js",
|
|
11
11
|
"api.d.ts",
|
|
12
12
|
"api.js",
|
|
13
|
-
"types.d.ts",
|
|
14
|
-
"types.js",
|
|
15
13
|
"enums.d.ts",
|
|
16
|
-
"enums.js"
|
|
14
|
+
"enums.js",
|
|
15
|
+
"schemas.d.ts",
|
|
16
|
+
"schemas.js"
|
|
17
17
|
],
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"types": "./api.d.ts",
|
|
25
25
|
"default": "./api.js"
|
|
26
26
|
},
|
|
27
|
-
"./types": {
|
|
28
|
-
"types": "./types.d.ts",
|
|
29
|
-
"default": "./types.js"
|
|
30
|
-
},
|
|
31
27
|
"./enums": {
|
|
32
28
|
"types": "./enums.d.ts",
|
|
33
29
|
"default": "./enums.js"
|
|
30
|
+
},
|
|
31
|
+
"./schemas": {
|
|
32
|
+
"types": "./schemas.d.ts",
|
|
33
|
+
"default": "./schemas.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"types": "./index.d.ts"
|
package/schemas.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/** Schema for the payload of an authentication token. */
|
|
6
|
+
export declare const authPayloadSchema: z.ZodObject<{
|
|
7
|
+
employee: z.ZodObject<{
|
|
8
|
+
id: z.ZodInt;
|
|
9
|
+
email: z.ZodString;
|
|
10
|
+
fullName: z.ZodString;
|
|
11
|
+
}, {
|
|
12
|
+
out: {};
|
|
13
|
+
in: {};
|
|
14
|
+
}>;
|
|
15
|
+
permissions: z.ZodArray<z.ZodEnum<{
|
|
16
|
+
"employee.create": "employee.create";
|
|
17
|
+
"employee.read": "employee.read";
|
|
18
|
+
"employee.update": "employee.update";
|
|
19
|
+
}>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type AuthPayload = z.infer<typeof authPayloadSchema>;
|
|
22
|
+
|
|
23
|
+
export {};
|
package/schemas.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// src/app/flows/authentication/authentication.schemas.ts
|
|
2
|
+
import { z as z5 } 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.drizzle.ts
|
|
14
|
+
import { sql } from "drizzle-orm";
|
|
15
|
+
import { check, pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
|
|
16
|
+
|
|
17
|
+
// src/app/domain/(iam)/employees/employees.enums.ts
|
|
18
|
+
import { pgEnum } from "drizzle-orm/pg-core";
|
|
19
|
+
|
|
20
|
+
// src/utilities/enums.utilities.ts
|
|
21
|
+
function createStringEnumRecord(values) {
|
|
22
|
+
return Object.fromEntries(values.map((value) => [value.toUpperCase(), value]));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/app/domain/(iam)/employees/employees.enums.ts
|
|
26
|
+
var employeeStatuses = ["active", "suspended"];
|
|
27
|
+
var employeeStatusesRecord = createStringEnumRecord(employeeStatuses);
|
|
28
|
+
var employeeStatusPGEnum = pgEnum("employee_status", employeeStatuses);
|
|
29
|
+
|
|
30
|
+
// src/app/domain/(iam)/employees/employees.drizzle.ts
|
|
31
|
+
var employeesTable = pgTable("employees", {
|
|
32
|
+
id: serial("id").primaryKey(),
|
|
33
|
+
email: text("email").notNull().unique(),
|
|
34
|
+
fullName: text("full_name").notNull(),
|
|
35
|
+
status: employeeStatusPGEnum("status").notNull().default("active"),
|
|
36
|
+
passwordDigest: text("password_digest").notNull(),
|
|
37
|
+
updatedAt: timestamp("updated_at").$onUpdateFn(() => /* @__PURE__ */ new Date()),
|
|
38
|
+
createdAt: timestamp("created_at").notNull().defaultNow()
|
|
39
|
+
}, (table) => [
|
|
40
|
+
// Database-level email field format validation using a regex pattern.
|
|
41
|
+
check("employees_email_check", sql`${table.email} ~* '^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$'`)
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
// src/drizzle/drizzle.database.ts
|
|
45
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
46
|
+
|
|
47
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.relations.ts
|
|
48
|
+
import { defineRelationsPart } from "drizzle-orm";
|
|
49
|
+
|
|
50
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.drizzle.ts
|
|
51
|
+
import { sql as sql2 } from "drizzle-orm";
|
|
52
|
+
import { check as check2, index, integer, jsonb, pgTable as pgTable2, serial as serial2, text as text2, timestamp as timestamp2 } from "drizzle-orm/pg-core";
|
|
53
|
+
var auditLogsTable = pgTable2("audit_logs", {
|
|
54
|
+
id: serial2("id").primaryKey(),
|
|
55
|
+
actorEmployeeId: integer("actor_employee_id").references(() => employeesTable.id, {
|
|
56
|
+
onDelete: "set null"
|
|
57
|
+
}),
|
|
58
|
+
event: text2("event").notNull().$type(),
|
|
59
|
+
payload: jsonb("payload"),
|
|
60
|
+
createdAt: timestamp2("created_at").notNull().defaultNow()
|
|
61
|
+
}, (table) => [
|
|
62
|
+
// Ensure event is not empty and payload is a valid JSON object.
|
|
63
|
+
check2("audit_event_check", sql2`${table.event} != ''`),
|
|
64
|
+
check2("audit_payload_check", sql2`jsonb_typeof(${table.payload}) = 'object'`),
|
|
65
|
+
// Indexes for efficient querying by employeeId and event type.
|
|
66
|
+
index("audit_logs_actor_employee_id_idx").on(table.actorEmployeeId),
|
|
67
|
+
index("audit_logs_event_idx").on(table.event),
|
|
68
|
+
index("audit_logs_created_at_idx").on(table.createdAt)
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.relations.ts
|
|
72
|
+
var auditLogsRelationsPart = defineRelationsPart({ auditLogsTable, employeesTable }, (r) => ({
|
|
73
|
+
auditLogsTable: {
|
|
74
|
+
employee: r.one.employeesTable({
|
|
75
|
+
from: r.auditLogsTable.actorEmployeeId,
|
|
76
|
+
to: r.employeesTable.id
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
// src/app/domain/(iam)/employees-permissions/employees-permissions.relations.ts
|
|
82
|
+
import { defineRelationsPart as defineRelationsPart2 } from "drizzle-orm";
|
|
83
|
+
|
|
84
|
+
// src/app/domain/(iam)/employees-permissions/employees-permissions.drizzle.ts
|
|
85
|
+
import { integer as integer2, pgTable as pgTable3, serial as serial3, text as text3, unique } from "drizzle-orm/pg-core";
|
|
86
|
+
var employeesPermissionsTable = pgTable3("employees_permissions", {
|
|
87
|
+
id: serial3("id").primaryKey(),
|
|
88
|
+
permission: text3("permission").notNull().$type(),
|
|
89
|
+
employeeId: integer2("employee_id").notNull().references(() => employeesTable.id, { onDelete: "cascade" })
|
|
90
|
+
}, (table) => [
|
|
91
|
+
// Unique constraint on (employeeId, permission) to prevent duplicate permissions for the same employee.
|
|
92
|
+
unique("employees_permissions_employee_id_permission_unique").on(table.employeeId, table.permission)
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
// src/app/domain/(iam)/employees-permissions/employees-permissions.relations.ts
|
|
96
|
+
var employeesPermissionsRelationsPart = defineRelationsPart2({ employeesPermissionsTable, employeesTable }, (r) => ({
|
|
97
|
+
employeesPermissionsTable: {
|
|
98
|
+
employee: r.one.employeesTable({
|
|
99
|
+
from: r.employeesPermissionsTable.employeeId,
|
|
100
|
+
to: r.employeesTable.id
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
// src/app/domain/(iam)/employees/employees.relations.ts
|
|
106
|
+
import { defineRelationsPart as defineRelationsPart3 } from "drizzle-orm";
|
|
107
|
+
|
|
108
|
+
// src/app/domain/(iam)/employees-permissions/employees-permissions.audit.ts
|
|
109
|
+
import { z as z2 } from "zod";
|
|
110
|
+
|
|
111
|
+
// src/app/domain/(iam)/employees-permissions/employees-permissions.enums.ts
|
|
112
|
+
var PBACPermissionItems = ["employee.create", "employee.read", "employee.update"];
|
|
113
|
+
var PBACPermissions = createStringEnumRecord(PBACPermissionItems);
|
|
114
|
+
|
|
115
|
+
// src/app/domain/(iam)/employees-permissions/employees-permissions.audit.ts
|
|
116
|
+
var employeesPermissionsAuditEvents = {
|
|
117
|
+
"permissions.updated": z2.object({
|
|
118
|
+
targetEmployeeId: z2.number(),
|
|
119
|
+
newPermissions: z2.array(z2.enum(PBACPermissionItems))
|
|
120
|
+
})
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// src/app/domain/(iam)/sessions/sessions.audit.ts
|
|
124
|
+
import { z as z3 } from "zod";
|
|
125
|
+
var sessionsAuditEvents = {
|
|
126
|
+
"session.created": z3.object({ userAgent: z3.string().optional() }),
|
|
127
|
+
"session.revoked": z3.object({
|
|
128
|
+
targetSessionId: z3.number(),
|
|
129
|
+
actorEmployeeId: z3.number().optional()
|
|
130
|
+
// Required only if the actor is not the owner of the session.
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/app/domain/(iam)/sessions/sessions.drizzle.ts
|
|
135
|
+
import { index as index2, integer as integer3, pgTable as pgTable4, serial as serial4, text as text4, timestamp as timestamp3 } from "drizzle-orm/pg-core";
|
|
136
|
+
var sessionsTable = pgTable4("sessions", {
|
|
137
|
+
id: serial4("id").primaryKey(),
|
|
138
|
+
refreshTokenDigest: text4("refresh_token_digest").notNull().unique(),
|
|
139
|
+
employeeId: integer3("employee_id").notNull().references(() => employeesTable.id, { onDelete: "cascade" }),
|
|
140
|
+
createdAt: timestamp3("created_at").notNull().defaultNow(),
|
|
141
|
+
expiresAt: timestamp3("expires_at").notNull(),
|
|
142
|
+
revokedAt: timestamp3("revoked_at")
|
|
143
|
+
}, (table) => [
|
|
144
|
+
// Indexes for efficient querying by employeeId and expiration time.
|
|
145
|
+
index2("sessions_employee_id_idx").on(table.employeeId),
|
|
146
|
+
index2("sessions_expires_at_idx").on(table.expiresAt)
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
// src/app/domain/(iam)/sessions/sessions.schemas.ts
|
|
150
|
+
import { createInsertSchema, createSelectSchema } from "drizzle-orm/zod";
|
|
151
|
+
var sessionSchema = createSelectSchema(sessionsTable);
|
|
152
|
+
var sessionInsertSchema = createInsertSchema(sessionsTable);
|
|
153
|
+
|
|
154
|
+
// src/app/domain/(iam)/sessions/sessions.repository.ts
|
|
155
|
+
import { eq } from "drizzle-orm";
|
|
156
|
+
|
|
157
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.registry.ts
|
|
158
|
+
var auditEventsRegistry = {
|
|
159
|
+
...employeesPermissionsAuditEvents,
|
|
160
|
+
...employeesAuditEvents,
|
|
161
|
+
...sessionsAuditEvents
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/app/domain/(iam)/employees/employees.relations.ts
|
|
165
|
+
var employeesRelationsPart = defineRelationsPart3({ employeesTable, employeesPermissionsTable, auditLogsTable, sessionsTable }, (r) => ({
|
|
166
|
+
employeesTable: {
|
|
167
|
+
sessions: r.many.sessionsTable({
|
|
168
|
+
from: r.employeesTable.id,
|
|
169
|
+
to: r.sessionsTable.employeeId
|
|
170
|
+
}),
|
|
171
|
+
auditLogs: r.many.auditLogsTable({
|
|
172
|
+
from: r.employeesTable.id,
|
|
173
|
+
to: r.auditLogsTable.actorEmployeeId
|
|
174
|
+
}),
|
|
175
|
+
permissions: r.many.employeesPermissionsTable({
|
|
176
|
+
from: r.employeesTable.id,
|
|
177
|
+
to: r.employeesPermissionsTable.employeeId
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
// src/app/domain/(iam)/sessions/sessions.relations.ts
|
|
183
|
+
import { defineRelationsPart as defineRelationsPart4 } from "drizzle-orm";
|
|
184
|
+
var sessionsRelationsPart = defineRelationsPart4({ sessionsTable, employeesTable }, (r) => ({
|
|
185
|
+
sessionsTable: {
|
|
186
|
+
employee: r.one.employeesTable({
|
|
187
|
+
from: r.sessionsTable.employeeId,
|
|
188
|
+
to: r.employeesTable.id
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
}));
|
|
192
|
+
|
|
193
|
+
// src/app/domain/domain.registry.ts
|
|
194
|
+
var domainRelationsRegistry = {
|
|
195
|
+
...auditLogsRelationsPart,
|
|
196
|
+
...employeesRelationsPart,
|
|
197
|
+
...employeesPermissionsRelationsPart,
|
|
198
|
+
...sessionsRelationsPart
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// src/internal/env.config.ts
|
|
202
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
203
|
+
import { z as z4 } from "zod";
|
|
204
|
+
var env = createEnv({
|
|
205
|
+
server: {
|
|
206
|
+
// Database settings for Drizzle ORM
|
|
207
|
+
DRIZZLE_DB_URL: z4.url().min(8).max(256),
|
|
208
|
+
DRIZZLE_MIGRATIONS_FOLDER: z4.string().min(1).max(256),
|
|
209
|
+
// Bun server settings
|
|
210
|
+
BUN_SERVER_PORT: z4.coerce.number().int().positive().min(1).max(65535),
|
|
211
|
+
BUN_SERVER_HOST: z4.string().min(1).max(64).optional().default("0.0.0.0"),
|
|
212
|
+
// Ecosystem variables
|
|
213
|
+
ESB_MARKET_SPACE_JWT_SECRET: z4.string().min(16).max(256),
|
|
214
|
+
// Peripheral settings, usually not required in the environment
|
|
215
|
+
DEFAULT_TIMEZONE: z4.string().min(4).max(256).optional().default("Asia/Tbilisi"),
|
|
216
|
+
NODE_ENV: z4.enum(["development", "production", "test"]).optional().default("development")
|
|
217
|
+
},
|
|
218
|
+
runtimeEnv: process.env,
|
|
219
|
+
emptyStringAsUndefined: true
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// src/drizzle/drizzle.database.ts
|
|
223
|
+
var db = drizzle(env.DRIZZLE_DB_URL, { relations: domainRelationsRegistry });
|
|
224
|
+
|
|
225
|
+
// src/app/domain/(iam)/employees/employees.schemas.ts
|
|
226
|
+
import { createSelectSchema as createSelectSchema2 } from "drizzle-orm/zod";
|
|
227
|
+
var employeeSchema = createSelectSchema2(employeesTable);
|
|
228
|
+
|
|
229
|
+
// src/app/domain/(iam)/employees/employees.exceptions.ts
|
|
230
|
+
import { HTTPException } from "hono/http-exception";
|
|
231
|
+
|
|
232
|
+
// src/app/flows/authentication/authentication.schemas.ts
|
|
233
|
+
var authorizeRequestSchema = z5.object({
|
|
234
|
+
email: z5.email().min(8).max(128),
|
|
235
|
+
password: z5.string().min(8).max(128)
|
|
236
|
+
});
|
|
237
|
+
var authPayloadSchema = z5.object({
|
|
238
|
+
employee: employeeSchema.pick({ id: true, email: true, fullName: true }),
|
|
239
|
+
permissions: z5.array(z5.enum(PBACPermissionItems))
|
|
240
|
+
});
|
|
241
|
+
export {
|
|
242
|
+
authPayloadSchema
|
|
243
|
+
};
|
package/types.d.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
-
|
|
3
|
-
import { SerializeDates } from '@kalutskii/foundation';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
declare const AuthLoginSchema: z.ZodObject<{
|
|
7
|
-
email: z.ZodEmail;
|
|
8
|
-
password: z.ZodString;
|
|
9
|
-
}, z.core.$strict>;
|
|
10
|
-
export type AuthLogin = z.infer<typeof AuthLoginSchema>;
|
|
11
|
-
declare const AuthSessionSchema: z.ZodObject<{
|
|
12
|
-
expiresAt: z.ZodDate;
|
|
13
|
-
user: z.ZodObject<{
|
|
14
|
-
id: z.ZodInt;
|
|
15
|
-
email: z.ZodString;
|
|
16
|
-
fullName: z.ZodString;
|
|
17
|
-
status: z.ZodEnum<{
|
|
18
|
-
active: "active";
|
|
19
|
-
inactive: "inactive";
|
|
20
|
-
suspended: "suspended";
|
|
21
|
-
}>;
|
|
22
|
-
lastLoginAt: z.ZodNullable<z.ZodDate>;
|
|
23
|
-
}, {
|
|
24
|
-
out: {};
|
|
25
|
-
in: {};
|
|
26
|
-
}>;
|
|
27
|
-
}, {
|
|
28
|
-
out: {};
|
|
29
|
-
in: {};
|
|
30
|
-
}>;
|
|
31
|
-
export type AuthSession = z.infer<typeof AuthSessionSchema>;
|
|
32
|
-
export type AuthLoginRequest = AuthLogin;
|
|
33
|
-
export type AuthSessionRequest = Record<string, never>;
|
|
34
|
-
export type AuthSessionResponse = SerializeDates<AuthSession>;
|
|
35
|
-
export type AuthClientSession = AuthSession;
|
|
36
|
-
export type AuthLogoutRequest = Record<string, never>;
|
|
37
|
-
export type AuthLogoutResponse = Record<string, never>;
|
|
38
|
-
declare const EmployeeSchema: z.ZodObject<{
|
|
39
|
-
id: z.ZodInt;
|
|
40
|
-
email: z.ZodString;
|
|
41
|
-
fullName: z.ZodString;
|
|
42
|
-
status: z.ZodEnum<{
|
|
43
|
-
active: "active";
|
|
44
|
-
inactive: "inactive";
|
|
45
|
-
suspended: "suspended";
|
|
46
|
-
}>;
|
|
47
|
-
lastLoginAt: z.ZodNullable<z.ZodDate>;
|
|
48
|
-
updatedAt: z.ZodDate;
|
|
49
|
-
createdAt: z.ZodDate;
|
|
50
|
-
roles: z.ZodArray<z.ZodObject<{
|
|
51
|
-
id: z.ZodInt;
|
|
52
|
-
name: z.ZodString;
|
|
53
|
-
code: z.ZodString;
|
|
54
|
-
}, {
|
|
55
|
-
out: {};
|
|
56
|
-
in: {};
|
|
57
|
-
}>>;
|
|
58
|
-
}, {
|
|
59
|
-
out: {};
|
|
60
|
-
in: {};
|
|
61
|
-
}>;
|
|
62
|
-
export type Employee = z.infer<typeof EmployeeSchema>;
|
|
63
|
-
declare const EmployeeListResultSchema: z.ZodObject<{
|
|
64
|
-
items: z.ZodArray<z.ZodObject<{
|
|
65
|
-
id: z.ZodInt;
|
|
66
|
-
email: z.ZodString;
|
|
67
|
-
fullName: z.ZodString;
|
|
68
|
-
status: z.ZodEnum<{
|
|
69
|
-
active: "active";
|
|
70
|
-
inactive: "inactive";
|
|
71
|
-
suspended: "suspended";
|
|
72
|
-
}>;
|
|
73
|
-
lastLoginAt: z.ZodNullable<z.ZodDate>;
|
|
74
|
-
updatedAt: z.ZodDate;
|
|
75
|
-
createdAt: z.ZodDate;
|
|
76
|
-
roles: z.ZodArray<z.ZodObject<{
|
|
77
|
-
id: z.ZodInt;
|
|
78
|
-
name: z.ZodString;
|
|
79
|
-
code: z.ZodString;
|
|
80
|
-
}, {
|
|
81
|
-
out: {};
|
|
82
|
-
in: {};
|
|
83
|
-
}>>;
|
|
84
|
-
}, {
|
|
85
|
-
out: {};
|
|
86
|
-
in: {};
|
|
87
|
-
}>>;
|
|
88
|
-
meta: z.ZodObject<{
|
|
89
|
-
page: z.ZodNumber;
|
|
90
|
-
limit: z.ZodNumber;
|
|
91
|
-
total: z.ZodNumber;
|
|
92
|
-
totalPages: z.ZodNumber;
|
|
93
|
-
}, z.core.$strip>;
|
|
94
|
-
}, z.core.$strip>;
|
|
95
|
-
export type EmployeeListResult = z.infer<typeof EmployeeListResultSchema>;
|
|
96
|
-
declare const EmployeesQuerySchema: z.ZodObject<{
|
|
97
|
-
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
98
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown> & z.ZodType<100 | 10 | 20 | 50, unknown, z.core.$ZodTypeInternals<100 | 10 | 20 | 50, unknown>>>;
|
|
99
|
-
sort: z.ZodOptional<z.ZodString>;
|
|
100
|
-
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
101
|
-
active: "active";
|
|
102
|
-
inactive: "inactive";
|
|
103
|
-
suspended: "suspended";
|
|
104
|
-
}>>>;
|
|
105
|
-
role: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
106
|
-
search: z.ZodOptional<z.ZodString>;
|
|
107
|
-
}, z.core.$strip>;
|
|
108
|
-
export type EmployeesQuery = z.infer<typeof EmployeesQuerySchema>;
|
|
109
|
-
declare const EmployeesTableMetadataSchema: z.ZodObject<{
|
|
110
|
-
filters: z.ZodObject<{
|
|
111
|
-
statuses: z.ZodArray<z.ZodObject<{
|
|
112
|
-
label: z.ZodString;
|
|
113
|
-
value: z.ZodString;
|
|
114
|
-
}, z.core.$strip>>;
|
|
115
|
-
roles: z.ZodArray<z.ZodObject<{
|
|
116
|
-
label: z.ZodString;
|
|
117
|
-
value: z.ZodString;
|
|
118
|
-
}, z.core.$strip>>;
|
|
119
|
-
}, z.core.$strip>;
|
|
120
|
-
sorting: z.ZodObject<{
|
|
121
|
-
fields: z.ZodArray<z.ZodObject<{
|
|
122
|
-
label: z.ZodString;
|
|
123
|
-
value: z.ZodString;
|
|
124
|
-
}, z.core.$strip>>;
|
|
125
|
-
default: z.ZodObject<{
|
|
126
|
-
field: z.ZodString;
|
|
127
|
-
direction: z.ZodEnum<{
|
|
128
|
-
asc: "asc";
|
|
129
|
-
desc: "desc";
|
|
130
|
-
}>;
|
|
131
|
-
}, z.core.$strip>;
|
|
132
|
-
}, z.core.$strip>;
|
|
133
|
-
pagination: z.ZodObject<{
|
|
134
|
-
defaultLimit: z.ZodNumber;
|
|
135
|
-
availableLimits: z.ZodArray<z.ZodNumber>;
|
|
136
|
-
}, z.core.$strip>;
|
|
137
|
-
}, z.core.$strip>;
|
|
138
|
-
export type EmployeesTableMetadata = z.infer<typeof EmployeesTableMetadataSchema>;
|
|
139
|
-
export type EmployeesListRequest = EmployeesQuery;
|
|
140
|
-
export type EmployeesListResponse = SerializeDates<EmployeeListResult>;
|
|
141
|
-
export type EmployeesTableMetadataResponse = EmployeesTableMetadata;
|
|
142
|
-
|
|
143
|
-
export {};
|
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|