@mindstudio-ai/agent 0.1.176 → 0.1.177
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/CHANGELOG.md +7 -0
- package/dist/analytics/index.d.ts +384 -0
- package/dist/auth/index.d.ts +113 -0
- package/dist/browser/index.d.ts +332 -0
- package/dist/cli.js +27 -27
- package/dist/client.d.ts +767 -0
- package/dist/config.d.ts +13 -0
- package/dist/context.d.ts +125 -0
- package/dist/datasources/index.d.ts +52 -0
- package/dist/datasources/source.d.ts +1074 -0
- package/dist/db/aggregate.d.ts +101 -0
- package/dist/db/index.d.ts +280 -0
- package/dist/db/mutation.d.ts +65 -0
- package/dist/db/predicate.d.ts +85 -0
- package/dist/db/query.d.ts +233 -0
- package/dist/db/raw.d.ts +36 -0
- package/dist/db/readBatching.d.ts +36 -0
- package/dist/db/scanHints.d.ts +8 -0
- package/dist/db/sql.d.ts +136 -0
- package/dist/db/table.d.ts +146 -0
- package/dist/db/time.d.ts +17 -0
- package/dist/db/types.d.ts +237 -0
- package/dist/db-ws.d.ts +35 -0
- package/dist/email/index.d.ts +396 -0
- package/dist/errors.d.ts +34 -0
- package/dist/events/index.d.ts +127 -0
- package/dist/files/index.d.ts +62 -0
- package/dist/files/store.d.ts +244 -0
- package/dist/generated/metadata.d.ts +8 -0
- package/dist/generated/snippets.d.ts +8 -0
- package/dist/generated/steps.d.ts +2745 -0
- package/dist/generated/types.d.ts +4234 -0
- package/dist/http.d.ts +22 -0
- package/dist/index.d.ts +59 -13329
- package/dist/index.js +15 -15
- package/dist/index.js.map +7 -1
- package/dist/jewel/index.d.ts +325 -0
- package/dist/mapper/index.d.ts +229 -0
- package/dist/rate-limit.d.ts +25 -0
- package/dist/reader/index.d.ts +170 -0
- package/dist/respond.d.ts +68 -0
- package/dist/task/index.d.ts +18 -0
- package/dist/task/local.d.ts +48 -0
- package/dist/task/schema.d.ts +120 -0
- package/dist/task/types.d.ts +203 -0
- package/dist/types.d.ts +591 -0
- package/dist/voice/index.d.ts +87 -0
- package/package.json +6 -12
- package/dist/postinstall.js +0 -12115
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a MindStudio API request fails.
|
|
3
|
+
*
|
|
4
|
+
* Contains the HTTP status code, an error code from the API,
|
|
5
|
+
* and any additional details returned in the response body.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MindStudioError extends Error {
|
|
8
|
+
/** Machine-readable error code from the API (e.g. "invalid_step_config"). */
|
|
9
|
+
readonly code: string;
|
|
10
|
+
/** HTTP status code of the failed request. */
|
|
11
|
+
readonly status: number;
|
|
12
|
+
/** Raw error body from the API, if available. */
|
|
13
|
+
readonly details?: unknown;
|
|
14
|
+
readonly name = "MindStudioError";
|
|
15
|
+
constructor(message: string,
|
|
16
|
+
/** Machine-readable error code from the API (e.g. "invalid_step_config"). */
|
|
17
|
+
code: string,
|
|
18
|
+
/** HTTP status code of the failed request. */
|
|
19
|
+
status: number,
|
|
20
|
+
/** Raw error body from the API, if available. */
|
|
21
|
+
details?: unknown);
|
|
22
|
+
toString(): string;
|
|
23
|
+
toJSON(): Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The machine-readable code in an API error body, or `fallback`.
|
|
27
|
+
*
|
|
28
|
+
* The platform answers with `{ code, errorString, errorMessage }`, where `code`
|
|
29
|
+
* is the numeric HTTP status (already on `MindStudioError.status`) and
|
|
30
|
+
* `errorString` is the slug, e.g. `rate_limit_exceeded`. A string `code` wins,
|
|
31
|
+
* for bodies that carry their slug there. `errorString` counts only when it is
|
|
32
|
+
* a slug: for an unexpected error the platform puts prose in it.
|
|
33
|
+
*/
|
|
34
|
+
export declare function errorCodeFrom(body: unknown, fallback: string): string;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `events` namespace — server→client realtime.
|
|
3
|
+
*
|
|
4
|
+
* `publish()` pushes a payload to named channels; any client holding a grant
|
|
5
|
+
* that names one of those channels receives it instantly over a
|
|
6
|
+
* platform-held SSE stream. `grant()` mints that subscribe token — call it
|
|
7
|
+
* from a method AFTER your own authorization checks, because the grant is the
|
|
8
|
+
* entire subscribe-side authorization: the platform delivers to whoever holds
|
|
9
|
+
* it, no questions asked.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { auth, events } from '@mindstudio-ai/agent';
|
|
13
|
+
*
|
|
14
|
+
* // The subscribe door is one of your own methods:
|
|
15
|
+
* export async function watchJobs() {
|
|
16
|
+
* auth.requireRole('operator');
|
|
17
|
+
* return await events.grant(`jobs:${auth.userId}`); // { token, expiresAt, ttlSeconds }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // Anything can publish — another method, a cron, a webhook handler:
|
|
21
|
+
* export async function enqueueJob(input: { operator: string }) {
|
|
22
|
+
* const job = await Jobs.insert({ ...input, status: 'queued' });
|
|
23
|
+
* await events.publish(`jobs:${input.operator}`, { type: 'job', id: job.id });
|
|
24
|
+
* return job;
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* **A channel is an audience, and a method decides who is in it.** Never put
|
|
29
|
+
* two users' data on one channel — the channel is the unit of authorization.
|
|
30
|
+
* For membership-gated audiences (chat rooms, notifications), use per-user
|
|
31
|
+
* channels and fan out at publish time (`events.publish(members.map(...))`) —
|
|
32
|
+
* removing someone then stops their events immediately. Reserve shared
|
|
33
|
+
* channels for genuinely broadcast content. For anonymous visitors,
|
|
34
|
+
* `auth.userId` is null — key their channels on `session.visitorId` instead,
|
|
35
|
+
* or `user:null` becomes one channel shared by every anonymous user.
|
|
36
|
+
*
|
|
37
|
+
* **Events are nudges, at-most-once.** Nothing is buffered for a
|
|
38
|
+
* disconnected client and nothing is replayed on connect — subscribe for
|
|
39
|
+
* speed, reconcile for truth (fetch current state when the stream opens).
|
|
40
|
+
*
|
|
41
|
+
* Environment isolation is automatic: publishes and grants are scoped to the
|
|
42
|
+
* execution's world (live / preview / dev), so a dev-session publish can
|
|
43
|
+
* never reach a live subscriber.
|
|
44
|
+
*/
|
|
45
|
+
/** @internal Transport provided by the client (POST /_internal/v2/app-events/<op>). */
|
|
46
|
+
export type EventsTransport = (op: string, body: unknown) => Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* Serialized payload cap per publish, mirroring the platform's (which stays
|
|
49
|
+
* authoritative). Exported so code whose publish carries data can check the
|
|
50
|
+
* size BEFORE committing the write the publish announces — an oversize
|
|
51
|
+
* payload discovered after the commit means the write landed and the
|
|
52
|
+
* broadcast didn't. A publish that carries only ids can never hit this.
|
|
53
|
+
*/
|
|
54
|
+
export declare const MAX_EVENT_PAYLOAD_CHARS = 256000;
|
|
55
|
+
export interface EventGrantOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Grant lifetime in seconds — also the stream lifetime and the
|
|
58
|
+
* authorization staleness budget. The platform clamps to [60, 3600]
|
|
59
|
+
* (default 900): at expiry the stream closes and the client re-mints
|
|
60
|
+
* through your method, which re-runs your checks. A user whose access you
|
|
61
|
+
* revoke keeps receiving for at most this long.
|
|
62
|
+
*/
|
|
63
|
+
ttlSeconds?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Channels the holder may PUBLISH on (up to 20) — the client-direct
|
|
66
|
+
* ephemeral path for cursors, typing, live strokes: the frontend calls
|
|
67
|
+
* `sub.publish(...)` (or an external client `POST`s `/_/events`) and events
|
|
68
|
+
* fan out with no method invoke per signal. Treat it like the browser-held
|
|
69
|
+
* credential it is: whoever holds the token can inject events into these
|
|
70
|
+
* channels until the TTL, so grant only channels this client should speak
|
|
71
|
+
* on. Client events are capped small (8k serialized) and rate-boxed per
|
|
72
|
+
* grant — they are signals, not documents.
|
|
73
|
+
*/
|
|
74
|
+
publish?: string | string[];
|
|
75
|
+
}
|
|
76
|
+
export interface EventGrantResult {
|
|
77
|
+
/** Bearer token for `GET /_/events` (`Accept: text/event-stream`). */
|
|
78
|
+
token: string;
|
|
79
|
+
/** Milliseconds since epoch; the stream closes at this instant. */
|
|
80
|
+
expiresAt: number;
|
|
81
|
+
/** The clamped lifetime actually applied. */
|
|
82
|
+
ttlSeconds: number;
|
|
83
|
+
}
|
|
84
|
+
export interface Events {
|
|
85
|
+
/**
|
|
86
|
+
* Publish a payload to one or many channels — one call, up to 500 channels,
|
|
87
|
+
* so fanning out to every member of a room is a single request.
|
|
88
|
+
*
|
|
89
|
+
* Returns how many live subscriber connections were counted across the
|
|
90
|
+
* published channels (a connection matching several of them counts once per
|
|
91
|
+
* channel). `delivered: 0` is not an error — it means nobody is listening
|
|
92
|
+
* right now, which is normal for a nudge. Also returns the platform-stamped
|
|
93
|
+
* publish `id` — the same id arrives on every delivered frame (dedupe key
|
|
94
|
+
* for consumers is id+channel), so it correlates your logs with
|
|
95
|
+
* `remy-admin events tail`.
|
|
96
|
+
*
|
|
97
|
+
* Payloads are capped at `MAX_EVENT_PAYLOAD_CHARS` serialized characters,
|
|
98
|
+
* checked here before anything touches the network — so an oversize payload
|
|
99
|
+
* throws synchronously and shows up in local testing. If a publish carries
|
|
100
|
+
* data (not just ids), publish before you commit the write it announces, or
|
|
101
|
+
* check the size against the exported cap first: an oversize failure after
|
|
102
|
+
* the commit means the write landed and no other client heard about it.
|
|
103
|
+
* High-rate paths should publish ids and let the client fetch regardless.
|
|
104
|
+
*
|
|
105
|
+
* @throws MindStudioError on invalid channels, an oversize payload, or a
|
|
106
|
+
* platform failure. Unlike `stream()`, publishing is an explicit act and
|
|
107
|
+
* failures are not swallowed.
|
|
108
|
+
*/
|
|
109
|
+
publish(channels: string | string[], data: unknown): Promise<{
|
|
110
|
+
delivered: number;
|
|
111
|
+
id: string;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Mint a subscribe token for an explicit list of channels (up to 100, exact
|
|
115
|
+
* names — letters, digits, `: _ - .`, no wildcards). Do your authorization
|
|
116
|
+
* first; whoever holds the returned token WILL receive those channels'
|
|
117
|
+
* events for its lifetime.
|
|
118
|
+
*
|
|
119
|
+
* Return the result from your method (`return await events.grant(...)`);
|
|
120
|
+
* the client passes `result.token` to the events stream (the frontend SDK's
|
|
121
|
+
* `getToken`, or `Authorization: Bearer` on `GET /_/events` for an external
|
|
122
|
+
* client).
|
|
123
|
+
*/
|
|
124
|
+
grant(channels: string | string[], options?: EventGrantOptions): Promise<EventGrantResult>;
|
|
125
|
+
}
|
|
126
|
+
/** @internal Factory used by the client; import the `events` singleton instead. */
|
|
127
|
+
export declare function createEvents(call: EventsTransport): Events;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `files` namespace — typed, private-by-default file storage for MindStudio
|
|
3
|
+
* apps. Think of a store as a CDN-backed bucket the app talks to, not app-defined
|
|
4
|
+
* state like a `db` table: the API is *shaped* like `db` (define a store at module
|
|
5
|
+
* scope, import the handle into route handlers), but its contents are arbitrary
|
|
6
|
+
* durable blobs, and one store is shared across dev and prod.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // files/uploads.ts
|
|
10
|
+
* import { files } from '@mindstudio-ai/agent';
|
|
11
|
+
* export const Uploads = files.defineStore('uploads'); // private
|
|
12
|
+
* export const Assets = files.defineStore('assets', { access: 'public' });
|
|
13
|
+
*
|
|
14
|
+
* // routes/upload.ts
|
|
15
|
+
* import { Uploads } from '../files/uploads';
|
|
16
|
+
* const f = await Uploads.put(buffer, { contentType, filename });
|
|
17
|
+
* return { url: f.url }; // drop into <img src> / <a download>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* `file.url` is a stable, on-domain URL a logged-in user's browser can load
|
|
21
|
+
* directly. For a link that works without a session (email, cross-site embed),
|
|
22
|
+
* use `await file.shareUrl({ expiresIn })`.
|
|
23
|
+
*/
|
|
24
|
+
import { Store, type FileAccess, type FilesTransport, type StoreStepRunner } from './store.js';
|
|
25
|
+
export { Store } from './store.js';
|
|
26
|
+
export type { FileAccess, GetStreamOptions, PutOptions, PutStream, ListOptions, StoredFile, UploadToken, } from './store.js';
|
|
27
|
+
/** Options for `files.defineStore()`. */
|
|
28
|
+
export interface DefineStoreOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Access level. **Defaults to `'private'`** (signed / session-authorized
|
|
31
|
+
* reads). `'public'` marks the store world-readable and CDN-served on the
|
|
32
|
+
* app's own domain (resizable via image query params). Pinned at define-time
|
|
33
|
+
* — no `put()` can change it.
|
|
34
|
+
*/
|
|
35
|
+
access?: FileAccess;
|
|
36
|
+
/**
|
|
37
|
+
* Max upload size in bytes for client-direct uploads (the default for
|
|
38
|
+
* `createUploadToken`; enforced by the presigned POST). Overridable per call;
|
|
39
|
+
* capped at the platform ceiling.
|
|
40
|
+
*/
|
|
41
|
+
maxSize?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Allowed content types for client-direct uploads. When set,
|
|
44
|
+
* `createUploadToken({ contentType })` must pass one of these.
|
|
45
|
+
*/
|
|
46
|
+
contentTypes?: string[];
|
|
47
|
+
}
|
|
48
|
+
/** The `files` namespace object. */
|
|
49
|
+
export interface Files {
|
|
50
|
+
/**
|
|
51
|
+
* Define a typed file store. Lazy — nothing executes until you await a method
|
|
52
|
+
* on the returned {@link Store}, so it's safe to call at module scope.
|
|
53
|
+
*/
|
|
54
|
+
defineStore(name: string, options?: DefineStoreOptions): Store;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a Files namespace bound to a transport.
|
|
58
|
+
*
|
|
59
|
+
* @internal Called by MindStudioAgent; not part of the public API — access
|
|
60
|
+
* `files` via the agent instance or the top-level export.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createFiles(call: FilesTransport, runStep?: StoreStepRunner): Files;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access level of a file store. `private` (the default) → reads are signed /
|
|
3
|
+
* session-authorized; `public` → world-readable, CDN-served on the app's own
|
|
4
|
+
* domain (and resizable via image query params).
|
|
5
|
+
*/
|
|
6
|
+
export type FileAccess = 'public' | 'private';
|
|
7
|
+
/** Options for {@link Store.put}. */
|
|
8
|
+
export interface PutOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Object key within the store (nested paths allowed, e.g. `reports/q1.pdf`).
|
|
11
|
+
* Omit to auto-generate a UUID key (with `filename`'s extension, if given).
|
|
12
|
+
*/
|
|
13
|
+
key?: string;
|
|
14
|
+
/** MIME type stored on the object and returned on read. */
|
|
15
|
+
contentType?: string;
|
|
16
|
+
/** Original filename — used only to derive an extension when `key` is omitted. */
|
|
17
|
+
filename?: string;
|
|
18
|
+
/**
|
|
19
|
+
* When true (and no explicit `key`), derive the key from a content hash
|
|
20
|
+
* (`<sha256>.<ext>`) instead of a random UUID — immutable + idempotent, so
|
|
21
|
+
* re-uploading identical bytes yields the same key/URL. Ideal for public
|
|
22
|
+
* assets baked into source.
|
|
23
|
+
*/
|
|
24
|
+
contentAddressed?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Cache-Control header stored on the object: how long a browser that
|
|
27
|
+
* already fetched a public file may keep its copy, at most an hour. The CDN
|
|
28
|
+
* itself drops a public file when it is overwritten or deleted. Defaults
|
|
29
|
+
* (public stores): auto-minted keys (`key` omitted — UUID or
|
|
30
|
+
* content-addressed, never reused) → an hour; explicitly named (overwritable)
|
|
31
|
+
* keys → `public, max-age=300`, so an overwrite reaches every browser within
|
|
32
|
+
* ~5 minutes. Recipes: `'public, max-age=60'` (near-live config),
|
|
33
|
+
* `'no-store'` (revalidate every read). Validated server-side — known
|
|
34
|
+
* directives only; a longer `max-age`, or `immutable`, is capped at an hour.
|
|
35
|
+
*/
|
|
36
|
+
cacheControl?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Options for {@link Store.list}. */
|
|
39
|
+
export interface ListOptions {
|
|
40
|
+
/** Restrict to keys under this prefix (relative to the store). */
|
|
41
|
+
prefix?: string;
|
|
42
|
+
/** Pagination cursor from a previous page. */
|
|
43
|
+
cursor?: string;
|
|
44
|
+
/** Max objects per page. */
|
|
45
|
+
limit?: number;
|
|
46
|
+
}
|
|
47
|
+
/** A stored object plus a ready-to-use URL. */
|
|
48
|
+
export interface StoredFile {
|
|
49
|
+
store: string;
|
|
50
|
+
key: string;
|
|
51
|
+
access: FileAccess;
|
|
52
|
+
size?: number;
|
|
53
|
+
contentType?: string;
|
|
54
|
+
updatedAt?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Stable, on-domain URL for the app's own frontend — drop straight into
|
|
57
|
+
* `<img src>`, `fetch`, or `<a download>`. Relative (resolves against the
|
|
58
|
+
* app's origin); a same-origin logged-in request authorizes automatically
|
|
59
|
+
* via the app session, so there's nothing to await.
|
|
60
|
+
*/
|
|
61
|
+
url: string;
|
|
62
|
+
/**
|
|
63
|
+
* Mint an ABSOLUTE, signed share URL that works with **no** active session —
|
|
64
|
+
* email it, or embed it on another site. Expires (default 24h). Private
|
|
65
|
+
* stores only.
|
|
66
|
+
*/
|
|
67
|
+
shareUrl(options?: {
|
|
68
|
+
expiresIn?: number;
|
|
69
|
+
}): Promise<string>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A token for a client-direct upload, from {@link Store.createUploadToken}.
|
|
73
|
+
* Return it from a backend method and pass it straight to the frontend's
|
|
74
|
+
* `platform.upload(token, file)` — the browser then POSTs the file directly to
|
|
75
|
+
* storage (no bytes through the platform).
|
|
76
|
+
*/
|
|
77
|
+
export interface UploadToken {
|
|
78
|
+
/** The object key the upload will land at (within the store). */
|
|
79
|
+
key: string;
|
|
80
|
+
/** The stable on-domain URL the file will be readable at once uploaded. */
|
|
81
|
+
url: string;
|
|
82
|
+
/**
|
|
83
|
+
* @internal The scoped presigned POST the frontend submits to, and the grant
|
|
84
|
+
* a file too large for one request starts a multipart upload with.
|
|
85
|
+
*/
|
|
86
|
+
upload: {
|
|
87
|
+
url: string;
|
|
88
|
+
fields: Record<string, string>;
|
|
89
|
+
grant?: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Options for {@link Store.getStream}: a byte range, both ends included. */
|
|
93
|
+
export interface GetStreamOptions {
|
|
94
|
+
start?: number;
|
|
95
|
+
end?: number;
|
|
96
|
+
}
|
|
97
|
+
/** What {@link Store.put} and {@link Store.putFile} take from a stream. */
|
|
98
|
+
export type PutStream = AsyncIterable<Uint8Array>;
|
|
99
|
+
/** @internal Per-store upload policy carried from `defineStore`. */
|
|
100
|
+
export interface StorePolicy {
|
|
101
|
+
maxSize?: number;
|
|
102
|
+
contentTypes?: string[];
|
|
103
|
+
}
|
|
104
|
+
/** @internal Transport: `POST /_internal/v2/files/<op>` with the hook token. */
|
|
105
|
+
export type FilesTransport = (op: string, body: unknown) => Promise<any>;
|
|
106
|
+
/** @internal Runs an SDK action with its output going to `store`. */
|
|
107
|
+
export type StoreStepRunner = (stepType: string, step: Record<string, unknown>, store: Store) => Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* A typed handle to one named file store. Lazy — nothing executes until a
|
|
110
|
+
* method is awaited, so it's safe to `defineStore()` at module scope and import
|
|
111
|
+
* the handle into route handlers (same ergonomics as `db.defineTable`).
|
|
112
|
+
*/
|
|
113
|
+
export declare class Store {
|
|
114
|
+
private readonly _store;
|
|
115
|
+
private readonly _access;
|
|
116
|
+
private readonly _call;
|
|
117
|
+
private readonly _policy;
|
|
118
|
+
private readonly _runStep?;
|
|
119
|
+
constructor(_store: string, _access: FileAccess, _call: FilesTransport, _policy?: StorePolicy, _runStep?: StoreStepRunner | undefined);
|
|
120
|
+
/** The store's name. */
|
|
121
|
+
get name(): string;
|
|
122
|
+
/** The store's access level. */
|
|
123
|
+
get access(): FileAccess;
|
|
124
|
+
/**
|
|
125
|
+
* Store bytes, or a stream of them (a Node `Readable`, a web
|
|
126
|
+
* `ReadableStream`, any async iterable of `Uint8Array`), which goes up a
|
|
127
|
+
* part at a time and is never held whole. Returns a {@link StoredFile} with
|
|
128
|
+
* a ready-to-use `url`. A stream needs a `key`, or a `filename` for one,
|
|
129
|
+
* since a content-addressed key needs every byte before the first is sent.
|
|
130
|
+
*/
|
|
131
|
+
put(content: Buffer | Uint8Array | string | PutStream, options?: PutOptions): Promise<StoredFile>;
|
|
132
|
+
/**
|
|
133
|
+
* Large-content half of {@link put}: mint a presigned POST scoped to exactly
|
|
134
|
+
* these bytes and send them direct to storage — the JSON transport's body
|
|
135
|
+
* limit never sees them. Same result contract as the small path; the final
|
|
136
|
+
* `head` keeps the returned metadata honest (server-observed size/type/time).
|
|
137
|
+
*/
|
|
138
|
+
private _putPresigned;
|
|
139
|
+
/**
|
|
140
|
+
* Store a file from disk, read a part at a time, so a large one is never
|
|
141
|
+
* held in memory: a recording, an ffmpeg output. `filename` defaults to the
|
|
142
|
+
* file's own name, for the key's extension.
|
|
143
|
+
*/
|
|
144
|
+
putFile(path: string, options?: PutOptions): Promise<StoredFile>;
|
|
145
|
+
/**
|
|
146
|
+
* Copy the file at a URL into this store, without its bytes passing
|
|
147
|
+
* through the method: the platform fetches it straight into storage. For a
|
|
148
|
+
* direct link to a file (a recording, an export, a podcast episode's mp3),
|
|
149
|
+
* up to 5 GiB; a share page (Google Drive's, Dropbox's) isn't the file. The
|
|
150
|
+
* key is chosen for it, the URL's extension kept. The `importFromUrl`
|
|
151
|
+
* action, with this store as its `store`.
|
|
152
|
+
*/
|
|
153
|
+
importFromUrl(url: string, options?: {
|
|
154
|
+
contentType?: string;
|
|
155
|
+
}): Promise<StoredFile>;
|
|
156
|
+
/**
|
|
157
|
+
* A file too large for one request: a multipart upload, its parts sent
|
|
158
|
+
* straight to storage `PART_CONCURRENCY` at a time, each retried on its own.
|
|
159
|
+
* `size` is the file's when known; a stream's is learned as it ends.
|
|
160
|
+
*/
|
|
161
|
+
private _putInParts;
|
|
162
|
+
/** Send every part, at most `PART_CONCURRENCY` at once; how many were sent. */
|
|
163
|
+
private _sendParts;
|
|
164
|
+
/**
|
|
165
|
+
* Read an object's bytes (backend / trusted context), straight from storage.
|
|
166
|
+
* For a large file, {@link getStream} or {@link download} reads it without
|
|
167
|
+
* holding it whole.
|
|
168
|
+
*/
|
|
169
|
+
get(key: string): Promise<Buffer>;
|
|
170
|
+
/**
|
|
171
|
+
* Read an object as a stream, straight from storage: the whole of it, or
|
|
172
|
+
* the bytes from `start` to `end`, both included. A web `ReadableStream`
|
|
173
|
+
* (`Readable.fromWeb` makes it a Node stream).
|
|
174
|
+
*/
|
|
175
|
+
getStream(key: string, options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>;
|
|
176
|
+
/** Write an object to a file on disk, streamed, so it's never held whole. */
|
|
177
|
+
download(key: string, path: string): Promise<void>;
|
|
178
|
+
/** A GET straight to storage, through a short-lived URL the platform signs. */
|
|
179
|
+
private _read;
|
|
180
|
+
/** Metadata without downloading. Rejects if the object doesn't exist. */
|
|
181
|
+
head(key: string): Promise<StoredFile>;
|
|
182
|
+
/** Whether an object exists. */
|
|
183
|
+
exists(key: string): Promise<boolean>;
|
|
184
|
+
/** List objects in the store (optionally under `prefix`), one page at a time. */
|
|
185
|
+
list(options?: ListOptions): Promise<{
|
|
186
|
+
files: StoredFile[];
|
|
187
|
+
cursor?: string;
|
|
188
|
+
}>;
|
|
189
|
+
/** Delete an object. No-op if it doesn't exist. */
|
|
190
|
+
delete(key: string): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Mint an ABSOLUTE, signed share URL for a key — works with **no** active
|
|
193
|
+
* session (email it, or embed it on another site). Expires (default 24h).
|
|
194
|
+
* Private stores only.
|
|
195
|
+
*
|
|
196
|
+
* The same link is available as `file.shareUrl()` on a {@link StoredFile};
|
|
197
|
+
* this convenience skips the `head()` when you already hold just the key.
|
|
198
|
+
*/
|
|
199
|
+
shareUrl(key: string, options?: {
|
|
200
|
+
expiresIn?: number;
|
|
201
|
+
}): Promise<string>;
|
|
202
|
+
/**
|
|
203
|
+
* Mint an {@link UploadToken} for a **client-direct** upload — the browser
|
|
204
|
+
* POSTs the file straight to storage, so the bytes never pass through the
|
|
205
|
+
* platform. Return the token from a backend method and hand it to the
|
|
206
|
+
* frontend's `platform.upload(token, file)`. Works for private + public stores.
|
|
207
|
+
*
|
|
208
|
+
* Enforced at upload time by the presigned POST: a max size (this call's
|
|
209
|
+
* `maxSize`, else the store's, else the platform default) and — when
|
|
210
|
+
* `contentType` is set — an exact content-type match. When the store declares
|
|
211
|
+
* `contentTypes`, `contentType` must be one of them.
|
|
212
|
+
*
|
|
213
|
+
* Note: a presigned POST can pin exactly ONE content-type per token, so the
|
|
214
|
+
* *allowlist* is declared on `defineStore({ contentTypes })` and each token
|
|
215
|
+
* pins one type from it. This is by design, not a per-token limitation.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* // backend method
|
|
220
|
+
* export async function getUploadSlot(input: { contentType: string }) {
|
|
221
|
+
* return Uploads.createUploadToken({ contentType: input.contentType, maxSize: 50 * 1024 * 1024 });
|
|
222
|
+
* }
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
createUploadToken(options?: {
|
|
226
|
+
key?: string;
|
|
227
|
+
contentType?: string;
|
|
228
|
+
filename?: string;
|
|
229
|
+
maxSize?: number;
|
|
230
|
+
/**
|
|
231
|
+
* Seconds the token can start an upload for: 600 (ten minutes) by
|
|
232
|
+
* default, from 60 to 900. A large file's upload, once started, isn't
|
|
233
|
+
* bound by it.
|
|
234
|
+
*/
|
|
235
|
+
expiresIn?: number;
|
|
236
|
+
/**
|
|
237
|
+
* Cache-Control header stored on the uploaded object and served by the
|
|
238
|
+
* CDN (see {@link PutOptions.cacheControl}). Public uploads default to
|
|
239
|
+
* `public, max-age=300` server-side.
|
|
240
|
+
*/
|
|
241
|
+
cacheControl?: string;
|
|
242
|
+
}): Promise<UploadToken>;
|
|
243
|
+
private _toFile;
|
|
244
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type MonacoSnippetFieldType = 'string' | 'number' | 'boolean' | 'array' | 'object' | string[];
|
|
2
|
+
export type MonacoSnippetField = [name: string, type: MonacoSnippetFieldType];
|
|
3
|
+
export interface MonacoSnippet {
|
|
4
|
+
fields: MonacoSnippetField[];
|
|
5
|
+
outputKeys: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const monacoSnippets: Record<string, MonacoSnippet>;
|
|
8
|
+
export declare const blockTypeAliases: Record<string, string>;
|