@activepieces/piece-katana 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.
- package/README.md +7 -0
- package/package.json +25 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +37 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-customer.d.ts +14 -0
- package/src/lib/actions/create-customer.js +196 -0
- package/src/lib/actions/create-customer.js.map +1 -0
- package/src/lib/actions/create-sales-order.d.ts +23 -0
- package/src/lib/actions/create-sales-order.js +275 -0
- package/src/lib/actions/create-sales-order.js.map +1 -0
- package/src/lib/actions/find-customer.d.ts +14 -0
- package/src/lib/actions/find-customer.js +117 -0
- package/src/lib/actions/find-customer.js.map +1 -0
- package/src/lib/actions/index.d.ts +3 -0
- package/src/lib/actions/index.js +7 -0
- package/src/lib/actions/index.js.map +1 -0
- package/src/lib/common/auth.d.ts +1 -0
- package/src/lib/common/auth.js +41 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +2 -0
- package/src/lib/common/client.js +22 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/constants.d.ts +1 -0
- package/src/lib/common/constants.js +5 -0
- package/src/lib/common/constants.js.map +1 -0
- package/src/lib/common/index.d.ts +4 -0
- package/src/lib/common/index.js +8 -0
- package/src/lib/common/index.js.map +1 -0
- package/src/lib/common/props.d.ts +5 -0
- package/src/lib/common/props.js +212 -0
- package/src/lib/common/props.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-katana",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@sinclair/typebox": "0.34.11",
|
|
9
|
+
"axios": "1.13.1",
|
|
10
|
+
"axios-retry": "4.4.1",
|
|
11
|
+
"deepmerge-ts": "7.1.0",
|
|
12
|
+
"mime-types": "2.1.35",
|
|
13
|
+
"nanoid": "3.3.8",
|
|
14
|
+
"semver": "7.6.0",
|
|
15
|
+
"socket.io-client": "4.8.1",
|
|
16
|
+
"tslib": "^2.3.0",
|
|
17
|
+
"zod": "4.1.13",
|
|
18
|
+
"@activepieces/pieces-common": "0.10.1",
|
|
19
|
+
"@activepieces/pieces-framework": "0.22.2",
|
|
20
|
+
"@activepieces/shared": "0.30.3"
|
|
21
|
+
},
|
|
22
|
+
"resolutions": {
|
|
23
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const katana: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.katana = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const shared_1 = require("@activepieces/shared");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
const auth_1 = require("./lib/common/auth");
|
|
9
|
+
const constants_1 = require("./lib/common/constants");
|
|
10
|
+
const create_customer_1 = require("./lib/actions/create-customer");
|
|
11
|
+
const create_sales_order_1 = require("./lib/actions/create-sales-order");
|
|
12
|
+
const find_customer_1 = require("./lib/actions/find-customer");
|
|
13
|
+
exports.katana = (0, pieces_framework_1.createPiece)({
|
|
14
|
+
displayName: 'Katana',
|
|
15
|
+
auth: auth_1.katanaAuth,
|
|
16
|
+
minimumSupportedRelease: '0.36.1',
|
|
17
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/katana.png',
|
|
18
|
+
description: 'Katana is a cloud-based manufacturing ERP software for inventory, production, and order management.',
|
|
19
|
+
categories: [shared_1.PieceCategory.PRODUCTIVITY],
|
|
20
|
+
authors: ["onyedikachi-david"],
|
|
21
|
+
actions: [
|
|
22
|
+
create_customer_1.createCustomer,
|
|
23
|
+
create_sales_order_1.createSalesOrder,
|
|
24
|
+
find_customer_1.findCustomer,
|
|
25
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
26
|
+
auth: auth_1.katanaAuth,
|
|
27
|
+
baseUrl: () => constants_1.BASE_URL,
|
|
28
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
return ({
|
|
30
|
+
Authorization: `Bearer ${auth.secret_text}`,
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
triggers: [],
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/katana/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,iDAAqD;AACrD,+DAAwE;AACxE,4CAA+C;AAC/C,sDAAkD;AAClD,mEAA+D;AAC/D,yEAAoE;AACpE,+DAA2D;AAE9C,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,QAAQ;IACrB,IAAI,EAAE,iBAAU;IAChB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,gDAAgD;IACzD,WAAW,EACT,qGAAqG;IACvG,UAAU,EAAE,CAAC,sBAAa,CAAC,YAAY,CAAC;IACxC,OAAO,EAAE,CAAC,mBAAmB,CAAC;IAC9B,OAAO,EAAE;QACP,gCAAc;QACd,qCAAgB;QAChB,4BAAY;QACZ,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,iBAAU;YAChB,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAQ;YACvB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAU,IAAI,CAAC,WAAW,EAAE;iBAC5C,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const createCustomer: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
first_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
last_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
company: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
phone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
currency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
reference_id: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
category: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
comment: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
12
|
+
discount_rate: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
13
|
+
addresses: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCustomer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
const constants_1 = require("../common/constants");
|
|
9
|
+
exports.createCustomer = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.katanaAuth,
|
|
11
|
+
name: 'create_customer',
|
|
12
|
+
displayName: 'Create Customer',
|
|
13
|
+
description: 'Creates a new customer in Katana.',
|
|
14
|
+
props: {
|
|
15
|
+
name: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Name',
|
|
17
|
+
description: 'Customer display name.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
first_name: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'First Name',
|
|
22
|
+
required: false,
|
|
23
|
+
}),
|
|
24
|
+
last_name: pieces_framework_1.Property.ShortText({
|
|
25
|
+
displayName: 'Last Name',
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
28
|
+
company: pieces_framework_1.Property.ShortText({
|
|
29
|
+
displayName: 'Company',
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
32
|
+
email: pieces_framework_1.Property.ShortText({
|
|
33
|
+
displayName: 'Email',
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
36
|
+
phone: pieces_framework_1.Property.ShortText({
|
|
37
|
+
displayName: 'Phone',
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
currency: pieces_framework_1.Property.ShortText({
|
|
41
|
+
displayName: 'Currency',
|
|
42
|
+
description: 'Currency code (ISO 4217), e.g. USD, EUR, GBP.',
|
|
43
|
+
required: false,
|
|
44
|
+
}),
|
|
45
|
+
reference_id: pieces_framework_1.Property.ShortText({
|
|
46
|
+
displayName: 'Reference ID',
|
|
47
|
+
description: 'External reference ID (max 100 characters).',
|
|
48
|
+
required: false,
|
|
49
|
+
}),
|
|
50
|
+
category: pieces_framework_1.Property.ShortText({
|
|
51
|
+
displayName: 'Category',
|
|
52
|
+
description: 'Customer category (max 100 characters).',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
55
|
+
comment: pieces_framework_1.Property.LongText({
|
|
56
|
+
displayName: 'Comment',
|
|
57
|
+
description: 'Additional notes about the customer.',
|
|
58
|
+
required: false,
|
|
59
|
+
}),
|
|
60
|
+
discount_rate: pieces_framework_1.Property.Number({
|
|
61
|
+
displayName: 'Discount Rate',
|
|
62
|
+
description: 'Default discount rate for this customer.',
|
|
63
|
+
required: false,
|
|
64
|
+
}),
|
|
65
|
+
addresses: pieces_framework_1.Property.Array({
|
|
66
|
+
displayName: 'Addresses',
|
|
67
|
+
required: false,
|
|
68
|
+
properties: {
|
|
69
|
+
entity_type: pieces_framework_1.Property.StaticDropdown({
|
|
70
|
+
displayName: 'Address Type',
|
|
71
|
+
required: true,
|
|
72
|
+
options: {
|
|
73
|
+
options: [
|
|
74
|
+
{ label: 'Billing', value: 'billing' },
|
|
75
|
+
{ label: 'Shipping', value: 'shipping' },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
default: pieces_framework_1.Property.Checkbox({
|
|
80
|
+
displayName: 'Set as Default',
|
|
81
|
+
required: false,
|
|
82
|
+
}),
|
|
83
|
+
first_name: pieces_framework_1.Property.ShortText({
|
|
84
|
+
displayName: 'First Name',
|
|
85
|
+
required: false,
|
|
86
|
+
}),
|
|
87
|
+
last_name: pieces_framework_1.Property.ShortText({
|
|
88
|
+
displayName: 'Last Name',
|
|
89
|
+
required: false,
|
|
90
|
+
}),
|
|
91
|
+
company: pieces_framework_1.Property.ShortText({
|
|
92
|
+
displayName: 'Company',
|
|
93
|
+
required: false,
|
|
94
|
+
}),
|
|
95
|
+
phone: pieces_framework_1.Property.ShortText({
|
|
96
|
+
displayName: 'Phone',
|
|
97
|
+
required: false,
|
|
98
|
+
}),
|
|
99
|
+
line_1: pieces_framework_1.Property.ShortText({
|
|
100
|
+
displayName: 'Address Line 1',
|
|
101
|
+
required: false,
|
|
102
|
+
}),
|
|
103
|
+
line_2: pieces_framework_1.Property.ShortText({
|
|
104
|
+
displayName: 'Address Line 2',
|
|
105
|
+
required: false,
|
|
106
|
+
}),
|
|
107
|
+
city: pieces_framework_1.Property.ShortText({
|
|
108
|
+
displayName: 'City',
|
|
109
|
+
required: false,
|
|
110
|
+
}),
|
|
111
|
+
state: pieces_framework_1.Property.ShortText({
|
|
112
|
+
displayName: 'State',
|
|
113
|
+
required: false,
|
|
114
|
+
}),
|
|
115
|
+
zip: pieces_framework_1.Property.ShortText({
|
|
116
|
+
displayName: 'Zip/Postal Code',
|
|
117
|
+
required: false,
|
|
118
|
+
}),
|
|
119
|
+
country: pieces_framework_1.Property.ShortText({
|
|
120
|
+
displayName: 'Country',
|
|
121
|
+
required: false,
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
run(context) {
|
|
127
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const { name, first_name, last_name, company, email, phone, currency, reference_id, category, comment, discount_rate, addresses, } = context.propsValue;
|
|
129
|
+
const body = {
|
|
130
|
+
name,
|
|
131
|
+
};
|
|
132
|
+
if (first_name)
|
|
133
|
+
body['first_name'] = first_name;
|
|
134
|
+
if (last_name)
|
|
135
|
+
body['last_name'] = last_name;
|
|
136
|
+
if (company)
|
|
137
|
+
body['company'] = company;
|
|
138
|
+
if (email)
|
|
139
|
+
body['email'] = email;
|
|
140
|
+
if (phone)
|
|
141
|
+
body['phone'] = phone;
|
|
142
|
+
if (currency)
|
|
143
|
+
body['currency'] = currency;
|
|
144
|
+
if (reference_id)
|
|
145
|
+
body['reference_id'] = reference_id;
|
|
146
|
+
if (category)
|
|
147
|
+
body['category'] = category;
|
|
148
|
+
if (comment)
|
|
149
|
+
body['comment'] = comment;
|
|
150
|
+
if (discount_rate !== undefined && discount_rate !== null) {
|
|
151
|
+
body['discount_rate'] = discount_rate;
|
|
152
|
+
}
|
|
153
|
+
if (addresses && addresses.length > 0) {
|
|
154
|
+
body['addresses'] = addresses.map((addr) => {
|
|
155
|
+
const address = {
|
|
156
|
+
entity_type: addr.entity_type,
|
|
157
|
+
};
|
|
158
|
+
if (addr.default !== undefined)
|
|
159
|
+
address['default'] = addr.default;
|
|
160
|
+
if (addr.first_name)
|
|
161
|
+
address['first_name'] = addr.first_name;
|
|
162
|
+
if (addr.last_name)
|
|
163
|
+
address['last_name'] = addr.last_name;
|
|
164
|
+
if (addr.company)
|
|
165
|
+
address['company'] = addr.company;
|
|
166
|
+
if (addr.phone)
|
|
167
|
+
address['phone'] = addr.phone;
|
|
168
|
+
if (addr.line_1)
|
|
169
|
+
address['line_1'] = addr.line_1;
|
|
170
|
+
if (addr.line_2)
|
|
171
|
+
address['line_2'] = addr.line_2;
|
|
172
|
+
if (addr.city)
|
|
173
|
+
address['city'] = addr.city;
|
|
174
|
+
if (addr.state)
|
|
175
|
+
address['state'] = addr.state;
|
|
176
|
+
if (addr.zip)
|
|
177
|
+
address['zip'] = addr.zip;
|
|
178
|
+
if (addr.country)
|
|
179
|
+
address['country'] = addr.country;
|
|
180
|
+
return address;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
184
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
185
|
+
url: `${constants_1.BASE_URL}/customers`,
|
|
186
|
+
authentication: {
|
|
187
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
188
|
+
token: context.auth,
|
|
189
|
+
},
|
|
190
|
+
body,
|
|
191
|
+
});
|
|
192
|
+
return response.body;
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
//# sourceMappingURL=create-customer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-customer.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/actions/create-customer.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAIqC;AACrC,yCAA4C;AAC5C,mDAA+C;AAiBlC,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC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OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;oBACjD,IAAI,IAAI,CAAC,IAAI;wBAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;oBAC3C,IAAI,IAAI,CAAC,KAAK;wBAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;oBAC9C,IAAI,IAAI,CAAC,GAAG;wBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;oBACxC,IAAI,IAAI,CAAC,OAAO;wBAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;oBAEpD,OAAO,OAAO,CAAC;gBACjB,CAAC,CAAC,CAAC;YACL,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,oBAAQ,YAAY;gBAC5B,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAyB;iBACzC;gBACD,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const createSalesOrder: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
order_no: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
customer_id: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
variant_id: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
5
|
+
quantity: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
6
|
+
price_per_unit: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
7
|
+
total_discount: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
8
|
+
tax_rate_id: import("@activepieces/pieces-framework").DropdownProperty<number, false, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
9
|
+
additional_order_rows: import("@activepieces/pieces-framework").JsonProperty<false>;
|
|
10
|
+
status: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
11
|
+
location_id: import("@activepieces/pieces-framework").DropdownProperty<number, false, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
12
|
+
currency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
order_created_date: import("@activepieces/pieces-framework").DateTimeProperty<false>;
|
|
14
|
+
delivery_date: import("@activepieces/pieces-framework").DateTimeProperty<false>;
|
|
15
|
+
customer_ref: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
additional_info: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
17
|
+
tracking_number: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
18
|
+
tracking_number_url: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
19
|
+
addresses: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
20
|
+
ecommerce_order_type: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
21
|
+
ecommerce_store_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
22
|
+
ecommerce_order_id: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSalesOrder = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
const constants_1 = require("../common/constants");
|
|
9
|
+
const props_1 = require("../common/props");
|
|
10
|
+
exports.createSalesOrder = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.katanaAuth,
|
|
12
|
+
name: 'create_sales_order',
|
|
13
|
+
displayName: 'Create Sales Order',
|
|
14
|
+
description: 'Creates a new sales order in Katana.',
|
|
15
|
+
props: {
|
|
16
|
+
order_no: pieces_framework_1.Property.ShortText({
|
|
17
|
+
displayName: 'Order Number',
|
|
18
|
+
description: 'Unique order number.',
|
|
19
|
+
required: true,
|
|
20
|
+
}),
|
|
21
|
+
customer_id: props_1.customerDropdown,
|
|
22
|
+
// Simple mode: single product variant
|
|
23
|
+
variant_id: props_1.variantDropdown,
|
|
24
|
+
quantity: pieces_framework_1.Property.Number({
|
|
25
|
+
displayName: 'Quantity',
|
|
26
|
+
description: 'Quantity for the product variant.',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
price_per_unit: pieces_framework_1.Property.Number({
|
|
30
|
+
displayName: 'Price Per Unit',
|
|
31
|
+
description: 'Override price per unit.',
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
total_discount: pieces_framework_1.Property.Number({
|
|
35
|
+
displayName: 'Total Discount',
|
|
36
|
+
description: 'Discount amount for this line.',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
tax_rate_id: props_1.taxRateDropdown,
|
|
40
|
+
additional_order_rows: pieces_framework_1.Property.Json({
|
|
41
|
+
displayName: 'Additional Order Lines (JSON)',
|
|
42
|
+
description: 'Add more line items as JSON array. Each object needs: variant_id, quantity. Optional: price_per_unit, total_discount, tax_rate_id, location_id.',
|
|
43
|
+
required: false,
|
|
44
|
+
}),
|
|
45
|
+
status: pieces_framework_1.Property.StaticDropdown({
|
|
46
|
+
displayName: 'Status',
|
|
47
|
+
description: 'Order status. Use PENDING for quotes.',
|
|
48
|
+
required: false,
|
|
49
|
+
options: {
|
|
50
|
+
options: [
|
|
51
|
+
{ label: 'Not Shipped', value: 'NOT_SHIPPED' },
|
|
52
|
+
{ label: 'Pending (Quote)', value: 'PENDING' },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
location_id: props_1.locationDropdown,
|
|
57
|
+
currency: pieces_framework_1.Property.ShortText({
|
|
58
|
+
displayName: 'Currency',
|
|
59
|
+
description: 'Currency code (ISO 4217), e.g. USD, EUR.',
|
|
60
|
+
required: false,
|
|
61
|
+
}),
|
|
62
|
+
order_created_date: pieces_framework_1.Property.DateTime({
|
|
63
|
+
displayName: 'Order Created Date',
|
|
64
|
+
required: false,
|
|
65
|
+
}),
|
|
66
|
+
delivery_date: pieces_framework_1.Property.DateTime({
|
|
67
|
+
displayName: 'Delivery Date',
|
|
68
|
+
required: false,
|
|
69
|
+
}),
|
|
70
|
+
customer_ref: pieces_framework_1.Property.ShortText({
|
|
71
|
+
displayName: 'Customer Reference',
|
|
72
|
+
description: 'Customer reference number (max 255 characters).',
|
|
73
|
+
required: false,
|
|
74
|
+
}),
|
|
75
|
+
additional_info: pieces_framework_1.Property.LongText({
|
|
76
|
+
displayName: 'Additional Info',
|
|
77
|
+
description: 'Additional notes for this order.',
|
|
78
|
+
required: false,
|
|
79
|
+
}),
|
|
80
|
+
tracking_number: pieces_framework_1.Property.ShortText({
|
|
81
|
+
displayName: 'Tracking Number',
|
|
82
|
+
description: 'Shipping tracking number (max 256 characters).',
|
|
83
|
+
required: false,
|
|
84
|
+
}),
|
|
85
|
+
tracking_number_url: pieces_framework_1.Property.ShortText({
|
|
86
|
+
displayName: 'Tracking URL',
|
|
87
|
+
description: 'URL to track the shipment.',
|
|
88
|
+
required: false,
|
|
89
|
+
}),
|
|
90
|
+
addresses: pieces_framework_1.Property.Array({
|
|
91
|
+
displayName: 'Addresses',
|
|
92
|
+
required: false,
|
|
93
|
+
properties: {
|
|
94
|
+
entity_type: pieces_framework_1.Property.StaticDropdown({
|
|
95
|
+
displayName: 'Address Type',
|
|
96
|
+
required: true,
|
|
97
|
+
options: {
|
|
98
|
+
options: [
|
|
99
|
+
{ label: 'Billing', value: 'billing' },
|
|
100
|
+
{ label: 'Shipping', value: 'shipping' },
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
first_name: pieces_framework_1.Property.ShortText({
|
|
105
|
+
displayName: 'First Name',
|
|
106
|
+
required: false,
|
|
107
|
+
}),
|
|
108
|
+
last_name: pieces_framework_1.Property.ShortText({
|
|
109
|
+
displayName: 'Last Name',
|
|
110
|
+
required: false,
|
|
111
|
+
}),
|
|
112
|
+
company: pieces_framework_1.Property.ShortText({
|
|
113
|
+
displayName: 'Company',
|
|
114
|
+
required: false,
|
|
115
|
+
}),
|
|
116
|
+
phone: pieces_framework_1.Property.ShortText({
|
|
117
|
+
displayName: 'Phone',
|
|
118
|
+
required: false,
|
|
119
|
+
}),
|
|
120
|
+
line_1: pieces_framework_1.Property.ShortText({
|
|
121
|
+
displayName: 'Address Line 1',
|
|
122
|
+
required: false,
|
|
123
|
+
}),
|
|
124
|
+
line_2: pieces_framework_1.Property.ShortText({
|
|
125
|
+
displayName: 'Address Line 2',
|
|
126
|
+
required: false,
|
|
127
|
+
}),
|
|
128
|
+
city: pieces_framework_1.Property.ShortText({
|
|
129
|
+
displayName: 'City',
|
|
130
|
+
required: false,
|
|
131
|
+
}),
|
|
132
|
+
state: pieces_framework_1.Property.ShortText({
|
|
133
|
+
displayName: 'State',
|
|
134
|
+
required: false,
|
|
135
|
+
}),
|
|
136
|
+
zip: pieces_framework_1.Property.ShortText({
|
|
137
|
+
displayName: 'Zip/Postal Code',
|
|
138
|
+
required: false,
|
|
139
|
+
}),
|
|
140
|
+
country: pieces_framework_1.Property.ShortText({
|
|
141
|
+
displayName: 'Country',
|
|
142
|
+
required: false,
|
|
143
|
+
}),
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
ecommerce_order_type: pieces_framework_1.Property.ShortText({
|
|
147
|
+
displayName: 'E-commerce Order Type',
|
|
148
|
+
description: 'Source platform (e.g. shopify).',
|
|
149
|
+
required: false,
|
|
150
|
+
}),
|
|
151
|
+
ecommerce_store_name: pieces_framework_1.Property.ShortText({
|
|
152
|
+
displayName: 'E-commerce Store Name',
|
|
153
|
+
description: 'Store identifier.',
|
|
154
|
+
required: false,
|
|
155
|
+
}),
|
|
156
|
+
ecommerce_order_id: pieces_framework_1.Property.ShortText({
|
|
157
|
+
displayName: 'E-commerce Order ID',
|
|
158
|
+
description: 'External order ID from the e-commerce platform.',
|
|
159
|
+
required: false,
|
|
160
|
+
}),
|
|
161
|
+
},
|
|
162
|
+
run(context) {
|
|
163
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const { order_no, customer_id, variant_id, quantity, price_per_unit, total_discount, tax_rate_id, additional_order_rows, status, location_id, currency, order_created_date, delivery_date, customer_ref, additional_info, tracking_number, tracking_number_url, addresses, ecommerce_order_type, ecommerce_store_name, ecommerce_order_id, } = context.propsValue;
|
|
165
|
+
// Build the first order row
|
|
166
|
+
const firstRow = {
|
|
167
|
+
variant_id,
|
|
168
|
+
quantity,
|
|
169
|
+
};
|
|
170
|
+
if (price_per_unit !== undefined && price_per_unit !== null) {
|
|
171
|
+
firstRow['price_per_unit'] = price_per_unit;
|
|
172
|
+
}
|
|
173
|
+
if (total_discount !== undefined && total_discount !== null) {
|
|
174
|
+
firstRow['total_discount'] = total_discount;
|
|
175
|
+
}
|
|
176
|
+
if (tax_rate_id)
|
|
177
|
+
firstRow['tax_rate_id'] = tax_rate_id;
|
|
178
|
+
if (location_id)
|
|
179
|
+
firstRow['location_id'] = location_id;
|
|
180
|
+
// Start with the first row
|
|
181
|
+
const salesOrderRows = [firstRow];
|
|
182
|
+
// Add additional rows if provided
|
|
183
|
+
if (additional_order_rows) {
|
|
184
|
+
const additionalRows = Array.isArray(additional_order_rows)
|
|
185
|
+
? additional_order_rows
|
|
186
|
+
: [];
|
|
187
|
+
for (const row of additionalRows) {
|
|
188
|
+
const orderRow = {
|
|
189
|
+
variant_id: row.variant_id,
|
|
190
|
+
quantity: row.quantity,
|
|
191
|
+
};
|
|
192
|
+
if (row.price_per_unit !== undefined) {
|
|
193
|
+
orderRow['price_per_unit'] = row.price_per_unit;
|
|
194
|
+
}
|
|
195
|
+
if (row.total_discount !== undefined) {
|
|
196
|
+
orderRow['total_discount'] = row.total_discount;
|
|
197
|
+
}
|
|
198
|
+
if (row.tax_rate_id)
|
|
199
|
+
orderRow['tax_rate_id'] = row.tax_rate_id;
|
|
200
|
+
if (row.location_id)
|
|
201
|
+
orderRow['location_id'] = row.location_id;
|
|
202
|
+
salesOrderRows.push(orderRow);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const body = {
|
|
206
|
+
order_no,
|
|
207
|
+
customer_id,
|
|
208
|
+
sales_order_rows: salesOrderRows,
|
|
209
|
+
};
|
|
210
|
+
if (status)
|
|
211
|
+
body['status'] = status;
|
|
212
|
+
if (location_id)
|
|
213
|
+
body['location_id'] = location_id;
|
|
214
|
+
if (currency)
|
|
215
|
+
body['currency'] = currency;
|
|
216
|
+
if (order_created_date)
|
|
217
|
+
body['order_created_date'] = order_created_date;
|
|
218
|
+
if (delivery_date)
|
|
219
|
+
body['delivery_date'] = delivery_date;
|
|
220
|
+
if (customer_ref)
|
|
221
|
+
body['customer_ref'] = customer_ref;
|
|
222
|
+
if (additional_info)
|
|
223
|
+
body['additional_info'] = additional_info;
|
|
224
|
+
if (tracking_number)
|
|
225
|
+
body['tracking_number'] = tracking_number;
|
|
226
|
+
if (tracking_number_url)
|
|
227
|
+
body['tracking_number_url'] = tracking_number_url;
|
|
228
|
+
if (ecommerce_order_type)
|
|
229
|
+
body['ecommerce_order_type'] = ecommerce_order_type;
|
|
230
|
+
if (ecommerce_store_name)
|
|
231
|
+
body['ecommerce_store_name'] = ecommerce_store_name;
|
|
232
|
+
if (ecommerce_order_id)
|
|
233
|
+
body['ecommerce_order_id'] = ecommerce_order_id;
|
|
234
|
+
if (addresses && addresses.length > 0) {
|
|
235
|
+
body['addresses'] = addresses.map((addr) => {
|
|
236
|
+
const address = {
|
|
237
|
+
entity_type: addr.entity_type,
|
|
238
|
+
};
|
|
239
|
+
if (addr.first_name)
|
|
240
|
+
address['first_name'] = addr.first_name;
|
|
241
|
+
if (addr.last_name)
|
|
242
|
+
address['last_name'] = addr.last_name;
|
|
243
|
+
if (addr.company)
|
|
244
|
+
address['company'] = addr.company;
|
|
245
|
+
if (addr.phone)
|
|
246
|
+
address['phone'] = addr.phone;
|
|
247
|
+
if (addr.line_1)
|
|
248
|
+
address['line_1'] = addr.line_1;
|
|
249
|
+
if (addr.line_2)
|
|
250
|
+
address['line_2'] = addr.line_2;
|
|
251
|
+
if (addr.city)
|
|
252
|
+
address['city'] = addr.city;
|
|
253
|
+
if (addr.state)
|
|
254
|
+
address['state'] = addr.state;
|
|
255
|
+
if (addr.zip)
|
|
256
|
+
address['zip'] = addr.zip;
|
|
257
|
+
if (addr.country)
|
|
258
|
+
address['country'] = addr.country;
|
|
259
|
+
return address;
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
263
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
264
|
+
url: `${constants_1.BASE_URL}/sales_orders`,
|
|
265
|
+
authentication: {
|
|
266
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
267
|
+
token: context.auth.secret_text,
|
|
268
|
+
},
|
|
269
|
+
body,
|
|
270
|
+
});
|
|
271
|
+
return response.body;
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
//# sourceMappingURL=create-sales-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-sales-order.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/actions/create-sales-order.ts"],"names":[],"mappings":";;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D,IAAI,IAAI,CAAC,KAAK;wBAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;oBAC9C,IAAI,IAAI,CAAC,MAAM;wBAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;oBACjD,IAAI,IAAI,CAAC,MAAM;wBAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;oBACjD,IAAI,IAAI,CAAC,IAAI;wBAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;oBAC3C,IAAI,IAAI,CAAC,KAAK;wBAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;oBAC9C,IAAI,IAAI,CAAC,GAAG;wBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;oBACxC,IAAI,IAAI,CAAC,OAAO;wBAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;oBAEpD,OAAO,OAAO,CAAC;gBACjB,CAAC,CAAC,CAAC;YACL,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,oBAAQ,eAAe;gBAC/B,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;iBAChC;gBACD,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const findCustomer: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
first_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
last_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
company: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
phone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
currency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
reference_id: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
category: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
include_deleted: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
limit: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
13
|
+
page: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findCustomer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
const constants_1 = require("../common/constants");
|
|
9
|
+
exports.findCustomer = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.katanaAuth,
|
|
11
|
+
name: 'find_customer',
|
|
12
|
+
displayName: 'Find Customer',
|
|
13
|
+
description: 'Find a customer by name, email, or phone number.',
|
|
14
|
+
props: {
|
|
15
|
+
name: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Name',
|
|
17
|
+
description: 'Filters customers by name.',
|
|
18
|
+
required: false,
|
|
19
|
+
}),
|
|
20
|
+
first_name: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'First Name',
|
|
22
|
+
description: 'Filters customers by first name.',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
last_name: pieces_framework_1.Property.ShortText({
|
|
26
|
+
displayName: 'Last Name',
|
|
27
|
+
description: 'Filters customers by last name.',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
company: pieces_framework_1.Property.ShortText({
|
|
31
|
+
displayName: 'Company',
|
|
32
|
+
description: 'Filters customers by company.',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
email: pieces_framework_1.Property.ShortText({
|
|
36
|
+
displayName: 'Email',
|
|
37
|
+
description: 'Filters customers by email.',
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
phone: pieces_framework_1.Property.ShortText({
|
|
41
|
+
displayName: 'Phone',
|
|
42
|
+
description: 'Filters customers by phone number.',
|
|
43
|
+
required: false,
|
|
44
|
+
}),
|
|
45
|
+
currency: pieces_framework_1.Property.ShortText({
|
|
46
|
+
displayName: 'Currency',
|
|
47
|
+
description: 'Filters customers by currency.',
|
|
48
|
+
required: false,
|
|
49
|
+
}),
|
|
50
|
+
reference_id: pieces_framework_1.Property.ShortText({
|
|
51
|
+
displayName: 'Reference ID',
|
|
52
|
+
description: 'Filters customers by reference ID.',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
55
|
+
category: pieces_framework_1.Property.ShortText({
|
|
56
|
+
displayName: 'Category',
|
|
57
|
+
description: 'Filters customers by category.',
|
|
58
|
+
required: false,
|
|
59
|
+
}),
|
|
60
|
+
include_deleted: pieces_framework_1.Property.Checkbox({
|
|
61
|
+
displayName: 'Include Deleted',
|
|
62
|
+
description: 'Include soft-deleted customers in results.',
|
|
63
|
+
required: false,
|
|
64
|
+
}),
|
|
65
|
+
limit: pieces_framework_1.Property.Number({
|
|
66
|
+
displayName: 'Limit',
|
|
67
|
+
description: 'Maximum number of results to return (default is 50).',
|
|
68
|
+
required: false,
|
|
69
|
+
}),
|
|
70
|
+
page: pieces_framework_1.Property.Number({
|
|
71
|
+
displayName: 'Page',
|
|
72
|
+
description: 'Page number for pagination (default is 1).',
|
|
73
|
+
required: false,
|
|
74
|
+
}),
|
|
75
|
+
},
|
|
76
|
+
run(context) {
|
|
77
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const { name, first_name, last_name, company, email, phone, currency, reference_id, category, include_deleted, limit, page, } = context.propsValue;
|
|
79
|
+
const queryParams = {};
|
|
80
|
+
if (name)
|
|
81
|
+
queryParams['name'] = name;
|
|
82
|
+
if (first_name)
|
|
83
|
+
queryParams['first_name'] = first_name;
|
|
84
|
+
if (last_name)
|
|
85
|
+
queryParams['last_name'] = last_name;
|
|
86
|
+
if (company)
|
|
87
|
+
queryParams['company'] = company;
|
|
88
|
+
if (email)
|
|
89
|
+
queryParams['email'] = email;
|
|
90
|
+
if (phone)
|
|
91
|
+
queryParams['phone'] = phone;
|
|
92
|
+
if (currency)
|
|
93
|
+
queryParams['currency'] = currency;
|
|
94
|
+
if (reference_id)
|
|
95
|
+
queryParams['reference_id'] = reference_id;
|
|
96
|
+
if (category)
|
|
97
|
+
queryParams['category'] = category;
|
|
98
|
+
if (include_deleted !== undefined)
|
|
99
|
+
queryParams['include_deleted'] = include_deleted.toString();
|
|
100
|
+
if (limit !== undefined)
|
|
101
|
+
queryParams['limit'] = limit.toString();
|
|
102
|
+
if (page !== undefined)
|
|
103
|
+
queryParams['page'] = page.toString();
|
|
104
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
105
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
106
|
+
url: `${constants_1.BASE_URL}/customers`,
|
|
107
|
+
authentication: {
|
|
108
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
109
|
+
token: context.auth.secret_text,
|
|
110
|
+
},
|
|
111
|
+
queryParams,
|
|
112
|
+
});
|
|
113
|
+
return response.body;
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=find-customer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-customer.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/actions/find-customer.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAIqC;AACrC,yCAA4C;AAC5C,mDAA+C;AAElC,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,kDAAkD;IAC/D,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,oCAAoC;YACjD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YAC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AAG,OAAO,CAAC;YAC9C,IAAI,KAAK;gBAAE,WAAW,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;YACxC,IAAI,KAAK;gBAAE,WAAW,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;YACxC,IAAI,QAAQ;gBAAE,WAAW,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;YACjD,IAAI,YAAY;gBAAE,WAAW,CAAC,cAAc,CAAC,GAAG,YAAY,CAAC;YAC7D,IAAI,QAAQ;gBAAE,WAAW,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;YACjD,IAAI,eAAe,KAAK,SAAS;gBAAE,WAAW,CAAC,iBAAiB,CAAC,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;YAC/F,IAAI,KAAK,KAAK,SAAS;gBAAE,WAAW,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;YACjE,IAAI,IAAI,KAAK,SAAS;gBAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAE9D,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,oBAAQ,YAAY;gBAC5B,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;iBAChC;gBACD,WAAW;aACZ,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./create-customer"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./create-sales-order"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./find-customer"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/actions/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,+DAAqC;AACrC,0DAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const katanaAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.katanaAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
exports.katanaAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
9
|
+
displayName: 'API Key',
|
|
10
|
+
required: true,
|
|
11
|
+
description: `
|
|
12
|
+
To generate your API key:
|
|
13
|
+
|
|
14
|
+
1. Log in to your Katana account
|
|
15
|
+
2. Go to **Settings > API**
|
|
16
|
+
3. Select **Add new API key**
|
|
17
|
+
4. Copy and paste the key here
|
|
18
|
+
`,
|
|
19
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
20
|
+
try {
|
|
21
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
22
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
23
|
+
url: `${constants_1.BASE_URL}/products`,
|
|
24
|
+
authentication: {
|
|
25
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
26
|
+
token: auth,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
valid: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (_b) {
|
|
34
|
+
return {
|
|
35
|
+
valid: false,
|
|
36
|
+
error: 'Invalid API Key',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAA2D;AAC3D,+DAIqC;AACrC,2CAAuC;AAE1B,QAAA,UAAU,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC7C,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE;;;;;;;CAOd;IACC,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC3B,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,oBAAQ,WAAW;gBAC3B,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI;iBACZ;aACF,CAAC,CAAC;YAEH,OAAO;gBACL,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAAC,WAAM,CAAC;YACP,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,iBAAiB;aACzB,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.katanaApiCall = katanaApiCall;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
function katanaApiCall(auth, method, endpoint, body, queryParams) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
10
|
+
method,
|
|
11
|
+
url: `${constants_1.BASE_URL}${endpoint}`,
|
|
12
|
+
authentication: {
|
|
13
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
14
|
+
token: auth,
|
|
15
|
+
},
|
|
16
|
+
body,
|
|
17
|
+
queryParams,
|
|
18
|
+
});
|
|
19
|
+
return response.body;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/common/client.ts"],"names":[],"mappings":";;AAOA,sCAmBC;;AA1BD,+DAIqC;AACrC,2CAAuC;AAEvC,SAAsB,aAAa,CACjC,IAAY,EACZ,MAAkB,EAClB,QAAgB,EAChB,IAAc,EACd,WAAoC;;QAEpC,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAI;YAC/C,MAAM;YACN,GAAG,EAAE,GAAG,oBAAQ,GAAG,QAAQ,EAAE;YAC7B,cAAc,EAAE;gBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;gBACrC,KAAK,EAAE,IAAI;aACZ;YACD,IAAI;YACJ,WAAW;SACZ,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BASE_URL = "https://api.katanamrp.com/v1";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./auth"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./client"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./props"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/common/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,sDAA4B;AAC5B,mDAAyB;AACzB,kDAAwB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const customerDropdown: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
2
|
+
export declare const variantDropdown: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
export declare const taxRateDropdown: import("@activepieces/pieces-framework").DropdownProperty<number, false, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
export declare const locationDropdown: import("@activepieces/pieces-framework").DropdownProperty<number, false, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
5
|
+
export declare const locationDropdownRequired: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.locationDropdownRequired = exports.locationDropdown = exports.taxRateDropdown = exports.variantDropdown = exports.customerDropdown = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("./auth");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
exports.customerDropdown = pieces_framework_1.Property.Dropdown({
|
|
10
|
+
displayName: 'Customer',
|
|
11
|
+
description: 'Select the customer.',
|
|
12
|
+
required: true,
|
|
13
|
+
refreshers: [],
|
|
14
|
+
auth: auth_1.katanaAuth,
|
|
15
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
16
|
+
if (!auth) {
|
|
17
|
+
return {
|
|
18
|
+
disabled: true,
|
|
19
|
+
placeholder: 'Connect your account first',
|
|
20
|
+
options: [],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
25
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
26
|
+
url: `${constants_1.BASE_URL}/customers`,
|
|
27
|
+
authentication: {
|
|
28
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
29
|
+
token: auth.secret_text,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const customers = Array.isArray(response.body) ? response.body : [];
|
|
33
|
+
return {
|
|
34
|
+
disabled: false,
|
|
35
|
+
options: customers.map((customer) => ({
|
|
36
|
+
label: customer.name,
|
|
37
|
+
value: customer.id,
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (_b) {
|
|
42
|
+
return {
|
|
43
|
+
disabled: true,
|
|
44
|
+
placeholder: 'Failed to load customers',
|
|
45
|
+
options: [],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
exports.variantDropdown = pieces_framework_1.Property.Dropdown({
|
|
51
|
+
displayName: 'Product Variant',
|
|
52
|
+
description: 'Select the product variant.',
|
|
53
|
+
required: true,
|
|
54
|
+
refreshers: [],
|
|
55
|
+
auth: auth_1.katanaAuth,
|
|
56
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
57
|
+
if (!auth) {
|
|
58
|
+
return {
|
|
59
|
+
disabled: true,
|
|
60
|
+
placeholder: 'Connect your account first',
|
|
61
|
+
options: [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
66
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
67
|
+
url: `${constants_1.BASE_URL}/variants`,
|
|
68
|
+
authentication: {
|
|
69
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
70
|
+
token: auth.secret_text,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
const variants = Array.isArray(response.body) ? response.body : [];
|
|
74
|
+
return {
|
|
75
|
+
disabled: false,
|
|
76
|
+
options: variants.map((variant) => ({
|
|
77
|
+
label: variant.sku || variant.name || `Variant ${variant.id}`,
|
|
78
|
+
value: variant.id,
|
|
79
|
+
})),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (_b) {
|
|
83
|
+
return {
|
|
84
|
+
disabled: true,
|
|
85
|
+
placeholder: 'Failed to load variants',
|
|
86
|
+
options: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
exports.taxRateDropdown = pieces_framework_1.Property.Dropdown({
|
|
92
|
+
displayName: 'Tax Rate',
|
|
93
|
+
required: false,
|
|
94
|
+
refreshers: [],
|
|
95
|
+
auth: auth_1.katanaAuth,
|
|
96
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
97
|
+
if (!auth) {
|
|
98
|
+
return {
|
|
99
|
+
disabled: true,
|
|
100
|
+
placeholder: 'Connect your account first',
|
|
101
|
+
options: [],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
106
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
107
|
+
url: `${constants_1.BASE_URL}/tax_rates`,
|
|
108
|
+
authentication: {
|
|
109
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
110
|
+
token: auth.secret_text,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const taxRates = Array.isArray(response.body) ? response.body : [];
|
|
114
|
+
return {
|
|
115
|
+
disabled: false,
|
|
116
|
+
options: taxRates.map((rate) => ({
|
|
117
|
+
label: `${rate.name} (${rate.percentage}%)`,
|
|
118
|
+
value: rate.id,
|
|
119
|
+
})),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (_b) {
|
|
123
|
+
return {
|
|
124
|
+
disabled: false,
|
|
125
|
+
placeholder: 'No tax rates available',
|
|
126
|
+
options: [],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
exports.locationDropdown = pieces_framework_1.Property.Dropdown({
|
|
132
|
+
displayName: 'Location',
|
|
133
|
+
required: false,
|
|
134
|
+
refreshers: [],
|
|
135
|
+
auth: auth_1.katanaAuth,
|
|
136
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
137
|
+
if (!auth) {
|
|
138
|
+
return {
|
|
139
|
+
disabled: true,
|
|
140
|
+
placeholder: 'Connect your account first',
|
|
141
|
+
options: [],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
146
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
147
|
+
url: `${constants_1.BASE_URL}/locations`,
|
|
148
|
+
authentication: {
|
|
149
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
150
|
+
token: auth.secret_text,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
const locations = Array.isArray(response.body) ? response.body : [];
|
|
154
|
+
return {
|
|
155
|
+
disabled: false,
|
|
156
|
+
options: locations.map((location) => ({
|
|
157
|
+
label: location.name,
|
|
158
|
+
value: location.id,
|
|
159
|
+
})),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
catch (_b) {
|
|
163
|
+
return {
|
|
164
|
+
disabled: false,
|
|
165
|
+
placeholder: 'No locations available',
|
|
166
|
+
options: [],
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}),
|
|
170
|
+
});
|
|
171
|
+
exports.locationDropdownRequired = pieces_framework_1.Property.Dropdown({
|
|
172
|
+
displayName: 'Default Location',
|
|
173
|
+
description: 'Default location for the order.',
|
|
174
|
+
required: true,
|
|
175
|
+
refreshers: [],
|
|
176
|
+
auth: auth_1.katanaAuth,
|
|
177
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
178
|
+
if (!auth) {
|
|
179
|
+
return {
|
|
180
|
+
disabled: true,
|
|
181
|
+
placeholder: 'Connect your account first',
|
|
182
|
+
options: [],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
187
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
188
|
+
url: `${constants_1.BASE_URL}/locations`,
|
|
189
|
+
authentication: {
|
|
190
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
191
|
+
token: auth.secret_text,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
const locations = Array.isArray(response.body) ? response.body : [];
|
|
195
|
+
return {
|
|
196
|
+
disabled: false,
|
|
197
|
+
options: locations.map((location) => ({
|
|
198
|
+
label: location.name,
|
|
199
|
+
value: location.id,
|
|
200
|
+
})),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
catch (_b) {
|
|
204
|
+
return {
|
|
205
|
+
disabled: false,
|
|
206
|
+
placeholder: 'No locations available',
|
|
207
|
+
options: [],
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}),
|
|
211
|
+
});
|
|
212
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/katana/src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA0D;AAC1D,+DAIqC;AACrC,iCAAoC;AACpC,2CAAuC;AAwB1B,QAAA,gBAAgB,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAChD,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,sBAAsB;IACnC,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,iBAAU;IAChB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,4BAA4B;gBACzC,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAmB;gBAC9D,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,oBAAQ,YAAY;gBAC5B,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,WAAW;iBACxB;aACF,CAAC,CAAC;YAEH,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;oBACpC,KAAK,EAAE,QAAQ,CAAC,IAAI;oBACpB,KAAK,EAAE,QAAQ,CAAC,EAA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