@suffolklitlab/alkiln 5.12.0 → 5.13.0-logs2
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/.env.example +29 -0
- package/.github/workflows/github_server.yml +59 -12
- package/.github/workflows/playground.yml +11 -4
- package/CHANGELOG.md +41 -1
- package/CONTRIBUTING.md +98 -83
- package/README.md +1 -1
- package/action.yml +69 -29
- package/action_for_github_server/action.yml +65 -31
- package/docs/decisions/006_which_log_level_to_pick_2024_09_5.md +46 -0
- package/docs/decisions/adopt_architectural_decision_records.md +58 -0
- package/docs/decisions/detect_sign_in.md +124 -0
- package/docs/decisions/pdfjs_version_2024_08_08.md +18 -0
- package/docs/decisions/reports_and_logs_2024_08_11.md +141 -0
- package/docs/decisions/update_puppeteer_2024_07_28.md +62 -0
- package/docs/story_tables.md +1 -1
- package/lib/docassemble/docassemble_api_REST.js +67 -1
- package/lib/docassemble/docassemble_api_interface.js +225 -18
- package/lib/docassemble/server_install.js +23 -9
- package/lib/docassemble/setup.js +33 -20
- package/lib/docassemble/takedown.js +27 -7
- package/lib/run_cucumber.js +83 -33
- package/lib/scope.js +222 -82
- package/lib/steps.js +206 -62
- package/lib/utils/files.js +8 -6
- package/lib/utils/log.js +477 -84
- package/lib/utils/reports.js +14 -5
- package/lib/utils/session_vars.js +25 -18
- package/lib/utils/time.js +44 -0
- package/npm-shrinkwrap.json +635 -193
- package/package.json +8 -8
- package/setup.py +1 -1
- package/tests/log_codes/check_codes.sh +163 -108
- package/tests/log_codes/log_code_expected_instances.txt +213 -0
- package/tests/unit_tests/getAllFields.test.js +5 -0
- package/tests/unit_tests/getMatchingRows.test.js +5 -0
- package/tests/unit_tests/log.test.js +20 -0
- package/tests/unit_tests/normalizeTable.test.js +5 -0
- package/tests/log_codes/deleted_codes.json +0 -8
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Use response data to detect sign-in success
|
|
2
|
+
|
|
3
|
+
## Context and Problem Statement
|
|
4
|
+
|
|
5
|
+
What is a robust way to detect whether signing in worked or not?
|
|
6
|
+
|
|
7
|
+
## Considered Options
|
|
8
|
+
|
|
9
|
+
- Elements in the DOM.
|
|
10
|
+
- Use some class or ID that only the sign-in page has, so we can detect that a user is on a new page and succeeded.
|
|
11
|
+
- User-facing invalidation message elements in the DOM on failure.
|
|
12
|
+
- URL change.
|
|
13
|
+
- Response data.
|
|
14
|
+
|
|
15
|
+
## Decision Outcome
|
|
16
|
+
|
|
17
|
+
Use a change in the URL to detect sign-in navigation.
|
|
18
|
+
|
|
19
|
+
## Pros and Cons of the Options
|
|
20
|
+
|
|
21
|
+
### DOM
|
|
22
|
+
|
|
23
|
+
Pros:
|
|
24
|
+
|
|
25
|
+
- It can be easy to do with the tools we are using.
|
|
26
|
+
|
|
27
|
+
Cons:
|
|
28
|
+
|
|
29
|
+
- The DOM can, and has been, changed by docassemble and these kinds of changes are made pretty quietly so we find it hard to keep track of them.
|
|
30
|
+
- It is pretty easy for site developers to change the HTML of standard pages like the sign-in page.
|
|
31
|
+
|
|
32
|
+
### URL change
|
|
33
|
+
|
|
34
|
+
Pros:
|
|
35
|
+
|
|
36
|
+
- It seems very likely that developers will keep an unsuccessful sign-in on the same page, even if they change some other functionality.
|
|
37
|
+
- It seems very likely that developers will change the url when the sign-in succeeds.
|
|
38
|
+
- Sticking with checking the url would mesh with how we currently detecting page navigation. See the cons for issues with that.
|
|
39
|
+
|
|
40
|
+
Cons:
|
|
41
|
+
|
|
42
|
+
- It seems precarious, though I haven't yet been able to articulate why. I know it hasn't been a sufficient full solution in the past for interview pages. For example, in a `show if` infinite page loop.
|
|
43
|
+
- Developers can manipulate a page's url, though it seems unlikely in this situation.
|
|
44
|
+
|
|
45
|
+
### Response data
|
|
46
|
+
|
|
47
|
+
Use the response data from the sign in request.
|
|
48
|
+
|
|
49
|
+
Pros:
|
|
50
|
+
|
|
51
|
+
- It seems reliable - it seems very likely that developers will re-direct their users to a different page, even if they change some other functionality.
|
|
52
|
+
- Less likely to change than the DOM.
|
|
53
|
+
- Has some standard values we can expect, like status codes.
|
|
54
|
+
|
|
55
|
+
Cons:
|
|
56
|
+
|
|
57
|
+
- DA's responses are not typical. There's no 400's in unsuccessful responses.
|
|
58
|
+
- Regular interview page navigation doesn't get a 302, so this method would be a special case for signing in.
|
|
59
|
+
|
|
60
|
+
Options are:
|
|
61
|
+
|
|
62
|
+
- 302 redirection status. It seems fairly reliable that a developer will send a user to a different page after they sign in, and also likely that they will keep the user on the same page if the sign-in failed.
|
|
63
|
+
- Cache-Control header value that contains "must-revalidate" (See [MDN cache control directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives)). It makes sure this data isn't cached. I'm not familiar with this and I'm not sure what might or might not trigger this.
|
|
64
|
+
- Cookie with the name "secret". This seems promising, but I don't know much about cookies.
|
|
65
|
+
|
|
66
|
+
Based on our current knowledge, we think the 302 status response will be most reliable.
|
|
67
|
+
|
|
68
|
+
Notes for response data:
|
|
69
|
+
|
|
70
|
+
I have isolated the differences between the sign-in success and failure responses.
|
|
71
|
+
|
|
72
|
+
Key for following entries:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
<key of object containing the data>
|
|
76
|
+
🌈 <sign in success data>
|
|
77
|
+
vs
|
|
78
|
+
🤕 <sign in failure data>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Findings:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
response
|
|
85
|
+
🌈 "redirectURL": "/path", "headersSize": 552, "bodySize": 0, "_transferSize": 552,
|
|
86
|
+
vs
|
|
87
|
+
🤕 "redirectURL": "", "headersSize": 570, "bodySize": 1998, "_transferSize": 2568,
|
|
88
|
+
---
|
|
89
|
+
response
|
|
90
|
+
🌈 "status": 302, "statusText": "FOUND",
|
|
91
|
+
vs
|
|
92
|
+
🤕 "status": 200, "statusText": "OK",
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
headers
|
|
96
|
+
🌈 no cache-control
|
|
97
|
+
vs
|
|
98
|
+
🤕 { "name": "Cache-Control", "value": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0" },
|
|
99
|
+
---
|
|
100
|
+
headers
|
|
101
|
+
🌈 { "name": "Content-Length", "value": "209" },
|
|
102
|
+
vs
|
|
103
|
+
🤕 { "name": "Content-Encoding", "value": "gzip" },
|
|
104
|
+
---
|
|
105
|
+
headers
|
|
106
|
+
🌈 { "name": "Location", "value": "/interviews" },
|
|
107
|
+
vs
|
|
108
|
+
🤕 no location
|
|
109
|
+
---
|
|
110
|
+
headers
|
|
111
|
+
🌈 { "name": "Set-Cookie", "value": "secret=secretchars; Secure; HttpOnly; Path=/; SameSite=Lax" },
|
|
112
|
+
vs
|
|
113
|
+
🤕 no secret
|
|
114
|
+
---
|
|
115
|
+
headers
|
|
116
|
+
🌈 no transfer-encoding
|
|
117
|
+
vs
|
|
118
|
+
🤕 { "name": "Transfer-Encoding", "value": "chunked" },
|
|
119
|
+
---
|
|
120
|
+
cookies
|
|
121
|
+
🌈 { "name": "secret", "value": "secretchars", "path": "/", "domain": "site.com", "expires": null, "httpOnly": true, "secure": true, "sameSite": "Lax" },
|
|
122
|
+
vs
|
|
123
|
+
🤕 no secret
|
|
124
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Leave pdfjs at its current version
|
|
2
|
+
|
|
3
|
+
## Context and Problem Statement
|
|
4
|
+
|
|
5
|
+
pdfjs has a security vulnerability (that does not affect us) where malicious PDFs can inject code into an unsuspecting project and cause havoc.
|
|
6
|
+
|
|
7
|
+
Our users are downloading and manipulating their own PDFs. We will assume they're not putting malicious code into their PDFs.
|
|
8
|
+
|
|
9
|
+
The update changes pdfjs .js files to be .mjs files. It might take some bother to configure our repo to use .mjs files.
|
|
10
|
+
|
|
11
|
+
## Considered Options
|
|
12
|
+
|
|
13
|
+
- Update pdfjs
|
|
14
|
+
- Leave pdfjs at its current version, 3.2.146
|
|
15
|
+
|
|
16
|
+
## Decision Outcome
|
|
17
|
+
|
|
18
|
+
Leave pdfjs at its current version, 3.2.146. The vulnerability is irrelevant for our situation and we don't have bandwidth to set up the configurations right now.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Shape and behavior of the report and log objects
|
|
2
|
+
|
|
3
|
+
## Context and scope
|
|
4
|
+
|
|
5
|
+
We have reports and logs we show to the user in the console and as artifacts. We have logs we use for development. cucumber also has logs we want to include in the above until we are confident we are handling all cases ourselves.
|
|
6
|
+
|
|
7
|
+
Right now, the system for logging is fractured and scattered - reports log to the console and save completely separately from other logs. Logs that are not from the report don't get saved anywhere. Some logs only get shown in debug mode, which can be frustrating and unhelpful.
|
|
8
|
+
|
|
9
|
+
## Goals
|
|
10
|
+
|
|
11
|
+
Overview:
|
|
12
|
+
|
|
13
|
+
- Unify the logging and report systems
|
|
14
|
+
- Clarify their flow
|
|
15
|
+
- Make log information more visible
|
|
16
|
+
|
|
17
|
+
Details:
|
|
18
|
+
|
|
19
|
+
- Log objects have statuses, icons, log codes (e.g. ALK0105), contextual info (e.g. `setup`, `takedown`, `invalid answer`), timestamps, descriptive text, and data (like full error traces).
|
|
20
|
+
- These are the broad purposes of various logs:
|
|
21
|
+
1. Setup and takedown messages.
|
|
22
|
+
2. Test progress (a compact way to see what's happening/happened in each test):
|
|
23
|
+
|
|
24
|
+
Test1: .............F--
|
|
25
|
+
|
|
26
|
+
Test 2: ..
|
|
27
|
+
3. A pretty report at the end with details about each test. It has sections, like "failed" and "passed", headings, etc.
|
|
28
|
+
4. cucumber's various console logs
|
|
29
|
+
5. Lots of other informational logs for internal development and debugging purposes.
|
|
30
|
+
I want to do different things with different logs:
|
|
31
|
+
- During the tests, always log items 1, 2, 3, and 4 to the console.
|
|
32
|
+
- During the tests, save items 2, 3, and 4 to a log as they come with all the info in the log objects - `report_log.txt`/`running_report.txt`/`report_run.txt` maybe. If we have to stop the tests early because of an infinite loop or something, this will at least show some information.
|
|
33
|
+
- At the end of the tests, format items 2, 3, and 4, often with only part of the log object info, in a file called `report.txt`.
|
|
34
|
+
- During the tests, save all of the items to a `verbose_log.txt` as they happen.
|
|
35
|
+
- In debug mode, log all that stuff to the console while the tests are running.
|
|
36
|
+
Right now, a few of the logs, like for the test progress (item 2), are printed with `stdout` inline while all others are logged with `console.log`.
|
|
37
|
+
- Logs should accept multiple arguments to match console.log/etc. behavior.
|
|
38
|
+
|
|
39
|
+
Note: The progress logs printed to the console have color codes. We also may want a plain text version without any colors to save in the report log and show in the Playground[^1] "console" and/or a version converted to HTML that does have styles. The latter may be for something easier to digest in a browser and/or to show visually in the Playground version of the tests.
|
|
40
|
+
|
|
41
|
+
Questions:
|
|
42
|
+
- Should `log` throw errors? Otherwise everywhere we need to error, we need to use `log` and `throw`, but I am unable to find a way to remove the current function from an error stack/trace.
|
|
43
|
+
- How do we capture "errors" that are more subtle? Keep the word "error" in the "context"/"types" list? For example, expected errors:
|
|
44
|
+
- Invalid answers on the form that are then assessed as valid behavior?
|
|
45
|
+
- `AbortError`s of promises that should indeed have been aborted.
|
|
46
|
+
- Should we allow "in-between"s for all parts of the log? All together: pre-everything (new lines, dividers, etc), icon/context/etc., pre-logs, logs (the actual messages to print), pre-data, data, post-data? We can default to nothing for all of those.
|
|
47
|
+
- How do we differentiate between methods that log to the console vs. methods that just store data?
|
|
48
|
+
|
|
49
|
+
[^1]: Don't go down this rabbit hole. Broadly - with the "Playground" version, users see the results as a web page instead of in the GitHub job console or in the artifacts. The users run the tests on their own server. This has to do with the platform we built ALKiln for - [docassemble](https://docassemble.org/). It gives users a faster iteration cycle.
|
|
50
|
+
|
|
51
|
+
## Non/anti-goals
|
|
52
|
+
|
|
53
|
+
- Spend a month on this
|
|
54
|
+
- Create a complex and heavy system to try to abstract absolutely everything
|
|
55
|
+
|
|
56
|
+
## The actual design
|
|
57
|
+
|
|
58
|
+
This design still seems a little complex and potentially too coupled with reports.
|
|
59
|
+
|
|
60
|
+
### System-context diagram
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
logic code -> logger -> report -----------> console
|
|
64
|
+
^ |-> console |-> stdout/progress
|
|
65
|
+
cucumber ---| |-> running report |-> final report.txt
|
|
66
|
+
|-> verbose log
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
logic code -> logger ------> report ------> final report.txt
|
|
71
|
+
^ |-> console
|
|
72
|
+
cucumber ---| |-> stdout/inline/progress
|
|
73
|
+
|-> running report
|
|
74
|
+
|-> verbose log
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
|------------------------------------<|
|
|
79
|
+
v |
|
|
80
|
+
logic code -> logger -> report -----------> format prettily
|
|
81
|
+
^ |-> console
|
|
82
|
+
cucumber ---| |-> running report
|
|
83
|
+
|-> verbose log
|
|
84
|
+
|-> stdout/progress
|
|
85
|
+
|-> final report.txt
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### APIs
|
|
89
|
+
|
|
90
|
+
Everything saves to the "verbose"/"debug" log. Aside from that:
|
|
91
|
+
|
|
92
|
+
`log.info/warning/success/error` methods log to console. This includes, e.g, setup, takedown which show up in GitHub workflow job logs.
|
|
93
|
+
|
|
94
|
+
`log.report` saves to the running report then uses a report obj focused on cosmetics that has `.heading/table/header/error/etc` methods. Maybe a `.stdout/inlne` method, which then prints to the console immediately.
|
|
95
|
+
|
|
96
|
+
`log.verbose/debug` (name?) - Only save to verbose/debug log with log codes, etc.
|
|
97
|
+
|
|
98
|
+
### Data storage
|
|
99
|
+
|
|
100
|
+
- `report.txt` - final pretty output for the user with headings, etc.
|
|
101
|
+
- Each Scenario's `report.txt` - pretty output in each test's folder.
|
|
102
|
+
- `running_report_log.txt` (name?) - ugly, but still sparse, giving the user some info about what happened during the tests without overwhelming them.
|
|
103
|
+
- `verbose.txt` (name? `debug`?) - very ugly and full of all the information from everywhere else and more. Useful for internal development and troubleshooting. Includes setup and takedown.
|
|
104
|
+
|
|
105
|
+
It may be complex to store setup and takedown output in the verbose/debug file. `console.Console` cannot append to a file[^2], so we would have to figure out a work-around. One approach could be to always first copy from the existing verbose file and paste those contents back into the file as the first log. That may take setting up some fallbacks to avoid errors.
|
|
106
|
+
|
|
107
|
+
[^2]: `fs.appendFile()` only takes strings and doesn't log exactly like the console. I want to log exactly like the console to make it easy to search for words I and others see in the console output.
|
|
108
|
+
|
|
109
|
+
### Code and pseudo-code
|
|
110
|
+
|
|
111
|
+
For capturing console output, look into how to get the `stdin` for capturing various console output. https://stackoverflow.com/a/54202970:
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
const stdin = process.openStdin()
|
|
115
|
+
|
|
116
|
+
process.stdout.write('Enter name: ')
|
|
117
|
+
|
|
118
|
+
stdin.addListener('data', text => {
|
|
119
|
+
const name = text.toString().trim()
|
|
120
|
+
console.log('Your name is: ' + name)
|
|
121
|
+
|
|
122
|
+
stdin.pause() // stop reading
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Degree of constraint
|
|
127
|
+
|
|
128
|
+
I think this can basically be greenfield (designed from scratch). We do have a current system, but I think we can easily convert our existing code to a new system.
|
|
129
|
+
|
|
130
|
+
## Alternatives considered
|
|
131
|
+
|
|
132
|
+
- The `report` object saves to the running report and then sends that same information to the `log` object. Also prints the final report. This includes `stdout` logs. `log` remains otherwise the same as described above.
|
|
133
|
+
- `log` handles `stdout` logs and leaves them out of the report.
|
|
134
|
+
- For report content, `log` would call to `report`, which would do pretty formatting and then hand the format text back to `log` to be saved and/or printed to the console. I'm not sure how `log` could then know what to do with the output - leave out the codes/etc. when it logs to the console and/or saves to the final report.txt.
|
|
135
|
+
- Avoid the complexity of storing setup and takedown output in the verbose/debug file. In GitHub, they're in the GitHub console. Locally, we see the results immediately. On the other hand, storing them ourselves lets us look for information in just one place.
|
|
136
|
+
|
|
137
|
+
## Cross-cutting concerns
|
|
138
|
+
|
|
139
|
+
_Security, privacy, observability, etc._
|
|
140
|
+
|
|
141
|
+
The same ones we've already dealt with for our current logs.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Use response data to detect sign-in success
|
|
2
|
+
|
|
3
|
+
## Context and Problem Statement
|
|
4
|
+
|
|
5
|
+
Should we update to the newest version of puppeteer, [22.15.0](https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/CHANGELOG.md#22150-2024-07-31)?
|
|
6
|
+
|
|
7
|
+
See https://github.com/SuffolkLITLab/ALKiln/issues/930.
|
|
8
|
+
|
|
9
|
+
## Considered Options
|
|
10
|
+
|
|
11
|
+
- Update to 22.15.0
|
|
12
|
+
- Update to 22.12.0, which is the lowest version that would fix our current problems
|
|
13
|
+
- Stay with 20.8.2
|
|
14
|
+
|
|
15
|
+
See pros and cons
|
|
16
|
+
|
|
17
|
+
## Decision Outcome
|
|
18
|
+
|
|
19
|
+
Update puppeteer from 20.8.2 to 22.15.0
|
|
20
|
+
|
|
21
|
+
## Pros and Cons of the Options
|
|
22
|
+
|
|
23
|
+
### Update at all {#update}
|
|
24
|
+
|
|
25
|
+
**Pros:**
|
|
26
|
+
|
|
27
|
+
- Makes the current fix possible
|
|
28
|
+
|
|
29
|
+
**Cons:**
|
|
30
|
+
|
|
31
|
+
- Change in the middle of a complex PR
|
|
32
|
+
- [A few breaking changes](https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/CHANGELOG.md#2200-2024-02-05), which includes for us at the very least:
|
|
33
|
+
- "Removes the deprecated `$x` (replace with `$$`) and `waitForXpath` (replace with `waitForSelector`)." We need to add [extra syntax to the start of our selector strings](https://github.com/puppeteer/puppeteer/pull/11782): "xpath//."
|
|
34
|
+
- Replace any `page.waitForTimeout` with cucumber's version or ours.
|
|
35
|
+
|
|
36
|
+
### Update to to 22.15.0
|
|
37
|
+
|
|
38
|
+
**Pros:**
|
|
39
|
+
|
|
40
|
+
- Has all the most recent bug fixes and features
|
|
41
|
+
|
|
42
|
+
**Cons:**
|
|
43
|
+
|
|
44
|
+
- Exposes us to possible unknown new bugs
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Update to to 22.12.0
|
|
48
|
+
|
|
49
|
+
This is the lowest version that would fix our problem
|
|
50
|
+
|
|
51
|
+
**Pros:**
|
|
52
|
+
|
|
53
|
+
- Avoids possibly unknown new bugs
|
|
54
|
+
|
|
55
|
+
**Cons:**
|
|
56
|
+
|
|
57
|
+
- Doesn't have fixes to already known bugs
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Stay with 20.8.2
|
|
61
|
+
|
|
62
|
+
Opposite of first entry ["Update at all"](#update).
|
package/docs/story_tables.md
CHANGED
|
@@ -4,7 +4,7 @@ The Story Table is a very flexible tool. It lets the author answer interview (fo
|
|
|
4
4
|
|
|
5
5
|
When the robot arrives on each interview page, it finds all the fields on the page and loops through the whole Story Table trying to match rows with fields.
|
|
6
6
|
|
|
7
|
-
Here's some [documentation on the use of Story Table rows](https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln
|
|
7
|
+
Here's some [documentation on the use of Story Table rows](https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing#story-table).
|
|
8
8
|
|
|
9
9
|
## Tracking use of rows
|
|
10
10
|
|
|
@@ -31,7 +31,28 @@ da.get_dev_id = async function ( timeout ) {
|
|
|
31
31
|
}; // Ends da.get_dev_id()
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
da.get_api_key_info = async function ( timeout, { api_key = null, server_url = null }) {
|
|
35
|
+
/** Get information about an API key owned by the user of the given API key. */
|
|
36
|
+
let options = {
|
|
37
|
+
method: 'GET',
|
|
38
|
+
headers: {'X-API-Key': api_key},
|
|
39
|
+
url: `${ server_url }/api/user/api`,
|
|
40
|
+
params: {
|
|
41
|
+
api_key: api_key,
|
|
42
|
+
},
|
|
43
|
+
timeout: timeout,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
return await axios.request( options );
|
|
48
|
+
} catch (error) {
|
|
49
|
+
let response = error.response || { data: null }
|
|
50
|
+
throw {...error.toJSON(), data: response.data};
|
|
51
|
+
}
|
|
52
|
+
}; // Ends da.get_api_key_info()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// node -e 'require("./lib/docassemble/docassemble_api_REST.js").delete_project()'
|
|
35
56
|
da.delete_project = async function ( timeout ) {
|
|
36
57
|
/* Delete a project on the user's da server. */
|
|
37
58
|
let options = {
|
|
@@ -53,6 +74,51 @@ da.delete_project = async function ( timeout ) {
|
|
|
53
74
|
}; // Ends da.delete_project()
|
|
54
75
|
|
|
55
76
|
|
|
77
|
+
// node -e 'require("./lib/docassemble/docassemble_api_REST.js").delete_interview(...)'
|
|
78
|
+
da.delete_interview = async function ( timeout, { session = null, api_key = null }) {
|
|
79
|
+
/* Delete an interview with the given session id. */
|
|
80
|
+
let options = {
|
|
81
|
+
method: 'DELETE',
|
|
82
|
+
headers: { 'X-API-Key': api_key },
|
|
83
|
+
// Can't use `api/session` that uses the API key to identify the user's
|
|
84
|
+
// interview sessions. The test may have signed in with an account
|
|
85
|
+
// that's different than the ALKiln dev account that sends this request.
|
|
86
|
+
url: `${ session_vars.get_da_server_url() }/api/user/interviews`,
|
|
87
|
+
params: { session },
|
|
88
|
+
timeout: timeout,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
return await axios.request( options );
|
|
93
|
+
} catch (error) {
|
|
94
|
+
let response = error.response || {data: null}
|
|
95
|
+
throw {...error.toJSON(), data: response.data};
|
|
96
|
+
}
|
|
97
|
+
}; // Ends da.delete_interview()
|
|
98
|
+
|
|
99
|
+
// node -e 'require("./lib/docassemble/docassemble_api_REST.js").get_interview(...)'
|
|
100
|
+
da.get_interview = async function ( timeout, { session = null, api_key = null }) {
|
|
101
|
+
/* Get a specific interview. */
|
|
102
|
+
let options = {
|
|
103
|
+
method: 'GET',
|
|
104
|
+
headers: { 'X-API-Key': api_key },
|
|
105
|
+
// Can't use `/api/user/interviews` that uses the API key to identify the user's
|
|
106
|
+
// interview sessions. The test may have signed in with an account
|
|
107
|
+
// that's different than the ALKiln dev account that sends this request.
|
|
108
|
+
url: `${ session_vars.get_da_server_url() }/api/user/interviews`,
|
|
109
|
+
params: { session },
|
|
110
|
+
timeout: timeout,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
return await axios.request( options );
|
|
115
|
+
} catch ( error ) {
|
|
116
|
+
let response = error.response || { data: null }
|
|
117
|
+
throw { ...error.toJSON(), data: response.data };
|
|
118
|
+
}
|
|
119
|
+
}; // Ends da.get_interview()
|
|
120
|
+
|
|
121
|
+
|
|
56
122
|
// node -e 'require("./lib/docassemble/docassemble_api_REST.js").__delete_projects_starting_with( "testingdocassembleALAutomatedTestingTestsmain", 1, 1 )'
|
|
57
123
|
da.__delete_projects_starting_with = async function ( base_name, starting_num=1, ending_num ) {
|
|
58
124
|
/** FOR DEVELOPMENT ONLY. Deletes a set of Projects that start with a shared
|