Commit Graph

4595 Commits

Author SHA1 Message Date
Siddharth Kulkarni
5c6ba674fb docs: update link to io-redis options (#6337)
…ties

Update redis.md to correct the documentation link to io-redis propoerties.   Current Link was incorrect.
2024-02-07 12:55:21 +00:00
Oli Juhl
82c728bec7 feat(medusa): Allow configuring of staged job polling batch size (#6333) 2024-02-07 10:35:49 +01:00
Ira
44470bf8c5 Update all curl documentation examples and references with new x-medusa-access-token header (#6326)
## What

This is to update incorrect documentation in regards to authentication to the Admin API - raised in https://github.com/medusajs/medusa/issues/6264.

## Why

Because the current documentation has been incorrect since the September 2023 release of [v1.17.0](https://github.com/medusajs/medusa/releases/tag/v1.17.0), which had breaking changes to API token usage.

## How

Simple search and replace. I was asked to replace occurrences under `www/apps/docs/content/` but there were also additional places where I thought references should also be updated:

- `packages/medusa/src/api/`
- `www/apps/api-reference/`

Feel free to revert them as needed.

There is also some inconsistency between the format shown in examples e.g. `<API_TOKEN>` vs `{api_token}` vs `{access_token}`.

I have kept the format the same in all cases as the original, as surrounding documentation text would not have format updated as well. I suggest maybe reviewing the documentation and keeping to a consistent format e.g. `<API_TOKEN>`.

 
## Testing 

I have not tested these changes. I would assume the `packages/medusa/src/api/` changes may need more thorough testing?
2024-02-07 08:41:38 +00:00
Oli Juhl
e2cb72efd8 feat(region): Add migration (#6320) 2024-02-06 19:58:16 +01:00
Adrien de Peretti
12054f5c01 feat: Fulfillment module basic structure (#6319)
**What**
Scafold the fulfillment module basic structure

**Bonus**
Simplified module scaffolding with new factories and less directories to manage
- mikro orm connection loader factory
- initialize factory

FIXES CORE-1709
FIXES CORE-1710
2024-02-06 13:29:36 +00:00
Frane Polić
2104843826 feat(payment): payment and session methods (#6138) 2024-02-06 13:40:22 +01:00
xyzones
5cabe9585f docs: s3 The "images.domains" configuration is deprecated (#6321) 2024-02-06 09:57:52 +00:00
Philip Korsholm
882aa549bd Feat(auth): Remove auth provider entity (#6314)
**What**
- remove auth provider entity

**Why**
- The auth provider entity was not really used anywhere

**How**
- Keeping loader behavior as is but removing the 

Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
2024-02-06 07:54:34 +00:00
Philip Korsholm
b2eaac8cb1 feat(user): Init user module (#6293)
* init user module

* add migration

* update module with latest utils

* pr ready

* make interface types interfaces
2024-02-06 11:10:54 +08:00
Oli Juhl
823b98aaa1 feat: Region Module (basic CRUD) (#6315) 2024-02-05 16:03:26 +00:00
Oli Juhl
ede221d4f7 feat(cart): POST /store/carts (#6273)
Depends on #6262
2024-02-05 15:15:15 +00:00
Carlos R. L. Rodrigues
884428a1b5 feat: event aggregator (#6218)
What:
- Event Aggregator Util
- Preparation for normalizing event in a new format (backward compatible with the current format)
- GQL Schema to joiner config and some Entities configured
- Link modules emmiting events
2024-02-05 11:59:10 +00:00
Kasper Fabricius Kristensen
73fd92a1af feat(dashboard): Log in, reset password, and accept invite pages (#6310) 2024-02-05 11:16:10 +01:00
Erik Engervall
b1276cfcd5 feat(medusa-react): Add medusaClient prop to MedusaProvider (#6299) 2024-02-05 09:56:57 +01:00
Philip Korsholm
e2738ab91d feat(auth): Make token auth default (#6305)
**What**
- make token auth the default being returned from authentication endpoints in api-v2
- Add `auth/session` to convert token to session based auth
- add regex-scopes to authenticate middleware 

Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
2024-02-05 08:17:08 +00:00
Carlos R. L. Rodrigues
96ba49329b fix: load custom modules by path (#6312)
What:
medusa-config.js loading custom modules by their path.

```typescript
{
  modules: {
    internalModule: {
      scope: MODULE_SCOPE.INTERNAL,
      resources: MODULE_RESOURCE_TYPE.SHARED,
      resolve: "./internal_module",
      definition: {
        key: "internalModule",
        registrationName: "internalModule",
      },
    },
  }
}
```
2024-02-04 14:26:34 +00:00
Erik Engervall
58baead34e fix(admin-ui) Refactor use-copy-promotion to map product IDs (#6306) 2024-02-04 14:18:54 +01:00
Kasper Fabricius Kristensen
8cbf6c60fe feat(dashboard): DataTable component (#6297) 2024-02-02 21:56:55 +01:00
Adrien de Peretti
a7be5d7b6d chore: Abstract module service (#6188)
**What**
- Remove services that do not have any custom business and replace them with a simple interfaces
- Abstract module service provide the following base implementation
  - retrieve
  - list
  - listAndCount
  - delete
  - softDelete
  - restore

The above methods are created for the main model and also for each other models for which a config is provided

all method such as list, listAndCount, delete, softDelete and restore are pluralized with the model it refers to

**Migration**
- [x] product
- [x] pricing
- [x] promotion
- [x] cart
- [x] auth
- [x] customer
- [x] payment
- [x] Sales channel
- [x] Workflow-*


**Usage**

**Module**

The module service can now extend the ` ModulesSdkUtils.abstractModuleServiceFactory` which returns a class with the default implementation for each method and each model following the standard naming convention mentioned above.
This factory have 3 template arguments being the container, the main model DTO and an object representing the other model with a config object that contains at list the DTO and optionally a singular and plural property in case it needs to be set manually. It looks like the following:

```ts
export default class PricingModuleService</* ... */>
  extends ModulesSdkUtils.abstractModuleServiceFactory<
    InjectedDependencies,
    PricingTypes.PriceSetDTO,
    {
      Currency: { dto: PricingTypes.CurrencyDTO }
      MoneyAmount: { dto: PricingTypes.MoneyAmountDTO }
      PriceSetMoneyAmount: { dto: PricingTypes.PriceSetMoneyAmountDTO }
      PriceSetMoneyAmountRules: {
        dto: PricingTypes.PriceSetMoneyAmountRulesDTO
      }
      PriceRule: { dto: PricingTypes.PriceRuleDTO }
      RuleType: { dto: PricingTypes.RuleTypeDTO }
      PriceList: { dto: PricingTypes.PriceListDTO }
      PriceListRule: { dto: PricingTypes.PriceListRuleDTO }
    }
  >(PriceSet, generateMethodForModels, entityNameToLinkableKeysMap)
  implements PricingTypes.IPricingModuleService
{
// ...
}
```

In the above, the singular and plural can be inferred as there is no tricky naming. Also, the default implementation does not remove the fact that you need to provides all the overloads etc in your module service interface. The above will provide a default implementation following the interface `AbstractModuleService` which is also auto generated, hence you will have the following methods available:

**for the main model**
- list
- retrieve
- listAndCount 
- delete
- softDelete
- restore


**for the other models**
- list**MyModels**
- retrieve**MyModel**
- listAndCount**MyModels**
- delete**MyModels**
- softDelete**MyModels**
- restore**MyModels**

**Internal module service**

The internal module service can now extend `ModulesSdkUtils.internalModuleServiceFactory` which takes only one template argument which is the container type. 
All internal services provides a default implementation for all retrieve, list, listAndCount, create, update, delete, softDelete, restore methods which follow the following interface `ModulesSdkTypes.InternalModuleService`:

```ts
export interface InternalModuleService<
  TEntity extends {},
  TContainer extends object = object
> {
  get __container__(): TContainer

  retrieve(
    idOrObject: string,
    config?: FindConfig<any>,
    sharedContext?: Context
  ): Promise<TEntity>
  retrieve(
    idOrObject: object,
    config?: FindConfig<any>,
    sharedContext?: Context
  ): Promise<TEntity>

  list(
    filters?: FilterQuery<any> | BaseFilterable<FilterQuery<any>>,
    config?: FindConfig<any>,
    sharedContext?: Context
  ): Promise<TEntity[]>

  listAndCount(
    filters?: FilterQuery<any> | BaseFilterable<FilterQuery<any>>,
    config?: FindConfig<any>,
    sharedContext?: Context
  ): Promise<[TEntity[], number]>

  create(data: any[], sharedContext?: Context): Promise<TEntity[]>
  create(data: any, sharedContext?: Context): Promise<TEntity>

  update(data: any[], sharedContext?: Context): Promise<TEntity[]>
  update(data: any, sharedContext?: Context): Promise<TEntity>
  update(
    selectorAndData: {
      selector: FilterQuery<any> | BaseFilterable<FilterQuery<any>>
      data: any
    },
    sharedContext?: Context
  ): Promise<TEntity[]>
  update(
    selectorAndData: {
      selector: FilterQuery<any> | BaseFilterable<FilterQuery<any>>
      data: any
    }[],
    sharedContext?: Context
  ): Promise<TEntity[]>

  delete(idOrSelector: string, sharedContext?: Context): Promise<void>
  delete(idOrSelector: string[], sharedContext?: Context): Promise<void>
  delete(idOrSelector: object, sharedContext?: Context): Promise<void>
  delete(idOrSelector: object[], sharedContext?: Context): Promise<void>
  delete(
    idOrSelector: {
      selector: FilterQuery<any> | BaseFilterable<FilterQuery<any>>
    },
    sharedContext?: Context
  ): Promise<void>

  softDelete(
    idsOrFilter: string[] | InternalFilterQuery,
    sharedContext?: Context
  ): Promise<[TEntity[], Record<string, unknown[]>]>

  restore(
    idsOrFilter: string[] | InternalFilterQuery,
    sharedContext?: Context
  ): Promise<[TEntity[], Record<string, unknown[]>]>

  upsert(data: any[], sharedContext?: Context): Promise<TEntity[]>
  upsert(data: any, sharedContext?: Context): Promise<TEntity>
}
```

When a service is auto generated you can use that interface to type your class property representing the expected internal service.

**Repositories**

The repositories can now extend `DALUtils.mikroOrmBaseRepositoryFactory` which takes one template argument being the entity or the template entity and provides all the default implementation. If the repository is auto generated you can type it using the `RepositoryService` interface. Here is the new interface typings.

```ts
export interface RepositoryService<T = any> extends BaseRepositoryService<T> {
  find(options?: FindOptions<T>, context?: Context): Promise<T[]>

  findAndCount(
    options?: FindOptions<T>,
    context?: Context
  ): Promise<[T[], number]>

  create(data: any[], context?: Context): Promise<T[]>

  // Becareful here, if you have a custom internal service, the update data should never be the entity otherwise
 // both entity and update will point to the same ref and create issues with mikro orm
  update(data: { entity; update }[], context?: Context): Promise<T[]>

  delete(
    idsOrPKs: FilterQuery<T> & BaseFilterable<FilterQuery<T>>,
    context?: Context
  ): Promise<void>

  /**
   * Soft delete entities and cascade to related entities if configured.
   *
   * @param idsOrFilter
   * @param context
   *
   * @returns [T[], Record<string, string[]>] the second value being the map of the entity names and ids that were soft deleted
   */
  softDelete(
    idsOrFilter: string[] | InternalFilterQuery,
    context?: Context
  ): Promise<[T[], Record<string, unknown[]>]>

  restore(
    idsOrFilter: string[] | InternalFilterQuery,
    context?: Context
  ): Promise<[T[], Record<string, unknown[]>]>

  upsert(data: any[], context?: Context): Promise<T[]>
}
```
2024-02-02 14:20:32 +00:00
Riqwan Thamir
abc30517cb feat(): added percentage calculations for all cases (#6300)
what:

- adds missing percentage calculations for items and shipping methods
2024-02-02 11:39:34 +00:00
Philip Korsholm
9fda6a6824 feat(auth): add authentication endpoints (#6265)
**What**
- Add authentication endpoints: 
  - `/auth/[scope]/[provider]` 
  - `/auth/[scope]/[provider]/callback`
- update authenticate-middleware handler
- Add scope field to user
- Add unique constraint on scope and entity_id

note: there's still some remaining work related to jwt auth to be handled, this is mainly focussed on session auth with endpoints



Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
2024-02-02 10:45:32 +00:00
Mohammad Awais
061c449179 [FIX] [Typo] Cart -> Card (#6302) 2024-02-01 20:36:37 +00:00
Oli Juhl
3a103f0c36 feat(modules-sdk): Module provider plugin loader (#6286) 2024-02-01 17:03:31 +01:00
Carlos R. L. Rodrigues
45134e4d11 chore: local workflow proxying methods to pass context (#6263)
What:
- When calling a module's method inside a Local Workflow the MedusaContext is passed as the last argument to the method if not provided
- Add `requestId` to req
- A couple of fixes on Remote Joiner and the data fetcher for internal services

Why:
- The context used to initialize the workflow has to be shared with all modules. properties like transactionId will be used to emit events and requestId to trace logs for example.
2024-02-01 13:37:26 +00:00
Sebastian Rindom
a2bf6756ac feat(customer): manage default address selection (#6295)
**What**
- Catches unique constraints on customer_id, is_default_billing/is_default_shipping and reformats
- Adds an step to create and update of addresses that unsets the previous default shipping/billing address if necessary.
  - This creates a behavior in the API where you can always set an address to be default and it will automatically unset the previous one for you.
2024-02-01 12:28:14 +00:00
Sebastian Rindom
a28822e0d4 feat(customer): store addresses (#6283)
- GET /customers/me/addresses
- POST /customers/me/addresses
- GET /customers/me/addresses/:address_id
- POST /customers/me/addresses/:address_id
- DELETE /customers/me/addresses/:address_id
2024-02-01 10:11:52 +00:00
github-actions[bot]
fab1799841 chore(docs): Removed Docs Announcement Bar (automated) (#6278)
Co-authored-by: shahednasser <shahednasser@users.noreply.github.com>
2024-01-31 20:33:25 +01:00
Oli Juhl
d5e4707084 feat(medusa): Use remote query in get cart API route (#6285) 2024-01-31 19:20:48 +01:00
Shahed Nasser
2cebadc3a8 docs: fix title of the configuration page (#6268)
Fix the title of the configurations page which is generated by typedoc
2024-01-31 13:50:34 +00:00
Riqwan Thamir
e749dd653c feat(types): added computed actions for automatic promotions (#6272)
what:

- compute actions account for automatic promotions (RESOLVES CORE-1701)

RESOLVES CORE-1689
2024-01-31 12:30:33 +00:00
Sebastian Rindom
7903a15e0f feat(customer): Add create and retrieve customer from store side (#6267)
**What**
- GET /store/customers/me
- POST /store/customers
- Workflow for customer account creation
- Authentication middleware on customer routes
2024-01-31 11:58:29 +00:00
Sebastian Rindom
f41877ef61 feat(customer): add customer group customer management (#6276)
**What**
- GET /admin/customer-groups/:id/customers
- POST /admin/customer-groups/:id/customers/batch
- POST /admin/customer-groups/:id/customers/remove

Workflows
2024-01-31 10:24:22 +00:00
Sebastian Rindom
36ec3ea3aa feat(customer): admin addresses (#6235)
**What**
- GET /admin/customers/:id/addresses
- POST /admin/customers/:id/addresses
- POST /admin/customers/:id/addresses/:address_id
- DELETE /admin/customers/:id/addresses/:address_id
2024-01-31 09:55:07 +00:00
Sebastian Rindom
ca0e0631af feat(customer): add customer group management apis (#6233)
**What**
```
POST /admin/customer-groups
POST /admin/customer-groups/:id
GET /admin/customer-groups/:id
DELETE /admin/customer-groups/:id
```

- Workflows
2024-01-30 19:37:53 +00:00
Shahed Nasser
8c7a031090 docs: refactoring of docblock generator tool (#6261)
small refactoring of the docblock generator tool that moves all git operations and requests into the `GitManager`
2024-01-30 17:01:54 +00:00
Kasper Fabricius Kristensen
1100c21c63 feat(dashboard): Users domain (#6212) 2024-01-30 17:20:06 +01:00
Philip Korsholm
7d5a6f8b00 feat(auth, medusa): Initial auth module middleware (#6271)
note: This is an initial implementation

Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
2024-01-30 12:23:20 +00:00
Oli Juhl
374b9b1fee feat(cart): GET /store/carts/:id (#6262) 2024-01-30 12:52:54 +01:00
Sebastian Rindom
18ff739a94 feat(customer): admin CRUD endpoints (#6232)
**What**

- GET /customers/:id
- POST /customers/:id
- DELETE /customers/:id
- POST /customers

Including workflows for each.
2024-01-30 11:43:30 +00:00
Riqwan Thamir
328eb85a8b feat(): added compute actions for buyget promotions (#6255)
what:

- computes actions for buyget promotion (RESOLVES CORE-1700)
2024-01-30 10:32:16 +00:00
Oli Juhl
1c27f7cb34 chore(cart): Clean up data models (#6256)
Clean up data models in Cart Module according to latest established conventions
2024-01-29 18:22:13 +00:00
Sebastian Rindom
87390704be feat(customer): list customer (#6206)
**What**

- GET /admin/customers
- GET /admin/customer-groups
2024-01-29 16:56:39 +00:00
Kasper Fabricius Kristensen
90cff0777f fix(medusa): add support for order field on GET /admin/orders (#6258)
**What**
- Adds support for `order` field on `GET /admin/orders`
2024-01-29 16:00:45 +00:00
Philip Korsholm
8ec093dc07 fix(authentication): remove providers loader (#6257)
**What**
- remove file leftover from renaming authentication -> auth
2024-01-29 15:38:31 +00:00
Riqwan Thamir
10c67ecd74 chore(core-flows): reorganize folder structure for promotion workflows (#6243)
workflows folder structure:

```
- src/
  - promotion/
    - workflows/
      - create-promotion.ts
    - steps/
      - prepare-create-promotion-data.ts
```

RESOLVES CORE-1688
2024-01-29 14:35:59 +00:00
Oli Juhl
c15438c744 feat(cart): Migration file (#6156)
* feat(cart): Migration file

* fixup migration

* Add indexes on cart table for currency, region, and sales channel

* fix indexes

* address PR comments
2024-01-29 12:49:48 +01:00
Philip Korsholm
512b041929 Feat(auth): Rename authentication to auth (#6229)
**What**
- rename `authenticationModule` -> `authModule`
2024-01-29 10:19:30 +00:00
Philip Korsholm
a41aad4bea feat(authentication, types, utils): Add Authentication provider scopes (#6228)
* initial implementation

* add test for invalid scope

* get config from scope not db

* assign config from scope

* fix package.json

* optional providers

* make providers options

* update type
2024-01-29 17:42:42 +08:00
Philip Korsholm
d1c18a3090 feat(medusa, stock-location, types): Add q and order params to list-stock-locations (#6197)
**What**
- add `q` and `order` params to list-stock-location endpoint

closes #6189
2024-01-29 09:14:39 +00:00
Frane Polić
3db2f95e65 feat: sales channel module (#5923) 2024-01-29 09:47:28 +01:00