@activepieces/piece-coupa 0.0.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.
Files changed (73) hide show
  1. package/package.json +23 -0
  2. package/src/index.d.ts +7 -0
  3. package/src/index.d.ts.map +1 -0
  4. package/src/index.js +74 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/actions/add-file-attachment.d.ts +23 -0
  7. package/src/lib/actions/add-file-attachment.d.ts.map +1 -0
  8. package/src/lib/actions/add-file-attachment.js +122 -0
  9. package/src/lib/actions/add-file-attachment.js.map +1 -0
  10. package/src/lib/actions/cancel-purchase-order.d.ts +14 -0
  11. package/src/lib/actions/cancel-purchase-order.d.ts.map +1 -0
  12. package/src/lib/actions/cancel-purchase-order.js +30 -0
  13. package/src/lib/actions/cancel-purchase-order.js.map +1 -0
  14. package/src/lib/actions/close-purchase-order.d.ts +14 -0
  15. package/src/lib/actions/close-purchase-order.d.ts.map +1 -0
  16. package/src/lib/actions/close-purchase-order.js +30 -0
  17. package/src/lib/actions/close-purchase-order.js.map +1 -0
  18. package/src/lib/actions/create-object.d.ts +12 -0
  19. package/src/lib/actions/create-object.d.ts.map +1 -0
  20. package/src/lib/actions/create-object.js +39 -0
  21. package/src/lib/actions/create-object.js.map +1 -0
  22. package/src/lib/actions/get-object-by-id.d.ts +17 -0
  23. package/src/lib/actions/get-object-by-id.d.ts.map +1 -0
  24. package/src/lib/actions/get-object-by-id.js +39 -0
  25. package/src/lib/actions/get-object-by-id.js.map +1 -0
  26. package/src/lib/actions/get-remit-to-addresses.d.ts +15 -0
  27. package/src/lib/actions/get-remit-to-addresses.d.ts.map +1 -0
  28. package/src/lib/actions/get-remit-to-addresses.js +75 -0
  29. package/src/lib/actions/get-remit-to-addresses.js.map +1 -0
  30. package/src/lib/actions/get-supplier-sites.d.ts +14 -0
  31. package/src/lib/actions/get-supplier-sites.d.ts.map +1 -0
  32. package/src/lib/actions/get-supplier-sites.js +35 -0
  33. package/src/lib/actions/get-supplier-sites.js.map +1 -0
  34. package/src/lib/actions/grant-approval.d.ts +14 -0
  35. package/src/lib/actions/grant-approval.d.ts.map +1 -0
  36. package/src/lib/actions/grant-approval.js +30 -0
  37. package/src/lib/actions/grant-approval.js.map +1 -0
  38. package/src/lib/actions/reject-approval.d.ts +15 -0
  39. package/src/lib/actions/reject-approval.d.ts.map +1 -0
  40. package/src/lib/actions/reject-approval.js +43 -0
  41. package/src/lib/actions/reject-approval.js.map +1 -0
  42. package/src/lib/actions/search-objects.d.ts +11 -0
  43. package/src/lib/actions/search-objects.d.ts.map +1 -0
  44. package/src/lib/actions/search-objects.js +41 -0
  45. package/src/lib/actions/search-objects.js.map +1 -0
  46. package/src/lib/actions/set-integration-run-status.d.ts +10 -0
  47. package/src/lib/actions/set-integration-run-status.d.ts.map +1 -0
  48. package/src/lib/actions/set-integration-run-status.js +44 -0
  49. package/src/lib/actions/set-integration-run-status.js.map +1 -0
  50. package/src/lib/actions/update-object.d.ts +18 -0
  51. package/src/lib/actions/update-object.d.ts.map +1 -0
  52. package/src/lib/actions/update-object.js +41 -0
  53. package/src/lib/actions/update-object.js.map +1 -0
  54. package/src/lib/auth.d.ts +7 -0
  55. package/src/lib/auth.d.ts.map +1 -0
  56. package/src/lib/auth.js +50 -0
  57. package/src/lib/auth.js.map +1 -0
  58. package/src/lib/common/client.d.ts +34 -0
  59. package/src/lib/common/client.d.ts.map +1 -0
  60. package/src/lib/common/client.js +146 -0
  61. package/src/lib/common/client.js.map +1 -0
  62. package/src/lib/common/props.d.ts +47 -0
  63. package/src/lib/common/props.d.ts.map +1 -0
  64. package/src/lib/common/props.js +366 -0
  65. package/src/lib/common/props.js.map +1 -0
  66. package/src/lib/common/utils.d.ts +22 -0
  67. package/src/lib/common/utils.d.ts.map +1 -0
  68. package/src/lib/common/utils.js +182 -0
  69. package/src/lib/common/utils.js.map +1 -0
  70. package/src/lib/triggers/new-or-updated-object.d.ts +39 -0
  71. package/src/lib/triggers/new-or-updated-object.d.ts.map +1 -0
  72. package/src/lib/triggers/new-or-updated-object.js +98 -0
  73. package/src/lib/triggers/new-or-updated-object.js.map +1 -0
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@activepieces/piece-coupa",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@activepieces/pieces-common": "0.12.3",
9
+ "@activepieces/pieces-framework": "0.30.0",
10
+ "@activepieces/shared": "0.87.1",
11
+ "dayjs": "1.11.9",
12
+ "form-data": "4.0.4",
13
+ "tslib": "2.6.2"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc -p tsconfig.lib.json && cp package.json dist/",
17
+ "lint": "eslint 'src/**/*.ts'",
18
+ "test": "vitest run"
19
+ },
20
+ "devDependencies": {
21
+ "vitest": "3.0.8"
22
+ }
23
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare const coupa: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
+ }>>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,KAAK;;;;;GAmDhB,CAAC"}
package/src/index.js ADDED
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coupa = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const shared_1 = require("@activepieces/shared");
8
+ const add_file_attachment_1 = require("./lib/actions/add-file-attachment");
9
+ const cancel_purchase_order_1 = require("./lib/actions/cancel-purchase-order");
10
+ const close_purchase_order_1 = require("./lib/actions/close-purchase-order");
11
+ const create_object_1 = require("./lib/actions/create-object");
12
+ const get_object_by_id_1 = require("./lib/actions/get-object-by-id");
13
+ const get_remit_to_addresses_1 = require("./lib/actions/get-remit-to-addresses");
14
+ const get_supplier_sites_1 = require("./lib/actions/get-supplier-sites");
15
+ const grant_approval_1 = require("./lib/actions/grant-approval");
16
+ const reject_approval_1 = require("./lib/actions/reject-approval");
17
+ const search_objects_1 = require("./lib/actions/search-objects");
18
+ const set_integration_run_status_1 = require("./lib/actions/set-integration-run-status");
19
+ const update_object_1 = require("./lib/actions/update-object");
20
+ const auth_1 = require("./lib/auth");
21
+ const client_1 = require("./lib/common/client");
22
+ const utils_1 = require("./lib/common/utils");
23
+ const new_or_updated_object_1 = require("./lib/triggers/new-or-updated-object");
24
+ exports.coupa = (0, pieces_framework_1.createPiece)({
25
+ displayName: 'Coupa',
26
+ description: 'Business spend management — automate procurement, approvals, purchase orders, and ERP integrations with the Coupa Core API.',
27
+ minimumSupportedRelease: '0.36.1',
28
+ logoUrl: 'https://cdn.activepieces.com/pieces/coupa.png',
29
+ categories: [shared_1.PieceCategory.ACCOUNTING],
30
+ authors: ['maurivan'],
31
+ auth: auth_1.coupaAuth,
32
+ actions: [
33
+ create_object_1.createObject,
34
+ update_object_1.updateObject,
35
+ get_object_by_id_1.getObjectById,
36
+ search_objects_1.searchObjects,
37
+ cancel_purchase_order_1.cancelPurchaseOrder,
38
+ close_purchase_order_1.closePurchaseOrder,
39
+ add_file_attachment_1.addFileAttachment,
40
+ get_remit_to_addresses_1.getRemitToAddresses,
41
+ get_supplier_sites_1.getSupplierSites,
42
+ grant_approval_1.grantApproval,
43
+ reject_approval_1.rejectApproval,
44
+ set_integration_run_status_1.setIntegrationRunStatus,
45
+ (0, pieces_common_1.createCustomApiCallAction)({
46
+ auth: auth_1.coupaAuth,
47
+ name: 'custom_action',
48
+ displayName: 'Custom Action',
49
+ description: 'Make a custom API call to any Coupa endpoint (Purchase Orders, Suppliers, Contracts, or other resources).',
50
+ baseUrl: (auth) => {
51
+ if (!auth) {
52
+ return '';
53
+ }
54
+ const host = (0, utils_1.normalizeInstanceUrl)(auth.props.instanceUrl);
55
+ return `https://${host}/api`;
56
+ },
57
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
58
+ const client = new client_1.CoupaClient({
59
+ instanceUrl: auth.props.instanceUrl,
60
+ clientId: auth.props.clientId,
61
+ clientSecret: auth.props.clientSecret,
62
+ scope: auth.props.scope,
63
+ });
64
+ const token = yield client.getAccessToken();
65
+ return {
66
+ Authorization: `Bearer ${token}`,
67
+ Accept: 'application/json',
68
+ };
69
+ }),
70
+ }),
71
+ ],
72
+ triggers: [new_or_updated_object_1.newOrUpdatedObject],
73
+ });
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAA6D;AAC7D,iDAAqD;AACrD,2EAAsE;AACtE,+EAA0E;AAC1E,6EAAwE;AACxE,+DAA2D;AAC3D,qEAA+D;AAC/D,iFAA2E;AAC3E,yEAAoE;AACpE,iEAA6D;AAC7D,mEAA+D;AAC/D,iEAA6D;AAC7D,yFAAmF;AACnF,+DAA2D;AAC3D,qCAAuC;AACvC,gDAAkD;AAClD,8CAA0D;AAC1D,gFAA0E;AAE7D,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAC/B,WAAW,EAAE,OAAO;IACpB,WAAW,EACT,6HAA6H;IAC/H,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+CAA+C;IACxD,UAAU,EAAE,CAAC,sBAAa,CAAC,UAAU,CAAC;IACtC,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,IAAI,EAAE,gBAAS;IACf,OAAO,EAAE;QACP,4BAAY;QACZ,4BAAY;QACZ,gCAAa;QACb,8BAAa;QACb,2CAAmB;QACnB,yCAAkB;QAClB,uCAAiB;QACjB,4CAAmB;QACnB,qCAAgB;QAChB,8BAAa;QACb,gCAAc;QACd,oDAAuB;QACvB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,gBAAS;YACf,IAAI,EAAE,eAAe;YACrB,WAAW,EAAE,eAAe;YAC5B,WAAW,EACT,2GAA2G;YAC7G,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChB,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO,EAAE,CAAC;gBACZ,CAAC;gBACD,MAAM,IAAI,GAAG,IAAA,4BAAoB,EAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;gBAC1D,OAAO,WAAW,IAAI,MAAM,CAAC;YAC/B,CAAC;YACD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;oBAC7B,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;oBACnC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;oBAC7B,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;iBACxB,CAAC,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;gBAC5C,OAAO;oBACL,aAAa,EAAE,UAAU,KAAK,EAAE;oBAChC,MAAM,EAAE,kBAAkB;iBAC3B,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,0CAAkB,CAAC;CAC/B,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare const addFileAttachment: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
+ }>, {
7
+ module: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
8
+ parentRecord: import("@activepieces/pieces-framework").DynamicProperties<true, import("@activepieces/pieces-framework").CustomAuthProperty<{
9
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
11
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
12
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
13
+ }>>;
14
+ attachmentSource: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
15
+ attachment: import("@activepieces/pieces-framework").DynamicProperties<true, import("@activepieces/pieces-framework").CustomAuthProperty<{
16
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
17
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
18
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
19
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
20
+ }>>;
21
+ intent: import("@activepieces/pieces-framework").ShortTextProperty<false>;
22
+ }>;
23
+ //# sourceMappingURL=add-file-attachment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-file-attachment.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/add-file-attachment.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EA+G5B,CAAC"}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addFileAttachment = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
7
+ const auth_1 = require("../auth");
8
+ const client_1 = require("../common/client");
9
+ const props_1 = require("../common/props");
10
+ const utils_1 = require("../common/utils");
11
+ exports.addFileAttachment = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.coupaAuth,
13
+ name: 'add_file_attachment_to_object',
14
+ displayName: 'Add File Attachment to Object',
15
+ description: 'Adds an attachment (an uploaded file or a link) to a Purchase Order, Supplier, or Contract in Coupa.',
16
+ props: {
17
+ module: props_1.attachmentModuleProperty,
18
+ parentRecord: pieces_framework_1.Property.DynamicProperties({
19
+ displayName: 'Record',
20
+ description: 'The record to attach to. Pick it by name after choosing a module.',
21
+ required: true,
22
+ refreshers: ['module'],
23
+ auth: auth_1.coupaAuth,
24
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ module }) {
25
+ if (module === 'purchase_orders') {
26
+ return { recordId: props_1.purchaseOrderDropdown };
27
+ }
28
+ if (module === 'suppliers') {
29
+ return { recordId: props_1.supplierDropdown };
30
+ }
31
+ if (module === 'contracts') {
32
+ return { recordId: props_1.contractDropdown };
33
+ }
34
+ return {
35
+ recordId: pieces_framework_1.Property.ShortText({
36
+ displayName: 'Record ID',
37
+ description: 'Select a module first.',
38
+ required: true,
39
+ }),
40
+ };
41
+ }),
42
+ }),
43
+ attachmentSource: pieces_framework_1.Property.StaticDropdown({
44
+ displayName: 'Attachment Type',
45
+ description: 'Choose whether to upload a file directly or attach a link (URL).',
46
+ required: true,
47
+ defaultValue: 'file',
48
+ options: {
49
+ disabled: false,
50
+ options: [
51
+ { label: 'Upload a file', value: 'file' },
52
+ { label: 'Link a URL', value: 'url' },
53
+ ],
54
+ },
55
+ }),
56
+ attachment: pieces_framework_1.Property.DynamicProperties({
57
+ displayName: 'Attachment',
58
+ description: 'The file to upload or the URL to link.',
59
+ required: true,
60
+ refreshers: ['attachmentSource'],
61
+ auth: auth_1.coupaAuth,
62
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ attachmentSource }) {
63
+ if (attachmentSource === 'url') {
64
+ return {
65
+ url: pieces_framework_1.Property.ShortText({
66
+ displayName: 'URL',
67
+ description: 'The full link to attach (e.g. https://example.com/spec.pdf).',
68
+ required: true,
69
+ }),
70
+ };
71
+ }
72
+ return {
73
+ file: pieces_framework_1.Property.File({
74
+ displayName: 'File',
75
+ description: 'The file to upload to the record.',
76
+ required: true,
77
+ }),
78
+ };
79
+ }),
80
+ }),
81
+ intent: pieces_framework_1.Property.ShortText({
82
+ displayName: 'Intent',
83
+ description: 'Optional Coupa attachment intent that controls who can see the attachment (e.g. `Supplier`). Leave empty to use the Coupa default.',
84
+ required: false,
85
+ }),
86
+ },
87
+ run(_a) {
88
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
89
+ var _b;
90
+ const client = new client_1.CoupaClient(auth.props);
91
+ const module = (0, props_1.toCoupaModule)(propsValue.module);
92
+ const parentId = propsValue.parentRecord['recordId'];
93
+ const source = propsValue.attachmentSource;
94
+ const attachment = propsValue.attachment;
95
+ const formData = new form_data_1.default();
96
+ if (source === 'url') {
97
+ formData.append('attachment[url]', (_b = (0, utils_1.getString)(attachment['url'])) !== null && _b !== void 0 ? _b : '');
98
+ formData.append('attachment[type]', 'url');
99
+ }
100
+ else {
101
+ const file = attachment['file'];
102
+ if (!file) {
103
+ throw new Error('A file is required when the attachment type is "Upload a file".');
104
+ }
105
+ formData.append('attachment[file]', file.data, {
106
+ filename: file.filename,
107
+ contentType: (0, utils_1.getMimeType)(file.filename, file.extension),
108
+ });
109
+ formData.append('attachment[type]', 'file');
110
+ }
111
+ if (propsValue.intent) {
112
+ formData.append('attachment[intent]', propsValue.intent);
113
+ }
114
+ const result = yield client.requestMultipart({
115
+ resourceUri: `/${module}/${parentId}/attachments`,
116
+ formData,
117
+ });
118
+ return (0, utils_1.formatCoupaOutput)(result, module);
119
+ });
120
+ },
121
+ });
122
+ //# sourceMappingURL=add-file-attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-file-attachment.js","sourceRoot":"","sources":["../../../../src/lib/actions/add-file-attachment.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,kEAAiC;AACjC,kCAAoC;AACpC,6CAA+C;AAC/C,2CAMyB;AACzB,2CAA4E;AAE/D,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,+BAA+B;IACrC,WAAW,EAAE,+BAA+B;IAC5C,WAAW,EACT,sGAAsG;IACxG,KAAK,EAAE;QACL,MAAM,EAAE,gCAAwB;QAChC,YAAY,EAAE,2BAAQ,CAAC,iBAAiB,CAAC;YACvC,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,mEAAmE;YAChF,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,QAAQ,CAAC;YACtB,IAAI,EAAE,gBAAS;YACf,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,MAAM,EAAE;gBACtB,IAAI,MAAM,KAAK,iBAAiB,EAAE,CAAC;oBACjC,OAAO,EAAE,QAAQ,EAAE,6BAAqB,EAAE,CAAC;gBAC7C,CAAC;gBACD,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;oBAC3B,OAAO,EAAE,QAAQ,EAAE,wBAAgB,EAAE,CAAC;gBACxC,CAAC;gBACD,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;oBAC3B,OAAO,EAAE,QAAQ,EAAE,wBAAgB,EAAE,CAAC;gBACxC,CAAC;gBACD,OAAO;oBACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;wBAC3B,WAAW,EAAE,WAAW;wBACxB,WAAW,EAAE,wBAAwB;wBACrC,QAAQ,EAAE,IAAI;qBACf,CAAC;iBACH,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;QACF,gBAAgB,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACxC,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EACT,kEAAkE;Y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B,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const cancelPurchaseOrder: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
+ }>, {
7
+ purchaseOrderId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
8
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
9
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
10
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
11
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
12
+ }>>;
13
+ }>;
14
+ //# sourceMappingURL=cancel-purchase-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-purchase-order.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/cancel-purchase-order.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAiB9B,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cancelPurchaseOrder = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const auth_1 = require("../auth");
8
+ const client_1 = require("../common/client");
9
+ const props_1 = require("../common/props");
10
+ const utils_1 = require("../common/utils");
11
+ exports.cancelPurchaseOrder = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.coupaAuth,
13
+ name: 'cancel_purchase_order',
14
+ displayName: 'Cancel Purchase Order',
15
+ description: 'Cancels a purchase order using `PUT /api/purchase_orders/:id/cancel`.',
16
+ props: {
17
+ purchaseOrderId: props_1.purchaseOrderDropdown,
18
+ },
19
+ run(_a) {
20
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
21
+ const client = new client_1.CoupaClient(auth.props);
22
+ const result = yield client.request({
23
+ method: pieces_common_1.HttpMethod.PUT,
24
+ resourceUri: `/purchase_orders/${propsValue.purchaseOrderId}/cancel`,
25
+ });
26
+ return (0, utils_1.formatCoupaOutput)(result, 'purchase_orders');
27
+ });
28
+ },
29
+ });
30
+ //# sourceMappingURL=cancel-purchase-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-purchase-order.js","sourceRoot":"","sources":["../../../../src/lib/actions/cancel-purchase-order.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAA8D;AAC9D,kCAAoC;AACpC,6CAA+C;AAC/C,2CAAwD;AACxD,2CAAoD;AAEvC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EACT,uEAAuE;IACzE,KAAK,EAAE;QACL,eAAe,EAAE,6BAAqB;KACvC;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAA0B;gBAC3D,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,oBAAoB,UAAU,CAAC,eAAe,SAAS;aACrE,CAAC,CAAC;YACH,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QACtD,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const closePurchaseOrder: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
+ }>, {
7
+ purchaseOrderId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
8
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
9
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
10
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
11
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
12
+ }>>;
13
+ }>;
14
+ //# sourceMappingURL=close-purchase-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close-purchase-order.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/close-purchase-order.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAiB7B,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.closePurchaseOrder = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const auth_1 = require("../auth");
8
+ const client_1 = require("../common/client");
9
+ const props_1 = require("../common/props");
10
+ const utils_1 = require("../common/utils");
11
+ exports.closePurchaseOrder = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.coupaAuth,
13
+ name: 'close_purchase_order',
14
+ displayName: 'Close Purchase Order',
15
+ description: 'Closes a purchase order using `PUT /api/purchase_orders/:id/close`.',
16
+ props: {
17
+ purchaseOrderId: props_1.purchaseOrderDropdown,
18
+ },
19
+ run(_a) {
20
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
21
+ const client = new client_1.CoupaClient(auth.props);
22
+ const result = yield client.request({
23
+ method: pieces_common_1.HttpMethod.PUT,
24
+ resourceUri: `/purchase_orders/${propsValue.purchaseOrderId}/close`,
25
+ });
26
+ return (0, utils_1.formatCoupaOutput)(result, 'purchase_orders');
27
+ });
28
+ },
29
+ });
30
+ //# sourceMappingURL=close-purchase-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close-purchase-order.js","sourceRoot":"","sources":["../../../../src/lib/actions/close-purchase-order.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAA8D;AAC9D,kCAAoC;AACpC,6CAA+C;AAC/C,2CAAwD;AACxD,2CAAoD;AAEvC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EACT,qEAAqE;IACvE,KAAK,EAAE;QACL,eAAe,EAAE,6BAAqB;KACvC;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAA0B;gBAC3D,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,oBAAoB,UAAU,CAAC,eAAe,QAAQ;aACpE,CAAC,CAAC;YACH,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QACtD,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export declare const createObject: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
+ }>, {
7
+ module: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
8
+ customResource: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ bodyHelp: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
10
+ body: import("@activepieces/pieces-framework").JsonProperty<true>;
11
+ }>;
12
+ //# sourceMappingURL=create-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-object.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/create-object.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,YAAY;;;;;;;;;;EA6BvB,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createObject = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const auth_1 = require("../auth");
8
+ const client_1 = require("../common/client");
9
+ const props_1 = require("../common/props");
10
+ const utils_1 = require("../common/utils");
11
+ exports.createObject = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.coupaAuth,
13
+ name: 'create_object',
14
+ displayName: 'Create Object',
15
+ description: 'Creates a record in the selected Coupa module (Purchase Orders, Suppliers, or Contracts).',
16
+ props: {
17
+ module: props_1.moduleProperty,
18
+ customResource: props_1.customModuleResourceProperty,
19
+ bodyHelp: props_1.requestBodyHelp,
20
+ body: props_1.requestBodyProperty,
21
+ },
22
+ run(_a) {
23
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
24
+ const client = new client_1.CoupaClient(auth.props);
25
+ const resource = (0, props_1.resolveModuleResource)(propsValue.module, propsValue.customResource);
26
+ const body = (0, utils_1.parseJsonBody)(propsValue.body);
27
+ const result = yield client.request({
28
+ method: pieces_common_1.HttpMethod.POST,
29
+ resourceUri: `/${resource}`,
30
+ body,
31
+ });
32
+ if (propsValue.module !== '__custom__') {
33
+ return (0, utils_1.formatCoupaOutput)(result, (0, props_1.toCoupaModule)(propsValue.module));
34
+ }
35
+ return result;
36
+ });
37
+ },
38
+ });
39
+ //# sourceMappingURL=create-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-object.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-object.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAA8D;AAC9D,kCAAoC;AACpC,6CAA+C;AAC/C,2CAOyB;AACzB,2CAAmE;AAEtD,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EACT,2FAA2F;IAC7F,KAAK,EAAE;QACL,MAAM,EAAE,sBAAc;QACtB,cAAc,EAAE,oCAA4B;QAC5C,QAAQ,EAAE,uBAAe;QACzB,IAAI,EAAE,2BAAmB;KAC1B;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3C,MAAM,QAAQ,GAAG,IAAA,6BAAqB,EACpC,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,cAAc,CAC1B,CAAC;YACF,MAAM,IAAI,GAAG,IAAA,qBAAa,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAA0B;gBAC3D,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,WAAW,EAAE,IAAI,QAAQ,EAAE;gBAC3B,IAAI;aACL,CAAC,CAAC;YACH,IAAI,UAAU,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;gBACvC,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,IAAA,qBAAa,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export declare const getObjectById: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
+ }>, {
7
+ module: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
8
+ customResource: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ record: import("@activepieces/pieces-framework").DynamicProperties<true, import("@activepieces/pieces-framework").CustomAuthProperty<{
10
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
11
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
12
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
13
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
14
+ }>>;
15
+ queryParams: import("@activepieces/pieces-framework").JsonProperty<false>;
16
+ }>;
17
+ //# sourceMappingURL=get-object-by-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-object-by-id.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-object-by-id.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EA6BxB,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getObjectById = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const auth_1 = require("../auth");
8
+ const client_1 = require("../common/client");
9
+ const props_1 = require("../common/props");
10
+ const utils_1 = require("../common/utils");
11
+ exports.getObjectById = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.coupaAuth,
13
+ name: 'get_object_by_id',
14
+ displayName: 'Get Object by ID',
15
+ description: 'Retrieves a single record by ID from Purchase Orders, Suppliers, or Contracts.',
16
+ props: {
17
+ module: props_1.moduleProperty,
18
+ customResource: props_1.customModuleResourceProperty,
19
+ record: props_1.objectSelector,
20
+ queryParams: props_1.optionalQueryParamsProperty,
21
+ },
22
+ run(_a) {
23
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
24
+ const client = new client_1.CoupaClient(auth.props);
25
+ const resource = (0, props_1.resolveModuleResource)(propsValue.module, propsValue.customResource);
26
+ const objectId = propsValue.record['objectId'];
27
+ const result = yield client.request({
28
+ method: pieces_common_1.HttpMethod.GET,
29
+ resourceUri: `/${resource}/${objectId}`,
30
+ query: (0, props_1.parseOptionalQuery)(propsValue.queryParams),
31
+ });
32
+ if (propsValue.module !== '__custom__') {
33
+ return (0, utils_1.formatCoupaOutput)(result, (0, props_1.toCoupaModule)(propsValue.module));
34
+ }
35
+ return result;
36
+ });
37
+ },
38
+ });
39
+ //# sourceMappingURL=get-object-by-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-object-by-id.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-object-by-id.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAA8D;AAC9D,kCAAoC;AACpC,6CAA+C;AAC/C,2CAQyB;AACzB,2CAAoD;AAEvC,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EACT,gFAAgF;IAClF,KAAK,EAAE;QACL,MAAM,EAAE,sBAAc;QACtB,cAAc,EAAE,oCAA4B;QAC5C,MAAM,EAAE,sBAAc;QACtB,WAAW,EAAE,mCAA2B;KACzC;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3C,MAAM,QAAQ,GAAG,IAAA,6BAAqB,EACpC,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,cAAc,CAC1B,CAAC;YACF,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAA0B;gBAC3D,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,IAAI,QAAQ,IAAI,QAAQ,EAAE;gBACvC,KAAK,EAAE,IAAA,0BAAkB,EAAC,UAAU,CAAC,WAAW,CAAC;aAClD,CAAC,CAAC;YACH,IAAI,UAAU,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;gBACvC,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,IAAA,qBAAa,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare const getRemitToAddresses: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
+ }>, {
7
+ parentModule: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
8
+ parentRecord: import("@activepieces/pieces-framework").DynamicProperties<true, import("@activepieces/pieces-framework").CustomAuthProperty<{
9
+ instanceUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
+ clientId: import("@activepieces/pieces-framework").SecretTextProperty<true>;
11
+ clientSecret: import("@activepieces/pieces-framework").SecretTextProperty<true>;
12
+ scope: import("@activepieces/pieces-framework").LongTextProperty<true>;
13
+ }>>;
14
+ }>;
15
+ //# sourceMappingURL=get-remit-to-addresses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-remit-to-addresses.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-remit-to-addresses.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;EA+D9B,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRemitToAddresses = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const auth_1 = require("../auth");
8
+ const client_1 = require("../common/client");
9
+ const props_1 = require("../common/props");
10
+ const utils_1 = require("../common/utils");
11
+ exports.getRemitToAddresses = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.coupaAuth,
13
+ name: 'get_remit_to_addresses_by_object_id',
14
+ displayName: 'Get Remit-To Addresses by Object ID',
15
+ description: 'Lists remit-to addresses for a Supplier or resolves the supplier from a Purchase Order.',
16
+ props: {
17
+ parentModule: props_1.remitToParentTypeProperty,
18
+ parentRecord: pieces_framework_1.Property.DynamicProperties({
19
+ displayName: 'Record',
20
+ required: true,
21
+ refreshers: ['parentModule'],
22
+ auth: auth_1.coupaAuth,
23
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ parentModule }) {
24
+ if (parentModule === 'suppliers') {
25
+ return { recordId: props_1.supplierDropdown };
26
+ }
27
+ if (parentModule === 'purchase_orders') {
28
+ return { recordId: props_1.purchaseOrderDropdown };
29
+ }
30
+ return {
31
+ recordId: pieces_framework_1.Property.ShortText({
32
+ displayName: 'Record ID',
33
+ description: 'Select a parent module first.',
34
+ required: true,
35
+ }),
36
+ };
37
+ }),
38
+ }),
39
+ },
40
+ run(_a) {
41
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
42
+ var _b;
43
+ const client = new client_1.CoupaClient(auth.props);
44
+ const recordId = propsValue.parentRecord['recordId'];
45
+ let path;
46
+ if (propsValue.parentModule === 'suppliers') {
47
+ path = `/suppliers/${recordId}/addresses`;
48
+ }
49
+ else {
50
+ const po = yield client.request({
51
+ method: pieces_common_1.HttpMethod.GET,
52
+ resourceUri: `/purchase_orders/${recordId}`,
53
+ query: { fields: '["id","supplier"]' },
54
+ });
55
+ const supplier = po['supplier'];
56
+ const supplierId = (_b = ((0, utils_1.isRecord)(supplier) ? supplier['id'] : undefined)) !== null && _b !== void 0 ? _b : po['supplier-id'];
57
+ if (!supplierId) {
58
+ throw new Error('Purchase order has no linked supplier.');
59
+ }
60
+ path = `/suppliers/${supplierId}/addresses`;
61
+ }
62
+ const result = yield client.request({
63
+ method: pieces_common_1.HttpMethod.GET,
64
+ resourceUri: path,
65
+ });
66
+ const list = Array.isArray(result) ? result : [result];
67
+ const formatted = (0, utils_1.flattenRecords)(list);
68
+ return {
69
+ total_count: formatted.length,
70
+ addresses: formatted,
71
+ };
72
+ });
73
+ },
74
+ });
75
+ //# sourceMappingURL=get-remit-to-addresses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-remit-to-addresses.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-remit-to-addresses.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAoC;AACpC,6CAA+C;AAC/C,2CAIyB;AACzB,2CAA2D;AAE9C,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,qCAAqC;IAC3C,WAAW,EAAE,qCAAqC;IAClD,WAAW,EACT,yFAAyF;IAC3F,KAAK,EAAE;QACL,YAAY,EAAE,iCAA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