Migrated to release candidate Squidex SDK
This commit is contained in:
parent
c989bbaa9c
commit
783ef8e7c3
|
|
@ -44,7 +44,7 @@ export default defineConfig({
|
||||||
transformMixedEsModules: true,
|
transformMixedEsModules: true,
|
||||||
},
|
},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: ['@squidex/squidex', '../squidex-node-sdk'],
|
// external: ['@squidex/squidex', '../squidex-node-sdk'],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
|
|
@ -52,7 +52,7 @@ export default defineConfig({
|
||||||
commonjs(/**/)
|
commonjs(/**/)
|
||||||
],
|
],
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
exclude: ['@squidex/squidex', '../squidex-node-sdk'],
|
// exclude: ['@squidex/squidex', '../squidex-node-sdk'],
|
||||||
}
|
}
|
||||||
// resolve: {
|
// resolve: {
|
||||||
// alias: [
|
// alias: [
|
||||||
|
|
|
||||||
|
|
@ -97,11 +97,11 @@ 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,
|
||||||
body: listing as any,
|
requestBody: listing as any,
|
||||||
}, {
|
|
||||||
timeoutInSeconds: core.TIMEOUT_IN_SECONDS
|
|
||||||
});
|
});
|
||||||
log(`Listing version ${updatedDto.version} stored.`);
|
log(`Listing version ${updatedDto.version} stored.`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,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[]) {
|
||||||
|
|
@ -46,20 +46,21 @@ export async function lookupAmazonASINs(asins: string[]) {
|
||||||
] } },
|
] } },
|
||||||
requestDate: { iv: requestDate }
|
requestDate: { iv: requestDate }
|
||||||
}
|
}
|
||||||
let amazonGetItemDto = await client.contents.postContent(SCHEMAS.AMAZON_GET_ITEMS, {
|
let amazonGetItemDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.AMAZON_GET_ITEMS,
|
||||||
publish: true,
|
publish: true,
|
||||||
body: amazonGetItem as any,
|
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() {
|
||||||
|
|
@ -97,8 +98,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({
|
||||||
body: {
|
schema: SCHEMAS.BRANDS,
|
||||||
|
requestBody: {
|
||||||
brandName: {
|
brandName: {
|
||||||
"en-US": brandName!,
|
"en-US": brandName!,
|
||||||
"es-US": brandName!,
|
"es-US": brandName!,
|
||||||
|
|
@ -110,10 +112,8 @@ export async function getAddNewBrandDtoByName(brandName: string) {
|
||||||
"fr-CA": `fr-CA/${slugify(brandName!, { lower: true, trim: true })}`
|
"fr-CA": `fr-CA/${slugify(brandName!, { lower: true, trim: true })}`
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
timeoutInSeconds: TIMEOUT_IN_SECONDS,
|
|
||||||
});
|
});
|
||||||
let brandsDto = await client.contents.getContents(SCHEMAS.BRANDS, { unpublished: true, ids: brandDto.id }, { timeoutInSeconds: TIMEOUT_IN_SECONDS }) as ContentsDto<Brand>;
|
let brandsDto = await client.contents.getContents({ schema: SCHEMAS.BRANDS, unpublished: true, ids: brandDto.id }) as ContentsDto<Brand>;
|
||||||
return brandsDto;
|
return brandsDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,8 +128,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({
|
||||||
body: {
|
schema: SCHEMAS.SELLERS,
|
||||||
|
requestBody: {
|
||||||
sellerName: {
|
sellerName: {
|
||||||
"en-US": sellerName!,
|
"en-US": sellerName!,
|
||||||
"es-US": sellerName!,
|
"es-US": sellerName!,
|
||||||
|
|
@ -141,10 +142,8 @@ export async function getAddNewSellerDtoByName(sellerName: string) {
|
||||||
"fr-CA": `fr-CA/${slugify(sellerName!, { lower: true, trim: true })}`
|
"fr-CA": `fr-CA/${slugify(sellerName!, { lower: true, trim: true })}`
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
timeoutInSeconds: TIMEOUT_IN_SECONDS,
|
|
||||||
});
|
});
|
||||||
let sellersDto = await client.contents.getContents(SCHEMAS.SELLERS, { unpublished: true, ids: sellerDto.id }, {timeoutInSeconds: TIMEOUT_IN_SECONDS}) as ContentsDto<Seller>;
|
let sellersDto = await client.contents.getContents({ schema: SCHEMAS.SELLERS, unpublished: true, ids: sellerDto.id }) as ContentsDto<Seller>;
|
||||||
return sellersDto;
|
return sellersDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -407,17 +406,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,
|
publish: false,
|
||||||
body: {
|
requestBody: {
|
||||||
categoryName,
|
categoryName,
|
||||||
description,
|
description,
|
||||||
parentCategory: parentProductCategoryId,
|
parentCategory: parentProductCategoryId,
|
||||||
},
|
},
|
||||||
}, {
|
|
||||||
timeoutInSeconds: TIMEOUT_IN_SECONDS,
|
|
||||||
});
|
});
|
||||||
let productCategoriesDto = await client.contents.getContents(SCHEMAS.PRODUCT_CATEGORIES, { unpublished: true, ids: productCategoryDto.id }, {timeoutInSeconds: TIMEOUT_IN_SECONDS}) 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -448,28 +446,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, {
|
let productDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.PRODUCTS,
|
||||||
publish: false,
|
publish: false,
|
||||||
body: {
|
requestBody: {
|
||||||
...product
|
...product
|
||||||
},
|
},
|
||||||
}, {
|
|
||||||
timeoutInSeconds: TIMEOUT_IN_SECONDS,
|
|
||||||
});
|
});
|
||||||
let productsDto = await client.contents.getContents(SCHEMAS.PRODUCTS, { unpublished: true, ids: productDto.id }, {timeoutInSeconds: TIMEOUT_IN_SECONDS}) as ContentsDto<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, {
|
let listingDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.LISTINGS,
|
||||||
publish: true,
|
publish: true,
|
||||||
body: {
|
requestBody: {
|
||||||
...listing
|
...listing
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
timeoutInSeconds: TIMEOUT_IN_SECONDS,
|
|
||||||
});
|
});
|
||||||
let listingsDto = await client.contents.getContents(SCHEMAS.LISTINGS, { unpublished: true, ids: listingDto.id }, {timeoutInSeconds: TIMEOUT_IN_SECONDS}) as ContentsDto<Listing>;
|
let listingsDto = await client.contents.getContents({ schema: SCHEMAS.LISTINGS, unpublished: true, ids: listingDto.id }) as ContentsDto<Listing>;
|
||||||
return listingsDto;
|
return listingsDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -482,11 +478,11 @@ export function removeQuotes(str: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function upsertAssetFolder(folderName: string, parentFolderId?: string|undefined) {
|
export async function upsertAssetFolder(folderName: string, parentFolderId?: string|undefined) {
|
||||||
const assetFolders = await client.assets.getAssetFolders({ scope: 'Items', parentId: parentFolderId }, { timeoutInSeconds: TIMEOUT_IN_SECONDS });
|
const assetFolders = await client.assets.getAssetFolders({ scope: 'Items', parentId: parentFolderId });
|
||||||
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 }, { timeoutInSeconds: TIMEOUT_IN_SECONDS });
|
assetFolder = await client.assets.postAssetFolder({ createAssetFolderDto: { folderName: folderName, parentId: parentFolderId }});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assetFolder = assetFolderLookup[0];
|
assetFolder = assetFolderLookup[0];
|
||||||
|
|
@ -501,20 +497,19 @@ export async function getAllAssetsInFolder(assetFolderId: string) {
|
||||||
|
|
||||||
export async function uploadDownloadedImageToSquidexAsAsset(downloadUrl: string, assetFolderId: string) {
|
export async function uploadDownloadedImageToSquidexAsAsset(downloadUrl: string, assetFolderId: string) {
|
||||||
let filename = downloadUrl.substring(downloadUrl.lastIndexOf('/')+1);
|
let filename = downloadUrl.substring(downloadUrl.lastIndexOf('/')+1);
|
||||||
let response = await axios.get(downloadUrl, { timeout: TIMEOUT_IN_SECONDS * 1000, responseType: 'arraybuffer' });
|
let response = await axios.get(downloadUrl, { timeout: TIMEOUT_IN_SECONDS * 1000, responseType: 'blob' });
|
||||||
let assetDto = await client.assets.postAsset({ readable: response.data, fileName: filename }, { timeoutInSeconds: TIMEOUT_IN_SECONDS });
|
let assetDto = await client.assets.postAsset({ file: response.data, fileName: filename });
|
||||||
assetDto = await client.assets.putAsset(assetDto.id, { fileName: filename, metadata: { ...assetDto.metadata, 'amazon-url': downloadUrl }, tags: ['amazon', 'product'] })
|
assetDto = await client.assets.putAsset({ id: assetDto.id, annotateAssetDto: { metadata: { ...assetDto.metadata, 'amazon-url': downloadUrl }, tags: ['amazon', 'product'] } })
|
||||||
assetDto = await client.assets.putAssetParent(assetDto.id, { 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, {
|
let offerDto = await client.contents.postContent({
|
||||||
|
schema: SCHEMAS.OFFERS,
|
||||||
publish: true,
|
publish: true,
|
||||||
body: offer as any,
|
requestBody: offer as any,
|
||||||
}, {
|
|
||||||
timeoutInSeconds: TIMEOUT_IN_SECONDS,
|
|
||||||
});
|
});
|
||||||
let offersDto = await client.contents.getContents(SCHEMAS.OFFERS, { unpublished: true, ids: offerDto.id }, {timeoutInSeconds: TIMEOUT_IN_SECONDS}) as ContentsDto<ProductCategory>;
|
let offersDto = await client.contents.getContents({ schema: SCHEMAS.OFFERS, unpublished: true, ids: offerDto.id }) as ContentsDto<ProductCategory>;
|
||||||
return offersDto;
|
return offersDto;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import * as core from "./core/client";
|
import * as core from "./core/client";
|
||||||
import { SCHEMAS } from "./models/schemas";
|
import { SCHEMAS } from "./models/schemas";
|
||||||
import { getContents } from "./core/client.js";
|
import { getAllContents } from "./core/client.js";
|
||||||
import { SupportedLocales, type Localized } from "./internals/LocalizedT.js";
|
import { SupportedLocales, type Localized } from "./internals/LocalizedT.js";
|
||||||
import type { Component } from "./internals/Component";
|
import type { Component } from "./internals/Component";
|
||||||
import type { Brand } from "./models/multis/Brand";
|
import type { Brand } from "./models/multis/Brand";
|
||||||
|
|
@ -14,7 +14,6 @@ import type { Slug } from "./models/multis/Slug";
|
||||||
import type { Seller } from "./models/multis/Seller";
|
import type { Seller } from "./models/multis/Seller";
|
||||||
import type { NonLocalized } from "./internals/NonLocalizedT.js";
|
import type { NonLocalized } from "./internals/NonLocalizedT.js";
|
||||||
import type { ContentsDto } from "./internals/ContentsDtoT";
|
import type { ContentsDto } from "./internals/ContentsDtoT";
|
||||||
import type { ContentData } from "@squidex/squidex/api/types/ContentData";
|
|
||||||
import type { ContentDto } from "./internals/ContentDtoT";
|
import type { ContentDto } from "./internals/ContentDtoT";
|
||||||
import type { Listing } from "./models/multis/Listing.js";
|
import type { Listing } from "./models/multis/Listing.js";
|
||||||
import type { Offer } from "./models/multis/Offer.js";
|
import type { Offer } from "./models/multis/Offer.js";
|
||||||
|
|
@ -144,7 +143,7 @@ export const getRedirectsByPreviousSlug = async (prevSlug: string) =>
|
||||||
/** Slugs handlers */
|
/** Slugs handlers */
|
||||||
|
|
||||||
export const getAllSlugs = async () =>
|
export const getAllSlugs = async () =>
|
||||||
await core.getContents<Slug>(SCHEMAS.SLUGS);
|
await core.getAllContents<Slug>(SCHEMAS.SLUGS);
|
||||||
|
|
||||||
export const getSlugByLangSlug = async (forLang: SupportedLocales|string, slug: string) =>
|
export const getSlugByLangSlug = async (forLang: SupportedLocales|string, slug: string) =>
|
||||||
await core.getContentsUsingJsonQuery<Slug>(SCHEMAS.SLUGS, JSON.stringify({
|
await core.getContentsUsingJsonQuery<Slug>(SCHEMAS.SLUGS, JSON.stringify({
|
||||||
|
|
@ -159,7 +158,7 @@ export const getSlugByLangSlug = async (forLang: SupportedLocales|string, slug:
|
||||||
/** Site handlers */
|
/** Site handlers */
|
||||||
|
|
||||||
export const getSite = async () =>
|
export const getSite = async () =>
|
||||||
await getContents<Site>(SCHEMAS.SITE);
|
await getAllContents<Site>(SCHEMAS.SITE);
|
||||||
|
|
||||||
export const getSiteHomePage = async (site: Site) => {
|
export const getSiteHomePage = async (site: Site) => {
|
||||||
if (site.homePage && site.homePage.iv.length > 0) {
|
if (site.homePage && site.homePage.iv.length > 0) {
|
||||||
|
|
@ -171,7 +170,7 @@ export const getSiteHomePage = async (site: Site) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSiteConfig = async () =>
|
export const getSiteConfig = async () =>
|
||||||
await getContents<SiteConfig>(SCHEMAS.SITE_CONFIG);
|
await getAllContents<SiteConfig>(SCHEMAS.SITE_CONFIG);
|
||||||
|
|
||||||
export async function performSyncLocalizedSlugs(logFn = console.log) {
|
export async function performSyncLocalizedSlugs(logFn = console.log) {
|
||||||
logFn("Begin sync localized slugs.")
|
logFn("Begin sync localized slugs.")
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
import { config } from "../../config.js";
|
import { config } from "../../config.js";
|
||||||
import { Squidex, SquidexClient } from "@squidex/squidex";
|
import { SquidexClient } from "@squidex/squidex";
|
||||||
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";
|
||||||
import type { Contents } from "@squidex/squidex/api/resources/contents/client/Client.js";
|
|
||||||
|
|
||||||
export const client = new SquidexClient({
|
export const client = new SquidexClient({
|
||||||
appName: config.squidexAppName!,
|
appName: config.squidexAppName!,
|
||||||
|
|
@ -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, {timeoutInSeconds: TIMEOUT_IN_SECONDS})
|
await client.assets.getAsset({ id: assetId })
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Generic Content Handling */
|
/** Generic Content Handling */
|
||||||
|
|
||||||
export const getContents = async <T>(schema: SCHEMAS|string) => (
|
export const getAllContents = async <T>(schema: SCHEMAS|string) => (
|
||||||
await client.contents.getContents(schema, { }, { timeoutInSeconds: TIMEOUT_IN_SECONDS })
|
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 }, { timeoutInSeconds: TIMEOUT_IN_SECONDS })
|
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 }, { timeoutInSeconds: TIMEOUT_IN_SECONDS })
|
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) => (
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Squidex } from "@squidex/squidex";
|
import type { ContentDto as SquidexContentDto } from "@squidex/squidex";
|
||||||
|
|
||||||
export interface ContentDto<T> extends Squidex.ContentDto {
|
export interface ContentDto<T> extends SquidexContentDto {
|
||||||
data?: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { ContentDto } from "./ContentDtoT";
|
import type { ContentDto } from "./ContentDtoT";
|
||||||
import { Squidex } from "@squidex/squidex";
|
import type { ContentsDto as SquidexContentsDto } from "@squidex/squidex";
|
||||||
|
|
||||||
export interface ContentsDto<T> extends Squidex.ContentsDto {
|
export interface ContentsDto<T> extends SquidexContentsDto {
|
||||||
/** The generic content items. */
|
/** The generic content items. */
|
||||||
items: ContentDto<T>[];
|
items: ContentDto<T>[];
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,7 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page as Page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page as Page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
<meta name="description" content={metaDescription} />
|
<meta name="description" content={metaDescription} />
|
||||||
{
|
{
|
||||||
|
|
@ -160,7 +160,7 @@ try {
|
||||||
<main>
|
<main>
|
||||||
<Banner editToken={siteDto.items[0].editToken} homePageLink={`/${locale}/`} siteName={site.siteName[locale]} />
|
<Banner editToken={siteDto.items[0].editToken} homePageLink={`/${locale}/`} siteName={site.siteName[locale]} />
|
||||||
<ComponentRouter
|
<ComponentRouter
|
||||||
pageEditToken={pageDto?.items[0].editToken}
|
pageEditToken={pageDto?.items[0].editToken!}
|
||||||
componentRouter={getLocaleField(locale, page.content)||[]}
|
componentRouter={getLocaleField(locale, page.content)||[]}
|
||||||
homePage={homePage as Page}
|
homePage={homePage as Page}
|
||||||
isHomePage={isHomePage}
|
isHomePage={isHomePage}
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,10 @@ else {
|
||||||
console.log("redirectDto:", redirectDto);
|
console.log("redirectDto:", redirectDto);
|
||||||
if (redirectDto && redirectDto.items && redirectDto.items.length > 0) {
|
if (redirectDto && redirectDto.items && redirectDto.items.length > 0) {
|
||||||
console.log("getting redirectReferencesDto for", SCHEMAS.REDIRECTS, redirectDto.items[0].id);
|
console.log("getting redirectReferencesDto for", SCHEMAS.REDIRECTS, redirectDto.items[0].id);
|
||||||
let redirectReferencesDto = await client.contents.getReferences(SCHEMAS.REDIRECTS, redirectDto.items[0].id);
|
//next line crashes:
|
||||||
|
let redirectReferencesDto = await client.contents.getReferences({ schema: SCHEMAS.REDIRECTS, id: redirectDto.items[0].id });
|
||||||
console.log("redirectReferencesDto:", redirectReferencesDto);
|
console.log("redirectReferencesDto:", redirectReferencesDto);
|
||||||
client.contents.getConten
|
// client.contents.getConten
|
||||||
// switch (redirectDto.items[0].data?.referenceSchema.iv) {
|
// switch (redirectDto.items[0].data?.referenceSchema.iv) {
|
||||||
// case SCHEMAS.BRANDS:
|
// case SCHEMAS.BRANDS:
|
||||||
// return Astro.rewrite(`/view/brands/${locale}/${objectId}`);
|
// return Astro.rewrite(`/view/brands/${locale}/${objectId}`);
|
||||||
|
|
@ -136,7 +137,7 @@ const renderContext = {
|
||||||
shouldEmbedSquidexSDK,
|
shouldEmbedSquidexSDK,
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot slot="head">
|
<slot slot="head">
|
||||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||||
{
|
{
|
||||||
|
|
@ -177,7 +178,7 @@ const renderContext = {
|
||||||
pageEditToken={pageEditToken}
|
pageEditToken={pageEditToken}
|
||||||
brand={brand||undefined}
|
brand={brand||undefined}
|
||||||
site={site}
|
site={site}
|
||||||
siteEditToken={siteEditToken}
|
siteEditToken={siteEditToken!}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<slot name="disclaimers" slot="disclaimers">
|
<slot name="disclaimers" slot="disclaimers">
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ const renderContext = {
|
||||||
shouldEmbedSquidexSDK,
|
shouldEmbedSquidexSDK,
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||||
{
|
{
|
||||||
|
|
@ -90,10 +90,10 @@ const renderContext = {
|
||||||
isHomePage={false}
|
isHomePage={false}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
page={page}
|
page={page}
|
||||||
pageEditToken={pageEditToken}
|
pageEditToken={pageEditToken!}
|
||||||
brand={brand||undefined}
|
brand={brand||undefined}
|
||||||
site={site}
|
site={site}
|
||||||
siteEditToken={siteEditToken}
|
siteEditToken={siteEditToken!}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<span slot="disclaimers">
|
<span slot="disclaimers">
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ const renderContext = {
|
||||||
shouldEmbedSquidexSDK,
|
shouldEmbedSquidexSDK,
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||||
{
|
{
|
||||||
|
|
@ -90,10 +90,10 @@ const renderContext = {
|
||||||
isHomePage={false}
|
isHomePage={false}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
page={page}
|
page={page}
|
||||||
pageEditToken={pageEditToken}
|
pageEditToken={pageEditToken!}
|
||||||
marketplace={marketplace}
|
marketplace={marketplace}
|
||||||
site={site}
|
site={site}
|
||||||
siteEditToken={siteEditToken}
|
siteEditToken={siteEditToken!}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<span slot="disclaimers">
|
<span slot="disclaimers">
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ const renderContext = {
|
||||||
shouldEmbedSquidexSDK,
|
shouldEmbedSquidexSDK,
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||||
{
|
{
|
||||||
|
|
@ -96,9 +96,9 @@ const renderContext = {
|
||||||
isHomePage={isHomePage}
|
isHomePage={isHomePage}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
page={page}
|
page={page}
|
||||||
pageEditToken={pageEditToken}
|
pageEditToken={pageEditToken!}
|
||||||
site={site}
|
site={site}
|
||||||
siteEditToken={siteEditToken}
|
siteEditToken={siteEditToken!}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<span slot="disclaimers">
|
<span slot="disclaimers">
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ const renderContext = {
|
||||||
shouldEmbedSquidexSDK,
|
shouldEmbedSquidexSDK,
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||||
{
|
{
|
||||||
|
|
@ -91,11 +91,11 @@ const renderContext = {
|
||||||
isHomePage={false}
|
isHomePage={false}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
page={page}
|
page={page}
|
||||||
pageEditToken={pageEditToken}
|
pageEditToken={pageEditToken!}
|
||||||
productCategory={productCategory}
|
productCategory={productCategory}
|
||||||
brand={undefined}
|
brand={undefined}
|
||||||
site={site}
|
site={site}
|
||||||
siteEditToken={siteEditToken}
|
siteEditToken={siteEditToken!}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<span slot="disclaimers">
|
<span slot="disclaimers">
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ const renderContext = {
|
||||||
// disclaimers,
|
// disclaimers,
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||||
{
|
{
|
||||||
|
|
@ -94,11 +94,11 @@ const renderContext = {
|
||||||
isHomePage={false}
|
isHomePage={false}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
page={page}
|
page={page}
|
||||||
pageEditToken={pageEditToken}
|
pageEditToken={pageEditToken!}
|
||||||
productDto={productDto}
|
productDto={productDto}
|
||||||
brand={undefined}
|
brand={undefined}
|
||||||
site={site}
|
site={site}
|
||||||
siteEditToken={siteEditToken}
|
siteEditToken={siteEditToken!}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<span slot="disclaimers">
|
<span slot="disclaimers">
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ const renderContext = {
|
||||||
shouldEmbedSquidexSDK,
|
shouldEmbedSquidexSDK,
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
<Layout locale={locale} title={title} site={site} siteConfig={siteConfig} siteEditToken={siteDto.items[0].editToken!} page={page} shouldEmbedSquidexSDK={shouldEmbedSquidexSDK}>
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||||
{
|
{
|
||||||
|
|
@ -90,10 +90,10 @@ const renderContext = {
|
||||||
isHomePage={false}
|
isHomePage={false}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
page={page}
|
page={page}
|
||||||
pageEditToken={pageEditToken}
|
pageEditToken={pageEditToken!}
|
||||||
seller={seller}
|
seller={seller}
|
||||||
site={site}
|
site={site}
|
||||||
siteEditToken={siteEditToken}
|
siteEditToken={siteEditToken!}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
<span slot="disclaimers">
|
<span slot="disclaimers">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user