@panneau/protocol 5.0.0-alpha.3 → 5.0.0-alpha.5

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.
Files changed (67) hide show
  1. package/dist/conformance/index.d.ts.map +1 -1
  2. package/dist/conformance/index.js +151 -1
  3. package/dist/conformance/index.js.map +1 -1
  4. package/dist/constants.d.ts +2 -2
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +3 -1
  7. package/dist/constants.js.map +1 -1
  8. package/dist/index.js +5 -2
  9. package/dist/libraries.d.ts +16 -0
  10. package/dist/libraries.d.ts.map +1 -0
  11. package/dist/libraries.js +15 -0
  12. package/dist/libraries.js.map +1 -0
  13. package/dist/lint.d.ts +2 -1
  14. package/dist/lint.d.ts.map +1 -1
  15. package/dist/lint.js +34 -2
  16. package/dist/lint.js.map +1 -1
  17. package/dist/mock/example.d.ts +2 -1
  18. package/dist/mock/example.d.ts.map +1 -1
  19. package/dist/mock/example.js +227 -143
  20. package/dist/mock/example.js.map +1 -1
  21. package/dist/mock/index.d.ts +9 -1
  22. package/dist/mock/index.d.ts.map +1 -1
  23. package/dist/mock/index.js +257 -11
  24. package/dist/mock/index.js.map +1 -1
  25. package/dist/openapi.d.ts.map +1 -1
  26. package/dist/openapi.js +55 -101
  27. package/dist/openapi.js.map +1 -1
  28. package/dist/rules.d.ts.map +1 -1
  29. package/dist/rules.js +17 -0
  30. package/dist/rules.js.map +1 -1
  31. package/dist/runtime/index.d.ts +3 -0
  32. package/dist/runtime/index.d.ts.map +1 -1
  33. package/dist/runtime/index.js +4 -1
  34. package/dist/schemas/action.d.ts +17 -1
  35. package/dist/schemas/action.d.ts.map +1 -1
  36. package/dist/schemas/api.d.ts +155 -37
  37. package/dist/schemas/api.d.ts.map +1 -1
  38. package/dist/schemas/api.js +89 -28
  39. package/dist/schemas/api.js.map +1 -1
  40. package/dist/schemas/definition.d.ts +39 -2
  41. package/dist/schemas/definition.d.ts.map +1 -1
  42. package/dist/schemas/definition.js +4 -3
  43. package/dist/schemas/definition.js.map +1 -1
  44. package/dist/schemas/field.d.ts +24 -1
  45. package/dist/schemas/field.d.ts.map +1 -1
  46. package/dist/schemas/field.js +22 -4
  47. package/dist/schemas/field.js.map +1 -1
  48. package/dist/schemas/index.d.ts +262 -40
  49. package/dist/schemas/index.d.ts.map +1 -1
  50. package/dist/schemas/index.js +13 -5
  51. package/dist/schemas/index.js.map +1 -1
  52. package/dist/schemas/resource.d.ts +37 -2
  53. package/dist/schemas/resource.d.ts.map +1 -1
  54. package/dist/schemas/resource.js +4 -1
  55. package/dist/schemas/resource.js.map +1 -1
  56. package/dist/search.d.ts +51 -0
  57. package/dist/search.d.ts.map +1 -0
  58. package/dist/search.js +53 -0
  59. package/dist/search.js.map +1 -0
  60. package/dist/transforms.d.ts +17 -0
  61. package/dist/transforms.d.ts.map +1 -0
  62. package/dist/transforms.js +34 -0
  63. package/dist/transforms.js.map +1 -0
  64. package/package.json +1 -1
  65. package/schema/boot.schema.json +84 -1
  66. package/schema/definition.schema.json +84 -1
  67. package/schema/openapi.json +771 -605
@@ -1,7 +1,8 @@
1
1
  import type { DefinitionInput } from '../schemas';
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 authors. For tests
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
  export declare function createExampleDefinition(): DefinitionInput;
@@ -1 +1 @@
1
- {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/mock/example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,eAAe,CA2IzD"}
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/mock/example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,eAAe,CAkMzD"}
@@ -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 authors. For tests
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,247 @@ function createExampleDefinition() {
11
12
  locale: "fr",
12
13
  locales: ["fr", "en"],
13
14
  api: { baseUrl: "/panneau/api" },
14
- resources: [{
15
- id: "pages",
16
- label: {
17
- singular: "page",
18
- plural: "pages"
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
- }]
15
+ resources: [
16
+ {
17
+ id: "pages",
18
+ label: {
19
+ singular: "page",
20
+ plural: "pages"
31
21
  },
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
- }]
46
- },
47
- {
48
- name: "published_at",
49
- type: "datetime",
50
- visibleWhen: {
51
- field: "status",
52
- equals: "published"
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
- rules: [{ rule: "required" }]
55
- },
56
- {
57
- name: "author",
58
- type: "relation",
59
- resource: "authors"
60
- },
61
- {
62
- name: "blocks",
63
- type: "repeater",
64
- types: [{
65
- id: "text",
66
- label: "Texte",
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
- id: "image",
74
- label: "Image",
75
- fields: [{
76
- name: "image",
77
- type: "media",
78
- rules: [{
79
- rule: "accept",
80
- value: ["image/*"]
81
- }, {
82
- rule: "maxSize",
83
- value: 1e3
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
+ }]
84
87
  }]
85
88
  }]
86
- }]
87
- }
88
- ],
89
- form: { layout: [{
90
- type: "tabs",
91
- children: [{
92
- type: "tab",
93
- label: "Contenu",
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
+ type: "tabs",
94
110
  children: [{
95
- type: "row",
111
+ type: "tab",
112
+ label: "Contenu",
96
113
  children: [{
97
- type: "field",
98
- name: "title",
99
- width: 8
114
+ type: "row",
115
+ children: [{
116
+ type: "field",
117
+ name: "title",
118
+ width: 8
119
+ }, {
120
+ type: "field",
121
+ name: "status",
122
+ width: 4
123
+ }]
100
124
  }, {
101
125
  type: "field",
102
- name: "status",
103
- width: 4
126
+ name: "blocks"
104
127
  }]
128
+ }]
129
+ }, {
130
+ type: "sidebar",
131
+ children: [{
132
+ type: "field",
133
+ name: "published_at"
105
134
  }, {
106
135
  type: "field",
107
- name: "blocks"
136
+ name: "attachment"
108
137
  }]
109
- }]
110
- }, {
111
- type: "sidebar",
112
- children: [{
113
- type: "field",
114
- name: "published_at"
115
- }]
116
- }] },
117
- list: {
118
- columns: [
119
- {
120
- field: "title",
121
- sortable: true
122
- },
123
- { field: "status" },
124
- { id: "updated" }
125
- ],
126
- filters: [{
127
- id: "status",
128
- type: "select"
138
+ }] },
139
+ list: {
140
+ columns: [
141
+ {
142
+ field: "title",
143
+ sortable: true
144
+ },
145
+ { field: "status" },
146
+ { id: "updated" }
147
+ ],
148
+ filters: [{
149
+ id: "status",
150
+ type: "select"
151
+ }, {
152
+ id: "published_at",
153
+ type: "date-range",
154
+ label: "Publication"
155
+ }],
156
+ sorts: ["title", "published_at"],
157
+ defaultSort: "title",
158
+ perPage: 20,
159
+ search: true
160
+ },
161
+ actions: [{
162
+ id: "publish",
163
+ label: "Publier",
164
+ scope: ["item", "selection"],
165
+ placement: ["row", "toolbar"],
166
+ confirm: { message: "Publier {count} pages ?" },
167
+ fields: [{
168
+ name: "notify",
169
+ type: "boolean"
170
+ }],
171
+ dryRun: true
129
172
  }, {
130
- id: "published_at",
131
- type: "date-range",
132
- label: "Publication"
173
+ id: "edit",
174
+ label: "Modifier",
175
+ kind: "link",
176
+ url: "/pages/{id}/edit",
177
+ scope: ["item"]
133
178
  }],
134
- sorts: ["title", "published_at"],
135
- defaultSort: "title",
136
- perPage: 20,
137
- search: true
179
+ abilities: {
180
+ viewAny: true,
181
+ create: true
182
+ }
138
183
  },
139
- actions: [{
140
- id: "publish",
141
- label: "Publier",
142
- scope: ["item", "selection"],
143
- placement: ["row", "toolbar"],
144
- confirm: { message: "Publier {count} pages ?" },
184
+ {
185
+ id: "authors",
186
+ label: {
187
+ singular: "auteur",
188
+ plural: "auteurs"
189
+ },
145
190
  fields: [{
146
- name: "notify",
147
- type: "boolean"
148
- }],
149
- dryRun: true
150
- }, {
151
- id: "edit",
152
- label: "Modifier",
153
- kind: "link",
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"
191
+ name: "name",
192
+ type: "text",
193
+ rules: [{ rule: "required" }]
194
+ }, {
195
+ name: "photo",
196
+ type: "media",
197
+ accept: ["image/*"]
198
+ }]
166
199
  },
167
- fields: [{
168
- name: "name",
169
- type: "text",
170
- rules: [{ rule: "required" }]
171
- }]
172
- }],
200
+ {
201
+ id: "media",
202
+ kind: "media",
203
+ label: {
204
+ singular: "média",
205
+ plural: "médias"
206
+ },
207
+ itemTitle: "name",
208
+ fields: [
209
+ {
210
+ name: "file",
211
+ type: "file",
212
+ accept: [
213
+ "image/*",
214
+ "video/*",
215
+ "application/pdf"
216
+ ],
217
+ rules: [{ rule: "required" }]
218
+ },
219
+ {
220
+ name: "name",
221
+ type: "text"
222
+ },
223
+ {
224
+ name: "alt",
225
+ type: "text",
226
+ localized: true
227
+ }
228
+ ],
229
+ list: {
230
+ filters: [{
231
+ id: "type",
232
+ type: "select",
233
+ options: [
234
+ {
235
+ value: "image",
236
+ label: "Images"
237
+ },
238
+ {
239
+ value: "video",
240
+ label: "Vidéos"
241
+ },
242
+ {
243
+ value: "document",
244
+ label: "Documents"
245
+ }
246
+ ]
247
+ }],
248
+ search: true
249
+ },
250
+ abilities: {
251
+ viewAny: true,
252
+ create: true
253
+ }
254
+ }
255
+ ],
173
256
  menus: { main: [{ type: "resources" }, {
174
257
  type: "link",
175
258
  label: "Site",
@@ -182,7 +265,8 @@ function createExampleDefinition() {
182
265
  id: "google",
183
266
  label: "Google"
184
267
  }]
185
- }
268
+ },
269
+ uploads: { mode: "presigned" }
186
270
  };
187
271
  }
188
272
  //#endregion
@@ -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,OAAO;IAAE,UAAU;IAAQ,QAAQ;GAAQ;GAC3C,WAAW;GACX,QAAQ;IACJ;KACI,MAAM;KACN,MAAM;KACN,OAAO;KACP,WAAW;KACX,OAAO,CAAC,EAAE,MAAM,WAAW,GAA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,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 {\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 {\n type: 'sidebar',\n children: [\n { type: 'field', name: 'published_at' },\n { type: 'field', name: 'attachment' },\n ],\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 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: [\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 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: [{ id: 'google', label: 'Google' }] },\n uploads: { mode: 'presigned' },\n };\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,0BAA2C;CACvD,OAAO;EACH,UAAU;EACV,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,MAAM,IAAI;EACpB,KAAK,EAAE,SAAS,eAAe;EAC/B,WAAW;GACP;IACI,IAAI;IACJ,OAAO;KAAE,UAAU;KAAQ,QAAQ;IAAQ;IAC3C,WAAW;IACX,QAAQ;KACJ;MACI,MAAM;MACN,MAAM;MACN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W;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"}
@@ -6,6 +6,14 @@ export interface MockBackendOptions {
6
6
  definition: DefinitionInput;
7
7
  /** Initial values of the items, per resource id. Items without an `id` get one. */
8
8
  items?: Record<string, Values[]>;
9
+ /**
10
+ * The URL that `POST /resources/{resource}/{id}/preview` returns, for the item with the posted
11
+ * values. Defaults to a `data:` URL of a plain page with the item's values.
12
+ */
13
+ previewUrl?: (context: {
14
+ resource: string;
15
+ item: Item;
16
+ }) => string;
9
17
  }
10
18
  export interface MockBackend {
11
19
  /** A `fetch`-compatible function that answers protocol requests. */
@@ -19,6 +27,6 @@ export interface MockBackend {
19
27
  * with the portable rules. Used to test the conformance kit, and to develop frontends without a
20
28
  * real backend.
21
29
  */
22
- export declare function createMockBackend({ definition, items }: MockBackendOptions): MockBackend;
30
+ export declare function createMockBackend(options: MockBackendOptions): MockBackend;
23
31
  export { createExampleDefinition } from './example';
24
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mock/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAgB,IAAI,EAAsB,MAAM,gBAAgB,CAAC;AAI7E,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IAC/B,kGAAkG;IAClG,UAAU,EAAE,eAAe,CAAC;IAC5B,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IACxB,oEAAoE;IACpE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChF,uCAAuC;IACvC,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;CACvC;AA6GD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,UAAU,EAAE,KAAU,EAAE,EAAE,kBAAkB,GAAG,WAAW,CA+O7F;AAED,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mock/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAGR,IAAI,EAUP,MAAM,gBAAgB,CAAC;AAKxB,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IAC/B,kGAAkG;IAClG,UAAU,EAAE,eAAe,CAAC;IAC5B,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC,MA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