@medusajs/search 0.0.1
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/README.md +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/initialize/index.d.ts +8 -0
- package/dist/initialize/index.js +17 -0
- package/dist/joiner-config.d.ts +2 -0
- package/dist/joiner-config.js +4 -0
- package/dist/loaders/connection.d.ts +4 -0
- package/dist/loaders/connection.js +41 -0
- package/dist/loaders/container.d.ts +4 -0
- package/dist/loaders/container.js +21 -0
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.js +10 -0
- package/dist/migrations/Migration20231019174230.d.ts +4 -0
- package/dist/migrations/Migration20231019174230.js +18 -0
- package/dist/models/catalog-relation.d.ts +15 -0
- package/dist/models/catalog-relation.js +72 -0
- package/dist/models/catalog.d.ts +11 -0
- package/dist/models/catalog.js +55 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +18 -0
- package/dist/module-definition.d.ts +2 -0
- package/dist/module-definition.js +15 -0
- package/dist/scripts/bin/run-migration-down.d.ts +3 -0
- package/dist/scripts/bin/run-migration-down.js +32 -0
- package/dist/scripts/bin/run-migration-up.d.ts +3 -0
- package/dist/scripts/bin/run-migration-up.js +32 -0
- package/dist/scripts/bin/run-seed.d.ts +3 -0
- package/dist/scripts/bin/run-seed.js +38 -0
- package/dist/scripts/index.d.ts +2 -0
- package/dist/scripts/index.js +18 -0
- package/dist/scripts/migration-down.d.ts +10 -0
- package/dist/scripts/migration-down.js +52 -0
- package/dist/scripts/migration-up.d.ts +10 -0
- package/dist/scripts/migration-up.js +56 -0
- package/dist/scripts/seed-data/index.d.ts +8 -0
- package/dist/scripts/seed-data/index.js +138 -0
- package/dist/scripts/seed.d.ts +5 -0
- package/dist/scripts/seed.js +65 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +8 -0
- package/dist/services/postgres-provider.d.ts +126 -0
- package/dist/services/postgres-provider.js +441 -0
- package/dist/services/search-module-service.d.ts +31 -0
- package/dist/services/search-module-service.js +66 -0
- package/dist/types/index.d.ts +122 -0
- package/dist/types/index.js +7 -0
- package/dist/utils/build-config.d.ts +21 -0
- package/dist/utils/build-config.js +437 -0
- package/dist/utils/create-partitions.d.ts +3 -0
- package/dist/utils/create-partitions.js +27 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/query-builder.d.ts +28 -0
- package/dist/utils/query-builder.js +375 -0
- package/package.json +67 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryBuilder = void 0;
|
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
|
5
|
+
class QueryBuilder {
|
|
6
|
+
constructor(args) {
|
|
7
|
+
this.schema = args.schema;
|
|
8
|
+
this.entityMap = args.entityMap;
|
|
9
|
+
this.selector = args.selector;
|
|
10
|
+
this.options = args.options;
|
|
11
|
+
this.knex = args.knex;
|
|
12
|
+
this.structure = this.selector.select;
|
|
13
|
+
}
|
|
14
|
+
getStructureKeys(structure) {
|
|
15
|
+
return Object.keys(structure ?? {}).filter((key) => key !== "entity");
|
|
16
|
+
}
|
|
17
|
+
getEntity(path) {
|
|
18
|
+
if (!this.schema._schemaPropertiesMap[path]) {
|
|
19
|
+
throw new Error(`Could not find entity for path: ${path}`);
|
|
20
|
+
}
|
|
21
|
+
return this.schema._schemaPropertiesMap[path];
|
|
22
|
+
}
|
|
23
|
+
getGraphQLType(path, field) {
|
|
24
|
+
const entity = this.getEntity(path)?.ref?.entity;
|
|
25
|
+
const fieldRef = this.entityMap[entity]._fields[field];
|
|
26
|
+
if (!fieldRef) {
|
|
27
|
+
throw new Error(`Field ${field} not found in the entityMap.`);
|
|
28
|
+
}
|
|
29
|
+
let currentType = fieldRef.type;
|
|
30
|
+
while (currentType.ofType) {
|
|
31
|
+
currentType = currentType.ofType;
|
|
32
|
+
}
|
|
33
|
+
return currentType.name;
|
|
34
|
+
}
|
|
35
|
+
transformValueToType(path, field, value) {
|
|
36
|
+
const typeToFn = {
|
|
37
|
+
Int: (val) => parseInt(val, 10),
|
|
38
|
+
Float: (val) => parseFloat(val),
|
|
39
|
+
String: (val) => String(val),
|
|
40
|
+
Boolean: (val) => Boolean(val),
|
|
41
|
+
ID: (val) => String(val),
|
|
42
|
+
Date: (val) => new Date(val).toISOString(),
|
|
43
|
+
Time: (val) => new Date(`1970-01-01T${val}Z`).toISOString(),
|
|
44
|
+
};
|
|
45
|
+
const graphqlType = this.getGraphQLType(path, field);
|
|
46
|
+
const fn = typeToFn[graphqlType];
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
return value.map((v) => (!fn ? v : fn(v)));
|
|
49
|
+
}
|
|
50
|
+
return !fn ? value : fn(value);
|
|
51
|
+
}
|
|
52
|
+
getPostgresCastType(path, field) {
|
|
53
|
+
const graphqlToPostgresTypeMap = {
|
|
54
|
+
Int: "::integer",
|
|
55
|
+
Float: "::double precision",
|
|
56
|
+
Boolean: "::boolean",
|
|
57
|
+
Date: "::timestamp",
|
|
58
|
+
Time: "::time",
|
|
59
|
+
};
|
|
60
|
+
const graphqlType = this.getGraphQLType(path, field);
|
|
61
|
+
return graphqlToPostgresTypeMap[graphqlType] ?? "";
|
|
62
|
+
}
|
|
63
|
+
parseWhere(aliasMapping, obj, builder) {
|
|
64
|
+
const OPERATOR_MAP = {
|
|
65
|
+
$eq: "=",
|
|
66
|
+
$lt: "<",
|
|
67
|
+
$gt: ">",
|
|
68
|
+
$lte: "<=",
|
|
69
|
+
$gte: ">=",
|
|
70
|
+
$ne: "!=",
|
|
71
|
+
$in: "IN",
|
|
72
|
+
$like: "LIKE",
|
|
73
|
+
$ilike: "ILIKE",
|
|
74
|
+
};
|
|
75
|
+
const keys = Object.keys(obj);
|
|
76
|
+
keys.forEach((key) => {
|
|
77
|
+
let value = obj[key];
|
|
78
|
+
if ((key === "$and" || key === "$or") && !Array.isArray(value)) {
|
|
79
|
+
value = [value];
|
|
80
|
+
}
|
|
81
|
+
if (key === "$and" && Array.isArray(value)) {
|
|
82
|
+
builder.where((qb) => {
|
|
83
|
+
value.forEach((cond) => {
|
|
84
|
+
qb.andWhere((subBuilder) => this.parseWhere(aliasMapping, cond, subBuilder));
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else if (key === "$or" && Array.isArray(value)) {
|
|
89
|
+
builder.where((qb) => {
|
|
90
|
+
value.forEach((cond) => {
|
|
91
|
+
qb.orWhere((subBuilder) => this.parseWhere(aliasMapping, cond, subBuilder));
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else if ((0, utils_1.isObject)(value) && !Array.isArray(value)) {
|
|
96
|
+
const subKeys = Object.keys(value);
|
|
97
|
+
subKeys.forEach((subKey) => {
|
|
98
|
+
let operator = OPERATOR_MAP[subKey];
|
|
99
|
+
if (operator) {
|
|
100
|
+
const path = key.split(".");
|
|
101
|
+
const field = path.pop();
|
|
102
|
+
const attr = path.join(".");
|
|
103
|
+
const subValue = this.transformValueToType(attr, field, value[subKey]);
|
|
104
|
+
const castType = this.getPostgresCastType(attr, field);
|
|
105
|
+
const val = operator === "IN" ? subValue : [subValue];
|
|
106
|
+
builder.whereRaw(`(${aliasMapping[attr]}.data->>?)${castType} ${operator} ?`, [field, ...val]);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw new Error(`Unsupported operator: ${subKey}`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const path = key.split(".");
|
|
115
|
+
const field = path.pop();
|
|
116
|
+
const attr = path.join(".");
|
|
117
|
+
value = this.transformValueToType(attr, field, value);
|
|
118
|
+
if (Array.isArray(value)) {
|
|
119
|
+
const castType = this.getPostgresCastType(attr, field);
|
|
120
|
+
builder.whereRaw(`(${aliasMapping[attr]}.data->>?)${castType} IN (?)`, [field, ...value]);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const castType = this.getPostgresCastType(attr, field);
|
|
124
|
+
builder.whereRaw(`(${aliasMapping[attr]}.data->>?)${castType} = ?`, [
|
|
125
|
+
field,
|
|
126
|
+
value,
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return builder;
|
|
132
|
+
}
|
|
133
|
+
buildQueryParts(structure, parentAlias, parentEntity, parentProperty, aliasPath = [], level = 0, aliasMapping = {}) {
|
|
134
|
+
const currentAliasPath = [...aliasPath, parentProperty].join(".");
|
|
135
|
+
const entities = this.getEntity(currentAliasPath);
|
|
136
|
+
const mainEntity = entities.ref.entity;
|
|
137
|
+
const mainAlias = mainEntity.toLowerCase() + level;
|
|
138
|
+
const allEntities = [];
|
|
139
|
+
if (!entities.shortCutOf) {
|
|
140
|
+
allEntities.push({
|
|
141
|
+
entity: mainEntity,
|
|
142
|
+
parEntity: parentEntity,
|
|
143
|
+
parAlias: parentAlias,
|
|
144
|
+
alias: mainAlias,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const intermediateAlias = entities.shortCutOf.split(".");
|
|
149
|
+
for (let i = intermediateAlias.length - 1, x = 0; i >= 0; i--, x++) {
|
|
150
|
+
const intermediateEntity = this.getEntity(intermediateAlias.join("."));
|
|
151
|
+
intermediateAlias.pop();
|
|
152
|
+
if (intermediateEntity.ref.entity === parentEntity) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
const parentIntermediateEntity = this.getEntity(intermediateAlias.join("."));
|
|
156
|
+
const alias = intermediateEntity.ref.entity.toLowerCase() + level + "_" + x;
|
|
157
|
+
const parAlias = parentIntermediateEntity.ref.entity === parentEntity
|
|
158
|
+
? parentAlias
|
|
159
|
+
: parentIntermediateEntity.ref.entity.toLowerCase() +
|
|
160
|
+
level +
|
|
161
|
+
"_" +
|
|
162
|
+
(x + 1);
|
|
163
|
+
if (x === 0) {
|
|
164
|
+
aliasMapping[currentAliasPath] = alias;
|
|
165
|
+
}
|
|
166
|
+
allEntities.unshift({
|
|
167
|
+
entity: intermediateEntity.ref.entity,
|
|
168
|
+
parEntity: parentIntermediateEntity.ref.entity,
|
|
169
|
+
parAlias,
|
|
170
|
+
alias,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
let queryParts = [];
|
|
175
|
+
for (const join of allEntities) {
|
|
176
|
+
const { alias, entity, parEntity, parAlias } = join;
|
|
177
|
+
aliasMapping[currentAliasPath] = alias;
|
|
178
|
+
if (level > 0) {
|
|
179
|
+
const subQuery = this.knex.queryBuilder();
|
|
180
|
+
const knex = this.knex;
|
|
181
|
+
subQuery
|
|
182
|
+
.select(`${alias}.id`, `${alias}.data`)
|
|
183
|
+
.from("catalog AS " + alias)
|
|
184
|
+
.join(`catalog_relation AS ${alias}_ref`, function () {
|
|
185
|
+
this.on(`${alias}_ref.pivot`, "=", knex.raw("?", [`${parEntity}-${entity}`]))
|
|
186
|
+
.andOn(`${alias}_ref.parent_id`, "=", `${parAlias}.id`)
|
|
187
|
+
.andOn(`${alias}.id`, "=", `${alias}_ref.child_id`);
|
|
188
|
+
})
|
|
189
|
+
.where(`${alias}.name`, "=", knex.raw("?", [entity]));
|
|
190
|
+
const joinWhere = this.selector.joinWhere ?? {};
|
|
191
|
+
const joinKey = Object.keys(joinWhere).find((key) => {
|
|
192
|
+
const k = key.split(".");
|
|
193
|
+
k.pop();
|
|
194
|
+
return k.join(".") === currentAliasPath;
|
|
195
|
+
});
|
|
196
|
+
if (joinKey) {
|
|
197
|
+
this.parseWhere(aliasMapping, { [joinKey]: joinWhere[joinKey] }, subQuery);
|
|
198
|
+
}
|
|
199
|
+
queryParts.push(`LEFT JOIN LATERAL (
|
|
200
|
+
${subQuery.toQuery()}
|
|
201
|
+
) ${alias} ON TRUE`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const children = this.getStructureKeys(structure);
|
|
205
|
+
for (const child of children) {
|
|
206
|
+
const childStructure = structure[child];
|
|
207
|
+
queryParts = queryParts.concat(this.buildQueryParts(childStructure, mainAlias, mainEntity, child, aliasPath.concat(parentProperty), level + 1, aliasMapping));
|
|
208
|
+
}
|
|
209
|
+
return queryParts;
|
|
210
|
+
}
|
|
211
|
+
buildSelectParts(structure, parentProperty, aliasMapping, aliasPath = [], selectParts = {}) {
|
|
212
|
+
const currentAliasPath = [...aliasPath, parentProperty].join(".");
|
|
213
|
+
const alias = aliasMapping[currentAliasPath];
|
|
214
|
+
selectParts[currentAliasPath] = `${alias}.data`;
|
|
215
|
+
selectParts[currentAliasPath + ".id"] = `${alias}.id`;
|
|
216
|
+
const children = this.getStructureKeys(structure);
|
|
217
|
+
for (const child of children) {
|
|
218
|
+
const childStructure = structure[child];
|
|
219
|
+
this.buildSelectParts(childStructure, child, aliasMapping, aliasPath.concat(parentProperty), selectParts);
|
|
220
|
+
}
|
|
221
|
+
return selectParts;
|
|
222
|
+
}
|
|
223
|
+
transformOrderBy(arr) {
|
|
224
|
+
const result = {};
|
|
225
|
+
const map = new Map();
|
|
226
|
+
map.set(true, "ASC");
|
|
227
|
+
map.set(1, "ASC");
|
|
228
|
+
map.set("ASC", "ASC");
|
|
229
|
+
map.set(false, "DESC");
|
|
230
|
+
map.set(-1, "DESC");
|
|
231
|
+
map.set("DESC", "DESC");
|
|
232
|
+
function nested(obj, prefix = "") {
|
|
233
|
+
const keys = Object.keys(obj);
|
|
234
|
+
if (!keys.length) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
else if (keys.length > 1) {
|
|
238
|
+
throw new Error("Order by only supports one key per object.");
|
|
239
|
+
}
|
|
240
|
+
const key = keys[0];
|
|
241
|
+
let value = obj[key];
|
|
242
|
+
if ((0, utils_1.isObject)(value)) {
|
|
243
|
+
nested(value, prefix + key + ".");
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
if ((0, utils_1.isString)(value)) {
|
|
247
|
+
value = value.toUpperCase();
|
|
248
|
+
}
|
|
249
|
+
result[prefix + key] = map.get(value) ?? "ASC";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
arr.forEach((obj) => nested(obj));
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
buildQuery(countAllResults = true, returnIdOnly = false) {
|
|
256
|
+
const queryBuilder = this.knex.queryBuilder();
|
|
257
|
+
const structure = this.structure;
|
|
258
|
+
const filter = this.selector.where ?? {};
|
|
259
|
+
const { orderBy: order, skip, take } = this.options ?? {};
|
|
260
|
+
const orderBy = this.transformOrderBy((order && !Array.isArray(order) ? [order] : order) ?? []);
|
|
261
|
+
const rootKey = this.getStructureKeys(structure)[0];
|
|
262
|
+
const rootStructure = structure[rootKey];
|
|
263
|
+
const entity = this.getEntity(rootKey).ref.entity;
|
|
264
|
+
const rootEntity = entity.toLowerCase();
|
|
265
|
+
const aliasMapping = {};
|
|
266
|
+
const joinParts = this.buildQueryParts(rootStructure, "", entity, rootKey, [], 0, aliasMapping);
|
|
267
|
+
const rootAlias = aliasMapping[rootKey];
|
|
268
|
+
const selectParts = !returnIdOnly
|
|
269
|
+
? this.buildSelectParts(rootStructure, rootKey, aliasMapping)
|
|
270
|
+
: { [rootKey + ".id"]: `${rootAlias}.id` };
|
|
271
|
+
if (countAllResults) {
|
|
272
|
+
selectParts["offset_"] = this.knex.raw(`DENSE_RANK() OVER (ORDER BY ${rootEntity}0.id)`);
|
|
273
|
+
}
|
|
274
|
+
queryBuilder.select(selectParts);
|
|
275
|
+
queryBuilder.from(`catalog AS ${rootEntity}0`);
|
|
276
|
+
joinParts.forEach((joinPart) => {
|
|
277
|
+
queryBuilder.joinRaw(joinPart);
|
|
278
|
+
});
|
|
279
|
+
queryBuilder.where(`${aliasMapping[rootEntity]}.name`, "=", entity);
|
|
280
|
+
// WHERE clause
|
|
281
|
+
this.parseWhere(aliasMapping, filter, queryBuilder);
|
|
282
|
+
// ORDER BY clause
|
|
283
|
+
for (const aliasPath in orderBy) {
|
|
284
|
+
const path = aliasPath.split(".");
|
|
285
|
+
const field = path.pop();
|
|
286
|
+
const attr = path.join(".");
|
|
287
|
+
const alias = aliasMapping[attr];
|
|
288
|
+
const direction = orderBy[aliasPath];
|
|
289
|
+
queryBuilder.orderByRaw(`${alias}.data->>'${field}' ${direction}`);
|
|
290
|
+
}
|
|
291
|
+
let sql = `WITH data AS (${queryBuilder.toQuery()})
|
|
292
|
+
SELECT * ${countAllResults ? ", (SELECT max(offset_) FROM data) AS count" : ""}
|
|
293
|
+
FROM data`;
|
|
294
|
+
let take_ = !isNaN(+take) ? +take : 15;
|
|
295
|
+
let skip_ = !isNaN(+skip) ? +skip : 0;
|
|
296
|
+
if (typeof take === "number" || typeof skip === "number") {
|
|
297
|
+
sql += `
|
|
298
|
+
WHERE offset_ > ${skip_}
|
|
299
|
+
AND offset_ <= ${skip_ + take_}
|
|
300
|
+
`;
|
|
301
|
+
}
|
|
302
|
+
return sql;
|
|
303
|
+
}
|
|
304
|
+
buildObjectFromResultset(resultSet) {
|
|
305
|
+
const structure = this.structure;
|
|
306
|
+
const rootKey = this.getStructureKeys(structure)[0];
|
|
307
|
+
const maps = {};
|
|
308
|
+
const isListMap = {};
|
|
309
|
+
const referenceMap = {};
|
|
310
|
+
const pathDetails = {};
|
|
311
|
+
const initializeMaps = (structure, path) => {
|
|
312
|
+
const currentPath = path.join(".");
|
|
313
|
+
maps[currentPath] = {};
|
|
314
|
+
if (path.length > 1) {
|
|
315
|
+
const property = path[path.length - 1];
|
|
316
|
+
const parents = path.slice(0, -1);
|
|
317
|
+
const parentPath = parents.join(".");
|
|
318
|
+
isListMap[currentPath] = !!this.getEntity(currentPath).ref.parents.find((p) => p.targetProp === property)?.isList;
|
|
319
|
+
pathDetails[currentPath] = { property, parents, parentPath };
|
|
320
|
+
}
|
|
321
|
+
const children = this.getStructureKeys(structure);
|
|
322
|
+
for (const key of children) {
|
|
323
|
+
initializeMaps(structure[key], [...path, key]);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
initializeMaps(structure[rootKey], [rootKey]);
|
|
327
|
+
function buildReferenceKey(path, id, row) {
|
|
328
|
+
let current = "";
|
|
329
|
+
let key = "";
|
|
330
|
+
for (const p of path) {
|
|
331
|
+
current += `${p}`;
|
|
332
|
+
key += row[`${current}.id`] + ".";
|
|
333
|
+
current += ".";
|
|
334
|
+
}
|
|
335
|
+
return key + id;
|
|
336
|
+
}
|
|
337
|
+
resultSet.forEach((row) => {
|
|
338
|
+
for (const path in maps) {
|
|
339
|
+
const id = row[`${path}.id`];
|
|
340
|
+
// root level
|
|
341
|
+
if (!pathDetails[path]) {
|
|
342
|
+
if (!maps[path][id]) {
|
|
343
|
+
maps[path][id] = row[path] || undefined;
|
|
344
|
+
}
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const { property, parents, parentPath } = pathDetails[path];
|
|
348
|
+
const referenceKey = buildReferenceKey(parents, id, row);
|
|
349
|
+
if (referenceMap[referenceKey]) {
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
maps[path][id] = row[path] || undefined;
|
|
353
|
+
const parentObj = maps[parentPath][row[`${parentPath}.id`]];
|
|
354
|
+
if (!parentObj) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const isList = isListMap[parentPath + "." + property];
|
|
358
|
+
if (isList) {
|
|
359
|
+
parentObj[property] ?? (parentObj[property] = []);
|
|
360
|
+
}
|
|
361
|
+
if (maps[path][id] !== undefined) {
|
|
362
|
+
if (isList) {
|
|
363
|
+
parentObj[property].push(maps[path][id]);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
parentObj[property] = maps[path][id];
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
referenceMap[referenceKey] = true;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
return Object.values(maps[rootKey] ?? {});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
exports.QueryBuilder = QueryBuilder;
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@medusajs/search",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Medusa Search module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"bin": {
|
|
11
|
+
"medusa-search-migrations-down": "dist/scripts/bin/run-migration-down.js",
|
|
12
|
+
"medusa-search-migrations-up": "dist/scripts/bin/run-migration-up.js",
|
|
13
|
+
"medusa-search-seed": "dist/scripts/bin/run-seed.js"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/medusajs/medusa",
|
|
18
|
+
"directory": "packages/search"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"author": "Medusa",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"watch": "tsc --build --watch",
|
|
27
|
+
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
|
28
|
+
"prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
|
|
29
|
+
"build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
|
|
30
|
+
"test": "jest --runInBand --bail --passWithNoTests --forceExit -- ./src/__tests__/**/*.ts",
|
|
31
|
+
"test:integration": "jest --runInBand --passWithNoTests --forceExit -- ./integration-tests/**/__tests__/**/*.ts",
|
|
32
|
+
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
|
33
|
+
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
|
|
34
|
+
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
|
|
35
|
+
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up",
|
|
36
|
+
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear",
|
|
37
|
+
"experiment": "ts-node src/_experiments/experiment.ts"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@faker-js/faker": "^8.2.0",
|
|
41
|
+
"@medusajs/types": "^1.11.1",
|
|
42
|
+
"@mikro-orm/cli": "5.7.12",
|
|
43
|
+
"cross-env": "^5.2.1",
|
|
44
|
+
"jest": "^29.6.3",
|
|
45
|
+
"medusa-test-utils": "^1.1.40",
|
|
46
|
+
"pg-god": "^1.0.12",
|
|
47
|
+
"rimraf": "^3.0.2",
|
|
48
|
+
"ts-jest": "^29.1.1",
|
|
49
|
+
"ts-node": "^10.9.1",
|
|
50
|
+
"tsc-alias": "^1.8.6",
|
|
51
|
+
"typescript": "^5.1.6"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@graphql-tools/merge": "^9.0.0",
|
|
55
|
+
"@graphql-tools/schema": "^10.0.0",
|
|
56
|
+
"@medusajs/modules-sdk": "^1.11.0",
|
|
57
|
+
"@medusajs/utils": "^1.10.1",
|
|
58
|
+
"@mikro-orm/core": "5.7.12",
|
|
59
|
+
"@mikro-orm/migrations": "5.7.12",
|
|
60
|
+
"@mikro-orm/postgresql": "5.7.12",
|
|
61
|
+
"awilix": "^8.0.0",
|
|
62
|
+
"dotenv": "^16.1.4",
|
|
63
|
+
"graphql": "^16.8.1",
|
|
64
|
+
"knex": "2.4.2",
|
|
65
|
+
"lodash": "^4.17.21"
|
|
66
|
+
}
|
|
67
|
+
}
|