@laboratoria/sdk-js 4.0.2 → 5.0.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/dist/laboratoria-sdk-esm.js +1 -1
- package/dist/laboratoria-sdk-umd.js +1 -1
- package/lib/core.js +115 -8
- package/package.json +4 -4
- package/schemas/core.json +4 -2
package/lib/core.js
CHANGED
@@ -3,6 +3,9 @@ import { createModels, extendSchemaDefinitions } from './model';
|
|
3
3
|
import { createClient } from './client.js';
|
4
4
|
import schema from '../schemas/core.json';
|
5
5
|
|
6
|
+
const ONE_HOUR = 60 * 60 * 1000;
|
7
|
+
const ONE_DAY = 24 * ONE_HOUR;
|
8
|
+
|
6
9
|
const extended = {
|
7
10
|
Country: {
|
8
11
|
primaryKey: 'code',
|
@@ -90,21 +93,77 @@ const extended = {
|
|
90
93
|
`${name}${!stage ? '' : ` - ${stage.name}`} (id: ${id})`
|
91
94
|
),
|
92
95
|
properties: {},
|
96
|
+
// Status:
|
97
|
+
// - `draft`: El cohort todavía no tiene fecha de inicio o fin de admisión.
|
98
|
+
// - `planned`: El cohort ya tiene fechas de inicio y fin de admisión, pero el
|
99
|
+
// período de admisiones todavía no ha comenzado.
|
100
|
+
// - `admission_started`: El periodo de admisión está abierto.
|
101
|
+
// - `admission_ended`: El período de admisión ya terminó, pero todavía no
|
102
|
+
// comienza el bootcamp.
|
103
|
+
// - `started`: El cohort está en período de bootcamp.
|
104
|
+
// - `ended`: El cohort ya terminó su bootcamp.
|
105
|
+
// - `placement_started`: El cohort se encuentra en período de placement (aka
|
106
|
+
// _placement_season_).
|
107
|
+
// - `placement_ended`: El período de placement ya terminó.
|
93
108
|
parse: (props) => {
|
94
109
|
const now = Date.now();
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
110
|
+
|
111
|
+
let status;
|
112
|
+
|
113
|
+
if (props.placementStart) {
|
114
|
+
const placementDuration = props.placementDuration || 270;
|
115
|
+
const placementEnd = new Date(
|
116
|
+
+props.placementStart
|
117
|
+
+ placementDuration * 24 * 60 * 60 * 1000
|
118
|
+
)
|
119
|
+
|
120
|
+
if (placementEnd < now) {
|
121
|
+
status = 'placement_ended';
|
122
|
+
} else if (props.placementStart < now) {
|
123
|
+
status = 'placement_started';
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
if (!status && props.end < now) {
|
128
|
+
status = 'ended';
|
129
|
+
}
|
130
|
+
|
131
|
+
if (!status && props.start < now) {
|
132
|
+
status = 'started';
|
133
|
+
}
|
134
|
+
|
135
|
+
// NOTA: La fecha de cierre de admisiones se guarda por defecto con la
|
136
|
+
// hora 00:00:00, pero semánticamente en realidad queremos expersar que
|
137
|
+
// las postulaciones están abiertas inclusive ese día, hasta las 23:59:59,
|
138
|
+
// con lo cual sumamos un día a la fecha de cierre para no excluir el
|
139
|
+
// último día.
|
140
|
+
const admissionEnd = (
|
141
|
+
props.admissionEnd
|
142
|
+
? +props.admissionEnd + ONE_DAY
|
143
|
+
: false
|
102
144
|
);
|
145
|
+
if (!status && admissionEnd && admissionEnd < now) {
|
146
|
+
status = 'admission_ended';
|
147
|
+
}
|
148
|
+
|
149
|
+
if (!status && props.admissionStart && props.admissionStart < now) {
|
150
|
+
status = 'admission_started';
|
151
|
+
}
|
152
|
+
|
153
|
+
if (!status && props.admissionStart && props.admissionEnd) {
|
154
|
+
status = 'planned';
|
155
|
+
}
|
156
|
+
|
157
|
+
if (!status) {
|
158
|
+
status = 'draft'
|
159
|
+
}
|
160
|
+
|
103
161
|
const size = (
|
104
|
-
|
162
|
+
props.start > now && props.vacancies
|
105
163
|
? props.vacancies
|
106
164
|
: props._count?.students || props.students?.length || 0
|
107
165
|
);
|
166
|
+
|
108
167
|
return {
|
109
168
|
...props,
|
110
169
|
status,
|
@@ -208,6 +267,54 @@ const extended = {
|
|
208
267
|
isRequired: false,
|
209
268
|
},
|
210
269
|
},
|
270
|
+
// Status:
|
271
|
+
// - `active`: Postulación en progreso.
|
272
|
+
// - `rejected`: Postulación rechazada por filtros (ingresos y/o educación).
|
273
|
+
// - `ready`: Retos completados y postulación _enviada_ (confirmada). Llegado a
|
274
|
+
// este estado se considera que la postulación está lista para el siguiente
|
275
|
+
// paso, por ejemplo entrevista.
|
276
|
+
// - `admission_ended`: Período de admisión del cohort seleccionado ya ha
|
277
|
+
// terminado, pero la postulación todavía no ha expirado, así que la postulante
|
278
|
+
// todavía puede continuar cambiando de cohort, siempre y cuando haya uno
|
279
|
+
// abierto dentro del período de validez de 90 días desde la creación de la
|
280
|
+
// postulación.
|
281
|
+
// - `expired`: Se pasaron los 90 días. La postulación ya no puede ser
|
282
|
+
// completada.
|
283
|
+
// - `cancelled`: La postulante canceló su propia postulación. (Todavía no
|
284
|
+
// implementado).
|
285
|
+
parse: (props) => {
|
286
|
+
const hasFailedFilters = (
|
287
|
+
typeof props.hasFailedFilters === 'boolean'
|
288
|
+
? props.hasFailedFilters
|
289
|
+
: typeof props.failedFilters?.length === 'number'
|
290
|
+
? props.failedFilters.length > 0
|
291
|
+
: undefined
|
292
|
+
);
|
293
|
+
|
294
|
+
if (!props.cohort?.admissionEnd || typeof hasFailedFilters === 'undefined') {
|
295
|
+
return props;
|
296
|
+
}
|
297
|
+
|
298
|
+
const now = Date.now();
|
299
|
+
let status;
|
300
|
+
|
301
|
+
if (props.isReady) {
|
302
|
+
status = 'ready';
|
303
|
+
} else if (hasFailedFilters && !props.bypassFilters) {
|
304
|
+
status = 'rejected';
|
305
|
+
} else if (props.createdAt < (now - 90 * ONE_DAY)) {
|
306
|
+
status = 'expired';
|
307
|
+
} else if (props.cohort?.status !== 'admission_started') {
|
308
|
+
status = 'admission_ended';
|
309
|
+
} else {
|
310
|
+
status = 'active';
|
311
|
+
}
|
312
|
+
|
313
|
+
return {
|
314
|
+
...props,
|
315
|
+
status,
|
316
|
+
};
|
317
|
+
},
|
211
318
|
},
|
212
319
|
IscedLevel: {
|
213
320
|
parse: (props) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@laboratoria/sdk-js",
|
3
|
-
"version": "
|
3
|
+
"version": "5.0.0",
|
4
4
|
"description": "Laboratoria JavaScript (browser) SDK",
|
5
5
|
"license": "MIT",
|
6
6
|
"scripts": {
|
@@ -11,7 +11,7 @@
|
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
13
|
"blueimp-md5": "^2.19.0",
|
14
|
-
"firebase": "^9.
|
14
|
+
"firebase": "^9.20.0"
|
15
15
|
},
|
16
16
|
"devDependencies": {
|
17
17
|
"@babel/core": "^7.21.4",
|
@@ -19,8 +19,8 @@
|
|
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.0.
|
22
|
+
"webpack": "^5.80.0",
|
23
|
+
"webpack-cli": "^5.0.2"
|
24
24
|
},
|
25
25
|
"jest": {
|
26
26
|
"testEnvironment": "jsdom",
|
package/schemas/core.json
CHANGED
@@ -989,7 +989,8 @@
|
|
989
989
|
"enum": [
|
990
990
|
"challenge",
|
991
991
|
"application_filter",
|
992
|
-
"application_filter_bypass"
|
992
|
+
"application_filter_bypass",
|
993
|
+
"application_cohort_change"
|
993
994
|
]
|
994
995
|
},
|
995
996
|
"data": {
|
@@ -1178,7 +1179,8 @@
|
|
1178
1179
|
"transport": {
|
1179
1180
|
"type": "string",
|
1180
1181
|
"enum": [
|
1181
|
-
"mandrill"
|
1182
|
+
"mandrill",
|
1183
|
+
"slack"
|
1182
1184
|
]
|
1183
1185
|
},
|
1184
1186
|
"status": {
|