@dianemo/plugin-newegg 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 (80) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +59 -0
  4. package/dist/client.d.ts +16 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +92 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/index.d.ts +12 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +26 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/requests/feeds/index.d.ts +4 -0
  13. package/dist/requests/feeds/index.d.ts.map +1 -0
  14. package/dist/requests/feeds/index.js +49 -0
  15. package/dist/requests/feeds/index.js.map +1 -0
  16. package/dist/requests/feeds/types.d.ts +43 -0
  17. package/dist/requests/feeds/types.d.ts.map +1 -0
  18. package/dist/requests/feeds/types.js +2 -0
  19. package/dist/requests/feeds/types.js.map +1 -0
  20. package/dist/requests/index.d.ts +6 -0
  21. package/dist/requests/index.d.ts.map +1 -0
  22. package/dist/requests/index.js +6 -0
  23. package/dist/requests/index.js.map +1 -0
  24. package/dist/requests/inventory/index.d.ts +10 -0
  25. package/dist/requests/inventory/index.d.ts.map +1 -0
  26. package/dist/requests/inventory/index.js +55 -0
  27. package/dist/requests/inventory/index.js.map +1 -0
  28. package/dist/requests/inventory/types.d.ts +70 -0
  29. package/dist/requests/inventory/types.d.ts.map +1 -0
  30. package/dist/requests/inventory/types.js +2 -0
  31. package/dist/requests/inventory/types.js.map +1 -0
  32. package/dist/requests/orders/index.d.ts +10 -0
  33. package/dist/requests/orders/index.d.ts.map +1 -0
  34. package/dist/requests/orders/index.js +59 -0
  35. package/dist/requests/orders/index.js.map +1 -0
  36. package/dist/requests/orders/types.d.ts +241 -0
  37. package/dist/requests/orders/types.d.ts.map +1 -0
  38. package/dist/requests/orders/types.js +40 -0
  39. package/dist/requests/orders/types.js.map +1 -0
  40. package/dist/requests/pricing/index.d.ts +5 -0
  41. package/dist/requests/pricing/index.d.ts.map +1 -0
  42. package/dist/requests/pricing/index.js +40 -0
  43. package/dist/requests/pricing/index.js.map +1 -0
  44. package/dist/requests/pricing/types.d.ts +80 -0
  45. package/dist/requests/pricing/types.d.ts.map +1 -0
  46. package/dist/requests/pricing/types.js +11 -0
  47. package/dist/requests/pricing/types.js.map +1 -0
  48. package/dist/requests/returns/index.d.ts +3 -0
  49. package/dist/requests/returns/index.d.ts.map +1 -0
  50. package/dist/requests/returns/index.js +18 -0
  51. package/dist/requests/returns/index.js.map +1 -0
  52. package/dist/requests/returns/types.d.ts +93 -0
  53. package/dist/requests/returns/types.d.ts.map +1 -0
  54. package/dist/requests/returns/types.js +2 -0
  55. package/dist/requests/returns/types.js.map +1 -0
  56. package/dist/requests/types.d.ts +32 -0
  57. package/dist/requests/types.d.ts.map +1 -0
  58. package/dist/requests/types.js +26 -0
  59. package/dist/requests/types.js.map +1 -0
  60. package/dist/requests/utils.d.ts +22 -0
  61. package/dist/requests/utils.d.ts.map +1 -0
  62. package/dist/requests/utils.js +26 -0
  63. package/dist/requests/utils.js.map +1 -0
  64. package/docs/newegg-api.md +155 -0
  65. package/package.json +128 -0
  66. package/src/client.ts +120 -0
  67. package/src/index.ts +34 -0
  68. package/src/requests/feeds/index.ts +70 -0
  69. package/src/requests/feeds/types.ts +56 -0
  70. package/src/requests/index.ts +5 -0
  71. package/src/requests/inventory/index.ts +94 -0
  72. package/src/requests/inventory/types.ts +83 -0
  73. package/src/requests/orders/index.ts +94 -0
  74. package/src/requests/orders/types.ts +284 -0
  75. package/src/requests/pricing/index.ts +70 -0
  76. package/src/requests/pricing/types.ts +95 -0
  77. package/src/requests/returns/index.ts +30 -0
  78. package/src/requests/returns/types.ts +113 -0
  79. package/src/requests/types.ts +36 -0
  80. package/src/requests/utils.ts +26 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ @dianemo/plugin-newegg
2
+ Copyright 2026 Aaron Leman
3
+
4
+ This product includes software developed at vivo-us
5
+ (https://github.com/vivo-us/dianemo-plugins).
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @dianemo/plugin-newegg
2
+
3
+ Newegg plugin — Newegg and Newegg Business marketplaces
4
+
5
+ A plugin for [dianemo](https://github.com/vivo-us/dianemo), which distributes one API rate limit
6
+ across every process that draws on it.
7
+
8
+ ```bash
9
+ npm install @dianemo/core @dianemo/backend-redis @dianemo/plugin-newegg ioredis
10
+ ```
11
+
12
+ ## Setup
13
+
14
+ ```ts
15
+ import RequestHandler, { buildClientName } from "@dianemo/core";
16
+ import { redisBackend } from "@dianemo/backend-redis";
17
+ import newegg from "@dianemo/plugin-newegg";
18
+ import { Redis } from "ioredis";
19
+
20
+ const handler = new RequestHandler({
21
+ key: process.env.DIANEMO_KEY!,
22
+ backend: redisBackend(new Redis(process.env.REDIS_URL!)),
23
+ });
24
+
25
+ export const requests = handler.use(newegg);
26
+
27
+ // Credentials are encrypted into the backend, so every process pointed at this
28
+ // Redis rebuilds the same client and draws on one shared budget.
29
+ await handler.addTemplateClient("newegg", {
30
+ instanceId: "main",
31
+ baseUrl: "https://api.newegg.com/marketplace",
32
+ token: process.env.NEWEGG_TOKEN!,
33
+ secretKey: process.env.NEWEGG_SECRET_KEY!,
34
+ sellerId: process.env.NEWEGG_SELLER_ID!,
35
+ });
36
+
37
+ // "newegg:_:main" — <template>:<organizationId | "_">:<instanceId>
38
+ const account = buildClientName("newegg", { instanceId: "main" });
39
+
40
+ const orders = await requests.newegg.getOrders(account, {
41
+ RequestCriteria: { OrderDownloaded: 0 },
42
+ });
43
+ ```
44
+
45
+ Newegg Business is a second template — register it as `neweggBusiness` with `baseUrl: "https://api.newegg.com/marketplace/b2b"`, build its name the same way, and pass that name instead. The two marketplaces are metered separately.
46
+
47
+ Register another account by calling `addTemplateClient` again with a different `instanceId`. Pass
48
+ `organizationId` alongside it in a multi-tenant deployment: it becomes the second segment of the
49
+ client name, keeping each tenant's credentials and budget separate.
50
+
51
+ **API notes.** The rate-limit evidence behind this package's calibration, the wire quirks
52
+ it works around, and the questions still open are in
53
+ [`docs/newegg-api.md`](docs/newegg-api.md) — it ships with the package.
54
+
55
+ See [dianemo-plugins](https://github.com/vivo-us/dianemo-plugins) for the full catalogue.
56
+
57
+ ## License
58
+
59
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
@@ -0,0 +1,16 @@
1
+ import { TokenCredentials } from "@dianemo/core/client/types";
2
+ import RequestHandler from "@dianemo/core";
3
+ interface NeweggCredentials extends TokenCredentials {
4
+ secretKey: string;
5
+ sellerId: string;
6
+ }
7
+ declare module "@dianemo/core" {
8
+ interface ClientTemplates {
9
+ newegg: NeweggCredentials;
10
+ neweggBusiness: NeweggCredentials;
11
+ }
12
+ }
13
+ export declare function registerNeweggTemplate(handler: RequestHandler): Promise<void>;
14
+ export declare function registerNeweggBusinessTemplate(handler: RequestHandler): Promise<void>;
15
+ export {};
16
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,cAAmC,MAAM,eAAe,CAAC;AAEhE,UAAU,iBAAkB,SAAQ,gBAAgB;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,OAAO,QAAQ,eAAe,CAAC;IAC7B,UAAU,eAAe;QACvB,MAAM,EAAE,iBAAiB,CAAC;QAC1B,cAAc,EAAE,iBAAiB,CAAC;KACnC;CACF;AA0FD,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,cAAc,iBAOnE;AAED,wBAAsB,8BAA8B,CAAC,OAAO,EAAE,cAAc,iBAO3E"}
package/dist/client.js ADDED
@@ -0,0 +1,92 @@
1
+ import { buildClientName } from "@dianemo/core";
2
+ const tenThousandPerHourEndpoints = [
3
+ "getItemInventory",
4
+ "updateItemInventory",
5
+ "getItemPricing",
6
+ "updateItemPricing",
7
+ "getFeedStatus",
8
+ ];
9
+ const oneThousandPerHourEndpoints = [
10
+ "getOrders",
11
+ "markOrderDownloaded",
12
+ "shipOrder",
13
+ "getRmaInfo",
14
+ ];
15
+ const tenPerMinuteEndpoints = ["submitFeed"];
16
+ /**
17
+ * **Every figure below is this repo's own ceiling, not Newegg's.** Newegg
18
+ * documents that non-datafeed functions are metered per minute and datafeed
19
+ * functions per hour, but publishes no numbers for either — and returns the real
20
+ * per-function limit in `X-RateLimit-Limit` on every response, which is how they
21
+ * could be replaced with vendor-stated ones. The hourly buckets here are also
22
+ * drip-fed rather than burstable, which is safe against a per-minute limit but is
23
+ * not the shape of the limit: docs/newegg-api.md#rate-limits-the-mechanism-is-documented-the-numbers-are-not
24
+ */
25
+ const getSubClients = () => {
26
+ const subClients = [];
27
+ for (const endpoint of tenThousandPerHourEndpoints) {
28
+ subClients.push({
29
+ name: endpoint,
30
+ rateLimit: {
31
+ type: "requestLimit",
32
+ interval: 360,
33
+ tokensToAdd: 1,
34
+ maxTokens: 10000,
35
+ },
36
+ });
37
+ }
38
+ for (const endpoint of oneThousandPerHourEndpoints) {
39
+ subClients.push({
40
+ name: endpoint,
41
+ rateLimit: {
42
+ type: "requestLimit",
43
+ interval: 3600,
44
+ tokensToAdd: 1,
45
+ maxTokens: 1000,
46
+ },
47
+ });
48
+ }
49
+ for (const endpoint of tenPerMinuteEndpoints) {
50
+ subClients.push({
51
+ name: endpoint,
52
+ rateLimit: {
53
+ type: "requestLimit",
54
+ interval: 6000,
55
+ tokensToAdd: 1,
56
+ maxTokens: 10,
57
+ },
58
+ });
59
+ }
60
+ return subClients;
61
+ };
62
+ const buildNeweggClient = (name, creds) => ({
63
+ name,
64
+ authentication: {
65
+ type: "token",
66
+ excludePrefix: true,
67
+ token: creds.token,
68
+ },
69
+ requestOptions: {
70
+ defaults: {
71
+ baseURL: creds.baseUrl,
72
+ headers: {
73
+ "Content-Type": "application/json",
74
+ Accept: "application/json",
75
+ SecretKey: creds.secretKey,
76
+ },
77
+ params: { sellerid: creds.sellerId },
78
+ },
79
+ },
80
+ subClients: getSubClients(),
81
+ });
82
+ export async function registerNeweggTemplate(handler) {
83
+ await handler.registerClientTemplate("newegg", (creds) => [
84
+ buildNeweggClient(buildClientName("newegg", creds), creds),
85
+ ]);
86
+ }
87
+ export async function registerNeweggBusinessTemplate(handler) {
88
+ await handler.registerClientTemplate("neweggBusiness", (creds) => [
89
+ buildNeweggClient(buildClientName("neweggBusiness", creds), creds),
90
+ ]);
91
+ }
92
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAuB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAchE,MAAM,2BAA2B,GAAG;IAClC,kBAAkB;IAClB,qBAAqB;IACrB,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;CAChB,CAAC;AAEF,MAAM,2BAA2B,GAAG;IAClC,WAAW;IACX,qBAAqB;IACrB,WAAW;IACX,YAAY;CACb,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,YAAY,CAAC,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,GAAuB,EAAE;IAC7C,MAAM,UAAU,GAAuB,EAAE,CAAC;IAC1C,KAAK,MAAM,QAAQ,IAAI,2BAA2B,EAAE,CAAC;QACnD,UAAU,CAAC,IAAI,CAAC;YACd,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE;gBACT,IAAI,EAAE,cAAc;gBACpB,QAAQ,EAAE,GAAG;gBACb,WAAW,EAAE,CAAC;gBACd,SAAS,EAAE,KAAK;aACjB;SACF,CAAC,CAAC;IACL,CAAC;IACD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CAAC,EAAE,KAAK,CAAC;KAC3D,CACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,OAAuB;IAC1E,MAAM,OAAO,CAAC,sBAAsB,CAClC,gBAAgB,EAChB,CAAC,KAAK,EAAsB,EAAE,CAAC;QAC7B,iBAAiB,CAAC,eAAe,CAAC,gBAAgB,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC;KACnE,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as requests from "./requests/index.js";
2
+ declare const _default: import("@dianemo/core").RequestHandlerPlugin<"newegg", typeof requests>;
3
+ export default _default;
4
+ export { registerNeweggTemplate, registerNeweggBusinessTemplate, } from "./client.js";
5
+ export * from "./requests/index.js";
6
+ export * from "./requests/feeds/types.js";
7
+ export * from "./requests/inventory/types.js";
8
+ export * from "./requests/orders/types.js";
9
+ export * from "./requests/pricing/types.js";
10
+ export * from "./requests/returns/types.js";
11
+ export * from "./requests/types.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;;AAShD,wBAUG;AAEH,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,cAAc,qBAAqB,CAAC;AAEpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import { bindTryHandleRequest } from "@dianemo/plugin-kit";
2
+ import * as requests from "./requests/index.js";
3
+ import { definePlugin } from "@dianemo/core";
4
+ import { registerNeweggTemplate, registerNeweggBusinessTemplate, } from "./client.js";
5
+ // Two templates, one API surface: the consumer and business marketplaces
6
+ // take separate credentials but share every request function.
7
+ export default definePlugin({
8
+ name: "newegg",
9
+ registerTemplate: async (handler) => {
10
+ await registerNeweggTemplate(handler);
11
+ await registerNeweggBusinessTemplate(handler);
12
+ },
13
+ createRequests: (ctx) => {
14
+ bindTryHandleRequest(ctx);
15
+ return requests;
16
+ },
17
+ });
18
+ export { registerNeweggTemplate, registerNeweggBusinessTemplate, } from "./client.js";
19
+ export * from "./requests/index.js";
20
+ export * from "./requests/feeds/types.js";
21
+ export * from "./requests/inventory/types.js";
22
+ export * from "./requests/orders/types.js";
23
+ export * from "./requests/pricing/types.js";
24
+ export * from "./requests/returns/types.js";
25
+ export * from "./requests/types.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,yEAAyE;AACzE,8DAA8D;AAC9D,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,QAAQ;IACd,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAClC,MAAM,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,8BAA8B,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE;QACtB,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC,CAAC;AAEH,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,cAAc,qBAAqB,CAAC;AAEpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { NeweggFeedResponse } from "./types.js";
2
+ export declare const getFeedStatus: (clientName: string, feedId: string) => Promise<NeweggFeedResponse>;
3
+ export declare const submitFeed: (clientName: string, requestType: string, data: object) => Promise<NeweggFeedResponse>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/requests/feeds/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAGnB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,aAAa,GACxB,YAAY,MAAM,EAClB,QAAQ,MAAM,KACb,OAAO,CAAC,kBAAkB,CA4B5B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,YAAY,MAAM,EAClB,aAAa,MAAM,EACnB,MAAM,MAAM,KACX,OAAO,CAAC,kBAAkB,CAuB5B,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { neweggSubClient, neweggSucceeded } from "../utils.js";
2
+ import { tryHandleRequest } from "@dianemo/plugin-kit";
3
+ import { RequestError } from "@dianemo/core";
4
+ export const getFeedStatus = async (clientName, feedId) => {
5
+ const data = {
6
+ OperationType: "GetFeedStatusRequest",
7
+ RequestBody: {
8
+ GetRequestStatus: { RequestIDList: [{ RequestID: feedId }] },
9
+ },
10
+ };
11
+ const res = await tryHandleRequest({
12
+ clientName: neweggSubClient(clientName, "getFeedStatus"),
13
+ requestName: "newegg.feeds.getStatus",
14
+ url: `/datafeedmgmt/feeds/status`,
15
+ method: "PUT",
16
+ data,
17
+ }, "NWG_0007", "Failed to get Newegg feed status");
18
+ const resData = res.data;
19
+ const feedData = resData.ResponseBody.ResponseList[0];
20
+ if (!feedData || !neweggSucceeded(resData)) {
21
+ throw new RequestError("NWG_0008", "Newegg feed status request failed", {
22
+ metadata: {
23
+ context: `${feedData?.RequestStatus ?? "No request status"} | MEMO: ${resData.Memo || "N/A"}`,
24
+ },
25
+ });
26
+ }
27
+ return feedData;
28
+ };
29
+ export const submitFeed = async (clientName, requestType, data) => {
30
+ const res = await tryHandleRequest({
31
+ clientName: neweggSubClient(clientName, "submitFeed"),
32
+ requestName: "newegg.feeds.submit",
33
+ url: `/datafeedmgmt/feeds/submitfeed`,
34
+ method: "POST",
35
+ params: { requesttype: requestType },
36
+ data,
37
+ }, "NWG_0005", "Failed to submit Newegg feed");
38
+ const resData = res.data;
39
+ const feedData = resData.ResponseBody.ResponseList[0];
40
+ if (!feedData || !neweggSucceeded(resData)) {
41
+ throw new RequestError("NWG_0006", "Newegg feed submission failed", {
42
+ metadata: {
43
+ context: `${feedData?.RequestStatus ?? "No request status"} | MEMO: ${resData.Memo || "N/A"}`,
44
+ },
45
+ });
46
+ }
47
+ return feedData;
48
+ };
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/requests/feeds/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,UAAkB,EAClB,MAAc,EACe,EAAE;IAC/B,MAAM,IAAI,GAA4B;QACpC,aAAa,EAAE,sBAAsB;QACrC,WAAW,EAAE;YACX,gBAAgB,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE;SAC7D;KACF,CAAC;IACF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAChC;QACE,UAAU,EAAE,eAAe,CAAC,UAA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AClE,QAAQ,EAAE;gBACR,OAAO,EAAE,GAAG,QAAQ,EAAE,aAAa,IAAI,mBAAmB,YAAY,OAAO,CAAC,IAAI,IAAI,KAAK,EAAE;aAC9F;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ export type NeweggFeedType = "ITEM_DATA" | "INVENTORY_AND_PRICE_DATA" | "INVENTORY_DATA" | "PRICE_DATA" | "ITEM_COUNTRY_RESTRICTION_DATA" | "ORDER_SHIP_NOTICE_DATA" | "MULTICHANNEL_ORDER_DATA" | "VOLUME_DISCOUNT_DATA" | "ITEM_WARRANTY_DATA" | "ITEM_CAPROP65_DATA" | "ITEM_CHINATAXSETTING_DATA" | "ITEM_SAFEGUARD_SETTING_DATA" | "VEHICLE_SPECIFIC_ITEM_DATA";
2
+ export type NeweggFeedStatus = "SUBMITTED" | "IN_PROGRESS" | "FINISHED" | "CANCELLED";
3
+ export interface NeweggGetFeedStatusData {
4
+ OperationType: "GetFeedStatusRequest";
5
+ RequestBody: {
6
+ GetRequestStatus: {
7
+ RequestIDList?: {
8
+ RequestID: string;
9
+ }[];
10
+ RequestType?: NeweggFeedType;
11
+ MaxCount?: string;
12
+ RequestStatus?: "ALL" | NeweggFeedStatus;
13
+ RequestDateFrom?: string;
14
+ RequestDateTo?: string;
15
+ };
16
+ };
17
+ }
18
+ export interface NeweggSubmitFeedResponse {
19
+ /**
20
+ * A JSON boolean on this endpoint, per Newegg's published sample. Read it
21
+ * through `neweggSucceeded` rather than comparing directly — the same flag is
22
+ * a string on other Newegg endpoints.
23
+ */
24
+ IsSuccess: boolean;
25
+ OperationType: string;
26
+ SellerID: string;
27
+ ResponseBody: {
28
+ ResponseList: NeweggFeedResponse[];
29
+ };
30
+ Memo?: string;
31
+ }
32
+ export interface NeweggFeedResponse {
33
+ /**
34
+ * `RequestId` here, but `RequestIDList.RequestID` in the request body above:
35
+ * Newegg spells the key differently by direction. Both are as published — not
36
+ * a typo to fix. docs/newegg-api.md#requestid-on-the-way-in-requestid-on-the-way-out
37
+ */
38
+ RequestId: string;
39
+ RequestType: NeweggFeedType;
40
+ RequestDate: string;
41
+ RequestStatus: NeweggFeedStatus;
42
+ }
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/requests/feeds/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,WAAW,GACX,0BAA0B,GAC1B,gBAAgB,GAChB,YAAY,GACZ,+BAA+B,GAC/B,wBAAwB,GACxB,yBAAyB,GACzB,sBAAsB,GACtB,oBAAoB,GACpB,oBAAoB,GACpB,2BAA2B,GAC3B,6BAA6B,GAC7B,4BAA4B,CAAC;AAEjC,MAAM,MAAM,gBAAgB,GAC1B,WAAW,GAAG,aAAa,GAAG,UAAU,GAAG,WAAW,CAAC;AAEzD,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,sBAAsB,CAAC;IACtC,WAAW,EAAE;QACX,gBAAgB,EAAE;YAChB,aAAa,CAAC,EAAE;gBAAE,SAAS,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YACxC,WAAW,CAAC,EAAE,cAAc,CAAC;YAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,aAAa,CAAC,EAAE,KAAK,GAAG,gBAAgB,CAAC;YACzC,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,aAAa,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE;QAAE,YAAY,EAAE,kBAAkB,EAAE,CAAA;KAAE,CAAC;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,gBAAgB,CAAC;CACjC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/requests/feeds/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from "./orders/index.js";
2
+ export * from "./returns/index.js";
3
+ export * from "./inventory/index.js";
4
+ export * from "./pricing/index.js";
5
+ export * from "./feeds/index.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/requests/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./orders/index.js";
2
+ export * from "./returns/index.js";
3
+ export * from "./inventory/index.js";
4
+ export * from "./pricing/index.js";
5
+ export * from "./feeds/index.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/requests/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { NeweggBusinessInventoryResponse, NeweggDetailedItemInventory, NeweggGetInventoryData, NeweggInventoryFeedItemData, NeweggItemInventory, NeweggUpdateItemInventoryResponse } from "./types.js";
2
+ export declare const getItemInventory: (clientName: string, data: NeweggGetInventoryData) => Promise<NeweggDetailedItemInventory[]>;
3
+ /**
4
+ * Deliberately the same `getItemInventory` sub-client: it is the same logical
5
+ * operation against the same published budget, so the two share one bucket.
6
+ */
7
+ export declare const getBusinessItemInventory: (clientName: string, data: NeweggGetInventoryData) => Promise<NeweggBusinessInventoryResponse>;
8
+ export declare const submitInventoryFeed: (clientName: string, inventory: NeweggInventoryFeedItemData[]) => Promise<import("../feeds/types.js").NeweggFeedResponse>;
9
+ export declare const updateItemInventory: (clientName: string, sku: string, inventory: NeweggItemInventory[]) => Promise<NeweggUpdateItemInventoryResponse>;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/requests/inventory/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,sBAAsB,EAEtB,2BAA2B,EAC3B,mBAAmB,EAGnB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,gBAAgB,GAC3B,YAAY,MAAM,EAClB,MAAM,sBAAsB,KAC3B,OAAO,CAAC,2BAA2B,EAAE,CAavC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,YAAY,MAAM,EAClB,MAAM,sBAAsB,KAC3B,OAAO,CAAC,+BAA+B,CAczC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,YAAY,MAAM,EAClB,WAAW,2BAA2B,EAAE,4DAUzC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,YAAY,MAAM,EAClB,KAAK,MAAM,EACX,WAAW,mBAAmB,EAAE,KAC/B,OAAO,CAAC,iCAAiC,CAkB3C,CAAC"}