@astrale-os/sdk 0.1.6 → 0.1.8
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/dist/cli/bin.d.ts +7 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +15 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/dotenv.d.ts +13 -0
- package/dist/cli/dotenv.d.ts.map +1 -0
- package/dist/cli/dotenv.js +46 -0
- package/dist/cli/dotenv.js.map +1 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/run.d.ts +84 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +603 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/spec.d.ts +19 -0
- package/dist/cli/spec.d.ts.map +1 -0
- package/dist/cli/spec.js +31 -0
- package/dist/cli/spec.js.map +1 -0
- package/dist/config/adapter.d.ts +140 -0
- package/dist/config/adapter.d.ts.map +1 -0
- package/dist/config/adapter.js +40 -0
- package/dist/config/adapter.js.map +1 -0
- package/dist/config/define-domain.d.ts +112 -0
- package/dist/config/define-domain.d.ts.map +1 -0
- package/dist/config/define-domain.js +98 -0
- package/dist/config/define-domain.js.map +1 -0
- package/dist/config/deploy.d.ts +28 -0
- package/dist/config/deploy.d.ts.map +1 -0
- package/dist/config/deploy.js +24 -0
- package/dist/config/deploy.js.map +1 -0
- package/dist/config/index.d.ts +21 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +18 -0
- package/dist/config/index.js.map +1 -0
- package/dist/define/remote-function.d.ts +19 -11
- package/dist/define/remote-function.d.ts.map +1 -1
- package/dist/define/remote-function.js.map +1 -1
- package/dist/dispatch/call-remote.d.ts +7 -3
- package/dist/dispatch/call-remote.d.ts.map +1 -1
- package/dist/dispatch/call-remote.js.map +1 -1
- package/dist/dispatch/dispatcher.d.ts.map +1 -1
- package/dist/dispatch/dispatcher.js +8 -4
- package/dist/dispatch/dispatcher.js.map +1 -1
- package/dist/dispatch/index.d.ts +1 -1
- package/dist/dispatch/index.d.ts.map +1 -1
- package/dist/dispatch/index.js.map +1 -1
- package/dist/dispatch/self.d.ts +46 -10
- package/dist/dispatch/self.d.ts.map +1 -1
- package/dist/dispatch/self.js +65 -8
- package/dist/dispatch/self.js.map +1 -1
- package/dist/domain/define.d.ts +3 -3
- package/dist/domain/define.js +3 -3
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/method/class.d.ts.map +1 -1
- package/dist/method/class.js.map +1 -1
- package/dist/method/context.d.ts +32 -7
- package/dist/method/context.d.ts.map +1 -1
- package/dist/method/index.d.ts +1 -1
- package/dist/method/index.d.ts.map +1 -1
- package/dist/method/single.d.ts +16 -11
- package/dist/method/single.d.ts.map +1 -1
- package/dist/method/single.js.map +1 -1
- package/dist/server/domain-entry.d.ts +67 -0
- package/dist/server/domain-entry.d.ts.map +1 -0
- package/dist/server/domain-entry.js +58 -0
- package/dist/server/domain-entry.js.map +1 -0
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/worker-entry.d.ts +80 -5
- package/dist/server/worker-entry.d.ts.map +1 -1
- package/dist/server/worker-entry.js +105 -24
- package/dist/server/worker-entry.js.map +1 -1
- package/package.json +12 -3
- package/src/cli/bin.ts +15 -0
- package/src/cli/dotenv.ts +45 -0
- package/src/cli/index.ts +15 -0
- package/src/cli/run.ts +710 -0
- package/src/cli/spec.ts +42 -0
- package/src/config/adapter.ts +172 -0
- package/src/config/define-domain.ts +218 -0
- package/src/config/deploy.ts +35 -0
- package/src/config/index.ts +31 -0
- package/src/define/remote-function.ts +42 -13
- package/src/dispatch/call-remote.ts +7 -2
- package/src/dispatch/dispatcher.ts +8 -4
- package/src/dispatch/index.ts +1 -1
- package/src/dispatch/self.ts +96 -10
- package/src/domain/define.ts +3 -3
- package/src/index.ts +25 -4
- package/src/method/class.ts +4 -3
- package/src/method/context.ts +38 -7
- package/src/method/index.ts +1 -1
- package/src/method/single.ts +30 -11
- package/src/server/domain-entry.ts +113 -0
- package/src/server/index.ts +3 -1
- package/src/server/worker-entry.ts +128 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Astrale Remote Domain SDK - Define and deploy domains as standalone Hono servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/astrale-os/sdk.git"
|
|
17
17
|
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"astrale-domain": "./dist/cli/bin.js"
|
|
20
|
+
},
|
|
18
21
|
"files": [
|
|
19
22
|
"dist",
|
|
20
23
|
"src"
|
|
@@ -31,6 +34,14 @@
|
|
|
31
34
|
"types": "./dist/server/index.d.ts",
|
|
32
35
|
"import": "./dist/server/index.js"
|
|
33
36
|
},
|
|
37
|
+
"./domain": {
|
|
38
|
+
"types": "./dist/domain/index.d.ts",
|
|
39
|
+
"import": "./dist/domain/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./cli": {
|
|
42
|
+
"types": "./dist/cli/index.d.ts",
|
|
43
|
+
"import": "./dist/cli/index.js"
|
|
44
|
+
},
|
|
34
45
|
"./deploy": {
|
|
35
46
|
"types": "./dist/deploy/index.d.ts",
|
|
36
47
|
"import": "./dist/deploy/index.js"
|
|
@@ -50,8 +61,6 @@
|
|
|
50
61
|
"zod": "^4.3.6"
|
|
51
62
|
},
|
|
52
63
|
"devDependencies": {
|
|
53
|
-
"@astrale-os/kernel-host": ">=0.4.0 <1.0.0",
|
|
54
|
-
"@astrale-os/kernel-test": ">=0.4.0 <1.0.0",
|
|
55
64
|
"@astrale-os/ox": ">=0.1.0 <1.0.0",
|
|
56
65
|
"@astrale/commitlint-config": "npm:@jsr/astrale__commitlint-config@~2.0.0",
|
|
57
66
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
package/src/cli/bin.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* `astrale-domain` bin entry. Runs under bun (native TS) so it can import the
|
|
4
|
+
* project's `astrale.config.ts` directly — matching the `astrale` CLI.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { run } from './run'
|
|
8
|
+
|
|
9
|
+
run(process.argv.slice(2))
|
|
10
|
+
.then((code) => process.exit(code))
|
|
11
|
+
.catch((err: unknown) => {
|
|
12
|
+
process.stderr.write(`\x1b[31m✗\x1b[0m ${(err as Error).message ?? String(err)}\n`)
|
|
13
|
+
if (process.env.DEBUG) process.stderr.write(`${(err as Error).stack ?? ''}\n`)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal dotenv parser — the secrets-file boundary.
|
|
3
|
+
*
|
|
4
|
+
* `secrets: '.env.<env>'` in an adapter's params points a gitignored file whose
|
|
5
|
+
* entire contents are secrets. `loadDotenvFile` reads it into a flat
|
|
6
|
+
* `Record<string,string>` the CLI hands the adapter (injected into the local
|
|
7
|
+
* runtime in dev, pushed to a secret store in prod). No `process.env` mutation,
|
|
8
|
+
* no interpolation magic beyond `${VAR}` against earlier keys in the same file.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { readFileSync } from 'node:fs'
|
|
12
|
+
|
|
13
|
+
export function parseDotenv(contents: string): Record<string, string> {
|
|
14
|
+
const out: Record<string, string> = {}
|
|
15
|
+
for (const raw of contents.split('\n')) {
|
|
16
|
+
const line = raw.trim()
|
|
17
|
+
if (!line || line.startsWith('#')) continue
|
|
18
|
+
const match = /^(?:export\s+)?([A-Za-z_]\w*)\s*=\s*(.*)$/.exec(line)
|
|
19
|
+
if (!match) continue
|
|
20
|
+
const [, key, rawValue] = match
|
|
21
|
+
let value = rawValue.trim()
|
|
22
|
+
// Single quotes mean a LITERAL value (standard dotenv): no `${VAR}`
|
|
23
|
+
// interpolation, so a secret that legitimately contains a literal `${...}`
|
|
24
|
+
// (e.g. a password) survives intact instead of being silently blanked.
|
|
25
|
+
const singleQuoted = value.length >= 2 && value.startsWith("'") && value.endsWith("'")
|
|
26
|
+
if ((value.length >= 2 && value.startsWith('"') && value.endsWith('"')) || singleQuoted) {
|
|
27
|
+
value = value.slice(1, -1)
|
|
28
|
+
}
|
|
29
|
+
out[key] = singleQuoted
|
|
30
|
+
? value
|
|
31
|
+
: value.replace(/\$\{(\w+)\}/g, (_, name: string) => out[name] ?? '')
|
|
32
|
+
}
|
|
33
|
+
return out
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Read + parse a dotenv file. Returns `{}` if the file is absent (CI-safe). */
|
|
37
|
+
export function loadDotenvFile(path: string): Record<string, string> {
|
|
38
|
+
let contents: string
|
|
39
|
+
try {
|
|
40
|
+
contents = readFileSync(path, 'utf-8')
|
|
41
|
+
} catch {
|
|
42
|
+
return {}
|
|
43
|
+
}
|
|
44
|
+
return parseDotenv(contents)
|
|
45
|
+
}
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@astrale-os/sdk/cli` — the `astrale-domain` CLI (dev | build | deploy) and
|
|
3
|
+
* the dotenv secrets-file boundary, folded in from the former
|
|
4
|
+
* `@astrale-os/devkit` package.
|
|
5
|
+
*
|
|
6
|
+
* Node-only: the CLI imports `node:fs`/`node:module`/`node:url` and runs under
|
|
7
|
+
* Bun (it imports the project's `astrale.config.ts` directly). This subpath is
|
|
8
|
+
* deliberately NOT re-exported from the package barrel — pulling it into the
|
|
9
|
+
* isomorphic `.` entry would poison browser/worker bundlers that traverse every
|
|
10
|
+
* re-export (the same rule that keeps `./server` and `./deploy` off the barrel).
|
|
11
|
+
* The bin lives at `./bin`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export { run, parseArgs } from './run'
|
|
15
|
+
export { parseDotenv, loadDotenvFile } from './dotenv'
|