Skip to content

Commit 8519a2a

Browse files
committed
chore: inital commit
0 parents  commit 8519a2a

File tree

725 files changed

+80174
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

725 files changed

+80174
-0
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '21 7 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
language: [ 'javascript' ]
32+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33+
# Learn more:
34+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v2
39+
40+
# Initializes the CodeQL tools for scanning.
41+
- name: Initialize CodeQL
42+
uses: github/codeql-action/init@v1
43+
with:
44+
languages: ${{ matrix.language }}
45+
# If you wish to specify custom queries, you can do so here or in a config file.
46+
# By default, queries listed here will override any specified in a config file.
47+
# Prefix the list here with "+" to use these queries and those in the config file.
48+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
49+
50+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51+
# If this step fails, then you should remove it and run the build manually (see below)
52+
- name: Autobuild
53+
uses: github/codeql-action/autobuild@v1
54+
55+
# ℹ️ Command-line programs to run using the OS shell.
56+
# 📚 https://git.io/JvXDl
57+
58+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59+
# and modify them (or add more) to build your code if your project
60+
# uses a compiled language
61+
62+
#- run: |
63+
# make bootstrap
64+
# make release
65+
66+
- name: Perform CodeQL Analysis
67+
uses: github/codeql-action/analyze@v1

.github/workflows/deployment.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Tests and publishing
2+
env:
3+
FORCE_COLOR: 1
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
- develop
10+
pull_request:
11+
branches:
12+
- master
13+
- main
14+
jobs:
15+
test_linux:
16+
name: Ubuntu
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-node@v1
21+
with:
22+
node-version: 14
23+
- uses: microsoft/playwright-github-action@v1
24+
- uses: actions/cache@v1
25+
with:
26+
path: ~/.npm
27+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-node-
30+
- name: Install dependencies
31+
run: npm ci
32+
- name: Run tests
33+
run: npm test
34+
test_win:
35+
name: "Windows"
36+
runs-on: windows-latest
37+
steps:
38+
- uses: actions/checkout@v2
39+
- uses: actions/setup-node@v1
40+
with:
41+
node-version: 14
42+
- uses: microsoft/playwright-github-action@v1
43+
- uses: actions/cache@v1
44+
with:
45+
path: ~/.npm
46+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
47+
restore-keys: |
48+
${{ runner.os }}-node-
49+
- name: Install dependencies
50+
run: npm ci
51+
- name: Run tests
52+
run: npm test
53+
tag:
54+
name: "Publishing release"
55+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
56+
needs:
57+
- test_linux
58+
- test_win
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v2
63+
with:
64+
fetch-depth: 0
65+
- uses: actions/setup-node@v2
66+
with:
67+
node-version: '14.x'
68+
registry-url: 'https://registry.npmjs.org'
69+
- uses: actions/cache@v1
70+
with:
71+
path: ~/.npm
72+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
73+
restore-keys: |
74+
${{ runner.os }}-node-
75+
- run: npm install
76+
- name: Read version from package.json
77+
uses: culshaw/read-package-node-version-actions@v1
78+
id: package-node-version
79+
- name: Changelog
80+
uses: scottbrenner/generate-changelog-action@master
81+
id: Changelog
82+
- name: Github Release
83+
id: create_release
84+
uses: actions/create-release@latest
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
with:
88+
tag_name: v${{ steps.package-node-version.outputs.version }}
89+
release_name: v${{ steps.package-node-version.outputs.version }}
90+
body: |
91+
${{ steps.Changelog.outputs.changelog }}
92+
draft: false
93+
prerelease: false
94+
- run: npm publish --access public
95+
env:
96+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# General
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
6+
# Icon must end with two \r
7+
Icon
8+
9+
10+
# Thumbnails
11+
._*
12+
13+
# Windows thumbnail cache files
14+
Thumbs.db
15+
ehthumbs.db
16+
ehthumbs_vista.db
17+
18+
# Dump file
19+
*.stackdump
20+
21+
# Folder config file
22+
[Dd]esktop.ini
23+
24+
# Recycle Bin used on file shares
25+
$RECYCLE.BIN/
26+
27+
# Windows Installer files
28+
*.cab
29+
*.msi
30+
*.msix
31+
*.msm
32+
*.msp
33+
34+
# Windows shortcuts
35+
*.lnk
36+
37+
.vscode/*
38+
!.vscode/settings.json
39+
!.vscode/tasks.json
40+
!.vscode/launch.json
41+
!.vscode/extensions.json
42+
43+
*~
44+
45+
# temporary files which can be created if a process still has a handle open of a deleted file
46+
.fuse_hidden*
47+
48+
# KDE directory preferences
49+
.directory
50+
51+
# Linux trash folder which might appear on any partition or disk
52+
.Trash-*
53+
54+
# .nfs files are created when an open file is removed but is still being accessed
55+
.nfs*
56+
57+
node_modules
58+
coverage
59+
demo/vendor.js
60+
61+
# AMF models
62+
demo/models/
63+
64+
.idea/

.npmignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage/
2+
test/
3+
demo/
4+
CONTRIBUTING.md
5+
polymer.json
6+
karma.*
7+
.*
8+
demo/vendor.js
9+
custom-elements.json
10+
tsconfig.json

.vscode/settings.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"cSpell.words": [
3+
"apirequest",
4+
"apiserverchanged",
5+
"Applian",
6+
"contentinfo",
7+
"dompurify",
8+
"fasttext",
9+
"formdata",
10+
"httpbin",
11+
"mimechange",
12+
"monostate",
13+
"Nexmo",
14+
"notryit",
15+
"onapiserverchange",
16+
"onserverscountchange",
17+
"securitysettingsinfochanged",
18+
"serverscountchanged",
19+
"signedup",
20+
"stevetest",
21+
"Tryit",
22+
"Unionable",
23+
"xone"
24+
]
25+
}

CHANGELOG.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Changelog
2+
3+
## ApiResourceDocumentElement (former api-endpoint-documentation)
4+
5+
The `api-resource-document` element has the following properties changes compared to deprecated `api-endpoint-documentation`
6+
7+
- `noTryIt` is renamed to `tryItButton`. When `tryItButton` is set then the try it button in operations is rendered.
8+
- `inlineMethods` is renamed to `tryItPanel`. Has the same function.
9+
- `noUrlEditor` is now renamed to `urlEditor`. When `urlEditor` is set then the HTTP request editor renders the URL editor input field.
10+
11+
## ApiOperationDocumentElement (former api-operation-documentation)
12+
13+
- `tryIt` is renamed to `tryItButton`
14+
- `tryItButton` is always set to `false` when `tryItPanel` is set on the resource document element.
15+
16+
## Authorization
17+
18+
### Configuration and HTTP request
19+
20+
The authorization has been moved into this library and has a new API surface.
21+
22+
The request object generated by the request editor has a new `authorization` property (`auth` in version 0.2.0).
23+
It is a list of authorization settings defined by the user and/or the API.
24+
25+
By default the application that hosts the element must apply the authorization setting to the request. When the `applyAuthorization` property is set on the editor / panel then before dispatching the request authorization configuration is applied to the HTTP message (headers, URL). When applying the configuration to the request object, it sets the `enabled` property of the authorization settings object to `false`. Any processor that handled the request event should not process authorization values that are not enabled.
26+
27+
To maximize the compatibility with 0.2.0 use the following configuration:
28+
29+
```html
30+
<api-request-editor
31+
applyAuthorization
32+
></api-request-editor>
33+
```
34+
35+
## Caching values
36+
37+
The editor has a new boolean property `globalCache`. Once set it instruct the caching mechanism to cache user input in memory. The cached values are kept in memory even when API spec change.
38+
Use the `src/lib/InputCache.js` class to manipulate the cache programmatically when needed.
39+
40+
When the `globalCache` is not set then the values are stored in a reference to the editor element. After removing the element from the DOM all cached properties are GC'd.
41+
42+
## Request editor
43+
44+
### Refactor
45+
46+
- `serializeRequest()` -> `serialize()`
47+
- removed option `allowDisableParams`
48+
49+
### Setting URL values (baseUri, protocols, server)
50+
51+
With version `0.2.x` it was possible to set `server`, `baseUri`, and `protocols` properties so the component is able to compute the endpoint URL without having the `server` value read from the AMF graph model. This turned out to be a feature that is not used so it is removed in `0.3.0`. Use `baseUri` to override any value defined in the servers.
52+
Note, when `baseUri` is set it takes precedence over any other URI configuration (like a selected server).
53+
54+
## URL editor
55+
56+
The URL editor is optional by default. The input won't be rendered until the `urlEditor` property is set.
57+
For a better user experience do not set this option unless crucial for the application. To give user a feedback when updating parameters use option `urlLabel`.
58+
59+
Additionally, the user entered values are now updated on input value change rather than user input. This reduces UI changes (especially with URL editor enabled) while typing value into the editor.
60+
61+
## Body editor
62+
63+
The body editor has been re-created from scratch. The new editor uses monaco editor to render the body input.
64+
This requires loading monaco environment before the editor is rendered and activated.
65+
66+
Use the `MonacoLoader` class from the `@advanced-rest-client/monaco-support` package to load the editor with the required dependencies.
67+
68+
```javascript
69+
import { MonacoLoader } from '@advanced-rest-client/monaco-support';
70+
71+
// the base path from the current location to the editor location.
72+
const base = `../node_modules/monaco-editor/`;
73+
MonacoLoader.createEnvironment(base); // creates an environment to load the dependencies
74+
await MonacoLoader.loadMonaco(base); // initializes the monaco editor.
75+
await MonacoLoader.monacoReady(); // waits until all libraries are loaded.
76+
```
77+
78+
Note, Monaco does not support encapsulation. Once loaded a global `Monaco` variable is created.
79+
80+
## Events
81+
82+
With this version the following events are deprecated:
83+
84+
- ~~api-request~~
85+
- ~~abort-api-request~~
86+
- ~~api-response~~
87+
88+
All DOM event types should be lowercase [a-z] names. This version dispatches both new and old events. The deprecated events will be removed in the future.
89+
90+
Use the following evens instead:
91+
92+
- `apirequest`
93+
- `apiabort`
94+
- `apiresponse`
95+
96+
Also, use the `src/events/EventTypes.js` and `src/events/RequestEvents.js` definitions to dispatch or handle the events:
97+
98+
```javascript
99+
import { EventTypes, RequestEvents } from '@api-components/api-request';
100+
101+
// handle a request event
102+
window.addEventListener(EventTypes.Request.apiRequest, (e) => {
103+
console.log(e.detail);
104+
});
105+
106+
// dispatch the request event
107+
RequestEvents.apiRequest(window, { /* the request definition */ });
108+
```
109+
110+
## Tests
111+
112+
The tests for Firefox currently fails because `playwright` uses a previous version of the browser which has no support for ES modules in web workers. However, the current version support them. Firefox is temporarily removed from tests.

0 commit comments

Comments
 (0)