@gls_spain/gps-common 35.20.0 → 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,10 @@
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
+
1
8
  # [35.20.0](https://github.com/GLS-Spain/gps-common/compare/v35.19.4...v35.20.0) (2026-10-21)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "35.20.0",
3
+ "version": "35.21.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "keywords": [
6
6
  "gls"
@@ -149,6 +149,14 @@ const shopActivity = () => ({
149
149
  ],
150
150
  });
151
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
+ });
152
160
  function channelingType() {
153
161
  return ['postalCode', 'parcelShop'];
154
162
  }
@@ -274,6 +282,7 @@ const shop = () => ({
274
282
  radical: { type: 'boolean', default: false },
275
283
  operations: { type: ['boolean', 'string'], trim: true },
276
284
  reverseLogistic: { type: 'boolean', default: false },
285
+ optionsFeatures: optionsFeatures(),
277
286
  // 2023-01-12 JL están definidos como string
278
287
  // TODO en el momento que el frontend sea capaz de mandar integer, se quita "string"
279
288
  squareCode: { type: ['integer', 'string'], minimum: 0, maximum: 32767, description: 'agency code' },
@@ -366,6 +375,7 @@ const createShopRequest = () =>
366
375
  'radical',
367
376
  'operations',
368
377
  'reverseLogistic',
378
+ 'optionsFeatures',
369
379
  'capacity',
370
380
  'squareCode',
371
381
  'clientCode',
@@ -498,6 +508,7 @@ const updateShopRequest = () =>
498
508
  'radical',
499
509
  'operations',
500
510
  'reverseLogistic',
511
+ 'optionsFeatures',
501
512
  'capacity',
502
513
  'squareCode',
503
514
  'clientCode',
@@ -873,7 +884,101 @@ const updateLockerRequest = () =>
873
884
 
874
885
  const updateLockerResponse = () => updateResponse(locker());
875
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
+
876
980
  module.exports = {
981
+ OPTIONS_FEATURES,
877
982
  shop,
878
983
  locker,
879
984
  lockerNxt,
@@ -894,4 +999,9 @@ module.exports = {
894
999
  createLockerResponse,
895
1000
  updateLockerRequest,
896
1001
  updateLockerResponse,
1002
+ PRINT_LABELS_BULK_MAX_SHOP_IDS,
1003
+ previewPrintLabelsBulkRequest,
1004
+ updatePrintLabelsBulkRequest,
1005
+ resolvePrintLabelsShopsRequest,
1006
+ getPrintLabelsBulkOperationRequest,
897
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,