@medusajs/utils 2.18.0 → 2.19.0-preview-20260811102316
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/common/create-psql-index-helper.d.ts +1 -1
- package/dist/common/create-psql-index-helper.d.ts.map +1 -1
- package/dist/common/define-config.d.ts.map +1 -1
- package/dist/common/define-config.js +5 -2
- package/dist/common/define-config.js.map +1 -1
- package/dist/core-flows/events.d.ts +20 -15
- package/dist/core-flows/events.d.ts.map +1 -1
- package/dist/core-flows/events.js +20 -15
- package/dist/core-flows/events.js.map +1 -1
- package/dist/dml/entity-builder.d.ts +11 -2
- package/dist/dml/entity-builder.d.ts.map +1 -1
- package/dist/dml/entity-builder.js +10 -1
- package/dist/dml/entity-builder.js.map +1 -1
- package/dist/dml/helpers/entity-builder/build-indexes.d.ts +1 -1
- package/dist/dml/helpers/entity-builder/build-indexes.d.ts.map +1 -1
- package/dist/dml/helpers/entity-builder/build-indexes.js +8 -0
- package/dist/dml/helpers/entity-builder/build-indexes.js.map +1 -1
- package/dist/dml/properties/json.d.ts +5 -2
- package/dist/dml/properties/json.d.ts.map +1 -1
- package/dist/dml/properties/json.js +4 -1
- package/dist/dml/properties/json.js.map +1 -1
- package/dist/fulfillment/provider.d.ts +6 -2
- package/dist/fulfillment/provider.d.ts.map +1 -1
- package/dist/fulfillment/provider.js +6 -2
- package/dist/fulfillment/provider.js.map +1 -1
- package/dist/modules-sdk/definition.d.ts +3 -0
- package/dist/modules-sdk/definition.d.ts.map +1 -1
- package/dist/modules-sdk/definition.js +2 -0
- package/dist/modules-sdk/definition.js.map +1 -1
- package/dist/search/abstract-search-provider.d.ts +278 -0
- package/dist/search/abstract-search-provider.d.ts.map +1 -0
- package/dist/search/abstract-search-provider.js +282 -0
- package/dist/search/abstract-search-provider.js.map +1 -0
- package/dist/search/define-search-index.d.ts +9 -0
- package/dist/search/define-search-index.d.ts.map +1 -0
- package/dist/search/define-search-index.js +19 -0
- package/dist/search/define-search-index.js.map +1 -0
- package/dist/search/index.d.ts +2 -4
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +2 -4
- package/dist/search/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/search/abstract-service.d.ts +0 -345
- package/dist/search/abstract-service.d.ts.map +0 -1
- package/dist/search/abstract-service.js +0 -139
- package/dist/search/abstract-service.js.map +0 -1
- package/dist/search/index-types.d.ts +0 -4
- package/dist/search/index-types.d.ts.map +0 -1
- package/dist/search/index-types.js +0 -7
- package/dist/search/index-types.js.map +0 -1
- package/dist/search/search-relations.d.ts +0 -2
- package/dist/search/search-relations.d.ts.map +0 -1
- package/dist/search/search-relations.js +0 -14
- package/dist/search/search-relations.js.map +0 -1
- package/dist/search/variant-keys.d.ts +0 -2
- package/dist/search/variant-keys.d.ts.map +0 -1
- package/dist/search/variant-keys.js +0 -13
- package/dist/search/variant-keys.js.map +0 -1
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractSearchService = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* ## Overview
|
|
6
|
-
*
|
|
7
|
-
* A search service class is in a TypeScript or JavaScript file created in the `src/services` directory. The class must extend the `AbstractSearchService` class imported
|
|
8
|
-
* from the `@medusajs/utils` package.
|
|
9
|
-
*
|
|
10
|
-
* Based on services’ naming conventions, the file’s name should be the slug version of the search service’s name without `service`, and the class’s name should be the
|
|
11
|
-
* pascal case of the search service’s name following by `Service`.
|
|
12
|
-
*
|
|
13
|
-
* For example, create the `MySearchService` class in the file `src/services/my-search.ts`:
|
|
14
|
-
*
|
|
15
|
-
* ```ts title="src/services/my-search.ts"
|
|
16
|
-
* import { AbstractSearchService } from "@medusajs/utils"
|
|
17
|
-
*
|
|
18
|
-
* class MySearchService extends AbstractSearchService {
|
|
19
|
-
* isDefault = false
|
|
20
|
-
*
|
|
21
|
-
* createIndex(indexName: string, options: Record<string, any>) {
|
|
22
|
-
* throw new Error("Method not implemented.")
|
|
23
|
-
* }
|
|
24
|
-
* getIndex(indexName: string) {
|
|
25
|
-
* throw new Error("Method not implemented.")
|
|
26
|
-
* }
|
|
27
|
-
* addDocuments(
|
|
28
|
-
* indexName: string,
|
|
29
|
-
* documents: Record<string, any>[],
|
|
30
|
-
* type: string
|
|
31
|
-
* ) {
|
|
32
|
-
* throw new Error("Method not implemented.")
|
|
33
|
-
* }
|
|
34
|
-
* replaceDocuments(
|
|
35
|
-
* indexName: string,
|
|
36
|
-
* documents: Record<string, any>[],
|
|
37
|
-
* type: string
|
|
38
|
-
* ) {
|
|
39
|
-
* throw new Error("Method not implemented.")
|
|
40
|
-
* }
|
|
41
|
-
* deleteDocument(
|
|
42
|
-
* indexName: string,
|
|
43
|
-
* document_id: string | number
|
|
44
|
-
* ) {
|
|
45
|
-
* throw new Error("Method not implemented.")
|
|
46
|
-
* }
|
|
47
|
-
* deleteAllDocuments(indexName: string) {
|
|
48
|
-
* throw new Error("Method not implemented.")
|
|
49
|
-
* }
|
|
50
|
-
* search(
|
|
51
|
-
* indexName: string,
|
|
52
|
-
* query: string,
|
|
53
|
-
* options: Record<string, any>
|
|
54
|
-
* ) {
|
|
55
|
-
* return {
|
|
56
|
-
* message: "test",
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
* updateSettings(
|
|
60
|
-
* indexName: string,
|
|
61
|
-
* settings: Record<string, any>
|
|
62
|
-
* ) {
|
|
63
|
-
* throw new Error("Method not implemented.")
|
|
64
|
-
* }
|
|
65
|
-
*
|
|
66
|
-
* }
|
|
67
|
-
*
|
|
68
|
-
* export default MySearchService
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* ---
|
|
72
|
-
*
|
|
73
|
-
* ## Notes About Class Methods
|
|
74
|
-
*
|
|
75
|
-
* Although there are several helper methods in this class, the main methods used by the Medusa backend are `addDocuments`, `deleteDocument`, and `search`.
|
|
76
|
-
* The rest of the methods are provided in case you need them for custom use cases.
|
|
77
|
-
*
|
|
78
|
-
* ---
|
|
79
|
-
*/
|
|
80
|
-
class AbstractSearchService {
|
|
81
|
-
/**
|
|
82
|
-
* @ignore
|
|
83
|
-
*/
|
|
84
|
-
static isSearchService(obj) {
|
|
85
|
-
return obj?.constructor?._isSearchService;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @ignore
|
|
89
|
-
*/
|
|
90
|
-
get options() {
|
|
91
|
-
return this.options_;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* You can use the `constructor` of your search service to access the different services in Medusa through dependency injection.
|
|
95
|
-
*
|
|
96
|
-
* You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs,
|
|
97
|
-
* you can initialize it in the constructor and use it in other methods in the service.
|
|
98
|
-
*
|
|
99
|
-
* Additionally, if you’re creating your search service as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin,
|
|
100
|
-
* you can access them in the constructor. The default constructor already sets the value of the class proeprty `options_` to the passed options.
|
|
101
|
-
*
|
|
102
|
-
* @param {Record<string, unknown>} cradle - An container cradle that allows you to access other resources, such as services, in your Medusa backend.
|
|
103
|
-
* @param {Record<string, unknown>} options - If this search service is created in a plugin, the plugin's options are passed in this parameter.
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* // ...
|
|
107
|
-
* import { ProductService } from "@medusajs/medusa"
|
|
108
|
-
*
|
|
109
|
-
* type InjectedDependencies = {
|
|
110
|
-
* productService: ProductService
|
|
111
|
-
* }
|
|
112
|
-
*
|
|
113
|
-
* class MySearchService extends AbstractSearchService {
|
|
114
|
-
* // ...
|
|
115
|
-
* protected readonly productService_: ProductService
|
|
116
|
-
*
|
|
117
|
-
* constructor({ productService }: InjectedDependencies) {
|
|
118
|
-
* // @ts-expect-error prefer-rest-params
|
|
119
|
-
* super(...arguments)
|
|
120
|
-
* this.productService_ = productService
|
|
121
|
-
*
|
|
122
|
-
* // you can also initialize a client that
|
|
123
|
-
* // communicates with a third-party service.
|
|
124
|
-
* this.client = new Client(options)
|
|
125
|
-
* }
|
|
126
|
-
*
|
|
127
|
-
* // ...
|
|
128
|
-
* }
|
|
129
|
-
*/
|
|
130
|
-
constructor(cradle, options) {
|
|
131
|
-
this.options_ = options;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.AbstractSearchService = AbstractSearchService;
|
|
135
|
-
/**
|
|
136
|
-
* @ignore
|
|
137
|
-
*/
|
|
138
|
-
AbstractSearchService._isSearchService = true;
|
|
139
|
-
//# sourceMappingURL=abstract-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-service.js","sourceRoot":"","sources":["../../src/search/abstract-service.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,MAAsB,qBAAqB;IAQzC;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG;QACxB,OAAO,GAAG,EAAE,WAAW,EAAE,gBAAgB,CAAA;IAC3C,CAAC;IAWD;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,YAAsB,MAAM,EAAE,OAAO;QACnC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACzB,CAAC;;AAtEH,sDA6SC;AA1SC;;GAEG;AACI,sCAAgB,GAAG,IAAI,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-types.d.ts","sourceRoot":"","sources":["../../src/search/index-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;CAEtB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-types.js","sourceRoot":"","sources":["../../src/search/index-types.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE,UAAU;CACrB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-relations.d.ts","sourceRoot":"","sources":["../../src/search/search-relations.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qCAAqC,UASjD,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultSearchIndexingProductRelations = void 0;
|
|
4
|
-
exports.defaultSearchIndexingProductRelations = [
|
|
5
|
-
"variants",
|
|
6
|
-
"tags",
|
|
7
|
-
"type",
|
|
8
|
-
"collection",
|
|
9
|
-
"variants.prices",
|
|
10
|
-
"images",
|
|
11
|
-
"variants.options",
|
|
12
|
-
"options",
|
|
13
|
-
];
|
|
14
|
-
//# sourceMappingURL=search-relations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-relations.js","sourceRoot":"","sources":["../../src/search/search-relations.ts"],"names":[],"mappings":";;;AAAa,QAAA,qCAAqC,GAAG;IACnD,UAAU;IACV,MAAM;IACN,MAAM;IACN,YAAY;IACZ,iBAAiB;IACjB,QAAQ;IACR,kBAAkB;IAClB,SAAS;CACV,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant-keys.d.ts","sourceRoot":"","sources":["../../src/search/variant-keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAQvB,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.variantKeys = void 0;
|
|
4
|
-
exports.variantKeys = [
|
|
5
|
-
"sku",
|
|
6
|
-
"title",
|
|
7
|
-
"upc",
|
|
8
|
-
"ean",
|
|
9
|
-
"mid_code",
|
|
10
|
-
"hs_code",
|
|
11
|
-
"options",
|
|
12
|
-
];
|
|
13
|
-
//# sourceMappingURL=variant-keys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant-keys.js","sourceRoot":"","sources":["../../src/search/variant-keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,KAAK;IACL,OAAO;IACP,KAAK;IACL,KAAK;IACL,UAAU;IACV,SAAS;IACT,SAAS;CACV,CAAA"}
|