@axium/tasks 0.2.2 → 0.2.3

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.
@@ -0,0 +1,6 @@
1
+ import './common.js';
2
+ import './server.js';
3
+ export declare function statusText(): Promise<string>;
4
+ export declare function db_init(): Promise<void>;
5
+ export declare function db_wipe(): Promise<void>;
6
+ export declare function remove(): Promise<void>;
@@ -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 { tasks, task_lists } = await count('tasks', 'task_lists');
10
9
  return `${tasks} tasks, ${task_lists} lists`;
11
10
  }
12
- async function db_init() {
11
+ export async function db_init() {
13
12
  start('Creating table task_lists');
14
13
  await database.schema
15
14
  .createTable('task_lists')
@@ -41,22 +40,17 @@ async function db_init() {
41
40
  await createIndex('tasks', 'listId');
42
41
  await createIndex('tasks', 'parentId');
43
42
  }
44
- async function db_wipe() {
43
+ export async function db_wipe() {
45
44
  start('Wiping data from tasks');
46
45
  await database.deleteFrom('tasks').execute().then(done);
47
46
  start('Wiping data from task_lists');
48
47
  await database.deleteFrom('task_lists').execute().then(done);
49
48
  await acl.wipeTable('task_lists');
50
49
  }
51
- async function remove() {
50
+ export async function remove() {
52
51
  start('Dropping table tasks');
53
52
  await database.schema.dropTable('tasks').execute().then(done);
54
53
  start('Dropping table task_lists');
55
54
  await database.schema.dropTable('task_lists').execute().then(done);
56
55
  await acl.dropTable('task_lists');
57
56
  }
58
- export default {
59
- ...pkg,
60
- statusText,
61
- hooks: { db_init, db_wipe, remove },
62
- };
package/dist/server.js CHANGED
@@ -27,9 +27,9 @@ expectedTypes.task_lists = {
27
27
  addRoute({
28
28
  path: '/api/users/:id/task_lists',
29
29
  params: { id: z.uuid() },
30
- async GET(event) {
31
- const userId = event.params.id;
32
- await checkAuthForUser(event, userId);
30
+ async GET(request, params) {
31
+ const userId = params.id;
32
+ await checkAuthForUser(request, userId);
33
33
  const lists = await database
34
34
  .selectFrom('task_lists')
35
35
  .selectAll()
@@ -42,10 +42,10 @@ addRoute({
42
42
  tasks: list.tasks.map(t => ({ ...t, created: new Date(t.created), due: t.due ? new Date(t.due) : null })),
43
43
  }));
44
44
  },
45
- async PUT(event) {
46
- const init = await parseBody(event, TaskListInit);
47
- const userId = event.params.id;
48
- await checkAuthForUser(event, userId);
45
+ async PUT(request, params) {
46
+ const init = await parseBody(request, TaskListInit);
47
+ const userId = params.id;
48
+ await checkAuthForUser(request, userId);
49
49
  return await database
50
50
  .insertInto('task_lists')
51
51
  .values({ ...init, userId })
@@ -57,9 +57,9 @@ addRoute({
57
57
  addRoute({
58
58
  path: '/api/task_lists/:id',
59
59
  params: { id: z.uuid() },
60
- async GET(event) {
61
- const id = event.params.id;
62
- const { item } = await checkAuthForItem(event, 'task_lists', id, Permission.Read);
60
+ async GET(request, params) {
61
+ const id = params.id;
62
+ const { item } = await checkAuthForItem(request, 'task_lists', id, Permission.Read);
63
63
  const tasks = await database
64
64
  .selectFrom('tasks')
65
65
  .selectAll()
@@ -68,10 +68,10 @@ addRoute({
68
68
  .catch(withError('Could not get tasks'));
69
69
  return Object.assign(item, { tasks });
70
70
  },
71
- async PUT(event) {
72
- const listId = event.params.id;
73
- const init = await parseBody(event, TaskInit.omit({ listId: true }));
74
- await checkAuthForItem(event, 'task_lists', listId, Permission.Edit);
71
+ async PUT(request, params) {
72
+ const listId = params.id;
73
+ const init = await parseBody(request, TaskInit.omit({ listId: true }));
74
+ await checkAuthForItem(request, 'task_lists', listId, Permission.Edit);
75
75
  return await database
76
76
  .insertInto('tasks')
77
77
  .values({ summary: '', ...init, listId })
@@ -79,10 +79,10 @@ addRoute({
79
79
  .executeTakeFirstOrThrow()
80
80
  .catch(withError('Could not update task list'));
81
81
  },
82
- async PATCH(event) {
83
- const id = event.params.id;
84
- await checkAuthForItem(event, 'task_lists', id, Permission.Edit);
85
- const init = await parseBody(event, TaskListInit);
82
+ async PATCH(request, params) {
83
+ const id = params.id;
84
+ await checkAuthForItem(request, 'task_lists', id, Permission.Edit);
85
+ const init = await parseBody(request, TaskListInit);
86
86
  return await database
87
87
  .updateTable('task_lists')
88
88
  .set(init)
@@ -91,10 +91,10 @@ addRoute({
91
91
  .executeTakeFirstOrThrow()
92
92
  .catch(withError('Could not update task list'));
93
93
  },
94
- async POST(event) {
95
- const body = await parseBody(event, TaskListUpdate);
96
- const id = event.params.id;
97
- await checkAuthForItem(event, 'task_lists', id, Permission.Edit);
94
+ async POST(request, params) {
95
+ const body = await parseBody(request, TaskListUpdate);
96
+ const id = params.id;
97
+ await checkAuthForItem(request, 'task_lists', id, Permission.Edit);
98
98
  if (typeof body.all_completed == 'boolean') {
99
99
  await database
100
100
  .updateTable('tasks')
@@ -107,9 +107,9 @@ addRoute({
107
107
  }
108
108
  return {};
109
109
  },
110
- async DELETE(event) {
111
- const id = event.params.id;
112
- await checkAuthForItem(event, 'task_lists', id, Permission.Manage);
110
+ async DELETE(request, params) {
111
+ const id = params.id;
112
+ await checkAuthForItem(request, 'task_lists', id, Permission.Manage);
113
113
  return await database
114
114
  .deleteFrom('task_lists')
115
115
  .where('id', '=', id)
@@ -121,16 +121,16 @@ addRoute({
121
121
  addRoute({
122
122
  path: '/api/tasks/:id',
123
123
  params: { id: z.uuid() },
124
- async PATCH(event) {
125
- const init = await parseBody(event, TaskInit.omit({ listId: true }));
126
- const id = event.params.id;
124
+ async PATCH(request, params) {
125
+ const init = await parseBody(request, TaskInit.omit({ listId: true }));
126
+ const id = params.id;
127
127
  const task = await database
128
128
  .selectFrom('tasks')
129
129
  .select('listId')
130
130
  .where('id', '=', id)
131
131
  .executeTakeFirstOrThrow()
132
132
  .catch(withError('Could not get task'));
133
- await checkAuthForItem(event, 'task_lists', task.listId, Permission.Edit);
133
+ await checkAuthForItem(request, 'task_lists', task.listId, Permission.Edit);
134
134
  return await database
135
135
  .updateTable('tasks')
136
136
  .set(init)
@@ -139,15 +139,15 @@ addRoute({
139
139
  .executeTakeFirstOrThrow()
140
140
  .catch(withError('Could not update task'));
141
141
  },
142
- async DELETE(event) {
143
- const id = event.params.id;
142
+ async DELETE(request, params) {
143
+ const id = params.id;
144
144
  const task = await database
145
145
  .selectFrom('tasks')
146
146
  .select('listId')
147
147
  .where('id', '=', id)
148
148
  .executeTakeFirstOrThrow()
149
149
  .catch(withError('Could not fetch task'));
150
- await checkAuthForItem(event, 'task_lists', task.listId, Permission.Manage);
150
+ await checkAuthForItem(request, 'task_lists', task.listId, Permission.Manage);
151
151
  return await database
152
152
  .deleteFrom('tasks')
153
153
  .where('id', '=', id)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@axium/tasks",
3
- "version": "0.2.2",
4
- "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
3
+ "version": "0.2.3",
4
+ "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "Tasks 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.4.0",
39
- "@axium/core": ">=0.7.0",
40
- "@axium/server": ">=0.23.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.3.8"
43
42
  },
44
43
  "dependencies": {
45
44
  "zod": "^4.0.5"
46
45
  },
47
- "apps": [
48
- {
49
- "id": "tasks",
50
- "name": "Tasks",
51
- "icon": "list-check"
52
- }
53
- ]
46
+ "axium": {
47
+ "routes": "routes",
48
+ "hooks": "./dist/hooks.js",
49
+ "apps": [
50
+ {
51
+ "id": "tasks",
52
+ "name": "Tasks",
53
+ "icon": "list-check"
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;