Commit Graph

106 Commits

Author SHA1 Message Date
Carlos R. L. Rodrigues
ad7f56506f Feat(medusa,modules-sdk): Modules SDK package (#3294) 2023-02-23 13:09:35 -03:00
olivermrbl
e1b92e9b04 fix: Merge conflicts with master 2023-02-22 17:38:49 +01:00
olivermrbl
fefc248a41 chore(release): v1.7.8 2023-02-22 13:13:48 +01:00
Patrick
e8e7d7bb53 fix(medusa-dev): include packages/ subdirectories in discovery (#3293)
## What

Include packages/ subdirectories in medusa-dev packages discovery.

## Why

We started to use subdirectories in the monorepo `packages/` directory in order to better organize packages.

Packages in subdirectories were invisible to `medusa-dev` and could not be copied.

## How

Rely on monorepo package.json workspace glob patterns to discover packages that can be published to the local npm registry.
2023-02-21 16:12:02 +00:00
Patrick
1c40346e9e feat(codegen): openapi-typescript-codegen fork (#3272)
## What

Allow `medusa-oas` CLI to generate API client code from an OAS json file.

## Why

Manually maintaining API clients is time consuming and error prone. We wish to automate the process by using code generation strategies.

We also wish to eliminate direct import from `@medusajs/medusa` in clients which can lead to unwanted side effects like importing unnecessary dependencies.

## How

Fork and customize an OAS code generator library that is TypeScript friendly.

Attempt to match the interface and signature of our current client packages: `@medusajs/medusa-js`, `medusa-react`

Add a new `client` command to the `medusa-oas` CLI as the main interface to interact with the code generation tooling.

## Test

### Prerequisites 
* From the root of the monorepo:
* `yarn install`
* `yarn build`

### Case - all in one build
* From the root of the monorepo:
* Run `yarn medusa-oas oas --out-dir ~/tmp/oas --type store`
* Run `yarn medusa-oas client --src-file ~/tmp/oas/store.oas.json --out-dir ~/tmp/client-store --type store`
* Expect `~/tmp/client-store` to contain the following files and directories:
```
core/
hooks/
models/
services/
index.ts
MedusaStore.ts
useMedusaStore.tsx
```

### Case - types only
* From the root of the monorepo:
* Run `yarn medusa-oas oas --out-dir ~/tmp/oas --type store`
* Run `yarn medusa-oas client --src-file ~/tmp/oas/store.oas.json --out-dir ~/tmp/client-types --type store --component types`
* Expect `~/tmp/client-types` to contain the following files and directories:
```
models/
index.ts
```

### Case - client only
* From the root of the monorepo:
* Run `yarn medusa-oas oas --out-dir ~/tmp/oas --type store`
* Run `yarn medusa-oas client --src-file ~/tmp/oas/store.oas.json --out-dir ~/tmp/client-only --type store --component client --types-package @medusajs/client-types`
* Expect `~/tmp/client-only` to contain the following files and directories:
```
core/
services/
index.ts
MedusaStore.ts
```
2023-02-20 20:50:39 +00:00
Riqwan Thamir
121b42acfe chore(medusa): Typeorm upgrade to 0.3.11 (#3041) 2023-02-15 16:25:30 +01:00
Patrick
8137061908 feat(oas): medusa-oas-cli as OAS build tool (#3213)
## What

Introduce a CLI for extracting OAS from the core `medusa` package.

## Why

We need to decouple OAS tooling from documentation tooling in order to allow packages and external systems to leverage our OAS has a dependency.

## How

Introduce a new OAS workspace within packages in order to organize current and future OAS related package. Only 1 OAS package for now.

Introduce a new CLI only package to act as the main gateway for all upcoming OAS tooling. Only 1 command for now.

Update documentation tooling pertaining to OAS to use the CLI instead.

## Test

### Prerequisite
From the monorepo root:
* `yarn install`
* `yarn build`

### Documentation

#### Case - validation only - success
* Run `yarn openapi:generate --dry-run`
* Expect console output `🟢 Valid OAS` but no mention of `🔵 Exported OAS`

#### Case - validation only - invalid
* Introduce a bug by renaming `@schema Cart` to `@schema Kart` in [models/cart.ts](0adb0d9ff9/packages/medusa/src/models/cart.ts (L2))
* Run `yarn build` to update `@medusajs/medusa` package with the bug.
* Run `yarn openapi:generate --dry-run`
* Expect console output `🔴 Invalid OAS` with a stack trace of the issue.

#### Case - docs generation
* Run `yarn openapi:generate`
* Expect `docs/api/` directory to contain:
  * `admin.oas.json` (raw OAS)
  * `store.oas.json` (raw OAS)
  * `admin.oas.yaml` (sanitized OAS)
  * `store.oas.yaml` (sanitized OAS)
  * `admin/` (updated redocly split output)
  * `store/` (updated redocly split output)

### CLI

#### Case - crawl additional paths
* From a local medusa server (`medusa-starter-default`), add an `index.ts` file in `src/models/`
* In the `index.ts`, add dummy OAS JSDoc like `/** @schema Foobar */`
* From the root of the monorepo, run `yarn medusa-oas --type store --paths path-to-medusa-server/src`
* Expect a `store.oas.json` to be created at the root of the monorepo.
* The `store.oas.json` should contain an additional `Foobar` entry in `components.schemas`.
2023-02-15 14:55:58 +00:00
olivermrbl
1bfbe27b9b chore(release): Publish 2023-02-14 17:30:40 +01:00
olivermrbl
3b474ec35c chore(release): Publish 2023-02-08 19:35:44 +01:00
Patrick
53532df8d5 feat(OAS): sanitize circular reference for Redocly (#3198)
### What

Add OAS build step to patch known circular references that prevent Redocly from rendering the API documentation.

### Why

We've encountered crashing and loading issues with Redocly when the OAS contained circular references. We have been working around the limitation by omitting some known problematic $ref in our source OAS. We wish to move away from this strategy in order to always explicitly include $ref in our OAS.

### How

We are introducing a custom Redocly CLI plugin that will replace `$ref` by `type: object` base on a configurable set of instructions. These instructions can be modified in `docs-util/redocly/config.yaml`

We are adding a `redocly bundle` step in the current OAS build process in order to sanitize problematic circular references.

We updated the redocly-cli package version in order to ensure that plugins are supported.

### Test

We will use [Cart.payment](fd5c185159/packages/medusa/src/models/cart.ts (L72-L74)) to ensure that the new process is properly sanitizing.

* Run `yarn openapi:generate`
* Open `docs/api/store/components/schemas/Cart.yaml`
  * Expect the `payment` property to have been sanitized to `type: object`
* Run `yarn redocly preview-docs docs/api/store/openapi.yaml --config=docs-util/redocly/config.yaml`
* Visit http://127.0.0.1:8080/#tag/Cart/operation/GetCartsCart
  * In the response, expect cart.payment to not list the properties of the Payment schema.
2023-02-08 13:01:03 +00:00
Oliver Windall Juhl
08324355a4 chore: Patch bump all dependencies + minor bumps winston (#3185) 2023-02-07 19:15:29 +01:00
Kasper Fabricius Kristensen
4fbf6b7ad3 fix(medusa-react): Fix production.min.js causing invalid hook usage error in CJS environments (#3144) 2023-02-01 14:07:02 +01:00
olivermrbl
a48c533bec chore(release): Publish 2023-01-19 18:29:07 +01:00
olivermrbl
6481b0c357 chore(release): Publish 2023-01-18 18:48:57 +01:00
olivermrbl
ab580066ae fix: Merge conflicts with master 2023-01-18 10:17:39 +01:00
Kasper Fabricius Kristensen
cb25244007 hotfix(medusa-js, medusa-react): Fix issue with JS client bundle (#3038) 2023-01-16 17:44:24 +01:00
Kasper Fabricius Kristensen
8d1275c942 feat(medusa-react): Upgrade react-query and clean up dependencies (#2969) 2023-01-11 19:19:34 +01:00
olivermrbl
a8bde8ba74 chore(release): Publish 2023-01-11 16:27:54 +01:00
Carlos R. L. Rodrigues
93ee248493 feat(medusa, inventory): Inventory Management module (#2956)
* feat: inventory module
2023-01-10 14:38:30 -03:00
Kasper Fabricius Kristensen
f6c81dab9e feat(medusa-js): Bundle package using Rollup (#2964) 2023-01-10 14:44:25 +01:00
Riqwan Thamir
b280e53bd3 refactor(medusa): move repository specs into its own folder (#2952)
**What:**

Introduces a new folder under which repository specs will be placed. 

Why:

We don't currently have a good place to test ORM logic or custom queries against the database. The repository folder tests are a place for just exactly that. 

How:

Creates an internal package similar to other integration tests - api and plugins. 

CORE-965
2023-01-09 08:19:01 +00:00
Carlos R. L. Rodrigues
c07ffb6165 feat(medusa): Stock location module (#2907)
* feat: stock location module
2023-01-04 13:11:59 -03:00
Shahed Nasser
d1b4b11ff6 chore(docs): added eslint to lint documentation code blocks (#2920)
* docs: added rule for code length

* chore: fixes based on vale errors

* changed to use eslint

* fixes using eslint

* added github action for documentation eslint

* changed allowed max-length

* fixed incorrect heading level

* removed comment
2022-12-30 18:44:46 +02:00
olivermrbl
233d6904f8 chore(release): Publish 2022-12-22 15:54:20 +01:00
Patrick
0a9c891853 chore: explicitly add devDependencies for monorepo peerDependencies (#2808) 2022-12-15 08:46:52 +01:00
Patrick
7bb9cd6aff fix(medusa-js): missing devDependency was failing repo build task (#2804)
### What

Explicitly declare `@medusajs/medusa` as a devDependency for `@medusajs/medusa-js` client package.

### Why

With our latest version upgrade of `turbo`, peerDependencies aren't taken into account in the build graph. The recommendation is to also explicitly declare them in devDependencies.

### Test

* Run `yarn build --graph`
* Expect to see medusa-js having a dependency on medusa
```
"[root] @medusajs/medusa-js#build" -> "[root] @medusajs/medusa#build"
```
2022-12-14 16:46:08 +00:00
olivermrbl
8edf6a06ee Merge branch 'master' into develop 2022-12-14 14:47:23 +01:00
olivermrbl
01d521ed40 chore(medusa-js): Version package + add missing changeset 2022-12-14 09:37:20 +01:00
Patrick
17c3f34e3d chore(turbo): flip turbo caching glob from allow-list to deny-list (#2772)
### What

Flip Turborepo cache glob pattern from an allow-list to deny-list pattern.

### Why

Packages within medusa's monorepo will output their build to a `dist` directory. 

This convention does not apply to plugins since the core plugin loader expects the content of plugin packages `src` directory to be outputted at the root of the package. 

i.e. `packages/foobar-plugin/src/utils/index.ts` -> `packages/foobar-plugin/utils/index.js`

Manually maintaining an allow-list of known plugin output directories is not scalable. When a directory exists in a plugin package but is not know to the allow-list, the directory will not be re-built on subsequent builds. Troubleshooting the issue requires intimate knowledge of Turborepo caching strategies.

### How

By using a deny-list glob pattern, plugin packages can now declare any not-known directory within their `src` folder without facing any potential omission issues during the build process.

We declare `src` and its content as the only directory for turbo cache to ignore.

### Additional scope

* Use `turbo.json` file content in cache hashing algorithm in order to break CI cache when changes are made to the Turborepo config.
* Upgraded turbo minor verion.
* Added missing dependency to medusa package.

### Test
* Delete previously built output in packages. Run `yarn build --force` (replace any existing cache)
  * Expect all src content to be outputted
* Run `yarn build` right after
  * Expect a fast build time since cache will be fresh
* Add a new directory with an index.ts file in a plugin package src folder. Run `yarn build` 
  * Expect a fast build time, except for the modified plugin package.
  * Expect the newly added directory to be outputted.
* Delete the newly outputted directory. Run `yarn build`
  * Expect the outputted directory to reappear. 

### References
* 5093b82f3a/packages/medusa/src/loaders/plugins.ts
* https://turbo.build/repo/docs/reference/configuration#outputs
* https://turbo.build/repo/docs/reference/configuration#globaldependencies

Resolves CORE-891
2022-12-13 17:59:48 +00:00
olivermrbl
29135c0519 chore(release): Publish 2022-12-13 10:34:07 +01:00
Patrick
86f9455d00 test: allow integration-tests to leverage workspaces optimizations (#2727)
### What
Leverage yarn workspaces and Turborepo for integration-tests in order to accelerate development and reduce DevX complexity.

### Why
The current solution for running integration tests requires using `medusa-dev-cli` in order to publish packages to a local npm repository. The package where the command is executed will have its package.json altered for any known medusa dependency in order to install from the local npm. The process is taxing on the host machine resources and prevents rapid iterations when working with integration tests.

For more information, see documentation: f0cc1b324c/docs/content/usage/local-development.md (run-api-integration-tests)

### How
By declaring `integeration-tests/**/*` as a workspace, Turborepo can now be leveraged to build and run integration test as if there were packages. The build process will take care of interdependency between package in order to ensure local dependency are met.

In addition, within each integration-tests "packages", we can declare local dependencies as "*" which will translate to using the one that is part of the current build, regardless of the dependency's version number. No more fiddling with version numbers.

Github actions pertaining to integration-tests have been streamlined to use the new behavior.

The integration-tests packages have been marked as `private:true` in order to avoid publishing them to the public npm registry.

### Testing
```
cd root-of-medusajs-medusa-repo/
yarn install
yarn build
yarn test:integration:api
yarn test:integration:plugins
```

After a code change, `yarn build` must be run before re-running an integration test, which is the same procedure as for unit tests.

Resolves: CORE-845
2022-12-08 14:57:16 +00:00
Adrien de Peretti
1b21af87ab chore(medusa-core-utils): Migrate to TS (#2670) 2022-12-05 10:21:04 +01:00
Adrien de Peretti
e18b59de66 chore: Update Awilix to v8 (#2668) 2022-11-25 13:56:22 +01:00
olivermrbl
105c689298 chore(release): Publish 2022-11-24 11:42:04 +01:00
olivermrbl
a4d75f4a40 fix: merge conflicts with develop 2022-11-22 13:39:27 +01:00
olivermrbl
ade898d434 chore(release): Publish 2022-11-22 13:35:50 +01:00
Philip Korsholm
5332081972 fix(medusa, medusa-plugin-discount-generator, medusa-plugin-restock-notification): Bump Medusa package versions (#2623) 2022-11-18 10:50:13 +01:00
olivermrbl
a4dd26e137 chore(release): Publish 2022-11-09 19:34:59 +01:00
olivermrbl
a68af8a474 chore: Update lockfile 2022-11-04 13:32:23 +01:00
olivermrbl
ee8a71c692 chore(release): Publish 2022-11-02 16:44:54 +01:00
Carlos R. L. Rodrigues
b88cef2b1f feat: Development server for core + plugins (#2448) 2022-10-21 15:53:06 +02:00
Shahed Nasser
479ae1e257 docs: Added automated freshness check (#2428)
* docs: created freshness check script

* added github action
2022-10-17 10:01:45 +03:00
olivermrbl
35df4962f8 chore(release): Publish 2022-10-10 18:02:50 +02:00
Shahed Nasser
31fb4c3d3f docs: automated announcement bar (#2231) 2022-09-20 10:21:24 +03:00
olivermrbl
3efeb6b84f chore(release): Publish 2022-09-14 11:36:53 +02:00
Carlos R. L. Rodrigues
a94d9816fe chore: Centralise ESLint rules (#2162)
* chore: centrilize eslint rules
2022-09-13 07:42:33 -03:00
olivermrbl
70139d0bbb chore(release): Publish 2022-09-06 09:50:00 +02:00
Oliver Windall Juhl
e707b46499 fix(medusa-plugin-meilisearch): Update meilisearch dependency (#2140) 2022-09-05 18:15:09 +02:00
Oliver Windall Juhl
ad717b9533 chore(medusa): Remove deprecated dependency @hapi/joi (#2069) 2022-09-05 16:03:06 +02:00
Oliver Windall Juhl
6a62a8f1ed chore: Remove lerna (#2116)
**What**
- Removes `lerna` as we are now using `changesets` + Turborepo to handle builds and releases
2022-08-29 13:26:58 +00:00