@dv4resi/dvss-backend-module-offering-im 0.0.16 → 0.0.18

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
@@ -1,17 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  var common = require('@nestjs/common');
4
- var dotenv = require('dotenv');
5
- var path = require('path');
4
+ var dvssBackendModuleDatastore = require('@dv4resi/dvss-backend-module-datastore');
6
5
  var dvssBackendModuleUtility = require('@dv4resi/dvss-backend-module-utility');
7
6
  var axios = require('@nestjs/axios');
8
7
  var config = require('@nestjs/config');
8
+ var path = require('path');
9
9
  var rxjs = require('rxjs');
10
+ var dotenv = require('dotenv');
10
11
  var models = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models');
11
- var dvssBackendModuleDatastore = require('@dv4resi/dvss-backend-module-datastore');
12
12
  var common_enum = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/commons/common.enum');
13
13
  var capabilityIntegration_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability-integration.model');
14
14
  var capability_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability.model');
15
+ var luxonDate_util = require('@dv4resi/dvss-backend-module-utility/dist/common/utils/luxon-date.util');
15
16
 
16
17
  var __defProp = Object.defineProperty;
17
18
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -79,10 +80,6 @@ AppController = _ts_decorate2([
79
80
  typeof AppService === "undefined" ? Object : AppService
80
81
  ])
81
82
  ], AppController);
82
- var rootEnvPath = path.resolve(__dirname, "../../../.env");
83
- dotenv.config({
84
- path: rootEnvPath
85
- });
86
83
  function _ts_decorate3(decorators, target, key, desc2) {
87
84
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
88
85
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
@@ -90,31 +87,19 @@ function _ts_decorate3(decorators, target, key, desc2) {
90
87
  return c > 3 && r && Object.defineProperty(target, key, r), r;
91
88
  }
92
89
  __name(_ts_decorate3, "_ts_decorate");
93
- function _ts_metadata3(k, v) {
94
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
95
- }
96
- __name(_ts_metadata3, "_ts_metadata");
97
90
  var AppService2 = class {
98
91
  static {
99
92
  __name(this, "AppService");
100
93
  }
101
- /**
102
- * Creates an instance of the app service
103
- */
104
- constructor() {
105
- }
106
94
  getHello() {
107
- console.log(`${this.constructor.name}::getHello`);
108
95
  return "Hello World!";
109
96
  }
110
97
  };
111
98
  AppService2 = _ts_decorate3([
112
- common.Injectable(),
113
- _ts_metadata3("design:type", Function),
114
- _ts_metadata3("design:paramtypes", [])
99
+ common.Injectable()
115
100
  ], AppService2);
116
101
 
117
- // ../../packages/dvss-integration-trybe/src/app.controller.ts
102
+ // ../../packages/dvss-integration-libs/src/app.controller.ts
118
103
  function _ts_decorate4(decorators, target, key, desc2) {
119
104
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
120
105
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
@@ -122,10 +107,10 @@ function _ts_decorate4(decorators, target, key, desc2) {
122
107
  return c > 3 && r && Object.defineProperty(target, key, r), r;
123
108
  }
124
109
  __name(_ts_decorate4, "_ts_decorate");
125
- function _ts_metadata4(k, v) {
110
+ function _ts_metadata3(k, v) {
126
111
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
127
112
  }
128
- __name(_ts_metadata4, "_ts_metadata");
113
+ __name(_ts_metadata3, "_ts_metadata");
129
114
  var AppController2 = class {
130
115
  static {
131
116
  __name(this, "AppController");
@@ -139,74 +124,18 @@ var AppController2 = class {
139
124
  }
140
125
  };
141
126
  _ts_decorate4([
142
- common.Get("integration-trybe"),
143
- _ts_metadata4("design:type", Function),
144
- _ts_metadata4("design:paramtypes", []),
145
- _ts_metadata4("design:returntype", String)
127
+ common.Get("integration-libs"),
128
+ _ts_metadata3("design:type", Function),
129
+ _ts_metadata3("design:paramtypes", []),
130
+ _ts_metadata3("design:returntype", String)
146
131
  ], AppController2.prototype, "getHello", null);
147
132
  AppController2 = _ts_decorate4([
148
133
  common.Controller(),
149
- _ts_metadata4("design:type", Function),
150
- _ts_metadata4("design:paramtypes", [
134
+ _ts_metadata3("design:type", Function),
135
+ _ts_metadata3("design:paramtypes", [
151
136
  typeof AppService2 === "undefined" ? Object : AppService2
152
137
  ])
153
138
  ], AppController2);
154
- function _ts_decorate5(decorators, target, key, desc2) {
155
- var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
156
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
157
- 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;
158
- return c > 3 && r && Object.defineProperty(target, key, r), r;
159
- }
160
- __name(_ts_decorate5, "_ts_decorate");
161
- var AppService3 = class {
162
- static {
163
- __name(this, "AppService");
164
- }
165
- getHello() {
166
- return "Hello World!";
167
- }
168
- };
169
- AppService3 = _ts_decorate5([
170
- common.Injectable()
171
- ], AppService3);
172
-
173
- // ../../packages/dvss-integration-libs/src/app.controller.ts
174
- function _ts_decorate6(decorators, target, key, desc2) {
175
- var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
176
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
177
- 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;
178
- return c > 3 && r && Object.defineProperty(target, key, r), r;
179
- }
180
- __name(_ts_decorate6, "_ts_decorate");
181
- function _ts_metadata5(k, v) {
182
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
183
- }
184
- __name(_ts_metadata5, "_ts_metadata");
185
- var AppController3 = class {
186
- static {
187
- __name(this, "AppController");
188
- }
189
- appService;
190
- constructor(appService) {
191
- this.appService = appService;
192
- }
193
- getHello() {
194
- return this.appService.getHello();
195
- }
196
- };
197
- _ts_decorate6([
198
- common.Get("integration-libs"),
199
- _ts_metadata5("design:type", Function),
200
- _ts_metadata5("design:paramtypes", []),
201
- _ts_metadata5("design:returntype", String)
202
- ], AppController3.prototype, "getHello", null);
203
- AppController3 = _ts_decorate6([
204
- common.Controller(),
205
- _ts_metadata5("design:type", Function),
206
- _ts_metadata5("design:paramtypes", [
207
- typeof AppService3 === "undefined" ? Object : AppService3
208
- ])
209
- ], AppController3);
210
139
 
211
140
  // ../../packages/dvss-integration-libs/src/integration-traffic-router/constants/http.constant.ts
212
141
  var HTTP_METHOD = /* @__PURE__ */ (function(HTTP_METHOD2) {
@@ -217,17 +146,17 @@ var HTTP_METHOD = /* @__PURE__ */ (function(HTTP_METHOD2) {
217
146
  HTTP_METHOD2["PATCH"] = "PATCH";
218
147
  return HTTP_METHOD2;
219
148
  })({});
220
- function _ts_decorate7(decorators, target, key, desc2) {
149
+ function _ts_decorate5(decorators, target, key, desc2) {
221
150
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
222
151
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
223
152
  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;
224
153
  return c > 3 && r && Object.defineProperty(target, key, r), r;
225
154
  }
226
- __name(_ts_decorate7, "_ts_decorate");
227
- function _ts_metadata6(k, v) {
155
+ __name(_ts_decorate5, "_ts_decorate");
156
+ function _ts_metadata4(k, v) {
228
157
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
229
158
  }
230
- __name(_ts_metadata6, "_ts_metadata");
159
+ __name(_ts_metadata4, "_ts_metadata");
231
160
  exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService {
232
161
  static {
233
162
  __name(this, "IntegrationRequestLoggerService");
@@ -304,20 +233,20 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
304
233
  }
305
234
  }
306
235
  };
307
- exports.IntegrationRequestLoggerService = _ts_decorate7([
236
+ exports.IntegrationRequestLoggerService = _ts_decorate5([
308
237
  common.Injectable(),
309
- _ts_metadata6("design:type", Function),
310
- _ts_metadata6("design:paramtypes", [
238
+ _ts_metadata4("design:type", Function),
239
+ _ts_metadata4("design:paramtypes", [
311
240
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
312
241
  ])
313
242
  ], exports.IntegrationRequestLoggerService);
314
- function _ts_decorate8(decorators, target, key, desc2) {
243
+ function _ts_decorate6(decorators, target, key, desc2) {
315
244
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
316
245
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
317
246
  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;
318
247
  return c > 3 && r && Object.defineProperty(target, key, r), r;
319
248
  }
320
- __name(_ts_decorate8, "_ts_decorate");
249
+ __name(_ts_decorate6, "_ts_decorate");
321
250
  exports.RateLimiterService = class RateLimiterService {
322
251
  static {
323
252
  __name(this, "RateLimiterService");
@@ -330,22 +259,22 @@ exports.RateLimiterService = class RateLimiterService {
330
259
  async validateAndEnforceRateLimit() {
331
260
  }
332
261
  };
333
- exports.RateLimiterService = _ts_decorate8([
262
+ exports.RateLimiterService = _ts_decorate6([
334
263
  common.Injectable()
335
264
  ], exports.RateLimiterService);
336
265
 
337
266
  // ../../packages/dvss-integration-libs/src/integration-traffic-router/gateway/traffic-gateway.service.ts
338
- function _ts_decorate9(decorators, target, key, desc2) {
267
+ function _ts_decorate7(decorators, target, key, desc2) {
339
268
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
340
269
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
341
270
  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;
342
271
  return c > 3 && r && Object.defineProperty(target, key, r), r;
343
272
  }
344
- __name(_ts_decorate9, "_ts_decorate");
345
- function _ts_metadata7(k, v) {
273
+ __name(_ts_decorate7, "_ts_decorate");
274
+ function _ts_metadata5(k, v) {
346
275
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
347
276
  }
348
- __name(_ts_metadata7, "_ts_metadata");
277
+ __name(_ts_metadata5, "_ts_metadata");
349
278
  exports.TrafficGatewayService = class TrafficGatewayService {
350
279
  static {
351
280
  __name(this, "TrafficGatewayService");
@@ -540,34 +469,34 @@ exports.TrafficGatewayService = class TrafficGatewayService {
540
469
  };
541
470
  }
542
471
  };
543
- exports.TrafficGatewayService = _ts_decorate9([
472
+ exports.TrafficGatewayService = _ts_decorate7([
544
473
  common.Injectable(),
545
- _ts_metadata7("design:type", Function),
546
- _ts_metadata7("design:paramtypes", [
474
+ _ts_metadata5("design:type", Function),
475
+ _ts_metadata5("design:paramtypes", [
547
476
  typeof axios.HttpService === "undefined" ? Object : axios.HttpService,
548
477
  typeof exports.IntegrationRequestLoggerService === "undefined" ? Object : exports.IntegrationRequestLoggerService,
549
478
  typeof exports.RateLimiterService === "undefined" ? Object : exports.RateLimiterService
550
479
  ])
551
480
  ], exports.TrafficGatewayService);
552
- var rootEnvPath2 = path.resolve(__dirname, "../../../.env");
481
+ var rootEnvPath = path.resolve(__dirname, "../../../.env");
553
482
  dotenv.config({
554
- path: rootEnvPath2
483
+ path: rootEnvPath
555
484
  });
556
485
 
557
486
  // ../../packages/dvss-integration-libs/src/app.module.ts
558
- function _ts_decorate10(decorators, target, key, desc2) {
487
+ function _ts_decorate8(decorators, target, key, desc2) {
559
488
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
560
489
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
561
490
  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;
562
491
  return c > 3 && r && Object.defineProperty(target, key, r), r;
563
492
  }
564
- __name(_ts_decorate10, "_ts_decorate");
493
+ __name(_ts_decorate8, "_ts_decorate");
565
494
  exports.IntegrationLibsModule = class AppModule {
566
495
  static {
567
496
  __name(this, "AppModule");
568
497
  }
569
498
  };
570
- exports.IntegrationLibsModule = _ts_decorate10([
499
+ exports.IntegrationLibsModule = _ts_decorate8([
571
500
  common.Module({
572
501
  imports: [
573
502
  // Load environment variables from root .env file
@@ -579,10 +508,10 @@ exports.IntegrationLibsModule = _ts_decorate10([
579
508
  dvssBackendModuleUtility.LoggerModule
580
509
  ],
581
510
  controllers: [
582
- AppController3
511
+ AppController2
583
512
  ],
584
513
  providers: [
585
- AppService3,
514
+ AppService2,
586
515
  exports.TrafficGatewayService,
587
516
  exports.IntegrationRequestLoggerService,
588
517
  exports.RateLimiterService
@@ -754,17 +683,17 @@ var BaseMembershipManagement = class {
754
683
  __name(this, "BaseMembershipManagement");
755
684
  }
756
685
  };
757
- function _ts_decorate11(decorators, target, key, desc2) {
686
+ function _ts_decorate9(decorators, target, key, desc2) {
758
687
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
759
688
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
760
689
  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;
761
690
  return c > 3 && r && Object.defineProperty(target, key, r), r;
762
691
  }
763
- __name(_ts_decorate11, "_ts_decorate");
764
- function _ts_metadata8(k, v) {
692
+ __name(_ts_decorate9, "_ts_decorate");
693
+ function _ts_metadata6(k, v) {
765
694
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
766
695
  }
767
- __name(_ts_metadata8, "_ts_metadata");
696
+ __name(_ts_metadata6, "_ts_metadata");
768
697
  exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
769
698
  static {
770
699
  __name(this, "BaseIntegrationConfiguration");
@@ -955,10 +884,10 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
955
884
  return integration;
956
885
  }
957
886
  };
958
- exports.BaseIntegrationConfiguration = _ts_decorate11([
887
+ exports.BaseIntegrationConfiguration = _ts_decorate9([
959
888
  common.Injectable(),
960
- _ts_metadata8("design:type", Function),
961
- _ts_metadata8("design:paramtypes", [
889
+ _ts_metadata6("design:type", Function),
890
+ _ts_metadata6("design:paramtypes", [
962
891
  typeof IntegrationConfigurationDao === "undefined" ? Object : IntegrationConfigurationDao,
963
892
  typeof CommonValidationDatabaseService === "undefined" ? Object : CommonValidationDatabaseService,
964
893
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
@@ -1278,9 +1207,9 @@ var Table = class Table2 {
1278
1207
  [IsDrizzleTable] = true;
1279
1208
  /** @internal */
1280
1209
  [ExtraConfigBuilder] = void 0;
1281
- constructor(name, schema3, baseName) {
1210
+ constructor(name, schema4, baseName) {
1282
1211
  this[TableName] = this[OriginalName] = name;
1283
- this[Schema] = schema3;
1212
+ this[Schema] = schema4;
1284
1213
  this[BaseName] = baseName;
1285
1214
  }
1286
1215
  };
@@ -2256,11 +2185,11 @@ var View = class View2 {
2256
2185
  static [entityKind] = "View";
2257
2186
  /** @internal */
2258
2187
  [ViewBaseConfig];
2259
- constructor({ name: name2, schema: schema3, selectedFields, query }) {
2188
+ constructor({ name: name2, schema: schema4, selectedFields, query }) {
2260
2189
  this[ViewBaseConfig] = {
2261
2190
  name: name2,
2262
2191
  originalName: name2,
2263
- schema: schema3,
2192
+ schema: schema4,
2264
2193
  selectedFields,
2265
2194
  query,
2266
2195
  isExisting: !query,
@@ -2355,24 +2284,108 @@ function getTableColumns(table) {
2355
2284
  }
2356
2285
  __name(getTableColumns, "getTableColumns");
2357
2286
 
2358
- // ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-configuration.dao.ts
2359
- function _ts_decorate12(decorators, target, key, desc2) {
2287
+ // ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-common.dao.ts
2288
+ function _ts_decorate10(decorators, target, key, desc2) {
2360
2289
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2361
2290
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2362
2291
  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;
2363
2292
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2364
2293
  }
2365
- __name(_ts_decorate12, "_ts_decorate");
2366
- function _ts_metadata9(k, v) {
2294
+ __name(_ts_decorate10, "_ts_decorate");
2295
+ function _ts_metadata7(k, v) {
2367
2296
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2368
2297
  }
2369
- __name(_ts_metadata9, "_ts_metadata");
2298
+ __name(_ts_metadata7, "_ts_metadata");
2370
2299
  function _ts_param(paramIndex, decorator) {
2371
2300
  return function(target, key) {
2372
2301
  decorator(target, key, paramIndex);
2373
2302
  };
2374
2303
  }
2375
2304
  __name(_ts_param, "_ts_param");
2305
+ exports.IntegrationCommonDao = class IntegrationCommonDao {
2306
+ static {
2307
+ __name(this, "IntegrationCommonDao");
2308
+ }
2309
+ conn;
2310
+ logger;
2311
+ fileName = "integration-common.dao";
2312
+ constructor(conn, logger) {
2313
+ this.conn = conn;
2314
+ this.logger = logger;
2315
+ }
2316
+ /**
2317
+ * Gets timezone using userContext (first propertyId) with fallback to projectId
2318
+ * First tries to get timezone from user's first propertyId, then falls back to projectId
2319
+ * @param input - Object containing projectId and loggedInUserId
2320
+ * @returns Promise resolving to timezone string
2321
+ */
2322
+ async getTimezoneForRequest(input) {
2323
+ const { projectId, loggedInUserId } = input;
2324
+ try {
2325
+ const userBehavior = await this.conn.query.userIdentityBehaviorMapping.findFirst({
2326
+ where: and(eq(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.userIdentityId, loggedInUserId), isNotNull(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.propertyId), isNull(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.deletedAt)),
2327
+ with: {
2328
+ property: true
2329
+ }
2330
+ });
2331
+ if (userBehavior?.propertyId && userBehavior.property?.timezone) {
2332
+ this.logger.info(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Successfully fetched property timezone using userContext", {
2333
+ projectId,
2334
+ loggedInUserId,
2335
+ propertyId: userBehavior.propertyId,
2336
+ timezone: userBehavior.property.timezone
2337
+ });
2338
+ return userBehavior.property.timezone;
2339
+ }
2340
+ if (projectId) {
2341
+ const properties = await this.conn.query.property.findMany({
2342
+ where: and(eq(dvssBackendModuleDatastore.schema.property.projectId, projectId), isNull(dvssBackendModuleDatastore.schema.property.deletedAt)),
2343
+ limit: 1
2344
+ });
2345
+ if (properties.length > 0 && properties[0].timezone) {
2346
+ this.logger.info(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Successfully fetched property timezone using projectId", {
2347
+ projectId,
2348
+ propertyId: properties[0].id,
2349
+ timezone: properties[0].timezone
2350
+ });
2351
+ return properties[0].timezone;
2352
+ }
2353
+ }
2354
+ } catch (error) {
2355
+ this.logger.warn(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Error fetching property timezone, using default", {
2356
+ projectId,
2357
+ error
2358
+ });
2359
+ }
2360
+ return dvssBackendModuleUtility.DEFAULT_TIMEZONE;
2361
+ }
2362
+ };
2363
+ exports.IntegrationCommonDao = _ts_decorate10([
2364
+ common.Injectable(),
2365
+ _ts_param(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2366
+ _ts_metadata7("design:type", Function),
2367
+ _ts_metadata7("design:paramtypes", [
2368
+ typeof MySql2Database === "undefined" ? Object : MySql2Database,
2369
+ typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
2370
+ ])
2371
+ ], exports.IntegrationCommonDao);
2372
+ function _ts_decorate11(decorators, target, key, desc2) {
2373
+ var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2374
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2375
+ 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;
2376
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2377
+ }
2378
+ __name(_ts_decorate11, "_ts_decorate");
2379
+ function _ts_metadata8(k, v) {
2380
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2381
+ }
2382
+ __name(_ts_metadata8, "_ts_metadata");
2383
+ function _ts_param2(paramIndex, decorator) {
2384
+ return function(target, key) {
2385
+ decorator(target, key, paramIndex);
2386
+ };
2387
+ }
2388
+ __name(_ts_param2, "_ts_param");
2376
2389
  exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
2377
2390
  static {
2378
2391
  __name(this, "IntegrationConfigurationDao");
@@ -2682,60 +2695,26 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
2682
2695
  }
2683
2696
  }
2684
2697
  };
2685
- exports.IntegrationConfigurationDao = _ts_decorate12([
2698
+ exports.IntegrationConfigurationDao = _ts_decorate11([
2686
2699
  common.Injectable(),
2687
- _ts_param(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2688
- _ts_metadata9("design:type", Function),
2689
- _ts_metadata9("design:paramtypes", [
2700
+ _ts_param2(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2701
+ _ts_metadata8("design:type", Function),
2702
+ _ts_metadata8("design:paramtypes", [
2690
2703
  typeof MySql2Database === "undefined" ? Object : MySql2Database,
2691
2704
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
2692
2705
  ])
2693
2706
  ], exports.IntegrationConfigurationDao);
2694
- function _ts_decorate13(decorators, target, key, desc2) {
2695
- var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2696
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2697
- 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;
2698
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2699
- }
2700
- __name(_ts_decorate13, "_ts_decorate");
2701
- function _ts_metadata10(k, v) {
2702
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2703
- }
2704
- __name(_ts_metadata10, "_ts_metadata");
2705
- function _ts_param2(paramIndex, decorator) {
2706
- return function(target, key) {
2707
- decorator(target, key, paramIndex);
2708
- };
2709
- }
2710
- __name(_ts_param2, "_ts_param");
2711
- exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
2712
- static {
2713
- __name(this, "IntegrationUserManagementDao");
2714
- }
2715
- conn;
2716
- constructor(conn) {
2717
- this.conn = conn;
2718
- }
2719
- };
2720
- exports.IntegrationUserManagementDao = _ts_decorate13([
2721
- common.Injectable(),
2722
- _ts_param2(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2723
- _ts_metadata10("design:type", Function),
2724
- _ts_metadata10("design:paramtypes", [
2725
- typeof MySql2Database === "undefined" ? Object : MySql2Database
2726
- ])
2727
- ], exports.IntegrationUserManagementDao);
2728
- function _ts_decorate14(decorators, target, key, desc2) {
2707
+ function _ts_decorate12(decorators, target, key, desc2) {
2729
2708
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2730
2709
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2731
2710
  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;
2732
2711
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2733
2712
  }
2734
- __name(_ts_decorate14, "_ts_decorate");
2735
- function _ts_metadata11(k, v) {
2713
+ __name(_ts_decorate12, "_ts_decorate");
2714
+ function _ts_metadata9(k, v) {
2736
2715
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2737
2716
  }
2738
- __name(_ts_metadata11, "_ts_metadata");
2717
+ __name(_ts_metadata9, "_ts_metadata");
2739
2718
  function _ts_param3(paramIndex, decorator) {
2740
2719
  return function(target, key) {
2741
2720
  decorator(target, key, paramIndex);
@@ -2903,30 +2882,132 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
2903
2882
  }
2904
2883
  }
2905
2884
  };
2906
- exports.IntegrationResourceManagementDao = _ts_decorate14([
2885
+ exports.IntegrationResourceManagementDao = _ts_decorate12([
2907
2886
  common.Injectable(),
2908
2887
  _ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2909
- _ts_metadata11("design:type", Function),
2910
- _ts_metadata11("design:paramtypes", [
2888
+ _ts_metadata9("design:type", Function),
2889
+ _ts_metadata9("design:paramtypes", [
2911
2890
  typeof MySql2Database === "undefined" ? Object : MySql2Database,
2912
2891
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
2913
2892
  ])
2914
2893
  ], exports.IntegrationResourceManagementDao);
2915
- function _ts_decorate15(decorators, target, key, desc2) {
2894
+ function _ts_decorate13(decorators, target, key, desc2) {
2916
2895
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2917
2896
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2918
2897
  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;
2919
2898
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2920
2899
  }
2921
- __name(_ts_decorate15, "_ts_decorate");
2922
- function _ts_metadata12(k, v) {
2900
+ __name(_ts_decorate13, "_ts_decorate");
2901
+ function _ts_metadata10(k, v) {
2923
2902
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2924
2903
  }
2925
- __name(_ts_metadata12, "_ts_metadata");
2926
- exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
2927
- static {
2928
- __name(this, "TrybeCustomerManagement");
2929
- }
2904
+ __name(_ts_metadata10, "_ts_metadata");
2905
+ function _ts_param4(paramIndex, decorator) {
2906
+ return function(target, key) {
2907
+ decorator(target, key, paramIndex);
2908
+ };
2909
+ }
2910
+ __name(_ts_param4, "_ts_param");
2911
+ exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
2912
+ static {
2913
+ __name(this, "IntegrationUserManagementDao");
2914
+ }
2915
+ conn;
2916
+ constructor(conn) {
2917
+ this.conn = conn;
2918
+ }
2919
+ };
2920
+ exports.IntegrationUserManagementDao = _ts_decorate13([
2921
+ common.Injectable(),
2922
+ _ts_param4(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
2923
+ _ts_metadata10("design:type", Function),
2924
+ _ts_metadata10("design:paramtypes", [
2925
+ typeof MySql2Database === "undefined" ? Object : MySql2Database
2926
+ ])
2927
+ ], exports.IntegrationUserManagementDao);
2928
+ function _ts_decorate14(decorators, target, key, desc2) {
2929
+ var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2930
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2931
+ 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;
2932
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2933
+ }
2934
+ __name(_ts_decorate14, "_ts_decorate");
2935
+ function _ts_metadata11(k, v) {
2936
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2937
+ }
2938
+ __name(_ts_metadata11, "_ts_metadata");
2939
+ var AppService3 = class {
2940
+ static {
2941
+ __name(this, "AppService");
2942
+ }
2943
+ /**
2944
+ * Creates an instance of the app service
2945
+ */
2946
+ constructor() {
2947
+ }
2948
+ getHello() {
2949
+ console.log(`${this.constructor.name}::getHello`);
2950
+ return "Hello World!";
2951
+ }
2952
+ };
2953
+ AppService3 = _ts_decorate14([
2954
+ common.Injectable(),
2955
+ _ts_metadata11("design:type", Function),
2956
+ _ts_metadata11("design:paramtypes", [])
2957
+ ], AppService3);
2958
+
2959
+ // ../../packages/dvss-integration-trybe/src/app.controller.ts
2960
+ function _ts_decorate15(decorators, target, key, desc2) {
2961
+ var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2962
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2963
+ 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;
2964
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2965
+ }
2966
+ __name(_ts_decorate15, "_ts_decorate");
2967
+ function _ts_metadata12(k, v) {
2968
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2969
+ }
2970
+ __name(_ts_metadata12, "_ts_metadata");
2971
+ var AppController3 = class {
2972
+ static {
2973
+ __name(this, "AppController");
2974
+ }
2975
+ appService;
2976
+ constructor(appService) {
2977
+ this.appService = appService;
2978
+ }
2979
+ getHello() {
2980
+ return this.appService.getHello();
2981
+ }
2982
+ };
2983
+ _ts_decorate15([
2984
+ common.Get("integration-trybe"),
2985
+ _ts_metadata12("design:type", Function),
2986
+ _ts_metadata12("design:paramtypes", []),
2987
+ _ts_metadata12("design:returntype", String)
2988
+ ], AppController3.prototype, "getHello", null);
2989
+ AppController3 = _ts_decorate15([
2990
+ common.Controller(),
2991
+ _ts_metadata12("design:type", Function),
2992
+ _ts_metadata12("design:paramtypes", [
2993
+ typeof AppService3 === "undefined" ? Object : AppService3
2994
+ ])
2995
+ ], AppController3);
2996
+ function _ts_decorate16(decorators, target, key, desc2) {
2997
+ var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
2998
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
2999
+ 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;
3000
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3001
+ }
3002
+ __name(_ts_decorate16, "_ts_decorate");
3003
+ function _ts_metadata13(k, v) {
3004
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3005
+ }
3006
+ __name(_ts_metadata13, "_ts_metadata");
3007
+ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
3008
+ static {
3009
+ __name(this, "TrybeCustomerManagement");
3010
+ }
2930
3011
  logger;
2931
3012
  trafficGatewayService;
2932
3013
  fileName = "customer-management.service";
@@ -3035,10 +3116,10 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
3035
3116
  }
3036
3117
  }
3037
3118
  };
3038
- exports.TrybeCustomerManagement = _ts_decorate15([
3119
+ exports.TrybeCustomerManagement = _ts_decorate16([
3039
3120
  common.Injectable(),
3040
- _ts_metadata12("design:type", Function),
3041
- _ts_metadata12("design:paramtypes", [
3121
+ _ts_metadata13("design:type", Function),
3122
+ _ts_metadata13("design:paramtypes", [
3042
3123
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
3043
3124
  typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
3044
3125
  ])
@@ -3056,17 +3137,17 @@ function isValidHttpUrl(urlString) {
3056
3137
  __name(isValidHttpUrl, "isValidHttpUrl");
3057
3138
 
3058
3139
  // ../../packages/dvss-integration-trybe/src/capabilities/auth/auth.service.ts
3059
- function _ts_decorate16(decorators, target, key, desc2) {
3140
+ function _ts_decorate17(decorators, target, key, desc2) {
3060
3141
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
3061
3142
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
3062
3143
  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;
3063
3144
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3064
3145
  }
3065
- __name(_ts_decorate16, "_ts_decorate");
3066
- function _ts_metadata13(k, v) {
3146
+ __name(_ts_decorate17, "_ts_decorate");
3147
+ function _ts_metadata14(k, v) {
3067
3148
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3068
3149
  }
3069
- __name(_ts_metadata13, "_ts_metadata");
3150
+ __name(_ts_metadata14, "_ts_metadata");
3070
3151
  exports.TrybeAuthService = class _TrybeAuthService {
3071
3152
  static {
3072
3153
  __name(this, "TrybeAuthService");
@@ -3164,10 +3245,10 @@ exports.TrybeAuthService = class _TrybeAuthService {
3164
3245
  throw new Error("Method not implemented.");
3165
3246
  }
3166
3247
  };
3167
- exports.TrybeAuthService = _ts_decorate16([
3248
+ exports.TrybeAuthService = _ts_decorate17([
3168
3249
  common.Injectable(),
3169
- _ts_metadata13("design:type", Function),
3170
- _ts_metadata13("design:paramtypes", [
3250
+ _ts_metadata14("design:type", Function),
3251
+ _ts_metadata14("design:paramtypes", [
3171
3252
  typeof exports.TrybeCustomerManagement === "undefined" ? Object : exports.TrybeCustomerManagement,
3172
3253
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
3173
3254
  ])
@@ -3230,17 +3311,17 @@ function mapTrybeCreditsToSystem(res, integration) {
3230
3311
  __name(mapTrybeCreditsToSystem, "mapTrybeCreditsToSystem");
3231
3312
 
3232
3313
  // ../../packages/dvss-integration-trybe/src/capabilities/credit-management/credit-booking.service.ts
3233
- function _ts_decorate17(decorators, target, key, desc2) {
3314
+ function _ts_decorate18(decorators, target, key, desc2) {
3234
3315
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
3235
3316
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
3236
3317
  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;
3237
3318
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3238
3319
  }
3239
- __name(_ts_decorate17, "_ts_decorate");
3240
- function _ts_metadata14(k, v) {
3320
+ __name(_ts_decorate18, "_ts_decorate");
3321
+ function _ts_metadata15(k, v) {
3241
3322
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3242
3323
  }
3243
- __name(_ts_metadata14, "_ts_metadata");
3324
+ __name(_ts_metadata15, "_ts_metadata");
3244
3325
  exports.TrybeCreditBooking = class _TrybeCreditBooking {
3245
3326
  static {
3246
3327
  __name(this, "TrybeCreditBooking");
@@ -3298,25 +3379,245 @@ exports.TrybeCreditBooking = class _TrybeCreditBooking {
3298
3379
  return mapTrybeCreditsToSystem(raw, validatedIntegration);
3299
3380
  }
3300
3381
  };
3301
- exports.TrybeCreditBooking = _ts_decorate17([
3382
+ exports.TrybeCreditBooking = _ts_decorate18([
3302
3383
  common.Injectable(),
3303
- _ts_metadata14("design:type", Function),
3304
- _ts_metadata14("design:paramtypes", [
3384
+ _ts_metadata15("design:type", Function),
3385
+ _ts_metadata15("design:paramtypes", [
3305
3386
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
3306
3387
  typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
3307
3388
  typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
3308
3389
  ])
3309
- ], exports.TrybeCreditBooking);
3390
+ ], exports.TrybeCreditBooking);
3391
+
3392
+ // ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.mapper.ts
3393
+ function mapTrybeSiteResponseToSystem(response) {
3394
+ return {
3395
+ customPaymentTypes: response.data?.custom_payment_types?.map((paymentType) => ({
3396
+ id: paymentType.id,
3397
+ name: paymentType.name,
3398
+ kind: paymentType.kind
3399
+ }))
3400
+ };
3401
+ }
3402
+ __name(mapTrybeSiteResponseToSystem, "mapTrybeSiteResponseToSystem");
3403
+
3404
+ // ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.service.ts
3405
+ function _ts_decorate19(decorators, target, key, desc2) {
3406
+ var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
3407
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
3408
+ 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;
3409
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3410
+ }
3411
+ __name(_ts_decorate19, "_ts_decorate");
3412
+ function _ts_metadata16(k, v) {
3413
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3414
+ }
3415
+ __name(_ts_metadata16, "_ts_metadata");
3416
+ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends exports.BaseIntegrationConfiguration {
3417
+ static {
3418
+ __name(this, "TrybeIntegrationConfigurationService");
3419
+ }
3420
+ trybeAuthService;
3421
+ trafficGatewayService;
3422
+ constructor(integrationConfigurationDao, commonValidationDatabaseService, logger, trybeAuthService, trafficGatewayService) {
3423
+ super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
3424
+ }
3425
+ /**
3426
+ * Add capability integration: validate Trybe config, then configuredFor (offering), then delegate to base.
3427
+ */
3428
+ async addCapabilityIntegration(input, context) {
3429
+ this.trybeAuthService.validateConfig({
3430
+ config: input.config
3431
+ }, context.loggedInUserId);
3432
+ if (input.configuredFor != null) {
3433
+ await this.validateCapabilityIntegrationConfiguredForInput(input.configuredFor, input.projectId);
3434
+ }
3435
+ return super.addCapabilityIntegration(input, context);
3436
+ }
3437
+ /**
3438
+ * Update capability integration: convert to new signature and delegate to base.
3439
+ */
3440
+ async updateCapabilityIntegration(request, integration, loggedInUserId) {
3441
+ if (request.updateData.config) {
3442
+ this.trybeAuthService.validateConfig({
3443
+ config: request.updateData.config
3444
+ }, loggedInUserId);
3445
+ }
3446
+ return super.updateCapabilityIntegration(request, integration, loggedInUserId);
3447
+ }
3448
+ /**
3449
+ * Validates configuredFor (offering exists and belongs to project). Same as project-ms validateCapabilityIntegrationConfiguredForInput.
3450
+ */
3451
+ async validateCapabilityIntegrationConfiguredForInput(configuredFor, projectId) {
3452
+ if (configuredFor.configuredForType !== models.CONFIGURED_FOR_TYPE_ENUM.OFFERING) {
3453
+ throw new Error(`configuredForType not supported: ${configuredFor.configuredForType}`);
3454
+ }
3455
+ await this.commonValidationDatabaseService.getOffering({
3456
+ offeringId: configuredFor.configuredForId,
3457
+ projectId
3458
+ });
3459
+ }
3460
+ /**
3461
+ * Trybe 3rd party: GET /shop/sites/{siteId} via executeIntegrationRequest.
3462
+ */
3463
+ async getSiteDetailedInformation(integration, loggedInUserId) {
3464
+ const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
3465
+ const siteId = validatedIntegration.config.integrationConfig.siteId;
3466
+ const url = `/shop/sites/${siteId}`;
3467
+ const response = await this.trafficGatewayService.executeIntegrationRequest({
3468
+ apiMethod: HTTP_METHOD.GET,
3469
+ url,
3470
+ baseUrl: validatedIntegration.config.platformConfig.baseUrl,
3471
+ headers: validatedIntegration.headers
3472
+ }, validatedIntegration, loggedInUserId);
3473
+ return mapTrybeSiteResponseToSystem(response);
3474
+ }
3475
+ };
3476
+ exports.TrybeIntegrationConfigurationService = _ts_decorate19([
3477
+ common.Injectable(),
3478
+ _ts_metadata16("design:type", Function),
3479
+ _ts_metadata16("design:paramtypes", [
3480
+ typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
3481
+ typeof dvssBackendModuleDatastore.CommonValidationDatabaseService === "undefined" ? Object : dvssBackendModuleDatastore.CommonValidationDatabaseService,
3482
+ typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
3483
+ typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService,
3484
+ typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
3485
+ ])
3486
+ ], exports.TrybeIntegrationConfigurationService);
3487
+
3488
+ // ../../packages/dvss-integration-trybe/src/models/integration-resource-management.model.ts
3489
+ var TRYBE_SUPPORTED_JOURNEYS_ENUM = /* @__PURE__ */ (function(TRYBE_SUPPORTED_JOURNEYS_ENUM2) {
3490
+ TRYBE_SUPPORTED_JOURNEYS_ENUM2["APPOINTMENT"] = "APPOINTMENT";
3491
+ TRYBE_SUPPORTED_JOURNEYS_ENUM2["SESSION"] = "SESSION";
3492
+ TRYBE_SUPPORTED_JOURNEYS_ENUM2["COURSE"] = "COURSE";
3493
+ return TRYBE_SUPPORTED_JOURNEYS_ENUM2;
3494
+ })({});
3495
+ var TRYBE_CATALOGING_BY_ENUM = /* @__PURE__ */ (function(TRYBE_CATALOGING_BY_ENUM2) {
3496
+ TRYBE_CATALOGING_BY_ENUM2["PEOPLE_RESOURCE"] = "PEOPLE_RESOURCE";
3497
+ return TRYBE_CATALOGING_BY_ENUM2;
3498
+ })({});
3499
+
3500
+ // ../../packages/dvss-integration-trybe/src/capabilities/integration-resource-management/integration-resource-management.service.ts
3501
+ function _ts_decorate20(decorators, target, key, desc2) {
3502
+ var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
3503
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
3504
+ 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;
3505
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3506
+ }
3507
+ __name(_ts_decorate20, "_ts_decorate");
3508
+ function _ts_metadata17(k, v) {
3509
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3510
+ }
3511
+ __name(_ts_metadata17, "_ts_metadata");
3512
+ var OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = "OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS";
3513
+ var VALID_JOURNEY_VALUES = /* @__PURE__ */ new Set([
3514
+ "SESSION",
3515
+ "COURSE",
3516
+ "APPOINTMENT"
3517
+ ]);
3518
+ exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResourceManagementService extends BaseIntegrationResourceManagement {
3519
+ static {
3520
+ __name(this, "TrybeIntegrationResourceManagementService");
3521
+ }
3522
+ constructor(logger, integrationResourceManagementDao) {
3523
+ super(integrationResourceManagementDao, logger);
3524
+ }
3525
+ /**
3526
+ * Validates Trybe resource mapping config (same rules as MS trybe-offering-integration-management.service).
3527
+ * @throws CustomException BAD_REQUEST if config is invalid
3528
+ */
3529
+ validateResourceMappingConfig(config3) {
3530
+ const resourceMappingConfig = config3;
3531
+ if (!resourceMappingConfig.supportedJourneys || resourceMappingConfig.supportedJourneys.length === 0) {
3532
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys required and must be non-empty");
3533
+ }
3534
+ if (!resourceMappingConfig.catalogingBy || // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
3535
+ resourceMappingConfig.catalogingBy !== TRYBE_CATALOGING_BY_ENUM.PEOPLE_RESOURCE) {
3536
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: catalogingBy must be PEOPLE_RESOURCE");
3537
+ }
3538
+ if (!resourceMappingConfig.supportedJourneys.some((journey) => VALID_JOURNEY_VALUES.has(journey))) {
3539
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys must contain at least one of SESSION, COURSE, APPOINTMENT");
3540
+ }
3541
+ if (resourceMappingConfig.supportedJourneys.some((journey) => !VALID_JOURNEY_VALUES.has(journey))) {
3542
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys may only contain SESSION, COURSE, APPOINTMENT");
3543
+ }
3544
+ if (!resourceMappingConfig.paymentType || typeof resourceMappingConfig.paymentType !== "string") {
3545
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: paymentType required and must be a string");
3546
+ }
3547
+ }
3548
+ async addResourceToIntegration(input, context) {
3549
+ if (input.config != null && typeof input.config === "object") {
3550
+ this.validateResourceMappingConfig(input.config);
3551
+ }
3552
+ const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
3553
+ capabilityIntegrationId: input.capabilityIntegrationId,
3554
+ configuredForId: input.offeringId,
3555
+ configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
3556
+ }, context.loggedInUserId);
3557
+ if (isMappingExists) {
3558
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS);
3559
+ }
3560
+ return super.addResourceToIntegration(input, context);
3561
+ }
3562
+ async removeResourceFromIntegration(request, context) {
3563
+ const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
3564
+ capabilityIntegrationId: request.capabilityIntegrationId,
3565
+ configuredForId: request.offeringId,
3566
+ configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
3567
+ }, context.loggedInUserId);
3568
+ if (!isMappingExists) {
3569
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Mapping not found");
3570
+ }
3571
+ return super.removeResourceFromIntegration(request, context);
3572
+ }
3573
+ async updateOfferingIntegrationResourceConfiguration(input, context) {
3574
+ const resourceMapping = await this.integrationResourceManagementDao.getCapabilityIntegrationResourceMappingById(input.id, context.loggedInUserId);
3575
+ if (!resourceMapping) {
3576
+ throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Resource mapping not found");
3577
+ }
3578
+ this.validateResourceMappingConfig(input.config);
3579
+ return await super.updateOfferingIntegrationResourceConfiguration(input, context);
3580
+ }
3581
+ };
3582
+ exports.TrybeIntegrationResourceManagementService = _ts_decorate20([
3583
+ common.Injectable(),
3584
+ _ts_metadata17("design:type", Function),
3585
+ _ts_metadata17("design:paramtypes", [
3586
+ typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
3587
+ typeof exports.IntegrationResourceManagementDao === "undefined" ? Object : exports.IntegrationResourceManagementDao
3588
+ ])
3589
+ ], exports.TrybeIntegrationResourceManagementService);
3310
3590
 
3311
- // ../../packages/dvss-integration-trybe/src/utils/date.util.ts
3312
- function formatDateForTrybe(date, isStartOfDay) {
3591
+ // ../../packages/dvss-integration-trybe/src/models/wellness-management.model.ts
3592
+ var TRYBE_OFFERING_TYPE_ENUM = /* @__PURE__ */ (function(TRYBE_OFFERING_TYPE_ENUM2) {
3593
+ TRYBE_OFFERING_TYPE_ENUM2["APPOINTMENT"] = "APPOINTMENT";
3594
+ TRYBE_OFFERING_TYPE_ENUM2["SESSION"] = "SESSION";
3595
+ TRYBE_OFFERING_TYPE_ENUM2["COURSE"] = "COURSE";
3596
+ return TRYBE_OFFERING_TYPE_ENUM2;
3597
+ })({});
3598
+ var TRYBE_OFFERING_TYPE_API = {
3599
+ APPOINTMENT: "appointment",
3600
+ SESSION: "session",
3601
+ COURSE: "course"
3602
+ };
3603
+ function formatDateForTrybe(date, isStartOfDay, timezone) {
3313
3604
  const year = date.getFullYear();
3314
3605
  const month = String(date.getMonth() + 1).padStart(2, "0");
3315
3606
  const day = String(date.getDate()).padStart(2, "0");
3316
3607
  const hours = isStartOfDay ? "00" : "23";
3317
3608
  const minutes = isStartOfDay ? "00" : "59";
3318
3609
  const seconds = isStartOfDay ? "00" : "59";
3319
- return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}-05:00`;
3610
+ let timezoneOffset;
3611
+ if (timezone) {
3612
+ const offsetMinutes = luxonDate_util.getCurrentOffsetFromTimezone(timezone, date);
3613
+ const offsetHours = Math.floor(Math.abs(offsetMinutes) / 60);
3614
+ const offsetMins = Math.abs(offsetMinutes) % 60;
3615
+ const sign = offsetMinutes >= 0 ? "+" : "-";
3616
+ timezoneOffset = `${sign}${String(offsetHours).padStart(2, "0")}:${String(offsetMins).padStart(2, "0")}`;
3617
+ } else {
3618
+ timezoneOffset = "-05:00";
3619
+ }
3620
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${timezoneOffset}`;
3320
3621
  }
3321
3622
  __name(formatDateForTrybe, "formatDateForTrybe");
3322
3623
  function extractTimeFromIsoString(isoString) {
@@ -3360,31 +3661,6 @@ var fetchAllPages = /* @__PURE__ */ __name(async (firstPageResponse, shouldFetch
3360
3661
  }
3361
3662
  return items;
3362
3663
  }, "fetchAllPages");
3363
-
3364
- // ../../packages/dvss-integration-trybe/src/models/wellness-management.model.ts
3365
- var TRYBE_OFFERING_TYPE_ENUM = /* @__PURE__ */ (function(TRYBE_OFFERING_TYPE_ENUM2) {
3366
- TRYBE_OFFERING_TYPE_ENUM2["APPOINTMENT"] = "APPOINTMENT";
3367
- TRYBE_OFFERING_TYPE_ENUM2["SESSION"] = "SESSION";
3368
- TRYBE_OFFERING_TYPE_ENUM2["COURSE"] = "COURSE";
3369
- return TRYBE_OFFERING_TYPE_ENUM2;
3370
- })({});
3371
- var TRYBE_OFFERING_TYPE_API = {
3372
- APPOINTMENT: "appointment",
3373
- SESSION: "session",
3374
- COURSE: "course"
3375
- };
3376
-
3377
- // ../../packages/dvss-integration-trybe/src/models/integration-resource-management.model.ts
3378
- var TRYBE_SUPPORTED_JOURNEYS_ENUM = /* @__PURE__ */ (function(TRYBE_SUPPORTED_JOURNEYS_ENUM2) {
3379
- TRYBE_SUPPORTED_JOURNEYS_ENUM2["APPOINTMENT"] = "APPOINTMENT";
3380
- TRYBE_SUPPORTED_JOURNEYS_ENUM2["SESSION"] = "SESSION";
3381
- TRYBE_SUPPORTED_JOURNEYS_ENUM2["COURSE"] = "COURSE";
3382
- return TRYBE_SUPPORTED_JOURNEYS_ENUM2;
3383
- })({});
3384
- var TRYBE_CATALOGING_BY_ENUM = /* @__PURE__ */ (function(TRYBE_CATALOGING_BY_ENUM2) {
3385
- TRYBE_CATALOGING_BY_ENUM2["PEOPLE_RESOURCE"] = "PEOPLE_RESOURCE";
3386
- return TRYBE_CATALOGING_BY_ENUM2;
3387
- })({});
3388
3664
  var TRYBE_WEEKDAYS_MAPPING = {
3389
3665
  monday: models.DAY_OF_WEEK.MON,
3390
3666
  tuesday: models.DAY_OF_WEEK.TUE,
@@ -3775,17 +4051,19 @@ function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
3775
4051
  };
3776
4052
  }
3777
4053
  __name(mapTrybeAppointmentAvailabilityToSystemResponse, "mapTrybeAppointmentAvailabilityToSystemResponse");
3778
- function _ts_decorate18(decorators, target, key, desc2) {
4054
+
4055
+ // ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.service.ts
4056
+ function _ts_decorate21(decorators, target, key, desc2) {
3779
4057
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
3780
4058
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
3781
4059
  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;
3782
4060
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3783
4061
  }
3784
- __name(_ts_decorate18, "_ts_decorate");
3785
- function _ts_metadata15(k, v) {
4062
+ __name(_ts_decorate21, "_ts_decorate");
4063
+ function _ts_metadata18(k, v) {
3786
4064
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3787
4065
  }
3788
- __name(_ts_metadata15, "_ts_metadata");
4066
+ __name(_ts_metadata18, "_ts_metadata");
3789
4067
  exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
3790
4068
  static {
3791
4069
  __name(this, "TrybeWellnessManagement");
@@ -3793,11 +4071,13 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
3793
4071
  logger;
3794
4072
  trafficGatewayService;
3795
4073
  trybeAuthService;
4074
+ integrationCommonDao;
3796
4075
  fileName = "wellness-management.service";
3797
- constructor(logger, trafficGatewayService, trybeAuthService) {
4076
+ constructor(logger, trafficGatewayService, trybeAuthService, integrationCommonDao) {
3798
4077
  this.logger = logger;
3799
4078
  this.trafficGatewayService = trafficGatewayService;
3800
4079
  this.trybeAuthService = trybeAuthService;
4080
+ this.integrationCommonDao = integrationCommonDao;
3801
4081
  }
3802
4082
  fetchWellnessAppointmentSession() {
3803
4083
  throw new Error("Method not implemented.");
@@ -3909,7 +4189,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
3909
4189
  meta: {
3910
4190
  url: offering.data.image.original_url
3911
4191
  }
3912
- } : void 0
4192
+ } : void 0,
4193
+ meta: {
4194
+ basketItemId: bookableItem.id
4195
+ }
3913
4196
  };
3914
4197
  }) ?? []
3915
4198
  };
@@ -4488,8 +4771,17 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
4488
4771
  try {
4489
4772
  const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
4490
4773
  const siteId = validatedIntegration.config.integrationConfig.siteId;
4491
- const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true);
4492
- const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false);
4774
+ const finalTimezone = await this.integrationCommonDao.getTimezoneForRequest({
4775
+ projectId: integration.projectId,
4776
+ loggedInUserId
4777
+ });
4778
+ this.logger.info(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, "Using timezone for date formatting", {
4779
+ timezone: finalTimezone,
4780
+ dateTimeFrom: request.dateTimeFrom,
4781
+ dateTimeTo: request.dateTimeTo
4782
+ });
4783
+ const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true, finalTimezone);
4784
+ const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false, finalTimezone);
4493
4785
  const apiUrl = `/shop/item-availability/sessions/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&offeringId=${request.externalOfferingBookableItemId}`;
4494
4786
  const response = await this.trafficGatewayService.executeIntegrationRequest({
4495
4787
  apiMethod: HTTP_METHOD.GET,
@@ -4513,8 +4805,17 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
4513
4805
  try {
4514
4806
  const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
4515
4807
  const siteId = validatedIntegration.config.integrationConfig.siteId;
4516
- const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true);
4517
- const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false);
4808
+ const finalTimezone = await this.integrationCommonDao.getTimezoneForRequest({
4809
+ projectId: integration.projectId,
4810
+ loggedInUserId
4811
+ });
4812
+ this.logger.info(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, "Using timezone for date formatting", {
4813
+ timezone: finalTimezone,
4814
+ dateTimeFrom: request.dateTimeFrom,
4815
+ dateTimeTo: request.dateTimeTo
4816
+ });
4817
+ const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true, finalTimezone);
4818
+ const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false, finalTimezone);
4518
4819
  const apiUrl = `/shop/item-availability/appointment-slots/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&OfferingID=${request.externalOfferingBookableItemId}`;
4519
4820
  const response = await this.trafficGatewayService.executeIntegrationRequest({
4520
4821
  apiMethod: HTTP_METHOD.GET,
@@ -4544,215 +4845,35 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
4544
4845
  }
4545
4846
  }
4546
4847
  };
4547
- exports.TrybeWellnessManagement = _ts_decorate18([
4848
+ exports.TrybeWellnessManagement = _ts_decorate21([
4548
4849
  common.Injectable(),
4549
- _ts_metadata15("design:type", Function),
4550
- _ts_metadata15("design:paramtypes", [
4850
+ _ts_metadata18("design:type", Function),
4851
+ _ts_metadata18("design:paramtypes", [
4551
4852
  typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
4552
4853
  typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
4553
- typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
4554
- ])
4555
- ], exports.TrybeWellnessManagement);
4556
-
4557
- // ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.mapper.ts
4558
- function mapTrybeSiteResponseToSystem(response) {
4559
- return {
4560
- customPaymentTypes: response.data?.custom_payment_types?.map((paymentType) => ({
4561
- id: paymentType.id,
4562
- name: paymentType.name,
4563
- kind: paymentType.kind
4564
- }))
4565
- };
4566
- }
4567
- __name(mapTrybeSiteResponseToSystem, "mapTrybeSiteResponseToSystem");
4568
-
4569
- // ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.service.ts
4570
- function _ts_decorate19(decorators, target, key, desc2) {
4571
- var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
4572
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
4573
- 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;
4574
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4575
- }
4576
- __name(_ts_decorate19, "_ts_decorate");
4577
- function _ts_metadata16(k, v) {
4578
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4579
- }
4580
- __name(_ts_metadata16, "_ts_metadata");
4581
- exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends exports.BaseIntegrationConfiguration {
4582
- static {
4583
- __name(this, "TrybeIntegrationConfigurationService");
4584
- }
4585
- trybeAuthService;
4586
- trafficGatewayService;
4587
- constructor(integrationConfigurationDao, commonValidationDatabaseService, logger, trybeAuthService, trafficGatewayService) {
4588
- super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
4589
- }
4590
- /**
4591
- * Add capability integration: validate Trybe config, then configuredFor (offering), then delegate to base.
4592
- */
4593
- async addCapabilityIntegration(input, context) {
4594
- this.trybeAuthService.validateConfig({
4595
- config: input.config
4596
- }, context.loggedInUserId);
4597
- if (input.configuredFor != null) {
4598
- await this.validateCapabilityIntegrationConfiguredForInput(input.configuredFor, input.projectId);
4599
- }
4600
- return super.addCapabilityIntegration(input, context);
4601
- }
4602
- /**
4603
- * Update capability integration: convert to new signature and delegate to base.
4604
- */
4605
- async updateCapabilityIntegration(request, integration, loggedInUserId) {
4606
- if (request.updateData.config) {
4607
- this.trybeAuthService.validateConfig({
4608
- config: request.updateData.config
4609
- }, loggedInUserId);
4610
- }
4611
- return super.updateCapabilityIntegration(request, integration, loggedInUserId);
4612
- }
4613
- /**
4614
- * Validates configuredFor (offering exists and belongs to project). Same as project-ms validateCapabilityIntegrationConfiguredForInput.
4615
- */
4616
- async validateCapabilityIntegrationConfiguredForInput(configuredFor, projectId) {
4617
- if (configuredFor.configuredForType !== models.CONFIGURED_FOR_TYPE_ENUM.OFFERING) {
4618
- throw new Error(`configuredForType not supported: ${configuredFor.configuredForType}`);
4619
- }
4620
- await this.commonValidationDatabaseService.getOffering({
4621
- offeringId: configuredFor.configuredForId,
4622
- projectId
4623
- });
4624
- }
4625
- /**
4626
- * Trybe 3rd party: GET /shop/sites/{siteId} via executeIntegrationRequest.
4627
- */
4628
- async getSiteDetailedInformation(integration, loggedInUserId) {
4629
- const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
4630
- const siteId = validatedIntegration.config.integrationConfig.siteId;
4631
- const url = `/shop/sites/${siteId}`;
4632
- const response = await this.trafficGatewayService.executeIntegrationRequest({
4633
- apiMethod: HTTP_METHOD.GET,
4634
- url,
4635
- baseUrl: validatedIntegration.config.platformConfig.baseUrl,
4636
- headers: validatedIntegration.headers
4637
- }, validatedIntegration, loggedInUserId);
4638
- return mapTrybeSiteResponseToSystem(response);
4639
- }
4640
- };
4641
- exports.TrybeIntegrationConfigurationService = _ts_decorate19([
4642
- common.Injectable(),
4643
- _ts_metadata16("design:type", Function),
4644
- _ts_metadata16("design:paramtypes", [
4645
- typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
4646
- typeof dvssBackendModuleDatastore.CommonValidationDatabaseService === "undefined" ? Object : dvssBackendModuleDatastore.CommonValidationDatabaseService,
4647
- typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
4648
4854
  typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService,
4649
- typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
4650
- ])
4651
- ], exports.TrybeIntegrationConfigurationService);
4652
- function _ts_decorate20(decorators, target, key, desc2) {
4653
- var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
4654
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
4655
- 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;
4656
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4657
- }
4658
- __name(_ts_decorate20, "_ts_decorate");
4659
- function _ts_metadata17(k, v) {
4660
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4661
- }
4662
- __name(_ts_metadata17, "_ts_metadata");
4663
- var OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = "OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS";
4664
- var VALID_JOURNEY_VALUES = /* @__PURE__ */ new Set([
4665
- "SESSION",
4666
- "COURSE",
4667
- "APPOINTMENT"
4668
- ]);
4669
- exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResourceManagementService extends BaseIntegrationResourceManagement {
4670
- static {
4671
- __name(this, "TrybeIntegrationResourceManagementService");
4672
- }
4673
- constructor(logger, integrationResourceManagementDao) {
4674
- super(integrationResourceManagementDao, logger);
4675
- }
4676
- /**
4677
- * Validates Trybe resource mapping config (same rules as MS trybe-offering-integration-management.service).
4678
- * @throws CustomException BAD_REQUEST if config is invalid
4679
- */
4680
- validateResourceMappingConfig(config3) {
4681
- const resourceMappingConfig = config3;
4682
- if (!resourceMappingConfig.supportedJourneys || resourceMappingConfig.supportedJourneys.length === 0) {
4683
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys required and must be non-empty");
4684
- }
4685
- if (!resourceMappingConfig.catalogingBy || // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
4686
- resourceMappingConfig.catalogingBy !== TRYBE_CATALOGING_BY_ENUM.PEOPLE_RESOURCE) {
4687
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: catalogingBy must be PEOPLE_RESOURCE");
4688
- }
4689
- if (!resourceMappingConfig.supportedJourneys.some((journey) => VALID_JOURNEY_VALUES.has(journey))) {
4690
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys must contain at least one of SESSION, COURSE, APPOINTMENT");
4691
- }
4692
- if (resourceMappingConfig.supportedJourneys.some((journey) => !VALID_JOURNEY_VALUES.has(journey))) {
4693
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys may only contain SESSION, COURSE, APPOINTMENT");
4694
- }
4695
- if (!resourceMappingConfig.paymentType || typeof resourceMappingConfig.paymentType !== "string") {
4696
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: paymentType required and must be a string");
4697
- }
4698
- }
4699
- async addResourceToIntegration(input, context) {
4700
- if (input.config != null && typeof input.config === "object") {
4701
- this.validateResourceMappingConfig(input.config);
4702
- }
4703
- const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
4704
- capabilityIntegrationId: input.capabilityIntegrationId,
4705
- configuredForId: input.offeringId,
4706
- configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
4707
- }, context.loggedInUserId);
4708
- if (isMappingExists) {
4709
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS);
4710
- }
4711
- return super.addResourceToIntegration(input, context);
4712
- }
4713
- async removeResourceFromIntegration(request, context) {
4714
- const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
4715
- capabilityIntegrationId: request.capabilityIntegrationId,
4716
- configuredForId: request.offeringId,
4717
- configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
4718
- }, context.loggedInUserId);
4719
- if (!isMappingExists) {
4720
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Mapping not found");
4721
- }
4722
- return super.removeResourceFromIntegration(request, context);
4723
- }
4724
- async updateOfferingIntegrationResourceConfiguration(input, context) {
4725
- const resourceMapping = await this.integrationResourceManagementDao.getCapabilityIntegrationResourceMappingById(input.id, context.loggedInUserId);
4726
- if (!resourceMapping) {
4727
- throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Resource mapping not found");
4728
- }
4729
- this.validateResourceMappingConfig(input.config);
4730
- return await super.updateOfferingIntegrationResourceConfiguration(input, context);
4731
- }
4732
- };
4733
- exports.TrybeIntegrationResourceManagementService = _ts_decorate20([
4734
- common.Injectable(),
4735
- _ts_metadata17("design:type", Function),
4736
- _ts_metadata17("design:paramtypes", [
4737
- typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
4738
- typeof exports.IntegrationResourceManagementDao === "undefined" ? Object : exports.IntegrationResourceManagementDao
4855
+ typeof exports.IntegrationCommonDao === "undefined" ? Object : exports.IntegrationCommonDao
4739
4856
  ])
4740
- ], exports.TrybeIntegrationResourceManagementService);
4857
+ ], exports.TrybeWellnessManagement);
4858
+ var rootEnvPath2 = path.resolve(__dirname, "../../../.env");
4859
+ dotenv.config({
4860
+ path: rootEnvPath2
4861
+ });
4741
4862
 
4742
4863
  // ../../packages/dvss-integration-trybe/src/app.module.ts
4743
- function _ts_decorate21(decorators, target, key, desc2) {
4864
+ function _ts_decorate22(decorators, target, key, desc2) {
4744
4865
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
4745
4866
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
4746
4867
  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;
4747
4868
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4748
4869
  }
4749
- __name(_ts_decorate21, "_ts_decorate");
4870
+ __name(_ts_decorate22, "_ts_decorate");
4750
4871
  exports.IntegrationTrybeModule = class AppModule2 {
4751
4872
  static {
4752
4873
  __name(this, "AppModule");
4753
4874
  }
4754
4875
  };
4755
- exports.IntegrationTrybeModule = _ts_decorate21([
4876
+ exports.IntegrationTrybeModule = _ts_decorate22([
4756
4877
  common.Module({
4757
4878
  imports: [
4758
4879
  // Load environment variables from root .env file
@@ -4766,16 +4887,17 @@ exports.IntegrationTrybeModule = _ts_decorate21([
4766
4887
  dvssBackendModuleDatastore.DatastoreModule
4767
4888
  ],
4768
4889
  controllers: [
4769
- AppController2
4890
+ AppController3
4770
4891
  ],
4771
4892
  providers: [
4772
- AppService2,
4893
+ AppService3,
4773
4894
  exports.TrybeAuthService,
4774
4895
  exports.TrybeCustomerManagement,
4775
4896
  exports.TrybeCreditBooking,
4776
4897
  exports.TrybeWellnessManagement,
4777
4898
  exports.IntegrationConfigurationDao,
4778
4899
  exports.IntegrationResourceManagementDao,
4900
+ exports.IntegrationCommonDao,
4779
4901
  exports.IntegrationRequestLoggerService,
4780
4902
  exports.RateLimiterService,
4781
4903
  exports.TrafficGatewayService,
@@ -4797,19 +4919,19 @@ exports.IntegrationTrybeModule = _ts_decorate21([
4797
4919
  ], exports.IntegrationTrybeModule);
4798
4920
 
4799
4921
  // src/app.module.ts
4800
- function _ts_decorate22(decorators, target, key, desc2) {
4922
+ function _ts_decorate23(decorators, target, key, desc2) {
4801
4923
  var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
4802
4924
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
4803
4925
  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;
4804
4926
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4805
4927
  }
4806
- __name(_ts_decorate22, "_ts_decorate");
4928
+ __name(_ts_decorate23, "_ts_decorate");
4807
4929
  exports.OfferingIntegrationManager = class AppModule3 {
4808
4930
  static {
4809
4931
  __name(this, "AppModule");
4810
4932
  }
4811
4933
  };
4812
- exports.OfferingIntegrationManager = _ts_decorate22([
4934
+ exports.OfferingIntegrationManager = _ts_decorate23([
4813
4935
  common.Module({
4814
4936
  imports: [
4815
4937
  exports.IntegrationTrybeModule,