@run402/sdk 4.26.0 → 4.27.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.
|
@@ -11,11 +11,19 @@ export interface ActiveProjectState {
|
|
|
11
11
|
profile: string;
|
|
12
12
|
updated_at: string;
|
|
13
13
|
}
|
|
14
|
+
export interface ActiveOrgState {
|
|
15
|
+
org_id: string;
|
|
16
|
+
api_base: string;
|
|
17
|
+
principal?: string | null;
|
|
18
|
+
profile: string;
|
|
19
|
+
updated_at: string;
|
|
20
|
+
}
|
|
14
21
|
export interface ProfileState {
|
|
15
22
|
version?: 1;
|
|
16
23
|
active_project_id?: string;
|
|
17
24
|
previous_active_project_id?: string;
|
|
18
25
|
active_projects?: Record<string, ActiveProjectState>;
|
|
26
|
+
active_orgs?: Record<string, ActiveOrgState>;
|
|
19
27
|
migrations?: Record<string, unknown>;
|
|
20
28
|
}
|
|
21
29
|
export declare function loadProfileState(path?: string): ProfileState;
|
|
@@ -25,5 +33,8 @@ export declare function activeProjectScopeKey(scope?: ActiveProjectScope): strin
|
|
|
25
33
|
export declare function getActiveProjectId(path?: string, scope?: ActiveProjectScope): string | undefined;
|
|
26
34
|
export declare function setActiveProjectId(projectId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
27
35
|
export declare function clearActiveProjectId(projectId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
36
|
+
export declare function getActiveOrgId(path?: string, scope?: ActiveProjectScope): string | undefined;
|
|
37
|
+
export declare function setActiveOrgId(orgId: string, path?: string, scope?: ActiveProjectScope): void;
|
|
38
|
+
export declare function clearActiveOrgId(path?: string, scope?: ActiveProjectScope): void;
|
|
28
39
|
export declare function recordMigration(marker: string, value: unknown, path?: string): void;
|
|
29
40
|
//# sourceMappingURL=profile-state.d.ts.map
|
|
@@ -126,6 +126,52 @@ export function clearActiveProjectId(projectId, path, scope = {}) {
|
|
|
126
126
|
saveProfileState(state, p);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
// Selected organization (add-cli-current-org, design D3).
|
|
131
|
+
//
|
|
132
|
+
// Scoped exactly like the active project id — by api_base, profile, and
|
|
133
|
+
// principal — and stored in the SAME per-profile state.json, never in the
|
|
134
|
+
// base-level config.json beside `active_wallet`. The chain is
|
|
135
|
+
// wallet -> principal -> memberships, so a globally-selected org survives
|
|
136
|
+
// `wallets use other` and then either 403s or, worse, silently resolves to a
|
|
137
|
+
// valid-but-wrong org when both principals are members. Per-profile makes the
|
|
138
|
+
// failure mode "this profile has no current org", which the ORG_REQUIRED
|
|
139
|
+
// envelope already knows how to explain.
|
|
140
|
+
//
|
|
141
|
+
// There is deliberately no top-level `active_org_id` mirror: the project one
|
|
142
|
+
// exists only to carry pre-scoping installs forward, and this key is new.
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
export function getActiveOrgId(path, scope = {}) {
|
|
145
|
+
const state = loadProfileState(path);
|
|
146
|
+
return state.active_orgs?.[activeProjectScopeKey(scope)]?.org_id;
|
|
147
|
+
}
|
|
148
|
+
export function setActiveOrgId(orgId, path, scope = {}) {
|
|
149
|
+
const p = path ?? getProfileStatePath();
|
|
150
|
+
withFileLock(p, () => {
|
|
151
|
+
const state = loadProfileState(p);
|
|
152
|
+
const key = activeProjectScopeKey(scope);
|
|
153
|
+
const resolved = defaultActiveProjectScope(scope);
|
|
154
|
+
state.active_orgs = state.active_orgs ?? {};
|
|
155
|
+
state.active_orgs[key] = {
|
|
156
|
+
org_id: orgId,
|
|
157
|
+
api_base: resolved.api_base,
|
|
158
|
+
principal: resolved.principal ?? null,
|
|
159
|
+
profile: resolved.profile,
|
|
160
|
+
updated_at: new Date().toISOString(),
|
|
161
|
+
};
|
|
162
|
+
saveProfileState(state, p);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export function clearActiveOrgId(path, scope = {}) {
|
|
166
|
+
const p = path ?? getProfileStatePath();
|
|
167
|
+
withFileLock(p, () => {
|
|
168
|
+
const state = loadProfileState(p);
|
|
169
|
+
const key = activeProjectScopeKey(scope);
|
|
170
|
+
if (state.active_orgs?.[key])
|
|
171
|
+
delete state.active_orgs[key];
|
|
172
|
+
saveProfileState(state, p);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
129
175
|
export function recordMigration(marker, value, path) {
|
|
130
176
|
const p = path ?? getProfileStatePath();
|
|
131
177
|
withFileLock(p, () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@run402/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.27.0",
|
|
4
4
|
"description": "Typed TypeScript client for the Run402 API. Kernel shared by the run402-mcp server, the run402 CLI, and user-deployed run402 functions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|