@simplysf/simply-community-core 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/checkPublishStatus.d.ts +3 -1
- package/lib/checkPublishStatus.js +13 -2
- package/lib/checkPublishStatus.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/publishCommunity.d.ts +8 -1
- package/lib/publishCommunity.js +9 -2
- package/lib/publishCommunity.js.map +1 -1
- package/lib/requestTimeout.d.ts +7 -0
- package/lib/requestTimeout.js +23 -0
- package/lib/requestTimeout.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Duration } from '@salesforce/kit';
|
|
1
2
|
import { type Connection, type StatusResult } from '@salesforce/core';
|
|
2
3
|
/**
|
|
3
4
|
* Builds a `PollingClient`-compatible `poll()` function for a community publish job.
|
|
@@ -9,7 +10,8 @@ import { type Connection, type StatusResult } from '@salesforce/core';
|
|
|
9
10
|
*
|
|
10
11
|
* @param connection - The org connection to poll against.
|
|
11
12
|
* @param jobId - The `jobId` returned by `POST /connect/communities/{id}/publish`.
|
|
13
|
+
* @param requestTimeout - Bounds each status-check attempt. Defaults to `DEFAULT_PUBLISH_REQUEST_TIMEOUT`; overridable mainly so tests don't have to wait out the real default.
|
|
12
14
|
* @returns A `poll()` function for `PollingClient.create({ poll, ... })`.
|
|
13
15
|
* @throws {SfError} `CommunityPublishFailedError` if the job reaches a terminal failure state.
|
|
14
16
|
*/
|
|
15
|
-
export declare function checkPublishStatus(connection: Connection, jobId: string): () => Promise<StatusResult>;
|
|
17
|
+
export declare function checkPublishStatus(connection: Connection, jobId: string, requestTimeout?: Duration): () => Promise<StatusResult>;
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { SfError } from '@salesforce/core';
|
|
17
|
+
import { retryWithBackoff } from '@simplysf/simply-core';
|
|
18
|
+
import { DEFAULT_PUBLISH_REQUEST_TIMEOUT } from './requestTimeout.js';
|
|
17
19
|
/**
|
|
18
20
|
* Builds a `PollingClient`-compatible `poll()` function for a community publish job.
|
|
19
21
|
*
|
|
@@ -24,12 +26,21 @@ import { SfError } from '@salesforce/core';
|
|
|
24
26
|
*
|
|
25
27
|
* @param connection - The org connection to poll against.
|
|
26
28
|
* @param jobId - The `jobId` returned by `POST /connect/communities/{id}/publish`.
|
|
29
|
+
* @param requestTimeout - Bounds each status-check attempt. Defaults to `DEFAULT_PUBLISH_REQUEST_TIMEOUT`; overridable mainly so tests don't have to wait out the real default.
|
|
27
30
|
* @returns A `poll()` function for `PollingClient.create({ poll, ... })`.
|
|
28
31
|
* @throws {SfError} `CommunityPublishFailedError` if the job reaches a terminal failure state.
|
|
29
32
|
*/
|
|
30
|
-
export function checkPublishStatus(connection, jobId) {
|
|
33
|
+
export function checkPublishStatus(connection, jobId, requestTimeout = DEFAULT_PUBLISH_REQUEST_TIMEOUT) {
|
|
31
34
|
return async () => {
|
|
32
|
-
|
|
35
|
+
let result;
|
|
36
|
+
try {
|
|
37
|
+
result = await retryWithBackoff(() => Promise.resolve(connection.query(`SELECT Id, Status, FinishedAt, Error FROM BackgroundOperation WHERE Id = '${jobId}'`)), { retryAttempts: 0, backoffFactor: 1, attemptTimeout: requestTimeout });
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// A stalled or failed status check isn't a publish failure — treat it the same as "not
|
|
41
|
+
// finished yet" below and let PollingClient's own timeout/frequency decide when to give up.
|
|
42
|
+
return { completed: false };
|
|
43
|
+
}
|
|
33
44
|
const operation = result.records[0];
|
|
34
45
|
// The BackgroundOperation record may not be queryable in the instant right after the publish
|
|
35
46
|
// request is submitted — treat "not found yet" the same as "still running", not as a failure.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkPublishStatus.js","sourceRoot":"","sources":["../src/checkPublishStatus.ts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AO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { checkPublishStatus } from './checkPublishStatus.js';
|
|
2
2
|
export { deployChangedFiles, type DeployChangedFilesOptions, type DeployComponentFailure, type DeployChangedFilesResult, } from './deployChangedFiles.js';
|
|
3
|
-
export { publishCommunity, type PublishCommunityOptions } from './publishCommunity.js';
|
|
3
|
+
export { publishCommunity, DEFAULT_PUBLISH_REQUEST_TIMEOUT, type PublishCommunityOptions } from './publishCommunity.js';
|
|
4
4
|
export { resolveSearchRoots, resolveRetrieveDestination, resolveSiteFile, resolveNetworkFile, } from './resolveSiteFiles.js';
|
|
5
5
|
export { retrieveCustomSite } from './retrieveCustomSite.js';
|
|
6
6
|
export { patchCustomSiteXml, type PatchCustomSiteXmlOptions, type PatchCustomSiteXmlResult, patchNetworkXml, readNetworkSiteName, } from './siteMetadataXml.js';
|
package/lib/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// it.
|
|
22
22
|
export { checkPublishStatus } from './checkPublishStatus.js';
|
|
23
23
|
export { deployChangedFiles, } from './deployChangedFiles.js';
|
|
24
|
-
export { publishCommunity } from './publishCommunity.js';
|
|
24
|
+
export { publishCommunity, DEFAULT_PUBLISH_REQUEST_TIMEOUT } from './publishCommunity.js';
|
|
25
25
|
export { resolveSearchRoots, resolveRetrieveDestination, resolveSiteFile, resolveNetworkFile, } from './resolveSiteFiles.js';
|
|
26
26
|
export { retrieveCustomSite } from './retrieveCustomSite.js';
|
|
27
27
|
export { patchCustomSiteXml, patchNetworkXml, readNetworkSiteName, } from './siteMetadataXml.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,mGAAmG;AACnG,iGAAiG;AACjG,qGAAqG;AACrG,kGAAkG;AAClG,oGAAoG;AACpG,MAAM;AAEN,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,kBAAkB,GAInB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAgC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,mGAAmG;AACnG,iGAAiG;AACjG,qGAAqG;AACrG,kGAAkG;AAClG,oGAAoG;AACpG,MAAM;AAEN,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,kBAAkB,GAInB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,+BAA+B,EAAgC,MAAM,uBAAuB,CAAC;AACxH,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAGlB,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAkD,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Duration } from '@salesforce/kit';
|
|
1
2
|
import type { Connection } from '@salesforce/core';
|
|
3
|
+
export { DEFAULT_PUBLISH_REQUEST_TIMEOUT } from './requestTimeout.js';
|
|
2
4
|
/** The response shape of `POST /connect/communities/{id}/publish`. */
|
|
3
5
|
type CommunityPublishResponse = {
|
|
4
6
|
id: string;
|
|
@@ -16,6 +18,12 @@ export type PublishCommunityOptions = {
|
|
|
16
18
|
retryAttempts?: number;
|
|
17
19
|
/** Factor the retry delay grows by after each failed attempt. Defaults to 2. */
|
|
18
20
|
retryBackoff?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Bounds each individual Connect/SOQL request this makes against the org. Defaults to
|
|
23
|
+
* {@link DEFAULT_PUBLISH_REQUEST_TIMEOUT}; overridable mainly so tests don't have to wait out the
|
|
24
|
+
* real default.
|
|
25
|
+
*/
|
|
26
|
+
requestTimeout?: Duration;
|
|
19
27
|
};
|
|
20
28
|
/**
|
|
21
29
|
* Trigger a community publish via the Connect REST API and poll until the job reaches a terminal
|
|
@@ -30,4 +38,3 @@ export type PublishCommunityOptions = {
|
|
|
30
38
|
* @throws If the initial publish request fails and retries (if any) are exhausted.
|
|
31
39
|
*/
|
|
32
40
|
export declare function publishCommunity(options: PublishCommunityOptions): Promise<CommunityPublishResponse>;
|
|
33
|
-
export {};
|
package/lib/publishCommunity.js
CHANGED
|
@@ -17,6 +17,8 @@ import { Duration } from '@salesforce/kit';
|
|
|
17
17
|
import { PollingClient } from '@salesforce/core';
|
|
18
18
|
import { retryWithBackoff } from '@simplysf/simply-core';
|
|
19
19
|
import { checkPublishStatus } from './checkPublishStatus.js';
|
|
20
|
+
import { DEFAULT_PUBLISH_REQUEST_TIMEOUT } from './requestTimeout.js';
|
|
21
|
+
export { DEFAULT_PUBLISH_REQUEST_TIMEOUT } from './requestTimeout.js';
|
|
20
22
|
/**
|
|
21
23
|
* Trigger a community publish via the Connect REST API and poll until the job reaches a terminal
|
|
22
24
|
* state, throwing if it fails.
|
|
@@ -30,12 +32,17 @@ import { checkPublishStatus } from './checkPublishStatus.js';
|
|
|
30
32
|
* @throws If the initial publish request fails and retries (if any) are exhausted.
|
|
31
33
|
*/
|
|
32
34
|
export async function publishCommunity(options) {
|
|
35
|
+
const requestTimeout = options.requestTimeout ?? DEFAULT_PUBLISH_REQUEST_TIMEOUT;
|
|
33
36
|
const publishResponse = await retryWithBackoff(async () => options.connection.request({
|
|
34
37
|
method: 'POST',
|
|
35
38
|
url: `/connect/communities/${options.networkId}/publish`,
|
|
36
|
-
}), {
|
|
39
|
+
}), {
|
|
40
|
+
retryAttempts: options.retryAttempts ?? 0,
|
|
41
|
+
backoffFactor: options.retryBackoff ?? 2,
|
|
42
|
+
attemptTimeout: requestTimeout,
|
|
43
|
+
});
|
|
37
44
|
const client = await PollingClient.create({
|
|
38
|
-
poll: checkPublishStatus(options.connection, publishResponse.jobId),
|
|
45
|
+
poll: checkPublishStatus(options.connection, publishResponse.jobId, requestTimeout),
|
|
39
46
|
frequency: Duration.seconds(15),
|
|
40
47
|
timeout: Duration.minutes(options.wait),
|
|
41
48
|
timeoutErrorName: 'CommunityPublishTimeoutError',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishCommunity.js","sourceRoot":"","sources":["../src/publishCommunity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"publishCommunity.js","sourceRoot":"","sources":["../src/publishCommunity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAuBtE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAgC;IACrE,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,+BAA+B,CAAC;IAEjF,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAC5C,KAAK,IAAI,EAAE,CACT,OAAO,CAAC,UAAU,CAAC,OAAO,CAA2B;QACnD,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,wBAAwB,OAAO,CAAC,SAAS,UAAU;KACzD,CAAC,EACJ;QACE,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,CAAC;QACzC,aAAa,EAAE,OAAO,CAAC,YAAY,IAAI,CAAC;QACxC,cAAc,EAAE,cAAc;KAC/B,CACF,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC;QACxC,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,UAAU,EAAE,eAAe,CAAC,KAAK,EAAE,cAAc,CAAC;QACnF,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QACvC,gBAAgB,EAAE,8BAA8B;KACjD,CAAC,CAAC;IACH,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;IAEzB,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Duration } from '@salesforce/kit';
|
|
2
|
+
/**
|
|
3
|
+
* Bounds a single attempt at any Connect/SOQL call this package makes against the org, so a stalled
|
|
4
|
+
* TCP/TLS handshake (e.g. a CI runner's network path to the org differing from a desktop's) fails
|
|
5
|
+
* fast instead of hanging forever. See docs/design/0040-community-publish-request-timeouts.md.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_PUBLISH_REQUEST_TIMEOUT: Duration;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Duration } from '@salesforce/kit';
|
|
17
|
+
/**
|
|
18
|
+
* Bounds a single attempt at any Connect/SOQL call this package makes against the org, so a stalled
|
|
19
|
+
* TCP/TLS handshake (e.g. a CI runner's network path to the org differing from a desktop's) fails
|
|
20
|
+
* fast instead of hanging forever. See docs/design/0040-community-publish-request-timeouts.md.
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_PUBLISH_REQUEST_TIMEOUT = Duration.seconds(30);
|
|
23
|
+
//# sourceMappingURL=requestTimeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestTimeout.js","sourceRoot":"","sources":["../src/requestTimeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysf/simply-community-core",
|
|
3
3
|
"description": "Community publish/deploy/domain-verification logic and site-file discovery — the library layer behind @simplysf/simply-community, published separately for direct consumption (e.g. editor tooling, CI scripts) without the CLI framework",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.8",
|
|
5
5
|
"author": "@ClayChipps",
|
|
6
6
|
"homepage": "https://github.com/SimplySF/simply-plugins-core",
|
|
7
7
|
"bugs": "https://github.com/SimplySF/simply-plugins-core/issues",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@salesforce/core": "^8.30.0",
|
|
42
42
|
"@salesforce/kit": "^3.2.6",
|
|
43
43
|
"@salesforce/source-deploy-retrieve": "^12.37.2",
|
|
44
|
-
"@simplysf/simply-core": "^1.6.
|
|
44
|
+
"@simplysf/simply-core": "^1.6.7",
|
|
45
45
|
"glob": "^13.0.6",
|
|
46
46
|
"xmlbuilder2": "^4.0.3"
|
|
47
47
|
},
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"output": []
|
|
136
136
|
}
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "d622401adb05e1d637da5ef33a96c2311cd98e8e"
|
|
139
139
|
}
|