@openfn/language-msupply 1.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.
- package/LICENSE +674 -0
- package/LICENSE.LESSER +165 -0
- package/README.md +27 -0
- package/ast.json +953 -0
- package/configuration-schema.json +28 -0
- package/dist/index.cjs +606 -0
- package/dist/index.js +580 -0
- package/package.json +49 -0
- package/types/Adaptor.d.ts +150 -0
- package/types/Utils.d.ts +3 -0
- package/types/index.d.ts +3 -0
- package/types/queries.d.ts +3 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State object
|
|
3
|
+
* @typedef {Object} HttpState
|
|
4
|
+
* @property data - the parsed response body
|
|
5
|
+
* @property response - the response from the HTTP server, including headers, statusCode, body, etc
|
|
6
|
+
* @property references - an array of all previous data objects used in the Job
|
|
7
|
+
**/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} RequestBody
|
|
10
|
+
* @property {string} query - The GraphQL query string
|
|
11
|
+
* @property {object} variables - The variables for that query string
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Object} GetItemsVariables
|
|
15
|
+
* @property {string} key - The unique key of each item in the list
|
|
16
|
+
* @property {string} storeId - The msupply store id the list is being fetched from
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} InsertOutboundShipmentvariables
|
|
20
|
+
* @property {string} otherPartyId - The recieving party id
|
|
21
|
+
* @property {string} storeId - The id of the store the shipment is being made from
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {Object} UpsertOutboundShipmentvariables
|
|
25
|
+
* @property {Object} input - The payload for the target shipment
|
|
26
|
+
* @property {string} storeId - The id of the store the shipment is being made from
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Get the list of items in the catalogue
|
|
30
|
+
* @public
|
|
31
|
+
* @function
|
|
32
|
+
* @example <caption>Get items in the catalogue</caption>
|
|
33
|
+
* getItemsWithStats({
|
|
34
|
+
"key": "name",
|
|
35
|
+
"storeId": "DFE0F611AD84A0419D36F8FEFAD1894C",
|
|
36
|
+
})
|
|
37
|
+
* @param {GetItemsVariables} variables - GraphQL query variables
|
|
38
|
+
* @returns {Operation}
|
|
39
|
+
* @state {HttpState}
|
|
40
|
+
*/
|
|
41
|
+
export function getItemsWithStats(variables: GetItemsVariables): Operation;
|
|
42
|
+
/**
|
|
43
|
+
* Create an outbound shipment.
|
|
44
|
+
* @public
|
|
45
|
+
* @function
|
|
46
|
+
* @example <caption>Create an outbound shipment</caption>
|
|
47
|
+
* insertOutboundShipment({
|
|
48
|
+
"otherPartyId": "861102F624354F15ABEB48DC207A4C2D",
|
|
49
|
+
"storeId": "DFE0F611AD84A0419D36F8FEFAD1894C"
|
|
50
|
+
})
|
|
51
|
+
* @param {InsertOutboundShipmentvariables} variables - GraphQL query variables
|
|
52
|
+
* @returns {Operation}
|
|
53
|
+
* @state {HttpState}
|
|
54
|
+
*/
|
|
55
|
+
export function insertOutboundShipment(variables: InsertOutboundShipmentvariables): Operation;
|
|
56
|
+
/**
|
|
57
|
+
* Update an outbound shipment
|
|
58
|
+
* @public
|
|
59
|
+
* @function
|
|
60
|
+
* @example <caption>Update outbound shipment status to 'PICKED'</caption>
|
|
61
|
+
* upsertOutboundShipment({
|
|
62
|
+
* "storeId": "DFE0F611AD84A0419D36F8FEFAD1894C",
|
|
63
|
+
* "input": {
|
|
64
|
+
* "updateOutboundShipments": [
|
|
65
|
+
* {
|
|
66
|
+
* "id": "01961fce-9ef6-7198-93c1-866395094e48",
|
|
67
|
+
* "status": "PICKED"
|
|
68
|
+
* }
|
|
69
|
+
* ]
|
|
70
|
+
* }
|
|
71
|
+
* })
|
|
72
|
+
* @param {UpsertOutboundShipmentvariables} variables - GraphQL query variables
|
|
73
|
+
* @returns {Operation}
|
|
74
|
+
* @state {HttpState}
|
|
75
|
+
*/
|
|
76
|
+
export function upsertOutboundShipment(variables: UpsertOutboundShipmentvariables): Operation;
|
|
77
|
+
/**
|
|
78
|
+
* Make a generic GraphQL request
|
|
79
|
+
* @public
|
|
80
|
+
* @function
|
|
81
|
+
* @example
|
|
82
|
+
* query(`
|
|
83
|
+
query isCentralServer {
|
|
84
|
+
isCentralServer
|
|
85
|
+
}`
|
|
86
|
+
)
|
|
87
|
+
*@param {string} query - GraphQl query string
|
|
88
|
+
*@param {Object} variables - GraphQl query variables
|
|
89
|
+
* @returns {Operation}
|
|
90
|
+
* @state {HttpState}
|
|
91
|
+
*/
|
|
92
|
+
export function query(query: string, variables?: any): Operation;
|
|
93
|
+
/**
|
|
94
|
+
* State object
|
|
95
|
+
*/
|
|
96
|
+
export type HttpState = {
|
|
97
|
+
/**
|
|
98
|
+
* - the parsed response body
|
|
99
|
+
*/
|
|
100
|
+
data: any;
|
|
101
|
+
/**
|
|
102
|
+
* - the response from the HTTP server, including headers, statusCode, body, etc
|
|
103
|
+
*/
|
|
104
|
+
response: any;
|
|
105
|
+
/**
|
|
106
|
+
* - an array of all previous data objects used in the Job
|
|
107
|
+
*/
|
|
108
|
+
references: any;
|
|
109
|
+
};
|
|
110
|
+
export type RequestBody = {
|
|
111
|
+
/**
|
|
112
|
+
* - The GraphQL query string
|
|
113
|
+
*/
|
|
114
|
+
query: string;
|
|
115
|
+
/**
|
|
116
|
+
* - The variables for that query string
|
|
117
|
+
*/
|
|
118
|
+
variables: object;
|
|
119
|
+
};
|
|
120
|
+
export type GetItemsVariables = {
|
|
121
|
+
/**
|
|
122
|
+
* - The unique key of each item in the list
|
|
123
|
+
*/
|
|
124
|
+
key: string;
|
|
125
|
+
/**
|
|
126
|
+
* - The msupply store id the list is being fetched from
|
|
127
|
+
*/
|
|
128
|
+
storeId: string;
|
|
129
|
+
};
|
|
130
|
+
export type InsertOutboundShipmentvariables = {
|
|
131
|
+
/**
|
|
132
|
+
* - The recieving party id
|
|
133
|
+
*/
|
|
134
|
+
otherPartyId: string;
|
|
135
|
+
/**
|
|
136
|
+
* - The id of the store the shipment is being made from
|
|
137
|
+
*/
|
|
138
|
+
storeId: string;
|
|
139
|
+
};
|
|
140
|
+
export type UpsertOutboundShipmentvariables = {
|
|
141
|
+
/**
|
|
142
|
+
* - The payload for the target shipment
|
|
143
|
+
*/
|
|
144
|
+
input: any;
|
|
145
|
+
/**
|
|
146
|
+
* - The id of the store the shipment is being made from
|
|
147
|
+
*/
|
|
148
|
+
storeId: string;
|
|
149
|
+
};
|
|
150
|
+
export { combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";
|
package/types/Utils.d.ts
ADDED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const getItemsQueryString: "\n query itemsWithStats($storeId: String!, $key: ItemSortFieldInput!, $isDesc: Boolean, $filter: ItemFilterInput, $first: Int, $offset: Int) {\n items(storeId: $storeId, sort: {key: $key, desc: $isDesc}, filter: $filter, page: {first: $first, offset: $offset}) {\n ... on ItemConnector {\n __typename\n nodes {\n code\n id\n name\n unitName\n defaultPackSize\n availableStockOnHand(storeId: $storeId)\n stats(storeId: $storeId) {\n averageMonthlyConsumption\n availableStockOnHand\n availableMonthsOfStockOnHand\n monthsOfStockOnHand\n totalConsumption\n stockOnHand\n }\n }\n totalCount\n }\n }\n }";
|
|
2
|
+
export const insertOutboundShipmentQuery: "mutation insertOutboundShipment($id: String!, $otherPartyId: String!, $storeId: String!) {\n insertOutboundShipment(\n storeId: $storeId\n input: {id: $id, otherPartyId: $otherPartyId}\n ) {\n __typename\n ... on InvoiceNode {\n id\n invoiceNumber\n }\n ... on InsertOutboundShipmentError {\n __typename\n error {\n description\n ... on OtherPartyNotACustomer {\n __typename\n description\n }\n ... on OtherPartyNotVisible {\n __typename\n description\n }\n description\n }\n }\n ... on NodeError {\n __typename\n error {\n description\n ... on DatabaseError {\n __typename\n description\n fullError\n }\n ... on RecordNotFound {\n __typename\n description\n }\n }\n }\n }\n}";
|
|
3
|
+
export const upsertOutboundShipmentQuery: "mutation upsertOutboundShipment($storeId: String!, $input: BatchOutboundShipmentInput!) {\n batchOutboundShipment(storeId: $storeId, input: $input) {\n __typename\n insertOutboundShipmentUnallocatedLines {\n id\n response {\n ... on InsertOutboundShipmentUnallocatedLineError {\n __typename\n error {\n description\n }\n }\n ... on InvoiceLineNode {\n id\n }\n }\n }\n deleteOutboundShipmentLines {\n id\n response {\n ... on DeleteOutboundShipmentLineError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n ... on CannotEditInvoice {\n __typename\n description\n }\n ... on ForeignKeyError {\n __typename\n description\n key\n }\n }\n }\n ... on DeleteResponse {\n id\n }\n }\n }\n deleteOutboundShipmentServiceLines {\n id\n response {\n ... on DeleteResponse {\n id\n }\n ... on DeleteOutboundShipmentServiceLineError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n ... on CannotEditInvoice {\n __typename\n description\n }\n ... on ForeignKeyError {\n __typename\n description\n key\n }\n }\n }\n }\n }\n deleteOutboundShipmentUnallocatedLines {\n id\n response {\n ... on DeleteResponse {\n id\n }\n ... on DeleteOutboundShipmentUnallocatedLineError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n }\n }\n }\n }\n deleteOutboundShipments {\n id\n response {\n ... on DeleteResponse {\n id\n }\n ... on DeleteOutboundShipmentError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n ... on CannotDeleteInvoiceWithLines {\n __typename\n description\n }\n ... on CannotEditInvoice {\n __typename\n description\n }\n }\n }\n }\n }\n insertOutboundShipmentLines {\n id\n response {\n ... on InsertOutboundShipmentLineError {\n __typename\n error {\n description\n }\n }\n }\n }\n insertOutboundShipmentServiceLines {\n id\n response {\n ... on InsertOutboundShipmentServiceLineError {\n __typename\n error {\n description\n }\n }\n }\n }\n insertOutboundShipments {\n id\n response {\n ... on InsertOutboundShipmentError {\n __typename\n error {\n description\n }\n }\n ... on NodeError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n ... on DatabaseError {\n __typename\n description\n fullError\n }\n }\n }\n }\n }\n updateOutboundShipmentLines {\n id\n response {\n ... on UpdateOutboundShipmentLineError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n ... on CannotEditInvoice {\n __typename\n description\n }\n ... on ForeignKeyError {\n __typename\n description\n key\n }\n ... on LocationIsOnHold {\n __typename\n description\n }\n ... on LocationNotFound {\n __typename\n description\n }\n ... on NotEnoughStockForReduction {\n __typename\n batch {\n ... on NodeError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n ... on DatabaseError {\n __typename\n description\n fullError\n }\n }\n }\n }\n }\n ... on StockLineAlreadyExistsInInvoice {\n __typename\n description\n }\n ... on StockLineIsOnHold {\n __typename\n description\n }\n }\n }\n }\n }\n updateOutboundShipmentServiceLines {\n id\n response {\n ... on UpdateOutboundShipmentServiceLineError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n ... on CannotEditInvoice {\n __typename\n description\n }\n ... on ForeignKeyError {\n __typename\n description\n key\n }\n }\n }\n }\n }\n updateOutboundShipmentUnallocatedLines {\n id\n response {\n ... on UpdateOutboundShipmentUnallocatedLineError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n }\n }\n }\n }\n updateOutboundShipments {\n id\n response {\n ... on UpdateOutboundShipmentError {\n __typename\n error {\n description\n }\n }\n ... on NodeError {\n __typename\n error {\n description\n }\n }\n }\n }\n allocateOutboundShipmentUnallocatedLines {\n id\n response {\n ... on AllocateOutboundShipmentUnallocatedLineError {\n __typename\n error {\n description\n ... on RecordNotFound {\n __typename\n description\n }\n }\n }\n ... on AllocateOutboundShipmentUnallocatedLineNode {\n __typename\n deletes {\n id\n }\n inserts {\n totalCount\n }\n updates {\n totalCount\n }\n }\n }\n }\n }\n}";
|