@gls_spain/gps-common 35.16.1 → 35.17.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.
@@ -1,80 +1,45 @@
1
1
  name: Claude Code Review
2
-
3
2
  on:
4
3
  pull_request:
5
4
  types: [opened]
6
- # Optional: Only run on specific file changes
7
- # paths:
8
- # - "src/**/*.ts"
9
- # - "src/**/*.tsx"
10
- # - "src/**/*.js"
11
- # - "src/**/*.jsx"
12
5
 
13
6
  jobs:
14
7
  claude-review:
15
- # Optional: Filter by PR author
16
- # if: |
17
- # github.event.pull_request.user.login == 'external-contributor' ||
18
- # github.event.pull_request.user.login == 'new-developer' ||
19
- # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20
-
21
8
  runs-on: ubuntu-latest
22
9
  permissions:
23
10
  contents: read
24
- pull-requests: read
25
- issues: read
11
+ pull-requests: write
12
+ issues: write
26
13
  id-token: write
14
+ actions: read
27
15
 
28
16
  steps:
29
17
  - name: Checkout repository
30
- uses: actions/checkout@v4
18
+ uses: actions/checkout@v4.2.2
31
19
  with:
32
20
  fetch-depth: 1
33
21
 
34
22
  - name: Run Claude Code Review
35
23
  id: claude-review
36
- uses: anthropics/claude-code-action@beta
24
+ uses: anthropics/claude-code-action@v1
37
25
  with:
38
26
  claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
27
+ prompt: |
28
+ Revisa la PR número ${{ github.event.pull_request.number }} de este repositorio.
29
+ Ejecuta `gh pr view ${{ github.event.pull_request.number }}` y `gh pr diff ${{ github.event.pull_request.number }}` para obtener los detalles y el diff.
39
30
 
40
- # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
41
- # model: "claude-opus-4-1-20250805"
42
-
43
- # Direct prompt for automated review (no @claude mention needed)
44
- direct_prompt: |
45
- Actúa como un code reviewer senior exigente pero constructivo.Por favor revisa esta pull request y provee feedback en base a estas dimensiones:
31
+ Actúa como un code reviewer senior exigente pero constructivo. Provee feedback en base a estas dimensiones:
46
32
  - Calidad del código y mejores prácticas
47
33
  - Posibles errores o problemas
48
34
  - Consideraciones de rendimiento
49
35
  - Preocupaciones de seguridad
50
-
51
- Sé constructivo y útil en tus comentarios.
52
36
 
37
+ Sé constructivo y útil en tus comentarios.
38
+ No tengas en cuenta las consideraciones referentes a sentencias con NOLOCK. Por defecto, en este codebase todo va con NOLOCK.
53
39
  Al final, da una puntuación global de 1 a 10 con un resumen de una línea.
54
-
55
40
  El idioma a usar es el español.
56
41
 
57
- # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
58
- use_sticky_comment: false
59
-
60
- # Optional: Customize review based on file types
61
- # direct_prompt: |
62
- # Review this PR focusing on:
63
- # - For TypeScript files: Type safety and proper interface usage
64
- # - For API endpoints: Security, input validation, and error handling
65
- # - For React components: Performance, accessibility, and best practices
66
- # - For tests: Coverage, edge cases, and test quality
67
-
68
- # Optional: Different prompts for different authors
69
- # direct_prompt: |
70
- # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
71
- # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
72
- # 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
73
-
74
- # Optional: Add specific tools for running tests or linting
75
- # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
76
-
77
- # Optional: Skip review for certain conditions
78
- # if: |
79
- # !contains(github.event.pull_request.title, '[skip-review]') &&
80
- # !contains(github.event.pull_request.title, '[WIP]')
42
+ Publica el resultado como comentario en la PR usando: gh pr comment ${{ github.event.pull_request.number }} --body "..."
43
+ claude_args: |
44
+ --model claude-sonnet-4-6
45
+ --allowedTools "Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*)"
@@ -1,5 +1,4 @@
1
1
  name: Claude Code
2
-
3
2
  on:
4
3
  issue_comment:
5
4
  types: [created]
@@ -23,7 +22,7 @@ jobs:
23
22
  pull-requests: read
24
23
  issues: read
25
24
  id-token: write
26
- actions: read # Required for Claude to read CI results on PRs
25
+ actions: read
27
26
  steps:
28
27
  - name: Checkout repository
29
28
  uses: actions/checkout@v4
@@ -32,32 +31,10 @@ jobs:
32
31
 
33
32
  - name: Run Claude Code
34
33
  id: claude
35
- uses: anthropics/claude-code-action@beta
34
+ uses: anthropics/claude-code-action@v1 # ← @beta → @v1
36
35
  with:
37
36
  claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38
-
39
- # This is an optional setting that allows Claude to read CI results on PRs
40
37
  additional_permissions: |
41
38
  actions: read
42
-
43
- # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
44
- # model: "claude-opus-4-1-20250805"
45
-
46
- # Optional: Customize the trigger phrase (default: @claude)
47
- # trigger_phrase: "/claude"
48
-
49
- # Optional: Trigger when specific user is assigned to an issue
50
- # assignee_trigger: "claude-bot"
51
-
52
- # Optional: Allow Claude to run specific commands
53
- # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"
54
-
55
- # Optional: Add custom instructions for Claude to customize its behavior for your project
56
- # custom_instructions: |
57
- # Follow our coding standards
58
- # Ensure all new code has tests
59
- # Use TypeScript for new files
60
-
61
- # Optional: Custom environment variables for Claude
62
- # claude_env: |
63
- # NODE_ENV: test
39
+ claude_args: |
40
+ --model claude-sonnet-4-6 # ← modelo válido actual
package/CHANGELOG.md CHANGED
@@ -1,18 +1,50 @@
1
- ## [35.16.1](https://github.com/GLS-Spain/gps-common/compare/v35.16.0...v35.16.1) (2026-04-20)
1
+ ## [35.17.1](https://github.com/GLS-Spain/gps-common/compare/v35.17.0...v35.17.1) (2026-05-27)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
+ * add sunday and minor fix validation ([00129c8](https://github.com/GLS-Spain/gps-common/commit/00129c8e72d9e62b7b8b6627514b5c432d3e1774))
7
+ * commit version task INN 563 ([f0dcb28](https://github.com/GLS-Spain/gps-common/commit/f0dcb28bb609aaac664d0f992bfc7d25d896a42a))
8
+
9
+ # [35.17.0](https://github.com/GLS-Spain/gps-common/compare/v35.16.0...v35.17.0) (2026-05-04)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * ajustar body de salesforce ([1f5072c](https://github.com/GLS-Spain/gps-common/commit/1f5072cd2abeefbeaa4ab4909df75184c9465959))
6
15
  * quitar validacion de pod para entrega DTT ([688af4f](https://github.com/GLS-Spain/gps-common/commit/688af4fbc68139bf61012c086a1d2ad52dc6116e))
7
16
  * quitar validacion de pod en customerWithPod para entrega DTT ([6ae1db1](https://github.com/GLS-Spain/gps-common/commit/6ae1db1ec0767bed6b0976b8ad44f99678ea9c36))
8
17
 
9
- # [35.16.0](https://github.com/GLS-Spain/gps-common/compare/v35.15.10...v35.16.0) (2026-04-10)
10
-
11
18
 
12
19
  ### Features
13
20
 
14
- * add optional per-service rates (delivery, pickup, s2s) to derivationRate ([1e8af9c](https://github.com/GLS-Spain/gps-common/commit/1e8af9c1ec10f21b79a30513b9d15de3cc0d8910))
21
+ * upgrade version common fix bug version ([b23a3c7](https://github.com/GLS-Spain/gps-common/commit/b23a3c7abeff91f47d9aec73006c7c7456332e34))
22
+
23
+ ## [35.16.1](https://github.com/GLS-Spain/gps-common/compare/v35.16.0...v35.16.1) (2026-05-04)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * ajustar body de salesforce ([1f5072c](https://github.com/GLS-Spain/gps-common/commit/1f5072cd2abeefbeaa4ab4909df75184c9465959))
29
+ * quitar validacion de pod para entrega DTT ([688af4f](https://github.com/GLS-Spain/gps-common/commit/688af4fbc68139bf61012c086a1d2ad52dc6116e))
30
+ * quitar validacion de pod en customerWithPod para entrega DTT ([6ae1db1](https://github.com/GLS-Spain/gps-common/commit/6ae1db1ec0767bed6b0976b8ad44f99678ea9c36))
15
31
 
32
+ ## [35.16.1](https://github.com/GLS-Spain/gps-common/compare/v35.16.0...v35.16.1) (2026-05-04)
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * ajustar body de salesforce ([1f5072c](https://github.com/GLS-Spain/gps-common/commit/1f5072cd2abeefbeaa4ab4909df75184c9465959))
38
+ * quitar validacion de pod para entrega DTT ([688af4f](https://github.com/GLS-Spain/gps-common/commit/688af4fbc68139bf61012c086a1d2ad52dc6116e))
39
+ * quitar validacion de pod en customerWithPod para entrega DTT ([6ae1db1](https://github.com/GLS-Spain/gps-common/commit/6ae1db1ec0767bed6b0976b8ad44f99678ea9c36))
40
+
41
+ # [35.16.0](https://github.com/GLS-Spain/gps-common/compare/v35.15.10...v35.16.0) (2026-04-10)
42
+
43
+
44
+ ### Features
45
+
46
+ * add optional per-service rates (delivery, pickup, s2s) to derivationRate ([1e8af9c](https://github.com/GLS-Spain/gps-common/commit/1e8af9c1ec10f21b79a30513b9d15de3cc0d8910))
47
+
16
48
  ## [35.15.10](https://github.com/GLS-Spain/gps-common/compare/v35.15.9...v35.15.10) (2026-03-13)
17
49
 
18
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "35.16.1",
3
+ "version": "35.17.1",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "keywords": [
6
6
  "gls"
@@ -307,6 +307,18 @@ const findAll = () => ({
307
307
 
308
308
  const findById = () => mergeSchemas(objectWithUuid(), { title: 'find by _id' });
309
309
 
310
+ // ── findByStringId ────────────────────────────────────────────────────────────
311
+ // Equivalente a findById() pero para entidades cuyo _id no es UUID.
312
+ // Usado en updateLockerRequest: el _id del locker es un string numérico ("6237514999")
313
+ // ─────────────────────────────────────────────────────────────────────────────
314
+ const findByStringId = () => ({
315
+ title: 'find by _id (string)',
316
+ type: 'object',
317
+ properties: { _id: { type: 'string', trim: true } },
318
+ required: ['_id'],
319
+ additionalProperties: false,
320
+ });
321
+
310
322
  const findByIds = () => ({
311
323
  title: 'find by _ids',
312
324
  type: 'object',
@@ -448,20 +460,99 @@ const findByIdInternational = () => ({
448
460
  },
449
461
  required: ['international'],
450
462
  additionalProperties: false,
451
-
452
463
  });
453
464
 
454
-
455
465
  const networkType = () => ({
456
466
  type: 'string',
457
467
  enum: [
458
468
  'Business',
459
469
  'Locker',
460
470
  'Agency',
461
- 'Premium'
471
+ 'Premium',
462
472
  ]
463
473
  });
464
474
 
475
+ // ── lockerAddress ─────────────────────────────────────────────────────────────
476
+ // Variante de addressWithRequiredLocation para lockers:
477
+ // - maxLength alineados con las columnas de BD relacional (ps_puntos Apolo)
478
+ // - campo extra access_descript_locker (descripción de acceso al locker)
479
+ // No se puede reutilizar addressWithRequiredLocation() directamente porque:
480
+ // 1. Tiene additionalProperties: false → no admite access_descript_locker
481
+ // 2. No define maxLength en sus campos → necesario para mapear contra varchar(N)
482
+ // ─────────────────────────────────────────────────────────────────────────────
483
+ const lockerAddress = () => ({
484
+ type: 'object',
485
+ properties: {
486
+ street: { type: 'string', trim: true, maxLength: 255 }, // Calle varchar(255)
487
+ door: { type: 'string', trim: true, maxLength: 20 },
488
+ postalCode: { type: 'string', trim: true, maxLength: 15 }, // cp varchar(15)
489
+ locality: { type: 'string', trim: true, maxLength: 100 }, // Poblacion varchar(100)
490
+ country: { type: 'string', trim: true, maxLength: 3 }, // ISO 3166-1 alpha-2/3
491
+ // campo específico de locker
492
+ access_descript_locker: { type: 'string', trim: true, maxLength: 500 },
493
+ location: {
494
+ type: 'object',
495
+ properties: {
496
+ geometry: {
497
+ type: 'object',
498
+ properties: {
499
+ type: { type: 'string', enum: ['Point'] },
500
+ coordinates: { type: 'array', items: { type: 'number' }, minItems: 2, maxItems: 2 },
501
+ },
502
+ required: ['type', 'coordinates'],
503
+ additionalProperties: false,
504
+ },
505
+ precision: { type: 'string' },
506
+ },
507
+ required: ['geometry'],
508
+ additionalProperties: false,
509
+ },
510
+ },
511
+ required: ['street', 'postalCode', 'locality', 'country', 'location'],
512
+ additionalProperties: false,
513
+ });
514
+
515
+ // ── lockerFiscal ──────────────────────────────────────────────────────────────
516
+ // Variante de fiscal() para lockers. No se puede reutilizar fiscal() de shop porque:
517
+ // - fiscal() de shop tiene required completo:
518
+ // ['iban', 'businessName', 'nif', 'contacts', 'address', 'paymentMethod', 'dueDays', 'activity', 'retention']
519
+ // - lockerFiscal tiene required mínimo: ['contacts', 'address', 'dueDays']
520
+ // (iban y nif son opcionales en locker — puede no tenerlos en el momento del alta)
521
+ // - Los campos de texto tienen maxLength alineados con las columnas de BD relacional
522
+ // - paymentMethod en locker es string libre (no enum como en shop)
523
+ // ─────────────────────────────────────────────────────────────────────────────
524
+ const lockerFiscal = () => ({
525
+ type: 'object',
526
+ properties: {
527
+ iban: { type: 'string', trim: true, maxLength: 34 }, // IBAN estándar 34 chars
528
+ businessName: { type: 'string', trim: true, maxLength: 100 }, // nombreComercial nvarchar(100)
529
+ nif: { type: 'string', trim: true, maxLength: 20 }, // NIF/CIF — margen para internacionales
530
+ contacts: {
531
+ type: 'array',
532
+ items: contact(),
533
+ },
534
+ address: {
535
+ type: 'object',
536
+ properties: {
537
+ street: { type: 'string', trim: true, maxLength: 255 },
538
+ door: { type: 'string', trim: true, maxLength: 20 },
539
+ postalCode: { type: 'string', trim: true, maxLength: 15 },
540
+ locality: { type: 'string', trim: true, maxLength: 100 },
541
+ country: { type: 'string', trim: true, maxLength: 3 },
542
+ },
543
+ required: ['street', 'postalCode', 'locality', 'country'],
544
+ additionalProperties: false,
545
+ },
546
+ paymentMethod: { type: 'string', trim: true, maxLength: 50 }, // string libre (vs enum en shop)
547
+ dueDays: { type: 'integer', minimum: 0 },
548
+ activity: { type: 'string', trim: true, maxLength: 50 }, // IAE — activity varchar(250) BD
549
+ retention: { type: 'integer' },
550
+ },
551
+ // iban y nif son opcionales en locker — required mínimo
552
+ required: ['contacts', 'address', 'dueDays'],
553
+ additionalProperties: false,
554
+ });
555
+
465
556
  module.exports = {
466
557
  specificErrorResponse,
467
558
  date,
@@ -469,8 +560,11 @@ module.exports = {
469
560
  country,
470
561
  address,
471
562
  addressWithRequiredLocation,
563
+ lockerAddress,
564
+ lockerFiscal,
472
565
  findAll,
473
566
  findById,
567
+ findByStringId,
474
568
  findByIds,
475
569
  findByName,
476
570
  findByAddress,
@@ -487,5 +581,5 @@ module.exports = {
487
581
  fiscal,
488
582
  findByFiscal,
489
583
  findByIdInternational,
490
- networkType
491
- };
584
+ networkType,
585
+ };
@@ -19,6 +19,7 @@ const {
19
19
  addressWithRequiredLocation,
20
20
  findAll,
21
21
  findById,
22
+ findByStringId, // _id string numérico — usado en updateLockerRequest
22
23
  findByName,
23
24
  findByAddress,
24
25
  findByCircularArea,
@@ -26,9 +27,10 @@ const {
26
27
  timezone,
27
28
  contact,
28
29
  fiscal,
30
+ lockerAddress, // address con maxLength de BD + campo access_descript_locker
31
+ lockerFiscal, // fiscal con required mínimo y maxLength de BD
29
32
  findByFiscal,
30
33
  findByIdInternational,
31
- address,
32
34
  } = require('./common');
33
35
  const { network, objectWithNetworkId } = require('./networks');
34
36
  const { defaults, derivationSettings, expirationSettings } = require('./defaults');
@@ -54,8 +56,9 @@ const shopSchedule = () => ({
54
56
  type: { type: 'string', enum: ['weekly'] },
55
57
  weekly: shopDaySchedule(),
56
58
  saturday: shopDaySchedule(),
59
+ sunday: shopDaySchedule(),
57
60
  },
58
- required: ['type', 'weekly', 'saturday'],
61
+ required: ['type', 'weekly', 'saturday'], // sunday not required
59
62
  additionalProperties: false,
60
63
  },
61
64
  {
@@ -69,8 +72,9 @@ const shopSchedule = () => ({
69
72
  thursday: shopDaySchedule(),
70
73
  friday: shopDaySchedule(),
71
74
  saturday: shopDaySchedule(),
75
+ sunday: shopDaySchedule(),
72
76
  },
73
- required: ['type', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
77
+ required: ['type', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'], // sunday not required
74
78
  additionalProperties: false,
75
79
  },
76
80
  ],
@@ -91,33 +95,6 @@ const shopHoliday = () => ({
91
95
  additionalProperties: false,
92
96
  });
93
97
 
94
- /*
95
- 2024-05-28 JL+SB este esquema con "absences" no se está utilizando
96
-
97
- const absencesHolidaysShop = () => ({
98
- title: 'Absences holidays shop',
99
- type: 'object',
100
- properties: {
101
- _id: uuid(),
102
- from: datetime(),
103
- to: datetime(),
104
- description: { type: 'string' },
105
- createAt: datetime(),
106
- },
107
- required: ['from', 'to', '_id', 'createAt'],
108
- additionalProperties: false,
109
- });
110
-
111
- const shopHolidays = () => ({
112
- title: 'Holidays shop',
113
- type: 'array',
114
- properties: {
115
- absences: absencesHolidaysShop(),
116
- },
117
- required: ['absences'],
118
- additionalProperties: false,
119
- });
120
- */
121
98
 
122
99
  const shopRepresentative = () => ({
123
100
  type: 'object',
@@ -264,8 +241,6 @@ const shop = () => ({
264
241
  radical: { type: 'boolean', default: false },
265
242
  operations: { type: ['boolean', 'string'], trim: true },
266
243
  reverseLogistic: { type: 'boolean', default: false },
267
- // squareCode: { type: 'string' },
268
- // clientCode: { type: 'string' },
269
244
  // 2023-01-12 JL están definidos como string
270
245
  // TODO en el momento que el frontend sea capaz de mandar integer, se quita "string"
271
246
  squareCode: { type: ['integer', 'string'], minimum: 0, maximum: 32767, description: 'agency code' },
@@ -275,7 +250,6 @@ const shop = () => ({
275
250
  // Volume capacity 07/11/2024
276
251
  capacity: { type: 'string' },
277
252
  // NXT integration
278
- // courierAccessCode: { type: 'string' }
279
253
  // 2024-12-24 JL courierAccessCode es un objeto!!!!
280
254
  courierAccessCode: {
281
255
  type: 'object',
@@ -362,7 +336,7 @@ const createShopRequest = () =>
362
336
  'clientCode',
363
337
  'channelingAgencyCode',
364
338
  ]),
365
- },
339
+ },// Shop
366
340
  required: ['network', 'status', 'name', 'address', 'openingSchedule', 'timezone'],
367
341
  additionalProperties: false,
368
342
  });
@@ -556,8 +530,20 @@ const upsertShopResponse = () => ({
556
530
  additionalProperties: false,
557
531
  });
558
532
 
559
- // LOCKERS
560
-
533
+ // ── LOCKERS ───────────────────────────────────────────────────────────────────
534
+ //
535
+ // Estructura equivalente a shop() + campos específicos de locker:
536
+ // - nxt → referencia al parcelShopId externo NXT
537
+ // - *_locker → campos de BD relacional (fuente de verdad para coords y dirección)
538
+ // - lockerNxt → sub-objeto con datos del hardware (provider, location, features, carrier)
539
+ //
540
+ // Patrón seguido:
541
+ // locker() → schema base de respuesta (≈ shop())
542
+ // lockerNxt() → schema del sub-objeto NXT (provider + location + features + carrier)
543
+ // lockerNxtUpdate()→ variante de lockerNxt sin lockerId en required (para updates)
544
+ // createLockerRequest → pickProperties(locker(), [...]) + setShopRepresentative()
545
+ // updateLockerRequest → findByStringId() + pickProperties(locker(), [...]) con schemaOrNull
546
+ // ─────────────────────────────────────────────────────────────────────────────
561
547
 
562
548
  const locker = () => ({
563
549
  title: 'locker',
@@ -567,22 +553,7 @@ const locker = () => ({
567
553
  createdAt: datetime(),
568
554
  updatedAt: datetime(),
569
555
  deletable: { type: 'boolean' },
570
- readonly: { type: 'boolean', description: 'readonly shops do not allow updates or adding expeditions to them' },
571
- international: {
572
- type: 'object',
573
- properties: {
574
- partnerKey: { type: 'string' },
575
- parcelShopId: { type: 'string' },
576
- },
577
- required: ['partnerKey', 'parcelShopId'],
578
- additionalProperties: false,
579
- },
580
- defaults: {
581
- type: 'object',
582
- properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings']) },
583
- required: ['derivationSettings', 'expirationSettings'],
584
- additionalProperties: false,
585
- },
556
+ readonly: { type: 'boolean', description: 'readonly lockers do not allow updates or adding expeditions to them' },
586
557
  network: {
587
558
  type: 'object',
588
559
  properties: { ...pickProperties(network(), ['_id', 'name', 'derivationSettings', 'expirationSettings']) },
@@ -597,98 +568,47 @@ const locker = () => ({
597
568
  },
598
569
  openingRepresentative: shopRepresentative(),
599
570
  managingRepresentative: shopRepresentative(),
600
- status: {
571
+ // reutilizamos el status de shop — mismos códigos y sub-objetos
572
+ status: shop().properties.status,
573
+
574
+ // ✅ Nombre varchar(100) — ps_puntos Apolo
575
+ name: { type: 'string', trim: true, maxLength: 100 },
576
+
577
+ // address con maxLength de BD + campo access_descript_locker — ver common.js
578
+ address: lockerAddress(),
579
+
580
+ // reutilizamos openingSchedule, timezone, activity y eco de shop()
581
+ openingSchedule: shop().properties.openingSchedule,
582
+ timezone: shop().properties.timezone,
583
+ activity: shop().properties.activity,
584
+ eco: shop().properties.eco,
585
+
586
+ // fiscal con required mínimo y maxLength de BD — ver common.js
587
+ fiscal: lockerFiscal(),
588
+
589
+ nxt: {
601
590
  type: 'object',
602
591
  properties: {
603
- code: { type: 'string', enum: ['enabled', 'disabled', 'manuallyDisabled'] },
604
- disabled: {
605
- type: 'object',
606
- properties: {
607
- at: datetime(),
608
- reason: { type: 'string', trim: true },
609
- },
610
- required: ['at', 'reason'],
611
- additionalProperties: false,
612
- },
613
- manuallyDisabled: {
614
- type: 'object',
615
- properties: {
616
- _id: uuid(),
617
- at: datetime(),
618
- to: datetime(),
619
- reason: { type: 'string', trim: true },
620
- },
621
- required: ['at', 'reason'],
622
- additionalProperties: false,
623
- },
592
+ parcelShopId: { type: 'string', maxLength: 100 }, // varchar(100)
624
593
  },
625
- required: ['code'],
594
+ required: ['parcelShopId'],
626
595
  additionalProperties: false,
627
596
  },
628
- name: { type: 'string', trim: true },
629
- address: addressWithRequiredLocation(),
630
- capabilities: {
631
- type: 'array',
632
- items: { type: 'string', enum: ['deliver', 'pickup', 'sell', 'sellplus'] },
633
- uniqueItems: true,
634
- },
635
- openingSchedule: shopSchedule(),
636
- holidays: { type: 'array', items: shopHoliday(), uniqueItems: true },
637
- timezone: timezone(),
638
- contacts: {
639
- type: 'array',
640
- items: contact(),
641
- },
642
- fiscal: {
643
- type: 'object',
644
- properties: {
645
- iban: { type: 'string', trim: true },
646
- businessName: { type: 'string', trim: true },
647
- nif: { type: 'string', trim: true },
648
- contacts: { type: 'array', items: contact() },
649
- // ✅ address inline — address() tiene additionalProperties:false sin 'door'
650
- address: {
651
- type: 'object',
652
- properties: {
653
- street: { type: 'string', trim: true },
654
- door: { type: 'string', trim: true },
655
- postalCode: { type: 'string', trim: true },
656
- locality: { type: 'string', trim: true },
657
- country: { type: 'string', trim: true },
658
- },
659
- required: ['street', 'postalCode', 'locality', 'country'],
660
- additionalProperties: false,
661
- },
662
- paymentMethod: { type: 'string', trim: true },
663
- dueDays: { type: 'integer', minimum: 0 },
664
- activity: { type: 'string', trim: true, maxLength: 50 },
665
- retention: { type: 'integer' },
666
- },
667
- required: ['iban', 'businessName', 'nif', 'contacts', 'address', 'dueDays', 'retention'],
668
- additionalProperties: false,
597
+
598
+ // ── Campos _locker — fuente de verdad para coordenadas y dirección ───────
599
+ direccion_locker: { type: 'string', trim: true, maxLength: 255 }, // varchar(255)
600
+ codpostal_locker: { type: 'string', trim: true, maxLength: 15 }, // varchar(15)
601
+ ciudad_locker: { type: 'string', trim: true, maxLength: 100 }, // varchar(100)
602
+ longitud_locker: {
603
+ type: 'number', minimum: -180, maximum: 180,
604
+ description: 'Fuente de verdad para longitude — sobreescribe address.location.geometry.coordinates[0]',
669
605
  },
670
- activity: shopActivity(),
671
- notes: { type: 'string', trim: true },
672
- derivationSettings: derivationSettings(),
673
- expirationSettings: expirationSettings(),
674
- eco: { type: 'boolean', default: false },
675
- gold: { type: 'boolean', default: false },
676
- radical: { type: 'boolean', default: false },
677
- operations: { type: ['boolean', 'string'], trim: true },
678
- reverseLogistic: { type: 'boolean', default: false },
679
- squareCode: { type: ['integer', 'string'], minimum: 0, maximum: 32767, description: 'agency code' },
680
- clientCode: { type: ['integer', 'string'], description: 'client code' },
681
- channelingAgencyCode: { type: ['integer', 'string', 'null'], description: 'Channeling Agency Code' },
682
- capacity: { type: 'string' },
683
- courierAccessCode: {
684
- type: 'object',
685
- properties: {
686
- code: { type: 'string' },
687
- updatedAt: { type: 'string', format: 'date-time' },
688
- },
689
- required: ['code', 'updatedAt'],
690
- additionalProperties: false,
606
+ latitud_locker: {
607
+ type: 'number', minimum: -90, maximum: 90,
608
+ description: 'Fuente de verdad para latitude — sobreescribe address.location.geometry.coordinates[1]',
691
609
  },
610
+ capacity_locker: { type: 'string', maxLength: 20 },
611
+ access_descript_locker: { type: 'string', trim: true, maxLength: 500 },
692
612
  },
693
613
  required: [
694
614
  '_id',
@@ -696,180 +616,124 @@ const locker = () => ({
696
616
  'updatedAt',
697
617
  'deletable',
698
618
  'readonly',
699
- 'international',
700
- 'defaults',
701
619
  'network',
702
620
  'status',
703
621
  'name',
704
622
  'address',
705
- 'capabilities',
706
623
  'openingSchedule',
707
624
  'timezone',
708
- 'contacts',
709
625
  ],
710
626
  additionalProperties: false,
711
627
  });
712
628
 
629
+ // ── Schema del sub-objeto NXT (hardware del locker) ───────────────────────────
630
+
631
+ const lockerNxt = () => ({
632
+ title: 'lockerNxt',
633
+ type: 'object',
634
+ properties: {
635
+ provider: {
636
+ type: 'object',
637
+ properties: {
638
+ name: { type: 'string', trim: true, maxLength: 100 }, // PartnerKey varchar(100)
639
+ lockerVersion: { type: 'string', trim: true, maxLength: 20 },
640
+ lockerModel: { type: 'string', trim: true, maxLength: 100 },
641
+ },
642
+ required: ['name'],
643
+ additionalProperties: false,
644
+ },
645
+ location: {
646
+ type: 'object',
647
+ properties: {
648
+ streetNumber: { type: 'string', trim: true, maxLength: 20 },
649
+ street: { type: 'string', trim: true, maxLength: 255 }, // varchar(255)
650
+ postalCode: { type: 'string', trim: true, maxLength: 15 }, // varchar(15)
651
+ lon: { type: 'number', minimum: -180, maximum: 180 }, // float BD
652
+ lat: { type: 'number', minimum: -90, maximum: 90 },
653
+ countryCode: { type: 'string', trim: true, minLength: 2, maxLength: 2 }, // ISO 3166-1 alpha-2
654
+ city: { type: 'string', trim: true, maxLength: 100 }, // varchar(100)
655
+ },
656
+ required: ['street', 'postalCode', 'countryCode', 'city'],
657
+ additionalProperties: false,
658
+ },
659
+ features: {
660
+ type: 'object',
661
+ properties: {
662
+ hasScreen: { type: 'boolean' },
663
+ hasPinPad: { type: 'boolean' },
664
+ hasPinBarcodeReader: { type: 'boolean' },
665
+ },
666
+ additionalProperties: false,
667
+ },
668
+ carrier: {
669
+ type: 'object',
670
+ properties: {
671
+ lockerName: { type: 'string', trim: true, maxLength: 100 }, // Nombre varchar(100)
672
+ activationDate: { type: 'string', format: 'date-time' },
673
+ lockerId: { type: 'string', maxLength: 36 }, // UUID = 36 chars
674
+ },
675
+ required: ['lockerName', 'lockerId'],
676
+ additionalProperties: false,
677
+ },
678
+ },
679
+ required: ['provider', 'location', 'carrier'],
680
+ additionalProperties: false,
681
+ });
682
+
683
+ // ── Variante de lockerNxt para update: lockerId fuera de required ─────────────
684
+ // El body real de updateLocker no envía lockerId
685
+
686
+ const lockerNxtUpdate = () => ({
687
+ ...lockerNxt(),
688
+ properties: {
689
+ ...lockerNxt().properties,
690
+ carrier: {
691
+ ...lockerNxt().properties.carrier,
692
+ required: ['lockerName'],
693
+ },
694
+ },
695
+ });
696
+
697
+ // ── createLockerRequest ───────────────────────────────────────────────────────
698
+ // Mismo patrón que createShopRequest:
699
+ // - pickProperties(locker(), [...]) para los campos del parcelshop
700
+ // - setShopRepresentative() para los representantes (formato "set": solo _id + since)
701
+ // - lockerNxt() para el sub-objeto hardware
713
702
 
714
703
  const createLockerRequest = () =>
715
704
  createRequest({
716
705
  type: 'object',
717
706
  properties: {
718
-
719
707
  parcelshop: {
720
708
  type: 'object',
721
709
  properties: {
722
- _id: uuid(),
723
- createdAt: datetime(),
710
+ // campos de identidad opcionales en create
711
+ ...pickProperties(locker(), ['_id', 'createdAt']),
712
+ // relaciones como objectWithUuid
724
713
  network: objectWithUuid(),
725
- zone: objectWithUuid(),
726
- openingRepresentative: setShopRepresentative(),
714
+ zone: objectWithUuid(),
715
+ // representantes en formato "set" (solo _id + since, sin name)
716
+ openingRepresentative: setShopRepresentative(),
727
717
  managingRepresentative: setShopRepresentative(),
728
-
729
- status: {
730
- type: 'object',
731
- properties: {
732
- code: { type: 'string', enum: ['enabled', 'disabled', 'manuallyDisabled'] },
733
- disabled: {
734
- type: 'object',
735
- properties: {
736
- at: datetime(),
737
- reason: { type: 'string', trim: true },
738
- },
739
- required: ['at', 'reason'],
740
- additionalProperties: false,
741
- },
742
- manuallyDisabled: {
743
- type: 'object',
744
- properties: {
745
- _id: uuid(),
746
- at: datetime(),
747
- to: datetime(),
748
- reason: { type: 'string', trim: true },
749
- },
750
- required: ['at', 'reason'],
751
- additionalProperties: false,
752
- },
753
- },
754
- required: ['code'],
755
- additionalProperties: false,
756
- },
757
-
758
- // ✅ maxLength alineado con Nombre varchar(100)
759
- name: { type: 'string', trim: true, maxLength: 100 },
760
-
761
- address: {
762
- type: 'object',
763
- properties: {
764
- // ✅ Calle varchar(255)
765
- street: { type: 'string', trim: true, maxLength: 255 },
766
- // ✅ sin límite estricto en BD pero razonable
767
- door: { type: 'string', trim: true, maxLength: 20 },
768
- // ✅ cp varchar(15)
769
- postalCode: { type: 'string', trim: true, maxLength: 15 },
770
- // ✅ Poblacion varchar(100)
771
- locality: { type: 'string', trim: true, maxLength: 100 },
772
- // ✅ código país ISO 3166-1 alpha-2/3
773
- country: { type: 'string', trim: true, maxLength: 3 },
774
- access_descript_locker: { type: 'string', trim: true, maxLength: 500 },
775
- location: {
776
- type: 'object',
777
- properties: {
778
- geometry: {
779
- type: 'object',
780
- properties: {
781
- type: { type: 'string', enum: ['Point'] },
782
- coordinates: {
783
- type: 'array',
784
- items: { type: 'number' },
785
- minItems: 2,
786
- maxItems: 2,
787
- },
788
- },
789
- required: ['type', 'coordinates'],
790
- additionalProperties: false,
791
- },
792
- precision: { type: 'string' },
793
- },
794
- required: ['geometry'],
795
- additionalProperties: false,
796
- },
797
- },
798
- required: ['street', 'postalCode', 'locality', 'country', 'location'],
799
- additionalProperties: false,
800
- },
801
-
802
- openingSchedule: shop().properties.openingSchedule,
803
- timezone: shop().properties.timezone,
804
- activity: shop().properties.activity,
805
- eco: shop().properties.eco,
806
-
807
- fiscal: {
808
- type: 'object',
809
- properties: {
810
- // ✅ IBAN estándar máximo 34 caracteres
811
- iban: { type: 'string', trim: true, maxLength: 34 },
812
- // ✅ nombreComercial nvarchar(100)
813
- businessName: { type: 'string', trim: true, maxLength: 100 },
814
- // ✅ NIF/CIF español máximo 9 chars, margen para internacionales
815
- nif: { type: 'string', trim: true, maxLength: 20 },
816
- contacts: { type: 'array', items: contact() },
817
- address: {
818
- type: 'object',
819
- properties: {
820
- street: { type: 'string', trim: true, maxLength: 255 },
821
- door: { type: 'string', trim: true, maxLength: 20 },
822
- postalCode: { type: 'string', trim: true, maxLength: 15 },
823
- locality: { type: 'string', trim: true, maxLength: 100 },
824
- // ✅ añadido country que faltaba y causaba el 400
825
- country: { type: 'string', trim: true, maxLength: 3 },
826
- },
827
- required: ['street', 'postalCode', 'locality', 'country'],
828
- additionalProperties: false,
829
- },
830
- paymentMethod: { type: 'string', trim: true, maxLength: 50 },
831
- dueDays: { type: 'integer', minimum: 0 },
832
- // ✅ activity varchar(250) en BD relacional
833
- activity: { type: 'string', trim: true, maxLength: 50 },
834
- retention: { type: 'integer' },
835
- },
836
- required: ['iban', 'businessName', 'nif', 'contacts', 'address', 'dueDays', 'retention'],
837
- additionalProperties: false,
838
- },
839
-
840
- nxt: {
841
- type: 'object',
842
- properties: {
843
- // ✅ ParcelShopId varchar(100)
844
- parcelShopId: { type: 'string', maxLength: 100 },
845
- },
846
- required: ['parcelShopId'],
847
- additionalProperties: false,
848
- },
849
-
850
- // ✅ Campos _locker con límites alineados a BD
851
- // Calle varchar(255)
852
- direccion_locker: { type: 'string', trim: true, maxLength: 255 },
853
- // cp varchar(15)
854
- codpostal_locker: { type: 'string', trim: true, maxLength: 15 },
855
- // Poblacion varchar(100)
856
- ciudad_locker: { type: 'string', trim: true, maxLength: 100 },
857
- // ✅ lat/lng float en BD — rango geográfico válido
858
- longitud_locker: {
859
- type: 'number',
860
- minimum: -180,
861
- maximum: 180,
862
- description: 'Fuente de verdad para longitude — sobreescribe address.location.geometry.coordinates[0]',
863
- },
864
- latitud_locker: {
865
- type: 'number',
866
- minimum: -90,
867
- maximum: 90,
868
- description: 'Fuente de verdad para latitude — sobreescribe address.location.geometry.coordinates[1]',
869
- },
870
- // ✅ capacidad razonable como string numérico
871
- capacity_locker: { type: 'string', maxLength: 20 },
872
- access_descript_locker: { type: 'string', trim: true, maxLength: 500 },
718
+ // resto de campos tomados directamente del schema base locker()
719
+ ...pickProperties(locker(), [
720
+ 'status',
721
+ 'name',
722
+ 'address',
723
+ 'openingSchedule',
724
+ 'timezone',
725
+ 'activity',
726
+ 'eco',
727
+ 'fiscal',
728
+ 'nxt',
729
+ 'direccion_locker',
730
+ 'codpostal_locker',
731
+ 'ciudad_locker',
732
+ 'longitud_locker',
733
+ 'latitud_locker',
734
+ 'capacity_locker',
735
+ 'access_descript_locker',
736
+ ]),
873
737
  },
874
738
  required: [
875
739
  'network',
@@ -886,295 +750,82 @@ const createLockerRequest = () =>
886
750
  ],
887
751
  additionalProperties: false,
888
752
  },
889
-
890
- locker: {
891
- title: 'locker',
892
- type: 'object',
893
- properties: {
894
-
895
- provider: {
896
- type: 'object',
897
- properties: {
898
- // ✅ PartnerKey varchar(100)
899
- name: { type: 'string', trim: true, maxLength: 100 },
900
- lockerVersion: { type: 'string', trim: true, maxLength: 20 },
901
- lockerModel: { type: 'string', trim: true, maxLength: 100 },
902
- },
903
- required: ['name'],
904
- additionalProperties: false,
905
- },
906
-
907
- location: {
908
- type: 'object',
909
- properties: {
910
- streetNumber: { type: 'string', trim: true, maxLength: 20 },
911
- // ✅ Calle varchar(255)
912
- street: { type: 'string', trim: true, maxLength: 255 },
913
- // ✅ cp varchar(15)
914
- postalCode: { type: 'string', trim: true, maxLength: 15 },
915
- // ✅ float en BD
916
- lon: { type: 'number', minimum: -180, maximum: 180 },
917
- lat: { type: 'number', minimum: -90, maximum: 90 },
918
- // ✅ ya tenía minLength:2 maxLength:2 — correcto para ISO 3166-1 alpha-2
919
- countryCode: { type: 'string', trim: true, minLength: 2, maxLength: 2 },
920
- // ✅ Poblacion varchar(100)
921
- city: { type: 'string', trim: true, maxLength: 100 },
922
- },
923
- required: ['street', 'postalCode', 'countryCode', 'city'],
924
- additionalProperties: false,
925
- },
926
-
927
- features: {
928
- type: 'object',
929
- properties: {
930
- hasScreen: { type: 'boolean' },
931
- hasPinPad: { type: 'boolean' },
932
- hasPinBarcodeReader: { type: 'boolean' },
933
- },
934
- additionalProperties: false,
935
- },
936
-
937
- carrier: {
938
- type: 'object',
939
- properties: {
940
- // ✅ Nombre varchar(100)
941
- lockerName: { type: 'string', trim: true, maxLength: 100 },
942
- activationDate: { type: 'string', format: 'date-time' },
943
- // ✅ UUID = 36 chars
944
- lockerId: { type: 'string', maxLength: 36 },
945
- },
946
- required: ['lockerName', 'lockerId'],
947
- additionalProperties: false,
948
- },
949
-
950
- },
951
- required: ['provider', 'location', 'carrier'],
952
- additionalProperties: false,
953
- },
954
-
753
+ locker: lockerNxt(),
955
754
  },
956
755
  required: ['parcelshop', 'locker'],
957
756
  additionalProperties: false,
958
757
  });
959
758
 
960
-
961
-
962
-
963
-
964
-
965
-
966
-
967
-
968
-
969
759
  const createLockerResponse = () => createResponse(locker());
970
760
 
761
+ // ── updateLockerRequest ───────────────────────────────────────────────────────
762
+ // Mismo patrón que updateShopRequest:
763
+ // - findByStringId() como find (el _id del locker es string numérico, no UUID)
764
+ // - pickProperties(locker(), [...]) con schemaOrNull para el set parcial
765
+ // - setShopRepresentative() / setShopStatus() para representantes y status
766
+ // - lockerNxtUpdate() para el sub-objeto hardware (lockerId no obligatorio)
767
+
971
768
  const updateLockerRequest = () =>
972
769
  updateRequest(
973
- // ── find: busca el locker por su _id (UUID) ──────────────────────────────
974
- findById(),
770
+ // find: _id no es UUID, es string numérico tipo "6237514999"
771
+ findByStringId(),
975
772
 
976
- // ── set: campos actualizables — todos opcionales (patch parcial) ─────────
773
+ // set: todos los campos opcionales (patch parcial)
977
774
  {
978
775
  type: 'object',
979
776
  properties: {
980
- network: schemaOrNull(objectWithUuid()),
981
- zone: schemaOrNull(objectWithUuid()),
982
- openingRepresentative: schemaOrNull(setShopRepresentative()),
777
+ // relaciones y representantes con helpers reutilizados de shop
778
+ network: schemaOrNull(objectWithUuid()),
779
+ zone: schemaOrNull(objectWithUuid()),
780
+ openingRepresentative: schemaOrNull(setShopRepresentative()),
983
781
  managingRepresentative: schemaOrNull(setShopRepresentative()),
984
- status: setShopStatus(),
985
-
986
- // ✅ Nombre varchar(100) — ps_puntos Apolo
987
- name: schemaOrNull({ type: 'string', trim: true, maxLength: 100 }),
988
-
989
- address: schemaOrNull({
990
- type: 'object',
991
- properties: {
992
- // ✅ Calle varchar(255) — ps_puntos Apolo
993
- street: { type: 'string', trim: true, maxLength: 255 },
994
- door: { type: 'string', trim: true, maxLength: 20 },
995
- // ✅ cp varchar(15) — ps_puntos Apolo
996
- postalCode: { type: 'string', trim: true, maxLength: 15 },
997
- // ✅ Poblacion varchar(100) — ps_puntos Apolo
998
- locality: { type: 'string', trim: true, maxLength: 100 },
999
- // ✅ ISO 3166-1 alpha-2
1000
- country: { type: 'string', trim: true, maxLength: 3 },
1001
- access_descript_locker: { type: 'string', trim: true, maxLength: 500 },
1002
- location: {
1003
- type: 'object',
1004
- properties: {
1005
- geometry: {
1006
- type: 'object',
1007
- properties: {
1008
- type: { type: 'string', enum: ['Point'] },
1009
- coordinates: {
1010
- type: 'array',
1011
- items: { type: 'number' },
1012
- minItems: 2,
1013
- maxItems: 2,
1014
- },
1015
- },
1016
- required: ['type', 'coordinates'],
1017
- additionalProperties: false,
1018
- },
1019
- precision: { type: 'string' },
1020
- },
1021
- required: ['geometry'],
1022
- additionalProperties: false,
1023
- },
1024
- },
1025
- required: ['street', 'postalCode', 'locality', 'country', 'location'],
1026
- additionalProperties: false,
1027
- }),
1028
-
1029
- openingSchedule: schemaOrNull(shop().properties.openingSchedule),
1030
- timezone: schemaOrNull(shop().properties.timezone),
1031
- activity: schemaOrNull(shop().properties.activity),
1032
- eco: schemaOrNull(shop().properties.eco),
1033
-
1034
- fiscal: schemaOrNull({
1035
- type: 'object',
1036
- properties: {
1037
- // ✅ IBAN estándar 34 chars
1038
- iban: { type: 'string', trim: true, maxLength: 34 },
1039
- // ✅ nombreComercial nvarchar(100) — ps_puntos Apolo
1040
- businessName: { type: 'string', trim: true, maxLength: 100 },
1041
- // ✅ NIF/CIF máximo 20 chars
1042
- nif: { type: 'string', trim: true, maxLength: 20 },
1043
- contacts: { type: 'array', items: contact() },
1044
- address: {
1045
- type: 'object',
1046
- properties: {
1047
- street: { type: 'string', trim: true, maxLength: 255 },
1048
- door: { type: 'string', trim: true, maxLength: 20 },
1049
- postalCode: { type: 'string', trim: true, maxLength: 15 },
1050
- locality: { type: 'string', trim: true, maxLength: 100 },
1051
- // ✅ country declarado explícitamente — evita additionalProperties 400
1052
- country: { type: 'string', trim: true, maxLength: 3 },
1053
- },
1054
- required: ['street', 'postalCode', 'locality', 'country'],
1055
- additionalProperties: false,
1056
- },
1057
- paymentMethod: { type: 'string', trim: true, maxLength: 50 },
1058
- dueDays: { type: 'integer', minimum: 0 },
1059
- activity: { type: 'string', trim: true, maxLength: 50 },
1060
- retention: { type: 'integer' },
1061
- },
1062
- required: ['iban', 'businessName', 'nif', 'contacts', 'address', 'dueDays', 'retention'],
1063
- additionalProperties: false,
1064
- }),
1065
-
1066
- nxt: schemaOrNull({
1067
- type: 'object',
1068
- properties: {
1069
- // ✅ ParcelShopId varchar(100) — ps_puntos Apolo
1070
- parcelShopId: { type: 'string', maxLength: 100 },
1071
- },
1072
- required: ['parcelShopId'],
1073
- additionalProperties: false,
1074
- }),
1075
-
1076
- // ✅ Campos _locker — fuente de verdad para coordenadas y dirección
1077
- // Calle varchar(255) — ps_puntos Apolo
1078
- direccion_locker: schemaOrNull({ type: 'string', trim: true, maxLength: 255 }),
1079
- // cp varchar(15) — ps_puntos Apolo
1080
- codpostal_locker: schemaOrNull({ type: 'string', trim: true, maxLength: 15 }),
1081
- // Poblacion varchar(100) — ps_puntos Apolo
1082
- ciudad_locker: schemaOrNull({ type: 'string', trim: true, maxLength: 100 }),
1083
- // ✅ float — rango geográfico válido, ps_puntos Apolo
1084
- longitud_locker: schemaOrNull({
1085
- type: 'number',
1086
- minimum: -180,
1087
- maximum: 180,
1088
- description: 'Fuente de verdad para longitude — sobreescribe address.location.geometry.coordinates[0]',
1089
- }),
1090
- latitud_locker: schemaOrNull({
1091
- type: 'number',
1092
- minimum: -90,
1093
- maximum: 90,
1094
- description: 'Fuente de verdad para latitude — sobreescribe address.location.geometry.coordinates[1]',
1095
- }),
1096
- capacity_locker: schemaOrNull({ type: 'string', maxLength: 20 }),
1097
- access_descript_locker: schemaOrNull({ type: 'string', trim: true, maxLength: 500 }),
1098
-
1099
- // ── Objeto locker (NXT) ──────────────────────────────────────────────
1100
- locker: schemaOrNull({
1101
- title: 'locker',
1102
- type: 'object',
1103
- properties: {
1104
-
1105
- provider: {
1106
- type: 'object',
1107
- properties: {
1108
- // ✅ PartnerKey varchar(100) — ps_puntos Apolo
1109
- name: { type: 'string', trim: true, maxLength: 100 },
1110
- lockerVersion: { type: 'string', trim: true, maxLength: 20 },
1111
- lockerModel: { type: 'string', trim: true, maxLength: 100 },
1112
- },
1113
- required: ['name'],
1114
- additionalProperties: false,
1115
- },
1116
-
1117
- location: {
1118
- type: 'object',
1119
- properties: {
1120
- streetNumber: { type: 'string', trim: true, maxLength: 20 },
1121
- // ✅ Calle varchar(255) — ps_puntos Apolo
1122
- street: { type: 'string', trim: true, maxLength: 255 },
1123
- // ✅ cp varchar(15) — ps_puntos Apolo
1124
- postalCode: { type: 'string', trim: true, maxLength: 15 },
1125
- // ✅ float — rango geográfico válido
1126
- lon: { type: 'number', minimum: -180, maximum: 180 },
1127
- lat: { type: 'number', minimum: -90, maximum: 90 },
1128
- // ✅ ISO 3166-1 alpha-2 — minLength/maxLength: 2
1129
- countryCode: { type: 'string', trim: true, minLength: 2, maxLength: 2 },
1130
- // ✅ Poblacion varchar(100) — ps_puntos Apolo
1131
- city: { type: 'string', trim: true, maxLength: 100 },
1132
- },
1133
- required: ['street', 'postalCode', 'countryCode', 'city'],
1134
- additionalProperties: false,
1135
- },
1136
-
1137
- features: {
1138
- type: 'object',
1139
- properties: {
1140
- hasScreen: { type: 'boolean' },
1141
- hasPinPad: { type: 'boolean' },
1142
- hasPinBarcodeReader: { type: 'boolean' },
1143
- },
1144
- additionalProperties: false,
1145
- },
1146
-
1147
- carrier: {
1148
- type: 'object',
1149
- properties: {
1150
- // ✅ Nombre varchar(100) — ps_puntos Apolo
1151
- lockerName: { type: 'string', trim: true, maxLength: 100 },
1152
- activationDate: { type: 'string', format: 'date-time' },
1153
- // ✅ UUID 36 chars
1154
- lockerId: { type: 'string', maxLength: 36 },
1155
- },
1156
- required: ['lockerName', 'lockerId'],
1157
- additionalProperties: false,
1158
- },
782
+ status: setShopStatus(),
783
+
784
+ // campos actualizables del schema base locker() — todos con schemaOrNull
785
+ ...Object.fromEntries(
786
+ Object.entries(
787
+ pickProperties(locker(), [
788
+ 'name',
789
+ 'address',
790
+ 'openingSchedule',
791
+ 'timezone',
792
+ 'activity',
793
+ 'eco',
794
+ 'fiscal',
795
+ 'nxt',
796
+ 'direccion_locker',
797
+ 'codpostal_locker',
798
+ 'ciudad_locker',
799
+ 'longitud_locker',
800
+ 'latitud_locker',
801
+ 'capacity_locker',
802
+ 'access_descript_locker',
803
+ ])
804
+ ).map(([key, schema]) => [key, schemaOrNull(schema)])
805
+ ),
1159
806
 
1160
- },
1161
- required: ['provider', 'location', 'carrier'],
1162
- additionalProperties: false,
1163
- }),
807
+ // capabilities: array, no nullable — va sin schemaOrNull
808
+ capabilities: {
809
+ type: 'array',
810
+ items: { type: 'string', enum: ['deliver', 'pickup', 'sell', 'sellplus'] },
811
+ uniqueItems: true,
812
+ },
1164
813
 
814
+ // sub-objeto hardware NXT con variante update (lockerId no obligatorio)
815
+ locker: schemaOrNull(lockerNxtUpdate()),
1165
816
  },
1166
- minProperties: 0, // permite updates parciales — ningún campo es obligatorio en el set
817
+ minProperties: 0, // permite updates parciales — ningún campo es obligatorio en el set
1167
818
  additionalProperties: false,
1168
819
  },
1169
820
  );
1170
821
 
1171
822
  const updateLockerResponse = () => updateResponse(locker());
1172
823
 
1173
-
1174
-
1175
824
  module.exports = {
1176
825
  shop,
1177
826
  locker,
827
+ lockerNxt,
828
+ lockerNxtUpdate,
1178
829
  objectWithShopId,
1179
830
  createShopRequest,
1180
831
  createShopResponse,
@@ -1191,4 +842,4 @@ module.exports = {
1191
842
  createLockerResponse,
1192
843
  updateLockerRequest,
1193
844
  updateLockerResponse,
1194
- };
845
+ };