@gls_spain/gps-common 34.9.2 → 34.9.3
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/.eslintignore +1 -1
- package/.eslintrc.json +11 -11
- package/.idea/codeStyles/Project.xml +36 -36
- package/.idea/codeStyles/codeStyleConfig.xml +4 -4
- package/.idea/gps-common.iml +11 -11
- package/.idea/inspectionProfiles/Project_Default.xml +6 -6
- package/.idea/jsLibraryMappings.xml +5 -5
- package/.idea/misc.xml +5 -5
- package/.idea/modules.xml +7 -7
- package/.idea/prettier.xml +6 -6
- package/.idea/scopes/Source_files.xml +2 -2
- package/.idea/vcs.xml +5 -5
- package/.prettierignore +4 -4
- package/.prettierrc.json +13 -13
- package/.releaserc +17 -17
- package/CHANGELOG.md +1264 -1257
- package/README.md +103 -103
- package/errors/CountersDoNotExistError.js +11 -11
- package/errors/DatabaseNotEmptyError.js +11 -11
- package/errors/DefaultsDoNotExistError.js +11 -11
- package/errors/ExpeditionAlreadyExistsError.js +11 -11
- package/errors/ExpeditionCannotBeDeletedError.js +11 -11
- package/errors/ExpeditionCannotBeUpdatedError.js +11 -11
- package/errors/ExpeditionDoesNotExistError.js +11 -11
- package/errors/GLSRecordingError.js +11 -11
- package/errors/GLSSpainError.js +11 -11
- package/errors/InconsistentSalesSettingsError.js +11 -11
- package/errors/InvalidSaleDestinationError.js +11 -11
- package/errors/LabelDoesNotExistError.js +11 -11
- package/errors/NetworkAlreadyExistsError.js +11 -11
- package/errors/NetworkCannotBeDeletedError.js +11 -11
- package/errors/NetworkCannotBeUpdatedError.js +11 -11
- package/errors/NetworkDoesNotExistError.js +11 -11
- package/errors/RepresentativeAlreadyExistsError.js +11 -11
- package/errors/RepresentativeCannotBeDeletedError.js +11 -11
- package/errors/RepresentativeDoesNotExistError.js +11 -11
- package/errors/SaleAlreadyExistsError.js +11 -11
- package/errors/SaleDoesNotExistError.js +11 -11
- package/errors/ShopAlreadyExistsError.js +11 -11
- package/errors/ShopCannotBeDeletedError.js +11 -11
- package/errors/ShopCannotBeUpdatedError.js +11 -11
- package/errors/ShopCannotSellError.js +11 -11
- package/errors/ShopDoesNotExistError.js +11 -11
- package/errors/ShopNotEnabledError.js +11 -11
- package/errors/UserAlreadyExistsError.js +11 -11
- package/errors/UserCannotBeDeletedError.js +11 -11
- package/errors/UserCannotBeUpdatedError.js +11 -11
- package/errors/UserDoesNotExistError.js +11 -11
- package/errors/WrongNetworkError.js +11 -11
- package/errors/WrongPasswordError.js +11 -11
- package/errors/WrongShopError.js +11 -11
- package/errors/ZoneAlreadyExistsError.js +11 -11
- package/errors/ZoneCannotBeDeletedError.js +11 -11
- package/errors/ZoneDoesNotExistError.js +11 -11
- package/errors/index.js +118 -118
- package/index.js +9 -9
- package/index.test.js +36 -36
- package/jest.config.js +5 -5
- package/open-api-spec/index.js +3715 -3715
- package/package.json +65 -69
- package/schemas/definitions/become.js +5 -5
- package/schemas/definitions/common.js +462 -451
- package/schemas/definitions/counters.js +43 -43
- package/schemas/definitions/defaults.js +140 -140
- package/schemas/definitions/expeditions.js +867 -867
- package/schemas/definitions/gls-spain-integration-events.js +139 -139
- package/schemas/definitions/historic-records.js +90 -90
- package/schemas/definitions/integrations.js +38 -38
- package/schemas/definitions/login.js +38 -38
- package/schemas/definitions/logout.js +8 -8
- package/schemas/definitions/networks.js +123 -123
- package/schemas/definitions/pods.js +26 -26
- package/schemas/definitions/representatives.js +194 -194
- package/schemas/definitions/sales.js +253 -249
- package/schemas/definitions/shops.js +404 -404
- package/schemas/definitions/users.js +337 -337
- package/schemas/definitions/zones.js +92 -92
- package/schemas/index.js +400 -400
- package/scripts/build-documentation.js +40 -40
- package/scripts/build-json-schemas.js +35 -35
- package/.idea/workspace.xml +0 -699
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
const { mergeSchemas } = require('@gls_spain/common-json-schemas');
|
|
2
|
-
const { date } = require('./common');
|
|
3
|
-
const { expedition, processedWithDriver, processedWithCustomerWithPod } = require('./expeditions');
|
|
4
|
-
const { shop, objectWithShopId } = require('./shops');
|
|
5
|
-
const { network, objectWithNetworkId } = require('./networks');
|
|
6
|
-
const { sale } = require('./sales');
|
|
7
|
-
|
|
8
|
-
const objectWithExpirationDate = () => ({
|
|
9
|
-
type: 'object',
|
|
10
|
-
properties: { expirationDate: date() },
|
|
11
|
-
required: ['expirationDate'],
|
|
12
|
-
additionalProperties: false,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const receiveFromDriverEvent = () => ({
|
|
16
|
-
title: 'receive from driver',
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {
|
|
19
|
-
_id: expedition().properties._id,
|
|
20
|
-
receiveFromDriver: mergeSchemas(processedWithDriver(), objectWithShopId(), objectWithNetworkId(), objectWithExpirationDate()),
|
|
21
|
-
expedition: expedition(),
|
|
22
|
-
},
|
|
23
|
-
required: ['_id', 'receiveFromDriver', 'expedition'],
|
|
24
|
-
additionalProperties: false,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const receiveFromCustomerEvent = () => ({
|
|
28
|
-
title: 'receive from customer',
|
|
29
|
-
type: 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
_id: expedition().properties._id,
|
|
32
|
-
receiveFromCustomer: mergeSchemas(processedWithCustomerWithPod(), objectWithShopId(), objectWithNetworkId()),
|
|
33
|
-
expedition: expedition(),
|
|
34
|
-
},
|
|
35
|
-
required: ['_id', 'receiveFromCustomer', 'expedition'],
|
|
36
|
-
additionalProperties: false,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const giveToCustomerEvent = () => ({
|
|
40
|
-
title: 'give to customer',
|
|
41
|
-
type: 'object',
|
|
42
|
-
properties: {
|
|
43
|
-
_id: expedition().properties._id,
|
|
44
|
-
giveToCustomer: mergeSchemas(processedWithCustomerWithPod(), objectWithShopId(), objectWithNetworkId()),
|
|
45
|
-
expedition: expedition(),
|
|
46
|
-
},
|
|
47
|
-
required: ['_id', 'giveToCustomer', 'expedition'],
|
|
48
|
-
additionalProperties: false,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const giveToDriverEvent = () => ({
|
|
52
|
-
title: 'give to driver',
|
|
53
|
-
type: 'object',
|
|
54
|
-
properties: {
|
|
55
|
-
_id: expedition().properties._id,
|
|
56
|
-
giveToDriver: mergeSchemas(processedWithDriver(), objectWithShopId(), objectWithNetworkId()),
|
|
57
|
-
expedition: expedition(),
|
|
58
|
-
},
|
|
59
|
-
required: ['_id', 'giveToDriver', 'expedition'],
|
|
60
|
-
additionalProperties: false,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const expirationReminderEvent = () => ({
|
|
64
|
-
title: 'expiration reminder',
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
_id: expedition().properties._id,
|
|
68
|
-
expirationReminder: mergeSchemas(objectWithExpirationDate(), objectWithShopId(), objectWithNetworkId()),
|
|
69
|
-
expedition: expedition(),
|
|
70
|
-
},
|
|
71
|
-
required: ['_id', 'expirationReminder', 'expedition'],
|
|
72
|
-
additionalProperties: false,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const expiredEvent = () => ({
|
|
76
|
-
title: 'expired',
|
|
77
|
-
type: 'object',
|
|
78
|
-
properties: {
|
|
79
|
-
_id: expedition().properties._id,
|
|
80
|
-
expired: mergeSchemas(objectWithExpirationDate(), objectWithShopId(), objectWithNetworkId()),
|
|
81
|
-
expedition: expedition(),
|
|
82
|
-
},
|
|
83
|
-
required: ['_id', 'expired', 'expedition'],
|
|
84
|
-
additionalProperties: false,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const priceEvent = () => ({
|
|
88
|
-
title: 'price',
|
|
89
|
-
type: 'object',
|
|
90
|
-
properties: {
|
|
91
|
-
_id: expedition().properties._id,
|
|
92
|
-
price: mergeSchemas(objectWithShopId(), objectWithNetworkId(), {
|
|
93
|
-
properties: {
|
|
94
|
-
total: expedition().properties.derivation.properties.totalPrice,
|
|
95
|
-
},
|
|
96
|
-
required: ['total'],
|
|
97
|
-
}),
|
|
98
|
-
expedition: expedition(),
|
|
99
|
-
},
|
|
100
|
-
required: ['_id', 'price', 'expedition'],
|
|
101
|
-
additionalProperties: false,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const upsertShopEvent = () => ({
|
|
105
|
-
title: 'upsert shop',
|
|
106
|
-
type: 'object',
|
|
107
|
-
properties: { shop: shop() },
|
|
108
|
-
required: ['shop'],
|
|
109
|
-
additionalProperties: false,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const upsertNetworkEvent = () => ({
|
|
113
|
-
title: 'upsert network',
|
|
114
|
-
type: 'object',
|
|
115
|
-
properties: { network: network() },
|
|
116
|
-
required: ['network'],
|
|
117
|
-
additionalProperties: false,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const upsertSaleEvent = () => ({
|
|
121
|
-
title: 'upsert sale',
|
|
122
|
-
type: 'object',
|
|
123
|
-
properties: { sale: sale() },
|
|
124
|
-
required: ['sale'],
|
|
125
|
-
additionalProperties: false,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
module.exports = {
|
|
129
|
-
receiveFromDriverEvent,
|
|
130
|
-
receiveFromCustomerEvent,
|
|
131
|
-
giveToCustomerEvent,
|
|
132
|
-
giveToDriverEvent,
|
|
133
|
-
expirationReminderEvent,
|
|
134
|
-
expiredEvent,
|
|
135
|
-
priceEvent,
|
|
136
|
-
upsertShopEvent,
|
|
137
|
-
upsertNetworkEvent,
|
|
138
|
-
upsertSaleEvent,
|
|
139
|
-
};
|
|
1
|
+
const { mergeSchemas } = require('@gls_spain/common-json-schemas');
|
|
2
|
+
const { date } = require('./common');
|
|
3
|
+
const { expedition, processedWithDriver, processedWithCustomerWithPod } = require('./expeditions');
|
|
4
|
+
const { shop, objectWithShopId } = require('./shops');
|
|
5
|
+
const { network, objectWithNetworkId } = require('./networks');
|
|
6
|
+
const { sale } = require('./sales');
|
|
7
|
+
|
|
8
|
+
const objectWithExpirationDate = () => ({
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: { expirationDate: date() },
|
|
11
|
+
required: ['expirationDate'],
|
|
12
|
+
additionalProperties: false,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const receiveFromDriverEvent = () => ({
|
|
16
|
+
title: 'receive from driver',
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
_id: expedition().properties._id,
|
|
20
|
+
receiveFromDriver: mergeSchemas(processedWithDriver(), objectWithShopId(), objectWithNetworkId(), objectWithExpirationDate()),
|
|
21
|
+
expedition: expedition(),
|
|
22
|
+
},
|
|
23
|
+
required: ['_id', 'receiveFromDriver', 'expedition'],
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const receiveFromCustomerEvent = () => ({
|
|
28
|
+
title: 'receive from customer',
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
_id: expedition().properties._id,
|
|
32
|
+
receiveFromCustomer: mergeSchemas(processedWithCustomerWithPod(), objectWithShopId(), objectWithNetworkId()),
|
|
33
|
+
expedition: expedition(),
|
|
34
|
+
},
|
|
35
|
+
required: ['_id', 'receiveFromCustomer', 'expedition'],
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const giveToCustomerEvent = () => ({
|
|
40
|
+
title: 'give to customer',
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
_id: expedition().properties._id,
|
|
44
|
+
giveToCustomer: mergeSchemas(processedWithCustomerWithPod(), objectWithShopId(), objectWithNetworkId()),
|
|
45
|
+
expedition: expedition(),
|
|
46
|
+
},
|
|
47
|
+
required: ['_id', 'giveToCustomer', 'expedition'],
|
|
48
|
+
additionalProperties: false,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const giveToDriverEvent = () => ({
|
|
52
|
+
title: 'give to driver',
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
_id: expedition().properties._id,
|
|
56
|
+
giveToDriver: mergeSchemas(processedWithDriver(), objectWithShopId(), objectWithNetworkId()),
|
|
57
|
+
expedition: expedition(),
|
|
58
|
+
},
|
|
59
|
+
required: ['_id', 'giveToDriver', 'expedition'],
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const expirationReminderEvent = () => ({
|
|
64
|
+
title: 'expiration reminder',
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {
|
|
67
|
+
_id: expedition().properties._id,
|
|
68
|
+
expirationReminder: mergeSchemas(objectWithExpirationDate(), objectWithShopId(), objectWithNetworkId()),
|
|
69
|
+
expedition: expedition(),
|
|
70
|
+
},
|
|
71
|
+
required: ['_id', 'expirationReminder', 'expedition'],
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const expiredEvent = () => ({
|
|
76
|
+
title: 'expired',
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
_id: expedition().properties._id,
|
|
80
|
+
expired: mergeSchemas(objectWithExpirationDate(), objectWithShopId(), objectWithNetworkId()),
|
|
81
|
+
expedition: expedition(),
|
|
82
|
+
},
|
|
83
|
+
required: ['_id', 'expired', 'expedition'],
|
|
84
|
+
additionalProperties: false,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const priceEvent = () => ({
|
|
88
|
+
title: 'price',
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
_id: expedition().properties._id,
|
|
92
|
+
price: mergeSchemas(objectWithShopId(), objectWithNetworkId(), {
|
|
93
|
+
properties: {
|
|
94
|
+
total: expedition().properties.derivation.properties.totalPrice,
|
|
95
|
+
},
|
|
96
|
+
required: ['total'],
|
|
97
|
+
}),
|
|
98
|
+
expedition: expedition(),
|
|
99
|
+
},
|
|
100
|
+
required: ['_id', 'price', 'expedition'],
|
|
101
|
+
additionalProperties: false,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const upsertShopEvent = () => ({
|
|
105
|
+
title: 'upsert shop',
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: { shop: shop() },
|
|
108
|
+
required: ['shop'],
|
|
109
|
+
additionalProperties: false,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const upsertNetworkEvent = () => ({
|
|
113
|
+
title: 'upsert network',
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: { network: network() },
|
|
116
|
+
required: ['network'],
|
|
117
|
+
additionalProperties: false,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const upsertSaleEvent = () => ({
|
|
121
|
+
title: 'upsert sale',
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: { sale: sale() },
|
|
124
|
+
required: ['sale'],
|
|
125
|
+
additionalProperties: false,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
module.exports = {
|
|
129
|
+
receiveFromDriverEvent,
|
|
130
|
+
receiveFromCustomerEvent,
|
|
131
|
+
giveToCustomerEvent,
|
|
132
|
+
giveToDriverEvent,
|
|
133
|
+
expirationReminderEvent,
|
|
134
|
+
expiredEvent,
|
|
135
|
+
priceEvent,
|
|
136
|
+
upsertShopEvent,
|
|
137
|
+
upsertNetworkEvent,
|
|
138
|
+
upsertSaleEvent,
|
|
139
|
+
};
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
const { uuid, datetime, objectWithUuid, findRequest, findResponse, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
2
|
-
const { superAdmin, networkAdmin, shopUser } = require('./users');
|
|
3
|
-
const { defaults } = require('./defaults');
|
|
4
|
-
const { network } = require('./networks');
|
|
5
|
-
const { zone } = require('./zones');
|
|
6
|
-
const { representative } = require('./representatives');
|
|
7
|
-
const { shop } = require('./shops');
|
|
8
|
-
const { expedition } = require('./expeditions');
|
|
9
|
-
const { integration } = require('./integrations');
|
|
10
|
-
const { sale } = require('./sales');
|
|
11
|
-
|
|
12
|
-
const historicRecord = () => ({
|
|
13
|
-
title: 'historicRecord',
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
_id: uuid(),
|
|
17
|
-
createdAt: datetime(),
|
|
18
|
-
updatedAt: datetime(),
|
|
19
|
-
deletable: { type: 'boolean' },
|
|
20
|
-
type: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
enum: ['defaults', 'superAdmin', 'network', 'networkAdmin', 'zone', 'representative', 'shop', 'shopUser', 'expedition', 'sale'],
|
|
23
|
-
},
|
|
24
|
-
document: {
|
|
25
|
-
oneOf: [defaults(), superAdmin(), network(), networkAdmin(), zone(), representative(), shop(), shopUser(), expedition(), sale()],
|
|
26
|
-
},
|
|
27
|
-
action: { type: 'string', enum: ['create', 'update', 'delete'] },
|
|
28
|
-
actionKeys: {
|
|
29
|
-
type: 'array',
|
|
30
|
-
items: { type: 'string' },
|
|
31
|
-
description: 'the list of updated keys in an update action, e.g ["name", "status.code"]',
|
|
32
|
-
},
|
|
33
|
-
actor: { type: 'string', description: 'who made the action, e.g. username of the user, name of the script' },
|
|
34
|
-
integrations: {
|
|
35
|
-
type: 'object',
|
|
36
|
-
additionalProperties: {
|
|
37
|
-
type: 'object',
|
|
38
|
-
properties: {
|
|
39
|
-
at: datetime(),
|
|
40
|
-
result: { type: 'string', enum: ['inProgress', 'completed', 'failed', 'ignored', 'blocked', 'needsReview'] },
|
|
41
|
-
message: { type: 'string' },
|
|
42
|
-
},
|
|
43
|
-
required: ['at', 'result', 'message'],
|
|
44
|
-
description: 'what the integration has done with this record',
|
|
45
|
-
},
|
|
46
|
-
description: 'one property per integration where the property name is the name of the integration',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'type', 'document', 'action', 'actionKeys', 'actor', 'integrations'],
|
|
50
|
-
additionalProperties: false,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const findByTypeAndDocumentId = () => ({
|
|
54
|
-
title: 'find by type and document _id',
|
|
55
|
-
type: 'object',
|
|
56
|
-
properties: {
|
|
57
|
-
...pickProperties(historicRecord(), ['type']),
|
|
58
|
-
document: objectWithUuid(),
|
|
59
|
-
},
|
|
60
|
-
required: ['type', 'document'],
|
|
61
|
-
additionalProperties: false,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const findByIntegrationNameAndResult = () => ({
|
|
65
|
-
title: 'find by integration name and result',
|
|
66
|
-
type: 'object',
|
|
67
|
-
properties: {
|
|
68
|
-
integration: {
|
|
69
|
-
type: 'object',
|
|
70
|
-
properties: {
|
|
71
|
-
...pickProperties(integration(), ['name']),
|
|
72
|
-
...pickProperties(historicRecord().properties.integrations.additionalProperties, ['result']),
|
|
73
|
-
},
|
|
74
|
-
required: ['name', 'result'],
|
|
75
|
-
additionalProperties: false,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
required: ['integration'],
|
|
79
|
-
additionalProperties: false,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const findHistoricRecordsRequest = () => findRequest({ oneOf: [findByTypeAndDocumentId(), findByIntegrationNameAndResult()] });
|
|
83
|
-
|
|
84
|
-
const findHistoricRecordsResponse = () => findResponse(historicRecord());
|
|
85
|
-
|
|
86
|
-
module.exports = {
|
|
87
|
-
historicRecord,
|
|
88
|
-
findHistoricRecordsRequest,
|
|
89
|
-
findHistoricRecordsResponse,
|
|
90
|
-
};
|
|
1
|
+
const { uuid, datetime, objectWithUuid, findRequest, findResponse, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
2
|
+
const { superAdmin, networkAdmin, shopUser } = require('./users');
|
|
3
|
+
const { defaults } = require('./defaults');
|
|
4
|
+
const { network } = require('./networks');
|
|
5
|
+
const { zone } = require('./zones');
|
|
6
|
+
const { representative } = require('./representatives');
|
|
7
|
+
const { shop } = require('./shops');
|
|
8
|
+
const { expedition } = require('./expeditions');
|
|
9
|
+
const { integration } = require('./integrations');
|
|
10
|
+
const { sale } = require('./sales');
|
|
11
|
+
|
|
12
|
+
const historicRecord = () => ({
|
|
13
|
+
title: 'historicRecord',
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
_id: uuid(),
|
|
17
|
+
createdAt: datetime(),
|
|
18
|
+
updatedAt: datetime(),
|
|
19
|
+
deletable: { type: 'boolean' },
|
|
20
|
+
type: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
enum: ['defaults', 'superAdmin', 'network', 'networkAdmin', 'zone', 'representative', 'shop', 'shopUser', 'expedition', 'sale'],
|
|
23
|
+
},
|
|
24
|
+
document: {
|
|
25
|
+
oneOf: [defaults(), superAdmin(), network(), networkAdmin(), zone(), representative(), shop(), shopUser(), expedition(), sale()],
|
|
26
|
+
},
|
|
27
|
+
action: { type: 'string', enum: ['create', 'update', 'delete'] },
|
|
28
|
+
actionKeys: {
|
|
29
|
+
type: 'array',
|
|
30
|
+
items: { type: 'string' },
|
|
31
|
+
description: 'the list of updated keys in an update action, e.g ["name", "status.code"]',
|
|
32
|
+
},
|
|
33
|
+
actor: { type: 'string', description: 'who made the action, e.g. username of the user, name of the script' },
|
|
34
|
+
integrations: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
additionalProperties: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
at: datetime(),
|
|
40
|
+
result: { type: 'string', enum: ['inProgress', 'completed', 'failed', 'ignored', 'blocked', 'needsReview'] },
|
|
41
|
+
message: { type: 'string' },
|
|
42
|
+
},
|
|
43
|
+
required: ['at', 'result', 'message'],
|
|
44
|
+
description: 'what the integration has done with this record',
|
|
45
|
+
},
|
|
46
|
+
description: 'one property per integration where the property name is the name of the integration',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'type', 'document', 'action', 'actionKeys', 'actor', 'integrations'],
|
|
50
|
+
additionalProperties: false,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const findByTypeAndDocumentId = () => ({
|
|
54
|
+
title: 'find by type and document _id',
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
...pickProperties(historicRecord(), ['type']),
|
|
58
|
+
document: objectWithUuid(),
|
|
59
|
+
},
|
|
60
|
+
required: ['type', 'document'],
|
|
61
|
+
additionalProperties: false,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const findByIntegrationNameAndResult = () => ({
|
|
65
|
+
title: 'find by integration name and result',
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: {
|
|
68
|
+
integration: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
...pickProperties(integration(), ['name']),
|
|
72
|
+
...pickProperties(historicRecord().properties.integrations.additionalProperties, ['result']),
|
|
73
|
+
},
|
|
74
|
+
required: ['name', 'result'],
|
|
75
|
+
additionalProperties: false,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
required: ['integration'],
|
|
79
|
+
additionalProperties: false,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const findHistoricRecordsRequest = () => findRequest({ oneOf: [findByTypeAndDocumentId(), findByIntegrationNameAndResult()] });
|
|
83
|
+
|
|
84
|
+
const findHistoricRecordsResponse = () => findResponse(historicRecord());
|
|
85
|
+
|
|
86
|
+
module.exports = {
|
|
87
|
+
historicRecord,
|
|
88
|
+
findHistoricRecordsRequest,
|
|
89
|
+
findHistoricRecordsResponse,
|
|
90
|
+
};
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const { uuid, datetime, findRequest, findResponse, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
2
|
-
const { findAll } = require('./common');
|
|
3
|
-
const { network } = require('./networks');
|
|
4
|
-
|
|
5
|
-
const integration = () => ({
|
|
6
|
-
title: 'integration',
|
|
7
|
-
type: 'object',
|
|
8
|
-
properties: {
|
|
9
|
-
_id: uuid(),
|
|
10
|
-
createdAt: datetime(),
|
|
11
|
-
updatedAt: datetime(),
|
|
12
|
-
deletable: { type: 'boolean' },
|
|
13
|
-
name: { type: 'string' },
|
|
14
|
-
enabled: { type: 'boolean' },
|
|
15
|
-
networks: {
|
|
16
|
-
type: 'array',
|
|
17
|
-
items: {
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: { ...pickProperties(network(), ['_id', 'name']) },
|
|
20
|
-
required: ['_id', 'name'],
|
|
21
|
-
additionalProperties: false,
|
|
22
|
-
},
|
|
23
|
-
uniqueItems: true,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
required: ['_id', 'createdAt', 'updatedAt', 'name', 'enabled', 'networks'],
|
|
27
|
-
additionalProperties: false,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const findIntegrationsRequest = () => findRequest({ oneOf: [findAll()] });
|
|
31
|
-
|
|
32
|
-
const findIntegrationsResponse = () => findResponse(integration());
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
integration,
|
|
36
|
-
findIntegrationsRequest,
|
|
37
|
-
findIntegrationsResponse,
|
|
38
|
-
};
|
|
1
|
+
const { uuid, datetime, findRequest, findResponse, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
2
|
+
const { findAll } = require('./common');
|
|
3
|
+
const { network } = require('./networks');
|
|
4
|
+
|
|
5
|
+
const integration = () => ({
|
|
6
|
+
title: 'integration',
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
_id: uuid(),
|
|
10
|
+
createdAt: datetime(),
|
|
11
|
+
updatedAt: datetime(),
|
|
12
|
+
deletable: { type: 'boolean' },
|
|
13
|
+
name: { type: 'string' },
|
|
14
|
+
enabled: { type: 'boolean' },
|
|
15
|
+
networks: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: { ...pickProperties(network(), ['_id', 'name']) },
|
|
20
|
+
required: ['_id', 'name'],
|
|
21
|
+
additionalProperties: false,
|
|
22
|
+
},
|
|
23
|
+
uniqueItems: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ['_id', 'createdAt', 'updatedAt', 'name', 'enabled', 'networks'],
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const findIntegrationsRequest = () => findRequest({ oneOf: [findAll()] });
|
|
31
|
+
|
|
32
|
+
const findIntegrationsResponse = () => findResponse(integration());
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
integration,
|
|
36
|
+
findIntegrationsRequest,
|
|
37
|
+
findIntegrationsResponse,
|
|
38
|
+
};
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const { superAdmin, networkAdmin, shopUser } = require('./users');
|
|
2
|
-
const { network } = require('./networks');
|
|
3
|
-
const { shop } = require('./shops');
|
|
4
|
-
|
|
5
|
-
const loginResponse = () => ({
|
|
6
|
-
oneOf: [
|
|
7
|
-
{
|
|
8
|
-
title: 'super admin',
|
|
9
|
-
type: 'object',
|
|
10
|
-
properties: { user: superAdmin() },
|
|
11
|
-
require: ['user'],
|
|
12
|
-
additionalProperties: false,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
title: 'network admin',
|
|
16
|
-
type: 'object',
|
|
17
|
-
properties: {
|
|
18
|
-
user: networkAdmin(),
|
|
19
|
-
network: network(),
|
|
20
|
-
},
|
|
21
|
-
require: ['user', 'network'],
|
|
22
|
-
additionalProperties: false,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
title: 'shop user',
|
|
26
|
-
type: 'object',
|
|
27
|
-
properties: {
|
|
28
|
-
user: shopUser(),
|
|
29
|
-
network: network(),
|
|
30
|
-
shop: shop(),
|
|
31
|
-
},
|
|
32
|
-
require: ['user', 'network', 'shop'],
|
|
33
|
-
additionalProperties: false,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
module.exports = { loginResponse };
|
|
1
|
+
const { superAdmin, networkAdmin, shopUser } = require('./users');
|
|
2
|
+
const { network } = require('./networks');
|
|
3
|
+
const { shop } = require('./shops');
|
|
4
|
+
|
|
5
|
+
const loginResponse = () => ({
|
|
6
|
+
oneOf: [
|
|
7
|
+
{
|
|
8
|
+
title: 'super admin',
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: { user: superAdmin() },
|
|
11
|
+
require: ['user'],
|
|
12
|
+
additionalProperties: false,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
title: 'network admin',
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
user: networkAdmin(),
|
|
19
|
+
network: network(),
|
|
20
|
+
},
|
|
21
|
+
require: ['user', 'network'],
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: 'shop user',
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
user: shopUser(),
|
|
29
|
+
network: network(),
|
|
30
|
+
shop: shop(),
|
|
31
|
+
},
|
|
32
|
+
require: ['user', 'network', 'shop'],
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
module.exports = { loginResponse };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const logoutResponse = () => ({
|
|
2
|
-
type: 'object',
|
|
3
|
-
properties: { loggedOut: { type: 'boolean', enum: [true] } },
|
|
4
|
-
required: ['loggedOut'],
|
|
5
|
-
additionalProperties: false,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
module.exports = { logoutResponse };
|
|
1
|
+
const logoutResponse = () => ({
|
|
2
|
+
type: 'object',
|
|
3
|
+
properties: { loggedOut: { type: 'boolean', enum: [true] } },
|
|
4
|
+
required: ['loggedOut'],
|
|
5
|
+
additionalProperties: false,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
module.exports = { logoutResponse };
|