@data-fair/lib-common-types 1.6.1 → 1.7.1
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 +1 -1
- package/session/.type/index.d.ts +2 -0
- package/session/.type/validate.js +157 -17
- package/session/schema.d.ts +6 -0
- package/session/schema.js +6 -0
package/package.json
CHANGED
package/session/.type/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type SessionState = {
|
|
|
11
11
|
organization?: OrganizationMembership;
|
|
12
12
|
account?: Account;
|
|
13
13
|
accountRole?: string;
|
|
14
|
+
siteRole?: string;
|
|
14
15
|
lang: string;
|
|
15
16
|
/**
|
|
16
17
|
* @deprecated
|
|
@@ -34,6 +35,7 @@ export type User = {
|
|
|
34
35
|
idp?: IsTheUserComingFromACoreIDProvider;
|
|
35
36
|
os?: ShortForOrgStorage;
|
|
36
37
|
rememberMe?: 1;
|
|
38
|
+
siteOwner?: Account;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* This interface was referenced by `SessionState`'s JSON-Schema
|
|
@@ -5,10 +5,10 @@ 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]}}},"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
|
-
const
|
|
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]}}};
|
|
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
|
+
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"}}};
|
|
12
12
|
const schema19 = {"type":"object","additionalProperties":false,"required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string"}}};
|
|
13
13
|
const func2 = Object.prototype.hasOwnProperty;
|
|
14
14
|
const formats0 = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
|
|
@@ -509,9 +509,11 @@ vErrors.push(err41);
|
|
|
509
509
|
errors++;
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
512
|
+
if(data.siteOwner !== undefined){
|
|
513
|
+
let data21 = data.siteOwner;
|
|
514
|
+
if(data21 && typeof data21 == "object" && !Array.isArray(data21)){
|
|
515
|
+
if(data21.type === undefined){
|
|
516
|
+
const err42 = {instancePath:instancePath+"/siteOwner",schemaPath:"#/$defs/account/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};
|
|
515
517
|
if(vErrors === null){
|
|
516
518
|
vErrors = [err42];
|
|
517
519
|
}
|
|
@@ -520,6 +522,132 @@ vErrors.push(err42);
|
|
|
520
522
|
}
|
|
521
523
|
errors++;
|
|
522
524
|
}
|
|
525
|
+
if(data21.id === undefined){
|
|
526
|
+
const err43 = {instancePath:instancePath+"/siteOwner",schemaPath:"#/$defs/account/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
|
|
527
|
+
if(vErrors === null){
|
|
528
|
+
vErrors = [err43];
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
vErrors.push(err43);
|
|
532
|
+
}
|
|
533
|
+
errors++;
|
|
534
|
+
}
|
|
535
|
+
if(data21.name === undefined){
|
|
536
|
+
const err44 = {instancePath:instancePath+"/siteOwner",schemaPath:"#/$defs/account/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};
|
|
537
|
+
if(vErrors === null){
|
|
538
|
+
vErrors = [err44];
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
vErrors.push(err44);
|
|
542
|
+
}
|
|
543
|
+
errors++;
|
|
544
|
+
}
|
|
545
|
+
for(const key3 in data21){
|
|
546
|
+
if(!(((((key3 === "type") || (key3 === "id")) || (key3 === "name")) || (key3 === "department")) || (key3 === "departmentName"))){
|
|
547
|
+
const err45 = {instancePath:instancePath+"/siteOwner",schemaPath:"#/$defs/account/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};
|
|
548
|
+
if(vErrors === null){
|
|
549
|
+
vErrors = [err45];
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
vErrors.push(err45);
|
|
553
|
+
}
|
|
554
|
+
errors++;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if(data21.type !== undefined){
|
|
558
|
+
let data22 = data21.type;
|
|
559
|
+
if(typeof data22 !== "string"){
|
|
560
|
+
const err46 = {instancePath:instancePath+"/siteOwner/type",schemaPath:"#/$defs/account/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
561
|
+
if(vErrors === null){
|
|
562
|
+
vErrors = [err46];
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
vErrors.push(err46);
|
|
566
|
+
}
|
|
567
|
+
errors++;
|
|
568
|
+
}
|
|
569
|
+
if(!((data22 === "user") || (data22 === "organization"))){
|
|
570
|
+
const err47 = {instancePath:instancePath+"/siteOwner/type",schemaPath:"#/$defs/account/properties/type/enum",keyword:"enum",params:{allowedValues: schema20.properties.type.enum},message:"must be equal to one of the allowed values"};
|
|
571
|
+
if(vErrors === null){
|
|
572
|
+
vErrors = [err47];
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
vErrors.push(err47);
|
|
576
|
+
}
|
|
577
|
+
errors++;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if(data21.id !== undefined){
|
|
581
|
+
if(typeof data21.id !== "string"){
|
|
582
|
+
const err48 = {instancePath:instancePath+"/siteOwner/id",schemaPath:"#/$defs/account/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
583
|
+
if(vErrors === null){
|
|
584
|
+
vErrors = [err48];
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
vErrors.push(err48);
|
|
588
|
+
}
|
|
589
|
+
errors++;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if(data21.name !== undefined){
|
|
593
|
+
if(typeof data21.name !== "string"){
|
|
594
|
+
const err49 = {instancePath:instancePath+"/siteOwner/name",schemaPath:"#/$defs/account/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
595
|
+
if(vErrors === null){
|
|
596
|
+
vErrors = [err49];
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
vErrors.push(err49);
|
|
600
|
+
}
|
|
601
|
+
errors++;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if(data21.department !== undefined){
|
|
605
|
+
if(typeof data21.department !== "string"){
|
|
606
|
+
const err50 = {instancePath:instancePath+"/siteOwner/department",schemaPath:"#/$defs/account/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
607
|
+
if(vErrors === null){
|
|
608
|
+
vErrors = [err50];
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
vErrors.push(err50);
|
|
612
|
+
}
|
|
613
|
+
errors++;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if(data21.departmentName !== undefined){
|
|
617
|
+
if(typeof data21.departmentName !== "string"){
|
|
618
|
+
const err51 = {instancePath:instancePath+"/siteOwner/departmentName",schemaPath:"#/$defs/account/properties/departmentName/type",keyword:"type",params:{type: "string"},message:"must be string"};
|
|
619
|
+
if(vErrors === null){
|
|
620
|
+
vErrors = [err51];
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
vErrors.push(err51);
|
|
624
|
+
}
|
|
625
|
+
errors++;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
const err52 = {instancePath:instancePath+"/siteOwner",schemaPath:"#/$defs/account/type",keyword:"type",params:{type: "object"},message:"must be object"};
|
|
631
|
+
if(vErrors === null){
|
|
632
|
+
vErrors = [err52];
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
vErrors.push(err52);
|
|
636
|
+
}
|
|
637
|
+
errors++;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
const err53 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};
|
|
643
|
+
if(vErrors === null){
|
|
644
|
+
vErrors = [err53];
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
vErrors.push(err53);
|
|
648
|
+
}
|
|
649
|
+
errors++;
|
|
650
|
+
}
|
|
523
651
|
validate15.errors = vErrors;
|
|
524
652
|
return errors === 0;
|
|
525
653
|
}
|
|
@@ -541,7 +669,7 @@ vErrors.push(err0);
|
|
|
541
669
|
errors++;
|
|
542
670
|
}
|
|
543
671
|
for(const key0 in data){
|
|
544
|
-
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"))){
|
|
545
673
|
const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};
|
|
546
674
|
if(vErrors === null){
|
|
547
675
|
vErrors = [err1];
|
|
@@ -756,7 +884,7 @@ vErrors.push(err18);
|
|
|
756
884
|
errors++;
|
|
757
885
|
}
|
|
758
886
|
if(!((data9 === "user") || (data9 === "organization"))){
|
|
759
|
-
const err19 = {instancePath:instancePath+"/account/type",schemaPath:"#/$defs/account/properties/type/enum",keyword:"enum",params:{allowedValues:
|
|
887
|
+
const err19 = {instancePath:instancePath+"/account/type",schemaPath:"#/$defs/account/properties/type/enum",keyword:"enum",params:{allowedValues: schema20.properties.type.enum},message:"must be equal to one of the allowed values"};
|
|
760
888
|
if(vErrors === null){
|
|
761
889
|
vErrors = [err19];
|
|
762
890
|
}
|
|
@@ -838,9 +966,9 @@ vErrors.push(err25);
|
|
|
838
966
|
errors++;
|
|
839
967
|
}
|
|
840
968
|
}
|
|
841
|
-
if(data.
|
|
842
|
-
if(typeof data.
|
|
843
|
-
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"};
|
|
844
972
|
if(vErrors === null){
|
|
845
973
|
vErrors = [err26];
|
|
846
974
|
}
|
|
@@ -850,9 +978,9 @@ vErrors.push(err26);
|
|
|
850
978
|
errors++;
|
|
851
979
|
}
|
|
852
980
|
}
|
|
853
|
-
if(data.
|
|
854
|
-
if(typeof data.
|
|
855
|
-
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"};
|
|
856
984
|
if(vErrors === null){
|
|
857
985
|
vErrors = [err27];
|
|
858
986
|
}
|
|
@@ -862,9 +990,9 @@ vErrors.push(err27);
|
|
|
862
990
|
errors++;
|
|
863
991
|
}
|
|
864
992
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
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"};
|
|
868
996
|
if(vErrors === null){
|
|
869
997
|
vErrors = [err28];
|
|
870
998
|
}
|
|
@@ -873,6 +1001,18 @@ vErrors.push(err28);
|
|
|
873
1001
|
}
|
|
874
1002
|
errors++;
|
|
875
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
|
+
}
|
|
876
1016
|
validate14.errors = vErrors;
|
|
877
1017
|
return errors === 0;
|
|
878
1018
|
}
|
package/session/schema.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ declare const _default: {
|
|
|
18
18
|
accountRole: {
|
|
19
19
|
type: string;
|
|
20
20
|
};
|
|
21
|
+
siteRole: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
21
24
|
lang: {
|
|
22
25
|
type: string;
|
|
23
26
|
};
|
|
@@ -121,6 +124,9 @@ declare const _default: {
|
|
|
121
124
|
type: string;
|
|
122
125
|
enum: number[];
|
|
123
126
|
};
|
|
127
|
+
siteOwner: {
|
|
128
|
+
$ref: string;
|
|
129
|
+
};
|
|
124
130
|
};
|
|
125
131
|
};
|
|
126
132
|
account: {
|
package/session/schema.js
CHANGED
|
@@ -18,6 +18,9 @@ export default {
|
|
|
18
18
|
accountRole: {
|
|
19
19
|
type: 'string'
|
|
20
20
|
},
|
|
21
|
+
siteRole: {
|
|
22
|
+
type: 'string'
|
|
23
|
+
},
|
|
21
24
|
lang: {
|
|
22
25
|
type: 'string'
|
|
23
26
|
},
|
|
@@ -132,6 +135,9 @@ export default {
|
|
|
132
135
|
rememberMe: {
|
|
133
136
|
type: 'integer',
|
|
134
137
|
enum: [1]
|
|
138
|
+
},
|
|
139
|
+
siteOwner: {
|
|
140
|
+
$ref: '#/$defs/account'
|
|
135
141
|
}
|
|
136
142
|
}
|
|
137
143
|
},
|