@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.
package/src/index.ts CHANGED
@@ -16,8 +16,8 @@ import { ShopNamespace, ShopSDKConfig } from './shop.js'
16
16
  export interface ForgeCartSDKConfig {
17
17
  /** Base API endpoint (e.g., 'https://api.forgecart.com') */
18
18
  endpoint?: string
19
- /** Channel token for Vendure multi-tenancy */
20
- token?: string
19
+ /** Channel token for Vendure multi-tenancy (required) */
20
+ token: string
21
21
  /** Use HTTP only, skip WebSocket initialization (default: false) */
22
22
  httpOnly?: boolean
23
23
  /** Custom HTTP headers */
@@ -54,14 +54,19 @@ export class ForgeCartSDK {
54
54
  readonly admin: AdminNamespace
55
55
  readonly shop: ShopNamespace
56
56
 
57
- constructor(config: ForgeCartSDKConfig = {}) {
57
+ constructor(config: ForgeCartSDKConfig) {
58
+ // Validate channel token is provided
59
+ if (!config.token || config.token.trim() === '') {
60
+ throw new Error('ForgeCartSDK: Channel token is required. Please provide a valid "token" in the configuration.')
61
+ }
62
+
58
63
  const baseEndpoint = config.endpoint || 'https://api.forgecart.com'
59
64
  const baseWsEndpoint = baseEndpoint.replace('http', 'ws')
60
65
 
61
66
  // Build headers with token
62
67
  const headers: Record<string, string> = {
63
68
  ...config.headers,
64
- ...(config.token ? { 'forge-token': config.token } : {}),
69
+ 'forge-token': config.token,
65
70
  }
66
71
 
67
72
  const adminConfig: AdminSDKConfig = {
@@ -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
@@ -3459,4 +3459,5 @@ export class ShopNamespace {
3459
3459
  dispose(): void {
3460
3460
  this.client.dispose();
3461
3461
  }
3462
+
3462
3463
  }
package/src/shop-types.ts CHANGED
@@ -12,13 +12,9 @@ export type Scalars = {
12
12
  Boolean: { input: boolean; output: boolean; }
13
13
  Int: { input: number; output: number; }
14
14
  Float: { input: number; output: number; }
15
- /** 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. */
16
15
  DateTime: { input: any; output: any; }
17
- /** The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
18
16
  JSON: { input: any; output: any; }
19
- /** 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). */
20
17
  Money: { input: any; output: any; }
21
- /** The `Upload` scalar type represents a file upload. */
22
18
  Upload: { input: any; output: any; }
23
19
  };
24
20
 
@@ -36,6 +32,11 @@ export type AcfValueUnion = BooleanValue | DateValue | FloatValue | GroupValue |
36
32
 
37
33
  export type ActiveOrderResult = NoActiveOrderError | Order;
38
34
 
35
+ export type AddItemInput = {
36
+ productVariantId: Scalars['ID']['input'];
37
+ quantity: Scalars['Int']['input'];
38
+ };
39
+
39
40
  export type AddPaymentToOrderResult = IneligiblePaymentMethodError | NoActiveOrderError | Order | OrderPaymentStateError | OrderStateTransitionError | PaymentDeclinedError | PaymentFailedError;
40
41
 
41
42
  export type Address = Node & {
@@ -228,6 +229,8 @@ export type BlogPostMeta = {
228
229
 
229
230
  export type BooleanCustomFieldConfig = CustomField & {
230
231
  __typename?: 'BooleanCustomFieldConfig';
232
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
233
+ deprecationReason?: Maybe<Scalars['String']['output']>;
231
234
  description?: Maybe<Array<LocalizedString>>;
232
235
  internal?: Maybe<Scalars['Boolean']['output']>;
233
236
  label?: Maybe<Array<LocalizedString>>;
@@ -875,6 +878,8 @@ export type CurrentUserChannel = {
875
878
  };
876
879
 
877
880
  export type CustomField = {
881
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
882
+ deprecationReason?: Maybe<Scalars['String']['output']>;
878
883
  description?: Maybe<Array<LocalizedString>>;
879
884
  internal?: Maybe<Scalars['Boolean']['output']>;
880
885
  label?: Maybe<Array<LocalizedString>>;
@@ -1004,6 +1009,8 @@ export type DateRange = {
1004
1009
  */
1005
1010
  export type DateTimeCustomFieldConfig = CustomField & {
1006
1011
  __typename?: 'DateTimeCustomFieldConfig';
1012
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1013
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1007
1014
  description?: Maybe<Array<LocalizedString>>;
1008
1015
  internal?: Maybe<Scalars['Boolean']['output']>;
1009
1016
  label?: Maybe<Array<LocalizedString>>;
@@ -1274,6 +1281,8 @@ export type FacetValueTranslation = {
1274
1281
 
1275
1282
  export type FloatCustomFieldConfig = CustomField & {
1276
1283
  __typename?: 'FloatCustomFieldConfig';
1284
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1285
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1277
1286
  description?: Maybe<Array<LocalizedString>>;
1278
1287
  internal?: Maybe<Scalars['Boolean']['output']>;
1279
1288
  label?: Maybe<Array<LocalizedString>>;
@@ -1588,6 +1597,8 @@ export type InsufficientStockError = ErrorResult & {
1588
1597
 
1589
1598
  export type IntCustomFieldConfig = CustomField & {
1590
1599
  __typename?: 'IntCustomFieldConfig';
1600
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1601
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1591
1602
  description?: Maybe<Array<LocalizedString>>;
1592
1603
  internal?: Maybe<Scalars['Boolean']['output']>;
1593
1604
  label?: Maybe<Array<LocalizedString>>;
@@ -1970,6 +1981,8 @@ export type LanguageCode =
1970
1981
 
1971
1982
  export type LocaleStringCustomFieldConfig = CustomField & {
1972
1983
  __typename?: 'LocaleStringCustomFieldConfig';
1984
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
1985
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1973
1986
  description?: Maybe<Array<LocalizedString>>;
1974
1987
  internal?: Maybe<Scalars['Boolean']['output']>;
1975
1988
  label?: Maybe<Array<LocalizedString>>;
@@ -1986,6 +1999,8 @@ export type LocaleStringCustomFieldConfig = CustomField & {
1986
1999
 
1987
2000
  export type LocaleTextCustomFieldConfig = CustomField & {
1988
2001
  __typename?: 'LocaleTextCustomFieldConfig';
2002
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
2003
+ deprecationReason?: Maybe<Scalars['String']['output']>;
1989
2004
  description?: Maybe<Array<LocalizedString>>;
1990
2005
  internal?: Maybe<Scalars['Boolean']['output']>;
1991
2006
  label?: Maybe<Array<LocalizedString>>;
@@ -2023,6 +2038,8 @@ export type Mutation = {
2023
2038
  __typename?: 'Mutation';
2024
2039
  /** Adds an item to the Order. If custom fields are defined on the OrderLine entity, a third argument 'customFields' will be available. */
2025
2040
  addItemToOrder: UpdateOrderItemsResult;
2041
+ /** Adds mutliple items to the Order. Returns a list of errors for each item that failed to add. It will still add successful items. */
2042
+ addItemsToOrder: UpdateMultipleOrderItemsResult;
2026
2043
  /** Add a Payment to the Order */
2027
2044
  addPaymentToOrder: AddPaymentToOrderResult;
2028
2045
  /** Adjusts an OrderLine. If custom fields are defined on the OrderLine entity, a third argument 'customFields' of type `OrderLineCustomFieldsInput` will be available. */
@@ -2135,6 +2152,11 @@ export type MutationAddItemToOrderArgs = {
2135
2152
  };
2136
2153
 
2137
2154
 
2155
+ export type MutationAddItemsToOrderArgs = {
2156
+ inputs: Array<AddItemInput>;
2157
+ };
2158
+
2159
+
2138
2160
  export type MutationAddPaymentToOrderArgs = {
2139
2161
  input: PaymentInput;
2140
2162
  };
@@ -3633,6 +3655,8 @@ export type RegisterCustomerInput = {
3633
3655
 
3634
3656
  export type RelationCustomFieldConfig = CustomField & {
3635
3657
  __typename?: 'RelationCustomFieldConfig';
3658
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
3659
+ deprecationReason?: Maybe<Scalars['String']['output']>;
3636
3660
  description?: Maybe<Array<LocalizedString>>;
3637
3661
  entity: Scalars['String']['output'];
3638
3662
  internal?: Maybe<Scalars['Boolean']['output']>;
@@ -3717,6 +3741,7 @@ export type SearchInput = {
3717
3741
  collectionSlug?: InputMaybe<Scalars['String']['input']>;
3718
3742
  facetValueFilters?: InputMaybe<Array<FacetValueFilterInput>>;
3719
3743
  groupByProduct?: InputMaybe<Scalars['Boolean']['input']>;
3744
+ groupBySKU?: InputMaybe<Scalars['Boolean']['input']>;
3720
3745
  inStock?: InputMaybe<Scalars['Boolean']['input']>;
3721
3746
  priceRange?: InputMaybe<PriceRangeInput>;
3722
3747
  priceRangeWithTax?: InputMaybe<PriceRangeInput>;
@@ -3880,6 +3905,8 @@ export type SortOrder =
3880
3905
 
3881
3906
  export type StringCustomFieldConfig = CustomField & {
3882
3907
  __typename?: 'StringCustomFieldConfig';
3908
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
3909
+ deprecationReason?: Maybe<Scalars['String']['output']>;
3883
3910
  description?: Maybe<Array<LocalizedString>>;
3884
3911
  internal?: Maybe<Scalars['Boolean']['output']>;
3885
3912
  label?: Maybe<Array<LocalizedString>>;
@@ -3954,6 +3981,8 @@ export type StringValue = {
3954
3981
 
3955
3982
  export type StructCustomFieldConfig = CustomField & {
3956
3983
  __typename?: 'StructCustomFieldConfig';
3984
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
3985
+ deprecationReason?: Maybe<Scalars['String']['output']>;
3957
3986
  description?: Maybe<Array<LocalizedString>>;
3958
3987
  fields: Array<StructFieldConfig>;
3959
3988
  internal?: Maybe<Scalars['Boolean']['output']>;
@@ -4049,6 +4078,8 @@ export type TaxRateList = PaginatedList & {
4049
4078
 
4050
4079
  export type TextCustomFieldConfig = CustomField & {
4051
4080
  __typename?: 'TextCustomFieldConfig';
4081
+ deprecated?: Maybe<Scalars['Boolean']['output']>;
4082
+ deprecationReason?: Maybe<Scalars['String']['output']>;
4052
4083
  description?: Maybe<Array<LocalizedString>>;
4053
4084
  internal?: Maybe<Scalars['Boolean']['output']>;
4054
4085
  label?: Maybe<Array<LocalizedString>>;
@@ -4123,10 +4154,23 @@ export type UpdateCustomerInput = {
4123
4154
 
4124
4155
  export type UpdateCustomerPasswordResult = InvalidCredentialsError | NativeAuthStrategyError | PasswordValidationError | Success;
4125
4156
 
4157
+ /**
4158
+ * Returned when multiple items are added to an Order.
4159
+ * The errorResults array contains the errors that occurred for each item, if any.
4160
+ */
4161
+ export type UpdateMultipleOrderItemsResult = {
4162
+ __typename?: 'UpdateMultipleOrderItemsResult';
4163
+ errorResults: Array<UpdateOrderItemErrorResult>;
4164
+ order: Order;
4165
+ };
4166
+
4126
4167
  export type UpdateOrderInput = {
4127
4168
  customFields?: InputMaybe<Scalars['JSON']['input']>;
4128
4169
  };
4129
4170
 
4171
+ /** Union type of all possible errors that can occur when adding or removing items from an Order. */
4172
+ export type UpdateOrderItemErrorResult = InsufficientStockError | NegativeQuantityError | OrderInterceptorError | OrderLimitError | OrderModificationError;
4173
+
4130
4174
  export type UpdateOrderItemsResult = InsufficientStockError | NegativeQuantityError | Order | OrderInterceptorError | OrderLimitError | OrderModificationError;
4131
4175
 
4132
4176
  export type User = Node & {