addio-admin-sdk 1.7.87 → 1.7.88
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/Interfaces/Cart/index.d.ts +1 -0
- package/dist/Interfaces/Cart/index.js.map +1 -1
- package/dist/Interfaces/Space/index.d.ts +2 -1
- package/dist/Interfaces/Space/index.js +1 -0
- package/dist/Interfaces/Space/index.js.map +1 -1
- package/dist/lib/Cart/index.js +2 -2
- package/dist/lib/Cart/index.js.map +1 -1
- package/dist/lib/Space/index.d.ts +10 -0
- package/dist/lib/Space/index.js +40 -0
- package/dist/lib/Space/index.js.map +1 -1
- package/dist/rules/GR/utils/g2.d.ts +4 -4
- package/dist/rules/GR/utils/g2.js +5 -1
- package/dist/rules/GR/utils/g2.js.map +1 -1
- package/dist/utils/data.js +3 -2
- package/dist/utils/data.js.map +1 -1
- package/package.json +1 -1
|
@@ -61,6 +61,8 @@ import FirstOrderTracking from '../FirstOrderTracking';
|
|
|
61
61
|
import { ExternalServiceTypeEnum, IExternalServices } from '../../Interfaces/Space/IExternalService';
|
|
62
62
|
import { IStoreCreditHistory } from '../../Interfaces/Customer/IStoreCredit';
|
|
63
63
|
import Menu from '../../lib/Menu';
|
|
64
|
+
import Note from '../Note';
|
|
65
|
+
import { NoteTypeEnum } from '../../Interfaces/Note';
|
|
64
66
|
export default class Space {
|
|
65
67
|
private _space_ref;
|
|
66
68
|
private _user;
|
|
@@ -870,4 +872,12 @@ export default class Space {
|
|
|
870
872
|
getName: () => string;
|
|
871
873
|
getId: () => string;
|
|
872
874
|
isMultiPromo: () => boolean;
|
|
875
|
+
private _getNotes;
|
|
876
|
+
private _addNote;
|
|
877
|
+
private _deleteNote;
|
|
878
|
+
notes: {
|
|
879
|
+
get: (parentId: string, type: NoteTypeEnum) => Promise<Note[]>;
|
|
880
|
+
add: (content: string, createdByName: string, parentId: string, type: NoteTypeEnum) => Promise<Note>;
|
|
881
|
+
delete: (noteId: string) => Promise<boolean>;
|
|
882
|
+
};
|
|
873
883
|
}
|
package/dist/lib/Space/index.js
CHANGED
|
@@ -106,6 +106,7 @@ const categories_1 = require("../../utils/categories");
|
|
|
106
106
|
const IExternalService_1 = require("../../Interfaces/Space/IExternalService");
|
|
107
107
|
const utils_1 = require("../../services/products/utils");
|
|
108
108
|
const Menu_1 = __importDefault(require("../../lib/Menu"));
|
|
109
|
+
const Note_1 = __importDefault(require("../Note"));
|
|
109
110
|
class Space {
|
|
110
111
|
constructor(space, user, space_ref) {
|
|
111
112
|
this.getRef = () => this._space_ref;
|
|
@@ -5029,6 +5030,45 @@ class Space {
|
|
|
5029
5030
|
this.isMultiPromo = () => {
|
|
5030
5031
|
return !!this._space.multipromo_aware ? this._space.multipromo_aware : false;
|
|
5031
5032
|
};
|
|
5033
|
+
this._getNotes = async (parentId, type) => {
|
|
5034
|
+
try {
|
|
5035
|
+
const path = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/notes');
|
|
5036
|
+
const collRef = DatabaseService_1.default.asCollectionObject(this._space_ref.path, this._space_ref.id + '/notes');
|
|
5037
|
+
const docs = await DatabaseService_1.default.getDocuments(path, {
|
|
5038
|
+
query: [
|
|
5039
|
+
{ field: 'parent_id', operator: '==', value: parentId },
|
|
5040
|
+
{ field: 'type', operator: '==', value: type }
|
|
5041
|
+
]
|
|
5042
|
+
});
|
|
5043
|
+
return docs
|
|
5044
|
+
.filter((d) => d.exists && !!d.data)
|
|
5045
|
+
.map((d) => new Note_1.default(Object.assign(Object.assign({}, d.data), { id: d.id }), collRef, this._user))
|
|
5046
|
+
.sort((a, b) => {
|
|
5047
|
+
const dateA = !!a.data().created ? new Date(a.data().created).getTime() : 0;
|
|
5048
|
+
const dateB = !!b.data().created ? new Date(b.data().created).getTime() : 0;
|
|
5049
|
+
return dateB - dateA;
|
|
5050
|
+
});
|
|
5051
|
+
}
|
|
5052
|
+
catch (error) {
|
|
5053
|
+
(0, console_1.errorMessage)(`Error while getting notes: ${error}`);
|
|
5054
|
+
return [];
|
|
5055
|
+
}
|
|
5056
|
+
};
|
|
5057
|
+
this._addNote = async (content, createdByName, parentId, type) => {
|
|
5058
|
+
const collRef = DatabaseService_1.default.asCollectionObject(this._space_ref.path, this._space_ref.id + '/notes');
|
|
5059
|
+
const note = new Note_1.default({ content, created_by_name: createdByName, parent_id: parentId, type }, collRef, this._user);
|
|
5060
|
+
const id = await note.save();
|
|
5061
|
+
return new Note_1.default(Object.assign(Object.assign({}, note.data()), { id, created: new Date(), created_by_email: this._user }), collRef, this._user);
|
|
5062
|
+
};
|
|
5063
|
+
this._deleteNote = async (noteId) => {
|
|
5064
|
+
const path = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/notes');
|
|
5065
|
+
return await DatabaseService_1.default.deleteDocument(path, noteId);
|
|
5066
|
+
};
|
|
5067
|
+
this.notes = {
|
|
5068
|
+
get: this._getNotes,
|
|
5069
|
+
add: this._addNote,
|
|
5070
|
+
delete: this._deleteNote
|
|
5071
|
+
};
|
|
5032
5072
|
const lengthToCheck = space_ref.path.startsWith('/') ? 6 : 5;
|
|
5033
5073
|
if (space_ref.path.split('/').length != lengthToCheck) {
|
|
5034
5074
|
try {
|