@infrab4a/connect 4.9.4-beta.5 → 4.9.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
@@ -2901,7 +2901,7 @@ const withGetFirestore = (MixinBase) => {
2901
2901
  .get();
2902
2902
  const data = docRef.data();
2903
2903
  if (lodash.isNil(data))
2904
- throw new NotFoundError(`Document '${collectionName}/${JSON.stringify(identifiers)}' not found`);
2904
+ throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers).shift()}' not found`);
2905
2905
  const res = ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted)) || data;
2906
2906
  logger.log({ req, res });
2907
2907
  return res;
@@ -3081,10 +3081,10 @@ const withCreateFirestore = (MixinBase) => {
3081
3081
  }
3082
3082
  }
3083
3083
  async save(data) {
3084
- var _a, _b, _c;
3084
+ var _a, _b;
3085
3085
  const collectionPath = this.buildCollectionPathForAdd(data);
3086
3086
  const collection = this.collection(collectionPath);
3087
- return collection.add((_a = data === null || data === void 0 ? void 0 : data.toPlain) === null || _a === void 0 ? void 0 : _a.call(data), (_c = (_b = Object.values(data.identifier).shift()) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b));
3087
+ return collection.add(data, (_b = (_a = Object.values(data.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a));
3088
3088
  }
3089
3089
  buildCollectionPathForAdd(identifiers) {
3090
3090
  return this.isSubCollection(this)
@@ -3835,7 +3835,7 @@ class ConnectDocumentService {
3835
3835
  if (doc.exists())
3836
3836
  await firestore.updateDoc(this.reference, data);
3837
3837
  else
3838
- await firestore.addDoc(this.reference.parent, data);
3838
+ await firestore.setDoc(this.reference, data);
3839
3839
  return this;
3840
3840
  }
3841
3841
  async delete() {
@@ -3920,7 +3920,7 @@ class ConnectCollectionService {
3920
3920
  if (lodash.isEmpty(id))
3921
3921
  return firestore.addDoc(this.reference, data);
3922
3922
  const docRef = firestore.doc(this.reference, id);
3923
- await firestore.updateDoc(docRef, data);
3923
+ await firestore.setDoc(docRef, data);
3924
3924
  return docRef;
3925
3925
  }
3926
3926
  }
package/index.esm.js CHANGED
@@ -10,7 +10,7 @@ import { debug } from 'debug';
10
10
  import { CustomError } from 'ts-custom-error';
11
11
  import axios from 'axios';
12
12
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
13
- import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc, addDoc, deleteDoc, collection, getDocs, query, where, orderBy, limit, startAfter, startAt } from 'firebase/firestore';
13
+ import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc, setDoc, deleteDoc, collection, getDocs, query, where, orderBy, limit, startAfter, startAt, addDoc } from 'firebase/firestore';
14
14
  import { ref, uploadBytes } from 'firebase/storage';
15
15
  import { mutation, query as query$1 } from 'gql-query-builder';
16
16
 
@@ -2877,7 +2877,7 @@ const withGetFirestore = (MixinBase) => {
2877
2877
  .get();
2878
2878
  const data = docRef.data();
2879
2879
  if (isNil(data))
2880
- throw new NotFoundError(`Document '${collectionName}/${JSON.stringify(identifiers)}' not found`);
2880
+ throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers).shift()}' not found`);
2881
2881
  const res = ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted)) || data;
2882
2882
  logger.log({ req, res });
2883
2883
  return res;
@@ -3057,10 +3057,10 @@ const withCreateFirestore = (MixinBase) => {
3057
3057
  }
3058
3058
  }
3059
3059
  async save(data) {
3060
- var _a, _b, _c;
3060
+ var _a, _b;
3061
3061
  const collectionPath = this.buildCollectionPathForAdd(data);
3062
3062
  const collection = this.collection(collectionPath);
3063
- return collection.add((_a = data === null || data === void 0 ? void 0 : data.toPlain) === null || _a === void 0 ? void 0 : _a.call(data), (_c = (_b = Object.values(data.identifier).shift()) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b));
3063
+ return collection.add(data, (_b = (_a = Object.values(data.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a));
3064
3064
  }
3065
3065
  buildCollectionPathForAdd(identifiers) {
3066
3066
  return this.isSubCollection(this)
@@ -3811,7 +3811,7 @@ class ConnectDocumentService {
3811
3811
  if (doc.exists())
3812
3812
  await updateDoc(this.reference, data);
3813
3813
  else
3814
- await addDoc(this.reference.parent, data);
3814
+ await setDoc(this.reference, data);
3815
3815
  return this;
3816
3816
  }
3817
3817
  async delete() {
@@ -3896,7 +3896,7 @@ class ConnectCollectionService {
3896
3896
  if (isEmpty(id))
3897
3897
  return addDoc(this.reference, data);
3898
3898
  const docRef = doc(this.reference, id);
3899
- await updateDoc(docRef, data);
3899
+ await setDoc(docRef, data);
3900
3900
  return docRef;
3901
3901
  }
3902
3902
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.9.4-beta.5",
3
+ "version": "4.9.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },