@data-fair/lib-common-types 1.5.1 → 1.5.3
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/account/.type/index.d.ts +2 -2
- package/account/schema.js +1 -0
- package/application/.type/index.d.ts +3 -3
- package/event/.type/index.d.ts +7 -7
- package/notification/.type/index.d.ts +3 -3
- package/package.json +1 -1
- package/session/.type/index.d.ts +9 -6
- package/session/.type/validate.js +95 -85
- package/session/index.d.ts +2 -2
- package/session/index.js +2 -1
- package/session/schema.d.ts +2 -0
- package/session/schema.js +2 -0
- package/session/types.d.ts +0 -2
- package/session/types.js +0 -2
package/account/.type/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const schemaExports: string[]
|
|
3
3
|
|
|
4
4
|
// see https://github.com/bcherny/json-schema-to-typescript/issues/439 if some types are not exported
|
|
5
|
-
export
|
|
5
|
+
export type Account = {
|
|
6
6
|
type: "user" | "organization";
|
|
7
7
|
id: string;
|
|
8
8
|
name: string;
|
|
@@ -14,7 +14,7 @@ export interface Account {
|
|
|
14
14
|
* This interface was referenced by `Account`'s JSON-Schema
|
|
15
15
|
* via the `definition` "accountKeys".
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type AccountKeys = {
|
|
18
18
|
type: "user" | "organization";
|
|
19
19
|
id: string;
|
|
20
20
|
department?: string;
|
package/account/schema.js
CHANGED
|
@@ -31,7 +31,7 @@ export type Dataset1 = {
|
|
|
31
31
|
[k: string]: unknown;
|
|
32
32
|
} | null;
|
|
33
33
|
|
|
34
|
-
export
|
|
34
|
+
export type Application = {
|
|
35
35
|
/**
|
|
36
36
|
* Globally unique identifier of the application
|
|
37
37
|
*/
|
|
@@ -62,7 +62,7 @@ export interface Application {
|
|
|
62
62
|
};
|
|
63
63
|
[k: string]: unknown;
|
|
64
64
|
}
|
|
65
|
-
export
|
|
65
|
+
export type AccountKeys = {
|
|
66
66
|
type: "user" | "organization";
|
|
67
67
|
id: string;
|
|
68
68
|
department?: string;
|
|
@@ -71,7 +71,7 @@ export interface AccountKeys {
|
|
|
71
71
|
* This interface was referenced by `Application`'s JSON-Schema
|
|
72
72
|
* via the `definition` "field".
|
|
73
73
|
*/
|
|
74
|
-
export
|
|
74
|
+
export type Field = {
|
|
75
75
|
key: string;
|
|
76
76
|
type: string;
|
|
77
77
|
format?: string;
|
package/event/.type/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type TopicTitle = string;
|
|
|
12
12
|
export type Visibility = "public" | "private";
|
|
13
13
|
export type ReceptionDate = string;
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export type Event = {
|
|
16
16
|
title: Title | InternationalizedTitle;
|
|
17
17
|
body?: Content | InternationalizedContent;
|
|
18
18
|
htmlBody?: HTMLContent | InternationalizedHTMLContent;
|
|
@@ -29,21 +29,21 @@ export interface Event {
|
|
|
29
29
|
[k: string]: unknown;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export type InternationalizedTitle = {
|
|
33
33
|
/**
|
|
34
34
|
* This interface was referenced by `InternationalizedTitle`'s JSON-Schema definition
|
|
35
35
|
* via the `patternProperty` ".*".
|
|
36
36
|
*/
|
|
37
37
|
[k: string]: string;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export type InternationalizedContent = {
|
|
40
40
|
/**
|
|
41
41
|
* This interface was referenced by `InternationalizedContent`'s JSON-Schema definition
|
|
42
42
|
* via the `patternProperty` ".*".
|
|
43
43
|
*/
|
|
44
44
|
[k: string]: string;
|
|
45
45
|
}
|
|
46
|
-
export
|
|
46
|
+
export type InternationalizedHTMLContent = {
|
|
47
47
|
/**
|
|
48
48
|
* This interface was referenced by `InternationalizedHTMLContent`'s JSON-Schema definition
|
|
49
49
|
* via the `patternProperty` ".*".
|
|
@@ -54,7 +54,7 @@ export interface InternationalizedHTMLContent {
|
|
|
54
54
|
* This interface was referenced by `Event`'s JSON-Schema
|
|
55
55
|
* via the `definition` "sender".
|
|
56
56
|
*/
|
|
57
|
-
export
|
|
57
|
+
export type Emitter = {
|
|
58
58
|
type: Type;
|
|
59
59
|
/**
|
|
60
60
|
* The unique id of the user or organization
|
|
@@ -81,11 +81,11 @@ export interface Emitter {
|
|
|
81
81
|
* This interface was referenced by `Event`'s JSON-Schema
|
|
82
82
|
* via the `definition` "topicRef".
|
|
83
83
|
*/
|
|
84
|
-
export
|
|
84
|
+
export type TopicRef = {
|
|
85
85
|
key: TopicKey;
|
|
86
86
|
title?: TopicTitle;
|
|
87
87
|
}
|
|
88
|
-
export
|
|
88
|
+
export type UsedToFillSubscriptionUrlTemplateAndSoCreateNotificationUrl = {
|
|
89
89
|
/**
|
|
90
90
|
* This interface was referenced by `UsedToFillSubscriptionUrlTemplateAndSoCreateNotificationUrl`'s JSON-Schema definition
|
|
91
91
|
* via the `patternProperty` ".*".
|
|
@@ -16,7 +16,7 @@ export type RecevoirLaNotificationParEmail = "email";
|
|
|
16
16
|
export type Sorties = ((RecevoirLaNotificationSurVosAppareilsConfigures | RecevoirLaNotificationParEmail) & string)[];
|
|
17
17
|
export type CalculeAPartirDeSubscriptionUrlTemplateEtEventUrlParams = string;
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export type Notification = {
|
|
20
20
|
origin?: SiteDOrigineDeLaSouscription;
|
|
21
21
|
title: Titre;
|
|
22
22
|
body?: Contenu;
|
|
@@ -50,7 +50,7 @@ export interface Notification {
|
|
|
50
50
|
[k: string]: unknown;
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
export
|
|
53
|
+
export type Emitter = {
|
|
54
54
|
type: Type;
|
|
55
55
|
/**
|
|
56
56
|
* The unique id of the user or organization
|
|
@@ -73,7 +73,7 @@ export interface Emitter {
|
|
|
73
73
|
*/
|
|
74
74
|
departmentName?: string;
|
|
75
75
|
}
|
|
76
|
-
export
|
|
76
|
+
export type TopicRef = {
|
|
77
77
|
key: TopicKey;
|
|
78
78
|
title?: TopicTitle;
|
|
79
79
|
}
|
package/package.json
CHANGED
package/session/.type/index.d.ts
CHANGED
|
@@ -6,19 +6,22 @@ export type ShortForIgnorePersonalAccount = 1;
|
|
|
6
6
|
export type IsTheUserComingFromACoreIDProvider = 1;
|
|
7
7
|
export type ShortForOrgStorage = 1;
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export type SessionState = {
|
|
10
10
|
user?: User;
|
|
11
11
|
organization?: OrganizationMembership;
|
|
12
12
|
account?: Account;
|
|
13
13
|
accountRole?: string;
|
|
14
|
-
lang
|
|
14
|
+
lang: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
15
18
|
dark?: boolean;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
21
|
* This interface was referenced by `SessionState`'s JSON-Schema
|
|
19
22
|
* via the `definition` "user".
|
|
20
23
|
*/
|
|
21
|
-
export
|
|
24
|
+
export type User = {
|
|
22
25
|
email: string;
|
|
23
26
|
id: string;
|
|
24
27
|
name: string;
|
|
@@ -36,7 +39,7 @@ export interface User {
|
|
|
36
39
|
* This interface was referenced by `SessionState`'s JSON-Schema
|
|
37
40
|
* via the `definition` "organizationMembership".
|
|
38
41
|
*/
|
|
39
|
-
export
|
|
42
|
+
export type OrganizationMembership = {
|
|
40
43
|
id: string;
|
|
41
44
|
name: string;
|
|
42
45
|
role: string;
|
|
@@ -48,7 +51,7 @@ export interface OrganizationMembership {
|
|
|
48
51
|
* This interface was referenced by `SessionState`'s JSON-Schema
|
|
49
52
|
* via the `definition` "userRef".
|
|
50
53
|
*/
|
|
51
|
-
export
|
|
54
|
+
export type UserRef = {
|
|
52
55
|
id: string;
|
|
53
56
|
name: string;
|
|
54
57
|
}
|
|
@@ -56,7 +59,7 @@ export interface UserRef {
|
|
|
56
59
|
* This interface was referenced by `SessionState`'s JSON-Schema
|
|
57
60
|
* via the `definition` "account".
|
|
58
61
|
*/
|
|
59
|
-
export
|
|
62
|
+
export type Account = {
|
|
60
63
|
type: "user" | "organization";
|
|
61
64
|
id: string;
|
|
62
65
|
name: string;
|
|
@@ -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,"properties":{"user":{"$ref":"#/$defs/user"},"organization":{"$ref":"#/$defs/organizationMembership"},"account":{"$ref":"#/$defs/account"},"accountRole":{"type":"string"},"lang":{"type":"string"},"dark":{"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]}}},"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"},"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]}}},"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 schema21 = {"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]}}};
|
|
@@ -530,9 +530,8 @@ function validate14(data, {instancePath="", parentData, parentDataProperty, root
|
|
|
530
530
|
let vErrors = null;
|
|
531
531
|
let errors = 0;
|
|
532
532
|
if(data && typeof data == "object" && !Array.isArray(data)){
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const err0 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};
|
|
533
|
+
if(data.lang === undefined){
|
|
534
|
+
const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "lang"},message:"must have required property '"+"lang"+"'"};
|
|
536
535
|
if(vErrors === null){
|
|
537
536
|
vErrors = [err0];
|
|
538
537
|
}
|
|
@@ -541,6 +540,17 @@ vErrors.push(err0);
|
|
|
541
540
|
}
|
|
542
541
|
errors++;
|
|
543
542
|
}
|
|
543
|
+
for(const key0 in data){
|
|
544
|
+
if(!((((((key0 === "user") || (key0 === "organization")) || (key0 === "account")) || (key0 === "accountRole")) || (key0 === "lang")) || (key0 === "dark"))){
|
|
545
|
+
const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};
|
|
546
|
+
if(vErrors === null){
|
|
547
|
+
vErrors = [err1];
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
vErrors.push(err1);
|
|
551
|
+
}
|
|
552
|
+
errors++;
|
|
553
|
+
}
|
|
544
554
|
}
|
|
545
555
|
if(data.user !== undefined){
|
|
546
556
|
if(!(validate15(data.user, {instancePath:instancePath+"/user",parentData:data,parentDataProperty:"user",rootData}))){
|
|
@@ -552,103 +562,103 @@ if(data.organization !== undefined){
|
|
|
552
562
|
let data1 = data.organization;
|
|
553
563
|
if(data1 && typeof data1 == "object" && !Array.isArray(data1)){
|
|
554
564
|
if(data1.id === undefined){
|
|
555
|
-
const
|
|
565
|
+
const err2 = {instancePath:instancePath+"/organization",schemaPath:"#/$defs/organizationMembership/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
|
|
556
566
|
if(vErrors === null){
|
|
557
|
-
vErrors = [
|
|
567
|
+
vErrors = [err2];
|
|
558
568
|
}
|
|
559
569
|
else {
|
|
560
|
-
vErrors.push(
|
|
570
|
+
vErrors.push(err2);
|
|
561
571
|
}
|
|
562
572
|
errors++;
|
|
563
573
|
}
|
|
564
574
|
if(data1.name === undefined){
|
|
565
|
-
const
|
|
575
|
+
const err3 = {instancePath:instancePath+"/organization",schemaPath:"#/$defs/organizationMembership/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};
|
|
566
576
|
if(vErrors === null){
|
|
567
|
-
vErrors = [
|
|
577
|
+
vErrors = [err3];
|
|
568
578
|
}
|
|
569
579
|
else {
|
|
570
|
-
vErrors.push(
|
|
580
|
+
vErrors.push(err3);
|
|
571
581
|
}
|
|
572
582
|
errors++;
|
|
573
583
|
}
|
|
574
584
|
if(data1.role === undefined){
|
|
575
|
-
const
|
|
585
|
+
const err4 = {instancePath:instancePath+"/organization",schemaPath:"#/$defs/organizationMembership/required",keyword:"required",params:{missingProperty: "role"},message:"must have required property '"+"role"+"'"};
|
|
576
586
|
if(vErrors === null){
|
|
577
|
-
vErrors = [
|
|
587
|
+
vErrors = [err4];
|
|
578
588
|
}
|
|
579
589
|
else {
|
|
580
|
-
vErrors.push(
|
|
590
|
+
vErrors.push(err4);
|
|
581
591
|
}
|
|
582
592
|
errors++;
|
|
583
593
|
}
|
|
584
594
|
for(const key1 in data1){
|
|
585
595
|
if(!((((((key1 === "id") || (key1 === "name")) || (key1 === "role")) || (key1 === "department")) || (key1 === "departmentName")) || (key1 === "dflt"))){
|
|
586
|
-
const
|
|
596
|
+
const err5 = {instancePath:instancePath+"/organization",schemaPath:"#/$defs/organizationMembership/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};
|
|
587
597
|
if(vErrors === null){
|
|
588
|
-
vErrors = [
|
|
598
|
+
vErrors = [err5];
|
|
589
599
|
}
|
|
590
600
|
else {
|
|
591
|
-
vErrors.push(
|
|
601
|
+
vErrors.push(err5);
|
|
592
602
|
}
|
|
593
603
|
errors++;
|
|
594
604
|
}
|
|
595
605
|
}
|
|
596
606
|
if(data1.id !== undefined){
|
|
597
607
|
if(typeof data1.id !== "string"){
|
|
598
|
-
const
|
|
608
|
+
const err6 = {instancePath:instancePath+"/organization/id",schemaPath:"#/$defs/organizationMembership/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
599
609
|
if(vErrors === null){
|
|
600
|
-
vErrors = [
|
|
610
|
+
vErrors = [err6];
|
|
601
611
|
}
|
|
602
612
|
else {
|
|
603
|
-
vErrors.push(
|
|
613
|
+
vErrors.push(err6);
|
|
604
614
|
}
|
|
605
615
|
errors++;
|
|
606
616
|
}
|
|
607
617
|
}
|
|
608
618
|
if(data1.name !== undefined){
|
|
609
619
|
if(typeof data1.name !== "string"){
|
|
610
|
-
const
|
|
620
|
+
const err7 = {instancePath:instancePath+"/organization/name",schemaPath:"#/$defs/organizationMembership/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
611
621
|
if(vErrors === null){
|
|
612
|
-
vErrors = [
|
|
622
|
+
vErrors = [err7];
|
|
613
623
|
}
|
|
614
624
|
else {
|
|
615
|
-
vErrors.push(
|
|
625
|
+
vErrors.push(err7);
|
|
616
626
|
}
|
|
617
627
|
errors++;
|
|
618
628
|
}
|
|
619
629
|
}
|
|
620
630
|
if(data1.role !== undefined){
|
|
621
631
|
if(typeof data1.role !== "string"){
|
|
622
|
-
const
|
|
632
|
+
const err8 = {instancePath:instancePath+"/organization/role",schemaPath:"#/$defs/organizationMembership/properties/role/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
623
633
|
if(vErrors === null){
|
|
624
|
-
vErrors = [
|
|
634
|
+
vErrors = [err8];
|
|
625
635
|
}
|
|
626
636
|
else {
|
|
627
|
-
vErrors.push(
|
|
637
|
+
vErrors.push(err8);
|
|
628
638
|
}
|
|
629
639
|
errors++;
|
|
630
640
|
}
|
|
631
641
|
}
|
|
632
642
|
if(data1.department !== undefined){
|
|
633
643
|
if(typeof data1.department !== "string"){
|
|
634
|
-
const
|
|
644
|
+
const err9 = {instancePath:instancePath+"/organization/department",schemaPath:"#/$defs/organizationMembership/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
635
645
|
if(vErrors === null){
|
|
636
|
-
vErrors = [
|
|
646
|
+
vErrors = [err9];
|
|
637
647
|
}
|
|
638
648
|
else {
|
|
639
|
-
vErrors.push(
|
|
649
|
+
vErrors.push(err9);
|
|
640
650
|
}
|
|
641
651
|
errors++;
|
|
642
652
|
}
|
|
643
653
|
}
|
|
644
654
|
if(data1.departmentName !== undefined){
|
|
645
655
|
if(typeof data1.departmentName !== "string"){
|
|
646
|
-
const
|
|
656
|
+
const err10 = {instancePath:instancePath+"/organization/departmentName",schemaPath:"#/$defs/organizationMembership/properties/departmentName/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
647
657
|
if(vErrors === null){
|
|
648
|
-
vErrors = [
|
|
658
|
+
vErrors = [err10];
|
|
649
659
|
}
|
|
650
660
|
else {
|
|
651
|
-
vErrors.push(
|
|
661
|
+
vErrors.push(err10);
|
|
652
662
|
}
|
|
653
663
|
errors++;
|
|
654
664
|
}
|
|
@@ -656,34 +666,34 @@ errors++;
|
|
|
656
666
|
if(data1.dflt !== undefined){
|
|
657
667
|
let data7 = data1.dflt;
|
|
658
668
|
if(!((typeof data7 == "number") && (!(data7 % 1) && !isNaN(data7)))){
|
|
659
|
-
const
|
|
669
|
+
const err11 = {instancePath:instancePath+"/organization/dflt",schemaPath:"#/$defs/organizationMembership/properties/dflt/type",keyword:"type",params:{type: "integer"},message:"must be integer"};
|
|
660
670
|
if(vErrors === null){
|
|
661
|
-
vErrors = [
|
|
671
|
+
vErrors = [err11];
|
|
662
672
|
}
|
|
663
673
|
else {
|
|
664
|
-
vErrors.push(
|
|
674
|
+
vErrors.push(err11);
|
|
665
675
|
}
|
|
666
676
|
errors++;
|
|
667
677
|
}
|
|
668
678
|
if(!(data7 === 1)){
|
|
669
|
-
const
|
|
679
|
+
const err12 = {instancePath:instancePath+"/organization/dflt",schemaPath:"#/$defs/organizationMembership/properties/dflt/enum",keyword:"enum",params:{allowedValues: schema18.properties.dflt.enum},message:"must be equal to one of the allowed values"};
|
|
670
680
|
if(vErrors === null){
|
|
671
|
-
vErrors = [
|
|
681
|
+
vErrors = [err12];
|
|
672
682
|
}
|
|
673
683
|
else {
|
|
674
|
-
vErrors.push(
|
|
684
|
+
vErrors.push(err12);
|
|
675
685
|
}
|
|
676
686
|
errors++;
|
|
677
687
|
}
|
|
678
688
|
}
|
|
679
689
|
}
|
|
680
690
|
else {
|
|
681
|
-
const
|
|
691
|
+
const err13 = {instancePath:instancePath+"/organization",schemaPath:"#/$defs/organizationMembership/type",keyword:"type",params:{type: "object"},message:"must be object"};
|
|
682
692
|
if(vErrors === null){
|
|
683
|
-
vErrors = [
|
|
693
|
+
vErrors = [err13];
|
|
684
694
|
}
|
|
685
695
|
else {
|
|
686
|
-
vErrors.push(
|
|
696
|
+
vErrors.push(err13);
|
|
687
697
|
}
|
|
688
698
|
errors++;
|
|
689
699
|
}
|
|
@@ -692,43 +702,43 @@ if(data.account !== undefined){
|
|
|
692
702
|
let data8 = data.account;
|
|
693
703
|
if(data8 && typeof data8 == "object" && !Array.isArray(data8)){
|
|
694
704
|
if(data8.type === undefined){
|
|
695
|
-
const
|
|
705
|
+
const err14 = {instancePath:instancePath+"/account",schemaPath:"#/$defs/account/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};
|
|
696
706
|
if(vErrors === null){
|
|
697
|
-
vErrors = [
|
|
707
|
+
vErrors = [err14];
|
|
698
708
|
}
|
|
699
709
|
else {
|
|
700
|
-
vErrors.push(
|
|
710
|
+
vErrors.push(err14);
|
|
701
711
|
}
|
|
702
712
|
errors++;
|
|
703
713
|
}
|
|
704
714
|
if(data8.id === undefined){
|
|
705
|
-
const
|
|
715
|
+
const err15 = {instancePath:instancePath+"/account",schemaPath:"#/$defs/account/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
|
|
706
716
|
if(vErrors === null){
|
|
707
|
-
vErrors = [
|
|
717
|
+
vErrors = [err15];
|
|
708
718
|
}
|
|
709
719
|
else {
|
|
710
|
-
vErrors.push(
|
|
720
|
+
vErrors.push(err15);
|
|
711
721
|
}
|
|
712
722
|
errors++;
|
|
713
723
|
}
|
|
714
724
|
if(data8.name === undefined){
|
|
715
|
-
const
|
|
725
|
+
const err16 = {instancePath:instancePath+"/account",schemaPath:"#/$defs/account/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};
|
|
716
726
|
if(vErrors === null){
|
|
717
|
-
vErrors = [
|
|
727
|
+
vErrors = [err16];
|
|
718
728
|
}
|
|
719
729
|
else {
|
|
720
|
-
vErrors.push(
|
|
730
|
+
vErrors.push(err16);
|
|
721
731
|
}
|
|
722
732
|
errors++;
|
|
723
733
|
}
|
|
724
734
|
for(const key2 in data8){
|
|
725
735
|
if(!(((((key2 === "type") || (key2 === "id")) || (key2 === "name")) || (key2 === "department")) || (key2 === "departmentName"))){
|
|
726
|
-
const
|
|
736
|
+
const err17 = {instancePath:instancePath+"/account",schemaPath:"#/$defs/account/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};
|
|
727
737
|
if(vErrors === null){
|
|
728
|
-
vErrors = [
|
|
738
|
+
vErrors = [err17];
|
|
729
739
|
}
|
|
730
740
|
else {
|
|
731
|
-
vErrors.push(
|
|
741
|
+
vErrors.push(err17);
|
|
732
742
|
}
|
|
733
743
|
errors++;
|
|
734
744
|
}
|
|
@@ -736,130 +746,130 @@ errors++;
|
|
|
736
746
|
if(data8.type !== undefined){
|
|
737
747
|
let data9 = data8.type;
|
|
738
748
|
if(typeof data9 !== "string"){
|
|
739
|
-
const
|
|
749
|
+
const err18 = {instancePath:instancePath+"/account/type",schemaPath:"#/$defs/account/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
740
750
|
if(vErrors === null){
|
|
741
|
-
vErrors = [
|
|
751
|
+
vErrors = [err18];
|
|
742
752
|
}
|
|
743
753
|
else {
|
|
744
|
-
vErrors.push(
|
|
754
|
+
vErrors.push(err18);
|
|
745
755
|
}
|
|
746
756
|
errors++;
|
|
747
757
|
}
|
|
748
758
|
if(!((data9 === "user") || (data9 === "organization"))){
|
|
749
|
-
const
|
|
759
|
+
const err19 = {instancePath:instancePath+"/account/type",schemaPath:"#/$defs/account/properties/type/enum",keyword:"enum",params:{allowedValues: schema21.properties.type.enum},message:"must be equal to one of the allowed values"};
|
|
750
760
|
if(vErrors === null){
|
|
751
|
-
vErrors = [
|
|
761
|
+
vErrors = [err19];
|
|
752
762
|
}
|
|
753
763
|
else {
|
|
754
|
-
vErrors.push(
|
|
764
|
+
vErrors.push(err19);
|
|
755
765
|
}
|
|
756
766
|
errors++;
|
|
757
767
|
}
|
|
758
768
|
}
|
|
759
769
|
if(data8.id !== undefined){
|
|
760
770
|
if(typeof data8.id !== "string"){
|
|
761
|
-
const
|
|
771
|
+
const err20 = {instancePath:instancePath+"/account/id",schemaPath:"#/$defs/account/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
762
772
|
if(vErrors === null){
|
|
763
|
-
vErrors = [
|
|
773
|
+
vErrors = [err20];
|
|
764
774
|
}
|
|
765
775
|
else {
|
|
766
|
-
vErrors.push(
|
|
776
|
+
vErrors.push(err20);
|
|
767
777
|
}
|
|
768
778
|
errors++;
|
|
769
779
|
}
|
|
770
780
|
}
|
|
771
781
|
if(data8.name !== undefined){
|
|
772
782
|
if(typeof data8.name !== "string"){
|
|
773
|
-
const
|
|
783
|
+
const err21 = {instancePath:instancePath+"/account/name",schemaPath:"#/$defs/account/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
774
784
|
if(vErrors === null){
|
|
775
|
-
vErrors = [
|
|
785
|
+
vErrors = [err21];
|
|
776
786
|
}
|
|
777
787
|
else {
|
|
778
|
-
vErrors.push(
|
|
788
|
+
vErrors.push(err21);
|
|
779
789
|
}
|
|
780
790
|
errors++;
|
|
781
791
|
}
|
|
782
792
|
}
|
|
783
793
|
if(data8.department !== undefined){
|
|
784
794
|
if(typeof data8.department !== "string"){
|
|
785
|
-
const
|
|
795
|
+
const err22 = {instancePath:instancePath+"/account/department",schemaPath:"#/$defs/account/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
786
796
|
if(vErrors === null){
|
|
787
|
-
vErrors = [
|
|
797
|
+
vErrors = [err22];
|
|
788
798
|
}
|
|
789
799
|
else {
|
|
790
|
-
vErrors.push(
|
|
800
|
+
vErrors.push(err22);
|
|
791
801
|
}
|
|
792
802
|
errors++;
|
|
793
803
|
}
|
|
794
804
|
}
|
|
795
805
|
if(data8.departmentName !== undefined){
|
|
796
806
|
if(typeof data8.departmentName !== "string"){
|
|
797
|
-
const
|
|
807
|
+
const err23 = {instancePath:instancePath+"/account/departmentName",schemaPath:"#/$defs/account/properties/departmentName/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
798
808
|
if(vErrors === null){
|
|
799
|
-
vErrors = [
|
|
809
|
+
vErrors = [err23];
|
|
800
810
|
}
|
|
801
811
|
else {
|
|
802
|
-
vErrors.push(
|
|
812
|
+
vErrors.push(err23);
|
|
803
813
|
}
|
|
804
814
|
errors++;
|
|
805
815
|
}
|
|
806
816
|
}
|
|
807
817
|
}
|
|
808
818
|
else {
|
|
809
|
-
const
|
|
819
|
+
const err24 = {instancePath:instancePath+"/account",schemaPath:"#/$defs/account/type",keyword:"type",params:{type: "object"},message:"must be object"};
|
|
810
820
|
if(vErrors === null){
|
|
811
|
-
vErrors = [
|
|
821
|
+
vErrors = [err24];
|
|
812
822
|
}
|
|
813
823
|
else {
|
|
814
|
-
vErrors.push(
|
|
824
|
+
vErrors.push(err24);
|
|
815
825
|
}
|
|
816
826
|
errors++;
|
|
817
827
|
}
|
|
818
828
|
}
|
|
819
829
|
if(data.accountRole !== undefined){
|
|
820
830
|
if(typeof data.accountRole !== "string"){
|
|
821
|
-
const
|
|
831
|
+
const err25 = {instancePath:instancePath+"/accountRole",schemaPath:"#/properties/accountRole/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
822
832
|
if(vErrors === null){
|
|
823
|
-
vErrors = [
|
|
833
|
+
vErrors = [err25];
|
|
824
834
|
}
|
|
825
835
|
else {
|
|
826
|
-
vErrors.push(
|
|
836
|
+
vErrors.push(err25);
|
|
827
837
|
}
|
|
828
838
|
errors++;
|
|
829
839
|
}
|
|
830
840
|
}
|
|
831
841
|
if(data.lang !== undefined){
|
|
832
842
|
if(typeof data.lang !== "string"){
|
|
833
|
-
const
|
|
843
|
+
const err26 = {instancePath:instancePath+"/lang",schemaPath:"#/properties/lang/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
834
844
|
if(vErrors === null){
|
|
835
|
-
vErrors = [
|
|
845
|
+
vErrors = [err26];
|
|
836
846
|
}
|
|
837
847
|
else {
|
|
838
|
-
vErrors.push(
|
|
848
|
+
vErrors.push(err26);
|
|
839
849
|
}
|
|
840
850
|
errors++;
|
|
841
851
|
}
|
|
842
852
|
}
|
|
843
853
|
if(data.dark !== undefined){
|
|
844
854
|
if(typeof data.dark !== "boolean"){
|
|
845
|
-
const
|
|
855
|
+
const err27 = {instancePath:instancePath+"/dark",schemaPath:"#/properties/dark/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};
|
|
846
856
|
if(vErrors === null){
|
|
847
|
-
vErrors = [
|
|
857
|
+
vErrors = [err27];
|
|
848
858
|
}
|
|
849
859
|
else {
|
|
850
|
-
vErrors.push(
|
|
860
|
+
vErrors.push(err27);
|
|
851
861
|
}
|
|
852
862
|
errors++;
|
|
853
863
|
}
|
|
854
864
|
}
|
|
855
865
|
}
|
|
856
866
|
else {
|
|
857
|
-
const
|
|
867
|
+
const err28 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};
|
|
858
868
|
if(vErrors === null){
|
|
859
|
-
vErrors = [
|
|
869
|
+
vErrors = [err28];
|
|
860
870
|
}
|
|
861
871
|
else {
|
|
862
|
-
vErrors.push(
|
|
872
|
+
vErrors.push(err28);
|
|
863
873
|
}
|
|
864
874
|
errors++;
|
|
865
875
|
}
|
package/session/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import { type SessionState, type Account } from './.type/index.js';
|
|
2
|
+
export type AccountKeys = Pick<Account, 'type' | 'id' | 'department'>;
|
|
3
3
|
export type SessionStateAuthenticated = SessionState & Required<Pick<SessionState, 'user' | 'account' | 'accountRole'>>;
|
|
4
4
|
export * from './.type/index.js';
|
|
5
5
|
export declare function isAuthenticated(sessionState: SessionState): sessionState is SessionStateAuthenticated;
|
package/session/index.js
CHANGED
|
@@ -22,8 +22,9 @@ function matchAccount (userAccount, resourceAccount, acceptDepAsRoot = false) {
|
|
|
22
22
|
export function getAccountRole (sessionState, account, options = {}) {
|
|
23
23
|
if (!isAuthenticated(sessionState)) { return null }
|
|
24
24
|
if (sessionState.user.adminMode) { return 'admin' }
|
|
25
|
+
// user is always admin of themself even if currently switched in an orga
|
|
26
|
+
if (account.type === 'user' && sessionState.user.id === account.id) { return 'admin' }
|
|
25
27
|
if (options.allAccounts) {
|
|
26
|
-
if (account.type === 'user' && sessionState.user.id === account.id) { return 'admin' }
|
|
27
28
|
for (const org of sessionState.user.organizations) {
|
|
28
29
|
if (matchAccount({ type: 'organization', id: org.id, department: org.department }, account, options.acceptDepAsRoot)) { return org.role }
|
|
29
30
|
}
|
package/session/schema.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare const _default: {
|
|
|
4
4
|
type: string;
|
|
5
5
|
title: string;
|
|
6
6
|
additionalProperties: boolean;
|
|
7
|
+
required: string[];
|
|
7
8
|
properties: {
|
|
8
9
|
user: {
|
|
9
10
|
$ref: string;
|
|
@@ -21,6 +22,7 @@ declare const _default: {
|
|
|
21
22
|
type: string;
|
|
22
23
|
};
|
|
23
24
|
dark: {
|
|
25
|
+
deprecated: boolean;
|
|
24
26
|
type: string;
|
|
25
27
|
};
|
|
26
28
|
};
|
package/session/schema.js
CHANGED
|
@@ -4,6 +4,7 @@ export default {
|
|
|
4
4
|
type: 'object',
|
|
5
5
|
title: 'session state',
|
|
6
6
|
additionalProperties: false,
|
|
7
|
+
required: ['lang'],
|
|
7
8
|
properties: {
|
|
8
9
|
user: {
|
|
9
10
|
$ref: '#/$defs/user'
|
|
@@ -21,6 +22,7 @@ export default {
|
|
|
21
22
|
type: 'string'
|
|
22
23
|
},
|
|
23
24
|
dark: {
|
|
25
|
+
deprecated: true,
|
|
24
26
|
type: 'boolean'
|
|
25
27
|
}
|
|
26
28
|
},
|
package/session/types.d.ts
DELETED
package/session/types.js
DELETED