From a159ed96318a8ec52c8362bbc9ca1a4baebdc5cb Mon Sep 17 00:00:00 2001 From: Alexis JC Date: Wed, 19 Feb 2025 14:12:44 +0100 Subject: [PATCH 1/4] feat: add ai description --- ww-config.js | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/ww-config.js b/ww-config.js index 4e4cd06..17accae 100644 --- a/ww-config.js +++ b/ww-config.js @@ -67,6 +67,37 @@ export default { getIsValid({ parameters, body }) { return !parameters || body; }, + copilot: { + description: + 'Register a new user in Xano. On success, automatically stores the auth token and fetches the user profile.', + returns: 'object - The newly created user profile data', + schema: { + body: { + type: 'object', + description: + 'Request body containing user registration data. Must match your Xano API endpoint schema.', + bindable: true, + }, + parameters: { + type: 'object', + description: + 'Add query parameters to URL. Example: {"userId": "123", "filter": "active"}. The values are bindable, but not the whole object.', + bindable: false, + }, + headers: { + type: 'Array<{key: string, value: string}', + description: + 'Custom headers as key-value pairs, e.g., [{"Content-Type": "application/json"}]. Automatically includes Xano authentication token if available. key and value are bindable individually.', + bindable: true, + }, + withCredentials: { + type: 'boolean', + description: + 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', + bindable: true, + }, + }, + }, /* wwEditor:end */ }, { @@ -78,6 +109,37 @@ export default { getIsValid({ parameters, body }) { return !parameters || body; }, + copilot: { + description: + 'Authenticate a user with Xano. On success, automatically stores the auth token and fetches the user profile.', + returns: 'object - The authenticated user profile data', + schema: { + body: { + type: 'object', + description: + 'Request body containing login credentials. Must match your Xano API endpoint schema.', + bindable: true, + }, + parameters: { + type: 'object', + description: + 'Add query parameters to URL. Example: {"userId": "123", "filter": "active"}. The values are bindable, but not the whole object.', + bindable: false, + }, + headers: { + type: 'Array<{key: string, value: string}', + description: + 'Custom headers as key-value pairs, e.g., [{"Content-Type": "application/json"}]. Automatically includes Xano authentication token if available. key and value are bindable individually.', + bindable: true, + }, + withCredentials: { + type: 'boolean', + description: + 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', + bindable: true, + }, + }, + }, /* wwEditor:end */ }, { @@ -89,6 +151,40 @@ export default { getIsValid({ provider, type }) { return !!provider && !!type; }, + copilot: { + description: + "Initiate OAuth social login with a specified provider (e.g., Google, Facebook). Opens the provider's authentication window.", + returns: "void - Redirects to the provider's auth page", + schema: { + provider: { + type: 'string', + description: 'The name of the social provider as configured in your Xano settings', + bindable: true, + }, + type: { + type: 'string', + description: 'The type of OAuth flow to use', + bindable: true, + }, + redirectPage: { + type: 'string', + description: 'The page path to redirect to after successful authentication', + bindable: true, + }, + headers: { + type: 'Array<{key: string, value: string}', + description: + 'Custom headers as key-value pairs, e.g., [{"Content-Type": "application/json"}]. Automatically includes Xano authentication token if available. key and value are bindable individually.', + bindable: true, + }, + withCredentials: { + type: 'boolean', + description: + 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', + bindable: true, + }, + }, + }, /* wwEditor:end */ }, { @@ -97,6 +193,25 @@ export default { isAsync: true, /* wwEditor:start */ edit: () => import('./src/components/Functions/FetchUser.vue'), + copilot: { + description: + "Fetch the current authenticated user's profile from Xano. Updates the internal user state and isAuthenticated flag.", + returns: "object - The current user's profile data", + schema: { + headers: { + type: 'Array<{key: string, value: string}', + description: + 'Custom headers as key-value pairs, e.g., [{"Content-Type": "application/json"}]. Automatically includes Xano authentication token if available. key and value are bindable individually.', + bindable: true, + }, + withCredentials: { + type: 'boolean', + description: + 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', + bindable: true, + }, + }, + }, /* wwEditor:end */ }, { @@ -104,11 +219,31 @@ export default { code: 'storeAuthToken', /* wwEditor:start */ edit: () => import('./src/components/Functions/StoreAuthToken.vue'), + copilot: { + description: + 'Manually store a Xano authentication token. Updates the cookie, internal state, and configures the Xano client with the token.', + returns: 'void', + schema: { + authToken: { + type: 'string', + description: 'The authentication token to store', + bindable: true, + }, + }, + }, /* wwEditor:end */ }, { name: 'Logout', code: 'logout', + /* wwEditor:start */ + copilot: { + description: + 'Log out the current user. Clears the auth token, user data, and resets the authentication state.', + returns: 'void', + schema: {}, + }, + /* wwEditor:end */ }, ], }; From 298a834f30613b217480c0f718195c6be7d621dd Mon Sep 17 00:00:00 2001 From: Alexis JC Date: Wed, 19 Feb 2025 14:24:54 +0100 Subject: [PATCH 2/4] fix: add copilot context --- src/wwPlugin.js | 8 ++++++++ ww-config.js | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/wwPlugin.js b/src/wwPlugin.js index 38f5c04..0f6fd79 100644 --- a/src/wwPlugin.js +++ b/src/wwPlugin.js @@ -46,6 +46,14 @@ export default { Editor API \================================================================================================*/ /* wwEditor:start */ + _getCopilotContext() { + return { + loginEndpoint: this.settings.publicData.loginEndpoint, + signupEndpoint: this.settings.publicData.signupEndpoint, + getMeEndpoint: this.settings.publicData.getMeEndpoint, + socialProviders: this.settings.publicData.socialProviders, + }; + }, async initManager(settings) { this.xanoManager = this.createManager(settings); try { diff --git a/ww-config.js b/ww-config.js index 17accae..ec5c1e9 100644 --- a/ww-config.js +++ b/ww-config.js @@ -75,8 +75,8 @@ export default { body: { type: 'object', description: - 'Request body containing user registration data. Must match your Xano API endpoint schema.', - bindable: true, + 'Request body containing user registration data. Must match your Xano API endpoint schema. The key values are bindable, but not the whole object.', + bindable: false, }, parameters: { type: 'object', @@ -94,7 +94,7 @@ export default { type: 'boolean', description: 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', - bindable: true, + bindable: false, }, }, }, @@ -117,8 +117,8 @@ export default { body: { type: 'object', description: - 'Request body containing login credentials. Must match your Xano API endpoint schema.', - bindable: true, + 'Request body containing login credentials. Must match your Xano API endpoint schema. The key values are bindable, but not the whole object.', + bindable: false, }, parameters: { type: 'object', @@ -136,7 +136,7 @@ export default { type: 'boolean', description: 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', - bindable: true, + bindable: false, }, }, }, @@ -163,7 +163,8 @@ export default { }, type: { type: 'string', - description: 'The type of OAuth flow to use', + description: + 'The type of OAuth flow to use. For twitter-oauth, use "access_token", for the rest, use "continue"', bindable: true, }, redirectPage: { @@ -181,7 +182,7 @@ export default { type: 'boolean', description: 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', - bindable: true, + bindable: false, }, }, }, @@ -208,7 +209,7 @@ export default { type: 'boolean', description: 'Whether to include credentials (cookies) with the request. Falls back to plugin settings if not specified.', - bindable: true, + bindable: false, }, }, }, From b1fa86d279e66732dc5ca59493f67fb3bf382482 Mon Sep 17 00:00:00 2001 From: Alexis JC Date: Wed, 19 Feb 2025 14:39:08 +0100 Subject: [PATCH 3/4] fix: binding spec --- ww-config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ww-config.js b/ww-config.js index ec5c1e9..1b4cfff 100644 --- a/ww-config.js +++ b/ww-config.js @@ -75,7 +75,7 @@ export default { body: { type: 'object', description: - 'Request body containing user registration data. Must match your Xano API endpoint schema. The key values are bindable, but not the whole object.', + 'Request body containing user registration data. Must match your Xano API endpoint schema. The key values are bindable, but not the whole object. The object cannot be bind, you have to bind individual sub keys. eg. {email: , password: }', bindable: false, }, parameters: { @@ -117,7 +117,7 @@ export default { body: { type: 'object', description: - 'Request body containing login credentials. Must match your Xano API endpoint schema. The key values are bindable, but not the whole object.', + 'Request body containing login credentials. Must match your Xano API endpoint schema. The object cannot be bind, you have to bind individual sub keys. eg. {email: , password: }', bindable: false, }, parameters: { From 9845795ce2ab68135ff3b4b980829790b15ce78f Mon Sep 17 00:00:00 2001 From: Alexis JC Date: Wed, 19 Feb 2025 15:07:53 +0100 Subject: [PATCH 4/4] fix: formula exemple --- ww-config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ww-config.js b/ww-config.js index 1b4cfff..23b2a8a 100644 --- a/ww-config.js +++ b/ww-config.js @@ -75,7 +75,7 @@ export default { body: { type: 'object', description: - 'Request body containing user registration data. Must match your Xano API endpoint schema. The key values are bindable, but not the whole object. The object cannot be bind, you have to bind individual sub keys. eg. {email: , password: }', + 'Request body containing user registration data. Must match your Xano API endpoint schema. The key values are bindable, but not the whole object. The object cannot be bind, you have to bind individual sub keys. eg. {email: {__wwType: "...", code: "..."}, password {__wwType: "...", code: "..."}}', bindable: false, }, parameters: { @@ -117,7 +117,7 @@ export default { body: { type: 'object', description: - 'Request body containing login credentials. Must match your Xano API endpoint schema. The object cannot be bind, you have to bind individual sub keys. eg. {email: , password: }', + 'Request body containing login credentials. Must match your Xano API endpoint schema. The object cannot be bind, you have to bind individual sub keys. eg. {email: {__wwType: "...", code: "..."}, password {__wwType: "...", code: "..."}}', bindable: false, }, parameters: {