@cequrebackends/cequre-ts 0.11.4
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/adapters/bun/bun-cron.d.ts +20 -0
- package/dist/adapters/bun/bun-media.d.ts +9 -0
- package/dist/adapters/bun/bun-redis-cache.d.ts +33 -0
- package/dist/adapters/bun/bun-response.d.ts +13 -0
- package/dist/adapters/bun/bun-server.d.ts +6 -0
- package/dist/adapters/bun/bun-storage.d.ts +10 -0
- package/dist/adapters/bun/bun-websocket.d.ts +104 -0
- package/dist/adapters/bun/index.d.ts +9 -0
- package/dist/adapters/bun/index.js +547 -0
- package/dist/adapters/node/index.d.ts +9 -0
- package/dist/adapters/node/index.js +902 -0
- package/dist/adapters/node/node-cron.d.ts +20 -0
- package/dist/adapters/node/node-media.d.ts +9 -0
- package/dist/adapters/node/node-redis-cache.d.ts +32 -0
- package/dist/adapters/node/node-response.d.ts +13 -0
- package/dist/adapters/node/node-server.d.ts +6 -0
- package/dist/adapters/node/node-storage.d.ts +10 -0
- package/dist/adapters/node/node-websocket.d.ts +102 -0
- package/dist/index-17yswtmg.js +175 -0
- package/dist/index-kyvy0s1x.js +2662 -0
- package/dist/index-mfqj7cwr.js +165 -0
- package/dist/index-rf1kdn5b.js +732 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +3152 -0
- package/dist/interface-map.d.ts +175 -0
- package/dist/shared/core/adapter.d.ts +84 -0
- package/dist/shared/core/base-sql-adapter.d.ts +34 -0
- package/dist/shared/core/cache.d.ts +8 -0
- package/dist/shared/core/email.d.ts +53 -0
- package/dist/shared/core/index.d.ts +12 -0
- package/dist/shared/core/index.js +47 -0
- package/dist/shared/core/openapi.d.ts +24 -0
- package/dist/shared/core/plugins.d.ts +2 -0
- package/dist/shared/core/request.d.ts +32 -0
- package/dist/shared/core/sdk.d.ts +3 -0
- package/dist/shared/core/stream.d.ts +24 -0
- package/dist/shared/core/types-generator.d.ts +0 -0
- package/dist/shared/core/types.d.ts +304 -0
- package/dist/shared/core/ulid.d.ts +5 -0
- package/dist/shared/core/validator.d.ts +32 -0
- package/dist/shared/main/access-evaluator.d.ts +13 -0
- package/dist/shared/main/access.d.ts +34 -0
- package/dist/shared/main/aot.d.ts +3 -0
- package/dist/shared/main/hooks.d.ts +76 -0
- package/dist/shared/main/population.d.ts +13 -0
- package/dist/shared/main/router.d.ts +112 -0
- package/dist/shared/main/runtime.d.ts +195 -0
- package/dist/shared/main/sse.d.ts +87 -0
- package/dist/shared/utils/crypto.d.ts +23 -0
- package/dist/shared/utils/durable-queue.d.ts +20 -0
- package/dist/shared/utils/duration.d.ts +15 -0
- package/dist/shared/utils/error.d.ts +52 -0
- package/dist/shared/utils/kv/adapters/memory.d.ts +20 -0
- package/dist/shared/utils/kv/adapters/sqlite.d.ts +32 -0
- package/dist/shared/utils/kv/index.d.ts +37 -0
- package/dist/shared/utils/kv/types.d.ts +38 -0
- package/dist/shared/utils/logger.d.ts +42 -0
- package/dist/shared/utils/queue-manager.d.ts +64 -0
- package/dist/shared/utils/url.d.ts +13 -0
- package/package.json +63 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* CEQURE UNIVERSAL ADAPTER CONTRACT (INTERFACE MAP)
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* Architectural Context:
|
|
7
|
+
* Cequre is designed using a strict "Ports and Adapters" (Hexagonal) architecture.
|
|
8
|
+
* Because 95% of Cequre's logic (AST parsing, TypeBox validation, ORM mapping,
|
|
9
|
+
* SDK generation, Auth flows, and Hooks) is pure, platform-agnostic TypeScript,
|
|
10
|
+
* it can execute natively on any modern JavaScript runtime.
|
|
11
|
+
*
|
|
12
|
+
* However, the remaining 5% of the framework physically touches the underlying
|
|
13
|
+
* Operating System or Infrastructure boundaries (I/O). Examples include:
|
|
14
|
+
* - Local File Systems vs Cloud Buckets (Storage)
|
|
15
|
+
* - Persistent Daemons vs Serverless Webhooks (Queues and Cron)
|
|
16
|
+
* - Raw TCP Sockets vs Stateless Functions (Realtime WebSockets)
|
|
17
|
+
* - Native bindings vs WebCrypto (Password Hashing)
|
|
18
|
+
*
|
|
19
|
+
* Purpose of this File:
|
|
20
|
+
* This file explicitly defines the 10 interfaces that represent those physical I/O boundaries.
|
|
21
|
+
* The core Cequre framework MUST NEVER directly invoke Bun, Node, Vercel, or Deno APIs.
|
|
22
|
+
* It ONLY programs against the generic contracts defined in this file.
|
|
23
|
+
*
|
|
24
|
+
* Building an Adapter:
|
|
25
|
+
* For Cequre to compile and run on a new deployment platform (e.g., Vercel Serverless or Node.js),
|
|
26
|
+
* a developer only needs to write a thin "Platform Adapter" that implements these 10 interfaces.
|
|
27
|
+
* At build time, the Cequre CLI (Compiler) uses Dependency Injection and bundler path-aliasing
|
|
28
|
+
* to hot-swap these abstract interfaces with the concrete, platform-specific implementations.
|
|
29
|
+
*
|
|
30
|
+
* TL;DR for AI/LLMs:
|
|
31
|
+
* If you are reading this file to port Cequre to a new runtime environment, your ONLY job
|
|
32
|
+
* is to write classes that satisfy the 10 interfaces below using the native APIs of your
|
|
33
|
+
* target environment, and register them with the Dependency Injector.
|
|
34
|
+
*/
|
|
35
|
+
export interface UploadedFile {
|
|
36
|
+
filename: string;
|
|
37
|
+
originalName: string;
|
|
38
|
+
mimetype: string;
|
|
39
|
+
size: number;
|
|
40
|
+
url: string;
|
|
41
|
+
}
|
|
42
|
+
export interface StorageProvider {
|
|
43
|
+
/** Save a file to the platform's storage medium */
|
|
44
|
+
saveFile(file: File, options?: {
|
|
45
|
+
filename?: string;
|
|
46
|
+
}): Promise<UploadedFile>;
|
|
47
|
+
/** Delete a file by its reference filename/path */
|
|
48
|
+
deleteFile(filename: string): Promise<void>;
|
|
49
|
+
/** Optional: S3/Blob specific Multipart uploads for massive files */
|
|
50
|
+
initMultipartUpload?(options: {
|
|
51
|
+
filename: string;
|
|
52
|
+
mimetype: string;
|
|
53
|
+
size: number;
|
|
54
|
+
}): Promise<{
|
|
55
|
+
uploadId: string;
|
|
56
|
+
filename: string;
|
|
57
|
+
parts?: {
|
|
58
|
+
partNumber: number;
|
|
59
|
+
url: string;
|
|
60
|
+
}[];
|
|
61
|
+
}>;
|
|
62
|
+
completeMultipartUpload?(uploadId: string, filename: string, parts: {
|
|
63
|
+
partNumber: number;
|
|
64
|
+
etag?: string;
|
|
65
|
+
}[]): Promise<UploadedFile>;
|
|
66
|
+
}
|
|
67
|
+
export interface PaginatedResult<T = Record<string, unknown>> {
|
|
68
|
+
docs: T[];
|
|
69
|
+
totalDocs: number;
|
|
70
|
+
limit: number;
|
|
71
|
+
page: number;
|
|
72
|
+
totalPages: number;
|
|
73
|
+
hasNextPage: boolean;
|
|
74
|
+
hasPrevPage: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface CequreAdapter {
|
|
77
|
+
readonly adapterType: string;
|
|
78
|
+
connect(): Promise<void>;
|
|
79
|
+
disconnect(): Promise<void>;
|
|
80
|
+
ping(): Promise<void>;
|
|
81
|
+
find(collection: string, query: Record<string, any>): Promise<PaginatedResult>;
|
|
82
|
+
findById(collection: string, id: string): Promise<Record<string, unknown> | null>;
|
|
83
|
+
create(collection: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
84
|
+
update(collection: string, id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
85
|
+
delete(collection: string, id: string): Promise<void>;
|
|
86
|
+
count(collection: string, query?: Record<string, any>): Promise<number>;
|
|
87
|
+
createTableDDL?(table: unknown): string;
|
|
88
|
+
dropTableDDL?(table: string): string;
|
|
89
|
+
raw?(sql: string, params?: unknown[]): Promise<unknown>;
|
|
90
|
+
}
|
|
91
|
+
export interface CacheStore {
|
|
92
|
+
get(key: string): Promise<any | null>;
|
|
93
|
+
set(key: string, value: any, ttlSeconds?: number): Promise<void>;
|
|
94
|
+
del(...keys: string[]): Promise<number>;
|
|
95
|
+
close(): void;
|
|
96
|
+
}
|
|
97
|
+
export interface CequreEmailSendOptions {
|
|
98
|
+
from?: string;
|
|
99
|
+
to?: string;
|
|
100
|
+
cc?: string;
|
|
101
|
+
bcc?: string;
|
|
102
|
+
replyTo?: string;
|
|
103
|
+
subject?: string;
|
|
104
|
+
text?: string;
|
|
105
|
+
html?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface CequreEmailTransport {
|
|
108
|
+
send(options: CequreEmailSendOptions): Promise<{
|
|
109
|
+
messageId: string;
|
|
110
|
+
}>;
|
|
111
|
+
verify(): Promise<boolean>;
|
|
112
|
+
}
|
|
113
|
+
export interface CryptoProvider {
|
|
114
|
+
/** Hash a plaintext password */
|
|
115
|
+
hash(plaintext: string): Promise<string>;
|
|
116
|
+
/** Verify a plaintext password against a hash */
|
|
117
|
+
verify(plaintext: string, hash: string): Promise<boolean>;
|
|
118
|
+
/** Generate a cryptographically secure random token */
|
|
119
|
+
generateRandomToken(length: number): string;
|
|
120
|
+
}
|
|
121
|
+
export interface CronJobConfig {
|
|
122
|
+
/** Standard cron expression (e.g. "0 0 * * *") */
|
|
123
|
+
schedule: string;
|
|
124
|
+
/** The function to execute */
|
|
125
|
+
handler: () => void | Promise<void>;
|
|
126
|
+
}
|
|
127
|
+
export interface CronProvider {
|
|
128
|
+
/** Register a job with the underlying platform's scheduler */
|
|
129
|
+
registerJob(name: string, config: CronJobConfig): void;
|
|
130
|
+
/** Start/Initialize the scheduler if required by the platform */
|
|
131
|
+
start(): void;
|
|
132
|
+
}
|
|
133
|
+
export interface RealtimeProvider {
|
|
134
|
+
/** Publish a message to a specific topic/channel */
|
|
135
|
+
publish(topic: string, data: any): void;
|
|
136
|
+
/** Broadcast a message to all connected clients */
|
|
137
|
+
broadcast(data: any): void;
|
|
138
|
+
/** Handle an incoming Upgrade request from the HTTP layer */
|
|
139
|
+
upgrade(req: Request): boolean | Promise<boolean>;
|
|
140
|
+
}
|
|
141
|
+
export interface QueueJob<T = any> {
|
|
142
|
+
id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
data: T;
|
|
145
|
+
timestamp: number;
|
|
146
|
+
}
|
|
147
|
+
export interface QueueProvider {
|
|
148
|
+
/** Enqueue a new job to be processed */
|
|
149
|
+
enqueue<T>(queueName: string, jobName: string, data: T, options?: any): Promise<string>;
|
|
150
|
+
/** Register a worker to process jobs from a specific queue */
|
|
151
|
+
registerWorker<T>(queueName: string, handler: (job: QueueJob<T>) => Promise<void>): void;
|
|
152
|
+
/** Start processing jobs (used by persistent platforms, ignored by serverless webhook queues) */
|
|
153
|
+
startWorkers(): void;
|
|
154
|
+
}
|
|
155
|
+
export interface CequreServerConfig {
|
|
156
|
+
port?: number;
|
|
157
|
+
hostname?: string;
|
|
158
|
+
/** The universal fetch handler generated by the Cequre Router */
|
|
159
|
+
fetch: (req: Request) => Promise<Response> | Response;
|
|
160
|
+
}
|
|
161
|
+
export interface ServerProvider {
|
|
162
|
+
/**
|
|
163
|
+
* Starts the server on persistent platforms (Bun/Node).
|
|
164
|
+
* On Serverless platforms (Vercel), this may simply export the fetch handler.
|
|
165
|
+
*/
|
|
166
|
+
start(config: CequreServerConfig): void | any;
|
|
167
|
+
/** Stop the server gracefully */
|
|
168
|
+
stop?(): Promise<void>;
|
|
169
|
+
}
|
|
170
|
+
export interface LoggerProvider {
|
|
171
|
+
info(message: string, meta?: Record<string, any>): void;
|
|
172
|
+
warn(message: string, meta?: Record<string, any>): void;
|
|
173
|
+
error(message: string, error?: Error, meta?: Record<string, any>): void;
|
|
174
|
+
debug(message: string, meta?: Record<string, any>): void;
|
|
175
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type ConstraintType = "foreign_key" | "unique" | "not_null" | "check" | "exclusion";
|
|
2
|
+
export interface ParsedConstraintError {
|
|
3
|
+
type: ConstraintType;
|
|
4
|
+
table?: string;
|
|
5
|
+
column?: string;
|
|
6
|
+
constraint?: string;
|
|
7
|
+
referencedTable?: string;
|
|
8
|
+
referencedColumn?: string;
|
|
9
|
+
rawMessage: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CequreAdapter {
|
|
12
|
+
readonly adapterType: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
disconnect(): Promise<void>;
|
|
16
|
+
transaction?<R>(callback: (trxAdapter: CequreAdapter) => Promise<R>): Promise<R>;
|
|
17
|
+
ping(): Promise<void>;
|
|
18
|
+
configureCollections?(collections: any[]): void | Promise<void>;
|
|
19
|
+
getStartupInfo?(): {
|
|
20
|
+
createdResourceName?: string | null;
|
|
21
|
+
};
|
|
22
|
+
getSystemTableStatements?(): string[];
|
|
23
|
+
getCurrentSchema?(): Promise<{
|
|
24
|
+
tables: string[];
|
|
25
|
+
columns: Record<string, string[]>;
|
|
26
|
+
}>;
|
|
27
|
+
recordMigration?(version: string, description: string): Promise<void>;
|
|
28
|
+
getCurrentMigrationVersion?(): Promise<string | null>;
|
|
29
|
+
parseConstraintError?(error: unknown): ParsedConstraintError | null;
|
|
30
|
+
createTableDDL?(table: unknown): string;
|
|
31
|
+
renameColumnDDL?(table: string, oldName: string, newName: string, column?: unknown): string;
|
|
32
|
+
addColumnDDL?(table: string, column: unknown): string | null;
|
|
33
|
+
dropColumnDDL?(table: string, column: string): string;
|
|
34
|
+
dropTableDDL?(table: string): string;
|
|
35
|
+
supportsGeneratedConstraintSQL?: boolean;
|
|
36
|
+
find(collection: string, query: QueryArgs<any>): Promise<PaginatedResult>;
|
|
37
|
+
findById(collection: string, id: string): Promise<Record<string, unknown> | null>;
|
|
38
|
+
findByIds?(collection: string, ids: string[]): Promise<Record<string, unknown>[]>;
|
|
39
|
+
create(collection: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
40
|
+
createMany?(collection: string, docs: Record<string, unknown>[]): Promise<Record<string, unknown>[]>;
|
|
41
|
+
update(collection: string, id: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
42
|
+
delete(collection: string, id: string): Promise<void>;
|
|
43
|
+
deleteMany?(collection: string, ids: string[]): Promise<void>;
|
|
44
|
+
count(collection: string, query?: Pick<QueryArgs<any>, "where">): Promise<number>;
|
|
45
|
+
raw?(sql: string, params?: unknown[]): Promise<unknown>;
|
|
46
|
+
}
|
|
47
|
+
export type FilterOperators<T> = {
|
|
48
|
+
eq?: T;
|
|
49
|
+
neq?: T;
|
|
50
|
+
gt?: T;
|
|
51
|
+
gte?: T;
|
|
52
|
+
lt?: T;
|
|
53
|
+
lte?: T;
|
|
54
|
+
in?: T[];
|
|
55
|
+
nin?: T[];
|
|
56
|
+
like?: string;
|
|
57
|
+
nlike?: string;
|
|
58
|
+
contains?: string;
|
|
59
|
+
startsWith?: string;
|
|
60
|
+
endsWith?: string;
|
|
61
|
+
mode?: "sensitive" | "insensitive" | "default";
|
|
62
|
+
};
|
|
63
|
+
export type WhereClause<T> = {
|
|
64
|
+
[P in keyof T]?: T[P] | FilterOperators<T[P]>;
|
|
65
|
+
} & {
|
|
66
|
+
OR?: WhereClause<T>[];
|
|
67
|
+
AND?: WhereClause<T>[];
|
|
68
|
+
};
|
|
69
|
+
export interface QueryArgs<T = any> {
|
|
70
|
+
where?: WhereClause<T>;
|
|
71
|
+
sort?: string;
|
|
72
|
+
limit?: number;
|
|
73
|
+
page?: number;
|
|
74
|
+
depth?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface PaginatedResult<T = Record<string, unknown>> {
|
|
77
|
+
docs: T[];
|
|
78
|
+
totalDocs: number;
|
|
79
|
+
limit: number;
|
|
80
|
+
page: number;
|
|
81
|
+
totalPages: number;
|
|
82
|
+
hasNextPage: boolean;
|
|
83
|
+
hasPrevPage: boolean;
|
|
84
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CequreAdapter, ParsedConstraintError } from "./adapter";
|
|
2
|
+
import type { CollectionConfig as Collection } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Base abstract class for SQL adapters (Postgres, SQLite, Turso)
|
|
5
|
+
* Encapsulates shared registry logic for fields, collections, and constraint error parsing.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseSqlAdapter implements CequreAdapter {
|
|
8
|
+
abstract readonly adapterType: string;
|
|
9
|
+
abstract readonly supportsGeneratedConstraintSQL?: boolean;
|
|
10
|
+
protected _createdDbName: string | null;
|
|
11
|
+
protected _numericFields: Map<string, Set<string>>;
|
|
12
|
+
protected _jsonFields: Map<string, Set<string>>;
|
|
13
|
+
protected _relationshipTargets: Map<string, string>;
|
|
14
|
+
protected _searchableFields: Map<string, Set<string>>;
|
|
15
|
+
protected _knownFields: Map<string, Set<string>>;
|
|
16
|
+
abstract connect(): Promise<void>;
|
|
17
|
+
abstract disconnect(): Promise<void>;
|
|
18
|
+
abstract ping(): Promise<void>;
|
|
19
|
+
abstract find(collection: string, query: any): Promise<any>;
|
|
20
|
+
abstract findById(collection: string, id: string): Promise<any>;
|
|
21
|
+
abstract create(collection: string, data: any): Promise<any>;
|
|
22
|
+
abstract update(collection: string, id: string, data: any): Promise<any>;
|
|
23
|
+
abstract delete(collection: string, id: string): Promise<void>;
|
|
24
|
+
abstract count(collection: string, query?: any): Promise<number>;
|
|
25
|
+
get createdDbName(): string | null;
|
|
26
|
+
getStartupInfo(): {
|
|
27
|
+
createdResourceName?: string | null;
|
|
28
|
+
};
|
|
29
|
+
configureCollections(collections: Collection[]): void;
|
|
30
|
+
registerCollections(collections: Collection[]): void;
|
|
31
|
+
parseConstraintError(error: unknown): ParsedConstraintError | null;
|
|
32
|
+
}
|
|
33
|
+
export declare function sqlIdentifier(identifier: string): string;
|
|
34
|
+
export declare function sqlLiteral(value: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CacheStore } from './types';
|
|
2
|
+
export declare class MemoryCacheStore implements CacheStore {
|
|
3
|
+
private cache;
|
|
4
|
+
get(key: string): Promise<any | null>;
|
|
5
|
+
set(key: string, value: any, ttlSeconds?: number): Promise<void>;
|
|
6
|
+
del(...keys: string[]): Promise<number>;
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EmailConfig, CequreEmailSendOptions, CequreEmailTransport } from "./types";
|
|
2
|
+
export type { CequreEmailSendOptions, CequreEmailTransport };
|
|
3
|
+
export declare class CequreMailer {
|
|
4
|
+
private transport;
|
|
5
|
+
private appName;
|
|
6
|
+
private resetTokenExpiryMinutes;
|
|
7
|
+
private from;
|
|
8
|
+
private templates?;
|
|
9
|
+
constructor(config?: EmailConfig, transport?: CequreEmailTransport);
|
|
10
|
+
send(options: CequreEmailSendOptions): Promise<{
|
|
11
|
+
messageId: string;
|
|
12
|
+
}>;
|
|
13
|
+
verify(): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Sends a welcome / registration confirmation email.
|
|
16
|
+
*/
|
|
17
|
+
sendWelcome(to: string, opts?: {
|
|
18
|
+
appName?: string;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Sends a password-reset email containing a one-time token link.
|
|
22
|
+
*
|
|
23
|
+
* @param to - Recipient email address
|
|
24
|
+
* @param resetUrl - Full reset URL including the token,
|
|
25
|
+
* e.g. https://myapp.com/reset-password?token=abc123
|
|
26
|
+
* @param opts - Optional overrides
|
|
27
|
+
*/
|
|
28
|
+
sendForgotPassword(to: string, resetUrl: string, opts?: {
|
|
29
|
+
appName?: string;
|
|
30
|
+
expiresInMinutes?: number;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Sends a confirmation email after a password has been successfully reset.
|
|
34
|
+
*/
|
|
35
|
+
sendPasswordResetSuccess(to: string, opts?: {
|
|
36
|
+
appName?: string;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Sends a verification email with a one-time link.
|
|
40
|
+
*
|
|
41
|
+
* @param to - Recipient email address
|
|
42
|
+
* @param verifyUrl - Full verification URL including the token,
|
|
43
|
+
* e.g. https://myapp.com/verify-email?token=abc123
|
|
44
|
+
* @param opts - Optional overrides
|
|
45
|
+
*/
|
|
46
|
+
sendVerificationEmail(to: string, verifyUrl: string, opts?: {
|
|
47
|
+
appName?: string;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a CequreMailer instance from optional config + env vars.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createMailer(config?: EmailConfig): CequreMailer | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./adapter";
|
|
3
|
+
export * from "./base-sql-adapter";
|
|
4
|
+
export * from "./cache";
|
|
5
|
+
export * from "./email";
|
|
6
|
+
export * from "./openapi";
|
|
7
|
+
export * from "./plugins";
|
|
8
|
+
export * from "./request";
|
|
9
|
+
export * from "./sdk";
|
|
10
|
+
export * from "./ulid";
|
|
11
|
+
export * from "./validator";
|
|
12
|
+
export * from "./stream";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
BaseSqlAdapter,
|
|
4
|
+
CequreMailer,
|
|
5
|
+
MemoryCacheStore,
|
|
6
|
+
MemoryStreamStore,
|
|
7
|
+
buildCollectionCreateSchema,
|
|
8
|
+
buildCollectionUpdateSchema,
|
|
9
|
+
createMailer,
|
|
10
|
+
createRouteContext,
|
|
11
|
+
generateBackendSchemas,
|
|
12
|
+
generateOpenAPISpec,
|
|
13
|
+
generateScalarHTML,
|
|
14
|
+
generateSharedModels,
|
|
15
|
+
generateTypeScriptClientSDK,
|
|
16
|
+
parseQuery,
|
|
17
|
+
sortPlugins,
|
|
18
|
+
sqlIdentifier,
|
|
19
|
+
sqlLiteral,
|
|
20
|
+
validateCreate,
|
|
21
|
+
validateUpdate
|
|
22
|
+
} from "../../index-kyvy0s1x.js";
|
|
23
|
+
import {
|
|
24
|
+
ulid
|
|
25
|
+
} from "../../index-17yswtmg.js";
|
|
26
|
+
export {
|
|
27
|
+
validateUpdate,
|
|
28
|
+
validateCreate,
|
|
29
|
+
ulid,
|
|
30
|
+
sqlLiteral,
|
|
31
|
+
sqlIdentifier,
|
|
32
|
+
sortPlugins,
|
|
33
|
+
parseQuery,
|
|
34
|
+
generateTypeScriptClientSDK,
|
|
35
|
+
generateSharedModels,
|
|
36
|
+
generateScalarHTML,
|
|
37
|
+
generateOpenAPISpec,
|
|
38
|
+
generateBackendSchemas,
|
|
39
|
+
createRouteContext,
|
|
40
|
+
createMailer,
|
|
41
|
+
buildCollectionUpdateSchema,
|
|
42
|
+
buildCollectionCreateSchema,
|
|
43
|
+
MemoryStreamStore,
|
|
44
|
+
MemoryCacheStore,
|
|
45
|
+
CequreMailer,
|
|
46
|
+
BaseSqlAdapter
|
|
47
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CequreAST } from "./types";
|
|
2
|
+
export type OpenAPIRouteDetail = Record<string, unknown> & {
|
|
3
|
+
description?: string;
|
|
4
|
+
summary?: string;
|
|
5
|
+
tags?: string[];
|
|
6
|
+
};
|
|
7
|
+
export type OpenAPIRouteHooks = Record<string, unknown> & {
|
|
8
|
+
body?: unknown;
|
|
9
|
+
detail?: OpenAPIRouteDetail;
|
|
10
|
+
query?: unknown;
|
|
11
|
+
response?: unknown;
|
|
12
|
+
tags?: string[];
|
|
13
|
+
};
|
|
14
|
+
export type OpenAPIRoute = {
|
|
15
|
+
hooks?: OpenAPIRouteHooks;
|
|
16
|
+
options?: OpenAPIRouteHooks;
|
|
17
|
+
method?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
};
|
|
20
|
+
export type OpenAPIRouteApp = {
|
|
21
|
+
routes?: Iterable<OpenAPIRoute>;
|
|
22
|
+
};
|
|
23
|
+
export declare function generateScalarHTML(specUrl: string, title?: string): string;
|
|
24
|
+
export declare function generateOpenAPISpec(schema: CequreAST, serverUrl: string, prefix: string, app?: OpenAPIRouteApp, includeHidden?: boolean): any;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AuthUser } from "../main/access";
|
|
2
|
+
import type { CequreRuntime } from "../../shared/main/runtime";
|
|
3
|
+
export type CequreQuery = Record<string, any>;
|
|
4
|
+
export type CequreParams = Record<string, string>;
|
|
5
|
+
export type ExtractAuthUser<TCollections> = TCollections extends {
|
|
6
|
+
__auth: infer A;
|
|
7
|
+
} ? (A extends AuthUser ? A : AuthUser) : AuthUser;
|
|
8
|
+
export interface CequreRouteContext<TCollections extends Record<string, any> = any, TState = unknown, TParams = CequreParams, TQuery = CequreQuery, TBody = unknown> {
|
|
9
|
+
request: Request;
|
|
10
|
+
url: URL;
|
|
11
|
+
params: TParams;
|
|
12
|
+
query: TQuery;
|
|
13
|
+
body?: TBody;
|
|
14
|
+
user: ExtractAuthUser<TCollections> | null;
|
|
15
|
+
cequre: CequreRuntime<TCollections>;
|
|
16
|
+
state?: TState;
|
|
17
|
+
/**
|
|
18
|
+
* Streams a chunk of data to the client instantly.
|
|
19
|
+
* Calling this will automatically hijack the response and keep the connection open.
|
|
20
|
+
*/
|
|
21
|
+
/** Internal method to stream data immediately. Do not use directly unless you know what you are doing. */
|
|
22
|
+
stream: (chunk: string | Uint8Array | Record<string, any>, options?: {
|
|
23
|
+
delay?: number;
|
|
24
|
+
event?: string;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
/** Internal streaming state (do not use) */
|
|
27
|
+
_streamInitiated?: boolean;
|
|
28
|
+
_streamWriter?: WritableStreamDefaultWriter<any>;
|
|
29
|
+
_streamResolver?: (res: Response) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare function parseQuery(searchParams: URLSearchParams): CequreQuery;
|
|
32
|
+
export declare function createRouteContext<TCollections extends Record<string, any>, TState, TParams = CequreParams, TQuery = CequreQuery, TBody = unknown>(request: Request, params?: TParams, state?: TState, user?: ExtractAuthUser<TCollections> | null, body?: TBody, cequre?: CequreRuntime<TCollections>): CequreRouteContext<TCollections, TState, TParams, TQuery, TBody>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface StreamEvent {
|
|
2
|
+
id: string;
|
|
3
|
+
collection: string;
|
|
4
|
+
action: string;
|
|
5
|
+
data: Record<string, any>;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
}
|
|
8
|
+
export interface DurableStreamStore {
|
|
9
|
+
publish(collection: string, action: string, data: Record<string, any>): Promise<string>;
|
|
10
|
+
read(collection: string, lastEventId?: string): Promise<StreamEvent[]>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* In-memory implementation of DurableStreamStore.
|
|
14
|
+
* [Development Only] This uses a local array ring buffer.
|
|
15
|
+
* It does not scale across multiple servers and loses data on restart.
|
|
16
|
+
* Use @cequrebackends/cequre-plugin-durable-streams for production.
|
|
17
|
+
*/
|
|
18
|
+
export declare class MemoryStreamStore implements DurableStreamStore {
|
|
19
|
+
private streams;
|
|
20
|
+
private maxCapacity;
|
|
21
|
+
constructor(maxCapacity?: number);
|
|
22
|
+
publish(collection: string, action: string, data: Record<string, any>): Promise<string>;
|
|
23
|
+
read(collection: string, lastEventId?: string): Promise<StreamEvent[]>;
|
|
24
|
+
}
|
|
File without changes
|