cozy-client 60.30.6 → 60.31.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/dist/CozyClient.js +1 -1
- package/dist/models/__fixtures__/io.cozy.banners.json +1152 -0
- package/dist/models/banner.js +978 -0
- package/dist/models/banner.spec.js +761 -0
- package/dist/models/index.js +5 -1
- package/package.json +2 -2
- package/types/models/banner.d.ts +193 -0
- package/types/models/index.d.ts +2 -1
package/dist/models/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.assistant = exports.ai = exports.doctypes = exports.geo = exports.user = exports.paper = exports.dacc = exports.sharing = exports.timeseries = exports.document = exports.contact = exports.utils = exports.permission = exports.note = exports.account = exports.konnectorFolder = exports.folder = exports.file = exports.applications = exports.instance = exports.trigger = exports.accounts = exports.triggers = void 0;
|
|
8
|
+
exports.banner = exports.assistant = exports.ai = exports.doctypes = exports.geo = exports.user = exports.paper = exports.dacc = exports.sharing = exports.timeseries = exports.document = exports.contact = exports.utils = exports.permission = exports.note = exports.account = exports.konnectorFolder = exports.folder = exports.file = exports.applications = exports.instance = exports.trigger = exports.accounts = exports.triggers = void 0;
|
|
9
9
|
|
|
10
10
|
var trigger = _interopRequireWildcard(require("./trigger"));
|
|
11
11
|
|
|
@@ -90,6 +90,10 @@ exports.ai = ai;
|
|
|
90
90
|
var assistant = _interopRequireWildcard(require("./assistant"));
|
|
91
91
|
|
|
92
92
|
exports.assistant = assistant;
|
|
93
|
+
|
|
94
|
+
var banner = _interopRequireWildcard(require("./banner"));
|
|
95
|
+
|
|
96
|
+
exports.banner = banner;
|
|
93
97
|
// For backward compatibility before 9.0.0
|
|
94
98
|
var triggers = trigger;
|
|
95
99
|
exports.triggers = triggers;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "60.
|
|
3
|
+
"version": "60.31.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": "
|
|
77
|
+
"gitHead": "aec873af45ab69774636e89341e3511707d2dca7"
|
|
78
78
|
}
|
|
@@ -0,0 +1,193 @@
|
|
|
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<{
|
|
90
|
+
data: Banner | null;
|
|
91
|
+
}>;
|
|
92
|
+
export type BannerCta = {
|
|
93
|
+
/**
|
|
94
|
+
* - The label, plain text, in the same language as the banner text
|
|
95
|
+
*/
|
|
96
|
+
label: string;
|
|
97
|
+
/**
|
|
98
|
+
* - Absolute https URL the label points to
|
|
99
|
+
*/
|
|
100
|
+
url: string;
|
|
101
|
+
};
|
|
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
|
+
/**
|
|
126
|
+
* An io.cozy.banners document
|
|
127
|
+
*/
|
|
128
|
+
export type Banner = {
|
|
129
|
+
/**
|
|
130
|
+
* - Identifier of the document, minted by CouchDB
|
|
131
|
+
*/
|
|
132
|
+
_id?: string;
|
|
133
|
+
/**
|
|
134
|
+
* - Revision identifier of the document
|
|
135
|
+
*/
|
|
136
|
+
_rev?: string;
|
|
137
|
+
/**
|
|
138
|
+
* - Identifier of the banner itself
|
|
139
|
+
*/
|
|
140
|
+
bannerId: string;
|
|
141
|
+
/**
|
|
142
|
+
* - What the banner is about
|
|
143
|
+
*/
|
|
144
|
+
category: BannerCategory;
|
|
145
|
+
/**
|
|
146
|
+
* - info, warning or error
|
|
147
|
+
*/
|
|
148
|
+
severity: BannerSeverity;
|
|
149
|
+
/**
|
|
150
|
+
* - banner or modal
|
|
151
|
+
*/
|
|
152
|
+
surface: BannerSurface;
|
|
153
|
+
/**
|
|
154
|
+
* - The message, in the language given by lang
|
|
155
|
+
*/
|
|
156
|
+
text: string;
|
|
157
|
+
/**
|
|
158
|
+
* - BCP 47 tag of the language text is written in
|
|
159
|
+
*/
|
|
160
|
+
lang: string;
|
|
161
|
+
/**
|
|
162
|
+
* - Optional call to action
|
|
163
|
+
*/
|
|
164
|
+
cta?: BannerCta | null;
|
|
165
|
+
/**
|
|
166
|
+
* - Whether the client offers a dismiss control
|
|
167
|
+
*/
|
|
168
|
+
dismissible: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* - When the user dismissed this banner
|
|
171
|
+
*/
|
|
172
|
+
dismissedAt?: string | null;
|
|
173
|
+
/**
|
|
174
|
+
* - Sort order, highest first
|
|
175
|
+
*/
|
|
176
|
+
priority: number;
|
|
177
|
+
/**
|
|
178
|
+
* - Start of the validity window, inclusive
|
|
179
|
+
*/
|
|
180
|
+
startsAt: string;
|
|
181
|
+
/**
|
|
182
|
+
* - End of the validity window, exclusive
|
|
183
|
+
*/
|
|
184
|
+
endsAt?: string | null;
|
|
185
|
+
/**
|
|
186
|
+
* - What produced the document
|
|
187
|
+
*/
|
|
188
|
+
source?: object;
|
|
189
|
+
/**
|
|
190
|
+
* - Document lifecycle metadata
|
|
191
|
+
*/
|
|
192
|
+
cozyMetadata?: object;
|
|
193
|
+
};
|
package/types/models/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const triggers: typeof trigger;
|
|
2
|
+
import * as banner from "./banner";
|
|
2
3
|
import * as trigger from "./trigger";
|
|
3
4
|
import * as instance from "./instance";
|
|
4
5
|
import * as applications from "./applications";
|
|
@@ -21,4 +22,4 @@ import * as geo from "./geo";
|
|
|
21
22
|
import * as doctypes from "./doctypes";
|
|
22
23
|
import * as ai from "./ai";
|
|
23
24
|
import * as assistant from "./assistant";
|
|
24
|
-
export { trigger, instance, applications, file, folder, konnectorFolder, note, account, permission, utils, contact, document, timeseries, sharing, dacc, paper, user, geo, doctypes, ai, assistant };
|
|
25
|
+
export { banner, trigger, instance, applications, file, folder, konnectorFolder, note, account, permission, utils, contact, document, timeseries, sharing, dacc, paper, user, geo, doctypes, ai, assistant };
|