lamp-core-lst 2025.11.1-3.basic → 2025.11.14

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.
@@ -90,11 +90,11 @@ var ActivityService = /** @class */ (function () {
90
90
  * @param participantId
91
91
  */
92
92
  ActivityService.prototype.allByParticipant = function (participantId, transform, ignore_binary, limit, offset) {
93
- var _a;
93
+ var _a, _b, _c;
94
94
  return __awaiter(this, void 0, void 0, function () {
95
- var auth_2, credential, output, total, paginatedOutput, params, queryString, result, activitiesArray, totalCount, responseData;
96
- return __generator(this, function (_b) {
97
- switch (_b.label) {
95
+ var auth_2, credential, output, total, paginatedOutput, params, queryString, result, activitiesArray, totalCount;
96
+ return __generator(this, function (_d) {
97
+ switch (_d.label) {
98
98
  case 0:
99
99
  if (participantId === null || participantId === undefined)
100
100
  throw new Error("Required parameter participantId was null or undefined when calling activityAllByParticipant.");
@@ -130,23 +130,19 @@ var ActivityService = /** @class */ (function () {
130
130
  }
131
131
  queryString = params.toString();
132
132
  return [4 /*yield*/, Fetch_1.Fetch.get("/participant/" + participantId + "/activity?" + queryString, this.configuration)
133
- // Handle the response structure - API returns { data: { data: Activity[], total: number } }
133
+ // Handle the response structure:
134
+ // - With pagination: { data: Activity[], total: number }
135
+ // - Without pagination: { data: Activity[] } (backward compatible)
134
136
  ];
135
137
  case 1:
136
- result = _b.sent();
138
+ result = _d.sent();
137
139
  activitiesArray = [];
138
140
  totalCount = 0;
139
141
  if (result && result.data) {
140
- responseData = result.data;
141
- if (Array.isArray(responseData.data)) {
142
- activitiesArray = responseData.data;
143
- totalCount = responseData.total || 0;
144
- }
145
- else if (Array.isArray(responseData)) {
146
- // Fallback: if responseData is directly an array
147
- activitiesArray = responseData;
148
- totalCount = responseData.length;
149
- }
142
+ // result.data is always an array
143
+ activitiesArray = Array.isArray(result.data) ? result.data : [];
144
+ // total exists only when pagination was provided
145
+ totalCount = typeof ((_b = result.data) === null || _b === void 0 ? void 0 : _b.total) === 'number' ? (_c = result.data) === null || _c === void 0 ? void 0 : _c.total : activitiesArray.length;
150
146
  }
151
147
  else if (Array.isArray(result)) {
152
148
  // Legacy fallback: if result is directly an array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lamp-core-lst",
3
- "version": "2025.11.1-3.basic",
3
+ "version": "2025.11.14",
4
4
  "author": "BIDMC Division of Digital Psychiatry <team@digitalpsych.org>",
5
5
  "description": "The JavaScript and TypeScript API client for the LAMP Platform.",
6
6
  "homepage": "https://docs.lamp.digital/",
@@ -73,26 +73,22 @@ export class ActivityService {
73
73
  params.append('offset', offset.toString())
74
74
  }
75
75
  const queryString = params.toString()
76
- const result: any = await Fetch.get<{ data: { data: Activity[], total: number } }>(
76
+ const result: any = await Fetch.get<{ data: Activity[] | { data: Activity[], total: number } }>(
77
77
  `/participant/${participantId}/activity?${queryString}`,
78
78
  this.configuration
79
79
  )
80
80
 
81
- // Handle the response structure - API returns { data: { data: Activity[], total: number } }
81
+ // Handle the response structure:
82
+ // - With pagination: { data: Activity[], total: number }
83
+ // - Without pagination: { data: Activity[] } (backward compatible)
82
84
  let activitiesArray: any[] = []
83
85
  let totalCount = 0
84
86
 
85
87
  if (result && result.data) {
86
- // API wraps response in { data: { data: Activity[], total: number } }
87
- const responseData = result.data
88
- if (Array.isArray(responseData.data)) {
89
- activitiesArray = responseData.data
90
- totalCount = responseData.total || 0
91
- } else if (Array.isArray(responseData)) {
92
- // Fallback: if responseData is directly an array
93
- activitiesArray = responseData
94
- totalCount = responseData.length
95
- }
88
+ // result.data is always an array
89
+ activitiesArray = Array.isArray(result.data) ? result.data : []
90
+ // total exists only when pagination was provided
91
+ totalCount = typeof result.data?.total === 'number' ? result.data?.total : activitiesArray.length
96
92
  } else if (Array.isArray(result)) {
97
93
  // Legacy fallback: if result is directly an array
98
94
  activitiesArray = result