@axium/core 0.20.2 → 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 +1 -0
- package/dist/api.d.ts +23 -18
- package/dist/api.js +6 -8
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +1 -0
- package/dist/io.js +5 -5
- package/dist/locales.d.ts +6 -0
- package/dist/locales.js +5 -0
- package/dist/node/packages.d.ts +1 -2
- package/dist/node/packages.js +3 -25
- package/dist/packages.d.ts +18 -1
- package/dist/packages.js +31 -1
- package/dist/preferences.d.ts +0 -1
- package/dist/preferences.js +2 -1
- package/dist/user.d.ts +1 -0
- package/dist/user.js +4 -1
- package/package.json +2 -1
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.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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>>;
|
|
@@ -59,6 +59,7 @@ declare const _API: {
|
|
|
59
59
|
}, z.core.$strip>;
|
|
60
60
|
id: z.ZodUUID;
|
|
61
61
|
userId: z.ZodUUID;
|
|
62
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
62
63
|
expires: z.ZodCoercedDate<unknown>;
|
|
63
64
|
created: z.ZodCoercedDate<unknown>;
|
|
64
65
|
elevated: z.ZodBoolean;
|
|
@@ -66,6 +67,7 @@ declare const _API: {
|
|
|
66
67
|
readonly DELETE: z.ZodObject<{
|
|
67
68
|
id: z.ZodUUID;
|
|
68
69
|
userId: z.ZodUUID;
|
|
70
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
71
|
expires: z.ZodCoercedDate<unknown>;
|
|
70
72
|
created: z.ZodCoercedDate<unknown>;
|
|
71
73
|
elevated: z.ZodBoolean;
|
|
@@ -207,6 +209,7 @@ declare const _API: {
|
|
|
207
209
|
sessions: z.ZodArray<z.ZodObject<{
|
|
208
210
|
id: z.ZodUUID;
|
|
209
211
|
userId: z.ZodUUID;
|
|
212
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
210
213
|
expires: z.ZodCoercedDate<unknown>;
|
|
211
214
|
created: z.ZodCoercedDate<unknown>;
|
|
212
215
|
elevated: z.ZodBoolean;
|
|
@@ -229,6 +232,7 @@ declare const _API: {
|
|
|
229
232
|
readonly 'users/:id/auth': {
|
|
230
233
|
readonly OPTIONS: [z.ZodObject<{
|
|
231
234
|
type: z.ZodLiteral<"login" | "action" | "client_login">;
|
|
235
|
+
client: z.ZodOptional<z.ZodString>;
|
|
232
236
|
}, z.core.$strip>, z.ZodObject<{
|
|
233
237
|
challenge: z.ZodBase64URL;
|
|
234
238
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
@@ -267,6 +271,7 @@ declare const _API: {
|
|
|
267
271
|
readonly GET: z.ZodArray<z.ZodObject<{
|
|
268
272
|
id: z.ZodUUID;
|
|
269
273
|
userId: z.ZodUUID;
|
|
274
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
270
275
|
expires: z.ZodCoercedDate<unknown>;
|
|
271
276
|
created: z.ZodCoercedDate<unknown>;
|
|
272
277
|
elevated: z.ZodBoolean;
|
|
@@ -277,6 +282,7 @@ declare const _API: {
|
|
|
277
282
|
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
278
283
|
id: z.ZodUUID;
|
|
279
284
|
userId: z.ZodUUID;
|
|
285
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
280
286
|
expires: z.ZodCoercedDate<unknown>;
|
|
281
287
|
created: z.ZodCoercedDate<unknown>;
|
|
282
288
|
elevated: z.ZodBoolean;
|
|
@@ -505,11 +511,11 @@ declare const _API: {
|
|
|
505
511
|
auditEvents: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
506
512
|
configFiles: z.ZodInt;
|
|
507
513
|
plugins: z.ZodInt;
|
|
508
|
-
versions: z.
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}, z.core.$strip
|
|
514
|
+
versions: z.ZodObject<{
|
|
515
|
+
core: z.ZodString;
|
|
516
|
+
client: z.ZodString;
|
|
517
|
+
server: z.ZodString;
|
|
518
|
+
}, z.core.$strip>;
|
|
513
519
|
}, z.core.$strip>;
|
|
514
520
|
};
|
|
515
521
|
readonly 'admin/users': {
|
|
@@ -589,10 +595,13 @@ declare const _API: {
|
|
|
589
595
|
};
|
|
590
596
|
readonly 'admin/plugins': {
|
|
591
597
|
readonly GET: z.ZodArray<z.ZodObject<{
|
|
592
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
593
598
|
name: z.ZodString;
|
|
599
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
600
|
+
cli: z.ZodOptional<z.ZodString>;
|
|
601
|
+
hooks: z.ZodOptional<z.ZodString>;
|
|
602
|
+
integrations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
603
|
+
}, z.core.$strip>>;
|
|
594
604
|
version: z.ZodString;
|
|
595
|
-
latest: z.ZodNullable<z.ZodString>;
|
|
596
605
|
cli: z.ZodOptional<z.ZodString>;
|
|
597
606
|
description: z.ZodOptional<z.ZodString>;
|
|
598
607
|
apps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -601,11 +610,6 @@ declare const _API: {
|
|
|
601
610
|
image: z.ZodOptional<z.ZodString>;
|
|
602
611
|
icon: z.ZodOptional<z.ZodString>;
|
|
603
612
|
}, z.core.$strip>>>;
|
|
604
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
605
|
-
cli: z.ZodOptional<z.ZodString>;
|
|
606
|
-
hooks: z.ZodOptional<z.ZodString>;
|
|
607
|
-
integrations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
608
|
-
}, z.core.$strip>>;
|
|
609
613
|
server: z.ZodOptional<z.ZodObject<{
|
|
610
614
|
cli: z.ZodOptional<z.ZodString>;
|
|
611
615
|
hooks: z.ZodOptional<z.ZodString>;
|
|
@@ -616,6 +620,7 @@ declare const _API: {
|
|
|
616
620
|
web_client_hooks: z.ZodOptional<z.ZodString>;
|
|
617
621
|
}, z.core.$strip>>;
|
|
618
622
|
update_checks: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
623
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
619
624
|
path: z.ZodString;
|
|
620
625
|
dirname: z.ZodString;
|
|
621
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.
|
|
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:
|
|
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/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
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);
|
package/dist/locales.js
ADDED
package/dist/node/packages.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
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
|
package/dist/node/packages.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import { findPackageJSON } from 'node:module';
|
|
3
|
-
import {
|
|
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
|
|
23
|
-
|
|
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
|
}
|
package/dist/packages.d.ts
CHANGED
|
@@ -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().
|
|
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
|
+
}
|
package/dist/preferences.d.ts
CHANGED
|
@@ -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>>>;
|
package/dist/preferences.js
CHANGED
|
@@ -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/dist/user.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export declare const UserRegistration: z.ZodObject<{
|
|
|
92
92
|
}, z.core.$strip>;
|
|
93
93
|
export declare const UserAuthOptions: z.ZodObject<{
|
|
94
94
|
type: z.ZodLiteral<"login" | "action" | "client_login">;
|
|
95
|
+
client: z.ZodOptional<z.ZodString>;
|
|
95
96
|
}, z.core.$strip>;
|
|
96
97
|
export type UserAuthOptions = z.infer<typeof UserAuthOptions>;
|
|
97
98
|
export declare const LogoutSessions: z.ZodObject<{
|
package/dist/user.js
CHANGED
|
@@ -60,7 +60,10 @@ export const UserRegistration = z.object({
|
|
|
60
60
|
userId: z.uuid(),
|
|
61
61
|
response: PasskeyRegistration,
|
|
62
62
|
});
|
|
63
|
-
export const UserAuthOptions = z.object({
|
|
63
|
+
export const UserAuthOptions = z.object({
|
|
64
|
+
type: z.literal(['login', 'action', 'client_login']),
|
|
65
|
+
client: z.string().max(200).optional(),
|
|
66
|
+
});
|
|
64
67
|
export const LogoutSessions = z.object({
|
|
65
68
|
id: z.array(z.uuid()).optional(),
|
|
66
69
|
confirm_all: z.boolean().optional(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/core",
|
|
3
|
-
"version": "0.
|
|
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"
|