Skip to content

Commit

Permalink
feat(core): Add means to selectively ignore plugin compatibility errors
Browse files Browse the repository at this point in the history
Closes #2958
  • Loading branch information
michaelbromley authored Nov 27, 2024
1 parent dde738d commit e362475
Show file tree
Hide file tree
Showing 22 changed files with 303 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ interface AssetServerOptions {
imageTransformStrategy?: ImageTransformStrategy | ImageTransformStrategy[];
namingStrategy?: AssetNamingStrategy;
previewStrategy?: AssetPreviewStrategy;
storageStrategyFactory?: (
options: AssetServerOptions,
storageStrategyFactory?: (
options: AssetServerOptions,
) => AssetStorageStrategy | Promise<AssetStorageStrategy>;
cacheHeader?: CacheConfig | string;
}
Expand All @@ -49,12 +49,12 @@ The local directory to which assets will be uploaded when using the <a href='/re

<MemberInfo kind="property" type={`string | ((ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, identifier: string) =&#62; string)`} />

The complete URL prefix of the asset files. For example, "https://demo.vendure.io/assets/". A
function can also be provided to handle more complex cases, such as serving multiple domains
from a single server. In this case, the function should return a string url prefix.

If not provided, the plugin will attempt to guess based off the incoming
request and the configured route. However, in all but the simplest cases,
The complete URL prefix of the asset files. For example, "https://demo.vendure.io/assets/". A
function can also be provided to handle more complex cases, such as serving multiple domains
from a single server. In this case, the function should return a string url prefix.

If not provided, the plugin will attempt to guess based off the incoming
request and the configured route. However, in all but the simplest cases,
this guess may not yield correct results.
### previewMaxWidth

Expand All @@ -75,12 +75,12 @@ An array of additional <a href='/reference/core-plugins/asset-server-plugin/imag

<MemberInfo kind="property" type={`<a href='/reference/core-plugins/asset-server-plugin/image-transform-strategy#imagetransformstrategy'>ImageTransformStrategy</a> | <a href='/reference/core-plugins/asset-server-plugin/image-transform-strategy#imagetransformstrategy'>ImageTransformStrategy</a>[]`} default={`[]`} since="3.1.0" />

The strategy or strategies to use to determine the parameters for transforming an image.
This can be used to implement custom image transformation logic, for example to
limit transform parameters to a known set of presets.

If multiple strategies are provided, they will be executed in the order in which they are defined.
If a strategy throws an error, the image transformation will be aborted and the error
The strategy or strategies to use to determine the parameters for transforming an image.
This can be used to implement custom image transformation logic, for example to
limit transform parameters to a known set of presets.

If multiple strategies are provided, they will be executed in the order in which they are defined.
If a strategy throws an error, the image transformation will be aborted and the error
will be logged, with an HTTP 400 response sent to the client.
### namingStrategy

Expand All @@ -91,19 +91,19 @@ Defines how asset files and preview images are named before being saved.

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/assets/asset-preview-strategy#assetpreviewstrategy'>AssetPreviewStrategy</a>`} since="1.7.0" />

Defines how previews are generated for a given Asset binary. By default, this uses
Defines how previews are generated for a given Asset binary. By default, this uses
the <a href='/reference/core-plugins/asset-server-plugin/sharp-asset-preview-strategy#sharpassetpreviewstrategy'>SharpAssetPreviewStrategy</a>
### storageStrategyFactory

<MemberInfo kind="property" type={`( options: <a href='/reference/core-plugins/asset-server-plugin/asset-server-options#assetserveroptions'>AssetServerOptions</a>, ) =&#62; <a href='/reference/typescript-api/assets/asset-storage-strategy#assetstoragestrategy'>AssetStorageStrategy</a> | Promise&#60;<a href='/reference/typescript-api/assets/asset-storage-strategy#assetstoragestrategy'>AssetStorageStrategy</a>&#62;`} default={`() =&#62; <a href='/reference/core-plugins/asset-server-plugin/local-asset-storage-strategy#localassetstoragestrategy'>LocalAssetStorageStrategy</a>`} />
<MemberInfo kind="property" type={`( options: <a href='/reference/core-plugins/asset-server-plugin/asset-server-options#assetserveroptions'>AssetServerOptions</a>, ) =&#62; <a href='/reference/typescript-api/assets/asset-storage-strategy#assetstoragestrategy'>AssetStorageStrategy</a> | Promise&#60;<a href='/reference/typescript-api/assets/asset-storage-strategy#assetstoragestrategy'>AssetStorageStrategy</a>&#62;`} default={`() =&#62; <a href='/reference/core-plugins/asset-server-plugin/local-asset-storage-strategy#localassetstoragestrategy'>LocalAssetStorageStrategy</a>`} />

A function which can be used to configure an <a href='/reference/typescript-api/assets/asset-storage-strategy#assetstoragestrategy'>AssetStorageStrategy</a>. This is useful e.g. if you wish to store your assets
A function which can be used to configure an <a href='/reference/typescript-api/assets/asset-storage-strategy#assetstoragestrategy'>AssetStorageStrategy</a>. This is useful e.g. if you wish to store your assets
using a cloud storage provider. By default, the <a href='/reference/core-plugins/asset-server-plugin/local-asset-storage-strategy#localassetstoragestrategy'>LocalAssetStorageStrategy</a> is used.
### cacheHeader

<MemberInfo kind="property" type={`<a href='/reference/core-plugins/asset-server-plugin/cache-config#cacheconfig'>CacheConfig</a> | string`} default={`'public, max-age=15552000'`} since="1.9.3" />

Configures the `Cache-Control` directive for response to control caching in browsers and shared caches (e.g. Proxies, CDNs).
Configures the `Cache-Control` directive for response to control caching in browsers and shared caches (e.g. Proxies, CDNs).
Defaults to publicly cached for 6 months.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ Using type `any` in order to avoid the need to include `aws-sdk` dependency in g

<GenerationInfo sourceFile="packages/asset-server-plugin/src/config/s3-asset-storage-strategy.ts" sourceLine="119" packageName="@vendure/asset-server-plugin" />

Returns a configured instance of the <a href='/reference/core-plugins/asset-server-plugin/s3asset-storage-strategy#s3assetstoragestrategy'>S3AssetStorageStrategy</a> which can then be passed to the <a href='/reference/core-plugins/asset-server-plugin/asset-server-options#assetserveroptions'>AssetServerOptions</a>`storageStrategyFactory` property.
Returns a configured instance of the <a href='/reference/core-plugins/asset-server-plugin/s3asset-storage-strategy#s3assetstoragestrategy'>S3AssetStorageStrategy</a> which can then be passed to the <a href='/reference/core-plugins/asset-server-plugin/asset-server-options#assetserveroptions'>AssetServerOptions</a>
`storageStrategyFactory` property.

Before using this strategy, make sure you have the `@aws-sdk/client-s3` and `@aws-sdk/lib-storage` package installed:

Expand Down
36 changes: 36 additions & 0 deletions docs/docs/reference/graphql-api/admin/object-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">orderLine: <a href="/reference/graphql-api/admin/object-types#orderline">OrderLine</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -356,6 +358,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">orderLine: <a href="/reference/graphql-api/admin/object-types#orderline">OrderLine</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -847,10 +851,14 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">GlobalSettings: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">HistoryEntry: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">Order: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">OrderLine: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">Payment: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">PaymentMethod: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">Product: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>
Expand All @@ -865,14 +873,24 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">Promotion: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">Refund: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">Region: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">Seller: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">Session: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">ShippingLine: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">ShippingMethod: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">StockLevel: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">StockLocation: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">StockMovement: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">TaxCategory: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>

<div class="graphql-code-line ">TaxRate: [<a href="/reference/graphql-api/admin/object-types#customfieldconfig">CustomFieldConfig</a>!]!</div>
Expand Down Expand Up @@ -1516,6 +1534,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">data: <a href="/reference/graphql-api/admin/object-types#json">JSON</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -2593,6 +2613,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">metadata: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -3226,6 +3248,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">metadata: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -3393,6 +3417,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">quantity: <a href="/reference/graphql-api/admin/object-types#int">Int</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -3434,6 +3460,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">quantity: <a href="/reference/graphql-api/admin/object-types#int">Int</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -3488,6 +3516,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">quantity: <a href="/reference/graphql-api/admin/object-types#int">Int</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -3713,6 +3743,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">discounts: [<a href="/reference/graphql-api/admin/object-types#discount">Discount</a>!]!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -3837,6 +3869,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">quantity: <a href="/reference/graphql-api/admin/object-types#int">Int</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand All @@ -3859,6 +3893,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">stockLocation: <a href="/reference/graphql-api/admin/object-types#stocklocation">StockLocation</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/admin/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions docs/docs/reference/graphql-api/shop/object-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">data: <a href="/reference/graphql-api/shop/object-types#json">JSON</a>!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/shop/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -1942,6 +1944,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">metadata: <a href="/reference/graphql-api/shop/object-types#json">JSON</a></div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/shop/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -2470,6 +2474,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">metadata: <a href="/reference/graphql-api/shop/object-types#json">JSON</a></div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/shop/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down Expand Up @@ -2757,6 +2763,8 @@ import MemberDescription from '@site/src/components/MemberDescription';

<div class="graphql-code-line ">discounts: [<a href="/reference/graphql-api/shop/object-types#discount">Discount</a>!]!</div>

<div class="graphql-code-line ">customFields: <a href="/reference/graphql-api/shop/object-types#json">JSON</a></div>


<div class="graphql-code-line top-level">&#125;</div>
</div>
Expand Down
48 changes: 46 additions & 2 deletions docs/docs/reference/typescript-api/common/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## bootstrap

<GenerationInfo sourceFile="packages/core/src/bootstrap.ts" sourceLine="106" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/bootstrap.ts" sourceLine="159" packageName="@vendure/core" />

Bootstraps the Vendure server. This is the entry point to the application.

Expand Down Expand Up @@ -49,6 +49,27 @@ bootstrap(config, {
});
```

### Ignoring compatibility errors for plugins

Since v3.1.0, you can ignore compatibility errors for specific plugins by passing the `ignoreCompatibilityErrorsForPlugins` option.

This should be used with caution, only if you are sure that the plugin will still work as expected with the current version of Vendure.

*Example*

```ts
import { bootstrap } from '@vendure/core';
import { config } from './vendure-config';
import { MyPlugin } from './plugins/my-plugin';

bootstrap(config, {
// Let's say that `MyPlugin` is not yet compatible with the current version of Vendure
// but we know that it will still work as expected, and we are not able to publish
// a new version of the plugin right now.
ignoreCompatibilityErrorsForPlugins: [MyPlugin],
});
```

```ts title="Signature"
function bootstrap(userConfig: Partial<VendureConfig>, options?: BootstrapOptions): Promise<INestApplication>
```
Expand All @@ -73,7 +94,8 @@ Vendure server.

```ts title="Signature"
interface BootstrapOptions {
nestApplicationOptions: NestApplicationOptions;
nestApplicationOptions?: NestApplicationOptions;
ignoreCompatibilityErrorsForPlugins?: Array<DynamicModule | Type<any>>;
}
```

Expand All @@ -84,6 +106,28 @@ interface BootstrapOptions {
<MemberInfo kind="property" type={`NestApplicationOptions`} />

These options get passed directly to the `NestFactory.create()` method.
### ignoreCompatibilityErrorsForPlugins

<MemberInfo kind="property" type={`Array&#60;DynamicModule | Type&#60;any&#62;&#62;`} default={`[]`} since="3.1.0" />

By default, if a plugin specifies a compatibility range which does not include the current
Vendure version, the bootstrap process will fail. This option allows you to ignore compatibility
errors for specific plugins.

This setting should be used with caution, only if you are sure that the plugin will still
work as expected with the current version of Vendure.

*Example*

```ts
import { bootstrap } from '@vendure/core';
import { config } from './vendure-config';
import { MyPlugin } from './plugins/my-plugin';
bootstrap(config, {
ignoreCompatibilityErrorsForPlugins: [MyPlugin],
});
```


</div>
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/common/currency-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## CurrencyCode

<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="992" packageName="@vendure/common" />
<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="994" packageName="@vendure/common" />

ISO 4217 currency code

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/common/job-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## JobState

<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2228" packageName="@vendure/common" />
<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2238" packageName="@vendure/common" />

The state of a Job in the JobQueue

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/common/language-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## LanguageCode

<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2246" packageName="@vendure/common" />
<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2256" packageName="@vendure/common" />

Languages in the form of a ISO 639-1 language code with optional
region or script modifier (e.g. de_AT). The selection available is based
Expand Down
Loading

0 comments on commit e362475

Please sign in to comment.