lamp-core-lst 2025.11.1-3.basic
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.
- package/.github/workflows/publish.yml +34 -0
- package/LICENSE.md +29 -0
- package/MANUAL.md +26 -0
- package/README.md +126 -0
- package/cli.js +2 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +311 -0
- package/dist/model/Activity.d.ts +81 -0
- package/dist/model/Activity.js +30 -0
- package/dist/model/ActivityEvent.d.ts +51 -0
- package/dist/model/ActivityEvent.js +21 -0
- package/dist/model/ActivitySpec.d.ts +38 -0
- package/dist/model/ActivitySpec.js +12 -0
- package/dist/model/Credential.d.ts +21 -0
- package/dist/model/Credential.js +12 -0
- package/dist/model/DynamicAttachment.d.ts +34 -0
- package/dist/model/DynamicAttachment.js +12 -0
- package/dist/model/Participant.d.ts +30 -0
- package/dist/model/Participant.js +12 -0
- package/dist/model/Researcher.d.ts +27 -0
- package/dist/model/Researcher.js +12 -0
- package/dist/model/ResearcherSettings.d.ts +57 -0
- package/dist/model/ResearcherSettings.js +12 -0
- package/dist/model/Sensor.d.ts +22 -0
- package/dist/model/Sensor.js +12 -0
- package/dist/model/SensorEvent.d.ts +18 -0
- package/dist/model/SensorEvent.js +12 -0
- package/dist/model/SensorSpec.d.ts +13 -0
- package/dist/model/SensorSpec.js +12 -0
- package/dist/model/Study.d.ts +24 -0
- package/dist/model/Study.js +12 -0
- package/dist/model/Type.d.ts +56 -0
- package/dist/model/Type.js +30 -0
- package/dist/model/index.d.ts +12 -0
- package/dist/model/index.js +24 -0
- package/dist/service/API.service.d.ts +12 -0
- package/dist/service/API.service.js +82 -0
- package/dist/service/Activity.service.d.ts +101 -0
- package/dist/service/Activity.service.js +756 -0
- package/dist/service/ActivityEvent.service.d.ts +46 -0
- package/dist/service/ActivityEvent.service.js +303 -0
- package/dist/service/ActivitySpec.service.d.ts +31 -0
- package/dist/service/ActivitySpec.service.js +173 -0
- package/dist/service/Credential.service.d.ts +38 -0
- package/dist/service/Credential.service.js +319 -0
- package/dist/service/Demo.d.ts +14 -0
- package/dist/service/Demo.js +24 -0
- package/dist/service/Fetch.d.ts +30 -0
- package/dist/service/Fetch.js +245 -0
- package/dist/service/Participant.service.d.ts +42 -0
- package/dist/service/Participant.service.js +312 -0
- package/dist/service/Researcher.service.d.ts +34 -0
- package/dist/service/Researcher.service.js +252 -0
- package/dist/service/ResearcherSettings.service.d.ts +16 -0
- package/dist/service/ResearcherSettings.service.js +114 -0
- package/dist/service/Sensor.service.d.ts +47 -0
- package/dist/service/Sensor.service.js +372 -0
- package/dist/service/SensorEvent.service.d.ts +44 -0
- package/dist/service/SensorEvent.service.js +302 -0
- package/dist/service/SensorSpec.service.d.ts +31 -0
- package/dist/service/SensorSpec.service.js +171 -0
- package/dist/service/Study.service.d.ts +42 -0
- package/dist/service/Study.service.js +286 -0
- package/dist/service/Type.service.d.ts +48 -0
- package/dist/service/Type.service.js +352 -0
- package/dist/service/index.d.ts +13 -0
- package/dist/service/index.js +25 -0
- package/docs/APIApi.md +82 -0
- package/docs/AccessCitation.md +11 -0
- package/docs/Activity.md +13 -0
- package/docs/ActivityApi.md +356 -0
- package/docs/ActivityEvent.md +13 -0
- package/docs/ActivityEventApi.md +251 -0
- package/docs/ActivitySpec.md +14 -0
- package/docs/ActivitySpecApi.md +222 -0
- package/docs/Credential.md +12 -0
- package/docs/CredentialApi.md +175 -0
- package/docs/Document.md +9 -0
- package/docs/DurationInterval.md +11 -0
- package/docs/DurationIntervalLegacy.md +10 -0
- package/docs/DynamicAttachment.md +14 -0
- package/docs/Error.md +8 -0
- package/docs/Metadata.md +8 -0
- package/docs/Participant.md +14 -0
- package/docs/ParticipantApi.md +312 -0
- package/docs/Researcher.md +12 -0
- package/docs/ResearcherApi.md +223 -0
- package/docs/Sensor.md +12 -0
- package/docs/SensorApi.md +356 -0
- package/docs/SensorEvent.md +11 -0
- package/docs/SensorEventApi.md +250 -0
- package/docs/SensorSpec.md +10 -0
- package/docs/SensorSpecApi.md +222 -0
- package/docs/Study.md +11 -0
- package/docs/StudyApi.md +268 -0
- package/docs/TemporalSlice.md +13 -0
- package/docs/TypeApi.md +274 -0
- package/package.json +44 -0
- package/src/index.ts +256 -0
- package/src/model/Activity.ts +93 -0
- package/src/model/ActivityEvent.ts +63 -0
- package/src/model/ActivitySpec.ts +45 -0
- package/src/model/Credential.ts +26 -0
- package/src/model/DynamicAttachment.ts +42 -0
- package/src/model/Participant.ts +37 -0
- package/src/model/Researcher.ts +33 -0
- package/src/model/ResearcherSettings.ts +65 -0
- package/src/model/Sensor.ts +27 -0
- package/src/model/SensorEvent.ts +22 -0
- package/src/model/SensorSpec.ts +16 -0
- package/src/model/Study.ts +29 -0
- package/src/model/Type.ts +68 -0
- package/src/model/index.ts +12 -0
- package/src/service/API.service.ts +29 -0
- package/src/service/Activity.service.ts +625 -0
- package/src/service/ActivityEvent.service.ts +244 -0
- package/src/service/ActivitySpec.service.ts +98 -0
- package/src/service/Credential.service.ts +268 -0
- package/src/service/Demo.ts +21 -0
- package/src/service/Fetch.ts +187 -0
- package/src/service/Participant.service.ts +217 -0
- package/src/service/Researcher.service.ts +147 -0
- package/src/service/ResearcherSettings.service.ts +62 -0
- package/src/service/Sensor.service.ts +256 -0
- package/src/service/SensorEvent.service.ts +239 -0
- package/src/service/SensorSpec.service.ts +96 -0
- package/src/service/Study.service.ts +187 -0
- package/src/service/Type.service.ts +297 -0
- package/src/service/index.ts +13 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.ActivityService = void 0;
|
|
54
|
+
var Fetch_1 = require("./Fetch");
|
|
55
|
+
var Activity_1 = require("../model/Activity");
|
|
56
|
+
var Demo_1 = require("./Demo");
|
|
57
|
+
var jsonata_1 = __importDefault(require("jsonata"));
|
|
58
|
+
var ActivityService = /** @class */ (function () {
|
|
59
|
+
function ActivityService() {
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the set of all activities.
|
|
63
|
+
*/
|
|
64
|
+
ActivityService.prototype.all = function (transform) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var auth_1, credential, output;
|
|
68
|
+
return __generator(this, function (_c) {
|
|
69
|
+
switch (_c.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
72
|
+
auth_1 = (this.configuration.authorization || ":").split(":");
|
|
73
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_1[0] && x["secret_key"] === auth_1[1]; });
|
|
74
|
+
if (credential.length === 0)
|
|
75
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
76
|
+
output = (_a = Demo_1.Demo.Activity) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
77
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
78
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
79
|
+
}
|
|
80
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/activity", this.configuration)];
|
|
81
|
+
case 1: return [2 /*return*/, (_b = (_c.sent()).data) === null || _b === void 0 ? void 0 : _b.map(function (x) {
|
|
82
|
+
return Object.assign(new Activity_1.Activity(), x);
|
|
83
|
+
})];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Get the set of all activities available to a participant, by participant identifier.
|
|
90
|
+
* @param participantId
|
|
91
|
+
*/
|
|
92
|
+
ActivityService.prototype.allByParticipant = function (participantId, transform, ignore_binary, limit, offset) {
|
|
93
|
+
var _a;
|
|
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) {
|
|
98
|
+
case 0:
|
|
99
|
+
if (participantId === null || participantId === undefined)
|
|
100
|
+
throw new Error("Required parameter participantId was null or undefined when calling activityAllByParticipant.");
|
|
101
|
+
if (ignore_binary === null || ignore_binary === undefined)
|
|
102
|
+
ignore_binary = false;
|
|
103
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
104
|
+
auth_2 = (this.configuration.authorization || ":").split(":");
|
|
105
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_2[0] && x["secret_key"] === auth_2[1]; });
|
|
106
|
+
if (credential.length === 0)
|
|
107
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
108
|
+
if (participantId === "me")
|
|
109
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
110
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
111
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { var _a; return (_a = Demo_1.Demo.Participant.filter(function (y) { return y["id"] === participantId; })) === null || _a === void 0 ? void 0 : _a.map(function (y) { return y["#parent"]; }).includes(x["#parent"]); })) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
112
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
113
|
+
total = output.length;
|
|
114
|
+
paginatedOutput = limit !== undefined && offset !== undefined
|
|
115
|
+
? output.slice(offset, offset + limit)
|
|
116
|
+
: output;
|
|
117
|
+
return [2 /*return*/, Promise.resolve({ data: paginatedOutput, total: total })];
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
params = new URLSearchParams();
|
|
124
|
+
params.append('ignore_binary', String(ignore_binary));
|
|
125
|
+
if (limit !== undefined && limit !== null) {
|
|
126
|
+
params.append('limit', limit.toString());
|
|
127
|
+
}
|
|
128
|
+
if (offset !== undefined && offset !== null) {
|
|
129
|
+
params.append('offset', offset.toString());
|
|
130
|
+
}
|
|
131
|
+
queryString = params.toString();
|
|
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 } }
|
|
134
|
+
];
|
|
135
|
+
case 1:
|
|
136
|
+
result = _b.sent();
|
|
137
|
+
activitiesArray = [];
|
|
138
|
+
totalCount = 0;
|
|
139
|
+
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
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (Array.isArray(result)) {
|
|
152
|
+
// Legacy fallback: if result is directly an array
|
|
153
|
+
activitiesArray = result;
|
|
154
|
+
totalCount = result.length;
|
|
155
|
+
}
|
|
156
|
+
return [2 /*return*/, {
|
|
157
|
+
data: activitiesArray.map(function (x) { return Object.assign(new Activity_1.Activity(), x); }),
|
|
158
|
+
total: totalCount
|
|
159
|
+
}];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Get the set of all activities available to participants of any study conducted by a researcher, by researcher identifier.
|
|
166
|
+
* @param researcherId
|
|
167
|
+
*/
|
|
168
|
+
ActivityService.prototype.allByResearcher = function (researcherId, transform) {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
+
var auth_3, credential, output;
|
|
172
|
+
return __generator(this, function (_c) {
|
|
173
|
+
switch (_c.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
if (researcherId === null || researcherId === undefined)
|
|
176
|
+
throw new Error("Required parameter researcherId was null or undefined when calling activityAllByResearcher.");
|
|
177
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
178
|
+
auth_3 = (this.configuration.authorization || ":").split(":");
|
|
179
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_3[0] && x["secret_key"] === auth_3[1]; });
|
|
180
|
+
if (credential.length === 0) {
|
|
181
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
182
|
+
}
|
|
183
|
+
if (researcherId === "me") {
|
|
184
|
+
researcherId = credential.length > 0 ? credential[0]["origin"] : researcherId;
|
|
185
|
+
}
|
|
186
|
+
if (Demo_1.Demo.Researcher.filter(function (x) { return x["id"] === researcherId; }).length > 0) {
|
|
187
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { var _a; return (_a = Demo_1.Demo.Study.filter(function (y) { return y["#parent"] === researcherId; })) === null || _a === void 0 ? void 0 : _a.map(function (y) { return y["id"]; }).includes(x["#parent"]); })) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
188
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
189
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/researcher/" + researcherId + "/activity", this.configuration)];
|
|
196
|
+
case 1: return [2 /*return*/, (_b = (_c.sent()).data) === null || _b === void 0 ? void 0 : _b.map(function (x) { return Object.assign(new Activity_1.Activity(), x); })];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Get the set of all activities available to participants of a single study, by study identifier.
|
|
203
|
+
* @param studyId
|
|
204
|
+
*/
|
|
205
|
+
ActivityService.prototype.allByStudy = function (studyId, transform, ignore_binary) {
|
|
206
|
+
var _a, _b;
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
var auth_4, credential, output;
|
|
209
|
+
return __generator(this, function (_c) {
|
|
210
|
+
switch (_c.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
if (studyId === null || studyId === undefined)
|
|
213
|
+
throw new Error("Required parameter studyId was null or undefined when calling activityAllByStudy.");
|
|
214
|
+
if (ignore_binary === null || ignore_binary === undefined)
|
|
215
|
+
ignore_binary = false;
|
|
216
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
217
|
+
auth_4 = (this.configuration.authorization || ":").split(":");
|
|
218
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_4[0] && x["secret_key"] === auth_4[1]; });
|
|
219
|
+
if (credential.length === 0)
|
|
220
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
221
|
+
if (studyId === "me")
|
|
222
|
+
studyId = credential.length > 0 ? credential[0]["origin"] : studyId;
|
|
223
|
+
if (Demo_1.Demo.Study.filter(function (x) { return x["id"] === studyId; }).length > 0) {
|
|
224
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { return x["#parent"] === studyId; })) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
225
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
226
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/study/" + studyId + "/activity?ignore_binary=" + ignore_binary, this.configuration)];
|
|
233
|
+
case 1: return [2 /*return*/, (_b = (_c.sent()).data) === null || _b === void 0 ? void 0 : _b.map(function (x) { return Object.assign(new Activity_1.Activity(), x); })];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Get the set of all activities available to participants of a single study, by participant identifier.
|
|
240
|
+
* @param participantId
|
|
241
|
+
*/
|
|
242
|
+
ActivityService.prototype.listActivities = function (participantId, tab, transform, limit, offset) {
|
|
243
|
+
var _a;
|
|
244
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
+
var auth_5, credential, output, params, queryString, result;
|
|
246
|
+
return __generator(this, function (_b) {
|
|
247
|
+
switch (_b.label) {
|
|
248
|
+
case 0:
|
|
249
|
+
if (participantId === null || participantId === undefined)
|
|
250
|
+
throw new Error("Required parameter participantId was null or undefined when calling listActivities.");
|
|
251
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
252
|
+
auth_5 = (this.configuration.authorization || ":").split(":");
|
|
253
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_5[0] && x["secret_key"] === auth_5[1]; });
|
|
254
|
+
if (credential.length === 0)
|
|
255
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
256
|
+
if (participantId === "me")
|
|
257
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
258
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
259
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { return x["#parent"] === participantId; })) === null || _a === void 0 ? void 0 : _a.map(function (x) {
|
|
260
|
+
return Object.assign(new Activity_1.Activity(), x);
|
|
261
|
+
});
|
|
262
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
263
|
+
return [2 /*return*/, Promise.resolve({ data: output, total: output.length })];
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
params = new URLSearchParams();
|
|
270
|
+
if (tab)
|
|
271
|
+
params.append("tab", tab);
|
|
272
|
+
if (typeof limit === 'number' && limit > 0)
|
|
273
|
+
params.append("limit", limit.toString());
|
|
274
|
+
if (typeof offset === 'number' && offset > 0)
|
|
275
|
+
params.append("offset", offset.toString());
|
|
276
|
+
queryString = params.toString();
|
|
277
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/activity/" + participantId + "/activity" + (queryString ? "?" + queryString : ''), this.configuration)
|
|
278
|
+
// Handle different response structures
|
|
279
|
+
];
|
|
280
|
+
case 1:
|
|
281
|
+
result = _b.sent();
|
|
282
|
+
// Handle different response structures
|
|
283
|
+
if (result && result.data !== undefined && typeof result.total === 'number') {
|
|
284
|
+
return [2 /*return*/, { data: result.data, total: result.total }];
|
|
285
|
+
}
|
|
286
|
+
// Legacy fallback: if result is directly the data object
|
|
287
|
+
if (result && !result.total) {
|
|
288
|
+
return [2 /*return*/, { data: result, total: 0 }];
|
|
289
|
+
}
|
|
290
|
+
return [2 /*return*/, { data: {}, total: 0 }];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Create a new Activity under the given Study.
|
|
297
|
+
* @param studyId
|
|
298
|
+
* @param activity
|
|
299
|
+
*/
|
|
300
|
+
ActivityService.prototype.create = function (studyId, activity) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
302
|
+
var auth_6, credential, data;
|
|
303
|
+
return __generator(this, function (_a) {
|
|
304
|
+
switch (_a.label) {
|
|
305
|
+
case 0:
|
|
306
|
+
if (studyId === null || studyId === undefined)
|
|
307
|
+
throw new Error("Required parameter studyId was null or undefined when calling activityCreate.");
|
|
308
|
+
if (activity === null || activity === undefined)
|
|
309
|
+
throw new Error("Required parameter activity was null or undefined when calling activityCreate.");
|
|
310
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
311
|
+
auth_6 = (this.configuration.authorization || ":").split(":");
|
|
312
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_6[0] && x["secret_key"] === auth_6[1]; });
|
|
313
|
+
if (credential.length === 0)
|
|
314
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
315
|
+
if (studyId === "me")
|
|
316
|
+
studyId = credential.length > 0 ? credential[0]["origin"] : studyId;
|
|
317
|
+
if (Demo_1.Demo.Study.filter(function (x) { return x["id"] === studyId; }).length > 0) {
|
|
318
|
+
data = __assign(__assign({ "#type": "Activity", "#parent": studyId }, activity), { id: "activity" + Math.random().toString().substring(2, 6) });
|
|
319
|
+
Demo_1.Demo.Activity.push(data);
|
|
320
|
+
return [2 /*return*/, Promise.resolve({ data: data["id"] })];
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return [4 /*yield*/, Fetch_1.Fetch.post("/study/" + studyId + "/activity", activity, this.configuration)];
|
|
327
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Delete an Activity.
|
|
334
|
+
* @param activityId
|
|
335
|
+
*/
|
|
336
|
+
ActivityService.prototype.delete = function (activityId) {
|
|
337
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
338
|
+
var auth_7, credential, idx;
|
|
339
|
+
return __generator(this, function (_a) {
|
|
340
|
+
switch (_a.label) {
|
|
341
|
+
case 0:
|
|
342
|
+
if (activityId === null || activityId === undefined)
|
|
343
|
+
throw new Error("Required parameter activityId was null or undefined when calling activityDelete.");
|
|
344
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
345
|
+
auth_7 = (this.configuration.authorization || ":").split(":");
|
|
346
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_7[0] && x["secret_key"] === auth_7[1]; });
|
|
347
|
+
if (credential.length === 0)
|
|
348
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
349
|
+
if (activityId === "me")
|
|
350
|
+
activityId = credential.length > 0 ? credential[0]["origin"] : activityId;
|
|
351
|
+
idx = Demo_1.Demo.Activity.findIndex(function (x) { return x["id"] === activityId; });
|
|
352
|
+
if (idx >= 0) {
|
|
353
|
+
Demo_1.Demo.Activity.splice(idx, 1);
|
|
354
|
+
Demo_1.Demo.ActivityEvent = Demo_1.Demo.ActivityEvent.filter(function (x) { return x["activity"] !== activityId; });
|
|
355
|
+
Demo_1.Demo.Credential = Demo_1.Demo.Credential.filter(function (x) { return x["#parent"] !== activityId; });
|
|
356
|
+
Demo_1.Demo.Tags = Demo_1.Demo.Tags.filter(function (x) { return x["#parent"] !== activityId && x["target"] !== activityId; });
|
|
357
|
+
return [2 /*return*/, Promise.resolve({})];
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return [4 /*yield*/, Fetch_1.Fetch.delete("/activity/" + activityId, this.configuration)];
|
|
364
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Update an Activity's settings.
|
|
371
|
+
* @param activityId
|
|
372
|
+
* @param activity
|
|
373
|
+
*/
|
|
374
|
+
ActivityService.prototype.update = function (activityId, activity) {
|
|
375
|
+
var _a;
|
|
376
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
377
|
+
var auth_8, credential, idx;
|
|
378
|
+
return __generator(this, function (_b) {
|
|
379
|
+
switch (_b.label) {
|
|
380
|
+
case 0:
|
|
381
|
+
if (activityId === null || activityId === undefined)
|
|
382
|
+
throw new Error("Required parameter activityId was null or undefined when calling activityUpdate.");
|
|
383
|
+
if (activity === null || activity === undefined)
|
|
384
|
+
throw new Error("Required parameter activity was null or undefined when calling activityUpdate.");
|
|
385
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
386
|
+
auth_8 = (this.configuration.authorization || ":").split(":");
|
|
387
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_8[0] && x["secret_key"] === auth_8[1]; });
|
|
388
|
+
if (credential.length === 0)
|
|
389
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
390
|
+
if (activityId === "me")
|
|
391
|
+
activityId = credential.length > 0 ? credential[0]["origin"] : activityId;
|
|
392
|
+
idx = Demo_1.Demo.Activity.findIndex(function (x) { return x["id"] === activityId; });
|
|
393
|
+
if (idx >= 0) {
|
|
394
|
+
Demo_1.Demo.Activity[idx] = {
|
|
395
|
+
"#type": "Activity",
|
|
396
|
+
"#parent": Demo_1.Demo.Activity[idx]["#parent"],
|
|
397
|
+
id: Demo_1.Demo.Activity[idx]["id"],
|
|
398
|
+
spec: Demo_1.Demo.Activity[idx]["spec"],
|
|
399
|
+
name: (_a = activity.name) !== null && _a !== void 0 ? _a : Demo_1.Demo.Activity[idx]["name"],
|
|
400
|
+
settings: Demo_1.Demo.Activity[idx]["spec"] === "lamp.survey" ? Demo_1.Demo.Activity[idx]["settings"] : activity.settings,
|
|
401
|
+
schedule: activity.schedule,
|
|
402
|
+
};
|
|
403
|
+
return [2 /*return*/, Promise.resolve({})];
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return [4 /*yield*/, Fetch_1.Fetch.put("/activity/" + activityId, activity, this.configuration)];
|
|
410
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Get a single activity, by identifier.
|
|
417
|
+
* @param activityId
|
|
418
|
+
*/
|
|
419
|
+
ActivityService.prototype.view = function (activityId, transform, ignore_binary) {
|
|
420
|
+
var _a;
|
|
421
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
422
|
+
var auth_9, credential, data, output, result;
|
|
423
|
+
return __generator(this, function (_b) {
|
|
424
|
+
switch (_b.label) {
|
|
425
|
+
case 0:
|
|
426
|
+
if (activityId === null || activityId === undefined)
|
|
427
|
+
throw new Error("Required parameter activityId was null or undefined when calling activityView.");
|
|
428
|
+
if (ignore_binary === null || ignore_binary === undefined)
|
|
429
|
+
ignore_binary = false;
|
|
430
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
431
|
+
auth_9 = (this.configuration.authorization || ":").split(":");
|
|
432
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_9[0] && x["secret_key"] === auth_9[1]; });
|
|
433
|
+
if (credential.length === 0)
|
|
434
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
435
|
+
if (activityId === "me")
|
|
436
|
+
activityId = credential.length > 0 ? credential[0]["origin"] : activityId;
|
|
437
|
+
data = (_a = Demo_1.Demo.Activity.filter(function (x) { return x["id"] === activityId; })) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
438
|
+
if (data.length > 0) {
|
|
439
|
+
output = data[0];
|
|
440
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
441
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/activity/" + activityId + "?ignore_binary=" + ignore_binary, this.configuration)
|
|
448
|
+
// API returns { data: Activity } (single object, not array)
|
|
449
|
+
];
|
|
450
|
+
case 1:
|
|
451
|
+
result = _b.sent();
|
|
452
|
+
// API returns { data: Activity } (single object, not array)
|
|
453
|
+
if (result && result.data) {
|
|
454
|
+
return [2 /*return*/, Object.assign(new Activity_1.Activity(), result.data)];
|
|
455
|
+
}
|
|
456
|
+
return [2 /*return*/, null];
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* Get the set of all sub-activities available to a module, by module identifier.
|
|
463
|
+
* @param moduleId
|
|
464
|
+
* @param participantId
|
|
465
|
+
*/
|
|
466
|
+
ActivityService.prototype.moduleByParticipant = function (moduleId, participantId, startTime, endTime) {
|
|
467
|
+
var _a, _b;
|
|
468
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
469
|
+
var auth_10, credential, output, params, queryString, url;
|
|
470
|
+
return __generator(this, function (_c) {
|
|
471
|
+
switch (_c.label) {
|
|
472
|
+
case 0:
|
|
473
|
+
if (participantId === null || participantId === undefined)
|
|
474
|
+
throw new Error("Required parameter participantId was null or undefined when calling moduleByParticipant.");
|
|
475
|
+
if (moduleId === null || moduleId === undefined)
|
|
476
|
+
throw new Error("Required parameter moduleId was null or undefined when calling moduleByParticipant.");
|
|
477
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
478
|
+
auth_10 = (this.configuration.authorization || ":").split(":");
|
|
479
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_10[0] && x["secret_key"] === auth_10[1]; });
|
|
480
|
+
if (credential.length === 0)
|
|
481
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
482
|
+
if (participantId === "me")
|
|
483
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
484
|
+
if (moduleId === "me")
|
|
485
|
+
moduleId = credential.length > 0 ? credential[0]["origin"] : moduleId;
|
|
486
|
+
if (Demo_1.Demo.Activity.filter(function (x) { return x["id"] === moduleId; }).length > 0) {
|
|
487
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { return x["#parent"] === moduleId; })) === null || _a === void 0 ? void 0 : _a.map(function (x) {
|
|
488
|
+
return Object.assign(new Activity_1.Activity(), x);
|
|
489
|
+
});
|
|
490
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
params = new URLSearchParams();
|
|
497
|
+
if (startTime !== undefined && startTime !== null) {
|
|
498
|
+
params.append('startTime', startTime.toString());
|
|
499
|
+
}
|
|
500
|
+
if (endTime !== undefined && endTime !== null) {
|
|
501
|
+
params.append('endTime', endTime.toString());
|
|
502
|
+
}
|
|
503
|
+
queryString = params.toString();
|
|
504
|
+
url = "/module/" + moduleId + "/" + participantId + (queryString ? "?" + queryString : '');
|
|
505
|
+
return [4 /*yield*/, Fetch_1.Fetch.get(url, this.configuration)];
|
|
506
|
+
case 1: return [2 /*return*/, (_b = (_c.sent()).data) === null || _b === void 0 ? void 0 : _b.map(function (x) { return Object.assign(new Activity_1.Activity(), x); })];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
/**
|
|
512
|
+
* Get the set of all scheduled activities available to a participant, by participant identifier.
|
|
513
|
+
* @param participantId
|
|
514
|
+
*/
|
|
515
|
+
ActivityService.prototype.scheduledActivities = function (participantId, transform, ignore_binary) {
|
|
516
|
+
var _a;
|
|
517
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
518
|
+
var auth_11, credential, output, result;
|
|
519
|
+
return __generator(this, function (_b) {
|
|
520
|
+
switch (_b.label) {
|
|
521
|
+
case 0:
|
|
522
|
+
if (participantId === null || participantId === undefined)
|
|
523
|
+
throw new Error("Required parameter participantId was null or undefined when calling activityAllByParticipant.");
|
|
524
|
+
if (ignore_binary === null || ignore_binary === undefined)
|
|
525
|
+
ignore_binary = false;
|
|
526
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
527
|
+
auth_11 = (this.configuration.authorization || ":").split(":");
|
|
528
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_11[0] && x["secret_key"] === auth_11[1]; });
|
|
529
|
+
if (credential.length === 0)
|
|
530
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
531
|
+
if (participantId === "me")
|
|
532
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
533
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
534
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { var _a; return (_a = Demo_1.Demo.Participant.filter(function (y) { return y["id"] === participantId; })) === null || _a === void 0 ? void 0 : _a.map(function (y) { return y["#parent"]; }).includes(x["#parent"]); })) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
535
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
536
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/participant/" + participantId + "/activitySchedule?ignore_binary=" + ignore_binary, this.configuration)];
|
|
543
|
+
case 1:
|
|
544
|
+
result = (_b.sent());
|
|
545
|
+
return [2 /*return*/, result];
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* Get the set of all empty tabs by participant identifier.
|
|
552
|
+
* @param participantId
|
|
553
|
+
*/
|
|
554
|
+
ActivityService.prototype.emptyTabs = function (participantId, transform) {
|
|
555
|
+
var _a;
|
|
556
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
557
|
+
var auth_12, credential, output, result;
|
|
558
|
+
return __generator(this, function (_b) {
|
|
559
|
+
switch (_b.label) {
|
|
560
|
+
case 0:
|
|
561
|
+
if (participantId === null || participantId === undefined)
|
|
562
|
+
throw new Error("Required parameter participantId was null or undefined when calling activityAllByParticipant.");
|
|
563
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
564
|
+
auth_12 = (this.configuration.authorization || ":").split(":");
|
|
565
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_12[0] && x["secret_key"] === auth_12[1]; });
|
|
566
|
+
if (credential.length === 0)
|
|
567
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
568
|
+
if (participantId === "me")
|
|
569
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
570
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
571
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { var _a; return (_a = Demo_1.Demo.Participant.filter(function (y) { return y["id"] === participantId; })) === null || _a === void 0 ? void 0 : _a.map(function (y) { return y["#parent"]; }).includes(x["#parent"]); })) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
572
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
573
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/participant/" + participantId + "/emptyTab", this.configuration)];
|
|
580
|
+
case 1:
|
|
581
|
+
result = (_b.sent());
|
|
582
|
+
return [2 /*return*/, result];
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Delete multiple activities.
|
|
589
|
+
* @param activities
|
|
590
|
+
*/
|
|
591
|
+
ActivityService.prototype.deleteActivities = function (activities) {
|
|
592
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
593
|
+
var auth, access_key_1, secret_key_1, credential_1, resolvedActivities, notFound, _loop_1, _i, resolvedActivities_1, activityId;
|
|
594
|
+
return __generator(this, function (_a) {
|
|
595
|
+
switch (_a.label) {
|
|
596
|
+
case 0:
|
|
597
|
+
if (!activities || activities.length === 0) {
|
|
598
|
+
throw new Error("Required parameter 'activities' was null, undefined, or empty when calling deleteActivities.");
|
|
599
|
+
}
|
|
600
|
+
// Check if we are in DEMO mode
|
|
601
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
602
|
+
auth = (this.configuration.authorization || ":").split(":", 2);
|
|
603
|
+
access_key_1 = auth[0], secret_key_1 = auth[1];
|
|
604
|
+
credential_1 = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === access_key_1 && x["secret_key"] === secret_key_1; });
|
|
605
|
+
// Invalid credentials
|
|
606
|
+
if (credential_1.length === 0) {
|
|
607
|
+
return [2 /*return*/, { error: "403.invalid-credentials" }];
|
|
608
|
+
}
|
|
609
|
+
resolvedActivities = activities.map(function (id) {
|
|
610
|
+
return id === "me" && credential_1[0]["origin"] ? credential_1[0]["origin"] : id;
|
|
611
|
+
});
|
|
612
|
+
notFound = [];
|
|
613
|
+
_loop_1 = function (activityId) {
|
|
614
|
+
var idx = Demo_1.Demo.Activity.findIndex(function (x) { return x["id"] === activityId; });
|
|
615
|
+
if (idx >= 0) {
|
|
616
|
+
// Remove related records
|
|
617
|
+
Demo_1.Demo.ActivityEvent = Demo_1.Demo.ActivityEvent.filter(function (x) { return x["activity"] !== activityId; });
|
|
618
|
+
Demo_1.Demo.Credential = Demo_1.Demo.Credential.filter(function (x) { return x["#parent"] !== activityId; });
|
|
619
|
+
Demo_1.Demo.Tags = Demo_1.Demo.Tags.filter(function (x) { return x["#parent"] !== activityId && x["target"] !== activityId; });
|
|
620
|
+
// Remove the activity itself
|
|
621
|
+
Demo_1.Demo.Activity.splice(idx, 1);
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
notFound.push(activityId);
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
for (_i = 0, resolvedActivities_1 = resolvedActivities; _i < resolvedActivities_1.length; _i++) {
|
|
628
|
+
activityId = resolvedActivities_1[_i];
|
|
629
|
+
_loop_1(activityId);
|
|
630
|
+
}
|
|
631
|
+
// Return error if any IDs were not found
|
|
632
|
+
if (notFound.length > 0) {
|
|
633
|
+
return [2 /*return*/, { error: "404.not-found: " + notFound.join(", ") }];
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return [4 /*yield*/, Fetch_1.Fetch.delete("/activities", this.configuration, activities)];
|
|
637
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* Get the set of all sub-activities available to a module in participant feed, by module identifier,participant Identifier,startTime and EndTime.
|
|
644
|
+
* @param participantId
|
|
645
|
+
* @param modules
|
|
646
|
+
*/
|
|
647
|
+
ActivityService.prototype.feedModules = function (participantId, modules) {
|
|
648
|
+
var _a, _b;
|
|
649
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
650
|
+
var auth_13, credential, output;
|
|
651
|
+
return __generator(this, function (_c) {
|
|
652
|
+
switch (_c.label) {
|
|
653
|
+
case 0:
|
|
654
|
+
if (participantId === null || participantId === undefined)
|
|
655
|
+
throw new Error("Required parameter participantId was null or undefined when calling feedModules.");
|
|
656
|
+
if (modules === null || modules === undefined)
|
|
657
|
+
throw new Error("Required parameter modules was null or undefined when calling feedModules.");
|
|
658
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
659
|
+
auth_13 = (this.configuration.authorization || ":").split(":");
|
|
660
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_13[0] && x["secret_key"] === auth_13[1]; });
|
|
661
|
+
if (credential.length === 0)
|
|
662
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
663
|
+
if (participantId === "me")
|
|
664
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
665
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
666
|
+
output = (_a = Demo_1.Demo.Activity.filter(function (x) { var _a; return (_a = Demo_1.Demo.Participant.filter(function (y) { return y["id"] === participantId; })) === null || _a === void 0 ? void 0 : _a.map(function (y) { return y["#parent"]; }).includes(x["#parent"]); })) === null || _a === void 0 ? void 0 : _a.map(function (x) { return Object.assign(new Activity_1.Activity(), x); });
|
|
667
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return [4 /*yield*/, Fetch_1.Fetch.post("/feed/module/" + participantId, this.configuration)];
|
|
674
|
+
case 1: return [2 /*return*/, (_b = (_c.sent()).data) === null || _b === void 0 ? void 0 : _b.map(function (x) {
|
|
675
|
+
return Object.assign(new Activity_1.Activity(), x);
|
|
676
|
+
})];
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
682
|
+
* Get the list of favorite activity IDs for a participant.
|
|
683
|
+
* Returns custom selected activity IDs if Researcher_settings choice is "custom",
|
|
684
|
+
* otherwise returns the last 10 activity IDs most recently added to lamp.dashboard.favorite_activities tag.
|
|
685
|
+
* @param participantId
|
|
686
|
+
* @param transform
|
|
687
|
+
*/
|
|
688
|
+
ActivityService.prototype.favoriteActivityIds = function (participantId, transform) {
|
|
689
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
690
|
+
var auth_14, credential, output_1, result, output;
|
|
691
|
+
return __generator(this, function (_a) {
|
|
692
|
+
switch (_a.label) {
|
|
693
|
+
case 0:
|
|
694
|
+
if (participantId === null || participantId === undefined)
|
|
695
|
+
throw new Error("Required parameter participantId was null or undefined when calling favoriteActivityIds.");
|
|
696
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
697
|
+
auth_14 = (this.configuration.authorization || ":").split(":");
|
|
698
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_14[0] && x["secret_key"] === auth_14[1]; });
|
|
699
|
+
if (credential.length === 0)
|
|
700
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
701
|
+
if (participantId === "me")
|
|
702
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
703
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
704
|
+
output_1 = [];
|
|
705
|
+
output_1 = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output_1) : output_1;
|
|
706
|
+
return [2 /*return*/, Promise.resolve(output_1)];
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/participant/" + participantId + "/favorite_activities", this.configuration)];
|
|
713
|
+
case 1:
|
|
714
|
+
result = _a.sent();
|
|
715
|
+
output = result.data || [];
|
|
716
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
717
|
+
return [2 /*return*/, output];
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
/**
|
|
723
|
+
* Get feed details (schedule window entries with completion) for a participant and optional date (ms since epoch).
|
|
724
|
+
* @param participantId
|
|
725
|
+
* @param dateMs optional UTC ms for the day to fetch; defaults to today if omitted
|
|
726
|
+
*/
|
|
727
|
+
ActivityService.prototype.feedDetails = function (participantId, dateMs) {
|
|
728
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
729
|
+
var auth_15, credential, tzOffsetMinutes, url, result;
|
|
730
|
+
return __generator(this, function (_a) {
|
|
731
|
+
switch (_a.label) {
|
|
732
|
+
case 0:
|
|
733
|
+
if (participantId === null || participantId === undefined)
|
|
734
|
+
throw new Error("Required parameter participantId was null or undefined when calling feedDetails.");
|
|
735
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
736
|
+
auth_15 = (this.configuration.authorization || ":").split(":");
|
|
737
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_15[0] && x["secret_key"] === auth_15[1]; });
|
|
738
|
+
if (credential.length === 0)
|
|
739
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
740
|
+
if (participantId === "me")
|
|
741
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
742
|
+
return [2 /*return*/, []];
|
|
743
|
+
}
|
|
744
|
+
tzOffsetMinutes = new Date().getTimezoneOffset();
|
|
745
|
+
url = "/participant/" + participantId + "/feedDetails?date=" + dateMs + "&tzOffsetMinutes=" + tzOffsetMinutes;
|
|
746
|
+
return [4 /*yield*/, Fetch_1.Fetch.get(url, this.configuration)];
|
|
747
|
+
case 1:
|
|
748
|
+
result = _a.sent();
|
|
749
|
+
return [2 /*return*/, result.data || {}];
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
};
|
|
754
|
+
return ActivityService;
|
|
755
|
+
}());
|
|
756
|
+
exports.ActivityService = ActivityService;
|