From 430760eca831a3c7abf929fce57d5c107e41ba27 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 8 Aug 2024 14:18:27 +0200 Subject: [PATCH 1/2] #820 - Update API URLs --- CHANGELOG.md | 4 ++++ src/commands/Backers.ts | 24 ++++++++----------- src/constants/Links.ts | 4 ++-- .../components/Chatbot/Chatbot.tsx | 4 ++-- .../components/Chatbot/Feedback.tsx | 2 +- src/dashboardWebView/index.tsx | 2 +- src/services/SponsorAI.ts | 7 +++--- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6098947d..34119525 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [10.2.1] - 2024-08-08 + +- [#820](https://github.com/estruyf/vscode-front-matter/issues/820): Update API links to the new API URL + ## [10.2.0] - 2024-06-12 - [Release notes](https://beta.frontmatter.codes/updates/v10.2.0) ### ✨ New features diff --git a/src/commands/Backers.ts b/src/commands/Backers.ts index 5b743c61..1eaee891 100644 --- a/src/commands/Backers.ts +++ b/src/commands/Backers.ts @@ -22,20 +22,16 @@ export class Backers { const githubAuth = await authentication.getSession('github', ['read:user'], { silent: true }); if (githubAuth && githubAuth.accessToken) { try { - const isBeta = ext.isBetaVersion(); - const response = await fetch( - `https://${isBeta ? `beta.` : ``}frontmatter.codes/api/v2/backers`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - accept: 'application/json' - }, - body: JSON.stringify({ - token: githubAuth.accessToken - }) - } - ); + const response = await fetch(`https://api.frontmatter.codes/v2/backers`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + accept: 'application/json' + }, + body: JSON.stringify({ + token: githubAuth.accessToken + }) + }); if (response.ok) { const prevData = await ext.getState(CONTEXT.backer, 'global'); diff --git a/src/constants/Links.ts b/src/constants/Links.ts index 7c839c31..e27e94a5 100644 --- a/src/constants/Links.ts +++ b/src/constants/Links.ts @@ -14,8 +14,8 @@ export const DOCS_SUBMODULES = 'https://frontmatter.codes/docs/git-integration#g export const WEBSITE_LINKS = { root: 'https://frontmatter.codes', api: { - metrics: 'https://frontmatter.codes/api/metrics', - ai: 'https://frontmatter.codes/api/ai' + root: 'https://api.frontmatter.codes', + metrics: 'https://api.frontmatter.codes/metrics' }, docs: { dataDashboard: 'https://frontmatter.codes/docs/dashboard/datafiles-view', diff --git a/src/dashboardWebView/components/Chatbot/Chatbot.tsx b/src/dashboardWebView/components/Chatbot/Chatbot.tsx index 295cb9fa..c2dba4ab 100644 --- a/src/dashboardWebView/components/Chatbot/Chatbot.tsx +++ b/src/dashboardWebView/components/Chatbot/Chatbot.tsx @@ -36,7 +36,7 @@ export const Chatbot: React.FunctionComponent = ({ }: React.Props setLocaleReady(true); }); - const initResponse = await fetch(`${aiUrl}/api/ai-init`); + const initResponse = await fetch(`${aiUrl}/ai-init`); if (!initResponse.ok) { return; @@ -70,7 +70,7 @@ export const Chatbot: React.FunctionComponent = ({ }: React.Props return; } - const response = await fetch(`${aiUrl}/api/ai-chat`, { + const response = await fetch(`${aiUrl}/ai-chat`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/dashboardWebView/components/Chatbot/Feedback.tsx b/src/dashboardWebView/components/Chatbot/Feedback.tsx index 535d3ee7..b878cc35 100644 --- a/src/dashboardWebView/components/Chatbot/Feedback.tsx +++ b/src/dashboardWebView/components/Chatbot/Feedback.tsx @@ -28,7 +28,7 @@ export const Feedback: React.FunctionComponent = ({ }, []); const callVote = useCallback(async (vote: boolean) => { - await fetch(`${aiUrl}/api/ai-feedback`, { + await fetch(`${aiUrl}/ai-feedback`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/dashboardWebView/index.tsx b/src/dashboardWebView/index.tsx index 24a93426..2c0fbdc7 100644 --- a/src/dashboardWebView/index.tsx +++ b/src/dashboardWebView/index.tsx @@ -93,7 +93,7 @@ if (elm) { render( diff --git a/src/services/SponsorAI.ts b/src/services/SponsorAI.ts index 1bf7a9b2..10e86214 100644 --- a/src/services/SponsorAI.ts +++ b/src/services/SponsorAI.ts @@ -9,7 +9,6 @@ import { TaxonomyType } from '../models'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; -const AI_URL = WEBSITE_LINKS.api.ai; // const AI_URL = 'http://localhost:3000/api/ai'; export class SponsorAi { @@ -28,7 +27,7 @@ export class SponsorAi { }, 10000); const signal = controller.signal; - const response = await fetch(`${AI_URL}/title`, { + const response = await fetch(`${WEBSITE_LINKS.api.root}/ai/title`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -66,7 +65,7 @@ export class SponsorAi { articleContent = articleContent.substring(0, 2000); } - const response = await fetch(`${AI_URL}/description`, { + const response = await fetch(`${WEBSITE_LINKS.api.root}/ai/description`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -129,7 +128,7 @@ export class SponsorAi { taxonomy: optionsString }); - const response = await fetch(`${AI_URL}/taxonomy`, { + const response = await fetch(`${WEBSITE_LINKS.api.root}/ai/taxonomy`, { method: 'POST', headers: { 'Content-Type': 'application/json', From 1a97a11c1c4ed3823dcfad8cfa760d891c8fe906 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 8 Aug 2024 14:18:38 +0200 Subject: [PATCH 2/2] 10.2.1 --- package-lock.json | 4 +- package.json | 332 ++++++++++++++++++++++++++-------------------- 2 files changed, 187 insertions(+), 149 deletions(-) diff --git a/package-lock.json b/package-lock.json index ccdf1577..390912f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-front-matter-beta", - "version": "10.2.0", + "version": "10.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscode-front-matter-beta", - "version": "10.2.0", + "version": "10.2.1", "license": "MIT", "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6" diff --git a/package.json b/package.json index 0784479f..bfce85f4 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,15 @@ "displayName": "Front Matter CMS", "description": "Front Matter is a CMS that runs within Visual Studio Code. It gives you the power and control of a full-blown CMS while also providing you the flexibility and speed of the static site generator of your choice like: Hugo, Jekyll, Docusaurus, NextJs, Gatsby, and many more...", "icon": "assets/frontmatter-teal-128x128.png", - "version": "10.2.0", + "version": "10.2.1", "preview": false, "publisher": "eliostruyf", "galleryBanner": { "color": "#0e131f", "theme": "dark" }, - "badges": [{ + "badges": [ + { "description": "version", "url": "https://img.shields.io/github/package-json/v/estruyf/vscode-front-matter?color=green&label=vscode-front-matter&style=flat-square", "href": "https://github.com/estruyf/vscode-front-matter" @@ -69,7 +70,8 @@ "**/.frontmatter/config/*.json": "jsonc" } }, - "keybindings": [{ + "keybindings": [ + { "command": "frontMatter.dashboard", "key": "alt+d" }, @@ -93,19 +95,23 @@ } ], "viewsContainers": { - "activitybar": [{ - "id": "frontmatter-explorer", - "title": "FM", - "icon": "$(fm-logo)" - }] + "activitybar": [ + { + "id": "frontmatter-explorer", + "title": "FM", + "icon": "$(fm-logo)" + } + ] }, "views": { - "frontmatter-explorer": [{ - "id": "frontMatter.explorer", - "name": "Front Matter", - "icon": "$(fm-logo)", - "type": "webview" - }] + "frontmatter-explorer": [ + { + "id": "frontMatter.explorer", + "name": "Front Matter", + "icon": "$(fm-logo)", + "type": "webview" + } + ] }, "configuration": { "title": "%settings.configuration.title%", @@ -173,7 +179,8 @@ "frontMatter.content.defaultFileType": { "type": "string", "default": "md", - "oneOf": [{ + "oneOf": [ + { "enum": [ "md", "mdx" @@ -189,7 +196,8 @@ "frontMatter.content.defaultSorting": { "type": "string", "default": "", - "oneOf": [{ + "oneOf": [ + { "enum": [ "LastModifiedAsc", "LastModifiedDesc", @@ -541,7 +549,8 @@ "categories" ], "markdownDescription": "%setting.frontMatter.content.filters.markdownDescription%", - "items": [{ + "items": [ + { "type": "string", "enum": [ "contentFolders", @@ -614,7 +623,8 @@ "command": { "$id": "#scriptCommand", "type": "string", - "anyOf": [{ + "anyOf": [ + { "enum": [ "node", "bash", @@ -810,7 +820,8 @@ "title", "file" ], - "anyOf": [{ + "anyOf": [ + { "required": [ "schema" ] @@ -864,7 +875,8 @@ "id", "path" ], - "anyOf": [{ + "anyOf": [ + { "required": [ "schema" ] @@ -1105,26 +1117,29 @@ } } }, - "default": [{ - "name": "default", - "fileTypes": null, - "fields": [{ - "title": "Title", - "name": "title", - "type": "string" - }, - { - "title": "Caption", - "name": "caption", - "type": "string" - }, - { - "title": "Alt text", - "name": "alt", - "type": "string" - } - ] - }], + "default": [ + { + "name": "default", + "fileTypes": null, + "fields": [ + { + "title": "Title", + "name": "title", + "type": "string" + }, + { + "title": "Caption", + "name": "caption", + "type": "string" + }, + { + "title": "Alt text", + "name": "alt", + "type": "string" + } + ] + } + ], "scope": "Media" }, "frontMatter.media.supportedMimeTypes": { @@ -1360,7 +1375,8 @@ "default": "", "description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.taxonomyId.description%", "not": { - "anyOf": [{ + "anyOf": [ + { "const": "" }, { @@ -1554,7 +1570,8 @@ "type", "name" ], - "allOf": [{ + "allOf": [ + { "if": { "properties": { "type": { @@ -1766,48 +1783,51 @@ "fields" ] }, - "default": [{ - "name": "default", - "pageBundle": false, - "fields": [{ - "title": "Title", - "name": "title", - "type": "string" - }, - { - "title": "Description", - "name": "description", - "type": "string" - }, - { - "title": "Publishing date", - "name": "date", - "type": "datetime", - "default": "{{now}}", - "isPublishDate": true - }, - { - "title": "Content preview", - "name": "preview", - "type": "image" - }, - { - "title": "Is in draft", - "name": "draft", - "type": "boolean" - }, - { - "title": "Tags", - "name": "tags", - "type": "tags" - }, - { - "title": "Categories", - "name": "categories", - "type": "categories" - } - ] - }], + "default": [ + { + "name": "default", + "pageBundle": false, + "fields": [ + { + "title": "Title", + "name": "title", + "type": "string" + }, + { + "title": "Description", + "name": "description", + "type": "string" + }, + { + "title": "Publishing date", + "name": "date", + "type": "datetime", + "default": "{{now}}", + "isPublishDate": true + }, + { + "title": "Content preview", + "name": "preview", + "type": "image" + }, + { + "title": "Is in draft", + "name": "draft", + "type": "boolean" + }, + { + "title": "Tags", + "name": "tags", + "type": "tags" + }, + { + "title": "Categories", + "name": "categories", + "type": "categories" + } + ] + } + ], "scope": "Taxonomy" }, "frontMatter.taxonomy.customTaxonomy": { @@ -1820,7 +1840,8 @@ "type": "string", "description": "%setting.frontMatter.taxonomy.customTaxonomy.items.properties.id.description%", "not": { - "anyOf": [{ + "anyOf": [ + { "const": "" }, { @@ -2015,7 +2036,8 @@ } } }, - "commands": [{ + "commands": [ + { "command": "frontMatter.project.switch", "title": "%command.frontMatter.project.switch%", "category": "Front Matter", @@ -2341,16 +2363,21 @@ } } ], - "submenus": [{ - "id": "frontmatter.submenu", - "label": "Front Matter" - }], + "submenus": [ + { + "id": "frontmatter.submenu", + "label": "Front Matter" + } + ], "menus": { - "webview/context": [{ - "command": "workbench.action.webview.openDeveloperTools", - "when": "frontMatter:isDevelopment" - }], - "editor/title": [{ + "webview/context": [ + { + "command": "workbench.action.webview.openDeveloperTools", + "when": "frontMatter:isDevelopment" + } + ], + "editor/title": [ + { "command": "frontMatter.markup.heading", "group": "navigation@-133", "when": "frontMatter:file:isValid == true && frontMatter:markdown:wysiwyg" @@ -2436,11 +2463,14 @@ "when": "resourceFilename == 'frontmatter.json'" } ], - "explorer/context": [{ - "submenu": "frontmatter.submenu", - "group": "frontmatter@1" - }], - "frontmatter.submenu": [{ + "explorer/context": [ + { + "submenu": "frontmatter.submenu", + "group": "frontmatter@1" + } + ], + "frontmatter.submenu": [ + { "command": "frontMatter.createFromTemplate", "when": "explorerResourceIsFolder", "group": "frontmatter@1" @@ -2456,7 +2486,8 @@ "group": "frontmatter@3" } ], - "commandPalette": [{ + "commandPalette": [ + { "command": "frontMatter.init", "when": "frontMatterCanInit" }, @@ -2633,7 +2664,8 @@ "when": "frontMatter:file:isValid == true" } ], - "view/title": [{ + "view/title": [ + { "command": "frontMatter.chatbot", "group": "navigation@0", "when": "view == frontMatter.explorer" @@ -2665,13 +2697,16 @@ } ] }, - "languages": [{ - "id": "frontmatter.project.output", - "mimetypes": [ - "text/x-code-output" - ] - }], - "grammars": [{ + "languages": [ + { + "id": "frontmatter.project.output", + "mimetypes": [ + "text/x-code-output" + ] + } + ], + "grammars": [ + { "path": "./syntaxes/hugo.tmLanguage.json", "scopeName": "frontmatter.markdown.hugo", "injectTo": [ @@ -2684,45 +2719,48 @@ "path": "./syntaxes/frontmatter-output.tmLanguage.json" } ], - "walkthroughs": [{ - "id": "frontmatter.welcome", - "title": "Get started with Front Matter", - "description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.", - "steps": [{ - "id": "frontmatter.welcome.init", - "title": "Get started", - "description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)", - "media": { - "markdown": "assets/walkthrough/get-started.md" + "walkthroughs": [ + { + "id": "frontmatter.welcome", + "title": "Get started with Front Matter", + "description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.", + "steps": [ + { + "id": "frontmatter.welcome.init", + "title": "Get started", + "description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)", + "media": { + "markdown": "assets/walkthrough/get-started.md" + }, + "completionEvents": [ + "onContext:frontMatterInitialized" + ] }, - "completionEvents": [ - "onContext:frontMatterInitialized" - ] - }, - { - "id": "frontmatter.welcome.documentation", - "title": "Documentation", - "description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)", - "media": { - "markdown": "assets/walkthrough/documentation.md" + { + "id": "frontmatter.welcome.documentation", + "title": "Documentation", + "description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)", + "media": { + "markdown": "assets/walkthrough/documentation.md" + }, + "completionEvents": [ + "onLink:https://frontmatter.codes/docs" + ] }, - "completionEvents": [ - "onLink:https://frontmatter.codes/docs" - ] - }, - { - "id": "frontmatter.welcome.supporter", - "title": "Support the project", - "description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)", - "media": { - "markdown": "assets/walkthrough/support-the-project.md" - }, - "completionEvents": [ - "onLink:https://github.com/sponsors/estruyf" - ] - } - ] - }] + { + "id": "frontmatter.welcome.supporter", + "title": "Support the project", + "description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)", + "media": { + "markdown": "assets/walkthrough/support-the-project.md" + }, + "completionEvents": [ + "onLink:https://github.com/sponsors/estruyf" + ] + } + ] + } + ] }, "scripts": { "dev:ext": "npm run clean && npm run localization:generate && npm-run-all --parallel watch:*", @@ -2850,4 +2888,4 @@ "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6" } -} \ No newline at end of file +}