@rjsebening/n8n-nodes-learningsuite 1.3.0 → 1.3.1

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.
@@ -4,4 +4,5 @@ type LoadOptionRow = IDataObject;
4
4
  export declare function toOptions(rows: LoadOptionRow[], labelKeys?: string[], valueKeys?: string[]): INodePropertyOptions[];
5
5
  export declare function ensureArray<T>(res: T | T[]): T[];
6
6
  export declare function fetchOptions(this: ILoadOptionsFunctions, endpoint: string, qs?: IDataObject, labelKeys?: string[], valueKeys?: string[]): Promise<INodePropertyOptions[]>;
7
+ export declare function fetchOptionsAll(this: ILoadOptionsFunctions, endpoint: string, qs?: IDataObject, labelKeys?: string[], valueKeys?: string[]): Promise<INodePropertyOptions[]>;
7
8
  export {};
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toOptions = toOptions;
4
4
  exports.ensureArray = ensureArray;
5
5
  exports.fetchOptions = fetchOptions;
6
+ exports.fetchOptionsAll = fetchOptionsAll;
6
7
  const shared_1 = require("../../shared");
7
8
  function toOptions(rows, labelKeys = ['name', 'title', 'email'], valueKeys = ['id', 'sid', 'slug']) {
8
9
  return rows.map((r) => {
@@ -20,3 +21,7 @@ async function fetchOptions(endpoint, qs, labelKeys, valueKeys) {
20
21
  const rows = ensureArray(res);
21
22
  return toOptions(rows, labelKeys, valueKeys);
22
23
  }
24
+ async function fetchOptionsAll(endpoint, qs, labelKeys, valueKeys) {
25
+ const rows = await shared_1.lsRequestAll.call(this, endpoint, { qs });
26
+ return toOptions(rows, labelKeys, valueKeys);
27
+ }
@@ -31,16 +31,15 @@ function getMediaFieldDetails(fieldType, typeDefinition, cardName) {
31
31
  return [typeLabel, getMediaFieldMaxInfo(fieldType, typeDefinition), cardName].filter(Boolean).join(', ');
32
32
  }
33
33
  async function customFields_getCards() {
34
- return common_1.fetchOptions.call(this, '/custom-fields/cards', undefined, ['name', 'title'], ['id']);
34
+ return common_1.fetchOptionsAll.call(this, '/custom-fields/cards', undefined, ['name', 'title'], ['id']);
35
35
  }
36
36
  async function customFields_getDefinitions() {
37
37
  const cardId = this.getCurrentNodeParameter('cardId');
38
38
  const customFieldCardId = this.getCurrentNodeParameter('customFieldCardId');
39
39
  const filterCardId = cardId || customFieldCardId;
40
- const res = await shared_1.lsRequest.call(this, 'GET', '/custom-fields/definitions', {
40
+ const definitions = await shared_1.lsRequestAll.call(this, '/custom-fields/definitions', {
41
41
  qs: filterCardId ? { customFieldCardId: filterCardId } : undefined,
42
42
  });
43
- const definitions = Array.isArray(res) ? res : [res];
44
43
  return definitions
45
44
  .filter((definition) => typeof definition === 'object' && definition !== null)
46
45
  .map((definition) => {
@@ -62,10 +61,7 @@ async function customFields_getDefinitions() {
62
61
  }
63
62
  async function customFields_getMediaDefinitions() {
64
63
  var _a, _b, _c, _d, _e;
65
- const cards = await shared_1.lsRequest.call(this, 'GET', '/custom-fields/cards/expanded');
66
- if (!Array.isArray(cards)) {
67
- return [];
68
- }
64
+ const cards = await shared_1.lsRequestAll.call(this, '/custom-fields/cards/expanded');
69
65
  const options = [];
70
66
  for (const card of cards) {
71
67
  if (typeof card !== 'object' || card === null)
@@ -95,7 +91,7 @@ async function customFields_getMediaDefinitions() {
95
91
  }
96
92
  async function customFields_getCategories() {
97
93
  const customFieldCardId = this.getCurrentNodeParameter('customFieldCardId');
98
- return common_1.fetchOptions.call(this, '/custom-fields/categories', customFieldCardId ? { customFieldCardId } : undefined, ['name', 'title'], ['id']);
94
+ return common_1.fetchOptionsAll.call(this, '/custom-fields/categories', customFieldCardId ? { customFieldCardId } : undefined, ['name', 'title'], ['id']);
99
95
  }
100
96
  async function customFields_getFieldType() {
101
97
  const fieldKey = this.getCurrentNodeParameter('fieldKey');
@@ -6,10 +6,7 @@ exports.getLsSimpleType = getLsSimpleType;
6
6
  const request_1 = require("./request");
7
7
  const customFields_shared_1 = require("./customFields.shared");
8
8
  async function fetchFieldDefinition(ctx, fieldKey) {
9
- const cards = await request_1.lsRequest.call(ctx, 'GET', '/custom-fields/cards/expanded');
10
- if (!Array.isArray(cards)) {
11
- return undefined;
12
- }
9
+ const cards = await request_1.lsRequestAll.call(ctx, '/custom-fields/cards/expanded');
13
10
  for (const card of cards) {
14
11
  if (!(0, customFields_shared_1.isLsCard)(card) || !Array.isArray(card.definitions)) {
15
12
  continue;
@@ -11,3 +11,6 @@ export declare function apiRequest(this: ApiThis, { method, path, qs, body, }: {
11
11
  qs?: IDataObject;
12
12
  body?: IDataObject;
13
13
  }): Promise<IDataObject | IDataObject[]>;
14
+ export declare function lsRequestAll(this: ApiThis, endpoint: string, { qs }?: {
15
+ qs?: IDataObject;
16
+ }): Promise<IDataObject[]>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeEndpoint = normalizeEndpoint;
4
4
  exports.lsRequest = lsRequest;
5
5
  exports.apiRequest = apiRequest;
6
+ exports.lsRequestAll = lsRequestAll;
6
7
  const n8n_workflow_1 = require("n8n-workflow");
7
8
  function hasRequestWithAuthentication(value) {
8
9
  var _a;
@@ -51,3 +52,20 @@ async function lsRequest(method, endpoint, { qs, body } = {}) {
51
52
  async function apiRequest({ method, path, qs, body, }) {
52
53
  return requestCore.call(this, { method, endpoint: path, qs, body });
53
54
  }
55
+ async function lsRequestAll(endpoint, { qs } = {}) {
56
+ const pageSize = 100;
57
+ const maxPages = 500;
58
+ const all = [];
59
+ let offset = 0;
60
+ for (let page = 0; page < maxPages; page++) {
61
+ const res = await lsRequest.call(this, 'GET', endpoint, {
62
+ qs: { ...(qs !== null && qs !== void 0 ? qs : {}), limit: pageSize, offset },
63
+ });
64
+ const rows = Array.isArray(res) ? res : res ? [res] : [];
65
+ all.push(...rows);
66
+ if (rows.length < pageSize)
67
+ break;
68
+ offset += pageSize;
69
+ }
70
+ return all;
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsebening/n8n-nodes-learningsuite",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "n8n node for LearningSuite API",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",