Skip to content
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

244 jobstatus #353

Merged
merged 10 commits into from
May 31, 2023
Merged
54 changes: 31 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,31 @@ OPTIONS
this command invocation

DESCRIPTION
See 'Which Experience Cloud Template Should I Use?' in Salesforce Help for more information about the different
template types available for Experience Cloud.
Run the "community list template" command to see the templates available in your org. See 'Which Experience Cloud
Template Should I Use?' in Salesforce Help for more information about the different template types available.

When you create a site with the Build Your Own (LWR) template, you must also specify the AuthenticationType value
using the format templateParams.AuthenticationType=value, where value is AUTHENTICATED or
AUTHENTICATED_WITH_PUBLIC_ACCESS_ENABLED. Name and values are case-sensitive. See 'DigitalExperienceBundle' in the
Metadata API Developer Guide for more information.

The site creation process is an async job that generates a jobId. To check the site creation status, query the
BackgroundOperation object and enter the jobId as the Id. See ‘BackgroundOperation’ in the Object Reference for the
Salesforce Platform for more information.

When creating a site with the Build Your Own (LWR) template, you must also specify the AuthenticationType value using
the format templateParams.AuthenticationType=value, where value is AUTHENTICATED, UNAUTHENTICATED, or
AUTHENTICATED_WITH_PUBLIC_ACCESS. Name and values are case-sensitive. See 'ExperienceBundle' in the Metadata API
Developer Guide for more information.
If the job doesn’t complete within 10 minutes, it times out. You receive an error message and must restart the site
creation process. Completed jobs expire after 24 hours and are removed from the database.

When you execute this command, it creates the site in preview status, which means that it isn't yet live. After you
When you run this command, it creates the site in preview status, which means that the site isn't yet live. After you
finish building your site, you can make it live.

If you have an Experience Builder site, publish the site using the sfdx force:community:publish command to make it
live.
If you have an Experience Builder site, publish the site using the "community publish" command to make it live.

If you have a Salesforce Tabs + Visualforce site, activate the site to make it live by updating the status field of
the Network type in the Metadata API. Alternatively, in Experience Workspaces, go to Administration | Settings, and
click Activate.
If you have a Salesforce Tabs + Visualforce site, to activate the site and make it live, update the status field of
the Network type in Metadata API. Alternatively, in Experience Workspaces, go to Administration | Settings, and click
Activate.

For Experience Builder sites, activating the site just sends out a welcome email to site members.
For Experience Builder sites, activating the site sends a welcome email to site members.

EXAMPLES
$ sfdx force:community:create --name 'My Customer Site' --templatename 'Customer Service' --urlpathprefix customers
Expand Down Expand Up @@ -165,19 +171,21 @@ OPTIONS
this command invocation

DESCRIPTION
Each time you publish it, you update the live site with the most recent updates.
When you publish an Experience Builder site for the first time, you make the site's URL live and enable login access
for site members.
Each time you publish a site, you update the live site with the most recent updates. When you publish an Experience
Builder site for the first time, you make the site's URL live and enable login access for site members.

Additionally, to send a welcome email to all site members, you must activate the site. (Activation is also required to
successfully set up SEO for Experience Builder sites.) To activate a site, update the status field of the Network
type in the Metadata API. Alternatively, in Experience Workspaces, go to Administration | Settings, and click
Activate.
In addition to publishing, you must activate a site to send a welcome email to all site members. Activation is also
required to set up SEO for Experience Builder sites. To activate a site, update the status field of the Network type
in Metadata API. Alternatively, in Experience Workspaces, go to Administration | Settings, and click Activate.

An email notification informs you when your changes are live on the published site. The site publish process is an
async job that generates a jobId. To check the site publish status manually, query the BackgroundOperation object and
enter the jobId as the Id. See ‘BackgroundOperation’ in the Object Reference for the Salesforce Platform for more
information.

Subsequently, each time you publish the site, you update the live site with all changes made to the site since it was
last published.
If the job doesn’t complete within 15 minutes, it times out. You receive an error message and must restart the site
publish process. Completed jobs expire after 24 hours and are removed from the database.

An email notification informs you when your changes are live.

EXAMPLE
$ sfdx force:community:publish --name 'My Customer Site'
Expand Down
18 changes: 10 additions & 8 deletions messages/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ Create an Experience Cloud site using a template.

# description

See 'Which Experience Cloud Template Should I Use?' (https://help.salesforce.com/s/articleView?id=sf.siteforce_commtemp_intro.htm&type=5) in Salesforce Help for more information about the different template
types available for Experience Cloud.
Run the "community list template" command to see the templates available in your org. See 'Which Experience Cloud Template Should I Use?' in Salesforce Help for more information about the different template types available. (https://help.salesforce.com/s/articleView?id=sf.siteforce_commtemp_intro.htm&type=5)

When creating a site with the Build Your Own (LWR) template, you must also specify the AuthenticationType value using the format templateParams.AuthenticationType=value, where value is AUTHENTICATED, UNAUTHENTICATED, or AUTHENTICATED_WITH_PUBLIC_ACCESS. Name and values are case-sensitive. See 'ExperienceBundle' in the Metadata API Developer Guide for more information. (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_experiencebundle.htm)
When you create a site with the Build Your Own (LWR) template, you must also specify the AuthenticationType value using the format templateParams.AuthenticationType=value, where value is AUTHENTICATED or AUTHENTICATED_WITH_PUBLIC_ACCESS_ENABLED. Name and values are case-sensitive. See 'DigitalExperienceBundle' in the Metadata API Developer Guide for more information. (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_digitalexperiencebundle.htm)

When you execute this command, it creates the site in preview status, which means that it isn't yet live. After you finish building your site, you can make it live.
The site creation process is an async job that generates a jobId. To check the site creation status, query the BackgroundOperation object and enter the jobId as the Id. See ‘BackgroundOperation’ in the Object Reference for the Salesforce Platform for more information. (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_backgroundoperation.htm)

If the job doesn’t complete within 10 minutes, it times out. You receive an error message and must restart the site creation process. Completed jobs expire after 24 hours and are removed from the database.

When you run this command, it creates the site in preview status, which means that the site isn't yet live. After you finish building your site, you can make it live.

If you have an Experience Builder site, publish the site using the "community publish" command to make it live.

If you have a Salesforce Tabs + Visualforce site, activate the site to make it live by updating the status field of the Network type in the Metadata API. Alternatively, in Experience Workspaces, go to Administration | Settings, and click Activate.
If you have a Salesforce Tabs + Visualforce site, to activate the site and make it live, update the status field of the Network type in Metadata API. (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_network.htm) Alternatively, in Experience Workspaces, go to Administration | Settings, and click Activate.

For Experience Builder sites, activating the site just sends out a welcome email to site members.
For Experience Builder sites, activating the site sends a welcome email to site members.

# examples

Expand Down Expand Up @@ -61,8 +64,7 @@ The description displays in Digital Experiences - All Sites in Setup and helps w

# response.action

We’re creating your site. Run sfdx force:org:open -p \_ui/networks/setup/SetupNetworksPage to view a list of your sites,
and to confirm when this site is ready.
Site creation is under way. To track its status, query the BackgroundOperation object and include the jobId.

# response.styleHeader

Expand Down
8 changes: 4 additions & 4 deletions messages/publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Publish an Experience Builder site to make it live.

# description

Each time you publish it, you update the live site with the most recent updates. When you publish an Experience Builder site for the first time, you make the site's URL live and enable login access for site members.
Each time you publish a site, you update the live site with the most recent updates. When you publish an Experience Builder site for the first time, you make the site's URL live and enable login access for site members.

Additionally, to send a welcome email to all site members, you must activate the site. (Activation is also required to successfully set up SEO for Experience Builder sites.) To activate a site, update the status field of the Network type in the Metadata API. Alternatively, in Experience Workspaces, go to Administration | Settings, and click Activate.
In addition to publishing, you must activate a site to send a welcome email to all site members. Activation is also required to set up SEO for Experience Builder sites. To activate a site, update the status field of the Network type in Metadata API. (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_network.htm)Alternatively, in Experience Workspaces, go to Administration | Settings, and click Activate.

Subsequently, each time you publish the site, you update the live site with all changes made to the site since it was last published.
An email notification informs you when your changes are live on the published site. The site publish process is an async job that generates a jobId. To check the site publish status manually, query the BackgroundOperation object and enter the jobId as the Id. See ‘BackgroundOperation’ in the Object Reference for the Salesforce Platform for more information. (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_backgroundoperation.htm)

An email notification informs you when your changes are live.
If the job doesn’t complete within 15 minutes, it times out. You receive an error message and must restart the site publish process. Completed jobs expire after 24 hours and are removed from the database.

# examples

Expand Down
4 changes: 4 additions & 0 deletions schemas/community-create.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"type": "string",
"description": "name of the community"
},
"jobId": {
"type": "string",
"description": "id of the BackgroundOperation that runs the create job"
},
"action": {
"type": "string",
"description": "the next actions that user can do to check, if community is created or not."
Expand Down
4 changes: 4 additions & 0 deletions schemas/community-publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"url": {
"type": "string",
"description": "url to access the community"
},
"jobId": {
"type": "string",
"description": "id of the BackgroundOperation that runs the publish job"
}
},
"required": ["id", "message", "name", "url"],
Expand Down
2 changes: 2 additions & 0 deletions src/commands/community/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-community', 'create')

const MESSAGE_KEY = 'message';
const NAME_KEY = 'name';
const JOBID_KEY = 'jobId';
const ACTION_KEY = 'action';

/**
Expand Down Expand Up @@ -94,6 +95,7 @@ export class CommunityCreateCommand extends SfCommand<CommunityCreateResponse> {
const columns = {
[NAME_KEY]: { header: 'Name' },
[MESSAGE_KEY]: { header: 'Message' },
[JOBID_KEY]: { header: 'JobId' },
[ACTION_KEY]: { header: 'Action' },
};
this.styledHeader(messages.getMessage('response.styleHeader'));
Expand Down
1 change: 1 addition & 0 deletions src/commands/community/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class CommunityPublishCommand extends SfCommand<CommunityPublishResponse>
name: { header: 'Name' },
status: { header: 'Status' },
url: { header: 'Url' },
jobId: { header: 'JobId' },
};
this.styledHeader(messages.getMessage('response.styleHeader'));
this.table([results], columns);
Expand Down
8 changes: 6 additions & 2 deletions src/shared/community/connect/CommunityCreateResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { ConnectResource } from '../../connect/services/ConnectResource';
Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-community', 'create');

const NAME_KEY = 'name';
const JOBID_KEY = 'jobId';

/**
* A connect api resource for creating a community
*/
Expand All @@ -22,10 +25,11 @@ export class CommunityCreateResource implements ConnectResource<CommunityCreateR
public constructor(private options: CommunityCreateParams) {}

// eslint-disable-next-line class-methods-use-this
public handleSuccess(result: JsonCollection & { name: string }): CommunityCreateResponse {
public handleSuccess(result: JsonCollection & { [NAME_KEY]: string; [JOBID_KEY]: string }): CommunityCreateResponse {
const response: CommunityCreateResponse = {
message: messages.getMessage('response.createMessage'),
name: result.name,
name: result[NAME_KEY],
jobId: result[JOBID_KEY],
action: messages.getMessage('response.action'),
};
return response;
Expand Down
5 changes: 4 additions & 1 deletion src/shared/community/connect/CommunityPublishResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ export class CommunityPublishResource implements ConnectResource<CommunityPublis
return Promise.resolve(JSON.stringify({}));
}

public handleSuccess(result: JsonCollection & { id: string; name: string; url: string }): CommunityPublishResponse {
public handleSuccess(
result: JsonCollection & { id: string; name: string; url: string; jobId: string }
): CommunityPublishResponse {
return {
id: result.id,
message: messages.getMessage('response.message'),
name: result.name,
status: this.info?.status,
url: new URL(result.url).toString(),
jobId: result.jobId,
};
}

Expand Down
5 changes: 5 additions & 0 deletions src/shared/community/defs/CommunityCreateResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export type CommunityCreateResponse = {
*/
name: string;

/**
* id of the BackgroundOperation that runs the create job
*/
jobId?: string;

/**
* the next actions that user can do to check, if community is created or not.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/shared/community/defs/CommunityPublishResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ export type CommunityPublishResponse = {
* url to access the community
*/
url: string;

/**
* id of the BackgroundOperation that runs the publish job
*/
jobId?: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('CommunityCreateResource', () => {
const urlPathPrefix = 'urlPathPrefix';
const templateName = 'templateName';
const description = 'description';
const jobId = '000xx0000000000000';
let table: sinon.SinonStub;
let styledHeader: sinon.SinonStub;

Expand Down Expand Up @@ -69,13 +70,14 @@ describe('CommunityCreateResource', () => {
describe('handleSuccess', () => {
it('should return community info', () => {
const connectResponse = {
message: 'message',
name: communityName,
jobId,
};

const result: CommunityCreateResponse = communityCreateResource.handleSuccess(connectResponse);
expect(result.message).to.equal(messages.getMessage('response.createMessage'));
expect(result.name).to.equal(communityName);
expect(result.jobId).to.equal(jobId);
expect(result.action).to.equal(messages.getMessage('response.action'));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('CommunityPublishResource', () => {
let org: Org;
let communityPublishResource: CommunityPublishResource;
const communityName = 'communityName';
const jobId = '000xx0000000000000';
const validCommunityId = '0DB0000000000';
let table: sinon.SinonStub;
let styledHeader: sinon.SinonStub;
Expand Down Expand Up @@ -104,6 +105,7 @@ describe('CommunityPublishResource', () => {
message: 'message',
name: communityName,
url: 'http://someurl.com/s',
jobId,
};
// This sets up CommunityInfo
await communityPublishResource.fetchCommunityId();
Expand All @@ -115,6 +117,7 @@ describe('CommunityPublishResource', () => {
expect(result.name).to.equal(communityName);
expect(result.status).to.equal('UnderConstruction');
expect(result.url.toString()).to.equal('http://someurl.com/s');
expect(result.jobId).to.equal(jobId);
});
});

Expand Down