@platformatic/db 2.74.3 → 3.0.0-alpha.2

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.
Files changed (60) hide show
  1. package/config.d.ts +2 -30
  2. package/eslint.config.js +9 -5
  3. package/index.d.ts +56 -31
  4. package/index.js +67 -128
  5. package/lib/application.js +102 -0
  6. package/lib/commands/index.js +59 -0
  7. package/lib/commands/migrations-apply.js +62 -0
  8. package/lib/commands/migrations-create.js +48 -0
  9. package/lib/commands/print-schema.js +30 -0
  10. package/lib/commands/seed.js +72 -0
  11. package/lib/commands/types.js +21 -0
  12. package/lib/errors.js +15 -11
  13. package/lib/generator.js +229 -0
  14. package/lib/{migrator.mjs → migrator.js} +44 -37
  15. package/lib/{root-endpoint/index.js → root.js} +6 -7
  16. package/lib/schema.js +38 -22
  17. package/lib/stackable.js +14 -26
  18. package/lib/{generator/code-templates.js → templates.js} +57 -16
  19. package/lib/types.js +160 -0
  20. package/lib/upgrade.js +8 -12
  21. package/lib/utils.js +12 -23
  22. package/lib/versions/0.18.0.js +3 -5
  23. package/lib/versions/{from-zero-twenty-height-to-will-see.js → 0.28.0.js} +3 -5
  24. package/lib/versions/2.0.0.js +3 -5
  25. package/lib/versions/3.0.0.js +14 -0
  26. package/package.json +20 -28
  27. package/schema.json +9 -154
  28. package/tsconfig.json +16 -6
  29. package/.snapshots/810d795d512560f3863d8db472c81c27/0.json +0 -1
  30. package/.snapshots/810d795d512560f3863d8db472c81c27/1.json +0 -1
  31. package/db.mjs +0 -86
  32. package/help/compile.txt +0 -17
  33. package/help/create.txt +0 -13
  34. package/help/help.txt +0 -11
  35. package/help/migrations apply.txt +0 -45
  36. package/help/migrations create.txt +0 -27
  37. package/help/migrations.txt +0 -4
  38. package/help/schema.txt +0 -25
  39. package/help/seed.txt +0 -36
  40. package/help/start.txt +0 -47
  41. package/help/types.txt +0 -40
  42. package/index.test-d.ts +0 -43
  43. package/lib/adjust-config.js +0 -42
  44. package/lib/create.mjs +0 -89
  45. package/lib/gen-migration.mjs +0 -53
  46. package/lib/gen-schema.mjs +0 -68
  47. package/lib/gen-types.mjs +0 -202
  48. package/lib/generator/README.md +0 -38
  49. package/lib/generator/db-generator.js +0 -262
  50. package/lib/generator.d.ts +0 -7
  51. package/lib/migrate.mjs +0 -87
  52. package/lib/seed.mjs +0 -90
  53. /package/{lib/root-endpoint/public → public}/images/dark_mode.svg +0 -0
  54. /package/{lib/root-endpoint/public → public}/images/favicon.ico +0 -0
  55. /package/{lib/root-endpoint/public → public}/images/light_mode.svg +0 -0
  56. /package/{lib/root-endpoint/public → public}/images/platformatic-logo-dark.svg +0 -0
  57. /package/{lib/root-endpoint/public → public}/images/platformatic-logo-light.svg +0 -0
  58. /package/{lib/root-endpoint/public → public}/images/triangle_dark.svg +0 -0
  59. /package/{lib/root-endpoint/public → public}/images/triangle_light.svg +0 -0
  60. /package/{lib/root-endpoint/public → public}/index.html +0 -0
package/schema.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/db/2.74.3.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/db/3.0.0-alpha.2.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
- "title": "Platformatic DB",
4
+ "title": "Platformatic Database Config",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "basePath": {
@@ -1038,77 +1038,6 @@
1038
1038
  "dir"
1039
1039
  ]
1040
1040
  },
1041
- "metrics": {
1042
- "anyOf": [
1043
- {
1044
- "type": "boolean"
1045
- },
1046
- {
1047
- "type": "object",
1048
- "properties": {
1049
- "port": {
1050
- "anyOf": [
1051
- {
1052
- "type": "integer"
1053
- },
1054
- {
1055
- "type": "string"
1056
- }
1057
- ]
1058
- },
1059
- "hostname": {
1060
- "type": "string"
1061
- },
1062
- "endpoint": {
1063
- "type": "string"
1064
- },
1065
- "server": {
1066
- "type": "string",
1067
- "enum": [
1068
- "own",
1069
- "parent",
1070
- "hide"
1071
- ]
1072
- },
1073
- "defaultMetrics": {
1074
- "type": "object",
1075
- "properties": {
1076
- "enabled": {
1077
- "type": "boolean"
1078
- }
1079
- },
1080
- "required": [
1081
- "enabled"
1082
- ],
1083
- "additionalProperties": false
1084
- },
1085
- "auth": {
1086
- "type": "object",
1087
- "properties": {
1088
- "username": {
1089
- "type": "string"
1090
- },
1091
- "password": {
1092
- "type": "string"
1093
- }
1094
- },
1095
- "additionalProperties": false,
1096
- "required": [
1097
- "username",
1098
- "password"
1099
- ]
1100
- },
1101
- "labels": {
1102
- "type": "object",
1103
- "additionalProperties": {
1104
- "type": "string"
1105
- }
1106
- }
1107
- },
1108
- "additionalProperties": false
1109
- }
1110
- ]
1111
- },
1112
1041
  "types": {
1113
1042
  "type": "object",
1114
1043
  "properties": {
@@ -1222,45 +1151,6 @@
1222
1151
  }
1223
1152
  ]
1224
1153
  }
1225
- },
1226
- "typescript": {
1227
- "anyOf": [
1228
- {
1229
- "type": "object",
1230
- "properties": {
1231
- "enabled": {
1232
- "anyOf": [
1233
- {
1234
- "type": "boolean"
1235
- },
1236
- {
1237
- "type": "string"
1238
- }
1239
- ]
1240
- },
1241
- "tsConfig": {
1242
- "type": "string",
1243
- "resolvePath": true
1244
- },
1245
- "outDir": {
1246
- "type": "string",
1247
- "resolvePath": true
1248
- },
1249
- "flags": {
1250
- "type": "array",
1251
- "items": {
1252
- "type": "string"
1253
- }
1254
- }
1255
- }
1256
- },
1257
- {
1258
- "type": "boolean"
1259
- },
1260
- {
1261
- "type": "string"
1262
- }
1263
- ]
1264
1154
  }
1265
1155
  },
1266
1156
  "additionalProperties": false,
@@ -1277,6 +1167,13 @@
1277
1167
  }
1278
1168
  ]
1279
1169
  },
1170
+ "application": {
1171
+ "type": "object",
1172
+ "properties": {},
1173
+ "additionalProperties": false,
1174
+ "required": [],
1175
+ "default": {}
1176
+ },
1280
1177
  "telemetry": {
1281
1178
  "type": "object",
1282
1179
  "properties": {
@@ -1407,48 +1304,6 @@
1407
1304
  ],
1408
1305
  "additionalProperties": false
1409
1306
  },
1410
- "clients": {
1411
- "type": "array",
1412
- "items": {
1413
- "type": "object",
1414
- "properties": {
1415
- "serviceId": {
1416
- "type": "string"
1417
- },
1418
- "name": {
1419
- "type": "string"
1420
- },
1421
- "type": {
1422
- "type": "string",
1423
- "enum": [
1424
- "openapi",
1425
- "graphql"
1426
- ]
1427
- },
1428
- "path": {
1429
- "type": "string",
1430
- "resolvePath": true
1431
- },
1432
- "schema": {
1433
- "type": "string",
1434
- "resolvePath": true
1435
- },
1436
- "url": {
1437
- "type": "string"
1438
- },
1439
- "fullResponse": {
1440
- "type": "boolean"
1441
- },
1442
- "fullRequest": {
1443
- "type": "boolean"
1444
- },
1445
- "validateResponse": {
1446
- "type": "boolean"
1447
- }
1448
- },
1449
- "additionalProperties": false
1450
- }
1451
- },
1452
1307
  "runtime": {
1453
1308
  "type": "object",
1454
1309
  "properties": {
package/tsconfig.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "module": "CommonJS",
4
- "moduleResolution": "node",
3
+ "module": "commonjs",
5
4
  "esModuleInterop": true,
6
- "allowSyntheticDefaultImports": true,
7
- "target": "es2019",
8
- "outDir": "build",
5
+ "lib": ["es2022"],
6
+ "target": "es2022",
9
7
  "sourceMap": true,
10
- "strictNullChecks": true
8
+ "pretty": true,
9
+ "noEmitOnError": true,
10
+ "incremental": true,
11
+ "strict": true,
12
+ "outDir": "dist",
13
+ "skipLibCheck": true
14
+ },
15
+ "watchOptions": {
16
+ "watchFile": "fixedPollingInterval",
17
+ "watchDirectory": "fixedPollingInterval",
18
+ "fallbackPolling": "dynamicPriority",
19
+ "synchronousWatchDirectory": true,
20
+ "excludeDirectories": ["**/node_modules", "dist"]
11
21
  }
12
22
  }
@@ -1 +0,0 @@
1
- "type Query {\n getGraphById(id: ID!): Graph\n graphs(limit: LimitInt, offset: Int, orderBy: [GraphOrderByArguments], where: GraphWhereArguments): [Graph]\n countGraphs(where: GraphWhereArguments): graphsCount\n}\n\ntype Graph {\n id: ID\n name: String\n}\n\n\"\"\"\nLimit will be applied by default if not passed. If the provided value exceeds the maximum allowed value a validation error will be thrown\n\"\"\"\nscalar LimitInt\n\ninput GraphOrderByArguments {\n field: GraphOrderByField\n direction: OrderByDirection!\n}\n\nenum GraphOrderByField {\n id\n name\n}\n\nenum OrderByDirection {\n ASC\n DESC\n}\n\ninput GraphWhereArguments {\n id: GraphWhereArgumentsid\n name: GraphWhereArgumentsname\n or: [GraphWhereArgumentsOr]\n}\n\ninput GraphWhereArgumentsid {\n eq: ID\n neq: ID\n gt: ID\n gte: ID\n lt: ID\n lte: ID\n like: ID\n in: [ID]\n nin: [ID]\n}\n\ninput GraphWhereArgumentsname {\n eq: String\n neq: String\n gt: String\n gte: String\n lt: String\n lte: String\n like: String\n in: [String]\n nin: [String]\n}\n\ninput GraphWhereArgumentsOr {\n id: GraphWhereArgumentsid\n name: GraphWhereArgumentsname\n}\n\ntype graphsCount {\n total: Int\n}\n\ntype Mutation {\n saveGraph(input: GraphInput!): Graph\n insertGraphs(inputs: [GraphInput]!): [Graph]\n deleteGraphs(where: GraphWhereArguments): [Graph]\n}\n\ninput GraphInput {\n id: ID\n name: String\n}\n\ntype Subscription {\n graphSaved: Graph\n graphDeleted: GraphDeleted\n}\n\ntype GraphDeleted {\n id: ID\n}"
@@ -1 +0,0 @@
1
- "{\n \"openapi\": \"3.0.3\",\n \"info\": {\n \"title\": \"Platformatic DB\",\n \"description\": \"Exposing a SQL database as REST\",\n \"version\": \"1.0.0\"\n },\n \"components\": {\n \"schemas\": {\n \"Graph\": {\n \"title\": \"Graph\",\n \"description\": \"A Graph\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"integer\",\n \"nullable\": true\n },\n \"name\": {\n \"type\": \"string\",\n \"nullable\": true\n }\n },\n \"additionalProperties\": false\n },\n \"GraphInput\": {\n \"title\": \"GraphInput\",\n \"description\": \"A Graph\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"integer\"\n },\n \"name\": {\n \"type\": \"string\",\n \"nullable\": true\n }\n },\n \"additionalProperties\": false\n }\n }\n },\n \"paths\": {\n \"/graphs/\": {\n \"get\": {\n \"operationId\": \"getGraphs\",\n \"summary\": \"Get graphs.\",\n \"tags\": [\n \"graphs\"\n ],\n \"description\": \"Fetch graphs from the database.\",\n \"parameters\": [\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"limit\",\n \"required\": false,\n \"description\": \"Limit will be applied by default if not passed. If the provided value exceeds the maximum allowed value a validation error will be thrown\"\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"offset\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"in\": \"query\",\n \"name\": \"totalCount\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"in\": \"query\",\n \"name\": \"cursor\",\n \"required\": false,\n \"description\": \"Include cursor headers in response. Cursor keys built from orderBy clause\"\n },\n {\n \"schema\": {\n \"type\": \"string\",\n \"format\": \"byte\"\n },\n \"in\": \"query\",\n \"name\": \"startAfter\",\n \"required\": false,\n \"description\": \"Cursor for forward pagination. List objects after this cursor position\"\n },\n {\n \"schema\": {\n \"type\": \"string\",\n \"format\": \"byte\"\n },\n \"in\": \"query\",\n \"name\": \"endBefore\",\n \"required\": false,\n \"description\": \"Cursor for backward pagination. List objects before this cursor position\"\n },\n {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"enum\": [\n \"id\",\n \"name\"\n ]\n }\n },\n \"in\": \"query\",\n \"name\": \"fields\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.eq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.neq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.gt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.gte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.lt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.lte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.like\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.ilike\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.in\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.nin\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.contains\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.contained\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.overlaps\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.eq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.neq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.gt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.gte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.lt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.lte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.like\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.ilike\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.in\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.nin\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.contains\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.contained\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.overlaps\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"in\": \"query\",\n \"name\": \"where.or\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\",\n \"enum\": [\n \"asc\",\n \"desc\"\n ]\n },\n \"in\": \"query\",\n \"name\": \"orderby.id\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\",\n \"enum\": [\n \"asc\",\n \"desc\"\n ]\n },\n \"in\": \"query\",\n \"name\": \"orderby.name\",\n \"required\": false\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Default Response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Graph\"\n }\n }\n }\n }\n }\n }\n },\n \"post\": {\n \"operationId\": \"createGraph\",\n \"summary\": \"Create graph.\",\n \"tags\": [\n \"graphs\"\n ],\n \"description\": \"Add new graph to the database.\",\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/GraphInput\"\n }\n }\n }\n },\n \"responses\": {\n \"200\": {\n \"description\": \"A Graph\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Graph\"\n }\n }\n },\n \"links\": {}\n }\n }\n },\n \"put\": {\n \"operationId\": \"updateGraphs\",\n \"summary\": \"Update graphs.\",\n \"tags\": [\n \"graphs\"\n ],\n \"description\": \"Update one or more graphs in the database.\",\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/GraphInput\"\n }\n }\n }\n },\n \"parameters\": [\n {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"enum\": [\n \"id\",\n \"name\"\n ]\n }\n },\n \"in\": \"query\",\n \"name\": \"fields\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.eq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.neq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.gt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.gte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.lt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.lte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.like\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.ilike\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.in\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.nin\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.contains\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.contained\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.id.overlaps\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.eq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.neq\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.gt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.gte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.lt\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.lte\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.like\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.ilike\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.in\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.nin\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.contains\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.contained\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"string\"\n },\n \"in\": \"query\",\n \"name\": \"where.name.overlaps\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"in\": \"query\",\n \"name\": \"where.or\",\n \"required\": false\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Default Response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Graph\"\n }\n }\n }\n },\n \"links\": {}\n }\n }\n }\n },\n \"/graphs/{id}\": {\n \"get\": {\n \"operationId\": \"getGraphById\",\n \"summary\": \"Get Graph by id.\",\n \"tags\": [\n \"graphs\"\n ],\n \"description\": \"Fetch Graph using its id from the database.\",\n \"parameters\": [\n {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"enum\": [\n \"id\",\n \"name\"\n ]\n }\n },\n \"in\": \"query\",\n \"name\": \"fields\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"path\",\n \"name\": \"id\",\n \"required\": true\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"A Graph\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Graph\"\n }\n }\n },\n \"links\": {}\n }\n }\n },\n \"put\": {\n \"operationId\": \"updateGraph\",\n \"summary\": \"Update graph.\",\n \"tags\": [\n \"graphs\"\n ],\n \"description\": \"Update graph in the database.\",\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/GraphInput\"\n }\n }\n }\n },\n \"parameters\": [\n {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"enum\": [\n \"id\",\n \"name\"\n ]\n }\n },\n \"in\": \"query\",\n \"name\": \"fields\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"path\",\n \"name\": \"id\",\n \"required\": true\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"A Graph\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Graph\"\n }\n }\n },\n \"links\": {}\n }\n }\n },\n \"delete\": {\n \"operationId\": \"deleteGraphs\",\n \"summary\": \"Delete graphs.\",\n \"tags\": [\n \"graphs\"\n ],\n \"description\": \"Delete one or more graphs from the Database.\",\n \"parameters\": [\n {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"enum\": [\n \"id\",\n \"name\"\n ]\n }\n },\n \"in\": \"query\",\n \"name\": \"fields\",\n \"required\": false\n },\n {\n \"schema\": {\n \"type\": \"integer\"\n },\n \"in\": \"path\",\n \"name\": \"id\",\n \"required\": true\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"A Graph\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Graph\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"servers\": [\n {\n \"url\": \"/\"\n }\n ]\n}"
package/db.mjs DELETED
@@ -1,86 +0,0 @@
1
- #! /usr/bin/env node
2
-
3
- import commist from 'commist'
4
- import parseArgs from 'minimist'
5
- import isMain from 'es-main'
6
- import helpMe from 'help-me'
7
- import { readFile } from 'fs/promises'
8
- import { join } from 'desm'
9
- import { start, buildCompileCmd } from '@platformatic/service'
10
- import { printAndExitLoadConfigError } from '@platformatic/config'
11
- import { platformaticDB } from './index.js'
12
-
13
- import { applyMigrations } from './lib/migrate.mjs'
14
- import { seed } from './lib/seed.mjs'
15
- import { generateTypes } from './lib/gen-types.mjs'
16
- import { printGraphQLSchema, printOpenAPISchema, generateJsonSchemaConfig } from './lib/gen-schema.mjs'
17
- import { generateMigration } from './lib/gen-migration.mjs'
18
- import { createDB } from './lib/create.mjs'
19
-
20
- const compile = buildCompileCmd(platformaticDB)
21
-
22
- const help = helpMe({
23
- dir: join(import.meta.url, 'help'),
24
- // the default
25
- ext: '.txt',
26
- })
27
-
28
- function wrapCommand (fn) {
29
- return async function (...args) {
30
- try {
31
- return await fn(...args)
32
- } catch (err) {
33
- printAndExitLoadConfigError(err)
34
- }
35
- }
36
- }
37
-
38
- const program = commist({ maxDistance: 2 })
39
-
40
- program.register('help', help.toStdout)
41
- program.register('help start', help.toStdout.bind(null, ['start']))
42
- program.register('help compile', help.toStdout.bind(null, ['compile']))
43
- program.register('help migrations apply', help.toStdout.bind(null, ['migrations apply']))
44
- program.register({ command: 'help seed', strict: true }, help.toStdout.bind(null, ['seed']))
45
- program.register('help schema', help.toStdout.bind(null, ['schema']))
46
-
47
- program.register('start', (argv) => {
48
- start(platformaticDB, argv).catch(printAndExitLoadConfigError)
49
- })
50
-
51
- program.register('create', wrapCommand(createDB))
52
- program.register('compile', wrapCommand(compile))
53
- program.register('migrations create', wrapCommand(generateMigration))
54
- program.register('migrations apply', wrapCommand(applyMigrations))
55
- program.register('seed', wrapCommand(seed))
56
- program.register('types', wrapCommand(generateTypes))
57
- program.register('schema graphql', wrapCommand(printGraphQLSchema))
58
- program.register('schema openapi', wrapCommand(printOpenAPISchema))
59
- program.register('schema config', wrapCommand(generateJsonSchemaConfig))
60
- program.register('schema', help.toStdout.bind(null, ['schema']))
61
-
62
- // TODO add help command
63
-
64
- export async function runDB (argv) {
65
- const args = parseArgs(argv, {
66
- alias: {
67
- v: 'version',
68
- },
69
- })
70
-
71
- if (args.version) {
72
- console.log('v' + JSON.parse(await readFile(join(import.meta.url, 'package.json'), 'utf-8')).version)
73
- process.exit(0)
74
- }
75
-
76
- const output = await program.parseAsync(argv)
77
-
78
- return {
79
- output,
80
- help,
81
- }
82
- }
83
-
84
- if (isMain(import.meta)) {
85
- await runDB(process.argv.splice(2))
86
- }
package/help/compile.txt DELETED
@@ -1,17 +0,0 @@
1
- Compile typescript plugins.
2
-
3
- ``` bash
4
- $ platformatic db compile
5
- ```
6
-
7
- As a result of executing this command, the Platformatic DB will compile typescript
8
- plugins in the `outDir` directory.
9
-
10
- If not specified, the configuration will be loaded from any of the following, in the current directory.
11
-
12
- * `platformatic.json`, or
13
- * `platformatic.yml`, or
14
- * `platformatic.tml`
15
-
16
- You can find more details about the configuration format here:
17
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
package/help/create.txt DELETED
@@ -1,13 +0,0 @@
1
- Creates a new Platformatic DB application.
2
-
3
- Options are
4
-
5
- * `dir <string>` - the directory where to create the project (Default: `process.cwd() + 'platformatic-composer'`)
6
- * `port <string>` - the port where the application will listen (Default: `3042`)
7
- * `hostname <string>` - the hostname where the application will listen (Default: `0.0.0.0`)
8
- * `connectionString <string>` - the connection string for your database (Default: `sqlite://./db.sqlite`)
9
- * `migrations <boolean>` - Creates sample migrations (Default: `true`)
10
- * `git <boolean>` - Init the git repository (Default: `true`)
11
- * `typescript <boolean>` - Use Typescript (Default: `false`)
12
- * `install <boolean>` - Run or not `npm install` after creating the files (Default: `true`)
13
- * `plugin <boolean>` - Creates a sample plugin and tests (Default: `true`)
package/help/help.txt DELETED
@@ -1,11 +0,0 @@
1
- Available commands:
2
-
3
- * `help` - show this help message.
4
- * `help <command>` - shows more information about a command.
5
- * `start` - start the server.
6
- * `compile` - compile typescript plugins.
7
- * `seed` - run a seed file.
8
- * `types` - generate typescript types for entities.
9
- * `schema` - generate and print api schema.
10
- * `migrations create` - generate do and undo migration files.
11
- * `migrations apply` - apply migration files.
@@ -1,45 +0,0 @@
1
- Apply all configured migrations to the database:
2
-
3
- ``` bash
4
- $ platformatic db migrations apply
5
- ```
6
-
7
- The migrations will be applied in the order they are specified in the
8
- folder defined in the configuration file. If you want to apply a specific migration,
9
- you can use the `--to` option:
10
-
11
- ``` bash
12
- $ platformatic db migrations apply --to 001
13
- ```
14
-
15
- Here is an example migration:
16
-
17
- ``` sql
18
- CREATE TABLE graphs (
19
- id SERIAL PRIMARY KEY,
20
- name TEXT
21
- );
22
- ```
23
-
24
- You can always rollback to a specific migration with:
25
-
26
- ``` bash
27
- $ platformatic db migrations apply --to VERSION
28
- ```
29
-
30
- Use 000 to reset to the initial state.
31
-
32
- Options:
33
-
34
- * `-c, --config <path>` - Path to the configuration file.
35
- * `-t, --to <version>` - Migrate to a specific version.
36
-
37
- If not specified, the configuration will be loaded from any of the following, in the current directory.
38
-
39
- * `platformatic.json`, or
40
- * `platformatic.yml`, or
41
- * `platformatic.tml`
42
-
43
- You can find more details about the configuration format here:
44
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
45
-
@@ -1,27 +0,0 @@
1
- Create next migration files.
2
-
3
- ``` bash
4
- $ platformatic db migrations create
5
- ```
6
-
7
- It will generate do and undo sql files in the migrations folder. The name of the
8
- files will be the next migration number.
9
-
10
- ``` bash
11
- $ platformatic db migrations create
12
- ```
13
-
14
- The migration files are named `001.<do|undo>.sql`, `002.<do|undo>.sql` etc...
15
-
16
- Options:
17
-
18
- * `-c, --config <path>` - Path to the configuration file.
19
-
20
- If not specified, the configuration will be loaded from any of the following, in the current directory.
21
-
22
- * `platformatic.json`, or
23
- * `platformatic.yml`, or
24
- * `platformatic.tml`
25
-
26
- You can find more details about the configuration format here:
27
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
@@ -1,4 +0,0 @@
1
- Available commands:
2
-
3
- * `migrations create` - generate do and undo migration files.
4
- * `migrations apply` - apply migration files.
package/help/schema.txt DELETED
@@ -1,25 +0,0 @@
1
- Update the config schema file:
2
-
3
- * `schema config` - update the JSON schema config available on `platformatic.json`
4
-
5
- Your configuration on `platformatic.json` has a schema defined to improve the developer experience and avoid mistakes when updating the configuration of Platformatic DB.
6
- When you run `platformatic db init`, a new JSON `$schema` property is added in `platformatic.json`. This can allow your IDE to add suggestions (f.e. mandatory/missing fields, types, default values) by opening the config in `platformatic.json`.
7
- Running `platformatic schema config` you can update your schema so that it matches well the latest changes available on your config.
8
-
9
- Generate a schema from the database and prints it to standard output:
10
-
11
- * `schema graphql` - generate the GraphQL schema
12
- * `schema openapi` - generate the OpenAPI schema
13
-
14
- Options:
15
-
16
- * `-c, --config FILE` - Specify a configuration file to use.
17
-
18
- If not specified, the configuration will be loaded from any of the following, in the current directory.
19
-
20
- * `platformatic.json`, or
21
- * `platformatic.yml`, or
22
- * `platformatic.tml`
23
-
24
- You can find more details about the configuration format here:
25
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
package/help/seed.txt DELETED
@@ -1,36 +0,0 @@
1
- Load a seed into the database. This is a convenience method that loads
2
- a JavaScript file and configure @platformatic/sql-mapper to connect to
3
- the database specified in the configuration file.
4
-
5
- Here is an example of a seed file:
6
-
7
- ``` javascript
8
- 'use strict'
9
-
10
- module.exports = async function ({ entities, db, sql }) {
11
- await entities.graph.save({ input: { name: 'Hello' } })
12
- await db.query(sql`
13
- INSERT INTO graphs (name) VALUES ('Hello 2');
14
- `)
15
- }
16
- ```
17
-
18
- You can run this using the `seed` command:
19
-
20
- ``` bash
21
- $ platformatic db seed seed.js
22
- ```
23
-
24
- Options:
25
-
26
- * `--config` - Path to the configuration file.
27
-
28
- If not specified, the configuration will be loaded from any of the following, in the current directory.
29
-
30
- * `platformatic.json`, or
31
- * `platformatic.yml`, or
32
- * `platformatic.tml`
33
-
34
- You can find more details about the configuration format here:
35
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
36
-
package/help/start.txt DELETED
@@ -1,47 +0,0 @@
1
- Start the Platformatic DB server with the following command:
2
-
3
- ``` bash
4
- $ platformatic db start
5
- ```
6
-
7
- You will need a configuration file. Here is an example to get you started,
8
- save the following as `platformatic.json`:
9
-
10
- ``` json
11
- {
12
- "server": {
13
- "hostname": "127.0.0.1",
14
- "port": 0,
15
- "logger": {
16
- "level": "info"
17
- }
18
- },
19
- "db": {
20
- "connectionString": "sqlite://./db"
21
- },
22
- "migrations": {
23
- "dir": "./migrations"
24
- }
25
- }
26
- ```
27
-
28
- Remember to create a migration, run the `db help migrate` command to know more.
29
-
30
- All outstanding migrations will be applied to the database unless the
31
- `migrations.autoApply` configuration option is set to false.
32
-
33
- By sending the SIGUSR2 signal, the server can be reloaded.
34
-
35
- Options:
36
-
37
- * `-c, --config FILE` - Specify a configuration file to use.
38
-
39
- If not specified, the configuration will be loaded from any of the following, in the current directory.
40
-
41
- * `platformatic.json`, or
42
- * `platformatic.yml`, or
43
- * `platformatic.tml`
44
-
45
- You can find more details about the configuration format here:
46
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
47
-
package/help/types.txt DELETED
@@ -1,40 +0,0 @@
1
- Generate typescript types for your entities from the database.
2
-
3
- ``` bash
4
- $ platformatic db types
5
- ```
6
-
7
- As a result of executing this command, the Platformatic DB will generate a `types`
8
- folder with a typescript file for each database entity. It will also generate a
9
- `global.d.ts` file that injects the types into the Application instance.
10
-
11
- In order to add type support to your plugins, you need to install some additional
12
- dependencies. To do this, copy and run an `npm install` command with dependencies
13
- that "platformatic db types" will ask you.
14
-
15
- Here is an example of a platformatic plugin.js with jsdoc support.
16
- You can use it to add autocomplete to your code.
17
-
18
- ``` javascript
19
- /// <reference path="./global.d.ts" />
20
- 'use strict'
21
-
22
- /** @param {import('fastify').FastifyInstance} app */
23
- module.exports = async function (app) {
24
- app.get('/movie', async () => {
25
- const movies = await app.platformatic.entities.movie.find({
26
- where: { title: { eq: 'The Hitchhiker\'s Guide to the Galaxy' } }
27
- })
28
- return movies[0].id
29
- })
30
- }
31
- ```
32
-
33
- If not specified, the configuration will be loaded from any of the following, in the current directory.
34
-
35
- * `platformatic.json`, or
36
- * `platformatic.yml`, or
37
- * `platformatic.tml`
38
-
39
- You can find more details about the configuration format here:
40
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)