@infrab4a/connect 4.9.0-beta.2 → 4.9.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -2685,8 +2685,9 @@ class ProductsIndex {
2685
2685
  }
2686
2686
  async save(product) {
2687
2687
  try {
2688
- const { createdAt, updatedAt, kitProducts } = product, data = tslib_1.__rest(product, ["createdAt", "updatedAt", "kitProducts"]);
2689
- this.adapter.save(this.index, data);
2688
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib_1.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
2689
+ const newProduct = Product.toInstance(data);
2690
+ this.adapter.save(this.index, newProduct);
2690
2691
  }
2691
2692
  catch (error) {
2692
2693
  console.error(error);
@@ -2929,6 +2930,7 @@ const withFindFirestore = (MixinBase) => {
2929
2930
  ...this.buildWhereSentence(fieldName, is(filter[fieldName])),
2930
2931
  ], []);
2931
2932
  this.buildWhereSentence = (fieldName, options) => {
2933
+ var _a, _b, _c, _d;
2932
2934
  if (this.isSubCollection(this) && fieldName === this.parentIdField)
2933
2935
  return [];
2934
2936
  const value = (options === null || options === void 0 ? void 0 : options.value) || options;
@@ -2940,9 +2942,9 @@ const withFindFirestore = (MixinBase) => {
2940
2942
  : Object.keys(plainInstance).find((key) => plainInstance[key]);
2941
2943
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.LIKE) {
2942
2944
  if (Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
2943
- (this.fields[firestoreFieldName] ===
2945
+ (((_a = this.fields) === null || _a === void 0 ? void 0 : _a[firestoreFieldName]) ===
2944
2946
  FirestoreFieldType.Array ||
2945
- !this.fields[firestoreFieldName]))
2947
+ !((_b = this.fields) === null || _b === void 0 ? void 0 : _b[firestoreFieldName])))
2946
2948
  return [[firestoreFieldName, 'array-contains-any', options.value]];
2947
2949
  return [
2948
2950
  [firestoreFieldName, '>=', options.value],
@@ -2951,8 +2953,9 @@ const withFindFirestore = (MixinBase) => {
2951
2953
  }
2952
2954
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.IN &&
2953
2955
  Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
2954
- (this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
2955
- !this.fields[firestoreFieldName]))
2956
+ (((_c = this.fields) === null || _c === void 0 ? void 0 : _c[firestoreFieldName]) ===
2957
+ FirestoreFieldType.Array ||
2958
+ !((_d = this.fields) === null || _d === void 0 ? void 0 : _d[firestoreFieldName])))
2956
2959
  return [[firestoreFieldName, 'array-contains', options.value]];
2957
2960
  if (lodash.isObject(options) && lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) && lodash.isNil(options === null || options === void 0 ? void 0 : options.value)) {
2958
2961
  return Object.keys(options).reduce((queries, key) => [
package/index.esm.js CHANGED
@@ -2661,8 +2661,9 @@ class ProductsIndex {
2661
2661
  }
2662
2662
  async save(product) {
2663
2663
  try {
2664
- const { createdAt, updatedAt, kitProducts } = product, data = __rest(product, ["createdAt", "updatedAt", "kitProducts"]);
2665
- this.adapter.save(this.index, data);
2664
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
2665
+ const newProduct = Product.toInstance(data);
2666
+ this.adapter.save(this.index, newProduct);
2666
2667
  }
2667
2668
  catch (error) {
2668
2669
  console.error(error);
@@ -2905,6 +2906,7 @@ const withFindFirestore = (MixinBase) => {
2905
2906
  ...this.buildWhereSentence(fieldName, is(filter[fieldName])),
2906
2907
  ], []);
2907
2908
  this.buildWhereSentence = (fieldName, options) => {
2909
+ var _a, _b, _c, _d;
2908
2910
  if (this.isSubCollection(this) && fieldName === this.parentIdField)
2909
2911
  return [];
2910
2912
  const value = (options === null || options === void 0 ? void 0 : options.value) || options;
@@ -2916,9 +2918,9 @@ const withFindFirestore = (MixinBase) => {
2916
2918
  : Object.keys(plainInstance).find((key) => plainInstance[key]);
2917
2919
  if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
2918
2920
  if (Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
2919
- (this.fields[firestoreFieldName] ===
2921
+ (((_a = this.fields) === null || _a === void 0 ? void 0 : _a[firestoreFieldName]) ===
2920
2922
  FirestoreFieldType.Array ||
2921
- !this.fields[firestoreFieldName]))
2923
+ !((_b = this.fields) === null || _b === void 0 ? void 0 : _b[firestoreFieldName])))
2922
2924
  return [[firestoreFieldName, 'array-contains-any', options.value]];
2923
2925
  return [
2924
2926
  [firestoreFieldName, '>=', options.value],
@@ -2927,8 +2929,9 @@ const withFindFirestore = (MixinBase) => {
2927
2929
  }
2928
2930
  if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN &&
2929
2931
  Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
2930
- (this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
2931
- !this.fields[firestoreFieldName]))
2932
+ (((_c = this.fields) === null || _c === void 0 ? void 0 : _c[firestoreFieldName]) ===
2933
+ FirestoreFieldType.Array ||
2934
+ !((_d = this.fields) === null || _d === void 0 ? void 0 : _d[firestoreFieldName])))
2932
2935
  return [[firestoreFieldName, 'array-contains', options.value]];
2933
2936
  if (isObject$1(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
2934
2937
  return Object.keys(options).reduce((queries, key) => [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.9.0-beta.2",
3
+ "version": "4.9.0-beta.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -13,7 +13,7 @@
13
13
  "class-transformer": "^0.5.1",
14
14
  "date-fns": "^2.28.0",
15
15
  "debug": "^4.3.4",
16
- "firebase": "^9.9.0",
16
+ "firebase": "9.18.0",
17
17
  "gql-query-builder": "3.7.0",
18
18
  "lodash": "^4.17.21",
19
19
  "reflect-metadata": "^0.1.13",
@@ -11,7 +11,7 @@ export declare class AxiosAdapter<T extends ModelBaseStructure<T>> implements El
11
11
  constructor(config: AxiosElasticSearchConfig);
12
12
  get(index: string, id: string): Promise<T>;
13
13
  query(index: string, query: any): Promise<ElasticSearchResult<T>>;
14
- save(index: string, data: Partial<T>): Promise<void>;
14
+ save(index: string, data: T): Promise<void>;
15
15
  update(index: string, id: string, data: Partial<T>): Promise<void>;
16
16
  delete(index: string, id: string): Promise<void>;
17
17
  }
@@ -2,7 +2,7 @@ import { ElasticSearchResult } from '../types/elastic-search-result';
2
2
  export interface ElasticSearchAdapter<T = any> {
3
3
  get(index: string, id: string): Promise<T>;
4
4
  query(index: string, query: any): Promise<ElasticSearchResult<T>>;
5
- save(index: string, data: Partial<T>): Promise<void>;
5
+ save(index: string, data: T): Promise<void>;
6
6
  update(index: string, id: string, data: Partial<T>): Promise<void>;
7
7
  delete(index: string, id: string): Promise<void>;
8
8
  }