@proveanything/smartlinks 1.16.7 → 1.17.4
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/api/ai.d.ts +34 -1
- package/dist/api/ai.js +64 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/integrations.d.ts +28 -0
- package/dist/api/integrations.js +82 -0
- package/dist/api/research.d.ts +9 -0
- package/dist/api/research.js +21 -0
- package/dist/api/secrets.d.ts +15 -0
- package/dist/api/secrets.js +52 -0
- package/dist/docs/API_SUMMARY.md +374 -1
- package/dist/docs/ai-tools-and-skills.md +168 -0
- package/dist/docs/integrations.md +141 -0
- package/dist/openapi.yaml +617 -0
- package/dist/types/ai.d.ts +57 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/integrations.d.ts +136 -0
- package/dist/types/integrations.js +10 -0
- package/dist/types/research.d.ts +22 -0
- package/dist/types/research.js +6 -0
- package/docs/API_SUMMARY.md +374 -1
- package/docs/ai-tools-and-skills.md +168 -0
- package/docs/integrations.md +141 -0
- package/openapi.yaml +617 -0
- package/package.json +2 -2
package/dist/api/ai.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "../types/ai";
|
|
1
|
+
import type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, AgentRunRequest, AgentRunResult, AgentToolsQuery, AgentToolsResponse, SkillsListResponse, CatalogResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "../types/ai";
|
|
2
2
|
export type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto, };
|
|
3
3
|
declare namespace aiInternal {
|
|
4
4
|
namespace chat {
|
|
@@ -21,6 +21,30 @@ declare namespace aiInternal {
|
|
|
21
21
|
function create(collectionId: string, request: ChatCompletionRequest): Promise<ChatCompletionResponse | AsyncIterable<ChatCompletionChunk>>;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
namespace agent {
|
|
25
|
+
/**
|
|
26
|
+
* Run the server-side AI agent loop once: assembles the tool set, runs the
|
|
27
|
+
* model, executes tool calls, and returns the final text + the tool trace.
|
|
28
|
+
* POST /admin/collection/:collectionId/ai/agent/run
|
|
29
|
+
*/
|
|
30
|
+
function run(collectionId: string, body: AgentRunRequest): Promise<AgentRunResult>;
|
|
31
|
+
/**
|
|
32
|
+
* List the tools the agent can use (optionally scoped by capability / name).
|
|
33
|
+
* GET /admin/collection/:collectionId/ai/agent/tools
|
|
34
|
+
*/
|
|
35
|
+
function listTools(collectionId: string, query?: AgentToolsQuery): Promise<AgentToolsResponse>;
|
|
36
|
+
}
|
|
37
|
+
namespace skills {
|
|
38
|
+
/** List the skills apps can invoke (name, description, input/output schema). */
|
|
39
|
+
function list(collectionId: string): Promise<SkillsListResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Invoke a skill by name with structured input — the app-facing verb; no
|
|
42
|
+
* prompt-shaping. POST /admin/collection/:collectionId/ai/skills/:name/run
|
|
43
|
+
*/
|
|
44
|
+
function run<T = any>(collectionId: string, name: string, input?: Record<string, any>): Promise<T>;
|
|
45
|
+
}
|
|
46
|
+
/** The full self-describing catalog (tools + skills). GET /ai/catalog */
|
|
47
|
+
function catalog(collectionId: string): Promise<CatalogResponse>;
|
|
24
48
|
namespace models {
|
|
25
49
|
/**
|
|
26
50
|
* List available AI models
|
|
@@ -181,6 +205,15 @@ export declare const ai: {
|
|
|
181
205
|
listen: typeof aiInternal.voice.listen;
|
|
182
206
|
speak: typeof aiInternal.voice.speak;
|
|
183
207
|
};
|
|
208
|
+
agent: {
|
|
209
|
+
run: typeof aiInternal.agent.run;
|
|
210
|
+
listTools: typeof aiInternal.agent.listTools;
|
|
211
|
+
};
|
|
212
|
+
skills: {
|
|
213
|
+
list: typeof aiInternal.skills.list;
|
|
214
|
+
run: typeof aiInternal.skills.run;
|
|
215
|
+
};
|
|
216
|
+
catalog: typeof aiInternal.catalog;
|
|
184
217
|
generateContent: typeof aiInternal.generateContent;
|
|
185
218
|
generateImage: typeof aiInternal.generateImage;
|
|
186
219
|
searchPhotos: typeof aiInternal.searchPhotos;
|
package/dist/api/ai.js
CHANGED
|
@@ -59,6 +59,61 @@ var aiInternal;
|
|
|
59
59
|
})(completions = chat.completions || (chat.completions = {}));
|
|
60
60
|
})(chat = aiInternal.chat || (aiInternal.chat = {}));
|
|
61
61
|
// ============================================================================
|
|
62
|
+
// Agent API (server-side tool-registry loop)
|
|
63
|
+
// ============================================================================
|
|
64
|
+
let agent;
|
|
65
|
+
(function (agent) {
|
|
66
|
+
/**
|
|
67
|
+
* Run the server-side AI agent loop once: assembles the tool set, runs the
|
|
68
|
+
* model, executes tool calls, and returns the final text + the tool trace.
|
|
69
|
+
* POST /admin/collection/:collectionId/ai/agent/run
|
|
70
|
+
*/
|
|
71
|
+
async function run(collectionId, body) {
|
|
72
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/ai/agent/run`;
|
|
73
|
+
return post(path, body);
|
|
74
|
+
}
|
|
75
|
+
agent.run = run;
|
|
76
|
+
/**
|
|
77
|
+
* List the tools the agent can use (optionally scoped by capability / name).
|
|
78
|
+
* GET /admin/collection/:collectionId/ai/agent/tools
|
|
79
|
+
*/
|
|
80
|
+
async function listTools(collectionId, query = {}) {
|
|
81
|
+
const search = new URLSearchParams();
|
|
82
|
+
for (const [k, v] of Object.entries(query)) {
|
|
83
|
+
if (v)
|
|
84
|
+
search.set(k, String(v));
|
|
85
|
+
}
|
|
86
|
+
const qs = search.toString();
|
|
87
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/ai/agent/tools${qs ? `?${qs}` : ''}`;
|
|
88
|
+
return request(path);
|
|
89
|
+
}
|
|
90
|
+
agent.listTools = listTools;
|
|
91
|
+
})(agent = aiInternal.agent || (aiInternal.agent = {}));
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// Skills + Catalog (app-facing discovery)
|
|
94
|
+
// ============================================================================
|
|
95
|
+
let skills;
|
|
96
|
+
(function (skills) {
|
|
97
|
+
/** List the skills apps can invoke (name, description, input/output schema). */
|
|
98
|
+
async function list(collectionId) {
|
|
99
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/ai/skills`);
|
|
100
|
+
}
|
|
101
|
+
skills.list = list;
|
|
102
|
+
/**
|
|
103
|
+
* Invoke a skill by name with structured input — the app-facing verb; no
|
|
104
|
+
* prompt-shaping. POST /admin/collection/:collectionId/ai/skills/:name/run
|
|
105
|
+
*/
|
|
106
|
+
async function run(collectionId, name, input = {}) {
|
|
107
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/ai/skills/${encodeURIComponent(name)}/run`, input);
|
|
108
|
+
}
|
|
109
|
+
skills.run = run;
|
|
110
|
+
})(skills = aiInternal.skills || (aiInternal.skills = {}));
|
|
111
|
+
/** The full self-describing catalog (tools + skills). GET /ai/catalog */
|
|
112
|
+
async function catalog(collectionId) {
|
|
113
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/ai/catalog`);
|
|
114
|
+
}
|
|
115
|
+
aiInternal.catalog = catalog;
|
|
116
|
+
// ============================================================================
|
|
62
117
|
// Models API
|
|
63
118
|
// ============================================================================
|
|
64
119
|
let models;
|
|
@@ -377,6 +432,15 @@ export const ai = {
|
|
|
377
432
|
listen: aiInternal.voice.listen,
|
|
378
433
|
speak: aiInternal.voice.speak,
|
|
379
434
|
},
|
|
435
|
+
agent: {
|
|
436
|
+
run: aiInternal.agent.run,
|
|
437
|
+
listTools: aiInternal.agent.listTools,
|
|
438
|
+
},
|
|
439
|
+
skills: {
|
|
440
|
+
list: aiInternal.skills.list,
|
|
441
|
+
run: aiInternal.skills.run,
|
|
442
|
+
},
|
|
443
|
+
catalog: aiInternal.catalog,
|
|
380
444
|
generateContent: aiInternal.generateContent,
|
|
381
445
|
generateImage: aiInternal.generateImage,
|
|
382
446
|
searchPhotos: aiInternal.searchPhotos,
|
package/dist/api/index.d.ts
CHANGED
|
@@ -37,6 +37,9 @@ export { containers } from "./containers";
|
|
|
37
37
|
export { lots } from "./lots";
|
|
38
38
|
export { loyalty } from "./loyalty";
|
|
39
39
|
export { translations } from "./translations";
|
|
40
|
+
export { integrations } from "./integrations";
|
|
41
|
+
export { secrets } from "./secrets";
|
|
42
|
+
export { research } from "./research";
|
|
40
43
|
export { config } from "./config";
|
|
41
44
|
export { http } from "./http";
|
|
42
45
|
export { navigation } from "./navigation";
|
package/dist/api/index.js
CHANGED
|
@@ -40,6 +40,9 @@ export { containers } from "./containers";
|
|
|
40
40
|
export { lots } from "./lots";
|
|
41
41
|
export { loyalty } from "./loyalty";
|
|
42
42
|
export { translations } from "./translations";
|
|
43
|
+
export { integrations } from "./integrations";
|
|
44
|
+
export { secrets } from "./secrets";
|
|
45
|
+
export { research } from "./research";
|
|
43
46
|
export { config } from "./config";
|
|
44
47
|
export { http } from "./http";
|
|
45
48
|
export { navigation } from "./navigation";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IntegrationFlow, CreateFlowInput, UpdateFlowInput, ListFlowsQuery, FlowList, RunFlowInput, RunFlowResult, RunFlowSummary, RunFlowEnqueued } from "../types/integrations";
|
|
2
|
+
export declare namespace integrations {
|
|
3
|
+
/** List flows in a collection. GET /integrations/flows */
|
|
4
|
+
function listFlows(collectionId: string, query?: ListFlowsQuery): Promise<FlowList>;
|
|
5
|
+
/** Create a flow. POST /integrations/flows */
|
|
6
|
+
function createFlow(collectionId: string, input: CreateFlowInput): Promise<IntegrationFlow>;
|
|
7
|
+
/** Get one flow. GET /integrations/flows/:id */
|
|
8
|
+
function getFlow(collectionId: string, id: string): Promise<IntegrationFlow>;
|
|
9
|
+
/** Update whitelisted fields. PUT /integrations/flows/:id */
|
|
10
|
+
function updateFlow(collectionId: string, id: string, input: UpdateFlowInput): Promise<IntegrationFlow>;
|
|
11
|
+
/** Soft-delete a flow. DELETE /integrations/flows/:id */
|
|
12
|
+
function deleteFlow(collectionId: string, id: string): Promise<{
|
|
13
|
+
deleted: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Run a flow now. POST /integrations/flows/:id/run
|
|
17
|
+
* - inline (default): resolves and returns the run summary.
|
|
18
|
+
* - options.async: enqueue on the worker, returns { enqueued: true }.
|
|
19
|
+
* Pass options.entityId to run for a single source entity.
|
|
20
|
+
*/
|
|
21
|
+
function runFlow(collectionId: string, id: string, options?: RunFlowInput & {
|
|
22
|
+
async?: boolean;
|
|
23
|
+
}): Promise<RunFlowResult>;
|
|
24
|
+
/** Type guard: the run executed inline and returned a summary. */
|
|
25
|
+
function isRunSummary(r: RunFlowResult): r is RunFlowSummary;
|
|
26
|
+
/** Type guard: the run was enqueued (async). */
|
|
27
|
+
function isRunEnqueued(r: RunFlowResult): r is RunFlowEnqueued;
|
|
28
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/api/integrations.ts
|
|
2
|
+
//
|
|
3
|
+
// Integration flow management + execution. Flows model input/output pipelines
|
|
4
|
+
// (inbound: fetch external -> write entity; outbound: read entity -> transform ->
|
|
5
|
+
// send). Credentials live in the secret store (see the `secrets` namespace); a flow
|
|
6
|
+
// only carries an opaque credentialRef in config.connection.auth.
|
|
7
|
+
//
|
|
8
|
+
// Endpoints: /admin/collection/:collectionId/integrations/flows
|
|
9
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
10
|
+
var t = {};
|
|
11
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
12
|
+
t[p] = s[p];
|
|
13
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
14
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
15
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
16
|
+
t[p[i]] = s[p[i]];
|
|
17
|
+
}
|
|
18
|
+
return t;
|
|
19
|
+
};
|
|
20
|
+
import { request, post, put, del } from "../http";
|
|
21
|
+
function enc(v) { return encodeURIComponent(v); }
|
|
22
|
+
function encodeQuery(params = {}) {
|
|
23
|
+
const search = new URLSearchParams();
|
|
24
|
+
for (const [key, value] of Object.entries(params)) {
|
|
25
|
+
if (value === undefined || value === null || value === "")
|
|
26
|
+
continue;
|
|
27
|
+
search.set(key, typeof value === "boolean" ? (value ? "true" : "false") : String(value));
|
|
28
|
+
}
|
|
29
|
+
const qs = search.toString();
|
|
30
|
+
return qs ? `?${qs}` : "";
|
|
31
|
+
}
|
|
32
|
+
export var integrations;
|
|
33
|
+
(function (integrations) {
|
|
34
|
+
const base = (collectionId) => `/admin/collection/${enc(collectionId)}/integrations/flows`;
|
|
35
|
+
/** List flows in a collection. GET /integrations/flows */
|
|
36
|
+
async function listFlows(collectionId, query = {}) {
|
|
37
|
+
return request(`${base(collectionId)}${encodeQuery(query)}`);
|
|
38
|
+
}
|
|
39
|
+
integrations.listFlows = listFlows;
|
|
40
|
+
/** Create a flow. POST /integrations/flows */
|
|
41
|
+
async function createFlow(collectionId, input) {
|
|
42
|
+
return post(base(collectionId), input);
|
|
43
|
+
}
|
|
44
|
+
integrations.createFlow = createFlow;
|
|
45
|
+
/** Get one flow. GET /integrations/flows/:id */
|
|
46
|
+
async function getFlow(collectionId, id) {
|
|
47
|
+
return request(`${base(collectionId)}/${enc(id)}`);
|
|
48
|
+
}
|
|
49
|
+
integrations.getFlow = getFlow;
|
|
50
|
+
/** Update whitelisted fields. PUT /integrations/flows/:id */
|
|
51
|
+
async function updateFlow(collectionId, id, input) {
|
|
52
|
+
return put(`${base(collectionId)}/${enc(id)}`, input);
|
|
53
|
+
}
|
|
54
|
+
integrations.updateFlow = updateFlow;
|
|
55
|
+
/** Soft-delete a flow. DELETE /integrations/flows/:id */
|
|
56
|
+
async function deleteFlow(collectionId, id) {
|
|
57
|
+
return del(`${base(collectionId)}/${enc(id)}`);
|
|
58
|
+
}
|
|
59
|
+
integrations.deleteFlow = deleteFlow;
|
|
60
|
+
/**
|
|
61
|
+
* Run a flow now. POST /integrations/flows/:id/run
|
|
62
|
+
* - inline (default): resolves and returns the run summary.
|
|
63
|
+
* - options.async: enqueue on the worker, returns { enqueued: true }.
|
|
64
|
+
* Pass options.entityId to run for a single source entity.
|
|
65
|
+
*/
|
|
66
|
+
async function runFlow(collectionId, id, options = {}) {
|
|
67
|
+
const { async: runAsync } = options, body = __rest(options, ["async"]);
|
|
68
|
+
const qs = runAsync ? "?async=true" : "";
|
|
69
|
+
return post(`${base(collectionId)}/${enc(id)}/run${qs}`, body);
|
|
70
|
+
}
|
|
71
|
+
integrations.runFlow = runFlow;
|
|
72
|
+
/** Type guard: the run executed inline and returned a summary. */
|
|
73
|
+
function isRunSummary(r) {
|
|
74
|
+
return r.status !== undefined;
|
|
75
|
+
}
|
|
76
|
+
integrations.isRunSummary = isRunSummary;
|
|
77
|
+
/** Type guard: the run was enqueued (async). */
|
|
78
|
+
function isRunEnqueued(r) {
|
|
79
|
+
return r.enqueued === true;
|
|
80
|
+
}
|
|
81
|
+
integrations.isRunEnqueued = isRunEnqueued;
|
|
82
|
+
})(integrations || (integrations = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResearchFetchRequest, ResearchFetchResult } from "../types/research";
|
|
2
|
+
export declare namespace research {
|
|
3
|
+
/**
|
|
4
|
+
* Fetch + extract a web page: clean markdown, page metadata, and any schema.org
|
|
5
|
+
* JSON-LD (filtered by `type` when given). Firecrawl-primary, cached per collection.
|
|
6
|
+
* POST /admin/collection/:collectionId/research/fetch
|
|
7
|
+
*/
|
|
8
|
+
function fetch(collectionId: string, body: ResearchFetchRequest): Promise<ResearchFetchResult>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/api/research.ts
|
|
2
|
+
//
|
|
3
|
+
// Web research — the direct (deterministic, non-agent) fetch+extract capability.
|
|
4
|
+
// Apps that just want a page's content/structured data call this rather than the AI
|
|
5
|
+
// agent loop (e.g. the Recipes app fetching a recipe's schema.org JSON-LD from a URL).
|
|
6
|
+
//
|
|
7
|
+
// Endpoints: /admin/collection/:collectionId/research
|
|
8
|
+
import { post } from "../http";
|
|
9
|
+
export var research;
|
|
10
|
+
(function (research) {
|
|
11
|
+
/**
|
|
12
|
+
* Fetch + extract a web page: clean markdown, page metadata, and any schema.org
|
|
13
|
+
* JSON-LD (filtered by `type` when given). Firecrawl-primary, cached per collection.
|
|
14
|
+
* POST /admin/collection/:collectionId/research/fetch
|
|
15
|
+
*/
|
|
16
|
+
async function fetch(collectionId, body) {
|
|
17
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/research/fetch`;
|
|
18
|
+
return post(path, body);
|
|
19
|
+
}
|
|
20
|
+
research.fetch = fetch;
|
|
21
|
+
})(research || (research = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SecretMeta, SecretList, SetSecretInput, SetSecretResult, ListSecretsQuery } from "../types/integrations";
|
|
2
|
+
export declare namespace secrets {
|
|
3
|
+
/** List secrets as refs + masked hints + metadata (never values). GET /secrets */
|
|
4
|
+
function list(collectionId: string, query?: ListSecretsQuery): Promise<SecretList>;
|
|
5
|
+
/** Create a secret. POST /secrets → { ref, hint }. Store the ref on a flow. */
|
|
6
|
+
function set(collectionId: string, input: SetSecretInput): Promise<SetSecretResult>;
|
|
7
|
+
/** Metadata for one secret (never the value). GET /secrets/:ref */
|
|
8
|
+
function get(collectionId: string, ref: string): Promise<SecretMeta>;
|
|
9
|
+
/** Rotate/update a secret's value (and optionally name/purpose). PUT /secrets/:ref → { ref, hint } */
|
|
10
|
+
function rotate(collectionId: string, ref: string, input: SetSecretInput): Promise<SetSecretResult>;
|
|
11
|
+
/** Soft-delete a secret. DELETE /secrets/:ref */
|
|
12
|
+
function remove(collectionId: string, ref: string): Promise<{
|
|
13
|
+
deleted: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/api/secrets.ts
|
|
2
|
+
//
|
|
3
|
+
// Sealed-secret store — the credentials that back integration flows and other
|
|
4
|
+
// server-side handlers. WRITE-ONLY from the client: you can set, rotate, list
|
|
5
|
+
// (refs + masked hints + metadata) and delete, but a value NEVER comes back over the
|
|
6
|
+
// API. It is sealed at rest and resolved server-side only, at execution time.
|
|
7
|
+
//
|
|
8
|
+
// Typical use: `set` a credential, take the returned `ref`, and put it on a flow's
|
|
9
|
+
// config.connection.auth.credentialRef.
|
|
10
|
+
//
|
|
11
|
+
// Endpoints: /admin/collection/:collectionId/secrets
|
|
12
|
+
import { request, post, put, del } from "../http";
|
|
13
|
+
function enc(v) { return encodeURIComponent(v); }
|
|
14
|
+
function encodeQuery(params = {}) {
|
|
15
|
+
const search = new URLSearchParams();
|
|
16
|
+
for (const [key, value] of Object.entries(params)) {
|
|
17
|
+
if (value === undefined || value === null || value === "")
|
|
18
|
+
continue;
|
|
19
|
+
search.set(key, String(value));
|
|
20
|
+
}
|
|
21
|
+
const qs = search.toString();
|
|
22
|
+
return qs ? `?${qs}` : "";
|
|
23
|
+
}
|
|
24
|
+
export var secrets;
|
|
25
|
+
(function (secrets) {
|
|
26
|
+
const base = (collectionId) => `/admin/collection/${enc(collectionId)}/secrets`;
|
|
27
|
+
/** List secrets as refs + masked hints + metadata (never values). GET /secrets */
|
|
28
|
+
async function list(collectionId, query = {}) {
|
|
29
|
+
return request(`${base(collectionId)}${encodeQuery(query)}`);
|
|
30
|
+
}
|
|
31
|
+
secrets.list = list;
|
|
32
|
+
/** Create a secret. POST /secrets → { ref, hint }. Store the ref on a flow. */
|
|
33
|
+
async function set(collectionId, input) {
|
|
34
|
+
return post(base(collectionId), input);
|
|
35
|
+
}
|
|
36
|
+
secrets.set = set;
|
|
37
|
+
/** Metadata for one secret (never the value). GET /secrets/:ref */
|
|
38
|
+
async function get(collectionId, ref) {
|
|
39
|
+
return request(`${base(collectionId)}/${enc(ref)}`);
|
|
40
|
+
}
|
|
41
|
+
secrets.get = get;
|
|
42
|
+
/** Rotate/update a secret's value (and optionally name/purpose). PUT /secrets/:ref → { ref, hint } */
|
|
43
|
+
async function rotate(collectionId, ref, input) {
|
|
44
|
+
return put(`${base(collectionId)}/${enc(ref)}`, input);
|
|
45
|
+
}
|
|
46
|
+
secrets.rotate = rotate;
|
|
47
|
+
/** Soft-delete a secret. DELETE /secrets/:ref */
|
|
48
|
+
async function remove(collectionId, ref) {
|
|
49
|
+
return del(`${base(collectionId)}/${enc(ref)}`);
|
|
50
|
+
}
|
|
51
|
+
secrets.remove = remove;
|
|
52
|
+
})(secrets || (secrets = {}));
|