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,302 @@
|
|
|
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.SensorEventService = void 0;
|
|
54
|
+
var Fetch_1 = require("./Fetch");
|
|
55
|
+
var SensorEvent_1 = require("../model/SensorEvent");
|
|
56
|
+
var Demo_1 = require("./Demo");
|
|
57
|
+
var jsonata_1 = __importDefault(require("jsonata"));
|
|
58
|
+
var SensorEventService = /** @class */ (function () {
|
|
59
|
+
function SensorEventService() {
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the set of all sensor events produced by the given participant.
|
|
63
|
+
* @param participantId
|
|
64
|
+
* @param origin
|
|
65
|
+
* @param from
|
|
66
|
+
* @param to
|
|
67
|
+
*/
|
|
68
|
+
SensorEventService.prototype.allByParticipant = function (participantId, origin, from, to, limit, transform) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
+
var queryParameters, auth_1, credential, output;
|
|
72
|
+
return __generator(this, function (_c) {
|
|
73
|
+
switch (_c.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
if (participantId === null || participantId === undefined)
|
|
76
|
+
throw new Error("Required parameter participantId was null or undefined when calling sensorEventAllByParticipant.");
|
|
77
|
+
queryParameters = new URLSearchParams();
|
|
78
|
+
if (origin !== undefined && origin !== null)
|
|
79
|
+
queryParameters.set("origin", origin);
|
|
80
|
+
if (from !== undefined && from !== null)
|
|
81
|
+
queryParameters.set("from", from);
|
|
82
|
+
if (to !== undefined && to !== null)
|
|
83
|
+
queryParameters.set("to", to);
|
|
84
|
+
if (limit !== undefined && limit !== null)
|
|
85
|
+
queryParameters.set("limit", limit);
|
|
86
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
87
|
+
auth_1 = (this.configuration.authorization || ":").split(":");
|
|
88
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_1[0] && x["secret_key"] === auth_1[1]; });
|
|
89
|
+
if (credential.length === 0)
|
|
90
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
91
|
+
if (participantId === "me")
|
|
92
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
93
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
94
|
+
output = Demo_1.Demo.SensorEvent.filter(function (x) { return x["#parent"] === participantId && (!!origin ? x["sensor"] === origin : true); }).map(function (x) { return Object.assign(new SensorEvent_1.SensorEvent(), x); });
|
|
95
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
96
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/participant/" + participantId + "/sensor_event?" + queryParameters.toString(), this.configuration)];
|
|
103
|
+
case 1: return [2 /*return*/, (_b = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.map(function (x) { return Object.assign(new SensorEvent_1.SensorEvent(), x); })];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Get the set of all sensor events produced by participants of any study conducted by a researcher, by researcher identifier.
|
|
110
|
+
* @param researcherId
|
|
111
|
+
* @param origin
|
|
112
|
+
* @param from
|
|
113
|
+
* @param to
|
|
114
|
+
*/
|
|
115
|
+
SensorEventService.prototype.allByResearcher = function (researcherId, origin, from, to, limit, transform) {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var queryParameters, auth_2, credential, participants, fn_1, output;
|
|
119
|
+
return __generator(this, function (_c) {
|
|
120
|
+
switch (_c.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
if (researcherId === null || researcherId === undefined)
|
|
123
|
+
throw new Error("Required parameter researcherId was null or undefined when calling sensorEventAllByResearcher.");
|
|
124
|
+
queryParameters = new URLSearchParams();
|
|
125
|
+
if (origin !== undefined && origin !== null)
|
|
126
|
+
queryParameters.set("origin", origin);
|
|
127
|
+
if (from !== undefined && from !== null)
|
|
128
|
+
queryParameters.set("from", from);
|
|
129
|
+
if (to !== undefined && to !== null)
|
|
130
|
+
queryParameters.set("to", to);
|
|
131
|
+
if (limit !== undefined && limit !== null)
|
|
132
|
+
queryParameters.set("limit", limit);
|
|
133
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
134
|
+
auth_2 = (this.configuration.authorization || ":").split(":");
|
|
135
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_2[0] && x["secret_key"] === auth_2[1]; });
|
|
136
|
+
if (credential.length === 0)
|
|
137
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
138
|
+
if (researcherId === "me")
|
|
139
|
+
researcherId = credential.length > 0 ? credential[0]["origin"] : researcherId;
|
|
140
|
+
if (Demo_1.Demo.Researcher.filter(function (x) { return x["id"] === researcherId; }).length > 0) {
|
|
141
|
+
participants = Demo_1.Demo.Study.filter(function (x) { return x["#parent"] === researcherId; })
|
|
142
|
+
.map(function (x) { return Demo_1.Demo.Participant.filter(function (y) { return y["#parent"] === x["id"]; }); })
|
|
143
|
+
.flat(1);
|
|
144
|
+
fn_1 = function (id) {
|
|
145
|
+
return Demo_1.Demo.SensorEvent.filter(function (x) { return x["#parent"] === id && (!!origin ? x["sensor"] === origin : true); }).map(function (x) {
|
|
146
|
+
return Object.assign(new SensorEvent_1.SensorEvent(), x);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
output = participants.reduce(function (all, participant) {
|
|
150
|
+
var _a;
|
|
151
|
+
return (__assign(__assign({}, all), (_a = {}, _a[participant["id"]] = fn_1(participant["id"]), _a)));
|
|
152
|
+
}, {});
|
|
153
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
154
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/researcher/" + researcherId + "/sensor_event?" + queryParameters.toString(), this.configuration)];
|
|
161
|
+
case 1: return [2 /*return*/, (_b = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.map(function (x) { return Object.assign(new SensorEvent_1.SensorEvent(), x); })];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Get the set of all sensor events produced by participants participants of a single study, by study identifier.
|
|
168
|
+
* @param studyId
|
|
169
|
+
* @param origin
|
|
170
|
+
* @param from
|
|
171
|
+
* @param to
|
|
172
|
+
*/
|
|
173
|
+
SensorEventService.prototype.allByStudy = function (studyId, origin, from, to, limit, transform) {
|
|
174
|
+
var _a, _b;
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
var queryParameters, auth_3, credential, participants, fn_2, output;
|
|
177
|
+
return __generator(this, function (_c) {
|
|
178
|
+
switch (_c.label) {
|
|
179
|
+
case 0:
|
|
180
|
+
if (studyId === null || studyId === undefined)
|
|
181
|
+
throw new Error("Required parameter studyId was null or undefined when calling sensorEventAllByStudy.");
|
|
182
|
+
queryParameters = new URLSearchParams();
|
|
183
|
+
if (origin !== undefined && origin !== null)
|
|
184
|
+
queryParameters.set("origin", origin);
|
|
185
|
+
if (from !== undefined && from !== null)
|
|
186
|
+
queryParameters.set("from", from);
|
|
187
|
+
if (to !== undefined && to !== null)
|
|
188
|
+
queryParameters.set("to", to);
|
|
189
|
+
if (limit !== undefined && limit !== null)
|
|
190
|
+
queryParameters.set("limit", limit);
|
|
191
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
192
|
+
auth_3 = (this.configuration.authorization || ":").split(":");
|
|
193
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_3[0] && x["secret_key"] === auth_3[1]; });
|
|
194
|
+
if (credential.length === 0)
|
|
195
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
196
|
+
if (studyId === "me")
|
|
197
|
+
studyId = credential.length > 0 ? credential[0]["origin"] : studyId;
|
|
198
|
+
if (Demo_1.Demo.Study.filter(function (x) { return x["id"] === studyId; }).length > 0) {
|
|
199
|
+
participants = Demo_1.Demo.Participant.filter(function (x) { return x["#parent"] === studyId; });
|
|
200
|
+
fn_2 = function (id) {
|
|
201
|
+
return Demo_1.Demo.SensorEvent.filter(function (x) { return x["#parent"] === id && (!!origin ? x["sensor"] === origin : true); }).map(function (x) {
|
|
202
|
+
return Object.assign(new SensorEvent_1.SensorEvent(), x);
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
output = participants.reduce(function (all, participant) {
|
|
206
|
+
var _a;
|
|
207
|
+
return (__assign(__assign({}, all), (_a = {}, _a[participant["id"]] = fn_2(participant["id"]), _a)));
|
|
208
|
+
}, {});
|
|
209
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
210
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/study/" + studyId + "/sensor_event?" + queryParameters.toString(), this.configuration)];
|
|
217
|
+
case 1: return [2 /*return*/, (_b = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.map(function (x) { return Object.assign(new SensorEvent_1.SensorEvent(), x); })];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Create a new SensorEvent for the given Participant.
|
|
224
|
+
* @param participantId
|
|
225
|
+
* @param sensorEvent
|
|
226
|
+
*/
|
|
227
|
+
SensorEventService.prototype.create = function (participantId, sensorEvent) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var auth_4, credential;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
if (participantId === null || participantId === undefined)
|
|
234
|
+
throw new Error("Required parameter participantId was null or undefined when calling sensorEventCreate.");
|
|
235
|
+
if (sensorEvent === null || sensorEvent === undefined)
|
|
236
|
+
throw new Error("Required parameter sensorEvent was null or undefined when calling sensorEventCreate.");
|
|
237
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
238
|
+
auth_4 = (this.configuration.authorization || ":").split(":");
|
|
239
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_4[0] && x["secret_key"] === auth_4[1]; });
|
|
240
|
+
if (credential.length === 0)
|
|
241
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
242
|
+
if (participantId === "me")
|
|
243
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
244
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
245
|
+
Demo_1.Demo.SensorEvent.push(__assign({ "#type": "SensorEvent", "#parent": participantId }, sensorEvent));
|
|
246
|
+
return [2 /*return*/, Promise.resolve({})];
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return [4 /*yield*/, Fetch_1.Fetch.post("/participant/" + participantId + "/sensor_event", sensorEvent, this.configuration)];
|
|
253
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Delete a sensor event.
|
|
260
|
+
* @param participantId
|
|
261
|
+
* @param origin
|
|
262
|
+
* @param from
|
|
263
|
+
* @param to
|
|
264
|
+
*/
|
|
265
|
+
SensorEventService.prototype.delete = function (participantId, origin, from, to) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
267
|
+
var queryParameters, auth_5, credential;
|
|
268
|
+
return __generator(this, function (_a) {
|
|
269
|
+
switch (_a.label) {
|
|
270
|
+
case 0:
|
|
271
|
+
if (participantId === null || participantId === undefined)
|
|
272
|
+
throw new Error("Required parameter participantId was null or undefined when calling sensorEventDelete.");
|
|
273
|
+
queryParameters = new URLSearchParams();
|
|
274
|
+
if (origin !== undefined && origin !== null)
|
|
275
|
+
queryParameters.set("origin", origin);
|
|
276
|
+
if (from !== undefined && from !== null)
|
|
277
|
+
queryParameters.set("from", from);
|
|
278
|
+
if (to !== undefined && to !== null)
|
|
279
|
+
queryParameters.set("to", to);
|
|
280
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
281
|
+
auth_5 = (this.configuration.authorization || ":").split(":");
|
|
282
|
+
credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_5[0] && x["secret_key"] === auth_5[1]; });
|
|
283
|
+
if (credential.length === 0)
|
|
284
|
+
return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
|
|
285
|
+
if (participantId === "me")
|
|
286
|
+
participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
|
|
287
|
+
if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
|
|
288
|
+
return [2 /*return*/, Promise.resolve({ error: "500.demo-restriction" })];
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return [4 /*yield*/, Fetch_1.Fetch.delete("/participant/" + participantId + "/sensor_event?" + queryParameters.toString(), this.configuration)];
|
|
295
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
return SensorEventService;
|
|
301
|
+
}());
|
|
302
|
+
exports.SensorEventService = SensorEventService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Configuration } from "./Fetch";
|
|
2
|
+
import { Identifier } from "../model/Type";
|
|
3
|
+
import { SensorSpec } from "../model/SensorSpec";
|
|
4
|
+
export declare class SensorSpecService {
|
|
5
|
+
configuration?: Configuration;
|
|
6
|
+
/**
|
|
7
|
+
* Get all SensorSpecs registered by any Researcher.
|
|
8
|
+
*/
|
|
9
|
+
all(transform?: string): Promise<SensorSpec[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new SensorSpec.
|
|
12
|
+
* @param sensorSpec
|
|
13
|
+
*/
|
|
14
|
+
create(sensorSpec: SensorSpec): Promise<Identifier>;
|
|
15
|
+
/**
|
|
16
|
+
* Delete an SensorSpec.
|
|
17
|
+
* @param sensorSpecName
|
|
18
|
+
*/
|
|
19
|
+
delete(sensorSpecName: string): Promise<Identifier>;
|
|
20
|
+
/**
|
|
21
|
+
* Update an SensorSpec.
|
|
22
|
+
* @param sensorSpecName
|
|
23
|
+
* @param sensorSpec
|
|
24
|
+
*/
|
|
25
|
+
update(sensorSpecName: string, sensorSpec: SensorSpec): Promise<Identifier>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a SensorSpec.
|
|
28
|
+
* @param sensorSpecName
|
|
29
|
+
*/
|
|
30
|
+
view(sensorSpecName: string, transform?: string): Promise<SensorSpec>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.SensorSpecService = void 0;
|
|
43
|
+
var Fetch_1 = require("./Fetch");
|
|
44
|
+
var SensorSpec_1 = require("../model/SensorSpec");
|
|
45
|
+
var Demo_1 = require("./Demo");
|
|
46
|
+
var jsonata_1 = __importDefault(require("jsonata"));
|
|
47
|
+
var SensorSpecService = /** @class */ (function () {
|
|
48
|
+
function SensorSpecService() {
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get all SensorSpecs registered by any Researcher.
|
|
52
|
+
*/
|
|
53
|
+
SensorSpecService.prototype.all = function (transform) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
+
var output;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
60
|
+
output = Demo_1.Demo.SensorSpec.map(function (x) { return Object.assign(new SensorSpec_1.SensorSpec(), x); });
|
|
61
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
62
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
63
|
+
}
|
|
64
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/sensor_spec", this.configuration)];
|
|
65
|
+
case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
|
|
66
|
+
return Object.assign(new SensorSpec_1.SensorSpec(), x);
|
|
67
|
+
})];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Create a new SensorSpec.
|
|
74
|
+
* @param sensorSpec
|
|
75
|
+
*/
|
|
76
|
+
SensorSpecService.prototype.create = function (sensorSpec) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
if (sensorSpec === null || sensorSpec === undefined)
|
|
82
|
+
throw new Error("Required parameter sensorSpec was null or undefined when calling sensorSpecCreate.");
|
|
83
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
84
|
+
// DEMO
|
|
85
|
+
return [2 /*return*/, Promise.resolve({ error: "500.demo-restriction" })];
|
|
86
|
+
}
|
|
87
|
+
return [4 /*yield*/, Fetch_1.Fetch.post("/sensor_spec", sensorSpec, this.configuration)];
|
|
88
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Delete an SensorSpec.
|
|
95
|
+
* @param sensorSpecName
|
|
96
|
+
*/
|
|
97
|
+
SensorSpecService.prototype.delete = function (sensorSpecName) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
if (sensorSpecName === null || sensorSpecName === undefined)
|
|
103
|
+
throw new Error("Required parameter sensorSpecName was null or undefined when calling sensorSpecDelete.");
|
|
104
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
105
|
+
// DEMO
|
|
106
|
+
return [2 /*return*/, Promise.resolve({ error: "500.demo-restriction" })];
|
|
107
|
+
}
|
|
108
|
+
return [4 /*yield*/, Fetch_1.Fetch.delete("/sensor_spec/" + sensorSpecName, this.configuration)];
|
|
109
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Update an SensorSpec.
|
|
116
|
+
* @param sensorSpecName
|
|
117
|
+
* @param sensorSpec
|
|
118
|
+
*/
|
|
119
|
+
SensorSpecService.prototype.update = function (sensorSpecName, sensorSpec) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (sensorSpecName === null || sensorSpecName === undefined)
|
|
125
|
+
throw new Error("Required parameter sensorSpecName was null or undefined when calling sensorSpecUpdate.");
|
|
126
|
+
if (sensorSpec === null || sensorSpec === undefined)
|
|
127
|
+
throw new Error("Required parameter sensorSpec was null or undefined when calling sensorSpecUpdate.");
|
|
128
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
129
|
+
// DEMO
|
|
130
|
+
return [2 /*return*/, Promise.resolve({ error: "500.demo-restriction" })];
|
|
131
|
+
}
|
|
132
|
+
return [4 /*yield*/, Fetch_1.Fetch.put("/sensor_spec/" + sensorSpecName, sensorSpec, this.configuration)];
|
|
133
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Get a SensorSpec.
|
|
140
|
+
* @param sensorSpecName
|
|
141
|
+
*/
|
|
142
|
+
SensorSpecService.prototype.view = function (sensorSpecName, transform) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
var data, output;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0:
|
|
148
|
+
if (sensorSpecName === null || sensorSpecName === undefined)
|
|
149
|
+
throw new Error("Required parameter sensorSpecName was null or undefined when calling sensorSpecView.");
|
|
150
|
+
if (this.configuration.base === "https://demo.lamp.digital") {
|
|
151
|
+
data = Demo_1.Demo.SensorSpec.filter(function (x) { return x["name"] === sensorSpecName; }).map(function (x) { return Object.assign(new SensorSpec_1.SensorSpec(), x); });
|
|
152
|
+
if (data.length > 0) {
|
|
153
|
+
output = data[0];
|
|
154
|
+
output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
|
|
155
|
+
return [2 /*return*/, Promise.resolve(output)];
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return [4 /*yield*/, Fetch_1.Fetch.get("/sensor_spec/" + sensorSpecName, this.configuration)];
|
|
162
|
+
case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
|
|
163
|
+
return Object.assign(new SensorSpec_1.SensorSpec(), x);
|
|
164
|
+
})[0]];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
return SensorSpecService;
|
|
170
|
+
}());
|
|
171
|
+
exports.SensorSpecService = SensorSpecService;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Configuration } from "./Fetch";
|
|
2
|
+
import { Identifier } from "../model/Type";
|
|
3
|
+
import { Study } from "../model/Study";
|
|
4
|
+
export declare class StudyService {
|
|
5
|
+
configuration?: Configuration;
|
|
6
|
+
/**
|
|
7
|
+
* Get the set of all studies.
|
|
8
|
+
*/
|
|
9
|
+
all(transform?: string): Promise<Study[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Get the set of studies for a single researcher.
|
|
12
|
+
* @param researcherId
|
|
13
|
+
*/
|
|
14
|
+
allByResearcher(researcherId: Identifier, transform?: string): Promise<Study[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new Study for the given Researcher.
|
|
17
|
+
* @param researcherId
|
|
18
|
+
* @param study
|
|
19
|
+
*/
|
|
20
|
+
create(researcherId: Identifier, study: Study): Promise<Identifier>;
|
|
21
|
+
/**
|
|
22
|
+
* Delete a study.
|
|
23
|
+
* @param studyId
|
|
24
|
+
*/
|
|
25
|
+
delete(studyId: Identifier): Promise<Identifier>;
|
|
26
|
+
/**
|
|
27
|
+
* Update the study.
|
|
28
|
+
* @param studyId
|
|
29
|
+
* @param study
|
|
30
|
+
*/
|
|
31
|
+
update(studyId: Identifier, study: Study): Promise<Identifier>;
|
|
32
|
+
/**
|
|
33
|
+
* Get a single study, by identifier.
|
|
34
|
+
* @param studyId
|
|
35
|
+
*/
|
|
36
|
+
view(studyId: Identifier, transform?: string): Promise<Study>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a single study, by identifier.
|
|
39
|
+
* @param studyId
|
|
40
|
+
*/
|
|
41
|
+
lookup(studyId: Identifier, mode: number, transform?: string): Promise<any>;
|
|
42
|
+
}
|