@axium/core 0.20.3 → 0.21.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/access.d.ts CHANGED
@@ -28,6 +28,7 @@ export declare function getTarget(ac: AccessControl): AccessTarget;
28
28
  export declare function fromTarget(target: AccessTarget): Partial<Pick<AccessControl, 'userId' | 'role' | 'tag'>>;
29
29
  export declare function pickPermissions<T extends AccessControl & object>(ac: T): Omit<T, 'itemId' | 'userId' | 'role' | 'tag' | 'user' | 'createdAt'>;
30
30
  export interface AccessControllable {
31
+ id: string;
31
32
  userId: string;
32
33
  parentId?: string | null;
33
34
  acl?: AccessControl[];
package/dist/api.d.ts CHANGED
@@ -8,11 +8,11 @@ export declare const AdminSummary: z.ZodObject<{
8
8
  auditEvents: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
9
9
  configFiles: z.ZodInt;
10
10
  plugins: z.ZodInt;
11
- versions: z.ZodRecord<z.ZodLiteral<"client" | "server" | "core">, z.ZodObject<{
12
- name: z.ZodString;
13
- version: z.ZodString;
14
- latest: z.ZodNullable<z.ZodString>;
15
- }, z.core.$strip>>;
11
+ versions: z.ZodObject<{
12
+ core: z.ZodString;
13
+ client: z.ZodString;
14
+ server: z.ZodString;
15
+ }, z.core.$strip>;
16
16
  }, z.core.$strip>;
17
17
  /**
18
18
  * Schemas for all API endpoints
@@ -24,7 +24,7 @@ declare const _API: {
24
24
  versions: z.ZodArray<z.ZodObject<{
25
25
  name: z.ZodString;
26
26
  version: z.ZodString;
27
- latest: z.ZodNullable<z.ZodString>;
27
+ latest: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
28
  }, z.core.$strip>>;
29
29
  routes: z.ZodRecord<z.ZodString, z.ZodObject<{
30
30
  params: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
@@ -511,11 +511,11 @@ declare const _API: {
511
511
  auditEvents: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
512
512
  configFiles: z.ZodInt;
513
513
  plugins: z.ZodInt;
514
- versions: z.ZodRecord<z.ZodLiteral<"client" | "server" | "core">, z.ZodObject<{
515
- name: z.ZodString;
516
- version: z.ZodString;
517
- latest: z.ZodNullable<z.ZodString>;
518
- }, z.core.$strip>>;
514
+ versions: z.ZodObject<{
515
+ core: z.ZodString;
516
+ client: z.ZodString;
517
+ server: z.ZodString;
518
+ }, z.core.$strip>;
519
519
  }, z.core.$strip>;
520
520
  };
521
521
  readonly 'admin/users': {
@@ -595,15 +595,13 @@ declare const _API: {
595
595
  };
596
596
  readonly 'admin/plugins': {
597
597
  readonly GET: z.ZodArray<z.ZodObject<{
598
- config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
599
598
  name: z.ZodString;
600
- version: z.ZodString;
601
- latest: z.ZodNullable<z.ZodString>;
602
599
  client: z.ZodOptional<z.ZodObject<{
603
600
  cli: z.ZodOptional<z.ZodString>;
604
601
  hooks: z.ZodOptional<z.ZodString>;
605
602
  integrations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
606
603
  }, z.core.$strip>>;
604
+ version: z.ZodString;
607
605
  cli: z.ZodOptional<z.ZodString>;
608
606
  description: z.ZodOptional<z.ZodString>;
609
607
  apps: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -622,6 +620,7 @@ declare const _API: {
622
620
  web_client_hooks: z.ZodOptional<z.ZodString>;
623
621
  }, z.core.$strip>>;
624
622
  update_checks: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
623
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
625
624
  path: z.ZodString;
626
625
  dirname: z.ZodString;
627
626
  specifier: z.ZodString;
package/dist/api.js CHANGED
@@ -14,7 +14,11 @@ export const AdminSummary = z.object({
14
14
  auditEvents: z.tuple(Array(Severity.Debug + 1).fill(z.int().nonnegative())),
15
15
  configFiles: z.int().nonnegative(),
16
16
  plugins: z.int().nonnegative(),
17
- versions: z.record(z.literal(['core', 'server', 'client']), PackageVersionInfo),
17
+ versions: z.object({
18
+ core: z.string(),
19
+ client: z.string(),
20
+ server: z.string(),
21
+ }),
18
22
  });
19
23
  /**
20
24
  * Schemas for all API endpoints
@@ -99,13 +103,7 @@ const _API = {
99
103
  }),
100
104
  },
101
105
  'admin/plugins': {
102
- GET: z
103
- .looseObject({
104
- ...PluginInternal.omit({ _hooks: true, _client: true }).shape,
105
- ...PackageVersionInfo.shape,
106
- config: z.record(z.string(), z.any()).optional(),
107
- })
108
- .array(),
106
+ GET: PluginInternal.omit({ _hooks: true, _client: true }).array(),
109
107
  POST: [PluginUpdate, z.object({})],
110
108
  },
111
109
  'admin/audit/events': {
package/dist/io.js CHANGED
@@ -25,11 +25,11 @@ export function useProgress(io) {
25
25
  done = io.done.bind(io);
26
26
  }
27
27
  // User-facing messaging
28
- export let debug;
29
- export let log;
30
- export let info;
31
- export let warn;
32
- export let error;
28
+ export let debug = console.debug;
29
+ export let log = console.log;
30
+ export let info = console.info;
31
+ export let warn = console.warn;
32
+ export let error = console.error;
33
33
  export function useOutput(output) {
34
34
  debug = output.debug.bind(output);
35
35
  log = output.log.bind(output);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Zod registry for attaching translation keys to schemas
3
+ */
4
+ export declare const zKeys: import("zod/v4/core").$ZodRegistry<{
5
+ key: string;
6
+ }, import("zod/v4/core").$ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>;
@@ -0,0 +1,5 @@
1
+ import { registry as zodRegistry } from 'zod/v4/core';
2
+ /**
3
+ * Zod registry for attaching translation keys to schemas
4
+ */
5
+ export const zKeys = zodRegistry();
@@ -1,5 +1,4 @@
1
- import type { PackageVersionInfo } from '../packages.js';
2
- export declare function setPackageCacheTTL(seconds: number): void;
1
+ import { type PackageVersionInfo } from '../packages.js';
3
2
  /**
4
3
  * @param name Package name
5
4
  * @param version The current/installed version
@@ -1,15 +1,6 @@
1
1
  import * as fs from 'node:fs';
2
2
  import { findPackageJSON } from 'node:module';
3
- import { lt as ltVersion } from 'semver';
4
- import { warn } from '../io.js';
5
- function isRelative(specifier) {
6
- return specifier[0] == '/' || ['.', '..'].includes(specifier.split('/')[0]);
7
- }
8
- let cacheTTL = 1000 * 60 * 60;
9
- export function setPackageCacheTTL(seconds) {
10
- cacheTTL = seconds * 1000;
11
- }
12
- const cache = new Map();
3
+ import { getPackage } from '../packages.js';
13
4
  /**
14
5
  * @param name Package name
15
6
  * @param version The current/installed version
@@ -19,19 +10,6 @@ export async function getVersionInfo(specifier, from = import.meta.filename) {
19
10
  if (!path)
20
11
  throw new Error(`Cannot find package.json for package ${specifier} (from ${from})`);
21
12
  const { version, name } = JSON.parse(fs.readFileSync(path, 'utf8'));
22
- const info = { name, version, latest: null };
23
- if (isRelative(specifier))
24
- return info;
25
- const cached = cache.get(specifier);
26
- const useCache = cached && Date.now() - cached.timestamp < cacheTTL;
27
- try {
28
- const pkg = useCache ? cached.data : await fetch('https://registry.npmjs.org/' + specifier).then(res => res.json());
29
- if (!useCache)
30
- cache.set(specifier, { timestamp: Date.now(), data: pkg });
31
- info.latest = pkg['dist-tags']?.latest || Object.keys(pkg.versions).sort((a, b) => (ltVersion(a, b) ? 1 : -1))[0];
32
- }
33
- catch (e) {
34
- warn(`Failed to fetch version info for package ${name}: ${e instanceof Error ? e.message : String(e)}`);
35
- }
36
- return info;
13
+ const pkg = await getPackage(name);
14
+ return { name, version, latest: pkg?._latest };
37
15
  }
@@ -2,7 +2,24 @@ import * as z from 'zod';
2
2
  export declare const PackageVersionInfo: z.ZodObject<{
3
3
  name: z.ZodString;
4
4
  version: z.ZodString;
5
- latest: z.ZodNullable<z.ZodString>;
5
+ latest: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
6
  }, z.core.$strip>;
7
7
  export interface PackageVersionInfo extends z.infer<typeof PackageVersionInfo> {
8
8
  }
9
+ export declare function isRelative(specifier: string): boolean;
10
+ interface NpmPackageVersion {
11
+ name: string;
12
+ version: string;
13
+ }
14
+ export interface NpmPackage {
15
+ name: string;
16
+ 'dist-tags': Record<string, string>;
17
+ versions: Record<string, NpmPackageVersion>;
18
+ _latest: string;
19
+ }
20
+ export declare function setPackageCacheTTL(seconds: number): void;
21
+ /**
22
+ * Get information for an npm package
23
+ */
24
+ export declare function getPackage(specifier: string): Promise<NpmPackage | null>;
25
+ export {};
package/dist/packages.js CHANGED
@@ -1,6 +1,36 @@
1
1
  import * as z from 'zod';
2
+ import { lt as ltVersion } from 'semver';
3
+ import { warn } from './io.js';
2
4
  export const PackageVersionInfo = z.object({
3
5
  name: z.string(),
4
6
  version: z.string(),
5
- latest: z.string().nullable(),
7
+ latest: z.string().nullish(),
6
8
  });
9
+ export function isRelative(specifier) {
10
+ return specifier[0] == '/' || ['.', '..'].includes(specifier.split('/')[0]);
11
+ }
12
+ let cacheTTL = 1000 * 60 * 60;
13
+ export function setPackageCacheTTL(seconds) {
14
+ cacheTTL = seconds * 1000;
15
+ }
16
+ const cache = new Map();
17
+ /**
18
+ * Get information for an npm package
19
+ */
20
+ export async function getPackage(specifier) {
21
+ if (isRelative(specifier))
22
+ return null;
23
+ const cached = cache.get(specifier);
24
+ if (cached && Date.now() - cached.timestamp < cacheTTL)
25
+ return cached.data;
26
+ try {
27
+ const pkg = await fetch('https://registry.npmjs.org/' + specifier).then(res => res.json());
28
+ pkg._latest = pkg['dist-tags']?.latest || Object.keys(pkg.versions).sort((a, b) => (ltVersion(a, b) ? 1 : -1))[0];
29
+ cache.set(specifier, { timestamp: Date.now(), data: pkg });
30
+ return pkg;
31
+ }
32
+ catch (e) {
33
+ warn(`Failed to fetch metadata for package ${specifier}: ${e instanceof Error ? e.message : String(e)}`);
34
+ return cached?.data || null;
35
+ }
36
+ }
@@ -1,5 +1,4 @@
1
1
  import * as z from 'zod';
2
- /** @internal Used so we can narrow using `type` and get access to type-specific properties (e.g. `ZodNumber.minValue`) */
3
2
  type StringFormatTypes = z.ZodGUID | z.ZodUUID | z.ZodEmail | z.ZodURL | z.ZodEmoji | z.ZodNanoID | z.ZodCUID | z.ZodCUID2 | z.ZodULID | z.ZodXID | z.ZodKSUID | z.ZodISODateTime | z.ZodISODate | z.ZodISOTime | z.ZodISODuration | z.ZodIPv4 | z.ZodIPv6 | z.ZodCIDRv4 | z.ZodCIDRv6 | z.ZodBase64 | z.ZodBase64URL | z.ZodE164 | z.ZodJWT;
4
3
  type ZodPrefPrimitive = z.ZodString | z.ZodNumber | z.ZodBigInt | z.ZodBoolean | z.ZodDate | z.ZodLiteral | z.ZodTemplateLiteral | z.ZodFile | z.ZodEnum | StringFormatTypes;
5
4
  type ZodPrefComposite = ZodPrefPrimitive | z.ZodNullable<ZodPrefPrimitive> | z.ZodOptional<ZodPrefPrimitive> | z.ZodDefault<ZodPrefPrimitive> | z.ZodArray<ZodPrefPrimitive> | z.ZodTuple<ZodPrefPrimitive[]> | z.ZodRecord<z.ZodString, ZodPrefPrimitive> | z.ZodObject<Readonly<Record<string, ZodPrefPrimitive>>>;
@@ -1,9 +1,10 @@
1
+ import { zKeys } from './locales.js';
1
2
  import * as z from 'zod';
2
3
  /**
3
4
  * @internal
4
5
  */
5
6
  export let Preferences = z.object({
6
- debug: z.boolean().default(false),
7
+ debug: z.boolean().default(false).register(zKeys, { key: 'preference.debug' }),
7
8
  });
8
9
  /**
9
10
  * @internal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/core",
3
- "version": "0.20.3",
3
+ "version": "0.21.0",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -19,6 +19,7 @@
19
19
  "main": "dist/index.js",
20
20
  "types": "dist/index.d.ts",
21
21
  "exports": {
22
+ "./package.json": "./package.json",
22
23
  ".": "./dist/index.js",
23
24
  "./*": "./dist/*.js",
24
25
  "./node": "./dist/node/index.js"