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.
Files changed (130) hide show
  1. package/.github/workflows/publish.yml +34 -0
  2. package/LICENSE.md +29 -0
  3. package/MANUAL.md +26 -0
  4. package/README.md +126 -0
  5. package/cli.js +2 -0
  6. package/dist/index.d.ts +64 -0
  7. package/dist/index.js +311 -0
  8. package/dist/model/Activity.d.ts +81 -0
  9. package/dist/model/Activity.js +30 -0
  10. package/dist/model/ActivityEvent.d.ts +51 -0
  11. package/dist/model/ActivityEvent.js +21 -0
  12. package/dist/model/ActivitySpec.d.ts +38 -0
  13. package/dist/model/ActivitySpec.js +12 -0
  14. package/dist/model/Credential.d.ts +21 -0
  15. package/dist/model/Credential.js +12 -0
  16. package/dist/model/DynamicAttachment.d.ts +34 -0
  17. package/dist/model/DynamicAttachment.js +12 -0
  18. package/dist/model/Participant.d.ts +30 -0
  19. package/dist/model/Participant.js +12 -0
  20. package/dist/model/Researcher.d.ts +27 -0
  21. package/dist/model/Researcher.js +12 -0
  22. package/dist/model/ResearcherSettings.d.ts +57 -0
  23. package/dist/model/ResearcherSettings.js +12 -0
  24. package/dist/model/Sensor.d.ts +22 -0
  25. package/dist/model/Sensor.js +12 -0
  26. package/dist/model/SensorEvent.d.ts +18 -0
  27. package/dist/model/SensorEvent.js +12 -0
  28. package/dist/model/SensorSpec.d.ts +13 -0
  29. package/dist/model/SensorSpec.js +12 -0
  30. package/dist/model/Study.d.ts +24 -0
  31. package/dist/model/Study.js +12 -0
  32. package/dist/model/Type.d.ts +56 -0
  33. package/dist/model/Type.js +30 -0
  34. package/dist/model/index.d.ts +12 -0
  35. package/dist/model/index.js +24 -0
  36. package/dist/service/API.service.d.ts +12 -0
  37. package/dist/service/API.service.js +82 -0
  38. package/dist/service/Activity.service.d.ts +101 -0
  39. package/dist/service/Activity.service.js +756 -0
  40. package/dist/service/ActivityEvent.service.d.ts +46 -0
  41. package/dist/service/ActivityEvent.service.js +303 -0
  42. package/dist/service/ActivitySpec.service.d.ts +31 -0
  43. package/dist/service/ActivitySpec.service.js +173 -0
  44. package/dist/service/Credential.service.d.ts +38 -0
  45. package/dist/service/Credential.service.js +319 -0
  46. package/dist/service/Demo.d.ts +14 -0
  47. package/dist/service/Demo.js +24 -0
  48. package/dist/service/Fetch.d.ts +30 -0
  49. package/dist/service/Fetch.js +245 -0
  50. package/dist/service/Participant.service.d.ts +42 -0
  51. package/dist/service/Participant.service.js +312 -0
  52. package/dist/service/Researcher.service.d.ts +34 -0
  53. package/dist/service/Researcher.service.js +252 -0
  54. package/dist/service/ResearcherSettings.service.d.ts +16 -0
  55. package/dist/service/ResearcherSettings.service.js +114 -0
  56. package/dist/service/Sensor.service.d.ts +47 -0
  57. package/dist/service/Sensor.service.js +372 -0
  58. package/dist/service/SensorEvent.service.d.ts +44 -0
  59. package/dist/service/SensorEvent.service.js +302 -0
  60. package/dist/service/SensorSpec.service.d.ts +31 -0
  61. package/dist/service/SensorSpec.service.js +171 -0
  62. package/dist/service/Study.service.d.ts +42 -0
  63. package/dist/service/Study.service.js +286 -0
  64. package/dist/service/Type.service.d.ts +48 -0
  65. package/dist/service/Type.service.js +352 -0
  66. package/dist/service/index.d.ts +13 -0
  67. package/dist/service/index.js +25 -0
  68. package/docs/APIApi.md +82 -0
  69. package/docs/AccessCitation.md +11 -0
  70. package/docs/Activity.md +13 -0
  71. package/docs/ActivityApi.md +356 -0
  72. package/docs/ActivityEvent.md +13 -0
  73. package/docs/ActivityEventApi.md +251 -0
  74. package/docs/ActivitySpec.md +14 -0
  75. package/docs/ActivitySpecApi.md +222 -0
  76. package/docs/Credential.md +12 -0
  77. package/docs/CredentialApi.md +175 -0
  78. package/docs/Document.md +9 -0
  79. package/docs/DurationInterval.md +11 -0
  80. package/docs/DurationIntervalLegacy.md +10 -0
  81. package/docs/DynamicAttachment.md +14 -0
  82. package/docs/Error.md +8 -0
  83. package/docs/Metadata.md +8 -0
  84. package/docs/Participant.md +14 -0
  85. package/docs/ParticipantApi.md +312 -0
  86. package/docs/Researcher.md +12 -0
  87. package/docs/ResearcherApi.md +223 -0
  88. package/docs/Sensor.md +12 -0
  89. package/docs/SensorApi.md +356 -0
  90. package/docs/SensorEvent.md +11 -0
  91. package/docs/SensorEventApi.md +250 -0
  92. package/docs/SensorSpec.md +10 -0
  93. package/docs/SensorSpecApi.md +222 -0
  94. package/docs/Study.md +11 -0
  95. package/docs/StudyApi.md +268 -0
  96. package/docs/TemporalSlice.md +13 -0
  97. package/docs/TypeApi.md +274 -0
  98. package/package.json +44 -0
  99. package/src/index.ts +256 -0
  100. package/src/model/Activity.ts +93 -0
  101. package/src/model/ActivityEvent.ts +63 -0
  102. package/src/model/ActivitySpec.ts +45 -0
  103. package/src/model/Credential.ts +26 -0
  104. package/src/model/DynamicAttachment.ts +42 -0
  105. package/src/model/Participant.ts +37 -0
  106. package/src/model/Researcher.ts +33 -0
  107. package/src/model/ResearcherSettings.ts +65 -0
  108. package/src/model/Sensor.ts +27 -0
  109. package/src/model/SensorEvent.ts +22 -0
  110. package/src/model/SensorSpec.ts +16 -0
  111. package/src/model/Study.ts +29 -0
  112. package/src/model/Type.ts +68 -0
  113. package/src/model/index.ts +12 -0
  114. package/src/service/API.service.ts +29 -0
  115. package/src/service/Activity.service.ts +625 -0
  116. package/src/service/ActivityEvent.service.ts +244 -0
  117. package/src/service/ActivitySpec.service.ts +98 -0
  118. package/src/service/Credential.service.ts +268 -0
  119. package/src/service/Demo.ts +21 -0
  120. package/src/service/Fetch.ts +187 -0
  121. package/src/service/Participant.service.ts +217 -0
  122. package/src/service/Researcher.service.ts +147 -0
  123. package/src/service/ResearcherSettings.service.ts +62 -0
  124. package/src/service/Sensor.service.ts +256 -0
  125. package/src/service/SensorEvent.service.ts +239 -0
  126. package/src/service/SensorSpec.service.ts +96 -0
  127. package/src/service/Study.service.ts +187 -0
  128. package/src/service/Type.service.ts +297 -0
  129. package/src/service/index.ts +13 -0
  130. package/tsconfig.json +29 -0
@@ -0,0 +1,16 @@
1
+ import { Configuration } from "./Fetch";
2
+ import { Identifier } from "../model/Type";
3
+ export declare class ResearcherSettingsService {
4
+ configuration?: Configuration;
5
+ /**
6
+ * Create Researcher Settings.
7
+ * @param researcherId
8
+ */
9
+ createResearcherSettings(researcherId: Identifier, researcherData: any, choice?: any): Promise<Identifier>;
10
+ /**
11
+ * Get Researcher Settings.
12
+ * @param researcherId
13
+ */
14
+ getResearcherSettings(type: string, id: Identifier): Promise<any>;
15
+ getResearcherSettingsforParticipant(participantId: Identifier): Promise<any>;
16
+ }
@@ -0,0 +1,114 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ResearcherSettingsService = void 0;
40
+ var Fetch_1 = require("./Fetch");
41
+ var ResearcherSettingsService = /** @class */ (function () {
42
+ function ResearcherSettingsService() {
43
+ }
44
+ /**
45
+ * Create Researcher Settings.
46
+ * @param researcherId
47
+ */
48
+ ResearcherSettingsService.prototype.createResearcherSettings = function (researcherId, researcherData, choice) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var res;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ if (researcherId === null || researcherId === undefined)
55
+ throw new Error("Required parameter researcherId was null or undefined when calling researcherSettingsCreate.");
56
+ if (this.configuration.base === "https://demo.lamp.digital") {
57
+ // DEMO
58
+ return [2 /*return*/, Promise.resolve({ error: "500.demo-restriction" })];
59
+ }
60
+ return [4 /*yield*/, Fetch_1.Fetch.post("/researcherSettings/" + researcherId + "?choice=" + choice, researcherData, this.configuration)];
61
+ case 1:
62
+ res = _a.sent();
63
+ return [2 /*return*/, res];
64
+ }
65
+ });
66
+ });
67
+ };
68
+ /**
69
+ * Get Researcher Settings.
70
+ * @param researcherId
71
+ */
72
+ ResearcherSettingsService.prototype.getResearcherSettings = function (type, id) {
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ var result;
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0:
78
+ if (id === null || id === undefined)
79
+ throw new Error("Required parameter id was null or undefined when calling researcherSettingsGet.");
80
+ if (this.configuration.base === "https://demo.lamp.digital") {
81
+ // DEMO
82
+ return [2 /*return*/, Promise.resolve({ error: "500.demo-restriction" })];
83
+ }
84
+ return [4 /*yield*/, Fetch_1.Fetch.get("/researcherSettings/" + type + "/" + id, this.configuration)];
85
+ case 1:
86
+ result = (_a.sent());
87
+ return [2 /*return*/, result.data];
88
+ }
89
+ });
90
+ });
91
+ };
92
+ ResearcherSettingsService.prototype.getResearcherSettingsforParticipant = function (participantId) {
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ var result;
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ if (participantId === null || participantId === undefined)
99
+ throw new Error("Required parameter researcherId was null or undefined when calling researcherSettingsGet.");
100
+ if (this.configuration.base === "https://demo.lamp.digital") {
101
+ // DEMO
102
+ return [2 /*return*/, Promise.resolve({ error: "500.demo-restriction" })];
103
+ }
104
+ return [4 /*yield*/, Fetch_1.Fetch.get("/participant/researcherSettings/" + participantId, this.configuration)];
105
+ case 1:
106
+ result = (_a.sent());
107
+ return [2 /*return*/, result.data];
108
+ }
109
+ });
110
+ });
111
+ };
112
+ return ResearcherSettingsService;
113
+ }());
114
+ exports.ResearcherSettingsService = ResearcherSettingsService;
@@ -0,0 +1,47 @@
1
+ import { Configuration } from "./Fetch";
2
+ import { Sensor } from "../model/Sensor";
3
+ import { Identifier } from "../model/Type";
4
+ export declare class SensorService {
5
+ configuration?: Configuration;
6
+ /**
7
+ * Get the set of all activities.
8
+ */
9
+ all(transform?: string): Promise<Sensor[]>;
10
+ /**
11
+ * Get the set of all activities available to a participant, by participant identifier.
12
+ * @param participantId
13
+ */
14
+ allByParticipant(participantId: Identifier, transform?: string, ignore_binary?: boolean): Promise<Sensor[]>;
15
+ /**
16
+ * Get the set of all activities available to participants of any study conducted by a researcher, by researcher identifier.
17
+ * @param researcherId
18
+ */
19
+ allByResearcher(researcherId: Identifier, transform?: string): Promise<Sensor[]>;
20
+ /**
21
+ * Get the set of all activities available to participants of a single study, by study identifier.
22
+ * @param studyId
23
+ */
24
+ allByStudy(studyId: Identifier, transform?: string, ignore_binary?: boolean): Promise<Sensor[]>;
25
+ /**
26
+ * Create a new Sensor under the given Study.
27
+ * @param studyId
28
+ * @param sensor
29
+ */
30
+ create(studyId: Identifier, sensor: Sensor): Promise<Identifier>;
31
+ /**
32
+ * Delete an Sensor.
33
+ * @param sensorId
34
+ */
35
+ delete(sensorId: Identifier): Promise<Identifier>;
36
+ /**
37
+ * Update an Sensor's settings.
38
+ * @param sensorId
39
+ * @param sensor
40
+ */
41
+ update(sensorId: Identifier, sensor: Sensor): Promise<Identifier>;
42
+ /**
43
+ * Get a single sensor, by identifier.
44
+ * @param sensorId
45
+ */
46
+ view(sensorId: Identifier, transform?: string, ignore_binary?: boolean): Promise<Sensor>;
47
+ }
@@ -0,0 +1,372 @@
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.SensorService = void 0;
54
+ var Fetch_1 = require("./Fetch");
55
+ var Sensor_1 = require("../model/Sensor");
56
+ var Demo_1 = require("./Demo");
57
+ var jsonata_1 = __importDefault(require("jsonata"));
58
+ var SensorService = /** @class */ (function () {
59
+ function SensorService() {
60
+ }
61
+ /**
62
+ * Get the set of all activities.
63
+ */
64
+ SensorService.prototype.all = function (transform) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var auth_1, credential, output;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0:
70
+ if (this.configuration.base === "https://demo.lamp.digital") {
71
+ auth_1 = (this.configuration.authorization || ":").split(":");
72
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_1[0] && x["secret_key"] === auth_1[1]; });
73
+ if (credential.length === 0)
74
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
75
+ output = Demo_1.Demo.Sensor.map(function (x) { return Object.assign(new Sensor_1.Sensor(), x); });
76
+ output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
77
+ return [2 /*return*/, Promise.resolve(output)];
78
+ }
79
+ return [4 /*yield*/, Fetch_1.Fetch.get("/sensor", this.configuration)];
80
+ case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
81
+ return Object.assign(new Sensor_1.Sensor(), x);
82
+ })];
83
+ }
84
+ });
85
+ });
86
+ };
87
+ /**
88
+ * Get the set of all activities available to a participant, by participant identifier.
89
+ * @param participantId
90
+ */
91
+ SensorService.prototype.allByParticipant = function (participantId, transform, ignore_binary) {
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var auth_2, credential, output;
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0:
97
+ if (participantId === null || participantId === undefined)
98
+ throw new Error("Required parameter participantId was null or undefined when calling sensorAllByParticipant.");
99
+ if (ignore_binary === null || ignore_binary === undefined)
100
+ ignore_binary = false;
101
+ if (this.configuration.base === "https://demo.lamp.digital") {
102
+ auth_2 = (this.configuration.authorization || ":").split(":");
103
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_2[0] && x["secret_key"] === auth_2[1]; });
104
+ if (credential.length === 0)
105
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
106
+ if (participantId === "me")
107
+ participantId = credential.length > 0 ? credential[0]["origin"] : participantId;
108
+ if (Demo_1.Demo.Participant.filter(function (x) { return x["id"] === participantId; }).length > 0) {
109
+ output = Demo_1.Demo.Sensor.filter(function (x) {
110
+ return Demo_1.Demo.Participant.filter(function (y) { return y["id"] === participantId; })
111
+ .map(function (y) { return y["#parent"]; })
112
+ .includes(x["#parent"]);
113
+ }).map(function (x) { return Object.assign(new Sensor_1.Sensor(), x); });
114
+ output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
115
+ return [2 /*return*/, Promise.resolve(output)];
116
+ }
117
+ else {
118
+ return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
119
+ }
120
+ }
121
+ return [4 /*yield*/, Fetch_1.Fetch.get("/participant/" + participantId + "/sensor?ignore_binary=" + ignore_binary, this.configuration)];
122
+ case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
123
+ return Object.assign(new Sensor_1.Sensor(), x);
124
+ })];
125
+ }
126
+ });
127
+ });
128
+ };
129
+ /**
130
+ * Get the set of all activities available to participants of any study conducted by a researcher, by researcher identifier.
131
+ * @param researcherId
132
+ */
133
+ SensorService.prototype.allByResearcher = function (researcherId, transform) {
134
+ return __awaiter(this, void 0, void 0, function () {
135
+ var auth_3, credential, output;
136
+ return __generator(this, function (_a) {
137
+ switch (_a.label) {
138
+ case 0:
139
+ if (researcherId === null || researcherId === undefined)
140
+ throw new Error("Required parameter researcherId was null or undefined when calling sensorAllByResearcher.");
141
+ if (this.configuration.base === "https://demo.lamp.digital") {
142
+ auth_3 = (this.configuration.authorization || ":").split(":");
143
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_3[0] && x["secret_key"] === auth_3[1]; });
144
+ if (credential.length === 0) {
145
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
146
+ }
147
+ if (researcherId === "me") {
148
+ researcherId = credential.length > 0 ? credential[0]["origin"] : researcherId;
149
+ }
150
+ if (Demo_1.Demo.Researcher.filter(function (x) { return x["id"] === researcherId; }).length > 0) {
151
+ output = Demo_1.Demo.Sensor.filter(function (x) {
152
+ return Demo_1.Demo.Study.filter(function (y) { return y["#parent"] === researcherId; })
153
+ .map(function (y) { return y["id"]; })
154
+ .includes(x["#parent"]);
155
+ }).map(function (x) { return Object.assign(new Sensor_1.Sensor(), x); });
156
+ output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
157
+ return [2 /*return*/, Promise.resolve(output)];
158
+ }
159
+ else {
160
+ return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
161
+ }
162
+ }
163
+ return [4 /*yield*/, Fetch_1.Fetch.get("/researcher/" + researcherId + "/sensor", this.configuration)];
164
+ case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
165
+ return Object.assign(new Sensor_1.Sensor(), x);
166
+ })];
167
+ }
168
+ });
169
+ });
170
+ };
171
+ /**
172
+ * Get the set of all activities available to participants of a single study, by study identifier.
173
+ * @param studyId
174
+ */
175
+ SensorService.prototype.allByStudy = function (studyId, transform, ignore_binary) {
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var auth_4, credential, output;
178
+ return __generator(this, function (_a) {
179
+ switch (_a.label) {
180
+ case 0:
181
+ if (studyId === null || studyId === undefined)
182
+ throw new Error("Required parameter studyId was null or undefined when calling sensorAllByStudy.");
183
+ if (ignore_binary === null || ignore_binary === undefined)
184
+ ignore_binary = false;
185
+ if (this.configuration.base === "https://demo.lamp.digital") {
186
+ auth_4 = (this.configuration.authorization || ":").split(":");
187
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_4[0] && x["secret_key"] === auth_4[1]; });
188
+ if (credential.length === 0)
189
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
190
+ if (studyId === "me")
191
+ studyId = credential.length > 0 ? credential[0]["origin"] : studyId;
192
+ if (Demo_1.Demo.Study.filter(function (x) { return x["id"] === studyId; }).length > 0) {
193
+ output = Demo_1.Demo.Sensor.filter(function (x) { return x["#parent"] === studyId; }).map(function (x) { return Object.assign(new Sensor_1.Sensor(), x); });
194
+ output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
195
+ return [2 /*return*/, Promise.resolve(output)];
196
+ }
197
+ else {
198
+ return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
199
+ }
200
+ }
201
+ return [4 /*yield*/, Fetch_1.Fetch.get("/study/" + studyId + "/sensor?ignore_binary=" + ignore_binary, this.configuration)];
202
+ case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
203
+ return Object.assign(new Sensor_1.Sensor(), x);
204
+ })];
205
+ }
206
+ });
207
+ });
208
+ };
209
+ /**
210
+ * Create a new Sensor under the given Study.
211
+ * @param studyId
212
+ * @param sensor
213
+ */
214
+ SensorService.prototype.create = function (studyId, sensor) {
215
+ return __awaiter(this, void 0, void 0, function () {
216
+ var auth_5, credential, data;
217
+ return __generator(this, function (_a) {
218
+ switch (_a.label) {
219
+ case 0:
220
+ if (studyId === null || studyId === undefined)
221
+ throw new Error("Required parameter studyId was null or undefined when calling sensorCreate.");
222
+ if (sensor === null || sensor === undefined)
223
+ throw new Error("Required parameter sensor was null or undefined when calling sensorCreate.");
224
+ if (this.configuration.base === "https://demo.lamp.digital") {
225
+ auth_5 = (this.configuration.authorization || ":").split(":");
226
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_5[0] && x["secret_key"] === auth_5[1]; });
227
+ if (credential.length === 0)
228
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
229
+ if (studyId === "me")
230
+ studyId = credential.length > 0 ? credential[0]["origin"] : studyId;
231
+ if (Demo_1.Demo.Study.filter(function (x) { return x["id"] === studyId; }).length > 0) {
232
+ data = __assign(__assign({ "#type": "Sensor", "#parent": studyId }, sensor), { id: "sensor" +
233
+ Math.random()
234
+ .toString()
235
+ .substring(2, 6) });
236
+ Demo_1.Demo.Sensor.push(data);
237
+ return [2 /*return*/, Promise.resolve({ data: data["id"] })];
238
+ }
239
+ else {
240
+ return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
241
+ }
242
+ }
243
+ return [4 /*yield*/, Fetch_1.Fetch.post("/study/" + studyId + "/sensor", sensor, this.configuration)];
244
+ case 1: return [2 /*return*/, _a.sent()];
245
+ }
246
+ });
247
+ });
248
+ };
249
+ /**
250
+ * Delete an Sensor.
251
+ * @param sensorId
252
+ */
253
+ SensorService.prototype.delete = function (sensorId) {
254
+ return __awaiter(this, void 0, void 0, function () {
255
+ var auth_6, credential, idx;
256
+ return __generator(this, function (_a) {
257
+ switch (_a.label) {
258
+ case 0:
259
+ if (sensorId === null || sensorId === undefined)
260
+ throw new Error("Required parameter sensorId was null or undefined when calling sensorDelete.");
261
+ if (this.configuration.base === "https://demo.lamp.digital") {
262
+ auth_6 = (this.configuration.authorization || ":").split(":");
263
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_6[0] && x["secret_key"] === auth_6[1]; });
264
+ if (credential.length === 0)
265
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
266
+ if (sensorId === "me")
267
+ sensorId = credential.length > 0 ? credential[0]["origin"] : sensorId;
268
+ idx = Demo_1.Demo.Sensor.findIndex(function (x) { return x["id"] === sensorId; });
269
+ if (idx >= 0) {
270
+ Demo_1.Demo.Sensor.splice(idx, 1);
271
+ Demo_1.Demo.SensorEvent = Demo_1.Demo.SensorEvent.filter(function (x) { return x["sensor"] !== sensorId; });
272
+ Demo_1.Demo.Credential = Demo_1.Demo.Credential.filter(function (x) { return x["#parent"] !== sensorId; });
273
+ Demo_1.Demo.Tags = Demo_1.Demo.Tags.filter(function (x) { return x["#parent"] !== sensorId && x["target"] !== sensorId; });
274
+ return [2 /*return*/, Promise.resolve({})];
275
+ }
276
+ else {
277
+ return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
278
+ }
279
+ }
280
+ return [4 /*yield*/, Fetch_1.Fetch.delete("/sensor/" + sensorId, this.configuration)];
281
+ case 1: return [2 /*return*/, _a.sent()];
282
+ }
283
+ });
284
+ });
285
+ };
286
+ /**
287
+ * Update an Sensor's settings.
288
+ * @param sensorId
289
+ * @param sensor
290
+ */
291
+ SensorService.prototype.update = function (sensorId, sensor) {
292
+ var _a;
293
+ return __awaiter(this, void 0, void 0, function () {
294
+ var auth_7, credential, idx;
295
+ return __generator(this, function (_b) {
296
+ switch (_b.label) {
297
+ case 0:
298
+ if (sensorId === null || sensorId === undefined)
299
+ throw new Error("Required parameter sensorId was null or undefined when calling sensorUpdate.");
300
+ if (sensor === null || sensor === undefined)
301
+ throw new Error("Required parameter sensor was null or undefined when calling sensorUpdate.");
302
+ if (this.configuration.base === "https://demo.lamp.digital") {
303
+ auth_7 = (this.configuration.authorization || ":").split(":");
304
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_7[0] && x["secret_key"] === auth_7[1]; });
305
+ if (credential.length === 0)
306
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
307
+ if (sensorId === "me")
308
+ sensorId = credential.length > 0 ? credential[0]["origin"] : sensorId;
309
+ idx = Demo_1.Demo.Sensor.findIndex(function (x) { return x["id"] === sensorId; });
310
+ if (idx >= 0) {
311
+ Demo_1.Demo.Sensor[idx] = {
312
+ "#type": "Sensor",
313
+ "#parent": Demo_1.Demo.Sensor[idx]["#parent"],
314
+ id: Demo_1.Demo.Sensor[idx]["id"],
315
+ spec: Demo_1.Demo.Sensor[idx]["spec"],
316
+ name: (_a = sensor.name) !== null && _a !== void 0 ? _a : Demo_1.Demo.Sensor[idx]["name"],
317
+ settings: sensor.settings
318
+ };
319
+ return [2 /*return*/, Promise.resolve({})];
320
+ }
321
+ else {
322
+ return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
323
+ }
324
+ }
325
+ return [4 /*yield*/, Fetch_1.Fetch.put("/sensor/" + sensorId, sensor, this.configuration)];
326
+ case 1: return [2 /*return*/, _b.sent()];
327
+ }
328
+ });
329
+ });
330
+ };
331
+ /**
332
+ * Get a single sensor, by identifier.
333
+ * @param sensorId
334
+ */
335
+ SensorService.prototype.view = function (sensorId, transform, ignore_binary) {
336
+ return __awaiter(this, void 0, void 0, function () {
337
+ var auth_8, credential, data, output;
338
+ return __generator(this, function (_a) {
339
+ switch (_a.label) {
340
+ case 0:
341
+ if (sensorId === null || sensorId === undefined)
342
+ throw new Error("Required parameter sensorId was null or undefined when calling sensorView.");
343
+ if (ignore_binary === null || ignore_binary === undefined)
344
+ ignore_binary = false;
345
+ if (this.configuration.base === "https://demo.lamp.digital") {
346
+ auth_8 = (this.configuration.authorization || ":").split(":");
347
+ credential = Demo_1.Demo.Credential.filter(function (x) { return x["access_key"] === auth_8[0] && x["secret_key"] === auth_8[1]; });
348
+ if (credential.length === 0)
349
+ return [2 /*return*/, Promise.resolve({ error: "403.invalid-credentials" })];
350
+ if (sensorId === "me")
351
+ sensorId = credential.length > 0 ? credential[0]["origin"] : sensorId;
352
+ data = Demo_1.Demo.Sensor.filter(function (x) { return x["id"] === sensorId; }).map(function (x) { return Object.assign(new Sensor_1.Sensor(), x); });
353
+ if (data.length > 0) {
354
+ output = data[0];
355
+ output = typeof transform === "string" ? jsonata_1.default(transform).evaluate(output) : output;
356
+ return [2 /*return*/, Promise.resolve(output)];
357
+ }
358
+ else {
359
+ return [2 /*return*/, Promise.resolve({ error: "404.not-found" })];
360
+ }
361
+ }
362
+ return [4 /*yield*/, Fetch_1.Fetch.get("/sensor/" + sensorId + "?ignore_binary=" + ignore_binary, this.configuration)];
363
+ case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
364
+ return Object.assign(new Sensor_1.Sensor(), x);
365
+ })[0]];
366
+ }
367
+ });
368
+ });
369
+ };
370
+ return SensorService;
371
+ }());
372
+ exports.SensorService = SensorService;
@@ -0,0 +1,44 @@
1
+ import { Configuration } from "./Fetch";
2
+ import { Identifier } from "../model/Type";
3
+ import { SensorEvent } from "../model/SensorEvent";
4
+ export declare class SensorEventService {
5
+ configuration?: Configuration;
6
+ /**
7
+ * Get the set of all sensor events produced by the given participant.
8
+ * @param participantId
9
+ * @param origin
10
+ * @param from
11
+ * @param to
12
+ */
13
+ allByParticipant(participantId: Identifier, origin?: string, from?: number, to?: number, limit?: number, transform?: string): Promise<SensorEvent[]>;
14
+ /**
15
+ * Get the set of all sensor events produced by participants of any study conducted by a researcher, by researcher identifier.
16
+ * @param researcherId
17
+ * @param origin
18
+ * @param from
19
+ * @param to
20
+ */
21
+ allByResearcher(researcherId: Identifier, origin?: string, from?: number, to?: number, limit?: number, transform?: string): Promise<SensorEvent[]>;
22
+ /**
23
+ * Get the set of all sensor events produced by participants participants of a single study, by study identifier.
24
+ * @param studyId
25
+ * @param origin
26
+ * @param from
27
+ * @param to
28
+ */
29
+ allByStudy(studyId: Identifier, origin?: string, from?: number, to?: number, limit?: number, transform?: string): Promise<SensorEvent[]>;
30
+ /**
31
+ * Create a new SensorEvent for the given Participant.
32
+ * @param participantId
33
+ * @param sensorEvent
34
+ */
35
+ create(participantId: Identifier, sensorEvent: SensorEvent): Promise<Identifier>;
36
+ /**
37
+ * Delete a sensor event.
38
+ * @param participantId
39
+ * @param origin
40
+ * @param from
41
+ * @param to
42
+ */
43
+ delete(participantId: Identifier, origin?: string, from?: number, to?: number): Promise<Identifier>;
44
+ }