@xenon-device-management/xenon 1.1.4 → 1.1.7

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/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xenon-device-management/xenon",
3
- "version": "1.1.4",
3
+ "version": "1.1.7",
4
4
  "description": "Xenon - Intelligent Mobile Infrastructure. A self-healing device orchestration platform for Appium.",
5
5
  "main": "./lib/src/index.js",
6
6
  "exports": {
@@ -9,6 +9,7 @@
9
9
  "./package.json": "./package.json"
10
10
  },
11
11
  "scripts": {
12
+ "postinstall": "node scripts/generate-prisma.js",
12
13
  "build": "npx prisma generate && tsc -b && npm run build:copy",
13
14
  "build:all": "npm run build:xenon && npm run build",
14
15
  "build:copy": "rm -rf lib/public && mkdir -p lib && cp -R src/public lib/ && cp schema.json lib/",
@@ -12,14 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.addNewPendingSession = addNewPendingSession;
13
13
  exports.removePendingSession = removePendingSession;
14
14
  const device_store_1 = require("./device-store");
15
- const store = device_store_1.DeviceStoreFactory.getPendingSessionStore();
16
15
  function addNewPendingSession(capability) {
17
16
  return __awaiter(this, void 0, void 0, function* () {
17
+ const store = device_store_1.DeviceStoreFactory.getPendingSessionStore();
18
18
  yield store.addPendingSession(capability);
19
19
  });
20
20
  }
21
21
  function removePendingSession(sessionCapabilityId) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
+ const store = device_store_1.DeviceStoreFactory.getPendingSessionStore();
23
24
  yield store.removePendingSession(sessionCapabilityId);
24
25
  });
25
26
  }
@@ -9,19 +9,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PrismaService = void 0;
13
- const client_1 = require("@prisma/client");
14
- const config_1 = require("../config");
12
+ exports.getPrismaService = exports.PrismaService = void 0;
13
+ const prisma_1 = require("../prisma");
15
14
  const typedi_1 = require("typedi");
16
- let PrismaService = class PrismaService extends client_1.PrismaClient {
17
- constructor() {
18
- super({
19
- datasources: {
20
- db: {
21
- url: config_1.config.databaseUrl,
22
- },
23
- },
24
- });
15
+ let PrismaService = class PrismaService {
16
+ constructor() { }
17
+ get client() {
18
+ return prisma_1.prisma;
25
19
  }
26
20
  };
27
21
  exports.PrismaService = PrismaService;
@@ -29,3 +23,6 @@ exports.PrismaService = PrismaService = __decorate([
29
23
  (0, typedi_1.Service)(),
30
24
  __metadata("design:paramtypes", [])
31
25
  ], PrismaService);
26
+ // For compatibility with parts of the code that might expect PrismaService to be the client
27
+ const getPrismaService = () => prisma_1.prisma;
28
+ exports.getPrismaService = getPrismaService;
@@ -51,8 +51,8 @@ const typedi_1 = require("typedi");
51
51
  const semver = __importStar(require("semver"));
52
52
  const logger_1 = __importDefault(require("../logger"));
53
53
  class PrismaDeviceStore {
54
- constructor() {
55
- this.prisma = typedi_1.Container.get(prisma_service_1.PrismaService);
54
+ get prisma() {
55
+ return typedi_1.Container.get(prisma_service_1.PrismaService).client;
56
56
  }
57
57
  toIDevice(device) {
58
58
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -275,8 +275,8 @@ class PrismaDeviceStore {
275
275
  }
276
276
  exports.PrismaDeviceStore = PrismaDeviceStore;
277
277
  class PrismaPendingSessionStore {
278
- constructor() {
279
- this.prisma = typedi_1.Container.get(prisma_service_1.PrismaService);
278
+ get prisma() {
279
+ return typedi_1.Container.get(prisma_service_1.PrismaService).client;
280
280
  }
281
281
  addPendingSession(capability) {
282
282
  return __awaiter(this, void 0, void 0, function* () {
@@ -327,8 +327,8 @@ class PrismaPendingSessionStore {
327
327
  }
328
328
  exports.PrismaPendingSessionStore = PrismaPendingSessionStore;
329
329
  class PrismaCLIArgsStore {
330
- constructor() {
331
- this.prisma = typedi_1.Container.get(prisma_service_1.PrismaService);
330
+ get prisma() {
331
+ return typedi_1.Container.get(prisma_service_1.PrismaService).client;
332
332
  }
333
333
  addCLIArgs(args) {
334
334
  return __awaiter(this, void 0, void 0, function* () {
@@ -348,8 +348,8 @@ class PrismaCLIArgsStore {
348
348
  }
349
349
  exports.PrismaCLIArgsStore = PrismaCLIArgsStore;
350
350
  class PrismaHealEtalonStore {
351
- constructor() {
352
- this.prisma = typedi_1.Container.get(prisma_service_1.PrismaService);
351
+ get prisma() {
352
+ return typedi_1.Container.get(prisma_service_1.PrismaService).client;
353
353
  }
354
354
  saveSignature(etalon) {
355
355
  return __awaiter(this, void 0, void 0, function* () {
@@ -27,8 +27,8 @@ const prisma_service_1 = require("./prisma-service");
27
27
  const logger_1 = __importDefault(require("../logger"));
28
28
  const typedi_1 = require("typedi");
29
29
  let QueueService = class QueueService {
30
- constructor(prisma) {
31
- this.prisma = prisma;
30
+ constructor(prismaService) {
31
+ this.prismaService = prismaService;
32
32
  this.deviceStore = device_store_1.DeviceStoreFactory.getStore();
33
33
  this.pendingStore = device_store_1.DeviceStoreFactory.getPendingSessionStore();
34
34
  }
@@ -39,7 +39,7 @@ let QueueService = class QueueService {
39
39
  getAverageSessionDuration(platform) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  try {
42
- const recentSessions = yield this.prisma.session.findMany({
42
+ const recentSessions = yield this.prismaService.client.session.findMany({
43
43
  where: {
44
44
  device_platform: platform.toLowerCase(),
45
45
  endTime: { not: null },
@@ -32,12 +32,12 @@ let NotificationService = class NotificationService {
32
32
  }
33
33
  getConfigs() {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- return this.prisma.webhookConfig.findMany();
35
+ return this.prisma.client.webhookConfig.findMany();
36
36
  });
37
37
  }
38
38
  saveConfig(url_1, events_1) {
39
39
  return __awaiter(this, arguments, void 0, function* (url, events, type = 'slack', payloadTemplate) {
40
- return this.prisma.webhookConfig.create({
40
+ return this.prisma.client.webhookConfig.create({
41
41
  data: {
42
42
  url,
43
43
  events: JSON.stringify(events),
@@ -50,7 +50,7 @@ let NotificationService = class NotificationService {
50
50
  }
51
51
  deleteConfig(id) {
52
52
  return __awaiter(this, void 0, void 0, function* () {
53
- yield this.prisma.webhookConfig.delete({ where: { id } });
53
+ yield this.prisma.client.webhookConfig.delete({ where: { id } });
54
54
  });
55
55
  }
56
56
  dispatchEvent(eventType, payload) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xenon-device-management/xenon",
3
- "version": "1.1.4",
3
+ "version": "1.1.7",
4
4
  "description": "Xenon - Intelligent Mobile Infrastructure. A self-healing device orchestration platform for Appium.",
5
5
  "main": "./lib/src/index.js",
6
6
  "exports": {
@@ -9,6 +9,7 @@
9
9
  "./package.json": "./package.json"
10
10
  },
11
11
  "scripts": {
12
+ "postinstall": "node scripts/generate-prisma.js",
12
13
  "build": "npx prisma generate && tsc -b && npm run build:copy",
13
14
  "build:all": "npm run build:xenon && npm run build",
14
15
  "build:copy": "rm -rf lib/public && mkdir -p lib && cp -R src/public lib/ && cp schema.json lib/",
@@ -0,0 +1,40 @@
1
+ const { execSync } = require('child_process');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ /**
6
+ * Robust Prisma Client Generator
7
+ *
8
+ * This script runs 'prisma generate' but ensures that it doesn't
9
+ * crash the npm install process if it fails.
10
+ */
11
+ function generate() {
12
+ console.log('📦 [Xenon] Running Prisma client generation...');
13
+
14
+ try {
15
+ // Determine the path to prisma CLI
16
+ let prismaBin = path.resolve(__dirname, '../node_modules/.bin/prisma');
17
+ if (!fs.existsSync(prismaBin)) {
18
+ prismaBin = 'npx prisma'; // Fallback to npx
19
+ }
20
+
21
+ const command = `${prismaBin} generate`;
22
+ console.log(`🚀 [Xenon] Executing: ${command}`);
23
+
24
+ execSync(command, {
25
+ stdio: 'inherit',
26
+ cwd: path.resolve(__dirname, '..')
27
+ });
28
+
29
+ console.log('✅ [Xenon] Prisma client generated successfully.');
30
+ } catch (error) {
31
+ console.error('⚠️ [Xenon] Prisma client generation failed.');
32
+ console.error('⚠️ [Xenon] This is usually fine during installation; the client will be verified at runtime.');
33
+ console.error('⚠️ [Xenon] Error detail:', error.message);
34
+
35
+ // Crucial: Exit with 0 so npm install proceeds
36
+ process.exit(0);
37
+ }
38
+ }
39
+
40
+ generate();