@spscommerce/asst-api 0.0.1-beta.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.
@@ -0,0 +1,125 @@
1
+ import { A as AsstClient, V as VendorPartnerAttGroups, a as AttrProdType, T as TradingPartnerAccessByCompanyId } from './TradingPartnerAccessByCompanyId-479e3e57.js';
2
+ export { b as AsstClientOptions, c as AsstUrl, B as BASE_URLS, E as Env } from './TradingPartnerAccessByCompanyId-479e3e57.js';
3
+ import { I as Import, a as ImportsStatus, E as Export, b as ItemCategoriesSearch } from './ItemCategoriesSearch-1bb945de.js';
4
+ export { c as ImportErrors } from './ItemCategoriesSearch-1bb945de.js';
5
+ import { z } from 'zod';
6
+ export { E as ExportDayOfWeek, c as ExportFrequency, d as ExportType, I as ImportDetails, a as ImportError, b as ImportStatusEnum, e as ItemCategory } from './ItemCategory-768179bd.js';
7
+ import 'ky-universal';
8
+ import 'ky';
9
+
10
+ declare const generateImportTemplateParamsSchema: z.ZodObject<{
11
+ "multi-sheet": z.ZodBoolean;
12
+ gids: z.ZodOptional<z.ZodString>;
13
+ productTypeIds: z.ZodOptional<z.ZodString>;
14
+ groupTypeId: z.ZodOptional<z.ZodNumber>;
15
+ includeGuides: z.ZodOptional<z.ZodBoolean>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ "multi-sheet": boolean;
18
+ gids?: string | undefined;
19
+ productTypeIds?: string | undefined;
20
+ groupTypeId?: number | undefined;
21
+ includeGuides?: boolean | undefined;
22
+ }, {
23
+ "multi-sheet": boolean;
24
+ gids?: string | undefined;
25
+ productTypeIds?: string | undefined;
26
+ groupTypeId?: number | undefined;
27
+ includeGuides?: boolean | undefined;
28
+ }>;
29
+ type GenerateImportTemplateParams = z.infer<typeof generateImportTemplateParamsSchema>;
30
+
31
+ /**
32
+ * Initialize Imports Api functions
33
+ * @param client Assortment Client instance
34
+ * @returns An object containing Imports API functions
35
+ */
36
+ declare function createImportsApi(client: AsstClient): {
37
+ getImportErrors: (importId: number, params?: {
38
+ offset?: number;
39
+ limit?: number;
40
+ }, signal?: AbortSignal) => Promise<{
41
+ importId: number;
42
+ count: number;
43
+ errors: {
44
+ attribute: string;
45
+ description: string;
46
+ importErrorId: number;
47
+ row: number;
48
+ }[];
49
+ hasNext: boolean;
50
+ totalCount: number;
51
+ }>;
52
+ getImports: (params?: {
53
+ status: string;
54
+ }, signal?: AbortSignal) => Promise<Import>;
55
+ getImportsStatus: (signal?: AbortSignal) => Promise<ImportsStatus[]>;
56
+ uploadImport: (file: FormData) => Promise<void>;
57
+ getVendorPartnerGroups: (signal?: AbortSignal) => Promise<VendorPartnerAttGroups[]>;
58
+ generateImportTemplate: (params: GenerateImportTemplateParams) => Promise<void>;
59
+ };
60
+
61
+ /**
62
+ * Initialize Exports Api functions
63
+ * @param client Assortment Client instance
64
+ * @returns An object containing Exports API functions
65
+ */
66
+ declare function createExportsApi(client: AsstClient): {
67
+ createExport: (data: Export) => Promise<void>;
68
+ };
69
+
70
+ /**
71
+ * Initialize Product Types Api functions
72
+ * @param client Assortment Client instance
73
+ * @returns An object containing Product Types API functions
74
+ */
75
+ declare function createProductTypesApi(client: AsstClient): {
76
+ getProductTypes: (params?: {
77
+ retailerIds: number[];
78
+ }, signal?: AbortSignal) => Promise<AttrProdType[]>;
79
+ };
80
+
81
+ declare const connectionSchema: z.ZodObject<{
82
+ catalog_id: z.ZodNumber;
83
+ catalog_name: z.ZodString;
84
+ partner_company_name: z.ZodString;
85
+ partner_company_id: z.ZodNumber;
86
+ }, "strip", z.ZodTypeAny, {
87
+ catalog_id: number;
88
+ catalog_name: string;
89
+ partner_company_name: string;
90
+ partner_company_id: number;
91
+ }, {
92
+ catalog_id: number;
93
+ catalog_name: string;
94
+ partner_company_name: string;
95
+ partner_company_id: number;
96
+ }>;
97
+ type Connection = z.infer<typeof connectionSchema>;
98
+
99
+ /**
100
+ * Initialize Trading Partner Access Api functions
101
+ * @param client Assortment Client instance
102
+ * @returns An object containing Trading Partner Access API functions
103
+ */
104
+ declare function createTradingPartnerAccessApi(client: AsstClient): {
105
+ getAllTradingPartners: (signal?: AbortSignal) => Promise<TradingPartnerAccessByCompanyId>;
106
+ };
107
+
108
+ /**
109
+ * Initialize Categories Api functions
110
+ * @param client Assortment Client instance
111
+ * @returns An object containing Categories API functions
112
+ */
113
+ declare function createCategoriesApi(client: AsstClient): {
114
+ getCatalogs: (params?: {
115
+ categoryName?: string;
116
+ }, signal?: AbortSignal) => Promise<ItemCategoriesSearch>;
117
+ getProductCodes: (params?: {
118
+ categoryName?: string;
119
+ }, signal?: AbortSignal) => Promise<ItemCategoriesSearch>;
120
+ getSelectionCodes: (params?: {
121
+ categoryName?: string;
122
+ }, signal?: AbortSignal) => Promise<ItemCategoriesSearch>;
123
+ };
124
+
125
+ export { AsstClient, AttrProdType, Connection, Export, GenerateImportTemplateParams, Import, ImportsStatus, ItemCategoriesSearch, TradingPartnerAccessByCompanyId, VendorPartnerAttGroups, createCategoriesApi, createExportsApi, createImportsApi, createProductTypesApi, createTradingPartnerAccessApi };
package/dist/index.js ADDED
@@ -0,0 +1,69 @@
1
+ import {
2
+ createCategoriesApi,
3
+ createExportsApi,
4
+ createImportsApi,
5
+ createProductTypesApi,
6
+ createTradingPartnerAccessApi
7
+ } from "./chunk-RNUSCCKB.js";
8
+ import "./chunk-D3ML6E4G.js";
9
+
10
+ // lib/asstClient.ts
11
+ import ky from "ky-universal";
12
+ var BASE_URLS = {
13
+ local: "https://localhost:8443",
14
+ test: "https://integration.api.spscommerce.com/assortment/gateway",
15
+ prod: "https://api.spscommerce.com/assortment/gateway"
16
+ };
17
+ var AsstClient = class {
18
+ #client = ky.create({
19
+ prefixUrl: BASE_URLS["test"],
20
+ retry: 0
21
+ });
22
+ #baseUrl = BASE_URLS["test"];
23
+ #subscriptionCallback;
24
+ constructor(options) {
25
+ this.updateConfig(options);
26
+ }
27
+ updateConfig(options) {
28
+ this.#client = this.#client.extend(options);
29
+ if (options.prefixUrl) {
30
+ this.#baseUrl = options.prefixUrl;
31
+ }
32
+ if (this.#subscriptionCallback) {
33
+ this.#subscriptionCallback(options);
34
+ }
35
+ }
36
+ getBaseUrl() {
37
+ return this.#baseUrl;
38
+ }
39
+ subscribeToConfigChange(subscriptionCallback) {
40
+ this.#subscriptionCallback = subscriptionCallback;
41
+ }
42
+ get(url, options) {
43
+ return this.#client.get(url, options);
44
+ }
45
+ post(url, options) {
46
+ return this.#client.post(url, options);
47
+ }
48
+ put(url, options) {
49
+ return this.#client.put(url, options);
50
+ }
51
+ patch(url, options) {
52
+ return this.#client.patch(url, options);
53
+ }
54
+ head(url, options) {
55
+ return this.#client.head(url, options);
56
+ }
57
+ delete(url, options) {
58
+ return this.#client.delete(url, options);
59
+ }
60
+ };
61
+ export {
62
+ AsstClient,
63
+ BASE_URLS,
64
+ createCategoriesApi,
65
+ createExportsApi,
66
+ createImportsApi,
67
+ createProductTypesApi,
68
+ createTradingPartnerAccessApi
69
+ };