@forgecart/sdk 1.2.5 → 1.2.7
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/README.md +57 -59
- package/dist/admin-types.generated.d.ts +10013 -0
- package/dist/admin.d.ts +57 -8
- package/dist/admin.generated.d.ts +806 -0
- package/dist/admin.generated.js +1837 -0
- package/dist/admin.js +114 -23
- package/dist/client.generated.d.ts +249 -0
- package/dist/client.generated.js +688 -0
- package/dist/documents.generated.d.ts +473 -0
- package/dist/documents.generated.js +24388 -0
- package/dist/error-utils.d.ts +25 -0
- package/dist/error-utils.js +59 -0
- package/dist/hook-event-map.generated.d.ts +243 -0
- package/dist/hook-event-map.generated.js +9 -0
- package/dist/index.d.ts +22 -59
- package/dist/index.js +33 -83
- package/dist/nest.generated.d.ts +13 -0
- package/dist/nest.generated.js +92 -0
- package/dist/sdk-hook-subscription.generated.d.ts +29 -0
- package/dist/sdk-hook-subscription.generated.js +73 -0
- package/dist/sdk-plugin.generated.d.ts +38 -0
- package/dist/sdk-plugin.generated.js +31 -0
- package/dist/sdk-types.generated.d.ts +56 -0
- package/dist/sdk-types.generated.js +28 -0
- package/dist/shop-types.generated.d.ts +4786 -0
- package/dist/shop.d.ts +19 -8
- package/dist/shop.generated.d.ts +213 -0
- package/dist/shop.generated.js +465 -0
- package/dist/shop.js +37 -23
- package/dist/upload.d.ts +14 -0
- package/dist/upload.js +163 -0
- package/package.json +23 -25
- package/src/admin-types.generated.ts +28612 -0
- package/src/admin.generated.ts +1807 -0
- package/src/admin.ts +57 -9
- package/src/client.generated.ts +825 -0
- package/src/documents.generated.ts +24843 -0
- package/src/error-utils.ts +74 -0
- package/src/hook-event-map.generated.ts +252 -0
- package/src/index.ts +22 -115
- package/src/nest.generated.ts +45 -0
- package/src/sdk-hook-subscription.generated.ts +93 -0
- package/src/sdk-plugin.generated.ts +59 -0
- package/src/sdk-types.generated.ts +79 -0
- package/src/shop-types.generated.ts +10412 -0
- package/src/shop.generated.ts +452 -0
- package/src/shop.ts +19 -9
- package/src/upload.ts +211 -0
- package/LICENSE +0 -21
- package/dist/admin-namespace.d.ts +0 -2688
- package/dist/admin-namespace.js +0 -9691
- package/dist/admin-types.d.ts +0 -16195
- package/dist/shop-namespace.d.ts +0 -718
- package/dist/shop-namespace.js +0 -3124
- package/dist/shop-types.d.ts +0 -6310
- package/src/admin-namespace.ts +0 -11428
- package/src/admin-types.ts +0 -10809
- package/src/shop-namespace.ts +0 -3547
- package/src/shop-types.ts +0 -4684
- /package/dist/{admin-types.js → admin-types.generated.js} +0 -0
- /package/dist/{shop-types.js → shop-types.generated.js} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ExtractedError {
|
|
2
|
+
code: string;
|
|
3
|
+
variables: Record<string, string>;
|
|
4
|
+
classification: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Extract the structured error code from a ClientError.
|
|
9
|
+
* Returns null if the error has no GraphQL error code.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractErrorCode(error: unknown): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Extract full structured error info from a ClientError.
|
|
14
|
+
* Returns null if the error has no GraphQL extensions.
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractError(error: unknown): ExtractedError | null;
|
|
17
|
+
/**
|
|
18
|
+
* Extract the localized error message from a ClientError.
|
|
19
|
+
* Returns null if the error has no localized message.
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractErrorMessage(error: unknown): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Check if an error has a specific error code.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isErrorCode(error: unknown, code: string): boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractErrorCode = extractErrorCode;
|
|
4
|
+
exports.extractError = extractError;
|
|
5
|
+
exports.extractErrorMessage = extractErrorMessage;
|
|
6
|
+
exports.isErrorCode = isErrorCode;
|
|
7
|
+
/**
|
|
8
|
+
* Get the first GraphQL error from an error object.
|
|
9
|
+
* Uses duck-typing so it works across bundler boundaries where instanceof fails.
|
|
10
|
+
*/
|
|
11
|
+
function getFirstGraphQLError(error) {
|
|
12
|
+
const err = error;
|
|
13
|
+
const errors = err?.response?.errors;
|
|
14
|
+
if (!Array.isArray(errors) || errors.length === 0) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return errors[0] ?? null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extract the structured error code from a ClientError.
|
|
21
|
+
* Returns null if the error has no GraphQL error code.
|
|
22
|
+
*/
|
|
23
|
+
function extractErrorCode(error) {
|
|
24
|
+
const firstError = getFirstGraphQLError(error);
|
|
25
|
+
if (!firstError?.extensions?.['code']) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return firstError.extensions['code'];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Extract full structured error info from a ClientError.
|
|
32
|
+
* Returns null if the error has no GraphQL extensions.
|
|
33
|
+
*/
|
|
34
|
+
function extractError(error) {
|
|
35
|
+
const firstError = getFirstGraphQLError(error);
|
|
36
|
+
if (!firstError?.extensions) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
code: firstError.extensions['code'] ?? firstError.message,
|
|
41
|
+
variables: firstError.extensions['variables'] ?? {},
|
|
42
|
+
classification: firstError.extensions['classification'] ?? 'UNKNOWN',
|
|
43
|
+
message: firstError.extensions['message'] ?? undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extract the localized error message from a ClientError.
|
|
48
|
+
* Returns null if the error has no localized message.
|
|
49
|
+
*/
|
|
50
|
+
function extractErrorMessage(error) {
|
|
51
|
+
const firstError = getFirstGraphQLError(error);
|
|
52
|
+
return firstError?.extensions?.['message'] ?? null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if an error has a specific error code.
|
|
56
|
+
*/
|
|
57
|
+
function isErrorCode(error, code) {
|
|
58
|
+
return extractErrorCode(error) === code;
|
|
59
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED FILE — DO NOT EDIT
|
|
3
|
+
*
|
|
4
|
+
* This file was generated by @forgecart/client-sdk-generators.
|
|
5
|
+
* Any manual changes will be overwritten on the next generation run.
|
|
6
|
+
*/
|
|
7
|
+
import type { AddIdentityToSegmentInput, Administrator, Asset, AudienceMembership, AudienceSegment, Channel, ChannelPlugin, Collection, Country, CreateAdministratorInput, CreateAssetInput, CreateAudienceSegmentInput, CreateChannelInput, CreateCollectionInput, CreateCountryInput, CreateCustomerGroupInput, CreateCustomerInput, CreateFacetInput, CreateFacetValueInput, CreateFulfillmentInput, CreateProductInput, CreateProductVariantInput, CreatePromotionInput, CreateRoleInput, CreateSellerInput, CreateStockLocationInput, CreateTaxCategoryInput, CreateTaxRateInput, CreateZoneInput, Customer, CustomerGroup, Facet, FacetValue, Fulfillment, HistoryEntry, Order, Product, ProductVariant, Promotion, RegisterCustomerInput, RemoveIdentityFromSegmentInput, Role, Seller, StockLocation, TaxCategory, TaxRate, UpdateAdministratorInput, UpdateAssetInput, UpdateAudienceSegmentInput, UpdateChannelInput, UpdateChannelPluginConfigInput, UpdateCollectionInput, UpdateCountryInput, UpdateCustomerGroupInput, UpdateCustomerInput, UpdateFacetInput, UpdateFacetValueInput, UpdateProductInput, UpdateProductVariantInput, UpdatePromotionInput, UpdateRoleInput, UpdateSellerInput, UpdateStockLocationInput, UpdateTaxCategoryInput, UpdateTaxRateInput, UpdateZoneInput, Zone } from './admin-types.generated';
|
|
8
|
+
import type { TransactionContext } from './client.generated';
|
|
9
|
+
export interface AdminHookEventMap {
|
|
10
|
+
'asset.create.before': CreateAssetInput;
|
|
11
|
+
'asset.create.after': Asset;
|
|
12
|
+
'asset.create.async': Asset;
|
|
13
|
+
'asset.update.before': UpdateAssetInput;
|
|
14
|
+
'asset.update.after': Asset;
|
|
15
|
+
'asset.update.async': Asset;
|
|
16
|
+
'asset.executeSingleAssetDelete.before': void;
|
|
17
|
+
'asset.executeSingleAssetDelete.after': Asset;
|
|
18
|
+
'asset.executeSingleAssetDelete.async': Asset;
|
|
19
|
+
'asset.createFromUrl.before': string;
|
|
20
|
+
'asset.createFromUrl.after': Asset;
|
|
21
|
+
'asset.createFromUrl.async': Asset;
|
|
22
|
+
'administrator.create.before': CreateAdministratorInput;
|
|
23
|
+
'administrator.create.after': Administrator;
|
|
24
|
+
'administrator.create.async': Administrator;
|
|
25
|
+
'administrator.update.before': UpdateAdministratorInput;
|
|
26
|
+
'administrator.update.after': Administrator;
|
|
27
|
+
'administrator.update.async': Administrator;
|
|
28
|
+
'administrator.softDelete.before': string;
|
|
29
|
+
'administrator.softDelete.after': Administrator;
|
|
30
|
+
'administrator.softDelete.async': Administrator;
|
|
31
|
+
'administrator.inviteExistingUser.before': void;
|
|
32
|
+
'administrator.inviteExistingUser.after': Administrator;
|
|
33
|
+
'administrator.inviteExistingUser.async': Administrator;
|
|
34
|
+
'administrator.inviteNewUser.before': void;
|
|
35
|
+
'administrator.inviteNewUser.after': Administrator;
|
|
36
|
+
'administrator.inviteNewUser.async': Administrator;
|
|
37
|
+
'authentication.attemptLogin.before': unknown;
|
|
38
|
+
'authentication.attemptLogin.after': unknown;
|
|
39
|
+
'authentication.attemptLogin.async': unknown;
|
|
40
|
+
'role.create.before': CreateRoleInput;
|
|
41
|
+
'role.create.after': Role;
|
|
42
|
+
'role.create.async': Role;
|
|
43
|
+
'role.update.before': UpdateRoleInput;
|
|
44
|
+
'role.update.after': Role;
|
|
45
|
+
'role.update.async': Role;
|
|
46
|
+
'role.executeRoleDelete.before': void;
|
|
47
|
+
'role.executeRoleDelete.after': Role;
|
|
48
|
+
'role.executeRoleDelete.async': Role;
|
|
49
|
+
'collection.create.before': CreateCollectionInput;
|
|
50
|
+
'collection.create.after': Collection;
|
|
51
|
+
'collection.create.async': Collection;
|
|
52
|
+
'collection.update.before': UpdateCollectionInput;
|
|
53
|
+
'collection.update.after': Collection;
|
|
54
|
+
'collection.update.async': Collection;
|
|
55
|
+
'collection.executeCollectionDelete.before': void;
|
|
56
|
+
'collection.executeCollectionDelete.after': Collection;
|
|
57
|
+
'collection.executeCollectionDelete.async': Collection;
|
|
58
|
+
'facet.create.before': CreateFacetInput;
|
|
59
|
+
'facet.create.after': Facet;
|
|
60
|
+
'facet.create.async': Facet;
|
|
61
|
+
'facet.update.before': UpdateFacetInput;
|
|
62
|
+
'facet.update.after': Facet;
|
|
63
|
+
'facet.update.async': Facet;
|
|
64
|
+
'facet.executeFacetDelete.before': void;
|
|
65
|
+
'facet.executeFacetDelete.after': Facet;
|
|
66
|
+
'facet.executeFacetDelete.async': Facet;
|
|
67
|
+
'facetValue.create.before': CreateFacetValueInput;
|
|
68
|
+
'facetValue.create.after': FacetValue;
|
|
69
|
+
'facetValue.create.async': FacetValue;
|
|
70
|
+
'facetValue.update.before': UpdateFacetValueInput;
|
|
71
|
+
'facetValue.update.after': FacetValue;
|
|
72
|
+
'facetValue.update.async': FacetValue;
|
|
73
|
+
'facetValue.executeFacetValueDelete.before': void;
|
|
74
|
+
'facetValue.executeFacetValueDelete.after': FacetValue;
|
|
75
|
+
'facetValue.executeFacetValueDelete.async': FacetValue;
|
|
76
|
+
'channel.create.before': CreateChannelInput;
|
|
77
|
+
'channel.create.after': Channel;
|
|
78
|
+
'channel.create.async': Channel;
|
|
79
|
+
'channel.update.before': UpdateChannelInput;
|
|
80
|
+
'channel.update.after': Channel;
|
|
81
|
+
'channel.update.async': Channel;
|
|
82
|
+
'channel.delete.before': string;
|
|
83
|
+
'channel.delete.after': Channel;
|
|
84
|
+
'channel.delete.async': Channel;
|
|
85
|
+
'customer.create.before': CreateCustomerInput;
|
|
86
|
+
'customer.create.after': Customer;
|
|
87
|
+
'customer.create.async': Customer;
|
|
88
|
+
'customer.update.before': UpdateCustomerInput;
|
|
89
|
+
'customer.update.after': Customer;
|
|
90
|
+
'customer.update.async': Customer;
|
|
91
|
+
'customer.performSoftDelete.before': string;
|
|
92
|
+
'customer.performSoftDelete.after': Customer;
|
|
93
|
+
'customer.performSoftDelete.async': Customer;
|
|
94
|
+
'customer.registerCustomerAccount.before': RegisterCustomerInput;
|
|
95
|
+
'customer.registerCustomerAccount.after': Customer;
|
|
96
|
+
'customer.registerCustomerAccount.async': Customer;
|
|
97
|
+
'customer.createCustomerForRegistration.before': void;
|
|
98
|
+
'customer.createCustomerForRegistration.after': Customer;
|
|
99
|
+
'customer.createCustomerForRegistration.async': Customer;
|
|
100
|
+
'customerGroup.create.before': CreateCustomerGroupInput;
|
|
101
|
+
'customerGroup.create.after': CustomerGroup;
|
|
102
|
+
'customerGroup.create.async': CustomerGroup;
|
|
103
|
+
'customerGroup.update.before': UpdateCustomerGroupInput;
|
|
104
|
+
'customerGroup.update.after': CustomerGroup;
|
|
105
|
+
'customerGroup.update.async': CustomerGroup;
|
|
106
|
+
'customerGroup.executeCustomerGroupDelete.before': void;
|
|
107
|
+
'customerGroup.executeCustomerGroupDelete.after': CustomerGroup;
|
|
108
|
+
'customerGroup.executeCustomerGroupDelete.async': CustomerGroup;
|
|
109
|
+
'country.create.before': CreateCountryInput;
|
|
110
|
+
'country.create.after': Country;
|
|
111
|
+
'country.create.async': Country;
|
|
112
|
+
'country.update.before': UpdateCountryInput;
|
|
113
|
+
'country.update.after': Country;
|
|
114
|
+
'country.update.async': Country;
|
|
115
|
+
'country.executeCountryDelete.before': void;
|
|
116
|
+
'country.executeCountryDelete.after': Country;
|
|
117
|
+
'country.executeCountryDelete.async': Country;
|
|
118
|
+
'zone.create.before': CreateZoneInput;
|
|
119
|
+
'zone.create.after': Zone;
|
|
120
|
+
'zone.create.async': Zone;
|
|
121
|
+
'zone.update.before': UpdateZoneInput;
|
|
122
|
+
'zone.update.after': Zone;
|
|
123
|
+
'zone.update.async': Zone;
|
|
124
|
+
'zone.delete.before': string;
|
|
125
|
+
'zone.delete.after': Zone;
|
|
126
|
+
'zone.delete.async': Zone;
|
|
127
|
+
'product.create.before': CreateProductInput;
|
|
128
|
+
'product.create.after': Product;
|
|
129
|
+
'product.create.async': Product;
|
|
130
|
+
'product.update.before': UpdateProductInput;
|
|
131
|
+
'product.update.after': Product;
|
|
132
|
+
'product.update.async': Product;
|
|
133
|
+
'product.executeProductDelete.before': void;
|
|
134
|
+
'product.executeProductDelete.after': Product;
|
|
135
|
+
'product.executeProductDelete.async': Product;
|
|
136
|
+
'productVariant.createSingleVariant.before': CreateProductVariantInput;
|
|
137
|
+
'productVariant.createSingleVariant.after': ProductVariant;
|
|
138
|
+
'productVariant.createSingleVariant.async': ProductVariant;
|
|
139
|
+
'productVariant.updateSingleVariant.before': UpdateProductVariantInput;
|
|
140
|
+
'productVariant.updateSingleVariant.after': ProductVariant;
|
|
141
|
+
'productVariant.updateSingleVariant.async': ProductVariant;
|
|
142
|
+
'productVariant.deleteSingleVariant.before': string;
|
|
143
|
+
'productVariant.deleteSingleVariant.after': ProductVariant;
|
|
144
|
+
'productVariant.deleteSingleVariant.async': ProductVariant;
|
|
145
|
+
'promotion.create.before': CreatePromotionInput;
|
|
146
|
+
'promotion.create.after': Promotion;
|
|
147
|
+
'promotion.create.async': Promotion;
|
|
148
|
+
'promotion.update.before': UpdatePromotionInput;
|
|
149
|
+
'promotion.update.after': Promotion;
|
|
150
|
+
'promotion.update.async': Promotion;
|
|
151
|
+
'promotion.executePromotionDelete.before': void;
|
|
152
|
+
'promotion.executePromotionDelete.after': Promotion;
|
|
153
|
+
'promotion.executePromotionDelete.async': Promotion;
|
|
154
|
+
'seller.create.before': CreateSellerInput;
|
|
155
|
+
'seller.create.after': Seller;
|
|
156
|
+
'seller.create.async': Seller;
|
|
157
|
+
'seller.update.before': UpdateSellerInput;
|
|
158
|
+
'seller.update.after': Seller;
|
|
159
|
+
'seller.update.async': Seller;
|
|
160
|
+
'seller.softDelete.before': string;
|
|
161
|
+
'seller.softDelete.after': Seller;
|
|
162
|
+
'seller.softDelete.async': Seller;
|
|
163
|
+
'stockLocation.create.before': CreateStockLocationInput;
|
|
164
|
+
'stockLocation.create.after': StockLocation;
|
|
165
|
+
'stockLocation.create.async': StockLocation;
|
|
166
|
+
'stockLocation.update.before': UpdateStockLocationInput;
|
|
167
|
+
'stockLocation.update.after': StockLocation;
|
|
168
|
+
'stockLocation.update.async': StockLocation;
|
|
169
|
+
'stockLocation.executeStockLocationDelete.before': void;
|
|
170
|
+
'stockLocation.executeStockLocationDelete.after': StockLocation;
|
|
171
|
+
'stockLocation.executeStockLocationDelete.async': StockLocation;
|
|
172
|
+
'taxCategory.create.before': CreateTaxCategoryInput;
|
|
173
|
+
'taxCategory.create.after': TaxCategory;
|
|
174
|
+
'taxCategory.create.async': TaxCategory;
|
|
175
|
+
'taxCategory.update.before': UpdateTaxCategoryInput;
|
|
176
|
+
'taxCategory.update.after': TaxCategory;
|
|
177
|
+
'taxCategory.update.async': TaxCategory;
|
|
178
|
+
'taxCategory.executeTaxCategoryDelete.before': void;
|
|
179
|
+
'taxCategory.executeTaxCategoryDelete.after': TaxCategory;
|
|
180
|
+
'taxCategory.executeTaxCategoryDelete.async': TaxCategory;
|
|
181
|
+
'taxRate.create.before': CreateTaxRateInput;
|
|
182
|
+
'taxRate.create.after': TaxRate;
|
|
183
|
+
'taxRate.create.async': TaxRate;
|
|
184
|
+
'taxRate.update.before': UpdateTaxRateInput;
|
|
185
|
+
'taxRate.update.after': TaxRate;
|
|
186
|
+
'taxRate.update.async': TaxRate;
|
|
187
|
+
'taxRate.delete.before': string;
|
|
188
|
+
'taxRate.delete.after': TaxRate;
|
|
189
|
+
'taxRate.delete.async': TaxRate;
|
|
190
|
+
'fulfillment.createFulfillment.before': CreateFulfillmentInput;
|
|
191
|
+
'fulfillment.createFulfillment.after': Fulfillment;
|
|
192
|
+
'fulfillment.createFulfillment.async': Fulfillment;
|
|
193
|
+
'fulfillment.executeFulfillmentTransition.before': unknown;
|
|
194
|
+
'fulfillment.executeFulfillmentTransition.after': unknown;
|
|
195
|
+
'fulfillment.executeFulfillmentTransition.async': unknown;
|
|
196
|
+
'order.createDraft.before': void;
|
|
197
|
+
'order.createDraft.after': Order;
|
|
198
|
+
'order.createDraft.async': Order;
|
|
199
|
+
'order.create.before': void;
|
|
200
|
+
'order.create.after': Order;
|
|
201
|
+
'order.create.async': Order;
|
|
202
|
+
'payment.executePaymentTransition.before': unknown;
|
|
203
|
+
'payment.executePaymentTransition.after': unknown;
|
|
204
|
+
'payment.executePaymentTransition.async': unknown;
|
|
205
|
+
'channelPlugin.enable.before': string;
|
|
206
|
+
'channelPlugin.enable.after': ChannelPlugin;
|
|
207
|
+
'channelPlugin.enable.async': ChannelPlugin;
|
|
208
|
+
'channelPlugin.disable.before': string;
|
|
209
|
+
'channelPlugin.disable.after': ChannelPlugin;
|
|
210
|
+
'channelPlugin.disable.async': ChannelPlugin;
|
|
211
|
+
'channelPlugin.updateConfiguration.before': UpdateChannelPluginConfigInput;
|
|
212
|
+
'channelPlugin.updateConfiguration.after': ChannelPlugin;
|
|
213
|
+
'channelPlugin.updateConfiguration.async': ChannelPlugin;
|
|
214
|
+
'history.createForOrder.before': unknown;
|
|
215
|
+
'history.createForOrder.after': HistoryEntry;
|
|
216
|
+
'history.createForOrder.async': HistoryEntry;
|
|
217
|
+
'history.createForCustomer.before': unknown;
|
|
218
|
+
'history.createForCustomer.after': HistoryEntry;
|
|
219
|
+
'history.createForCustomer.async': HistoryEntry;
|
|
220
|
+
'history.updateEntry.before': unknown;
|
|
221
|
+
'history.updateEntry.after': HistoryEntry;
|
|
222
|
+
'history.updateEntry.async': HistoryEntry;
|
|
223
|
+
'history.deleteEntry.before': string;
|
|
224
|
+
'history.deleteEntry.after': HistoryEntry;
|
|
225
|
+
'history.deleteEntry.async': HistoryEntry;
|
|
226
|
+
'audienceSegment.create.before': CreateAudienceSegmentInput;
|
|
227
|
+
'audienceSegment.create.after': AudienceSegment;
|
|
228
|
+
'audienceSegment.create.async': AudienceSegment;
|
|
229
|
+
'audienceSegment.update.before': UpdateAudienceSegmentInput;
|
|
230
|
+
'audienceSegment.update.after': AudienceSegment;
|
|
231
|
+
'audienceSegment.update.async': AudienceSegment;
|
|
232
|
+
'audienceSegment.delete.before': string;
|
|
233
|
+
'audienceSegment.delete.after': AudienceSegment;
|
|
234
|
+
'audienceSegment.delete.async': AudienceSegment;
|
|
235
|
+
'audienceMembership.addIdentityToSegment.before': AddIdentityToSegmentInput;
|
|
236
|
+
'audienceMembership.addIdentityToSegment.after': AudienceMembership;
|
|
237
|
+
'audienceMembership.addIdentityToSegment.async': AudienceMembership;
|
|
238
|
+
'audienceMembership.removeIdentityFromSegment.before': RemoveIdentityFromSegmentInput;
|
|
239
|
+
'audienceMembership.removeIdentityFromSegment.after': AudienceMembership;
|
|
240
|
+
'audienceMembership.removeIdentityFromSegment.async': AudienceMembership;
|
|
241
|
+
}
|
|
242
|
+
export type AdminHookPoint = keyof AdminHookEventMap;
|
|
243
|
+
export type AdminHookHandler<K extends AdminHookPoint> = AdminHookEventMap[K] extends void ? (ctx: TransactionContext) => Promise<void> : (ctx: TransactionContext, payload: AdminHookEventMap[K]) => Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* AUTO-GENERATED FILE — DO NOT EDIT
|
|
5
|
+
*
|
|
6
|
+
* This file was generated by @forgecart/client-sdk-generators.
|
|
7
|
+
* Any manual changes will be overwritten on the next generation run.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,59 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/** Custom HTTP headers */
|
|
24
|
-
headers?: Record<string, string>;
|
|
25
|
-
/** Custom WebSocket implementation (optional, auto-detected if not provided) */
|
|
26
|
-
webSocketImpl?: unknown;
|
|
27
|
-
}
|
|
28
|
-
export type { AdminSDKConfig, ShopSDKConfig };
|
|
29
|
-
export { AdminNamespace, ShopNamespace };
|
|
30
|
-
/**
|
|
31
|
-
* ForgeCartSDK
|
|
32
|
-
* Unified SDK with categorized operations across multiple namespaces
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* const sdk = new ForgeCartSDK({
|
|
37
|
-
* endpoint: 'https://api.forgecart.com',
|
|
38
|
-
* token: 'your-channel-token',
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* // Admin namespace → Category → Operations
|
|
42
|
-
* await sdk.admin.products.products({ take: 10 });
|
|
43
|
-
* await sdk.admin.customer.customer({ id: '1' });
|
|
44
|
-
*
|
|
45
|
-
* // Shop namespace → Category → Operations
|
|
46
|
-
* await sdk.shop.products.products({ take: 10 });
|
|
47
|
-
* await sdk.shop.order.addItemToOrder({ productVariantId: '1', quantity: 1 });
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare class ForgeCartSDK {
|
|
51
|
-
readonly admin: AdminNamespace;
|
|
52
|
-
readonly shop: ShopNamespace;
|
|
53
|
-
constructor(config: ForgeCartSDKConfig);
|
|
54
|
-
setAdminAuthToken(token: string): void;
|
|
55
|
-
clearAdminAuthToken(): void;
|
|
56
|
-
setShopAuthToken(token: string): void;
|
|
57
|
-
clearShopAuthToken(): void;
|
|
58
|
-
dispose(): void;
|
|
59
|
-
}
|
|
1
|
+
export { ForgeCartAdminClient } from './client.generated';
|
|
2
|
+
export { ForgeCartShopClient } from './client.generated';
|
|
3
|
+
export { ForgeCartClient, ClientError, QueryObservable } from './client.generated';
|
|
4
|
+
export type { GraphQLErrorResponse } from './client.generated';
|
|
5
|
+
export type { ForgeCartAdminClientConfig } from './client.generated';
|
|
6
|
+
export type { ForgeCartShopClientConfig } from './client.generated';
|
|
7
|
+
export type { ForgeCartClientConfig } from './client.generated';
|
|
8
|
+
export { TransactionContext } from './client.generated';
|
|
9
|
+
export { AdminNamespace } from './admin.generated';
|
|
10
|
+
export { ShopNamespace } from './shop.generated';
|
|
11
|
+
export type { ID, Type, ApiExtension, IRequestContext, HookHandler } from './sdk-types.generated';
|
|
12
|
+
export type { IFulfillmentHandler, FulfillmentHandlerCapabilities, OrderLineInput } from './sdk-types.generated';
|
|
13
|
+
export { SdkError, SdkErrorCode } from './sdk-types.generated';
|
|
14
|
+
export type { ConfigurationItem, ManageableConfig, IHookRegistry } from './sdk-plugin.generated';
|
|
15
|
+
export { ForgeCartPlugin } from './sdk-plugin.generated';
|
|
16
|
+
export type { HookDispatchEvent, HookSubscription } from './sdk-hook-subscription.generated';
|
|
17
|
+
export { hookDispatchDocument, hookRespondDocument, HookSubscriptionManager } from './sdk-hook-subscription.generated';
|
|
18
|
+
export type { AdminHookEventMap, AdminHookPoint, AdminHookHandler } from './hook-event-map.generated';
|
|
19
|
+
export type { AcfFieldType } from './admin-types.generated';
|
|
20
|
+
export { extractErrorCode, extractError, extractErrorMessage, isErrorCode } from './error-utils';
|
|
21
|
+
export type { ExtractedError } from './error-utils';
|
|
22
|
+
export { Observable, firstValueFrom, lastValueFrom } from 'rxjs';
|
package/dist/index.js
CHANGED
|
@@ -1,85 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @forgecart/sdk - Auto-generated TypeScript SDK
|
|
4
|
-
*
|
|
5
|
-
* This file was automatically generated and should not be manually edited.
|
|
6
|
-
* To regenerate, run: npm run codegen:ts
|
|
7
|
-
*
|
|
8
|
-
* 🤖 Generated with ForgeCart SDK Generator
|
|
9
|
-
*/
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Build headers with token
|
|
45
|
-
const headers = {
|
|
46
|
-
...config.headers,
|
|
47
|
-
'forge-token': config.token,
|
|
48
|
-
};
|
|
49
|
-
const adminConfig = {
|
|
50
|
-
endpoint: `${baseEndpoint}/admin-api`,
|
|
51
|
-
wsEndpoint: `${baseWsEndpoint}/admin-api`,
|
|
52
|
-
headers,
|
|
53
|
-
webSocketImpl: config.webSocketImpl,
|
|
54
|
-
httpOnly: config.httpOnly,
|
|
55
|
-
debug: config.debug,
|
|
56
|
-
};
|
|
57
|
-
this.admin = new admin_js_1.AdminNamespace(adminConfig);
|
|
58
|
-
const shopConfig = {
|
|
59
|
-
endpoint: `${baseEndpoint}/shop-api`,
|
|
60
|
-
wsEndpoint: `${baseWsEndpoint}/shop-api`,
|
|
61
|
-
headers,
|
|
62
|
-
webSocketImpl: config.webSocketImpl,
|
|
63
|
-
httpOnly: config.httpOnly,
|
|
64
|
-
debug: config.debug,
|
|
65
|
-
};
|
|
66
|
-
this.shop = new shop_js_1.ShopNamespace(shopConfig);
|
|
67
|
-
}
|
|
68
|
-
setAdminAuthToken(token) {
|
|
69
|
-
this.admin.setAuthToken(token);
|
|
70
|
-
}
|
|
71
|
-
clearAdminAuthToken() {
|
|
72
|
-
this.admin.clearAuthToken();
|
|
73
|
-
}
|
|
74
|
-
setShopAuthToken(token) {
|
|
75
|
-
this.shop.setAuthToken(token);
|
|
76
|
-
}
|
|
77
|
-
clearShopAuthToken() {
|
|
78
|
-
this.shop.clearAuthToken();
|
|
79
|
-
}
|
|
80
|
-
dispose() {
|
|
81
|
-
this.admin.dispose();
|
|
82
|
-
this.shop.dispose();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.ForgeCartSDK = ForgeCartSDK;
|
|
3
|
+
exports.lastValueFrom = exports.firstValueFrom = exports.Observable = exports.isErrorCode = exports.extractErrorMessage = exports.extractError = exports.extractErrorCode = exports.HookSubscriptionManager = exports.hookRespondDocument = exports.hookDispatchDocument = exports.ForgeCartPlugin = exports.SdkErrorCode = exports.SdkError = exports.ShopNamespace = exports.AdminNamespace = exports.TransactionContext = exports.QueryObservable = exports.ClientError = exports.ForgeCartClient = exports.ForgeCartShopClient = exports.ForgeCartAdminClient = void 0;
|
|
4
|
+
var client_generated_1 = require("./client.generated");
|
|
5
|
+
Object.defineProperty(exports, "ForgeCartAdminClient", { enumerable: true, get: function () { return client_generated_1.ForgeCartAdminClient; } });
|
|
6
|
+
var client_generated_2 = require("./client.generated");
|
|
7
|
+
Object.defineProperty(exports, "ForgeCartShopClient", { enumerable: true, get: function () { return client_generated_2.ForgeCartShopClient; } });
|
|
8
|
+
var client_generated_3 = require("./client.generated");
|
|
9
|
+
Object.defineProperty(exports, "ForgeCartClient", { enumerable: true, get: function () { return client_generated_3.ForgeCartClient; } });
|
|
10
|
+
Object.defineProperty(exports, "ClientError", { enumerable: true, get: function () { return client_generated_3.ClientError; } });
|
|
11
|
+
Object.defineProperty(exports, "QueryObservable", { enumerable: true, get: function () { return client_generated_3.QueryObservable; } });
|
|
12
|
+
var client_generated_4 = require("./client.generated");
|
|
13
|
+
Object.defineProperty(exports, "TransactionContext", { enumerable: true, get: function () { return client_generated_4.TransactionContext; } });
|
|
14
|
+
var admin_generated_1 = require("./admin.generated");
|
|
15
|
+
Object.defineProperty(exports, "AdminNamespace", { enumerable: true, get: function () { return admin_generated_1.AdminNamespace; } });
|
|
16
|
+
var shop_generated_1 = require("./shop.generated");
|
|
17
|
+
Object.defineProperty(exports, "ShopNamespace", { enumerable: true, get: function () { return shop_generated_1.ShopNamespace; } });
|
|
18
|
+
var sdk_types_generated_1 = require("./sdk-types.generated");
|
|
19
|
+
Object.defineProperty(exports, "SdkError", { enumerable: true, get: function () { return sdk_types_generated_1.SdkError; } });
|
|
20
|
+
Object.defineProperty(exports, "SdkErrorCode", { enumerable: true, get: function () { return sdk_types_generated_1.SdkErrorCode; } });
|
|
21
|
+
var sdk_plugin_generated_1 = require("./sdk-plugin.generated");
|
|
22
|
+
Object.defineProperty(exports, "ForgeCartPlugin", { enumerable: true, get: function () { return sdk_plugin_generated_1.ForgeCartPlugin; } });
|
|
23
|
+
var sdk_hook_subscription_generated_1 = require("./sdk-hook-subscription.generated");
|
|
24
|
+
Object.defineProperty(exports, "hookDispatchDocument", { enumerable: true, get: function () { return sdk_hook_subscription_generated_1.hookDispatchDocument; } });
|
|
25
|
+
Object.defineProperty(exports, "hookRespondDocument", { enumerable: true, get: function () { return sdk_hook_subscription_generated_1.hookRespondDocument; } });
|
|
26
|
+
Object.defineProperty(exports, "HookSubscriptionManager", { enumerable: true, get: function () { return sdk_hook_subscription_generated_1.HookSubscriptionManager; } });
|
|
27
|
+
var error_utils_1 = require("./error-utils");
|
|
28
|
+
Object.defineProperty(exports, "extractErrorCode", { enumerable: true, get: function () { return error_utils_1.extractErrorCode; } });
|
|
29
|
+
Object.defineProperty(exports, "extractError", { enumerable: true, get: function () { return error_utils_1.extractError; } });
|
|
30
|
+
Object.defineProperty(exports, "extractErrorMessage", { enumerable: true, get: function () { return error_utils_1.extractErrorMessage; } });
|
|
31
|
+
Object.defineProperty(exports, "isErrorCode", { enumerable: true, get: function () { return error_utils_1.isErrorCode; } });
|
|
32
|
+
var rxjs_1 = require("rxjs");
|
|
33
|
+
Object.defineProperty(exports, "Observable", { enumerable: true, get: function () { return rxjs_1.Observable; } });
|
|
34
|
+
Object.defineProperty(exports, "firstValueFrom", { enumerable: true, get: function () { return rxjs_1.firstValueFrom; } });
|
|
35
|
+
Object.defineProperty(exports, "lastValueFrom", { enumerable: true, get: function () { return rxjs_1.lastValueFrom; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED FILE — DO NOT EDIT
|
|
3
|
+
*
|
|
4
|
+
* This file was generated by @forgecart/client-sdk-generators.
|
|
5
|
+
* Any manual changes will be overwritten on the next generation run.
|
|
6
|
+
*/
|
|
7
|
+
import { type DynamicModule } from '@nestjs/common';
|
|
8
|
+
import type { ForgeCartClientConfig, ForgeCartAdminClientConfig, ForgeCartShopClientConfig } from './client.generated';
|
|
9
|
+
export declare class ForgeCartGraphQLModule {
|
|
10
|
+
static forAdmin(config: ForgeCartAdminClientConfig): DynamicModule;
|
|
11
|
+
static forShop(config: ForgeCartShopClientConfig): DynamicModule;
|
|
12
|
+
static forRoot(config: ForgeCartClientConfig): DynamicModule;
|
|
13
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* AUTO-GENERATED FILE — DO NOT EDIT
|
|
5
|
+
*
|
|
6
|
+
* This file was generated by @forgecart/client-sdk-generators.
|
|
7
|
+
* Any manual changes will be overwritten on the next generation run.
|
|
8
|
+
*/
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
37
|
+
var useValue = arguments.length > 2;
|
|
38
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
39
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
40
|
+
}
|
|
41
|
+
return useValue ? value : void 0;
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.ForgeCartGraphQLModule = void 0;
|
|
45
|
+
const common_1 = require("@nestjs/common");
|
|
46
|
+
const client_generated_1 = require("./client.generated");
|
|
47
|
+
let ForgeCartGraphQLModule = (() => {
|
|
48
|
+
let _classDecorators = [(0, common_1.Module)({})];
|
|
49
|
+
let _classDescriptor;
|
|
50
|
+
let _classExtraInitializers = [];
|
|
51
|
+
let _classThis;
|
|
52
|
+
var ForgeCartGraphQLModule = class {
|
|
53
|
+
static { _classThis = this; }
|
|
54
|
+
static {
|
|
55
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
56
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
57
|
+
ForgeCartGraphQLModule = _classThis = _classDescriptor.value;
|
|
58
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
59
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
60
|
+
}
|
|
61
|
+
static forAdmin(config) {
|
|
62
|
+
const client = new client_generated_1.ForgeCartAdminClient(config);
|
|
63
|
+
return {
|
|
64
|
+
module: ForgeCartGraphQLModule,
|
|
65
|
+
providers: [{ provide: client_generated_1.ForgeCartAdminClient, useValue: client }],
|
|
66
|
+
exports: [client_generated_1.ForgeCartAdminClient],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static forShop(config) {
|
|
70
|
+
const client = new client_generated_1.ForgeCartShopClient(config);
|
|
71
|
+
return {
|
|
72
|
+
module: ForgeCartGraphQLModule,
|
|
73
|
+
providers: [{ provide: client_generated_1.ForgeCartShopClient, useValue: client }],
|
|
74
|
+
exports: [client_generated_1.ForgeCartShopClient],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static forRoot(config) {
|
|
78
|
+
const client = new client_generated_1.ForgeCartClient(config);
|
|
79
|
+
return {
|
|
80
|
+
module: ForgeCartGraphQLModule,
|
|
81
|
+
providers: [
|
|
82
|
+
{ provide: client_generated_1.ForgeCartClient, useValue: client },
|
|
83
|
+
{ provide: client_generated_1.ForgeCartAdminClient, useValue: client.admin },
|
|
84
|
+
{ provide: client_generated_1.ForgeCartShopClient, useValue: client.shop },
|
|
85
|
+
],
|
|
86
|
+
exports: [client_generated_1.ForgeCartClient, client_generated_1.ForgeCartAdminClient, client_generated_1.ForgeCartShopClient],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return ForgeCartGraphQLModule = _classThis;
|
|
91
|
+
})();
|
|
92
|
+
exports.ForgeCartGraphQLModule = ForgeCartGraphQLModule;
|