@scalekit-sdk/node 2.2.0-beta.1 → 2.2.0-beta.3
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/lib/actions.d.ts +126 -0
- package/lib/actions.js +199 -0
- package/lib/actions.js.map +1 -0
- package/lib/core.js +2 -2
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +32 -0
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +40 -2
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +4 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +2 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.d.ts +10 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js +10 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.d.ts +54 -0
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js +89 -2
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.d.ts +10 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js +10 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +17 -0
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +33 -2
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/scalekit.d.ts +2 -0
- package/lib/scalekit.js +2 -0
- package/lib/scalekit.js.map +1 -1
- package/lib/tools.d.ts +22 -5
- package/lib/tools.js +30 -5
- package/lib/tools.js.map +1 -1
- package/package.json +1 -1
- package/reference.md +378 -0
- package/src/actions.ts +349 -0
- package/src/core.ts +2 -2
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +57 -1
- package/src/pkg/grpc/scalekit/v1/auth/passwordless_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/auth/passwordless_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +7 -1
- package/src/pkg/grpc/scalekit/v1/directories/directories_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/directories/directories_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/domains/domains_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/roles/roles_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/roles/roles_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_connect.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_pb.ts +1 -1
- package/src/pkg/grpc/scalekit/v1/tools/tools_connect.ts +11 -2
- package/src/pkg/grpc/scalekit/v1/tools/tools_pb.ts +105 -1
- package/src/pkg/grpc/scalekit/v1/users/users_connect.ts +11 -2
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +38 -1
- package/src/scalekit.ts +7 -0
- package/src/tools.ts +44 -7
- package/tests/actions.test.ts +356 -0
- package/tests/tools.test.ts +46 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// @generated by protoc-gen-connect-es v1.
|
|
1
|
+
// @generated by protoc-gen-connect-es v1.7.0 with parameter "target=ts"
|
|
2
2
|
// @generated from file scalekit/v1/tools/tools.proto (package scalekit.v1.tools, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
// @ts-nocheck
|
|
5
5
|
|
|
6
|
-
import { CreateToolRequest, CreateToolResponse, DeleteToolRequest, ExecuteToolRequest, ExecuteToolResponse, ListScopedToolsRequest, ListScopedToolsResponse, ListToolsRequest, ListToolsResponse, SetToolDefaultRequest, SetToolDefaultResponse, UpdateToolRequest, UpdateToolResponse } from "./tools_pb.js";
|
|
6
|
+
import { CreateToolRequest, CreateToolResponse, DeleteToolRequest, ExecuteToolRequest, ExecuteToolResponse, ListAvailableToolsRequest, ListAvailableToolsResponse, ListScopedToolsRequest, ListScopedToolsResponse, ListToolsRequest, ListToolsResponse, SetToolDefaultRequest, SetToolDefaultResponse, UpdateToolRequest, UpdateToolResponse } from "./tools_pb.js";
|
|
7
7
|
import { Empty, MethodKind } from "@bufbuild/protobuf";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -39,6 +39,15 @@ export const ToolService = {
|
|
|
39
39
|
O: ListScopedToolsResponse,
|
|
40
40
|
kind: MethodKind.Unary,
|
|
41
41
|
},
|
|
42
|
+
/**
|
|
43
|
+
* @generated from rpc scalekit.v1.tools.ToolService.ListAvailableTools
|
|
44
|
+
*/
|
|
45
|
+
listAvailableTools: {
|
|
46
|
+
name: "ListAvailableTools",
|
|
47
|
+
I: ListAvailableToolsRequest,
|
|
48
|
+
O: ListAvailableToolsResponse,
|
|
49
|
+
kind: MethodKind.Unary,
|
|
50
|
+
},
|
|
42
51
|
/**
|
|
43
52
|
* @generated from rpc scalekit.v1.tools.ToolService.SetToolDefault
|
|
44
53
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es v1.10.
|
|
1
|
+
// @generated by protoc-gen-es v1.10.1 with parameter "target=ts"
|
|
2
2
|
// @generated from file scalekit/v1/tools/tools.proto (package scalekit.v1.tools, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
// @ts-nocheck
|
|
@@ -845,3 +845,107 @@ export class ScopedToolFilter extends Message<ScopedToolFilter> {
|
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
|
|
848
|
+
/**
|
|
849
|
+
* @generated from message scalekit.v1.tools.ListAvailableToolsRequest
|
|
850
|
+
*/
|
|
851
|
+
export class ListAvailableToolsRequest extends Message<ListAvailableToolsRequest> {
|
|
852
|
+
/**
|
|
853
|
+
* @generated from field: string identifier = 1;
|
|
854
|
+
*/
|
|
855
|
+
identifier = "";
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* @generated from field: uint32 page_size = 2;
|
|
859
|
+
*/
|
|
860
|
+
pageSize = 0;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* @generated from field: string page_token = 3;
|
|
864
|
+
*/
|
|
865
|
+
pageToken = "";
|
|
866
|
+
|
|
867
|
+
constructor(data?: PartialMessage<ListAvailableToolsRequest>) {
|
|
868
|
+
super();
|
|
869
|
+
proto3.util.initPartial(data, this);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
static readonly runtime: typeof proto3 = proto3;
|
|
873
|
+
static readonly typeName = "scalekit.v1.tools.ListAvailableToolsRequest";
|
|
874
|
+
static readonly fields: FieldList = proto3.util.newFieldList(() => [
|
|
875
|
+
{ no: 1, name: "identifier", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
876
|
+
{ no: 2, name: "page_size", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
|
|
877
|
+
{ no: 3, name: "page_token", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
878
|
+
]);
|
|
879
|
+
|
|
880
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ListAvailableToolsRequest {
|
|
881
|
+
return new ListAvailableToolsRequest().fromBinary(bytes, options);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ListAvailableToolsRequest {
|
|
885
|
+
return new ListAvailableToolsRequest().fromJson(jsonValue, options);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ListAvailableToolsRequest {
|
|
889
|
+
return new ListAvailableToolsRequest().fromJsonString(jsonString, options);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
static equals(a: ListAvailableToolsRequest | PlainMessage<ListAvailableToolsRequest> | undefined, b: ListAvailableToolsRequest | PlainMessage<ListAvailableToolsRequest> | undefined): boolean {
|
|
893
|
+
return proto3.util.equals(ListAvailableToolsRequest, a, b);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* @generated from message scalekit.v1.tools.ListAvailableToolsResponse
|
|
899
|
+
*/
|
|
900
|
+
export class ListAvailableToolsResponse extends Message<ListAvailableToolsResponse> {
|
|
901
|
+
/**
|
|
902
|
+
* @generated from field: string next_page_token = 1;
|
|
903
|
+
*/
|
|
904
|
+
nextPageToken = "";
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* @generated from field: uint32 total_size = 2;
|
|
908
|
+
*/
|
|
909
|
+
totalSize = 0;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* @generated from field: string prev_page_token = 3;
|
|
913
|
+
*/
|
|
914
|
+
prevPageToken = "";
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* @generated from field: repeated scalekit.v1.tools.Tool tools = 4;
|
|
918
|
+
*/
|
|
919
|
+
tools: Tool[] = [];
|
|
920
|
+
|
|
921
|
+
constructor(data?: PartialMessage<ListAvailableToolsResponse>) {
|
|
922
|
+
super();
|
|
923
|
+
proto3.util.initPartial(data, this);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
static readonly runtime: typeof proto3 = proto3;
|
|
927
|
+
static readonly typeName = "scalekit.v1.tools.ListAvailableToolsResponse";
|
|
928
|
+
static readonly fields: FieldList = proto3.util.newFieldList(() => [
|
|
929
|
+
{ no: 1, name: "next_page_token", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
930
|
+
{ no: 2, name: "total_size", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
|
|
931
|
+
{ no: 3, name: "prev_page_token", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
932
|
+
{ no: 4, name: "tools", kind: "message", T: Tool, repeated: true },
|
|
933
|
+
]);
|
|
934
|
+
|
|
935
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ListAvailableToolsResponse {
|
|
936
|
+
return new ListAvailableToolsResponse().fromBinary(bytes, options);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ListAvailableToolsResponse {
|
|
940
|
+
return new ListAvailableToolsResponse().fromJson(jsonValue, options);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ListAvailableToolsResponse {
|
|
944
|
+
return new ListAvailableToolsResponse().fromJsonString(jsonString, options);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
static equals(a: ListAvailableToolsResponse | PlainMessage<ListAvailableToolsResponse> | undefined, b: ListAvailableToolsResponse | PlainMessage<ListAvailableToolsResponse> | undefined): boolean {
|
|
948
|
+
return proto3.util.equals(ListAvailableToolsResponse, a, b);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// @generated by protoc-gen-connect-es v1.
|
|
1
|
+
// @generated by protoc-gen-connect-es v1.7.0 with parameter "target=ts"
|
|
2
2
|
// @generated from file scalekit/v1/users/users.proto (package scalekit.v1.users, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
// @ts-nocheck
|
|
5
5
|
|
|
6
|
-
import { AssignUserRolesRequest, AssignUserRolesResponse, CreateMembershipRequest, CreateMembershipResponse, CreateUserAndMembershipRequest, CreateUserAndMembershipResponse, DeleteMembershipRequest, DeleteUserRequest, GetCurrentUserRequest, GetCurrentUserResponse, GetUserRequest, GetUserResponse, ListOrganizationUsersRequest, ListOrganizationUsersResponse, ListUserPermissionsRequest, ListUserPermissionsResponse, ListUserRolesRequest, ListUserRolesResponse, ListUsersRequest, ListUsersResponse, RemoveUserRoleRequest, ResendInviteRequest, ResendInviteResponse, SearchOrganizationUsersRequest, SearchOrganizationUsersResponse, SearchUsersRequest, SearchUsersResponse, UpdateMembershipRequest, UpdateMembershipResponse, UpdateUserRequest, UpdateUserResponse } from "./users_pb.js";
|
|
6
|
+
import { AssignUserRolesRequest, AssignUserRolesResponse, CreateMembershipRequest, CreateMembershipResponse, CreateUserAndMembershipRequest, CreateUserAndMembershipResponse, DeleteMembershipRequest, DeleteUserRequest, GetCurrentUserRequest, GetCurrentUserResponse, GetSupportHashResponse, GetUserRequest, GetUserResponse, ListOrganizationUsersRequest, ListOrganizationUsersResponse, ListUserPermissionsRequest, ListUserPermissionsResponse, ListUserRolesRequest, ListUserRolesResponse, ListUsersRequest, ListUsersResponse, RemoveUserRoleRequest, ResendInviteRequest, ResendInviteResponse, SearchOrganizationUsersRequest, SearchOrganizationUsersResponse, SearchUsersRequest, SearchUsersResponse, UpdateMembershipRequest, UpdateMembershipResponse, UpdateUserRequest, UpdateUserResponse } from "./users_pb.js";
|
|
7
7
|
import { Empty, MethodKind } from "@bufbuild/protobuf";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -32,6 +32,15 @@ export const UserService = {
|
|
|
32
32
|
O: GetCurrentUserResponse,
|
|
33
33
|
kind: MethodKind.Unary,
|
|
34
34
|
},
|
|
35
|
+
/**
|
|
36
|
+
* @generated from rpc scalekit.v1.users.UserService.GetSupportHash
|
|
37
|
+
*/
|
|
38
|
+
getSupportHash: {
|
|
39
|
+
name: "GetSupportHash",
|
|
40
|
+
I: Empty,
|
|
41
|
+
O: GetSupportHashResponse,
|
|
42
|
+
kind: MethodKind.Unary,
|
|
43
|
+
},
|
|
35
44
|
/**
|
|
36
45
|
* @generated from rpc scalekit.v1.users.UserService.ListUsers
|
|
37
46
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es v1.10.
|
|
1
|
+
// @generated by protoc-gen-es v1.10.1 with parameter "target=ts"
|
|
2
2
|
// @generated from file scalekit/v1/users/users.proto (package scalekit.v1.users, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
// @ts-nocheck
|
|
@@ -2112,6 +2112,43 @@ export class Permission extends Message<Permission> {
|
|
|
2112
2112
|
}
|
|
2113
2113
|
}
|
|
2114
2114
|
|
|
2115
|
+
/**
|
|
2116
|
+
* @generated from message scalekit.v1.users.GetSupportHashResponse
|
|
2117
|
+
*/
|
|
2118
|
+
export class GetSupportHashResponse extends Message<GetSupportHashResponse> {
|
|
2119
|
+
/**
|
|
2120
|
+
* @generated from field: string support_hash = 1;
|
|
2121
|
+
*/
|
|
2122
|
+
supportHash = "";
|
|
2123
|
+
|
|
2124
|
+
constructor(data?: PartialMessage<GetSupportHashResponse>) {
|
|
2125
|
+
super();
|
|
2126
|
+
proto3.util.initPartial(data, this);
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
static readonly runtime: typeof proto3 = proto3;
|
|
2130
|
+
static readonly typeName = "scalekit.v1.users.GetSupportHashResponse";
|
|
2131
|
+
static readonly fields: FieldList = proto3.util.newFieldList(() => [
|
|
2132
|
+
{ no: 1, name: "support_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
2133
|
+
]);
|
|
2134
|
+
|
|
2135
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetSupportHashResponse {
|
|
2136
|
+
return new GetSupportHashResponse().fromBinary(bytes, options);
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetSupportHashResponse {
|
|
2140
|
+
return new GetSupportHashResponse().fromJson(jsonValue, options);
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetSupportHashResponse {
|
|
2144
|
+
return new GetSupportHashResponse().fromJsonString(jsonString, options);
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
static equals(a: GetSupportHashResponse | PlainMessage<GetSupportHashResponse> | undefined, b: GetSupportHashResponse | PlainMessage<GetSupportHashResponse> | undefined): boolean {
|
|
2148
|
+
return proto3.util.equals(GetSupportHashResponse, a, b);
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2115
2152
|
/**
|
|
2116
2153
|
* @generated from message scalekit.v1.users.ListUserPermissionsResponse
|
|
2117
2154
|
*/
|
package/src/scalekit.ts
CHANGED
|
@@ -17,6 +17,7 @@ import SessionClient from './session';
|
|
|
17
17
|
import RoleClient from './role';
|
|
18
18
|
import PermissionClient from './permission';
|
|
19
19
|
import WebAuthnClient from './webauthn';
|
|
20
|
+
import ActionsClient from './actions';
|
|
20
21
|
import { IdpInitiatedLoginClaims, IdTokenClaim, User } from './types/auth';
|
|
21
22
|
import { AuthenticationOptions, AuthenticationResponse, AuthorizationUrlOptions, GrantType, LogoutUrlOptions, RefreshTokenResponse ,TokenValidationOptions } from './types/scalekit';
|
|
22
23
|
import { WebhookVerificationError, ScalekitValidateTokenFailureException } from './errors/base-exception';
|
|
@@ -64,6 +65,7 @@ export default class ScalekitClient {
|
|
|
64
65
|
readonly domain: DomainClient;
|
|
65
66
|
readonly tools: ToolsClient;
|
|
66
67
|
readonly connectedAccounts: ConnectedAccountsClient;
|
|
68
|
+
readonly actions: ActionsClient;
|
|
67
69
|
readonly directory: DirectoryClient;
|
|
68
70
|
readonly passwordless: PasswordlessClient;
|
|
69
71
|
readonly user: UserClient;
|
|
@@ -97,6 +99,11 @@ export default class ScalekitClient {
|
|
|
97
99
|
this.grpcConnect,
|
|
98
100
|
this.coreClient
|
|
99
101
|
);
|
|
102
|
+
this.actions = new ActionsClient(
|
|
103
|
+
this.tools,
|
|
104
|
+
this.connectedAccounts,
|
|
105
|
+
this.coreClient
|
|
106
|
+
);
|
|
100
107
|
this.directory = new DirectoryClient(this.grpcConnect, this.coreClient);
|
|
101
108
|
this.passwordless = new PasswordlessClient(
|
|
102
109
|
this.grpcConnect,
|
package/src/tools.ts
CHANGED
|
@@ -4,6 +4,8 @@ import GrpcConnect from "./connect";
|
|
|
4
4
|
import CoreClient from "./core";
|
|
5
5
|
import { ToolService } from "./pkg/grpc/scalekit/v1/tools/tools_connect";
|
|
6
6
|
import {
|
|
7
|
+
ListAvailableToolsRequest,
|
|
8
|
+
ListAvailableToolsResponse,
|
|
7
9
|
ExecuteToolRequest,
|
|
8
10
|
ExecuteToolResponse,
|
|
9
11
|
Filter,
|
|
@@ -69,26 +71,58 @@ export default class ToolsClient {
|
|
|
69
71
|
*
|
|
70
72
|
* @param identifier Connected account identifier to scope the tools list (for example,
|
|
71
73
|
* a workspace identifier or email).
|
|
72
|
-
* @param options
|
|
73
|
-
* @param options.filter Filter configuration for scoped tools (providers, tool names, connection names).
|
|
74
|
+
* @param options Filter and pagination parameters
|
|
75
|
+
* @param options.filter Filter configuration for scoped tools (providers, tool names, connection names). Required.
|
|
74
76
|
* @param options.pageSize Maximum number of tools to return per page.
|
|
75
77
|
* @param options.pageToken Token from a previous `listScopedTools` response for pagination.
|
|
76
78
|
*/
|
|
77
79
|
async listScopedTools(
|
|
78
80
|
identifier: string,
|
|
79
|
-
options
|
|
80
|
-
filter
|
|
81
|
+
options: {
|
|
82
|
+
filter: PartialMessage<ScopedToolFilter>;
|
|
81
83
|
pageSize?: number;
|
|
82
84
|
pageToken?: string;
|
|
83
85
|
}
|
|
84
86
|
): Promise<ListScopedToolsResponse> {
|
|
85
87
|
const request: PartialMessage<ListScopedToolsRequest> = {
|
|
86
88
|
identifier,
|
|
89
|
+
filter: options.filter as ScopedToolFilter,
|
|
87
90
|
};
|
|
88
91
|
|
|
89
|
-
if (options
|
|
90
|
-
request.
|
|
92
|
+
if (options.pageSize !== undefined) {
|
|
93
|
+
request.pageSize = options.pageSize;
|
|
91
94
|
}
|
|
95
|
+
if (options.pageToken) {
|
|
96
|
+
request.pageToken = options.pageToken;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return this.coreClient.connectExec(this.client.listScopedTools, request);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Lists tools that are available for a specific connected account identifier.
|
|
104
|
+
*
|
|
105
|
+
* This is similar to `listScopedTools` but returns the tools that can be
|
|
106
|
+
* made available for a given identifier, rather than the tools that are
|
|
107
|
+
* already scoped to it.
|
|
108
|
+
*
|
|
109
|
+
* @param identifier Connected account identifier to scope the available tools list (for example,
|
|
110
|
+
* a workspace identifier or email).
|
|
111
|
+
* @param options Optional pagination parameters
|
|
112
|
+
* @param options.pageSize Maximum number of tools to return per page.
|
|
113
|
+
* @param options.pageToken Token from a previous `listAvailableTools` response for pagination.
|
|
114
|
+
*/
|
|
115
|
+
async listAvailableTools(
|
|
116
|
+
identifier: string,
|
|
117
|
+
options?: {
|
|
118
|
+
pageSize?: number;
|
|
119
|
+
pageToken?: string;
|
|
120
|
+
}
|
|
121
|
+
): Promise<ListAvailableToolsResponse> {
|
|
122
|
+
const request: PartialMessage<ListAvailableToolsRequest> = {
|
|
123
|
+
identifier,
|
|
124
|
+
};
|
|
125
|
+
|
|
92
126
|
if (options?.pageSize !== undefined) {
|
|
93
127
|
request.pageSize = options.pageSize;
|
|
94
128
|
}
|
|
@@ -96,7 +130,10 @@ export default class ToolsClient {
|
|
|
96
130
|
request.pageToken = options.pageToken;
|
|
97
131
|
}
|
|
98
132
|
|
|
99
|
-
return this.coreClient.connectExec(
|
|
133
|
+
return this.coreClient.connectExec(
|
|
134
|
+
this.client.listAvailableTools,
|
|
135
|
+
request
|
|
136
|
+
);
|
|
100
137
|
}
|
|
101
138
|
|
|
102
139
|
/**
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import ScalekitClient from "../src/scalekit";
|
|
2
|
+
import { describe, it, expect, beforeEach, afterEach } from "@jest/globals";
|
|
3
|
+
import { TestDataGenerator, TestOrganizationManager } from "./utils/test-data";
|
|
4
|
+
import {
|
|
5
|
+
AuthorizationDetails,
|
|
6
|
+
CreateConnectedAccount,
|
|
7
|
+
OauthToken,
|
|
8
|
+
} from "../src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb";
|
|
9
|
+
|
|
10
|
+
declare const global: {
|
|
11
|
+
client: ScalekitClient;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe("Actions", () => {
|
|
15
|
+
let client: ScalekitClient;
|
|
16
|
+
let testOrg: string;
|
|
17
|
+
|
|
18
|
+
// Happy-path assumptions for the test environment:
|
|
19
|
+
// - A GMAIL connector named "GMAIL-test" exists.
|
|
20
|
+
// - A connected account with identifier "default" is ACTIVE for that connector.
|
|
21
|
+
// - A tool named "gmail_fetch_mails" is available for that connection.
|
|
22
|
+
const GMAIL_CONNECTION_NAME = "GMAIL-test";
|
|
23
|
+
const GMAIL_IDENTIFIER = "default";
|
|
24
|
+
const GMAIL_TOOL_NAME = "gmail_fetch_mails";
|
|
25
|
+
const USER_PROFILE_PATH = "/v1/users/me/profile";
|
|
26
|
+
const FRESHDESK_CONNECTION_NAME = "freshdesk";
|
|
27
|
+
|
|
28
|
+
beforeEach(async () => {
|
|
29
|
+
client = global.client;
|
|
30
|
+
testOrg = await TestOrganizationManager.createTestOrganization(client);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterEach(async () => {
|
|
34
|
+
await TestOrganizationManager.cleanupTestOrganization(client, testOrg);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should expose actions on ScalekitClient", () => {
|
|
38
|
+
expect(client.actions).toBeDefined();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should expose key connected-account helper methods", () => {
|
|
42
|
+
|
|
43
|
+
expect(typeof client.actions.createConnectedAccount).toBe("function");
|
|
44
|
+
expect(typeof client.actions.getOrCreateConnectedAccount).toBe("function");
|
|
45
|
+
expect(typeof client.actions.updateConnectedAccount).toBe("function");
|
|
46
|
+
expect(typeof client.actions.deleteConnectedAccount).toBe("function");
|
|
47
|
+
expect(typeof client.actions.getConnectedAccount).toBe("function");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("executeTool", () => {
|
|
51
|
+
it("should delegate to tools.executeTool with basic params", async () => {
|
|
52
|
+
try {
|
|
53
|
+
await client.actions.executeTool({
|
|
54
|
+
toolName: "test_tool",
|
|
55
|
+
toolInput: { key: "value" },
|
|
56
|
+
});
|
|
57
|
+
} catch (error: any) {
|
|
58
|
+
expect(error).toBeDefined();
|
|
59
|
+
expect(error.message || error.toString()).toBeDefined();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should execute a Gmail tool successfully via actions", async () => {
|
|
64
|
+
const toolInput = { max_results: 1 };
|
|
65
|
+
|
|
66
|
+
const response = await client.actions.executeTool({
|
|
67
|
+
toolName: GMAIL_TOOL_NAME,
|
|
68
|
+
toolInput,
|
|
69
|
+
identifier: GMAIL_IDENTIFIER,
|
|
70
|
+
connector: GMAIL_CONNECTION_NAME,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(response).toBeDefined();
|
|
74
|
+
// We expect a non-empty executionId and some data from the tool.
|
|
75
|
+
expect(typeof response.executionId).toBe("string");
|
|
76
|
+
expect(response.executionId.length).toBeGreaterThan(0);
|
|
77
|
+
expect(response.data).toBeDefined();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("getAuthorizationLink", () => {
|
|
82
|
+
it("should call underlying magic link API", async () => {
|
|
83
|
+
try {
|
|
84
|
+
const response = await client.actions.getAuthorizationLink({
|
|
85
|
+
connectionName: "test_connector",
|
|
86
|
+
identifier: "test_identifier",
|
|
87
|
+
organizationId: testOrg,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(response).toBeDefined();
|
|
91
|
+
} catch (error: any) {
|
|
92
|
+
expect(error).toBeDefined();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("createConnectedAccount", () => {
|
|
98
|
+
it("should construct CreateConnectedAccount payload", async () => {
|
|
99
|
+
const oauthToken = new OauthToken({
|
|
100
|
+
accessToken: "test_access_token",
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const authorizationDetails = new AuthorizationDetails({
|
|
104
|
+
details: {
|
|
105
|
+
case: "oauthToken",
|
|
106
|
+
value: oauthToken,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const response = await client.actions.createConnectedAccount({
|
|
112
|
+
connectionName: "test_connector",
|
|
113
|
+
identifier: `test_${Date.now()}`,
|
|
114
|
+
authorizationDetails,
|
|
115
|
+
organizationId: testOrg,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(response).toBeDefined();
|
|
119
|
+
} catch (error: any) {
|
|
120
|
+
expect(error).toBeDefined();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should validate required parameters", async () => {
|
|
125
|
+
const oauthToken = new OauthToken({
|
|
126
|
+
accessToken: "test_access_token",
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const authorizationDetails = new AuthorizationDetails({
|
|
130
|
+
details: {
|
|
131
|
+
case: "oauthToken",
|
|
132
|
+
value: oauthToken,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Missing connectionName
|
|
137
|
+
await expect(
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
+
client.actions.createConnectedAccount({
|
|
140
|
+
connectionName: "" as any,
|
|
141
|
+
identifier: "test_id",
|
|
142
|
+
authorizationDetails,
|
|
143
|
+
} as any)
|
|
144
|
+
).rejects.toThrow("connectionName is required");
|
|
145
|
+
|
|
146
|
+
// Missing identifier
|
|
147
|
+
await expect(
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
|
+
client.actions.createConnectedAccount({
|
|
150
|
+
connectionName: "GMAIL",
|
|
151
|
+
identifier: "" as any,
|
|
152
|
+
authorizationDetails,
|
|
153
|
+
} as any)
|
|
154
|
+
).rejects.toThrow("identifier is required");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe("getOrCreateConnectedAccount", () => {
|
|
159
|
+
it("should delegate validation to underlying client", async () => {
|
|
160
|
+
// connector / connectionName required
|
|
161
|
+
await expect(
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
+
client.actions.getOrCreateConnectedAccount({
|
|
164
|
+
connectionName: "" as any,
|
|
165
|
+
identifier: "user_123",
|
|
166
|
+
} as any)
|
|
167
|
+
).rejects.toThrow("connector is required");
|
|
168
|
+
|
|
169
|
+
// identifier required
|
|
170
|
+
await expect(
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
|
+
client.actions.getOrCreateConnectedAccount({
|
|
173
|
+
connectionName: "gmail",
|
|
174
|
+
identifier: "" as any,
|
|
175
|
+
} as any)
|
|
176
|
+
).rejects.toThrow("identifier is required");
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
describe("request", () => {
|
|
181
|
+
it("should validate required parameters", async () => {
|
|
182
|
+
await expect(
|
|
183
|
+
client.actions.request({
|
|
184
|
+
connectionName: "",
|
|
185
|
+
identifier: "",
|
|
186
|
+
path: "",
|
|
187
|
+
})
|
|
188
|
+
).rejects.toThrow();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("should fetch user profile successfully via proxy request", async () => {
|
|
192
|
+
const response = await client.actions.request({
|
|
193
|
+
connectionName: GMAIL_CONNECTION_NAME,
|
|
194
|
+
identifier: GMAIL_IDENTIFIER,
|
|
195
|
+
path: USER_PROFILE_PATH,
|
|
196
|
+
method: "GET",
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
expect(response).toBeDefined();
|
|
200
|
+
expect(response.status).toBeGreaterThanOrEqual(200);
|
|
201
|
+
expect(response.status).toBeLessThan(300);
|
|
202
|
+
// Response data should be JSON-serializable user profile shape.
|
|
203
|
+
expect(response.data).toBeDefined();
|
|
204
|
+
expect(typeof response.data).toBe("object");
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe("connected account lifecycle (Gmail OAuth)", () => {
|
|
209
|
+
it("should create, get, update, and delete a Gmail connected account with apiConfig", async () => {
|
|
210
|
+
const uniqueId = TestDataGenerator.generateUniqueId();
|
|
211
|
+
const identifier = `test_actions_gmail_${uniqueId}`;
|
|
212
|
+
|
|
213
|
+
const oauthToken = new OauthToken({
|
|
214
|
+
accessToken: "test_access_token_api",
|
|
215
|
+
refreshToken: "test_refresh_token_api",
|
|
216
|
+
scopes: ["read", "write"],
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const authorizationDetails = new AuthorizationDetails({
|
|
220
|
+
details: {
|
|
221
|
+
case: "oauthToken",
|
|
222
|
+
value: oauthToken,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const initialApiConfig = {
|
|
227
|
+
version: "v1.0",
|
|
228
|
+
domain: "gmail.com",
|
|
229
|
+
api_endpoint: "https://gmail.googleapis.com",
|
|
230
|
+
custom_auth_header: "Bearer",
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// Create
|
|
234
|
+
const createResponse = await client.actions.createConnectedAccount({
|
|
235
|
+
connectionName: GMAIL_CONNECTION_NAME,
|
|
236
|
+
identifier,
|
|
237
|
+
authorizationDetails,
|
|
238
|
+
apiConfig: initialApiConfig,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
expect(createResponse.connectedAccount).toBeDefined();
|
|
242
|
+
const created = createResponse.connectedAccount!;
|
|
243
|
+
expect(created.identifier).toBe(identifier);
|
|
244
|
+
expect(created.apiConfig).toBeDefined();
|
|
245
|
+
|
|
246
|
+
// Get via actions wrapper
|
|
247
|
+
const getResponse = await client.actions.getConnectedAccount({
|
|
248
|
+
connectionName: GMAIL_CONNECTION_NAME,
|
|
249
|
+
identifier,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
expect(getResponse.connectedAccount).toBeDefined();
|
|
253
|
+
expect(getResponse.connectedAccount!.identifier).toBe(identifier);
|
|
254
|
+
|
|
255
|
+
// Update apiConfig
|
|
256
|
+
const updatedApiConfig = {
|
|
257
|
+
version: "v2.0",
|
|
258
|
+
domain: "updated.gmail.com",
|
|
259
|
+
api_endpoint: "https://updated.gmail.googleapis.com",
|
|
260
|
+
custom_auth_header: "Updated Bearer",
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const updateResponse = await client.actions.updateConnectedAccount({
|
|
264
|
+
connectionName: GMAIL_CONNECTION_NAME,
|
|
265
|
+
identifier,
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
|
+
apiConfig: updatedApiConfig as any,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
expect(updateResponse.connectedAccount).toBeDefined();
|
|
271
|
+
const updated = updateResponse.connectedAccount!;
|
|
272
|
+
expect(updated.identifier).toBe(identifier);
|
|
273
|
+
expect(updated.apiConfig).toBeDefined();
|
|
274
|
+
|
|
275
|
+
// Delete via actions wrapper
|
|
276
|
+
const deleteResponse = await client.actions.deleteConnectedAccount({
|
|
277
|
+
connectionName: GMAIL_CONNECTION_NAME,
|
|
278
|
+
identifier,
|
|
279
|
+
});
|
|
280
|
+
expect(deleteResponse).toBeDefined();
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
describe("connected account lifecycle (Freshdesk static auth)", () => {
|
|
285
|
+
it("should create, update, and delete a Freshdesk connected account with static auth", async () => {
|
|
286
|
+
const uniqueId = TestDataGenerator.generateUniqueId();
|
|
287
|
+
const identifier = `test_actions_freshdesk_${uniqueId}`;
|
|
288
|
+
|
|
289
|
+
// Initial static auth
|
|
290
|
+
const initialStaticAuth = {
|
|
291
|
+
static_auth: {
|
|
292
|
+
domain: "initial.freshdesk.com",
|
|
293
|
+
username: "initial_user",
|
|
294
|
+
password: "initial_password",
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
try {
|
|
299
|
+
// Create Freshdesk account
|
|
300
|
+
const createResponse = await client.actions.createConnectedAccount({
|
|
301
|
+
connectionName: FRESHDESK_CONNECTION_NAME,
|
|
302
|
+
identifier,
|
|
303
|
+
// For Node, authorizationDetails is carried through as a generic value; we rely
|
|
304
|
+
// on the backend to interpret the structure.
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
306
|
+
authorizationDetails: initialStaticAuth as any,
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
expect(createResponse.connectedAccount).toBeDefined();
|
|
310
|
+
const created = createResponse.connectedAccount!;
|
|
311
|
+
expect(created.identifier).toBe(identifier);
|
|
312
|
+
|
|
313
|
+
// Update static auth
|
|
314
|
+
const updatedStaticAuth = {
|
|
315
|
+
static_auth: {
|
|
316
|
+
domain: "updated.freshdesk.com",
|
|
317
|
+
username: "updated_user",
|
|
318
|
+
password: "updated_password",
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const updateResponse = await client.actions.updateConnectedAccount({
|
|
323
|
+
connectionName: FRESHDESK_CONNECTION_NAME,
|
|
324
|
+
identifier,
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
326
|
+
authorizationDetails: updatedStaticAuth as any,
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
expect(updateResponse.connectedAccount).toBeDefined();
|
|
330
|
+
const updated = updateResponse.connectedAccount!;
|
|
331
|
+
expect(updated.identifier).toBe(identifier);
|
|
332
|
+
|
|
333
|
+
// Best-effort check: authorizationDetails should be present
|
|
334
|
+
expect(updated.authorizationDetails).toBeDefined();
|
|
335
|
+
|
|
336
|
+
// Delete Freshdesk account
|
|
337
|
+
const deleteResponse = await client.actions.deleteConnectedAccount({
|
|
338
|
+
connectionName: FRESHDESK_CONNECTION_NAME,
|
|
339
|
+
identifier,
|
|
340
|
+
});
|
|
341
|
+
expect(deleteResponse).toBeDefined();
|
|
342
|
+
} catch (error: any) {
|
|
343
|
+
// If the Freshdesk connector is not configured in this environment,
|
|
344
|
+
// treat this as a skipped integration scenario rather than a hard failure.
|
|
345
|
+
if (
|
|
346
|
+
error?.name === "ScalekitNotFoundException" ||
|
|
347
|
+
/connection not found/i.test(String(error.message ?? error))
|
|
348
|
+
) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
throw error;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|