@spfn/auth 0.2.0-beta.91 → 0.3.0-beta.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/dist/server.d.ts +11 -11
- package/dist/server.js +43 -113
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/server.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
80
80
|
identity: undefined;
|
|
81
81
|
generated: undefined;
|
|
82
82
|
}>;
|
|
83
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"users", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
83
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"users", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
84
84
|
name: string;
|
|
85
85
|
tableName: "users";
|
|
86
86
|
dataType: "object date";
|
|
@@ -581,7 +581,7 @@ declare const roles: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
581
581
|
identity: undefined;
|
|
582
582
|
generated: undefined;
|
|
583
583
|
}>;
|
|
584
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"roles", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
584
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"roles", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
585
585
|
name: string;
|
|
586
586
|
tableName: "roles";
|
|
587
587
|
dataType: "object date";
|
|
@@ -894,7 +894,7 @@ declare const userInvitations: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
894
894
|
identity: undefined;
|
|
895
895
|
generated: undefined;
|
|
896
896
|
}>;
|
|
897
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_invitations", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
897
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_invitations", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
898
898
|
name: string;
|
|
899
899
|
tableName: "user_invitations";
|
|
900
900
|
dataType: "object date";
|
|
@@ -1655,7 +1655,7 @@ declare const accountDeletionRequests: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
1655
1655
|
identity: undefined;
|
|
1656
1656
|
generated: undefined;
|
|
1657
1657
|
}>;
|
|
1658
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"account_deletion_requests", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
1658
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"account_deletion_requests", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
1659
1659
|
name: string;
|
|
1660
1660
|
tableName: "account_deletion_requests";
|
|
1661
1661
|
dataType: "object date";
|
|
@@ -1977,7 +1977,7 @@ declare const userProfiles: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
1977
1977
|
identity: undefined;
|
|
1978
1978
|
generated: undefined;
|
|
1979
1979
|
}>;
|
|
1980
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_profiles", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
1980
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_profiles", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
1981
1981
|
name: string;
|
|
1982
1982
|
tableName: "user_profiles";
|
|
1983
1983
|
dataType: "object date";
|
|
@@ -2552,7 +2552,7 @@ declare const userSocialAccounts: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
2552
2552
|
identity: undefined;
|
|
2553
2553
|
generated: undefined;
|
|
2554
2554
|
}>;
|
|
2555
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_social_accounts", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
2555
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_social_accounts", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
2556
2556
|
name: string;
|
|
2557
2557
|
tableName: "user_social_accounts";
|
|
2558
2558
|
dataType: "object date";
|
|
@@ -2718,7 +2718,7 @@ declare const verificationCodes: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
2718
2718
|
identity: undefined;
|
|
2719
2719
|
generated: undefined;
|
|
2720
2720
|
}>;
|
|
2721
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"verification_codes", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
2721
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"verification_codes", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
2722
2722
|
name: string;
|
|
2723
2723
|
tableName: "verification_codes";
|
|
2724
2724
|
dataType: "object date";
|
|
@@ -2889,7 +2889,7 @@ declare const permissions: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
2889
2889
|
identity: undefined;
|
|
2890
2890
|
generated: undefined;
|
|
2891
2891
|
}>;
|
|
2892
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"permissions", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
2892
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"permissions", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
2893
2893
|
name: string;
|
|
2894
2894
|
tableName: "permissions";
|
|
2895
2895
|
dataType: "object date";
|
|
@@ -3075,7 +3075,7 @@ declare const rolePermissions: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
3075
3075
|
identity: undefined;
|
|
3076
3076
|
generated: undefined;
|
|
3077
3077
|
}>;
|
|
3078
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"role_permissions", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
3078
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"role_permissions", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
3079
3079
|
name: string;
|
|
3080
3080
|
tableName: "role_permissions";
|
|
3081
3081
|
dataType: "object date";
|
|
@@ -3174,7 +3174,7 @@ declare const userPermissions: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
3174
3174
|
identity: undefined;
|
|
3175
3175
|
generated: undefined;
|
|
3176
3176
|
}>;
|
|
3177
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_permissions", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder
|
|
3177
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"user_permissions", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
3178
3178
|
name: string;
|
|
3179
3179
|
tableName: "user_permissions";
|
|
3180
3180
|
dataType: "object date";
|
|
@@ -3325,7 +3325,7 @@ declare const authMetadata: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
3325
3325
|
identity: undefined;
|
|
3326
3326
|
generated: undefined;
|
|
3327
3327
|
}>;
|
|
3328
|
-
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"auth_metadata", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgTimestampBuilder
|
|
3328
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"auth_metadata", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
3329
3329
|
name: string;
|
|
3330
3330
|
tableName: "auth_metadata";
|
|
3331
3331
|
dataType: "object date";
|
package/dist/server.js
CHANGED
|
@@ -5411,6 +5411,7 @@ var init_user_permissions = __esm({
|
|
|
5411
5411
|
});
|
|
5412
5412
|
|
|
5413
5413
|
// src/server/entities/auth-metadata.ts
|
|
5414
|
+
import { sql as sql3 } from "drizzle-orm";
|
|
5414
5415
|
import { text as text11, timestamp } from "drizzle-orm/pg-core";
|
|
5415
5416
|
var authMetadata;
|
|
5416
5417
|
var init_auth_metadata = __esm({
|
|
@@ -5424,8 +5425,8 @@ var init_auth_metadata = __esm({
|
|
|
5424
5425
|
key: text11("key").primaryKey(),
|
|
5425
5426
|
// Metadata value
|
|
5426
5427
|
value: text11("value").notNull(),
|
|
5427
|
-
// Last updated timestamp
|
|
5428
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
5428
|
+
// Last updated timestamp — stamped by the database on insert and on update
|
|
5429
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => sql3`now()`)
|
|
5429
5430
|
}
|
|
5430
5431
|
);
|
|
5431
5432
|
}
|
|
@@ -5551,18 +5552,14 @@ var init_users_repository = __esm({
|
|
|
5551
5552
|
* Write primary 사용
|
|
5552
5553
|
*/
|
|
5553
5554
|
async create(data) {
|
|
5554
|
-
return await this._create(users,
|
|
5555
|
-
...data,
|
|
5556
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
5557
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
5558
|
-
});
|
|
5555
|
+
return await this._create(users, data);
|
|
5559
5556
|
}
|
|
5560
5557
|
/**
|
|
5561
5558
|
* 사용자 정보 업데이트
|
|
5562
5559
|
* Write primary 사용
|
|
5563
5560
|
*/
|
|
5564
5561
|
async updateById(id12, data) {
|
|
5565
|
-
const result = await this.db.update(users).set(
|
|
5562
|
+
const result = await this.db.update(users).set(data).where(eq(users.id, id12)).returning();
|
|
5566
5563
|
return result[0] ?? null;
|
|
5567
5564
|
}
|
|
5568
5565
|
/**
|
|
@@ -5575,7 +5572,7 @@ var init_users_repository = __esm({
|
|
|
5575
5572
|
* Write primary 사용
|
|
5576
5573
|
*/
|
|
5577
5574
|
async reactivateFromPendingDeletion(id12) {
|
|
5578
|
-
const result = await this.db.update(users).set({ status: "active"
|
|
5575
|
+
const result = await this.db.update(users).set({ status: "active" }).where(
|
|
5579
5576
|
and(
|
|
5580
5577
|
eq(users.id, id12),
|
|
5581
5578
|
eq(users.status, "pending_deletion")
|
|
@@ -5589,8 +5586,7 @@ var init_users_repository = __esm({
|
|
|
5589
5586
|
*/
|
|
5590
5587
|
async updatePassword(id12, passwordHash, clearPasswordChangeRequired = true) {
|
|
5591
5588
|
const updateData = {
|
|
5592
|
-
passwordHash
|
|
5593
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
5589
|
+
passwordHash
|
|
5594
5590
|
};
|
|
5595
5591
|
if (clearPasswordChangeRequired) {
|
|
5596
5592
|
updateData.passwordChangeRequired = false;
|
|
@@ -5604,8 +5600,7 @@ var init_users_repository = __esm({
|
|
|
5604
5600
|
*/
|
|
5605
5601
|
async updateLastLogin(id12) {
|
|
5606
5602
|
const result = await this.db.update(users).set({
|
|
5607
|
-
lastLoginAt: /* @__PURE__ */ new Date()
|
|
5608
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
5603
|
+
lastLoginAt: /* @__PURE__ */ new Date()
|
|
5609
5604
|
}).where(eq(users.id, id12)).returning();
|
|
5610
5605
|
return result[0] ?? null;
|
|
5611
5606
|
}
|
|
@@ -5731,7 +5726,7 @@ var init_users_repository = __esm({
|
|
|
5731
5726
|
|
|
5732
5727
|
// src/server/repositories/keys.repository.ts
|
|
5733
5728
|
import { BaseRepository as BaseRepository2 } from "@spfn/core/db";
|
|
5734
|
-
import { eq as eq2, and as and2, or, isNull, lt, ne, desc, sql as
|
|
5729
|
+
import { eq as eq2, and as and2, or, isNull, lt, ne, desc, sql as sql4 } from "drizzle-orm";
|
|
5735
5730
|
var LAST_USED_THROTTLE_MS, KeysRepository, keysRepository;
|
|
5736
5731
|
var init_keys_repository = __esm({
|
|
5737
5732
|
"src/server/repositories/keys.repository.ts"() {
|
|
@@ -5972,19 +5967,19 @@ var init_keys_repository = __esm({
|
|
|
5972
5967
|
await this.db.update(userPublicKeys).set({ lastUsedAt: /* @__PURE__ */ new Date() }).where(and2(eq2(userPublicKeys.id, id12), lastUsedIsStale));
|
|
5973
5968
|
return;
|
|
5974
5969
|
}
|
|
5975
|
-
const identityChanged =
|
|
5970
|
+
const identityChanged = sql4`(
|
|
5976
5971
|
${userPublicKeys.clientKind} IS DISTINCT FROM ${identity.kind}
|
|
5977
5972
|
OR ${userPublicKeys.clientVersion} IS DISTINCT FROM ${identity.version}
|
|
5978
5973
|
OR ${userPublicKeys.clientContractVersion} IS DISTINCT FROM ${identity.contractVersion}
|
|
5979
5974
|
)`;
|
|
5980
5975
|
const now = /* @__PURE__ */ new Date();
|
|
5981
|
-
const nowParam =
|
|
5976
|
+
const nowParam = sql4`${now.toISOString()}::timestamptz`;
|
|
5982
5977
|
await this.db.update(userPublicKeys).set({
|
|
5983
5978
|
lastUsedAt: now,
|
|
5984
5979
|
clientKind: identity.kind,
|
|
5985
5980
|
clientVersion: identity.version,
|
|
5986
5981
|
clientContractVersion: identity.contractVersion,
|
|
5987
|
-
clientSeenAt:
|
|
5982
|
+
clientSeenAt: sql4`CASE WHEN ${identityChanged} THEN ${nowParam} ELSE ${userPublicKeys.clientSeenAt} END`
|
|
5988
5983
|
}).where(and2(
|
|
5989
5984
|
eq2(userPublicKeys.id, id12),
|
|
5990
5985
|
or(lastUsedIsStale, identityChanged)
|
|
@@ -6034,11 +6029,7 @@ var init_verification_codes_repository = __esm({
|
|
|
6034
6029
|
* Write primary 사용
|
|
6035
6030
|
*/
|
|
6036
6031
|
async create(data) {
|
|
6037
|
-
return await this._create(verificationCodes,
|
|
6038
|
-
...data,
|
|
6039
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
6040
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6041
|
-
});
|
|
6032
|
+
return await this._create(verificationCodes, data);
|
|
6042
6033
|
}
|
|
6043
6034
|
/**
|
|
6044
6035
|
* 인증 코드 사용 처리
|
|
@@ -6046,8 +6037,7 @@ var init_verification_codes_repository = __esm({
|
|
|
6046
6037
|
*/
|
|
6047
6038
|
async markAsUsed(id12) {
|
|
6048
6039
|
const result = await this.db.update(verificationCodes).set({
|
|
6049
|
-
usedAt: /* @__PURE__ */ new Date()
|
|
6050
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6040
|
+
usedAt: /* @__PURE__ */ new Date()
|
|
6051
6041
|
}).where(eq3(verificationCodes.id, id12)).returning();
|
|
6052
6042
|
return result[0] ?? null;
|
|
6053
6043
|
}
|
|
@@ -6059,8 +6049,7 @@ var init_verification_codes_repository = __esm({
|
|
|
6059
6049
|
const code = await this.findById(id12);
|
|
6060
6050
|
if (!code) return null;
|
|
6061
6051
|
const result = await this.db.update(verificationCodes).set({
|
|
6062
|
-
attempts: code.attempts + 1
|
|
6063
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6052
|
+
attempts: code.attempts + 1
|
|
6064
6053
|
}).where(eq3(verificationCodes.id, id12)).returning();
|
|
6065
6054
|
return result[0] ?? null;
|
|
6066
6055
|
}
|
|
@@ -6090,8 +6079,7 @@ var init_verification_codes_repository = __esm({
|
|
|
6090
6079
|
*/
|
|
6091
6080
|
async invalidatePreviousCodes(target, purpose) {
|
|
6092
6081
|
const result = await this.db.update(verificationCodes).set({
|
|
6093
|
-
usedAt: /* @__PURE__ */ new Date()
|
|
6094
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6082
|
+
usedAt: /* @__PURE__ */ new Date()
|
|
6095
6083
|
}).where(
|
|
6096
6084
|
and3(
|
|
6097
6085
|
eq3(verificationCodes.target, target),
|
|
@@ -6145,17 +6133,13 @@ var init_roles_repository = __esm({
|
|
|
6145
6133
|
* 역할 생성
|
|
6146
6134
|
*/
|
|
6147
6135
|
async create(data) {
|
|
6148
|
-
return await this._create(roles,
|
|
6149
|
-
...data,
|
|
6150
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
6151
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6152
|
-
});
|
|
6136
|
+
return await this._create(roles, data);
|
|
6153
6137
|
}
|
|
6154
6138
|
/**
|
|
6155
6139
|
* 역할 업데이트
|
|
6156
6140
|
*/
|
|
6157
6141
|
async updateById(id12, data) {
|
|
6158
|
-
const result = await this.db.update(roles).set(
|
|
6142
|
+
const result = await this.db.update(roles).set(data).where(eq4(roles.id, id12)).returning();
|
|
6159
6143
|
return result[0] ?? null;
|
|
6160
6144
|
}
|
|
6161
6145
|
/**
|
|
@@ -6222,30 +6206,20 @@ var init_permissions_repository = __esm({
|
|
|
6222
6206
|
* 권한 생성
|
|
6223
6207
|
*/
|
|
6224
6208
|
async create(data) {
|
|
6225
|
-
return await this._create(permissions,
|
|
6226
|
-
...data,
|
|
6227
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
6228
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6229
|
-
});
|
|
6209
|
+
return await this._create(permissions, data);
|
|
6230
6210
|
}
|
|
6231
6211
|
/**
|
|
6232
6212
|
* 여러 권한 일괄 생성
|
|
6233
6213
|
*/
|
|
6234
6214
|
async createMany(data) {
|
|
6235
6215
|
if (data.length === 0) return [];
|
|
6236
|
-
|
|
6237
|
-
const valuesWithTimestamps = data.map((d) => ({
|
|
6238
|
-
...d,
|
|
6239
|
-
createdAt: now,
|
|
6240
|
-
updatedAt: now
|
|
6241
|
-
}));
|
|
6242
|
-
return await this._createMany(permissions, valuesWithTimestamps);
|
|
6216
|
+
return await this._createMany(permissions, data);
|
|
6243
6217
|
}
|
|
6244
6218
|
/**
|
|
6245
6219
|
* 권한 업데이트
|
|
6246
6220
|
*/
|
|
6247
6221
|
async updateById(id12, data) {
|
|
6248
|
-
const result = await this.db.update(permissions).set(
|
|
6222
|
+
const result = await this.db.update(permissions).set(data).where(eq5(permissions.id, id12)).returning();
|
|
6249
6223
|
return result[0] ?? null;
|
|
6250
6224
|
}
|
|
6251
6225
|
/**
|
|
@@ -6285,24 +6259,14 @@ var init_role_permissions_repository = __esm({
|
|
|
6285
6259
|
* 역할-권한 매핑 생성
|
|
6286
6260
|
*/
|
|
6287
6261
|
async create(data) {
|
|
6288
|
-
return await this._create(rolePermissions,
|
|
6289
|
-
...data,
|
|
6290
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
6291
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6292
|
-
});
|
|
6262
|
+
return await this._create(rolePermissions, data);
|
|
6293
6263
|
}
|
|
6294
6264
|
/**
|
|
6295
6265
|
* 여러 역할-권한 매핑 일괄 생성
|
|
6296
6266
|
*/
|
|
6297
6267
|
async createMany(data) {
|
|
6298
6268
|
if (data.length === 0) return [];
|
|
6299
|
-
|
|
6300
|
-
const valuesWithTimestamps = data.map((d) => ({
|
|
6301
|
-
...d,
|
|
6302
|
-
createdAt: now,
|
|
6303
|
-
updatedAt: now
|
|
6304
|
-
}));
|
|
6305
|
-
return await this._createMany(rolePermissions, valuesWithTimestamps);
|
|
6269
|
+
return await this._createMany(rolePermissions, data);
|
|
6306
6270
|
}
|
|
6307
6271
|
/**
|
|
6308
6272
|
* 특정 역할-권한 매핑 삭제
|
|
@@ -6387,17 +6351,13 @@ var init_user_permissions_repository = __esm({
|
|
|
6387
6351
|
* 사용자 권한 오버라이드 생성
|
|
6388
6352
|
*/
|
|
6389
6353
|
async create(data) {
|
|
6390
|
-
return await this._create(userPermissions,
|
|
6391
|
-
...data,
|
|
6392
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
6393
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6394
|
-
});
|
|
6354
|
+
return await this._create(userPermissions, data);
|
|
6395
6355
|
}
|
|
6396
6356
|
/**
|
|
6397
6357
|
* 사용자 권한 오버라이드 업데이트
|
|
6398
6358
|
*/
|
|
6399
6359
|
async updateById(id12, data) {
|
|
6400
|
-
const result = await this.db.update(userPermissions).set(
|
|
6360
|
+
const result = await this.db.update(userPermissions).set(data).where(eq7(userPermissions.id, id12)).returning();
|
|
6401
6361
|
return result[0] ?? null;
|
|
6402
6362
|
}
|
|
6403
6363
|
/**
|
|
@@ -6471,24 +6431,20 @@ var init_user_profiles_repository = __esm({
|
|
|
6471
6431
|
* 프로필 생성
|
|
6472
6432
|
*/
|
|
6473
6433
|
async create(data) {
|
|
6474
|
-
return await this._create(userProfiles,
|
|
6475
|
-
...data,
|
|
6476
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
6477
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6478
|
-
});
|
|
6434
|
+
return await this._create(userProfiles, data);
|
|
6479
6435
|
}
|
|
6480
6436
|
/**
|
|
6481
6437
|
* 프로필 업데이트 (by ID)
|
|
6482
6438
|
*/
|
|
6483
6439
|
async updateById(id12, data) {
|
|
6484
|
-
const result = await this.db.update(userProfiles).set(
|
|
6440
|
+
const result = await this.db.update(userProfiles).set(data).where(eq8(userProfiles.id, id12)).returning();
|
|
6485
6441
|
return result[0] ?? null;
|
|
6486
6442
|
}
|
|
6487
6443
|
/**
|
|
6488
6444
|
* 프로필 업데이트 (by User ID)
|
|
6489
6445
|
*/
|
|
6490
6446
|
async updateByUserId(userId, data) {
|
|
6491
|
-
const result = await this.db.update(userProfiles).set(
|
|
6447
|
+
const result = await this.db.update(userProfiles).set(data).where(eq8(userProfiles.userId, userId)).returning();
|
|
6492
6448
|
return result[0] ?? null;
|
|
6493
6449
|
}
|
|
6494
6450
|
/**
|
|
@@ -6572,7 +6528,7 @@ var init_user_profiles_repository = __esm({
|
|
|
6572
6528
|
});
|
|
6573
6529
|
|
|
6574
6530
|
// src/server/repositories/invitations.repository.ts
|
|
6575
|
-
import { eq as eq9, and as and6, lt as lt4, desc as desc2, sql as
|
|
6531
|
+
import { eq as eq9, and as and6, lt as lt4, desc as desc2, sql as sql5 } from "drizzle-orm";
|
|
6576
6532
|
import { BaseRepository as BaseRepository9 } from "@spfn/core/db";
|
|
6577
6533
|
var InvitationsRepository, invitationsRepository;
|
|
6578
6534
|
var init_invitations_repository = __esm({
|
|
@@ -6624,19 +6580,14 @@ var init_invitations_repository = __esm({
|
|
|
6624
6580
|
* 초대 생성
|
|
6625
6581
|
*/
|
|
6626
6582
|
async create(data) {
|
|
6627
|
-
return await this._create(userInvitations,
|
|
6628
|
-
...data,
|
|
6629
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
6630
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6631
|
-
});
|
|
6583
|
+
return await this._create(userInvitations, data);
|
|
6632
6584
|
}
|
|
6633
6585
|
/**
|
|
6634
6586
|
* 초대 상태 업데이트
|
|
6635
6587
|
*/
|
|
6636
6588
|
async updateStatus(id12, status, timestamp2) {
|
|
6637
6589
|
const updates = {
|
|
6638
|
-
status
|
|
6639
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6590
|
+
status
|
|
6640
6591
|
};
|
|
6641
6592
|
if (timestamp2) {
|
|
6642
6593
|
if (status === "accepted") {
|
|
@@ -6660,10 +6611,7 @@ var init_invitations_repository = __esm({
|
|
|
6660
6611
|
*/
|
|
6661
6612
|
async updateExpiredInvitations() {
|
|
6662
6613
|
const now = /* @__PURE__ */ new Date();
|
|
6663
|
-
const result = await this.db.update(userInvitations).set({
|
|
6664
|
-
status: "expired",
|
|
6665
|
-
updatedAt: now
|
|
6666
|
-
}).where(
|
|
6614
|
+
const result = await this.db.update(userInvitations).set({ status: "expired" }).where(
|
|
6667
6615
|
and6(
|
|
6668
6616
|
eq9(userInvitations.status, "pending"),
|
|
6669
6617
|
lt4(userInvitations.expiresAt, now)
|
|
@@ -6714,7 +6662,7 @@ var init_invitations_repository = __esm({
|
|
|
6714
6662
|
conditions.push(eq9(userInvitations.invitedBy, invitedBy));
|
|
6715
6663
|
}
|
|
6716
6664
|
const whereClause = conditions.length > 0 ? and6(...conditions) : void 0;
|
|
6717
|
-
const countResult = await this.readDb.select({ count:
|
|
6665
|
+
const countResult = await this.readDb.select({ count: sql5`count(*)` }).from(userInvitations).where(whereClause);
|
|
6718
6666
|
const total = Number(countResult[0]?.count || 0);
|
|
6719
6667
|
const results = await this.readDb.select({
|
|
6720
6668
|
id: userInvitations.id,
|
|
@@ -6751,10 +6699,7 @@ var init_invitations_repository = __esm({
|
|
|
6751
6699
|
* 초대 업데이트 (일반 업데이트 - 모든 필드 가능)
|
|
6752
6700
|
*/
|
|
6753
6701
|
async updateById(id12, data) {
|
|
6754
|
-
const result = await this.db.update(userInvitations).set(
|
|
6755
|
-
...data,
|
|
6756
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6757
|
-
}).where(eq9(userInvitations.id, id12)).returning();
|
|
6702
|
+
const result = await this.db.update(userInvitations).set(data).where(eq9(userInvitations.id, id12)).returning();
|
|
6758
6703
|
return result[0] ?? null;
|
|
6759
6704
|
}
|
|
6760
6705
|
/**
|
|
@@ -6763,8 +6708,7 @@ var init_invitations_repository = __esm({
|
|
|
6763
6708
|
async resend(id12, newExpiresAt) {
|
|
6764
6709
|
const result = await this.db.update(userInvitations).set({
|
|
6765
6710
|
status: "pending",
|
|
6766
|
-
expiresAt: newExpiresAt
|
|
6767
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6711
|
+
expiresAt: newExpiresAt
|
|
6768
6712
|
}).where(eq9(userInvitations.id, id12)).returning();
|
|
6769
6713
|
return result[0] ?? null;
|
|
6770
6714
|
}
|
|
@@ -6776,8 +6720,7 @@ var init_invitations_repository = __esm({
|
|
|
6776
6720
|
const result = await this.db.update(userInvitations).set({
|
|
6777
6721
|
status: "cancelled",
|
|
6778
6722
|
cancelledAt: /* @__PURE__ */ new Date(),
|
|
6779
|
-
metadata: newMetadata
|
|
6780
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
6723
|
+
metadata: newMetadata
|
|
6781
6724
|
}).where(eq9(userInvitations.id, id12)).returning();
|
|
6782
6725
|
return result[0] ?? null;
|
|
6783
6726
|
}
|
|
@@ -7495,9 +7438,7 @@ var init_social_accounts_repository = __esm({
|
|
|
7495
7438
|
const created = await this._create(userSocialAccounts, {
|
|
7496
7439
|
...data,
|
|
7497
7440
|
accessToken: data.accessToken ? await encryptToken(data.accessToken, context("access")) : data.accessToken,
|
|
7498
|
-
refreshToken: data.refreshToken ? await encryptToken(data.refreshToken, context("refresh")) : data.refreshToken
|
|
7499
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
7500
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
7441
|
+
refreshToken: data.refreshToken ? await encryptToken(data.refreshToken, context("refresh")) : data.refreshToken
|
|
7501
7442
|
});
|
|
7502
7443
|
return this.decryptAccount(created);
|
|
7503
7444
|
}
|
|
@@ -7522,8 +7463,7 @@ var init_social_accounts_repository = __esm({
|
|
|
7522
7463
|
const result = await this.db.update(userSocialAccounts).set({
|
|
7523
7464
|
...data,
|
|
7524
7465
|
accessToken: data.accessToken ? await encryptToken(data.accessToken, context("access")) : data.accessToken,
|
|
7525
|
-
refreshToken: data.refreshToken ? await encryptToken(data.refreshToken, context("refresh")) : data.refreshToken
|
|
7526
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
7466
|
+
refreshToken: data.refreshToken ? await encryptToken(data.refreshToken, context("refresh")) : data.refreshToken
|
|
7527
7467
|
}).where(eq10(userSocialAccounts.id, id12)).returning();
|
|
7528
7468
|
return this.decryptAccount(result[0] ?? null);
|
|
7529
7469
|
}
|
|
@@ -7586,13 +7526,11 @@ var init_auth_metadata_repository = __esm({
|
|
|
7586
7526
|
async set(key, value) {
|
|
7587
7527
|
await this.db.insert(authMetadata).values({
|
|
7588
7528
|
key,
|
|
7589
|
-
value
|
|
7590
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
7529
|
+
value
|
|
7591
7530
|
}).onConflictDoUpdate({
|
|
7592
7531
|
target: authMetadata.key,
|
|
7593
7532
|
set: {
|
|
7594
|
-
value
|
|
7595
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
7533
|
+
value
|
|
7596
7534
|
}
|
|
7597
7535
|
});
|
|
7598
7536
|
}
|
|
@@ -7664,11 +7602,7 @@ var init_account_deletion_requests_repository = __esm({
|
|
|
7664
7602
|
* Write primary 사용
|
|
7665
7603
|
*/
|
|
7666
7604
|
async create(data) {
|
|
7667
|
-
return await this._create(accountDeletionRequests,
|
|
7668
|
-
...data,
|
|
7669
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
7670
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
7671
|
-
});
|
|
7605
|
+
return await this._create(accountDeletionRequests, data);
|
|
7672
7606
|
}
|
|
7673
7607
|
/**
|
|
7674
7608
|
* 요청 취소 (복구)
|
|
@@ -7681,8 +7615,7 @@ var init_account_deletion_requests_repository = __esm({
|
|
|
7681
7615
|
async markCancelled(id12) {
|
|
7682
7616
|
const result = await this.db.update(accountDeletionRequests).set({
|
|
7683
7617
|
status: "cancelled",
|
|
7684
|
-
cancelledAt: /* @__PURE__ */ new Date()
|
|
7685
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
7618
|
+
cancelledAt: /* @__PURE__ */ new Date()
|
|
7686
7619
|
}).where(
|
|
7687
7620
|
and8(
|
|
7688
7621
|
eq12(accountDeletionRequests.id, id12),
|
|
@@ -7705,8 +7638,7 @@ var init_account_deletion_requests_repository = __esm({
|
|
|
7705
7638
|
const result = await this.db.update(accountDeletionRequests).set({
|
|
7706
7639
|
status: "completed",
|
|
7707
7640
|
completedAt: /* @__PURE__ */ new Date(),
|
|
7708
|
-
purgeStrategy
|
|
7709
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
7641
|
+
purgeStrategy
|
|
7710
7642
|
}).where(
|
|
7711
7643
|
and8(
|
|
7712
7644
|
eq12(accountDeletionRequests.id, id12),
|
|
@@ -8371,7 +8303,6 @@ async function registerPublicKeyService(params) {
|
|
|
8371
8303
|
deviceName,
|
|
8372
8304
|
platform,
|
|
8373
8305
|
isActive: true,
|
|
8374
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
8375
8306
|
expiresAt: getKeyExpiryDate()
|
|
8376
8307
|
});
|
|
8377
8308
|
}
|
|
@@ -8396,7 +8327,6 @@ async function rotateKeyService(params) {
|
|
|
8396
8327
|
deviceName: params.deviceName ?? replaced?.deviceName ?? void 0,
|
|
8397
8328
|
platform: params.platform ?? replaced?.platform ?? void 0,
|
|
8398
8329
|
isActive: true,
|
|
8399
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
8400
8330
|
expiresAt: getKeyExpiryDate()
|
|
8401
8331
|
});
|
|
8402
8332
|
return {
|