Skip to content

Single API rewrites for SDK frontend modules #3314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
20 changes: 10 additions & 10 deletions js-wixcode-sdk/wix-window-frontend/guides/App Page Data.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@

# App Page Data

You can use the [`getAppPageData()`](https://dev.wix.com/docs/velo/api-reference/wix-window-frontend/get-app-page-data) method for [custom app pages](https://dev.wix.com/docs/develop-websites/articles/wix-apps/build-a-custom-wix-business-app-page) to retrieve data you can use to customize the page. The data passed to each type of custom app page is different. This article lists the objects passed to each type of custom app page.
You can use the `getAppPageData()` ([SDK](https://dev.wix.com/docs/sdk/frontend-modules/window/get-app-page-data) | [Velo](https://dev.wix.com/docs/velo/apis/wix-window-frontend/get-app-page-data)) method for [custom app pages](https://dev.wix.com/docs/develop-websites/articles/wix-apps/replace-a-wix-business-app-page-with-your-own-custom-version) to retrieve data you can use to customize the page. The data passed to each type of custom app page is different. This article lists the objects passed to each type of custom app page.

## Booking Service Page
## Bookings Service Page

The object passed to a custom Booking Service page contains the following properties:
The object passed to a custom Bookings Service page contains the following properties:

| Name | Type | Description |
| --- | --- | --- |
| `service` | Object | The [Service object](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/service-object), which contains detailed data about the service. |
| `service` | Object | The `service` object which contains detailed data about the service. <br /><br />For a full description of the `service` object, see the object returned in `getService()` ([SDK](https://dev.wix.com/docs/sdk/backend-modules/bookings/services/get-service) | [Velo](https://dev.wix.com/docs/velo/apis/wix-bookings-v2/services/get-service)). |

> **Note**: If the page URL specifies a service that is deleted, hidden, or does not exist, the app returns `null`.

Learn more about [building a custom Service page](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-bookings/build-a-custom-booking-service-page).
Learn more about [building a custom Service page](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/wix-bookings/build-a-custom-booking-service-page).

## Booking Calendar Page
## Bookings Calendar Page

The object passed to a custom Booking Calendar page contains the following properties:
The object passed to a custom Bookings Calendar page contains the following properties:

| Name | Type | Description |
| --- | --- | --- |
| `service` | Object | The [Service object](https://dev.wix.com/docs/rest/business-solutions/bookings/services/services-v2/service-object), which contains detailed data about the service. |
| `service` | Object | The `service` object which contains detailed data about the service. <br /><br />For a full description of the `service` object, see the object returned in `getService()` ([SDK](https://dev.wix.com/docs/sdk/backend-modules/bookings/services/get-service) | [Velo](https://dev.wix.com/docs/velo/apis/wix-bookings-v2/services/get-service)). |

## Pricing Plans Page

The object passed to a custom Pricing Plans page contains the following properties:

| Name | Type | Description |
| --- | --- | --- |
| `plan` | Object | The [Plan object](https://dev.wix.com/docs/rest/business-solutions/pricing-plans/pricing-plans/plans/plan-object), which contains detailed data about the plans. |
| `plan` | Object | The `plan` object which contains detailed data about the plans. <br /><br />For a full description of the `plan` object, see the object returned in `getService()` ([SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/plans/get-plan) | [Velo](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/plans/get-plan)). |

> **Note**: If the page URL specifies a plan that is deleted, hidden, or does not exist, the app returns `null`.

Learn more about [building a custom Pricing Plans page](https://dev.wix.com/docs/develop-websites/articles/wix-apps/other-apps/wix-pricing-plans/tutorial-using-the-pricing-plans-api-for-pricing-plan-ordering-and-payment).
Learn more about [building a custom Pricing Plans page](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/other-apps/wix-pricing-plans/tutorial-using-the-pricing-plans-api-for-pricing-plan-ordering-and-payment).
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# New Members

When a new member registers for an account on your site, they can't immediately login. They must be approved as a member (which can be set to automatic), and you may wish to have them verify their email.
When a new member registers for an account on a site, they can't immediately login. They must be approved as a member (which can be set to automatic), and you may wish to have them verify their email.

You can edit these settings in your site's [dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/signup-login-settings).

## Email verification
You may want to check that a new member is using their own email address, not using someone else's or a fake email address.

To run this check, require members to verify their email address once they've signed up in one of the following ways:
- In your site's [dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/signup-login-settings), under **Ask new members to confirm their email**.
- Using code. [This example](https://www.wix.com/velo/example/members-area) includes email verification through code.
- In a site's [dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/signup-login-settings), under **Ask new members to confirm their email**.
- With code. [This example](https://www.wix.com/velo/example/members-area) includes email verification through code.

## Manual vs automatic approval
The [register function](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/register) behaves differently depending on your [site's member signup settings](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-members/enabling-custom-site-registration).
The `register()` method behaves differently depending on your [site's member signup settings](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-members/enabling-custom-site-registration).

### Manual approval
When manual approval is enabled, everyone who signs up must then be approved. Immediately after signing up, a new member's `status` is `"PENDING"`.

You can approve a new member by:
- Passing the returned `approvalToken` to [`approveByToken()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-token).
- Calling [`approveByEmail()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-email).
To approve a new member:
- Pass the returned `approvalToken` to [`approveByToken()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-token).
- Call [`approveByEmail()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-email).
- Navigating to your [site members list](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/members) in your dashboard and approving the new member there.

### Automatic approval
When automatic approval is enabled, everyone who signs up is approved. Immediately after signing up, a new member's `status` is `"ACTIVE"`.

They can immediately log in to the site, or you can log them in by passing the returned `sessionToken` to [`applySessionToken()`](https://dev.wix.com/docs/velo/api-reference/wix-members-frontend/authentication/apply-session-token) from wix-members-frontend.
They can immediately log in to the site, or you can log them in by passing the returned `sessionToken` to `applySessionToken()` ([SDK](https://dev.wix.com/docs/sdk/frontend-modules/members/authentication/apply-session-token) | [Velo](https://dev.wix.com/docs/velo/apis/wix-members-frontend/authentication/apply-session-token)) from the frontend code.

You can have more control of who can become a site member using [custom site registration](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-members/enabling-custom-site-registration) and Velo code.

If you are implementing code to automatically approve emails in a collection, make sure to set the [collection Permissions to private](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code#wix-app-collection-permissions) and to never expose the collection in your frontend code.
If you are implementing code to automatically approve emails in a collection, make sure to set the [collection permissions to private](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code#wix-app-collection-permissions) and to never expose the collection in your frontend code.
29 changes: 21 additions & 8 deletions wix-members-backend/wix-members-backend/guides/Custom Fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ Member profiles can contain custom data,
located in the member object at `contactDetails.customFields`.
The member object is returned when calling these functions:

- [`currentMember.getMember()`](/current-member/get-member)
- [`members.getMember()`](/members/get-member)
- [`members.updateMember()`](/members/update-member)
- `currentMember.getMember()`
- `members.getMember()`
- `members.updateMember()`

The Members API works with [custom fields](https://support.wix.com/en/article/adding-custom-fields-to-contacts) that are
[added to the member profile in the Dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmembers-account).
Custom fields that haven't been added to the member profile
aren't available through the Members API.
When retrieving members, empty fields are not returned.
You can query, create, rename, and delete custom field definitions with the Contacts
[Extended Fields API](/contacts/about-extended-fields).
You can query, create, rename, and delete custom field definitions with the
Extended Fields API ([SDK](https://dev.wix.com/docs/sdk/backend-modules/crm/extended-fields/introduction) | [Velo](https://dev.wix.com/docs/velo/apis/wix-crm-v2/extended-fields/introduction)).

## Data structure

The member's `customFields` object contains key:object pairs.
The key is defined in the Contacts Extended Fields API.
The key is defined in the Extended Fields API ([SDK](https://dev.wix.com/docs/sdk/backend-modules/crm/extended-fields/introduction) | [Velo](https://dev.wix.com/docs/velo/apis/wix-crm-v2/extended-fields/introduction)).
The paired object is structured as follows:

```js
Expand All @@ -45,8 +45,21 @@ The paired object contains these properties:

## Retrieve custom field IDs

For a list of your site's custom field IDs, use this function in your backend code:
For a list of your site's custom field IDs, use this function in your backend code.
**SDK:**
```js
import { extendedFields } from "@wix/crm";

export async function listCustomFieldKeys() {
const queryResults = await queryExtendedFields().find();
// Filters for custom fields (where fieldType is USER_DEFINED), then converts to an array of keys
return queryResults.items
.filter((field) => field.fieldType === "USER_DEFINED")
.map((field) => field.key);
}
```

**Velo:**
```js
import { contacts } from "wix-crm-backend";

Expand All @@ -62,7 +75,7 @@ export async function listCustomFieldKeys() {
## Set a custom field for a new site member

You can set the value of a custom field for a new site member in the `contactInfo` object
using the [`authentication.register()`](/authentication/register) function.
using the `authentication.register()` function.
Use a key:value pair in the top level of the `contactInfo` object, like this:

```js
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# New Members

When a new member registers for an account on your site, they can't immediately login. They must be approved as a member (which can be set to automatic), and you may wish to have them verify their email.
When a new member registers for an account on a site, they can't immediately login. They must be approved as a member (which can be set to automatic), and you may wish to have them verify their email.

You can edit these settings in your site's [dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/signup-login-settings).

## Email verification
You may want to check that a new member is using their own email address, not using someone else's or a fake email address.

To run this check, require members to verify their email address once they've signed up in one of the following ways:
- In your site's [dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/signup-login-settings), under **Ask new members to confirm their email**.
- Using code. [This example](https://www.wix.com/velo/example/members-area) includes email verification through code.
- In a site's [dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/signup-login-settings), under **Ask new members to confirm their email**.
- With code. [This example](https://www.wix.com/velo/example/members-area) includes email verification through code.


## Manual vs automatic approval
The [register function](https://dev.wix.com/docs/velo/api-reference/wix-members-frontend/authentication/register) behaves differently depending on your [site's member signup settings](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-members/enabling-custom-site-registration).
The `register()` method behaves differently depending on your [site's member signup settings](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-members/enabling-custom-site-registration).

### Manual approval
When manual approval is enabled, everyone who signs up must then be approved. Immediately after signing up, a new member's `status` is `"PENDING"`.

You can approve a new member by:
- Passing the returned `approvalToken` to [`approveByToken()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-token) from wix-members-backend.
- Calling [`approveByEmail()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-email) from wix-members-backend.
To approve a new member:
- Pass the returned `approvalToken` to [`approveByToken()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-token) from wix-members-backend.
- Call [`approveByEmail()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-email) from `wix-members-backend`.
- Navigating to your [site members list](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmember-permissions/members) in your dashboard and approving the new member there.

>**Note:** If you need the `member` object, use [`register()`](https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/register) from wix-members-backend.
>**Note:** If you need the `member` object, use `register()`.

### Automatic approval
When automatic approval is enabled, everyone who signs up is approved. Immediately after signing up, a new member's `status` is `"ACTIVE"`.

The member is immediately logged in to the site.
The member is immediately logged in to the site.
31 changes: 22 additions & 9 deletions wix-members-frontend/wix-members-frontend/guides/Custom Fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ Member profiles can contain custom data,
located in the member object at `contactDetails.customFields`.
The member object is returned when calling these functions:

- [`currentMember.getMember()`](https://dev.wix.com/docs/sdk/frontend-modules/members/current-member/get-member)
- [`members.getMember()`](/members/get-member)
- [`members.updateMember()`](/members/update-member)
- `currentMember.getMember()`
- `members.getMember()`
- `members.updateMember()`

The Members API works with [custom fields](https://support.wix.com/en/article/adding-custom-fields-to-contacts) that are
[added to the member profile in the Dashboard](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmembers-account).
Custom fields that haven't been added to the member profile
aren't available through the Members API.
When retrieving members, empty fields are not returned.
You can query, create, rename, and delete custom field definitions with the Contacts
[Extended Fields API](https://dev.wix.com/docs/sdk/backend-modules/crm/extended-fields/introduction).
You can query, create, rename, and delete custom field definitions with the
Extended Fields API ([SDK](https://dev.wix.com/docs/sdk/backend-modules/crm/extended-fields/introduction) | [Velo](https://dev.wix.com/docs/velo/apis/wix-crm-v2/extended-fields/introduction)).

## Data structure

The member's `customFields` object contains key:object pairs.
The key is defined in the Contacts Extended Fields API.
The key is defined in the Extended Fields API ([SDK](https://dev.wix.com/docs/sdk/backend-modules/crm/extended-fields/introduction) | [Velo](https://dev.wix.com/docs/velo/apis/wix-crm-v2/extended-fields/introduction)).
The paired object is structured as follows:

```js
Expand All @@ -45,8 +45,21 @@ The paired object contains these properties:

## Retrieve custom field IDs

For a list of your site's custom field IDs, use this function in your backend code:
For a list of your site's custom field IDs, use this function in your backend code.
**SDK:**
```js
import { extendedFields } from "@wix/crm";

export async function listCustomFieldKeys() {
const queryResults = await queryExtendedFields().find();
// Filters for custom fields (where fieldType is USER_DEFINED), then converts to an array of keys
return queryResults.items
.filter((field) => field.fieldType === "USER_DEFINED")
.map((field) => field.key);
}
```

**Velo:**
```js
import { contacts } from "wix-crm-backend";

Expand All @@ -61,8 +74,8 @@ export async function listCustomFieldKeys() {

## Set a custom field for a new site member

You can set the value of a custom field for a new site member in the `contactInfo`
object using the [`authentication.register()`](/authentication/register) function.
You can set the value of a custom field for a new site member in the `contactInfo` object
using the `authentication.register()` function.
Use a key:value pair in the top level of the `contactInfo` object, like this:

```js
Expand Down