@jacebenson/jsn 4.3.8-dev.49 → 4.3.8-dev.50
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/package.json +1 -1
- package/src/flow-publish.js +15 -3
package/package.json
CHANGED
package/src/flow-publish.js
CHANGED
|
@@ -80,9 +80,21 @@ export async function publishFlows(sdk, flowIDs = [], actionIDs = []) {
|
|
|
80
80
|
/** Publish one flow through the ProcessFlow snapshot/version lifecycle. */
|
|
81
81
|
export async function publishFlowLifecycle(sdk, instance, flowId) {
|
|
82
82
|
const flowRecord = sdk.get ? await sdk.get('sys_hub_flow', flowId) : null;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const flowPath = `${instance}${PROCESSFLOW_PATH}/${encodeURIComponent(flowId)}`;
|
|
84
|
+
// sys_hub_flow.scope is often omitted by the Table API for newly created
|
|
85
|
+
// flows. The ProcessFlow definition carries the application scope needed by
|
|
86
|
+
// its snapshot and version endpoints, so read it before constructing either.
|
|
87
|
+
let scope = str(flowRecord, 'scope');
|
|
88
|
+
let definitionResponse;
|
|
89
|
+
if (!scope) {
|
|
90
|
+
definitionResponse = await sdk.request(flowPath, { method: 'GET' });
|
|
91
|
+
const initialDefinition = definitionResponse?.result?.data ?? definitionResponse?.data?.result?.data ?? definitionResponse?.data ?? definitionResponse?.result ?? definitionResponse;
|
|
92
|
+
scope = str(initialDefinition, 'scope');
|
|
93
|
+
if (!scope) throw new Error(`Flow ${flowId} has no transaction scope; refusing to publish`);
|
|
94
|
+
}
|
|
95
|
+
if (!definitionResponse) {
|
|
96
|
+
definitionResponse = await sdk.request(`${flowPath}?sysparm_transaction_scope=${encodeURIComponent(scope)}`, { method: 'GET' });
|
|
97
|
+
}
|
|
86
98
|
const definition = definitionResponse?.result?.data ?? definitionResponse?.data?.result?.data ?? definitionResponse?.data ?? definitionResponse?.result ?? definitionResponse;
|
|
87
99
|
if (!definition || typeof definition !== 'object') throw new Error(`Flow definition could not be read for ${flowId}`);
|
|
88
100
|
const definitionScope = str(definition, 'scope');
|