@axium/client 0.9.9 → 0.9.10

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.
@@ -10,7 +10,9 @@ export declare function session(): {
10
10
  id: string;
11
11
  name: string;
12
12
  email: string;
13
- preferences: Record<string, any>;
13
+ preferences: {
14
+ debug: boolean;
15
+ };
14
16
  roles: string[];
15
17
  registeredAt: Date;
16
18
  isAdmin: boolean;
@@ -3,7 +3,6 @@ import { loadPlugin } from '@axium/core/node/plugins';
3
3
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
4
  import { homedir } from 'node:os';
5
5
  import { join } from 'node:path/posix';
6
- import * as z from 'zod';
7
6
  import { ClientConfig, config } from '../config.js';
8
7
  import { fetchAPI, setPrefix, setToken } from '../requests.js';
9
8
  import { getCurrentSession } from '../user.js';
@@ -32,14 +31,7 @@ export async function loadConfig(safe) {
32
31
  await loadPlugin('client', plugin, axcConfig, safe);
33
32
  }
34
33
  catch (e) {
35
- io.warn('Failed to load config: ' +
36
- (e instanceof z.core.$ZodError
37
- ? z.prettifyError(e)
38
- : e instanceof Error
39
- ? io._debugOutput
40
- ? e.stack
41
- : e.message
42
- : String(e)));
34
+ io.warn('Failed to load config: ' + io.errorText(e));
43
35
  }
44
36
  }
45
37
  export function saveConfig() {
@@ -51,7 +43,7 @@ export async function updateCache(force) {
51
43
  if (!force && config.cache && config.cache.fetched + _dayMs > Date.now())
52
44
  return;
53
45
  io.start('Fetching metadata');
54
- const [session, apps] = await Promise.all([getCurrentSession(), fetchAPI('GET', 'apps')]).catch(err => io.exit(err.message));
46
+ const [session, apps] = await Promise.all([getCurrentSession(), fetchAPI('GET', 'apps')]).catch(io.exit);
55
47
  try {
56
48
  config.cache = { fetched: Date.now(), session, apps };
57
49
  saveConfig();
package/dist/cli/index.js CHANGED
@@ -51,7 +51,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
51
51
  var e = new Error(message);
52
52
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
53
53
  });
54
- import { outputDaemonStatus, io, pluginText } from '@axium/core/node';
54
+ import { io, outputDaemonStatus, pluginText } from '@axium/core/node';
55
55
  import { _findPlugin, plugins } from '@axium/core/plugins';
56
56
  import { program } from 'commander';
57
57
  import { createServer } from 'node:http';
@@ -88,17 +88,17 @@ try {
88
88
  .configureHelp({ showGlobalOptions: true })
89
89
  .option('--debug', 'override debug mode')
90
90
  .option('--no-debug', 'override debug mode')
91
- .option('--refresh-session', 'Force a refresh of session and user metadata from server')
92
- .option('--cache-only', 'Run entirely from local cache, even if it is expired.')
93
- .option('--safe', 'do not execute code from plugins');
94
- program.on('option:debug', () => io._setDebugOutput(true));
95
- program.hook('preAction', async (_, action) => {
96
- const opt = action.optsWithGlobals();
91
+ .option('--refresh-session', 'Force a refresh of session and user metadata from server', false)
92
+ .option('--cache-only', 'Run entirely from local cache, even if it is expired.', false)
93
+ .option('--safe', 'do not execute code from plugins', false)
94
+ .hook('preAction', async (axc, action) => {
95
+ const opt = axc.optsWithGlobals();
97
96
  if (!config.token)
98
97
  return;
99
98
  if (!opt.cacheOnly && action.name() != 'login')
100
99
  await updateCache(opt.refreshSession);
101
100
  });
101
+ program.on('option:debug', () => io._setDebugOutput(true));
102
102
  program
103
103
  .command('login')
104
104
  .description('Log in to your account on an Axium server')
@@ -202,7 +202,7 @@ try {
202
202
  .description('List loaded plugins')
203
203
  .option('-l, --long', 'use the long listing format')
204
204
  .option('--no-versions', 'do not show plugin versions')
205
- .action((opt) => {
205
+ .action(opt => {
206
206
  if (!plugins.size) {
207
207
  console.log('No plugins loaded.');
208
208
  return;
package/dist/config.d.ts CHANGED
@@ -16,7 +16,9 @@ export declare const ClientConfig: z.ZodObject<{
16
16
  email: z.ZodEmail;
17
17
  emailVerified: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
18
18
  image: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
19
- preferences: z.ZodRecord<z.ZodString, z.ZodAny>;
19
+ preferences: z.ZodObject<{
20
+ debug: z.ZodBoolean;
21
+ }, z.core.$strip>;
20
22
  roles: z.ZodArray<z.ZodString>;
21
23
  registeredAt: z.ZodCoercedDate<unknown>;
22
24
  isAdmin: z.ZodBoolean;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { preferenceLabels, preferenceSchemas, type PreferenceName, type Preferences } from '@axium/core';
2
+ import { preferenceLabels, Preferences } from '@axium/core';
3
3
  import Preference from './Preference.svelte';
4
4
 
5
5
  interface Props {
@@ -11,10 +11,10 @@
11
11
  const id = $props.id();
12
12
  </script>
13
13
 
14
- {#each Object.keys(preferenceSchemas) as PreferenceName[] as path}
14
+ {#each Object.keys(Preferences.shape) as (keyof Preferences)[] as path}
15
15
  <div class="pref">
16
16
  <label for={id}>{preferenceLabels[path]}</label>
17
- <Preference {userId} bind:preferences {path} schema={preferenceSchemas[path]} />
17
+ <Preference {userId} bind:preferences {path} schema={Preferences.shape[path]} />
18
18
  </div>
19
19
  {/each}
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/client",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "author": "James Prevett <jp@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -40,7 +40,7 @@
40
40
  "build": "tsc"
41
41
  },
42
42
  "peerDependencies": {
43
- "@axium/core": ">=0.12.0",
43
+ "@axium/core": ">=0.15.0",
44
44
  "utilium": "^2.3.8",
45
45
  "zod": "^4.0.5",
46
46
  "svelte": "^5.36.0"