@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
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Catalog Module
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const module_definition_1 = require("./module-definition");
|
|
18
|
+
exports.default = module_definition_1.moduleDefinition;
|
|
19
|
+
__exportStar(require("./initialize"), exports);
|
|
20
|
+
__exportStar(require("./loaders"), exports);
|
|
21
|
+
__exportStar(require("./models"), exports);
|
|
22
|
+
__exportStar(require("./scripts"), exports);
|
|
23
|
+
__exportStar(require("./services"), exports);
|
|
24
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
|
|
2
|
+
import { IEventBusModuleService, RemoteJoinerQuery } from "@medusajs/types";
|
|
3
|
+
import { SearchModuleOptions } from "../types";
|
|
4
|
+
import { SearchModuleService } from "../services";
|
|
5
|
+
export declare const initialize: (options: SearchModuleOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies: {
|
|
6
|
+
eventBusModuleService: IEventBusModuleService;
|
|
7
|
+
remoteQuery: (query: string | RemoteJoinerQuery | object, variables?: Record<string, unknown>) => Promise<any>;
|
|
8
|
+
}) => Promise<SearchModuleService>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initialize = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
const module_definition_1 = require("../module-definition");
|
|
6
|
+
const initialize = async (options, injectedDependencies) => {
|
|
7
|
+
if (!injectedDependencies?.eventBusModuleService) {
|
|
8
|
+
throw new Error("SearchModule is missing the eventBusModuleService dependency to work");
|
|
9
|
+
}
|
|
10
|
+
if (!injectedDependencies?.remoteQuery) {
|
|
11
|
+
throw new Error("SearchModule is missing the remoteQuery dependency to work");
|
|
12
|
+
}
|
|
13
|
+
const serviceKey = modules_sdk_1.Modules.SEARCH;
|
|
14
|
+
const loaded = await modules_sdk_1.MedusaModule.bootstrap(serviceKey, modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.SEARCH], options, module_definition_1.moduleDefinition, injectedDependencies);
|
|
15
|
+
return loaded[serviceKey];
|
|
16
|
+
};
|
|
17
|
+
exports.initialize = initialize;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk";
|
|
2
|
+
import { SearchModuleOptions } from "../types";
|
|
3
|
+
declare const _default: ({ options, container, logger }: LoaderOptions<SearchModuleOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const utils_1 = require("@medusajs/utils");
|
|
27
|
+
const SearchModels = __importStar(require("../models"));
|
|
28
|
+
exports.default = async ({ options, container, logger }, moduleDeclaration) => {
|
|
29
|
+
if (options?.defaultAdapterOptions) {
|
|
30
|
+
const entities = Object.values(SearchModels);
|
|
31
|
+
const pathToMigrations = __dirname + "/../migrations";
|
|
32
|
+
await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
|
|
33
|
+
entities,
|
|
34
|
+
container,
|
|
35
|
+
options: options.defaultAdapterOptions,
|
|
36
|
+
moduleDeclaration,
|
|
37
|
+
logger,
|
|
38
|
+
pathToMigrations,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _services_1 = require("../services");
|
|
4
|
+
const awilix_1 = require("awilix");
|
|
5
|
+
const postgres_provider_1 = require("../services/postgres-provider");
|
|
6
|
+
exports.default = async ({ container, options, }) => {
|
|
7
|
+
container.register({
|
|
8
|
+
searchModuleService: (0, awilix_1.asClass)(_services_1.SearchModuleService).singleton(),
|
|
9
|
+
});
|
|
10
|
+
if (!options?.customAdapter && !options?.defaultAdapterOptions) {
|
|
11
|
+
throw new Error("Search module error, either customAdapter or defaultAdapterOptions must be provided. None have been provided.");
|
|
12
|
+
}
|
|
13
|
+
container.register("storageProviderCtrOptions", (0, awilix_1.asValue)(undefined));
|
|
14
|
+
if (!options?.customAdapter) {
|
|
15
|
+
container.register("storageProviderCtr", (0, awilix_1.asValue)(postgres_provider_1.PostgresProvider));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
container.register("storageProviderCtr", (0, awilix_1.asValue)(options.customAdapter.constructor));
|
|
19
|
+
container.register("storageProviderCtrOptions", (0, awilix_1.asValue)(options.customAdapter.options));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.connectionLoader = exports.containerLoader = void 0;
|
|
7
|
+
var container_1 = require("./container");
|
|
8
|
+
Object.defineProperty(exports, "containerLoader", { enumerable: true, get: function () { return __importDefault(container_1).default; } });
|
|
9
|
+
var connection_1 = require("./connection");
|
|
10
|
+
Object.defineProperty(exports, "connectionLoader", { enumerable: true, get: function () { return __importDefault(connection_1).default; } });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20231019174230 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20231019174230 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
const schema = this.config.get("schema")
|
|
8
|
+
? `"${this.config.get("schema")}".`
|
|
9
|
+
: "";
|
|
10
|
+
this.addSql(`create table ${schema}"catalog" ("id" text not null, "name" text not null, "data" jsonb not null default '{}', constraint "catalog_pkey" primary key ("id", "name")) PARTITION BY LIST("name");`);
|
|
11
|
+
this.addSql(`create index "IDX_catalog_id" on ${schema}"catalog" ("id");`);
|
|
12
|
+
this.addSql(`create index "IDX_catalog_name" on ${schema}"catalog" ("name");`);
|
|
13
|
+
this.addSql(`create index "IDX_catalog_data_gin" on ${schema}"catalog" using GIN ("data");`);
|
|
14
|
+
this.addSql(`create table ${schema}"catalog_relation" ("id" bigserial, "pivot" text not null, "parent_id" text not null, "parent_name" text not null, "child_id" text not null, "child_name" text not null, constraint "catalog_relation_pkey" primary key ("id", "pivot")) PARTITION BY LIST("pivot");`);
|
|
15
|
+
this.addSql(`create index "IDX_catalog_relation_child_id" on ${schema}"catalog_relation" ("child_id");`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Migration20231019174230 = Migration20231019174230;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OptionalProps, Ref } from "@mikro-orm/core";
|
|
2
|
+
import Catalog from "./catalog";
|
|
3
|
+
type OptionalRelations = "parent" | "child" | "parent_id" | "child_id" | "parent_name" | "child_name";
|
|
4
|
+
export declare class CatalogRelation {
|
|
5
|
+
[OptionalProps]: OptionalRelations;
|
|
6
|
+
id: string;
|
|
7
|
+
pivot: string;
|
|
8
|
+
parent_id?: string;
|
|
9
|
+
parent_name?: string;
|
|
10
|
+
child_id?: string;
|
|
11
|
+
child_name?: string;
|
|
12
|
+
parent?: Ref<Catalog>;
|
|
13
|
+
child?: Ref<Catalog>;
|
|
14
|
+
}
|
|
15
|
+
export default CatalogRelation;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CatalogRelation = void 0;
|
|
16
|
+
const core_1 = require("@mikro-orm/core");
|
|
17
|
+
const catalog_1 = __importDefault(require("./catalog"));
|
|
18
|
+
let CatalogRelation = class CatalogRelation {
|
|
19
|
+
};
|
|
20
|
+
exports.CatalogRelation = CatalogRelation;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, core_1.PrimaryKey)({ columnType: "integer", autoincrement: true }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], CatalogRelation.prototype, "id", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, core_1.Property)({
|
|
27
|
+
columnType: "text",
|
|
28
|
+
}),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], CatalogRelation.prototype, "pivot", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], CatalogRelation.prototype, "parent_id", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], CatalogRelation.prototype, "parent_name", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], CatalogRelation.prototype, "child_id", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], CatalogRelation.prototype, "child_name", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, core_1.ManyToOne)({
|
|
49
|
+
entity: () => catalog_1.default,
|
|
50
|
+
onDelete: "cascade",
|
|
51
|
+
persist: false,
|
|
52
|
+
}),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], CatalogRelation.prototype, "parent", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, core_1.ManyToOne)({
|
|
57
|
+
entity: () => catalog_1.default,
|
|
58
|
+
onDelete: "cascade",
|
|
59
|
+
persist: false,
|
|
60
|
+
}),
|
|
61
|
+
__metadata("design:type", Object)
|
|
62
|
+
], CatalogRelation.prototype, "child", void 0);
|
|
63
|
+
exports.CatalogRelation = CatalogRelation = __decorate([
|
|
64
|
+
(0, core_1.Entity)({
|
|
65
|
+
tableName: "catalog_relation",
|
|
66
|
+
}),
|
|
67
|
+
(0, core_1.Index)({
|
|
68
|
+
name: "IDX_catalog_relation_child_id",
|
|
69
|
+
properties: ["child_id"],
|
|
70
|
+
})
|
|
71
|
+
], CatalogRelation);
|
|
72
|
+
exports.default = CatalogRelation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Collection, OptionalProps, PrimaryKeyType } from "@mikro-orm/core";
|
|
2
|
+
type OptionalRelations = "parents";
|
|
3
|
+
export declare class Catalog {
|
|
4
|
+
[OptionalProps]: OptionalRelations;
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
[PrimaryKeyType]?: [string, string];
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
parents: Collection<Catalog, object>;
|
|
10
|
+
}
|
|
11
|
+
export default Catalog;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Catalog = void 0;
|
|
16
|
+
const core_1 = require("@mikro-orm/core");
|
|
17
|
+
const catalog_relation_1 = __importDefault(require("./catalog-relation"));
|
|
18
|
+
let Catalog = class Catalog {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.parents = new core_1.Collection(this);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.Catalog = Catalog;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
26
|
+
(0, core_1.Index)({ name: "IDX_catalog_id" }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], Catalog.prototype, "id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
31
|
+
(0, core_1.Index)({ name: "IDX_catalog_name" }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], Catalog.prototype, "name", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, core_1.Index)({ name: "IDX_catalog_data_gin", type: "GIN" }),
|
|
36
|
+
(0, core_1.Property)({ columnType: "jsonb", default: "{}" }),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], Catalog.prototype, "data", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, core_1.ManyToMany)({
|
|
41
|
+
owner: true,
|
|
42
|
+
entity: () => Catalog,
|
|
43
|
+
pivotEntity: () => catalog_relation_1.default,
|
|
44
|
+
cascade: [core_1.Cascade.REMOVE],
|
|
45
|
+
inverseJoinColumns: ["parent_id", "parent_name"],
|
|
46
|
+
joinColumns: ["child_id", "child_name"],
|
|
47
|
+
}),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], Catalog.prototype, "parents", void 0);
|
|
50
|
+
exports.Catalog = Catalog = __decorate([
|
|
51
|
+
(0, core_1.Entity)({
|
|
52
|
+
tableName: "catalog",
|
|
53
|
+
})
|
|
54
|
+
], Catalog);
|
|
55
|
+
exports.default = Catalog;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./catalog"), exports);
|
|
18
|
+
__exportStar(require("./catalog-relation"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.moduleDefinition = void 0;
|
|
7
|
+
const _services_1 = require("./services");
|
|
8
|
+
const connection_1 = __importDefault(require("./loaders/connection"));
|
|
9
|
+
const container_1 = __importDefault(require("./loaders/container"));
|
|
10
|
+
const service = _services_1.SearchModuleService;
|
|
11
|
+
const loaders = [connection_1.default, container_1.default];
|
|
12
|
+
exports.moduleDefinition = {
|
|
13
|
+
service,
|
|
14
|
+
loaders,
|
|
15
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.default = (async () => {
|
|
28
|
+
const { revertMigration } = await Promise.resolve().then(() => __importStar(require("../migration-down")));
|
|
29
|
+
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
|
30
|
+
config();
|
|
31
|
+
await revertMigration();
|
|
32
|
+
})();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.default = (async () => {
|
|
28
|
+
const { runMigrations } = await Promise.resolve().then(() => __importStar(require("../migration-up")));
|
|
29
|
+
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
|
30
|
+
config();
|
|
31
|
+
await runMigrations();
|
|
32
|
+
})();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const seed_1 = require("../seed");
|
|
28
|
+
const os_1 = require("os");
|
|
29
|
+
const args = process.argv;
|
|
30
|
+
const path = args.pop();
|
|
31
|
+
exports.default = (async () => {
|
|
32
|
+
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
|
33
|
+
config();
|
|
34
|
+
if (!path) {
|
|
35
|
+
throw new Error(`filePath is required.${os_1.EOL}Example: medusa-search-seed <filePath>`);
|
|
36
|
+
}
|
|
37
|
+
await (0, seed_1.run)({ path });
|
|
38
|
+
})();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./migration-up"), exports);
|
|
18
|
+
__exportStar(require("./migration-down"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LoaderOptions } from "@medusajs/types";
|
|
2
|
+
import { SearchModuleOptions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* This script is only valid for mikro orm managers. If a user provide a custom manager
|
|
5
|
+
* he is in charge of reverting the migrations.
|
|
6
|
+
* @param options
|
|
7
|
+
* @param logger
|
|
8
|
+
* @param moduleDeclaration
|
|
9
|
+
*/
|
|
10
|
+
export declare function revertMigration({ options, logger, }?: Pick<LoaderOptions<SearchModuleOptions>, "options" | "logger">): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.revertMigration = void 0;
|
|
27
|
+
const SearchModels = __importStar(require("../models"));
|
|
28
|
+
const utils_1 = require("@medusajs/utils");
|
|
29
|
+
/**
|
|
30
|
+
* This script is only valid for mikro orm managers. If a user provide a custom manager
|
|
31
|
+
* he is in charge of reverting the migrations.
|
|
32
|
+
* @param options
|
|
33
|
+
* @param logger
|
|
34
|
+
* @param moduleDeclaration
|
|
35
|
+
*/
|
|
36
|
+
async function revertMigration({ options, logger, } = {}) {
|
|
37
|
+
logger ?? (logger = console);
|
|
38
|
+
const dbData = utils_1.ModulesSdkUtils.loadDatabaseConfig("search", options?.defaultAdapterOptions);
|
|
39
|
+
const entities = Object.values(SearchModels);
|
|
40
|
+
const pathToMigrations = __dirname + "/../migrations";
|
|
41
|
+
const orm = await utils_1.DALUtils.mikroOrmCreateConnection(dbData, entities, pathToMigrations);
|
|
42
|
+
try {
|
|
43
|
+
const migrator = orm.getMigrator();
|
|
44
|
+
await migrator.down();
|
|
45
|
+
logger?.info("Search module migration executed");
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
logger?.error(`Search module migration failed to run - Error: ${error}`);
|
|
49
|
+
}
|
|
50
|
+
await orm.close();
|
|
51
|
+
}
|
|
52
|
+
exports.revertMigration = revertMigration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LoaderOptions } from "@medusajs/types";
|
|
2
|
+
import { SearchModuleOptions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* This script is only valid for mikro orm managers. If a user provide a custom manager
|
|
5
|
+
* he is in charge of running the migrations.
|
|
6
|
+
* @param options
|
|
7
|
+
* @param logger
|
|
8
|
+
* @param moduleDeclaration
|
|
9
|
+
*/
|
|
10
|
+
export declare function runMigrations({ options, logger, }?: Pick<LoaderOptions<SearchModuleOptions>, "options" | "logger">): Promise<void>;
|