model:directory - Heil Dave :)

This commit is contained in:
lovebird 2025-03-16 19:32:56 +01:00
parent f66769175c
commit f2ad684473
13 changed files with 572053 additions and 153 deletions

View File

@ -45,15 +45,6 @@
"handling": 2
}
},
"manufacturing": {
"type": "object",
"properties": {
"lead_time": {
"type": "number"
}
},
"additionalProperties": false
},
"replaced_by": {
"type": "string"
},
@ -145,9 +136,6 @@
"name": {
"type": "string"
},
"flags": {
"type": "number"
},
"edrawings": {
"type": "string"
},
@ -184,12 +172,28 @@
},
"default": []
},
"manufacturing": {
"type": "object",
"properties": {
"lead_time": {
"type": "number"
}
},
"additionalProperties": false
},
"showDimensions": {
"type": "boolean"
},
"showParts": {
"type": "boolean"
},
"Preview3d": {
"type": "boolean"
},
"flags": {
"type": "number",
"default": 0
},
"slug": {
"type": "string"
},
@ -358,84 +362,236 @@
}
}
},
"Preview3d": {
"type": "boolean"
},
"howto_categories": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"components": {
"type": "array",
"items": {
"type": "object",
"properties": {
"cart_id": {
"$ref": "#/definitions/projects/properties/cart_id"
},
"code": {
"$ref": "#/definitions/projects/properties/code"
},
"price": {
"$ref": "#/definitions/projects/properties/price"
},
"cscartCats": {
"$ref": "#/definitions/projects/properties/cscartCats"
},
"cscartId": {
"$ref": "#/definitions/projects/properties/cscartId"
},
"vendorId": {
"$ref": "#/definitions/projects/properties/vendorId"
},
"shipping": {
"$ref": "#/definitions/projects/properties/shipping"
},
"replaced_by": {
"$ref": "#/definitions/projects/properties/replaced_by"
},
"alternatives": {
"$ref": "#/definitions/projects/properties/alternatives"
},
"used_by": {
"$ref": "#/definitions/projects/properties/used_by"
},
"image": {
"$ref": "#/definitions/projects/properties/image"
},
"name": {
"$ref": "#/definitions/projects/properties/name"
},
"edrawings": {
"$ref": "#/definitions/projects/properties/edrawings"
},
"cad": {
"$ref": "#/definitions/projects/properties/cad"
},
"manufacturing": {
"$ref": "#/definitions/projects/properties/manufacturing"
},
"showDimensions": {
"$ref": "#/definitions/projects/properties/showDimensions"
},
"showParts": {
"$ref": "#/definitions/projects/properties/showParts"
},
"Preview3d": {
"$ref": "#/definitions/projects/properties/Preview3d"
},
"flags": {
"$ref": "#/definitions/projects/properties/flags"
},
"slug": {
"$ref": "#/definitions/projects/properties/slug"
},
"keywords": {
"$ref": "#/definitions/projects/properties/keywords"
},
"meta_keywords": {
"$ref": "#/definitions/projects/properties/meta_keywords"
},
"version": {
"$ref": "#/definitions/projects/properties/version"
},
"versions": {
"$ref": "#/definitions/projects/properties/versions"
},
"status": {
"$ref": "#/definitions/projects/properties/status"
},
"authors": {
"$ref": "#/definitions/projects/properties/authors"
},
"assets": {
"$ref": "#/definitions/projects/properties/assets"
},
"resources": {
"$ref": "#/definitions/projects/properties/resources"
},
"tests": {
"$ref": "#/definitions/projects/properties/tests"
},
"download": {
"$ref": "#/definitions/projects/properties/download"
},
"gallery": {
"$ref": "#/definitions/projects/properties/gallery"
},
"components": {
"$ref": "#/definitions/projects/properties/components"
},
"howto_categories": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"steps": {},
"sourceLanguage": {
"type": "string"
},
"category": {
"type": "string"
},
"product_dimensions": {
"type": "string"
},
"production": {
"type": "object",
"properties": {
"fusion-folder": {
"type": "string"
},
"nc-folder": {
"type": "string"
},
"cam": {
"type": "array",
"items": {
"$ref": "#/definitions/projects/properties/authors/items"
}
}
},
"required": [
"fusion-folder",
"nc-folder",
"cam"
],
"additionalProperties": false
},
"score": {
"type": "number"
},
"body": {
"type": "string"
},
"features": {
"type": "string"
},
"highlights": {
"type": "string"
},
"specs": {
"type": "string"
},
"license": {
"type": "string"
},
"readme": {
"type": "string"
},
"shared": {
"type": "string"
}
}
]
},
"required": [
"code",
"name",
"manufacturing",
"slug",
"category"
],
"additionalProperties": true
},
"default": []
},
"howto_categories": {
"$ref": "#/definitions/projects/properties/components/items/properties/howto_categories"
},
"steps": {
"$ref": "#/definitions/projects/properties/components/items/properties/steps"
},
"steps": {},
"sourceLanguage": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/sourceLanguage"
},
"category": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/category"
},
"product_dimensions": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/product_dimensions"
},
"production": {
"type": "object",
"properties": {
"fusion-folder": {
"type": "string"
},
"nc-folder": {
"type": "string"
},
"cam": {
"type": "array",
"items": {
"$ref": "#/definitions/projects/properties/authors/items"
}
}
},
"required": [
"fusion-folder",
"nc-folder",
"cam"
],
"additionalProperties": false
"$ref": "#/definitions/projects/properties/components/items/properties/production"
},
"score": {
"type": "number"
"$ref": "#/definitions/projects/properties/components/items/properties/score"
},
"body": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/body"
},
"features": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/features"
},
"highlights": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/highlights"
},
"specs": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/specs"
},
"license": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/license"
},
"readme": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/readme"
},
"shared": {
"type": "string"
"$ref": "#/definitions/projects/properties/components/items/properties/shared"
}
},
"required": [
"code",
"manufacturing",
"name",
"manufacturing",
"slug",
"category"
],

View File

@ -5,7 +5,8 @@
"type": "object",
"properties": {
"title": {
"type": "string"
"type": "string",
"default": "Untitled"
},
"pubDate": {
"anyOf": [
@ -21,48 +22,46 @@
"type": "integer",
"format": "unix-time"
}
]
],
"default": "2025-03-16T18:11:19.899Z"
},
"description": {
"type": "string"
"type": "string",
"default": "No description provided"
},
"author": {
"type": "string"
"type": "string",
"default": "Anonymous"
},
"image": {
"type": "object",
"properties": {
"url": {
"type": "string"
"type": "string",
"default": ""
},
"alt": {
"type": "string"
"type": "string",
"default": ""
}
},
"required": [
"url",
"alt"
],
"additionalProperties": false
"additionalProperties": false,
"default": {
"url": "",
"alt": ""
}
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"default": []
},
"$schema": {
"type": "string"
}
},
"required": [
"title",
"pubDate",
"description",
"author",
"image",
"tags"
],
"additionalProperties": true
}
},

View File

@ -45,15 +45,6 @@
"handling": 2
}
},
"manufacturing": {
"type": "object",
"properties": {
"lead_time": {
"type": "number"
}
},
"additionalProperties": false
},
"replaced_by": {
"type": "string"
},
@ -145,9 +136,6 @@
"name": {
"type": "string"
},
"flags": {
"type": "number"
},
"edrawings": {
"type": "string"
},
@ -184,12 +172,28 @@
},
"default": []
},
"manufacturing": {
"type": "object",
"properties": {
"lead_time": {
"type": "number"
}
},
"additionalProperties": false
},
"showDimensions": {
"type": "boolean"
},
"showParts": {
"type": "boolean"
},
"Preview3d": {
"type": "boolean"
},
"flags": {
"type": "number",
"default": 0
},
"slug": {
"type": "string"
},
@ -358,84 +362,236 @@
}
}
},
"Preview3d": {
"type": "boolean"
},
"howto_categories": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"components": {
"type": "array",
"items": {
"type": "object",
"properties": {
"cart_id": {
"$ref": "#/definitions/store/properties/cart_id"
},
"code": {
"$ref": "#/definitions/store/properties/code"
},
"price": {
"$ref": "#/definitions/store/properties/price"
},
"cscartCats": {
"$ref": "#/definitions/store/properties/cscartCats"
},
"cscartId": {
"$ref": "#/definitions/store/properties/cscartId"
},
"vendorId": {
"$ref": "#/definitions/store/properties/vendorId"
},
"shipping": {
"$ref": "#/definitions/store/properties/shipping"
},
"replaced_by": {
"$ref": "#/definitions/store/properties/replaced_by"
},
"alternatives": {
"$ref": "#/definitions/store/properties/alternatives"
},
"used_by": {
"$ref": "#/definitions/store/properties/used_by"
},
"image": {
"$ref": "#/definitions/store/properties/image"
},
"name": {
"$ref": "#/definitions/store/properties/name"
},
"edrawings": {
"$ref": "#/definitions/store/properties/edrawings"
},
"cad": {
"$ref": "#/definitions/store/properties/cad"
},
"manufacturing": {
"$ref": "#/definitions/store/properties/manufacturing"
},
"showDimensions": {
"$ref": "#/definitions/store/properties/showDimensions"
},
"showParts": {
"$ref": "#/definitions/store/properties/showParts"
},
"Preview3d": {
"$ref": "#/definitions/store/properties/Preview3d"
},
"flags": {
"$ref": "#/definitions/store/properties/flags"
},
"slug": {
"$ref": "#/definitions/store/properties/slug"
},
"keywords": {
"$ref": "#/definitions/store/properties/keywords"
},
"meta_keywords": {
"$ref": "#/definitions/store/properties/meta_keywords"
},
"version": {
"$ref": "#/definitions/store/properties/version"
},
"versions": {
"$ref": "#/definitions/store/properties/versions"
},
"status": {
"$ref": "#/definitions/store/properties/status"
},
"authors": {
"$ref": "#/definitions/store/properties/authors"
},
"assets": {
"$ref": "#/definitions/store/properties/assets"
},
"resources": {
"$ref": "#/definitions/store/properties/resources"
},
"tests": {
"$ref": "#/definitions/store/properties/tests"
},
"download": {
"$ref": "#/definitions/store/properties/download"
},
"gallery": {
"$ref": "#/definitions/store/properties/gallery"
},
"components": {
"$ref": "#/definitions/store/properties/components"
},
"howto_categories": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"steps": {},
"sourceLanguage": {
"type": "string"
},
"category": {
"type": "string"
},
"product_dimensions": {
"type": "string"
},
"production": {
"type": "object",
"properties": {
"fusion-folder": {
"type": "string"
},
"nc-folder": {
"type": "string"
},
"cam": {
"type": "array",
"items": {
"$ref": "#/definitions/store/properties/authors/items"
}
}
},
"required": [
"fusion-folder",
"nc-folder",
"cam"
],
"additionalProperties": false
},
"score": {
"type": "number"
},
"body": {
"type": "string"
},
"features": {
"type": "string"
},
"highlights": {
"type": "string"
},
"specs": {
"type": "string"
},
"license": {
"type": "string"
},
"readme": {
"type": "string"
},
"shared": {
"type": "string"
}
}
]
},
"required": [
"code",
"name",
"manufacturing",
"slug",
"category"
],
"additionalProperties": true
},
"default": []
},
"howto_categories": {
"$ref": "#/definitions/store/properties/components/items/properties/howto_categories"
},
"steps": {
"$ref": "#/definitions/store/properties/components/items/properties/steps"
},
"steps": {},
"sourceLanguage": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/sourceLanguage"
},
"category": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/category"
},
"product_dimensions": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/product_dimensions"
},
"production": {
"type": "object",
"properties": {
"fusion-folder": {
"type": "string"
},
"nc-folder": {
"type": "string"
},
"cam": {
"type": "array",
"items": {
"$ref": "#/definitions/store/properties/authors/items"
}
}
},
"required": [
"fusion-folder",
"nc-folder",
"cam"
],
"additionalProperties": false
"$ref": "#/definitions/store/properties/components/items/properties/production"
},
"score": {
"type": "number"
"$ref": "#/definitions/store/properties/components/items/properties/score"
},
"body": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/body"
},
"features": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/features"
},
"highlights": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/highlights"
},
"specs": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/specs"
},
"license": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/license"
},
"readme": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/readme"
},
"shared": {
"type": "string"
"$ref": "#/definitions/store/properties/components/items/properties/shared"
}
},
"required": [
"code",
"manufacturing",
"name",
"manufacturing",
"slug",
"category"
],

View File

@ -1,4 +1,5 @@
export default new Map([
["src/content/infopages/contact.mdx", () => import("astro:content-layer-deferred-module?astro%3Acontent-layer-deferred-module=&fileName=src%2Fcontent%2Finfopages%2Fcontact.mdx&astroContentModuleFlag=true")]]);
["src/content/infopages/contact.mdx", () => import("astro:content-layer-deferred-module?astro%3Acontent-layer-deferred-module=&fileName=src%2Fcontent%2Finfopages%2Fcontact.mdx&astroContentModuleFlag=true")],
["src/content/resources/workflow.mdx", () => import("astro:content-layer-deferred-module?astro%3Acontent-layer-deferred-module=&fileName=src%2Fcontent%2Fresources%2Fworkflow.mdx&astroContentModuleFlag=true")]]);

File diff suppressed because one or more lines are too long

570991
data/last.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"dev": "astro dev --mode dev --host=0.0.0.0 --o-images=medium",
"dev": "astro dev --mode dev --host=0.0.0.0",
"start": "astro dev",
"build": "astro build",
"test:build": "astro build ; cd dist ; serve",

View File

@ -27,17 +27,17 @@ const infopages = defineCollection({
})
const resources = defineCollection({
loader: glob({ base: './src/content/resources', pattern: '*.{md,mdx}' }),
loader: glob({ base: './src/content/resources', pattern: '*.{md,mdx}' }),
schema: z.object({
title: z.string(),
pubDate: z.date(),
description: z.string(),
author: z.string(),
title: z.string().optional().default('Untitled'),
pubDate: z.date().optional().default(new Date()),
description: z.string().optional().default('No description provided'),
author: z.string().optional().default('Anonymous'),
image: z.object({
url: z.string(),
alt: z.string()
}),
tags: z.array(z.string())
url: z.string().optional().default(''),
alt: z.string().optional().default('')
}).optional().default({ url: '', alt: '' }),
tags: z.array(z.string()).optional().default([])
}).passthrough(),
});

View File

@ -1,13 +1,11 @@
---
---
## Migration
- json -> content/resources/howtos/*.mdx
## Editing
- content/resources/howtos/*.mdx + overlay
## Processing
@ -16,3 +14,7 @@
completions (resources ext/content) ->
outputs (json-ld/pdf/md)
## Editing
- content/resources/howtos/*.mdx + overlay

132
src/model/directory.ts Normal file
View File

@ -0,0 +1,132 @@
import * as path from 'path'
import { findUp } from 'find-up'
import { sync as read } from '@polymech/fs/read'
import { resolveConfig } from '@polymech/commons'
import { DataEntry } from "astro:content"
import type { Loader, LoaderContext } from 'astro/loaders'
import { logger } from '@/base/index.js'
import {
PRODUCT_BRANCHES,
PRODUCT_DIR, PRODUCT_GLOB,
PRODUCT_ROOT
} from 'config/config.js'
import { env } from '../base/index.js'
import { gallery } from '../base/media.js';
import { get } from '@polymech/commons/component'
import { PFilterValid } from '@polymech/commons/filter'
import { translate } from "@/base/i18n.js"
import { I18N_SOURCE_LANGUAGE } from "config/config.js"
import { slugify } from "@/base/strings.js"
import { I_PC_USER } from 'site/types/types.js'
export interface I_User extends I_PC_USER {
content: string
[key: string]: unknown
}
export interface IStoreItem extends DataEntry {
data: I_User,
}
const filterBranch = (items: { rel: string, config, path }[], branch: string) => {
if (!PRODUCT_BRANCHES) {
return items
}
const branchItems = PRODUCT_BRANCHES[branch]
if (!branchItems) {
return items
}
return items.filter((item) => branchItems.includes(item.rel))
}
export const items = (branch: string) =>
filterBranch(get(`${PRODUCT_ROOT()}/${PRODUCT_GLOB}`,
PRODUCT_ROOT(), PFilterValid.marketplace_component), branch)
const onItem = async (item: IStoreItem, ctx: LoaderContext) => {
if (!item || !item.data) {
ctx.logger.error(`Error completing ${''}: no data`);
return
}
let data: I_User = item.data
data = resolveConfig(data as Record<string, string>) as I_User
}
export function loader(branch: string): Loader {
const load = async ({
config,
logger,
watcher,
parseData,
store,
generateDigest }: LoaderContext) => {
store.clear();
let products = items(branch)
for (const item of products) {
const product: any = item.config
const id = product.slug;
const data = {
rel: item.rel,
slug: id,
id,
title: product.name,
type: 'directory',
...product,
}
//const parsedData = await parseData({ id, data: data });
const storeItem = {
digest: await generateDigest(data),
filePath: id,
assetImports: [],
id: `${item.rel}`,
data: data
}
await onItem(storeItem, {
logger,
watcher,
parseData,
store,
generateDigest
} as any)
storeItem.data['config'] = JSON.stringify({
...storeItem.data
}, null, 2)
store.set(storeItem)
}
}
return {
name: "directory-loader",
load
};
}
export const group_path = (item) => item.id.split("/")[1]
const group_label = async (text: string, locale) => await translate(slugify(text), I18N_SOURCE_LANGUAGE, locale)
const group = async (items, locale) => {
return items.reduce(async (accPromise, item) => {
const acc = await accPromise
const id = group_path(item)
let key: string = await group_label(id, locale)
key = key.charAt(0).toUpperCase() + key.slice(1)
if (!acc[key]) {
acc[key] = []
}
acc[key].push(item)
return acc
}, {})
}
export const group_by_path = async (items, locale): Promise<I_User[]> => await group(items, locale)

302
src/types/types.ts Normal file
View File

@ -0,0 +1,302 @@
/* eslint-disable @typescript-eslint/naming-convention*/
export interface IConvertedFileMeta {
photoData: Blob
objectUrl: string
name: string
type: string
}
export interface IUploadedFileMeta {
downloadUrl: string
contentType?: string | null
fullPath: string
name: string
type: string
size: number
timeCreated: string
updated: string
}
// Types for moderation status
export type IModerationStatus =
| 'draft'
| 'awaiting-moderation'
| 'rejected'
| 'accepted'
export interface IModerable {
moderation: IModerationStatus
_createdBy?: string
_id?: string
}
export type ISODateString = string;
export interface IUserState {
user?: IUser
}
// IUser retains most of the fields from legacy users (omitting passwords),
// and has a few additional fields. Note 'email' is excluded
// _uid is unique/fixed identifier
// ALL USER INFO BELOW IS PUBLIC
export interface IUser {
// authID is additional id populated by firebase auth, required for some auth operations
_authID: string
_lastActive?: ISODateString
// userName is same as legacy 'mention_name', e.g. @my-name. It will also be the doc _id and
// firebase auth displayName property
userName: string
displayName: string
moderation: IModerationStatus
// note, user avatar url is taken direct from userName so no longer populated here
// avatar:string
verified: boolean
badges?: IUserBadges
// images will be in different formats if they are pending upload vs pulled from db
coverImages: IUploadedFileMeta[] | IConvertedFileMeta[]
links: IExternalLink[]
userRoles?: string[]
about?: string | null
DHSite_id?: number
DHSite_mention_name?: string
country?: string | null
// location?: ILocation | null
year?: ISODateString
stats?: IUserStats
/** keep a map of all howto ids that a user has voted as useful */
votedUsefulHowtos?: { [howtoId: string]: boolean }
/** keep a map of all Research ids that a user has voted as useful */
votedUsefulResearch?: { [researchId: string]: boolean }
notifications?: INotification[]
}
interface IUserBadges {
verified: boolean
}
interface IExternalLink {
url: string
label:
| 'email'
| 'website'
| 'discord'
| 'bazar'
| 'forum'
| 'social media'
| 'facebook'
| 'instagram'
}
/**
* Track the ids and moderation status as summary for user stats
*/
interface IUserStats {
userCreatedHowtos: { [id: string]: IModerationStatus }
userCreatedResearch: { [id: string]: IModerationStatus }
userCreatedEvents: { [id: string]: IModerationStatus }
}
export type IUserDB = IUser;
export interface INotification {
_id: string
_created: string
triggeredBy: {
displayName: string
userId: string
}
relevantUrl?: string
type: NotificationType
read: boolean
}
export type NotificationType =
| 'new_comment'
| 'howto_useful'
| 'new_comment_research'
| 'research_useful'
export type PlasticTypeLabel =
| 'pet'
| 'hdpe'
| 'pvc'
| 'ldpe'
| 'pp'
| 'ps'
| 'other'
export type MachineBuilderXpLabel =
| 'electronics'
| 'machining'
| 'welding'
| 'assembling'
| 'mould-making'
export type WorkspaceType =
| 'shredder'
| 'sheetpress'
| 'extrusion'
| 'injection'
| 'mix'
export interface IPlasticType {
label: PlasticTypeLabel
number: string
imageSrc?: string
}
export interface IProfileType {
label: string;
imageSrc?: string
cleanImageSrc?: string
cleanImageVerifiedSrc?: string
textLabel?: string
}
export interface IWorkspaceType {
label: WorkspaceType
imageSrc?: string
textLabel?: string
subText?: string
}
export interface IMAchineBuilderXp {
label: MachineBuilderXpLabel
}
export interface IOpeningHours {
day: string
openFrom: string
openTo: string
}
/**
* PP users can have a bunch of custom meta fields depending on profile type
*/
export interface IUserPP extends IUser {
profileType: string;
workspaceType?: WorkspaceType | null
mapPinDescription?: string | null
openingHours?: IOpeningHours[]
collectedPlasticTypes?: PlasticTypeLabel[] | null
machineBuilderXp?: IMAchineBuilderXp[] | null
isExpert?: boolean | null
isV4Member?: boolean | null
}
export type IUserPPDB = IUserPP;
///////////////////////////////////////////////////////////////////
//
// OSR Specific Namespace
export interface Location {
lng: number;
lat: number;
}
export interface Detail {
lastActive: Date;
profilePicUrl: string;
shortDescription: string;
heroImageUrl: string;
name: string;
profileUrl: string;
}
export interface Administrative {
name: string;
description: string;
isoName: string;
order: number;
adminLevel: number;
isoCode: string;
wikidataId: string;
geonameId: number;
}
export interface Informative {
name: string;
description: string;
order: number;
isoCode: string;
wikidataId: string;
geonameId: number;
}
export interface LocalityInfo {
administrative: Administrative[];
informative: Informative[];
}
export interface Geo {
latitude: number;
longitude: number;
continent: string;
lookupSource: string;
continentCode: string;
localityLanguageRequested: string;
city: string;
countryName: string;
postcode: string;
countryCode: string;
principalSubdivision: string;
principalSubdivisionCode: string;
plusCode: string;
locality: string;
localityInfo: LocalityInfo;
}
export interface Url {
name: string;
url: string;
}
export interface Service {
welding: boolean;
assembling: boolean;
machining: boolean;
electronics: boolean;
molds: boolean;
}
export interface Image {
url: string;
}
export interface Data {
urls: Url[];
description: string;
services: Service[];
title: string;
images: Image[];
}
export interface I_OSR_USER {
_created: Date;
location: Location;
_modified: Date;
_id: string;
detail: Detail;
type: string;
_deleted: boolean;
moderation: string;
geo: Geo;
data: Data;
}
export interface I_USER_SHORT {
name: string;
email: string;
bazar: string;
web: string;
social: string;
censored: string;
lastActive: Date;
ig: string;
}
export * from './types_vendor.js'

160
src/types/types_vendor.ts Normal file
View File

@ -0,0 +1,160 @@
export interface VendorSearchAll {
[id: string]: VendorSearch;
}
export interface VendorSearch {
search: Search;
urls: string[];
url: string;
products: string[];
paths: string[];
}
export interface Search {
search_metadata: SearchMetadata;
search_parameters: SearchParameters;
search_information: SearchInformation;
knowledge_graph: KnowledgeGraph;
related_questions: RelatedQuestion[];
organic_results: OrganicResult[];
pagination: Pagination;
serpapi_pagination: Pagination;
}
export interface KnowledgeGraph {
title: string;
place_id: string;
website: string;
local_map: LocalMap;
rating: number;
review_count: number;
raw_hours: string;
hours: Hours;
merchant_description: string;
}
export interface Hours {
sunday: Day;
monday: Day;
tuesday: Day;
wednesday: Day;
thursday: Day;
friday_good_friday: Day;
saturday: Day;
}
export interface Day {
opens: string;
closes: string;
}
export interface LocalMap {
image: string;
link: string;
gps_coordinates: GpsCoordinates;
}
export interface GpsCoordinates {
latitude: number;
longitude: number;
altitude: number;
}
export interface OrganicResult {
position: number;
title: string;
link: string;
displayed_link: string;
snippet: string;
snippet_highlighted_words: string[];
about_this_result: AboutThisResult;
about_page_link: string;
about_page_serpapi_link: string;
cached_page_link: string;
rich_snippet?: RichSnippet;
}
export interface AboutThisResult {
source: Source;
}
export interface Source {
description: string;
source_info_link: string;
security: Security;
icon: string;
}
export enum Security {
Secure = "secure",
}
export interface RichSnippet {
top: Top;
}
export interface Top {
detected_extensions: DetectedExtensions;
extensions: string[];
}
export interface DetectedExtensions {
price: number;
currency: string;
}
export interface Pagination {
current: number;
next: string;
other_pages: { [key: string]: string };
next_link?: string;
}
export interface RelatedQuestion {
question: string;
snippet: string;
title: string;
link: string;
displayed_link: string;
thumbnail: string;
next_page_token: string;
serpapi_link: string;
}
export interface SearchInformation {
organic_results_state: string;
error_message: string;
total_results: number;
time_taken_displayed: number;
menu_items: MenuItem[];
}
export interface MenuItem {
position: number;
title: string;
link: string;
serpapi_link?: string;
}
export interface SearchMetadata {
id: string;
status: string;
json_endpoint: string;
created_at: string;
processed_at: string;
google_url: string;
raw_html_file: string;
total_time_taken: number;
}
export interface SearchParameters {
engine: string;
q: string;
location_requested: string;
location_used: string;
google_domain: string;
hl: string;
gl: string;
device: string;
}

View File

@ -19,6 +19,7 @@
"resolveJsonModule": true,
"paths": {
"@/*": ["src/*"],
"site/*": ["src/*"],
"config/*": ["src/app/*"]
}
},