Skip to content

Commit e46a85e

Browse files
committed
Add Samples
- Added more samples - Organised samples as content Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
1 parent 064fba2 commit e46a85e

19 files changed

+374
-94
lines changed

.netlify/v1/config.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"images":{"remote_images":[]},"headers":[{"for":"/_astro/*","values":{"Cache-Control":"public, max-age=31536000, immutable"}}]}

package-lock.json

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const SpecErrorV1Schema = z.object({
2222
});
2323
export type SpecErrorV1Schema = z.infer<typeof SpecErrorV1Schema>;
2424

25+
const exampleSchema = z.object({
26+
title: z.string()
27+
});
28+
export type Example = z.infer<typeof SpecErrorV1Schema>;
29+
2530
const blog = defineCollection({
2631
loader: getGlobLoader('blog', `{${mdExtensions.join(',')}}`),
2732
schema: BlogPostSchema
@@ -30,6 +35,10 @@ const specErrorV1 = defineCollection({
3035
loader: getGlobLoader('spec/1.0.0/errors', 'json'),
3136
schema: SpecErrorV1Schema
3237
});
38+
const example = defineCollection({
39+
loader: getGlobLoader('examples', `{${mdExtensions.join(',')}}`),
40+
schema: exampleSchema
41+
});
3342
/*
3443
const docs = defineCollection({
3544
loader: getLoader('docs'),
@@ -42,6 +51,7 @@ const docs = defineCollection({
4251
export const collections = {
4352
blog,
4453
specErrorV1,
54+
example,
4555
//docs,
4656
};
4757

src/content/examples/async-api.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Async API
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: examples
7+
name: call-asyncapi
8+
version: '1.0.0'
9+
do:
10+
- findPet:
11+
call: asyncapi
12+
with:
13+
document:
14+
uri: https://fake.com/docs/asyncapi.json
15+
operationRef: findPetsByStatus
16+
server: staging
17+
message:
18+
payload:
19+
petId: ${ .pet.id }
20+
authentication:
21+
bearer:
22+
token: ${ .token }

src/content/examples/container.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Container
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: examples
7+
name: run-container
8+
version: '1.0.0'
9+
do:
10+
- runContainer:
11+
run:
12+
container:
13+
image: fake-image

src/content/examples/emit.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Emit Event
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: test
7+
name: emit
8+
version: '0.1.0'
9+
do:
10+
- emitEvent:
11+
emit:
12+
event:
13+
with:
14+
source: https://petstore.com
15+
type: com.petstore.order.placed.v1
16+
data:
17+
client:
18+
firstName: Cruella
19+
lastName: de Vil
20+
items:
21+
- breed: dalmatian
22+
quantity: 101

src/content/examples/for.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: For
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: test
7+
name: for-example
8+
version: '0.1.0'
9+
do:
10+
- checkup:
11+
for:
12+
each: pet
13+
in: .pets
14+
at: index
15+
while: .vet != null
16+
do:
17+
- waitForCheckup:
18+
listen:
19+
to:
20+
one:
21+
with:
22+
type: com.fake.petclinic.pets.checkup.completed.v2
23+
output:
24+
as: '.pets + [{ "id": $pet.id }]'

src/content/examples/fork.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Fork
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: test
7+
name: fork-example
8+
version: '0.1.0'
9+
do:
10+
- raiseAlarm:
11+
fork:
12+
compete: true
13+
branches:
14+
- callNurse:
15+
call: http
16+
with:
17+
method: put
18+
endpoint: https://fake-hospital.com/api/v3/alert/nurses
19+
body:
20+
patientId: ${ .patient.fullName }
21+
room: ${ .room.number }
22+
- callDoctor:
23+
call: http
24+
with:
25+
method: put
26+
endpoint: https://fake-hospital.com/api/v3/alert/doctor
27+
body:
28+
patientId: ${ .patient.fullName }
29+
room: ${ .room.number }

src/content/examples/grpc.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: gRPC
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: examples
7+
name: call-grpc
8+
version: '1.0.0'
9+
do:
10+
- greet:
11+
call: grpc
12+
with:
13+
proto:
14+
endpoint: file://app/greet.proto
15+
service:
16+
name: GreeterApi.Greeter
17+
host: localhost
18+
port: 5011
19+
method: SayHello
20+
arguments:
21+
name: '${ .user.preferredDisplayName }'

src/content/examples/http.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: HTTP
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: examples
7+
name: call-http
8+
version: '1.0.0'
9+
do:
10+
- getPet:
11+
call: http
12+
with:
13+
method: get
14+
endpoint: https://petstore.swagger.io/v2/pet/{petId}

src/content/examples/listen.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Listen Event
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: test
7+
name: listen-to-all
8+
version: '0.1.0'
9+
do:
10+
- callDoctor:
11+
listen:
12+
to:
13+
all:
14+
- with:
15+
type: com.fake-hospital.vitals.measurements.temperature
16+
data: ${ .temperature > 38 }
17+
- with:
18+
type: com.fake-hospital.vitals.measurements.bpm
19+
data: ${ .bpm < 60 or .bpm > 100 }

src/content/examples/open-api.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Open API
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: examples
7+
name: call-openapi
8+
version: '1.0.0'
9+
do:
10+
- findPet:
11+
call: openapi
12+
with:
13+
document:
14+
endpoint: https://petstore.swagger.io/v2/swagger.json
15+
operationId: findPetsByStatus
16+
parameters:
17+
status: available

src/content/examples/raise.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Raise Error
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: test
7+
name: raise-not-implemented
8+
version: '0.1.0'
9+
do:
10+
- notImplemented:
11+
raise:
12+
error:
13+
type: https://serverlessworkflow.io/errors/not-implemented
14+
status: 500
15+
title: Not Implemented
16+
detail: ${ "The workflow '\( $workflow.definition.document.name ):\( $workflow.definition.document.version )' is a work in progress and cannot be run yet" }

src/content/examples/script.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Script
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: samples
7+
name: run-script-with-arguments
8+
version: 0.1.0
9+
do:
10+
- log:
11+
run:
12+
script:
13+
language: javascript
14+
arguments:
15+
message: ${ .message }
16+
code: >
17+
console.log(message)

src/content/examples/subflow.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Subflow
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: test
7+
name: run-subflow
8+
version: '0.1.0'
9+
do:
10+
- registerCustomer:
11+
run:
12+
workflow:
13+
namespace: test
14+
name: register-customer
15+
version: '0.1.0'
16+
input:
17+
customer: .user

src/content/examples/switch.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Switch
3+
---
4+
document:
5+
dsl: '1.0.0-alpha5'
6+
namespace: test
7+
name: switch-example
8+
version: '0.1.0'
9+
do:
10+
- processOrder:
11+
switch:
12+
- case1:
13+
when: .orderType == "electronic"
14+
then: processElectronicOrder
15+
- case2:
16+
when: .orderType == "physical"
17+
then: processPhysicalOrder
18+
- default:
19+
then: handleUnknownOrderType
20+
- processElectronicOrder:
21+
do:
22+
- validatePayment:
23+
call: http
24+
with:
25+
method: post
26+
endpoint: https://fake-payment-service.com/validate
27+
- fulfillOrder:
28+
call: http
29+
with:
30+
method: post
31+
endpoint: https://fake-fulfillment-service.com/fulfill
32+
then: exit
33+
- processPhysicalOrder:
34+
do:
35+
- checkInventory:
36+
call: http
37+
with:
38+
method: get
39+
endpoint: https://fake-inventory-service.com/inventory
40+
- packItems:
41+
call: http
42+
with:
43+
method: post
44+
endpoint: https://fake-packaging-service.com/pack
45+
- scheduleShipping:
46+
call: http
47+
with:
48+
method: post
49+
endpoint: https://fake-shipping-service.com/schedule
50+
then: exit
51+
- handleUnknownOrderType:
52+
do:
53+
- logWarning:
54+
call: http
55+
with:
56+
method: post
57+
endpoint: https://fake-logging-service.com/warn
58+
- notifyAdmin:
59+
call: http
60+
with:
61+
method: post
62+
endpoint: https://fake-notification-service.com/notify

0 commit comments

Comments
 (0)