@neutron.co.id/pendidikan-operation 1.27.25 → 1.27.27

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.
@@ -37,10 +37,13 @@ const sendPointNotification = operation.Action.define({
37
37
  "Authorization": `ApiKey ${config.novuApi.token}`,
38
38
  "Content-Type": "application/json"
39
39
  },
40
- body: JSON.stringify({
40
+ body: {
41
41
  name: "get-point",
42
42
  to: {
43
- subscriberId: student.userId
43
+ subscriberId: student.userId,
44
+ email: student.user?.email || "",
45
+ firstName: student.user?.name || "Student",
46
+ lastName: ""
44
47
  },
45
48
  payload: {
46
49
  point: data?.point
@@ -54,7 +57,7 @@ const sendPointNotification = operation.Action.define({
54
57
  }
55
58
  }
56
59
  }
57
- })
60
+ }
58
61
  });
59
62
  await stream?.actions.data.createOne.execute({
60
63
  model: "neu:data:notification",
@@ -70,7 +73,7 @@ const sendPointNotification = operation.Action.define({
70
73
  }
71
74
  }, stream);
72
75
  } catch (error) {
73
- console.error(`Failed to send score notification to student ${student.userId}:`, error);
76
+ console.error(`Failed to send point notification to student ${student.userId}:`, error);
74
77
  }
75
78
  return core.Result.ok({
76
79
  state: "notificationSent",
@@ -81,22 +84,22 @@ const sendPointNotification = operation.Action.define({
81
84
  }
82
85
  });
83
86
  } catch (error) {
84
- console.error("Failed to send score notifications:", error);
87
+ console.error("Failed to send point notifications:", error);
85
88
  return core.Result.ok({
86
- state: "emailsSent",
89
+ state: "notificationSent",
87
90
  message: "Failed to send notifications",
88
91
  data: { sentCount: 0, transactionIds: [] }
89
92
  });
90
93
  }
91
94
  }
92
95
  });
93
- async function _getOneStudent(stream, userId) {
96
+ async function _getOneStudent(stream, studentId) {
94
97
  const result = await stream.actions.data.getMany.execute(
95
98
  {
96
99
  model: "neu:akademik:student",
97
100
  query: query.Query.define({
98
101
  filter: {
99
- userId
102
+ _id: studentId
100
103
  },
101
104
  fields: {
102
105
  id: 1,
@@ -113,11 +116,14 @@ async function _getOneStudent(stream, userId) {
113
116
  levels: { id: 1, name: 1 },
114
117
  branches: { id: 1, name: 1 },
115
118
  user: {
119
+ name: 1,
120
+ email: 1,
116
121
  roles: {
117
122
  name: 1,
118
123
  handle: 1
119
124
  }
120
125
  },
126
+ userId: 1,
121
127
  seniorSchools: { id: 1, name: 1 },
122
128
  classGroups: {
123
129
  id: 1,
@@ -35,10 +35,13 @@ const sendPointNotification = Action.define({
35
35
  "Authorization": `ApiKey ${config.novuApi.token}`,
36
36
  "Content-Type": "application/json"
37
37
  },
38
- body: JSON.stringify({
38
+ body: {
39
39
  name: "get-point",
40
40
  to: {
41
- subscriberId: student.userId
41
+ subscriberId: student.userId,
42
+ email: student.user?.email || "",
43
+ firstName: student.user?.name || "Student",
44
+ lastName: ""
42
45
  },
43
46
  payload: {
44
47
  point: data?.point
@@ -52,7 +55,7 @@ const sendPointNotification = Action.define({
52
55
  }
53
56
  }
54
57
  }
55
- })
58
+ }
56
59
  });
57
60
  await stream?.actions.data.createOne.execute({
58
61
  model: "neu:data:notification",
@@ -68,7 +71,7 @@ const sendPointNotification = Action.define({
68
71
  }
69
72
  }, stream);
70
73
  } catch (error) {
71
- console.error(`Failed to send score notification to student ${student.userId}:`, error);
74
+ console.error(`Failed to send point notification to student ${student.userId}:`, error);
72
75
  }
73
76
  return Result.ok({
74
77
  state: "notificationSent",
@@ -79,22 +82,22 @@ const sendPointNotification = Action.define({
79
82
  }
80
83
  });
81
84
  } catch (error) {
82
- console.error("Failed to send score notifications:", error);
85
+ console.error("Failed to send point notifications:", error);
83
86
  return Result.ok({
84
- state: "emailsSent",
87
+ state: "notificationSent",
85
88
  message: "Failed to send notifications",
86
89
  data: { sentCount: 0, transactionIds: [] }
87
90
  });
88
91
  }
89
92
  }
90
93
  });
91
- async function _getOneStudent(stream, userId) {
94
+ async function _getOneStudent(stream, studentId) {
92
95
  const result = await stream.actions.data.getMany.execute(
93
96
  {
94
97
  model: "neu:akademik:student",
95
98
  query: Query.define({
96
99
  filter: {
97
- userId
100
+ _id: studentId
98
101
  },
99
102
  fields: {
100
103
  id: 1,
@@ -111,11 +114,14 @@ async function _getOneStudent(stream, userId) {
111
114
  levels: { id: 1, name: 1 },
112
115
  branches: { id: 1, name: 1 },
113
116
  user: {
117
+ name: 1,
118
+ email: 1,
114
119
  roles: {
115
120
  name: 1,
116
121
  handle: 1
117
122
  }
118
123
  },
124
+ userId: 1,
119
125
  seniorSchools: { id: 1, name: 1 },
120
126
  classGroups: {
121
127
  id: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neutron.co.id/pendidikan-operation",
3
- "version": "1.27.25",
3
+ "version": "1.27.27",
4
4
  "description": "Operation package of Neutron Pendidikan.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "contributors": [
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "build": 150
89
+ "build": 152
90
90
  }