@zero-server/lifecycle 0.9.7 → 0.9.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero-server/lifecycle",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "Graceful shutdown manager and multi-worker clustering.",
5
5
  "keywords": [
6
6
  "zero-server",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "sideEffects": false,
47
47
  "peerDependencies": {
48
- "@zero-server/sdk": ">=0.9.7"
48
+ "@zero-server/sdk": ">=0.9.8"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "@zero-server/sdk": {
package/types/body.d.ts CHANGED
@@ -1,14 +1,82 @@
1
- // Re-exports for @zero-server/body - body parser types
2
- export {
3
- BodyParserOptions,
4
- JsonParserOptions,
5
- UrlencodedParserOptions,
6
- TextParserOptions,
7
- MultipartOptions,
8
- MultipartFile,
9
- json,
10
- urlencoded,
11
- text,
12
- raw,
13
- multipart,
14
- } from './middleware';
1
+ // TypeScript declarations for the bundled body parsers
2
+ // (`json`, `urlencoded`, `text`, `raw`, `multipart`).
3
+ //
4
+ // These live in `lib/body/*` at runtime and are surfaced both via the
5
+ // top-level SDK and the standalone `@zero-server/body` scope. They are
6
+ // declared here (not in `./middleware`) so the body-parser package has
7
+ // a self-contained declaration file.
8
+
9
+ import { MiddlewareFunction } from './middleware';
10
+ import { Request } from './request';
11
+ import { Response } from './response';
12
+
13
+ export interface BodyParserOptions {
14
+ /** Max body size (e.g. '10kb', '1mb'). Default: '1mb'. */
15
+ limit?: string | number;
16
+ /** Content-Type(s) to match. Accepts a string, an array of strings, or a predicate function. */
17
+ type?: string | string[] | ((ct: string) => boolean);
18
+ /** Reject non-HTTPS requests with 403. */
19
+ requireSecure?: boolean;
20
+ /**
21
+ * Verification callback invoked with the raw buffer before parsing.
22
+ * Throw an error to reject the request with 403.
23
+ * Useful for webhook signature verification (e.g. Stripe, GitHub).
24
+ */
25
+ verify?: (req: Request, res: Response, buf: Buffer, encoding: string) => void;
26
+ /** Decompress gzip/deflate/br request bodies. Default: true. When false, compressed bodies return 415. */
27
+ inflate?: boolean;
28
+ }
29
+
30
+ export interface JsonParserOptions extends BodyParserOptions {
31
+ /** JSON.parse reviver function. */
32
+ reviver?: (key: string, value: any) => any;
33
+ /** Reject non-object/array roots. Default: true. */
34
+ strict?: boolean;
35
+ }
36
+
37
+ export interface UrlencodedParserOptions extends BodyParserOptions {
38
+ /** Enable nested bracket parsing. Default: false. */
39
+ extended?: boolean;
40
+ /** Max number of parameters. Default: 1000. Prevents parameter flooding DoS. */
41
+ parameterLimit?: number;
42
+ /** Max nesting depth for bracket syntax. Default: 32. Prevents deep-nesting DoS. */
43
+ depth?: number;
44
+ }
45
+
46
+ export interface TextParserOptions extends BodyParserOptions {
47
+ /** Fallback character encoding when Content-Type has no charset. Default: 'utf8'. */
48
+ encoding?: BufferEncoding;
49
+ }
50
+
51
+ export interface MultipartOptions {
52
+ /** Upload directory (default: OS temp). */
53
+ dir?: string;
54
+ /** Maximum size per file in bytes. */
55
+ maxFileSize?: number;
56
+ /** Reject non-HTTPS requests with 403. */
57
+ requireSecure?: boolean;
58
+ /** Maximum number of non-file fields. Default: 1000. */
59
+ maxFields?: number;
60
+ /** Maximum number of uploaded files. Default: 10. */
61
+ maxFiles?: number;
62
+ /** Maximum size of a single field value in bytes. Default: 1 MB. */
63
+ maxFieldSize?: number;
64
+ /** Whitelist of allowed MIME types for uploaded files (e.g. ['image/png', 'image/jpeg']). */
65
+ allowedMimeTypes?: string[];
66
+ /** Maximum combined size of all uploaded files in bytes. */
67
+ maxTotalSize?: number;
68
+ }
69
+
70
+ export interface MultipartFile {
71
+ originalFilename: string;
72
+ storedName: string;
73
+ path: string;
74
+ contentType: string;
75
+ size: number;
76
+ }
77
+
78
+ export function json(options?: JsonParserOptions): MiddlewareFunction;
79
+ export function urlencoded(options?: UrlencodedParserOptions): MiddlewareFunction;
80
+ export function text(options?: TextParserOptions): MiddlewareFunction;
81
+ export function raw(options?: BodyParserOptions): MiddlewareFunction;
82
+ export function multipart(options?: MultipartOptions): MiddlewareFunction;
package/types/cli.d.ts CHANGED
@@ -1,2 +1,40 @@
1
- // Re-exports for @zero-server/cli - CLI runner types
2
- export { CLI, runCLI } from './orm';
1
+ // TypeScript declarations for the bundled CLI runner (`zs` / `zh`).
2
+ //
3
+ // The CLI lives in `lib/cli.js` and is published both as the `zs` /
4
+ // `zh` bin scripts and as a programmatic API on the SDK. It dispatches
5
+ // ORM subcommands (`migrate`, `seed`, `make:*`) to `@zero-server/orm`
6
+ // and `webrtc:*` subcommands to `@zero-server/webrtc`, but the runner
7
+ // itself is scope-neutral - hence its own declaration file.
8
+
9
+ /**
10
+ * CLI runner for the bundled `zs` command.
11
+ *
12
+ * Parses `process.argv`-style input, resolves a config file
13
+ * (`zero.config.js` / `.zero-server.js` / `.zero-http.js`), and
14
+ * dispatches to the matching subcommand handler.
15
+ */
16
+ export class CLI {
17
+ constructor(argv?: string[]);
18
+
19
+ /** The first positional argument (subcommand name). Defaults to `"help"`. */
20
+ readonly command: string;
21
+
22
+ /** Remaining positional arguments after the subcommand. */
23
+ readonly args: string[];
24
+
25
+ /** Parsed `--flag=value` and `-f value` pairs. */
26
+ readonly flags: Map<string, string>;
27
+
28
+ /** Execute the parsed command. Sets `process.exitCode` on failure. */
29
+ run(): Promise<void>;
30
+ }
31
+
32
+ /**
33
+ * One-shot helper: `new CLI(argv).run()`.
34
+ *
35
+ * @example
36
+ * const { runCLI } = require('@zero-server/sdk');
37
+ * await runCLI(['migrate']);
38
+ * await runCLI(['make:model', 'User', '--dir=src/models']);
39
+ */
40
+ export function runCLI(argv?: string[]): Promise<void>;
package/types/index.d.ts CHANGED
@@ -97,8 +97,8 @@ export {
97
97
  StoredProcedure, StoredProcedureOptions, ProcedureParam,
98
98
  StoredFunction, StoredFunctionOptions,
99
99
  TriggerManager, TriggerDefinition,
100
- CLI, runCLI,
101
100
  } from './orm';
101
+ export { CLI, runCLI } from './cli';
102
102
  // Re-export validate from orm as schemaValidate to avoid collision with middleware validate
103
103
  export { validate as schemaValidate } from './orm';
104
104
  export {
@@ -161,7 +161,8 @@ import { Database, Model, Query } from './orm';
161
161
  import { TYPES, validateFKAction, validateCheck } from './orm';
162
162
  import { Migrator, QueryCache, Seeder, SeederRunner, Factory, Fake, defineMigration } from './orm';
163
163
  import { QueryProfiler, ReplicaManager } from './orm';
164
- import { TenantManager, AuditLog, PluginManager, StoredProcedure, StoredFunction, TriggerManager, CLI, runCLI } from './orm';
164
+ import { TenantManager, AuditLog, PluginManager, StoredProcedure, StoredFunction, TriggerManager } from './orm';
165
+ import { CLI, runCLI } from './cli';
165
166
  import { LifecycleManager, LIFECYCLE_STATE } from './lifecycle';
166
167
  import { ClusterManager, cluster as clusterize } from './cluster';
167
168
  import {
@@ -21,77 +21,23 @@ export interface CorsOptions {
21
21
  export function cors(options?: CorsOptions): MiddlewareFunction;
22
22
 
23
23
  // --- Body Parsers ------------------------------------------------
24
-
25
- export interface BodyParserOptions {
26
- /** Max body size (e.g. '10kb', '1mb'). Default: '1mb'. */
27
- limit?: string | number;
28
- /** Content-Type(s) to match. Accepts a string, an array of strings, or a predicate function. */
29
- type?: string | string[] | ((ct: string) => boolean);
30
- /** Reject non-HTTPS requests with 403. */
31
- requireSecure?: boolean;
32
- /**
33
- * Verification callback invoked with the raw buffer before parsing.
34
- * Throw an error to reject the request with 403.
35
- * Useful for webhook signature verification (e.g. Stripe, GitHub).
36
- */
37
- verify?: (req: import('./request').Request, res: import('./response').Response, buf: Buffer, encoding: string) => void;
38
- /** Decompress gzip/deflate/br request bodies. Default: true. When false, compressed bodies return 415. */
39
- inflate?: boolean;
40
- }
41
-
42
- export interface JsonParserOptions extends BodyParserOptions {
43
- /** JSON.parse reviver function. */
44
- reviver?: (key: string, value: any) => any;
45
- /** Reject non-object/array roots. Default: true. */
46
- strict?: boolean;
47
- }
48
-
49
- export interface UrlencodedParserOptions extends BodyParserOptions {
50
- /** Enable nested bracket parsing. Default: false. */
51
- extended?: boolean;
52
- /** Max number of parameters. Default: 1000. Prevents parameter flooding DoS. */
53
- parameterLimit?: number;
54
- /** Max nesting depth for bracket syntax. Default: 32. Prevents deep-nesting DoS. */
55
- depth?: number;
56
- }
57
-
58
- export interface TextParserOptions extends BodyParserOptions {
59
- /** Fallback character encoding when Content-Type has no charset. Default: 'utf8'. */
60
- encoding?: BufferEncoding;
61
- }
62
-
63
- export interface MultipartOptions {
64
- /** Upload directory (default: OS temp). */
65
- dir?: string;
66
- /** Maximum size per file in bytes. */
67
- maxFileSize?: number;
68
- /** Reject non-HTTPS requests with 403. */
69
- requireSecure?: boolean;
70
- /** Maximum number of non-file fields. Default: 1000. */
71
- maxFields?: number;
72
- /** Maximum number of uploaded files. Default: 10. */
73
- maxFiles?: number;
74
- /** Maximum size of a single field value in bytes. Default: 1 MB. */
75
- maxFieldSize?: number;
76
- /** Whitelist of allowed MIME types for uploaded files (e.g. ['image/png', 'image/jpeg']). */
77
- allowedMimeTypes?: string[];
78
- /** Maximum combined size of all uploaded files in bytes. */
79
- maxTotalSize?: number;
80
- }
81
-
82
- export interface MultipartFile {
83
- originalFilename: string;
84
- storedName: string;
85
- path: string;
86
- contentType: string;
87
- size: number;
88
- }
89
-
90
- export function json(options?: JsonParserOptions): MiddlewareFunction;
91
- export function urlencoded(options?: UrlencodedParserOptions): MiddlewareFunction;
92
- export function text(options?: TextParserOptions): MiddlewareFunction;
93
- export function raw(options?: BodyParserOptions): MiddlewareFunction;
94
- export function multipart(options?: MultipartOptions): MiddlewareFunction;
24
+ // Declarations live in `./body` so the standalone `@zero-server/body`
25
+ // package has its own self-contained type file. Re-exported here so
26
+ // callers using the aggregate middleware surface continue to work.
27
+
28
+ export {
29
+ BodyParserOptions,
30
+ JsonParserOptions,
31
+ UrlencodedParserOptions,
32
+ TextParserOptions,
33
+ MultipartOptions,
34
+ MultipartFile,
35
+ json,
36
+ urlencoded,
37
+ text,
38
+ raw,
39
+ multipart,
40
+ } from './body';
95
41
 
96
42
  // --- Rate Limiting -----------------------------------------------
97
43
 
package/types/orm.d.ts CHANGED
@@ -1875,13 +1875,4 @@ export class TriggerManager {
1875
1875
  get(name: string): TriggerDefinition | undefined;
1876
1876
  }
1877
1877
 
1878
- // --- CLI (Phase 4) --------------------------------------------------
1879
-
1880
- export class CLI {
1881
- constructor(argv?: string[]);
1882
- /** Run the CLI command. */
1883
- run(): Promise<void>;
1884
- }
1885
-
1886
- /** Create and run the CLI. */
1887
- export function runCLI(argv?: string[]): Promise<void>;
1878
+ // CLI declarations live in `./cli` (re-exported from `./index`).