fix build errors

This commit is contained in:
Jesse Winton
2025-04-01 12:42:54 -04:00
parent 687a05e34d
commit 3d36dffaef
3 changed files with 28 additions and 14 deletions

View File

@@ -33,6 +33,9 @@ export const Service = {
Users: 'users'
} as const;
export type ServiceType = typeof Service;
export type ServiceValue = (typeof Service)[keyof typeof Service];
export const Platform = {
ClientWeb: 'client-web',
ClientFlutter: 'client-flutter',
@@ -57,6 +60,9 @@ export const Platform = {
ServerRest: 'server-rest'
} as const;
type PlatformType = typeof Platform;
export type Platform = (typeof Platform)[keyof typeof Platform];
export const Framework = {
NextJs: 'Next.js',
SvelteKit: 'SvelteKit',
@@ -126,7 +132,7 @@ export const platformMap: Record<Language | string, string> = {
go: 'Go'
};
export const serviceMap: Record<Service, string> = {
export const serviceMap: Record<ServiceValue, string> = {
[Service.Account]: 'Account',
[Service.Avatars]: 'Avatars',
[Service.Databases]: 'Databases',

View File

@@ -1,5 +1,5 @@
import { OpenAPIV3 } from 'openapi-types';
import { Platform, type Service } from './references';
import { Platform, type ServiceValue } from './references';
import { error } from '@sveltejs/kit';
export type SDKMethod = {
@@ -65,6 +65,9 @@ export const ModelType = {
GRAPHQL: 'GraphQL'
} as const;
type ModelTypeType = keyof typeof ModelType;
type ModelTypeValue = (typeof ModelType)[ModelTypeType];
function getExamples(version: string) {
switch (version) {
case '0.15.x':
@@ -217,7 +220,7 @@ export async function getApi(version: string, platform: string): Promise<OpenAPI
isServer ? 'server' : isClient ? 'client' : 'console'
}.json`;
return specs[target]();
return specs[target]() as unknown as OpenAPIV3.Document;
}
const descriptions = import.meta.glob(
@@ -228,14 +231,14 @@ const descriptions = import.meta.glob(
}
);
export async function getDescription(service: string): Promise<string> {
export async function getDescription(service: string) {
const target = `/src/routes/docs/references/[version]/[platform]/[service]/descriptions/${service}.md`;
if (!(target in descriptions)) {
throw new Error('Missing service description');
}
return descriptions[target]();
return descriptions[target]() as unknown as string;
}
export async function getService(
@@ -244,7 +247,7 @@ export async function getService(
service: string
): Promise<{
service: {
name: Service;
name: ServiceValue;
description: string;
};
methods: SDKMethod[];
@@ -262,7 +265,7 @@ export async function getService(
const data: Awaited<ReturnType<typeof getService>> = {
service: {
name: service as Service,
name: service as ServiceValue,
description: await getDescription(service)
},
methods: []
@@ -324,7 +327,7 @@ export async function getService(
continue;
}
const demo = await examples[path]();
const demo = (await examples[path]()) as unknown as string;
data.methods.push({
id: operation['x-appwrite'].method,
@@ -370,7 +373,7 @@ export function resolveReference(
export const generateExample = (
schema: OpenAPIV3.SchemaObject,
api: OpenAPIV3.Document<object>,
modelType: ModelType = ModelType.REST
modelType: ModelTypeValue = ModelType.REST
): object => {
const properties = Object.keys(schema.properties ?? {}).map((key) => {
const name = key;

View File

@@ -10,7 +10,7 @@
import MainFooter from '../../lib/components/MainFooter.svelte';
import Copy from './Copy.svelte';
const title: 'Assets' + TITLE_SUFFIX;
const title: string = 'Assets' + TITLE_SUFFIX;
const description =
"This page features Appwrite's key brand assets including the logotype, colors, product visuals, and practical guidelines for their usage.";
const ogImage = DEFAULT_HOST + '/images/open-graph/website.png';
@@ -22,15 +22,20 @@
COLORS: 'Brand colors',
VISUALS: 'Product visuals',
CONTACT: 'Contact us'
} as const
} as const;
const getSectionId = (section: Section) => section.toLowerCase().replace(/\s/g, '-');
type SectionType = typeof Section;
let selectedMap: Map<Section, boolean> = new Map(
// To get the type of the values (union of string literals)
type SectionValues = SectionType[keyof SectionType];
const getSectionId = (section: SectionValues) => section.toLowerCase().replace(/\s/g, '-');
let selectedMap: Map<SectionValues, boolean> = new Map(
Object.values(Section).map((section) => [section, false])
);
const handleVisibility = (section: Section) => {
const handleVisibility = (section: SectionValues) => {
return (e: CustomEvent<boolean>) => {
selectedMap.set(section, e.detail);
selectedMap = selectedMap;