Skip to content

Commit

Permalink
delete map adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Aug 7, 2023
1 parent 233d299 commit d493494
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 88 deletions.
3 changes: 2 additions & 1 deletion adapters/bonusprogram/BonusProgramAdapter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class BonusProgramAdapter {
id;
config = {};
constructor(config) {
this.config = {};
this.config = config;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion adapters/captcha/CaptchaAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
*/
Object.defineProperty(exports, "__esModule", { value: true });
class CaptchaAdapter {
static taskStorage = {};
}
CaptchaAdapter.taskStorage = {};
exports.default = CaptchaAdapter;
1 change: 1 addition & 0 deletions adapters/discount/AbstractDiscountAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class AbstractDiscountHandlerINSTANCE {
static discounts;
}
exports.default = AbstractDiscountHandlerINSTANCE;
16 changes: 16 additions & 0 deletions adapters/discount/default/configuredDiscount.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ class configuredDiscount extends AbstractDiscount_1.default {
// this.displayGroupDiscount = discount.displayGroupDiscount;
// this.displayGroupDish = discount.displayGroupDish;
}
id;
isJoint;
name;
isPublic;
description;
concept;
configDiscount;
discount;
discountType;
actions;
enable;
isDeleted;
sortOrder;
productCategoryDiscounts;
hash;
worktime;
condition(order) {
throw new Error("Method not implemented.");
}
Expand Down
14 changes: 7 additions & 7 deletions adapters/discount/default/discountAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ exports.DiscountAdapter = void 0;
const configuredDiscount_1 = require("./configuredDiscount");
const worktime_1 = require("@webresto/worktime");
class DiscountAdapter {
// constructor all discounts isDeleted: true
// public readonly DiscountA: AbstractDiscount;
// protected constructor() {
// // this.DiscountA = DiscountA;
// Discount.setDelete();
// }
static discounts = {};
static async apply(order) {
// Order.concept : string
// when apply => use only discounts from this.discounts
Expand Down Expand Up @@ -96,11 +103,4 @@ class DiscountAdapter {
return DiscountAdapter.prototype;
}
}
// constructor all discounts isDeleted: true
// public readonly DiscountA: AbstractDiscount;
// protected constructor() {
// // this.DiscountA = DiscountA;
// Discount.setDelete();
// }
DiscountAdapter.discounts = {};
exports.DiscountAdapter = DiscountAdapter;
28 changes: 5 additions & 23 deletions adapters/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Adapter = exports.OTP = exports.Captcha = exports.Map = void 0;
exports.Adapter = exports.OTP = exports.Captcha = void 0;
const RMSAdapter_1 = require("./rms/RMSAdapter");
const pow_1 = require("./captcha/default/pow");
const defaultOTP_1 = require("./otp/default/defaultOTP");
Expand All @@ -10,27 +10,6 @@ const fs = require("fs");
const discountAdapter_1 = require("./discount/default/discountAdapter");
// import DiscountAdapter from "./discount/AbstractDiscountAdapter";
const WEBRESTO_MODULES_PATH = process.env.WEBRESTO_MODULES_PATH === undefined ? "@webresto" : process.env.WEBRESTO_MODULES_PATH;
/**
* retruns Map-adapter
*/
class Map {
static async getAdapter(adapterName) {
if (!adapterName) {
adapterName = await Settings.get("DEFAULT_MAP_ADAPTER");
}
let adapterLocation = WEBRESTO_MODULES_PATH + "/" + adapterName.toLowerCase() + "-map-adapter";
adapterLocation = fs.existsSync(adapterLocation) ? adapterLocation : "@webresto/" + adapterName.toLowerCase() + "-map-adapter";
try {
const adapter = require(adapterLocation);
return adapter.MapAdapter.default;
}
catch (e) {
sails.log.error("CORE > getAdapter Map > error; ", e);
throw new Error("Module " + adapterLocation + " not found");
}
}
}
exports.Map = Map;
/**
* retruns Captcha-adapter
*/
Expand Down Expand Up @@ -83,6 +62,10 @@ class OTP {
exports.OTP = OTP;
/** TODO: move other Adapters to one class adapter */
class Adapter {
// Singletons
static instanceRMS;
static instanceMF;
static WEBRESTO_MODULES_PATH = process.env.WEBRESTO_MODULES_PATH === undefined ? "@webresto" : process.env.WEBRESTO_MODULES_PATH;
static async getDiscountAdapter(adapterName, initParams) {
if (!adapterName) {
adapterName = await Settings.get("DEFAULT_DISCOUNT_ADAPTER");
Expand Down Expand Up @@ -223,5 +206,4 @@ class Adapter {
}
}
}
Adapter.WEBRESTO_MODULES_PATH = process.env.WEBRESTO_MODULES_PATH === undefined ? "@webresto" : process.env.WEBRESTO_MODULES_PATH;
exports.Adapter = Adapter;
8 changes: 0 additions & 8 deletions adapters/map/MapAdapter.js

This file was deleted.

12 changes: 0 additions & 12 deletions adapters/map/Point.js

This file was deleted.

22 changes: 0 additions & 22 deletions adapters/map/Polygon.js

This file was deleted.

3 changes: 3 additions & 0 deletions adapters/mediafile/MediaFileAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
const uuid_1 = require("uuid");
;
class MediaFileAdapter {
config;
initializationPromise;
UUID_NAMESPACE;
constructor(config) {
this.config = config;
this.initializationPromise = this.initialize();
Expand Down
5 changes: 3 additions & 2 deletions adapters/mediafile/default/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ const path = require("path");
// }
// },
class LocalMediaFileAdapter extends MediaFileAdapter_1.default {
processing = false;
processingTimeout; // TODO: rewrite by proxy
loadMediaFilesProcessQueue = [];
constructor(config) {
super(config);
this.processing = false;
this.loadMediaFilesProcessQueue = [];
this.loadMediaFiles();
}
getNameByUrl(url, ext, options, salt = false) {
Expand Down
2 changes: 2 additions & 0 deletions adapters/payment/PaymentAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class PaymentAdapter {
InitPaymentAdapter;
config;
constructor(InitPaymentAdapter) {
this.InitPaymentAdapter = InitPaymentAdapter;
this.config = InitPaymentAdapter.config;
Expand Down
7 changes: 6 additions & 1 deletion adapters/rms/RMSAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const ObservablePromise_1 = require("../../libs/ObservablePromise");
* An abstract RMS adapter class. Used to create new RMS adapters.
*/
class RMSAdapter {
config = {};
static syncProductsInterval;
static syncOutOfStocksInterval;
initializationPromise;
syncProductsPromise;
syncOutOfStocksPromise;
constructor(config) {
this.config = {};
this.config = config;
// Run async initialization
this.initializationPromise = this.initialize();
Expand Down
9 changes: 9 additions & 0 deletions libs/AwaitEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const sleep = require("util").promisify(setTimeout);
* с ошибкой или время ожидания вышло).
*/
class AwaitEmitter {
events;
name;
timeout;
/**
* @param name - название нового эмиттера
* @param timeout - указывает сколько милисекунд ожидать функции, которые возвращают Promise.
Expand Down Expand Up @@ -139,6 +142,8 @@ exports.default = AwaitEmitter;
* Объект собятия, хранит название события и его слушателей
*/
class Event {
name;
fns;
constructor(name) {
this.name = name;
this.fns = [];
Expand All @@ -149,6 +154,10 @@ class Event {
* ошибку, которые вернула или вызвала функция
*/
class Response {
label;
state;
result;
error;
constructor(label, result, error, timeout) {
this.label = label;
this.result = result;
Expand Down
2 changes: 2 additions & 0 deletions libs/NotificationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationManager = void 0;
class NotificationManager {
static kitchenChannels;
static userChannels;
constructor() {
}
isChannelExist(channel) {
Expand Down
3 changes: 2 additions & 1 deletion libs/ObservablePromise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObservablePromise = void 0;
class ObservablePromise {
_status = 'pending';
_promise;
constructor(promise) {
this._status = 'pending';
this._promise = promise
.then((value) => {
this._status = 'fulfilled';
Expand Down
4 changes: 4 additions & 0 deletions libs/hookTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const buildDictionary = require("sails-build-dictionary");
* Provide tools for hooks. Has only static methods.
*/
class HookTools {
/**
* Policies array is one for all project. It not assigned with sails policies
*/
static policies;
/**
* Bind models from folder. Folder must be full path.
* @param folder - path to models
Expand Down
2 changes: 1 addition & 1 deletion models/Dish.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ let Model = {
}
const dish = await Dish.findOne(criteria);
if (!dish) {
return Dish.create({ hash, ...values }).fetch();
return await Dish.create({ hash, ...values }).fetch();
}
else {
if (hash === dish.hash) {
Expand Down
2 changes: 1 addition & 1 deletion models/Dish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ let Model = {
const dish = await Dish.findOne(criteria);

if (!dish) {
return Dish.create({ hash, ...values }).fetch();
return await Dish.create({ hash, ...values }).fetch();
} else {
if (hash === dish.hash) {
return dish;
Expand Down
7 changes: 7 additions & 0 deletions test/generators/lib/mockSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const util_1 = require("util");
const listFiles = (0, util_1.promisify)(fs_1.readdir);
const isRecord = (o) => o != null && typeof o === "object" && !(o instanceof Array) && Object.keys(o).reduce((result, key) => result && typeof key === "string", true);
class MockSet {
static instance;
declarationPaths;
fileNames;
fileData;
mocks;
extension;
interfaces;
constructor() {
this.declarationPaths = ["../../models/", "../../interfaces/", "../../adapters/", "../../config/", "../../libs/"];
this.extension = ".d.ts";
Expand Down
16 changes: 8 additions & 8 deletions test/mocks/adapter/bonusProgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.InMemoryBonusProgramAdapter = void 0;
const BonusProgramAdapter_1 = require("../../../adapters/bonusprogram/BonusProgramAdapter");
class InMemoryBonusProgramAdapter extends BonusProgramAdapter_1.default {
transactions = new Map();
users = new Map();
name = "test bonus adapter name";
adapter = "test";
exchangeRate = 10;
coveragePercentage = 0.5;
decimals = 1;
description = "In-memory BonusProgramAdapter";
constructor(config) {
super(config);
this.transactions = new Map();
this.users = new Map();
this.name = "test bonus adapter name";
this.adapter = "test";
this.exchangeRate = 10;
this.coveragePercentage = 0.5;
this.decimals = 1;
this.description = "In-memory BonusProgramAdapter";
}
async registration(user) {
if (!this.users.has(user.id)) {
Expand Down

0 comments on commit d493494

Please sign in to comment.