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,3 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
2
+ export declare const description: INodeProperties[];
3
+ export declare function execute(this: IExecuteFunctions, operation: string, itemIndex: number): Promise<INodeExecutionData[]>;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.execute = execute;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ const common_1 = require("../../descriptions/common");
7
+ const request_1 = require("../../helpers/request");
8
+ const router_1 = require("../../../../../utils/router");
9
+ const transport_1 = require("../../transport");
10
+ const showFor = (operations) => ({
11
+ show: { resource: ['offer'], operation: operations },
12
+ });
13
+ const LISTS = ['getMany', 'getManyTags'];
14
+ exports.description = [
15
+ {
16
+ displayName: 'Operation',
17
+ name: 'operation',
18
+ type: 'options',
19
+ noDataExpression: true,
20
+ default: 'getMany',
21
+ displayOptions: { show: { resource: ['offer'] } },
22
+ options: [
23
+ {
24
+ name: 'Get',
25
+ value: 'get',
26
+ action: 'Get an offer',
27
+ description: 'Информация по предложению — цена, НДС, продукты и теги',
28
+ },
29
+ {
30
+ name: 'Get Many',
31
+ value: 'getMany',
32
+ action: 'Get many offers',
33
+ description: 'Информация по всем предложениям. The endpoint pages with limit and offset and reports no total, so Return All walks it until a short page comes back.',
34
+ },
35
+ {
36
+ name: 'Get Many Tags',
37
+ value: 'getManyTags',
38
+ action: 'Get many offer tags',
39
+ description: 'Список предложений и их тегов. One row per offer, holding the tag names and no IDs — far cheaper than reading every offer when the tags are all that matter.',
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ displayName: 'Предложение приходит целиком, частичного ответа у метода нет. Ставка НДС — vat: none, vat0, vat5, vat7, vat10, vat22; тип продукта — products[].type: groups, simple, training, tariff, cms_template, extend_limits, user_balance, virtual_balance, promo_code, chatium_course, hd_advert, ticket, ai_token, и вложенные training и stream заполнены только у продуктов типа training. Теги предложения — это объект вида {"1": "Программирование"}, а не массив, и это единственное место в API, где виден ID тега; params спецификация объявляет объектом, хотя в собственном примере он пустой массив, так что читать его надо с оглядкой на обе формы.',
45
+ name: 'offerShapeNotice',
46
+ type: 'notice',
47
+ default: '',
48
+ displayOptions: showFor(['get', 'getMany']),
49
+ },
50
+ {
51
+ displayName: 'Offer Name or ID',
52
+ name: 'offerId',
53
+ type: 'options',
54
+ typeOptions: { loadOptionsMethod: 'getOffers' },
55
+ default: '',
56
+ required: true,
57
+ displayOptions: showFor(['get']),
58
+ description: 'Предложение, о котором нужны данные. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
59
+ },
60
+ ...(0, common_1.returnAllProperties)(showFor(LISTS)),
61
+ ];
62
+ async function getOffer(itemIndex) {
63
+ var _a;
64
+ const offerId = String((_a = this.getNodeParameter('offerId', itemIndex, '')) !== null && _a !== void 0 ? _a : '').trim();
65
+ if (offerId === '') {
66
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No offer named', {
67
+ description: 'Pick an offer from the list, or give its numeric ID.',
68
+ itemIndex,
69
+ });
70
+ }
71
+ const data = (await transport_1.techApiRequest.call(this, 'GET', '/offer/get-offer-by-id', undefined, {
72
+ offerId: Number(offerId),
73
+ }));
74
+ const rows = Array.isArray(data) ? data : (0, request_1.toItems)(data, {});
75
+ return rows.map((row) => ({ json: row }));
76
+ }
77
+ const LIST_ENDPOINTS = {
78
+ getMany: '/offer/get-offers',
79
+ getManyTags: '/offer/get-offers-tags',
80
+ };
81
+ async function getOfferList(operation, itemIndex) {
82
+ const returnAll = this.getNodeParameter('returnAll', itemIndex, false);
83
+ const limit = this.getNodeParameter('limit', itemIndex, 50);
84
+ const rows = await transport_1.techApiRequestAllItems.call(this, LIST_ENDPOINTS[operation], {}, { pageSize: 100, ...(returnAll ? {} : { limit: Math.max(1, limit) }) });
85
+ return rows.map((row) => ({ json: row }));
86
+ }
87
+ async function execute(operation, itemIndex) {
88
+ switch (operation) {
89
+ case 'get':
90
+ return await getOffer.call(this, itemIndex);
91
+ case 'getMany':
92
+ case 'getManyTags':
93
+ return await getOfferList.call(this, operation, itemIndex);
94
+ default:
95
+ throw router_1.unknownOperation.call(this, 'offer', operation, itemIndex);
96
+ }
97
+ }
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../nodes/GetCourse/v1/actions/offer/index.ts"],"names":[],"mappings":";;;AAuIA,0BAcC;AA/ID,+CAAkD;AAElD,sDAAgE;AAChE,mDAAgD;AAChD,wDAA+D;AAC/D,+CAAyE;AAEzE,MAAM,OAAO,GAAG,CAAC,UAAoB,EAAqC,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE;CACpD,CAAC,CAAC;AAGH,MAAM,KAAK,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAU5B,QAAA,WAAW,GAAsB;IAC7C;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,SAAS;QAClB,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE;QACjD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,cAAc;gBACtB,WAAW,EAAE,wDAAwD;aACrE;YACD;gBACC,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,iBAAiB;gBACzB,WAAW,EACV,uJAAuJ;aACxJ;YACD;gBACC,IAAI,EAAE,eAAe;gBAC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AI,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAC5D;YACC,MAAM,yBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACnE,CAAC;AACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
2
+ export declare const description: INodeProperties[];
3
+ export declare function execute(this: IExecuteFunctions, operation: string, itemIndex: number): Promise<INodeExecutionData[]>;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.execute = execute;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ const common_1 = require("../../descriptions/common");
7
+ const request_1 = require("../../helpers/request");
8
+ const router_1 = require("../../../../../utils/router");
9
+ const transport_1 = require("../../transport");
10
+ const showFor = (operations) => ({
11
+ show: { resource: ['school'], operation: operations },
12
+ });
13
+ exports.description = [
14
+ {
15
+ displayName: 'Operation',
16
+ name: 'operation',
17
+ type: 'options',
18
+ noDataExpression: true,
19
+ default: 'getGroups',
20
+ displayOptions: { show: { resource: ['school'] } },
21
+ options: [
22
+ {
23
+ name: 'Get Many Departments',
24
+ value: 'getDepartments',
25
+ action: 'Get many departments',
26
+ description: 'Отделы школы. Departments are what dialogs and HelpDesk tickets are routed between.',
27
+ },
28
+ {
29
+ name: 'Get Many Groups',
30
+ value: 'getGroups',
31
+ action: 'Get many user groups',
32
+ description: 'Группы пользователей аккаунта, with their IDs',
33
+ },
34
+ {
35
+ name: 'Get Many Personal Managers',
36
+ value: 'getManagers',
37
+ action: 'Get many personal managers',
38
+ description: 'Сотрудники с правами менеджера. Returns full user records, which is where the author ID for a comment comes from.',
39
+ },
40
+ {
41
+ name: 'Get Many Trainings',
42
+ value: 'getTrainings',
43
+ action: 'Get many trainings',
44
+ description: 'Тренинги аккаунта, with their lesson counts and status',
45
+ },
46
+ {
47
+ name: 'Get Survey Answers',
48
+ value: 'getSurveyAnswers',
49
+ action: 'Get the answers to a survey',
50
+ description: 'Ответы на анкету. The one endpoint in the whole API that reports a total, so paging through it is exact.',
51
+ },
52
+ ],
53
+ },
54
+ {
55
+ displayName: 'Survey ID',
56
+ name: 'surveyId',
57
+ type: 'string',
58
+ default: '',
59
+ required: true,
60
+ displayOptions: showFor(['getSurveyAnswers']),
61
+ description: "ID анкеты. There is no endpoint listing surveys — the ID comes from the survey's address in the account.",
62
+ },
63
+ ...(0, common_1.returnAllProperties)(showFor(['getSurveyAnswers'])),
64
+ {
65
+ displayName: 'Resolve Question Titles',
66
+ name: 'resolveQuestions',
67
+ type: 'boolean',
68
+ default: true,
69
+ displayOptions: showFor(['getSurveyAnswers']),
70
+ description: 'Whether to key each answer by the question text rather than its ID (подставить тексты вопросов). GetCourse answers with two objects — a question map and an answer map keyed by question ID — and joining them is almost always what a workflow wants.',
71
+ },
72
+ ];
73
+ async function getSurveyAnswers(itemIndex) {
74
+ var _a, _b;
75
+ const surveyId = String((_a = this.getNodeParameter('surveyId', itemIndex, '')) !== null && _a !== void 0 ? _a : '').trim();
76
+ if (surveyId === '') {
77
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No survey named', {
78
+ description: 'Give the numeric survey ID.',
79
+ itemIndex,
80
+ });
81
+ }
82
+ const returnAll = this.getNodeParameter('returnAll', itemIndex, false);
83
+ const limit = this.getNodeParameter('limit', itemIndex, 50);
84
+ const wanted = returnAll ? Number.POSITIVE_INFINITY : Math.max(1, limit);
85
+ const resolve = this.getNodeParameter('resolveQuestions', itemIndex, true);
86
+ const pageSize = 1000;
87
+ const collected = [];
88
+ let questions = {};
89
+ for (let offset = 0; collected.length < wanted; offset += pageSize) {
90
+ const page = (await transport_1.techApiRequest.call(this, 'GET', '/common/get-survey-answer', undefined, {
91
+ surveyId: Number(surveyId),
92
+ limit: Math.min(pageSize, wanted - collected.length),
93
+ offset,
94
+ }));
95
+ const answers = page === null || page === void 0 ? void 0 : page.answers;
96
+ if (!Array.isArray(answers) || answers.length === 0)
97
+ break;
98
+ questions = ((_b = page === null || page === void 0 ? void 0 : page.questions) !== null && _b !== void 0 ? _b : questions);
99
+ collected.push(...answers);
100
+ const total = Number(page === null || page === void 0 ? void 0 : page.total_count);
101
+ if (Number.isFinite(total) && collected.length >= total)
102
+ break;
103
+ if (answers.length < pageSize)
104
+ break;
105
+ }
106
+ const rows = returnAll ? collected : collected.slice(0, wanted);
107
+ return rows.map((answer) => ({ json: resolve ? withQuestionTitles(answer, questions) : answer }));
108
+ }
109
+ function withQuestionTitles(answer, questions) {
110
+ var _a, _b, _c;
111
+ const raw = ((_a = answer.answers) !== null && _a !== void 0 ? _a : {});
112
+ const resolved = {};
113
+ const used = new Map();
114
+ for (const [questionId, value] of Object.entries(raw)) {
115
+ const title = String((_b = questions[questionId]) !== null && _b !== void 0 ? _b : '').trim();
116
+ const base = title === '' ? questionId : title;
117
+ const seen = (_c = used.get(base)) !== null && _c !== void 0 ? _c : 0;
118
+ used.set(base, seen + 1);
119
+ resolved[seen === 0 ? base : `${base} (${questionId})`] = value;
120
+ }
121
+ return { ...answer, answers: resolved, answers_by_id: raw };
122
+ }
123
+ const DICTIONARIES = {
124
+ getDepartments: '/common/get-departments',
125
+ getGroups: '/common/get-groups',
126
+ getManagers: '/common/get-personal-managers',
127
+ getTrainings: '/common/get-trainings',
128
+ };
129
+ async function execute(operation, itemIndex) {
130
+ if (operation === 'getSurveyAnswers')
131
+ return await getSurveyAnswers.call(this, itemIndex);
132
+ const endpoint = DICTIONARIES[operation];
133
+ if (endpoint === undefined)
134
+ throw router_1.unknownOperation.call(this, 'school', operation, itemIndex);
135
+ const data = await transport_1.techApiRequest.call(this, 'GET', endpoint);
136
+ const rows = Array.isArray(data) ? data : (0, request_1.toItems)(data, {});
137
+ return rows.map((row) => ({ json: row }));
138
+ }
139
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js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