@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.
Files changed (223) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +21 -0
  3. package/README.md +81 -0
  4. package/dist/categories/api.d.ts +12 -0
  5. package/dist/categories/api.d.ts.map +1 -0
  6. package/dist/categories/api.js +34 -0
  7. package/dist/client.d.ts +37 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +70 -0
  10. package/dist/config.d.ts +9 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +58 -0
  13. package/dist/connection.d.ts +5 -0
  14. package/dist/connection.d.ts.map +1 -0
  15. package/dist/connection.js +4 -0
  16. package/dist/constants/defaults.d.ts +16 -0
  17. package/dist/constants/defaults.d.ts.map +1 -0
  18. package/dist/constants/defaults.js +15 -0
  19. package/dist/constants/hosts.d.ts +9 -0
  20. package/dist/constants/hosts.d.ts.map +1 -0
  21. package/dist/constants/hosts.js +25 -0
  22. package/dist/constants/page-limits.d.ts +15 -0
  23. package/dist/constants/page-limits.d.ts.map +1 -0
  24. package/dist/constants/page-limits.js +14 -0
  25. package/dist/errors.d.ts +42 -0
  26. package/dist/errors.d.ts.map +1 -0
  27. package/dist/errors.js +162 -0
  28. package/dist/http/query.d.ts +2 -0
  29. package/dist/http/query.d.ts.map +1 -0
  30. package/dist/http/query.js +10 -0
  31. package/dist/http/response.d.ts +12 -0
  32. package/dist/http/response.d.ts.map +1 -0
  33. package/dist/http/response.js +43 -0
  34. package/dist/http/security.d.ts +6 -0
  35. package/dist/http/security.d.ts.map +1 -0
  36. package/dist/http/security.js +29 -0
  37. package/dist/http/signals.d.ts +5 -0
  38. package/dist/http/signals.d.ts.map +1 -0
  39. package/dist/http/signals.js +26 -0
  40. package/dist/http.d.ts +12 -0
  41. package/dist/http.d.ts.map +1 -0
  42. package/dist/http.js +143 -0
  43. package/dist/index.d.ts +47 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +37 -0
  46. package/dist/invoice/api.d.ts +14 -0
  47. package/dist/invoice/api.d.ts.map +1 -0
  48. package/dist/invoice/api.js +12 -0
  49. package/dist/invoice/parse.d.ts +3 -0
  50. package/dist/invoice/parse.d.ts.map +1 -0
  51. package/dist/invoice/parse.js +12 -0
  52. package/dist/invoice/send-link.d.ts +9 -0
  53. package/dist/invoice/send-link.d.ts.map +1 -0
  54. package/dist/invoice/send-link.js +16 -0
  55. package/dist/invoice/soap-body.d.ts +6 -0
  56. package/dist/invoice/soap-body.d.ts.map +1 -0
  57. package/dist/invoice/soap-body.js +23 -0
  58. package/dist/invoice/validate.d.ts +7 -0
  59. package/dist/invoice/validate.d.ts.map +1 -0
  60. package/dist/invoice/validate.js +73 -0
  61. package/dist/logger.d.ts +20 -0
  62. package/dist/logger.d.ts.map +1 -0
  63. package/dist/logger.js +61 -0
  64. package/dist/orders/api.d.ts +22 -0
  65. package/dist/orders/api.d.ts.map +1 -0
  66. package/dist/orders/api.js +40 -0
  67. package/dist/orders/date.d.ts +12 -0
  68. package/dist/orders/date.d.ts.map +1 -0
  69. package/dist/orders/date.js +21 -0
  70. package/dist/orders/labor-cost.d.ts +9 -0
  71. package/dist/orders/labor-cost.d.ts.map +1 -0
  72. package/dist/orders/labor-cost.js +23 -0
  73. package/dist/orders/list.d.ts +23 -0
  74. package/dist/orders/list.d.ts.map +1 -0
  75. package/dist/orders/list.js +76 -0
  76. package/dist/orders/paths.d.ts +7 -0
  77. package/dist/orders/paths.d.ts.map +1 -0
  78. package/dist/orders/paths.js +6 -0
  79. package/dist/orders/reconciler.d.ts +30 -0
  80. package/dist/orders/reconciler.d.ts.map +1 -0
  81. package/dist/orders/reconciler.js +38 -0
  82. package/dist/orders/shipping.d.ts +11 -0
  83. package/dist/orders/shipping.d.ts.map +1 -0
  84. package/dist/orders/shipping.js +57 -0
  85. package/dist/orders/update.d.ts +15 -0
  86. package/dist/orders/update.d.ts.map +1 -0
  87. package/dist/orders/update.js +25 -0
  88. package/dist/products/api.d.ts +21 -0
  89. package/dist/products/api.d.ts.map +1 -0
  90. package/dist/products/api.js +35 -0
  91. package/dist/products/builder.d.ts +18 -0
  92. package/dist/products/builder.d.ts.map +1 -0
  93. package/dist/products/builder.js +138 -0
  94. package/dist/products/paths.d.ts +6 -0
  95. package/dist/products/paths.d.ts.map +1 -0
  96. package/dist/products/paths.js +5 -0
  97. package/dist/products/query.d.ts +9 -0
  98. package/dist/products/query.d.ts.map +1 -0
  99. package/dist/products/query.js +49 -0
  100. package/dist/products/tasks.d.ts +12 -0
  101. package/dist/products/tasks.d.ts.map +1 -0
  102. package/dist/products/tasks.js +49 -0
  103. package/dist/qna/answer.d.ts +10 -0
  104. package/dist/qna/answer.d.ts.map +1 -0
  105. package/dist/qna/answer.js +23 -0
  106. package/dist/qna/api.d.ts +17 -0
  107. package/dist/qna/api.d.ts.map +1 -0
  108. package/dist/qna/api.js +20 -0
  109. package/dist/qna/detail.d.ts +9 -0
  110. package/dist/qna/detail.d.ts.map +1 -0
  111. package/dist/qna/detail.js +18 -0
  112. package/dist/qna/list.d.ts +9 -0
  113. package/dist/qna/list.d.ts.map +1 -0
  114. package/dist/qna/list.js +16 -0
  115. package/dist/qna/parse.d.ts +6 -0
  116. package/dist/qna/parse.d.ts.map +1 -0
  117. package/dist/qna/parse.js +65 -0
  118. package/dist/qna/soap-body.d.ts +14 -0
  119. package/dist/qna/soap-body.d.ts.map +1 -0
  120. package/dist/qna/soap-body.js +48 -0
  121. package/dist/qna/validate.d.ts +7 -0
  122. package/dist/qna/validate.d.ts.map +1 -0
  123. package/dist/qna/validate.js +75 -0
  124. package/dist/rate-limit/governor.d.ts +8 -0
  125. package/dist/rate-limit/governor.d.ts.map +1 -0
  126. package/dist/rate-limit/governor.js +30 -0
  127. package/dist/rate-limit/groups.d.ts +34 -0
  128. package/dist/rate-limit/groups.d.ts.map +1 -0
  129. package/dist/rate-limit/groups.js +32 -0
  130. package/dist/retry.d.ts +5 -0
  131. package/dist/retry.d.ts.map +1 -0
  132. package/dist/retry.js +22 -0
  133. package/dist/returns/api.d.ts +21 -0
  134. package/dist/returns/api.d.ts.map +1 -0
  135. package/dist/returns/api.js +36 -0
  136. package/dist/returns/call.d.ts +2 -0
  137. package/dist/returns/call.d.ts.map +1 -0
  138. package/dist/returns/call.js +1 -0
  139. package/dist/returns/cancel-partial.d.ts +9 -0
  140. package/dist/returns/cancel-partial.d.ts.map +1 -0
  141. package/dist/returns/cancel-partial.js +18 -0
  142. package/dist/returns/list.d.ts +9 -0
  143. package/dist/returns/list.d.ts.map +1 -0
  144. package/dist/returns/list.js +16 -0
  145. package/dist/returns/mutations.d.ts +11 -0
  146. package/dist/returns/mutations.d.ts.map +1 -0
  147. package/dist/returns/mutations.js +22 -0
  148. package/dist/returns/parse.d.ts +6 -0
  149. package/dist/returns/parse.d.ts.map +1 -0
  150. package/dist/returns/parse.js +89 -0
  151. package/dist/returns/reasons.d.ts +11 -0
  152. package/dist/returns/reasons.d.ts.map +1 -0
  153. package/dist/returns/reasons.js +20 -0
  154. package/dist/returns/soap-body.d.ts +26 -0
  155. package/dist/returns/soap-body.d.ts.map +1 -0
  156. package/dist/returns/soap-body.js +95 -0
  157. package/dist/soap/call.d.ts +8 -0
  158. package/dist/soap/call.d.ts.map +1 -0
  159. package/dist/soap/call.js +22 -0
  160. package/dist/soap/client.d.ts +13 -0
  161. package/dist/soap/client.d.ts.map +1 -0
  162. package/dist/soap/client.js +125 -0
  163. package/dist/soap/envelope.d.ts +10 -0
  164. package/dist/soap/envelope.d.ts.map +1 -0
  165. package/dist/soap/envelope.js +47 -0
  166. package/dist/soap/operations.d.ts +6 -0
  167. package/dist/soap/operations.d.ts.map +1 -0
  168. package/dist/soap/operations.js +91 -0
  169. package/dist/soap/parse.d.ts +17 -0
  170. package/dist/soap/parse.d.ts.map +1 -0
  171. package/dist/soap/parse.js +37 -0
  172. package/dist/tasks/api.d.ts +11 -0
  173. package/dist/tasks/api.d.ts.map +1 -0
  174. package/dist/tasks/api.js +44 -0
  175. package/dist/tasks/module.d.ts +14 -0
  176. package/dist/tasks/module.d.ts.map +1 -0
  177. package/dist/tasks/module.js +15 -0
  178. package/dist/tasks/poller.d.ts +12 -0
  179. package/dist/tasks/poller.d.ts.map +1 -0
  180. package/dist/tasks/poller.js +133 -0
  181. package/dist/tasks/types.d.ts +27 -0
  182. package/dist/tasks/types.d.ts.map +1 -0
  183. package/dist/tasks/types.js +2 -0
  184. package/dist/testing/fixtures/category-leaf.json +11 -0
  185. package/dist/testing/fixtures/order-package.json +12 -0
  186. package/dist/testing/fixtures/task-partial-fail.json +18 -0
  187. package/dist/testing/fixtures.d.ts +76 -0
  188. package/dist/testing/fixtures.d.ts.map +1 -0
  189. package/dist/testing/fixtures.js +85 -0
  190. package/dist/testing/guard.d.ts +21 -0
  191. package/dist/testing/guard.d.ts.map +1 -0
  192. package/dist/testing/guard.js +50 -0
  193. package/dist/testing/index.d.ts +6 -0
  194. package/dist/testing/index.d.ts.map +1 -0
  195. package/dist/testing/index.js +4 -0
  196. package/dist/testing/mock-client.d.ts +49 -0
  197. package/dist/testing/mock-client.d.ts.map +1 -0
  198. package/dist/testing/mock-client.js +100 -0
  199. package/dist/types/invoice.d.ts +21 -0
  200. package/dist/types/invoice.d.ts.map +1 -0
  201. package/dist/types/invoice.js +1 -0
  202. package/dist/types/orders.d.ts +127 -0
  203. package/dist/types/orders.d.ts.map +1 -0
  204. package/dist/types/orders.js +1 -0
  205. package/dist/types/products.d.ts +146 -0
  206. package/dist/types/products.d.ts.map +1 -0
  207. package/dist/types/products.js +1 -0
  208. package/dist/types/qna.d.ts +61 -0
  209. package/dist/types/qna.d.ts.map +1 -0
  210. package/dist/types/qna.js +1 -0
  211. package/dist/types/returns.d.ts +96 -0
  212. package/dist/types/returns.d.ts.map +1 -0
  213. package/dist/types/returns.js +1 -0
  214. package/dist/types.d.ts +112 -0
  215. package/dist/types.d.ts.map +1 -0
  216. package/dist/types.js +1 -0
  217. package/dist/wire/normalize.d.ts +20 -0
  218. package/dist/wire/normalize.d.ts.map +1 -0
  219. package/dist/wire/normalize.js +158 -0
  220. package/dist/wire/validate.d.ts +6 -0
  221. package/dist/wire/validate.d.ts.map +1 -0
  222. package/dist/wire/validate.js +53 -0
  223. package/package.json +53 -0
@@ -0,0 +1,112 @@
1
+ export type RetryPolicy = "safe" | "none";
2
+ export type N11Result<T> = {
3
+ ok: true;
4
+ data: T;
5
+ } | {
6
+ ok: false;
7
+ reason: string;
8
+ code?: string | number;
9
+ status?: number;
10
+ raw?: unknown;
11
+ retryable?: boolean;
12
+ };
13
+ export type N11Config = {
14
+ appKey: string;
15
+ appSecret: string;
16
+ integratorName: string;
17
+ requestTimeoutMs: number;
18
+ debug: boolean;
19
+ maxRetries: number;
20
+ retryBaseMs: number;
21
+ enableClientSideLimiter: boolean;
22
+ maxResponseBodyBytes: number;
23
+ maxSoapBodyBytes: number;
24
+ allowProdMutations: boolean;
25
+ maxConcurrent?: number;
26
+ };
27
+ /** REST path prefix routing — tek host api.n11.com */
28
+ export type N11RestResource = "cdn" | "ms" | "rest";
29
+ export type HttpRequestOptions = {
30
+ resource: N11RestResource;
31
+ method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
32
+ path: string;
33
+ query?: Record<string, unknown>;
34
+ body?: unknown;
35
+ retryPolicy: RetryPolicy;
36
+ signal?: AbortSignal;
37
+ headers?: Record<string, string>;
38
+ };
39
+ export type WireRow<T> = T & {
40
+ raw: Record<string, unknown>;
41
+ };
42
+ export type N11Category = {
43
+ id?: number;
44
+ name?: string;
45
+ parentId?: number;
46
+ subCategories?: N11Category[];
47
+ };
48
+ export type CategoryListResponse = {
49
+ categories: WireRow<N11Category>[];
50
+ raw: Record<string, unknown>;
51
+ };
52
+ export type N11Logger = (level: "debug" | "info" | "warn" | "error", message: string, meta?: Record<string, unknown>) => void;
53
+ export type N11Hooks = {
54
+ onRequestStart?: (meta: RequestHookMeta) => void;
55
+ onRequestEnd?: (meta: RequestHookMeta & {
56
+ status?: number;
57
+ durationMs: number;
58
+ }) => void;
59
+ onRetry?: (meta: {
60
+ attempt: number;
61
+ status?: number;
62
+ delayMs: number;
63
+ }) => void;
64
+ onRateLimitHit?: (meta: {
65
+ retryAfterMs?: number;
66
+ resource?: string;
67
+ }) => void;
68
+ onTaskPoll?: (meta: {
69
+ taskId: string;
70
+ kind: string;
71
+ attempt: number;
72
+ status?: string;
73
+ elapsedMs: number;
74
+ }) => void;
75
+ onSoapCall?: (meta: {
76
+ correlationId: string;
77
+ operation: string;
78
+ durationMs: number;
79
+ status?: number;
80
+ }) => void;
81
+ };
82
+ export type RequestHookMeta = {
83
+ correlationId: string;
84
+ resource: string;
85
+ method: string;
86
+ path: string;
87
+ host: string;
88
+ transport: "rest" | "soap";
89
+ };
90
+ export type SoapEnvelopeFieldValue = string | number | boolean | undefined | null;
91
+ export type SoapCallOptions = {
92
+ wsdl: string;
93
+ operation: string;
94
+ endpoint: string;
95
+ bodyFields?: Record<string, SoapEnvelopeFieldValue>;
96
+ bodyXml?: string;
97
+ retryPolicy?: RetryPolicy;
98
+ signal?: AbortSignal;
99
+ };
100
+ export type SoapCallResult = {
101
+ rawBody: string;
102
+ status: number;
103
+ };
104
+ export type SoapOperationDef = {
105
+ wsdl: string;
106
+ wsdlUrl: string;
107
+ soapEndpoint: string;
108
+ operation: string;
109
+ faz: number;
110
+ };
111
+ export type TestConnectionResult = CategoryListResponse;
112
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACrB;IACE,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAA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AAM,oBAAoB,GAAG,oBAAoB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { TaskStatusPayload } from "../tasks/types.js";
2
+ import type { N11CategoryAttributesResponse, N11ProductQueryResponse, N11TaskSubmitResponse } from "../types/products.js";
3
+ import type { N11LaborCostUpdateResponse, N11OrderUpdateResponse, N11ShipmentPackagesListResponse, N11SplitPackageResponse, N11CollectionRequestResponse } from "../types/orders.js";
4
+ import type { WireRow } from "../types.js";
5
+ export declare function attachRaw<T extends Record<string, unknown>>(row: T): WireRow<T>;
6
+ export declare function normalizeCategoryTree(data: unknown): {
7
+ categories: WireRow<Record<string, unknown>>[];
8
+ raw: Record<string, unknown>;
9
+ };
10
+ export declare function normalizeCategoryAttributes(data: unknown): N11CategoryAttributesResponse;
11
+ export declare function normalizeTaskSubmitResponse(data: unknown): N11TaskSubmitResponse;
12
+ export declare function normalizeTaskStatusPayload(data: unknown): TaskStatusPayload;
13
+ export declare function normalizeShipmentPackagesResponse(data: unknown): N11ShipmentPackagesListResponse;
14
+ export declare function normalizeOrderUpdateResponse(data: unknown): N11OrderUpdateResponse;
15
+ export declare function normalizeLaborCostUpdateResponse(data: unknown): N11LaborCostUpdateResponse;
16
+ export declare function normalizeSplitPackageResponse(data: unknown): N11SplitPackageResponse;
17
+ export declare function normalizeCollectionRequestResponse(data: unknown): N11CollectionRequestResponse;
18
+ export declare function computeShipmentPackagesHasMore(response: N11ShipmentPackagesListResponse, page: number, pageSize: number): boolean;
19
+ export declare function normalizeProductQueryResponse(data: unknown): N11ProductQueryResponse;
20
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/wire/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,E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wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,uBAAuB,CAqBpF"}
@@ -0,0 +1,158 @@
1
+ export function attachRaw(row) {
2
+ return { ...row, raw: { ...row } };
3
+ }
4
+ export function normalizeCategoryTree(data) {
5
+ if (!data || typeof data !== "object") {
6
+ return { categories: [], raw: {} };
7
+ }
8
+ const record = data;
9
+ const root = record.categories ?? record.categoryList ?? record;
10
+ const list = Array.isArray(root) ? root : [];
11
+ return {
12
+ categories: list.map((item) => attachRaw(item && typeof item === "object" ? item : {})),
13
+ raw: record,
14
+ };
15
+ }
16
+ export function normalizeCategoryAttributes(data) {
17
+ if (!data || typeof data !== "object") {
18
+ return { categoryAttributes: [], raw: {} };
19
+ }
20
+ const record = data;
21
+ const attributes = record.categoryAttributes ?? record.attributes ?? [];
22
+ const list = Array.isArray(attributes) ? attributes : [];
23
+ return {
24
+ id: typeof record.id === "number" ? record.id : undefined,
25
+ name: typeof record.name === "string" ? record.name : undefined,
26
+ categoryAttributes: list.map((item) => attachRaw(item && typeof item === "object" ? item : {})),
27
+ raw: record,
28
+ };
29
+ }
30
+ export function normalizeTaskSubmitResponse(data) {
31
+ const record = data && typeof data === "object" ? data : {};
32
+ const id = record.id ?? record.taskId;
33
+ return {
34
+ id: id != null ? String(id) : "",
35
+ type: typeof record.type === "string" ? record.type : "",
36
+ status: typeof record.status === "string" ? record.status : "",
37
+ reasons: Array.isArray(record.reasons)
38
+ ? record.reasons.filter((r) => typeof r === "string")
39
+ : undefined,
40
+ raw: record,
41
+ };
42
+ }
43
+ function extractTaskSkuRows(data) {
44
+ const skus = data.skus;
45
+ if (!skus || typeof skus !== "object") {
46
+ return [];
47
+ }
48
+ const content = skus.content;
49
+ if (!Array.isArray(content)) {
50
+ return [];
51
+ }
52
+ return content.map((item) => attachRaw(item && typeof item === "object" ? item : {}));
53
+ }
54
+ export function normalizeTaskStatusPayload(data) {
55
+ const record = data && typeof data === "object" ? data : {};
56
+ const rows = extractTaskSkuRows(record);
57
+ const failedRows = rows.filter((row) => String(row.status ?? "").toUpperCase() === "FAIL");
58
+ const errors = failedRows.flatMap((row) => {
59
+ const reasons = row.reasons;
60
+ if (Array.isArray(reasons)) {
61
+ return reasons;
62
+ }
63
+ return [];
64
+ });
65
+ return {
66
+ status: typeof record.status === "string" ? record.status : "",
67
+ failedItemCount: failedRows.length > 0 ? failedRows.length : undefined,
68
+ errors: errors.length > 0 ? errors : undefined,
69
+ rows: rows.length > 0 ? rows : undefined,
70
+ raw: record,
71
+ };
72
+ }
73
+ export function normalizeShipmentPackagesResponse(data) {
74
+ if (!data || typeof data !== "object") {
75
+ return { content: [], raw: {} };
76
+ }
77
+ const record = data;
78
+ const content = record.content;
79
+ const list = Array.isArray(content) ? content : [];
80
+ return {
81
+ content: list.map((item) => attachRaw(item && typeof item === "object" ? item : {})),
82
+ page: typeof record.page === "number" ? record.page : undefined,
83
+ size: typeof record.size === "number" ? record.size : undefined,
84
+ totalPages: typeof record.totalPages === "number" ? record.totalPages : undefined,
85
+ pageCount: typeof record.pageCount === "number" ? record.pageCount : undefined,
86
+ raw: record,
87
+ };
88
+ }
89
+ function normalizeLineContentRows(data) {
90
+ if (!data || typeof data !== "object") {
91
+ return [];
92
+ }
93
+ const record = data;
94
+ const content = record.content;
95
+ if (!Array.isArray(content)) {
96
+ return [];
97
+ }
98
+ return content.map((item) => attachRaw(item && typeof item === "object" ? item : {}));
99
+ }
100
+ export function normalizeOrderUpdateResponse(data) {
101
+ const record = data && typeof data === "object" ? data : {};
102
+ return {
103
+ content: normalizeLineContentRows(data),
104
+ raw: record,
105
+ };
106
+ }
107
+ export function normalizeLaborCostUpdateResponse(data) {
108
+ const record = data && typeof data === "object" ? data : {};
109
+ return {
110
+ content: normalizeLineContentRows(data),
111
+ raw: record,
112
+ };
113
+ }
114
+ export function normalizeSplitPackageResponse(data) {
115
+ const record = data && typeof data === "object" ? data : {};
116
+ const items = record.splitPackageOrderItems;
117
+ const list = Array.isArray(items) ? items : [];
118
+ return {
119
+ code: typeof record.code === "number" ? record.code : undefined,
120
+ message: typeof record.message === "string" ? record.message : undefined,
121
+ splitPackageOrderItems: list.map((item) => attachRaw(item && typeof item === "object" ? item : {})),
122
+ raw: record,
123
+ };
124
+ }
125
+ export function normalizeCollectionRequestResponse(data) {
126
+ const record = data && typeof data === "object" ? data : {};
127
+ return {
128
+ code: typeof record.code === "number" ? record.code : undefined,
129
+ message: typeof record.message === "string" ? record.message : undefined,
130
+ raw: record,
131
+ };
132
+ }
133
+ export function computeShipmentPackagesHasMore(response, page, pageSize) {
134
+ if (response.content.length === 0) {
135
+ return false;
136
+ }
137
+ if (typeof response.totalPages === "number") {
138
+ return page + 1 < response.totalPages;
139
+ }
140
+ return response.content.length >= pageSize;
141
+ }
142
+ export function normalizeProductQueryResponse(data) {
143
+ if (!data || typeof data !== "object") {
144
+ return { content: [], raw: {} };
145
+ }
146
+ const record = data;
147
+ const content = record.content;
148
+ const list = Array.isArray(content) ? content : [];
149
+ return {
150
+ content: list.map((item) => attachRaw(item && typeof item === "object" ? item : {})),
151
+ totalElements: typeof record.totalElements === "number" ? record.totalElements : undefined,
152
+ totalPages: typeof record.totalPages === "number" ? record.totalPages : undefined,
153
+ number: typeof record.number === "number" ? record.number : undefined,
154
+ numberOfElements: typeof record.numberOfElements === "number" ? record.numberOfElements : undefined,
155
+ size: typeof record.size === "number" ? record.size : undefined,
156
+ raw: record,
157
+ };
158
+ }
@@ -0,0 +1,6 @@
1
+ import type { N11Result } from "../types.js";
2
+ export declare function validateBatchSize(count: number, max?: number): N11Result<void>;
3
+ export declare function validateProductQueryPageSize(size: number): N11Result<void>;
4
+ export declare function validateShipmentPackagesPageSize(size: number): N11Result<void>;
5
+ export declare function validatePrices(listPrice: number, salePrice: number): N11Result<void>;
6
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/wire/validate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,GAAG,SAA4B,GAC9B,SAAS,CAAC,IAAI,CAAC,CAYjB;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAY1E;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAY9E;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,IAAI,CAAC,CAYjB"}
@@ -0,0 +1,53 @@
1
+ import { N11_PRODUCT_QUERY_MAX_SIZE, N11_PRODUCT_TASK_MAX_SKUS, N11_SHIPMENT_PACKAGES_MAX_SIZE, } from "../constants/page-limits.js";
2
+ export function validateBatchSize(count, max = N11_PRODUCT_TASK_MAX_SKUS) {
3
+ if (count < 1) {
4
+ return { ok: false, reason: "En az bir SKU gerekli." };
5
+ }
6
+ if (count > max) {
7
+ return {
8
+ ok: false,
9
+ reason: `Batch en fazla ${max} SKU icerir (gonderilen: ${count}).`,
10
+ code: "BATCH_TOO_LARGE",
11
+ };
12
+ }
13
+ return { ok: true, data: undefined };
14
+ }
15
+ export function validateProductQueryPageSize(size) {
16
+ if (size < 1) {
17
+ return { ok: false, reason: "Sayfa boyutu en az 1 olmalidir." };
18
+ }
19
+ if (size > N11_PRODUCT_QUERY_MAX_SIZE) {
20
+ return {
21
+ ok: false,
22
+ reason: `product-query size en fazla ${N11_PRODUCT_QUERY_MAX_SIZE} olabilir.`,
23
+ code: "PAGE_SIZE_TOO_LARGE",
24
+ };
25
+ }
26
+ return { ok: true, data: undefined };
27
+ }
28
+ export function validateShipmentPackagesPageSize(size) {
29
+ if (size < 1) {
30
+ return { ok: false, reason: "Sayfa boyutu en az 1 olmalidir." };
31
+ }
32
+ if (size > N11_SHIPMENT_PACKAGES_MAX_SIZE) {
33
+ return {
34
+ ok: false,
35
+ reason: `shipmentPackages size en fazla ${N11_SHIPMENT_PACKAGES_MAX_SIZE} olabilir.`,
36
+ code: "PAGE_SIZE_TOO_LARGE",
37
+ };
38
+ }
39
+ return { ok: true, data: undefined };
40
+ }
41
+ export function validatePrices(listPrice, salePrice) {
42
+ if (!Number.isFinite(listPrice) || !Number.isFinite(salePrice)) {
43
+ return { ok: false, reason: "listPrice ve salePrice gecerli sayi olmalidir." };
44
+ }
45
+ if (listPrice < salePrice) {
46
+ return {
47
+ ok: false,
48
+ reason: "listPrice, salePrice degerinden kucuk olamaz.",
49
+ code: "INVALID_PRICE_PAIR",
50
+ };
51
+ }
52
+ return { ok: true, data: undefined };
53
+ }
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@hubcommerce/n11",
3
+ "version": "1.0.0",
4
+ "description": "n11 TR Marketplace API SDK — REST + SOAP, task poll, poll-primary orders",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./testing": {
14
+ "types": "./dist/testing/index.d.ts",
15
+ "import": "./dist/testing/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "CHANGELOG.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsc -p tsconfig.json",
26
+ "test": "node --import tsx --test tests/**/*.test.ts",
27
+ "test:exports": "node --import tsx scripts/verify-exports.ts",
28
+ "check:deps": "node --import tsx scripts/check-deps.ts",
29
+ "check:snapshot-drift": "node --import tsx scripts/check-snapshot-drift.ts",
30
+ "snapshot": "node --import tsx scripts/snapshot-endpoints.ts",
31
+ "qa:smoke": "node --import tsx scripts/qa-smoke.ts",
32
+ "verify:release": "node --import tsx ../../scripts/verify-release.ts",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "keywords": [
36
+ "n11",
37
+ "marketplace",
38
+ "ecommerce",
39
+ "turkey"
40
+ ],
41
+ "license": "MIT",
42
+ "devDependencies": {
43
+ "@types/node": "^24.3.0",
44
+ "tsx": "^4.23.12",
45
+ "typescript": "^5.9.2"
46
+ },
47
+ "engines": {
48
+ "node": ">=20.10.0"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ }
53
+ }