@forgecart/sdk 1.2.0 → 1.2.2

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.
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/admin.js CHANGED
@@ -1,7 +1,25 @@
1
+ "use strict";
1
2
  /**
2
3
  * @forgecart/sdk - Admin API
3
4
  *
4
5
  * Admin namespace and types
5
6
  */
6
- export { AdminNamespace } from './admin-namespace.js';
7
- export * from './admin-types.js';
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.AdminNamespace = void 0;
23
+ var admin_namespace_js_1 = require("./admin-namespace.js");
24
+ Object.defineProperty(exports, "AdminNamespace", { enumerable: true, get: function () { return admin_namespace_js_1.AdminNamespace; } });
25
+ __exportStar(require("./admin-types.js"), exports);
package/dist/index.d.ts CHANGED
@@ -14,8 +14,8 @@ import { ShopNamespace, ShopSDKConfig } from './shop.js';
14
14
  export interface ForgeCartSDKConfig {
15
15
  /** Base API endpoint (e.g., 'https://api.forgecart.com') */
16
16
  endpoint?: string;
17
- /** Channel token for Vendure multi-tenancy */
18
- token?: string;
17
+ /** Channel token for Vendure multi-tenancy (required) */
18
+ token: string;
19
19
  /** Use HTTP only, skip WebSocket initialization (default: false) */
20
20
  httpOnly?: boolean;
21
21
  /** Custom HTTP headers */
@@ -48,7 +48,7 @@ export { AdminNamespace, ShopNamespace };
48
48
  export declare class ForgeCartSDK {
49
49
  readonly admin: AdminNamespace;
50
50
  readonly shop: ShopNamespace;
51
- constructor(config?: ForgeCartSDKConfig);
51
+ constructor(config: ForgeCartSDKConfig);
52
52
  setAdminAuthToken(token: string): void;
53
53
  clearAdminAuthToken(): void;
54
54
  setShopAuthToken(token: string): void;
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * @forgecart/sdk - Auto-generated TypeScript SDK
3
4
  *
@@ -6,9 +7,12 @@
6
7
  *
7
8
  * 🤖 Generated with ForgeCart SDK Generator
8
9
  */
9
- import { AdminNamespace } from './admin.js';
10
- import { ShopNamespace } from './shop.js';
11
- export { AdminNamespace, ShopNamespace };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ForgeCartSDK = exports.ShopNamespace = exports.AdminNamespace = void 0;
12
+ const admin_js_1 = require("./admin.js");
13
+ Object.defineProperty(exports, "AdminNamespace", { enumerable: true, get: function () { return admin_js_1.AdminNamespace; } });
14
+ const shop_js_1 = require("./shop.js");
15
+ Object.defineProperty(exports, "ShopNamespace", { enumerable: true, get: function () { return shop_js_1.ShopNamespace; } });
12
16
  /**
13
17
  * ForgeCartSDK
14
18
  * Unified SDK with categorized operations across multiple namespaces
@@ -29,14 +33,18 @@ export { AdminNamespace, ShopNamespace };
29
33
  * await sdk.shop.order.addItemToOrder({ productVariantId: '1', quantity: 1 });
30
34
  * ```
31
35
  */
32
- export class ForgeCartSDK {
33
- constructor(config = {}) {
36
+ class ForgeCartSDK {
37
+ constructor(config) {
38
+ // Validate channel token is provided
39
+ if (!config.token || config.token.trim() === '') {
40
+ throw new Error('ForgeCartSDK: Channel token is required. Please provide a valid "token" in the configuration.');
41
+ }
34
42
  const baseEndpoint = config.endpoint || 'https://api.forgecart.com';
35
43
  const baseWsEndpoint = baseEndpoint.replace('http', 'ws');
36
44
  // Build headers with token
37
45
  const headers = {
38
46
  ...config.headers,
39
- ...(config.token ? { 'forge-token': config.token } : {}),
47
+ 'forge-token': config.token,
40
48
  };
41
49
  const adminConfig = {
42
50
  endpoint: `${baseEndpoint}/admin-api`,
@@ -45,7 +53,7 @@ export class ForgeCartSDK {
45
53
  webSocketImpl: config.webSocketImpl,
46
54
  httpOnly: config.httpOnly,
47
55
  };
48
- this.admin = new AdminNamespace(adminConfig);
56
+ this.admin = new admin_js_1.AdminNamespace(adminConfig);
49
57
  const shopConfig = {
50
58
  endpoint: `${baseEndpoint}/shop-api`,
51
59
  wsEndpoint: `${baseWsEndpoint}/shop-api`,
@@ -53,7 +61,7 @@ export class ForgeCartSDK {
53
61
  webSocketImpl: config.webSocketImpl,
54
62
  httpOnly: config.httpOnly,
55
63
  };
56
- this.shop = new ShopNamespace(shopConfig);
64
+ this.shop = new shop_js_1.ShopNamespace(shopConfig);
57
65
  }
58
66
  setAdminAuthToken(token) {
59
67
  this.admin.setAuthToken(token);
@@ -72,3 +80,4 @@ export class ForgeCartSDK {
72
80
  this.shop.dispose();
73
81
  }
74
82
  }
83
+ exports.ForgeCartSDK = ForgeCartSDK;
@@ -4,7 +4,7 @@
4
4
  * This file was automatically generated and should not be manually edited.
5
5
  * To regenerate, run: npm run codegen:ts
6
6
  *
7
- * Generated at: 2025-12-13T23:18:09.300Z
7
+ * Generated at: 2025-12-15T07:13:55.632Z
8
8
  * Generator version: 1.0.0
9
9
  *
10
10
  * 🤖 Generated with ForgeCart SDK Generator
@@ -1,16 +1,19 @@
1
+ "use strict";
1
2
  /**
2
3
  * @forgecart/sdk - Auto-generated TypeScript SDK
3
4
  *
4
5
  * This file was automatically generated and should not be manually edited.
5
6
  * To regenerate, run: npm run codegen:ts
6
7
  *
7
- * Generated at: 2025-12-13T23:18:09.300Z
8
+ * Generated at: 2025-12-15T07:13:55.632Z
8
9
  * Generator version: 1.0.0
9
10
  *
10
11
  * 🤖 Generated with ForgeCart SDK Generator
11
12
  */
12
- import { GraphQLClient } from 'graphql-request';
13
- import { createClient } from 'graphql-ws';
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ShopNamespace = void 0;
15
+ const graphql_request_1 = require("graphql-request");
16
+ const graphql_ws_1 = require("graphql-ws");
14
17
  const assetDocument = `query asset($id: ID!) {
15
18
  asset(id: $id) {
16
19
  id
@@ -2219,7 +2222,7 @@ class BaseGraphQLClient {
2219
2222
  return response;
2220
2223
  };
2221
2224
  // Initialize HTTP client with custom fetch
2222
- this.httpClient = new GraphQLClient(this.endpoint, {
2225
+ this.httpClient = new graphql_request_1.GraphQLClient(this.endpoint, {
2223
2226
  headers: config.headers || {},
2224
2227
  credentials: 'include',
2225
2228
  fetch: customFetch,
@@ -2391,7 +2394,7 @@ class BaseGraphQLClient {
2391
2394
  },
2392
2395
  },
2393
2396
  };
2394
- this.wsClient = createClient(wsOptions);
2397
+ this.wsClient = (0, graphql_ws_1.createClient)(wsOptions);
2395
2398
  this.wsInitializing = null;
2396
2399
  }
2397
2400
  catch (error) {
@@ -3004,7 +3007,7 @@ class SearchOperations {
3004
3007
  * Shop namespace
3005
3008
  * Contains categorized operations for shop API
3006
3009
  */
3007
- export class ShopNamespace {
3010
+ class ShopNamespace {
3008
3011
  constructor(config) {
3009
3012
  this.client = new BaseGraphQLClient(config);
3010
3013
  this.asset = new AssetOperations(this.client);
@@ -3041,3 +3044,4 @@ export class ShopNamespace {
3041
3044
  this.client.dispose();
3042
3045
  }
3043
3046
  }
3047
+ exports.ShopNamespace = ShopNamespace;
@@ -41,22 +41,18 @@ export type Scalars = {
41
41
  input: number;
42
42
  output: number;
43
43
  };
44
- /** A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar. */
45
44
  DateTime: {
46
45
  input: any;
47
46
  output: any;
48
47
  };
49
- /** The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
50
48
  JSON: {
51
49
  input: any;
52
50
  output: any;
53
51
  };
54
- /** The `Money` scalar type represents monetary values and supports signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point). */
55
52
  Money: {
56
53
  input: any;
57
54
  output: any;
58
55
  };
59
- /** The `Upload` scalar type represents a file upload. */
60
56
  Upload: {
61
57
  input: any;
62
58
  output: any;
@@ -72,6 +68,10 @@ export type AcfGroupMember = {
72
68
  };
73
69
  export type AcfValueUnion = BooleanValue | DateValue | FloatValue | GroupValue | IntegerValue | RelationValue | RichTextValue | StringValue;
74
70
  export type ActiveOrderResult = NoActiveOrderError | Order;
71
+ export type AddItemInput = {
72
+ productVariantId: Scalars['ID']['input'];
73
+ quantity: Scalars['Int']['input'];
74
+ };
75
75
  export type AddPaymentToOrderResult = IneligiblePaymentMethodError | NoActiveOrderError | Order | OrderPaymentStateError | OrderStateTransitionError | PaymentDeclinedError | PaymentFailedError;
76
76
  export type Address = Node & {
77
77
  __typename?: 'Address';
@@ -237,6 +237,8 @@ export type BlogPostMeta = {
237
237
  };
238
238
  export type BooleanCustomFieldConfig = CustomField & {
239
239
  __typename?: 'BooleanCustomFieldConfig';
240
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
241
+ deprecationReason?: Maybe<Scalars['String']['output']>;
240
242
  description?: Maybe<Array<LocalizedString>>;
241
243
  internal?: Maybe<Scalars['Boolean']['output']>;
242
244
  label?: Maybe<Array<LocalizedString>>;
@@ -850,6 +852,8 @@ export type CurrentUserChannel = {
850
852
  token: Scalars['String']['output'];
851
853
  };
852
854
  export type CustomField = {
855
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
856
+ deprecationReason?: Maybe<Scalars['String']['output']>;
853
857
  description?: Maybe<Array<LocalizedString>>;
854
858
  internal?: Maybe<Scalars['Boolean']['output']>;
855
859
  label?: Maybe<Array<LocalizedString>>;
@@ -963,6 +967,8 @@ export type DateRange = {
963
967
  */
964
968
  export type DateTimeCustomFieldConfig = CustomField & {
965
969
  __typename?: 'DateTimeCustomFieldConfig';
970
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
971
+ deprecationReason?: Maybe<Scalars['String']['output']>;
966
972
  description?: Maybe<Array<LocalizedString>>;
967
973
  internal?: Maybe<Scalars['Boolean']['output']>;
968
974
  label?: Maybe<Array<LocalizedString>>;
@@ -1175,6 +1181,8 @@ export type FacetValueTranslation = {
1175
1181
  };
1176
1182
  export type FloatCustomFieldConfig = CustomField & {
1177
1183
  __typename?: 'FloatCustomFieldConfig';
1184
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1185
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1178
1186
  description?: Maybe<Array<LocalizedString>>;
1179
1187
  internal?: Maybe<Scalars['Boolean']['output']>;
1180
1188
  label?: Maybe<Array<LocalizedString>>;
@@ -1427,6 +1435,8 @@ export type InsufficientStockError = ErrorResult & {
1427
1435
  };
1428
1436
  export type IntCustomFieldConfig = CustomField & {
1429
1437
  __typename?: 'IntCustomFieldConfig';
1438
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1439
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1430
1440
  description?: Maybe<Array<LocalizedString>>;
1431
1441
  internal?: Maybe<Scalars['Boolean']['output']>;
1432
1442
  label?: Maybe<Array<LocalizedString>>;
@@ -1803,6 +1813,8 @@ export type LanguageCode =
1803
1813
  | 'zu';
1804
1814
  export type LocaleStringCustomFieldConfig = CustomField & {
1805
1815
  __typename?: 'LocaleStringCustomFieldConfig';
1816
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1817
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1806
1818
  description?: Maybe<Array<LocalizedString>>;
1807
1819
  internal?: Maybe<Scalars['Boolean']['output']>;
1808
1820
  label?: Maybe<Array<LocalizedString>>;
@@ -1818,6 +1830,8 @@ export type LocaleStringCustomFieldConfig = CustomField & {
1818
1830
  };
1819
1831
  export type LocaleTextCustomFieldConfig = CustomField & {
1820
1832
  __typename?: 'LocaleTextCustomFieldConfig';
1833
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1834
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1821
1835
  description?: Maybe<Array<LocalizedString>>;
1822
1836
  internal?: Maybe<Scalars['Boolean']['output']>;
1823
1837
  label?: Maybe<Array<LocalizedString>>;
@@ -1848,6 +1862,8 @@ export type Mutation = {
1848
1862
  __typename?: 'Mutation';
1849
1863
  /** Adds an item to the Order. If custom fields are defined on the OrderLine entity, a third argument 'customFields' will be available. */
1850
1864
  addItemToOrder: UpdateOrderItemsResult;
1865
+ /** Adds mutliple items to the Order. Returns a list of errors for each item that failed to add. It will still add successful items. */
1866
+ addItemsToOrder: UpdateMultipleOrderItemsResult;
1851
1867
  /** Add a Payment to the Order */
1852
1868
  addPaymentToOrder: AddPaymentToOrderResult;
1853
1869
  /** Adjusts an OrderLine. If custom fields are defined on the OrderLine entity, a third argument 'customFields' of type `OrderLineCustomFieldsInput` will be available. */
@@ -1956,6 +1972,9 @@ export type MutationAddItemToOrderArgs = {
1956
1972
  productVariantId: Scalars['ID']['input'];
1957
1973
  quantity: Scalars['Int']['input'];
1958
1974
  };
1975
+ export type MutationAddItemsToOrderArgs = {
1976
+ inputs: Array<AddItemInput>;
1977
+ };
1959
1978
  export type MutationAddPaymentToOrderArgs = {
1960
1979
  input: PaymentInput;
1961
1980
  };
@@ -3241,6 +3260,8 @@ export type RegisterCustomerInput = {
3241
3260
  };
3242
3261
  export type RelationCustomFieldConfig = CustomField & {
3243
3262
  __typename?: 'RelationCustomFieldConfig';
3263
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
3264
+ deprecationReason?: Maybe<Scalars['String']['output']>;
3244
3265
  description?: Maybe<Array<LocalizedString>>;
3245
3266
  entity: Scalars['String']['output'];
3246
3267
  internal?: Maybe<Scalars['Boolean']['output']>;
@@ -3314,6 +3335,7 @@ export type SearchInput = {
3314
3335
  collectionSlug?: InputMaybe<Scalars['String']['input']>;
3315
3336
  facetValueFilters?: InputMaybe<Array<FacetValueFilterInput>>;
3316
3337
  groupByProduct?: InputMaybe<Scalars['Boolean']['input']>;
3338
+ groupBySKU?: InputMaybe<Scalars['Boolean']['input']>;
3317
3339
  inStock?: InputMaybe<Scalars['Boolean']['input']>;
3318
3340
  priceRange?: InputMaybe<PriceRangeInput>;
3319
3341
  priceRangeWithTax?: InputMaybe<PriceRangeInput>;
@@ -3455,6 +3477,8 @@ export type SinglePrice = {
3455
3477
  export type SortOrder = 'ASC' | 'DESC';
3456
3478
  export type StringCustomFieldConfig = CustomField & {
3457
3479
  __typename?: 'StringCustomFieldConfig';
3480
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
3481
+ deprecationReason?: Maybe<Scalars['String']['output']>;
3458
3482
  description?: Maybe<Array<LocalizedString>>;
3459
3483
  internal?: Maybe<Scalars['Boolean']['output']>;
3460
3484
  label?: Maybe<Array<LocalizedString>>;
@@ -3522,6 +3546,8 @@ export type StringValue = {
3522
3546
  };
3523
3547
  export type StructCustomFieldConfig = CustomField & {
3524
3548
  __typename?: 'StructCustomFieldConfig';
3549
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
3550
+ deprecationReason?: Maybe<Scalars['String']['output']>;
3525
3551
  description?: Maybe<Array<LocalizedString>>;
3526
3552
  fields: Array<StructFieldConfig>;
3527
3553
  internal?: Maybe<Scalars['Boolean']['output']>;
@@ -3606,6 +3632,8 @@ export type TaxRateList = PaginatedList & {
3606
3632
  };
3607
3633
  export type TextCustomFieldConfig = CustomField & {
3608
3634
  __typename?: 'TextCustomFieldConfig';
3635
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
3636
+ deprecationReason?: Maybe<Scalars['String']['output']>;
3609
3637
  description?: Maybe<Array<LocalizedString>>;
3610
3638
  internal?: Maybe<Scalars['Boolean']['output']>;
3611
3639
  label?: Maybe<Array<LocalizedString>>;
@@ -3671,9 +3699,20 @@ export type UpdateCustomerInput = {
3671
3699
  title?: InputMaybe<Scalars['String']['input']>;
3672
3700
  };
3673
3701
  export type UpdateCustomerPasswordResult = InvalidCredentialsError | NativeAuthStrategyError | PasswordValidationError | Success;
3702
+ /**
3703
+ * Returned when multiple items are added to an Order.
3704
+ * The errorResults array contains the errors that occurred for each item, if any.
3705
+ */
3706
+ export type UpdateMultipleOrderItemsResult = {
3707
+ __typename?: 'UpdateMultipleOrderItemsResult';
3708
+ errorResults: Array<UpdateOrderItemErrorResult>;
3709
+ order: Order;
3710
+ };
3674
3711
  export type UpdateOrderInput = {
3675
3712
  customFields?: InputMaybe<Scalars['JSON']['input']>;
3676
3713
  };
3714
+ /** Union type of all possible errors that can occur when adding or removing items from an Order. */
3715
+ export type UpdateOrderItemErrorResult = InsufficientStockError | NegativeQuantityError | OrderInterceptorError | OrderLimitError | OrderModificationError;
3677
3716
  export type UpdateOrderItemsResult = InsufficientStockError | NegativeQuantityError | Order | OrderInterceptorError | OrderLimitError | OrderModificationError;
3678
3717
  export type User = Node & {
3679
3718
  __typename?: 'User';
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/shop.js CHANGED
@@ -1,7 +1,25 @@
1
+ "use strict";
1
2
  /**
2
3
  * @forgecart/sdk - Shop API
3
4
  *
4
5
  * Shop namespace and types
5
6
  */
6
- export { ShopNamespace } from './shop-namespace.js';
7
- export * from './shop-types.js';
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.ShopNamespace = void 0;
23
+ var shop_namespace_js_1 = require("./shop-namespace.js");
24
+ Object.defineProperty(exports, "ShopNamespace", { enumerable: true, get: function () { return shop_namespace_js_1.ShopNamespace; } });
25
+ __exportStar(require("./shop-types.js"), exports);
package/package.json CHANGED
@@ -1,23 +1,28 @@
1
1
  {
2
2
  "name": "@forgecart/sdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "TypeScript SDK for ForgeCart API - Auto-generated GraphQL client",
5
- "type": "module",
6
5
  "main": "./dist/index.js",
7
6
  "module": "./dist/index.js",
8
7
  "types": "./dist/index.d.ts",
9
8
  "exports": {
10
9
  ".": {
10
+ "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
12
+ "require": "./dist/index.js",
13
+ "default": "./dist/index.js"
13
14
  },
14
15
  "./admin": {
16
+ "types": "./dist/admin.d.ts",
15
17
  "import": "./dist/admin.js",
16
- "types": "./dist/admin.d.ts"
18
+ "require": "./dist/admin.js",
19
+ "default": "./dist/admin.js"
17
20
  },
18
21
  "./shop": {
22
+ "types": "./dist/shop.d.ts",
19
23
  "import": "./dist/shop.js",
20
- "types": "./dist/shop.d.ts"
24
+ "require": "./dist/shop.js",
25
+ "default": "./dist/shop.js"
21
26
  }
22
27
  },
23
28
  "files": [