@infrab4a/connect-nestjs 1.0.0 → 1.1.0-beta.0

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/index.cjs.js CHANGED
@@ -2,10 +2,151 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var elasticsearch = require('@elastic/elasticsearch');
5
6
  var connect = require('@infrab4a/connect');
6
7
  var common = require('@nestjs/common');
7
8
  var nestjsFirebase = require('nestjs-firebase');
8
9
 
10
+ /******************************************************************************
11
+ Copyright (c) Microsoft Corporation.
12
+
13
+ Permission to use, copy, modify, and/or distribute this software for any
14
+ purpose with or without fee is hereby granted.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
+ PERFORMANCE OF THIS SOFTWARE.
23
+ ***************************************************************************** */
24
+
25
+ function __decorate(decorators, target, key, desc) {
26
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
27
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
28
+ 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;
29
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
30
+ }
31
+
32
+ function __param(paramIndex, decorator) {
33
+ return function (target, key) { decorator(target, key, paramIndex); }
34
+ }
35
+
36
+ function __metadata(metadataKey, metadataValue) {
37
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
38
+ }
39
+
40
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
41
+ var e = new Error(message);
42
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
43
+ };
44
+
45
+ const ES_CONFIG = 'ES_CONFIG';
46
+
47
+ const HASURA_OPTIONS = 'HASURA_OPTIONS';
48
+
49
+ exports.NativeElasticSearchAdapter = class NativeElasticSearchAdapter {
50
+ constructor(config) {
51
+ this.logger = connect.DebugHelper.from(this);
52
+ try {
53
+ this.client = !connect.isEmpty(config.cloud.id) && !connect.isEmpty(config.auth.apiKey) && new elasticsearch.Client(config);
54
+ }
55
+ catch (error) {
56
+ this.logger.error({ req: config, res: error });
57
+ throw error;
58
+ }
59
+ }
60
+ async get(index, id) {
61
+ const logger = this.logger.with('get');
62
+ const req = { index, id };
63
+ try {
64
+ const data = await this.client.get({ index, id });
65
+ logger.log({ req, res: data });
66
+ return data._source;
67
+ }
68
+ catch (error) {
69
+ const message = error instanceof Error ? error.message : `${index}/${id} not found`;
70
+ logger.log({ req, res: error });
71
+ throw new connect.NotFoundError(message);
72
+ }
73
+ }
74
+ async query(index, query) {
75
+ const logger = this.logger.with('query');
76
+ const params = {
77
+ index,
78
+ query,
79
+ };
80
+ try {
81
+ const result = await this.client.search(params);
82
+ const res = {
83
+ total: result.hits.total,
84
+ hits: result.hits.hits,
85
+ };
86
+ logger.log({ req: params, res });
87
+ return res;
88
+ }
89
+ catch (error) {
90
+ logger.error({ req: params, res: error });
91
+ throw error;
92
+ }
93
+ }
94
+ async save(index, data) {
95
+ const logger = this.logger.with('save');
96
+ const req = {
97
+ index,
98
+ id: data.identifiersFields.length > 1
99
+ ? JSON.stringify(data.identifier)
100
+ : Object.values(data.identifier).shift().toString(),
101
+ document: data,
102
+ };
103
+ try {
104
+ await this.client.index(req);
105
+ logger.log({ req, res: undefined });
106
+ }
107
+ catch (error) {
108
+ logger.error({ req, res: error });
109
+ throw error;
110
+ }
111
+ }
112
+ async update(index, id, data) {
113
+ const logger = this.logger.with('update');
114
+ const req = {
115
+ index,
116
+ id,
117
+ doc: data,
118
+ };
119
+ try {
120
+ await this.client.update(req);
121
+ logger.log({ req, res: undefined });
122
+ }
123
+ catch (error) {
124
+ logger.error({ req, res: error });
125
+ throw error;
126
+ }
127
+ }
128
+ async delete(index, id) {
129
+ const logger = this.logger.with('delete');
130
+ const req = {
131
+ index,
132
+ id,
133
+ };
134
+ try {
135
+ await this.client.delete(req);
136
+ logger.log({ req, res: undefined });
137
+ }
138
+ catch (error) {
139
+ logger.error({ req, res: error });
140
+ throw error;
141
+ }
142
+ }
143
+ };
144
+ exports.NativeElasticSearchAdapter = __decorate([
145
+ common.Injectable(),
146
+ __param(0, common.Inject(ES_CONFIG)),
147
+ __metadata("design:paramtypes", [Object])
148
+ ], exports.NativeElasticSearchAdapter);
149
+
9
150
  class ConnectBaseDocumentSnapshot {
10
151
  constructor(connectDocumentSnapshot) {
11
152
  this.connectDocumentSnapshot = connectDocumentSnapshot;
@@ -141,33 +282,6 @@ class ConnectFirestoreService {
141
282
  }
142
283
  }
143
284
 
144
- /******************************************************************************
145
- Copyright (c) Microsoft Corporation.
146
-
147
- Permission to use, copy, modify, and/or distribute this software for any
148
- purpose with or without fee is hereby granted.
149
-
150
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
151
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
152
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
153
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
154
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
155
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
156
- PERFORMANCE OF THIS SOFTWARE.
157
- ***************************************************************************** */
158
-
159
- function __decorate(decorators, target, key, desc) {
160
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
161
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
162
- 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;
163
- return c > 3 && r && Object.defineProperty(target, key, r), r;
164
- }
165
-
166
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
167
- var e = new Error(message);
168
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
169
- };
170
-
171
285
  var NestFirestoreModule_1;
172
286
  exports.NestFirestoreModule = NestFirestoreModule_1 = class NestFirestoreModule {
173
287
  static initializeApp(options) {
@@ -178,11 +292,11 @@ exports.NestFirestoreModule = NestFirestoreModule_1 = class NestFirestoreModule
178
292
  googleApplicationCredential: options.firebase.googleApplicationCredential,
179
293
  }),
180
294
  ],
295
+ exports: [nestjsFirebase.FirebaseModule],
181
296
  };
182
297
  }
183
298
  };
184
299
  exports.NestFirestoreModule = NestFirestoreModule_1 = __decorate([
185
- common.Global(),
186
300
  common.Module({
187
301
  providers: [
188
302
  {
@@ -414,8 +528,6 @@ exports.NestFirestoreModule = NestFirestoreModule_1 = __decorate([
414
528
  })
415
529
  ], exports.NestFirestoreModule);
416
530
 
417
- const HASURA_OPTIONS = 'HASURA_OPTIONS';
418
-
419
531
  var NestHasuraGraphQLModule_1;
420
532
  exports.NestHasuraGraphQLModule = NestHasuraGraphQLModule_1 = class NestHasuraGraphQLModule {
421
533
  static initializeApp(options) {
@@ -564,59 +676,13 @@ exports.NestConnectModule = NestConnectModule_1 = class NestConnectModule {
564
676
  return {
565
677
  module: NestConnectModule_1,
566
678
  imports: [
567
- ...(options.firebase
568
- ? [
569
- nestjsFirebase.FirebaseModule.forRoot({
570
- googleApplicationCredential: options.firebase.googleApplicationCredential,
571
- }),
572
- exports.NestFirestoreModule,
573
- ]
574
- : []),
679
+ ...(options.firebase ? [exports.NestFirestoreModule] : []),
575
680
  ...(connect.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [exports.NestHasuraGraphQLModule.initializeApp(options.hasura)]),
576
681
  ],
577
- // exports: [
578
- // ...(isNil(options?.hasura)
579
- // ? []
580
- // : [
581
- // 'CategoryRepository',
582
- // 'ProductRepository',
583
- // 'ProductReviewsRepository',
584
- // 'VariantRepository',
585
- // 'CategoryFilterRepository',
586
- // 'FilterOptionRepository',
587
- // 'FilterRepository',
588
- // 'CategoryCollectionChildrenRepository',
589
- // 'WishlistRepository',
590
- // ]),
591
- // ...(isNil(options?.firebase?.googleApplicationCredential)
592
- // ? []
593
- // : [
594
- // 'BeautyProfileRepository',
595
- // 'Buy2WinRepository',
596
- // 'CheckoutRepository',
597
- // 'CheckoutSubscriptionRepository',
598
- // 'CouponRepository',
599
- // 'CampaignHashtagRepository',
600
- // 'CampaignDashboardRepository',
601
- // 'EditionRepository',
602
- // 'HomeRepository',
603
- // 'LeadRepository',
604
- // 'LegacyOrderRepository',
605
- // 'ShopMenuRepository',
606
- // 'OrderRepository',
607
- // 'PaymentRepository',
608
- // 'ShopSettingsRepository',
609
- // 'SubscriptionPaymentRepository',
610
- // 'SubscriptionPlanRepository',
611
- // 'SubscriptionProductRepository',
612
- // 'SubscriptionRepository',
613
- // 'UserRepository',
614
- // 'UserAddressRepository',
615
- // 'UserPaymentMethodRepository',
616
- // 'SubscriptionMaterializationRepository',
617
- // 'SubscriptionSummaryRepository',
618
- // ]),
619
- // ],
682
+ exports: [
683
+ ...(options.firebase ? [exports.NestFirestoreModule] : []),
684
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [exports.NestHasuraGraphQLModule]),
685
+ ],
620
686
  };
621
687
  }
622
688
  };
package/index.esm.js CHANGED
@@ -1,7 +1,148 @@
1
- import { isEmpty, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, isNil } from '@infrab4a/connect';
2
- import { Global, Module } from '@nestjs/common';
1
+ import { Client } from '@elastic/elasticsearch';
2
+ import { DebugHelper, isEmpty, NotFoundError, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, isNil } from '@infrab4a/connect';
3
+ import { Injectable, Inject, Module, Global } from '@nestjs/common';
3
4
  import { FirebaseConstants, FirebaseModule } from 'nestjs-firebase';
4
5
 
6
+ /******************************************************************************
7
+ Copyright (c) Microsoft Corporation.
8
+
9
+ Permission to use, copy, modify, and/or distribute this software for any
10
+ purpose with or without fee is hereby granted.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
+ PERFORMANCE OF THIS SOFTWARE.
19
+ ***************************************************************************** */
20
+
21
+ function __decorate(decorators, target, key, desc) {
22
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
23
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
24
+ 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;
25
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
26
+ }
27
+
28
+ function __param(paramIndex, decorator) {
29
+ return function (target, key) { decorator(target, key, paramIndex); }
30
+ }
31
+
32
+ function __metadata(metadataKey, metadataValue) {
33
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
34
+ }
35
+
36
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
37
+ var e = new Error(message);
38
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
39
+ };
40
+
41
+ const ES_CONFIG = 'ES_CONFIG';
42
+
43
+ const HASURA_OPTIONS = 'HASURA_OPTIONS';
44
+
45
+ let NativeElasticSearchAdapter = class NativeElasticSearchAdapter {
46
+ constructor(config) {
47
+ this.logger = DebugHelper.from(this);
48
+ try {
49
+ this.client = !isEmpty(config.cloud.id) && !isEmpty(config.auth.apiKey) && new Client(config);
50
+ }
51
+ catch (error) {
52
+ this.logger.error({ req: config, res: error });
53
+ throw error;
54
+ }
55
+ }
56
+ async get(index, id) {
57
+ const logger = this.logger.with('get');
58
+ const req = { index, id };
59
+ try {
60
+ const data = await this.client.get({ index, id });
61
+ logger.log({ req, res: data });
62
+ return data._source;
63
+ }
64
+ catch (error) {
65
+ const message = error instanceof Error ? error.message : `${index}/${id} not found`;
66
+ logger.log({ req, res: error });
67
+ throw new NotFoundError(message);
68
+ }
69
+ }
70
+ async query(index, query) {
71
+ const logger = this.logger.with('query');
72
+ const params = {
73
+ index,
74
+ query,
75
+ };
76
+ try {
77
+ const result = await this.client.search(params);
78
+ const res = {
79
+ total: result.hits.total,
80
+ hits: result.hits.hits,
81
+ };
82
+ logger.log({ req: params, res });
83
+ return res;
84
+ }
85
+ catch (error) {
86
+ logger.error({ req: params, res: error });
87
+ throw error;
88
+ }
89
+ }
90
+ async save(index, data) {
91
+ const logger = this.logger.with('save');
92
+ const req = {
93
+ index,
94
+ id: data.identifiersFields.length > 1
95
+ ? JSON.stringify(data.identifier)
96
+ : Object.values(data.identifier).shift().toString(),
97
+ document: data,
98
+ };
99
+ try {
100
+ await this.client.index(req);
101
+ logger.log({ req, res: undefined });
102
+ }
103
+ catch (error) {
104
+ logger.error({ req, res: error });
105
+ throw error;
106
+ }
107
+ }
108
+ async update(index, id, data) {
109
+ const logger = this.logger.with('update');
110
+ const req = {
111
+ index,
112
+ id,
113
+ doc: data,
114
+ };
115
+ try {
116
+ await this.client.update(req);
117
+ logger.log({ req, res: undefined });
118
+ }
119
+ catch (error) {
120
+ logger.error({ req, res: error });
121
+ throw error;
122
+ }
123
+ }
124
+ async delete(index, id) {
125
+ const logger = this.logger.with('delete');
126
+ const req = {
127
+ index,
128
+ id,
129
+ };
130
+ try {
131
+ await this.client.delete(req);
132
+ logger.log({ req, res: undefined });
133
+ }
134
+ catch (error) {
135
+ logger.error({ req, res: error });
136
+ throw error;
137
+ }
138
+ }
139
+ };
140
+ NativeElasticSearchAdapter = __decorate([
141
+ Injectable(),
142
+ __param(0, Inject(ES_CONFIG)),
143
+ __metadata("design:paramtypes", [Object])
144
+ ], NativeElasticSearchAdapter);
145
+
5
146
  class ConnectBaseDocumentSnapshot {
6
147
  constructor(connectDocumentSnapshot) {
7
148
  this.connectDocumentSnapshot = connectDocumentSnapshot;
@@ -137,33 +278,6 @@ class ConnectFirestoreService {
137
278
  }
138
279
  }
139
280
 
140
- /******************************************************************************
141
- Copyright (c) Microsoft Corporation.
142
-
143
- Permission to use, copy, modify, and/or distribute this software for any
144
- purpose with or without fee is hereby granted.
145
-
146
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
147
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
148
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
149
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
150
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
151
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
152
- PERFORMANCE OF THIS SOFTWARE.
153
- ***************************************************************************** */
154
-
155
- function __decorate(decorators, target, key, desc) {
156
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
157
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
158
- 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;
159
- return c > 3 && r && Object.defineProperty(target, key, r), r;
160
- }
161
-
162
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
163
- var e = new Error(message);
164
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
165
- };
166
-
167
281
  var NestFirestoreModule_1;
168
282
  let NestFirestoreModule = NestFirestoreModule_1 = class NestFirestoreModule {
169
283
  static initializeApp(options) {
@@ -174,11 +288,11 @@ let NestFirestoreModule = NestFirestoreModule_1 = class NestFirestoreModule {
174
288
  googleApplicationCredential: options.firebase.googleApplicationCredential,
175
289
  }),
176
290
  ],
291
+ exports: [FirebaseModule],
177
292
  };
178
293
  }
179
294
  };
180
295
  NestFirestoreModule = NestFirestoreModule_1 = __decorate([
181
- Global(),
182
296
  Module({
183
297
  providers: [
184
298
  {
@@ -410,8 +524,6 @@ NestFirestoreModule = NestFirestoreModule_1 = __decorate([
410
524
  })
411
525
  ], NestFirestoreModule);
412
526
 
413
- const HASURA_OPTIONS = 'HASURA_OPTIONS';
414
-
415
527
  var NestHasuraGraphQLModule_1;
416
528
  let NestHasuraGraphQLModule = NestHasuraGraphQLModule_1 = class NestHasuraGraphQLModule {
417
529
  static initializeApp(options) {
@@ -560,59 +672,13 @@ let NestConnectModule = NestConnectModule_1 = class NestConnectModule {
560
672
  return {
561
673
  module: NestConnectModule_1,
562
674
  imports: [
563
- ...(options.firebase
564
- ? [
565
- FirebaseModule.forRoot({
566
- googleApplicationCredential: options.firebase.googleApplicationCredential,
567
- }),
568
- NestFirestoreModule,
569
- ]
570
- : []),
675
+ ...(options.firebase ? [NestFirestoreModule] : []),
571
676
  ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [NestHasuraGraphQLModule.initializeApp(options.hasura)]),
572
677
  ],
573
- // exports: [
574
- // ...(isNil(options?.hasura)
575
- // ? []
576
- // : [
577
- // 'CategoryRepository',
578
- // 'ProductRepository',
579
- // 'ProductReviewsRepository',
580
- // 'VariantRepository',
581
- // 'CategoryFilterRepository',
582
- // 'FilterOptionRepository',
583
- // 'FilterRepository',
584
- // 'CategoryCollectionChildrenRepository',
585
- // 'WishlistRepository',
586
- // ]),
587
- // ...(isNil(options?.firebase?.googleApplicationCredential)
588
- // ? []
589
- // : [
590
- // 'BeautyProfileRepository',
591
- // 'Buy2WinRepository',
592
- // 'CheckoutRepository',
593
- // 'CheckoutSubscriptionRepository',
594
- // 'CouponRepository',
595
- // 'CampaignHashtagRepository',
596
- // 'CampaignDashboardRepository',
597
- // 'EditionRepository',
598
- // 'HomeRepository',
599
- // 'LeadRepository',
600
- // 'LegacyOrderRepository',
601
- // 'ShopMenuRepository',
602
- // 'OrderRepository',
603
- // 'PaymentRepository',
604
- // 'ShopSettingsRepository',
605
- // 'SubscriptionPaymentRepository',
606
- // 'SubscriptionPlanRepository',
607
- // 'SubscriptionProductRepository',
608
- // 'SubscriptionRepository',
609
- // 'UserRepository',
610
- // 'UserAddressRepository',
611
- // 'UserPaymentMethodRepository',
612
- // 'SubscriptionMaterializationRepository',
613
- // 'SubscriptionSummaryRepository',
614
- // ]),
615
- // ],
678
+ exports: [
679
+ ...(options.firebase ? [NestFirestoreModule] : []),
680
+ ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [NestHasuraGraphQLModule]),
681
+ ],
616
682
  };
617
683
  }
618
684
  };
@@ -620,4 +686,4 @@ NestConnectModule = NestConnectModule_1 = __decorate([
620
686
  Module({})
621
687
  ], NestConnectModule);
622
688
 
623
- export { ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, NestConnectModule, NestFirestoreModule, NestHasuraGraphQLModule };
689
+ export { ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, NativeElasticSearchAdapter, NestConnectModule, NestFirestoreModule, NestHasuraGraphQLModule };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect-nestjs",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,12 +9,13 @@
9
9
  "url": "https://github.com/B4AGroup/b4a-firebase-libs"
10
10
  },
11
11
  "peerDependencies": {
12
- "@infrab4a/connect": "4.4.0",
12
+ "@infrab4a/connect": "4.9.0",
13
13
  "@nestjs/common": "^10.3.3",
14
14
  "@nestjs/core": "^10.3.3",
15
15
  "firebase-admin": "^12.0.0"
16
16
  },
17
17
  "dependencies": {
18
+ "@elastic/elasticsearch": "^8.13.1",
18
19
  "nestjs-firebase": "^10.4.0"
19
20
  },
20
21
  "exports": {
@@ -0,0 +1 @@
1
+ export declare const ES_CONFIG = "ES_CONFIG";
@@ -1 +1,2 @@
1
+ export * from './es-config.const';
1
2
  export * from './hasura-options.const';
@@ -0,0 +1 @@
1
+ export * from './native-elasticsearch-adapter';
@@ -0,0 +1,19 @@
1
+ import { BaseModel, ElasticSearchAdapter, ElasticSearchResult } from '@infrab4a/connect';
2
+ export interface ESClientOptions {
3
+ cloud: {
4
+ id: string;
5
+ };
6
+ auth: {
7
+ apiKey: string;
8
+ };
9
+ }
10
+ export declare class NativeElasticSearchAdapter<T extends BaseModel<T> = any> implements ElasticSearchAdapter<T> {
11
+ private client;
12
+ private logger;
13
+ constructor(config: ESClientOptions);
14
+ get(index: string, id: string): Promise<T>;
15
+ query(index: string, query: any): Promise<ElasticSearchResult<T>>;
16
+ save(index: string, data: Partial<T>): Promise<void>;
17
+ update(index: string, id: string, data: Partial<T>): Promise<void>;
18
+ delete(index: string, id: string): Promise<void>;
19
+ }
@@ -0,0 +1 @@
1
+ export * from './adapters';
@@ -1 +1,2 @@
1
+ export * from './elasticsearch';
1
2
  export * from './firebase';
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { ESClientOptions } from './infra';
3
+ export declare class NestElasticSeachModule {
4
+ static initializeApp(options: ESClientOptions): DynamicModule;
5
+ }