dce-reactkit 3.12.1-beta-cross-server.8 → 4.0.0-beta-date-and-time.1

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.
Files changed (92) hide show
  1. package/.vscode/settings.json +3 -1
  2. package/README.md +0 -20
  3. package/dist/cjs/index.js +7838 -15905
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/types/components/ItemPicker/index.d.ts +1 -0
  6. package/dist/cjs/types/components/LoadingSpinner.d.ts +2 -2
  7. package/dist/cjs/types/components/Modal/ModalProps.d.ts +2 -0
  8. package/dist/cjs/types/components/SimpleDateChooser.d.ts +3 -1
  9. package/dist/cjs/types/components/SimpleTimeChooser.d.ts +20 -0
  10. package/dist/cjs/types/components/TabBox.d.ts +1 -0
  11. package/dist/cjs/types/components/Tooltip.d.ts +1 -1
  12. package/dist/cjs/types/helpers/getWordCount.d.ts +10 -0
  13. package/dist/cjs/types/index.d.ts +13 -13
  14. package/dist/cjs/types/types/ParamType.d.ts +10 -10
  15. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +2 -28
  16. package/dist/esm/index.js +6661 -14723
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/types/components/ItemPicker/index.d.ts +1 -0
  19. package/dist/esm/types/components/LoadingSpinner.d.ts +2 -2
  20. package/dist/esm/types/components/Modal/ModalProps.d.ts +2 -0
  21. package/dist/esm/types/components/SimpleDateChooser.d.ts +3 -1
  22. package/dist/esm/types/components/SimpleTimeChooser.d.ts +20 -0
  23. package/dist/esm/types/components/TabBox.d.ts +1 -0
  24. package/dist/esm/types/components/Tooltip.d.ts +1 -1
  25. package/dist/esm/types/helpers/getWordCount.d.ts +10 -0
  26. package/dist/esm/types/index.d.ts +13 -13
  27. package/dist/esm/types/types/ParamType.d.ts +10 -10
  28. package/dist/esm/types/types/ReactKitErrorCode.d.ts +2 -28
  29. package/dist/index.d.ts +189 -379
  30. package/package.json +5 -11
  31. package/src/components/AppWrapper.tsx +3 -1
  32. package/src/components/CheckboxButton.tsx +1 -1
  33. package/src/components/Dropdown.tsx +1 -1
  34. package/src/components/IntelliTable.tsx +1 -1
  35. package/src/components/ItemPicker/NestableItemList.tsx +1 -0
  36. package/src/components/ItemPicker/index.tsx +96 -0
  37. package/src/components/LogReviewer.tsx +2 -2
  38. package/src/components/Modal/ModalProps.ts +4 -0
  39. package/src/components/Modal/index.tsx +60 -21
  40. package/src/components/RadioButton.tsx +3 -1
  41. package/src/components/SimpleDateChooser.tsx +62 -26
  42. package/src/components/SimpleTimeChooser.tsx +195 -0
  43. package/src/components/TabBox.tsx +27 -9
  44. package/src/components/Tooltip.tsx +1 -1
  45. package/src/helpers/getWordCount.ts +26 -0
  46. package/src/{client → helpers}/initClient.tsx +5 -1
  47. package/src/helpers/logClientEvent.tsx +3 -1
  48. package/src/helpers/visitServerEndpoint.tsx +1 -1
  49. package/src/index.ts +22 -24
  50. package/src/types/ParamType.ts +10 -10
  51. package/src/types/ReactKitErrorCode.tsx +3 -31
  52. package/dist/cjs/types/components/ItemPicker/index.test.d.ts +0 -1
  53. package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +0 -41
  54. package/dist/cjs/types/helpers/dataSigner.d.ts +0 -40
  55. package/dist/cjs/types/helpers/genRouteHandler.d.ts +0 -76
  56. package/dist/cjs/types/helpers/handleError.d.ts +0 -18
  57. package/dist/cjs/types/helpers/handleSuccess.d.ts +0 -8
  58. package/dist/cjs/types/helpers/parseUserAgent.d.ts +0 -17
  59. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -20
  60. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -27
  61. package/dist/cjs/types/server/initCrossServerCredentialCollection.d.ts +0 -8
  62. package/dist/cjs/types/server/initLogCollection.d.ts +0 -8
  63. package/dist/cjs/types/server/initServer.d.ts +0 -53
  64. package/dist/cjs/types/types/CrossServerCredential.d.ts +0 -11
  65. package/dist/esm/types/components/ItemPicker/index.test.d.ts +0 -1
  66. package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +0 -41
  67. package/dist/esm/types/helpers/dataSigner.d.ts +0 -40
  68. package/dist/esm/types/helpers/genRouteHandler.d.ts +0 -76
  69. package/dist/esm/types/helpers/handleError.d.ts +0 -18
  70. package/dist/esm/types/helpers/handleSuccess.d.ts +0 -8
  71. package/dist/esm/types/helpers/parseUserAgent.d.ts +0 -17
  72. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -20
  73. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -27
  74. package/dist/esm/types/server/initCrossServerCredentialCollection.d.ts +0 -8
  75. package/dist/esm/types/server/initLogCollection.d.ts +0 -8
  76. package/dist/esm/types/server/initServer.d.ts +0 -53
  77. package/dist/esm/types/types/CrossServerCredential.d.ts +0 -11
  78. package/src/components/ItemPicker/index.test.tsx +0 -783
  79. package/src/helpers/addDBEditorEndpoints.ts +0 -128
  80. package/src/helpers/dataSigner.ts +0 -342
  81. package/src/helpers/genRouteHandler.ts +0 -911
  82. package/src/helpers/handleError.ts +0 -65
  83. package/src/helpers/handleSuccess.ts +0 -18
  84. package/src/helpers/parseUserAgent.ts +0 -108
  85. package/src/helpers/visitEndpointOnAnotherServer/index.ts +0 -152
  86. package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +0 -162
  87. package/src/server/initCrossServerCredentialCollection.ts +0 -16
  88. package/src/server/initLogCollection.ts +0 -27
  89. package/src/server/initServer.ts +0 -305
  90. package/src/types/CrossServerCredential.ts +0 -16
  91. /package/dist/cjs/types/{client → helpers}/initClient.d.ts +0 -0
  92. /package/dist/esm/types/{client → helpers}/initClient.d.ts +0 -0
@@ -1,76 +0,0 @@
1
- import ParamType from '../types/ParamType';
2
- import LogFunction from '../types/LogFunction';
3
- /**
4
- * Generate an express API route handler
5
- * @author Gabe Abrams
6
- * @param opts object containing all arguments
7
- * @param opts.paramTypes map containing the types for each parameter that is
8
- * included in the request (map: param name => type)
9
- * @param opts.handler function that processes the request
10
- * @param [opts.crossServerScope] the scope associated with this endpoint.
11
- * If defined, this is a cross-server endpoint, which will never
12
- * have any launch data, will never check Canvas roles or launch status, and will
13
- * instead use scopes and reactkit credentials to sign and validate requests.
14
- * Never start the path with /api/ttm or /api/admin if the endpoint is a cross-server
15
- * endpoint because those roles will not be validated
16
- * @param [opts.skipSessionCheck=true if crossServerScope defined] if true, skip
17
- * the session check (allow users to not be logged in and launched via LTI).
18
- * If crossServerScope is defined, this is always true
19
- * @param [opts.unhandledErrorMessagePrefix] if included, when an error that
20
- * is not of type ErrorWithCode is thrown, the client will receive an error
21
- * where the error message is prefixed with this string. For example,
22
- * if unhandledErrorMessagePrefix is
23
- * 'While saving progress, we encountered an error:'
24
- * and the error is 'progressInfo is not an object',
25
- * the client will receive an error with the message
26
- * 'While saving progress, we encountered an error: progressInfo is not an object'
27
- * @returns express route handler that takes the following arguments:
28
- * params (map: param name => value),
29
- * req (express request object),
30
- * next (express next function),
31
- * send (a function that sends a string to the client),
32
- * redirect (takes a url and redirects the user to that url),
33
- * renderErrorPage (shows a static error page to the user),
34
- * renderInfoPage (shows a static info page to the user),
35
- * renderCustomHTML (renders custom html and sends it to the user),
36
- * and returns the value to send to the client as a JSON API response, or
37
- * calls next() or redirect(...) or send(...) or renderErrorPage(...).
38
- * Note: params also has userId, userFirstName,
39
- * userLastName, userEmail, userAvatarURL, isLearner, isTTM, isAdmin,
40
- * and any other variables that
41
- * are directly added to the session, if the user does have a session.
42
- */
43
- declare const genRouteHandler: (opts: {
44
- paramTypes?: {
45
- [k: string]: ParamType;
46
- } | undefined;
47
- handler: (opts: {
48
- params: {
49
- [k: string]: any;
50
- };
51
- req: any;
52
- next: () => void;
53
- redirect: (pathOrURL: string) => void;
54
- send: (text: string, status?: number) => void;
55
- renderErrorPage: (opts?: {
56
- title?: string;
57
- description?: string;
58
- code?: string;
59
- pageTitle?: string;
60
- status?: number;
61
- }) => void;
62
- renderInfoPage: (opts: {
63
- title: string;
64
- body: string;
65
- }) => void;
66
- renderCustomHTML: (opts: {
67
- html: string;
68
- status?: number;
69
- }) => void;
70
- logServerEvent: LogFunction;
71
- }) => any;
72
- crossServerScope?: string | undefined;
73
- skipSessionCheck?: boolean | undefined;
74
- unhandledErrorMessagePrefix?: string | undefined;
75
- }) => (req: any, res: any, next: () => void) => Promise<undefined>;
76
- export default genRouteHandler;
@@ -1,18 +0,0 @@
1
- /**
2
- * Handle an error and respond to the client
3
- * @author Gabe Abrams
4
- * @param res express response
5
- * @param error error info
6
- * @param opts.err the error to send to the client
7
- * or the error message
8
- * @param [opts.code] an error code (only used if err.code is not
9
- * included)
10
- * @param [opts.status=500] the https status code to use
11
- * defined)
12
- */
13
- declare const handleError: (res: any, error: ({
14
- message: any;
15
- code?: string;
16
- status?: number;
17
- } | Error | string | any)) => undefined;
18
- export default handleError;
@@ -1,8 +0,0 @@
1
- /**
2
- * Send successful API response
3
- * @author Gabe Abrams
4
- * @param res express response
5
- * @param body the body of the response to send to the client
6
- */
7
- declare const handleSuccess: (res: any, body: any) => undefined;
8
- export default handleSuccess;
@@ -1,17 +0,0 @@
1
- /**
2
- * Perform a rudimentary parsing of the user's browser agent string
3
- * @author Gabe Abrams
4
- * @param userAgent the user's browser agent
5
- * @returns user info
6
- */
7
- declare const parseUserAgent: (userAgent: string) => {
8
- browser: {
9
- name: string;
10
- version: string;
11
- };
12
- device: {
13
- isMobile: boolean;
14
- os: string;
15
- };
16
- };
17
- export default parseUserAgent;
@@ -1,20 +0,0 @@
1
- /**
2
- * Visit an endpoint on another server
3
- * @author Gabe Abrams
4
- * @param opts object containing all arguments
5
- * @param opts.method the method of the endpoint
6
- * @param opts.path the path of the other server's endpoint
7
- * @param opts.host the host of the other server
8
- * @param [opts.params={}] query/body parameters to include
9
- * @param [opts.responseType=JSON] the response type from the other server
10
- */
11
- declare const visitEndpointOnAnotherServer: (opts: {
12
- method: 'GET' | 'POST' | 'DELETE' | 'PUT';
13
- path: string;
14
- host: string;
15
- params?: {
16
- [x: string]: any;
17
- } | undefined;
18
- responseType?: "Text" | "JSON" | undefined;
19
- }) => Promise<any>;
20
- export default visitEndpointOnAnotherServer;
@@ -1,27 +0,0 @@
1
- /**
2
- * Sends and retries an http request
3
- * @author Gabriel Abrams
4
- * @param opts object containing all arguments
5
- * @param opts.path path to send request to
6
- * @param [opts.host] host to send request to
7
- * @param [opts.method=GET] http method to use
8
- * @param [opts.params] body/data to include in the request
9
- * @param [opts.responseType=JSON] expected response type
10
- * @returns { body, status, headers } on success
11
- */
12
- declare const sendServerToServerRequest: (opts: {
13
- path: string;
14
- host?: string | undefined;
15
- method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
16
- params?: {
17
- [x: string]: any;
18
- } | undefined;
19
- responseType?: "Text" | "JSON" | undefined;
20
- }) => Promise<{
21
- body: any;
22
- status: number;
23
- headers: {
24
- [x: string]: any;
25
- };
26
- }>;
27
- export default sendServerToServerRequest;
@@ -1,8 +0,0 @@
1
- /**
2
- * Initialize a cross-server credential collection given the dce-mango Collection class
3
- * @author Gabe Abrams
4
- * @param Collection the Collection class from dce-mango
5
- * @returns initialized logCollection
6
- */
7
- declare const initCrossServerCredentialCollection: (Collection: any) => any;
8
- export default initCrossServerCredentialCollection;
@@ -1,8 +0,0 @@
1
- /**
2
- * Initialize a log collection given the dce-mango Collection class
3
- * @author Gabe Abrams
4
- * @param Collection the Collection class from dce-mango
5
- * @returns initialized logCollection
6
- */
7
- declare const initLogCollection: (Collection: any) => any;
8
- export default initLogCollection;
@@ -1,53 +0,0 @@
1
- type GetLaunchInfoFunction = (req: any) => {
2
- launched: boolean;
3
- launchInfo?: any;
4
- };
5
- /**
6
- * Get launch info via CACCL
7
- * @author Gabe Abrams
8
- * @param req express request object
9
- * @returns object { launched, launchInfo }
10
- */
11
- export declare const cacclGetLaunchInfo: GetLaunchInfoFunction;
12
- /**
13
- * Get log collection
14
- * @author Gabe Abrams
15
- * @returns log collection if one was included during launch or null if we don't
16
- * have a log collection (yet)
17
- */
18
- export declare const internalGetLogCollection: () => any;
19
- /**
20
- * Get cross-server credential collection
21
- * @author Gabe Abrams
22
- * @return cross-server credential collection if one was included during launch or null
23
- * if we don't have a cross-server credential collection (yet)
24
- */
25
- export declare const internalGetCrossServerCredentialCollection: () => any;
26
- /**
27
- * Prepare dce-reactkit to run on the server
28
- * @author Gabe Abrams
29
- * @param opts object containing all arguments
30
- * @param opts.app express app from inside of the postprocessor function that
31
- * we will add routes to
32
- * @param opts.getLaunchInfo CACCL LTI's get launch info function
33
- * @param [opts.logCollection] mongo collection from dce-mango to use for
34
- * storing logs. If none is included, logs are written to the console
35
- * @param [opts.logReviewAdmins=all] info on which admins can review
36
- * logs from the client. If not included, all Canvas admins are allowed to
37
- * review logs. If null, no Canvas admins are allowed to review logs.
38
- * If an array of Canvas userIds (numbers), only Canvas admins with those
39
- * userIds are allowed to review logs. If a dce-mango collection, only
40
- * Canvas admins with entries in that collection ({ userId, ...}) are allowed
41
- * to review logs
42
- * @param [opts.crossServerCredentialCollection] mongo collection from dce-mango to use for
43
- * storing cross-server credentials. If none is included, cross-server credentials
44
- * are not supported
45
- */
46
- declare const initServer: (opts: {
47
- app: any;
48
- getLaunchInfo: GetLaunchInfoFunction;
49
- logCollection?: any;
50
- logReviewAdmins?: (number[] | any);
51
- crossServerCredentialCollection?: any;
52
- }) => void;
53
- export default initServer;
@@ -1,11 +0,0 @@
1
- /**
2
- * Single cross-server credential
3
- * @author Gabe Abrams
4
- */
5
- type CrossServerCredential = {
6
- description: string;
7
- key: string;
8
- encodedeSecret: string;
9
- scopes: string[];
10
- };
11
- export default CrossServerCredential;
@@ -1 +0,0 @@
1
- export {};
@@ -1,41 +0,0 @@
1
- import express from 'express';
2
- /**
3
- * Interface for a collection in the database
4
- * @author Yuen Ler Chow
5
- */
6
- type DCEMangoCollection = {
7
- /**
8
- * Find all items in the collection that match the filter query
9
- * @param filterQuery query for the filter
10
- * @returns list of items that match the filter query
11
- */
12
- find: (filterQuery: any) => Promise<any[]>;
13
- /**
14
- * Insert an item into the collection
15
- * @param item the item to insert
16
- */
17
- insert: (item: any) => Promise<void>;
18
- /**
19
- * Delete an item in the collection
20
- * @param id the id of the item to delete
21
- */
22
- delete: (filterQuery: {
23
- id: string;
24
- }) => Promise<void>;
25
- };
26
- /**
27
- * Add all routes for the DBEditor
28
- * @author Yuen Ler Chow
29
- * @param opts object containing all arguments
30
- * @param opts.app express app to add routes too
31
- * @param opts.collectionName the name of the collection
32
- * @param opts.adminsOnly true if the endpoint is for admins only
33
- * @param opts.collection dce-mango db collection
34
- */
35
- declare const addDBEditorEndpoints: (opts: {
36
- app: express.Application;
37
- collectionName: string;
38
- adminsOnly: boolean;
39
- collection: DCEMangoCollection;
40
- }) => void;
41
- export default addDBEditorEndpoints;
@@ -1,40 +0,0 @@
1
- /**
2
- * Sign a request and get the new request params
3
- * @author Gabe Abrams
4
- * @param opts object containing all arguments
5
- * @param opts.method the method to sign
6
- * @param opts.path the http request path
7
- * @param opts.params the data in the body to sign
8
- * @param opts.key the reactkit key to sign with
9
- * @param opts.secret the reactkit secret to sign with
10
- * @return augmented params for the request, including a signature, timestamp, and key
11
- */
12
- export declare const signRequest: (opts: {
13
- method: string;
14
- path: string;
15
- params: {
16
- [key: string]: any;
17
- };
18
- key: string;
19
- secret: string;
20
- }) => Promise<{
21
- [key: string]: any;
22
- }>;
23
- /**
24
- * Validate a signed request. Throws an error if invalid
25
- * @author Gabe Abrams
26
- * @param opts object containing all arguments
27
- * @param opts.method the method of the data validate
28
- * @param opts.path the http request path to validate
29
- * @param opts.scope the name of the scope to validate
30
- * @param opts.params the request data to validate
31
- * @returns parsed and validated params
32
- */
33
- export declare const validateSignedRequest: (opts: {
34
- method: string;
35
- path: string;
36
- scope: string;
37
- params: {
38
- [key: string]: any;
39
- };
40
- }) => Promise<void>;
@@ -1,76 +0,0 @@
1
- import ParamType from '../types/ParamType';
2
- import LogFunction from '../types/LogFunction';
3
- /**
4
- * Generate an express API route handler
5
- * @author Gabe Abrams
6
- * @param opts object containing all arguments
7
- * @param opts.paramTypes map containing the types for each parameter that is
8
- * included in the request (map: param name => type)
9
- * @param opts.handler function that processes the request
10
- * @param [opts.crossServerScope] the scope associated with this endpoint.
11
- * If defined, this is a cross-server endpoint, which will never
12
- * have any launch data, will never check Canvas roles or launch status, and will
13
- * instead use scopes and reactkit credentials to sign and validate requests.
14
- * Never start the path with /api/ttm or /api/admin if the endpoint is a cross-server
15
- * endpoint because those roles will not be validated
16
- * @param [opts.skipSessionCheck=true if crossServerScope defined] if true, skip
17
- * the session check (allow users to not be logged in and launched via LTI).
18
- * If crossServerScope is defined, this is always true
19
- * @param [opts.unhandledErrorMessagePrefix] if included, when an error that
20
- * is not of type ErrorWithCode is thrown, the client will receive an error
21
- * where the error message is prefixed with this string. For example,
22
- * if unhandledErrorMessagePrefix is
23
- * 'While saving progress, we encountered an error:'
24
- * and the error is 'progressInfo is not an object',
25
- * the client will receive an error with the message
26
- * 'While saving progress, we encountered an error: progressInfo is not an object'
27
- * @returns express route handler that takes the following arguments:
28
- * params (map: param name => value),
29
- * req (express request object),
30
- * next (express next function),
31
- * send (a function that sends a string to the client),
32
- * redirect (takes a url and redirects the user to that url),
33
- * renderErrorPage (shows a static error page to the user),
34
- * renderInfoPage (shows a static info page to the user),
35
- * renderCustomHTML (renders custom html and sends it to the user),
36
- * and returns the value to send to the client as a JSON API response, or
37
- * calls next() or redirect(...) or send(...) or renderErrorPage(...).
38
- * Note: params also has userId, userFirstName,
39
- * userLastName, userEmail, userAvatarURL, isLearner, isTTM, isAdmin,
40
- * and any other variables that
41
- * are directly added to the session, if the user does have a session.
42
- */
43
- declare const genRouteHandler: (opts: {
44
- paramTypes?: {
45
- [k: string]: ParamType;
46
- } | undefined;
47
- handler: (opts: {
48
- params: {
49
- [k: string]: any;
50
- };
51
- req: any;
52
- next: () => void;
53
- redirect: (pathOrURL: string) => void;
54
- send: (text: string, status?: number) => void;
55
- renderErrorPage: (opts?: {
56
- title?: string;
57
- description?: string;
58
- code?: string;
59
- pageTitle?: string;
60
- status?: number;
61
- }) => void;
62
- renderInfoPage: (opts: {
63
- title: string;
64
- body: string;
65
- }) => void;
66
- renderCustomHTML: (opts: {
67
- html: string;
68
- status?: number;
69
- }) => void;
70
- logServerEvent: LogFunction;
71
- }) => any;
72
- crossServerScope?: string | undefined;
73
- skipSessionCheck?: boolean | undefined;
74
- unhandledErrorMessagePrefix?: string | undefined;
75
- }) => (req: any, res: any, next: () => void) => Promise<undefined>;
76
- export default genRouteHandler;
@@ -1,18 +0,0 @@
1
- /**
2
- * Handle an error and respond to the client
3
- * @author Gabe Abrams
4
- * @param res express response
5
- * @param error error info
6
- * @param opts.err the error to send to the client
7
- * or the error message
8
- * @param [opts.code] an error code (only used if err.code is not
9
- * included)
10
- * @param [opts.status=500] the https status code to use
11
- * defined)
12
- */
13
- declare const handleError: (res: any, error: ({
14
- message: any;
15
- code?: string;
16
- status?: number;
17
- } | Error | string | any)) => undefined;
18
- export default handleError;
@@ -1,8 +0,0 @@
1
- /**
2
- * Send successful API response
3
- * @author Gabe Abrams
4
- * @param res express response
5
- * @param body the body of the response to send to the client
6
- */
7
- declare const handleSuccess: (res: any, body: any) => undefined;
8
- export default handleSuccess;
@@ -1,17 +0,0 @@
1
- /**
2
- * Perform a rudimentary parsing of the user's browser agent string
3
- * @author Gabe Abrams
4
- * @param userAgent the user's browser agent
5
- * @returns user info
6
- */
7
- declare const parseUserAgent: (userAgent: string) => {
8
- browser: {
9
- name: string;
10
- version: string;
11
- };
12
- device: {
13
- isMobile: boolean;
14
- os: string;
15
- };
16
- };
17
- export default parseUserAgent;
@@ -1,20 +0,0 @@
1
- /**
2
- * Visit an endpoint on another server
3
- * @author Gabe Abrams
4
- * @param opts object containing all arguments
5
- * @param opts.method the method of the endpoint
6
- * @param opts.path the path of the other server's endpoint
7
- * @param opts.host the host of the other server
8
- * @param [opts.params={}] query/body parameters to include
9
- * @param [opts.responseType=JSON] the response type from the other server
10
- */
11
- declare const visitEndpointOnAnotherServer: (opts: {
12
- method: 'GET' | 'POST' | 'DELETE' | 'PUT';
13
- path: string;
14
- host: string;
15
- params?: {
16
- [x: string]: any;
17
- } | undefined;
18
- responseType?: "Text" | "JSON" | undefined;
19
- }) => Promise<any>;
20
- export default visitEndpointOnAnotherServer;
@@ -1,27 +0,0 @@
1
- /**
2
- * Sends and retries an http request
3
- * @author Gabriel Abrams
4
- * @param opts object containing all arguments
5
- * @param opts.path path to send request to
6
- * @param [opts.host] host to send request to
7
- * @param [opts.method=GET] http method to use
8
- * @param [opts.params] body/data to include in the request
9
- * @param [opts.responseType=JSON] expected response type
10
- * @returns { body, status, headers } on success
11
- */
12
- declare const sendServerToServerRequest: (opts: {
13
- path: string;
14
- host?: string | undefined;
15
- method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
16
- params?: {
17
- [x: string]: any;
18
- } | undefined;
19
- responseType?: "Text" | "JSON" | undefined;
20
- }) => Promise<{
21
- body: any;
22
- status: number;
23
- headers: {
24
- [x: string]: any;
25
- };
26
- }>;
27
- export default sendServerToServerRequest;
@@ -1,8 +0,0 @@
1
- /**
2
- * Initialize a cross-server credential collection given the dce-mango Collection class
3
- * @author Gabe Abrams
4
- * @param Collection the Collection class from dce-mango
5
- * @returns initialized logCollection
6
- */
7
- declare const initCrossServerCredentialCollection: (Collection: any) => any;
8
- export default initCrossServerCredentialCollection;
@@ -1,8 +0,0 @@
1
- /**
2
- * Initialize a log collection given the dce-mango Collection class
3
- * @author Gabe Abrams
4
- * @param Collection the Collection class from dce-mango
5
- * @returns initialized logCollection
6
- */
7
- declare const initLogCollection: (Collection: any) => any;
8
- export default initLogCollection;
@@ -1,53 +0,0 @@
1
- type GetLaunchInfoFunction = (req: any) => {
2
- launched: boolean;
3
- launchInfo?: any;
4
- };
5
- /**
6
- * Get launch info via CACCL
7
- * @author Gabe Abrams
8
- * @param req express request object
9
- * @returns object { launched, launchInfo }
10
- */
11
- export declare const cacclGetLaunchInfo: GetLaunchInfoFunction;
12
- /**
13
- * Get log collection
14
- * @author Gabe Abrams
15
- * @returns log collection if one was included during launch or null if we don't
16
- * have a log collection (yet)
17
- */
18
- export declare const internalGetLogCollection: () => any;
19
- /**
20
- * Get cross-server credential collection
21
- * @author Gabe Abrams
22
- * @return cross-server credential collection if one was included during launch or null
23
- * if we don't have a cross-server credential collection (yet)
24
- */
25
- export declare const internalGetCrossServerCredentialCollection: () => any;
26
- /**
27
- * Prepare dce-reactkit to run on the server
28
- * @author Gabe Abrams
29
- * @param opts object containing all arguments
30
- * @param opts.app express app from inside of the postprocessor function that
31
- * we will add routes to
32
- * @param opts.getLaunchInfo CACCL LTI's get launch info function
33
- * @param [opts.logCollection] mongo collection from dce-mango to use for
34
- * storing logs. If none is included, logs are written to the console
35
- * @param [opts.logReviewAdmins=all] info on which admins can review
36
- * logs from the client. If not included, all Canvas admins are allowed to
37
- * review logs. If null, no Canvas admins are allowed to review logs.
38
- * If an array of Canvas userIds (numbers), only Canvas admins with those
39
- * userIds are allowed to review logs. If a dce-mango collection, only
40
- * Canvas admins with entries in that collection ({ userId, ...}) are allowed
41
- * to review logs
42
- * @param [opts.crossServerCredentialCollection] mongo collection from dce-mango to use for
43
- * storing cross-server credentials. If none is included, cross-server credentials
44
- * are not supported
45
- */
46
- declare const initServer: (opts: {
47
- app: any;
48
- getLaunchInfo: GetLaunchInfoFunction;
49
- logCollection?: any;
50
- logReviewAdmins?: (number[] | any);
51
- crossServerCredentialCollection?: any;
52
- }) => void;
53
- export default initServer;
@@ -1,11 +0,0 @@
1
- /**
2
- * Single cross-server credential
3
- * @author Gabe Abrams
4
- */
5
- type CrossServerCredential = {
6
- description: string;
7
- key: string;
8
- encodedeSecret: string;
9
- scopes: string[];
10
- };
11
- export default CrossServerCredential;