@data-fair/lib-common-types 0.1.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.
@@ -0,0 +1,29 @@
1
+
2
+ export const schemaExports: string[]
3
+
4
+ // see https://github.com/bcherny/json-schema-to-typescript/issues/439 if some types are not exported
5
+ export interface Account {
6
+ type: "user" | "organization";
7
+ id: string;
8
+ name: string;
9
+ department?: string;
10
+ departmentName?: string;
11
+ [k: string]: unknown;
12
+ }
13
+ /**
14
+ * This interface was referenced by `Account`'s JSON-Schema
15
+ * via the `definition` "accountKeys".
16
+ */
17
+ export interface AccountKeys {
18
+ type: "user" | "organization";
19
+ id: string;
20
+ department?: string;
21
+ }
22
+
23
+
24
+ export const validate: (data: any) => data is Account
25
+ export const assertValid: (data: any, options?: import('@data-fair/lib-node/validation.js').AssertValidOptions) => asserts data is Account
26
+ export const returnValid: (data: any, options?: import('@data-fair/lib-node/validation.js').AssertValidOptions) => Account
27
+
28
+ export const schema: any
29
+
@@ -0,0 +1,83 @@
1
+ /* eslint-disable */
2
+
3
+
4
+ import validate from './validate.js'
5
+ import { assertValid as assertValidGeneric } from '@data-fair/lib-node/validation.js'
6
+
7
+ export const schemaExports = [
8
+ "types",
9
+ "validate",
10
+ "schema"
11
+ ]
12
+
13
+ export { validate } from './validate.js'
14
+ export const assertValid = (data, options) => {
15
+ assertValidGeneric(validate, data, options)
16
+ }
17
+ export const returnValid = (data, options) => {
18
+ assertValid(data, options)
19
+ return data
20
+ }
21
+
22
+ export const schema = {
23
+ "$id": "https://github.com/data-fair/lib/account",
24
+ "x-exports": [
25
+ "types",
26
+ "validate",
27
+ "schema"
28
+ ],
29
+ "type": "object",
30
+ "title": "account",
31
+ "required": [
32
+ "type",
33
+ "id",
34
+ "name"
35
+ ],
36
+ "properties": {
37
+ "type": {
38
+ "type": "string",
39
+ "enum": [
40
+ "user",
41
+ "organization"
42
+ ]
43
+ },
44
+ "id": {
45
+ "type": "string"
46
+ },
47
+ "name": {
48
+ "type": "string"
49
+ },
50
+ "department": {
51
+ "type": "string"
52
+ },
53
+ "departmentName": {
54
+ "type": "string"
55
+ }
56
+ },
57
+ "$defs": {
58
+ "accountKeys": {
59
+ "type": "object",
60
+ "title": "account keys",
61
+ "required": [
62
+ "type",
63
+ "id"
64
+ ],
65
+ "additionalProperties": false,
66
+ "properties": {
67
+ "type": {
68
+ "type": "string",
69
+ "enum": [
70
+ "user",
71
+ "organization"
72
+ ]
73
+ },
74
+ "id": {
75
+ "type": "string"
76
+ },
77
+ "department": {
78
+ "type": "string"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,128 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+
4
+ "use strict";
5
+ export const validate = validate14;
6
+ export default validate14;
7
+ const schema16 = {"$id":"https://github.com/data-fair/lib/account","x-exports":["types","validate","schema"],"type":"object","title":"account","required":["type","id","name"],"properties":{"type":{"type":"string","enum":["user","organization"]},"id":{"type":"string"},"name":{"type":"string"},"department":{"type":"string"},"departmentName":{"type":"string"}},"$defs":{"accountKeys":{"type":"object","title":"account keys","required":["type","id"],"additionalProperties":false,"properties":{"type":{"type":"string","enum":["user","organization"]},"id":{"type":"string"},"department":{"type":"string"}}}}};
8
+
9
+ function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){
10
+ /*# sourceURL="https://github.com/data-fair/lib/account" */;
11
+ let vErrors = null;
12
+ let errors = 0;
13
+ if(data && typeof data == "object" && !Array.isArray(data)){
14
+ if(data.type === undefined){
15
+ const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};
16
+ if(vErrors === null){
17
+ vErrors = [err0];
18
+ }
19
+ else {
20
+ vErrors.push(err0);
21
+ }
22
+ errors++;
23
+ }
24
+ if(data.id === undefined){
25
+ const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
26
+ if(vErrors === null){
27
+ vErrors = [err1];
28
+ }
29
+ else {
30
+ vErrors.push(err1);
31
+ }
32
+ errors++;
33
+ }
34
+ if(data.name === undefined){
35
+ const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};
36
+ if(vErrors === null){
37
+ vErrors = [err2];
38
+ }
39
+ else {
40
+ vErrors.push(err2);
41
+ }
42
+ errors++;
43
+ }
44
+ if(data.type !== undefined){
45
+ let data0 = data.type;
46
+ if(typeof data0 !== "string"){
47
+ const err3 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"};
48
+ if(vErrors === null){
49
+ vErrors = [err3];
50
+ }
51
+ else {
52
+ vErrors.push(err3);
53
+ }
54
+ errors++;
55
+ }
56
+ if(!((data0 === "user") || (data0 === "organization"))){
57
+ const err4 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues: schema16.properties.type.enum},message:"must be equal to one of the allowed values"};
58
+ if(vErrors === null){
59
+ vErrors = [err4];
60
+ }
61
+ else {
62
+ vErrors.push(err4);
63
+ }
64
+ errors++;
65
+ }
66
+ }
67
+ if(data.id !== undefined){
68
+ if(typeof data.id !== "string"){
69
+ const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
70
+ if(vErrors === null){
71
+ vErrors = [err5];
72
+ }
73
+ else {
74
+ vErrors.push(err5);
75
+ }
76
+ errors++;
77
+ }
78
+ }
79
+ if(data.name !== undefined){
80
+ if(typeof data.name !== "string"){
81
+ const err6 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};
82
+ if(vErrors === null){
83
+ vErrors = [err6];
84
+ }
85
+ else {
86
+ vErrors.push(err6);
87
+ }
88
+ errors++;
89
+ }
90
+ }
91
+ if(data.department !== undefined){
92
+ if(typeof data.department !== "string"){
93
+ const err7 = {instancePath:instancePath+"/department",schemaPath:"#/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
94
+ if(vErrors === null){
95
+ vErrors = [err7];
96
+ }
97
+ else {
98
+ vErrors.push(err7);
99
+ }
100
+ errors++;
101
+ }
102
+ }
103
+ if(data.departmentName !== undefined){
104
+ if(typeof data.departmentName !== "string"){
105
+ const err8 = {instancePath:instancePath+"/departmentName",schemaPath:"#/properties/departmentName/type",keyword:"type",params:{type: "string"},message:"must be string"};
106
+ if(vErrors === null){
107
+ vErrors = [err8];
108
+ }
109
+ else {
110
+ vErrors.push(err8);
111
+ }
112
+ errors++;
113
+ }
114
+ }
115
+ }
116
+ else {
117
+ const err9 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};
118
+ if(vErrors === null){
119
+ vErrors = [err9];
120
+ }
121
+ else {
122
+ vErrors.push(err9);
123
+ }
124
+ errors++;
125
+ }
126
+ validate14.errors = vErrors;
127
+ return errors === 0;
128
+ }
@@ -0,0 +1 @@
1
+ export * from './.type/index.js'
@@ -0,0 +1,100 @@
1
+
2
+ export const schemaExports: string[]
3
+
4
+ // see https://github.com/bcherny/json-schema-to-typescript/issues/439 if some types are not exported
5
+ /**
6
+ * This interface was referenced by `Application`'s JSON-Schema
7
+ * via the `definition` "dataset".
8
+ */
9
+ export type Dataset = {
10
+ href: string;
11
+ id: string;
12
+ title: string;
13
+ /**
14
+ * Not the id of the dataset, but a key inside this configuration object to define the role of the dataset in this context.
15
+ */
16
+ key?: string;
17
+ schema?: Field[];
18
+ finalizedAt: string;
19
+ [k: string]: unknown;
20
+ } & Dataset1;
21
+ export type Dataset1 = {
22
+ href: string;
23
+ id: string;
24
+ title: string;
25
+ /**
26
+ * Not the id of the dataset, but a key inside this configuration object to define the role of the dataset in this context.
27
+ */
28
+ key?: string;
29
+ schema?: Field[];
30
+ finalizedAt: string;
31
+ [k: string]: unknown;
32
+ } | null;
33
+
34
+ export interface Application {
35
+ /**
36
+ * Globally unique identifier of the application
37
+ */
38
+ id: string;
39
+ /**
40
+ * Short title of the application
41
+ */
42
+ title: string;
43
+ /**
44
+ * The URL where this application is exposed
45
+ */
46
+ exposedUrl: string;
47
+ /**
48
+ * The URL where this resource can be fetched
49
+ */
50
+ href: string;
51
+ /**
52
+ * The URL where this application can be accessed through a websocket
53
+ */
54
+ wsUrl: string;
55
+ owner: AccountKeys;
56
+ /**
57
+ * A free format configuration object used by applications. A minimal common structure is used to ensure proper linking between applications and datasets and remote services
58
+ */
59
+ configuration: {
60
+ datasets?: Dataset[];
61
+ [k: string]: unknown;
62
+ };
63
+ [k: string]: unknown;
64
+ }
65
+ export interface AccountKeys {
66
+ type: "user" | "organization";
67
+ id: string;
68
+ department?: string;
69
+ }
70
+ /**
71
+ * This interface was referenced by `Application`'s JSON-Schema
72
+ * via the `definition` "field".
73
+ */
74
+ export interface Field {
75
+ key: string;
76
+ type: string;
77
+ format?: string;
78
+ title?: string;
79
+ "x-originalName"?: string;
80
+ "x-group"?: string;
81
+ /**
82
+ * @deprecated
83
+ */
84
+ "x-refersTo"?: string | null;
85
+ "x-concept"?: {
86
+ id?: string;
87
+ title?: string;
88
+ primary?: boolean;
89
+ [k: string]: unknown;
90
+ };
91
+ "x-labels"?: {
92
+ [k: string]: string;
93
+ };
94
+ "x-labelsRestricted"?: boolean;
95
+ [k: string]: unknown;
96
+ }
97
+
98
+
99
+ export const schema: any
100
+
@@ -0,0 +1,161 @@
1
+ /* eslint-disable */
2
+
3
+
4
+
5
+ export const schemaExports = [
6
+ "types",
7
+ "schema"
8
+ ]
9
+
10
+ export const schema = {
11
+ "$id": "https://github.com/data-fair/lib/application",
12
+ "title": "Application",
13
+ "x-exports": [
14
+ "types",
15
+ "schema"
16
+ ],
17
+ "type": "object",
18
+ "required": [
19
+ "id",
20
+ "title",
21
+ "exposedUrl",
22
+ "href",
23
+ "wsUrl",
24
+ "owner",
25
+ "configuration"
26
+ ],
27
+ "properties": {
28
+ "id": {
29
+ "type": "string",
30
+ "description": "Globally unique identifier of the application"
31
+ },
32
+ "title": {
33
+ "type": "string",
34
+ "description": "Short title of the application"
35
+ },
36
+ "exposedUrl": {
37
+ "type": "string",
38
+ "description": "The URL where this application is exposed"
39
+ },
40
+ "href": {
41
+ "type": "string",
42
+ "description": "The URL where this resource can be fetched"
43
+ },
44
+ "wsUrl": {
45
+ "type": "string",
46
+ "description": "The URL where this application can be accessed through a websocket"
47
+ },
48
+ "owner": {
49
+ "$ref": "https://github.com/data-fair/lib/account#/$defs/accountKeys"
50
+ },
51
+ "configuration": {
52
+ "type": "object",
53
+ "description": "A free format configuration object used by applications. A minimal common structure is used to ensure proper linking between applications and datasets and remote services",
54
+ "additionalProperties": true,
55
+ "properties": {
56
+ "datasets": {
57
+ "type": "array",
58
+ "items": {
59
+ "$ref": "#/$defs/dataset"
60
+ }
61
+ }
62
+ }
63
+ }
64
+ },
65
+ "$defs": {
66
+ "dataset": {
67
+ "type": [
68
+ "object",
69
+ "null"
70
+ ],
71
+ "required": [
72
+ "href",
73
+ "id",
74
+ "title",
75
+ "finalizedAt"
76
+ ],
77
+ "properties": {
78
+ "href": {
79
+ "type": "string"
80
+ },
81
+ "id": {
82
+ "type": "string"
83
+ },
84
+ "title": {
85
+ "type": "string"
86
+ },
87
+ "key": {
88
+ "type": "string",
89
+ "description": "Not the id of the dataset, but a key inside this configuration object to define the role of the dataset in this context."
90
+ },
91
+ "schema": {
92
+ "type": "array",
93
+ "items": {
94
+ "$ref": "#/$defs/field"
95
+ }
96
+ },
97
+ "finalizedAt": {
98
+ "type": "string",
99
+ "format": "date-time"
100
+ }
101
+ }
102
+ },
103
+ "field": {
104
+ "type": "object",
105
+ "required": [
106
+ "key",
107
+ "type"
108
+ ],
109
+ "properties": {
110
+ "key": {
111
+ "type": "string"
112
+ },
113
+ "type": {
114
+ "type": "string"
115
+ },
116
+ "format": {
117
+ "type": "string"
118
+ },
119
+ "title": {
120
+ "type": "string"
121
+ },
122
+ "x-originalName": {
123
+ "type": "string"
124
+ },
125
+ "x-group": {
126
+ "type": "string"
127
+ },
128
+ "x-refersTo": {
129
+ "deprecated": true,
130
+ "type": [
131
+ "string",
132
+ "null"
133
+ ]
134
+ },
135
+ "x-concept": {
136
+ "type": "object",
137
+ "properties": {
138
+ "id": {
139
+ "type": "string"
140
+ },
141
+ "title": {
142
+ "type": "string"
143
+ },
144
+ "primary": {
145
+ "type": "boolean"
146
+ }
147
+ }
148
+ },
149
+ "x-labels": {
150
+ "type": "object",
151
+ "additionalProperties": {
152
+ "type": "string"
153
+ }
154
+ },
155
+ "x-labelsRestricted": {
156
+ "type": "boolean"
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
@@ -0,0 +1 @@
1
+ export * from './.type/index.js'
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@data-fair/lib-common-types",
3
+ "version": "0.1.0",
4
+ "description": "Shared schemas and built type definitions in the data-fair stack.",
5
+ "main": "index.js",
6
+ "devDependencies": {},
7
+ "files": [
8
+ "**/*.js",
9
+ "**/*.d.ts"
10
+ ],
11
+ "author": "",
12
+ "license": "MIT",
13
+ "type": "module"
14
+ }
@@ -0,0 +1,66 @@
1
+
2
+ export const schemaExports: string[]
3
+
4
+ // see https://github.com/bcherny/json-schema-to-typescript/issues/439 if some types are not exported
5
+ export interface SessionState {
6
+ user?: User;
7
+ organization?: OrganizationMembership;
8
+ account?: Account;
9
+ accountRole?: string;
10
+ lang?: string;
11
+ dark?: boolean;
12
+ }
13
+ /**
14
+ * This interface was referenced by `SessionState`'s JSON-Schema
15
+ * via the `definition` "user".
16
+ */
17
+ export interface User {
18
+ email: string;
19
+ id: string;
20
+ name: string;
21
+ organizations: OrganizationMembership[];
22
+ isAdmin?: 0 | 1;
23
+ adminMode?: 0 | 1;
24
+ asAdmin?: UserRef;
25
+ pd?: string;
26
+ ipa?: 0 | 1;
27
+ }
28
+ /**
29
+ * This interface was referenced by `SessionState`'s JSON-Schema
30
+ * via the `definition` "organizationMembership".
31
+ */
32
+ export interface OrganizationMembership {
33
+ id: string;
34
+ name: string;
35
+ role: string;
36
+ department?: string;
37
+ departmentName?: string;
38
+ dflt?: boolean;
39
+ }
40
+ /**
41
+ * This interface was referenced by `SessionState`'s JSON-Schema
42
+ * via the `definition` "userRef".
43
+ */
44
+ export interface UserRef {
45
+ id: string;
46
+ name: string;
47
+ }
48
+ /**
49
+ * This interface was referenced by `SessionState`'s JSON-Schema
50
+ * via the `definition` "account".
51
+ */
52
+ export interface Account {
53
+ type: "user" | "organization";
54
+ id: string;
55
+ name: string;
56
+ department?: string;
57
+ departmentName?: string;
58
+ }
59
+
60
+
61
+ export const validate: (data: any) => data is SessionState
62
+ export const assertValid: (data: any, options?: import('@data-fair/lib-node/validation.js').AssertValidOptions) => asserts data is SessionState
63
+ export const returnValid: (data: any, options?: import('@data-fair/lib-node/validation.js').AssertValidOptions) => SessionState
64
+
65
+ export const schema: any
66
+