@collective-intelligence/external-apps-server-sdk 0.1.37 → 0.1.38
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/README.md +111 -12
- package/dist/{runtime/effect.js → chunks/index-zrrnrqkm.js} +11 -2
- package/dist/effect.d.ts +1349 -0
- package/dist/effect.js +1 -0
- package/dist/gateway.d.ts +9 -3
- package/dist/gateway.js +1 -1
- package/dist/index.d.ts +84 -37
- package/dist/index.js +1 -16
- package/dist/next.d.ts +358 -0
- package/dist/next.js +1 -0
- package/dist/persistence/drizzle-effect.d.ts +23 -4
- package/dist/resources.js +1 -1
- package/dist/runtime/effect.d.ts +137 -106
- package/dist/runtime/next.d.ts +126 -86
- package/dist/runtime/web.d.ts +11 -5
- package/dist/runtime/web.js +1 -1
- package/package.json +20 -11
- package/dist/persistence/drizzle-effect.js +0 -1
- package/dist/runtime/next.js +0 -1
package/dist/effect.d.ts
CHANGED
|
@@ -1,3 +1,1352 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
import { ConsumerProfileDiagnostic, DatasetDefinition, DatasetProviderCapabilities, DatasetProviderResult, DatasetResultPage, FormMetadata, JsonSchemaDocument, OperationDomainDeclaration, PackageSchemaProjection, PortableOperationDeclaration, QueryInput } from '@collective-intelligence/extensions-sdk';
|
|
4
|
+
import { CiError, CiErrorCode, CiTransportError, FederatedAuthError, FederatedAuthErrorCode } from '@collective-intelligence/external-apps-client-sdk/effect';
|
|
5
|
+
import { EntityOperation, EntityOperationResult, EntityProtocol, EntityRequest, EntityUploadInput, EntityUploadSlot, ResourceDefinition, ResourceJsonValue, ResourceListQuery, ResourceListResult, ResourceRecord, ResourceResult, ResourceTransportRequest } from '@collective-intelligence/external-apps-client-sdk/resources';
|
|
6
|
+
import * as DrizzleNodePostgres from 'drizzle-orm/node-postgres';
|
|
7
|
+
import * as Context from 'effect/Context';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Layer from 'effect/Layer';
|
|
10
|
+
import * as Redacted from 'effect/Redacted';
|
|
11
|
+
import * as Schema from 'effect/Schema';
|
|
12
|
+
import { Pool, PoolConfig } from 'pg';
|
|
13
|
+
|
|
14
|
+
declare const DrizzlePostgresInitializationError_base: Schema.Class<DrizzlePostgresInitializationError, Schema.TaggedStruct<"DrizzlePostgresInitializationError", {
|
|
15
|
+
readonly cause: Schema.Defect;
|
|
16
|
+
}>, import("effect/Cause").YieldableError>;
|
|
17
|
+
declare class DrizzlePostgresInitializationError extends DrizzlePostgresInitializationError_base {
|
|
18
|
+
}
|
|
19
|
+
declare const makeDatabase: (drizzle: typeof DrizzleNodePostgres.drizzle, pool: Pool) => DrizzleNodePostgres.NodePgDatabase<import("drizzle-orm").EmptyRelations> & {
|
|
20
|
+
$client: Pool;
|
|
21
|
+
};
|
|
22
|
+
export type DrizzlePostgresValue = Readonly<{
|
|
23
|
+
database: ReturnType<typeof makeDatabase>;
|
|
24
|
+
pool: Pool;
|
|
25
|
+
}>;
|
|
26
|
+
declare const DrizzlePostgres_base: Context.ServiceClass<DrizzlePostgres, "@collective-intelligence/external-apps-server-sdk/DrizzlePostgres", Readonly<{
|
|
27
|
+
database: ReturnType<typeof makeDatabase>;
|
|
28
|
+
pool: Pool;
|
|
29
|
+
}>>;
|
|
30
|
+
declare class DrizzlePostgres extends DrizzlePostgres_base {
|
|
31
|
+
}
|
|
32
|
+
export type NodePostgresLayerOptions = Readonly<{
|
|
33
|
+
connection: PoolConfig;
|
|
34
|
+
/** Explicit host-selected migration hook. The SDK never discovers or runs DDL implicitly. */
|
|
35
|
+
migrate?: (value: DrizzlePostgresValue) => Promise<void>;
|
|
36
|
+
}>;
|
|
37
|
+
/** Application login identities are separate from gateway machine callers. */
|
|
38
|
+
export type ApplicationUserIdentity = Readonly<{
|
|
39
|
+
kind: "local_user";
|
|
40
|
+
id: string;
|
|
41
|
+
email: string;
|
|
42
|
+
name: string | null;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "ci_user";
|
|
45
|
+
id: string;
|
|
46
|
+
email: string | null;
|
|
47
|
+
name: string | null;
|
|
48
|
+
issuer: string;
|
|
49
|
+
organizationId: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** Constructed only after user/app/organization authorization at server ingress.
|
|
52
|
+
* Canonical identities survive proxy hops and scope mutation receipts; credentials
|
|
53
|
+
* and request/correlation IDs are deliberately not part of that logical identity.
|
|
54
|
+
*/
|
|
55
|
+
export type EntityInvocationContext = Readonly<{
|
|
56
|
+
/** The App Permissions of the user's effective roles on the app. */
|
|
57
|
+
appPermissions: readonly string[];
|
|
58
|
+
applicationId: string;
|
|
59
|
+
issuer: string;
|
|
60
|
+
organizationId: string;
|
|
61
|
+
resourceId: string;
|
|
62
|
+
/** The user's effective roles on the app, read from CI at this lookup. */
|
|
63
|
+
roles: readonly string[];
|
|
64
|
+
scopes: readonly string[];
|
|
65
|
+
user: ApplicationUserIdentity;
|
|
66
|
+
}>;
|
|
67
|
+
export type PrincipalKind = "detached_user" | "service_principal";
|
|
68
|
+
export type DelegatedSubjectPolicy = "allowed" | "forbidden" | "required";
|
|
69
|
+
export type AuthorizationRequirement = Readonly<{
|
|
70
|
+
delegatedSubject?: DelegatedSubjectPolicy;
|
|
71
|
+
organization: "required";
|
|
72
|
+
principalKinds: readonly PrincipalKind[];
|
|
73
|
+
scopes: readonly string[];
|
|
74
|
+
}>;
|
|
75
|
+
export type ExternalAuditSubject = Readonly<{
|
|
76
|
+
issuer: string;
|
|
77
|
+
mappedCiUserId?: string;
|
|
78
|
+
subject: string;
|
|
79
|
+
}>;
|
|
80
|
+
export type GatewayCallerIdentity = Readonly<{
|
|
81
|
+
audience: readonly string[];
|
|
82
|
+
binding: string;
|
|
83
|
+
expiresAt: number;
|
|
84
|
+
installationId: string;
|
|
85
|
+
issuer: string;
|
|
86
|
+
organizationId: string;
|
|
87
|
+
principalKind: PrincipalKind;
|
|
88
|
+
requestId: string;
|
|
89
|
+
scopes: readonly string[];
|
|
90
|
+
subject: string;
|
|
91
|
+
}>;
|
|
92
|
+
export type GatewayInvocationContext = Readonly<{
|
|
93
|
+
caller: GatewayCallerIdentity;
|
|
94
|
+
correlationId: string;
|
|
95
|
+
externalAuditSubject?: ExternalAuditSubject;
|
|
96
|
+
organizationId: string;
|
|
97
|
+
}>;
|
|
98
|
+
export type ResourceChange<Entity> = Readonly<{
|
|
99
|
+
kind: "upsert";
|
|
100
|
+
record: ResourceRecord<Entity>;
|
|
101
|
+
}> | Readonly<{
|
|
102
|
+
kind: "tombstone";
|
|
103
|
+
id: string;
|
|
104
|
+
revision: string;
|
|
105
|
+
deletedAt: string;
|
|
106
|
+
}>;
|
|
107
|
+
export type ResourceChangePage<Entity> = Readonly<{
|
|
108
|
+
changes: readonly ResourceChange<Entity>[];
|
|
109
|
+
nextCursor?: string;
|
|
110
|
+
}>;
|
|
111
|
+
/** Full inventory only: no filters, text search or caller-selected ordering.
|
|
112
|
+
* Continue consecutive pages with the first watermark. A conflict requires restart.
|
|
113
|
+
*/
|
|
114
|
+
export type ResourceInventoryRequest = Readonly<{
|
|
115
|
+
page: number;
|
|
116
|
+
pageSize: number;
|
|
117
|
+
watermark?: string;
|
|
118
|
+
}>;
|
|
119
|
+
export type ResourceInventoryPage<Entity> = Extract<ResourceListResult<Entity>, {
|
|
120
|
+
pagination: "page";
|
|
121
|
+
}> & Readonly<{
|
|
122
|
+
/** Resource-scoped committed change cursor; consume deltas strictly after it. */
|
|
123
|
+
watermark: string;
|
|
124
|
+
}>;
|
|
125
|
+
export type ResourceMutation = Readonly<{
|
|
126
|
+
id: string;
|
|
127
|
+
expectedRevision: string;
|
|
128
|
+
}>;
|
|
129
|
+
export interface CrudRepository<Entity, Create = Entity, Update = Partial<Entity>> {
|
|
130
|
+
readonly list: (query: ResourceListQuery, context?: EntityInvocationContext) => Promise<ResourceListResult<Entity>>;
|
|
131
|
+
readonly scan?: (request: ResourceInventoryRequest) => Promise<ResourceInventoryPage<Entity>>;
|
|
132
|
+
readonly get?: (id: string, includeDeleted?: boolean, context?: EntityInvocationContext) => Promise<ResourceRecord<Entity>>;
|
|
133
|
+
readonly create?: (value: Create, idempotencyKey: string, context?: EntityInvocationContext) => Promise<ResourceRecord<Entity>>;
|
|
134
|
+
readonly update?: (input: ResourceMutation & Readonly<{
|
|
135
|
+
value: Update;
|
|
136
|
+
}>, context?: EntityInvocationContext) => Promise<ResourceRecord<Entity>>;
|
|
137
|
+
readonly hardDelete?: (input: ResourceMutation, context?: EntityInvocationContext) => Promise<void>;
|
|
138
|
+
readonly softDelete?: (input: ResourceMutation, context?: EntityInvocationContext) => Promise<ResourceRecord<Entity>>;
|
|
139
|
+
readonly restore?: (input: ResourceMutation, context?: EntityInvocationContext) => Promise<ResourceRecord<Entity>>;
|
|
140
|
+
readonly changes?: (input: Readonly<{
|
|
141
|
+
cursor?: string;
|
|
142
|
+
limit: number;
|
|
143
|
+
}>) => Promise<ResourceChangePage<Entity>>;
|
|
144
|
+
}
|
|
145
|
+
/** A configured local or CI-backed binding; no storage policy is exposed to browsers. */
|
|
146
|
+
export type EntityResourceDefinition<Value = unknown, Create = Value, Patch = Partial<Value>> = Readonly<{
|
|
147
|
+
definition: ResourceDefinition<Value, Create, Patch>;
|
|
148
|
+
execute: (request: EntityRequest<Create, Patch>, context: EntityInvocationContext, options?: Readonly<{
|
|
149
|
+
signal?: AbortSignal;
|
|
150
|
+
}>) => Promise<ResourceResult<EntityOperationResult<Value, EntityOperation>>>;
|
|
151
|
+
}>;
|
|
152
|
+
export type GatewayResourceOperation = ResourceTransportRequest["operation"];
|
|
153
|
+
export type GatewayResourceAuthorization = Readonly<Partial<Record<GatewayResourceOperation, AuthorizationRequirement>>>;
|
|
154
|
+
export type GatewayResourceDefinition<Entity = unknown, Create = Entity, Update = Partial<Entity>> = Readonly<{
|
|
155
|
+
authorization: GatewayResourceAuthorization;
|
|
156
|
+
definition: ResourceDefinition<Entity, Create, Update>;
|
|
157
|
+
execute: (request: ResourceTransportRequest, context: GatewayInvocationContext, options?: Readonly<{
|
|
158
|
+
signal?: AbortSignal;
|
|
159
|
+
}>) => Promise<ResourceResult<unknown>>;
|
|
160
|
+
scan?: (request: ResourceInventoryRequest & Readonly<{
|
|
161
|
+
requestId: string;
|
|
162
|
+
resourceId: string;
|
|
163
|
+
}>, context: GatewayInvocationContext, options?: Readonly<{
|
|
164
|
+
signal?: AbortSignal;
|
|
165
|
+
}>) => Promise<ResourceResult<unknown>>;
|
|
166
|
+
changes?: (request: Readonly<{
|
|
167
|
+
cursor?: string;
|
|
168
|
+
limit: number;
|
|
169
|
+
requestId: string;
|
|
170
|
+
resourceId: string;
|
|
171
|
+
}>, context: GatewayInvocationContext, options?: Readonly<{
|
|
172
|
+
signal?: AbortSignal;
|
|
173
|
+
}>) => Promise<ResourceResult<unknown>>;
|
|
174
|
+
}>;
|
|
175
|
+
export type CrudResource<Entity = unknown, Create = Entity, Update = Partial<Entity>> = GatewayResourceDefinition<Entity, Create, Update> & Readonly<{
|
|
176
|
+
executeCrud: (request: ResourceTransportRequest, context: EntityInvocationContext) => Promise<ResourceResult<unknown>>;
|
|
177
|
+
}>;
|
|
178
|
+
export type ResourceHttpHandlerOptions<Value = unknown, Create = Value, Patch = Partial<Value>> = Readonly<{
|
|
179
|
+
resource: CrudResource<Value, Create, Patch> | EntityResourceDefinition<Value, Create, Patch>;
|
|
180
|
+
/** Mount path including the entity name, e.g. /api/leads. */
|
|
181
|
+
basePath: string;
|
|
182
|
+
/** Host verifies the current CI session and resource policy; no browser identity is trusted. */
|
|
183
|
+
authorize: (request: Request, operation: ResourceTransportRequest["operation"] | EntityOperation) => Promise<EntityInvocationContext | Response>;
|
|
184
|
+
maxBodyBytes?: number;
|
|
185
|
+
}>;
|
|
186
|
+
/**
|
|
187
|
+
* Runtime dispatch validates the declared input schema before invoking a
|
|
188
|
+
* handler. The bivariant call signature lets domains retain heterogeneous,
|
|
189
|
+
* strongly typed handlers while exposing one erased operation collection.
|
|
190
|
+
*/
|
|
191
|
+
export type GatewayOperationHandler<Input = unknown, Output = unknown> = {
|
|
192
|
+
bivarianceHack(request: Readonly<{
|
|
193
|
+
context: GatewayInvocationContext;
|
|
194
|
+
/** Validated caller key; the handler owns durable replay storage. */
|
|
195
|
+
idempotencyKey?: string;
|
|
196
|
+
input: Input;
|
|
197
|
+
signal: AbortSignal;
|
|
198
|
+
}>): Promise<Output>;
|
|
199
|
+
}["bivarianceHack"];
|
|
200
|
+
export type GatewayOperationDefinition<Input = unknown, Output = unknown> = Omit<PortableOperationDeclaration, "input" | "output"> & Readonly<{
|
|
201
|
+
handler: GatewayOperationHandler<Input, Output>;
|
|
202
|
+
input: PackageSchemaProjection;
|
|
203
|
+
output: PackageSchemaProjection;
|
|
204
|
+
}>;
|
|
205
|
+
export type GatewayOperationManifest = Omit<GatewayOperationDefinition, "handler"> & Readonly<{
|
|
206
|
+
canonicalReference: string;
|
|
207
|
+
}>;
|
|
208
|
+
export type GatewayOperationDomainDefinition = OperationDomainDeclaration<GatewayOperationDefinition>;
|
|
209
|
+
export type GatewayOperationDomainManifest = OperationDomainDeclaration<GatewayOperationManifest>;
|
|
210
|
+
/** CI destination marker only; source records are shared across all connections. */
|
|
211
|
+
export type OrganizationBinding = Readonly<{
|
|
212
|
+
mode: "installed_organization";
|
|
213
|
+
}>;
|
|
214
|
+
export type GatewayKnowledgeResourceExposure = Readonly<{
|
|
215
|
+
resource: GatewayResourceDefinition;
|
|
216
|
+
access: "read" | "read_write";
|
|
217
|
+
}>;
|
|
218
|
+
export type GatewayDatasetBinding = Readonly<{
|
|
219
|
+
id: string;
|
|
220
|
+
title: string;
|
|
221
|
+
definition: DatasetDefinition;
|
|
222
|
+
authorization: AuthorizationRequirement;
|
|
223
|
+
providerFqn: string;
|
|
224
|
+
query: (input: QueryInput, context: GatewayInvocationContext, options: Readonly<{
|
|
225
|
+
signal: AbortSignal;
|
|
226
|
+
}>) => Promise<DatasetProviderResult<DatasetResultPage>>;
|
|
227
|
+
}>;
|
|
228
|
+
export type GatewayDatasetManifest = Omit<GatewayDatasetBinding, "query"> & Readonly<{
|
|
229
|
+
capabilities: DatasetProviderCapabilities;
|
|
230
|
+
}>;
|
|
231
|
+
export type GatewayDefinitionInput = Readonly<{
|
|
232
|
+
knowledge?: readonly GatewayKnowledgeResourceExposure[];
|
|
233
|
+
datasets?: readonly GatewayDatasetBinding[];
|
|
234
|
+
id: string;
|
|
235
|
+
operationDomains: readonly GatewayOperationDomainDefinition[];
|
|
236
|
+
organizationBinding?: OrganizationBinding;
|
|
237
|
+
protocolVersion?: "2";
|
|
238
|
+
version: string;
|
|
239
|
+
}>;
|
|
240
|
+
export type GatewayManifest = Readonly<{
|
|
241
|
+
capabilities: Readonly<{
|
|
242
|
+
resources: boolean;
|
|
243
|
+
}>;
|
|
244
|
+
datasets: readonly GatewayDatasetManifest[];
|
|
245
|
+
knowledge: readonly Readonly<{
|
|
246
|
+
id: string;
|
|
247
|
+
access: "read" | "read_write";
|
|
248
|
+
definition: GatewayResourceDefinition["definition"];
|
|
249
|
+
fullInventory: boolean;
|
|
250
|
+
incrementalChanges: boolean;
|
|
251
|
+
}>[];
|
|
252
|
+
contentHash: string;
|
|
253
|
+
id: string;
|
|
254
|
+
operationDomains: readonly GatewayOperationDomainManifest[];
|
|
255
|
+
organizationBinding: OrganizationBinding;
|
|
256
|
+
protocolVersion: "2";
|
|
257
|
+
revision: string;
|
|
258
|
+
version: string;
|
|
259
|
+
}>;
|
|
260
|
+
export type GatewayProposal = Readonly<{
|
|
261
|
+
gatewayId: string;
|
|
262
|
+
gatewayVersion: string;
|
|
263
|
+
knowledge: GatewayManifest["knowledge"];
|
|
264
|
+
operationDomains: readonly GatewayOperationDomainManifest[];
|
|
265
|
+
revision: string;
|
|
266
|
+
}>;
|
|
267
|
+
export interface DefinedGateway {
|
|
268
|
+
readonly input: GatewayDefinitionInput;
|
|
269
|
+
readonly resource: (id: string) => GatewayResourceDefinition | undefined;
|
|
270
|
+
readonly dataset: (id: string) => GatewayDatasetBinding | undefined;
|
|
271
|
+
readonly manifest: GatewayManifest;
|
|
272
|
+
readonly proposal: GatewayProposal;
|
|
273
|
+
}
|
|
274
|
+
export interface GatewayKernel {
|
|
275
|
+
readonly handle: (request: Request) => Promise<Response>;
|
|
276
|
+
readonly manifest: DefinedGateway["manifest"];
|
|
277
|
+
}
|
|
278
|
+
export type ExternalApplicationsGetContextErrors = {
|
|
279
|
+
/**
|
|
280
|
+
* Error
|
|
281
|
+
*/
|
|
282
|
+
400: {
|
|
283
|
+
correlationId: string;
|
|
284
|
+
error: {
|
|
285
|
+
code: "invalid_request";
|
|
286
|
+
message: string;
|
|
287
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
288
|
+
retryable: false;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Error
|
|
293
|
+
*/
|
|
294
|
+
401: {
|
|
295
|
+
correlationId: string;
|
|
296
|
+
error: {
|
|
297
|
+
code: "authentication_required";
|
|
298
|
+
message: string;
|
|
299
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
300
|
+
retryable: false;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Error
|
|
305
|
+
*/
|
|
306
|
+
403: {
|
|
307
|
+
correlationId: string;
|
|
308
|
+
error: {
|
|
309
|
+
code: "authorization_denied";
|
|
310
|
+
message: string;
|
|
311
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
312
|
+
retryable: false;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Error
|
|
317
|
+
*/
|
|
318
|
+
404: {
|
|
319
|
+
correlationId: string;
|
|
320
|
+
error: {
|
|
321
|
+
code: "operation_not_allowed";
|
|
322
|
+
message: string;
|
|
323
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
324
|
+
retryable: false;
|
|
325
|
+
};
|
|
326
|
+
} | {
|
|
327
|
+
correlationId: string;
|
|
328
|
+
error: {
|
|
329
|
+
code: "not_found";
|
|
330
|
+
message: string;
|
|
331
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
332
|
+
retryable: false;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Error
|
|
337
|
+
*/
|
|
338
|
+
409: {
|
|
339
|
+
correlationId: string;
|
|
340
|
+
error: {
|
|
341
|
+
code: "conflict";
|
|
342
|
+
message: string;
|
|
343
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
344
|
+
retryable: false;
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Error
|
|
349
|
+
*/
|
|
350
|
+
500: {
|
|
351
|
+
correlationId: string;
|
|
352
|
+
error: {
|
|
353
|
+
code: "internal_error";
|
|
354
|
+
message: string;
|
|
355
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
356
|
+
retryable: false;
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Error
|
|
361
|
+
*/
|
|
362
|
+
503: {
|
|
363
|
+
correlationId: string;
|
|
364
|
+
error: {
|
|
365
|
+
code: "temporarily_unavailable";
|
|
366
|
+
message: string;
|
|
367
|
+
reason?: "users_create_forbidden" | "role_not_assignable" | "user_unavailable" | "target_inactive" | "user_not_found" | "user_not_created_by_app" | "application_unavailable" | "actor_not_allowed";
|
|
368
|
+
retryable: true;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
export type ExternalApplicationsGetContextError = ExternalApplicationsGetContextErrors[keyof ExternalApplicationsGetContextErrors];
|
|
373
|
+
export type ExternalApplicationsListAppUsersResponses = {
|
|
374
|
+
/**
|
|
375
|
+
* Success
|
|
376
|
+
*/
|
|
377
|
+
200: {
|
|
378
|
+
correlationId: string;
|
|
379
|
+
result: {
|
|
380
|
+
items: Array<{
|
|
381
|
+
email: string | null;
|
|
382
|
+
name: string | null;
|
|
383
|
+
userId: string;
|
|
384
|
+
}>;
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
export type ExternalApplicationsListAppUsersResponse = ExternalApplicationsListAppUsersResponses[keyof ExternalApplicationsListAppUsersResponses];
|
|
389
|
+
export type ExternalApplicationsCreateOrGetAppUserData = {
|
|
390
|
+
body: {
|
|
391
|
+
email: string;
|
|
392
|
+
name: string;
|
|
393
|
+
roles: Array<string>;
|
|
394
|
+
};
|
|
395
|
+
headers: {
|
|
396
|
+
authorization?: string;
|
|
397
|
+
"x-organization-id": string;
|
|
398
|
+
"x-correlation-id"?: string;
|
|
399
|
+
"x-external-audit-issuer"?: string;
|
|
400
|
+
"x-external-audit-subject"?: string;
|
|
401
|
+
"x-external-caller-kind"?: "anonymous_visitor";
|
|
402
|
+
"x-external-ci-user-id"?: string;
|
|
403
|
+
"x-external-server-role"?: string;
|
|
404
|
+
};
|
|
405
|
+
path?: never;
|
|
406
|
+
query?: never;
|
|
407
|
+
url: "/application/v1/users";
|
|
408
|
+
};
|
|
409
|
+
export type ExternalApplicationsCreateOrGetAppUserResponses = {
|
|
410
|
+
/**
|
|
411
|
+
* Success
|
|
412
|
+
*/
|
|
413
|
+
200: {
|
|
414
|
+
correlationId: string;
|
|
415
|
+
result: {
|
|
416
|
+
email: string | null;
|
|
417
|
+
name: string | null;
|
|
418
|
+
userId: string;
|
|
419
|
+
created: boolean;
|
|
420
|
+
kind: "member" | "external_app_user";
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
export type ExternalApplicationsCreateOrGetAppUserResponse = ExternalApplicationsCreateOrGetAppUserResponses[keyof ExternalApplicationsCreateOrGetAppUserResponses];
|
|
425
|
+
export type ExternalApplicationsCheckAppUserEmailData = {
|
|
426
|
+
body: {
|
|
427
|
+
email: string;
|
|
428
|
+
};
|
|
429
|
+
headers: {
|
|
430
|
+
authorization?: string;
|
|
431
|
+
"x-organization-id": string;
|
|
432
|
+
"x-correlation-id"?: string;
|
|
433
|
+
"x-external-audit-issuer"?: string;
|
|
434
|
+
"x-external-audit-subject"?: string;
|
|
435
|
+
"x-external-caller-kind"?: "anonymous_visitor";
|
|
436
|
+
"x-external-ci-user-id"?: string;
|
|
437
|
+
"x-external-server-role"?: string;
|
|
438
|
+
};
|
|
439
|
+
path?: never;
|
|
440
|
+
query?: never;
|
|
441
|
+
url: "/application/v1/users/check-email";
|
|
442
|
+
};
|
|
443
|
+
export type ExternalApplicationsCheckAppUserEmailResponses = {
|
|
444
|
+
/**
|
|
445
|
+
* Success
|
|
446
|
+
*/
|
|
447
|
+
200: {
|
|
448
|
+
correlationId: string;
|
|
449
|
+
result: {
|
|
450
|
+
usable: true;
|
|
451
|
+
} | {
|
|
452
|
+
reason: "user_unavailable" | "target_inactive";
|
|
453
|
+
usable: false;
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
export type ExternalApplicationsCheckAppUserEmailResponse = ExternalApplicationsCheckAppUserEmailResponses[keyof ExternalApplicationsCheckAppUserEmailResponses];
|
|
458
|
+
export type ExternalApplicationsGetAppUserResponses = {
|
|
459
|
+
/**
|
|
460
|
+
* Success
|
|
461
|
+
*/
|
|
462
|
+
200: {
|
|
463
|
+
correlationId: string;
|
|
464
|
+
result: {
|
|
465
|
+
email: string | null;
|
|
466
|
+
name: string | null;
|
|
467
|
+
userId: string;
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
export type ExternalApplicationsGetAppUserResponse = ExternalApplicationsGetAppUserResponses[keyof ExternalApplicationsGetAppUserResponses];
|
|
472
|
+
export type ExternalApplicationsListAppRolesResponses = {
|
|
473
|
+
/**
|
|
474
|
+
* Success
|
|
475
|
+
*/
|
|
476
|
+
200: {
|
|
477
|
+
correlationId: string;
|
|
478
|
+
result: {
|
|
479
|
+
items: Array<{
|
|
480
|
+
id: string;
|
|
481
|
+
key: string;
|
|
482
|
+
}>;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
export type ExternalApplicationsListAppRolesResponse = ExternalApplicationsListAppRolesResponses[keyof ExternalApplicationsListAppRolesResponses];
|
|
487
|
+
export type JsonValue = boolean | null | number | readonly JsonValue[] | Readonly<{
|
|
488
|
+
readonly [key: string]: JsonValue;
|
|
489
|
+
}> | string;
|
|
490
|
+
export type JsonObject = Readonly<Record<string, JsonValue>>;
|
|
491
|
+
export type WorkflowInvokeTarget = {
|
|
492
|
+
workflowId: string;
|
|
493
|
+
workflowFqn?: never;
|
|
494
|
+
} | {
|
|
495
|
+
workflowFqn: string;
|
|
496
|
+
workflowId?: never;
|
|
497
|
+
};
|
|
498
|
+
/** Addresses an Agent by its UUID or its in-organization FQN. */
|
|
499
|
+
export type AgentInvokeTarget = {
|
|
500
|
+
agentId: string;
|
|
501
|
+
agentFqn?: never;
|
|
502
|
+
} | {
|
|
503
|
+
agentFqn: string;
|
|
504
|
+
agentId?: never;
|
|
505
|
+
};
|
|
506
|
+
/** Starts a conversation with an Agent, or continues an existing one. */
|
|
507
|
+
export type ConversationContinueTarget = (AgentInvokeTarget & {
|
|
508
|
+
conversationId?: never;
|
|
509
|
+
}) | {
|
|
510
|
+
agentFqn?: never;
|
|
511
|
+
agentId?: never;
|
|
512
|
+
conversationId: string;
|
|
513
|
+
};
|
|
514
|
+
export type ConversationTurnStatus = "accepted" | "cancelled" | "failed" | "running" | "succeeded";
|
|
515
|
+
/**
|
|
516
|
+
* One conversation turn: the application's input, the Agent's final message
|
|
517
|
+
* once its run succeeded, and the Agent Output the run saved, if any.
|
|
518
|
+
* `runId` identifies the turn and its producing run.
|
|
519
|
+
*/
|
|
520
|
+
export interface ConversationTurn {
|
|
521
|
+
completedAt: string | null;
|
|
522
|
+
createdAt: string;
|
|
523
|
+
input: unknown;
|
|
524
|
+
message: string | null;
|
|
525
|
+
output?: unknown;
|
|
526
|
+
runId: string;
|
|
527
|
+
status: ConversationTurnStatus;
|
|
528
|
+
}
|
|
529
|
+
export interface ConversationHistory {
|
|
530
|
+
agentId: string;
|
|
531
|
+
conversationId: string;
|
|
532
|
+
createdAt: string;
|
|
533
|
+
turns: ConversationTurn[];
|
|
534
|
+
}
|
|
535
|
+
export interface QueryFilter {
|
|
536
|
+
caseSensitive?: boolean;
|
|
537
|
+
field: string;
|
|
538
|
+
op: "eq" | "neq" | "in" | "contains" | "gt" | "gte" | "lt" | "lte" | "exists";
|
|
539
|
+
value?: unknown;
|
|
540
|
+
}
|
|
541
|
+
export interface SearchQuery {
|
|
542
|
+
cursor?: string;
|
|
543
|
+
entitySchemaId: string;
|
|
544
|
+
fields?: string[];
|
|
545
|
+
filters?: QueryFilter[];
|
|
546
|
+
limit?: number;
|
|
547
|
+
text?: string;
|
|
548
|
+
}
|
|
549
|
+
export type KnowledgeQuery = {
|
|
550
|
+
entityId: string;
|
|
551
|
+
op: "get";
|
|
552
|
+
} | (SearchQuery & {
|
|
553
|
+
op: "search";
|
|
554
|
+
}) | {
|
|
555
|
+
entitySchemaId: string;
|
|
556
|
+
fields: string[];
|
|
557
|
+
filters?: QueryFilter[];
|
|
558
|
+
op: "facets";
|
|
559
|
+
text?: string;
|
|
560
|
+
} | (SearchQuery & {
|
|
561
|
+
op: "autocomplete";
|
|
562
|
+
});
|
|
563
|
+
export type ExternalApplicationOperationRequest = {
|
|
564
|
+
input: {
|
|
565
|
+
userId: string;
|
|
566
|
+
};
|
|
567
|
+
operationId: "users_get";
|
|
568
|
+
} | {
|
|
569
|
+
input: {
|
|
570
|
+
page?: number;
|
|
571
|
+
pageSize?: number;
|
|
572
|
+
};
|
|
573
|
+
operationId: "users_list";
|
|
574
|
+
} | {
|
|
575
|
+
input: {
|
|
576
|
+
userId: string;
|
|
577
|
+
};
|
|
578
|
+
operationId: "users_deactivate";
|
|
579
|
+
} | {
|
|
580
|
+
input: Record<string, never>;
|
|
581
|
+
operationId: "roles_list";
|
|
582
|
+
} | {
|
|
583
|
+
input: {
|
|
584
|
+
userId: string;
|
|
585
|
+
roles: string[];
|
|
586
|
+
};
|
|
587
|
+
operationId: "roles_assign";
|
|
588
|
+
} | {
|
|
589
|
+
input: {
|
|
590
|
+
userId: string;
|
|
591
|
+
roles: string[];
|
|
592
|
+
};
|
|
593
|
+
operationId: "roles_revoke";
|
|
594
|
+
} | {
|
|
595
|
+
input: ExternalApplicationsCreateOrGetAppUserData["body"];
|
|
596
|
+
operationId: "users_create_or_get";
|
|
597
|
+
} | {
|
|
598
|
+
input: JsonObject | unknown[];
|
|
599
|
+
operationId: "context_get";
|
|
600
|
+
} | {
|
|
601
|
+
input: {
|
|
602
|
+
query: KnowledgeQuery;
|
|
603
|
+
};
|
|
604
|
+
operationId: "knowledge_query";
|
|
605
|
+
} | {
|
|
606
|
+
input: {
|
|
607
|
+
schemaId: string;
|
|
608
|
+
};
|
|
609
|
+
operationId: "knowledge_get_entity_schema_snapshot";
|
|
610
|
+
} | {
|
|
611
|
+
input: SearchQuery;
|
|
612
|
+
operationId: "knowledge_search_entities";
|
|
613
|
+
} | {
|
|
614
|
+
input: {
|
|
615
|
+
entitySchemaId: string;
|
|
616
|
+
fields: string[];
|
|
617
|
+
filters?: QueryFilter[];
|
|
618
|
+
text?: string;
|
|
619
|
+
};
|
|
620
|
+
operationId: "knowledge_facets";
|
|
621
|
+
} | {
|
|
622
|
+
input: {
|
|
623
|
+
entitySchemaId: string;
|
|
624
|
+
};
|
|
625
|
+
operationId: "knowledge_get_schema_query_context";
|
|
626
|
+
} | {
|
|
627
|
+
input: SearchQuery;
|
|
628
|
+
operationId: "knowledge_autocomplete";
|
|
629
|
+
} | {
|
|
630
|
+
input: {
|
|
631
|
+
entityId: string;
|
|
632
|
+
};
|
|
633
|
+
operationId: "knowledge_get_entity";
|
|
634
|
+
} | {
|
|
635
|
+
input: {
|
|
636
|
+
entity: {
|
|
637
|
+
data: JsonObject;
|
|
638
|
+
description?: string;
|
|
639
|
+
entitySchemaId: string;
|
|
640
|
+
name: string;
|
|
641
|
+
};
|
|
642
|
+
idempotencyKey: string;
|
|
643
|
+
};
|
|
644
|
+
operationId: "knowledge_create_entity";
|
|
645
|
+
} | {
|
|
646
|
+
input: {
|
|
647
|
+
entity: {
|
|
648
|
+
data?: JsonObject;
|
|
649
|
+
description?: string;
|
|
650
|
+
name?: string;
|
|
651
|
+
};
|
|
652
|
+
entityId: string;
|
|
653
|
+
expectedVersion: number;
|
|
654
|
+
idempotencyKey: string;
|
|
655
|
+
};
|
|
656
|
+
operationId: "knowledge_update_entity";
|
|
657
|
+
} | {
|
|
658
|
+
input: {
|
|
659
|
+
entity: {
|
|
660
|
+
data: JsonObject;
|
|
661
|
+
description?: string;
|
|
662
|
+
entitySchemaId: string;
|
|
663
|
+
name: string;
|
|
664
|
+
};
|
|
665
|
+
entitySchemaId: string;
|
|
666
|
+
externalIdentity: {
|
|
667
|
+
source: string;
|
|
668
|
+
value: string;
|
|
669
|
+
};
|
|
670
|
+
idempotencyKey: string;
|
|
671
|
+
};
|
|
672
|
+
operationId: "knowledge_upsert_entity";
|
|
673
|
+
} | {
|
|
674
|
+
input: {
|
|
675
|
+
entityId: string;
|
|
676
|
+
expectedVersion: number;
|
|
677
|
+
idempotencyKey: string;
|
|
678
|
+
};
|
|
679
|
+
operationId: "knowledge_delete_entity";
|
|
680
|
+
} | {
|
|
681
|
+
input: {
|
|
682
|
+
filter?: JsonObject;
|
|
683
|
+
};
|
|
684
|
+
operationId: "agents_list";
|
|
685
|
+
} | {
|
|
686
|
+
input: {
|
|
687
|
+
idempotencyKey: string;
|
|
688
|
+
input: unknown;
|
|
689
|
+
} & AgentInvokeTarget;
|
|
690
|
+
operationId: "agents_invoke";
|
|
691
|
+
} | {
|
|
692
|
+
input: {
|
|
693
|
+
filter?: JsonObject;
|
|
694
|
+
};
|
|
695
|
+
operationId: "skills_list";
|
|
696
|
+
} | {
|
|
697
|
+
input: {
|
|
698
|
+
idempotencyKey: string;
|
|
699
|
+
input: unknown;
|
|
700
|
+
skillId: string;
|
|
701
|
+
};
|
|
702
|
+
operationId: "skills_invoke";
|
|
703
|
+
} | {
|
|
704
|
+
input: {
|
|
705
|
+
filter?: JsonObject;
|
|
706
|
+
};
|
|
707
|
+
operationId: "workflows_list";
|
|
708
|
+
} | {
|
|
709
|
+
input: {
|
|
710
|
+
idempotencyKey: string;
|
|
711
|
+
input: unknown;
|
|
712
|
+
} & WorkflowInvokeTarget;
|
|
713
|
+
operationId: "workflows_invoke";
|
|
714
|
+
} | {
|
|
715
|
+
input: {
|
|
716
|
+
runId: string;
|
|
717
|
+
};
|
|
718
|
+
operationId: "runs_get";
|
|
719
|
+
} | {
|
|
720
|
+
input: {
|
|
721
|
+
afterCursor?: string;
|
|
722
|
+
runId: string;
|
|
723
|
+
};
|
|
724
|
+
operationId: "runs_stream";
|
|
725
|
+
} | {
|
|
726
|
+
input: {
|
|
727
|
+
runId: string;
|
|
728
|
+
};
|
|
729
|
+
operationId: "runs_cancel";
|
|
730
|
+
} | {
|
|
731
|
+
input: {
|
|
732
|
+
contentBase64: string;
|
|
733
|
+
contentType: string;
|
|
734
|
+
fileName: string;
|
|
735
|
+
runId: string;
|
|
736
|
+
sizeBytes: number;
|
|
737
|
+
};
|
|
738
|
+
operationId: "attachments_upload";
|
|
739
|
+
} | {
|
|
740
|
+
input: {
|
|
741
|
+
attachmentId: string;
|
|
742
|
+
runId: string;
|
|
743
|
+
};
|
|
744
|
+
operationId: "attachments_download_url";
|
|
745
|
+
} | {
|
|
746
|
+
input: {
|
|
747
|
+
idempotencyKey: string;
|
|
748
|
+
input: unknown;
|
|
749
|
+
} & ConversationContinueTarget;
|
|
750
|
+
operationId: "conversations_continue";
|
|
751
|
+
} | {
|
|
752
|
+
input: {
|
|
753
|
+
conversationId: string;
|
|
754
|
+
};
|
|
755
|
+
operationId: "conversations_history";
|
|
756
|
+
};
|
|
757
|
+
export interface EnvelopeSuccess<Id extends string, Result> {
|
|
758
|
+
correlationId: string;
|
|
759
|
+
operationId: Id;
|
|
760
|
+
result: Result;
|
|
761
|
+
}
|
|
762
|
+
export type ExternalApplicationOperationSuccess = EnvelopeSuccess<"users_get", ApplicationUser> | EnvelopeSuccess<"users_list", ApplicationUserPage> | EnvelopeSuccess<"users_deactivate", {
|
|
763
|
+
userId: string;
|
|
764
|
+
}> | EnvelopeSuccess<"roles_list", {
|
|
765
|
+
items: ApplicationRole[];
|
|
766
|
+
}> | EnvelopeSuccess<"roles_assign", {
|
|
767
|
+
userId: string;
|
|
768
|
+
}> | EnvelopeSuccess<"roles_revoke", {
|
|
769
|
+
userId: string;
|
|
770
|
+
}> | EnvelopeSuccess<"users_create_or_get", ApplicationUserResolution> | EnvelopeSuccess<"context_get", JsonObject> | EnvelopeSuccess<"knowledge_query", JsonObject> | EnvelopeSuccess<"knowledge_get_entity_schema_snapshot", JsonObject> | EnvelopeSuccess<"knowledge_search_entities", JsonObject> | EnvelopeSuccess<"knowledge_facets", JsonObject> | EnvelopeSuccess<"knowledge_get_schema_query_context", JsonObject> | EnvelopeSuccess<"knowledge_autocomplete", JsonObject> | EnvelopeSuccess<"knowledge_get_entity", JsonObject> | EnvelopeSuccess<"knowledge_create_entity", JsonObject> | EnvelopeSuccess<"knowledge_update_entity", JsonObject> | EnvelopeSuccess<"knowledge_upsert_entity", JsonObject> | EnvelopeSuccess<"knowledge_delete_entity", JsonObject> | EnvelopeSuccess<"agents_list", JsonObject> | EnvelopeSuccess<"agents_invoke", {
|
|
771
|
+
runId: string;
|
|
772
|
+
}> | EnvelopeSuccess<"skills_list", JsonObject> | EnvelopeSuccess<"skills_invoke", {
|
|
773
|
+
runId: string;
|
|
774
|
+
}> | EnvelopeSuccess<"workflows_list", JsonObject> | EnvelopeSuccess<"workflows_invoke", {
|
|
775
|
+
runId: string;
|
|
776
|
+
}> | EnvelopeSuccess<"runs_get", JsonObject> | EnvelopeSuccess<"runs_stream", {
|
|
777
|
+
events: JsonObject[];
|
|
778
|
+
nextCursor: string | null;
|
|
779
|
+
}> | EnvelopeSuccess<"runs_cancel", JsonObject> | EnvelopeSuccess<"attachments_upload", {
|
|
780
|
+
attachmentId: string;
|
|
781
|
+
}> | EnvelopeSuccess<"attachments_download_url", {
|
|
782
|
+
expiresAt: string;
|
|
783
|
+
url: string;
|
|
784
|
+
}> | EnvelopeSuccess<"conversations_continue", {
|
|
785
|
+
conversationId: string;
|
|
786
|
+
runId: string;
|
|
787
|
+
}> | EnvelopeSuccess<"conversations_history", ConversationHistory>;
|
|
788
|
+
/** User details returned by the application's user-management gateway. */
|
|
789
|
+
export type ApplicationUser = ExternalApplicationsGetAppUserResponse["result"];
|
|
790
|
+
export type ApplicationUserResolution = ExternalApplicationsCreateOrGetAppUserResponse["result"];
|
|
791
|
+
export type ApplicationUserPage = ExternalApplicationsListAppUsersResponse["result"];
|
|
792
|
+
export type ApplicationRole = ExternalApplicationsListAppRolesResponse["result"]["items"][number];
|
|
793
|
+
declare const storageFileIdBrand: unique symbol;
|
|
794
|
+
/** A durable private file of the application's Organization. */
|
|
795
|
+
export type StorageFileId = string & Readonly<{
|
|
796
|
+
[storageFileIdBrand]: "StorageFileId";
|
|
797
|
+
}>;
|
|
798
|
+
/**
|
|
799
|
+
* One file of up to 10 MiB, base64-encoded. CI accepts the content types
|
|
800
|
+
* `application/pdf`, `image/jpeg` and `image/png`.
|
|
801
|
+
*/
|
|
802
|
+
export interface DurableFileUpload {
|
|
803
|
+
contentBase64: string;
|
|
804
|
+
contentType: string;
|
|
805
|
+
fileName: string;
|
|
806
|
+
sizeBytes: number;
|
|
807
|
+
}
|
|
808
|
+
export type ExternalApplicationServiceOperationRequest = {
|
|
809
|
+
input: ExternalApplicationsCheckAppUserEmailData["body"];
|
|
810
|
+
operationId: "users_check_email";
|
|
811
|
+
} | {
|
|
812
|
+
input: DurableFileUpload;
|
|
813
|
+
operationId: "files_upload";
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* Whether `users_create_or_get` would accept an email, checked without
|
|
817
|
+
* creating anything; an unknown email is usable.
|
|
818
|
+
*/
|
|
819
|
+
export type ApplicationUserEmailCheck = ExternalApplicationsCheckAppUserEmailResponse["result"];
|
|
820
|
+
export type ExternalApplicationServiceOperationSuccess = EnvelopeSuccess<"users_check_email", ApplicationUserEmailCheck> | EnvelopeSuccess<"files_upload", {
|
|
821
|
+
storageFileId: StorageFileId;
|
|
822
|
+
}>;
|
|
823
|
+
/** Every operation a confidential server client may invoke. */
|
|
824
|
+
export type ExternalApplicationServerOperationRequest = ExternalApplicationOperationRequest | ExternalApplicationServiceOperationRequest;
|
|
825
|
+
export type ExternalApplicationOperationFailure = ExternalApplicationsGetContextError;
|
|
826
|
+
export type ExternalApplicationServerOperationId = ExternalApplicationServerOperationRequest["operationId"];
|
|
827
|
+
export type ExternalApplicationOperationRequestFor<Id extends ExternalApplicationServerOperationId> = Extract<ExternalApplicationServerOperationRequest, {
|
|
828
|
+
operationId: Id;
|
|
829
|
+
}>;
|
|
830
|
+
export type ExternalApplicationOperationSuccessFor<Id extends ExternalApplicationServerOperationId> = Extract<ExternalApplicationOperationSuccess | ExternalApplicationServiceOperationSuccess, {
|
|
831
|
+
operationId: Id;
|
|
832
|
+
}>;
|
|
833
|
+
export type ExternalApplicationOperationResult<Id extends ExternalApplicationServerOperationId> = Readonly<{
|
|
834
|
+
error: ExternalApplicationOperationFailure;
|
|
835
|
+
ok: false;
|
|
836
|
+
}> | Readonly<{
|
|
837
|
+
ok: true;
|
|
838
|
+
value: ExternalApplicationOperationSuccessFor<Id>;
|
|
839
|
+
}>;
|
|
840
|
+
export interface ExternalApplicationExternalAuditSubject {
|
|
841
|
+
readonly issuer: string;
|
|
842
|
+
readonly mappedUserId?: string;
|
|
843
|
+
readonly subjectId: string;
|
|
844
|
+
}
|
|
845
|
+
type JsonObject$1 = Readonly<Record<string, ResourceJsonValue>>;
|
|
846
|
+
/** A text, or a text that CI speaks with a Voice of the Organization or a named one. */
|
|
847
|
+
export type MessageContent = Readonly<{
|
|
848
|
+
kind: "text";
|
|
849
|
+
text: string;
|
|
850
|
+
}> | Readonly<{
|
|
851
|
+
kind: "voice";
|
|
852
|
+
/** Selects the Voice. Absent: the language detected from `text`. */
|
|
853
|
+
language?: string;
|
|
854
|
+
/** Absent: the default text-to-speech Speech Model of the Organization. */
|
|
855
|
+
modelId?: string;
|
|
856
|
+
modelSettings?: JsonObject$1;
|
|
857
|
+
speed?: number;
|
|
858
|
+
text: string;
|
|
859
|
+
voice: Readonly<{
|
|
860
|
+
mode: "organization";
|
|
861
|
+
}> | Readonly<{
|
|
862
|
+
mode: "fixed";
|
|
863
|
+
voiceId: string;
|
|
864
|
+
}> | Readonly<{
|
|
865
|
+
mode: "per_language";
|
|
866
|
+
voices: readonly Readonly<{
|
|
867
|
+
languageCode: string;
|
|
868
|
+
voiceId: string;
|
|
869
|
+
}>[];
|
|
870
|
+
}>;
|
|
871
|
+
}>;
|
|
872
|
+
/**
|
|
873
|
+
* Where the message goes: the Conversation Reference of an earlier message,
|
|
874
|
+
* or the recipient fields of the vendor for a new conversation.
|
|
875
|
+
*/
|
|
876
|
+
export type MessageTarget = Readonly<{
|
|
877
|
+
conversation: string;
|
|
878
|
+
mode: "continue";
|
|
879
|
+
}> | Readonly<{
|
|
880
|
+
mode: "start_new";
|
|
881
|
+
recipient: JsonObject$1;
|
|
882
|
+
}>;
|
|
883
|
+
export type MessageSendInput = Readonly<{
|
|
884
|
+
/** A connection that an administrator granted to the application. */
|
|
885
|
+
connectionId: string;
|
|
886
|
+
content: MessageContent;
|
|
887
|
+
idempotencyKey: string;
|
|
888
|
+
/** Vendor sender fields; required when the account has more than one sender. */
|
|
889
|
+
sender?: JsonObject$1;
|
|
890
|
+
/** The vendor service; required when the connection has more than one. */
|
|
891
|
+
service?: string;
|
|
892
|
+
target: MessageTarget;
|
|
893
|
+
}>;
|
|
894
|
+
/** The vendor accepted the message. It does not mean that a person received it. */
|
|
895
|
+
export type MessageReceipt = Readonly<{
|
|
896
|
+
/** Continues the conversation of the sent message. */
|
|
897
|
+
conversation: string;
|
|
898
|
+
/** The message id of the vendor. */
|
|
899
|
+
messageId: string;
|
|
900
|
+
}>;
|
|
901
|
+
declare const messageSendErrorCodes: readonly [
|
|
902
|
+
"invalid_message",
|
|
903
|
+
"recipient_unreachable",
|
|
904
|
+
"window_closed",
|
|
905
|
+
"template_required",
|
|
906
|
+
"not_installed",
|
|
907
|
+
"unsupported_content",
|
|
908
|
+
"rejected",
|
|
909
|
+
"transport",
|
|
910
|
+
"configuration",
|
|
911
|
+
"unknown_provider"
|
|
912
|
+
];
|
|
913
|
+
/** Why the provider did not send the message. */
|
|
914
|
+
export type MessageSendErrorCode = (typeof messageSendErrorCodes)[number];
|
|
915
|
+
declare const messageSendFailureCodes: readonly [
|
|
916
|
+
"authentication_required",
|
|
917
|
+
"authorization_denied",
|
|
918
|
+
"conflict",
|
|
919
|
+
"internal_error",
|
|
920
|
+
"invalid_request",
|
|
921
|
+
"message_send_failed",
|
|
922
|
+
"not_found",
|
|
923
|
+
"operation_not_allowed",
|
|
924
|
+
"rate_limited",
|
|
925
|
+
"send_outcome_unknown",
|
|
926
|
+
"temporarily_unavailable"
|
|
927
|
+
];
|
|
928
|
+
export type MessageSendFailure = Readonly<{
|
|
929
|
+
correlationId: string;
|
|
930
|
+
error: Readonly<{
|
|
931
|
+
code: (typeof messageSendFailureCodes)[number];
|
|
932
|
+
message: string;
|
|
933
|
+
retryable: boolean;
|
|
934
|
+
/** Present with the code `message_send_failed`. */
|
|
935
|
+
sendErrorCode?: MessageSendErrorCode;
|
|
936
|
+
}>;
|
|
937
|
+
}>;
|
|
938
|
+
export type MessageSendResult = Readonly<{
|
|
939
|
+
error: MessageSendFailure;
|
|
940
|
+
ok: false;
|
|
941
|
+
}> | Readonly<{
|
|
942
|
+
ok: true;
|
|
943
|
+
value: Readonly<{
|
|
944
|
+
correlationId: string;
|
|
945
|
+
operationId: "messages_send";
|
|
946
|
+
result: MessageReceipt;
|
|
947
|
+
}>;
|
|
948
|
+
}>;
|
|
949
|
+
/**
|
|
950
|
+
* A client secret: a string at `.`, or the `Redacted` string that Effect
|
|
951
|
+
* `Config.Redacted` reads for the `./effect` layers.
|
|
952
|
+
*/
|
|
953
|
+
export type ClientSecret = Redacted.Redacted<string> | string;
|
|
954
|
+
export interface ConfidentialCredentials<Secret extends ClientSecret = string> {
|
|
955
|
+
readonly clientId: string;
|
|
956
|
+
readonly clientSecret: Secret;
|
|
957
|
+
}
|
|
958
|
+
export interface RotatingConfidentialCredentialProvider {
|
|
959
|
+
readonly getCredentials: () => ConfidentialCredentials | Promise<ConfidentialCredentials>;
|
|
960
|
+
}
|
|
961
|
+
export type ConfidentialCredentialProvider<Secret extends ClientSecret = string> = ConfidentialCredentials<Secret> | RotatingConfidentialCredentialProvider;
|
|
962
|
+
declare const GatewayEffectRuntimeError_base: Schema.Class<GatewayEffectRuntimeError, Schema.TaggedStruct<"GatewayEffectRuntimeError", {
|
|
963
|
+
readonly cause: Schema.Defect;
|
|
964
|
+
}>, import("effect/Cause").YieldableError>;
|
|
965
|
+
declare class GatewayEffectRuntimeError extends GatewayEffectRuntimeError_base {
|
|
966
|
+
/** The positional form of `./runtime/effect`: one argument is the cause. */
|
|
967
|
+
constructor(cause: unknown);
|
|
968
|
+
/** The Schema form; Schema decoding gives the fields and the options. */
|
|
969
|
+
constructor(fields: Readonly<{
|
|
970
|
+
cause: unknown;
|
|
971
|
+
}>, options: Schema.MakeOptions | undefined);
|
|
972
|
+
get message(): string;
|
|
973
|
+
}
|
|
974
|
+
declare const oauthErrorCodes: readonly [
|
|
975
|
+
"invalid_client",
|
|
976
|
+
"invalid_grant",
|
|
977
|
+
"invalid_request",
|
|
978
|
+
"invalid_scope",
|
|
979
|
+
"invalid_target",
|
|
980
|
+
"temporarily_unavailable",
|
|
981
|
+
"unauthorized_client",
|
|
982
|
+
"unsupported_grant_type"
|
|
983
|
+
];
|
|
984
|
+
/**
|
|
985
|
+
* `invalid_grant` means the member's CI session ended or the member cannot act
|
|
986
|
+
* in the Organization: sign the member in again. `invalid_response` means CI
|
|
987
|
+
* answered with neither a token nor an OAuth error. Other codes are CI's OAuth
|
|
988
|
+
* errors and point at the application's configuration or CI availability.
|
|
989
|
+
*/
|
|
990
|
+
export type MemberSessionExchangeErrorCode = (typeof oauthErrorCodes)[number] | "invalid_response";
|
|
991
|
+
declare const MemberSessionExchangeError_base: Schema.Class<MemberSessionExchangeError, Schema.TaggedStruct<"MemberSessionExchangeError", {
|
|
992
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
993
|
+
readonly code: Schema.Literals<readonly [
|
|
994
|
+
"invalid_client",
|
|
995
|
+
"invalid_grant",
|
|
996
|
+
"invalid_request",
|
|
997
|
+
"invalid_scope",
|
|
998
|
+
"invalid_target",
|
|
999
|
+
"temporarily_unavailable",
|
|
1000
|
+
"unauthorized_client",
|
|
1001
|
+
"unsupported_grant_type",
|
|
1002
|
+
"invalid_response"
|
|
1003
|
+
]>;
|
|
1004
|
+
/** The HTTP status CI answered with; absent when CI was unreachable. */
|
|
1005
|
+
readonly status: Schema.UndefinedOr<Schema.Int>;
|
|
1006
|
+
}>, import("effect/Cause").YieldableError>;
|
|
1007
|
+
declare class MemberSessionExchangeError extends MemberSessionExchangeError_base {
|
|
1008
|
+
/** The positional form of `.`: CI's code, its HTTP status and the cause. */
|
|
1009
|
+
constructor(code: MemberSessionExchangeErrorCode, status: number | undefined, options?: ErrorOptions);
|
|
1010
|
+
/** The Schema form; Schema decoding gives the fields and the options. */
|
|
1011
|
+
constructor(fields: Readonly<{
|
|
1012
|
+
cause?: unknown;
|
|
1013
|
+
code: MemberSessionExchangeErrorCode;
|
|
1014
|
+
status: number | undefined;
|
|
1015
|
+
}>, options: Schema.MakeOptions | undefined);
|
|
1016
|
+
get message(): string;
|
|
1017
|
+
}
|
|
1018
|
+
export interface ServerRetryPolicy {
|
|
1019
|
+
readonly baseDelayMs?: number;
|
|
1020
|
+
readonly maxAttempts?: number;
|
|
1021
|
+
readonly maxDelayMs?: number;
|
|
1022
|
+
}
|
|
1023
|
+
export type DelegatedServerAuthentication = Readonly<{
|
|
1024
|
+
getAccessToken: () => Promise<string> | string;
|
|
1025
|
+
mode?: "delegated";
|
|
1026
|
+
}>;
|
|
1027
|
+
export type ServiceServerAuthentication<Secret extends ClientSecret = string> = Readonly<{
|
|
1028
|
+
credentials: ConfidentialCredentialProvider<Secret>;
|
|
1029
|
+
mode: "service";
|
|
1030
|
+
}>;
|
|
1031
|
+
export type ServerClientAuthentication<Secret extends ClientSecret = string> = DelegatedServerAuthentication | ServiceServerAuthentication<Secret>;
|
|
1032
|
+
/** `Secret` is a string at `.`; the `./effect` layers also take a `Redacted` one. */
|
|
1033
|
+
export interface ServerClientConfig<Secret extends ClientSecret = string> {
|
|
1034
|
+
readonly auditSubject?: ExternalApplicationExternalAuditSubject;
|
|
1035
|
+
readonly authentication: ServerClientAuthentication<Secret>;
|
|
1036
|
+
readonly createCorrelationId?: () => string;
|
|
1037
|
+
readonly createIdempotencyKey?: () => string;
|
|
1038
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
1039
|
+
readonly retry?: ServerRetryPolicy;
|
|
1040
|
+
readonly sleep?: (milliseconds: number) => Promise<void>;
|
|
1041
|
+
readonly tenantUrl: string;
|
|
1042
|
+
}
|
|
1043
|
+
export interface ServerInvocationContext {
|
|
1044
|
+
readonly auditSubject?: ExternalApplicationExternalAuditSubject;
|
|
1045
|
+
/**
|
|
1046
|
+
* `anonymous_visitor`: this service call is made for the anonymous visitor
|
|
1047
|
+
* `auditSubject` names, who must not map to a CI user. The visitor may only
|
|
1048
|
+
* converse with Agents that admit anonymous visitors of this application.
|
|
1049
|
+
*/
|
|
1050
|
+
readonly callerKind?: "anonymous_visitor";
|
|
1051
|
+
readonly correlationId?: string;
|
|
1052
|
+
readonly organizationId: string;
|
|
1053
|
+
/** Selects a Server Role for this call; omission uses the credential default. */
|
|
1054
|
+
readonly serverRole?: string;
|
|
1055
|
+
readonly signal?: AbortSignal;
|
|
1056
|
+
readonly traceparent?: string;
|
|
1057
|
+
}
|
|
1058
|
+
export type OperationInput<Id extends ExternalApplicationServerOperationId> = ExternalApplicationOperationRequestFor<Id>["input"];
|
|
1059
|
+
export type ManagedInput<Input> = Input extends {
|
|
1060
|
+
idempotencyKey: string;
|
|
1061
|
+
} ? Omit<Input, "idempotencyKey"> & {
|
|
1062
|
+
readonly idempotencyKey?: string;
|
|
1063
|
+
} : Input;
|
|
1064
|
+
export type ManagedOperationInput<Id extends ExternalApplicationServerOperationId> = ManagedInput<OperationInput<Id>>;
|
|
1065
|
+
export type ServerOperationRequest<Id extends ExternalApplicationServerOperationId> = OperationInput<Id> extends Readonly<Record<string, never>> ? ServerInvocationContext : ManagedOperationInput<Id> & ServerInvocationContext;
|
|
1066
|
+
/** The value of an operation that CI accepted. */
|
|
1067
|
+
export type ServerOperationSuccess<Id extends ExternalApplicationServerOperationId> = Extract<ExternalApplicationOperationResult<Id>, {
|
|
1068
|
+
ok: true;
|
|
1069
|
+
}>["value"];
|
|
1070
|
+
/** One message to send; `idempotencyKey` is generated when omitted. */
|
|
1071
|
+
export type ServerMessageSendRequest = Omit<MessageSendInput, "idempotencyKey"> & Readonly<{
|
|
1072
|
+
idempotencyKey?: string;
|
|
1073
|
+
}> & ServerInvocationContext;
|
|
1074
|
+
/** A File upload slot for one File field of an entity schema, named by id or FQN. */
|
|
1075
|
+
export type ServerResourceUploadRequest = EntityUploadInput & Readonly<{
|
|
1076
|
+
schemaId: string;
|
|
1077
|
+
/** Bound on each attempt's request and response body. Defaults to 10 seconds. */
|
|
1078
|
+
timeoutMs?: number;
|
|
1079
|
+
}> & ServerInvocationContext;
|
|
1080
|
+
declare const resourceFailureCodes: readonly [
|
|
1081
|
+
"conflict",
|
|
1082
|
+
"forbidden",
|
|
1083
|
+
"internal",
|
|
1084
|
+
"invalid_request",
|
|
1085
|
+
"not_found",
|
|
1086
|
+
"unauthenticated",
|
|
1087
|
+
"unavailable",
|
|
1088
|
+
"upload_not_supported"
|
|
1089
|
+
];
|
|
1090
|
+
/** Why CI's resources API refused the request. */
|
|
1091
|
+
export type ServerResourceFailure = Readonly<{
|
|
1092
|
+
correlationId: string;
|
|
1093
|
+
error: Readonly<{
|
|
1094
|
+
code: (typeof resourceFailureCodes)[number];
|
|
1095
|
+
details?: Readonly<Record<string, ResourceJsonValue>>;
|
|
1096
|
+
message: string;
|
|
1097
|
+
retryable: boolean;
|
|
1098
|
+
}>;
|
|
1099
|
+
}>;
|
|
1100
|
+
/** PUT the bytes to `result.url` with `result.headers`, then write `{ upload: uploadId }`. */
|
|
1101
|
+
export type ServerResourceUploadResult = Readonly<{
|
|
1102
|
+
error: ServerResourceFailure;
|
|
1103
|
+
ok: false;
|
|
1104
|
+
}> | Readonly<{
|
|
1105
|
+
ok: true;
|
|
1106
|
+
value: Readonly<{
|
|
1107
|
+
correlationId: string;
|
|
1108
|
+
operationId: "resources_create_upload";
|
|
1109
|
+
result: EntityUploadSlot;
|
|
1110
|
+
}>;
|
|
1111
|
+
}>;
|
|
1112
|
+
export type ServerClientValue = Readonly<{
|
|
1113
|
+
/** A File upload slot; a refusal of CI is a value of the result. */
|
|
1114
|
+
createUpload: (request: ServerResourceUploadRequest) => Effect.Effect<ServerResourceUploadResult, CiTransportError>;
|
|
1115
|
+
/** The value of one operation; an Expected Error of CI fails with `CiError`. */
|
|
1116
|
+
execute: <Id extends ExternalApplicationServerOperationId>(operationId: Id, request: ServerOperationRequest<Id>) => Effect.Effect<ServerOperationSuccess<Id>, CiError | CiTransportError>;
|
|
1117
|
+
/** The same call as its result, which keeps the error envelope of CI. */
|
|
1118
|
+
executeResult: <Id extends ExternalApplicationServerOperationId>(operationId: Id, request: ServerOperationRequest<Id>) => Effect.Effect<ExternalApplicationOperationResult<Id>, CiTransportError>;
|
|
1119
|
+
/** Sends one message; a refusal of CI is a value of the result. */
|
|
1120
|
+
sendMessage: (request: ServerMessageSendRequest) => Effect.Effect<MessageSendResult, CiTransportError>;
|
|
1121
|
+
}>;
|
|
1122
|
+
declare const ServerClient_base: Context.ServiceClass<ServerClient, "@collective-intelligence/external-apps-server-sdk/ServerClient", Readonly<{
|
|
1123
|
+
/** A File upload slot; a refusal of CI is a value of the result. */
|
|
1124
|
+
createUpload: (request: ServerResourceUploadRequest) => Effect.Effect<ServerResourceUploadResult, CiTransportError>;
|
|
1125
|
+
/** The value of one operation; an Expected Error of CI fails with `CiError`. */
|
|
1126
|
+
execute: <Id extends ExternalApplicationServerOperationId>(operationId: Id, request: ServerOperationRequest<Id>) => Effect.Effect<ServerOperationSuccess<Id>, CiError | CiTransportError>;
|
|
1127
|
+
/** The same call as its result, which keeps the error envelope of CI. */
|
|
1128
|
+
executeResult: <Id extends ExternalApplicationServerOperationId>(operationId: Id, request: ServerOperationRequest<Id>) => Effect.Effect<ExternalApplicationOperationResult<Id>, CiTransportError>;
|
|
1129
|
+
/** Sends one message; a refusal of CI is a value of the result. */
|
|
1130
|
+
sendMessage: (request: ServerMessageSendRequest) => Effect.Effect<MessageSendResult, CiTransportError>;
|
|
1131
|
+
}>>;
|
|
1132
|
+
declare class ServerClient extends ServerClient_base {
|
|
1133
|
+
}
|
|
1134
|
+
export type GatewayRuntimeKernel = Pick<GatewayKernel, "handle">;
|
|
1135
|
+
export type EffectCrudResourceOptions<Entity, Create, Update, Error, Requirements> = Readonly<{
|
|
1136
|
+
definition: ResourceDefinition<Entity, Create, Update>;
|
|
1137
|
+
authorization: GatewayResourceAuthorization;
|
|
1138
|
+
repository: Effect.Effect<CrudRepository<Entity, Create, Update>, Error, Requirements>;
|
|
1139
|
+
}>;
|
|
1140
|
+
export type ResourceProjectionDiagnostic = Readonly<{
|
|
1141
|
+
code: "unsupported_refinement" | "unsupported_transform" | "unsupported_schema" | ConsumerProfileDiagnostic["code"];
|
|
1142
|
+
location: string;
|
|
1143
|
+
reason: string;
|
|
1144
|
+
}>;
|
|
1145
|
+
export type ResourceSchemaProjection = Readonly<{
|
|
1146
|
+
success: true;
|
|
1147
|
+
schema: JsonSchemaDocument;
|
|
1148
|
+
fidelity: "exact";
|
|
1149
|
+
metadata?: FormMetadata<string>;
|
|
1150
|
+
}> | Readonly<{
|
|
1151
|
+
success: false;
|
|
1152
|
+
diagnostics: readonly ResourceProjectionDiagnostic[];
|
|
1153
|
+
}>;
|
|
1154
|
+
export type GatewayEffectHandler = (request: Request) => Effect.Effect<Response, GatewayEffectRuntimeError>;
|
|
1155
|
+
export type ResourceEffectHandlerOptions<E = never, R = never, Value = unknown, Create = Value, Patch = Partial<Value>> = Omit<ResourceHttpHandlerOptions<Value, Create, Patch>, "authorize"> & Readonly<{
|
|
1156
|
+
authorize: (request: Request, operation: Parameters<ResourceHttpHandlerOptions["authorize"]>[1]) => Effect.Effect<EntityInvocationContext | Response, E, R>;
|
|
1157
|
+
}>;
|
|
1158
|
+
export interface MemberSessionExchangeRequest {
|
|
1159
|
+
readonly credentials: ConfidentialCredentialProvider;
|
|
1160
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
1161
|
+
/** The Organization the member acts in; the application must be allowed in it. */
|
|
1162
|
+
readonly organizationId: string;
|
|
1163
|
+
/** A subset of the application's scopes. */
|
|
1164
|
+
readonly scopes: readonly string[];
|
|
1165
|
+
/** The member's CI session token, for example from `POST /auth/otp/verify`. */
|
|
1166
|
+
readonly sessionToken: string;
|
|
1167
|
+
/** Cancels the exchange; a cancelled exchange rejects with the signal's reason. */
|
|
1168
|
+
readonly signal?: AbortSignal;
|
|
1169
|
+
readonly tenantUrl: string;
|
|
1170
|
+
/** Bound on the request and its response body. Defaults to 10 seconds. */
|
|
1171
|
+
readonly timeoutMs?: number;
|
|
1172
|
+
}
|
|
1173
|
+
export interface MemberAccessToken {
|
|
1174
|
+
readonly accessToken: string;
|
|
1175
|
+
/** When to exchange again: before CI's expiry, which is counted from signing. */
|
|
1176
|
+
readonly expiresAt: Date;
|
|
1177
|
+
}
|
|
1178
|
+
/** `Secret` is a string at `.`; the `./effect` layers also take a `Redacted` one. */
|
|
1179
|
+
export type RunAsApplicationConfig<Secret extends ClientSecret = string> = Readonly<{
|
|
1180
|
+
auditSubject: ExternalApplicationExternalAuditSubject;
|
|
1181
|
+
credentials: ConfidentialCredentials<Secret>;
|
|
1182
|
+
createCorrelationId?: () => string;
|
|
1183
|
+
createIdempotencyKey?: () => string;
|
|
1184
|
+
fetch?: typeof globalThis.fetch;
|
|
1185
|
+
retry?: ServerRetryPolicy;
|
|
1186
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
1187
|
+
tenantUrl: string;
|
|
1188
|
+
}>;
|
|
1189
|
+
export type CiEntitiesOptions = Readonly<{
|
|
1190
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
1191
|
+
organizationId: string;
|
|
1192
|
+
tenantUrl: string;
|
|
1193
|
+
}>;
|
|
1194
|
+
/**
|
|
1195
|
+
* One CI entity schema, the Resource Definition that maps it, and the entity
|
|
1196
|
+
* protocol of that definition: `createEntityProtocol(definition)` of the
|
|
1197
|
+
* client SDK, made once for the binding.
|
|
1198
|
+
*/
|
|
1199
|
+
export type CiEntityBinding<Value, Create = Value, Patch = Partial<Value>> = Readonly<{
|
|
1200
|
+
definition: ResourceDefinition<Value, Create, Patch>;
|
|
1201
|
+
protocol: EntityProtocol<Value, Create, Patch>;
|
|
1202
|
+
schemaFqn: string;
|
|
1203
|
+
}>;
|
|
1204
|
+
export type EntityResult<Value> = EntityOperationResult<Value, EntityOperation>;
|
|
1205
|
+
export type CiEntitiesValue = Readonly<{
|
|
1206
|
+
/** The result of one entity request; it fails with `CiError` or `CiTransportError`. */
|
|
1207
|
+
execute: <Value, Create, Patch>(binding: CiEntityBinding<Value, Create, Patch>, request: EntityRequest<Create, Patch>, context: EntityInvocationContext) => Effect.Effect<EntityResult<Value>, CiError | CiTransportError>;
|
|
1208
|
+
/** The same call as its `ResourceResult`; every failure is a value. */
|
|
1209
|
+
executeResult: <Value, Create, Patch>(binding: CiEntityBinding<Value, Create, Patch>, request: EntityRequest<Create, Patch>, context: EntityInvocationContext, options?: Readonly<{
|
|
1210
|
+
signal?: AbortSignal;
|
|
1211
|
+
}>) => Effect.Effect<ResourceResult<EntityResult<Value>>>;
|
|
1212
|
+
}>;
|
|
1213
|
+
declare const CiEntities_base: Context.ServiceClass<CiEntities, "@collective-intelligence/external-apps-server-sdk/CiEntities", Readonly<{
|
|
1214
|
+
/** The result of one entity request; it fails with `CiError` or `CiTransportError`. */
|
|
1215
|
+
execute: <Value, Create, Patch>(binding: CiEntityBinding<Value, Create, Patch>, request: EntityRequest<Create, Patch>, context: EntityInvocationContext) => Effect.Effect<EntityResult<Value>, CiError | CiTransportError>;
|
|
1216
|
+
/** The same call as its `ResourceResult`; every failure is a value. */
|
|
1217
|
+
executeResult: <Value, Create, Patch>(binding: CiEntityBinding<Value, Create, Patch>, request: EntityRequest<Create, Patch>, context: EntityInvocationContext, options?: Readonly<{
|
|
1218
|
+
signal?: AbortSignal;
|
|
1219
|
+
}>) => Effect.Effect<ResourceResult<EntityResult<Value>>>;
|
|
1220
|
+
}>>;
|
|
1221
|
+
declare class CiEntities extends CiEntities_base {
|
|
1222
|
+
}
|
|
1223
|
+
/** One file of a File field, as every CI read surface returns it. */
|
|
1224
|
+
export declare const EntityFileValue: Schema.Struct<{
|
|
1225
|
+
readonly filename: Schema.String;
|
|
1226
|
+
readonly id: Schema.String;
|
|
1227
|
+
readonly mimeType: Schema.NullOr<Schema.String>;
|
|
1228
|
+
readonly size: Schema.NullOr<Schema.Int>;
|
|
1229
|
+
readonly source: Schema.Literals<readonly [
|
|
1230
|
+
"managed",
|
|
1231
|
+
"external_url"
|
|
1232
|
+
]>;
|
|
1233
|
+
readonly url: Schema.String;
|
|
1234
|
+
}>;
|
|
1235
|
+
export type EntityFileValue = typeof EntityFileValue.Type;
|
|
1236
|
+
/**
|
|
1237
|
+
* One file of a File field write: `{ upload }` adds the File upload of an
|
|
1238
|
+
* upload slot's `uploadId`; `{ id }` keeps a file, so a File value read before
|
|
1239
|
+
* decodes as the file it names.
|
|
1240
|
+
*/
|
|
1241
|
+
export declare const EntityFileWrite: Schema.Union<readonly [
|
|
1242
|
+
Schema.Struct<{
|
|
1243
|
+
readonly id: Schema.optionalKey<Schema.Never>;
|
|
1244
|
+
readonly upload: Schema.String;
|
|
1245
|
+
}>,
|
|
1246
|
+
Schema.Struct<{
|
|
1247
|
+
readonly id: Schema.String;
|
|
1248
|
+
readonly upload: Schema.optionalKey<Schema.Never>;
|
|
1249
|
+
}>
|
|
1250
|
+
]>;
|
|
1251
|
+
export type EntityFileWrite = typeof EntityFileWrite.Type;
|
|
1252
|
+
/**
|
|
1253
|
+
* The write form of a File field key: one file or `null` for a single field,
|
|
1254
|
+
* an ordered array for a multiple field; `null` removes every file. Omit the
|
|
1255
|
+
* key to keep its files unchanged.
|
|
1256
|
+
*/
|
|
1257
|
+
export declare const EntityFileFieldWrite: Schema.NullOr<Schema.Union<readonly [
|
|
1258
|
+
Schema.Union<readonly [
|
|
1259
|
+
Schema.Struct<{
|
|
1260
|
+
readonly id: Schema.optionalKey<Schema.Never>;
|
|
1261
|
+
readonly upload: Schema.String;
|
|
1262
|
+
}>,
|
|
1263
|
+
Schema.Struct<{
|
|
1264
|
+
readonly id: Schema.String;
|
|
1265
|
+
readonly upload: Schema.optionalKey<Schema.Never>;
|
|
1266
|
+
}>
|
|
1267
|
+
]>,
|
|
1268
|
+
Schema.$Array<Schema.Union<readonly [
|
|
1269
|
+
Schema.Struct<{
|
|
1270
|
+
readonly id: Schema.optionalKey<Schema.Never>;
|
|
1271
|
+
readonly upload: Schema.String;
|
|
1272
|
+
}>,
|
|
1273
|
+
Schema.Struct<{
|
|
1274
|
+
readonly id: Schema.String;
|
|
1275
|
+
readonly upload: Schema.optionalKey<Schema.Never>;
|
|
1276
|
+
}>
|
|
1277
|
+
]>>
|
|
1278
|
+
]>>;
|
|
1279
|
+
export type EntityFileFieldWrite = typeof EntityFileFieldWrite.Type;
|
|
1280
|
+
declare const CiError$1: typeof CiError;
|
|
1281
|
+
type CiError$1 = CiError;
|
|
1282
|
+
declare const CiErrorCode$1: import("effect/Schema").Literals<readonly [
|
|
1283
|
+
"unauthenticated",
|
|
1284
|
+
"forbidden",
|
|
1285
|
+
"not_found",
|
|
1286
|
+
"conflict",
|
|
1287
|
+
"invalid_request",
|
|
1288
|
+
"rate_limited",
|
|
1289
|
+
"unavailable",
|
|
1290
|
+
"internal"
|
|
1291
|
+
]>;
|
|
1292
|
+
type CiErrorCode$1 = CiErrorCode;
|
|
1293
|
+
declare const CiTransportError$1: typeof CiTransportError;
|
|
1294
|
+
type CiTransportError$1 = CiTransportError;
|
|
1295
|
+
declare const FederatedAuthError$1: typeof FederatedAuthError;
|
|
1296
|
+
type FederatedAuthError$1 = FederatedAuthError;
|
|
1297
|
+
declare const FederatedAuthErrorCode$1: import("effect/Schema").Literals<readonly [
|
|
1298
|
+
"configuration_error",
|
|
1299
|
+
"invalid_return_target",
|
|
1300
|
+
"invalid_callback",
|
|
1301
|
+
"invalid_state",
|
|
1302
|
+
"transaction_expired",
|
|
1303
|
+
"authorization_failed",
|
|
1304
|
+
"token_exchange_failed",
|
|
1305
|
+
"reauthorization_required"
|
|
1306
|
+
]>;
|
|
1307
|
+
type FederatedAuthErrorCode$1 = FederatedAuthErrorCode;
|
|
1308
|
+
declare const GatewayEffectRuntimeError$1: typeof GatewayEffectRuntimeError;
|
|
1309
|
+
type GatewayEffectRuntimeError$1 = GatewayEffectRuntimeError;
|
|
1310
|
+
declare const MemberSessionExchangeError$1: typeof MemberSessionExchangeError;
|
|
1311
|
+
type MemberSessionExchangeError$1 = MemberSessionExchangeError;
|
|
1312
|
+
declare const ServerClient$1: typeof ServerClient;
|
|
1313
|
+
type ServerClient$1 = ServerClient;
|
|
1314
|
+
export declare const layerServerClient: (config: ServerClientConfig<ClientSecret>) => import("effect/Layer").Layer<ServerClient, never, never>;
|
|
1315
|
+
export declare const layerServerClientConfig: (config: import("effect/Config").Wrap<ServerClientConfig<import("effect/Redacted").Redacted<string>>>) => import("effect/Layer").Layer<ServerClient, import("effect/Config").ConfigError, never>;
|
|
1316
|
+
export declare const layerApplicationServerClient: (config: RunAsApplicationConfig<ClientSecret>) => import("effect/Layer").Layer<ServerClient, never, never>;
|
|
1317
|
+
export declare const layerApplicationServerClientConfig: (config: import("effect/Config").Wrap<RunAsApplicationConfig<import("effect/Redacted").Redacted<string>>>) => import("effect/Layer").Layer<ServerClient, import("effect/Config").ConfigError, never>;
|
|
1318
|
+
export declare const exchangeMemberSession: (request: MemberSessionExchangeRequest) => import("effect/Effect").Effect<MemberAccessToken, MemberSessionExchangeError, never>;
|
|
1319
|
+
declare const CiEntities$1: typeof CiEntities;
|
|
1320
|
+
type CiEntities$1 = CiEntities;
|
|
1321
|
+
export declare const layerCiEntities: (options: CiEntitiesOptions) => import("effect/Layer").Layer<CiEntities, never, never>;
|
|
1322
|
+
export declare const layerCiEntitiesConfig: (config: import("effect/Config").Wrap<CiEntitiesOptions>) => import("effect/Layer").Layer<CiEntities, import("effect/Config").ConfigError, never>;
|
|
1323
|
+
export declare const DateTimeString: import("effect/Schema").String;
|
|
1324
|
+
export declare const jsonSchema: (schema: import("effect/Schema").Top) => import("@collective-intelligence/extensions-sdk").JsonSchemaDocument;
|
|
1325
|
+
export declare const projectResourceSchema: (schema: import("effect/Schema").Top, metadata?: import("@collective-intelligence/extensions-sdk").FormMetadata<string>) => ResourceSchemaProjection;
|
|
1326
|
+
export declare const UuidV7: import("effect/Schema").String;
|
|
1327
|
+
export declare const uuidV7: () => string;
|
|
1328
|
+
export declare const createGatewayEffectHandler: (kernel: GatewayRuntimeKernel) => GatewayEffectHandler;
|
|
1329
|
+
export declare const createResourceEffectHandler: <E, R, Value = unknown, Create = Value, Patch = Partial<Value>>(options: ResourceEffectHandlerOptions<E, R, Value, Create, Patch>) => (request: Request) => import("effect/Effect").Effect<Response, GatewayEffectRuntimeError | E, R>;
|
|
1330
|
+
export declare const makeEffectCrudResource: <Entity, Create = Entity, Update = Partial<Entity>, Error = never, Requirements = never>(options: EffectCrudResourceOptions<Entity, Create, Update, Error, Requirements>) => import("effect/Effect").Effect<CrudResource<Entity, Create, Update>, Error, Requirements>;
|
|
1331
|
+
declare const DrizzlePostgres$1: typeof DrizzlePostgres;
|
|
1332
|
+
type DrizzlePostgres$1 = DrizzlePostgres;
|
|
1333
|
+
declare const DrizzlePostgresInitializationError$1: typeof DrizzlePostgresInitializationError;
|
|
1334
|
+
type DrizzlePostgresInitializationError$1 = DrizzlePostgresInitializationError;
|
|
1335
|
+
export declare const layerFromDatabase: (value: DrizzlePostgresValue) => import("effect/Layer").Layer<DrizzlePostgres, never, never>;
|
|
1336
|
+
export declare const layerNodePostgres: (options: NodePostgresLayerOptions) => import("effect/Layer").Layer<DrizzlePostgres, DrizzlePostgresInitializationError, never>;
|
|
1337
|
+
|
|
1338
|
+
export {
|
|
1339
|
+
CiEntities$1 as CiEntities,
|
|
1340
|
+
CiError$1 as CiError,
|
|
1341
|
+
CiErrorCode$1 as CiErrorCode,
|
|
1342
|
+
CiTransportError$1 as CiTransportError,
|
|
1343
|
+
DrizzlePostgres$1 as DrizzlePostgres,
|
|
1344
|
+
DrizzlePostgresInitializationError$1 as DrizzlePostgresInitializationError,
|
|
1345
|
+
FederatedAuthError$1 as FederatedAuthError,
|
|
1346
|
+
FederatedAuthErrorCode$1 as FederatedAuthErrorCode,
|
|
1347
|
+
GatewayEffectRuntimeError$1 as GatewayEffectRuntimeError,
|
|
1348
|
+
MemberSessionExchangeError$1 as MemberSessionExchangeError,
|
|
1349
|
+
ServerClient$1 as ServerClient,
|
|
1350
|
+
};
|
|
1351
|
+
|
|
3
1352
|
export {};
|