@data-fair/lib-common-types 1.3.0 → 1.4.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 +69 -0
- package/event/.type/index.js +7 -0
- package/event/index.d.ts +1 -0
- package/event/index.js +1 -0
- package/event/schema.d.ts +100 -0
- package/event/schema.js +79 -0
- package/package.json +1 -1
- package/session/.type/index.d.ts +1 -0
- package/session/.type/validate.js +17 -5
- package/session/schema.d.ts +3 -0
- package/session/schema.js +3 -0
|
@@ -0,0 +1,69 @@
|
|
|
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 type Title = string;
|
|
6
|
+
export type Content = string;
|
|
7
|
+
export type HTMLContent = string;
|
|
8
|
+
export type URLOfEventIcon = string;
|
|
9
|
+
export type CleDuSujet = string;
|
|
10
|
+
export type LibelleDuSujet = string;
|
|
11
|
+
export type Visibility = "public" | "private";
|
|
12
|
+
export type ReceptionDate = string;
|
|
13
|
+
|
|
14
|
+
export interface Event {
|
|
15
|
+
title: Title | InternationalizedTitle;
|
|
16
|
+
body?: Content | InternationalizedContent;
|
|
17
|
+
htmlBody?: HTMLContent | InternationalizedHTMLContent;
|
|
18
|
+
icon?: URLOfEventIcon;
|
|
19
|
+
sender: Emitter;
|
|
20
|
+
topic: {
|
|
21
|
+
key: CleDuSujet;
|
|
22
|
+
title?: LibelleDuSujet;
|
|
23
|
+
};
|
|
24
|
+
urlParams?: UsedToFillSubscriptionUrlTemplateAndSoCreateNotificationUrl;
|
|
25
|
+
visibility?: Visibility;
|
|
26
|
+
date: ReceptionDate;
|
|
27
|
+
/**
|
|
28
|
+
* Free properties that varie depending on the type of event
|
|
29
|
+
*/
|
|
30
|
+
extra?: {
|
|
31
|
+
[k: string]: unknown;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface InternationalizedTitle {
|
|
35
|
+
/**
|
|
36
|
+
* This interface was referenced by `InternationalizedTitle`'s JSON-Schema definition
|
|
37
|
+
* via the `patternProperty` ".*".
|
|
38
|
+
*/
|
|
39
|
+
[k: string]: string;
|
|
40
|
+
}
|
|
41
|
+
export interface InternationalizedContent {
|
|
42
|
+
/**
|
|
43
|
+
* This interface was referenced by `InternationalizedContent`'s JSON-Schema definition
|
|
44
|
+
* via the `patternProperty` ".*".
|
|
45
|
+
*/
|
|
46
|
+
[k: string]: string;
|
|
47
|
+
}
|
|
48
|
+
export interface InternationalizedHTMLContent {
|
|
49
|
+
/**
|
|
50
|
+
* This interface was referenced by `InternationalizedHTMLContent`'s JSON-Schema definition
|
|
51
|
+
* via the `patternProperty` ".*".
|
|
52
|
+
*/
|
|
53
|
+
[k: string]: string;
|
|
54
|
+
}
|
|
55
|
+
export interface Emitter {
|
|
56
|
+
type: "user" | "organization";
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
department?: string;
|
|
60
|
+
departmentName?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface UsedToFillSubscriptionUrlTemplateAndSoCreateNotificationUrl {
|
|
63
|
+
/**
|
|
64
|
+
* This interface was referenced by `UsedToFillSubscriptionUrlTemplateAndSoCreateNotificationUrl`'s JSON-Schema definition
|
|
65
|
+
* via the `patternProperty` ".*".
|
|
66
|
+
*/
|
|
67
|
+
[k: string]: string;
|
|
68
|
+
}
|
|
69
|
+
|
package/event/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './.type/index.js';
|
package/event/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './.type/index.js'
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
$id: string;
|
|
3
|
+
'x-exports': string[];
|
|
4
|
+
title: string;
|
|
5
|
+
type: string;
|
|
6
|
+
additionalProperties: boolean;
|
|
7
|
+
required: string[];
|
|
8
|
+
properties: {
|
|
9
|
+
title: {
|
|
10
|
+
oneOf: ({
|
|
11
|
+
type: string;
|
|
12
|
+
title: string;
|
|
13
|
+
patternProperties: {
|
|
14
|
+
'.*': {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
type: string;
|
|
20
|
+
title: string;
|
|
21
|
+
})[];
|
|
22
|
+
};
|
|
23
|
+
body: {
|
|
24
|
+
oneOf: ({
|
|
25
|
+
type: string;
|
|
26
|
+
title: string;
|
|
27
|
+
patternProperties: {
|
|
28
|
+
'.*': {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
type: string;
|
|
34
|
+
title: string;
|
|
35
|
+
})[];
|
|
36
|
+
};
|
|
37
|
+
htmlBody: {
|
|
38
|
+
oneOf: ({
|
|
39
|
+
type: string;
|
|
40
|
+
title: string;
|
|
41
|
+
patternProperties: {
|
|
42
|
+
'.*': {
|
|
43
|
+
type: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
type: string;
|
|
48
|
+
title: string;
|
|
49
|
+
})[];
|
|
50
|
+
};
|
|
51
|
+
icon: {
|
|
52
|
+
type: string;
|
|
53
|
+
title: string;
|
|
54
|
+
};
|
|
55
|
+
sender: {
|
|
56
|
+
$ref: string;
|
|
57
|
+
title: string;
|
|
58
|
+
};
|
|
59
|
+
topic: {
|
|
60
|
+
type: string;
|
|
61
|
+
additionalProperties: boolean;
|
|
62
|
+
required: string[];
|
|
63
|
+
properties: {
|
|
64
|
+
key: {
|
|
65
|
+
type: string;
|
|
66
|
+
title: string;
|
|
67
|
+
};
|
|
68
|
+
title: {
|
|
69
|
+
type: string;
|
|
70
|
+
title: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
urlParams: {
|
|
75
|
+
type: string;
|
|
76
|
+
title: string;
|
|
77
|
+
patternProperties: {
|
|
78
|
+
'.*': {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
visibility: {
|
|
84
|
+
type: string;
|
|
85
|
+
title: string;
|
|
86
|
+
enum: string[];
|
|
87
|
+
default: string;
|
|
88
|
+
};
|
|
89
|
+
date: {
|
|
90
|
+
type: string;
|
|
91
|
+
title: string;
|
|
92
|
+
format: string;
|
|
93
|
+
};
|
|
94
|
+
extra: {
|
|
95
|
+
type: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export default _default;
|
package/event/schema.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const i18nMsg = (title) => ({
|
|
2
|
+
type: 'object',
|
|
3
|
+
title: `Internationalized ${title} `,
|
|
4
|
+
patternProperties: {
|
|
5
|
+
'.*': { type: 'string' }
|
|
6
|
+
}
|
|
7
|
+
// properties: ['fr', 'en'].reduce((/** @type {Record<string, any>} */props, locale) => { props[locale] = { type: 'string', title: locale }; return props }, {})
|
|
8
|
+
})
|
|
9
|
+
export default {
|
|
10
|
+
$id: 'https://github.com/data-fair/lib/event',
|
|
11
|
+
'x-exports': ['types'],
|
|
12
|
+
title: 'Event',
|
|
13
|
+
type: 'object',
|
|
14
|
+
additionalProperties: false,
|
|
15
|
+
required: ['title', 'topic', 'sender', 'date'],
|
|
16
|
+
properties: {
|
|
17
|
+
title: {
|
|
18
|
+
oneOf: [{
|
|
19
|
+
type: 'string',
|
|
20
|
+
title: 'Title'
|
|
21
|
+
}, i18nMsg('title')]
|
|
22
|
+
},
|
|
23
|
+
body: {
|
|
24
|
+
oneOf: [{
|
|
25
|
+
type: 'string',
|
|
26
|
+
title: 'Content'
|
|
27
|
+
}, i18nMsg('content')]
|
|
28
|
+
},
|
|
29
|
+
htmlBody: {
|
|
30
|
+
oneOf: [{
|
|
31
|
+
type: 'string',
|
|
32
|
+
title: 'HTML content'
|
|
33
|
+
}, i18nMsg('HTML content')]
|
|
34
|
+
},
|
|
35
|
+
icon: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
title: 'URL of event icon'
|
|
38
|
+
},
|
|
39
|
+
// sender is the owner of the topic
|
|
40
|
+
sender: { $ref: 'https://github.com/data-fair/lib/session-state#/$defs/account', title: 'Emitter' },
|
|
41
|
+
topic: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
required: ['key'],
|
|
45
|
+
properties: {
|
|
46
|
+
key: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
title: 'Clé du sujet'
|
|
49
|
+
},
|
|
50
|
+
title: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
title: 'Libellé du sujet'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
urlParams: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
title: 'used to fill subscription.urlTemplate and so create notification.url',
|
|
59
|
+
patternProperties: {
|
|
60
|
+
'.*': { type: 'string' }
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
visibility: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
title: 'Visibility',
|
|
66
|
+
enum: ['public', 'private'],
|
|
67
|
+
default: 'private'
|
|
68
|
+
},
|
|
69
|
+
date: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
title: 'Reception date',
|
|
72
|
+
format: 'date-time'
|
|
73
|
+
},
|
|
74
|
+
extra: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
description: 'Free properties that varie depending on the type of event'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
package/package.json
CHANGED
package/session/.type/index.d.ts
CHANGED
|
@@ -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,"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]}}},"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,"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":"boolean"}}},"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
|
-
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]}}};
|
|
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":"boolean"}}};
|
|
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;
|
|
@@ -486,9 +486,9 @@ vErrors.push(err39);
|
|
|
486
486
|
errors++;
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const err40 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "
|
|
489
|
+
if(data.rememberMe !== undefined){
|
|
490
|
+
if(typeof data.rememberMe !== "boolean"){
|
|
491
|
+
const err40 = {instancePath:instancePath+"/rememberMe",schemaPath:"#/properties/rememberMe/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};
|
|
492
492
|
if(vErrors === null){
|
|
493
493
|
vErrors = [err40];
|
|
494
494
|
}
|
|
@@ -497,6 +497,18 @@ vErrors.push(err40);
|
|
|
497
497
|
}
|
|
498
498
|
errors++;
|
|
499
499
|
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
const err41 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};
|
|
504
|
+
if(vErrors === null){
|
|
505
|
+
vErrors = [err41];
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
vErrors.push(err41);
|
|
509
|
+
}
|
|
510
|
+
errors++;
|
|
511
|
+
}
|
|
500
512
|
validate15.errors = vErrors;
|
|
501
513
|
return errors === 0;
|
|
502
514
|
}
|
package/session/schema.d.ts
CHANGED