@axium/notes 0.1.8 → 0.1.9
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/dist/hooks.d.ts +6 -0
- package/dist/{plugin.js → hooks.js} +4 -10
- package/dist/server.js +17 -17
- package/package.json +16 -13
- package/dist/plugin.d.ts +0 -61
package/dist/hooks.d.ts
ADDED
|
@@ -2,14 +2,13 @@ import * as acl from '@axium/server/acl';
|
|
|
2
2
|
import { count, createIndex, database, warnExists } from '@axium/server/database';
|
|
3
3
|
import { done, start } from '@axium/server/io';
|
|
4
4
|
import { sql } from 'kysely';
|
|
5
|
-
import pkg from '../package.json' with { type: 'json' };
|
|
6
5
|
import './common.js';
|
|
7
6
|
import './server.js';
|
|
8
|
-
async function statusText() {
|
|
7
|
+
export async function statusText() {
|
|
9
8
|
const { notes } = await count('notes');
|
|
10
9
|
return `${notes} notes`;
|
|
11
10
|
}
|
|
12
|
-
async function db_init() {
|
|
11
|
+
export async function db_init() {
|
|
13
12
|
start('Creating table notes');
|
|
14
13
|
await database.schema
|
|
15
14
|
.createTable('notes')
|
|
@@ -27,18 +26,13 @@ async function db_init() {
|
|
|
27
26
|
await createIndex('notes', 'userId');
|
|
28
27
|
await acl.createTable('notes');
|
|
29
28
|
}
|
|
30
|
-
async function db_wipe() {
|
|
29
|
+
export async function db_wipe() {
|
|
31
30
|
start('Wiping data from notes');
|
|
32
31
|
await database.deleteFrom('notes').execute().then(done);
|
|
33
32
|
await acl.wipeTable('notes');
|
|
34
33
|
}
|
|
35
|
-
async function remove() {
|
|
34
|
+
export async function remove() {
|
|
36
35
|
await acl.dropTable('notes');
|
|
37
36
|
start('Dropping table notes');
|
|
38
37
|
await database.schema.dropTable('notes').execute().then(done);
|
|
39
38
|
}
|
|
40
|
-
export default {
|
|
41
|
-
...pkg,
|
|
42
|
-
statusText,
|
|
43
|
-
hooks: { db_init, db_wipe, remove },
|
|
44
|
-
};
|
package/dist/server.js
CHANGED
|
@@ -18,9 +18,9 @@ expectedTypes.notes = {
|
|
|
18
18
|
addRoute({
|
|
19
19
|
path: '/api/users/:id/notes',
|
|
20
20
|
params: { id: z.uuid() },
|
|
21
|
-
async GET(
|
|
22
|
-
const userId =
|
|
23
|
-
await checkAuthForUser(
|
|
21
|
+
async GET(request, params) {
|
|
22
|
+
const userId = params.id;
|
|
23
|
+
await checkAuthForUser(request, userId);
|
|
24
24
|
return await database
|
|
25
25
|
.selectFrom('notes')
|
|
26
26
|
.selectAll()
|
|
@@ -28,10 +28,10 @@ addRoute({
|
|
|
28
28
|
.execute()
|
|
29
29
|
.catch(withError('Could not get notes'));
|
|
30
30
|
},
|
|
31
|
-
async PUT(
|
|
32
|
-
const init = await parseBody(
|
|
33
|
-
const userId =
|
|
34
|
-
await checkAuthForUser(
|
|
31
|
+
async PUT(request, params) {
|
|
32
|
+
const init = await parseBody(request, NoteInit);
|
|
33
|
+
const userId = params.id;
|
|
34
|
+
await checkAuthForUser(request, userId);
|
|
35
35
|
return await database
|
|
36
36
|
.insertInto('notes')
|
|
37
37
|
.values({ ...init, userId })
|
|
@@ -43,15 +43,15 @@ addRoute({
|
|
|
43
43
|
addRoute({
|
|
44
44
|
path: '/api/notes/:id',
|
|
45
45
|
params: { id: z.uuid() },
|
|
46
|
-
async GET(
|
|
47
|
-
const id =
|
|
48
|
-
const { item } = await checkAuthForItem(
|
|
46
|
+
async GET(request, params) {
|
|
47
|
+
const id = params.id;
|
|
48
|
+
const { item } = await checkAuthForItem(request, 'notes', id, Permission.Read);
|
|
49
49
|
return item;
|
|
50
50
|
},
|
|
51
|
-
async PATCH(
|
|
52
|
-
const init = await parseBody(
|
|
53
|
-
const id =
|
|
54
|
-
await checkAuthForItem(
|
|
51
|
+
async PATCH(request, params) {
|
|
52
|
+
const init = await parseBody(request, NoteInit);
|
|
53
|
+
const id = params.id;
|
|
54
|
+
await checkAuthForItem(request, 'notes', id, Permission.Edit);
|
|
55
55
|
return await database
|
|
56
56
|
.updateTable('notes')
|
|
57
57
|
.set(init)
|
|
@@ -61,9 +61,9 @@ addRoute({
|
|
|
61
61
|
.executeTakeFirstOrThrow()
|
|
62
62
|
.catch(withError('Could not update note'));
|
|
63
63
|
},
|
|
64
|
-
async DELETE(
|
|
65
|
-
const id =
|
|
66
|
-
await checkAuthForItem(
|
|
64
|
+
async DELETE(request, params) {
|
|
65
|
+
const id = params.id;
|
|
66
|
+
await checkAuthForItem(request, 'notes', id, Permission.Manage);
|
|
67
67
|
return await database
|
|
68
68
|
.deleteFrom('notes')
|
|
69
69
|
.where('id', '=', id)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/notes",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"author": "James Prevett <axium@jamespre.dev>
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"author": "James Prevett <axium@jamespre.dev>",
|
|
5
5
|
"description": "Notes for Axium",
|
|
6
6
|
"funding": {
|
|
7
7
|
"type": "individual",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"./components": "./lib/index.js",
|
|
26
26
|
"./components/*": "./lib/*.svelte"
|
|
27
27
|
},
|
|
28
|
-
"routes": "routes",
|
|
29
28
|
"files": [
|
|
30
29
|
"dist",
|
|
31
30
|
"lib",
|
|
@@ -35,20 +34,24 @@
|
|
|
35
34
|
"build": "tsc"
|
|
36
35
|
},
|
|
37
36
|
"peerDependencies": {
|
|
38
|
-
"@axium/client": ">=0.
|
|
39
|
-
"@axium/core": ">=0.
|
|
40
|
-
"@axium/server": ">=0.
|
|
37
|
+
"@axium/client": ">=0.5.0",
|
|
38
|
+
"@axium/core": ">=0.8.0",
|
|
39
|
+
"@axium/server": ">=0.25.0",
|
|
41
40
|
"@sveltejs/kit": "^2.27.3",
|
|
42
41
|
"utilium": "^2.4.0"
|
|
43
42
|
},
|
|
44
43
|
"dependencies": {
|
|
45
44
|
"zod": "^4.0.5"
|
|
46
45
|
},
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
"axium": {
|
|
47
|
+
"routes": "routes",
|
|
48
|
+
"hooks": "./dist/hooks.js",
|
|
49
|
+
"apps": [
|
|
50
|
+
{
|
|
51
|
+
"id": "notes",
|
|
52
|
+
"name": "Notes",
|
|
53
|
+
"icon": "notes"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
54
57
|
}
|
package/dist/plugin.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import './common.js';
|
|
2
|
-
import './server.js';
|
|
3
|
-
declare function statusText(): Promise<string>;
|
|
4
|
-
declare function db_init(): Promise<void>;
|
|
5
|
-
declare function db_wipe(): Promise<void>;
|
|
6
|
-
declare function remove(): Promise<void>;
|
|
7
|
-
declare const _default: {
|
|
8
|
-
statusText: typeof statusText;
|
|
9
|
-
hooks: {
|
|
10
|
-
db_init: typeof db_init;
|
|
11
|
-
db_wipe: typeof db_wipe;
|
|
12
|
-
remove: typeof remove;
|
|
13
|
-
};
|
|
14
|
-
name: string;
|
|
15
|
-
version: string;
|
|
16
|
-
author: string;
|
|
17
|
-
description: string;
|
|
18
|
-
funding: {
|
|
19
|
-
type: string;
|
|
20
|
-
url: string;
|
|
21
|
-
};
|
|
22
|
-
license: string;
|
|
23
|
-
repository: {
|
|
24
|
-
type: string;
|
|
25
|
-
url: string;
|
|
26
|
-
};
|
|
27
|
-
homepage: string;
|
|
28
|
-
bugs: {
|
|
29
|
-
url: string;
|
|
30
|
-
};
|
|
31
|
-
type: string;
|
|
32
|
-
main: string;
|
|
33
|
-
types: string;
|
|
34
|
-
exports: {
|
|
35
|
-
".": string;
|
|
36
|
-
"./*": string;
|
|
37
|
-
"./components": string;
|
|
38
|
-
"./components/*": string;
|
|
39
|
-
};
|
|
40
|
-
routes: string;
|
|
41
|
-
files: string[];
|
|
42
|
-
scripts: {
|
|
43
|
-
build: string;
|
|
44
|
-
};
|
|
45
|
-
peerDependencies: {
|
|
46
|
-
"@axium/client": string;
|
|
47
|
-
"@axium/core": string;
|
|
48
|
-
"@axium/server": string;
|
|
49
|
-
"@sveltejs/kit": string;
|
|
50
|
-
utilium: string;
|
|
51
|
-
};
|
|
52
|
-
dependencies: {
|
|
53
|
-
zod: string;
|
|
54
|
-
};
|
|
55
|
-
apps: {
|
|
56
|
-
id: string;
|
|
57
|
-
name: string;
|
|
58
|
-
icon: string;
|
|
59
|
-
}[];
|
|
60
|
-
};
|
|
61
|
-
export default _default;
|