@synthigy/sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +102 -0
- package/codegen/codegen.mjs +499 -0
- package/codegen/lib.mjs +30 -0
- package/codegen/pull.mjs +47 -0
- package/package.json +63 -0
- package/src/index.d.ts +1108 -0
- package/src/index.js +2535 -0
- package/src/watch-query.js +533 -0
- package/src/watch.js +915 -0
package/codegen/pull.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Pull the IAM-filtered schema → commit synthigy.schema.json.
|
|
3
|
+
//
|
|
4
|
+
// The codegen type-truth. Everyone (Prisma/genqlient/sqlc) does the same:
|
|
5
|
+
// pull once → commit the artifact → generate offline. Retires the nREPL `spit`.
|
|
6
|
+
//
|
|
7
|
+
// Reuses the SDK's `client.schema()` — it already does GET /schema + auth, so
|
|
8
|
+
// there's no HTTP/auth to reimplement here (ladder: a dependency already solves it).
|
|
9
|
+
//
|
|
10
|
+
// Config via env (or --endpoint):
|
|
11
|
+
// SYNTHIGY_ENDPOINT e.g. http://localhost:7887 (or argv[2])
|
|
12
|
+
// SYNTHIGY_TOKEN static bearer — OR —
|
|
13
|
+
// SYNTHIGY_CLIENT_ID + SYNTHIGY_CLIENT_SECRET client-credentials
|
|
14
|
+
// (none ⇒ authless GET, for bare servers / SYNTHIGY_IAM_ALLOW_PUBLIC)
|
|
15
|
+
//
|
|
16
|
+
// ponytail: device-code flow (gh/gcloud-style human login) skipped — token or
|
|
17
|
+
// client-creds covers the dev/CI loop. Add device-code when a human-pull UX is wanted.
|
|
18
|
+
|
|
19
|
+
import fs from 'node:fs'
|
|
20
|
+
import path from 'node:path'
|
|
21
|
+
import { createClient } from '../src/index.js'
|
|
22
|
+
|
|
23
|
+
const endpoint = process.argv[2] ?? process.env.SYNTHIGY_ENDPOINT
|
|
24
|
+
if (!endpoint) {
|
|
25
|
+
console.error('usage: node pull.mjs <endpoint> (or set SYNTHIGY_ENDPOINT)')
|
|
26
|
+
process.exit(1)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { SYNTHIGY_TOKEN, SYNTHIGY_CLIENT_ID, SYNTHIGY_CLIENT_SECRET } = process.env
|
|
30
|
+
const config = { endpoint }
|
|
31
|
+
if (SYNTHIGY_CLIENT_ID && SYNTHIGY_CLIENT_SECRET) {
|
|
32
|
+
config.clientId = SYNTHIGY_CLIENT_ID
|
|
33
|
+
config.clientSecret = SYNTHIGY_CLIENT_SECRET
|
|
34
|
+
} else {
|
|
35
|
+
config.token = SYNTHIGY_TOKEN ?? '' // '' = authless (bare server)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const here = path.dirname(new URL(import.meta.url).pathname)
|
|
39
|
+
const outPath = process.argv[3] ? path.resolve(process.argv[3]) : path.join(here, 'schema.json')
|
|
40
|
+
|
|
41
|
+
const client = createClient(config)
|
|
42
|
+
const schema = await client.schema()
|
|
43
|
+
fs.writeFileSync(outPath, JSON.stringify(schema, null, 2) + '\n')
|
|
44
|
+
|
|
45
|
+
const n = Object.keys(schema.entities ?? {}).length
|
|
46
|
+
const v = schema.version ? ` @${schema.version}` : ''
|
|
47
|
+
console.log(`pulled ${n} entities${v} → ${path.relative(process.cwd(), outPath)}`)
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@synthigy/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-dependency client for Synthigy's /data endpoint",
|
|
5
|
+
"author": "Robert Geršak",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/synthigy/synthigy",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/synthigy/js.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/synthigy/js/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "src/index.js",
|
|
17
|
+
"types": "src/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./src/index.d.ts",
|
|
21
|
+
"import": "./src/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"synthigy-gen": "./codegen/codegen.mjs"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"src/",
|
|
30
|
+
"codegen/codegen.mjs",
|
|
31
|
+
"codegen/lib.mjs",
|
|
32
|
+
"codegen/pull.mjs"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
36
|
+
"pretest": "npm run typecheck",
|
|
37
|
+
"test": "node --test test/*.test.js",
|
|
38
|
+
"pretest:live": "npm run typecheck",
|
|
39
|
+
"test:live": "node --test test/integration.test.js",
|
|
40
|
+
"codegen": "node codegen/codegen.mjs"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"synthigy",
|
|
44
|
+
"sdk",
|
|
45
|
+
"dataset",
|
|
46
|
+
"iam",
|
|
47
|
+
"crud",
|
|
48
|
+
"client",
|
|
49
|
+
"sse",
|
|
50
|
+
"realtime",
|
|
51
|
+
"xsql"
|
|
52
|
+
],
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"typescript": "^6.0.3"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=20.0.0"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public",
|
|
61
|
+
"provenance": true
|
|
62
|
+
}
|
|
63
|
+
}
|