@panneau/protocol 5.0.0-alpha.35 → 5.0.0-alpha.37

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 (59) hide show
  1. package/dist/aggregates.d.ts +135 -0
  2. package/dist/aggregates.d.ts.map +1 -0
  3. package/dist/aggregates.js +236 -0
  4. package/dist/aggregates.js.map +1 -0
  5. package/dist/conformance/index.d.ts.map +1 -1
  6. package/dist/conformance/index.js +201 -24
  7. package/dist/conformance/index.js.map +1 -1
  8. package/dist/dashboards.d.ts +95 -0
  9. package/dist/dashboards.d.ts.map +1 -0
  10. package/dist/dashboards.js +140 -0
  11. package/dist/dashboards.js.map +1 -0
  12. package/dist/index.js +9 -6
  13. package/dist/lint.d.ts.map +1 -1
  14. package/dist/lint.js +237 -15
  15. package/dist/lint.js.map +1 -1
  16. package/dist/mock/example.js +1 -1
  17. package/dist/mock/example.js.map +1 -1
  18. package/dist/mock/index.d.ts +27 -8
  19. package/dist/mock/index.d.ts.map +1 -1
  20. package/dist/mock/index.js +42 -6
  21. package/dist/mock/index.js.map +1 -1
  22. package/dist/openapi.d.ts.map +1 -1
  23. package/dist/openapi.js +89 -3
  24. package/dist/openapi.js.map +1 -1
  25. package/dist/periods.d.ts +49 -0
  26. package/dist/periods.d.ts.map +1 -0
  27. package/dist/periods.js +93 -0
  28. package/dist/periods.js.map +1 -0
  29. package/dist/runtime/index.d.ts +4 -1
  30. package/dist/runtime/index.d.ts.map +1 -1
  31. package/dist/runtime/index.js +5 -2
  32. package/dist/schemas/definition.d.ts +136 -0
  33. package/dist/schemas/definition.d.ts.map +1 -1
  34. package/dist/schemas/definition.js +15 -4
  35. package/dist/schemas/definition.js.map +1 -1
  36. package/dist/schemas/index.d.ts +287 -1
  37. package/dist/schemas/index.d.ts.map +1 -1
  38. package/dist/schemas/index.js +13 -6
  39. package/dist/schemas/index.js.map +1 -1
  40. package/dist/schemas/list.d.ts +11 -0
  41. package/dist/schemas/list.d.ts.map +1 -1
  42. package/dist/schemas/list.js +8 -2
  43. package/dist/schemas/list.js.map +1 -1
  44. package/dist/schemas/resource.d.ts +98 -0
  45. package/dist/schemas/resource.d.ts.map +1 -1
  46. package/dist/schemas/resource.js +10 -2
  47. package/dist/schemas/resource.js.map +1 -1
  48. package/dist/schemas/widget.d.ts +62 -2
  49. package/dist/schemas/widget.d.ts.map +1 -1
  50. package/dist/schemas/widget.js +36 -8
  51. package/dist/schemas/widget.js.map +1 -1
  52. package/dist/widgets.d.ts +48 -9
  53. package/dist/widgets.d.ts.map +1 -1
  54. package/dist/widgets.js +81 -10
  55. package/dist/widgets.js.map +1 -1
  56. package/package.json +1 -1
  57. package/schema/boot.schema.json +260 -66
  58. package/schema/definition.schema.json +260 -66
  59. package/schema/openapi.json +604 -8
@@ -21,6 +21,60 @@ export declare const ResourceType: z.ZodObject<{
21
21
  fields: z.ZodArray<typeof Field>;
22
22
  abilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
23
23
  }, z.core.$loose>;
24
+ export declare const SummaryPeriod: z.ZodObject<{
25
+ options: z.ZodArray<z.ZodEnum<{
26
+ "7d": "7d";
27
+ "30d": "30d";
28
+ "90d": "90d";
29
+ month: "month";
30
+ year: "year";
31
+ }>>;
32
+ default: z.ZodOptional<z.ZodEnum<{
33
+ "7d": "7d";
34
+ "30d": "30d";
35
+ "90d": "90d";
36
+ month: "month";
37
+ year: "year";
38
+ }>>;
39
+ filter: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$loose>;
41
+ export declare const ResourceSummary: z.ZodObject<{
42
+ widgets: z.ZodArray<z.ZodObject<{
43
+ id: z.ZodString;
44
+ type: z.ZodString;
45
+ label: z.ZodOptional<z.ZodString>;
46
+ width: z.ZodOptional<z.ZodNumber>;
47
+ settings: z.ZodOptional<z.ZodObject<{
48
+ resource: z.ZodOptional<z.ZodString>;
49
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
50
+ measure: z.ZodOptional<z.ZodString>;
51
+ group: z.ZodOptional<z.ZodString>;
52
+ target: z.ZodOptional<z.ZodNumber>;
53
+ period: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
54
+ followsList: z.ZodOptional<z.ZodBoolean>;
55
+ }, z.core.$loose>>;
56
+ }, z.core.$loose>>;
57
+ list: z.ZodOptional<z.ZodEnum<{
58
+ collapsed: "collapsed";
59
+ }>>;
60
+ period: z.ZodOptional<z.ZodObject<{
61
+ options: z.ZodArray<z.ZodEnum<{
62
+ "7d": "7d";
63
+ "30d": "30d";
64
+ "90d": "90d";
65
+ month: "month";
66
+ year: "year";
67
+ }>>;
68
+ default: z.ZodOptional<z.ZodEnum<{
69
+ "7d": "7d";
70
+ "30d": "30d";
71
+ "90d": "90d";
72
+ month: "month";
73
+ year: "year";
74
+ }>>;
75
+ filter: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$loose>>;
77
+ }, z.core.$loose>;
24
78
  export declare const Resource: z.ZodObject<{
25
79
  id: z.ZodString;
26
80
  kind: z.ZodOptional<z.ZodString>;
@@ -298,6 +352,11 @@ export declare const Resource: z.ZodObject<{
298
352
  filter: z.ZodOptional<z.ZodString>;
299
353
  perPage: z.ZodOptional<z.ZodNumber>;
300
354
  }, z.core.$loose>>;
355
+ aggregates: z.ZodOptional<z.ZodObject<{
356
+ sum: z.ZodOptional<z.ZodArray<z.ZodString>>;
357
+ groupBy: z.ZodOptional<z.ZodArray<z.ZodString>>;
358
+ dates: z.ZodOptional<z.ZodArray<z.ZodString>>;
359
+ }, z.core.$loose>>;
301
360
  }, z.core.$loose>>;
302
361
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
303
362
  id: z.ZodString;
@@ -565,10 +624,49 @@ export declare const Resource: z.ZodObject<{
565
624
  fields: z.ZodArray<typeof Field>;
566
625
  abilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
567
626
  }, z.core.$loose>>>;
627
+ summary: z.ZodOptional<z.ZodObject<{
628
+ widgets: z.ZodArray<z.ZodObject<{
629
+ id: z.ZodString;
630
+ type: z.ZodString;
631
+ label: z.ZodOptional<z.ZodString>;
632
+ width: z.ZodOptional<z.ZodNumber>;
633
+ settings: z.ZodOptional<z.ZodObject<{
634
+ resource: z.ZodOptional<z.ZodString>;
635
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
636
+ measure: z.ZodOptional<z.ZodString>;
637
+ group: z.ZodOptional<z.ZodString>;
638
+ target: z.ZodOptional<z.ZodNumber>;
639
+ period: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
640
+ followsList: z.ZodOptional<z.ZodBoolean>;
641
+ }, z.core.$loose>>;
642
+ }, z.core.$loose>>;
643
+ list: z.ZodOptional<z.ZodEnum<{
644
+ collapsed: "collapsed";
645
+ }>>;
646
+ period: z.ZodOptional<z.ZodObject<{
647
+ options: z.ZodArray<z.ZodEnum<{
648
+ "7d": "7d";
649
+ "30d": "30d";
650
+ "90d": "90d";
651
+ month: "month";
652
+ year: "year";
653
+ }>>;
654
+ default: z.ZodOptional<z.ZodEnum<{
655
+ "7d": "7d";
656
+ "30d": "30d";
657
+ "90d": "90d";
658
+ month: "month";
659
+ year: "year";
660
+ }>>;
661
+ filter: z.ZodOptional<z.ZodString>;
662
+ }, z.core.$loose>>;
663
+ }, z.core.$loose>>;
568
664
  settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
569
665
  }, z.core.$loose>;
570
666
  export type ResourceFeatures = z.infer<typeof ResourceFeatures>;
571
667
  export type ResourceType = z.infer<typeof ResourceType>;
668
+ export type SummaryPeriod = z.infer<typeof SummaryPeriod>;
669
+ export type ResourceSummary = z.infer<typeof ResourceSummary>;
572
670
  export type Resource = z.infer<typeof Resource>;
573
671
  /** A resource as a backend writes it, before defaults are applied. */
574
672
  export type ResourceInput = z.input<typeof Resource>;
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/schemas/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,eAAO,MAAM,gBAAgB;;;;;;;;;;;iBAmB3B,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;YAeH,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;;iBAcxC,CAAC;AAEP,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA3CC,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4FoB,CAAC;AAEnE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AACxD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC9D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChD,sEAAsE;AACtE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC"}
@@ -3,6 +3,7 @@ import { Field } from "./field.js";
3
3
  import { LayoutNode } from "./layout.js";
4
4
  import { Action } from "./action.js";
5
5
  import { ListDefinition } from "./list.js";
6
+ import { OverviewPeriod, Widget } from "./widget.js";
6
7
  import { z } from "zod";
7
8
  //#region src/schemas/resource.ts
8
9
  var ResourceFeatures = z.looseObject({
@@ -24,6 +25,12 @@ var ResourceType = z.looseObject({
24
25
  },
25
26
  abilities: Abilities.optional().meta({ description: "`create: false`: the type is not offered when creating, and the backend refuses to create one (a singleton such as the home page). Its items can still be edited." })
26
27
  }).meta({ description: "A type of the items of a resource (decision 0077): the items of a type have the fields of the resource and its own." });
28
+ var SummaryPeriod = OverviewPeriod.extend({ filter: z.string().min(1).optional().meta({ description: "The id of the list's `date-range` filter that the period sets. Defaults to the first `date-range` filter of the list." }) }).meta({ description: "The period of a summary (decision 0084): the list's own `date-range` filter, so choosing it filters the rows too." });
29
+ var ResourceSummary = z.looseObject({
30
+ widgets: z.array(Widget).meta({ description: "The widgets of the summary for the user, in order, drawn above the list in the grid of a dashboard. Widgets on this resource get the list's current filters and search, unless `settings.followsList` is `false`. Widgets with data of their own are fed by `GET /dashboard/widgets/{widget}?resource={resource}`, with the filters and the search of the list." }),
31
+ list: z.enum(["collapsed"]).optional().meta({ description: "`collapsed`: the resource opens on its summary, with its list folded under it behind \"Show the N items\". Without it, the list is shown under the summary." }),
32
+ period: SummaryPeriod.optional()
33
+ }).meta({ description: "Widgets above the list of a resource, which follow its filters and its search (decision 0084)." });
27
34
  var Resource = z.looseObject({
28
35
  id: z.string().min(1),
29
36
  kind: z.string().min(1).optional().meta({ description: "What the resource is. `media`: a library of media (decision 0026), with a `file` field and a `media` on each item. Without it, an ordinary resource. Clients treat a kind they don't know as an ordinary resource." }),
@@ -36,7 +43,7 @@ var Resource = z.looseObject({
36
43
  itemTitle: z.string().optional().meta({ description: "The field used as the title of an item, in lists and pickers." }),
37
44
  itemSubtitle: z.string().optional().meta({ description: "The field shown under the title of an item, in search results, cards and pickers." }),
38
45
  itemImage: z.string().optional().meta({ description: "The field that holds the image of an item (a media, a file or a URL), in search results, pickers, the gallery and the thumbnails of the table. Defaults to the item's `media` in a resource of kind `media` (decision 0061)." }),
39
- open: z.union([z.enum(["panel", "edit"]), z.string().min(1)]).optional().meta({ description: "Where an item's title goes, in its list and wherever the app links to the item (decision 0040). `panel`, the default: the show route, with the item's details in a panel next to the list. `edit`: its edit form, and the show route redirects there. Clients treat a value they don't know as `panel`." }),
46
+ open: z.union([z.enum(["panel", "edit"]), z.string().min(1)]).optional().meta({ description: "Where an item's title goes, in its list and wherever the app links to the item (decision 0082). `edit`, the default: its edit form, and the show route redirects there. An item the user can't update still opens in the panel. `panel`: the show route, with the item's details in a panel next to the list, for items read more than edited, or shown with their preview. Clients treat a value they don't know as `edit`." }),
40
47
  itemActions: z.array(z.string().min(1)).optional().meta({ description: "The built-in item actions the resource shows, in their order (decision 0040): some of `show`, `edit`, `duplicate` and `delete`. Defaults to all four. Each one is shown on the items whose abilities allow it (`view`, `update`, `duplicate`, `delete`). `[]` shows none. Clients ignore ids they don't know." }),
41
48
  fields: z.array(Field),
42
49
  form: z.looseObject({ layout: z.array(LayoutNode).optional() }).optional(),
@@ -45,9 +52,10 @@ var Resource = z.looseObject({
45
52
  abilities: Abilities.optional(),
46
53
  features: ResourceFeatures.optional(),
47
54
  types: z.array(ResourceType).optional().meta({ description: "The types of the resource's items, each with fields of its own (decision 0077). Each item has a `type`, set when it is created, among their ids." }),
55
+ summary: ResourceSummary.optional().meta({ description: "Widgets above the list, which follow its filters and its search (decision 0084)." }),
48
56
  settings: z.record(z.string(), z.unknown()).optional()
49
57
  }).meta({ description: "A set of items managed in the admin." });
50
58
  //#endregion
51
- export { Resource, ResourceFeatures, ResourceType };
59
+ export { Resource, ResourceFeatures, ResourceSummary, ResourceType, SummaryPeriod };
52
60
 
53
61
  //# sourceMappingURL=resource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.js","names":[],"sources":["../../src/schemas/resource.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { Action } from './action';\nimport { Abilities } from './common';\nimport { Field } from './field';\nimport { LayoutNode } from './layout';\nimport { ListDefinition } from './list';\n\nexport const ResourceFeatures = z.looseObject({\n drafts: z.boolean().optional(),\n revisions: z.boolean().optional(),\n preview: z\n .union([\n z.null(),\n z.looseObject({\n mode: z.enum(['component', 'iframe']),\n component: z\n .string()\n .optional()\n .meta({ description: '`component`: the plugin preview.' }),\n }),\n ])\n .optional(),\n search: z.boolean().optional().meta({\n description:\n 'Whether the resource is in the global search. Defaults to whether its list has a search (`list.search`).',\n }),\n});\n\nexport const ResourceType = z\n .looseObject({\n id: z.string().min(1).meta({\n description: 'The `type` of the items of this type, which the client sends on create.',\n }),\n label: z.string().meta({\n description:\n 'The name of the type: the title of its create form and of its choice when creating.',\n }),\n description: z\n .string()\n .optional()\n .meta({ description: 'A line under the label, in the choice of a type.' }),\n icon: z.string().optional(),\n // The return type is written out so that declaration files name `Field`.\n get fields(): z.ZodArray<typeof Field> {\n return z.array(Field).meta({\n description:\n \"The type's own fields, after those of the resource. The resource's `form.layout` can name them: forms of the other types leave them out.\",\n });\n },\n abilities: Abilities.optional().meta({\n description:\n '`create: false`: the type is not offered when creating, and the backend refuses to create one (a singleton such as the home page). Its items can still be edited.',\n }),\n })\n .meta({\n description:\n 'A type of the items of a resource (decision 0077): the items of a type have the fields of the resource and its own.',\n });\n\nexport const Resource = z\n .looseObject({\n id: z.string().min(1),\n kind: z.string().min(1).optional().meta({\n description:\n \"What the resource is. `media`: a library of media (decision 0026), with a `file` field and a `media` on each item. Without it, an ordinary resource. Clients treat a kind they don't know as an ordinary resource.\",\n }),\n label: z.looseObject({ singular: z.string(), plural: z.string() }),\n description: z.string().optional(),\n icon: z.string().optional(),\n itemTitle: z\n .string()\n .optional()\n .meta({ description: 'The field used as the title of an item, in lists and pickers.' }),\n itemSubtitle: z.string().optional().meta({\n description:\n 'The field shown under the title of an item, in search results, cards and pickers.',\n }),\n itemImage: z.string().optional().meta({\n description:\n \"The field that holds the image of an item (a media, a file or a URL), in search results, pickers, the gallery and the thumbnails of the table. Defaults to the item's `media` in a resource of kind `media` (decision 0061).\",\n }),\n open: z\n .union([z.enum(['panel', 'edit']), z.string().min(1)])\n .optional()\n .meta({\n description:\n \"Where an item's title goes, in its list and wherever the app links to the item (decision 0040). `panel`, the default: the show route, with the item's details in a panel next to the list. `edit`: its edit form, and the show route redirects there. Clients treat a value they don't know as `panel`.\",\n }),\n itemActions: z.array(z.string().min(1)).optional().meta({\n description:\n \"The built-in item actions the resource shows, in their order (decision 0040): some of `show`, `edit`, `duplicate` and `delete`. Defaults to all four. Each one is shown on the items whose abilities allow it (`view`, `update`, `duplicate`, `delete`). `[]` shows none. Clients ignore ids they don't know.\",\n }),\n fields: z.array(Field),\n form: z.looseObject({ layout: z.array(LayoutNode).optional() }).optional(),\n list: ListDefinition.optional(),\n actions: z.array(Action).optional(),\n abilities: Abilities.optional(),\n features: ResourceFeatures.optional(),\n types: z.array(ResourceType).optional().meta({\n description:\n \"The types of the resource's items, each with fields of its own (decision 0077). Each item has a `type`, set when it is created, among their ids.\",\n }),\n settings: z.record(z.string(), z.unknown()).optional(),\n })\n .meta({ description: 'A set of items managed in the admin.' });\n\nexport type ResourceFeatures = z.infer<typeof ResourceFeatures>;\nexport type ResourceType = z.infer<typeof ResourceType>;\nexport type Resource = z.infer<typeof Resource>;\n/** A resource as a backend writes it, before defaults are applied. */\nexport type ResourceInput = z.input<typeof Resource>;\n"],"mappings":";;;;;;;AAQA,IAAa,mBAAmB,EAAE,YAAY;CAC1C,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAAS,EACJ,MAAM,CACH,EAAE,KAAK,GACP,EAAE,YAAY;EACV,MAAM,EAAE,KAAK,CAAC,aAAa,QAAQ,CAAC;EACpC,WAAW,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,KAAK,EAAE,aAAa,mCAAmC,CAAC;CACjE,CAAC,CACL,CAAC,CAAC,CACD,SAAS;CACd,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAChC,aACI,2GACR,CAAC;AACL,CAAC;AAED,IAAa,eAAe,EACvB,YAAY;CACT,IAAI,EAAE,OAAO,CAAC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CAAC;CACL,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACpD,aACI,gTACR,CAAC;CACD,QAAQ,EAAE,MAAM,KAAK;CACrB,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS;CACzE,MAAM,eAAe,SAAS;CAC9B,SAAS,EAAE,MAAM,MAAM,CAAC,CAAC,SAAS;CAClC,WAAW,UAAU,SAAS;CAC9B,UAAU,iBAAiB,SAAS;CACpC,OAAO,EAAE,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACzC,aACI,mJACR,CAAC;CACD,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;AACzD,CAAC,CAAC,CACD,KAAK,EAAE,aAAa,uCAAuC,CAAC"}
1
+ {"version":3,"file":"resource.js","names":[],"sources":["../../src/schemas/resource.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { Action } from './action';\nimport { Abilities } from './common';\nimport { Field } from './field';\nimport { LayoutNode } from './layout';\nimport { ListDefinition } from './list';\nimport { OverviewPeriod, Widget } from './widget';\n\nexport const ResourceFeatures = z.looseObject({\n drafts: z.boolean().optional(),\n revisions: z.boolean().optional(),\n preview: z\n .union([\n z.null(),\n z.looseObject({\n mode: z.enum(['component', 'iframe']),\n component: z\n .string()\n .optional()\n .meta({ description: '`component`: the plugin preview.' }),\n }),\n ])\n .optional(),\n search: z.boolean().optional().meta({\n description:\n 'Whether the resource is in the global search. Defaults to whether its list has a search (`list.search`).',\n }),\n});\n\nexport const ResourceType = z\n .looseObject({\n id: z.string().min(1).meta({\n description: 'The `type` of the items of this type, which the client sends on create.',\n }),\n label: z.string().meta({\n description:\n 'The name of the type: the title of its create form and of its choice when creating.',\n }),\n description: z\n .string()\n .optional()\n .meta({ description: 'A line under the label, in the choice of a type.' }),\n icon: z.string().optional(),\n // The return type is written out so that declaration files name `Field`.\n get fields(): z.ZodArray<typeof Field> {\n return z.array(Field).meta({\n description:\n \"The type's own fields, after those of the resource. The resource's `form.layout` can name them: forms of the other types leave them out.\",\n });\n },\n abilities: Abilities.optional().meta({\n description:\n '`create: false`: the type is not offered when creating, and the backend refuses to create one (a singleton such as the home page). Its items can still be edited.',\n }),\n })\n .meta({\n description:\n 'A type of the items of a resource (decision 0077): the items of a type have the fields of the resource and its own.',\n });\n\nexport const SummaryPeriod = OverviewPeriod.extend({\n filter: z.string().min(1).optional().meta({\n description:\n \"The id of the list's `date-range` filter that the period sets. Defaults to the first `date-range` filter of the list.\",\n }),\n}).meta({\n description:\n \"The period of a summary (decision 0084): the list's own `date-range` filter, so choosing it filters the rows too.\",\n});\n\nexport const ResourceSummary = z\n .looseObject({\n widgets: z.array(Widget).meta({\n description:\n \"The widgets of the summary for the user, in order, drawn above the list in the grid of a dashboard. Widgets on this resource get the list's current filters and search, unless `settings.followsList` is `false`. Widgets with data of their own are fed by `GET /dashboard/widgets/{widget}?resource={resource}`, with the filters and the search of the list.\",\n }),\n list: z.enum(['collapsed']).optional().meta({\n description:\n '`collapsed`: the resource opens on its summary, with its list folded under it behind \"Show the N items\". Without it, the list is shown under the summary.',\n }),\n period: SummaryPeriod.optional(),\n })\n .meta({\n description:\n 'Widgets above the list of a resource, which follow its filters and its search (decision 0084).',\n });\n\nexport const Resource = z\n .looseObject({\n id: z.string().min(1),\n kind: z.string().min(1).optional().meta({\n description:\n \"What the resource is. `media`: a library of media (decision 0026), with a `file` field and a `media` on each item. Without it, an ordinary resource. Clients treat a kind they don't know as an ordinary resource.\",\n }),\n label: z.looseObject({ singular: z.string(), plural: z.string() }),\n description: z.string().optional(),\n icon: z.string().optional(),\n itemTitle: z\n .string()\n .optional()\n .meta({ description: 'The field used as the title of an item, in lists and pickers.' }),\n itemSubtitle: z.string().optional().meta({\n description:\n 'The field shown under the title of an item, in search results, cards and pickers.',\n }),\n itemImage: z.string().optional().meta({\n description:\n \"The field that holds the image of an item (a media, a file or a URL), in search results, pickers, the gallery and the thumbnails of the table. Defaults to the item's `media` in a resource of kind `media` (decision 0061).\",\n }),\n open: z\n .union([z.enum(['panel', 'edit']), z.string().min(1)])\n .optional()\n .meta({\n description:\n \"Where an item's title goes, in its list and wherever the app links to the item (decision 0082). `edit`, the default: its edit form, and the show route redirects there. An item the user can't update still opens in the panel. `panel`: the show route, with the item's details in a panel next to the list, for items read more than edited, or shown with their preview. Clients treat a value they don't know as `edit`.\",\n }),\n itemActions: z.array(z.string().min(1)).optional().meta({\n description:\n \"The built-in item actions the resource shows, in their order (decision 0040): some of `show`, `edit`, `duplicate` and `delete`. Defaults to all four. Each one is shown on the items whose abilities allow it (`view`, `update`, `duplicate`, `delete`). `[]` shows none. Clients ignore ids they don't know.\",\n }),\n fields: z.array(Field),\n form: z.looseObject({ layout: z.array(LayoutNode).optional() }).optional(),\n list: ListDefinition.optional(),\n actions: z.array(Action).optional(),\n abilities: Abilities.optional(),\n features: ResourceFeatures.optional(),\n types: z.array(ResourceType).optional().meta({\n description:\n \"The types of the resource's items, each with fields of its own (decision 0077). Each item has a `type`, set when it is created, among their ids.\",\n }),\n summary: ResourceSummary.optional().meta({\n description:\n 'Widgets above the list, which follow its filters and its search (decision 0084).',\n }),\n settings: z.record(z.string(), z.unknown()).optional(),\n })\n .meta({ description: 'A set of items managed in the admin.' });\n\nexport type ResourceFeatures = z.infer<typeof ResourceFeatures>;\nexport type ResourceType = z.infer<typeof ResourceType>;\nexport type SummaryPeriod = z.infer<typeof SummaryPeriod>;\nexport type ResourceSummary = z.infer<typeof ResourceSummary>;\nexport type Resource = z.infer<typeof Resource>;\n/** A resource as a backend writes it, before defaults are applied. */\nexport type ResourceInput = z.input<typeof Resource>;\n"],"mappings":";;;;;;;;AASA,IAAa,mBAAmB,EAAE,YAAY;CAC1C,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;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S;CAClC,WAAW,UAAU,SAAS;CAC9B,UAAU,iBAAiB,SAAS;CACpC,OAAO,EAAE,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACzC,aACI,mJACR,CAAC;CACD,SAAS,gBAAgB,SAAS,CAAC,CAAC,KAAK,EACrC,aACI,mFACR,CAAC;CACD,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;AACzD,CAAC,CAAC,CACD,KAAK,EAAE,aAAa,uCAAuC,CAAC"}
@@ -2,6 +2,27 @@ import { z } from 'zod';
2
2
  export declare const WidgetSettings: z.ZodObject<{
3
3
  resource: z.ZodOptional<z.ZodString>;
4
4
  query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
5
+ measure: z.ZodOptional<z.ZodString>;
6
+ group: z.ZodOptional<z.ZodString>;
7
+ target: z.ZodOptional<z.ZodNumber>;
8
+ period: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
9
+ followsList: z.ZodOptional<z.ZodBoolean>;
10
+ }, z.core.$loose>;
11
+ export declare const OverviewPeriod: z.ZodObject<{
12
+ options: z.ZodArray<z.ZodEnum<{
13
+ "7d": "7d";
14
+ "30d": "30d";
15
+ "90d": "90d";
16
+ month: "month";
17
+ year: "year";
18
+ }>>;
19
+ default: z.ZodOptional<z.ZodEnum<{
20
+ "7d": "7d";
21
+ "30d": "30d";
22
+ "90d": "90d";
23
+ month: "month";
24
+ year: "year";
25
+ }>>;
5
26
  }, z.core.$loose>;
6
27
  export declare const Widget: z.ZodObject<{
7
28
  id: z.ZodString;
@@ -11,6 +32,11 @@ export declare const Widget: z.ZodObject<{
11
32
  settings: z.ZodOptional<z.ZodObject<{
12
33
  resource: z.ZodOptional<z.ZodString>;
13
34
  query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
35
+ measure: z.ZodOptional<z.ZodString>;
36
+ group: z.ZodOptional<z.ZodString>;
37
+ target: z.ZodOptional<z.ZodNumber>;
38
+ period: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
39
+ followsList: z.ZodOptional<z.ZodBoolean>;
14
40
  }, z.core.$loose>>;
15
41
  }, z.core.$loose>;
16
42
  export declare const WidgetBadge: z.ZodObject<{
@@ -22,6 +48,7 @@ export declare const StatWidgetData: z.ZodObject<{
22
48
  help: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
49
  tone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
50
  url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ target: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
25
52
  }, z.core.$loose>;
26
53
  export declare const SeriesPoint: z.ZodObject<{
27
54
  date: z.ZodString;
@@ -29,9 +56,9 @@ export declare const SeriesPoint: z.ZodObject<{
29
56
  }, z.core.$loose>;
30
57
  export declare const SeriesWidgetData: z.ZodObject<{
31
58
  period: z.ZodEnum<{
59
+ month: "month";
32
60
  day: "day";
33
61
  week: "week";
34
- month: "month";
35
62
  }>;
36
63
  points: z.ZodArray<z.ZodObject<{
37
64
  date: z.ZodString;
@@ -63,6 +90,24 @@ export declare const ListWidgetData: z.ZodObject<{
63
90
  empty: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
91
  url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
92
  }, z.core.$loose>;
93
+ export declare const BreakdownWidgetItem: z.ZodObject<{
94
+ label: z.ZodString;
95
+ value: z.ZodNumber;
96
+ tone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
97
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
98
+ key: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
99
+ }, z.core.$loose>;
100
+ export declare const BreakdownWidgetData: z.ZodObject<{
101
+ items: z.ZodArray<z.ZodObject<{
102
+ label: z.ZodString;
103
+ value: z.ZodNumber;
104
+ tone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
+ key: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
107
+ }, z.core.$loose>>;
108
+ total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
109
+ other: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
110
+ }, z.core.$loose>;
66
111
  /** The schema of the data of each built-in widget type. */
67
112
  export declare const widgetDataSchemas: {
68
113
  readonly stat: z.ZodObject<{
@@ -70,12 +115,13 @@ export declare const widgetDataSchemas: {
70
115
  help: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
116
  tone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
117
  url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
+ target: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
73
119
  }, z.core.$loose>;
74
120
  readonly series: z.ZodObject<{
75
121
  period: z.ZodEnum<{
122
+ month: "month";
76
123
  day: "day";
77
124
  week: "week";
78
- month: "month";
79
125
  }>;
80
126
  points: z.ZodArray<z.ZodObject<{
81
127
  date: z.ZodString;
@@ -97,7 +143,19 @@ export declare const widgetDataSchemas: {
97
143
  empty: z.ZodOptional<z.ZodNullable<z.ZodString>>;
98
144
  url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
99
145
  }, z.core.$loose>;
146
+ readonly breakdown: z.ZodObject<{
147
+ items: z.ZodArray<z.ZodObject<{
148
+ label: z.ZodString;
149
+ value: z.ZodNumber;
150
+ tone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
151
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
152
+ key: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
153
+ }, z.core.$loose>>;
154
+ total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
155
+ other: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
156
+ }, z.core.$loose>;
100
157
  };
158
+ export type OverviewPeriod = z.infer<typeof OverviewPeriod>;
101
159
  export type WidgetSettings = z.infer<typeof WidgetSettings>;
102
160
  export type Widget = z.infer<typeof Widget>;
103
161
  export type WidgetBadge = z.infer<typeof WidgetBadge>;
@@ -106,4 +164,6 @@ export type SeriesPoint = z.infer<typeof SeriesPoint>;
106
164
  export type SeriesWidgetData = z.infer<typeof SeriesWidgetData>;
107
165
  export type ListWidgetItem = z.infer<typeof ListWidgetItem>;
108
166
  export type ListWidgetData = z.infer<typeof ListWidgetData>;
167
+ export type BreakdownWidgetItem = z.infer<typeof BreakdownWidgetItem>;
168
+ export type BreakdownWidgetData = z.infer<typeof BreakdownWidgetData>;
109
169
  //# sourceMappingURL=widget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/schemas/widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,cAAc;;;iBAiBrB,CAAC;AAEP,eAAO,MAAM,MAAM;;;;;;;;;iBAejB,CAAC;AAEH,eAAO,MAAM,WAAW;;;iBAE8C,CAAC;AAEvE,eAAO,MAAM,cAAc;;;;;iBAgByD,CAAC;AAErF,eAAO,MAAM,WAAW;;;iBAMtB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;iBAyBvB,CAAC;AAEP,eAAO,MAAM,cAAc;;;;;;;;;iBAUzB,CAAC;AAEH,eAAO,MAAM,cAAc;;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from "../widgets.js";
2
+ import { OVERVIEW_PERIODS } from "../periods.js";
2
3
  import { z } from "zod";
3
4
  //#region src/schemas/widget.ts
4
5
  var ToneName = z.string().regex(/^[a-z0-9-]+$/);
@@ -8,12 +9,21 @@ var QueryValue = z.union([
8
9
  z.boolean()
9
10
  ]);
10
11
  var WidgetSettings = z.looseObject({
11
- resource: z.string().min(1).optional().meta({ description: "Built-in `stat` and `list`: the resource whose list feeds the widget. The client reads `GET /resources/{resource}` with `query`: a `stat` counts its items (`meta.total`), a `list` shows its first items. Such a widget has no data at `GET /dashboard/widgets/{widget}`." }),
12
- query: z.record(z.string(), z.union([QueryValue, z.array(QueryValue)])).optional().meta({ description: "With `resource`: the query of the list, as its query parameters (`{ \"filter[status]\": \"to-judge\", \"sort\": \"-created_at\" }`), and of the link to the list. The client sets `page`, `perPage` and `cursor`." })
13
- }).meta({ description: "The settings of a widget: `resource` and `query` for the built-in `stat` and `list` on a resource, anything else for widgets of plugins." });
12
+ resource: z.string().min(1).optional().meta({ description: "Built-in types: the resource that feeds the widget. A `stat` counts the items of its list (`meta.total`), a `list` shows its first items, and a `series`, a `breakdown` and a `stat` with a `sum:` measure read `GET /resources/{resource}/aggregate` (decision 0084). Such a widget has no data at `GET /dashboard/widgets/{widget}`." }),
13
+ query: z.record(z.string(), z.union([QueryValue, z.array(QueryValue)])).optional().meta({ description: "With `resource`: the query of the list, as its query parameters (`{ \"filter[status]\": \"to-judge\", \"sort\": \"-created_at\" }`), and of the link to the list. The client sets `page`, `perPage` and `cursor`." }),
14
+ measure: z.string().min(1).optional().meta({ description: "With `resource`, for a `stat`, a `series` and a `breakdown`: `count` (the default), or `sum:{field}` of a field of the `sum` of the aggregates of the list." }),
15
+ group: z.string().min(1).optional().meta({ description: "With `resource`: for a `series`, `{period}:{date field}` (`day`, `week` or `month`, and a field of `dates` of the aggregates of the list); for a `breakdown`, a field of their `groupBy`." }),
16
+ target: z.number().positive().optional().meta({ description: "With `resource`, for a `stat`: its `target` (a budget, a quota), in the unit of the value: minor units for a sum of `money`." }),
17
+ period: z.union([z.string().min(1), z.literal(false)]).optional().meta({ description: "In an overview with a `period` (decision 0084). With `resource`: the id of the list's `date-range` filter that gets the days of the chosen period. `false`: the widget doesn't follow the period; a widget with data of its own then gets no `period` parameters." }),
18
+ followsList: z.boolean().optional().meta({ description: "In the summary of a resource (decision 0084): `false` keeps the widget on the whole resource, without the list's current filters and search. Widgets on that resource, and widgets with data of their own, follow the list by default." })
19
+ }).meta({ description: "The settings of a widget: `resource`, `query`, `measure`, `group` and `target` for the built-in types on a resource, `period` in an overview with a period, `followsList` in a summary, anything else for widgets of plugins." });
20
+ var OverviewPeriod = z.looseObject({
21
+ options: z.array(z.enum(OVERVIEW_PERIODS)).min(1).meta({ description: "The periods the user chooses from, in order: `7d`, `30d` and `90d`, the 7, 30 or 90 days ending today; `month`, the current calendar month, from its first day to today; `year`, the last 12 months, from the first day of the month 11 months ago to today. Days are those of the time zone of the browser." }),
22
+ default: z.enum(OVERVIEW_PERIODS).optional().meta({ description: "The period the overview opens on, among `options`. Defaults to the first." })
23
+ }).meta({ description: "One period for the widgets of a dashboard page or a summary, chosen in its header and kept in the URL (`?period=30d`, decision 0084)." });
14
24
  var Widget = z.looseObject({
15
- id: z.string().min(1).meta({ description: "Unique in the dashboard: the `{widget}` of its route." }),
16
- type: z.string().min(1).meta({ description: "Built-in: `stat` (a number), `series` (a line over days, weeks or months) and `list` (a few items). Other types are widgets of plugins." }),
25
+ id: z.string().min(1).meta({ description: "Unique in its dashboard: the `{widget}` of its route." }),
26
+ type: z.string().min(1).meta({ description: "Built-in: `stat` (a number), `series` (a line over days, weeks or months), `list` (a few items) and `breakdown` (the parts of a total). Other types are widgets of plugins." }),
17
27
  label: z.string().optional(),
18
28
  width: z.number().int().min(1).max(12).optional().meta({ description: "Columns of a grid of 12. Defaults to 3 for a `stat`, 6 for others. One column on a phone." }),
19
29
  settings: WidgetSettings.optional()
@@ -26,7 +36,8 @@ var StatWidgetData = z.looseObject({
26
36
  value: z.number().meta({ description: "The number, in large type." }),
27
37
  help: z.string().nullable().optional().meta({ description: "A line under the number, translated: `3 more than last week`." }),
28
38
  tone: ToneName.nullable().optional().meta({ description: "A tone of the theme, only when the number calls for attention (`warning`, `danger`): neutral otherwise, and at 0." }),
29
- url: z.string().nullable().optional().meta({ description: "Where the widget links: the list of what it counts." })
39
+ url: z.string().nullable().optional().meta({ description: "Where the widget links: the list of what it counts." }),
40
+ target: z.number().positive().nullable().optional().meta({ description: "A target for the number (a budget, a quota), drawn as a meter under it. Past it, the meter takes `tone`, or `danger` without one (decision 0084)." })
30
41
  }).meta({ description: "The data of a `stat` widget: a number (decision 0064)." });
31
42
  var SeriesPoint = z.looseObject({
32
43
  date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).meta({ description: "The first day of the period: `2026-10-05`." }),
@@ -62,13 +73,30 @@ var ListWidgetData = z.looseObject({
62
73
  empty: z.string().nullable().optional().meta({ description: "The message without items, translated: `No open contests.`" }),
63
74
  url: z.string().nullable().optional().meta({ description: "Where \"See all\" links, under the items." })
64
75
  }).meta({ description: "The data of a `list` widget: a few items (decision 0064)." });
76
+ var BreakdownWidgetItem = z.looseObject({
77
+ label: z.string().meta({ description: "What the part is, translated: `Failed`." }),
78
+ value: z.number().meta({ description: "The count or the sum of the part." }),
79
+ tone: ToneName.nullable().optional().meta({ description: "A tone of the theme for its bar: the tone of an option of a `select`." }),
80
+ url: z.string().nullable().optional().meta({ description: "Where the bar links: the list of what it counts." }),
81
+ key: z.union([
82
+ z.string(),
83
+ z.number(),
84
+ z.boolean()
85
+ ]).nullable().optional().meta({ description: "From `GET /resources/{resource}/aggregate`: the value of the field it groups, `null` for the items without one. The client links the bar to the list filtered by it." })
86
+ });
87
+ var BreakdownWidgetData = z.looseObject({
88
+ items: z.array(BreakdownWidgetItem).max(10).meta({ description: `The parts, at most 10: clients draw the largest first.` }),
89
+ total: z.number().nullable().optional().meta({ description: "The total the parts are of. Items with several values count in each of their parts, and once in the total." }),
90
+ other: z.number().nullable().optional().meta({ description: "The rest of the total, past the items: drawn last, as \"Other\"." })
91
+ }).meta({ description: "The data of a `breakdown` widget: the parts of a total, as horizontal bars (decision 0084)." });
65
92
  /** The schema of the data of each built-in widget type. */
66
93
  var widgetDataSchemas = {
67
94
  stat: StatWidgetData,
68
95
  series: SeriesWidgetData,
69
- list: ListWidgetData
96
+ list: ListWidgetData,
97
+ breakdown: BreakdownWidgetData
70
98
  };
71
99
  //#endregion
72
- export { ListWidgetData, ListWidgetItem, SeriesPoint, SeriesWidgetData, StatWidgetData, Widget, WidgetBadge, WidgetSettings, widgetDataSchemas };
100
+ export { BreakdownWidgetData, BreakdownWidgetItem, ListWidgetData, ListWidgetItem, OverviewPeriod, SeriesPoint, SeriesWidgetData, StatWidgetData, Widget, WidgetBadge, WidgetSettings, widgetDataSchemas };
73
101
 
74
102
  //# sourceMappingURL=widget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"widget.js","names":[],"sources":["../../src/schemas/widget.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { WIDGET_LIST_MAX_ITEMS, WIDGET_SERIES_PERIODS } from '../widgets';\n\nconst ToneName = z.string().regex(/^[a-z0-9-]+$/);\n\nconst QueryValue = z.union([z.string(), z.number(), z.boolean()]);\n\nexport const WidgetSettings = z\n .looseObject({\n resource: z.string().min(1).optional().meta({\n description:\n 'Built-in `stat` and `list`: the resource whose list feeds the widget. The client reads `GET /resources/{resource}` with `query`: a `stat` counts its items (`meta.total`), a `list` shows its first items. Such a widget has no data at `GET /dashboard/widgets/{widget}`.',\n }),\n query: z\n .record(z.string(), z.union([QueryValue, z.array(QueryValue)]))\n .optional()\n .meta({\n description:\n 'With `resource`: the query of the list, as its query parameters (`{ \"filter[status]\": \"to-judge\", \"sort\": \"-created_at\" }`), and of the link to the list. The client sets `page`, `perPage` and `cursor`.',\n }),\n })\n .meta({\n description:\n 'The settings of a widget: `resource` and `query` for the built-in `stat` and `list` on a resource, anything else for widgets of plugins.',\n });\n\nexport const Widget = z.looseObject({\n id: z\n .string()\n .min(1)\n .meta({ description: 'Unique in the dashboard: the `{widget}` of its route.' }),\n type: z.string().min(1).meta({\n description:\n 'Built-in: `stat` (a number), `series` (a line over days, weeks or months) and `list` (a few items). Other types are widgets of plugins.',\n }),\n label: z.string().optional(),\n width: z.number().int().min(1).max(12).optional().meta({\n description:\n 'Columns of a grid of 12. Defaults to 3 for a `stat`, 6 for others. One column on a phone.',\n }),\n settings: WidgetSettings.optional(),\n});\n\nexport const WidgetBadge = z\n .looseObject({ label: z.string(), tone: ToneName.optional() })\n .meta({ description: 'A badge: a word, in a tone of the theme.' });\n\nexport const StatWidgetData = z\n .looseObject({\n value: z.number().meta({ description: 'The number, in large type.' }),\n help: z.string().nullable().optional().meta({\n description: 'A line under the number, translated: `3 more than last week`.',\n }),\n tone: ToneName.nullable().optional().meta({\n description:\n 'A tone of the theme, only when the number calls for attention (`warning`, `danger`): neutral otherwise, and at 0.',\n }),\n url: z\n .string()\n .nullable()\n .optional()\n .meta({ description: 'Where the widget links: the list of what it counts.' }),\n })\n .meta({ description: 'The data of a `stat` widget: a number (decision 0064).' });\n\nexport const SeriesPoint = z.looseObject({\n date: z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/)\n .meta({ description: 'The first day of the period: `2026-10-05`.' }),\n value: z.number(),\n});\n\nexport const SeriesWidgetData = z\n .looseObject({\n period: z.enum(WIDGET_SERIES_PERIODS).meta({ description: 'The period of each point.' }),\n points: z.array(SeriesPoint).meta({\n description:\n 'One point per period, the dates going up. Periods without a value are points at 0.',\n }),\n total: z.number().nullable().optional().meta({\n description: 'The total over the points, shown with the line.',\n }),\n })\n .superRefine((data, context) => {\n data.points.forEach((point, index) => {\n const previous = data.points[index - 1];\n if (previous !== undefined && point.date <= previous.date) {\n context.addIssue({\n code: 'custom',\n message: 'The dates of the points must go up.',\n path: ['points', index, 'date'],\n });\n }\n });\n })\n .meta({\n description: 'The data of a `series` widget: a line of values per period (decision 0064).',\n });\n\nexport const ListWidgetItem = z.looseObject({\n title: z.string(),\n description: z.string().nullable().optional(),\n meta: z\n .string()\n .nullable()\n .optional()\n .meta({ description: 'A short fact at the end of the item: `12 answers`.' }),\n url: z.string().nullable().optional(),\n badge: WidgetBadge.nullable().optional(),\n});\n\nexport const ListWidgetData = z\n .looseObject({\n items: z\n .array(ListWidgetItem)\n .max(WIDGET_LIST_MAX_ITEMS)\n .meta({\n description: `At most ${WIDGET_LIST_MAX_ITEMS} items, the most useful first.`,\n }),\n empty: z.string().nullable().optional().meta({\n description: 'The message without items, translated: `No open contests.`',\n }),\n url: z\n .string()\n .nullable()\n .optional()\n .meta({ description: 'Where \"See all\" links, under the items.' }),\n })\n .meta({ description: 'The data of a `list` widget: a few items (decision 0064).' });\n\n/** The schema of the data of each built-in widget type. */\nexport const widgetDataSchemas = {\n stat: StatWidgetData,\n series: SeriesWidgetData,\n list: ListWidgetData,\n} as const;\n\nexport type WidgetSettings = z.infer<typeof WidgetSettings>;\nexport type Widget = z.infer<typeof Widget>;\nexport type WidgetBadge = z.infer<typeof WidgetBadge>;\nexport type StatWidgetData = z.infer<typeof StatWidgetData>;\nexport type SeriesPoint = z.infer<typeof SeriesPoint>;\nexport type SeriesWidgetData = z.infer<typeof SeriesWidgetData>;\nexport type ListWidgetItem = z.infer<typeof ListWidgetItem>;\nexport type ListWidgetData = z.infer<typeof ListWidgetData>;\n"],"mappings":";;;AAIA,IAAM,WAAW,EAAE,OAAO,CAAC,CAAC,MAAM,cAAc;AAEhD,IAAM,aAAa,EAAE,MAAM;CAAC,EAAE,OAAO;CAAG,EAAE,OAAO;CAAG,EAAE,QAAQ;AAAC,CAAC;AAEhE,IAAa,iBAAiB,EACzB,YAAY;CACT,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACxC,aACI,6QACR,CAAC;CACD,OAAO,EACF,OAAO,EAAE,OAAO,GAAG,EAAE,MA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K,EACzC,aAAa,6DACjB,CAAC;CACD,KAAK,EACA,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,CAAC,CACV,KAAK,EAAE,aAAa,4CAA0C,CAAC;AACxE,CAAC,CAAC,CACD,KAAK,EAAE,aAAa,4DAA4D,CAAC;;AAGtF,IAAa,oBAAoB;CAC7B,MAAM;CACN,QAAQ;CACR,MAAM;AACV"}
1
+ {"version":3,"file":"widget.js","names":[],"sources":["../../src/schemas/widget.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { OVERVIEW_PERIODS } from '../periods';\nimport {\n WIDGET_BREAKDOWN_MAX_ITEMS,\n WIDGET_LIST_MAX_ITEMS,\n WIDGET_SERIES_PERIODS,\n} from '../widgets';\n\nconst ToneName = z.string().regex(/^[a-z0-9-]+$/);\n\nconst QueryValue = z.union([z.string(), z.number(), z.boolean()]);\n\nexport const WidgetSettings = z\n .looseObject({\n resource: z.string().min(1).optional().meta({\n description:\n 'Built-in types: the resource that feeds the widget. A `stat` counts the items of its list (`meta.total`), a `list` shows its first items, and a `series`, a `breakdown` and a `stat` with a `sum:` measure read `GET /resources/{resource}/aggregate` (decision 0084). Such a widget has no data at `GET /dashboard/widgets/{widget}`.',\n }),\n query: z\n .record(z.string(), z.union([QueryValue, z.array(QueryValue)]))\n .optional()\n .meta({\n description:\n 'With `resource`: the query of the list, as its query parameters (`{ \"filter[status]\": \"to-judge\", \"sort\": \"-created_at\" }`), and of the link to the list. The client sets `page`, `perPage` and `cursor`.',\n }),\n measure: z.string().min(1).optional().meta({\n description:\n 'With `resource`, for a `stat`, a `series` and a `breakdown`: `count` (the default), or `sum:{field}` of a field of the `sum` of the aggregates of the list.',\n }),\n group: z.string().min(1).optional().meta({\n description:\n 'With `resource`: for a `series`, `{period}:{date field}` (`day`, `week` or `month`, and a field of `dates` of the aggregates of the list); for a `breakdown`, a field of their `groupBy`.',\n }),\n target: z.number().positive().optional().meta({\n description:\n 'With `resource`, for a `stat`: its `target` (a budget, a quota), in the unit of the value: minor units for a sum of `money`.',\n }),\n period: z\n .union([z.string().min(1), z.literal(false)])\n .optional()\n .meta({\n description:\n \"In an overview with a `period` (decision 0084). With `resource`: the id of the list's `date-range` filter that gets the days of the chosen period. `false`: the widget doesn't follow the period; a widget with data of its own then gets no `period` parameters.\",\n }),\n followsList: z.boolean().optional().meta({\n description:\n \"In the summary of a resource (decision 0084): `false` keeps the widget on the whole resource, without the list's current filters and search. Widgets on that resource, and widgets with data of their own, follow the list by default.\",\n }),\n })\n .meta({\n description:\n 'The settings of a widget: `resource`, `query`, `measure`, `group` and `target` for the built-in types on a resource, `period` in an overview with a period, `followsList` in a summary, anything else for widgets of plugins.',\n });\n\nexport const OverviewPeriod = z\n .looseObject({\n options: z.array(z.enum(OVERVIEW_PERIODS)).min(1).meta({\n description:\n 'The periods the user chooses from, in order: `7d`, `30d` and `90d`, the 7, 30 or 90 days ending today; `month`, the current calendar month, from its first day to today; `year`, the last 12 months, from the first day of the month 11 months ago to today. Days are those of the time zone of the browser.',\n }),\n default: z.enum(OVERVIEW_PERIODS).optional().meta({\n description:\n 'The period the overview opens on, among `options`. Defaults to the first.',\n }),\n })\n .meta({\n description:\n 'One period for the widgets of a dashboard page or a summary, chosen in its header and kept in the URL (`?period=30d`, decision 0084).',\n });\n\nexport const Widget = z.looseObject({\n id: z\n .string()\n .min(1)\n .meta({ description: 'Unique in its dashboard: the `{widget}` of its route.' }),\n type: z.string().min(1).meta({\n description:\n 'Built-in: `stat` (a number), `series` (a line over days, weeks or months), `list` (a few items) and `breakdown` (the parts of a total). Other types are widgets of plugins.',\n }),\n label: z.string().optional(),\n width: z.number().int().min(1).max(12).optional().meta({\n description:\n 'Columns of a grid of 12. Defaults to 3 for a `stat`, 6 for others. One column on a phone.',\n }),\n settings: WidgetSettings.optional(),\n});\n\nexport const WidgetBadge = z\n .looseObject({ label: z.string(), tone: ToneName.optional() })\n .meta({ description: 'A badge: a word, in a tone of the theme.' });\n\nexport const StatWidgetData = z\n .looseObject({\n value: z.number().meta({ description: 'The number, in large type.' }),\n help: z.string().nullable().optional().meta({\n description: 'A line under the number, translated: `3 more than last week`.',\n }),\n tone: ToneName.nullable().optional().meta({\n description:\n 'A tone of the theme, only when the number calls for attention (`warning`, `danger`): neutral otherwise, and at 0.',\n }),\n url: z\n .string()\n .nullable()\n .optional()\n .meta({ description: 'Where the widget links: the list of what it counts.' }),\n target: z.number().positive().nullable().optional().meta({\n description:\n 'A target for the number (a budget, a quota), drawn as a meter under it. Past it, the meter takes `tone`, or `danger` without one (decision 0084).',\n }),\n })\n .meta({ description: 'The data of a `stat` widget: a number (decision 0064).' });\n\nexport const SeriesPoint = z.looseObject({\n date: z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/)\n .meta({ description: 'The first day of the period: `2026-10-05`.' }),\n value: z.number(),\n});\n\nexport const SeriesWidgetData = z\n .looseObject({\n period: z.enum(WIDGET_SERIES_PERIODS).meta({ description: 'The period of each point.' }),\n points: z.array(SeriesPoint).meta({\n description:\n 'One point per period, the dates going up. Periods without a value are points at 0.',\n }),\n total: z.number().nullable().optional().meta({\n description: 'The total over the points, shown with the line.',\n }),\n })\n .superRefine((data, context) => {\n data.points.forEach((point, index) => {\n const previous = data.points[index - 1];\n if (previous !== undefined && point.date <= previous.date) {\n context.addIssue({\n code: 'custom',\n message: 'The dates of the points must go up.',\n path: ['points', index, 'date'],\n });\n }\n });\n })\n .meta({\n description: 'The data of a `series` widget: a line of values per period (decision 0064).',\n });\n\nexport const ListWidgetItem = z.looseObject({\n title: z.string(),\n description: z.string().nullable().optional(),\n meta: z\n .string()\n .nullable()\n .optional()\n .meta({ description: 'A short fact at the end of the item: `12 answers`.' }),\n url: z.string().nullable().optional(),\n badge: WidgetBadge.nullable().optional(),\n});\n\nexport const ListWidgetData = z\n .looseObject({\n items: z\n .array(ListWidgetItem)\n .max(WIDGET_LIST_MAX_ITEMS)\n .meta({\n description: `At most ${WIDGET_LIST_MAX_ITEMS} items, the most useful first.`,\n }),\n empty: z.string().nullable().optional().meta({\n description: 'The message without items, translated: `No open contests.`',\n }),\n url: z\n .string()\n .nullable()\n .optional()\n .meta({ description: 'Where \"See all\" links, under the items.' }),\n })\n .meta({ description: 'The data of a `list` widget: a few items (decision 0064).' });\n\nexport const BreakdownWidgetItem = z.looseObject({\n label: z.string().meta({ description: 'What the part is, translated: `Failed`.' }),\n value: z.number().meta({ description: 'The count or the sum of the part.' }),\n tone: ToneName.nullable().optional().meta({\n description: 'A tone of the theme for its bar: the tone of an option of a `select`.',\n }),\n url: z\n .string()\n .nullable()\n .optional()\n .meta({ description: 'Where the bar links: the list of what it counts.' }),\n key: z.union([z.string(), z.number(), z.boolean()]).nullable().optional().meta({\n description:\n 'From `GET /resources/{resource}/aggregate`: the value of the field it groups, `null` for the items without one. The client links the bar to the list filtered by it.',\n }),\n});\n\nexport const BreakdownWidgetData = z\n .looseObject({\n items: z\n .array(BreakdownWidgetItem)\n .max(WIDGET_BREAKDOWN_MAX_ITEMS)\n .meta({\n description: `The parts, at most ${WIDGET_BREAKDOWN_MAX_ITEMS}: clients draw the largest first.`,\n }),\n total: z.number().nullable().optional().meta({\n description:\n 'The total the parts are of. Items with several values count in each of their parts, and once in the total.',\n }),\n other: z.number().nullable().optional().meta({\n description: 'The rest of the total, past the items: drawn last, as \"Other\".',\n }),\n })\n .meta({\n description:\n 'The data of a `breakdown` widget: the parts of a total, as horizontal bars (decision 0084).',\n });\n\n/** The schema of the data of each built-in widget type. */\nexport const widgetDataSchemas = {\n stat: StatWidgetData,\n series: SeriesWidgetData,\n list: ListWidgetData,\n breakdown: BreakdownWidgetData,\n} as const;\n\nexport type OverviewPeriod = z.infer<typeof OverviewPeriod>;\nexport type WidgetSettings = z.infer<typeof WidgetSettings>;\nexport type Widget = z.infer<typeof Widget>;\nexport type WidgetBadge = z.infer<typeof WidgetBadge>;\nexport type StatWidgetData = z.infer<typeof StatWidgetData>;\nexport type SeriesPoint = z.infer<typeof SeriesPoint>;\nexport type SeriesWidgetData = z.infer<typeof SeriesWidgetData>;\nexport type ListWidgetItem = z.infer<typeof ListWidgetItem>;\nexport type ListWidgetData = z.infer<typeof ListWidgetData>;\nexport type BreakdownWidgetItem = z.infer<typeof BreakdownWidgetItem>;\nexport type BreakdownWidgetData = z.infer<typeof BreakdownWidgetData>;\n"],"mappings":";;;;AASA,IAAM,WAAW,EAAE,OAAO,CAAC,CAAC,MAAM,cAAc;AAEhD,IAAM,aAAa,EAAE,MAAM;CAAC,EAAE,OAAO;CAAG,EAAE,OAAO;CAAG,EAAE,QAAQ;AAAC,CAAC;AAEhE,IAAa,iBAAiB,EACzB,YAAY;CACT,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACxC,aACI,yUACR,CAAC;CACD,OAAO,EACF,OAAO,EAAE,OAAO,GAAG,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC,CAC9D,SAAS,CAAC,CACV,KAAK,EACF,aACI,oNACR,CAAC;CACL,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACvC,aACI,8JACR,CAAC;CACD,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACrC,aACI,4LACR,CAAC;CACD,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAC1C,aACI,+HACR,CAAC;CACD,QAAQ,EACH,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAC5C,SAAS,CAAC,CACV,KAAK,EACF,aACI,oQACR,CAAC;CACL,aAAa,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACrC,aACI,yOACR,CAAC;AACL,CAAC,CAAC,CAC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ACD,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACzC,aAAa,mEACjB,CAAC;AACL,CAAC,CAAC,CACD,KAAK,EACF,aACI,8FACR,CAAC;;AAGL,IAAa,oBAAoB;CAC7B,MAAM;CACN,QAAQ;CACR,MAAM;CACN,WAAW;AACf"}
package/dist/widgets.d.ts CHANGED
@@ -1,14 +1,24 @@
1
1
  import { type ListQuery } from './query.js';
2
- /** The widget types that every client draws (decision 0064). Other types are widgets of plugins. */
3
- export declare const BUILT_IN_WIDGET_TYPES: readonly ["stat", "series", "list"];
2
+ /**
3
+ * The widget types that every client draws (decisions 0064 and 0084). Other types are widgets of
4
+ * plugins.
5
+ */
6
+ export declare const BUILT_IN_WIDGET_TYPES: readonly ["stat", "series", "list", "breakdown"];
4
7
  export type BuiltInWidgetType = (typeof BUILT_IN_WIDGET_TYPES)[number];
5
8
  /** The periods of the points of a `series` widget. */
6
9
  export declare const WIDGET_SERIES_PERIODS: readonly ["day", "week", "month"];
7
10
  export type WidgetSeriesPeriod = (typeof WIDGET_SERIES_PERIODS)[number];
8
11
  /** The most items a `list` widget shows: the backend sends the most useful first. */
9
12
  export declare const WIDGET_LIST_MAX_ITEMS = 5;
10
- /** The built-in types that can read the list of a resource (`settings.resource`). */
11
- export declare const RESOURCE_WIDGET_TYPES: readonly ["stat", "list"];
13
+ /** The most items of a `breakdown` widget: the rest is its `other`. */
14
+ export declare const WIDGET_BREAKDOWN_MAX_ITEMS = 10;
15
+ /**
16
+ * The built-in types that can read a resource (`settings.resource`): `stat` and `list` read its
17
+ * list, `series` and `breakdown` its aggregates, and a `stat` with a `sum:` measure too.
18
+ */
19
+ export declare const RESOURCE_WIDGET_TYPES: readonly ["stat", "series", "list", "breakdown"];
20
+ /** The built-in types that read the aggregates of a resource, grouped by `settings.group`. */
21
+ export declare const GROUPED_WIDGET_TYPES: readonly ["series", "breakdown"];
12
22
  /** Query parameters that the client sets on the list of a widget on a resource, never `query`. */
13
23
  export declare const WIDGET_RESERVED_QUERY_PARAMS: readonly ["page", "perPage", "cursor"];
14
24
  export declare function isBuiltInWidgetType(type: string): type is BuiltInWidgetType;
@@ -17,7 +27,17 @@ interface WidgetLike {
17
27
  type: string;
18
28
  settings?: Record<string, unknown> | undefined;
19
29
  }
20
- /** A built-in widget that reads the list of a resource, with no data of its own (decision 0064). */
30
+ /** What a widget reads of `GET /resources/{resource}/aggregate` (decision 0084). */
31
+ export interface WidgetAggregate {
32
+ /** `count`, or `sum:{field}`. */
33
+ measure: string;
34
+ /** `{period}:{date field}` or a field of `groupBy`, for a `series` or a `breakdown`. */
35
+ group: string | null;
36
+ }
37
+ /**
38
+ * A built-in widget that reads a resource, with no data of its own (decisions 0064 and 0084): its
39
+ * list, or its aggregates.
40
+ */
21
41
  export interface WidgetResource {
22
42
  /** The id of the resource. */
23
43
  resource: string;
@@ -25,16 +45,35 @@ export interface WidgetResource {
25
45
  params: URLSearchParams;
26
46
  /** The same query, parsed: the query of the list request, and of the link to the list. */
27
47
  query: ListQuery;
48
+ /**
49
+ * The measure and the group of the aggregates the widget reads: a `series`, a `breakdown`, and
50
+ * a `stat` with a `sum:` measure. `null` for a `list`, and a `stat` that counts the items of
51
+ * the list (`meta.total`).
52
+ */
53
+ aggregate: WidgetAggregate | null;
28
54
  }
29
55
  /**
30
- * The resource whose list feeds a built-in `stat` or `list` widget, and its query: `null` for a
56
+ * The resource that feeds a built-in widget, its query, and the aggregates it reads: `null` for a
31
57
  * widget with data of its own at `GET /dashboard/widgets/{widget}`, and for widgets of plugins.
32
58
  */
33
59
  export declare function getWidgetResource(widget: WidgetLike): WidgetResource | null;
34
60
  /**
35
- * Checks the data of a widget against the shape of its type (decision 0064), without the schemas:
36
- * the paths of the wrong keys (`value`, `points.2.date`), empty when it is right. The data of a
37
- * widget of a plugin only has to be an object. The dates of a series must go up, one point per
61
+ * Whether a widget of the summary of a resource follows its list (decision 0084), and gets its
62
+ * current filters and search: a widget on that resource, or with data of its own, unless its
63
+ * `settings.followsList` is `false`. A widget on another resource doesn't.
64
+ */
65
+ export declare function followsList(widget: WidgetLike, resource: string): boolean;
66
+ /**
67
+ * Whether a widget follows the period of its overview (decision 0084): a built-in widget on a
68
+ * resource with `settings.period`, the list's `date-range` filter that gets its days; in the
69
+ * summary of `summaryOf`, a widget that follows its list, whose `date-range` filter the period is;
70
+ * and a widget with data of its own, which gets the period, unless `settings.period` is `false`.
71
+ */
72
+ export declare function followsPeriod(widget: WidgetLike, summaryOf?: string): boolean;
73
+ /**
74
+ * Checks the data of a widget against the shape of its type (decisions 0064 and 0084), without the
75
+ * schemas: the paths of the wrong keys (`value`, `points.2.date`), empty when it is right. The data
76
+ * of a widget of a plugin only has to be an object. The dates of a series must go up, one point per
38
77
  * period.
39
78
  */
40
79
  export declare function checkWidgetData(type: string, data: unknown): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"widgets.d.ts","sourceRoot":"","sources":["../src/widgets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,SAAS,CAAC;AAG3D,oGAAoG;AACpG,eAAO,MAAM,qBAAqB,qCAAsC,CAAC;AAEzE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,mCAAoC,CAAC;AAEvE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,2BAA4B,CAAC;AAE/D,kGAAkG;AAClG,eAAO,MAAM,4BAA4B,wCAAyC,CAAC;AAEnF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,iBAAiB,CAE3E;AAED,gGAAgG;AAChG,UAAU,UAA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