autosync_backend2 1.2.11 → 1.2.12

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.d.ts CHANGED
@@ -994,6 +994,7 @@ export declare const app: Elysia<"", {
994
994
  warehouseId?: string | undefined;
995
995
  safetyStock?: number | undefined;
996
996
  shelfNumber?: string | undefined;
997
+ isSafetyStock?: boolean | undefined;
997
998
  pagination: {
998
999
  size: number;
999
1000
  page: number;
@@ -1011,6 +1012,8 @@ export declare const app: Elysia<"", {
1011
1012
  quantity: number;
1012
1013
  safetyStock: number;
1013
1014
  shelfNumber: string | null;
1015
+ description: string | null;
1016
+ isOrdered: boolean;
1014
1017
  id: string;
1015
1018
  createdAt: string;
1016
1019
  updatedAt: string;
@@ -1066,8 +1069,10 @@ export declare const app: Elysia<"", {
1066
1069
  post: {
1067
1070
  body: {
1068
1071
  oldId?: number | null | undefined;
1072
+ description?: string | null | undefined;
1069
1073
  quantity?: number | undefined;
1070
1074
  shelfNumber?: string | null | undefined;
1075
+ isOrdered?: boolean | undefined;
1071
1076
  productId: string;
1072
1077
  warehouseId: string;
1073
1078
  safetyStock: number;
@@ -1082,11 +1087,13 @@ export declare const app: Elysia<"", {
1082
1087
  updatedAt: string;
1083
1088
  deletedAt: string | null;
1084
1089
  oldId: number | null;
1090
+ description: string | null;
1085
1091
  quantity: number;
1086
1092
  productId: string;
1087
1093
  warehouseId: string;
1088
1094
  safetyStock: number;
1089
1095
  shelfNumber: string | null;
1096
+ isOrdered: boolean;
1090
1097
  };
1091
1098
  422: {
1092
1099
  type: "validation";
@@ -1106,8 +1113,10 @@ export declare const app: Elysia<"", {
1106
1113
  post: {
1107
1114
  body: {
1108
1115
  oldId?: number | null | undefined;
1116
+ description?: string | null | undefined;
1109
1117
  quantity?: number | undefined;
1110
1118
  shelfNumber?: string | null | undefined;
1119
+ isOrdered?: boolean | undefined;
1111
1120
  productId: string;
1112
1121
  warehouseId: string;
1113
1122
  safetyStock: number;
@@ -1199,6 +1208,8 @@ export declare const app: Elysia<"", {
1199
1208
  quantity: number;
1200
1209
  safetyStock: number;
1201
1210
  shelfNumber: string | null;
1211
+ description: string | null;
1212
+ isOrdered: boolean;
1202
1213
  id: string;
1203
1214
  createdAt: string;
1204
1215
  updatedAt: string;
@@ -1270,6 +1281,8 @@ export declare const app: Elysia<"", {
1270
1281
  quantity: number;
1271
1282
  safetyStock: number;
1272
1283
  shelfNumber: string | null;
1284
+ description: string | null;
1285
+ isOrdered: boolean;
1273
1286
  id: string;
1274
1287
  createdAt: string;
1275
1288
  updatedAt: string;
@@ -1297,10 +1310,12 @@ export declare const app: Elysia<"", {
1297
1310
  put: {
1298
1311
  body: {
1299
1312
  oldId?: number | null | undefined;
1313
+ description?: string | null | undefined;
1300
1314
  productId?: string | undefined;
1301
1315
  warehouseId?: string | undefined;
1302
1316
  safetyStock?: number | undefined;
1303
1317
  shelfNumber?: string | null | undefined;
1318
+ isOrdered?: boolean | undefined;
1304
1319
  };
1305
1320
  params: {
1306
1321
  id: string;
@@ -1314,6 +1329,8 @@ export declare const app: Elysia<"", {
1314
1329
  quantity: number;
1315
1330
  safetyStock: number;
1316
1331
  shelfNumber: string | null;
1332
+ description: string | null;
1333
+ isOrdered: boolean;
1317
1334
  id: string;
1318
1335
  createdAt: string;
1319
1336
  updatedAt: string;
package/dist/index.js CHANGED
@@ -151617,7 +151617,9 @@ var warehouseItemTable = warehouseSchema.table("item", {
151617
151617
  productId: uuid8().notNull(),
151618
151618
  quantity: numeric({ mode: "number" }).notNull().default(0),
151619
151619
  safetyStock: numeric({ mode: "number" }).notNull(),
151620
- shelfNumber: varchar()
151620
+ shelfNumber: varchar(),
151621
+ description: text(),
151622
+ isOrdered: boolean4().notNull().default(false)
151621
151623
  }, (t2) => [unique().on(t2.warehouseId, t2.productId)]);
151622
151624
  var warehouseTransactionTypeEnum = warehouseSchema.enum("transaction_type", ["IN", "OUT"]);
151623
151625
  var warehouseTransactionKindEnum = warehouseSchema.enum("transaction_kind", ["TRANSFER", "RETURN", "ADJUSTMENT", "REJECTION", "ORDER", "SALES"]);
@@ -154541,17 +154543,14 @@ var secondaryStorage = {
154541
154543
  }
154542
154544
  };
154543
154545
  var auth2 = betterAuth({
154544
- database: drizzleAdapter(db_default, {
154545
- provider: "pg"
154546
- }),
154547
- emailAndPassword: {
154548
- enabled: true
154549
- },
154550
- plugins: [openAPI(), bearer()],
154551
- basePath: "/api",
154552
- secondaryStorage,
154553
154546
  user: {
154554
154547
  additionalFields: {
154548
+ branchId: {
154549
+ type: "string"
154550
+ },
154551
+ companyId: {
154552
+ type: "string"
154553
+ },
154555
154554
  kind: {
154556
154555
  type: userKindEnum.enumValues,
154557
154556
  defaultValue: "CUSTOMER"
@@ -154559,15 +154558,18 @@ var auth2 = betterAuth({
154559
154558
  employeeId: {
154560
154559
  type: "string",
154561
154560
  required: false
154562
- },
154563
- branchId: {
154564
- type: "string"
154565
- },
154566
- companyId: {
154567
- type: "string"
154568
154561
  }
154569
154562
  }
154570
154563
  },
154564
+ database: drizzleAdapter(db_default, {
154565
+ provider: "pg"
154566
+ }),
154567
+ emailAndPassword: {
154568
+ enabled: true
154569
+ },
154570
+ plugins: [openAPI(), bearer()],
154571
+ basePath: "/api",
154572
+ secondaryStorage,
154571
154573
  logger: {
154572
154574
  log(level, ...args) {
154573
154575
  if (level === "error" && args[0] === "Error" && args.length === 2 && args[1] instanceof Error && args[1].message === "NOT_FOUND")
@@ -154575,17 +154577,7 @@ var auth2 = betterAuth({
154575
154577
  console[level](...args);
154576
154578
  }
154577
154579
  },
154578
- telemetry: {
154579
- enabled: false
154580
- },
154581
- trustedOrigins: ["https://user.autosync.mn", "https://admin.autosync.mn"],
154582
- advanced: {
154583
- defaultCookieAttributes: {
154584
- sameSite: "None",
154585
- secure: true,
154586
- httpOnly: true
154587
- }
154588
- }
154580
+ trustedOrigins: ["https://user.autosync.mn", "https://admin.autosync.mn"]
154589
154581
  });
154590
154582
  var _schema;
154591
154583
  var getSchema2 = async () => _schema ??= auth2.api.generateOpenAPISchema();
@@ -155738,7 +155730,7 @@ var WarehouseItemLogic;
155738
155730
  ((WarehouseItemLogic) => {
155739
155731
  WarehouseItemLogic.select = async (query, user2) => {
155740
155732
  console.log(query);
155741
- const filter = and(softDeletedFilter(warehouseItemTable).if(query.isActive), isNotNull(warehouseItemTable.deletedAt).if(query.isActive !== undefined && query.isActive === false), ...query.product ? [logic_default5.getFilter(query.product, user2)] : [], eq(warehouseItemTable.safetyStock, query.safetyStock ?? 0).if(query.safetyStock), ilike(warehouseItemTable.shelfNumber, `%${query.shelfNumber}%`).if(query.shelfNumber), eq(warehouseItemTable.warehouseId, query.warehouseId).if(query.warehouseId));
155733
+ const filter = and(softDeletedFilter(warehouseItemTable).if(query.isActive), isNotNull(warehouseItemTable.deletedAt).if(query.isActive !== undefined && query.isActive === false), ...query.product ? [logic_default5.getFilter(query.product, user2)] : [], eq(warehouseItemTable.safetyStock, query.safetyStock ?? 0).if(query.safetyStock), lte(warehouseItemTable.safetyStock, warehouseItemTable.quantity).if(query.isSafetyStock), ilike(warehouseItemTable.shelfNumber, `%${query.shelfNumber}%`).if(query.shelfNumber), eq(warehouseItemTable.warehouseId, query.warehouseId).if(query.warehouseId));
155742
155734
  const baseQuery = db_default.select({
155743
155735
  item: warehouseItemTable,
155744
155736
  supplier: techdocSupplierTable,
@@ -161881,13 +161873,35 @@ var userRoutes = new Elysia({
161881
161873
  query: selectUserSchema,
161882
161874
  userKind: "COMPANY_ADMIN"
161883
161875
  }).get("/me", async ({ user: user2 }) => {
161884
- const company2 = await service3.get({
161885
- id: user2.companyId,
161886
- pagination: { size: 1, page: 1 }
161876
+ const cacheKey = `user_company_${user2.companyId}`;
161877
+ const cached4 = await redis_client_default.get(cacheKey);
161878
+ if (cached4) {
161879
+ return {
161880
+ ...user2,
161881
+ company: cached4
161882
+ };
161883
+ }
161884
+ const company2 = await db_default.query.companyCompanyTable.findFirst({
161885
+ where: (t2, { eq: eq2 }) => eq2(t2.id, user2.companyId),
161886
+ columns: {
161887
+ id: true,
161888
+ name: true,
161889
+ logoUrl: true,
161890
+ regNumber: true,
161891
+ province: true,
161892
+ district: true,
161893
+ khoroo: true,
161894
+ street: true,
161895
+ email: true,
161896
+ phone: true
161897
+ }
161887
161898
  });
161899
+ if (company2) {
161900
+ await redis_client_default.set(cacheKey, company2);
161901
+ }
161888
161902
  return {
161889
161903
  ...user2,
161890
- company: company2.result[0]
161904
+ company: company2
161891
161905
  };
161892
161906
  }).post("/", async ({ body, user: user2 }) => logic_default23.registerUser(body, user2), {
161893
161907
  body: createUserSchema,
@@ -161941,7 +161955,8 @@ var WarehouseItemModel;
161941
161955
  warehouseId: t.String({ format: "uuid" }),
161942
161956
  isActive: t.Boolean({
161943
161957
  default: true
161944
- })
161958
+ }),
161959
+ isSafetyStock: t.Boolean()
161945
161960
  }))
161946
161961
  ]);
161947
161962
  WarehouseItemModel.selectTransaction = t.Composite([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosync_backend2",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,13 +22,13 @@
22
22
  "@bogeychan/elysia-logger": "^0.1.10",
23
23
  "@elysiajs/cors": "^1.4.0",
24
24
  "@elysiajs/cron": "^1.4.1",
25
- "@elysiajs/eden": "^1.4.3",
25
+ "@elysiajs/eden": "^1.4.4",
26
26
  "@elysiajs/openapi": "^1.4.11",
27
27
  "@elysiajs/swagger": "^1.3.1",
28
28
  "@react-email/components": "^0.0.41",
29
29
  "@sinclair/typebox": "^0.34.40",
30
30
  "@upstash/redis": "^1.35.4",
31
- "better-auth": "^1.3.18",
31
+ "better-auth": "^1.3.27",
32
32
  "drizzle-orm": "^0.44.4",
33
33
  "drizzle-typebox": "^0.3.3",
34
34
  "elysia": "1.4.11",