Compare commits
2 Commits
a6fde93c6e
...
783ef8e7c3
| Author | SHA1 | Date | |
|---|---|---|---|
| 783ef8e7c3 | |||
| c989bbaa9c |
|
|
@ -44,7 +44,7 @@ export default defineConfig({
|
|||
transformMixedEsModules: true,
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ['@squidex/squidex', '../squidex-node-sdk'],
|
||||
// external: ['@squidex/squidex', '../squidex-node-sdk'],
|
||||
}
|
||||
},
|
||||
vite: {
|
||||
|
|
@ -52,7 +52,7 @@ export default defineConfig({
|
|||
commonjs(/**/)
|
||||
],
|
||||
optimizeDeps: {
|
||||
exclude: ['@squidex/squidex', '../squidex-node-sdk'],
|
||||
// exclude: ['@squidex/squidex', '../squidex-node-sdk'],
|
||||
}
|
||||
// resolve: {
|
||||
// alias: [
|
||||
|
|
|
|||
|
|
@ -97,11 +97,11 @@ export const amazonAppendImagesCommand = (amazonCommand: Command) =>
|
|||
}
|
||||
if (didUpdate) {
|
||||
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,
|
||||
body: listing as any,
|
||||
}, {
|
||||
timeoutInSeconds: core.TIMEOUT_IN_SECONDS
|
||||
requestBody: listing as any,
|
||||
});
|
||||
log(`Listing version ${updatedDto.version} stored.`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { Command } from "commander";
|
|||
import { amazonAppendImagesCommand } from "./amazon-append-images";
|
||||
import { amazonCrawleeProductsCommand } from "./amazon-crawlee-products";
|
||||
import { amazonProcureASINsCommand } from "./amazon-procure-asins";
|
||||
import { amazonGetItemsCommand } from "./get-items/get-items";
|
||||
import { amazonGetItemsCommand } from "./get-items/amazon-get-items";
|
||||
|
||||
const COMMAND_NAME = 'amazon';
|
||||
|
||||
|
|
|
|||
26
src/apps/catalog/amazon/get-items/amazon-get-items-fetch.ts
Normal file
26
src/apps/catalog/amazon/get-items/amazon-get-items-fetch.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import type { Command } from "commander";
|
||||
import * as core from '../../../../data/core/client'
|
||||
import { getProductsUsingJsonQuery } from "../../../../data/api-client";
|
||||
import type { AmazonMarketplaceConnection } from "../../../../data/models/components/AmazonMarketplaceConnection";
|
||||
import { logForCommand } from "../../common/console";
|
||||
import { SCHEMAS } from "../../../../data/models/schemas";
|
||||
import type { AmazonGetItem } from "../../../../data/models/multis/AmazonGetItem";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
export const COMMAND_NAME = 'fetch';
|
||||
|
||||
export const amazonGetItemsFetchCommand = (commandName: string, amazonGetItemsCommand: Command) => {
|
||||
const log = logForCommand(commandName);
|
||||
const command = amazonGetItemsCommand.command(commandName).alias('get')
|
||||
.description('List all the get-items logs')
|
||||
.action(async (args: string[]) => {
|
||||
let logsDto = await core.getContentsUsingJsonQuery<AmazonGetItem>(SCHEMAS.AMAZON_GET_ITEMS);
|
||||
logsDto.items.forEach((logDto, index) => {
|
||||
const logEach = logForCommand(`${commandName}:${index+1}`);
|
||||
logEach(`ID: ${logDto.id} Request Date: ${DateTime.fromISO(logDto.data?.requestDate.iv!).toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS)}`)
|
||||
});
|
||||
log(`Returned ${logsDto.items.length} get-items logs.`)
|
||||
});
|
||||
command.configureHelp();
|
||||
return command;
|
||||
}
|
||||
|
|
@ -9,10 +9,9 @@ import { DateTime } from "luxon";
|
|||
|
||||
export const COMMAND_NAME = 'logs';
|
||||
|
||||
const log = console.log;
|
||||
|
||||
export const amazonGetItemsLogsCommand = (amazonGetItemsCommand: Command) => {
|
||||
const command = amazonGetItemsCommand.command(COMMAND_NAME).alias('log')
|
||||
export const amazonGetItemsLogsCommand = (commandName: string, amazonGetItemsCommand: Command) => {
|
||||
const log = console.log;
|
||||
const command = amazonGetItemsCommand.command(commandName).alias('log')
|
||||
.description('Prints the get-items JSON response')
|
||||
.argument('<log-ids...>')
|
||||
.action(async (logIds: string[]) => {
|
||||
|
|
|
|||
|
|
@ -9,15 +9,16 @@ import { DateTime } from "luxon";
|
|||
|
||||
export const COMMAND_NAME = 'ls';
|
||||
|
||||
const log = logForCommand(COMMAND_NAME);
|
||||
|
||||
export const amazonGetItemsLsCommand = (amazonGetItemsCommand: Command) => {
|
||||
const command = amazonGetItemsCommand.command(COMMAND_NAME).alias('list')
|
||||
.description('List all the get-items logs')
|
||||
.action(async (args: string[]) => {
|
||||
export const amazonGetItemsLsCommand = (commandName: string, amazonGetItemsCommand: Command) => {
|
||||
const log = logForCommand(commandName);
|
||||
const command = amazonGetItemsCommand.command(commandName).alias('list')
|
||||
.description('Fetch Amazon Items by inputting one or more ASINs separated by spaces.')
|
||||
.argument('<ASINs...>', 'Amazon Standard Identification Numbers')
|
||||
.description('Begin automated product procurement from Amazon by inputting one or more ASINs separated by spaces.')
|
||||
.action(async (args: string[]) => {
|
||||
let logsDto = await core.getContentsUsingJsonQuery<AmazonGetItem>(SCHEMAS.AMAZON_GET_ITEMS);
|
||||
logsDto.items.forEach((logDto, index) => {
|
||||
const logEach = logForCommand(`${COMMAND_NAME}:${index+1}`);
|
||||
const logEach = logForCommand(`${commandName}:${index+1}`);
|
||||
logEach(`ID: ${logDto.id} Request Date: ${DateTime.fromISO(logDto.data?.requestDate.iv!).toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS)}`)
|
||||
});
|
||||
log(`Returned ${logsDto.items.length} get-items logs.`)
|
||||
|
|
|
|||
14
src/apps/catalog/amazon/get-items/amazon-get-items.ts
Normal file
14
src/apps/catalog/amazon/get-items/amazon-get-items.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import type { Command } from "commander";
|
||||
import * as fetch from "./amazon-get-items-fetch";
|
||||
import * as ls from "./amazon-get-items-ls";
|
||||
import * as logs from "./amazon-get-items-logs";
|
||||
|
||||
const COMMAND_NAME = 'get-items';
|
||||
|
||||
export const amazonGetItemsCommand = (program: Command) => {
|
||||
const amazonGetItemsCommand = program.command(COMMAND_NAME).alias('get-item').description('Amazon Get Items commands');
|
||||
fetch.amazonGetItemsFetchCommand(fetch.COMMAND_NAME, amazonGetItemsCommand);
|
||||
ls.amazonGetItemsLsCommand(ls.COMMAND_NAME, amazonGetItemsCommand);
|
||||
logs.amazonGetItemsLogsCommand(logs.COMMAND_NAME, amazonGetItemsCommand);
|
||||
return amazonGetItemsCommand;
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import type { Command } from "commander";
|
||||
import { amazonGetItemsLsCommand } from "./amazon-get-items-ls";
|
||||
import { amazonGetItemsLogsCommand } from "./amazon-get-items-logs";
|
||||
|
||||
const COMMAND_NAME = 'get-items';
|
||||
|
||||
export const amazonGetItemsCommand = (program: Command) => {
|
||||
const amazonGetItemsCommand = program.command(COMMAND_NAME).alias('get-item').description('Amazon Get Items commands');
|
||||
amazonGetItemsLsCommand(amazonGetItemsCommand);
|
||||
amazonGetItemsLogsCommand(amazonGetItemsCommand);
|
||||
return amazonGetItemsCommand;
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ export function isValidASIN(asinOrNot: string) {
|
|||
}
|
||||
|
||||
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[]) {
|
||||
|
|
@ -46,20 +46,21 @@ export async function lookupAmazonASINs(asins: string[]) {
|
|||
] } },
|
||||
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,
|
||||
body: amazonGetItem as any,
|
||||
requestBody: amazonGetItem as any,
|
||||
})
|
||||
let amazonGetItemsDto = await getContentsByIds<AmazonGetItem>(SCHEMAS.AMAZON_GET_ITEMS, amazonGetItemDto.id);
|
||||
return amazonGetItemsDto;
|
||||
}
|
||||
|
||||
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() {
|
||||
return await client.schemas.getSchema('product-marketplace-connection-amazon')
|
||||
return await client.schemas.getSchema({ schema: 'product-marketplace-connection-amazon' })
|
||||
}
|
||||
|
||||
export async function getAmazonMarketplaceDto() {
|
||||
|
|
@ -97,8 +98,9 @@ export async function getBrandDtoByName(brandName: string) {
|
|||
}
|
||||
|
||||
export async function getAddNewBrandDtoByName(brandName: string) {
|
||||
let brandDto = await client.contents.postContent(SCHEMAS.BRANDS, {
|
||||
body: {
|
||||
let brandDto = await client.contents.postContent({
|
||||
schema: SCHEMAS.BRANDS,
|
||||
requestBody: {
|
||||
brandName: {
|
||||
"en-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 })}`
|
||||
},
|
||||
}
|
||||
}, {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +128,9 @@ export async function getSellerDtoByName(sellerName: string) {
|
|||
}
|
||||
|
||||
export async function getAddNewSellerDtoByName(sellerName: string) {
|
||||
let sellerDto = await client.contents.postContent(SCHEMAS.SELLERS, {
|
||||
body: {
|
||||
let sellerDto = await client.contents.postContent({
|
||||
schema: SCHEMAS.SELLERS,
|
||||
requestBody: {
|
||||
sellerName: {
|
||||
"en-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 })}`
|
||||
},
|
||||
}
|
||||
}, {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -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>) {
|
||||
let productCategoryDto = await client.contents.postContent(SCHEMAS.PRODUCT_CATEGORIES, {
|
||||
let productCategoryDto = await client.contents.postContent({
|
||||
schema: SCHEMAS.PRODUCT_CATEGORIES,
|
||||
publish: false,
|
||||
body: {
|
||||
requestBody: {
|
||||
categoryName,
|
||||
description,
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -448,28 +446,26 @@ export async function translateAmazonDescription_from_en_US_to_fr_CA(brandName:
|
|||
}
|
||||
|
||||
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,
|
||||
body: {
|
||||
requestBody: {
|
||||
...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;
|
||||
}
|
||||
|
||||
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,
|
||||
body: {
|
||||
requestBody: {
|
||||
...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;
|
||||
}
|
||||
|
||||
|
|
@ -482,11 +478,11 @@ export function removeQuotes(str: string) {
|
|||
}
|
||||
|
||||
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 assetFolderLookup = assetFolders.items.filter(folder => folder.folderName === folderName);
|
||||
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 {
|
||||
assetFolder = assetFolderLookup[0];
|
||||
|
|
@ -501,20 +497,19 @@ export async function getAllAssetsInFolder(assetFolderId: string) {
|
|||
|
||||
export async function uploadDownloadedImageToSquidexAsAsset(downloadUrl: string, assetFolderId: string) {
|
||||
let filename = downloadUrl.substring(downloadUrl.lastIndexOf('/')+1);
|
||||
let response = await axios.get(downloadUrl, { timeout: TIMEOUT_IN_SECONDS * 1000, responseType: 'arraybuffer' });
|
||||
let assetDto = await client.assets.postAsset({ readable: response.data, fileName: filename }, { timeoutInSeconds: TIMEOUT_IN_SECONDS });
|
||||
assetDto = await client.assets.putAsset(assetDto.id, { fileName: filename, metadata: { ...assetDto.metadata, 'amazon-url': downloadUrl }, tags: ['amazon', 'product'] })
|
||||
assetDto = await client.assets.putAssetParent(assetDto.id, { parentId: assetFolderId });
|
||||
let response = await axios.get(downloadUrl, { timeout: TIMEOUT_IN_SECONDS * 1000, responseType: 'blob' });
|
||||
let assetDto = await client.assets.postAsset({ file: response.data, fileName: filename });
|
||||
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 } });
|
||||
return assetDto;
|
||||
}
|
||||
|
||||
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,
|
||||
body: offer as any,
|
||||
}, {
|
||||
timeoutInSeconds: TIMEOUT_IN_SECONDS,
|
||||
requestBody: offer as any,
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as core from "./core/client";
|
||||
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 type { Component } from "./internals/Component";
|
||||
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 { NonLocalized } from "./internals/NonLocalizedT.js";
|
||||
import type { ContentsDto } from "./internals/ContentsDtoT";
|
||||
import type { ContentData } from "@squidex/squidex/api/types/ContentData";
|
||||
import type { ContentDto } from "./internals/ContentDtoT";
|
||||
import type { Listing } from "./models/multis/Listing.js";
|
||||
import type { Offer } from "./models/multis/Offer.js";
|
||||
|
|
@ -144,7 +143,7 @@ export const getRedirectsByPreviousSlug = async (prevSlug: string) =>
|
|||
/** Slugs handlers */
|
||||
|
||||
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) =>
|
||||
await core.getContentsUsingJsonQuery<Slug>(SCHEMAS.SLUGS, JSON.stringify({
|
||||
|
|
@ -159,7 +158,7 @@ export const getSlugByLangSlug = async (forLang: SupportedLocales|string, slug:
|
|||
/** Site handlers */
|
||||
|
||||
export const getSite = async () =>
|
||||
await getContents<Site>(SCHEMAS.SITE);
|
||||
await getAllContents<Site>(SCHEMAS.SITE);
|
||||
|
||||
export const getSiteHomePage = async (site: Site) => {
|
||||
if (site.homePage && site.homePage.iv.length > 0) {
|
||||
|
|
@ -171,7 +170,7 @@ export const getSiteHomePage = async (site: Site) => {
|
|||
}
|
||||
|
||||
export const getSiteConfig = async () =>
|
||||
await getContents<SiteConfig>(SCHEMAS.SITE_CONFIG);
|
||||
await getAllContents<SiteConfig>(SCHEMAS.SITE_CONFIG);
|
||||
|
||||
export async function performSyncLocalizedSlugs(logFn = console.log) {
|
||||
logFn("Begin sync localized slugs.")
|
||||
|
|
|
|||
|
|
@ -19,21 +19,21 @@ export const TIMEOUT_IN_SECONDS = 10;
|
|||
/** Asset Handling */
|
||||
|
||||
export const getAssetById = async (assetId: string) => (
|
||||
await client.assets.getAsset(assetId, {timeoutInSeconds: TIMEOUT_IN_SECONDS})
|
||||
await client.assets.getAsset({ id: assetId })
|
||||
);
|
||||
|
||||
/** Generic Content Handling */
|
||||
|
||||
export const getContents = async <T>(schema: SCHEMAS|string) => (
|
||||
await client.contents.getContents(schema, { }, { timeoutInSeconds: TIMEOUT_IN_SECONDS })
|
||||
export const getAllContents = async <T>(schema: SCHEMAS|string) => (
|
||||
await client.contents.getContents({ schema })
|
||||
) as ContentsDto<T>;
|
||||
|
||||
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>;
|
||||
|
||||
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>;
|
||||
|
||||
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 {
|
||||
data?: T;
|
||||
export interface ContentDto<T> extends SquidexContentDto {
|
||||
data: T;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
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. */
|
||||
items: ContentDto<T>[];
|
||||
}
|
||||
|
|
@ -2,6 +2,9 @@ import type { PageSeo } from "../components/PageSeo";
|
|||
import type { Localized } from "../../internals/LocalizedT";
|
||||
import type { NonLocalized } from "../../internals/NonLocalizedT";
|
||||
import type { Component } from "../../internals/Component";
|
||||
import type { ContentDto } from "../../internals/ContentDtoT";
|
||||
import type { ContentsDto } from "../../internals/ContentsDtoT";
|
||||
import type { SCHEMAS } from "../schemas";
|
||||
|
||||
export interface Page {
|
||||
title: Localized<string>,
|
||||
|
|
@ -9,4 +12,10 @@ export interface Page {
|
|||
content: Localized<Component[]>,
|
||||
seo: Localized<PageSeo>,
|
||||
parentPage: NonLocalized<string[]>,
|
||||
}
|
||||
}
|
||||
|
||||
export interface PageDto extends ContentDto<Page> {
|
||||
schemaName: SCHEMAS.PAGES,
|
||||
}
|
||||
|
||||
export type PagesDto = ContentsDto<Page>;
|
||||
|
|
@ -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">
|
||||
<meta name="description" content={metaDescription} />
|
||||
{
|
||||
|
|
@ -160,7 +160,7 @@ try {
|
|||
<main>
|
||||
<Banner editToken={siteDto.items[0].editToken} homePageLink={`/${locale}/`} siteName={site.siteName[locale]} />
|
||||
<ComponentRouter
|
||||
pageEditToken={pageDto?.items[0].editToken}
|
||||
pageEditToken={pageDto?.items[0].editToken!}
|
||||
componentRouter={getLocaleField(locale, page.content)||[]}
|
||||
homePage={homePage as Page}
|
||||
isHomePage={isHomePage}
|
||||
|
|
|
|||
|
|
@ -88,9 +88,10 @@ else {
|
|||
console.log("redirectDto:", redirectDto);
|
||||
if (redirectDto && redirectDto.items && redirectDto.items.length > 0) {
|
||||
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);
|
||||
client.contents.getConten
|
||||
// client.contents.getConten
|
||||
// switch (redirectDto.items[0].data?.referenceSchema.iv) {
|
||||
// case SCHEMAS.BRANDS:
|
||||
// return Astro.rewrite(`/view/brands/${locale}/${objectId}`);
|
||||
|
|
@ -136,7 +137,7 @@ const renderContext = {
|
|||
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">
|
||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||
{
|
||||
|
|
@ -177,7 +178,7 @@ const renderContext = {
|
|||
pageEditToken={pageEditToken}
|
||||
brand={brand||undefined}
|
||||
site={site}
|
||||
siteEditToken={siteEditToken}
|
||||
siteEditToken={siteEditToken!}
|
||||
/>
|
||||
</main>
|
||||
<slot name="disclaimers" slot="disclaimers">
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ const renderContext = {
|
|||
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">
|
||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||
{
|
||||
|
|
@ -90,10 +90,10 @@ const renderContext = {
|
|||
isHomePage={false}
|
||||
locale={locale}
|
||||
page={page}
|
||||
pageEditToken={pageEditToken}
|
||||
pageEditToken={pageEditToken!}
|
||||
brand={brand||undefined}
|
||||
site={site}
|
||||
siteEditToken={siteEditToken}
|
||||
siteEditToken={siteEditToken!}
|
||||
/>
|
||||
</main>
|
||||
<span slot="disclaimers">
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ const renderContext = {
|
|||
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">
|
||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||
{
|
||||
|
|
@ -90,10 +90,10 @@ const renderContext = {
|
|||
isHomePage={false}
|
||||
locale={locale}
|
||||
page={page}
|
||||
pageEditToken={pageEditToken}
|
||||
pageEditToken={pageEditToken!}
|
||||
marketplace={marketplace}
|
||||
site={site}
|
||||
siteEditToken={siteEditToken}
|
||||
siteEditToken={siteEditToken!}
|
||||
/>
|
||||
</main>
|
||||
<span slot="disclaimers">
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ const renderContext = {
|
|||
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">
|
||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||
{
|
||||
|
|
@ -96,9 +96,9 @@ const renderContext = {
|
|||
isHomePage={isHomePage}
|
||||
locale={locale}
|
||||
page={page}
|
||||
pageEditToken={pageEditToken}
|
||||
pageEditToken={pageEditToken!}
|
||||
site={site}
|
||||
siteEditToken={siteEditToken}
|
||||
siteEditToken={siteEditToken!}
|
||||
/>
|
||||
</main>
|
||||
<span slot="disclaimers">
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ const renderContext = {
|
|||
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">
|
||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||
{
|
||||
|
|
@ -91,11 +91,11 @@ const renderContext = {
|
|||
isHomePage={false}
|
||||
locale={locale}
|
||||
page={page}
|
||||
pageEditToken={pageEditToken}
|
||||
pageEditToken={pageEditToken!}
|
||||
productCategory={productCategory}
|
||||
brand={undefined}
|
||||
site={site}
|
||||
siteEditToken={siteEditToken}
|
||||
siteEditToken={siteEditToken!}
|
||||
/>
|
||||
</main>
|
||||
<span slot="disclaimers">
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ const renderContext = {
|
|||
// 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">
|
||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||
{
|
||||
|
|
@ -94,11 +94,11 @@ const renderContext = {
|
|||
isHomePage={false}
|
||||
locale={locale}
|
||||
page={page}
|
||||
pageEditToken={pageEditToken}
|
||||
pageEditToken={pageEditToken!}
|
||||
productDto={productDto}
|
||||
brand={undefined}
|
||||
site={site}
|
||||
siteEditToken={siteEditToken}
|
||||
siteEditToken={siteEditToken!}
|
||||
/>
|
||||
</main>
|
||||
<span slot="disclaimers">
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ const renderContext = {
|
|||
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">
|
||||
{ metaDescription && <meta name="description" content={metaDescription} /> }
|
||||
{
|
||||
|
|
@ -90,10 +90,10 @@ const renderContext = {
|
|||
isHomePage={false}
|
||||
locale={locale}
|
||||
page={page}
|
||||
pageEditToken={pageEditToken}
|
||||
pageEditToken={pageEditToken!}
|
||||
seller={seller}
|
||||
site={site}
|
||||
siteEditToken={siteEditToken}
|
||||
siteEditToken={siteEditToken!}
|
||||
/>
|
||||
</main>
|
||||
<span slot="disclaimers">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user