@cequrebackends/cequre-ts 0.12.2 → 0.14.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/adapters/bun/index.js +11 -5
- package/dist/adapters/node/index.js +20 -7
- package/dist/adapters/vercel/index.d.ts +38 -0
- package/dist/adapters/vercel/index.js +305 -0
- package/dist/adapters/vercel/upstash-kv.d.ts +41 -0
- package/dist/adapters/vercel/vercel-cron.d.ts +34 -0
- package/dist/adapters/vercel/vercel-media.d.ts +10 -0
- package/dist/adapters/vercel/vercel-queue.d.ts +31 -0
- package/dist/adapters/vercel/vercel-response.d.ts +4 -0
- package/dist/adapters/vercel/vercel-server.d.ts +24 -0
- package/dist/adapters/vercel/vercel-sse.d.ts +20 -0
- package/dist/adapters/vercel/vercel-storage.d.ts +23 -0
- package/dist/adapters/vercel/vercel-websocket.d.ts +12 -0
- package/dist/{index-kyvy0s1x.js → index-6qbca8zn.js} +4 -2
- package/dist/index-7xxm1add.js +203 -0
- package/dist/{index-rf1kdn5b.js → index-8bhn0nb4.js} +105 -178
- package/dist/index-cpw1bjf1.js +62 -0
- package/dist/{index-17yswtmg.js → index-qzzg2p5r.js} +1 -61
- package/dist/index.js +35 -18
- package/dist/shared/core/index.js +3 -2
- package/dist/shared/main/runtime.d.ts +16 -3
- package/dist/shared/utils/kv/types.d.ts +8 -1
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -22,34 +22,38 @@ import {
|
|
|
22
22
|
sqlLiteral,
|
|
23
23
|
validateCreate,
|
|
24
24
|
validateUpdate
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-6qbca8zn.js";
|
|
26
26
|
import {
|
|
27
27
|
CequreStreamMedia,
|
|
28
28
|
methodNotAllowed,
|
|
29
29
|
notFound,
|
|
30
30
|
toResponse
|
|
31
31
|
} from "./index-mfqj7cwr.js";
|
|
32
|
+
import {
|
|
33
|
+
CequreQueueManager
|
|
34
|
+
} from "./index-7xxm1add.js";
|
|
35
|
+
import {
|
|
36
|
+
CequreError,
|
|
37
|
+
buildErrorResponse,
|
|
38
|
+
extractPathname,
|
|
39
|
+
getConstraintErrorMessage,
|
|
40
|
+
getConstraintErrorStatus,
|
|
41
|
+
parseConstraintError,
|
|
42
|
+
toErrorResponse
|
|
43
|
+
} from "./index-qzzg2p5r.js";
|
|
32
44
|
import {
|
|
33
45
|
CequreErrorLogs,
|
|
34
46
|
CequreKV,
|
|
35
|
-
CequreQueueManager,
|
|
36
47
|
createLogger,
|
|
37
48
|
init_kv,
|
|
38
49
|
init_logger,
|
|
39
50
|
logger
|
|
40
|
-
} from "./index-
|
|
51
|
+
} from "./index-8bhn0nb4.js";
|
|
41
52
|
import {
|
|
42
|
-
CequreError,
|
|
43
53
|
__require,
|
|
44
54
|
__toCommonJS,
|
|
45
|
-
buildErrorResponse,
|
|
46
|
-
extractPathname,
|
|
47
|
-
getConstraintErrorMessage,
|
|
48
|
-
getConstraintErrorStatus,
|
|
49
|
-
parseConstraintError,
|
|
50
|
-
toErrorResponse,
|
|
51
55
|
ulid
|
|
52
|
-
} from "./index-
|
|
56
|
+
} from "./index-cpw1bjf1.js";
|
|
53
57
|
|
|
54
58
|
// shared/main/sse.ts
|
|
55
59
|
var encoder = new TextEncoder;
|
|
@@ -2532,8 +2536,13 @@ class CequreRuntime {
|
|
|
2532
2536
|
result[f.name] = f.default;
|
|
2533
2537
|
}
|
|
2534
2538
|
const v = result[f.name];
|
|
2535
|
-
if (v !== undefined &&
|
|
2536
|
-
|
|
2539
|
+
if (v !== undefined && v !== null) {
|
|
2540
|
+
if (typeof v === "string" && !isEncrypted(v)) {
|
|
2541
|
+
result[f.name] = await encryptField(key, v);
|
|
2542
|
+
} else if (typeof v !== "string") {
|
|
2543
|
+
const jsonStr = JSON.stringify(v);
|
|
2544
|
+
result[f.name] = await encryptField(key, jsonStr);
|
|
2545
|
+
}
|
|
2537
2546
|
}
|
|
2538
2547
|
}
|
|
2539
2548
|
}
|
|
@@ -2553,8 +2562,13 @@ class CequreRuntime {
|
|
|
2553
2562
|
for (const [k, v] of Object.entries(result)) {
|
|
2554
2563
|
if (encFields.has(k) && typeof v === "string" && isEncrypted(v)) {
|
|
2555
2564
|
const decrypted = await decryptField(key, v);
|
|
2556
|
-
if (decrypted !== null)
|
|
2557
|
-
|
|
2565
|
+
if (decrypted !== null) {
|
|
2566
|
+
try {
|
|
2567
|
+
result[k] = JSON.parse(decrypted);
|
|
2568
|
+
} catch {
|
|
2569
|
+
result[k] = decrypted;
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2558
2572
|
}
|
|
2559
2573
|
}
|
|
2560
2574
|
return result;
|
|
@@ -2826,8 +2840,7 @@ class CequreRuntime {
|
|
|
2826
2840
|
return toErrorResponse(err, req, this.adapter);
|
|
2827
2841
|
}
|
|
2828
2842
|
}
|
|
2829
|
-
async
|
|
2830
|
-
if (false) {}
|
|
2843
|
+
async init() {
|
|
2831
2844
|
for (const plugin of this.plugins) {
|
|
2832
2845
|
if (plugin.onInit) {
|
|
2833
2846
|
await plugin.onInit(this);
|
|
@@ -2852,6 +2865,10 @@ class CequreRuntime {
|
|
|
2852
2865
|
}
|
|
2853
2866
|
await this.syncDatabaseSchema();
|
|
2854
2867
|
await this.buildRoutes();
|
|
2868
|
+
}
|
|
2869
|
+
async start(options = {}) {
|
|
2870
|
+
if (false) {}
|
|
2871
|
+
await this.init();
|
|
2855
2872
|
this.queue.startWorker();
|
|
2856
2873
|
if (process.env.CEQURE_CLI_GENERATE) {
|
|
2857
2874
|
const { generateTypeScriptClientSDK: generateTypeScriptClientSDK2 } = (init_sdk(), __toCommonJS(exports_sdk));
|
|
@@ -3066,7 +3083,7 @@ ${r}${b} |_| ${reset}
|
|
|
3066
3083
|
`;
|
|
3067
3084
|
if (!process.env.CEQURE_DEV) {
|
|
3068
3085
|
console.log(banner);
|
|
3069
|
-
} else {
|
|
3086
|
+
} else if (process.env.CEQURE_VITE_MODE !== "1") {
|
|
3070
3087
|
const p = server ? server.port : options.port;
|
|
3071
3088
|
console.log(`\uD83D\uDE80 Cequre API Framework started gracefully on port ${p}`);
|
|
3072
3089
|
}
|
|
@@ -19,10 +19,11 @@ import {
|
|
|
19
19
|
sqlLiteral,
|
|
20
20
|
validateCreate,
|
|
21
21
|
validateUpdate
|
|
22
|
-
} from "../../index-
|
|
22
|
+
} from "../../index-6qbca8zn.js";
|
|
23
|
+
import"../../index-qzzg2p5r.js";
|
|
23
24
|
import {
|
|
24
25
|
ulid
|
|
25
|
-
} from "../../index-
|
|
26
|
+
} from "../../index-cpw1bjf1.js";
|
|
26
27
|
export {
|
|
27
28
|
validateUpdate,
|
|
28
29
|
validateCreate,
|
|
@@ -24,9 +24,9 @@ export interface CequreConfig {
|
|
|
24
24
|
plugins?: CequrePlugin[];
|
|
25
25
|
email?: import("../core/types").EmailConfig;
|
|
26
26
|
streamStore?: DurableStreamStore;
|
|
27
|
-
/** KV store config for rate limiter. Defaults to memory (single-instance). Use redis for multi-instance. */
|
|
27
|
+
/** KV store config for rate limiter. Defaults to memory (single-instance). Use redis for multi-instance. Use upstash for serverless. */
|
|
28
28
|
kv?: {
|
|
29
|
-
driver: "memory" | "sqlite" | "redis";
|
|
29
|
+
driver: "memory" | "sqlite" | "redis" | "upstash";
|
|
30
30
|
redis?: {
|
|
31
31
|
host?: string;
|
|
32
32
|
port?: number;
|
|
@@ -35,13 +35,17 @@ export interface CequreConfig {
|
|
|
35
35
|
sqlite?: {
|
|
36
36
|
path?: string;
|
|
37
37
|
};
|
|
38
|
+
upstash?: {
|
|
39
|
+
url?: string;
|
|
40
|
+
token?: string;
|
|
41
|
+
};
|
|
38
42
|
};
|
|
39
43
|
serverProvider?: import("../core/types").ServerProvider;
|
|
40
44
|
cronProvider?: import("../core/types").CronProvider;
|
|
41
45
|
realtimeProvider?: import("../core/types").RealtimeProvider;
|
|
42
46
|
}
|
|
43
47
|
import { CequreDurableQueue } from "../utils/durable-queue";
|
|
44
|
-
export declare class CequreRuntime<TCollections extends Record<string, any> = Record<string, any
|
|
48
|
+
export declare class CequreRuntime<TCollections extends Record<string, any> = Record<string, any>, TUser = AuthUser> {
|
|
45
49
|
schema: CequreAST;
|
|
46
50
|
adapter: CequreAdapter;
|
|
47
51
|
router: CequreRouter<TCollections>;
|
|
@@ -181,6 +185,15 @@ export declare class CequreRuntime<TCollections extends Record<string, any> = Re
|
|
|
181
185
|
*/
|
|
182
186
|
cron(name: string, schedule: string, handler: (app: CequreRuntime<TCollections>) => unknown): void;
|
|
183
187
|
fetch(req: Request): Promise<Response>;
|
|
188
|
+
/**
|
|
189
|
+
* Initialize the runtime without starting a server. Used by serverless
|
|
190
|
+
* platforms (Vercel, Cloudflare) where the platform handles invocation.
|
|
191
|
+
* Runs: plugin init → adapter connect → schema sync → route building.
|
|
192
|
+
* Does NOT start: server, queue worker, cron scheduler, graceful shutdown.
|
|
193
|
+
*
|
|
194
|
+
* After init(), call `fetch(req)` to handle individual requests.
|
|
195
|
+
*/
|
|
196
|
+
init(): Promise<void>;
|
|
184
197
|
start(options?: {
|
|
185
198
|
port?: number;
|
|
186
199
|
drainTimeoutMs?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type KVDriverType = "memory" | "sqlite" | "redis";
|
|
1
|
+
export type KVDriverType = "memory" | "sqlite" | "redis" | "upstash";
|
|
2
2
|
export interface KVOptions {
|
|
3
3
|
/** The storage driver to use. Default: "sqlite" */
|
|
4
4
|
driver?: KVDriverType;
|
|
@@ -17,6 +17,13 @@ export interface KVOptions {
|
|
|
17
17
|
/** Redis connection URL. Default: "redis://localhost:6379" */
|
|
18
18
|
url?: string;
|
|
19
19
|
};
|
|
20
|
+
/** Configuration for the Upstash Redis driver (HTTP-based, serverless) */
|
|
21
|
+
upstash?: {
|
|
22
|
+
/** Upstash Redis REST URL */
|
|
23
|
+
url?: string;
|
|
24
|
+
/** Upstash Redis REST token */
|
|
25
|
+
token?: string;
|
|
26
|
+
};
|
|
20
27
|
}
|
|
21
28
|
export interface KVAdapter {
|
|
22
29
|
get<T>(key: string): Promise<T | null> | T | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cequrebackends/cequre-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "The Cequre Universal Runtime Engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"types": "./dist/adapters/node/index.d.ts",
|
|
27
27
|
"import": "./dist/adapters/node/index.js",
|
|
28
28
|
"default": "./dist/adapters/node/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./adapters/vercel": {
|
|
31
|
+
"types": "./dist/adapters/vercel/index.d.ts",
|
|
32
|
+
"import": "./dist/adapters/vercel/index.js",
|
|
33
|
+
"default": "./dist/adapters/vercel/index.js"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"files": [
|
|
@@ -40,7 +45,7 @@
|
|
|
40
45
|
"url": "https://github.com/cequrebackends/cequre.git"
|
|
41
46
|
},
|
|
42
47
|
"scripts": {
|
|
43
|
-
"build": "rm -rf dist && bun build ./index.ts ./shared/core/index.ts ./adapters/bun/index.ts ./adapters/node/index.ts --outdir ./dist --target bun --packages external --splitting --format esm && tsc --emitDeclarationOnly"
|
|
48
|
+
"build": "rm -rf dist && bun build ./index.ts ./shared/core/index.ts ./adapters/bun/index.ts ./adapters/node/index.ts ./adapters/vercel/index.ts --outdir ./dist --target bun --packages external --splitting --format esm && tsc --emitDeclarationOnly"
|
|
44
49
|
},
|
|
45
50
|
"dependencies": {
|
|
46
51
|
"@sinclair/typebox": "^0.34.49",
|