@duffel/components 3.0.6-canary → 3.0.7-canary
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/.eslintrc.js +6 -1
- package/.github/workflows/release.yml +1 -1
- package/CONTRIBUTING.md +6 -54
- package/README.md +24 -1
- package/config/esbuild.dev.config.js +1 -1
- package/package.json +1 -1
- package/react-dist/custom-elements.js +3 -3
- package/react-dist/custom-elements.js.map +1 -1
- package/react-dist/index.js +3 -3
- package/react-dist/index.js.map +1 -1
- package/src/examples/client-side/README.md +30 -0
- package/src/examples/full-stack/README.md +34 -0
package/.eslintrc.js
CHANGED
|
@@ -9,7 +9,12 @@ module.exports = {
|
|
|
9
9
|
node: true,
|
|
10
10
|
jest: true,
|
|
11
11
|
},
|
|
12
|
-
ignorePatterns: [
|
|
12
|
+
ignorePatterns: [
|
|
13
|
+
"**/dist/**",
|
|
14
|
+
"**/cdn-dist/**",
|
|
15
|
+
"**/react-dist/**",
|
|
16
|
+
"__generated__**",
|
|
17
|
+
],
|
|
13
18
|
parser: "@typescript-eslint/parser",
|
|
14
19
|
extends: [
|
|
15
20
|
"eslint:recommended",
|
|
@@ -62,7 +62,7 @@ jobs:
|
|
|
62
62
|
if: steps.initversion.outputs.version != steps.extractver.outputs.extractver
|
|
63
63
|
uses: peter-evans/create-pull-request@v3.10.0
|
|
64
64
|
with:
|
|
65
|
-
token: ${{ secrets.PAT }}
|
|
65
|
+
token: ${{ secrets.PAT }} # You can fin this on https://duffel.1password.com/vaults/all/allitems/m3heg3y3ijclli4tmmp4bsyxna
|
|
66
66
|
commit-message: "chore(release): ${{ steps.extractver.outputs.extractver }}"
|
|
67
67
|
committer: duffel-bot <duffel-bot-read-write@duffel.com>
|
|
68
68
|
author: duffel-bot <duffel-bot-read-write@duffel.com>
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,52 +1,3 @@
|
|
|
1
|
-
## How do I integrate this into my website?
|
|
2
|
-
|
|
3
|
-
1. Please start by reading our integration guide on https://duffel.com/docs/guides/ancillaries-component
|
|
4
|
-
2. You can also find examples code in the `example` folder (see below).
|
|
5
|
-
|
|
6
|
-
## Integration examples
|
|
7
|
-
|
|
8
|
-
We have two ways to run the example.
|
|
9
|
-
|
|
10
|
-
### 1. Full stack
|
|
11
|
-
|
|
12
|
-
This example has a server that will reach out to the Duffel API to search and retrieve an offer.
|
|
13
|
-
To talk to the API we'll define the url to the API environment we want and .
|
|
14
|
-
Please add the following to `.env.local`:
|
|
15
|
-
|
|
16
|
-
```sh
|
|
17
|
-
# .env.local
|
|
18
|
-
|
|
19
|
-
# Used to authenticate our
|
|
20
|
-
# example server to talk to Duffel
|
|
21
|
-
DUFFEL_API_TOKEN=test_duffel_dev_rw
|
|
22
|
-
|
|
23
|
-
# The Duffel API environment we want
|
|
24
|
-
# to talk. Remember to update the key
|
|
25
|
-
# if this value changes.
|
|
26
|
-
DUFFEL_API_URL=https://localhost:4000;
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
This is a 'real life' example, where it uses a real offer ID and client key retrieved from the Duffel API. To run this, use `yarn run-example:full-stack`. This command will:
|
|
30
|
-
|
|
31
|
-
1. Serve the Duffel component bundle and watch for changes to rebuild on port `8000`. This can also be done with `yarn dev`
|
|
32
|
-
2. Run the full stack server using node. The example page will be ready on port `6262`. This can be done with `yarn run-full-stack-server`
|
|
33
|
-
|
|
34
|
-
### What do I need to do to use the component with a local version of the Duffel API?
|
|
35
|
-
|
|
36
|
-
- Make sure you visit https://localhost:4000 to allow your browser to make requests to it.
|
|
37
|
-
- Make sure the org your are using has the [flags enabled](http://localhost:4242/features):
|
|
38
|
-
- `ancillaries_component_enable_client_key`
|
|
39
|
-
- `ancillaries_component_enable_client_key_endpoints`
|
|
40
|
-
|
|
41
|
-
### 2. Client side with fixtures
|
|
42
|
-
|
|
43
|
-
For a more basic example that doesn't rely on the Duffel API, use `yarn run-example:client-side`.
|
|
44
|
-
|
|
45
|
-
This command will:
|
|
46
|
-
|
|
47
|
-
1. Serve the Duffel component bundle and watch for changes to rebuild on port `8000`. This can also be done with `yarn dev`
|
|
48
|
-
2. Host a basic `index.html` with `http-server`. The example page will be ready on port `6262`. This can be done with `yarn run-client-side-server`
|
|
49
|
-
|
|
50
1
|
## Debug mode
|
|
51
2
|
|
|
52
3
|
The component takes a `debug` boolean prop. When enabled, debug output is logged to the console, with useful info like the props that were passed in. This is intended both for our internal use and for users integrating it.
|
|
@@ -61,9 +12,9 @@ Debug mode makes use of a logger, which selectively outputs to the console based
|
|
|
61
12
|
|
|
62
13
|
Our CDN is [hosted on Google Cloud Platform](<https://console.cloud.google.com/storage/browser/duffel-assets/components/ancillaries?pageState=(%22StorageObjectListTable%22:(%22f%22:%22%255B%255D%22))&project=duffel-prod-fda1bc52&prefix=&forceOnObjectsSortingFiltering=false>). To upload new changes you'll need to have `gcloud` intalled and authenticate with GCP. You can do this by running `gcloud auth login` and following the instructions.
|
|
63
14
|
|
|
64
|
-
### Setup
|
|
15
|
+
### Setup environment
|
|
65
16
|
|
|
66
|
-
Make sure you have an up-to-date version of `.env.build
|
|
17
|
+
Make sure you have an up-to-date version of `.env.build`:
|
|
67
18
|
|
|
68
19
|
```sh
|
|
69
20
|
# .env.build
|
|
@@ -76,7 +27,7 @@ DUFFEL_API_URL=https://api.duffel.com
|
|
|
76
27
|
# This is needed so the component knows the url base to use for its stylesheet
|
|
77
28
|
# This variable is here so we can release component versions that may point to local environments or bypass the cache.
|
|
78
29
|
# If no value is provided, the default `https://assets.duffel.com/ancillaries-component` will be used.
|
|
79
|
-
COMPONENT_CDN=https://assets.duffel.com/components
|
|
30
|
+
COMPONENT_CDN=https://assets.duffel.com/components
|
|
80
31
|
|
|
81
32
|
# The auth token is so we send data
|
|
82
33
|
# to sentry during the build.
|
|
@@ -109,7 +60,7 @@ This command will:
|
|
|
109
60
|
|
|
110
61
|
### Build component
|
|
111
62
|
|
|
112
|
-
#### Build
|
|
63
|
+
#### Build for CDN upload
|
|
113
64
|
|
|
114
65
|
```sh
|
|
115
66
|
yarn cdn-build # Build will output to ./cdn-dist
|
|
@@ -120,7 +71,7 @@ You can see this build referenced on:
|
|
|
120
71
|
- `src/examples/client-side`
|
|
121
72
|
- `src/examples/full-stack`
|
|
122
73
|
|
|
123
|
-
#### Build
|
|
74
|
+
#### Build for npm publishing
|
|
124
75
|
|
|
125
76
|
```sh
|
|
126
77
|
yarn react-build # Build will output to ./react-dist
|
|
@@ -129,3 +80,4 @@ yarn react-build # Build will output to ./react-dist
|
|
|
129
80
|
You can see this build referenced on:
|
|
130
81
|
|
|
131
82
|
- `src/examples/react-app`
|
|
83
|
+
- `src/examples/just-typescript`
|
package/README.md
CHANGED
|
@@ -18,10 +18,33 @@ npm i @duffel/components
|
|
|
18
18
|
<script src="https://assets.duffel.com/components/3.0.5-canary/index.js"></script>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## How do I integrate this into my website?
|
|
22
|
+
|
|
23
|
+
1. Please start by reading our integration guide on https://duffel.com/docs/guides/ancillaries-component
|
|
24
|
+
|
|
25
|
+
## Integration examples
|
|
26
|
+
|
|
27
|
+
1. **client-side** | This example loads a local version of the components using a `script` tag. It uses a fixture for the
|
|
28
|
+
|
|
29
|
+
- [Find it on src/examples/client-side](src/examples/client-side)
|
|
30
|
+
|
|
31
|
+
2. **full-stack** | This example loads a local version of the components using a `script` tag. It will search and retrieve an offer from the Duffel API and render the ancillaries component custom element with its `offer_id` and `client_key`. As soon as a service modal is closed it will create a test order with the given payload.
|
|
32
|
+
|
|
33
|
+
- [Find it on src/examples/full-stack](src/examples/full-stack)
|
|
34
|
+
|
|
35
|
+
3. **just-typescript** | This example imports a local version of `@duffel/components` and renders the custom element with an offer fixture once the page loads.
|
|
36
|
+
|
|
37
|
+
- [Find it on src/examples/just-typescript](src/examples/just-typescript)
|
|
38
|
+
|
|
39
|
+
4. **react-app** | This example imports a local version of `@duffel/components` and renders the a react element with an offer fixture.
|
|
40
|
+
- [Find it on src/examples/react-app](src/examples/react-app)
|
|
41
|
+
|
|
42
|
+
## What components are available?
|
|
22
43
|
|
|
23
44
|
### Ancillaries component
|
|
24
45
|
|
|
25
46
|
The ancillaries component allows your customers to add ancillaries to their order. It's simple to add to your website and can be customised to fit your brand. This component is avaiable through npm and our cdn.
|
|
26
47
|
|
|
27
48
|
- [Find live demo on codesandbox.io ↗](https://codesandbox.io/s/duffel-ancillaries-example-1nxuu7)
|
|
49
|
+
|
|
50
|
+
#### more coming soon...
|