cozy-client 60.31.0 → 60.32.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "60.31.0",
3
+ "version": "60.32.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -74,5 +74,5 @@
74
74
  "react-native-ios11-devicecheck": "^0.0.3"
75
75
  },
76
76
  "sideEffects": false,
77
- "gitHead": "aec873af45ab69774636e89341e3511707d2dca7"
77
+ "gitHead": "afc1cbe7a956b8abbb875e5436ed031f05207a24"
78
78
  }
@@ -1,139 +1,33 @@
1
1
  export const BANNERS_DOCTYPE: "io.cozy.banners";
2
- /**
3
- * The version of the io.cozy.banners shape this code was written against.
4
- * A document declaring a higher cozyMetadata.doctypeVersion is skipped.
5
- */
6
- export const SUPPORTED_DOCTYPE_VERSION: 1;
7
- /**
8
- * The severities the doctype defines. A value outside this list is rendered
9
- * with DEFAULT_SEVERITY. Frozen because the fallbacks read it at call time, so
10
- * a consumer mutating it would change what every other consumer renders.
11
- *
12
- * @type {readonly BannerSeverity[]}
13
- */
14
- export const KNOWN_SEVERITIES: readonly BannerSeverity[];
15
- /**
16
- * The surfaces the doctype defines. A value outside this list is rendered on
17
- * DEFAULT_SURFACE. Frozen for the same reason as KNOWN_SEVERITIES.
18
- *
19
- * @type {readonly BannerSurface[]}
20
- */
21
- export const KNOWN_SURFACES: readonly BannerSurface[];
22
- /**
23
- * @typedef {object} BannerCta
24
- * @property {string} label - The label, plain text, in the same language as the banner text
25
- * @property {string} url - Absolute https URL the label points to
26
- */
27
- /**
28
- * @typedef {'quota'|'billing'|'trial'|'account'|'system'} BannerCategory
29
- */
30
- /**
31
- * @typedef {'info'|'warning'|'error'} BannerSeverity
32
- */
33
- /**
34
- * @typedef {'banner'|'modal'} BannerSurface
35
- */
36
- /**
37
- * @typedef {object} VisibleBannersOptions
38
- * @property {Date} [now] - The current time, defaults to now
39
- * @property {number} [supportedDoctypeVersion] - The highest version this client handles
40
- */
41
- /**
42
- * @typedef {import("../CozyClient").default} BannerClient A CozyClient instance
43
- */
44
- /**
45
- * @typedef {object} DismissOptions
46
- * @property {string} [dismissedAt] - The timestamp to record, defaults to now
47
- */
48
- /**
49
- * @typedef {object} Banner An io.cozy.banners document
50
- * @property {string} [_id] - Identifier of the document, minted by CouchDB
51
- * @property {string} [_rev] - Revision identifier of the document
52
- * @property {string} bannerId - Identifier of the banner itself
53
- * @property {BannerCategory} category - What the banner is about
54
- * @property {BannerSeverity} severity - info, warning or error
55
- * @property {BannerSurface} surface - banner or modal
56
- * @property {string} text - The message, in the language given by lang
57
- * @property {string} lang - BCP 47 tag of the language text is written in
58
- * @property {BannerCta|null} [cta] - Optional call to action
59
- * @property {boolean} dismissible - Whether the client offers a dismiss control
60
- * @property {string|null} [dismissedAt] - When the user dismissed this banner
61
- * @property {number} priority - Sort order, highest first
62
- * @property {string} startsAt - Start of the validity window, inclusive
63
- * @property {string|null} [endsAt] - End of the validity window, exclusive
64
- * @property {object} [source] - What produced the document
65
- * @property {object} [cozyMetadata] - Document lifecycle metadata
66
- */
67
- /**
68
- * The name the banners query is stored under. It is namespaced rather than the
69
- * bare doctype: `client.query` keys the store entry on this name but keys the
70
- * in-flight promise on the definition, so an unrelated consumer naming its own
71
- * `io.cozy.banners` query would make this one resolve nothing while that query
72
- * is loading.
73
- */
74
- export const BANNERS_QUERY_NAME: string;
75
- export function buildBannersQuery(): import('../types').Query;
76
- export function isTrusted(banner: Banner): boolean;
77
- export function isSupported(banner: Banner, supportedVersion?: number): boolean;
78
- export function isDismissed(banner: Banner): boolean;
79
- export function isInWindow(banner: Banner, now?: Date): boolean;
80
- export function byPriority(a: Banner, b: Banner): number;
81
- export function getSeverity(banner: Banner): BannerSeverity;
82
- export function getSurface(banner: Banner): BannerSurface;
83
- export function getCta(banner: Banner): BannerCta | null;
84
- export function getVisibleBanners(banners: Banner[], options?: VisibleBannersOptions): Banner[];
85
- export function getActiveBanners(client: BannerClient, options?: VisibleBannersOptions): Promise<Banner[]>;
86
- export function getActiveBanner(client: BannerClient, options?: VisibleBannersOptions): Promise<Banner | null>;
87
- export function dismiss(client: BannerClient, banner: Banner & {
88
- _id: string;
89
- }, options?: DismissOptions): Promise<{
2
+ export function getActiveBanners(client: object, { now }?: {
3
+ now: Date;
4
+ }): Promise<Banner[]>;
5
+ export function getActiveBanner(client: object, options?: {
6
+ now: Date;
7
+ }): Promise<Banner | null>;
8
+ export function dismiss(client: object, banner: Banner, { dismissedAt }?: {
9
+ dismissedAt: string;
10
+ }): Promise<{
90
11
  data: Banner | null;
91
12
  }>;
92
13
  export type BannerCta = {
93
14
  /**
94
- * - The label, plain text, in the same language as the banner text
15
+ * - The label, plain text
95
16
  */
96
17
  label: string;
97
18
  /**
98
- * - Absolute https URL the label points to
19
+ * - Where the label points
99
20
  */
100
21
  url: string;
101
22
  };
102
- export type BannerCategory = "account" | "quota" | "billing" | "trial" | "system";
103
- export type BannerSeverity = "info" | "error" | "warning";
104
- export type BannerSurface = "banner" | "modal";
105
- export type VisibleBannersOptions = {
106
- /**
107
- * - The current time, defaults to now
108
- */
109
- now?: Date;
110
- /**
111
- * - The highest version this client handles
112
- */
113
- supportedDoctypeVersion?: number;
114
- };
115
- /**
116
- * A CozyClient instance
117
- */
118
- export type BannerClient = import("../CozyClient").default;
119
- export type DismissOptions = {
120
- /**
121
- * - The timestamp to record, defaults to now
122
- */
123
- dismissedAt?: string;
124
- };
125
23
  /**
126
24
  * An io.cozy.banners document
127
25
  */
128
26
  export type Banner = {
129
27
  /**
130
- * - Identifier of the document, minted by CouchDB
28
+ * - Identifier of the document
131
29
  */
132
30
  _id?: string;
133
- /**
134
- * - Revision identifier of the document
135
- */
136
- _rev?: string;
137
31
  /**
138
32
  * - Identifier of the banner itself
139
33
  */
@@ -141,35 +35,43 @@ export type Banner = {
141
35
  /**
142
36
  * - What the banner is about
143
37
  */
144
- category: BannerCategory;
38
+ category: string;
39
+ /**
40
+ * - How loudly to render it
41
+ */
42
+ severity: 'info' | 'warning' | 'error';
145
43
  /**
146
- * - info, warning or error
44
+ * - Where to render it
147
45
  */
148
- severity: BannerSeverity;
46
+ surface: 'banner' | 'modal';
149
47
  /**
150
- * - banner or modal
48
+ * - Optional heading, used on the modal surface
151
49
  */
152
- surface: BannerSurface;
50
+ title?: string;
153
51
  /**
154
- * - The message, in the language given by lang
52
+ * - The message, already localized
155
53
  */
156
54
  text: string;
157
55
  /**
158
- * - BCP 47 tag of the language text is written in
56
+ * - BCP 47 tag of the language `text` and `cta.label` are in
159
57
  */
160
58
  lang: string;
161
59
  /**
162
60
  * - Optional call to action
163
61
  */
164
- cta?: BannerCta | null;
62
+ cta?: BannerCta;
63
+ /**
64
+ * - Optional lesser action, needs a cta
65
+ */
66
+ secondaryCta?: BannerCta;
165
67
  /**
166
68
  * - Whether the client offers a dismiss control
167
69
  */
168
70
  dismissible: boolean;
169
71
  /**
170
- * - When the user dismissed this banner
72
+ * - When the user dismissed it
171
73
  */
172
- dismissedAt?: string | null;
74
+ dismissedAt?: string;
173
75
  /**
174
76
  * - Sort order, highest first
175
77
  */
@@ -181,13 +83,5 @@ export type Banner = {
181
83
  /**
182
84
  * - End of the validity window, exclusive
183
85
  */
184
- endsAt?: string | null;
185
- /**
186
- * - What produced the document
187
- */
188
- source?: object;
189
- /**
190
- * - Document lifecycle metadata
191
- */
192
- cozyMetadata?: object;
86
+ endsAt?: string;
193
87
  };