@axium/notes 0.1.0 → 0.1.1
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 +3 -3
- package/dist/common.js +3 -3
- package/dist/server.d.ts +2 -2
- package/dist/server.js +3 -2
- package/lib/Note.svelte +9 -6
- package/package.json +1 -1
- package/routes/notes/+page.svelte +9 -24
package/dist/common.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { Permission } from '@axium/core';
|
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
export declare const NoteInit: z.ZodObject<{
|
|
4
4
|
title: z.ZodString;
|
|
5
|
-
content: z.ZodString
|
|
6
|
-
labels: z.ZodArray<z.ZodString
|
|
7
|
-
publicPermission: z.ZodInt
|
|
5
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
7
|
+
publicPermission: z.ZodDefault<z.ZodInt>;
|
|
8
8
|
}, z.core.$strip>;
|
|
9
9
|
export interface NoteInit extends z.infer<typeof NoteInit> {
|
|
10
10
|
publicPermission: Permission;
|
package/dist/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
export const NoteInit = z.object({
|
|
3
3
|
title: z.string().max(100),
|
|
4
|
-
content: z.string().max(
|
|
5
|
-
labels: z.array(z.string().max(
|
|
6
|
-
publicPermission: z.int().min(0).max(5),
|
|
4
|
+
content: z.string().max(10_000).nullish(),
|
|
5
|
+
labels: z.array(z.string().max(30)).default([]),
|
|
6
|
+
publicPermission: z.int().min(0).max(5).default(0),
|
|
7
7
|
});
|
package/dist/server.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ declare module '@axium/server/database' {
|
|
|
6
6
|
id: GeneratedAlways<string>;
|
|
7
7
|
userId: string;
|
|
8
8
|
created: GeneratedAlways<Date>;
|
|
9
|
-
modified:
|
|
9
|
+
modified: Generated<Date>;
|
|
10
10
|
title: string;
|
|
11
|
-
content: string;
|
|
11
|
+
content: string | null;
|
|
12
12
|
publicPermission: Generated<Permission>;
|
|
13
13
|
labels: Generated<string[]>;
|
|
14
14
|
};
|
package/dist/server.js
CHANGED
|
@@ -11,9 +11,9 @@ expectedTypes.notes = {
|
|
|
11
11
|
created: { type: 'timestamptz', required: true, hasDefault: true },
|
|
12
12
|
modified: { type: 'timestamptz', required: true, hasDefault: true },
|
|
13
13
|
title: { type: 'text', required: true },
|
|
14
|
-
content: { type: 'text'
|
|
14
|
+
content: { type: 'text' },
|
|
15
15
|
publicPermission: { type: 'int4', required: true, hasDefault: true },
|
|
16
|
-
labels: { type: '_text', required:
|
|
16
|
+
labels: { type: '_text', required: true, hasDefault: true },
|
|
17
17
|
};
|
|
18
18
|
addRoute({
|
|
19
19
|
path: '/api/users/:id/notes',
|
|
@@ -55,6 +55,7 @@ addRoute({
|
|
|
55
55
|
return await database
|
|
56
56
|
.updateTable('notes')
|
|
57
57
|
.set(init)
|
|
58
|
+
.set('modified', new Date())
|
|
58
59
|
.where('id', '=', id)
|
|
59
60
|
.returningAll()
|
|
60
61
|
.executeTakeFirstOrThrow()
|
package/lib/Note.svelte
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
type="text"
|
|
16
16
|
bind:value={note.title}
|
|
17
17
|
class="editable-text"
|
|
18
|
-
|
|
18
|
+
onchange={e => {
|
|
19
19
|
note.title = e.currentTarget.value;
|
|
20
20
|
fetchAPI('PATCH', 'notes/:id', note, note.id);
|
|
21
21
|
}}
|
|
@@ -52,7 +52,14 @@
|
|
|
52
52
|
{/if}
|
|
53
53
|
</Popover>
|
|
54
54
|
</div>
|
|
55
|
-
<textarea
|
|
55
|
+
<textarea
|
|
56
|
+
name="content"
|
|
57
|
+
class="editable-text"
|
|
58
|
+
onchange={e => {
|
|
59
|
+
note.content = e.currentTarget.value;
|
|
60
|
+
fetchAPI('PATCH', 'notes/:id', note, note.id);
|
|
61
|
+
}}>{note.content}</textarea
|
|
62
|
+
>
|
|
56
63
|
</div>
|
|
57
64
|
|
|
58
65
|
<style>
|
|
@@ -90,8 +97,4 @@
|
|
|
90
97
|
.note:hover :global(.popover-toggle) {
|
|
91
98
|
visibility: visible;
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
.note-content {
|
|
95
|
-
background-color: inherit;
|
|
96
|
-
}
|
|
97
100
|
</style>
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { Icon } from '@axium/client/components';
|
|
2
3
|
import { fetchAPI } from '@axium/client/requests';
|
|
3
|
-
import { FormDialog, Icon } from '@axium/client/components';
|
|
4
4
|
import { parseNote } from '@axium/notes/client';
|
|
5
|
-
import { NoteInit } from '@axium/notes/common';
|
|
6
5
|
import { Note } from '@axium/notes/components';
|
|
7
6
|
|
|
8
7
|
const { data } = $props();
|
|
9
8
|
|
|
10
9
|
let notes = $state(data.notes);
|
|
11
|
-
let dialog = $state<HTMLDialogElement>();
|
|
12
10
|
</script>
|
|
13
11
|
|
|
14
12
|
<svelte:head>
|
|
@@ -18,7 +16,14 @@
|
|
|
18
16
|
<div class="notes-main">
|
|
19
17
|
<h1>Notes</h1>
|
|
20
18
|
<span>
|
|
21
|
-
<button
|
|
19
|
+
<button
|
|
20
|
+
class="icon-text"
|
|
21
|
+
onclick={async () => {
|
|
22
|
+
const result = await fetchAPI('PUT', 'users/:id/notes', { title: '' }, data.session.userId);
|
|
23
|
+
parseNote(result);
|
|
24
|
+
notes.push(result);
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
22
27
|
<Icon i="plus" /> New Note
|
|
23
28
|
</button>
|
|
24
29
|
</span>
|
|
@@ -29,26 +34,6 @@
|
|
|
29
34
|
</div>
|
|
30
35
|
</div>
|
|
31
36
|
|
|
32
|
-
<FormDialog
|
|
33
|
-
bind:dialog
|
|
34
|
-
submitText="Create Note"
|
|
35
|
-
submit={async rawInit => {
|
|
36
|
-
const init = NoteInit.parse(rawInit);
|
|
37
|
-
const result = await fetchAPI('PUT', 'users/:id/notes', init, data.session.userId);
|
|
38
|
-
parseNote(result);
|
|
39
|
-
notes.push(result);
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
<div>
|
|
43
|
-
<label for="name">Name</label>
|
|
44
|
-
<input name="name" type="text" required />
|
|
45
|
-
</div>
|
|
46
|
-
<div>
|
|
47
|
-
<label for="description">Description <span class="subtle">(optional)</span></label>
|
|
48
|
-
<input name="description" type="text" />
|
|
49
|
-
</div>
|
|
50
|
-
</FormDialog>
|
|
51
|
-
|
|
52
37
|
<style>
|
|
53
38
|
.notes-main {
|
|
54
39
|
padding: 2em;
|