diff --git a/nginx.conf b/nginx.conf index 9a507824866d..882867973dbb 100644 --- a/nginx.conf +++ b/nginx.conf @@ -90,9 +90,12 @@ http { rewrite ^/docs/([a-zA-Z][a-zA-Z])/cookbook/quick-start/$ $scheme://$http_host/docs/$1/quick-start/ permanent; rewrite ^/docs/en/substreams/(?!index\.).+$ https://substreams.streamingfast.io permanent; rewrite ^/docs/en/firehose/(?!index\.).+$ https://firehose.streamingfast.io permanent; + rewrite ^/docs/([a-zA-Z][a-zA-Z])/developer/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent; + rewrite ^/docs/([a-zA-Z][a-zA-Z])/developing/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent; # Temporary redirects (302) rewrite ^/docs/en/querying/graph-client/$ $scheme://$http_host/docs/en/querying/graph-client/README/ redirect; + rewrite ^/docs/en/developing/graph-ts/$ $scheme://$http_host/docs/en/developing/graph-ts/README/ redirect; location / { try_files $uri $uri.html $uri/index.html =404; diff --git a/website/next.config.js b/website/next.config.js index 220c1df10967..18c43ceba793 100644 --- a/website/next.config.js +++ b/website/next.config.js @@ -61,6 +61,21 @@ export default withNextra({ destination: '/en/querying/graph-client/README/', permanent: false, }, + { + source: '/en/developing/graph-ts/', + destination: '/en/developing/graph-ts/README/', + permanent: false, + }, + { + source: '/en/developer/assemblyscript-api/', + destination: '/en/developing/graph-ts/api/', + permanent: true, + }, + { + source: '/en/developing/assemblyscript-api/', + destination: '/en/developing/graph-ts/api/', + permanent: true, + }, ], images: { unoptimized: true, diff --git a/website/pages/en/developing/_meta.js b/website/pages/en/developing/_meta.js index 36fce28a516e..8233bdd02d64 100644 --- a/website/pages/en/developing/_meta.js +++ b/website/pages/en/developing/_meta.js @@ -1,7 +1,7 @@ export default { 'supported-networks': '', 'creating-a-subgraph': '', - 'assemblyscript-api': '', + 'graph-ts': 'AssemblyScript API', 'unit-testing-framework': '', 'developer-faqs': '', 'substreams-powered-subgraphs-faq': '', diff --git a/website/pages/en/developing/graph-ts/[[...slug]].mdx b/website/pages/en/developing/graph-ts/[[...slug]].mdx new file mode 100644 index 000000000000..6c0a46b8602f --- /dev/null +++ b/website/pages/en/developing/graph-ts/[[...slug]].mdx @@ -0,0 +1,52 @@ +import { RemoteContent } from 'nextra/data' +import { buildDynamicMDX } from 'nextra/remote' +import { getPageMap } from '@/src/getPageMap' +import { remarkReplaceLinks } from '@/src/remarkReplaceLinks' +import { Mermaid } from 'nextra/components' +import { visit } from 'unist-util-visit' +import json from '@/remote-files/graph-ts.json' + +export const getStaticPaths = () => ({ + fallback: false, + paths: json.filePaths.map((filePath) => ({ + params: { + slug: filePath.replace(/\.mdx?/, '').split('/'), + }, + })), +}) + +export async function getStaticProps({ params }) { + const { filePaths, user, repo, branch, docsPath } = json + const paths = params?.slug?.join('/') + const foundPath = filePaths.find((filePath) => filePath.startsWith(paths)) + const baseURL = `https://raw.githubusercontent.com/${user}/${repo}/${branch}/${docsPath}${foundPath}` + const response = await fetch(baseURL) + const content = await response.text() + const mdx = await buildDynamicMDX(content, { + mdxOptions: { + format: 'md', + remarkPlugins: [ + () => (tree, _file, done) => { + visit(tree, 'link', (node) => { + if (node.url.startsWith('../')) { + node.url = node.url.replace('../', `https://github.com/${user}/${repo}/tree/${branch}/`) + } + }) + done() + }, + [remarkReplaceLinks, { foundPath, basePath: '/developing/graph-ts/' }], + ], + }, + codeHighlight: false, + }) + return { + props: { + ...mdx, + __nextra_pageMap: await getPageMap('en'), + hideLocaleSwitcher: true, + remoteFilePath: `https://github.com/${user}/${repo}/tree/${branch}/${docsPath}${foundPath}`, + }, + } +} + + diff --git a/website/pages/en/developing/graph-ts/_meta.js b/website/pages/en/developing/graph-ts/_meta.js new file mode 100644 index 000000000000..56029533d9ea --- /dev/null +++ b/website/pages/en/developing/graph-ts/_meta.js @@ -0,0 +1,10 @@ +import { createCatchAllMeta } from 'nextra/catch-all' + +import json from '../../../../remote-files/graph-ts.json' assert { type: 'json' } + +export default () => + createCatchAllMeta(json.filePaths, { + README: 'Introduction', + api: 'API Reference', + 'common-issues': 'Common Issues', + }) diff --git a/website/pages/en/developing/assemblyscript-api.mdx b/website/pages/en/developing/graph-ts/api.mdx similarity index 96% rename from website/pages/en/developing/assemblyscript-api.mdx rename to website/pages/en/developing/graph-ts/api.mdx index bbe395130da7..4384e0b8d1e2 100644 --- a/website/pages/en/developing/assemblyscript-api.mdx +++ b/website/pages/en/developing/graph-ts/api.mdx @@ -11,22 +11,6 @@ This page documents what built-in APIs can be used when writing subgraph mapping It is also possible to add other libraries as dependencies, as long as they are compatible with [AssemblyScript](https://github.com/AssemblyScript/assemblyscript). Since this is the language mappings are written in, the [AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) is a good source for language and standard library features. -## Installation - -Subgraphs created with [`graph init`](/developing/creating-a-subgraph) come with preconfigured dependencies. All that is required to install these dependencies is to run one of the following commands: - -```sh -yarn install # Yarn -npm install # NPM -``` - -If the subgraph was created from scratch, one of the following two commands will install the Graph TypeScript library as a dependency: - -```sh -yarn add --dev @graphprotocol/graph-ts # Yarn -npm install --save-dev @graphprotocol/graph-ts # NPM -``` - ## API Reference The `@graphprotocol/graph-ts` library provides the following APIs: @@ -862,10 +846,3 @@ dataSources: - `BigInt`: Specifies a large integer value. Must be quoted due to its large size. This context is then accessible in your subgraph mapping files, enabling more dynamic and configurable subgraphs. - -### Common AssemblyScript Issues - -There are certain [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) issues that are common to run into during subgraph development. They range in debug difficulty, however, being aware of them may help. The following is a non-exhaustive list of these issues: - -- `Private` class variables are not enforced in [AssembyScript](https://www.assemblyscript.org/status.html#language-features). There is no way to protect class variables from being directly changed from the class object. -- Scope is not inherited into [closure functions](https://www.assemblyscript.org/status.html#on-closures), i.e. variables declared outside of closure functions cannot be used. Explanation in [Developer Highlights #3](https://www.youtube.com/watch?v=1-8AW-lVfrA&t=3243s). diff --git a/website/pages/en/developing/graph-ts/common-issues.mdx b/website/pages/en/developing/graph-ts/common-issues.mdx new file mode 100644 index 000000000000..5b99efa8f493 --- /dev/null +++ b/website/pages/en/developing/graph-ts/common-issues.mdx @@ -0,0 +1,8 @@ +--- +title: Common AssemblyScript Issues +--- + +There are certain [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) issues that are common to run into during subgraph development. They range in debug difficulty, however, being aware of them may help. The following is a non-exhaustive list of these issues: + +- `Private` class variables are not enforced in [AssembyScript](https://www.assemblyscript.org/status.html#language-features). There is no way to protect class variables from being directly changed from the class object. +- Scope is not inherited into [closure functions](https://www.assemblyscript.org/status.html#on-closures), i.e. variables declared outside of closure functions cannot be used. Explanation in [Developer Highlights #3](https://www.youtube.com/watch?v=1-8AW-lVfrA&t=3243s). diff --git a/website/remote-files/firehose.json b/website/remote-files/firehose.json index e0aedb9de58f..d8f228a78350 100644 --- a/website/remote-files/firehose.json +++ b/website/remote-files/firehose.json @@ -35,6 +35,8 @@ "references/indexing.md", "references/naming-conventions.md", "references/protobuf-schemas.md", - "references/repositories.md" + "references/repositories.md", + "release-notes/change-logs/README.md", + "release-notes/change-logs/nov-8th-2023-polygon-update.md" ] } \ No newline at end of file diff --git a/website/remote-files/graph-ts.json b/website/remote-files/graph-ts.json new file mode 100644 index 000000000000..a13fa1e05bf2 --- /dev/null +++ b/website/remote-files/graph-ts.json @@ -0,0 +1,10 @@ +{ + "user": "graphprotocol", + "repo": "graph-tooling", + "branch": "main", + "docsPath": "packages/ts/", + "filePaths": [ + "CHANGELOG.md", + "README.md" + ] +} \ No newline at end of file diff --git a/website/route-lockfile.txt b/website/route-lockfile.txt index c4663e075f06..4b6085ce1fe8 100644 --- a/website/route-lockfile.txt +++ b/website/route-lockfile.txt @@ -184,9 +184,15 @@ /en/deploying/hosted-service/ /en/deploying/subgraph-studio-faqs/ /en/deploying/subgraph-studio/ -/en/developing/assemblyscript-api/ +/en/developer/assemblyscript-api/ -> /en/developing/graph-ts/api/ +/en/developing/assemblyscript-api/ -> /en/developing/graph-ts/api/ /en/developing/creating-a-subgraph/ /en/developing/developer-faqs/ +/en/developing/graph-ts/ -> /en/developing/graph-ts/README/ +/en/developing/graph-ts/CHANGELOG/ +/en/developing/graph-ts/README/ +/en/developing/graph-ts/api/ +/en/developing/graph-ts/common-issues/ /en/developing/substreams-powered-subgraphs-faq/ /en/developing/supported-networks/ /en/developing/unit-testing-framework/ diff --git a/website/scripts/fetch-remote-filepaths.ts b/website/scripts/fetch-remote-filepaths.ts index f5ce16e88726..3f9332d500c9 100644 --- a/website/scripts/fetch-remote-filepaths.ts +++ b/website/scripts/fetch-remote-filepaths.ts @@ -86,3 +86,11 @@ await fetchRemoteFilePaths({ docsPath: 'docs/', outputPath: path.join(process.cwd(), 'remote-files', 'graph-client.json'), }) + +await fetchRemoteFilePaths({ + user: 'graphprotocol', + repo: 'graph-tooling', + branch: 'main', + docsPath: 'packages/ts/', + outputPath: path.join(process.cwd(), 'remote-files', 'graph-ts.json'), +})