@hubcommerce/n11 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/categories/api.d.ts +12 -0
- package/dist/categories/api.d.ts.map +1 -0
- package/dist/categories/api.js +34 -0
- package/dist/client.d.ts +37 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +70 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +58 -0
- package/dist/connection.d.ts +5 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +4 -0
- package/dist/constants/defaults.d.ts +16 -0
- package/dist/constants/defaults.d.ts.map +1 -0
- package/dist/constants/defaults.js +15 -0
- package/dist/constants/hosts.d.ts +9 -0
- package/dist/constants/hosts.d.ts.map +1 -0
- package/dist/constants/hosts.js +25 -0
- package/dist/constants/page-limits.d.ts +15 -0
- package/dist/constants/page-limits.d.ts.map +1 -0
- package/dist/constants/page-limits.js +14 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +162 -0
- package/dist/http/query.d.ts +2 -0
- package/dist/http/query.d.ts.map +1 -0
- package/dist/http/query.js +10 -0
- package/dist/http/response.d.ts +12 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +43 -0
- package/dist/http/security.d.ts +6 -0
- package/dist/http/security.d.ts.map +1 -0
- package/dist/http/security.js +29 -0
- package/dist/http/signals.d.ts +5 -0
- package/dist/http/signals.d.ts.map +1 -0
- package/dist/http/signals.js +26 -0
- package/dist/http.d.ts +12 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +143 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/invoice/api.d.ts +14 -0
- package/dist/invoice/api.d.ts.map +1 -0
- package/dist/invoice/api.js +12 -0
- package/dist/invoice/parse.d.ts +3 -0
- package/dist/invoice/parse.d.ts.map +1 -0
- package/dist/invoice/parse.js +12 -0
- package/dist/invoice/send-link.d.ts +9 -0
- package/dist/invoice/send-link.d.ts.map +1 -0
- package/dist/invoice/send-link.js +16 -0
- package/dist/invoice/soap-body.d.ts +6 -0
- package/dist/invoice/soap-body.d.ts.map +1 -0
- package/dist/invoice/soap-body.js +23 -0
- package/dist/invoice/validate.d.ts +7 -0
- package/dist/invoice/validate.d.ts.map +1 -0
- package/dist/invoice/validate.js +73 -0
- package/dist/logger.d.ts +20 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +61 -0
- package/dist/orders/api.d.ts +22 -0
- package/dist/orders/api.d.ts.map +1 -0
- package/dist/orders/api.js +40 -0
- package/dist/orders/date.d.ts +12 -0
- package/dist/orders/date.d.ts.map +1 -0
- package/dist/orders/date.js +21 -0
- package/dist/orders/labor-cost.d.ts +9 -0
- package/dist/orders/labor-cost.d.ts.map +1 -0
- package/dist/orders/labor-cost.js +23 -0
- package/dist/orders/list.d.ts +23 -0
- package/dist/orders/list.d.ts.map +1 -0
- package/dist/orders/list.js +76 -0
- package/dist/orders/paths.d.ts +7 -0
- package/dist/orders/paths.d.ts.map +1 -0
- package/dist/orders/paths.js +6 -0
- package/dist/orders/reconciler.d.ts +30 -0
- package/dist/orders/reconciler.d.ts.map +1 -0
- package/dist/orders/reconciler.js +38 -0
- package/dist/orders/shipping.d.ts +11 -0
- package/dist/orders/shipping.d.ts.map +1 -0
- package/dist/orders/shipping.js +57 -0
- package/dist/orders/update.d.ts +15 -0
- package/dist/orders/update.d.ts.map +1 -0
- package/dist/orders/update.js +25 -0
- package/dist/products/api.d.ts +21 -0
- package/dist/products/api.d.ts.map +1 -0
- package/dist/products/api.js +35 -0
- package/dist/products/builder.d.ts +18 -0
- package/dist/products/builder.d.ts.map +1 -0
- package/dist/products/builder.js +138 -0
- package/dist/products/paths.d.ts +6 -0
- package/dist/products/paths.d.ts.map +1 -0
- package/dist/products/paths.js +5 -0
- package/dist/products/query.d.ts +9 -0
- package/dist/products/query.d.ts.map +1 -0
- package/dist/products/query.js +49 -0
- package/dist/products/tasks.d.ts +12 -0
- package/dist/products/tasks.d.ts.map +1 -0
- package/dist/products/tasks.js +49 -0
- package/dist/qna/answer.d.ts +10 -0
- package/dist/qna/answer.d.ts.map +1 -0
- package/dist/qna/answer.js +23 -0
- package/dist/qna/api.d.ts +17 -0
- package/dist/qna/api.d.ts.map +1 -0
- package/dist/qna/api.js +20 -0
- package/dist/qna/detail.d.ts +9 -0
- package/dist/qna/detail.d.ts.map +1 -0
- package/dist/qna/detail.js +18 -0
- package/dist/qna/list.d.ts +9 -0
- package/dist/qna/list.d.ts.map +1 -0
- package/dist/qna/list.js +16 -0
- package/dist/qna/parse.d.ts +6 -0
- package/dist/qna/parse.d.ts.map +1 -0
- package/dist/qna/parse.js +65 -0
- package/dist/qna/soap-body.d.ts +14 -0
- package/dist/qna/soap-body.d.ts.map +1 -0
- package/dist/qna/soap-body.js +48 -0
- package/dist/qna/validate.d.ts +7 -0
- package/dist/qna/validate.d.ts.map +1 -0
- package/dist/qna/validate.js +75 -0
- package/dist/rate-limit/governor.d.ts +8 -0
- package/dist/rate-limit/governor.d.ts.map +1 -0
- package/dist/rate-limit/governor.js +30 -0
- package/dist/rate-limit/groups.d.ts +34 -0
- package/dist/rate-limit/groups.d.ts.map +1 -0
- package/dist/rate-limit/groups.js +32 -0
- package/dist/retry.d.ts +5 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +22 -0
- package/dist/returns/api.d.ts +21 -0
- package/dist/returns/api.d.ts.map +1 -0
- package/dist/returns/api.js +36 -0
- package/dist/returns/call.d.ts +2 -0
- package/dist/returns/call.d.ts.map +1 -0
- package/dist/returns/call.js +1 -0
- package/dist/returns/cancel-partial.d.ts +9 -0
- package/dist/returns/cancel-partial.d.ts.map +1 -0
- package/dist/returns/cancel-partial.js +18 -0
- package/dist/returns/list.d.ts +9 -0
- package/dist/returns/list.d.ts.map +1 -0
- package/dist/returns/list.js +16 -0
- package/dist/returns/mutations.d.ts +11 -0
- package/dist/returns/mutations.d.ts.map +1 -0
- package/dist/returns/mutations.js +22 -0
- package/dist/returns/parse.d.ts +6 -0
- package/dist/returns/parse.d.ts.map +1 -0
- package/dist/returns/parse.js +89 -0
- package/dist/returns/reasons.d.ts +11 -0
- package/dist/returns/reasons.d.ts.map +1 -0
- package/dist/returns/reasons.js +20 -0
- package/dist/returns/soap-body.d.ts +26 -0
- package/dist/returns/soap-body.d.ts.map +1 -0
- package/dist/returns/soap-body.js +95 -0
- package/dist/soap/call.d.ts +8 -0
- package/dist/soap/call.d.ts.map +1 -0
- package/dist/soap/call.js +22 -0
- package/dist/soap/client.d.ts +13 -0
- package/dist/soap/client.d.ts.map +1 -0
- package/dist/soap/client.js +125 -0
- package/dist/soap/envelope.d.ts +10 -0
- package/dist/soap/envelope.d.ts.map +1 -0
- package/dist/soap/envelope.js +47 -0
- package/dist/soap/operations.d.ts +6 -0
- package/dist/soap/operations.d.ts.map +1 -0
- package/dist/soap/operations.js +91 -0
- package/dist/soap/parse.d.ts +17 -0
- package/dist/soap/parse.d.ts.map +1 -0
- package/dist/soap/parse.js +37 -0
- package/dist/tasks/api.d.ts +11 -0
- package/dist/tasks/api.d.ts.map +1 -0
- package/dist/tasks/api.js +44 -0
- package/dist/tasks/module.d.ts +14 -0
- package/dist/tasks/module.d.ts.map +1 -0
- package/dist/tasks/module.js +15 -0
- package/dist/tasks/poller.d.ts +12 -0
- package/dist/tasks/poller.d.ts.map +1 -0
- package/dist/tasks/poller.js +133 -0
- package/dist/tasks/types.d.ts +27 -0
- package/dist/tasks/types.d.ts.map +1 -0
- package/dist/tasks/types.js +2 -0
- package/dist/testing/fixtures/category-leaf.json +11 -0
- package/dist/testing/fixtures/order-package.json +12 -0
- package/dist/testing/fixtures/task-partial-fail.json +18 -0
- package/dist/testing/fixtures.d.ts +76 -0
- package/dist/testing/fixtures.d.ts.map +1 -0
- package/dist/testing/fixtures.js +85 -0
- package/dist/testing/guard.d.ts +21 -0
- package/dist/testing/guard.d.ts.map +1 -0
- package/dist/testing/guard.js +50 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/mock-client.d.ts +49 -0
- package/dist/testing/mock-client.d.ts.map +1 -0
- package/dist/testing/mock-client.js +100 -0
- package/dist/types/invoice.d.ts +21 -0
- package/dist/types/invoice.d.ts.map +1 -0
- package/dist/types/invoice.js +1 -0
- package/dist/types/orders.d.ts +127 -0
- package/dist/types/orders.d.ts.map +1 -0
- package/dist/types/orders.js +1 -0
- package/dist/types/products.d.ts +146 -0
- package/dist/types/products.d.ts.map +1 -0
- package/dist/types/products.js +1 -0
- package/dist/types/qna.d.ts +61 -0
- package/dist/types/qna.d.ts.map +1 -0
- package/dist/types/qna.js +1 -0
- package/dist/types/returns.d.ts +96 -0
- package/dist/types/returns.d.ts.map +1 -0
- package/dist/types/returns.js +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/wire/normalize.d.ts +20 -0
- package/dist/wire/normalize.d.ts.map +1 -0
- package/dist/wire/normalize.js +158 -0
- package/dist/wire/validate.d.ts +6 -0
- package/dist/wire/validate.d.ts.map +1 -0
- package/dist/wire/validate.js +53 -0
- package/package.json +53 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { COLLECTION_REQUEST_PATH, SPLIT_COMBINE_PACKAGE_PATH, SPLIT_PACKAGE_BY_QUANTITY_PATH, } from "../orders/paths.js";
|
|
2
|
+
import { normalizeCollectionRequestResponse, normalizeSplitPackageResponse, } from "../wire/normalize.js";
|
|
3
|
+
export async function createCollectionRequest(http, params, options) {
|
|
4
|
+
if (params.collectionRequestDetails.length < 1) {
|
|
5
|
+
return {
|
|
6
|
+
ok: false,
|
|
7
|
+
reason: "En az bir collectionRequestDetail gerekli.",
|
|
8
|
+
code: "EMPTY_DETAILS",
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const result = await http.requestJson({
|
|
12
|
+
resource: "rest",
|
|
13
|
+
method: "PUT",
|
|
14
|
+
path: COLLECTION_REQUEST_PATH,
|
|
15
|
+
body: params,
|
|
16
|
+
retryPolicy: "none",
|
|
17
|
+
signal: options?.signal,
|
|
18
|
+
});
|
|
19
|
+
if (!result.ok) {
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
return { ok: true, data: normalizeCollectionRequestResponse(result.data) };
|
|
23
|
+
}
|
|
24
|
+
export async function splitCombinePackage(http, params, options) {
|
|
25
|
+
if (params.splitGroups.length < 1) {
|
|
26
|
+
return { ok: false, reason: "En az bir splitGroup gerekli.", code: "EMPTY_GROUPS" };
|
|
27
|
+
}
|
|
28
|
+
const result = await http.requestJson({
|
|
29
|
+
resource: "rest",
|
|
30
|
+
method: "POST",
|
|
31
|
+
path: SPLIT_COMBINE_PACKAGE_PATH,
|
|
32
|
+
body: params,
|
|
33
|
+
retryPolicy: "none",
|
|
34
|
+
signal: options?.signal,
|
|
35
|
+
});
|
|
36
|
+
if (!result.ok) {
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
return { ok: true, data: normalizeSplitPackageResponse(result.data) };
|
|
40
|
+
}
|
|
41
|
+
export async function splitPackageByQuantity(http, params, options) {
|
|
42
|
+
if (params.splitPackages.length < 1) {
|
|
43
|
+
return { ok: false, reason: "En az bir splitPackage gerekli.", code: "EMPTY_PACKAGES" };
|
|
44
|
+
}
|
|
45
|
+
const result = await http.requestJson({
|
|
46
|
+
resource: "rest",
|
|
47
|
+
method: "POST",
|
|
48
|
+
path: SPLIT_PACKAGE_BY_QUANTITY_PATH,
|
|
49
|
+
body: params,
|
|
50
|
+
retryPolicy: "none",
|
|
51
|
+
signal: options?.signal,
|
|
52
|
+
});
|
|
53
|
+
if (!result.ok) {
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
return { ok: true, data: normalizeSplitPackageResponse(result.data) };
|
|
57
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { N11HttpClient } from "../http.js";
|
|
2
|
+
import type { N11Result } from "../types.js";
|
|
3
|
+
import type { N11OrderUpdateParams, N11OrderUpdateResponse } from "../types/orders.js";
|
|
4
|
+
type UpdateOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export declare function buildOrderUpdateBody(params: N11OrderUpdateParams): {
|
|
8
|
+
lines: {
|
|
9
|
+
lineId: number;
|
|
10
|
+
}[];
|
|
11
|
+
status: "Picking";
|
|
12
|
+
};
|
|
13
|
+
export declare function updateOrderLines(http: N11HttpClient, params: N11OrderUpdateParams, options?: UpdateOptions): Promise<N11Result<N11OrderUpdateResponse>>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/orders/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGvF,KAAK,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAE9C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG;IAClE,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5B,MAAM,EAAE,SAAS,CAAC;CACnB,CAKA;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAmB5C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ORDER_UPDATE_PATH } from "../orders/paths.js";
|
|
2
|
+
import { normalizeOrderUpdateResponse } from "../wire/normalize.js";
|
|
3
|
+
export function buildOrderUpdateBody(params) {
|
|
4
|
+
return {
|
|
5
|
+
lines: params.lines.map((line) => ({ lineId: line.orderLineId })),
|
|
6
|
+
status: params.status ?? "Picking",
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export async function updateOrderLines(http, params, options) {
|
|
10
|
+
if (params.lines.length < 1) {
|
|
11
|
+
return { ok: false, reason: "En az bir orderLineId gerekli.", code: "EMPTY_LINES" };
|
|
12
|
+
}
|
|
13
|
+
const result = await http.requestJson({
|
|
14
|
+
resource: "rest",
|
|
15
|
+
method: "PUT",
|
|
16
|
+
path: ORDER_UPDATE_PATH,
|
|
17
|
+
body: buildOrderUpdateBody(params),
|
|
18
|
+
retryPolicy: "none",
|
|
19
|
+
signal: options?.signal,
|
|
20
|
+
});
|
|
21
|
+
if (!result.ok) {
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
return { ok: true, data: normalizeOrderUpdateResponse(result.data) };
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { N11HttpClient } from "../http.js";
|
|
2
|
+
import type { N11Config, N11Result } from "../types.js";
|
|
3
|
+
import type { N11PriceStockSku, N11ProductCreateSku, N11ProductDeleteSku, N11ProductQueryParams, N11ProductQueryResponse, N11ProductUpdateSku, N11TaskSubmitResponse } from "../types/products.js";
|
|
4
|
+
import type { BuildProductPayloadOptions } from "./builder.js";
|
|
5
|
+
type ProductRequestOptions = {
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
validate?: boolean;
|
|
8
|
+
categoryAttributes?: BuildProductPayloadOptions["categoryAttributes"];
|
|
9
|
+
};
|
|
10
|
+
export declare class ProductsApi {
|
|
11
|
+
private readonly http;
|
|
12
|
+
private readonly config;
|
|
13
|
+
constructor(http: N11HttpClient, config: N11Config);
|
|
14
|
+
createProduct(skus: N11ProductCreateSku[], options?: ProductRequestOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
15
|
+
updateProduct(skus: N11ProductUpdateSku[], options?: ProductRequestOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
16
|
+
updatePriceStock(skus: N11PriceStockSku[], options?: ProductRequestOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
17
|
+
deleteProduct(skus: N11ProductDeleteSku[] | string[], options?: ProductRequestOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
18
|
+
query(params?: N11ProductQueryParams, options?: ProductRequestOptions): Promise<N11Result<N11ProductQueryResponse>>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/products/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAU/D,KAAK,qBAAqB,GAAG;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;CACvE,CAAC;AAEF,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS;IAG9B,aAAa,CACjB,IAAI,EAAE,mBAAmB,EAAE,EAC3B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAa5C,aAAa,CACX,IAAI,EAAE,mBAAmB,EAAE,EAC3B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAI5C,gBAAgB,CACd,IAAI,EAAE,gBAAgB,EAAE,EACxB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAI5C,aAAa,CACX,IAAI,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,EACtC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAO5C,KAAK,CACH,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;CAG/C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { buildProductCreatePayload } from "./builder.js";
|
|
2
|
+
import { queryProducts } from "./query.js";
|
|
3
|
+
import { submitCreateProduct, submitDeleteProduct, submitPriceStockUpdate, submitUpdateProduct, } from "./tasks.js";
|
|
4
|
+
export class ProductsApi {
|
|
5
|
+
http;
|
|
6
|
+
config;
|
|
7
|
+
constructor(http, config) {
|
|
8
|
+
this.http = http;
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
async createProduct(skus, options) {
|
|
12
|
+
if (options?.validate !== false) {
|
|
13
|
+
const built = buildProductCreatePayload(skus, {
|
|
14
|
+
categoryAttributes: options?.categoryAttributes,
|
|
15
|
+
});
|
|
16
|
+
if (!built.ok) {
|
|
17
|
+
return built;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return submitCreateProduct(this.http, this.config, skus, options);
|
|
21
|
+
}
|
|
22
|
+
updateProduct(skus, options) {
|
|
23
|
+
return submitUpdateProduct(this.http, this.config, skus, options);
|
|
24
|
+
}
|
|
25
|
+
updatePriceStock(skus, options) {
|
|
26
|
+
return submitPriceStockUpdate(this.http, this.config, skus, options);
|
|
27
|
+
}
|
|
28
|
+
deleteProduct(skus, options) {
|
|
29
|
+
const normalized = skus.map((item) => typeof item === "string" ? { stockCode: item } : item);
|
|
30
|
+
return submitDeleteProduct(this.http, this.config, normalized, options);
|
|
31
|
+
}
|
|
32
|
+
query(params, options) {
|
|
33
|
+
return queryProducts(this.http, params, options);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { N11Result } from "../types.js";
|
|
2
|
+
import type { N11CatalogFastPathInput, N11CategoryAttribute, N11ProductCreateSku } from "../types/products.js";
|
|
3
|
+
export type BuildProductPayloadOptions = {
|
|
4
|
+
categoryAttributes?: N11CategoryAttribute[];
|
|
5
|
+
};
|
|
6
|
+
/** catalogId veya barcode ile katalog/buybox hizli yukleme yolu. */
|
|
7
|
+
export declare function isCatalogFastPathSku(sku: Pick<N11ProductCreateSku, "catalogId" | "barcode">): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Katalog hizli yukleme SKU'su — SearchCatalog SOAP yerine product-create + catalogId/barcode.
|
|
10
|
+
* Attribute zorunlulugu yok; n11 katalog eslesmesi portal kurali.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildCatalogFastPathSku(input: N11CatalogFastPathInput): N11Result<N11ProductCreateSku>;
|
|
13
|
+
/**
|
|
14
|
+
* Urun yukleme payload dogrulama.
|
|
15
|
+
* Katalog hizli yol (catalogId/barcode) attribute zorunlulugunu atlar.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildProductCreatePayload(items: N11ProductCreateSku[], options?: BuildProductPayloadOptions): N11Result<N11ProductCreateSku[]>;
|
|
18
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/products/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,0BAA0B,GAAG;IACvC,kBAAkB,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAC7C,CAAC;AAIF,oEAAoE;AACpE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,SAAS,CAAC,GAAG,OAAO,CASrG;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,uBAAuB,GAC7B,SAAS,CAAC,mBAAmB,CAAC,CAiDhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,mBAAmB,EAAE,EAC5B,OAAO,CAAC,EAAE,0BAA0B,GACnC,SAAS,CAAC,mBAAmB,EAAE,CAAC,CA+DlC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { validatePrices } from "../wire/validate.js";
|
|
2
|
+
const VALID_VAT_RATES = new Set([0, 1, 10, 20]);
|
|
3
|
+
/** catalogId veya barcode ile katalog/buybox hizli yukleme yolu. */
|
|
4
|
+
export function isCatalogFastPathSku(sku) {
|
|
5
|
+
if (sku.catalogId != null && sku.catalogId !== 0) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const barcode = sku.barcode;
|
|
9
|
+
if (barcode == null || barcode === "" || barcode === "null") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Katalog hizli yukleme SKU'su — SearchCatalog SOAP yerine product-create + catalogId/barcode.
|
|
16
|
+
* Attribute zorunlulugu yok; n11 katalog eslesmesi portal kurali.
|
|
17
|
+
*/
|
|
18
|
+
export function buildCatalogFastPathSku(input) {
|
|
19
|
+
if (!input.stockCode?.trim()) {
|
|
20
|
+
return { ok: false, reason: "stockCode zorunludur." };
|
|
21
|
+
}
|
|
22
|
+
if (input.catalogId == null && (input.barcode == null || input.barcode === "")) {
|
|
23
|
+
return {
|
|
24
|
+
ok: false,
|
|
25
|
+
reason: "Katalog hizli yukleme icin catalogId veya barcode gerekli.",
|
|
26
|
+
code: "CATALOG_IDENTIFIER_MISSING",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const priceValidation = validatePrices(input.listPrice, input.salePrice);
|
|
30
|
+
if (!priceValidation.ok) {
|
|
31
|
+
return priceValidation;
|
|
32
|
+
}
|
|
33
|
+
if (!Number.isFinite(input.quantity) || input.quantity < 0) {
|
|
34
|
+
return { ok: false, reason: "quantity gecerli bir sayi olmalidir." };
|
|
35
|
+
}
|
|
36
|
+
if (!input.shipmentTemplate?.trim()) {
|
|
37
|
+
return { ok: false, reason: "shipmentTemplate zorunludur." };
|
|
38
|
+
}
|
|
39
|
+
if (!Number.isFinite(input.preparingDay) || input.preparingDay < 0) {
|
|
40
|
+
return { ok: false, reason: "preparingDay gecerli bir sayi olmalidir." };
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
ok: true,
|
|
44
|
+
data: {
|
|
45
|
+
title: input.title ?? input.stockCode,
|
|
46
|
+
description: input.description ?? input.title ?? input.stockCode,
|
|
47
|
+
categoryId: input.categoryId ?? 0,
|
|
48
|
+
currencyType: input.currencyType ?? "TL",
|
|
49
|
+
productMainId: input.productMainId ?? input.stockCode,
|
|
50
|
+
preparingDay: input.preparingDay,
|
|
51
|
+
shipmentTemplate: input.shipmentTemplate,
|
|
52
|
+
stockCode: input.stockCode.trim(),
|
|
53
|
+
catalogId: input.catalogId ?? null,
|
|
54
|
+
barcode: input.barcode ?? null,
|
|
55
|
+
quantity: input.quantity,
|
|
56
|
+
salePrice: input.salePrice,
|
|
57
|
+
listPrice: input.listPrice,
|
|
58
|
+
vatRate: input.vatRate ?? 20,
|
|
59
|
+
maxPurchaseQuantity: input.maxPurchaseQuantity,
|
|
60
|
+
images: [],
|
|
61
|
+
attributes: [],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Urun yukleme payload dogrulama.
|
|
67
|
+
* Katalog hizli yol (catalogId/barcode) attribute zorunlulugunu atlar.
|
|
68
|
+
*/
|
|
69
|
+
export function buildProductCreatePayload(items, options) {
|
|
70
|
+
if (items.length < 1) {
|
|
71
|
+
return { ok: false, reason: "En az bir urun satiri gerekli." };
|
|
72
|
+
}
|
|
73
|
+
const seenStockCodes = new Set();
|
|
74
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
75
|
+
const item = items[index];
|
|
76
|
+
const prefix = `skus[${index}]`;
|
|
77
|
+
if (!item.stockCode?.trim()) {
|
|
78
|
+
return { ok: false, reason: `${prefix}: stockCode zorunludur.` };
|
|
79
|
+
}
|
|
80
|
+
const stockCode = item.stockCode.trim();
|
|
81
|
+
if (seenStockCodes.has(stockCode)) {
|
|
82
|
+
return { ok: false, reason: `${prefix}: tekrarlayan stockCode '${stockCode}'.` };
|
|
83
|
+
}
|
|
84
|
+
seenStockCodes.add(stockCode);
|
|
85
|
+
const priceValidation = validatePrices(item.listPrice, item.salePrice);
|
|
86
|
+
if (!priceValidation.ok) {
|
|
87
|
+
return { ok: false, reason: `${prefix}: ${priceValidation.reason}` };
|
|
88
|
+
}
|
|
89
|
+
if (!VALID_VAT_RATES.has(item.vatRate)) {
|
|
90
|
+
return { ok: false, reason: `${prefix}: vatRate 0, 1, 10 veya 20 olmalidir.` };
|
|
91
|
+
}
|
|
92
|
+
if (isCatalogFastPathSku(item)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (!item.title?.trim()) {
|
|
96
|
+
return { ok: false, reason: `${prefix}: title zorunludur.` };
|
|
97
|
+
}
|
|
98
|
+
if (!item.description?.trim()) {
|
|
99
|
+
return { ok: false, reason: `${prefix}: description zorunludur.` };
|
|
100
|
+
}
|
|
101
|
+
if (!Number.isFinite(item.categoryId) || item.categoryId <= 0) {
|
|
102
|
+
return { ok: false, reason: `${prefix}: categoryId zorunludur.` };
|
|
103
|
+
}
|
|
104
|
+
if (!item.productMainId?.trim()) {
|
|
105
|
+
return { ok: false, reason: `${prefix}: productMainId zorunludur.` };
|
|
106
|
+
}
|
|
107
|
+
if (!item.shipmentTemplate?.trim()) {
|
|
108
|
+
return { ok: false, reason: `${prefix}: shipmentTemplate zorunludur.` };
|
|
109
|
+
}
|
|
110
|
+
if (!Array.isArray(item.images) || item.images.length < 1) {
|
|
111
|
+
return { ok: false, reason: `${prefix}: en az bir gorsel gerekli.` };
|
|
112
|
+
}
|
|
113
|
+
const attributeError = validateMandatoryCategoryAttributes(item, options?.categoryAttributes, prefix);
|
|
114
|
+
if (attributeError) {
|
|
115
|
+
return attributeError;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return { ok: true, data: items };
|
|
119
|
+
}
|
|
120
|
+
function validateMandatoryCategoryAttributes(item, categoryAttributes, prefix) {
|
|
121
|
+
if (!categoryAttributes?.length) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
const mandatory = categoryAttributes.filter((attr) => attr.isMandatory === true);
|
|
125
|
+
if (mandatory.length === 0) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const provided = new Set((item.attributes ?? []).map((a) => a.id));
|
|
129
|
+
for (const attr of mandatory) {
|
|
130
|
+
if (attr.attributeId != null && !provided.has(attr.attributeId)) {
|
|
131
|
+
return {
|
|
132
|
+
ok: false,
|
|
133
|
+
reason: `${prefix}: zorunlu kategori attribute ${attr.attributeId} (${attr.attributeName ?? "?"}) eksik.`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const PRODUCT_CREATE_PATH = "/product/tasks/product-create";
|
|
2
|
+
export declare const PRODUCT_UPDATE_PATH = "/product/tasks/product-update";
|
|
3
|
+
export declare const PRICE_STOCK_UPDATE_PATH = "/product/tasks/price-stock-update";
|
|
4
|
+
export declare const PRODUCT_DELETE_PATH = "/product/tasks/product-delete";
|
|
5
|
+
export declare const PRODUCT_QUERY_PATH = "/product-query";
|
|
6
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/products/paths.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AACnE,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AACnE,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAC3E,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AACnE,eAAO,MAAM,kBAAkB,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const PRODUCT_CREATE_PATH = "/product/tasks/product-create";
|
|
2
|
+
export const PRODUCT_UPDATE_PATH = "/product/tasks/product-update";
|
|
3
|
+
export const PRICE_STOCK_UPDATE_PATH = "/product/tasks/price-stock-update";
|
|
4
|
+
export const PRODUCT_DELETE_PATH = "/product/tasks/product-delete";
|
|
5
|
+
export const PRODUCT_QUERY_PATH = "/product-query";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { N11HttpClient } from "../http.js";
|
|
2
|
+
import type { N11Result } from "../types.js";
|
|
3
|
+
import type { N11ProductQueryParams, N11ProductQueryResponse } from "../types/products.js";
|
|
4
|
+
type ProductQueryOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export declare function queryProducts(http: N11HttpClient, params?: N11ProductQueryParams, options?: ProductQueryOptions): Promise<N11Result<N11ProductQueryResponse>>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/products/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAM3F,KAAK,mBAAmB,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAwBpD,wBAAsB,aAAa,CACjC,IAAI,EAAE,aAAa,EACnB,MAAM,GAAE,qBAA0B,EAClC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC,CAqB7C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { N11_PRODUCT_QUERY_DEFAULT_SIZE } from "../constants/page-limits.js";
|
|
2
|
+
import { normalizeProductQueryResponse } from "../wire/normalize.js";
|
|
3
|
+
import { validateProductQueryPageSize } from "../wire/validate.js";
|
|
4
|
+
import { PRODUCT_QUERY_PATH } from "./paths.js";
|
|
5
|
+
function serializeProductQuery(params) {
|
|
6
|
+
const query = {};
|
|
7
|
+
if (params.id !== undefined)
|
|
8
|
+
query.id = params.id;
|
|
9
|
+
if (params.productMainId !== undefined)
|
|
10
|
+
query.productMainId = params.productMainId;
|
|
11
|
+
if (params.stockCode !== undefined)
|
|
12
|
+
query.stockCode = params.stockCode;
|
|
13
|
+
if (params.saleStatus !== undefined)
|
|
14
|
+
query.saleStatus = params.saleStatus;
|
|
15
|
+
if (params.productStatus !== undefined)
|
|
16
|
+
query.productStatus = params.productStatus;
|
|
17
|
+
if (params.brandName !== undefined)
|
|
18
|
+
query.brandName = params.brandName;
|
|
19
|
+
if (params.sender !== undefined)
|
|
20
|
+
query.sender = params.sender;
|
|
21
|
+
if (params.page !== undefined)
|
|
22
|
+
query.page = params.page;
|
|
23
|
+
query.size = params.size ?? N11_PRODUCT_QUERY_DEFAULT_SIZE;
|
|
24
|
+
if (params.categoryIds !== undefined) {
|
|
25
|
+
query.categoryIds = Array.isArray(params.categoryIds)
|
|
26
|
+
? params.categoryIds.join(",")
|
|
27
|
+
: params.categoryIds;
|
|
28
|
+
}
|
|
29
|
+
return query;
|
|
30
|
+
}
|
|
31
|
+
export async function queryProducts(http, params = {}, options) {
|
|
32
|
+
const size = params.size ?? N11_PRODUCT_QUERY_DEFAULT_SIZE;
|
|
33
|
+
const sizeValidation = validateProductQueryPageSize(size);
|
|
34
|
+
if (!sizeValidation.ok) {
|
|
35
|
+
return sizeValidation;
|
|
36
|
+
}
|
|
37
|
+
const result = await http.requestJson({
|
|
38
|
+
resource: "ms",
|
|
39
|
+
method: "GET",
|
|
40
|
+
path: PRODUCT_QUERY_PATH,
|
|
41
|
+
query: serializeProductQuery({ ...params, size }),
|
|
42
|
+
retryPolicy: "safe",
|
|
43
|
+
signal: options?.signal,
|
|
44
|
+
});
|
|
45
|
+
if (!result.ok) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
return { ok: true, data: normalizeProductQueryResponse(result.data) };
|
|
49
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { N11HttpClient } from "../http.js";
|
|
2
|
+
import type { N11Config, N11Result } from "../types.js";
|
|
3
|
+
import type { N11PriceStockSku, N11ProductCreateSku, N11ProductDeleteSku, N11ProductUpdateSku, N11TaskSubmitResponse } from "../types/products.js";
|
|
4
|
+
type TaskSubmitOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export declare function submitCreateProduct(http: N11HttpClient, config: N11Config, skus: N11ProductCreateSku[], options?: TaskSubmitOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
8
|
+
export declare function submitUpdateProduct(http: N11HttpClient, config: N11Config, skus: N11ProductUpdateSku[], options?: TaskSubmitOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
9
|
+
export declare function submitPriceStockUpdate(http: N11HttpClient, config: N11Config, skus: N11PriceStockSku[], options?: TaskSubmitOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
10
|
+
export declare function submitDeleteProduct(http: N11HttpClient, config: N11Config, skus: N11ProductDeleteSku[], options?: TaskSubmitOptions): Promise<N11Result<N11TaskSubmitResponse>>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=tasks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/products/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAU9B,KAAK,iBAAiB,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAgDlD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,mBAAmB,EAAE,EAC3B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAE3C;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,mBAAmB,EAAE,EAC3B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAE3C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,gBAAgB,EAAE,EACxB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAE3C;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,mBAAmB,EAAE,EAC3B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAE3C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { normalizeTaskSubmitResponse } from "../wire/normalize.js";
|
|
2
|
+
import { validateBatchSize } from "../wire/validate.js";
|
|
3
|
+
import { PRICE_STOCK_UPDATE_PATH, PRODUCT_CREATE_PATH, PRODUCT_DELETE_PATH, PRODUCT_UPDATE_PATH, } from "./paths.js";
|
|
4
|
+
function buildTaskBody(integrator, skus) {
|
|
5
|
+
return {
|
|
6
|
+
payload: {
|
|
7
|
+
integrator,
|
|
8
|
+
skus,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
async function submitProductTask(http, config, path, skus, options) {
|
|
13
|
+
const validation = validateBatchSize(skus.length);
|
|
14
|
+
if (!validation.ok) {
|
|
15
|
+
return validation;
|
|
16
|
+
}
|
|
17
|
+
const result = await http.requestJson({
|
|
18
|
+
resource: "ms",
|
|
19
|
+
method: "POST",
|
|
20
|
+
path,
|
|
21
|
+
body: buildTaskBody(config.integratorName, skus),
|
|
22
|
+
retryPolicy: "none",
|
|
23
|
+
signal: options?.signal,
|
|
24
|
+
});
|
|
25
|
+
if (!result.ok) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
const normalized = normalizeTaskSubmitResponse(result.data);
|
|
29
|
+
if (!normalized.id) {
|
|
30
|
+
return {
|
|
31
|
+
ok: false,
|
|
32
|
+
reason: "Task submit yanitinda id bulunamadi.",
|
|
33
|
+
raw: normalized.raw,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return { ok: true, data: normalized };
|
|
37
|
+
}
|
|
38
|
+
export async function submitCreateProduct(http, config, skus, options) {
|
|
39
|
+
return submitProductTask(http, config, PRODUCT_CREATE_PATH, skus, options);
|
|
40
|
+
}
|
|
41
|
+
export async function submitUpdateProduct(http, config, skus, options) {
|
|
42
|
+
return submitProductTask(http, config, PRODUCT_UPDATE_PATH, skus, options);
|
|
43
|
+
}
|
|
44
|
+
export async function submitPriceStockUpdate(http, config, skus, options) {
|
|
45
|
+
return submitProductTask(http, config, PRICE_STOCK_UPDATE_PATH, skus, options);
|
|
46
|
+
}
|
|
47
|
+
export async function submitDeleteProduct(http, config, skus, options) {
|
|
48
|
+
return submitProductTask(http, config, PRODUCT_DELETE_PATH, skus, options);
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { N11SoapClient } from "../soap/client.js";
|
|
2
|
+
import type { N11Config, N11Result } from "../types.js";
|
|
3
|
+
import type { N11ProductQuestionAnswerParams } from "../types/qna.js";
|
|
4
|
+
import type { N11SoapMutationResult } from "../types/returns.js";
|
|
5
|
+
type AnswerOptions = {
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
};
|
|
8
|
+
export declare function saveProductAnswer(soap: N11SoapClient, config: N11Config, params: N11ProductQuestionAnswerParams, options?: AnswerOptions): Promise<N11Result<N11SoapMutationResult>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=answer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/qna/answer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAKjE,KAAK,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAE9C,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,8BAA8B,EACtC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAyB3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { invokeSoapOperation } from "../soap/call.js";
|
|
2
|
+
import { parseSaveProductAnswerResponse } from "./parse.js";
|
|
3
|
+
import { buildSaveProductAnswerRequestBody } from "./soap-body.js";
|
|
4
|
+
import { validateProductQuestionAnswer } from "./validate.js";
|
|
5
|
+
export async function saveProductAnswer(soap, config, params, options) {
|
|
6
|
+
if (params.productQuestionId === undefined || String(params.productQuestionId).length === 0) {
|
|
7
|
+
return {
|
|
8
|
+
ok: false,
|
|
9
|
+
reason: "productQuestionId zorunludur.",
|
|
10
|
+
code: "INVALID_QNA_PARAMS",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const answerCheck = validateProductQuestionAnswer(params.answer);
|
|
14
|
+
if (!answerCheck.ok) {
|
|
15
|
+
return answerCheck;
|
|
16
|
+
}
|
|
17
|
+
const bodyXml = buildSaveProductAnswerRequestBody({ appKey: config.appKey, appSecret: config.appSecret }, params);
|
|
18
|
+
const result = await invokeSoapOperation(soap, "SaveProductAnswer", bodyXml, options);
|
|
19
|
+
if (!result.ok) {
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
return { ok: true, data: parseSaveProductAnswerResponse(result.data) };
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { N11SoapClient } from "../soap/client.js";
|
|
2
|
+
import type { N11Config, N11Result } from "../types.js";
|
|
3
|
+
import type { N11ProductQuestionAnswerParams, N11ProductQuestionDetailParams, N11ProductQuestionDetailResponse, N11ProductQuestionListParams, N11ProductQuestionListResponse } from "../types/qna.js";
|
|
4
|
+
import type { N11SoapMutationResult } from "../types/returns.js";
|
|
5
|
+
type QnaRequestOptions = {
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
};
|
|
8
|
+
export declare class QnaApi {
|
|
9
|
+
private readonly soap;
|
|
10
|
+
private readonly config;
|
|
11
|
+
constructor(soap: N11SoapClient, config: N11Config);
|
|
12
|
+
list(params: N11ProductQuestionListParams, options?: QnaRequestOptions): Promise<N11Result<N11ProductQuestionListResponse>>;
|
|
13
|
+
detail(params: N11ProductQuestionDetailParams, options?: QnaRequestOptions): Promise<N11Result<N11ProductQuestionDetailResponse>>;
|
|
14
|
+
answer(params: N11ProductQuestionAnswerParams, options?: QnaRequestOptions): Promise<N11Result<N11SoapMutationResult>>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/qna/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EACV,8BAA8B,EAC9B,8BAA8B,EAC9B,gCAAgC,EAChC,4BAA4B,EAC5B,8BAA8B,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAKjE,KAAK,iBAAiB,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAElD,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS;IAGpC,IAAI,CACF,MAAM,EAAE,4BAA4B,EACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;IAIrD,MAAM,CACJ,MAAM,EAAE,8BAA8B,EACtC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;IAIvD,MAAM,CACJ,MAAM,EAAE,8BAA8B,EACtC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;CAG7C"}
|
package/dist/qna/api.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { saveProductAnswer as saveProductAnswerImpl } from "./answer.js";
|
|
2
|
+
import { getProductQuestionDetail as getProductQuestionDetailImpl } from "./detail.js";
|
|
3
|
+
import { listProductQuestions } from "./list.js";
|
|
4
|
+
export class QnaApi {
|
|
5
|
+
soap;
|
|
6
|
+
config;
|
|
7
|
+
constructor(soap, config) {
|
|
8
|
+
this.soap = soap;
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
list(params, options) {
|
|
12
|
+
return listProductQuestions(this.soap, this.config, params, options);
|
|
13
|
+
}
|
|
14
|
+
detail(params, options) {
|
|
15
|
+
return getProductQuestionDetailImpl(this.soap, this.config, params, options);
|
|
16
|
+
}
|
|
17
|
+
answer(params, options) {
|
|
18
|
+
return saveProductAnswerImpl(this.soap, this.config, params, options);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { N11SoapClient } from "../soap/client.js";
|
|
2
|
+
import type { N11Config, N11Result } from "../types.js";
|
|
3
|
+
import type { N11ProductQuestionDetailParams, N11ProductQuestionDetailResponse } from "../types/qna.js";
|
|
4
|
+
type DetailOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export declare function getProductQuestionDetail(soap: N11SoapClient, config: N11Config, params: N11ProductQuestionDetailParams, options?: DetailOptions): Promise<N11Result<N11ProductQuestionDetailResponse>>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=detail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detail.d.ts","sourceRoot":"","sources":["../../src/qna/detail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EACV,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,iBAAiB,CAAC;AAIzB,KAAK,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAE9C,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,8BAA8B,EACtC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC,CAoBtD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { invokeSoapOperation } from "../soap/call.js";
|
|
2
|
+
import { parseProductQuestionDetailResponse } from "./parse.js";
|
|
3
|
+
import { buildGetProductQuestionDetailRequestBody } from "./soap-body.js";
|
|
4
|
+
export async function getProductQuestionDetail(soap, config, params, options) {
|
|
5
|
+
if (params.productQuestionId === undefined || String(params.productQuestionId).length === 0) {
|
|
6
|
+
return {
|
|
7
|
+
ok: false,
|
|
8
|
+
reason: "productQuestionId zorunludur.",
|
|
9
|
+
code: "INVALID_QNA_PARAMS",
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const bodyXml = buildGetProductQuestionDetailRequestBody({ appKey: config.appKey, appSecret: config.appSecret }, params);
|
|
13
|
+
const result = await invokeSoapOperation(soap, "GetProductQuestionDetail", bodyXml, options);
|
|
14
|
+
if (!result.ok) {
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
return { ok: true, data: parseProductQuestionDetailResponse(result.data) };
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { N11SoapClient } from "../soap/client.js";
|
|
2
|
+
import type { N11Config, N11Result } from "../types.js";
|
|
3
|
+
import type { N11ProductQuestionListParams, N11ProductQuestionListResponse } from "../types/qna.js";
|
|
4
|
+
type ListOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export declare function listProductQuestions(soap: N11SoapClient, config: N11Config, params: N11ProductQuestionListParams, options?: ListOptions): Promise<N11Result<N11ProductQuestionListResponse>>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/qna/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EACV,4BAA4B,EAC5B,8BAA8B,EAC/B,MAAM,iBAAiB,CAAC;AAKzB,KAAK,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,4BAA4B,EACpC,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC,CAiBpD"}
|
package/dist/qna/list.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { invokeSoapOperation } from "../soap/call.js";
|
|
2
|
+
import { parseProductQuestionListResponse } from "./parse.js";
|
|
3
|
+
import { buildGetProductQuestionListRequestBody } from "./soap-body.js";
|
|
4
|
+
import { validateProductQuestionListParams } from "./validate.js";
|
|
5
|
+
export async function listProductQuestions(soap, config, params, options) {
|
|
6
|
+
const validation = validateProductQuestionListParams(params);
|
|
7
|
+
if (!validation.ok) {
|
|
8
|
+
return validation;
|
|
9
|
+
}
|
|
10
|
+
const bodyXml = buildGetProductQuestionListRequestBody({ appKey: config.appKey, appSecret: config.appSecret }, params);
|
|
11
|
+
const result = await invokeSoapOperation(soap, "GetProductQuestionList", bodyXml, options);
|
|
12
|
+
if (!result.ok) {
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
return { ok: true, data: parseProductQuestionListResponse(result.data) };
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { N11ProductQuestionDetailResponse, N11ProductQuestionListResponse } from "../types/qna.js";
|
|
2
|
+
import type { N11SoapMutationResult } from "../types/returns.js";
|
|
3
|
+
export declare function parseProductQuestionListResponse(xml: string): N11ProductQuestionListResponse;
|
|
4
|
+
export declare function parseProductQuestionDetailResponse(xml: string): N11ProductQuestionDetailResponse;
|
|
5
|
+
export declare function parseSaveProductAnswerResponse(xml: string): N11SoapMutationResult;
|
|
6
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/qna/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,gCAAgC,EAChC,8BAA8B,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AA0CjE,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,8BAA8B,CAkB5F;AAED,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,MAAM,GAAG,gCAAgC,CAQhG;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAMjF"}
|