@immediately-run/sdk 0.37.0 → 0.39.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/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +2 -2
- package/dist/catalog.d.ts +2 -2
- package/dist/catalog.js.map +1 -1
- package/dist/components/MountImage.d.cts +1 -0
- package/dist/components/MountImage.d.ts +1 -0
- package/dist/fs.d.cts +1 -0
- package/dist/fs.d.ts +1 -0
- package/dist/generated/spaces.cjs +62 -0
- package/dist/generated/spaces.cjs.map +1 -0
- package/dist/generated/spaces.d.cts +121 -0
- package/dist/generated/spaces.d.ts +121 -0
- package/dist/generated/spaces.js +31 -0
- package/dist/generated/spaces.js.map +1 -0
- package/dist/hooks.d.cts +1 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/mounts.cjs +10 -26
- package/dist/mounts.cjs.map +1 -1
- package/dist/mounts.d.cts +3 -78
- package/dist/mounts.d.ts +3 -78
- package/dist/mounts.js +11 -17
- package/dist/mounts.js.map +1 -1
- package/dist/safeContent/renderMdast.cjs +22 -6
- package/dist/safeContent/renderMdast.cjs.map +1 -1
- package/dist/safeContent/renderMdast.js +22 -6
- package/dist/safeContent/renderMdast.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +3 -2
package/dist/catalog.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
1
|
+
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */\n name: string;\n /** The capability this method requires (already held — it's in your catalog). */\n capability: string;\n /** True when the method STREAMS (use {@link invokeStream}) vs. single-reply. */\n stream?: boolean;\n /**\n * JSON Schema for the method's single object argument, when the host declares one.\n * Self-describes the call so a catalog-as-tools bridge (an embedded agent) can\n * advertise the real param shape — e.g. that `authoring:typecheck` takes a nested\n * `{ files: [{ path, content }] }` array — instead of a permissive \"any object\".\n * Absent for methods the host advertises without a schema.\n */\n paramsSchema?: Record<string, unknown>;\n}\n\n// `scheme:method` → ['scheme', 'method'] (the wire protocol is `protocol-scheme`).\nconst split = (name: string): [string, string] => {\n const i = name.indexOf(':');\n if (i <= 0) throw new Error(`invalid catalog method name: ${name}`);\n return [name.slice(0, i), name.slice(i + 1)];\n};\n\n/**\n * Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.\n * A thin generic over the host protocol: the host validates params and gates the\n * call (an un-granted method → `forbidden`, even if you name it directly). For a\n * STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.\n */\nexport const invoke = async <T = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n): Promise<T> => {\n const [scheme, method] = split(name);\n // The host replies with an `{ ok, data } | { ok:false, code }` envelope; unwrap\n // it and THROW on refusal (a `.code` like `forbidden` for an off-catalog call)\n // so callers — and any agent driving `invoke` — see the gate's verdict.\n const res = (await protocolRequest(scheme, method, [params])) as\n | { ok: true; data: unknown }\n | { ok: false; code?: string; message?: string }\n | undefined;\n if (!res || res.ok !== true) {\n const err = new Error(res?.message ?? `${name} failed`) as Error & { code?: string };\n err.code = res?.code ?? 'unknown';\n throw err;\n }\n return res.data as T;\n};\n\n// Stream transport over the resolver (SDK_PACKAGING_SPEC §4) — sendMessage /\n// addListener route through `transport()` (injected bundler messageBus or the §4\n// global), never `bundler.messageBus` directly.\nconst streamTransport: StreamTransport = {\n send: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n subscribe: (type, handler) =>\n addListener(type, (msg) => handler(msg as { msgId?: number; stream?: StreamFrame })),\n // Early-cancel: route a `{type, msgId, cancel:true}` frame back to the host so it\n // aborts the in-flight generation (and, for `llm:chat`, stops billing) — §3.3.\n cancel: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n};\n\n/** Call a STREAMING catalog method by name, yielding its events. Pass `signal` to\n * abort mid-stream: the host stops generating and (for `llm:chat`) stops billing. */\nexport function invokeStream<T = unknown, R = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n signal?: AbortSignal,\n): AsyncGenerator<T, R, void> {\n const [scheme, method] = split(name);\n return consumeStream<T, R>(streamTransport, `protocol-${scheme}`, method, [params], undefined, signal);\n}\n\n// The catalog list is read over the transport (§4): the host pushes `api-catalog`\n// and answers `request-api-catalog` with this app's grant-filtered methods (wire\n// format: site-main channelBridge.ts).\nconst channel = createPushChannel<ApiMethod[]>({\n pushType: 'api-catalog',\n requestType: 'request-api-catalog',\n initial: [],\n parse: (msg) => (Array.isArray(msg.methods) ? (msg.methods as ApiMethod[]) : undefined),\n});\n\n/** The methods this app may call (grant-filtered, §5.5). Poll for a one-off read;\n * use {@link onCatalogChange} / {@link useCatalog} to react. */\nexport const getCatalog = (): ApiMethod[] => channel.get();\n\n/** Subscribe to catalog changes (e.g. a grant added/revoked). Invoked immediately\n * with the current catalog, then on every change. Returns an unsubscribe fn. */\nexport const onCatalogChange = (listener: (catalog: ApiMethod[]) => void): (() => void) =>\n channel.onChange(listener);\n\n/** React hook returning this app's method catalog, re-rendering on change. Hand\n * it to an embedded agent as its tool list to confine the agent to the app's\n * authority (§5.9). */\nexport const useCatalog = (): ApiMethod[] => channel.use();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,0BAA0D;AAE1D,4BAA8B;AAC9B,yBAAkC;AAqBlC,MAAM,QAAQ,CAAC,SAAmC;AAChD,QAAM,IAAI,KAAK,QAAQ,GAAG;AAC1B,MAAI,KAAK,EAAG,OAAM,IAAI,MAAM,gCAAgC,IAAI,EAAE;AAClE,SAAO,CAAC,KAAK,MAAM,GAAG,CAAC,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;AAC7C;AAQO,MAAM,SAAS,OACpB,MACA,SAAkC,CAAC,MACpB;AACf,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AAInC,QAAM,MAAO,UAAM,qCAAgB,QAAQ,QAAQ,CAAC,MAAM,CAAC;AAI3D,MAAI,CAAC,OAAO,IAAI,OAAO,MAAM;AAC3B,UAAM,MAAM,IAAI,MAAM,KAAK,WAAW,GAAG,IAAI,SAAS;AACtD,QAAI,OAAO,KAAK,QAAQ;AACxB,UAAM;AAAA,EACR;AACA,SAAO,IAAI;AACb;AAKA,MAAM,kBAAmC;AAAA,EACvC,MAAM,CAAC,YAAQ,iCAAY,IAAI,MAAM,GAAyC;AAAA,EAC9E,WAAW,CAAC,MAAM,gBAChB,iCAAY,MAAM,CAAC,QAAQ,QAAQ,GAA+C,CAAC;AAAA;AAAA;AAAA,EAGrF,QAAQ,CAAC,YAAQ,iCAAY,IAAI,MAAM,GAAyC;AAClF;AAIO,SAAS,aACd,MACA,SAAkC,CAAC,GACnC,QAC4B;AAC5B,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AACnC,aAAO,qCAAoB,iBAAiB,YAAY,MAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,QAAW,MAAM;AACvG;AAKA,MAAM,cAAU,sCAA+B;AAAA,EAC7C,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS,CAAC;AAAA,EACV,OAAO,CAAC,QAAS,MAAM,QAAQ,IAAI,OAAO,IAAK,IAAI,UAA0B;AAC/E,CAAC;AAIM,MAAM,aAAa,MAAmB,QAAQ,IAAI;AAIlD,MAAM,kBAAkB,CAAC,aAC9B,QAAQ,SAAS,QAAQ;AAKpB,MAAM,aAAa,MAAmB,QAAQ,IAAI;","names":[]}
|
package/dist/catalog.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** One advertised method, as the host generated it from its gate table. */
|
|
2
2
|
interface ApiMethod {
|
|
3
|
-
/** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
3
|
+
/** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */
|
|
4
4
|
name: string;
|
|
5
5
|
/** The capability this method requires (already held — it's in your catalog). */
|
|
6
6
|
capability: string;
|
|
@@ -16,7 +16,7 @@ interface ApiMethod {
|
|
|
16
16
|
paramsSchema?: Record<string, unknown>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Call a catalog method by name — `invoke('spaces:
|
|
19
|
+
* Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.
|
|
20
20
|
* A thin generic over the host protocol: the host validates params and gates the
|
|
21
21
|
* call (an un-granted method → `forbidden`, even if you name it directly). For a
|
|
22
22
|
* STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** One advertised method, as the host generated it from its gate table. */
|
|
2
2
|
interface ApiMethod {
|
|
3
|
-
/** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
3
|
+
/** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */
|
|
4
4
|
name: string;
|
|
5
5
|
/** The capability this method requires (already held — it's in your catalog). */
|
|
6
6
|
capability: string;
|
|
@@ -16,7 +16,7 @@ interface ApiMethod {
|
|
|
16
16
|
paramsSchema?: Record<string, unknown>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Call a catalog method by name — `invoke('spaces:
|
|
19
|
+
* Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.
|
|
20
20
|
* A thin generic over the host protocol: the host validates params and gates the
|
|
21
21
|
* call (an un-granted method → `forbidden`, even if you name it directly). For a
|
|
22
22
|
* STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
1
|
+
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */\n name: string;\n /** The capability this method requires (already held — it's in your catalog). */\n capability: string;\n /** True when the method STREAMS (use {@link invokeStream}) vs. single-reply. */\n stream?: boolean;\n /**\n * JSON Schema for the method's single object argument, when the host declares one.\n * Self-describes the call so a catalog-as-tools bridge (an embedded agent) can\n * advertise the real param shape — e.g. that `authoring:typecheck` takes a nested\n * `{ files: [{ path, content }] }` array — instead of a permissive \"any object\".\n * Absent for methods the host advertises without a schema.\n */\n paramsSchema?: Record<string, unknown>;\n}\n\n// `scheme:method` → ['scheme', 'method'] (the wire protocol is `protocol-scheme`).\nconst split = (name: string): [string, string] => {\n const i = name.indexOf(':');\n if (i <= 0) throw new Error(`invalid catalog method name: ${name}`);\n return [name.slice(0, i), name.slice(i + 1)];\n};\n\n/**\n * Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.\n * A thin generic over the host protocol: the host validates params and gates the\n * call (an un-granted method → `forbidden`, even if you name it directly). For a\n * STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.\n */\nexport const invoke = async <T = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n): Promise<T> => {\n const [scheme, method] = split(name);\n // The host replies with an `{ ok, data } | { ok:false, code }` envelope; unwrap\n // it and THROW on refusal (a `.code` like `forbidden` for an off-catalog call)\n // so callers — and any agent driving `invoke` — see the gate's verdict.\n const res = (await protocolRequest(scheme, method, [params])) as\n | { ok: true; data: unknown }\n | { ok: false; code?: string; message?: string }\n | undefined;\n if (!res || res.ok !== true) {\n const err = new Error(res?.message ?? `${name} failed`) as Error & { code?: string };\n err.code = res?.code ?? 'unknown';\n throw err;\n }\n return res.data as T;\n};\n\n// Stream transport over the resolver (SDK_PACKAGING_SPEC §4) — sendMessage /\n// addListener route through `transport()` (injected bundler messageBus or the §4\n// global), never `bundler.messageBus` directly.\nconst streamTransport: StreamTransport = {\n send: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n subscribe: (type, handler) =>\n addListener(type, (msg) => handler(msg as { msgId?: number; stream?: StreamFrame })),\n // Early-cancel: route a `{type, msgId, cancel:true}` frame back to the host so it\n // aborts the in-flight generation (and, for `llm:chat`, stops billing) — §3.3.\n cancel: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n};\n\n/** Call a STREAMING catalog method by name, yielding its events. Pass `signal` to\n * abort mid-stream: the host stops generating and (for `llm:chat`) stops billing. */\nexport function invokeStream<T = unknown, R = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n signal?: AbortSignal,\n): AsyncGenerator<T, R, void> {\n const [scheme, method] = split(name);\n return consumeStream<T, R>(streamTransport, `protocol-${scheme}`, method, [params], undefined, signal);\n}\n\n// The catalog list is read over the transport (§4): the host pushes `api-catalog`\n// and answers `request-api-catalog` with this app's grant-filtered methods (wire\n// format: site-main channelBridge.ts).\nconst channel = createPushChannel<ApiMethod[]>({\n pushType: 'api-catalog',\n requestType: 'request-api-catalog',\n initial: [],\n parse: (msg) => (Array.isArray(msg.methods) ? (msg.methods as ApiMethod[]) : undefined),\n});\n\n/** The methods this app may call (grant-filtered, §5.5). Poll for a one-off read;\n * use {@link onCatalogChange} / {@link useCatalog} to react. */\nexport const getCatalog = (): ApiMethod[] => channel.get();\n\n/** Subscribe to catalog changes (e.g. a grant added/revoked). Invoked immediately\n * with the current catalog, then on every change. Returns an unsubscribe fn. */\nexport const onCatalogChange = (listener: (catalog: ApiMethod[]) => void): (() => void) =>\n channel.onChange(listener);\n\n/** React hook returning this app's method catalog, re-rendering on change. Hand\n * it to an embedded agent as its tool list to confine the agent to the app's\n * authority (§5.9). */\nexport const useCatalog = (): ApiMethod[] => channel.use();\n"],"mappings":";AAKA,SAAS,iBAAiB,aAAa,mBAAmB;AAE1D,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAqBlC,MAAM,QAAQ,CAAC,SAAmC;AAChD,QAAM,IAAI,KAAK,QAAQ,GAAG;AAC1B,MAAI,KAAK,EAAG,OAAM,IAAI,MAAM,gCAAgC,IAAI,EAAE;AAClE,SAAO,CAAC,KAAK,MAAM,GAAG,CAAC,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;AAC7C;AAQO,MAAM,SAAS,OACpB,MACA,SAAkC,CAAC,MACpB;AACf,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AAInC,QAAM,MAAO,MAAM,gBAAgB,QAAQ,QAAQ,CAAC,MAAM,CAAC;AAI3D,MAAI,CAAC,OAAO,IAAI,OAAO,MAAM;AAC3B,UAAM,MAAM,IAAI,MAAM,KAAK,WAAW,GAAG,IAAI,SAAS;AACtD,QAAI,OAAO,KAAK,QAAQ;AACxB,UAAM;AAAA,EACR;AACA,SAAO,IAAI;AACb;AAKA,MAAM,kBAAmC;AAAA,EACvC,MAAM,CAAC,QAAQ,YAAY,IAAI,MAAM,GAAyC;AAAA,EAC9E,WAAW,CAAC,MAAM,YAChB,YAAY,MAAM,CAAC,QAAQ,QAAQ,GAA+C,CAAC;AAAA;AAAA;AAAA,EAGrF,QAAQ,CAAC,QAAQ,YAAY,IAAI,MAAM,GAAyC;AAClF;AAIO,SAAS,aACd,MACA,SAAkC,CAAC,GACnC,QAC4B;AAC5B,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AACnC,SAAO,cAAoB,iBAAiB,YAAY,MAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,QAAW,MAAM;AACvG;AAKA,MAAM,UAAU,kBAA+B;AAAA,EAC7C,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS,CAAC;AAAA,EACV,OAAO,CAAC,QAAS,MAAM,QAAQ,IAAI,OAAO,IAAK,IAAI,UAA0B;AAC/E,CAAC;AAIM,MAAM,aAAa,MAAmB,QAAQ,IAAI;AAIlD,MAAM,kBAAkB,CAAC,aAC9B,QAAQ,SAAS,QAAQ;AAKpB,MAAM,aAAa,MAAmB,QAAQ,IAAI;","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ImgHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
import { SandboxMount } from '../mounts.cjs';
|
|
4
|
+
import '../generated/spaces.cjs';
|
|
4
5
|
import '../tasks.cjs';
|
|
5
6
|
|
|
6
7
|
/** Props for {@link MountImage}. Extends the native `<img>` attributes (minus `src`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ImgHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
import { SandboxMount } from '../mounts.js';
|
|
4
|
+
import '../generated/spaces.js';
|
|
4
5
|
import '../tasks.js';
|
|
5
6
|
|
|
6
7
|
/** Props for {@link MountImage}. Extends the native `<img>` attributes (minus `src`,
|
package/dist/fs.d.cts
CHANGED
package/dist/fs.d.ts
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var spaces_exports = {};
|
|
20
|
+
__export(spaces_exports, {
|
|
21
|
+
getSpaceMembers: () => getSpaceMembers,
|
|
22
|
+
inviteToSpace: () => inviteToSpace,
|
|
23
|
+
listAllSpaces: () => listAllSpaces,
|
|
24
|
+
listGrants: () => listGrants,
|
|
25
|
+
listSpaces: () => listSpaces,
|
|
26
|
+
lookupUser: () => lookupUser,
|
|
27
|
+
revokeGrant: () => revokeGrant,
|
|
28
|
+
setSpaceRole: () => setSpaceRole,
|
|
29
|
+
unshareSpace: () => unshareSpace
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(spaces_exports);
|
|
32
|
+
var import_catalog = require("../catalog");
|
|
33
|
+
const listSpaces = (opts = {}) => (0, import_catalog.invoke)("spaces:list", opts);
|
|
34
|
+
const listAllSpaces = () => (0, import_catalog.invoke)("spaces:listAll", {});
|
|
35
|
+
const getSpaceMembers = (spaceId) => (0, import_catalog.invoke)("spaces:members", { spaceId });
|
|
36
|
+
const inviteToSpace = async (spaceId, login, role) => {
|
|
37
|
+
await (0, import_catalog.invoke)("spaces:invite", { spaceId, login, role });
|
|
38
|
+
};
|
|
39
|
+
const unshareSpace = async (spaceId, uid) => {
|
|
40
|
+
await (0, import_catalog.invoke)("spaces:unshare", { spaceId, uid });
|
|
41
|
+
};
|
|
42
|
+
const setSpaceRole = async (spaceId, uid, role) => {
|
|
43
|
+
await (0, import_catalog.invoke)("spaces:setRole", { spaceId, uid, role });
|
|
44
|
+
};
|
|
45
|
+
const lookupUser = (login) => (0, import_catalog.invoke)("spaces:lookupUser", { login });
|
|
46
|
+
const listGrants = () => (0, import_catalog.invoke)("spaces:grants", {});
|
|
47
|
+
const revokeGrant = async (appKey, spaceId) => {
|
|
48
|
+
await (0, import_catalog.invoke)("spaces:revokeGrant", { appKey, spaceId });
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
getSpaceMembers,
|
|
53
|
+
inviteToSpace,
|
|
54
|
+
listAllSpaces,
|
|
55
|
+
listGrants,
|
|
56
|
+
listSpaces,
|
|
57
|
+
lookupUser,
|
|
58
|
+
revokeGrant,
|
|
59
|
+
setSpaceRole,
|
|
60
|
+
unshareSpace
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=spaces.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/generated/spaces.ts"],"sourcesContent":["// GENERATED by scripts/codegen-prototype/generate.mjs — DO NOT EDIT.\n// Source of truth: descriptors.spaces.mjs\n// Family: spaces — Space management (the space-manager app) — UI_AS_APPS_SPEC §5.\n\nimport { invoke } from '../catalog';\n\n/** A collaborator's role on a shared space: full `owner`, read-write `writer`, or read-only `reader`. */\nexport type Role =\n | 'owner'\n | 'writer'\n | 'reader';\n\n/** Summary of a space, as returned by {@link listSpaces}. */\nexport interface SpaceInfo {\n spaceId: string;\n role?: Role;\n owner?: string;\n name?: string;\n}\n\n/** A member of a space (for the share/manage UI). */\nexport interface Member {\n /** The **grantee** — `user:{uid}` | `group:{gid}`. This is the canonical name (core_concepts §4: \"principal\" is reserved for the authority context; a space member is a *grantee*). The host populates this on every member row. */\n grantee: string;\n /** @deprecated Use {@link Member.grantee}. Kept as an alias (same value) for back-compat during the `principal`→`grantee` migration; will be removed in a future major. The host still populates both. */\n principal: string;\n role: Role;\n login?: string;\n avatarUrl?: string;\n}\n\n/** A handle resolved to a principal (handle → who). */\nexport interface ResolvedUser {\n uid: string;\n login: string;\n avatarUrl?: string;\n}\n\n/** One durable grant an app holds, for the §8.11 capability audit view. */\nexport interface GrantRecord {\n /** The app's provider-qualified **program** identity (AA-01 `appKey`). The DEFAULT program keys to the bare `provider__namespace__repository`; a NAMED mini-app appends a fourth `enc()`-escaped component (`provider__namespace__repository__name`) so its grants isolate from the repo's other programs. Host-supplied — the app never builds this key. */\n appKey: string;\n spaceId: string;\n /** Universal mount id (§3.5). */\n mountId: string;\n subtree?: string;\n mode: 'ro' | 'rw';\n name?: string;\n}\n\nexport type ListSpacesError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * List spaces you can access — all of them, or just those bound to this app.\n *\n * Capability: `spaces:app`. Catalog name: `spaces:list`.\n * @throws `Error & { code: ListSpacesError }` on host refusal.\n */\nexport const listSpaces = (opts: { app?: boolean } = {}): Promise<SpaceInfo[]> =>\n invoke<SpaceInfo[]>(\"spaces:list\", opts);\n\nexport type ListAllSpacesError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Enumerate ALL the user's spaces (not just this app's).\n *\n * Capability: `spaces:user`. Catalog name: `spaces:listAll`.\n * @throws `Error & { code: ListAllSpacesError }` on host refusal.\n */\nexport const listAllSpaces = (): Promise<SpaceInfo[]> =>\n invoke<SpaceInfo[]>(\"spaces:listAll\", {});\n\nexport type GetSpaceMembersError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Read a space's members one-shot.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:members`.\n * @throws `Error & { code: GetSpaceMembersError }` on host refusal.\n */\nexport const getSpaceMembers = (spaceId: string): Promise<Member[]> =>\n invoke<Member[]>(\"spaces:members\", { spaceId });\n\nexport type InviteToSpaceError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Invite a user (by provider handle) to a space at a role. The host resolves\n * the handle, so the app never sees other users' uids except the one it\n * invited. Pull-based (FILE_SHARING_SPEC §6.4): this writes an INVITATION,\n * not membership — the recipient must {@link acceptInvite}. Re-inviting an\n * already-invited/member user is idempotent.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:invite`.\n * @throws `Error & { code: InviteToSpaceError }` on host refusal.\n */\nexport const inviteToSpace = async (spaceId: string, login: string, role: Role): Promise<void> => { await invoke<void>(\"spaces:invite\", { spaceId, login, role }); };\n\nexport type UnshareSpaceError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';\n\n/**\n * Remove a member from a space. Refused if it would orphan the space\n * (owner-lockout, T41).\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:unshare`.\n * @throws `Error & { code: UnshareSpaceError }` on host refusal.\n */\nexport const unshareSpace = async (spaceId: string, uid: string): Promise<void> => { await invoke<void>(\"spaces:unshare\", { spaceId, uid }); };\n\nexport type SetSpaceRoleError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';\n\n/**\n * Change a member's role. Refused if it would drop the sole owner\n * (owner-lockout, T41).\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:setRole`.\n * @throws `Error & { code: SetSpaceRoleError }` on host refusal.\n */\nexport const setSpaceRole = async (spaceId: string, uid: string, role: Role): Promise<void> => { await invoke<void>(\"spaces:setRole\", { spaceId, uid, role }); };\n\nexport type LookupUserError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Resolve a provider handle to a principal (for the invite flow).\n * Rate-limited host-side.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:lookupUser`.\n * @throws `Error & { code: LookupUserError }` on host refusal.\n */\nexport const lookupUser = (login: string): Promise<ResolvedUser> =>\n invoke<ResolvedUser>(\"spaces:lookupUser\", { login });\n\nexport type ListGrantsError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Enumerate every (app, mount) grant the user holds — the audit view\n * (§8.11). Elevated.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:grants`.\n * @throws `Error & { code: ListGrantsError }` on host refusal.\n */\nexport const listGrants = (): Promise<GrantRecord[]> =>\n invoke<GrantRecord[]>(\"spaces:grants\", {});\n\nexport type RevokeGrantError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Revoke one app's grant on a space — durable (the app can't re-mount) plus\n * a best-effort live teardown. Elevated.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:revokeGrant`.\n * @throws `Error & { code: RevokeGrantError }` on host refusal.\n */\nexport const revokeGrant = async (appKey: string, spaceId: string): Promise<void> => { await invoke<void>(\"spaces:revokeGrant\", { appKey, spaceId }); };\n\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAAuB;AAuDhB,MAAM,aAAa,CAAC,OAA0B,CAAC,UACpD,uBAAoB,eAAe,IAAI;AAWlC,MAAM,gBAAgB,UAC3B,uBAAoB,kBAAkB,CAAC,CAAC;AAWnC,MAAM,kBAAkB,CAAC,gBAC9B,uBAAiB,kBAAkB,EAAE,QAAQ,CAAC;AAezC,MAAM,gBAAgB,OAAO,SAAiB,OAAe,SAA8B;AAAE,YAAM,uBAAa,iBAAiB,EAAE,SAAS,OAAO,KAAK,CAAC;AAAG;AAY5J,MAAM,eAAe,OAAO,SAAiB,QAA+B;AAAE,YAAM,uBAAa,kBAAkB,EAAE,SAAS,IAAI,CAAC;AAAG;AAYtI,MAAM,eAAe,OAAO,SAAiB,KAAa,SAA8B;AAAE,YAAM,uBAAa,kBAAkB,EAAE,SAAS,KAAK,KAAK,CAAC;AAAG;AAYxJ,MAAM,aAAa,CAAC,cACzB,uBAAqB,qBAAqB,EAAE,MAAM,CAAC;AAY9C,MAAM,aAAa,UACxB,uBAAsB,iBAAiB,CAAC,CAAC;AAYpC,MAAM,cAAc,OAAO,QAAgB,YAAmC;AAAE,YAAM,uBAAa,sBAAsB,EAAE,QAAQ,QAAQ,CAAC;AAAG;","names":[]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/** A collaborator's role on a shared space: full `owner`, read-write `writer`, or read-only `reader`. */
|
|
2
|
+
type Role = 'owner' | 'writer' | 'reader';
|
|
3
|
+
/** Summary of a space, as returned by {@link listSpaces}. */
|
|
4
|
+
interface SpaceInfo {
|
|
5
|
+
spaceId: string;
|
|
6
|
+
role?: Role;
|
|
7
|
+
owner?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A member of a space (for the share/manage UI). */
|
|
11
|
+
interface Member {
|
|
12
|
+
/** The **grantee** — `user:{uid}` | `group:{gid}`. This is the canonical name (core_concepts §4: "principal" is reserved for the authority context; a space member is a *grantee*). The host populates this on every member row. */
|
|
13
|
+
grantee: string;
|
|
14
|
+
/** @deprecated Use {@link Member.grantee}. Kept as an alias (same value) for back-compat during the `principal`→`grantee` migration; will be removed in a future major. The host still populates both. */
|
|
15
|
+
principal: string;
|
|
16
|
+
role: Role;
|
|
17
|
+
login?: string;
|
|
18
|
+
avatarUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
/** A handle resolved to a principal (handle → who). */
|
|
21
|
+
interface ResolvedUser {
|
|
22
|
+
uid: string;
|
|
23
|
+
login: string;
|
|
24
|
+
avatarUrl?: string;
|
|
25
|
+
}
|
|
26
|
+
/** One durable grant an app holds, for the §8.11 capability audit view. */
|
|
27
|
+
interface GrantRecord {
|
|
28
|
+
/** The app's provider-qualified **program** identity (AA-01 `appKey`). The DEFAULT program keys to the bare `provider__namespace__repository`; a NAMED mini-app appends a fourth `enc()`-escaped component (`provider__namespace__repository__name`) so its grants isolate from the repo's other programs. Host-supplied — the app never builds this key. */
|
|
29
|
+
appKey: string;
|
|
30
|
+
spaceId: string;
|
|
31
|
+
/** Universal mount id (§3.5). */
|
|
32
|
+
mountId: string;
|
|
33
|
+
subtree?: string;
|
|
34
|
+
mode: 'ro' | 'rw';
|
|
35
|
+
name?: string;
|
|
36
|
+
}
|
|
37
|
+
type ListSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
38
|
+
/**
|
|
39
|
+
* List spaces you can access — all of them, or just those bound to this app.
|
|
40
|
+
*
|
|
41
|
+
* Capability: `spaces:app`. Catalog name: `spaces:list`.
|
|
42
|
+
* @throws `Error & { code: ListSpacesError }` on host refusal.
|
|
43
|
+
*/
|
|
44
|
+
declare const listSpaces: (opts?: {
|
|
45
|
+
app?: boolean;
|
|
46
|
+
}) => Promise<SpaceInfo[]>;
|
|
47
|
+
type ListAllSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
48
|
+
/**
|
|
49
|
+
* Enumerate ALL the user's spaces (not just this app's).
|
|
50
|
+
*
|
|
51
|
+
* Capability: `spaces:user`. Catalog name: `spaces:listAll`.
|
|
52
|
+
* @throws `Error & { code: ListAllSpacesError }` on host refusal.
|
|
53
|
+
*/
|
|
54
|
+
declare const listAllSpaces: () => Promise<SpaceInfo[]>;
|
|
55
|
+
type GetSpaceMembersError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
56
|
+
/**
|
|
57
|
+
* Read a space's members one-shot.
|
|
58
|
+
*
|
|
59
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:members`.
|
|
60
|
+
* @throws `Error & { code: GetSpaceMembersError }` on host refusal.
|
|
61
|
+
*/
|
|
62
|
+
declare const getSpaceMembers: (spaceId: string) => Promise<Member[]>;
|
|
63
|
+
type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
64
|
+
/**
|
|
65
|
+
* Invite a user (by provider handle) to a space at a role. The host resolves
|
|
66
|
+
* the handle, so the app never sees other users' uids except the one it
|
|
67
|
+
* invited. Pull-based (FILE_SHARING_SPEC §6.4): this writes an INVITATION,
|
|
68
|
+
* not membership — the recipient must {@link acceptInvite}. Re-inviting an
|
|
69
|
+
* already-invited/member user is idempotent.
|
|
70
|
+
*
|
|
71
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:invite`.
|
|
72
|
+
* @throws `Error & { code: InviteToSpaceError }` on host refusal.
|
|
73
|
+
*/
|
|
74
|
+
declare const inviteToSpace: (spaceId: string, login: string, role: Role) => Promise<void>;
|
|
75
|
+
type UnshareSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
|
|
76
|
+
/**
|
|
77
|
+
* Remove a member from a space. Refused if it would orphan the space
|
|
78
|
+
* (owner-lockout, T41).
|
|
79
|
+
*
|
|
80
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:unshare`.
|
|
81
|
+
* @throws `Error & { code: UnshareSpaceError }` on host refusal.
|
|
82
|
+
*/
|
|
83
|
+
declare const unshareSpace: (spaceId: string, uid: string) => Promise<void>;
|
|
84
|
+
type SetSpaceRoleError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
|
|
85
|
+
/**
|
|
86
|
+
* Change a member's role. Refused if it would drop the sole owner
|
|
87
|
+
* (owner-lockout, T41).
|
|
88
|
+
*
|
|
89
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:setRole`.
|
|
90
|
+
* @throws `Error & { code: SetSpaceRoleError }` on host refusal.
|
|
91
|
+
*/
|
|
92
|
+
declare const setSpaceRole: (spaceId: string, uid: string, role: Role) => Promise<void>;
|
|
93
|
+
type LookupUserError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
94
|
+
/**
|
|
95
|
+
* Resolve a provider handle to a principal (for the invite flow).
|
|
96
|
+
* Rate-limited host-side.
|
|
97
|
+
*
|
|
98
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:lookupUser`.
|
|
99
|
+
* @throws `Error & { code: LookupUserError }` on host refusal.
|
|
100
|
+
*/
|
|
101
|
+
declare const lookupUser: (login: string) => Promise<ResolvedUser>;
|
|
102
|
+
type ListGrantsError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
103
|
+
/**
|
|
104
|
+
* Enumerate every (app, mount) grant the user holds — the audit view
|
|
105
|
+
* (§8.11). Elevated.
|
|
106
|
+
*
|
|
107
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:grants`.
|
|
108
|
+
* @throws `Error & { code: ListGrantsError }` on host refusal.
|
|
109
|
+
*/
|
|
110
|
+
declare const listGrants: () => Promise<GrantRecord[]>;
|
|
111
|
+
type RevokeGrantError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
112
|
+
/**
|
|
113
|
+
* Revoke one app's grant on a space — durable (the app can't re-mount) plus
|
|
114
|
+
* a best-effort live teardown. Elevated.
|
|
115
|
+
*
|
|
116
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:revokeGrant`.
|
|
117
|
+
* @throws `Error & { code: RevokeGrantError }` on host refusal.
|
|
118
|
+
*/
|
|
119
|
+
declare const revokeGrant: (appKey: string, spaceId: string) => Promise<void>;
|
|
120
|
+
|
|
121
|
+
export { type GetSpaceMembersError, type GrantRecord, type InviteToSpaceError, type ListAllSpacesError, type ListGrantsError, type ListSpacesError, type LookupUserError, type Member, type ResolvedUser, type RevokeGrantError, type Role, type SetSpaceRoleError, type SpaceInfo, type UnshareSpaceError, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/** A collaborator's role on a shared space: full `owner`, read-write `writer`, or read-only `reader`. */
|
|
2
|
+
type Role = 'owner' | 'writer' | 'reader';
|
|
3
|
+
/** Summary of a space, as returned by {@link listSpaces}. */
|
|
4
|
+
interface SpaceInfo {
|
|
5
|
+
spaceId: string;
|
|
6
|
+
role?: Role;
|
|
7
|
+
owner?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A member of a space (for the share/manage UI). */
|
|
11
|
+
interface Member {
|
|
12
|
+
/** The **grantee** — `user:{uid}` | `group:{gid}`. This is the canonical name (core_concepts §4: "principal" is reserved for the authority context; a space member is a *grantee*). The host populates this on every member row. */
|
|
13
|
+
grantee: string;
|
|
14
|
+
/** @deprecated Use {@link Member.grantee}. Kept as an alias (same value) for back-compat during the `principal`→`grantee` migration; will be removed in a future major. The host still populates both. */
|
|
15
|
+
principal: string;
|
|
16
|
+
role: Role;
|
|
17
|
+
login?: string;
|
|
18
|
+
avatarUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
/** A handle resolved to a principal (handle → who). */
|
|
21
|
+
interface ResolvedUser {
|
|
22
|
+
uid: string;
|
|
23
|
+
login: string;
|
|
24
|
+
avatarUrl?: string;
|
|
25
|
+
}
|
|
26
|
+
/** One durable grant an app holds, for the §8.11 capability audit view. */
|
|
27
|
+
interface GrantRecord {
|
|
28
|
+
/** The app's provider-qualified **program** identity (AA-01 `appKey`). The DEFAULT program keys to the bare `provider__namespace__repository`; a NAMED mini-app appends a fourth `enc()`-escaped component (`provider__namespace__repository__name`) so its grants isolate from the repo's other programs. Host-supplied — the app never builds this key. */
|
|
29
|
+
appKey: string;
|
|
30
|
+
spaceId: string;
|
|
31
|
+
/** Universal mount id (§3.5). */
|
|
32
|
+
mountId: string;
|
|
33
|
+
subtree?: string;
|
|
34
|
+
mode: 'ro' | 'rw';
|
|
35
|
+
name?: string;
|
|
36
|
+
}
|
|
37
|
+
type ListSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
38
|
+
/**
|
|
39
|
+
* List spaces you can access — all of them, or just those bound to this app.
|
|
40
|
+
*
|
|
41
|
+
* Capability: `spaces:app`. Catalog name: `spaces:list`.
|
|
42
|
+
* @throws `Error & { code: ListSpacesError }` on host refusal.
|
|
43
|
+
*/
|
|
44
|
+
declare const listSpaces: (opts?: {
|
|
45
|
+
app?: boolean;
|
|
46
|
+
}) => Promise<SpaceInfo[]>;
|
|
47
|
+
type ListAllSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
48
|
+
/**
|
|
49
|
+
* Enumerate ALL the user's spaces (not just this app's).
|
|
50
|
+
*
|
|
51
|
+
* Capability: `spaces:user`. Catalog name: `spaces:listAll`.
|
|
52
|
+
* @throws `Error & { code: ListAllSpacesError }` on host refusal.
|
|
53
|
+
*/
|
|
54
|
+
declare const listAllSpaces: () => Promise<SpaceInfo[]>;
|
|
55
|
+
type GetSpaceMembersError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
56
|
+
/**
|
|
57
|
+
* Read a space's members one-shot.
|
|
58
|
+
*
|
|
59
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:members`.
|
|
60
|
+
* @throws `Error & { code: GetSpaceMembersError }` on host refusal.
|
|
61
|
+
*/
|
|
62
|
+
declare const getSpaceMembers: (spaceId: string) => Promise<Member[]>;
|
|
63
|
+
type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
64
|
+
/**
|
|
65
|
+
* Invite a user (by provider handle) to a space at a role. The host resolves
|
|
66
|
+
* the handle, so the app never sees other users' uids except the one it
|
|
67
|
+
* invited. Pull-based (FILE_SHARING_SPEC §6.4): this writes an INVITATION,
|
|
68
|
+
* not membership — the recipient must {@link acceptInvite}. Re-inviting an
|
|
69
|
+
* already-invited/member user is idempotent.
|
|
70
|
+
*
|
|
71
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:invite`.
|
|
72
|
+
* @throws `Error & { code: InviteToSpaceError }` on host refusal.
|
|
73
|
+
*/
|
|
74
|
+
declare const inviteToSpace: (spaceId: string, login: string, role: Role) => Promise<void>;
|
|
75
|
+
type UnshareSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
|
|
76
|
+
/**
|
|
77
|
+
* Remove a member from a space. Refused if it would orphan the space
|
|
78
|
+
* (owner-lockout, T41).
|
|
79
|
+
*
|
|
80
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:unshare`.
|
|
81
|
+
* @throws `Error & { code: UnshareSpaceError }` on host refusal.
|
|
82
|
+
*/
|
|
83
|
+
declare const unshareSpace: (spaceId: string, uid: string) => Promise<void>;
|
|
84
|
+
type SetSpaceRoleError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
|
|
85
|
+
/**
|
|
86
|
+
* Change a member's role. Refused if it would drop the sole owner
|
|
87
|
+
* (owner-lockout, T41).
|
|
88
|
+
*
|
|
89
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:setRole`.
|
|
90
|
+
* @throws `Error & { code: SetSpaceRoleError }` on host refusal.
|
|
91
|
+
*/
|
|
92
|
+
declare const setSpaceRole: (spaceId: string, uid: string, role: Role) => Promise<void>;
|
|
93
|
+
type LookupUserError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
94
|
+
/**
|
|
95
|
+
* Resolve a provider handle to a principal (for the invite flow).
|
|
96
|
+
* Rate-limited host-side.
|
|
97
|
+
*
|
|
98
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:lookupUser`.
|
|
99
|
+
* @throws `Error & { code: LookupUserError }` on host refusal.
|
|
100
|
+
*/
|
|
101
|
+
declare const lookupUser: (login: string) => Promise<ResolvedUser>;
|
|
102
|
+
type ListGrantsError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
103
|
+
/**
|
|
104
|
+
* Enumerate every (app, mount) grant the user holds — the audit view
|
|
105
|
+
* (§8.11). Elevated.
|
|
106
|
+
*
|
|
107
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:grants`.
|
|
108
|
+
* @throws `Error & { code: ListGrantsError }` on host refusal.
|
|
109
|
+
*/
|
|
110
|
+
declare const listGrants: () => Promise<GrantRecord[]>;
|
|
111
|
+
type RevokeGrantError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
|
|
112
|
+
/**
|
|
113
|
+
* Revoke one app's grant on a space — durable (the app can't re-mount) plus
|
|
114
|
+
* a best-effort live teardown. Elevated.
|
|
115
|
+
*
|
|
116
|
+
* Capability: `spaces:admin`. Catalog name: `spaces:revokeGrant`.
|
|
117
|
+
* @throws `Error & { code: RevokeGrantError }` on host refusal.
|
|
118
|
+
*/
|
|
119
|
+
declare const revokeGrant: (appKey: string, spaceId: string) => Promise<void>;
|
|
120
|
+
|
|
121
|
+
export { type GetSpaceMembersError, type GrantRecord, type InviteToSpaceError, type ListAllSpacesError, type ListGrantsError, type ListSpacesError, type LookupUserError, type Member, type ResolvedUser, type RevokeGrantError, type Role, type SetSpaceRoleError, type SpaceInfo, type UnshareSpaceError, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "../chunk-VHAA22YE.js";
|
|
2
|
+
import { invoke } from "../catalog";
|
|
3
|
+
const listSpaces = (opts = {}) => invoke("spaces:list", opts);
|
|
4
|
+
const listAllSpaces = () => invoke("spaces:listAll", {});
|
|
5
|
+
const getSpaceMembers = (spaceId) => invoke("spaces:members", { spaceId });
|
|
6
|
+
const inviteToSpace = async (spaceId, login, role) => {
|
|
7
|
+
await invoke("spaces:invite", { spaceId, login, role });
|
|
8
|
+
};
|
|
9
|
+
const unshareSpace = async (spaceId, uid) => {
|
|
10
|
+
await invoke("spaces:unshare", { spaceId, uid });
|
|
11
|
+
};
|
|
12
|
+
const setSpaceRole = async (spaceId, uid, role) => {
|
|
13
|
+
await invoke("spaces:setRole", { spaceId, uid, role });
|
|
14
|
+
};
|
|
15
|
+
const lookupUser = (login) => invoke("spaces:lookupUser", { login });
|
|
16
|
+
const listGrants = () => invoke("spaces:grants", {});
|
|
17
|
+
const revokeGrant = async (appKey, spaceId) => {
|
|
18
|
+
await invoke("spaces:revokeGrant", { appKey, spaceId });
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
getSpaceMembers,
|
|
22
|
+
inviteToSpace,
|
|
23
|
+
listAllSpaces,
|
|
24
|
+
listGrants,
|
|
25
|
+
listSpaces,
|
|
26
|
+
lookupUser,
|
|
27
|
+
revokeGrant,
|
|
28
|
+
setSpaceRole,
|
|
29
|
+
unshareSpace
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=spaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/generated/spaces.ts"],"sourcesContent":["// GENERATED by scripts/codegen-prototype/generate.mjs — DO NOT EDIT.\n// Source of truth: descriptors.spaces.mjs\n// Family: spaces — Space management (the space-manager app) — UI_AS_APPS_SPEC §5.\n\nimport { invoke } from '../catalog';\n\n/** A collaborator's role on a shared space: full `owner`, read-write `writer`, or read-only `reader`. */\nexport type Role =\n | 'owner'\n | 'writer'\n | 'reader';\n\n/** Summary of a space, as returned by {@link listSpaces}. */\nexport interface SpaceInfo {\n spaceId: string;\n role?: Role;\n owner?: string;\n name?: string;\n}\n\n/** A member of a space (for the share/manage UI). */\nexport interface Member {\n /** The **grantee** — `user:{uid}` | `group:{gid}`. This is the canonical name (core_concepts §4: \"principal\" is reserved for the authority context; a space member is a *grantee*). The host populates this on every member row. */\n grantee: string;\n /** @deprecated Use {@link Member.grantee}. Kept as an alias (same value) for back-compat during the `principal`→`grantee` migration; will be removed in a future major. The host still populates both. */\n principal: string;\n role: Role;\n login?: string;\n avatarUrl?: string;\n}\n\n/** A handle resolved to a principal (handle → who). */\nexport interface ResolvedUser {\n uid: string;\n login: string;\n avatarUrl?: string;\n}\n\n/** One durable grant an app holds, for the §8.11 capability audit view. */\nexport interface GrantRecord {\n /** The app's provider-qualified **program** identity (AA-01 `appKey`). The DEFAULT program keys to the bare `provider__namespace__repository`; a NAMED mini-app appends a fourth `enc()`-escaped component (`provider__namespace__repository__name`) so its grants isolate from the repo's other programs. Host-supplied — the app never builds this key. */\n appKey: string;\n spaceId: string;\n /** Universal mount id (§3.5). */\n mountId: string;\n subtree?: string;\n mode: 'ro' | 'rw';\n name?: string;\n}\n\nexport type ListSpacesError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * List spaces you can access — all of them, or just those bound to this app.\n *\n * Capability: `spaces:app`. Catalog name: `spaces:list`.\n * @throws `Error & { code: ListSpacesError }` on host refusal.\n */\nexport const listSpaces = (opts: { app?: boolean } = {}): Promise<SpaceInfo[]> =>\n invoke<SpaceInfo[]>(\"spaces:list\", opts);\n\nexport type ListAllSpacesError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Enumerate ALL the user's spaces (not just this app's).\n *\n * Capability: `spaces:user`. Catalog name: `spaces:listAll`.\n * @throws `Error & { code: ListAllSpacesError }` on host refusal.\n */\nexport const listAllSpaces = (): Promise<SpaceInfo[]> =>\n invoke<SpaceInfo[]>(\"spaces:listAll\", {});\n\nexport type GetSpaceMembersError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Read a space's members one-shot.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:members`.\n * @throws `Error & { code: GetSpaceMembersError }` on host refusal.\n */\nexport const getSpaceMembers = (spaceId: string): Promise<Member[]> =>\n invoke<Member[]>(\"spaces:members\", { spaceId });\n\nexport type InviteToSpaceError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Invite a user (by provider handle) to a space at a role. The host resolves\n * the handle, so the app never sees other users' uids except the one it\n * invited. Pull-based (FILE_SHARING_SPEC §6.4): this writes an INVITATION,\n * not membership — the recipient must {@link acceptInvite}. Re-inviting an\n * already-invited/member user is idempotent.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:invite`.\n * @throws `Error & { code: InviteToSpaceError }` on host refusal.\n */\nexport const inviteToSpace = async (spaceId: string, login: string, role: Role): Promise<void> => { await invoke<void>(\"spaces:invite\", { spaceId, login, role }); };\n\nexport type UnshareSpaceError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';\n\n/**\n * Remove a member from a space. Refused if it would orphan the space\n * (owner-lockout, T41).\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:unshare`.\n * @throws `Error & { code: UnshareSpaceError }` on host refusal.\n */\nexport const unshareSpace = async (spaceId: string, uid: string): Promise<void> => { await invoke<void>(\"spaces:unshare\", { spaceId, uid }); };\n\nexport type SetSpaceRoleError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';\n\n/**\n * Change a member's role. Refused if it would drop the sole owner\n * (owner-lockout, T41).\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:setRole`.\n * @throws `Error & { code: SetSpaceRoleError }` on host refusal.\n */\nexport const setSpaceRole = async (spaceId: string, uid: string, role: Role): Promise<void> => { await invoke<void>(\"spaces:setRole\", { spaceId, uid, role }); };\n\nexport type LookupUserError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Resolve a provider handle to a principal (for the invite flow).\n * Rate-limited host-side.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:lookupUser`.\n * @throws `Error & { code: LookupUserError }` on host refusal.\n */\nexport const lookupUser = (login: string): Promise<ResolvedUser> =>\n invoke<ResolvedUser>(\"spaces:lookupUser\", { login });\n\nexport type ListGrantsError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Enumerate every (app, mount) grant the user holds — the audit view\n * (§8.11). Elevated.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:grants`.\n * @throws `Error & { code: ListGrantsError }` on host refusal.\n */\nexport const listGrants = (): Promise<GrantRecord[]> =>\n invoke<GrantRecord[]>(\"spaces:grants\", {});\n\nexport type RevokeGrantError =\n 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';\n\n/**\n * Revoke one app's grant on a space — durable (the app can't re-mount) plus\n * a best-effort live teardown. Elevated.\n *\n * Capability: `spaces:admin`. Catalog name: `spaces:revokeGrant`.\n * @throws `Error & { code: RevokeGrantError }` on host refusal.\n */\nexport const revokeGrant = async (appKey: string, spaceId: string): Promise<void> => { await invoke<void>(\"spaces:revokeGrant\", { appKey, spaceId }); };\n\n"],"mappings":";AAIA,SAAS,cAAc;AAuDhB,MAAM,aAAa,CAAC,OAA0B,CAAC,MACpD,OAAoB,eAAe,IAAI;AAWlC,MAAM,gBAAgB,MAC3B,OAAoB,kBAAkB,CAAC,CAAC;AAWnC,MAAM,kBAAkB,CAAC,YAC9B,OAAiB,kBAAkB,EAAE,QAAQ,CAAC;AAezC,MAAM,gBAAgB,OAAO,SAAiB,OAAe,SAA8B;AAAE,QAAM,OAAa,iBAAiB,EAAE,SAAS,OAAO,KAAK,CAAC;AAAG;AAY5J,MAAM,eAAe,OAAO,SAAiB,QAA+B;AAAE,QAAM,OAAa,kBAAkB,EAAE,SAAS,IAAI,CAAC;AAAG;AAYtI,MAAM,eAAe,OAAO,SAAiB,KAAa,SAA8B;AAAE,QAAM,OAAa,kBAAkB,EAAE,SAAS,KAAK,KAAK,CAAC;AAAG;AAYxJ,MAAM,aAAa,CAAC,UACzB,OAAqB,qBAAqB,EAAE,MAAM,CAAC;AAY9C,MAAM,aAAa,MACxB,OAAsB,iBAAiB,CAAC,CAAC;AAYpC,MAAM,cAAc,OAAO,QAAgB,YAAmC;AAAE,QAAM,OAAa,sBAAsB,EAAE,QAAQ,QAAQ,CAAC;AAAG;","names":[]}
|
package/dist/hooks.d.cts
CHANGED
package/dist/hooks.d.ts
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -12,7 +12,7 @@ export { EditorContext, getEditorContext, onEditorContextChange, useEditorContex
|
|
|
12
12
|
export { EditTarget, EditorOpenError, EditorSessionError, EditorWriteError, RequestEditError, closeFile, createFile, createFolder, deleteEntry, openInEditor, renameEntry, requestEdit, setActiveFile, uploadFile } from './editor.cjs';
|
|
13
13
|
export { FormFactor, FormFactorClass, Orientation, getFormFactor, onFormFactorChange, useFormFactor } from './formFactor.cjs';
|
|
14
14
|
export { getRegion, useRegion } from './region.cjs';
|
|
15
|
-
export {
|
|
15
|
+
export { Invite, MountQuery, MountRemoveReason, MountRule, RemovedMount, SandboxMount, SessionMount, SpaceError, acceptInvite, awaitMatchingMount, createSpace, declineInvite, findMount, getAppMountPath, getInvites, getMounts, getSessionMounts, importSettingsFromParent, listMyInvites, listPendingInvites, listSettingsApps, makeContentRef, mount, mountSpace, onInvitesChange, onMountsChange, onSessionMountsChange, openSettings, openSettingsOf, requestMount, requestSpace, resolveContentRef, resolveContentRefs, revokeInvite, unmountSpace, useInvites, useMounts, useSessionMounts, waitForMount } from './mounts.cjs';
|
|
16
16
|
export { ContributeMode, ContributeOptions, ContributionEvent, ContributionResult, contribute } from './contribute.cjs';
|
|
17
17
|
export { ApiMethod, getCatalog, invoke, invokeStream, onCatalogChange, useCatalog } from './catalog.cjs';
|
|
18
18
|
export { RegionMessage, onRegionMessage, postToRegion, revealRegion, useRegionMessage } from './ipc.cjs';
|
|
@@ -39,6 +39,7 @@ export { ParseSafeMdastOptions, SafeMdastNode, SafeMdxAttribute, parseSafeMdast
|
|
|
39
39
|
export { sanitizeUrl } from './safeContent/sanitizeUrl.cjs';
|
|
40
40
|
export { WikiLinkToken, WikiPart, parseWikiInner, splitWikiLinks } from './safeContent/wikilink.cjs';
|
|
41
41
|
export { Admonition, AdmonitionType } from './components/Admonition.cjs';
|
|
42
|
+
export { GrantRecord, Member, ResolvedUser, Role, SpaceInfo, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace } from './generated/spaces.cjs';
|
|
42
43
|
export { HeadingAnchor } from './components/HeadingAnchor.cjs';
|
|
43
44
|
export { ImmediatelyRunGlobal, getHostRuntime } from './hostRuntime.cjs';
|
|
44
45
|
export { InternalLink, Link } from './components/Link.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { EditorContext, getEditorContext, onEditorContextChange, useEditorContex
|
|
|
12
12
|
export { EditTarget, EditorOpenError, EditorSessionError, EditorWriteError, RequestEditError, closeFile, createFile, createFolder, deleteEntry, openInEditor, renameEntry, requestEdit, setActiveFile, uploadFile } from './editor.js';
|
|
13
13
|
export { FormFactor, FormFactorClass, Orientation, getFormFactor, onFormFactorChange, useFormFactor } from './formFactor.js';
|
|
14
14
|
export { getRegion, useRegion } from './region.js';
|
|
15
|
-
export {
|
|
15
|
+
export { Invite, MountQuery, MountRemoveReason, MountRule, RemovedMount, SandboxMount, SessionMount, SpaceError, acceptInvite, awaitMatchingMount, createSpace, declineInvite, findMount, getAppMountPath, getInvites, getMounts, getSessionMounts, importSettingsFromParent, listMyInvites, listPendingInvites, listSettingsApps, makeContentRef, mount, mountSpace, onInvitesChange, onMountsChange, onSessionMountsChange, openSettings, openSettingsOf, requestMount, requestSpace, resolveContentRef, resolveContentRefs, revokeInvite, unmountSpace, useInvites, useMounts, useSessionMounts, waitForMount } from './mounts.js';
|
|
16
16
|
export { ContributeMode, ContributeOptions, ContributionEvent, ContributionResult, contribute } from './contribute.js';
|
|
17
17
|
export { ApiMethod, getCatalog, invoke, invokeStream, onCatalogChange, useCatalog } from './catalog.js';
|
|
18
18
|
export { RegionMessage, onRegionMessage, postToRegion, revealRegion, useRegionMessage } from './ipc.js';
|
|
@@ -39,6 +39,7 @@ export { ParseSafeMdastOptions, SafeMdastNode, SafeMdxAttribute, parseSafeMdast
|
|
|
39
39
|
export { sanitizeUrl } from './safeContent/sanitizeUrl.js';
|
|
40
40
|
export { WikiLinkToken, WikiPart, parseWikiInner, splitWikiLinks } from './safeContent/wikilink.js';
|
|
41
41
|
export { Admonition, AdmonitionType } from './components/Admonition.js';
|
|
42
|
+
export { GrantRecord, Member, ResolvedUser, Role, SpaceInfo, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace } from './generated/spaces.js';
|
|
42
43
|
export { HeadingAnchor } from './components/HeadingAnchor.js';
|
|
43
44
|
export { ImmediatelyRunGlobal, getHostRuntime } from './hostRuntime.js';
|
|
44
45
|
export { InternalLink, Link } from './components/Link.js';
|