@sanity/runtime-cli 17.21.4 → 17.21.5-next.g584ecfe
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/README.md +19 -19
- package/dist/cores/functions/test.js +2 -3
- package/dist/utils/functions/child-process-wrapper.js +15 -4
- package/dist/utils/functions/child-runtime/callback.d.ts +10 -10
- package/dist/utils/functions/child-runtime/callback.js +4 -29
- package/dist/utils/functions/child-runtime/durables/delegate.js +44 -0
- package/dist/utils/functions/child-runtime/durables/durable.d.ts +29 -0
- package/dist/utils/functions/child-runtime/durables/durable.js +91 -0
- package/dist/utils/functions/child-runtime/durables/eventsFactoryPlugin.js +171 -0
- package/dist/utils/functions/child-runtime/durables/fanout.js +24 -0
- package/dist/utils/functions/child-runtime/durables/index.js +45 -0
- package/dist/utils/functions/child-runtime/durables/logger.js +31 -0
- package/dist/utils/functions/child-runtime/durables/retry.js +60 -0
- package/dist/utils/functions/child-runtime/durables/run.js +23 -0
- package/dist/utils/functions/child-runtime/durables/utils.js +20 -0
- package/dist/utils/functions/child-runtime/durables/wait.js +11 -0
- package/dist/utils/functions/child-runtime/durables/waitForCallback.js +40 -0
- package/dist/utils/functions/child-runtime/durables/waitForCondition.js +44 -0
- package/oclif.manifest.json +1 -1
- package/package.json +3 -1
- package/dist/utils/functions/child-runtime/durable.d.ts +0 -18
- package/dist/utils/functions/child-runtime/durable.js +0 -264
- package/dist/utils/functions/child-runtime/getBatchResults.d.ts +0 -6
- package/dist/utils/functions/child-runtime/getBatchResults.js +0 -74
- package/dist/utils/functions/child-runtime/step-history.d.ts +0 -15
- package/dist/utils/functions/child-runtime/step-history.js +0 -52
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Maps to runtime APIs from @sanity/functions
|
|
3
|
-
* @param outcomes - array of outcomes from the batch execution, each outcome should have a status and result or error
|
|
4
|
-
* @param reason - a string indicating the reason for the batch result, e.g., 'ALL_COMPLETED' or 'FAILED'
|
|
5
|
-
*/
|
|
6
|
-
export const getBatchResults = (outcomes, reason) => {
|
|
7
|
-
/**
|
|
8
|
-
* Returns an array of all outcomes, regardless of their status.
|
|
9
|
-
*/
|
|
10
|
-
const all = outcomes.map((outcome) => ({...outcome}))
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns an array of outcomes that have failed (status 'FAILED').
|
|
14
|
-
*/
|
|
15
|
-
const failed = () =>
|
|
16
|
-
all.filter((outcome) => outcome.error !== undefined && outcome.status === 'FAILED')
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returns an array of outcomes that have succeeded (status 'SUCCEEDED').
|
|
20
|
-
*/
|
|
21
|
-
const succeeded = () => all.filter((outcome) => outcome.status === 'SUCCEEDED')
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns an array of outcomes that are still in progress (status 'STARTED').
|
|
25
|
-
*/
|
|
26
|
-
const started = () => all.filter((outcome) => outcome.status === 'STARTED')
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns the count of successful outcomes (status 'SUCCEEDED')
|
|
30
|
-
*/
|
|
31
|
-
const successCount = all.filter((item) => item.status === 'SUCCEEDED').length
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Returns the count of failed outcomes (status 'FAILED')
|
|
35
|
-
*/
|
|
36
|
-
const failureCount = all.filter((item) => item.status === 'FAILED').length
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Returns an array of results from successful outcomes (status 'SUCCEEDED').
|
|
40
|
-
*/
|
|
41
|
-
const getResults = () => succeeded().map((item) => item.result)
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Returns an array of errors from failed outcomes (status 'FAILED').
|
|
45
|
-
*/
|
|
46
|
-
const getErrors = () => failed().map((item) => item.error)
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Throws the first error found in the failed outcomes (status 'FAILED').
|
|
50
|
-
*/
|
|
51
|
-
const throwIfError = () => {
|
|
52
|
-
const failure = all.find((outcome) => outcome.status === 'FAILED')
|
|
53
|
-
if (failure?.error) {
|
|
54
|
-
throw failure.error
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
all,
|
|
60
|
-
status: failureCount > 0 ? 'FAILED' : 'SUCCEEDED',
|
|
61
|
-
hasFailure: failureCount > 0,
|
|
62
|
-
failed,
|
|
63
|
-
succeeded,
|
|
64
|
-
started,
|
|
65
|
-
reason,
|
|
66
|
-
successCount,
|
|
67
|
-
failureCount,
|
|
68
|
-
startedCount: started().length,
|
|
69
|
-
totalCount: all.length,
|
|
70
|
-
getResults,
|
|
71
|
-
getErrors,
|
|
72
|
-
throwIfError,
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type {DurableStepEvent} from '../../types.js'
|
|
2
|
-
|
|
3
|
-
type PendingRetry = {index: number; event: DurableStepEvent; delayMs: number}
|
|
4
|
-
|
|
5
|
-
export function createStepHistory(): {
|
|
6
|
-
startRun: () => void
|
|
7
|
-
nextStep: () => {index: number; saved: DurableStepEvent | undefined}
|
|
8
|
-
recordSuccess: (index: number, event: DurableStepEvent) => void
|
|
9
|
-
recordFailure: (
|
|
10
|
-
index: number,
|
|
11
|
-
failure: {event: DurableStepEvent; error: unknown; delayMs: number},
|
|
12
|
-
) => boolean
|
|
13
|
-
getPending: () => PendingRetry | null
|
|
14
|
-
settle: (pending: PendingRetry) => void
|
|
15
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const createStepHistory = () => {
|
|
2
|
-
const history = new Map([])
|
|
3
|
-
let cursor = 0
|
|
4
|
-
let pending = null
|
|
5
|
-
|
|
6
|
-
const startRun = () => {
|
|
7
|
-
cursor = 0
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const nextStep = () => {
|
|
11
|
-
const index = cursor
|
|
12
|
-
cursor++
|
|
13
|
-
return {index, saved: history.get(index)}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const recordSuccess = (index, event) => {
|
|
17
|
-
history.set(index, event)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const recordFailure = (index, {event, error, delayMs}) => {
|
|
21
|
-
const retryable = event.attempt <= event.retries && error?.name !== 'UnrecoverableError'
|
|
22
|
-
|
|
23
|
-
if (retryable) {
|
|
24
|
-
history.set(index, {...event, output: error, retryDelayMs: delayMs})
|
|
25
|
-
pending = {index, event, delayMs}
|
|
26
|
-
} else {
|
|
27
|
-
history.set(index, {...event, output: error})
|
|
28
|
-
}
|
|
29
|
-
return retryable
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const getPending = () => {
|
|
33
|
-
const item = pending
|
|
34
|
-
pending = null
|
|
35
|
-
return item
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const settle = ({index, event}) => {
|
|
39
|
-
history.set(index, {...event, output: history.get(index).output})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
startRun,
|
|
44
|
-
nextStep,
|
|
45
|
-
recordSuccess,
|
|
46
|
-
recordFailure,
|
|
47
|
-
getPending,
|
|
48
|
-
settle,
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export {createStepHistory}
|