@axium/tasks 0.5.0 → 0.5.2

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/db.json CHANGED
@@ -71,6 +71,21 @@
71
71
  }
72
72
  }
73
73
  }
74
+ },
75
+ {
76
+ "delta": true,
77
+ "alter_tables": {
78
+ "task_lists": {
79
+ "add_triggers": {
80
+ "sync_events": {
81
+ "forEach": "row",
82
+ "when": "after",
83
+ "events": ["insert", "update", "delete"],
84
+ "execute": "add_sync_event"
85
+ }
86
+ }
87
+ }
88
+ }
74
89
  }
75
90
  ],
76
91
  "wipe": ["task_lists", "tasks", "acl.task_lists"],
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type schema from '../db.json';
2
1
  import type { FromFile as FromSchemaFile } from '@axium/server/db/schema';
2
+ import type schema from '../db.json';
3
3
  declare module '@axium/server/database' {
4
4
  interface Schema extends FromSchemaFile<typeof schema> {
5
5
  }
package/dist/server.js CHANGED
@@ -3,24 +3,32 @@ import { authRequestForItem, checkAuthForUser } from '@axium/server/auth';
3
3
  import { database } from '@axium/server/database';
4
4
  import { parseBody, withError } from '@axium/server/requests';
5
5
  import { addRoute } from '@axium/server/routes';
6
+ import { addObjectType as addSyncObjectType } from '@axium/server/sync';
6
7
  import { jsonArrayFrom } from 'kysely/helpers/postgres';
7
8
  import * as z from 'zod';
8
9
  import { TaskInit, TaskListInit, TaskListUpdate } from './common.js';
10
+ function listExtraFields(user) {
11
+ return (eb) => [
12
+ jsonArrayFrom(eb.selectFrom('tasks').selectAll().whereRef('tasks.listId', '=', 'task_lists.id'))
13
+ .$castTo()
14
+ .as('tasks'),
15
+ acl.existsIn('task_lists', user)(eb).$castTo().as('isShared'),
16
+ ];
17
+ }
18
+ addSyncObjectType('task_lists', {
19
+ queryAdditions: (qb, user) => qb.select(listExtraFields(user)),
20
+ });
9
21
  addRoute({
10
22
  path: '/api/users/:id/task_lists',
11
23
  params: { id: z.uuid() },
12
24
  async GET(request, { id: userId }) {
13
25
  const { user } = await checkAuthForUser(request, userId);
14
- const shared = acl.existsIn('task_lists', user, { alias: 'list' });
15
26
  const lists = await database
16
- .selectFrom('task_lists as list')
17
- .selectAll('list')
18
- .select(eb => jsonArrayFrom(eb.selectFrom('tasks').selectAll().whereRef('tasks.listId', '=', 'list.id'))
19
- .$castTo()
20
- .as('tasks'))
21
- .select(acl.from('task_lists', { alias: 'list' }))
22
- .select(eb => shared(eb).$castTo().as('isShared'))
23
- .where(eb => eb.or([eb('userId', '=', userId), shared(eb)]))
27
+ .selectFrom('task_lists')
28
+ .selectAll()
29
+ .select(listExtraFields(user))
30
+ .select(acl.from('task_lists'))
31
+ .where(acl.userHasAccess('task_lists', user))
24
32
  .execute()
25
33
  .catch(withError('Could not get task lists'));
26
34
  return lists;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { goto } from '$app/navigation';
3
3
  import { page } from '$app/state';
4
- import { fetchAPI, getAppPreferences, text } from '@axium/client';
4
+ import { fetchAPI, preferences, text } from '@axium/client';
5
5
  import { AccessControlDialog, Icon, Popover } from '@axium/client/components';
6
6
  import { copy } from '@axium/client/gui';
7
7
  import { toastStatus } from '@axium/client/toast';
@@ -22,8 +22,8 @@
22
22
  let tasks = $state(list.tasks),
23
23
  open = $state(false);
24
24
 
25
- const preferences = await getAppPreferences(user.id, 'tasks');
26
- const showCompletedInline = preferences.show_completed_subtasks == 'inline';
25
+ const { show_completed_subtasks } = await preferences.get(user.id, 'tasks');
26
+ const showCompletedInline = show_completed_subtasks == 'inline';
27
27
 
28
28
  const tree = $derived(buildTaskTree(tasks));
29
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/tasks",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "Tasks for Axium",
6
6
  "funding": {
@@ -36,9 +36,9 @@
36
36
  "build": "tsc"
37
37
  },
38
38
  "peerDependencies": {
39
- "@axium/client": ">=0.20.0",
39
+ "@axium/client": ">=0.27.0",
40
40
  "@axium/core": ">=0.23.0",
41
- "@axium/server": ">=0.35.0",
41
+ "@axium/server": ">=0.47.0",
42
42
  "@sveltejs/kit": "^2.27.3",
43
43
  "kysely": "^0.28.15",
44
44
  "utilium": "^3.0.0"
@@ -75,6 +75,7 @@
75
75
  @media (width < 700px) {
76
76
  #tasks-main {
77
77
  padding: 1em;
78
+ padding-bottom: 5em;
78
79
  align-content: center;
79
80
  }
80
81