From 35954693a8993b24216b30069036fa1682336c27 Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Thu, 23 Nov 2023 14:13:20 +0000
Subject: [PATCH 1/7] fix link margin

---
 src/scss/7-components/_article.scss | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/scss/7-components/_article.scss b/src/scss/7-components/_article.scss
index b51002c07a1..db957dbba15 100644
--- a/src/scss/7-components/_article.scss
+++ b/src/scss/7-components/_article.scss
@@ -22,6 +22,7 @@
       &-description   { margin-block-start:pxToRem(4); margin-block-end:pxToRem(4); }
       &-label         { margin-block-end:pxToRem(16); }
       &-paragraph-md  { margin-block-end:pxToRem(32); }
+      &-link          { margin-block-end:0 !important; }
       &-code-snippet  { margin-block-start:pxToRem(16); margin-block-end:pxToRem(32); }
       &-card          { margin-block-end:pxToRem(32); }
       &-list,

From 5e8d41a1fe1920c7ee4c21ca72f9cf332fbeb157 Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Thu, 23 Nov 2023 17:10:52 +0000
Subject: [PATCH 2/7] add api endpoint

---
 src/lib/utils/specs.ts                        | 507 +++++++++---------
 src/markdoc/nodes/Fence.svelte                |   7 +-
 .../[platform]/[service]/+page.svelte         |  23 +-
 .../[version]/models/[model]/+page.server.ts  | 129 +++--
 4 files changed, 346 insertions(+), 320 deletions(-)

diff --git a/src/lib/utils/specs.ts b/src/lib/utils/specs.ts
index b49d7a1b157..87d8e1fa9a3 100644
--- a/src/lib/utils/specs.ts
+++ b/src/lib/utils/specs.ts
@@ -2,310 +2,321 @@ import { OpenAPIV3 } from 'openapi-types';
 import { Platform, type Service } from './references';
 
 type SDKMethod = {
-	id: string;
-	title: string;
-	description: string;
-	demo: string;
-	parameters: Array<{
-		name: string;
-		description: string;
-		required: boolean;
-		type: string;
-		example: string;
-	}>;
-	responses: Array<{
-		code: number;
-		contentType?: string;
-		models?: SDKMethodModel[];
-	}>;
+    id: string;
+    title: string;
+    description: string;
+    demo: string;
+    parameters: Array<{
+        name: string;
+        description: string;
+        required: boolean;
+        type: string;
+        example: string;
+    }>;
+    responses: Array<{
+        code: number;
+        contentType?: string;
+        models?: SDKMethodModel[];
+    }>;
+    method: OpenAPIV3.HttpMethods;
+    url: string;
 };
 
 type SDKMethodModel = {
-	id: string;
-	name: string;
+    id: string;
+    name: string;
 };
 
 type AppwriteOperationObject = OpenAPIV3.OperationObject & {
-	'x-appwrite': {
-		method: string;
-		weight: number;
-		cookies: boolean;
-		type: string;
-		demo: string;
-		edit: string;
-		'rate-limit': number;
-		'rate-time': number;
-		'rate-key': string;
-		scope: string;
-		platforms: string[];
-		packaging: boolean;
-	};
+    'x-appwrite': {
+        method: string;
+        weight: number;
+        cookies: boolean;
+        type: string;
+        demo: string;
+        edit: string;
+        'rate-limit': number;
+        'rate-time': number;
+        'rate-key': string;
+        scope: string;
+        platforms: string[];
+        packaging: boolean;
+    };
 };
 
 export type AppwriteSchemaObject = OpenAPIV3.SchemaObject & {
-	'x-example': string;
+    'x-example': string;
 };
 
 function getExamples(version: string) {
-	switch (version) {
-		case '0.15.x':
-			return import.meta.glob('$appwrite/docs/examples/0.15.x/**/*.md', {
-				as: 'raw'
-			});
-		case '1.0.x':
-			return import.meta.glob('$appwrite/docs/examples/1.0.x/**/*.md', {
-				as: 'raw'
-			});
-		case '1.1.x':
-			return import.meta.glob('$appwrite/docs/examples/1.1.x/**/*.md', {
-				as: 'raw'
-			});
-		case '1.2.x':
-			return import.meta.glob('$appwrite/docs/examples/1.2.x/**/*.md', {
-				as: 'raw'
-			});
-		case '1.3.x':
-			return import.meta.glob('$appwrite/docs/examples/1.3.x/**/*.md', {
-				as: 'raw'
-			});
-		case '1.4.x':
-			return import.meta.glob('$appwrite/docs/examples/1.4.x/**/*.md', {
-				as: 'raw'
-			});
-	}
+    switch (version) {
+        case '0.15.x':
+            return import.meta.glob('$appwrite/docs/examples/0.15.x/**/*.md', {
+                as: 'raw'
+            });
+        case '1.0.x':
+            return import.meta.glob('$appwrite/docs/examples/1.0.x/**/*.md', {
+                as: 'raw'
+            });
+        case '1.1.x':
+            return import.meta.glob('$appwrite/docs/examples/1.1.x/**/*.md', {
+                as: 'raw'
+            });
+        case '1.2.x':
+            return import.meta.glob('$appwrite/docs/examples/1.2.x/**/*.md', {
+                as: 'raw'
+            });
+        case '1.3.x':
+            return import.meta.glob('$appwrite/docs/examples/1.3.x/**/*.md', {
+                as: 'raw'
+            });
+        case '1.4.x':
+            return import.meta.glob('$appwrite/docs/examples/1.4.x/**/*.md', {
+                as: 'raw'
+            });
+    }
 }
 
 function* iterateAllMethods(
-	api: OpenAPIV3.Document,
-	service: string
-): Generator<[OpenAPIV3.HttpMethods, OpenAPIV3.OperationObject]> {
-	for (const url in api.paths) {
-		const methods = api.paths[url];
-		if (methods?.get?.tags?.includes(service)) {
-			yield [OpenAPIV3.HttpMethods.GET, methods.get];
-		}
-		if (methods?.post?.tags?.includes(service)) {
-			yield [OpenAPIV3.HttpMethods.POST, methods.post];
-		}
-		if (methods?.put?.tags?.includes(service)) {
-			yield [OpenAPIV3.HttpMethods.PUT, methods.put];
-		}
-		if (methods?.patch?.tags?.includes(service)) {
-			yield [OpenAPIV3.HttpMethods.PATCH, methods.patch];
-		}
-		if (methods?.delete?.tags?.includes(service)) {
-			yield [OpenAPIV3.HttpMethods.DELETE, methods.delete];
-		}
-	}
+    api: OpenAPIV3.Document,
+    service: string
+): Generator<{ method: OpenAPIV3.HttpMethods; value: OpenAPIV3.OperationObject; url: string }> {
+    for (const url in api.paths) {
+        const methods = api.paths[url];
+        if (methods?.get?.tags?.includes(service)) {
+            yield { method: OpenAPIV3.HttpMethods.GET, value: methods.get, url };
+        }
+        if (methods?.post?.tags?.includes(service)) {
+            yield { method: OpenAPIV3.HttpMethods.POST, value: methods.post, url };
+        }
+        if (methods?.put?.tags?.includes(service)) {
+            yield { method: OpenAPIV3.HttpMethods.PUT, value: methods.put, url };
+        }
+        if (methods?.patch?.tags?.includes(service)) {
+            yield { method: OpenAPIV3.HttpMethods.PATCH, value: methods.patch, url };
+        }
+        if (methods?.delete?.tags?.includes(service)) {
+            yield { method: OpenAPIV3.HttpMethods.DELETE, value: methods.delete, url };
+        }
+    }
 }
 
-function getParameters(
-	operation: AppwriteOperationObject
-): SDKMethod['parameters'] {
-	const parameters: ReturnType<typeof getParameters> = [];
-	const requestBody = operation?.requestBody as OpenAPIV3.RequestBodyObject;
-	const schemaJson = requestBody?.content['application/json']?.schema as OpenAPIV3.SchemaObject;
-	const schemaMultipart = requestBody?.content['multipart/form-data']?.schema as OpenAPIV3.SchemaObject;
-	if (operation?.parameters) {
-		for (const parameter of (operation?.parameters as OpenAPIV3.ParameterObject[])) {
-			const schema = parameter.schema as OpenAPIV3.SchemaObject;
+function getParameters(operation: AppwriteOperationObject): SDKMethod['parameters'] {
+    const parameters: ReturnType<typeof getParameters> = [];
+    const requestBody = operation?.requestBody as OpenAPIV3.RequestBodyObject;
+    const schemaJson = requestBody?.content['application/json']?.schema as OpenAPIV3.SchemaObject;
+    const schemaMultipart = requestBody?.content['multipart/form-data']
+        ?.schema as OpenAPIV3.SchemaObject;
+    if (operation?.parameters) {
+        for (const parameter of operation?.parameters as OpenAPIV3.ParameterObject[]) {
+            const schema = parameter.schema as OpenAPIV3.SchemaObject;
 
-			parameters.push({
-				name: parameter.name,
-				description: parameter.description ?? '',
-				required: parameter.required ?? false,
-				type: schema?.type ?? '',
-				example: schema?.example
-			});
-		}
-	}
-	if (schemaJson?.properties) {
-		for (const [key, value] of Object.entries(schemaJson.properties)) {
-			const property = value as AppwriteSchemaObject;
-			parameters.push({
-				name: key,
-				description: property.description ?? '',
-				required: schemaJson?.required?.includes(key) ?? false,
-				type: property.type ?? '',
-				example: property['x-example'] ?? ''
-			});
-		}
-	}
-	if (schemaMultipart?.properties) {
-		for (const [key, value] of Object.entries(schemaMultipart.properties)) {
-			const property = value as AppwriteSchemaObject;
-			parameters.push({
-				name: key,
-				description: property.description ?? '',
-				required: schemaMultipart?.required?.includes(key) ?? false,
-				type: property.type ?? '',
-				example: property['x-example'] ?? ''
-			});
-		}
-	}
+            parameters.push({
+                name: parameter.name,
+                description: parameter.description ?? '',
+                required: parameter.required ?? false,
+                type: schema?.type ?? '',
+                example: schema?.example
+            });
+        }
+    }
+    if (schemaJson?.properties) {
+        for (const [key, value] of Object.entries(schemaJson.properties)) {
+            const property = value as AppwriteSchemaObject;
+            parameters.push({
+                name: key,
+                description: property.description ?? '',
+                required: schemaJson?.required?.includes(key) ?? false,
+                type: property.type ?? '',
+                example: property['x-example'] ?? ''
+            });
+        }
+    }
+    if (schemaMultipart?.properties) {
+        for (const [key, value] of Object.entries(schemaMultipart.properties)) {
+            const property = value as AppwriteSchemaObject;
+            parameters.push({
+                name: key,
+                description: property.description ?? '',
+                required: schemaMultipart?.required?.includes(key) ?? false,
+                type: property.type ?? '',
+                example: property['x-example'] ?? ''
+            });
+        }
+    }
 
     return parameters.sort((a, b) => {
-        return (a.required === b.required) ? 0 : a.required ? -1 : 1;
+        return a.required === b.required ? 0 : a.required ? -1 : 1;
     });
 }
 
 export function getSchema(id: string, api: OpenAPIV3.Document): OpenAPIV3.SchemaObject {
-	const schema = api.components?.schemas?.[id] as OpenAPIV3.SchemaObject;
-	if (schema) {
-		return schema;
-	}
-	throw new Error("Schema doesn't exist");
+    const schema = api.components?.schemas?.[id] as OpenAPIV3.SchemaObject;
+    if (schema) {
+        return schema;
+    }
+    throw new Error("Schema doesn't exist");
 }
 
 const specs = import.meta.glob(
-	'$appwrite/app/config/specs/open-api3*-(client|server|console).json',
-	{
-		as: 'raw'
-	}
+    '$appwrite/app/config/specs/open-api3*-(client|server|console).json',
+    {
+        as: 'raw'
+    }
 );
 async function getSpec(version: string, platform: string) {
-	const isClient = platform.startsWith('client-');
-	const isServer = platform.startsWith('server-');
-	const target = `/node_modules/@appwrite.io/repo/app/config/specs/open-api3-${version}-${
-		isServer ? 'server' : isClient ? 'client' : 'console'
-	}.json`;
-	return specs[target]();
+    const isClient = platform.startsWith('client-');
+    const isServer = platform.startsWith('server-');
+    const target = `/node_modules/@appwrite.io/repo/app/config/specs/open-api3-${version}-${
+        isServer ? 'server' : isClient ? 'client' : 'console'
+    }.json`;
+    return specs[target]();
 }
 
 export async function getApi(version: string, platform: string): Promise<OpenAPIV3.Document> {
-	const raw = await getSpec(version, platform);
-	const api = JSON.parse(raw);
-	return api;
+    const raw = await getSpec(version, platform);
+    const api = JSON.parse(raw);
+    return api;
 }
 
 const descriptions = import.meta.glob(
-	'/src/routes/docs/references/[version]/[platform]/[service]/descriptions/*.md',
-	{
-		as: 'raw'
-	}
+    '/src/routes/docs/references/[version]/[platform]/[service]/descriptions/*.md',
+    {
+        as: 'raw'
+    }
 );
 
 export async function getDescription(service: string): Promise<string> {
-	const target = `/src/routes/docs/references/[version]/[platform]/[service]/descriptions/${service}.md`;
+    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]();
+    if (!(target in descriptions)) {
+        throw new Error('Missing service description');
+    }
+    return descriptions[target]();
 }
 
 export async function getService(
-	version: string,
-	platform: string,
-	service: string
+    version: string,
+    platform: string,
+    service: string
 ): Promise<{
-	service: {
-		name: Service;
-		description: string;
-	};
-	methods: SDKMethod[];
+    service: {
+        name: Service;
+        description: string;
+    };
+    methods: SDKMethod[];
 }> {
-	/**
-	 * Exceptions for Android SDK.
-	 */
-	const isAndroidJava = platform === Platform.ClientAndroidJava || platform === Platform.ServerJava;
-	const isAndroidKotlin = platform === Platform.ClientAndroidKotlin || platform === Platform.ServerKotlin;
-	const isAndroid = isAndroidJava || isAndroidKotlin;
-	const isAndroidServer = platform === Platform.ServerJava || platform === Platform.ServerKotlin;
-	const api = await getApi(version, platform);
-	const tag = api.tags?.find((n) => n.name === service);
+    /**
+     * Exceptions for Android SDK.
+     */
+    const isAndroidJava =
+        platform === Platform.ClientAndroidJava || platform === Platform.ServerJava;
+    const isAndroidKotlin =
+        platform === Platform.ClientAndroidKotlin || platform === Platform.ServerKotlin;
+    const isAndroid = isAndroidJava || isAndroidKotlin;
+    const isAndroidServer = platform === Platform.ServerJava || platform === Platform.ServerKotlin;
+    const api = await getApi(version, platform);
+    console.log({ api });
+    const tag = api.tags?.find((n) => n.name === service);
 
-	const data: Awaited<ReturnType<typeof getService>> = {
-		service: {
-			name: tag?.name as Service,
-			description: await getDescription(service)
-		},
-		methods: []
-	};
+    const data: Awaited<ReturnType<typeof getService>> = {
+        service: {
+            name: tag?.name as Service,
+            description: await getDescription(service)
+        },
+        methods: []
+    };
 
-	const examples = getExamples(version);
+    const examples = getExamples(version);
 
-	if (!examples) {
-		return data;
-	}
+    if (!examples) {
+        return data;
+    }
 
-	for (const [method, value] of iterateAllMethods(api, service)) {
-		const operation = value as AppwriteOperationObject;
-		const parameters = getParameters(operation);
-		const responses: SDKMethod['responses'] = Object.entries(operation.responses ?? {}).map(
-			(tuple) => {
-				const [code, response] = tuple as [string, OpenAPIV3.ResponseObject];
-				const models: SDKMethodModel[] = [];
-				const schemas = response?.content?.['application/json']?.schema as OpenAPIV3.SchemaObject;
-				if (code !== '204') {
-					if (schemas?.oneOf) {
-						schemas.oneOf.forEach((ref) => {
-							const schema = resolveReference(ref as OpenAPIV3.ReferenceObject, api);
-							models.push({
-								id: getIdFromReference(ref as OpenAPIV3.ReferenceObject),
-								name: schema.description ?? ''
-							});
-						});
-					} else {
-						if (schemas) {
-							const id = getIdFromReference(schemas as OpenAPIV3.ReferenceObject);
-							const schema = resolveReference(schemas as OpenAPIV3.ReferenceObject, api);
-							models.push({
-								id,
-								name: schema?.description ?? ''
-							});
-						}
-					}
-				}
+    for (const { method, value, url } of iterateAllMethods(api, service)) {
+        // console.log({ method, value });
+        const operation = value as AppwriteOperationObject;
+        const parameters = getParameters(operation);
+        const responses: SDKMethod['responses'] = Object.entries(operation.responses ?? {}).map(
+            (tuple) => {
+                const [code, response] = tuple as [string, OpenAPIV3.ResponseObject];
+                const models: SDKMethodModel[] = [];
+                const schemas = response?.content?.['application/json']
+                    ?.schema as OpenAPIV3.SchemaObject;
+                if (code !== '204') {
+                    if (schemas?.oneOf) {
+                        schemas.oneOf.forEach((ref) => {
+                            const schema = resolveReference(ref as OpenAPIV3.ReferenceObject, api);
+                            models.push({
+                                id: getIdFromReference(ref as OpenAPIV3.ReferenceObject),
+                                name: schema.description ?? ''
+                            });
+                        });
+                    } else {
+                        if (schemas) {
+                            const id = getIdFromReference(schemas as OpenAPIV3.ReferenceObject);
+                            const schema = resolveReference(
+                                schemas as OpenAPIV3.ReferenceObject,
+                                api
+                            );
+                            models.push({
+                                id,
+                                name: schema?.description ?? ''
+                            });
+                        }
+                    }
+                }
 
-				return {
-					code: Number(code),
-					contentType: response?.content ? Object.keys(response.content)[0] : undefined,
-					models
-				};
-			}
-		);
+                return {
+                    code: Number(code),
+                    contentType: response?.content ? Object.keys(response.content)[0] : undefined,
+                    models
+                };
+            }
+        );
 
-		const path = isAndroid
-			? `/node_modules/@appwrite.io/repo/docs/examples/${version}/${isAndroidServer ? 'server-kotlin' : 'client-android'}/${
-					isAndroidJava ? 'java' : 'kotlin'
-			  }/${operation['x-appwrite'].demo}`
-			: `/node_modules/@appwrite.io/repo/docs/examples/${version}/${platform}/examples/${operation['x-appwrite'].demo}`;
-		if (!(path in examples)) {
-			continue;
-		}
-		data.methods.push({
-			id: operation['x-appwrite'].method,
-			demo: await examples[path](),
-			title: operation.summary ?? '',
-			description: operation.description ?? '',
-			parameters: parameters ?? [],
-			responses: responses ?? []
-		});
-	}
+        const path = isAndroid
+            ? `/node_modules/@appwrite.io/repo/docs/examples/${version}/${
+                  isAndroidServer ? 'server-kotlin' : 'client-android'
+              }/${isAndroidJava ? 'java' : 'kotlin'}/${operation['x-appwrite'].demo}`
+            : `/node_modules/@appwrite.io/repo/docs/examples/${version}/${platform}/examples/${operation['x-appwrite'].demo}`;
+        if (!(path in examples)) {
+            continue;
+        }
+        data.methods.push({
+            id: operation['x-appwrite'].method,
+            demo: await examples[path](),
+            title: operation.summary ?? '',
+            description: operation.description ?? '',
+            parameters: parameters ?? [],
+            responses: responses ?? [],
+            method,
+            url
+        });
+    }
 
-	return data;
+    return data;
 }
 
 export function getIdFromReference(reference: OpenAPIV3.ReferenceObject) {
-	const id = reference?.$ref?.split('/')?.pop();
-	if (!id) {
-		throw new Error('Invalid reference');
-	}
-	return id;
+    const id = reference?.$ref?.split('/')?.pop();
+    if (!id) {
+        throw new Error('Invalid reference');
+    }
+    return id;
 }
 
 export function resolveReference(
-	reference: OpenAPIV3.ReferenceObject,
-	api: OpenAPIV3.Document
+    reference: OpenAPIV3.ReferenceObject,
+    api: OpenAPIV3.Document
 ): AppwriteSchemaObject {
-	const id = reference.$ref.split('/').pop();
-	if (!id) {
-		throw new Error('Invalid reference');
-	}
-	const schema = api.components?.schemas?.[id] as AppwriteSchemaObject;
-	if (schema) {
-		return schema;
-	}
-	throw new Error("Schema doesn't exist");
+    const id = reference.$ref.split('/').pop();
+    if (!id) {
+        throw new Error('Invalid reference');
+    }
+    const schema = api.components?.schemas?.[id] as AppwriteSchemaObject;
+    if (schema) {
+        return schema;
+    }
+    throw new Error("Schema doesn't exist");
 }
diff --git a/src/markdoc/nodes/Fence.svelte b/src/markdoc/nodes/Fence.svelte
index d92b26129d5..312a0b8f044 100644
--- a/src/markdoc/nodes/Fence.svelte
+++ b/src/markdoc/nodes/Fence.svelte
@@ -12,6 +12,7 @@
     export let language: Language;
     export let process: boolean;
     export let withLineNumbers = true;
+    export let badge: string | null = null;
 
     const insideMultiCode = hasContext('multi-code');
     const selected = insideMultiCode ? getContext<CodeContext>('multi-code').selected : null;
@@ -49,6 +50,8 @@
     $: result = process
         ? getCodeHtml({ content, language: language ?? 'sh', withLineNumbers })
         : content;
+
+    $: badgeValue = badge ?? platformMap[language];
 </script>
 
 {#if insideMultiCode}
@@ -60,9 +63,9 @@
     <section class="theme-dark aw-code-snippet" aria-label="code-snippet panel">
         <header class="aw-code-snippet-header">
             <div class="aw-code-snippet-header-start">
-                {#if platformMap[language]}
+                {#if badgeValue}
                     <div class="u-flex u-gap-16">
-                        <div class="aw-tag"><span class="text">{platformMap[language]}</span></div>
+                        <div class="aw-tag"><span class="text">{badgeValue}</span></div>
                     </div>
                 {/if}
             </div>
diff --git a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
index 64508c676b0..879f4b26478 100644
--- a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
+++ b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
@@ -151,6 +151,16 @@
                     <!-- eslint-disable-next-line svelte/no-at-html-tags -->
                     {@html parse(data.service?.description)}
                 </div>
+                <div class="aw-article-content-grid-6-4-column-2 u-flex-vertical u-gap-32">
+                    <Fence
+                        language="text"
+                        badge="Base URL"
+                        content="https://cloud.appwrite.io/v1"
+                        process
+                        withLineNumbers={false}
+                    />
+                </div>
+
                 {#if data.methods.length === 0}
                     <div class="aw-article-content-grid-6-4-column-2 u-flex-vertical u-gap-32">
                         <div class="aw-inline-info">
@@ -299,11 +309,20 @@
                                 style="--inset-block-start:var(--p-grid-huge-navs-secondary-sticky-position);"
                             >
                                 <Fence
-                                    language={platform}
-                                    content={method.demo}
+                                    language="text"
+                                    badge="Endpoint"
+                                    content="{method.method.toUpperCase()} {method.url}"
                                     process
                                     withLineNumbers={false}
                                 />
+                                <div class="u-margin-block-start-24">
+                                    <Fence
+                                        language={platform}
+                                        content={method.demo}
+                                        process
+                                        withLineNumbers={false}
+                                    />
+                                </div>
                             </div>
                         </div>
                     </div>
diff --git a/src/routes/docs/references/[version]/models/[model]/+page.server.ts b/src/routes/docs/references/[version]/models/[model]/+page.server.ts
index a85a55f2ea7..2227c152907 100644
--- a/src/routes/docs/references/[version]/models/[model]/+page.server.ts
+++ b/src/routes/docs/references/[version]/models/[model]/+page.server.ts
@@ -1,15 +1,6 @@
-import type { EntryGenerator, PageServerLoad } from './$types';
-import {
-	getApi,
-	getSchema,
-	getService,
-	type AppwriteSchemaObject,
-	getIdFromReference,
-	resolveReference
-} from '$lib/utils/specs';
-import { Platform, Service, versions } from '$lib/utils/references';
-import { error } from '@sveltejs/kit';
+import { getApi, getIdFromReference, getSchema, type AppwriteSchemaObject } from '$lib/utils/specs';
 import type { OpenAPIV3 } from 'openapi-types';
+import type { PageServerLoad } from './$types';
 
 // export const entries: EntryGenerator = () => {
 // 	return ['cloud', ...(versions as string[])].flatMap((version) => {
@@ -22,67 +13,69 @@ import type { OpenAPIV3 } from 'openapi-types';
 // };
 
 type Model = {
-	title: string;
-	properties: Array<{
-		name: string;
-		type: string;
-		description: string;
-		example: string | boolean | number | object | Array<unknown>;
-		items?: Array<string>;
-	}>;
+    title: string;
+    properties: Array<{
+        name: string;
+        type: string;
+        description: string;
+        example: string | boolean | number | object | Array<unknown>;
+        items?: Array<string>;
+    }>;
 };
 
 export const load: PageServerLoad = async ({ params }) => {
-	const version = params.version === 'cloud' ? '1.4.x' : params.version;
-	const api = await getApi(version, 'console-web');
-	const schema = getSchema(params.model, api);
-	const props = Object.entries(schema.properties ?? {});
-	const model: Model = {
-		title: schema.description as string,
-		properties: props.map(([name, data]) => {
-			const property = data as AppwriteSchemaObject;
-			switch (property.type) {
-				case 'array': {
-					const items = [];
-					const propItems = property.items as AppwriteSchemaObject;
-					if (Array.isArray(propItems.anyOf)) {
-						items.push(
-							...propItems.anyOf.map((ref) => getIdFromReference(ref as OpenAPIV3.ReferenceObject))
-						);
-					} else {
-						// items.push(getIdFromReference(propItems as unknown as OpenAPIV3.ReferenceObject));
-					}
-					return {
-						name,
-						type: property.type as string,
-						description: property.description as string,
-						example: '',
-						items:
-							(property.items as AppwriteSchemaObject)?.anyOf?.map((ref) => {
-								const item = getIdFromReference(ref as OpenAPIV3.ReferenceObject);
-								return item;
-							}) ?? []
-					};
-				}
+    const version = params.version === 'cloud' ? '1.4.x' : params.version;
+    const api = await getApi(version, 'console-web');
+    const schema = getSchema(params.model, api);
+    const props = Object.entries(schema.properties ?? {});
+    const model: Model = {
+        title: schema.description as string,
+        properties: props.map(([name, data]) => {
+            const property = data as AppwriteSchemaObject;
+            switch (property.type) {
+                case 'array': {
+                    const items = [];
+                    const propItems = property.items as AppwriteSchemaObject;
+                    if (Array.isArray(propItems.anyOf)) {
+                        items.push(
+                            ...propItems.anyOf.map((ref) =>
+                                getIdFromReference(ref as OpenAPIV3.ReferenceObject)
+                            )
+                        );
+                    } else {
+                        // items.push(getIdFromReference(propItems as unknown as OpenAPIV3.ReferenceObject));
+                    }
+                    return {
+                        name,
+                        type: property.type as string,
+                        description: property.description as string,
+                        example: '',
+                        items:
+                            (property.items as AppwriteSchemaObject)?.anyOf?.map((ref) => {
+                                const item = getIdFromReference(ref as OpenAPIV3.ReferenceObject);
+                                return item;
+                            }) ?? []
+                    };
+                }
 
-				default:
-					return {
-						name,
-						type: property.type as string,
-						description: property.description as string,
-						example: property['x-example']
-					};
-			}
-		})
-	};
+                default:
+                    return {
+                        name,
+                        type: property.type as string,
+                        description: property.description as string,
+                        example: property['x-example']
+                    };
+            }
+        })
+    };
 
-	const example = model.properties.reduce<Record<string, unknown>>((carry, property) => {
-		carry[property.name] = property.example;
+    const example = model.properties.reduce<Record<string, unknown>>((carry, property) => {
+        carry[property.name] = property.example;
 
-		return carry;
-	}, {});
-	return {
-		model,
-		example
-	};
+        return carry;
+    }, {});
+    return {
+        model,
+        example
+    };
 };

From 59ba4887aed06835565d2aeb56d91cd6152b1b74 Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Sun, 17 Dec 2023 01:48:44 +0000
Subject: [PATCH 3/7] fix docs hero

---
 src/routes/docs/+page.svelte | 49 ++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/src/routes/docs/+page.svelte b/src/routes/docs/+page.svelte
index bbd96c6a4b0..1be7c2b703f 100644
--- a/src/routes/docs/+page.svelte
+++ b/src/routes/docs/+page.svelte
@@ -69,22 +69,6 @@
         <enhanced:img src="./blur-1.png" alt="" />
     </div>
 
-    <div
-        class="u-position-absolute aw-is-not-mobile u-only-light"
-        style:inline-size="768px"
-        style:block-size="768px"
-        style:inset-block-start="26rem"
-        style:left="calc(50% - 384px + 600px)"
-    >
-        <img
-            src="/images/animations/tech-light.png"
-            width="768"
-            height="768"
-            alt=""
-            style="position: absolute; display: block;"
-        />
-    </div>
-
     <main class="aw-main-section u-position-relative">
         <div class="u-position-absolute aw-u-opacity-40-mobile bg-blur">
             <img src="/images/bgs/docs-blur-1.svg" alt="" />
@@ -121,18 +105,27 @@
                 <span class="aw-sub-body-500">Explore all technologies</span>
             </a>
 
-            <div class="u-position-absolute aw-is-not-mobile u-only-dark spline-wrapper">
+            <div class="u-position-absolute aw-is-not-mobile spline-wrapper">
                 <Spline url="/images/animations/dark-scene.splinecode" width={660} height={660}>
                     <img
+                        class="u-only-dark"
                         src="/images/animations/tech-dark.png"
                         width="660"
                         height="660"
                         alt=""
                         style="position: absolute;"
                     />
+                    <img
+                        class="u-only-light"
+                        src="/images/animations/tech-light.png"
+                        width="660"
+                        height="660"
+                        alt=""
+                        style="position: absolute;"
+                    />
                 </Spline>
             </div>
-            <div class="bg-boi" />
+            <div class="bg-overlay" />
         </section>
         <section>
             <h2 class="aw-title aw-u-color-text-primary u-max-width-600">Show me some code</h2>
@@ -429,11 +422,6 @@
     .tech-hero {
         @include border-block-gradient;
 
-        background: linear-gradient(to right, #19191c80, #19191c00);
-        // background-color: #19191c80;
-        backdrop-filter: blur(1rem);
-        -webkit-backdrop-filter: blur(1rem);
-
         --m-border-size: 1px;
         --m-border-gradient-before: linear-gradient(
             to right,
@@ -460,9 +448,10 @@
             left: calc(50% - 384px + 600px);
         }
 
-        .bg-boi {
+        .bg-overlay {
             position: absolute;
-            background: linear-gradient(to right, #19191c00 0%, #19191c00 10%, #19191c);
+
+            background: linear-gradient(to right, #ffffff00 0%, #ffffff00 10%, #ffffff);
 
             top: 0;
             right: 10rem;
@@ -473,4 +462,14 @@
             z-index: 9999;
         }
     }
+
+    :global(.theme-dark) .tech-hero {
+        background: linear-gradient(to right, #19191c80, #19191c00);
+        backdrop-filter: blur(1rem);
+        -webkit-backdrop-filter: blur(1rem);
+    }
+
+    :global(.theme-dark) .bg-overlay {
+        background: linear-gradient(to right, #19191c00 0%, #19191c00 10%, #19191c);
+    }
 </style>

From 9102a0d8c5f8d6b5ec9ba4cde88df8f92ee8be96 Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Sun, 17 Dec 2023 12:49:27 +0000
Subject: [PATCH 4/7] PR comments

---
 src/lib/utils/specs.ts                                    | 2 --
 .../[version]/[platform]/[service]/+page.svelte           | 8 +++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/lib/utils/specs.ts b/src/lib/utils/specs.ts
index 87d8e1fa9a3..d2d5da0a147 100644
--- a/src/lib/utils/specs.ts
+++ b/src/lib/utils/specs.ts
@@ -216,7 +216,6 @@ export async function getService(
     const isAndroid = isAndroidJava || isAndroidKotlin;
     const isAndroidServer = platform === Platform.ServerJava || platform === Platform.ServerKotlin;
     const api = await getApi(version, platform);
-    console.log({ api });
     const tag = api.tags?.find((n) => n.name === service);
 
     const data: Awaited<ReturnType<typeof getService>> = {
@@ -234,7 +233,6 @@ export async function getService(
     }
 
     for (const { method, value, url } of iterateAllMethods(api, service)) {
-        // console.log({ method, value });
         const operation = value as AppwriteOperationObject;
         const parameters = getParameters(operation);
         const responses: SDKMethod['responses'] = Object.entries(operation.responses ?? {}).map(
diff --git a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
index 879f4b26478..8ae72f3d9bf 100644
--- a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
+++ b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
@@ -145,13 +145,15 @@
                 </div>
             </div>
         </header>
-        <div class="aw-article-content">
+        <div class="aw-article-content" style:gap="6rem">
             <section class="aw-article-content-grid-6-4">
                 <div class="aw-article-content-grid-6-4-column-1 u-flex-vertical u-gap-32">
                     <!-- eslint-disable-next-line svelte/no-at-html-tags -->
                     {@html parse(data.service?.description)}
                 </div>
-                <div class="aw-article-content-grid-6-4-column-2 u-flex-vertical u-gap-32">
+                <div
+                    class="aw-article-content-grid-6-4-column-2 u-flex-vertical u-gap-32 u-main-end"
+                >
                     <Fence
                         language="text"
                         badge="Base URL"
@@ -311,7 +313,7 @@
                                 <Fence
                                     language="text"
                                     badge="Endpoint"
-                                    content="{method.method.toUpperCase()} {method.url}"
+                                    content="{method.method.toUpperCase()} /v1{method.url}"
                                     process
                                     withLineNumbers={false}
                                 />

From c286bf39548629a899debffb78059e91755880b4 Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Sun, 17 Dec 2023 13:06:05 +0000
Subject: [PATCH 5/7] adjust method gap & accordion spacings in docs references

---
 .../[platform]/[service]/+page.svelte         | 39 +++++++++++++------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
index 8ae72f3d9bf..32d8dc2f391 100644
--- a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
+++ b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
@@ -202,17 +202,11 @@
                                             </div>
                                         </summary>
                                         <div class="collapsible-content">
-                                            <div
-                                                class="aw-card is-transparent u-padding-16 u-margin-block-start-16"
-                                            >
+                                            <div class="aw-card is-transparent u-padding-16">
                                                 <ul class="u-flex-vertical">
                                                     {#each method.parameters as parameter, i}
                                                         {@const first = i === 0}
-                                                        <li
-                                                            class:u-sep-block-start={!first}
-                                                            class:u-padding-block-start-16={!first}
-                                                            class="u-margin-block-start-16"
-                                                        >
+                                                        <li class:u-padding-block-start-16={!first}>
                                                             <article>
                                                                 <header
                                                                     class="u-flex u-cross-baseline u-gap-8"
@@ -257,9 +251,7 @@
                                         </div>
                                     </summary>
                                     <div class="collapsible-content">
-                                        <div
-                                            class="aw-card is-transparent u-padding-16 u-margin-block-start-16"
-                                        >
+                                        <div class="aw-card is-transparent u-padding-16">
                                             <ul>
                                                 {#each method.responses as response}
                                                     {#if response.models}
@@ -380,4 +372,29 @@
     .aw-inline-code {
         translate: 0 0.125rem;
     }
+
+    .collapsible-item {
+        border-block-end: 0.0625rem solid hsl(var(--aw-color-offset));
+    }
+
+    .collapsible-button {
+        padding-block: 1rem;
+    }
+
+    .collapsible-content {
+        margin-block-start: 0;
+        padding-block-end: 1rem;
+
+        article :last-child {
+            margin-block-end: 0;
+        }
+
+        ul {
+            gap: 1rem;
+
+            li:not(:first-child) {
+                border-block-start: solid 0.0625rem hsl(var(--aw-color-offset));
+            }
+        }
+    }
 </style>

From e2c170f3e3d3fa9788a76b3f87665d34a0bc01ca Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Mon, 18 Dec 2023 14:26:36 +0000
Subject: [PATCH 6/7] vincent review

---
 .../references/[version]/[platform]/[service]/+page.svelte    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
index 32d8dc2f391..e8103d070df 100644
--- a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
+++ b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
@@ -212,7 +212,7 @@
                                                                     class="u-flex u-cross-baseline u-gap-8"
                                                                 >
                                                                     <span
-                                                                        class="aw-eyebrow aw-u-color-text-primary"
+                                                                        class="aw-code aw-u-color-text-primary"
                                                                     >
                                                                         {parameter.name}
                                                                     </span>
@@ -305,7 +305,7 @@
                                 <Fence
                                     language="text"
                                     badge="Endpoint"
-                                    content="{method.method.toUpperCase()} /v1{method.url}"
+                                    content="{method.method.toUpperCase()} {method.url}"
                                     process
                                     withLineNumbers={false}
                                 />

From 42effa21e25f584a98012a4aa91a2d281bdba417 Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Mon, 18 Dec 2023 15:12:04 +0000
Subject: [PATCH 7/7] change endpoint copy content

---
 src/markdoc/nodes/Fence.svelte                                 | 3 ++-
 .../references/[version]/[platform]/[service]/+page.svelte     | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/markdoc/nodes/Fence.svelte b/src/markdoc/nodes/Fence.svelte
index 312a0b8f044..550f2d4b131 100644
--- a/src/markdoc/nodes/Fence.svelte
+++ b/src/markdoc/nodes/Fence.svelte
@@ -9,6 +9,7 @@
     import { melt } from '@melt-ui/svelte';
 
     export let content: string;
+    export let toCopy: string | undefined = undefined;
     export let language: Language;
     export let process: boolean;
     export let withLineNumbers = true;
@@ -23,7 +24,7 @@
     }
     let copyText = CopyStatus.Copy;
     async function handleCopy() {
-        await copy(content);
+        await copy(toCopy ?? content);
 
         copyText = CopyStatus.Copied;
         setTimeout(() => {
diff --git a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
index e8103d070df..aa020f094fb 100644
--- a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
+++ b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte
@@ -306,6 +306,7 @@
                                     language="text"
                                     badge="Endpoint"
                                     content="{method.method.toUpperCase()} {method.url}"
+                                    toCopy={method.url}
                                     process
                                     withLineNumbers={false}
                                 />
