lamp-core-lst 2025.1.16
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/TESTING_DISPATCH_EVENT.md +192 -0
- package/cli.js +2 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +345 -0
- package/dist/model/Activity.d.ts +85 -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 +69 -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 +191 -0
- package/dist/service/Activity.service.js +1004 -0
- package/dist/service/ActivityEvent.service.d.ts +57 -0
- package/dist/service/ActivityEvent.service.js +329 -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 +15 -0
- package/dist/service/Demo.js +25 -0
- package/dist/service/Fetch.d.ts +30 -0
- package/dist/service/Fetch.js +336 -0
- package/dist/service/ImageUpload.service.d.ts +14 -0
- package/dist/service/ImageUpload.service.js +108 -0
- package/dist/service/Participant.service.d.ts +72 -0
- package/dist/service/Participant.service.js +371 -0
- package/dist/service/Researcher.service.d.ts +96 -0
- package/dist/service/Researcher.service.js +462 -0
- package/dist/service/ResearcherSettings.d.ts +69 -0
- package/dist/service/ResearcherSettings.js +12 -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 +14 -0
- package/dist/service/index.js +26 -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 +294 -0
- package/src/model/Activity.ts +98 -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 +77 -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 +945 -0
- package/src/service/ActivityEvent.service.ts +269 -0
- package/src/service/ActivitySpec.service.ts +98 -0
- package/src/service/Credential.service.ts +268 -0
- package/src/service/Demo.ts +22 -0
- package/src/service/Fetch.ts +262 -0
- package/src/service/ImageUpload.service.ts +71 -0
- package/src/service/Participant.service.ts +282 -0
- package/src/service/Researcher.service.ts +316 -0
- package/src/service/ResearcherSettings.service.ts +59 -0
- package/src/service/ResearcherSettings.ts +77 -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 +14 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [created]
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v2
|
|
10
|
+
- uses: actions/setup-node@v1
|
|
11
|
+
with:
|
|
12
|
+
node-version: 16.x
|
|
13
|
+
- run: |
|
|
14
|
+
npm install
|
|
15
|
+
- run: npm test
|
|
16
|
+
publish-npm:
|
|
17
|
+
needs: build
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v2
|
|
21
|
+
- uses: actions/setup-node@v1
|
|
22
|
+
with:
|
|
23
|
+
node-version: 16.x
|
|
24
|
+
registry-url: https://registry.npmjs.org/
|
|
25
|
+
- name: Autoincrement version
|
|
26
|
+
run: |
|
|
27
|
+
# from refs/tags/v1.2.3 get 1.2.3
|
|
28
|
+
VERSION=$(echo $GITHUB_REF | sed 's#.*/##')
|
|
29
|
+
npm version --no-git-tag-version $VERSION
|
|
30
|
+
shell: bash
|
|
31
|
+
- run: npm install
|
|
32
|
+
- run: npm publish
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Division of Digital Psychiatry at Beth Israel Deaconess Medical Center
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/MANUAL.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
lamp(3) -- connect to and manipulate objects in the LAMP Platform
|
|
2
|
+
===
|
|
3
|
+
|
|
4
|
+
## SYNOPSIS
|
|
5
|
+
|
|
6
|
+
`lamp <type> <method> [<id>]`
|
|
7
|
+
|
|
8
|
+
## DESCRIPTION
|
|
9
|
+
|
|
10
|
+
lamp(3) implements a connector and object manipulator to the LAMP Platform. You must specify a `server_address` (defaults to `api.lamp.digital`), `access_key`, and `secret_key`.
|
|
11
|
+
|
|
12
|
+
## EXAMPLES
|
|
13
|
+
|
|
14
|
+
None yet.
|
|
15
|
+
|
|
16
|
+
## DIAGNOSTICS
|
|
17
|
+
|
|
18
|
+
None.
|
|
19
|
+
|
|
20
|
+
## AUTHOR
|
|
21
|
+
|
|
22
|
+
Division of Digital Psychiatry at BIDMC <team@digitalpsych.org>
|
|
23
|
+
|
|
24
|
+
## SEE ALSO
|
|
25
|
+
|
|
26
|
+
[Visit our documentation for more information about the LAMP Platform.](https://docs.lamp.digital/)
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# JavaScript & TypeScript API client for the LAMP Platform
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This API client is used to connect to the LAMP Platform from the JavaScript and TypeScript programming languages. [Visit our documentation for more information about the LAMP Platform.](https://docs.lamp.digital/)
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
### Prerequisites
|
|
9
|
+
|
|
10
|
+
Install the package directly from the GitHub repository.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm i lamp-core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Configuration
|
|
17
|
+
|
|
18
|
+
Ensure your `serverAddress` is set correctly. If using the default server, it will be `api.lamp.digital`. Keep your `accessKey` (sometimes an email address) and `secretKey` (sometimes a password) private and do not share them with others.
|
|
19
|
+
|
|
20
|
+
To make requests using `http`, enable dev mode before attempting to connect to a server.
|
|
21
|
+
|
|
22
|
+
**Warning:** Dev mode should only be used for local development!
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
import LAMP from 'lamp-core'
|
|
26
|
+
LAMP.enableDevMode() // optional
|
|
27
|
+
await LAMP.connect({ serverAddress: '...', accessKey: '...', secretKey: '...' })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API Endpoints
|
|
31
|
+
|
|
32
|
+
All URIs are relative to the `serverAddress` (by default, `api.lamp.digital`).
|
|
33
|
+
|
|
34
|
+
The protocol defaults to `https` but `http` can be used with dev mode enabled.
|
|
35
|
+
|
|
36
|
+
Class | Method | HTTP request | Description
|
|
37
|
+
------------ | ------------- | ------------- | -------------
|
|
38
|
+
*LAMP.API* | [**query**](docs/APIApi.md#query) | **POST** / | Query the LAMP Database.
|
|
39
|
+
*LAMP.API* | [**schema**](docs/APIApi.md#schema) | **GET** / | View the API schema document.
|
|
40
|
+
*LAMP.Activity* | [**all**](docs/ActivityApi.md#all) | **GET** /activity | Get the set of all activities.
|
|
41
|
+
*LAMP.Activity* | [**allByParticipant**](docs/ActivityApi.md#allByParticipant) | **GET** /participant/{participant_id}/activity | Get all activities for a participant.
|
|
42
|
+
*LAMP.Activity* | [**allByResearcher**](docs/ActivityApi.md#allByResearcher) | **GET** /researcher/{researcher_id}/activity | Get all activities for a researcher.
|
|
43
|
+
*LAMP.Activity* | [**allByStudy**](docs/ActivityApi.md#allByStudy) | **GET** /study/{study_id}/activity | Get all activities in a study.
|
|
44
|
+
*LAMP.Activity* | [**create**](docs/ActivityApi.md#create) | **POST** /study/{study_id}/activity | Create a new Activity under the given Study.
|
|
45
|
+
*LAMP.Activity* | [**delete**](docs/ActivityApi.md#delete) | **DELETE** /activity/{activity_id} | Delete an Activity.
|
|
46
|
+
*LAMP.Activity* | [**update**](docs/ActivityApi.md#update) | **PUT** /activity/{activity_id} | Update an Activity's settings.
|
|
47
|
+
*LAMP.Activity* | [**view**](docs/ActivityApi.md#view) | **GET** /activity/{activity_id} | Get a single activity, by identifier.
|
|
48
|
+
*LAMP.ActivityEvent* | [**allByParticipant**](docs/ActivityEventApi.md#allByParticipant) | **GET** /participant/{participant_id}/activity_event | Get all activity events for a participant.
|
|
49
|
+
*LAMP.ActivityEvent* | [**allByResearcher**](docs/ActivityEventApi.md#allByResearcher) | **GET** /researcher/{researcher_id}/activity_event | Get all activity events for a researcher by participant.
|
|
50
|
+
*LAMP.ActivityEvent* | [**allByStudy**](docs/ActivityEventApi.md#allByStudy) | **GET** /study/{study_id}/activity_event | Get all activity events for a study by participant.
|
|
51
|
+
*LAMP.ActivityEvent* | [**create**](docs/ActivityEventApi.md#create) | **POST** /participant/{participant_id}/activity_event | Create a new ActivityEvent for the given Participant.
|
|
52
|
+
*LAMP.ActivityEvent* | [**delete**](docs/ActivityEventApi.md#delete) | **DELETE** /participant/{participant_id}/activity_event | Delete a ActivityEvent.
|
|
53
|
+
*LAMP.ActivitySpec* | [**all**](docs/ActivitySpecApi.md#all) | **GET** /activity_spec | Get all ActivitySpecs registered.
|
|
54
|
+
*LAMP.ActivitySpec* | [**create**](docs/ActivitySpecApi.md#create) | **POST** /activity_spec | Create a new ActivitySpec.
|
|
55
|
+
*LAMP.ActivitySpec* | [**delete**](docs/ActivitySpecApi.md#delete) | **DELETE** /activity_spec/{activity_spec_name} | Delete an ActivitySpec.
|
|
56
|
+
*LAMP.ActivitySpec* | [**update**](docs/ActivitySpecApi.md#update) | **PUT** /activity_spec/{activity_spec_name} | Update an ActivitySpec.
|
|
57
|
+
*LAMP.ActivitySpec* | [**view**](docs/ActivitySpecApi.md#view) | **GET** /activity_spec/{activity_spec_name} | View an ActivitySpec.
|
|
58
|
+
*LAMP.Credential* | [**create**](docs/CredentialApi.md#create) | **POST** /type/{type_id}/credential |
|
|
59
|
+
*LAMP.Credential* | [**delete**](docs/CredentialApi.md#delete) | **DELETE** /type/{type_id}/credential/{access_key} |
|
|
60
|
+
*LAMP.Credential* | [**list**](docs/CredentialApi.md#list) | **GET** /type/{type_id}/credential |
|
|
61
|
+
*LAMP.Credential* | [**update**](docs/CredentialApi.md#update) | **PUT** /type/{type_id}/credential/{access_key} |
|
|
62
|
+
*LAMP.Participant* | [**all**](docs/ParticipantApi.md#all) | **GET** /participant | Get the set of all participants.
|
|
63
|
+
*LAMP.Participant* | [**allByResearcher**](docs/ParticipantApi.md#allByResearcher) | **GET** /researcher/{researcher_id}/participant | Get the set of all participants under a single researcher.
|
|
64
|
+
*LAMP.Participant* | [**allByStudy**](docs/ParticipantApi.md#allByStudy) | **GET** /study/{study_id}/participant | Get the set of all participants in a single study.
|
|
65
|
+
*LAMP.Participant* | [**create**](docs/ParticipantApi.md#create) | **POST** /study/{study_id}/participant | Create a new Participant for the given Study.
|
|
66
|
+
*LAMP.Participant* | [**delete**](docs/ParticipantApi.md#delete) | **DELETE** /participant/{participant_id} | Delete a participant AND all owned data or event streams.
|
|
67
|
+
*LAMP.Participant* | [**update**](docs/ParticipantApi.md#update) | **PUT** /participant/{participant_id} | Update a Participant's settings.
|
|
68
|
+
*LAMP.Participant* | [**view**](docs/ParticipantApi.md#view) | **GET** /participant/{participant_id} | Get a single participant, by identifier.
|
|
69
|
+
*LAMP.Researcher* | [**all**](docs/ResearcherApi.md#all) | **GET** /researcher | Get the set of all researchers.
|
|
70
|
+
*LAMP.Researcher* | [**create**](docs/ResearcherApi.md#create) | **POST** /researcher | Create a new Researcher.
|
|
71
|
+
*LAMP.Researcher* | [**delete**](docs/ResearcherApi.md#delete) | **DELETE** /researcher/{researcher_id} | Delete a researcher.
|
|
72
|
+
*LAMP.Researcher* | [**update**](docs/ResearcherApi.md#update) | **PUT** /researcher/{researcher_id} | Update a Researcher's settings.
|
|
73
|
+
*LAMP.Researcher* | [**view**](docs/ResearcherApi.md#view) | **GET** /researcher/{researcher_id} | Get a single researcher, by identifier.
|
|
74
|
+
*LAMP.Sensor* | [**all**](docs/SensorApi.md#all) | **GET** /sensor | Get the set of all sensors.
|
|
75
|
+
*LAMP.Sensor* | [**allByParticipant**](docs/SensorApi.md#allByParticipant) | **GET** /participant/{participant_id}/sensor | Get all sensors for a participant.
|
|
76
|
+
*LAMP.Sensor* | [**allByResearcher**](docs/SensorApi.md#allByResearcher) | **GET** /researcher/{researcher_id}/sensor | Get all sensors for a researcher.
|
|
77
|
+
*LAMP.Sensor* | [**allByStudy**](docs/SensorApi.md#allByStudy) | **GET** /study/{study_id}/sensor | View all sensors in a study.
|
|
78
|
+
*LAMP.Sensor* | [**create**](docs/SensorApi.md#create) | **POST** /study/{study_id}/sensor | Create a new Sensor under the given Study.
|
|
79
|
+
*LAMP.Sensor* | [**delete**](docs/SensorApi.md#delete) | **DELETE** /sensor/{sensor_id} | Delete a Sensor.
|
|
80
|
+
*LAMP.Sensor* | [**update**](docs/SensorApi.md#update) | **PUT** /sensor/{sensor_id} | Update an Sensor's settings.
|
|
81
|
+
*LAMP.Sensor* | [**view**](docs/SensorApi.md#view) | **GET** /sensor/{sensor_id} | Get a single sensor, by identifier.
|
|
82
|
+
*LAMP.SensorEvent* | [**allByParticipant**](docs/SensorEventApi.md#allByParticipant) | **GET** /participant/{participant_id}/sensor_event | Get all sensor events for a participant.
|
|
83
|
+
*LAMP.SensorEvent* | [**allByResearcher**](docs/SensorEventApi.md#allByResearcher) | **GET** /researcher/{researcher_id}/sensor_event | Get all sensor events for a researcher by participant.
|
|
84
|
+
*LAMP.SensorEvent* | [**allByStudy**](docs/SensorEventApi.md#allByStudy) | **GET** /study/{study_id}/sensor_event | Get all sensor events for a study by participant.
|
|
85
|
+
*LAMP.SensorEvent* | [**create**](docs/SensorEventApi.md#create) | **POST** /participant/{participant_id}/sensor_event | Create a new SensorEvent for the given Participant.
|
|
86
|
+
*LAMP.SensorEvent* | [**delete**](docs/SensorEventApi.md#delete) | **DELETE** /participant/{participant_id}/sensor_event | Delete a sensor event.
|
|
87
|
+
*LAMP.SensorSpec* | [**all**](docs/SensorSpecApi.md#all) | **GET** /sensor_spec | Get all SensorSpecs registered.
|
|
88
|
+
*LAMP.SensorSpec* | [**create**](docs/SensorSpecApi.md#create) | **POST** /sensor_spec | Create a new SensorSpec.
|
|
89
|
+
*LAMP.SensorSpec* | [**delete**](docs/SensorSpecApi.md#delete) | **DELETE** /sensor_spec/{sensor_spec_name} | Delete an SensorSpec.
|
|
90
|
+
*LAMP.SensorSpec* | [**update**](docs/SensorSpecApi.md#update) | **PUT** /sensor_spec/{sensor_spec_name} | Update an SensorSpec.
|
|
91
|
+
*LAMP.SensorSpec* | [**view**](docs/SensorSpecApi.md#view) | **GET** /sensor_spec/{sensor_spec_name} | Get a SensorSpec.
|
|
92
|
+
*LAMP.Study* | [**all**](docs/StudyApi.md#all) | **GET** /study | Get the set of all studies.
|
|
93
|
+
*LAMP.Study* | [**allByResearcher**](docs/StudyApi.md#allByResearcher) | **GET** /researcher/{researcher_id}/study | Get the set of studies for a single researcher.
|
|
94
|
+
*LAMP.Study* | [**create**](docs/StudyApi.md#create) | **POST** /researcher/{researcher_id}/study | Create a new Study for the given Researcher.
|
|
95
|
+
*LAMP.Study* | [**delete**](docs/StudyApi.md#delete) | **DELETE** /study/{study_id} | Delete a study.
|
|
96
|
+
*LAMP.Study* | [**update**](docs/StudyApi.md#update) | **PUT** /study/{study_id} | Update the study.
|
|
97
|
+
*LAMP.Study* | [**view**](docs/StudyApi.md#view) | **GET** /study/{study_id} | Get a single study, by identifier.
|
|
98
|
+
*LAMP.Type* | [**getAttachment**](docs/TypeApi.md#getAttachment) | **GET** /type/{type_id}/attachment/{attachment_key} |
|
|
99
|
+
*LAMP.Type* | [**getDynamicAttachment**](docs/TypeApi.md#getDynamicAttachment) | **GET** /type/{type_id}/attachment/dynamic/{attachment_key} |
|
|
100
|
+
*LAMP.Type* | [**listAttachments**](docs/TypeApi.md#listAttachments) | **GET** /type/{type_id}/attachment |
|
|
101
|
+
*LAMP.Type* | [**parent**](docs/TypeApi.md#parent) | **GET** /type/{type_id}/parent | Find the owner(s) of the resource.
|
|
102
|
+
*LAMP.Type* | [**setAttachment**](docs/TypeApi.md#setAttachment) | **PUT** /type/{type_id}/attachment/{attachment_key}/{target} |
|
|
103
|
+
*LAMP.Type* | [**setDynamicAttachment**](docs/TypeApi.md#setDynamicAttachment) | **PUT** /type/{type_id}/attachment/dynamic/{attachment_key}/{target} |
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## Documentation for Models
|
|
107
|
+
|
|
108
|
+
- [AccessCitation](docs/AccessCitation.md)
|
|
109
|
+
- [Activity](docs/Activity.md)
|
|
110
|
+
- [ActivityEvent](docs/ActivityEvent.md)
|
|
111
|
+
- [ActivitySpec](docs/ActivitySpec.md)
|
|
112
|
+
- [Credential](docs/Credential.md)
|
|
113
|
+
- [Document](docs/Document.md)
|
|
114
|
+
- [DurationInterval](docs/DurationInterval.md)
|
|
115
|
+
- [DurationIntervalLegacy](docs/DurationIntervalLegacy.md)
|
|
116
|
+
- [DynamicAttachment](docs/DynamicAttachment.md)
|
|
117
|
+
- [Error](docs/Error.md)
|
|
118
|
+
- [Metadata](docs/Metadata.md)
|
|
119
|
+
- [Participant](docs/Participant.md)
|
|
120
|
+
- [Researcher](docs/Researcher.md)
|
|
121
|
+
- [Sensor](docs/Sensor.md)
|
|
122
|
+
- [SensorEvent](docs/SensorEvent.md)
|
|
123
|
+
- [SensorSpec](docs/SensorSpec.md)
|
|
124
|
+
- [Study](docs/Study.md)
|
|
125
|
+
- [TemporalSlice](docs/TemporalSlice.md)
|
|
126
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Testing LAMP.dispatchEvent in Browser Console
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
`LAMP.dispatchEvent` is an event system that allows components to communicate via custom events. You can test it directly from the browser console when the LAMP-dashboard is running.
|
|
5
|
+
|
|
6
|
+
## Basic Usage
|
|
7
|
+
|
|
8
|
+
### 1. Add an Event Listener
|
|
9
|
+
```javascript
|
|
10
|
+
// Listen for a custom event
|
|
11
|
+
LAMP.addEventListener("MY_TEST_EVENT", (event) => {
|
|
12
|
+
console.log("Event received:", event.detail);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Listen for LOGIN events (already used by LAMP)
|
|
16
|
+
LAMP.addEventListener("LOGIN", (event) => {
|
|
17
|
+
console.log("Login event:", event.detail);
|
|
18
|
+
console.log("Identity:", event.detail.identityObject);
|
|
19
|
+
console.log("Server:", event.detail.serverAddress);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Listen for LOGOUT events
|
|
23
|
+
LAMP.addEventListener("LOGOUT", (event) => {
|
|
24
|
+
console.log("Logout event:", event.detail);
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Dispatch a Test Event
|
|
29
|
+
```javascript
|
|
30
|
+
// Dispatch a simple test event
|
|
31
|
+
LAMP.dispatchEvent("MY_TEST_EVENT", { message: "Hello from console!" });
|
|
32
|
+
|
|
33
|
+
// Dispatch with more complex data
|
|
34
|
+
LAMP.dispatchEvent("MY_TEST_EVENT", {
|
|
35
|
+
timestamp: Date.now(),
|
|
36
|
+
data: { key: "value" },
|
|
37
|
+
user: "test-user"
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Remove an Event Listener
|
|
42
|
+
```javascript
|
|
43
|
+
// Create a named function for the listener
|
|
44
|
+
const myHandler = (event) => {
|
|
45
|
+
console.log("Event:", event.detail);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Add listener
|
|
49
|
+
LAMP.addEventListener("MY_TEST_EVENT", myHandler);
|
|
50
|
+
|
|
51
|
+
// Remove listener
|
|
52
|
+
LAMP.removeEventListener("MY_TEST_EVENT", myHandler);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Testing Existing Events
|
|
56
|
+
|
|
57
|
+
### Test LOGIN Event
|
|
58
|
+
```javascript
|
|
59
|
+
// Add listener first
|
|
60
|
+
LAMP.addEventListener("LOGIN", (event) => {
|
|
61
|
+
console.log("LOGIN Event Details:", event.detail);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Trigger login (this will also dispatch LOGIN event automatically)
|
|
65
|
+
// But you can also manually test it:
|
|
66
|
+
LAMP.dispatchEvent("LOGIN", {
|
|
67
|
+
authorizationToken: "test:token",
|
|
68
|
+
identityObject: { id: "test-user", name: "Test User" },
|
|
69
|
+
serverAddress: "https://api.lamp.digital",
|
|
70
|
+
accessToken: "access-token",
|
|
71
|
+
refreshToken: "refresh-token"
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Test LOGOUT Event
|
|
76
|
+
```javascript
|
|
77
|
+
// Add listener
|
|
78
|
+
LAMP.addEventListener("LOGOUT", (event) => {
|
|
79
|
+
console.log("LOGOUT Event:", event.detail);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Dispatch logout
|
|
83
|
+
LAMP.dispatchEvent("LOGOUT", {
|
|
84
|
+
deleteCache: true
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Complete Testing Example
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// Step 1: Set up listeners for all events you want to test
|
|
92
|
+
const eventLog = [];
|
|
93
|
+
|
|
94
|
+
// Generic event logger
|
|
95
|
+
const logEvent = (eventName) => (event) => {
|
|
96
|
+
const logEntry = {
|
|
97
|
+
event: eventName,
|
|
98
|
+
timestamp: new Date().toISOString(),
|
|
99
|
+
detail: event.detail
|
|
100
|
+
};
|
|
101
|
+
eventLog.push(logEntry);
|
|
102
|
+
console.log(`[${eventName}]`, logEntry);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Add listeners
|
|
106
|
+
LAMP.addEventListener("LOGIN", logEvent("LOGIN"));
|
|
107
|
+
LAMP.addEventListener("LOGOUT", logEvent("LOGOUT"));
|
|
108
|
+
LAMP.addEventListener("MY_TEST_EVENT", logEvent("MY_TEST_EVENT"));
|
|
109
|
+
|
|
110
|
+
// Step 2: Dispatch test events
|
|
111
|
+
LAMP.dispatchEvent("MY_TEST_EVENT", { test: "data" });
|
|
112
|
+
LAMP.dispatchEvent("LOGIN", {
|
|
113
|
+
identityObject: { id: "test" },
|
|
114
|
+
serverAddress: "https://test.com"
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Step 3: View all logged events
|
|
118
|
+
console.log("All Events:", eventLog);
|
|
119
|
+
|
|
120
|
+
// Step 4: Check if LAMP object is available
|
|
121
|
+
console.log("LAMP object:", LAMP);
|
|
122
|
+
console.log("LAMP.dispatchEvent:", LAMP.dispatchEvent);
|
|
123
|
+
console.log("LAMP.addEventListener:", LAMP.addEventListener);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Debugging Tips
|
|
127
|
+
|
|
128
|
+
### Check if LAMP is loaded
|
|
129
|
+
```javascript
|
|
130
|
+
// In browser console
|
|
131
|
+
typeof LAMP !== 'undefined' && LAMP.dispatchEvent
|
|
132
|
+
// Should return: function dispatchEvent() { ... }
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Monitor all dispatched events
|
|
136
|
+
```javascript
|
|
137
|
+
// Override dispatchEvent temporarily to log all events
|
|
138
|
+
const originalDispatch = LAMP.dispatchEvent;
|
|
139
|
+
LAMP.dispatchEvent = function(event, detail) {
|
|
140
|
+
console.log("Dispatching:", event, detail);
|
|
141
|
+
return originalDispatch.call(this, event, detail);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Now all events will be logged
|
|
145
|
+
LAMP.dispatchEvent("TEST", { data: "test" });
|
|
146
|
+
|
|
147
|
+
// Restore original
|
|
148
|
+
LAMP.dispatchEvent = originalDispatch;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Check event bus
|
|
152
|
+
```javascript
|
|
153
|
+
// The internal event bus is a DOM element
|
|
154
|
+
// You can inspect it (though it's private)
|
|
155
|
+
// Events are dispatched using CustomEvent API
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Common Use Cases
|
|
159
|
+
|
|
160
|
+
### 1. Test Activity Completion Events
|
|
161
|
+
```javascript
|
|
162
|
+
LAMP.addEventListener("ACTIVITY_COMPLETE", (event) => {
|
|
163
|
+
console.log("Activity completed:", event.detail);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
LAMP.dispatchEvent("ACTIVITY_COMPLETE", {
|
|
167
|
+
activityId: "test-activity-123",
|
|
168
|
+
participantId: "test-participant",
|
|
169
|
+
timestamp: Date.now()
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 2. Test Data Sync Events
|
|
174
|
+
```javascript
|
|
175
|
+
LAMP.addEventListener("DATA_SYNC", (event) => {
|
|
176
|
+
console.log("Data synced:", event.detail);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
LAMP.dispatchEvent("DATA_SYNC", {
|
|
180
|
+
type: "activities",
|
|
181
|
+
count: 10,
|
|
182
|
+
timestamp: Date.now()
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Notes
|
|
187
|
+
- Events use the browser's native CustomEvent API
|
|
188
|
+
- The event bus is an internal HTMLElement (`_bus`)
|
|
189
|
+
- Events are synchronous - listeners are called immediately
|
|
190
|
+
- Multiple listeners can be attached to the same event
|
|
191
|
+
- Event details are passed in the `detail` property of the event object
|
|
192
|
+
|
package/cli.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "isomorphic-fetch";
|
|
2
|
+
import { Researcher, Participant } from "./model/index";
|
|
3
|
+
import { APIService, ActivityService, ActivityEventService, ActivitySpecService, CredentialService, ParticipantService, ResearcherService, SensorService, SensorEventService, SensorSpecService, StudyService, TypeService, ResearcherSettingsService, ImageUploadService } from "./service/index";
|
|
4
|
+
export * from "./service/index";
|
|
5
|
+
export * from "./model/index";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
interface IAuth {
|
|
10
|
+
id: string | null;
|
|
11
|
+
password: string | null;
|
|
12
|
+
serverAddress: string | undefined;
|
|
13
|
+
token?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The root type in LAMP. You must use `LAMP.connect(...)` to begin using any LAMP classes.
|
|
17
|
+
*/
|
|
18
|
+
export default class LAMP {
|
|
19
|
+
static API: APIService;
|
|
20
|
+
static Type: TypeService;
|
|
21
|
+
static Credential: CredentialService;
|
|
22
|
+
static Researcher: ResearcherService;
|
|
23
|
+
static Participant: ParticipantService;
|
|
24
|
+
static Study: StudyService;
|
|
25
|
+
static Activity: ActivityService;
|
|
26
|
+
static ActivityEvent: ActivityEventService;
|
|
27
|
+
static ActivitySpec: ActivitySpecService;
|
|
28
|
+
static Sensor: SensorService;
|
|
29
|
+
static SensorEvent: SensorEventService;
|
|
30
|
+
static SensorSpec: SensorSpecService;
|
|
31
|
+
static ResearcherSettings: ResearcherSettingsService;
|
|
32
|
+
static ImageUpload: ImageUploadService;
|
|
33
|
+
private static get configuration();
|
|
34
|
+
private static set configuration(value);
|
|
35
|
+
private static protocol;
|
|
36
|
+
static enableDevMode(): void;
|
|
37
|
+
static addEventListener(event: string, callback: (any: any) => void): void;
|
|
38
|
+
static removeEventListener(event: string, callback: (any: any) => void): void;
|
|
39
|
+
static dispatchEvent(event: string, detail?: any): void;
|
|
40
|
+
static initializeDemoDB(db: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}): void;
|
|
43
|
+
static connect(identity?: {
|
|
44
|
+
accessKey: string | null;
|
|
45
|
+
secretKey: string | null;
|
|
46
|
+
serverAddress: string | undefined;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Connect using Bearer token authentication (JWT).
|
|
50
|
+
* Use this for server-to-server communication where you have an access token.
|
|
51
|
+
* @param options - Connection options with accessToken and serverAddress
|
|
52
|
+
*/
|
|
53
|
+
static connectWithToken(options: {
|
|
54
|
+
accessToken: string;
|
|
55
|
+
serverAddress: string;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
static Auth: {
|
|
58
|
+
new (): {};
|
|
59
|
+
_auth: IAuth;
|
|
60
|
+
_me: Researcher[] | Researcher | Participant | null | undefined;
|
|
61
|
+
_type: "admin" | "researcher" | "participant" | null;
|
|
62
|
+
/**
|
|
63
|
+
* Authenticate/authorize as a user of a given `type`.
|
|
64
|
+
* If all values are null (especially `type`), the authorization is cleared.
|
|
65
|
+
*/
|
|
66
|
+
set_identity(identity?: {
|
|
67
|
+
id: string | null;
|
|
68
|
+
password: string | null;
|
|
69
|
+
serverAddress: string | null;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
refresh_identity(): Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export declare const main: () => void;
|