@data-fair/lib-common-types 1.7.0 → 1.8.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/event/.type/index.d.ts +36 -0
- package/event/schema.d.ts +63 -0
- package/event/schema.js +64 -0
- package/package.json +1 -1
- package/session/.type/index.d.ts +1 -0
- package/session/.type/validate.js +23 -11
- package/session/schema.d.ts +3 -0
- package/session/schema.js +3 -0
package/event/.type/index.d.ts
CHANGED
|
@@ -7,10 +7,18 @@ export type Content = string;
|
|
|
7
7
|
export type HTMLContent = string;
|
|
8
8
|
export type URLOfEventIcon = string;
|
|
9
9
|
export type Type = "user" | "organization";
|
|
10
|
+
export type UserID = string;
|
|
11
|
+
export type UserName = string;
|
|
12
|
+
export type UserEmail = string;
|
|
13
|
+
export type OrganizationID = string;
|
|
14
|
+
export type OrganizationName = string;
|
|
15
|
+
export type OrganizationDepartment = string;
|
|
16
|
+
export type OrganizationDepartmentName = string;
|
|
10
17
|
export type TopicKey = string;
|
|
11
18
|
export type TopicTitle = string;
|
|
12
19
|
export type Visibility = "public" | "private";
|
|
13
20
|
export type ReceptionDate = string;
|
|
21
|
+
export type Type1 = string;
|
|
14
22
|
|
|
15
23
|
export type Event = {
|
|
16
24
|
title: Title | InternationalizedTitle;
|
|
@@ -18,6 +26,22 @@ export type Event = {
|
|
|
18
26
|
htmlBody?: HTMLContent | InternationalizedHTMLContent;
|
|
19
27
|
icon?: URLOfEventIcon;
|
|
20
28
|
sender: Emitter;
|
|
29
|
+
originator?: {
|
|
30
|
+
user?: {
|
|
31
|
+
id?: UserID;
|
|
32
|
+
name?: UserName;
|
|
33
|
+
email?: UserEmail;
|
|
34
|
+
[k: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
organization?: {
|
|
37
|
+
id?: OrganizationID;
|
|
38
|
+
name?: OrganizationName;
|
|
39
|
+
department?: OrganizationDepartment;
|
|
40
|
+
departmentName?: OrganizationDepartmentName;
|
|
41
|
+
[k: string]: unknown;
|
|
42
|
+
};
|
|
43
|
+
[k: string]: unknown;
|
|
44
|
+
};
|
|
21
45
|
topic: TopicRef;
|
|
22
46
|
urlParams?: UsedToFillSubscriptionUrlTemplateAndSoCreateNotificationUrl;
|
|
23
47
|
visibility?: Visibility;
|
|
@@ -28,6 +52,7 @@ export type Event = {
|
|
|
28
52
|
extra?: {
|
|
29
53
|
[k: string]: unknown;
|
|
30
54
|
};
|
|
55
|
+
resource?: TheMainResourceConcernedByTheEvent;
|
|
31
56
|
}
|
|
32
57
|
export type InternationalizedTitle = {
|
|
33
58
|
/**
|
|
@@ -92,4 +117,15 @@ export type UsedToFillSubscriptionUrlTemplateAndSoCreateNotificationUrl = {
|
|
|
92
117
|
*/
|
|
93
118
|
[k: string]: string;
|
|
94
119
|
}
|
|
120
|
+
export type TheMainResourceConcernedByTheEvent = {
|
|
121
|
+
type: Type1;
|
|
122
|
+
/**
|
|
123
|
+
* The unique id of the resource
|
|
124
|
+
*/
|
|
125
|
+
id: string;
|
|
126
|
+
/**
|
|
127
|
+
* The display name of the resource
|
|
128
|
+
*/
|
|
129
|
+
title?: string;
|
|
130
|
+
}
|
|
95
131
|
|
package/event/schema.d.ts
CHANGED
|
@@ -55,6 +55,49 @@ declare const _default: {
|
|
|
55
55
|
sender: {
|
|
56
56
|
$ref: string;
|
|
57
57
|
};
|
|
58
|
+
originator: {
|
|
59
|
+
type: string;
|
|
60
|
+
properties: {
|
|
61
|
+
user: {
|
|
62
|
+
type: string;
|
|
63
|
+
properties: {
|
|
64
|
+
id: {
|
|
65
|
+
type: string;
|
|
66
|
+
title: string;
|
|
67
|
+
};
|
|
68
|
+
name: {
|
|
69
|
+
type: string;
|
|
70
|
+
title: string;
|
|
71
|
+
};
|
|
72
|
+
email: {
|
|
73
|
+
type: string;
|
|
74
|
+
title: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
organization: {
|
|
79
|
+
type: string;
|
|
80
|
+
properties: {
|
|
81
|
+
id: {
|
|
82
|
+
type: string;
|
|
83
|
+
title: string;
|
|
84
|
+
};
|
|
85
|
+
name: {
|
|
86
|
+
type: string;
|
|
87
|
+
title: string;
|
|
88
|
+
};
|
|
89
|
+
department: {
|
|
90
|
+
type: string;
|
|
91
|
+
title: string;
|
|
92
|
+
};
|
|
93
|
+
departmentName: {
|
|
94
|
+
type: string;
|
|
95
|
+
title: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
58
101
|
topic: {
|
|
59
102
|
$ref: string;
|
|
60
103
|
};
|
|
@@ -82,6 +125,26 @@ declare const _default: {
|
|
|
82
125
|
type: string;
|
|
83
126
|
description: string;
|
|
84
127
|
};
|
|
128
|
+
resource: {
|
|
129
|
+
type: string;
|
|
130
|
+
title: string;
|
|
131
|
+
additionalProperties: boolean;
|
|
132
|
+
required: string[];
|
|
133
|
+
properties: {
|
|
134
|
+
type: {
|
|
135
|
+
type: string;
|
|
136
|
+
title: string;
|
|
137
|
+
};
|
|
138
|
+
id: {
|
|
139
|
+
type: string;
|
|
140
|
+
description: string;
|
|
141
|
+
};
|
|
142
|
+
title: {
|
|
143
|
+
type: string;
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
85
148
|
};
|
|
86
149
|
$defs: {
|
|
87
150
|
sender: {
|
package/event/schema.js
CHANGED
|
@@ -38,6 +38,50 @@ export default {
|
|
|
38
38
|
},
|
|
39
39
|
// sender is the owner of the topic
|
|
40
40
|
sender: { $ref: '#/$defs/sender' },
|
|
41
|
+
// originator is the account/user who triggered the event
|
|
42
|
+
originator: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
user: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
id: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
title: 'User ID'
|
|
51
|
+
},
|
|
52
|
+
name: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
title: 'User name'
|
|
55
|
+
},
|
|
56
|
+
email: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
title: 'User email'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
organization: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
id: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
title: 'Organization ID'
|
|
68
|
+
},
|
|
69
|
+
name: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
title: 'Organization name'
|
|
72
|
+
},
|
|
73
|
+
department: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
title: 'Organization department'
|
|
76
|
+
},
|
|
77
|
+
departmentName: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
title: 'Organization department name'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
41
85
|
topic: { $ref: '#/$defs/topicRef' },
|
|
42
86
|
urlParams: {
|
|
43
87
|
type: 'object',
|
|
@@ -60,6 +104,26 @@ export default {
|
|
|
60
104
|
extra: {
|
|
61
105
|
type: 'object',
|
|
62
106
|
description: 'Free properties that varie depending on the type of event'
|
|
107
|
+
},
|
|
108
|
+
resource: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
title: 'The main resource concerned by the event',
|
|
111
|
+
additionalProperties: false,
|
|
112
|
+
required: ['type', 'id'],
|
|
113
|
+
properties: {
|
|
114
|
+
type: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
title: 'Type'
|
|
117
|
+
},
|
|
118
|
+
id: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
description: 'The unique id of the resource'
|
|
121
|
+
},
|
|
122
|
+
title: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
description: 'The display name of the resource'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
63
127
|
}
|
|
64
128
|
},
|
|
65
129
|
$defs: {
|
package/package.json
CHANGED
package/session/.type/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { fullFormats } from "ajv-formats/dist/formats.js";
|
|
|
5
5
|
"use strict";
|
|
6
6
|
export const validate = validate14;
|
|
7
7
|
export default validate14;
|
|
8
|
-
const schema16 = {"$id":"https://github.com/data-fair/lib/session-state","x-exports":["types","validate"],"type":"object","title":"session state","additionalProperties":false,"required":["lang"],"properties":{"user":{"$ref":"#/$defs/user"},"organization":{"$ref":"#/$defs/organizationMembership"},"account":{"$ref":"#/$defs/account"},"accountRole":{"type":"string"},"lang":{"type":"string"},"dark":{"deprecated":true,"type":"boolean"}},"$defs":{"organizationMembership":{"type":"object","additionalProperties":false,"required":["id","name","role"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"role":{"type":"string"},"department":{"type":"string"},"departmentName":{"type":"string"},"dflt":{"type":"integer","enum":[1]}}},"userRef":{"type":"object","additionalProperties":false,"required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string"}}},"user":{"type":"object","additionalProperties":false,"required":["email","id","name","organizations"],"properties":{"email":{"type":"string","format":"email"},"id":{"type":"string"},"name":{"type":"string"},"organizations":{"type":"array","items":{"$ref":"#/$defs/organizationMembership"}},"isAdmin":{"type":"integer","enum":[1]},"adminMode":{"type":"integer","enum":[1]},"asAdmin":{"$ref":"#/$defs/userRef"},"pd":{"type":"string","format":"date"},"ipa":{"type":"integer","title":"short for ignorePersonalAccount","enum":[1]},"idp":{"type":"integer","title":"Is the user coming from a core ID provider ?","enum":[1]},"os":{"type":"integer","title":"short for orgStorage","enum":[1]},"rememberMe":{"type":"integer","enum":[1]},"siteOwner":{"$ref":"#/$defs/account"}}},"account":{"type":"object","additionalProperties":false,"required":["type","id","name"],"properties":{"type":{"type":"string","enum":["user","organization"]},"id":{"type":"string"},"name":{"type":"string"},"department":{"type":"string"},"departmentName":{"type":"string"}}}}};
|
|
8
|
+
const schema16 = {"$id":"https://github.com/data-fair/lib/session-state","x-exports":["types","validate"],"type":"object","title":"session state","additionalProperties":false,"required":["lang"],"properties":{"user":{"$ref":"#/$defs/user"},"organization":{"$ref":"#/$defs/organizationMembership"},"account":{"$ref":"#/$defs/account"},"accountRole":{"type":"string"},"siteRole":{"type":"string"},"lang":{"type":"string"},"dark":{"deprecated":true,"type":"boolean"}},"$defs":{"organizationMembership":{"type":"object","additionalProperties":false,"required":["id","name","role"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"role":{"type":"string"},"department":{"type":"string"},"departmentName":{"type":"string"},"dflt":{"type":"integer","enum":[1]}}},"userRef":{"type":"object","additionalProperties":false,"required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string"}}},"user":{"type":"object","additionalProperties":false,"required":["email","id","name","organizations"],"properties":{"email":{"type":"string","format":"email"},"id":{"type":"string"},"name":{"type":"string"},"organizations":{"type":"array","items":{"$ref":"#/$defs/organizationMembership"}},"isAdmin":{"type":"integer","enum":[1]},"adminMode":{"type":"integer","enum":[1]},"asAdmin":{"$ref":"#/$defs/userRef"},"pd":{"type":"string","format":"date"},"ipa":{"type":"integer","title":"short for ignorePersonalAccount","enum":[1]},"idp":{"type":"integer","title":"Is the user coming from a core ID provider ?","enum":[1]},"os":{"type":"integer","title":"short for orgStorage","enum":[1]},"rememberMe":{"type":"integer","enum":[1]},"siteOwner":{"$ref":"#/$defs/account"}}},"account":{"type":"object","additionalProperties":false,"required":["type","id","name"],"properties":{"type":{"type":"string","enum":["user","organization"]},"id":{"type":"string"},"name":{"type":"string"},"department":{"type":"string"},"departmentName":{"type":"string"}}}}};
|
|
9
9
|
const schema18 = {"type":"object","additionalProperties":false,"required":["id","name","role"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"role":{"type":"string"},"department":{"type":"string"},"departmentName":{"type":"string"},"dflt":{"type":"integer","enum":[1]}}};
|
|
10
10
|
const schema20 = {"type":"object","additionalProperties":false,"required":["type","id","name"],"properties":{"type":{"type":"string","enum":["user","organization"]},"id":{"type":"string"},"name":{"type":"string"},"department":{"type":"string"},"departmentName":{"type":"string"}}};
|
|
11
11
|
const schema17 = {"type":"object","additionalProperties":false,"required":["email","id","name","organizations"],"properties":{"email":{"type":"string","format":"email"},"id":{"type":"string"},"name":{"type":"string"},"organizations":{"type":"array","items":{"$ref":"#/$defs/organizationMembership"}},"isAdmin":{"type":"integer","enum":[1]},"adminMode":{"type":"integer","enum":[1]},"asAdmin":{"$ref":"#/$defs/userRef"},"pd":{"type":"string","format":"date"},"ipa":{"type":"integer","title":"short for ignorePersonalAccount","enum":[1]},"idp":{"type":"integer","title":"Is the user coming from a core ID provider ?","enum":[1]},"os":{"type":"integer","title":"short for orgStorage","enum":[1]},"rememberMe":{"type":"integer","enum":[1]},"siteOwner":{"$ref":"#/$defs/account"}}};
|
|
@@ -669,7 +669,7 @@ vErrors.push(err0);
|
|
|
669
669
|
errors++;
|
|
670
670
|
}
|
|
671
671
|
for(const key0 in data){
|
|
672
|
-
if(!((((((key0 === "user") || (key0 === "organization")) || (key0 === "account")) || (key0 === "accountRole")) || (key0 === "lang")) || (key0 === "dark"))){
|
|
672
|
+
if(!(((((((key0 === "user") || (key0 === "organization")) || (key0 === "account")) || (key0 === "accountRole")) || (key0 === "siteRole")) || (key0 === "lang")) || (key0 === "dark"))){
|
|
673
673
|
const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};
|
|
674
674
|
if(vErrors === null){
|
|
675
675
|
vErrors = [err1];
|
|
@@ -966,9 +966,9 @@ vErrors.push(err25);
|
|
|
966
966
|
errors++;
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
|
-
if(data.
|
|
970
|
-
if(typeof data.
|
|
971
|
-
const err26 = {instancePath:instancePath+"/
|
|
969
|
+
if(data.siteRole !== undefined){
|
|
970
|
+
if(typeof data.siteRole !== "string"){
|
|
971
|
+
const err26 = {instancePath:instancePath+"/siteRole",schemaPath:"#/properties/siteRole/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
972
972
|
if(vErrors === null){
|
|
973
973
|
vErrors = [err26];
|
|
974
974
|
}
|
|
@@ -978,9 +978,9 @@ vErrors.push(err26);
|
|
|
978
978
|
errors++;
|
|
979
979
|
}
|
|
980
980
|
}
|
|
981
|
-
if(data.
|
|
982
|
-
if(typeof data.
|
|
983
|
-
const err27 = {instancePath:instancePath+"/
|
|
981
|
+
if(data.lang !== undefined){
|
|
982
|
+
if(typeof data.lang !== "string"){
|
|
983
|
+
const err27 = {instancePath:instancePath+"/lang",schemaPath:"#/properties/lang/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
984
984
|
if(vErrors === null){
|
|
985
985
|
vErrors = [err27];
|
|
986
986
|
}
|
|
@@ -990,9 +990,9 @@ vErrors.push(err27);
|
|
|
990
990
|
errors++;
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
const err28 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "
|
|
993
|
+
if(data.dark !== undefined){
|
|
994
|
+
if(typeof data.dark !== "boolean"){
|
|
995
|
+
const err28 = {instancePath:instancePath+"/dark",schemaPath:"#/properties/dark/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};
|
|
996
996
|
if(vErrors === null){
|
|
997
997
|
vErrors = [err28];
|
|
998
998
|
}
|
|
@@ -1001,6 +1001,18 @@ vErrors.push(err28);
|
|
|
1001
1001
|
}
|
|
1002
1002
|
errors++;
|
|
1003
1003
|
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
else {
|
|
1007
|
+
const err29 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};
|
|
1008
|
+
if(vErrors === null){
|
|
1009
|
+
vErrors = [err29];
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
vErrors.push(err29);
|
|
1013
|
+
}
|
|
1014
|
+
errors++;
|
|
1015
|
+
}
|
|
1004
1016
|
validate14.errors = vErrors;
|
|
1005
1017
|
return errors === 0;
|
|
1006
1018
|
}
|
package/session/schema.d.ts
CHANGED