@gls_spain/gps-common 35.19.4 → 35.21.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/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # [35.21.0](https://github.com/GLS-Spain/gps-common/compare/v35.20.0...v35.21.0) (2026-10-26)
2
+
3
+
4
+ ### Features
5
+
6
+ * esquemas de funciones de tienda y operaciones masivas ([10e9c96](https://github.com/GLS-Spain/gps-common/commit/10e9c9650f97dd7cb92487bd1e9af58e56266470))
7
+
8
+ # [35.20.0](https://github.com/GLS-Spain/gps-common/compare/v35.19.4...v35.20.0) (2026-10-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * network & shops updated schemas ([73ecb9e](https://github.com/GLS-Spain/gps-common/commit/73ecb9ed5c6c998a93763599507db3368beb68a8))
14
+
15
+
16
+ ### Features
17
+
18
+ * shop.channeling ([f15c86b](https://github.com/GLS-Spain/gps-common/commit/f15c86b6c8c8c7685cbc0898ce8d48105ec1c034))
19
+
1
20
  ## [35.19.4](https://github.com/GLS-Spain/gps-common/compare/v35.19.3...v35.19.4) (2026-10-19)
2
21
 
3
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "35.19.4",
3
+ "version": "35.21.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "keywords": [
6
6
  "gls"
@@ -15,6 +15,10 @@ const {
15
15
  const { findAll, findById, findByName, objectWithUuidAndName, contact, fiscal, networkType } = require('./common');
16
16
  const { defaults, derivationSettings, expirationSettings } = require('./defaults');
17
17
 
18
+ function parseAddressType() {
19
+ return ['auto'];
20
+ }
21
+
18
22
  const network = () => ({
19
23
  title: 'network',
20
24
  type: 'object',
@@ -47,9 +51,31 @@ const network = () => ({
47
51
  required: ['networkPercentage', 'shopPercentage'],
48
52
  additionalProperties: false,
49
53
  },
50
- type: networkType()
54
+ type: networkType(),
55
+ isActive: { type: 'boolean' },
56
+ searchName: { type: 'string' },
57
+ canUpdate: { type: 'boolean' },
58
+ // country: countryCode(),
59
+ country: { type: 'string' },
60
+ isInternational: { type: 'boolean' },
61
+ mandatoryShopFiscalData: { type: 'boolean' },
62
+ calcChanneling: { type: 'boolean' },
63
+ parseAddress: { type: 'string', enum: parseAddressType() },
51
64
  },
52
- required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'readonly', 'defaults', 'name', 'contacts', 'salesSettings', 'type'],
65
+ required: [
66
+ '_id',
67
+ 'createdAt',
68
+ 'updatedAt',
69
+ 'deletable',
70
+ 'readonly',
71
+ 'defaults',
72
+ 'name',
73
+ 'contacts',
74
+ 'salesSettings',
75
+ 'type',
76
+ 'isActive',
77
+ 'searchName',
78
+ ],
53
79
  additionalProperties: false,
54
80
  });
55
81
 
@@ -74,7 +100,7 @@ const createNetworkRequest = () =>
74
100
  'derivationSettings',
75
101
  'expirationSettings',
76
102
  'salesSettings',
77
- 'type'
103
+ 'type',
78
104
  ]),
79
105
  },
80
106
  required: ['name', 'salesSettings'],
@@ -19,7 +19,7 @@ const {
19
19
  addressWithRequiredLocation,
20
20
  findAll,
21
21
  findById,
22
- findByStringId, // _id string numérico — usado en updateLockerRequest
22
+ findByStringId, // _id string numérico — usado en updateLockerRequest
23
23
  findByName,
24
24
  findByAddress,
25
25
  findByCircularArea,
@@ -27,8 +27,8 @@ const {
27
27
  timezone,
28
28
  contact,
29
29
  fiscal,
30
- lockerAddress, // address con maxLength de BD + campo access_descript_locker
31
- lockerFiscal, // fiscal con required mínimo y maxLength de BD
30
+ lockerAddress, // address con maxLength de BD + campo access_descript_locker
31
+ lockerFiscal, // fiscal con required mínimo y maxLength de BD
32
32
  findByFiscal,
33
33
  findByIdInternational,
34
34
  } = require('./common');
@@ -58,7 +58,7 @@ const shopSchedule = () => ({
58
58
  saturday: shopDaySchedule(),
59
59
  sunday: shopDaySchedule(),
60
60
  },
61
- required: ['type', 'weekly'],// saturday and sunday are optional
61
+ required: ['type', 'weekly'], // saturday and sunday are optional
62
62
  additionalProperties: false,
63
63
  },
64
64
  {
@@ -95,7 +95,6 @@ const shopHoliday = () => ({
95
95
  additionalProperties: false,
96
96
  });
97
97
 
98
-
99
98
  const shopRepresentative = () => ({
100
99
  type: 'object',
101
100
  properties: {
@@ -150,6 +149,48 @@ const shopActivity = () => ({
150
149
  ],
151
150
  });
152
151
 
152
+ // Funciones que se activan o desactivan por tienda desde el admin; el shop solo muestra las que están a true
153
+ const OPTIONS_FEATURES = Object.freeze(['printLabels', 'analytics', 'billing', 'labelReplenishment']);
154
+
155
+ const optionsFeatures = () => ({
156
+ type: 'object',
157
+ properties: Object.fromEntries(OPTIONS_FEATURES.map(feature => [feature, { type: 'boolean', default: false }])),
158
+ additionalProperties: false,
159
+ });
160
+ function channelingType() {
161
+ return ['postalCode', 'parcelShop'];
162
+ }
163
+
164
+ function shopChanneling() {
165
+ return {
166
+ type: 'object',
167
+ properties: {
168
+ at: { type: 'string', format: 'date-time' },
169
+ type: { type: 'string', enum: channelingType() },
170
+ agency: {
171
+ type: 'object',
172
+ properties: {
173
+ code: { type: 'integer' },
174
+ name: { type: 'string' },
175
+ nxt: {
176
+ description:'nxt data',
177
+ type: 'object',
178
+ properties: {
179
+ uid: { type: 'string' },
180
+ },
181
+ required: ['uid'],
182
+ additionalProperties: false,
183
+ },
184
+ },
185
+ required: ['code', 'name'],
186
+ additionalProperties: false,
187
+ },
188
+ },
189
+ required: ['at'],
190
+ additionalProperties: false,
191
+ };
192
+ }
193
+
153
194
  const shop = () => ({
154
195
  title: 'shop',
155
196
  type: 'object',
@@ -241,6 +282,7 @@ const shop = () => ({
241
282
  radical: { type: 'boolean', default: false },
242
283
  operations: { type: ['boolean', 'string'], trim: true },
243
284
  reverseLogistic: { type: 'boolean', default: false },
285
+ optionsFeatures: optionsFeatures(),
244
286
  // 2023-01-12 JL están definidos como string
245
287
  // TODO en el momento que el frontend sea capaz de mandar integer, se quita "string"
246
288
  squareCode: { type: ['integer', 'string'], minimum: 0, maximum: 32767, description: 'agency code' },
@@ -260,6 +302,8 @@ const shop = () => ({
260
302
  required: ['code', 'updatedAt'],
261
303
  additionalProperties: false,
262
304
  },
305
+ // 2026-10-15 JL cálculo de canalización
306
+ shopChanneling: shopChanneling(),
263
307
  },
264
308
  required: [
265
309
  '_id',
@@ -331,12 +375,13 @@ const createShopRequest = () =>
331
375
  'radical',
332
376
  'operations',
333
377
  'reverseLogistic',
378
+ 'optionsFeatures',
334
379
  'capacity',
335
380
  'squareCode',
336
381
  'clientCode',
337
382
  'channelingAgencyCode',
338
383
  ]),
339
- },// Shop
384
+ }, // Shop
340
385
  required: ['network', 'status', 'name', 'address', 'openingSchedule', 'timezone'],
341
386
  additionalProperties: false,
342
387
  });
@@ -463,6 +508,7 @@ const updateShopRequest = () =>
463
508
  'radical',
464
509
  'operations',
465
510
  'reverseLogistic',
511
+ 'optionsFeatures',
466
512
  'capacity',
467
513
  'squareCode',
468
514
  'clientCode',
@@ -592,9 +638,9 @@ const locker = () => ({
592
638
 
593
639
  // reutilizamos openingSchedule, timezone, activity y eco de shop()
594
640
  openingSchedule: shop().properties.openingSchedule,
595
- timezone: shop().properties.timezone,
596
- activity: shop().properties.activity,
597
- eco: shop().properties.eco,
641
+ timezone: shop().properties.timezone,
642
+ activity: shop().properties.activity,
643
+ eco: shop().properties.eco,
598
644
 
599
645
  // fiscal con required mínimo y maxLength de BD — ver common.js
600
646
  fiscal: lockerFiscal(),
@@ -610,17 +656,21 @@ const locker = () => ({
610
656
 
611
657
  // ── Campos _locker — fuente de verdad para coordenadas y dirección ───────
612
658
  direccion_locker: { type: 'string', trim: true, maxLength: 255 }, // varchar(255)
613
- codpostal_locker: { type: 'string', trim: true, maxLength: 15 }, // varchar(15)
614
- ciudad_locker: { type: 'string', trim: true, maxLength: 100 }, // varchar(100)
659
+ codpostal_locker: { type: 'string', trim: true, maxLength: 15 }, // varchar(15)
660
+ ciudad_locker: { type: 'string', trim: true, maxLength: 100 }, // varchar(100)
615
661
  longitud_locker: {
616
- type: 'number', minimum: -180, maximum: 180,
662
+ type: 'number',
663
+ minimum: -180,
664
+ maximum: 180,
617
665
  description: 'Fuente de verdad para longitude — sobreescribe address.location.geometry.coordinates[0]',
618
666
  },
619
667
  latitud_locker: {
620
- type: 'number', minimum: -90, maximum: 90,
668
+ type: 'number',
669
+ minimum: -90,
670
+ maximum: 90,
621
671
  description: 'Fuente de verdad para latitude — sobreescribe address.location.geometry.coordinates[1]',
622
672
  },
623
- capacity_locker: { type: 'string', maxLength: 20 },
673
+ capacity_locker: { type: 'string', maxLength: 20 },
624
674
  access_descript_locker: { type: 'string', trim: true, maxLength: 500 },
625
675
  },
626
676
  required: [
@@ -648,9 +698,9 @@ const lockerNxt = () => ({
648
698
  provider: {
649
699
  type: 'object',
650
700
  properties: {
651
- name: { type: 'string', trim: true, maxLength: 100 }, // PartnerKey varchar(100)
701
+ name: { type: 'string', trim: true, maxLength: 100 }, // PartnerKey varchar(100)
652
702
  lockerVersion: { type: 'string', trim: true, maxLength: 20 },
653
- lockerModel: { type: 'string', trim: true, maxLength: 100 },
703
+ lockerModel: { type: 'string', trim: true, maxLength: 100 },
654
704
  },
655
705
  required: ['name'],
656
706
  additionalProperties: false,
@@ -659,12 +709,12 @@ const lockerNxt = () => ({
659
709
  type: 'object',
660
710
  properties: {
661
711
  streetNumber: { type: 'string', trim: true, maxLength: 20 },
662
- street: { type: 'string', trim: true, maxLength: 255 }, // varchar(255)
663
- postalCode: { type: 'string', trim: true, maxLength: 15 }, // varchar(15)
664
- lon: { type: 'number', minimum: -180, maximum: 180 }, // float BD
665
- lat: { type: 'number', minimum: -90, maximum: 90 },
666
- countryCode: { type: 'string', trim: true, minLength: 2, maxLength: 2 }, // ISO 3166-1 alpha-2
667
- city: { type: 'string', trim: true, maxLength: 100 }, // varchar(100)
712
+ street: { type: 'string', trim: true, maxLength: 255 }, // varchar(255)
713
+ postalCode: { type: 'string', trim: true, maxLength: 15 }, // varchar(15)
714
+ lon: { type: 'number', minimum: -180, maximum: 180 }, // float BD
715
+ lat: { type: 'number', minimum: -90, maximum: 90 },
716
+ countryCode: { type: 'string', trim: true, minLength: 2, maxLength: 2 }, // ISO 3166-1 alpha-2
717
+ city: { type: 'string', trim: true, maxLength: 100 }, // varchar(100)
668
718
  },
669
719
  required: ['street', 'postalCode', 'countryCode', 'city'],
670
720
  additionalProperties: false,
@@ -672,8 +722,8 @@ const lockerNxt = () => ({
672
722
  features: {
673
723
  type: 'object',
674
724
  properties: {
675
- hasScreen: { type: 'boolean' },
676
- hasPinPad: { type: 'boolean' },
725
+ hasScreen: { type: 'boolean' },
726
+ hasPinPad: { type: 'boolean' },
677
727
  hasPinBarcodeReader: { type: 'boolean' },
678
728
  },
679
729
  additionalProperties: false,
@@ -681,9 +731,9 @@ const lockerNxt = () => ({
681
731
  carrier: {
682
732
  type: 'object',
683
733
  properties: {
684
- lockerName: { type: 'string', trim: true, maxLength: 100 }, // Nombre varchar(100)
734
+ lockerName: { type: 'string', trim: true, maxLength: 100 }, // Nombre varchar(100)
685
735
  activationDate: { type: 'string', format: 'date-time' },
686
- lockerId: { type: 'string', maxLength: 36 }, // UUID = 36 chars
736
+ lockerId: { type: 'string', maxLength: 36 }, // UUID = 36 chars
687
737
  },
688
738
  required: ['lockerName'],
689
739
  additionalProperties: false,
@@ -724,9 +774,9 @@ const createLockerRequest = () =>
724
774
  ...pickProperties(locker(), ['_id', 'createdAt']),
725
775
  // relaciones como objectWithUuid
726
776
  network: objectWithUuid(),
727
- zone: objectWithUuid(),
777
+ zone: objectWithUuid(),
728
778
  // representantes en formato "set" (solo _id + since, sin name)
729
- openingRepresentative: setShopRepresentative(),
779
+ openingRepresentative: setShopRepresentative(),
730
780
  managingRepresentative: setShopRepresentative(),
731
781
  // resto de campos tomados directamente del schema base locker()
732
782
  ...pickProperties(locker(), [
@@ -788,11 +838,11 @@ const updateLockerRequest = () =>
788
838
  type: 'object',
789
839
  properties: {
790
840
  // relaciones y representantes con helpers reutilizados de shop
791
- network: schemaOrNull(objectWithUuid()),
792
- zone: schemaOrNull(objectWithUuid()),
793
- openingRepresentative: schemaOrNull(setShopRepresentative()),
841
+ network: schemaOrNull(objectWithUuid()),
842
+ zone: schemaOrNull(objectWithUuid()),
843
+ openingRepresentative: schemaOrNull(setShopRepresentative()),
794
844
  managingRepresentative: schemaOrNull(setShopRepresentative()),
795
- status: setShopStatus(),
845
+ status: setShopStatus(),
796
846
 
797
847
  // campos actualizables del schema base locker() — todos con schemaOrNull
798
848
  ...Object.fromEntries(
@@ -813,8 +863,8 @@ const updateLockerRequest = () =>
813
863
  'latitud_locker',
814
864
  'capacity_locker',
815
865
  'access_descript_locker',
816
- ])
817
- ).map(([key, schema]) => [key, schemaOrNull(schema)])
866
+ ]),
867
+ ).map(([key, schema]) => [key, schemaOrNull(schema)]),
818
868
  ),
819
869
 
820
870
  // capabilities: array, no nullable — va sin schemaOrNull
@@ -834,7 +884,101 @@ const updateLockerRequest = () =>
834
884
 
835
885
  const updateLockerResponse = () => updateResponse(locker());
836
886
 
887
+ // Máximo de tiendas en una lista explícita (buscador o Excel de IDs)
888
+ const PRINT_LABELS_BULK_MAX_SHOP_IDS = 10000;
889
+
890
+ // Id de tienda en las operaciones masivas: no se exige uuid porque hay tiendas antiguas con _id que no lo es, y el
891
+ // backend ya se queda solo con las que existen
892
+ const printLabelsShopId = () => ({ type: 'string', minLength: 1, maxLength: 100 });
893
+
894
+ const printLabelsGroupOf = (type, properties) => ({
895
+ type: 'object',
896
+ properties: { type: { const: type }, ...properties },
897
+ required: ['type', ...Object.keys(properties)],
898
+ additionalProperties: false,
899
+ });
900
+
901
+ // Grupo de tiendas sobre el que se activa o desactiva la impresión de etiquetas
902
+ const printLabelsGroup = () => ({
903
+ oneOf: [
904
+ printLabelsGroupOf('networks', { networkIds: { type: 'array', items: uuid(), minItems: 1, uniqueItems: true } }),
905
+ printLabelsGroupOf('zone', { zoneId: uuid() }),
906
+ printLabelsGroupOf('representative', { representativeIds: { type: 'array', items: uuid(), minItems: 1, uniqueItems: true } }),
907
+ printLabelsGroupOf('shops', {
908
+ shopIds: { type: 'array', items: printLabelsShopId(), minItems: 1, maxItems: PRINT_LABELS_BULK_MAX_SHOP_IDS, uniqueItems: true },
909
+ }),
910
+ ],
911
+ });
912
+
913
+ const printLabelsExcludedShopIds = () => ({ type: 'array', items: printLabelsShopId(), maxItems: PRINT_LABELS_BULK_MAX_SHOP_IDS, uniqueItems: true });
914
+
915
+ // Sin feature/value solo se cuenta el grupo; con ellos, los recuentos y las tiendas de esa función
916
+ const previewPrintLabelsBulkRequest = () => ({
917
+ type: 'object',
918
+ properties: {
919
+ group: printLabelsGroup(),
920
+ feature: { type: 'string', enum: [...OPTIONS_FEATURES] },
921
+ value: { type: 'boolean' },
922
+ excludedShopIds: printLabelsExcludedShopIds(),
923
+ skip: { type: 'integer', minimum: 0, default: 0 },
924
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 25 },
925
+ },
926
+ required: ['group'],
927
+ dependencies: { feature: ['value'], value: ['feature'] },
928
+ additionalProperties: false,
929
+ });
930
+
931
+ // Valor que se quiere aplicar a cada función ({ printLabels: true, analytics: false }); las que no vienen no se tocan
932
+ const updatePrintLabelsBulkRequest = () => ({
933
+ type: 'object',
934
+ properties: {
935
+ group: printLabelsGroup(),
936
+ features: {
937
+ type: 'object',
938
+ properties: Object.fromEntries(OPTIONS_FEATURES.map(feature => [feature, { type: 'boolean' }])),
939
+ minProperties: 1,
940
+ additionalProperties: false,
941
+ },
942
+ excludedShopIds: printLabelsExcludedShopIds(),
943
+ // Nombre legible del grupo ("Zona Norte", "3 redes"...) para el historial de operaciones
944
+ groupLabel: { type: 'string', trim: true, maxLength: 500 },
945
+ },
946
+ required: ['group', 'features'],
947
+ additionalProperties: false,
948
+ });
949
+
950
+ // Identificadores leídos de un Excel (UUID, ID internacional, código de cliente o CIF/NIF) para traducirlos a tiendas
951
+ const resolvePrintLabelsShopsRequest = () => ({
952
+ type: 'object',
953
+ properties: {
954
+ identifiers: {
955
+ type: 'array',
956
+ items: { type: 'string', trim: true, minLength: 1, maxLength: 100 },
957
+ minItems: 1,
958
+ maxItems: PRINT_LABELS_BULK_MAX_SHOP_IDS,
959
+ },
960
+ },
961
+ required: ['identifiers'],
962
+ additionalProperties: false,
963
+ });
964
+
965
+ // Estado de una operación masiva en curso o terminada (el asistente la consulta para mostrar el progreso)
966
+ const getPrintLabelsBulkOperationRequest = () => ({
967
+ type: 'object',
968
+ properties: {
969
+ operation: {
970
+ type: 'object',
971
+ properties: { _id: uuid() },
972
+ required: ['_id'],
973
+ additionalProperties: false,
974
+ },
975
+ },
976
+ required: ['operation'],
977
+ additionalProperties: false,
978
+ });
979
+
837
980
  module.exports = {
981
+ OPTIONS_FEATURES,
838
982
  shop,
839
983
  locker,
840
984
  lockerNxt,
@@ -855,4 +999,9 @@ module.exports = {
855
999
  createLockerResponse,
856
1000
  updateLockerRequest,
857
1001
  updateLockerResponse,
858
- };
1002
+ PRINT_LABELS_BULK_MAX_SHOP_IDS,
1003
+ previewPrintLabelsBulkRequest,
1004
+ updatePrintLabelsBulkRequest,
1005
+ resolvePrintLabelsShopsRequest,
1006
+ getPrintLabelsBulkOperationRequest,
1007
+ };
package/schemas/index.js CHANGED
@@ -64,6 +64,10 @@ const {
64
64
  createLockerRequest,
65
65
  updateLockerRequest,
66
66
  locker,
67
+ previewPrintLabelsBulkRequest,
68
+ updatePrintLabelsBulkRequest,
69
+ resolvePrintLabelsShopsRequest,
70
+ getPrintLabelsBulkOperationRequest,
67
71
  } = require('./definitions/shops');
68
72
  const {
69
73
  createExpeditionRequest,
@@ -205,6 +209,10 @@ const shopsUpdateRequest = request(updateShopRequest(), 'shopsUpdateRequest');
205
209
  const shopsUpdateResponse = response(updateShopResponse(), 'shopsUpdateResponse');
206
210
  const shopsDeleteRequest = request(deleteShopRequest(), 'shopsDeleteRequest');
207
211
  const shopsDeleteResponse = response(deleteShopResponse(), 'shopsDeleteResponse');
212
+ const shopsPrintLabelsPreviewRequest = request(previewPrintLabelsBulkRequest(), 'shopsPrintLabelsPreviewRequest');
213
+ const shopsPrintLabelsBulkRequest = request(updatePrintLabelsBulkRequest(), 'shopsPrintLabelsBulkRequest');
214
+ const shopsPrintLabelsResolveRequest = request(resolvePrintLabelsShopsRequest(), 'shopsPrintLabelsResolveRequest');
215
+ const shopsPrintLabelsOperationRequest = request(getPrintLabelsBulkOperationRequest(), 'shopsPrintLabelsOperationRequest');
208
216
 
209
217
  const shopUsersCreateRequest = request(createShopUserRequest(), 'shopUsersCreateRequest');
210
218
  const shopUsersCreateResponse = response(createShopUserResponse(), 'shopUsersCreateResponse');
@@ -371,6 +379,10 @@ module.exports = {
371
379
  shopsUpdateResponse,
372
380
  shopsDeleteRequest,
373
381
  shopsDeleteResponse,
382
+ shopsPrintLabelsPreviewRequest,
383
+ shopsPrintLabelsBulkRequest,
384
+ shopsPrintLabelsResolveRequest,
385
+ shopsPrintLabelsOperationRequest,
374
386
 
375
387
  lockersCreateRequest,
376
388
  lockersUpdateRequest,