@axium/core 0.17.0 → 0.18.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/api.d.ts +8 -1
- package/dist/api.js +9 -2
- package/dist/format.js +1 -1
- package/dist/node/plugins.js +0 -1
- package/dist/plugins.d.ts +30 -1
- package/dist/plugins.js +25 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -497,6 +497,7 @@ declare const _API: {
|
|
|
497
497
|
};
|
|
498
498
|
readonly 'admin/plugins': {
|
|
499
499
|
readonly GET: z.ZodArray<z.ZodObject<{
|
|
500
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
500
501
|
name: z.ZodString;
|
|
501
502
|
version: z.ZodString;
|
|
502
503
|
latest: z.ZodNullable<z.ZodString>;
|
|
@@ -520,6 +521,7 @@ declare const _API: {
|
|
|
520
521
|
http_handler: z.ZodOptional<z.ZodString>;
|
|
521
522
|
routes: z.ZodOptional<z.ZodString>;
|
|
522
523
|
db: z.ZodOptional<z.ZodString>;
|
|
524
|
+
web_client_hooks: z.ZodOptional<z.ZodString>;
|
|
523
525
|
}, z.core.$strip>>;
|
|
524
526
|
update_checks: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
525
527
|
path: z.ZodString;
|
|
@@ -528,7 +530,12 @@ declare const _API: {
|
|
|
528
530
|
loadedBy: z.ZodString;
|
|
529
531
|
isServer: z.ZodBoolean;
|
|
530
532
|
_db: z.ZodOptional<z.ZodAny>;
|
|
531
|
-
|
|
533
|
+
_configPath: z.ZodOptional<z.ZodString>;
|
|
534
|
+
}, z.core.$loose>>;
|
|
535
|
+
readonly POST: [z.ZodObject<{
|
|
536
|
+
plugin: z.ZodString;
|
|
537
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
538
|
+
}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>];
|
|
532
539
|
};
|
|
533
540
|
readonly 'admin/audit/events': {
|
|
534
541
|
readonly OPTIONS: z.ZodUnion<[z.ZodObject<{
|
package/dist/api.js
CHANGED
|
@@ -5,7 +5,7 @@ import { AuditEvent, AuditFilter, Severity } from './audit.js';
|
|
|
5
5
|
import { NewSessionResponse, Session, Verification, VerificationInternal } from './auth.js';
|
|
6
6
|
import { PackageVersionInfo } from './packages.js';
|
|
7
7
|
import { Passkey, PasskeyAuthOptions, PasskeyAuthResponse, PasskeyChangeable, PasskeyCreationOptions, PasskeyRegistration, } from './passkeys.js';
|
|
8
|
-
import { PluginInternal } from './plugins.js';
|
|
8
|
+
import { PluginInternal, PluginUpdate } from './plugins.js';
|
|
9
9
|
import { LogoutSessions, User, UserAuthOptions, UserChangeable, UserPublic, UserRegistration, UserRegistrationInit } from './user.js';
|
|
10
10
|
export const AdminSummary = z.object({
|
|
11
11
|
users: z.number(),
|
|
@@ -93,7 +93,14 @@ const _API = {
|
|
|
93
93
|
}),
|
|
94
94
|
},
|
|
95
95
|
'admin/plugins': {
|
|
96
|
-
GET: z
|
|
96
|
+
GET: z
|
|
97
|
+
.looseObject({
|
|
98
|
+
...PluginInternal.omit({ _hooks: true, _client: true }).shape,
|
|
99
|
+
...PackageVersionInfo.shape,
|
|
100
|
+
config: z.record(z.string(), z.any()).optional(),
|
|
101
|
+
})
|
|
102
|
+
.array(),
|
|
103
|
+
POST: [PluginUpdate, z.object({})],
|
|
97
104
|
},
|
|
98
105
|
'admin/audit/events': {
|
|
99
106
|
OPTIONS: z.object({ name: z.string().array(), source: z.string().array(), tags: z.string().array() }).or(z.literal(false)),
|
package/dist/format.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function formatDateRange(date) {
|
|
2
2
|
const rawDays = (date.getTime() - Date.now()) / (24 * 3600_000);
|
|
3
3
|
const daysCount = Math.abs(rawDays);
|
|
4
|
-
const daysText =
|
|
4
|
+
const daysText = Math.round(daysCount);
|
|
5
5
|
const plural = daysCount == 1 ? '' : 's';
|
|
6
6
|
return `${date.toLocaleString()} (${rawDays >= 0 ? `in ${daysText} day${plural}` : `${daysText} day${plural} ago`})`;
|
|
7
7
|
}
|
package/dist/node/plugins.js
CHANGED
package/dist/plugins.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const PluginServerHooks: z.ZodObject<{
|
|
|
3
3
|
statusText: z.ZodOptional<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<readonly [], null>, z.ZodString>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<readonly [], null>, z.ZodString>>>;
|
|
4
4
|
remove: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
5
5
|
clean: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
6
|
+
load: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
6
7
|
}, z.core.$strip>;
|
|
7
8
|
interface _InitOptions {
|
|
8
9
|
force?: boolean;
|
|
@@ -15,6 +16,7 @@ export interface ServerHooks {
|
|
|
15
16
|
force?: boolean;
|
|
16
17
|
}) => void | Promise<void>;
|
|
17
18
|
clean?: (opt: Partial<_InitOptions>) => void | Promise<void>;
|
|
19
|
+
load?(): void | Promise<void>;
|
|
18
20
|
}
|
|
19
21
|
export interface ClientHooks {
|
|
20
22
|
run(): void | Promise<void>;
|
|
@@ -41,9 +43,12 @@ export declare const Plugin: z.ZodObject<{
|
|
|
41
43
|
http_handler: z.ZodOptional<z.ZodString>;
|
|
42
44
|
routes: z.ZodOptional<z.ZodString>;
|
|
43
45
|
db: z.ZodOptional<z.ZodString>;
|
|
46
|
+
web_client_hooks: z.ZodOptional<z.ZodString>;
|
|
44
47
|
}, z.core.$strip>>;
|
|
45
48
|
/** If set Axium can check the npm registry for updates */
|
|
46
49
|
update_checks: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
50
|
+
/** In plugin's packages, this is the default. At runtime this is the loaded config */
|
|
51
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
47
52
|
}, z.core.$loose>;
|
|
48
53
|
export interface Plugin extends z.infer<typeof Plugin> {
|
|
49
54
|
}
|
|
@@ -57,10 +62,12 @@ export declare const PluginInfo: z.ZodObject<{
|
|
|
57
62
|
statusText: z.ZodOptional<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<readonly [], null>, z.ZodString>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<readonly [], null>, z.ZodString>>>;
|
|
58
63
|
remove: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
59
64
|
clean: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
65
|
+
load: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
60
66
|
}, z.core.$strip>>;
|
|
61
67
|
_client: z.ZodOptional<z.ZodAny>;
|
|
62
68
|
isServer: z.ZodBoolean;
|
|
63
69
|
_db: z.ZodOptional<z.ZodAny>;
|
|
70
|
+
_configPath: z.ZodOptional<z.ZodString>;
|
|
64
71
|
}, z.core.$strip>;
|
|
65
72
|
export interface PluginInfo extends z.infer<typeof PluginInfo> {
|
|
66
73
|
}
|
|
@@ -74,10 +81,12 @@ export declare const PluginInternal: z.ZodObject<{
|
|
|
74
81
|
statusText: z.ZodOptional<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<readonly [], null>, z.ZodString>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<readonly [], null>, z.ZodString>>>;
|
|
75
82
|
remove: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
76
83
|
clean: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
84
|
+
load: z.ZodOptional<z.ZodCustom<(...args: any[]) => any, (...args: any[]) => any>>;
|
|
77
85
|
}, z.core.$strip>>;
|
|
78
86
|
_client: z.ZodOptional<z.ZodAny>;
|
|
79
87
|
isServer: z.ZodBoolean;
|
|
80
88
|
_db: z.ZodOptional<z.ZodAny>;
|
|
89
|
+
_configPath: z.ZodOptional<z.ZodString>;
|
|
81
90
|
name: z.ZodString;
|
|
82
91
|
version: z.ZodString;
|
|
83
92
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -99,11 +108,14 @@ export declare const PluginInternal: z.ZodObject<{
|
|
|
99
108
|
http_handler: z.ZodOptional<z.ZodString>;
|
|
100
109
|
routes: z.ZodOptional<z.ZodString>;
|
|
101
110
|
db: z.ZodOptional<z.ZodString>;
|
|
111
|
+
web_client_hooks: z.ZodOptional<z.ZodString>;
|
|
102
112
|
}, z.core.$strip>>;
|
|
103
113
|
/** If set Axium can check the npm registry for updates */
|
|
104
114
|
update_checks: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
115
|
+
/** In plugin's packages, this is the default. At runtime this is the loaded config */
|
|
116
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
105
117
|
}, z.core.$loose>;
|
|
106
|
-
export interface PluginInternal extends Plugin,
|
|
118
|
+
export interface PluginInternal extends Plugin, PluginInfo {
|
|
107
119
|
}
|
|
108
120
|
export declare const plugins: Map<string, PluginInternal>;
|
|
109
121
|
/**
|
|
@@ -111,4 +123,21 @@ export declare const plugins: Map<string, PluginInternal>;
|
|
|
111
123
|
*/
|
|
112
124
|
export declare function _findPlugin(search: string): PluginInternal;
|
|
113
125
|
export declare function runIntegrations(): Promise<void>;
|
|
126
|
+
export interface $PluginConfigs {
|
|
127
|
+
}
|
|
128
|
+
interface PluginConfigData {
|
|
129
|
+
schema: z.ZodObject;
|
|
130
|
+
labels: Record<string, string>;
|
|
131
|
+
}
|
|
132
|
+
export declare const serverConfigs: Map<string, PluginConfigData>;
|
|
133
|
+
export declare function setServerConfig(pluginName: string, schema: z.ZodObject, labels?: Record<string, string>): void;
|
|
134
|
+
export declare function getConfig<T extends string>(pluginName: T): T extends keyof $PluginConfigs ? $PluginConfigs[T] : Record<string, unknown>;
|
|
135
|
+
export declare const PluginUpdate: z.ZodObject<{
|
|
136
|
+
plugin: z.ZodString;
|
|
137
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
/**
|
|
140
|
+
* Transforms a plugin name into a string suitable for use with file systems.
|
|
141
|
+
*/
|
|
142
|
+
export declare function toBaseName(pluginName: string): string;
|
|
114
143
|
export {};
|
package/dist/plugins.js
CHANGED
|
@@ -7,6 +7,7 @@ export const PluginServerHooks = z.object({
|
|
|
7
7
|
statusText: zAsyncFunction(z.function({ input: [], output: z.string() })).optional(),
|
|
8
8
|
remove: fn.optional(),
|
|
9
9
|
clean: fn.optional(),
|
|
10
|
+
load: fn.optional(),
|
|
10
11
|
});
|
|
11
12
|
const PluginCommon = z.object({
|
|
12
13
|
/** CLI mixin path */
|
|
@@ -27,9 +28,12 @@ export const Plugin = z.looseObject({
|
|
|
27
28
|
/** The path to the HTTP handler used by the server */
|
|
28
29
|
routes: z.string().optional(),
|
|
29
30
|
db: z.string().optional(),
|
|
31
|
+
web_client_hooks: z.string().optional(),
|
|
30
32
|
}).optional(),
|
|
31
33
|
/** If set Axium can check the npm registry for updates */
|
|
32
34
|
update_checks: z.boolean().nullish(),
|
|
35
|
+
/** In plugin's packages, this is the default. At runtime this is the loaded config */
|
|
36
|
+
config: z.record(z.string(), z.any()).optional(),
|
|
33
37
|
});
|
|
34
38
|
export const PluginInfo = z.object({
|
|
35
39
|
path: z.string(),
|
|
@@ -43,6 +47,7 @@ export const PluginInfo = z.object({
|
|
|
43
47
|
_client: z.any().optional(),
|
|
44
48
|
isServer: z.boolean(),
|
|
45
49
|
_db: z.any().optional(),
|
|
50
|
+
_configPath: z.string().optional(),
|
|
46
51
|
});
|
|
47
52
|
export const PluginInternal = z.looseObject({ ...Plugin.shape, ...PluginInfo.shape });
|
|
48
53
|
export const plugins = new Map();
|
|
@@ -71,3 +76,23 @@ export async function runIntegrations() {
|
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
}
|
|
79
|
+
export const serverConfigs = new Map();
|
|
80
|
+
export function setServerConfig(pluginName, schema, labels = {}) {
|
|
81
|
+
serverConfigs.set(pluginName, { schema, labels });
|
|
82
|
+
}
|
|
83
|
+
export function getConfig(pluginName) {
|
|
84
|
+
const plugin = _findPlugin(pluginName);
|
|
85
|
+
return plugin.config;
|
|
86
|
+
}
|
|
87
|
+
export const PluginUpdate = z.object({
|
|
88
|
+
plugin: z.string(),
|
|
89
|
+
config: z.record(z.string(), z.any()).optional(),
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Transforms a plugin name into a string suitable for use with file systems.
|
|
93
|
+
*/
|
|
94
|
+
export function toBaseName(pluginName) {
|
|
95
|
+
if (pluginName[0] == '@')
|
|
96
|
+
pluginName = pluginName.slice(1);
|
|
97
|
+
return pluginName.replaceAll('/', '_');
|
|
98
|
+
}
|