@collective-intelligence/external-apps-server-sdk 0.0.0-stage → 0.1.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.
Files changed (40) hide show
  1. package/README.md +1075 -2
  2. package/dist/admin.d.ts +7556 -0
  3. package/dist/admin.js +6 -0
  4. package/dist/auth/better-auth.d.ts +71 -0
  5. package/dist/auth/better-auth.js +1 -0
  6. package/dist/auth/federated.d.ts +135 -0
  7. package/dist/auth/federated.js +8 -0
  8. package/dist/auth.d.ts +162 -0
  9. package/dist/auth.js +1 -0
  10. package/dist/express.d.ts +644 -0
  11. package/dist/express.js +1 -0
  12. package/dist/gateway/contracts.d.ts +663 -0
  13. package/dist/gateway/contracts.js +0 -0
  14. package/dist/gateway.d.ts +762 -0
  15. package/dist/gateway.js +8 -0
  16. package/dist/index.d.ts +597 -0
  17. package/dist/index.js +9 -0
  18. package/dist/knowledge-sources/payload.d.ts +420 -0
  19. package/dist/knowledge-sources/payload.js +1 -0
  20. package/dist/knowledge-sources/strapi.d.ts +389 -0
  21. package/dist/knowledge-sources/strapi.js +1 -0
  22. package/dist/persistence/drizzle-effect.d.ts +38 -0
  23. package/dist/persistence/drizzle-effect.js +1 -0
  24. package/dist/persistence/drizzle.d.ts +1514 -0
  25. package/dist/persistence/drizzle.js +18 -0
  26. package/dist/resources.d.ts +423 -0
  27. package/dist/resources.js +15 -0
  28. package/dist/runtime/effect.d.ts +954 -0
  29. package/dist/runtime/effect.js +15 -0
  30. package/dist/runtime/express.d.ts +644 -0
  31. package/dist/runtime/express.js +1 -0
  32. package/dist/runtime/nestjs.d.ts +802 -0
  33. package/dist/runtime/nestjs.js +8 -0
  34. package/dist/runtime/next.d.ts +874 -0
  35. package/dist/runtime/next.js +8 -0
  36. package/dist/runtime/web.d.ts +776 -0
  37. package/dist/runtime/web.js +8 -0
  38. package/dist/tools/ai-sdk.d.ts +170 -0
  39. package/dist/tools/ai-sdk.js +8 -0
  40. package/package.json +242 -4
@@ -0,0 +1,644 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { RequestHandler } from 'express';
4
+
5
+ export type PrincipalKind = "detached_user" | "service_principal";
6
+ export type DelegatedSubjectPolicy = "allowed" | "forbidden" | "required";
7
+ export type AuthorizationRequirement = Readonly<{
8
+ delegatedSubject?: DelegatedSubjectPolicy;
9
+ organization: "required";
10
+ principalKinds: readonly PrincipalKind[];
11
+ scopes: readonly string[];
12
+ }>;
13
+ export type ExternalAuditSubject = Readonly<{
14
+ issuer: string;
15
+ mappedCiUserId?: string;
16
+ subject: string;
17
+ }>;
18
+ export type GatewayCallerIdentity = Readonly<{
19
+ audience: readonly string[];
20
+ binding: string;
21
+ expiresAt: number;
22
+ installationId: string;
23
+ issuer: string;
24
+ organizationId: string;
25
+ principalKind: PrincipalKind;
26
+ requestId: string;
27
+ scopes: readonly string[];
28
+ subject: string;
29
+ }>;
30
+ export type GatewayInvocationContext = Readonly<{
31
+ caller: GatewayCallerIdentity;
32
+ correlationId: string;
33
+ externalAuditSubject?: ExternalAuditSubject;
34
+ organizationId: string;
35
+ }>;
36
+ export type JsonPrimitive = boolean | null | number | string;
37
+ export type JsonValue = JsonObject | JsonPrimitive | readonly JsonValue[];
38
+ export interface JsonObject {
39
+ readonly [key: string]: JsonValue;
40
+ }
41
+ declare const Draft202012Dialect: "https://json-schema.org/draft/2020-12/schema";
42
+ /** JSON-compatible Draft 2020-12 vocabulary used for portable manifests. */
43
+ export type JsonSchemaDocument = JsonObject & Readonly<{
44
+ $anchor?: string;
45
+ $comment?: string;
46
+ $defs?: Readonly<Record<string, JsonSchemaDocument>>;
47
+ $dynamicAnchor?: string;
48
+ $dynamicRef?: string;
49
+ $id?: string;
50
+ $ref?: string;
51
+ $schema?: typeof Draft202012Dialect;
52
+ additionalProperties?: boolean | JsonSchemaDocument;
53
+ allOf?: readonly JsonSchemaDocument[];
54
+ anyOf?: readonly JsonSchemaDocument[];
55
+ const?: JsonValue;
56
+ contains?: JsonSchemaDocument;
57
+ default?: JsonValue;
58
+ dependentRequired?: Readonly<Record<string, readonly string[]>>;
59
+ description?: string;
60
+ else?: JsonSchemaDocument;
61
+ enum?: readonly JsonValue[];
62
+ exclusiveMaximum?: number;
63
+ exclusiveMinimum?: number;
64
+ format?: string;
65
+ if?: JsonSchemaDocument;
66
+ items?: JsonSchemaDocument;
67
+ maxItems?: number;
68
+ maxLength?: number;
69
+ maxProperties?: number;
70
+ maximum?: number;
71
+ minItems?: number;
72
+ minLength?: number;
73
+ minProperties?: number;
74
+ minimum?: number;
75
+ multipleOf?: number;
76
+ not?: JsonSchemaDocument;
77
+ oneOf?: readonly JsonSchemaDocument[];
78
+ pattern?: string;
79
+ patternProperties?: Readonly<Record<string, JsonSchemaDocument>>;
80
+ prefixItems?: readonly JsonSchemaDocument[];
81
+ properties?: Readonly<Record<string, JsonSchemaDocument>>;
82
+ required?: readonly string[];
83
+ then?: JsonSchemaDocument;
84
+ title?: string;
85
+ type?: "array" | "boolean" | "integer" | "null" | "number" | "object" | "string" | readonly ("array" | "boolean" | "integer" | "null" | "number" | "object" | "string")[];
86
+ unevaluatedItems?: boolean | JsonSchemaDocument;
87
+ unevaluatedProperties?: boolean | JsonSchemaDocument;
88
+ uniqueItems?: boolean;
89
+ }>;
90
+ export type ProjectionFidelity = "exact" | "structural";
91
+ export type PackageSchemaProjection = Readonly<{
92
+ dialect: typeof Draft202012Dialect;
93
+ document: JsonSchemaDocument;
94
+ fidelity: ProjectionFidelity;
95
+ }>;
96
+ /** Closed public principal vocabulary accepted by a gateway operation. */
97
+ export type PortableOperationPrincipalKind = "detached_user" | "service_principal";
98
+ /** Explicit delegated-subject requirement reviewed with an operation. */
99
+ export type PortableOperationDelegatedSubjectPolicy = "allowed" | "forbidden" | "required";
100
+ /** Fully materialized authorization policy for one exposed operation. */
101
+ export type PortableOperationAuthorization = Readonly<{
102
+ delegatedSubject: PortableOperationDelegatedSubjectPolicy;
103
+ organization: "required";
104
+ principalKinds: readonly PortableOperationPrincipalKind[];
105
+ scopes: readonly string[];
106
+ }>;
107
+ /** Observable side-effect class reviewed before an operation becomes a tool. */
108
+ export type PortableOperationEffect = "external_side_effect" | "read" | "write";
109
+ /** The replay guarantee supplied by the operation implementation. */
110
+ export type PortableOperationIdempotency = "idempotent" | "requires_key" | "safe";
111
+ /** Explicit, bounded retry permission for callers of the operation. */
112
+ export type PortableOperationRetryPolicy = Readonly<{
113
+ mode: "never";
114
+ }> | Readonly<{
115
+ maxAttempts: number;
116
+ mode: "idempotent_only";
117
+ }>;
118
+ /** Execution lifecycle and maximum wall-clock duration. */
119
+ export type PortableOperationExecutionPolicy = Readonly<{
120
+ mode: "synchronous";
121
+ timeoutMs: number;
122
+ }>;
123
+ /** Per-invocation transport bounds. */
124
+ export type PortableOperationLimits = Readonly<{
125
+ maxRequestBytes: number;
126
+ maxResponseBytes: number;
127
+ }>;
128
+ /**
129
+ * Complete JSON-only operation contract reviewed by a host. Executable
130
+ * handlers remain in a server runtime sidecar and never enter this descriptor.
131
+ */
132
+ export type PortableOperationDeclaration = Readonly<{
133
+ authorization: PortableOperationAuthorization;
134
+ description: string;
135
+ effects: PortableOperationEffect;
136
+ execution: PortableOperationExecutionPolicy;
137
+ id: string;
138
+ idempotency: PortableOperationIdempotency;
139
+ input: PackageSchemaProjection;
140
+ limits: PortableOperationLimits;
141
+ output: PackageSchemaProjection;
142
+ retry: PortableOperationRetryPolicy;
143
+ title: string;
144
+ version: string;
145
+ }>;
146
+ /** One catalog and identity namespace for an ordered operation list. */
147
+ export type OperationDomainDeclaration<Operation extends PortableOperationDeclaration = PortableOperationDeclaration> = Readonly<{
148
+ description?: string;
149
+ displayOrder?: number;
150
+ icon?: string;
151
+ id: string;
152
+ operations: readonly Operation[];
153
+ tags?: readonly string[];
154
+ title: string;
155
+ }>;
156
+ export type DatasetProviderResult<Value> = Readonly<{
157
+ status: "success";
158
+ value: Value;
159
+ }> | Readonly<{
160
+ status: "failure";
161
+ error: DatasetProviderError;
162
+ }>;
163
+ export type DatasetScalarType = "boolean" | "string" | "int64" | "float64" | "decimal" | "date" | "timestamp" | "duration" | "json";
164
+ export type DatasetValue = Readonly<{
165
+ kind: "null";
166
+ }> | Readonly<{
167
+ kind: "boolean";
168
+ value: boolean;
169
+ }> | Readonly<{
170
+ kind: "string";
171
+ value: string;
172
+ }> | Readonly<{
173
+ kind: "int64";
174
+ value: string;
175
+ }> | Readonly<{
176
+ kind: "float64";
177
+ value: number;
178
+ }> | Readonly<{
179
+ kind: "decimal";
180
+ value: string;
181
+ }> | Readonly<{
182
+ kind: "date";
183
+ value: string;
184
+ }> | Readonly<{
185
+ kind: "timestamp";
186
+ value: string;
187
+ }> | Readonly<{
188
+ kind: "duration";
189
+ value: string;
190
+ }> | Readonly<{
191
+ kind: "json";
192
+ value: JsonValue;
193
+ }>;
194
+ export type DatasetPredicateOperator = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "is_null" | "is_not_null" | "contains" | "starts_with";
195
+ export type DatasetAggregateOperation = "count" | "count_distinct" | "sum" | "min" | "max" | "avg";
196
+ export type DatasetQueryIntent = "records" | "aggregate" | "time_series";
197
+ export type DatasetTimeBucket = "hour" | "day" | "week" | "month";
198
+ export type DatasetPredicate = Readonly<{
199
+ kind: "predicate";
200
+ fieldId: string;
201
+ operator: DatasetPredicateOperator;
202
+ values: readonly DatasetValue[];
203
+ }>;
204
+ export type DatasetFilter = DatasetPredicate | Readonly<{
205
+ kind: "and" | "or";
206
+ filters: readonly DatasetFilter[];
207
+ }> | Readonly<{
208
+ kind: "not";
209
+ filter: DatasetFilter;
210
+ }>;
211
+ export type DatasetOrder = Readonly<{
212
+ fieldOrAlias: string;
213
+ direction: "asc" | "desc";
214
+ }>;
215
+ export type DatasetOperation = Readonly<{
216
+ kind: "records";
217
+ projection: readonly string[];
218
+ filter?: DatasetFilter;
219
+ orderBy: readonly DatasetOrder[];
220
+ cursor?: string;
221
+ }> | Readonly<{
222
+ kind: "aggregate";
223
+ filter?: DatasetFilter;
224
+ groupBy: readonly string[];
225
+ measures: readonly Readonly<{
226
+ alias: string;
227
+ operation: DatasetAggregateOperation;
228
+ fieldId?: string;
229
+ }>[];
230
+ orderBy: readonly DatasetOrder[];
231
+ cursor?: string;
232
+ }> | Readonly<{
233
+ kind: "time_series";
234
+ timeFieldId: string;
235
+ measure: Readonly<{
236
+ alias: string;
237
+ operation: DatasetAggregateOperation;
238
+ fieldId?: string;
239
+ }>;
240
+ bucket: DatasetTimeBucket;
241
+ order: "asc" | "desc";
242
+ filter?: DatasetFilter;
243
+ cursor?: string;
244
+ }>;
245
+ export type DatasetProviderCapabilities = Readonly<{
246
+ intents: readonly DatasetQueryIntent[];
247
+ predicates: readonly DatasetPredicateOperator[];
248
+ aggregates: readonly DatasetAggregateOperation[];
249
+ grouping: boolean;
250
+ ordering: boolean;
251
+ pagination: boolean;
252
+ definitionRefresh: boolean;
253
+ limits: Readonly<{
254
+ maxRows: number;
255
+ maxBytes: number;
256
+ timeoutMs: number;
257
+ maxPageRows: number;
258
+ }>;
259
+ }>;
260
+ export type SafeDiagnostic = Readonly<{
261
+ code: string;
262
+ message: string;
263
+ fieldId?: string;
264
+ }>;
265
+ export type ConnectorContext = Readonly<{
266
+ correlationId: string;
267
+ deadlineEpochMs: number;
268
+ }>;
269
+ export type DatasetSourceLocation = Readonly<{
270
+ segments: readonly [
271
+ Readonly<{
272
+ kind: "container";
273
+ opaqueId: string;
274
+ label: string;
275
+ }>,
276
+ ...Readonly<{
277
+ kind: "container" | "dataset";
278
+ opaqueId: string;
279
+ label: string;
280
+ }>[]
281
+ ];
282
+ }>;
283
+ export type DatasetDefinition = Readonly<{
284
+ version: 1;
285
+ fields: readonly Readonly<{
286
+ id: string;
287
+ name: string;
288
+ type: DatasetScalarType;
289
+ nullable: boolean;
290
+ semantic?: string;
291
+ }>[];
292
+ measures: readonly Readonly<{
293
+ id: string;
294
+ name: string;
295
+ resultType: DatasetScalarType;
296
+ }>[];
297
+ relationships: readonly Readonly<{
298
+ id: string;
299
+ fromFieldId: string;
300
+ toFieldId: string;
301
+ cardinality: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many";
302
+ }>[];
303
+ }>;
304
+ export type Bounds = Readonly<{
305
+ maxRows: number;
306
+ maxBytes: number;
307
+ timeoutMs: number;
308
+ }>;
309
+ export type QueryInput = ConnectorContext & Readonly<{
310
+ location: DatasetSourceLocation;
311
+ definitionRevisionId: string;
312
+ definition: DatasetDefinition;
313
+ operation: DatasetOperation;
314
+ bounds: Bounds;
315
+ }>;
316
+ export type DatasetRecordPage = Readonly<{
317
+ columns: readonly Readonly<{
318
+ fieldId: string;
319
+ type: DatasetScalarType;
320
+ }>[];
321
+ rows: readonly (readonly DatasetValue[])[];
322
+ nextCursor?: string;
323
+ rowCount: number;
324
+ byteCount: number;
325
+ observedAt: string;
326
+ }>;
327
+ export type DatasetResultPage = (Readonly<{
328
+ kind: "records";
329
+ }> & DatasetRecordPage) | Readonly<{
330
+ kind: "aggregate";
331
+ columns: readonly Readonly<{
332
+ alias: string;
333
+ type: DatasetScalarType;
334
+ }>[];
335
+ rows: readonly (readonly DatasetValue[])[];
336
+ nextCursor?: string;
337
+ rowCount: number;
338
+ byteCount: number;
339
+ observedAt: string;
340
+ }> | Readonly<{
341
+ kind: "time_series";
342
+ valueType: DatasetScalarType;
343
+ points: readonly Readonly<{
344
+ time: string;
345
+ value: DatasetValue;
346
+ }>[];
347
+ nextCursor?: string;
348
+ pointCount: number;
349
+ byteCount: number;
350
+ observedAt: string;
351
+ }>;
352
+ export type DatasetProviderError = Readonly<{
353
+ kind: "not_ready" | "incompatible_source" | "unsupported_operation" | "policy_not_pushable" | "invalid_cursor" | "timeout" | "permission_denied" | "provider_unavailable" | "provider_rejected" | "invalid_provider_response";
354
+ diagnostics: readonly SafeDiagnostic[];
355
+ }> | Readonly<{
356
+ kind: "limit_exceeded";
357
+ limit: "rows" | "bytes" | "timeout";
358
+ diagnostics: readonly SafeDiagnostic[];
359
+ }> | Readonly<{
360
+ kind: "throttled";
361
+ retryAfterMs?: number;
362
+ diagnostics: readonly SafeDiagnostic[];
363
+ }>;
364
+ export type ResourceJsonValue = null | boolean | number | string | readonly ResourceJsonValue[] | Readonly<{
365
+ [key: string]: ResourceJsonValue;
366
+ }>;
367
+ /** Opaque wire identity. Callers must not infer or concatenate its internals. */
368
+ export type ResourceId = string;
369
+ export type ResourceRecordId = ResourceId;
370
+ /** Opaque concurrency token independent from source timestamps. */
371
+ export type ResourceRevision = string;
372
+ /** Opaque pagination position issued and consumed only by a resource adapter. */
373
+ export type ResourceCursor = string;
374
+ export type IdempotencyKey = string;
375
+ export type ResourceIdentityField = Readonly<{
376
+ name: string;
377
+ type: "number" | "string";
378
+ }>;
379
+ export type ResourceCapabilities = Readonly<{
380
+ create?: boolean;
381
+ /** Common entity deletion is always soft deletion. */
382
+ delete?: boolean;
383
+ get?: boolean;
384
+ hardDelete?: boolean;
385
+ includeDeleted?: boolean;
386
+ restore?: boolean;
387
+ search: true;
388
+ softDelete?: boolean;
389
+ update?: boolean;
390
+ }>;
391
+ export type ResourcePaginationMode = "cursor" | "page";
392
+ export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
393
+ export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>> = Readonly<{
394
+ capabilities: ResourceCapabilities;
395
+ concurrency: "revision";
396
+ id: string;
397
+ identity: Readonly<{
398
+ fields: readonly [
399
+ ResourceIdentityField,
400
+ ...ResourceIdentityField[]
401
+ ];
402
+ }>;
403
+ query: Readonly<{
404
+ filterableFields: readonly string[];
405
+ pagination: Readonly<{
406
+ modes: readonly ResourcePaginationMode[];
407
+ }>;
408
+ sortableFields: readonly string[];
409
+ textSearchFields?: readonly string[];
410
+ }>;
411
+ schemas: Readonly<{
412
+ create?: PortableResourceSchema;
413
+ entity: PortableResourceSchema;
414
+ update?: PortableResourceSchema;
415
+ }>;
416
+ version: string;
417
+ /** Portable UI metadata; required/enum/nullability remain in schemas. */
418
+ metadata?: Readonly<Record<string, ResourceJsonValue>>;
419
+ /** Type-only slots keep definition values portable and serializable. */
420
+ readonly __types?: Readonly<{
421
+ create: Create;
422
+ entity: Entity;
423
+ update: Update;
424
+ }>;
425
+ }>;
426
+ export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
427
+ export type ResourceFilter = Readonly<{
428
+ field: string;
429
+ operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
430
+ value: FilterValue;
431
+ }> | Readonly<{
432
+ field: string;
433
+ operator: "is_not_null" | "is_null";
434
+ }> | Readonly<{
435
+ filters: readonly ResourceFilter[];
436
+ operator: "and" | "or";
437
+ }> | Readonly<{
438
+ filter: ResourceFilter;
439
+ operator: "not";
440
+ }>;
441
+ export type ResourceSort = Readonly<{
442
+ direction: "asc" | "desc";
443
+ field: string;
444
+ }>;
445
+ export type ResourcePagination = Readonly<{
446
+ mode: "cursor";
447
+ cursor?: ResourceCursor;
448
+ limit: number;
449
+ }> | Readonly<{
450
+ mode: "page";
451
+ page: number;
452
+ pageSize: number;
453
+ }>;
454
+ export type ResourceListQuery = Readonly<{
455
+ filter?: ResourceFilter;
456
+ includeDeleted?: boolean;
457
+ pagination: ResourcePagination;
458
+ sort?: readonly ResourceSort[];
459
+ textSearch?: string;
460
+ }>;
461
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
462
+ export type ResourceError = Readonly<{
463
+ code: ResourceErrorCode;
464
+ /** Client-observed dispatch outcome; uncertainty never proves rollback. */
465
+ outcome?: "not_dispatched" | "rejected" | "uncertain";
466
+ details?: Readonly<Record<string, ResourceJsonValue>>;
467
+ message: string;
468
+ retryable: boolean;
469
+ }>;
470
+ export type ResourceResult<Value> = Readonly<{
471
+ correlationId: string;
472
+ ok: true;
473
+ value: Value;
474
+ }> | Readonly<{
475
+ correlationId: string;
476
+ error: ResourceError;
477
+ ok: false;
478
+ }>;
479
+ export type ResourceListRequest = Readonly<{
480
+ operation: "list";
481
+ query: ResourceListQuery;
482
+ requestId: string;
483
+ resourceId: string;
484
+ }>;
485
+ export type ResourceGetRequest = Readonly<{
486
+ id: ResourceRecordId;
487
+ includeDeleted?: boolean;
488
+ operation: "get";
489
+ requestId: string;
490
+ resourceId: string;
491
+ }>;
492
+ export type ResourceCreateRequest<Create> = Readonly<{
493
+ idempotencyKey: IdempotencyKey;
494
+ operation: "create";
495
+ requestId: string;
496
+ resourceId: string;
497
+ value: Create;
498
+ }>;
499
+ export type ResourceUpdateRequest<Update> = Readonly<{
500
+ expectedRevision: ResourceRevision;
501
+ id: ResourceRecordId;
502
+ idempotencyKey?: IdempotencyKey;
503
+ operation: "update";
504
+ requestId: string;
505
+ resourceId: string;
506
+ value: Update;
507
+ }>;
508
+ export type ResourceLifecycleRequest = Readonly<{
509
+ expectedRevision: ResourceRevision;
510
+ id: ResourceRecordId;
511
+ idempotencyKey?: IdempotencyKey;
512
+ operation: "hard_delete" | "restore" | "soft_delete";
513
+ requestId: string;
514
+ resourceId: string;
515
+ }>;
516
+ export type ResourceTransportRequest = ResourceCreateRequest<unknown> | ResourceGetRequest | ResourceLifecycleRequest | ResourceListRequest | ResourceUpdateRequest<unknown>;
517
+ /** Full inventory only: no filters, text search or caller-selected ordering.
518
+ * Continue consecutive pages with the first watermark. A conflict requires restart.
519
+ */
520
+ export type ResourceInventoryRequest = Readonly<{
521
+ page: number;
522
+ pageSize: number;
523
+ watermark?: string;
524
+ }>;
525
+ export type GatewayResourceOperation = ResourceTransportRequest["operation"];
526
+ export type GatewayResourceAuthorization = Readonly<Partial<Record<GatewayResourceOperation, AuthorizationRequirement>>>;
527
+ export type GatewayResourceDefinition<Entity = unknown, Create = Entity, Update = Partial<Entity>> = Readonly<{
528
+ authorization: GatewayResourceAuthorization;
529
+ definition: ResourceDefinition<Entity, Create, Update>;
530
+ execute: (request: ResourceTransportRequest, context: GatewayInvocationContext, options?: Readonly<{
531
+ signal?: AbortSignal;
532
+ }>) => Promise<ResourceResult<unknown>>;
533
+ scan?: (request: ResourceInventoryRequest & Readonly<{
534
+ requestId: string;
535
+ resourceId: string;
536
+ }>, context: GatewayInvocationContext, options?: Readonly<{
537
+ signal?: AbortSignal;
538
+ }>) => Promise<ResourceResult<unknown>>;
539
+ changes?: (request: Readonly<{
540
+ cursor?: string;
541
+ limit: number;
542
+ requestId: string;
543
+ resourceId: string;
544
+ }>, context: GatewayInvocationContext, options?: Readonly<{
545
+ signal?: AbortSignal;
546
+ }>) => Promise<ResourceResult<unknown>>;
547
+ }>;
548
+ /**
549
+ * Runtime dispatch validates the declared input schema before invoking a
550
+ * handler. The bivariant call signature lets domains retain heterogeneous,
551
+ * strongly typed handlers while exposing one erased operation collection.
552
+ */
553
+ export type GatewayOperationHandler<Input = unknown, Output = unknown> = {
554
+ bivarianceHack(request: Readonly<{
555
+ context: GatewayInvocationContext;
556
+ /** Validated caller key; the handler owns durable replay storage. */
557
+ idempotencyKey?: string;
558
+ input: Input;
559
+ signal: AbortSignal;
560
+ }>): Promise<Output>;
561
+ }["bivarianceHack"];
562
+ export type GatewayOperationDefinition<Input = unknown, Output = unknown> = Omit<PortableOperationDeclaration, "input" | "output"> & Readonly<{
563
+ handler: GatewayOperationHandler<Input, Output>;
564
+ input: PackageSchemaProjection;
565
+ output: PackageSchemaProjection;
566
+ }>;
567
+ export type GatewayOperationManifest = Omit<GatewayOperationDefinition, "handler"> & Readonly<{
568
+ canonicalReference: string;
569
+ }>;
570
+ export type GatewayOperationDomainDefinition = OperationDomainDeclaration<GatewayOperationDefinition>;
571
+ export type GatewayOperationDomainManifest = OperationDomainDeclaration<GatewayOperationManifest>;
572
+ /** CI destination marker only; source records are shared across all connections. */
573
+ export type OrganizationBinding = Readonly<{
574
+ mode: "installed_organization";
575
+ }>;
576
+ export type GatewayKnowledgeResourceExposure = Readonly<{
577
+ resource: GatewayResourceDefinition;
578
+ access: "read" | "read_write";
579
+ }>;
580
+ export type GatewayDatasetBinding = Readonly<{
581
+ id: string;
582
+ title: string;
583
+ definition: DatasetDefinition;
584
+ authorization: AuthorizationRequirement;
585
+ providerFqn: string;
586
+ query: (input: QueryInput, context: GatewayInvocationContext, options: Readonly<{
587
+ signal: AbortSignal;
588
+ }>) => Promise<DatasetProviderResult<DatasetResultPage>>;
589
+ }>;
590
+ export type GatewayDatasetManifest = Omit<GatewayDatasetBinding, "query"> & Readonly<{
591
+ capabilities: DatasetProviderCapabilities;
592
+ }>;
593
+ export type GatewayDefinitionInput = Readonly<{
594
+ knowledge?: readonly GatewayKnowledgeResourceExposure[];
595
+ datasets?: readonly GatewayDatasetBinding[];
596
+ id: string;
597
+ operationDomains: readonly GatewayOperationDomainDefinition[];
598
+ organizationBinding?: OrganizationBinding;
599
+ protocolVersion?: "2";
600
+ version: string;
601
+ }>;
602
+ export type GatewayManifest = Readonly<{
603
+ capabilities: Readonly<{
604
+ resources: boolean;
605
+ }>;
606
+ datasets: readonly GatewayDatasetManifest[];
607
+ knowledge: readonly Readonly<{
608
+ id: string;
609
+ access: "read" | "read_write";
610
+ definition: GatewayResourceDefinition["definition"];
611
+ fullInventory: boolean;
612
+ incrementalChanges: boolean;
613
+ }>[];
614
+ contentHash: string;
615
+ id: string;
616
+ operationDomains: readonly GatewayOperationDomainManifest[];
617
+ organizationBinding: OrganizationBinding;
618
+ protocolVersion: "2";
619
+ revision: string;
620
+ version: string;
621
+ }>;
622
+ export type GatewayProposal = Readonly<{
623
+ gatewayId: string;
624
+ gatewayVersion: string;
625
+ knowledge: GatewayManifest["knowledge"];
626
+ operationDomains: readonly GatewayOperationDomainManifest[];
627
+ revision: string;
628
+ }>;
629
+ export interface DefinedGateway {
630
+ readonly input: GatewayDefinitionInput;
631
+ readonly resource: (id: string) => GatewayResourceDefinition | undefined;
632
+ readonly dataset: (id: string) => GatewayDatasetBinding | undefined;
633
+ readonly manifest: GatewayManifest;
634
+ readonly proposal: GatewayProposal;
635
+ }
636
+ export interface GatewayKernel {
637
+ readonly handle: (request: Request) => Promise<Response>;
638
+ readonly manifest: DefinedGateway["manifest"];
639
+ }
640
+ export type GatewayRuntimeKernel = Pick<GatewayKernel, "handle">;
641
+ export type ServerSdkExpressMiddleware = RequestHandler;
642
+ export declare const createGatewayExpressMiddleware: (kernel: GatewayRuntimeKernel) => ServerSdkExpressMiddleware, serverSdkExpressEntrypoint: "express";
643
+
644
+ export {};
@@ -0,0 +1 @@
1
+ var __defProp=Object.defineProperty;var __returnValue=(v)=>v;function __exportSetter(name,newValue){this[name]=__returnValue.bind(null,newValue)}var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true,configurable:true,set:__exportSetter.bind(all,name)})};var exports_express={};__export(exports_express,{serverSdkExpressEntrypoint:()=>serverSdkExpressEntrypoint,createGatewayExpressMiddleware:()=>createGatewayExpressMiddleware});var headersFromNode=(input)=>{const headers=new Headers;for(const[name,value]of Object.entries(input)){if(typeof value==="string"){headers.set(name,value)}else if(Array.isArray(value)){headers.set(name,value.join(", "))}}return headers};var nodeChunk=(chunk)=>{if(typeof chunk==="string"){return new TextEncoder().encode(chunk)}return chunk};var bodyFromNode=(request,onBodyCancelled)=>{if(request.body!==undefined){return typeof request.body==="string"?request.body:JSON.stringify(request.body)}const iterator=request.iterator?.({destroyOnReturn:false})??request[Symbol.asyncIterator]?.();if(iterator===undefined){return}return new ReadableStream({cancel:async()=>{onBodyCancelled?.();await iterator.return?.()},pull:async(controller)=>{try{const next=await iterator.next();if(next.done===true){controller.close()}else{controller.enqueue(nodeChunk(next.value))}}catch(error){controller.error(error)}}},{highWaterMark:0})};var webRequestFromNode=async(request,signal,onBodyCancelled)=>{const method=request.method??"GET";const headers=headersFromNode(request.headers);const host=headers.get("host")??"gateway.local";const protocol=request.protocol??"http";const url=new URL(request.originalUrl??request.url??"/",`${protocol}://${host}`);const body=method==="GET"||method==="HEAD"?undefined:bodyFromNode(request,onBodyCancelled);const requestInit={headers,method,signal};if(body!==undefined){requestInit.body=body;requestInit.duplex="half"}return new Request(url,requestInit)};var sendWebResponseToNode=async(response,result)=>{if(response.status===undefined){response.statusCode=result.status}else{response.status(result.status)}for(const[name,value]of result.headers){if(response.setHeader===undefined){response.header?.(name,value)}else{response.setHeader(name,value)}}if(result.body===null){response.end();return}const reader=result.body.getReader();while(true){const next=await reader.read();if(next.done){break}response.write?.(next.value)}response.end()};var handleNodeRequest=async(kernel,request,response)=>{const controller=new AbortController;const onAborted=()=>{controller.abort()};request.once?.("aborted",onAborted);response?.once?.("close",onAborted);try{let bodyCancelled=false;let result=await kernel.handle(await webRequestFromNode(request,controller.signal,()=>{bodyCancelled=true}));if(bodyCancelled){const headers=new Headers(result.headers);headers.set("connection","close");result=new Response(result.body,{headers,status:result.status,statusText:result.statusText})}if(response!==undefined){await sendWebResponseToNode(response,result.clone())}return result}finally{request.off?.("aborted",onAborted);response?.off?.("close",onAborted)}};var createGatewayExpressMiddleware=(kernel)=>(request,response,next)=>{const nodeRequest={[Symbol.asyncIterator]:()=>request[Symbol.asyncIterator](),body:request.body,headers:request.headers,iterator:(options)=>request.iterator(options),method:request.method,off:(event,listener)=>{request.off(event,listener)},once:(event,listener)=>{request.once(event,listener)},originalUrl:request.url,protocol:request.protocol,url:request.url};const nodeResponse={end:(body)=>{response.end(body)},off:(event,listener)=>{response.off(event,listener)},once:(event,listener)=>{response.once(event,listener)},setHeader:(name,value)=>{response.setHeader(name,value)},status:(status)=>{response.status(status);return nodeResponse},write:(body)=>{response.write(body)}};(async()=>{try{await handleNodeRequest(kernel,nodeRequest,nodeResponse)}catch(error){next(error)}})()};var serverSdkExpressEntrypoint="express";var{createGatewayExpressMiddleware:createGatewayExpressMiddleware2,serverSdkExpressEntrypoint:serverSdkExpressEntrypoint2}=exports_express;export{serverSdkExpressEntrypoint2 as serverSdkExpressEntrypoint,createGatewayExpressMiddleware2 as createGatewayExpressMiddleware};