@crimson-education/replit-sdk 1.0.1-alpha-11 → 1.0.1-alpha-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +5 -1
- package/lib/functions/index.d.ts +49 -0
- package/lib/functions/index.d.ts.map +1 -0
- package/lib/functions/index.js +85 -0
- package/lib/functions/index.js.map +1 -0
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -14,5 +14,9 @@ we are going to embed the app on a iframe, so now you need to do all things one
|
|
|
14
14
|
</QueryClientProvider>
|
|
15
15
|
);
|
|
16
16
|
}```
|
|
17
|
-
3.
|
|
17
|
+
3. set Express proxy endpint,
|
|
18
|
+
4. use the ExternalLink component to replace all the <a> tag which has a external link.
|
|
19
|
+
5. set dev capp endpoint when build app like ```
|
|
20
|
+
import { setStoredParams } from "@crimson-education/replit-sdk/lib/hooks/use-url-params";
|
|
21
|
+
setStoredParams({'cappEndpoint': 'http://6d94f1eb.r8.cpolar.top/graphql'});```
|
|
18
22
|
````
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const fetchLoginUserQuery = "query fetchLoginUser($userId: String!) {\n user: user(userId: $userId) {\n userId\n firstName\n lastName\n email\n role\n userRoles\n avatar\n }\n}";
|
|
2
|
+
export interface CrimsonUser {
|
|
3
|
+
userId: string;
|
|
4
|
+
firstName: string;
|
|
5
|
+
lastName: string;
|
|
6
|
+
email: string;
|
|
7
|
+
role: string;
|
|
8
|
+
userRoles: string[];
|
|
9
|
+
avatar?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function fetchLoginUser(userId?: string): Promise<CrimsonUser>;
|
|
12
|
+
export declare const fetchOurPeopleMyStudentsByRolesQuery = "query fetchOurPeopleMyStudentsByRoles(\n $pagination: paginationParams!\n $principalUid: String\n $roles: [String!]\n $filter: MyStudentsFilter\n $orders: OurPeopleMyStudentsOrders\n) {\n fetchOurPeopleMyStudentsByRoles: fetchOurPeopleMyStudentsByRoles(\n pagination: $pagination\n principalUid: $principalUid\n roles: $roles\n filter: $filter\n orders: $orders\n ) {\n results {\n userId\n email\n timezone\n firstName\n lastName\n avatar\n studentInfo {\n yearOfApplication\n essayFolder\n }\n lastAccess\n }\n pagination {\n totalPages\n totalCount\n pageSize\n pageNumber\n }\n }\n}";
|
|
13
|
+
export interface StudentResult {
|
|
14
|
+
userId: string;
|
|
15
|
+
email: string;
|
|
16
|
+
firstName: string;
|
|
17
|
+
lastName: string;
|
|
18
|
+
timezone?: string;
|
|
19
|
+
avatar?: string;
|
|
20
|
+
activatedAt?: string;
|
|
21
|
+
location?: string;
|
|
22
|
+
applicationYear?: number;
|
|
23
|
+
subjects?: string[];
|
|
24
|
+
lastStrategyMeetingAt?: string;
|
|
25
|
+
userRoles?: string[];
|
|
26
|
+
roles?: Array<{
|
|
27
|
+
isPrimary: boolean;
|
|
28
|
+
roleId: string;
|
|
29
|
+
role: {
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
studentInfo?: {
|
|
34
|
+
yearOfApplication?: number;
|
|
35
|
+
essayFolder?: string;
|
|
36
|
+
};
|
|
37
|
+
lastAccess?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface FetchStudentsResult {
|
|
40
|
+
results: StudentResult[];
|
|
41
|
+
pagination: {
|
|
42
|
+
totalPages: number;
|
|
43
|
+
totalCount: number;
|
|
44
|
+
pageSize: number;
|
|
45
|
+
pageNumber: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export declare function fetchMyStudents(principalUid: string, roles: string[], pageNumber?: number, pageSize?: number): Promise<FetchStudentsResult>;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,+KAU9B,CAAC;AAEH,MAAM,WAAW,WAAW;IAC1B,MA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ACnB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,wBAAsB,eAAe,CACnC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EAAE,EACf,UAAU,GAAE,MAAU,EACtB,QAAQ,GAAE,MAAW,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAoB9B"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchOurPeopleMyStudentsByRolesQuery = exports.fetchLoginUserQuery = void 0;
|
|
4
|
+
exports.fetchLoginUser = fetchLoginUser;
|
|
5
|
+
exports.fetchMyStudents = fetchMyStudents;
|
|
6
|
+
const use_url_params_1 = require("../hooks/use-url-params");
|
|
7
|
+
const queryClient_1 = require("../utils/queryClient");
|
|
8
|
+
exports.fetchLoginUserQuery = `query fetchLoginUser($userId: String!) {
|
|
9
|
+
user: user(userId: $userId) {
|
|
10
|
+
userId
|
|
11
|
+
firstName
|
|
12
|
+
lastName
|
|
13
|
+
email
|
|
14
|
+
role
|
|
15
|
+
userRoles
|
|
16
|
+
avatar
|
|
17
|
+
}
|
|
18
|
+
}`;
|
|
19
|
+
async function fetchLoginUser(userId) {
|
|
20
|
+
var _a;
|
|
21
|
+
const finalUserId = userId || (0, use_url_params_1.getStoredUserId)();
|
|
22
|
+
const res = await (0, queryClient_1.apiRequest)(exports.fetchLoginUserQuery, { userId: finalUserId });
|
|
23
|
+
const json = await res.json();
|
|
24
|
+
if (json.errors && json.errors.length > 0) {
|
|
25
|
+
throw new Error(`Failed to fetch user: ${json.errors[0].message}`);
|
|
26
|
+
}
|
|
27
|
+
if (!((_a = json.data) === null || _a === void 0 ? void 0 : _a.user)) {
|
|
28
|
+
throw new Error(`User not found: ${userId}`);
|
|
29
|
+
}
|
|
30
|
+
return json.data.user;
|
|
31
|
+
}
|
|
32
|
+
exports.fetchOurPeopleMyStudentsByRolesQuery = `query fetchOurPeopleMyStudentsByRoles(
|
|
33
|
+
$pagination: paginationParams!
|
|
34
|
+
$principalUid: String
|
|
35
|
+
$roles: [String!]
|
|
36
|
+
$filter: MyStudentsFilter
|
|
37
|
+
$orders: OurPeopleMyStudentsOrders
|
|
38
|
+
) {
|
|
39
|
+
fetchOurPeopleMyStudentsByRoles: fetchOurPeopleMyStudentsByRoles(
|
|
40
|
+
pagination: $pagination
|
|
41
|
+
principalUid: $principalUid
|
|
42
|
+
roles: $roles
|
|
43
|
+
filter: $filter
|
|
44
|
+
orders: $orders
|
|
45
|
+
) {
|
|
46
|
+
results {
|
|
47
|
+
userId
|
|
48
|
+
email
|
|
49
|
+
timezone
|
|
50
|
+
firstName
|
|
51
|
+
lastName
|
|
52
|
+
avatar
|
|
53
|
+
studentInfo {
|
|
54
|
+
yearOfApplication
|
|
55
|
+
essayFolder
|
|
56
|
+
}
|
|
57
|
+
lastAccess
|
|
58
|
+
}
|
|
59
|
+
pagination {
|
|
60
|
+
totalPages
|
|
61
|
+
totalCount
|
|
62
|
+
pageSize
|
|
63
|
+
pageNumber
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}`;
|
|
67
|
+
async function fetchMyStudents(principalUid, roles, pageNumber = 1, pageSize = 10) {
|
|
68
|
+
var _a;
|
|
69
|
+
const variables = {
|
|
70
|
+
pagination: { pageNumber, pageSize },
|
|
71
|
+
principalUid,
|
|
72
|
+
roles,
|
|
73
|
+
filter: {},
|
|
74
|
+
};
|
|
75
|
+
const res = await (0, queryClient_1.apiRequest)(exports.fetchOurPeopleMyStudentsByRolesQuery, variables);
|
|
76
|
+
const json = await res.json();
|
|
77
|
+
if (json.errors && json.errors.length > 0) {
|
|
78
|
+
throw new Error(`Failed to fetch students: ${json.errors[0].message}`);
|
|
79
|
+
}
|
|
80
|
+
return (((_a = json.data) === null || _a === void 0 ? void 0 : _a.fetchOurPeopleMyStudentsByRoles) || {
|
|
81
|
+
results: [],
|
|
82
|
+
pagination: { totalPages: 0, totalCount: 0, pageSize, pageNumber },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;AAyBA,wCAcC;AAyED,0CAyBC;AAzID,4DAA0D;AAC1D,sDAAkD;AAErC,QAAA,mBAAmB,GAAG;;;;;;;;;;EAUjC,CAAC;AAYI,KAAK,UAAU,cAAc,CAAC,MAAe;;IAClD,MAAM,WAAW,GAAG,MAAM,IAAI,IAAA,gCAAe,GAAE,CAAC;IAChD,MAAM,GAAG,GAAG,MAAM,IAAA,wBAAU,EAAC,2BAAmB,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAE9B,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,CAAA,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACxB,CAAC;AAEY,QAAA,oCAAoC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkClD,CAAC;AAqCI,KAAK,UAAU,eAAe,CACnC,YAAoB,EACpB,KAAe,EACf,aAAqB,CAAC,EACtB,WAAmB,EAAE;;IAErB,MAAM,SAAS,GAAG;QAChB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