diff --git a/.changeset/gentle-lies-provide.md b/.changeset/gentle-lies-provide.md deleted file mode 100644 index 432336003d..0000000000 --- a/.changeset/gentle-lies-provide.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -"@vue-storefront/middleware": minor ---- - -[ADDED] Added factory function for the extension API. Previously the extension API was an object with a set of methods. Now it can be created using a factory function the same way as the base API. - -Previously only object was allowed: - -```ts -export const extension: ApiClientExtension = { - name: "extension", - extendApiMethods: { - ...extendedMethods, //methods as an object - }, -}; -``` - -Now you can either use an object or a factory function: - -```ts -export const extension: ApiClientExtension = { - name: "extension", - // methods as a factory function with injected config object - extendApiMethods: ({ config }) => { - return createMyMethods(config); - }, -}; -``` diff --git a/docs/content/3.middleware/3.api/middleware.api.json b/docs/content/3.middleware/3.api/middleware.api.json index a9aa53256f..181d1d05b7 100644 --- a/docs/content/3.middleware/3.api/middleware.api.json +++ b/docs/content/3.middleware/3.api/middleware.api.json @@ -701,6 +701,14 @@ "kind": "Content", "text": "any" }, + { + "kind": "Content", + "text": ", CONFIG = " + }, + { + "kind": "Content", + "text": "any" + }, { "kind": "Content", "text": "> " @@ -730,6 +738,17 @@ "startIndex": 3, "endIndex": 4 } + }, + { + "typeParameterName": "CONFIG", + "constraintTokenRange": { + "startIndex": 0, + "endIndex": 0 + }, + "defaultTypeTokenRange": { + "startIndex": 5, + "endIndex": 6 + } } ], "name": "ApiClientExtension", @@ -751,7 +770,25 @@ }, { "kind": "Content", - "text": "" + "text": " | " + }, + { + "kind": "Reference", + "text": "ApiMethodsFactory", + "canonicalReference": "@vue-storefront/middleware!ApiMethodsFactory:type" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "ExtendApiMethod", + "canonicalReference": "@vue-storefront/middleware!ExtendApiMethod:type" + }, + { + "kind": "Content", + "text": ", CONFIG>" }, { "kind": "Content", @@ -764,7 +801,7 @@ "name": "extendApiMethods", "propertyTypeTokenRange": { "startIndex": 1, - "endIndex": 3 + "endIndex": 7 } }, { @@ -2214,7 +2251,7 @@ }, { "kind": "Content", - "text": "(configuration: CONFIG) => API" + "text": "(configuration: {\n config: CONFIG;\n}) => API" }, { "kind": "Content", diff --git a/docs/content/3.middleware/4.reference/change-log.md b/docs/content/3.middleware/4.reference/change-log.md index 73c9ee4f6a..2dc43ce134 100644 --- a/docs/content/3.middleware/4.reference/change-log.md +++ b/docs/content/3.middleware/4.reference/change-log.md @@ -1,5 +1,34 @@ # Change log +## 4.3.0 + +### Minor Changes + +- **[ADDED]** Added factory function for the extension API. Previously the extension API was an object with a set of methods. Now it can be created using a factory function the same way as the base API. + +Previously only object was allowed: + +```ts +export const extension: ApiClientExtension = { + name: "extension", + extendApiMethods: { + ...extendedMethods, //methods as an object + }, +}; +``` + +Now you can either use an object or a factory function: + +```ts +export const extension: ApiClientExtension = { + name: "extension", + // methods as a factory function with injected config object + extendApiMethods: ({ config }) => { + return createMyMethods(config); + }, +}; +``` + ## 4.2.0 ### Minor Changes diff --git a/packages/middleware/CHANGELOG.md b/packages/middleware/CHANGELOG.md index 73c9ee4f6a..2dc43ce134 100644 --- a/packages/middleware/CHANGELOG.md +++ b/packages/middleware/CHANGELOG.md @@ -1,5 +1,34 @@ # Change log +## 4.3.0 + +### Minor Changes + +- **[ADDED]** Added factory function for the extension API. Previously the extension API was an object with a set of methods. Now it can be created using a factory function the same way as the base API. + +Previously only object was allowed: + +```ts +export const extension: ApiClientExtension = { + name: "extension", + extendApiMethods: { + ...extendedMethods, //methods as an object + }, +}; +``` + +Now you can either use an object or a factory function: + +```ts +export const extension: ApiClientExtension = { + name: "extension", + // methods as a factory function with injected config object + extendApiMethods: ({ config }) => { + return createMyMethods(config); + }, +}; +``` + ## 4.2.0 ### Minor Changes diff --git a/packages/middleware/package.json b/packages/middleware/package.json index 2634c3fccc..73afc2eb5b 100644 --- a/packages/middleware/package.json +++ b/packages/middleware/package.json @@ -1,6 +1,6 @@ { "name": "@vue-storefront/middleware", - "version": "4.2.0", + "version": "4.3.0", "main": "lib/index.cjs.js", "module": "lib/index.es.js", "types": "lib/index.d.ts",