@panneau/protocol 5.0.0-alpha.3 → 5.0.0-alpha.32
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/dist/addresses.d.ts +23 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +52 -0
- package/dist/addresses.js.map +1 -0
- package/dist/compound.d.ts +20 -0
- package/dist/compound.d.ts.map +1 -0
- package/dist/compound.js +27 -0
- package/dist/compound.js.map +1 -0
- package/dist/conditions.d.ts +1 -1
- package/dist/conformance/index.d.ts +6 -0
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +801 -11
- package/dist/conformance/index.js.map +1 -1
- package/dist/constants.d.ts +108 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +181 -3
- package/dist/constants.js.map +1 -1
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +34 -0
- package/dist/context.js.map +1 -0
- package/dist/currencies.d.ts +22 -0
- package/dist/currencies.d.ts.map +1 -0
- package/dist/currencies.js +231 -0
- package/dist/currencies.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +19 -8
- package/dist/libraries.d.ts +33 -0
- package/dist/libraries.d.ts.map +1 -0
- package/dist/libraries.js +59 -0
- package/dist/libraries.js.map +1 -0
- package/dist/links.d.ts +38 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +65 -0
- package/dist/links.js.map +1 -0
- package/dist/lint.d.ts +4 -3
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +168 -7
- package/dist/lint.js.map +1 -1
- package/dist/mock/auth.d.ts +71 -0
- package/dist/mock/auth.d.ts.map +1 -0
- package/dist/mock/auth.js +346 -0
- package/dist/mock/auth.js.map +1 -0
- package/dist/mock/example.d.ts +3 -2
- package/dist/mock/example.d.ts.map +1 -1
- package/dist/mock/example.js +241 -144
- package/dist/mock/example.js.map +1 -1
- package/dist/mock/index.d.ts +79 -7
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +603 -38
- package/dist/mock/index.js.map +1 -1
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +392 -144
- package/dist/openapi.js.map +1 -1
- package/dist/problem.d.ts +1 -1
- package/dist/query.d.ts +18 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +34 -8
- package/dist/query.js.map +1 -1
- package/dist/resourceTypes.d.ts +39 -0
- package/dist/resourceTypes.d.ts.map +1 -0
- package/dist/resourceTypes.js +34 -0
- package/dist/resourceTypes.js.map +1 -0
- package/dist/rules.d.ts +18 -5
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +233 -15
- package/dist/rules.js.map +1 -1
- package/dist/runtime/index.d.ts +20 -10
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +13 -3
- package/dist/schemas/action.d.ts +118 -10
- package/dist/schemas/action.d.ts.map +1 -1
- package/dist/schemas/action.js +20 -3
- package/dist/schemas/action.js.map +1 -1
- package/dist/schemas/api.d.ts +334 -42
- package/dist/schemas/api.d.ts.map +1 -1
- package/dist/schemas/api.js +194 -34
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/boot.d.ts +25 -1
- package/dist/schemas/boot.d.ts.map +1 -1
- package/dist/schemas/boot.js +2 -1
- package/dist/schemas/boot.js.map +1 -1
- package/dist/schemas/common.d.ts +1 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/common.js +2 -1
- package/dist/schemas/common.js.map +1 -1
- package/dist/schemas/definition.d.ts +341 -28
- package/dist/schemas/definition.d.ts.map +1 -1
- package/dist/schemas/definition.js +65 -19
- package/dist/schemas/definition.js.map +1 -1
- package/dist/schemas/field.d.ts +357 -2
- package/dist/schemas/field.d.ts.map +1 -1
- package/dist/schemas/field.js +160 -20
- package/dist/schemas/field.js.map +1 -1
- package/dist/schemas/index.d.ts +1429 -80
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +60 -10
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/jsonRules.d.ts +83 -0
- package/dist/schemas/jsonRules.d.ts.map +1 -0
- package/dist/schemas/jsonRules.js +46 -0
- package/dist/schemas/jsonRules.js.map +1 -0
- package/dist/schemas/layout.d.ts +2 -1
- package/dist/schemas/layout.d.ts.map +1 -1
- package/dist/schemas/layout.js +2 -1
- package/dist/schemas/layout.js.map +1 -1
- package/dist/schemas/list.d.ts +23 -2
- package/dist/schemas/list.d.ts.map +1 -1
- package/dist/schemas/list.js +15 -6
- package/dist/schemas/list.js.map +1 -1
- package/dist/schemas/resource.d.ts +263 -17
- package/dist/schemas/resource.d.ts.map +1 -1
- package/dist/schemas/resource.js +19 -4
- package/dist/schemas/resource.js.map +1 -1
- package/dist/schemas/theme.d.ts +4 -0
- package/dist/schemas/theme.d.ts.map +1 -1
- package/dist/schemas/theme.js +1 -0
- package/dist/schemas/theme.js.map +1 -1
- package/dist/schemas/widget.d.ts +109 -0
- package/dist/schemas/widget.d.ts.map +1 -0
- package/dist/schemas/widget.js +74 -0
- package/dist/schemas/widget.js.map +1 -0
- package/dist/search.d.ts +51 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +53 -0
- package/dist/search.js.map +1 -0
- package/dist/themes.d.ts +1 -1
- package/dist/transforms.d.ts +17 -0
- package/dist/transforms.d.ts.map +1 -0
- package/dist/transforms.js +34 -0
- package/dist/transforms.js.map +1 -0
- package/dist/validate.d.ts +5 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +36 -2
- package/dist/validate.js.map +1 -1
- package/dist/values.d.ts +5 -1
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +16 -2
- package/dist/values.js.map +1 -1
- package/dist/widgets.d.ts +42 -0
- package/dist/widgets.d.ts.map +1 -0
- package/dist/widgets.js +130 -0
- package/dist/widgets.js.map +1 -0
- package/package.json +6 -3
- package/schema/boot.schema.json +716 -20
- package/schema/definition.schema.json +713 -20
- package/schema/openapi.json +5659 -2229
package/dist/mock/example.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//#region src/mock/example.ts
|
|
2
2
|
/**
|
|
3
3
|
* A small but complete definition: pages with localized titles, a status, a publication date shown
|
|
4
|
-
* for published pages, an author and typed blocks, in tabs and a sidebar, plus
|
|
4
|
+
* for published pages, an author, an attachment and typed blocks, in tabs and a sidebar, plus
|
|
5
|
+
* authors with a photo, and a media library. For tests
|
|
5
6
|
* and stories, with `createMockBackend()`.
|
|
6
7
|
*/
|
|
7
8
|
function createExampleDefinition() {
|
|
@@ -11,165 +12,260 @@ function createExampleDefinition() {
|
|
|
11
12
|
locale: "fr",
|
|
12
13
|
locales: ["fr", "en"],
|
|
13
14
|
api: { baseUrl: "/panneau/api" },
|
|
14
|
-
resources: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
itemTitle: "title",
|
|
21
|
-
fields: [
|
|
22
|
-
{
|
|
23
|
-
name: "title",
|
|
24
|
-
type: "text",
|
|
25
|
-
label: "Titre",
|
|
26
|
-
localized: true,
|
|
27
|
-
rules: [{ rule: "required" }, {
|
|
28
|
-
rule: "max",
|
|
29
|
-
value: 120
|
|
30
|
-
}]
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "status",
|
|
34
|
-
type: "select",
|
|
35
|
-
options: [{
|
|
36
|
-
value: "draft",
|
|
37
|
-
label: "Brouillon"
|
|
38
|
-
}, {
|
|
39
|
-
value: "published",
|
|
40
|
-
label: "Publiée"
|
|
41
|
-
}],
|
|
42
|
-
rules: [{ rule: "required" }, {
|
|
43
|
-
rule: "in",
|
|
44
|
-
value: ["draft", "published"]
|
|
45
|
-
}]
|
|
15
|
+
resources: [
|
|
16
|
+
{
|
|
17
|
+
id: "pages",
|
|
18
|
+
label: {
|
|
19
|
+
singular: "page",
|
|
20
|
+
plural: "pages"
|
|
46
21
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
22
|
+
itemTitle: "title",
|
|
23
|
+
fields: [
|
|
24
|
+
{
|
|
25
|
+
name: "title",
|
|
26
|
+
type: "text",
|
|
27
|
+
label: "Titre",
|
|
28
|
+
localized: true,
|
|
29
|
+
rules: [{ rule: "required" }, {
|
|
30
|
+
rule: "max",
|
|
31
|
+
value: 120
|
|
32
|
+
}]
|
|
53
33
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
fields: [{
|
|
68
|
-
name: "body",
|
|
69
|
-
type: "richtext",
|
|
70
|
-
rules: [{ rule: "required" }]
|
|
34
|
+
{
|
|
35
|
+
name: "status",
|
|
36
|
+
type: "select",
|
|
37
|
+
options: [{
|
|
38
|
+
value: "draft",
|
|
39
|
+
label: "Brouillon"
|
|
40
|
+
}, {
|
|
41
|
+
value: "published",
|
|
42
|
+
label: "Publiée"
|
|
43
|
+
}],
|
|
44
|
+
rules: [{ rule: "required" }, {
|
|
45
|
+
rule: "in",
|
|
46
|
+
value: ["draft", "published"]
|
|
71
47
|
}]
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "published_at",
|
|
51
|
+
type: "datetime",
|
|
52
|
+
visibleWhen: {
|
|
53
|
+
field: "status",
|
|
54
|
+
equals: "published"
|
|
55
|
+
},
|
|
56
|
+
rules: [{ rule: "required" }]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "author",
|
|
60
|
+
type: "relation",
|
|
61
|
+
resource: "authors"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "blocks",
|
|
65
|
+
type: "repeater",
|
|
66
|
+
types: [{
|
|
67
|
+
id: "text",
|
|
68
|
+
label: "Texte",
|
|
69
|
+
fields: [{
|
|
70
|
+
name: "body",
|
|
71
|
+
type: "richtext",
|
|
72
|
+
rules: [{ rule: "required" }]
|
|
73
|
+
}]
|
|
74
|
+
}, {
|
|
75
|
+
id: "image",
|
|
76
|
+
label: "Image",
|
|
77
|
+
fields: [{
|
|
78
|
+
name: "image",
|
|
79
|
+
type: "media",
|
|
80
|
+
rules: [{
|
|
81
|
+
rule: "accept",
|
|
82
|
+
value: ["image/*"]
|
|
83
|
+
}, {
|
|
84
|
+
rule: "maxSize",
|
|
85
|
+
value: 1e3
|
|
86
|
+
}]
|
|
87
|
+
}]
|
|
88
|
+
}]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "attachment",
|
|
92
|
+
type: "file",
|
|
93
|
+
label: "Pièce jointe",
|
|
94
|
+
rules: [{
|
|
95
|
+
rule: "accept",
|
|
96
|
+
value: ["application/pdf"]
|
|
97
|
+
}]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "slug",
|
|
101
|
+
type: "slug",
|
|
102
|
+
from: "title",
|
|
103
|
+
localized: true,
|
|
104
|
+
check: true,
|
|
105
|
+
settings: { prefix: "https://example.com/" }
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
form: { layout: [
|
|
109
|
+
{
|
|
110
|
+
type: "tabs",
|
|
111
|
+
children: [{
|
|
112
|
+
type: "tab",
|
|
113
|
+
label: "Contenu",
|
|
114
|
+
children: [{
|
|
115
|
+
type: "field",
|
|
116
|
+
name: "title"
|
|
81
117
|
}, {
|
|
82
|
-
|
|
83
|
-
|
|
118
|
+
type: "field",
|
|
119
|
+
name: "blocks"
|
|
84
120
|
}]
|
|
85
121
|
}]
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: "sidebar",
|
|
125
|
+
panel: "save"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "sidebar",
|
|
129
|
+
panel: "errors"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
type: "sidebar",
|
|
133
|
+
panel: "publication",
|
|
134
|
+
label: "Publication",
|
|
96
135
|
children: [{
|
|
97
136
|
type: "field",
|
|
98
|
-
name: "
|
|
99
|
-
width: 8
|
|
137
|
+
name: "status"
|
|
100
138
|
}, {
|
|
101
139
|
type: "field",
|
|
102
|
-
name: "
|
|
103
|
-
width: 4
|
|
140
|
+
name: "published_at"
|
|
104
141
|
}]
|
|
105
|
-
},
|
|
106
|
-
type: "field",
|
|
107
|
-
name: "blocks"
|
|
108
|
-
}]
|
|
109
|
-
}]
|
|
110
|
-
}, {
|
|
111
|
-
type: "sidebar",
|
|
112
|
-
children: [{
|
|
113
|
-
type: "field",
|
|
114
|
-
name: "published_at"
|
|
115
|
-
}]
|
|
116
|
-
}] },
|
|
117
|
-
list: {
|
|
118
|
-
columns: [
|
|
142
|
+
},
|
|
119
143
|
{
|
|
120
|
-
|
|
121
|
-
|
|
144
|
+
type: "sidebar",
|
|
145
|
+
panel: "actions"
|
|
122
146
|
},
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
{
|
|
148
|
+
type: "sidebar",
|
|
149
|
+
label: "Pièce jointe",
|
|
150
|
+
children: [{
|
|
151
|
+
type: "field",
|
|
152
|
+
name: "attachment"
|
|
153
|
+
}]
|
|
154
|
+
}
|
|
155
|
+
] },
|
|
156
|
+
list: {
|
|
157
|
+
columns: [
|
|
158
|
+
{
|
|
159
|
+
field: "title",
|
|
160
|
+
sortable: true
|
|
161
|
+
},
|
|
162
|
+
{ field: "status" },
|
|
163
|
+
{ id: "updated" }
|
|
164
|
+
],
|
|
165
|
+
filters: [{
|
|
166
|
+
id: "status",
|
|
167
|
+
type: "select"
|
|
168
|
+
}, {
|
|
169
|
+
id: "published_at",
|
|
170
|
+
type: "date-range",
|
|
171
|
+
label: "Publication"
|
|
172
|
+
}],
|
|
173
|
+
sorts: ["title", "published_at"],
|
|
174
|
+
defaultSort: "title",
|
|
175
|
+
perPage: 20,
|
|
176
|
+
search: true
|
|
177
|
+
},
|
|
178
|
+
actions: [{
|
|
179
|
+
id: "publish",
|
|
180
|
+
label: "Publier",
|
|
181
|
+
scope: ["item", "selection"],
|
|
182
|
+
placement: ["row", "toolbar"],
|
|
183
|
+
confirm: { message: "Publier {count} pages ?" },
|
|
184
|
+
fields: [{
|
|
185
|
+
name: "notify",
|
|
186
|
+
type: "boolean"
|
|
187
|
+
}],
|
|
188
|
+
dryRun: true
|
|
133
189
|
}],
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
190
|
+
abilities: {
|
|
191
|
+
viewAny: true,
|
|
192
|
+
create: true
|
|
193
|
+
}
|
|
138
194
|
},
|
|
139
|
-
|
|
140
|
-
id: "
|
|
141
|
-
label:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
195
|
+
{
|
|
196
|
+
id: "authors",
|
|
197
|
+
label: {
|
|
198
|
+
singular: "auteur",
|
|
199
|
+
plural: "auteurs"
|
|
200
|
+
},
|
|
201
|
+
open: "edit",
|
|
145
202
|
fields: [{
|
|
146
|
-
name: "
|
|
147
|
-
type: "
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
url: "/pages/{id}/edit",
|
|
155
|
-
scope: ["item"]
|
|
156
|
-
}],
|
|
157
|
-
abilities: {
|
|
158
|
-
viewAny: true,
|
|
159
|
-
create: true
|
|
160
|
-
}
|
|
161
|
-
}, {
|
|
162
|
-
id: "authors",
|
|
163
|
-
label: {
|
|
164
|
-
singular: "auteur",
|
|
165
|
-
plural: "auteurs"
|
|
203
|
+
name: "name",
|
|
204
|
+
type: "text",
|
|
205
|
+
rules: [{ rule: "required" }]
|
|
206
|
+
}, {
|
|
207
|
+
name: "photo",
|
|
208
|
+
type: "media",
|
|
209
|
+
accept: ["image/*"]
|
|
210
|
+
}]
|
|
166
211
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
212
|
+
{
|
|
213
|
+
id: "media",
|
|
214
|
+
kind: "media",
|
|
215
|
+
label: {
|
|
216
|
+
singular: "média",
|
|
217
|
+
plural: "médias"
|
|
218
|
+
},
|
|
219
|
+
itemActions: ["edit", "delete"],
|
|
220
|
+
itemTitle: "name",
|
|
221
|
+
fields: [
|
|
222
|
+
{
|
|
223
|
+
name: "file",
|
|
224
|
+
type: "file",
|
|
225
|
+
accept: [
|
|
226
|
+
"image/*",
|
|
227
|
+
"video/*",
|
|
228
|
+
"application/pdf"
|
|
229
|
+
],
|
|
230
|
+
rules: [{ rule: "required" }]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "name",
|
|
234
|
+
type: "text"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "alt",
|
|
238
|
+
type: "text",
|
|
239
|
+
localized: true
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
list: {
|
|
243
|
+
filters: [{
|
|
244
|
+
id: "type",
|
|
245
|
+
type: "select",
|
|
246
|
+
options: [
|
|
247
|
+
{
|
|
248
|
+
value: "image",
|
|
249
|
+
label: "Images"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
value: "video",
|
|
253
|
+
label: "Vidéos"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
value: "document",
|
|
257
|
+
label: "Documents"
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}],
|
|
261
|
+
search: true
|
|
262
|
+
},
|
|
263
|
+
abilities: {
|
|
264
|
+
viewAny: true,
|
|
265
|
+
create: true
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
],
|
|
173
269
|
menus: { main: [{ type: "resources" }, {
|
|
174
270
|
type: "link",
|
|
175
271
|
label: "Site",
|
|
@@ -182,7 +278,8 @@ function createExampleDefinition() {
|
|
|
182
278
|
id: "google",
|
|
183
279
|
label: "Google"
|
|
184
280
|
}]
|
|
185
|
-
}
|
|
281
|
+
},
|
|
282
|
+
uploads: { mode: "presigned" }
|
|
186
283
|
};
|
|
187
284
|
}
|
|
188
285
|
//#endregion
|
package/dist/mock/example.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"example.js","names":[],"sources":["../../src/mock/example.ts"],"sourcesContent":["import type { DefinitionInput } from '../schemas';\n\n/**\n * A small but complete definition: pages with localized titles, a status, a publication date shown\n * for published pages, an author and typed blocks, in tabs and a sidebar, plus authors. For tests\n * and stories, with `createMockBackend()`.\n */\nexport function createExampleDefinition(): DefinitionInput {\n return {\n protocol: 1,\n name: 'Test site',\n locale: 'fr',\n locales: ['fr', 'en'],\n api: { baseUrl: '/panneau/api' },\n resources: [\n {\n id: 'pages',\n label: { singular: 'page', plural: 'pages' },\n itemTitle: 'title',\n fields: [\n {\n name: 'title',\n type: 'text',\n label: 'Titre',\n localized: true,\n rules: [{ rule: 'required' }, { rule: 'max', value: 120 }],\n },\n {\n name: 'status',\n type: 'select',\n options: [\n { value: 'draft', label: 'Brouillon' },\n { value: 'published', label: 'Publiée' },\n ],\n rules: [\n { rule: 'required' },\n { rule: 'in', value: ['draft', 'published'] },\n ],\n },\n {\n name: 'published_at',\n type: 'datetime',\n visibleWhen: { field: 'status', equals: 'published' },\n rules: [{ rule: 'required' }],\n },\n { name: 'author', type: 'relation', resource: 'authors' },\n {\n name: 'blocks',\n type: 'repeater',\n types: [\n {\n id: 'text',\n label: 'Texte',\n fields: [\n {\n name: 'body',\n type: 'richtext',\n rules: [{ rule: 'required' }],\n },\n ],\n },\n {\n id: 'image',\n label: 'Image',\n fields: [\n {\n name: 'image',\n type: 'media',\n rules: [\n { rule: 'accept', value: ['image/*'] },\n { rule: 'maxSize', value: 1000 },\n ],\n },\n ],\n },\n ],\n },\n ],\n form: {\n layout: [\n {\n type: 'tabs',\n children: [\n {\n type: 'tab',\n label: 'Contenu',\n children: [\n {\n type: 'row',\n children: [\n { type: 'field', name: 'title', width: 8 },\n { type: 'field', name: 'status', width: 4 },\n ],\n },\n { type: 'field', name: 'blocks' },\n ],\n },\n ],\n },\n { type: 'sidebar', children: [{ type: 'field', name: 'published_at' }] },\n ],\n },\n list: {\n columns: [\n { field: 'title', sortable: true },\n { field: 'status' },\n { id: 'updated' },\n ],\n filters: [\n { id: 'status', type: 'select' },\n { id: 'published_at', type: 'date-range', label: 'Publication' },\n ],\n sorts: ['title', 'published_at'],\n defaultSort: 'title',\n perPage: 20,\n search: true,\n },\n actions: [\n {\n id: 'publish',\n label: 'Publier',\n scope: ['item', 'selection'],\n placement: ['row', 'toolbar'],\n confirm: { message: 'Publier {count} pages ?' },\n fields: [{ name: 'notify', type: 'boolean' }],\n dryRun: true,\n },\n {\n id: 'edit',\n label: 'Modifier',\n kind: 'link',\n url: '/pages/{id}/edit',\n scope: ['item'],\n },\n ],\n abilities: { viewAny: true, create: true },\n },\n {\n id: 'authors',\n label: { singular: 'auteur', plural: 'auteurs' },\n fields: [{ name: 'name', type: 'text', rules: [{ rule: 'required' }] }],\n },\n ],\n menus: { main: [{ type: 'resources' }, { type: 'link', label: 'Site', url: '/' }] },\n auth: { mode: 'panneau', password: true, providers: [{ id: 'google', label: 'Google' }] },\n };\n}\n"],"mappings":";;;;;;AAOA,SAAgB,0BAA2C;CACvD,OAAO;EACH,UAAU;EACV,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,MAAM,IAAI;EACpB,KAAK,EAAE,SAAS,eAAe;EAC/B,WAAW,CACP;GACI,IAAI;GACJ,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IAAE,MAAM;IAAW,UAAU,CAAC;KAAE,MAAM;KAAS,MAAM;IAAe,CAAC;GAAE,CAC3E,EACJ;GACA,MAAM;IACF,SAAS;KACL;MAAE,OAAO;MAAS,UAAU;KAAK;KACjC,EAAE,OAAO,SAAS;KAClB,EAAE,IAAI,UAAU;IACpB;IACA,SAAS,CACL;KAAE,IAAI;KAAU,MAAM;IAAS,GAC/B;KAAE,IAAI;KAAgB,MAAM;KAAc,OAAO;IAAc,CACnE;IACA,OAAO,CAAC,SAAS,cAAc;IAC/B,aAAa;IACb,SAAS;IACT,QAAQ;GACZ;GACA,SAAS,CACL;IACI,IAAI;IACJ,OAAO;IACP,OAAO,CAAC,QAAQ,WAAW;IAC3B,WAAW,CAAC,OAAO,SAAS;IAC5B,SAAS,EAAE,SAAS,0BAA0B;IAC9C,QAAQ,CAAC;KAAE,MAAM;KAAU,MAAM;IAAU,CAAC;IAC5C,QAAQ;GACZ,GACA;IACI,IAAI;IACJ,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO,CAAC,MAAM;GAClB,CACJ;GACA,WAAW;IAAE,SAAS;IAAM,QAAQ;GAAK;EAC7C,GACA;GACI,IAAI;GACJ,OAAO;IAAE,UAAU;IAAU,QAAQ;GAAU;GAC/C,QAAQ,CAAC;IAAE,MAAM;IAAQ,MAAM;IAAQ,OAAO,CAAC,EAAE,MAAM,WAAW,CAAC;GAAE,CAAC;EAC1E,CACJ;EACA,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,YAAY,GAAG;GAAE,MAAM;GAAQ,OAAO;GAAQ,KAAK;EAAI,CAAC,EAAE;EAClF,MAAM;GAAE,MAAM;GAAW,UAAU;GAAM,WAAW,CAAC;IAAE,IAAI;IAAU,OAAO;GAAS,CAAC;EAAE;CAC5F;AACJ"}
|
|
1
|
+
{"version":3,"file":"example.js","names":[],"sources":["../../src/mock/example.ts"],"sourcesContent":["import type { DefinitionInput } from '../schemas';\n\n/**\n * A small but complete definition: pages with localized titles, a status, a publication date shown\n * for published pages, an author, an attachment and typed blocks, in tabs and a sidebar, plus\n * authors with a photo, and a media library. For tests\n * and stories, with `createMockBackend()`.\n */\nexport function createExampleDefinition(): DefinitionInput {\n return {\n protocol: 1,\n name: 'Test site',\n locale: 'fr',\n locales: ['fr', 'en'],\n api: { baseUrl: '/panneau/api' },\n resources: [\n {\n id: 'pages',\n label: { singular: 'page', plural: 'pages' },\n itemTitle: 'title',\n fields: [\n {\n name: 'title',\n type: 'text',\n label: 'Titre',\n localized: true,\n rules: [{ rule: 'required' }, { rule: 'max', value: 120 }],\n },\n {\n name: 'status',\n type: 'select',\n options: [\n { value: 'draft', label: 'Brouillon' },\n { value: 'published', label: 'Publiée' },\n ],\n rules: [\n { rule: 'required' },\n { rule: 'in', value: ['draft', 'published'] },\n ],\n },\n {\n name: 'published_at',\n type: 'datetime',\n visibleWhen: { field: 'status', equals: 'published' },\n rules: [{ rule: 'required' }],\n },\n { name: 'author', type: 'relation', resource: 'authors' },\n {\n name: 'blocks',\n type: 'repeater',\n types: [\n {\n id: 'text',\n label: 'Texte',\n fields: [\n {\n name: 'body',\n type: 'richtext',\n rules: [{ rule: 'required' }],\n },\n ],\n },\n {\n id: 'image',\n label: 'Image',\n fields: [\n {\n name: 'image',\n type: 'media',\n rules: [\n { rule: 'accept', value: ['image/*'] },\n { rule: 'maxSize', value: 1000 },\n ],\n },\n ],\n },\n ],\n },\n {\n name: 'attachment',\n type: 'file',\n label: 'Pièce jointe',\n rules: [{ rule: 'accept', value: ['application/pdf'] }],\n },\n {\n name: 'slug',\n type: 'slug',\n from: 'title',\n localized: true,\n check: true,\n settings: { prefix: 'https://example.com/' },\n },\n ],\n form: {\n layout: [\n {\n type: 'tabs',\n children: [\n {\n type: 'tab',\n label: 'Contenu',\n children: [\n { type: 'field', name: 'title' },\n { type: 'field', name: 'blocks' },\n ],\n },\n ],\n },\n // The panels of its sidebar (decision 0075): Save, the errors after a\n // failed save, the publication with Publish, the actions of the page\n { type: 'sidebar', panel: 'save' },\n { type: 'sidebar', panel: 'errors' },\n {\n type: 'sidebar',\n panel: 'publication',\n label: 'Publication',\n children: [\n { type: 'field', name: 'status' },\n { type: 'field', name: 'published_at' },\n ],\n },\n { type: 'sidebar', panel: 'actions' },\n {\n type: 'sidebar',\n label: 'Pièce jointe',\n children: [{ type: 'field', name: 'attachment' }],\n },\n ],\n },\n list: {\n columns: [\n { field: 'title', sortable: true },\n { field: 'status' },\n { id: 'updated' },\n ],\n filters: [\n { id: 'status', type: 'select' },\n { id: 'published_at', type: 'date-range', label: 'Publication' },\n ],\n sorts: ['title', 'published_at'],\n defaultSort: 'title',\n perPage: 20,\n search: true,\n },\n actions: [\n {\n id: 'publish',\n label: 'Publier',\n scope: ['item', 'selection'],\n placement: ['row', 'toolbar'],\n confirm: { message: 'Publier {count} pages ?' },\n fields: [{ name: 'notify', type: 'boolean' }],\n dryRun: true,\n },\n ],\n abilities: { viewAny: true, create: true },\n },\n {\n id: 'authors',\n label: { singular: 'auteur', plural: 'auteurs' },\n // Titles open the form, without the panel of the details.\n open: 'edit',\n fields: [\n { name: 'name', type: 'text', rules: [{ rule: 'required' }] },\n { name: 'photo', type: 'media', accept: ['image/*'] },\n ],\n },\n {\n id: 'media',\n kind: 'media',\n label: { singular: 'média', plural: 'médias' },\n // Of the built-in item actions, only these, in this order\n itemActions: ['edit', 'delete'],\n itemTitle: 'name',\n fields: [\n {\n name: 'file',\n type: 'file',\n accept: ['image/*', 'video/*', 'application/pdf'],\n rules: [{ rule: 'required' }],\n },\n { name: 'name', type: 'text' },\n { name: 'alt', type: 'text', localized: true },\n ],\n list: {\n filters: [\n {\n id: 'type',\n type: 'select',\n options: [\n { value: 'image', label: 'Images' },\n { value: 'video', label: 'Vidéos' },\n { value: 'document', label: 'Documents' },\n ],\n },\n ],\n search: true,\n },\n abilities: { viewAny: true, create: true },\n },\n ],\n menus: { main: [{ type: 'resources' }, { type: 'link', label: 'Site', url: '/' }] },\n auth: { mode: 'panneau', password: true, providers: [{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ACI,IAAI;IACJ,OAAO;KAAE,UAAU;KAAU,QAAQ;IAAU;IAE/C,MAAM;IACN,QAAQ,CACJ;KAAE,MAAM;KAAQ,MAAM;KAAQ,OAAO,CAAC,EAAE,MAAM,WAAW,CAAC;IAAE,GAC5D;KAAE,MAAM;KAAS,MAAM;KAAS,QAAQ,CAAC,SAAS;IAAE,CACxD;GACJ;GACA;IACI,IAAI;IACJ,MAAM;IACN,OAAO;KAAE,UAAU;KAAS,QAAQ;IAAS;IAE7C,aAAa,CAAC,QAAQ,QAAQ;IAC9B,WAAW;IACX,QAAQ;KACJ;MACI,MAAM;MACN,MAAM;MACN,QAAQ;OAAC;OAAW;OAAW;MAAiB;MAChD,OAAO,CAAC,EAAE,MAAM,WAAW,CAAC;KAChC;KACA;MAAE,MAAM;MAAQ,MAAM;KAAO;KAC7B;MAAE,MAAM;MAAO,MAAM;MAAQ,WAAW;KAAK;IACjD;IACA,MAAM;KACF,SAAS,CACL;MACI,IAAI;MACJ,MAAM;MACN,SAAS;OACL;QAAE,OAAO;QAAS,OAAO;OAAS;OAClC;QAAE,OAAO;QAAS,OAAO;OAAS;OAClC;QAAE,OAAO;QAAY,OAAO;OAAY;MAC5C;KACJ,CACJ;KACA,QAAQ;IACZ;IACA,WAAW;KAAE,SAAS;KAAM,QAAQ;IAAK;GAC7C;EACJ;EACA,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,YAAY,GAAG;GAAE,MAAM;GAAQ,OAAO;GAAQ,KAAK;EAAI,CAAC,EAAE;EAClF,MAAM;GAAE,MAAM;GAAW,UAAU;GAAM,WAAW,CAAC;IAAE,IAAI;IAAU,OAAO;GAAS,CAAC;EAAE;EACxF,SAAS,EAAE,MAAM,YAAY;CACjC;AACJ"}
|
package/dist/mock/index.d.ts
CHANGED
|
@@ -1,11 +1,74 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
1
|
+
import { type ContextValues } from '../context.js';
|
|
2
|
+
import type { ContextOption, DefinitionInput } from '../schemas/index.js';
|
|
3
|
+
import type { EmbedValue, Item } from '../schemas/api.js';
|
|
4
|
+
import { type MockAuthOptions } from './auth.js';
|
|
5
|
+
export type { MockAuthOptions, MockMail, MockUser } from './auth.js';
|
|
3
6
|
type Values = Record<string, unknown>;
|
|
4
7
|
export interface MockBackendOptions {
|
|
5
8
|
/** The definition served by `GET /definition`. Its `api.baseUrl` is the prefix of every route. */
|
|
6
9
|
definition: DefinitionInput;
|
|
7
10
|
/** Initial values of the items, per resource id. Items without an `id` get one. */
|
|
8
11
|
items?: Record<string, Values[]>;
|
|
12
|
+
/**
|
|
13
|
+
* The URL that `POST /resources/{resource}/{id}/preview` returns, for the item with the posted
|
|
14
|
+
* values. Defaults to a `data:` URL of a plain page with the item's values.
|
|
15
|
+
*/
|
|
16
|
+
previewUrl?: (context: {
|
|
17
|
+
resource: string;
|
|
18
|
+
item: Item;
|
|
19
|
+
}) => string;
|
|
20
|
+
/**
|
|
21
|
+
* The value of `GET /embeds?url=` for a URL, or `null` to refuse it with a `422`. Defaults to
|
|
22
|
+
* a video for YouTube and Vimeo URLs, and a link for other web pages.
|
|
23
|
+
*/
|
|
24
|
+
embed?: (url: string) => EmbedValue | null;
|
|
25
|
+
/**
|
|
26
|
+
* The current context, when the definition has `context` (decision 0045). The values of the
|
|
27
|
+
* `Panneau-Context` header are checked against the choices of each param: a value that isn't
|
|
28
|
+
* one is a `403` problem.
|
|
29
|
+
*/
|
|
30
|
+
context?: MockContextOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Users and a session, for the `panneau` auth mode: the auth routes answer, guests get a `401`
|
|
33
|
+
* on the other routes, and with `auth.emailVerification`, users whose address isn't verified
|
|
34
|
+
* get its `403` problem (decision 0048). Without it, every request is the user's.
|
|
35
|
+
*/
|
|
36
|
+
auth?: MockAuthOptions;
|
|
37
|
+
/**
|
|
38
|
+
* The data of `GET /dashboard/widgets/{widget}`, per widget id (decision 0064): the data, a
|
|
39
|
+
* function that returns it for the current context, or a `Response` to answer as is (a `403`,
|
|
40
|
+
* a slow or failing widget). Data that doesn't have the shape of a built-in type is a `500`
|
|
41
|
+
* problem that names the wrong keys, as a backend answers it. Widgets of the dashboard without
|
|
42
|
+
* data, and built-in `stat` and `list` on a resource, are a `404`.
|
|
43
|
+
*/
|
|
44
|
+
widgets?: Record<string, MockWidget>;
|
|
45
|
+
/**
|
|
46
|
+
* Whether something else uses an item, so that it can't be deleted: `delete` skips it with
|
|
47
|
+
* the reason `in_use`, and its `undo` leaves it out. Without it, no item is in use.
|
|
48
|
+
*/
|
|
49
|
+
inUse?: (context: {
|
|
50
|
+
resource: string;
|
|
51
|
+
item: Item;
|
|
52
|
+
}) => boolean;
|
|
53
|
+
}
|
|
54
|
+
/** The data of a widget in the mock backend: its data, or what answers it. */
|
|
55
|
+
export type MockWidget = Response | Record<string, unknown> | ((context: MockWidgetContext) => Response | Record<string, unknown> | Promise<Response | Record<string, unknown>>);
|
|
56
|
+
/** What the function of a widget of the mock backend gets. */
|
|
57
|
+
export interface MockWidgetContext {
|
|
58
|
+
/** The values of the context of the request. */
|
|
59
|
+
context: ContextValues;
|
|
60
|
+
/** The current items of a resource, in the context. */
|
|
61
|
+
items: (resource: string) => Item[];
|
|
62
|
+
}
|
|
63
|
+
/** How the mock backend answers the context of its definition (decision 0045). */
|
|
64
|
+
export interface MockContextOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Every choice of a param without inline `options`, for the values of the params before it.
|
|
67
|
+
* `GET /context/{name}/options?q=` gives the first 20 whose label matches `q`.
|
|
68
|
+
*/
|
|
69
|
+
options?: (name: string, before: ContextValues) => ContextOption[];
|
|
70
|
+
/** Whether an item of a resource is in the context, for lists, items, actions and search. */
|
|
71
|
+
scope?: (resource: string, item: Item, values: ContextValues) => boolean;
|
|
9
72
|
}
|
|
10
73
|
export interface MockBackend {
|
|
11
74
|
/** A `fetch`-compatible function that answers protocol requests. */
|
|
@@ -15,10 +78,19 @@ export interface MockBackend {
|
|
|
15
78
|
}
|
|
16
79
|
/**
|
|
17
80
|
* An in-memory backend that implements the protocol's resource routes: definition, list, show,
|
|
18
|
-
* create, update (with `If-Match`), delete and the built-in `delete` action.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
81
|
+
* create, update (with `If-Match`), delete, duplicate and the built-in `delete` action. A resource
|
|
82
|
+
* that declares its `delete` `undoable` has a trash: the result of `delete` says how to undo it,
|
|
83
|
+
* and the built-in `restore` puts the items back (decision 0063). Its items
|
|
84
|
+
* allow every built-in item action (`view`, `update`, `duplicate`, `delete`), unless an item of
|
|
85
|
+
* `items` gives its own `abilities`. It reads abilities as clients do (decision 0046): a resource
|
|
86
|
+
* without `viewAny` answers `403` on its list, one without `create` on creates, an item without
|
|
87
|
+
* `view`, `update` or `delete` on those requests; items leave out the values of fields with
|
|
88
|
+
* `view: false`, and writes ignore those of fields with `update: false`. A resource with `types`
|
|
89
|
+
* needs the `type` of a new item, among the types it can create, and its items have the fields of
|
|
90
|
+
* their type (decision 0077). Values are checked with
|
|
91
|
+
* the portable rules. Used to test the conformance kit, and to develop frontends without a real
|
|
92
|
+
* backend.
|
|
21
93
|
*/
|
|
22
|
-
export declare function createMockBackend(
|
|
23
|
-
export { createExampleDefinition } from './example';
|
|
94
|
+
export declare function createMockBackend(options: MockBackendOptions): MockBackend;
|
|
95
|
+
export { createExampleDefinition } from './example.js';
|
|
24
96
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mock/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mock/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mock/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,aAAa,EAAqC,MAAM,YAAY,CAAC;AAKnF,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAC;AAChF,OAAO,KAAK,EAER,UAAU,EAEV,IAAI,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