@synthigy/sdk 0.1.0 → 0.1.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.
- package/README.md +1 -1
- package/codegen/codegen.mjs +13 -1
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ for await (const ev of w.events) {
|
|
|
66
66
|
IAM / RBAC / row-level security enforced *server-side*. Tokens never have to
|
|
67
67
|
reach the browser. → [AUTH.md](./docs/AUTH.md)
|
|
68
68
|
|
|
69
|
-
- **Typed from your model.** `synthigy-gen` compiles your ERD + `.xsql` files
|
|
69
|
+
- **Typed from your model.** `synthigy-gen` (needs `typescript` in your project) compiles your ERD + `.xsql` files
|
|
70
70
|
into typed methods whose result types follow the selection — a typo'd entity
|
|
71
71
|
or an unselected field is a compile error. → [codegen](./docs/WATCH.md#codegen)
|
|
72
72
|
|
package/codegen/codegen.mjs
CHANGED
|
@@ -10,9 +10,21 @@ import fs from 'node:fs'
|
|
|
10
10
|
import path from 'node:path'
|
|
11
11
|
import { createHash } from 'node:crypto'
|
|
12
12
|
import { execFileSync } from 'node:child_process'
|
|
13
|
-
import
|
|
13
|
+
import { createRequire } from 'node:module'
|
|
14
14
|
import { TS, tsScalar, pascal, camel } from './lib.mjs'
|
|
15
15
|
|
|
16
|
+
// typescript is an optional peer: the runtime client has no dependencies and
|
|
17
|
+
// must stay that way, but generating .ts files needs the compiler — resolved
|
|
18
|
+
// from the consumer's project, where a TypeScript codebase already has it.
|
|
19
|
+
let ts
|
|
20
|
+
try {
|
|
21
|
+
ts = createRequire(import.meta.url)('typescript')
|
|
22
|
+
} catch {
|
|
23
|
+
console.error('synthigy-gen: `typescript` is required to generate code and was not found.\n' +
|
|
24
|
+
' npm install -D typescript')
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
const here = path.dirname(new URL(import.meta.url).pathname)
|
|
17
29
|
|
|
18
30
|
// Reformat generated TS through the compiler's own printer: correct indentation,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synthigy/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Zero-dependency client for Synthigy's /data endpoint",
|
|
5
5
|
"author": "Robert Geršak",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,6 +50,14 @@
|
|
|
50
50
|
"realtime",
|
|
51
51
|
"xsql"
|
|
52
52
|
],
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"typescript": ">=5"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"typescript": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
53
61
|
"devDependencies": {
|
|
54
62
|
"typescript": "^6.0.3"
|
|
55
63
|
},
|