@laboratoria/sdk-js 5.0.1 → 5.1.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/laboratoria-sdk-esm.js +1 -1
- package/dist/laboratoria-sdk-umd.js +1 -1
- package/index.js +2 -0
- package/lib/core.js +10 -2
- package/lib/util.js +68 -0
- package/package.json +5 -5
- package/schemas/core.json +94 -3
package/index.js
CHANGED
@@ -10,6 +10,8 @@ import { createAPI as createCoreAPI } from './lib/core';
|
|
10
10
|
import { createAPI as createCurriculumAPI } from './lib/curriculum';
|
11
11
|
import { createAPI as createJobsAPI } from './lib/jobs';
|
12
12
|
|
13
|
+
export * from './lib/util';
|
14
|
+
|
13
15
|
export const createApp = ({
|
14
16
|
firebaseApiKey = 'AIzaSyAXbaEbpq8NOfn0r8mIrcoHvoGRkJThwdc',
|
15
17
|
firebaseProject = 'laboratoria-la',
|
package/lib/core.js
CHANGED
@@ -10,7 +10,8 @@ const extended = {
|
|
10
10
|
Country: {
|
11
11
|
primaryKey: 'code',
|
12
12
|
plural: 'countries',
|
13
|
-
searchProps: ['code', 'name'],
|
13
|
+
searchProps: ['code', 'name', "timeZone"],
|
14
|
+
getOptionLabel: ({ code, name }) => `${code} / ${name}`,
|
14
15
|
},
|
15
16
|
ActivityLogEntry: {
|
16
17
|
plural: 'activityLog',
|
@@ -83,10 +84,14 @@ const extended = {
|
|
83
84
|
'name',
|
84
85
|
'start',
|
85
86
|
'end',
|
87
|
+
'timeZone',
|
88
|
+
'startTime',
|
89
|
+
'endTime',
|
86
90
|
'vacancies',
|
87
91
|
'admissionStart',
|
88
92
|
'admissionEnd',
|
89
93
|
'placementStart',
|
94
|
+
'admissionCountries',
|
90
95
|
],
|
91
96
|
searchProps: ['name'],
|
92
97
|
getOptionLabel: ({ id, name, stage }) => (
|
@@ -172,7 +177,10 @@ const extended = {
|
|
172
177
|
},
|
173
178
|
},
|
174
179
|
Student: {
|
175
|
-
inputProps: [
|
180
|
+
inputProps: [
|
181
|
+
'cohort',
|
182
|
+
'user',
|
183
|
+
],
|
176
184
|
searchProps: [],
|
177
185
|
},
|
178
186
|
Dropout: {
|
package/lib/util.js
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
const pad = n => n > 9 ? `${n}` : `0${n}`;
|
2
|
+
|
3
|
+
export const formatDate = date => (
|
4
|
+
`${pad(date.getUTCDate())}/${pad(date.getUTCMonth() + 1)}/${date.getUTCFullYear()}`
|
5
|
+
);
|
6
|
+
|
7
|
+
export const formatTime = date => (
|
8
|
+
`${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${date.getUTCSeconds()} UTC`
|
9
|
+
);
|
10
|
+
|
11
|
+
export const formatDateTime = date => `${formatDate(date)} ${formatTime(date)}`;
|
12
|
+
|
13
|
+
const locales = {
|
14
|
+
es: 'es-ES',
|
15
|
+
pt: 'pt-BR',
|
16
|
+
};
|
17
|
+
|
18
|
+
export const formatMonth = (date, lang = 'es', showYear = false) => {
|
19
|
+
return new Intl.DateTimeFormat(locales[lang], {
|
20
|
+
...(showYear && {
|
21
|
+
year: 'numeric',
|
22
|
+
}),
|
23
|
+
month: 'long',
|
24
|
+
day: 'numeric',
|
25
|
+
timeZone: 'UTC',
|
26
|
+
}).format(new Date(date));
|
27
|
+
};
|
28
|
+
|
29
|
+
export const getAgeAt = (dateOfBirth, at) => {
|
30
|
+
let age = at.getFullYear() - dateOfBirth.getFullYear();
|
31
|
+
const m = at.getMonth() - dateOfBirth.getMonth();
|
32
|
+
|
33
|
+
if (m < 0 || (m === 0 && at.getDate() < dateOfBirth.getDate())) {
|
34
|
+
age--;
|
35
|
+
}
|
36
|
+
|
37
|
+
return age;
|
38
|
+
};
|
39
|
+
|
40
|
+
const createCurrencyFormatter = (
|
41
|
+
lang,
|
42
|
+
countryCode,
|
43
|
+
currencyCode,
|
44
|
+
) => new Intl.NumberFormat(
|
45
|
+
`${lang}-${countryCode}`,
|
46
|
+
{ currency: currencyCode },
|
47
|
+
);
|
48
|
+
|
49
|
+
export const formatCurrency = (
|
50
|
+
val,
|
51
|
+
lang,
|
52
|
+
countryCode,
|
53
|
+
currencyCode,
|
54
|
+
) => createCurrencyFormatter(
|
55
|
+
lang,
|
56
|
+
countryCode,
|
57
|
+
currencyCode,
|
58
|
+
).format(val);
|
59
|
+
|
60
|
+
export const parseCurrency = val => parseInt(val.replace(/[,\.]/g, ''), 10);
|
61
|
+
|
62
|
+
export const loadFromLocalStorage = (path) => {
|
63
|
+
try {
|
64
|
+
return JSON.parse(window.localStorage.getItem(path));
|
65
|
+
} catch (_) {
|
66
|
+
return null;
|
67
|
+
}
|
68
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@laboratoria/sdk-js",
|
3
|
-
"version": "5.0.1",
|
3
|
+
"version": "5.1.0-beta.1",
|
4
4
|
"description": "Laboratoria JavaScript (browser) SDK",
|
5
5
|
"license": "MIT",
|
6
6
|
"scripts": {
|
@@ -11,16 +11,16 @@
|
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
13
|
"blueimp-md5": "^2.19.0",
|
14
|
-
"firebase": "^9.
|
14
|
+
"firebase": "^9.22.1"
|
15
15
|
},
|
16
16
|
"devDependencies": {
|
17
|
-
"@babel/core": "^7.
|
17
|
+
"@babel/core": "^7.22.1",
|
18
18
|
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
|
19
19
|
"babel-jest": "^29.5.0",
|
20
20
|
"jest": "^29.5.0",
|
21
21
|
"jest-environment-jsdom": "^29.5.0",
|
22
|
-
"webpack": "^5.
|
23
|
-
"webpack-cli": "^5.
|
22
|
+
"webpack": "^5.84.1",
|
23
|
+
"webpack-cli": "^5.1.1"
|
24
24
|
},
|
25
25
|
"jest": {
|
26
26
|
"testEnvironment": "jsdom",
|
package/schemas/core.json
CHANGED
@@ -10,6 +10,44 @@
|
|
10
10
|
"name": {
|
11
11
|
"type": "string"
|
12
12
|
},
|
13
|
+
"incomeFilter": {
|
14
|
+
"type": [
|
15
|
+
"integer",
|
16
|
+
"null"
|
17
|
+
]
|
18
|
+
},
|
19
|
+
"canApply": {
|
20
|
+
"type": "boolean",
|
21
|
+
"default": false
|
22
|
+
},
|
23
|
+
"capital": {
|
24
|
+
"type": "array",
|
25
|
+
"items": {
|
26
|
+
"type": "string"
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"timeZone": {
|
30
|
+
"type": [
|
31
|
+
"string",
|
32
|
+
"null"
|
33
|
+
]
|
34
|
+
},
|
35
|
+
"flag": {
|
36
|
+
"type": [
|
37
|
+
"string",
|
38
|
+
"null"
|
39
|
+
]
|
40
|
+
},
|
41
|
+
"currency": {
|
42
|
+
"anyOf": [
|
43
|
+
{
|
44
|
+
"$ref": "#/definitions/Currency"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"type": "null"
|
48
|
+
}
|
49
|
+
]
|
50
|
+
},
|
13
51
|
"contracts": {
|
14
52
|
"type": "array",
|
15
53
|
"items": {
|
@@ -39,6 +77,32 @@
|
|
39
77
|
"items": {
|
40
78
|
"$ref": "#/definitions/EducationLevel"
|
41
79
|
}
|
80
|
+
},
|
81
|
+
"universities": {
|
82
|
+
"type": "array",
|
83
|
+
"items": {
|
84
|
+
"$ref": "#/definitions/University"
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
"Currency": {
|
90
|
+
"type": "object",
|
91
|
+
"properties": {
|
92
|
+
"code": {
|
93
|
+
"type": "string"
|
94
|
+
},
|
95
|
+
"name": {
|
96
|
+
"type": "string"
|
97
|
+
},
|
98
|
+
"symbol": {
|
99
|
+
"type": "string"
|
100
|
+
},
|
101
|
+
"countries": {
|
102
|
+
"type": "array",
|
103
|
+
"items": {
|
104
|
+
"$ref": "#/definitions/Country"
|
105
|
+
}
|
42
106
|
}
|
43
107
|
}
|
44
108
|
},
|
@@ -374,6 +438,24 @@
|
|
374
438
|
"type": "string",
|
375
439
|
"format": "date-time"
|
376
440
|
},
|
441
|
+
"timeZone": {
|
442
|
+
"type": [
|
443
|
+
"string",
|
444
|
+
"null"
|
445
|
+
]
|
446
|
+
},
|
447
|
+
"startTime": {
|
448
|
+
"type": [
|
449
|
+
"string",
|
450
|
+
"null"
|
451
|
+
]
|
452
|
+
},
|
453
|
+
"endTime": {
|
454
|
+
"type": [
|
455
|
+
"string",
|
456
|
+
"null"
|
457
|
+
]
|
458
|
+
},
|
377
459
|
"legacySlug": {
|
378
460
|
"type": "string"
|
379
461
|
},
|
@@ -397,6 +479,12 @@
|
|
397
479
|
],
|
398
480
|
"format": "date-time"
|
399
481
|
},
|
482
|
+
"admissionCountries": {
|
483
|
+
"type": "array",
|
484
|
+
"items": {
|
485
|
+
"type": "string"
|
486
|
+
}
|
487
|
+
},
|
400
488
|
"placementStart": {
|
401
489
|
"type": [
|
402
490
|
"string",
|
@@ -659,9 +747,6 @@
|
|
659
747
|
"type": "string",
|
660
748
|
"format": "date-time"
|
661
749
|
},
|
662
|
-
"countryCode": {
|
663
|
-
"type": "string"
|
664
|
-
},
|
665
750
|
"lang": {
|
666
751
|
"type": "string",
|
667
752
|
"enum": [
|
@@ -676,6 +761,9 @@
|
|
676
761
|
"filter": {
|
677
762
|
"type": "boolean"
|
678
763
|
},
|
764
|
+
"country": {
|
765
|
+
"$ref": "#/definitions/Country"
|
766
|
+
},
|
679
767
|
"applications": {
|
680
768
|
"type": "array",
|
681
769
|
"items": {
|
@@ -1258,6 +1346,9 @@
|
|
1258
1346
|
"country": {
|
1259
1347
|
"$ref": "#/definitions/Country"
|
1260
1348
|
},
|
1349
|
+
"currency": {
|
1350
|
+
"$ref": "#/definitions/Currency"
|
1351
|
+
},
|
1261
1352
|
"user": {
|
1262
1353
|
"$ref": "#/definitions/User"
|
1263
1354
|
},
|