mercur-cli 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/backend-setup.js +2 -2
- package/cli/data.js +3 -0
- package/cli/frontend-setup.js +17 -0
- package/cli/full-install.js +7 -1
- package/cli/pull-and-install.js +13 -1
- package/cli/start.js +14 -1
- package/index.js +5 -0
- package/package.json +1 -1
- package/mercur/backend/.env.template +0 -8
- package/mercur/backend/.env.test +0 -0
- package/mercur/backend/.github/dependabot.yml +0 -21
- package/mercur/backend/.github/scripts/wait-for-server-live.sh +0 -29
- package/mercur/backend/.github/workflows/test-cli.yml +0 -222
- package/mercur/backend/.github/workflows/update-preview-deps-ci.yml +0 -69
- package/mercur/backend/.github/workflows/update-preview-deps.yml +0 -67
- package/mercur/backend/.vscode/settings.json +0 -2
- package/mercur/backend/.yarnrc.yml +0 -1
- package/mercur/backend/README.md +0 -62
- package/mercur/backend/instrumentation.ts +0 -24
- package/mercur/backend/integration-tests/http/README.md +0 -29
- package/mercur/backend/integration-tests/http/health.spec.ts +0 -15
- package/mercur/backend/integration-tests/setup.js +0 -3
- package/mercur/backend/jest.config.js +0 -27
- package/mercur/backend/medusa-config.ts +0 -88
- package/mercur/backend/package.json +0 -65
- package/mercur/backend/src/admin/README.md +0 -33
- package/mercur/backend/src/admin/tsconfig.json +0 -24
- package/mercur/backend/src/admin/vite-env.d.ts +0 -1
- package/mercur/backend/src/api/README.md +0 -135
- package/mercur/backend/src/api/admin/custom/route.ts +0 -8
- package/mercur/backend/src/api/store/custom/route.ts +0 -8
- package/mercur/backend/src/jobs/README.md +0 -38
- package/mercur/backend/src/links/README.md +0 -26
- package/mercur/backend/src/modules/README.md +0 -117
- package/mercur/backend/src/scripts/README.md +0 -63
- package/mercur/backend/src/scripts/seed/seed-functions.ts +0 -519
- package/mercur/backend/src/scripts/seed/seed-products.ts +0 -601
- package/mercur/backend/src/scripts/seed.ts +0 -75
- package/mercur/backend/src/subscribers/README.md +0 -61
- package/mercur/backend/src/workflows/README.md +0 -81
- package/mercur/backend/tsconfig.json +0 -35
- package/mercur/backend/yarn.lock +0 -11469
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# Custom subscribers
|
|
2
|
-
|
|
3
|
-
Subscribers handle events emitted in the Medusa application.
|
|
4
|
-
|
|
5
|
-
> Learn more about Subscribers in [this documentation](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers).
|
|
6
|
-
|
|
7
|
-
The subscriber is created in a TypeScript or JavaScript file under the `src/subscribers` directory.
|
|
8
|
-
|
|
9
|
-
For example, create the file `src/subscribers/product-created.ts` with the following content:
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import {
|
|
13
|
-
type SubscriberConfig,
|
|
14
|
-
} from "@medusajs/framework"
|
|
15
|
-
|
|
16
|
-
// subscriber function
|
|
17
|
-
export default async function productCreateHandler() {
|
|
18
|
-
console.log("A product was created")
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// subscriber config
|
|
22
|
-
export const config: SubscriberConfig = {
|
|
23
|
-
event: "product.created",
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
A subscriber file must export:
|
|
28
|
-
|
|
29
|
-
- The subscriber function that is an asynchronous function executed whenever the associated event is triggered.
|
|
30
|
-
- A configuration object defining the event this subscriber is listening to.
|
|
31
|
-
|
|
32
|
-
## Subscriber Parameters
|
|
33
|
-
|
|
34
|
-
A subscriber receives an object having the following properties:
|
|
35
|
-
|
|
36
|
-
- `event`: An object holding the event's details. It has a `data` property, which is the event's data payload.
|
|
37
|
-
- `container`: The Medusa container. Use it to resolve modules' main services and other registered resources.
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
import type {
|
|
41
|
-
SubscriberArgs,
|
|
42
|
-
SubscriberConfig,
|
|
43
|
-
} from "@medusajs/framework"
|
|
44
|
-
|
|
45
|
-
export default async function productCreateHandler({
|
|
46
|
-
event: { data },
|
|
47
|
-
container,
|
|
48
|
-
}: SubscriberArgs<{ id: string }>) {
|
|
49
|
-
const productId = data.id
|
|
50
|
-
|
|
51
|
-
const productModuleService = container.resolve("product")
|
|
52
|
-
|
|
53
|
-
const product = await productModuleService.retrieveProduct(productId)
|
|
54
|
-
|
|
55
|
-
console.log(`The product ${product.title} was created`)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const config: SubscriberConfig = {
|
|
59
|
-
event: "product.created",
|
|
60
|
-
}
|
|
61
|
-
```
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Custom Workflows
|
|
2
|
-
|
|
3
|
-
A workflow is a series of queries and actions that complete a task.
|
|
4
|
-
|
|
5
|
-
The workflow is created in a TypeScript or JavaScript file under the `src/workflows` directory.
|
|
6
|
-
|
|
7
|
-
> Learn more about workflows in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows).
|
|
8
|
-
|
|
9
|
-
For example:
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import {
|
|
13
|
-
createStep,
|
|
14
|
-
createWorkflow,
|
|
15
|
-
WorkflowResponse,
|
|
16
|
-
StepResponse,
|
|
17
|
-
} from "@medusajs/framework/workflows-sdk"
|
|
18
|
-
|
|
19
|
-
const step1 = createStep("step-1", async () => {
|
|
20
|
-
return new StepResponse(`Hello from step one!`)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
type WorkflowInput = {
|
|
24
|
-
name: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const step2 = createStep(
|
|
28
|
-
"step-2",
|
|
29
|
-
async ({ name }: WorkflowInput) => {
|
|
30
|
-
return new StepResponse(`Hello ${name} from step two!`)
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
type WorkflowOutput = {
|
|
35
|
-
message1: string
|
|
36
|
-
message2: string
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const helloWorldWorkflow = createWorkflow(
|
|
40
|
-
"hello-world",
|
|
41
|
-
(input: WorkflowInput) => {
|
|
42
|
-
const greeting1 = step1()
|
|
43
|
-
const greeting2 = step2(input)
|
|
44
|
-
|
|
45
|
-
return new WorkflowResponse({
|
|
46
|
-
message1: greeting1,
|
|
47
|
-
message2: greeting2
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
export default helloWorldWorkflow
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Execute Workflow
|
|
56
|
-
|
|
57
|
-
You can execute the workflow from other resources, such as API routes, scheduled jobs, or subscribers.
|
|
58
|
-
|
|
59
|
-
For example, to execute the workflow in an API route:
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
import type {
|
|
63
|
-
MedusaRequest,
|
|
64
|
-
MedusaResponse,
|
|
65
|
-
} from "@medusajs/framework"
|
|
66
|
-
import myWorkflow from "../../../workflows/hello-world"
|
|
67
|
-
|
|
68
|
-
export async function GET(
|
|
69
|
-
req: MedusaRequest,
|
|
70
|
-
res: MedusaResponse
|
|
71
|
-
) {
|
|
72
|
-
const { result } = await myWorkflow(req.scope)
|
|
73
|
-
.run({
|
|
74
|
-
input: {
|
|
75
|
-
name: req.query.name as string,
|
|
76
|
-
},
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
res.send(result)
|
|
80
|
-
}
|
|
81
|
-
```
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2021",
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"module": "Node16",
|
|
6
|
-
"moduleResolution": "Node16",
|
|
7
|
-
"emitDecoratorMetadata": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"skipDefaultLibCheck": true,
|
|
11
|
-
"declaration": false,
|
|
12
|
-
"sourceMap": false,
|
|
13
|
-
"inlineSourceMap": true,
|
|
14
|
-
"outDir": "./.medusa/server",
|
|
15
|
-
"rootDir": "./",
|
|
16
|
-
"jsx": "react-jsx",
|
|
17
|
-
"forceConsistentCasingInFileNames": true,
|
|
18
|
-
"resolveJsonModule": true,
|
|
19
|
-
"checkJs": false,
|
|
20
|
-
"strictNullChecks": true
|
|
21
|
-
},
|
|
22
|
-
"ts-node": {
|
|
23
|
-
"swc": true
|
|
24
|
-
},
|
|
25
|
-
"include": [
|
|
26
|
-
"**/*",
|
|
27
|
-
".medusa/types/*"
|
|
28
|
-
],
|
|
29
|
-
"exclude": [
|
|
30
|
-
"node_modules",
|
|
31
|
-
".medusa/server",
|
|
32
|
-
".medusa/admin",
|
|
33
|
-
".cache"
|
|
34
|
-
]
|
|
35
|
-
}
|