@data-fair/lib-common-types 1.20.1 → 1.20.2

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.
@@ -7,12 +7,16 @@ export type AccessRef =
7
7
  | UnEmail
8
8
  | UneOrganisationPartenaire
9
9
  | UnRoleOuDepartementDeMonOrganisation;
10
+ export type Membre = string;
10
11
  export type AdresseMail = string;
12
+ export type Partenaire = string;
13
+ export type Departement = string;
14
+ export type Roles = string[];
11
15
 
12
16
  export type UnMembreDeLOrganisation = {
13
17
  mode: "member";
14
18
  type: "user";
15
- id: string;
19
+ id: Membre;
16
20
  }
17
21
  export type UnEmail = {
18
22
  mode: "member";
@@ -23,15 +27,15 @@ export type UneOrganisationPartenaire = {
23
27
  mode: "member";
24
28
  type: "organization";
25
29
  department?: "*";
26
- roles?: unknown[];
27
- id: string;
30
+ roles?: string[];
31
+ id: Partenaire;
28
32
  }
29
33
  export type UnRoleOuDepartementDeMonOrganisation = {
30
34
  mode: "internal";
31
35
  type: "organization";
32
36
  id: string;
33
- department?: string;
34
- roles?: string[];
37
+ department?: Departement;
38
+ roles?: Roles;
35
39
  }
36
40
 
37
41
 
@@ -1,11 +1,13 @@
1
1
  /* eslint-disable */
2
2
  // @ts-nocheck
3
3
 
4
- import equal from "ajv/dist/runtime/equal.js";
4
+ import _equal from "ajv/dist/runtime/equal.js";
5
+ const equal = _equal.default || _equal;
5
6
  "use strict";
6
7
  export const validate = validate14;
7
8
  export default validate14;
8
- const schema16 = {"$id":"https://github.com/data-fair/lib/access-ref","x-exports":["types","validate"],"title":"Access Ref","x-i18n-title":{"fr":"Référence d'accès","en":"Access Ref","es":"Referencia de acceso","it":"Riferimento di accesso","pt":"Referência de acesso","de":"Zugriffsreferenz"},"type":"object","discriminator":{"propertyName":"mode"},"oneOfLayout":{"emptyData":true},"oneOf":[{"title":"Un membre de l'organisation","x-i18n-title":{"fr":"Un membre de l'organisation","en":"An organization member","es":"Un miembro de la organización","it":"Un membro dell'organizzazione","pt":"Um membro da organização","de":"Ein Organisationsmitglied"},"layout":{"if":"context.owner.type === 'organization'"},"required":["mode","type","id"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"member"},"type":{"type":"string","const":"user"},"id":{"type":"string","layout":{"getItems":{"url":"/simple-directory/api/organization/${context.owner.id}/members","itemsResults":"data.results","itemTitle":"item.name","itemValue":"item.id","itemIcon":"`/simple-directory/api/avatars/user/${item.id}/avatar.png`"}}}}},{"title":"Un email","x-i18n-title":{"fr":"Un email","en":"An email","es":"Un correo electrónico","it":"Un'email","pt":"Um email","de":"Eine E-Mail"},"required":["mode","type","email"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"member"},"type":{"type":"string","const":"user"},"email":{"type":"string","title":"Adresse mail","x-i18n-title":{"fr":"Adresse mail","en":"Email address","es":"Dirección de correo","it":"Indirizzo email","pt":"Endereço de email","de":"E-Mail-Adresse"}}}},{"title":"Une organisation partenaire","x-i18n-title":{"fr":"Une organisation partenaire","en":"A partner organization","es":"Una organización asociada","it":"Un'organizzazione partner","pt":"Uma organização parceira","de":"Eine Partnerorganisation"},"layout":{"if":"context.owner.type === 'organization'"},"required":["mode","type","id"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"member"},"type":{"type":"string","const":"organization"},"department":{"type":"string","const":"*"},"roles":{"type":"array","const":[]},"id":{"type":"string","layout":{"getItems":{"url":"/simple-directory/api/organization/${context.owner.id}/partners","itemsResults":"data.results","itemTitle":"item.name","itemValue":"item.id","itemIcon":"`/simple-directory/api/avatars/organization/${item.id}/avatar.png`"}}}}},{"title":"Un role ou département de mon organisation","x-i18n-title":{"fr":"Un rôle ou département de mon organisation","en":"A role or department of my organization","es":"Un rol o departamento de mi organización","it":"Un ruolo o dipartimento della mia organizzazione","pt":"Um papel ou departamento da minha organização","de":"Eine Rolle oder Abteilung meiner Organisation"},"layout":{"if":"context.owner.type === 'organization'"},"required":["mode","type","id"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"internal"},"type":{"type":"string","const":"organization"},"id":{"type":"string"},"department":{"type":"string","layout":{"getItems":{"url":"/simple-directory/api/organization/${context.owner.id}/departments","itemsResults":"[...data.results, {id: \"*\", name: \"Tous les départements\"}, {id: \"-\", name: \"Racine de l'organisation uniquement\"}]","itemTitle":"item.name","itemValue":"item.id"}}},"roles":{"type":"array","items":{"type":"string"},"layout":{"getItems":{"url":"/simple-directory/api/organization/${context.owner.id}/roles","itemsResults":"data.results","itemTitle":"item.name","itemValue":"item.id"}}}}}]};
9
+ const schema16 = {"$id":"https://github.com/data-fair/lib/access-ref","x-exports":["types","validate"],"title":"Access Ref","x-i18n-title":{"fr":"Référence d'accès","en":"Access Ref","es":"Referencia de acceso","it":"Riferimento di accesso","pt":"Referência de acesso","de":"Zugriffsreferenz"},"type":"object","discriminator":{"propertyName":"mode"},"oneOfLayout":{"emptyData":true},"oneOf":[{"title":"Un membre de l'organisation","x-i18n-title":{"fr":"Un membre de l'organisation","en":"An organization member","es":"Un miembro de la organización","it":"Un membro dell'organizzazione","pt":"Um membro da organização","de":"Ein Organisationsmitglied"},"layout":{"if":"context.owner.type === 'organization'"},"required":["mode","type","id"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"member"},"type":{"type":"string","const":"user"},"id":{"type":"string","title":"Membre","x-i18n-title":{"fr":"Membre","en":"Member","es":"Miembro","it":"Membro","pt":"Membro","de":"Mitglied"},"layout":{"getItems":{"url":"/simple-directory/api/organizations/${context.owner.id}/members","itemsResults":"data.results","itemTitle":"item.name","itemValue":"item.id","itemIcon":"`/simple-directory/api/avatars/user/${item.id}/avatar.png`"}}}}},{"title":"Un email","x-i18n-title":{"fr":"Un email","en":"An email","es":"Un correo electrónico","it":"Un'email","pt":"Um email","de":"Eine E-Mail"},"required":["mode","type","email"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"member"},"type":{"type":"string","const":"user"},"email":{"type":"string","format":"email","title":"Adresse mail","x-i18n-title":{"fr":"Adresse mail","en":"Email address","es":"Dirección de correo","it":"Indirizzo email","pt":"Endereço de email","de":"E-Mail-Adresse"}}}},{"title":"Une organisation partenaire","x-i18n-title":{"fr":"Une organisation partenaire","en":"A partner organization","es":"Una organización asociada","it":"Un'organizzazione partner","pt":"Uma organização parceira","de":"Eine Partnerorganisation"},"layout":{"if":"context.owner.type === 'organization'"},"required":["mode","type","id"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"member"},"type":{"type":"string","const":"organization"},"department":{"type":"string","const":"*"},"roles":{"type":"array","const":[],"items":{"type":"string"}},"id":{"type":"string","title":"Partenaire","x-i18n-title":{"fr":"Partenaire","en":"Partner","es":"Socio","it":"Partner","pt":"Parceiro","de":"Partner"},"layout":{"getItems":{"url":"/simple-directory/api/organizations/${context.owner.id}","itemsResults":"data.partners","itemTitle":"item.name","itemValue":"item.id","itemIcon":"`/simple-directory/api/avatars/organization/${item.id}/avatar.png`"}}}}},{"title":"Un role ou département de mon organisation","x-i18n-title":{"fr":"Un rôle ou département de mon organisation","en":"A role or department of my organization","es":"Un rol o departamento de mi organización","it":"Un ruolo o dipartimento della mia organizzazione","pt":"Um papel ou departamento da minha organização","de":"Eine Rolle oder Abteilung meiner Organisation"},"layout":{"if":"context.owner.type === 'organization'"},"required":["mode","type","id"],"additionalProperties":false,"properties":{"mode":{"type":"string","const":"internal"},"type":{"type":"string","const":"organization"},"id":{"type":"string","layout":{"comp":"none","getConstData":"context.owner.id"}},"department":{"type":"string","title":"Département","x-i18n-title":{"fr":"Département","en":"Department","es":"Departamento","it":"Dipartimento","pt":"Departamento","de":"Abteilung"},"layout":{"getItems":{"url":"/simple-directory/api/organizations/${context.owner.id}","itemsResults":"[...(data.departments || []), {id: \"*\", name: \"Tous les départements\"}, {id: \"-\", name: \"Racine de l'organisation uniquement\"}]","itemTitle":"item.name","itemValue":"item.id"}}},"roles":{"type":"array","title":"Rôles","x-i18n-title":{"fr":"Rôles","en":"Roles","es":"Roles","it":"Ruoli","pt":"Funções","de":"Rollen"},"items":{"type":"string"},"layout":{"getItems":{"url":"/simple-directory/api/organizations/${context.owner.id}","itemsResults":"data.roles"}}}}}]};
10
+ 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;
9
11
  const func0 = equal;
10
12
 
11
13
  function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){
@@ -224,8 +226,10 @@ errors++;
224
226
  }
225
227
  }
226
228
  if(data.email !== undefined){
227
- if(typeof data.email !== "string"){
228
- const err18 = {instancePath:instancePath+"/email",schemaPath:"#/oneOf/1/properties/email/type",keyword:"type",params:{type: "string"},message:"must be string"};
229
+ let data5 = data.email;
230
+ if(typeof data5 === "string"){
231
+ if(!(formats0.test(data5))){
232
+ const err18 = {instancePath:instancePath+"/email",schemaPath:"#/oneOf/1/properties/email/format",keyword:"format",params:{format: "email"},message:"must match format \""+"email"+"\""};
229
233
  if(vErrors === null){
230
234
  vErrors = [err18];
231
235
  }
@@ -235,6 +239,17 @@ vErrors.push(err18);
235
239
  errors++;
236
240
  }
237
241
  }
242
+ else {
243
+ const err19 = {instancePath:instancePath+"/email",schemaPath:"#/oneOf/1/properties/email/type",keyword:"type",params:{type: "string"},message:"must be string"};
244
+ if(vErrors === null){
245
+ vErrors = [err19];
246
+ }
247
+ else {
248
+ vErrors.push(err19);
249
+ }
250
+ errors++;
251
+ }
252
+ }
238
253
  }
239
254
  var _valid0 = _errs10 === errors;
240
255
  if(_valid0 && valid0){
@@ -249,43 +264,43 @@ passing0 = 1;
249
264
  const _errs18 = errors;
250
265
  if(data && typeof data == "object" && !Array.isArray(data)){
251
266
  if(data.mode === undefined){
252
- const err19 = {instancePath,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty: "mode"},message:"must have required property '"+"mode"+"'"};
267
+ const err20 = {instancePath,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty: "mode"},message:"must have required property '"+"mode"+"'"};
253
268
  if(vErrors === null){
254
- vErrors = [err19];
269
+ vErrors = [err20];
255
270
  }
256
271
  else {
257
- vErrors.push(err19);
272
+ vErrors.push(err20);
258
273
  }
259
274
  errors++;
260
275
  }
261
276
  if(data.type === undefined){
262
- const err20 = {instancePath,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};
277
+ const err21 = {instancePath,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};
263
278
  if(vErrors === null){
264
- vErrors = [err20];
279
+ vErrors = [err21];
265
280
  }
266
281
  else {
267
- vErrors.push(err20);
282
+ vErrors.push(err21);
268
283
  }
269
284
  errors++;
270
285
  }
271
286
  if(data.id === undefined){
272
- const err21 = {instancePath,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
287
+ const err22 = {instancePath,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
273
288
  if(vErrors === null){
274
- vErrors = [err21];
289
+ vErrors = [err22];
275
290
  }
276
291
  else {
277
- vErrors.push(err21);
292
+ vErrors.push(err22);
278
293
  }
279
294
  errors++;
280
295
  }
281
296
  for(const key2 in data){
282
297
  if(!(((((key2 === "mode") || (key2 === "type")) || (key2 === "department")) || (key2 === "roles")) || (key2 === "id"))){
283
- const err22 = {instancePath,schemaPath:"#/oneOf/2/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};
298
+ const err23 = {instancePath,schemaPath:"#/oneOf/2/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};
284
299
  if(vErrors === null){
285
- vErrors = [err22];
300
+ vErrors = [err23];
286
301
  }
287
302
  else {
288
- vErrors.push(err22);
303
+ vErrors.push(err23);
289
304
  }
290
305
  errors++;
291
306
  }
@@ -293,22 +308,22 @@ errors++;
293
308
  if(data.mode !== undefined){
294
309
  let data6 = data.mode;
295
310
  if(typeof data6 !== "string"){
296
- const err23 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/2/properties/mode/type",keyword:"type",params:{type: "string"},message:"must be string"};
311
+ const err24 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/2/properties/mode/type",keyword:"type",params:{type: "string"},message:"must be string"};
297
312
  if(vErrors === null){
298
- vErrors = [err23];
313
+ vErrors = [err24];
299
314
  }
300
315
  else {
301
- vErrors.push(err23);
316
+ vErrors.push(err24);
302
317
  }
303
318
  errors++;
304
319
  }
305
320
  if("member" !== data6){
306
- const err24 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/2/properties/mode/const",keyword:"const",params:{allowedValue: "member"},message:"must be equal to constant"};
321
+ const err25 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/2/properties/mode/const",keyword:"const",params:{allowedValue: "member"},message:"must be equal to constant"};
307
322
  if(vErrors === null){
308
- vErrors = [err24];
323
+ vErrors = [err25];
309
324
  }
310
325
  else {
311
- vErrors.push(err24);
326
+ vErrors.push(err25);
312
327
  }
313
328
  errors++;
314
329
  }
@@ -316,22 +331,22 @@ errors++;
316
331
  if(data.type !== undefined){
317
332
  let data7 = data.type;
318
333
  if(typeof data7 !== "string"){
319
- const err25 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/2/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"};
334
+ const err26 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/2/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"};
320
335
  if(vErrors === null){
321
- vErrors = [err25];
336
+ vErrors = [err26];
322
337
  }
323
338
  else {
324
- vErrors.push(err25);
339
+ vErrors.push(err26);
325
340
  }
326
341
  errors++;
327
342
  }
328
343
  if("organization" !== data7){
329
- const err26 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/2/properties/type/const",keyword:"const",params:{allowedValue: "organization"},message:"must be equal to constant"};
344
+ const err27 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/2/properties/type/const",keyword:"const",params:{allowedValue: "organization"},message:"must be equal to constant"};
330
345
  if(vErrors === null){
331
- vErrors = [err26];
346
+ vErrors = [err27];
332
347
  }
333
348
  else {
334
- vErrors.push(err26);
349
+ vErrors.push(err27);
335
350
  }
336
351
  errors++;
337
352
  }
@@ -339,57 +354,72 @@ errors++;
339
354
  if(data.department !== undefined){
340
355
  let data8 = data.department;
341
356
  if(typeof data8 !== "string"){
342
- const err27 = {instancePath:instancePath+"/department",schemaPath:"#/oneOf/2/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
357
+ const err28 = {instancePath:instancePath+"/department",schemaPath:"#/oneOf/2/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
343
358
  if(vErrors === null){
344
- vErrors = [err27];
359
+ vErrors = [err28];
345
360
  }
346
361
  else {
347
- vErrors.push(err27);
362
+ vErrors.push(err28);
348
363
  }
349
364
  errors++;
350
365
  }
351
366
  if("*" !== data8){
352
- const err28 = {instancePath:instancePath+"/department",schemaPath:"#/oneOf/2/properties/department/const",keyword:"const",params:{allowedValue: "*"},message:"must be equal to constant"};
367
+ const err29 = {instancePath:instancePath+"/department",schemaPath:"#/oneOf/2/properties/department/const",keyword:"const",params:{allowedValue: "*"},message:"must be equal to constant"};
353
368
  if(vErrors === null){
354
- vErrors = [err28];
369
+ vErrors = [err29];
355
370
  }
356
371
  else {
357
- vErrors.push(err28);
372
+ vErrors.push(err29);
358
373
  }
359
374
  errors++;
360
375
  }
361
376
  }
362
377
  if(data.roles !== undefined){
363
378
  let data9 = data.roles;
364
- if(!(Array.isArray(data9))){
365
- const err29 = {instancePath:instancePath+"/roles",schemaPath:"#/oneOf/2/properties/roles/type",keyword:"type",params:{type: "array"},message:"must be array"};
379
+ if(!func0(data9, schema16.oneOf[2].properties.roles.const)){
380
+ const err30 = {instancePath:instancePath+"/roles",schemaPath:"#/oneOf/2/properties/roles/const",keyword:"const",params:{allowedValue: schema16.oneOf[2].properties.roles.const},message:"must be equal to constant"};
366
381
  if(vErrors === null){
367
- vErrors = [err29];
382
+ vErrors = [err30];
368
383
  }
369
384
  else {
370
- vErrors.push(err29);
385
+ vErrors.push(err30);
371
386
  }
372
387
  errors++;
373
388
  }
374
- if(!func0(data9, schema16.oneOf[2].properties.roles.const)){
375
- const err30 = {instancePath:instancePath+"/roles",schemaPath:"#/oneOf/2/properties/roles/const",keyword:"const",params:{allowedValue: schema16.oneOf[2].properties.roles.const},message:"must be equal to constant"};
389
+ if(Array.isArray(data9)){
390
+ const len0 = data9.length;
391
+ for(let i0=0; i0<len0; i0++){
392
+ if(typeof data9[i0] !== "string"){
393
+ const err31 = {instancePath:instancePath+"/roles/" + i0,schemaPath:"#/oneOf/2/properties/roles/items/type",keyword:"type",params:{type: "string"},message:"must be string"};
376
394
  if(vErrors === null){
377
- vErrors = [err30];
395
+ vErrors = [err31];
378
396
  }
379
397
  else {
380
- vErrors.push(err30);
398
+ vErrors.push(err31);
399
+ }
400
+ errors++;
401
+ }
402
+ }
403
+ }
404
+ else {
405
+ const err32 = {instancePath:instancePath+"/roles",schemaPath:"#/oneOf/2/properties/roles/type",keyword:"type",params:{type: "array"},message:"must be array"};
406
+ if(vErrors === null){
407
+ vErrors = [err32];
408
+ }
409
+ else {
410
+ vErrors.push(err32);
381
411
  }
382
412
  errors++;
383
413
  }
384
414
  }
385
415
  if(data.id !== undefined){
386
416
  if(typeof data.id !== "string"){
387
- const err31 = {instancePath:instancePath+"/id",schemaPath:"#/oneOf/2/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
417
+ const err33 = {instancePath:instancePath+"/id",schemaPath:"#/oneOf/2/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
388
418
  if(vErrors === null){
389
- vErrors = [err31];
419
+ vErrors = [err33];
390
420
  }
391
421
  else {
392
- vErrors.push(err31);
422
+ vErrors.push(err33);
393
423
  }
394
424
  errors++;
395
425
  }
@@ -405,150 +435,150 @@ if(_valid0){
405
435
  valid0 = true;
406
436
  passing0 = 2;
407
437
  }
408
- const _errs30 = errors;
438
+ const _errs32 = errors;
409
439
  if(data && typeof data == "object" && !Array.isArray(data)){
410
440
  if(data.mode === undefined){
411
- const err32 = {instancePath,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty: "mode"},message:"must have required property '"+"mode"+"'"};
441
+ const err34 = {instancePath,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty: "mode"},message:"must have required property '"+"mode"+"'"};
412
442
  if(vErrors === null){
413
- vErrors = [err32];
443
+ vErrors = [err34];
414
444
  }
415
445
  else {
416
- vErrors.push(err32);
446
+ vErrors.push(err34);
417
447
  }
418
448
  errors++;
419
449
  }
420
450
  if(data.type === undefined){
421
- const err33 = {instancePath,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};
451
+ const err35 = {instancePath,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};
422
452
  if(vErrors === null){
423
- vErrors = [err33];
453
+ vErrors = [err35];
424
454
  }
425
455
  else {
426
- vErrors.push(err33);
456
+ vErrors.push(err35);
427
457
  }
428
458
  errors++;
429
459
  }
430
460
  if(data.id === undefined){
431
- const err34 = {instancePath,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
461
+ const err36 = {instancePath,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};
432
462
  if(vErrors === null){
433
- vErrors = [err34];
463
+ vErrors = [err36];
434
464
  }
435
465
  else {
436
- vErrors.push(err34);
466
+ vErrors.push(err36);
437
467
  }
438
468
  errors++;
439
469
  }
440
470
  for(const key3 in data){
441
471
  if(!(((((key3 === "mode") || (key3 === "type")) || (key3 === "id")) || (key3 === "department")) || (key3 === "roles"))){
442
- const err35 = {instancePath,schemaPath:"#/oneOf/3/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};
472
+ const err37 = {instancePath,schemaPath:"#/oneOf/3/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};
443
473
  if(vErrors === null){
444
- vErrors = [err35];
474
+ vErrors = [err37];
445
475
  }
446
476
  else {
447
- vErrors.push(err35);
477
+ vErrors.push(err37);
448
478
  }
449
479
  errors++;
450
480
  }
451
481
  }
452
482
  if(data.mode !== undefined){
453
- let data11 = data.mode;
454
- if(typeof data11 !== "string"){
455
- const err36 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/3/properties/mode/type",keyword:"type",params:{type: "string"},message:"must be string"};
483
+ let data12 = data.mode;
484
+ if(typeof data12 !== "string"){
485
+ const err38 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/3/properties/mode/type",keyword:"type",params:{type: "string"},message:"must be string"};
456
486
  if(vErrors === null){
457
- vErrors = [err36];
487
+ vErrors = [err38];
458
488
  }
459
489
  else {
460
- vErrors.push(err36);
490
+ vErrors.push(err38);
461
491
  }
462
492
  errors++;
463
493
  }
464
- if("internal" !== data11){
465
- const err37 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/3/properties/mode/const",keyword:"const",params:{allowedValue: "internal"},message:"must be equal to constant"};
494
+ if("internal" !== data12){
495
+ const err39 = {instancePath:instancePath+"/mode",schemaPath:"#/oneOf/3/properties/mode/const",keyword:"const",params:{allowedValue: "internal"},message:"must be equal to constant"};
466
496
  if(vErrors === null){
467
- vErrors = [err37];
497
+ vErrors = [err39];
468
498
  }
469
499
  else {
470
- vErrors.push(err37);
500
+ vErrors.push(err39);
471
501
  }
472
502
  errors++;
473
503
  }
474
504
  }
475
505
  if(data.type !== undefined){
476
- let data12 = data.type;
477
- if(typeof data12 !== "string"){
478
- const err38 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/3/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"};
506
+ let data13 = data.type;
507
+ if(typeof data13 !== "string"){
508
+ const err40 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/3/properties/type/type",keyword:"type",params:{type: "string"},message:"must be string"};
479
509
  if(vErrors === null){
480
- vErrors = [err38];
510
+ vErrors = [err40];
481
511
  }
482
512
  else {
483
- vErrors.push(err38);
513
+ vErrors.push(err40);
484
514
  }
485
515
  errors++;
486
516
  }
487
- if("organization" !== data12){
488
- const err39 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/3/properties/type/const",keyword:"const",params:{allowedValue: "organization"},message:"must be equal to constant"};
517
+ if("organization" !== data13){
518
+ const err41 = {instancePath:instancePath+"/type",schemaPath:"#/oneOf/3/properties/type/const",keyword:"const",params:{allowedValue: "organization"},message:"must be equal to constant"};
489
519
  if(vErrors === null){
490
- vErrors = [err39];
520
+ vErrors = [err41];
491
521
  }
492
522
  else {
493
- vErrors.push(err39);
523
+ vErrors.push(err41);
494
524
  }
495
525
  errors++;
496
526
  }
497
527
  }
498
528
  if(data.id !== undefined){
499
529
  if(typeof data.id !== "string"){
500
- const err40 = {instancePath:instancePath+"/id",schemaPath:"#/oneOf/3/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
530
+ const err42 = {instancePath:instancePath+"/id",schemaPath:"#/oneOf/3/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};
501
531
  if(vErrors === null){
502
- vErrors = [err40];
532
+ vErrors = [err42];
503
533
  }
504
534
  else {
505
- vErrors.push(err40);
535
+ vErrors.push(err42);
506
536
  }
507
537
  errors++;
508
538
  }
509
539
  }
510
540
  if(data.department !== undefined){
511
541
  if(typeof data.department !== "string"){
512
- const err41 = {instancePath:instancePath+"/department",schemaPath:"#/oneOf/3/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
542
+ const err43 = {instancePath:instancePath+"/department",schemaPath:"#/oneOf/3/properties/department/type",keyword:"type",params:{type: "string"},message:"must be string"};
513
543
  if(vErrors === null){
514
- vErrors = [err41];
544
+ vErrors = [err43];
515
545
  }
516
546
  else {
517
- vErrors.push(err41);
547
+ vErrors.push(err43);
518
548
  }
519
549
  errors++;
520
550
  }
521
551
  }
522
552
  if(data.roles !== undefined){
523
- let data15 = data.roles;
524
- if(Array.isArray(data15)){
525
- const len0 = data15.length;
526
- for(let i0=0; i0<len0; i0++){
527
- if(typeof data15[i0] !== "string"){
528
- const err42 = {instancePath:instancePath+"/roles/" + i0,schemaPath:"#/oneOf/3/properties/roles/items/type",keyword:"type",params:{type: "string"},message:"must be string"};
553
+ let data16 = data.roles;
554
+ if(Array.isArray(data16)){
555
+ const len1 = data16.length;
556
+ for(let i1=0; i1<len1; i1++){
557
+ if(typeof data16[i1] !== "string"){
558
+ const err44 = {instancePath:instancePath+"/roles/" + i1,schemaPath:"#/oneOf/3/properties/roles/items/type",keyword:"type",params:{type: "string"},message:"must be string"};
529
559
  if(vErrors === null){
530
- vErrors = [err42];
560
+ vErrors = [err44];
531
561
  }
532
562
  else {
533
- vErrors.push(err42);
563
+ vErrors.push(err44);
534
564
  }
535
565
  errors++;
536
566
  }
537
567
  }
538
568
  }
539
569
  else {
540
- const err43 = {instancePath:instancePath+"/roles",schemaPath:"#/oneOf/3/properties/roles/type",keyword:"type",params:{type: "array"},message:"must be array"};
570
+ const err45 = {instancePath:instancePath+"/roles",schemaPath:"#/oneOf/3/properties/roles/type",keyword:"type",params:{type: "array"},message:"must be array"};
541
571
  if(vErrors === null){
542
- vErrors = [err43];
572
+ vErrors = [err45];
543
573
  }
544
574
  else {
545
- vErrors.push(err43);
575
+ vErrors.push(err45);
546
576
  }
547
577
  errors++;
548
578
  }
549
579
  }
550
580
  }
551
- var _valid0 = _errs30 === errors;
581
+ var _valid0 = _errs32 === errors;
552
582
  if(_valid0 && valid0){
553
583
  valid0 = false;
554
584
  passing0 = [passing0, 3];
@@ -562,12 +592,12 @@ passing0 = 3;
562
592
  }
563
593
  }
564
594
  if(!valid0){
565
- const err44 = {instancePath,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};
595
+ const err46 = {instancePath,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};
566
596
  if(vErrors === null){
567
- vErrors = [err44];
597
+ vErrors = [err46];
568
598
  }
569
599
  else {
570
- vErrors.push(err44);
600
+ vErrors.push(err46);
571
601
  }
572
602
  errors++;
573
603
  }
@@ -46,18 +46,17 @@ export const mongoFilterAccessRef = (session) => {
46
46
  };
47
47
  if (session.account.type === 'user')
48
48
  return userFilter;
49
+ const departmentCondition = session.account.department
50
+ ? { $or: [{ 'access.department': { $exists: false } }, { 'access.department': { $in: ['*', session.account.department] } }] }
51
+ : { $or: [{ 'access.department': { $exists: false } }, { 'access.department': { $in: ['-', '*'] } }] };
49
52
  const baseOrgFilter = {
50
- 'access.type': 'organization',
51
- 'access.id': session.account.id,
52
- $or: [
53
- { 'access.roles': { $size: 0 } },
54
- { 'access.roles': { $in: [session.accountRole] } }
53
+ $and: [
54
+ { 'access.type': 'organization' },
55
+ { 'access.id': session.account.id },
56
+ { $or: [{ 'access.roles': { $exists: false } }, { 'access.roles': { $size: 0 } }, { 'access.roles': { $in: [session.accountRole] } }] },
57
+ departmentCondition
55
58
  ]
56
59
  };
57
- if (session.account.department)
58
- baseOrgFilter['access.department'] = { $in: ['*', session.account.department] };
59
- else
60
- baseOrgFilter['access.department'] = { $in: ['-', '*'] };
61
60
  userFilter.$or.push(baseOrgFilter);
62
61
  return userFilter;
63
62
  };
@@ -43,6 +43,15 @@ declare const _default: {
43
43
  };
44
44
  id: {
45
45
  type: string;
46
+ title: string;
47
+ 'x-i18n-title': {
48
+ fr: string;
49
+ en: string;
50
+ es: string;
51
+ it: string;
52
+ pt: string;
53
+ de: string;
54
+ };
46
55
  layout: {
47
56
  getItems: {
48
57
  url: string;
@@ -51,6 +60,8 @@ declare const _default: {
51
60
  itemValue: string;
52
61
  itemIcon: string;
53
62
  };
63
+ comp?: undefined;
64
+ getConstData?: undefined;
54
65
  };
55
66
  };
56
67
  email?: undefined;
@@ -80,6 +91,7 @@ declare const _default: {
80
91
  };
81
92
  email: {
82
93
  type: string;
94
+ format: string;
83
95
  title: string;
84
96
  'x-i18n-title': {
85
97
  fr: string;
@@ -122,16 +134,31 @@ declare const _default: {
122
134
  department: {
123
135
  type: string;
124
136
  const: string;
137
+ title?: undefined;
138
+ 'x-i18n-title'?: undefined;
125
139
  layout?: undefined;
126
140
  };
127
141
  roles: {
128
142
  type: string;
129
143
  const: never[];
130
- items?: undefined;
144
+ items: {
145
+ type: string;
146
+ };
147
+ title?: undefined;
148
+ 'x-i18n-title'?: undefined;
131
149
  layout?: undefined;
132
150
  };
133
151
  id: {
134
152
  type: string;
153
+ title: string;
154
+ 'x-i18n-title': {
155
+ fr: string;
156
+ en: string;
157
+ es: string;
158
+ it: string;
159
+ pt: string;
160
+ de: string;
161
+ };
135
162
  layout: {
136
163
  getItems: {
137
164
  url: string;
@@ -140,6 +167,8 @@ declare const _default: {
140
167
  itemValue: string;
141
168
  itemIcon: string;
142
169
  };
170
+ comp?: undefined;
171
+ getConstData?: undefined;
143
172
  };
144
173
  };
145
174
  email?: undefined;
@@ -170,10 +199,25 @@ declare const _default: {
170
199
  };
171
200
  id: {
172
201
  type: string;
173
- layout?: undefined;
202
+ layout: {
203
+ comp: string;
204
+ getConstData: string;
205
+ getItems?: undefined;
206
+ };
207
+ title?: undefined;
208
+ 'x-i18n-title'?: undefined;
174
209
  };
175
210
  department: {
176
211
  type: string;
212
+ title: string;
213
+ 'x-i18n-title': {
214
+ fr: string;
215
+ en: string;
216
+ es: string;
217
+ it: string;
218
+ pt: string;
219
+ de: string;
220
+ };
177
221
  layout: {
178
222
  getItems: {
179
223
  url: string;
@@ -186,6 +230,15 @@ declare const _default: {
186
230
  };
187
231
  roles: {
188
232
  type: string;
233
+ title: string;
234
+ 'x-i18n-title': {
235
+ fr: string;
236
+ en: string;
237
+ es: string;
238
+ it: string;
239
+ pt: string;
240
+ de: string;
241
+ };
189
242
  items: {
190
243
  type: string;
191
244
  };
@@ -193,8 +246,6 @@ declare const _default: {
193
246
  getItems: {
194
247
  url: string;
195
248
  itemsResults: string;
196
- itemTitle: string;
197
- itemValue: string;
198
249
  };
199
250
  };
200
251
  const?: undefined;
@@ -37,9 +37,18 @@ export default {
37
37
  type: { type: 'string', const: 'user' },
38
38
  id: {
39
39
  type: 'string',
40
+ title: 'Membre',
41
+ 'x-i18n-title': {
42
+ fr: 'Membre',
43
+ en: 'Member',
44
+ es: 'Miembro',
45
+ it: 'Membro',
46
+ pt: 'Membro',
47
+ de: 'Mitglied'
48
+ },
40
49
  layout: {
41
50
  getItems: {
42
- url: '/simple-directory/api/organization/${context.owner.id}/members',
51
+ url: '/simple-directory/api/organizations/${context.owner.id}/members',
43
52
  itemsResults: 'data.results',
44
53
  itemTitle: 'item.name',
45
54
  itemValue: 'item.id',
@@ -66,6 +75,7 @@ export default {
66
75
  type: { type: 'string', const: 'user' },
67
76
  email: {
68
77
  type: 'string',
78
+ format: 'email',
69
79
  title: 'Adresse mail',
70
80
  'x-i18n-title': {
71
81
  fr: 'Adresse mail',
@@ -95,13 +105,22 @@ export default {
95
105
  mode: { type: 'string', const: 'member' },
96
106
  type: { type: 'string', const: 'organization' },
97
107
  department: { type: 'string', const: '*' },
98
- roles: { type: 'array', const: [] },
108
+ roles: { type: 'array', const: [], items: { type: 'string' } },
99
109
  id: {
100
110
  type: 'string',
111
+ title: 'Partenaire',
112
+ 'x-i18n-title': {
113
+ fr: 'Partenaire',
114
+ en: 'Partner',
115
+ es: 'Socio',
116
+ it: 'Partner',
117
+ pt: 'Parceiro',
118
+ de: 'Partner'
119
+ },
101
120
  layout: {
102
121
  getItems: {
103
- url: '/simple-directory/api/organization/${context.owner.id}/partners',
104
- itemsResults: 'data.results',
122
+ url: '/simple-directory/api/organizations/${context.owner.id}',
123
+ itemsResults: 'data.partners',
105
124
  itemTitle: 'item.name',
106
125
  itemValue: 'item.id',
107
126
  itemIcon: '`/simple-directory/api/avatars/organization/${item.id}/avatar.png`'
@@ -126,13 +145,28 @@ export default {
126
145
  properties: {
127
146
  mode: { type: 'string', const: 'internal' },
128
147
  type: { type: 'string', const: 'organization' },
129
- id: { type: 'string' },
148
+ id: {
149
+ type: 'string',
150
+ layout: {
151
+ comp: 'none',
152
+ getConstData: 'context.owner.id'
153
+ }
154
+ },
130
155
  department: {
131
156
  type: 'string',
157
+ title: 'Département',
158
+ 'x-i18n-title': {
159
+ fr: 'Département',
160
+ en: 'Department',
161
+ es: 'Departamento',
162
+ it: 'Dipartimento',
163
+ pt: 'Departamento',
164
+ de: 'Abteilung'
165
+ },
132
166
  layout: {
133
167
  getItems: {
134
- url: '/simple-directory/api/organization/${context.owner.id}/departments',
135
- itemsResults: '[...data.results, {id: "*", name: "Tous les départements"}, {id: "-", name: "Racine de l\'organisation uniquement"}]',
168
+ url: '/simple-directory/api/organizations/${context.owner.id}',
169
+ itemsResults: '[...(data.departments || []), {id: "*", name: "Tous les départements"}, {id: "-", name: "Racine de l\'organisation uniquement"}]',
136
170
  itemTitle: 'item.name',
137
171
  itemValue: 'item.id'
138
172
  }
@@ -140,15 +174,22 @@ export default {
140
174
  },
141
175
  roles: {
142
176
  type: 'array',
177
+ title: 'Rôles',
178
+ 'x-i18n-title': {
179
+ fr: 'Rôles',
180
+ en: 'Roles',
181
+ es: 'Roles',
182
+ it: 'Ruoli',
183
+ pt: 'Funções',
184
+ de: 'Rollen'
185
+ },
143
186
  items: {
144
187
  type: 'string'
145
188
  },
146
189
  layout: {
147
190
  getItems: {
148
- url: '/simple-directory/api/organization/${context.owner.id}/roles',
149
- itemsResults: 'data.results',
150
- itemTitle: 'item.name',
151
- itemValue: 'item.id'
191
+ url: '/simple-directory/api/organizations/${context.owner.id}',
192
+ itemsResults: 'data.roles'
152
193
  }
153
194
  }
154
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-common-types",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "description": "Shared schemas and built type definitions in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "scripts": {