-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/order-client-loading-states
- Loading branch information
Showing
21 changed files
with
363 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
// TODO set correct version number + date and the changes you've made connected to the PR. See this example for the correct format: https://github.com/Pinelab-studio/pinelab-vendure-plugins/blob/main/packages/vendure-plugin-invoices/CHANGELOG.md | ||
# 1.1.2 (2023-09-26) | ||
|
||
- Added `onJobFailure` option to inspect errors from failed jobs([#262](https://github.com/Pinelab-studio/pinelab-vendure-plugins/pull/262)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pinelab/vendure-plugin-google-cloud-tasks", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Vendure plugin for using worker jobs with Google Cloud Tasks", | ||
"author": "Martijn van de Brug <[email protected]>", | ||
"homepage": "https://pinelab-plugins.com/", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 1.0.0 (2023-09-18) | ||
|
||
- Initial setup([#258](https://github.com/Pinelab-studio/pinelab-vendure-plugins/pull/258)) | ||
|
||
# 1.0.1 (2023-09-22) | ||
|
||
- Added index barrel file to export plugin ([#261](https://github.com/Pinelab-studio/pinelab-vendure-plugins/pull/261)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Vendure Primary Collection Plugin | ||
|
||
![Vendure version](https://img.shields.io/badge/dynamic/json.svg?url=https%3A%2F%2Fraw.githubusercontent.com%2FPinelab-studio%2Fpinelab-vendure-plugins%2Fmain%2Fpackage.json&query=$.devDependencies[%27@vendure/core%27]&colorB=blue&label=Built%20on%20Vendure) | ||
|
||
To construct breadcrumbs and URL's it's useful to have a primary collection for each product, in case a product is part of multiple collections. This plugin extends Vendure's `Product` graphql type adding a `primaryCollection` field which points to the primary collection of a product, which is the the highest placed collection in Vendure (Collection's are sortable in Vendure, and it's a good practice to sort by importance). | ||
|
||
## Getting started | ||
|
||
Add the plugin to your `vendure-config.ts`: | ||
|
||
```ts | ||
plugins: [PrimaryCollectionPlugin]; | ||
``` | ||
|
||
And your good to go with just that. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@pinelab/vendure-plugin-primary-collection", | ||
"version": "1.0.1", | ||
"description": "Adds a primary collection to all Products by extending vendure's graphql api", | ||
"author": "Surafel Melese Tariku <[email protected]>", | ||
"homepage": "https://pinelab-plugins.com/", | ||
"repository": "https://github.com/Pinelab-studio/pinelab-vendure-plugins", | ||
"license": "MIT", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"README.md", | ||
"CHANGELOG.md" | ||
], | ||
"scripts": { | ||
"start": "yarn ts-node test/dev-server.ts", | ||
"build": "rimraf dist && tsc", | ||
"test": "vitest run" | ||
}, | ||
"gitHead": "476f36da3aafea41fbf21c70774a30306f1d238f" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './primary-collection-plugin'; |
17 changes: 17 additions & 0 deletions
17
packages/vendure-plugin-primary-collection/src/primary-collection-plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { PluginCommonModule, Type, VendurePlugin } from '@vendure/core'; | ||
import { gql } from 'graphql-tag'; | ||
import { PrimaryCollectionResolver } from './primary-collection.resolver'; | ||
|
||
@VendurePlugin({ | ||
imports: [PluginCommonModule], | ||
shopApiExtensions: { | ||
schema: gql` | ||
extend type Product { | ||
primaryCollection: Collection | ||
} | ||
`, | ||
resolvers: [PrimaryCollectionResolver], | ||
}, | ||
compatibility: '^2.0.0', | ||
}) | ||
export class PrimaryCollectionPlugin {} |
37 changes: 37 additions & 0 deletions
37
packages/vendure-plugin-primary-collection/src/primary-collection.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Parent, ResolveField, Resolver } from '@nestjs/graphql'; | ||
import { | ||
Collection, | ||
CollectionService, | ||
Ctx, | ||
RequestContext, | ||
Product, | ||
} from '@vendure/core'; | ||
|
||
@Resolver('Product') | ||
export class PrimaryCollectionResolver { | ||
constructor(private readonly collectionService: CollectionService) {} | ||
|
||
@ResolveField() | ||
async primaryCollection( | ||
@Ctx() ctx: RequestContext, | ||
@Parent() product: Product | ||
): Promise<Collection | null> { | ||
const collections = await this.collectionService.getCollectionsByProductId( | ||
ctx, | ||
product.id, | ||
true | ||
); | ||
const collectionsExcludingParents = collections.filter( | ||
(coll) => !collections.find((childColl) => childColl.parentId === coll.id) | ||
); | ||
return collectionsExcludingParents.reduce<Collection | null>((acc, val) => { | ||
if (!acc) { | ||
return val; | ||
} | ||
if (val.position < acc.position) { | ||
return val; | ||
} | ||
return acc; | ||
}, null); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/vendure-plugin-primary-collection/test/dev-server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { AdminUiPlugin } from '@vendure/admin-ui-plugin'; | ||
import { | ||
DefaultLogger, | ||
DefaultSearchPlugin, | ||
LogLevel, | ||
mergeConfig, | ||
} from '@vendure/core'; | ||
import { | ||
createTestEnvironment, | ||
registerInitializer, | ||
SqljsInitializer, | ||
testConfig, | ||
} from '@vendure/testing'; | ||
import { initialTestData } from './initial-test-data'; | ||
import { PrimaryCollectionPlugin } from '../src/primary-collection-plugin'; | ||
|
||
require('dotenv').config(); | ||
|
||
(async () => { | ||
registerInitializer('sqljs', new SqljsInitializer('__data__')); | ||
const devConfig = mergeConfig(testConfig, { | ||
logger: new DefaultLogger({ level: LogLevel.Debug }), | ||
plugins: [ | ||
PrimaryCollectionPlugin, | ||
DefaultSearchPlugin, | ||
AdminUiPlugin.init({ | ||
port: 3002, | ||
route: 'admin', | ||
}), | ||
], | ||
apiOptions: { | ||
shopApiPlayground: true, | ||
adminApiPlayground: true, | ||
}, | ||
}); | ||
const { server, adminClient, shopClient } = createTestEnvironment(devConfig); | ||
await server.init({ | ||
initialData: initialTestData, | ||
productsCsvPath: './test/products.csv', | ||
}); | ||
})(); |
56 changes: 56 additions & 0 deletions
56
packages/vendure-plugin-primary-collection/test/initial-test-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { LanguageCode } from '@vendure/common/lib/generated-types'; | ||
import { InitialData } from '@vendure/core'; | ||
|
||
export const initialTestData: InitialData = { | ||
defaultLanguage: LanguageCode.en, | ||
defaultZone: 'Europe', | ||
taxRates: [ | ||
{ name: 'Standard Tax', percentage: 20 }, | ||
{ name: 'Reduced Tax', percentage: 10 }, | ||
{ name: 'Zero Tax', percentage: 0 }, | ||
], | ||
shippingMethods: [ | ||
{ name: 'Standard Shipping', price: 500 }, | ||
{ name: 'Express Shipping', price: 1000 }, | ||
], | ||
countries: [ | ||
{ name: 'Australia', code: 'AU', zone: 'Oceania' }, | ||
{ name: 'Austria', code: 'AT', zone: 'Europe' }, | ||
{ name: 'Canada', code: 'CA', zone: 'Americas' }, | ||
{ name: 'China', code: 'CN', zone: 'Asia' }, | ||
{ name: 'South Africa', code: 'ZA', zone: 'Africa' }, | ||
{ name: 'United Kingdom', code: 'GB', zone: 'Europe' }, | ||
{ name: 'United States of America', code: 'US', zone: 'Americas' }, | ||
{ name: 'Nederland', code: 'NL', zone: 'Europe' }, | ||
], | ||
collections: [ | ||
{ | ||
name: 'Computers', | ||
filters: [ | ||
{ | ||
code: 'facet-value-filter', | ||
args: { facetValueNames: ['computers'], containsAny: false }, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'Electronics', | ||
filters: [ | ||
{ | ||
code: 'facet-value-filter', | ||
args: { facetValueNames: ['electronics'], containsAny: false }, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'Others', | ||
filters: [ | ||
{ | ||
code: 'facet-value-filter', | ||
args: { facetValueNames: ['others'], containsAny: false }, | ||
}, | ||
], | ||
}, | ||
], | ||
paymentMethods: [], | ||
}; |
Oops, something went wrong.