postgresdk 0.6.4 → 0.6.6
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/cli.js +535 -14
- package/dist/emit-api-contract.d.ts +60 -0
- package/dist/emit-tests.d.ts +8 -0
- package/dist/index.js +535 -14
- package/package.json +2 -1
@@ -0,0 +1,60 @@
|
|
1
|
+
import type { Model } from "./introspect";
|
2
|
+
import type { Config, AuthConfig } from "./types";
|
3
|
+
export interface ApiContract {
|
4
|
+
version: string;
|
5
|
+
generatedAt: string;
|
6
|
+
description: string;
|
7
|
+
authentication?: {
|
8
|
+
type: string;
|
9
|
+
description: string;
|
10
|
+
};
|
11
|
+
resources: ResourceContract[];
|
12
|
+
relationships: RelationshipContract[];
|
13
|
+
}
|
14
|
+
export interface ResourceContract {
|
15
|
+
name: string;
|
16
|
+
tableName: string;
|
17
|
+
description: string;
|
18
|
+
endpoints: EndpointContract[];
|
19
|
+
fields: FieldContract[];
|
20
|
+
}
|
21
|
+
export interface EndpointContract {
|
22
|
+
method: string;
|
23
|
+
path: string;
|
24
|
+
description: string;
|
25
|
+
requestBody?: any;
|
26
|
+
responseBody?: any;
|
27
|
+
queryParameters?: any;
|
28
|
+
}
|
29
|
+
export interface FieldContract {
|
30
|
+
name: string;
|
31
|
+
type: string;
|
32
|
+
required: boolean;
|
33
|
+
description: string;
|
34
|
+
foreignKey?: {
|
35
|
+
table: string;
|
36
|
+
field: string;
|
37
|
+
};
|
38
|
+
}
|
39
|
+
export interface RelationshipContract {
|
40
|
+
from: string;
|
41
|
+
to: string;
|
42
|
+
type: "one-to-many" | "many-to-one" | "many-to-many";
|
43
|
+
description: string;
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* Generate a comprehensive API contract in JSON format
|
47
|
+
*/
|
48
|
+
export declare function generateApiContract(model: Model, config: Config & {
|
49
|
+
auth?: AuthConfig;
|
50
|
+
}): ApiContract;
|
51
|
+
/**
|
52
|
+
* Generate a human-readable markdown version of the contract
|
53
|
+
*/
|
54
|
+
export declare function generateApiContractMarkdown(contract: ApiContract): string;
|
55
|
+
/**
|
56
|
+
* Emit the API contract as TypeScript code that can be served as an endpoint
|
57
|
+
*/
|
58
|
+
export declare function emitApiContract(model: Model, config: Config & {
|
59
|
+
auth?: AuthConfig;
|
60
|
+
}): string;
|
package/dist/emit-tests.d.ts
CHANGED
@@ -7,6 +7,14 @@ export declare function emitTableTest(table: Table, clientPath: string, framewor
|
|
7
7
|
* Generate a test setup file
|
8
8
|
*/
|
9
9
|
export declare function emitTestSetup(clientPath: string, framework?: "vitest" | "jest" | "bun"): string;
|
10
|
+
/**
|
11
|
+
* Generate vitest config file
|
12
|
+
*/
|
13
|
+
export declare function emitVitestConfig(): string;
|
14
|
+
/**
|
15
|
+
* Generate .gitignore for test directory
|
16
|
+
*/
|
17
|
+
export declare function emitTestGitignore(): string;
|
10
18
|
/**
|
11
19
|
* Generate docker-compose.yml for test database
|
12
20
|
*/
|