@rippling/rippling-sdk 0.2.0-alpha.72 → 0.2.0-alpha.73
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/examples/functions/durable.ts +41 -52
- package/package.json +1 -1
- package/resources/workflow-action-executions.d.mts +9 -1627
- package/resources/workflow-action-executions.d.mts.map +1 -1
- package/resources/workflow-action-executions.d.ts +9 -1627
- package/resources/workflow-action-executions.d.ts.map +1 -1
- package/resources/workflow-action-executions.js +1 -1
- package/resources/workflow-action-executions.mjs +1 -1
- package/src/functions.md +19 -30
- package/src/resources/workflow-action-executions.ts +10 -2320
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import RipplingSDK, { DurableFunctionContext, FunctionEvent, FunctionResponse } from '@rippling/rippling-sdk';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
status: '
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type QueryReviewCompletedEvent = {
|
|
4
|
+
status: 'approved' | 'rejected';
|
|
5
|
+
reviewerId?: string;
|
|
6
|
+
rejectionReason?: string;
|
|
7
7
|
completedAt?: string;
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -16,81 +16,70 @@ export async function onRipplingEvent(
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
const workflowDefinitionId = event['workflow_definition_id'] as string | undefined;
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const signingBonusAmount = Number(event['signing_bonus_amount'] ?? 0);
|
|
19
|
+
const initialQuery = event['initial_query'] as string | undefined;
|
|
20
|
+
const followUpQuery = event['follow_up_query'] as string | undefined;
|
|
21
|
+
const followUpTime = event['follow_up_time'] as string | undefined;
|
|
23
22
|
|
|
24
|
-
if (!workflowDefinitionId || !
|
|
25
|
-
context.fail('Missing required
|
|
26
|
-
code: '
|
|
23
|
+
if (!workflowDefinitionId || !initialQuery || !followUpQuery || !followUpTime) {
|
|
24
|
+
context.fail('Missing required query inputs.', {
|
|
25
|
+
code: 'missing_query_inputs',
|
|
27
26
|
details: {
|
|
28
27
|
hasWorkflowDefinitionId: Boolean(workflowDefinitionId),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
hasInitialQuery: Boolean(initialQuery),
|
|
29
|
+
hasFollowUpQuery: Boolean(followUpQuery),
|
|
30
|
+
hasFollowUpTime: Boolean(followUpTime),
|
|
32
31
|
},
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
await context.step('
|
|
35
|
+
await context.step('run initial query', async () => {
|
|
37
36
|
await client.workflowActionExecutions.create({
|
|
38
|
-
action_type: '
|
|
37
|
+
action_type: 'run_query',
|
|
39
38
|
payload: {
|
|
40
|
-
|
|
41
|
-
recipients: supergroupId,
|
|
39
|
+
query: initialQuery,
|
|
42
40
|
},
|
|
43
41
|
workflow_definition_id: workflowDefinitionId,
|
|
44
42
|
});
|
|
45
43
|
});
|
|
46
44
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
timeout: '7 days',
|
|
52
|
-
},
|
|
53
|
-
);
|
|
45
|
+
const queryReview = await context.waitForEvent<QueryReviewCompletedEvent>('wait for query review', {
|
|
46
|
+
type: 'query_review_completed',
|
|
47
|
+
timeout: '7 days',
|
|
48
|
+
});
|
|
54
49
|
|
|
55
|
-
if (
|
|
56
|
-
context.fail('
|
|
57
|
-
code: '
|
|
58
|
-
details:
|
|
50
|
+
if (queryReview.isTimeout()) {
|
|
51
|
+
context.fail('The query was not reviewed before the deadline.', {
|
|
52
|
+
code: 'query_review_timeout',
|
|
53
|
+
details: queryReview,
|
|
59
54
|
});
|
|
60
55
|
}
|
|
61
56
|
|
|
62
|
-
if (
|
|
63
|
-
context.fail('
|
|
64
|
-
code: '
|
|
65
|
-
details:
|
|
57
|
+
if (queryReview.payload.status !== 'approved') {
|
|
58
|
+
context.fail('The query was rejected.', {
|
|
59
|
+
code: 'query_rejected',
|
|
60
|
+
details: queryReview.payload,
|
|
66
61
|
});
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
await context.sleepUntil('wait until
|
|
64
|
+
await context.sleepUntil('wait until follow-up time', followUpTime);
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
await
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
payment_amount: signingBonusAmount,
|
|
79
|
-
recipients: supergroupId,
|
|
80
|
-
},
|
|
81
|
-
workflow_definition_id: workflowDefinitionId,
|
|
82
|
-
});
|
|
66
|
+
await context.step('run follow-up query', async () => {
|
|
67
|
+
await client.workflowActionExecutions.create({
|
|
68
|
+
action_type: 'run_query',
|
|
69
|
+
payload: {
|
|
70
|
+
query: followUpQuery,
|
|
71
|
+
},
|
|
72
|
+
workflow_definition_id: workflowDefinitionId,
|
|
83
73
|
});
|
|
84
|
-
}
|
|
74
|
+
});
|
|
85
75
|
|
|
86
76
|
return new FunctionResponse({
|
|
87
77
|
statusCode: 200,
|
|
88
78
|
body: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
signingBonusScheduled: signingBonusAmount > 0,
|
|
79
|
+
reviewStatus: queryReview.payload.status,
|
|
80
|
+
reviewerId: queryReview.payload.reviewerId,
|
|
81
|
+
completedAt: queryReview.payload.completedAt,
|
|
82
|
+
followUpQueryCompleted: true,
|
|
94
83
|
},
|
|
95
84
|
});
|
|
96
85
|
}
|
package/package.json
CHANGED