@data-fair/lib-common-types 1.6.0 → 1.7.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": "@data-fair/lib-common-types",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Shared schemas and built type definitions in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,8 @@
8
8
  "build": "cd .. && npm run build"
9
9
  },
10
10
  "dependencies": {
11
- "@data-fair/lib-validation": "^1.0.0"
11
+ "@data-fair/lib-validation": "^1.0.0",
12
+ "ajv-formats": "3.0.1"
12
13
  },
13
14
  "devDependencies": {},
14
15
  "files": [
@@ -34,6 +34,7 @@ export type User = {
34
34
  idp?: IsTheUserComingFromACoreIDProvider;
35
35
  os?: ShortForOrgStorage;
36
36
  rememberMe?: 1;
37
+ siteOwner?: Account;
37
38
  }
38
39
  /**
39
40
  * 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"},"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 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
- 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
- else {
514
- const err42 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};
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
  }
@@ -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: schema21.properties.type.enum},message:"must be equal to one of the allowed values"};
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
  }
@@ -121,6 +121,9 @@ declare const _default: {
121
121
  type: string;
122
122
  enum: number[];
123
123
  };
124
+ siteOwner: {
125
+ $ref: string;
126
+ };
124
127
  };
125
128
  };
126
129
  account: {
package/session/schema.js CHANGED
@@ -132,6 +132,9 @@ export default {
132
132
  rememberMe: {
133
133
  type: 'integer',
134
134
  enum: [1]
135
+ },
136
+ siteOwner: {
137
+ $ref: '#/$defs/account'
135
138
  }
136
139
  }
137
140
  },