@dodi-smart/nuki-graphql-api
Version:
Nuki GraphQL API
147 lines • 6.01 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const builder_1 = require("../builder");
const session_1 = require("../session");
const utils_1 = require("../utils");
builder_1.builder.objectType('NukiSmartlock', {
fields: (t) => ({
smartlockId: t.exposeInt('smartlockId', {
description: 'The smartlock id',
nullable: false
}),
accountId: t.exposeInt('accountId', {
description: 'The account id',
nullable: false
}),
type: t.exposeInt('type', {
description: 'The type: 0 .. keyturner, 1 .. box, 2 .. opener, 3 .. smartdoor',
nullable: false
}),
lmType: t.exposeInt('lmType', {
description: 'The lock mechanism used in the smart door lock: 1 .. MyEVO, 2 .. KFV Genius (only for type = 3)',
nullable: true
}),
authId: t.exposeInt('authId', {
description: 'The authorization id',
nullable: false
}),
name: t.exposeString('name', {
description: 'The name of the smartlock',
nullable: false
}),
favorite: t.exposeBoolean('favorite', {
description: 'The favorite flag',
nullable: false
}),
config: t.expose('config', {
type: 'NukiSmartlockConfig',
nullable: true
}),
advancedConfig: t.expose('advancedConfig', {
type: 'NukiSmartlockAdvancedConfig',
nullable: true
}),
state: t.expose('state', {
type: 'NukiSmartlockState',
nullable: true
}),
firmwareVersion: t.exposeInt('firmwareVersion', {
description: 'The firmware version',
nullable: true
}),
hardwareVersion: t.exposeInt('hardwareVersion', {
description: 'The hardware version',
nullable: true
}),
operationId: t.exposeString('operationId', {
description: "The operation id - if set it's locked for another operation",
nullable: true
}),
serverState: t.exposeInt('serverState', {
description: 'The server state: 0 .. ok, 1 .. unregistered, 2 .. auth uuid invalid, 3 .. auth invalid, 4 .. offline',
nullable: false
}),
adminPinState: t.exposeInt('adminPinState', {
description: 'The admin pin state: 0 .. ok, 1 .. missing, 2 .. invalid',
nullable: false
}),
virtualDevice: t.exposeBoolean('virtualDevice', {
description: 'The flag indicating a virtual Smart Lock',
nullable: true
}),
creationDate: t.exposeString('creationDate', {
description: 'The creation date',
nullable: true
}),
updateDate: t.exposeString('updateDate', {
description: 'The update date',
nullable: true
}),
opener: t.exposeBoolean('opener', {
description: '',
nullable: true
}),
box: t.exposeBoolean('box', {
description: '',
nullable: true
}),
smartDoor: t.exposeBoolean('smartDoor', {
description: '',
nullable: true
}),
keyturner: t.exposeBoolean('keyturner', {
description: '',
nullable: true
}),
smartlock3: t.exposeBoolean('smartlock3', {
description: '',
nullable: true
}),
logs: t.field({
type: ['NukiSmartlockLog'],
nullable: false,
description: 'List with the smartlock access logs',
args: {
authId: t.arg.string({
description: 'Filter for auths',
required: false
}),
accountUserId: t.arg.int({
description: 'Filter for account users',
required: false
}),
fromDate: t.arg.string({
description: 'Filter for date (RFC3339)',
required: false
}),
toDate: t.arg.string({
description: 'Filter for date (RFC3339)',
required: false
}),
action: t.arg.int({
description: 'Filter for action',
required: false
}),
limit: t.arg.int({
description: 'Amount of logs (max: 50)',
required: false,
defaultValue: 10
})
},
resolve: (smartlock, { authId, accountUserId, fromDate, toDate, action, limit }) => __awaiter(void 0, void 0, void 0, function* () {
const logs = yield session_1.authHolder.appClient.smartlockLog.getSmartlockLogs(smartlock.smartlockId, (0, utils_1.fixStringNullable)(authId), (0, utils_1.fixNumberNullable)(accountUserId), (0, utils_1.fixStringNullable)(fromDate), (0, utils_1.fixStringNullable)(toDate), (0, utils_1.fixNumberNullable)(action), undefined, (0, utils_1.fixNumberNullable)(limit));
return logs;
})
})
})
});
//# sourceMappingURL=smartlock.js.map