@eeplatform/core 1.7.2 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2175,11 +2175,13 @@ function useRoleRepo() {
2175
2175
  throw new InternalServerError8("Failed to create unique index on role.");
2176
2176
  }
2177
2177
  }
2178
- async function addRole(value, session) {
2178
+ async function addRole(value, session, clearCache = true) {
2179
2179
  value = new MRole(value);
2180
2180
  try {
2181
2181
  const res = await collection.insertOne(value, { session });
2182
- delCachedData();
2182
+ if (clearCache) {
2183
+ delCachedData();
2184
+ }
2183
2185
  return res.insertedId;
2184
2186
  } catch (error) {
2185
2187
  logger7.log({ level: "error", message: `${error}` });
@@ -2452,7 +2454,8 @@ function useRoleRepo() {
2452
2454
  getRoleByName,
2453
2455
  updateRole,
2454
2456
  deleteRole,
2455
- updatePermissionsById
2457
+ updatePermissionsById,
2458
+ delCachedData
2456
2459
  };
2457
2460
  }
2458
2461
 
@@ -3842,6 +3845,7 @@ function useRoleController() {
3842
3845
  // src/resources/file/file.service.ts
3843
3846
  import { logger as logger11, useS3 as useS32, useAtlas as useAtlas11 } from "@eeplatform/nodejs-utils";
3844
3847
  import cron from "node-cron";
3848
+ import * as fs from "fs";
3845
3849
  function useFileService() {
3846
3850
  const {
3847
3851
  createFile: _createFile,
@@ -3865,12 +3869,23 @@ function useFileService() {
3865
3869
  };
3866
3870
  try {
3867
3871
  const id = await _createFile(file, session);
3872
+ const fileBuffer = value.buffer || await fs.promises.readFile(value.path);
3868
3873
  await s3.uploadObject({
3869
3874
  key: id,
3870
- body: value.buffer,
3875
+ body: fileBuffer,
3871
3876
  contentType: value.mimetype
3872
3877
  });
3873
3878
  await session?.commitTransaction();
3879
+ if (value.path) {
3880
+ try {
3881
+ await fs.promises.unlink(value.path);
3882
+ } catch (cleanupError) {
3883
+ console.error(
3884
+ `Failed to cleanup temporary file ${value.path}:`,
3885
+ cleanupError
3886
+ );
3887
+ }
3888
+ }
3874
3889
  return id;
3875
3890
  } catch (error) {
3876
3891
  await session?.abortTransaction();
@@ -5907,7 +5922,7 @@ function useCounterRepo() {
5907
5922
 
5908
5923
  // src/resources/utils/gemini.service.ts
5909
5924
  import { GoogleGenerativeAI } from "@google/generative-ai";
5910
- import fs from "fs";
5925
+ import fs2 from "fs";
5911
5926
  import path from "path";
5912
5927
  var genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
5913
5928
  var SUPPORTED_AUDIO_FORMATS = [
@@ -5927,7 +5942,7 @@ function useGeminiAiService() {
5927
5942
  };
5928
5943
  const readAudioFile = async (filePath) => {
5929
5944
  try {
5930
- const audioBuffer = await fs.promises.readFile(filePath);
5945
+ const audioBuffer = await fs2.promises.readFile(filePath);
5931
5946
  const extension = path.extname(filePath).toLowerCase();
5932
5947
  const mimeTypeMap = {
5933
5948
  ".wav": "audio/wav",
@@ -6265,7 +6280,7 @@ function useGitHubService() {
6265
6280
  const octokit = new Octokit({ auth: githubToken });
6266
6281
  const { owner, repo } = parseRepoUrl(repoUrl);
6267
6282
  await checkAdminPermission(owner, repo, octokit);
6268
- const lines = keyValues.split(/[\n\r\s\t]+/).map((l) => l.trim()).filter(Boolean);
6283
+ const lines = keyValues.split(";").map((l) => l.trim()).filter(Boolean);
6269
6284
  for (const line of lines) {
6270
6285
  const equalIndex = line.indexOf("=");
6271
6286
  if (equalIndex === -1)
@@ -6890,7 +6905,7 @@ function useUtilController() {
6890
6905
  availableEndpoints: [
6891
6906
  "POST /github/variables - Set GitHub environment variables or secrets"
6892
6907
  ],
6893
- keyValueFormat: "KEY=value pairs separated by newlines, spaces, or tabs"
6908
+ keyValueFormat: "KEY=value pairs separated by semicolons"
6894
6909
  }
6895
6910
  });
6896
6911
  } catch (error) {
@@ -6944,14 +6959,14 @@ function useUtilController() {
6944
6959
  );
6945
6960
  return;
6946
6961
  }
6947
- const lines = keyValues.split(/[\n\r\s\t]+/).map((l) => l.trim()).filter(Boolean);
6962
+ const lines = keyValues.split(";").map((l) => l.trim()).filter(Boolean);
6948
6963
  const invalidLines = lines.filter(
6949
6964
  (line) => !line.includes("=") || line.indexOf("=") === -1
6950
6965
  );
6951
6966
  if (invalidLines.length > 0) {
6952
6967
  next(
6953
6968
  new BadRequestError33(
6954
- "Invalid key-value format. Each pair should be in format: KEY=value. Pairs can be separated by newlines, spaces, or tabs."
6969
+ "Invalid key-value format. Each pair should be in format: KEY=value. Pairs should be separated by semicolons."
6955
6970
  )
6956
6971
  );
6957
6972
  return;