@vqnguyen1/piece-sellercloud 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/package.json +9 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +41 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/get-product-inventory.d.ts +9 -0
- package/src/lib/actions/get-product-inventory.js +56 -0
- package/src/lib/actions/get-product-inventory.js.map +1 -0
- package/src/lib/actions/get-queued-job.d.ts +10 -0
- package/src/lib/actions/get-queued-job.js +40 -0
- package/src/lib/actions/get-queued-job.js.map +1 -0
- package/src/lib/actions/import-inventory-from-csv.d.ts +25 -0
- package/src/lib/actions/import-inventory-from-csv.js +119 -0
- package/src/lib/actions/import-inventory-from-csv.js.map +1 -0
- package/src/lib/actions/import-physical-inventory.d.ts +18 -0
- package/src/lib/actions/import-physical-inventory.js +65 -0
- package/src/lib/actions/import-physical-inventory.js.map +1 -0
- package/src/lib/actions/list-warehouses.d.ts +6 -0
- package/src/lib/actions/list-warehouses.js +33 -0
- package/src/lib/actions/list-warehouses.js.map +1 -0
- package/src/lib/auth.d.ts +6 -0
- package/src/lib/auth.js +42 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +51 -0
- package/src/lib/common/client.js +96 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/csv-mapping.d.ts +33 -0
- package/src/lib/common/csv-mapping.js +111 -0
- package/src/lib/common/csv-mapping.js.map +1 -0
- package/src/lib/common/inventory.d.ts +64 -0
- package/src/lib/common/inventory.js +110 -0
- package/src/lib/common/inventory.js.map +1 -0
- package/src/lib/common/props.d.ts +12 -0
- package/src/lib/common/props.js +66 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/common/run-import.d.ts +38 -0
- package/src/lib/common/run-import.js +39 -0
- package/src/lib/common/run-import.js.map +1 -0
package/package.json
ADDED
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const sellercloud: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
6
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sellercloud = 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 get_product_inventory_1 = require("./lib/actions/get-product-inventory");
|
|
9
|
+
const get_queued_job_1 = require("./lib/actions/get-queued-job");
|
|
10
|
+
const import_inventory_from_csv_1 = require("./lib/actions/import-inventory-from-csv");
|
|
11
|
+
const import_physical_inventory_1 = require("./lib/actions/import-physical-inventory");
|
|
12
|
+
const list_warehouses_1 = require("./lib/actions/list-warehouses");
|
|
13
|
+
const auth_1 = require("./lib/auth");
|
|
14
|
+
const client_1 = require("./lib/common/client");
|
|
15
|
+
exports.sellercloud = (0, pieces_framework_1.createPiece)({
|
|
16
|
+
displayName: 'SellerCloud',
|
|
17
|
+
description: 'Multichannel inventory and order management: import physical inventory, check stock and track queued jobs.',
|
|
18
|
+
minimumSupportedRelease: '0.36.1',
|
|
19
|
+
logoUrl: 'data:image/webp;base64,UklGRlAGAABXRUJQVlA4WAoAAAAQAAAAfwAAfwAAQUxQSJ4BAAABR6A0kiQ1eRmQIgX/niMiAFX+mpGQY21741S/wwJk2ICzWzKUjkMrbi7JUOZQW9Lo2zdp5rzn3Dqi/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ions: [
|
|
24
|
+
import_inventory_from_csv_1.importInventoryFromCsv,
|
|
25
|
+
import_physical_inventory_1.importPhysicalInventory,
|
|
26
|
+
get_queued_job_1.getQueuedJob,
|
|
27
|
+
get_product_inventory_1.getProductInventory,
|
|
28
|
+
list_warehouses_1.listWarehouses,
|
|
29
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
30
|
+
auth: auth_1.sellercloudAuth,
|
|
31
|
+
baseUrl: (auth) => (auth ? client_1.sellercloudClient.apiBase({ auth: auth.props }) : ''),
|
|
32
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
return ({
|
|
34
|
+
Authorization: `Bearer ${yield client_1.sellercloudClient.getToken({ auth: auth.props })}`,
|
|
35
|
+
});
|
|
36
|
+
}),
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
triggers: [],
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAA6D;AAC7D,iDAAqD;AACrD,+EAA0E;AAC1E,iEAA4D;AAC5D,uFAAiF;AACjF,uFAAkF;AAClF,mEAA+D;AAC/D,qCAA6C;AAC7C,gDAAwD;AAE3C,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,4GAA4G;IACzH,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,ipEAAipE;IAC1pE,UAAU,EAAE,CAAC,sBAAa,CAAC,QAAQ,CAAC;IACpC,IAAI,EAAE,sBAAe;IACrB,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,OAAO,EAAE;QACL,kDAAsB;QACtB,mDAAuB;QACvB,6BAAY;QACZ,2CAAmB;QACnB,gCAAc;QACd,IAAA,yCAAyB,EAAC;YACtB,IAAI,EAAE,sBAAe;YACrB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAAiB,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChF,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC1B,aAAa,EAAE,UAAU,MAAM,0BAAiB,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE;iBACpF,CAAC,CAAA;cAAA;SACL,CAAC;KACL;IACD,QAAQ,EAAE,EAAE;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getProductInventory: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
6
|
+
}>, {
|
|
7
|
+
productId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
onlyNonZero: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProductInventory = 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
|
+
exports.getProductInventory = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.sellercloudAuth,
|
|
11
|
+
name: 'get_product_inventory',
|
|
12
|
+
displayName: 'Get Product Inventory',
|
|
13
|
+
description: 'Get physical and available quantity for a product in each warehouse.',
|
|
14
|
+
props: {
|
|
15
|
+
productId: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Product ID (SKU)',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
onlyNonZero: pieces_framework_1.Property.Checkbox({
|
|
20
|
+
displayName: 'Only Warehouses With Stock',
|
|
21
|
+
required: false,
|
|
22
|
+
defaultValue: false,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
run(context) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const { productId, onlyNonZero } = context.propsValue;
|
|
28
|
+
const auth = context.auth.props;
|
|
29
|
+
const token = yield client_1.sellercloudClient.getToken({ auth });
|
|
30
|
+
const [rows, warehouses] = yield Promise.all([
|
|
31
|
+
client_1.sellercloudClient.request({
|
|
32
|
+
auth,
|
|
33
|
+
token,
|
|
34
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
35
|
+
path: '/Inventory/Warehouses',
|
|
36
|
+
queryParams: { productID: productId },
|
|
37
|
+
}),
|
|
38
|
+
client_1.sellercloudClient.listWarehouses({ auth, token }),
|
|
39
|
+
]);
|
|
40
|
+
const names = new Map(warehouses.map((w) => [w.ID, w.Name]));
|
|
41
|
+
const inventory = rows
|
|
42
|
+
.filter((row) => !onlyNonZero || row.PhysicalQty !== 0 || row.AvailableQty !== 0)
|
|
43
|
+
.map((row) => {
|
|
44
|
+
var _a;
|
|
45
|
+
return ({
|
|
46
|
+
warehouse_id: row.WarehouseID,
|
|
47
|
+
warehouse_name: (_a = names.get(row.WarehouseID)) !== null && _a !== void 0 ? _a : null,
|
|
48
|
+
physical_qty: row.PhysicalQty,
|
|
49
|
+
available_qty: row.AvailableQty,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return { product_id: productId, inventory };
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=get-product-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-product-inventory.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-product-inventory.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAA0C;AAC1C,6CAAqD;AAExC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,sEAAsE;IACnF,KAAK,EAAE;QACH,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC3B,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;SACtB,CAAC;KACL;IACK,GAAG,CAAC,OAAO;;YACb,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YAChC,MAAM,KAAK,GAAG,MAAM,0BAAiB,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YACzD,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACzC,0BAAiB,CAAC,OAAO,CAAuB;oBAC5C,IAAI;oBACJ,KAAK;oBACL,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,IAAI,EAAE,uBAAuB;oBAC7B,WAAW,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE;iBACxC,CAAC;gBACF,0BAAiB,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;aACpD,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,SAAS,GAAG,IAAI;iBACjB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,KAAK,CAAC,IAAI,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC;iBAChF,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;;gBAAC,OAAA,CAAC;oBACX,YAAY,EAAE,GAAG,CAAC,WAAW;oBAC7B,cAAc,EAAE,MAAA,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,mCAAI,IAAI;oBAClD,YAAY,EAAE,GAAG,CAAC,WAAW;oBAC7B,aAAa,EAAE,GAAG,CAAC,YAAY;iBAClC,CAAC,CAAA;aAAA,CAAC,CAAC;YACR,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QAChD,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const getQueuedJob: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
6
|
+
}>, {
|
|
7
|
+
jobId: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
8
|
+
wait: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
9
|
+
timeoutSeconds: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getQueuedJob = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const inventory_1 = require("../common/inventory");
|
|
8
|
+
exports.getQueuedJob = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.sellercloudAuth,
|
|
10
|
+
name: 'get_queued_job',
|
|
11
|
+
displayName: 'Get Queued Job',
|
|
12
|
+
description: 'Get the status of a SellerCloud queued job (for example an inventory import), optionally waiting for it to finish.',
|
|
13
|
+
props: {
|
|
14
|
+
jobId: pieces_framework_1.Property.Number({
|
|
15
|
+
displayName: 'Job ID',
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
wait: pieces_framework_1.Property.Checkbox({
|
|
19
|
+
displayName: 'Wait Until Finished',
|
|
20
|
+
required: false,
|
|
21
|
+
defaultValue: false,
|
|
22
|
+
}),
|
|
23
|
+
timeoutSeconds: pieces_framework_1.Property.Number({
|
|
24
|
+
displayName: 'Wait Timeout (seconds)',
|
|
25
|
+
required: false,
|
|
26
|
+
defaultValue: 300,
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
run(context) {
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const { jobId, wait, timeoutSeconds } = context.propsValue;
|
|
32
|
+
const auth = context.auth.props;
|
|
33
|
+
if (wait) {
|
|
34
|
+
return inventory_1.inventoryImport.waitForJob({ auth, jobId, timeoutSeconds: timeoutSeconds !== null && timeoutSeconds !== void 0 ? timeoutSeconds : 300 });
|
|
35
|
+
}
|
|
36
|
+
return inventory_1.inventoryImport.getJob({ auth, jobId });
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=get-queued-job.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-queued-job.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-queued-job.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAA0C;AAC1C,mDAAsD;AAEzC,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,oHAAoH;IACjI,KAAK,EAAE;QACH,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACnB,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACpB,WAAW,EAAE,qBAAqB;YAClC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;SACtB,CAAC;QACF,cAAc,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC5B,WAAW,EAAE,wBAAwB;YACrC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,GAAG;SACpB,CAAC;KACL;IACK,GAAG,CAAC,OAAO;;YACb,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YAChC,IAAI,IAAI,EAAE,CAAC;gBACP,OAAO,2BAAe,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,GAAG,EAAE,CAAC,CAAC;YAC9F,CAAC;YACD,OAAO,2BAAe,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const importInventoryFromCsv: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
6
|
+
}>, {
|
|
7
|
+
warehouse: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
8
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
12
|
+
}>>;
|
|
13
|
+
file: import("@activepieces/pieces-framework").FileProperty<true>;
|
|
14
|
+
partNumberColumn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
15
|
+
quantityColumn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
16
|
+
skuSuffix: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
matchWithoutSuffix: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
18
|
+
stripLeadingZeros: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
19
|
+
onlyProductIds: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
20
|
+
updateType: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
21
|
+
inventoryDate: import("@activepieces/pieces-framework").DateTimeProperty<false>;
|
|
22
|
+
dryRun: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
23
|
+
waitForCompletion: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
24
|
+
timeoutSeconds: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importInventoryFromCsv = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const client_1 = require("../common/client");
|
|
8
|
+
const csv_mapping_1 = require("../common/csv-mapping");
|
|
9
|
+
const props_1 = require("../common/props");
|
|
10
|
+
const run_import_1 = require("../common/run-import");
|
|
11
|
+
exports.importInventoryFromCsv = (0, pieces_framework_1.createAction)({
|
|
12
|
+
auth: auth_1.sellercloudAuth,
|
|
13
|
+
name: 'import_inventory_from_csv',
|
|
14
|
+
displayName: 'Import Inventory from CSV',
|
|
15
|
+
description: 'Map a supplier CSV (part number + quantity) onto SellerCloud products and import it as physical inventory for one warehouse.',
|
|
16
|
+
props: {
|
|
17
|
+
warehouse: props_1.sellercloudProps.warehouse,
|
|
18
|
+
file: pieces_framework_1.Property.File({
|
|
19
|
+
displayName: 'CSV File',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
partNumberColumn: pieces_framework_1.Property.ShortText({
|
|
23
|
+
displayName: 'Part Number Column',
|
|
24
|
+
required: true,
|
|
25
|
+
defaultValue: 'PART NUMBER',
|
|
26
|
+
}),
|
|
27
|
+
quantityColumn: pieces_framework_1.Property.ShortText({
|
|
28
|
+
displayName: 'Quantity Column',
|
|
29
|
+
required: true,
|
|
30
|
+
defaultValue: 'INV QTY',
|
|
31
|
+
}),
|
|
32
|
+
skuSuffix: pieces_framework_1.Property.ShortText({
|
|
33
|
+
displayName: 'SKU Suffix',
|
|
34
|
+
description: 'Added to each part number to find the SellerCloud product, e.g. "-awp" turns 68227305AA into 68227305AA-awp. Leave empty to match part numbers as-is.',
|
|
35
|
+
required: false,
|
|
36
|
+
defaultValue: '-awp',
|
|
37
|
+
}),
|
|
38
|
+
matchWithoutSuffix: pieces_framework_1.Property.Checkbox({
|
|
39
|
+
displayName: 'Also Match Without Suffix',
|
|
40
|
+
description: 'If PART-suffix is not a SellerCloud product, try the bare part number.',
|
|
41
|
+
required: false,
|
|
42
|
+
defaultValue: true,
|
|
43
|
+
}),
|
|
44
|
+
stripLeadingZeros: pieces_framework_1.Property.Checkbox({
|
|
45
|
+
displayName: 'Also Match Without Leading Zeros',
|
|
46
|
+
description: 'For all-digit part numbers, also try 4884899 when the file says 04884899.',
|
|
47
|
+
required: false,
|
|
48
|
+
defaultValue: true,
|
|
49
|
+
}),
|
|
50
|
+
onlyProductIds: pieces_framework_1.Property.Array({
|
|
51
|
+
displayName: 'Only These Products',
|
|
52
|
+
description: 'For testing: import only these SellerCloud product IDs from the file. Requires Partial.',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
55
|
+
updateType: props_1.sellercloudProps.updateType,
|
|
56
|
+
inventoryDate: props_1.sellercloudProps.inventoryDate,
|
|
57
|
+
dryRun: pieces_framework_1.Property.Checkbox({
|
|
58
|
+
displayName: 'Dry Run',
|
|
59
|
+
description: 'Match the file and return what would be imported, without sending anything to SellerCloud.',
|
|
60
|
+
required: false,
|
|
61
|
+
defaultValue: false,
|
|
62
|
+
}),
|
|
63
|
+
waitForCompletion: props_1.sellercloudProps.waitForCompletion,
|
|
64
|
+
timeoutSeconds: props_1.sellercloudProps.timeoutSeconds,
|
|
65
|
+
},
|
|
66
|
+
run(context) {
|
|
67
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
var _a, _b, _c, _d, _e, _f;
|
|
69
|
+
const props = context.propsValue;
|
|
70
|
+
const updateType = props.updateType === 'FULL' ? 'FULL' : 'PARTIAL';
|
|
71
|
+
const onlyProductIds = ((_a = props.onlyProductIds) !== null && _a !== void 0 ? _a : []).map((id) => String(id).trim()).filter((id) => id !== '');
|
|
72
|
+
if (updateType === 'FULL' && onlyProductIds.length > 0) {
|
|
73
|
+
throw new Error('"Only These Products" can\'t be combined with Full: a Full import would set every other product in the warehouse to 0.');
|
|
74
|
+
}
|
|
75
|
+
const auth = context.auth.props;
|
|
76
|
+
const token = yield client_1.sellercloudClient.getToken({ auth });
|
|
77
|
+
const catalogIds = yield client_1.sellercloudClient.listCatalogProductIds({ auth, token });
|
|
78
|
+
const mapping = csv_mapping_1.csvMapping.mapToCatalog({
|
|
79
|
+
text: props.file.data.toString('utf8'),
|
|
80
|
+
partNumberColumn: props.partNumberColumn,
|
|
81
|
+
quantityColumn: props.quantityColumn,
|
|
82
|
+
catalogIds,
|
|
83
|
+
match: {
|
|
84
|
+
suffix: ((_b = props.skuSuffix) !== null && _b !== void 0 ? _b : '').trim(),
|
|
85
|
+
matchWithoutSuffix: (_c = props.matchWithoutSuffix) !== null && _c !== void 0 ? _c : true,
|
|
86
|
+
stripLeadingZeros: (_d = props.stripLeadingZeros) !== null && _d !== void 0 ? _d : true,
|
|
87
|
+
},
|
|
88
|
+
onlyProductIds,
|
|
89
|
+
});
|
|
90
|
+
const summary = {
|
|
91
|
+
fileName: props.file.filename,
|
|
92
|
+
catalogProducts: catalogIds.length,
|
|
93
|
+
fileRows: mapping.fileRows,
|
|
94
|
+
matchedRows: mapping.matchedRows,
|
|
95
|
+
unmatchedRows: mapping.unmatchedRows,
|
|
96
|
+
unmatchedSample: mapping.unmatchedSample,
|
|
97
|
+
productsToImport: mapping.rows.length,
|
|
98
|
+
missingFromFile: mapping.missingFromFile,
|
|
99
|
+
updateType,
|
|
100
|
+
};
|
|
101
|
+
if (props.dryRun) {
|
|
102
|
+
const warehouse = yield run_import_1.importRunner.findWarehouse({ auth, token, warehouseId: props.warehouse });
|
|
103
|
+
return Object.assign(Object.assign({}, summary), { dryRun: true, warehouse, preview: mapping.rows.slice(0, 50) });
|
|
104
|
+
}
|
|
105
|
+
const outcome = yield run_import_1.importRunner.runImport({
|
|
106
|
+
auth,
|
|
107
|
+
token,
|
|
108
|
+
warehouseId: props.warehouse,
|
|
109
|
+
rows: mapping.rows,
|
|
110
|
+
updateType,
|
|
111
|
+
inventoryDate: props.inventoryDate ? new Date(props.inventoryDate) : new Date(),
|
|
112
|
+
waitForCompletion: (_e = props.waitForCompletion) !== null && _e !== void 0 ? _e : true,
|
|
113
|
+
timeoutSeconds: (_f = props.timeoutSeconds) !== null && _f !== void 0 ? _f : 300,
|
|
114
|
+
});
|
|
115
|
+
return Object.assign(Object.assign(Object.assign({}, summary), { dryRun: false }), outcome);
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=import-inventory-from-csv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-inventory-from-csv.js","sourceRoot":"","sources":["../../../../src/lib/actions/import-inventory-from-csv.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAA0C;AAC1C,6CAAqD;AACrD,uDAAmD;AACnD,2CAAmD;AACnD,qDAAoD;AAEvC,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE,2BAA2B;IACxC,WAAW,EAAE,8HAA8H;IAC3I,KAAK,EAAE;QACH,SAAS,EAAE,wBAAgB,CAAC,SAAS;QACrC,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAChB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,gBAAgB,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACjC,WAAW,EAAE,oBAAoB;YACjC,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,aAAa;SAC9B,CAAC;QACF,cAAc,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE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gBAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,eAAe,EAAE,OAAO,CAAC,eAAe;gBACxC,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM;gBACrC,eAAe,EAAE,OAAO,CAAC,eAAe;gBACxC,UAAU;aACb,CAAC;YACF,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBACf,MAAM,SAAS,GAAG,MAAM,yBAAY,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;gBAClG,uCAAY,OAAO,KAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAG;YACvF,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,yBAAY,CAAC,SAAS,CAAC;gBACzC,IAAI;gBACJ,KAAK;gBACL,WAAW,EAAE,KAAK,CAAC,SAAS;gBAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,UAAU;gBACV,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;gBAC/E,iBAAiB,EAAE,MAAA,KAAK,CAAC,iBAAiB,mCAAI,IAAI;gBAClD,cAAc,EAAE,MAAA,KAAK,CAAC,cAAc,mCAAI,GAAG;aAC9C,CAAC,CAAC;YACH,qDAAY,OAAO,KAAE,MAAM,EAAE,KAAK,KAAK,OAAO,EAAG;QACrD,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const importPhysicalInventory: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
6
|
+
}>, {
|
|
7
|
+
warehouse: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
8
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
12
|
+
}>>;
|
|
13
|
+
items: import("@activepieces/pieces-framework").JsonProperty<true>;
|
|
14
|
+
updateType: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
15
|
+
inventoryDate: import("@activepieces/pieces-framework").DateTimeProperty<false>;
|
|
16
|
+
waitForCompletion: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
17
|
+
timeoutSeconds: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importPhysicalInventory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const client_1 = require("../common/client");
|
|
8
|
+
const props_1 = require("../common/props");
|
|
9
|
+
const run_import_1 = require("../common/run-import");
|
|
10
|
+
exports.importPhysicalInventory = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.sellercloudAuth,
|
|
12
|
+
name: 'import_physical_inventory',
|
|
13
|
+
displayName: 'Import Physical Inventory',
|
|
14
|
+
description: 'Set physical inventory for a list of products in one warehouse, as one SellerCloud import job.',
|
|
15
|
+
props: {
|
|
16
|
+
warehouse: props_1.sellercloudProps.warehouse,
|
|
17
|
+
items: pieces_framework_1.Property.Json({
|
|
18
|
+
displayName: 'Items',
|
|
19
|
+
description: 'An array of { "productId": "...", "quantity": 0 } objects.',
|
|
20
|
+
required: true,
|
|
21
|
+
defaultValue: [{ productId: 'SKU-1', quantity: 0 }],
|
|
22
|
+
}),
|
|
23
|
+
updateType: props_1.sellercloudProps.updateType,
|
|
24
|
+
inventoryDate: props_1.sellercloudProps.inventoryDate,
|
|
25
|
+
waitForCompletion: props_1.sellercloudProps.waitForCompletion,
|
|
26
|
+
timeoutSeconds: props_1.sellercloudProps.timeoutSeconds,
|
|
27
|
+
},
|
|
28
|
+
run(context) {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const props = context.propsValue;
|
|
32
|
+
const rows = parseItems({ items: props.items });
|
|
33
|
+
const auth = context.auth.props;
|
|
34
|
+
const token = yield client_1.sellercloudClient.getToken({ auth });
|
|
35
|
+
return run_import_1.importRunner.runImport({
|
|
36
|
+
auth,
|
|
37
|
+
token,
|
|
38
|
+
warehouseId: props.warehouse,
|
|
39
|
+
rows,
|
|
40
|
+
updateType: props.updateType === 'FULL' ? 'FULL' : 'PARTIAL',
|
|
41
|
+
inventoryDate: props.inventoryDate ? new Date(props.inventoryDate) : new Date(),
|
|
42
|
+
waitForCompletion: (_a = props.waitForCompletion) !== null && _a !== void 0 ? _a : true,
|
|
43
|
+
timeoutSeconds: (_b = props.timeoutSeconds) !== null && _b !== void 0 ? _b : 300,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
function parseItems({ items }) {
|
|
49
|
+
if (!Array.isArray(items)) {
|
|
50
|
+
throw new Error('Items must be a JSON array of { productId, quantity } objects.');
|
|
51
|
+
}
|
|
52
|
+
return items.map((item, index) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const productId = isRecord(item) ? String((_a = item['productId']) !== null && _a !== void 0 ? _a : '').trim() : '';
|
|
55
|
+
const quantity = isRecord(item) ? Number(item['quantity']) : NaN;
|
|
56
|
+
if (productId === '' || !Number.isInteger(quantity) || quantity < 0) {
|
|
57
|
+
throw new Error(`Item ${index} needs a productId and a whole, non-negative quantity: ${JSON.stringify(item)}`);
|
|
58
|
+
}
|
|
59
|
+
return { productId, quantity };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function isRecord(value) {
|
|
63
|
+
return typeof value === 'object' && value !== null;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=import-physical-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-physical-inventory.js","sourceRoot":"","sources":["../../../../src/lib/actions/import-physical-inventory.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAA0C;AAC1C,6CAAqD;AAErD,2CAAmD;AACnD,qDAAoD;AAEvC,QAAA,uBAAuB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE,2BAA2B;IACxC,WAAW,EAAE,gGAAgG;IAC7G,KAAK,EAAE;QACH,SAAS,EAAE,wBAAgB,CAAC,SAAS;QACrC,KAAK,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACjB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,4DAA4D;YACzE,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;SACtD,CAAC;QACF,UAAU,EAAE,wBAAgB,CAAC,UAAU;QACvC,aAAa,EAAE,wBAAgB,CAAC,aAAa;QAC7C,iBAAiB,EAAE,wBAAgB,CAAC,iBAAiB;QACrD,cAAc,EAAE,wBAAgB,CA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I,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/E,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACjE,IAAI,SAAS,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YAClE,MAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,0DAA0D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnH,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const listWarehouses: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
6
|
+
}>, {}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listWarehouses = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const client_1 = require("../common/client");
|
|
8
|
+
exports.listWarehouses = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.sellercloudAuth,
|
|
10
|
+
name: 'list_warehouses',
|
|
11
|
+
displayName: 'List Warehouses',
|
|
12
|
+
description: 'List all warehouses with their IDs.',
|
|
13
|
+
props: {},
|
|
14
|
+
run(context) {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const warehouses = yield client_1.sellercloudClient.listWarehouses({ auth: context.auth.props });
|
|
17
|
+
return {
|
|
18
|
+
total: warehouses.length,
|
|
19
|
+
warehouses: warehouses.map((w) => {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
return ({
|
|
22
|
+
id: w.ID,
|
|
23
|
+
name: w.Name,
|
|
24
|
+
is_default: (_a = w.IsDefault) !== null && _a !== void 0 ? _a : false,
|
|
25
|
+
warehouse_type: (_b = w.WarehouseType) !== null && _b !== void 0 ? _b : null,
|
|
26
|
+
is_sellable: (_c = w.IsSellAble) !== null && _c !== void 0 ? _c : null,
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=list-warehouses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-warehouses.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-warehouses.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,kCAA0C;AAC1C,6CAAqD;AAExC,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,qCAAqC;IAClD,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;YACb,MAAM,UAAU,GAAG,MAAM,0BAAiB,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YACxF,OAAO;gBACH,KAAK,EAAE,UAAU,CAAC,MAAM;gBACxB,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;;oBAAC,OAAA,CAAC;wBAC/B,EAAE,EAAE,CAAC,CAAC,EAAE;wBACR,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,UAAU,EAAE,MAAA,CAAC,CAAC,SAAS,mCAAI,KAAK;wBAChC,cAAc,EAAE,MAAA,CAAC,CAAC,aAAa,mCAAI,IAAI;wBACvC,WAAW,EAAE,MAAA,CAAC,CAAC,UAAU,mCAAI,IAAI;qBACpC,CAAC,CAAA;iBAAA,CAAC;aACN,CAAC;QACN,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const sellercloudAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
6
|
+
}>;
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sellercloudAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const client_1 = require("./common/client");
|
|
7
|
+
exports.sellercloudAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
8
|
+
description: `Connect a SellerCloud account with a username and password (SellerCloud's REST API has no OAuth or API keys).
|
|
9
|
+
|
|
10
|
+
1. **REST API URL**: open \`https://api.sellercloud.com/api/server-by-team/?team=<your team>\` and copy \`RestApiEndpoint\`, e.g. \`https://allwholesale.api.sellercloud.us/rest\`.
|
|
11
|
+
2. **Username / Password**: use a dedicated API user with only the permissions your flows need.
|
|
12
|
+
3. **PIN**: only needed when the company setting "Require PIN to change inventory quantity" is on.`,
|
|
13
|
+
required: true,
|
|
14
|
+
props: {
|
|
15
|
+
serverUrl: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'REST API URL',
|
|
17
|
+
description: 'The RestApiEndpoint for your team, ending in /rest.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
username: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Username',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
password: pieces_framework_1.PieceAuth.SecretText({
|
|
25
|
+
displayName: 'Password',
|
|
26
|
+
required: true,
|
|
27
|
+
}),
|
|
28
|
+
pinCode: pieces_framework_1.PieceAuth.SecretText({
|
|
29
|
+
displayName: 'Inventory PIN',
|
|
30
|
+
description: 'Only if SellerCloud requires a PIN to change inventory quantities.',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
35
|
+
const { error } = yield client_1.sellercloudClient.tryGetToken({ auth });
|
|
36
|
+
if (error) {
|
|
37
|
+
return { valid: false, error: `SellerCloud rejected the credentials: ${error}` };
|
|
38
|
+
}
|
|
39
|
+
return { valid: true };
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAqE;AACrE,4CAAoD;AAEvC,QAAA,eAAe,GAAG,4BAAS,CAAC,UAAU,CAAC;IAChD,WAAW,EAAE;;;;mGAIkF;IAC/F,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACH,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,qDAAqD;YAClE,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,QAAQ,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,OAAO,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC1B,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,oEAAoE;YACjF,QAAQ,EAAE,KAAK;SAClB,CAAC;KACL;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACrB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,0BAAiB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,yCAAyC,KAAK,EAAE,EAAE,CAAC;QACrF,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC,CAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HttpMethod } from '@activepieces/pieces-common';
|
|
2
|
+
declare function getToken({ auth }: {
|
|
3
|
+
auth: SellercloudAuthProps;
|
|
4
|
+
}): Promise<string>;
|
|
5
|
+
declare function tryGetToken({ auth }: {
|
|
6
|
+
auth: SellercloudAuthProps;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
error: string | null;
|
|
9
|
+
}>;
|
|
10
|
+
declare function request<T>({ auth, token, method, path, queryParams, body }: SellercloudRequest): Promise<T>;
|
|
11
|
+
declare function listWarehouses({ auth, token }: {
|
|
12
|
+
auth: SellercloudAuthProps;
|
|
13
|
+
token?: string;
|
|
14
|
+
}): Promise<SellercloudWarehouse[]>;
|
|
15
|
+
declare function listCatalogProductIds({ auth, token }: {
|
|
16
|
+
auth: SellercloudAuthProps;
|
|
17
|
+
token?: string;
|
|
18
|
+
}): Promise<string[]>;
|
|
19
|
+
declare function apiBase({ auth }: {
|
|
20
|
+
auth: SellercloudAuthProps;
|
|
21
|
+
}): string;
|
|
22
|
+
export declare const sellercloudClient: {
|
|
23
|
+
getToken: typeof getToken;
|
|
24
|
+
tryGetToken: typeof tryGetToken;
|
|
25
|
+
request: typeof request;
|
|
26
|
+
listWarehouses: typeof listWarehouses;
|
|
27
|
+
listCatalogProductIds: typeof listCatalogProductIds;
|
|
28
|
+
apiBase: typeof apiBase;
|
|
29
|
+
};
|
|
30
|
+
export type SellercloudAuthProps = {
|
|
31
|
+
serverUrl: string;
|
|
32
|
+
username: string;
|
|
33
|
+
password: string;
|
|
34
|
+
pinCode?: string;
|
|
35
|
+
};
|
|
36
|
+
export type SellercloudWarehouse = {
|
|
37
|
+
ID: number;
|
|
38
|
+
Name: string;
|
|
39
|
+
IsDefault?: boolean;
|
|
40
|
+
WarehouseType?: number;
|
|
41
|
+
IsSellAble?: boolean;
|
|
42
|
+
};
|
|
43
|
+
type SellercloudRequest = {
|
|
44
|
+
auth: SellercloudAuthProps;
|
|
45
|
+
token?: string;
|
|
46
|
+
method: HttpMethod;
|
|
47
|
+
path: string;
|
|
48
|
+
queryParams?: Record<string, string | number | boolean | undefined | null>;
|
|
49
|
+
body?: unknown;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sellercloudClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const shared_1 = require("@activepieces/shared");
|
|
7
|
+
function getToken(_a) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
|
|
9
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
10
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
11
|
+
url: `${apiBase({ auth })}/token`,
|
|
12
|
+
headers: { 'Content-Type': 'application/json' },
|
|
13
|
+
body: { Username: auth.username, Password: auth.password },
|
|
14
|
+
});
|
|
15
|
+
return response.body.access_token;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function tryGetToken(_a) {
|
|
19
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
|
|
20
|
+
const { error } = yield (0, shared_1.tryCatch)(() => getToken({ auth }));
|
|
21
|
+
return { error: error ? describeError({ error }) : null };
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// Callers that make many requests (catalog paging, job polling) pass `token` so one run logs in once; tokens last an hour.
|
|
25
|
+
function request(_a) {
|
|
26
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, method, path, queryParams, body }) {
|
|
27
|
+
const accessToken = token !== null && token !== void 0 ? token : yield getToken({ auth });
|
|
28
|
+
const { data, error } = yield (0, shared_1.tryCatch)(() => pieces_common_1.httpClient.sendRequest({
|
|
29
|
+
method,
|
|
30
|
+
url: `${apiBase({ auth })}${path}`,
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${accessToken}`,
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
},
|
|
35
|
+
queryParams: compactQuery({ queryParams }),
|
|
36
|
+
body,
|
|
37
|
+
}));
|
|
38
|
+
if (error) {
|
|
39
|
+
throw new Error(`SellerCloud ${method} ${path} failed: ${describeError({ error })}`);
|
|
40
|
+
}
|
|
41
|
+
return data.body;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function listWarehouses(_a) {
|
|
45
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token }) {
|
|
46
|
+
return fetchAllPages({ auth, token, path: '/Warehouses' });
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function listCatalogProductIds(_a) {
|
|
50
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token }) {
|
|
51
|
+
const products = yield fetchAllPages({ auth, token, path: '/Catalog' });
|
|
52
|
+
return products.map((product) => product.ID);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// SellerCloud silently caps pageSize (50 on /Catalog), so stop on the running total, not on pageNumber * pageSize.
|
|
56
|
+
function fetchAllPages(_a) {
|
|
57
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, path, pageNumber = 1, collected = [] }) {
|
|
58
|
+
var _b, _c;
|
|
59
|
+
const page = yield request({
|
|
60
|
+
auth,
|
|
61
|
+
token,
|
|
62
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
63
|
+
path,
|
|
64
|
+
queryParams: { 'model.pageSize': MAX_PAGE_SIZE, 'model.pageNumber': pageNumber },
|
|
65
|
+
});
|
|
66
|
+
const all = [...collected, ...((_b = page.Items) !== null && _b !== void 0 ? _b : [])];
|
|
67
|
+
if (((_c = page.Items) !== null && _c !== void 0 ? _c : []).length === 0 || all.length >= page.TotalResults) {
|
|
68
|
+
return all;
|
|
69
|
+
}
|
|
70
|
+
return fetchAllPages({ auth, token, path, pageNumber: pageNumber + 1, collected: all });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function apiBase({ auth }) {
|
|
74
|
+
return `${auth.serverUrl.trim().replace(/\/+$/, '')}/api`;
|
|
75
|
+
}
|
|
76
|
+
function compactQuery({ queryParams }) {
|
|
77
|
+
return Object.fromEntries(Object.entries(queryParams !== null && queryParams !== void 0 ? queryParams : {})
|
|
78
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
79
|
+
.map(([key, value]) => [key, String(value)]));
|
|
80
|
+
}
|
|
81
|
+
function describeError({ error }) {
|
|
82
|
+
if (error instanceof pieces_common_1.HttpError) {
|
|
83
|
+
return `${error.response.status} ${JSON.stringify(error.response.body)}`;
|
|
84
|
+
}
|
|
85
|
+
return error.message;
|
|
86
|
+
}
|
|
87
|
+
const MAX_PAGE_SIZE = 500;
|
|
88
|
+
exports.sellercloudClient = {
|
|
89
|
+
getToken,
|
|
90
|
+
tryGetToken,
|
|
91
|
+
request,
|
|
92
|
+
listWarehouses,
|
|
93
|
+
listCatalogProductIds,
|
|
94
|
+
apiBase,
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;;;AAAA,+DAA6F;AAC7F,iDAAgD;AAEhD,SAAe,QAAQ;iEAAC,EAAE,IAAI,EAAkC;QAC5D,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAA2B;YACpE,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,QAAQ;YACjC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;SAC7D,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;IACtC,CAAC;CAAA;AAED,SAAe,WAAW;iEAAC,EAAE,IAAI,EAAkC;QAC/D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,iBAAQ,EAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3D,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9D,CAAC;CAAA;AAED,2HAA2H;AAC3H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AI,IAAI,KAAK,KAAK,EAAE,CAAC;SAC5E,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACnD,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,EAAE,KAAK,EAAoB;IAC9C,IAAI,KAAK,YAAY,yBAAS,EAAE,CAAC;QAC7B,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC;AACzB,CAAC;AAED,MAAM,aAAa,GAAG,GAAG,CAAC;AAEb,QAAA,iBAAiB,GAAG;IAC7B,QAAQ;IACR,WAAW;IACX,OAAO;IACP,cAAc;IACd,qBAAqB;IACrB,OAAO;CACV,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare function parseCsv({ text }: {
|
|
2
|
+
text: string;
|
|
3
|
+
}): string[][];
|
|
4
|
+
declare function mapToCatalog({ text, partNumberColumn, quantityColumn, catalogIds, match, onlyProductIds }: MapToCatalogParams): CatalogMapping;
|
|
5
|
+
export declare const csvMapping: {
|
|
6
|
+
parseCsv: typeof parseCsv;
|
|
7
|
+
mapToCatalog: typeof mapToCatalog;
|
|
8
|
+
};
|
|
9
|
+
export type MatchOptions = {
|
|
10
|
+
suffix: string;
|
|
11
|
+
matchWithoutSuffix: boolean;
|
|
12
|
+
stripLeadingZeros: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type CatalogMapping = {
|
|
15
|
+
fileRows: number;
|
|
16
|
+
matchedRows: number;
|
|
17
|
+
unmatchedRows: number;
|
|
18
|
+
unmatchedSample: string[];
|
|
19
|
+
rows: {
|
|
20
|
+
productId: string;
|
|
21
|
+
quantity: number;
|
|
22
|
+
}[];
|
|
23
|
+
missingFromFile: string[];
|
|
24
|
+
};
|
|
25
|
+
type MapToCatalogParams = {
|
|
26
|
+
text: string;
|
|
27
|
+
partNumberColumn: string;
|
|
28
|
+
quantityColumn: string;
|
|
29
|
+
catalogIds: string[];
|
|
30
|
+
match: MatchOptions;
|
|
31
|
+
onlyProductIds: string[];
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.csvMapping = void 0;
|
|
4
|
+
function parseCsv({ text }) {
|
|
5
|
+
const rows = [];
|
|
6
|
+
let row = [];
|
|
7
|
+
let cell = '';
|
|
8
|
+
let inQuotes = false;
|
|
9
|
+
let i = 0;
|
|
10
|
+
while (i < text.length) {
|
|
11
|
+
const ch = text[i];
|
|
12
|
+
if (inQuotes) {
|
|
13
|
+
if (ch === '"' && text[i + 1] === '"') {
|
|
14
|
+
cell += '"';
|
|
15
|
+
i += 2;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (ch === '"') {
|
|
19
|
+
inQuotes = false;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
cell += ch;
|
|
23
|
+
}
|
|
24
|
+
i += 1;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
// Dealer exports write text cells as ="VALUE" so Excel keeps leading zeros; treat that as a quoted cell.
|
|
28
|
+
if (ch === '=' && cell === '' && text[i + 1] === '"') {
|
|
29
|
+
inQuotes = true;
|
|
30
|
+
i += 2;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (ch === '"' && cell === '') {
|
|
34
|
+
inQuotes = true;
|
|
35
|
+
}
|
|
36
|
+
else if (ch === ',') {
|
|
37
|
+
row.push(cell);
|
|
38
|
+
cell = '';
|
|
39
|
+
}
|
|
40
|
+
else if (ch === '\n' || ch === '\r') {
|
|
41
|
+
if (ch === '\r' && text[i + 1] === '\n') {
|
|
42
|
+
i += 1;
|
|
43
|
+
}
|
|
44
|
+
row.push(cell);
|
|
45
|
+
rows.push(row);
|
|
46
|
+
row = [];
|
|
47
|
+
cell = '';
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
cell += ch;
|
|
51
|
+
}
|
|
52
|
+
i += 1;
|
|
53
|
+
}
|
|
54
|
+
if (cell !== '' || row.length > 0) {
|
|
55
|
+
row.push(cell);
|
|
56
|
+
rows.push(row);
|
|
57
|
+
}
|
|
58
|
+
return rows.filter((r) => r.some((c) => c.trim() !== ''));
|
|
59
|
+
}
|
|
60
|
+
function mapToCatalog({ text, partNumberColumn, quantityColumn, catalogIds, match, onlyProductIds }) {
|
|
61
|
+
const [header, ...records] = parseCsv({ text });
|
|
62
|
+
if (!header) {
|
|
63
|
+
throw new Error('The CSV file is empty.');
|
|
64
|
+
}
|
|
65
|
+
const columns = header.map((name) => name.trim().toUpperCase());
|
|
66
|
+
const partIndex = columns.indexOf(partNumberColumn.trim().toUpperCase());
|
|
67
|
+
const qtyIndex = columns.indexOf(quantityColumn.trim().toUpperCase());
|
|
68
|
+
if (partIndex === -1 || qtyIndex === -1) {
|
|
69
|
+
throw new Error(`Column not found. Looked for "${partNumberColumn}" and "${quantityColumn}" in: ${header.join(', ')}`);
|
|
70
|
+
}
|
|
71
|
+
const catalog = new Map(catalogIds.map((id) => [id.toUpperCase(), id]));
|
|
72
|
+
const only = onlyProductIds.length > 0 ? new Set(onlyProductIds.map((id) => id.toUpperCase())) : null;
|
|
73
|
+
const resolved = records.map((record) => {
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
const partNumber = cleanPartNumber({ raw: (_a = record[partIndex]) !== null && _a !== void 0 ? _a : '' });
|
|
76
|
+
const quantity = Math.max(0, parseInt((_b = record[qtyIndex]) !== null && _b !== void 0 ? _b : '', 10) || 0);
|
|
77
|
+
const productId = (_c = candidates({ partNumber, match }).map((c) => catalog.get(c.toUpperCase())).find((id) => id !== undefined)) !== null && _c !== void 0 ? _c : null;
|
|
78
|
+
return { partNumber, quantity, productId };
|
|
79
|
+
}).filter((r) => r.partNumber !== '');
|
|
80
|
+
const matched = resolved.filter((r) => r.productId !== null);
|
|
81
|
+
const unmatched = resolved.filter((r) => r.productId === null);
|
|
82
|
+
// Several part numbers can land on one SellerCloud product (e.g. with and without leading zeros), so quantities add up.
|
|
83
|
+
const totals = matched
|
|
84
|
+
.filter((r) => only === null || only.has(r.productId.toUpperCase()))
|
|
85
|
+
.reduce((acc, r) => { var _a; return acc.set(r.productId, ((_a = acc.get(r.productId)) !== null && _a !== void 0 ? _a : 0) + r.quantity); }, new Map());
|
|
86
|
+
return {
|
|
87
|
+
fileRows: records.length,
|
|
88
|
+
matchedRows: matched.length,
|
|
89
|
+
unmatchedRows: unmatched.length,
|
|
90
|
+
unmatchedSample: unmatched.slice(0, 20).map((r) => r.partNumber),
|
|
91
|
+
rows: [...totals.entries()].map(([productId, quantity]) => ({ productId, quantity })),
|
|
92
|
+
missingFromFile: only === null ? [] : [...only].filter((id) => ![...totals.keys()].some((k) => k.toUpperCase() === id)),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function cleanPartNumber({ raw }) {
|
|
96
|
+
return raw.replace(/["'=]/g, '').trim();
|
|
97
|
+
}
|
|
98
|
+
function candidates({ partNumber, match }) {
|
|
99
|
+
const bases = match.stripLeadingZeros && /^0+\d+$/.test(partNumber)
|
|
100
|
+
? [partNumber, partNumber.replace(/^0+/, '')]
|
|
101
|
+
: [partNumber];
|
|
102
|
+
return bases.flatMap((base) => [
|
|
103
|
+
...(match.suffix ? [`${base}${match.suffix}`] : []),
|
|
104
|
+
...(match.matchWithoutSuffix || !match.suffix ? [base] : []),
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
exports.csvMapping = {
|
|
108
|
+
parseCsv,
|
|
109
|
+
mapToCatalog,
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=csv-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|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,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,KAAK,CAAC,kBAAkB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/D,CAAC,CAAC;AACP,CAAC;AAEY,QAAA,UAAU,GAAG;IACtB,QAAQ;IACR,YAAY;CACf,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SellercloudAuthProps } from './client';
|
|
2
|
+
declare function submitImport({ auth, token, warehouse, rows, updateType, inventoryDate }: SubmitImportParams): Promise<SubmittedJob>;
|
|
3
|
+
declare function getJob({ auth, token, jobId }: {
|
|
4
|
+
auth: SellercloudAuthProps;
|
|
5
|
+
token?: string;
|
|
6
|
+
jobId: number;
|
|
7
|
+
}): Promise<JobSummary>;
|
|
8
|
+
declare function waitForJob({ auth, token, jobId, timeoutSeconds }: WaitParams): Promise<JobResult>;
|
|
9
|
+
declare function buildTemplateCsv({ warehouseName, rows, inventoryDate }: {
|
|
10
|
+
warehouseName: string;
|
|
11
|
+
rows: InventoryRow[];
|
|
12
|
+
inventoryDate: Date;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare const inventoryImport: {
|
|
15
|
+
submitImport: typeof submitImport;
|
|
16
|
+
getJob: typeof getJob;
|
|
17
|
+
waitForJob: typeof waitForJob;
|
|
18
|
+
buildTemplateCsv: typeof buildTemplateCsv;
|
|
19
|
+
};
|
|
20
|
+
export type InventoryRow = {
|
|
21
|
+
productId: string;
|
|
22
|
+
quantity: number;
|
|
23
|
+
};
|
|
24
|
+
export type UpdateType = 'PARTIAL' | 'FULL';
|
|
25
|
+
export type JobSummary = {
|
|
26
|
+
id: number;
|
|
27
|
+
status: string;
|
|
28
|
+
finished: boolean;
|
|
29
|
+
succeeded: boolean;
|
|
30
|
+
errorMessage: string | null;
|
|
31
|
+
totalRecords: number | null;
|
|
32
|
+
totalProcessed: number | null;
|
|
33
|
+
totalSucceeded: number | null;
|
|
34
|
+
totalFailed: number | null;
|
|
35
|
+
submittedOn: string | null;
|
|
36
|
+
completedOn: string | null;
|
|
37
|
+
};
|
|
38
|
+
export type JobResult = JobSummary & {
|
|
39
|
+
timedOut: boolean;
|
|
40
|
+
errors: string[];
|
|
41
|
+
};
|
|
42
|
+
type SubmittedJob = {
|
|
43
|
+
id: number;
|
|
44
|
+
link: string | null;
|
|
45
|
+
message: string | null;
|
|
46
|
+
};
|
|
47
|
+
type SubmitImportParams = {
|
|
48
|
+
auth: SellercloudAuthProps;
|
|
49
|
+
token?: string;
|
|
50
|
+
warehouse: {
|
|
51
|
+
ID: number;
|
|
52
|
+
Name: string;
|
|
53
|
+
};
|
|
54
|
+
rows: InventoryRow[];
|
|
55
|
+
updateType: UpdateType;
|
|
56
|
+
inventoryDate: Date;
|
|
57
|
+
};
|
|
58
|
+
type WaitParams = {
|
|
59
|
+
auth: SellercloudAuthProps;
|
|
60
|
+
token?: string;
|
|
61
|
+
jobId: number;
|
|
62
|
+
timeoutSeconds: number;
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inventoryImport = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const client_1 = require("./client");
|
|
7
|
+
function submitImport(_a) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, warehouse, rows, updateType, inventoryDate }) {
|
|
9
|
+
var _b, _c;
|
|
10
|
+
const csv = buildTemplateCsv({ warehouseName: warehouse.Name, rows, inventoryDate });
|
|
11
|
+
const response = yield client_1.sellercloudClient.request({
|
|
12
|
+
auth,
|
|
13
|
+
token,
|
|
14
|
+
method: pieces_common_1.HttpMethod.PUT,
|
|
15
|
+
path: '/Inventory/ImportPhysicalInventory',
|
|
16
|
+
body: Object.assign({ FileContent: Buffer.from(csv, 'utf8').toString('base64'), Format: CSV_FORMAT, WarehouseID: warehouse.ID, UpdateType: updateType === 'FULL' ? 1 : 0, InventoryDate: inventoryDate.toISOString(), MergeDefaultWarehouseInventoryIntoShadowParent: true }, (auth.pinCode ? { PinCode: auth.pinCode } : {})),
|
|
17
|
+
});
|
|
18
|
+
return { id: response.ID, link: (_b = response.QueuedJobLink) !== null && _b !== void 0 ? _b : null, message: (_c = response.Message) !== null && _c !== void 0 ? _c : null };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function getJob(_a) {
|
|
22
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, jobId }) {
|
|
23
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
24
|
+
const job = yield client_1.sellercloudClient.request({
|
|
25
|
+
auth,
|
|
26
|
+
token,
|
|
27
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
28
|
+
path: `/QueuedJobs/${jobId}`,
|
|
29
|
+
});
|
|
30
|
+
const status = statusName({ raw: (_b = job.Basic) === null || _b === void 0 ? void 0 : _b.Status });
|
|
31
|
+
return {
|
|
32
|
+
id: jobId,
|
|
33
|
+
status,
|
|
34
|
+
finished: TERMINAL_STATUSES.includes(status),
|
|
35
|
+
succeeded: status === 'Completed',
|
|
36
|
+
errorMessage: ((_c = job.Basic) === null || _c === void 0 ? void 0 : _c.ErrorMessage) || null,
|
|
37
|
+
totalRecords: (_d = job.TotalRecords) !== null && _d !== void 0 ? _d : null,
|
|
38
|
+
totalProcessed: (_e = job.TotalProcessed) !== null && _e !== void 0 ? _e : null,
|
|
39
|
+
totalSucceeded: (_f = job.TotalSucceeded) !== null && _f !== void 0 ? _f : null,
|
|
40
|
+
totalFailed: (_g = job.TotalFailure) !== null && _g !== void 0 ? _g : null,
|
|
41
|
+
submittedOn: (_j = (_h = job.Basic) === null || _h === void 0 ? void 0 : _h.SubmittedOn) !== null && _j !== void 0 ? _j : null,
|
|
42
|
+
completedOn: (_l = (_k = job.Basic) === null || _k === void 0 ? void 0 : _k.CompletedOn) !== null && _l !== void 0 ? _l : null,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function getJobErrors(_a) {
|
|
47
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, jobId, limit }) {
|
|
48
|
+
var _b;
|
|
49
|
+
const logs = yield client_1.sellercloudClient.request({
|
|
50
|
+
auth,
|
|
51
|
+
token,
|
|
52
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
53
|
+
path: `/QueuedJobs/${jobId}/Logs`,
|
|
54
|
+
queryParams: { 'model.isError': true, 'model.pageSize': limit, 'model.pageNumber': 1 },
|
|
55
|
+
});
|
|
56
|
+
return ((_b = logs.Items) !== null && _b !== void 0 ? _b : []).map((log) => log.Message);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function waitForJob(_a) {
|
|
60
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, jobId, timeoutSeconds }) {
|
|
61
|
+
const deadline = Date.now() + timeoutSeconds * 1000;
|
|
62
|
+
const poll = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const job = yield getJob({ auth, token, jobId });
|
|
64
|
+
if (job.finished || Date.now() + POLL_INTERVAL_MS > deadline) {
|
|
65
|
+
return job;
|
|
66
|
+
}
|
|
67
|
+
yield new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
68
|
+
return poll();
|
|
69
|
+
});
|
|
70
|
+
const job = yield poll();
|
|
71
|
+
const errors = job.finished && !job.succeeded
|
|
72
|
+
? yield getJobErrors({ auth, token, jobId, limit: 50 })
|
|
73
|
+
: [];
|
|
74
|
+
return Object.assign(Object.assign({}, job), { timedOut: !job.finished, errors });
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function buildTemplateCsv({ warehouseName, rows, inventoryDate }) {
|
|
78
|
+
const date = formatTemplateDate({ date: inventoryDate });
|
|
79
|
+
const lines = rows.map((row) => [row.productId, warehouseName, String(row.quantity), date, ''].map(csvCell).join(','));
|
|
80
|
+
return [TEMPLATE_HEADER, ...lines].join('\r\n') + '\r\n';
|
|
81
|
+
}
|
|
82
|
+
function csvCell(value) {
|
|
83
|
+
return /[",\r\n]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value;
|
|
84
|
+
}
|
|
85
|
+
// Matches the template SellerCloud hands out, e.g. "9/1/2026 10:45:20 PM".
|
|
86
|
+
function formatTemplateDate({ date }) {
|
|
87
|
+
return date.toLocaleString('en-US', { timeZone: 'America/New_York', hour12: true }).replace(',', '');
|
|
88
|
+
}
|
|
89
|
+
function statusName({ raw }) {
|
|
90
|
+
var _a;
|
|
91
|
+
if (typeof raw === 'number') {
|
|
92
|
+
return (_a = JOB_STATUSES[raw]) !== null && _a !== void 0 ? _a : `Unknown(${raw})`;
|
|
93
|
+
}
|
|
94
|
+
return raw !== null && raw !== void 0 ? raw : 'Unknown';
|
|
95
|
+
}
|
|
96
|
+
const CSV_FORMAT = 1;
|
|
97
|
+
const POLL_INTERVAL_MS = 5000;
|
|
98
|
+
const TEMPLATE_HEADER = 'ProductID,Warehouse,PhysicalInventoryQty,InventoryDate,LocationNotes';
|
|
99
|
+
const JOB_STATUSES = [
|
|
100
|
+
'Submitted', 'Processing', 'Completed', 'Failed', 'PartialSuccess', 'OnHold',
|
|
101
|
+
'Cancelled', 'Cancelled_Service_Restarted', 'Aborted_Too_Much_Time_Consumed', 'Cancelled_While_Running',
|
|
102
|
+
];
|
|
103
|
+
const TERMINAL_STATUSES = ['Completed', 'Failed', 'PartialSuccess', 'Cancelled', 'Cancelled_Service_Restarted', 'Aborted_Too_Much_Time_Consumed', 'Cancelled_While_Running'];
|
|
104
|
+
exports.inventoryImport = {
|
|
105
|
+
submitImport,
|
|
106
|
+
getJob,
|
|
107
|
+
waitForJob,
|
|
108
|
+
buildTemplateCsv,
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../../../src/lib/common/inventory.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qCAAmE;AAEnE,SAAe,YAAY;iEAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAsB;;QACvG,MAAM,GAAG,GAAG,gBAAgB,CAAC,EAAE,aAAa,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,MAAM,QAAQ,GAAG,MAAM,0BAAiB,CAAC,OAAO,CAA2D;YACvG,IAAI;YACJ,KAAK;YACL,MAAM,EAAE,0BAAU,CAAC,GAAG;YACtB,IAAI,EAAE,oCAAoC;YAC1C,IAAI,kBACA,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EACxD,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,SAAS,CAAC,EAAE,EACzB,UAAU,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,aAAa,CAAC,WAAW,EAAE,EAC1C,8CAA8C,EAAE,IAAI,IACjD,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACrD;SACJ,CAAC,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,MAAA,QAAQ,CAAC,aAAa,mCAAI,IAAI,EAAE,OAAO,EAAE,MAAA,QAAQ,CAAC,OAAO,mCAAI,IAAI,EAAE,CAAC;IACxG,CAAC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AAG,IAAI,CAAC;AAC9B,MAAM,eAAe,GAAG,sEAAsE,CAAC;AAC/F,MAAM,YAAY,GAAG;IACjB,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ;IAC5E,WAAW,EAAE,6BAA6B,EAAE,gCAAgC,EAAE,yBAAyB;CAC1G,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,6BAA6B,EAAE,gCAAgC,EAAE,yBAAyB,CAAC,CAAC;AAEhK,QAAA,eAAe,GAAG;IAC3B,YAAY;IACZ,MAAM;IACN,UAAU;IACV,gBAAgB;CACnB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const sellercloudProps: {
|
|
2
|
+
warehouse: import("@activepieces/pieces-framework").DropdownProperty<number, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
serverUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
6
|
+
pinCode: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
7
|
+
}>>;
|
|
8
|
+
updateType: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
9
|
+
inventoryDate: import("@activepieces/pieces-framework").DateTimeProperty<false>;
|
|
10
|
+
waitForCompletion: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
11
|
+
timeoutSeconds: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sellercloudProps = 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 auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
const warehouse = pieces_framework_1.Property.Dropdown({
|
|
10
|
+
auth: auth_1.sellercloudAuth,
|
|
11
|
+
displayName: 'Warehouse',
|
|
12
|
+
required: true,
|
|
13
|
+
refreshers: [],
|
|
14
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
15
|
+
if (!auth) {
|
|
16
|
+
return { disabled: true, options: [], placeholder: 'Connect SellerCloud first' };
|
|
17
|
+
}
|
|
18
|
+
const { data, error } = yield (0, shared_1.tryCatch)(() => client_1.sellercloudClient.listWarehouses({ auth: auth.props }));
|
|
19
|
+
if (error) {
|
|
20
|
+
return { disabled: true, options: [], placeholder: `Couldn't load warehouses: ${error.message}` };
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
disabled: false,
|
|
24
|
+
options: [...data]
|
|
25
|
+
.sort((a, b) => a.Name.localeCompare(b.Name))
|
|
26
|
+
.map((w) => ({ label: `${w.Name} (${w.ID})`, value: w.ID })),
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
const updateType = pieces_framework_1.Property.StaticDropdown({
|
|
31
|
+
displayName: 'Update Type',
|
|
32
|
+
description: 'Partial only changes the products in the file. Full also sets every other product in this warehouse to 0.',
|
|
33
|
+
required: true,
|
|
34
|
+
defaultValue: 'PARTIAL',
|
|
35
|
+
options: {
|
|
36
|
+
options: [
|
|
37
|
+
{ label: 'Partial (only products in the file)', value: 'PARTIAL' },
|
|
38
|
+
{ label: 'Full (products not in the file go to 0)', value: 'FULL' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const inventoryDate = pieces_framework_1.Property.DateTime({
|
|
43
|
+
displayName: 'Inventory Date',
|
|
44
|
+
description: 'When the counts were taken. Defaults to now.',
|
|
45
|
+
required: false,
|
|
46
|
+
});
|
|
47
|
+
const waitForCompletion = pieces_framework_1.Property.Checkbox({
|
|
48
|
+
displayName: 'Wait for Import to Finish',
|
|
49
|
+
description: 'SellerCloud queues imports as a job. When on, this step polls the job and fails if the import fails.',
|
|
50
|
+
required: false,
|
|
51
|
+
defaultValue: true,
|
|
52
|
+
});
|
|
53
|
+
const timeoutSeconds = pieces_framework_1.Property.Number({
|
|
54
|
+
displayName: 'Wait Timeout (seconds)',
|
|
55
|
+
description: 'How long to wait for the job before returning its current status.',
|
|
56
|
+
required: false,
|
|
57
|
+
defaultValue: 300,
|
|
58
|
+
});
|
|
59
|
+
exports.sellercloudProps = {
|
|
60
|
+
warehouse,
|
|
61
|
+
updateType,
|
|
62
|
+
inventoryDate,
|
|
63
|
+
waitForCompletion,
|
|
64
|
+
timeoutSeconds,
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA0D;AAC1D,iDAAgD;AAChD,kCAA0C;AAC1C,qCAA6C;AAE7C,MAAM,SAAS,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAChC,IAAI,EAAE,sBAAe;IACrB,WAAW,EAAE,WAAW;IACxB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACpB,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;QACrF,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,iBAAQ,EAAC,GAAG,EAAE,CAAC,0BAAiB,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,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AAE,KAAK;IACf,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,2BAAQ,CAAC,MAAM,CAAC;IACnC,WAAW,EAAE,wBAAwB;IACrC,WAAW,EAAE,mEAAmE;IAChF,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,GAAG;CACpB,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG;IAC5B,SAAS;IACT,UAAU;IACV,aAAa;IACb,iBAAiB;IACjB,cAAc;CACjB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SellercloudAuthProps } from './client';
|
|
2
|
+
import { InventoryRow, JobResult, UpdateType } from './inventory';
|
|
3
|
+
declare function runImport({ auth, token, warehouseId, rows, updateType, inventoryDate, waitForCompletion, timeoutSeconds }: RunImportParams): Promise<ImportOutcome>;
|
|
4
|
+
declare function findWarehouse({ auth, token, warehouseId }: {
|
|
5
|
+
auth: SellercloudAuthProps;
|
|
6
|
+
token: string;
|
|
7
|
+
warehouseId: number;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
ID: number;
|
|
10
|
+
Name: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const importRunner: {
|
|
13
|
+
runImport: typeof runImport;
|
|
14
|
+
findWarehouse: typeof findWarehouse;
|
|
15
|
+
};
|
|
16
|
+
export type ImportOutcome = {
|
|
17
|
+
warehouse: {
|
|
18
|
+
ID: number;
|
|
19
|
+
Name: string;
|
|
20
|
+
};
|
|
21
|
+
submitted: boolean;
|
|
22
|
+
job: JobResult | {
|
|
23
|
+
id: number;
|
|
24
|
+
status: string;
|
|
25
|
+
message: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
};
|
|
28
|
+
type RunImportParams = {
|
|
29
|
+
auth: SellercloudAuthProps;
|
|
30
|
+
token: string;
|
|
31
|
+
warehouseId: number;
|
|
32
|
+
rows: InventoryRow[];
|
|
33
|
+
updateType: UpdateType;
|
|
34
|
+
inventoryDate: Date;
|
|
35
|
+
waitForCompletion: boolean;
|
|
36
|
+
timeoutSeconds: number;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importRunner = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
const inventory_1 = require("./inventory");
|
|
7
|
+
function runImport(_a) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, warehouseId, rows, updateType, inventoryDate, waitForCompletion, timeoutSeconds }) {
|
|
9
|
+
var _b;
|
|
10
|
+
const warehouse = yield findWarehouse({ auth, token, warehouseId });
|
|
11
|
+
if (rows.length === 0) {
|
|
12
|
+
return { warehouse, submitted: false, job: null };
|
|
13
|
+
}
|
|
14
|
+
const submitted = yield inventory_1.inventoryImport.submitImport({ auth, token, warehouse, rows, updateType, inventoryDate });
|
|
15
|
+
if (!waitForCompletion) {
|
|
16
|
+
return { warehouse, submitted: true, job: { id: submitted.id, status: 'Submitted', message: submitted.message } };
|
|
17
|
+
}
|
|
18
|
+
const job = yield inventory_1.inventoryImport.waitForJob({ auth, token, jobId: submitted.id, timeoutSeconds });
|
|
19
|
+
if (job.finished && !job.succeeded && job.status !== 'PartialSuccess') {
|
|
20
|
+
throw new Error(`SellerCloud import job ${job.id} ended as ${job.status}: ${(_b = job.errorMessage) !== null && _b !== void 0 ? _b : job.errors.slice(0, 5).join('; ')}`);
|
|
21
|
+
}
|
|
22
|
+
return { warehouse, submitted: true, job };
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function findWarehouse(_a) {
|
|
26
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, token, warehouseId }) {
|
|
27
|
+
const warehouses = yield client_1.sellercloudClient.listWarehouses({ auth, token });
|
|
28
|
+
const warehouse = warehouses.find((w) => w.ID === warehouseId);
|
|
29
|
+
if (!warehouse) {
|
|
30
|
+
throw new Error(`Warehouse ${warehouseId} not found. Available: ${warehouses.map((w) => `${w.ID} ${w.Name}`).join(', ')}`);
|
|
31
|
+
}
|
|
32
|
+
return { ID: warehouse.ID, Name: warehouse.Name };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.importRunner = {
|
|
36
|
+
runImport,
|
|
37
|
+
findWarehouse,
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=run-import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-import.js","sourceRoot":"","sources":["../../../../src/lib/common/run-import.ts"],"names":[],"mappings":";;;;AAAA,qCAAmE;AACnE,2CAAmF;AAEnF,SAAe,SAAS;iEAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAmB;;QACtI,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACpE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QACtD,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,2BAAe,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC,CAAC;QAClH,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACrB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QACtH,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,2BAAe,CAA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