@empty-complete-org/medusa-product-attributes 0.10.0
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/LICENSE +21 -0
- package/README.md +367 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/models/category-custom-attribute.d.ts +20 -0
- package/dist/models/category-custom-attribute.d.ts.map +1 -0
- package/dist/models/category-custom-attribute.js +24 -0
- package/dist/models/category-custom-attribute.js.map +1 -0
- package/dist/models/product-custom-attribute.d.ts +20 -0
- package/dist/models/product-custom-attribute.d.ts.map +1 -0
- package/dist/models/product-custom-attribute.js +19 -0
- package/dist/models/product-custom-attribute.js.map +1 -0
- package/dist/service.d.ts +223 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +66 -0
- package/dist/service.js.map +1 -0
- package/package.json +70 -0
- package/src/admin/lib/sdk.ts +9 -0
- package/src/admin/widgets/category-attribute-templates.tsx +237 -0
- package/src/admin/widgets/product-attribute-values.tsx +186 -0
- package/src/api/admin/category/[categoryId]/custom-attributes/route.ts +49 -0
- package/src/api/admin/product/[productId]/custom-attributes/route.ts +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 empty-complete
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/empty-complete/medusa-product-attributes/main/assets/logo_medusa-custom-attributes.png" alt="logo medusa product attributes module repo" width="120">
|
|
3
|
+
<h1>Product Attributes Module for Medusa v2</h1>
|
|
4
|
+
<p><i>Extend your store's capabilities with a flexible attribute system for products and categories</i></p>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://github.com/empty-complete/medusa-product-attributes/blob/main/LICENSE">
|
|
8
|
+
<img src="https://img.shields.io/github/license/empty-complete/medusa-product-attributes" alt="License">
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@empty-complete/medusa-product-attributes">
|
|
11
|
+
<img src="https://img.shields.io/npm/v/@empty-complete/medusa-product-attributes" alt="npm version">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/empty-complete/medusa-product-attributes/actions/workflows/ci.yml">
|
|
14
|
+
<img src="https://github.com/empty-complete/medusa-product-attributes/actions/workflows/ci.yml/badge.svg" alt="CI Status">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://github.com/empty-complete/medusa-product-attributes/commits/main">
|
|
17
|
+
<img src="https://img.shields.io/github/commit-activity/m/empty-complete/medusa-product-attributes" alt="GitHub commit activity">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://www.npmjs.com/package/@empty-complete/medusa-product-attributes">
|
|
20
|
+
<img src="https://img.shields.io/npm/dm/@empty-complete/medusa-product-attributes" alt="npm downloads">
|
|
21
|
+
</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<a href="https://medusajs.com/">
|
|
26
|
+
<img src="https://img.shields.io/badge/Medusa-v2-000000" alt="Medusa v2">
|
|
27
|
+
</a>
|
|
28
|
+
<a href="https://www.typescriptlang.org/">
|
|
29
|
+
<img src="https://img.shields.io/badge/TypeScript-5.0+-3178C6" alt="TypeScript">
|
|
30
|
+
</a>
|
|
31
|
+
<a href="https://nodejs.org/">
|
|
32
|
+
<img src="https://img.shields.io/badge/Node.js-%3E=20-339933" alt="Node.js">
|
|
33
|
+
</a>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<p>
|
|
37
|
+
<a href="https://t.me/kinesis_lab">
|
|
38
|
+
<img src="https://img.shields.io/badge/Telegram-follow-229ED9?logo=telegram" alt="Telegram">
|
|
39
|
+
</a>
|
|
40
|
+
</p>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## ✨ Features
|
|
46
|
+
|
|
47
|
+
| Feature | Description |
|
|
48
|
+
|---------|----------|
|
|
49
|
+
| 📝 **Text Attributes** | Arbitrary text values for products |
|
|
50
|
+
| 🔢 **Numeric Attributes** | Numbers with support for units (kg, m, pcs) |
|
|
51
|
+
| 📎 **File Attributes** | File uploads: certificates, 3D models, manuals |
|
|
52
|
+
| 🏷️ **Standard Keys** | Pre-defined attributes: `certificates`, `3dmodel`, `manual` |
|
|
53
|
+
| 📂 **Category Templates** | Attribute inheritance from category to products |
|
|
54
|
+
| 🗑️ **Soft Delete** | Safe deletion with recovery capability |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Requirements
|
|
59
|
+
|
|
60
|
+
| Dependency | Version |
|
|
61
|
+
|------------|---------|
|
|
62
|
+
| Medusa | ^2.0.0 |
|
|
63
|
+
| Node.js | >=20 |
|
|
64
|
+
| TypeScript | ^5.0.0 |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 🚀 Quick Start
|
|
69
|
+
|
|
70
|
+
### 📦 Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Via npm
|
|
74
|
+
npm install @empty-complete/medusa-product-attributes
|
|
75
|
+
|
|
76
|
+
# Via pnpm
|
|
77
|
+
pnpm add @empty-complete/medusa-product-attributes
|
|
78
|
+
|
|
79
|
+
# Via yarn
|
|
80
|
+
yarn add @empty-complete/medusa-product-attributes
|
|
81
|
+
|
|
82
|
+
# Via GitHub Packages (requires authentication)
|
|
83
|
+
npm install @empty-complete/medusa-product-attributes --registry=https://npm.pkg.github.com
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 1. Add the module to configuration
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// medusa-config.ts
|
|
90
|
+
import { defineConfig } from '@medusajs/framework/utils'
|
|
91
|
+
|
|
92
|
+
export default defineConfig({
|
|
93
|
+
modules: [
|
|
94
|
+
{
|
|
95
|
+
resolve: '@empty-complete/medusa-product-attributes',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 2. Run migrations
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pnpm medusa db:migrate
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 3. Done!
|
|
108
|
+
|
|
109
|
+
The module will automatically create the necessary tables and register services.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 💡 Usage
|
|
114
|
+
|
|
115
|
+
### Creating a category attribute
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { CUSTOM_ATTRIBUTE_MODULE } from '@empty-complete/medusa-product-attributes'
|
|
119
|
+
|
|
120
|
+
const module = container.resolve(CUSTOM_ATTRIBUTE_MODULE)
|
|
121
|
+
|
|
122
|
+
// Create a "Weight" attribute with unit
|
|
123
|
+
await module.createCategoryAttribute({
|
|
124
|
+
label: 'Weight',
|
|
125
|
+
type: 'number',
|
|
126
|
+
unit: 'kg',
|
|
127
|
+
category_id: 'pcat_123',
|
|
128
|
+
sort_order: 0,
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
// Create a 3D model attribute
|
|
132
|
+
await module.createCategoryAttribute({
|
|
133
|
+
label: '3D Model',
|
|
134
|
+
type: 'file',
|
|
135
|
+
category_id: 'pcat_123',
|
|
136
|
+
is_standard: true,
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Adding attributes to a product
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// Get the attribute template
|
|
144
|
+
const attributes = await module.getCategoryAttributes('pcat_123')
|
|
145
|
+
|
|
146
|
+
// Add values to the product
|
|
147
|
+
await module.createProductAttribute({
|
|
148
|
+
product_id: 'prod_456',
|
|
149
|
+
category_custom_attribute_id: attributes[0].id,
|
|
150
|
+
value_numeric: 5.5,
|
|
151
|
+
})
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Getting product attributes
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
const productAttributes = await module.getProductAttributes('prod_456')
|
|
158
|
+
|
|
159
|
+
console.log(productAttributes)
|
|
160
|
+
// [
|
|
161
|
+
// {
|
|
162
|
+
// id: 'pat_...',
|
|
163
|
+
// value: 'Premium quality',
|
|
164
|
+
// value_numeric: 5.5,
|
|
165
|
+
// value_file: null,
|
|
166
|
+
// category_custom_attribute: {
|
|
167
|
+
// label: 'Weight',
|
|
168
|
+
// unit: 'kg',
|
|
169
|
+
// type: 'number'
|
|
170
|
+
// }
|
|
171
|
+
// }
|
|
172
|
+
// ]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 📚 API Reference
|
|
178
|
+
|
|
179
|
+
### CategoryCustomAttribute
|
|
180
|
+
|
|
181
|
+
| Method | Description | Parameters |
|
|
182
|
+
|--------|-------------|------------|
|
|
183
|
+
| `getCategoryAttributes(categoryId)` | Get all category attributes | `categoryId: string` |
|
|
184
|
+
| `createCategoryAttribute(data)` | Create a new attribute | See below |
|
|
185
|
+
| `updateCategoryAttribute(id, data)` | Update an attribute | `id: string`, `data: Partial<Attribute>` |
|
|
186
|
+
|
|
187
|
+
#### createCategoryAttribute
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
{
|
|
191
|
+
label: string // Display name
|
|
192
|
+
type: 'text' | 'number' | 'file' | 'boolean'
|
|
193
|
+
unit?: string | null // Unit of measurement (optional)
|
|
194
|
+
category_id: string // Category ID
|
|
195
|
+
is_standard?: boolean // Standard attribute flag
|
|
196
|
+
sort_order?: number // Sort order
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### ProductCustomAttribute
|
|
201
|
+
|
|
202
|
+
| Method | Description | Parameters |
|
|
203
|
+
|--------|-------------|------------|
|
|
204
|
+
| `getProductAttributes(productId)` | Get product attributes | `productId: string` |
|
|
205
|
+
| `createProductAttribute(data)` | Create attribute value | See below |
|
|
206
|
+
| `updateProductAttribute(id, data)` | Update value | `id: string`, `data: Partial<Value>` |
|
|
207
|
+
|
|
208
|
+
#### createProductAttribute
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
{
|
|
212
|
+
product_id: string
|
|
213
|
+
category_custom_attribute_id: string
|
|
214
|
+
value?: string
|
|
215
|
+
value_numeric?: number | null
|
|
216
|
+
value_file?: string | null
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 🗄️ Data Structure
|
|
223
|
+
|
|
224
|
+
### CategoryCustomAttribute
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
┌─────────────────────────────────────────┐
|
|
228
|
+
│ CategoryCustomAttribute │
|
|
229
|
+
├─────────────────────────────────────────┤
|
|
230
|
+
│ id: string (PK) │
|
|
231
|
+
│ key: string │
|
|
232
|
+
│ label: string │
|
|
233
|
+
│ type: 'text' | 'number' | 'file' │
|
|
234
|
+
│ unit: string | null │
|
|
235
|
+
│ sort_order: number │
|
|
236
|
+
│ is_standard: boolean │
|
|
237
|
+
│ category_id: string │
|
|
238
|
+
│ created_at: timestamp │
|
|
239
|
+
│ updated_at: timestamp │
|
|
240
|
+
│ deleted_at: timestamp | null │
|
|
241
|
+
└─────────────────────────────────────────┘
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### ProductCustomAttribute
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
┌─────────────────────────────────────────┐
|
|
248
|
+
│ ProductCustomAttribute │
|
|
249
|
+
├─────────────────────────────────────────┤
|
|
250
|
+
│ id: string (PK) │
|
|
251
|
+
│ product_id: string │
|
|
252
|
+
│ value: string | null │
|
|
253
|
+
│ value_numeric: number | null │
|
|
254
|
+
│ value_file: string | null │
|
|
255
|
+
│ category_custom_attribute_id: FK │
|
|
256
|
+
│ created_at: timestamp │
|
|
257
|
+
│ updated_at: timestamp │
|
|
258
|
+
│ deleted_at: timestamp | null │
|
|
259
|
+
└─────────────────────────────────────────┘
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 📝 Examples
|
|
265
|
+
|
|
266
|
+
### Example 1: Creating attributes for electronics
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
// Attributes for "Smartphones" category
|
|
270
|
+
await module.createCategoryAttribute({
|
|
271
|
+
label: 'Screen Size',
|
|
272
|
+
type: 'number',
|
|
273
|
+
unit: 'inch',
|
|
274
|
+
category_id: 'pcat_phones',
|
|
275
|
+
sort_order: 1,
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
await module.createCategoryAttribute({
|
|
279
|
+
label: 'Storage Capacity',
|
|
280
|
+
type: 'number',
|
|
281
|
+
unit: 'GB',
|
|
282
|
+
category_id: 'pcat_phones',
|
|
283
|
+
sort_order: 2,
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
await module.createCategoryAttribute({
|
|
287
|
+
label: 'Certificate',
|
|
288
|
+
type: 'file',
|
|
289
|
+
category_id: 'pcat_phones',
|
|
290
|
+
is_standard: true,
|
|
291
|
+
sort_order: 3,
|
|
292
|
+
})
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Example 2: Adding attribute values to a product
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
// iPhone 15 Pro
|
|
299
|
+
await module.createProductAttribute({
|
|
300
|
+
product_id: 'prod_iphone15pro',
|
|
301
|
+
category_custom_attribute_id: 'attr_screen_size',
|
|
302
|
+
value_numeric: 6.1,
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
await module.createProductAttribute({
|
|
306
|
+
product_id: 'prod_iphone15pro',
|
|
307
|
+
category_custom_attribute_id: 'attr_storage',
|
|
308
|
+
value_numeric: 256,
|
|
309
|
+
})
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Example 3: Store API — getting attributes for storefront
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
// GET /store/attribute-values?product_id=prod_iphone15pro
|
|
316
|
+
// Response:
|
|
317
|
+
{
|
|
318
|
+
"attribute_values": [
|
|
319
|
+
{
|
|
320
|
+
"id": "pat_...",
|
|
321
|
+
"name": "Screen Size",
|
|
322
|
+
"type": "number",
|
|
323
|
+
"unit": "inch",
|
|
324
|
+
"numeric_value": 6.1,
|
|
325
|
+
"is_standard": false
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"id": "pat_...",
|
|
329
|
+
"name": "Certificate",
|
|
330
|
+
"type": "file",
|
|
331
|
+
"file_value": "/files/cert_iphone15pro.pdf",
|
|
332
|
+
"is_standard": true
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Project Structure
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
medusa-product-attributes/
|
|
344
|
+
├── src/
|
|
345
|
+
│ ├── models/
|
|
346
|
+
│ │ ├── category-custom-attribute.ts
|
|
347
|
+
│ │ └── product-custom-attribute.ts
|
|
348
|
+
│ ├── index.ts
|
|
349
|
+
│ └── service.ts
|
|
350
|
+
├── assets/
|
|
351
|
+
│ └── *.png
|
|
352
|
+
├── dist/
|
|
353
|
+
├── package.json
|
|
354
|
+
├── tsconfig.json
|
|
355
|
+
├── LICENSE
|
|
356
|
+
└── README.md
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
<div align="center">
|
|
362
|
+
<h2>🤝 Contributing</h2>
|
|
363
|
+
<p>Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.</p>
|
|
364
|
+
<p>
|
|
365
|
+
<sub>Made with ❤️ for the Medusa community</sub>
|
|
366
|
+
</p>
|
|
367
|
+
</div>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import CustomAttributeService from "./service";
|
|
2
|
+
export declare const CUSTOM_ATTRIBUTE_MODULE = "customAttributeModule";
|
|
3
|
+
declare const _default: import("@medusajs/types").ModuleExports<typeof CustomAttributeService> & {
|
|
4
|
+
linkable: {
|
|
5
|
+
categoryCustomAttribute: {
|
|
6
|
+
id: {
|
|
7
|
+
serviceName: "customAttributeModule";
|
|
8
|
+
field: "categoryCustomAttribute";
|
|
9
|
+
linkable: "category_custom_attribute_id";
|
|
10
|
+
primaryKey: "id";
|
|
11
|
+
};
|
|
12
|
+
toJSON: () => {
|
|
13
|
+
serviceName: "customAttributeModule";
|
|
14
|
+
field: "categoryCustomAttribute";
|
|
15
|
+
linkable: "category_custom_attribute_id";
|
|
16
|
+
primaryKey: "id";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
productCustomAttribute: {
|
|
20
|
+
id: {
|
|
21
|
+
serviceName: "customAttributeModule";
|
|
22
|
+
field: "productCustomAttribute";
|
|
23
|
+
linkable: "product_custom_attribute_id";
|
|
24
|
+
primaryKey: "id";
|
|
25
|
+
};
|
|
26
|
+
toJSON: () => {
|
|
27
|
+
serviceName: "customAttributeModule";
|
|
28
|
+
field: "productCustomAttribute";
|
|
29
|
+
linkable: "product_custom_attribute_id";
|
|
30
|
+
primaryKey: "id";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export default _default;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,WAAW,CAAA;AAE9C,eAAO,MAAM,uBAAuB,0BAA0B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9D,wBAEE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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.CUSTOM_ATTRIBUTE_MODULE = void 0;
|
|
7
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
8
|
+
const service_1 = __importDefault(require("./service"));
|
|
9
|
+
exports.CUSTOM_ATTRIBUTE_MODULE = "customAttributeModule";
|
|
10
|
+
exports.default = (0, utils_1.Module)(exports.CUSTOM_ATTRIBUTE_MODULE, {
|
|
11
|
+
service: service_1.default,
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkD;AAClD,wDAA8C;AAEjC,QAAA,uBAAuB,GAAG,uBAAuB,CAAA;AAE9D,kBAAe,IAAA,cAAM,EAAC,+BAAuB,EAAE;IAC7C,OAAO,EAAE,iBAAsB;CAChC,CAAC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const CategoryCustomAttribute: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
3
|
+
key: import("@medusajs/framework/utils").TextProperty;
|
|
4
|
+
type: import("@medusajs/framework/utils").TextProperty;
|
|
5
|
+
label: import("@medusajs/framework/utils").TextProperty;
|
|
6
|
+
unit: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
7
|
+
sort_order: import("@medusajs/framework/utils").NumberProperty;
|
|
8
|
+
category_id: import("@medusajs/framework/utils").TextProperty;
|
|
9
|
+
is_standard: import("@medusajs/framework/utils").BooleanProperty;
|
|
10
|
+
product_custom_attributes: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
11
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
12
|
+
product_id: import("@medusajs/framework/utils").TextProperty;
|
|
13
|
+
value: import("@medusajs/framework/utils").TextProperty;
|
|
14
|
+
value_numeric: import("@medusajs/framework/utils").NullableModifier<number, import("@medusajs/framework/utils").NumberProperty>;
|
|
15
|
+
value_file: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
16
|
+
category_custom_attribute: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "category_custom_attribute">, undefined>;
|
|
17
|
+
}>, "product_custom_attribute">>;
|
|
18
|
+
}>, "category_custom_attribute">;
|
|
19
|
+
export default CategoryCustomAttribute;
|
|
20
|
+
//# sourceMappingURL=category-custom-attribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-custom-attribute.d.ts","sourceRoot":"","sources":["../../src/models/category-custom-attribute.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;gCAczB,CAAA;AAEJ,eAAe,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
7
|
+
const product_custom_attribute_1 = __importDefault(require("./product-custom-attribute"));
|
|
8
|
+
const CategoryCustomAttribute = utils_1.model
|
|
9
|
+
.define("category_custom_attribute", {
|
|
10
|
+
id: utils_1.model.id().primaryKey(),
|
|
11
|
+
key: utils_1.model.text(),
|
|
12
|
+
type: utils_1.model.text().default("text"),
|
|
13
|
+
label: utils_1.model.text().default(""),
|
|
14
|
+
unit: utils_1.model.text().nullable(), // Единица измерения (кг, м, шт и т.д.)
|
|
15
|
+
sort_order: utils_1.model.number().default(0),
|
|
16
|
+
category_id: utils_1.model.text(),
|
|
17
|
+
is_standard: utils_1.model.boolean().default(false), // Стандартные атрибуты (certificates, 3dmodel, manual)
|
|
18
|
+
product_custom_attributes: utils_1.model.hasMany(() => product_custom_attribute_1.default),
|
|
19
|
+
})
|
|
20
|
+
.cascades({
|
|
21
|
+
delete: ["product_custom_attributes"],
|
|
22
|
+
});
|
|
23
|
+
exports.default = CategoryCustomAttribute;
|
|
24
|
+
//# sourceMappingURL=category-custom-attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-custom-attribute.js","sourceRoot":"","sources":["../../src/models/category-custom-attribute.ts"],"names":[],"mappings":";;;;;AAAA,qDAAiD;AACjD,0FAA+D;AAE/D,MAAM,uBAAuB,GAAG,aAAK;KAClC,MAAM,CAAC,2BAA2B,EAAE;IACnC,EAAE,EAAE,aAAK,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE;IAC3B,GAAG,EAAE,aAAK,CAAC,IAAI,EAAE;IACjB,IAAI,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAClC,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/B,IAAI,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,uCAAuC;IACtE,UAAU,EAAE,aAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACrC,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE;IACzB,WAAW,EAAE,aAAK,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,uDAAuD;IACpG,yBAAyB,EAAE,aAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,kCAAsB,CAAC;CACvE,CAAC;KACD,QAAQ,CAAC;IACR,MAAM,EAAE,CAAC,2BAA2B,CAAC;CACtC,CAAC,CAAA;AAEJ,kBAAe,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const ProductCustomAttribute: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
3
|
+
product_id: import("@medusajs/framework/utils").TextProperty;
|
|
4
|
+
value: import("@medusajs/framework/utils").TextProperty;
|
|
5
|
+
value_numeric: import("@medusajs/framework/utils").NullableModifier<number, import("@medusajs/framework/utils").NumberProperty>;
|
|
6
|
+
value_file: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
7
|
+
category_custom_attribute: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
8
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
9
|
+
key: import("@medusajs/framework/utils").TextProperty;
|
|
10
|
+
type: import("@medusajs/framework/utils").TextProperty;
|
|
11
|
+
label: import("@medusajs/framework/utils").TextProperty;
|
|
12
|
+
unit: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
13
|
+
sort_order: import("@medusajs/framework/utils").NumberProperty;
|
|
14
|
+
category_id: import("@medusajs/framework/utils").TextProperty;
|
|
15
|
+
is_standard: import("@medusajs/framework/utils").BooleanProperty;
|
|
16
|
+
product_custom_attributes: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "product_custom_attribute">>;
|
|
17
|
+
}>, "category_custom_attribute">, undefined>;
|
|
18
|
+
}>, "product_custom_attribute">;
|
|
19
|
+
export default ProductCustomAttribute;
|
|
20
|
+
//# sourceMappingURL=product-custom-attribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-custom-attribute.d.ts","sourceRoot":"","sources":["../../src/models/product-custom-attribute.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;+BAS1B,CAAA;AAEF,eAAe,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
7
|
+
const category_custom_attribute_1 = __importDefault(require("./category-custom-attribute"));
|
|
8
|
+
const ProductCustomAttribute = utils_1.model.define("product_custom_attribute", {
|
|
9
|
+
id: utils_1.model.id().primaryKey(),
|
|
10
|
+
product_id: utils_1.model.text(),
|
|
11
|
+
value: utils_1.model.text(),
|
|
12
|
+
value_numeric: utils_1.model.number().nullable(),
|
|
13
|
+
value_file: utils_1.model.text().nullable(),
|
|
14
|
+
category_custom_attribute: utils_1.model.belongsTo(() => category_custom_attribute_1.default, {
|
|
15
|
+
mappedBy: "product_custom_attributes",
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
exports.default = ProductCustomAttribute;
|
|
19
|
+
//# sourceMappingURL=product-custom-attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-custom-attribute.js","sourceRoot":"","sources":["../../src/models/product-custom-attribute.ts"],"names":[],"mappings":";;;;;AAAA,qDAAiD;AACjD,4FAAiE;AAEjE,MAAM,sBAAsB,GAAG,aAAK,CAAC,MAAM,CAAC,0BAA0B,EAAE;IACtE,EAAE,EAAE,aAAK,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE;IAC3B,UAAU,EAAE,aAAK,CAAC,IAAI,EAAE;IACxB,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE;IACnB,aAAa,EAAE,aAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxC,UAAU,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACnC,yBAAyB,EAAE,aAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,mCAAuB,EAAE;QACxE,QAAQ,EAAE,2BAA2B;KACtC,CAAC;CACH,CAAC,CAAA;AAEF,kBAAe,sBAAsB,CAAA"}
|