@spscommerce/asst-api 0.0.1-beta.2 → 0.0.1-beta.4

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,85 @@
1
+ import {
2
+ z
3
+ } from "./chunk-D3ML6E4G.js";
4
+
5
+ // lib/asstClient.ts
6
+ import ky from "ky-universal";
7
+ var baseUrlsSchema = z.object({
8
+ local: z.literal("https://localhost:8443"),
9
+ test: z.literal("https://integration.api.spscommerce.com/assortment/gateway"),
10
+ prod: z.literal("https://api.spscommerce.com/assortment/gateway")
11
+ });
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 envSchema = baseUrlsSchema.keyof();
18
+ var initialConfig = {
19
+ prefixUrl: BASE_URLS["test"],
20
+ retry: 0
21
+ };
22
+ var AsstClient = class {
23
+ #client = ky.create(initialConfig);
24
+ #baseUrl = BASE_URLS["test"];
25
+ #subscriptionCallback;
26
+ #currentConfig = initialConfig;
27
+ constructor(options) {
28
+ console.log(
29
+ `AsstClient created! Config: ${options ? JSON.stringify(options) : "default"}`
30
+ );
31
+ if (options) {
32
+ this.updateConfig(options);
33
+ }
34
+ }
35
+ updateConfig(options) {
36
+ console.log(`Config updated! ${JSON.stringify(options)}`);
37
+ this.#client = this.#client.extend(options);
38
+ this.#currentConfig = options;
39
+ if (options.prefixUrl) {
40
+ this.#baseUrl = options.prefixUrl;
41
+ }
42
+ if (this.#subscriptionCallback) {
43
+ this.#subscriptionCallback(options);
44
+ }
45
+ }
46
+ getBaseUrl() {
47
+ return this.#baseUrl;
48
+ }
49
+ /**
50
+ * Subscribe to config changes. The callback will be immediately invoked with the current config.
51
+ * @param subscriptionCallback Function that will be called with the new config every time it is changed
52
+ */
53
+ subscribeToConfigChange(subscriptionCallback) {
54
+ console.log(`Subscription added`);
55
+ this.#subscriptionCallback = subscriptionCallback;
56
+ subscriptionCallback(this.#currentConfig);
57
+ }
58
+ unsubscribeToConfigChange() {
59
+ this.#subscriptionCallback = void 0;
60
+ }
61
+ get(url, options) {
62
+ return this.#client.get(url, options);
63
+ }
64
+ post(url, options) {
65
+ return this.#client.post(url, options);
66
+ }
67
+ put(url, options) {
68
+ return this.#client.put(url, options);
69
+ }
70
+ patch(url, options) {
71
+ return this.#client.patch(url, options);
72
+ }
73
+ head(url, options) {
74
+ return this.#client.head(url, options);
75
+ }
76
+ delete(url, options) {
77
+ return this.#client.delete(url, options);
78
+ }
79
+ };
80
+
81
+ export {
82
+ BASE_URLS,
83
+ envSchema,
84
+ AsstClient
85
+ };
package/dist/index.cjs CHANGED
@@ -42,55 +42,6 @@ module.exports = __toCommonJS(lib_exports);
42
42
 
43
43
  // lib/asstClient.ts
44
44
  var import_ky_universal = __toESM(require("ky-universal"), 1);
45
- var BASE_URLS = {
46
- local: "https://localhost:8443",
47
- test: "https://integration.api.spscommerce.com/assortment/gateway",
48
- prod: "https://api.spscommerce.com/assortment/gateway"
49
- };
50
- var AsstClient = class {
51
- #client = import_ky_universal.default.create({
52
- prefixUrl: BASE_URLS["test"],
53
- retry: 0
54
- });
55
- #baseUrl = BASE_URLS["test"];
56
- #subscriptionCallback;
57
- constructor(options) {
58
- this.updateConfig(options);
59
- }
60
- updateConfig(options) {
61
- this.#client = this.#client.extend(options);
62
- if (options.prefixUrl) {
63
- this.#baseUrl = options.prefixUrl;
64
- }
65
- if (this.#subscriptionCallback) {
66
- this.#subscriptionCallback(options);
67
- }
68
- }
69
- getBaseUrl() {
70
- return this.#baseUrl;
71
- }
72
- subscribeToConfigChange(subscriptionCallback) {
73
- this.#subscriptionCallback = subscriptionCallback;
74
- }
75
- get(url, options) {
76
- return this.#client.get(url, options);
77
- }
78
- post(url, options) {
79
- return this.#client.post(url, options);
80
- }
81
- put(url, options) {
82
- return this.#client.put(url, options);
83
- }
84
- patch(url, options) {
85
- return this.#client.patch(url, options);
86
- }
87
- head(url, options) {
88
- return this.#client.head(url, options);
89
- }
90
- delete(url, options) {
91
- return this.#client.delete(url, options);
92
- }
93
- };
94
45
 
95
46
  // ../../node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs
96
47
  var util;
@@ -3774,6 +3725,73 @@ var z = /* @__PURE__ */ Object.freeze({
3774
3725
  ZodError
3775
3726
  });
3776
3727
 
3728
+ // lib/asstClient.ts
3729
+ var baseUrlsSchema = z.object({
3730
+ local: z.literal("https://localhost:8443"),
3731
+ test: z.literal("https://integration.api.spscommerce.com/assortment/gateway"),
3732
+ prod: z.literal("https://api.spscommerce.com/assortment/gateway")
3733
+ });
3734
+ var BASE_URLS = {
3735
+ local: "https://localhost:8443",
3736
+ test: "https://integration.api.spscommerce.com/assortment/gateway",
3737
+ prod: "https://api.spscommerce.com/assortment/gateway"
3738
+ };
3739
+ var envSchema = baseUrlsSchema.keyof();
3740
+ var initialConfig = {
3741
+ prefixUrl: BASE_URLS["test"],
3742
+ retry: 0
3743
+ };
3744
+ var AsstClient = class {
3745
+ #client = import_ky_universal.default.create(initialConfig);
3746
+ #baseUrl = BASE_URLS["test"];
3747
+ #listeners = /* @__PURE__ */ new Set();
3748
+ #currentConfig = initialConfig;
3749
+ constructor(options) {
3750
+ if (options) {
3751
+ this.updateConfig(options);
3752
+ }
3753
+ }
3754
+ updateConfig(options) {
3755
+ this.#client = this.#client.extend(options);
3756
+ this.#currentConfig = options;
3757
+ if (options.prefixUrl) {
3758
+ this.#baseUrl = options.prefixUrl;
3759
+ }
3760
+ this.#listeners.forEach((listener) => listener(options));
3761
+ }
3762
+ getBaseUrl() {
3763
+ return this.#baseUrl;
3764
+ }
3765
+ /**
3766
+ * Subscribe to config changes. The callback will be immediately invoked with the current config.
3767
+ * @param subscriptionCallback Function that will be called with the new config every time it is changed
3768
+ * @returns Function to unsubscribe to config changes
3769
+ */
3770
+ subscribeToConfigChange(listener) {
3771
+ this.#listeners.add(listener);
3772
+ listener(this.#currentConfig);
3773
+ return () => this.#listeners.delete(listener);
3774
+ }
3775
+ get(url, options) {
3776
+ return this.#client.get(url, options);
3777
+ }
3778
+ post(url, options) {
3779
+ return this.#client.post(url, options);
3780
+ }
3781
+ put(url, options) {
3782
+ return this.#client.put(url, options);
3783
+ }
3784
+ patch(url, options) {
3785
+ return this.#client.patch(url, options);
3786
+ }
3787
+ head(url, options) {
3788
+ return this.#client.head(url, options);
3789
+ }
3790
+ delete(url, options) {
3791
+ return this.#client.delete(url, options);
3792
+ }
3793
+ };
3794
+
3777
3795
  // lib/imports/models/ImportDetail.ts
3778
3796
  var importDetailSchema = z.object({
3779
3797
  completedAt: z.nullable(z.number()),
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
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';
1
+ import { A as AsstClient, I as Import, a as ImportsStatus, E as Export, b as ItemCategoriesSearch } from './ItemCategoriesSearch-ec43591f.js';
2
+ export { c as AsstClientOptions, d as AsstUrl, B as BASE_URLS, e as Env, f as ImportErrors } from './ItemCategoriesSearch-ec43591f.js';
3
+ import { V as VendorPartnerAttGroups, A as AttrProdType, T as TradingPartnerAccessByCompanyId } from './TradingPartnerAccessByCompanyId-29866586.js';
5
4
  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';
5
+ export { E as ExportDayOfWeek, c as ExportFrequency, d as ExportType, I as ImportDetails, a as ImportError, b as ImportStatusEnum, e as ItemCategory } from './ItemCategory-14816deb.js';
7
6
  import 'ky-universal';
8
7
  import 'ky';
9
8
 
package/dist/index.js CHANGED
@@ -5,59 +5,11 @@ import {
5
5
  createProductTypesApi,
6
6
  createTradingPartnerAccessApi
7
7
  } from "./chunk-RNUSCCKB.js";
8
+ import {
9
+ AsstClient,
10
+ BASE_URLS
11
+ } from "./chunk-OBXZRDPY.js";
8
12
  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
13
  export {
62
14
  AsstClient,
63
15
  BASE_URLS,
package/dist/msw.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as msw from 'msw';
2
2
  import { ResponseResolver, RestRequest, RestContext, DefaultBodyType } from 'msw';
3
3
  import * as msw_lib_glossary_de6278a9 from 'msw/lib/glossary-de6278a9';
4
- import { A as AsstClient, V as VendorPartnerAttGroups, d as attrProdTypeSchema, T as TradingPartnerAccessByCompanyId } from './TradingPartnerAccessByCompanyId-479e3e57.js';
5
- import { c as ImportErrors, I as Import, a as ImportsStatus, b as ItemCategoriesSearch, E as Export } from './ItemCategoriesSearch-1bb945de.js';
4
+ import { A as AsstClient, f as ImportErrors, I as Import, a as ImportsStatus, b as ItemCategoriesSearch, E as Export } from './ItemCategoriesSearch-ec43591f.js';
5
+ import { V as VendorPartnerAttGroups, a as attrProdTypeSchema, T as TradingPartnerAccessByCompanyId } from './TradingPartnerAccessByCompanyId-29866586.js';
6
6
  import { z } from 'zod';
7
7
  import 'ky-universal';
8
8
  import 'ky';
@@ -39,8 +39,8 @@ declare function createImportsApiHandlers(client: AsstClient): {
39
39
  generateData(): {
40
40
  count: number;
41
41
  imports: {
42
- completedAt: number | null;
43
42
  status: string;
43
+ completedAt: number | null;
44
44
  errorCount: number;
45
45
  importId: number;
46
46
  name: string;
package/dist/zod.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,11 +17,20 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // lib/zod.ts
21
31
  var zod_exports = {};
22
32
  __export(zod_exports, {
33
+ envSchema: () => envSchema,
23
34
  exportDayOfWeekEnum: () => exportDayOfWeekEnum,
24
35
  exportFrequencyEnum: () => exportFrequencyEnum,
25
36
  exportSchema: () => exportSchema,
@@ -35,6 +46,9 @@ __export(zod_exports, {
35
46
  });
36
47
  module.exports = __toCommonJS(zod_exports);
37
48
 
49
+ // lib/asstClient.ts
50
+ var import_ky_universal = __toESM(require("ky-universal"), 1);
51
+
38
52
  // ../../node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs
39
53
  var util;
40
54
  (function(util2) {
@@ -3717,6 +3731,23 @@ var z = /* @__PURE__ */ Object.freeze({
3717
3731
  ZodError
3718
3732
  });
3719
3733
 
3734
+ // lib/asstClient.ts
3735
+ var baseUrlsSchema = z.object({
3736
+ local: z.literal("https://localhost:8443"),
3737
+ test: z.literal("https://integration.api.spscommerce.com/assortment/gateway"),
3738
+ prod: z.literal("https://api.spscommerce.com/assortment/gateway")
3739
+ });
3740
+ var BASE_URLS = {
3741
+ local: "https://localhost:8443",
3742
+ test: "https://integration.api.spscommerce.com/assortment/gateway",
3743
+ prod: "https://api.spscommerce.com/assortment/gateway"
3744
+ };
3745
+ var envSchema = baseUrlsSchema.keyof();
3746
+ var initialConfig = {
3747
+ prefixUrl: BASE_URLS["test"],
3748
+ retry: 0
3749
+ };
3750
+
3720
3751
  // lib/imports/models/ImportDetail.ts
3721
3752
  var importDetailSchema = z.object({
3722
3753
  completedAt: z.nullable(z.number()),
@@ -3859,6 +3890,7 @@ var itemCategoriesSearchSchema = z.object({
3859
3890
  });
3860
3891
  // Annotate the CommonJS export names for ESM import in node:
3861
3892
  0 && (module.exports = {
3893
+ envSchema,
3862
3894
  exportDayOfWeekEnum,
3863
3895
  exportFrequencyEnum,
3864
3896
  exportSchema,
package/dist/zod.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export { f as exportSchema, i as importErrorsSchema, d as importSchema, e as importsStatusSchema, g as itemCategoriesSearchSchema } from './ItemCategoriesSearch-1bb945de.js';
2
- export { h as exportDayOfWeekEnum, j as exportFrequencyEnum, k as exportTypeEnum, i as importDetailSchema, f as importErrorSchema, g as importStatusEnumSchema, l as itemCategorySchema } from './ItemCategory-768179bd.js';
1
+ export { g as envSchema, k as exportSchema, i as importErrorsSchema, h as importSchema, j as importsStatusSchema, l as itemCategoriesSearchSchema } from './ItemCategoriesSearch-ec43591f.js';
2
+ export { h as exportDayOfWeekEnum, j as exportFrequencyEnum, k as exportTypeEnum, i as importDetailSchema, f as importErrorSchema, g as importStatusEnumSchema, l as itemCategorySchema } from './ItemCategory-14816deb.js';
3
+ import 'ky-universal';
4
+ import 'ky';
3
5
  import 'zod';
package/dist/zod.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ envSchema
3
+ } from "./chunk-OBXZRDPY.js";
1
4
  import "./chunk-LGP22FRF.js";
2
5
  import {
3
6
  importDetailSchema,
@@ -59,6 +62,7 @@ var exportSchema = z.object({
59
62
  additionalLocales: z.optional(z.array(z.string()))
60
63
  });
61
64
  export {
65
+ envSchema,
62
66
  exportDayOfWeekEnum,
63
67
  exportFrequencyEnum,
64
68
  exportSchema,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Assortment Api is a collection of HTTP functions to use Assortment endpoints",
4
4
  "author": "Assortment",
5
5
  "repository": "https://github.com/SPSCommerce/assortment-main/tree/main/ui/packages/asst-api",
6
- "version": "0.0.1-beta.2",
6
+ "version": "0.0.1-beta.4",
7
7
  "files": [
8
8
  "dist"
9
9
  ],