@narrative.io/data-collaboration-sdk-ts 2.101.1-beta.0 → 2.103.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/build/agents/index.d.ts +70 -0
- package/build/agents/index.js +100 -0
- package/build/agents/types.d.ts +188 -0
- package/build/agents/types.js +22 -0
- package/build/apps/index.d.ts +0 -7
- package/build/apps/index.js +0 -9
- package/build/collaboration-policy/core/filter-builder.js +1 -7
- package/build/collaboration-policy/core/types.d.ts +10 -81
- package/build/collaboration-policy/index.d.ts +4 -5
- package/build/collaboration-policy/index.js +3 -4
- package/build/collaboration-policy/types/collaboration-policy.d.ts +20 -20
- package/build/collaboration-policy/useCollaborationPolicy.d.ts +4 -13
- package/build/collaboration-policy/useCollaborationPolicy.js +1 -23
- package/build/collaboration-policy/utils/path-helpers.d.ts +3 -7
- package/build/collaboration-policy/utils/path-helpers.js +22 -6
- package/build/datasets/index.d.ts +2 -11
- package/build/datasets/index.js +0 -12
- package/build/datasets/types.d.ts +0 -25
- package/build/index.d.ts +3 -1
- package/build/index.js +3 -0
- package/build/nql/types.d.ts +13 -13
- package/build/nql/types.js +20 -5
- package/package.json +9 -10
- package/build/collaboration-policy/core/jsonschema/json-schema-types.d.ts +0 -45
- package/build/collaboration-policy/core/jsonschema/json-schema-types.js +0 -1
- package/build/collaboration-policy/core/jsonschema/policy-branches.d.ts +0 -49
- package/build/collaboration-policy/core/jsonschema/policy-branches.js +0 -1
- package/build/collaboration-policy/core/jsonschema/policy-evaluator.d.ts +0 -22
- package/build/collaboration-policy/core/jsonschema/policy-evaluator.js +0 -250
- package/build/collaboration-policy/core/jsonschema/sql-builder.d.ts +0 -79
- package/build/collaboration-policy/core/jsonschema/sql-builder.js +0 -306
- package/build/collaboration-policy/core/jsonschema/sql-poc.d.ts +0 -79
- package/build/collaboration-policy/core/jsonschema/sql-poc.js +0 -305
- package/build/nql/SubstraitParser.d.ts +0 -771
- package/build/nql/SubstraitParser.js +0 -797
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
|
+
import type { ApiRecordsV2, PaginationOptions } from "../types";
|
|
3
|
+
import type { ConversationId, ConversationResponse, CreateConversationRequest, CreateRunRequest, ListMessagesResponse, RunId, RunResponse } from "./types";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* @module AgentsApi
|
|
7
|
+
* @description Agent Conversations: long-lived conversations with pinned system
|
|
8
|
+
* prompt + defaults, asynchronous runs that may pause for caller-declared
|
|
9
|
+
* tool outputs, and a versioned delta-cursor message stream.
|
|
10
|
+
*
|
|
11
|
+
* @see https://docs.narrative.io/reference/architecture/agent-conversations
|
|
12
|
+
*
|
|
13
|
+
* @extends BaseApi
|
|
14
|
+
*/
|
|
15
|
+
export declare class AgentsApi extends BaseApi {
|
|
16
|
+
/**
|
|
17
|
+
* Create an agent conversation. `system_prompt` and `defaults.{tools,mcp_servers}`
|
|
18
|
+
* are pinned at creation; everything else in `defaults` is overridable per-run.
|
|
19
|
+
*/
|
|
20
|
+
createAgentConversation(request: CreateConversationRequest): Promise<ConversationResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* List the calling user's agent conversations, newest first by `created_at`.
|
|
23
|
+
* Scoped to both `company_id` and `user_id` from the bearer token — peers in
|
|
24
|
+
* the same company are not visible. Never 404s; empty state is `records: []`.
|
|
25
|
+
*/
|
|
26
|
+
listAgentConversations(options?: PaginationOptions): Promise<ApiRecordsV2<ConversationResponse>>;
|
|
27
|
+
/**
|
|
28
|
+
* Read a conversation's metadata + current `version`. Always re-read this
|
|
29
|
+
* immediately before starting a run — `version` is the compare-and-swap
|
|
30
|
+
* token for `expected_version` and a stale value yields 409.
|
|
31
|
+
*/
|
|
32
|
+
getAgentConversation(conversationId: ConversationId): Promise<ConversationResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Delta-read conversation messages with `sequence_no > since`. Use the
|
|
35
|
+
* returned `current_version` as the next call's `since` for gap-free reads.
|
|
36
|
+
*/
|
|
37
|
+
listAgentConversationMessages(conversationId: ConversationId, options?: {
|
|
38
|
+
since?: number;
|
|
39
|
+
}): Promise<ListMessagesResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Start a new run on the conversation. Returns immediately with
|
|
42
|
+
* `status: "pending"` — poll {@link getAgentRun} until terminal.
|
|
43
|
+
*
|
|
44
|
+
* - Generate a fresh UUID for `client_op_id` per logical request (it's the
|
|
45
|
+
* idempotency key; reusing one is only safe as a retry).
|
|
46
|
+
* - Set `expected_version` to the value just read from
|
|
47
|
+
* {@link getAgentConversation} — mismatches return 409.
|
|
48
|
+
*/
|
|
49
|
+
createAgentRun(conversationId: ConversationId, request: CreateRunRequest): Promise<RunResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Read a run's current state. Terminal states: `completed`,
|
|
52
|
+
* `requires_action`, `failed`. Stop polling on any of them.
|
|
53
|
+
*/
|
|
54
|
+
getAgentRun(runId: RunId): Promise<RunResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Convenience: poll {@link getAgentRun} until terminal. Caller is responsible
|
|
57
|
+
* for selecting a reasonable backoff; defaults to 1.5s fixed interval with a
|
|
58
|
+
* 2-minute ceiling.
|
|
59
|
+
*
|
|
60
|
+
* Returns the terminal run. Throws on `failed` only if `throwOnFailed` is
|
|
61
|
+
* true; otherwise the caller inspects `run.status === "failed"`.
|
|
62
|
+
*/
|
|
63
|
+
waitForAgentRun(runId: RunId, options?: {
|
|
64
|
+
intervalMs?: number;
|
|
65
|
+
timeoutMs?: number;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
onTick?: (run: RunResponse) => void;
|
|
68
|
+
throwOnFailed?: boolean;
|
|
69
|
+
}): Promise<RunResponse>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
const conversationsResource = "agents/conversations";
|
|
4
|
+
const runsResource = "agents/runs";
|
|
5
|
+
/**
|
|
6
|
+
* @module AgentsApi
|
|
7
|
+
* @description Agent Conversations: long-lived conversations with pinned system
|
|
8
|
+
* prompt + defaults, asynchronous runs that may pause for caller-declared
|
|
9
|
+
* tool outputs, and a versioned delta-cursor message stream.
|
|
10
|
+
*
|
|
11
|
+
* @see https://docs.narrative.io/reference/architecture/agent-conversations
|
|
12
|
+
*
|
|
13
|
+
* @extends BaseApi
|
|
14
|
+
*/
|
|
15
|
+
export class AgentsApi extends BaseApi {
|
|
16
|
+
// -------------------- Conversations --------------------
|
|
17
|
+
/**
|
|
18
|
+
* Create an agent conversation. `system_prompt` and `defaults.{tools,mcp_servers}`
|
|
19
|
+
* are pinned at creation; everything else in `defaults` is overridable per-run.
|
|
20
|
+
*/
|
|
21
|
+
async createAgentConversation(request) {
|
|
22
|
+
return await this.post(conversationsResource, request);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* List the calling user's agent conversations, newest first by `created_at`.
|
|
26
|
+
* Scoped to both `company_id` and `user_id` from the bearer token — peers in
|
|
27
|
+
* the same company are not visible. Never 404s; empty state is `records: []`.
|
|
28
|
+
*/
|
|
29
|
+
async listAgentConversations(options) {
|
|
30
|
+
return await this.get(conversationsResource, options ? { ...options } : undefined);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read a conversation's metadata + current `version`. Always re-read this
|
|
34
|
+
* immediately before starting a run — `version` is the compare-and-swap
|
|
35
|
+
* token for `expected_version` and a stale value yields 409.
|
|
36
|
+
*/
|
|
37
|
+
async getAgentConversation(conversationId) {
|
|
38
|
+
return await this.get(`${conversationsResource}/${conversationId}`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Delta-read conversation messages with `sequence_no > since`. Use the
|
|
42
|
+
* returned `current_version` as the next call's `since` for gap-free reads.
|
|
43
|
+
*/
|
|
44
|
+
async listAgentConversationMessages(conversationId, options) {
|
|
45
|
+
return await this.get(`${conversationsResource}/${conversationId}/messages`, options?.since !== undefined ? { since: options.since } : undefined);
|
|
46
|
+
}
|
|
47
|
+
// -------------------- Runs --------------------
|
|
48
|
+
/**
|
|
49
|
+
* Start a new run on the conversation. Returns immediately with
|
|
50
|
+
* `status: "pending"` — poll {@link getAgentRun} until terminal.
|
|
51
|
+
*
|
|
52
|
+
* - Generate a fresh UUID for `client_op_id` per logical request (it's the
|
|
53
|
+
* idempotency key; reusing one is only safe as a retry).
|
|
54
|
+
* - Set `expected_version` to the value just read from
|
|
55
|
+
* {@link getAgentConversation} — mismatches return 409.
|
|
56
|
+
*/
|
|
57
|
+
async createAgentRun(conversationId, request) {
|
|
58
|
+
return await this.post(`${conversationsResource}/${conversationId}/runs`, request);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Read a run's current state. Terminal states: `completed`,
|
|
62
|
+
* `requires_action`, `failed`. Stop polling on any of them.
|
|
63
|
+
*/
|
|
64
|
+
async getAgentRun(runId) {
|
|
65
|
+
return await this.get(`${runsResource}/${runId}`);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convenience: poll {@link getAgentRun} until terminal. Caller is responsible
|
|
69
|
+
* for selecting a reasonable backoff; defaults to 1.5s fixed interval with a
|
|
70
|
+
* 2-minute ceiling.
|
|
71
|
+
*
|
|
72
|
+
* Returns the terminal run. Throws on `failed` only if `throwOnFailed` is
|
|
73
|
+
* true; otherwise the caller inspects `run.status === "failed"`.
|
|
74
|
+
*/
|
|
75
|
+
async waitForAgentRun(runId, options = {}) {
|
|
76
|
+
const interval = options.intervalMs ?? 1500;
|
|
77
|
+
const timeout = options.timeoutMs ?? 120_000;
|
|
78
|
+
const deadline = Date.now() + timeout;
|
|
79
|
+
// terminal predicate kept local to avoid an extra import in consumers
|
|
80
|
+
const terminal = (s) => s === "completed" || s === "requires_action" || s === "failed";
|
|
81
|
+
// eslint-disable-next-line no-constant-condition
|
|
82
|
+
while (true) {
|
|
83
|
+
if (options.signal?.aborted) {
|
|
84
|
+
throw new Error("waitForAgentRun aborted");
|
|
85
|
+
}
|
|
86
|
+
const run = await this.getAgentRun(runId);
|
|
87
|
+
options.onTick?.(run);
|
|
88
|
+
if (terminal(run.status)) {
|
|
89
|
+
if (options.throwOnFailed && run.status === "failed") {
|
|
90
|
+
throw Object.assign(new Error(run.error?.message ?? "Agent run failed"), { run });
|
|
91
|
+
}
|
|
92
|
+
return run;
|
|
93
|
+
}
|
|
94
|
+
if (Date.now() >= deadline) {
|
|
95
|
+
throw new Error(`waitForAgentRun timed out after ${timeout}ms`);
|
|
96
|
+
}
|
|
97
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Conversations API — types.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `/agents/conversations` and `/agents/runs` on the Narrative Data
|
|
5
|
+
* Collaboration Platform (RFC 7807 errors; OpenAI-Assistants-shaped semantics).
|
|
6
|
+
*
|
|
7
|
+
* Two tool dimensions:
|
|
8
|
+
* - `mcp_servers[]` — server-side, resolved by the platform via MCP. Model sees
|
|
9
|
+
* each tool as `{alias}-{name}`.
|
|
10
|
+
* - `tools[]` — caller-declared. Dash-free names. When called, the run pauses
|
|
11
|
+
* at `requires_action`; resume by posting a follow-up run with
|
|
12
|
+
* `payload.kind: "tool_outputs"`.
|
|
13
|
+
*/
|
|
14
|
+
export type ConversationId = string;
|
|
15
|
+
export type RunId = string;
|
|
16
|
+
export type ClientOpId = string;
|
|
17
|
+
export type ConversationVersion = number;
|
|
18
|
+
export type ToolUseId = string;
|
|
19
|
+
export type AgentModel = "anthropic.claude-haiku-4.5" | "anthropic.claude-sonnet-4.5" | "anthropic.claude-sonnet-4.6" | "anthropic.claude-opus-4.5" | "anthropic.claude-opus-4.6" | "openai.gpt-oss-120b" | "openai.gpt-4.1" | "openai.o4-mini" | (string & {});
|
|
20
|
+
export type ExecutionCluster = "shared" | "dedicated";
|
|
21
|
+
/** Subset of JSON Schema Draft 2020-12 accepted by Bedrock structured output. */
|
|
22
|
+
export type JsonSchemaObject = Record<string, unknown>;
|
|
23
|
+
export interface McpServerConfig {
|
|
24
|
+
/** 1–8 char `[a-zA-Z][a-zA-Z0-9]{0,7}` — namespace prefix for the server's tools. */
|
|
25
|
+
alias: string;
|
|
26
|
+
url: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ToolSpec {
|
|
30
|
+
/** Caller-declared tools must NOT contain a dash. MCP tools' bare name. */
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
input_schema: JsonSchemaObject;
|
|
34
|
+
/** Defaults to true. Leave true in production. */
|
|
35
|
+
strict?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface ConversationDefaults {
|
|
38
|
+
model: AgentModel;
|
|
39
|
+
data_plane_id: string;
|
|
40
|
+
execution_cluster: ExecutionCluster;
|
|
41
|
+
compute_pool_id?: string;
|
|
42
|
+
max_iterations?: number;
|
|
43
|
+
max_tokens?: number;
|
|
44
|
+
temperature?: number;
|
|
45
|
+
output_format_schema?: JsonSchemaObject;
|
|
46
|
+
mcp_servers?: McpServerConfig[];
|
|
47
|
+
tools?: ToolSpec[];
|
|
48
|
+
}
|
|
49
|
+
export interface CreateConversationRequest {
|
|
50
|
+
name?: string;
|
|
51
|
+
system_prompt?: string;
|
|
52
|
+
defaults: ConversationDefaults;
|
|
53
|
+
}
|
|
54
|
+
export interface ConversationResponse {
|
|
55
|
+
id: ConversationId;
|
|
56
|
+
company_id: number;
|
|
57
|
+
user_id: number;
|
|
58
|
+
name: string | null;
|
|
59
|
+
system_prompt: string | null;
|
|
60
|
+
defaults: ConversationDefaults;
|
|
61
|
+
version: ConversationVersion;
|
|
62
|
+
created_at: string;
|
|
63
|
+
updated_at: string;
|
|
64
|
+
}
|
|
65
|
+
export type RunStatus = "pending" | "running" | "completed" | "requires_action" | "failed";
|
|
66
|
+
export interface UserMessagePayload {
|
|
67
|
+
kind: "user_message";
|
|
68
|
+
text: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ToolOutput {
|
|
71
|
+
tool_use_id: ToolUseId;
|
|
72
|
+
/** Plain text. Serialize JSON results before sending. */
|
|
73
|
+
content: string;
|
|
74
|
+
is_error?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface ToolOutputsPayload {
|
|
77
|
+
kind: "tool_outputs";
|
|
78
|
+
outputs: ToolOutput[];
|
|
79
|
+
}
|
|
80
|
+
export type RunPayload = UserMessagePayload | ToolOutputsPayload;
|
|
81
|
+
export type ToolChoice = {
|
|
82
|
+
kind: "auto";
|
|
83
|
+
} | {
|
|
84
|
+
kind: "any";
|
|
85
|
+
} | {
|
|
86
|
+
kind: "specific_tool";
|
|
87
|
+
name: string;
|
|
88
|
+
/** Set when pinning an MCP-resolved tool; omit for caller-declared. */
|
|
89
|
+
mcp_alias?: string | null;
|
|
90
|
+
};
|
|
91
|
+
/** Sparse override applied per-run; lists replace wholesale. */
|
|
92
|
+
export interface RunConfigOverride {
|
|
93
|
+
model?: AgentModel;
|
|
94
|
+
data_plane_id?: string;
|
|
95
|
+
execution_cluster?: ExecutionCluster;
|
|
96
|
+
compute_pool_id?: string;
|
|
97
|
+
max_iterations?: number;
|
|
98
|
+
max_tokens?: number;
|
|
99
|
+
temperature?: number;
|
|
100
|
+
output_format_schema?: JsonSchemaObject;
|
|
101
|
+
mcp_servers?: McpServerConfig[];
|
|
102
|
+
tools?: ToolSpec[];
|
|
103
|
+
}
|
|
104
|
+
export interface CreateRunRequest {
|
|
105
|
+
client_op_id: ClientOpId;
|
|
106
|
+
expected_version: ConversationVersion;
|
|
107
|
+
payload: RunPayload;
|
|
108
|
+
tool_choice?: ToolChoice;
|
|
109
|
+
config_override?: RunConfigOverride;
|
|
110
|
+
}
|
|
111
|
+
export interface PendingToolCall {
|
|
112
|
+
tool_use_id: ToolUseId;
|
|
113
|
+
/** Wire-form name. For caller-declared tools, dash-free. */
|
|
114
|
+
name: string;
|
|
115
|
+
arguments: Record<string, unknown>;
|
|
116
|
+
}
|
|
117
|
+
export interface AgentInferenceUsage {
|
|
118
|
+
prompt_tokens: number;
|
|
119
|
+
completion_tokens: number;
|
|
120
|
+
total_tokens: number;
|
|
121
|
+
}
|
|
122
|
+
export interface RunError {
|
|
123
|
+
/** Stable incident code, e.g. "AgentLoopMaxIterationsExceeded". */
|
|
124
|
+
type: string;
|
|
125
|
+
message: string;
|
|
126
|
+
title?: string;
|
|
127
|
+
docs_url?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface RunResponse {
|
|
130
|
+
id: RunId;
|
|
131
|
+
conversation_id: ConversationId;
|
|
132
|
+
company_id: number;
|
|
133
|
+
user_id: number;
|
|
134
|
+
client_op_id: ClientOpId;
|
|
135
|
+
status: RunStatus;
|
|
136
|
+
tool_choice?: ToolChoice;
|
|
137
|
+
effective_config: ConversationDefaults;
|
|
138
|
+
iterations_used?: number | null;
|
|
139
|
+
usage?: AgentInferenceUsage | null;
|
|
140
|
+
submitted_inference_job_ids: string[];
|
|
141
|
+
pending_tool_calls: PendingToolCall[];
|
|
142
|
+
final_text?: string | null;
|
|
143
|
+
error?: RunError | null;
|
|
144
|
+
started_at: string;
|
|
145
|
+
completed_at?: string | null;
|
|
146
|
+
}
|
|
147
|
+
export type AgentMessageRole = "user" | "assistant" | "tool";
|
|
148
|
+
export interface TextContentBlock {
|
|
149
|
+
type: "text";
|
|
150
|
+
text: string;
|
|
151
|
+
}
|
|
152
|
+
export interface ToolUseContentBlock {
|
|
153
|
+
type: "tool_use";
|
|
154
|
+
tool_use_id: ToolUseId;
|
|
155
|
+
/** Fully-aliased wire name (`{alias}-{tool_name}` for MCP, bare for caller-declared). */
|
|
156
|
+
name: string;
|
|
157
|
+
arguments: Record<string, unknown>;
|
|
158
|
+
}
|
|
159
|
+
export interface ToolResultContentBlock {
|
|
160
|
+
type: "tool_result";
|
|
161
|
+
tool_use_id: ToolUseId;
|
|
162
|
+
content: ContentBlock[];
|
|
163
|
+
is_error: boolean;
|
|
164
|
+
}
|
|
165
|
+
export type ContentBlock = TextContentBlock | ToolUseContentBlock | ToolResultContentBlock;
|
|
166
|
+
export interface MessageDto {
|
|
167
|
+
id: string;
|
|
168
|
+
sequence_no: number;
|
|
169
|
+
role: AgentMessageRole;
|
|
170
|
+
content_blocks: ContentBlock[];
|
|
171
|
+
run_id: RunId;
|
|
172
|
+
created_at: string;
|
|
173
|
+
}
|
|
174
|
+
export interface ListMessagesResponse {
|
|
175
|
+
current_version: ConversationVersion;
|
|
176
|
+
messages: MessageDto[];
|
|
177
|
+
}
|
|
178
|
+
export interface AgentRfcError {
|
|
179
|
+
type?: string | null;
|
|
180
|
+
title: string;
|
|
181
|
+
status: number;
|
|
182
|
+
detail?: string;
|
|
183
|
+
instance?: string;
|
|
184
|
+
log_id: string;
|
|
185
|
+
debug?: Record<string, unknown> | null;
|
|
186
|
+
}
|
|
187
|
+
export declare const TERMINAL_RUN_STATUSES: ReadonlyArray<RunStatus>;
|
|
188
|
+
export declare function isTerminalRunStatus(status: RunStatus): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Conversations API — types.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `/agents/conversations` and `/agents/runs` on the Narrative Data
|
|
5
|
+
* Collaboration Platform (RFC 7807 errors; OpenAI-Assistants-shaped semantics).
|
|
6
|
+
*
|
|
7
|
+
* Two tool dimensions:
|
|
8
|
+
* - `mcp_servers[]` — server-side, resolved by the platform via MCP. Model sees
|
|
9
|
+
* each tool as `{alias}-{name}`.
|
|
10
|
+
* - `tools[]` — caller-declared. Dash-free names. When called, the run pauses
|
|
11
|
+
* at `requires_action`; resume by posting a follow-up run with
|
|
12
|
+
* `payload.kind: "tool_outputs"`.
|
|
13
|
+
*/
|
|
14
|
+
// Terminal states helper
|
|
15
|
+
export const TERMINAL_RUN_STATUSES = [
|
|
16
|
+
"completed",
|
|
17
|
+
"requires_action",
|
|
18
|
+
"failed",
|
|
19
|
+
];
|
|
20
|
+
export function isTerminalRunStatus(status) {
|
|
21
|
+
return TERMINAL_RUN_STATUSES.includes(status);
|
|
22
|
+
}
|
package/build/apps/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseApi } from "../base-api";
|
|
2
|
-
import type { JsonSchemaConnectorPolicy } from "../collaboration-policy/core/jsonschema/json-schema-types";
|
|
3
2
|
import type { ApiRecords } from "../types";
|
|
4
3
|
import type { App, Installation } from "./types";
|
|
5
4
|
/**
|
|
@@ -15,11 +14,5 @@ declare class AppsApi extends BaseApi {
|
|
|
15
14
|
*/
|
|
16
15
|
getApps(appCategory?: string): Promise<ApiRecords<App>>;
|
|
17
16
|
getInstalledApps(appCategory?: string): Promise<ApiRecords<Installation>>;
|
|
18
|
-
/**
|
|
19
|
-
* Get all interfaces for the current user's installed connectors.
|
|
20
|
-
* @param {string[]} [tags] - Optional tags to filter interfaces (e.g. ["audience_delivery"]).
|
|
21
|
-
* @returns {Promise<ApiRecords<JsonSchemaConnectorPolicy>>} - Promise resolving with the list of interfaces.
|
|
22
|
-
*/
|
|
23
|
-
getInstalledInterfaces(tags?: string[]): Promise<ApiRecords<JsonSchemaConnectorPolicy>>;
|
|
24
17
|
}
|
|
25
18
|
export { type App, AppsApi, type Installation };
|
package/build/apps/index.js
CHANGED
|
@@ -21,14 +21,5 @@ class AppsApi extends BaseApi {
|
|
|
21
21
|
const url = `installations${appCategoryQuery}`;
|
|
22
22
|
return await this.get(url);
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Get all interfaces for the current user's installed connectors.
|
|
26
|
-
* @param {string[]} [tags] - Optional tags to filter interfaces (e.g. ["audience_delivery"]).
|
|
27
|
-
* @returns {Promise<ApiRecords<JsonSchemaConnectorPolicy>>} - Promise resolving with the list of interfaces.
|
|
28
|
-
*/
|
|
29
|
-
async getInstalledInterfaces(tags) {
|
|
30
|
-
const queryString = this.constructQueryString(tags != null ? { tags } : undefined);
|
|
31
|
-
return await this.get(`${resourceName}/installed/interfaces${queryString}`);
|
|
32
|
-
}
|
|
33
24
|
}
|
|
34
25
|
export { AppsApi };
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { normalizePathValue } from "../utils/path-helpers";
|
|
2
2
|
import { resolveAttributeExpression } from "../utils/sql-helpers";
|
|
3
|
-
|
|
4
|
-
return (!!node &&
|
|
5
|
-
typeof node === "object" &&
|
|
6
|
-
"type" in node &&
|
|
7
|
-
node.type === "attribute" &&
|
|
8
|
-
"attribute_name" in node);
|
|
9
|
-
}
|
|
3
|
+
import { isAttributeReference } from "./filter-utils";
|
|
10
4
|
export function filterToSql(filter, attributeByName, datasetName) {
|
|
11
5
|
const op = filter.op.toLowerCase();
|
|
12
6
|
switch (op) {
|
|
@@ -1,91 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
pointer: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* An attribute reference within a filter expression.
|
|
13
|
-
*/
|
|
14
|
-
export interface FilterAttributeRef {
|
|
15
|
-
type: "attribute";
|
|
16
|
-
attribute_name: string;
|
|
17
|
-
path?: PathValue;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* A filter expression: a literal value or an attribute reference.
|
|
21
|
-
*/
|
|
22
|
-
export type FilterExpression = string | number | boolean | FilterAttributeRef;
|
|
23
|
-
/**
|
|
24
|
-
* PolicyFilter is a single filter entry in a policy definition.
|
|
25
|
-
*
|
|
26
|
-
* This is the canonical filter type used across the codebase (JSON-Schema
|
|
27
|
-
* filters, SQL builder, etc.).
|
|
28
|
-
*/
|
|
29
|
-
export type PolicyFilter = PolicyFilterAndOr | PolicyFilterNot | PolicyFilterIsNull | PolicyFilterIn | PolicyFilterCompare | PolicyFilterBetween;
|
|
30
|
-
interface PolicyFilterBase {
|
|
31
|
-
stage?: "generation";
|
|
32
|
-
name?: string;
|
|
33
|
-
required?: boolean;
|
|
34
|
-
}
|
|
35
|
-
interface PolicyFilterAndOr extends PolicyFilterBase {
|
|
36
|
-
op: "and" | "or";
|
|
37
|
-
args: FilterExpression[];
|
|
38
|
-
}
|
|
39
|
-
interface PolicyFilterNot extends PolicyFilterBase {
|
|
40
|
-
op: "not";
|
|
41
|
-
args: FilterExpression[];
|
|
42
|
-
}
|
|
43
|
-
interface PolicyFilterIsNull extends PolicyFilterBase {
|
|
44
|
-
op: "is_null" | "is_not_null";
|
|
45
|
-
left: FilterExpression;
|
|
46
|
-
}
|
|
47
|
-
interface PolicyFilterIn extends PolicyFilterBase {
|
|
48
|
-
op: "in" | "not in";
|
|
49
|
-
left: FilterExpression;
|
|
50
|
-
right: FilterExpression[];
|
|
51
|
-
}
|
|
52
|
-
interface PolicyFilterCompare extends PolicyFilterBase {
|
|
53
|
-
op: "=" | "<>" | ">" | ">=" | "<" | "<=" | "like" | "not like";
|
|
54
|
-
left: FilterExpression;
|
|
55
|
-
right: FilterExpression;
|
|
56
|
-
}
|
|
57
|
-
interface PolicyFilterBetween extends PolicyFilterBase {
|
|
58
|
-
op: "between";
|
|
59
|
-
operand: FilterExpression;
|
|
60
|
-
lower: FilterExpression;
|
|
61
|
-
upper: FilterExpression;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Map from attribute name -> set of normalized paths that must be selected
|
|
65
|
-
* for SQL generation.
|
|
66
|
-
*/
|
|
1
|
+
import type { CollaborationPolicyType } from "../types";
|
|
2
|
+
type PolicyDefinition = CollaborationPolicyType["policy"]["definition"];
|
|
3
|
+
export type StructureNode = PolicyDefinition["structure"];
|
|
4
|
+
export type ExtendedAttributeNode = Extract<StructureNode, {
|
|
5
|
+
field: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
export type PolicyFilter = NonNullable<PolicyDefinition["filters"]>[number];
|
|
8
|
+
export type PathValue = NonNullable<ExtendedAttributeNode["field"]["additional_required_properties"]>[number];
|
|
67
9
|
export type AttributePathIndex = Map<string, Set<string>>;
|
|
68
|
-
/**
|
|
69
|
-
* A logical group of SQL fragments combined by an operation.
|
|
70
|
-
*/
|
|
71
10
|
export interface PolicySqlGroup {
|
|
72
11
|
fragments: Array<string | PolicySqlGroup>;
|
|
73
12
|
operation: "AND" | "OR";
|
|
74
13
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Core SQL fragments required to represent a set of collaboration policies.
|
|
77
|
-
*/
|
|
78
14
|
export interface PolicySqlFragments {
|
|
79
15
|
select: string[];
|
|
80
16
|
where: Array<PolicySqlGroup | string>;
|
|
81
17
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Full result of applying collaboration policies to a dataset, including:
|
|
84
|
-
* - which policies were applied
|
|
85
|
-
* - which were skipped and why
|
|
86
|
-
* - warnings
|
|
87
|
-
* - the minimum refresh schedule across applied policies
|
|
88
|
-
*/
|
|
89
18
|
export interface PolicyMatchResult extends PolicySqlFragments {
|
|
90
19
|
appliedPolicies: string[];
|
|
91
20
|
skippedPolicies: Array<{
|
|
@@ -94,7 +23,7 @@ export interface PolicyMatchResult extends PolicySqlFragments {
|
|
|
94
23
|
details: string[];
|
|
95
24
|
}>;
|
|
96
25
|
warnings: string[];
|
|
97
|
-
/** The minimum refresh schedule
|
|
98
|
-
refresh_schedule:
|
|
26
|
+
/** The minimum refresh schedule in milliseconds across all evaluated policies */
|
|
27
|
+
refresh_schedule: number;
|
|
99
28
|
}
|
|
100
29
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export { default as useCollaborationPolicy } from "./useCollaborationPolicy";
|
|
1
|
+
export { buildPolicySql, buildPolicySqlWithValidation, categorizePolicies, } from "./core/sql-builder";
|
|
2
|
+
export type { AttributePathIndex, ExtendedAttributeNode, PathValue, PolicyFilter, PolicyMatchResult, PolicySqlFragments, PolicySqlGroup, StructureNode, } from "./core/types";
|
|
3
|
+
export type { CollaborationPolicyInput, CollaborationPolicyType, } from "./types";
|
|
4
|
+
export { buildCollaborationPolicyJsonSchema, CollaborationPolicy, } from "./types";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export { buildPolicySql,
|
|
3
|
-
|
|
4
|
-
export { default as useCollaborationPolicy } from "./useCollaborationPolicy";
|
|
1
|
+
// Export the main functions
|
|
2
|
+
export { buildPolicySql, buildPolicySqlWithValidation, categorizePolicies, } from "./core/sql-builder";
|
|
3
|
+
export { buildCollaborationPolicyJsonSchema, CollaborationPolicy, } from "./types";
|