seam 0.0.2 → 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 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,27 +1,196 @@
1
- Seam
2
- =============
1
+ # Seam JavaScript SDK
3
2
 
4
- Attach JS behavior to your HTML in a universal with declarative binding.
3
+ [![npm](https://img.shields.io/npm/v/seam.svg)](https://www.npmjs.com/package/seam)
4
+ [![GitHub Actions](https://github.com/seamapi/javascript-next/actions/workflows/check.yml/badge.svg)](https://github.com/seamapi/javascript-next/actions/workflows/check.yml)
5
5
 
6
- Installation
7
- ============
6
+ JavaScript SDK for the Seam API written in TypeScript.
8
7
 
9
- ```bash
10
- npm install seam
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._
11
+
12
+ ## Description
13
+
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
+
18
+ The SDK is fully tree-shakeable
19
+ and optimized for use in both client and server applications.
20
+
21
+ The package does not contain any code, it re-exports from a core set of Seam modules:
22
+
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
+
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
32
+
33
+ ## Installation
34
+
35
+ Add this as a dependency to your project using [npm] with
36
+
37
+ ```
38
+ $ npm install seam
39
+ ```
40
+
41
+ [npm]: https://www.npmjs.com/
42
+
43
+ ### Usage
44
+
45
+ #### Unlock a door
46
+
47
+ ```ts
48
+ import Seam from 'seam'
49
+
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 })
53
+ ```
54
+
55
+ #### Parse and validate a webhook
56
+
57
+ ```ts
58
+ import { SeamWebhook } from 'seam'
59
+
60
+ const webhook = new SeamWebhook('webhook-secret')
61
+ const data = webhook.verify(payload, headers)
11
62
  ```
12
63
 
13
- How to use
14
- ==========
64
+ ## Development and Testing
15
65
 
16
- Require seam:
66
+ ### Quickstart
17
67
 
18
- ```js
19
- var Seam = require("seam");
20
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
78
+
79
+ ```
80
+ $ npm run
81
+ ```
82
+
83
+ ### Source code
84
+
85
+ The [source code] is hosted on GitHub.
86
+ Clone the project with
87
+
88
+ ```
89
+ $ git clone git@github.com:seamapi/javascript-next.git
90
+ ```
91
+
92
+ [source code]: https://github.com/seamapi/javascript-next
93
+
94
+ ### Requirements
95
+
96
+ You will need [Node.js] with [npm] and a [Node.js debugging] client.
97
+
98
+ Be sure that all commands run under the correct Node version, e.g.,
99
+ if using [nvm], install the correct version with
100
+
101
+ ```
102
+ $ nvm install
103
+ ```
104
+
105
+ Set the active version for each shell session with
106
+
107
+ ```
108
+ $ nvm use
109
+ ```
110
+
111
+ Install the development dependencies with
112
+
113
+ ```
114
+ $ npm install
115
+ ```
116
+
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
121
+
122
+ ### Publishing
123
+
124
+ #### Automatic
125
+
126
+ New versions are released automatically with [semantic-release]
127
+ as long as commits follow the [Angular Commit Message Conventions].
128
+
129
+ [Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format
130
+ [semantic-release]: https://semantic-release.gitbook.io/
131
+
132
+ #### Manual
133
+
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].
136
+
137
+ This may be done on the web or using the [GitHub CLI] with
138
+
139
+ ```
140
+ $ gh workflow run version.yml --raw-field version=<version>
141
+ ```
142
+
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
146
+
147
+ ## GitHub Actions
148
+
149
+ _GitHub Actions should already be configured: this section is for reference only._
150
+
151
+ The following repository secrets must be set on [GitHub Actions]:
152
+
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.
160
+
161
+ [GitHub Actions]: https://github.com/features/actions
162
+ [GPG private key]: https://github.com/marketplace/actions/import-gpg#prerequisites
163
+
164
+ ## Contributing
165
+
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.
168
+
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.
178
+
179
+ [Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format
180
+
181
+ ## License
21
182
 
22
- doc is coming
183
+ This npm package is licensed under the MIT license.
23
184
 
24
- LICENSE
25
- =======
185
+ ## Warranty
26
186
 
27
- MIT
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"]}
@@ -0,0 +1,4 @@
1
+ export * from '@seamapi/http/connect';
2
+ export { SeamHttp as Seam, SeamHttp as default } from '@seamapi/http/connect';
3
+ export * from '@seamapi/types/connect';
4
+ export * from '@seamapi/webhook';
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
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 };
package/index.js CHANGED
@@ -1,148 +1,7 @@
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
- "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
- "description": "Attach JS behavior to your HTML in a universal way with declarative binding",
4
- "version": "0.0.2",
5
- "homepage": "https://github.com/flams/seam",
6
- "licenses": [
7
- {
8
- "type": "MIT",
9
- "url": "https://raw.github.com/flams/seam/master/LICENSE"
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
- "files": [
13
- "LICENSE",
14
- "index.js"
15
- ],
16
- "author": "Olivier Scherrer <pode.fr@gmail.com>",
19
+ },
20
+ "module": "index.js",
21
+ "sideEffects": false,
17
22
  "keywords": [
18
- "html",
19
- "behavior",
20
- "plugin",
21
- "binding",
22
- "template",
23
- "declarative"
23
+ "node"
24
24
  ],
25
- "repository": {
26
- "type": "git",
27
- "url": "git@github.com:flams/seam.git"
28
- },
29
- "bugs": {
30
- "url": "https://github.com/flams/seam/issues"
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
- "test": "jasmine-node test/"
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
- "jasmine-node": "~1.14.3",
38
- "quick-dom": "0.0.1"
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
- "to-array": "~0.1.4",
42
- "simple-loop": "0.0.2",
43
- "get-nodes": "0.0.1",
44
- "get-dataset": "0.0.1"
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
@@ -0,0 +1,7 @@
1
+ import { SeamHttp as Seam } from '@seamapi/http/connect'
2
+
3
+ export * from '@seamapi/http/connect'
4
+ export * from '@seamapi/types/connect'
5
+ export * from '@seamapi/webhook'
6
+ export { Seam }
7
+ export { Seam as default }
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
- */