@haus-tech/package-size-plugin 3.0.1 → 3.0.4

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/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ ## 3.0.3
2
+
3
+ ### 🚀 Features
4
+
5
+ - **package-size-plugin:** enhance package size configuration options ([c04bd80](https://github.com/WeAreHausTech/haus-tech-vendure-plugins/commit/c04bd80))
6
+ - **package-size-plugin:** add package size unit support to ProductVariant ([3e2cdf0](https://github.com/WeAreHausTech/haus-tech-vendure-plugins/commit/3e2cdf0))
7
+ - **product:** Product package size plugin ([#2](https://github.com/WeAreHausTech/haus-tech-vendure-plugins/pull/2))
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - **package-size-plugin:** set default package size unit to 'st' ([e08589c](https://github.com/WeAreHausTech/haus-tech-vendure-plugins/commit/e08589c))
12
+
13
+ ## 3.0.1
14
+
15
+ ### 🚀 Features
16
+
17
+ - **package-size-plugin:** add package size unit support to ProductVariant ([3e2cdf0](https://github.com/WeAreHausTech/haus-tech-vendure-plugins/commit/3e2cdf0))
18
+
19
+ ## 3.0.0
20
+
21
+ ### 🚀 Features
22
+
23
+ - Product package size plugin (#2) ([b38c847](https://github.com/WeAreHausTech/haus-vendure-plugins-public/commit/b38c8477c4728556f5711d57b7ef8acdfad029e9))
24
+ - New plugin - product popularity (#6) ([3de3285](https://github.com/WeAreHausTech/haus-vendure-plugins-public/commit/3de3285c57c300ee46e2d02f5c960ceb323401e2))
package/README.md CHANGED
@@ -1,59 +1,261 @@
1
- # Vendure plugin template
1
+ ---
2
+ name: package-size-plugin
3
+ title: Package Size Plugin
4
+ description: Vendure plugin that allows you to manage and expose custom package size information for product variants.
5
+ version: 3.0.2
6
+ ---
2
7
 
3
- 1. Copy this directory and rename to `vendure-plugin-YOUR-PLUGIN-NAME`
4
- 2. Update the `name` and `description` field in `package.json`
5
- 3. Update this Readme: What does the plugin do? How can someone use your plugin in their project?
6
- 4. Run `yarn` to install the dependencies
7
- 5. Run `yarn start` to start the server
8
+ # Package Size Plugin
8
9
 
9
- The admin is now available at `http://localhost:3050/admin`. Login with _superadmin/superadmin_
10
+ This plugin adds package size and optional unit functionality to product variants in Vendure.
10
11
 
11
- The shop GraphQL `http://localhost:3050/shop-api`. Here you can test your custom GraphQL query:
12
+ ## Installation
12
13
 
13
- ```graphql
14
- {
15
- exampleQuery
14
+ ```bash
15
+ yarn add @haus-tech/package-size-plugin
16
+ ```
17
+
18
+ ## Basic Usage
19
+
20
+ The plugin must be initialized with configuration options using the `.init()` method:
21
+
22
+ ```typescript
23
+ import { VendureConfig } from '@vendure/core'
24
+ import { PackageSizePlugin } from '@haus-tech/package-size-plugin'
25
+
26
+ export const config: VendureConfig = {
27
+ // ... other config
28
+ plugins: [
29
+ PackageSizePlugin.init({
30
+ // Configuration options (see below)
31
+ }),
32
+ // ... other plugins
33
+ ],
16
34
  }
17
35
  ```
18
36
 
19
- ## Testing
37
+ ## Configuration Options
20
38
 
21
- 1. Run `yarn test` to run the e2e test.
22
- 2. Don't forget to implement your own!
39
+ ### Basic Configuration (Package Size Only)
23
40
 
24
- ## Publishing to NPM
41
+ ```typescript
42
+ PackageSizePlugin.init({
43
+ // Uses default settings: integer package size, no unit field
44
+ })
45
+ ```
25
46
 
26
- 1. Make sure you are [logged in to NPM](https://docs.npmjs.com/cli/v9/commands/npm-login)
27
- 2. `yarn build`
28
- 3. `yarn publish`
47
+ This creates a single custom field:
29
48
 
30
- That's it!
49
+ - `packageSizeInternal`: Integer field with default value `1`
31
50
 
32
- (Maybe share your accomplishments in the [Vendure slack](https://join.slack.com/t/vendure-ecommerce/shared_invite/zt-1exzio25w-vjL5TYkyJZjK52d6jkOsIA)?
51
+ ### Float Package Size Support
33
52
 
34
- ## Next steps
53
+ ```typescript
54
+ PackageSizePlugin.init({
55
+ packageSizeFieldType: 'float',
56
+ })
57
+ ```
35
58
 
36
- 1. Check out [the docs](https://www.vendure.io/docs/plugins/) to see the possibilities of a plugin
37
- 2. Check out [GraphQL codegen](https://the-guild.dev/graphql/codegen) to generate Typescript types for your custom GraphQL types
59
+ This allows decimal values like `0.5`, `1.25`, `2.75`, etc.
38
60
 
39
- ## Index Packagesize in ElasticsearchPlugin
40
- - Add following to elasticSearchConfig
61
+ ### With Package Size Unit
41
62
 
42
- In indexMappingProperties:
63
+ ```typescript
64
+ PackageSizePlugin.init({
65
+ usePackageSizeUnit: true,
66
+ defaultUnit: 'kg',
67
+ })
68
+ ```
69
+
70
+ This adds both fields:
71
+
72
+ - `packageSizeInternal`: Integer package size
73
+ - `packageSizeUnitInternal`: String unit field with text input
43
74
 
75
+ ### Full Configuration
76
+
77
+ ```typescript
78
+ PackageSizePlugin.init({
79
+ packageSizeFieldType: 'float', // Enable decimal values
80
+ usePackageSizeUnit: true, // Enable unit field
81
+ defaultUnit: 'kg', // Set default unit
82
+ })
44
83
  ```
45
- 'variant-packageSize': {
46
- type: 'integer',
47
- },
84
+
85
+ ## Configuration Reference
86
+
87
+ | Option | Type | Default | Description |
88
+ | ---------------------- | ------------------ | ------- | ------------------------------------------------------------------------ |
89
+ | `packageSizeFieldType` | `'int' \| 'float'` | `'int'` | Data type for package size field |
90
+ | `usePackageSizeUnit` | `boolean` | `false` | Whether to include the unit field |
91
+ | `defaultUnit` | `string` | `'st'` | Default value for unit field (only used if `usePackageSizeUnit` is true) |
92
+
93
+ ## GraphQL API
94
+
95
+ The plugin dynamically adds fields to the ProductVariant type based on your configuration:
96
+
97
+ ### Integer Package Size Only
98
+
99
+ ```graphql
100
+ type ProductVariant {
101
+ packageSize: Int
102
+ }
48
103
  ```
49
104
 
50
- In customProductVariantMappings:
105
+ ### Float Package Size with Unit
51
106
 
107
+ ```graphql
108
+ type ProductVariant {
109
+ packageSize: Float
110
+ packageSizeUnit: String
111
+ }
52
112
  ```
113
+
114
+ ## Migration from Previous Versions
115
+
116
+ If you were using this plugin without the `.init()` method, you'll need to update your configuration:
117
+
118
+ **Before:**
119
+
120
+ ```typescript
121
+ plugins: [PackageSizePlugin]
122
+ ```
123
+
124
+ **After:**
125
+
126
+ ```typescript
127
+ plugins: [
128
+ PackageSizePlugin.init({
129
+ // Add your desired configuration
130
+ packageSizeFieldType: 'int', // or 'float'
131
+ usePackageSizeUnit: false, // or true if you want units
132
+ }),
133
+ ]
134
+ ```
135
+
136
+ ## Database Migration
137
+
138
+ When changing `packageSizeFieldType` from `'int'` to `'float'`, you'll need to create a database migration:
139
+
140
+ ```bash
141
+ npx vendure migration:generate update-package-size-to-float
142
+ npx vendure migration:run
143
+ ```
144
+
145
+ ## Elasticsearch Integration
146
+
147
+ If you're using Elasticsearch, configure the mappings based on your field type:
148
+
149
+ ### For Integer Package Size
150
+
151
+ ```typescript
152
+ const elasticSearchConfig: ElasticsearchOptions = {
153
+ // ... other config
154
+ indexMappingProperties: {
155
+ 'variant-packageSize': { type: 'integer' },
156
+ 'variant-packageSizeUnit': { type: 'keyword' }, // if using units
157
+ },
158
+ customProductVariantMappings: {
53
159
  packageSize: {
54
160
  graphQlType: 'Int!',
55
- valueFn: async (productVariant: ProductVariant ) => {
56
- return productVariant.customFields.packageSizeInternal
161
+ valueFn: async (productVariant: ProductVariant) => {
162
+ return productVariant.customFields.packageSizeInternal ?? 1
163
+ },
164
+ },
165
+ packageSizeUnit: {
166
+ // if using units
167
+ graphQlType: 'String!',
168
+ valueFn: async (productVariant: ProductVariant) => {
169
+ return productVariant.customFields.packageSizeUnitInternal ?? 'st'
57
170
  },
58
171
  },
172
+ },
173
+ }
59
174
  ```
175
+
176
+ ### For Float Package Size
177
+
178
+ ```typescript
179
+ const elasticSearchConfig: ElasticsearchOptions = {
180
+ // ... other config
181
+ indexMappingProperties: {
182
+ 'variant-packageSize': { type: 'float' },
183
+ 'variant-packageSizeUnit': { type: 'keyword' }, // if using units
184
+ },
185
+ customProductVariantMappings: {
186
+ packageSize: {
187
+ graphQlType: 'Float!',
188
+ valueFn: async (productVariant: ProductVariant) => {
189
+ return productVariant.customFields.packageSizeInternal ?? 1.0
190
+ },
191
+ },
192
+ packageSizeUnit: {
193
+ // if using units
194
+ graphQlType: 'String!',
195
+ valueFn: async (productVariant: ProductVariant) => {
196
+ return productVariant.customFields.packageSizeUnitInternal ?? 'st'
197
+ },
198
+ },
199
+ },
200
+ }
201
+ ```
202
+
203
+ ## Use Cases
204
+
205
+ The Package Size Plugin is ideal for:
206
+
207
+ - E-commerce platforms that require detailed package size information for logistics and shipping calculations.
208
+ - Businesses that need to expose package size data to customers or third-party systems via the shop API.
209
+ - Scenarios where Elasticsearch is used to index and search for product variant data, including package sizes.
210
+
211
+ ## Example GraphQL Query
212
+
213
+ You can query the `packageSize` field using the shop API:
214
+
215
+ ```graphql
216
+ query {
217
+ product(id: "1") {
218
+ variants {
219
+ id
220
+ name
221
+ packageSize
222
+ packageSizeUnit # if using units
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ ## Testing
229
+
230
+ 1. Run `yarn test` to execute the e2e tests.
231
+ 2. Implement additional tests to cover your specific use cases.
232
+
233
+ ## Publishing to NPM
234
+
235
+ 1. Make sure you are [logged in to NPM](https://docs.npmjs.com/cli/v9/commands/npm-login).
236
+ 2. Build the plugin:
237
+
238
+ ```bash
239
+ yarn build
240
+ ```
241
+
242
+ 3. Publish the plugin:
243
+
244
+ ```bash
245
+ yarn publish
246
+ ```
247
+
248
+ ## Features
249
+
250
+ - ✅ Configurable package size field type (integer or float)
251
+ - ✅ Optional package size unit field
252
+ - ✅ Dynamic GraphQL schema generation
253
+ - ✅ Elasticsearch integration support
254
+ - ✅ Multi-language labels (English/Swedish)
255
+ - ✅ TypeScript support
256
+ - ✅ Backward compatibility with migration path
257
+
258
+ ## Resources
259
+
260
+ - [Vendure Plugin Documentation](https://www.vendure.io/docs/plugins/)
261
+ - [GraphQL Code Generator](https://the-guild.dev/graphql/codegen) for generating TypeScript types for custom GraphQL types.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haus-tech/package-size-plugin",
3
- "version": "3.0.1",
3
+ "version": "3.0.4",
4
4
  "description": "Package size plugin for Vendure",
5
5
  "author": "Haus Tech",
6
6
  "repository": {
@@ -11,16 +11,10 @@
11
11
  "engines": {
12
12
  "node": ">=20.0.0"
13
13
  },
14
- "main": "dist/index.js",
15
- "types": "dist/index.d.ts",
16
- "files": [
17
- "dist",
18
- "README.md"
19
- ],
14
+ "main": "src/index.js",
15
+ "types": "src/index.d.ts",
20
16
  "scripts": {
21
- "start": "yarn ts-node test/dev-server.ts",
22
- "build": "rimraf dist && tsc",
23
- "test": "jest --preset=\"ts-jest\"",
24
- "prepublishOnly": "yarn && yarn build"
25
- }
26
- }
17
+ "start": "yarn ts-node test/dev-server.ts"
18
+ },
19
+ "type": "commonjs"
20
+ }
@@ -0,0 +1 @@
1
+ export declare const getShopApiExtensions: (packageSizeFieldType: "int" | "float") => import("graphql").DocumentNode;
@@ -0,0 +1,18 @@
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.getShopApiExtensions = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ const getShopApiExtensions = (packageSizeFieldType) => {
9
+ const packageSizeType = packageSizeFieldType === 'float' ? 'Float' : 'Int';
10
+ return (0, graphql_tag_1.default) `
11
+ extend type ProductVariant {
12
+ packageSize: ${packageSizeType}
13
+ packageSizeUnit: String
14
+ }
15
+ `;
16
+ };
17
+ exports.getShopApiExtensions = getShopApiExtensions;
18
+ //# sourceMappingURL=api-extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-extensions.js","sourceRoot":"","sources":["../../../../../packages/package-size-plugin/src/api/api-extensions.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEtB,MAAM,oBAAoB,GAAG,CAAC,oBAAqC,EAAE,EAAE;IAC5E,MAAM,eAAe,GAAG,oBAAoB,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAA;IAE1E,OAAO,IAAA,qBAAG,EAAA;;qBAES,eAAe;;;GAGjC,CAAA;AACH,CAAC,CAAA;AATY,QAAA,oBAAoB,wBAShC"}
@@ -45,3 +45,4 @@ exports.ProductVariantEntityResolver = ProductVariantEntityResolver = __decorate
45
45
  (0, graphql_1.Resolver)('ProductVariant'),
46
46
  __metadata("design:paramtypes", [])
47
47
  ], ProductVariantEntityResolver);
48
+ //# sourceMappingURL=package-size.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-size.resolver.js","sourceRoot":"","sources":["../../../../../packages/package-size-plugin/src/api/package-size.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAgE;AAChE,wCAAmE;AAG5D,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IACvC,gBAAe,CAAC;IAGhB,WAAW,CAAQ,GAAmB,EAAY,OAAuB;QACvE,OAAO,OAAO,CAAC,YAAY,CAAC,mBAAmB,IAAI,CAAC,CAAA;IACtD,CAAC;IAGD,eAAe,CAAQ,GAAmB,EAAY,OAAuB;QAC3E,OAAO,OAAO,CAAC,YAAY,CAAC,uBAAuB,IAAI,IAAI,CAAA;IAC7D,CAAC;CACF,CAAA;AAZY,oEAA4B;AAIvC;IADC,IAAA,sBAAY,GAAE;IACF,WAAA,IAAA,UAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,gBAAM,GAAE,CAAA;;qCAAzB,qBAAc,EAAqB,qBAAc;;+DAExE;AAGD;IADC,IAAA,sBAAY,GAAE;IACE,WAAA,IAAA,UAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,gBAAM,GAAE,CAAA;;qCAAzB,qBAAc,EAAqB,qBAAc;;mEAE5E;uCAXU,4BAA4B;IADxC,IAAA,kBAAQ,EAAC,gBAAgB,CAAC;;GACd,4BAA4B,CAYxC"}
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PLUGIN_INIT_OPTIONS = exports.loggerCtx = void 0;
4
4
  exports.loggerCtx = 'PackageSizePlugin';
5
5
  exports.PLUGIN_INIT_OPTIONS = Symbol('PACKAGE_SIZE_PLUGIN_INIT_OPTIONS');
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../packages/package-size-plugin/src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,mBAAmB,CAAA;AAC/B,QAAA,mBAAmB,GAAG,MAAM,CAAC,kCAAkC,CAAC,CAAA"}
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./package-size.plugin"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/package-size-plugin/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
@@ -1,4 +1,4 @@
1
- import { LanguageCode } from '@vendure/core';
1
+ import { LanguageCode, Type } from '@vendure/core';
2
2
  export interface PackageSizeUnit {
3
3
  value: string;
4
4
  label: {
@@ -8,6 +8,8 @@ export interface PackageSizeUnit {
8
8
  }
9
9
  export interface PackageSizePluginConfig {
10
10
  defaultUnit?: string;
11
+ packageSizeFieldType?: 'int' | 'float';
12
+ usePackageSizeUnit?: boolean;
11
13
  }
12
14
  declare module '@vendure/core' {
13
15
  interface CustomProductVariantFields {
@@ -20,4 +22,5 @@ declare module '@vendure/core' {
20
22
  }
21
23
  }
22
24
  export declare class PackageSizePlugin {
25
+ static init(config: PackageSizePluginConfig): Type<any>;
23
26
  }
@@ -0,0 +1,63 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.PackageSizePlugin = void 0;
10
+ const core_1 = require("@vendure/core");
11
+ const api_extensions_1 = require("./api/api-extensions");
12
+ const package_size_resolver_1 = require("./api/package-size.resolver");
13
+ class PackageSizePlugin {
14
+ static init(config) {
15
+ const fieldType = config.packageSizeFieldType || 'int';
16
+ const usePackageSizeUnit = config.usePackageSizeUnit || false;
17
+ let DynamicPackageSizePlugin = class DynamicPackageSizePlugin {
18
+ };
19
+ DynamicPackageSizePlugin = __decorate([
20
+ (0, core_1.VendurePlugin)({
21
+ imports: [core_1.PluginCommonModule],
22
+ shopApiExtensions: {
23
+ resolvers: [package_size_resolver_1.ProductVariantEntityResolver],
24
+ schema: (0, api_extensions_1.getShopApiExtensions)(fieldType),
25
+ },
26
+ configuration: (vendureConfig) => {
27
+ const defaultUnit = config.defaultUnit || 'st';
28
+ const defaultValue = fieldType === 'float' ? 1.0 : 1;
29
+ vendureConfig.customFields.ProductVariant.push({
30
+ name: 'packageSizeInternal',
31
+ type: fieldType,
32
+ defaultValue: defaultValue,
33
+ public: false,
34
+ label: [
35
+ { languageCode: core_1.LanguageCode.en, value: 'Package Size' },
36
+ { languageCode: core_1.LanguageCode.sv, value: 'Förpackningsstorlek' },
37
+ ],
38
+ });
39
+ if (usePackageSizeUnit) {
40
+ vendureConfig.customFields.ProductVariant.push({
41
+ name: 'packageSizeUnitInternal',
42
+ type: 'string',
43
+ defaultValue: defaultUnit,
44
+ ui: {
45
+ component: 'text-form-input',
46
+ },
47
+ public: false,
48
+ label: [
49
+ { languageCode: core_1.LanguageCode.en, value: 'Package Size Unit' },
50
+ { languageCode: core_1.LanguageCode.sv, value: 'Förpackningsenhet' },
51
+ ],
52
+ });
53
+ }
54
+ return vendureConfig;
55
+ },
56
+ compatibility: '^3.0.0',
57
+ })
58
+ ], DynamicPackageSizePlugin);
59
+ return DynamicPackageSizePlugin;
60
+ }
61
+ }
62
+ exports.PackageSizePlugin = PackageSizePlugin;
63
+ //# sourceMappingURL=package-size.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-size.plugin.js","sourceRoot":"","sources":["../../../../packages/package-size-plugin/src/package-size.plugin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,wCAMsB;AACtB,yDAA2D;AAC3D,uEAA0E;AAyB1E,MAAa,iBAAiB;IACrB,AAAP,MAAM,CAAC,IAAI,CAAC,MAA+B;QACzC,MAAM,SAAS,GAAG,MAAM,CAAC,oBAAoB,IAAI,KAAK,CAAA;QACtD,MAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,IAAI,KAAK,CAAA;QA2C7D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;SAAG,CAAA;QAA3B,wBAAwB;YAzC7B,IAAA,oBAAa,EAAC;gBACb,OAAO,EAAE,CAAC,yBAAkB,CAAC;gBAC7B,iBAAiB,EAAE;oBACjB,SAAS,EAAE,CAAC,oDAA4B,CAAC;oBACzC,MAAM,EAAE,IAAA,qCAAoB,EAAC,SAAS,CAAC;iBACxC;gBACD,aAAa,EAAE,CAAC,aAAa,EAAE,EAAE;oBAC/B,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,CAAA;oBAC9C,MAAM,YAAY,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;oBAEpD,aAAa,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC;wBAC7C,IAAI,EAAE,qBAAqB;wBAC3B,IAAI,EAAE,SAAS;wBACf,YAAY,EAAE,YAAY;wBAC1B,MAAM,EAAE,KAAK;wBACb,KAAK,EAAE;4BACL,EAAE,YAAY,EAAE,mBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;4BACxD,EAAE,YAAY,EAAE,mBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE;yBAChE;qBACF,CAAC,CAAA;oBAEF,IAAI,kBAAkB,EAAE,CAAC;wBACvB,aAAa,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC;4BAC7C,IAAI,EAAE,yBAAyB;4BAC/B,IAAI,EAAE,QAAQ;4BACd,YAAY,EAAE,WAAW;4BACzB,EAAE,EAAE;gCACF,SAAS,EAAE,iBAAiB;6BAC7B;4BACD,MAAM,EAAE,KAAK;4BACb,KAAK,EAAE;gCACL,EAAE,YAAY,EAAE,mBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE;gCAC7D,EAAE,YAAY,EAAE,mBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE;6BAC9D;yBACF,CAAC,CAAA;oBACJ,CAAC;oBAED,OAAO,aAAa,CAAA;gBACtB,CAAC;gBACD,aAAa,EAAE,QAAQ;aACxB,CAAC;WACI,wBAAwB,CAAG;QAEjC,OAAO,wBAAwB,CAAA;IACjC,CAAC;CACF;AAlDD,8CAkDC"}
@@ -1 +0,0 @@
1
- export declare const shopApiExtensions: import("graphql").DocumentNode;
@@ -1,13 +0,0 @@
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.shopApiExtensions = void 0;
7
- const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
- exports.shopApiExtensions = (0, graphql_tag_1.default) `
9
- extend type ProductVariant {
10
- packageSize: Int
11
- packageSizeUnit: String
12
- }
13
- `;
@@ -1,52 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.PackageSizePlugin = void 0;
10
- const core_1 = require("@vendure/core");
11
- const api_extensions_1 = require("./api/api-extensions");
12
- const package_size_resolver_1 = require("./api/package-size.resolver");
13
- let PackageSizePlugin = class PackageSizePlugin {
14
- };
15
- exports.PackageSizePlugin = PackageSizePlugin;
16
- exports.PackageSizePlugin = PackageSizePlugin = __decorate([
17
- (0, core_1.VendurePlugin)({
18
- imports: [core_1.PluginCommonModule],
19
- shopApiExtensions: {
20
- resolvers: [package_size_resolver_1.ProductVariantEntityResolver],
21
- schema: api_extensions_1.shopApiExtensions,
22
- },
23
- configuration: (config) => {
24
- const pluginConfig = config.packageSize || {};
25
- const defaultUnit = pluginConfig.defaultUnit || 'st';
26
- config.customFields.ProductVariant.push({
27
- name: 'packageSizeInternal',
28
- type: 'int',
29
- defaultValue: 1,
30
- public: false,
31
- label: [
32
- { languageCode: core_1.LanguageCode.en, value: 'Package Size' },
33
- { languageCode: core_1.LanguageCode.sv, value: 'Förpackningsstorlek' },
34
- ],
35
- }, {
36
- name: 'packageSizeUnitInternal',
37
- type: 'string',
38
- defaultValue: defaultUnit,
39
- ui: {
40
- component: 'text-form-input',
41
- },
42
- public: false,
43
- label: [
44
- { languageCode: core_1.LanguageCode.en, value: 'Package Size Unit' },
45
- { languageCode: core_1.LanguageCode.sv, value: 'Förpackningsenhet' },
46
- ],
47
- });
48
- return config;
49
- },
50
- compatibility: '^3.0.0',
51
- })
52
- ], PackageSizePlugin);
File without changes
File without changes
File without changes