@openstax/ts-utils 1.28.1 → 1.30.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.
- package/dist/cjs/assertions/index.d.ts +7 -3
- package/dist/cjs/config/envConfig.d.ts +1 -1
- package/dist/cjs/config/index.d.ts +7 -7
- package/dist/cjs/config/resolveConfigValue.d.ts +2 -2
- package/dist/cjs/fetch/index.d.ts +16 -16
- package/dist/cjs/fetch/index.js +1 -1
- package/dist/cjs/middleware/apiErrorHandler.d.ts +3 -3
- package/dist/cjs/middleware/apiSlowResponseMiddleware.d.ts +1 -1
- package/dist/cjs/middleware/index.d.ts +7 -7
- package/dist/cjs/middleware/lambdaCorsResponseMiddleware.d.ts +1 -1
- package/dist/cjs/misc/hashValue.d.ts +2 -2
- package/dist/cjs/misc/helpers.d.ts +11 -11
- package/dist/cjs/misc/merge.d.ts +2 -2
- package/dist/cjs/misc/partitionSequence.d.ts +2 -2
- package/dist/cjs/pagination/index.d.ts +1 -1
- package/dist/cjs/routing/index.d.ts +30 -30
- package/dist/cjs/routing/index.js +18 -8
- package/dist/cjs/routing/validators/zod.d.ts +1 -1
- package/dist/cjs/routing/validators/zod.js +3 -1
- package/dist/cjs/services/accountsGateway/index.d.ts +17 -20
- package/dist/cjs/services/apiGateway/index.d.ts +10 -10
- package/dist/cjs/services/apiGateway/index.js +17 -7
- package/dist/cjs/services/authProvider/browser.d.ts +5 -7
- package/dist/cjs/services/authProvider/decryption.d.ts +3 -7
- package/dist/cjs/services/authProvider/index.d.ts +8 -8
- package/dist/cjs/services/authProvider/subrequest.d.ts +2 -5
- package/dist/cjs/services/authProvider/utils/decryptAndVerify.d.ts +1 -2
- package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.d.ts +4 -4
- package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.js +1 -1
- package/dist/cjs/services/authProvider/utils/userRoleValidator.d.ts +2 -2
- package/dist/cjs/services/documentStore/index.d.ts +7 -7
- package/dist/cjs/services/documentStore/unversioned/dynamodb.d.ts +7 -9
- package/dist/cjs/services/documentStore/unversioned/file-system.d.ts +7 -9
- package/dist/cjs/services/documentStore/unversioned/file-system.js +17 -7
- package/dist/cjs/services/documentStore/unversioned/index.d.ts +1 -1
- package/dist/cjs/services/documentStore/versioned/dynamodb.d.ts +7 -9
- package/dist/cjs/services/documentStore/versioned/file-system.d.ts +6 -8
- package/dist/cjs/services/documentStore/versioned/index.d.ts +4 -4
- package/dist/cjs/services/exercisesGateway/index.d.ts +9 -13
- package/dist/cjs/services/exercisesGateway/index.js +17 -7
- package/dist/cjs/services/fileServer/index.d.ts +2 -3
- package/dist/cjs/services/fileServer/localFileServer.d.ts +2 -6
- package/dist/cjs/services/fileServer/s3FileServer.d.ts +2 -5
- package/dist/cjs/services/launchParams/signer.d.ts +4 -9
- package/dist/cjs/services/launchParams/verifier.d.ts +5 -6
- package/dist/cjs/services/launchParams/verifier.js +29 -11
- package/dist/cjs/services/logger/index.d.ts +2 -2
- package/dist/cjs/services/logger/index.js +1 -1
- package/dist/cjs/services/lrsGateway/addStatementDefaultFields.d.ts +1 -1
- package/dist/cjs/services/lrsGateway/attempt-utils.d.ts +34 -34
- package/dist/cjs/services/lrsGateway/file-system.d.ts +2 -4
- package/dist/cjs/services/lrsGateway/file-system.js +17 -7
- package/dist/cjs/services/lrsGateway/index.d.ts +29 -32
- package/dist/cjs/services/lrsGateway/index.js +17 -7
- package/dist/cjs/services/lrsGateway/xapiUtils.d.ts +23 -23
- package/dist/cjs/services/postgresConnection/index.d.ts +3 -10
- package/dist/cjs/services/searchProvider/index.d.ts +7 -7
- package/dist/cjs/services/searchProvider/memorySearchTheBadWay.d.ts +1 -1
- package/dist/cjs/services/searchProvider/openSearch.d.ts +3 -6
- package/dist/cjs/services/searchProvider/openSearch.js +7 -3
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +5 -5
- package/dist/esm/assertions/index.d.ts +7 -3
- package/dist/esm/config/envConfig.d.ts +1 -1
- package/dist/esm/config/index.d.ts +7 -7
- package/dist/esm/config/resolveConfigValue.d.ts +2 -2
- package/dist/esm/fetch/index.d.ts +16 -16
- package/dist/esm/middleware/apiErrorHandler.d.ts +3 -3
- package/dist/esm/middleware/apiSlowResponseMiddleware.d.ts +1 -1
- package/dist/esm/middleware/index.d.ts +7 -7
- package/dist/esm/middleware/lambdaCorsResponseMiddleware.d.ts +1 -1
- package/dist/esm/misc/hashValue.d.ts +2 -2
- package/dist/esm/misc/helpers.d.ts +11 -11
- package/dist/esm/misc/merge.d.ts +2 -2
- package/dist/esm/misc/partitionSequence.d.ts +2 -2
- package/dist/esm/pagination/index.d.ts +1 -1
- package/dist/esm/routing/index.d.ts +30 -30
- package/dist/esm/routing/validators/zod.d.ts +1 -1
- package/dist/esm/routing/validators/zod.js +3 -1
- package/dist/esm/services/accountsGateway/index.d.ts +17 -20
- package/dist/esm/services/apiGateway/index.d.ts +10 -10
- package/dist/esm/services/authProvider/browser.d.ts +5 -7
- package/dist/esm/services/authProvider/decryption.d.ts +3 -7
- package/dist/esm/services/authProvider/index.d.ts +8 -8
- package/dist/esm/services/authProvider/subrequest.d.ts +2 -5
- package/dist/esm/services/authProvider/utils/decryptAndVerify.d.ts +1 -2
- package/dist/esm/services/authProvider/utils/embeddedAuthProvider.d.ts +4 -4
- package/dist/esm/services/authProvider/utils/userRoleValidator.d.ts +2 -2
- package/dist/esm/services/documentStore/index.d.ts +7 -7
- package/dist/esm/services/documentStore/unversioned/dynamodb.d.ts +7 -9
- package/dist/esm/services/documentStore/unversioned/file-system.d.ts +7 -9
- package/dist/esm/services/documentStore/unversioned/index.d.ts +1 -1
- package/dist/esm/services/documentStore/versioned/dynamodb.d.ts +7 -9
- package/dist/esm/services/documentStore/versioned/file-system.d.ts +6 -8
- package/dist/esm/services/documentStore/versioned/index.d.ts +4 -4
- package/dist/esm/services/exercisesGateway/index.d.ts +9 -13
- package/dist/esm/services/fileServer/index.d.ts +2 -3
- package/dist/esm/services/fileServer/localFileServer.d.ts +2 -6
- package/dist/esm/services/fileServer/s3FileServer.d.ts +2 -5
- package/dist/esm/services/launchParams/signer.d.ts +4 -9
- package/dist/esm/services/launchParams/verifier.d.ts +5 -6
- package/dist/esm/services/launchParams/verifier.js +12 -4
- package/dist/esm/services/logger/index.d.ts +2 -2
- package/dist/esm/services/lrsGateway/addStatementDefaultFields.d.ts +1 -1
- package/dist/esm/services/lrsGateway/attempt-utils.d.ts +34 -34
- package/dist/esm/services/lrsGateway/file-system.d.ts +2 -4
- package/dist/esm/services/lrsGateway/index.d.ts +29 -32
- package/dist/esm/services/lrsGateway/xapiUtils.d.ts +23 -23
- package/dist/esm/services/postgresConnection/index.d.ts +3 -10
- package/dist/esm/services/searchProvider/index.d.ts +7 -7
- package/dist/esm/services/searchProvider/memorySearchTheBadWay.d.ts +1 -1
- package/dist/esm/services/searchProvider/openSearch.d.ts +3 -6
- package/dist/esm/services/searchProvider/openSearch.js +7 -3
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +5 -5
- package/package.json +6 -6
- package/script/bin/.init-params-script.bash.swp +0 -0
|
@@ -3,7 +3,7 @@ import { GenericFetch } from '../../fetch';
|
|
|
3
3
|
import { JsonCompatibleStruct } from '../../routing';
|
|
4
4
|
import { ApiUser, ConsentPreferences } from '../authProvider';
|
|
5
5
|
import { Logger } from '../logger';
|
|
6
|
-
export
|
|
6
|
+
export type Config = {
|
|
7
7
|
accountsBase: string;
|
|
8
8
|
accountsAuthToken: string;
|
|
9
9
|
};
|
|
@@ -11,14 +11,14 @@ interface Initializer<C> {
|
|
|
11
11
|
configSpace?: C;
|
|
12
12
|
fetch: GenericFetch;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type FindUserPayload = ({
|
|
15
15
|
external_id: string;
|
|
16
16
|
} | {
|
|
17
17
|
uuid: string;
|
|
18
18
|
}) & {
|
|
19
19
|
sso?: string;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type FindOrCreateUserPayload = {
|
|
22
22
|
external_id: string;
|
|
23
23
|
email?: string;
|
|
24
24
|
already_verified?: boolean;
|
|
@@ -32,45 +32,42 @@ export declare type FindOrCreateUserPayload = {
|
|
|
32
32
|
is_test?: boolean;
|
|
33
33
|
sso?: string;
|
|
34
34
|
};
|
|
35
|
-
export
|
|
35
|
+
export type FindOrCreateUserResponse = {
|
|
36
36
|
id: number;
|
|
37
37
|
uuid: string;
|
|
38
38
|
external_ids: string[];
|
|
39
39
|
is_test: boolean;
|
|
40
40
|
sso: string;
|
|
41
41
|
};
|
|
42
|
-
export
|
|
42
|
+
export type FindUserResponse = (FindOrCreateUserResponse & {
|
|
43
43
|
external_ids: string[];
|
|
44
44
|
}) | undefined;
|
|
45
|
-
export
|
|
45
|
+
export type LinkUserPayload = {
|
|
46
46
|
userId: number;
|
|
47
47
|
externalId: string;
|
|
48
48
|
};
|
|
49
|
-
export
|
|
49
|
+
export type LinkUserResponse = {
|
|
50
50
|
user_id: number;
|
|
51
51
|
external_id: string;
|
|
52
52
|
};
|
|
53
|
-
export
|
|
53
|
+
export type SearchUsersPayload = {
|
|
54
54
|
q: string;
|
|
55
55
|
order_by?: string;
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type SearchUsersResponse = {
|
|
58
58
|
items: Array<ApiUser & {
|
|
59
59
|
external_ids: string[];
|
|
60
60
|
} & JsonCompatibleStruct>;
|
|
61
61
|
total_count: number;
|
|
62
62
|
};
|
|
63
|
-
export
|
|
64
|
-
export
|
|
63
|
+
export type UpdateUserPayload = ConsentPreferences;
|
|
64
|
+
export type MappedUserInfo<T> = {
|
|
65
65
|
data: T;
|
|
66
66
|
fullName: string;
|
|
67
67
|
platformUserId?: string;
|
|
68
68
|
uuid: string;
|
|
69
69
|
};
|
|
70
|
-
export declare const accountsGateway: <C extends string = "accounts">(initializer: Initializer<C>) => (configProvider: { [
|
|
71
|
-
accountsBase: import("../../config").ConfigValueProvider<string>;
|
|
72
|
-
accountsAuthToken: import("../../config").ConfigValueProvider<string>;
|
|
73
|
-
}; }) => ({ logger }: {
|
|
70
|
+
export declare const accountsGateway: <C extends string = "accounts">(initializer: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => ({ logger }: {
|
|
74
71
|
logger: Logger;
|
|
75
72
|
}) => {
|
|
76
73
|
findOrCreateUser: (body: FindOrCreateUserPayload) => Promise<FindOrCreateUserResponse>;
|
|
@@ -79,7 +76,7 @@ export declare const accountsGateway: <C extends string = "accounts">(initialize
|
|
|
79
76
|
linkUser: (body: LinkUserPayload) => Promise<LinkUserResponse>;
|
|
80
77
|
mapUserUuids: <T>(userUuidsMap: {
|
|
81
78
|
[uuid: string]: T;
|
|
82
|
-
}, platformId?: string
|
|
79
|
+
}, platformId?: string) => Promise<{
|
|
83
80
|
data: T;
|
|
84
81
|
fullName: string;
|
|
85
82
|
platformUserId: string | undefined;
|
|
@@ -87,9 +84,9 @@ export declare const accountsGateway: <C extends string = "accounts">(initialize
|
|
|
87
84
|
}[]>;
|
|
88
85
|
searchUsers: (payload: SearchUsersPayload) => Promise<SearchUsersResponse>;
|
|
89
86
|
updateUser: (token: string, body: UpdateUserPayload) => Promise<ApiUser & JsonCompatibleStruct>;
|
|
90
|
-
getUserMap: <R>(userUuids: Set<string>, mapper: (user: ApiUser) => R) => Promise<Map<string, R>>;
|
|
91
|
-
mapUserData: <
|
|
92
|
-
mapUsersData: <
|
|
87
|
+
getUserMap: <R>(userUuids: Set<string>, mapper: ((user: ApiUser) => R)) => Promise<Map<string, R>>;
|
|
88
|
+
mapUserData: <T, R>(input: T[], getUserUuid: (item: T) => string, mapper: ((user: ApiUser | undefined, item: T) => R)) => Promise<R[]>;
|
|
89
|
+
mapUsersData: <T, R_1>(input: T[], getUserUuids: (item: T) => string[], mapper: ((users: Map<string, ApiUser | undefined>, item: T) => R_1)) => Promise<R_1[]>;
|
|
93
90
|
};
|
|
94
|
-
export
|
|
91
|
+
export type AccountsGateway = ReturnType<ReturnType<ReturnType<typeof accountsGateway>>>;
|
|
95
92
|
export {};
|
|
@@ -4,9 +4,9 @@ import { ConfigForFetch, GenericFetch, Response } from '../../fetch';
|
|
|
4
4
|
import { AnyRoute, ApiResponse, OutputForRoute, ParamsForRoute, PayloadForRoute, QueryParams } from '../../routing';
|
|
5
5
|
import { UnwrapPromise } from '../../types';
|
|
6
6
|
import { Logger } from '../logger';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
7
|
+
export type TResponsePayload<R> = R extends ApiResponse<any, infer P> ? P : never;
|
|
8
|
+
export type TResponseStatus<R> = R extends ApiResponse<infer S, any> ? S : never;
|
|
9
|
+
export type RouteClient<R> = {
|
|
10
10
|
(config: {
|
|
11
11
|
fetchConfig?: any;
|
|
12
12
|
query?: QueryParams;
|
|
@@ -25,27 +25,27 @@ export interface AcceptStatus<Ro> {
|
|
|
25
25
|
<S extends TResponseStatus<Ro>[]>(...args: S): Promise<ApiClientResponse<Extract<Ro, Record<'statusCode', S[number]>>>>;
|
|
26
26
|
<S extends number[]>(...args: S): Promise<ApiClientResponse<any>>;
|
|
27
27
|
}
|
|
28
|
-
export
|
|
28
|
+
export type UnsafeApiClientResponse<Ro> = {
|
|
29
29
|
headers: Headers;
|
|
30
30
|
load: () => Promise<any>;
|
|
31
31
|
status: number;
|
|
32
32
|
acceptStatus: AcceptStatus<Ro>;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type ApiClientResponse<Ro> = Ro extends any ? {
|
|
35
35
|
headers: Headers;
|
|
36
36
|
status: TResponseStatus<Ro>;
|
|
37
37
|
load: () => Promise<TResponsePayload<Ro>>;
|
|
38
38
|
} : never;
|
|
39
|
-
export
|
|
39
|
+
export type ExpandRoute<T> = T extends ((...args: infer A) => infer R) & {
|
|
40
40
|
renderUrl: (...args: infer Ar) => Promise<string>;
|
|
41
41
|
} ? (...args: A) => R & {
|
|
42
42
|
renderUrl: (...args: Ar) => Promise<string>;
|
|
43
43
|
} : never;
|
|
44
|
-
export
|
|
44
|
+
export type MapRoutesToClient<Ru> = [Ru] extends [AnyRoute<Ru>] ? {
|
|
45
45
|
[N in Ru['name']]: ExpandRoute<RouteClient<Extract<Ru, Record<'name', N>>>>;
|
|
46
46
|
} : never;
|
|
47
|
-
export
|
|
48
|
-
[
|
|
47
|
+
export type MapRoutesToConfig<Ru> = [Ru] extends [AnyRoute<Ru>] ? {
|
|
48
|
+
[_N in Ru['name']]: {
|
|
49
49
|
path: string;
|
|
50
50
|
method: string;
|
|
51
51
|
};
|
|
@@ -63,6 +63,6 @@ export interface MakeApiGateway<F> {
|
|
|
63
63
|
launchToken?: string;
|
|
64
64
|
}): MapRoutesToClient<Ru>;
|
|
65
65
|
}
|
|
66
|
-
export declare const createApiGateway: <F extends GenericFetch
|
|
66
|
+
export declare const createApiGateway: <F extends GenericFetch>(initializer: {
|
|
67
67
|
fetch: F;
|
|
68
68
|
}) => MakeApiGateway<F>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ConfigProviderForConfig } from '../../config';
|
|
2
2
|
import { FetchConfig, GenericFetch } from '../../fetch';
|
|
3
3
|
import { User } from '.';
|
|
4
|
-
|
|
4
|
+
type Config = {
|
|
5
5
|
accountsBase: string;
|
|
6
6
|
};
|
|
7
7
|
interface Initializer<C> {
|
|
8
8
|
configSpace?: C;
|
|
9
9
|
window: Window;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type EventHandler = (e: {
|
|
12
12
|
data: any;
|
|
13
13
|
origin: string;
|
|
14
14
|
source: Pick<Window, 'postMessage'>;
|
|
@@ -26,10 +26,8 @@ export interface Window {
|
|
|
26
26
|
addEventListener: (event: 'message', callback: EventHandler) => void;
|
|
27
27
|
removeEventListener: (event: 'message', callback: EventHandler) => void;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
30
|
-
export declare const browserAuthProvider: <C extends string = "auth">({ window, configSpace }: Initializer<C>) => (configProvider: { [
|
|
31
|
-
accountsBase: import("../../config").ConfigValueProvider<string>;
|
|
32
|
-
}; }) => {
|
|
29
|
+
export type UpdatableUserFields = Partial<Pick<User, 'consent_preferences' | 'first_name' | 'last_name'>>;
|
|
30
|
+
export declare const browserAuthProvider: <C extends string = "auth">({ window, configSpace }: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => {
|
|
33
31
|
/**
|
|
34
32
|
* gets the authentication token
|
|
35
33
|
*/
|
|
@@ -54,7 +52,7 @@ export declare const browserAuthProvider: <C extends string = "auth">({ window,
|
|
|
54
52
|
*/
|
|
55
53
|
getAuthorizedEmbedUrl: (urlString: string, extraParams?: {
|
|
56
54
|
[key: string]: string;
|
|
57
|
-
}
|
|
55
|
+
}) => string;
|
|
58
56
|
/**
|
|
59
57
|
* gets second argument for `fetch` that has authentication token or cookie
|
|
60
58
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigProviderForConfig } from '../../config';
|
|
2
2
|
import { AuthProvider, CookieAuthProvider } from '.';
|
|
3
|
-
|
|
3
|
+
type Config = {
|
|
4
4
|
cookieName: string;
|
|
5
5
|
encryptionPrivateKey: string;
|
|
6
6
|
signaturePublicKey: string;
|
|
@@ -8,12 +8,8 @@ declare type Config = {
|
|
|
8
8
|
interface Initializer<C> {
|
|
9
9
|
configSpace?: C;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type DecryptionAuthProvider = AuthProvider & {
|
|
12
12
|
getTokenExpiration: (tokenString?: string) => Promise<number | null | undefined>;
|
|
13
13
|
};
|
|
14
|
-
export declare const decryptionAuthProvider: <C extends string = "decryption">(initializer: Initializer<C>) => (configProvider: { [
|
|
15
|
-
cookieName: import("../../config").ConfigValueProvider<string>;
|
|
16
|
-
encryptionPrivateKey: import("../../config").ConfigValueProvider<string>;
|
|
17
|
-
signaturePublicKey: import("../../config").ConfigValueProvider<string>;
|
|
18
|
-
}; }) => CookieAuthProvider<DecryptionAuthProvider>;
|
|
14
|
+
export declare const decryptionAuthProvider: <C extends string = "decryption">(initializer: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => CookieAuthProvider<DecryptionAuthProvider>;
|
|
19
15
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { FetchConfig } from '../../fetch';
|
|
2
2
|
import type { HttpHeaders, QueryParams } from '../../routing';
|
|
3
3
|
import type { Logger } from '../logger';
|
|
4
|
-
export
|
|
4
|
+
export type ConsentPreferences = {
|
|
5
5
|
consent_preferences: {
|
|
6
6
|
accepted: string[];
|
|
7
7
|
rejected: string[];
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type TokenUser = {
|
|
11
11
|
id: number;
|
|
12
12
|
name: string;
|
|
13
13
|
first_name: string;
|
|
@@ -35,8 +35,8 @@ export interface ApiUser extends TokenUser {
|
|
|
35
35
|
signed_contract_names: string[];
|
|
36
36
|
using_openstax: boolean;
|
|
37
37
|
}
|
|
38
|
-
export
|
|
39
|
-
export
|
|
38
|
+
export type User = TokenUser | ApiUser;
|
|
39
|
+
export type AuthProvider = {
|
|
40
40
|
getAuthToken: () => Promise<string | null>;
|
|
41
41
|
getUser: () => Promise<User | undefined>;
|
|
42
42
|
/**
|
|
@@ -44,17 +44,17 @@ export declare type AuthProvider = {
|
|
|
44
44
|
*/
|
|
45
45
|
getAuthorizedFetchConfig: () => Promise<FetchConfig>;
|
|
46
46
|
};
|
|
47
|
-
export
|
|
47
|
+
export type CookieAuthProviderRequest = {
|
|
48
48
|
cookies?: string[];
|
|
49
49
|
headers: HttpHeaders;
|
|
50
50
|
queryStringParameters?: QueryParams;
|
|
51
51
|
};
|
|
52
|
-
export
|
|
52
|
+
export type CookieAuthProvider<T extends AuthProvider = AuthProvider> = (inputs: {
|
|
53
53
|
request: CookieAuthProviderRequest;
|
|
54
54
|
logger: Logger;
|
|
55
55
|
}) => T;
|
|
56
|
-
export
|
|
57
|
-
export declare const stubAuthProvider: (user?: User
|
|
56
|
+
export type StubAuthProvider = (user: User | undefined) => AuthProvider;
|
|
57
|
+
export declare const stubAuthProvider: (user?: User) => AuthProvider;
|
|
58
58
|
export declare const getAuthTokenOrCookie: (request: CookieAuthProviderRequest, cookieName: string, queryKey?: string) => [string, {
|
|
59
59
|
Authorization: string;
|
|
60
60
|
}] | [string, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfigProviderForConfig } from '../../config';
|
|
2
2
|
import { GenericFetch } from '../../fetch';
|
|
3
3
|
import { CookieAuthProvider } from '.';
|
|
4
|
-
|
|
4
|
+
type Config = {
|
|
5
5
|
cookieName: string;
|
|
6
6
|
accountsBase: string;
|
|
7
7
|
};
|
|
@@ -9,8 +9,5 @@ interface Initializer<C> {
|
|
|
9
9
|
configSpace?: C;
|
|
10
10
|
fetch: GenericFetch;
|
|
11
11
|
}
|
|
12
|
-
export declare const subrequestAuthProvider: <C extends string = "subrequest">(initializer: Initializer<C>) => (configProvider: { [
|
|
13
|
-
cookieName: import("../../config").ConfigValueProvider<string>;
|
|
14
|
-
accountsBase: import("../../config").ConfigValueProvider<string>;
|
|
15
|
-
}; }) => CookieAuthProvider;
|
|
12
|
+
export declare const subrequestAuthProvider: <C extends string = "subrequest">(initializer: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => CookieAuthProvider;
|
|
16
13
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { User } from '..';
|
|
3
2
|
export declare const decryptJwe: (jwe: string, encryptionPrivateKey: Buffer | string) => string | undefined;
|
|
4
|
-
|
|
3
|
+
type MaybeAccountsSSOToken = {
|
|
5
4
|
iss?: string;
|
|
6
5
|
sub?: User | string;
|
|
7
6
|
aud?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { User } from '..';
|
|
2
2
|
import { Window } from '../browser';
|
|
3
|
-
export
|
|
3
|
+
export type UserData = {
|
|
4
4
|
user?: User;
|
|
5
5
|
token: string | null;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type UserDataLoader = () => Promise<UserData>;
|
|
8
8
|
export declare enum PostMessageTypes {
|
|
9
9
|
ReceiveUser = "receive-user",
|
|
10
10
|
RequestUser = "request-user"
|
|
@@ -13,14 +13,14 @@ export declare const embeddedAuthProvider: (getUserData: UserDataLoader, { authQ
|
|
|
13
13
|
authQuery?: {
|
|
14
14
|
key: string;
|
|
15
15
|
value: string | null;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
window: Window;
|
|
18
18
|
}) => {
|
|
19
19
|
embeddedQueryKey: string;
|
|
20
20
|
embeddedQueryValue: string;
|
|
21
21
|
getAuthorizedEmbedUrl: (urlString: string, extraParams?: {
|
|
22
22
|
[key: string]: string;
|
|
23
|
-
}
|
|
23
|
+
}) => string;
|
|
24
24
|
unmount: () => void;
|
|
25
25
|
};
|
|
26
26
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthProvider } from '..';
|
|
2
2
|
import { AssertionFailed } from '../../../assertions';
|
|
3
3
|
import { ConfigProviderForConfig } from '../../../config';
|
|
4
|
-
|
|
4
|
+
type Config = {
|
|
5
5
|
application: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const createUserRoleValidator: (auth: AuthProvider, config: ConfigProviderForConfig<Config>) => {
|
|
@@ -9,5 +9,5 @@ export declare const createUserRoleValidator: (auth: AuthProvider, config: Confi
|
|
|
9
9
|
userHasRole: (role: string[]) => Promise<boolean>;
|
|
10
10
|
assertUserRole: (role: string[], fail?: AssertionFailed) => Promise<void>;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type UserRoleValidator = ReturnType<typeof createUserRoleValidator>;
|
|
13
13
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Config = {
|
|
2
2
|
tableName: string;
|
|
3
3
|
};
|
|
4
|
-
export
|
|
4
|
+
export type DocumentBaseMapType = {
|
|
5
5
|
[key: string]: DocumentBaseValueTypes;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
7
|
+
export type DocumentBaseListType = DocumentBaseValueTypes[];
|
|
8
|
+
export type DocumentBaseValueTypes = number | boolean | string | null | DocumentBaseMapType | DocumentBaseListType;
|
|
9
|
+
export type DocumentBaseType = {
|
|
10
10
|
[key: string]: DocumentBaseValueTypes;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
[
|
|
12
|
+
export type TDocument<T> = {
|
|
13
|
+
[_key in keyof T]: DocumentBaseValueTypes;
|
|
14
14
|
};
|
|
@@ -5,14 +5,12 @@ interface Initializer<C> {
|
|
|
5
5
|
configSpace?: C;
|
|
6
6
|
dynamoClient?: DynamoDB;
|
|
7
7
|
}
|
|
8
|
-
export declare const dynamoUnversionedDocumentStore: <C extends string = "dynamodb">(initializer?: Initializer<C>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
batchAfterWrite?: ((items: T[]) => void | Promise<void>) | undefined;
|
|
13
|
-
} | undefined) => {
|
|
8
|
+
export declare const dynamoUnversionedDocumentStore: <C extends string = "dynamodb">(initializer?: Initializer<C>) => <T extends TDocument<T>>() => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => <K extends keyof T>(_: {}, hashKey: K, options?: {
|
|
9
|
+
afterWrite?: (item: T) => void | Promise<void>;
|
|
10
|
+
batchAfterWrite?: (items: T[]) => void | Promise<void>;
|
|
11
|
+
}) => {
|
|
14
12
|
loadAllDocumentsTheBadWay: () => Promise<T[]>;
|
|
15
|
-
getItemsByField: (key: keyof T, value: T[K], pageKey?: string
|
|
13
|
+
getItemsByField: (key: keyof T, value: T[K], pageKey?: string) => Promise<{
|
|
16
14
|
items: T[];
|
|
17
15
|
nextPageToken: string | undefined;
|
|
18
16
|
}>;
|
|
@@ -24,10 +22,10 @@ export declare const dynamoUnversionedDocumentStore: <C extends string = "dynamo
|
|
|
24
22
|
createItem: (item: T) => Promise<T>;
|
|
25
23
|
batchCreateItem: (items: T[], concurrency?: number) => Promise<{
|
|
26
24
|
successful: T[];
|
|
27
|
-
failed: {
|
|
25
|
+
failed: Array<{
|
|
28
26
|
item: T;
|
|
29
27
|
error: Error;
|
|
30
|
-
}
|
|
28
|
+
}>;
|
|
31
29
|
}>;
|
|
32
30
|
};
|
|
33
31
|
export {};
|
|
@@ -5,14 +5,12 @@ interface Initializer<C> {
|
|
|
5
5
|
fs?: Pick<typeof import('fs'), 'mkdir' | 'readdir' | 'readFile' | 'writeFile'>;
|
|
6
6
|
configSpace?: C;
|
|
7
7
|
}
|
|
8
|
-
export declare const fileSystemUnversionedDocumentStore: <C extends string = "fileSystem">(initializer: Initializer<C>) => <T extends TDocument<T>>() => (configProvider: { [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
batchAfterWrite?: ((items: T[]) => void | Promise<void>) | undefined;
|
|
13
|
-
} | undefined) => {
|
|
8
|
+
export declare const fileSystemUnversionedDocumentStore: <C extends string = "fileSystem">(initializer: Initializer<C>) => <T extends TDocument<T>>() => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => <K extends keyof T>(_: {}, hashKey: K, options?: {
|
|
9
|
+
afterWrite?: (item: T) => void | Promise<void>;
|
|
10
|
+
batchAfterWrite?: (items: T[]) => void | Promise<void>;
|
|
11
|
+
}) => {
|
|
14
12
|
loadAllDocumentsTheBadWay: () => Promise<T[]>;
|
|
15
|
-
getItemsByField: (key: keyof T, value: T[K], pageKey?: string
|
|
13
|
+
getItemsByField: (key: keyof T, value: T[K], pageKey?: string) => Promise<{
|
|
16
14
|
items: T[];
|
|
17
15
|
nextPageToken: string | undefined;
|
|
18
16
|
}>;
|
|
@@ -24,10 +22,10 @@ export declare const fileSystemUnversionedDocumentStore: <C extends string = "fi
|
|
|
24
22
|
createItem: (item: T) => Promise<T>;
|
|
25
23
|
batchCreateItem: (items: T[], _concurrency?: number) => Promise<{
|
|
26
24
|
successful: T[];
|
|
27
|
-
failed: {
|
|
25
|
+
failed: Array<{
|
|
28
26
|
item: T;
|
|
29
27
|
error: Error;
|
|
30
|
-
}
|
|
28
|
+
}>;
|
|
31
29
|
}>;
|
|
32
30
|
};
|
|
33
31
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { dynamoUnversionedDocumentStore } from './dynamodb';
|
|
2
|
-
export
|
|
2
|
+
export type UnversionedDocumentStoreCreator = typeof dynamoUnversionedDocumentStore;
|
|
@@ -6,21 +6,19 @@ interface Initializer<C> {
|
|
|
6
6
|
configSpace?: C;
|
|
7
7
|
dynamoClient?: DynamoDB;
|
|
8
8
|
}
|
|
9
|
-
export declare const dynamoVersionedDocumentStore: <C extends string = "dynamodb">(initializer?: Initializer<C>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
getAuthor?: A | undefined;
|
|
14
|
-
} | undefined) => {
|
|
9
|
+
export declare const dynamoVersionedDocumentStore: <C extends string = "dynamodb">(initializer?: Initializer<C>) => <T extends VersionedTDocument<T>>() => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => <K extends keyof T, A extends undefined | ((...a: any[]) => Promise<VersionedDocumentAuthor>)>(_: {}, hashKey: K, options?: {
|
|
10
|
+
afterWrite?: (item: T) => void | Promise<void>;
|
|
11
|
+
getAuthor?: A;
|
|
12
|
+
}) => {
|
|
15
13
|
loadAllDocumentsTheBadWay: () => Promise<T[]>;
|
|
16
|
-
getVersions: (id: T[K], startVersion?: number
|
|
14
|
+
getVersions: (id: T[K], startVersion?: number) => Promise<{
|
|
17
15
|
items: T[];
|
|
18
16
|
nextPageToken: number | undefined;
|
|
19
17
|
} | undefined>;
|
|
20
|
-
getItem: (id: T[K], timestamp?: number
|
|
18
|
+
getItem: (id: T[K], timestamp?: number) => Promise<T | undefined>;
|
|
21
19
|
prepareItem: (item: Omit<T, "timestamp" | "author">, ...authorArgs: A extends Function ? Parameters<A> : [VersionedDocumentAuthor]) => Promise<{
|
|
22
20
|
document: T;
|
|
23
|
-
save: (changes?: Partial<Omit<T, "timestamp" | "author">>
|
|
21
|
+
save: (changes?: Partial<Omit<T, "timestamp" | "author">>) => Promise<T>;
|
|
24
22
|
}>;
|
|
25
23
|
putItem: (item: Omit<T, "timestamp" | "author">, ...authorArgs: A extends Function ? Parameters<A> : [VersionedDocumentAuthor]) => Promise<T>;
|
|
26
24
|
};
|
|
@@ -6,20 +6,18 @@ interface Initializer<C> {
|
|
|
6
6
|
fs?: Pick<typeof import('fs'), 'mkdir' | 'readdir' | 'readFile' | 'writeFile'>;
|
|
7
7
|
configSpace?: C;
|
|
8
8
|
}
|
|
9
|
-
export declare const fileSystemVersionedDocumentStore: <C extends string = "fileSystem">(initializer: Initializer<C>) => <T extends VersionedTDocument<T>>() => (configProvider: { [
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
getAuthor?: A | undefined;
|
|
13
|
-
} | undefined) => {
|
|
9
|
+
export declare const fileSystemVersionedDocumentStore: <C extends string = "fileSystem">(initializer: Initializer<C>) => <T extends VersionedTDocument<T>>() => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => <K extends keyof T, A extends undefined | ((...a: any[]) => Promise<VersionedDocumentAuthor>)>(_: {}, hashKey: K, options?: {
|
|
10
|
+
getAuthor?: A;
|
|
11
|
+
}) => {
|
|
14
12
|
loadAllDocumentsTheBadWay: () => Promise<T[]>;
|
|
15
|
-
getVersions: (id: T[K], startVersion?: number
|
|
13
|
+
getVersions: (id: T[K], startVersion?: number) => Promise<{
|
|
16
14
|
items: T[];
|
|
17
15
|
nextPageToken: number | undefined;
|
|
18
16
|
} | undefined>;
|
|
19
|
-
getItem: (id: T[K], timestamp?: number
|
|
17
|
+
getItem: (id: T[K], timestamp?: number) => Promise<T | undefined>;
|
|
20
18
|
prepareItem: (item: Omit<T, "timestamp" | "author">, ...authorArgs: A extends Function ? Parameters<A> : [VersionedDocumentAuthor]) => Promise<{
|
|
21
19
|
document: T;
|
|
22
|
-
save: (changes?: Partial<Omit<T, "timestamp" | "author">>
|
|
20
|
+
save: (changes?: Partial<Omit<T, "timestamp" | "author">>) => Promise<T>;
|
|
23
21
|
}>;
|
|
24
22
|
putItem: (item: Omit<T, "timestamp" | "author">, ...authorArgs: A extends Function ? Parameters<A> : [VersionedDocumentAuthor]) => Promise<T>;
|
|
25
23
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TDocument } from '..';
|
|
2
2
|
import { dynamoVersionedDocumentStore } from './dynamodb';
|
|
3
|
-
export
|
|
3
|
+
export type VersionedDocumentAuthor = {
|
|
4
4
|
type: 'user';
|
|
5
5
|
uuid: string;
|
|
6
6
|
name: string;
|
|
@@ -9,9 +9,9 @@ export declare type VersionedDocumentAuthor = {
|
|
|
9
9
|
type: 'system';
|
|
10
10
|
reason: string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type VersionedDocumentRequiredFields = {
|
|
13
13
|
timestamp: number;
|
|
14
14
|
author: VersionedDocumentAuthor;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
17
|
-
export
|
|
16
|
+
export type VersionedTDocument<T> = TDocument<T> & VersionedDocumentRequiredFields;
|
|
17
|
+
export type VersionedDocumentStoreCreator = typeof dynamoVersionedDocumentStore;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigProviderForConfig } from '../../config';
|
|
2
2
|
import { GenericFetch } from '../../fetch';
|
|
3
|
-
export
|
|
3
|
+
export type Config = {
|
|
4
4
|
defaultCorrectness?: string;
|
|
5
5
|
exercisesHost: string;
|
|
6
6
|
exercisesAuthToken: string;
|
|
@@ -9,18 +9,18 @@ interface Initializer<C> {
|
|
|
9
9
|
configSpace?: C;
|
|
10
10
|
fetch: GenericFetch;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type Answer = {
|
|
13
13
|
id: number;
|
|
14
14
|
content_html: string;
|
|
15
15
|
correctness?: string;
|
|
16
16
|
feedback_html?: string;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type Solution = {
|
|
19
19
|
images: any[];
|
|
20
20
|
solution_type: string;
|
|
21
21
|
content_html: string;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type Question = {
|
|
24
24
|
id: number;
|
|
25
25
|
is_answer_order_important: boolean;
|
|
26
26
|
stimulus_html: string;
|
|
@@ -32,7 +32,7 @@ export declare type Question = {
|
|
|
32
32
|
collaborator_solutions?: Solution[];
|
|
33
33
|
community_solutions?: Solution[];
|
|
34
34
|
};
|
|
35
|
-
export
|
|
35
|
+
export type Exercise = {
|
|
36
36
|
images: any[];
|
|
37
37
|
tags: string[];
|
|
38
38
|
uuid: string;
|
|
@@ -51,21 +51,17 @@ export declare type Exercise = {
|
|
|
51
51
|
versions: number[];
|
|
52
52
|
stimulus_html: string;
|
|
53
53
|
};
|
|
54
|
-
export
|
|
54
|
+
export type ExercisesSearchResults = {
|
|
55
55
|
total_count: number;
|
|
56
56
|
items: Exercise[];
|
|
57
57
|
};
|
|
58
|
-
export
|
|
58
|
+
export type ExercisesSearchResultsWithDigest = ExercisesSearchResults & {
|
|
59
59
|
digest: string;
|
|
60
60
|
};
|
|
61
|
-
export declare const exercisesGateway: <C extends string = "exercises">(initializer: Initializer<C>) => (configProvider: { [
|
|
62
|
-
defaultCorrectness?: import("../../config").ConfigValueProvider<string> | undefined;
|
|
63
|
-
exercisesHost: import("../../config").ConfigValueProvider<string>;
|
|
64
|
-
exercisesAuthToken: import("../../config").ConfigValueProvider<string>;
|
|
65
|
-
}; }) => (_: {}) => {
|
|
61
|
+
export declare const exercisesGateway: <C extends string = "exercises">(initializer: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => (_: {}) => {
|
|
66
62
|
searchDigest: (query: string, page?: number, per_page?: number) => Promise<string>;
|
|
67
63
|
get: (uuid: string) => Promise<Exercise | undefined>;
|
|
68
64
|
search: (query: string, page?: number, per_page?: number) => Promise<ExercisesSearchResultsWithDigest>;
|
|
69
65
|
};
|
|
70
|
-
export
|
|
66
|
+
export type ExercisesGateway = ReturnType<ReturnType<ReturnType<typeof exercisesGateway>>>;
|
|
71
67
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type FileValue = {
|
|
1
|
+
export type FileValue = {
|
|
3
2
|
dataType: 'file';
|
|
4
3
|
mimeType: string;
|
|
5
4
|
path: string;
|
|
6
5
|
label: string;
|
|
7
6
|
};
|
|
8
|
-
export
|
|
7
|
+
export type FolderValue = {
|
|
9
8
|
dataType: 'folder';
|
|
10
9
|
files: FileValue[];
|
|
11
10
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigProviderForConfig } from '../../config';
|
|
2
2
|
import { FileServerAdapter } from '.';
|
|
3
|
-
export
|
|
3
|
+
export type Config = {
|
|
4
4
|
port?: string;
|
|
5
5
|
host?: string;
|
|
6
6
|
storagePrefix: string;
|
|
@@ -9,9 +9,5 @@ interface Initializer<C> {
|
|
|
9
9
|
dataDir: string;
|
|
10
10
|
configSpace?: C;
|
|
11
11
|
}
|
|
12
|
-
export declare const localFileServer: <C extends string = "local">(initializer: Initializer<C>) => (configProvider: { [
|
|
13
|
-
port?: import("../../config").ConfigValueProvider<string> | undefined;
|
|
14
|
-
host?: import("../../config").ConfigValueProvider<string> | undefined;
|
|
15
|
-
storagePrefix: import("../../config").ConfigValueProvider<string>;
|
|
16
|
-
}; }) => FileServerAdapter;
|
|
12
|
+
export declare const localFileServer: <C extends string = "local">(initializer: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => FileServerAdapter;
|
|
17
13
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
2
|
import { ConfigProviderForConfig } from '../../config';
|
|
3
3
|
import { FileServerAdapter } from '.';
|
|
4
|
-
export
|
|
4
|
+
export type Config = {
|
|
5
5
|
bucketName: string;
|
|
6
6
|
bucketRegion: string;
|
|
7
7
|
};
|
|
@@ -9,8 +9,5 @@ interface Initializer<C> {
|
|
|
9
9
|
configSpace?: C;
|
|
10
10
|
getS3Client?: (...args: ConstructorParameters<typeof S3Client>) => S3Client;
|
|
11
11
|
}
|
|
12
|
-
export declare const s3FileServer: <C extends string = "deployed">(initializer: Initializer<C>) => (configProvider: { [
|
|
13
|
-
bucketName: import("../../config").ConfigValueProvider<string>;
|
|
14
|
-
bucketRegion: import("../../config").ConfigValueProvider<string>;
|
|
15
|
-
}; }) => FileServerAdapter;
|
|
12
|
+
export declare const s3FileServer: <C extends string = "deployed">(initializer: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => FileServerAdapter;
|
|
16
13
|
export {};
|