@foxtware/mineral 0.1.0 → 0.1.2

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.
Files changed (68) hide show
  1. package/.creds.yml.sample +5 -0
  2. package/.gcloudignore +17 -0
  3. package/.hosting.yml.sample +23 -0
  4. package/README.md +3 -1
  5. package/_build_scripts/publish.js +105 -0
  6. package/_deploy_scripts/deployFromHostingYml.js +319 -0
  7. package/_deploy_scripts/execCommand.js +38 -0
  8. package/_deploy_scripts/generateHosted.js +44 -0
  9. package/_deploy_scripts/setEnvVarsGcloud.js +51 -0
  10. package/api/logiwa/logiwa.constants.js +8 -0
  11. package/api/logiwa/logiwa.utils.js +53 -0
  12. package/api/logiwa/logiwaAuthGet.js +86 -0
  13. package/api/logiwa/logiwaInventoriesGet.js +67 -0
  14. package/api/logiwa/logiwaOrderGet.js +54 -0
  15. package/api/logiwa/logiwaOrdersGet.js +92 -0
  16. package/api/logiwa/logiwaProductGet.js +54 -0
  17. package/api/logiwa/logiwaProductsGet.js +80 -0
  18. package/api/logiwa/logiwaReportGetAvailableToPromise.js +179 -0
  19. package/api/logiwa/logiwaReportGetInventoryCalculation.js +62 -0
  20. package/api/logiwa/logiwaReportGetInventorySnapshot.js +66 -0
  21. package/api/logiwa/logiwaReportGetTotalInventory.js +72 -0
  22. package/api/logiwa/logiwaWebhookStatusGet.js +54 -0
  23. package/api/logiwa/logiwaWebhookSubscribe.js +64 -0
  24. package/api/logiwa/logiwaWebhookUnsubscribe.js +54 -0
  25. package/api/logiwa/logiwaWebhooksGet.js +48 -0
  26. package/api/shopify/_example.get.js +46 -0
  27. package/api/shopify/shopifyAbandonedCheckoutsGet.js +46 -0
  28. package/api/shopify/shopifyArticlesGet.js +46 -0
  29. package/api/shopify/shopifyBlogsGet.js +46 -0
  30. package/api/shopify/shopifyBulkOperationsGet.js +46 -0
  31. package/api/shopify/shopifyCatalogsGet.js +46 -0
  32. package/api/shopify/shopifyChannelsGet.js +46 -0
  33. package/api/shopify/shopifyCheckoutAndAccountsConfigurationsGet.js +46 -0
  34. package/api/shopify/shopifyCollectionsGet.js +46 -0
  35. package/api/shopify/shopifyCustomersGet.js +2 -0
  36. package/api/shopify/shopifyDeliveryCustomizationsGet.js +46 -0
  37. package/api/shopify/shopifyDeliveryProfilesGet.js +46 -0
  38. package/api/shopify/shopifyDiscountNodesGet.js +46 -0
  39. package/api/shopify/shopifyDisputesGet.js +46 -0
  40. package/api/shopify/shopifyDraftOrdersGet.js +46 -0
  41. package/api/shopify/shopifyEventsGet.js +46 -0
  42. package/api/shopify/shopifyFilesGet.js +46 -0
  43. package/api/shopify/shopifyFulfillmentOrdersGet.js +46 -0
  44. package/api/shopify/shopifyGiftCardsGet.js +46 -0
  45. package/api/shopify/shopifyInventoryItemsGet.js +46 -0
  46. package/api/shopify/shopifyLocationsGet.js +46 -0
  47. package/api/shopify/shopifyMarketingEventsGet.js +46 -0
  48. package/api/shopify/shopifyMarketsGet.js +46 -0
  49. package/api/shopify/shopifyMenusGet.js +46 -0
  50. package/api/shopify/shopifyMetafieldDefinitionsGet.js +50 -0
  51. package/api/shopify/shopifyMetaobjectDefinitionsGet.js +46 -0
  52. package/api/shopify/shopifyMetaobjectsGet.js +50 -0
  53. package/api/shopify/shopifyPagesGet.js +46 -0
  54. package/api/shopify/shopifyPaymentCustomizationsGet.js +46 -0
  55. package/api/shopify/shopifyProductFeedsGet.js +46 -0
  56. package/api/shopify/shopifyProductVariantsGet.js +46 -0
  57. package/api/shopify/shopifyProductsGet.js +46 -0
  58. package/api/shopify/shopifyPublicationsGet.js +46 -0
  59. package/api/shopify/shopifySegmentsGet.js +46 -0
  60. package/api/shopify/shopifyUrlRedirectsGet.js +46 -0
  61. package/api/shopify/shopifyWebhookSubscriptionsGet.js +46 -0
  62. package/api/utils.js +4 -3
  63. package/api/workspace.js +43 -0
  64. package/cli.js +42 -0
  65. package/hosting.utils.js +232 -0
  66. package/package.json +5 -3
  67. package/server.js +157 -107
  68. package/server.utils.js +40 -0
@@ -0,0 +1,86 @@
1
+ // https://myapi.logiwa.com/swagger/index.html
2
+
3
+ const { credsFromPayload, customFetch, appendUrlToBase, ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { DEFAULT_API_VERSION } = require('./logiwa.constants');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const logiwaAuthGet = async (
12
+ credsPayload,
13
+ {
14
+ apiVersion = DEFAULT_API_VERSION,
15
+ } = {},
16
+ ) => {
17
+
18
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
19
+ if (rejectResponse) {
20
+ return rejectResponse;
21
+ }
22
+
23
+ const creds = await credsFromPayload(credsPayload);
24
+ const {
25
+ BASE_URL,
26
+ EMAIL,
27
+ PASSWORD,
28
+ } = creds;
29
+
30
+ if (!EMAIL || !PASSWORD) {
31
+ return {
32
+ ok: false,
33
+ error: {
34
+ code: 'INVALID_CREDS',
35
+ message: 'EMAIL and PASSWORD are required.',
36
+ },
37
+ };
38
+ }
39
+
40
+ const url = appendUrlToBase(BASE_URL, `/${ apiVersion }/Authorize/token`);
41
+
42
+ const response = await customFetch(
43
+ url,
44
+ {
45
+ method: 'post',
46
+ body: {
47
+ email: EMAIL,
48
+ password: PASSWORD,
49
+ },
50
+ },
51
+ );
52
+
53
+ if (!response.ok) {
54
+ return response;
55
+ }
56
+
57
+ if (!response.data?.token) {
58
+ return {
59
+ ok: false,
60
+ error: {
61
+ code: 'AUTH_FAILED',
62
+ message: 'Logiwa did not return a token.',
63
+ details: response.data,
64
+ },
65
+ };
66
+ }
67
+
68
+ return response;
69
+ };
70
+
71
+ const funcApiConfig = {
72
+ argsWarden,
73
+ };
74
+
75
+ module.exports = {
76
+ logiwaAuthGet,
77
+ funcApiConfig,
78
+ };
79
+
80
+ /*
81
+ curl -X POST "http://localhost:8000/logiwaAuthGet" \
82
+ -H "Content-Type: application/json" \
83
+ -d '{
84
+ "credsPayload": { "credsPath": "logiwa" }
85
+ }'
86
+ */
@@ -0,0 +1,67 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Inventory/get_v3_1_Inventory_list_i__index__s__size_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const logiwaInventoriesGet = async (
13
+ credsPayload,
14
+ {
15
+ apiVersion,
16
+ page = 0,
17
+ perPage = MAX_PER_PAGE,
18
+ sku_eq,
19
+ clientIdentifier_eq,
20
+ warehouseIdentifier_eq,
21
+ inventoryStatusId_eq,
22
+ location_eq,
23
+ useSnapshotData_eq,
24
+ } = {},
25
+ ) => {
26
+
27
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ const params = {
33
+ ...(sku_eq && { 'Sku.eq': sku_eq }),
34
+ ...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
35
+ ...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
36
+ ...(inventoryStatusId_eq && { 'InventoryStatusId.eq': inventoryStatusId_eq }),
37
+ ...(location_eq && { 'Location.eq': location_eq }),
38
+ ...(useSnapshotData_eq && { 'UseSnapshotData.eq': useSnapshotData_eq }),
39
+ };
40
+
41
+ return logiwaClient.fetch({
42
+ method: 'get',
43
+ url: `/Inventory/list/i/${ page }/s/${ perPage }`,
44
+ params,
45
+ context: {
46
+ credsPayload,
47
+ apiVersion,
48
+ },
49
+ });
50
+ };
51
+
52
+ const funcApiConfig = {
53
+ argsWarden,
54
+ };
55
+
56
+ module.exports = {
57
+ logiwaInventoriesGet,
58
+ funcApiConfig,
59
+ };
60
+
61
+ /*
62
+ curl -X POST "http://localhost:8000/logiwaInventoriesGet" \
63
+ -H "Content-Type: application/json" \
64
+ -d '{
65
+ "credsPayload": { "credsPath": "logiwa" }
66
+ }'
67
+ */
@@ -0,0 +1,54 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/ShipmentOrder/get_v3_1_ShipmentOrder__identifier_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['orderId'],
10
+ ]);
11
+
12
+ const logiwaOrderGet = async (
13
+ credsPayload,
14
+ orderId, // Logiwa order UUID
15
+ {
16
+ apiVersion,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ orderId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return logiwaClient.fetch({
29
+ method: 'get',
30
+ url: `/ShipmentOrder/${ orderId }`,
31
+ context: {
32
+ credsPayload,
33
+ apiVersion,
34
+ },
35
+ });
36
+ };
37
+
38
+ const funcApiConfig = {
39
+ argsWarden,
40
+ };
41
+
42
+ module.exports = {
43
+ logiwaOrderGet,
44
+ funcApiConfig,
45
+ };
46
+
47
+ /*
48
+ curl -X POST "http://localhost:8000/logiwaOrderGet" \
49
+ -H "Content-Type: application/json" \
50
+ -d '{
51
+ "credsPayload": { "credsPath": "logiwa" },
52
+ "orderId": "d53b375b-835d-4450-b71b-65e333f6709b"
53
+ }'
54
+ */
@@ -0,0 +1,92 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/ShipmentOrder/get_v3_1_ShipmentOrder_list_i__index__s__size_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const logiwaOrdersGet = async (
13
+ credsPayload,
14
+ {
15
+ apiVersion,
16
+ page = 0,
17
+ perPage = MAX_PER_PAGE,
18
+ sku_eq,
19
+ updatedDateTime_bt,
20
+ code_eq,
21
+ warehouseIdentifier_eq,
22
+ warehouseIdentifier_in,
23
+ identifier_eq,
24
+ clientIdentifier_eq,
25
+ clientIdentifier_in,
26
+ createdDateTime_bt,
27
+ actualShipmentDate_bt,
28
+ shipmentOrderDate_bt,
29
+ status_in,
30
+ status_eq,
31
+ expectedShipmentDate_bt,
32
+ shipmentOrderTypeName_eq,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
37
+ if (rejectResponse) {
38
+ return rejectResponse;
39
+ }
40
+
41
+ const params = {
42
+ ...(sku_eq && { 'Sku.eq': sku_eq }),
43
+ ...(updatedDateTime_bt && { 'UpdatedDateTime.bt': updatedDateTime_bt }),
44
+ ...(code_eq && { 'Code.eq': code_eq }),
45
+ ...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
46
+ ...(warehouseIdentifier_in && { 'WarehouseIdentifier.in': warehouseIdentifier_in }),
47
+ ...(identifier_eq && { 'Identifier.eq': identifier_eq }),
48
+ ...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
49
+ ...(clientIdentifier_in && { 'ClientIdentifier.in': clientIdentifier_in }),
50
+ ...(createdDateTime_bt && { 'CreatedDateTime.bt': createdDateTime_bt }),
51
+ ...(actualShipmentDate_bt && { 'ActualShipmentDate.bt': actualShipmentDate_bt }),
52
+ ...(shipmentOrderDate_bt && { 'ShipmentOrderDate.bt': shipmentOrderDate_bt }),
53
+ ...(status_in && { 'Status.in': status_in }),
54
+ ...(status_eq && { 'Status.eq': status_eq }),
55
+ ...(expectedShipmentDate_bt && { 'ExpectedShipmentDate.bt': expectedShipmentDate_bt }),
56
+ ...(shipmentOrderTypeName_eq && { 'ShipmentOrderTypeName.eq': shipmentOrderTypeName_eq }),
57
+ };
58
+
59
+ return logiwaClient.fetch({
60
+ method: 'get',
61
+ url: `/ShipmentOrder/list/i/${ page }/s/${ perPage }`,
62
+ params,
63
+ context: {
64
+ credsPayload,
65
+ apiVersion,
66
+ },
67
+ });
68
+ };
69
+
70
+ const funcApiConfig = {
71
+ argsWarden,
72
+ };
73
+
74
+ module.exports = {
75
+ logiwaOrdersGet,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/logiwaOrdersGet" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "logiwa" }
84
+ }'
85
+
86
+ curl -X POST "http://localhost:8000/logiwaOrdersGet" \
87
+ -H "Content-Type: application/json" \
88
+ -d '{
89
+ "credsPayload": { "credsPath": "logiwa" },
90
+ "options": { "code_eq": "#USA5674542" }
91
+ }'
92
+ */
@@ -0,0 +1,54 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Product/get_v3_1_Product_detail__id_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['productId'],
10
+ ]);
11
+
12
+ const logiwaProductGet = async (
13
+ credsPayload,
14
+ productId,
15
+ {
16
+ apiVersion,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ productId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return logiwaClient.fetch({
29
+ method: 'get',
30
+ url: `/Product/detail/${ productId }`,
31
+ context: {
32
+ credsPayload,
33
+ apiVersion,
34
+ },
35
+ });
36
+ };
37
+
38
+ const funcApiConfig = {
39
+ argsWarden,
40
+ };
41
+
42
+ module.exports = {
43
+ logiwaProductGet,
44
+ funcApiConfig,
45
+ };
46
+
47
+ /*
48
+ curl -X POST "http://localhost:8000/logiwaProductGet" \
49
+ -H "Content-Type: application/json" \
50
+ -d '{
51
+ "credsPayload": { "credsPath": "logiwa" },
52
+ "productId": "261a02aa-ce5a-4b06-a528-d419e0aa87a1"
53
+ }'
54
+ */
@@ -0,0 +1,80 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Product/get_v3_1_Product_list_i__index__s__size_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const logiwaProductsGet = async (
13
+ credsPayload,
14
+ {
15
+ apiVersion,
16
+ page = 0,
17
+ perPage = MAX_PER_PAGE,
18
+ sku_eq,
19
+ fnsku_eq,
20
+ clientIdentifier_eq,
21
+ clientIdentifier_in,
22
+ identifier_eq,
23
+ createdDateTime_bt,
24
+ updatedDateTime_bt,
25
+ productTypeName_eq,
26
+ productGroupName_eq,
27
+ } = {},
28
+ ) => {
29
+
30
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
31
+ if (rejectResponse) {
32
+ return rejectResponse;
33
+ }
34
+
35
+ const params = {
36
+ ...(sku_eq && { 'Sku.eq': sku_eq }),
37
+ ...(fnsku_eq && { 'FNSKU.eq': fnsku_eq }),
38
+ ...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
39
+ ...(clientIdentifier_in && { 'ClientIdentifier.in': clientIdentifier_in }),
40
+ ...(identifier_eq && { 'Identifier.eq': identifier_eq }),
41
+ ...(createdDateTime_bt && { 'CreatedDateTime.bt': createdDateTime_bt }),
42
+ ...(updatedDateTime_bt && { 'UpdatedDateTime.bt': updatedDateTime_bt }),
43
+ ...(productTypeName_eq && { 'ProductTypeName.eq': productTypeName_eq }),
44
+ ...(productGroupName_eq && { 'ProductGroupName.eq': productGroupName_eq }),
45
+ };
46
+
47
+ return logiwaClient.fetch({
48
+ method: 'get',
49
+ url: `/Product/list/i/${ page }/s/${ perPage }`,
50
+ params,
51
+ context: {
52
+ credsPayload,
53
+ apiVersion,
54
+ },
55
+ });
56
+ };
57
+
58
+ const funcApiConfig = {
59
+ argsWarden,
60
+ };
61
+
62
+ module.exports = {
63
+ logiwaProductsGet,
64
+ funcApiConfig,
65
+ };
66
+
67
+ /*
68
+ curl -X POST "http://localhost:8000/logiwaProductsGet" \
69
+ -H "Content-Type: application/json" \
70
+ -d '{
71
+ "credsPayload": { "credsPath": "logiwa" }
72
+ }'
73
+
74
+ curl -X POST "http://localhost:8000/logiwaProductsGet" \
75
+ -H "Content-Type: application/json" \
76
+ -d '{
77
+ "credsPayload": { "credsPath": "logiwa" },
78
+ "options": { "sku_eq": "EXD1684-2-L" }
79
+ }'
80
+ */
@@ -0,0 +1,179 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Report/get_v3_1_Report_AvailableToPromise_i__index__s__size_
2
+
3
+ const { ArgsWarden, actionSingleOrMultiple } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { DEFAULT_API_VERSION, MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const isSet = (value) => {
9
+ if (value === 0 || value === false || value === '') {
10
+ return true;
11
+ }
12
+
13
+ return Boolean(value);
14
+ };
15
+
16
+ const logiwaReportGetAvailableToPromiseSingle = async (
17
+ credsPayload,
18
+ {
19
+ apiVersion = DEFAULT_API_VERSION,
20
+ page = 0,
21
+ perPage = MAX_PER_PAGE,
22
+ sku_eq,
23
+ clientIdentifier_eq,
24
+ clientIdentifier_in,
25
+ warehouseIdentifier_eq,
26
+ warehouseIdentifier_in,
27
+ plannedAtpQuantity_eq,
28
+ plannedAtpQuantity_gt,
29
+ plannedAtpQuantity_lt,
30
+ plannedAtpQuantity_gte,
31
+ plannedAtpQuantity_lte,
32
+ totalStockQuantity_eq,
33
+ totalStockQuantity_gt,
34
+ totalStockQuantity_lt,
35
+ totalStockQuantity_gte,
36
+ totalStockQuantity_lte,
37
+ inventoryAtpQuantity_eq,
38
+ inventoryAtpQuantity_gt,
39
+ inventoryAtpQuantity_lt,
40
+ inventoryAtpQuantity_gte,
41
+ inventoryAtpQuantity_lte,
42
+ undamagedQuantity_eq,
43
+ undamagedQuantity_gt,
44
+ undamagedQuantity_lt,
45
+ undamagedQuantity_gte,
46
+ undamagedQuantity_lte,
47
+ currentAtpQuantity_eq,
48
+ currentAtpQuantity_gt,
49
+ currentAtpQuantity_lt,
50
+ currentAtpQuantity_gte,
51
+ currentAtpQuantity_lte,
52
+ } = {},
53
+ ) => {
54
+
55
+ const params = {
56
+ ...(sku_eq && { 'Sku.eq': sku_eq }),
57
+ ...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
58
+ ...(clientIdentifier_in && { 'ClientIdentifier.in': clientIdentifier_in }),
59
+ ...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
60
+ ...(warehouseIdentifier_in && { 'WarehouseIdentifier.in': warehouseIdentifier_in }),
61
+ ...(isSet(plannedAtpQuantity_eq) && { 'PlannedATPQuantity.eq': plannedAtpQuantity_eq }),
62
+ ...(isSet(plannedAtpQuantity_gt) && { 'PlannedATPQuantity.gt': plannedAtpQuantity_gt }),
63
+ ...(isSet(plannedAtpQuantity_lt) && { 'PlannedATPQuantity.lt': plannedAtpQuantity_lt }),
64
+ ...(isSet(plannedAtpQuantity_gte) && { 'PlannedATPQuantity.gte': plannedAtpQuantity_gte }),
65
+ ...(isSet(plannedAtpQuantity_lte) && { 'PlannedATPQuantity.lte': plannedAtpQuantity_lte }),
66
+ ...(apiVersion === 'v3.1' ? {
67
+ ...(isSet(totalStockQuantity_eq) && { 'TotalStockQuantity.eq': totalStockQuantity_eq }),
68
+ ...(isSet(totalStockQuantity_gt) && { 'TotalStockQuantity.gt': totalStockQuantity_gt }),
69
+ ...(isSet(totalStockQuantity_lt) && { 'TotalStockQuantity.lt': totalStockQuantity_lt }),
70
+ ...(isSet(totalStockQuantity_gte) && { 'TotalStockQuantity.gte': totalStockQuantity_gte }),
71
+ ...(isSet(totalStockQuantity_lte) && { 'TotalStockQuantity.lte': totalStockQuantity_lte }),
72
+ ...(isSet(inventoryAtpQuantity_eq) && { 'InventoryATPQuantity.eq': inventoryAtpQuantity_eq }),
73
+ ...(isSet(inventoryAtpQuantity_gt) && { 'InventoryATPQuantity.gt': inventoryAtpQuantity_gt }),
74
+ ...(isSet(inventoryAtpQuantity_lt) && { 'InventoryATPQuantity.lt': inventoryAtpQuantity_lt }),
75
+ ...(isSet(inventoryAtpQuantity_gte) && { 'InventoryATPQuantity.gte': inventoryAtpQuantity_gte }),
76
+ ...(isSet(inventoryAtpQuantity_lte) && { 'InventoryATPQuantity.lte': inventoryAtpQuantity_lte }),
77
+ } : {}),
78
+ ...(apiVersion === 'v3.2' ? {
79
+ ...(isSet(undamagedQuantity_eq) && { 'UndamagedQuantity.eq': undamagedQuantity_eq }),
80
+ ...(isSet(undamagedQuantity_gt) && { 'UndamagedQuantity.gt': undamagedQuantity_gt }),
81
+ ...(isSet(undamagedQuantity_lt) && { 'UndamagedQuantity.lt': undamagedQuantity_lt }),
82
+ ...(isSet(undamagedQuantity_gte) && { 'UndamagedQuantity.gte': undamagedQuantity_gte }),
83
+ ...(isSet(undamagedQuantity_lte) && { 'UndamagedQuantity.lte': undamagedQuantity_lte }),
84
+ ...(isSet(currentAtpQuantity_eq) && { 'CurrentATPQuantity.eq': currentAtpQuantity_eq }),
85
+ ...(isSet(currentAtpQuantity_gt) && { 'CurrentATPQuantity.gt': currentAtpQuantity_gt }),
86
+ ...(isSet(currentAtpQuantity_lt) && { 'CurrentATPQuantity.lt': currentAtpQuantity_lt }),
87
+ ...(isSet(currentAtpQuantity_gte) && { 'CurrentATPQuantity.gte': currentAtpQuantity_gte }),
88
+ ...(isSet(currentAtpQuantity_lte) && { 'CurrentATPQuantity.lte': currentAtpQuantity_lte }),
89
+ } : {}),
90
+ };
91
+
92
+ if (!Object.keys(params).length) {
93
+ return {
94
+ ok: false,
95
+ error: {
96
+ code: 'INVALID_CRITERIA',
97
+ message: 'At least one filter is required, and criteria must match the API version.',
98
+ },
99
+ };
100
+ }
101
+
102
+ return logiwaClient.fetch({
103
+ method: 'get',
104
+ url: `/Report/AvailableToPromise/i/${ page }/s/${ perPage }`,
105
+ params,
106
+ context: {
107
+ credsPayload,
108
+ apiVersion,
109
+ },
110
+ });
111
+ };
112
+
113
+ const argsWarden = new ArgsWarden([
114
+ ['credsPayload', credsValidator],
115
+ ['criteria'],
116
+ ]);
117
+
118
+ const logiwaReportGetAvailableToPromise = async (
119
+ credsPayload,
120
+ criteria,
121
+ {
122
+ queueRunOptions,
123
+ ...options
124
+ } = {},
125
+ ) => {
126
+
127
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
128
+ credsPayload,
129
+ criteria,
130
+ });
131
+ if (rejectResponse) {
132
+ return rejectResponse;
133
+ }
134
+
135
+ return actionSingleOrMultiple(
136
+ criteria,
137
+ logiwaReportGetAvailableToPromiseSingle,
138
+ (singleCriteria) => ({
139
+ args: [
140
+ credsPayload,
141
+ {
142
+ ...singleCriteria,
143
+ ...options,
144
+ },
145
+ ],
146
+ }),
147
+ {
148
+ ...(queueRunOptions ? { queueRunOptions } : {}),
149
+ },
150
+ );
151
+ };
152
+
153
+ const funcApiConfig = {
154
+ argsWarden,
155
+ };
156
+
157
+ module.exports = {
158
+ logiwaReportGetAvailableToPromise,
159
+ funcApiConfig,
160
+ };
161
+
162
+ /*
163
+ curl -X POST "http://localhost:8000/logiwaReportGetAvailableToPromise" \
164
+ -H "Content-Type: application/json" \
165
+ -d '{
166
+ "credsPayload": { "credsPath": "logiwa" },
167
+ "criteria": { "clientIdentifier_eq": "9f1ea39a-fccc-48af-8986-a35c34fcef8b" }
168
+ }'
169
+
170
+ curl -X POST "http://localhost:8000/logiwaReportGetAvailableToPromise" \
171
+ -H "Content-Type: application/json" \
172
+ -d '{
173
+ "credsPayload": { "credsPath": "logiwa" },
174
+ "criteria": [
175
+ { "sku_eq": "EXDAL355-15-S/M" },
176
+ { "sku_eq": "EXD535-1-XXS/XS" }
177
+ ]
178
+ }'
179
+ */
@@ -0,0 +1,62 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Report/get_v3_1_Report_InventoryCalculation_i__index__s__size_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ['warehouseIdentifier_eq'],
11
+ ]);
12
+
13
+ const logiwaReportGetInventoryCalculation = async (
14
+ credsPayload,
15
+ warehouseIdentifier_eq,
16
+ {
17
+ apiVersion,
18
+ page = 0,
19
+ perPage = MAX_PER_PAGE,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ warehouseIdentifier_eq,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const params = {
32
+ 'WarehouseIdentifier.eq': warehouseIdentifier_eq,
33
+ };
34
+
35
+ return logiwaClient.fetch({
36
+ method: 'get',
37
+ url: `/Report/InventoryCalculation/i/${ page }/s/${ perPage }`,
38
+ params,
39
+ context: {
40
+ credsPayload,
41
+ apiVersion,
42
+ },
43
+ });
44
+ };
45
+
46
+ const funcApiConfig = {
47
+ argsWarden,
48
+ };
49
+
50
+ module.exports = {
51
+ logiwaReportGetInventoryCalculation,
52
+ funcApiConfig,
53
+ };
54
+
55
+ /*
56
+ curl -X POST "http://localhost:8000/logiwaReportGetInventoryCalculation" \
57
+ -H "Content-Type: application/json" \
58
+ -d '{
59
+ "credsPayload": { "credsPath": "logiwa" },
60
+ "warehouseIdentifier_eq": "cfbdf154-3052-4e18-84f3-b93b7cde2875"
61
+ }'
62
+ */