From 803e4aad02933ad10e416861d54d17b75dfb9560 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 13 May 2024 18:54:59 +0300 Subject: [PATCH] docs: added file module docs (#7278) --- .../architectural-modules/page.mdx | 4 +- .../cache-module/page.mdx | 14 +- .../event-module/page.mdx | 14 +- .../file-module/page.mdx | 35 + .../book/app/architectural-concepts/page.mdx | 3 +- www/apps/book/sidebar.mjs | 16 +- .../cache}/create/page.mdx | 4 +- .../app/architectural-modules/cache/page.mdx | 11 + .../event}/create/page.mdx | 4 +- .../app/architectural-modules/event/page.mdx | 11 + .../architectural-modules/file/local/page.mdx | 101 + .../app/architectural-modules/file/page.mdx | 11 + .../app/architectural-modules/page.mdx | 2 +- .../payment/payment-provider/stripe/page.mdx | 14 +- www/apps/resources/generated/files-map.mjs | 32 +- www/apps/resources/generated/sidebar.mjs | 60 + www/apps/resources/generated/slug-changes.mjs | 6 +- .../file.AbstractFileProviderService/page.mdx | 125 + .../classes/file.AbstractFileService/page.mdx | 379 --- .../interfaces/file.IFileService/page.mdx | 355 --- .../references/modules/file/page.mdx | 6 +- www/apps/resources/sidebar.mjs | 40 + .../src/components/ChildDocs/index.tsx | 54 +- .../generated/typedoc-json-output/file.json | 2767 +---------------- .../src/constants/custom-options.ts | 4 +- .../constants/merger-custom-options/file.ts | 89 +- .../src/render-utils.ts | 2 + .../src/resources/helpers/start-sections.ts | 22 + .../src/resources/templates/index.hbs | 2 + .../src/resources/templates/reflection.hbs | 2 + .../resources/templates/reflection.member.hbs | 2 + www/utils/packages/types/lib/index.d.ts | 2 + 32 files changed, 745 insertions(+), 3448 deletions(-) create mode 100644 www/apps/book/app/architectural-concepts/file-module/page.mdx rename www/apps/{book/app/architectural-concepts/cache-module => resources/app/architectural-modules/cache}/create/page.mdx (97%) create mode 100644 www/apps/resources/app/architectural-modules/cache/page.mdx rename www/apps/{book/app/architectural-concepts/event-module => resources/app/architectural-modules/event}/create/page.mdx (97%) create mode 100644 www/apps/resources/app/architectural-modules/event/page.mdx create mode 100644 www/apps/resources/app/architectural-modules/file/local/page.mdx create mode 100644 www/apps/resources/app/architectural-modules/file/page.mdx create mode 100644 www/apps/resources/references/file/classes/file.AbstractFileProviderService/page.mdx delete mode 100644 www/apps/resources/references/file/classes/file.AbstractFileService/page.mdx delete mode 100644 www/apps/resources/references/file/interfaces/file.IFileService/page.mdx create mode 100644 www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/start-sections.ts diff --git a/www/apps/book/app/architectural-concepts/architectural-modules/page.mdx b/www/apps/book/app/architectural-concepts/architectural-modules/page.mdx index b06763bac2..3f15357b4d 100644 --- a/www/apps/book/app/architectural-concepts/architectural-modules/page.mdx +++ b/www/apps/book/app/architectural-concepts/architectural-modules/page.mdx @@ -12,8 +12,6 @@ An architectural module implements features and mechanisms related to the Medusa Since modules are interchangeable, you have more control over Medusa’s architecture. For example, you can choose to use Memcached for event handling instead of Redis. -Medusa currently supports two types of architectural modules: Cache and event modules. - Refer to the [Architectural Modules reference](!resources!/architectural-modules) for a list of Medusa’s architectural modules. @@ -26,4 +24,4 @@ Refer to the [Architectural Modules reference](!resources!/architectural-modules You create an architectural module like you’ve been creating custom modules: create a module with a service and export that service in the module’s definition file. The module's service extends an abstract class or interface provided by Medusa with predefined method signatures. -The next chapters explain the different architectural module types and how to create an architectural module for each. \ No newline at end of file +The next chapters explain the different architectural module types and how to create an architectural module for each. diff --git a/www/apps/book/app/architectural-concepts/cache-module/page.mdx b/www/apps/book/app/architectural-concepts/cache-module/page.mdx index 8c1edb21bc..ca6b02ea7e 100644 --- a/www/apps/book/app/architectural-concepts/cache-module/page.mdx +++ b/www/apps/book/app/architectural-concepts/cache-module/page.mdx @@ -18,4 +18,16 @@ The underlying database, third-party service, or caching logic is flexible since By default, Medusa uses the In-Memory Cache Module. This module uses a plain JavaScript Map object to store the cache data. -This is useful for development. However, for production, it's highly recommended to use other Cache Modules, such as the [Redis Cache Module](!resources!/architectural-modules/cache/redis). \ No newline at end of file +This is useful for development. However, for production, it's highly recommended to use other Cache Modules, such as the [Redis Cache Module](!resources!/architectural-modules/cache/redis). + +--- + +## List of Cache Modules + +Refer to the Medusa Learning Resources for a [list of available cache modules](!resources!/architectural-modules/cache). + +--- + +## Create a Cache Module + +To create a cache module, refer to [this guide in the Medusa Learning Resources](!resources!/architectural-modules/cache/create). diff --git a/www/apps/book/app/architectural-concepts/event-module/page.mdx b/www/apps/book/app/architectural-concepts/event-module/page.mdx index b37dc5f3b5..2ca511da14 100644 --- a/www/apps/book/app/architectural-concepts/event-module/page.mdx +++ b/www/apps/book/app/architectural-concepts/event-module/page.mdx @@ -12,7 +12,7 @@ In previous chapters, you learned that the Medusa application emits events, and The Event Module implements the underlying publish/subscribe system that handles queueing events, emitting them, and executing their subscribers. -This makes the event architecture customizable, as you can either choose one of Medusa’s Event Modules or create your own. +This makes the event architecture customizable, as you can either choose one of Medusa’s event modules or create your own. --- @@ -21,3 +21,15 @@ This makes the event architecture customizable, as you can either choose one of By default, Medusa uses the Local Event Module. This module uses Node’s EventEmitter to implement the publish/subscribe system. This is useful for development. However, for production, it’s highly recommended to use other Event Modules, such as the [Redis Event Module](!resources!/architectural-modules/event/redis). + +--- + +## List of Event Modules + +Refer to the Medusa Learning Resources for a [list of available event modules](!resources!/architectural-modules/event). + +--- + +## Create a Event Module + +To create an event module, refer to [this guide in the Medusa Learning Resources](!resources!/architectural-modules/event/create). diff --git a/www/apps/book/app/architectural-concepts/file-module/page.mdx b/www/apps/book/app/architectural-concepts/file-module/page.mdx new file mode 100644 index 0000000000..23ad9ac077 --- /dev/null +++ b/www/apps/book/app/architectural-concepts/file-module/page.mdx @@ -0,0 +1,35 @@ +export const metadata = { + title: `${pageNumber} File Module`, +} + +# {metadata.title} + +In this chapter, you’ll learn about what the File Module is. + +## What is the File Module? + +The File Module exposes the functionalities to upload assets, such as product images, to the Medusa application. + +--- + +## What is a File Provider Module? + +A file provider module implements the logic of handling uploads and downloads. The File Module must have one file provider module configured. + +By default, Medusa uses the Local File Module. This module uploads files to the `uploads` directory of your Medusa application. + +{/* TODO add once s3 module is working/published? */} + +{/* This is useful for development. However, for production, it’s highly recommended to use other File Modules, such as the [S3 Module](!resources!/architectural-modules/event/redis). */} + +--- + +## List of File Provider Modules + +Refer to the Medusa Learning Resources for a [list of available file provider modules](!resources!/architectural-modules/file). + +--- + +## Create a File Provider Module + +To create a file provider module, refer to [this guide in the Medusa Learning Resources](!resources!/architectural-modules/references/file-provider-module). diff --git a/www/apps/book/app/architectural-concepts/page.mdx b/www/apps/book/app/architectural-concepts/page.mdx index 33e22c01a1..0e764159ce 100644 --- a/www/apps/book/app/architectural-concepts/page.mdx +++ b/www/apps/book/app/architectural-concepts/page.mdx @@ -9,5 +9,4 @@ In the next chapters, you’ll learn more about customizable aspects of Medusa By the end of these chapters, you’ll learn about: - What an architectural module is. -- The cache architectural module and how to create one. -- The events architectural module and how to create one. \ No newline at end of file +- The different types of architectural modules, including cache and event modules. diff --git a/www/apps/book/sidebar.mjs b/www/apps/book/sidebar.mjs index 93fe638d4b..191053ae4e 100644 --- a/www/apps/book/sidebar.mjs +++ b/www/apps/book/sidebar.mjs @@ -253,22 +253,14 @@ export const sidebar = sidebarAttachHrefCommonOptions( { path: "/architectural-concepts/cache-module", title: "Cache Module", - children: [ - { - path: "/architectural-concepts/cache-module/create", - title: "Create Cache Module", - }, - ], }, { path: "/architectural-concepts/event-module", title: "Event Module", - children: [ - { - path: "/architectural-concepts/event-module/create", - title: "Create Event Module", - }, - ], + }, + { + path: "/architectural-concepts/file-module", + title: "File Module", }, ], }, diff --git a/www/apps/book/app/architectural-concepts/cache-module/create/page.mdx b/www/apps/resources/app/architectural-modules/cache/create/page.mdx similarity index 97% rename from www/apps/book/app/architectural-concepts/cache-module/create/page.mdx rename to www/apps/resources/app/architectural-modules/cache/create/page.mdx index fa57e6c172..6d93374015 100644 --- a/www/apps/book/app/architectural-concepts/cache-module/create/page.mdx +++ b/www/apps/resources/app/architectural-modules/cache/create/page.mdx @@ -1,10 +1,10 @@ export const metadata = { - title: `${pageNumber} How to Create a Cache Module`, + title: `How to Create a Cache Module`, } # {metadata.title} -In this chapter, you’ll learn how to create a Cache Module. +In this guide, you’ll learn how to create a Cache Module. ## 1. Create Module Directory diff --git a/www/apps/resources/app/architectural-modules/cache/page.mdx b/www/apps/resources/app/architectural-modules/cache/page.mdx new file mode 100644 index 0000000000..e7f1084492 --- /dev/null +++ b/www/apps/resources/app/architectural-modules/cache/page.mdx @@ -0,0 +1,11 @@ +import { ChildDocs } from "docs-ui" + +export const metadata = { + title: `Cache Modules`, +} + +# {metadata.title} + +Learn how to create a cache module in [this guide](./create/page.mdx). + + diff --git a/www/apps/book/app/architectural-concepts/event-module/create/page.mdx b/www/apps/resources/app/architectural-modules/event/create/page.mdx similarity index 97% rename from www/apps/book/app/architectural-concepts/event-module/create/page.mdx rename to www/apps/resources/app/architectural-modules/event/create/page.mdx index 77641e229b..69035ac78c 100644 --- a/www/apps/book/app/architectural-concepts/event-module/create/page.mdx +++ b/www/apps/resources/app/architectural-modules/event/create/page.mdx @@ -1,10 +1,10 @@ export const metadata = { - title: `${pageNumber} How to Create an Event Module`, + title: `How to Create an Event Module`, } # {metadata.title} -In this chapter, you’ll learn how to create an Event Module. +In this guide, you’ll learn how to create an Event Module. ## 1. Create Module Directory diff --git a/www/apps/resources/app/architectural-modules/event/page.mdx b/www/apps/resources/app/architectural-modules/event/page.mdx new file mode 100644 index 0000000000..6572ee134e --- /dev/null +++ b/www/apps/resources/app/architectural-modules/event/page.mdx @@ -0,0 +1,11 @@ +import { ChildDocs } from "docs-ui" + +export const metadata = { + title: `Event Modules`, +} + +# {metadata.title} + +Learn how to create a event module in [this guide](./create/page.mdx). + + diff --git a/www/apps/resources/app/architectural-modules/file/local/page.mdx b/www/apps/resources/app/architectural-modules/file/local/page.mdx new file mode 100644 index 0000000000..37b344a1b8 --- /dev/null +++ b/www/apps/resources/app/architectural-modules/file/local/page.mdx @@ -0,0 +1,101 @@ +import { Table } from "docs-ui" + +export const metadata = { + title: `Local File Provider Module`, +} + +# {metadata.title} + +The Local File Provider Module stores files uploaded to your Medusa application in the `/uploads` directory. + +--- + +## Install the Local File Module + +To install the Local File Provider Module, run the following command in the directory of your Medusa application: + +```bash npm2yarn +npm install @medusajs/file-local-next +``` + +Next, add the module into the `providers` array of the File Module: + + + +The File Module accepts one provider only. + + + +```js title="medusa-config.js" +module.exports = { + // ... + modules: { + // ... + [Modules.FILE]: { + resolve: "@medusajs/file", + options: { + providers: [ + { + resolve: "@medusajs/file-local-next", + options: { + config: { + local: { + // provider options... + }, + }, + }, + }, + ], + }, + }, + }, +} +``` + +### Local File Module Options + + + + + Option + Description + Default + + + + + + + `upload_dir` + + + + + The directory to upload files to. + + + + + `uploads` + + + + + + + `upload_dir` + + + + + The URL of the Medusa application. + + + + + `http://localhost:9000` + + + + +
diff --git a/www/apps/resources/app/architectural-modules/file/page.mdx b/www/apps/resources/app/architectural-modules/file/page.mdx new file mode 100644 index 0000000000..d5db18089b --- /dev/null +++ b/www/apps/resources/app/architectural-modules/file/page.mdx @@ -0,0 +1,11 @@ +import { ChildDocs } from "docs-ui" + +export const metadata = { + title: `File Provider Modules`, +} + +# {metadata.title} + +Learn how to create a file provider module in [this guide](/references/file-provider-module). + + diff --git a/www/apps/resources/app/architectural-modules/page.mdx b/www/apps/resources/app/architectural-modules/page.mdx index 92bcf7d0de..ea0b66891b 100644 --- a/www/apps/resources/app/architectural-modules/page.mdx +++ b/www/apps/resources/app/architectural-modules/page.mdx @@ -8,4 +8,4 @@ export const metadata = { This section includes documentation for official Medusa architectural modules. - \ No newline at end of file + \ No newline at end of file diff --git a/www/apps/resources/app/commerce-modules/payment/payment-provider/stripe/page.mdx b/www/apps/resources/app/commerce-modules/payment/payment-provider/stripe/page.mdx index faa2c83268..11d9cc619f 100644 --- a/www/apps/resources/app/commerce-modules/payment/payment-provider/stripe/page.mdx +++ b/www/apps/resources/app/commerce-modules/payment/payment-provider/stripe/page.mdx @@ -48,11 +48,15 @@ const modules = { { resolve: "@medusajs/payment-stripe", options: { - credentials: { - usd: { - apiKey: process.env.STRIPE_USD_API_KEY, - }, - }, + config: { + stripe: { + credentials: { + usd: { + apiKey: process.env.STRIPE_USD_API_KEY, + }, + }, + } + } }, }, ], diff --git a/www/apps/resources/generated/files-map.mjs b/www/apps/resources/generated/files-map.mjs index 25de30859f..ae0f2b3585 100644 --- a/www/apps/resources/generated/files-map.mjs +++ b/www/apps/resources/generated/files-map.mjs @@ -3,22 +3,46 @@ export const filesMap = [ "filePath": "/www/apps/resources/app/admin-widget-injection-zones/page.mdx", "pathname": "/admin-widget-injection-zones" }, + { + "filePath": "/www/apps/resources/app/architectural-modules/cache/create/page.mdx", + "pathname": "/architectural-modules/cache/create" + }, { "filePath": "/www/apps/resources/app/architectural-modules/cache/in-memory/page.mdx", "pathname": "/architectural-modules/cache/in-memory" }, + { + "filePath": "/www/apps/resources/app/architectural-modules/cache/page.mdx", + "pathname": "/architectural-modules/cache" + }, { "filePath": "/www/apps/resources/app/architectural-modules/cache/redis/page.mdx", "pathname": "/architectural-modules/cache/redis" }, + { + "filePath": "/www/apps/resources/app/architectural-modules/event/create/page.mdx", + "pathname": "/architectural-modules/event/create" + }, { "filePath": "/www/apps/resources/app/architectural-modules/event/local/page.mdx", "pathname": "/architectural-modules/event/local" }, + { + "filePath": "/www/apps/resources/app/architectural-modules/event/page.mdx", + "pathname": "/architectural-modules/event" + }, { "filePath": "/www/apps/resources/app/architectural-modules/event/redis/page.mdx", "pathname": "/architectural-modules/event/redis" }, + { + "filePath": "/www/apps/resources/app/architectural-modules/file/local/page.mdx", + "pathname": "/architectural-modules/file/local" + }, + { + "filePath": "/www/apps/resources/app/architectural-modules/file/page.mdx", + "pathname": "/architectural-modules/file" + }, { "filePath": "/www/apps/resources/app/architectural-modules/page.mdx", "pathname": "/architectural-modules" @@ -2004,12 +2028,8 @@ export const filesMap = [ "pathname": "/references/customer_models/classes/customer_models.CustomerGroupCustomer" }, { - "filePath": "/www/apps/resources/references/file/classes/file.AbstractFileService/page.mdx", - "pathname": "/references/file/classes/file.AbstractFileService" - }, - { - "filePath": "/www/apps/resources/references/file/interfaces/file.IFileService/page.mdx", - "pathname": "/references/file/interfaces/file.IFileService" + "filePath": "/www/apps/resources/references/file/classes/file.AbstractFileProviderService/page.mdx", + "pathname": "/references/file/classes/file.AbstractFileProviderService" }, { "filePath": "/www/apps/resources/references/fulfillment/IFulfillmentModuleService/methods/fulfillment.IFulfillmentModuleService.cancelFulfillment/page.mdx", diff --git a/www/apps/resources/generated/sidebar.mjs b/www/apps/resources/generated/sidebar.mjs index e8711fba4a..3a0d3d7d85 100644 --- a/www/apps/resources/generated/sidebar.mjs +++ b/www/apps/resources/generated/sidebar.mjs @@ -6804,6 +6804,7 @@ export const generatedSidebar = [ { "loaded": true, "isPathHref": true, + "path": "/architectural-modules/cache", "title": "Cache Modules", "hasTitleStyling": true, "children": [ @@ -6820,12 +6821,27 @@ export const generatedSidebar = [ "path": "/architectural-modules/cache/redis", "title": "Redis", "children": [] + }, + { + "loaded": true, + "isPathHref": true, + "title": "Guides", + "children": [ + { + "loaded": true, + "isPathHref": true, + "path": "/architectural-modules/cache/create", + "title": "Create Cache Module", + "children": [] + } + ] } ] }, { "loaded": true, "isPathHref": true, + "path": "/architectural-modules/event", "title": "Event Modules", "hasTitleStyling": true, "children": [ @@ -6842,6 +6858,50 @@ export const generatedSidebar = [ "path": "/architectural-modules/event/redis", "title": "Redis", "children": [] + }, + { + "loaded": true, + "isPathHref": true, + "title": "Guides", + "children": [ + { + "loaded": true, + "isPathHref": true, + "path": "/architectural-modules/event/create", + "title": "Create Event Module", + "children": [] + } + ] + } + ] + }, + { + "loaded": true, + "isPathHref": true, + "path": "/architectural-modules/file", + "title": "File Provider Modules", + "hasTitleStyling": true, + "children": [ + { + "loaded": true, + "isPathHref": true, + "path": "/architectural-modules/file/local", + "title": "Local", + "children": [] + }, + { + "loaded": true, + "isPathHref": true, + "title": "Guides", + "children": [ + { + "loaded": true, + "isPathHref": true, + "path": "/references/file-provider-module", + "title": "Create File Module", + "children": [] + } + ] } ] }, diff --git a/www/apps/resources/generated/slug-changes.mjs b/www/apps/resources/generated/slug-changes.mjs index 32f1e55c37..026304b8ed 100644 --- a/www/apps/resources/generated/slug-changes.mjs +++ b/www/apps/resources/generated/slug-changes.mjs @@ -570,9 +570,9 @@ export const slugChanges = [ "filePath": "/www/apps/resources/references/customer_models/classes/customer_models.CustomerGroupCustomer/page.mdx" }, { - "origSlug": "/references/file/classes/file.AbstractFileService", - "newSlug": "/references/file-service", - "filePath": "/www/apps/resources/references/file/classes/file.AbstractFileService/page.mdx" + "origSlug": "/references/file/classes/file.AbstractFileProviderService", + "newSlug": "/references/file-provider-module", + "filePath": "/www/apps/resources/references/file/classes/file.AbstractFileProviderService/page.mdx" }, { "origSlug": "/references/fulfillment/IFulfillmentModuleService/methods/fulfillment.IFulfillmentModuleService.cancelFulfillment", diff --git a/www/apps/resources/references/file/classes/file.AbstractFileProviderService/page.mdx b/www/apps/resources/references/file/classes/file.AbstractFileProviderService/page.mdx new file mode 100644 index 0000000000..c172863840 --- /dev/null +++ b/www/apps/resources/references/file/classes/file.AbstractFileProviderService/page.mdx @@ -0,0 +1,125 @@ +--- +slug: /references/file-provider-module +--- + +import { TypeList } from "docs-ui" + +# How to Create a File Provider Module + +In this document, you’ll learn how to create a file provider module and the methods you must implement in it. + +--- + +## 1. Create Module Directory + +Start by creating a new directory for your module. For example, `src/modules/my-file`. + +--- + +## 2. Create the File Provider Service + +Create the file `src/modules/my-file/service.ts` that holds the implementation of the file service. + +The File Provider Module's main service must extend the `AbstractFileProviderService` class imported from `@medusajs/utils`: + +```ts title="src/modules/my-file/service.ts" +import { AbstractFileProviderService } from "@medusajs/utils" + +class MyFileProviderService extends AbstractFileProviderService { + // TODO implement methods +} + +export default MyFileProviderService +``` + +### constructor + +### getIdentifier + +#### Returns + + + +### upload + +#### Parameters + + + +#### Returns + + + +### delete + +#### Parameters + + + +#### Returns + + + +### getPresignedDownloadUrl + +#### Parameters + + + +#### Returns + + + +--- + +## 3. Create Module Definition File + +Create the file `src/modules/my-file/index.ts` with the following content: + +```ts title="src/modules/my-file/index.ts" +import MyFileProviderService from "./service" + +export default { + service: MyFileProviderService, +} +``` + +This exports the module's definition, indicating that the `MyFileProviderService` is the main service of the module. + +--- + +## 4. Use Module + +To use your File Provider Module, add it to the `providers` array of the File Module: + + + +The File Module accepts one provider only. + + + +```js title="medusa-config.js" +module.exports = { + // ... + modules: { + // ... + [Modules.FILE]: { + resolve: "@medusajs/file", + options: { + providers: [ + { + resolve: "./dist/modules/my-file", + options: { + config: { + "my-file": { + // provider options... + }, + }, + }, + }, + ], + }, + }, + }, +} +``` diff --git a/www/apps/resources/references/file/classes/file.AbstractFileService/page.mdx b/www/apps/resources/references/file/classes/file.AbstractFileService/page.mdx deleted file mode 100644 index fe7515e4f3..0000000000 --- a/www/apps/resources/references/file/classes/file.AbstractFileService/page.mdx +++ /dev/null @@ -1,379 +0,0 @@ ---- -slug: /references/file-service ---- - -import { TypeList } from "docs-ui" - -# How to Create a File Service - -In this document, you’ll learn how to create a file service in the Medusa backend and the methods you must implement in it. - -## Overview - -A file service class is defined in a TypeScript or JavaScript file that’s created in the `src/services` directory. -The class must extend the `AbstractFileService` class imported from the `@medusajs/medusa` package. - -Based on services’ naming conventions, the file’s name should be the slug version of the file service’s name -without `service`, and the class’s name should be the pascal case of the file service’s name following by `Service`. - -For example, create the file `src/services/local-file.ts` with the following content: - -```ts title="src/services/local-file.ts" -import { AbstractFileService } from "@medusajs/medusa" -import { - DeleteFileType, - FileServiceGetUploadStreamResult, - FileServiceUploadResult, - GetUploadedFileType, - UploadStreamDescriptorType, -} from "@medusajs/types" - -class LocalFileService extends AbstractFileService { - async upload( - fileData: Express.Multer.File - ): Promise { - throw new Error("Method not implemented.") - } - async uploadProtected( - fileData: Express.Multer.File - ): Promise { - throw new Error("Method not implemented.") - } - async delete(fileData: DeleteFileType): Promise { - throw new Error("Method not implemented.") - } - async getUploadStreamDescriptor( - fileData: UploadStreamDescriptorType - ): Promise { - throw new Error("Method not implemented.") - } - async getDownloadStream( - fileData: GetUploadedFileType - ): Promise { - throw new Error("Method not implemented.") - } - async getPresignedDownloadUrl( - fileData: GetUploadedFileType - ): Promise { - throw new Error("Method not implemented.") - } -} - -export default LocalFileService -``` - -:::note[Multer Typing] - -The examples implement a file service supporting local uploads. - -If you’re using TypeScript and you're following along with the implementation, -you should install the Multer types package in the root of your Medusa backend to resolve errors within your file service types: - -```bash npm2yarn -npm install @types/multer -``` - -::: - ---- - -## constructor - -You can use the `constructor` of your file service to access the different services in Medusa through dependency injection. - -You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs, -you can initialize it in the constructor and use it in other methods in the service. - -Additionally, if you’re creating your file service as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin, -you can access them in the constructor. - -### Example - -```ts -// ... -import { Logger } from "@medusajs/medusa" -import * as fs from "fs" - -class LocalFileService extends AbstractFileService { - // can also be replaced by an environment variable - // or a plugin option - protected serverUrl = "http://localhost:9000" - protected publicPath = "uploads" - protected protectedPath = "protected-uploads" - protected logger_: Logger - - constructor({ logger }: InjectedDependencies) { - // @ts-ignore - super(...arguments) - this.logger_ = logger - - // for public uploads - if (!fs.existsSync(this.publicPath)) { - fs.mkdirSync(this.publicPath) - } - - // for protected uploads - if (!fs.existsSync(this.protectedPath)) { - fs.mkdirSync(this.protectedPath) - } - } - // ... -} -``` - -### Parameters - -`","description":"An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"`Record`","description":"If this file service is created in a plugin, the plugin's options are passed in this parameter.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="new AbstractFileService"/> - -___ - -## Methods - -### upload - -This method is used to upload a file to the Medusa backend. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - // ... - async upload( - fileData: Express.Multer.File - ): Promise { - const filePath = - `${this.publicPath}/${fileData.originalname}` - fs.copyFileSync(fileData.path, filePath) - return { - url: `${this.serverUrl}/${filePath}`, - key: filePath, - } - } - // ... -} -``` - -:::tip - -This example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name. - -::: - -#### Parameters - - - -#### Returns - - - -### uploadProtected - -This method is used to upload a file to the Medusa backend, but to a protected storage. Typically, this would be used to store files that -shouldn’t be accessible by using the file’s URL or should only be accessible by authenticated users. For example, exported or imported -CSV files. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - // ... - async uploadProtected( - fileData: Express.Multer.File - ): Promise { - const filePath = - `${this.protectedPath}/${fileData.originalname}` - fs.copyFileSync(fileData.path, filePath) - return { - url: `${this.serverUrl}/${filePath}`, - key: filePath - } - } - // ... -} -``` - -:::tip - -This example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name. - -::: - -#### Parameters - - - -#### Returns - - - -### delete - -This method is used to delete a file from storage. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - - async delete( - fileData: DeleteFileType - ): Promise { - fs.rmSync(fileData.fileKey) - } - - // ... -} -``` - -#### Parameters - - - -#### Returns - - - -### getUploadStreamDescriptor - -This method is used to retrieve a write stream to be used to upload a file. - -#### Example - -```ts -// ... -import { Stream } from "stream" - -class LocalFileService extends AbstractFileService { - // ... - async getUploadStreamDescriptor({ - name, - ext, - isPrivate = true, - }: UploadStreamDescriptorType - ): Promise { - const filePath = `${isPrivate ? - this.publicPath : this.protectedPath - }/${name}.${ext}` - - const pass = new Stream.PassThrough() - const writeStream = fs.createWriteStream(filePath) - - pass.pipe(writeStream) - - return { - writeStream: pass, - promise: Promise.resolve(), - url: `${this.serverUrl}/${filePath}`, - fileKey: filePath, - } - } - // ... -} -``` - -#### Parameters - - - -#### Returns - - - -### getDownloadStream - -This method is used to retrieve a read stream for a file, which can then be used to download the file. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - - async getDownloadStream({ - fileKey, - isPrivate = true, - }: GetUploadedFileType - ): Promise { - const filePath = `${isPrivate ? - this.publicPath : this.protectedPath - }/${fileKey}` - const readStream = fs.createReadStream(filePath) - - return readStream - } - - // ... -} -``` - -#### Parameters - - - -#### Returns - - - -### getPresignedDownloadUrl - -This method is used to retrieve a download URL of the file. For some file services, such as S3, a presigned URL indicates a temporary URL to get access to a file. - -If your file service doesn’t perform or offer a similar functionality, you can just return the URL to download the file. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - - async getPresignedDownloadUrl({ - fileKey, - isPrivate = true, - }: GetUploadedFileType - ): Promise { - // Local upload doesn't provide - // support for presigned URLs, - // so just return the file's URL. - - const filePath = `${isPrivate ? - this.publicPath : this.protectedPath - }/${fileKey}` - return `${this.serverUrl}/${filePath}` - } - - // ... -} -``` - -#### Parameters - - - -#### Returns - - - ---- - -## Test Implementation - -:::note - -If you created your file service in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin). - -::: - -After finishing your file service implementation: - -1\. Run the `build` command in the root of your Medusa backend: - -```bash npm2yarn -npm run build -``` - -2\. Start the backend with the `develop` command: - -```bash -npx medusa develop -``` - -3\. Upload a file using the [Admin REST APIs](https://docs.medusajs.com/api/admin#uploads_postuploads) or using the Medusa admin, for example, to [upload a product's thumbnail](https://docs.medusajs.com/user-guide/products/manage#manage-thumbnails). diff --git a/www/apps/resources/references/file/interfaces/file.IFileService/page.mdx b/www/apps/resources/references/file/interfaces/file.IFileService/page.mdx deleted file mode 100644 index a218694104..0000000000 --- a/www/apps/resources/references/file/interfaces/file.IFileService/page.mdx +++ /dev/null @@ -1,355 +0,0 @@ ---- -displayed_sidebar: core ---- - -import { TypeList } from "docs-ui" - -# IFileService - -## Overview - -A file service class is defined in a TypeScript or JavaScript file that’s created in the `src/services` directory. -The class must extend the `AbstractFileService` class imported from the `@medusajs/medusa` package. - -Based on services’ naming conventions, the file’s name should be the slug version of the file service’s name -without `service`, and the class’s name should be the pascal case of the file service’s name following by `Service`. - -For example, create the file `src/services/local-file.ts` with the following content: - -```ts title="src/services/local-file.ts" -import { AbstractFileService } from "@medusajs/medusa" -import { - DeleteFileType, - FileServiceGetUploadStreamResult, - FileServiceUploadResult, - GetUploadedFileType, - UploadStreamDescriptorType, -} from "@medusajs/types" - -class LocalFileService extends AbstractFileService { - async upload( - fileData: Express.Multer.File - ): Promise { - throw new Error("Method not implemented.") - } - async uploadProtected( - fileData: Express.Multer.File - ): Promise { - throw new Error("Method not implemented.") - } - async delete(fileData: DeleteFileType): Promise { - throw new Error("Method not implemented.") - } - async getUploadStreamDescriptor( - fileData: UploadStreamDescriptorType - ): Promise { - throw new Error("Method not implemented.") - } - async getDownloadStream( - fileData: GetUploadedFileType - ): Promise { - throw new Error("Method not implemented.") - } - async getPresignedDownloadUrl( - fileData: GetUploadedFileType - ): Promise { - throw new Error("Method not implemented.") - } -} - -export default LocalFileService -``` - -:::note[Multer Typing] - -The examples implement a file service supporting local uploads. - -If you’re using TypeScript and you're following along with the implementation, -you should install the Multer types package in the root of your Medusa backend to resolve errors within your file service types: - -```bash npm2yarn -npm install @types/multer -``` - -::: - ---- - -## Properties - -`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="IFileService"/> - -___ - -## Accessors - -### activeManager\_ - -#### Returns - - - -___ - -## Methods - -### upload - -This method is used to upload a file to the Medusa backend. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - // ... - async upload( - fileData: Express.Multer.File - ): Promise { - const filePath = - `${this.publicPath}/${fileData.originalname}` - fs.copyFileSync(fileData.path, filePath) - return { - url: `${this.serverUrl}/${filePath}`, - key: filePath, - } - } - // ... -} -``` - -:::tip - -This example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name. - -::: - -#### Parameters - - - -#### Returns - - - -### uploadProtected - -This method is used to upload a file to the Medusa backend, but to a protected storage. Typically, this would be used to store files that -shouldn’t be accessible by using the file’s URL or should only be accessible by authenticated users. For example, exported or imported -CSV files. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - // ... - async uploadProtected( - fileData: Express.Multer.File - ): Promise { - const filePath = - `${this.protectedPath}/${fileData.originalname}` - fs.copyFileSync(fileData.path, filePath) - return { - url: `${this.serverUrl}/${filePath}`, - key: filePath - } - } - // ... -} -``` - -:::tip - -This example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name. - -::: - -#### Parameters - - - -#### Returns - - - -### delete - -This method is used to delete a file from storage. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - - async delete( - fileData: DeleteFileType - ): Promise { - fs.rmSync(fileData.fileKey) - } - - // ... -} -``` - -#### Parameters - - - -#### Returns - - - -### getUploadStreamDescriptor - -This method is used to retrieve a write stream to be used to upload a file. - -#### Example - -```ts -// ... -import { Stream } from "stream" - -class LocalFileService extends AbstractFileService { - // ... - async getUploadStreamDescriptor({ - name, - ext, - isPrivate = true, - }: UploadStreamDescriptorType - ): Promise { - const filePath = `${isPrivate ? - this.publicPath : this.protectedPath - }/${name}.${ext}` - - const pass = new Stream.PassThrough() - const writeStream = fs.createWriteStream(filePath) - - pass.pipe(writeStream) - - return { - writeStream: pass, - promise: Promise.resolve(), - url: `${this.serverUrl}/${filePath}`, - fileKey: filePath, - } - } - // ... -} -``` - -#### Parameters - - - -#### Returns - - - -### getDownloadStream - -This method is used to retrieve a read stream for a file, which can then be used to download the file. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - - async getDownloadStream({ - fileKey, - isPrivate = true, - }: GetUploadedFileType - ): Promise { - const filePath = `${isPrivate ? - this.publicPath : this.protectedPath - }/${fileKey}` - const readStream = fs.createReadStream(filePath) - - return readStream - } - - // ... -} -``` - -#### Parameters - - - -#### Returns - - - -### getPresignedDownloadUrl - -This method is used to retrieve a download URL of the file. For some file services, such as S3, a presigned URL indicates a temporary URL to get access to a file. - -If your file service doesn’t perform or offer a similar functionality, you can just return the URL to download the file. - -#### Example - -```ts -class LocalFileService extends AbstractFileService { - - async getPresignedDownloadUrl({ - fileKey, - isPrivate = true, - }: GetUploadedFileType - ): Promise { - // Local upload doesn't provide - // support for presigned URLs, - // so just return the file's URL. - - const filePath = `${isPrivate ? - this.publicPath : this.protectedPath - }/${fileKey}` - return `${this.serverUrl}/${filePath}` - } - - // ... -} -``` - -#### Parameters - - - -#### Returns - - - -### withTransaction - -#### Parameters - - - -#### Returns - - - -### shouldRetryTransaction\_ - -#### Parameters - -` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/> - -#### Returns - - - -### atomicPhase\_ - -Wraps some work within a transactional block. If the service already has -a transaction manager attached this will be reused, otherwise a new -transaction manager is created. - -#### Type Parameters - - - -#### Parameters - - Promise<TResult>","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise<void \\| TResult>","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise<void \\| TResult>","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/> - -#### Returns - - diff --git a/www/apps/resources/references/modules/file/page.mdx b/www/apps/resources/references/modules/file/page.mdx index 75ae2e0853..37e82f04b1 100644 --- a/www/apps/resources/references/modules/file/page.mdx +++ b/www/apps/resources/references/modules/file/page.mdx @@ -4,8 +4,4 @@ import { TypeList } from "docs-ui" ## Classes -- [AbstractFileService](../../file/classes/file.AbstractFileService/page.mdx) - -## Interfaces - -- [IFileService](../../file/interfaces/file.IFileService/page.mdx) +- [AbstractFileProviderService](../../file/classes/file.AbstractFileProviderService/page.mdx) diff --git a/www/apps/resources/sidebar.mjs b/www/apps/resources/sidebar.mjs index 36c4ae636e..0d68f09c5a 100644 --- a/www/apps/resources/sidebar.mjs +++ b/www/apps/resources/sidebar.mjs @@ -1592,6 +1592,7 @@ export const sidebar = sidebarAttachHrefCommonOptions([ hasTitleStyling: true, children: [ { + path: "/architectural-modules/cache", title: "Cache Modules", hasTitleStyling: true, children: [ @@ -1603,9 +1604,19 @@ export const sidebar = sidebarAttachHrefCommonOptions([ path: "/architectural-modules/cache/redis", title: "Redis", }, + { + title: "Guides", + children: [ + { + path: "/architectural-modules/cache/create", + title: "Create Cache Module", + }, + ], + }, ], }, { + path: "/architectural-modules/event", title: "Event Modules", hasTitleStyling: true, children: [ @@ -1617,6 +1628,35 @@ export const sidebar = sidebarAttachHrefCommonOptions([ path: "/architectural-modules/event/redis", title: "Redis", }, + { + title: "Guides", + children: [ + { + path: "/architectural-modules/event/create", + title: "Create Event Module", + }, + ], + }, + ], + }, + { + path: "/architectural-modules/file", + title: "File Provider Modules", + hasTitleStyling: true, + children: [ + { + path: "/architectural-modules/file/local", + title: "Local", + }, + { + title: "Guides", + children: [ + { + path: "/references/file-provider-module", + title: "Create File Module", + }, + ], + }, ], }, { diff --git a/www/packages/docs-ui/src/components/ChildDocs/index.tsx b/www/packages/docs-ui/src/components/ChildDocs/index.tsx index d7aaf37323..bd6f3ac1b7 100644 --- a/www/packages/docs-ui/src/components/ChildDocs/index.tsx +++ b/www/packages/docs-ui/src/components/ChildDocs/index.tsx @@ -1,15 +1,59 @@ "use client" -import React from "react" +import React, { useMemo } from "react" import { Card, CardList, MDXComponents, useSidebar } from "../.." import { SidebarItemType } from "types" type ChildDocsProps = { onlyTopLevel?: boolean + type?: "sidebar" | "item" + filters?: string[] } -export const ChildDocs = ({ onlyTopLevel = false }: ChildDocsProps) => { - const { currentItems } = useSidebar() +export const ChildDocs = ({ + onlyTopLevel = false, + filters = [], + type = "sidebar", +}: ChildDocsProps) => { + const { currentItems, getActiveItem } = useSidebar() + + const filterItems = (items: SidebarItemType[]): SidebarItemType[] => { + return items + .filter( + (item) => + (!item.path || !filters.includes(item.path)) && + !filters.includes(item.title) + ) + .map((item) => Object.assign({}, item)) + .map((item) => { + if (item.children) { + item.children = filterItems(item.children) + } + + return item + }) + } + + const filteredItems = useMemo(() => { + const targetItems = + type === "sidebar" + ? currentItems + ? Object.assign({}, currentItems) + : undefined + : { + top: [...(getActiveItem()?.children || [])], + bottom: [], + } + if (!filters.length || !targetItems) { + return targetItems + } + + return { + ...targetItems, + top: filterItems(targetItems.top), + bottom: filterItems(targetItems.bottom), + } + }, [currentItems, type, getActiveItem]) const getTopLevelElms = (items?: SidebarItemType[]) => ( { return ( <> - {getElms(currentItems?.top)} - {getElms(currentItems?.bottom)} + {getElms(filteredItems?.top)} + {getElms(filteredItems?.bottom)} ) } diff --git a/www/utils/generated/typedoc-json-output/file.json b/www/utils/generated/typedoc-json-output/file.json index 861c3dc87e..9e67b20ce2 100644 --- a/www/utils/generated/typedoc-json-output/file.json +++ b/www/utils/generated/typedoc-json-output/file.json @@ -1,1660 +1,100 @@ { - "id": 14333, + "id": 0, "name": "file", "variant": "project", "kind": 1, "flags": {}, "children": [ { - "id": 14334, - "name": "IFileService", + "id": 1, + "name": "AbstractFileProviderService", "variant": "declaration", - "kind": 256, + "kind": 128, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "## Overview\n\nA file service class is defined in a TypeScript or JavaScript file that’s created in the " - }, - { - "kind": "code", - "text": "`src/services`" - }, - { - "kind": "text", - "text": " directory.\nThe class must extend the " - }, - { - "kind": "code", - "text": "`AbstractFileService`" - }, - { - "kind": "text", - "text": " class imported from the " - }, - { - "kind": "code", - "text": "`@medusajs/medusa`" - }, - { - "kind": "text", - "text": " package.\n\nBased on services’ naming conventions, the file’s name should be the slug version of the file service’s name\nwithout " - }, - { - "kind": "code", - "text": "`service`" - }, - { - "kind": "text", - "text": ", and the class’s name should be the pascal case of the file service’s name following by " - }, - { - "kind": "code", - "text": "`Service`" - }, - { - "kind": "text", - "text": ".\n\nFor example, create the file " - }, - { - "kind": "code", - "text": "`src/services/local-file.ts`" - }, - { - "kind": "text", - "text": " with the following content:\n\n" - }, - { - "kind": "code", - "text": "```ts title=\"src/services/local-file.ts\"\nimport { AbstractFileService } from \"@medusajs/medusa\"\nimport {\n DeleteFileType,\n FileServiceGetUploadStreamResult,\n FileServiceUploadResult,\n GetUploadedFileType,\n UploadStreamDescriptorType,\n} from \"@medusajs/types\"\n\nclass LocalFileService extends AbstractFileService {\n async upload(\n fileData: Express.Multer.File\n ): Promise {\n throw new Error(\"Method not implemented.\")\n }\n async uploadProtected(\n fileData: Express.Multer.File\n ): Promise {\n throw new Error(\"Method not implemented.\")\n }\n async delete(fileData: DeleteFileType): Promise {\n throw new Error(\"Method not implemented.\")\n }\n async getUploadStreamDescriptor(\n fileData: UploadStreamDescriptorType\n ): Promise {\n throw new Error(\"Method not implemented.\")\n }\n async getDownloadStream(\n fileData: GetUploadedFileType\n ): Promise {\n throw new Error(\"Method not implemented.\")\n }\n async getPresignedDownloadUrl(\n fileData: GetUploadedFileType\n ): Promise {\n throw new Error(\"Method not implemented.\")\n }\n}\n\nexport default LocalFileService\n```" - }, - { - "kind": "text", - "text": "\n\n:::note[Multer Typing]\n\nThe examples implement a file service supporting local uploads.\n\nIf you’re using TypeScript and you're following along with the implementation,\nyou should install the Multer types package in the root of your Medusa backend to resolve errors within your file service types:\n\n" - }, - { - "kind": "code", - "text": "```bash npm2yarn\nnpm install @types/multer\n```" - }, - { - "kind": "text", - "text": "\n\n:::\n\n---" - } - ] - }, "children": [ { - "id": 14335, - "name": "upload", - "variant": "declaration", - "kind": 2048, - "flags": {}, - "signatures": [ - { - "id": 14336, - "name": "upload", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to upload a file to the Medusa backend." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The details of the upload's result." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n // ...\n async upload(\n fileData: Express.Multer.File\n ): Promise {\n const filePath =\n `${this.publicPath}/${fileData.originalname}`\n fs.copyFileSync(fileData.path, filePath)\n return {\n url: `${this.serverUrl}/${filePath}`,\n key: filePath,\n }\n }\n // ...\n}\n```" - }, - { - "kind": "text", - "text": "\n\n:::tip\n\nThis example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name.\n\n:::" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14337, - "name": "file", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "A [multer file object](http://expressjs.com/en/resources/middleware/multer.html#file-information).\nThe file is uploaded to a temporary directory by default. Among the file’s details, you can access the file’s path in the " - }, - { - "kind": "code", - "text": "`path`" - }, - { - "kind": "text", - "text": " property of the file object." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/@types/multer/index.d.ts", - "qualifiedName": "__global.Express.Multer.File" - }, - "name": "File", - "package": "@types/multer", - "qualifiedName": "__global.Express.Multer.File" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "FileServiceUploadResult" - }, - "name": "FileServiceUploadResult", - "package": "@medusajs/types" - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - }, - { - "id": 14338, - "name": "uploadProtected", - "variant": "declaration", - "kind": 2048, - "flags": {}, - "signatures": [ - { - "id": 14339, - "name": "uploadProtected", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to upload a file to the Medusa backend, but to a protected storage. Typically, this would be used to store files that\nshouldn’t be accessible by using the file’s URL or should only be accessible by authenticated users. For example, exported or imported\nCSV files." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The details of the upload's result." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n // ...\n async uploadProtected(\n fileData: Express.Multer.File\n ): Promise {\n const filePath =\n `${this.protectedPath}/${fileData.originalname}`\n fs.copyFileSync(fileData.path, filePath)\n return {\n url: `${this.serverUrl}/${filePath}`,\n key: filePath\n }\n }\n // ...\n}\n```" - }, - { - "kind": "text", - "text": "\n\n:::tip\n\nThis example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name.\n\n:::" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14340, - "name": "file", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "A [multer file object](http://expressjs.com/en/resources/middleware/multer.html#file-information).\nThe file is uploaded to a temporary directory by default. Among the file’s details, you can access the file’s path in the " - }, - { - "kind": "code", - "text": "`path`" - }, - { - "kind": "text", - "text": " property of the file object." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/@types/multer/index.d.ts", - "qualifiedName": "__global.Express.Multer.File" - }, - "name": "File", - "package": "@types/multer", - "qualifiedName": "__global.Express.Multer.File" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "FileServiceUploadResult" - }, - "name": "FileServiceUploadResult", - "package": "@medusajs/types" - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - }, - { - "id": 14341, - "name": "delete", - "variant": "declaration", - "kind": 2048, - "flags": {}, - "signatures": [ - { - "id": 14342, - "name": "delete", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to delete a file from storage." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "Resolves when the file is deleted successfully." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n\n async delete(\n fileData: DeleteFileType\n ): Promise {\n fs.rmSync(fileData.fileKey)\n }\n\n // ...\n}\n```" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14343, - "name": "fileData", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file to remove." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "DeleteFileType" - }, - "name": "DeleteFileType", - "package": "@medusajs/types" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "void" - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - }, - { - "id": 14344, - "name": "getUploadStreamDescriptor", - "variant": "declaration", - "kind": 2048, - "flags": {}, - "signatures": [ - { - "id": 14345, - "name": "getUploadStreamDescriptor", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to retrieve a write stream to be used to upload a file." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The result of the file-stream upload." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\n// ...\nimport { Stream } from \"stream\"\n\nclass LocalFileService extends AbstractFileService {\n // ...\n async getUploadStreamDescriptor({\n name,\n ext,\n isPrivate = true,\n }: UploadStreamDescriptorType\n ): Promise {\n const filePath = `${isPrivate ?\n this.publicPath : this.protectedPath\n }/${name}.${ext}`\n\n const pass = new Stream.PassThrough()\n const writeStream = fs.createWriteStream(filePath)\n\n pass.pipe(writeStream)\n\n return {\n writeStream: pass,\n promise: Promise.resolve(),\n url: `${this.serverUrl}/${filePath}`,\n fileKey: filePath,\n }\n }\n // ...\n}\n```" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14346, - "name": "fileData", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file being uploaded." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "UploadStreamDescriptorType" - }, - "name": "UploadStreamDescriptorType", - "package": "@medusajs/types" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "FileServiceGetUploadStreamResult" - }, - "name": "FileServiceGetUploadStreamResult", - "package": "@medusajs/types" - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - }, - { - "id": 14347, - "name": "getDownloadStream", - "variant": "declaration", - "kind": 2048, - "flags": {}, - "signatures": [ - { - "id": 14348, - "name": "getDownloadStream", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to retrieve a read stream for a file, which can then be used to download the file." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The [read stream](https://nodejs.org/api/webstreams.html#class-readablestream) to read and download the file." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n\n async getDownloadStream({\n fileKey,\n isPrivate = true,\n }: GetUploadedFileType\n ): Promise {\n const filePath = `${isPrivate ?\n this.publicPath : this.protectedPath\n }/${fileKey}`\n const readStream = fs.createReadStream(filePath)\n\n return readStream\n }\n\n // ...\n}\n```" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14349, - "name": "fileData", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "GetUploadedFileType" - }, - "name": "GetUploadedFileType", - "package": "@medusajs/types" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/@types/node/globals.d.ts", - "qualifiedName": "NodeJS.ReadableStream" - }, - "name": "ReadableStream", - "package": "@types/node", - "qualifiedName": "NodeJS.ReadableStream" - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - }, - { - "id": 14350, - "name": "getPresignedDownloadUrl", - "variant": "declaration", - "kind": 2048, - "flags": {}, - "signatures": [ - { - "id": 14351, - "name": "getPresignedDownloadUrl", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to retrieve a download URL of the file. For some file services, such as S3, a presigned URL indicates a temporary URL to get access to a file.\n\nIf your file service doesn’t perform or offer a similar functionality, you can just return the URL to download the file." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The presigned URL to download the file" - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n\n async getPresignedDownloadUrl({\n fileKey,\n isPrivate = true,\n }: GetUploadedFileType\n ): Promise {\n // Local upload doesn't provide\n // support for presigned URLs,\n // so just return the file's URL.\n\n const filePath = `${isPrivate ?\n this.publicPath : this.protectedPath\n }/${fileKey}`\n return `${this.serverUrl}/${filePath}`\n }\n\n // ...\n}\n```" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14352, - "name": "fileData", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "GetUploadedFileType" - }, - "name": "GetUploadedFileType", - "package": "@medusajs/types" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - }, - { - "id": 14353, - "name": "manager_", + "id": 2, + "name": "identifier", "variant": "declaration", "kind": 1024, "flags": { - "isProtected": true - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/entity-manager/EntityManager.d.ts", - "qualifiedName": "EntityManager" - }, - "name": "EntityManager", - "package": "typeorm" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.manager_" - } - }, - { - "id": 14354, - "name": "transactionManager_", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true - }, - "type": { - "type": "union", - "types": [ - { - "type": "intrinsic", - "name": "undefined" - }, - { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/entity-manager/EntityManager.d.ts", - "qualifiedName": "EntityManager" - }, - "name": "EntityManager", - "package": "typeorm" - } - ] - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.transactionManager_" - } - }, - { - "id": 14355, - "name": "activeManager_", - "variant": "declaration", - "kind": 262144, - "flags": { - "isProtected": true - }, - "getSignature": { - "id": 14356, - "name": "activeManager_", - "variant": "signature", - "kind": 524288, - "flags": {}, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/entity-manager/EntityManager.d.ts", - "qualifiedName": "EntityManager" - }, - "name": "EntityManager", - "package": "typeorm" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.activeManager_" - } - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.activeManager_" - } - }, - { - "id": 14357, - "name": "__container__", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isReadonly": true + "isStatic": true }, "type": { "type": "intrinsic", - "name": "any" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.__container__" + "name": "string" } }, { - "id": 14358, - "name": "__configModule__", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isOptional": true, - "isReadonly": true - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.__configModule__" - } - }, - { - "id": 14359, - "name": "__moduleDeclaration__", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isOptional": true, - "isReadonly": true - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.__moduleDeclaration__" - } - }, - { - "id": 14360, - "name": "withTransaction", - "variant": "declaration", - "kind": 2048, - "flags": {}, - "signatures": [ - { - "id": 14361, - "name": "withTransaction", - "variant": "signature", - "kind": 4096, - "flags": {}, - "parameters": [ - { - "id": 14362, - "name": "transactionManager", - "variant": "param", - "kind": 32768, - "flags": { - "isOptional": true - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/entity-manager/EntityManager.d.ts", - "qualifiedName": "EntityManager" - }, - "name": "EntityManager", - "package": "typeorm" - } - } - ], - "type": { - "type": "intrinsic", - "name": "this" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.withTransaction" - } - } - ], - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.withTransaction" - } - }, - { - "id": 14363, - "name": "shouldRetryTransaction_", - "variant": "declaration", - "kind": 2048, - "flags": { - "isProtected": true - }, - "signatures": [ - { - "id": 14364, - "name": "shouldRetryTransaction_", - "variant": "signature", - "kind": 4096, - "flags": {}, - "parameters": [ - { - "id": 14365, - "name": "err", - "variant": "param", - "kind": 32768, - "flags": {}, - "type": { - "type": "union", - "types": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - }, - { - "type": "reflection", - "declaration": { - "id": 14366, - "name": "__type", - "variant": "declaration", - "kind": 65536, - "flags": {}, - "children": [ - { - "id": 14367, - "name": "code", - "variant": "declaration", - "kind": 1024, - "flags": {}, - "type": { - "type": "intrinsic", - "name": "string" - } - } - ], - "groups": [ - { - "title": "Properties", - "children": [ - 14367 - ] - } - ] - } - } - ] - } - } - ], - "type": { - "type": "intrinsic", - "name": "boolean" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.shouldRetryTransaction_" - } - } - ], - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.shouldRetryTransaction_" - } - }, - { - "id": 14368, - "name": "atomicPhase_", - "variant": "declaration", - "kind": 2048, - "flags": { - "isProtected": true - }, - "signatures": [ - { - "id": 14369, - "name": "atomicPhase_", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "Wraps some work within a transactional block. If the service already has\na transaction manager attached this will be reused, otherwise a new\ntransaction manager is created." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "the result of the transactional work" - } - ] - } - ] - }, - "typeParameter": [ - { - "id": 14370, - "name": "TResult", - "variant": "typeParam", - "kind": 131072, - "flags": {} - }, - { - "id": 14371, - "name": "TError", - "variant": "typeParam", - "kind": 131072, - "flags": {} - } - ], - "parameters": [ - { - "id": 14372, - "name": "work", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "the transactional work to be done" - } - ] - }, - "type": { - "type": "reflection", - "declaration": { - "id": 14373, - "name": "__type", - "variant": "declaration", - "kind": 65536, - "flags": {}, - "signatures": [ - { - "id": 14374, - "name": "__type", - "variant": "signature", - "kind": 4096, - "flags": {}, - "parameters": [ - { - "id": 14375, - "name": "transactionManager", - "variant": "param", - "kind": 32768, - "flags": {}, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/entity-manager/EntityManager.d.ts", - "qualifiedName": "EntityManager" - }, - "name": "EntityManager", - "package": "typeorm" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": 14370, - "name": "TResult", - "package": "@medusajs/medusa", - "refersToTypeParameter": true - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - } - } - }, - { - "id": 14376, - "name": "isolationOrErrorHandler", - "variant": "param", - "kind": 32768, - "flags": { - "isOptional": true - }, - "comment": { - "summary": [ - { - "kind": "text", - "text": "the isolation level to be used for the work." - } - ] - }, - "type": { - "type": "union", - "types": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/driver/types/IsolationLevel.d.ts", - "qualifiedName": "IsolationLevel" - }, - "name": "IsolationLevel", - "package": "typeorm" - }, - { - "type": "reflection", - "declaration": { - "id": 14377, - "name": "__type", - "variant": "declaration", - "kind": 65536, - "flags": {}, - "signatures": [ - { - "id": 14378, - "name": "__type", - "variant": "signature", - "kind": 4096, - "flags": {}, - "parameters": [ - { - "id": 14379, - "name": "error", - "variant": "param", - "kind": 32768, - "flags": {}, - "type": { - "type": "reference", - "target": 14371, - "name": "TError", - "package": "@medusajs/medusa", - "refersToTypeParameter": true - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "union", - "types": [ - { - "type": "intrinsic", - "name": "void" - }, - { - "type": "reference", - "target": 14370, - "name": "TResult", - "package": "@medusajs/medusa", - "refersToTypeParameter": true - } - ] - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - } - } - ] - } - }, - { - "id": 14380, - "name": "maybeErrorHandlerOrDontFail", - "variant": "param", - "kind": 32768, - "flags": { - "isOptional": true - }, - "comment": { - "summary": [ - { - "kind": "text", - "text": "Potential error handler" - } - ] - }, - "type": { - "type": "reflection", - "declaration": { - "id": 14381, - "name": "__type", - "variant": "declaration", - "kind": 65536, - "flags": {}, - "signatures": [ - { - "id": 14382, - "name": "__type", - "variant": "signature", - "kind": 4096, - "flags": {}, - "parameters": [ - { - "id": 14383, - "name": "error", - "variant": "param", - "kind": 32768, - "flags": {}, - "type": { - "type": "reference", - "target": 14371, - "name": "TError", - "package": "@medusajs/medusa", - "refersToTypeParameter": true - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "union", - "types": [ - { - "type": "intrinsic", - "name": "void" - }, - { - "type": "reference", - "target": 14370, - "name": "TResult", - "package": "@medusajs/medusa", - "refersToTypeParameter": true - } - ] - } - ], - "name": "Promise", - "package": "typescript" - } - } - ] - } - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": 14370, - "name": "TResult", - "package": "@medusajs/medusa", - "refersToTypeParameter": true - } - ], - "name": "Promise", - "package": "typescript" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.atomicPhase_" - } - } - ], - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.atomicPhase_" - } - } - ], - "groups": [ - { - "title": "Properties", - "children": [ - 14353, - 14354, - 14357, - 14358, - 14359 - ] - }, - { - "title": "Accessors", - "children": [ - 14355 - ] - }, - { - "title": "Methods", - "children": [ - 14335, - 14338, - 14341, - 14344, - 14347, - 14350, - 14360, - 14363, - 14368 - ] - } - ], - "extendedTypes": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService" - }, - "name": "TransactionBaseService", - "package": "@medusajs/medusa" - } - ], - "implementedBy": [ - { - "type": "reference", - "target": 14384, - "name": "AbstractFileService" - } - ] - }, - { - "id": 14384, - "name": "AbstractFileService", - "variant": "declaration", - "kind": 128, - "flags": { - "isAbstract": true - }, - "children": [ - { - "id": 14389, + "id": 3, "name": "constructor", "variant": "declaration", "kind": 512, - "flags": { - "isProtected": true - }, + "flags": {}, "signatures": [ { - "id": 14390, - "name": "new AbstractFileService", + "id": 4, + "name": "new AbstractFileProviderService", "variant": "signature", "kind": 16384, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "You can use the " - }, - { - "kind": "code", - "text": "`constructor`" - }, - { - "kind": "text", - "text": " of your file service to access the different services in Medusa through dependency injection.\n\nYou can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs,\nyou can initialize it in the constructor and use it in other methods in the service.\n\nAdditionally, if you’re creating your file service as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin,\nyou can access them in the constructor." - } - ], - "blockTags": [ - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\n// ...\nimport { Logger } from \"@medusajs/medusa\"\nimport * as fs from \"fs\"\n\nclass LocalFileService extends AbstractFileService {\n // can also be replaced by an environment variable\n // or a plugin option\n protected serverUrl = \"http://localhost:9000\"\n protected publicPath = \"uploads\"\n protected protectedPath = \"protected-uploads\"\n protected logger_: Logger\n\n constructor({ logger }: InjectedDependencies) {\n // @ts-ignore\n super(...arguments)\n this.logger_ = logger\n\n // for public uploads\n if (!fs.existsSync(this.publicPath)) {\n fs.mkdirSync(this.publicPath)\n }\n\n // for protected uploads\n if (!fs.existsSync(this.protectedPath)) {\n fs.mkdirSync(this.protectedPath)\n }\n }\n // ...\n}\n```" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14391, - "name": "container", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "An instance of " - }, - { - "kind": "code", - "text": "`MedusaContainer`" - }, - { - "kind": "text", - "text": " that allows you to access other resources, such as services, in your Medusa backend." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - } - }, - { - "id": 14392, - "name": "config", - "variant": "param", - "kind": 32768, - "flags": { - "isOptional": true - }, - "comment": { - "summary": [ - { - "kind": "text", - "text": "If this file service is created in a plugin, the plugin's options are passed in this parameter." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - } - } - ], "type": { "type": "reference", - "target": 14384, - "name": "AbstractFileService", - "package": "@medusajs/medusa" - }, - "overwrites": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.constructor" + "target": 1, + "name": "AbstractFileProviderService", + "package": "@medusajs/utils" } } - ], - "overwrites": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.constructor" - } + ] }, { - "id": 14393, - "name": "container", + "id": 5, + "name": "getIdentifier", "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isReadonly": true - }, - "comment": { - "summary": [ - { - "kind": "text", - "text": "An instance of " - }, - { - "kind": "code", - "text": "`MedusaContainer`" - }, - { - "kind": "text", - "text": " that allows you to access other resources, such as services, in your Medusa backend." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { + "kind": 2048, + "flags": {}, + "signatures": [ + { + "id": 6, + "name": "getIdentifier", + "variant": "signature", + "kind": 4096, + "flags": {}, + "type": { "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" + "name": "any" } - ], - "name": "Record", - "package": "typescript" - } + } + ] }, { - "id": 14394, - "name": "config", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isOptional": true, - "isReadonly": true - }, - "comment": { - "summary": [ - { - "kind": "text", - "text": "If this file service is created in a plugin, the plugin's options are passed in this parameter." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - } - }, - { - "id": 14395, + "id": 7, "name": "upload", "variant": "declaration", "kind": 2048, - "flags": { - "isAbstract": true - }, + "flags": {}, "signatures": [ { - "id": 14396, + "id": 8, "name": "upload", "variant": "signature", "kind": 4096, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to upload a file to the Medusa backend." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The details of the upload's result." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n // ...\n async upload(\n fileData: Express.Multer.File\n ): Promise {\n const filePath =\n `${this.publicPath}/${fileData.originalname}`\n fs.copyFileSync(fileData.path, filePath)\n return {\n url: `${this.serverUrl}/${filePath}`,\n key: filePath,\n }\n }\n // ...\n}\n```" - }, - { - "kind": "text", - "text": "\n\n:::tip\n\nThis example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name.\n\n:::" - } - ] - } - ] - }, "parameters": [ { - "id": 14397, - "name": "fileData", + "id": 9, + "name": "file", "variant": "param", "kind": 32768, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "A [multer file object](http://expressjs.com/en/resources/middleware/multer.html#file-information).\nThe file is uploaded to a temporary directory by default. Among the file’s details, you can access the file’s path in the " - }, - { - "kind": "code", - "text": "`path`" - }, - { - "kind": "text", - "text": " property of the file object." - } - ] - }, "type": { "type": "reference", "target": { - "sourceFileName": "../../../node_modules/@types/multer/index.d.ts", - "qualifiedName": "__global.Express.Multer.File" + "sourceFileName": "../../../../packages/core/types/src/file/provider.ts", + "qualifiedName": "ProviderUploadFileDTO" }, - "name": "File", - "package": "@types/multer", - "qualifiedName": "__global.Express.Multer.File" + "name": "ProviderUploadFileDTO", + "package": "@medusajs/types" } } ], @@ -1668,10 +108,10 @@ { "type": "reference", "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "FileServiceUploadResult" + "sourceFileName": "../../../../packages/core/types/src/file/provider.ts", + "qualifiedName": "ProviderFileResultDTO" }, - "name": "FileServiceUploadResult", + "name": "ProviderFileResultDTO", "package": "@medusajs/types" } ], @@ -1680,197 +120,44 @@ }, "implementationOf": { "type": "reference", - "target": 14336, - "name": "IFileService.upload" + "target": -1, + "name": "IFileProvider.upload" } } ], "implementationOf": { "type": "reference", - "target": 14335, - "name": "IFileService.upload" + "target": -1, + "name": "IFileProvider.upload" } }, { - "id": 14398, - "name": "uploadProtected", - "variant": "declaration", - "kind": 2048, - "flags": { - "isAbstract": true - }, - "signatures": [ - { - "id": 14399, - "name": "uploadProtected", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to upload a file to the Medusa backend, but to a protected storage. Typically, this would be used to store files that\nshouldn’t be accessible by using the file’s URL or should only be accessible by authenticated users. For example, exported or imported\nCSV files." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The details of the upload's result." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n // ...\n async uploadProtected(\n fileData: Express.Multer.File\n ): Promise {\n const filePath =\n `${this.protectedPath}/${fileData.originalname}`\n fs.copyFileSync(fileData.path, filePath)\n return {\n url: `${this.serverUrl}/${filePath}`,\n key: filePath\n }\n }\n // ...\n}\n```" - }, - { - "kind": "text", - "text": "\n\n:::tip\n\nThis example does not account for duplicate names to maintain simplicity in this guide. So, an uploaded file can replace another existing file that has the same name.\n\n:::" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14400, - "name": "fileData", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "A [multer file object](http://expressjs.com/en/resources/middleware/multer.html#file-information).\nThe file is uploaded to a temporary directory by default. Among the file’s details, you can access the file’s path in the " - }, - { - "kind": "code", - "text": "`path`" - }, - { - "kind": "text", - "text": " property of the file object." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/@types/multer/index.d.ts", - "qualifiedName": "__global.Express.Multer.File" - }, - "name": "File", - "package": "@types/multer", - "qualifiedName": "__global.Express.Multer.File" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "FileServiceUploadResult" - }, - "name": "FileServiceUploadResult", - "package": "@medusajs/types" - } - ], - "name": "Promise", - "package": "typescript" - }, - "implementationOf": { - "type": "reference", - "target": 14339, - "name": "IFileService.uploadProtected" - } - } - ], - "implementationOf": { - "type": "reference", - "target": 14338, - "name": "IFileService.uploadProtected" - } - }, - { - "id": 14401, + "id": 10, "name": "delete", "variant": "declaration", "kind": 2048, - "flags": { - "isAbstract": true - }, + "flags": {}, "signatures": [ { - "id": 14402, + "id": 11, "name": "delete", "variant": "signature", "kind": 4096, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to delete a file from storage." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "Resolves when the file is deleted successfully." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n\n async delete(\n fileData: DeleteFileType\n ): Promise {\n fs.rmSync(fileData.fileKey)\n }\n\n // ...\n}\n```" - } - ] - } - ] - }, "parameters": [ { - "id": 14403, - "name": "fileData", + "id": 12, + "name": "file", "variant": "param", "kind": 32768, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file to remove." - } - ] - }, "type": { "type": "reference", "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "DeleteFileType" + "sourceFileName": "../../../../packages/core/types/src/file/provider.ts", + "qualifiedName": "ProviderDeleteFileDTO" }, - "name": "DeleteFileType", + "name": "ProviderDeleteFileDTO", "package": "@medusajs/types" } } @@ -1892,287 +179,44 @@ }, "implementationOf": { "type": "reference", - "target": 14342, - "name": "IFileService.delete" + "target": -1, + "name": "IFileProvider.delete" } } ], "implementationOf": { "type": "reference", - "target": 14341, - "name": "IFileService.delete" + "target": -1, + "name": "IFileProvider.delete" } }, { - "id": 14404, - "name": "getUploadStreamDescriptor", - "variant": "declaration", - "kind": 2048, - "flags": { - "isAbstract": true - }, - "signatures": [ - { - "id": 14405, - "name": "getUploadStreamDescriptor", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to retrieve a write stream to be used to upload a file." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The result of the file-stream upload." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\n// ...\nimport { Stream } from \"stream\"\n\nclass LocalFileService extends AbstractFileService {\n // ...\n async getUploadStreamDescriptor({\n name,\n ext,\n isPrivate = true,\n }: UploadStreamDescriptorType\n ): Promise {\n const filePath = `${isPrivate ?\n this.publicPath : this.protectedPath\n }/${name}.${ext}`\n\n const pass = new Stream.PassThrough()\n const writeStream = fs.createWriteStream(filePath)\n\n pass.pipe(writeStream)\n\n return {\n writeStream: pass,\n promise: Promise.resolve(),\n url: `${this.serverUrl}/${filePath}`,\n fileKey: filePath,\n }\n }\n // ...\n}\n```" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14406, - "name": "fileData", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file being uploaded." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "UploadStreamDescriptorType" - }, - "name": "UploadStreamDescriptorType", - "package": "@medusajs/types" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "FileServiceGetUploadStreamResult" - }, - "name": "FileServiceGetUploadStreamResult", - "package": "@medusajs/types" - } - ], - "name": "Promise", - "package": "typescript" - }, - "implementationOf": { - "type": "reference", - "target": 14345, - "name": "IFileService.getUploadStreamDescriptor" - } - } - ], - "implementationOf": { - "type": "reference", - "target": 14344, - "name": "IFileService.getUploadStreamDescriptor" - } - }, - { - "id": 14407, - "name": "getDownloadStream", - "variant": "declaration", - "kind": 2048, - "flags": { - "isAbstract": true - }, - "signatures": [ - { - "id": 14408, - "name": "getDownloadStream", - "variant": "signature", - "kind": 4096, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to retrieve a read stream for a file, which can then be used to download the file." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The [read stream](https://nodejs.org/api/webstreams.html#class-readablestream) to read and download the file." - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n\n async getDownloadStream({\n fileKey,\n isPrivate = true,\n }: GetUploadedFileType\n ): Promise {\n const filePath = `${isPrivate ?\n this.publicPath : this.protectedPath\n }/${fileKey}`\n const readStream = fs.createReadStream(filePath)\n\n return readStream\n }\n\n // ...\n}\n```" - } - ] - } - ] - }, - "parameters": [ - { - "id": 14409, - "name": "fileData", - "variant": "param", - "kind": 32768, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file." - } - ] - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "GetUploadedFileType" - }, - "name": "GetUploadedFileType", - "package": "@medusajs/types" - } - } - ], - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Promise" - }, - "typeArguments": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/@types/node/globals.d.ts", - "qualifiedName": "NodeJS.ReadableStream" - }, - "name": "ReadableStream", - "package": "@types/node", - "qualifiedName": "NodeJS.ReadableStream" - } - ], - "name": "Promise", - "package": "typescript" - }, - "implementationOf": { - "type": "reference", - "target": 14348, - "name": "IFileService.getDownloadStream" - } - } - ], - "implementationOf": { - "type": "reference", - "target": 14347, - "name": "IFileService.getDownloadStream" - } - }, - { - "id": 14410, + "id": 13, "name": "getPresignedDownloadUrl", "variant": "declaration", "kind": 2048, - "flags": { - "isAbstract": true - }, + "flags": {}, "signatures": [ { - "id": 14411, + "id": 14, "name": "getPresignedDownloadUrl", "variant": "signature", "kind": 4096, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "This method is used to retrieve a download URL of the file. For some file services, such as S3, a presigned URL indicates a temporary URL to get access to a file.\n\nIf your file service doesn’t perform or offer a similar functionality, you can just return the URL to download the file." - } - ], - "blockTags": [ - { - "tag": "@returns", - "content": [ - { - "kind": "text", - "text": "The presigned URL to download the file" - } - ] - }, - { - "tag": "@example", - "content": [ - { - "kind": "code", - "text": "```ts\nclass LocalFileService extends AbstractFileService {\n\n async getPresignedDownloadUrl({\n fileKey,\n isPrivate = true,\n }: GetUploadedFileType\n ): Promise {\n // Local upload doesn't provide\n // support for presigned URLs,\n // so just return the file's URL.\n\n const filePath = `${isPrivate ?\n this.publicPath : this.protectedPath\n }/${fileKey}`\n return `${this.serverUrl}/${filePath}`\n }\n\n // ...\n}\n```" - } - ] - } - ] - }, "parameters": [ { - "id": 14412, + "id": 15, "name": "fileData", "variant": "param", "kind": 32768, "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "The details of the file." - } - ] - }, "type": { "type": "reference", "target": { - "sourceFileName": "../../../packages/types/src/file-service/index.ts", - "qualifiedName": "GetUploadedFileType" + "sourceFileName": "../../../../packages/core/types/src/file/provider.ts", + "qualifiedName": "ProviderGetFileDTO" }, - "name": "GetUploadedFileType", + "name": "ProviderGetFileDTO", "package": "@medusajs/types" } } @@ -2194,184 +238,15 @@ }, "implementationOf": { "type": "reference", - "target": 14351, - "name": "IFileService.getPresignedDownloadUrl" + "target": -1, + "name": "IFileProvider.getPresignedDownloadUrl" } } ], "implementationOf": { - "type": "reference", - "target": 14350, - "name": "IFileService.getPresignedDownloadUrl" - } - }, - { - "id": 14413, - "name": "manager_", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/entity-manager/EntityManager.d.ts", - "qualifiedName": "EntityManager" - }, - "name": "EntityManager", - "package": "typeorm" - }, - "inheritedFrom": { "type": "reference", "target": -1, - "name": "TransactionBaseService.manager_" - }, - "implementationOf": { - "type": "reference", - "target": 14353, - "name": "IFileService.manager_" - } - }, - { - "id": 14414, - "name": "transactionManager_", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true - }, - "type": { - "type": "union", - "types": [ - { - "type": "intrinsic", - "name": "undefined" - }, - { - "type": "reference", - "target": { - "sourceFileName": "../../../node_modules/typeorm/entity-manager/EntityManager.d.ts", - "qualifiedName": "EntityManager" - }, - "name": "EntityManager", - "package": "typeorm" - } - ] - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.transactionManager_" - }, - "implementationOf": { - "type": "reference", - "target": 14354, - "name": "IFileService.transactionManager_" - } - }, - { - "id": 14417, - "name": "__container__", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isReadonly": true - }, - "type": { - "type": "intrinsic", - "name": "any" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.__container__" - }, - "implementationOf": { - "type": "reference", - "target": 14357, - "name": "IFileService.__container__" - } - }, - { - "id": 14418, - "name": "__configModule__", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isOptional": true, - "isReadonly": true - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.__configModule__" - }, - "implementationOf": { - "type": "reference", - "target": 14358, - "name": "IFileService.__configModule__" - } - }, - { - "id": 14419, - "name": "__moduleDeclaration__", - "variant": "declaration", - "kind": 1024, - "flags": { - "isProtected": true, - "isOptional": true, - "isReadonly": true - }, - "type": { - "type": "reference", - "target": { - "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts", - "qualifiedName": "Record" - }, - "typeArguments": [ - { - "type": "intrinsic", - "name": "string" - }, - { - "type": "intrinsic", - "name": "unknown" - } - ], - "name": "Record", - "package": "typescript" - }, - "inheritedFrom": { - "type": "reference", - "target": -1, - "name": "TransactionBaseService.__moduleDeclaration__" - }, - "implementationOf": { - "type": "reference", - "target": 14359, - "name": "IFileService.__moduleDeclaration__" + "name": "IFileProvider.getPresignedDownloadUrl" } } ], @@ -2379,50 +254,34 @@ { "title": "Constructors", "children": [ - 14389 + 3 ] }, { "title": "Properties", "children": [ - 14393, - 14394, - 14413, - 14414, - 14417, - 14418, - 14419 + 2 ] }, { "title": "Methods", "children": [ - 14395, - 14398, - 14401, - 14404, - 14407, - 14410 + 5, + 7, + 10, + 13 ] } ], - "extendedTypes": [ - { - "type": "reference", - "target": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService" - }, - "name": "TransactionBaseService", - "package": "@medusajs/medusa" - } - ], "implementedTypes": [ { "type": "reference", - "target": 14334, - "name": "IFileService", - "package": "@medusajs/medusa" + "target": { + "sourceFileName": "../../../../packages/core/types/src/file/provider.ts", + "qualifiedName": "IFileProvider" + }, + "name": "IFileProvider", + "package": "@medusajs/types" } ] } @@ -2431,445 +290,67 @@ { "title": "Classes", "children": [ - 14384 - ] - }, - { - "title": "Interfaces", - "children": [ - 14334 + 1 ] } ], - "packageName": "@medusajs/medusa", + "packageName": "@medusajs/utils", "symbolIdMap": { - "14333": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", + "0": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", "qualifiedName": "" }, - "14334": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService" + "1": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService" }, - "14335": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.upload" + "2": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.identifier" }, - "14336": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.upload" + "5": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.getIdentifier" }, - "14337": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", + "6": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.getIdentifier" + }, + "7": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.upload" + }, + "8": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.upload" + }, + "9": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", "qualifiedName": "file" }, - "14338": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.uploadProtected" + "10": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.delete" }, - "14339": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.uploadProtected" + "11": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.delete" }, - "14340": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", + "12": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", "qualifiedName": "file" }, - "14341": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.delete" + "13": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.getPresignedDownloadUrl" }, - "14342": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.delete" + "14": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", + "qualifiedName": "AbstractFileProviderService.getPresignedDownloadUrl" }, - "14343": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", + "15": { + "sourceFileName": "../../../../packages/core/utils/src/file/abstract-file-provider.ts", "qualifiedName": "fileData" - }, - "14344": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.getUploadStreamDescriptor" - }, - "14345": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.getUploadStreamDescriptor" - }, - "14346": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14347": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.getDownloadStream" - }, - "14348": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.getDownloadStream" - }, - "14349": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14350": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.getPresignedDownloadUrl" - }, - "14351": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "IFileService.getPresignedDownloadUrl" - }, - "14352": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14353": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.manager_" - }, - "14354": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.transactionManager_" - }, - "14355": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.activeManager_" - }, - "14356": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.activeManager_" - }, - "14357": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.__container__" - }, - "14358": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.__configModule__" - }, - "14359": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.__moduleDeclaration__" - }, - "14360": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.withTransaction" - }, - "14361": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.withTransaction" - }, - "14362": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "transactionManager" - }, - "14363": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.shouldRetryTransaction_" - }, - "14364": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.shouldRetryTransaction_" - }, - "14365": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "err" - }, - "14366": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14367": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type.code" - }, - "14368": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.atomicPhase_" - }, - "14369": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.atomicPhase_" - }, - "14370": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TResult" - }, - "14371": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TError" - }, - "14372": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "work" - }, - "14373": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14374": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14375": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "transactionManager" - }, - "14376": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "isolationOrErrorHandler" - }, - "14377": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14378": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14379": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "error" - }, - "14380": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "maybeErrorHandlerOrDontFail" - }, - "14381": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14382": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14383": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "error" - }, - "14384": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService" - }, - "14389": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.__constructor" - }, - "14390": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService" - }, - "14391": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "container" - }, - "14392": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "config" - }, - "14393": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.container" - }, - "14394": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.config" - }, - "14395": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.upload" - }, - "14396": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.upload" - }, - "14397": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14398": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.uploadProtected" - }, - "14399": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.uploadProtected" - }, - "14400": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14401": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.delete" - }, - "14402": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.delete" - }, - "14403": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14404": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.getUploadStreamDescriptor" - }, - "14405": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.getUploadStreamDescriptor" - }, - "14406": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14407": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.getDownloadStream" - }, - "14408": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.getDownloadStream" - }, - "14409": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14410": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.getPresignedDownloadUrl" - }, - "14411": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "AbstractFileService.getPresignedDownloadUrl" - }, - "14412": { - "sourceFileName": "../../../packages/medusa/src/interfaces/file-service.ts", - "qualifiedName": "fileData" - }, - "14413": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.manager_" - }, - "14414": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.transactionManager_" - }, - "14415": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.activeManager_" - }, - "14416": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.activeManager_" - }, - "14417": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.__container__" - }, - "14418": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.__configModule__" - }, - "14419": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.__moduleDeclaration__" - }, - "14420": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.withTransaction" - }, - "14421": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.withTransaction" - }, - "14422": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "transactionManager" - }, - "14423": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.shouldRetryTransaction_" - }, - "14424": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.shouldRetryTransaction_" - }, - "14425": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "err" - }, - "14426": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14427": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type.code" - }, - "14428": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.atomicPhase_" - }, - "14429": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TransactionBaseService.atomicPhase_" - }, - "14430": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TResult" - }, - "14431": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "TError" - }, - "14432": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "work" - }, - "14433": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14434": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14435": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "transactionManager" - }, - "14436": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "isolationOrErrorHandler" - }, - "14437": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14438": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14439": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "error" - }, - "14440": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "maybeErrorHandlerOrDontFail" - }, - "14441": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14442": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "__type" - }, - "14443": { - "sourceFileName": "../../../packages/medusa/src/interfaces/transaction-base-service.ts", - "qualifiedName": "error" } } } \ No newline at end of file diff --git a/www/utils/packages/typedoc-generate-references/src/constants/custom-options.ts b/www/utils/packages/typedoc-generate-references/src/constants/custom-options.ts index 8fda797dc1..46d26fc743 100644 --- a/www/utils/packages/typedoc-generate-references/src/constants/custom-options.ts +++ b/www/utils/packages/typedoc-generate-references/src/constants/custom-options.ts @@ -16,8 +16,8 @@ const customOptions: Record> = { name: "entities", }), file: getOptions({ - entryPointPath: "packages/medusa/src/interfaces/file-service.ts", - tsConfigName: "medusa.json", + entryPointPath: "packages/core/utils/src/file/abstract-file-provider.ts", + tsConfigName: "utils.json", name: "file", parentIgnore: true, }), diff --git a/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/file.ts b/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/file.ts index 915d96d00f..f07286f567 100644 --- a/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/file.ts +++ b/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/file.ts @@ -6,42 +6,89 @@ const fileOptions: FormattingOptionsType = { displayed_sidebar: "core", }, }, - "^file/.*AbstractFileService": { + "^file/.*AbstractFileProviderService": { reflectionGroups: { Properties: false, }, - reflectionDescription: `In this document, you’ll learn how to create a file service in the Medusa backend and the methods you must implement in it.`, + reflectionDescription: `In this document, you’ll learn how to create a file provider module and the methods you must implement in it.`, frontmatterData: { - slug: "/references/file-service", + slug: "/references/file-provider-module", }, reflectionTitle: { - fullReplacement: "How to Create a File Service", + fullReplacement: "How to Create a File Provider Module", }, + shouldIncrementAfterStartSections: true, + expandMembers: true, + startSections: [ + `## 1. Create Module Directory + +Start by creating a new directory for your module. For example, \`src/modules/my-file\`.`, + `## 2. Create the File Provider Service + +Create the file \`src/modules/my-file/service.ts\` that holds the implementation of the file service. + +The File Provider Module's main service must extend the \`AbstractFileProviderService\` class imported from \`@medusajs/utils\`: + +\`\`\`ts title="src/modules/my-file/service.ts" +import { AbstractFileProviderService } from "@medusajs/utils" + +class MyFileProviderService extends AbstractFileProviderService { + // TODO implement methods +} + +export default MyFileProviderService +\`\`\``, + ], endSections: [ - `## Test Implementation + `## 3. Create Module Definition File -:::note +Create the file \`src/modules/my-file/index.ts\` with the following content: -If you created your file service in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin). +\`\`\`ts title="src/modules/my-file/index.ts" +import MyFileProviderService from "./service" -::: - -After finishing your file service implementation: - -1\\. Run the \`build\` command in the root of your Medusa backend: - -\`\`\`bash npm2yarn -npm run build +export default { + service: MyFileProviderService, +} \`\`\` -2\\. Start the backend with the \`develop\` command: +This exports the module's definition, indicating that the \`MyFileProviderService\` is the main service of the module.`, + `## 4. Use Module -\`\`\`bash -npx medusa develop +To use your File Provider Module, add it to the \`providers\` array of the File Module: + + + +The File Module accepts one provider only. + + + +\`\`\`js title="medusa-config.js" +module.exports = { + // ... + modules: { + // ... + [Modules.FILE]: { + resolve: "@medusajs/file", + options: { + providers: [ + { + resolve: "./dist/modules/my-file", + options: { + config: { + "my-file": { + // provider options... + }, + }, + }, + }, + ], + }, + }, + }, +} \`\`\` - -3\\. Upload a file using the [Admin REST APIs](https://docs.medusajs.com/api/admin#uploads_postuploads) or using the Medusa admin, for example, to [upload a product's thumbnail](https://docs.medusajs.com/user-guide/products/manage#manage-thumbnails). - `, +`, ], }, } diff --git a/www/utils/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts b/www/utils/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts index 564203a3d0..4020184269 100644 --- a/www/utils/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts +++ b/www/utils/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts @@ -63,6 +63,7 @@ import getDeclarationChildrenHelper from "./resources/helpers/get-declaration-ch import ifShowSeparatorForTitleLevelHelper from "./resources/helpers/if-show-separator-for-title-level" import shouldExpandPropertiesHelper from "./resources/helpers/should-expand-properties" import shouldExpandDeclarationChildrenHelper from "./resources/helpers/should-expand-declaration-children" +import startSectionsHelper from "./resources/helpers/start-sections" import { MarkdownTheme } from "./theme" const TEMPLATE_PATH = path.join(__dirname, "resources", "templates") @@ -154,4 +155,5 @@ export function registerHelpers(theme: MarkdownTheme) { ifShowSeparatorForTitleLevelHelper(theme) shouldExpandPropertiesHelper(theme) shouldExpandDeclarationChildrenHelper(theme) + startSectionsHelper(theme) } diff --git a/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/start-sections.ts b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/start-sections.ts new file mode 100644 index 0000000000..4098965b37 --- /dev/null +++ b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/start-sections.ts @@ -0,0 +1,22 @@ +import * as Handlebars from "handlebars" +import { MarkdownTheme } from "../../theme" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper("startSections", function () { + const { startSections, shouldIncrementAfterStartSections } = + theme.getFormattingOptionsForLocation() + + if (!startSections?.length) { + return "" + } + + const lineBreaks = "\n\n" + const separator = `---${lineBreaks}` + + if (shouldIncrementAfterStartSections) { + Handlebars.helpers.incrementCurrentTitleLevel() + } + + return `${separator}${startSections.join(`${lineBreaks}${separator}`)}` + }) +} diff --git a/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs index fc41b15f9c..8895ff8926 100644 --- a/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs +++ b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs @@ -2,6 +2,8 @@ {{incrementCurrentTitleLevel}} +{{{ startSections }}} + {{#with model.readme}} {{{comment this}}} diff --git a/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs index bf6a6fca25..a725b75ad6 100755 --- a/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs +++ b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs @@ -4,6 +4,8 @@ {{incrementCurrentTitleLevel}} +{{{ startSections }}} + {{#with model}} {{#if (sectionEnabled "reflection_comment")}} diff --git a/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs index 03354e0073..d424dd2d46 100644 --- a/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs +++ b/www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs @@ -6,6 +6,8 @@ {{incrementCurrentTitleLevel}} +{{{ startSections }}} + {{> member showSources=false}} {{decrementCurrentTitleLevel}} diff --git a/www/utils/packages/types/lib/index.d.ts b/www/utils/packages/types/lib/index.d.ts index 0c4c577dc4..952f17f187 100644 --- a/www/utils/packages/types/lib/index.d.ts +++ b/www/utils/packages/types/lib/index.d.ts @@ -75,7 +75,9 @@ export type FormattingOptionType = { mdxImports?: string[] maxLevel?: number fileNameSeparator?: string + startSections?: string[] endSections?: string[] + shouldIncrementAfterStartSections?: boolean } export declare module "typedoc" {