@esb-market-contracts/admin-backend 1.8.2 → 1.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.d.ts +4 -157
- package/constants.js +2 -2
- package/enums.d.ts +4 -9
- package/enums.js +202 -8
- package/package.json +1 -1
- package/types.d.ts +8 -58
package/api.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
3
|
declare const authRouter: import("hono/hono-base").HonoBase<{}, {
|
|
6
4
|
"/iam/authentication/signin": {
|
|
7
5
|
$post: {
|
|
@@ -18,17 +16,6 @@ declare const authRouter: import("hono/hono-base").HonoBase<{}, {
|
|
|
18
16
|
status: 200;
|
|
19
17
|
};
|
|
20
18
|
};
|
|
21
|
-
} & {
|
|
22
|
-
"/iam/authentication/logout": {
|
|
23
|
-
$post: {
|
|
24
|
-
input: {};
|
|
25
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
26
|
-
[x: string]: never;
|
|
27
|
-
}>;
|
|
28
|
-
outputFormat: "json";
|
|
29
|
-
status: 200;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
19
|
} & {
|
|
33
20
|
"/iam/authentication/refresh": {
|
|
34
21
|
$post: {
|
|
@@ -40,150 +27,10 @@ declare const authRouter: import("hono/hono-base").HonoBase<{}, {
|
|
|
40
27
|
status: 200;
|
|
41
28
|
};
|
|
42
29
|
};
|
|
43
|
-
}, "/iam/authentication", "/iam/authentication/refresh">;
|
|
44
|
-
export type AuthRouter = typeof authRouter;
|
|
45
|
-
declare const sessionPayloadSchema: z.ZodObject<{
|
|
46
|
-
employee: z.ZodObject<{
|
|
47
|
-
id: z.ZodInt;
|
|
48
|
-
email: z.ZodString;
|
|
49
|
-
fullName: z.ZodString;
|
|
50
|
-
status: z.ZodEnum<{
|
|
51
|
-
active: "active";
|
|
52
|
-
suspended: "suspended";
|
|
53
|
-
}>;
|
|
54
|
-
updatedAt: z.ZodNullable<z.ZodDate>;
|
|
55
|
-
createdAt: z.ZodDate;
|
|
56
|
-
}, {
|
|
57
|
-
out: {};
|
|
58
|
-
in: {};
|
|
59
|
-
}>;
|
|
60
|
-
permissions: z.ZodArray<z.ZodEnum<{
|
|
61
|
-
"employee.create": "employee.create";
|
|
62
|
-
"employee.read": "employee.read";
|
|
63
|
-
"employee.update": "employee.update";
|
|
64
|
-
}>>;
|
|
65
|
-
}, z.core.$strip>;
|
|
66
|
-
export type SessionPayload = z.infer<typeof sessionPayloadSchema>;
|
|
67
|
-
export type VariablesWithActor = {
|
|
68
|
-
actorSession: SessionPayload;
|
|
69
|
-
};
|
|
70
|
-
declare const managementRouter: import("hono/hono-base").HonoBase<{
|
|
71
|
-
Variables: VariablesWithActor;
|
|
72
|
-
}, {
|
|
73
|
-
"/iam/management/permissions": {
|
|
74
|
-
$get: {
|
|
75
|
-
input: {};
|
|
76
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
77
|
-
permissions: readonly ("employee.create" | "employee.read" | "employee.update")[];
|
|
78
|
-
}>;
|
|
79
|
-
outputFormat: "json";
|
|
80
|
-
status: 200;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
} & {
|
|
84
|
-
"/iam/management/employees/get": {
|
|
85
|
-
$get: {
|
|
86
|
-
input: {
|
|
87
|
-
query: {
|
|
88
|
-
id: string | string[];
|
|
89
|
-
} | {
|
|
90
|
-
email: string | string[];
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
94
|
-
employee: {
|
|
95
|
-
id: number;
|
|
96
|
-
email: string;
|
|
97
|
-
fullName: string;
|
|
98
|
-
status: "active" | "suspended";
|
|
99
|
-
updatedAt: string | null;
|
|
100
|
-
createdAt: string;
|
|
101
|
-
permissions: ("employee.create" | "employee.read" | "employee.update")[];
|
|
102
|
-
};
|
|
103
|
-
}>;
|
|
104
|
-
outputFormat: "json";
|
|
105
|
-
status: 200;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
} & {
|
|
109
|
-
"/iam/management/employees/list": {
|
|
110
|
-
$get: {
|
|
111
|
-
input: {};
|
|
112
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
113
|
-
employees: {
|
|
114
|
-
id: number;
|
|
115
|
-
email: string;
|
|
116
|
-
fullName: string;
|
|
117
|
-
status: "active" | "suspended";
|
|
118
|
-
updatedAt: string | null;
|
|
119
|
-
createdAt: string;
|
|
120
|
-
}[];
|
|
121
|
-
}>;
|
|
122
|
-
outputFormat: "json";
|
|
123
|
-
status: 200;
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
} & {
|
|
127
|
-
"/iam/management/employees/insert": {
|
|
128
|
-
$post: {
|
|
129
|
-
input: {
|
|
130
|
-
json: {
|
|
131
|
-
email: string;
|
|
132
|
-
fullName: string;
|
|
133
|
-
password: string;
|
|
134
|
-
permissions?: ("employee.create" | "employee.read" | "employee.update")[] | undefined;
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
138
|
-
id: number;
|
|
139
|
-
}>;
|
|
140
|
-
outputFormat: "json";
|
|
141
|
-
status: 201;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
} & {
|
|
145
|
-
"/iam/management/employees/suspend": {
|
|
146
|
-
$post: {
|
|
147
|
-
input: {
|
|
148
|
-
json: {
|
|
149
|
-
id: unknown;
|
|
150
|
-
} | {
|
|
151
|
-
email: string;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
155
|
-
[x: string]: never;
|
|
156
|
-
}>;
|
|
157
|
-
outputFormat: "json";
|
|
158
|
-
status: 200;
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
30
|
} & {
|
|
162
|
-
"/iam/
|
|
163
|
-
$post: {
|
|
164
|
-
input: {
|
|
165
|
-
json: {
|
|
166
|
-
id: unknown;
|
|
167
|
-
} | {
|
|
168
|
-
email: string;
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
172
|
-
[x: string]: never;
|
|
173
|
-
}>;
|
|
174
|
-
outputFormat: "json";
|
|
175
|
-
status: 200;
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
} & {
|
|
179
|
-
"/iam/management/employees/update-password": {
|
|
31
|
+
"/iam/authentication/logout": {
|
|
180
32
|
$post: {
|
|
181
|
-
input: {
|
|
182
|
-
json: {
|
|
183
|
-
employeeId: unknown;
|
|
184
|
-
password: string;
|
|
185
|
-
};
|
|
186
|
-
};
|
|
33
|
+
input: {};
|
|
187
34
|
output: import("@kalutskii/foundation").APIError | import("@kalutskii/foundation").APISuccess<{
|
|
188
35
|
[x: string]: never;
|
|
189
36
|
}>;
|
|
@@ -191,7 +38,7 @@ declare const managementRouter: import("hono/hono-base").HonoBase<{
|
|
|
191
38
|
status: 200;
|
|
192
39
|
};
|
|
193
40
|
};
|
|
194
|
-
}, "/iam/
|
|
195
|
-
export type
|
|
41
|
+
}, "/iam/authentication", "/iam/authentication/logout">;
|
|
42
|
+
export type AuthRouter = typeof authRouter;
|
|
196
43
|
|
|
197
44
|
export {};
|
package/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/app/flows/authentication/authentication.constants.ts
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var SESSION_TOKEN_TTL_MS = 60 * 15 * 1e3;
|
|
3
|
+
var REFRESH_TOKEN_TTL_MS = 60 * 60 * 24 * 7 * 1e3;
|
|
4
4
|
var AUTH_TIMEOUT_STATUS_CODE = 440;
|
|
5
5
|
var INVALID_SESSION_STATUS_CODE = 498;
|
|
6
6
|
export {
|
package/enums.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
declare const
|
|
3
|
+
declare const grantsArray: readonly [
|
|
4
4
|
"employee.create",
|
|
5
5
|
"employee.read",
|
|
6
6
|
"employee.update"
|
|
7
7
|
];
|
|
8
|
-
declare const
|
|
9
|
-
|
|
10
|
-
"EMPLOYEE.READ": "employee.read";
|
|
11
|
-
"EMPLOYEE.UPDATE": "employee.update";
|
|
12
|
-
};
|
|
13
|
-
type EmployeesPermission = (typeof employeesPermissionsArray)[number];
|
|
8
|
+
declare const grantsRecord: Record<"EMPLOYEE_CREATE" | "EMPLOYEE_READ" | "EMPLOYEE_UPDATE", "employee.create" | "employee.read" | "employee.update">;
|
|
9
|
+
export type Grant = (typeof grantsArray)[number];
|
|
14
10
|
|
|
15
11
|
export {
|
|
16
|
-
|
|
17
|
-
employeesPermissionsRecord as permissions,
|
|
12
|
+
grantsRecord as grants,
|
|
18
13
|
};
|
|
19
14
|
|
|
20
15
|
export {};
|
package/enums.js
CHANGED
|
@@ -1,15 +1,209 @@
|
|
|
1
|
-
// src/app/domain/(iam)/
|
|
2
|
-
import z from "zod";
|
|
1
|
+
// src/app/domain/(iam)/permissions/permissions.audit.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var permissionsAuditEvents = {
|
|
4
|
+
"permissions.updated": z.object({
|
|
5
|
+
targetEmployeeId: z.number(),
|
|
6
|
+
updatedGrants: grantsZodArray
|
|
7
|
+
})
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/app/domain/(iam)/permissions/permissions.repository.ts
|
|
11
|
+
import { sqlWhere } from "@kalutskii/foundation";
|
|
12
|
+
|
|
13
|
+
// src/drizzle/drizzle.database.ts
|
|
14
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
15
|
+
import postgres from "postgres";
|
|
16
|
+
|
|
17
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.relations.ts
|
|
18
|
+
import { defineRelationsPart } from "drizzle-orm";
|
|
19
|
+
|
|
20
|
+
// src/app/domain/(iam)/employees/employees.drizzle.ts
|
|
21
|
+
import { sql } from "drizzle-orm";
|
|
22
|
+
import { check, index, pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
|
|
23
|
+
|
|
24
|
+
// src/app/domain/(iam)/employees/employees.enums.ts
|
|
25
|
+
import { pgEnum } from "drizzle-orm/pg-core";
|
|
3
26
|
|
|
4
27
|
// src/utilities/enums.utilities.ts
|
|
5
28
|
function createStringEnumRecord(values) {
|
|
6
|
-
return Object.fromEntries(values.map((
|
|
29
|
+
return Object.fromEntries(values.map((v) => [v.replace(/\./g, "_").toUpperCase(), v]));
|
|
7
30
|
}
|
|
8
31
|
|
|
9
|
-
// src/app/domain/(iam)/employees
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
32
|
+
// src/app/domain/(iam)/employees/employees.enums.ts
|
|
33
|
+
var employeeStatusesArray = ["active", "suspended"];
|
|
34
|
+
var employeeStatusPGEnum = pgEnum("employee_status", employeeStatusesArray);
|
|
35
|
+
var employeeStatusesRecord = createStringEnumRecord(employeeStatusesArray);
|
|
36
|
+
|
|
37
|
+
// src/app/domain/(iam)/employees/employees.drizzle.ts
|
|
38
|
+
var employeesTable = pgTable("employees", {
|
|
39
|
+
id: serial("id").primaryKey(),
|
|
40
|
+
email: text("email").notNull().unique(),
|
|
41
|
+
fullName: text("full_name").notNull(),
|
|
42
|
+
passwordDigest: text("password_digest").notNull(),
|
|
43
|
+
status: employeeStatusPGEnum("status").notNull().default("active"),
|
|
44
|
+
updatedAt: timestamp("updated_at").$onUpdateFn(() => /* @__PURE__ */ new Date()),
|
|
45
|
+
createdAt: timestamp("created_at").notNull().defaultNow()
|
|
46
|
+
}, (table) => [
|
|
47
|
+
// Ensure `email` is not empty and matches a basic email regex pattern.
|
|
48
|
+
check("employees_email_check", sql`${table.email} ~* '^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$'`),
|
|
49
|
+
// Indexes for efficient querying by `passwordDigest`, and `status` columns.
|
|
50
|
+
index("employees_password_digest_idx").on(table.passwordDigest),
|
|
51
|
+
index("employees_status_idx").on(table.status)
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.drizzle.ts
|
|
55
|
+
import { sql as sql2 } from "drizzle-orm";
|
|
56
|
+
import { check as check2, index as index2, integer, jsonb, pgTable as pgTable2, serial as serial2, text as text2, timestamp as timestamp2 } from "drizzle-orm/pg-core";
|
|
57
|
+
var auditLogsTable = pgTable2("audit_logs", {
|
|
58
|
+
id: serial2("id").primaryKey(),
|
|
59
|
+
event: text2("event").notNull().$type(),
|
|
60
|
+
actorEmployeeId: integer("actor_employee_id").references(() => employeesTable.id, {
|
|
61
|
+
onDelete: "set null"
|
|
62
|
+
}),
|
|
63
|
+
payload: jsonb("payload").notNull(),
|
|
64
|
+
createdAt: timestamp2("created_at").notNull().defaultNow()
|
|
65
|
+
}, (table) => [
|
|
66
|
+
// Ensure `event` and `payload` are not empty.
|
|
67
|
+
check2("audit_event_check", sql2`${table.event} != ''`),
|
|
68
|
+
check2("audit_payload_check", sql2`jsonb_typeof(${table.payload}) = 'object'`),
|
|
69
|
+
// Indexes for efficient querying by `actorEmployeeId`, `event`, and `createdAt` columns.
|
|
70
|
+
index2("audit_logs_actor_employee_id_idx").on(table.actorEmployeeId),
|
|
71
|
+
index2("audit_logs_event_idx").on(table.event),
|
|
72
|
+
index2("audit_logs_created_at_idx").on(table.createdAt)
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
// src/app/domain/(iam)/audit-logs/audit-logs.relations.ts
|
|
76
|
+
var auditLogsRelationsPart = defineRelationsPart({ auditLogsTable, employeesTable }, (r) => ({
|
|
77
|
+
auditLogsTable: {
|
|
78
|
+
employee: r.one.employeesTable({
|
|
79
|
+
from: r.auditLogsTable.actorEmployeeId,
|
|
80
|
+
to: r.employeesTable.id
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
// src/app/domain/(iam)/employees/employees.relations.ts
|
|
86
|
+
import { defineRelationsPart as defineRelationsPart2 } from "drizzle-orm";
|
|
87
|
+
|
|
88
|
+
// src/app/domain/(iam)/permissions/permissions.drizzle.ts
|
|
89
|
+
import { integer as integer2, pgTable as pgTable3, serial as serial3, text as text3, timestamp as timestamp3, unique } from "drizzle-orm/pg-core";
|
|
90
|
+
var permissionsTable = pgTable3("permissions", {
|
|
91
|
+
id: serial3("id").primaryKey(),
|
|
92
|
+
grant: text3("grant").notNull().$type(),
|
|
93
|
+
employeeId: integer2("employee_id").notNull().references(() => employeesTable.id, { onDelete: "cascade" }),
|
|
94
|
+
createdAt: timestamp3("created_at").notNull().defaultNow()
|
|
95
|
+
}, (table) => [
|
|
96
|
+
// Unique constraint on (`employeeId`, `grant`) to prevent duplicate records for the same employee.
|
|
97
|
+
unique("permissions_employee_id_grant_unique").on(table.employeeId, table.grant)
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
// src/app/domain/(iam)/sessions/sessions.drizzle.ts
|
|
101
|
+
import { sql as sql3 } from "drizzle-orm";
|
|
102
|
+
import { check as check3, index as index3, integer as integer3, pgTable as pgTable4, serial as serial4, text as text4, timestamp as timestamp4 } from "drizzle-orm/pg-core";
|
|
103
|
+
var sessionsTable = pgTable4("sessions", {
|
|
104
|
+
id: serial4("id").primaryKey(),
|
|
105
|
+
employeeId: integer3("employee_id").notNull().references(() => employeesTable.id, { onDelete: "cascade" }),
|
|
106
|
+
refreshTokenDigest: text4("refresh_token_digest").notNull().unique(),
|
|
107
|
+
createdAt: timestamp4("created_at").notNull().defaultNow(),
|
|
108
|
+
expiresAt: timestamp4("expires_at").notNull(),
|
|
109
|
+
revokedAt: timestamp4("revoked_at")
|
|
110
|
+
}, (table) => [
|
|
111
|
+
// Ensure `expiresAt` is always greater than `createdAt`.
|
|
112
|
+
check3("sessions_expires_at_check", sql3`${table.expiresAt} > ${table.createdAt}`),
|
|
113
|
+
// Indexes for efficient querying by `employeeId` and `expiresAt` columns.
|
|
114
|
+
index3("sessions_employee_id_idx").on(table.employeeId),
|
|
115
|
+
index3("sessions_expires_at_idx").on(table.expiresAt)
|
|
116
|
+
]);
|
|
117
|
+
|
|
118
|
+
// src/app/domain/(iam)/employees/employees.relations.ts
|
|
119
|
+
var employeesRelationsPart = defineRelationsPart2({ auditLogsTable, employeesTable, permissionsTable, sessionsTable }, (r) => ({
|
|
120
|
+
employeesTable: {
|
|
121
|
+
auditLogs: r.many.auditLogsTable({
|
|
122
|
+
from: r.employeesTable.id,
|
|
123
|
+
to: r.auditLogsTable.actorEmployeeId
|
|
124
|
+
}),
|
|
125
|
+
permissions: r.many.permissionsTable({
|
|
126
|
+
from: r.employeesTable.id,
|
|
127
|
+
to: r.permissionsTable.employeeId
|
|
128
|
+
}),
|
|
129
|
+
sessions: r.many.sessionsTable({
|
|
130
|
+
from: r.employeesTable.id,
|
|
131
|
+
to: r.sessionsTable.employeeId
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
|
|
136
|
+
// src/app/domain/(iam)/permissions/permissions.relations.ts
|
|
137
|
+
import { defineRelationsPart as defineRelationsPart3 } from "drizzle-orm";
|
|
138
|
+
var permissionsRelationsPart = defineRelationsPart3({ permissionsTable, employeesTable }, (r) => ({
|
|
139
|
+
permissionsTable: {
|
|
140
|
+
employee: r.one.employeesTable({
|
|
141
|
+
from: r.permissionsTable.employeeId,
|
|
142
|
+
to: r.employeesTable.id
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
// src/app/domain/(iam)/sessions/sessions.relations.ts
|
|
148
|
+
import { defineRelationsPart as defineRelationsPart4 } from "drizzle-orm";
|
|
149
|
+
var sessionsRelationsPart = defineRelationsPart4({ sessionsTable, employeesTable }, (r) => ({
|
|
150
|
+
sessionsTable: {
|
|
151
|
+
employee: r.one.employeesTable({
|
|
152
|
+
from: r.sessionsTable.employeeId,
|
|
153
|
+
to: r.employeesTable.id
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
// src/app/domain/domain.registry.ts
|
|
159
|
+
var domainRelationsRegistry = {
|
|
160
|
+
...auditLogsRelationsPart,
|
|
161
|
+
...employeesRelationsPart,
|
|
162
|
+
...permissionsRelationsPart,
|
|
163
|
+
...sessionsRelationsPart
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/internal/env.config.ts
|
|
167
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
168
|
+
import { z as z2 } from "zod";
|
|
169
|
+
var env = createEnv({
|
|
170
|
+
server: {
|
|
171
|
+
// Database settings for Drizzle ORM
|
|
172
|
+
DRIZZLE_DB_URL: z2.url().min(8).max(256),
|
|
173
|
+
DRIZZLE_MIGRATIONS_FOLDER: z2.string().min(1).max(256),
|
|
174
|
+
// Bun server settings
|
|
175
|
+
BUN_SERVER_PORT: z2.coerce.number().int().positive().min(1).max(65535),
|
|
176
|
+
BUN_SERVER_HOST: z2.string().min(1).max(64).optional().default("0.0.0.0"),
|
|
177
|
+
// Ecosystem variables
|
|
178
|
+
ESB_MARKET_SPACE_JWT_SECRET: z2.string().min(32).max(256),
|
|
179
|
+
// Peripheral settings, usually not required in the environment
|
|
180
|
+
PRODUCTION: z2.boolean().default(process.env.NODE_ENV === "production"),
|
|
181
|
+
DEVELOPMENT: z2.boolean().default(process.env.NODE_ENV === "development"),
|
|
182
|
+
DEFAULT_TIMEZONE: z2.string().min(4).max(256).optional().default("Asia/Tbilisi")
|
|
183
|
+
},
|
|
184
|
+
runtimeEnv: process.env,
|
|
185
|
+
emptyStringAsUndefined: true
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// src/drizzle/drizzle.database.ts
|
|
189
|
+
var sql4 = postgres(env.DRIZZLE_DB_URL, { max: 10, idle_timeout: 20, connect_timeout: 10, prepare: false });
|
|
190
|
+
var db = drizzle({ client: sql4, relations: domainRelationsRegistry });
|
|
191
|
+
|
|
192
|
+
// src/app/domain/(iam)/permissions/permissions.schemas.ts
|
|
193
|
+
import { zodAtLeastOne } from "@kalutskii/foundation";
|
|
194
|
+
import { createSelectSchema } from "drizzle-orm/zod";
|
|
195
|
+
import { z as z3 } from "zod";
|
|
196
|
+
var permissionEntitySchema = createSelectSchema(permissionsTable);
|
|
197
|
+
var permissionSchema = permissionEntitySchema.omit({ grant: true }).extend({ grant: z3.enum(grantsArray) });
|
|
198
|
+
var permissionInsertSchema = permissionSchema.omit({ id: true, createdAt: true }).strict();
|
|
199
|
+
var permissionSelectSchema = permissionSchema.pick({ employeeId: true });
|
|
200
|
+
var permissionSelectManySchema = zodAtLeastOne(permissionSchema.pick({ employeeId: true, grant: true }).partial());
|
|
201
|
+
|
|
202
|
+
// src/app/domain/(iam)/permissions/permissions.enums.ts
|
|
203
|
+
import z4 from "zod";
|
|
204
|
+
var grantsArray = ["employee.create", "employee.read", "employee.update"];
|
|
205
|
+
var grantsZodArray = z4.array(z4.enum(grantsArray));
|
|
206
|
+
var grantsRecord = createStringEnumRecord(grantsArray);
|
|
13
207
|
export {
|
|
14
|
-
|
|
208
|
+
grantsRecord as grants
|
|
15
209
|
};
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import { AsQuery, SerializeDates } from '@kalutskii/foundation';
|
|
4
|
-
import z from 'zod';
|
|
5
3
|
import { z } from 'zod';
|
|
6
4
|
|
|
7
|
-
declare const
|
|
5
|
+
declare const signinPayloadSchema: z.ZodObject<{
|
|
8
6
|
email: z.ZodEmail;
|
|
9
7
|
password: z.ZodString;
|
|
10
|
-
}, z.core.$
|
|
8
|
+
}, z.core.$strict>;
|
|
11
9
|
declare const sessionPayloadSchema: z.ZodObject<{
|
|
12
10
|
employee: z.ZodObject<{
|
|
13
11
|
id: z.ZodInt;
|
|
@@ -19,65 +17,17 @@ declare const sessionPayloadSchema: z.ZodObject<{
|
|
|
19
17
|
}>;
|
|
20
18
|
updatedAt: z.ZodNullable<z.ZodDate>;
|
|
21
19
|
createdAt: z.ZodDate;
|
|
20
|
+
grants: z.ZodArray<z.ZodEnum<{
|
|
21
|
+
"employee.create": "employee.create";
|
|
22
|
+
"employee.read": "employee.read";
|
|
23
|
+
"employee.update": "employee.update";
|
|
24
|
+
}>>;
|
|
22
25
|
}, {
|
|
23
26
|
out: {};
|
|
24
27
|
in: {};
|
|
25
28
|
}>;
|
|
26
|
-
permissions: z.ZodArray<z.ZodEnum<{
|
|
27
|
-
"employee.create": "employee.create";
|
|
28
|
-
"employee.read": "employee.read";
|
|
29
|
-
"employee.update": "employee.update";
|
|
30
|
-
}>>;
|
|
31
29
|
}, z.core.$strip>;
|
|
32
|
-
export type
|
|
30
|
+
export type SigninPayload = z.infer<typeof signinPayloadSchema>;
|
|
33
31
|
export type SessionPayload = z.infer<typeof sessionPayloadSchema>;
|
|
34
|
-
declare const employeeSelectRequestSchema: z.ZodUnion<readonly [
|
|
35
|
-
z.ZodObject<{
|
|
36
|
-
id: z.ZodCoercedNumber<unknown>;
|
|
37
|
-
}, z.core.$strip>,
|
|
38
|
-
z.ZodObject<{
|
|
39
|
-
email: z.ZodString;
|
|
40
|
-
}, z.core.$strip>
|
|
41
|
-
]>;
|
|
42
|
-
declare const employeeRecordSchema: z.ZodObject<{
|
|
43
|
-
id: z.ZodInt;
|
|
44
|
-
email: z.ZodString;
|
|
45
|
-
fullName: z.ZodString;
|
|
46
|
-
status: z.ZodEnum<{
|
|
47
|
-
active: "active";
|
|
48
|
-
suspended: "suspended";
|
|
49
|
-
}>;
|
|
50
|
-
updatedAt: z.ZodNullable<z.ZodDate>;
|
|
51
|
-
createdAt: z.ZodDate;
|
|
52
|
-
permissions: z.ZodArray<z.ZodEnum<{
|
|
53
|
-
"employee.create": "employee.create";
|
|
54
|
-
"employee.read": "employee.read";
|
|
55
|
-
"employee.update": "employee.update";
|
|
56
|
-
}>>;
|
|
57
|
-
}, {
|
|
58
|
-
out: {};
|
|
59
|
-
in: {};
|
|
60
|
-
}>;
|
|
61
|
-
declare const employeeInsertRequestSchema: z.ZodObject<{
|
|
62
|
-
email: z.ZodString;
|
|
63
|
-
fullName: z.ZodString;
|
|
64
|
-
password: z.ZodString;
|
|
65
|
-
permissions: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
66
|
-
"employee.create": "employee.create";
|
|
67
|
-
"employee.read": "employee.read";
|
|
68
|
-
"employee.update": "employee.update";
|
|
69
|
-
}>>>;
|
|
70
|
-
}, {
|
|
71
|
-
out: {};
|
|
72
|
-
in: {};
|
|
73
|
-
}>;
|
|
74
|
-
declare const employeePasswordUpdateRequestSchema: z.ZodObject<{
|
|
75
|
-
employeeId: z.ZodCoercedNumber<unknown>;
|
|
76
|
-
password: z.ZodString;
|
|
77
|
-
}, z.core.$strip>;
|
|
78
|
-
export type EmployeeSelectRequest = AsQuery<z.infer<typeof employeeSelectRequestSchema>>;
|
|
79
|
-
export type EmployeeRecord = SerializeDates<z.infer<typeof employeeRecordSchema>>;
|
|
80
|
-
export type EmployeeInsertRequest = z.infer<typeof employeeInsertRequestSchema>;
|
|
81
|
-
export type EmployeePasswordUpdateRequest = z.infer<typeof employeePasswordUpdateRequestSchema>;
|
|
82
32
|
|
|
83
33
|
export {};
|