Browse Source

Merge branch 'master' into minor

Michael Bromley 4 years ago
parent
commit
4aa6f562a4

+ 11 - 0
CHANGELOG.md

@@ -1,3 +1,14 @@
+## <small>1.0.3 (2021-06-18)</small>
+
+
+#### Fixes
+
+* **admin-ui** Handle all ErrorResults when creating a Fulfillment ([75952dd](https://github.com/vendure-ecommerce/vendure/commit/75952dd)), closes [#929](https://github.com/vendure-ecommerce/vendure/issues/929)
+* **core** Correct handling of nested variantNameCollectionFilters ([14b40bb](https://github.com/vendure-ecommerce/vendure/commit/14b40bb)), closes [#927](https://github.com/vendure-ecommerce/vendure/issues/927)
+* **core** Do not return private collections in Shop API ([33f40f2](https://github.com/vendure-ecommerce/vendure/commit/33f40f2)), closes [#928](https://github.com/vendure-ecommerce/vendure/issues/928)
+* **core** Fix Admin/Customer user conflict with external auth ([69f46a3](https://github.com/vendure-ecommerce/vendure/commit/69f46a3)), closes [#926](https://github.com/vendure-ecommerce/vendure/issues/926)
+* **core** Remove "Placeholder" from Permission enum ([eabfe77](https://github.com/vendure-ecommerce/vendure/commit/eabfe77))
+
 ## <small>1.0.2 (2021-06-10)</small>
 
 

+ 54 - 0
docs/content/developer-guide/customizing-models.md

@@ -55,6 +55,60 @@ mutation {
 }
 ```
 
+## TypeScript Typings
+
+Because custom fields are generated at run-time, TypeScript has no way of knowing about them based on your
+VendureConfig. Consider the example above - let's say we have a [plugin]({{< relref "/docs/plugins" >}}) which needs to
+access the custom field values on a Product entity.
+
+Attempting to access the custom field will result in a TS compiler error:
+ 
+```TypeScript {hl_lines=[12,13]}
+import { RequestContext, TransactionalConnection, ID, Product } from '@vendure/core';
+
+export class MyService {
+  constructor(private connection: TransactionalConnection) {} 
+
+  async getInfoUrl(ctx: RequestContext, productId: ID) {
+    const product = await this.connection
+      .getRepository(ctx, Product)
+      .findOne(productId);
+    
+    return product.customFields.infoUrl; 
+  }                           // ^ TS2339: Property 'infoUrl' 
+}                             // does not exist on type 'CustomProductFields'.
+```
+
+The "easy" way to solve this is to assert the `customFields` object as `any`:
+```TypeScript
+return (product.customFields as any).infoUrl; 
+```
+However, this sacrifices type safety. To make our custom fields type-safe we can take advantage of a couple of more advanced TypeScript features - [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces) and  [ambient modules](https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules). This allows us to extend the built-in `CustomProductFields` interface to add our custom fields to it:
+
+```TypeScript
+// types.ts
+
+declare module '@vendure/core' {
+  interface CustomProductFields {
+    infoUrl: string;
+    downloadable: boolean;
+    shortName: string;
+  }
+}
+```
+
+When this file is then imported into our service file (either directly or indirectly), TypeScript will know about our custom fields, and we do not need to do any type assertions.
+
+```TypeScript
+return product.customFields.infoUrl; 
+// no error, plus TS autocomplete works.
+```
+
+{{< alert "primary" >}}
+For a working example of this setup, see the [real-world-vendure repo](https://github.com/vendure-ecommerce/real-world-vendure/blob/master/src/plugins/reviews/types.ts)
+{{< /alert >}}
+
+
 ## Examples
 
 ### defaultValue & nullable

+ 11 - 0
docs/content/plugins/extending-the-admin-ui/_index.md

@@ -89,3 +89,14 @@ plugins: [
   }),
 ],
 ```
+
+{{< alert warning >}}
+**Note:** the TypeScript source files of your UI extensions **must not** be compiled by your regular TypeScript build task. This is because they will instead be compiled by the Angular compiler when you run `compileUiExtensions()`. You can exclude them in your main `tsconfig.json` by adding a line to the "exclude" array:
+```json
+{
+  "exclude": [
+    "src/plugins/**/ui/*"
+  ]
+}
+```
+{{< /alert >}}

+ 12 - 0
docs/content/plugins/extending-the-admin-ui/using-angular/_index.md

@@ -118,6 +118,18 @@ Now go to the Admin UI app in your browser and log in. You should now be able to
 
 {{< figure src="./ui-extensions-greeter.jpg" >}}
 
+{{< alert warning >}}
+**Note:** the TypeScript source files of your UI extensions **must not** be compiled by your regular TypeScript build task. This is because they will instead be compiled by the Angular compiler when you run `compileUiExtensions()`. You can exclude them in your main `tsconfig.json` by adding a line to the "exclude" array:
+```json
+{
+  "exclude": [
+    "src/plugins/**/ui/*"
+  ]
+}
+```
+{{< /alert >}}
+
+
 ## Next Steps
 
 Now you have created your new route, you need a way for your admin to access it. See [Adding Navigation Items]({{< relref "../adding-navigation-items" >}})

+ 2 - 2
docs/data/build.json

@@ -1,4 +1,4 @@
 {
-  "version": "1.0.0-rc.0",
-  "commit": "1fb3620ce"
+  "version": "1.0.2",
+  "commit": "19e4faa4b"
 }

+ 1 - 1
lerna.json

@@ -2,7 +2,7 @@
   "packages": [
     "packages/*"
   ],
-  "version": "1.0.2",
+  "version": "1.0.3",
   "npmClient": "yarn",
   "useWorkspaces": true,
   "command": {

+ 3 - 3
packages/admin-ui-plugin/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/admin-ui-plugin",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "main": "lib/index.js",
   "types": "lib/index.d.ts",
   "files": [
@@ -19,8 +19,8 @@
   "devDependencies": {
     "@types/express": "^4.17.8",
     "@types/fs-extra": "^9.0.1",
-    "@vendure/common": "^1.0.2",
-    "@vendure/core": "^1.0.2",
+    "@vendure/common": "^1.0.3",
+    "@vendure/core": "^1.0.3",
     "express": "^4.17.1",
     "rimraf": "^3.0.2",
     "typescript": "4.1.5"

+ 2 - 2
packages/admin-ui/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/admin-ui",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "license": "MIT",
   "scripts": {
     "ng": "ng",
@@ -37,7 +37,7 @@
     "@ng-select/ng-select": "^6.1.0",
     "@ngx-translate/core": "^13.0.0",
     "@ngx-translate/http-loader": "^6.0.0",
-    "@vendure/common": "^1.0.2",
+    "@vendure/common": "^1.0.3",
     "@webcomponents/custom-elements": "^1.4.3",
     "apollo-angular": "^2.4.0",
     "apollo-upload-client": "^14.1.3",

+ 1 - 1
packages/admin-ui/src/lib/core/src/common/version.ts

@@ -1,2 +1,2 @@
 // Auto-generated by the set-version.js script.
-export const ADMIN_UI_VERSION = '1.0.2';
+export const ADMIN_UI_VERSION = '1.0.3';

+ 3 - 3
packages/asset-server-plugin/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/asset-server-plugin",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "main": "lib/index.js",
   "types": "lib/index.d.ts",
   "files": [
@@ -22,8 +22,8 @@
     "@types/fs-extra": "^9.0.8",
     "@types/node-fetch": "^2.5.8",
     "@types/sharp": "^0.27.1",
-    "@vendure/common": "^1.0.2",
-    "@vendure/core": "^1.0.2",
+    "@vendure/common": "^1.0.3",
+    "@vendure/core": "^1.0.3",
     "aws-sdk": "^2.856.0",
     "express": "^4.17.1",
     "node-fetch": "^2.6.1",

+ 1 - 1
packages/common/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/common",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "main": "index.js",
   "license": "MIT",
   "scripts": {

+ 2 - 2
packages/core/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/core",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "description": "A modern, headless ecommerce framework",
   "repository": {
     "type": "git",
@@ -47,7 +47,7 @@
     "@nestjs/testing": "7.6.17",
     "@nestjs/typeorm": "7.1.5",
     "@types/fs-extra": "^9.0.1",
-    "@vendure/common": "^1.0.2",
+    "@vendure/common": "^1.0.3",
     "apollo-server-express": "2.24.1",
     "bcrypt": "^5.0.0",
     "body-parser": "^1.19.0",

+ 37 - 0
packages/core/src/event-bus/event-bus.ts

@@ -12,6 +12,43 @@ import { VendureEvent } from './vendure-event';
  * @description
  * The EventBus is used to globally publish events which can then be subscribed to.
  *
+ * Events are published whenever certain actions take place within the Vendure server, for example:
+ *
+ * * when a Product is updated ({@link ProductEvent})
+ * * when an Order transitions state ({@link OrderStateTransitionEvent})
+ * * when a Customer registers a new account ({@link AccountRegistrationEvent})
+ *
+ * Using the EventBus it is possible to subscribe to an take action when these events occur.
+ * This is done with the `.ofType()` method, which takes an event type and returns an rxjs observable
+ * stream of events:
+ *
+ * @example
+ * ```TypeScript
+ * import { OnApplicationBootstrap } from '\@nestjs/common';
+ * import { EventBus, PluginCommonModule, VendurePlugin } from '\@vendure/core';
+ * import { filter } from 'rxjs/operators';
+ *
+ * \@VendurePlugin({
+ *     imports: [PluginCommonModule]
+ * })
+ * export class MyPlugin implements OnApplicationBootstrap {
+ *
+ *   constructor(private eventBus: EventBus) {}
+ *
+ *   async onApplicationBootstrap() {
+ *
+ *     this.eventBus
+ *       .ofType(OrderStateTransitionEvent)
+ *       .pipe(
+ *         filter(event => event.toState === 'PaymentSettled'),
+ *       )
+ *       .subscribe((event) => {
+ *         // do some action when this event fires
+ *       });
+ *   }
+ * }
+ * ```
+ *
  * @docsCategory events
  * */
 @Injectable()

+ 3 - 3
packages/create/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/create",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "license": "MIT",
   "bin": {
     "create": "./index.js"
@@ -26,13 +26,13 @@
     "@types/handlebars": "^4.1.0",
     "@types/listr": "^0.14.2",
     "@types/semver": "^6.2.2",
-    "@vendure/core": "^1.0.2",
+    "@vendure/core": "^1.0.3",
     "rimraf": "^3.0.2",
     "ts-node": "^9.0.0",
     "typescript": "4.1.5"
   },
   "dependencies": {
-    "@vendure/common": "^1.0.2",
+    "@vendure/common": "^1.0.3",
     "chalk": "^4.1.0",
     "commander": "^7.1.0",
     "cross-spawn": "^7.0.3",

+ 9 - 9
packages/dev-server/package.json

@@ -1,6 +1,6 @@
 {
   "name": "dev-server",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "main": "index.js",
   "license": "MIT",
   "private": true,
@@ -14,18 +14,18 @@
     "load-test:100k": "node -r ts-node/register load-testing/run-load-test.ts 100000"
   },
   "dependencies": {
-    "@vendure/admin-ui-plugin": "^1.0.2",
-    "@vendure/asset-server-plugin": "^1.0.2",
-    "@vendure/common": "^1.0.2",
-    "@vendure/core": "^1.0.2",
-    "@vendure/elasticsearch-plugin": "^1.0.2",
-    "@vendure/email-plugin": "^1.0.2",
+    "@vendure/admin-ui-plugin": "^1.0.3",
+    "@vendure/asset-server-plugin": "^1.0.3",
+    "@vendure/common": "^1.0.3",
+    "@vendure/core": "^1.0.3",
+    "@vendure/elasticsearch-plugin": "^1.0.3",
+    "@vendure/email-plugin": "^1.0.3",
     "typescript": "4.1.5"
   },
   "devDependencies": {
     "@types/csv-stringify": "^3.1.0",
-    "@vendure/testing": "^1.0.2",
-    "@vendure/ui-devkit": "^1.0.2",
+    "@vendure/testing": "^1.0.3",
+    "@vendure/ui-devkit": "^1.0.3",
     "concurrently": "^5.0.0",
     "csv-stringify": "^5.3.3"
   }

+ 3 - 3
packages/elasticsearch-plugin/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/elasticsearch-plugin",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "license": "MIT",
   "main": "lib/index.js",
   "types": "lib/index.d.ts",
@@ -22,8 +22,8 @@
     "deepmerge": "^4.2.2"
   },
   "devDependencies": {
-    "@vendure/common": "^1.0.2",
-    "@vendure/core": "^1.0.2",
+    "@vendure/common": "^1.0.3",
+    "@vendure/core": "^1.0.3",
     "rimraf": "^3.0.2",
     "typescript": "4.1.5"
   }

+ 3 - 3
packages/email-plugin/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/email-plugin",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "license": "MIT",
   "main": "lib/index.js",
   "types": "lib/index.d.ts",
@@ -33,8 +33,8 @@
     "@types/fs-extra": "^9.0.1",
     "@types/handlebars": "^4.1.0",
     "@types/mjml": "^4.0.4",
-    "@vendure/common": "^1.0.2",
-    "@vendure/core": "^1.0.2",
+    "@vendure/common": "^1.0.3",
+    "@vendure/core": "^1.0.3",
     "rimraf": "^3.0.2",
     "typescript": "4.1.5"
   }

+ 3 - 3
packages/job-queue-plugin/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/job-queue-plugin",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "license": "MIT",
   "main": "lib/index.js",
   "types": "lib/index.d.ts",
@@ -21,8 +21,8 @@
   "devDependencies": {
     "@google-cloud/pubsub": "^2.8.0",
     "@types/redis": "^2.8.28",
-    "@vendure/common": "^1.0.2",
-    "@vendure/core": "^1.0.2",
+    "@vendure/common": "^1.0.3",
+    "@vendure/core": "^1.0.3",
     "redis": "^3.0.2",
     "rimraf": "^3.0.2",
     "typescript": "4.1.5"

+ 3 - 3
packages/testing/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/testing",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "description": "End-to-end testing tools for Vendure projects",
   "keywords": [
     "vendure",
@@ -33,7 +33,7 @@
   },
   "dependencies": {
     "@types/node-fetch": "^2.5.4",
-    "@vendure/common": "^1.0.2",
+    "@vendure/common": "^1.0.3",
     "faker": "^4.1.0",
     "form-data": "^3.0.0",
     "graphql": "15.5.0",
@@ -44,7 +44,7 @@
   "devDependencies": {
     "@types/mysql": "^2.15.15",
     "@types/pg": "^7.14.5",
-    "@vendure/core": "^1.0.2",
+    "@vendure/core": "^1.0.3",
     "mysql": "^2.18.1",
     "pg": "^8.4.0",
     "rimraf": "^3.0.0",

+ 4 - 4
packages/ui-devkit/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@vendure/ui-devkit",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "description": "A library for authoring Vendure Admin UI extensions",
   "keywords": [
     "vendure",
@@ -39,8 +39,8 @@
     "@angular/cli": "11.2.4",
     "@angular/compiler": "11.2.5",
     "@angular/compiler-cli": "11.2.5",
-    "@vendure/admin-ui": "^1.0.2",
-    "@vendure/common": "^1.0.2",
+    "@vendure/admin-ui": "^1.0.3",
+    "@vendure/common": "^1.0.3",
     "chalk": "^4.1.0",
     "chokidar": "^3.5.1",
     "fs-extra": "^9.1.0",
@@ -51,7 +51,7 @@
     "@rollup/plugin-node-resolve": "^11.2.0",
     "@types/fs-extra": "^9.0.8",
     "@types/glob": "^7.1.3",
-    "@vendure/core": "^1.0.2",
+    "@vendure/core": "^1.0.3",
     "rimraf": "^3.0.2",
     "rollup": "^2.40.0",
     "rollup-plugin-terser": "^7.0.2",