@north-light/api 0.3.564 → 0.3.566
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.
|
@@ -55,6 +55,15 @@ export declare function resolveProfileOperand(operand: string): ProfileEntry;
|
|
|
55
55
|
/** `resolveProfileOperand` over any candidate list — the CLI passes the
|
|
56
56
|
* profiles the daemon lists for its caller. */
|
|
57
57
|
export declare function matchProfileOperand<T>(all: readonly T[], operand: string, key: CandidateOf<T>): T;
|
|
58
|
+
/** On a cloud role (D105) a new profile gets its own Blaxel environment, created in the same canvas write as the profile row. This file
|
|
59
|
+
* cannot open the database (V-1), so `environments.ts` registers the writer when the daemon loads it: it runs `insert` inside one write
|
|
60
|
+
* after making the environment, and `insert` receives the environment's object id. */
|
|
61
|
+
export type CloudProfileWriter = (spec: {
|
|
62
|
+
profileId: string;
|
|
63
|
+
grantee: string;
|
|
64
|
+
person: string;
|
|
65
|
+
}, insert: (environmentId: string) => Promise<void>) => Promise<void>;
|
|
66
|
+
export declare function setCloudProfileWriter(writer: CloudProfileWriter): void;
|
|
58
67
|
export declare function ensureRootProfile(): Promise<ProfileEntry>;
|
|
59
68
|
/** The env name a metadata entry surfaces as (spawn-env source F). Also the
|
|
60
69
|
* uniqueness domain for keys: the fold is lossy (`a-b`, `a_b`, `A_B` →
|
|
@@ -9,6 +9,7 @@ import { ensureDir, nowIso } from '../fs-utils.js';
|
|
|
9
9
|
import { cachedPausedProfileIds, cachedProfilePaused, getCachedProfile as getStoredProfile, listCachedProfiles, writeSettings } from '../scoped-state/person-store.js';
|
|
10
10
|
import { usage, notFound, ambiguous, general } from '../errors.js';
|
|
11
11
|
import { fuzzyMatchProfile } from './fuzzy-match.js';
|
|
12
|
+
import { isCloudRole, personId } from '../canvas/person-state.js';
|
|
12
13
|
// A generated id and its stored app determine the memory and environment paths.
|
|
13
14
|
/** `<slug>-<shortid>`: slug is lower-case, non-alphanumeric collapsed to `-`,
|
|
14
15
|
* trimmed to 40 chars (defaulting to `profile`); shortid is 8 lowercase hex
|
|
@@ -202,8 +203,18 @@ function generateProfileId(name) {
|
|
|
202
203
|
}
|
|
203
204
|
throw general(`failed to generate a unique profile id for "${name}" after 20 attempts`);
|
|
204
205
|
}
|
|
205
|
-
|
|
206
|
+
let cloudProfileWriter = null;
|
|
207
|
+
export function setCloudProfileWriter(writer) { cloudProfileWriter = writer; }
|
|
206
208
|
export async function ensureRootProfile() {
|
|
209
|
+
// A cloud role serves many people and `profiles.id` is global, so each person's root has its own generated id, found by name.
|
|
210
|
+
if (isCloudRole()) {
|
|
211
|
+
const own = listProfiles().find((p) => p.manifest.name === ROOT_PROFILE_NAME && profileApp(p.manifest) === 'app:terminal');
|
|
212
|
+
if (own !== undefined) {
|
|
213
|
+
scaffoldProfile(own.profileId, own.manifest);
|
|
214
|
+
return own;
|
|
215
|
+
}
|
|
216
|
+
return await createProfile(ROOT_PROFILE_NAME, [], { grantee: 'app:terminal' });
|
|
217
|
+
}
|
|
207
218
|
const existing = getStoredProfile(ROOT_PROFILE_ID);
|
|
208
219
|
if (existing !== null) {
|
|
209
220
|
scaffoldProfile(ROOT_PROFILE_ID, existing.manifest);
|
|
@@ -320,7 +331,13 @@ export async function createProfile(name, projects = [], opts = {}) {
|
|
|
320
331
|
last_used_at: null,
|
|
321
332
|
};
|
|
322
333
|
scaffoldProfile(profileId, manifest);
|
|
323
|
-
await writeSettings(() => [{ op: 'profile.insert', profile: { profileId, manifest } }]);
|
|
334
|
+
const insert = async () => { await writeSettings(() => [{ op: 'profile.insert', profile: { profileId, manifest } }]); };
|
|
335
|
+
if (!isCloudRole())
|
|
336
|
+
await insert();
|
|
337
|
+
else if (cloudProfileWriter === null)
|
|
338
|
+
throw new Error('a cloud role has no profile environment writer registered');
|
|
339
|
+
else
|
|
340
|
+
await cloudProfileWriter({ profileId, grantee: profileApp(manifest), person: personId() }, async (environmentId) => { manifest.environment_id = environmentId; await insert(); });
|
|
324
341
|
return { profileId, manifest };
|
|
325
342
|
}
|
|
326
343
|
export async function ensureAppProfile(grantee) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.566",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|