@axium/notes 0.1.10 → 0.1.12
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/common.d.ts +13 -3
- package/dist/common.js +2 -1
- package/dist/server.js +5 -10
- package/package.json +3 -3
package/dist/common.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import type { Permission } from '@axium/core';
|
|
2
1
|
import * as z from 'zod';
|
|
3
2
|
export declare const NoteInit: z.ZodObject<{
|
|
4
3
|
title: z.ZodString;
|
|
5
4
|
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
5
|
labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
7
|
-
publicPermission: z.ZodDefault<z.
|
|
6
|
+
publicPermission: z.ZodDefault<z.ZodEnum<{
|
|
7
|
+
readonly None: 0;
|
|
8
|
+
readonly Read: 1;
|
|
9
|
+
readonly Comment: 2;
|
|
10
|
+
readonly Edit: 3;
|
|
11
|
+
readonly Manage: 5;
|
|
12
|
+
}> & {
|
|
13
|
+
readonly None: 0;
|
|
14
|
+
readonly Read: 1;
|
|
15
|
+
readonly Comment: 2;
|
|
16
|
+
readonly Edit: 3;
|
|
17
|
+
readonly Manage: 5;
|
|
18
|
+
}>;
|
|
8
19
|
}, z.core.$strip>;
|
|
9
20
|
export interface NoteInit extends z.infer<typeof NoteInit> {
|
|
10
|
-
publicPermission: Permission;
|
|
11
21
|
}
|
|
12
22
|
export interface Note extends z.infer<typeof NoteInit> {
|
|
13
23
|
id: string;
|
package/dist/common.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Permission } from '@axium/core/access';
|
|
1
2
|
import * as z from 'zod';
|
|
2
3
|
export const NoteInit = z.object({
|
|
3
4
|
title: z.string().max(100),
|
|
4
5
|
content: z.string().max(10_000).nullish(),
|
|
5
6
|
labels: z.array(z.string().max(30)).default([]),
|
|
6
|
-
publicPermission:
|
|
7
|
+
publicPermission: Permission.default(0),
|
|
7
8
|
});
|
package/dist/server.js
CHANGED
|
@@ -18,8 +18,7 @@ expectedTypes.notes = {
|
|
|
18
18
|
addRoute({
|
|
19
19
|
path: '/api/users/:id/notes',
|
|
20
20
|
params: { id: z.uuid() },
|
|
21
|
-
async GET(request,
|
|
22
|
-
const userId = params.id;
|
|
21
|
+
async GET(request, { id: userId }) {
|
|
23
22
|
await checkAuthForUser(request, userId);
|
|
24
23
|
return await database
|
|
25
24
|
.selectFrom('notes')
|
|
@@ -28,9 +27,8 @@ addRoute({
|
|
|
28
27
|
.execute()
|
|
29
28
|
.catch(withError('Could not get notes'));
|
|
30
29
|
},
|
|
31
|
-
async PUT(request,
|
|
30
|
+
async PUT(request, { id: userId }) {
|
|
32
31
|
const init = await parseBody(request, NoteInit);
|
|
33
|
-
const userId = params.id;
|
|
34
32
|
await checkAuthForUser(request, userId);
|
|
35
33
|
return await database
|
|
36
34
|
.insertInto('notes')
|
|
@@ -43,14 +41,12 @@ addRoute({
|
|
|
43
41
|
addRoute({
|
|
44
42
|
path: '/api/notes/:id',
|
|
45
43
|
params: { id: z.uuid() },
|
|
46
|
-
async GET(request,
|
|
47
|
-
const id = params.id;
|
|
44
|
+
async GET(request, { id }) {
|
|
48
45
|
const { item } = await checkAuthForItem(request, 'notes', id, Permission.Read);
|
|
49
46
|
return item;
|
|
50
47
|
},
|
|
51
|
-
async PATCH(request,
|
|
48
|
+
async PATCH(request, { id }) {
|
|
52
49
|
const init = await parseBody(request, NoteInit);
|
|
53
|
-
const id = params.id;
|
|
54
50
|
await checkAuthForItem(request, 'notes', id, Permission.Edit);
|
|
55
51
|
return await database
|
|
56
52
|
.updateTable('notes')
|
|
@@ -61,8 +57,7 @@ addRoute({
|
|
|
61
57
|
.executeTakeFirstOrThrow()
|
|
62
58
|
.catch(withError('Could not update note'));
|
|
63
59
|
},
|
|
64
|
-
async DELETE(request,
|
|
65
|
-
const id = params.id;
|
|
60
|
+
async DELETE(request, { id }) {
|
|
66
61
|
await checkAuthForItem(request, 'notes', id, Permission.Manage);
|
|
67
62
|
return await database
|
|
68
63
|
.deleteFrom('notes')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/notes",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"author": "James Prevett <axium@jamespre.dev>",
|
|
5
5
|
"description": "Notes for Axium",
|
|
6
6
|
"funding": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@axium/client": ">=0.6.0",
|
|
38
|
-
"@axium/core": ">=0.
|
|
39
|
-
"@axium/server": ">=0.
|
|
38
|
+
"@axium/core": ">=0.10.0",
|
|
39
|
+
"@axium/server": ">=0.27.0",
|
|
40
40
|
"@sveltejs/kit": "^2.27.3",
|
|
41
41
|
"utilium": "^2.4.0"
|
|
42
42
|
},
|