@digipair/skill-nuki 0.91.0-0 → 0.92.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/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.cjs.js ADDED
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _extends() {
6
+ _extends = Object.assign || function assign(target) {
7
+ for(var i = 1; i < arguments.length; i++){
8
+ var source = arguments[i];
9
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
15
+
16
+ let NukiService = class NukiService {
17
+ async call(url, method, data, headers, signal) {
18
+ const response = await fetch(`${this.API_ENDPOINT}${url}`, {
19
+ signal,
20
+ method,
21
+ headers: _extends({
22
+ Authorization: 'Bearer ' + this.NUKI_API_KEY
23
+ }, headers),
24
+ body: data
25
+ });
26
+ if (!response.ok) throw new Error('[SKILL-NUKI] REQUEST FAILED: ' + response.status);
27
+ return await response.json();
28
+ }
29
+ async unlock(params, _pinsSettingsList, context) {
30
+ var _context_protected;
31
+ const { id } = params;
32
+ return await this.call(`/${id}/action/unlock`, 'POST', null, {}, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
33
+ }
34
+ async lock(params, _pinsSettingsList, context) {
35
+ var _context_protected;
36
+ const { id } = params;
37
+ return await this.call(`/${id}/action/lock`, 'POST', null, {}, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
38
+ }
39
+ constructor(context, params){
40
+ var _context_privates_NUKI_API_KEY, _ref;
41
+ this.NUKI_API_KEY = (_ref = (_context_privates_NUKI_API_KEY = context.privates.NUKI_API_KEY) != null ? _context_privates_NUKI_API_KEY : params == null ? void 0 : params.NUKI_API_KEY) != null ? _ref : process.env['NUKI_API_KEY'];
42
+ var _context_privates_NUKI_API_ENDPOINT, _ref1, _ref2;
43
+ this.API_ENDPOINT = (_ref2 = (_ref1 = (_context_privates_NUKI_API_ENDPOINT = context.privates.NUKI_API_ENDPOINT) != null ? _context_privates_NUKI_API_ENDPOINT : params == null ? void 0 : params.NUKI_API_ENDPOINT) != null ? _ref1 : process.env['NUKI_API_ENDPOINT']) != null ? _ref2 : 'https://api.nuki.io/smartlock';
44
+ }
45
+ };
46
+ const lock = (params, pinsSettingsList, context)=>new NukiService(context, params).lock(params, pinsSettingsList, context);
47
+ const unlock = (params, pinsSettingsList, context)=>new NukiService(context, params).unlock(params, pinsSettingsList, context);
48
+
49
+ exports.lock = lock;
50
+ exports.unlock = unlock;
package/index.esm.js ADDED
@@ -0,0 +1,45 @@
1
+ function _extends() {
2
+ _extends = Object.assign || function assign(target) {
3
+ for(var i = 1; i < arguments.length; i++){
4
+ var source = arguments[i];
5
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
6
+ }
7
+ return target;
8
+ };
9
+ return _extends.apply(this, arguments);
10
+ }
11
+
12
+ let NukiService = class NukiService {
13
+ async call(url, method, data, headers, signal) {
14
+ const response = await fetch(`${this.API_ENDPOINT}${url}`, {
15
+ signal,
16
+ method,
17
+ headers: _extends({
18
+ Authorization: 'Bearer ' + this.NUKI_API_KEY
19
+ }, headers),
20
+ body: data
21
+ });
22
+ if (!response.ok) throw new Error('[SKILL-NUKI] REQUEST FAILED: ' + response.status);
23
+ return await response.json();
24
+ }
25
+ async unlock(params, _pinsSettingsList, context) {
26
+ var _context_protected;
27
+ const { id } = params;
28
+ return await this.call(`/${id}/action/unlock`, 'POST', null, {}, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
29
+ }
30
+ async lock(params, _pinsSettingsList, context) {
31
+ var _context_protected;
32
+ const { id } = params;
33
+ return await this.call(`/${id}/action/lock`, 'POST', null, {}, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
34
+ }
35
+ constructor(context, params){
36
+ var _context_privates_NUKI_API_KEY, _ref;
37
+ this.NUKI_API_KEY = (_ref = (_context_privates_NUKI_API_KEY = context.privates.NUKI_API_KEY) != null ? _context_privates_NUKI_API_KEY : params == null ? void 0 : params.NUKI_API_KEY) != null ? _ref : process.env['NUKI_API_KEY'];
38
+ var _context_privates_NUKI_API_ENDPOINT, _ref1, _ref2;
39
+ this.API_ENDPOINT = (_ref2 = (_ref1 = (_context_privates_NUKI_API_ENDPOINT = context.privates.NUKI_API_ENDPOINT) != null ? _context_privates_NUKI_API_ENDPOINT : params == null ? void 0 : params.NUKI_API_ENDPOINT) != null ? _ref1 : process.env['NUKI_API_ENDPOINT']) != null ? _ref2 : 'https://api.nuki.io/smartlock';
40
+ }
41
+ };
42
+ const lock = (params, pinsSettingsList, context)=>new NukiService(context, params).lock(params, pinsSettingsList, context);
43
+ const unlock = (params, pinsSettingsList, context)=>new NukiService(context, params).unlock(params, pinsSettingsList, context);
44
+
45
+ export { lock, unlock };
@@ -0,0 +1,3 @@
1
+ import { PinsSettings } from '@digipair/engine';
2
+ export declare const lock: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
3
+ export declare const unlock: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
package/package.json CHANGED
@@ -1,28 +1,12 @@
1
1
  {
2
2
  "name": "@digipair/skill-nuki",
3
- "version": "0.91.0-0",
4
- "type": "module",
5
- "main": "dist/libs/skill-nuki/index.cjs.js",
6
- "module": "dist/libs/skill-nuki/index.esm.js",
7
- "types": "dist/libs/skill-nuki/index.esm.d.ts",
8
- "exports": {
9
- "./package.json": "./libs/skill-nuki/package.json",
10
- ".": {
11
- "development": "./dist/libs/skill-nuki/src/index.ts",
12
- "types": "./dist/libs/skill-nuki/index.esm.d.ts",
13
- "import": "./dist/libs/skill-nuki/index.esm.js",
14
- "default": "./dist/libs/skill-nuki/index.cjs.js"
15
- }
16
- },
3
+ "version": "0.92.0",
17
4
  "keywords": [
18
5
  "digipair",
19
- "tool",
20
- "service"
6
+ "service",
7
+ "tool"
21
8
  ],
22
- "nx": {
23
- "name": "skill-nuki"
24
- },
25
- "dependencies": {
26
- "@digipair/engine": "0.91.0-0"
27
- }
28
- }
9
+ "dependencies": {},
10
+ "main": "./index.cjs.js",
11
+ "module": "./index.esm.js"
12
+ }
package/.swcrc DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "jsc": {
3
- "target": "es2017",
4
- "parser": {
5
- "syntax": "typescript",
6
- "decorators": true,
7
- "dynamicImport": true
8
- },
9
- "transform": {
10
- "decoratorMetadata": true,
11
- "legacyDecorator": true
12
- },
13
- "keepClassNames": true,
14
- "externalHelpers": true,
15
- "loose": true
16
- },
17
- "module": {
18
- "type": "es6"
19
- },
20
- "sourceMaps": true,
21
- "exclude": [
22
- "jest.config.ts",
23
- ".*\\.spec.tsx?$",
24
- ".*\\.test.tsx?$",
25
- "./src/jest-setup.ts$",
26
- "./**/jest-setup.ts$"
27
- ]
28
- }
package/README.md DELETED
@@ -1,7 +0,0 @@
1
- # mylib
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build mylib` to build the library.
package/eslint.config.mjs DELETED
@@ -1,22 +0,0 @@
1
- import baseConfig from '../../eslint.config.mjs';
2
-
3
- export default [
4
- ...baseConfig,
5
- {
6
- files: ['**/*.json'],
7
- rules: {
8
- '@nx/dependency-checks': [
9
- 'error',
10
- {
11
- ignoredFiles: [
12
- '{projectRoot}/eslint.config.{js,cjs,mjs}',
13
- '{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
14
- ],
15
- },
16
- ],
17
- },
18
- languageOptions: {
19
- parser: await import('jsonc-eslint-parser'),
20
- },
21
- },
22
- ];
package/rollup.config.cjs DELETED
@@ -1,28 +0,0 @@
1
- const { withNx } = require('@nx/rollup/with-nx');
2
-
3
- module.exports = withNx(
4
- {
5
- main: 'libs/skill-nuki/src/index.ts',
6
- outputPath: 'dist/libs/skill-nuki',
7
- tsConfig: 'libs/skill-nuki/tsconfig.lib.json',
8
- compiler: 'swc',
9
- format: ['esm', "cjs"],
10
- assets: [
11
- {
12
- input: 'libs/skill-nuki/',
13
- glob: 'package.json',
14
- output: '.'
15
- },
16
- {
17
- input: 'libs/skill-nuki/src/',
18
- glob: '*.json',
19
- output: '.'
20
- }
21
- ]
22
- },
23
- {
24
- // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
25
- // e.g.
26
- // output: { sourcemap: true },
27
- }
28
- );
@@ -1,7 +0,0 @@
1
- import { skillNuki } from './skill-nuki';
2
-
3
- describe('skillNuki', () => {
4
- it('should work', () => {
5
- expect(skillNuki()).toEqual('skill-nuki');
6
- });
7
- });
@@ -1,48 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable @typescript-eslint/no-unused-vars */
3
- import { PinsSettings } from '@digipair/engine';
4
-
5
- class NukiService {
6
- private NUKI_API_KEY: string;
7
- private API_ENDPOINT: string;
8
-
9
- constructor(context: any, params: any) {
10
- this.NUKI_API_KEY =
11
- context.privates.NUKI_API_KEY ?? params?.NUKI_API_KEY ?? process.env['NUKI_API_KEY'];
12
- this.API_ENDPOINT =
13
- context.privates.NUKI_API_ENDPOINT ??
14
- params?.NUKI_API_ENDPOINT ??
15
- process.env['NUKI_API_ENDPOINT'] ??
16
- 'https://api.nuki.io/smartlock';
17
- }
18
-
19
- async call(url: string, method: string, data: any, headers: any, signal: AbortSignal) {
20
- const response = await fetch(`${this.API_ENDPOINT}${url}`, {
21
- signal,
22
- method,
23
- headers: {
24
- Authorization: 'Bearer ' + this.NUKI_API_KEY,
25
- ...headers,
26
- },
27
- body: data,
28
- });
29
- if (!response.ok) throw new Error('[SKILL-NUKI] REQUEST FAILED: ' + response.status);
30
- return await response.json();
31
- }
32
-
33
- async unlock(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
34
- const { id } = params;
35
- return await this.call(`/${id}/action/unlock`, 'POST', null, {}, context.protected?.signal);
36
- }
37
-
38
- async lock(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
39
- const { id } = params;
40
- return await this.call(`/${id}/action/lock`, 'POST', null, {}, context.protected?.signal);
41
- }
42
- }
43
-
44
- export const lock = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
45
- new NukiService(context, params).lock(params, pinsSettingsList, context);
46
-
47
- export const unlock = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
48
- new NukiService(context, params).unlock(params, pinsSettingsList, context);
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "files": [],
4
- "include": [],
5
- "references": [
6
- {
7
- "path": "../engine"
8
- },
9
- {
10
- "path": "./tsconfig.lib.json"
11
- }
12
- ]
13
- }
package/tsconfig.lib.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist",
6
- "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
- "emitDeclarationOnly": true,
8
- "module": "esnext",
9
- "moduleResolution": "node",
10
- "forceConsistentCasingInFileNames": true,
11
- "types": ["node"]
12
- },
13
- "include": ["src/**/*.ts"],
14
- "references": [
15
- {
16
- "path": "../engine/tsconfig.lib.json"
17
- }
18
- ]
19
- }
File without changes
File without changes
File without changes