-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
60 lines (56 loc) · 1.42 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* eslint-disable no-console, no-magic-numbers */
const { models } = require('@tradle/models')
const { merge } = require('./')
const model = {
type: 'tradle.Model',
id: 'my.custom.AddressForm',
title: 'Your Address',
subClassOf: 'tradle.Form',
properties: {
buildingName: {
type: 'string'
},
what3words: {
type: 'string',
description: 'Your three-word address on https://map.what3words.com'
}
},
required: ['what3words']
}
const lens = {
_t: 'tradle.Lens',
id: 'my.custom.AddressFormLens',
model: 'my.custom.AddressForm',
properties: {
what3words: {
// customize a field by adding / overriding model attributes
title: 'Address',
description: 'your address on https://map.what3words.com, e.g. parade.help.bleat'
}
},
required: ['buildingName', 'what3words'],
hidden: []
}
const merged = merge({ models, model, lens })
console.log(JSON.stringify(merged, null, 2))
// {
// "type": "tradle.Model",
// "id": "my.custom.AddressForm",
// "title": "Your Address",
// "subClassOf": "tradle.Form",
// "required": [
// "what3words",
// "buildingName"
// ],
// "properties": {
// "buildingName": {
// "type": "string"
// },
// "what3words": {
// "type": "string",
// "description": "your address on https://map.what3words.com, e.g. parade.help.bleat",
// "title": "Address"
// }
// },
// "hidden": []
// }