create-astrale-domain 0.3.0-beta.21 → 0.3.0-beta.211
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 +54 -3
- package/dist/index.js +382 -135
- package/package.json +17 -12
- package/template/.env.example +9 -8
- package/template/.gitignore.template +8 -2
- package/template/.variants/custom/README.md +19 -9
- package/template/.variants/custom/__tests__/variant.test.ts +4 -4
- package/template/.variants/custom/domain.ts +28 -0
- package/template/.variants/custom/{views/application/app → frontend}/index.html +1 -0
- package/template/.variants/custom/{views/application/app → frontend}/main.ts +1 -1
- package/template/.variants/custom/frontend/package.json +11 -0
- package/template/.variants/custom/frontend/public/favicon.svg +4 -0
- package/template/.variants/custom/frontend/tsconfig.json +17 -0
- package/template/.variants/custom/schema/schema.ts +15 -0
- package/template/.variants/custom/views/application/index.ts +1 -0
- package/template/.variants/custom/views/index.ts +1 -1
- package/template/.variants/custom/vite.config.ts +11 -2
- package/template/.variants/none/README.md +13 -4
- package/template/.variants/none/__tests__/variant.test.ts +3 -3
- package/template/.variants/none/domain.ts +18 -0
- package/template/.variants/none/schema/schema.ts +11 -0
- package/template/.variants/react/README.md +20 -10
- package/template/.variants/react/__tests__/variant.test.ts +4 -4
- package/template/.variants/react/domain.ts +28 -0
- package/template/.variants/react/frontend/index.html +1 -0
- package/template/.variants/react/frontend/package.json +7 -1
- package/template/.variants/react/frontend/public/favicon.svg +4 -0
- package/template/.variants/react/frontend/src/styles.css +1 -1
- package/template/.variants/react/frontend/tsconfig.json +19 -0
- package/template/.variants/react/schema/schema.ts +15 -0
- package/template/.variants/react/vite.config.ts +2 -3
- package/template/CLAUDE.md +43 -5
- package/template/index.ts +1 -1
- package/template/package.json +15 -31
- package/template/pnpm-workspace.yaml +5 -21
- package/template/runtime.ts +1 -2
- package/template/schema/__tests__/schema.test.ts +14 -0
- package/template/schema/index.ts +1 -1
- package/template/tests/datasets/demo.ts +21 -0
- package/template/tests/e2e/domain.test.ts +9 -0
- package/template/tsconfig.json +8 -17
- package/template/.variants/custom/application.ts +0 -9
- package/template/.variants/custom/schema/application/index.ts +0 -8
- package/template/.variants/custom/views/application/__tests__/routes.test.ts +0 -7
- package/template/.variants/custom/views/application/routes.ts +0 -12
- package/template/.variants/none/application.ts +0 -8
- package/template/.variants/none/schema/application/index.ts +0 -5
- package/template/.variants/react/application.ts +0 -9
- package/template/.variants/react/schema/application/index.ts +0 -8
- package/template/.variants/react/views/application/__tests__/routes.test.ts +0 -7
- package/template/.variants/react/views/application/routes.ts +0 -12
- package/template/.variants/react/views/index.ts +0 -1
- package/template/schema/application/__tests__/schema.test.ts +0 -11
- package/template/tests/e2e/application.test.ts +0 -10
- package/template/tsconfig.package.json +0 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astrale-domain",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.211",
|
|
4
4
|
"description": "Scaffold a standalone Astrale domain — npm create astrale-domain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -26,28 +26,33 @@
|
|
|
26
26
|
"!template/**/pnpm-lock.yaml"
|
|
27
27
|
],
|
|
28
28
|
"type": "module",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"registry": "https://registry.npmjs.org/"
|
|
31
|
+
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@astrale-os/adapter-
|
|
32
|
-
"@
|
|
33
|
+
"@astrale-os/adapter-astrale": "0.5.0-beta.211",
|
|
34
|
+
"@astrale-os/adapter-cloudflare": "0.5.0-beta.218",
|
|
35
|
+
"@clack/prompts": "^0.11.0"
|
|
33
36
|
},
|
|
34
37
|
"devDependencies": {
|
|
35
|
-
"@astrale-os/
|
|
36
|
-
"@
|
|
38
|
+
"@astrale-os/kernel-dsl": "1.0.0-beta.28",
|
|
39
|
+
"@astrale-os/ox": "0.1.4",
|
|
40
|
+
"@astrale-os/sdk": "0.6.0-beta.63",
|
|
41
|
+
"@types/node": "^24.0.0",
|
|
37
42
|
"esbuild": "^0.28.2",
|
|
38
|
-
"oxfmt": "0.
|
|
43
|
+
"oxfmt": "0.67.0",
|
|
39
44
|
"oxlint": "1.78.0",
|
|
40
45
|
"typescript": "7.0.2",
|
|
41
|
-
"vitest": "^
|
|
42
|
-
"
|
|
46
|
+
"vitest": "^5.0.5",
|
|
47
|
+
"zod": "4.6.7"
|
|
43
48
|
},
|
|
44
49
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
50
|
+
"node": ">=24"
|
|
46
51
|
},
|
|
47
52
|
"scripts": {
|
|
48
53
|
"build": "rm -rf dist && node scripts/build.mjs && node ../scripts/verify-no-source-maps.mjs dist",
|
|
49
|
-
"typecheck": "tsc --noEmit",
|
|
50
|
-
"test": "vitest run",
|
|
54
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
55
|
+
"test": "vitest run && node --test scripts/*.test.mjs",
|
|
51
56
|
"test:generated": "node scripts/verify-generated.mjs",
|
|
52
57
|
"lint": "oxlint .",
|
|
53
58
|
"format": "pnpm exec oxfmt --write ."
|
package/template/.env.example
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
# Secrets for an
|
|
2
|
-
# by `secrets:` in astrale.config.ts. The ENTIRE file is treated as
|
|
3
|
-
#
|
|
4
|
-
#
|
|
1
|
+
# Secrets for an Environment live in `.env.<env>` (e.g. .env.dev, .env.production),
|
|
2
|
+
# pointed at by `secrets:` in astrale.config.ts. The ENTIRE file is treated as
|
|
3
|
+
# secrets: `astrale-domain deploy <env>` binds its current values to the
|
|
4
|
+
# deployment it makes, and a redeploy of the same release rewrites them in place
|
|
5
|
+
# on that deployment only. These files are gitignored — copy this to `.env.dev`
|
|
6
|
+
# and fill in.
|
|
5
7
|
#
|
|
6
8
|
# Add one line per secret required by an Integration. Declare the corresponding
|
|
7
9
|
# binding returned by `runtime.ts` initialization. For example:
|
|
8
10
|
#
|
|
9
11
|
# EXAMPLE_API_KEY=sk-...
|
|
10
|
-
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
# that file for production rather than copying its value into this dotenv file.
|
|
12
|
+
#
|
|
13
|
+
# A deployment's signing key is not a secret of yours: each deploy generates the
|
|
14
|
+
# key of the deployment it makes, so there is no key file to keep or restore.
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# Deps
|
|
2
2
|
node_modules/
|
|
3
|
+
.yarn/install-state.gz
|
|
4
|
+
.yarn/unplugged/
|
|
5
|
+
.pnp.*
|
|
3
6
|
|
|
4
|
-
# Generated plumbing (worker entry, wrangler config,
|
|
7
|
+
# Generated plumbing (worker entry, wrangler config, spec)
|
|
5
8
|
.astrale/
|
|
6
|
-
.domain-studio
|
|
9
|
+
.domain-studio/
|
|
7
10
|
|
|
8
11
|
# Worker dev + build artifacts
|
|
9
12
|
.dev.vars
|
|
@@ -15,3 +18,6 @@ dist/
|
|
|
15
18
|
.env
|
|
16
19
|
.env.*
|
|
17
20
|
!.env.example
|
|
21
|
+
|
|
22
|
+
# Vitest reports and artifacts
|
|
23
|
+
.vitest/
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
# Astrale Domain
|
|
2
2
|
|
|
3
|
-
This project uses the framework-neutral frontend escape hatch. `
|
|
4
|
-
|
|
5
|
-
framework; `ui/` owns presentation assets. The starter route uses
|
|
6
|
-
as a plain hosted app. Change that route to `handshake: 'shell'`
|
|
7
|
-
boots the Shell protocol.
|
|
3
|
+
This project uses the framework-neutral frontend escape hatch. `domain.ts` binds declared
|
|
4
|
+
Schema Views to `defineFrontend`; `vite.config.ts` owns the ordinary `frontend/` Vite root you can
|
|
5
|
+
replace with any framework; `ui/` owns presentation assets. The starter route uses
|
|
6
|
+
`handshake: 'none'`, so it mounts as a plain hosted app. Change that route to `handshake: 'shell'`
|
|
7
|
+
only after your browser entrypoint boots the Shell protocol.
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
10
|
schema/ public Domain contract, including View declarations
|
|
11
11
|
runtime.ts Actions, Workflows, Integrations, Providers, and initialization
|
|
12
|
-
|
|
13
|
-
views/
|
|
14
|
-
|
|
12
|
+
domain.ts Schema, Runtime, and frontend composition
|
|
13
|
+
views/application/ application View projection and mount behavior
|
|
14
|
+
frontend/ browser entrypoint and assets
|
|
15
15
|
ui/application/ application presentation, tokens, and styles
|
|
16
16
|
tests/ cross-layer executable journeys
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Run `pnpm
|
|
19
|
+
Run `pnpm run deploy development` to build, verify, and make one immutable deployment of the
|
|
20
|
+
committed `development` Environment. It starts no local Worker, browser server, or tunnel, and never
|
|
21
|
+
installs: install the URL it prints with `astrale domain install <url> -i <instance>`.
|
|
22
|
+
There is no watch loop: deploy each change. Run `pnpm build` to build both Worker and browser assets
|
|
23
|
+
and print their build digest.
|
|
20
24
|
Domain projects intentionally own no `.spec` trees and import authoring contracts only through
|
|
21
25
|
semantic `@astrale-os/sdk/*` subpaths.
|
|
26
|
+
|
|
27
|
+
This project starts at the `0.1.0-alpha.0` pre-release because it has no stable version yet.
|
|
28
|
+
`npm version prerelease --preid alpha` advances it to `0.1.0-alpha.1`, and `npm version minor`
|
|
29
|
+
leaves alpha at `0.1.0`. The Versions section of the
|
|
30
|
+
[`create-astrale-domain` README](https://www.npmjs.com/package/create-astrale-domain#versions) gives
|
|
31
|
+
the Release Please settings and the `0.x` rule.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { domain } from '../domain.js'
|
|
2
2
|
|
|
3
3
|
describe('custom frontend variant', () => {
|
|
4
4
|
/** @evidence SDK-V1-SCAFFOLD-CUSTOM */
|
|
5
5
|
it('rejects missing authored frontend composition', () => {
|
|
6
|
-
expect(
|
|
7
|
-
expect(
|
|
8
|
-
expect(
|
|
6
|
+
expect(domain.frontend).toBeDefined()
|
|
7
|
+
expect(domain.frontend?.source.kind).toBe('vite')
|
|
8
|
+
expect(domain.frontend?.routes.application).toMatchObject({
|
|
9
9
|
path: '/application',
|
|
10
10
|
handshake: 'none',
|
|
11
11
|
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineDomain, defineFrontend, requirements, vite } from '@astrale-os/sdk/domain'
|
|
2
|
+
import { K } from '@astrale-os/sdk/schema'
|
|
3
|
+
|
|
4
|
+
import { schema } from '#schema'
|
|
5
|
+
|
|
6
|
+
import runtime from './runtime.js'
|
|
7
|
+
|
|
8
|
+
/** Framework-neutral escape hatch: swap Vite or the browser implementation without changing Views. */
|
|
9
|
+
const frontend = defineFrontend({
|
|
10
|
+
schema,
|
|
11
|
+
source: vite(),
|
|
12
|
+
routes: {
|
|
13
|
+
application: { handshake: 'none' },
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
/** Build and publication composition; provider effects live in astrale.config.ts. */
|
|
18
|
+
export const domain = defineDomain({
|
|
19
|
+
schema,
|
|
20
|
+
runtime,
|
|
21
|
+
frontend,
|
|
22
|
+
requirements: requirements({
|
|
23
|
+
roles: [
|
|
24
|
+
{ role: K.core.nodes['graph.reader'], members: [requirements.domain] },
|
|
25
|
+
{ role: K.core.nodes['graph.writer'], members: [requirements.domain] },
|
|
26
|
+
],
|
|
27
|
+
}),
|
|
28
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"paths": {
|
|
8
|
+
"#views/*": ["../views/*/index.ts"]
|
|
9
|
+
},
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"skipLibCheck": false,
|
|
14
|
+
"verbatimModuleSyntax": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["main.ts"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { classIcon, defineSchema, domainIcon, KernelSchema, view } from '@astrale-os/sdk/schema'
|
|
2
|
+
import { Box } from '@astrale-os/sdk/schema/icons'
|
|
3
|
+
|
|
4
|
+
export const schema = defineSchema('astrale-domain.example.dev', {
|
|
5
|
+
name: 'Astrale Domain',
|
|
6
|
+
// Replace with the Domain's own drawings: small (24 x 24), and medium (64 x 64) and large
|
|
7
|
+
// (512 x 512) when it is shown larger.
|
|
8
|
+
icon: domainIcon({ small: classIcon.lucide(Box) }),
|
|
9
|
+
entrypoint: 'application',
|
|
10
|
+
dependencies: { kernel: KernelSchema },
|
|
11
|
+
classes: {},
|
|
12
|
+
views: {
|
|
13
|
+
application: view({}),
|
|
14
|
+
},
|
|
15
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mountApplication } from './application.view.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { mountApplication } from './application/index.js'
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
1
2
|
import { defineConfig } from 'vite'
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
4
|
-
root: '
|
|
5
|
+
root: 'frontend',
|
|
6
|
+
resolve: {
|
|
7
|
+
alias: [
|
|
8
|
+
{
|
|
9
|
+
find: /^#views\//,
|
|
10
|
+
replacement: fileURLToPath(new URL('./views/', import.meta.url)),
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
},
|
|
5
14
|
build: {
|
|
6
|
-
outDir: '
|
|
15
|
+
outDir: '../dist/frontend',
|
|
7
16
|
emptyOutDir: true,
|
|
8
17
|
},
|
|
9
18
|
})
|
|
@@ -5,10 +5,19 @@ This is a callable-only Domain with no frontend artifact or browser assets.
|
|
|
5
5
|
```text
|
|
6
6
|
schema/ public Domain contract
|
|
7
7
|
runtime.ts Actions, Workflows, Integrations, Providers, and initialization
|
|
8
|
-
|
|
8
|
+
domain.ts Schema and Runtime composition
|
|
9
9
|
tests/ cross-layer executable journeys
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Run `pnpm
|
|
13
|
-
`
|
|
14
|
-
|
|
12
|
+
Run `pnpm run deploy development` to build, verify, and make one immutable deployment of the
|
|
13
|
+
committed `development` Environment. It starts no local Worker or tunnel, and never installs: install
|
|
14
|
+
the URL it prints with `astrale domain install <url> -i <instance>`. There is no watch loop:
|
|
15
|
+
deploy each change. Run `pnpm build` to qualify its deploy bundle and print its build digest. Add
|
|
16
|
+
`views/` and `ui/` later only when the schema gains declared Views. Domain projects intentionally own
|
|
17
|
+
no `.spec` trees and import authoring contracts only through semantic `@astrale-os/sdk/*` subpaths.
|
|
18
|
+
|
|
19
|
+
This project starts at the `0.1.0-alpha.0` pre-release because it has no stable version yet.
|
|
20
|
+
`npm version prerelease --preid alpha` advances it to `0.1.0-alpha.1`, and `npm version minor`
|
|
21
|
+
leaves alpha at `0.1.0`. The Versions section of the
|
|
22
|
+
[`create-astrale-domain` README](https://www.npmjs.com/package/create-astrale-domain#versions) gives
|
|
23
|
+
the Release Please settings and the `0.x` rule.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { domain } from '../domain.js'
|
|
2
2
|
|
|
3
3
|
describe('none frontend variant', () => {
|
|
4
4
|
/** @evidence SDK-V1-SCAFFOLD-NONE */
|
|
5
|
-
it('rejects an implicit browser frontend by keeping
|
|
6
|
-
expect(
|
|
5
|
+
it('rejects an implicit browser frontend by keeping the Domain headless', () => {
|
|
6
|
+
expect(domain.frontend).toBeUndefined()
|
|
7
7
|
})
|
|
8
8
|
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineDomain, requirements } from '@astrale-os/sdk/domain'
|
|
2
|
+
import { K } from '@astrale-os/sdk/schema'
|
|
3
|
+
|
|
4
|
+
import { schema } from '#schema'
|
|
5
|
+
|
|
6
|
+
import runtime from './runtime.js'
|
|
7
|
+
|
|
8
|
+
/** Build and publication composition; provider effects live in astrale.config.ts. */
|
|
9
|
+
export const domain = defineDomain({
|
|
10
|
+
schema,
|
|
11
|
+
runtime,
|
|
12
|
+
requirements: requirements({
|
|
13
|
+
roles: [
|
|
14
|
+
{ role: K.core.nodes['graph.reader'], members: [requirements.domain] },
|
|
15
|
+
{ role: K.core.nodes['graph.writer'], members: [requirements.domain] },
|
|
16
|
+
],
|
|
17
|
+
}),
|
|
18
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { classIcon, defineSchema, domainIcon, KernelSchema } from '@astrale-os/sdk/schema'
|
|
2
|
+
import { Box } from '@astrale-os/sdk/schema/icons'
|
|
3
|
+
|
|
4
|
+
export const schema = defineSchema('astrale-domain.example.dev', {
|
|
5
|
+
name: 'Astrale Domain',
|
|
6
|
+
// Replace with the Domain's own drawings: small (24 x 24), and medium (64 x 64) and large
|
|
7
|
+
// (512 x 512) when it is shown larger.
|
|
8
|
+
icon: domainIcon({ small: classIcon.lucide(Box) }),
|
|
9
|
+
dependencies: { kernel: KernelSchema },
|
|
10
|
+
classes: {},
|
|
11
|
+
})
|
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
# Astrale Domain
|
|
2
2
|
|
|
3
|
-
This project is an ordinary Vite React application. `
|
|
4
|
-
|
|
5
|
-
presentation. It has no mandatory Shell runtime: add
|
|
6
|
-
the application genuinely needs Shell sessions, graph
|
|
3
|
+
This project is an ordinary Vite React application. `domain.ts` owns the small Worker-safe,
|
|
4
|
+
Schema-bound frontend deployment contract; `frontend/` owns TanStack Router and browser
|
|
5
|
+
composition; `ui/` owns reusable presentation. It has no mandatory Shell runtime: add
|
|
6
|
+
`@astrale-os/shell-react` independently when the application genuinely needs Shell sessions, graph
|
|
7
|
+
context, or View-stage integration.
|
|
7
8
|
|
|
8
9
|
```text
|
|
9
10
|
schema/ public Domain contract, including View declarations
|
|
10
|
-
runtime.ts
|
|
11
|
-
|
|
12
|
-
views/ schema-bound frontend declaration
|
|
11
|
+
runtime.ts Functions, Integrations, Providers, and initialization
|
|
12
|
+
domain.ts Schema, Runtime, and frontend composition
|
|
13
13
|
frontend/ Vite, file-based TanStack Router, and Tailwind entrypoint
|
|
14
14
|
ui/ styles and pure presentation components
|
|
15
15
|
tests/ cross-layer executable journeys
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Run `pnpm
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
Run `pnpm run deploy development` to build, verify, and make one immutable deployment of the
|
|
19
|
+
committed `development` Environment. It starts no local Worker, Vite server, or tunnel, and never
|
|
20
|
+
installs: install the URL it prints with `astrale domain install <url> -i <instance>`.
|
|
21
|
+
There is no watch loop: deploy each change. Run `pnpm build` to qualify Worker and frontend output
|
|
22
|
+
and print their build digest, and `pnpm run deploy production` to deploy the `production`
|
|
23
|
+
Environment through the selected adapter. Add semantic `rules/`, `queries/`, `mutations/`, and
|
|
24
|
+
`functions/` modules only when the Domain gains those responsibilities.
|
|
21
25
|
|
|
22
26
|
Domain projects intentionally own no `.spec` trees. Import authoring contracts through semantic
|
|
23
27
|
`@astrale-os/sdk/*` subpaths; never import Kernel Core or DSL directly. Routing remains a normal
|
|
24
28
|
TanStack Router concern; optional Astrale hooks remain normal React hooks inside route components.
|
|
29
|
+
|
|
30
|
+
This project starts at the `0.1.0-alpha.0` pre-release because it has no stable version yet.
|
|
31
|
+
`npm version prerelease --preid alpha` advances it to `0.1.0-alpha.1`, and `npm version minor`
|
|
32
|
+
leaves alpha at `0.1.0`. The Versions section of the
|
|
33
|
+
[`create-astrale-domain` README](https://www.npmjs.com/package/create-astrale-domain#versions) gives
|
|
34
|
+
the Release Please settings and the `0.x` rule.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { domain } from '../domain.js'
|
|
2
2
|
|
|
3
3
|
describe('react frontend variant', () => {
|
|
4
4
|
/** @evidence SDK-V1-SCAFFOLD-REACT */
|
|
5
5
|
it('rejects missing authored frontend composition', () => {
|
|
6
|
-
expect(
|
|
7
|
-
expect(
|
|
8
|
-
expect(
|
|
6
|
+
expect(domain.frontend).toBeDefined()
|
|
7
|
+
expect(domain.frontend?.source.kind).toBe('vite')
|
|
8
|
+
expect(domain.frontend?.routes.application).toMatchObject({
|
|
9
9
|
path: '/application',
|
|
10
10
|
handshake: 'none',
|
|
11
11
|
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineDomain, defineFrontend, requirements, vite } from '@astrale-os/sdk/domain'
|
|
2
|
+
import { K } from '@astrale-os/sdk/schema'
|
|
3
|
+
|
|
4
|
+
import { schema } from '#schema'
|
|
5
|
+
|
|
6
|
+
import runtime from './runtime.js'
|
|
7
|
+
|
|
8
|
+
/** The complete deploy contract; Vite and the browser application stay author-owned. */
|
|
9
|
+
const frontend = defineFrontend({
|
|
10
|
+
schema,
|
|
11
|
+
source: vite(),
|
|
12
|
+
routes: {
|
|
13
|
+
application: { handshake: 'none' },
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
/** Build and publication composition; provider effects live in astrale.config.ts. */
|
|
18
|
+
export const domain = defineDomain({
|
|
19
|
+
schema,
|
|
20
|
+
runtime,
|
|
21
|
+
frontend,
|
|
22
|
+
requirements: requirements({
|
|
23
|
+
roles: [
|
|
24
|
+
{ role: K.core.nodes['graph.reader'], members: [requirements.domain] },
|
|
25
|
+
{ role: K.core.nodes['graph.writer'], members: [requirements.domain] },
|
|
26
|
+
],
|
|
27
|
+
}),
|
|
28
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"paths": {
|
|
9
|
+
"#schema": ["../schema/index.ts"],
|
|
10
|
+
"#ui/*": ["../ui/*/index.ts"]
|
|
11
|
+
},
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"allowImportingTsExtensions": true,
|
|
15
|
+
"skipLibCheck": false,
|
|
16
|
+
"verbatimModuleSyntax": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { classIcon, defineSchema, domainIcon, KernelSchema, view } from '@astrale-os/sdk/schema'
|
|
2
|
+
import { Box } from '@astrale-os/sdk/schema/icons'
|
|
3
|
+
|
|
4
|
+
export const schema = defineSchema('astrale-domain.example.dev', {
|
|
5
|
+
name: 'Astrale Domain',
|
|
6
|
+
// Replace with the Domain's own drawings: small (24 x 24), and medium (64 x 64) and large
|
|
7
|
+
// (512 x 512) when it is shown larger.
|
|
8
|
+
icon: domainIcon({ small: classIcon.lucide(Box) }),
|
|
9
|
+
entrypoint: 'application',
|
|
10
|
+
dependencies: { kernel: KernelSchema },
|
|
11
|
+
classes: {},
|
|
12
|
+
views: {
|
|
13
|
+
application: view({}),
|
|
14
|
+
},
|
|
15
|
+
})
|
|
@@ -7,7 +7,6 @@ import { defineConfig } from 'vite'
|
|
|
7
7
|
export default defineConfig({
|
|
8
8
|
root: 'frontend',
|
|
9
9
|
resolve: {
|
|
10
|
-
dedupe: ['@astrale-os/sdk', '@tanstack/react-router', 'react', 'react-dom'],
|
|
11
10
|
alias: [
|
|
12
11
|
{
|
|
13
12
|
find: /^#schema$/,
|
|
@@ -23,8 +22,8 @@ export default defineConfig({
|
|
|
23
22
|
tanstackRouter({
|
|
24
23
|
target: 'react',
|
|
25
24
|
autoCodeSplitting: true,
|
|
26
|
-
routesDirectory: './
|
|
27
|
-
generatedRouteTree: './
|
|
25
|
+
routesDirectory: './src/routes',
|
|
26
|
+
generatedRouteTree: './src/routeTree.gen.ts',
|
|
28
27
|
}),
|
|
29
28
|
react(),
|
|
30
29
|
tailwindcss(),
|
package/template/CLAUDE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Astrale domain
|
|
2
2
|
|
|
3
3
|
Load the `astrale-domain` skill before changing Schema, Rules, Queries, Mutations, Actions,
|
|
4
|
-
Workflows, Integrations, Providers, Views, UI,
|
|
4
|
+
Workflows, Integrations, Providers, Views, UI, or security. Install it user-level if
|
|
5
5
|
needed:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
@@ -11,15 +11,53 @@ npx skills add astrale-os/cli -g
|
|
|
11
11
|
This scaffold is intentionally minimal. React and custom projects include one schema-declared
|
|
12
12
|
application View to prove frontend delivery; `--frontend none` is callable-only. Start each real
|
|
13
13
|
behavior in its semantic submodule, keep owners explicit, put focused tests in `__tests__`, use
|
|
14
|
-
registered package `#` imports across owners, and keep `runtime.ts` and `
|
|
14
|
+
registered package `#` imports across owners, and keep `runtime.ts` and `domain.ts` limited to
|
|
15
15
|
their exact composition responsibilities.
|
|
16
|
-
Actions perform
|
|
16
|
+
Actions read what they need and perform at most one effect; Workflows coordinate several effects that
|
|
17
|
+
cannot commit together.
|
|
18
|
+
The scaffold's Kernel dependency and Domain requirements authorize bound graph executors: the
|
|
19
|
+
installed Domain is a member of the Kernel Roles `graph.reader` and `graph.writer`, which admit it to
|
|
20
|
+
`query` and `mutate`. Retain them while handlers access graph state; use `graph.self` for
|
|
21
|
+
Domain-owned facts.
|
|
22
|
+
|
|
23
|
+
Add `schema/modules/<module>/states/` only when a Schema business module owns a finite persisted
|
|
24
|
+
lifecycle with real illegal transitions. Declare it once with `stateMachine`, persist it with
|
|
25
|
+
`stateProperty(machine)`, initialize with `machine.initial`, and commit allowed decisions through
|
|
26
|
+
`mutation.transition`. Keep guards, authority, provider effects, retries, and deletion outside the
|
|
27
|
+
relation. The `states/` directory is optional organization inside the owning Schema module; there is
|
|
28
|
+
no top-level States layer or `#states` alias.
|
|
29
|
+
Schema declarations use a relative sibling import for the machine. Runtime layers in the same
|
|
30
|
+
business module use `#schema/modules/<module>/states` so Worker bundling retains the machine without
|
|
31
|
+
loading build-only Schema declarations.
|
|
17
32
|
|
|
18
33
|
`pnpm pack` runs the single `astrale-domain package` journey. The published package exposes its
|
|
19
|
-
Schema at the package root
|
|
20
|
-
remain
|
|
34
|
+
Schema contract at the package root. Runtime, handlers, Providers, frontend code, and deployment
|
|
35
|
+
adapters remain implementation inputs and are not published. Do not add a parallel build or
|
|
36
|
+
declaration-rewrite script.
|
|
37
|
+
|
|
38
|
+
`pnpm run deploy development` builds and verifies the release locally, then makes one immutable
|
|
39
|
+
deployment of it through the Environment's adapter, with a signing key generated for that
|
|
40
|
+
deployment, and prints its URL. A deploy never installs, reads an active instance, or starts a local
|
|
41
|
+
Worker, Vite server, or tunnel: install the URL it prints with
|
|
42
|
+
`astrale domain install <url> -i <instance>`. There is no watch loop: deploy each change.
|
|
43
|
+
Redeploying the same release reuses its deployment. With the Astrale managed adapter the deployments
|
|
44
|
+
live on Admin's Services and every Environment uses the authenticated Astrale CLI identity;
|
|
45
|
+
with the Cloudflare adapter they live in the platform's dispatch namespace, where only the platform
|
|
46
|
+
deploys. Do not add a parallel tunnel, install loop, frontend watcher, or shutdown uninstall. Do not
|
|
47
|
+
declare `installation` on a Project Environment, nor `instance`, `signingIdentity`, or `organization`
|
|
48
|
+
in `astrale()`:
|
|
49
|
+
each is refused. `cloudflare()` requires `namespace` and refuses `signingIdentity`, `route` and
|
|
50
|
+
`workerName`: do not add them.
|
|
21
51
|
|
|
22
52
|
Domain projects do not contain `.spec` directories. Do not add one: public SDK types, package
|
|
23
53
|
facades, the Domain knowledge rules, and executable tests are the contract guardrails. Import Core
|
|
24
54
|
and DSL authoring values only from the matching `@astrale-os/sdk/*` semantic subpath; never import
|
|
25
55
|
`@astrale-os/kernel-core` or `@astrale-os/kernel-dsl` directly.
|
|
56
|
+
|
|
57
|
+
`tsconfig.json` is the single TypeScript program for Worker code, Views, and tests: `lib` includes
|
|
58
|
+
the DOM, `types` is `["node", "vitest/globals"]`, and `skipLibCheck` is `false`. The Worker runs with
|
|
59
|
+
`nodejs_compat`, Vitest supplies its globals, and `skipLibCheck: false` keeps third-party
|
|
60
|
+
declarations verified. Do not narrow `types` or split the project per runtime. The SDK and Kernel
|
|
61
|
+
type-check their own Worker-facing sources against the Worker typings, so a typed environment
|
|
62
|
+
divergence in a published entrypoint is rejected upstream rather than in your project; runtime
|
|
63
|
+
behavior reaching those entrypoints stays covered by your own tests.
|
package/template/index.ts
CHANGED