@collective-intelligence/external-apps-server-sdk 0.1.36 → 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/dist/index.d.ts CHANGED
@@ -1,21 +1,13 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
- export type ResourceJsonValue = null | boolean | number | string | readonly ResourceJsonValue[] | Readonly<{
4
- [key: string]: ResourceJsonValue;
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
- }>;
3
+ import { CiError, CiTransportError, FederatedAuthError, FederatedAuthErrorCode } from '@collective-intelligence/external-apps-client-sdk/effect';
4
+ import { EntityUploadInput, EntityUploadSlot, ResourceJsonValue } from '@collective-intelligence/external-apps-client-sdk/resources';
5
+ import * as Context from 'effect/Context';
6
+ import * as Effect from 'effect/Effect';
7
+ import * as Layer from 'effect/Layer';
8
+ import * as Redacted from 'effect/Redacted';
9
+ import * as Schema from 'effect/Schema';
10
+
19
11
  export type ExternalApplicationsGetContextErrors = {
20
12
  /**
21
13
  * Error
@@ -687,14 +679,63 @@ type MessageSendResult = Readonly<{
687
679
  result: MessageReceipt;
688
680
  }>;
689
681
  }>;
690
- export interface ConfidentialCredentials {
682
+ /**
683
+ * A client secret: a string at `.`, or the `Redacted` string that Effect
684
+ * `Config.Redacted` reads for the `./effect` layers.
685
+ */
686
+ export type ClientSecret = Redacted.Redacted<string> | string;
687
+ export interface ConfidentialCredentials<Secret extends ClientSecret = string> {
691
688
  readonly clientId: string;
692
- readonly clientSecret: string;
689
+ readonly clientSecret: Secret;
693
690
  }
694
691
  export interface RotatingConfidentialCredentialProvider {
695
692
  readonly getCredentials: () => ConfidentialCredentials | Promise<ConfidentialCredentials>;
696
693
  }
697
- export type ConfidentialCredentialProvider = ConfidentialCredentials | RotatingConfidentialCredentialProvider;
694
+ export type ConfidentialCredentialProvider<Secret extends ClientSecret = string> = ConfidentialCredentials<Secret> | RotatingConfidentialCredentialProvider;
695
+ declare const oauthErrorCodes: readonly [
696
+ "invalid_client",
697
+ "invalid_grant",
698
+ "invalid_request",
699
+ "invalid_scope",
700
+ "invalid_target",
701
+ "temporarily_unavailable",
702
+ "unauthorized_client",
703
+ "unsupported_grant_type"
704
+ ];
705
+ /**
706
+ * `invalid_grant` means the member's CI session ended or the member cannot act
707
+ * in the Organization: sign the member in again. `invalid_response` means CI
708
+ * answered with neither a token nor an OAuth error. Other codes are CI's OAuth
709
+ * errors and point at the application's configuration or CI availability.
710
+ */
711
+ export type MemberSessionExchangeErrorCode = (typeof oauthErrorCodes)[number] | "invalid_response";
712
+ declare const MemberSessionExchangeError_base: Schema.Class<MemberSessionExchangeError, Schema.TaggedStruct<"MemberSessionExchangeError", {
713
+ readonly cause: Schema.optional<Schema.Defect>;
714
+ readonly code: Schema.Literals<readonly [
715
+ "invalid_client",
716
+ "invalid_grant",
717
+ "invalid_request",
718
+ "invalid_scope",
719
+ "invalid_target",
720
+ "temporarily_unavailable",
721
+ "unauthorized_client",
722
+ "unsupported_grant_type",
723
+ "invalid_response"
724
+ ]>;
725
+ /** The HTTP status CI answered with; absent when CI was unreachable. */
726
+ readonly status: Schema.UndefinedOr<Schema.Int>;
727
+ }>, import("effect/Cause").YieldableError>;
728
+ declare class MemberSessionExchangeError extends MemberSessionExchangeError_base {
729
+ /** The positional form of `.`: CI's code, its HTTP status and the cause. */
730
+ constructor(code: MemberSessionExchangeErrorCode, status: number | undefined, options?: ErrorOptions);
731
+ /** The Schema form; Schema decoding gives the fields and the options. */
732
+ constructor(fields: Readonly<{
733
+ cause?: unknown;
734
+ code: MemberSessionExchangeErrorCode;
735
+ status: number | undefined;
736
+ }>, options: Schema.MakeOptions | undefined);
737
+ get message(): string;
738
+ }
698
739
  export interface ServerRetryPolicy {
699
740
  readonly baseDelayMs?: number;
700
741
  readonly maxAttempts?: number;
@@ -704,14 +745,15 @@ export type DelegatedServerAuthentication = Readonly<{
704
745
  getAccessToken: () => Promise<string> | string;
705
746
  mode?: "delegated";
706
747
  }>;
707
- export type ServiceServerAuthentication = Readonly<{
708
- credentials: ConfidentialCredentialProvider;
748
+ export type ServiceServerAuthentication<Secret extends ClientSecret = string> = Readonly<{
749
+ credentials: ConfidentialCredentialProvider<Secret>;
709
750
  mode: "service";
710
751
  }>;
711
- export type ServerClientAuthentication = DelegatedServerAuthentication | ServiceServerAuthentication;
712
- export interface ServerClientConfig {
752
+ export type ServerClientAuthentication<Secret extends ClientSecret = string> = DelegatedServerAuthentication | ServiceServerAuthentication<Secret>;
753
+ /** `Secret` is a string at `.`; the `./effect` layers also take a `Redacted` one. */
754
+ export interface ServerClientConfig<Secret extends ClientSecret = string> {
713
755
  readonly auditSubject?: ExternalApplicationExternalAuditSubject;
714
- readonly authentication: ServerClientAuthentication;
756
+ readonly authentication: ServerClientAuthentication<Secret>;
715
757
  readonly createCorrelationId?: () => string;
716
758
  readonly createIdempotencyKey?: () => string;
717
759
  readonly fetch?: typeof globalThis.fetch;
@@ -742,12 +784,10 @@ export type ManagedInput<Input> = Input extends {
742
784
  } : Input;
743
785
  export type ManagedOperationInput<Id extends ExternalApplicationServerOperationId> = ManagedInput<OperationInput<Id>>;
744
786
  export type ServerOperationRequest<Id extends ExternalApplicationServerOperationId> = OperationInput<Id> extends Readonly<Record<string, never>> ? ServerInvocationContext : ManagedOperationInput<Id> & ServerInvocationContext;
745
- export type ServerOperationMethod<Id extends ExternalApplicationServerOperationId> = (request: ServerOperationRequest<Id>) => Promise<ExternalApplicationOperationResult<Id>>;
746
787
  /** One message to send; `idempotencyKey` is generated when omitted. */
747
788
  export type ServerMessageSendRequest = Omit<MessageSendInput, "idempotencyKey"> & Readonly<{
748
789
  idempotencyKey?: string;
749
790
  }> & ServerInvocationContext;
750
- export type ServerMessageSendMethod = (request: ServerMessageSendRequest) => Promise<MessageSendResult>;
751
791
  /** A File upload slot for one File field of an entity schema, named by id or FQN. */
752
792
  export type ServerResourceUploadRequest = EntityUploadInput & Readonly<{
753
793
  schemaId: string;
@@ -786,6 +826,8 @@ export type ServerResourceUploadResult = Readonly<{
786
826
  result: EntityUploadSlot;
787
827
  }>;
788
828
  }>;
829
+ export type ServerOperationMethod<Id extends ExternalApplicationServerOperationId> = (request: ServerOperationRequest<Id>) => Promise<ExternalApplicationOperationResult<Id>>;
830
+ export type ServerMessageSendMethod = (request: ServerMessageSendRequest) => Promise<MessageSendResult>;
789
831
  export type ServerResourceUploadMethod = (request: ServerResourceUploadRequest) => Promise<ServerResourceUploadResult>;
790
832
  export type RunOperationId = "runs_cancel" | "runs_get" | "runs_stream";
791
833
  export type ServerRunStatus = "accepted" | "cancelled" | "failed" | "running" | "succeeded";
@@ -949,23 +991,6 @@ export interface ServerClient {
949
991
  list: ServerOperationMethod<"workflows_list">;
950
992
  }>;
951
993
  }
952
- declare const oauthErrorCodes: readonly [
953
- "invalid_client",
954
- "invalid_grant",
955
- "invalid_request",
956
- "invalid_scope",
957
- "invalid_target",
958
- "temporarily_unavailable",
959
- "unauthorized_client",
960
- "unsupported_grant_type"
961
- ];
962
- /**
963
- * `invalid_grant` means the member's CI session ended or the member cannot act
964
- * in the Organization: sign the member in again. `invalid_response` means CI
965
- * answered with neither a token nor an OAuth error. Other codes are CI's OAuth
966
- * errors and point at the application's configuration or CI availability.
967
- */
968
- export type MemberSessionExchangeErrorCode = (typeof oauthErrorCodes)[number] | "invalid_response";
969
994
  export interface MemberSessionExchangeRequest {
970
995
  readonly credentials: ConfidentialCredentialProvider;
971
996
  readonly fetch?: typeof globalThis.fetch;
@@ -986,15 +1011,10 @@ export interface MemberAccessToken {
986
1011
  /** When to exchange again: before CI's expiry, which is counted from signing. */
987
1012
  readonly expiresAt: Date;
988
1013
  }
989
- declare class MemberSessionExchangeError extends Error {
990
- readonly code: MemberSessionExchangeErrorCode;
991
- /** The HTTP status CI answered with; absent when CI was unreachable. */
992
- readonly status: number | undefined;
993
- constructor(code: MemberSessionExchangeErrorCode, status: number | undefined, options?: ErrorOptions);
994
- }
995
- export type RunAsApplicationConfig = Readonly<{
1014
+ /** `Secret` is a string at `.`; the `./effect` layers also take a `Redacted` one. */
1015
+ export type RunAsApplicationConfig<Secret extends ClientSecret = string> = Readonly<{
996
1016
  auditSubject: ExternalApplicationExternalAuditSubject;
997
- credentials: ConfidentialCredentials;
1017
+ credentials: ConfidentialCredentials<Secret>;
998
1018
  createCorrelationId?: () => string;
999
1019
  createIdempotencyKey?: () => string;
1000
1020
  fetch?: typeof globalThis.fetch;
@@ -1002,8 +1022,18 @@ export type RunAsApplicationConfig = Readonly<{
1002
1022
  sleep?: (milliseconds: number) => Promise<void>;
1003
1023
  tenantUrl: string;
1004
1024
  }>;
1005
- export declare const createServerClient: (config: ServerClientConfig) => ServerClient, serverSdkRuntime: "node";
1006
- export declare const runAsApplication: (config: RunAsApplicationConfig) => ServerClient;
1025
+ declare const CiError$1: typeof CiError;
1026
+ type CiError$1 = CiError;
1027
+ declare const CiTransportError$1: typeof CiTransportError;
1028
+ type CiTransportError$1 = CiTransportError;
1029
+ declare const FederatedAuthError$1: typeof FederatedAuthError;
1030
+ type FederatedAuthError$1 = FederatedAuthError;
1031
+ export declare const createServerClient: (config: ServerClientConfig) => ServerClient & Readonly<{
1032
+ close: () => Promise<void>;
1033
+ }>, serverSdkRuntime: "node";
1034
+ export declare const runAsApplication: (config: RunAsApplicationConfig) => ServerClient & Readonly<{
1035
+ close: () => Promise<void>;
1036
+ }>;
1007
1037
  export declare const exchangeMemberSession: (request: MemberSessionExchangeRequest) => Promise<MemberAccessToken>, MemberSessionExchangeError$1: typeof MemberSessionExchangeError;
1008
1038
  export declare const uuidV7: () => string;
1009
1039
 
@@ -1012,7 +1042,12 @@ export {
1012
1042
  ApplicationUser as ServerApplicationUser,
1013
1043
  ApplicationUserPage as ServerApplicationUserPage,
1014
1044
  ApplicationUserResolution as ServerApplicationUserResolution,
1045
+ CiError$1 as CiError,
1046
+ CiTransportError$1 as CiTransportError,
1015
1047
  DurableFileUpload as ServerDurableFileUpload,
1048
+ EntityUploadInput,
1049
+ EntityUploadSlot,
1050
+ FederatedAuthError$1 as FederatedAuthError,
1016
1051
  MemberSessionExchangeError$1 as MemberSessionExchangeError,
1017
1052
  MessageContent as ServerMessageContent,
1018
1053
  MessageReceipt as ServerMessageReceipt,
@@ -1020,6 +1055,7 @@ export {
1020
1055
  MessageSendFailure as ServerMessageSendFailure,
1021
1056
  MessageSendResult as ServerMessageSendResult,
1022
1057
  MessageTarget as ServerMessageTarget,
1058
+ ResourceJsonValue,
1023
1059
  StorageFileId as ServerStorageFileId,
1024
1060
  };
1025
1061