n8n-nodes-pronote 0.2.0 → 0.2.2
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,5 +1,5 @@
|
|
|
1
|
-
import { type INodeType, type INodeTypeDescription, type
|
|
1
|
+
import { type INodeType, type INodeTypeDescription, type IExecuteFunctions, type INodeExecutionData } from "n8n-workflow";
|
|
2
2
|
export declare class PronoteTool implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
|
-
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
5
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PronoteTool = void 0;
|
|
4
|
-
const tools_1 = require("@langchain/core/tools");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
5
|
const pawnoteClient_1 = require("../../shared/pawnoteClient");
|
|
8
6
|
const GenericFunctions_1 = require("./GenericFunctions");
|
|
@@ -15,14 +13,14 @@ class PronoteTool {
|
|
|
15
13
|
group: ["transform"],
|
|
16
14
|
version: 1,
|
|
17
15
|
description: "Expose PRONOTE timetable, tasks, and grades to AI Agents",
|
|
18
|
-
subtitle: "={{ \"
|
|
16
|
+
subtitle: "={{ $parameter[\"action\"] || \"PRONOTE\" }}",
|
|
19
17
|
defaults: {
|
|
20
18
|
name: "PRONOTE Tool",
|
|
21
19
|
},
|
|
22
20
|
usableAsTool: true,
|
|
23
|
-
inputs: [],
|
|
24
|
-
outputs: [n8n_workflow_1.NodeConnectionTypes.
|
|
25
|
-
outputNames: ["
|
|
21
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
23
|
+
outputNames: ["Result"],
|
|
26
24
|
credentials: [
|
|
27
25
|
{
|
|
28
26
|
name: "pronoteApi",
|
|
@@ -31,97 +29,138 @@ class PronoteTool {
|
|
|
31
29
|
],
|
|
32
30
|
properties: [
|
|
33
31
|
{
|
|
34
|
-
displayName: "
|
|
35
|
-
name: "
|
|
36
|
-
type: "
|
|
37
|
-
default: "
|
|
32
|
+
displayName: "Action",
|
|
33
|
+
name: "action",
|
|
34
|
+
type: "options",
|
|
35
|
+
default: "timetable",
|
|
36
|
+
options: [
|
|
37
|
+
{ name: "Timetable", value: "timetable" },
|
|
38
|
+
{ name: "Tasks", value: "tasks" },
|
|
39
|
+
{ name: "Grades", value: "grades" },
|
|
40
|
+
{ name: "Grade Periods", value: "gradePeriods" },
|
|
41
|
+
],
|
|
42
|
+
description: "What to retrieve from PRONOTE",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
displayName: "Reference Date",
|
|
46
|
+
name: "referenceDate",
|
|
47
|
+
type: "string",
|
|
48
|
+
default: "",
|
|
49
|
+
placeholder: "2024-09-01",
|
|
50
|
+
description: "ISO date used to pick the PRONOTE week for timetable/tasks. Defaults to today.",
|
|
51
|
+
displayOptions: {
|
|
52
|
+
show: {
|
|
53
|
+
action: ["timetable", "tasks"],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: "Only Pending Tasks",
|
|
59
|
+
name: "onlyPendingTasks",
|
|
60
|
+
type: "boolean",
|
|
61
|
+
default: false,
|
|
62
|
+
description: "Filter out tasks already marked done",
|
|
63
|
+
displayOptions: {
|
|
64
|
+
show: {
|
|
65
|
+
action: ["tasks"],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
displayName: "Period Name or ID",
|
|
71
|
+
name: "periodName",
|
|
72
|
+
type: "string",
|
|
73
|
+
default: "",
|
|
74
|
+
description: "Grade period to fetch (name or ID). Leave empty to use the first available period.",
|
|
75
|
+
displayOptions: {
|
|
76
|
+
show: {
|
|
77
|
+
action: ["grades"],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
displayName: "Include Individual Grades",
|
|
83
|
+
name: "includeGrades",
|
|
84
|
+
type: "boolean",
|
|
85
|
+
default: true,
|
|
86
|
+
description: "If false, only averages and subjects are returned",
|
|
87
|
+
displayOptions: {
|
|
88
|
+
show: {
|
|
89
|
+
action: ["grades"],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
38
92
|
},
|
|
39
93
|
],
|
|
40
94
|
};
|
|
41
95
|
}
|
|
42
|
-
async
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
.describe("What to retrieve from PRONOTE."),
|
|
55
|
-
referenceDate: zod_1.z
|
|
56
|
-
.string()
|
|
57
|
-
.optional()
|
|
58
|
-
.describe("ISO date (e.g. 2024-09-01). Used for timetable and tasks to select the week; defaults to today."),
|
|
59
|
-
periodName: zod_1.z
|
|
60
|
-
.string()
|
|
61
|
-
.optional()
|
|
62
|
-
.describe("Grade period name or ID. Used when action=grades."),
|
|
63
|
-
onlyPendingTasks: zod_1.z
|
|
64
|
-
.boolean()
|
|
65
|
-
.optional()
|
|
66
|
-
.describe("When action=tasks, if true only return undone tasks."),
|
|
67
|
-
includeGrades: zod_1.z
|
|
68
|
-
.boolean()
|
|
69
|
-
.optional()
|
|
70
|
-
.describe("When action=grades, if false only averages are returned."),
|
|
71
|
-
}),
|
|
72
|
-
func: async (input) => {
|
|
73
|
-
const safeStringify = (data) => JSON.stringify(data, null, 2);
|
|
74
|
-
switch (input.action) {
|
|
75
|
-
case "timetable": {
|
|
76
|
-
const referenceDate = (0, GenericFunctions_1.resolveReferenceDate)(input.referenceDate);
|
|
77
|
-
const timetable = await (0, pawnoteClient_1.fetchTimetable)(session, referenceDate);
|
|
78
|
-
return safeStringify(timetable);
|
|
79
|
-
}
|
|
80
|
-
case "tasks": {
|
|
81
|
-
const referenceDate = (0, GenericFunctions_1.resolveReferenceDate)(input.referenceDate);
|
|
82
|
-
const assignments = await (0, pawnoteClient_1.fetchAssignments)(session, referenceDate);
|
|
83
|
-
const filtered = input.onlyPendingTasks
|
|
84
|
-
? assignments.filter((a) => !a.isDone)
|
|
85
|
-
: assignments;
|
|
86
|
-
return safeStringify(filtered);
|
|
87
|
-
}
|
|
88
|
-
case "gradePeriods": {
|
|
89
|
-
const periods = await (0, pawnoteClient_1.fetchGradePeriods)(session);
|
|
90
|
-
return safeStringify(periods);
|
|
91
|
-
}
|
|
92
|
-
case "grades": {
|
|
93
|
-
const includeGrades = input.includeGrades !== false;
|
|
94
|
-
const overview = await (0, pawnoteClient_1.fetchGrades)(session, input.periodName);
|
|
95
|
-
if (!includeGrades) {
|
|
96
|
-
return safeStringify({
|
|
97
|
-
period: overview.period,
|
|
98
|
-
studentOverall: overview.studentOverall,
|
|
99
|
-
classAverage: overview.classAverage,
|
|
100
|
-
subjects: overview.subjects.map((subject) => ({
|
|
101
|
-
id: subject.id,
|
|
102
|
-
name: subject.name,
|
|
103
|
-
studentAverage: subject.studentAverage,
|
|
104
|
-
classAverage: subject.classAverage,
|
|
105
|
-
maximum: subject.maximum,
|
|
106
|
-
minimum: subject.minimum,
|
|
107
|
-
outOf: subject.outOf,
|
|
108
|
-
})),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return safeStringify(overview);
|
|
112
|
-
}
|
|
113
|
-
default:
|
|
114
|
-
throw new Error(`Unsupported action: ${input["action"]}`);
|
|
96
|
+
async execute() {
|
|
97
|
+
const items = this.getInputData();
|
|
98
|
+
const returnData = [];
|
|
99
|
+
const auth = await (0, GenericFunctions_1.getPronoteAuth)(this);
|
|
100
|
+
const action = this.getNodeParameter("action", 0);
|
|
101
|
+
for (let i = 0; i < items.length; i++) {
|
|
102
|
+
try {
|
|
103
|
+
if (action === "timetable") {
|
|
104
|
+
const referenceDate = (0, GenericFunctions_1.resolveReferenceDate)(this.getNodeParameter("referenceDate", i));
|
|
105
|
+
const timetable = await (0, pawnoteClient_1.fetchTimetable)(auth.session, referenceDate);
|
|
106
|
+
for (const day of timetable) {
|
|
107
|
+
returnData.push({ json: day, pairedItem: { item: i } });
|
|
115
108
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (action === "tasks") {
|
|
112
|
+
const referenceDate = (0, GenericFunctions_1.resolveReferenceDate)(this.getNodeParameter("referenceDate", i));
|
|
113
|
+
const onlyPending = this.getNodeParameter("onlyPendingTasks", i);
|
|
114
|
+
const assignments = await (0, pawnoteClient_1.fetchAssignments)(auth.session, referenceDate);
|
|
115
|
+
for (const assignment of assignments) {
|
|
116
|
+
if (onlyPending && assignment.isDone)
|
|
117
|
+
continue;
|
|
118
|
+
returnData.push({ json: assignment, pairedItem: { item: i } });
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (action === "gradePeriods") {
|
|
123
|
+
const periods = await (0, pawnoteClient_1.fetchGradePeriods)(auth.session);
|
|
124
|
+
for (const period of periods) {
|
|
125
|
+
returnData.push({ json: period, pairedItem: { item: i } });
|
|
126
|
+
}
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (action === "grades") {
|
|
130
|
+
const periodName = this.getNodeParameter("periodName", i).trim() || undefined;
|
|
131
|
+
const includeGrades = this.getNodeParameter("includeGrades", i);
|
|
132
|
+
const overview = await (0, pawnoteClient_1.fetchGrades)(auth.session, periodName);
|
|
133
|
+
if (!includeGrades) {
|
|
134
|
+
returnData.push({
|
|
135
|
+
json: {
|
|
136
|
+
period: overview.period,
|
|
137
|
+
studentOverall: overview.studentOverall,
|
|
138
|
+
classAverage: overview.classAverage,
|
|
139
|
+
subjects: overview.subjects.map((subject) => ({
|
|
140
|
+
id: subject.id,
|
|
141
|
+
name: subject.name,
|
|
142
|
+
studentAverage: subject.studentAverage,
|
|
143
|
+
classAverage: subject.classAverage,
|
|
144
|
+
maximum: subject.maximum,
|
|
145
|
+
minimum: subject.minimum,
|
|
146
|
+
outOf: subject.outOf,
|
|
147
|
+
})),
|
|
148
|
+
},
|
|
149
|
+
pairedItem: { item: i },
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
returnData.push({ json: overview, pairedItem: { item: i } });
|
|
154
|
+
}
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
throw new Error(`Unsupported action ${action}`);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, { itemIndex: i });
|
|
161
|
+
}
|
|
124
162
|
}
|
|
163
|
+
return [returnData];
|
|
125
164
|
}
|
|
126
165
|
}
|
|
127
166
|
exports.PronoteTool = PronoteTool;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-pronote",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "n8n custom nodes and agent utilities to talk to PRONOTE via the Pawnote library.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/nodes/Pronote/Pronote.node.js",
|
|
7
7
|
"types": "dist/nodes/Pronote/Pronote.node.d.ts",
|
|
8
|
+
"keywords": ["n8n-community-node-package", "n8n", "n8n-nodes", "pronote", "pawnote", "langchain"],
|
|
8
9
|
"scripts": {
|
|
9
10
|
"build": "tsc -p .",
|
|
10
11
|
"clean": "rimraf dist"
|
|
@@ -13,9 +14,7 @@
|
|
|
13
14
|
"dist"
|
|
14
15
|
],
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
-
"pawnote": "^1.6.2",
|
|
18
|
-
"zod": "^3.23.8"
|
|
17
|
+
"pawnote": "^1.6.2"
|
|
19
18
|
},
|
|
20
19
|
"peerDependencies": {
|
|
21
20
|
"n8n-core": "^1.0.0",
|