@collective-intelligence/external-apps-server-sdk 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -3,6 +3,19 @@
3
3
  export type ResourceJsonValue = null | boolean | number | string | readonly ResourceJsonValue[] | Readonly<{
4
4
  [key: string]: ResourceJsonValue;
5
5
  }>;
6
+ /** A File upload request for one File field of the entity schema. */
7
+ export type EntityUploadInput = Readonly<{
8
+ field: string;
9
+ filename: string;
10
+ mimeType: string;
11
+ }>;
12
+ /** PUT the file bytes to `url` with `headers`; then write `{ upload: uploadId }`. */
13
+ export type EntityUploadSlot = Readonly<{
14
+ headers: Readonly<Record<string, string>>;
15
+ method: "PUT";
16
+ uploadId: string;
17
+ url: string;
18
+ }>;
6
19
  export type ExternalApplicationsGetContextErrors = {
7
20
  /**
8
21
  * Error
@@ -415,7 +428,25 @@ interface MemberUserPage {
415
428
  pageSize: number;
416
429
  totalItems: number;
417
430
  }
431
+ declare const storageFileIdBrand: unique symbol;
432
+ /** A durable private file of the application's Organization. */
433
+ type StorageFileId = string & Readonly<{
434
+ [storageFileIdBrand]: "StorageFileId";
435
+ }>;
436
+ /**
437
+ * One file of up to 10 MiB, base64-encoded. CI accepts the content types
438
+ * `application/pdf`, `image/jpeg` and `image/png`.
439
+ */
440
+ interface DurableFileUpload {
441
+ contentBase64: string;
442
+ contentType: string;
443
+ fileName: string;
444
+ sizeBytes: number;
445
+ }
418
446
  export type ExternalApplicationServiceOperationRequest = {
447
+ input: DurableFileUpload;
448
+ operationId: "files_upload";
449
+ } | {
419
450
  input: {
420
451
  email: string;
421
452
  name: string;
@@ -443,6 +474,11 @@ export type ExternalApplicationServiceOperationRequest = {
443
474
  userId: string;
444
475
  };
445
476
  operationId: "members_remove";
477
+ } | {
478
+ input: {
479
+ origin: string;
480
+ };
481
+ operationId: "origins_set_runtime";
446
482
  } | {
447
483
  input: {
448
484
  userId: string;
@@ -459,10 +495,14 @@ export type ExternalApplicationServiceOperationRequest = {
459
495
  export interface UserCompanyLinks {
460
496
  entityIds: string[];
461
497
  }
462
- export type ExternalApplicationServiceOperationSuccess = EnvelopeSuccess<"members_create_or_get", MemberUser & {
498
+ export type ExternalApplicationServiceOperationSuccess = EnvelopeSuccess<"files_upload", {
499
+ storageFileId: StorageFileId;
500
+ }> | EnvelopeSuccess<"members_create_or_get", MemberUser & {
463
501
  outcome: MemberUserResolution;
464
502
  }> | EnvelopeSuccess<"members_get", MemberUser> | EnvelopeSuccess<"members_list", MemberUserPage> | EnvelopeSuccess<"members_update", MemberUser> | EnvelopeSuccess<"members_remove", {
465
503
  userId: string;
504
+ }> | EnvelopeSuccess<"origins_set_runtime", {
505
+ origin: string;
466
506
  }> | EnvelopeSuccess<"users_list_company_links", UserCompanyLinks> | EnvelopeSuccess<"users_link_companies", UserCompanyLinks>;
467
507
  /** Every operation a confidential server client may invoke. */
468
508
  export type ExternalApplicationServerOperationRequest = ExternalApplicationOperationRequest | ExternalApplicationServiceOperationRequest;
@@ -649,6 +689,45 @@ export type ServerMessageSendRequest = Omit<MessageSendInput, "idempotencyKey">
649
689
  idempotencyKey?: string;
650
690
  }> & ServerInvocationContext;
651
691
  export type ServerMessageSendMethod = (request: ServerMessageSendRequest) => Promise<MessageSendResult>;
692
+ /** A File upload slot for one File field of an entity schema, named by id or FQN. */
693
+ export type ServerResourceUploadRequest = EntityUploadInput & Readonly<{
694
+ schemaId: string;
695
+ /** Bound on each attempt's request and response body. Defaults to 10 seconds. */
696
+ timeoutMs?: number;
697
+ }> & ServerInvocationContext;
698
+ declare const resourceFailureCodes: readonly [
699
+ "conflict",
700
+ "forbidden",
701
+ "internal",
702
+ "invalid_request",
703
+ "not_found",
704
+ "unauthenticated",
705
+ "unavailable",
706
+ "upload_not_supported"
707
+ ];
708
+ /** Why CI's resources API refused the request. */
709
+ export type ServerResourceFailure = Readonly<{
710
+ correlationId: string;
711
+ error: Readonly<{
712
+ code: (typeof resourceFailureCodes)[number];
713
+ details?: Readonly<Record<string, ResourceJsonValue>>;
714
+ message: string;
715
+ retryable: boolean;
716
+ }>;
717
+ }>;
718
+ /** PUT the bytes to `result.url` with `result.headers`, then write `{ upload: uploadId }`. */
719
+ export type ServerResourceUploadResult = Readonly<{
720
+ error: ServerResourceFailure;
721
+ ok: false;
722
+ }> | Readonly<{
723
+ ok: true;
724
+ value: Readonly<{
725
+ correlationId: string;
726
+ operationId: "resources_create_upload";
727
+ result: EntityUploadSlot;
728
+ }>;
729
+ }>;
730
+ export type ServerResourceUploadMethod = (request: ServerResourceUploadRequest) => Promise<ServerResourceUploadResult>;
652
731
  export type RunOperationId = "runs_cancel" | "runs_get" | "runs_stream";
653
732
  export type ServerRunStatus = "accepted" | "cancelled" | "failed" | "running" | "succeeded";
654
733
  /**
@@ -731,6 +810,17 @@ export interface ServerClient {
731
810
  continue: ServerOperationMethod<"conversations_continue">;
732
811
  history: ServerOperationMethod<"conversations_history">;
733
812
  }>;
813
+ /**
814
+ * Durable private files of the application's Organization. `upload` stores
815
+ * one PDF, JPEG or PNG of up to 10 MiB with no expiry and returns its
816
+ * `storageFileId`; a `workflows.invoke` input can name it, and the nodes of
817
+ * the run read the file. Needs the `ai:attachments` scope and confidential
818
+ * credentials. Unlike `attachments.upload`, the file belongs to no run and
819
+ * does not expire after 24 hours.
820
+ */
821
+ readonly files: Readonly<{
822
+ upload: ServerOperationMethod<"files_upload">;
823
+ }>;
734
824
  readonly knowledge: Readonly<{
735
825
  autocomplete: ServerOperationMethod<"knowledge_autocomplete">;
736
826
  createEntity: ServerOperationMethod<"knowledge_create_entity">;
@@ -772,6 +862,26 @@ export interface ServerClient {
772
862
  readonly messages: Readonly<{
773
863
  send: ServerMessageSendMethod;
774
864
  }>;
865
+ /**
866
+ * The application's browser origins in its Organization. `setRuntime({ origin })`
867
+ * replaces the application's one runtime origin, such as the URL of the
868
+ * current deployment, beside the `allowedOrigins` its package declares.
869
+ * Needs the `origins:write` scope and confidential credentials.
870
+ */
871
+ readonly origins: Readonly<{
872
+ setRuntime: ServerOperationMethod<"origins_set_runtime">;
873
+ }>;
874
+ /**
875
+ * CI's resources API. `createUpload` asks a single-use File upload slot for
876
+ * one File field of an entity schema; the entity write then names its
877
+ * `uploadId` as `{ upload }`. Slots follow entity writes: the member's
878
+ * delegated token writes as that member; the service credential writes as
879
+ * the Organization default service principal, only on schemas its own
880
+ * package declares.
881
+ */
882
+ readonly resources: Readonly<{
883
+ createUpload: ServerResourceUploadMethod;
884
+ }>;
775
885
  readonly runs: Readonly<{
776
886
  cancel: ServerRunOperationMethod<"runs_cancel", ServerRun>;
777
887
  get: ServerRunOperationMethod<"runs_get", ServerRun>;
@@ -854,6 +964,7 @@ export declare const exchangeMemberSession: (request: MemberSessionExchangeReque
854
964
  export declare const uuidV7: () => string;
855
965
 
856
966
  export {
967
+ DurableFileUpload as ServerDurableFileUpload,
857
968
  MemberSessionExchangeError$1 as MemberSessionExchangeError,
858
969
  MemberUser as ServerMemberUser,
859
970
  MemberUserPage as ServerMemberUserPage,
@@ -864,6 +975,7 @@ export {
864
975
  MessageSendFailure as ServerMessageSendFailure,
865
976
  MessageSendResult as ServerMessageSendResult,
866
977
  MessageTarget as ServerMessageTarget,
978
+ StorageFileId as ServerStorageFileId,
867
979
  };
868
980
 
869
981
  export {};