Revert "Merge pull request 'fix: Some of the release candidate API interface changes were reverted on the upstream.' (#6) from openapi-sdk-migration into main"
This reverts commit2b87f45069
, reversing changes made toc2a0633f2b
. There was a forced update on the branch.
This commit is contained in:
parent
2b87f45069
commit
caa0d93d91
104
src/apiclient/override-squidex-sdk.ts
Normal file
104
src/apiclient/override-squidex-sdk.ts
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
import { Assets } from "@squidex/squidex/api/resources/assets/client/Client.js"
|
||||||
|
import { SquidexClient } from "@squidex/squidex"
|
||||||
|
import * as environments from "@squidex/squidex/environments.js";
|
||||||
|
import * as core from "@squidex/squidex/core/index.js";
|
||||||
|
import { Squidex } from "@squidex/squidex";
|
||||||
|
import urlJoin from "url-join";
|
||||||
|
import * as errors from "@squidex/squidex/errors/index.js";
|
||||||
|
import * as serializers from "@squidex/squidex/serialization/index.js";
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { default as FormData } from "form-data";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You can only upload one file at a time. The mime type of the file is not calculated by Squidex and is required correctly.
|
||||||
|
* @throws {@link Squidex.BadRequestError}
|
||||||
|
* @throws {@link Squidex.NotFoundError}
|
||||||
|
* @throws {@link Squidex.ContentTooLargeError}
|
||||||
|
* @throws {@link Squidex.InternalServerError}
|
||||||
|
*/
|
||||||
|
export function async customPostAsset(
|
||||||
|
file: File | fs.ReadStream,
|
||||||
|
requestOptions?: Assets.RequestOptions
|
||||||
|
): Promise<Squidex.AssetDto> {
|
||||||
|
const _request = new FormData();
|
||||||
|
_request.append("file", file);
|
||||||
|
const _response = await (this._options.fetcher ?? core.fetcher)({
|
||||||
|
url: urlJoin(
|
||||||
|
(await core.Supplier.get(this._options.environment)) ?? environments.SquidexEnvironment.Default,
|
||||||
|
`api/apps/${this._options.appName}/assets`
|
||||||
|
),
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: await this._getAuthorizationHeader(),
|
||||||
|
"X-Fern-Language": "JavaScript",
|
||||||
|
"X-Fern-SDK-Name": "@squidex/squidex",
|
||||||
|
"X-Fern-SDK-Version": "1.2.1",
|
||||||
|
"Content-Length": (await core.getFormDataContentLength(_request)).toString(),
|
||||||
|
},
|
||||||
|
contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
|
||||||
|
body: _request,
|
||||||
|
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
||||||
|
});
|
||||||
|
if (_response.ok) {
|
||||||
|
return await serializers.AssetDto.parseOrThrow(_response.body, {
|
||||||
|
unrecognizedObjectKeys: "passthrough",
|
||||||
|
allowUnrecognizedUnionMembers: true,
|
||||||
|
allowUnrecognizedEnumValues: true,
|
||||||
|
breadcrumbsPrefix: ["response"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_response.error.reason === "status-code") {
|
||||||
|
switch (_response.error.statusCode) {
|
||||||
|
case 400:
|
||||||
|
throw new Squidex.BadRequestError(
|
||||||
|
await serializers.ErrorDto.parseOrThrow(_response.error.body, {
|
||||||
|
unrecognizedObjectKeys: "passthrough",
|
||||||
|
allowUnrecognizedUnionMembers: true,
|
||||||
|
allowUnrecognizedEnumValues: true,
|
||||||
|
breadcrumbsPrefix: ["response"],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
case 404:
|
||||||
|
throw new Squidex.NotFoundError(_response.error.body);
|
||||||
|
case 413:
|
||||||
|
throw new Squidex.ContentTooLargeError(
|
||||||
|
await serializers.ErrorDto.parseOrThrow(_response.error.body, {
|
||||||
|
unrecognizedObjectKeys: "passthrough",
|
||||||
|
allowUnrecognizedUnionMembers: true,
|
||||||
|
allowUnrecognizedEnumValues: true,
|
||||||
|
breadcrumbsPrefix: ["response"],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
case 500:
|
||||||
|
throw new Squidex.InternalServerError(
|
||||||
|
await serializers.ErrorDto.parseOrThrow(_response.error.body, {
|
||||||
|
unrecognizedObjectKeys: "passthrough",
|
||||||
|
allowUnrecognizedUnionMembers: true,
|
||||||
|
allowUnrecognizedEnumValues: true,
|
||||||
|
breadcrumbsPrefix: ["response"],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
throw new errors.SquidexError({
|
||||||
|
statusCode: _response.error.statusCode,
|
||||||
|
body: _response.error.body,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (_response.error.reason) {
|
||||||
|
case "non-json":
|
||||||
|
throw new errors.SquidexError({
|
||||||
|
statusCode: _response.error.statusCode,
|
||||||
|
body: _response.error.rawBody,
|
||||||
|
});
|
||||||
|
case "timeout":
|
||||||
|
throw new errors.SquidexTimeoutError();
|
||||||
|
case "unknown":
|
||||||
|
throw new errors.SquidexError({
|
||||||
|
message: _response.error.errorMessage,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -4,7 +4,6 @@ import { getAllAssetsInFolder, isValidASIN, uploadDownloadedImageToSquidexAsAsse
|
||||||
import { getMarketplacesUsingJsonQuery, getProductListingsUsingJsonQuery, getProductsUsingJsonQuery } from "../../../data/api-client";
|
import { getMarketplacesUsingJsonQuery, getProductListingsUsingJsonQuery, getProductsUsingJsonQuery } from "../../../data/api-client";
|
||||||
import { SCHEMAS } from "../../../data/models/schemas";
|
import { SCHEMAS } from "../../../data/models/schemas";
|
||||||
import { logForCommand } from "../common/console";
|
import { logForCommand } from "../common/console";
|
||||||
import type { ContentsPutContentRequest } from "@squidex/squidex/dist/generated/apis/ContentsApi";
|
|
||||||
|
|
||||||
export const COMMAND_NAME = 'append-images';
|
export const COMMAND_NAME = 'append-images';
|
||||||
|
|
||||||
|
@ -98,10 +97,12 @@ export const amazonAppendImagesCommand = (amazonCommand: Command) =>
|
||||||
}
|
}
|
||||||
if (didUpdate) {
|
if (didUpdate) {
|
||||||
log(`Listing did update, updating product listing with appended images.`);
|
log(`Listing did update, updating product listing with appended images.`);
|
||||||
let updatedDto = await core.client.contents.putContent(SCHEMAS.LISTINGS, listingDto.id, {
|
let updatedDto = await core.client.contents.putContent({
|
||||||
|
schema: SCHEMAS.LISTINGS,
|
||||||
|
id: listingDto.id,
|
||||||
unpublished: false,
|
unpublished: false,
|
||||||
requestBody: listing as any,
|
requestBody: listing as any,
|
||||||
} as ContentsPutContentRequest as any);
|
});
|
||||||
log(`Listing version ${updatedDto.version} stored.`);
|
log(`Listing version ${updatedDto.version} stored.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export function isValidASIN(asinOrNot: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAmazonGetItemsRequestSchemaDto() {
|
export async function getAmazonGetItemsRequestSchemaDto() {
|
||||||
return await client.schemas.getSchema('amazon-pa-get-items-request');
|
return await client.schemas.getSchema({ schema: 'amazon-pa-get-items-request' });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function lookupAmazonASINs(asins: string[]) {
|
export async function lookupAmazonASINs(asins: string[]) {
|
||||||
|
@ -48,17 +48,21 @@ export async function lookupAmazonASINs(asins: string[]) {
|
||||||
] } },
|
] } },
|
||||||
requestDate: { iv: requestDate }
|
requestDate: { iv: requestDate }
|
||||||
}
|
}
|
||||||
let amazonGetItemDto = await client.contents.postContent(SCHEMAS.AMAZON_GET_ITEMS, { ...amazonGetItem }, { publish: true })
|
let amazonGetItemDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.AMAZON_GET_ITEMS,
|
||||||
|
publish: true,
|
||||||
|
requestBody: amazonGetItem as any,
|
||||||
|
})
|
||||||
let amazonGetItemsDto = await getContentsByIds<AmazonGetItem>(SCHEMAS.AMAZON_GET_ITEMS, amazonGetItemDto.id);
|
let amazonGetItemsDto = await getContentsByIds<AmazonGetItem>(SCHEMAS.AMAZON_GET_ITEMS, amazonGetItemDto.id);
|
||||||
return amazonGetItemsDto;
|
return amazonGetItemsDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMarketplaceConnectionSchemaDto() {
|
export async function getMarketplaceConnectionSchemaDto() {
|
||||||
return await client.schemas.getSchema('product-marketplace-connection');
|
return await client.schemas.getSchema({ schema: 'product-marketplace-connection' });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAmazonMarketplaceConnectionSchemaDto() {
|
export async function getAmazonMarketplaceConnectionSchemaDto() {
|
||||||
return await client.schemas.getSchema('product-marketplace-connection-amazon')
|
return await client.schemas.getSchema({ schema: 'product-marketplace-connection-amazon' })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAmazonMarketplaceDto() {
|
export async function getAmazonMarketplaceDto() {
|
||||||
|
@ -96,7 +100,9 @@ export async function getBrandDtoByName(brandName: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAddNewBrandDtoByName(brandName: string) {
|
export async function getAddNewBrandDtoByName(brandName: string) {
|
||||||
let brandDto = await client.contents.postContent(SCHEMAS.BRANDS, {
|
let brandDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.BRANDS,
|
||||||
|
requestBody: {
|
||||||
brandName: {
|
brandName: {
|
||||||
"en-US": brandName!,
|
"en-US": brandName!,
|
||||||
"es-US": brandName!,
|
"es-US": brandName!,
|
||||||
|
@ -107,8 +113,9 @@ export async function getAddNewBrandDtoByName(brandName: string) {
|
||||||
"es-US": `es-US/${slugify(brandName!, { lower: true, trim: true })}`,
|
"es-US": `es-US/${slugify(brandName!, { lower: true, trim: true })}`,
|
||||||
"fr-CA": `fr-CA/${slugify(brandName!, { lower: true, trim: true })}`
|
"fr-CA": `fr-CA/${slugify(brandName!, { lower: true, trim: true })}`
|
||||||
},
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
let brandsDto = await client.contents.getContents(SCHEMAS.BRANDS, { unpublished: true, ids: brandDto.id }) as ContentsDto<Brand>;
|
let brandsDto = await client.contents.getContents({ schema: SCHEMAS.BRANDS, unpublished: true, ids: brandDto.id }) as ContentsDto<Brand>;
|
||||||
return brandsDto;
|
return brandsDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +130,9 @@ export async function getSellerDtoByName(sellerName: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAddNewSellerDtoByName(sellerName: string) {
|
export async function getAddNewSellerDtoByName(sellerName: string) {
|
||||||
let sellerDto = await client.contents.postContent(SCHEMAS.SELLERS, {
|
let sellerDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.SELLERS,
|
||||||
|
requestBody: {
|
||||||
sellerName: {
|
sellerName: {
|
||||||
"en-US": sellerName!,
|
"en-US": sellerName!,
|
||||||
"es-US": sellerName!,
|
"es-US": sellerName!,
|
||||||
|
@ -134,8 +143,9 @@ export async function getAddNewSellerDtoByName(sellerName: string) {
|
||||||
"es-US": `es-US/${slugify(sellerName!, { lower: true, trim: true })}`,
|
"es-US": `es-US/${slugify(sellerName!, { lower: true, trim: true })}`,
|
||||||
"fr-CA": `fr-CA/${slugify(sellerName!, { lower: true, trim: true })}`
|
"fr-CA": `fr-CA/${slugify(sellerName!, { lower: true, trim: true })}`
|
||||||
},
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
let sellersDto = await client.contents.getContents(SCHEMAS.SELLERS, { unpublished: true, ids: sellerDto.id }) as ContentsDto<Seller>;
|
let sellersDto = await client.contents.getContents({ schema: SCHEMAS.SELLERS, unpublished: true, ids: sellerDto.id }) as ContentsDto<Seller>;
|
||||||
return sellersDto;
|
return sellersDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,14 +408,16 @@ export async function translateTags_from_en_US_to_fr_CA(tags_en_US: string[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAddNewProductSubCategoryDto(parentProductCategoryId: NonLocalized<string[]>, categoryName: Localized<string>, description: Localized<string>) {
|
export async function getAddNewProductSubCategoryDto(parentProductCategoryId: NonLocalized<string[]>, categoryName: Localized<string>, description: Localized<string>) {
|
||||||
let productCategoryDto = await client.contents.postContent(SCHEMAS.PRODUCT_CATEGORIES, {
|
let productCategoryDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.PRODUCT_CATEGORIES,
|
||||||
|
publish: false,
|
||||||
|
requestBody: {
|
||||||
categoryName,
|
categoryName,
|
||||||
description,
|
description,
|
||||||
parentCategory: parentProductCategoryId,
|
parentCategory: parentProductCategoryId,
|
||||||
}, {
|
},
|
||||||
publish: false,
|
|
||||||
});
|
});
|
||||||
let productCategoriesDto = await client.contents.getContents(SCHEMAS.PRODUCT_CATEGORIES, { unpublished: true, ids: productCategoryDto.id }) as ContentsDto<ProductCategory>;
|
let productCategoriesDto = await client.contents.getContents({ schema: SCHEMAS.PRODUCT_CATEGORIES, unpublished: true, ids: productCategoryDto.id }) as ContentsDto<ProductCategory>;
|
||||||
return productCategoriesDto;
|
return productCategoriesDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,16 +448,26 @@ export async function translateAmazonDescription_from_en_US_to_fr_CA(brandName:
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAddNewProductDtoByProduct(product: Product) {
|
export async function getAddNewProductDtoByProduct(product: Product) {
|
||||||
let productDto = await client.contents.postContent(SCHEMAS.PRODUCTS, { ...product }, { publish: false });
|
let productDto = await client.contents.postContent({
|
||||||
let productsDto = await client.contents.getContents(SCHEMAS.PRODUCTS, { unpublished: true, ids: productDto.id }) as ContentsDto<Product>;
|
schema: SCHEMAS.PRODUCTS,
|
||||||
|
publish: false,
|
||||||
|
requestBody: {
|
||||||
|
...product
|
||||||
|
},
|
||||||
|
});
|
||||||
|
let productsDto = await client.contents.getContents({ schema: SCHEMAS.PRODUCTS, unpublished: true, ids: productDto.id }) as ContentsDto<Product>;
|
||||||
return productsDto;
|
return productsDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAddNewProductListingDtoByProduct(listing: Listing) {
|
export async function getAddNewProductListingDtoByProduct(listing: Listing) {
|
||||||
let listingDto = await client.contents.postContent(SCHEMAS.LISTINGS, { ...listing }, {
|
let listingDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.LISTINGS,
|
||||||
publish: true,
|
publish: true,
|
||||||
|
requestBody: {
|
||||||
|
...listing
|
||||||
|
}
|
||||||
});
|
});
|
||||||
let listingsDto = await client.contents.getContents(SCHEMAS.LISTINGS, { unpublished: true, ids: listingDto.id }) as ContentsDto<Listing>;
|
let listingsDto = await client.contents.getContents({ schema: SCHEMAS.LISTINGS, unpublished: true, ids: listingDto.id }) as ContentsDto<Listing>;
|
||||||
return listingsDto;
|
return listingsDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +484,7 @@ export async function upsertAssetFolder(folderName: string, parentFolderId?: str
|
||||||
let assetFolder;
|
let assetFolder;
|
||||||
let assetFolderLookup = assetFolders.items.filter(folder => folder.folderName === folderName);
|
let assetFolderLookup = assetFolders.items.filter(folder => folder.folderName === folderName);
|
||||||
if (assetFolderLookup.length === 0) {
|
if (assetFolderLookup.length === 0) {
|
||||||
assetFolder = await client.assets.postAssetFolder({ folderName: folderName, parentId: parentFolderId });
|
assetFolder = await client.assets.postAssetFolder({ createAssetFolderDto: { folderName: folderName, parentId: parentFolderId }});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assetFolder = assetFolderLookup[0];
|
assetFolder = assetFolderLookup[0];
|
||||||
|
@ -484,14 +506,20 @@ export async function uploadDownloadedImageToSquidexAsAsset(downloadUrl: string,
|
||||||
form.append('fileName', filename);
|
form.append('fileName', filename);
|
||||||
form.append('file', blob, filename);
|
form.append('file', blob, filename);
|
||||||
form.append('parentId', assetFolderId);
|
form.append('parentId', assetFolderId);
|
||||||
let assetDto = await client.assets.postAsset({ file: blob, name: filename, url: filename, parentId: assetFolderId }, { body: form });
|
let assetDto = await client.assets.postAsset({ file: blob, fileName: filename, fileUrl: filename, parentId: assetFolderId }, {
|
||||||
assetDto = await client.assets.putAsset(assetDto.id, { metadata: { ...assetDto.metadata, 'amazon-url': downloadUrl }, tags: ['amazon', 'product'] });
|
body: form
|
||||||
|
});
|
||||||
|
assetDto = await client.assets.putAsset({ id: assetDto.id, annotateAssetDto: { metadata: { ...assetDto.metadata, 'amazon-url': downloadUrl }, tags: ['amazon', 'product'] } })
|
||||||
// assetDto = await client.assets.putAssetParent({ id: assetDto.id, moveAssetDto: { parentId: assetFolderId } });
|
// assetDto = await client.assets.putAssetParent({ id: assetDto.id, moveAssetDto: { parentId: assetFolderId } });
|
||||||
return assetDto;
|
return assetDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAddNewOfferDto(offer: Offer) {
|
export async function getAddNewOfferDto(offer: Offer) {
|
||||||
let offerDto = await client.contents.postContent(SCHEMAS.OFFERS, { ...offer }, { publish: true });
|
let offerDto = await client.contents.postContent({
|
||||||
let offersDto = await client.contents.getContents(SCHEMAS.OFFERS, { unpublished: true, ids: offerDto.id }) as ContentsDto<ProductCategory>;
|
schema: SCHEMAS.OFFERS,
|
||||||
|
publish: true,
|
||||||
|
requestBody: offer as any,
|
||||||
|
});
|
||||||
|
let offersDto = await client.contents.getContents({ schema: SCHEMAS.OFFERS, unpublished: true, ids: offerDto.id }) as ContentsDto<ProductCategory>;
|
||||||
return offersDto;
|
return offersDto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,14 +320,10 @@ export async function performSyncLocalizedSlugs(logFn = console.log) {
|
||||||
});
|
});
|
||||||
const MAX_TIME_TO_POST_SLUGS = 60;//s
|
const MAX_TIME_TO_POST_SLUGS = 60;//s
|
||||||
logFn("Add", batchAddSlugsQueue.length, "slugs");
|
logFn("Add", batchAddSlugsQueue.length, "slugs");
|
||||||
//postContents is deprecated, will loop with postContent
|
let bulkAddResult = await core.client.contents.postContents({ schema: SCHEMAS.SLUGS, importContentsDto: { datas: batchAddSlugsQueue as any, publish: true } });
|
||||||
let bulkAddResult = [];//await core.client.contents.postContents(SCHEMAS.SLUGS, { datas: batchAddSlugsQueue as any, publish: true });
|
|
||||||
for (let bar = 0; bar < batchAddSlugsQueue.length; bar++) {
|
|
||||||
bulkAddResult.push(await core.client.contents.postContent(SCHEMAS.SLUGS, batchAddSlugsQueue[bar] as any, { publish: true }));
|
|
||||||
}
|
|
||||||
logFn("Remove by id", batchRemoveSlugsQueue.length, "slugs");
|
logFn("Remove by id", batchRemoveSlugsQueue.length, "slugs");
|
||||||
batchRemoveSlugsQueue.forEach(async (removeId) => {
|
batchRemoveSlugsQueue.forEach(async (removeId) => {
|
||||||
await core.client.contents.deleteContent(SCHEMAS.SLUGS, removeId)
|
await core.client.contents.deleteContent({ schema: SCHEMAS.SLUGS, id: removeId })
|
||||||
})
|
})
|
||||||
logFn("Finish sync localized slugs.")
|
logFn("Finish sync localized slugs.")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { config } from "../../config.js";
|
import { config } from "../../config.js";
|
||||||
import { SquidexClient } from "@squidex/squidex";
|
import { SquidexClient } from "@squidex/squidex";
|
||||||
import { InMemoryTokenStore } from "@squidex/squidex/dist/wrapper/SquidexClient.js";
|
|
||||||
import type { ContentsDto } from "../internals/ContentsDtoT.js";
|
import type { ContentsDto } from "../internals/ContentsDtoT.js";
|
||||||
import type { SupportedLocales } from "../internals/LocalizedT.js";
|
import type { SupportedLocales } from "../internals/LocalizedT.js";
|
||||||
import type { SCHEMAS } from "../models/schemas.js";
|
import type { SCHEMAS } from "../models/schemas.js";
|
||||||
|
@ -10,7 +9,7 @@ export const client = new SquidexClient({
|
||||||
clientId: config.squidexClientId!,
|
clientId: config.squidexClientId!,
|
||||||
clientSecret: config.squidexClientSecret!,
|
clientSecret: config.squidexClientSecret!,
|
||||||
environment: config.squidexEnvironment!,
|
environment: config.squidexEnvironment!,
|
||||||
tokenStore: new InMemoryTokenStore(),
|
tokenStore: new SquidexClient.InMemoryTokenStore(),
|
||||||
// tokenStore: new SquidexStorageTokenStore() // Keep the tokens in the local store.
|
// tokenStore: new SquidexStorageTokenStore() // Keep the tokens in the local store.
|
||||||
// tokenStore: new SquidexStorageTokenStore(sessionStorage, "CustomKey")
|
// tokenStore: new SquidexStorageTokenStore(sessionStorage, "CustomKey")
|
||||||
});
|
});
|
||||||
|
@ -20,21 +19,21 @@ export const TIMEOUT_IN_SECONDS = 10;
|
||||||
/** Asset Handling */
|
/** Asset Handling */
|
||||||
|
|
||||||
export const getAssetById = async (assetId: string) => (
|
export const getAssetById = async (assetId: string) => (
|
||||||
await client.assets.getAsset(assetId)
|
await client.assets.getAsset({ id: assetId })
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Generic Content Handling */
|
/** Generic Content Handling */
|
||||||
|
|
||||||
export const getAllContents = async <T>(schema: SCHEMAS|string) => (
|
export const getAllContents = async <T>(schema: SCHEMAS|string) => (
|
||||||
await client.contents.getContents(schema, { })
|
await client.contents.getContents({ schema })
|
||||||
) as ContentsDto<T>;
|
) as ContentsDto<T>;
|
||||||
|
|
||||||
export const getContentsByIds = async <T>(schema: SCHEMAS|string, ids: string) => (
|
export const getContentsByIds = async <T>(schema: SCHEMAS|string, ids: string) => (
|
||||||
await client.contents.getContents(schema, { ids })
|
await client.contents.getContents({ schema, ids })
|
||||||
) as ContentsDto<T>;
|
) as ContentsDto<T>;
|
||||||
|
|
||||||
export const getContentsUsingJsonQuery = async <T>(schema: SCHEMAS|string, jsonQuery: string|undefined = undefined) => (
|
export const getContentsUsingJsonQuery = async <T>(schema: SCHEMAS|string, jsonQuery: string|undefined = undefined) => (
|
||||||
await client.contents.getContents(schema, { q: jsonQuery })
|
await client.contents.getContents({ schema, q: jsonQuery })
|
||||||
) as ContentsDto<T>;
|
) as ContentsDto<T>;
|
||||||
|
|
||||||
export const getContentsByLangSlug = async <T>(schema: SCHEMAS|string, forLang: SupportedLocales|string, slug: string) => (
|
export const getContentsByLangSlug = async <T>(schema: SCHEMAS|string, forLang: SupportedLocales|string, slug: string) => (
|
||||||
|
|
|
@ -76,7 +76,7 @@ export const genericPageForBrand = ({ brand, brandId, homePageId }: PageForBrand
|
||||||
schemaId: '',
|
schemaId: '',
|
||||||
schemaName: '',
|
schemaName: '',
|
||||||
keywords: brand.brandName['en-US'],
|
keywords: brand.brandName['en-US'],
|
||||||
metaDescription: brand.shortDescription!['en-US'],
|
metaDescription: brand.shortDescription['en-US'],
|
||||||
metaImage: '',
|
metaImage: '',
|
||||||
metaSocial: [],
|
metaSocial: [],
|
||||||
metaTitle: brand.brandName['en-US'],
|
metaTitle: brand.brandName['en-US'],
|
||||||
|
@ -85,7 +85,7 @@ export const genericPageForBrand = ({ brand, brandId, homePageId }: PageForBrand
|
||||||
schemaId: '',
|
schemaId: '',
|
||||||
schemaName: '',
|
schemaName: '',
|
||||||
keywords: brand.brandName['es-US'],
|
keywords: brand.brandName['es-US'],
|
||||||
metaDescription: brand.shortDescription!['es-US'],
|
metaDescription: brand.shortDescription['es-US'],
|
||||||
metaImage: '',
|
metaImage: '',
|
||||||
metaSocial: [],
|
metaSocial: [],
|
||||||
metaTitle: brand.brandName['es-US'],
|
metaTitle: brand.brandName['es-US'],
|
||||||
|
@ -94,7 +94,7 @@ export const genericPageForBrand = ({ brand, brandId, homePageId }: PageForBrand
|
||||||
schemaId: '',
|
schemaId: '',
|
||||||
schemaName: '',
|
schemaName: '',
|
||||||
keywords: brand.brandName['fr-CA'],
|
keywords: brand.brandName['fr-CA'],
|
||||||
metaDescription: brand.shortDescription!['fr-CA'],
|
metaDescription: brand.shortDescription['fr-CA'],
|
||||||
metaImage: '',
|
metaImage: '',
|
||||||
metaSocial: [],
|
metaSocial: [],
|
||||||
metaTitle: brand.brandName['fr-CA'],
|
metaTitle: brand.brandName['fr-CA'],
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import cheerio, { type CheerioAPI } from 'cheerio';
|
import cheerio, { type CheerioAPI } from 'cheerio';
|
||||||
import { type AmazonProductDetails } from '../old-data/products/amazon-product-details';
|
import { type AmazonProductDetails } from '../data/products/amazon-product-details';
|
||||||
import { type ProductAttribute } from '../old-data/products/product-attribute';
|
import { type ProductAttribute } from '../data/products/product-attribute';
|
||||||
import { parseNumberFromSelector } from './utils';
|
import { parseNumberFromSelector } from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user