@axium/notes 0.2.5 → 0.3.0

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 CHANGED
@@ -6,22 +6,79 @@ export declare const NoteInit: z.ZodObject<{
6
6
  }, z.core.$strip>;
7
7
  export interface NoteInit extends z.infer<typeof NoteInit> {
8
8
  }
9
- export interface Note extends z.infer<typeof NoteInit> {
10
- id: string;
11
- userId: string;
12
- created: Date;
13
- modified: Date;
9
+ export declare const Note: z.ZodObject<{
10
+ title: z.ZodString;
11
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
13
+ id: z.ZodUUID;
14
+ userId: z.ZodUUID;
15
+ created: z.ZodCoercedDate<unknown>;
16
+ modified: z.ZodCoercedDate<unknown>;
17
+ }, z.core.$strip>;
18
+ export interface Note extends z.infer<typeof Note> {
14
19
  }
20
+ declare const NotesAPI: {
21
+ readonly 'users/:id/notes': {
22
+ readonly GET: z.ZodArray<z.ZodObject<{
23
+ title: z.ZodString;
24
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
26
+ id: z.ZodUUID;
27
+ userId: z.ZodUUID;
28
+ created: z.ZodCoercedDate<unknown>;
29
+ modified: z.ZodCoercedDate<unknown>;
30
+ }, z.core.$strip>>;
31
+ readonly PUT: readonly [z.ZodObject<{
32
+ title: z.ZodString;
33
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
35
+ }, z.core.$strip>, z.ZodObject<{
36
+ title: z.ZodString;
37
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
39
+ id: z.ZodUUID;
40
+ userId: z.ZodUUID;
41
+ created: z.ZodCoercedDate<unknown>;
42
+ modified: z.ZodCoercedDate<unknown>;
43
+ }, z.core.$strip>];
44
+ };
45
+ readonly 'notes/:id': {
46
+ readonly GET: z.ZodObject<{
47
+ title: z.ZodString;
48
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
50
+ id: z.ZodUUID;
51
+ userId: z.ZodUUID;
52
+ created: z.ZodCoercedDate<unknown>;
53
+ modified: z.ZodCoercedDate<unknown>;
54
+ }, z.core.$strip>;
55
+ readonly PATCH: readonly [z.ZodObject<{
56
+ title: z.ZodString;
57
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
59
+ }, z.core.$strip>, z.ZodObject<{
60
+ title: z.ZodString;
61
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
62
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
63
+ id: z.ZodUUID;
64
+ userId: z.ZodUUID;
65
+ created: z.ZodCoercedDate<unknown>;
66
+ modified: z.ZodCoercedDate<unknown>;
67
+ }, z.core.$strip>];
68
+ readonly DELETE: z.ZodObject<{
69
+ title: z.ZodString;
70
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
72
+ id: z.ZodUUID;
73
+ userId: z.ZodUUID;
74
+ created: z.ZodCoercedDate<unknown>;
75
+ modified: z.ZodCoercedDate<unknown>;
76
+ }, z.core.$strip>;
77
+ };
78
+ };
79
+ type NotesAPI = typeof NotesAPI;
15
80
  declare module '@axium/core/api' {
16
- interface $API {
17
- 'users/:id/notes': {
18
- GET: Note[];
19
- PUT: [z.input<typeof NoteInit>, Note];
20
- };
21
- 'notes/:id': {
22
- GET: Note;
23
- PATCH: [z.input<typeof NoteInit>, Note];
24
- DELETE: Note;
25
- };
81
+ interface $API extends NotesAPI {
26
82
  }
27
83
  }
84
+ export {};
package/dist/common.js CHANGED
@@ -1,6 +1,25 @@
1
+ import { $API } from '@axium/core/api';
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
7
  });
8
+ export const Note = NoteInit.extend({
9
+ id: z.uuid(),
10
+ userId: z.uuid(),
11
+ created: z.coerce.date(),
12
+ modified: z.coerce.date(),
13
+ });
14
+ const NotesAPI = {
15
+ 'users/:id/notes': {
16
+ GET: Note.array(),
17
+ PUT: [NoteInit, Note],
18
+ },
19
+ 'notes/:id': {
20
+ GET: Note,
21
+ PATCH: [NoteInit, Note],
22
+ DELETE: Note,
23
+ },
24
+ };
25
+ Object.assign($API, NotesAPI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/notes",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "Notes for Axium",
6
6
  "funding": {
@@ -35,8 +35,8 @@
35
35
  "build": "tsc"
36
36
  },
37
37
  "peerDependencies": {
38
- "@axium/client": ">=0.9.6",
39
- "@axium/core": ">=0.12.0",
38
+ "@axium/client": ">=0.11.0",
39
+ "@axium/core": ">=0.17.0",
40
40
  "@axium/server": ">=0.28.0",
41
41
  "@sveltejs/kit": "^2.27.3",
42
42
  "utilium": "^2.4.0"
@@ -0,0 +1 @@
1
+ import '@axium/notes/common';
@@ -1,5 +1,4 @@
1
1
  import { fetchAPI } from '@axium/client/requests';
2
- import { parseNote } from '@axium/notes/client';
3
2
  import { redirect } from '@sveltejs/kit';
4
3
 
5
4
  export const ssr = false;
@@ -11,7 +10,5 @@ export async function load({ parent }) {
11
10
 
12
11
  const notes = await fetchAPI('GET', 'users/:id/notes', {}, session.userId);
13
12
 
14
- for (const note of notes) parseNote(note);
15
-
16
13
  return { notes, session };
17
14
  }
@@ -1,12 +1,9 @@
1
1
  import { fetchAPI } from '@axium/client/requests';
2
- import { parseNote } from '@axium/notes/client';
3
2
 
4
3
  export const ssr = false;
5
4
 
6
5
  export async function load({ params }) {
7
6
  const note = await fetchAPI('GET', 'notes/:id', {}, params.id!);
8
7
 
9
- parseNote(note);
10
-
11
8
  return { note };
12
9
  }
package/dist/client.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Note } from './common.js';
2
- export declare function parseNote<const T extends Note>(note: T): T;
package/dist/client.js DELETED
@@ -1,5 +0,0 @@
1
- export function parseNote(note) {
2
- note.created = new Date(note.created);
3
- note.modified = new Date(note.modified);
4
- return note;
5
- }