@astrale-os/cli 1.0.0-beta.7 → 1.0.0-beta.9
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/dist/astrale.js +1531 -1356
- package/dist/public/connect-core.js +4 -4
- package/dist/types/admin/binding.d.ts +19 -0
- package/dist/types/admin/instance/client.d.ts +22 -0
- package/dist/types/admin/instance/index.d.ts +2 -0
- package/dist/types/admin/instance/model.d.ts +3 -9
- package/dist/types/connection/auth.d.ts +3 -0
- package/dist/types/connection/call.d.ts +3 -0
- package/dist/types/connection/command.d.ts +27 -0
- package/dist/types/connection/credential.d.ts +14 -0
- package/dist/types/connection/errors.d.ts +1 -0
- package/dist/types/connection/exchange.d.ts +9 -0
- package/dist/types/connection/failure/classify.d.ts +2 -0
- package/dist/types/connection/failure/index.d.ts +5 -0
- package/dist/types/connection/failure/model.d.ts +25 -0
- package/dist/types/connection/failure/render.d.ts +3 -0
- package/dist/types/connection/index.d.ts +8 -0
- package/dist/types/connection/reasons.d.ts +37 -0
- package/dist/types/connection/self.d.ts +37 -0
- package/dist/types/connection/session.d.ts +31 -0
- package/dist/types/connection/target.d.ts +38 -0
- package/dist/types/lib/admin-instance.d.ts +17 -0
- package/dist/types/lib/failure-debug.d.ts +1 -0
- package/dist/types/lib/instance.d.ts +7 -1
- package/dist/types/lib/log.d.ts +3 -1
- package/dist/types/lib/self.d.ts +9 -0
- package/package.json +1 -1
- package/src/admin/instance/__tests__/client.test.ts +4 -104
- package/src/admin/instance/client.ts +2 -96
- package/src/admin/instance/index.ts +1 -2
- package/src/admin/instance/model.ts +4 -14
- package/src/commands/__tests__/admin-instance.test.ts +11 -8
- package/src/commands/__tests__/instance-list-rows.test.ts +1 -1
- package/src/commands/call-describe.ts +1 -1
- package/src/commands/call.ts +2 -2
- package/src/commands/domain/list.ts +1 -1
- package/src/commands/domain/publish.ts +14 -11
- package/src/commands/get.ts +1 -1
- package/src/commands/instance/create.ts +8 -16
- package/src/commands/instance/delete.ts +7 -6
- package/src/commands/instance/list.ts +2 -2
- package/src/commands/instance/status.ts +4 -4
- package/src/commands/instance/use.ts +16 -12
- package/src/commands/introspect.ts +5 -5
- package/src/commands/view.ts +3 -3
- package/src/connection/__tests__/credential.test.ts +19 -0
- package/src/connection/__tests__/target.test.ts +1 -0
- package/src/connection/auth.ts +13 -0
- package/src/connection/failure/index.ts +1 -1
- package/src/connection/session.ts +12 -1
- package/src/lib/__tests__/command-dx.test.ts +1 -1
- package/src/lib/__tests__/domain-publication.test.ts +6 -1
- package/src/lib/__tests__/instance-candidates.test.ts +1 -3
- package/src/lib/__tests__/instance-target.test.ts +1 -0
- package/src/lib/__tests__/log-errors.test.ts +11 -0
- package/src/lib/admin-instance.ts +14 -8
- package/src/lib/command-dx.ts +8 -5
- package/src/lib/domain-publication.ts +8 -6
- package/src/lib/instance-candidates.ts +2 -2
- package/src/lib/instance.ts +14 -10
- package/src/lib/log.ts +6 -4
- package/src/lib/provision-instance.ts +34 -57
- package/src/program/__tests__/program.test.ts +20 -4
- package/src/program/build.ts +2 -2
- package/src/setup/__tests__/instance-step.test.ts +27 -10
- package/src/setup/steps/instance.ts +22 -15
- package/studio/client/dist/assets/{elk-api-Di4OXGNH.js → elk-api-ByzoDZWH.js} +1 -1
- package/studio/client/dist/assets/{index-DTjvkOUX.js → index-B0RCgUOT.js} +4 -4
- package/studio/client/dist/assets/{index-BLm6J11H.js → index-N8J8EKlB.js} +2 -2
- package/studio/client/dist/index.html +1 -1
- package/studio/server/introspect/runtime.test.ts +2 -2
- package/viewer/dist/main.js +28 -28
- package/src/commands/__tests__/instance-create-hosts.test.ts +0 -29
- /package/src/{connection/failure/debug.ts → lib/failure-debug.ts} +0 -0
package/src/program/build.ts
CHANGED
|
@@ -159,7 +159,7 @@ Command groups:
|
|
|
159
159
|
|
|
160
160
|
Path syntax:
|
|
161
161
|
/:origin Domain root
|
|
162
|
-
/:origin:class.Name Class node
|
|
162
|
+
/:origin:class.Name Class node
|
|
163
163
|
/:origin:class.Name:method Static callable
|
|
164
164
|
<nodePath>::method Instance method dispatch — double colon ::
|
|
165
165
|
@nodeId Reference a node by its UID
|
|
@@ -174,7 +174,7 @@ Examples:
|
|
|
174
174
|
$ astrale instance status staging
|
|
175
175
|
$ astrale token --audience shell.astrale.ai --ttl 3600
|
|
176
176
|
$ astrale query /:notes.example.dev:class.Note --limit 50
|
|
177
|
-
$ astrale introspect /:
|
|
177
|
+
$ astrale introspect /:kernel.astrale.ai:class.Identity:whois
|
|
178
178
|
$ astrale query --file query.v6.json --cursor "$CURSOR"
|
|
179
179
|
`,
|
|
180
180
|
)
|
|
@@ -27,11 +27,15 @@ function instance(slug: string, state: OwnedInstanceInfo['state'] = 'ready'): Ow
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function inventory(instances: OwnedInstanceInfo[], identity?: string) {
|
|
31
|
+
return { instances, ...(identity ? { identity } : {}) }
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
function dependencies(
|
|
31
35
|
overrides: Partial<InstanceSetupDependencies> = {},
|
|
32
36
|
): InstanceSetupDependencies {
|
|
33
37
|
return {
|
|
34
|
-
fetchOwned: mock(async () => []),
|
|
38
|
+
fetchOwned: mock(async () => inventory([])),
|
|
35
39
|
adopt: mock(async () => {}),
|
|
36
40
|
selectReady: mock(async (instances) => instances[0] ?? null),
|
|
37
41
|
confirmCreate: mock(async () => true),
|
|
@@ -48,12 +52,14 @@ describe('setup owned-instance reconciliation', () => {
|
|
|
48
52
|
test('silently adopts the sole owned ready instance', async () => {
|
|
49
53
|
const ready = instance('only')
|
|
50
54
|
const failed = instance('old-attempt', 'failed')
|
|
51
|
-
const deps = dependencies({
|
|
55
|
+
const deps = dependencies({
|
|
56
|
+
fetchOwned: mock(async () => inventory([failed, ready], 'manager')),
|
|
57
|
+
})
|
|
52
58
|
|
|
53
59
|
await expect(ensureOwnedInstance(ctx, deps)).resolves.toBe('fixed')
|
|
54
60
|
|
|
55
61
|
expect(deps.adopt).toHaveBeenCalledTimes(1)
|
|
56
|
-
expect(deps.adopt).toHaveBeenCalledWith(ready)
|
|
62
|
+
expect(deps.adopt).toHaveBeenCalledWith(ready, 'manager')
|
|
57
63
|
expect(deps.selectReady).not.toHaveBeenCalled()
|
|
58
64
|
expect(deps.confirmCreate).not.toHaveBeenCalled()
|
|
59
65
|
expect(deps.provision).not.toHaveBeenCalled()
|
|
@@ -64,14 +70,14 @@ describe('setup owned-instance reconciliation', () => {
|
|
|
64
70
|
const second = instance('second')
|
|
65
71
|
const pending = instance('pending', 'provisioning')
|
|
66
72
|
const deps = dependencies({
|
|
67
|
-
fetchOwned: mock(async () => [first, pending, second]),
|
|
73
|
+
fetchOwned: mock(async () => inventory([first, pending, second], 'manager')),
|
|
68
74
|
selectReady: mock(async (instances) => instances[1] ?? null),
|
|
69
75
|
})
|
|
70
76
|
|
|
71
77
|
await expect(ensureOwnedInstance(ctx, deps)).resolves.toBe('fixed')
|
|
72
78
|
|
|
73
79
|
expect(deps.selectReady).toHaveBeenCalledWith([first, second])
|
|
74
|
-
expect(deps.adopt).toHaveBeenCalledWith(second)
|
|
80
|
+
expect(deps.adopt).toHaveBeenCalledWith(second, 'manager')
|
|
75
81
|
expect(deps.confirmCreate).not.toHaveBeenCalled()
|
|
76
82
|
expect(deps.provision).not.toHaveBeenCalled()
|
|
77
83
|
})
|
|
@@ -80,7 +86,7 @@ describe('setup owned-instance reconciliation', () => {
|
|
|
80
86
|
const first = instance('first')
|
|
81
87
|
const second = instance('second')
|
|
82
88
|
const deps = dependencies({
|
|
83
|
-
fetchOwned: mock(async () => [first, second]),
|
|
89
|
+
fetchOwned: mock(async () => inventory([first, second])),
|
|
84
90
|
selectReady: mock(async () => null),
|
|
85
91
|
})
|
|
86
92
|
|
|
@@ -165,7 +171,9 @@ describe('setup owned-instance reconciliation', () => {
|
|
|
165
171
|
phase: 'installing:default-domains',
|
|
166
172
|
}
|
|
167
173
|
const failed = { ...instance('broken', 'failed'), error: 'postInstall failed' }
|
|
168
|
-
const deps = dependencies({
|
|
174
|
+
const deps = dependencies({
|
|
175
|
+
fetchOwned: mock(async () => inventory([provisioning, failed])),
|
|
176
|
+
})
|
|
169
177
|
const logged: string[] = []
|
|
170
178
|
const original = console.log
|
|
171
179
|
console.log = mock((...args: unknown[]) => {
|
|
@@ -218,10 +226,10 @@ describe('owned-instance adoption', () => {
|
|
|
218
226
|
console.log = mock(() => {})
|
|
219
227
|
|
|
220
228
|
try {
|
|
221
|
-
await adoptOwnedInstance(owned, {
|
|
229
|
+
await adoptOwnedInstance(owned, 'manager', {
|
|
222
230
|
upsert: mock(async (...args) => {
|
|
223
231
|
calls.push(['upsert', ...args])
|
|
224
|
-
return {}
|
|
232
|
+
return { entry: {} }
|
|
225
233
|
}),
|
|
226
234
|
activate: mock(async (...args) => {
|
|
227
235
|
calls.push(['activate', ...args])
|
|
@@ -232,7 +240,16 @@ describe('owned-instance adoption', () => {
|
|
|
232
240
|
}
|
|
233
241
|
|
|
234
242
|
expect(calls).toEqual([
|
|
235
|
-
[
|
|
243
|
+
[
|
|
244
|
+
'upsert',
|
|
245
|
+
{
|
|
246
|
+
key: 'existing',
|
|
247
|
+
slug: 'existing',
|
|
248
|
+
url: 'https://existing.eu.astrale.ai',
|
|
249
|
+
organizationId: 'org_existing',
|
|
250
|
+
defaultIdentity: 'manager',
|
|
251
|
+
},
|
|
252
|
+
],
|
|
236
253
|
['activate', 'existing'],
|
|
237
254
|
])
|
|
238
255
|
})
|
|
@@ -4,7 +4,7 @@ import type { OwnedInstanceInfo } from '../../lib/admin-instance'
|
|
|
4
4
|
import type { SetupContext, SetupStep } from '../types'
|
|
5
5
|
|
|
6
6
|
import { AstraleError } from '../../errors'
|
|
7
|
-
import {
|
|
7
|
+
import { listOwnedInstancesWithIdentity } from '../../lib/admin-instance'
|
|
8
8
|
import { normalizeInstanceKernelUrl, setActive, upsertManagedBookmark } from '../../lib/instance'
|
|
9
9
|
import { readLocalStatus } from '../../lib/local-status'
|
|
10
10
|
import { log, withSpinner } from '../../lib/log'
|
|
@@ -14,8 +14,11 @@ import { provisionInstance, type ProvisionResult } from '../../lib/provision-ins
|
|
|
14
14
|
import { guiOrigin, slugError } from '../util'
|
|
15
15
|
|
|
16
16
|
export type InstanceSetupDependencies = {
|
|
17
|
-
fetchOwned: (ctx: SetupContext) => Promise<
|
|
18
|
-
|
|
17
|
+
fetchOwned: (ctx: SetupContext) => Promise<{
|
|
18
|
+
readonly instances: OwnedInstanceInfo[]
|
|
19
|
+
readonly identity?: string
|
|
20
|
+
}>
|
|
21
|
+
adopt: (info: OwnedInstanceInfo, identity?: string) => Promise<void>
|
|
19
22
|
selectReady: (instances: OwnedInstanceInfo[]) => Promise<OwnedInstanceInfo | null>
|
|
20
23
|
confirmCreate: () => Promise<boolean>
|
|
21
24
|
promptSlug: () => Promise<string | undefined>
|
|
@@ -23,12 +26,7 @@ export type InstanceSetupDependencies = {
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export type OwnedInstanceAdoptionDependencies = {
|
|
26
|
-
upsert:
|
|
27
|
-
key: string,
|
|
28
|
-
slug: string,
|
|
29
|
-
url: string,
|
|
30
|
-
organizationId?: string,
|
|
31
|
-
) => Promise<{ repointedFrom?: string }>
|
|
29
|
+
upsert: typeof upsertManagedBookmark
|
|
32
30
|
activate: (slug: string) => Promise<unknown>
|
|
33
31
|
}
|
|
34
32
|
|
|
@@ -41,12 +39,19 @@ function hero(slug: string, kernelUrl: string): void {
|
|
|
41
39
|
|
|
42
40
|
export async function adoptOwnedInstance(
|
|
43
41
|
info: OwnedInstanceInfo,
|
|
42
|
+
defaultIdentity?: string,
|
|
44
43
|
deps: OwnedInstanceAdoptionDependencies = {
|
|
45
44
|
upsert: upsertManagedBookmark,
|
|
46
45
|
activate: setActive,
|
|
47
46
|
},
|
|
48
47
|
): Promise<void> {
|
|
49
|
-
const { repointedFrom } = await deps.upsert(
|
|
48
|
+
const { repointedFrom } = await deps.upsert({
|
|
49
|
+
key: info.slug,
|
|
50
|
+
slug: info.slug,
|
|
51
|
+
url: info.url,
|
|
52
|
+
...(info.organizationId ? { organizationId: info.organizationId } : {}),
|
|
53
|
+
...(defaultIdentity ? { defaultIdentity } : {}),
|
|
54
|
+
})
|
|
50
55
|
await deps.activate(info.slug)
|
|
51
56
|
if (repointedFrom) {
|
|
52
57
|
log.warn(
|
|
@@ -61,7 +66,7 @@ function defaultDependencies(ctx: SetupContext): InstanceSetupDependencies {
|
|
|
61
66
|
return {
|
|
62
67
|
fetchOwned: (setupCtx) =>
|
|
63
68
|
withSpinner('Checking for existing instances', !setupCtx.machine, () =>
|
|
64
|
-
|
|
69
|
+
listOwnedInstancesWithIdentity(setupCtx.opts),
|
|
65
70
|
),
|
|
66
71
|
adopt: adoptOwnedInstance,
|
|
67
72
|
selectReady: (instances) =>
|
|
@@ -90,9 +95,9 @@ export async function ensureOwnedInstance(
|
|
|
90
95
|
ctx: SetupContext,
|
|
91
96
|
deps: InstanceSetupDependencies = defaultDependencies(ctx),
|
|
92
97
|
): Promise<'fixed' | 'skipped'> {
|
|
93
|
-
let
|
|
98
|
+
let inventory: Awaited<ReturnType<InstanceSetupDependencies['fetchOwned']>>
|
|
94
99
|
try {
|
|
95
|
-
|
|
100
|
+
inventory = await deps.fetchOwned(ctx)
|
|
96
101
|
} catch (cause) {
|
|
97
102
|
const detail = cause instanceof Error ? cause.message : String(cause)
|
|
98
103
|
throw new AstraleError(
|
|
@@ -102,9 +107,11 @@ export async function ensureOwnedInstance(
|
|
|
102
107
|
)
|
|
103
108
|
}
|
|
104
109
|
|
|
110
|
+
const owned = inventory.instances
|
|
111
|
+
|
|
105
112
|
const ready = owned.filter((info) => info.state === 'ready')
|
|
106
113
|
if (ready.length === 1) {
|
|
107
|
-
await deps.adopt(ready[0]
|
|
114
|
+
await deps.adopt(ready[0]!, inventory.identity)
|
|
108
115
|
return 'fixed'
|
|
109
116
|
}
|
|
110
117
|
|
|
@@ -114,7 +121,7 @@ export async function ensureOwnedInstance(
|
|
|
114
121
|
log.dim(' Skipped — no active instance set.')
|
|
115
122
|
return 'skipped'
|
|
116
123
|
}
|
|
117
|
-
await deps.adopt(choice)
|
|
124
|
+
await deps.adopt(choice, inventory.identity)
|
|
118
125
|
return 'fixed'
|
|
119
126
|
}
|
|
120
127
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as L}from"./index-
|
|
1
|
+
import{m as L}from"./index-N8J8EKlB.js";function S(y,b){for(var u=0;u<b.length;u++){const a=b[u];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in y)){const n=Object.getOwnPropertyDescriptor(a,i);n&&Object.defineProperty(y,i,n.get?n:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}))}function w(y){throw new Error('Could not dynamically require "'+y+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var O={exports:{}},j;function C(){return j||(j=1,(function(y,b){(function(u){y.exports=u()})(function(){return(function(){function u(a,i,n){function d(f,_){if(!i[f]){if(!a[f]){var h=typeof w=="function"&&w;if(!_&&h)return h(f,!0);if(g)return g(f,!0);var o=new Error("Cannot find module '"+f+"'");throw o.code="MODULE_NOT_FOUND",o}var e=i[f]={exports:{}};a[f][0].call(e.exports,function(r){var t=a[f][1][r];return d(t||r)},e,e.exports,u,a,i,n)}return i[f].exports}for(var g=typeof w=="function"&&w,m=0;m<n.length;m++)d(n[m]);return d}return u})()({1:[function(u,a,i){Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;function n(o){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(o)}function d(o,e){if(!(o instanceof e))throw new TypeError("Cannot call a class as a function")}function g(o,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(o,f(t.key),t)}}function m(o,e,r){return e&&g(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),o}function f(o){var e=_(o,"string");return n(e)=="symbol"?e:e+""}function _(o,e){if(n(o)!="object"||!o)return o;var r=o[Symbol.toPrimitive];if(r!==void 0){var t=r.call(o,e);if(n(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(o)}i.default=(function(){function o(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=r.defaultLayoutOptions,s=t===void 0?{}:t,l=r.algorithms,v=l===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:l,c=r.workerFactory,p=r.workerUrl;if(d(this,o),this.defaultLayoutOptions=s,this.initialized=!1,typeof p>"u"&&typeof c>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var k=c;typeof p<"u"&&typeof c>"u"&&(k=function(M){return new Worker(M)});var E=k(p);if(typeof E.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new h(E),this.worker.postMessage({cmd:"register",algorithms:v}).then(function(P){return e.initialized=!0}).catch(console.err)}return m(o,[{key:"layout",value:function(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=t.layoutOptions,l=s===void 0?this.defaultLayoutOptions:s,v=t.logging,c=v===void 0?!1:v,p=t.measureExecutionTime,k=p===void 0?!1:p;return r?this.worker.postMessage({cmd:"layout",graph:r,layoutOptions:l,options:{logging:c,measureExecutionTime:k}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}])})();var h=(function(){function o(e){var r=this;if(d(this,o),e===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=e,this.worker.onmessage=function(t){setTimeout(function(){r.receive(r,t)},0)}}return m(o,[{key:"postMessage",value:function(r){var t=this.id||0;this.id=t+1,r.id=t;var s=this;return new Promise(function(l,v){s.resolvers[t]=function(c,p){c?(s.convertGwtStyleError(c),v(c)):l(p)},s.worker.postMessage(r)})}},{key:"receive",value:function(r,t){var s=t.data,l=r.resolvers[s.id];l&&(delete r.resolvers[s.id],s.error?l(s.error):l(null,s.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(r){if(r){var t=r.__java$exception;t&&(t.cause&&t.cause.backingJsObject&&(r.cause=t.cause.backingJsObject,this.convertGwtStyleError(r.cause)),delete r.__java$exception)}}}])})()},{}],2:[function(u,a,i){var n=u("./elk-api.js").default;Object.defineProperty(a.exports,"__esModule",{value:!0}),a.exports=n,n.default=n},{"./elk-api.js":1}]},{},[2])(2)})})(O)),O.exports}var x=C();const A=L(x),q=S({__proto__:null,default:A},[x]);export{q as e};
|