Skip to content

Commit

Permalink
feat: medusa-react admin hooks (medusajs#978)
Browse files Browse the repository at this point in the history
* add: medusa admin hooks + tests

* fix: remove unneeded props

* fix: deps

* fix: deps

* fix: deps

* fix: failing tests

* fix: failing tests

* fix: query key

* add: yarn workspaces

* fix: linting medusa-react

* fix: add prepare script

* fix: buildOptions

* fix: useAdminShippingOptions query

* fix: use qs instead for query params (medusajs#1019)

* fix: formatting

* debug: ci pipeline

* debug: log node_modules structure

* debug: use lerna bootstrap

* debug: update node version

* debug: print pkgs in workspace

* debug: print pkgs in workspace

* debug: print pkgs in workspace

* debug: print pkgs in workspace

* debug: add explicit build step

* fix: jsdoc

* debug: run build step

* debug: fix build errors

* debug: add build step to integration tests

* fix: failing test

* cleanup

Co-authored-by: Sebastian Rindom <[email protected]>
Co-authored-by: Sebastian Rindom <[email protected]>
  • Loading branch information
3 people authored Feb 2, 2022
1 parent 2417502 commit 2e38484
Show file tree
Hide file tree
Showing 209 changed files with 28,075 additions and 2,885 deletions.
52 changes: 0 additions & 52 deletions .circleci/config.yml

This file was deleted.

8 changes: 7 additions & 1 deletion .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ jobs:
with:
extension: unit-tests

- name: Build Packages
run: yarn build

- name: Run unit tests
run: node --max-old-space-size=2048 ./node_modules/.bin/jest -w 1
run: yarn test

integration-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -70,6 +73,9 @@ jobs:
uses: ./.github/actions/cache-bootstrap
with:
extension: integration-tests

- name: Build Packages
run: lerna run build

- name: Install dev cli
run: sudo npm i -g medusa-dev-cli
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
"main": "index.js",
"license": "MIT",
"scripts": {
"test": "jest --maxWorkers=50% --silent=false",
"test": "jest --silent=false",
"build": "babel src -d dist --extensions \".ts,.js\""
},
"dependencies": {
"@medusajs/medusa": "1.1.59-dev-1639132284143",
"medusa-interfaces": "1.1.32-dev-1639132284143",
"@medusajs/medusa": "1.1.60-dev-1641824815181",
"medusa-interfaces": "1.1.32-dev-1641824815181",
"typeorm": "^0.2.31"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/node": "^7.12.10",
"babel-preset-medusa-package": "1.1.19-dev-1639132284143",
"babel-preset-medusa-package": "1.1.19-dev-1641824815181",
"jest": "^26.6.3"
}
}
70 changes: 35 additions & 35 deletions integration-tests/api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1256,10 +1256,10 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"

"@medusajs/[email protected].24-dev-1639132284143":
version "1.1.24-dev-1639132284143"
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.24-dev-1639132284143.tgz#80eeb1f732db447797d8c1c141fc2590a00f89e1"
integrity sha512-IEEq9iJpTHeXAHm8KbGepYVO8xxntlrviCuGfh3OCMBzTAgnQJ/CDvRhAgb4fRGxJZ0uwLJLtQG/7ePCPAotOw==
"@medusajs/[email protected].25-dev-1641824815181":
version "1.1.25-dev-1641824815181"
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.25-dev-1641824815181.tgz#fc595f422bf3142a65e48df9855ea8644cedaa18"
integrity sha512-xGPb3GJJweG4O3/xESQbL4MyuBHRfTYo09Q/9zaFeD6KSw/MyBiY6odwtD7n1hbLSdUHtfEs8M7h+0WPe2o+/Q==
dependencies:
"@babel/polyfill" "^7.8.7"
"@babel/runtime" "^7.9.6"
Expand All @@ -1277,8 +1277,8 @@
is-valid-path "^0.1.1"
joi-objectid "^3.0.1"
meant "^1.0.1"
medusa-core-utils "1.1.31-dev-1639132284143"
medusa-telemetry "0.0.11-dev-1639132284143"
medusa-core-utils "1.1.31-dev-1641824815181"
medusa-telemetry "0.0.11-dev-1641824815181"
netrc-parser "^3.1.6"
open "^8.0.6"
ora "^5.4.1"
Expand All @@ -1292,13 +1292,13 @@
winston "^3.3.3"
yargs "^15.3.1"

"@medusajs/[email protected].59-dev-1639132284143":
version "1.1.59-dev-1639132284143"
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.59-dev-1639132284143.tgz#9cb56910e415e7f8654e94aea0468b960c2ffb12"
integrity sha512-uxKIJLKMwOR/UbuLFW9IvdReODvHace5DVWbTMIK1g031PBX3/ghto0yIbcZVaNdMLETS5SiEwPHkx0QAw2k2A==
"@medusajs/[email protected].60-dev-1641824815181":
version "1.1.60-dev-1641824815181"
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.60-dev-1641824815181.tgz#cb309b3007fff1e51181f3c65fc563f60503d9ca"
integrity sha512-uVC0L3YhM8oEmczoqrOoYevhln2e2TGcfZDDttXznl0Rjke+gmvI4Isz6KmRNL/6MBeoNMK36qpakAjqJbCPNg==
dependencies:
"@hapi/joi" "^16.1.8"
"@medusajs/medusa-cli" "1.1.24-dev-1639132284143"
"@medusajs/medusa-cli" "1.1.25-dev-1641824815181"
"@types/lodash" "^4.14.168"
awilix "^4.2.3"
body-parser "^1.19.0"
Expand All @@ -1322,8 +1322,8 @@
joi "^17.3.0"
joi-objectid "^3.0.1"
jsonwebtoken "^8.5.1"
medusa-core-utils "1.1.31-dev-1639132284143"
medusa-test-utils "1.1.34-dev-1639132284143"
medusa-core-utils "1.1.31-dev-1641824815181"
medusa-test-utils "1.1.35-dev-1641824815181"
morgan "^1.9.1"
multer "^1.4.2"
passport "^0.4.0"
Expand Down Expand Up @@ -1947,10 +1947,10 @@ babel-preset-jest@^26.6.2:
babel-plugin-jest-hoist "^26.6.2"
babel-preset-current-node-syntax "^1.0.0"

[email protected]1639132284143:
version "1.1.19-dev-1639132284143"
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.19-dev-1639132284143.tgz#a98da041ddda18db99244ae79bf415c1c674f302"
integrity sha512-o5za+lj+zXs4j7gCA3s3fYvvyiPqHiOOlsahEuXqi7FXwu3CUm1+SInxroG1U1kKeu3GbRaBzS+BFQ+xjg/K4w==
[email protected]1641824815181:
version "1.1.19-dev-1641824815181"
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.19-dev-1641824815181.tgz#7bd1f3c9098304f44ec2375b834699bc7af24281"
integrity sha512-n7IhbnTBB7ZuLalchSTTQJGrQJijwj+exgk4qff3ZPT+HYpbOJOtDjgbzCpLfvKxrkXZB2L0dU49ssvshPdMzg==
dependencies:
"@babel/plugin-proposal-class-properties" "^7.12.1"
"@babel/plugin-proposal-decorators" "^7.12.1"
Expand Down Expand Up @@ -5135,25 +5135,25 @@ [email protected]:
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=

[email protected]1639132284143:
version "1.1.31-dev-1639132284143"
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.31-dev-1639132284143.tgz#c0085cf2ec65ca9cc7500d02b1f61f8e86e95bec"
integrity sha512-l5+3ozll9BMwmPDpQlv4zqdlXnQbiy6iW5XQkykRoNiF6pGeq12ZVCoBop4TE9GKYck6UmRBbVF/kawq6nptoQ==
[email protected]1641824815181:
version "1.1.31-dev-1641824815181"
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.31-dev-1641824815181.tgz#40510df0144690a838b683a68b8e0c07404d1ee2"
integrity sha512-SedEB/rafahrsIDzXu2/Dy8nB+3DYcqbo0hzrcirrT+UouqbuaPYkXfjB1N76YwD1rC1c3p4JmBizK7Mwj84KA==
dependencies:
joi "^17.3.0"
joi-objectid "^3.0.1"

[email protected]1639132284143:
version "1.1.32-dev-1639132284143"
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.32-dev-1639132284143.tgz#a220cba78f2f9a25f711c968893a53c4ad1da0ae"
integrity sha512-/AMaqvbTVaTlAFZ48lSpBREG2s3mjFzPb3B4pr2R3x1fRfEYxMuTNXoUbFX8ubrIlKMwpB61Efon9tXouE5Cog==
[email protected]1641824815181:
version "1.1.32-dev-1641824815181"
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.32-dev-1641824815181.tgz#ec5a22fb653690256371225b08e7e12de914ff27"
integrity sha512-1W5BQLOTKaIWkkOq6g5rpNcm1pAp09SpUvDtLKpy41UignIyJp8zY7FnzCqdraSe1q/CoMptNclso6I4OABQ2w==
dependencies:
medusa-core-utils "1.1.31-dev-1639132284143"
medusa-core-utils "1.1.31-dev-1641824815181"

[email protected]1639132284143:
version "0.0.11-dev-1639132284143"
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.11-dev-1639132284143.tgz#39e32d1ef44aa1ec6a7007c27ed8a52d8786193b"
integrity sha512-6grC1gkKskrvtlHXrWBobZKsKnjJBSB94JzY7U3Sv9pD1FG3rY/100u4qixkIve9ileICzYSFLS6KcTXbDG31A==
[email protected]1641824815181:
version "0.0.11-dev-1641824815181"
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.11-dev-1641824815181.tgz#d49db51f90f16544379b2e6470821592f8b24ee4"
integrity sha512-xEVGR/OKw44xDnc1uHWm48edX+QPCiowmp+aLaHaWKontAT/C0jn9k2tFK85ObScqy0FshJPluQg2RedALjLOg==
dependencies:
axios "^0.21.1"
axios-retry "^3.1.9"
Expand All @@ -5165,13 +5165,13 @@ [email protected]:
remove-trailing-slash "^0.1.1"
uuid "^8.3.2"

[email protected].34-dev-1639132284143:
version "1.1.34-dev-1639132284143"
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.34-dev-1639132284143.tgz#8495b6e3e86ce9cf23074ce46dea06b357b3d1eb"
integrity sha512-pstRNkau48cJodUBRSbXoW/gzbOsUXaFW+grBPNzgnSD0ap7KKSM0jBGfPFgFCnBpnu5m7MBtYZBu3Ajp/8Enw==
[email protected].35-dev-1641824815181:
version "1.1.35-dev-1641824815181"
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.35-dev-1641824815181.tgz#5cf0e45f534a5532acf11d6094d0291850379875"
integrity sha512-1vTZ4D20qPEuh8LX4+wMdOfZd4pilRCE4wBehhJvyqLX5r7z+xmgVwz/EJC4VGCbk+keNXardVwb+leFYLywug==
dependencies:
"@babel/plugin-transform-classes" "^7.9.5"
medusa-core-utils "1.1.31-dev-1639132284143"
medusa-core-utils "1.1.31-dev-1641824815181"
randomatic "^3.1.1"

[email protected]:
Expand Down
9 changes: 3 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const ignoreDirs = [].concat(

const coverageDirs = pkgs.map((p) => path.join(p, `src/**/*.js`))
const useCoverage = !!process.env.GENERATE_JEST_REPORT
const projects = pkgs.map((pkg) => pkg.concat("/jest.config.js"))

module.exports = {
notify: true,
verbose: true,
roots: pkgs,
roots: ["<rootDir>"],
projects: ["<rootDir>/packages/*/jest.config.js"],
modulePathIgnorePatterns: ignoreDirs,
coveragePathIgnorePatterns: ignoreDirs,
testPathIgnorePatterns: [
Expand All @@ -33,9 +35,6 @@ module.exports = {
`<rootDir>/node_modules/`,
`__tests__/fixtures`,
],
transform: {
"^.+\\.[jt]s?$": `<rootDir>/jest-transformer.js`,
},
//moduleNameMapper: {
// "^highlight.js$": `<rootDir>/node_modules/highlight.js/lib/index.js`,
//},
Expand All @@ -46,7 +45,5 @@ module.exports = {
// useCoverage ? `jest-junit` : []
// )
// : [`default`].concat(useCoverage ? `jest-junit` : []),
testEnvironment: `node`,
moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`],
// setupFiles: [`<rootDir>/.jestSetup.js`],
}
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
Expand Down
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"name": "root",
"private": true,
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/tsdx",
"**/tsdx/**"
]
},
"devDependencies": {
"@babel/core": "^7.12.7",
"@babel/eslint-parser": "^7.15.8",
Expand Down Expand Up @@ -35,7 +44,7 @@
"pg-god": "^1.0.11",
"prettier": "^2.1.1",
"resolve-cwd": "^3.0.0",
"ts-jest": "^27.1.1",
"ts-jest": "^26.5.6",
"typeorm": "^0.2.31"
},
"lint-staged": {
Expand All @@ -47,6 +56,7 @@
"hooks:uninstall": "husky uninstall",
"publish:next": "lerna publish --canary --preid next --dist-tag next",
"bootstrap": "lerna bootstrap",
"build": "lerna run build",
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
"jest": "jest",
"test": "jest",
Expand All @@ -59,5 +69,8 @@
"import-from": "^3.0.0",
"oas-normalize": "^5.0.1",
"swagger-inline": "^3.2.2"
},
"resolutions": {
"**/tsdx/typescript": "^4.5.0"
}
}
16 changes: 8 additions & 8 deletions packages/gatsby-source-medusa/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export const createClient = (
options: MedusaPluginOptions,
reporter: Reporter
): any => {
const { storeUrl, authToken } = options
const { storeUrl, authToken } = options as any

/**
*
* @param {string} date used fetch products updated since the specified date
* @param {string} _date used fetch products updated since the specified date
* @return {Promise<any[]>}
*/
async function products(date?: string): Promise<any[]> {
async function products(_date?: string): Promise<any[]> {
let products: any[] = []
let offset = 0
let count = 1
Expand All @@ -56,7 +56,7 @@ export const createClient = (
* @param {string} date used fetch regions updated since the specified date
* @return {Promise<any[]>}
*/
async function regions(date?: string): Promise<any[]> {
async function regions(_date?: string): Promise<any[]> {
const regions = await medusaRequest(storeUrl, `/store/regions`)
.then(({ data }) => {
return data.regions
Expand All @@ -72,10 +72,10 @@ export const createClient = (

/**
*
* @param {string} date used fetch regions updated since the specified date
* @param {string} _date used fetch regions updated since the specified date
* @return {Promise<any[]>}
*/
async function orders(date?: string): Promise<any[]> {
async function orders(_date?: string): Promise<any[]> {
const orders = await medusaRequest(storeUrl, `/admin/orders`, {
Authorization: `Bearer ${authToken}`,
})
Expand All @@ -94,10 +94,10 @@ export const createClient = (

/**
*
* @param {string} date used fetch regions updated since the specified date
* @param {string} _date used fetch regions updated since the specified date
* @return {Promise<any[]>}
*/
async function collections(date?: string): Promise<any[]> {
async function collections(_date?: string): Promise<any[]> {
let collections: any[] = []
let offset = 0
let count = 1
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-medusa/src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const medusaNodeTypes = [
"MedusaCollections",
]

async function sourceUpdatedNodes(
export async function sourceUpdatedNodes(
gatsbyApi: SourceNodesArgs,
pluginOptions: MedusaPluginOptions
): Promise<void> {
Expand Down
5 changes: 2 additions & 3 deletions packages/medusa-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"description": "Client for Medusa Commerce Rest API",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**/*"
],
"files": ["dist/**/*"],
"scripts": {
"build": "tsc --build",
"test": "jest --config jestconfig.json",
Expand All @@ -18,6 +16,7 @@
"@medusajs/medusa": "^1.1.62",
"axios": "^0.24.0",
"form-data": "^4.0.0",
"qs": "^6.10.3",
"retry-axios": "^2.6.0"
},
"repository": {
Expand Down
Loading

0 comments on commit 2e38484

Please sign in to comment.