@ozdao/martyrs 0.2.562 → 0.2.564
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/{abac-DC2x92Pa.js → abac-DYoheWuc.js} +2 -1
- package/dist/{core.logger-VRHh-WUW.js → core.cache-DALYFDdy.js} +10 -59
- package/dist/core.logger-C3q8A9dl.js +51 -0
- package/dist/core.server.js +1 -1
- package/dist/{crud-DFFgLl09.js → crud-C7FSTUes.js} +2 -1
- package/dist/inventory.server.js +4 -3
- package/dist/{main-TV4u6Jux.js → main-CmjWiDVF.js} +402 -402
- package/dist/marketplace.server.js +389 -0
- package/dist/martyrs/src/modules/core/views/components/sections/filters/FiltersGroup.vue.js +1 -3
- package/dist/martyrs/src/modules/core/views/components/sections/filters/FiltersGroup.vue.js.map +1 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeatures.vue.js +1 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeatures.vue.js.map +1 -1
- package/dist/martyrs/src/modules/marketplace/marketplace.client.js +5 -9
- package/dist/martyrs/src/modules/marketplace/marketplace.client.js.map +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/{layouts → pages}/Marketplace.vue.js +14 -18
- package/dist/martyrs/src/modules/marketplace/views/components/pages/Marketplace.vue.js.map +1 -0
- package/dist/martyrs/src/modules/marketplace/views/router/marketplace.router.js +39 -0
- package/dist/martyrs/src/modules/marketplace/views/router/marketplace.router.js.map +1 -0
- package/dist/martyrs/src/modules/marketplace/views/store/marketplace.js +0 -16
- package/dist/martyrs/src/modules/marketplace/views/store/marketplace.js.map +1 -1
- package/dist/martyrs.es.js +1 -1
- package/dist/music.server.js +4 -3
- package/dist/orders.server.js +2 -2
- package/dist/organizations.server.js +9 -219
- package/dist/products.server.js +4 -3
- package/dist/queryProcessorOrganizations-BB11WFpc.js +221 -0
- package/dist/rents.server.js +2 -1
- package/dist/{web-Cq5tyhkl.js → web-cNKIl_cL.js} +1 -1
- package/package.json +1 -1
- package/src/modules/core/views/components/sections/filters/FiltersGroup.vue +3 -4
- package/src/modules/landing/components/sections/SectionFeatures.vue +1 -1
- package/src/modules/marketplace/marketplace.client.js +3 -10
- package/src/modules/marketplace/views/components/{layouts → pages}/Marketplace.vue +7 -16
- package/src/modules/marketplace/views/router/marketplace.router.js +37 -45
- package/src/modules/marketplace/views/store/marketplace.js +0 -16
- package/dist/martyrs/src/modules/marketplace/marketplace.router.js +0 -63
- package/dist/martyrs/src/modules/marketplace/marketplace.router.js.map +0 -1
- package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.js.map +0 -1
- package/dist/martyrs/src/modules/marketplace/views/components/pages/Catalog.vue.js +0 -73
- package/dist/martyrs/src/modules/marketplace/views/components/pages/Catalog.vue.js.map +0 -1
- package/src/modules/marketplace/marketplace.router.js +0 -66
- package/src/modules/marketplace/views/components/pages/Catalog.vue +0 -74
|
@@ -54,22 +54,6 @@ const state = reactive({
|
|
|
54
54
|
{ label: "Crypto", value: "crypto" },
|
|
55
55
|
{ label: "Bank Transfer", value: "bank" }
|
|
56
56
|
]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
title: "Availability Date",
|
|
60
|
-
value: "availabilityDate",
|
|
61
|
-
type: "date"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
title: "Rating",
|
|
65
|
-
value: "rating",
|
|
66
|
-
type: "radio",
|
|
67
|
-
options: [
|
|
68
|
-
{ label: "5 stars", value: "5" },
|
|
69
|
-
{ label: "4+ stars", value: "4" },
|
|
70
|
-
{ label: "3+ stars", value: "3" },
|
|
71
|
-
{ label: "Any rating", value: "any" }
|
|
72
|
-
]
|
|
73
57
|
}
|
|
74
58
|
]
|
|
75
59
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketplace.js","sources":["../../../../../../../src/modules/marketplace/views/store/marketplace.js"],"sourcesContent":["import { reactive, watch } from 'vue';\nimport StoreManager from '@martyrs/src/modules/core/views/classes/store.manager.js';\nimport { useGlobalMixins } from '@martyrs/src/modules/core/views/mixins/mixins.js';\n\nconst { returnCurrency } = useGlobalMixins();\n\n// State\nconst state = reactive({\n shops: [],\n popular: [],\n pagination: {\n page: 1,\n perPage: 18,\n },\n search: {\n active: false,\n current: '',\n result: [],\n },\n locationOptions: [\n { label: 'All', path: '/marketplace' },\n { label: 'Phuket', path: '/marketplace/thailand/phuket' },\n { label: 'Bangkok', path: '/marketplace/thailand/bangkok' },\n { label: 'Chiang Mai', path: '/marketplace/thailand/chiang-mai' },\n { label: 'Pattaya', path: '/marketplace/thailand/pattaya' },\n ],\n filter: {\n active: false,\n class: 'mobile-only',\n selected: {},\n options: [\n {\n title: 'Price',\n value: 'price',\n type: 'range',\n minPlaceholder: 'From',\n maxPlaceholder: 'To',\n label: returnCurrency()\n },\n {\n title: 'Delivery',\n value: 'delivery',\n type: 'checkbox',\n options: [\n { label: 'Pickup', value: 'pickup' },\n { label: 'Delivery', value: 'courier' },\n { label: 'Mail', value: 'post' },\n ],\n },\n {\n title: 'Payment',\n value: 'payment',\n type: 'checkbox',\n options: [\n { label: 'Cash', value: 'cash' },\n { label: 'Card', value: 'card' },\n { label: 'Crypto', value: 'crypto' },\n { label: 'Bank Transfer', value: 'bank' },\n ],\n },\n
|
|
1
|
+
{"version":3,"file":"marketplace.js","sources":["../../../../../../../src/modules/marketplace/views/store/marketplace.js"],"sourcesContent":["import { reactive, watch } from 'vue';\nimport StoreManager from '@martyrs/src/modules/core/views/classes/store.manager.js';\nimport { useGlobalMixins } from '@martyrs/src/modules/core/views/mixins/mixins.js';\n\nconst { returnCurrency } = useGlobalMixins();\n\n// State\nconst state = reactive({\n shops: [],\n popular: [],\n pagination: {\n page: 1,\n perPage: 18,\n },\n search: {\n active: false,\n current: '',\n result: [],\n },\n locationOptions: [\n { label: 'All', path: '/marketplace' },\n { label: 'Phuket', path: '/marketplace/thailand/phuket' },\n { label: 'Bangkok', path: '/marketplace/thailand/bangkok' },\n { label: 'Chiang Mai', path: '/marketplace/thailand/chiang-mai' },\n { label: 'Pattaya', path: '/marketplace/thailand/pattaya' },\n ],\n filter: {\n active: false,\n class: 'mobile-only',\n selected: {},\n options: [\n {\n title: 'Price',\n value: 'price',\n type: 'range',\n minPlaceholder: 'From',\n maxPlaceholder: 'To',\n label: returnCurrency()\n },\n {\n title: 'Delivery',\n value: 'delivery',\n type: 'checkbox',\n options: [\n { label: 'Pickup', value: 'pickup' },\n { label: 'Delivery', value: 'courier' },\n { label: 'Mail', value: 'post' },\n ],\n },\n {\n title: 'Payment',\n value: 'payment',\n type: 'checkbox',\n options: [\n { label: 'Cash', value: 'cash' },\n { label: 'Card', value: 'card' },\n { label: 'Crypto', value: 'crypto' },\n { label: 'Bank Transfer', value: 'bank' },\n ],\n },\n ],\n },\n sort: {\n param: 'distance',\n order: 'asc',\n options: [\n {\n label: 'Distance',\n value: 'distance',\n },\n {\n label: 'Popularity',\n value: 'views',\n },\n {\n label: 'Products',\n value: 'numberOfProducts',\n },\n ],\n },\n});\n\n// History\nconst history = [];\nhistory.push(state);\n\n// Watch\nwatch(state, (newState, oldState) => {\n history.push(newState);\n});\n\n// Actions через StoreManager\nconst marketplaceStore = new StoreManager('/api/marketplace');\n\n// Custom action для каталога\nmarketplaceStore.readCatalog = async function(params = {}) {\n console.log('Reading marketplace catalog with params:', params);\n try {\n const result = await this.request('/catalog', { params });\n console.log(`Catalog returned ${result.length || 0} items`);\n\n // Обновляем state.shops если нужно\n if (result && Array.isArray(result)) {\n state.shops = result;\n }\n\n return result;\n } catch (error) {\n console.error('Catalog read failed:', error);\n throw error;\n }\n};\n\n// Module Export\nexport { state, marketplaceStore };\n\nexport default marketplaceStore;\n"],"names":[],"mappings":";;;AAIA,MAAM,EAAE,eAAc,IAAK,gBAAe;AAGrC,MAAC,QAAQ,SAAS;AAAA,EACrB,OAAO,CAAA;AAAA,EACP,SAAS,CAAA;AAAA,EACT,YAAY;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA,EACb;AAAA,EACE,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,QAAQ,CAAA;AAAA,EACZ;AAAA,EACE,iBAAiB;AAAA,IACf,EAAE,OAAO,OAAO,MAAM,eAAc;AAAA,IACpC,EAAE,OAAO,UAAU,MAAM,+BAA8B;AAAA,IACvD,EAAE,OAAO,WAAW,MAAM,gCAA+B;AAAA,IACzD,EAAE,OAAO,cAAc,MAAM,mCAAkC;AAAA,IAC/D,EAAE,OAAO,WAAW,MAAM,gCAA+B;AAAA,EAC7D;AAAA,EACE,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU,CAAA;AAAA,IACV,SAAS;AAAA,MACP;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,QACP,MAAM;AAAA,QACN,gBAAgB;AAAA,QAChB,gBAAgB;AAAA,QAChB,OAAO,eAAc;AAAA,MAC7B;AAAA,MACM;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,QACP,MAAM;AAAA,QACN,SAAS;AAAA,UACP,EAAE,OAAO,UAAU,OAAO,SAAQ;AAAA,UAClC,EAAE,OAAO,YAAY,OAAO,UAAS;AAAA,UACrC,EAAE,OAAO,QAAQ,OAAO,OAAM;AAAA,QACxC;AAAA,MACA;AAAA,MACM;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,QACP,MAAM;AAAA,QACN,SAAS;AAAA,UACP,EAAE,OAAO,QAAQ,OAAO,OAAM;AAAA,UAC9B,EAAE,OAAO,QAAQ,OAAO,OAAM;AAAA,UAC9B,EAAE,OAAO,UAAU,OAAO,SAAQ;AAAA,UAClC,EAAE,OAAO,iBAAiB,OAAO,OAAM;AAAA,QACjD;AAAA,MACA;AAAA,IACA;AAAA,EACA;AAAA,EACE,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,MACP;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,MACf;AAAA,MACM;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,MACf;AAAA,MACM;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,MACf;AAAA,IACA;AAAA,EACA;AACA,CAAC;AAOD,MAAM,OAAO,CAAC,UAAU,aAAa;AAErC,CAAC;AAGI,MAAC,mBAAmB,IAAI,aAAa,kBAAkB;AAG5D,iBAAiB,cAAc,eAAe,SAAS,IAAI;AACzD,UAAQ,IAAI,4CAA4C,MAAM;AAC9D,MAAI;AACF,UAAM,SAAS,MAAM,KAAK,QAAQ,YAAY,EAAE,QAAQ;AACxD,YAAQ,IAAI,oBAAoB,OAAO,UAAU,CAAC,QAAQ;AAG1D,QAAI,UAAU,MAAM,QAAQ,MAAM,GAAG;AACnC,YAAM,QAAQ;AAAA,IAChB;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,wBAAwB,KAAK;AAC3C,UAAM;AAAA,EACR;AACF;"}
|
package/dist/martyrs.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as e, a as o, b as d, C as r, k as t, c as l, d as i, e as p, f as u, g as n, h as M, i as S, j as c, F as m, l as C, n as F, o as g, p as h, L as b, q as k, M as x, r as B, I, s as T, t as U, u as f, v as w, S as D, w as E, x as L, y as P, z as q, A as y, B as A, D as G, E as j, U as v, G as z, H, m as R } from "./main-
|
|
1
|
+
import { _ as e, a as o, b as d, C as r, k as t, c as l, d as i, e as p, f as u, g as n, h as M, i as S, j as c, F as m, l as C, n as F, o as g, p as h, L as b, q as k, M as x, r as B, I, s as T, t as U, u as f, v as w, S as D, w as E, x as L, y as P, z as q, A as y, B as A, D as G, E as j, U as v, G as z, H, m as R } from "./main-CmjWiDVF.js";
|
|
2
2
|
export {
|
|
3
3
|
e as Address,
|
|
4
4
|
o as Breadcrumbs,
|
package/dist/music.server.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { c as coreabac } from "./core.abac-DUPBnlk6.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { C as CacheNamespaced } from "./core.cache-DALYFDdy.js";
|
|
3
|
+
import { L as LoggerNamespaced } from "./core.logger-C3q8A9dl.js";
|
|
4
|
+
import { C as CRUD } from "./crud-C7FSTUes.js";
|
|
5
|
+
import { A as ABAC } from "./abac-DYoheWuc.js";
|
|
5
6
|
import { V as Verifier, a as Validator } from "./core.verifier-gPPX_jhf.js";
|
|
6
7
|
import fs$1 from "fs";
|
|
7
8
|
import path$1 from "path";
|
package/dist/orders.server.js
CHANGED
|
@@ -4,8 +4,8 @@ import "./mailing-DuEFRsa3.js";
|
|
|
4
4
|
import { m as modelsFactory, a as applyProfileSchema } from "./profile.schema-CjLOfG7b.js";
|
|
5
5
|
import { a as applyOwnershipSchema } from "./ownership.schema-fwwDf_e5.js";
|
|
6
6
|
import { a as applyCredentialsSchema } from "./credentials.schema--2vvcu8c.js";
|
|
7
|
-
import { C as CRUD } from "./crud-
|
|
8
|
-
import { A as ABAC } from "./abac-
|
|
7
|
+
import { C as CRUD } from "./crud-C7FSTUes.js";
|
|
8
|
+
import { A as ABAC } from "./abac-DYoheWuc.js";
|
|
9
9
|
import axios from "axios";
|
|
10
10
|
import { V as Verifier, a as Validator } from "./core.verifier-gPPX_jhf.js";
|
|
11
11
|
import { m as middlewareIndexFactory } from "./index-_Edcmck_.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as ABAC } from "./abac-
|
|
1
|
+
import { A as ABAC } from "./abac-DYoheWuc.js";
|
|
2
2
|
import { a as applyCredentialsSchema } from "./credentials.schema--2vvcu8c.js";
|
|
3
3
|
import { a as applyOwnershipSchema } from "./ownership.schema-fwwDf_e5.js";
|
|
4
4
|
import { a as applyEngagementSchema } from "./engagement.schema-fh6W1fb_.js";
|
|
@@ -8,10 +8,10 @@ import { uuid } from "uuidv4";
|
|
|
8
8
|
import { q as queryProcessorCore } from "./queryProcessor-CBQgZycY.js";
|
|
9
9
|
import { Types } from "mongoose";
|
|
10
10
|
import { c as coreabac } from "./core.abac-DUPBnlk6.js";
|
|
11
|
-
import { C as CacheNamespaced } from "./core.
|
|
11
|
+
import { C as CacheNamespaced } from "./core.cache-DALYFDdy.js";
|
|
12
12
|
import { a as addUserStatusFields, b as addMembersQuantity } from "./addUserStatusFields-Cc-JpmPo.js";
|
|
13
13
|
import jwt from "jsonwebtoken";
|
|
14
|
-
import
|
|
14
|
+
import { g as getRequestedLookups, a as getBasicMatchConditions, b as getLookupStages, c as getPostableConditions, d as getContainConditions, e as getPriceConditions, f as getLocationStages } from "./queryProcessorOrganizations-BB11WFpc.js";
|
|
15
15
|
import { V as Verifier, a as Validator } from "./core.verifier-gPPX_jhf.js";
|
|
16
16
|
const controllerFactory$2 = (db) => {
|
|
17
17
|
const Department = db.department;
|
|
@@ -666,7 +666,7 @@ const invitesRoutes = (function(app, db) {
|
|
|
666
666
|
app.put("/api/invites/update", controller.update);
|
|
667
667
|
app.post("/api/invites/delete", controller.delete);
|
|
668
668
|
});
|
|
669
|
-
const ObjectId
|
|
669
|
+
const ObjectId = { Types }.Types.ObjectId;
|
|
670
670
|
const controllerFactory$1 = (db) => {
|
|
671
671
|
const Membership = db.membership;
|
|
672
672
|
const Department = db.department;
|
|
@@ -694,9 +694,9 @@ const controllerFactory$1 = (db) => {
|
|
|
694
694
|
},
|
|
695
695
|
{
|
|
696
696
|
$match: {
|
|
697
|
-
...req.query.user && { user: new ObjectId
|
|
697
|
+
...req.query.user && { user: new ObjectId(req.query.user) },
|
|
698
698
|
...req.query.type && { type: req.query.type },
|
|
699
|
-
...req.query.target && { target: new ObjectId
|
|
699
|
+
...req.query.target && { target: new ObjectId(req.query.target) },
|
|
700
700
|
...req.query.role && { role: { $in: req.query.role } },
|
|
701
701
|
...req.query.search && {
|
|
702
702
|
$or: [
|
|
@@ -777,10 +777,10 @@ const controllerFactory$1 = (db) => {
|
|
|
777
777
|
const { _id, type, target, user, role } = req.body;
|
|
778
778
|
console.log("Delete membership request:", { _id, type, target, user, role });
|
|
779
779
|
try {
|
|
780
|
-
const query = _id ? { _id: new ObjectId
|
|
780
|
+
const query = _id ? { _id: new ObjectId(_id) } : {
|
|
781
781
|
type,
|
|
782
|
-
target: new ObjectId
|
|
783
|
-
user: new ObjectId
|
|
782
|
+
target: new ObjectId(target),
|
|
783
|
+
user: new ObjectId(user),
|
|
784
784
|
role
|
|
785
785
|
};
|
|
786
786
|
console.log("Delete query:", query);
|
|
@@ -881,216 +881,6 @@ const lookupConfigs = {
|
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
883
|
};
|
|
884
|
-
const ObjectId = { Types }.Types.ObjectId;
|
|
885
|
-
const { Client } = googleMapsServicesJs;
|
|
886
|
-
const client = new Client({});
|
|
887
|
-
const getRequestedLookups = (query) => query.lookup ? Array.isArray(query.lookup) ? query.lookup : [query.lookup] : [];
|
|
888
|
-
const getLookupStages = (requestedLookups, configs) => {
|
|
889
|
-
if (!requestedLookups) return [];
|
|
890
|
-
const lookupsArray = Array.isArray(requestedLookups) ? requestedLookups : requestedLookups.split(",");
|
|
891
|
-
return lookupsArray.map((lookup) => configs[lookup]).filter(Boolean).flatMap((config) => [
|
|
892
|
-
{ $lookup: config.lookup },
|
|
893
|
-
// Оберните lookup в объект с $lookup
|
|
894
|
-
...config.additionalStages || []
|
|
895
|
-
]);
|
|
896
|
-
};
|
|
897
|
-
const getLocationStages = async (query) => {
|
|
898
|
-
if (!hasLocationParams(query)) {
|
|
899
|
-
return { stages: [], userLocation: null };
|
|
900
|
-
}
|
|
901
|
-
const location = await resolveLocation(query);
|
|
902
|
-
const radius = getRadius(query);
|
|
903
|
-
const geoStages = radius ? [
|
|
904
|
-
{
|
|
905
|
-
$match: {
|
|
906
|
-
"spots.location.coordinates": {
|
|
907
|
-
$geoWithin: {
|
|
908
|
-
$centerSphere: [[location.coordinates[0], location.coordinates[1]], radius]
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
] : [];
|
|
914
|
-
return {
|
|
915
|
-
stages: [...geoStages, ...getDistanceStages(location)],
|
|
916
|
-
userLocation: location
|
|
917
|
-
};
|
|
918
|
-
};
|
|
919
|
-
const getRadius = (query) => {
|
|
920
|
-
if (query.locationRadius) return parseFloat(query.locationRadius) / 6378.1;
|
|
921
|
-
if (query.city) return 25 / 6378.1;
|
|
922
|
-
if (query.state) return 50 / 6378.1;
|
|
923
|
-
return null;
|
|
924
|
-
};
|
|
925
|
-
const hasLocationParams = (query) => query.location || query.address || query.city || query.state || query.country;
|
|
926
|
-
const resolveLocation = async (query) => {
|
|
927
|
-
if (query.location) {
|
|
928
|
-
const parsedLocation = typeof query.location === "string" ? JSON.parse(query.location) : query.location;
|
|
929
|
-
const coordinates = parsedLocation.lng ? [parsedLocation.lng, parsedLocation.lat] : parsedLocation.coordinates;
|
|
930
|
-
return { coordinates: coordinates.map((coord) => parseFloat(coord)) };
|
|
931
|
-
}
|
|
932
|
-
const searchString = [query.address, query.city, query.state, query.country].filter(Boolean).join(", ");
|
|
933
|
-
try {
|
|
934
|
-
const geoResponse = await client.geocode({
|
|
935
|
-
params: {
|
|
936
|
-
address: searchString,
|
|
937
|
-
key: process.env.GOOGLE_MAPS_API_KEY
|
|
938
|
-
}
|
|
939
|
-
});
|
|
940
|
-
if (!geoResponse.data.results?.length) {
|
|
941
|
-
throw new Error("Unable to geocode the provided location.");
|
|
942
|
-
}
|
|
943
|
-
const { lng, lat } = geoResponse.data.results[0].geometry.location;
|
|
944
|
-
return { coordinates: [lng, lat] };
|
|
945
|
-
} catch (err) {
|
|
946
|
-
throw new Error("Error occurred while geocoding.");
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
const getDistanceStages = (location) => [
|
|
950
|
-
{
|
|
951
|
-
$addFields: {
|
|
952
|
-
spots: {
|
|
953
|
-
$map: {
|
|
954
|
-
input: "$spots",
|
|
955
|
-
as: "spot",
|
|
956
|
-
in: {
|
|
957
|
-
$mergeObjects: [
|
|
958
|
-
"$$spot",
|
|
959
|
-
{
|
|
960
|
-
distance: {
|
|
961
|
-
$function: {
|
|
962
|
-
body: `function(spotCoords, userCoords, isMiles) {
|
|
963
|
-
function toRad(x) {
|
|
964
|
-
return x * Math.PI / 180;
|
|
965
|
-
}
|
|
966
|
-
var lon1 = spotCoords[0];
|
|
967
|
-
var lat1 = spotCoords[1];
|
|
968
|
-
var lon2 = userCoords[0];
|
|
969
|
-
var lat2 = userCoords[1];
|
|
970
|
-
var R = 6371;
|
|
971
|
-
if (isMiles) R = 3959;
|
|
972
|
-
var x1 = lat2 - lat1;
|
|
973
|
-
var dLat = toRad(x1);
|
|
974
|
-
var x2 = lon2 - lon1;
|
|
975
|
-
var dLon = toRad(x2);
|
|
976
|
-
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
977
|
-
Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) *
|
|
978
|
-
Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
979
|
-
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
980
|
-
var d = R * c;
|
|
981
|
-
return d;
|
|
982
|
-
}`,
|
|
983
|
-
args: ["$$spot.location.coordinates", location.coordinates, false],
|
|
984
|
-
lang: "js"
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
]
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
$addFields: {
|
|
996
|
-
distance: { $min: "$spots.distance" },
|
|
997
|
-
distanceExist: {
|
|
998
|
-
$cond: {
|
|
999
|
-
if: { $eq: [{ $type: "$distance" }, "double"] },
|
|
1000
|
-
then: true,
|
|
1001
|
-
else: false
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
];
|
|
1007
|
-
const getPriceConditions = (prices, priceMin, priceMax) => {
|
|
1008
|
-
if (priceMin && priceMin.trim() !== "" || priceMax && priceMax.trim() !== "") {
|
|
1009
|
-
const min = priceMin && priceMin.trim() !== "" ? priceMin : "0";
|
|
1010
|
-
const max = priceMax && priceMax.trim() !== "" ? priceMax : "999999";
|
|
1011
|
-
prices = `${min}-${max}`;
|
|
1012
|
-
}
|
|
1013
|
-
if (!prices) return [];
|
|
1014
|
-
const priceRanges = prices.split(",");
|
|
1015
|
-
const priceConditions = priceRanges.map((priceRange) => {
|
|
1016
|
-
if (priceRange.startsWith("<")) return { "products.price": { $lt: parseInt(priceRange.slice(1)) } };
|
|
1017
|
-
if (priceRange.startsWith(">")) return { "products.price": { $gt: parseInt(priceRange.slice(1)) } };
|
|
1018
|
-
const [min, max] = priceRange.split("-").map(Number);
|
|
1019
|
-
return { "products.price": { $gte: min, $lte: max } };
|
|
1020
|
-
});
|
|
1021
|
-
return priceConditions.length > 0 ? [{ $match: { $or: priceConditions } }] : [];
|
|
1022
|
-
};
|
|
1023
|
-
const getContainConditions = (contain) => {
|
|
1024
|
-
if (!contain) return [];
|
|
1025
|
-
const conditions = contain.map((property) => ({
|
|
1026
|
-
[property]: { $exists: true, $not: { $size: 0 } }
|
|
1027
|
-
}));
|
|
1028
|
-
return conditions.length > 0 ? [{ $match: { $and: conditions } }] : [];
|
|
1029
|
-
};
|
|
1030
|
-
const getBasicMatchConditions = (query) => [
|
|
1031
|
-
...query._id ? [{ _id: new ObjectId(query._id) }] : [],
|
|
1032
|
-
...query.owner ? [{ owner: new ObjectId(query.owner) }] : [],
|
|
1033
|
-
...query.types ? [{ types: { $in: query.types } }] : [],
|
|
1034
|
-
...query.member ? [
|
|
1035
|
-
{
|
|
1036
|
-
memberships: {
|
|
1037
|
-
$elemMatch: {
|
|
1038
|
-
user: new ObjectId(query.member),
|
|
1039
|
-
role: "member"
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
] : [],
|
|
1044
|
-
...query.subscriber ? [
|
|
1045
|
-
{
|
|
1046
|
-
memberships: {
|
|
1047
|
-
$elemMatch: {
|
|
1048
|
-
user: new ObjectId(query.subscriber),
|
|
1049
|
-
role: "subscriber"
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
] : [],
|
|
1054
|
-
...query.categories?.split(",").length > 0 ? [{ "products.category": { $in: query.categories?.split(",") } }] : [],
|
|
1055
|
-
...query.delivery?.split(",").length > 0 ? [{ "spots.delivery": { $all: query.delivery?.split(",") } }] : []
|
|
1056
|
-
];
|
|
1057
|
-
const getPostableConditions = (postableId) => {
|
|
1058
|
-
if (!postableId) return [];
|
|
1059
|
-
return [
|
|
1060
|
-
{
|
|
1061
|
-
$match: {
|
|
1062
|
-
$or: [
|
|
1063
|
-
{ owner: new ObjectId(postableId) },
|
|
1064
|
-
{
|
|
1065
|
-
$and: [
|
|
1066
|
-
{ types: { $elemMatch: { $eq: "public" } } },
|
|
1067
|
-
{
|
|
1068
|
-
memberships: {
|
|
1069
|
-
$elemMatch: {
|
|
1070
|
-
user: new ObjectId(postableId)
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
]
|
|
1075
|
-
},
|
|
1076
|
-
{
|
|
1077
|
-
$and: [
|
|
1078
|
-
{ types: { $elemMatch: { $in: ["exclusive", "hidden"] } } },
|
|
1079
|
-
{
|
|
1080
|
-
memberships: {
|
|
1081
|
-
$elemMatch: {
|
|
1082
|
-
user: new ObjectId(postableId),
|
|
1083
|
-
role: { $ne: "subscriber" }
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
]
|
|
1088
|
-
}
|
|
1089
|
-
]
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
];
|
|
1093
|
-
};
|
|
1094
884
|
const controllerFactory = (db) => {
|
|
1095
885
|
const Organization = db.organization;
|
|
1096
886
|
const Department = db.department;
|
package/dist/products.server.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as CacheNamespaced } from "./core.cache-DALYFDdy.js";
|
|
2
|
+
import { L as LoggerNamespaced } from "./core.logger-C3q8A9dl.js";
|
|
2
3
|
import { q as queryProcessorCore } from "./queryProcessor-CBQgZycY.js";
|
|
3
4
|
import OpenAI from "openai";
|
|
4
5
|
import { Types } from "mongoose";
|
|
@@ -9,8 +10,8 @@ import { a as applyOwnershipSchema } from "./ownership.schema-fwwDf_e5.js";
|
|
|
9
10
|
import { m as middlewareFactory } from "./authJwt-J1csaMWA.js";
|
|
10
11
|
import { c as coreabac } from "./core.abac-DUPBnlk6.js";
|
|
11
12
|
import { a as Validator, V as Verifier } from "./core.verifier-gPPX_jhf.js";
|
|
12
|
-
import { C as CRUD } from "./crud-
|
|
13
|
-
import { A as ABAC } from "./abac-
|
|
13
|
+
import { C as CRUD } from "./crud-C7FSTUes.js";
|
|
14
|
+
import { A as ABAC } from "./abac-DYoheWuc.js";
|
|
14
15
|
const controllerFactory$1 = (db) => {
|
|
15
16
|
const Category = db.category;
|
|
16
17
|
const logger = new LoggerNamespaced(db);
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import * as googleMapsServicesJs from "@googlemaps/google-maps-services-js";
|
|
2
|
+
import { Types } from "mongoose";
|
|
3
|
+
const ObjectId = { Types }.Types.ObjectId;
|
|
4
|
+
const { Client } = googleMapsServicesJs;
|
|
5
|
+
const client = new Client({});
|
|
6
|
+
const getRequestedLookups = (query) => query.lookup ? Array.isArray(query.lookup) ? query.lookup : [query.lookup] : [];
|
|
7
|
+
const getLookupStages = (requestedLookups, configs) => {
|
|
8
|
+
if (!requestedLookups) return [];
|
|
9
|
+
const lookupsArray = Array.isArray(requestedLookups) ? requestedLookups : requestedLookups.split(",");
|
|
10
|
+
return lookupsArray.map((lookup) => configs[lookup]).filter(Boolean).flatMap((config) => [
|
|
11
|
+
{ $lookup: config.lookup },
|
|
12
|
+
// Оберните lookup в объект с $lookup
|
|
13
|
+
...config.additionalStages || []
|
|
14
|
+
]);
|
|
15
|
+
};
|
|
16
|
+
const getLocationStages = async (query) => {
|
|
17
|
+
if (!hasLocationParams(query)) {
|
|
18
|
+
return { stages: [], userLocation: null };
|
|
19
|
+
}
|
|
20
|
+
const location = await resolveLocation(query);
|
|
21
|
+
const radius = getRadius(query);
|
|
22
|
+
const geoStages = radius ? [
|
|
23
|
+
{
|
|
24
|
+
$match: {
|
|
25
|
+
"spots.location.coordinates": {
|
|
26
|
+
$geoWithin: {
|
|
27
|
+
$centerSphere: [[location.coordinates[0], location.coordinates[1]], radius]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
] : [];
|
|
33
|
+
return {
|
|
34
|
+
stages: [...geoStages, ...getDistanceStages(location)],
|
|
35
|
+
userLocation: location
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const getRadius = (query) => {
|
|
39
|
+
if (query.locationRadius) return parseFloat(query.locationRadius) / 6378.1;
|
|
40
|
+
if (query.city) return 25 / 6378.1;
|
|
41
|
+
if (query.state) return 50 / 6378.1;
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
const hasLocationParams = (query) => query.location || query.address || query.city || query.state || query.country;
|
|
45
|
+
const resolveLocation = async (query) => {
|
|
46
|
+
if (query.location) {
|
|
47
|
+
const parsedLocation = typeof query.location === "string" ? JSON.parse(query.location) : query.location;
|
|
48
|
+
const coordinates = parsedLocation.lng ? [parsedLocation.lng, parsedLocation.lat] : parsedLocation.coordinates;
|
|
49
|
+
return { coordinates: coordinates.map((coord) => parseFloat(coord)) };
|
|
50
|
+
}
|
|
51
|
+
const searchString = [query.address, query.city, query.state, query.country].filter(Boolean).join(", ");
|
|
52
|
+
try {
|
|
53
|
+
const geoResponse = await client.geocode({
|
|
54
|
+
params: {
|
|
55
|
+
address: searchString,
|
|
56
|
+
key: process.env.GOOGLE_MAPS_API_KEY
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (!geoResponse.data.results?.length) {
|
|
60
|
+
throw new Error("Unable to geocode the provided location.");
|
|
61
|
+
}
|
|
62
|
+
const { lng, lat } = geoResponse.data.results[0].geometry.location;
|
|
63
|
+
return { coordinates: [lng, lat] };
|
|
64
|
+
} catch (err) {
|
|
65
|
+
throw new Error("Error occurred while geocoding.");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const getDistanceStages = (location) => [
|
|
69
|
+
{
|
|
70
|
+
$addFields: {
|
|
71
|
+
spots: {
|
|
72
|
+
$map: {
|
|
73
|
+
input: "$spots",
|
|
74
|
+
as: "spot",
|
|
75
|
+
in: {
|
|
76
|
+
$mergeObjects: [
|
|
77
|
+
"$$spot",
|
|
78
|
+
{
|
|
79
|
+
distance: {
|
|
80
|
+
$function: {
|
|
81
|
+
body: `function(spotCoords, userCoords, isMiles) {
|
|
82
|
+
function toRad(x) {
|
|
83
|
+
return x * Math.PI / 180;
|
|
84
|
+
}
|
|
85
|
+
var lon1 = spotCoords[0];
|
|
86
|
+
var lat1 = spotCoords[1];
|
|
87
|
+
var lon2 = userCoords[0];
|
|
88
|
+
var lat2 = userCoords[1];
|
|
89
|
+
var R = 6371;
|
|
90
|
+
if (isMiles) R = 3959;
|
|
91
|
+
var x1 = lat2 - lat1;
|
|
92
|
+
var dLat = toRad(x1);
|
|
93
|
+
var x2 = lon2 - lon1;
|
|
94
|
+
var dLon = toRad(x2);
|
|
95
|
+
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
96
|
+
Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) *
|
|
97
|
+
Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
98
|
+
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
99
|
+
var d = R * c;
|
|
100
|
+
return d;
|
|
101
|
+
}`,
|
|
102
|
+
args: ["$$spot.location.coordinates", location.coordinates, false],
|
|
103
|
+
lang: "js"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
$addFields: {
|
|
115
|
+
distance: { $min: "$spots.distance" },
|
|
116
|
+
distanceExist: {
|
|
117
|
+
$cond: {
|
|
118
|
+
if: { $eq: [{ $type: "$distance" }, "double"] },
|
|
119
|
+
then: true,
|
|
120
|
+
else: false
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
const getPriceConditions = (prices, priceMin, priceMax) => {
|
|
127
|
+
if (priceMin && priceMin.trim() !== "" || priceMax && priceMax.trim() !== "") {
|
|
128
|
+
const min = priceMin && priceMin.trim() !== "" ? priceMin : "0";
|
|
129
|
+
const max = priceMax && priceMax.trim() !== "" ? priceMax : "999999";
|
|
130
|
+
prices = `${min}-${max}`;
|
|
131
|
+
}
|
|
132
|
+
if (!prices) return [];
|
|
133
|
+
const priceRanges = prices.split(",");
|
|
134
|
+
const priceConditions = priceRanges.map((priceRange) => {
|
|
135
|
+
if (priceRange.startsWith("<")) return { "products.price": { $lt: parseInt(priceRange.slice(1)) } };
|
|
136
|
+
if (priceRange.startsWith(">")) return { "products.price": { $gt: parseInt(priceRange.slice(1)) } };
|
|
137
|
+
const [min, max] = priceRange.split("-").map(Number);
|
|
138
|
+
return { "products.price": { $gte: min, $lte: max } };
|
|
139
|
+
});
|
|
140
|
+
return priceConditions.length > 0 ? [{ $match: { $or: priceConditions } }] : [];
|
|
141
|
+
};
|
|
142
|
+
const getContainConditions = (contain) => {
|
|
143
|
+
if (!contain) return [];
|
|
144
|
+
const conditions = contain.map((property) => ({
|
|
145
|
+
[property]: { $exists: true, $not: { $size: 0 } }
|
|
146
|
+
}));
|
|
147
|
+
return conditions.length > 0 ? [{ $match: { $and: conditions } }] : [];
|
|
148
|
+
};
|
|
149
|
+
const getBasicMatchConditions = (query) => [
|
|
150
|
+
...query._id ? [{ _id: new ObjectId(query._id) }] : [],
|
|
151
|
+
...query.owner ? [{ owner: new ObjectId(query.owner) }] : [],
|
|
152
|
+
...query.types ? [{ types: { $in: query.types } }] : [],
|
|
153
|
+
...query.member ? [
|
|
154
|
+
{
|
|
155
|
+
memberships: {
|
|
156
|
+
$elemMatch: {
|
|
157
|
+
user: new ObjectId(query.member),
|
|
158
|
+
role: "member"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
] : [],
|
|
163
|
+
...query.subscriber ? [
|
|
164
|
+
{
|
|
165
|
+
memberships: {
|
|
166
|
+
$elemMatch: {
|
|
167
|
+
user: new ObjectId(query.subscriber),
|
|
168
|
+
role: "subscriber"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
] : [],
|
|
173
|
+
...query.categories?.split(",").length > 0 ? [{ "products.category": { $in: query.categories?.split(",") } }] : [],
|
|
174
|
+
...query.delivery?.split(",").length > 0 ? [{ "spots.delivery": { $all: query.delivery?.split(",") } }] : []
|
|
175
|
+
];
|
|
176
|
+
const getPostableConditions = (postableId) => {
|
|
177
|
+
if (!postableId) return [];
|
|
178
|
+
return [
|
|
179
|
+
{
|
|
180
|
+
$match: {
|
|
181
|
+
$or: [
|
|
182
|
+
{ owner: new ObjectId(postableId) },
|
|
183
|
+
{
|
|
184
|
+
$and: [
|
|
185
|
+
{ types: { $elemMatch: { $eq: "public" } } },
|
|
186
|
+
{
|
|
187
|
+
memberships: {
|
|
188
|
+
$elemMatch: {
|
|
189
|
+
user: new ObjectId(postableId)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
$and: [
|
|
197
|
+
{ types: { $elemMatch: { $in: ["exclusive", "hidden"] } } },
|
|
198
|
+
{
|
|
199
|
+
memberships: {
|
|
200
|
+
$elemMatch: {
|
|
201
|
+
user: new ObjectId(postableId),
|
|
202
|
+
role: { $ne: "subscriber" }
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
];
|
|
212
|
+
};
|
|
213
|
+
export {
|
|
214
|
+
getBasicMatchConditions as a,
|
|
215
|
+
getLookupStages as b,
|
|
216
|
+
getPostableConditions as c,
|
|
217
|
+
getContainConditions as d,
|
|
218
|
+
getPriceConditions as e,
|
|
219
|
+
getLocationStages as f,
|
|
220
|
+
getRequestedLookups as g
|
|
221
|
+
};
|
package/dist/rents.server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { m as middlewareIndexFactory } from "./index-_Edcmck_.js";
|
|
2
2
|
import { c as coreabac } from "./core.abac-DUPBnlk6.js";
|
|
3
|
-
import {
|
|
3
|
+
import { C as CacheNamespaced } from "./core.cache-DALYFDdy.js";
|
|
4
|
+
import { L as LoggerNamespaced } from "./core.logger-C3q8A9dl.js";
|
|
4
5
|
import { V as Verifier, a as Validator } from "./core.verifier-gPPX_jhf.js";
|
|
5
6
|
import { q as queryProcessorCore } from "./queryProcessor-CBQgZycY.js";
|
|
6
7
|
const queryValidatorConfig = {
|
package/package.json
CHANGED
|
@@ -166,11 +166,10 @@ const resetFilters = () => {
|
|
|
166
166
|
} else {
|
|
167
167
|
workingValues[filter.value] = null
|
|
168
168
|
}
|
|
169
|
-
})
|
|
170
169
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
170
|
+
// Удаляем ключ из selected
|
|
171
|
+
delete selected.value[filter.value]
|
|
172
|
+
})
|
|
174
173
|
}
|
|
175
174
|
</script>
|
|
176
175
|
|