autosync_backend2 1.2.104 → 1.2.105

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/index.js CHANGED
@@ -155020,12 +155020,12 @@ var require_sign2 = __commonJS((exports, module) => {
155020
155020
  exp: { isValid: isNumber2, message: '"exp" should be a number of seconds' },
155021
155021
  nbf: { isValid: isNumber2, message: '"nbf" should be a number of seconds' }
155022
155022
  };
155023
- function validate3(schema4, allowUnknown, object2, parameterName) {
155023
+ function validate3(schema5, allowUnknown, object2, parameterName) {
155024
155024
  if (!isPlainObject6(object2)) {
155025
155025
  throw new Error('Expected "' + parameterName + '" to be a plain object.');
155026
155026
  }
155027
155027
  Object.keys(object2).forEach(function(key) {
155028
- const validator = schema4[key];
155028
+ const validator = schema5[key];
155029
155029
  if (!validator) {
155030
155030
  if (!allowUnknown) {
155031
155031
  throw new Error('"' + key + '" is not allowed in "' + parameterName + '"');
@@ -285190,6 +285190,7 @@ var bigint = /^-?\d+n?$/;
285190
285190
  var integer = /^-?\d+$/;
285191
285191
  var number = /^-?\d+(?:\.\d+)?/;
285192
285192
  var boolean = /^(?:true|false)$/i;
285193
+ var _undefined = /^undefined$/i;
285193
285194
  var lowercase2 = /^[^A-Z]*$/;
285194
285195
  var uppercase2 = /^[^a-z]*$/;
285195
285196
 
@@ -286099,6 +286100,25 @@ var $ZodBigInt = /* @__PURE__ */ $constructor3("$ZodBigInt", (inst, def) => {
286099
286100
  return payload;
286100
286101
  };
286101
286102
  });
286103
+ var $ZodUndefined = /* @__PURE__ */ $constructor3("$ZodUndefined", (inst, def) => {
286104
+ $ZodType3.init(inst, def);
286105
+ inst._zod.pattern = _undefined;
286106
+ inst._zod.values = new Set([undefined]);
286107
+ inst._zod.optin = "optional";
286108
+ inst._zod.optout = "optional";
286109
+ inst._zod.parse = (payload, _ctx) => {
286110
+ const input = payload.value;
286111
+ if (typeof input === "undefined")
286112
+ return payload;
286113
+ payload.issues.push({
286114
+ expected: "undefined",
286115
+ code: "invalid_type",
286116
+ input,
286117
+ inst
286118
+ });
286119
+ return payload;
286120
+ };
286121
+ });
286102
286122
  var $ZodAny = /* @__PURE__ */ $constructor3("$ZodAny", (inst, def) => {
286103
286123
  $ZodType3.init(inst, def);
286104
286124
  inst._zod.parse = (payload) => payload;
@@ -287348,6 +287368,12 @@ function _coercedBigint(Class4, params) {
287348
287368
  ...normalizeParams3(params)
287349
287369
  });
287350
287370
  }
287371
+ function _undefined2(Class4, params) {
287372
+ return new Class4({
287373
+ type: "undefined",
287374
+ ...normalizeParams3(params)
287375
+ });
287376
+ }
287351
287377
  function _any(Class4) {
287352
287378
  return new Class4({
287353
287379
  type: "any"
@@ -287910,6 +287936,13 @@ var ZodBigInt = /* @__PURE__ */ $constructor3("ZodBigInt", (inst, def) => {
287910
287936
  inst.maxValue = bag.maximum ?? null;
287911
287937
  inst.format = bag.format ?? null;
287912
287938
  });
287939
+ var ZodUndefined = /* @__PURE__ */ $constructor3("ZodUndefined", (inst, def) => {
287940
+ $ZodUndefined.init(inst, def);
287941
+ ZodType3.init(inst, def);
287942
+ });
287943
+ function _undefined3(params) {
287944
+ return _undefined2(ZodUndefined, params);
287945
+ }
287913
287946
  var ZodAny = /* @__PURE__ */ $constructor3("ZodAny", (inst, def) => {
287914
287947
  $ZodAny.init(inst, def);
287915
287948
  ZodType3.init(inst, def);
@@ -293833,6 +293866,25 @@ function parseUserInput(options, user, action) {
293833
293866
  const schema = getAllFields(options, "user");
293834
293867
  return parseInputData(user || {}, { fields: schema, action });
293835
293868
  }
293869
+ function mergeSchema(schema, newSchema) {
293870
+ if (!newSchema) {
293871
+ return schema;
293872
+ }
293873
+ for (const table in newSchema) {
293874
+ const newModelName = newSchema[table]?.modelName;
293875
+ if (newModelName) {
293876
+ schema[table].modelName = newModelName;
293877
+ }
293878
+ for (const field in schema[table].fields) {
293879
+ const newField = newSchema[table]?.fields?.[field];
293880
+ if (!newField) {
293881
+ continue;
293882
+ }
293883
+ schema[table].fields[field].fieldName = newField;
293884
+ }
293885
+ }
293886
+ return schema;
293887
+ }
293836
293888
 
293837
293889
  // node_modules/defu/dist/defu.mjs
293838
293890
  function isPlainObject4(value) {
@@ -307567,6 +307619,24 @@ var bearer = (options) => {
307567
307619
  }
307568
307620
  };
307569
307621
  };
307622
+ // node_modules/better-auth/dist/shared/better-auth.DQI8AD7d.mjs
307623
+ var getEndpointResponse = async (ctx) => {
307624
+ const returned = ctx.context.returned;
307625
+ if (!returned) {
307626
+ return null;
307627
+ }
307628
+ if (returned instanceof Response) {
307629
+ if (returned.status !== 200) {
307630
+ return null;
307631
+ }
307632
+ return await returned.clone().json();
307633
+ }
307634
+ if (returned instanceof APIError) {
307635
+ return null;
307636
+ }
307637
+ return returned;
307638
+ };
307639
+
307570
307640
  // node_modules/better-auth/dist/plugins/admin/access/index.mjs
307571
307641
  var defaultStatements2 = {
307572
307642
  user: [
@@ -307601,6 +307671,30 @@ var userAc = defaultAc2.newRole({
307601
307671
  user: [],
307602
307672
  session: []
307603
307673
  });
307674
+ var defaultRoles3 = {
307675
+ admin: adminAc2,
307676
+ user: userAc
307677
+ };
307678
+
307679
+ // node_modules/better-auth/dist/shared/better-auth.bkwPl2G4.mjs
307680
+ var hasPermission = (input) => {
307681
+ if (input.userId && input.options?.adminUserIds?.includes(input.userId)) {
307682
+ return true;
307683
+ }
307684
+ if (!input.permissions && !input.permission) {
307685
+ return false;
307686
+ }
307687
+ const roles = (input.role || input.options?.defaultRole || "user").split(",");
307688
+ const acRoles = input.options?.roles || defaultRoles3;
307689
+ for (const role3 of roles) {
307690
+ const _role = acRoles[role3];
307691
+ const result = _role?.authorize(input.permission ?? input.permissions);
307692
+ if (result?.success) {
307693
+ return true;
307694
+ }
307695
+ }
307696
+ return false;
307697
+ };
307604
307698
 
307605
307699
  // node_modules/better-auth/dist/shared/better-auth.BdecEc2O.mjs
307606
307700
  var ADMIN_ERROR_CODES = defineErrorCodes({
@@ -307623,6 +307717,1167 @@ var ADMIN_ERROR_CODES = defineErrorCodes({
307623
307717
  YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: "You are not allowed to update users",
307624
307718
  YOU_CANNOT_REMOVE_YOURSELF: "You cannot remove yourself"
307625
307719
  });
307720
+ var schema3 = {
307721
+ user: {
307722
+ fields: {
307723
+ role: {
307724
+ type: "string",
307725
+ required: false,
307726
+ input: false
307727
+ },
307728
+ banned: {
307729
+ type: "boolean",
307730
+ defaultValue: false,
307731
+ required: false,
307732
+ input: false
307733
+ },
307734
+ banReason: {
307735
+ type: "string",
307736
+ required: false,
307737
+ input: false
307738
+ },
307739
+ banExpires: {
307740
+ type: "date",
307741
+ required: false,
307742
+ input: false
307743
+ }
307744
+ }
307745
+ },
307746
+ session: {
307747
+ fields: {
307748
+ impersonatedBy: {
307749
+ type: "string",
307750
+ required: false
307751
+ }
307752
+ }
307753
+ }
307754
+ };
307755
+ function parseRoles(roles) {
307756
+ return Array.isArray(roles) ? roles.join(",") : roles;
307757
+ }
307758
+ var admin = (options) => {
307759
+ const opts = {
307760
+ defaultRole: options?.defaultRole ?? "user",
307761
+ adminRoles: options?.adminRoles ?? ["admin"],
307762
+ bannedUserMessage: options?.bannedUserMessage ?? "You have been banned from this application. Please contact support if you believe this is an error.",
307763
+ ...options
307764
+ };
307765
+ const adminMiddleware = createAuthMiddleware(async (ctx) => {
307766
+ const session = await getSessionFromCtx(ctx);
307767
+ if (!session) {
307768
+ throw new APIError("UNAUTHORIZED");
307769
+ }
307770
+ return {
307771
+ session
307772
+ };
307773
+ });
307774
+ return {
307775
+ id: "admin",
307776
+ init() {
307777
+ return {
307778
+ options: {
307779
+ databaseHooks: {
307780
+ user: {
307781
+ create: {
307782
+ async before(user) {
307783
+ return {
307784
+ data: {
307785
+ role: options?.defaultRole ?? "user",
307786
+ ...user
307787
+ }
307788
+ };
307789
+ }
307790
+ }
307791
+ },
307792
+ session: {
307793
+ create: {
307794
+ async before(session, ctx) {
307795
+ if (!ctx) {
307796
+ return;
307797
+ }
307798
+ const user = await ctx.context.internalAdapter.findUserById(session.userId);
307799
+ if (user.banned) {
307800
+ if (user.banExpires && new Date(user.banExpires).getTime() < Date.now()) {
307801
+ await ctx.context.internalAdapter.updateUser(session.userId, {
307802
+ banned: false,
307803
+ banReason: null,
307804
+ banExpires: null
307805
+ });
307806
+ return;
307807
+ }
307808
+ if (ctx && (ctx.path.startsWith("/callback") || ctx.path.startsWith("/oauth2/callback"))) {
307809
+ const redirectURI = ctx.context.options.onAPIError?.errorURL || `${ctx.context.baseURL}/error`;
307810
+ throw ctx.redirect(`${redirectURI}?error=banned&error_description=${opts.bannedUserMessage}`);
307811
+ }
307812
+ throw new APIError("FORBIDDEN", {
307813
+ message: opts.bannedUserMessage,
307814
+ code: "BANNED_USER"
307815
+ });
307816
+ }
307817
+ }
307818
+ }
307819
+ }
307820
+ }
307821
+ }
307822
+ };
307823
+ },
307824
+ hooks: {
307825
+ after: [
307826
+ {
307827
+ matcher(context) {
307828
+ return context.path === "/list-sessions";
307829
+ },
307830
+ handler: createAuthMiddleware(async (ctx) => {
307831
+ const response = await getEndpointResponse(ctx);
307832
+ if (!response) {
307833
+ return;
307834
+ }
307835
+ const newJson = response.filter((session) => {
307836
+ return !session.impersonatedBy;
307837
+ });
307838
+ return ctx.json(newJson);
307839
+ })
307840
+ }
307841
+ ]
307842
+ },
307843
+ endpoints: {
307844
+ setRole: createAuthEndpoint("/admin/set-role", {
307845
+ method: "POST",
307846
+ body: object({
307847
+ userId: exports_coerce.string().meta({
307848
+ description: "The user id"
307849
+ }),
307850
+ role: union3([
307851
+ string6().meta({
307852
+ description: "The role to set. `admin` or `user` by default"
307853
+ }),
307854
+ array3(string6().meta({
307855
+ description: "The roles to set. `admin` or `user` by default"
307856
+ }))
307857
+ ]).meta({
307858
+ description: "The role to set, this can be a string or an array of strings. Eg: `admin` or `[admin, user]`"
307859
+ })
307860
+ }),
307861
+ requireHeaders: true,
307862
+ use: [adminMiddleware],
307863
+ metadata: {
307864
+ openapi: {
307865
+ operationId: "setRole",
307866
+ summary: "Set the role of a user",
307867
+ description: "Set the role of a user",
307868
+ responses: {
307869
+ 200: {
307870
+ description: "User role updated",
307871
+ content: {
307872
+ "application/json": {
307873
+ schema: {
307874
+ type: "object",
307875
+ properties: {
307876
+ user: {
307877
+ $ref: "#/components/schemas/User"
307878
+ }
307879
+ }
307880
+ }
307881
+ }
307882
+ }
307883
+ }
307884
+ }
307885
+ },
307886
+ $Infer: {
307887
+ body: {}
307888
+ }
307889
+ }
307890
+ }, async (ctx) => {
307891
+ const canSetRole = hasPermission({
307892
+ userId: ctx.context.session.user.id,
307893
+ role: ctx.context.session.user.role,
307894
+ options: opts,
307895
+ permissions: {
307896
+ user: ["set-role"]
307897
+ }
307898
+ });
307899
+ if (!canSetRole) {
307900
+ throw new APIError("FORBIDDEN", {
307901
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE
307902
+ });
307903
+ }
307904
+ const updatedUser = await ctx.context.internalAdapter.updateUser(ctx.body.userId, {
307905
+ role: parseRoles(ctx.body.role)
307906
+ }, ctx);
307907
+ return ctx.json({
307908
+ user: updatedUser
307909
+ });
307910
+ }),
307911
+ getUser: createAuthEndpoint("/admin/get-user", {
307912
+ method: "GET",
307913
+ query: object({
307914
+ id: string6().meta({
307915
+ description: "The id of the User"
307916
+ })
307917
+ }),
307918
+ use: [adminMiddleware],
307919
+ metadata: {
307920
+ openapi: {
307921
+ operationId: "getUser",
307922
+ summary: "Get an existing user",
307923
+ description: "Get an existing user",
307924
+ responses: {
307925
+ 200: {
307926
+ description: "User",
307927
+ content: {
307928
+ "application/json": {
307929
+ schema: {
307930
+ type: "object",
307931
+ properties: {
307932
+ user: {
307933
+ $ref: "#/components/schemas/User"
307934
+ }
307935
+ }
307936
+ }
307937
+ }
307938
+ }
307939
+ }
307940
+ }
307941
+ }
307942
+ }
307943
+ }, async (ctx) => {
307944
+ const { id } = ctx.query;
307945
+ const canGetUser = hasPermission({
307946
+ userId: ctx.context.session.user.id,
307947
+ role: ctx.context.session.user.role,
307948
+ options: opts,
307949
+ permissions: {
307950
+ user: ["get"]
307951
+ }
307952
+ });
307953
+ if (!canGetUser) {
307954
+ throw ctx.error("FORBIDDEN", {
307955
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_GET_USER,
307956
+ code: "YOU_ARE_NOT_ALLOWED_TO_GET_USER"
307957
+ });
307958
+ }
307959
+ const user = await ctx.context.internalAdapter.findUserById(id);
307960
+ if (!user) {
307961
+ throw new APIError("NOT_FOUND", {
307962
+ message: BASE_ERROR_CODES.USER_NOT_FOUND
307963
+ });
307964
+ }
307965
+ return parseUserOutput(ctx.context.options, user);
307966
+ }),
307967
+ createUser: createAuthEndpoint("/admin/create-user", {
307968
+ method: "POST",
307969
+ body: object({
307970
+ email: string6().meta({
307971
+ description: "The email of the user"
307972
+ }),
307973
+ password: string6().meta({
307974
+ description: "The password of the user"
307975
+ }),
307976
+ name: string6().meta({
307977
+ description: "The name of the user"
307978
+ }),
307979
+ role: union3([
307980
+ string6().meta({
307981
+ description: "The role of the user"
307982
+ }),
307983
+ array3(string6().meta({
307984
+ description: "The roles of user"
307985
+ }))
307986
+ ]).optional().meta({
307987
+ description: `A string or array of strings representing the roles to apply to the new user. Eg: "user"`
307988
+ }),
307989
+ data: record(string6(), any()).optional().meta({
307990
+ description: "Extra fields for the user. Including custom additional fields."
307991
+ })
307992
+ }),
307993
+ metadata: {
307994
+ openapi: {
307995
+ operationId: "createUser",
307996
+ summary: "Create a new user",
307997
+ description: "Create a new user",
307998
+ responses: {
307999
+ 200: {
308000
+ description: "User created",
308001
+ content: {
308002
+ "application/json": {
308003
+ schema: {
308004
+ type: "object",
308005
+ properties: {
308006
+ user: {
308007
+ $ref: "#/components/schemas/User"
308008
+ }
308009
+ }
308010
+ }
308011
+ }
308012
+ }
308013
+ }
308014
+ }
308015
+ },
308016
+ $Infer: {
308017
+ body: {}
308018
+ }
308019
+ }
308020
+ }, async (ctx) => {
308021
+ const session = await getSessionFromCtx(ctx);
308022
+ if (!session && (ctx.request || ctx.headers)) {
308023
+ throw ctx.error("UNAUTHORIZED");
308024
+ }
308025
+ if (session) {
308026
+ const canCreateUser = hasPermission({
308027
+ userId: session.user.id,
308028
+ role: session.user.role,
308029
+ options: opts,
308030
+ permissions: {
308031
+ user: ["create"]
308032
+ }
308033
+ });
308034
+ if (!canCreateUser) {
308035
+ throw new APIError("FORBIDDEN", {
308036
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS
308037
+ });
308038
+ }
308039
+ }
308040
+ const existUser = await ctx.context.internalAdapter.findUserByEmail(ctx.body.email);
308041
+ if (existUser) {
308042
+ throw new APIError("BAD_REQUEST", {
308043
+ message: ADMIN_ERROR_CODES.USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL
308044
+ });
308045
+ }
308046
+ const user = await ctx.context.internalAdapter.createUser({
308047
+ email: ctx.body.email,
308048
+ name: ctx.body.name,
308049
+ role: (ctx.body.role && parseRoles(ctx.body.role)) ?? options?.defaultRole ?? "user",
308050
+ ...ctx.body.data
308051
+ }, ctx);
308052
+ if (!user) {
308053
+ throw new APIError("INTERNAL_SERVER_ERROR", {
308054
+ message: ADMIN_ERROR_CODES.FAILED_TO_CREATE_USER
308055
+ });
308056
+ }
308057
+ const hashedPassword = await ctx.context.password.hash(ctx.body.password);
308058
+ await ctx.context.internalAdapter.linkAccount({
308059
+ accountId: user.id,
308060
+ providerId: "credential",
308061
+ password: hashedPassword,
308062
+ userId: user.id
308063
+ }, ctx);
308064
+ return ctx.json({
308065
+ user
308066
+ });
308067
+ }),
308068
+ adminUpdateUser: createAuthEndpoint("/admin/update-user", {
308069
+ method: "POST",
308070
+ body: object({
308071
+ userId: exports_coerce.string().meta({
308072
+ description: "The user id"
308073
+ }),
308074
+ data: record(any(), any()).meta({
308075
+ description: "The user data to update"
308076
+ })
308077
+ }),
308078
+ use: [adminMiddleware],
308079
+ metadata: {
308080
+ openapi: {
308081
+ operationId: "updateUser",
308082
+ summary: "Update a user",
308083
+ description: "Update a user's details",
308084
+ responses: {
308085
+ 200: {
308086
+ description: "User updated",
308087
+ content: {
308088
+ "application/json": {
308089
+ schema: {
308090
+ type: "object",
308091
+ properties: {
308092
+ user: {
308093
+ $ref: "#/components/schemas/User"
308094
+ }
308095
+ }
308096
+ }
308097
+ }
308098
+ }
308099
+ }
308100
+ }
308101
+ }
308102
+ }
308103
+ }, async (ctx) => {
308104
+ const canUpdateUser = hasPermission({
308105
+ userId: ctx.context.session.user.id,
308106
+ role: ctx.context.session.user.role,
308107
+ options: opts,
308108
+ permissions: {
308109
+ user: ["update"]
308110
+ }
308111
+ });
308112
+ if (!canUpdateUser) {
308113
+ throw ctx.error("FORBIDDEN", {
308114
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS,
308115
+ code: "YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS"
308116
+ });
308117
+ }
308118
+ if (Object.keys(ctx.body.data).length === 0) {
308119
+ throw new APIError("BAD_REQUEST", {
308120
+ message: ADMIN_ERROR_CODES.NO_DATA_TO_UPDATE
308121
+ });
308122
+ }
308123
+ if (ctx.body.data?.role) {
308124
+ ctx.body.data.role = parseRoles(ctx.body.data.role);
308125
+ }
308126
+ const updatedUser = await ctx.context.internalAdapter.updateUser(ctx.body.userId, ctx.body.data, ctx);
308127
+ return ctx.json(updatedUser);
308128
+ }),
308129
+ listUsers: createAuthEndpoint("/admin/list-users", {
308130
+ method: "GET",
308131
+ use: [adminMiddleware],
308132
+ query: object({
308133
+ searchValue: string6().optional().meta({
308134
+ description: 'The value to search for. Eg: "some name"'
308135
+ }),
308136
+ searchField: _enum2(["email", "name"]).meta({
308137
+ description: 'The field to search in, defaults to email. Can be `email` or `name`. Eg: "name"'
308138
+ }).optional(),
308139
+ searchOperator: _enum2(["contains", "starts_with", "ends_with"]).meta({
308140
+ description: 'The operator to use for the search. Can be `contains`, `starts_with` or `ends_with`. Eg: "contains"'
308141
+ }).optional(),
308142
+ limit: string6().meta({
308143
+ description: "The number of users to return"
308144
+ }).or(number2()).optional(),
308145
+ offset: string6().meta({
308146
+ description: "The offset to start from"
308147
+ }).or(number2()).optional(),
308148
+ sortBy: string6().meta({
308149
+ description: "The field to sort by"
308150
+ }).optional(),
308151
+ sortDirection: _enum2(["asc", "desc"]).meta({
308152
+ description: "The direction to sort by"
308153
+ }).optional(),
308154
+ filterField: string6().meta({
308155
+ description: "The field to filter by"
308156
+ }).optional(),
308157
+ filterValue: string6().meta({
308158
+ description: "The value to filter by"
308159
+ }).or(number2()).or(boolean2()).optional(),
308160
+ filterOperator: _enum2(["eq", "ne", "lt", "lte", "gt", "gte", "contains"]).meta({
308161
+ description: "The operator to use for the filter"
308162
+ }).optional()
308163
+ }),
308164
+ metadata: {
308165
+ openapi: {
308166
+ operationId: "listUsers",
308167
+ summary: "List users",
308168
+ description: "List users",
308169
+ responses: {
308170
+ 200: {
308171
+ description: "List of users",
308172
+ content: {
308173
+ "application/json": {
308174
+ schema: {
308175
+ type: "object",
308176
+ properties: {
308177
+ users: {
308178
+ type: "array",
308179
+ items: {
308180
+ $ref: "#/components/schemas/User"
308181
+ }
308182
+ },
308183
+ total: {
308184
+ type: "number"
308185
+ },
308186
+ limit: {
308187
+ type: "number"
308188
+ },
308189
+ offset: {
308190
+ type: "number"
308191
+ }
308192
+ },
308193
+ required: ["users", "total"]
308194
+ }
308195
+ }
308196
+ }
308197
+ }
308198
+ }
308199
+ }
308200
+ }
308201
+ }, async (ctx) => {
308202
+ const session = ctx.context.session;
308203
+ const canListUsers = hasPermission({
308204
+ userId: ctx.context.session.user.id,
308205
+ role: session.user.role,
308206
+ options: opts,
308207
+ permissions: {
308208
+ user: ["list"]
308209
+ }
308210
+ });
308211
+ if (!canListUsers) {
308212
+ throw new APIError("FORBIDDEN", {
308213
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_LIST_USERS
308214
+ });
308215
+ }
308216
+ const where = [];
308217
+ if (ctx.query?.searchValue) {
308218
+ where.push({
308219
+ field: ctx.query.searchField || "email",
308220
+ operator: ctx.query.searchOperator || "contains",
308221
+ value: ctx.query.searchValue
308222
+ });
308223
+ }
308224
+ if (ctx.query?.filterValue) {
308225
+ where.push({
308226
+ field: ctx.query.filterField || "email",
308227
+ operator: ctx.query.filterOperator || "eq",
308228
+ value: ctx.query.filterValue
308229
+ });
308230
+ }
308231
+ try {
308232
+ const users = await ctx.context.internalAdapter.listUsers(Number(ctx.query?.limit) || undefined, Number(ctx.query?.offset) || undefined, ctx.query?.sortBy ? {
308233
+ field: ctx.query.sortBy,
308234
+ direction: ctx.query.sortDirection || "asc"
308235
+ } : undefined, where.length ? where : undefined);
308236
+ const total = await ctx.context.internalAdapter.countTotalUsers(where.length ? where : undefined);
308237
+ return ctx.json({
308238
+ users,
308239
+ total,
308240
+ limit: Number(ctx.query?.limit) || undefined,
308241
+ offset: Number(ctx.query?.offset) || undefined
308242
+ });
308243
+ } catch (e) {
308244
+ return ctx.json({
308245
+ users: [],
308246
+ total: 0
308247
+ });
308248
+ }
308249
+ }),
308250
+ listUserSessions: createAuthEndpoint("/admin/list-user-sessions", {
308251
+ method: "POST",
308252
+ use: [adminMiddleware],
308253
+ body: object({
308254
+ userId: exports_coerce.string().meta({
308255
+ description: "The user id"
308256
+ })
308257
+ }),
308258
+ metadata: {
308259
+ openapi: {
308260
+ operationId: "listUserSessions",
308261
+ summary: "List user sessions",
308262
+ description: "List user sessions",
308263
+ responses: {
308264
+ 200: {
308265
+ description: "List of user sessions",
308266
+ content: {
308267
+ "application/json": {
308268
+ schema: {
308269
+ type: "object",
308270
+ properties: {
308271
+ sessions: {
308272
+ type: "array",
308273
+ items: {
308274
+ $ref: "#/components/schemas/Session"
308275
+ }
308276
+ }
308277
+ }
308278
+ }
308279
+ }
308280
+ }
308281
+ }
308282
+ }
308283
+ }
308284
+ }
308285
+ }, async (ctx) => {
308286
+ const session = ctx.context.session;
308287
+ const canListSessions = hasPermission({
308288
+ userId: ctx.context.session.user.id,
308289
+ role: session.user.role,
308290
+ options: opts,
308291
+ permissions: {
308292
+ session: ["list"]
308293
+ }
308294
+ });
308295
+ if (!canListSessions) {
308296
+ throw new APIError("FORBIDDEN", {
308297
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS
308298
+ });
308299
+ }
308300
+ const sessions = await ctx.context.internalAdapter.listSessions(ctx.body.userId);
308301
+ return {
308302
+ sessions
308303
+ };
308304
+ }),
308305
+ unbanUser: createAuthEndpoint("/admin/unban-user", {
308306
+ method: "POST",
308307
+ body: object({
308308
+ userId: exports_coerce.string().meta({
308309
+ description: "The user id"
308310
+ })
308311
+ }),
308312
+ use: [adminMiddleware],
308313
+ metadata: {
308314
+ openapi: {
308315
+ operationId: "unbanUser",
308316
+ summary: "Unban a user",
308317
+ description: "Unban a user",
308318
+ responses: {
308319
+ 200: {
308320
+ description: "User unbanned",
308321
+ content: {
308322
+ "application/json": {
308323
+ schema: {
308324
+ type: "object",
308325
+ properties: {
308326
+ user: {
308327
+ $ref: "#/components/schemas/User"
308328
+ }
308329
+ }
308330
+ }
308331
+ }
308332
+ }
308333
+ }
308334
+ }
308335
+ }
308336
+ }
308337
+ }, async (ctx) => {
308338
+ const session = ctx.context.session;
308339
+ const canBanUser = hasPermission({
308340
+ userId: ctx.context.session.user.id,
308341
+ role: session.user.role,
308342
+ options: opts,
308343
+ permissions: {
308344
+ user: ["ban"]
308345
+ }
308346
+ });
308347
+ if (!canBanUser) {
308348
+ throw new APIError("FORBIDDEN", {
308349
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_BAN_USERS
308350
+ });
308351
+ }
308352
+ const user = await ctx.context.internalAdapter.updateUser(ctx.body.userId, {
308353
+ banned: false,
308354
+ banExpires: null,
308355
+ banReason: null,
308356
+ updatedAt: /* @__PURE__ */ new Date
308357
+ });
308358
+ return ctx.json({
308359
+ user
308360
+ });
308361
+ }),
308362
+ banUser: createAuthEndpoint("/admin/ban-user", {
308363
+ method: "POST",
308364
+ body: object({
308365
+ userId: exports_coerce.string().meta({
308366
+ description: "The user id"
308367
+ }),
308368
+ banReason: string6().meta({
308369
+ description: "The reason for the ban"
308370
+ }).optional(),
308371
+ banExpiresIn: number2().meta({
308372
+ description: "The number of seconds until the ban expires"
308373
+ }).optional()
308374
+ }),
308375
+ use: [adminMiddleware],
308376
+ metadata: {
308377
+ openapi: {
308378
+ operationId: "banUser",
308379
+ summary: "Ban a user",
308380
+ description: "Ban a user",
308381
+ responses: {
308382
+ 200: {
308383
+ description: "User banned",
308384
+ content: {
308385
+ "application/json": {
308386
+ schema: {
308387
+ type: "object",
308388
+ properties: {
308389
+ user: {
308390
+ $ref: "#/components/schemas/User"
308391
+ }
308392
+ }
308393
+ }
308394
+ }
308395
+ }
308396
+ }
308397
+ }
308398
+ }
308399
+ }
308400
+ }, async (ctx) => {
308401
+ const session = ctx.context.session;
308402
+ const canBanUser = hasPermission({
308403
+ userId: ctx.context.session.user.id,
308404
+ role: session.user.role,
308405
+ options: opts,
308406
+ permissions: {
308407
+ user: ["ban"]
308408
+ }
308409
+ });
308410
+ if (!canBanUser) {
308411
+ throw new APIError("FORBIDDEN", {
308412
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_BAN_USERS
308413
+ });
308414
+ }
308415
+ const foundUser = await ctx.context.internalAdapter.findUserById(ctx.body.userId);
308416
+ if (!foundUser) {
308417
+ throw new APIError("NOT_FOUND", {
308418
+ message: BASE_ERROR_CODES.USER_NOT_FOUND
308419
+ });
308420
+ }
308421
+ if (ctx.body.userId === ctx.context.session.user.id) {
308422
+ throw new APIError("BAD_REQUEST", {
308423
+ message: ADMIN_ERROR_CODES.YOU_CANNOT_BAN_YOURSELF
308424
+ });
308425
+ }
308426
+ const user = await ctx.context.internalAdapter.updateUser(ctx.body.userId, {
308427
+ banned: true,
308428
+ banReason: ctx.body.banReason || options?.defaultBanReason || "No reason",
308429
+ banExpires: ctx.body.banExpiresIn ? getDate(ctx.body.banExpiresIn, "sec") : options?.defaultBanExpiresIn ? getDate(options.defaultBanExpiresIn, "sec") : undefined,
308430
+ updatedAt: /* @__PURE__ */ new Date
308431
+ }, ctx);
308432
+ await ctx.context.internalAdapter.deleteSessions(ctx.body.userId);
308433
+ return ctx.json({
308434
+ user
308435
+ });
308436
+ }),
308437
+ impersonateUser: createAuthEndpoint("/admin/impersonate-user", {
308438
+ method: "POST",
308439
+ body: object({
308440
+ userId: exports_coerce.string().meta({
308441
+ description: "The user id"
308442
+ })
308443
+ }),
308444
+ use: [adminMiddleware],
308445
+ metadata: {
308446
+ openapi: {
308447
+ operationId: "impersonateUser",
308448
+ summary: "Impersonate a user",
308449
+ description: "Impersonate a user",
308450
+ responses: {
308451
+ 200: {
308452
+ description: "Impersonation session created",
308453
+ content: {
308454
+ "application/json": {
308455
+ schema: {
308456
+ type: "object",
308457
+ properties: {
308458
+ session: {
308459
+ $ref: "#/components/schemas/Session"
308460
+ },
308461
+ user: {
308462
+ $ref: "#/components/schemas/User"
308463
+ }
308464
+ }
308465
+ }
308466
+ }
308467
+ }
308468
+ }
308469
+ }
308470
+ }
308471
+ }
308472
+ }, async (ctx) => {
308473
+ const canImpersonateUser = hasPermission({
308474
+ userId: ctx.context.session.user.id,
308475
+ role: ctx.context.session.user.role,
308476
+ options: opts,
308477
+ permissions: {
308478
+ user: ["impersonate"]
308479
+ }
308480
+ });
308481
+ if (!canImpersonateUser) {
308482
+ throw new APIError("FORBIDDEN", {
308483
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS
308484
+ });
308485
+ }
308486
+ const targetUser = await ctx.context.internalAdapter.findUserById(ctx.body.userId);
308487
+ if (!targetUser) {
308488
+ throw new APIError("NOT_FOUND", {
308489
+ message: "User not found"
308490
+ });
308491
+ }
308492
+ const session = await ctx.context.internalAdapter.createSession(targetUser.id, ctx, true, {
308493
+ impersonatedBy: ctx.context.session.user.id,
308494
+ expiresAt: options?.impersonationSessionDuration ? getDate(options.impersonationSessionDuration, "sec") : getDate(60 * 60, "sec")
308495
+ }, true);
308496
+ if (!session) {
308497
+ throw new APIError("INTERNAL_SERVER_ERROR", {
308498
+ message: ADMIN_ERROR_CODES.FAILED_TO_CREATE_USER
308499
+ });
308500
+ }
308501
+ const authCookies = ctx.context.authCookies;
308502
+ deleteSessionCookie(ctx);
308503
+ const dontRememberMeCookie = await ctx.getSignedCookie(ctx.context.authCookies.dontRememberToken.name, ctx.context.secret);
308504
+ const adminCookieProp = ctx.context.createAuthCookie("admin_session");
308505
+ await ctx.setSignedCookie(adminCookieProp.name, `${ctx.context.session.session.token}:${dontRememberMeCookie || ""}`, ctx.context.secret, authCookies.sessionToken.options);
308506
+ await setSessionCookie(ctx, {
308507
+ session,
308508
+ user: targetUser
308509
+ }, true);
308510
+ return ctx.json({
308511
+ session,
308512
+ user: targetUser
308513
+ });
308514
+ }),
308515
+ stopImpersonating: createAuthEndpoint("/admin/stop-impersonating", {
308516
+ method: "POST",
308517
+ requireHeaders: true
308518
+ }, async (ctx) => {
308519
+ const session = await getSessionFromCtx(ctx);
308520
+ if (!session) {
308521
+ throw new APIError("UNAUTHORIZED");
308522
+ }
308523
+ if (!session.session.impersonatedBy) {
308524
+ throw new APIError("BAD_REQUEST", {
308525
+ message: "You are not impersonating anyone"
308526
+ });
308527
+ }
308528
+ const user = await ctx.context.internalAdapter.findUserById(session.session.impersonatedBy);
308529
+ if (!user) {
308530
+ throw new APIError("INTERNAL_SERVER_ERROR", {
308531
+ message: "Failed to find user"
308532
+ });
308533
+ }
308534
+ const adminCookieName = ctx.context.createAuthCookie("admin_session").name;
308535
+ const adminCookie = await ctx.getSignedCookie(adminCookieName, ctx.context.secret);
308536
+ if (!adminCookie) {
308537
+ throw new APIError("INTERNAL_SERVER_ERROR", {
308538
+ message: "Failed to find admin session"
308539
+ });
308540
+ }
308541
+ const [adminSessionToken, dontRememberMeCookie] = adminCookie?.split(":");
308542
+ const adminSession = await ctx.context.internalAdapter.findSession(adminSessionToken);
308543
+ if (!adminSession || adminSession.session.userId !== user.id) {
308544
+ throw new APIError("INTERNAL_SERVER_ERROR", {
308545
+ message: "Failed to find admin session"
308546
+ });
308547
+ }
308548
+ await ctx.context.internalAdapter.deleteSession(session.session.token);
308549
+ await setSessionCookie(ctx, adminSession, !!dontRememberMeCookie);
308550
+ return ctx.json(adminSession);
308551
+ }),
308552
+ revokeUserSession: createAuthEndpoint("/admin/revoke-user-session", {
308553
+ method: "POST",
308554
+ body: object({
308555
+ sessionToken: string6().meta({
308556
+ description: "The session token"
308557
+ })
308558
+ }),
308559
+ use: [adminMiddleware],
308560
+ metadata: {
308561
+ openapi: {
308562
+ operationId: "revokeUserSession",
308563
+ summary: "Revoke a user session",
308564
+ description: "Revoke a user session",
308565
+ responses: {
308566
+ 200: {
308567
+ description: "Session revoked",
308568
+ content: {
308569
+ "application/json": {
308570
+ schema: {
308571
+ type: "object",
308572
+ properties: {
308573
+ success: {
308574
+ type: "boolean"
308575
+ }
308576
+ }
308577
+ }
308578
+ }
308579
+ }
308580
+ }
308581
+ }
308582
+ }
308583
+ }
308584
+ }, async (ctx) => {
308585
+ const session = ctx.context.session;
308586
+ const canRevokeSession = hasPermission({
308587
+ userId: ctx.context.session.user.id,
308588
+ role: session.user.role,
308589
+ options: opts,
308590
+ permissions: {
308591
+ session: ["revoke"]
308592
+ }
308593
+ });
308594
+ if (!canRevokeSession) {
308595
+ throw new APIError("FORBIDDEN", {
308596
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS
308597
+ });
308598
+ }
308599
+ await ctx.context.internalAdapter.deleteSession(ctx.body.sessionToken);
308600
+ return ctx.json({
308601
+ success: true
308602
+ });
308603
+ }),
308604
+ revokeUserSessions: createAuthEndpoint("/admin/revoke-user-sessions", {
308605
+ method: "POST",
308606
+ body: object({
308607
+ userId: exports_coerce.string().meta({
308608
+ description: "The user id"
308609
+ })
308610
+ }),
308611
+ use: [adminMiddleware],
308612
+ metadata: {
308613
+ openapi: {
308614
+ operationId: "revokeUserSessions",
308615
+ summary: "Revoke all user sessions",
308616
+ description: "Revoke all user sessions",
308617
+ responses: {
308618
+ 200: {
308619
+ description: "Sessions revoked",
308620
+ content: {
308621
+ "application/json": {
308622
+ schema: {
308623
+ type: "object",
308624
+ properties: {
308625
+ success: {
308626
+ type: "boolean"
308627
+ }
308628
+ }
308629
+ }
308630
+ }
308631
+ }
308632
+ }
308633
+ }
308634
+ }
308635
+ }
308636
+ }, async (ctx) => {
308637
+ const session = ctx.context.session;
308638
+ const canRevokeSession = hasPermission({
308639
+ userId: ctx.context.session.user.id,
308640
+ role: session.user.role,
308641
+ options: opts,
308642
+ permissions: {
308643
+ session: ["revoke"]
308644
+ }
308645
+ });
308646
+ if (!canRevokeSession) {
308647
+ throw new APIError("FORBIDDEN", {
308648
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS
308649
+ });
308650
+ }
308651
+ await ctx.context.internalAdapter.deleteSessions(ctx.body.userId);
308652
+ return ctx.json({
308653
+ success: true
308654
+ });
308655
+ }),
308656
+ removeUser: createAuthEndpoint("/admin/remove-user", {
308657
+ method: "POST",
308658
+ body: object({
308659
+ userId: exports_coerce.string().meta({
308660
+ description: "The user id"
308661
+ })
308662
+ }),
308663
+ use: [adminMiddleware],
308664
+ metadata: {
308665
+ openapi: {
308666
+ operationId: "removeUser",
308667
+ summary: "Remove a user",
308668
+ description: "Delete a user and all their sessions and accounts. Cannot be undone.",
308669
+ responses: {
308670
+ 200: {
308671
+ description: "User removed",
308672
+ content: {
308673
+ "application/json": {
308674
+ schema: {
308675
+ type: "object",
308676
+ properties: {
308677
+ success: {
308678
+ type: "boolean"
308679
+ }
308680
+ }
308681
+ }
308682
+ }
308683
+ }
308684
+ }
308685
+ }
308686
+ }
308687
+ }
308688
+ }, async (ctx) => {
308689
+ const session = ctx.context.session;
308690
+ const canDeleteUser = hasPermission({
308691
+ userId: ctx.context.session.user.id,
308692
+ role: session.user.role,
308693
+ options: opts,
308694
+ permissions: {
308695
+ user: ["delete"]
308696
+ }
308697
+ });
308698
+ if (!canDeleteUser) {
308699
+ throw new APIError("FORBIDDEN", {
308700
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS
308701
+ });
308702
+ }
308703
+ if (ctx.body.userId === ctx.context.session.user.id) {
308704
+ throw new APIError("BAD_REQUEST", {
308705
+ message: ADMIN_ERROR_CODES.YOU_CANNOT_REMOVE_YOURSELF
308706
+ });
308707
+ }
308708
+ const user = await ctx.context.internalAdapter.findUserById(ctx.body.userId);
308709
+ if (!user) {
308710
+ throw new APIError("NOT_FOUND", {
308711
+ message: "User not found"
308712
+ });
308713
+ }
308714
+ await ctx.context.internalAdapter.deleteUser(ctx.body.userId);
308715
+ return ctx.json({
308716
+ success: true
308717
+ });
308718
+ }),
308719
+ setUserPassword: createAuthEndpoint("/admin/set-user-password", {
308720
+ method: "POST",
308721
+ body: object({
308722
+ newPassword: string6().meta({
308723
+ description: "The new password"
308724
+ }),
308725
+ userId: exports_coerce.string().meta({
308726
+ description: "The user id"
308727
+ })
308728
+ }),
308729
+ use: [adminMiddleware],
308730
+ metadata: {
308731
+ openapi: {
308732
+ operationId: "setUserPassword",
308733
+ summary: "Set a user's password",
308734
+ description: "Set a user's password",
308735
+ responses: {
308736
+ 200: {
308737
+ description: "Password set",
308738
+ content: {
308739
+ "application/json": {
308740
+ schema: {
308741
+ type: "object",
308742
+ properties: {
308743
+ status: {
308744
+ type: "boolean"
308745
+ }
308746
+ }
308747
+ }
308748
+ }
308749
+ }
308750
+ }
308751
+ }
308752
+ }
308753
+ }
308754
+ }, async (ctx) => {
308755
+ const canSetUserPassword = hasPermission({
308756
+ userId: ctx.context.session.user.id,
308757
+ role: ctx.context.session.user.role,
308758
+ options: opts,
308759
+ permissions: {
308760
+ user: ["set-password"]
308761
+ }
308762
+ });
308763
+ if (!canSetUserPassword) {
308764
+ throw new APIError("FORBIDDEN", {
308765
+ message: ADMIN_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD
308766
+ });
308767
+ }
308768
+ const hashedPassword = await ctx.context.password.hash(ctx.body.newPassword);
308769
+ await ctx.context.internalAdapter.updatePassword(ctx.body.userId, hashedPassword);
308770
+ return ctx.json({
308771
+ status: true
308772
+ });
308773
+ }),
308774
+ userHasPermission: createAuthEndpoint("/admin/has-permission", {
308775
+ method: "POST",
308776
+ body: object({
308777
+ userId: exports_coerce.string().optional().meta({
308778
+ description: `The user id. Eg: "user-id"`
308779
+ }),
308780
+ role: string6().optional().meta({
308781
+ description: `The role to check permission for. Eg: "admin"`
308782
+ })
308783
+ }).and(union3([
308784
+ object({
308785
+ permission: record(string6(), array3(string6())),
308786
+ permissions: _undefined3()
308787
+ }),
308788
+ object({
308789
+ permission: _undefined3(),
308790
+ permissions: record(string6(), array3(string6()))
308791
+ })
308792
+ ])),
308793
+ metadata: {
308794
+ openapi: {
308795
+ description: "Check if the user has permission",
308796
+ requestBody: {
308797
+ content: {
308798
+ "application/json": {
308799
+ schema: {
308800
+ type: "object",
308801
+ properties: {
308802
+ permission: {
308803
+ type: "object",
308804
+ description: "The permission to check",
308805
+ deprecated: true
308806
+ },
308807
+ permissions: {
308808
+ type: "object",
308809
+ description: "The permission to check"
308810
+ }
308811
+ },
308812
+ required: ["permissions"]
308813
+ }
308814
+ }
308815
+ }
308816
+ },
308817
+ responses: {
308818
+ "200": {
308819
+ description: "Success",
308820
+ content: {
308821
+ "application/json": {
308822
+ schema: {
308823
+ type: "object",
308824
+ properties: {
308825
+ error: {
308826
+ type: "string"
308827
+ },
308828
+ success: {
308829
+ type: "boolean"
308830
+ }
308831
+ },
308832
+ required: ["success"]
308833
+ }
308834
+ }
308835
+ }
308836
+ }
308837
+ }
308838
+ },
308839
+ $Infer: {
308840
+ body: {}
308841
+ }
308842
+ }
308843
+ }, async (ctx) => {
308844
+ if (!ctx.body?.permission && !ctx.body?.permissions) {
308845
+ throw new APIError("BAD_REQUEST", {
308846
+ message: "invalid permission check. no permission(s) were passed."
308847
+ });
308848
+ }
308849
+ const session = await getSessionFromCtx(ctx);
308850
+ if (!session && (ctx.request || ctx.headers)) {
308851
+ throw new APIError("UNAUTHORIZED");
308852
+ }
308853
+ if (!session && !ctx.body.userId && !ctx.body.role) {
308854
+ throw new APIError("BAD_REQUEST", {
308855
+ message: "user id or role is required"
308856
+ });
308857
+ }
308858
+ const user = session?.user || (ctx.body.role ? { id: ctx.body.userId || "", role: ctx.body.role } : null) || await ctx.context.internalAdapter.findUserById(ctx.body.userId);
308859
+ if (!user) {
308860
+ throw new APIError("BAD_REQUEST", {
308861
+ message: "user not found"
308862
+ });
308863
+ }
308864
+ const result = hasPermission({
308865
+ userId: user.id,
308866
+ role: user.role,
308867
+ options,
308868
+ permissions: ctx.body.permissions ?? ctx.body.permission
308869
+ });
308870
+ return ctx.json({
308871
+ error: null,
308872
+ success: result
308873
+ });
308874
+ })
308875
+ },
308876
+ $ERROR_CODES: ADMIN_ERROR_CODES,
308877
+ schema: mergeSchema(schema3, opts.schema),
308878
+ options
308879
+ };
308880
+ };
307626
308881
  // node_modules/better-auth/dist/shared/better-auth.DDuRjwGK.mjs
307627
308882
  var minute2 = 60;
307628
308883
  var hour2 = minute2 * 60;
@@ -307645,16 +308900,16 @@ function getTypeFromZodType2(zodType) {
307645
308900
  return allowedType.has(type) ? type : "string";
307646
308901
  }
307647
308902
  function getFieldSchema(field) {
307648
- const schema3 = {
308903
+ const schema4 = {
307649
308904
  type: field.type === "date" ? "string" : field.type
307650
308905
  };
307651
308906
  if (field.defaultValue !== undefined) {
307652
- schema3.default = typeof field.defaultValue === "function" ? "Generated at runtime" : field.defaultValue;
308907
+ schema4.default = typeof field.defaultValue === "function" ? "Generated at runtime" : field.defaultValue;
307653
308908
  }
307654
308909
  if (field.input === false) {
307655
- schema3.readOnly = true;
308910
+ schema4.readOnly = true;
307656
308911
  }
307657
- return schema3;
308912
+ return schema4;
307658
308913
  }
307659
308914
  function getParameters2(options) {
307660
308915
  const parameters = [];
@@ -308091,8 +309346,8 @@ var openAPI = (options) => {
308091
309346
  generateOpenAPISchema: createAuthEndpoint("/open-api/generate-schema", {
308092
309347
  method: "GET"
308093
309348
  }, async (ctx) => {
308094
- const schema3 = await generator2(ctx.context, ctx.context.options);
308095
- return ctx.json(schema3);
309349
+ const schema4 = await generator2(ctx.context, ctx.context.options);
309350
+ return ctx.json(schema4);
308096
309351
  }),
308097
309352
  openAPIReference: createAuthEndpoint(path, {
308098
309353
  method: "GET",
@@ -308103,8 +309358,8 @@ var openAPI = (options) => {
308103
309358
  if (options?.disableDefaultReference) {
308104
309359
  throw new APIError("NOT_FOUND");
308105
309360
  }
308106
- const schema3 = await generator2(ctx.context, ctx.context.options);
308107
- return new Response(getHTML2(schema3, options?.theme), {
309361
+ const schema4 = await generator2(ctx.context, ctx.context.options);
309362
+ return new Response(getHTML2(schema4, options?.theme), {
308108
309363
  headers: {
308109
309364
  "Content-Type": "text/html"
308110
309365
  }
@@ -308354,18 +309609,18 @@ class CasingCache {
308354
309609
  getColumnCasing(column) {
308355
309610
  if (!column.keyAsName)
308356
309611
  return column.name;
308357
- const schema4 = column.table[Table.Symbol.Schema] ?? "public";
309612
+ const schema5 = column.table[Table.Symbol.Schema] ?? "public";
308358
309613
  const tableName = column.table[Table.Symbol.OriginalName];
308359
- const key = `${schema4}.${tableName}.${column.name}`;
309614
+ const key = `${schema5}.${tableName}.${column.name}`;
308360
309615
  if (!this.cache[key]) {
308361
309616
  this.cacheTable(column.table);
308362
309617
  }
308363
309618
  return this.cache[key];
308364
309619
  }
308365
309620
  cacheTable(table) {
308366
- const schema4 = table[Table.Symbol.Schema] ?? "public";
309621
+ const schema5 = table[Table.Symbol.Schema] ?? "public";
308367
309622
  const tableName = table[Table.Symbol.OriginalName];
308368
- const tableKey = `${schema4}.${tableName}`;
309623
+ const tableKey = `${schema5}.${tableName}`;
308369
309624
  if (!this.cachedTables[tableKey]) {
308370
309625
  for (const column of Object.values(table[Table.Symbol.Columns])) {
308371
309626
  const columnKey = `${tableKey}.${column.name}`;
@@ -308748,7 +310003,7 @@ class PgDialect {
308748
310003
  }
308749
310004
  buildRelationalQueryWithoutPK({
308750
310005
  fullSchema,
308751
- schema: schema4,
310006
+ schema: schema5,
308752
310007
  tableNamesMap,
308753
310008
  table,
308754
310009
  tableConfig,
@@ -308842,17 +310097,17 @@ class PgDialect {
308842
310097
  queryConfig: selectedRelationConfigValue,
308843
310098
  relation
308844
310099
  } of selectedRelations) {
308845
- const normalizedRelation = normalizeRelation(schema4, tableNamesMap, relation);
310100
+ const normalizedRelation = normalizeRelation(schema5, tableNamesMap, relation);
308846
310101
  const relationTableName = getTableUniqueName(relation.referencedTable);
308847
310102
  const relationTableTsName = tableNamesMap[relationTableName];
308848
310103
  const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
308849
310104
  const joinOn2 = and(...normalizedRelation.fields.map((field2, i2) => eq(aliasedTableColumn(normalizedRelation.references[i2], relationTableAlias), aliasedTableColumn(field2, tableAlias))));
308850
310105
  const builtRelation = this.buildRelationalQueryWithoutPK({
308851
310106
  fullSchema,
308852
- schema: schema4,
310107
+ schema: schema5,
308853
310108
  tableNamesMap,
308854
310109
  table: fullSchema[relationTableTsName],
308855
- tableConfig: schema4[relationTableTsName],
310110
+ tableConfig: schema5[relationTableTsName],
308856
310111
  queryConfig: is(relation, One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
308857
310112
  tableAlias: relationTableAlias,
308858
310113
  joinOn: joinOn2,
@@ -309360,9 +310615,9 @@ class QueryBuilder {
309360
310615
 
309361
310616
  // node_modules/drizzle-orm/pg-core/view.js
309362
310617
  class DefaultViewBuilderCore {
309363
- constructor(name, schema4) {
310618
+ constructor(name, schema5) {
309364
310619
  this.name = name;
309365
- this.schema = schema4;
310620
+ this.schema = schema5;
309366
310621
  }
309367
310622
  static [entityKind] = "PgDefaultViewBuilderCore";
309368
310623
  config = {};
@@ -309400,8 +310655,8 @@ class ViewBuilder extends DefaultViewBuilderCore {
309400
310655
  class ManualViewBuilder extends DefaultViewBuilderCore {
309401
310656
  static [entityKind] = "PgManualViewBuilder";
309402
310657
  columns;
309403
- constructor(name, columns, schema4) {
309404
- super(name, schema4);
310658
+ constructor(name, columns, schema5) {
310659
+ super(name, schema5);
309405
310660
  this.columns = getTableColumns(pgTable(name, columns));
309406
310661
  }
309407
310662
  existing() {
@@ -309439,9 +310694,9 @@ class ManualViewBuilder extends DefaultViewBuilderCore {
309439
310694
  }
309440
310695
 
309441
310696
  class MaterializedViewBuilderCore {
309442
- constructor(name, schema4) {
310697
+ constructor(name, schema5) {
309443
310698
  this.name = name;
309444
- this.schema = schema4;
310699
+ this.schema = schema5;
309445
310700
  }
309446
310701
  static [entityKind] = "PgMaterializedViewBuilderCore";
309447
310702
  config = {};
@@ -309496,8 +310751,8 @@ class MaterializedViewBuilder extends MaterializedViewBuilderCore {
309496
310751
  class ManualMaterializedViewBuilder extends MaterializedViewBuilderCore {
309497
310752
  static [entityKind] = "PgManualMaterializedViewBuilder";
309498
310753
  columns;
309499
- constructor(name, columns, schema4) {
309500
- super(name, schema4);
310754
+ constructor(name, columns, schema5) {
310755
+ super(name, schema5);
309501
310756
  this.columns = getTableColumns(pgTable(name, columns));
309502
310757
  }
309503
310758
  existing() {
@@ -309571,17 +310826,17 @@ class PgMaterializedView extends PgViewBase {
309571
310826
  };
309572
310827
  }
309573
310828
  }
309574
- function pgViewWithSchema(name, selection, schema4) {
310829
+ function pgViewWithSchema(name, selection, schema5) {
309575
310830
  if (selection) {
309576
- return new ManualViewBuilder(name, selection, schema4);
310831
+ return new ManualViewBuilder(name, selection, schema5);
309577
310832
  }
309578
- return new ViewBuilder(name, schema4);
310833
+ return new ViewBuilder(name, schema5);
309579
310834
  }
309580
- function pgMaterializedViewWithSchema(name, selection, schema4) {
310835
+ function pgMaterializedViewWithSchema(name, selection, schema5) {
309581
310836
  if (selection) {
309582
- return new ManualMaterializedViewBuilder(name, selection, schema4);
310837
+ return new ManualMaterializedViewBuilder(name, selection, schema5);
309583
310838
  }
309584
- return new MaterializedViewBuilder(name, schema4);
310839
+ return new MaterializedViewBuilder(name, schema5);
309585
310840
  }
309586
310841
 
309587
310842
  // node_modules/drizzle-orm/pg-core/utils.js
@@ -310029,9 +311284,9 @@ class PgCountBuilder extends SQL {
310029
311284
 
310030
311285
  // node_modules/drizzle-orm/pg-core/query-builders/query.js
310031
311286
  class RelationalQueryBuilder {
310032
- constructor(fullSchema, schema4, tableNamesMap, table, tableConfig, dialect2, session) {
311287
+ constructor(fullSchema, schema5, tableNamesMap, table, tableConfig, dialect2, session) {
310033
311288
  this.fullSchema = fullSchema;
310034
- this.schema = schema4;
311289
+ this.schema = schema5;
310035
311290
  this.tableNamesMap = tableNamesMap;
310036
311291
  this.table = table;
310037
311292
  this.tableConfig = tableConfig;
@@ -310048,10 +311303,10 @@ class RelationalQueryBuilder {
310048
311303
  }
310049
311304
 
310050
311305
  class PgRelationalQuery extends QueryPromise {
310051
- constructor(fullSchema, schema4, tableNamesMap, table, tableConfig, dialect2, session, config5, mode) {
311306
+ constructor(fullSchema, schema5, tableNamesMap, table, tableConfig, dialect2, session, config5, mode) {
310052
311307
  super();
310053
311308
  this.fullSchema = fullSchema;
310054
- this.schema = schema4;
311309
+ this.schema = schema5;
310055
311310
  this.tableNamesMap = tableNamesMap;
310056
311311
  this.table = table;
310057
311312
  this.tableConfig = tableConfig;
@@ -310139,13 +311394,13 @@ class PgRaw extends QueryPromise {
310139
311394
 
310140
311395
  // node_modules/drizzle-orm/pg-core/db.js
310141
311396
  class PgDatabase {
310142
- constructor(dialect2, session, schema4) {
311397
+ constructor(dialect2, session, schema5) {
310143
311398
  this.dialect = dialect2;
310144
311399
  this.session = session;
310145
- this._ = schema4 ? {
310146
- schema: schema4.schema,
310147
- fullSchema: schema4.fullSchema,
310148
- tableNamesMap: schema4.tableNamesMap,
311400
+ this._ = schema5 ? {
311401
+ schema: schema5.schema,
311402
+ fullSchema: schema5.fullSchema,
311403
+ tableNamesMap: schema5.tableNamesMap,
310149
311404
  session
310150
311405
  } : {
310151
311406
  schema: undefined,
@@ -310156,7 +311411,7 @@ class PgDatabase {
310156
311411
  this.query = {};
310157
311412
  if (this._.schema) {
310158
311413
  for (const [tableName, columns] of Object.entries(this._.schema)) {
310159
- this.query[tableName] = new RelationalQueryBuilder(schema4.fullSchema, this._.schema, this._.tableNamesMap, schema4.fullSchema[tableName], columns, dialect2, session);
311414
+ this.query[tableName] = new RelationalQueryBuilder(schema5.fullSchema, this._.schema, this._.tableNamesMap, schema5.fullSchema[tableName], columns, dialect2, session);
310160
311415
  }
310161
311416
  }
310162
311417
  this.$cache = { invalidate: async (_params) => {} };
@@ -310296,15 +311551,15 @@ function alias(table, alias2) {
310296
311551
 
310297
311552
  // node_modules/drizzle-orm/pg-core/sequence.js
310298
311553
  class PgSequence {
310299
- constructor(seqName, seqOptions, schema4) {
311554
+ constructor(seqName, seqOptions, schema5) {
310300
311555
  this.seqName = seqName;
310301
311556
  this.seqOptions = seqOptions;
310302
- this.schema = schema4;
311557
+ this.schema = schema5;
310303
311558
  }
310304
311559
  static [entityKind] = "PgSequence";
310305
311560
  }
310306
- function pgSequenceWithSchema(name, options, schema4) {
310307
- return new PgSequence(name, options, schema4);
311561
+ function pgSequenceWithSchema(name, options, schema5) {
311562
+ return new PgSequence(name, options, schema5);
310308
311563
  }
310309
311564
 
310310
311565
  // node_modules/drizzle-orm/pg-core/schema.js
@@ -310447,9 +311702,9 @@ class PgSession {
310447
311702
  }
310448
311703
 
310449
311704
  class PgTransaction extends PgDatabase {
310450
- constructor(dialect2, session, schema4, nestedIndex = 0) {
310451
- super(dialect2, session, schema4);
310452
- this.schema = schema4;
311705
+ constructor(dialect2, session, schema5, nestedIndex = 0) {
311706
+ super(dialect2, session, schema5);
311707
+ this.schema = schema5;
310453
311708
  this.nestedIndex = nestedIndex;
310454
311709
  }
310455
311710
  static [entityKind] = "PgTransaction";
@@ -310618,10 +311873,10 @@ class NodePgPreparedQuery extends PgPreparedQuery {
310618
311873
  }
310619
311874
 
310620
311875
  class NodePgSession extends PgSession {
310621
- constructor(client, dialect2, schema4, options = {}) {
311876
+ constructor(client, dialect2, schema5, options = {}) {
310622
311877
  super(dialect2);
310623
311878
  this.client = client;
310624
- this.schema = schema4;
311879
+ this.schema = schema5;
310625
311880
  this.options = options;
310626
311881
  this.logger = options.logger ?? new NoopLogger;
310627
311882
  this.cache = options.cache ?? new NoopCache;
@@ -310680,8 +311935,8 @@ class NodePgDriver {
310680
311935
  this.options = options;
310681
311936
  }
310682
311937
  static [entityKind] = "NodePgDriver";
310683
- createSession(schema4) {
310684
- return new NodePgSession(this.client, this.dialect, schema4, {
311938
+ createSession(schema5) {
311939
+ return new NodePgSession(this.client, this.dialect, schema5, {
310685
311940
  logger: this.options.logger,
310686
311941
  cache: this.options.cache
310687
311942
  });
@@ -310699,18 +311954,18 @@ function construct(client, config5 = {}) {
310699
311954
  } else if (config5.logger !== false) {
310700
311955
  logger2 = config5.logger;
310701
311956
  }
310702
- let schema4;
311957
+ let schema5;
310703
311958
  if (config5.schema) {
310704
311959
  const tablesConfig = extractTablesRelationalConfig(config5.schema, createTableRelationsHelpers);
310705
- schema4 = {
311960
+ schema5 = {
310706
311961
  fullSchema: config5.schema,
310707
311962
  schema: tablesConfig.tables,
310708
311963
  tableNamesMap: tablesConfig.tableNamesMap
310709
311964
  };
310710
311965
  }
310711
311966
  const driver2 = new NodePgDriver(client, dialect2, { logger: logger2, cache: config5.cache });
310712
- const session = driver2.createSession(schema4);
310713
- const db = new NodePgDatabase(dialect2, session, schema4);
311967
+ const session = driver2.createSession(schema5);
311968
+ const db = new NodePgDatabase(dialect2, session, schema5);
310714
311969
  db.$client = client;
310715
311970
  db.$cache = config5.cache;
310716
311971
  if (db.$cache) {
@@ -310918,7 +312173,11 @@ var user = pgTable("user", {
310918
312173
  companyId: uuid5().notNull(),
310919
312174
  branchId: uuid5().notNull(),
310920
312175
  kind: userKindEnum("kind").notNull().default("CUSTOMER"),
310921
- employeeId: uuid5()
312176
+ employeeId: uuid5(),
312177
+ role: text("role"),
312178
+ banned: boolean4("banned").default(false),
312179
+ banReason: text("ban_reason"),
312180
+ banExpires: timestamp("ban_expires")
310922
312181
  });
310923
312182
  var session = pgTable("session", {
310924
312183
  id: text("id").primaryKey(),
@@ -331886,7 +333145,7 @@ var auth2 = betterAuth({
331886
333145
  },
331887
333146
  revokeSessionsOnPasswordReset: true
331888
333147
  },
331889
- plugins: [openAPI(), bearer()],
333148
+ plugins: [openAPI(), bearer(), admin()],
331890
333149
  basePath: "/api",
331891
333150
  secondaryStorage,
331892
333151
  logger: {
@@ -332267,57 +333526,57 @@ function mapEnumValues(values) {
332267
333526
  return Object.fromEntries(values.map((value) => [value, value]));
332268
333527
  }
332269
333528
  function columnToSchema(column, t2) {
332270
- let schema4;
333529
+ let schema5;
332271
333530
  if (isWithEnum(column)) {
332272
- schema4 = column.enumValues.length ? t2.Enum(mapEnumValues(column.enumValues)) : t2.String();
333531
+ schema5 = column.enumValues.length ? t2.Enum(mapEnumValues(column.enumValues)) : t2.String();
332273
333532
  }
332274
- if (!schema4) {
333533
+ if (!schema5) {
332275
333534
  if (isColumnType(column, ["PgGeometry", "PgPointTuple"])) {
332276
- schema4 = t2.Tuple([t2.Number(), t2.Number()]);
333535
+ schema5 = t2.Tuple([t2.Number(), t2.Number()]);
332277
333536
  } else if (isColumnType(column, ["PgGeometryObject", "PgPointObject"])) {
332278
- schema4 = t2.Object({ x: t2.Number(), y: t2.Number() });
333537
+ schema5 = t2.Object({ x: t2.Number(), y: t2.Number() });
332279
333538
  } else if (isColumnType(column, ["PgHalfVector", "PgVector"])) {
332280
- schema4 = t2.Array(t2.Number(), column.dimensions ? {
333539
+ schema5 = t2.Array(t2.Number(), column.dimensions ? {
332281
333540
  minItems: column.dimensions,
332282
333541
  maxItems: column.dimensions
332283
333542
  } : undefined);
332284
333543
  } else if (isColumnType(column, ["PgLine"])) {
332285
- schema4 = t2.Tuple([t2.Number(), t2.Number(), t2.Number()]);
333544
+ schema5 = t2.Tuple([t2.Number(), t2.Number(), t2.Number()]);
332286
333545
  } else if (isColumnType(column, ["PgLineABC"])) {
332287
- schema4 = t2.Object({
333546
+ schema5 = t2.Object({
332288
333547
  a: t2.Number(),
332289
333548
  b: t2.Number(),
332290
333549
  c: t2.Number()
332291
333550
  });
332292
333551
  } else if (isColumnType(column, ["PgArray"])) {
332293
- schema4 = t2.Array(columnToSchema(column.baseColumn, t2), column.size ? {
333552
+ schema5 = t2.Array(columnToSchema(column.baseColumn, t2), column.size ? {
332294
333553
  minItems: column.size,
332295
333554
  maxItems: column.size
332296
333555
  } : undefined);
332297
333556
  } else if (column.dataType === "array") {
332298
- schema4 = t2.Array(t2.Any());
333557
+ schema5 = t2.Array(t2.Any());
332299
333558
  } else if (column.dataType === "number") {
332300
- schema4 = numberColumnToSchema(column, t2);
333559
+ schema5 = numberColumnToSchema(column, t2);
332301
333560
  } else if (column.dataType === "bigint") {
332302
- schema4 = bigintColumnToSchema(column, t2);
333561
+ schema5 = bigintColumnToSchema(column, t2);
332303
333562
  } else if (column.dataType === "boolean") {
332304
- schema4 = t2.Boolean();
333563
+ schema5 = t2.Boolean();
332305
333564
  } else if (column.dataType === "date") {
332306
- schema4 = t2.Date();
333565
+ schema5 = t2.Date();
332307
333566
  } else if (column.dataType === "string") {
332308
- schema4 = stringColumnToSchema(column, t2);
333567
+ schema5 = stringColumnToSchema(column, t2);
332309
333568
  } else if (column.dataType === "json") {
332310
- schema4 = jsonSchema;
333569
+ schema5 = jsonSchema;
332311
333570
  } else if (column.dataType === "custom") {
332312
- schema4 = t2.Any();
333571
+ schema5 = t2.Any();
332313
333572
  } else if (column.dataType === "buffer") {
332314
- schema4 = bufferSchema;
333573
+ schema5 = bufferSchema;
332315
333574
  }
332316
333575
  }
332317
- if (!schema4) {
332318
- schema4 = t2.Any();
333576
+ if (!schema5) {
333577
+ schema5 = t2.Any();
332319
333578
  }
332320
- return schema4;
333579
+ return schema5;
332321
333580
  }
332322
333581
  function numberColumnToSchema(column, t2) {
332323
333582
  let unsigned = column.getSQLType().includes("unsigned");
@@ -332461,8 +333720,8 @@ function handleColumns(columns, refinements, conditions, factory) {
332461
333720
  continue;
332462
333721
  }
332463
333722
  const column = is(selected, Column) ? selected : undefined;
332464
- const schema4 = column ? columnToSchema(column, factory?.typeboxInstance ?? Type) : Type.Any();
332465
- const refined = typeof refinement === "function" ? refinement(schema4) : schema4;
333723
+ const schema5 = column ? columnToSchema(column, factory?.typeboxInstance ?? Type) : Type.Any();
333724
+ const refined = typeof refinement === "function" ? refinement(schema5) : schema5;
332466
333725
  if (conditions.never(column)) {
332467
333726
  continue;
332468
333727
  } else {
@@ -332525,8 +333784,8 @@ function createSchemaFactory(options) {
332525
333784
  var { createSelectSchema, createUpdateSchema, createInsertSchema: createInsertSchema2 } = createSchemaFactory({
332526
333785
  typeboxInstance: t
332527
333786
  });
332528
- var OmitBaseSchema2 = (schema4) => {
332529
- return t.Omit(schema4, ["id", "createdAt", "updatedAt"]);
333787
+ var OmitBaseSchema2 = (schema5) => {
333788
+ return t.Omit(schema5, ["id", "createdAt", "updatedAt"]);
332530
333789
  };
332531
333790
 
332532
333791
  // src/routes/bt/invoice/model.ts
@@ -333171,9 +334430,9 @@ var phoneRegex = /^\d{8}$/;
333171
334430
  var CompanyBranchModel;
333172
334431
  ((CompanyBranchModel) => {
333173
334432
  const createSchema = createInsertSchema2(companyBranchTable, {
333174
- phone: (schema4) => t.RegExp(phoneRegex, { ...schema4 }),
333175
- email: (schema4) => t.String({ ...schema4, format: "email" }),
333176
- merchantId: (schema4) => t.Optional(schema4)
334433
+ phone: (schema5) => t.RegExp(phoneRegex, { ...schema5 }),
334434
+ email: (schema5) => t.String({ ...schema5, format: "email" }),
334435
+ merchantId: (schema5) => t.Optional(schema5)
333177
334436
  });
333178
334437
  const updateSchema = createUpdateSchema(companyBranchTable);
333179
334438
  const selectSchema = createSelectSchema(companyBranchTable);
@@ -343007,7 +344266,7 @@ var $generate = function(options) {
343007
344266
  var UserLogic;
343008
344267
  ((UserLogic) => {
343009
344268
  UserLogic.select = async (query, user2) => {
343010
- const filter = and(eq(user.branchId, query.branchId ?? "").if(query.branchId && user2.kind !== "CUSTOMER"), eq(user.branchId, user2.branchId).if(user2.kind === "CUSTOMER"), eq(user.companyId, user2.companyId).if(user2.kind !== "ADMIN"));
344269
+ const filter = and(eq(user.branchId, query.branchId ?? "").if(query.branchId && user2.kind !== "CUSTOMER"), eq(user.branchId, user2.branchId).if(user2.kind === "CUSTOMER"), eq(user.companyId, user2.companyId).if(user2.kind !== "ADMIN"), eq(user.banned, query.banned ?? false).if(query.banned !== undefined));
343011
344270
  const columns = getTableColumns(user);
343012
344271
  const baseQuery = db_default.select({
343013
344272
  ...columns,
@@ -343077,9 +344336,10 @@ var UserLogic;
343077
344336
  throw status("Not Found", "\u0425\u044D\u0440\u044D\u0433\u043B\u044D\u0433\u0447 \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
343078
344337
  }
343079
344338
  if (body.password) {
343080
- await auth2.api.resetPassword({
344339
+ await auth2.api.setUserPassword({
343081
344340
  body: {
343082
- newPassword: body.password
344341
+ newPassword: body.password,
344342
+ userId: updatedUser.id
343083
344343
  }
343084
344344
  });
343085
344345
  }
@@ -343095,7 +344355,7 @@ var create2 = createInsertSchema2(user);
343095
344355
  var update = createUpdateSchema(user);
343096
344356
  var selectUserSchema = t.Composite([
343097
344357
  PaginationSchema,
343098
- t.Partial(t.Pick(select, ["branchId"]))
344358
+ t.Partial(t.Pick(select, ["branchId", "banned"]))
343099
344359
  ]);
343100
344360
  var createUserSchema = t.Composite([
343101
344361
  t.Pick(create2, ["name", "email", "kind", "employeeId"]),