@collective-intelligence/external-apps-server-sdk 0.1.37 → 0.1.39
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 +114 -14
- package/dist/admin.d.ts +1 -0
- package/dist/{runtime/effect.js → chunks/index-7b0e6810.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.d.ts +5 -1
- package/dist/resources.js +1 -1
- package/dist/runtime/effect.d.ts +137 -106
- package/dist/runtime/nestjs.js +1 -1
- 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/index.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
import { CiError, CiTransportError, FederatedAuthError, FederatedAuthErrorCode } from '@collective-intelligence/external-apps-client-sdk/effect';
|
|
3
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';
|
|
4
10
|
|
|
5
11
|
export type ExternalApplicationsGetContextErrors = {
|
|
6
12
|
/**
|
|
@@ -673,14 +679,63 @@ type MessageSendResult = Readonly<{
|
|
|
673
679
|
result: MessageReceipt;
|
|
674
680
|
}>;
|
|
675
681
|
}>;
|
|
676
|
-
|
|
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> {
|
|
677
688
|
readonly clientId: string;
|
|
678
|
-
readonly clientSecret:
|
|
689
|
+
readonly clientSecret: Secret;
|
|
679
690
|
}
|
|
680
691
|
export interface RotatingConfidentialCredentialProvider {
|
|
681
692
|
readonly getCredentials: () => ConfidentialCredentials | Promise<ConfidentialCredentials>;
|
|
682
693
|
}
|
|
683
|
-
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
|
+
}
|
|
684
739
|
export interface ServerRetryPolicy {
|
|
685
740
|
readonly baseDelayMs?: number;
|
|
686
741
|
readonly maxAttempts?: number;
|
|
@@ -690,14 +745,15 @@ export type DelegatedServerAuthentication = Readonly<{
|
|
|
690
745
|
getAccessToken: () => Promise<string> | string;
|
|
691
746
|
mode?: "delegated";
|
|
692
747
|
}>;
|
|
693
|
-
export type ServiceServerAuthentication = Readonly<{
|
|
694
|
-
credentials: ConfidentialCredentialProvider
|
|
748
|
+
export type ServiceServerAuthentication<Secret extends ClientSecret = string> = Readonly<{
|
|
749
|
+
credentials: ConfidentialCredentialProvider<Secret>;
|
|
695
750
|
mode: "service";
|
|
696
751
|
}>;
|
|
697
|
-
export type ServerClientAuthentication = DelegatedServerAuthentication | ServiceServerAuthentication
|
|
698
|
-
|
|
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> {
|
|
699
755
|
readonly auditSubject?: ExternalApplicationExternalAuditSubject;
|
|
700
|
-
readonly authentication: ServerClientAuthentication
|
|
756
|
+
readonly authentication: ServerClientAuthentication<Secret>;
|
|
701
757
|
readonly createCorrelationId?: () => string;
|
|
702
758
|
readonly createIdempotencyKey?: () => string;
|
|
703
759
|
readonly fetch?: typeof globalThis.fetch;
|
|
@@ -728,12 +784,10 @@ export type ManagedInput<Input> = Input extends {
|
|
|
728
784
|
} : Input;
|
|
729
785
|
export type ManagedOperationInput<Id extends ExternalApplicationServerOperationId> = ManagedInput<OperationInput<Id>>;
|
|
730
786
|
export type ServerOperationRequest<Id extends ExternalApplicationServerOperationId> = OperationInput<Id> extends Readonly<Record<string, never>> ? ServerInvocationContext : ManagedOperationInput<Id> & ServerInvocationContext;
|
|
731
|
-
export type ServerOperationMethod<Id extends ExternalApplicationServerOperationId> = (request: ServerOperationRequest<Id>) => Promise<ExternalApplicationOperationResult<Id>>;
|
|
732
787
|
/** One message to send; `idempotencyKey` is generated when omitted. */
|
|
733
788
|
export type ServerMessageSendRequest = Omit<MessageSendInput, "idempotencyKey"> & Readonly<{
|
|
734
789
|
idempotencyKey?: string;
|
|
735
790
|
}> & ServerInvocationContext;
|
|
736
|
-
export type ServerMessageSendMethod = (request: ServerMessageSendRequest) => Promise<MessageSendResult>;
|
|
737
791
|
/** A File upload slot for one File field of an entity schema, named by id or FQN. */
|
|
738
792
|
export type ServerResourceUploadRequest = EntityUploadInput & Readonly<{
|
|
739
793
|
schemaId: string;
|
|
@@ -772,6 +826,8 @@ export type ServerResourceUploadResult = Readonly<{
|
|
|
772
826
|
result: EntityUploadSlot;
|
|
773
827
|
}>;
|
|
774
828
|
}>;
|
|
829
|
+
export type ServerOperationMethod<Id extends ExternalApplicationServerOperationId> = (request: ServerOperationRequest<Id>) => Promise<ExternalApplicationOperationResult<Id>>;
|
|
830
|
+
export type ServerMessageSendMethod = (request: ServerMessageSendRequest) => Promise<MessageSendResult>;
|
|
775
831
|
export type ServerResourceUploadMethod = (request: ServerResourceUploadRequest) => Promise<ServerResourceUploadResult>;
|
|
776
832
|
export type RunOperationId = "runs_cancel" | "runs_get" | "runs_stream";
|
|
777
833
|
export type ServerRunStatus = "accepted" | "cancelled" | "failed" | "running" | "succeeded";
|
|
@@ -935,23 +991,6 @@ export interface ServerClient {
|
|
|
935
991
|
list: ServerOperationMethod<"workflows_list">;
|
|
936
992
|
}>;
|
|
937
993
|
}
|
|
938
|
-
declare const oauthErrorCodes: readonly [
|
|
939
|
-
"invalid_client",
|
|
940
|
-
"invalid_grant",
|
|
941
|
-
"invalid_request",
|
|
942
|
-
"invalid_scope",
|
|
943
|
-
"invalid_target",
|
|
944
|
-
"temporarily_unavailable",
|
|
945
|
-
"unauthorized_client",
|
|
946
|
-
"unsupported_grant_type"
|
|
947
|
-
];
|
|
948
|
-
/**
|
|
949
|
-
* `invalid_grant` means the member's CI session ended or the member cannot act
|
|
950
|
-
* in the Organization: sign the member in again. `invalid_response` means CI
|
|
951
|
-
* answered with neither a token nor an OAuth error. Other codes are CI's OAuth
|
|
952
|
-
* errors and point at the application's configuration or CI availability.
|
|
953
|
-
*/
|
|
954
|
-
export type MemberSessionExchangeErrorCode = (typeof oauthErrorCodes)[number] | "invalid_response";
|
|
955
994
|
export interface MemberSessionExchangeRequest {
|
|
956
995
|
readonly credentials: ConfidentialCredentialProvider;
|
|
957
996
|
readonly fetch?: typeof globalThis.fetch;
|
|
@@ -972,15 +1011,10 @@ export interface MemberAccessToken {
|
|
|
972
1011
|
/** When to exchange again: before CI's expiry, which is counted from signing. */
|
|
973
1012
|
readonly expiresAt: Date;
|
|
974
1013
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
/** The HTTP status CI answered with; absent when CI was unreachable. */
|
|
978
|
-
readonly status: number | undefined;
|
|
979
|
-
constructor(code: MemberSessionExchangeErrorCode, status: number | undefined, options?: ErrorOptions);
|
|
980
|
-
}
|
|
981
|
-
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<{
|
|
982
1016
|
auditSubject: ExternalApplicationExternalAuditSubject;
|
|
983
|
-
credentials: ConfidentialCredentials
|
|
1017
|
+
credentials: ConfidentialCredentials<Secret>;
|
|
984
1018
|
createCorrelationId?: () => string;
|
|
985
1019
|
createIdempotencyKey?: () => string;
|
|
986
1020
|
fetch?: typeof globalThis.fetch;
|
|
@@ -988,8 +1022,18 @@ export type RunAsApplicationConfig = Readonly<{
|
|
|
988
1022
|
sleep?: (milliseconds: number) => Promise<void>;
|
|
989
1023
|
tenantUrl: string;
|
|
990
1024
|
}>;
|
|
991
|
-
|
|
992
|
-
|
|
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
|
+
}>;
|
|
993
1037
|
export declare const exchangeMemberSession: (request: MemberSessionExchangeRequest) => Promise<MemberAccessToken>, MemberSessionExchangeError$1: typeof MemberSessionExchangeError;
|
|
994
1038
|
export declare const uuidV7: () => string;
|
|
995
1039
|
|
|
@@ -998,9 +1042,12 @@ export {
|
|
|
998
1042
|
ApplicationUser as ServerApplicationUser,
|
|
999
1043
|
ApplicationUserPage as ServerApplicationUserPage,
|
|
1000
1044
|
ApplicationUserResolution as ServerApplicationUserResolution,
|
|
1045
|
+
CiError$1 as CiError,
|
|
1046
|
+
CiTransportError$1 as CiTransportError,
|
|
1001
1047
|
DurableFileUpload as ServerDurableFileUpload,
|
|
1002
1048
|
EntityUploadInput,
|
|
1003
1049
|
EntityUploadSlot,
|
|
1050
|
+
FederatedAuthError$1 as FederatedAuthError,
|
|
1004
1051
|
MemberSessionExchangeError$1 as MemberSessionExchangeError,
|
|
1005
1052
|
MessageContent as ServerMessageContent,
|
|
1006
1053
|
MessageReceipt as ServerMessageReceipt,
|