@gls_spain/gps-common 35.21.0 → 35.21.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [35.21.1](https://github.com/GLS-Spain/gps-common/compare/v35.21.0...v35.21.1) (2026-10-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * cambios address ([cd05621](https://github.com/GLS-Spain/gps-common/commit/cd056212a78adaa3c361541e2c6e09e480bffe66))
7
+ * delete comments ([655a5e9](https://github.com/GLS-Spain/gps-common/commit/655a5e9d5610a8725b9406190211ba6786f494d1))
8
+ * fix set.locker no admite null ([e9c4ad9](https://github.com/GLS-Spain/gps-common/commit/e9c4ad9bdf2482032a75b7ff9d9b97f99d62bc45))
9
+
1
10
  # [35.21.0](https://github.com/GLS-Spain/gps-common/compare/v35.20.0...v35.21.0) (2026-10-26)
2
11
 
3
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "35.21.0",
3
+ "version": "35.21.1",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "keywords": [
6
6
  "gls"
@@ -348,7 +348,7 @@ const setShopRepresentative = () => ({
348
348
  additionalProperties: false,
349
349
  });
350
350
 
351
- const createShopRequest = () =>
351
+ const createShopRequest =(address = shop().properties.address) =>
352
352
  createRequest({
353
353
  type: 'object',
354
354
  properties: {
@@ -381,6 +381,7 @@ const createShopRequest = () =>
381
381
  'clientCode',
382
382
  'channelingAgencyCode',
383
383
  ]),
384
+ address,
384
385
  }, // Shop
385
386
  required: ['network', 'status', 'name', 'address', 'openingSchedule', 'timezone'],
386
387
  additionalProperties: false,
@@ -478,12 +479,24 @@ const findShopsResponse = () => findResponse(shop());
478
479
  // Se usa pattern en vez de minLength porque Ajv valida minLength antes de que trim modifique el dato.
479
480
  const nonEmpty = () => ({ pattern: '\\S' });
480
481
 
482
+ // INN-1333: el backend construye street con streetType + streetName + streetNumber (varchar 255 = 50 + 183 + 20 + 2 espacios)
483
+ const salesforceAddress = baseAddress => ({
484
+ ...baseAddress,
485
+ properties: {
486
+ ...baseAddress.properties,
487
+ streetType: mergeSchemas(baseAddress.properties.streetType, nonEmpty(), { maxLength: 50 }),
488
+ streetName: mergeSchemas(baseAddress.properties.streetName, nonEmpty(), { maxLength: 183 }),
489
+ streetNumber: mergeSchemas(baseAddress.properties.streetNumber, nonEmpty(), { maxLength: 20 }),
490
+ },
491
+ required: [...baseAddress.required.filter(key => key !== 'street'), 'streetType', 'streetName', 'streetNumber'],
492
+ });
493
+
481
494
  const updateShopAddress = () =>
482
495
  mergeSchemas(addressWithRequiredLocation(), {
483
496
  properties: { street: nonEmpty(), postalCode: nonEmpty(), locality: nonEmpty(), country: nonEmpty() },
484
497
  });
485
498
 
486
- const updateShopRequest = () =>
499
+ const updateShopRequest =(address = updateShopAddress()) =>
487
500
  updateRequest(
488
501
  findById(),
489
502
  {
@@ -517,7 +530,7 @@ const updateShopRequest = () =>
517
530
  ['fiscal', 'activity', 'notes', 'derivationSettings', 'expirationSettings'],
518
531
  ),
519
532
  name: mergeSchemas(shop().properties.name, nonEmpty()),
520
- address: updateShopAddress(),
533
+ address,
521
534
  squareCode: mergeSchemas(shop().properties.squareCode, nonEmpty()),
522
535
  clientCode: mergeSchemas(shop().properties.clientCode, nonEmpty()),
523
536
  },
@@ -532,6 +545,9 @@ const updateShopRequest = () =>
532
545
  },
533
546
  );
534
547
 
548
+ const createShopSalesforceRequest = () => createShopRequest(salesforceAddress(shop().properties.address));
549
+ const updateShopSalesforceRequest = () => updateShopRequest(salesforceAddress(updateShopAddress()));
550
+
535
551
  const updateShopResponse = () => updateResponse(shop());
536
552
 
537
553
  const deleteShopRequest = () => deleteRequest(findById());
@@ -601,7 +617,7 @@ const upsertShopResponse = () => ({
601
617
  // lockerNxt() → schema del sub-objeto NXT (provider + location + features + carrier)
602
618
  // lockerNxtUpdate()→ variante de lockerNxt sin lockerId en required (para updates)
603
619
  // createLockerRequest → pickProperties(locker(), [...]) + setShopRepresentative()
604
- // updateLockerRequest → findByStringId() + pickProperties(locker(), [...]) con schemaOrNull
620
+ // updateLockerRequest → findByStringId() + set { parcelshop, locker }
605
621
  // ─────────────────────────────────────────────────────────────────────────────
606
622
 
607
623
  const locker = () => ({
@@ -797,6 +813,7 @@ const createLockerRequest = () =>
797
813
  'capacity_locker',
798
814
  'access_descript_locker',
799
815
  ]),
816
+ address: salesforceAddress(lockerAddress()),
800
817
  },
801
818
  required: [
802
819
  'network',
@@ -824,9 +841,9 @@ const createLockerResponse = () => createResponse(locker());
824
841
  // ── updateLockerRequest ───────────────────────────────────────────────────────
825
842
  // Mismo patrón que updateShopRequest:
826
843
  // - findByStringId() como find (el _id del locker es string numérico, no UUID)
827
- // - pickProperties(locker(), [...]) con schemaOrNull para el set parcial
844
+ // - set.parcelshop: pickProperties(locker(), [...]) con schemaOrNull para el set parcial
828
845
  // - setShopRepresentative() / setShopStatus() para representantes y status
829
- // - lockerNxtUpdate() para el sub-objeto hardware (lockerId no obligatorio)
846
+ // - set.locker: sub-objeto hardware NXT
830
847
 
831
848
  const updateLockerRequest = () =>
832
849
  updateRequest(
@@ -837,47 +854,54 @@ const updateLockerRequest = () =>
837
854
  {
838
855
  type: 'object',
839
856
  properties: {
840
- // relaciones y representantes con helpers reutilizados de shop
841
- network: schemaOrNull(objectWithUuid()),
842
- zone: schemaOrNull(objectWithUuid()),
843
- openingRepresentative: schemaOrNull(setShopRepresentative()),
844
- managingRepresentative: schemaOrNull(setShopRepresentative()),
845
- status: setShopStatus(),
846
-
847
- // campos actualizables del schema base locker() — todos con schemaOrNull
848
- ...Object.fromEntries(
849
- Object.entries(
850
- pickProperties(locker(), [
851
- 'name',
852
- 'address',
853
- 'openingSchedule',
854
- 'timezone',
855
- 'activity',
856
- 'eco',
857
- 'fiscal',
858
- 'nxt',
859
- 'direccion_locker',
860
- 'codpostal_locker',
861
- 'ciudad_locker',
862
- 'longitud_locker',
863
- 'latitud_locker',
864
- 'capacity_locker',
865
- 'access_descript_locker',
866
- ]),
867
- ).map(([key, schema]) => [key, schemaOrNull(schema)]),
868
- ),
869
-
870
- // capabilities: array, no nullable — va sin schemaOrNull
871
- capabilities: {
872
- type: 'array',
873
- items: { type: 'string', enum: ['deliver', 'pickup', 'sell', 'sellplus'] },
874
- uniqueItems: true,
857
+ parcelshop: {
858
+ type: 'object',
859
+ properties: {
860
+ // relaciones y representantes con helpers reutilizados de shop
861
+ network: schemaOrNull(objectWithUuid()),
862
+ zone: schemaOrNull(objectWithUuid()),
863
+ openingRepresentative: schemaOrNull(setShopRepresentative()),
864
+ managingRepresentative: schemaOrNull(setShopRepresentative()),
865
+ // updateLocker también envía status.code
866
+ status: mergeSchemas(setShopStatus(), { properties: { code: shop().properties.status.properties.code } }),
867
+
868
+ // campos actualizables del schema base locker() — todos con schemaOrNull
869
+ ...Object.fromEntries(
870
+ Object.entries(
871
+ pickProperties(locker(), [
872
+ 'name',
873
+ 'openingSchedule',
874
+ 'timezone',
875
+ 'activity',
876
+ 'eco',
877
+ 'fiscal',
878
+ 'nxt',
879
+ 'direccion_locker',
880
+ 'codpostal_locker',
881
+ 'ciudad_locker',
882
+ 'longitud_locker',
883
+ 'latitud_locker',
884
+ 'capacity_locker',
885
+ 'access_descript_locker',
886
+ ]),
887
+ ).map(([key, schema]) => [key, schemaOrNull(schema)]),
888
+ ),
889
+ address: schemaOrNull(salesforceAddress(lockerAddress())),
890
+
891
+ // capabilities: array, no nullable — va sin schemaOrNull
892
+ capabilities: {
893
+ type: 'array',
894
+ items: { type: 'string', enum: ['deliver', 'pickup', 'sell', 'sellplus'] },
895
+ uniqueItems: true,
896
+ },
897
+ },
898
+ additionalProperties: false,
875
899
  },
876
900
 
877
- // sub-objeto hardware NXT con variante update (lockerId no obligatorio)
878
- locker: schemaOrNull(lockerNxtUpdate()),
901
+ // sub-objeto hardware NXT: no se validan sus campos
902
+ locker: { type: 'object' },
879
903
  },
880
- minProperties: 0, // permite updates parciales — ningún campo es obligatorio en el set
904
+ minProperties: 0,
881
905
  additionalProperties: false,
882
906
  },
883
907
  );
@@ -985,11 +1009,13 @@ module.exports = {
985
1009
  lockerNxtUpdate,
986
1010
  objectWithShopId,
987
1011
  createShopRequest,
1012
+ createShopSalesforceRequest,
988
1013
  createShopResponse,
989
1014
  findShopsSuperAdminRequest,
990
1015
  findShopsNetworkAdminRequest,
991
1016
  findShopsResponse,
992
1017
  updateShopRequest,
1018
+ updateShopSalesforceRequest,
993
1019
  updateShopResponse,
994
1020
  deleteShopRequest,
995
1021
  deleteShopResponse,
package/schemas/index.js CHANGED
@@ -50,11 +50,13 @@ const {
50
50
  } = require('./definitions/networks');
51
51
  const {
52
52
  createShopRequest,
53
+ createShopSalesforceRequest,
53
54
  createShopResponse,
54
55
  findShopsSuperAdminRequest,
55
56
  findShopsNetworkAdminRequest,
56
57
  findShopsResponse,
57
58
  updateShopRequest,
59
+ updateShopSalesforceRequest,
58
60
  updateShopResponse,
59
61
  deleteShopRequest,
60
62
  deleteShopResponse,
@@ -201,11 +203,13 @@ const networkAdminsDeleteRequest = request(deleteNetworkAdminRequest(), 'network
201
203
  const networkAdminsDeleteResponse = response(deleteNetworkAdminResponse(), 'networkAdminsDeleteResponse');
202
204
 
203
205
  const shopsCreateRequest = request(createShopRequest(), 'shopsCreateRequest');
206
+ const shopsSalesforceCreateRequest = request(createShopSalesforceRequest(), 'shopsSalesforceCreateRequest');
204
207
  const shopsCreateResponse = response(createShopResponse(), 'shopsCreateResponse');
205
208
  const shopsFindSuperAdminRequest = request(findShopsSuperAdminRequest(), 'shopsFindSuperAdminRequest');
206
209
  const shopsFindNetworkAdminRequest = request(findShopsNetworkAdminRequest(), 'shopsFindNetworkAdminRequest');
207
210
  const shopsFindResponse = response(findShopsResponse(), 'shopsFindResponse');
208
211
  const shopsUpdateRequest = request(updateShopRequest(), 'shopsUpdateRequest');
212
+ const shopsSalesforceUpdateRequest = request(updateShopSalesforceRequest(), 'shopsSalesforceUpdateRequest');
209
213
  const shopsUpdateResponse = response(updateShopResponse(), 'shopsUpdateResponse');
210
214
  const shopsDeleteRequest = request(deleteShopRequest(), 'shopsDeleteRequest');
211
215
  const shopsDeleteResponse = response(deleteShopResponse(), 'shopsDeleteResponse');
@@ -371,11 +375,13 @@ module.exports = {
371
375
  networkAdminsDeleteResponse,
372
376
 
373
377
  shopsCreateRequest,
378
+ shopsSalesforceCreateRequest,
374
379
  shopsCreateResponse,
375
380
  shopsFindSuperAdminRequest,
376
381
  shopsFindNetworkAdminRequest,
377
382
  shopsFindResponse,
378
383
  shopsUpdateRequest,
384
+ shopsSalesforceUpdateRequest,
379
385
  shopsUpdateResponse,
380
386
  shopsDeleteRequest,
381
387
  shopsDeleteResponse,