@dv4resi/dvss-backend-module-offering-im 0.0.24 → 0.0.25

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
@@ -6,6 +6,7 @@ var dvssBackendModuleUtility = require('@dv4resi/dvss-backend-module-utility');
6
6
  var axios = require('@nestjs/axios');
7
7
  var config = require('@nestjs/config');
8
8
  var path = require('path');
9
+ var https = require('https');
9
10
  var rxjs = require('rxjs');
10
11
  var dotenv = require('dotenv');
11
12
  var models = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models');
@@ -14,6 +15,26 @@ var capabilityIntegration_model = require('@dv4resi/dvss-backend-module-datastor
14
15
  var capability_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability.model');
15
16
  var luxonDate_util = require('@dv4resi/dvss-backend-module-utility/dist/common/utils/luxon-date.util');
16
17
 
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n.default = e;
33
+ return Object.freeze(n);
34
+ }
35
+
36
+ var https__namespace = /*#__PURE__*/_interopNamespace(https);
37
+
17
38
  var __defProp = Object.defineProperty;
18
39
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
40
  function _ts_decorate(decorators, target, key, desc2) {
@@ -531,7 +552,12 @@ exports.IntegrationLibsModule = _ts_decorate8([
531
552
  envFilePath: path.resolve(__dirname, "../../../.env"),
532
553
  isGlobal: true
533
554
  }),
534
- axios.HttpModule,
555
+ axios.HttpModule.register({
556
+ global: true,
557
+ httpsAgent: new https__namespace.Agent({
558
+ rejectUnauthorized: false
559
+ })
560
+ }),
535
561
  dvssBackendModuleUtility.LoggerModule
536
562
  ],
537
563
  controllers: [
@@ -580,15 +606,6 @@ var CREDIT_FILTER_BY_ENUM = /* @__PURE__ */ (function(CREDIT_FILTER_BY_ENUM2) {
580
606
  return CREDIT_FILTER_BY_ENUM2;
581
607
  })({});
582
608
 
583
- // ../../packages/dvss-integration-libs/src/integration-operation-skeletons/models/capability-integration.model.ts
584
- var INTEGRATION_PROVIDER_ENUM = /* @__PURE__ */ (function(INTEGRATION_PROVIDER_ENUM2) {
585
- INTEGRATION_PROVIDER_ENUM2["TRYBE"] = "TRYBE";
586
- INTEGRATION_PROVIDER_ENUM2["SUPREMA_BIOSTAR"] = "SUPREMA_BIOSTAR";
587
- INTEGRATION_PROVIDER_ENUM2["SALTO_PRO"] = "SALTO_PRO";
588
- INTEGRATION_PROVIDER_ENUM2["SCHINDLER"] = "SCHINDLER";
589
- return INTEGRATION_PROVIDER_ENUM2;
590
- })({});
591
-
592
609
  // ../../packages/dvss-integration-libs/src/integration-operation-skeletons/models/wellness-management.model.ts
593
610
  var BOOKABLE_ITEM_TYPE_ENUM = /* @__PURE__ */ (function(BOOKABLE_ITEM_TYPE_ENUM2) {
594
611
  BOOKABLE_ITEM_TYPE_ENUM2["APPOINTMENT"] = "APPOINTMENT";
@@ -751,6 +768,19 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
751
768
  projectId: input.projectId
752
769
  });
753
770
  }
771
+ if (input.resourceMappings?.length) {
772
+ for (const mapping of input.resourceMappings) {
773
+ if (mapping.configuredForType === models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY) {
774
+ const propertyId = Number(mapping.configuredForId);
775
+ await this.commonValidationDatabaseService.validatePropertyIds({
776
+ propertyIds: [
777
+ propertyId
778
+ ],
779
+ projectId: input.projectId
780
+ });
781
+ }
782
+ }
783
+ }
754
784
  if (input.parentId != null) {
755
785
  const parentIntegration = await this.integrationConfigurationDao.getCapabilityIntegration({
756
786
  capabilityIntegrationId: input.parentId
@@ -823,8 +853,25 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
823
853
  throw new Error("loggedInUserId is required");
824
854
  }
825
855
  this.validateIconAndNickName(request.updateData, loggedInUserId);
856
+ if (request.updateData.resourceMappings?.length) {
857
+ for (const mapping of request.updateData.resourceMappings) {
858
+ if (mapping.configuredForType === models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY) {
859
+ if (!integration?.projectId) {
860
+ throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", "integration.projectId is required to validate resourceMappings");
861
+ }
862
+ const propertyId = Number(mapping.configuredForId);
863
+ await this.commonValidationDatabaseService.validatePropertyIds({
864
+ propertyIds: [
865
+ propertyId
866
+ ],
867
+ projectId: integration.projectId
868
+ });
869
+ }
870
+ }
871
+ }
826
872
  let configToUpdate;
827
873
  const updateData = request.updateData;
874
+ const { resourceMappings } = updateData;
828
875
  if (updateData.config && integration?.config) {
829
876
  const existingConfig = integration.config;
830
877
  configToUpdate = {
@@ -858,10 +905,19 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
858
905
  availableFor: updateData.availableFor,
859
906
  updatedBy: loggedInUserId
860
907
  };
861
- return await this.integrationConfigurationDao.updateCapabilityIntegration({
908
+ const updateResult = await this.integrationConfigurationDao.updateCapabilityIntegration({
862
909
  id: request.id,
863
- updateData: updateDataForDao
910
+ updateData: updateDataForDao,
911
+ projectId: integration?.projectId
864
912
  }, loggedInUserId);
913
+ if (resourceMappings?.length) {
914
+ await this.integrationConfigurationDao.syncCapabilityIntegrationResourceMappings({
915
+ capabilityIntegrationId: request.id,
916
+ projectId: integration?.projectId,
917
+ resourceMappings
918
+ }, loggedInUserId);
919
+ }
920
+ return updateResult;
865
921
  }
866
922
  /**
867
923
  * Validates icon and nickname. Can be overridden in subclasses for provider-specific validation.
@@ -1015,6 +1071,20 @@ var BaseIntegrationResourceManagement = class {
1015
1071
  }
1016
1072
  };
1017
1073
 
1074
+ // ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/device-management/device-management.base.ts
1075
+ var BaseDeviceManagement = class {
1076
+ static {
1077
+ __name(this, "BaseDeviceManagement");
1078
+ }
1079
+ };
1080
+
1081
+ // ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/access-control/access-management.base.ts
1082
+ var BaseAccessManagement = class {
1083
+ static {
1084
+ __name(this, "BaseAccessManagement");
1085
+ }
1086
+ };
1087
+
1018
1088
  // ../../node_modules/drizzle-orm/entity.js
1019
1089
  var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
1020
1090
  function is(value, type) {
@@ -1245,9 +1315,9 @@ var Table = class Table2 {
1245
1315
  [IsDrizzleTable] = true;
1246
1316
  /** @internal */
1247
1317
  [ExtraConfigBuilder] = void 0;
1248
- constructor(name, schema8, baseName) {
1318
+ constructor(name, schema9, baseName) {
1249
1319
  this[TableName] = this[OriginalName] = name;
1250
- this[Schema] = schema8;
1320
+ this[Schema] = schema9;
1251
1321
  this[BaseName] = baseName;
1252
1322
  }
1253
1323
  };
@@ -2223,11 +2293,11 @@ var View = class View2 {
2223
2293
  static [entityKind] = "View";
2224
2294
  /** @internal */
2225
2295
  [ViewBaseConfig];
2226
- constructor({ name: name2, schema: schema8, selectedFields, query }) {
2296
+ constructor({ name: name2, schema: schema9, selectedFields, query }) {
2227
2297
  this[ViewBaseConfig] = {
2228
2298
  name: name2,
2229
2299
  originalName: name2,
2230
- schema: schema8,
2300
+ schema: schema9,
2231
2301
  selectedFields,
2232
2302
  query,
2233
2303
  isExisting: !query,
@@ -2297,6 +2367,16 @@ function or(...unfilteredConditions) {
2297
2367
  ]);
2298
2368
  }
2299
2369
  __name(or, "or");
2370
+ function inArray(column, values) {
2371
+ if (Array.isArray(values)) {
2372
+ if (values.length === 0) {
2373
+ return sql`false`;
2374
+ }
2375
+ return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
2376
+ }
2377
+ return sql`${column} in ${bindIfParam(values, column)}`;
2378
+ }
2379
+ __name(inArray, "inArray");
2300
2380
  function isNull(value) {
2301
2381
  return sql`${value} is null`;
2302
2382
  }
@@ -2494,31 +2574,189 @@ function _ts_param3(paramIndex, decorator) {
2494
2574
  };
2495
2575
  }
2496
2576
  __name(_ts_param3, "_ts_param");
2577
+ exports.IntegrationSubcapabilityDao = class IntegrationSubcapabilityDao {
2578
+ static {
2579
+ __name(this, "IntegrationSubcapabilityDao");
2580
+ }
2581
+ conn;
2582
+ logger;
2583
+ fileName = "integration-subcapability.dao";
2584
+ constructor(conn, logger) {
2585
+ this.conn = conn;
2586
+ this.logger = logger;
2587
+ }
2588
+ /**
2589
+ * Returns subcapability id for given capabilityId and subcapability name.
2590
+ * Enforces uniqueness: if more than one active row is found, throws an error.
2591
+ * If no active row is found, returns undefined (caller decides how to handle).
2592
+ */
2593
+ async getSubcapabilityId(input, loggedInUserId) {
2594
+ this.logger.info(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "IntegrationSubcapabilityDao -> getSubcapabilityId called", {
2595
+ input
2596
+ });
2597
+ try {
2598
+ const rows = await this.conn.query.subcapability.findMany({
2599
+ where: and(eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), eq(dvssBackendModuleDatastore.schema.subcapability.name, input.name), isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
2600
+ });
2601
+ if (rows.length === 0) {
2602
+ this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Subcapability not found for given capabilityId and name", {
2603
+ input
2604
+ });
2605
+ return void 0;
2606
+ }
2607
+ return rows[0].id;
2608
+ } catch (error) {
2609
+ this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Error in getSubcapabilityId", error, {
2610
+ input
2611
+ });
2612
+ throw error;
2613
+ }
2614
+ }
2615
+ async getSubcapabilities(input, loggedInUserId) {
2616
+ this.logger.info(loggedInUserId, this.getSubcapabilities.name, this.fileName, "IntegrationSubcapabilityDao -> getSubcapabilities called", {
2617
+ input
2618
+ });
2619
+ try {
2620
+ return await this.conn.query.subcapability.findMany({
2621
+ where: and(eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
2622
+ });
2623
+ } catch (error) {
2624
+ this.logger.error(loggedInUserId, this.getSubcapabilities.name, this.fileName, "Error in getSubcapabilities", error, {
2625
+ input
2626
+ });
2627
+ throw error;
2628
+ }
2629
+ }
2630
+ };
2631
+ exports.IntegrationSubcapabilityDao = _ts_decorate12([
2632
+ common.Injectable(),
2633
+ _ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2634
+ _ts_metadata9("design:type", Function),
2635
+ _ts_metadata9("design:paramtypes", [
2636
+ typeof MySql2Database === "undefined" ? Object : MySql2Database,
2637
+ typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
2638
+ ])
2639
+ ], exports.IntegrationSubcapabilityDao);
2640
+ var IntegrationVisitorCredentialMappingDao = class {
2641
+ static {
2642
+ __name(this, "IntegrationVisitorCredentialMappingDao");
2643
+ }
2644
+ generateVisitorCredentialConfigKey = "generateCredentialsForVisitor";
2645
+ capIntegResourceMappingOfficeVisitorType = models.CONFIGURED_FOR_TYPE_ENUM.OFFICE_VISITOR_CONFIGURATION;
2646
+ extractGenerateCredentialsForVisitorValue(config3) {
2647
+ if (!config3 || typeof config3 !== "object") {
2648
+ return void 0;
2649
+ }
2650
+ const integrationConfig = config3.integrationConfig;
2651
+ const value = integrationConfig?.[this.generateVisitorCredentialConfigKey];
2652
+ return typeof value === "boolean" ? value : void 0;
2653
+ }
2654
+ async syncVisitorCredentialMapping(input) {
2655
+ const isGenerateCredentialEnabled = Boolean(input.isGenerateCredentialsForVisitorEnabled);
2656
+ if (!isGenerateCredentialEnabled && input.createOnly) {
2657
+ return;
2658
+ }
2659
+ const officeVisitorConfigProfile = await input.db.query.officeVisitorConfigProfile.findFirst({
2660
+ where: and(eq(dvssBackendModuleDatastore.schema.officeVisitorConfigProfile.projectId, input.projectId), isNull(dvssBackendModuleDatastore.schema.officeVisitorConfigProfile.deletedAt))
2661
+ });
2662
+ if (!officeVisitorConfigProfile) {
2663
+ return;
2664
+ }
2665
+ const capIntegResourceMapping = await input.db.query.capIntegResourceMapping.findFirst({
2666
+ where: and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, this.capIntegResourceMappingOfficeVisitorType), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, officeVisitorConfigProfile.id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))
2667
+ });
2668
+ const currentConfig = capIntegResourceMapping?.config;
2669
+ const isCurrentGenerateCredentialEnabled = currentConfig?.generateCredential === true;
2670
+ if (capIntegResourceMapping) {
2671
+ if (isCurrentGenerateCredentialEnabled !== isGenerateCredentialEnabled) {
2672
+ await input.db.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
2673
+ config: {
2674
+ generateCredential: isGenerateCredentialEnabled
2675
+ },
2676
+ updatedAt: /* @__PURE__ */ new Date(),
2677
+ updatedBy: input.loggedInUserId
2678
+ }).where(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, capIntegResourceMapping.id));
2679
+ }
2680
+ return;
2681
+ }
2682
+ if (!isGenerateCredentialEnabled) {
2683
+ return;
2684
+ }
2685
+ await input.db.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values({
2686
+ projectId: input.projectId,
2687
+ configuredForId: officeVisitorConfigProfile.id,
2688
+ configuredForType: this.capIntegResourceMappingOfficeVisitorType,
2689
+ capabilityIntegrationId: input.capabilityIntegrationId,
2690
+ config: {
2691
+ generateCredential: true
2692
+ },
2693
+ createdBy: input.loggedInUserId,
2694
+ status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE
2695
+ });
2696
+ }
2697
+ };
2698
+
2699
+ // ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-configuration.dao.ts
2700
+ function _ts_decorate13(decorators, target, key, desc2) {
2701
+ var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2702
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2703
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2704
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2705
+ }
2706
+ __name(_ts_decorate13, "_ts_decorate");
2707
+ function _ts_metadata10(k, v) {
2708
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2709
+ }
2710
+ __name(_ts_metadata10, "_ts_metadata");
2711
+ function _ts_param4(paramIndex, decorator) {
2712
+ return function(target, key) {
2713
+ decorator(target, key, paramIndex);
2714
+ };
2715
+ }
2716
+ __name(_ts_param4, "_ts_param");
2497
2717
  exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
2498
2718
  static {
2499
2719
  __name(this, "IntegrationConfigurationDao");
2500
2720
  }
2501
2721
  conn;
2502
2722
  logger;
2723
+ integrationSubcapabilityDao;
2503
2724
  fileName = "integration-configuration.dao";
2504
- constructor(conn, logger) {
2725
+ integrationVisitorCredentialMappingDao = new IntegrationVisitorCredentialMappingDao();
2726
+ constructor(conn, logger, integrationSubcapabilityDao) {
2505
2727
  this.conn = conn;
2506
2728
  this.logger = logger;
2729
+ this.integrationSubcapabilityDao = integrationSubcapabilityDao;
2507
2730
  }
2508
2731
  async addCapabilityIntegration(input, loggedInUserId) {
2509
2732
  this.logger.info(loggedInUserId, this.addCapabilityIntegration.name, this.fileName, `CapabilityDaoService -> addCapabilityIntegration called`);
2510
2733
  try {
2511
2734
  return this.conn.transaction(async (tx) => {
2512
- const [integrationResult] = await tx.insert(dvssBackendModuleDatastore.schema.capabilityIntegration).values(input).$returningId();
2735
+ const { configuredFor, resourceMappings, ...capabilityIntegrationInsertInput } = input;
2736
+ const [integrationResult] = await tx.insert(dvssBackendModuleDatastore.schema.capabilityIntegration).values(capabilityIntegrationInsertInput).$returningId();
2513
2737
  if (!integrationResult.id) {
2514
2738
  tx.rollback();
2515
2739
  return;
2516
2740
  }
2517
- if (input.configuredFor) {
2741
+ if (resourceMappings?.length) {
2742
+ for (const mapping of resourceMappings) {
2743
+ const insertData = {
2744
+ capabilityIntegrationId: integrationResult.id,
2745
+ configuredForId: mapping.configuredForId,
2746
+ configuredForType: mapping.configuredForType,
2747
+ status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE,
2748
+ projectId: input.projectId,
2749
+ config: mapping.config ?? void 0,
2750
+ createdAt: /* @__PURE__ */ new Date(),
2751
+ createdBy: loggedInUserId
2752
+ };
2753
+ await tx.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values(insertData);
2754
+ }
2755
+ } else if (configuredFor) {
2518
2756
  const insertData = {
2519
2757
  capabilityIntegrationId: integrationResult.id,
2520
- configuredForId: input.configuredFor.configuredForId,
2521
- configuredForType: input.configuredFor.configuredForType,
2758
+ configuredForId: configuredFor.configuredForId,
2759
+ configuredForType: configuredFor.configuredForType,
2522
2760
  status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE,
2523
2761
  projectId: input.projectId,
2524
2762
  createdAt: /* @__PURE__ */ new Date(),
@@ -2526,6 +2764,29 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
2526
2764
  };
2527
2765
  await tx.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values(insertData);
2528
2766
  }
2767
+ const subcapabilities = await this.integrationSubcapabilityDao.getSubcapabilities({
2768
+ capabilityId: input.capabilityId
2769
+ }, loggedInUserId);
2770
+ this.logger.info(loggedInUserId, this.addCapabilityIntegration.name, this.fileName, `Subcapabilities ${subcapabilities.length} found for capabilityIntegrationId: ${integrationResult.id}`);
2771
+ for (const subcapability of subcapabilities) {
2772
+ const insertData = {
2773
+ capabilityIntegrationId: integrationResult.id,
2774
+ subcapabilityId: subcapability.id,
2775
+ projectId: input.projectId,
2776
+ createdAt: /* @__PURE__ */ new Date(),
2777
+ createdBy: loggedInUserId,
2778
+ status: capabilityIntegration_model.CAP_INTEG_SUBCAPABILITY_MAPPING_STATUS_ENUM.ACTIVE
2779
+ };
2780
+ await tx.insert(dvssBackendModuleDatastore.schema.capIntegSubcapabilityMapping).values(insertData);
2781
+ }
2782
+ await this.integrationVisitorCredentialMappingDao.syncVisitorCredentialMapping({
2783
+ db: tx,
2784
+ capabilityIntegrationId: integrationResult.id,
2785
+ projectId: input.projectId,
2786
+ isGenerateCredentialsForVisitorEnabled: this.integrationVisitorCredentialMappingDao.extractGenerateCredentialsForVisitorValue(input.config),
2787
+ loggedInUserId,
2788
+ createOnly: true
2789
+ });
2529
2790
  return {
2530
2791
  id: integrationResult.id
2531
2792
  };
@@ -2589,6 +2850,17 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
2589
2850
  const response = await this.conn.update(dvssBackendModuleDatastore.schema.capabilityIntegration).set({
2590
2851
  ...input.updateData
2591
2852
  }).where(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.id));
2853
+ const isGenerateCredentialsForVisitorEnabled = this.integrationVisitorCredentialMappingDao.extractGenerateCredentialsForVisitorValue(input.updateData.config);
2854
+ if (typeof isGenerateCredentialsForVisitorEnabled === "boolean") {
2855
+ await this.integrationVisitorCredentialMappingDao.syncVisitorCredentialMapping({
2856
+ db: this.conn,
2857
+ capabilityIntegrationId: input.id,
2858
+ projectId: input.projectId,
2859
+ isGenerateCredentialsForVisitorEnabled,
2860
+ loggedInUserId,
2861
+ createOnly: false
2862
+ });
2863
+ }
2592
2864
  return {
2593
2865
  status: response[0].affectedRows > 0
2594
2866
  };
@@ -2597,6 +2869,71 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
2597
2869
  throw error;
2598
2870
  }
2599
2871
  }
2872
+ /**
2873
+ * Replace cap_integ_resource_mapping rows for the given capabilityIntegrationId and configuredForTypes.
2874
+ * Upsert semantics: delete existing rows first, then insert the provided mappings.
2875
+ */
2876
+ async syncCapabilityIntegrationResourceMappings(input, loggedInUserId) {
2877
+ try {
2878
+ if (input.resourceMappings.length === 0) {
2879
+ return {
2880
+ status: true
2881
+ };
2882
+ }
2883
+ const inputMap = /* @__PURE__ */ new Map();
2884
+ for (const m of input.resourceMappings) {
2885
+ inputMap.set(`${m.configuredForId}:${m.configuredForType}`, m);
2886
+ }
2887
+ const inputKeys = new Set(inputMap.keys());
2888
+ return await this.conn.transaction(async (tx) => {
2889
+ const existing = await tx.select({
2890
+ id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
2891
+ configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
2892
+ configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType
2893
+ }).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, input.projectId), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)));
2894
+ const existingMap = /* @__PURE__ */ new Map();
2895
+ for (const e of existing) {
2896
+ existingMap.set(`${e.configuredForId}:${e.configuredForType}`, e);
2897
+ }
2898
+ const toDeleteIds = [];
2899
+ for (const [key, value] of existingMap.entries()) {
2900
+ if (!inputKeys.has(key)) {
2901
+ toDeleteIds.push(value.id);
2902
+ }
2903
+ }
2904
+ const toInsert = [];
2905
+ for (const [key, mapping] of inputMap.entries()) {
2906
+ if (!existingMap.has(key)) {
2907
+ toInsert.push({
2908
+ capabilityIntegrationId: input.capabilityIntegrationId,
2909
+ configuredForId: mapping.configuredForId,
2910
+ configuredForType: mapping.configuredForType,
2911
+ status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE,
2912
+ projectId: input.projectId,
2913
+ config: mapping.config ?? void 0,
2914
+ createdAt: /* @__PURE__ */ new Date(),
2915
+ createdBy: loggedInUserId
2916
+ });
2917
+ }
2918
+ }
2919
+ if (toDeleteIds.length > 0) {
2920
+ await tx.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
2921
+ deletedAt: /* @__PURE__ */ new Date(),
2922
+ deletedBy: loggedInUserId
2923
+ }).where(inArray(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, toDeleteIds));
2924
+ }
2925
+ if (toInsert.length > 0) {
2926
+ await tx.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values(toInsert);
2927
+ }
2928
+ return {
2929
+ status: true
2930
+ };
2931
+ });
2932
+ } catch (error) {
2933
+ this.logger.error(loggedInUserId, this.syncCapabilityIntegrationResourceMappings.name, this.fileName, "Error syncing capability integration resource mappings", error, input);
2934
+ throw error;
2935
+ }
2936
+ }
2600
2937
  /**
2601
2938
  * Get capability integration by id (for parent validation when parentId is set).
2602
2939
  * Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegration.
@@ -2805,80 +3142,16 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
2805
3142
  }
2806
3143
  }
2807
3144
  };
2808
- exports.IntegrationConfigurationDao = _ts_decorate12([
2809
- common.Injectable(),
2810
- _ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2811
- _ts_metadata9("design:type", Function),
2812
- _ts_metadata9("design:paramtypes", [
2813
- typeof MySql2Database === "undefined" ? Object : MySql2Database,
2814
- typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
2815
- ])
2816
- ], exports.IntegrationConfigurationDao);
2817
- function _ts_decorate13(decorators, target, key, desc2) {
2818
- var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2819
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2820
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2821
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2822
- }
2823
- __name(_ts_decorate13, "_ts_decorate");
2824
- function _ts_metadata10(k, v) {
2825
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2826
- }
2827
- __name(_ts_metadata10, "_ts_metadata");
2828
- function _ts_param4(paramIndex, decorator) {
2829
- return function(target, key) {
2830
- decorator(target, key, paramIndex);
2831
- };
2832
- }
2833
- __name(_ts_param4, "_ts_param");
2834
- exports.IntegrationSubcapabilityDao = class IntegrationSubcapabilityDao {
2835
- static {
2836
- __name(this, "IntegrationSubcapabilityDao");
2837
- }
2838
- conn;
2839
- logger;
2840
- fileName = "integration-subcapability.dao";
2841
- constructor(conn, logger) {
2842
- this.conn = conn;
2843
- this.logger = logger;
2844
- }
2845
- /**
2846
- * Returns subcapability id for given capabilityId and subcapability name.
2847
- * Enforces uniqueness: if more than one active row is found, throws an error.
2848
- * If no active row is found, returns undefined (caller decides how to handle).
2849
- */
2850
- async getSubcapabilityId(input, loggedInUserId) {
2851
- this.logger.info(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "IntegrationSubcapabilityDao -> getSubcapabilityId called", {
2852
- input
2853
- });
2854
- try {
2855
- const rows = await this.conn.query.subcapability.findMany({
2856
- where: and(eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), eq(dvssBackendModuleDatastore.schema.subcapability.name, input.name), isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
2857
- });
2858
- if (rows.length === 0) {
2859
- this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Subcapability not found for given capabilityId and name", {
2860
- input
2861
- });
2862
- return void 0;
2863
- }
2864
- return rows[0].id;
2865
- } catch (error) {
2866
- this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Error in getSubcapabilityId", error, {
2867
- input
2868
- });
2869
- throw error;
2870
- }
2871
- }
2872
- };
2873
- exports.IntegrationSubcapabilityDao = _ts_decorate13([
3145
+ exports.IntegrationConfigurationDao = _ts_decorate13([
2874
3146
  common.Injectable(),
2875
3147
  _ts_param4(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2876
3148
  _ts_metadata10("design:type", Function),
2877
3149
  _ts_metadata10("design:paramtypes", [
2878
3150
  typeof MySql2Database === "undefined" ? Object : MySql2Database,
2879
- typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
3151
+ typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
3152
+ typeof exports.IntegrationSubcapabilityDao === "undefined" ? Object : exports.IntegrationSubcapabilityDao
2880
3153
  ])
2881
- ], exports.IntegrationSubcapabilityDao);
3154
+ ], exports.IntegrationConfigurationDao);
2882
3155
  function _ts_decorate14(decorators, target, key, desc2) {
2883
3156
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2884
3157
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
@@ -3577,6 +3850,71 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
3577
3850
  throw error;
3578
3851
  }
3579
3852
  }
3853
+ async init(configuration, credentials) {
3854
+ this.logger.info(dvssBackendModuleUtility.SYSTEM_USER_ID, this.init.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.init.name} Called`, {
3855
+ configuration,
3856
+ credentials
3857
+ });
3858
+ throw new dvssBackendModuleUtility.CustomException(" init method is not implemented for TrybeCustomerManagement");
3859
+ }
3860
+ async fetchPage(url, loggedInUserId, items) {
3861
+ this.logger.info(loggedInUserId, this.fetchPage.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.fetchPage.name} Called`, {
3862
+ url,
3863
+ items
3864
+ });
3865
+ throw new dvssBackendModuleUtility.CustomException(" fetchPage method is not implemented for TrybeCustomerManagement");
3866
+ }
3867
+ async listCustomers(request, loggedInUserId) {
3868
+ this.logger.info(loggedInUserId, this.listCustomers.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.listCustomers.name} Called`, {
3869
+ request
3870
+ });
3871
+ throw new dvssBackendModuleUtility.CustomException(" listCustomers method is not implemented for TrybeCustomerManagement");
3872
+ }
3873
+ async getCustomer(request, userId, loggedInUserId) {
3874
+ this.logger.info(loggedInUserId, this.getCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.getCustomer.name} Called`, {
3875
+ request,
3876
+ userId
3877
+ });
3878
+ throw new dvssBackendModuleUtility.CustomException(" getCustomer method is not implemented for TrybeCustomerManagement");
3879
+ }
3880
+ async getCustomerByEmail(request, loggedInUserId) {
3881
+ this.logger.info(loggedInUserId, this.getCustomerByEmail.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.getCustomerByEmail.name} Called`, {
3882
+ request
3883
+ });
3884
+ throw new dvssBackendModuleUtility.CustomException(" getCustomerByEmail method is not implemented for TrybeCustomerManagement");
3885
+ }
3886
+ async addCustomerToAccessGroup(request, userId, loggedInUserId) {
3887
+ this.logger.info(loggedInUserId, this.addCustomerToAccessGroup.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.addCustomerToAccessGroup.name} Called`, {
3888
+ request,
3889
+ userId
3890
+ });
3891
+ throw new dvssBackendModuleUtility.CustomException(" addCustomerToAccessGroup method is not implemented for TrybeCustomerManagement");
3892
+ }
3893
+ async removeCustomerFromAccessGroup(request, userId, loggedInUserId) {
3894
+ this.logger.info(loggedInUserId, this.removeCustomerFromAccessGroup.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.removeCustomerFromAccessGroup.name} Called`, {
3895
+ request,
3896
+ userId
3897
+ });
3898
+ throw new dvssBackendModuleUtility.CustomException(" removeCustomerFromAccessGroup method is not implemented for TrybeCustomerManagement");
3899
+ }
3900
+ async resendInviteToCustomer(request, loggedInUserId) {
3901
+ this.logger.info(loggedInUserId, this.resendInviteToCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.resendInviteToCustomer.name} Called`, {
3902
+ request
3903
+ });
3904
+ throw new dvssBackendModuleUtility.CustomException(" resendInviteToCustomer method is not implemented for TrybeCustomerManagement");
3905
+ }
3906
+ async addCustomerToExistingSite(request, loggedInUserId) {
3907
+ this.logger.info(loggedInUserId, this.addCustomerToExistingSite.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.addCustomerToExistingSite.name} Called`, {
3908
+ request
3909
+ });
3910
+ throw new dvssBackendModuleUtility.CustomException(" addCustomerToExistingSite method is not implemented for TrybeCustomerManagement");
3911
+ }
3912
+ async getCustomerAccessGroups(request, loggedInUserId) {
3913
+ this.logger.info(loggedInUserId, this.getCustomerAccessGroups.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.getCustomerAccessGroups.name} Called`, {
3914
+ request
3915
+ });
3916
+ throw new dvssBackendModuleUtility.CustomException(" getCustomerAccessGroups method is not implemented for TrybeCustomerManagement");
3917
+ }
3580
3918
  };
3581
3919
  exports.TrybeCustomerManagement = _ts_decorate21([
3582
3920
  common.Injectable(),
@@ -5541,6 +5879,7 @@ exports.IntegrationTrybeModule = _ts_decorate28([
5541
5879
  exports.TrybeWebhookUtilService,
5542
5880
  exports.IntegrationBookingDao,
5543
5881
  exports.IntegrationConfigurationDao,
5882
+ exports.IntegrationSubcapabilityDao,
5544
5883
  exports.IntegrationResourceManagementDao,
5545
5884
  exports.IntegrationCommonDao,
5546
5885
  exports.IntegrationRequestLoggerService,
@@ -5599,6 +5938,7 @@ exports.OfferingIntegrationManager = _ts_decorate29([
5599
5938
 
5600
5939
  exports.BOOKABLE_ITEM_STATUS_ENUM = BOOKABLE_ITEM_STATUS_ENUM;
5601
5940
  exports.BOOKABLE_ITEM_TYPE_ENUM = BOOKABLE_ITEM_TYPE_ENUM;
5941
+ exports.BaseAccessManagement = BaseAccessManagement;
5602
5942
  exports.BaseAccountingContactManagement = BaseAccountingContactManagement;
5603
5943
  exports.BaseAccountingCreditNoteManagement = BaseAccountingCreditNoteManagement;
5604
5944
  exports.BaseAccountingCustomerManagement = BaseAccountingCustomerManagement;
@@ -5609,6 +5949,7 @@ exports.BaseAccountingTaxManagement = BaseAccountingTaxManagement;
5609
5949
  exports.BaseAuth = BaseAuth;
5610
5950
  exports.BaseCreditBooking = BaseCreditBooking;
5611
5951
  exports.BaseCustomerManagement = BaseCustomerManagement;
5952
+ exports.BaseDeviceManagement = BaseDeviceManagement;
5612
5953
  exports.BaseIntegrationResourceManagement = BaseIntegrationResourceManagement;
5613
5954
  exports.BaseMembershipCustomerManagement = BaseMembershipCustomerManagement;
5614
5955
  exports.BaseMembershipManagement = BaseMembershipManagement;
@@ -5621,7 +5962,7 @@ exports.CREDIT_FILTER_BY_ENUM = CREDIT_FILTER_BY_ENUM;
5621
5962
  exports.CREDIT_STATUS_ENUM = CREDIT_STATUS_ENUM;
5622
5963
  exports.CREDIT_TYPE_ENUM = CREDIT_TYPE_ENUM;
5623
5964
  exports.HTTP_METHOD = HTTP_METHOD;
5624
- exports.INTEGRATION_PROVIDER_ENUM = INTEGRATION_PROVIDER_ENUM;
5965
+ exports.IntegrationVisitorCredentialMappingDao = IntegrationVisitorCredentialMappingDao;
5625
5966
  exports.OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS;
5626
5967
  exports.TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY = TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY;
5627
5968
  exports.TRYBE_CATALOGING_BY_ENUM = TRYBE_CATALOGING_BY_ENUM;