@ikas/storefront-api 4.0.0-alpha.38 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/__api/models/Cart.ts +0 -2
- package/src/__api/models/CartStorefrontRoutingDynamicCurrencySettings.ts +0 -2
- package/src/__api/models/CartV2.ts +0 -2
- package/src/__api/models/CheckoutSettingsPrice.ts +0 -2
- package/src/__api/models/Country.ts +0 -4
- package/src/__api/models/CurrencyRate.ts +0 -4
- package/src/__api/models/OrderLineItem.ts +0 -2
- package/src/__api/models/OrderLineVariantPrice.ts +0 -2
- package/src/__api/models/ProductBackInStockRemind.ts +0 -2
- package/src/__api/models/ProductOptionSelectValueOtherPrice.ts +0 -2
- package/src/__api/models/ProductPrice.ts +0 -4
- package/src/__api/models/{StorefrontRaffle.ts → Raffle.ts} +16 -5
- package/src/__api/models/RafflePaginationResponse.ts +3 -5
- package/src/__api/models/RaffleParticipants.ts +10 -8
- package/src/__api/models/RaffleParticipantsInput.ts +4 -1
- package/src/__api/models/RaffleParticipantsUpdateInput.ts +24 -0
- package/src/__api/models/SearchProductPrice.ts +0 -4
- package/src/__api/models/StorefrontDynamicCurrencySettings.ts +0 -2
- package/src/__api/models/StorefrontOrder.ts +0 -2
- package/src/__api/models/StorefrontTransaction.ts +0 -2
- package/src/__api/models/_base.ts +1 -2
- package/src/__api/mutations/addCouponCodeToCheckout.ts +1 -5
- package/src/__api/mutations/addItemToCart.ts +1 -4
- package/src/__api/mutations/createOrderRefundRequest.ts +1 -4
- package/src/__api/mutations/saveCart.ts +1 -4
- package/src/__api/mutations/saveCartCouponCode.ts +1 -4
- package/src/__api/mutations/saveCheckout.ts +1 -5
- package/src/__api/mutations/saveItemToCart.ts +1 -5
- package/src/__api/mutations/saveProductBackInStockRemind.ts +1 -2
- package/src/__api/mutations/saveRaffleParticipant.ts +3 -25
- package/src/__api/mutations/updateCartCampaignOffer.ts +1 -4
- package/src/__api/mutations/updateRaffleParticipant.ts +72 -0
- package/src/__api/queries/getCart.ts +1 -5
- package/src/__api/queries/getCartById.ts +1 -4
- package/src/__api/queries/getCheckoutByCartId.ts +1 -5
- package/src/__api/queries/getCheckoutById.ts +1 -5
- package/src/__api/queries/getCurrencyRate.ts +1 -3
- package/src/__api/queries/getCustomerOrders.ts +1 -4
- package/src/__api/queries/getOrder.ts +1 -4
- package/src/__api/queries/getOrderByEmail.ts +1 -4
- package/src/__api/queries/getRaffleParticipants.ts +59 -0
- package/src/__api/queries/getRafflesByCustomerId.ts +74 -0
- package/src/__api/queries/getStorefront.ts +1 -2
- package/src/__api/queries/listCheckoutSettings.ts +1 -2
- package/src/__api/queries/listCountry.ts +1 -3
- package/src/__api/queries/listOrderTransactions.ts +1 -2
- package/src/__api/queries/listProduct.ts +1 -3
- package/src/__api/queries/listProductBackInStockRemind.ts +1 -2
- package/src/__api/queries/listProductOptionSet.ts +1 -3
- package/src/__api/queries/{listStorefrontRaffle.ts → listRaffle.ts} +10 -10
- package/src/__api/queries/searchProducts.ts +1 -3
- package/src/__api/types/index.ts +35 -43
- package/src/api/checkout/index.ts +1 -1
- package/src/api/customer/index.ts +0 -9
- package/src/api/file-upload/index.ts +29 -35
- package/src/api/masterpass/index.ts +7 -7
- package/src/api/product/index.ts +0 -1
- package/src/api/raffle/index.ts +14 -12
- package/src/index.ts +7 -9
- package/src/__api/queries/listRaffleParticipants.ts +0 -81
|
@@ -1,44 +1,38 @@
|
|
|
1
1
|
import { IkasProductOption } from "@ikas/storefront-models";
|
|
2
|
-
import {
|
|
3
|
-
import { IkasProductOptionFileUrl } from "@ikas/storefront-models";
|
|
4
|
-
import { APIResponse } from "@ikas/fe-api-client";
|
|
5
|
-
import axios from "axios";
|
|
2
|
+
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
6
3
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
params: GetProductOptionFileUrlQueryParams,
|
|
11
|
-
file: File
|
|
4
|
+
export async function uploadProductOptionFile(
|
|
5
|
+
file: File,
|
|
6
|
+
option: IkasProductOption
|
|
12
7
|
) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const response = await _getProductOptionFileUrl(params);
|
|
17
|
-
return new APIResponse(
|
|
18
|
-
response.data
|
|
19
|
-
? {
|
|
20
|
-
...(response.data as unknown as IkasProductOptionFileUrl),
|
|
21
|
-
file: file,
|
|
22
|
-
}
|
|
23
|
-
: null,
|
|
24
|
-
response.graphQLErrors
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function uploadFile(params: IkasProductOptionFileUrl, file: File) {
|
|
29
|
-
const config = {
|
|
8
|
+
const URL = `${IkasStorefrontConfig.getAdminApiUrl()}/upload-product-option-file`;
|
|
9
|
+
const response = await fetch(URL, {
|
|
10
|
+
method: "POST",
|
|
30
11
|
headers: {
|
|
31
|
-
"
|
|
12
|
+
"x-api-key": IkasStorefrontConfig.getApiKey() || "",
|
|
13
|
+
"x-sfid": IkasStorefrontConfig.getStorefrontId() || "",
|
|
14
|
+
"x-sfrid": IkasStorefrontConfig.getStorefrontRoutingId() || "",
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
Accept: "application/json",
|
|
32
17
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
base64: await getBase64(file),
|
|
20
|
+
fileName: file.name,
|
|
21
|
+
productOptionSetId: option.productOptionSetId,
|
|
22
|
+
productOptionId: option.id,
|
|
23
|
+
}),
|
|
38
24
|
});
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return await response.text();
|
|
30
|
+
}
|
|
41
31
|
|
|
42
|
-
|
|
43
|
-
return
|
|
32
|
+
export function getBase64(file: File): Promise<string | null> {
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
const reader = new FileReader();
|
|
35
|
+
reader.addEventListener("load", () => resolve(reader.result as string));
|
|
36
|
+
reader.readAsDataURL(file);
|
|
37
|
+
});
|
|
44
38
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { QueryParams as
|
|
1
|
+
import { QueryParams as GetMasterpassRequestTokenQueryParams } from "../../__api/queries/getMasterpassRequestToken";
|
|
2
2
|
|
|
3
|
-
export type {
|
|
3
|
+
export type { GetMasterpassRequestTokenQueryParams };
|
|
4
4
|
|
|
5
|
-
export async function
|
|
6
|
-
data:
|
|
5
|
+
export async function getMasterpassRequestToken(
|
|
6
|
+
data: GetMasterpassRequestTokenQueryParams
|
|
7
7
|
) {
|
|
8
|
-
const
|
|
9
|
-
await import("../../__api/queries/
|
|
8
|
+
const _getMasterpassRequestToken = (
|
|
9
|
+
await import("../../__api/queries/getMasterpassRequestToken")
|
|
10
10
|
).default;
|
|
11
|
-
return await
|
|
11
|
+
return await _getMasterpassRequestToken(data);
|
|
12
12
|
}
|
package/src/api/product/index.ts
CHANGED
|
@@ -266,7 +266,6 @@ function simpleToProduct(simple: SearchProduct): IkasProduct {
|
|
|
266
266
|
shortDescription: simple.shortDescription || "",
|
|
267
267
|
productOptionSetId: simple.productOptionSetId,
|
|
268
268
|
variantTypes: simple.productVariantTypes.map((pvt) => ({
|
|
269
|
-
order: pvt.order,
|
|
270
269
|
variantType: {
|
|
271
270
|
id: pvt.variantType.id,
|
|
272
271
|
name: pvt.variantType.name,
|
package/src/api/raffle/index.ts
CHANGED
|
@@ -7,21 +7,21 @@ import {
|
|
|
7
7
|
} from "@ikas/storefront-models";
|
|
8
8
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
9
9
|
|
|
10
|
-
import { QueryParams as
|
|
10
|
+
import { QueryParams as ListRaffleQueryParams } from "../../__api/queries/listRaffle";
|
|
11
11
|
import { QueryParams as SaveRaffleParticipantQueryParams } from "../../__api/mutations/saveRaffleParticipant";
|
|
12
12
|
import { QueryParams as ListRaffleMetadataQueryParams } from "../../__api/queries/listRaffleMetadata";
|
|
13
|
+
import { QueryParams as GetRafflesByCustomerIdQueryParams } from "../../__api/queries/getRafflesByCustomerId";
|
|
13
14
|
|
|
14
15
|
export type {
|
|
15
|
-
|
|
16
|
+
ListRaffleQueryParams,
|
|
16
17
|
SaveRaffleParticipantQueryParams,
|
|
17
18
|
ListRaffleMetadataQueryParams,
|
|
19
|
+
GetRafflesByCustomerIdQueryParams,
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
export async function
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
).default;
|
|
24
|
-
const response = await _listStorefrontRaffle(params);
|
|
22
|
+
export async function listRaffle(params: ListRaffleQueryParams) {
|
|
23
|
+
const _listRaffle = (await import("../../__api/queries/listRaffle")).default;
|
|
24
|
+
const response = await _listRaffle(params);
|
|
25
25
|
const data: IkasRaffle[] | undefined = response.data as any;
|
|
26
26
|
|
|
27
27
|
data?.forEach((r) =>
|
|
@@ -45,7 +45,7 @@ export async function saveRaffleParticipant(
|
|
|
45
45
|
).default;
|
|
46
46
|
const response = await _saveRaffleParticipant(params);
|
|
47
47
|
return new APIResponse(
|
|
48
|
-
response.data ? (response.data as
|
|
48
|
+
response.data ? (response.data as IkasRaffleParticipant) : null,
|
|
49
49
|
response.graphQLErrors
|
|
50
50
|
);
|
|
51
51
|
}
|
|
@@ -63,11 +63,13 @@ export async function listRaffleMetaData(
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export async function
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
export async function getRafflesByCustomerId(
|
|
67
|
+
params: GetRafflesByCustomerIdQueryParams
|
|
68
|
+
) {
|
|
69
|
+
const _getRafflesByCustomerId = (
|
|
70
|
+
await import("../../__api/queries/getRafflesByCustomerId")
|
|
69
71
|
).default;
|
|
70
|
-
const response = await
|
|
72
|
+
const response = await _getRafflesByCustomerId(params);
|
|
71
73
|
const data: IkasRaffle[] | undefined = response.data as any;
|
|
72
74
|
|
|
73
75
|
data?.forEach((r) =>
|
package/src/index.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { APIErrorCode, Config } from "@ikas/fe-api-client";
|
|
2
2
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
id: "ikas-storefront-api",
|
|
6
|
-
callback: setAPIClientConfig,
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export function setAPIClientConfig() {
|
|
4
|
+
const onConfigChange = () => {
|
|
10
5
|
Config.URL = IkasStorefrontConfig.getApiUrl() || "";
|
|
11
6
|
Config.HEADERS = {
|
|
12
7
|
"x-api-key": IkasStorefrontConfig.getApiKey() || "",
|
|
13
8
|
"x-sfid": IkasStorefrontConfig.getStorefrontId() || "",
|
|
14
9
|
"x-sfrid": IkasStorefrontConfig.getStorefrontRoutingId() || "",
|
|
15
|
-
"x-sid": IkasStorefrontConfig.getSessionId() || "",
|
|
16
|
-
"x-vid": IkasStorefrontConfig.getVisitorId() || "",
|
|
17
10
|
};
|
|
18
11
|
|
|
19
12
|
if (IkasStorefrontConfig.getCustomerToken()) {
|
|
@@ -30,7 +23,12 @@ export function setAPIClientConfig() {
|
|
|
30
23
|
],
|
|
31
24
|
};
|
|
32
25
|
}
|
|
33
|
-
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
IkasStorefrontConfig.addObserver({
|
|
29
|
+
id: "ikas-storefront-api",
|
|
30
|
+
callback: onConfigChange,
|
|
31
|
+
});
|
|
34
32
|
|
|
35
33
|
export * from "./api/blog";
|
|
36
34
|
export * from "./api/brand";
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fetchQuery,
|
|
3
|
-
ConfigType,
|
|
4
|
-
APIResponse,
|
|
5
|
-
handleAPIError,
|
|
6
|
-
} from "@ikas/fe-api-client";
|
|
7
|
-
import { RaffleParticipants } from "../types";
|
|
8
|
-
|
|
9
|
-
const listRaffleParticipants = async (
|
|
10
|
-
fields?: string[],
|
|
11
|
-
config?: ConfigType
|
|
12
|
-
) => {
|
|
13
|
-
try {
|
|
14
|
-
const { data, errors } = await fetchQuery({
|
|
15
|
-
operationName: "listRaffleParticipants",
|
|
16
|
-
config,
|
|
17
|
-
allReturnFields,
|
|
18
|
-
fields,
|
|
19
|
-
query: (returnFields: string) => `
|
|
20
|
-
query listRaffleParticipants {
|
|
21
|
-
listRaffleParticipants ${returnFields}
|
|
22
|
-
}
|
|
23
|
-
`,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return new APIResponse<RaffleParticipants[]>(
|
|
27
|
-
data?.listRaffleParticipants,
|
|
28
|
-
errors
|
|
29
|
-
);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
return handleAPIError(err);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default listRaffleParticipants;
|
|
36
|
-
|
|
37
|
-
const allReturnFields =
|
|
38
|
-
"{applicationDate appliedProduct {productId variantId } createdAt customerId deleted email extraData firstName fullName id isDeliveredCargo lastName phone raffle {createdAt dateRange {end start } deleted id metadata {canonicals createdAt deleted description disableIndex id pageTitle slug targetId targetType updatedAt } name requiredCustomerAccount status updatedAt variants {productId variantId } verificationType } raffleId status updatedAt }";
|
|
39
|
-
|
|
40
|
-
export enum ResponseField {
|
|
41
|
-
APPLICATION_DATE = "applicationDate",
|
|
42
|
-
APPLIED_PRODUCT__PRODUCT_ID = "appliedProduct.productId",
|
|
43
|
-
APPLIED_PRODUCT__VARIANT_ID = "appliedProduct.variantId",
|
|
44
|
-
CREATED_AT = "createdAt",
|
|
45
|
-
CUSTOMER_ID = "customerId",
|
|
46
|
-
DELETED = "deleted",
|
|
47
|
-
EMAIL = "email",
|
|
48
|
-
EXTRA_DATA = "extraData",
|
|
49
|
-
FIRST_NAME = "firstName",
|
|
50
|
-
FULL_NAME = "fullName",
|
|
51
|
-
ID = "id",
|
|
52
|
-
IS_DELIVERED_CARGO = "isDeliveredCargo",
|
|
53
|
-
LAST_NAME = "lastName",
|
|
54
|
-
PHONE = "phone",
|
|
55
|
-
RAFFLE__CREATED_AT = "raffle.createdAt",
|
|
56
|
-
RAFFLE__DATE_RANGE__END = "raffle.dateRange.end",
|
|
57
|
-
RAFFLE__DATE_RANGE__START = "raffle.dateRange.start",
|
|
58
|
-
RAFFLE__DELETED = "raffle.deleted",
|
|
59
|
-
RAFFLE__ID = "raffle.id",
|
|
60
|
-
RAFFLE__METADATA__CANONICALS = "raffle.metadata.canonicals",
|
|
61
|
-
RAFFLE__METADATA__CREATED_AT = "raffle.metadata.createdAt",
|
|
62
|
-
RAFFLE__METADATA__DELETED = "raffle.metadata.deleted",
|
|
63
|
-
RAFFLE__METADATA__DESCRIPTION = "raffle.metadata.description",
|
|
64
|
-
RAFFLE__METADATA__DISABLE_INDEX = "raffle.metadata.disableIndex",
|
|
65
|
-
RAFFLE__METADATA__ID = "raffle.metadata.id",
|
|
66
|
-
RAFFLE__METADATA__PAGE_TITLE = "raffle.metadata.pageTitle",
|
|
67
|
-
RAFFLE__METADATA__SLUG = "raffle.metadata.slug",
|
|
68
|
-
RAFFLE__METADATA__TARGET_ID = "raffle.metadata.targetId",
|
|
69
|
-
RAFFLE__METADATA__TARGET_TYPE = "raffle.metadata.targetType",
|
|
70
|
-
RAFFLE__METADATA__UPDATED_AT = "raffle.metadata.updatedAt",
|
|
71
|
-
RAFFLE__NAME = "raffle.name",
|
|
72
|
-
RAFFLE__REQUIRED_CUSTOMER_ACCOUNT = "raffle.requiredCustomerAccount",
|
|
73
|
-
RAFFLE__STATUS = "raffle.status",
|
|
74
|
-
RAFFLE__UPDATED_AT = "raffle.updatedAt",
|
|
75
|
-
RAFFLE__VARIANTS__PRODUCT_ID = "raffle.variants.productId",
|
|
76
|
-
RAFFLE__VARIANTS__VARIANT_ID = "raffle.variants.variantId",
|
|
77
|
-
RAFFLE__VERIFICATION_TYPE = "raffle.verificationType",
|
|
78
|
-
RAFFLE_ID = "raffleId",
|
|
79
|
-
STATUS = "status",
|
|
80
|
-
UPDATED_AT = "updatedAt",
|
|
81
|
-
}
|