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,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
|
+
|
package/cli.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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 } 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
|
+
private static get configuration();
|
|
33
|
+
private static set configuration(value);
|
|
34
|
+
private static protocol;
|
|
35
|
+
static enableDevMode(): void;
|
|
36
|
+
static addEventListener(event: string, callback: (any: any) => void): void;
|
|
37
|
+
static removeEventListener(event: string, callback: (any: any) => void): void;
|
|
38
|
+
static dispatchEvent(event: string, detail?: any): void;
|
|
39
|
+
static initializeDemoDB(db: {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}): void;
|
|
42
|
+
static connect(identity?: {
|
|
43
|
+
accessKey: string | null;
|
|
44
|
+
secretKey: string | null;
|
|
45
|
+
serverAddress: string | undefined;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
static Auth: {
|
|
48
|
+
new (): {};
|
|
49
|
+
_auth: IAuth;
|
|
50
|
+
_me: Researcher[] | Researcher | Participant | null | undefined;
|
|
51
|
+
_type: "admin" | "researcher" | "participant" | null;
|
|
52
|
+
/**
|
|
53
|
+
* Authenticate/authorize as a user of a given `type`.
|
|
54
|
+
* If all values are null (especially `type`), the authorization is cleared.
|
|
55
|
+
*/
|
|
56
|
+
set_identity(identity?: {
|
|
57
|
+
id: string | null;
|
|
58
|
+
password: string | null;
|
|
59
|
+
serverAddress: string | null;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
refresh_identity(): Promise<void>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export declare const main: () => void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
+
function step(op) {
|
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
+
while (_) try {
|
|
39
|
+
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;
|
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
+
switch (op[0]) {
|
|
42
|
+
case 0: case 1: t = op; break;
|
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
+
default:
|
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
+
if (t[2]) _.ops.pop();
|
|
52
|
+
_.trys.pop(); continue;
|
|
53
|
+
}
|
|
54
|
+
op = body.call(thisArg, _);
|
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var _a;
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.main = void 0;
|
|
62
|
+
require("isomorphic-fetch");
|
|
63
|
+
var index_1 = require("./service/index");
|
|
64
|
+
var Demo_1 = require("./service/Demo");
|
|
65
|
+
__exportStar(require("./service/index"), exports);
|
|
66
|
+
__exportStar(require("./model/index"), exports);
|
|
67
|
+
//
|
|
68
|
+
var _bus = (_a = global.document) === null || _a === void 0 ? void 0 : _a.createElement("_lamp_fake");
|
|
69
|
+
/**
|
|
70
|
+
* The root type in LAMP. You must use `LAMP.connect(...)` to begin using any LAMP classes.
|
|
71
|
+
*/
|
|
72
|
+
var LAMP = /** @class */ (function () {
|
|
73
|
+
function LAMP() {
|
|
74
|
+
}
|
|
75
|
+
Object.defineProperty(LAMP, "configuration", {
|
|
76
|
+
get: function () {
|
|
77
|
+
return LAMP.API.configuration;
|
|
78
|
+
},
|
|
79
|
+
set: function (configuration) {
|
|
80
|
+
LAMP.API.configuration = configuration;
|
|
81
|
+
LAMP.Activity.configuration = configuration;
|
|
82
|
+
LAMP.ActivityEvent.configuration = configuration;
|
|
83
|
+
LAMP.ActivitySpec.configuration = configuration;
|
|
84
|
+
LAMP.Credential.configuration = configuration;
|
|
85
|
+
LAMP.Participant.configuration = configuration;
|
|
86
|
+
LAMP.Researcher.configuration = configuration;
|
|
87
|
+
LAMP.Sensor.configuration = configuration;
|
|
88
|
+
LAMP.SensorEvent.configuration = configuration;
|
|
89
|
+
LAMP.SensorSpec.configuration = configuration;
|
|
90
|
+
LAMP.Study.configuration = configuration;
|
|
91
|
+
LAMP.Type.configuration = configuration;
|
|
92
|
+
LAMP.ResearcherSettings.configuration = configuration;
|
|
93
|
+
},
|
|
94
|
+
enumerable: false,
|
|
95
|
+
configurable: true
|
|
96
|
+
});
|
|
97
|
+
LAMP.enableDevMode = function () {
|
|
98
|
+
// Make all future server requests over http
|
|
99
|
+
// Only use this for local development
|
|
100
|
+
LAMP.protocol = "http://";
|
|
101
|
+
};
|
|
102
|
+
LAMP.addEventListener = function (event, callback) {
|
|
103
|
+
_bus === null || _bus === void 0 ? void 0 : _bus.addEventListener(event, callback);
|
|
104
|
+
};
|
|
105
|
+
LAMP.removeEventListener = function (event, callback) {
|
|
106
|
+
_bus === null || _bus === void 0 ? void 0 : _bus.removeEventListener(event, callback);
|
|
107
|
+
};
|
|
108
|
+
LAMP.dispatchEvent = function (event, detail) {
|
|
109
|
+
if (detail === void 0) { detail = null; }
|
|
110
|
+
_bus === null || _bus === void 0 ? void 0 : _bus.dispatchEvent(new CustomEvent(event, { detail: detail }));
|
|
111
|
+
};
|
|
112
|
+
//
|
|
113
|
+
// [Demo API]
|
|
114
|
+
//
|
|
115
|
+
LAMP.initializeDemoDB = function (db) {
|
|
116
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
117
|
+
db = JSON.parse(JSON.stringify(db)); // make a deep copy first!
|
|
118
|
+
Demo_1.Demo.ActivitySpec = (_a = db.ActivitySpec) !== null && _a !== void 0 ? _a : [];
|
|
119
|
+
Demo_1.Demo.SensorSpec = (_b = db.SensorSpec) !== null && _b !== void 0 ? _b : [];
|
|
120
|
+
Demo_1.Demo.Researcher = (_c = db.Researcher) !== null && _c !== void 0 ? _c : [];
|
|
121
|
+
Demo_1.Demo.Study = (_d = db.Study) !== null && _d !== void 0 ? _d : [];
|
|
122
|
+
Demo_1.Demo.Participant = (_e = db.Participant) !== null && _e !== void 0 ? _e : [];
|
|
123
|
+
Demo_1.Demo.Activity = (_f = db.Activity) !== null && _f !== void 0 ? _f : [];
|
|
124
|
+
Demo_1.Demo.Sensor = (_g = db.Sensor) !== null && _g !== void 0 ? _g : [];
|
|
125
|
+
Demo_1.Demo.ActivityEvent = (_h = db.ActivityEvent) !== null && _h !== void 0 ? _h : [];
|
|
126
|
+
Demo_1.Demo.SensorEvent = (_j = db.SensorEvent) !== null && _j !== void 0 ? _j : [];
|
|
127
|
+
Demo_1.Demo.Credential = (_k = db.Credential) !== null && _k !== void 0 ? _k : [];
|
|
128
|
+
Demo_1.Demo.Tags = (_l = db.Tags) !== null && _l !== void 0 ? _l : [];
|
|
129
|
+
};
|
|
130
|
+
//
|
|
131
|
+
// [Credential/Identity Management]
|
|
132
|
+
//
|
|
133
|
+
// Shorthand for console/data analysis usage.
|
|
134
|
+
LAMP.connect = function (identity) {
|
|
135
|
+
if (identity === void 0) { identity = {
|
|
136
|
+
accessKey: null,
|
|
137
|
+
secretKey: null,
|
|
138
|
+
serverAddress: undefined,
|
|
139
|
+
}; }
|
|
140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
// Propogate the authorization.
|
|
143
|
+
// await LAMP.Credential.login(identity.accessKey!, identity.secretKey!);
|
|
144
|
+
LAMP.Auth._auth = {
|
|
145
|
+
id: identity.accessKey,
|
|
146
|
+
password: identity.secretKey,
|
|
147
|
+
serverAddress: identity.serverAddress,
|
|
148
|
+
};
|
|
149
|
+
LAMP.configuration = !!LAMP.Auth._auth.id ? {
|
|
150
|
+
base: !!identity.serverAddress ? "https://" + identity.serverAddress : "https://api.lamp.digital",
|
|
151
|
+
authorization: LAMP.Auth._auth.id + ":" + LAMP.Auth._auth.password
|
|
152
|
+
} : {
|
|
153
|
+
base: !!identity.serverAddress ? "https://" + identity.serverAddress : "https://api.lamp.digital",
|
|
154
|
+
};
|
|
155
|
+
return [2 /*return*/];
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
var _b;
|
|
160
|
+
LAMP.API = new index_1.APIService();
|
|
161
|
+
LAMP.Type = new index_1.TypeService();
|
|
162
|
+
LAMP.Credential = new index_1.CredentialService();
|
|
163
|
+
LAMP.Researcher = new index_1.ResearcherService();
|
|
164
|
+
LAMP.Participant = new index_1.ParticipantService();
|
|
165
|
+
LAMP.Study = new index_1.StudyService();
|
|
166
|
+
LAMP.Activity = new index_1.ActivityService();
|
|
167
|
+
LAMP.ActivityEvent = new index_1.ActivityEventService();
|
|
168
|
+
LAMP.ActivitySpec = new index_1.ActivitySpecService();
|
|
169
|
+
LAMP.Sensor = new index_1.SensorService();
|
|
170
|
+
LAMP.SensorEvent = new index_1.SensorEventService();
|
|
171
|
+
LAMP.SensorSpec = new index_1.SensorSpecService();
|
|
172
|
+
LAMP.ResearcherSettings = new index_1.ResearcherSettingsService();
|
|
173
|
+
LAMP.protocol = "https://";
|
|
174
|
+
LAMP.Auth = (_b = /** @class */ (function () {
|
|
175
|
+
function class_1() {
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Authenticate/authorize as a user of a given `type`.
|
|
179
|
+
* If all values are null (especially `type`), the authorization is cleared.
|
|
180
|
+
*/
|
|
181
|
+
class_1.set_identity = function (identity) {
|
|
182
|
+
var _a;
|
|
183
|
+
if (identity === void 0) { identity = {
|
|
184
|
+
id: null,
|
|
185
|
+
password: null,
|
|
186
|
+
serverAddress: null,
|
|
187
|
+
}; }
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var typeData, e_1, _b, err_1;
|
|
190
|
+
return __generator(this, function (_c) {
|
|
191
|
+
switch (_c.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
LAMP.configuration = {
|
|
194
|
+
base: !!identity.serverAddress ? "" + LAMP.protocol + identity.serverAddress : LAMP.protocol + "api.lamp.digital",
|
|
195
|
+
};
|
|
196
|
+
// Ensure there's actually a change to process.
|
|
197
|
+
// let l: IAuth = LAMP.Auth._auth || { id: null, password: null, serverAddress: null }
|
|
198
|
+
// if (l.id === identity.id && l.password === identity.password && l.serverAddress === identity.serverAddress) return
|
|
199
|
+
// Propogate the authorization.
|
|
200
|
+
LAMP.Auth._auth = {
|
|
201
|
+
id: identity.id,
|
|
202
|
+
password: identity.password,
|
|
203
|
+
serverAddress: identity.serverAddress,
|
|
204
|
+
};
|
|
205
|
+
LAMP.configuration = !!LAMP.Auth._auth.id ? __assign(__assign({}, (LAMP.configuration || { base: undefined, headers: undefined })), { authorization: LAMP.Auth._auth.id + ":" + LAMP.Auth._auth.password }) : __assign({}, (LAMP.configuration || { base: undefined, headers: undefined }));
|
|
206
|
+
_c.label = 1;
|
|
207
|
+
case 1:
|
|
208
|
+
_c.trys.push([1, 9, 10, 11]);
|
|
209
|
+
if (!(!!identity.id && !!identity.password)) return [3 /*break*/, 7];
|
|
210
|
+
typeData = void 0;
|
|
211
|
+
_c.label = 2;
|
|
212
|
+
case 2:
|
|
213
|
+
_c.trys.push([2, 4, , 5]);
|
|
214
|
+
return [4 /*yield*/, LAMP.Type.parent("me")];
|
|
215
|
+
case 3:
|
|
216
|
+
typeData = _c.sent();
|
|
217
|
+
return [3 /*break*/, 5];
|
|
218
|
+
case 4:
|
|
219
|
+
e_1 = _c.sent();
|
|
220
|
+
return [3 /*break*/, 5];
|
|
221
|
+
case 5:
|
|
222
|
+
LAMP.Auth._type =
|
|
223
|
+
typeData.data === "admin"
|
|
224
|
+
? "admin"
|
|
225
|
+
: Object.entries(typeData.data).length === 0
|
|
226
|
+
? "researcher"
|
|
227
|
+
: !!typeData.data
|
|
228
|
+
? "participant"
|
|
229
|
+
: null;
|
|
230
|
+
// Get our 'me' object now that we figured out our type.
|
|
231
|
+
_b = LAMP.Auth;
|
|
232
|
+
return [4 /*yield*/, (LAMP.Auth._type === "admin"
|
|
233
|
+
? { id: identity.id }
|
|
234
|
+
: LAMP.Auth._type === "researcher"
|
|
235
|
+
? LAMP.Researcher.view("me")
|
|
236
|
+
: LAMP.Participant.view("me"))];
|
|
237
|
+
case 6:
|
|
238
|
+
// Get our 'me' object now that we figured out our type.
|
|
239
|
+
_b._me = _c.sent();
|
|
240
|
+
LAMP.dispatchEvent("LOGIN", {
|
|
241
|
+
authorizationToken: LAMP.configuration.authorization,
|
|
242
|
+
// authorizationToken: LAMP.configuration.token,
|
|
243
|
+
identityObject: LAMP.Auth._me,
|
|
244
|
+
serverAddress: LAMP.configuration.base,
|
|
245
|
+
accessToken: LAMP.configuration.accessToken,
|
|
246
|
+
refreshToken: LAMP.configuration.refreshToken,
|
|
247
|
+
});
|
|
248
|
+
return [3 /*break*/, 8];
|
|
249
|
+
case 7:
|
|
250
|
+
LAMP.dispatchEvent("LOGOUT", {
|
|
251
|
+
deleteCache: true,
|
|
252
|
+
});
|
|
253
|
+
_c.label = 8;
|
|
254
|
+
case 8: return [3 /*break*/, 11];
|
|
255
|
+
case 9:
|
|
256
|
+
err_1 = _c.sent();
|
|
257
|
+
console.log("#####LAMP err", err_1);
|
|
258
|
+
// We failed: clear and propogate the authorization.
|
|
259
|
+
LAMP.Auth._auth = { id: null, password: null, serverAddress: null };
|
|
260
|
+
// if (!!LAMP.configuration) LAMP.configuration.token = undefined
|
|
261
|
+
// if (!!LAMP.configuration) LAMP.configuration.authorization = undefined
|
|
262
|
+
// Delete the "self" identity and throw the error we received.
|
|
263
|
+
LAMP.Auth._me = null;
|
|
264
|
+
LAMP.Auth._type = null;
|
|
265
|
+
throw new Error("invalid id or password");
|
|
266
|
+
case 10:
|
|
267
|
+
// Save the authorization in sessionStorage for later.
|
|
268
|
+
;
|
|
269
|
+
(_a = global.sessionStorage) === null || _a === void 0 ? void 0 : _a.setItem("LAMP._auth", JSON.stringify(LAMP.Auth._auth));
|
|
270
|
+
return [7 /*endfinally*/];
|
|
271
|
+
case 11: return [2 /*return*/];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
class_1.refresh_identity = function () {
|
|
277
|
+
var _a, _b;
|
|
278
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
+
var _saved;
|
|
280
|
+
return __generator(this, function (_c) {
|
|
281
|
+
switch (_c.label) {
|
|
282
|
+
case 0:
|
|
283
|
+
_saved = JSON.parse((_b = (_a = global.sessionStorage) === null || _a === void 0 ? void 0 : _a.getItem("LAMP._auth")) !== null && _b !== void 0 ? _b : "null") || LAMP.Auth._auth;
|
|
284
|
+
return [4 /*yield*/, LAMP.Auth.set_identity({
|
|
285
|
+
id: _saved.id,
|
|
286
|
+
password: _saved.password,
|
|
287
|
+
serverAddress: _saved.serverAddress,
|
|
288
|
+
})];
|
|
289
|
+
case 1:
|
|
290
|
+
_c.sent();
|
|
291
|
+
return [2 /*return*/];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
return class_1;
|
|
297
|
+
}()),
|
|
298
|
+
_b._auth = { id: null, password: null, serverAddress: null },
|
|
299
|
+
_b._type = null,
|
|
300
|
+
_b);
|
|
301
|
+
return LAMP;
|
|
302
|
+
}());
|
|
303
|
+
exports.default = LAMP;
|
|
304
|
+
exports.main = function () {
|
|
305
|
+
if (process === undefined) {
|
|
306
|
+
console.error("This function cannot be invoked from within the library.");
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
console.log("This command-line tool is currently disabled.");
|
|
310
|
+
process === null || process === void 0 ? void 0 : process.exit(1);
|
|
311
|
+
};
|