@kyro-cms/core 0.3.5 → 0.4.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/README.md +3 -3
- package/dist/api-handler.cjs +5 -5
- package/dist/api-handler.js +4 -4
- package/dist/{chunk-X3CU27OO.cjs → chunk-3FW6WVVP.cjs} +2 -17
- package/dist/chunk-3FW6WVVP.cjs.map +1 -0
- package/dist/{chunk-R4C4O4SE.cjs → chunk-3ZZPZYCM.cjs} +36 -61
- package/dist/chunk-3ZZPZYCM.cjs.map +1 -0
- package/dist/{chunk-Y3TM7WH7.js → chunk-C4JJEE42.js} +36 -61
- package/dist/chunk-C4JJEE42.js.map +1 -0
- package/dist/{chunk-2UOI5MUC.cjs → chunk-FWGHXRRI.cjs} +4 -4
- package/dist/{chunk-2UOI5MUC.cjs.map → chunk-FWGHXRRI.cjs.map} +1 -1
- package/dist/{chunk-DE7OQOMD.cjs → chunk-M4GFA2UQ.cjs} +19 -19
- package/dist/chunk-M4GFA2UQ.cjs.map +1 -0
- package/dist/{chunk-4UD44U4Z.js → chunk-OJBK3JYF.js} +18 -18
- package/dist/chunk-OJBK3JYF.js.map +1 -0
- package/dist/{chunk-5FTY2DLG.js → chunk-SAMZQVC2.js} +3 -3
- package/dist/{chunk-5FTY2DLG.js.map → chunk-SAMZQVC2.js.map} +1 -1
- package/dist/{chunk-RGIQKTZ7.js → chunk-YMG55RSX.js} +4 -18
- package/dist/chunk-YMG55RSX.js.map +1 -0
- package/dist/drizzle/index.cjs +10 -10
- package/dist/drizzle/index.js +2 -2
- package/dist/index.cjs +48 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -13
- package/dist/index.js.map +1 -1
- package/dist/rest/index.cjs +4 -4
- package/dist/rest/index.js +2 -2
- package/package.json +2 -14
- package/dist/WebhookService-118ZTFis.d.ts +0 -112
- package/dist/WebhookService-AefJfqX0.d.cts +0 -112
- package/dist/api-handler.d.cts +0 -9
- package/dist/api-handler.d.ts +0 -9
- package/dist/base-DvvNqnM-.d.cts +0 -73
- package/dist/base-eVegJ_Pr.d.ts +0 -73
- package/dist/chunk-4UD44U4Z.js.map +0 -1
- package/dist/chunk-DE7OQOMD.cjs.map +0 -1
- package/dist/chunk-R4C4O4SE.cjs.map +0 -1
- package/dist/chunk-RGIQKTZ7.js.map +0 -1
- package/dist/chunk-X3CU27OO.cjs.map +0 -1
- package/dist/chunk-Y3TM7WH7.js.map +0 -1
- package/dist/cli/index.d.cts +0 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/client.d.cts +0 -12
- package/dist/client.d.ts +0 -12
- package/dist/drizzle/index.d.cts +0 -135
- package/dist/drizzle/index.d.ts +0 -135
- package/dist/fields/index.d.cts +0 -27
- package/dist/fields/index.d.ts +0 -27
- package/dist/graphql/index.d.cts +0 -22
- package/dist/graphql/index.d.ts +0 -22
- package/dist/index-Bz9JqRGI.d.cts +0 -86
- package/dist/index-Bz9JqRGI.d.ts +0 -86
- package/dist/index-CLp-DRKA.d.ts +0 -64
- package/dist/index-DfO7G4kN.d.cts +0 -64
- package/dist/index.d.cts +0 -1363
- package/dist/index.d.ts +0 -1363
- package/dist/integration.d.cts +0 -27
- package/dist/integration.d.ts +0 -27
- package/dist/mongodb/index.d.cts +0 -63
- package/dist/mongodb/index.d.ts +0 -63
- package/dist/mysql-media-AI6YK767.cjs +0 -48
- package/dist/mysql-media-AI6YK767.cjs.map +0 -1
- package/dist/mysql-media-CDZUS7YX.js +0 -45
- package/dist/mysql-media-CDZUS7YX.js.map +0 -1
- package/dist/rest/index.d.cts +0 -57
- package/dist/rest/index.d.ts +0 -57
- package/dist/templates/index.d.cts +0 -59
- package/dist/templates/index.d.ts +0 -59
- package/dist/trpc/index.d.cts +0 -136
- package/dist/trpc/index.d.ts +0 -136
- package/dist/types-BnTm7oJG.d.cts +0 -130
- package/dist/types-BnTm7oJG.d.ts +0 -130
- package/dist/types-Bs1up4yP.d.ts +0 -461
- package/dist/types-J3R9nVsZ.d.cts +0 -461
- package/dist/types-VtjUxIMp.d.cts +0 -246
- package/dist/types-VtjUxIMp.d.ts +0 -246
- package/dist/ws/index.d.cts +0 -88
- package/dist/ws/index.d.ts +0 -88
package/dist/index.d.ts
DELETED
|
@@ -1,1363 +0,0 @@
|
|
|
1
|
-
import { KyroRouter } from './trpc/index.js';
|
|
2
|
-
export { createContext, createCountProcedure, createCreateProcedure, createDeleteProcedure, createDynamicRouter, createFindByIDProcedure, createFindProcedure, createKyroServer, createUpdateProcedure } from './trpc/index.js';
|
|
3
|
-
import * as graphql from 'graphql';
|
|
4
|
-
import * as hono from 'hono';
|
|
5
|
-
import * as hono_types from 'hono/types';
|
|
6
|
-
import { R as Registry } from './index-CLp-DRKA.js';
|
|
7
|
-
export { c as createRegistry, g as getRegistry, r as resetRegistry } from './index-CLp-DRKA.js';
|
|
8
|
-
import { B as BaseAdapter, K as KyroConfig, m as User, R as Request$1, C as CollectionConfig, G as GlobalConfig, F as FindArgs, b as FindResult, c as FindByIDArgs, d as CreateArgs, e as UpdateArgs, D as DeleteArgs, f as FindVersionsArgs, g as VersionRecord, h as CreateVersionArgs, i as DraftFindArgs, j as DraftSnapshot, k as DraftUpsertArgs, l as DraftDeleteArgs, H as Hook } from './types-Bs1up4yP.js';
|
|
9
|
-
export { n as AccessArgs, o as AccessControl, p as AdapterConfig, A as AdminConfig, a as AuthConfig, q as CollectionAccess, r as CollectionHooks, s as CreateResult, t as FieldAccess, u as FieldHooks, v as GlobalAccess, w as GlobalHooks, x as HookArgs, I as ImageSize, P as PluginConfig, U as UploadConfig, V as VersionConfig, W as WhereClause, y as evaluateAccess, z as getWhereClause, E as mergeWhereClauses, J as runFieldHooks, L as runHooks } from './types-Bs1up4yP.js';
|
|
10
|
-
import { KyroPubSub, KyroWSServer } from './ws/index.js';
|
|
11
|
-
export { PubSub, createWSServer } from './ws/index.js';
|
|
12
|
-
import { W as WebhookPayload, a as WebhookDelivery, b as WebhookConfig, c as WebhookService } from './WebhookService-118ZTFis.js';
|
|
13
|
-
export { A as ALL_WEBHOOK_EVENTS, C as CreateWebhookData, U as UpdateWebhookData, d as WEBHOOK_COLLECTION, e as WEBHOOK_DELIVERY_COLLECTION, f as WEBHOOK_EVENTS, g as WebhookEvent, h as WebhookTriggerResult, i as createWebhookService } from './WebhookService-118ZTFis.js';
|
|
14
|
-
import { F as Field } from './types-VtjUxIMp.js';
|
|
15
|
-
export { p as ALL_FIELD_TYPES, A as ArrayField, B as BaseField, a as Block, d as BlocksField, q as COMPLEX_FIELD_TYPES, C as CheckboxField, e as CodeField, f as CollapsibleField, g as ColorField, D as DateField, E as EmailField, h as FieldAdmin, i as FieldType, G as GroupField, I as ImageField, J as JSONField, L as LAYOUT_FIELD_TYPES, M as MarkdownField, N as NumberField, r as PRIMITIVE_FIELD_TYPES, P as PasswordField, s as RELATIONAL_FIELD_TYPES, R as RadioField, j as RelationshipField, k as RichTextBlock, l as RichTextField, m as RowField, S as SelectField, T as TabsField, n as TextField, o as TextareaField, U as UploadField, V as ValidateOptions, t as isArrayField, u as isBlocksField, v as isGroupField, w as isImageField, x as isLayoutField, y as isNumberField, z as isRelationshipField, H as isRichTextField, K as isSelectField, O as isTextField, Q as isUploadField } from './types-VtjUxIMp.js';
|
|
16
|
-
import { ZodTypeAny } from 'zod';
|
|
17
|
-
export { z } from 'zod';
|
|
18
|
-
export { createColumnsNode, normalizeRichTextDocument, normalizeRichTextValue, renderRichText, richTextStyles } from './fields/index.js';
|
|
19
|
-
import { A as AbstractBaseAdapter } from './base-eVegJ_Pr.js';
|
|
20
|
-
import { Dialect } from './drizzle/index.js';
|
|
21
|
-
export { DrizzleAdapter, PostgresAuthAdapter, collectionToDrizzleSchema, createDatabase, createDrizzleAdapter, fieldToDrizzleType, runMigrations, seedDefaultRoles } from './drizzle/index.js';
|
|
22
|
-
export { MongoDBAdapter, createMongoDBAdapter } from './mongodb/index.js';
|
|
23
|
-
export { buildGraphQLSchema, createGraphQLSchema } from './graphql/index.js';
|
|
24
|
-
export { createHonoApp, createRESTAPI } from './rest/index.js';
|
|
25
|
-
export { A as AdminStylingConfig, C as CSSGenerator, F as FieldStyling, S as StylingConfig, a as StylingMode, T as ThemeBorderRadius, b as ThemeColors, c as ThemeConfig, d as ThemeFonts, e as ThemeShadows, f as ThemeSpacing, g as createAdminStyling, h as defaultDarkTheme, i as defaultFieldStyling, j as defaultLightTheme, k as ecommerce2026Theme, l as generateCSSVariables, m as generateTailwindConfig } from './index-Bz9JqRGI.js';
|
|
26
|
-
import { d as AuditLog, e as AuditLogFilter, A as AuthAdapter, U as UserRole, c as AuthUser, S as Session, b as AuthTokenConfig, R as RegisterData, a as AuthResult, L as LoginCredentials, J as JWTPayload } from './types-BnTm7oJG.js';
|
|
27
|
-
export { f as AuditAction } from './types-BnTm7oJG.js';
|
|
28
|
-
export { TemplateConfig, allSettingsGlobals, blogCollections, blogGlobals, coreSettingsGlobals, createTemplateConfig, ecommerceCollections, ecommerceGlobals, ecommerceSettingsGlobals, kitchenSinkCollections, mediaCollections, minimalCollections } from './templates/index.js';
|
|
29
|
-
import { Redis } from 'ioredis';
|
|
30
|
-
import 'ws';
|
|
31
|
-
import 'drizzle-orm/postgres-js';
|
|
32
|
-
|
|
33
|
-
interface DeliveryResult {
|
|
34
|
-
success: boolean;
|
|
35
|
-
status: number;
|
|
36
|
-
statusText?: string;
|
|
37
|
-
body?: string;
|
|
38
|
-
duration: number;
|
|
39
|
-
error?: string;
|
|
40
|
-
}
|
|
41
|
-
interface DeliveryOptions {
|
|
42
|
-
timeout?: number;
|
|
43
|
-
maxRetries?: number;
|
|
44
|
-
retryDelay?: number;
|
|
45
|
-
onRetry?: (attempt: number, error: string) => void;
|
|
46
|
-
onSuccess?: (result: DeliveryResult) => void;
|
|
47
|
-
onFailure?: (error: string) => void;
|
|
48
|
-
}
|
|
49
|
-
declare function signPayload(payload: string, secret: string): string;
|
|
50
|
-
declare function generateWebhookSecret(): string;
|
|
51
|
-
declare function deliverWebhook(webhook: WebhookConfig, payload: WebhookPayload, options?: DeliveryOptions): Promise<DeliveryResult>;
|
|
52
|
-
declare function deliverWithRetry(webhook: WebhookConfig, payload: WebhookPayload, deliveryId: string, options?: DeliveryOptions): Promise<DeliveryResult>;
|
|
53
|
-
declare function buildDeliveryRecord(deliveryId: string, webhookId: string, event: string, payload: WebhookPayload, attempt: number, result: DeliveryResult): WebhookDelivery;
|
|
54
|
-
declare function createTestPayload(): WebhookPayload;
|
|
55
|
-
|
|
56
|
-
declare class AuditLogger {
|
|
57
|
-
private redis;
|
|
58
|
-
private prefix;
|
|
59
|
-
private retentionDays;
|
|
60
|
-
constructor(redis: Redis, retentionDays?: number, prefix?: string);
|
|
61
|
-
log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
|
|
62
|
-
get(id: string): Promise<AuditLog | null>;
|
|
63
|
-
query(filter?: AuditLogFilter): Promise<{
|
|
64
|
-
logs: AuditLog[];
|
|
65
|
-
total: number;
|
|
66
|
-
}>;
|
|
67
|
-
getRecent(limit?: number): Promise<AuditLog[]>;
|
|
68
|
-
getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
|
|
69
|
-
getStats(startDate?: Date, endDate?: Date): Promise<{
|
|
70
|
-
totalEvents: number;
|
|
71
|
-
byAction: Record<string, number>;
|
|
72
|
-
successRate: number;
|
|
73
|
-
failedLogins: number;
|
|
74
|
-
uniqueUsers: Set<string>;
|
|
75
|
-
}>;
|
|
76
|
-
cleanup(): Promise<number>;
|
|
77
|
-
private getKeyForDate;
|
|
78
|
-
private getKeysForDateRange;
|
|
79
|
-
private matchesFilter;
|
|
80
|
-
private serializeLog;
|
|
81
|
-
private deserializeLog;
|
|
82
|
-
}
|
|
83
|
-
declare function createAuditContext(req: Request): {
|
|
84
|
-
ipAddress: string;
|
|
85
|
-
userAgent: string;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
declare class Kyro {
|
|
89
|
-
registry: Registry;
|
|
90
|
-
db: BaseAdapter;
|
|
91
|
-
pubsub: KyroPubSub;
|
|
92
|
-
webhookService: WebhookService;
|
|
93
|
-
settings?: Record<string, any>;
|
|
94
|
-
private wsServer?;
|
|
95
|
-
private config;
|
|
96
|
-
constructor(config: KyroConfig);
|
|
97
|
-
init(): Promise<void>;
|
|
98
|
-
loadSettings(): Promise<Record<string, any>>;
|
|
99
|
-
getREST(options?: {
|
|
100
|
-
user?: User;
|
|
101
|
-
req?: Request$1;
|
|
102
|
-
tenantID?: string;
|
|
103
|
-
}): hono.Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
|
|
104
|
-
getGraphQL(options?: {
|
|
105
|
-
user?: User;
|
|
106
|
-
req?: Request$1;
|
|
107
|
-
tenantID?: string;
|
|
108
|
-
}): graphql.GraphQLSchema;
|
|
109
|
-
getTRPC(options?: {
|
|
110
|
-
user?: User;
|
|
111
|
-
req?: Request$1;
|
|
112
|
-
tenantID?: string;
|
|
113
|
-
}): KyroRouter;
|
|
114
|
-
startWebSocket(options?: {
|
|
115
|
-
port?: number;
|
|
116
|
-
requireAuth?: boolean;
|
|
117
|
-
verifyToken?: (token: string) => Promise<any>;
|
|
118
|
-
}): Promise<KyroWSServer | null>;
|
|
119
|
-
shutdown(): Promise<void>;
|
|
120
|
-
}
|
|
121
|
-
declare function createKyro(config: KyroConfig): Kyro;
|
|
122
|
-
|
|
123
|
-
declare class ConfigValidationError extends Error {
|
|
124
|
-
errors: string[];
|
|
125
|
-
constructor(errors: string[]);
|
|
126
|
-
}
|
|
127
|
-
declare function validateCollection(config: CollectionConfig): string[];
|
|
128
|
-
declare function validateGlobal(config: GlobalConfig): string[];
|
|
129
|
-
declare function validateFields(fields: Field[], context: string): string[];
|
|
130
|
-
declare function validateConfig(collections: CollectionConfig[], globals?: GlobalConfig[]): void;
|
|
131
|
-
|
|
132
|
-
declare function fieldToZod(field: Field): ZodTypeAny;
|
|
133
|
-
declare function collectionToZod(collection: CollectionConfig): ZodTypeAny;
|
|
134
|
-
declare function collectionToCreateZod(collection: CollectionConfig): ZodTypeAny;
|
|
135
|
-
declare function collectionToUpdateZod(collection: CollectionConfig): ZodTypeAny;
|
|
136
|
-
declare function collectionToWhereZod(collection: CollectionConfig): ZodTypeAny;
|
|
137
|
-
declare function globalToZod(global: GlobalConfig): ZodTypeAny;
|
|
138
|
-
|
|
139
|
-
type DatabaseType$1 = 'postgres' | 'mysql' | 'sqlite' | 'mongodb';
|
|
140
|
-
interface DatabaseConnectionOptions {
|
|
141
|
-
type: DatabaseType$1;
|
|
142
|
-
host?: string;
|
|
143
|
-
port?: number;
|
|
144
|
-
database?: string;
|
|
145
|
-
user?: string;
|
|
146
|
-
password?: string;
|
|
147
|
-
url?: string;
|
|
148
|
-
ssl?: boolean | Record<string, any>;
|
|
149
|
-
maxConnections?: number;
|
|
150
|
-
connectionTimeout?: number;
|
|
151
|
-
}
|
|
152
|
-
interface DrizzleAdapterOptions {
|
|
153
|
-
type: 'postgres' | 'mysql' | 'sqlite';
|
|
154
|
-
client: any;
|
|
155
|
-
schema?: any;
|
|
156
|
-
connectionOptions?: DatabaseConnectionOptions;
|
|
157
|
-
}
|
|
158
|
-
interface MongoDBAdapterOptions {
|
|
159
|
-
type: 'mongodb';
|
|
160
|
-
client: any;
|
|
161
|
-
database: string;
|
|
162
|
-
connectionOptions?: DatabaseConnectionOptions;
|
|
163
|
-
}
|
|
164
|
-
type AdapterOptions = DrizzleAdapterOptions | MongoDBAdapterOptions;
|
|
165
|
-
|
|
166
|
-
declare class LocalAdapter extends AbstractBaseAdapter {
|
|
167
|
-
private db;
|
|
168
|
-
private path?;
|
|
169
|
-
private migrations;
|
|
170
|
-
private readonly draftsTableName;
|
|
171
|
-
private readonly versionsTableName;
|
|
172
|
-
constructor(options: {
|
|
173
|
-
db?: any;
|
|
174
|
-
path?: string;
|
|
175
|
-
});
|
|
176
|
-
connect(): Promise<void>;
|
|
177
|
-
disconnect(): Promise<void>;
|
|
178
|
-
private ensureTable;
|
|
179
|
-
private ensureVersionsTable;
|
|
180
|
-
private ensureDraftsTable;
|
|
181
|
-
private col;
|
|
182
|
-
private fieldToSQL;
|
|
183
|
-
private parseGlobalsSlug;
|
|
184
|
-
find<T>(args: FindArgs): Promise<FindResult<T>>;
|
|
185
|
-
findByID<T>(args: FindByIDArgs): Promise<T | null>;
|
|
186
|
-
create<T>(args: CreateArgs): Promise<T>;
|
|
187
|
-
update<T>(args: UpdateArgs): Promise<T>;
|
|
188
|
-
delete<T>(args: DeleteArgs): Promise<T>;
|
|
189
|
-
count(args: {
|
|
190
|
-
collection: string;
|
|
191
|
-
where?: Record<string, any>;
|
|
192
|
-
tenantID?: string;
|
|
193
|
-
}): Promise<number>;
|
|
194
|
-
findOne(args: {
|
|
195
|
-
collection: string;
|
|
196
|
-
where: Record<string, any>;
|
|
197
|
-
tenantID?: string;
|
|
198
|
-
draft?: boolean;
|
|
199
|
-
}): Promise<any>;
|
|
200
|
-
findVersions(args: FindVersionsArgs): Promise<FindResult<VersionRecord>>;
|
|
201
|
-
findVersionByID(args: {
|
|
202
|
-
collection: string;
|
|
203
|
-
versionId: string;
|
|
204
|
-
tenantID?: string;
|
|
205
|
-
}): Promise<VersionRecord | null>;
|
|
206
|
-
createVersion<T = Record<string, any>>(args: CreateVersionArgs<T>): Promise<VersionRecord<T>>;
|
|
207
|
-
deleteVersions(args: {
|
|
208
|
-
collection: string;
|
|
209
|
-
documentId: string;
|
|
210
|
-
keepLatest?: number;
|
|
211
|
-
tenantID?: string;
|
|
212
|
-
}): Promise<void>;
|
|
213
|
-
private rowToVersion;
|
|
214
|
-
findDraft<T>(args: DraftFindArgs): Promise<DraftSnapshot<T> | null>;
|
|
215
|
-
upsertDraft<T>(args: DraftUpsertArgs<T>): Promise<DraftSnapshot<T>>;
|
|
216
|
-
deleteDraft(args: DraftDeleteArgs): Promise<void>;
|
|
217
|
-
protected prepareData(data: Record<string, any>, config: CollectionConfig | GlobalConfig): Record<string, any>;
|
|
218
|
-
private rowToDoc;
|
|
219
|
-
private generateId;
|
|
220
|
-
private getMediaById;
|
|
221
|
-
private getTableNameFor;
|
|
222
|
-
private rowToDraft;
|
|
223
|
-
migrate(): Promise<void>;
|
|
224
|
-
rollback(): Promise<void>;
|
|
225
|
-
transaction<T>(fn: (tx: any) => Promise<T>): Promise<T>;
|
|
226
|
-
getDatabase(): any;
|
|
227
|
-
exec(sql: string): void;
|
|
228
|
-
prepare(sql: string): any;
|
|
229
|
-
}
|
|
230
|
-
declare function createLocalAdapter(options?: {
|
|
231
|
-
db?: any;
|
|
232
|
-
path?: string;
|
|
233
|
-
}): LocalAdapter;
|
|
234
|
-
|
|
235
|
-
interface PluginHooks {
|
|
236
|
-
beforeInit?: Hook[];
|
|
237
|
-
afterInit?: Hook[];
|
|
238
|
-
beforeRegisterCollections?: Hook[];
|
|
239
|
-
afterRegisterCollections?: Hook[];
|
|
240
|
-
beforeRegisterGlobals?: Hook[];
|
|
241
|
-
afterRegisterGlobals?: Hook[];
|
|
242
|
-
beforeServerStart?: Hook[];
|
|
243
|
-
afterServerStart?: Hook[];
|
|
244
|
-
beforeServerStop?: Hook[];
|
|
245
|
-
afterServerStop?: Hook[];
|
|
246
|
-
}
|
|
247
|
-
interface PluginCollectionExtension {
|
|
248
|
-
slug: string;
|
|
249
|
-
config: Partial<CollectionConfig>;
|
|
250
|
-
}
|
|
251
|
-
interface PluginGlobalExtension {
|
|
252
|
-
slug: string;
|
|
253
|
-
config: Partial<GlobalConfig>;
|
|
254
|
-
}
|
|
255
|
-
interface PluginFieldExtension {
|
|
256
|
-
collectionSlug: string;
|
|
257
|
-
field: Field;
|
|
258
|
-
}
|
|
259
|
-
interface PluginAPI {
|
|
260
|
-
registry: {
|
|
261
|
-
getCollection: (slug: string) => CollectionConfig | undefined;
|
|
262
|
-
getCollections: () => CollectionConfig[];
|
|
263
|
-
getGlobal: (slug: string) => GlobalConfig | undefined;
|
|
264
|
-
addCollection: (config: CollectionConfig) => void;
|
|
265
|
-
addGlobal: (config: GlobalConfig) => void;
|
|
266
|
-
extendCollection: (slug: string, extension: Partial<CollectionConfig>) => void;
|
|
267
|
-
extendGlobal: (slug: string, extension: Partial<GlobalConfig>) => void;
|
|
268
|
-
addField: (collectionSlug: string, field: Field, position?: number) => void;
|
|
269
|
-
};
|
|
270
|
-
hooks: {
|
|
271
|
-
register: (event: string, handler: Hook) => void;
|
|
272
|
-
unregister: (event: string, handler: Hook) => void;
|
|
273
|
-
};
|
|
274
|
-
config: {
|
|
275
|
-
get: (key: string) => any;
|
|
276
|
-
set: (key: string, value: any) => void;
|
|
277
|
-
};
|
|
278
|
-
db: any;
|
|
279
|
-
}
|
|
280
|
-
declare abstract class KyroPlugin {
|
|
281
|
-
name: string;
|
|
282
|
-
version?: string;
|
|
283
|
-
description?: string;
|
|
284
|
-
hooks: PluginHooks;
|
|
285
|
-
collections: Partial<CollectionConfig>[];
|
|
286
|
-
globals: Partial<GlobalConfig>[];
|
|
287
|
-
fields: PluginFieldExtension[];
|
|
288
|
-
extensions: {
|
|
289
|
-
collections: PluginCollectionExtension[];
|
|
290
|
-
globals: PluginGlobalExtension[];
|
|
291
|
-
};
|
|
292
|
-
adminComponents: Record<string, any>;
|
|
293
|
-
adminStyles: string[];
|
|
294
|
-
serverMiddleware?: (app: any) => void;
|
|
295
|
-
clientMiddleware?: (req: any) => any;
|
|
296
|
-
constructor(name: string);
|
|
297
|
-
init?(api: PluginAPI): Promise<void>;
|
|
298
|
-
beforeInit?(api: PluginAPI): Promise<void>;
|
|
299
|
-
afterInit?(api: PluginAPI): Promise<void>;
|
|
300
|
-
getCollections?(): Partial<CollectionConfig>[];
|
|
301
|
-
getGlobals?(): Partial<GlobalConfig>[];
|
|
302
|
-
getHooks?(): PluginHooks;
|
|
303
|
-
}
|
|
304
|
-
declare class PluginManager {
|
|
305
|
-
private plugins;
|
|
306
|
-
private hooks;
|
|
307
|
-
register(plugin: KyroPlugin): void;
|
|
308
|
-
unregister(name: string): void;
|
|
309
|
-
get(name: string): KyroPlugin | undefined;
|
|
310
|
-
getAll(): KyroPlugin[];
|
|
311
|
-
has(name: string): boolean;
|
|
312
|
-
registerHook(event: string, handler: Hook): void;
|
|
313
|
-
unregisterHook(event: string, handler: Hook): void;
|
|
314
|
-
executeHook(event: string, args?: any): Promise<any>;
|
|
315
|
-
getAllCollections(): Partial<CollectionConfig>[];
|
|
316
|
-
getAllGlobals(): Partial<GlobalConfig>[];
|
|
317
|
-
getAllFields(): PluginFieldExtension[];
|
|
318
|
-
getAdminComponents(): Record<string, any>;
|
|
319
|
-
getAdminStyles(): string[];
|
|
320
|
-
}
|
|
321
|
-
declare class SEOPLugin extends KyroPlugin {
|
|
322
|
-
constructor();
|
|
323
|
-
}
|
|
324
|
-
declare class AnalyticsPlugin extends KyroPlugin {
|
|
325
|
-
constructor();
|
|
326
|
-
}
|
|
327
|
-
declare class CommentsPlugin extends KyroPlugin {
|
|
328
|
-
constructor();
|
|
329
|
-
}
|
|
330
|
-
declare class ReviewsPlugin extends KyroPlugin {
|
|
331
|
-
constructor();
|
|
332
|
-
}
|
|
333
|
-
declare class WishlistPlugin extends KyroPlugin {
|
|
334
|
-
constructor();
|
|
335
|
-
}
|
|
336
|
-
declare const presetPlugins: {
|
|
337
|
-
SEO: typeof SEOPLugin;
|
|
338
|
-
Analytics: typeof AnalyticsPlugin;
|
|
339
|
-
Comments: typeof CommentsPlugin;
|
|
340
|
-
Reviews: typeof ReviewsPlugin;
|
|
341
|
-
Wishlist: typeof WishlistPlugin;
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
interface RedisAuthAdapterOptions {
|
|
345
|
-
url?: string;
|
|
346
|
-
host?: string;
|
|
347
|
-
port?: number;
|
|
348
|
-
password?: string;
|
|
349
|
-
db?: number;
|
|
350
|
-
keyPrefix?: string;
|
|
351
|
-
tokenExpiration?: number;
|
|
352
|
-
refreshTokenExpiration?: number;
|
|
353
|
-
tls?: boolean;
|
|
354
|
-
}
|
|
355
|
-
declare class RedisAuthAdapter implements AuthAdapter {
|
|
356
|
-
private _redis;
|
|
357
|
-
private prefix;
|
|
358
|
-
private tokenExpiration;
|
|
359
|
-
private refreshExpiration;
|
|
360
|
-
private options;
|
|
361
|
-
constructor(options?: RedisAuthAdapterOptions);
|
|
362
|
-
private getRedis;
|
|
363
|
-
connect(): Promise<void>;
|
|
364
|
-
disconnect(): Promise<void>;
|
|
365
|
-
private userKey;
|
|
366
|
-
private sessionKey;
|
|
367
|
-
private refreshKey;
|
|
368
|
-
private userByEmailKey;
|
|
369
|
-
private passwordHistoryKey;
|
|
370
|
-
createUser(data: {
|
|
371
|
-
email: string;
|
|
372
|
-
password: string;
|
|
373
|
-
role?: UserRole;
|
|
374
|
-
tenantId?: string;
|
|
375
|
-
}): Promise<AuthUser>;
|
|
376
|
-
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
377
|
-
findUserById(userId: string): Promise<AuthUser | null>;
|
|
378
|
-
updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
|
|
379
|
-
deleteUser(userId: string): Promise<boolean>;
|
|
380
|
-
hashPassword(password: string): Promise<string>;
|
|
381
|
-
verifyPassword(email: string, password: string): Promise<AuthUser | null>;
|
|
382
|
-
createSession(userId: string, data?: {
|
|
383
|
-
ipAddress?: string;
|
|
384
|
-
userAgent?: string;
|
|
385
|
-
}): Promise<Session>;
|
|
386
|
-
findSessionByToken(token: string): Promise<Session | null>;
|
|
387
|
-
findSessionByRefreshToken(refreshToken: string): Promise<Session | null>;
|
|
388
|
-
deleteSession(sessionId: string): Promise<boolean>;
|
|
389
|
-
deleteUserSessions(userId: string): Promise<number>;
|
|
390
|
-
addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
|
|
391
|
-
getPasswordHistory(userId: string, count?: number): Promise<string[]>;
|
|
392
|
-
isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
393
|
-
private userToHash;
|
|
394
|
-
private hashToUser;
|
|
395
|
-
private sessionToHash;
|
|
396
|
-
private hashToSession;
|
|
397
|
-
private auditLogKey;
|
|
398
|
-
private auditLogIndexKey;
|
|
399
|
-
findAuditLogs(filter: {
|
|
400
|
-
userId?: string;
|
|
401
|
-
action?: string | string[];
|
|
402
|
-
resource?: string;
|
|
403
|
-
success?: boolean;
|
|
404
|
-
limit?: number;
|
|
405
|
-
offset?: number;
|
|
406
|
-
}): Promise<{
|
|
407
|
-
logs: any[];
|
|
408
|
-
total: number;
|
|
409
|
-
}>;
|
|
410
|
-
createAuditLog(data: any): Promise<any>;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
interface EmailConfig$1 {
|
|
414
|
-
provider: "smtp" | "resend" | "sendgrid" | "mailgun" | "ses";
|
|
415
|
-
from: string;
|
|
416
|
-
fromName?: string;
|
|
417
|
-
replyTo?: string;
|
|
418
|
-
smtp?: {
|
|
419
|
-
host: string;
|
|
420
|
-
port: number;
|
|
421
|
-
secure: boolean;
|
|
422
|
-
auth: {
|
|
423
|
-
user: string;
|
|
424
|
-
pass: string;
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
resend?: {
|
|
428
|
-
apiKey: string;
|
|
429
|
-
};
|
|
430
|
-
sendgrid?: {
|
|
431
|
-
apiKey: string;
|
|
432
|
-
};
|
|
433
|
-
mailgun?: {
|
|
434
|
-
apiKey: string;
|
|
435
|
-
domain: string;
|
|
436
|
-
region?: "us" | "eu";
|
|
437
|
-
};
|
|
438
|
-
ses?: {
|
|
439
|
-
accessKeyId: string;
|
|
440
|
-
secretAccessKey: string;
|
|
441
|
-
region: string;
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
interface EmailOptions {
|
|
445
|
-
to: string | string[];
|
|
446
|
-
subject: string;
|
|
447
|
-
html: string;
|
|
448
|
-
text?: string;
|
|
449
|
-
replyTo?: string;
|
|
450
|
-
}
|
|
451
|
-
interface EmailTemplates {
|
|
452
|
-
verifyEmail: (link: string, userName?: string) => {
|
|
453
|
-
subject: string;
|
|
454
|
-
html: string;
|
|
455
|
-
text: string;
|
|
456
|
-
};
|
|
457
|
-
resetPassword: (link: string, userName?: string) => {
|
|
458
|
-
subject: string;
|
|
459
|
-
html: string;
|
|
460
|
-
text: string;
|
|
461
|
-
};
|
|
462
|
-
welcome: (userName?: string) => {
|
|
463
|
-
subject: string;
|
|
464
|
-
html: string;
|
|
465
|
-
text: string;
|
|
466
|
-
};
|
|
467
|
-
accountLocked: (attempts: number, duration: number, userName?: string) => {
|
|
468
|
-
subject: string;
|
|
469
|
-
html: string;
|
|
470
|
-
text: string;
|
|
471
|
-
};
|
|
472
|
-
passwordChanged: (userName?: string) => {
|
|
473
|
-
subject: string;
|
|
474
|
-
html: string;
|
|
475
|
-
text: string;
|
|
476
|
-
};
|
|
477
|
-
newLogin: (location: string, time: string, userName?: string) => {
|
|
478
|
-
subject: string;
|
|
479
|
-
html: string;
|
|
480
|
-
text: string;
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
declare class EmailTransport {
|
|
484
|
-
private transporter?;
|
|
485
|
-
private config;
|
|
486
|
-
private templates;
|
|
487
|
-
private transporterInitialized;
|
|
488
|
-
constructor(config: EmailConfig$1, templates?: Partial<EmailTemplates>);
|
|
489
|
-
private ensureTransporter;
|
|
490
|
-
send(options: EmailOptions): Promise<any>;
|
|
491
|
-
private sendViaResend;
|
|
492
|
-
private sendViaSendGrid;
|
|
493
|
-
private sendViaMailgun;
|
|
494
|
-
getTemplates(): EmailTemplates;
|
|
495
|
-
verifyConnection(): Promise<boolean>;
|
|
496
|
-
static fromConfig(db: any): Promise<EmailTransport | null>;
|
|
497
|
-
static fromEnv(): EmailTransport | null;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
interface BootstrapConfig {
|
|
501
|
-
authAdapter?: AuthAdapter;
|
|
502
|
-
authDbPath?: string;
|
|
503
|
-
adminEmail: string;
|
|
504
|
-
adminPassword: string;
|
|
505
|
-
adminRole?: string;
|
|
506
|
-
tenantId?: string;
|
|
507
|
-
emailConfig?: EmailConfig$1;
|
|
508
|
-
sendWelcomeEmail?: boolean;
|
|
509
|
-
}
|
|
510
|
-
interface BootstrapResult {
|
|
511
|
-
success: boolean;
|
|
512
|
-
user?: AuthUser;
|
|
513
|
-
error?: string;
|
|
514
|
-
}
|
|
515
|
-
declare function bootstrapAdmin(config: BootstrapConfig): Promise<BootstrapResult>;
|
|
516
|
-
declare function getBootstrapFromEnv(): BootstrapConfig | null;
|
|
517
|
-
declare function autoBootstrap(): Promise<BootstrapResult | null>;
|
|
518
|
-
|
|
519
|
-
interface PasswordPolicyConfig {
|
|
520
|
-
minLength: number;
|
|
521
|
-
requireUppercase: boolean;
|
|
522
|
-
requireLowercase: boolean;
|
|
523
|
-
requireNumbers: boolean;
|
|
524
|
-
requireSpecialChars: boolean;
|
|
525
|
-
preventReuse: number;
|
|
526
|
-
maxLength?: number;
|
|
527
|
-
}
|
|
528
|
-
interface ValidationResult {
|
|
529
|
-
valid: boolean;
|
|
530
|
-
errors: string[];
|
|
531
|
-
}
|
|
532
|
-
declare class PasswordPolicy {
|
|
533
|
-
private config;
|
|
534
|
-
constructor(config?: Partial<PasswordPolicyConfig>);
|
|
535
|
-
validate(password: string): ValidationResult;
|
|
536
|
-
checkReuse(passwordHash: string, history: string[], verifyFn: (password: string, hash: string) => Promise<boolean>): Promise<ValidationResult>;
|
|
537
|
-
isInHistory(password: string, history: string[], verifyFn: (password: string, hash: string) => Promise<boolean>): Promise<boolean>;
|
|
538
|
-
generatePassword(length?: number): string;
|
|
539
|
-
getStrength(password: string): {
|
|
540
|
-
score: number;
|
|
541
|
-
label: string;
|
|
542
|
-
feedback: string[];
|
|
543
|
-
};
|
|
544
|
-
setConfig(config: Partial<PasswordPolicyConfig>): void;
|
|
545
|
-
getConfig(): PasswordPolicyConfig;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
interface LockoutConfig {
|
|
549
|
-
maxAttempts: number;
|
|
550
|
-
lockDuration: number;
|
|
551
|
-
notifyUser: boolean;
|
|
552
|
-
notifyAdmin: boolean;
|
|
553
|
-
adminNotifyAfter: number;
|
|
554
|
-
}
|
|
555
|
-
interface LockoutStatus {
|
|
556
|
-
locked: boolean;
|
|
557
|
-
attemptsRemaining: number;
|
|
558
|
-
lockedUntil?: Date;
|
|
559
|
-
totalAttempts: number;
|
|
560
|
-
}
|
|
561
|
-
declare class AccountLockout {
|
|
562
|
-
private redis;
|
|
563
|
-
private prefix;
|
|
564
|
-
private config;
|
|
565
|
-
constructor(redis: Redis, config?: Partial<LockoutConfig>, prefix?: string);
|
|
566
|
-
private lockKey;
|
|
567
|
-
private historyKey;
|
|
568
|
-
checkLockout(userId: string): Promise<LockoutStatus>;
|
|
569
|
-
recordFailedAttempt(userId: string): Promise<LockoutStatus>;
|
|
570
|
-
lockAccount(userId: string, duration?: number): Promise<void>;
|
|
571
|
-
unlockAccount(userId: string): Promise<void>;
|
|
572
|
-
resetAttempts(userId: string): Promise<void>;
|
|
573
|
-
getLockoutHistory(userId: string, limit?: number): Promise<Date[]>;
|
|
574
|
-
getLockoutStats(userId: string): Promise<{
|
|
575
|
-
totalFailedAttempts: number;
|
|
576
|
-
lockoutCount: number;
|
|
577
|
-
lastLockout: Date | null;
|
|
578
|
-
averageAttemptsBeforeLockout: number;
|
|
579
|
-
}>;
|
|
580
|
-
shouldNotifyAdmin(currentAttempts: number): boolean;
|
|
581
|
-
getConfig(): LockoutConfig;
|
|
582
|
-
setConfig(config: Partial<LockoutConfig>): void;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
interface RateLimitConfig {
|
|
586
|
-
window: number;
|
|
587
|
-
max: number;
|
|
588
|
-
}
|
|
589
|
-
interface RateLimitResult {
|
|
590
|
-
allowed: boolean;
|
|
591
|
-
remaining: number;
|
|
592
|
-
resetAt: number;
|
|
593
|
-
retryAfter?: number;
|
|
594
|
-
}
|
|
595
|
-
declare class RateLimiter {
|
|
596
|
-
private redis;
|
|
597
|
-
private prefix;
|
|
598
|
-
private limits;
|
|
599
|
-
private userLimits;
|
|
600
|
-
constructor(redis: Redis, limits?: Record<string, RateLimitConfig>, userLimits?: Record<string, RateLimitConfig>, prefix?: string);
|
|
601
|
-
private getKey;
|
|
602
|
-
check(type: string, identifier: string): Promise<RateLimitResult>;
|
|
603
|
-
checkUser(type: string, userId: string, identifier: string): Promise<RateLimitResult>;
|
|
604
|
-
reset(type: string, identifier: string): Promise<void>;
|
|
605
|
-
resetUser(type: string, userId: string, identifier: string): Promise<void>;
|
|
606
|
-
getStatus(type: string, identifier: string): Promise<{
|
|
607
|
-
count: number;
|
|
608
|
-
limit: number;
|
|
609
|
-
remaining: number;
|
|
610
|
-
resetAt: number;
|
|
611
|
-
}>;
|
|
612
|
-
setLimit(type: string, config: RateLimitConfig): void;
|
|
613
|
-
setUserLimit(type: string, config: RateLimitConfig): void;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
declare class InMemoryRateLimiter {
|
|
617
|
-
private storage;
|
|
618
|
-
private userStorage;
|
|
619
|
-
private limits;
|
|
620
|
-
private userLimits;
|
|
621
|
-
constructor(limits?: Record<string, RateLimitConfig>, userLimits?: Record<string, RateLimitConfig>);
|
|
622
|
-
private getKey;
|
|
623
|
-
private getUserKey;
|
|
624
|
-
private cleanupOldEntries;
|
|
625
|
-
check(type: string, identifier: string): Promise<RateLimitResult>;
|
|
626
|
-
checkUser(type: string, userId: string, identifier: string): Promise<RateLimitResult>;
|
|
627
|
-
reset(type: string, identifier: string): Promise<void>;
|
|
628
|
-
resetUser(type: string, userId: string, identifier: string): Promise<void>;
|
|
629
|
-
getStatus(type: string, identifier: string): Promise<{
|
|
630
|
-
count: number;
|
|
631
|
-
limit: number;
|
|
632
|
-
remaining: number;
|
|
633
|
-
resetAt: number;
|
|
634
|
-
}>;
|
|
635
|
-
setLimit(type: string, config: RateLimitConfig): void;
|
|
636
|
-
setUserLimit(type: string, config: RateLimitConfig): void;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
declare class InMemoryAccountLockout {
|
|
640
|
-
private storage;
|
|
641
|
-
private history;
|
|
642
|
-
private config;
|
|
643
|
-
constructor(config?: Partial<LockoutConfig>);
|
|
644
|
-
checkLockout(userId: string): Promise<LockoutStatus>;
|
|
645
|
-
recordFailedAttempt(userId: string): Promise<LockoutStatus>;
|
|
646
|
-
lockAccount(userId: string, duration?: number): Promise<void>;
|
|
647
|
-
unlockAccount(userId: string): Promise<void>;
|
|
648
|
-
resetAttempts(userId: string): Promise<void>;
|
|
649
|
-
getLockoutHistory(userId: string, limit?: number): Promise<Date[]>;
|
|
650
|
-
getLockoutStats(userId: string): Promise<{
|
|
651
|
-
totalFailedAttempts: number;
|
|
652
|
-
lockoutCount: number;
|
|
653
|
-
lastLockout: Date | null;
|
|
654
|
-
averageAttemptsBeforeLockout: number;
|
|
655
|
-
}>;
|
|
656
|
-
shouldNotifyAdmin(currentAttempts: number): boolean;
|
|
657
|
-
getConfig(): LockoutConfig;
|
|
658
|
-
setConfig(config: Partial<LockoutConfig>): void;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
declare class InMemoryAuditLogger {
|
|
662
|
-
private logs;
|
|
663
|
-
private retentionDays;
|
|
664
|
-
constructor(retentionDays?: number);
|
|
665
|
-
log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
|
|
666
|
-
get(id: string): Promise<AuditLog | null>;
|
|
667
|
-
query(filter?: AuditLogFilter): Promise<{
|
|
668
|
-
logs: AuditLog[];
|
|
669
|
-
total: number;
|
|
670
|
-
}>;
|
|
671
|
-
getRecent(limit?: number): Promise<AuditLog[]>;
|
|
672
|
-
getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
|
|
673
|
-
getStats(startDate?: Date, endDate?: Date): Promise<{
|
|
674
|
-
totalEvents: number;
|
|
675
|
-
byAction: Record<string, number>;
|
|
676
|
-
successRate: number;
|
|
677
|
-
failedLogins: number;
|
|
678
|
-
uniqueUsers: Set<string>;
|
|
679
|
-
}>;
|
|
680
|
-
cleanup(): Promise<number>;
|
|
681
|
-
private cleanupOldLogs;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
interface AuthRoutesConfig {
|
|
685
|
-
redis: AuthAdapter;
|
|
686
|
-
jwtSecret?: string;
|
|
687
|
-
jwtExpiresIn?: string;
|
|
688
|
-
jwtIssuer?: string;
|
|
689
|
-
jwtAudience?: string;
|
|
690
|
-
email?: EmailTransport;
|
|
691
|
-
passwordPolicy?: PasswordPolicy;
|
|
692
|
-
lockout?: InMemoryAccountLockout;
|
|
693
|
-
rateLimiter?: InMemoryRateLimiter;
|
|
694
|
-
auditLogger?: InMemoryAuditLogger;
|
|
695
|
-
baseUrl?: string;
|
|
696
|
-
emailVerificationRequired?: boolean;
|
|
697
|
-
}
|
|
698
|
-
declare class AuthRoutes {
|
|
699
|
-
private authAdapter;
|
|
700
|
-
private email?;
|
|
701
|
-
private passwordPolicy;
|
|
702
|
-
private lockout?;
|
|
703
|
-
private rateLimiter?;
|
|
704
|
-
private auditLogger?;
|
|
705
|
-
private baseUrl;
|
|
706
|
-
private emailVerificationRequired;
|
|
707
|
-
constructor(config: AuthRoutesConfig);
|
|
708
|
-
register(req: Request): Promise<Response>;
|
|
709
|
-
login(req: Request): Promise<Response>;
|
|
710
|
-
logout(req: Request): Promise<Response>;
|
|
711
|
-
refresh(req: Request): Promise<Response>;
|
|
712
|
-
me(req: Request): Promise<Response>;
|
|
713
|
-
changePassword(req: Request): Promise<Response>;
|
|
714
|
-
forgotPassword(req: Request): Promise<Response>;
|
|
715
|
-
verifyEmail(req: Request): Promise<Response>;
|
|
716
|
-
private recordFailedLogin;
|
|
717
|
-
private sanitizeUser;
|
|
718
|
-
private jsonResponse;
|
|
719
|
-
listSessions(req: Request): Promise<Response>;
|
|
720
|
-
revokeSession(req: Request, sessionId: string): Promise<Response>;
|
|
721
|
-
revokeOtherSessions(req: Request): Promise<Response>;
|
|
722
|
-
renameSession(req: Request, sessionId: string): Promise<Response>;
|
|
723
|
-
refreshSession(req: Request): Promise<Response>;
|
|
724
|
-
private errorResponse;
|
|
725
|
-
private rateLimitResponse;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
type DatabaseType = "sqlite" | "postgres" | "mysql" | "mongodb" | "memory";
|
|
729
|
-
interface KyroAuthConfig {
|
|
730
|
-
authAdapter: AuthAdapter;
|
|
731
|
-
databaseType?: string;
|
|
732
|
-
email?: EmailTransport;
|
|
733
|
-
passwordPolicy: PasswordPolicy;
|
|
734
|
-
lockout?: InMemoryAccountLockout;
|
|
735
|
-
rateLimiter?: InMemoryRateLimiter;
|
|
736
|
-
auditLogger?: InMemoryAuditLogger;
|
|
737
|
-
routes: AuthRoutes;
|
|
738
|
-
}
|
|
739
|
-
declare function createAuthConfig(databaseType?: string): Promise<KyroAuthConfig>;
|
|
740
|
-
declare const authConfig: Promise<KyroAuthConfig>;
|
|
741
|
-
|
|
742
|
-
declare class InMemoryAuthAdapter implements AuthAdapter {
|
|
743
|
-
private users;
|
|
744
|
-
private sessions;
|
|
745
|
-
private refreshTokens;
|
|
746
|
-
private emailToUserId;
|
|
747
|
-
private passwordHistory;
|
|
748
|
-
private auditLogs;
|
|
749
|
-
private externalDb;
|
|
750
|
-
constructor();
|
|
751
|
-
connect(): Promise<void>;
|
|
752
|
-
disconnect(): Promise<void>;
|
|
753
|
-
createUser(data: {
|
|
754
|
-
email: string;
|
|
755
|
-
password: string;
|
|
756
|
-
role?: UserRole;
|
|
757
|
-
tenantId?: string;
|
|
758
|
-
}): Promise<AuthUser>;
|
|
759
|
-
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
760
|
-
findUserById(userId: string): Promise<AuthUser | null>;
|
|
761
|
-
updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
|
|
762
|
-
deleteUser(userId: string): Promise<boolean>;
|
|
763
|
-
hashPassword(password: string): Promise<string>;
|
|
764
|
-
verifyPassword(email: string, password: string): Promise<AuthUser | null>;
|
|
765
|
-
createSession(userId: string, data?: {
|
|
766
|
-
ipAddress?: string;
|
|
767
|
-
userAgent?: string;
|
|
768
|
-
}): Promise<Session>;
|
|
769
|
-
findSessionByToken(token: string): Promise<Session | null>;
|
|
770
|
-
findSessionByRefreshToken(refreshToken: string): Promise<Session | null>;
|
|
771
|
-
deleteSession(sessionId: string): Promise<boolean>;
|
|
772
|
-
deleteUserSessions(userId: string): Promise<number>;
|
|
773
|
-
addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
|
|
774
|
-
getPasswordHistory(userId: string, count?: number): Promise<string[]>;
|
|
775
|
-
isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
776
|
-
hasAnyUsers(): Promise<boolean>;
|
|
777
|
-
findAuditLogs(filter: {
|
|
778
|
-
userId?: string;
|
|
779
|
-
action?: string | string[];
|
|
780
|
-
resource?: string;
|
|
781
|
-
success?: boolean;
|
|
782
|
-
limit?: number;
|
|
783
|
-
offset?: number;
|
|
784
|
-
}): Promise<{
|
|
785
|
-
logs: any[];
|
|
786
|
-
total: number;
|
|
787
|
-
}>;
|
|
788
|
-
createAuditLog(data: any): Promise<any>;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
declare class Auth {
|
|
792
|
-
private adapter;
|
|
793
|
-
private config;
|
|
794
|
-
constructor(adapter: AuthAdapter, config: AuthTokenConfig);
|
|
795
|
-
register(data: RegisterData): Promise<AuthResult>;
|
|
796
|
-
login(credentials: LoginCredentials): Promise<AuthResult>;
|
|
797
|
-
logout(token: string): Promise<void>;
|
|
798
|
-
refreshToken(refreshToken: string): Promise<AuthResult>;
|
|
799
|
-
verifyToken(token: string): Promise<JWTPayload | null>;
|
|
800
|
-
getUserFromToken(token: string): Promise<AuthUser | null>;
|
|
801
|
-
changePassword(userId: string, currentPassword: string, newPassword: string): Promise<AuthResult>;
|
|
802
|
-
resetPassword(email: string, newPassword: string): Promise<AuthResult>;
|
|
803
|
-
deleteAccount(userId: string): Promise<AuthResult>;
|
|
804
|
-
private createSessionForUser;
|
|
805
|
-
private generateToken;
|
|
806
|
-
private hashPassword;
|
|
807
|
-
private parseExpiresIn;
|
|
808
|
-
}
|
|
809
|
-
declare function createAuth(adapter: AuthAdapter, config: AuthTokenConfig): Auth;
|
|
810
|
-
|
|
811
|
-
interface SQLiteAuthAdapterOptions {
|
|
812
|
-
path?: string;
|
|
813
|
-
db?: any;
|
|
814
|
-
saltRounds?: number;
|
|
815
|
-
busyTimeout?: number;
|
|
816
|
-
walAutoCheckpoint?: number;
|
|
817
|
-
cacheSize?: number;
|
|
818
|
-
mmapSize?: number;
|
|
819
|
-
}
|
|
820
|
-
declare class SQLiteAuthAdapter implements AuthAdapter {
|
|
821
|
-
private db;
|
|
822
|
-
private path;
|
|
823
|
-
private saltRounds;
|
|
824
|
-
private externalDb;
|
|
825
|
-
private busyTimeout;
|
|
826
|
-
private walAutoCheckpoint;
|
|
827
|
-
private cacheSize;
|
|
828
|
-
private mmapSize;
|
|
829
|
-
private preparedStatements;
|
|
830
|
-
constructor(options?: SQLiteAuthAdapterOptions);
|
|
831
|
-
connect(): Promise<void>;
|
|
832
|
-
disconnect(): Promise<void>;
|
|
833
|
-
private ensureConnected;
|
|
834
|
-
private ensureTables;
|
|
835
|
-
private prepareStatements;
|
|
836
|
-
private stmt;
|
|
837
|
-
cleanupExpiredSessions(): Promise<number>;
|
|
838
|
-
cleanupOldAuditLogs(retentionDays?: number): Promise<number>;
|
|
839
|
-
getStats(): Promise<{
|
|
840
|
-
userCount: number;
|
|
841
|
-
activeSessionCount: number;
|
|
842
|
-
auditLogCount: number;
|
|
843
|
-
}>;
|
|
844
|
-
createUser(data: {
|
|
845
|
-
email: string;
|
|
846
|
-
password: string;
|
|
847
|
-
name?: string;
|
|
848
|
-
role?: UserRole;
|
|
849
|
-
tenantId?: string;
|
|
850
|
-
}): Promise<AuthUser>;
|
|
851
|
-
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
852
|
-
findUserById(userId: string): Promise<AuthUser | null>;
|
|
853
|
-
updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
|
|
854
|
-
deleteUser(userId: string): Promise<boolean>;
|
|
855
|
-
hashPassword(password: string): Promise<string>;
|
|
856
|
-
verifyPassword(email: string, password: string): Promise<AuthUser | null>;
|
|
857
|
-
createSession(userId: string, data?: {
|
|
858
|
-
ipAddress?: string;
|
|
859
|
-
userAgent?: string;
|
|
860
|
-
}): Promise<Session>;
|
|
861
|
-
findSessionByToken(token: string): Promise<Session | null>;
|
|
862
|
-
findSessionByRefreshToken(refreshToken: string): Promise<Session | null>;
|
|
863
|
-
deleteSession(sessionId: string): Promise<boolean>;
|
|
864
|
-
deleteUserSessions(userId: string): Promise<number>;
|
|
865
|
-
hasAnyUsers(): Promise<boolean>;
|
|
866
|
-
findUsers(options?: {
|
|
867
|
-
page?: number;
|
|
868
|
-
limit?: number;
|
|
869
|
-
search?: string;
|
|
870
|
-
}): Promise<{
|
|
871
|
-
users: AuthUser[];
|
|
872
|
-
total: number;
|
|
873
|
-
}>;
|
|
874
|
-
addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
|
|
875
|
-
getPasswordHistory(userId: string, count?: number): Promise<string[]>;
|
|
876
|
-
isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
877
|
-
recordFailedAttempt(userId: string): Promise<void>;
|
|
878
|
-
resetAttempts(userId: string): Promise<void>;
|
|
879
|
-
checkLockout(userId: string): Promise<{
|
|
880
|
-
locked: boolean;
|
|
881
|
-
attemptsRemaining: number;
|
|
882
|
-
lockedUntil?: Date;
|
|
883
|
-
totalAttempts: number;
|
|
884
|
-
}>;
|
|
885
|
-
logAudit(data: {
|
|
886
|
-
action: string;
|
|
887
|
-
userId?: string;
|
|
888
|
-
userEmail?: string;
|
|
889
|
-
role?: string;
|
|
890
|
-
resource: string;
|
|
891
|
-
resourceId?: string;
|
|
892
|
-
ipAddress?: string;
|
|
893
|
-
userAgent?: string;
|
|
894
|
-
success: boolean;
|
|
895
|
-
error?: string;
|
|
896
|
-
metadata?: Record<string, unknown>;
|
|
897
|
-
}): Promise<string>;
|
|
898
|
-
queryAuditLogs(options?: {
|
|
899
|
-
action?: string;
|
|
900
|
-
userId?: string;
|
|
901
|
-
resource?: string;
|
|
902
|
-
success?: boolean;
|
|
903
|
-
startDate?: Date;
|
|
904
|
-
endDate?: Date;
|
|
905
|
-
limit?: number;
|
|
906
|
-
offset?: number;
|
|
907
|
-
}): Promise<{
|
|
908
|
-
logs: Array<{
|
|
909
|
-
id: string;
|
|
910
|
-
timestamp: Date;
|
|
911
|
-
action: string;
|
|
912
|
-
userId?: string;
|
|
913
|
-
userEmail?: string;
|
|
914
|
-
resource: string;
|
|
915
|
-
resourceId?: string;
|
|
916
|
-
ipAddress?: string;
|
|
917
|
-
userAgent?: string;
|
|
918
|
-
success: boolean;
|
|
919
|
-
error?: string;
|
|
920
|
-
metadata?: Record<string, unknown>;
|
|
921
|
-
}>;
|
|
922
|
-
total: number;
|
|
923
|
-
}>;
|
|
924
|
-
private rowToUser;
|
|
925
|
-
private rowToSession;
|
|
926
|
-
findAuditLogs(filter: AuditLogFilter): Promise<{
|
|
927
|
-
logs: AuditLog[];
|
|
928
|
-
total: number;
|
|
929
|
-
}>;
|
|
930
|
-
createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
type VersionStatus = 'draft' | 'published' | 'archived';
|
|
934
|
-
interface Version<T = Record<string, unknown>> {
|
|
935
|
-
id: string;
|
|
936
|
-
collection: string;
|
|
937
|
-
documentId: string;
|
|
938
|
-
version: number;
|
|
939
|
-
status: VersionStatus;
|
|
940
|
-
data: T;
|
|
941
|
-
createdBy: string;
|
|
942
|
-
createdAt: Date;
|
|
943
|
-
publishedAt?: Date;
|
|
944
|
-
changeDescription?: string;
|
|
945
|
-
}
|
|
946
|
-
interface VersionDiff {
|
|
947
|
-
field: string;
|
|
948
|
-
oldValue: unknown;
|
|
949
|
-
newValue: unknown;
|
|
950
|
-
}
|
|
951
|
-
interface VersionHistoryOptions {
|
|
952
|
-
collection: string;
|
|
953
|
-
documentId: string;
|
|
954
|
-
limit?: number;
|
|
955
|
-
offset?: number;
|
|
956
|
-
}
|
|
957
|
-
interface CreateVersionOptions<T = Record<string, unknown>> {
|
|
958
|
-
collection: string;
|
|
959
|
-
documentId: string;
|
|
960
|
-
data: T;
|
|
961
|
-
status?: VersionStatus;
|
|
962
|
-
createdBy: string;
|
|
963
|
-
changeDescription?: string;
|
|
964
|
-
}
|
|
965
|
-
interface PublishVersionOptions {
|
|
966
|
-
collection: string;
|
|
967
|
-
documentId: string;
|
|
968
|
-
versionId: string;
|
|
969
|
-
publishedBy: string;
|
|
970
|
-
}
|
|
971
|
-
interface CompareVersionsOptions {
|
|
972
|
-
collection: string;
|
|
973
|
-
documentId: string;
|
|
974
|
-
versionA: string | number;
|
|
975
|
-
versionB: string | number;
|
|
976
|
-
}
|
|
977
|
-
interface VersionAdapter {
|
|
978
|
-
createVersion<T>(options: CreateVersionOptions<T>): Promise<Version<T>>;
|
|
979
|
-
getVersion<T>(collection: string, versionId: string): Promise<Version<T> | null>;
|
|
980
|
-
getVersions<T>(options: VersionHistoryOptions): Promise<Version<T>[]>;
|
|
981
|
-
getLatestVersion<T>(collection: string, documentId: string): Promise<Version<T> | null>;
|
|
982
|
-
getPublishedVersion<T>(collection: string, documentId: string): Promise<Version<T> | null>;
|
|
983
|
-
publishVersion(options: PublishVersionOptions): Promise<void>;
|
|
984
|
-
revertToVersion<T>(options: {
|
|
985
|
-
collection: string;
|
|
986
|
-
documentId: string;
|
|
987
|
-
versionId: string;
|
|
988
|
-
userId: string;
|
|
989
|
-
}): Promise<Version<T>>;
|
|
990
|
-
compareVersions<T>(options: CompareVersionsOptions): Promise<VersionDiff[]>;
|
|
991
|
-
deleteVersions(collection: string, documentId: string): Promise<void>;
|
|
992
|
-
}
|
|
993
|
-
interface DraftPublishConfig {
|
|
994
|
-
enabled?: boolean;
|
|
995
|
-
draftsEnabled?: boolean;
|
|
996
|
-
publishEnabled?: boolean;
|
|
997
|
-
scheduleEnabled?: boolean;
|
|
998
|
-
versioningEnabled?: boolean;
|
|
999
|
-
maxVersionsPerDocument?: number;
|
|
1000
|
-
autoPublish?: boolean;
|
|
1001
|
-
requirePublishPermission?: boolean;
|
|
1002
|
-
}
|
|
1003
|
-
interface VersionPublishSchedule {
|
|
1004
|
-
versionId: string;
|
|
1005
|
-
scheduledFor: Date;
|
|
1006
|
-
status: 'pending' | 'published' | 'cancelled';
|
|
1007
|
-
}
|
|
1008
|
-
declare function getDefaultDraftPublishConfig(): Required<DraftPublishConfig>;
|
|
1009
|
-
|
|
1010
|
-
declare class VersionManager<T = Record<string, unknown>> {
|
|
1011
|
-
private adapter;
|
|
1012
|
-
private config;
|
|
1013
|
-
constructor(adapter: VersionAdapter, config?: DraftPublishConfig);
|
|
1014
|
-
createVersion(options: Omit<CreateVersionOptions<T>, 'version'>): Promise<Version<T>>;
|
|
1015
|
-
publishVersion(options: PublishVersionOptions): Promise<void>;
|
|
1016
|
-
unpublishDocument(collection: string, documentId: string): Promise<void>;
|
|
1017
|
-
revertToVersion(collection: string, documentId: string, versionId: string, userId: string): Promise<Version<T>>;
|
|
1018
|
-
getVersionHistory(collection: string, documentId: string, limit?: number, offset?: number): Promise<Version<T>[]>;
|
|
1019
|
-
compareTwoVersions(collection: string, documentId: string, versionA: string | number, versionB: string | number): Promise<VersionDiff[]>;
|
|
1020
|
-
getLatestDraft(collection: string, documentId: string): Promise<Version<T> | null>;
|
|
1021
|
-
getPublishedVersion(collection: string, documentId: string): Promise<Version<T> | null>;
|
|
1022
|
-
getVersion(collection: string, versionId: string): Promise<Version<T> | null>;
|
|
1023
|
-
schedulePublish(collection: string, documentId: string, versionId: string, scheduledFor: Date): Promise<void>;
|
|
1024
|
-
deleteVersionHistory(collection: string, documentId: string): Promise<void>;
|
|
1025
|
-
private pruneOldVersions;
|
|
1026
|
-
}
|
|
1027
|
-
declare function createVersionManager<T>(adapter: VersionAdapter, config?: DraftPublishConfig): VersionManager<T>;
|
|
1028
|
-
declare function isPublished(status: VersionStatus): boolean;
|
|
1029
|
-
declare function isDraft(status: VersionStatus): boolean;
|
|
1030
|
-
declare function isArchived(status: VersionStatus): boolean;
|
|
1031
|
-
|
|
1032
|
-
interface S3CompatibleConfig {
|
|
1033
|
-
bucket?: string;
|
|
1034
|
-
region?: string;
|
|
1035
|
-
accessKeyId?: string;
|
|
1036
|
-
secretAccessKey?: string;
|
|
1037
|
-
endpoint?: string;
|
|
1038
|
-
cdnUrl?: string;
|
|
1039
|
-
prefix?: string;
|
|
1040
|
-
}
|
|
1041
|
-
interface R2Config {
|
|
1042
|
-
accountId?: string;
|
|
1043
|
-
accessKeyId?: string;
|
|
1044
|
-
secretAccessKey?: string;
|
|
1045
|
-
bucket?: string;
|
|
1046
|
-
cdnUrl?: string;
|
|
1047
|
-
prefix?: string;
|
|
1048
|
-
publicDevUrl?: string;
|
|
1049
|
-
}
|
|
1050
|
-
interface GCSConfig {
|
|
1051
|
-
bucket?: string;
|
|
1052
|
-
projectId?: string;
|
|
1053
|
-
clientEmail?: string;
|
|
1054
|
-
privateKey?: string;
|
|
1055
|
-
cdnUrl?: string;
|
|
1056
|
-
prefix?: string;
|
|
1057
|
-
}
|
|
1058
|
-
interface BackblazeConfig {
|
|
1059
|
-
bucket?: string;
|
|
1060
|
-
accountId?: string;
|
|
1061
|
-
applicationKeyId?: string;
|
|
1062
|
-
applicationKey?: string;
|
|
1063
|
-
cdnUrl?: string;
|
|
1064
|
-
prefix?: string;
|
|
1065
|
-
}
|
|
1066
|
-
interface BunnyConfig {
|
|
1067
|
-
storageZone?: string;
|
|
1068
|
-
apiKey?: string;
|
|
1069
|
-
cdnUrl?: string;
|
|
1070
|
-
prefix?: string;
|
|
1071
|
-
}
|
|
1072
|
-
interface FTPConfig {
|
|
1073
|
-
host?: string;
|
|
1074
|
-
port?: number;
|
|
1075
|
-
user?: string;
|
|
1076
|
-
password?: string;
|
|
1077
|
-
secure?: boolean;
|
|
1078
|
-
baseUrl?: string;
|
|
1079
|
-
prefix?: string;
|
|
1080
|
-
}
|
|
1081
|
-
interface StorageConfig$1 {
|
|
1082
|
-
type: string;
|
|
1083
|
-
s3: S3CompatibleConfig;
|
|
1084
|
-
r2: R2Config;
|
|
1085
|
-
gcs: GCSConfig;
|
|
1086
|
-
digitalocean: S3CompatibleConfig;
|
|
1087
|
-
backblaze: BackblazeConfig;
|
|
1088
|
-
wasabi: S3CompatibleConfig;
|
|
1089
|
-
bunny: BunnyConfig;
|
|
1090
|
-
ftp: FTPConfig;
|
|
1091
|
-
cloudinary: {
|
|
1092
|
-
cloudName?: string;
|
|
1093
|
-
apiKey?: string;
|
|
1094
|
-
apiSecret?: string;
|
|
1095
|
-
folder?: string;
|
|
1096
|
-
};
|
|
1097
|
-
imgix: {
|
|
1098
|
-
domain?: string;
|
|
1099
|
-
signKey?: string;
|
|
1100
|
-
};
|
|
1101
|
-
local: {
|
|
1102
|
-
uploadDir?: string;
|
|
1103
|
-
baseUrl?: string;
|
|
1104
|
-
};
|
|
1105
|
-
}
|
|
1106
|
-
interface EmailConfig {
|
|
1107
|
-
provider?: string;
|
|
1108
|
-
host?: string;
|
|
1109
|
-
port?: number;
|
|
1110
|
-
secure?: boolean;
|
|
1111
|
-
user?: string;
|
|
1112
|
-
pass?: string;
|
|
1113
|
-
from?: string;
|
|
1114
|
-
fromName?: string;
|
|
1115
|
-
replyTo?: string;
|
|
1116
|
-
}
|
|
1117
|
-
declare class ConfigService {
|
|
1118
|
-
private db;
|
|
1119
|
-
private cache;
|
|
1120
|
-
private static readonly SENSITIVE_KEYS;
|
|
1121
|
-
constructor(db: any);
|
|
1122
|
-
/**
|
|
1123
|
-
* Initialize the service by loading all settings from the database
|
|
1124
|
-
*/
|
|
1125
|
-
load(): Promise<void>;
|
|
1126
|
-
/**
|
|
1127
|
-
* Load settings from the _globals_storage-settings table (SQLite fallback)
|
|
1128
|
-
* Maps nested global structure to flat key-value cache
|
|
1129
|
-
*/
|
|
1130
|
-
private loadFromGlobals;
|
|
1131
|
-
/**
|
|
1132
|
-
* Get a settings value with environment fallback
|
|
1133
|
-
*/
|
|
1134
|
-
get(key: string, envKey?: string, defaultValue?: string): string | undefined;
|
|
1135
|
-
/**
|
|
1136
|
-
* Get storage configuration
|
|
1137
|
-
*/
|
|
1138
|
-
getStorageConfig(): StorageConfig$1;
|
|
1139
|
-
/**
|
|
1140
|
-
* Get email configuration
|
|
1141
|
-
*/
|
|
1142
|
-
getEmailConfig(): EmailConfig;
|
|
1143
|
-
/**
|
|
1144
|
-
* Mask sensitive values for display
|
|
1145
|
-
*/
|
|
1146
|
-
maskSensitive(key: string, value: string | undefined): string | undefined;
|
|
1147
|
-
/**
|
|
1148
|
-
* Update a setting in the database
|
|
1149
|
-
*/
|
|
1150
|
-
set(key: string, value: string, description?: string): Promise<void>;
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
interface LocalStorageConfig {
|
|
1154
|
-
uploadDir: string;
|
|
1155
|
-
baseUrl?: string;
|
|
1156
|
-
}
|
|
1157
|
-
declare function createLocalStorage(config: LocalStorageConfig): StorageProvider;
|
|
1158
|
-
|
|
1159
|
-
interface UploadOptions {
|
|
1160
|
-
folder?: string;
|
|
1161
|
-
filename?: string;
|
|
1162
|
-
mimeType?: string;
|
|
1163
|
-
metadata?: Record<string, unknown>;
|
|
1164
|
-
}
|
|
1165
|
-
interface UploadedFile {
|
|
1166
|
-
id: string;
|
|
1167
|
-
filename: string;
|
|
1168
|
-
originalName: string;
|
|
1169
|
-
mimeType: string;
|
|
1170
|
-
size: number;
|
|
1171
|
-
url: string;
|
|
1172
|
-
thumbnailUrl?: string;
|
|
1173
|
-
width?: number;
|
|
1174
|
-
height?: number;
|
|
1175
|
-
folder?: string;
|
|
1176
|
-
provider: string;
|
|
1177
|
-
metadata?: Record<string, unknown>;
|
|
1178
|
-
createdAt: string;
|
|
1179
|
-
}
|
|
1180
|
-
interface ImageTransforms {
|
|
1181
|
-
width?: number;
|
|
1182
|
-
height?: number;
|
|
1183
|
-
fit?: "clip" | "crop" | "fill" | "fillmax" | "scale" | "max" | "min";
|
|
1184
|
-
format?: "webp" | "avif" | "jpeg" | "jpg" | "png" | "gif";
|
|
1185
|
-
quality?: number;
|
|
1186
|
-
blur?: number;
|
|
1187
|
-
sharpen?: number;
|
|
1188
|
-
}
|
|
1189
|
-
interface StorageProvider {
|
|
1190
|
-
name: string;
|
|
1191
|
-
displayName: string;
|
|
1192
|
-
supportsDynamicResize: boolean;
|
|
1193
|
-
upload(file: File, options?: UploadOptions): Promise<UploadedFile>;
|
|
1194
|
-
uploadFromUrl(url: string, options?: UploadOptions): Promise<UploadedFile>;
|
|
1195
|
-
delete(url: string): Promise<void>;
|
|
1196
|
-
rename(oldUrl: string, newKey: string): Promise<string>;
|
|
1197
|
-
getImageUrl(url: string, transforms?: ImageTransforms): string;
|
|
1198
|
-
generateThumbnail(file: UploadedFile, size: {
|
|
1199
|
-
width: number;
|
|
1200
|
-
height: number;
|
|
1201
|
-
}): Promise<string>;
|
|
1202
|
-
list(prefix?: string): Promise<UploadedFile[]>;
|
|
1203
|
-
exists(url: string): Promise<boolean>;
|
|
1204
|
-
createFolder?(folder: string): Promise<void>;
|
|
1205
|
-
deleteFolder?(folder: string): Promise<void>;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
declare function resolveProvider(configService: ConfigService): Promise<StorageProvider>;
|
|
1209
|
-
|
|
1210
|
-
interface MediaSearchParams {
|
|
1211
|
-
page?: number;
|
|
1212
|
-
limit?: number;
|
|
1213
|
-
search?: string;
|
|
1214
|
-
type?: string;
|
|
1215
|
-
folder?: string;
|
|
1216
|
-
sortBy?: string;
|
|
1217
|
-
sortDir?: "asc" | "desc";
|
|
1218
|
-
}
|
|
1219
|
-
interface MediaRow {
|
|
1220
|
-
id: string;
|
|
1221
|
-
filename: string;
|
|
1222
|
-
title: string | null;
|
|
1223
|
-
originalName: string;
|
|
1224
|
-
mimeType: string;
|
|
1225
|
-
fileSize: number;
|
|
1226
|
-
width: number | null;
|
|
1227
|
-
height: number | null;
|
|
1228
|
-
url: string;
|
|
1229
|
-
thumbnailUrl: string | null;
|
|
1230
|
-
folder: string | null;
|
|
1231
|
-
provider: string;
|
|
1232
|
-
alt: string | null;
|
|
1233
|
-
caption: string | null;
|
|
1234
|
-
metadata: string | null;
|
|
1235
|
-
createdAt: string;
|
|
1236
|
-
updatedAt: string;
|
|
1237
|
-
}
|
|
1238
|
-
declare class MediaService {
|
|
1239
|
-
private db;
|
|
1240
|
-
private storage;
|
|
1241
|
-
private dialect;
|
|
1242
|
-
private genId;
|
|
1243
|
-
private mediaTable;
|
|
1244
|
-
private foldersTable;
|
|
1245
|
-
constructor(db: any, storage: StorageProvider, options?: {
|
|
1246
|
-
dialect?: Dialect;
|
|
1247
|
-
genId?: () => string;
|
|
1248
|
-
});
|
|
1249
|
-
static init(db: any, options?: {
|
|
1250
|
-
dialect?: Dialect;
|
|
1251
|
-
genId?: () => string;
|
|
1252
|
-
storageConfig?: any;
|
|
1253
|
-
}): Promise<MediaService>;
|
|
1254
|
-
private ensureTables;
|
|
1255
|
-
private now;
|
|
1256
|
-
private buildFindConditions;
|
|
1257
|
-
private rowToMedia;
|
|
1258
|
-
private sqliteRun;
|
|
1259
|
-
private sqliteGet;
|
|
1260
|
-
upload(file: File, folder?: string): Promise<MediaRow>;
|
|
1261
|
-
uploadFromUrl(url: string, folder?: string): Promise<MediaRow>;
|
|
1262
|
-
delete(id: string): Promise<void>;
|
|
1263
|
-
deleteFile(url: string): Promise<void>;
|
|
1264
|
-
rename(id: string, newKey: string): Promise<MediaRow | null>;
|
|
1265
|
-
findById(id: string): Promise<MediaRow | null>;
|
|
1266
|
-
find(params?: MediaSearchParams): Promise<{
|
|
1267
|
-
docs: MediaRow[];
|
|
1268
|
-
totalDocs: number;
|
|
1269
|
-
page: number;
|
|
1270
|
-
limit: number;
|
|
1271
|
-
totalPages: number;
|
|
1272
|
-
}>;
|
|
1273
|
-
update(id: string, data: {
|
|
1274
|
-
title?: string;
|
|
1275
|
-
alt?: string;
|
|
1276
|
-
caption?: string;
|
|
1277
|
-
folder?: string;
|
|
1278
|
-
}): Promise<MediaRow | null>;
|
|
1279
|
-
updateMany(ids: string[], data: {
|
|
1280
|
-
folder?: string;
|
|
1281
|
-
}): Promise<void>;
|
|
1282
|
-
listFolders(): Promise<string[]>;
|
|
1283
|
-
createFolder(name: string, parentPath?: string): Promise<void>;
|
|
1284
|
-
deleteFolder(folder: string): Promise<void>;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
declare function defineConfig(config: {
|
|
1288
|
-
collections?: CollectionConfig[] | Record<string, CollectionConfig>;
|
|
1289
|
-
globals?: GlobalConfig[] | Record<string, GlobalConfig>;
|
|
1290
|
-
adapter: KyroConfig["adapter"];
|
|
1291
|
-
plugins?: KyroConfig["plugins"];
|
|
1292
|
-
auth?: KyroConfig["auth"];
|
|
1293
|
-
cors?: KyroConfig["cors"];
|
|
1294
|
-
admin?: KyroConfig["admin"];
|
|
1295
|
-
upload?: KyroConfig["upload"];
|
|
1296
|
-
graphQL?: KyroConfig["graphQL"];
|
|
1297
|
-
typescript?: KyroConfig["typescript"];
|
|
1298
|
-
localization?: KyroConfig["localization"];
|
|
1299
|
-
rateLimit?: KyroConfig["rateLimit"];
|
|
1300
|
-
debug?: KyroConfig["debug"];
|
|
1301
|
-
}): KyroConfig;
|
|
1302
|
-
|
|
1303
|
-
interface SeoTagsOptions {
|
|
1304
|
-
siteSettings: any;
|
|
1305
|
-
title?: string;
|
|
1306
|
-
description?: string;
|
|
1307
|
-
image?: string;
|
|
1308
|
-
url?: string;
|
|
1309
|
-
}
|
|
1310
|
-
/**
|
|
1311
|
-
* Generates standard SEO meta tags based on global site settings and page overrides.
|
|
1312
|
-
*/
|
|
1313
|
-
declare function generateSeoTags(options: SeoTagsOptions): string;
|
|
1314
|
-
/**
|
|
1315
|
-
* Generates analytics script tags based on global site settings.
|
|
1316
|
-
*/
|
|
1317
|
-
declare function generateAnalyticsTags(siteSettings: any): string;
|
|
1318
|
-
|
|
1319
|
-
type StorageAdapter = 'indexeddb' | 'fs' | 'redis' | 'sqlite' | 'postgres';
|
|
1320
|
-
type Environment = 'browser' | 'node';
|
|
1321
|
-
interface EncryptionConfig {
|
|
1322
|
-
enabled: boolean;
|
|
1323
|
-
algorithm?: 'AES-256-GCM' | 'ChaCha20-Poly1305';
|
|
1324
|
-
}
|
|
1325
|
-
interface StorageConfig {
|
|
1326
|
-
environment: Environment;
|
|
1327
|
-
adapter?: StorageAdapter;
|
|
1328
|
-
connectionString?: string;
|
|
1329
|
-
encryption?: EncryptionConfig;
|
|
1330
|
-
}
|
|
1331
|
-
interface StorageOptions {
|
|
1332
|
-
namespace?: string;
|
|
1333
|
-
ttl?: number;
|
|
1334
|
-
}
|
|
1335
|
-
type CreateStorageResult = {
|
|
1336
|
-
storage: {
|
|
1337
|
-
getItem: (name: string) => string | null | Promise<string | null>;
|
|
1338
|
-
setItem: (name: string, value: string) => void | Promise<void>;
|
|
1339
|
-
removeItem: (name: string) => void | Promise<void>;
|
|
1340
|
-
};
|
|
1341
|
-
cleanup?: () => Promise<void>;
|
|
1342
|
-
};
|
|
1343
|
-
|
|
1344
|
-
declare function createStorage(config: StorageConfig): Promise<CreateStorageResult & {
|
|
1345
|
-
storage: _StateStorage;
|
|
1346
|
-
}>;
|
|
1347
|
-
type _StateStorage = {
|
|
1348
|
-
getItem: (name: string) => string | null | Promise<string | null>;
|
|
1349
|
-
setItem: (name: string, value: string) => void | Promise<void>;
|
|
1350
|
-
removeItem: (name: string) => void | Promise<void>;
|
|
1351
|
-
};
|
|
1352
|
-
declare function createAuthStorage(config: StorageConfig): Promise<CreateStorageResult>;
|
|
1353
|
-
|
|
1354
|
-
declare function setDbAdapter(adapter: any): void;
|
|
1355
|
-
declare function loadSecrets(): Promise<void>;
|
|
1356
|
-
declare function getAppSecret(): string;
|
|
1357
|
-
declare function getEncryptionKey(): string;
|
|
1358
|
-
declare function getSessionConfig(): {
|
|
1359
|
-
maxAge: number;
|
|
1360
|
-
maxSessionsPerUser: number;
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
export { AbstractBaseAdapter, AccountLockout, type AdapterOptions, AnalyticsPlugin, AuditLog, AuditLogFilter, AuditLogger, Auth, AuthAdapter, AuthResult, Session as AuthSession, AuthTokenConfig, AuthUser, BaseAdapter, CollectionConfig, CommentsPlugin, type CompareVersionsOptions, ConfigService, ConfigValidationError, CreateArgs, type CreateStorageResult, type CreateVersionOptions, type DatabaseConnectionOptions, type DatabaseType, type DatabaseType$1 as DbAdapterType, DeleteArgs, type DeliveryOptions, type DeliveryResult, Dialect, type DraftPublishConfig, type DrizzleAdapterOptions, type EmailConfig, EmailTransport, type EncryptionConfig, type Environment, Field, FindArgs, FindByIDArgs, FindResult, GlobalConfig, Hook, InMemoryAccountLockout, InMemoryAuditLogger, InMemoryAuthAdapter, InMemoryRateLimiter, JWTPayload, Kyro, type KyroAuthConfig, KyroConfig, KyroPlugin, KyroPubSub, KyroWSServer, LocalAdapter, LoginCredentials, MediaService, type MongoDBAdapterOptions, PasswordPolicy, type PluginAPI, type PluginHooks, PluginManager, type PublishVersionOptions, RateLimiter, RedisAuthAdapter, RegisterData, Registry, Request$1 as Request, ReviewsPlugin, SEOPLugin, SQLiteAuthAdapter, type SeoTagsOptions, Session, type StorageAdapter, type StorageConfig$1 as StorageConfig, type StorageOptions, UpdateArgs, User, UserRole, type Version, type VersionAdapter, type VersionDiff, type VersionHistoryOptions, VersionManager, type VersionPublishSchedule, type VersionStatus, WebhookConfig, WebhookDelivery, WebhookPayload, WebhookService, WishlistPlugin, authConfig, autoBootstrap, bootstrapAdmin, buildDeliveryRecord, collectionToCreateZod, collectionToUpdateZod, collectionToWhereZod, collectionToZod, createAuditContext, createAuth, createAuthConfig, createAuthStorage, createKyro, createLocalAdapter, createLocalStorage, createStorage, createTestPayload, createVersionManager, defineConfig, deliverWebhook, deliverWithRetry, fieldToZod, generateAnalyticsTags, generateSeoTags, generateWebhookSecret, getAppSecret, getBootstrapFromEnv, getDefaultDraftPublishConfig, getEncryptionKey, getSessionConfig, globalToZod, isArchived, isDraft, isPublished, loadSecrets, presetPlugins, resolveProvider, setDbAdapter, signPayload, validateCollection, validateConfig, validateFields, validateGlobal };
|