@haus-storefront-react/vendure-plugin-configs 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.
Files changed (34) hide show
  1. package/README.md +176 -0
  2. package/badge.js +1 -0
  3. package/badge.mjs +91 -0
  4. package/campaign.js +42 -0
  5. package/campaign.mjs +467 -0
  6. package/index-CzxpJe9c.js +27 -0
  7. package/index-RBMJ45wv.mjs +3751 -0
  8. package/index.d.ts +1 -0
  9. package/index.js +1 -0
  10. package/index.mjs +4 -0
  11. package/lib/configs/vendure-badge-plugin.augmentation.d.ts +15 -0
  12. package/lib/configs/vendure-badge-plugin.d.ts +14 -0
  13. package/lib/configs/vendure-badge-plugin.types.d.ts +24 -0
  14. package/lib/configs/vendure-campaign-plugin.augmentation.d.ts +13 -0
  15. package/lib/configs/vendure-campaign-plugin.d.ts +5 -0
  16. package/lib/configs/vendure-campaign-plugin.types.d.ts +19 -0
  17. package/lib/configs/vendure-packagesize-plugin.augmentation.d.ts +14 -0
  18. package/lib/configs/vendure-packagesize-plugin.d.ts +23 -0
  19. package/lib/configs/vendure-packagesize-plugin.types.d.ts +27 -0
  20. package/lib/configs/vendure-product-popularity-plugin.augmentation.d.ts +12 -0
  21. package/lib/configs/vendure-product-popularity-plugin.d.ts +32 -0
  22. package/lib/configs/vendure-product-popularity-plugin.types.d.ts +3 -0
  23. package/lib/exports/augmentations.d.ts +4 -0
  24. package/lib/exports/badge.d.ts +1 -0
  25. package/lib/exports/campaign.d.ts +1 -0
  26. package/lib/exports/packagesize.d.ts +1 -0
  27. package/lib/exports/product-popularity.d.ts +1 -0
  28. package/lib/plugin-config.d.ts +63 -0
  29. package/lib/types.d.ts +2 -0
  30. package/package.json +42 -0
  31. package/packagesize.js +1 -0
  32. package/packagesize.mjs +61 -0
  33. package/product-popularity.js +1 -0
  34. package/product-popularity.mjs +24 -0
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/plugin-config';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CzxpJe9c.js");exports.VendurePluginConfig=e.VendurePluginConfig;
package/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { V as o } from "./index-RBMJ45wv.mjs";
2
+ export {
3
+ o as VendurePluginConfig
4
+ };
@@ -0,0 +1,15 @@
1
+ import { BadgeFeatures } from './vendure-badge-plugin.types';
2
+ declare module '@haus-storefront-react/shared-types' {
3
+ interface Product {
4
+ badges?: Maybe<Array<Badge>>;
5
+ }
6
+ interface SearchResult {
7
+ badges?: Maybe<Array<Badge>>;
8
+ }
9
+ interface ProductVariant {
10
+ badges?: Maybe<Array<Badge>>;
11
+ }
12
+ interface PluginFeatureMappings {
13
+ showBadges: BadgeFeatures['showBadges'];
14
+ }
15
+ }
@@ -0,0 +1,14 @@
1
+ import { Asset, Collection } from '@haus-storefront-react/shared-types';
2
+ import { VendurePluginConfig } from '../plugin-config';
3
+ import { BadgeFeatures, BadgePluginRequests, BadgePluginSettings } from './vendure-badge-plugin.types';
4
+ export declare const VendureBadgePlugin: VendurePluginConfig<BadgeFeatures, BadgePluginRequests, BadgePluginSettings, import('@haus-storefront-react/shared-types').IGraphQLSDK>;
5
+ export type Badge = {
6
+ id: string;
7
+ createdAt: string;
8
+ updatedAt: string;
9
+ collection: Collection;
10
+ collectionId: string;
11
+ position: string;
12
+ asset: Asset;
13
+ assetId: string;
14
+ };
@@ -0,0 +1,24 @@
1
+ import { Badge, ErrorResult, Maybe, PaginatedList, Product, ProductVariant, SearchResult } from '@haus-storefront-react/shared-types';
2
+ export interface BadgePluginRequests {
3
+ [key: string]: (...args: unknown[]) => unknown;
4
+ getBadges: () => Promise<PaginatedList<Badge> | ErrorResult>;
5
+ }
6
+ export interface BadgeFeatures {
7
+ showBadges: (props: {
8
+ product?: Product | SearchResult;
9
+ variant?: ProductVariant;
10
+ parentComponent?: keyof BadgePluginSettings['availablePositions'];
11
+ badges: Maybe<Badge[]>;
12
+ }) => {
13
+ badges: Badge[];
14
+ availablePositions?: string[];
15
+ };
16
+ }
17
+ export type BadgePluginSettings = {
18
+ defaultPositions: string[];
19
+ availablePositions: {
20
+ productListItem?: string[];
21
+ productDetail?: string[];
22
+ imageCarousel?: string[];
23
+ };
24
+ };
@@ -0,0 +1,13 @@
1
+ import { CampaignFeatures } from './vendure-campaign-plugin.types';
2
+ declare module '@haus-storefront-react/shared-types' {
3
+ interface Product {
4
+ ordinaryPrice?: Price;
5
+ }
6
+ interface SearchResult {
7
+ ordinaryPrice?: Price;
8
+ }
9
+ interface PluginFeatureMappings {
10
+ showCampaignPrices: CampaignFeatures['showCampaignPrices'];
11
+ ordinaryPrice: CampaignFeatures['ordinaryPrice'];
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ import { VendurePluginConfig } from '../plugin-config';
2
+ import { CampaignFeatures } from './vendure-campaign-plugin.types';
3
+ export declare const VendureCampaignPlugin: VendurePluginConfig<CampaignFeatures, Record<string, (...args: any[]) => any>, {
4
+ [x: string]: any;
5
+ }, import('@haus-storefront-react/shared-types').IGraphQLSDK>;
@@ -0,0 +1,19 @@
1
+ import { OrderLine, Price, Product, ProductVariant, SearchResult } from '@haus-storefront-react/shared-types';
2
+ export interface CampaignFeatures {
3
+ showCampaignPrices: boolean;
4
+ ordinaryPrice: (props: {
5
+ product?: Product;
6
+ searchResult?: SearchResult & {
7
+ ordinaryPrice?: Price;
8
+ };
9
+ variant?: ProductVariant & {
10
+ ordinaryPrice?: Price;
11
+ };
12
+ orderLine?: OrderLine & {
13
+ productVariant: ProductVariant & {
14
+ ordinaryPrice?: Price;
15
+ };
16
+ };
17
+ identifier?: string;
18
+ }) => Price;
19
+ }
@@ -0,0 +1,14 @@
1
+ import { PackageSizeFeatures } from './vendure-packagesize-plugin.types';
2
+ declare module '@haus-storefront-react/shared-types' {
3
+ interface Product {
4
+ packageSize?: number;
5
+ }
6
+ interface SearchResult {
7
+ packageSize?: number;
8
+ }
9
+ interface PluginFeatureMappings {
10
+ changeQuantityByPackageSize: PackageSizeFeatures['changeQuantityByPackageSize'];
11
+ showPackageSize: PackageSizeFeatures['showPackageSize'];
12
+ showCostPerPackage: PackageSizeFeatures['showCostPerPackage'];
13
+ }
14
+ }
@@ -0,0 +1,23 @@
1
+ import { VendurePluginConfig } from '../plugin-config';
2
+ import { PackageSizeFeatures } from './vendure-packagesize-plugin.types';
3
+ /**
4
+ * Instance of `VendurePluginConfig` configured for the `packageSize` plugin.
5
+ * This setup initializes the plugin with its specific name and an empty array of enabled features,
6
+ * indicating that no additional features are enabled by default. It also provides an empty object for
7
+ * query updates, which can be customized as needed.
8
+ *
9
+ * Usage:
10
+ * To enable features, you can modify the `enableFeatures` array during instantiation or use the `init` method
11
+ * to update it later. For example, to enable the `changeQuantityByPackageSize` feature, you would pass
12
+ * `['changeQuantityByPackageSize']` as the value for `enableFeatures` in the configuration object.
13
+ *
14
+ * @example
15
+ * const VendurePackageSizePlugin = new VendurePluginConfig<PackageSizeFeatures>({
16
+ * name: 'packageSize',
17
+ * enableFeatures: ['changeQuantityByPackageSize'], // Enable specific features here
18
+ * queryUpdates: {},
19
+ * });
20
+ */
21
+ export declare const VendurePackageSizePlugin: VendurePluginConfig<PackageSizeFeatures, Record<string, (...args: any[]) => any>, {
22
+ [x: string]: any;
23
+ }, import('@haus-storefront-react/shared-types').IGraphQLSDK>;
@@ -0,0 +1,27 @@
1
+ import { Product, ProductVariant, SearchResult } from '@haus-storefront-react/shared-types';
2
+ /**
3
+ * Represents the specific features available for the `packageSize` plugin.
4
+ * These features can be enabled individually to customize the behavior of the plugin.
5
+ *
6
+ * @type {('changeQuantityByPackageSize' | 'showPackageSize')}
7
+ *
8
+ * - `changeQuantityByPackageSize`: Enables functionality to adjust product quantities based on package size.
9
+ * - `showPackageSize`: Allows the display of package sizes in product details.
10
+ */
11
+ export type PackageSizeFeatures = {
12
+ changeQuantityByPackageSize: (props: {
13
+ product?: Product | SearchResult;
14
+ variant?: ProductVariant;
15
+ identifier: string;
16
+ }) => boolean;
17
+ showPackageSize: (props: {
18
+ product?: Product | SearchResult;
19
+ variant?: ProductVariant;
20
+ identifier: string;
21
+ }) => boolean;
22
+ showCostPerPackage: (props: {
23
+ product?: Product | SearchResult;
24
+ variant?: ProductVariant;
25
+ identifier: string;
26
+ }) => boolean;
27
+ };
@@ -0,0 +1,12 @@
1
+ import { ProductPopularityFeatures } from './vendure-product-popularity-plugin.types';
2
+ declare module '@haus-storefront-react/shared-types' {
3
+ interface Product {
4
+ popularity?: number;
5
+ }
6
+ interface SearchResult {
7
+ popularity?: number;
8
+ }
9
+ interface PluginFeatureMappings {
10
+ sortByPopularity: ProductPopularityFeatures['sortByPopularity'];
11
+ }
12
+ }
@@ -0,0 +1,32 @@
1
+ import { VendurePluginConfig } from '../plugin-config';
2
+ import { ProductPopularityFeatures } from './vendure-product-popularity-plugin.types';
3
+ /**
4
+ * Represents the specific features available for the `productPopularity` plugin.
5
+ * These features can be enabled individually to customize the behavior of the plugin.
6
+ *
7
+ * @type {('sortByPopularity')}
8
+ *
9
+ * - `changeQuantityByPackageSize`: Enables functionality to adjust product quantities based on package size.
10
+ * - `showPackageSize`: Allows the display of package sizes in product details.
11
+ */
12
+ /**
13
+ * Instance of `VendurePluginConfig` configured for the `packageSize` plugin.
14
+ * This setup initializes the plugin with its specific name and an empty array of enabled features,
15
+ * indicating that no additional features are enabled by default. It also provides an empty object for
16
+ * query updates, which can be customized as needed.
17
+ *
18
+ * Usage:
19
+ * To enable features, you can modify the `enableFeatures` array during instantiation or use the `init` method
20
+ * to update it later. For example, to enable the `changeQuantityByPackageSize` feature, you would pass
21
+ * `['changeQuantityByPackageSize']` as the value for `enableFeatures` in the configuration object.
22
+ *
23
+ * @example
24
+ * const VendurePackageSizePlugin = new VendurePluginConfig<PackageSizeFeatures>({
25
+ * name: 'packageSize',
26
+ * enableFeatures: ['changeQuantityByPackageSize'], // Enable specific features here
27
+ * queryUpdates: {},
28
+ * });
29
+ */
30
+ export declare const VendureProductPopularityPlugin: VendurePluginConfig<ProductPopularityFeatures, Record<string, (...args: any[]) => any>, {
31
+ [x: string]: any;
32
+ }, import('@haus-storefront-react/shared-types').IGraphQLSDK>;
@@ -0,0 +1,3 @@
1
+ export type ProductPopularityFeatures = {
2
+ sortByPopularity: boolean;
3
+ };
@@ -0,0 +1,4 @@
1
+ export * from '../configs/vendure-badge-plugin.augmentation';
2
+ export * from '../configs/vendure-campaign-plugin.augmentation';
3
+ export * from '../configs/vendure-packagesize-plugin.augmentation';
4
+ export * from '../configs/vendure-product-popularity-plugin.augmentation';
@@ -0,0 +1 @@
1
+ export * from '../configs/vendure-badge-plugin';
@@ -0,0 +1 @@
1
+ export * from '../configs/vendure-campaign-plugin';
@@ -0,0 +1 @@
1
+ export * from '../configs/vendure-packagesize-plugin';
@@ -0,0 +1 @@
1
+ export * from '../configs/vendure-product-popularity-plugin';
@@ -0,0 +1,63 @@
1
+ import { BuilderQueryUpdates, IVendurePluginConfig, PluginFeatures, ProviderDataMap, IGraphQLSDK } from '@haus-storefront-react/shared-types';
2
+ type PluginSettings = Record<string, any>;
3
+ export type VendurePluginConfigInput<Features, R, S> = {
4
+ name: string;
5
+ enabled?: boolean;
6
+ enableFeatures?: Partial<Record<keyof Features, boolean>> | Partial<Features>;
7
+ queryUpdates: BuilderQueryUpdates;
8
+ requests?: R;
9
+ providers?: ProviderDataMap;
10
+ settings?: S;
11
+ };
12
+ export declare class VendurePluginConfig<Features extends PluginFeatures = PluginFeatures, R extends Record<string, (...args: any[]) => any> = Record<string, (...args: any[]) => any>, S extends PluginSettings = PluginSettings, T extends IGraphQLSDK = IGraphQLSDK> implements IVendurePluginConfig<Features, R, S, T> {
13
+ sdk: T;
14
+ name: IVendurePluginConfig<Features, R, S, T>['name'];
15
+ enabled: boolean;
16
+ enableFeatures: IVendurePluginConfig<Features, R, S, T>['enableFeatures'] | undefined;
17
+ queryUpdates: BuilderQueryUpdates;
18
+ requests: R;
19
+ providers: IVendurePluginConfig<Features, R, S, T>['providers'];
20
+ settings: S;
21
+ constructor(config: VendurePluginConfigInput<Features, R, S>);
22
+ /**
23
+ * Initializes the plugin configuration with a specified set of features.
24
+ * This method allows dynamically setting the features that should be enabled for the plugin.
25
+ *
26
+ * For the `packageSize` plugin, the available features to enable are:
27
+ * - `changeQuantityByPackageSize`: Allows changing the quantity of products based on their package size.
28
+ * - `showPackageSize`: Enables the display of package sizes in product details.
29
+ *
30
+ * @param {Pick<IVendurePluginConfig<Features>, 'enableFeatures'>} config An object specifying the features to enable.
31
+ * @returns {VendurePluginConfig<Features>} Returns the current instance of `VendurePluginConfig`, enabling method chaining.
32
+ */
33
+ init(config: Pick<IVendurePluginConfig<Features, R, S, T>, 'enableFeatures' | 'settings'> & {
34
+ enableFeatures?: Partial<Record<keyof Features, boolean>> | Partial<Features> | Array<keyof Features>;
35
+ }): VendurePluginConfig<Features, R, S, T>;
36
+ setSdk(sdk: T): void;
37
+ getSdk(): T;
38
+ getName(): string;
39
+ isEnabled(): boolean;
40
+ setEnabled(enabled: boolean): void;
41
+ setQueryUpdates(queryUpdates: BuilderQueryUpdates): void;
42
+ getQueryUpdates(): BuilderQueryUpdates;
43
+ setRequests(requests: R): void;
44
+ getRequests(): R;
45
+ setProviders(providers: IVendurePluginConfig<Features, R, S, T>['providers']): void;
46
+ getProviders(): ProviderDataMap;
47
+ setSettings(settings: S): void;
48
+ getSettings(): S;
49
+ setEnableFeatures(enableFeatures: Partial<Record<keyof Features, boolean>> | Partial<Features>): void;
50
+ getEnabled(): boolean;
51
+ getEnabledFeatures(): {};
52
+ }
53
+ /**
54
+ * Extraherar alla enabled features från en array av pluginConfigs.
55
+ * Används för att få typ-automatik i SDK/getFeature.
56
+ */
57
+ export type ExtractEnabledFeatures<T extends readonly any[]> = T[number] extends {
58
+ getEnabledFeatures: () => infer F;
59
+ } ? keyof F : never;
60
+ export type EnabledFeaturesMap<T extends readonly any[]> = {
61
+ [K in ExtractEnabledFeatures<T>]: boolean;
62
+ };
63
+ export {};
package/lib/types.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './configs/vendure-badge-plugin.types';
2
+ export * from './configs/vendure-product-popularity-plugin.types';
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@haus-storefront-react/vendure-plugin-configs",
3
+ "version": "0.0.1",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "import": "./index.mjs",
10
+ "require": "./index.js"
11
+ },
12
+ "./augmentations": {
13
+ "types": "./lib/exports/augmentations.d.ts",
14
+ "import": "./augmentations.mjs",
15
+ "require": "./augmentations.js"
16
+ },
17
+ "./badge": {
18
+ "types": "./lib/exports/badge.d.ts",
19
+ "import": "./badge.mjs",
20
+ "require": "./badge.js"
21
+ },
22
+ "./campaign": {
23
+ "types": "./lib/exports/campaign.d.ts",
24
+ "import": "./campaign.mjs",
25
+ "require": "./campaign.js"
26
+ },
27
+ "./packagesize": {
28
+ "types": "./lib/exports/packagesize.d.ts",
29
+ "import": "./packagesize.mjs",
30
+ "require": "./packagesize.js"
31
+ },
32
+ "./product-popularity": {
33
+ "types": "./lib/exports/product-popularity.d.ts",
34
+ "import": "./product-popularity.mjs",
35
+ "require": "./product-popularity.js"
36
+ }
37
+ },
38
+ "dependencies": {
39
+ "@haus-storefront-react/common-utils": "0.0.7-0",
40
+ "@haus-storefront-react/shared-types": "0.0.7-0"
41
+ }
42
+ }
package/packagesize.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-CzxpJe9c.js"),e=new a.VendurePluginConfig({name:"packageSize",enableFeatures:{},queryUpdates:{}});e.setQueryUpdates({activeOrder:{fields:[{lines:[{productVariant:["packageSize"]}]}]},orderByCode:{fields:[{lines:[{productVariant:["packageSize"]}]}]},product:{fields:[{variants:["packageSize"]}]},briefProducts:{fields:[{items:[{variants:["packageSize"]}]}]},adjustOrderLine:{fields:[{fields:[{lines:[{productVariant:["packageSize"]}]}]}]},addItemToOrder:{fields:[{fields:[{lines:[{productVariant:["packageSize"]}]}]}]}});exports.VendurePackageSizePlugin=e;
@@ -0,0 +1,61 @@
1
+ import { V as e } from "./index-RBMJ45wv.mjs";
2
+ const a = new e({
3
+ name: "packageSize",
4
+ enableFeatures: {},
5
+ queryUpdates: {}
6
+ });
7
+ a.setQueryUpdates({
8
+ activeOrder: {
9
+ fields: [{
10
+ lines: [{
11
+ productVariant: ["packageSize"]
12
+ // TODO: add packageSizeUnit
13
+ }]
14
+ }]
15
+ },
16
+ orderByCode: {
17
+ fields: [{
18
+ lines: [{
19
+ productVariant: ["packageSize"]
20
+ // TODO: add packageSizeUnit
21
+ }]
22
+ }]
23
+ },
24
+ product: {
25
+ fields: [{
26
+ variants: ["packageSize"]
27
+ // TODO: add packageSizeUnit
28
+ }]
29
+ },
30
+ briefProducts: {
31
+ fields: [{
32
+ items: [{
33
+ variants: ["packageSize"]
34
+ // TODO: add packageSizeUnit
35
+ }]
36
+ }]
37
+ },
38
+ adjustOrderLine: {
39
+ fields: [{
40
+ fields: [{
41
+ lines: [{
42
+ productVariant: ["packageSize"]
43
+ // TODO: add packageSizeUnit
44
+ }]
45
+ }]
46
+ }]
47
+ },
48
+ addItemToOrder: {
49
+ fields: [{
50
+ fields: [{
51
+ lines: [{
52
+ productVariant: ["packageSize"]
53
+ // TODO: add packageSizeUnit
54
+ }]
55
+ }]
56
+ }]
57
+ }
58
+ });
59
+ export {
60
+ a as VendurePackageSizePlugin
61
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-CzxpJe9c.js"),e=new r.VendurePluginConfig({name:"productPopularity",enableFeatures:{},queryUpdates:{}});e.setQueryUpdates({product:{fields:["popularity"]},search:{fields:[{items:["popularity"]}]},searchField:{fields:[{items:["popularity"]}]}});exports.VendureProductPopularityPlugin=e;
@@ -0,0 +1,24 @@
1
+ import { V as e } from "./index-RBMJ45wv.mjs";
2
+ const r = new e({
3
+ name: "productPopularity",
4
+ enableFeatures: {},
5
+ queryUpdates: {}
6
+ });
7
+ r.setQueryUpdates({
8
+ product: {
9
+ fields: ["popularity"]
10
+ },
11
+ search: {
12
+ fields: [{
13
+ items: ["popularity"]
14
+ }]
15
+ },
16
+ searchField: {
17
+ fields: [{
18
+ items: ["popularity"]
19
+ }]
20
+ }
21
+ });
22
+ export {
23
+ r as VendureProductPopularityPlugin
24
+ };