n8n-nodes-getcourse 0.1.0

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.
Files changed (171) hide show
  1. package/LICENSE.md +38 -0
  2. package/README.md +359 -0
  3. package/dist/credentials/GetCourseApi.credentials.d.ts +10 -0
  4. package/dist/credentials/GetCourseApi.credentials.js +58 -0
  5. package/dist/credentials/GetCourseApi.credentials.js.map +1 -0
  6. package/dist/credentials/GetCourseTechApi.credentials.d.ts +11 -0
  7. package/dist/credentials/GetCourseTechApi.credentials.js +63 -0
  8. package/dist/credentials/GetCourseTechApi.credentials.js.map +1 -0
  9. package/dist/credentials/accountAddress.d.ts +11 -0
  10. package/dist/credentials/accountAddress.js +116 -0
  11. package/dist/credentials/accountAddress.js.map +1 -0
  12. package/dist/icons/getcourse.dark.svg +15 -0
  13. package/dist/icons/getcourse.svg +11 -0
  14. package/dist/nodes/GetCourse/GetCourse.node.d.ts +9 -0
  15. package/dist/nodes/GetCourse/GetCourse.node.js +48 -0
  16. package/dist/nodes/GetCourse/GetCourse.node.js.map +1 -0
  17. package/dist/nodes/GetCourse/GetCourse.node.json +40 -0
  18. package/dist/nodes/GetCourse/v1/actions/call/index.d.ts +3 -0
  19. package/dist/nodes/GetCourse/v1/actions/call/index.js +98 -0
  20. package/dist/nodes/GetCourse/v1/actions/call/index.js.map +1 -0
  21. package/dist/nodes/GetCourse/v1/actions/deal/description.d.ts +2 -0
  22. package/dist/nodes/GetCourse/v1/actions/deal/description.js +261 -0
  23. package/dist/nodes/GetCourse/v1/actions/deal/description.js.map +1 -0
  24. package/dist/nodes/GetCourse/v1/actions/deal/execute.d.ts +2 -0
  25. package/dist/nodes/GetCourse/v1/actions/deal/execute.js +181 -0
  26. package/dist/nodes/GetCourse/v1/actions/deal/execute.js.map +1 -0
  27. package/dist/nodes/GetCourse/v1/actions/deal/index.d.ts +2 -0
  28. package/dist/nodes/GetCourse/v1/actions/deal/index.js +8 -0
  29. package/dist/nodes/GetCourse/v1/actions/deal/index.js.map +1 -0
  30. package/dist/nodes/GetCourse/v1/actions/dialog/index.d.ts +3 -0
  31. package/dist/nodes/GetCourse/v1/actions/dialog/index.js +262 -0
  32. package/dist/nodes/GetCourse/v1/actions/dialog/index.js.map +1 -0
  33. package/dist/nodes/GetCourse/v1/actions/helpdesk/index.d.ts +3 -0
  34. package/dist/nodes/GetCourse/v1/actions/helpdesk/index.js +305 -0
  35. package/dist/nodes/GetCourse/v1/actions/helpdesk/index.js.map +1 -0
  36. package/dist/nodes/GetCourse/v1/actions/index.d.ts +5 -0
  37. package/dist/nodes/GetCourse/v1/actions/index.js +119 -0
  38. package/dist/nodes/GetCourse/v1/actions/index.js.map +1 -0
  39. package/dist/nodes/GetCourse/v1/actions/lesson/index.d.ts +3 -0
  40. package/dist/nodes/GetCourse/v1/actions/lesson/index.js +180 -0
  41. package/dist/nodes/GetCourse/v1/actions/lesson/index.js.map +1 -0
  42. package/dist/nodes/GetCourse/v1/actions/offer/index.d.ts +3 -0
  43. package/dist/nodes/GetCourse/v1/actions/offer/index.js +98 -0
  44. package/dist/nodes/GetCourse/v1/actions/offer/index.js.map +1 -0
  45. package/dist/nodes/GetCourse/v1/actions/school/index.d.ts +3 -0
  46. package/dist/nodes/GetCourse/v1/actions/school/index.js +139 -0
  47. package/dist/nodes/GetCourse/v1/actions/school/index.js.map +1 -0
  48. package/dist/nodes/GetCourse/v1/actions/user/description.d.ts +2 -0
  49. package/dist/nodes/GetCourse/v1/actions/user/description.js +499 -0
  50. package/dist/nodes/GetCourse/v1/actions/user/description.js.map +1 -0
  51. package/dist/nodes/GetCourse/v1/actions/user/execute.d.ts +2 -0
  52. package/dist/nodes/GetCourse/v1/actions/user/execute.js +270 -0
  53. package/dist/nodes/GetCourse/v1/actions/user/execute.js.map +1 -0
  54. package/dist/nodes/GetCourse/v1/actions/user/index.d.ts +2 -0
  55. package/dist/nodes/GetCourse/v1/actions/user/index.js +8 -0
  56. package/dist/nodes/GetCourse/v1/actions/user/index.js.map +1 -0
  57. package/dist/nodes/GetCourse/v1/actions/webhook/index.d.ts +4 -0
  58. package/dist/nodes/GetCourse/v1/actions/webhook/index.js +179 -0
  59. package/dist/nodes/GetCourse/v1/actions/webhook/index.js.map +1 -0
  60. package/dist/nodes/GetCourse/v1/actions/webinar/index.d.ts +3 -0
  61. package/dist/nodes/GetCourse/v1/actions/webinar/index.js +376 -0
  62. package/dist/nodes/GetCourse/v1/actions/webinar/index.js.map +1 -0
  63. package/dist/nodes/GetCourse/v1/descriptions/common.d.ts +7 -0
  64. package/dist/nodes/GetCourse/v1/descriptions/common.js +142 -0
  65. package/dist/nodes/GetCourse/v1/descriptions/common.js.map +1 -0
  66. package/dist/nodes/GetCourse/v1/helpers/errors.d.ts +11 -0
  67. package/dist/nodes/GetCourse/v1/helpers/errors.js +90 -0
  68. package/dist/nodes/GetCourse/v1/helpers/errors.js.map +1 -0
  69. package/dist/nodes/GetCourse/v1/helpers/request.d.ts +7 -0
  70. package/dist/nodes/GetCourse/v1/helpers/request.js +79 -0
  71. package/dist/nodes/GetCourse/v1/helpers/request.js.map +1 -0
  72. package/dist/nodes/GetCourse/v1/methods/index.d.ts +2 -0
  73. package/dist/nodes/GetCourse/v1/methods/index.js +39 -0
  74. package/dist/nodes/GetCourse/v1/methods/index.js.map +1 -0
  75. package/dist/nodes/GetCourse/v1/methods/loadOptions.d.ts +7 -0
  76. package/dist/nodes/GetCourse/v1/methods/loadOptions.js +76 -0
  77. package/dist/nodes/GetCourse/v1/methods/loadOptions.js.map +1 -0
  78. package/dist/nodes/GetCourse/v1/transport/index.d.ts +18 -0
  79. package/dist/nodes/GetCourse/v1/transport/index.js +165 -0
  80. package/dist/nodes/GetCourse/v1/transport/index.js.map +1 -0
  81. package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.d.ts +9 -0
  82. package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.js +48 -0
  83. package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.js.map +1 -0
  84. package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.json +35 -0
  85. package/dist/nodes/GetCourseLegacy/v1/actions/deal/description.d.ts +2 -0
  86. package/dist/nodes/GetCourseLegacy/v1/actions/deal/description.js +287 -0
  87. package/dist/nodes/GetCourseLegacy/v1/actions/deal/description.js.map +1 -0
  88. package/dist/nodes/GetCourseLegacy/v1/actions/deal/execute.d.ts +2 -0
  89. package/dist/nodes/GetCourseLegacy/v1/actions/deal/execute.js +150 -0
  90. package/dist/nodes/GetCourseLegacy/v1/actions/deal/execute.js.map +1 -0
  91. package/dist/nodes/GetCourseLegacy/v1/actions/deal/index.d.ts +2 -0
  92. package/dist/nodes/GetCourseLegacy/v1/actions/deal/index.js +8 -0
  93. package/dist/nodes/GetCourseLegacy/v1/actions/deal/index.js.map +1 -0
  94. package/dist/nodes/GetCourseLegacy/v1/actions/export/description.d.ts +2 -0
  95. package/dist/nodes/GetCourseLegacy/v1/actions/export/description.js +487 -0
  96. package/dist/nodes/GetCourseLegacy/v1/actions/export/description.js.map +1 -0
  97. package/dist/nodes/GetCourseLegacy/v1/actions/export/execute.d.ts +2 -0
  98. package/dist/nodes/GetCourseLegacy/v1/actions/export/execute.js +252 -0
  99. package/dist/nodes/GetCourseLegacy/v1/actions/export/execute.js.map +1 -0
  100. package/dist/nodes/GetCourseLegacy/v1/actions/export/index.d.ts +2 -0
  101. package/dist/nodes/GetCourseLegacy/v1/actions/export/index.js +8 -0
  102. package/dist/nodes/GetCourseLegacy/v1/actions/export/index.js.map +1 -0
  103. package/dist/nodes/GetCourseLegacy/v1/actions/field/index.d.ts +3 -0
  104. package/dist/nodes/GetCourseLegacy/v1/actions/field/index.js +61 -0
  105. package/dist/nodes/GetCourseLegacy/v1/actions/field/index.js.map +1 -0
  106. package/dist/nodes/GetCourseLegacy/v1/actions/group/index.d.ts +3 -0
  107. package/dist/nodes/GetCourseLegacy/v1/actions/group/index.js +42 -0
  108. package/dist/nodes/GetCourseLegacy/v1/actions/group/index.js.map +1 -0
  109. package/dist/nodes/GetCourseLegacy/v1/actions/index.d.ts +5 -0
  110. package/dist/nodes/GetCourseLegacy/v1/actions/index.js +84 -0
  111. package/dist/nodes/GetCourseLegacy/v1/actions/index.js.map +1 -0
  112. package/dist/nodes/GetCourseLegacy/v1/actions/user/description.d.ts +2 -0
  113. package/dist/nodes/GetCourseLegacy/v1/actions/user/description.js +87 -0
  114. package/dist/nodes/GetCourseLegacy/v1/actions/user/description.js.map +1 -0
  115. package/dist/nodes/GetCourseLegacy/v1/actions/user/execute.d.ts +5 -0
  116. package/dist/nodes/GetCourseLegacy/v1/actions/user/execute.js +129 -0
  117. package/dist/nodes/GetCourseLegacy/v1/actions/user/execute.js.map +1 -0
  118. package/dist/nodes/GetCourseLegacy/v1/actions/user/index.d.ts +2 -0
  119. package/dist/nodes/GetCourseLegacy/v1/actions/user/index.js +8 -0
  120. package/dist/nodes/GetCourseLegacy/v1/actions/user/index.js.map +1 -0
  121. package/dist/nodes/GetCourseLegacy/v1/descriptions/common.d.ts +14 -0
  122. package/dist/nodes/GetCourseLegacy/v1/descriptions/common.js +198 -0
  123. package/dist/nodes/GetCourseLegacy/v1/descriptions/common.js.map +1 -0
  124. package/dist/nodes/GetCourseLegacy/v1/descriptions/constants.d.ts +7 -0
  125. package/dist/nodes/GetCourseLegacy/v1/descriptions/constants.js +116 -0
  126. package/dist/nodes/GetCourseLegacy/v1/descriptions/constants.js.map +1 -0
  127. package/dist/nodes/GetCourseLegacy/v1/helpers/errors.d.ts +18 -0
  128. package/dist/nodes/GetCourseLegacy/v1/helpers/errors.js +141 -0
  129. package/dist/nodes/GetCourseLegacy/v1/helpers/errors.js.map +1 -0
  130. package/dist/nodes/GetCourseLegacy/v1/helpers/exportRows.d.ts +8 -0
  131. package/dist/nodes/GetCourseLegacy/v1/helpers/exportRows.js +100 -0
  132. package/dist/nodes/GetCourseLegacy/v1/helpers/exportRows.js.map +1 -0
  133. package/dist/nodes/GetCourseLegacy/v1/methods/index.d.ts +2 -0
  134. package/dist/nodes/GetCourseLegacy/v1/methods/index.js +39 -0
  135. package/dist/nodes/GetCourseLegacy/v1/methods/index.js.map +1 -0
  136. package/dist/nodes/GetCourseLegacy/v1/methods/loadOptions.d.ts +5 -0
  137. package/dist/nodes/GetCourseLegacy/v1/methods/loadOptions.js +92 -0
  138. package/dist/nodes/GetCourseLegacy/v1/methods/loadOptions.js.map +1 -0
  139. package/dist/nodes/GetCourseLegacy/v1/transport/index.d.ts +13 -0
  140. package/dist/nodes/GetCourseLegacy/v1/transport/index.js +204 -0
  141. package/dist/nodes/GetCourseLegacy/v1/transport/index.js.map +1 -0
  142. package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.d.ts +12 -0
  143. package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.js +339 -0
  144. package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.js.map +1 -0
  145. package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.json +32 -0
  146. package/dist/nodes/GetCourseTrigger/payload.d.ts +14 -0
  147. package/dist/nodes/GetCourseTrigger/payload.js +66 -0
  148. package/dist/nodes/GetCourseTrigger/payload.js.map +1 -0
  149. package/dist/utils/cache.d.ts +2 -0
  150. package/dist/utils/cache.js +27 -0
  151. package/dist/utils/cache.js.map +1 -0
  152. package/dist/utils/dates.d.ts +3 -0
  153. package/dist/utils/dates.js +70 -0
  154. package/dist/utils/dates.js.map +1 -0
  155. package/dist/utils/events.d.ts +14 -0
  156. package/dist/utils/events.js +92 -0
  157. package/dist/utils/events.js.map +1 -0
  158. package/dist/utils/httpError.d.ts +4 -0
  159. package/dist/utils/httpError.js +46 -0
  160. package/dist/utils/httpError.js.map +1 -0
  161. package/dist/utils/query.d.ts +4 -0
  162. package/dist/utils/query.js +42 -0
  163. package/dist/utils/query.js.map +1 -0
  164. package/dist/utils/rateLimiter.d.ts +3 -0
  165. package/dist/utils/rateLimiter.js +44 -0
  166. package/dist/utils/rateLimiter.js.map +1 -0
  167. package/dist/utils/router.d.ts +8 -0
  168. package/dist/utils/router.js +40 -0
  169. package/dist/utils/router.js.map +1 -0
  170. package/index.js +0 -0
  171. package/package.json +68 -0
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTruthyFlag = isTruthyFlag;
4
+ exports.errorCodeOf = errorCodeOf;
5
+ exports.errorTextOf = errorTextOf;
6
+ exports.toLegacyApiError = toLegacyApiError;
7
+ exports.envelopeError = envelopeError;
8
+ exports.importResultError = importResultError;
9
+ exports.isExportPending = isExportPending;
10
+ const n8n_workflow_1 = require("n8n-workflow");
11
+ const httpError_1 = require("../../../../utils/httpError");
12
+ function isTruthyFlag(value) {
13
+ if (typeof value === 'boolean')
14
+ return value;
15
+ if (typeof value === 'number')
16
+ return value !== 0;
17
+ if (typeof value !== 'string')
18
+ return false;
19
+ const text = value.trim().toLowerCase();
20
+ return text !== '' && text !== 'false' && text !== '0';
21
+ }
22
+ function errorCodeOf(envelope) {
23
+ const parsed = Number(envelope.error_code);
24
+ return Number.isFinite(parsed) ? parsed : undefined;
25
+ }
26
+ function errorTextOf(envelope) {
27
+ var _a;
28
+ const parts = [
29
+ typeof envelope.error === 'string' ? envelope.error : '',
30
+ (_a = envelope.error_message) !== null && _a !== void 0 ? _a : '',
31
+ ].filter((part) => part !== '');
32
+ return [...new Set(parts)].join('\n');
33
+ }
34
+ function describeCode(code, text) {
35
+ if (code === 901 || text.includes('Неавторизованное') || text.includes('Access denied')) {
36
+ return 'Either the secret key is wrong or the account address is. A key belongs to one account; if the account force-redirects to its own domain, the credential has to use that domain.';
37
+ }
38
+ if (code === 903 || text.includes('Слишком много запросов')) {
39
+ return 'The Export API allows 100 requests per two hours per account, and every status check counts. Wait for the window to clear, and lower "Export Requests per Hour" on the credential if this keeps happening.';
40
+ }
41
+ if (code === 905 || text.includes('Уже запущен')) {
42
+ return 'GetCourse builds one export at a time per account and refuses a second while one is still being built — including one started by another workflow, or by another integration on the same school. Nothing was started, so there is no export to collect. Feed this node a single item (Settings → Execute Once), or run the items through a Loop Over Items with a Wait node, or use "Export and Wait" so each export finishes before the next begins. Turning on Settings → On Error → Continue keeps the export IDs earlier items already returned instead of losing them with the run.';
43
+ }
44
+ if (code === 904 ||
45
+ text.includes('отсутсвует параметр key') ||
46
+ text.includes('отсутствует параметр key')) {
47
+ return 'The request reached GetCourse without a key. Check that the credential has its Secret Key filled in.';
48
+ }
49
+ if (code === 917 || text.includes('Функционал недоступен')) {
50
+ return 'The Import/Export API is switched off for this account. It is available on paid plans only, and the account owner has to generate a key under Профиль → Настройки аккаунта → АПИ.';
51
+ }
52
+ if (text.includes('Действие запрещено')) {
53
+ return 'The key is read-only. Imports need a key generated with write access.';
54
+ }
55
+ if (text.includes('Достигнут лимит')) {
56
+ return 'The account has used up its monthly allowance for creating objects through the API. The allowance depends on the GetCourse plan; updates to existing objects do not count against it.';
57
+ }
58
+ if (text.includes('Файл не создан')) {
59
+ return 'No object matched the filter, so GetCourse produced no export file. Widen the filter, or check in the account that the objects exist.';
60
+ }
61
+ if (code === 909 || text.includes('еще не создан')) {
62
+ return 'The export is still being built — this is a stage, not a failure. Give GetCourse longer: raise "Give Up After" on Export and Wait, or put a Wait node in front of Get Result. The ID stays valid, so the file can be collected by a later run.';
63
+ }
64
+ if (code === 908 || text.includes('хотя бы один фильтр')) {
65
+ return 'GetCourse refuses an export with no filter at all. Give at least one — a created-from date is the usual choice. A parameter GetCourse does not recognise as a filter does not satisfy the rule either, and is answered the same way: on the user export, `type` is one such parameter and is ignored.';
66
+ }
67
+ if (code === 913 || code === 914 || code === 918 || text.includes('поле статус')) {
68
+ return 'The status filter carries a value this export does not accept. GetCourse lists the ones it does in the message above, and the three sets differ: users, orders and payments each have their own.';
69
+ }
70
+ if (text.includes('Пустой параметр action')) {
71
+ return 'GetCourse read no action on the request. The usual cause is a redirect: an account with a forced domain redirect turns the POST into a GET and loses its body, so the credential has to name the custom domain.';
72
+ }
73
+ if (text.includes('Доступ возможен только по https')) {
74
+ return 'The request was made over plain HTTP. This node always uses HTTPS, so this points at a proxy in front of n8n rewriting the scheme.';
75
+ }
76
+ return undefined;
77
+ }
78
+ function toLegacyApiError(node, error, status) {
79
+ var _a;
80
+ if (error instanceof n8n_workflow_1.NodeApiError && status === undefined)
81
+ return error;
82
+ const httpCode = status !== null && status !== void 0 ? status : (0, httpError_1.extractStatusCode)(error);
83
+ const body = ((_a = (0, httpError_1.extractResponseBody)(error)) !== null && _a !== void 0 ? _a : {});
84
+ const text = errorTextOf(body);
85
+ let message = text === '' ? 'GetCourse request failed' : text;
86
+ let description = describeCode(errorCodeOf(body), text);
87
+ if (httpCode === 404 && text === '') {
88
+ message = 'GetCourse does not know that account';
89
+ description =
90
+ 'An address that is not a GetCourse account answers 404 with the plain text "Wrong subdomain". Check the account address on the credential.';
91
+ }
92
+ if (httpCode !== undefined && httpCode >= 500 && text === '') {
93
+ message = 'GetCourse returned a server error';
94
+ }
95
+ return new n8n_workflow_1.NodeApiError(node, asPlainError(error), {
96
+ message,
97
+ description,
98
+ httpCode: httpCode === undefined ? undefined : String(httpCode),
99
+ });
100
+ }
101
+ function asPlainError(error) {
102
+ var _a;
103
+ if (!(error instanceof n8n_workflow_1.NodeApiError))
104
+ return error;
105
+ return {
106
+ message: error.message,
107
+ description: (_a = error.description) !== null && _a !== void 0 ? _a : null,
108
+ httpCode: error.httpCode,
109
+ };
110
+ }
111
+ function envelopeError(node, envelope) {
112
+ const text = errorTextOf(envelope);
113
+ const code = errorCodeOf(envelope);
114
+ return new n8n_workflow_1.NodeApiError(node, envelope, {
115
+ message: text === '' ? 'GetCourse reported a failure' : text,
116
+ description: describeCode(code, text),
117
+ httpCode: code === undefined ? undefined : String(code),
118
+ });
119
+ }
120
+ function importResultError(node, envelope) {
121
+ var _a;
122
+ if (envelope.result === null || typeof envelope.result !== 'object')
123
+ return undefined;
124
+ const result = envelope.result;
125
+ const failed = isTruthyFlag(result.error) || (result.success !== undefined && !isTruthyFlag(result.success));
126
+ if (!failed)
127
+ return undefined;
128
+ const text = String((_a = result.error_message) !== null && _a !== void 0 ? _a : '').trim();
129
+ return new n8n_workflow_1.NodeApiError(node, envelope, {
130
+ message: text === '' ? 'GetCourse rejected the import' : text,
131
+ description: describeCode(undefined, text),
132
+ });
133
+ }
134
+ function isExportPending(envelope) {
135
+ if (errorCodeOf(envelope) === 909)
136
+ return true;
137
+ if (isTruthyFlag(envelope.success))
138
+ return false;
139
+ return errorTextOf(envelope).includes('еще не создан');
140
+ }
141
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../nodes/GetCourseLegacy/v1/helpers/errors.ts"],"names":[],"mappings":";;AAkCA,oCAOC;AAGD,kCAGC;AAGD,kCAOC;AAuFD,4CAyBC;AA2BD,sCASC;AAWD,8CAeC;AAWD,0CAKC;AAtPD,+CAA4C;AAE5C,2DAAqF;AA+BrF,SAAgB,YAAY,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,KAAK,CAAC,CAAC;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,OAAO,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,GAAG,CAAC;AACxD,CAAC;AAGD,SAAgB,WAAW,CAAC,QAAwB;IACnD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAAC;AAGD,SAAgB,WAAW,CAAC,QAA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,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { IDataObject } from 'n8n-workflow';
2
+ export interface ExportTable {
3
+ fields: string[];
4
+ items: unknown[][];
5
+ }
6
+ export declare function readTable(info: unknown): ExportTable | undefined;
7
+ export declare function slugifyColumn(title: string): string;
8
+ export declare function tableToRows(table: ExportTable, keyStyle?: string): IDataObject[];
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readTable = readTable;
4
+ exports.slugifyColumn = slugifyColumn;
5
+ exports.tableToRows = tableToRows;
6
+ function readTable(info) {
7
+ if (info === null || typeof info !== 'object')
8
+ return undefined;
9
+ const source = info;
10
+ const fields = source.fields;
11
+ const items = source.items;
12
+ if (!Array.isArray(fields) || !Array.isArray(items))
13
+ return undefined;
14
+ return {
15
+ fields: fields.map((field) => String(field !== null && field !== void 0 ? field : '')),
16
+ items: items.map((row) => (Array.isArray(row) ? row : [row])),
17
+ };
18
+ }
19
+ const CYRILLIC = {
20
+ а: 'a',
21
+ б: 'b',
22
+ в: 'v',
23
+ г: 'g',
24
+ д: 'd',
25
+ е: 'e',
26
+ ё: 'e',
27
+ ж: 'zh',
28
+ з: 'z',
29
+ и: 'i',
30
+ й: 'y',
31
+ к: 'k',
32
+ л: 'l',
33
+ м: 'm',
34
+ н: 'n',
35
+ о: 'o',
36
+ п: 'p',
37
+ р: 'r',
38
+ с: 's',
39
+ т: 't',
40
+ у: 'u',
41
+ ф: 'f',
42
+ х: 'h',
43
+ ц: 'ts',
44
+ ч: 'ch',
45
+ ш: 'sh',
46
+ щ: 'sch',
47
+ ъ: '',
48
+ ы: 'y',
49
+ ь: '',
50
+ э: 'e',
51
+ ю: 'yu',
52
+ я: 'ya',
53
+ і: 'i',
54
+ ї: 'yi',
55
+ є: 'ye',
56
+ ґ: 'g',
57
+ ў: 'u',
58
+ };
59
+ function slugifyColumn(title) {
60
+ const latin = [...title.toLowerCase()]
61
+ .map((char) => (char in CYRILLIC ? CYRILLIC[char] : char))
62
+ .join('');
63
+ const slug = latin
64
+ .replace(/[^a-z0-9]+/g, '_')
65
+ .replace(/^_+|_+$/g, '')
66
+ .replace(/_{2,}/g, '_');
67
+ return slug === '' ? 'column' : slug;
68
+ }
69
+ function columnKeys(fields, style) {
70
+ const seen = new Map();
71
+ const bases = fields.map((field, index) => (style === 'slug' ? slugifyColumn(field) : field.trim()) || `column_${index + 1}`);
72
+ const taken = new Set(bases);
73
+ return bases.map((base) => {
74
+ var _a;
75
+ const previous = (_a = seen.get(base)) !== null && _a !== void 0 ? _a : 0;
76
+ seen.set(base, previous + 1);
77
+ if (previous === 0)
78
+ return base;
79
+ let attempt = previous;
80
+ let candidate = `${base}_${attempt + 1}`;
81
+ while (taken.has(candidate)) {
82
+ attempt += 1;
83
+ candidate = `${base}_${attempt + 1}`;
84
+ }
85
+ taken.add(candidate);
86
+ return candidate;
87
+ });
88
+ }
89
+ function tableToRows(table, keyStyle = 'original') {
90
+ const keys = columnKeys(table.fields, keyStyle);
91
+ return table.items.map((row) => {
92
+ const entry = {};
93
+ keys.forEach((key, index) => {
94
+ const value = row[index];
95
+ entry[key] = value === undefined ? null : value;
96
+ });
97
+ return entry;
98
+ });
99
+ }
100
+ //# sourceMappingURL=exportRows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportRows.js","sourceRoot":"","sources":["../../../../../nodes/GetCourseLegacy/v1/helpers/exportRows.ts"],"names":[],"mappings":";;AAgBA,8BAaC;AAoDD,sCAWC;AAiDD,kCAaC;AA1ID,SAAgB,SAAS,CAAC,IAAa;IACtC,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAEhE,MAAM,MAAM,GAAG,IAAmB,CAAC;IACnC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAA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__createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.loadOptions = void 0;
37
+ const loadOptions = __importStar(require("./loadOptions"));
38
+ exports.loadOptions = loadOptions;
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/GetCourseLegacy/v1/methods/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6C;AAEpC,kCAAW"}
@@ -0,0 +1,5 @@
1
+ import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
2
+ export declare function getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
3
+ export declare function getGroupNames(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
4
+ export declare function getUserCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
5
+ export declare function getDealCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGroups = getGroups;
4
+ exports.getGroupNames = getGroupNames;
5
+ exports.getUserCustomFields = getUserCustomFields;
6
+ exports.getDealCustomFields = getDealCustomFields;
7
+ const transport_1 = require("../transport");
8
+ async function loadGroups() {
9
+ const envelope = await transport_1.cachedExportRequest.call(this, '/pl/api/account/groups');
10
+ const info = envelope.info;
11
+ return Array.isArray(info) ? info : [];
12
+ }
13
+ function sortByName(rows, key) {
14
+ return [...rows].sort((left, right) => { var _a, _b; return String((_a = left[key]) !== null && _a !== void 0 ? _a : '').localeCompare(String((_b = right[key]) !== null && _b !== void 0 ? _b : '')); });
15
+ }
16
+ function describeGroup(group) {
17
+ var _a;
18
+ const addedAt = group.last_added_at;
19
+ const when = addedAt === null || addedAt === undefined || addedAt === ''
20
+ ? 'empty'
21
+ : `last added ${String(addedAt)}`;
22
+ return `ID ${String((_a = group.id) !== null && _a !== void 0 ? _a : '?')} · ${when}`;
23
+ }
24
+ async function getGroups() {
25
+ return sortByName(await loadGroups.call(this), 'name').map((group) => {
26
+ var _a, _b;
27
+ return ({
28
+ name: String((_b = (_a = group.name) !== null && _a !== void 0 ? _a : group.id) !== null && _b !== void 0 ? _b : ''),
29
+ value: group.id,
30
+ description: describeGroup(group),
31
+ });
32
+ });
33
+ }
34
+ async function getGroupNames() {
35
+ return sortByName(await loadGroups.call(this), 'name')
36
+ .filter((group) => { var _a; return String((_a = group.name) !== null && _a !== void 0 ? _a : '') !== ''; })
37
+ .map((group) => ({
38
+ name: String(group.name),
39
+ value: String(group.name),
40
+ description: describeGroup(group),
41
+ }));
42
+ }
43
+ const SYSTEM_FIELD = /^gc_system_/;
44
+ async function loadFields() {
45
+ const envelope = await transport_1.fieldsRequest.call(this);
46
+ const info = envelope.info;
47
+ return Array.isArray(info) ? info : [];
48
+ }
49
+ function inContext(fields, context, pattern) {
50
+ const exact = fields.filter((field) => { var _a; return String((_a = field.context_type) !== null && _a !== void 0 ? _a : '') === context; });
51
+ if (exact.length > 0)
52
+ return { fields: exact, narrowed: true };
53
+ const matched = fields.filter((field) => { var _a; return pattern.test(String((_a = field.context_type) !== null && _a !== void 0 ? _a : '')); });
54
+ if (matched.length > 0)
55
+ return { fields: matched, narrowed: true };
56
+ return { fields, narrowed: false };
57
+ }
58
+ function toFieldOptions(fields, showContext) {
59
+ const sorted = [...fields].sort((left, right) => {
60
+ var _a, _b, _c, _d, _e, _f;
61
+ const bySystem = Number(SYSTEM_FIELD.test(String((_a = left.title) !== null && _a !== void 0 ? _a : ''))) -
62
+ Number(SYSTEM_FIELD.test(String((_b = right.title) !== null && _b !== void 0 ? _b : '')));
63
+ if (bySystem !== 0)
64
+ return bySystem;
65
+ const byPosition = Number((_c = left.field_order_pos) !== null && _c !== void 0 ? _c : 0) - Number((_d = right.field_order_pos) !== null && _d !== void 0 ? _d : 0);
66
+ if (Number.isFinite(byPosition) && byPosition !== 0)
67
+ return byPosition;
68
+ return String((_e = left.title) !== null && _e !== void 0 ? _e : '').localeCompare(String((_f = right.title) !== null && _f !== void 0 ? _f : ''));
69
+ });
70
+ return sorted
71
+ .filter((field) => { var _a; return String((_a = field.title) !== null && _a !== void 0 ? _a : '') !== ''; })
72
+ .map((field) => ({
73
+ name: String(field.title),
74
+ value: String(field.title),
75
+ description: [
76
+ field.id === undefined ? '' : `ID ${String(field.id)}`,
77
+ field.type === undefined ? '' : String(field.type),
78
+ showContext && field.context_type !== undefined ? String(field.context_type) : '',
79
+ ]
80
+ .filter((part) => part !== '')
81
+ .join(' · '),
82
+ }));
83
+ }
84
+ async function getUserCustomFields() {
85
+ const scoped = inContext(await loadFields.call(this), 'user', /user|пользоват/i);
86
+ return toFieldOptions(scoped.fields, !scoped.narrowed);
87
+ }
88
+ async function getDealCustomFields() {
89
+ const scoped = inContext(await loadFields.call(this), 'deal', /deal|order|заказ/i);
90
+ return toFieldOptions(scoped.fields, !scoped.narrowed);
91
+ }
92
+ //# sourceMappingURL=loadOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadOptions.js","sourceRoot":"","sources":["../../../../../nodes/GetCourseLegacy/v1/methods/loadOptions.ts"],"names":[],"mappings":";;AA8BA,8BAMC;AAQD,sCAQC;AAyGD,kDAKC;AAED,kDAKC;AAvKD,4CAAkE;AAGlE,KAAK,UAAU,UAAU;IACxB,MAAM,QAAQ,GAAG,MAAM,+BAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;IAChF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAE3B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAAsB,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,SAAS,UAAU,CAAC,IAAmB,EAAE,GAAW;IACnD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,eACrC,OAAA,MAAM,CAAC,MAAA,IAAI,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,MAAA,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC,CAAC,CAAA,EAAA,CAC/D,CAAC;AACH,CAAC;AAGD,SAAS,aAAa,CAAC,KAAkB;;IACxC,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC;IACpC,MAAM,IAAI,GACT,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE;QAC1D,CAAC,CAAC,OAAO;QACT,CAA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AAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;aAC7B,IAAI,CAAC,KAAK,CAAC;KACb,CAAC,CAAC,CAAC;AACN,CAAC;AAEM,KAAK,UAAU,mBAAmB;IAGxC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACjF,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxD,CAAC;AAEM,KAAK,UAAU,mBAAmB;IAGxC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACnF,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { IDataObject, IExecuteFunctions, ILoadOptionsFunctions, IPollFunctions } from 'n8n-workflow';
2
+ import type { LegacyEnvelope } from '../helpers/errors';
3
+ export type LegacyContext = IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions;
4
+ export declare const CREDENTIAL_NAME = "getCourseApi";
5
+ export declare function importRequest(this: LegacyContext, endpoint: string, action: string, params: IDataObject): Promise<LegacyEnvelope>;
6
+ export interface ExportRequestOptions {
7
+ allowPending?: boolean;
8
+ maxWaitMs?: number;
9
+ metered?: boolean;
10
+ }
11
+ export declare function exportRequest(this: LegacyContext, endpoint: string, qs?: IDataObject, options?: ExportRequestOptions): Promise<LegacyEnvelope>;
12
+ export declare function fieldsRequest(this: LegacyContext): Promise<LegacyEnvelope>;
13
+ export declare function cachedExportRequest(this: LegacyContext, endpoint: string, qs?: IDataObject): Promise<LegacyEnvelope>;
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CREDENTIAL_NAME = void 0;
4
+ exports.importRequest = importRequest;
5
+ exports.exportRequest = exportRequest;
6
+ exports.fieldsRequest = fieldsRequest;
7
+ exports.cachedExportRequest = cachedExportRequest;
8
+ const n8n_workflow_1 = require("n8n-workflow");
9
+ const accountAddress_1 = require("../../../../credentials/accountAddress");
10
+ const cache_1 = require("../../../../utils/cache");
11
+ const httpError_1 = require("../../../../utils/httpError");
12
+ const query_1 = require("../../../../utils/query");
13
+ const rateLimiter_1 = require("../../../../utils/rateLimiter");
14
+ const errors_1 = require("../helpers/errors");
15
+ exports.CREDENTIAL_NAME = 'getCourseApi';
16
+ const EXPORT_WINDOW_MS = 3600000;
17
+ const MAX_BUDGET_WAIT_MS = 15 * 60000;
18
+ const MAX_DROPDOWN_WAIT_MS = 10000;
19
+ async function resolveAccount() {
20
+ var _a, _b, _c, _d;
21
+ const credentials = await this.getCredentials(exports.CREDENTIAL_NAME);
22
+ const baseUrl = (0, accountAddress_1.accountBaseUrl)(credentials);
23
+ if (baseUrl === '') {
24
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The GetCourse credential has no usable account address', {
25
+ description: 'Open the credential and fill in the account address — either the subdomain, for example myschool.getcourse.ru, or the school domain.',
26
+ });
27
+ }
28
+ return {
29
+ baseUrl,
30
+ secretKey: String((_a = credentials.secretKey) !== null && _a !== void 0 ? _a : ''),
31
+ exportRequestsPerHour: Number(credentials.exportRequestsPerHour) || 45,
32
+ credentialId: (_d = (_c = (_b = this.getNode().credentials) === null || _b === void 0 ? void 0 : _b[exports.CREDENTIAL_NAME]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : 'unbound',
33
+ };
34
+ }
35
+ function assertNoRedirect(response, url) {
36
+ var _a, _b, _c;
37
+ const status = Number(response.statusCode);
38
+ if (!Number.isFinite(status) || status < 300 || status >= 400)
39
+ return;
40
+ const headers = ((_a = response.headers) !== null && _a !== void 0 ? _a : {});
41
+ const location = String((_c = (_b = headers.location) !== null && _b !== void 0 ? _b : headers.Location) !== null && _c !== void 0 ? _c : '').trim();
42
+ const host = location === '' ? '' : location.replace(/^https?:\/\//i, '').split('/')[0];
43
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The GetCourse account redirects API calls elsewhere', {
44
+ description: `${url} answered ${status}${host === '' ? '' : ` and pointed at ${host}`}. An account that ` +
45
+ 'force-redirects its GetCourse address to its own domain serves the API only on that domain. ' +
46
+ `Set the credential to Custom Domain${host === '' ? '' : ` and enter ${host}`}. The redirect ` +
47
+ 'was not followed: it would have stripped the request body and sent the account key to the other host.',
48
+ });
49
+ }
50
+ function assertEnvelope(body, url, status) {
51
+ if (body !== null && typeof body === 'object' && !Array.isArray(body)) {
52
+ return body;
53
+ }
54
+ const text = String(body !== null && body !== void 0 ? body : '').trim();
55
+ if (text.toLowerCase().includes('wrong subdomain')) {
56
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'GetCourse does not know that account', {
57
+ description: 'The address in the credential does not resolve to a GetCourse account. Check the subdomain — it is the part in front of .getcourse.ru.',
58
+ });
59
+ }
60
+ if (text === '') {
61
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'GetCourse answered nothing at all', {
62
+ description: `${url} returned ${status} with an empty body, so there is no way to tell whether anything was written — and on the imports observed this way, nothing was. This is how GetCourse refuses an import the plan does not include: it does not answer error_code 917, it answers nothing. Check the account's plan first, then that the key is allowed to write under Профиль → Настройки аккаунта → АПИ, and confirm in the account itself whether the object appeared before running the workflow again.`,
63
+ });
64
+ }
65
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'GetCourse answered with a page instead of API data', {
66
+ description: `The request to ${url} came back as ${status === 404 ? `${status} and a web page` : 'text rather than JSON'}. ` +
67
+ (status === 404
68
+ ? 'That path is not one this account serves. If the account force-redirects its GetCourse address to a domain of its own, the API answers only on that domain — switch the credential to Custom Domain.'
69
+ : 'The usual cause is an account that serves the API on its own domain; switch the credential to Custom Domain.'),
70
+ });
71
+ }
72
+ function assertSuccess(envelope) {
73
+ if ((0, errors_1.isTruthyFlag)(envelope.success))
74
+ return envelope;
75
+ if (envelope.success === undefined && envelope.error === undefined)
76
+ return envelope;
77
+ throw (0, errors_1.envelopeError)(this.getNode(), envelope);
78
+ }
79
+ async function send(requestOptions, retryable, beforeAttempt) {
80
+ var _a;
81
+ const maxAttempts = retryable ? 3 : 1;
82
+ const url = `${(_a = requestOptions.baseURL) !== null && _a !== void 0 ? _a : ''}${requestOptions.url}`;
83
+ for (let attempt = 1;; attempt++) {
84
+ if (beforeAttempt !== undefined)
85
+ await beforeAttempt();
86
+ let response;
87
+ try {
88
+ response = (await this.helpers.httpRequest(requestOptions));
89
+ }
90
+ catch (error) {
91
+ const status = (0, httpError_1.extractStatusCode)(error);
92
+ if (retryable && attempt < maxAttempts) {
93
+ await (0, n8n_workflow_1.sleep)(Math.min(2 ** (attempt - 1) * 1000, 8000) + (0, n8n_workflow_1.randomInt)(250));
94
+ continue;
95
+ }
96
+ throw (0, errors_1.toLegacyApiError)(this.getNode(), error, status);
97
+ }
98
+ assertNoRedirect.call(this, response, url);
99
+ const status = Number(response.statusCode);
100
+ const body = response.body;
101
+ const isEnvelope = body !== null && typeof body === 'object' && !Array.isArray(body);
102
+ if (status >= 500 && !isEnvelope) {
103
+ if (retryable && attempt < maxAttempts) {
104
+ await (0, n8n_workflow_1.sleep)(Math.min(2 ** (attempt - 1) * 1000, 8000) + (0, n8n_workflow_1.randomInt)(250));
105
+ continue;
106
+ }
107
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GetCourse returned ${status}`, {
108
+ description: `The request to ${url} failed on GetCourse's side and the answer carried no API error to report.`,
109
+ });
110
+ }
111
+ return assertEnvelope.call(this, body, url, status);
112
+ }
113
+ }
114
+ const TRANSPORT_DEFAULTS = {
115
+ json: true,
116
+ returnFullResponse: true,
117
+ disableFollowRedirect: true,
118
+ ignoreHttpStatusErrors: true,
119
+ };
120
+ async function importRequest(endpoint, action, params) {
121
+ const account = await resolveAccount.call(this);
122
+ const encoded = Buffer.from(JSON.stringify(params), 'utf8').toString('base64');
123
+ const body = [
124
+ `action=${encodeURIComponent(action)}`,
125
+ `key=${encodeURIComponent(account.secretKey)}`,
126
+ `params=${encodeURIComponent(encoded)}`,
127
+ ].join('&');
128
+ await (0, rateLimiter_1.acquireSlot)(`${account.baseUrl}|import`, 5, 1000);
129
+ const envelope = await send.call(this, {
130
+ ...TRANSPORT_DEFAULTS,
131
+ method: 'POST',
132
+ baseURL: account.baseUrl,
133
+ url: endpoint,
134
+ headers: {
135
+ 'Content-Type': 'application/x-www-form-urlencoded',
136
+ Accept: 'application/json',
137
+ },
138
+ body,
139
+ }, false);
140
+ return assertSuccess.call(this, envelope);
141
+ }
142
+ async function spendBudget(account, maxWaitMs, refusal) {
143
+ const budgetKey = `${account.baseUrl}|export`;
144
+ const allowed = await (0, rateLimiter_1.acquireSlot)(budgetKey, account.exportRequestsPerHour, EXPORT_WINDOW_MS, maxWaitMs);
145
+ if (allowed)
146
+ return;
147
+ if (refusal !== undefined) {
148
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), refusal.message, {
149
+ description: refusal.description,
150
+ });
151
+ }
152
+ const minutes = Math.ceil((0, rateLimiter_1.slotDelay)(budgetKey, account.exportRequestsPerHour, EXPORT_WINDOW_MS) / 60000);
153
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The GetCourse export budget for this account is used up', {
154
+ description: `The next slot frees up in about ${minutes} minutes. GetCourse allows 100 export ` +
155
+ 'requests per two hours per account and counts every status check; this node keeps to ' +
156
+ 'the rate set as "Export Requests per Hour" on the credential so that a poll loop ' +
157
+ "cannot lock the school's other integrations out.",
158
+ });
159
+ }
160
+ async function exportRequest(endpoint, qs = {}, options = {}) {
161
+ var _a;
162
+ const account = await resolveAccount.call(this);
163
+ const spend = options.metered === false
164
+ ? undefined
165
+ : spendBudget.bind(this, account, (_a = options.maxWaitMs) !== null && _a !== void 0 ? _a : MAX_BUDGET_WAIT_MS);
166
+ const envelope = await send.call(this, {
167
+ ...TRANSPORT_DEFAULTS,
168
+ method: 'GET',
169
+ baseURL: account.baseUrl,
170
+ url: endpoint,
171
+ qs: { key: account.secretKey, ...(0, query_1.flattenQuery)(qs) },
172
+ headers: { Accept: 'application/json' },
173
+ }, true, spend);
174
+ if (options.allowPending === true && (0, errors_1.isExportPending)(envelope))
175
+ return envelope;
176
+ return assertSuccess.call(this, envelope);
177
+ }
178
+ async function fieldsRequest() {
179
+ const account = await resolveAccount.call(this);
180
+ return await (0, cache_1.cached)(`legacy|fields|${account.credentialId}`, async () => {
181
+ const body = ['action=get', `key=${encodeURIComponent(account.secretKey)}`].join('&');
182
+ const envelope = await send.call(this, {
183
+ ...TRANSPORT_DEFAULTS,
184
+ method: 'POST',
185
+ baseURL: account.baseUrl,
186
+ url: '/pl/api/account/fields',
187
+ headers: {
188
+ 'Content-Type': 'application/x-www-form-urlencoded',
189
+ Accept: 'application/json',
190
+ },
191
+ body,
192
+ }, true, spendBudget.bind(this, account, MAX_DROPDOWN_WAIT_MS, {
193
+ message: 'The custom-field list cannot be read: the export budget is spent',
194
+ description: 'GetCourse counts this call against the same hundred-requests-per-two-hours budget as an export, and that budget is currently used up. The field name can be typed in by hand in the meantime.',
195
+ }));
196
+ return assertSuccess.call(this, envelope);
197
+ });
198
+ }
199
+ async function cachedExportRequest(endpoint, qs = {}) {
200
+ const account = await resolveAccount.call(this);
201
+ const key = `legacy|${account.credentialId}|${endpoint}|${JSON.stringify(qs)}`;
202
+ return await (0, cache_1.cached)(key, async () => await exportRequest.call(this, endpoint, qs, { maxWaitMs: MAX_DROPDOWN_WAIT_MS }));
203
+ }
204
+ //# sourceMappingURL=index.js.map