@axium/tasks 0.1.5 → 0.1.7

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
@@ -27,7 +27,7 @@ export interface TaskList extends TaskListInit {
27
27
  tasks?: Task[];
28
28
  }
29
29
  declare module '@axium/core/api' {
30
- interface _apiTypes {
30
+ interface $API {
31
31
  'users/:id/task_lists': {
32
32
  GET: WithRequired<TaskList, 'tasks'>[];
33
33
  PUT: [z.input<typeof TaskListInit>, TaskList];
@@ -1,7 +1,9 @@
1
1
  <script lang="ts">
2
2
  import { goto } from '$app/navigation';
3
- import { fetchAPI } from '@axium/client/requests';
3
+ import { page } from '$app/state';
4
+ import { copy } from '@axium/client/clipboard';
4
5
  import { Icon, Popover } from '@axium/client/components';
6
+ import { fetchAPI } from '@axium/client/requests';
5
7
  import type { Task, TaskList } from '@axium/tasks/common';
6
8
  import type { WithRequired } from 'utilium';
7
9
 
@@ -49,6 +51,11 @@
49
51
  >
50
52
  <Icon i="trash" /> Delete
51
53
  </div>
54
+ {#if page.data.session?.user.preferences.debug}
55
+ <div class="menu-item" onclick={() => copy('text/plain', root.id)}>
56
+ <Icon i="copy" --size="14px" /> Copy ID
57
+ </div>
58
+ {/if}
52
59
  </Popover>
53
60
  </div>
54
61
  {#each tasks.filter(task => task.parentId == root.id) as child}
@@ -91,6 +98,11 @@
91
98
  <Icon i="arrow-up-right-from-square" /> Open in New Tab
92
99
  </div>
93
100
  {/if}
101
+ {#if page.data.session?.user.preferences.debug}
102
+ <div class="menu-item" onclick={() => copy('text/plain', list.id)}>
103
+ <Icon i="copy" --size="14px" /> Copy ID
104
+ </div>
105
+ {/if}
94
106
  </Popover>
95
107
  </div>
96
108
  <div>
package/lib/tsconfig.json CHANGED
@@ -4,7 +4,8 @@
4
4
  "rootDir": "..",
5
5
  "noEmit": true,
6
6
  "module": "preserve",
7
- "moduleResolution": "Bundler"
7
+ "moduleResolution": "Bundler",
8
+ "types": ["@sveltejs/kit"]
8
9
  },
9
10
  "include": ["**/*.svelte", "**/*.ts"],
10
11
  "exclude": [],
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@axium/tasks",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
- "description": "",
5
+ "description": "Tasks for Axium",
6
6
  "funding": {
7
7
  "type": "individual",
8
8
  "url": "https://github.com/sponsors/james-pre"
@@ -35,8 +35,8 @@
35
35
  "build": "tsc"
36
36
  },
37
37
  "peerDependencies": {
38
- "@axium/client": ">=0.2.0",
39
- "@axium/core": ">=0.5.4",
38
+ "@axium/client": ">=0.4.0",
39
+ "@axium/core": ">=0.6.0",
40
40
  "@axium/server": ">=0.22.0",
41
41
  "@sveltejs/kit": "^2.27.3",
42
42
  "utilium": "^2.3.8"
@@ -0,0 +1,10 @@
1
+ import { getCurrentSession } from '@axium/client/user';
2
+ import type { Session } from '@axium/core';
3
+
4
+ export async function load({ parent, url }) {
5
+ let { session }: { session?: Session | null } = await parent();
6
+
7
+ session ||= await getCurrentSession().catch(() => null);
8
+
9
+ return { session };
10
+ }
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
- import { fetchAPI } from '@axium/client/requests';
3
2
  import { FormDialog, Icon } from '@axium/client/components';
3
+ import { fetchAPI } from '@axium/client/requests';
4
4
  import { parseList } from '@axium/tasks/client';
5
5
  import { TaskListInit } from '@axium/tasks/common';
6
6
  import { TaskList } from '@axium/tasks/components';
@@ -34,7 +34,7 @@
34
34
  submitText="Create List"
35
35
  submit={async rawInit => {
36
36
  const init = TaskListInit.parse(rawInit);
37
- const result = await fetchAPI('PUT', 'users/:id/task_lists', init, data.session.userId);
37
+ const result = await fetchAPI('PUT', 'users/:id/task_lists', init, data.session!.userId);
38
38
  parseList(result);
39
39
  lists.push(Object.assign(result, { tasks: [] }));
40
40
  }}
@@ -1,19 +1,17 @@
1
1
  import { fetchAPI } from '@axium/client/requests';
2
- import { getCurrentSession } from '@axium/client/user';
3
- import type { Session } from '@axium/core';
4
2
  import { parseList } from '@axium/tasks/client';
5
- import type { LoadEvent } from '@sveltejs/kit';
3
+ import { redirect } from '@sveltejs/kit';
6
4
 
7
5
  export const ssr = false;
8
6
 
9
- export async function load({ parent }: LoadEvent) {
10
- let { session }: { session?: Session } = await parent();
7
+ export async function load({ parent }) {
8
+ const { session } = await parent();
11
9
 
12
- session ||= await getCurrentSession();
10
+ if (!session) redirect(307, '/login?after=/tasks');
13
11
 
14
12
  const lists = await fetchAPI('GET', 'users/:id/task_lists', {}, session.userId);
15
13
 
16
14
  for (const list of lists) parseList(list);
17
15
 
18
- return { lists, session };
16
+ return { lists };
19
17
  }