@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.
@@ -1,9 +1,9 @@
1
1
  import RipplingSDK, { DurableFunctionContext, FunctionEvent, FunctionResponse } from '@rippling/rippling-sdk';
2
2
 
3
- type OfferLetterCompletedEvent = {
4
- status: 'signed' | 'declined';
5
- signedDocumentId?: string;
6
- declinedReason?: string;
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 supergroupId = event['employee_id'] as string | undefined;
20
- const offerLetterDocumentId = event['offer_letter_document_id'] as string | undefined;
21
- const startDate = event['start_date'] as string | undefined;
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 || !supergroupId || !offerLetterDocumentId || !startDate) {
25
- context.fail('Missing required onboarding inputs.', {
26
- code: 'missing_onboarding_inputs',
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
- hasSupergroupId: Boolean(supergroupId),
30
- hasOfferLetterDocumentId: Boolean(offerLetterDocumentId),
31
- hasStartDate: Boolean(startDate),
28
+ hasInitialQuery: Boolean(initialQuery),
29
+ hasFollowUpQuery: Boolean(followUpQuery),
30
+ hasFollowUpTime: Boolean(followUpTime),
32
31
  },
33
32
  });
34
33
  }
35
34
 
36
- await context.step('send offer letter document', async () => {
35
+ await context.step('run initial query', async () => {
37
36
  await client.workflowActionExecutions.create({
38
- action_type: 'send_document',
37
+ action_type: 'run_query',
39
38
  payload: {
40
- document: offerLetterDocumentId,
41
- recipients: supergroupId,
39
+ query: initialQuery,
42
40
  },
43
41
  workflow_definition_id: workflowDefinitionId,
44
42
  });
45
43
  });
46
44
 
47
- const offerCompletion = await context.waitForEvent<OfferLetterCompletedEvent>(
48
- 'wait for signed offer letter',
49
- {
50
- type: 'offer_letter_completed',
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 (offerCompletion.isTimeout()) {
56
- context.fail('Offer letter was not completed before the deadline.', {
57
- code: 'offer_letter_timeout',
58
- details: offerCompletion,
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 (offerCompletion.payload.status !== 'signed') {
63
- context.fail('Offer letter was declined.', {
64
- code: 'offer_letter_declined',
65
- details: offerCompletion.payload,
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 employee start date', startDate);
64
+ await context.sleepUntil('wait until follow-up time', followUpTime);
70
65
 
71
- if (signingBonusAmount > 0) {
72
- await context.step('schedule signing bonus payment', async () => {
73
- await client.workflowActionExecutions.create({
74
- action_type: 'make_payment',
75
- payload: {
76
- apply_cap: false,
77
- description: `Signing bonus for durable run ${context.function.run_id}`,
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
- supergroupId: supergroupId,
90
- offerStatus: offerCompletion.payload.status,
91
- signedDocumentId: offerCompletion.payload.signedDocumentId,
92
- completedAt: offerCompletion.payload.completedAt,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rippling/rippling-sdk",
3
- "version": "0.2.0-alpha.72",
3
+ "version": "0.2.0-alpha.73",
4
4
  "description": "The official TypeScript library for the Rippling SDK API",
5
5
  "author": "Rippling SDK <no-reply@rippling.com>",
6
6
  "types": "./index.d.ts",