@vantis/data 0.0.1

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.
@@ -0,0 +1,494 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "additionalProperties": false,
4
+ "definitions": {
5
+ "Access": {
6
+ "description": "Access-control tier for a table. \"private\" is the current supported value. \"public\" (VAN-844) and \"owned\" (Auth block) are reserved for future tiers.",
7
+ "enum": [
8
+ "private"
9
+ ],
10
+ "type": "string"
11
+ },
12
+ "Column": {
13
+ "additionalProperties": false,
14
+ "description": "A single column in a table.",
15
+ "properties": {
16
+ "default": {
17
+ "$ref": "#/definitions/Default",
18
+ "description": "Optional default value for this column."
19
+ },
20
+ "name": {
21
+ "$ref": "#/definitions/Identifier",
22
+ "description": "Column name."
23
+ },
24
+ "nullable": {
25
+ "default": false,
26
+ "description": "Whether the column accepts NULL. Defaults to false (NOT NULL). Incompatible with primary_key:true.",
27
+ "type": "boolean"
28
+ },
29
+ "primary_key": {
30
+ "default": false,
31
+ "description": "Whether this column is (part of) the primary key. Primary-key columns are implicitly NOT NULL.",
32
+ "type": "boolean"
33
+ },
34
+ "searchable": {
35
+ "default": false,
36
+ "description": "Whether this column participates in full-text search. Requires spec version 2 and a text or varchar column type.",
37
+ "type": "boolean"
38
+ },
39
+ "type": {
40
+ "$ref": "#/definitions/ColumnTypeName",
41
+ "description": "Column type."
42
+ },
43
+ "unique": {
44
+ "default": false,
45
+ "description": "Whether this column has a UNIQUE constraint.",
46
+ "type": "boolean"
47
+ }
48
+ },
49
+ "required": [
50
+ "name",
51
+ "type"
52
+ ],
53
+ "type": "object"
54
+ },
55
+ "ColumnTypeName": {
56
+ "description": "Closed set of supported Postgres column types.",
57
+ "enum": [
58
+ "bigint",
59
+ "boolean",
60
+ "date",
61
+ "double",
62
+ "integer",
63
+ "jsonb",
64
+ "numeric",
65
+ "real",
66
+ "text",
67
+ "timestamptz",
68
+ "uuid",
69
+ "varchar"
70
+ ],
71
+ "type": "string"
72
+ },
73
+ "Default": {
74
+ "description": "Closed default-value grammar. Raw SQL expressions are intentionally absent — this grammar bounds injection from customer-supplied defaults. Each branch of the discriminated union requires exactly the kind-specific field that the engine enforces.",
75
+ "oneOf": [
76
+ {
77
+ "additionalProperties": false,
78
+ "description": "Default with kind \"bool\". Requires exactly the \"bool\" field.",
79
+ "properties": {
80
+ "bool": {
81
+ "description": "Boolean value. Required when kind is \"bool\".",
82
+ "type": "boolean"
83
+ },
84
+ "kind": {
85
+ "const": "bool",
86
+ "type": "string"
87
+ }
88
+ },
89
+ "required": [
90
+ "kind",
91
+ "bool"
92
+ ],
93
+ "type": "object"
94
+ },
95
+ {
96
+ "additionalProperties": false,
97
+ "description": "Default with kind \"builtin\". Requires exactly the \"builtin\" field from the allowlist.",
98
+ "properties": {
99
+ "builtin": {
100
+ "description": "Allowed built-in function call. Required when kind is \"builtin\".",
101
+ "enum": [
102
+ "gen_random_uuid()",
103
+ "now()"
104
+ ],
105
+ "type": "string"
106
+ },
107
+ "kind": {
108
+ "const": "builtin",
109
+ "type": "string"
110
+ }
111
+ },
112
+ "required": [
113
+ "kind",
114
+ "builtin"
115
+ ],
116
+ "type": "object"
117
+ },
118
+ {
119
+ "additionalProperties": false,
120
+ "description": "Default with kind \"null\". No kind-specific field is permitted.",
121
+ "properties": {
122
+ "kind": {
123
+ "const": "null",
124
+ "type": "string"
125
+ }
126
+ },
127
+ "required": [
128
+ "kind"
129
+ ],
130
+ "type": "object"
131
+ },
132
+ {
133
+ "additionalProperties": false,
134
+ "description": "Default with kind \"number\". Requires exactly the \"number\" field (stored as a string to avoid float-precision issues).",
135
+ "properties": {
136
+ "kind": {
137
+ "const": "number",
138
+ "type": "string"
139
+ },
140
+ "number": {
141
+ "description": "Numeric literal. Required when kind is \"number\". Stored as a string to avoid float-precision issues. Only digits, optional leading minus, optional decimal point.",
142
+ "pattern": "^-?[0-9]+(\\.[0-9]+)?$",
143
+ "type": "string"
144
+ }
145
+ },
146
+ "required": [
147
+ "kind",
148
+ "number"
149
+ ],
150
+ "type": "object"
151
+ },
152
+ {
153
+ "additionalProperties": false,
154
+ "description": "Default with kind \"string\". Requires exactly the \"string\" field.",
155
+ "properties": {
156
+ "kind": {
157
+ "const": "string",
158
+ "type": "string"
159
+ },
160
+ "string": {
161
+ "description": "String literal. Required when kind is \"string\". Must not contain backslash, null byte, carriage return, or newline.",
162
+ "type": "string"
163
+ }
164
+ },
165
+ "required": [
166
+ "kind",
167
+ "string"
168
+ ],
169
+ "type": "object"
170
+ }
171
+ ]
172
+ },
173
+ "DefaultKind": {
174
+ "description": "Discriminant for the Default object. Exactly one kind-specific field must match the kind value.",
175
+ "enum": [
176
+ "bool",
177
+ "builtin",
178
+ "null",
179
+ "number",
180
+ "string"
181
+ ],
182
+ "type": "string"
183
+ },
184
+ "ForeignKey": {
185
+ "additionalProperties": false,
186
+ "description": "A foreign-key constraint from this table to a referenced table in the same spec.",
187
+ "properties": {
188
+ "columns": {
189
+ "description": "Column(s) in this table that form the foreign key. Must not be empty.",
190
+ "items": {
191
+ "$ref": "#/definitions/Identifier"
192
+ },
193
+ "minItems": 1,
194
+ "type": "array"
195
+ },
196
+ "name": {
197
+ "$ref": "#/definitions/Identifier",
198
+ "description": "Foreign-key constraint name."
199
+ },
200
+ "ref_columns": {
201
+ "description": "Column(s) in the referenced table. Must have the same length as columns.",
202
+ "items": {
203
+ "$ref": "#/definitions/Identifier"
204
+ },
205
+ "minItems": 1,
206
+ "type": "array"
207
+ },
208
+ "ref_table": {
209
+ "$ref": "#/definitions/Identifier",
210
+ "description": "Name of the referenced table (must exist in this spec)."
211
+ }
212
+ },
213
+ "required": [
214
+ "columns",
215
+ "name",
216
+ "ref_columns",
217
+ "ref_table"
218
+ ],
219
+ "type": "object"
220
+ },
221
+ "Function": {
222
+ "additionalProperties": false,
223
+ "description": "A customer-authored typed RPC over a Postgres function. Requires spec version 3. The engine always emits SECURITY INVOKER; no Security field is accepted.",
224
+ "properties": {
225
+ "args": {
226
+ "description": "Function arguments (may be empty).",
227
+ "items": {
228
+ "$ref": "#/definitions/FunctionArg"
229
+ },
230
+ "type": "array"
231
+ },
232
+ "body": {
233
+ "description": "PL/pgSQL function body. Raw SQL — not grammar-checked by the schema engine. Must not be empty or exceed 8192 bytes.",
234
+ "minLength": 1,
235
+ "type": "string"
236
+ },
237
+ "name": {
238
+ "$ref": "#/definitions/Identifier",
239
+ "description": "Function name. Reserved prefixes search_ and __vantis_ are rejected; JS meta-keys (then, catch, etc.) are rejected."
240
+ },
241
+ "returns": {
242
+ "$ref": "#/definitions/FunctionReturns",
243
+ "description": "Return shape."
244
+ },
245
+ "timeout_ms": {
246
+ "description": "Statement timeout in milliseconds. 0 means no per-statement override. Range: 0 to 60000.",
247
+ "maximum": 60000,
248
+ "minimum": 0,
249
+ "type": "integer"
250
+ },
251
+ "volatility": {
252
+ "$ref": "#/definitions/Volatility",
253
+ "description": "Function volatility category."
254
+ }
255
+ },
256
+ "required": [
257
+ "body",
258
+ "name",
259
+ "returns",
260
+ "volatility"
261
+ ],
262
+ "type": "object"
263
+ },
264
+ "FunctionArg": {
265
+ "additionalProperties": false,
266
+ "description": "A typed function argument.",
267
+ "properties": {
268
+ "name": {
269
+ "$ref": "#/definitions/Identifier",
270
+ "description": "Argument name."
271
+ },
272
+ "type": {
273
+ "$ref": "#/definitions/ColumnTypeName",
274
+ "description": "Argument type."
275
+ }
276
+ },
277
+ "required": [
278
+ "name",
279
+ "type"
280
+ ],
281
+ "type": "object"
282
+ },
283
+ "FunctionReturnCol": {
284
+ "additionalProperties": false,
285
+ "description": "A column in a \"returns table\" function result.",
286
+ "properties": {
287
+ "name": {
288
+ "$ref": "#/definitions/Identifier",
289
+ "description": "Return column name."
290
+ },
291
+ "type": {
292
+ "$ref": "#/definitions/ColumnTypeName",
293
+ "description": "Return column type."
294
+ }
295
+ },
296
+ "required": [
297
+ "name",
298
+ "type"
299
+ ],
300
+ "type": "object"
301
+ },
302
+ "FunctionReturnKind": {
303
+ "description": "Return shape: \"scalar\" (a single typed value), \"void\" (no return value), or \"table\" (a set of typed rows).",
304
+ "enum": [
305
+ "scalar",
306
+ "table",
307
+ "void"
308
+ ],
309
+ "type": "string"
310
+ },
311
+ "FunctionReturns": {
312
+ "description": "The return shape of a typed RPC function. Each branch of the discriminated union requires exactly the kind-specific field(s) that the engine enforces.",
313
+ "oneOf": [
314
+ {
315
+ "additionalProperties": false,
316
+ "description": "Function returns a single scalar value. Requires the \"scalar\" field; \"columns\" is forbidden.",
317
+ "properties": {
318
+ "kind": {
319
+ "const": "scalar",
320
+ "type": "string"
321
+ },
322
+ "scalar": {
323
+ "$ref": "#/definitions/ColumnTypeName"
324
+ }
325
+ },
326
+ "required": [
327
+ "kind",
328
+ "scalar"
329
+ ],
330
+ "type": "object"
331
+ },
332
+ {
333
+ "additionalProperties": false,
334
+ "description": "Function returns a set of typed rows. Requires a non-empty \"columns\" list; \"scalar\" is forbidden.",
335
+ "properties": {
336
+ "columns": {
337
+ "description": "Return columns. Required when kind is \"table\". Must not be empty.",
338
+ "items": {
339
+ "$ref": "#/definitions/FunctionReturnCol"
340
+ },
341
+ "minItems": 1,
342
+ "type": "array"
343
+ },
344
+ "kind": {
345
+ "const": "table",
346
+ "type": "string"
347
+ }
348
+ },
349
+ "required": [
350
+ "kind",
351
+ "columns"
352
+ ],
353
+ "type": "object"
354
+ },
355
+ {
356
+ "additionalProperties": false,
357
+ "description": "Function returns nothing. No \"scalar\" or \"columns\" fields are permitted.",
358
+ "properties": {
359
+ "kind": {
360
+ "const": "void",
361
+ "type": "string"
362
+ }
363
+ },
364
+ "required": [
365
+ "kind"
366
+ ],
367
+ "type": "object"
368
+ }
369
+ ]
370
+ },
371
+ "Identifier": {
372
+ "description": "A valid Postgres identifier: lowercase letters, digits, and underscores; must start with a letter or underscore; at most 63 bytes (Postgres NAMEDATALEN-1).",
373
+ "maxLength": 63,
374
+ "pattern": "^[a-z_][a-z0-9_]*$",
375
+ "type": "string"
376
+ },
377
+ "Index": {
378
+ "additionalProperties": false,
379
+ "description": "An additional index on a table. Index names must be unique across the entire schema (PostgreSQL shares one relation namespace per schema).",
380
+ "properties": {
381
+ "columns": {
382
+ "description": "Ordered column names included in the index. Must not be empty.",
383
+ "items": {
384
+ "$ref": "#/definitions/Identifier"
385
+ },
386
+ "minItems": 1,
387
+ "type": "array"
388
+ },
389
+ "name": {
390
+ "$ref": "#/definitions/Identifier",
391
+ "description": "Index name. Must be unique across all indexes and table names in the schema."
392
+ },
393
+ "unique": {
394
+ "default": false,
395
+ "description": "Whether this is a UNIQUE index.",
396
+ "type": "boolean"
397
+ }
398
+ },
399
+ "required": [
400
+ "columns",
401
+ "name"
402
+ ],
403
+ "type": "object"
404
+ },
405
+ "Table": {
406
+ "additionalProperties": false,
407
+ "description": "A single table in the schema. Table names must be unique; reserved prefixes search_ and __vantis_ are rejected.",
408
+ "properties": {
409
+ "access": {
410
+ "$ref": "#/definitions/Access",
411
+ "description": "Access-control tier. Defaults to \"private\" when omitted."
412
+ },
413
+ "columns": {
414
+ "description": "Columns in this table. At least one column is required.",
415
+ "items": {
416
+ "$ref": "#/definitions/Column"
417
+ },
418
+ "minItems": 1,
419
+ "type": "array"
420
+ },
421
+ "foreign_keys": {
422
+ "description": "Optional foreign-key constraints on this table.",
423
+ "items": {
424
+ "$ref": "#/definitions/ForeignKey"
425
+ },
426
+ "type": "array"
427
+ },
428
+ "indexes": {
429
+ "description": "Optional additional indexes on this table.",
430
+ "items": {
431
+ "$ref": "#/definitions/Index"
432
+ },
433
+ "type": "array"
434
+ },
435
+ "name": {
436
+ "$ref": "#/definitions/Identifier",
437
+ "description": "Table name."
438
+ }
439
+ },
440
+ "required": [
441
+ "columns",
442
+ "name"
443
+ ],
444
+ "type": "object"
445
+ },
446
+ "Volatility": {
447
+ "description": "PostgreSQL function volatility category.",
448
+ "enum": [
449
+ "immutable",
450
+ "stable",
451
+ "volatile"
452
+ ],
453
+ "type": "string"
454
+ }
455
+ },
456
+ "description": "Vantis declarative schema document (vantis.schema.json). Governs table definitions, column types, indexes, foreign keys, and typed RPC functions. Consumed by `vantis data build`, `plan`, and `apply` (VAN-869, ADR-0048).",
457
+ "properties": {
458
+ "$schema": {
459
+ "const": "https://vantis.build/schema/vantis.schema.json",
460
+ "description": "Optional editor-tooling hint. If present, must be the canonical Vantis schema URL (ExpectedSchemaURL). Accepted and stripped before downstream use by all Vantis consumers (vantis data build / plan / apply / dev-MCP / schema-runner); any other value is rejected with a clear error. Prefer the VS Code json.schemas workspace setting — the VS Code docs note that in-file $schema is VS Code-specific and not part of the JSON Schema specification (VAN-869 item 2, ADR-0048).",
461
+ "type": "string"
462
+ },
463
+ "functions": {
464
+ "description": "Customer-authored typed RPC functions over Postgres. Requires spec version 3.",
465
+ "items": {
466
+ "$ref": "#/definitions/Function"
467
+ },
468
+ "type": "array"
469
+ },
470
+ "tables": {
471
+ "description": "Tables in this schema. At least one table is required.",
472
+ "items": {
473
+ "$ref": "#/definitions/Table"
474
+ },
475
+ "minItems": 1,
476
+ "type": "array"
477
+ },
478
+ "version": {
479
+ "description": "Spec version. 1: base tables. 2: adds the searchable annotation for full-text search. 3: adds typed RPC functions.",
480
+ "enum": [
481
+ 1,
482
+ 2,
483
+ 3
484
+ ],
485
+ "type": "integer"
486
+ }
487
+ },
488
+ "required": [
489
+ "tables",
490
+ "version"
491
+ ],
492
+ "title": "vantis.schema.json",
493
+ "type": "object"
494
+ }