-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.json
More file actions
1270 lines (1270 loc) · 38 KB
/
schema.json
File metadata and controls
1270 lines (1270 loc) · 38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/mpyw/sql-http-proxy/internal/config/schema.json",
"title": "sql-http-proxy configuration",
"description": "Configuration file schema for sql-http-proxy. Define HTTP endpoints that map to SQL queries or mock data.",
"type": "object",
"properties": {
"global_helpers": {
"title": "Global Helpers",
"oneOf": [
{
"title": "Inline JavaScript (string)",
"type": "string",
"minLength": 1,
"description": "Inline JavaScript helpers (shorthand for global_helpers.js)",
"examples": [
"function requireInt(v) { return parseInt(v) || 0; }"
]
},
{
"title": "JavaScript Files (object)",
"type": "object",
"properties": {
"js": {
"title": "Inline JavaScript",
"type": "string",
"minLength": 1,
"description": "Inline JavaScript helper code",
"examples": [
"function validate(x) { if (!x) throw { status: 400, body: { error: 'required' } }; return x; }"
]
},
"js_files": {
"title": "JavaScript File Paths",
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"title": "JavaScript File Path",
"description": "Path to JavaScript helper file",
"examples": [
"./helpers/validation.js"
]
},
"minItems": 1,
"description": "Paths to JavaScript helper files (relative to config file)",
"examples": [
[
"./helpers/validation.js",
"./helpers/auth.js"
]
]
}
},
"anyOf": [
{
"required": [
"js"
]
},
{
"required": [
"js_files"
]
}
],
"additionalProperties": false,
"description": "Object form with js and/or js_files"
}
],
"description": "Global JavaScript helpers available in all JS contexts (pre, post, mock JS, filter, csv.value_parser)"
},
"csv": {
"title": "CSV Config",
"type": "object",
"properties": {
"value_parser": {
"title": "CSV Value Parser",
"type": "string",
"minLength": 1,
"description": "JavaScript code to parse each CSV cell value. Receives 'value' (string). Should return the parsed value.",
"examples": [
"if (value === 'true') return true;\nif (value === 'false') return false;\nif (/^\\d+$/.test(value)) return parseInt(value);\nreturn value;"
]
}
},
"additionalProperties": false,
"description": "Global CSV parsing configuration for mock csv and csv_file sources"
},
"database": {
"title": "Database Configuration",
"type": "object",
"properties": {
"dsn": {
"title": "DSN (Data Source Name)",
"type": "string",
"minLength": 1,
"description": "Database connection string. Supports ${VAR}, $VAR, ${VAR:-default} environment variable expansion.",
"examples": [
"postgres://user:pass@localhost:5432/mydb?sslmode=disable",
"mysql://user:pass@tcp(localhost:3306)/mydb",
"sqlite:./data.db",
"postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST:-localhost}:5432/mydb"
]
},
"init": {
"title": "Database Initialization",
"oneOf": [
{
"title": "Inline SQL (string)",
"type": "string",
"minLength": 1,
"description": "Inline SQL to execute on startup (e.g., CREATE TABLE statements)",
"examples": [
"CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)"
]
},
{
"title": "SQL Configuration (object)",
"type": "object",
"properties": {
"sql": {
"title": "Inline SQL",
"type": "string",
"minLength": 1,
"description": "Inline SQL to execute on startup"
},
"sql_files": {
"title": "SQL File Paths",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"minItems": 1,
"description": "Paths to SQL files to execute on startup (relative to config file)",
"examples": [
[
"./migrations/001_init.sql",
"./migrations/002_seed.sql"
]
]
}
},
"anyOf": [
{
"required": [
"sql"
]
},
{
"required": [
"sql_files"
]
}
],
"additionalProperties": false,
"description": "Object form with sql and/or sql_files"
}
],
"description": "SQL to execute on database connection (e.g., schema creation). Runs once on startup."
}
},
"required": [
"dsn"
],
"additionalProperties": false,
"description": "Database connection configuration. Required unless all endpoints use mock data."
},
"http": {
"title": "HTTP Configuration",
"type": "object",
"properties": {
"cors": {
"title": "CORS Configuration",
"oneOf": [
{
"title": "Enable permissive CORS (boolean)",
"type": "boolean",
"description": "Set to true to enable permissive CORS (Access-Control-Allow-Origin: *)"
},
{
"title": "CORS Configuration (object)",
"type": "object",
"properties": {
"allowed_origins": {
"title": "Allowed Origins",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"minItems": 1,
"description": "List of allowed origins. Use '*' for all origins (not recommended for production).",
"examples": [
[
"https://example.com",
"https://app.example.com"
],
[
"*"
]
]
},
"allow_credentials": {
"title": "Allow Credentials",
"type": "boolean",
"default": false,
"description": "Allow credentials (cookies, authorization headers). Cannot be used with '*' origin."
},
"max_age": {
"title": "Max Age",
"type": "integer",
"minimum": 0,
"description": "How long (in seconds) browsers can cache preflight results. Default: 0 (no caching).",
"examples": [
86400,
3600
]
}
},
"required": [
"allowed_origins"
],
"additionalProperties": false,
"description": "Detailed CORS configuration"
}
],
"description": "CORS configuration. Use true for permissive defaults, or object for fine-grained control."
}
},
"additionalProperties": false,
"description": "HTTP server configuration including CORS settings."
},
"queries": {
"title": "Queries",
"type": "array",
"items": {
"title": "Query",
"oneOf": [
{
"$ref": "#/$defs/queryOne"
},
{
"$ref": "#/$defs/queryMany"
}
]
},
"minItems": 1,
"description": "List of query endpoints for SELECT operations. Each query maps an HTTP path to a SQL SELECT or mock data."
},
"mutations": {
"title": "Mutations",
"type": "array",
"items": {
"title": "Mutation",
"oneOf": [
{
"$ref": "#/$defs/mutationOne"
},
{
"$ref": "#/$defs/mutationMany"
},
{
"$ref": "#/$defs/mutationNone"
}
]
},
"minItems": 1,
"description": "List of mutation endpoints for INSERT/UPDATE/DELETE operations. Each mutation maps an HTTP path to a SQL statement or mock data."
}
},
"anyOf": [
{
"required": [
"queries"
]
},
{
"required": [
"mutations"
]
}
],
"additionalProperties": false,
"$defs": {
"path": {
"title": "Endpoint Path",
"type": "string",
"pattern": "^/",
"description": "HTTP endpoint path. Must start with /. Supports path parameters with :param syntax (e.g., /users/:id).",
"examples": [
"/users",
"/users/:id",
"/users/:user_id/posts/:post_id",
"/api/v1/products"
]
},
"sql": {
"title": "SQL Query",
"type": "string",
"minLength": 1,
"description": "SQL query or statement with named placeholders using :name syntax. Placeholders are replaced with request parameters.",
"examples": [
"SELECT * FROM users WHERE id = :id",
"SELECT * FROM users WHERE status = :status ORDER BY created_at DESC LIMIT :limit",
"INSERT INTO users (name, email) VALUES (:name, :email) RETURNING *",
"UPDATE users SET name = :name WHERE id = :id RETURNING *",
"DELETE FROM users WHERE id = :id"
]
},
"method": {
"title": "HTTP Method (Mutation)",
"type": "string",
"enum": [
"POST",
"PUT",
"PATCH",
"DELETE"
],
"default": "POST",
"description": "HTTP method for mutation endpoint. POST: create, PUT: replace, PATCH: partial update, DELETE: delete.",
"examples": [
"POST",
"PUT",
"PATCH",
"DELETE"
]
},
"queryMethod": {
"title": "HTTP Method (Query)",
"type": "string",
"enum": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"default": "GET",
"description": "HTTP method for query endpoint. GET is default. Use POST for complex parameters in request body.",
"examples": [
"GET",
"POST"
]
},
"accepts": {
"title": "Accepted Content-Types",
"oneOf": [
{
"title": "Single Content-Type",
"type": "string",
"enum": [
"json",
"form"
],
"description": "Accept single content type. json: application/json, form: application/x-www-form-urlencoded"
},
{
"title": "Multiple Content-Types",
"type": "array",
"items": {
"type": "string",
"enum": [
"json",
"form"
],
"title": "Content-Type",
"description": "Content type identifier"
},
"description": "Accept multiple content types. Empty array means no body accepted."
}
],
"default": [
"json",
"form"
],
"description": "Accepted Content-Types for request body. json: application/json, form: application/x-www-form-urlencoded. Returns 415 if not matched.",
"examples": [
"json",
"form",
[
"json",
"form"
]
]
},
"preTransform": {
"title": "Pre-Transform",
"type": "string",
"minLength": 1,
"description": "JavaScript to validate/transform input before SQL/mock execution. Receives: input (param), ctx (free var, shared state), sql (free var, modifiable). Must return: object with parameters for SQL/mock.",
"examples": [
"return { id: parseInt(input.id) };",
"ctx.startTime = Date.now();\nif (!input.id) throw { status: 400, body: { error: 'id required' } };\nreturn { id: parseInt(input.id) };",
"sql += ' WHERE status = :status';\nreturn { ...input, status: 'active' };"
]
},
"postTransformOne": {
"title": "Post-Transform (type: one)",
"type": "string",
"minLength": 1,
"description": "JavaScript to transform single row result. Receives: input (param, original request), output (param, query result), ctx (free var, shared state). Must return: transformed output.",
"examples": [
"return { ...output, formatted: true };",
"return { id: output.id, fullName: output.first_name + ' ' + output.last_name, processingTime: Date.now() - ctx.startTime };"
]
},
"postTransformMany": {
"title": "Post-Transform (type: many)",
"oneOf": [
{
"title": "Transform All (string shorthand)",
"type": "string",
"minLength": 1,
"description": "JavaScript to transform entire array. Receives: input, output (params), ctx (free var). Returns: transformed output.",
"examples": [
"return { data: output, count: output.length };",
"return output.map(row => ({ ...row, processed: true }));"
]
},
{
"title": "Transform Each/All (object)",
"type": "object",
"properties": {
"each": {
"title": "Transform Each Row",
"type": "string",
"minLength": 1,
"description": "JavaScript to transform each row individually. Receives: input, output (params, output is current row), ctx (free var). Returns: transformed row.",
"examples": [
"return { ...output, fullName: output.first_name + ' ' + output.last_name };",
"return { id: output.id, name: output.name.toUpperCase() };"
]
},
"all": {
"title": "Transform All Rows",
"type": "string",
"minLength": 1,
"description": "JavaScript to transform entire array after each transform. Receives: input, output (params, output is array), ctx (free var). Returns: transformed output.",
"examples": [
"return { items: output, total: output.length };",
"return { data: output, meta: { count: output.length, limit: ctx.limit } };"
]
}
},
"additionalProperties": false,
"description": "Object with each (per-row transform) and/or all (array transform). If both specified, each runs first."
}
],
"description": "JavaScript to transform array results. Can be string (transform all) or object with each/all."
},
"filter": {
"title": "Filter",
"type": "string",
"minLength": 1,
"description": "JavaScript to filter array data rows. Receives: row (param, current row), input (param, request parameters), ctx (free var, shared state). Must return: boolean (true to include row).",
"examples": [
"return row.id == parseInt(input.id)",
"return row.status === input.status",
"return !input.role || row.role === input.role"
]
},
"delay": {
"title": "Response Delay",
"type": "string",
"pattern": "^[0-9]+(ns|us|µs|ms|s|m|h)$",
"description": "Artificial delay before returning response. Uses Go duration format (e.g., '100ms', '1s', '500µs').",
"examples": [
"100ms",
"1s",
"500ms",
"2s"
]
},
"mockOneObject": {
"title": "Mock Object Sources (type: one)",
"type": "object",
"oneOf": [
{
"title": "YAML Object",
"properties": {
"object": {
"title": "Object Data",
"type": "object",
"description": "Inline YAML/JSON object to return",
"examples": [
{
"id": 1,
"name": "Alice",
"email": "alice@example.com"
}
]
}
},
"required": [
"object"
],
"additionalProperties": false,
"description": "Return inline YAML object"
},
{
"title": "JSON String (object)",
"properties": {
"object_json": {
"title": "JSON Object String",
"type": "string",
"minLength": 1,
"description": "JSON string containing a single object",
"examples": [
"{\"id\": 1, \"name\": \"Alice\"}"
]
}
},
"required": [
"object_json"
],
"additionalProperties": false,
"description": "Return object parsed from JSON string"
},
{
"title": "JSON File (object)",
"properties": {
"object_json_file": {
"title": "JSON File Path",
"type": "string",
"minLength": 1,
"description": "Path to JSON file containing a single object (relative to config file)",
"examples": [
"./mocks/user.json",
"./data/config.json"
]
}
},
"required": [
"object_json_file"
],
"additionalProperties": false,
"description": "Return object loaded from JSON file"
},
{
"title": "JavaScript (object)",
"properties": {
"object_js": {
"title": "JavaScript Object Generator",
"type": "string",
"minLength": 1,
"description": "JavaScript code that returns an object. Receives: input (param), ctx (free var), sql (free var). Return null for 404.",
"examples": [
"return { id: parseInt(input.id), name: 'User ' + input.id };",
"if (input.id === '404') return null;\nreturn { id: parseInt(input.id), name: 'Mock User' };"
]
}
},
"required": [
"object_js"
],
"additionalProperties": false,
"description": "Return object generated by JavaScript"
}
],
"description": "Mock data source returning single object for type: one queries/mutations"
},
"mockOneArray": {
"title": "Mock Array Sources with Filter (type: one)",
"type": "object",
"oneOf": [
{
"title": "YAML Array with filter",
"properties": {
"array": {
"title": "Array Data",
"type": "array",
"items": {
"type": "object"
},
"description": "Inline YAML/JSON array of objects",
"examples": [
[
{
"id": 1,
"name": "Alice"
},
{
"id": 2,
"name": "Bob"
}
]
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"array",
"filter"
],
"additionalProperties": false,
"description": "Filter YAML array to find matching row"
},
{
"title": "JSON String (array) with filter",
"properties": {
"array_json": {
"title": "JSON Array String",
"type": "string",
"minLength": 1,
"description": "JSON string containing array of objects",
"examples": [
"[{\"id\": 1, \"name\": \"Alice\"}, {\"id\": 2, \"name\": \"Bob\"}]"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"array_json",
"filter"
],
"additionalProperties": false,
"description": "Filter JSON array string to find matching row"
},
{
"title": "JSON File (array) with filter",
"properties": {
"array_json_file": {
"title": "JSON Array File Path",
"type": "string",
"minLength": 1,
"description": "Path to JSON file containing array of objects",
"examples": [
"./mocks/users.json"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"array_json_file",
"filter"
],
"additionalProperties": false,
"description": "Filter JSON file array to find matching row"
},
{
"title": "CSV with filter",
"properties": {
"csv": {
"title": "Inline CSV Data",
"type": "string",
"minLength": 1,
"description": "Inline CSV data with header row. First line is column names.",
"examples": [
"id,name,email\n1,Alice,alice@example.com\n2,Bob,bob@example.com"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"csv",
"filter"
],
"additionalProperties": false,
"description": "Filter CSV data to find matching row"
},
{
"title": "CSV File with filter",
"properties": {
"csv_file": {
"title": "CSV File Path",
"type": "string",
"minLength": 1,
"description": "Path to CSV file (relative to config file)",
"examples": [
"./mocks/users.csv",
"./data/products.csv"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"csv_file",
"filter"
],
"additionalProperties": false,
"description": "Filter CSV file to find matching row"
},
{
"title": "JSONL with filter",
"properties": {
"jsonl": {
"title": "Inline JSONL Data",
"type": "string",
"minLength": 1,
"description": "Inline JSONL data (one JSON object per line)",
"examples": [
"{\"id\": 1, \"name\": \"Alice\"}\n{\"id\": 2, \"name\": \"Bob\"}"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"jsonl",
"filter"
],
"additionalProperties": false,
"description": "Filter JSONL data to find matching row"
},
{
"title": "JSONL File with filter",
"properties": {
"jsonl_file": {
"title": "JSONL File Path",
"type": "string",
"minLength": 1,
"description": "Path to JSONL file (one JSON object per line)",
"examples": [
"./mocks/users.jsonl",
"./logs/events.jsonl"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"jsonl_file",
"filter"
],
"additionalProperties": false,
"description": "Filter JSONL file to find matching row"
}
],
"description": "Mock array source with required filter for type: one. Filter selects the first matching row (404 if none match)."
},
"mockOne": {
"title": "Mock (type: one)",
"oneOf": [
{
"$ref": "#/$defs/mockOneObject"
},
{
"$ref": "#/$defs/mockOneArray"
}
],
"description": "Mock data source for type: one. Either object sources (return single object) or array sources with filter (select matching row)."
},
"mockMany": {
"title": "Mock (type: many)",
"type": "object",
"oneOf": [
{
"title": "YAML Array",
"properties": {
"array": {
"title": "Array Data",
"type": "array",
"items": {
"type": "object"
},
"description": "Inline YAML/JSON array of objects",
"examples": [
[
{
"id": 1,
"name": "Alice"
},
{
"id": 2,
"name": "Bob"
}
]
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"array"
],
"additionalProperties": false,
"description": "Return YAML array (optionally filtered)"
},
{
"title": "JSON String (array)",
"properties": {
"array_json": {
"title": "JSON Array String",
"type": "string",
"minLength": 1,
"description": "JSON string containing array of objects",
"examples": [
"[{\"id\": 1}, {\"id\": 2}]"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"array_json"
],
"additionalProperties": false,
"description": "Return array parsed from JSON string (optionally filtered)"
},
{
"title": "JSON File (array)",
"properties": {
"array_json_file": {
"title": "JSON Array File Path",
"type": "string",
"minLength": 1,
"description": "Path to JSON file containing array of objects",
"examples": [
"./mocks/users.json"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"array_json_file"
],
"additionalProperties": false,
"description": "Return array loaded from JSON file (optionally filtered)"
},
{
"title": "JavaScript (array)",
"properties": {
"array_js": {
"title": "JavaScript Array Generator",
"type": "string",
"minLength": 1,
"description": "JavaScript code that returns an array. Receives: input (param), ctx (free var), sql (free var).",
"examples": [
"return [{ id: 1, name: 'User 1' }, { id: 2, name: 'User 2' }];",
"const count = parseInt(input.count) || 5;\nreturn Array.from({ length: count }, (_, i) => ({ id: i + 1, name: 'User ' + (i + 1) }));"
]
}
},
"required": [
"array_js"
],
"additionalProperties": false,
"description": "Return array generated by JavaScript"
},
{
"title": "CSV",
"properties": {
"csv": {
"title": "Inline CSV Data",
"type": "string",
"minLength": 1,
"description": "Inline CSV data with header row",
"examples": [
"id,name,role\n1,Alice,admin\n2,Bob,user\n3,Charlie,admin"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"csv"
],
"additionalProperties": false,
"description": "Return array parsed from CSV data (optionally filtered)"
},
{
"title": "CSV File",
"properties": {
"csv_file": {
"title": "CSV File Path",
"type": "string",
"minLength": 1,
"description": "Path to CSV file",
"examples": [
"./mocks/users.csv"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"csv_file"
],
"additionalProperties": false,
"description": "Return array loaded from CSV file (optionally filtered)"
},
{
"title": "JSONL",
"properties": {
"jsonl": {
"title": "Inline JSONL Data",
"type": "string",
"minLength": 1,
"description": "Inline JSONL data (one JSON object per line)",
"examples": [
"{\"id\": 1, \"level\": \"info\"}\n{\"id\": 2, \"level\": \"error\"}"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"jsonl"
],
"additionalProperties": false,
"description": "Return array parsed from JSONL data (optionally filtered)"
},
{
"title": "JSONL File",
"properties": {
"jsonl_file": {
"title": "JSONL File Path",
"type": "string",
"minLength": 1,
"description": "Path to JSONL file",
"examples": [
"./mocks/logs.jsonl"
]
},
"filter": {
"$ref": "#/$defs/filter"
}
},
"required": [
"jsonl_file"
],
"additionalProperties": false,
"description": "Return array loaded from JSONL file (optionally filtered)"
}
],
"description": "Mock data source for type: many. Returns array of objects. Filter is optional."
},
"transformOne": {
"title": "Transform (type: one)",
"type": "object",
"properties": {
"pre": {
"$ref": "#/$defs/preTransform"
},
"post": {
"$ref": "#/$defs/postTransformOne"
}
},
"additionalProperties": false,
"description": "Transform configuration for type: one queries/mutations. Pre runs before SQL/mock, post transforms the result."
},
"transformMany": {
"title": "Transform (type: many)",
"type": "object",
"properties": {
"pre": {
"$ref": "#/$defs/preTransform"
},
"post": {
"$ref": "#/$defs/postTransformMany"
}
},
"additionalProperties": false,
"description": "Transform configuration for type: many queries/mutations. Pre runs before SQL/mock, post transforms the results."
},
"postTransformNone": {
"title": "Post-Transform (type: none)",
"type": "string",
"minLength": 1,
"description": "JavaScript to run after SQL/mock execution. Receives: input (param), ctx (free var). Can set response headers. Return value is ignored.",
"examples": [
"response.headers.set('X-Custom', 'value');",
"response.status = 204;"
]
},
"transformNone": {
"title": "Transform (type: none)",
"type": "object",
"properties": {
"pre": {
"$ref": "#/$defs/preTransform"
},
"post": {
"$ref": "#/$defs/postTransformNone"
}
},
"additionalProperties": false,
"description": "Transform configuration for type: none mutations. Post-transform can set response headers but return value is ignored."
},