Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/wwPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
136 changes: 136 additions & 0 deletions ww-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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: {
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: false,
},
},
},
/* wwEditor:end */
},
{
Expand All @@ -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. The object cannot be bind, you have to bind individual sub keys. eg. {email: {__wwType: "...", code: "..."}, password {__wwType: "...", code: "..."}}',
bindable: false,
},
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: false,
},
},
},
/* wwEditor:end */
},
{
Expand All @@ -89,6 +151,41 @@ 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. For twitter-oauth, use "access_token", for the rest, use "continue"',
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: false,
},
},
},
/* wwEditor:end */
},
{
Expand All @@ -97,18 +194,57 @@ 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: false,
},
},
},
/* wwEditor:end */
},
{
name: 'Store Auth Token',
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 */
},
],
};