seam 0.0.3 → 0.1.0
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/LICENSE.txt +20 -0
- package/README.md +134 -149
- package/dist/index.cjs +38 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/index.d.ts +6 -0
- package/index.js +7 -148
- package/index.js.map +1 -0
- package/package.json +70 -33
- package/src/index.ts +7 -0
- package/LICENSE +0 -21
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2023 Seam Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,211 +1,196 @@
|
|
|
1
|
-
Seam
|
|
2
|
-
=============
|
|
1
|
+
# Seam JavaScript SDK
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/seam)
|
|
4
|
+
[](https://github.com/seamapi/javascript-next/actions/workflows/check.yml)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
JavaScript SDK for the Seam API written in TypeScript.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```
|
|
8
|
+
_This is a preview of the next major version of the Seam SDK.
|
|
9
|
+
This SDK is available for early preview.
|
|
10
|
+
It will eventually replace the [seamapi](https://github.com/seamapi/javascript/) package._
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
## Description
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
[Seam] makes it easy to integrate IoT devices with your applications.
|
|
15
|
+
This is an official SDK for the Seam API.
|
|
16
|
+
Please refer to the official [Seam Docs] to get started.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```
|
|
18
|
+
The SDK is fully tree-shakeable
|
|
19
|
+
and optimized for use in both client and server applications.
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
==========
|
|
21
|
+
The package does not contain any code, it re-exports from a core set of Seam modules:
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
- [@seamapi/types]: TypeScript types for the Seam API.
|
|
24
|
+
- [@seamapi/http]: JavaScript HTTP client for the Seam API written in TypeScript.
|
|
25
|
+
- [@seamapi/webhook]: Webhook SDK for the Seam API written in TypeScript.
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
[Seam]: https://www.seam.co/
|
|
28
|
+
[Seam Docs]: https://docs.seam.co/latest/
|
|
29
|
+
[@seamapi/types]: https://github.com/seamapi/types
|
|
30
|
+
[@seamapi/http]: https://github.com/seamapi/javascript-http
|
|
31
|
+
[@seamapi/webhook]: https://github.com/seamapi/javascript-webhook
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
## Installation
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
Add this as a dependency to your project using [npm] with
|
|
34
36
|
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
+
```
|
|
38
|
+
$ npm install seam
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
// The object to display in the DOM
|
|
43
|
-
var someone = {
|
|
44
|
-
// This is the value that we want to display in the paragraph
|
|
45
|
-
name: "John",
|
|
46
|
-
type: "Doe"
|
|
47
|
-
};
|
|
41
|
+
[npm]: https://www.npmjs.com/
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
var seam = new Seam();
|
|
43
|
+
### Usage
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
seam.add("bind", {
|
|
45
|
+
#### Unlock a door
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// That will set the innerText of the dom to "John"
|
|
58
|
-
node.innerText = someone[param];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
47
|
+
```ts
|
|
48
|
+
import Seam from 'seam'
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
const seam = new Seam()
|
|
51
|
+
const lock = await seam.locks.get({ name: 'Front Door' })
|
|
52
|
+
await seam.locks.unlockDoor({ device_id: lock.device_id })
|
|
64
53
|
```
|
|
65
54
|
|
|
66
|
-
|
|
55
|
+
#### Parse and validate a webhook
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- {String} the parameters specified in the data-attribute, after the name of the method (name in our case)
|
|
57
|
+
```ts
|
|
58
|
+
import { SeamWebhook } from 'seam'
|
|
71
59
|
|
|
72
|
-
|
|
60
|
+
const webhook = new SeamWebhook('webhook-secret')
|
|
61
|
+
const data = webhook.verify(payload, headers)
|
|
62
|
+
```
|
|
73
63
|
|
|
74
|
-
|
|
64
|
+
## Development and Testing
|
|
75
65
|
|
|
76
|
-
###
|
|
66
|
+
### Quickstart
|
|
77
67
|
|
|
78
|
-
```html
|
|
79
|
-
<section>
|
|
80
|
-
<p data-bind="value: name"></p>
|
|
81
|
-
<button data-listen="click: doSomething"></button>
|
|
82
|
-
</section>
|
|
83
68
|
```
|
|
69
|
+
$ git clone https://github.com/seamapi/javascript-next.git
|
|
70
|
+
$ cd javascript-next
|
|
71
|
+
$ nvm install
|
|
72
|
+
$ npm install
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Primary development tasks are defined under `scripts` in `package.json`
|
|
76
|
+
and available via `npm run`.
|
|
77
|
+
View them with
|
|
84
78
|
|
|
85
|
-
|
|
79
|
+
```
|
|
80
|
+
$ npm run
|
|
81
|
+
```
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
// This is some UI with a doSomething method:
|
|
89
|
-
var ui = {
|
|
90
|
-
doSomething: function () {
|
|
91
|
-
// do something
|
|
92
|
-
}
|
|
93
|
-
}
|
|
83
|
+
### Source code
|
|
94
84
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
bind: {
|
|
98
|
-
value: function (node, param) {
|
|
99
|
-
node.innerText = someone[param];
|
|
100
|
-
}
|
|
101
|
-
},
|
|
85
|
+
The [source code] is hosted on GitHub.
|
|
86
|
+
Clone the project with
|
|
102
87
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
click: function (node, method) {
|
|
106
|
-
node.addEventListener("click", function (event) {
|
|
107
|
-
ui[method](event);
|
|
108
|
-
}, true);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
88
|
+
```
|
|
89
|
+
$ git clone git@github.com:seamapi/javascript-next.git
|
|
112
90
|
```
|
|
113
91
|
|
|
114
|
-
|
|
92
|
+
[source code]: https://github.com/seamapi/javascript-next
|
|
115
93
|
|
|
116
|
-
|
|
94
|
+
### Requirements
|
|
117
95
|
|
|
118
|
-
|
|
96
|
+
You will need [Node.js] with [npm] and a [Node.js debugging] client.
|
|
119
97
|
|
|
120
|
-
|
|
98
|
+
Be sure that all commands run under the correct Node version, e.g.,
|
|
99
|
+
if using [nvm], install the correct version with
|
|
121
100
|
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
<p data-bind="change: name, innerText"></p>
|
|
125
|
-
<button data-event="listen: click, alert, name"></p>
|
|
126
|
-
</section>
|
|
101
|
+
```
|
|
102
|
+
$ nvm install
|
|
127
103
|
```
|
|
128
104
|
|
|
129
|
-
|
|
105
|
+
Set the active version for each shell session with
|
|
130
106
|
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
|
|
107
|
+
```
|
|
108
|
+
$ nvm use
|
|
109
|
+
```
|
|
134
110
|
|
|
135
|
-
|
|
136
|
-
view.alert = function (event, param) {
|
|
137
|
-
alert(model.get(param);
|
|
138
|
-
};
|
|
111
|
+
Install the development dependencies with
|
|
139
112
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
*/
|
|
144
|
-
function Binding(model) {
|
|
113
|
+
```
|
|
114
|
+
$ npm install
|
|
115
|
+
```
|
|
145
116
|
|
|
146
|
-
|
|
147
|
-
|
|
117
|
+
[Node.js]: https://nodejs.org/
|
|
118
|
+
[Node.js debugging]: https://nodejs.org/en/docs/guides/debugging-getting-started/
|
|
119
|
+
[npm]: https://www.npmjs.com/
|
|
120
|
+
[nvm]: https://github.com/creationix/nvm
|
|
148
121
|
|
|
149
|
-
|
|
150
|
-
node[attribute] = model.get(key);
|
|
122
|
+
### Publishing
|
|
151
123
|
|
|
152
|
-
|
|
153
|
-
model.on("change:" + key, function (newValue) {
|
|
154
|
-
node[attribute] = newValue;
|
|
155
|
-
});
|
|
124
|
+
#### Automatic
|
|
156
125
|
|
|
157
|
-
|
|
158
|
-
|
|
126
|
+
New versions are released automatically with [semantic-release]
|
|
127
|
+
as long as commits follow the [Angular Commit Message Conventions].
|
|
159
128
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
* It takes a view as parameter, so it knows where to call the method
|
|
163
|
-
*/
|
|
164
|
-
function Event(view) {
|
|
129
|
+
[Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format
|
|
130
|
+
[semantic-release]: https://semantic-release.gitbook.io/
|
|
165
131
|
|
|
166
|
-
|
|
167
|
-
node.addEventListener(eventName, function (event) {
|
|
168
|
-
view[methodName](event, param);
|
|
169
|
-
});
|
|
170
|
-
};
|
|
132
|
+
#### Manual
|
|
171
133
|
|
|
172
|
-
|
|
134
|
+
Publish a new version by triggering a [version workflow_dispatch on GitHub Actions].
|
|
135
|
+
The `version` input will be passed as the first argument to [npm-version].
|
|
173
136
|
|
|
174
|
-
|
|
175
|
-
var seam = new Seam();
|
|
137
|
+
This may be done on the web or using the [GitHub CLI] with
|
|
176
138
|
|
|
177
|
-
|
|
178
|
-
|
|
139
|
+
```
|
|
140
|
+
$ gh workflow run version.yml --raw-field version=<version>
|
|
141
|
+
```
|
|
179
142
|
|
|
180
|
-
|
|
181
|
-
|
|
143
|
+
[GitHub CLI]: https://cli.github.com/
|
|
144
|
+
[npm-version]: https://docs.npmjs.com/cli/version
|
|
145
|
+
[version workflow_dispatch on GitHub Actions]: https://github.com/seamapi/javascript-next/actions?query=workflow%3Aversion
|
|
182
146
|
|
|
183
|
-
|
|
184
|
-
"event": new Event(view)
|
|
147
|
+
## GitHub Actions
|
|
185
148
|
|
|
186
|
-
|
|
149
|
+
_GitHub Actions should already be configured: this section is for reference only._
|
|
187
150
|
|
|
188
|
-
|
|
189
|
-
seam.apply( document.querySelector("section") );
|
|
190
|
-
```
|
|
151
|
+
The following repository secrets must be set on [GitHub Actions]:
|
|
191
152
|
|
|
192
|
-
|
|
153
|
+
- `NPM_TOKEN`: npm token for installing and publishing packages.
|
|
154
|
+
- `GH_TOKEN`: A personal access token for the bot user with
|
|
155
|
+
and `contents:write` permission.
|
|
156
|
+
- `GIT_USER_NAME`: The GitHub bot user's real name.
|
|
157
|
+
- `GIT_USER_EMAIL`: The GitHub bot user's email.
|
|
158
|
+
- `GPG_PRIVATE_KEY`: The GitHub bot user's [GPG private key].
|
|
159
|
+
- `GPG_PASSPHRASE`: The GitHub bot user's GPG passphrase.
|
|
193
160
|
|
|
194
|
-
|
|
161
|
+
[GitHub Actions]: https://github.com/features/actions
|
|
162
|
+
[GPG private key]: https://github.com/marketplace/actions/import-gpg#prerequisites
|
|
195
163
|
|
|
196
|
-
|
|
164
|
+
## Contributing
|
|
197
165
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
```
|
|
166
|
+
> If using squash merge, edit and ensure the commit message follows the [Angular Commit Message Conventions] specification.
|
|
167
|
+
> Otherwise, each individual commit must follow the [Angular Commit Message Conventions] specification.
|
|
201
168
|
|
|
202
|
-
|
|
169
|
+
1. Create your feature branch (`git checkout -b my-new-feature`).
|
|
170
|
+
2. Make changes.
|
|
171
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
|
172
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
|
173
|
+
5. Create a new draft pull request.
|
|
174
|
+
6. Ensure all checks pass.
|
|
175
|
+
7. Mark your pull request ready for review.
|
|
176
|
+
8. Wait for the required approval from the code owners.
|
|
177
|
+
9. Merge when ready.
|
|
203
178
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
179
|
+
[Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
This npm package is licensed under the MIT license.
|
|
207
184
|
|
|
208
|
-
|
|
209
|
-
=======
|
|
185
|
+
## Warranty
|
|
210
186
|
|
|
211
|
-
|
|
187
|
+
This software is provided by the copyright holders and contributors "as is" and
|
|
188
|
+
any express or implied warranties, including, but not limited to, the implied
|
|
189
|
+
warranties of merchantability and fitness for a particular purpose are
|
|
190
|
+
disclaimed. In no event shall the copyright holder or contributors be liable for
|
|
191
|
+
any direct, indirect, incidental, special, exemplary, or consequential damages
|
|
192
|
+
(including, but not limited to, procurement of substitute goods or services;
|
|
193
|
+
loss of use, data, or profits; or business interruption) however caused and on
|
|
194
|
+
any theory of liability, whether in contract, strict liability, or tort
|
|
195
|
+
(including negligence or otherwise) arising in any way out of the use of this
|
|
196
|
+
software, even if advised of the possibility of such damage.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var connect = require('@seamapi/http/connect');
|
|
6
|
+
var connect$1 = require('@seamapi/types/connect');
|
|
7
|
+
var webhook = require('@seamapi/webhook');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(exports, "Seam", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return connect.SeamHttp; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "default", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return connect.SeamHttp; }
|
|
18
|
+
});
|
|
19
|
+
Object.keys(connect).forEach(function (k) {
|
|
20
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return connect[k]; }
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
Object.keys(connect$1).forEach(function (k) {
|
|
26
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return connect$1[k]; }
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
Object.keys(webhook).forEach(function (k) {
|
|
32
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return webhook[k]; }
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=out.js.map
|
|
38
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAAA,SAAS,YAAY,YAAY;AAEjC,cAAc;AACd,cAAc;AACd,cAAc","sourcesContent":["import { SeamHttp as Seam } from '@seamapi/http/connect'\n\nexport * from '@seamapi/http/connect'\nexport * from '@seamapi/types/connect'\nexport * from '@seamapi/webhook'\nexport { Seam }\nexport { Seam as default }\n"]}
|
package/dist/index.d.cts
ADDED
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -1,148 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* @
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
var toArray = require("to-array"),
|
|
11
|
-
simpleLoop = require("simple-loop"),
|
|
12
|
-
getNodes = require("get-nodes"),
|
|
13
|
-
getDataset = require("get-dataset");
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Seam makes it easy to attach JS behavior to your HTML/SVG via the data- attribute.
|
|
17
|
-
* <div data-plugin="method: param, param, ..."></tag>
|
|
18
|
-
*
|
|
19
|
-
* JS behaviors are defined in plugins, which are plain JS objects with data and methods.
|
|
20
|
-
*/
|
|
21
|
-
module.exports = function Seam($plugins) {
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The list of plugins
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
var _plugins = {},
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Just a "functionalification" of trim
|
|
31
|
-
* for code readability
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
trim = function trim(string) {
|
|
35
|
-
return string.trim();
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Call the plugins methods, passing them the dom node
|
|
40
|
-
* A phrase can be :
|
|
41
|
-
* <tag data-plugin='method: param, param; method:param...'/>
|
|
42
|
-
* the function has to call every method of the plugin
|
|
43
|
-
* passing it the node, and the given params
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
applyPlugin = function applyPlugin(node, phrase, plugin) {
|
|
47
|
-
// Split the methods
|
|
48
|
-
phrase.split(";")
|
|
49
|
-
.forEach(function (couple) {
|
|
50
|
-
// Split the result between method and params
|
|
51
|
-
var split = couple.split(":"),
|
|
52
|
-
// Trim the name
|
|
53
|
-
method = split[0].trim(),
|
|
54
|
-
// And the params, if any
|
|
55
|
-
params = split[1] ? split[1].split(",").map(trim) : [];
|
|
56
|
-
|
|
57
|
-
// The first param must be the dom node
|
|
58
|
-
params.unshift(node);
|
|
59
|
-
|
|
60
|
-
if (_plugins[plugin] && _plugins[plugin][method]) {
|
|
61
|
-
// Call the method with the following params for instance :
|
|
62
|
-
// [node, "param1", "param2" .. ]
|
|
63
|
-
_plugins[plugin][method].apply(_plugins[plugin], params);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Add a plugin
|
|
71
|
-
*
|
|
72
|
-
* Note that once added, the function adds a "plugins" property to the plugin.
|
|
73
|
-
* It's an object that holds a name property, with the registered name of the plugin
|
|
74
|
-
* and an apply function, to use on new nodes that the plugin would generate
|
|
75
|
-
*
|
|
76
|
-
* @param {String} name the name of the data that the plugin should look for
|
|
77
|
-
* @param {Object} plugin the plugin that has the functions to execute
|
|
78
|
-
* @returns true if plugin successfully added.
|
|
79
|
-
*/
|
|
80
|
-
this.add = function add(name, plugin) {
|
|
81
|
-
var propertyName = "plugins";
|
|
82
|
-
|
|
83
|
-
if (typeof name == "string" && typeof plugin == "object" && plugin) {
|
|
84
|
-
_plugins[name] = plugin;
|
|
85
|
-
|
|
86
|
-
plugin[propertyName] = {
|
|
87
|
-
name: name,
|
|
88
|
-
apply: function apply() {
|
|
89
|
-
return this.apply.apply(this, arguments);
|
|
90
|
-
}.bind(this)
|
|
91
|
-
};
|
|
92
|
-
return true;
|
|
93
|
-
} else {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Add multiple plugins at once
|
|
100
|
-
* @param {Object} list key is the plugin name and value is the plugin
|
|
101
|
-
* @returns true if correct param
|
|
102
|
-
*/
|
|
103
|
-
this.addAll = function addAll(list) {
|
|
104
|
-
return simpleLoop(list, function (plugin, name) {
|
|
105
|
-
this.add(name, plugin);
|
|
106
|
-
}, this);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Get a previously added plugin
|
|
111
|
-
* @param {String} name the name of the plugin
|
|
112
|
-
* @returns {Object} the plugin
|
|
113
|
-
*/
|
|
114
|
-
this.get = function get(name) {
|
|
115
|
-
return _plugins[name];
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Delete a plugin from the list
|
|
120
|
-
* @param {String} name the name of the plugin
|
|
121
|
-
* @returns {Boolean} true if success
|
|
122
|
-
*/
|
|
123
|
-
this.del = function del(name) {
|
|
124
|
-
return delete _plugins[name];
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Apply the plugins to a NodeList
|
|
129
|
-
* @param {HTMLElement|SVGElement} dom the dom nodes on which to apply the plugins
|
|
130
|
-
* @returns {Boolean} true if the param is a dom node
|
|
131
|
-
*/
|
|
132
|
-
this.apply = function apply(dom) {
|
|
133
|
-
var nodes = getNodes(dom);
|
|
134
|
-
|
|
135
|
-
simpleLoop(toArray(nodes), function (node) {
|
|
136
|
-
simpleLoop(getDataset(node), function (phrase, plugin) {
|
|
137
|
-
applyPlugin(node, phrase, plugin);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
return dom;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if ($plugins) {
|
|
145
|
-
this.addAll($plugins);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
};
|
|
1
|
+
import { SeamHttp as Seam } from '@seamapi/http/connect';
|
|
2
|
+
export * from '@seamapi/http/connect';
|
|
3
|
+
export * from '@seamapi/types/connect';
|
|
4
|
+
export * from '@seamapi/webhook';
|
|
5
|
+
export { Seam };
|
|
6
|
+
export { Seam as default };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAExD,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,CAAA;AACf,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,46 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seam",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "JavaScript SDK for the Seam API written in TypeScript.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
10
18
|
}
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"index.js"
|
|
15
|
-
],
|
|
16
|
-
"author": "Olivier Scherrer <pode.fr@gmail.com>",
|
|
19
|
+
},
|
|
20
|
+
"module": "index.js",
|
|
21
|
+
"sideEffects": false,
|
|
17
22
|
"keywords": [
|
|
18
|
-
"
|
|
19
|
-
"behavior",
|
|
20
|
-
"plugin",
|
|
21
|
-
"binding",
|
|
22
|
-
"template",
|
|
23
|
-
"declarative"
|
|
23
|
+
"node"
|
|
24
24
|
],
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
25
|
+
"homepage": "https://github.com/seamapi/javascript-next",
|
|
26
|
+
"bugs": "https://github.com/seamapi/javascript-next/issues",
|
|
27
|
+
"repository": "seamapi/javascript-next",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"author": {
|
|
30
|
+
"name": "Seam Labs, Inc.",
|
|
31
|
+
"email": "devops@getseam.com"
|
|
31
32
|
},
|
|
33
|
+
"files": [
|
|
34
|
+
"index.js",
|
|
35
|
+
"index.js.map",
|
|
36
|
+
"index.d.ts",
|
|
37
|
+
"src",
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
32
40
|
"scripts": {
|
|
33
|
-
"
|
|
41
|
+
"build": "npm run build:entrypoints",
|
|
42
|
+
"prebuild": "tsx src/index.ts",
|
|
43
|
+
"postbuild": "node ./index.js",
|
|
44
|
+
"build:entrypoints": "npm run build:ts",
|
|
45
|
+
"postbuild:entrypoints": "tsup",
|
|
46
|
+
"build:ts": "tsc --project tsconfig.build.json",
|
|
47
|
+
"prebuild:ts": "del 'index.*'",
|
|
48
|
+
"postbuild:ts": "tsc-alias --project tsconfig.build.json",
|
|
49
|
+
"typecheck": "tsc",
|
|
50
|
+
"test": "true",
|
|
51
|
+
"pretest": "tsx src/index.ts",
|
|
52
|
+
"lint": "eslint --ignore-path .gitignore .",
|
|
53
|
+
"prelint": "prettier --check --ignore-path .gitignore .",
|
|
54
|
+
"postversion": "git push --follow-tags",
|
|
55
|
+
"format": "eslint --ignore-path .gitignore --fix .",
|
|
56
|
+
"preformat": "prettier --write --ignore-path .gitignore ."
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18.12.0",
|
|
60
|
+
"npm": ">= 9.0.0"
|
|
34
61
|
},
|
|
35
|
-
"main": "index.js",
|
|
36
62
|
"devDependencies": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
63
|
+
"@types/node": "^20.8.10",
|
|
64
|
+
"del-cli": "^5.0.0",
|
|
65
|
+
"eslint": "^8.9.0",
|
|
66
|
+
"eslint-config-prettier": "^9.0.0",
|
|
67
|
+
"eslint-config-standard": "^17.1.0",
|
|
68
|
+
"eslint-config-standard-with-typescript": "^43.0.0",
|
|
69
|
+
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
70
|
+
"eslint-plugin-unused-imports": "^3.0.0",
|
|
71
|
+
"prettier": "^3.0.0",
|
|
72
|
+
"tsc-alias": "^1.8.2",
|
|
73
|
+
"tsup": "^8.0.1",
|
|
74
|
+
"tsx": "^4.6.2",
|
|
75
|
+
"typescript": "^5.1.0"
|
|
39
76
|
},
|
|
40
77
|
"dependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
78
|
+
"@seamapi/http": "^0.14.0",
|
|
79
|
+
"@seamapi/types": "^1.81.0",
|
|
80
|
+
"@seamapi/webhook": "^0.1.0",
|
|
81
|
+
"seamapi-types": "^1.32.0"
|
|
45
82
|
}
|
|
46
83
|
}
|
package/src/index.ts
ADDED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license seam https://github.com/flams/seam
|
|
3
|
-
*
|
|
4
|
-
* The MIT License (MIT)
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2014 Olivier Scherrer <pode.fr@gmail.com>
|
|
7
|
-
*
|
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
9
|
-
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
10
|
-
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
11
|
-
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
14
|
-
* portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
17
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
18
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
19
|
-
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
20
|
-
* IN THE SOFTWARE.
|
|
21
|
-
*/
|