@gls_spain/gps-common 27.1.1 → 28.0.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.
@@ -24,7 +24,7 @@ const network = () => ({
24
24
  updatedAt: datetime(),
25
25
  deletable: { type: 'boolean' },
26
26
  defaults: defaults(),
27
- name: { type: 'string' },
27
+ name: { type: 'string', trim: true },
28
28
  integrations: { type: 'array', items: { type: 'string', enum: ['gls'] }, uniqueItems: true },
29
29
  contacts: {
30
30
  type: 'array',
@@ -27,10 +27,10 @@ const representative = () => ({
27
27
  createdAt: datetime(),
28
28
  updatedAt: datetime(),
29
29
  deletable: { type: 'boolean' },
30
- name: { type: 'string' },
30
+ name: { type: 'string', trim: true },
31
31
  emails: { type: 'array', items: email(), uniqueItems: true },
32
32
  phones: { type: 'array', items: phone(), uniqueItems: true },
33
- nif: { type: 'string' },
33
+ nif: { type: 'string', trim: true },
34
34
  zones: {
35
35
  type: 'array',
36
36
  items: {
@@ -116,7 +116,7 @@ const shop = () => ({
116
116
  type: 'object',
117
117
  properties: {
118
118
  at: datetime(),
119
- reason: { type: 'string' },
119
+ reason: { type: 'string', trim: true },
120
120
  },
121
121
  required: ['at', 'reason'],
122
122
  additionalProperties: false,
@@ -125,7 +125,7 @@ const shop = () => ({
125
125
  type: 'object',
126
126
  properties: {
127
127
  at: datetime(),
128
- reason: { type: 'string' },
128
+ reason: { type: 'string', trim: true },
129
129
  },
130
130
  required: ['at', 'reason'],
131
131
  additionalProperties: false,
@@ -134,7 +134,7 @@ const shop = () => ({
134
134
  required: ['code'],
135
135
  additionalProperties: false,
136
136
  },
137
- name: { type: 'string' },
137
+ name: { type: 'string', trim: true },
138
138
  address: addressWithRequiredLocation(),
139
139
  capabilities: {
140
140
  type: 'array',
@@ -148,7 +148,7 @@ const shop = () => ({
148
148
  items: contact(),
149
149
  },
150
150
  fiscal: fiscal(),
151
- notes: { type: 'string' },
151
+ notes: { type: 'string', trim: true },
152
152
  derivationSettings: derivationSettings(),
153
153
  expirationSettings: expirationSettings(),
154
154
  },
@@ -36,10 +36,10 @@ const baseUser = () => ({
36
36
  loginEnabled: { type: 'boolean' },
37
37
  integrations: { type: 'array', items: { type: 'string', enum: ['glsApi', 'canReceiveAllFromDriver'] }, uniqueItems: true },
38
38
  role: { type: 'string' },
39
- name: { type: 'string' },
39
+ name: { type: 'string', trim: true },
40
40
  emails: { type: 'array', items: email(), uniqueItems: true },
41
41
  phones: { type: 'array', items: phone(), uniqueItems: true },
42
- nif: { type: 'string' },
42
+ nif: { type: 'string', trim: true },
43
43
  address: address(),
44
44
  },
45
45
  required: ['_id', 'createdAt', 'updatedAt', 'username', 'deletable', 'loginEnabled', 'integrations', 'role', 'name', 'emails', 'phones'],
@@ -22,7 +22,7 @@ const zone = () => ({
22
22
  createdAt: datetime(),
23
23
  updatedAt: datetime(),
24
24
  deletable: { type: 'boolean' },
25
- name: { type: 'string' },
25
+ name: { type: 'string', trim: true },
26
26
  commissions: {
27
27
  type: 'object',
28
28
  properties: {
package/schemas/index.js CHANGED
@@ -58,7 +58,8 @@ const {
58
58
  const {
59
59
  createExpeditionRequest,
60
60
  createExpeditionResponse,
61
- findExpeditionsRequest,
61
+ findExpeditionsSuperAdminRequest,
62
+ findExpeditionsNetworkAdminAndShopUserRequest,
62
63
  findExpeditionsResponse,
63
64
  updateExpeditionRequest,
64
65
  updateExpeditionResponse,
@@ -75,7 +76,6 @@ const {
75
76
  receiveAllExpeditionsFromDriverResponse,
76
77
  } = require('./definitions/expeditions');
77
78
  const { findPodsRequest, findPodsResponse } = require('./definitions/pods');
78
- const { findJobsRequest, findExpeditionJobsResponse, findShopsJobsResponse, findNetworksJobsResponse } = require('./definitions/jobs');
79
79
  const {
80
80
  createRepresentativeRequest,
81
81
  createRepresentativeResponse,
@@ -100,6 +100,8 @@ const {
100
100
  deleteZoneRequest,
101
101
  deleteZoneResponse,
102
102
  } = require('./definitions/zones');
103
+ const { findIntegrationsRequest, findIntegrationsResponse } = require('./definitions/integrations');
104
+ const { findHistoricRecordsRequest, findHistoricRecordsResponse } = require('./definitions/historic-records');
103
105
 
104
106
  function request(schema, $id) {
105
107
  return addMetadata(schema, $id);
@@ -173,7 +175,11 @@ const shopUsersDeleteResponse = response(deleteShopUserResponse(), 'shopUsersDel
173
175
 
174
176
  const expeditionsCreateRequest = request(createExpeditionRequest(), 'expeditionsCreateRequest');
175
177
  const expeditionsCreateResponse = response(createExpeditionResponse(), 'expeditionsCreateResponse');
176
- const expeditionsFindRequest = request(findExpeditionsRequest(), 'expeditionsFindRequest');
178
+ const expeditionsFindSuperAdminRequest = request(findExpeditionsSuperAdminRequest(), 'expeditionsFindSuperAdminRequest');
179
+ const expeditionsFindNetworkAdminAndShopUserRequest = request(
180
+ findExpeditionsNetworkAdminAndShopUserRequest(),
181
+ 'expeditionsFindNetworkAdminAndShopUserRequest',
182
+ );
177
183
  const expeditionsFindResponse = response(findExpeditionsResponse(), 'expeditionsFindResponse');
178
184
  const expeditionsUpdateRequest = request(updateExpeditionRequest(), 'expeditionsUpdateRequest');
179
185
  const expeditionsUpdateResponse = response(updateExpeditionResponse(), 'expeditionsUpdateResponse');
@@ -195,11 +201,6 @@ const expeditionsReceiveAllFromDriverResponse = response(
195
201
  const podsFindRequest = request(findPodsRequest(), 'podsFindRequest');
196
202
  const podsFindResponse = response(findPodsResponse(), 'podsFindResponse');
197
203
 
198
- const jobsFindRequest = request(findJobsRequest(), 'jobsFindRequest');
199
- const jobsFindExpeditionsResponse = response(findExpeditionJobsResponse(), 'jobsFindExpeditionsResponse');
200
- const jobsFindShopsResponse = response(findShopsJobsResponse(), 'jobsFindShopsResponse');
201
- const jobsFindNetworksResponse = response(findNetworksJobsResponse(), 'jobsFindNetworksResponse');
202
-
203
204
  const representativesCreateRequest = request(createRepresentativeRequest(), 'representativesCreateRequest');
204
205
  const representativesCreateResponse = response(createRepresentativeResponse(), 'representativesCreateResponse');
205
206
  const representativesListNamesResponse = response(listRepresentativesNamesResponse(), 'representativesListNamesResponse');
@@ -222,6 +223,12 @@ const zonesUpdateResponse = response(updateZoneResponse(), 'zonesUpdateResponse'
222
223
  const zonesDeleteRequest = request(deleteZoneRequest(), 'zonesDeleteRequest');
223
224
  const zonesDeleteResponse = response(deleteZoneResponse(), 'zonesDeleteResponse');
224
225
 
226
+ const integrationsFindRequest = request(findIntegrationsRequest(), 'integrationsFindRequest');
227
+ const integrationsFindResponse = response(findIntegrationsResponse(), 'integrationsFindResponse');
228
+
229
+ const historicRecordsFindRequest = request(findHistoricRecordsRequest(), 'historicRecordsFindRequest');
230
+ const historicRecordsFindResponse = response(findHistoricRecordsResponse(), 'historicRecordsFindResponse');
231
+
225
232
  module.exports = {
226
233
  errorResponse,
227
234
 
@@ -287,7 +294,8 @@ module.exports = {
287
294
 
288
295
  expeditionsCreateRequest,
289
296
  expeditionsCreateResponse,
290
- expeditionsFindRequest,
297
+ expeditionsFindSuperAdminRequest,
298
+ expeditionsFindNetworkAdminAndShopUserRequest,
291
299
  expeditionsFindResponse,
292
300
  expeditionsUpdateRequest,
293
301
  expeditionsUpdateResponse,
@@ -306,11 +314,6 @@ module.exports = {
306
314
  podsFindRequest,
307
315
  podsFindResponse,
308
316
 
309
- jobsFindRequest,
310
- jobsFindExpeditionsResponse,
311
- jobsFindShopsResponse,
312
- jobsFindNetworksResponse,
313
-
314
317
  representativesCreateRequest,
315
318
  representativesCreateResponse,
316
319
  representativesListNamesResponse,
@@ -332,4 +335,10 @@ module.exports = {
332
335
  zonesUpdateResponse,
333
336
  zonesDeleteRequest,
334
337
  zonesDeleteResponse,
338
+
339
+ integrationsFindRequest,
340
+ integrationsFindResponse,
341
+
342
+ historicRecordsFindRequest,
343
+ historicRecordsFindResponse,
335
344
  };
@@ -1,124 +0,0 @@
1
- const { uuid, datetime, datetimeRange, findRequest, findResponse, mergeSchemas } = require('@gls_spain/common-json-schemas');
2
- const {
3
- receiveFromDriverEvent,
4
- receiveFromCustomerEvent,
5
- giveToCustomerEvent,
6
- giveToDriverEvent,
7
- expirationReminderEvent,
8
- expiredEvent,
9
- priceEvent,
10
- upsertShopEvent,
11
- upsertNetworkEvent,
12
- } = require('./integration-events');
13
-
14
- const job = () => ({
15
- type: 'object',
16
- properties: {
17
- _id: uuid(),
18
- createdAt: datetime(),
19
- processAt: datetime(),
20
- status: { type: 'string', enum: ['pending', 'completed', 'failed'] },
21
- results: {
22
- type: 'array',
23
- items: {
24
- oneOf: [
25
- {
26
- title: 'success',
27
- type: 'object',
28
- properties: {
29
- at: datetime(),
30
- success: { type: 'string' },
31
- },
32
- required: ['at', 'success'],
33
- additionalProperties: false,
34
- },
35
- {
36
- title: 'error',
37
- type: 'object',
38
- properties: {
39
- at: datetime(),
40
- error: { type: 'string' },
41
- },
42
- required: ['at', 'error'],
43
- additionalProperties: false,
44
- },
45
- ],
46
- },
47
- description: 'the result of each try to process the job',
48
- },
49
- payload: { type: 'object' },
50
- },
51
- required: ['_id', 'createdAt', 'processAt', 'status', 'results', 'payload'],
52
- additionalProperties: false,
53
- });
54
-
55
- const consistencyJob = () =>
56
- mergeSchemas(job(), {
57
- properties: {
58
- payload: {
59
- type: 'object',
60
- properties: {
61
- collection: { type: 'string' },
62
- _id: uuid(),
63
- },
64
- required: ['collection', '_id'],
65
- additionalProperties: true,
66
- },
67
- },
68
- });
69
-
70
- const expeditionJob = () =>
71
- mergeSchemas(job(), {
72
- properties: {
73
- payload: {
74
- oneOf: [
75
- receiveFromDriverEvent(),
76
- receiveFromCustomerEvent(),
77
- giveToCustomerEvent(),
78
- giveToDriverEvent(),
79
- expirationReminderEvent(),
80
- expiredEvent(),
81
- priceEvent(),
82
- ],
83
- },
84
- },
85
- });
86
-
87
- const shopJob = () =>
88
- mergeSchemas(job(), {
89
- properties: { payload: upsertShopEvent() },
90
- });
91
-
92
- const networkJob = () =>
93
- mergeSchemas(job(), {
94
- properties: { payload: upsertNetworkEvent() },
95
- });
96
-
97
- const findByStatusAndProcessAt = () => ({
98
- title: 'find by status and processAt',
99
- type: 'object',
100
- properties: {
101
- status: job().properties.status,
102
- processAtRange: datetimeRange(),
103
- },
104
- required: ['status', 'processAtRange'],
105
- additionalProperties: false,
106
- });
107
-
108
- const findJobsRequest = () => findRequest(findByStatusAndProcessAt());
109
-
110
- const findExpeditionJobsResponse = () => findResponse(expeditionJob());
111
-
112
- const findShopsJobsResponse = () => findResponse(shopJob());
113
-
114
- const findNetworksJobsResponse = () => findResponse(networkJob());
115
-
116
- module.exports = {
117
- job,
118
- consistencyJob,
119
- expeditionJob,
120
- findJobsRequest,
121
- findExpeditionJobsResponse,
122
- findShopsJobsResponse,
123
- findNetworksJobsResponse,
124
- };