Skip to content

Commit

Permalink
fix types import order
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Sep 6, 2024
1 parent 9731d81 commit cc77c60
Show file tree
Hide file tree
Showing 49 changed files with 211 additions and 216 deletions.
2 changes: 1 addition & 1 deletion hook/afterHook.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const hashCode_1 = require("../libs/hashCode");
/**
* Initial RMS and set timezone if it was given
Expand Down Expand Up @@ -59,4 +60,3 @@ async function default_1() {
sails.log.error("RestoCore > initialization error > ", e);
}
}
exports.default = default_1;
2 changes: 1 addition & 1 deletion hook/bindAdminpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = bindAdminpanel;
const bind_1 = __importDefault(require("../libs/adminpanel/models/bind"));
const ProductCatalog_1 = require("../libs/adminpanel/ProductCatalog/ProductCatalog");
function bindAdminpanel() {
Expand All @@ -14,7 +15,6 @@ function bindAdminpanel() {
CatalogHandler.add(productCatalog);
});
}
exports.default = bindAdminpanel;
function processBindAdminpanel() {
if (sails.hooks?.adminpanel?.addModelConfig !== undefined) {
const addModelConfig = sails.hooks.adminpanel.addModelConfig;
Expand Down
2 changes: 1 addition & 1 deletion hook/bindAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const serve_static_1 = __importDefault(require("serve-static"));
const path = __importStar(require("path"));
function default_1() {
sails.hooks.http.app.use('/restocore/assets', (0, serve_static_1.default)(path.join(__dirname, '../assets')));
}
exports.default = default_1;
;
2 changes: 1 addition & 1 deletion hook/bindDictionaries.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
let countries = require("../libs/dictionaries/countries.json");
function default_1() {
sails.dictionaries = {
Expand All @@ -22,5 +23,4 @@ function default_1() {
countries: countriesHash
};
}
exports.default = default_1;
;
2 changes: 1 addition & 1 deletion hook/bindLocales.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
async function default_1() {
Expand Down Expand Up @@ -56,4 +57,3 @@ async function default_1() {
sails.log.error("restocore bindTranslations > Error:", e);
}
}
exports.default = default_1;
2 changes: 1 addition & 1 deletion hook/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ToInitialize;
const hookTools_1 = __importDefault(require("../libs/hookTools"));
const path_1 = require("path");
const afterHook_1 = __importDefault(require("./afterHook"));
Expand Down Expand Up @@ -101,4 +102,3 @@ function ToInitialize(sails) {
}
};
}
exports.default = ToInitialize;
3 changes: 1 addition & 2 deletions interfaces/CustomData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCustomData = void 0;
exports.isCustomData = isCustomData;
function isCustomData(value) {
return typeof value === "object" && !Array.isArray(value) && value !== null;
}
exports.isCustomData = isCustomData;
1 change: 0 additions & 1 deletion interfaces/ORMModel.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="node" />
import { RequiredField, NonPrimitiveKeys, TypeOrArray } from "../interfaces/toolsTS";
import { WaterlinePromise, CRUDBuilder, UpdateBuilder, LifecycleCallbacks } from "waterline";
export type Callback<T> = (err: Error | null, result: T) => void;
Expand Down
2 changes: 1 addition & 1 deletion libs/checkExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* // TODO: Abandoned because we have gone to global changes from Dish to Item
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
/**
* Check additionalInfo. Return empty string if success or reject reason string
* @param obj
Expand Down Expand Up @@ -30,7 +31,6 @@ function default_1(obj) {
return "";
}
}
exports.default = default_1;
function checkTime(timeArray) {
return true;
}
2 changes: 1 addition & 1 deletion libs/findModelInstance.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = findModelInstanceByAttributes;
function findModelInstanceByAttributes(obj) {
const models = Object.keys(sails.models);
for (let i = 0; i < models.length; i++) {
Expand All @@ -25,4 +26,3 @@ function findModelInstanceByAttributes(obj) {
}
return null;
}
exports.default = findModelInstanceByAttributes;
2 changes: 1 addition & 1 deletion libs/getEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = getEmitter;
const AwaitEmitter_1 = __importDefault(require("./AwaitEmitter"));
let emitter;
/**
Expand All @@ -15,4 +16,3 @@ function getEmitter() {
}
return emitter;
}
exports.default = getEmitter;
7 changes: 3 additions & 4 deletions libs/hashCode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateUUID = exports.generateRandomString = void 0;
exports.default = hashCode;
exports.generateRandomString = generateRandomString;
exports.generateUUID = generateUUID;
/**
* Returns the hash of a string
* @param str - string to hash
Expand All @@ -10,13 +12,10 @@ const uuid_1 = require("uuid");
function hashCode(str) {
return crypto.createHash("sha256").update(str).digest("hex");
}
exports.default = hashCode;
function generateRandomString(length) {
const bytes = crypto.randomBytes(Math.ceil(length / 2));
return bytes.toString('hex').slice(0, length);
}
exports.generateRandomString = generateRandomString;
function generateUUID() {
return (0, uuid_1.v4)();
}
exports.generateUUID = generateUUID;
5 changes: 2 additions & 3 deletions libs/importParams.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addImportParam = void 0;
exports.default = default_1;
exports.addImportParam = addImportParam;
let importFns = [];
/**
* Параметры импорта блюд и групп при синхронизации из RMS adapter
Expand Down Expand Up @@ -35,7 +36,6 @@ async function default_1(obj) {
sails.log.error("core > importParams 1 >", e);
}
}
exports.default = default_1;
/**
* Добавление кастомной функции импорта, функция принимает блюдо или группу, может менять их поля как угодно, сохранять
* модель после изменений не обязательно, это сделает модуль обработки импорта
Expand All @@ -45,7 +45,6 @@ exports.default = default_1;
function addImportParam(label, fn) {
importFns.push({ label, fn });
}
exports.addImportParam = addImportParam;
/**
* EXAMPLE
*/
Expand Down
3 changes: 1 addition & 2 deletions libs/phoneValidByMask.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.phoneValidByMask = void 0;
exports.phoneValidByMask = phoneValidByMask;
function phoneValidByMask(phoneNumber, countryCode, phoneMasks) {
const cleanedPhoneNumber = phoneNumber.replace(/\D/g, '');
const codeWithoutPlus = countryCode.slice(1);
Expand Down Expand Up @@ -40,4 +40,3 @@ function phoneValidByMask(phoneNumber, countryCode, phoneMasks) {
}
return false;
}
exports.phoneValidByMask = phoneValidByMask;
3 changes: 1 addition & 2 deletions libs/slugIt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.slugIt = void 0;
exports.slugIt = slugIt;
const slugify_1 = __importDefault(require("slugify"));
async function slugIt(model, name, slugField = 'slug', opts) {
if (!Object.keys(sails.models).includes(model))
Expand All @@ -24,4 +24,3 @@ async function slugIt(model, name, slugField = 'slug', opts) {
slug = count === 0 ? slug : slug + "-" + count;
return slug;
}
exports.slugIt = slugIt;
7 changes: 3 additions & 4 deletions libs/stringsInArray.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractFieldValues = exports.someInArray = exports.stringsInArray = void 0;
exports.stringsInArray = stringsInArray;
exports.someInArray = someInArray;
exports.extractFieldValues = extractFieldValues;
const isValue_1 = require("../utils/isValue");
/**
* @notused
Expand All @@ -24,7 +26,6 @@ function stringsInArray(check, array) {
return array.includes(check);
}
}
exports.stringsInArray = stringsInArray;
function someInArray(check, array) {
if (!(0, isValue_1.isValue)(check))
return false;
Expand All @@ -36,7 +37,6 @@ function someInArray(check, array) {
}
return array.some((e) => check.includes(e));
}
exports.someInArray = someInArray;
function extractFieldValues(obj, fields, exclude = true, result = []) {
if (typeof obj === 'object' && obj !== null) {
for (let key in obj) {
Expand All @@ -55,4 +55,3 @@ function extractFieldValues(obj, fields, exclude = true, result = []) {
}
return result;
}
exports.extractFieldValues = extractFieldValues;
6 changes: 3 additions & 3 deletions models/BonusProgram.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ declare let attributes: {
/** user option */
enable: boolean;
automaticUserRegistration: boolean;
customData: string | {
[key: string]: string | number | boolean;
};
customData: {
[key: string]: string | boolean | number;
} | string;
};
type attributes = typeof attributes;
export interface BonusProgramRecord extends attributes, ORM {
Expand Down
6 changes: 3 additions & 3 deletions models/City.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ declare let attributes: {
name: string;
/** City was deleted */
isDeleted: boolean;
customData: string | {
[key: string]: string | number | boolean;
};
customData: {
[key: string]: string | boolean | number;
} | string;
};
type attributes = typeof attributes;
export interface CityRecord extends attributes, ORM {
Expand Down
4 changes: 3 additions & 1 deletion models/Dish.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Group from "./Group";
import { MediaFileRecord } from "./MediaFile";
import { CriteriaQuery, ORMModel } from "../interfaces/ORMModel";
import ORM from "../interfaces/ORM";
import { WorkTime } from "@webresto/worktime";
import { RequiredField, OptionalAll } from "../interfaces/toolsTS";
import { GroupModifier } from "../interfaces/Modifier";
import { CustomData } from "../interfaces/CustomData";
import User from "./User";
declare let attributes: {
/** */
id: string;
Expand Down Expand Up @@ -80,7 +82,7 @@ declare let attributes: {
/** The dish can be modified*/
isModificable: boolean;
/** Parental group */
parentGroup: any;
parentGroup: Group | any;
/** Tags for filtering (vegetarian, sharp ...) */
tags: any;
/** Balance for sale, if -1, then as much as you like */
Expand Down
18 changes: 9 additions & 9 deletions models/Group.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ declare let attributes: {
/** Sorting weight */
sortOrder: number;
dishes: DishRecord[];
parentGroup: string | GroupRecord;
childGroups: string[] | GroupRecord[];
recommendations: string[] | GroupRecord[];
recommendedBy: string[] | GroupRecord[];
parentGroup: GroupRecord | string;
childGroups: GroupRecord[] | string[];
recommendations: GroupRecord[] | string[];
recommendedBy: GroupRecord[] | string[];
/** Icon */
icon: {
type: string;
allowNull: boolean;
};
/** Images */
images: string[] | MediaFileRecord[];
images: MediaFileRecord[] | string[];
/** Placeholder for group dishes */
dishesPlaceholder: MediaFileRecord[];
dishesPlaceholder: MediaFileRecord;
/** The human easy readable*/
slug: string;
/** The concept to which the group belongs */
Expand All @@ -55,9 +55,9 @@ declare let attributes: {
promo: boolean;
/** Working hours */
worktime: WorkTime[];
customData: string | {
[key: string]: string | number | boolean;
};
customData: {
[key: string]: string | boolean | number;
} | string;
};
interface IVirtualFields {
discountAmount?: number;
Expand Down
2 changes: 1 addition & 1 deletion models/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ let attributes = {
/** Placeholder for group dishes */
dishesPlaceholder: {
model: "mediafile",
} as unknown as MediaFileRecord[],
} as unknown as MediaFileRecord,

/** The human easy readable*/
slug: {
Expand Down
8 changes: 4 additions & 4 deletions models/MediaFile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ declare let attributes: {
* TODO: delete in ver 3
* Image items */
images: {
[key: string]: string;
[key: string]: string | undefined;
};
/**
* variants is just an array containing the variant name and its local path
* clone from images
* This is automatically cloned from images and vice versa
* Image items */
variant: {
[key: string]: string;
[key: string]: string | undefined;
};
original: string;
/** relations */
dish: string[] | DishRecord[];
dish: DishRecord[] | string[];
/** Group relation */
group: string[] | GroupRecord[];
group: GroupRecord[] | string[];
/** upload date
* @deprecated (del in v2)
*/
Expand Down
Loading

0 comments on commit cc77c60

Please sign in to comment.