addio-admin-sdk 1.7.71 → 1.7.72
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/TCG/index.d.ts +42 -0
- package/dist/Interfaces/TCG/index.js +7 -0
- package/dist/Interfaces/TCG/index.js.map +1 -1
- package/dist/lib/Category/index.js +2 -1
- package/dist/lib/Category/index.js.map +1 -1
- package/dist/lib/Queue/index.d.ts +40 -0
- package/dist/lib/Queue/index.js +255 -0
- package/dist/lib/Queue/index.js.map +1 -0
- package/dist/lib/Space/index.d.ts +3 -0
- package/dist/lib/Space/index.js +63 -2
- package/dist/lib/Space/index.js.map +1 -1
- package/dist/services/products/BaseClass.d.ts +6 -0
- package/dist/services/products/BaseClass.js +14 -2
- package/dist/services/products/BaseClass.js.map +1 -1
- package/dist/services/products/TCGService.d.ts +16 -5
- package/dist/services/products/TCGService.js +240 -15
- package/dist/services/products/TCGService.js.map +1 -1
- package/dist/services/products/utils.d.ts +2 -2
- package/dist/services/products/utils.js +1 -1
- package/dist/services/products/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -50,3 +50,45 @@ export interface ITcgAttributeValue {
|
|
|
50
50
|
readonly game_slug_csv: string;
|
|
51
51
|
readonly image_url: string | null;
|
|
52
52
|
}
|
|
53
|
+
export interface IServiceResult {
|
|
54
|
+
readonly status: string;
|
|
55
|
+
readonly error: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ICardDetails {
|
|
58
|
+
slug: string;
|
|
59
|
+
brandSlug?: string;
|
|
60
|
+
category: string;
|
|
61
|
+
setSlug: string;
|
|
62
|
+
isSingle: boolean;
|
|
63
|
+
name: {
|
|
64
|
+
fr: string;
|
|
65
|
+
en: string;
|
|
66
|
+
};
|
|
67
|
+
description: {
|
|
68
|
+
fr: string;
|
|
69
|
+
en: string;
|
|
70
|
+
};
|
|
71
|
+
attributes: {
|
|
72
|
+
name: string;
|
|
73
|
+
value: string;
|
|
74
|
+
}[];
|
|
75
|
+
images: string[];
|
|
76
|
+
currentPrice: number | null;
|
|
77
|
+
priceHistory: IPriceHistory[];
|
|
78
|
+
}
|
|
79
|
+
export interface IPriceHistory {
|
|
80
|
+
provider: string;
|
|
81
|
+
prices: IPricePoint[];
|
|
82
|
+
}
|
|
83
|
+
export interface IPricePoint {
|
|
84
|
+
date: string;
|
|
85
|
+
subType: string | null;
|
|
86
|
+
low?: number;
|
|
87
|
+
high?: number;
|
|
88
|
+
market: number;
|
|
89
|
+
}
|
|
90
|
+
export declare enum TCGProductFormatsEnum {
|
|
91
|
+
CARD = "tcg_card",
|
|
92
|
+
PACK = "tcg_pack",
|
|
93
|
+
BUNDLE = "tcg_bundle"
|
|
94
|
+
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TCGProductFormatsEnum = void 0;
|
|
4
|
+
var TCGProductFormatsEnum;
|
|
5
|
+
(function (TCGProductFormatsEnum) {
|
|
6
|
+
TCGProductFormatsEnum["CARD"] = "tcg_card";
|
|
7
|
+
TCGProductFormatsEnum["PACK"] = "tcg_pack";
|
|
8
|
+
TCGProductFormatsEnum["BUNDLE"] = "tcg_bundle";
|
|
9
|
+
})(TCGProductFormatsEnum = exports.TCGProductFormatsEnum || (exports.TCGProductFormatsEnum = {}));
|
|
3
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/TCG/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/TCG/index.ts"],"names":[],"mappings":";;;AA0FA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAChC,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,8CAAqB,CAAA;AACtB,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC"}
|
|
@@ -13,6 +13,7 @@ const Space_1 = __importDefault(require("../Space"));
|
|
|
13
13
|
const algolia_1 = require("../../utils/algolia");
|
|
14
14
|
const DatabaseService_1 = __importDefault(require("../../services/database/DatabaseService"));
|
|
15
15
|
const baseService_1 = require("../baseService");
|
|
16
|
+
const round_1 = __importDefault(require("lodash/round"));
|
|
16
17
|
class Category extends baseService_1.BaseServiceClass {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(...arguments);
|
|
@@ -139,7 +140,7 @@ class Category extends baseService_1.BaseServiceClass {
|
|
|
139
140
|
(0, console_1.errorMessage)(`Error while getting price rule returning orriginal price ${error}`);
|
|
140
141
|
return price;
|
|
141
142
|
}
|
|
142
|
-
return newPrice;
|
|
143
|
+
return (0, round_1.default)(newPrice, 2);
|
|
143
144
|
};
|
|
144
145
|
}
|
|
145
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Category/index.ts"],"names":[],"mappings":";;;;;;AACA,2CAAuE;AACvE,iDAAkE;AAClE,iDAAkD;AAClD,6DAAoC;AACpC,+DAAsC;AACtC,qDAA4B;AAC5B,iDAAkD;AAElD,8FAAqE;AACrE,gDAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Category/index.ts"],"names":[],"mappings":";;;;;;AACA,2CAAuE;AACvE,iDAAkE;AAClE,iDAAkD;AAClD,6DAAoC;AACpC,+DAAsC;AACtC,qDAA4B;AAC5B,iDAAkD;AAElD,8FAAqE;AACrE,gDAAiD;AAEjD,yDAAgC;AAEhC,MAAqB,QAAS,SAAQ,8BAA2B;IAAjE;;QAmCQ,SAAI,GAAG,GAAc,EAAE,CAAC,IAAI,CAAC,KAAkB,CAAA;QAE/C,WAAM,GAAG,KAAK,IAAmC,EAAE;YACzD,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM;gBAAE,OAAO,SAAS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AI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAE5D,IAAI,CAAC,CAAC,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEzB,OAAO,KAAK,CAAA;AACb,CAAC,CAAA;AAgNa,8CAAqC,GAAG,KAAK,EAAE,QAAmB,EAAE,KAAY,EAAE,EAAE;IACjG,MAAM,uBAAuB,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACxD,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;KAClE,CAAC,CAAA;IAEF,IAAI,CAAC,CAAC,CAAC,uBAAuB,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAEhF,KAAK,MAAM,IAAI,IAAI,uBAAuB,EAAE;QAC3C,IAAI;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;YACjC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;SACvB;QAAC,OAAO,KAAK,EAAE;YACf,OAAO,CAAC,GAAG,CAAC,iCAAiC,QAAQ,CAAC,IAAI,iBAAiB,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAA;YACrG,SAAQ;SACR;KACD;IACD,OAAO,IAAI,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Space from '../Space';
|
|
2
|
+
export default class Queue {
|
|
3
|
+
private _space;
|
|
4
|
+
constructor(space: Space);
|
|
5
|
+
last: () => Promise<QueueItem>;
|
|
6
|
+
first: () => Promise<QueueItem>;
|
|
7
|
+
lastX: (numberOfReturnedItems: number) => Promise<QueueItem[]>;
|
|
8
|
+
firstX: (numberOfReturnedItems: number) => Promise<QueueItem[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare enum QueueItemTypeEnum {
|
|
11
|
+
PRODUCT_CREATE = 0,
|
|
12
|
+
PRODUCT_UPDATE = 1,
|
|
13
|
+
PRODUCT_DELETE = 2,
|
|
14
|
+
INVENTORY_UPDATE = 3,
|
|
15
|
+
CLIENT_CREATE = 4,
|
|
16
|
+
CLIENT_UPDATE = 5,
|
|
17
|
+
CLIENT_DELETE = 6
|
|
18
|
+
}
|
|
19
|
+
export declare enum QueueExternalService {
|
|
20
|
+
QUICKBOOKS = 0,
|
|
21
|
+
SAGE = 1,
|
|
22
|
+
ACOMBA = 2
|
|
23
|
+
}
|
|
24
|
+
export declare enum QueueDirection {
|
|
25
|
+
FROM_OUTTER = 0,
|
|
26
|
+
TO_OUTTER = 1
|
|
27
|
+
}
|
|
28
|
+
export declare class QueueItem {
|
|
29
|
+
private _space;
|
|
30
|
+
private _type;
|
|
31
|
+
private _added_at;
|
|
32
|
+
private _id;
|
|
33
|
+
private _service;
|
|
34
|
+
private _direction;
|
|
35
|
+
private _details?;
|
|
36
|
+
private _progress;
|
|
37
|
+
constructor(space: Space, type: QueueItemTypeEnum, added_at: Date, id: string, service: QueueExternalService, direction: QueueDirection, rest: any);
|
|
38
|
+
private _triggerExec;
|
|
39
|
+
private _getOperation;
|
|
40
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
39
|
+
var t = {};
|
|
40
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
41
|
+
t[p] = s[p];
|
|
42
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
43
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
44
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
45
|
+
t[p[i]] = s[p[i]];
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.QueueItem = exports.QueueDirection = exports.QueueExternalService = exports.QueueItemTypeEnum = void 0;
|
|
54
|
+
var DatabaseService_1 = __importDefault(require("../../services/database/DatabaseService"));
|
|
55
|
+
var console_1 = require("../../utils/console");
|
|
56
|
+
var Product_1 = __importDefault(require("../Product"));
|
|
57
|
+
var Queue = (function () {
|
|
58
|
+
function Queue(space) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
this.last = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
61
|
+
var lastReq, _a, type, added_at, id, service, direction, rest;
|
|
62
|
+
return __generator(this, function (_b) {
|
|
63
|
+
switch (_b.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
if (!!!this._space)
|
|
66
|
+
throw new Error("Space must be defined");
|
|
67
|
+
return [4, DatabaseService_1.default.getDocuments(this._space.documents.queue(), {
|
|
68
|
+
orderBy: 'added_at',
|
|
69
|
+
order: 'desc',
|
|
70
|
+
limit: 1
|
|
71
|
+
})];
|
|
72
|
+
case 1:
|
|
73
|
+
lastReq = _b.sent();
|
|
74
|
+
if (lastReq.length == 0)
|
|
75
|
+
throw new Error("Can't access last, may be empty");
|
|
76
|
+
if (lastReq[0].exists || !!!lastReq[0].data)
|
|
77
|
+
throw new Error("Can't access last, may be empty");
|
|
78
|
+
_a = lastReq[0].data, type = _a.type, added_at = _a.added_at, id = _a.id, service = _a.service, direction = _a.direction, rest = __rest(_a, ["type", "added_at", "id", "service", "direction"]);
|
|
79
|
+
return [2, new QueueItem(this._space, type, added_at, id, service, direction, rest)];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}); };
|
|
83
|
+
this.first = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
var firstReq, _a, type, added_at, id, service, direction, rest;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
if (!!!this._space)
|
|
89
|
+
throw new Error("Space must be defined");
|
|
90
|
+
return [4, DatabaseService_1.default.getDocuments(this._space.documents.queue(), {
|
|
91
|
+
orderBy: 'added_at',
|
|
92
|
+
order: 'asc',
|
|
93
|
+
limit: 1
|
|
94
|
+
})];
|
|
95
|
+
case 1:
|
|
96
|
+
firstReq = _b.sent();
|
|
97
|
+
if (firstReq.length == 0)
|
|
98
|
+
throw new Error("Can't access first, may be empty");
|
|
99
|
+
if (firstReq[0].exists || !!!firstReq[0].data)
|
|
100
|
+
throw new Error("Can't access last, may be empty");
|
|
101
|
+
_a = firstReq[0].data, type = _a.type, added_at = _a.added_at, id = _a.id, service = _a.service, direction = _a.direction, rest = __rest(_a, ["type", "added_at", "id", "service", "direction"]);
|
|
102
|
+
return [2, new QueueItem(this._space, type, added_at, id, service, direction, rest)];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); };
|
|
106
|
+
this.lastX = function (numberOfReturnedItems) { return __awaiter(_this, void 0, void 0, function () {
|
|
107
|
+
var lastReq;
|
|
108
|
+
var _this = this;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0:
|
|
112
|
+
if (!!!this._space)
|
|
113
|
+
throw new Error("Space must be defined");
|
|
114
|
+
return [4, DatabaseService_1.default.getDocuments(this._space.documents.queue(), {
|
|
115
|
+
orderBy: 'added_at',
|
|
116
|
+
order: 'desc',
|
|
117
|
+
limit: numberOfReturnedItems
|
|
118
|
+
})];
|
|
119
|
+
case 1:
|
|
120
|
+
lastReq = _a.sent();
|
|
121
|
+
if (lastReq.length == 0)
|
|
122
|
+
throw new Error("Can't access last, may be empty");
|
|
123
|
+
if (lastReq[0].exists || !!!lastReq[0].data)
|
|
124
|
+
throw new Error("Can't access last, may be empty");
|
|
125
|
+
return [2, lastReq.map(function (d) {
|
|
126
|
+
var _a = d.data, type = _a.type, added_at = _a.added_at, id = _a.id, service = _a.service, direction = _a.direction, rest = __rest(_a, ["type", "added_at", "id", "service", "direction"]);
|
|
127
|
+
return new QueueItem(_this._space, type, added_at, id, service, direction, rest);
|
|
128
|
+
})];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}); };
|
|
132
|
+
this.firstX = function (numberOfReturnedItems) { return __awaiter(_this, void 0, void 0, function () {
|
|
133
|
+
var firstReq;
|
|
134
|
+
var _this = this;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
137
|
+
case 0:
|
|
138
|
+
if (!!!this._space)
|
|
139
|
+
throw new Error("Space must be defined");
|
|
140
|
+
return [4, DatabaseService_1.default.getDocuments(this._space.documents.queue(), {
|
|
141
|
+
orderBy: 'added_at',
|
|
142
|
+
order: 'asc',
|
|
143
|
+
limit: numberOfReturnedItems
|
|
144
|
+
})];
|
|
145
|
+
case 1:
|
|
146
|
+
firstReq = _a.sent();
|
|
147
|
+
if (firstReq.length == 0)
|
|
148
|
+
throw new Error("Can't access first, may be empty");
|
|
149
|
+
if (firstReq[0].exists || !!!firstReq[0].data)
|
|
150
|
+
throw new Error("Can't access last, may be empty");
|
|
151
|
+
return [2, firstReq.map(function (d) {
|
|
152
|
+
var _a = d.data, type = _a.type, added_at = _a.added_at, id = _a.id, service = _a.service, direction = _a.direction, rest = __rest(_a, ["type", "added_at", "id", "service", "direction"]);
|
|
153
|
+
return new QueueItem(_this._space, type, added_at, id, service, direction, rest);
|
|
154
|
+
})];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); };
|
|
158
|
+
this._space = space;
|
|
159
|
+
}
|
|
160
|
+
return Queue;
|
|
161
|
+
}());
|
|
162
|
+
exports.default = Queue;
|
|
163
|
+
var QueueItemTypeEnum;
|
|
164
|
+
(function (QueueItemTypeEnum) {
|
|
165
|
+
QueueItemTypeEnum[QueueItemTypeEnum["PRODUCT_CREATE"] = 0] = "PRODUCT_CREATE";
|
|
166
|
+
QueueItemTypeEnum[QueueItemTypeEnum["PRODUCT_UPDATE"] = 1] = "PRODUCT_UPDATE";
|
|
167
|
+
QueueItemTypeEnum[QueueItemTypeEnum["PRODUCT_DELETE"] = 2] = "PRODUCT_DELETE";
|
|
168
|
+
QueueItemTypeEnum[QueueItemTypeEnum["INVENTORY_UPDATE"] = 3] = "INVENTORY_UPDATE";
|
|
169
|
+
QueueItemTypeEnum[QueueItemTypeEnum["CLIENT_CREATE"] = 4] = "CLIENT_CREATE";
|
|
170
|
+
QueueItemTypeEnum[QueueItemTypeEnum["CLIENT_UPDATE"] = 5] = "CLIENT_UPDATE";
|
|
171
|
+
QueueItemTypeEnum[QueueItemTypeEnum["CLIENT_DELETE"] = 6] = "CLIENT_DELETE";
|
|
172
|
+
})(QueueItemTypeEnum = exports.QueueItemTypeEnum || (exports.QueueItemTypeEnum = {}));
|
|
173
|
+
var QueueExternalService;
|
|
174
|
+
(function (QueueExternalService) {
|
|
175
|
+
QueueExternalService[QueueExternalService["QUICKBOOKS"] = 0] = "QUICKBOOKS";
|
|
176
|
+
QueueExternalService[QueueExternalService["SAGE"] = 1] = "SAGE";
|
|
177
|
+
QueueExternalService[QueueExternalService["ACOMBA"] = 2] = "ACOMBA";
|
|
178
|
+
})(QueueExternalService = exports.QueueExternalService || (exports.QueueExternalService = {}));
|
|
179
|
+
var QueueDirection;
|
|
180
|
+
(function (QueueDirection) {
|
|
181
|
+
QueueDirection[QueueDirection["FROM_OUTTER"] = 0] = "FROM_OUTTER";
|
|
182
|
+
QueueDirection[QueueDirection["TO_OUTTER"] = 1] = "TO_OUTTER";
|
|
183
|
+
})(QueueDirection = exports.QueueDirection || (exports.QueueDirection = {}));
|
|
184
|
+
var QueueItem = (function () {
|
|
185
|
+
function QueueItem(space, type, added_at, id, service, direction, rest) {
|
|
186
|
+
var _this = this;
|
|
187
|
+
this._triggerExec = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
188
|
+
var operation, _a, _b, _c, _d, error_1;
|
|
189
|
+
return __generator(this, function (_e) {
|
|
190
|
+
switch (_e.label) {
|
|
191
|
+
case 0:
|
|
192
|
+
_e.trys.push([0, 5, , 6]);
|
|
193
|
+
operation = this._getOperation(this._type);
|
|
194
|
+
if (!!!!this._details) return [3, 2];
|
|
195
|
+
_a = this;
|
|
196
|
+
_b = _a._progress;
|
|
197
|
+
return [4, operation()];
|
|
198
|
+
case 1:
|
|
199
|
+
_a._progress = _b + _e.sent();
|
|
200
|
+
return [3, 4];
|
|
201
|
+
case 2:
|
|
202
|
+
_c = this;
|
|
203
|
+
_d = _c._progress;
|
|
204
|
+
return [4, operation(this._details)];
|
|
205
|
+
case 3:
|
|
206
|
+
_c._progress = _d + _e.sent();
|
|
207
|
+
_e.label = 4;
|
|
208
|
+
case 4: return [3, 6];
|
|
209
|
+
case 5:
|
|
210
|
+
error_1 = _e.sent();
|
|
211
|
+
(0, console_1.errorMessage)("Error while processing queue ".concat(error_1, " - ").concat(JSON.stringify(error_1)));
|
|
212
|
+
return [3, 6];
|
|
213
|
+
case 6: return [2];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}); };
|
|
217
|
+
this._getOperation = function (type) { return __awaiter(_this, void 0, void 0, function () {
|
|
218
|
+
var _this = this;
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
switch (type) {
|
|
221
|
+
case QueueItemTypeEnum.CLIENT_CREATE:
|
|
222
|
+
case QueueItemTypeEnum.CLIENT_DELETE:
|
|
223
|
+
case QueueItemTypeEnum.CLIENT_UPDATE:
|
|
224
|
+
case QueueItemTypeEnum.PRODUCT_CREATE:
|
|
225
|
+
return [2, this._space.addProduct];
|
|
226
|
+
case QueueItemTypeEnum.PRODUCT_DELETE:
|
|
227
|
+
return [2, function () {
|
|
228
|
+
return new Product_1.default(_this._details, DatabaseService_1.default.asCollectionObject(_this._space.getRef().path, _this._space.getRef().id + '/products'), "External service ".concat(_this._service.toString())).delete;
|
|
229
|
+
}];
|
|
230
|
+
case QueueItemTypeEnum.PRODUCT_UPDATE:
|
|
231
|
+
return [2, function () {
|
|
232
|
+
return new Product_1.default({ id: _this._details.id }, DatabaseService_1.default.asCollectionObject(_this._space.getRef().path, _this._space.getRef().id + '/products'), "External service ".concat(_this._service.toString())).save;
|
|
233
|
+
}];
|
|
234
|
+
case QueueItemTypeEnum.INVENTORY_UPDATE:
|
|
235
|
+
default:
|
|
236
|
+
return [2, function () { }];
|
|
237
|
+
}
|
|
238
|
+
return [2];
|
|
239
|
+
});
|
|
240
|
+
}); };
|
|
241
|
+
this._space = space;
|
|
242
|
+
this._type = type;
|
|
243
|
+
this._added_at = added_at;
|
|
244
|
+
this._id = id;
|
|
245
|
+
this._service = service;
|
|
246
|
+
this._direction = direction;
|
|
247
|
+
this._details = rest;
|
|
248
|
+
this._progress = '';
|
|
249
|
+
if (direction === QueueDirection.FROM_OUTTER)
|
|
250
|
+
this._triggerExec();
|
|
251
|
+
}
|
|
252
|
+
return QueueItem;
|
|
253
|
+
}());
|
|
254
|
+
exports.QueueItem = QueueItem;
|
|
255
|
+
//# sourceMappingURL=index.js.map
|
|
@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E,KAAI,CAAC,QAAQ,CAAC,EAAE,EAAS,EAC/B,yBAAe,CAAC,kBAAkB,CAAC,KAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,KAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,EACpG,2BAAoB,KAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAE,CAC9C,CAAC,IAAI;4BAJN,CAIM,EAAA;oBACR,KAAK,iBAAiB,CAAC,gBAAgB,CAAC;oBACxC;wBACC,WAAO,cAAO,CAAC,EAAA;iBAChB;;;aACD,CAAA;QAnDA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;QAEnB,IAAI,SAAS,KAAK,cAAc,CAAC,WAAW;YAAE,IAAI,CAAC,YAAY,EAAE,CAAA;IAClE,CAAC;IA0CF,gBAAC;AAAD,CAAC,AAvED,IAuEC;AAvEY,8BAAS"}
|
|
@@ -179,6 +179,8 @@ export default class Space {
|
|
|
179
179
|
addProduct: (product: Partial<IProduct>, options?: {
|
|
180
180
|
index?: boolean;
|
|
181
181
|
}) => Promise<void>;
|
|
182
|
+
private _getExternalProductBySlug;
|
|
183
|
+
private _getExternalProductsSlugToTry;
|
|
182
184
|
private _getProducts;
|
|
183
185
|
private _getProductsPage;
|
|
184
186
|
private _getAllProducts;
|
|
@@ -196,6 +198,7 @@ export default class Space {
|
|
|
196
198
|
private _getMinFromDeclinations;
|
|
197
199
|
getPriceTypeByDeclinations: (sample: ICartItem[]) => "regular_price" | "promo_price" | "discount_price";
|
|
198
200
|
getPriceTypeForProduct: (declinations: IIndexedDeclination[]) => 'regular' | 'promo' | 'discount';
|
|
201
|
+
private _getIndexedProductFromProduct;
|
|
199
202
|
private _getCartItems;
|
|
200
203
|
private _getAllIndexedProducts;
|
|
201
204
|
private _saveAllIndexedCategories;
|
package/dist/lib/Space/index.js
CHANGED
|
@@ -104,6 +104,7 @@ const FirstOrderTracking_1 = __importDefault(require("../FirstOrderTracking"));
|
|
|
104
104
|
const logs_1 = require("../../services/logs");
|
|
105
105
|
const categories_1 = require("../../utils/categories");
|
|
106
106
|
const IExternalService_1 = require("../../Interfaces/Space/IExternalService");
|
|
107
|
+
const utils_1 = require("../../services/products/utils");
|
|
107
108
|
class Space {
|
|
108
109
|
constructor(space, user, space_ref) {
|
|
109
110
|
this.getRef = () => this._space_ref;
|
|
@@ -1527,14 +1528,35 @@ class Space {
|
|
|
1527
1528
|
(0, console_1.errorMessage)(`Error while creating new product: ${error} ${JSON.stringify(error)}`);
|
|
1528
1529
|
}
|
|
1529
1530
|
};
|
|
1531
|
+
this._getExternalProductBySlug = async (slug) => {
|
|
1532
|
+
const services = this.externalServices.getExternalServicesByType(IExternalService_1.ExternalServiceTypeEnum.PRODUCTS);
|
|
1533
|
+
const pathInfo = (0, context_1.getIdsBasedOnPath)(this._space_ref.path + '/' + this._space_ref.id);
|
|
1534
|
+
for (const service of services) {
|
|
1535
|
+
const serviceClass = (0, utils_1.getInstanceToUseForProductService)(service.external_service_slug, pathInfo.space, pathInfo.org);
|
|
1536
|
+
if (serviceClass) {
|
|
1537
|
+
const prod = await serviceClass.getProduct(slug, this._space);
|
|
1538
|
+
if (prod)
|
|
1539
|
+
return prod;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1530
1543
|
this._getProducts = async (options) => {
|
|
1531
1544
|
if (!!!this._user)
|
|
1532
1545
|
throw 'Invalid or unauthenticated user';
|
|
1533
1546
|
try {
|
|
1534
1547
|
let call = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/products');
|
|
1535
1548
|
const productsCollection = await DatabaseService_1.default.getDocuments(call, options);
|
|
1536
|
-
if (productsCollection.length == 0)
|
|
1549
|
+
if (productsCollection.length == 0) {
|
|
1550
|
+
const slug = this._getExternalProductsSlugToTry(options);
|
|
1551
|
+
if (slug) {
|
|
1552
|
+
const productFound = await this._getExternalProductBySlug(slug);
|
|
1553
|
+
if (productFound)
|
|
1554
|
+
return [
|
|
1555
|
+
new Product_4.default(Object.assign(Object.assign({}, productFound), { id: productFound.slug }), DatabaseService_1.default.asCollectionObject(this._space_ref.path, this._space_ref.id + '/products'), this._user)
|
|
1556
|
+
];
|
|
1557
|
+
}
|
|
1537
1558
|
return [];
|
|
1559
|
+
}
|
|
1538
1560
|
return productsCollection.map((productDoc) => new Product_4.default(Object.assign(Object.assign({}, productDoc.data), { id: productDoc.id }), DatabaseService_1.default.asCollectionObject(this._space_ref.path, this._space_ref.id + '/products'), this._user));
|
|
1539
1561
|
}
|
|
1540
1562
|
catch (error) {
|
|
@@ -1728,12 +1750,21 @@ class Space {
|
|
|
1728
1750
|
try {
|
|
1729
1751
|
let call = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/indexes/products/public');
|
|
1730
1752
|
const indexedProducts = await DatabaseService_1.default.getDocuments(call, options);
|
|
1753
|
+
if (indexedProducts.length == 0) {
|
|
1754
|
+
const slug = this._getExternalProductsSlugToTry(options);
|
|
1755
|
+
if (slug) {
|
|
1756
|
+
const productFound = await this._getExternalProductBySlug(slug);
|
|
1757
|
+
if (productFound) {
|
|
1758
|
+
return [await this._getIndexedProductFromProduct(productFound)];
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1731
1762
|
return indexedProducts
|
|
1732
1763
|
.filter((i) => !!i.exists)
|
|
1733
1764
|
.map((i) => (Object.assign(Object.assign({}, i.data), { id: i.id })));
|
|
1734
1765
|
}
|
|
1735
1766
|
catch (error) {
|
|
1736
|
-
console.log(`Error while fetching indexed products ${error} - ${
|
|
1767
|
+
console.log(`Error while fetching indexed products ${error} - ${error.stack}`);
|
|
1737
1768
|
return [];
|
|
1738
1769
|
}
|
|
1739
1770
|
};
|
|
@@ -1743,6 +1774,17 @@ class Space {
|
|
|
1743
1774
|
try {
|
|
1744
1775
|
let call = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/indexes/products/public');
|
|
1745
1776
|
const allExistingIndexes = await DatabaseService_1.default.getDocuments(call, options);
|
|
1777
|
+
if (allExistingIndexes.length == 0) {
|
|
1778
|
+
const slug = this._getExternalProductsSlugToTry(options);
|
|
1779
|
+
if (slug) {
|
|
1780
|
+
const productFound = await this._getExternalProductBySlug(slug);
|
|
1781
|
+
if (productFound) {
|
|
1782
|
+
return [
|
|
1783
|
+
new Product_2.default(await this._getIndexedProductFromProduct(productFound), DatabaseService_1.default.asCollectionObject(this._space_ref.path, this._space_ref.id + '/indexes/products/public'), this._user)
|
|
1784
|
+
];
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1746
1788
|
const products = allExistingIndexes
|
|
1747
1789
|
.filter((d) => !!d.exists)
|
|
1748
1790
|
.map((d) => new Product_2.default(d.data, DatabaseService_1.default.asCollectionObject(this._space_ref.path, this._space_ref.id + '/indexes/products/public'), this._user));
|
|
@@ -4843,6 +4885,25 @@ class Space {
|
|
|
4843
4885
|
this._space = space;
|
|
4844
4886
|
this._user = user;
|
|
4845
4887
|
}
|
|
4888
|
+
_getExternalProductsSlugToTry(options) {
|
|
4889
|
+
if (!options)
|
|
4890
|
+
return undefined;
|
|
4891
|
+
if (options.id)
|
|
4892
|
+
return options.id;
|
|
4893
|
+
if (options.query && options.query.length == 1 && options.query[0].operator == '==') {
|
|
4894
|
+
if (options.query[0].field == 'id' || options.query[0].field == 'slug')
|
|
4895
|
+
return options.query[0].value;
|
|
4896
|
+
}
|
|
4897
|
+
return undefined;
|
|
4898
|
+
}
|
|
4899
|
+
async _getIndexedProductFromProduct(product) {
|
|
4900
|
+
const categories = product.category ? await this.categories.get({ id: product.category }) : undefined;
|
|
4901
|
+
const brands = product.brand ? await this.brands.get({ id: product.brand }) : undefined;
|
|
4902
|
+
const category = categories && categories.length == 1 ? categories[0] : undefined;
|
|
4903
|
+
const brand = brands && brands.length == 1 ? brands[0] : undefined;
|
|
4904
|
+
const tree = !!category ? await category.getParentTree() : [];
|
|
4905
|
+
return await (0, Product_3.populateIndexedProduct)(product, tree, this, category, brand);
|
|
4906
|
+
}
|
|
4846
4907
|
}
|
|
4847
4908
|
exports.default = Space;
|
|
4848
4909
|
_a = Space;
|