@astrale-os/cli 0.8.1-alpha.7 → 1.0.0-beta.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/README.md +15 -3
- package/dist/astrale.js +86 -35
- package/package.json +5 -5
- package/src/commands/__tests__/domain-install-operation.test.ts +121 -0
- package/src/commands/__tests__/domain-install-owned.test.ts +66 -0
- package/src/commands/__tests__/install-direct.test.ts +3 -2
- package/src/commands/domain/install.ts +78 -15
- package/src/connection/__tests__/errors.test.ts +82 -6
- package/src/connection/command.ts +9 -1
- package/src/connection/errors.ts +19 -8
- package/src/connection/index.ts +1 -1
- package/src/connection/reasons.ts +26 -12
- package/src/program/__tests__/program.test.ts +1 -1
- package/studio/client/dist/assets/{elk-api-D0cBetPW.js → elk-api-D2xgMJvi.js} +1 -1
- package/studio/client/dist/assets/{index-BQnJ5sgd.css → index-BMdnsIJA.css} +1 -1
- package/studio/client/dist/assets/index-D-vRV8w7.js +8 -0
- package/studio/client/dist/assets/index-LGSWRrk8.js +81 -0
- package/studio/client/dist/index.html +2 -2
- package/studio/package.json +1 -1
- package/studio/server/agent/prompts/anchors.test.ts +74 -0
- package/studio/server/agent/prompts/anchors.ts +85 -15
- package/studio/server/agent/prompts/system.test.ts +12 -0
- package/studio/server/agent/prompts/system.ts +6 -6
- package/studio/server/api.ts +1 -5
- package/studio/server/cache.ts +5 -2
- package/studio/server/domain.test.ts +67 -0
- package/studio/server/domain.ts +29 -6
- package/studio/server/index.ts +1 -3
- package/studio/server/introspect/anatomy-extras.test.ts +104 -1
- package/studio/server/introspect/anatomy-extras.ts +340 -8
- package/studio/server/introspect/anatomy.test.ts +33 -0
- package/studio/server/introspect/anatomy.ts +22 -7
- package/studio/server/introspect/bundle.ts +7 -1
- package/studio/server/introspect/canonical-schema.test.ts +395 -0
- package/studio/server/introspect/canonical-schema.ts +751 -0
- package/studio/server/introspect/core-extractor.ts +30 -10
- package/studio/server/introspect/core.ts +4 -2
- package/studio/server/introspect/diff.test.ts +124 -0
- package/studio/server/introspect/diff.ts +252 -23
- package/studio/server/introspect/extractor.ts +46 -14
- package/studio/server/introspect/overlay-tsmorph.test.ts +164 -1
- package/studio/server/introspect/overlay-tsmorph.ts +381 -106
- package/studio/server/introspect/overlay.test.ts +72 -0
- package/studio/server/introspect/overlay.ts +16 -6
- package/studio/server/introspect/runtime.test.ts +217 -0
- package/studio/server/introspect/runtime.ts +18 -6
- package/studio/server/introspect/schema-refs.test.ts +100 -0
- package/studio/server/introspect/schema-refs.ts +23 -2
- package/studio/server/state/baseline.test.ts +51 -0
- package/studio/server/state/baseline.ts +31 -2
- package/studio/server/state/create.test.ts +37 -0
- package/studio/server/state/create.ts +21 -15
- package/studio/server/state/instance.test.ts +63 -0
- package/studio/server/state/instance.ts +65 -29
- package/studio/server/state/views.test.ts +209 -9
- package/studio/server/state/views.ts +176 -69
- package/studio/server/watch.test.ts +36 -0
- package/studio/server/watch.ts +24 -16
- package/studio/server/workspace-watch.ts +8 -3
- package/studio/shared/types.ts +164 -33
- package/studio/client/dist/assets/index-Dspir4w7.js +0 -81
- package/studio/client/dist/assets/index-bVD2KJgz.js +0 -8
- package/studio/server/view-dev-server.test.ts +0 -111
- package/studio/server/view-dev-server.ts +0 -372
|
@@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
|
3
3
|
import { tmpdir } from 'node:os'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
|
|
6
|
-
import { buildHandlerLinks } from './overlay-tsmorph'
|
|
6
|
+
import { buildHandlerLinks, buildSchemaAnnotations, buildSourceSpans } from './overlay-tsmorph'
|
|
7
7
|
|
|
8
8
|
test('resolves authorization hooks from imported remote method definitions', () => {
|
|
9
9
|
const root = mkdtempSync(join(tmpdir(), 'astrale-studio-handler-links-'))
|
|
@@ -102,3 +102,166 @@ test('resolves authorization hooks from imported remote method definitions', ()
|
|
|
102
102
|
rmSync(root, { recursive: true, force: true })
|
|
103
103
|
}
|
|
104
104
|
})
|
|
105
|
+
|
|
106
|
+
test('links current implementation handlers and current edge source spans', () => {
|
|
107
|
+
const root = mkdtempSync(join(tmpdir(), 'astrale-studio-current-overlay-'))
|
|
108
|
+
const schemaDir = join(root, 'schema')
|
|
109
|
+
const actionsDir = join(root, 'actions')
|
|
110
|
+
mkdirSync(schemaDir)
|
|
111
|
+
mkdirSync(actionsDir)
|
|
112
|
+
writeFileSync(
|
|
113
|
+
join(root, 'package.json'),
|
|
114
|
+
JSON.stringify({ imports: { '#actions/*': './actions/*.ts' } }),
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
writeFileSync(
|
|
118
|
+
join(root, 'implementation.ts'),
|
|
119
|
+
`
|
|
120
|
+
import { rename } from '#actions/rename'
|
|
121
|
+
import { createIssue } from '#actions/create-issue'
|
|
122
|
+
export const domain = defineDomain.public({
|
|
123
|
+
schema,
|
|
124
|
+
handlers: {
|
|
125
|
+
functions: { createIssue },
|
|
126
|
+
classes: { Issue: { rename } },
|
|
127
|
+
interfaces: {},
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
`,
|
|
131
|
+
)
|
|
132
|
+
writeFileSync(
|
|
133
|
+
join(actionsDir, 'rename.ts'),
|
|
134
|
+
`
|
|
135
|
+
export function rename({ input }) {
|
|
136
|
+
return graph.update(input)
|
|
137
|
+
}
|
|
138
|
+
`,
|
|
139
|
+
)
|
|
140
|
+
writeFileSync(
|
|
141
|
+
join(actionsDir, 'create-issue.ts'),
|
|
142
|
+
`export const createIssue = ({ input }) => graph.create(input)`,
|
|
143
|
+
)
|
|
144
|
+
writeFileSync(
|
|
145
|
+
join(schemaDir, 'members.ts'),
|
|
146
|
+
`
|
|
147
|
+
export const iIssue = nodeInterface({
|
|
148
|
+
properties: { title: property({ type: 'string' }) },
|
|
149
|
+
})
|
|
150
|
+
export const Issue = nodeClass({
|
|
151
|
+
properties: { title: property({ type: 'string' }) },
|
|
152
|
+
methods: { rename },
|
|
153
|
+
})
|
|
154
|
+
export const assigned_to = edgeClass.directed({
|
|
155
|
+
source: { as: 'issue', accepts: [Issue], outgoing: '0..*' },
|
|
156
|
+
target: { as: 'owner', accepts: [Issue], incoming: '0..1' },
|
|
157
|
+
properties: { note: property({ type: 'string' }) },
|
|
158
|
+
})
|
|
159
|
+
export const createIssue = fn({ auth: 'anonymous', input, output })
|
|
160
|
+
`,
|
|
161
|
+
)
|
|
162
|
+
writeFileSync(
|
|
163
|
+
join(schemaDir, 'index.ts'),
|
|
164
|
+
`
|
|
165
|
+
import { Issue, assigned_to, createIssue, iIssue as issueInterface } from './members.js'
|
|
166
|
+
const schemaInput = {
|
|
167
|
+
interfaces: { Issue: issueInterface },
|
|
168
|
+
classes: { Issue, assigned_to },
|
|
169
|
+
functions: { createIssue },
|
|
170
|
+
} as const
|
|
171
|
+
export const schema = defineSchema('issues.example', schemaInput)
|
|
172
|
+
`,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
const links = buildHandlerLinks({
|
|
177
|
+
ir: {
|
|
178
|
+
version: 'v1',
|
|
179
|
+
domain: 'issues.example',
|
|
180
|
+
types: {},
|
|
181
|
+
interfaces: {},
|
|
182
|
+
classes: {
|
|
183
|
+
Issue: {
|
|
184
|
+
type: 'node',
|
|
185
|
+
name: 'Issue',
|
|
186
|
+
properties: {},
|
|
187
|
+
methods: {
|
|
188
|
+
rename: {
|
|
189
|
+
name: 'rename',
|
|
190
|
+
params: {},
|
|
191
|
+
returns: {},
|
|
192
|
+
static: false,
|
|
193
|
+
inheritance: 'default',
|
|
194
|
+
auth: 'authorized',
|
|
195
|
+
} as any,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
imports: {},
|
|
200
|
+
functions: {
|
|
201
|
+
createIssue: {
|
|
202
|
+
name: 'createIssue',
|
|
203
|
+
input: {},
|
|
204
|
+
params: {},
|
|
205
|
+
output: { mode: 'value', schema: {} },
|
|
206
|
+
returns: {},
|
|
207
|
+
static: true,
|
|
208
|
+
inheritance: 'default',
|
|
209
|
+
auth: 'anonymous',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
domainRoot: root,
|
|
214
|
+
})
|
|
215
|
+
expect(links).toHaveLength(2)
|
|
216
|
+
expect(links.find((link) => link.ownerKind === 'class')).toMatchObject({
|
|
217
|
+
owner: 'Issue',
|
|
218
|
+
ownerKind: 'class',
|
|
219
|
+
method: 'rename',
|
|
220
|
+
wiringFile: 'implementation.ts',
|
|
221
|
+
handlerFile: 'actions/rename.ts',
|
|
222
|
+
implemented: true,
|
|
223
|
+
auth: 'required',
|
|
224
|
+
callableAuth: 'authorized',
|
|
225
|
+
authorize: 'custom',
|
|
226
|
+
kernelCalls: ['graph.update'],
|
|
227
|
+
})
|
|
228
|
+
expect(links.find((link) => link.ownerKind === 'function')).toMatchObject({
|
|
229
|
+
owner: 'issues.example',
|
|
230
|
+
method: 'createIssue',
|
|
231
|
+
wiringFile: 'implementation.ts',
|
|
232
|
+
handlerFile: 'actions/create-issue.ts',
|
|
233
|
+
implemented: true,
|
|
234
|
+
static: true,
|
|
235
|
+
auth: 'public',
|
|
236
|
+
callableAuth: 'anonymous',
|
|
237
|
+
kernelCalls: ['graph.create'],
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
const spans = buildSourceSpans({ ir: null, schemaDir })
|
|
241
|
+
expect(spans['interface.Issue.property.title']?.file).toBe('schema/members.ts')
|
|
242
|
+
expect(spans['class.Issue.property.title']?.file).toBe('schema/members.ts')
|
|
243
|
+
expect(spans['edge.assigned_to.endpoint.issue']?.file).toBe('schema/members.ts')
|
|
244
|
+
expect(spans['edge.assigned_to.endpoint.owner']?.file).toBe('schema/members.ts')
|
|
245
|
+
expect(spans['edge.assigned_to.property.note']?.file).toBe('schema/members.ts')
|
|
246
|
+
expect(spans['function.createIssue']?.file).toBe('schema/members.ts')
|
|
247
|
+
} finally {
|
|
248
|
+
rmSync(root, { recursive: true, force: true })
|
|
249
|
+
}
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
test('does not emit the obsolete enum update warning', () => {
|
|
253
|
+
expect(
|
|
254
|
+
buildSchemaAnnotations({
|
|
255
|
+
ir: {
|
|
256
|
+
classes: {
|
|
257
|
+
Issue: {
|
|
258
|
+
type: 'node',
|
|
259
|
+
name: 'Issue',
|
|
260
|
+
properties: { status: { type: 'string', enum: ['open', 'closed'] } },
|
|
261
|
+
methods: {},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
} as any,
|
|
265
|
+
}),
|
|
266
|
+
).toEqual([])
|
|
267
|
+
})
|