Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 82 additions & 76 deletions src/samples/playground.ts
Original file line number Diff line number Diff line change
@@ -1,99 +1,105 @@
const MODEL = `namespace hello@1.0.0
import org.accordproject.money@0.3.0.{MonetaryAmount} from https://models.accordproject.org/money@0.3.0.cto

concept Address {
o String line1
o String city
o String state
o String country
}
const MODEL = `namespace org.accordproject.service@1.0.0

concept OrderLine {
o String sku
concept ServiceItem {
o String description
o Double rate
o Integer quantity
o Double price
}

concept Order {
o DateTime createdAt
o OrderLine[] orderLines
concept Compensation {
o ServiceItem[] services
o Integer paymentTerms
}

@template
concept TemplateData {
o String name
o Address address
o Integer age optional
o MonetaryAmount salary
o String[] favoriteColors
o Order order
concept ServiceAgreement {
o String clientName
o String clientAddress
o String providerName
o String providerAddress
o DateTime effectiveDate
o Compensation compensation
}`;

const TEMPLATE = `> A general sample that uses a range of features
### Welcome {{name}}!
const TEMPLATE = `# SERVICE AGREEMENT

![AP Logo](https://avatars.githubusercontent.com/u/29445438?s=64)
This Service Agreement is made and entered into as of
{{effectiveDate as "D MMMM YYYY"}}
by and between {{clientName}}, located at {{clientAddress}} (Client),
and {{providerName}}, located at {{providerAddress}} (Provider).

{{#clause address}}
#### Address
> {{line1}},
{{city}}, {{state}},
{{country}}
{{/clause}}
---

- You are *{{age}}* years old
- Your monthly salary is {{salary as "0,0.00 CCC"}}
- Your favorite colours are {{#join favoriteColors}}
## 1. Services

{{#clause order}}
## Orders
Your last order was placed {{createdAt as "D MMMM YYYY"}} ({{% return now.diff(order.createdAt, 'day')%}} days ago).
{{#clause compensation}}
### Services Provided

{{#ulist orderLines}}
- {{quantity}}x _{{sku}}_ @ £{{price as "0,0.00"}}
{{#ulist services}}
- {{description}} at {{rate as "0.00"}} per unit × {{quantity}}
{{/ulist}}
Order total: {{% return '£' + order.orderLines.map(ol => ol.price * ol.quantity).reduce((sum, cur) => sum + cur).toFixed(2);%}}

### Payment Terms
Payment is due within {{paymentTerms}} days of invoice.
{{/clause}}

Thank you.
---

## 2. Total Compensation

**Total Service Value:** {{%
return '$' + compensation.services
.map(s => s.rate * s.quantity)
.reduce((sum, cur) => sum + cur, 0)
.toFixed(2);
%}}

---

## 3. Execution

IN WITNESS WHEREOF, the parties hereto have executed this Agreement.

### Client:
![Client Logo](https://ui-avatars.com/api/?name=AcmeCorp&size=40)

{{clientName}}

### Provider:

![provider logo](https://ui-avatars.com/api/?name=DevConsult+Ltd&size=40)

{{providerName}}

`;

const DATA = {
"$class" : "hello@1.0.0.TemplateData",
"name": "John Doe",
"address" : {
"line1" : "1 Main Street",
"city" : "Boson",
"state" : "MA",
"country" : "USA"
},
"age" : 42,
"salary": {
"$class": "org.accordproject.money@0.3.0.MonetaryAmount",
"doubleValue": 1500,
"currencyCode": "EUR"
},
"favoriteColors" : ['red', 'green', 'blue'],
"order" : {
"createdAt" : "2023-05-01",
"$class" : "hello@1.0.0.Order",
"orderLines":
[
{
"$class" : "hello@1.0.0.OrderLine",
"sku" : "ABC-123",
"quantity" : 3,
"price" : 29.99
},
{
"$class" : "hello@1.0.0.OrderLine",
"sku" : "DEF-456",
"quantity" : 5,
"price" : 19.99
}
"$class": "org.accordproject.service@1.0.0.ServiceAgreement",
"effectiveDate": "2026-02-01T00:00:00Z",
"clientName": "Acme Corp",
"clientAddress": "123 Business Road, London, UK",
"providerName": "DevConsult Ltd",
"providerAddress": "456 Tech Street, Berlin, Germany",
"compensation": {
"$class": "org.accordproject.service@1.0.0.Compensation",
"paymentTerms": 30,
"services": [
{
"$class": "org.accordproject.service@1.0.0.ServiceItem",
"description": "Backend Development",
"rate": 80,
"quantity": 40
},
{
"$class": "org.accordproject.service@1.0.0.ServiceItem",
"description": "Code Review",
"rate": 60,
"quantity": 10
}
]
}
}
};

const NAME = 'Customer Order';
export {NAME, MODEL,DATA,TEMPLATE};
const NAME = 'Service Agreement';

export { NAME, MODEL, DATA, TEMPLATE };