postgresdk 0.6.5 → 0.6.7
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 +585 -78
- package/dist/emit-api-contract.d.ts +60 -0
- package/dist/index.js +585 -78
- 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;
|