@longvansoftware/storefront-js-client 0.0.3 → 1.0.1

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.
Files changed (64) hide show
  1. package/dist/config/config.d.ts +18 -0
  2. package/dist/config/config.js +21 -0
  3. package/dist/{constants/graphql/mutations/crmMutations.d.ts → src/graphql/crm/mutations.d.ts} +0 -2
  4. package/dist/{constants/graphql/mutations/crmMutations.js → src/graphql/crm/mutations.js} +1 -111
  5. package/dist/src/graphql/crm/queries.d.ts +3 -0
  6. package/dist/src/graphql/crm/queries.js +155 -0
  7. package/dist/src/graphql/payment/mutations.d.ts +1 -0
  8. package/dist/src/graphql/payment/mutations.js +35 -0
  9. package/dist/src/graphql/payment/queries.d.ts +1 -0
  10. package/dist/src/graphql/payment/queries.js +12 -0
  11. package/dist/src/graphql/product/mutations.d.ts +0 -0
  12. package/dist/src/graphql/product/mutations.js +1 -0
  13. package/dist/{constants/graphql/queries/productQueries.d.ts → src/graphql/product/queries.d.ts} +2 -1
  14. package/dist/src/graphql/product/queries.js +415 -0
  15. package/dist/{constants/graphql/mutations/userMutations.d.ts → src/graphql/user/mutations.d.ts} +0 -1
  16. package/dist/{constants/graphql/mutations/userMutations.js → src/graphql/user/mutations.js} +4 -33
  17. package/dist/src/graphql/user/queries.d.ts +3 -0
  18. package/dist/src/graphql/user/queries.js +67 -0
  19. package/dist/src/index.d.ts +1 -0
  20. package/dist/src/index.js +5 -0
  21. package/dist/src/lib/SDK.d.ts +28 -0
  22. package/dist/src/lib/SDK.js +43 -0
  23. package/dist/src/lib/auth/index.d.ts +26 -0
  24. package/dist/src/lib/auth/index.js +54 -0
  25. package/dist/src/lib/crm/index.d.ts +14 -0
  26. package/dist/src/lib/crm/index.js +185 -0
  27. package/dist/src/lib/order/index.d.ts +87 -0
  28. package/dist/src/lib/order/index.js +209 -0
  29. package/dist/src/lib/payment/index.d.ts +6 -0
  30. package/dist/src/lib/payment/index.js +50 -0
  31. package/dist/src/lib/product/index.d.ts +36 -0
  32. package/dist/src/lib/product/index.js +116 -0
  33. package/dist/src/lib/service.d.ts +14 -0
  34. package/dist/src/lib/service.js +97 -0
  35. package/dist/src/lib/user/index.d.ts +11 -0
  36. package/dist/src/lib/user/index.js +135 -0
  37. package/dist/{constants/interfaces → src/types}/crm.d.ts +1 -0
  38. package/dist/src/types/order.d.ts +7 -0
  39. package/dist/src/types/user.js +2 -0
  40. package/dist/src/utils/helpers.d.ts +4 -0
  41. package/dist/src/utils/helpers.js +41 -0
  42. package/package.json +25 -19
  43. package/dist/constants/graphql/queries/crmQueries.d.ts +0 -1
  44. package/dist/constants/graphql/queries/crmQueries.js +0 -45
  45. package/dist/constants/graphql/queries/productQueries.js +0 -368
  46. package/dist/index.d.ts +0 -19
  47. package/dist/index.js +0 -17
  48. package/dist/modules/authorization/graphql.d.ts +0 -15
  49. package/dist/modules/authorization/graphql.js +0 -116
  50. package/dist/modules/crm/graphql.d.ts +0 -19
  51. package/dist/modules/crm/graphql.js +0 -291
  52. package/dist/modules/product/graphql.d.ts +0 -19
  53. package/dist/modules/product/graphql.js +0 -180
  54. package/dist/modules/user/graphql.d.ts +0 -14
  55. package/dist/modules/user/graphql.js +0 -156
  56. /package/dist/{constants/graphql/mutations/authorizationMutations.d.ts → src/graphql/auth/mutations.d.ts} +0 -0
  57. /package/dist/{constants/graphql/mutations/authorizationMutations.js → src/graphql/auth/mutations.js} +0 -0
  58. /package/dist/{constants/interfaces/authorization.d.ts → src/types/auth.d.ts} +0 -0
  59. /package/dist/{constants/interfaces/authorization.js → src/types/auth.js} +0 -0
  60. /package/dist/{constants/interfaces → src/types}/crm.js +0 -0
  61. /package/dist/{constants/interfaces/product.js → src/types/order.js} +0 -0
  62. /package/dist/{constants/interfaces → src/types}/product.d.ts +0 -0
  63. /package/dist/{constants/interfaces/user.js → src/types/product.js} +0 -0
  64. /package/dist/{constants/interfaces → src/types}/user.d.ts +0 -0
@@ -0,0 +1,415 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_PRODUCT_OPTION = exports.GET_BRAND_DETAIL_QUERY = exports.GET_BRANDS_BY_CATEGORY_QUERY = exports.GET_BRANDS_QUERY = exports.GET_CATEGORY_BY_ID_QUERY = exports.GET_CATEGORY_BY_HANDLE_QUERY = exports.GET_CATEGORIES_QUERY = exports.GET_SIMPLE_PRODUCTS_QUERY = exports.GET_PRODUCT_BY_SLUG_QUERY = exports.GET_PRODUCT_BY_ID_QUERY = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ // export const GET_PRODUCT_BY_ID_QUERY = gql`
6
+ // query GetProductById(
7
+ // $partnerId: String!
8
+ // $storeChannel: String!
9
+ // $productId: String!
10
+ // ) {
11
+ // getProductById(
12
+ // partnerId: $partnerId
13
+ // storeChannel: $storeChannel
14
+ // productId: $productId
15
+ // ) {
16
+ // title
17
+ // id
18
+ // description
19
+ // sku
20
+ // shortDescription
21
+ // weight
22
+ // width
23
+ // height
24
+ // vat
25
+ // unit
26
+ // qualify
27
+ // parentId
28
+ // handle
29
+ // price
30
+ // priceVaries
31
+ // available
32
+ // options
33
+ // compareAtPrice
34
+ // featuredImage
35
+ // images
36
+ // createdAt
37
+ // favorite
38
+ // productAttributes {
39
+ // id
40
+ // productId
41
+ // attributeName
42
+ // attributeValue
43
+ // }
44
+ // variants {
45
+ // id
46
+ // handle
47
+ // title
48
+ // price
49
+ // weight
50
+ // width
51
+ // depth
52
+ // height
53
+ // compareAtPrice
54
+ // available
55
+ // option1
56
+ // option2
57
+ // option3
58
+ // options
59
+ // weightUnit
60
+ // optionsIds
61
+ // featuredImage
62
+ // sku
63
+ // qualify
64
+ // featureTypeDTOS {
65
+ // id
66
+ // name
67
+ // position
68
+ // values
69
+ // required
70
+ // valuesFull
71
+ // enable
72
+ // }
73
+ // }
74
+ // featureTypes {
75
+ // id
76
+ // name
77
+ // position
78
+ // values
79
+ // required
80
+ // valuesFull
81
+ // enable
82
+ // }
83
+ // categories {
84
+ // id
85
+ // title
86
+ // handle
87
+ // description
88
+ // }
89
+ // }
90
+ // }
91
+ // `;
92
+ exports.GET_PRODUCT_BY_ID_QUERY = (0, graphql_tag_1.gql) `
93
+ query GetProductById(
94
+ $partnerId: String!
95
+ $storeChannel: String!
96
+ $productId: String!
97
+ ) {
98
+ getProductById(
99
+ partnerId: $partnerId
100
+ storeChannel: $storeChannel
101
+ productId: $productId
102
+ ) {
103
+ id
104
+ title
105
+ description
106
+ sku
107
+ shortDescription
108
+ weight
109
+ width
110
+ depth
111
+ height
112
+ vat
113
+ qualify
114
+ parentId
115
+ handle
116
+ price
117
+ options
118
+ optionsRelationship
119
+ compareAtPrice
120
+ featuredImage
121
+ images
122
+ productAttributes {
123
+ attributeName
124
+ attributeValue
125
+ }
126
+ variants {
127
+ id
128
+ handle
129
+ title
130
+ price
131
+ compareAtPrice
132
+ options
133
+ optionsIds
134
+ featuredImage
135
+ sku
136
+ }
137
+ featureTypes {
138
+ id
139
+ name
140
+ values
141
+ }
142
+ categories {
143
+ id
144
+ title
145
+ handle
146
+ }
147
+ }
148
+ }
149
+ `;
150
+ exports.GET_PRODUCT_BY_SLUG_QUERY = (0, graphql_tag_1.gql) `
151
+ query GetProductByHandle(
152
+ $partnerId: String!
153
+ $storeChannel: String!
154
+ $handle: String!
155
+ ) {
156
+ getProductByHandle(
157
+ partnerId: $partnerId
158
+ storeChannel: $storeChannel
159
+ handle: $handle
160
+ ) {
161
+ id
162
+ title
163
+ description
164
+ sku
165
+ shortDescription
166
+ weight
167
+ width
168
+ depth
169
+ height
170
+ vat
171
+ qualify
172
+ parentId
173
+ handle
174
+ price
175
+ options
176
+ optionsRelationship
177
+ compareAtPrice
178
+ featuredImage
179
+ images
180
+ productAttributes {
181
+ attributeName
182
+ attributeValue
183
+ }
184
+ variants {
185
+ id
186
+ handle
187
+ title
188
+ price
189
+ compareAtPrice
190
+ options
191
+ optionsIds
192
+ featuredImage
193
+ sku
194
+ }
195
+ featureTypes {
196
+ id
197
+ name
198
+ values
199
+ }
200
+ categories {
201
+ id
202
+ title
203
+ handle
204
+ }
205
+ }
206
+ }
207
+ `;
208
+ exports.GET_SIMPLE_PRODUCTS_QUERY = (0, graphql_tag_1.gql) `
209
+ query GetSimpleProducts(
210
+ $partnerId: String!
211
+ $storeChannel: String!
212
+ $category: String
213
+ $product: String
214
+ $sku: String
215
+ $tag: String
216
+ $priceFrom: BigDecimal
217
+ $priceTo: BigDecimal
218
+ $status: String
219
+ $productType: String
220
+ $subType: String
221
+ $sortOrder: String
222
+ $sortBy: String
223
+ $brandId: String
224
+ $keyword: String
225
+ $display: String
226
+ $onlyPromotion: Boolean
227
+ $currentPage: Int
228
+ $maxResult: Int
229
+ ) {
230
+ getSimpleProducts(
231
+ partnerId: $partnerId
232
+ storeChannel: $storeChannel
233
+ category: $category
234
+ product: $product
235
+ sku: $sku
236
+ tag: $tag
237
+ priceFrom: $priceFrom
238
+ priceTo: $priceTo
239
+ status: $status
240
+ productType: $productType
241
+ subType: $subType
242
+ sortOrder: $sortOrder
243
+ sortBy: $sortBy
244
+ brandId: $brandId
245
+ keyword: $keyword
246
+ display: $display
247
+ onlyPromotion: $onlyPromotion
248
+ currentPage: $currentPage
249
+ maxResult: $maxResult
250
+ ) {
251
+ total
252
+ currentPage
253
+ maxResult
254
+ totalPage
255
+ data {
256
+ id
257
+ title
258
+ sku
259
+ shortDescription
260
+ vat
261
+ qualify
262
+ handle
263
+ price
264
+ compareAtPrice
265
+ featuredImage
266
+ images
267
+ }
268
+ }
269
+ }
270
+ `;
271
+ exports.GET_CATEGORIES_QUERY = (0, graphql_tag_1.gql) `
272
+ query GetCategories(
273
+ $partnerId: String!
274
+ $storeChannel: String!
275
+ $typeBuild: String!
276
+ $level: Int!
277
+ ) {
278
+ getCategories(
279
+ partnerId: $partnerId
280
+ storeChannel: $storeChannel
281
+ typeBuild: $typeBuild
282
+ level: $level
283
+ ) {
284
+ id
285
+ title
286
+ image
287
+ icon
288
+ parentId
289
+ level
290
+ sequence
291
+ handle
292
+ child {
293
+ id
294
+ title
295
+ image
296
+ icon
297
+ parentId
298
+ level
299
+ sequence
300
+ handle
301
+ }
302
+ }
303
+ }
304
+ `;
305
+ exports.GET_CATEGORY_BY_HANDLE_QUERY = (0, graphql_tag_1.gql) `
306
+ query GetCategoryByHandle(
307
+ $partnerId: String!
308
+ $storeChannel: String!
309
+ $handle: String!
310
+ ) {
311
+ getCategoryByHandle(
312
+ partnerId: $partnerId
313
+ storeChannel: $storeChannel
314
+ handle: $handle
315
+ ) {
316
+ id
317
+ title
318
+ image
319
+ icon
320
+ parentId
321
+ level
322
+ handle
323
+ child {
324
+ id
325
+ title
326
+ image
327
+ icon
328
+ parentId
329
+ level
330
+ handle
331
+ }
332
+ }
333
+ }
334
+ `;
335
+ exports.GET_CATEGORY_BY_ID_QUERY = (0, graphql_tag_1.gql) `
336
+ query GetCategoryById(
337
+ $partnerId: String!
338
+ $storeChannel: String!
339
+ $categoryId: String!
340
+ ) {
341
+ getCategoryById(
342
+ partnerId: $partnerId
343
+ storeChannel: $storeChannel
344
+ categoryId: $categoryId
345
+ ) {
346
+ id
347
+ title
348
+ image
349
+ icon
350
+ parentId
351
+ level
352
+ handle
353
+ child {
354
+ id
355
+ title
356
+ image
357
+ icon
358
+ parentId
359
+ level
360
+ handle
361
+ }
362
+ }
363
+ }
364
+ `;
365
+ exports.GET_BRANDS_QUERY = `
366
+ query GetBrands($partnerId: String!, $storeChannel: String!, $enable: Boolean) {
367
+ getBrands(partnerId: $partnerId, storeChannel: $storeChannel, enable: $enable) {
368
+ id
369
+ name
370
+ image
371
+ imageIcon
372
+ }
373
+ }
374
+ `;
375
+ exports.GET_BRANDS_BY_CATEGORY_QUERY = `
376
+ query GetBrandsByCategory($partnerId: String!, $storeChannel: String!, $categoryId: String!) {
377
+ getBrandsByCategory(partnerId: $partnerId, storeChannel: $storeChannel, categoryId: $categoryId) {
378
+ id
379
+ name
380
+ image
381
+ imageIcon
382
+ }
383
+ }
384
+ `;
385
+ exports.GET_BRAND_DETAIL_QUERY = `
386
+ query GetBrandDetail($partnerId: String!, $brandId: String!, $storeChannel: String!) {
387
+ getDetail(partnerId: $partnerId, brandId: $brandId, storeChannel: $storeChannel) {
388
+ id
389
+ name
390
+ image
391
+ imageIcon
392
+ }
393
+ }
394
+ `;
395
+ exports.GET_PRODUCT_OPTION = (0, graphql_tag_1.gql) `
396
+ query GetProductOption(
397
+ $partnerId: String!
398
+ $storeChannel: String!
399
+ $productId: String!
400
+ ) {
401
+ getProductOption(partnerId: $partnerId, storeChannel: $storeChannel, productId: $productId) {
402
+ id
403
+ name
404
+ subType
405
+ productFeatureDTOS {
406
+ productOptionGroupItemDTOS {
407
+ id
408
+ productId
409
+ productName
410
+ price
411
+ }
412
+ }
413
+ }
414
+ }
415
+ `;
@@ -1,4 +1,3 @@
1
1
  export declare const CREATE_COMPANY: import("graphql").DocumentNode;
2
2
  export declare const UPDATE_COMPANY_INFOR: import("graphql").DocumentNode;
3
3
  export declare const UPDATE_CUSTOMER_V2: import("graphql").DocumentNode;
4
- export declare const GET_PERSON_BY_PARTY_IDS: import("graphql").DocumentNode;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_PERSON_BY_PARTY_IDS = exports.UPDATE_CUSTOMER_V2 = exports.UPDATE_COMPANY_INFOR = exports.CREATE_COMPANY = void 0;
3
+ exports.UPDATE_CUSTOMER_V2 = exports.UPDATE_COMPANY_INFOR = exports.CREATE_COMPANY = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.CREATE_COMPANY = (0, graphql_tag_1.gql) `
6
6
  mutation CreateCompany(
7
- $createCompanyRequest: createCompanyRequestInput!,
8
- $createTaxCodeRequest: createTaxCodeRequestInput,
7
+ $createCompanyRequest: CreateCompanyRequest!,
8
+ $createTaxCodeRequest: CreateTaxCodeRequest,
9
9
  $orgId: String!,
10
10
  $createdBy: String!
11
11
  ) {
@@ -61,7 +61,7 @@ exports.UPDATE_COMPANY_INFOR = (0, graphql_tag_1.gql) `
61
61
  exports.UPDATE_CUSTOMER_V2 = (0, graphql_tag_1.gql) `
62
62
  mutation UpdateCustomerV2(
63
63
  $id: String!,
64
- $updateCustomerRequest: UpdateCustomerRequestInput!,
64
+ $updateCustomerRequest: UpdateCustomerRequest!,
65
65
  $tenantId: String!,
66
66
  $updatedBy: String!
67
67
  ) {
@@ -85,32 +85,3 @@ exports.UPDATE_CUSTOMER_V2 = (0, graphql_tag_1.gql) `
85
85
  }
86
86
  }
87
87
  `;
88
- exports.GET_PERSON_BY_PARTY_IDS = (0, graphql_tag_1.gql) `
89
- query GetPersonByPartyIds($partyIds: [String]!){
90
- getPersonByPartyIds(partyIds: ["string"]) {
91
- status
92
- partyId
93
- fullName
94
- phone
95
- address
96
- gender
97
- birthDate
98
- email
99
- personalTitle
100
- imageUrl
101
- identityNumber
102
- addressModel {
103
- id
104
- addressInfo
105
- provinceGeoId
106
- districtGeoId
107
- wardGeoId
108
- provinceName
109
- districtName
110
- wardName
111
- isDefault
112
- }
113
- id
114
- }
115
- }
116
- `;
@@ -0,0 +1,3 @@
1
+ export declare const GET_PERSON_BY_IDS_QUERY: import("graphql").DocumentNode;
2
+ export declare const GET_CUSTOMER_BY_ID: import("graphql").DocumentNode;
3
+ export declare const SEARCH_COMPANY: import("graphql").DocumentNode;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SEARCH_COMPANY = exports.GET_CUSTOMER_BY_ID = exports.GET_PERSON_BY_IDS_QUERY = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.GET_PERSON_BY_IDS_QUERY = (0, graphql_tag_1.gql) `
6
+ query GetPersonByIds($partyIds: [String!]!) {
7
+ getPersonByPartyIds(partyIds: $partyIds) {
8
+ status
9
+ partyId
10
+ fullName
11
+ phone
12
+ address
13
+ gender
14
+ birthDate
15
+ email
16
+ personalTitle
17
+ imageUrl
18
+ identityNumber
19
+ id
20
+ addressModel {
21
+ id
22
+ addressInfo
23
+ provinceGeoId
24
+ districtGeoId
25
+ wardGeoId
26
+ provinceName
27
+ districtName
28
+ wardName
29
+ isDefault
30
+ }
31
+ }
32
+ }
33
+ `;
34
+ exports.GET_CUSTOMER_BY_ID = (0, graphql_tag_1.gql) `
35
+ query GetCustomerById($id: String!){
36
+ getCustomerById(id: $id) {
37
+ id
38
+ name
39
+ address
40
+ gender
41
+ identityNumber
42
+ birthDate
43
+ email
44
+ phone
45
+ createdStamp
46
+ createdBy
47
+ memberLevel
48
+ }
49
+ }
50
+ `;
51
+ exports.SEARCH_COMPANY = (0, graphql_tag_1.gql) `
52
+ query SearchCompany($keyword: String, $orgId: String!, $limit: Number){
53
+ searchCompany(keyword: "string", orgId: "string", limit: 1) {
54
+ id
55
+ name
56
+ address
57
+ gender
58
+ identityNumber
59
+ birthDate
60
+ email
61
+ phone
62
+ createdStamp
63
+ createdBy
64
+ memberLevel
65
+ }
66
+ }
67
+ `;
@@ -0,0 +1 @@
1
+ export { SDK } from './lib/SDK';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SDK = void 0;
4
+ var SDK_1 = require("./lib/SDK");
5
+ Object.defineProperty(exports, "SDK", { enumerable: true, get: function () { return SDK_1.SDK; } });
@@ -0,0 +1,28 @@
1
+ import { ProductService } from "../lib/product/index";
2
+ import { AuthService } from "../lib/auth/index";
3
+ import { OrderService } from "../lib/order/index";
4
+ import { UserService } from "../lib/user/index";
5
+ import { PaymentService } from "../lib/payment/index";
6
+ import { CrmService } from "../lib/crm/index";
7
+ export interface Endpoints {
8
+ product: string;
9
+ crm: string;
10
+ auth: string;
11
+ order: string;
12
+ user: string;
13
+ payment: string;
14
+ }
15
+ export declare class SDK {
16
+ orgId: string;
17
+ storeId: string;
18
+ storefrontAccessToken: string;
19
+ product: ProductService;
20
+ auth: AuthService;
21
+ order: OrderService;
22
+ user: UserService;
23
+ payment: PaymentService;
24
+ crm: CrmService;
25
+ token: string | null;
26
+ constructor(orgId: string, storeId: string, storefrontAccessToken: string);
27
+ setToken(token: string): void;
28
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SDK = void 0;
4
+ // src/SDK.ts
5
+ const index_1 = require("../lib/product/index");
6
+ const index_2 = require("../lib/auth/index");
7
+ const index_3 = require("../lib/order/index");
8
+ const index_4 = require("../lib/user/index");
9
+ const config_1 = require("../../config/config");
10
+ const helpers_1 = require("../utils/helpers");
11
+ const index_5 = require("../lib/payment/index");
12
+ const index_6 = require("../lib/crm/index");
13
+ class SDK {
14
+ constructor(orgId, storeId, storefrontAccessToken) {
15
+ this.orgId = orgId;
16
+ this.storeId = storeId;
17
+ this.storefrontAccessToken = storefrontAccessToken;
18
+ // public crm: CrmService;
19
+ // Other services here
20
+ this.token = null;
21
+ (0, helpers_1.validateStorefrontAccessToken)(storefrontAccessToken);
22
+ const endpoints = config_1.environmentEndpoints.dev;
23
+ this.product = new index_1.ProductService(endpoints.product, orgId, storeId);
24
+ this.auth = new index_2.AuthService(endpoints.auth, orgId, storeId);
25
+ this.order = new index_3.OrderService(endpoints.order, orgId, storeId);
26
+ this.user = new index_4.UserService(endpoints.user, orgId, storeId);
27
+ this.payment = new index_5.PaymentService(endpoints.payment, orgId, storeId);
28
+ this.crm = new index_6.CrmService(endpoints.crm, orgId, storeId);
29
+ // Initialize other services here
30
+ }
31
+ setToken(token) {
32
+ this.token = token;
33
+ // Also set the token in each service
34
+ this.product.setToken(token);
35
+ this.auth.setToken(token);
36
+ this.order.setToken(token);
37
+ this.user.setToken(token);
38
+ this.payment.setToken(token);
39
+ this.crm.setToken(token);
40
+ // Set token for other services here
41
+ }
42
+ }
43
+ exports.SDK = SDK;
@@ -0,0 +1,26 @@
1
+ import { Service } from "../service";
2
+ import { LoginRequest, LoginResponse, RegisterRequest } from "../../types/auth";
3
+ /**
4
+ * Represents the authentication service.
5
+ */
6
+ export declare class AuthService extends Service {
7
+ /**
8
+ * Constructs a new ProductService instance.
9
+ * @param endpoint - The endpoint URL for the service.
10
+ * @param orgId - The organization ID.
11
+ * @param storeId - The store ID.
12
+ */
13
+ constructor(endpoint: string, orgId: string, storeId: string);
14
+ /**
15
+ * Logs in a user with the provided login request.
16
+ * @param loginRequest - The login request object.
17
+ * @returns A promise that resolves to the login response.
18
+ */
19
+ login(loginRequest: LoginRequest): Promise<LoginResponse>;
20
+ /**
21
+ * Registers a new user with the provided register request.
22
+ * @param registerRequest - The register request object.
23
+ * @returns A promise that resolves when the registration is successful.
24
+ */
25
+ register(registerRequest: RegisterRequest): Promise<void>;
26
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuthService = void 0;
13
+ const service_1 = require("../service");
14
+ const mutations_1 = require("../../graphql/auth/mutations");
15
+ /**
16
+ * Represents the authentication service.
17
+ */
18
+ class AuthService extends service_1.Service {
19
+ /**
20
+ * Constructs a new ProductService instance.
21
+ * @param endpoint - The endpoint URL for the service.
22
+ * @param orgId - The organization ID.
23
+ * @param storeId - The store ID.
24
+ */
25
+ constructor(endpoint, orgId, storeId) {
26
+ super(endpoint, orgId, storeId);
27
+ }
28
+ /**
29
+ * Logs in a user with the provided login request.
30
+ * @param loginRequest - The login request object.
31
+ * @returns A promise that resolves to the login response.
32
+ */
33
+ login(loginRequest) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const variables = {
36
+ loginRequest: Object.assign({ orgId: this.orgId }, loginRequest),
37
+ };
38
+ const data = yield this.graphqlMutation(mutations_1.LOGIN_MUTATION, variables);
39
+ return data.login;
40
+ });
41
+ }
42
+ /**
43
+ * Registers a new user with the provided register request.
44
+ * @param registerRequest - The register request object.
45
+ * @returns A promise that resolves when the registration is successful.
46
+ */
47
+ register(registerRequest) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const variables = { registerRequest };
50
+ yield this.graphqlMutation(mutations_1.REGISTER_MUTATION, variables);
51
+ });
52
+ }
53
+ }
54
+ exports.AuthService = AuthService;