Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into graph-relations-reference
  • Loading branch information
Dhghomon committed Dec 19, 2024
2 parents 3bb5ab1 + ebe1b15 commit 122e019
Show file tree
Hide file tree
Showing 63 changed files with 466 additions and 131 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ deploy:
@echo "Deploy..."
aws s3 sync --region eu-west-2 --cache-control "public, max-age=31536000, immutable" --exclude '.DS_Store' --exclude '*' --include '*.webp' --content-type 'image/webp' ./dist/docs/_astro s3://www.surrealdb.com/docs/_astro/
aws s3 sync --region eu-west-2 --cache-control "public, max-age=31536000, immutable" --exclude '.DS_Store' --exclude '*.webp' ./dist/docs/_astro s3://www.surrealdb.com/docs/_astro/
aws s3 sync --region eu-west-2 --cache-control "public, max-age=86400" --exclude '.DS_Store' ./dist/docs/~partytown s3://www.surrealdb.com/docs/~partytown/
aws s3 sync --region eu-west-2 --cache-control "public, max-age=30" --delete --exclude '*' --include '*.html' ./dist/docs/ s3://www.surrealdb.com/docs/

.PHONY: stage
stage:
@echo "Stage..."
aws s3 sync --region eu-west-2 --cache-control "public, max-age=31536000, immutable" --exclude '.DS_Store' --exclude '*' --include '*.webp' --content-type 'image/webp' ./dist/docs/_astro s3://www.surrealdb.dev/docs/_astro/
aws s3 sync --region eu-west-2 --cache-control "public, max-age=31536000, immutable" --exclude '.DS_Store' --exclude '*.webp' ./dist/docs/_astro s3://www.surrealdb.dev/docs/_astro/
aws s3 sync --region eu-west-2 --cache-control "public, max-age=86400" --exclude '.DS_Store' ./dist/docs/~partytown s3://www.surrealdb.dev/docs/~partytown/
aws s3 sync --region eu-west-2 --cache-control "public, max-age=30" --delete --exclude '*' --include '*.html' ./dist/docs/ s3://www.surrealdb.dev/docs/
2 changes: 0 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import mdx from '@astrojs/mdx';
import partytown from '@astrojs/partytown';
import solidJs from '@astrojs/solid-js';
import tailwind from '@astrojs/tailwind';
import compress from 'astro-compress';
Expand Down Expand Up @@ -32,7 +31,6 @@ export default defineConfig({
tailwind({
nesting: true,
}),
partytown(),
compress({
Image: false,
}),
Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@astrojs/partytown": "^2.1.2",
"@biomejs/biome": "1.8.3",
"astro-compress": "^2.3.5",
"esbuild": "^0.23.1",
Expand Down
146 changes: 139 additions & 7 deletions scripts/post-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,132 @@ const scripts = [
'https://static.ads-twitter.com/uwt.js',
];

await extractInlineResources();
await checkBrokenLinks();
await fetchRemoteResources();
await extractInlineResources();

async function checkBrokenLinks() {
const broken: string[] = [];
const files = await glob('**/*.html', {
cwd: __dist,
dot: true,
absolute: true,
filesOnly: true,
});

const websiteCache = new Map<string, boolean>();
const self = ['https://surrealdb.com', 'https://www.surrealdb.com'];

for (const file of files) {
let loggedFile = false;
const raw = fs.readFileSync(file, { encoding: 'utf-8' });
const parsed = parseHTML(raw, {
comment: true,
});

const links = parsed.querySelectorAll('a');
for (const link of links) {
let href = link.getAttribute('href');
if (!href) {
continue;
}

let hasIssue = false;
function issue(issue: string) {
if (!href) {
return;
}

if (!broken.includes(href)) {
broken.push(href);
}

if (!hasIssue && !loggedFile) {
console.error(`\n[ERROR] In file: ${file}`);
loggedFile = true;
}

hasIssue = true;
console.error(`[ERROR] ${issue}`);
}

for (const domain of self) {
if (href.startsWith(domain)) {
issue(`External link should be local: ${href}`);
href = href.slice(domain.length);
break;
}
}

if (href.startsWith('/')) {
href = href.split('#')[0];
href = href.split('?')[0];

let exists = false;

switch (true) {
case href === '/docs':
case href.startsWith('/docs/'): {
exists = fs.existsSync(
path.join(__root, 'dist', href, 'index.html')
);
break;
}

default: {
if (!websiteCache.has(href)) {
const res = await fetch(
`https://surrealdb.com${href}`,
{
redirect: 'manual',
}
);
websiteCache.set(href, res.ok);
}

const res = websiteCache.get(href);
if (res === undefined) {
throw new Error(`Cache miss for ${href}`);
}

exists = res;
break;
}
}

if (!exists) {
issue(`Broken link: ${href}`);
}
}

if (hasIssue) {
let elemStr = link.toString();
if (elemStr.length > 100) {
elemStr = `${elemStr.slice(0, 97)}...`;
}

console.error(`[ERROR] For element: ${elemStr}`);
}
}
}

if (broken.length > 0) {
console.error('\n=============================================');
console.error('\n[ERROR] Broken links found.');
console.error(
'[ERROR] Possible issues include dead links, redirected links, or external links that should be local.'
);
console.error('[ERROR] Check the above logs for more in-depth details');
console.error("[ERROR] Here's the list: \n");
for (const link of broken) {
console.error(`[ERROR] Broken link: ${link}`);
}

console.error('\n');

throw new Error('Broken links found');
}
}

async function fetchRemoteResources() {
// Fetch the remote scripts
Expand All @@ -28,12 +152,20 @@ async function fetchRemoteResources() {
fs.writeFileSync(path.join(__astro, name), await minifyJS(content));
// Scan the JS files in the dist folder
console.log('[EXTRACT] Scanning JS files in dist/docs/ folder');
const files = await glob('**/*.js', {
cwd: __dist,
dot: true,
absolute: true,
filesOnly: true,
});
const files = [
...(await glob('**/*.js', {
cwd: __dist,
dot: true,
absolute: true,
filesOnly: true,
})),
...(await glob('**/*.html', {
cwd: __dist,
dot: true,
absolute: true,
filesOnly: true,
})),
];
// Loop over each file and process the content
console.log(`[EXTRACT] Found ${files.length} JS files`);
for (const file of files) {
Expand Down
12 changes: 9 additions & 3 deletions src/components/RenderDoc.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { getEntry } from 'astro:content';
import type { CollectionKey } from 'astro:content';
import { PageHeadings } from '@components/PageHeadings.tsx';
import Sidebar from '@components/Sidebar/index.astro';
import { generateBreadcrumb, generateSidebar } from '@src/util/doc';
import {
findNextPage,
findPreviousPage,
generateBreadcrumb,
generateSidebar,
} from '@src/util/doc';
import { Icon } from 'astro-icon/components';
import BaseLayout from './layout/BaseLayout.astro';
import MarkdownContainer from './shared/MarkdownContainer.astro';
Expand All @@ -31,8 +36,9 @@ if (!entry) {
const { Content, headings } = await entry.render();
const sidebarItems = await generateSidebar(collection);
const sidebarIndex = sidebarItems.flat.findIndex((item) => item.slug === slug);
const prev = sidebarItems.flat.at(sidebarIndex - 1);
const next = sidebarItems.flat.at(sidebarIndex + 1) ?? sidebarItems.flat[0];
const prev = findPreviousPage(sidebarItems.flat, sidebarIndex);
const next =
findNextPage(sidebarItems.flat, sidebarIndex) ?? sidebarItems.flat[0];
function filteredHeadings() {
if (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const metadata = {
},
repo: {
title: 'Forum',
href: 'https://surrealdb.com/community/forums',
href: '/community',
},
},
'doc-surrealist': {
Expand Down
6 changes: 0 additions & 6 deletions src/components/layout/Analytics.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
document.head.appendChild(s);
}

</script>

<script defer is:inline type="text/partytown">

// Common Room

window.signals = Object.assign(
Expand Down Expand Up @@ -65,9 +61,7 @@
// Google

window.dataLayer = window.dataLayer || [];

window.gtag = function () { window.dataLayer.push(arguments); };

gtag('js', new Date());
gtag('config', 'G-J1NWM32T1V');

Expand Down
10 changes: 5 additions & 5 deletions src/components/layout/Footer/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
Discord
</a>
<span>•</span>
<a href="https://surrealdb.com/community">
<a href="/community">
Community
</a>
<span>•</span>
<a href="https://surrealdb.com/cloud">
<a href="/cloud">
Cloud
</a>
<span>•</span>
<a href="https://surrealdb.com/features">
<a href="/features">
Features
</a>
<span>•</span>
<a href="https://surrealdb.com/releases">
<a href="/releases">
Releases
</a>
<span>•</span>
<a href="https://surrealdb.com/install">
<a href="/install">
Install
</a>
</div>
2 changes: 1 addition & 1 deletion src/content/doc-cloud/advanced-topics/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ In this section you will explore the following advanced topics for navigating Su
- [Configure an Instance](/docs/cloud/advanced-topics/configure-an-instance)
- [Migrating databases](/docs/cloud/advanced-topics/migrating-data)
- [Settings and customisation](/docs/cloud/advanced-topics/settings-and-customisation)
- [SurrealQL editor](/docs/cloud/advanced-topics/surrealql-editor)
- [SurrealQL editor](/docs/cloud/advanced-topics/surrealql-editors)


## Next steps
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-cloud/billing-and-support/support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Surreal Cloud offers a variety of tools, resources, and community channels to he

## Surreal Sidekick (beta)

Surreal Sidekick (beta) is an AI copilot that can help you get started with SurrealDB, convert queries to SurrealQL, and answer general questions. Surreal Sidekick is only trained with public facing resources, such as our [SurrealDB documentation](/docs/surrealdb), [SurrealDB University](https://surrealdb.com/learn), and the [SurrealDB Book](https://surrealdb.com/learn/book).
Surreal Sidekick (beta) is an AI copilot that can help you get started with SurrealDB, convert queries to SurrealQL, and answer general questions. Surreal Sidekick is only trained with public facing resources, such as our [SurrealDB documentation](/docs/surrealdb), [SurrealDB University](/learn), and the [SurrealDB Book](/learn/book).

<Image
alt="Surreal Sidekick"
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-cloud/connect/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Once you have created a Surreal Cloud Instance, you can connect to it via CLI. T

## Prerequisites

Before connecting to your Surreal Cloud Instance using the CLI, you need to install the [SurrealDB CLI](/docs/surrealdb/installation). Installation instructions are in the [SurrealDB CLI documentation](/docs/cli/installation).
Before connecting to your Surreal Cloud Instance using the CLI, you need to install the [SurrealDB CLI](/docs/surrealdb/installation).

## Connect to your Surreal Cloud Instance

Expand Down
4 changes: 2 additions & 2 deletions src/content/doc-cloud/connect/sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ After you have selected your SDK, you will need to provide your connection detai

## Enter connection details

When using any of the SurrealDB SDKs, before you can start querying your Surreal Cloud Instance, you will need to provide your connection details. SurrealDB requires **namespace** & **database** details so that it knows where to run and store your data. Learn more about [namespaces and databases](/docs/surrealdb/concepts/databases) in the SurrealDB documentation.
When using any of the SurrealDB SDKs, before you can start querying your Surreal Cloud Instance, you will need to provide your connection details. SurrealDB requires **namespace** & **database** details so that it knows where to run and store your data. Learn more about [namespaces](/docs/surrealdb/introduction/concepts/namespace) and [databases](/docs/surrealdb/introduction/concepts/database) in the SurrealDB documentation.



Expand Down Expand Up @@ -61,7 +61,7 @@ src={{

After creating your root authentication, you will be able to authenticate with your Surreal Cloud Instance using any of the available SDKs.

If you want to create a Namespace and Database authentication for record-level access, you will need to first create a Namespace and Database. Learn more about [namespaces and databases](/docs/surrealdb/concepts/databases) in the SurrealDB documentation.
If you want to create a Namespace and Database authentication for record-level access, you will need to first create a Namespace and Database. Learn more about [namespaces](/docs/surrealdb/introduction/concepts/namespace) and [databases](/docs/surrealdb/introduction/concepts/database) in the SurrealDB documentation.


## Connect to your Surreal Cloud Instance
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-cloud/connect/surrealist.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ You can now see your queries and results in the Surrealist query view. You can a

## Next steps

Learn more about [Surrealist](/docs/surrealist) and SurrealQL in the [SurrealDB documentation](/docs/surrealdb/surrealql/).
Learn more about [Surrealist](/docs/surrealist) and SurrealQL in the [SurrealDB documentation](/docs/surrealql).
14 changes: 7 additions & 7 deletions src/content/doc-cloud/faqs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Yes. We have a [resource hub with all our latest documentation](/docs). We also

### What kind of support is available at the launch of Surreal Cloud (Beta)?

We are offering community support at launch. You can get help via our [Discord channel](https://discord.gg/surrealdb) `#surreal-cloud` or any of our [community channels](https://surrealdb.com/community).
We are offering community support at launch. You can get help via our [Discord channel](https://discord.gg/surrealdb) `#surreal-cloud` or any of our [community channels](/community).

### Which cloud platform is SurrealDB available on?

Expand All @@ -45,7 +45,7 @@ Surreal Cloud (Beta) supports the following programming languages:

- [JavaScript/TypeScript](/docs/sdk/javascript)
- [Python](/docs/sdk/python)
- [Go](/docs/sdk/go)
- [Go](/docs/sdk/golang)
- [Java](/docs/sdk/java)
- [Rust](/docs/sdk/rust)
- [PHP](/docs/sdk/php)
Expand Down Expand Up @@ -78,7 +78,7 @@ Surreal Cloud (Beta) does not currently allow outgoing network requests, scripti

Surreal Cloud (Beta) is designed with security in mind and aims to provide robust protection for your data and applications. The platform leverages industry-standard security practices, including encryption at rest and in transit, network isolation, access controls and monitoring. For authentication, Surreal Cloud (Beta) supports multi-factor authentication through the available identity providers that offer it to their users. We are also working towards ISO 27001 and SOC 2 compliance, with plans to expand to other industry-specific compliance programs in the future, such as HIPAA or PCI DSS.

Additionally, Surreal Cloud (Beta) is built on top of SurrealDB, which provides powerful and flexible [security features](https://surrealdb.com/docs/surrealdb/security/summary#product) that are available to all Surreal Cloud (Beta) customers. SurrealDB is developed and maintained following modern [security practices](https://surrealdb.com/docs/surrealdb/security/summary#process) to ensure early detection of security vulnerabilities and other security issues.
Additionally, Surreal Cloud (Beta) is built on top of SurrealDB, which provides powerful and flexible [security features](/docs/surrealdb/security/summary#product) that are available to all Surreal Cloud (Beta) customers. SurrealDB is developed and maintained following modern [security practices](/docs/surrealdb/security/summary#process) to ensure early detection of security vulnerabilities and other security issues.

Please note that we will keep improving security during the ongoing beta stage and, as a precaution, we recommend abstaining from hosting sensitive data in Surreal Cloud (Beta) during this stage.

Expand Down Expand Up @@ -118,7 +118,7 @@ All instances created in Surreal Cloud are publicly reachable over the internet

### How much does Surreal Cloud (Beta) cost?

Surreal Cloud (Beta) offers a flexible pricing model that allows you to pay only for the resources you use. The pricing is based on storage and compute you consume. For detailed pricing information, please refer to the [pricing](https://surrealdb.com/pricing) page.
Surreal Cloud (Beta) offers a flexible pricing model that allows you to pay only for the resources you use. The pricing is based on storage and compute you consume. For detailed pricing information, please refer to the [pricing](/pricing) page.

### Is there a free tier available for Surreal Cloud (Beta)?

Expand All @@ -142,7 +142,7 @@ Please send an email to [email protected] outlining the nature of your query

### Are there any additional fees?

No, we are transparent about our pricing. All costs are outlined on our [pricing page](https://surrealdb.com/pricing), and there are no hidden fees or unexpected charges. Prices quoted on our website are exclusive of VAT or sales tax. Any relevant taxes will be displayed clearly on all customer invoices.
No, we are transparent about our pricing. All costs are outlined on our [pricing page](/pricing), and there are no hidden fees or unexpected charges. Prices quoted on our website are exclusive of VAT or sales tax. Any relevant taxes will be displayed clearly on all customer invoices.

### How am I billed for usage?

Expand All @@ -152,7 +152,7 @@ You are billed on a monthly basis for all services used during the previous mont

### What terms and conditions govern my use of Surreal Cloud (Beta)?

Using Surreal Cloud (Beta) means that the User agrees to the terms and conditions of our Master Services Agreement (MSA) available on our [legal page](https://surrealdb.com/legal). Here we endeavour to be open and transparent with our legal, compliance, and privacy processes and our shared responsibilities and commitments to supporting your use of the Services.
Using Surreal Cloud (Beta) means that the User agrees to the terms and conditions of our Master Services Agreement (MSA) available on our [legal page](/legal). Here we endeavour to be open and transparent with our legal, compliance, and privacy processes and our shared responsibilities and commitments to supporting your use of the Services.

### Are you located in a US-Embargoed country or in Russia?

Expand All @@ -178,7 +178,7 @@ You can find a variety of resources to help you learn more about SurrealDB via [

- [SurrealDB Docs](http://www.surrealdb.com/docs): Comprehensive guides and references for all features, including docs to accompany [Surrealist](http://www.surrealdb.com/docs/cloud)
- [YouTube Channel](https://youtube.com/surrealdb): Stay up-to-date with the latest releases, learn new skills and discover what other developers are building with SurrealDB.
- [SurrealDB University](https://surrealdb.com/learn): A self-paced video course with hands-on labs and interactive tutorials.
- [SurrealDB University](/learn): A self-paced video course with hands-on labs and interactive tutorials.
- [SurrealDB Book](http://www.surrealdb.com/learn/book): An in-depth, story-driven guide to mastering SurrealDB.

### How do I report a bug or request a feature in Surreal Cloud (Beta)?
Expand Down
Loading

0 comments on commit 122e019

Please sign in to comment.