From 5d4012e2443d807bc6661429fec87c03edb0dc1e Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 8 Apr 2025 15:26:52 -0700 Subject: [PATCH 1/4] doc(CONTRIBUTORS): updated --- .release | 2 +- CONTRIBUTORS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.release b/.release index 80c3d1a..7307651 160000 --- a/.release +++ b/.release @@ -1 +1 @@ -Subproject commit 80c3d1a67344cc321e054a23a8b4ae59b284909a +Subproject commit 73076513e83c2057a32515831b638771c15b1d83 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index b0adecc..9f745a6 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,7 +2,7 @@ This handcrafted artisinal software is brought to you by: -|
msimerson (20)| +|
msimerson (21)| | :---: | this file is generated by [.release](https://github.com/msimerson/.release). From 160e971a3119fb9c4aedd92b1d69ab55e5855b7f Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 8 Apr 2025 15:33:17 -0700 Subject: [PATCH 2/4] release 0.8.2 - feat(zone_record): added GET, POST, and DELETE formats - feat(zone): added GET, POST, and DELETE formats - feat(session): can return a token - feat(perm): name ca be empty - feat(ns): GET always returns an array of items - feat(ns): address6 can be empty - meta: add [files] to package.json, deleted .npmignore --- .npmignore | 14 -------------- CHANGELOG.md | 12 ++++++++++++ lib/nameserver.js | 4 ++-- lib/permission.js | 2 +- lib/session.js | 1 + lib/zone.js | 38 ++++++++++++++++++++++++++++++++------ lib/zone_record.js | 34 ++++++++++++++++++++++++++++------ package.json | 16 ++++++++++------ 8 files changed, 86 insertions(+), 35 deletions(-) delete mode 100644 .npmignore diff --git a/.npmignore b/.npmignore deleted file mode 100644 index f3a982e..0000000 --- a/.npmignore +++ /dev/null @@ -1,14 +0,0 @@ -.github -.DS_Store -.editorconfig -.gitignore -.gitmodules -.lgtm.yml -appveyor.yml -codecov.yml -.release -.travis.yml -.eslintrc.yaml -.eslintrc.yml -.eslintrc.json -.prettierrc.yml \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fc70cf8..7d5d1f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Unreleased +### [0.8.2] - 2025-04-08 + +- feat(zone_record): added GET, POST, and DELETE formats +- feat(zone): added GET, POST, and DELETE formats +- feat(session): can return a token +- feat(perm): name ca be empty +- feat(ns): GET always returns an array of items +- feat(ns): address6 can be empty +- meta: add [files] to package.json, deleted .npmignore + ### [0.8.1] - 2024-12-16 - doc(CONTRIBUTORS): added @@ -75,3 +85,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). [0.7.4]: https://github.com/NicTool/validate/releases/tag/0.7.4 [0.8.0]: https://github.com/NicTool/validate/releases/tag/0.8.0 [0.8.1]: https://github.com/NicTool/validate/releases/tag/v0.8.1 +[0.8.2]: https://github.com/NicTool/validate/releases/tag/v0.8.2 +[1.0.0]: https://github.com/NicTool/validate/releases/tag/1.0.0 diff --git a/lib/nameserver.js b/lib/nameserver.js index 0264ac6..784c2f0 100644 --- a/lib/nameserver.js +++ b/lib/nameserver.js @@ -29,7 +29,7 @@ exports.v3 = Joi.object({ ttl: shared.ttl.required(), description: Joi.string().empty('').max(255), address: shared.ipv4.required(), - address6: shared.ipv6, + address6: shared.ipv6.empty(''), remote_login: exports.remote_login, logdir: Joi.string().empty('').max(255), datadir: Joi.string().empty('').min(2).max(255), @@ -49,7 +49,7 @@ exports.GET_req = Joi.object({ }) exports.GET_res = Joi.object({ - nameserver: exports.v3, + nameserver: Joi.array().items(exports.v3), meta: shared.meta, }) diff --git a/lib/permission.js b/lib/permission.js index d9d3740..0dac807 100644 --- a/lib/permission.js +++ b/lib/permission.js @@ -6,7 +6,7 @@ exports.id = Joi.number().integer().min(1).max(4294967295) exports.v3 = Joi.object({ id: exports.id, - name: Joi.string(), + name: Joi.string().empty(''), inherit: Joi.boolean(), self_write: Joi.boolean(), deleted: Joi.boolean(), diff --git a/lib/session.js b/lib/session.js index bf6cb5f..02dfae7 100644 --- a/lib/session.js +++ b/lib/session.js @@ -16,6 +16,7 @@ exports.GET_res = Joi.object({ group: group.v3, session: Joi.object({ id: Joi.number().integer().min(1).max(4294967295), + token: Joi.string(), last_access: Joi.number().integer().min(1).max(4294967295), }), meta: shared.meta, diff --git a/lib/zone.js b/lib/zone.js index ce78f30..958a763 100644 --- a/lib/zone.js +++ b/lib/zone.js @@ -2,16 +2,20 @@ const Joi = require('joi') const shared = require('./shared') -exports.v3 = Joi.object({ - id: shared.uint32, - - gid: shared.uint32.required(), +exports.id = shared.uint32 - zone: Joi.string() +exports.zone = Joi.string() .min(3) .max(255) .domain({ allowFullyQualified: true, tlds: false }) - .required(), + .required() + +exports.v3 = Joi.object({ + id: exports.id, + + gid: shared.uint32.required(), + + zone: exports.zone, description: Joi.string().empty(''), @@ -31,5 +35,27 @@ exports.v3 = Joi.object({ ttl: shared.ttl.required(), + last_modified: Joi.date(), + + last_publish: Joi.date().allow('', null), + + deleted: Joi.boolean(), +}) + +exports.GET_req = Joi.object({ + id: exports.id, + zone: exports.zone, + deleted: Joi.boolean(), +}) + +exports.GET_res = Joi.object({ + zone: Joi.array().items(exports.v3), + meta: shared.meta, +}) + +exports.POST = exports.v3 + +exports.DELETE = Joi.object({ + id: exports.id, deleted: Joi.boolean(), }) diff --git a/lib/zone_record.js b/lib/zone_record.js index 4b4aab5..cd2579e 100644 --- a/lib/zone_record.js +++ b/lib/zone_record.js @@ -2,16 +2,20 @@ const Joi = require('joi') const shared = require('./shared') -exports.v3 = Joi.object({ - id: shared.uint32.min(1).required(), - - zid: shared.uint32.min(1).required(), +exports.id = shared.uint32.min(1).required() - name: Joi.string() +exports.owner = Joi.string() .min(1) .max(255) .domain({ minDomainSegments: 1, allowFullyQualified: false, tlds: false }) - .required(), + .required() + +exports.v3 = Joi.object({ + id: exports.id, + + zid: shared.uint32.min(1).required(), + + owner: exports.owner, ttl: shared.ttl.required(), @@ -27,3 +31,21 @@ exports.v3 = Joi.object({ deleted: Joi.boolean(), }) + +exports.GET_req = Joi.object({ + id: shared.uint32, + zid: shared.uint32, + deleted: Joi.boolean(), +}) + +exports.GET_res = Joi.object({ + zone_record: Joi.array().items(exports.v3), + meta: shared.meta, +}) + +exports.POST = exports.v3 + +exports.DELETE = Joi.object({ + id: exports.id, + deleted: Joi.boolean(), +}) \ No newline at end of file diff --git a/package.json b/package.json index c4fad3e..6f1abe4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,10 @@ { "name": "@nictool/validate", - "version": "0.8.1", + "version": "0.8.2", "description": "NicTool Object Validation", + "files": [ + "lib", "index.js", "CHANGELOG.md" + ], "main": "index.js", "directories": { "test": "test" @@ -15,6 +18,7 @@ "prettier:fix": "npx prettier --ignore-path .gitignore --write .", "test": "node --test", "versions": "npx dependency-version-checker check", + "versions:fix": "npx dependency-version-checker update", "watch": "node --test --watch" }, "repository": { @@ -34,11 +38,11 @@ }, "homepage": "https://github.com/NicTool/validate#readme", "devDependencies": { - "@eslint/eslintrc": "^3.2.0", - "eslint": "^9.17.0", - "@eslint/js": "^9.17.0", - "eslint-config-prettier": "^9.1.0", - "globals": "^15.13.0" + "@eslint/eslintrc": "^3.3.1", + "eslint": "^9.24.0", + "@eslint/js": "^10.0.0", + "eslint-config-prettier": "^10.1.1", + "globals": "^16.0.0" }, "dependencies": { "joi": "^17.13.3", From 510b11be5f836468c7d7a125b546310d9be97d60 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 8 Apr 2025 15:33:29 -0700 Subject: [PATCH 3/4] chore: format --- CONTRIBUTORS.md | 4 ++-- eslint.config.mjs | 42 +++++++++++++++++++++++------------------- lib/zone.js | 8 ++++---- lib/zone_record.js | 10 +++++----- package.json | 4 +++- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9f745a6..bf1f31d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,8 +2,8 @@ This handcrafted artisinal software is brought to you by: -|
msimerson (21)| -| :---: | +|
msimerson (21) | +| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | this file is generated by [.release](https://github.com/msimerson/.release). Contribute to this project to get your GitHub profile included here. diff --git a/eslint.config.mjs b/eslint.config.mjs index c8fcfd8..2c521da 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,24 +1,28 @@ -import globals from "globals"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import js from "@eslint/js"; -import { FlatCompat } from "@eslint/eslintrc"; +import globals from 'globals' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import js from '@eslint/js' +import { FlatCompat } from '@eslint/eslintrc' -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all -}); + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}) -export default [{ - ignores: ["**/package-lock.json"], -}, ...compat.extends("eslint:recommended", "prettier"), { +export default [ + { + ignores: ['**/package-lock.json'], + }, + ...compat.extends('eslint:recommended', 'prettier'), + { languageOptions: { - globals: { - ...globals.node, - ...globals.mocha, - }, + globals: { + ...globals.node, + ...globals.mocha, + }, }, -}]; \ No newline at end of file + }, +] diff --git a/lib/zone.js b/lib/zone.js index 958a763..8795a03 100644 --- a/lib/zone.js +++ b/lib/zone.js @@ -5,10 +5,10 @@ const shared = require('./shared') exports.id = shared.uint32 exports.zone = Joi.string() - .min(3) - .max(255) - .domain({ allowFullyQualified: true, tlds: false }) - .required() + .min(3) + .max(255) + .domain({ allowFullyQualified: true, tlds: false }) + .required() exports.v3 = Joi.object({ id: exports.id, diff --git a/lib/zone_record.js b/lib/zone_record.js index cd2579e..c65553f 100644 --- a/lib/zone_record.js +++ b/lib/zone_record.js @@ -5,10 +5,10 @@ const shared = require('./shared') exports.id = shared.uint32.min(1).required() exports.owner = Joi.string() - .min(1) - .max(255) - .domain({ minDomainSegments: 1, allowFullyQualified: false, tlds: false }) - .required() + .min(1) + .max(255) + .domain({ minDomainSegments: 1, allowFullyQualified: false, tlds: false }) + .required() exports.v3 = Joi.object({ id: exports.id, @@ -48,4 +48,4 @@ exports.POST = exports.v3 exports.DELETE = Joi.object({ id: exports.id, deleted: Joi.boolean(), -}) \ No newline at end of file +}) diff --git a/package.json b/package.json index 6f1abe4..c6e75e4 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "version": "0.8.2", "description": "NicTool Object Validation", "files": [ - "lib", "index.js", "CHANGELOG.md" + "lib", + "index.js", + "CHANGELOG.md" ], "main": "index.js", "directories": { From d8e2738cbf485cf403de75f07fd54f0b1efcd42c Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 8 Apr 2025 15:39:33 -0700 Subject: [PATCH 4/4] test fixes --- lib/test/zone_record.json | 2 +- lib/zone_record.test.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/test/zone_record.json b/lib/test/zone_record.json index 910d924..45e4270 100644 --- a/lib/test/zone_record.json +++ b/lib/test/zone_record.json @@ -1,7 +1,7 @@ { "id": 1, "zid": 1, - "name": "a", + "owner": "a", "ttl": 86400, "type": "A", "address": "1.1.1.1" diff --git a/lib/zone_record.test.js b/lib/zone_record.test.js index 5e1bf3c..3a7a8c9 100644 --- a/lib/zone_record.test.js +++ b/lib/zone_record.test.js @@ -46,7 +46,7 @@ describe('zone_record', function () { } }) - describe('name', function () { + describe('owner', function () { it(`accepts valid`, () => { const testCase = JSON.parse(JSON.stringify(testZR)) const { error, value } = schema.validate(testCase) @@ -56,26 +56,26 @@ describe('zone_record', function () { it(`rejects missing`, () => { const testCase = JSON.parse(JSON.stringify(testZR)) - delete testCase.name + delete testCase.owner const { error } = schema.validate(testCase) - assert.strictEqual(error.message, '"name" is required') + assert.strictEqual(error.message, '"owner" is required') }) it(`rejects empty`, () => { const testCase = JSON.parse(JSON.stringify(testZR)) - testCase.name = '' + testCase.owner = '' const { error } = schema.validate(testCase) - assert.strictEqual(error.message, '"name" is not allowed to be empty') + assert.strictEqual(error.message, '"owner" is not allowed to be empty') }) - for (const name of ['a.m.', 'something.test.']) { - it(`rejects invalid: ${name}`, () => { + for (const owner of ['a.m.', 'something.test.']) { + it(`rejects invalid: ${owner}`, () => { const testCase = JSON.parse(JSON.stringify(testZR)) - testCase.name = name + testCase.owner = owner const { error } = schema.validate(testCase) assert.deepEqual( error.message, - '"name" must contain a valid domain name', + '"owner" must contain a valid domain name', ) }) }