File tree Expand file tree Collapse file tree 4 files changed +70
-1
lines changed Expand file tree Collapse file tree 4 files changed +70
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Authoring plugins
2
+
3
+ ## Process plugins
4
+
5
+ To use process-based plugins, you must be using [ Version
6
+ 2] ( ../reference/config.html ) of the configuration file. The top-level ` plugins `
7
+ array defines the available plugins and maps them to an executable on the system.
8
+
9
+ In the ` codegen ` section, the ` out ` field dictates what directory will contain
10
+ the new files. The ` plugin ` key must reference a plugin defined in the
11
+ top-level ` plugins ` map. The ` options ` are serialized to a string and passed on
12
+ to the plugin itself.
13
+
14
+ ``` json
15
+ {
16
+ "version" : " 2" ,
17
+ "plugins" : [
18
+ {
19
+ "name" : " jsonb" ,
20
+ "process" : {
21
+ "cmd" : " sqlc-gen-json"
22
+ }
23
+ }
24
+ ],
25
+ "sql" : [
26
+ {
27
+ "schema" : " schema.sql" ,
28
+ "queries" : " query.sql" ,
29
+ "engine" : " postgresql" ,
30
+ "codegen" : [
31
+ {
32
+ "out" : " gen" ,
33
+ "plugin" : " jsonb" ,
34
+ "options" : {
35
+ "indent" : " " ,
36
+ "filename" : " codegen.json"
37
+ }
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ }
43
+ ```
44
+
45
+ For a complete working example see the following files:
46
+ - [ sqlc-gen-json] ( https://github.com/kyleconroy/sqlc/tree/main/cmd/sqlc-gen-json )
47
+ - A process-based plugin that serializes the CodeGenRequest to JSON
48
+ - [ process_plugin_sqlc_gen_json] ( https://github.com/kyleconroy/sqlc/tree/main/internal/endtoend/testdata/process_plugin_sqlc_gen_json )
49
+ - An example project showing how to use a process-based plugin
50
+
51
+ ### Security
52
+
53
+ Process-based plugins offer minimal security. Only use plugins that you trust.
54
+ Better yet, only use plugins that you've written yourself.
55
+
56
+ ## WASM plugins
57
+
58
+ * Coming soon!*
Original file line number Diff line number Diff line change @@ -74,4 +74,5 @@ code ever again.
74
74
:hidden:
75
75
76
76
guides/development.md
77
+ guides/plugins.md
77
78
guides/privacy.md
Original file line number Diff line number Diff line change @@ -120,6 +120,16 @@ The `gen` mapping supports the following keys:
120
120
- Filename for the generated JSON document. Defaults to `codegen_request.json`.
121
121
- `indent`:
122
122
- Indent string to use in the JSON document. Defaults to ` `.
123
+
124
+ ### plugins
125
+
126
+ Each mapping in the `plugins` collection has the following keys:
127
+
128
+ - `name`:
129
+ - The name of this plugin. Required
130
+ - `process`:
131
+ - `cmd`:
132
+ - The executable to call when using this plugin
123
133
124
134
## Version 1
125
135
Original file line number Diff line number Diff line change 1
- Database and Language Support
1
+ Database and language support
2
2
#############################
3
3
4
4
======== ============ ============
You can’t perform that action at this time.
0 commit comments