@eliceio/cdk-cli 1.6.0-entryqa.1 → 1.6.0-entryqa.2
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/es/dev/learner-files.d.ts +88 -0
- package/es/dev/learner-files.js +282 -0
- package/es/dev/mock-api.d.ts +13 -0
- package/es/dev/mock-api.js +27 -3
- package/es/dev/server.d.ts +3 -0
- package/es/dev/server.js +35 -1
- package/es/rules/csp.d.ts +1 -0
- package/es/rules/csp.js +2 -0
- package/package.json +2 -2
- package/templates/_shared/lib/cdk-mock.d.ts +18 -0
- package/templates/_shared/lib/cdk-mock.js +45 -0
- package/templates/_shared/lib/elice-content.d.ts +22 -0
- package/templates/_shared/lib/elice-content.js +50 -0
- package/templates/entry/README.md +13 -1
- package/templates/entry/core/ml-data.d.ts +51 -0
- package/templates/entry/core/ml-data.js +480 -0
- package/templates/entry/core/workspace.d.ts +2 -0
- package/templates/entry/core/workspace.js +21 -1
- package/templates/entry/docs/storage.md +3 -0
- package/templates/entry/screens/edit/panels/grading.js +10 -3
- package/templates/entry/screens/edit.js +1 -0
- package/templates/entry/screens/learn.js +22 -2
- package/templates/entry/template.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* 학생 파일(엔트리 AI 학습 데이터 · 모델) 올리기 · 보기 흉내 (dev 전용). elice-material 명세 기준:
|
|
4
|
+
* 1. SDK `learnerFiles.post` → 흉내 API `POST /storage/upload-url` `{ key: "learner/{folder}/{file}", content_length,
|
|
5
|
+
* content_type }` (learn 토큰, 튜터 403) → `{ upload_url, key: "learners/{material}/{account}/{folder}/{file}" }`.
|
|
6
|
+
* 학생 × 자료마다 1분에 30번까지, 넘으면 429 `MATERIAL_TOO_MANY_LEARNER_UPLOADS`
|
|
7
|
+
* 2. SDK가 `upload_url`로 Azure 블록 업로드(PUT `?comp=block&blockid=…` 여러 번 + `?comp=blocklist`), 또는 PUT 한 번 →
|
|
8
|
+
* 콘텐츠 서버 `/__ecdk/blob/learners/…`가 받아 `.ecdk/learners/{material}/{account}/…`에 둔다
|
|
9
|
+
* 3. 흉내 API `GET /materials/{id}/learner-files/url` → `{ base_url, key_prefix, expires_at }`. 파일 주소는 base_url +
|
|
10
|
+
* (key에서 key_prefix를 뺀 것). base_url은 폴더 서명 prefix `{API}/s/{exp}.{sig}/learners/{material}/{account}/`,
|
|
11
|
+
* key_prefix는 `learners/{material}/{account}/`, 그 아래 파일을 흉내 API가 내준다 (상대 경로가 풀림)
|
|
12
|
+
* 주인은 kv 흉내와 같이 토큰 account (튜터 토큰은 보고 있는 학생). 운영 서버 명세에 없는 학생 × 자료 합계 한도는 흉내 내지 않는다.
|
|
13
|
+
*/
|
|
14
|
+
/** 받은 학생 파일을 두는 곳 (프로젝트 기준). `.ecdk/`라 감시 · zip에서 빠진다 */
|
|
15
|
+
export declare const LEARNERS_DIR = ".ecdk/learners";
|
|
16
|
+
/** 서명 주소 유효 시간 (초). 운영 TTL은 명세에 없음 */
|
|
17
|
+
export declare const LEARNER_BASE_URL_TTL_SECONDS = 3600;
|
|
18
|
+
/** 학생 × 자료마다 1분에 발급하는 업로드 주소 수 */
|
|
19
|
+
export declare const LEARNER_UPLOADS_PER_MINUTE = 30;
|
|
20
|
+
export declare const LEARNER_RATE_ERROR_CODE = "MATERIAL_TOO_MANY_LEARNER_UPLOADS";
|
|
21
|
+
/** 확장자 → 받는 Content-Type(처음 것이 내줄 때 형식) · 최대 크기. svg는 없음 */
|
|
22
|
+
export declare const LEARNER_FILE_KINDS: Readonly<Record<string, {
|
|
23
|
+
types: string[];
|
|
24
|
+
maxBytes: number;
|
|
25
|
+
}>>;
|
|
26
|
+
/** 발급한 학생 파일 업로드 (저장 키 → 허용 크기 · 받은 블록). 끝나면 지운다 */
|
|
27
|
+
export type PendingLearnerUploads = Map<string, {
|
|
28
|
+
allowed: number;
|
|
29
|
+
blocks: Map<string, Buffer>;
|
|
30
|
+
}>;
|
|
31
|
+
/** 학생 × 자료(`{material}/{account}`)마다 최근 1분 동안 업로드 주소를 발급한 시각들 (ms) */
|
|
32
|
+
export type LearnerUploadRate = Map<string, number[]>;
|
|
33
|
+
export type LearnerUploadUrlResult = {
|
|
34
|
+
ok: true;
|
|
35
|
+
data: {
|
|
36
|
+
upload_url: string;
|
|
37
|
+
key: string;
|
|
38
|
+
expires_in: number;
|
|
39
|
+
};
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
status: number;
|
|
43
|
+
code: string;
|
|
44
|
+
message: string;
|
|
45
|
+
details?: unknown[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* `POST /storage/upload-url`의 `learner/{folder}/{file}` 흉내: 이름 규칙 · 종류 · 크기 · 1분 30번을 보고 PUT할 주소를
|
|
49
|
+
* 준다. 권한(learn 토큰, 튜터 403)은 부르는 쪽(mock-api)이 본다.
|
|
50
|
+
* 오류: 규칙에 안 맞는 key · 모르는 확장자 · svg는 400 INVALID_INPUT `unsupported_upload_kind`, 다른 content_type은
|
|
51
|
+
* `unsupported_content_type`, 크기 0은 INVALID_INPUT, 종류 한도 초과 MATERIAL_PACKAGE_TOO_LARGE(`max_bytes`),
|
|
52
|
+
* 1분 30번 초과 429 MATERIAL_TOO_MANY_LEARNER_UPLOADS (운영 HTTP 상태는 명세에 없어 429로 둠). `rate`가 없으면 횟수를 세지 않는다
|
|
53
|
+
*/
|
|
54
|
+
export declare function createLearnerUploadUrl(body: unknown, opts: {
|
|
55
|
+
dir: string;
|
|
56
|
+
materialId: string;
|
|
57
|
+
accountId: number;
|
|
58
|
+
uploadOrigin: string;
|
|
59
|
+
pending: PendingLearnerUploads;
|
|
60
|
+
rate?: LearnerUploadRate;
|
|
61
|
+
now?: number;
|
|
62
|
+
}): Promise<LearnerUploadUrlResult>;
|
|
63
|
+
/**
|
|
64
|
+
* 콘텐츠 서버 `PUT /__ecdk/blob/learners/…`: 발급한 주소만, 알린 크기까지 받아 `.ecdk/learners/…`에 둔다.
|
|
65
|
+
* Azure 블록 업로드(`comp=block` · `comp=blocklist`, SDK가 쓰는 방식)와 PUT 한 번 둘 다 받는다.
|
|
66
|
+
* 처리했으면 true, 이 경로가 아니면 false
|
|
67
|
+
*/
|
|
68
|
+
export declare function handleLearnerBlobPut(req: IncomingMessage, res: ServerResponse, url: URL, opts: {
|
|
69
|
+
dir: string;
|
|
70
|
+
pending: PendingLearnerUploads;
|
|
71
|
+
log?: (m: string) => void;
|
|
72
|
+
}): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* `GET /materials/{id}/learner-files/url`의 응답: 주인 폴더 서명 주소, 파일 key에서 뺄 `key_prefix`, 만료 시각(ISO).
|
|
75
|
+
* @param apiSignedOrigin 서명 경로를 붙일 흉내 API 주소 (`{host}/api`)
|
|
76
|
+
*/
|
|
77
|
+
export declare function learnerFolderUrl(apiSignedOrigin: string, materialId: string, accountId: number, now?: number): {
|
|
78
|
+
base_url: string;
|
|
79
|
+
key_prefix: string;
|
|
80
|
+
expires_at: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 흉내 API `GET · HEAD /s/{exp}.{sig}/learners/{material}/{account}/{folder}/{file}`: 서명이 그 학생 폴더의 것이고
|
|
84
|
+
* 만료 전이면 받은 파일을 내준다. 서명 경로가 아니면 false (다른 처리로 넘김)
|
|
85
|
+
*/
|
|
86
|
+
export declare function serveLearnerFile(req: IncomingMessage, res: ServerResponse, signedPath: string, dir: string): Promise<boolean>;
|
|
87
|
+
/** "처음 상태로": 받은 학생 파일도 지운다 */
|
|
88
|
+
export declare const removeLearnerFiles: (dir: string) => Promise<void>;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual, createHmac } from 'node:crypto';
|
|
2
|
+
import { createReadStream } from 'node:fs';
|
|
3
|
+
import { mkdir, writeFile, rename, stat, rm } from 'node:fs/promises';
|
|
4
|
+
import { join, dirname } from 'node:path';
|
|
5
|
+
import { pipeline } from 'node:stream/promises';
|
|
6
|
+
import { DEV_BLOB_PREFIX } from './assets.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 학생 파일(엔트리 AI 학습 데이터 · 모델) 올리기 · 보기 흉내 (dev 전용). elice-material 명세 기준:
|
|
10
|
+
* 1. SDK `learnerFiles.post` → 흉내 API `POST /storage/upload-url` `{ key: "learner/{folder}/{file}", content_length,
|
|
11
|
+
* content_type }` (learn 토큰, 튜터 403) → `{ upload_url, key: "learners/{material}/{account}/{folder}/{file}" }`.
|
|
12
|
+
* 학생 × 자료마다 1분에 30번까지, 넘으면 429 `MATERIAL_TOO_MANY_LEARNER_UPLOADS`
|
|
13
|
+
* 2. SDK가 `upload_url`로 Azure 블록 업로드(PUT `?comp=block&blockid=…` 여러 번 + `?comp=blocklist`), 또는 PUT 한 번 →
|
|
14
|
+
* 콘텐츠 서버 `/__ecdk/blob/learners/…`가 받아 `.ecdk/learners/{material}/{account}/…`에 둔다
|
|
15
|
+
* 3. 흉내 API `GET /materials/{id}/learner-files/url` → `{ base_url, key_prefix, expires_at }`. 파일 주소는 base_url +
|
|
16
|
+
* (key에서 key_prefix를 뺀 것). base_url은 폴더 서명 prefix `{API}/s/{exp}.{sig}/learners/{material}/{account}/`,
|
|
17
|
+
* key_prefix는 `learners/{material}/{account}/`, 그 아래 파일을 흉내 API가 내준다 (상대 경로가 풀림)
|
|
18
|
+
* 주인은 kv 흉내와 같이 토큰 account (튜터 토큰은 보고 있는 학생). 운영 서버 명세에 없는 학생 × 자료 합계 한도는 흉내 내지 않는다.
|
|
19
|
+
*/
|
|
20
|
+
/** 받은 학생 파일을 두는 곳 (프로젝트 기준). `.ecdk/`라 감시 · zip에서 빠진다 */
|
|
21
|
+
const LEARNERS_DIR = '.ecdk/learners';
|
|
22
|
+
/** 서명 주소 유효 시간 (초). 운영 TTL은 명세에 없음 */
|
|
23
|
+
const LEARNER_BASE_URL_TTL_SECONDS = 3600;
|
|
24
|
+
/** 학생 × 자료마다 1분에 발급하는 업로드 주소 수 */
|
|
25
|
+
const LEARNER_UPLOADS_PER_MINUTE = 30;
|
|
26
|
+
const LEARNER_RATE_ERROR_CODE = 'MATERIAL_TOO_MANY_LEARNER_UPLOADS';
|
|
27
|
+
const MB = 1024 * 1024;
|
|
28
|
+
/** 확장자 → 받는 Content-Type(처음 것이 내줄 때 형식) · 최대 크기. svg는 없음 */
|
|
29
|
+
const LEARNER_FILE_KINDS = Object.freeze({
|
|
30
|
+
json: {
|
|
31
|
+
types: ['application/json'],
|
|
32
|
+
maxBytes: 20 * MB
|
|
33
|
+
},
|
|
34
|
+
bin: {
|
|
35
|
+
types: ['application/octet-stream'],
|
|
36
|
+
maxBytes: 50 * MB
|
|
37
|
+
},
|
|
38
|
+
wav: {
|
|
39
|
+
types: ['audio/wav', 'audio/x-wav', 'audio/wave'],
|
|
40
|
+
maxBytes: 10 * MB
|
|
41
|
+
},
|
|
42
|
+
mp3: {
|
|
43
|
+
types: ['audio/mpeg'],
|
|
44
|
+
maxBytes: 10 * MB
|
|
45
|
+
},
|
|
46
|
+
png: {
|
|
47
|
+
types: ['image/png'],
|
|
48
|
+
maxBytes: 10 * MB
|
|
49
|
+
},
|
|
50
|
+
jpg: {
|
|
51
|
+
types: ['image/jpeg'],
|
|
52
|
+
maxBytes: 10 * MB
|
|
53
|
+
},
|
|
54
|
+
jpeg: {
|
|
55
|
+
types: ['image/jpeg'],
|
|
56
|
+
maxBytes: 10 * MB
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const NAME = '[A-Za-z0-9_-]+';
|
|
60
|
+
/** folder: 이름 1~4단 (서버 규칙) */
|
|
61
|
+
const FOLDER = new RegExp(`^${NAME}(/${NAME}){0,3}$`);
|
|
62
|
+
/** file: `[A-Za-z0-9_.-]`, 마지막 `.` 뒤가 확장자 (서버 규칙. SDK는 `..` · 맨 앞 `.`을 더 막는다) */
|
|
63
|
+
const FILE_CHARS = '[A-Za-z0-9_.-]*\\.[A-Za-z0-9]+';
|
|
64
|
+
const FILE = new RegExp(`^${FILE_CHARS}$`);
|
|
65
|
+
/** 저장 키 `learners/{material}/{account}/{folder}/{file}` */
|
|
66
|
+
const STORAGE_KEY = new RegExp(`^learners/([0-9a-f-]{36})/(\\d+)/(${NAME}(?:/${NAME}){0,3})/(${FILE_CHARS})$`);
|
|
67
|
+
const UPLOAD_URL_EXPIRES_IN = 900;
|
|
68
|
+
const unsupported = (message, reason = 'unsupported_upload_kind') => ({
|
|
69
|
+
ok: false,
|
|
70
|
+
status: 400,
|
|
71
|
+
code: 'INVALID_INPUT',
|
|
72
|
+
message,
|
|
73
|
+
details: [{
|
|
74
|
+
msg: message,
|
|
75
|
+
type: 'app_exception_detail',
|
|
76
|
+
ctx: {
|
|
77
|
+
field: 'key',
|
|
78
|
+
reason
|
|
79
|
+
}
|
|
80
|
+
}]
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* `POST /storage/upload-url`의 `learner/{folder}/{file}` 흉내: 이름 규칙 · 종류 · 크기 · 1분 30번을 보고 PUT할 주소를
|
|
84
|
+
* 준다. 권한(learn 토큰, 튜터 403)은 부르는 쪽(mock-api)이 본다.
|
|
85
|
+
* 오류: 규칙에 안 맞는 key · 모르는 확장자 · svg는 400 INVALID_INPUT `unsupported_upload_kind`, 다른 content_type은
|
|
86
|
+
* `unsupported_content_type`, 크기 0은 INVALID_INPUT, 종류 한도 초과 MATERIAL_PACKAGE_TOO_LARGE(`max_bytes`),
|
|
87
|
+
* 1분 30번 초과 429 MATERIAL_TOO_MANY_LEARNER_UPLOADS (운영 HTTP 상태는 명세에 없어 429로 둠). `rate`가 없으면 횟수를 세지 않는다
|
|
88
|
+
*/
|
|
89
|
+
async function createLearnerUploadUrl(body, opts) {
|
|
90
|
+
const b = body && typeof body === 'object' ? body : {};
|
|
91
|
+
const key = typeof b.key === 'string' ? b.key : '';
|
|
92
|
+
const rest = key.slice('learner/'.length);
|
|
93
|
+
const slash = rest.lastIndexOf('/');
|
|
94
|
+
const folder = rest.slice(0, slash);
|
|
95
|
+
const file = rest.slice(slash + 1);
|
|
96
|
+
if (!key.startsWith('learner/') || slash < 1 || !FOLDER.test(folder) || !FILE.test(file)) return unsupported('key: learner/{folder}/{file}, folder 1-4 names of [A-Za-z0-9_-] joined by /, file of [A-Za-z0-9_.-] with an extension');
|
|
97
|
+
const ext = file.slice(file.lastIndexOf('.') + 1).toLowerCase();
|
|
98
|
+
const kind = LEARNER_FILE_KINDS[ext];
|
|
99
|
+
if (!kind) return unsupported(`key: .${ext} is not taken (json, bin, wav, mp3, png, jpg, jpeg)`);
|
|
100
|
+
const type = b.content_type ?? b.contentType;
|
|
101
|
+
if (type != null && (typeof type !== 'string' || !kind.types.includes(type))) return unsupported(`content_type: ${kind.types.join(' | ')} for .${ext}`, 'unsupported_content_type');
|
|
102
|
+
const length = Number(b.content_length ?? b.contentLength);
|
|
103
|
+
if (!Number.isInteger(length) || length <= 0) return {
|
|
104
|
+
ok: false,
|
|
105
|
+
status: 400,
|
|
106
|
+
code: 'INVALID_INPUT',
|
|
107
|
+
message: 'content_length: 1 byte or more'
|
|
108
|
+
};
|
|
109
|
+
if (length > kind.maxBytes) return {
|
|
110
|
+
ok: false,
|
|
111
|
+
status: 400,
|
|
112
|
+
code: 'MATERIAL_PACKAGE_TOO_LARGE',
|
|
113
|
+
message: `content_length: up to ${kind.maxBytes} bytes (${kind.maxBytes / MB}MB)`,
|
|
114
|
+
details: [{
|
|
115
|
+
msg: 'too large',
|
|
116
|
+
type: 'app_exception_detail',
|
|
117
|
+
ctx: {
|
|
118
|
+
max_bytes: kind.maxBytes
|
|
119
|
+
}
|
|
120
|
+
}]
|
|
121
|
+
};
|
|
122
|
+
if (opts.rate) {
|
|
123
|
+
const now = opts.now ?? Date.now();
|
|
124
|
+
const rateKey = `${opts.materialId}/${opts.accountId}`;
|
|
125
|
+
const recent = (opts.rate.get(rateKey) ?? []).filter(t => t > now - 60_000);
|
|
126
|
+
if (recent.length >= LEARNER_UPLOADS_PER_MINUTE) {
|
|
127
|
+
opts.rate.set(rateKey, recent);
|
|
128
|
+
return {
|
|
129
|
+
ok: false,
|
|
130
|
+
status: 429,
|
|
131
|
+
code: LEARNER_RATE_ERROR_CODE,
|
|
132
|
+
message: `up to ${LEARNER_UPLOADS_PER_MINUTE} learner uploads a minute per material`
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
opts.rate.set(rateKey, [...recent, now]);
|
|
136
|
+
}
|
|
137
|
+
const storageKey = `learners/${opts.materialId}/${opts.accountId}/${folder}/${file}`;
|
|
138
|
+
opts.pending.set(storageKey, {
|
|
139
|
+
allowed: length,
|
|
140
|
+
blocks: new Map()
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
ok: true,
|
|
144
|
+
data: {
|
|
145
|
+
upload_url: `${opts.uploadOrigin}${DEV_BLOB_PREFIX}${storageKey}?sig=dev`,
|
|
146
|
+
key: storageKey,
|
|
147
|
+
expires_in: UPLOAD_URL_EXPIRES_IN
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function readBody(req, limit) {
|
|
152
|
+
const chunks = [];
|
|
153
|
+
let size = 0;
|
|
154
|
+
for await (const chunk of req) {
|
|
155
|
+
size += chunk.length;
|
|
156
|
+
if (size > limit) return null;
|
|
157
|
+
chunks.push(chunk);
|
|
158
|
+
}
|
|
159
|
+
return Buffer.concat(chunks);
|
|
160
|
+
}
|
|
161
|
+
/** `<Latest>…</Latest>` 등 블록 목록 XML의 블록 id들 (Azure Put Block List) */
|
|
162
|
+
const blockListIds = xml => [...xml.matchAll(/<(?:Latest|Committed|Uncommitted)>([^<]*)<\/(?:Latest|Committed|Uncommitted)>/g)].map(m => m[1] ?? '');
|
|
163
|
+
/**
|
|
164
|
+
* 콘텐츠 서버 `PUT /__ecdk/blob/learners/…`: 발급한 주소만, 알린 크기까지 받아 `.ecdk/learners/…`에 둔다.
|
|
165
|
+
* Azure 블록 업로드(`comp=block` · `comp=blocklist`, SDK가 쓰는 방식)와 PUT 한 번 둘 다 받는다.
|
|
166
|
+
* 처리했으면 true, 이 경로가 아니면 false
|
|
167
|
+
*/
|
|
168
|
+
async function handleLearnerBlobPut(req, res, url, opts) {
|
|
169
|
+
if (!url.pathname.startsWith(`${DEV_BLOB_PREFIX}learners/`)) return false;
|
|
170
|
+
const storageKey = decodeURIComponent(url.pathname.slice(DEV_BLOB_PREFIX.length));
|
|
171
|
+
const upload = opts.pending.get(storageKey);
|
|
172
|
+
if (req.method !== 'PUT' || !upload || !STORAGE_KEY.test(storageKey)) {
|
|
173
|
+
req.resume();
|
|
174
|
+
res.writeHead(req.method === 'PUT' ? 403 : 405).end();
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
const comp = url.searchParams.get('comp');
|
|
178
|
+
const received = () => [...upload.blocks.values()].reduce((n, b) => n + b.length, 0);
|
|
179
|
+
let content;
|
|
180
|
+
if (comp === 'block') {
|
|
181
|
+
const id = url.searchParams.get('blockid') ?? '';
|
|
182
|
+
const block = await readBody(req, upload.allowed - received());
|
|
183
|
+
if (block === null || !id) {
|
|
184
|
+
opts.pending.delete(storageKey);
|
|
185
|
+
res.writeHead(413).end('larger than content_length');
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
upload.blocks.set(id, block);
|
|
189
|
+
res.writeHead(201).end();
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
if (comp === 'blocklist') {
|
|
193
|
+
const xml = (await readBody(req, 1024 * 1024))?.toString() ?? '';
|
|
194
|
+
const ids = blockListIds(xml);
|
|
195
|
+
if (ids.some(id => !upload.blocks.has(id))) {
|
|
196
|
+
res.writeHead(400).end('unknown block id');
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
content = Buffer.concat(ids.map(id => upload.blocks.get(id)));
|
|
200
|
+
} else {
|
|
201
|
+
const whole = await readBody(req, upload.allowed);
|
|
202
|
+
if (whole === null) {
|
|
203
|
+
opts.pending.delete(storageKey);
|
|
204
|
+
res.writeHead(413).end('larger than content_length');
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
content = whole;
|
|
208
|
+
}
|
|
209
|
+
opts.pending.delete(storageKey);
|
|
210
|
+
const file = join(opts.dir, '.ecdk', storageKey);
|
|
211
|
+
await mkdir(dirname(file), {
|
|
212
|
+
recursive: true
|
|
213
|
+
});
|
|
214
|
+
await writeFile(`${file}.part`, content);
|
|
215
|
+
await rename(`${file}.part`, file);
|
|
216
|
+
opts.log?.(`학생 파일을 받았습니다: ${storageKey} (${content.length} bytes) → ${LEARNERS_DIR}/`);
|
|
217
|
+
res.writeHead(201).end();
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
/** dev 서명 열쇠 (실행마다 새로). 흉내 서버도 서명 · 만료를 확인해 남의 폴더 · 지난 주소는 403 */
|
|
221
|
+
const SIGNING_KEY = randomBytes(32);
|
|
222
|
+
const signFolder = (prefix, exp) => createHmac('sha256', SIGNING_KEY).update(`${exp}:${prefix}`).digest('base64url').slice(0, 22);
|
|
223
|
+
/**
|
|
224
|
+
* `GET /materials/{id}/learner-files/url`의 응답: 주인 폴더 서명 주소, 파일 key에서 뺄 `key_prefix`, 만료 시각(ISO).
|
|
225
|
+
* @param apiSignedOrigin 서명 경로를 붙일 흉내 API 주소 (`{host}/api`)
|
|
226
|
+
*/
|
|
227
|
+
function learnerFolderUrl(apiSignedOrigin, materialId, accountId, now = Date.now()) {
|
|
228
|
+
const exp = Math.floor(now / 1000) + LEARNER_BASE_URL_TTL_SECONDS;
|
|
229
|
+
const prefix = `learners/${materialId}/${accountId}/`;
|
|
230
|
+
return {
|
|
231
|
+
base_url: `${apiSignedOrigin}/s/${exp}.${signFolder(prefix, exp)}/${prefix}`,
|
|
232
|
+
key_prefix: prefix,
|
|
233
|
+
expires_at: new Date(exp * 1000).toISOString()
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 흉내 API `GET · HEAD /s/{exp}.{sig}/learners/{material}/{account}/{folder}/{file}`: 서명이 그 학생 폴더의 것이고
|
|
238
|
+
* 만료 전이면 받은 파일을 내준다. 서명 경로가 아니면 false (다른 처리로 넘김)
|
|
239
|
+
*/
|
|
240
|
+
async function serveLearnerFile(req, res, signedPath, dir) {
|
|
241
|
+
const m = /^\/s\/(\d+)\.([A-Za-z0-9_-]+)\/(learners\/.*)$/.exec(signedPath);
|
|
242
|
+
if (!m) return false;
|
|
243
|
+
const [, expText = '', sig = '', storageKeyRaw = ''] = m;
|
|
244
|
+
const storageKey = decodeURIComponent(storageKeyRaw);
|
|
245
|
+
const key = STORAGE_KEY.exec(storageKey);
|
|
246
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
247
|
+
res.writeHead(405).end();
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
const exp = Number(expText);
|
|
251
|
+
const expected = key ? signFolder(`learners/${key[1]}/${key[2]}/`, exp) : '';
|
|
252
|
+
const valid = key !== null && exp * 1000 > Date.now() && expected.length === sig.length && timingSafeEqual(Buffer.from(expected), Buffer.from(sig));
|
|
253
|
+
if (!valid) {
|
|
254
|
+
res.writeHead(403).end('invalid or expired signature');
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
const file = join(dir, '.ecdk', storageKey);
|
|
258
|
+
const info = await stat(file).catch(() => null);
|
|
259
|
+
if (!info?.isFile()) {
|
|
260
|
+
res.writeHead(404).end('not found');
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
const ext = storageKey.slice(storageKey.lastIndexOf('.') + 1).toLowerCase();
|
|
264
|
+
res.writeHead(200, {
|
|
265
|
+
'Content-Type': LEARNER_FILE_KINDS[ext]?.types[0] ?? 'application/octet-stream',
|
|
266
|
+
'Content-Length': String(info.size),
|
|
267
|
+
'X-Content-Type-Options': 'nosniff'
|
|
268
|
+
});
|
|
269
|
+
if (req.method === 'HEAD') {
|
|
270
|
+
res.end();
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
await pipeline(createReadStream(file), res).catch(() => undefined);
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
/** "처음 상태로": 받은 학생 파일도 지운다 */
|
|
277
|
+
const removeLearnerFiles = dir => rm(join(dir, LEARNERS_DIR), {
|
|
278
|
+
recursive: true,
|
|
279
|
+
force: true
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
export { LEARNERS_DIR, LEARNER_BASE_URL_TTL_SECONDS, LEARNER_FILE_KINDS, LEARNER_RATE_ERROR_CODE, LEARNER_UPLOADS_PER_MINUTE, createLearnerUploadUrl, handleLearnerBlobPut, learnerFolderUrl, removeLearnerFiles, serveLearnerFile };
|
package/es/dev/mock-api.d.ts
CHANGED
|
@@ -101,6 +101,19 @@ export interface MockApiOptions {
|
|
|
101
101
|
message: string;
|
|
102
102
|
details?: unknown[];
|
|
103
103
|
};
|
|
104
|
+
/** `POST /storage/upload-url`의 `learner/{folder}/{file}` (dev/learner-files.ts `createLearnerUploadUrl`) */
|
|
105
|
+
createLearnerUploadUrl?: (body: unknown, materialId: string, accountId: number) => Promise<{
|
|
106
|
+
ok: true;
|
|
107
|
+
data: unknown;
|
|
108
|
+
} | {
|
|
109
|
+
ok: false;
|
|
110
|
+
status: number;
|
|
111
|
+
code: string;
|
|
112
|
+
message: string;
|
|
113
|
+
details?: unknown[];
|
|
114
|
+
}>;
|
|
115
|
+
/** `GET /materials/{id}/learner-files/url` (dev/learner-files.ts `learnerFolderUrl`) */
|
|
116
|
+
learnerFolderUrl?: (materialId: string, accountId: number) => unknown;
|
|
104
117
|
onEvent?: (message: string) => void;
|
|
105
118
|
}
|
|
106
119
|
/** `/api` 아래 요청을 처리한다 */
|
package/es/dev/mock-api.js
CHANGED
|
@@ -229,18 +229,36 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
229
229
|
}
|
|
230
230
|
}]);
|
|
231
231
|
}
|
|
232
|
-
// 자료 파일 올리기 주소 (편집 화면 SDK assets.post): edit 토큰, 자료는
|
|
232
|
+
// 자료 파일 올리기 주소 (편집 화면 SDK assets.post): edit 토큰, 자료는 토큰에서.
|
|
233
|
+
// 학생 파일(key `learner/…`, SDK learnerFiles.post)은 learn 토큰도 받고 튜터는 403, 계정 · 자료는 토큰에서
|
|
233
234
|
if (path === '/storage/upload-url' && method === 'POST') {
|
|
234
235
|
const claims = readClaims(req);
|
|
235
236
|
if (!claims) return fail(res, 401, 'AUTHENTICATION_INVALID', 'missing or expired token (dev)');
|
|
237
|
+
const {
|
|
238
|
+
json
|
|
239
|
+
} = await body(req);
|
|
240
|
+
const key = json?.key;
|
|
241
|
+
if (typeof key === 'string' && key.startsWith('learner/')) {
|
|
242
|
+
if (claims.viewer === 'tutor') return fail(res, 403, 'MATERIAL_READ_ONLY_MODE', 'tutor is read-only', [{
|
|
243
|
+
type: 'app_exception_detail',
|
|
244
|
+
ctx: {
|
|
245
|
+
reason: 'tutor_read_only'
|
|
246
|
+
}
|
|
247
|
+
}]);
|
|
248
|
+
if (!opts.createLearnerUploadUrl) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'uploads are off (dev)');
|
|
249
|
+
const r = await opts.createLearnerUploadUrl(json, claims.material_id, claims.account_id);
|
|
250
|
+
if (!r.ok) return fail(res, r.status, r.code, r.message, r.details);
|
|
251
|
+
log(`학생 파일 업로드 주소를 발급했습니다 (${key})`);
|
|
252
|
+
return send(res, 200, r.data);
|
|
253
|
+
}
|
|
236
254
|
if (claims.scope !== 'edit') return fail(res, 403, 'AUTH_PERMISSION_DENIED', 'upload only with an edit token');
|
|
237
255
|
if (!opts.createUploadUrl) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'uploads are off (dev)');
|
|
238
|
-
const r = opts.createUploadUrl(
|
|
256
|
+
const r = opts.createUploadUrl(json, claims.material_id);
|
|
239
257
|
if (!r.ok) return fail(res, r.status, r.code, r.message, r.details);
|
|
240
258
|
log('자료 파일 업로드 주소를 발급했습니다');
|
|
241
259
|
return send(res, 200, r.data);
|
|
242
260
|
}
|
|
243
|
-
const m = path.match(/^\/materials\/([0-9a-f-]{36})(\/me|\/draft|\/submissions|\/submissions\/me|\/kv\/account)?$/);
|
|
261
|
+
const m = path.match(/^\/materials\/([0-9a-f-]{36})(\/me|\/draft|\/submissions|\/submissions\/me|\/kv\/account|\/learner-files\/url)?$/);
|
|
244
262
|
if (!m) return fail(res, 404, 'RESOURCE_NOT_FOUND', `no route: ${method} ${path}`);
|
|
245
263
|
const claims = readClaims(req);
|
|
246
264
|
if (!claims) return fail(res, 401, 'AUTHENTICATION_INVALID', 'missing or expired token (dev)');
|
|
@@ -504,6 +522,12 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
504
522
|
log(`학생 제출: ${score ?? '-'}점 (${graded}, 완료 정책 ${policy})`);
|
|
505
523
|
return send(res, 200, response);
|
|
506
524
|
}
|
|
525
|
+
// 학생 폴더 서명 주소: 주인은 kv와 같이 토큰 account (튜터는 보고 있는 학생)
|
|
526
|
+
if (sub === '/learner-files/url') {
|
|
527
|
+
if (method !== 'GET') return fail(res, 405, 'RESOURCE_NOT_FOUND', `${method} ${path}`);
|
|
528
|
+
if (!opts.learnerFolderUrl) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'learner files are off (dev)');
|
|
529
|
+
return send(res, 200, opts.learnerFolderUrl(claims.material_id, subject));
|
|
530
|
+
}
|
|
507
531
|
// kvstore: 보는 사람(튜터는 보고 있는 학생) · 이 자료. 맨 위 key마다 값 하나
|
|
508
532
|
if (sub === '/kv/account') {
|
|
509
533
|
const doc = state.kv.get(subject) ?? {};
|
package/es/dev/server.d.ts
CHANGED
|
@@ -45,5 +45,8 @@ export declare const devOnlyConnectSrc: (contentOrigin: string) => string[];
|
|
|
45
45
|
* 콘텐츠 서버 PUT /__ecdk/blob/{asset_key} → .ecdk/assets/, 흉내 API 자료 응답(current_version · draft)의
|
|
46
46
|
* asset_base_url(흉내 API /api/s/dev/) + assets/{material_id}/{asset_key}로 Range 지원해 내준다.
|
|
47
47
|
* dev CSP connect-src에는 PUT 경로만 더한다 (devOnlyConnectSrc)
|
|
48
|
+
* - 학생 파일 흉내 (dev/learner-files.ts): upload-url `learner/…`(learn 토큰, 학생 × 자료 1분 30번) → 같은 PUT 경로
|
|
49
|
+
* (/__ecdk/blob/learners/…, Azure 블록 업로드도 받음) → .ecdk/learners/, learner-files/url의 폴더 서명
|
|
50
|
+
* 주소(흉내 API /api/s/{exp}.{sig}/learners/{material}/{account}/) 아래 파일을 내준다
|
|
48
51
|
*/
|
|
49
52
|
export declare function startDevServer(opts: DevServerOptions): Promise<DevServer>;
|
package/es/dev/server.js
CHANGED
|
@@ -15,6 +15,7 @@ import 'fflate';
|
|
|
15
15
|
import { DEV_BLOB_PREFIX, handleBlobPut, ASSET_SIGNED_PATH, serveAsset, createUploadUrl, MOCK_UPLOAD_URL_PATH, removeAssets, assetStoragePath } from './assets.js';
|
|
16
16
|
import { isCompletionPolicy, recommendedCompletionPolicy } from './grading.js';
|
|
17
17
|
import { hostPage } from './host-page.js';
|
|
18
|
+
import { handleLearnerBlobPut, serveLearnerFile, learnerFolderUrl, createLearnerUploadUrl, removeLearnerFiles } from './learner-files.js';
|
|
18
19
|
import { DEV_MATERIAL_ID, handleMockApi, isTokenScenario, issueToken, createState } from './mock-api.js';
|
|
19
20
|
|
|
20
21
|
/** 운영 콘텐츠 경로(/s/{exp}.{sig}/materials/{id}/{draft}/…)와 같은 모양. SDK가 여기서 자료 id를 읽는다 */
|
|
@@ -66,6 +67,9 @@ const listen = (server, port) => new Promise((ok, fail) => {
|
|
|
66
67
|
* 콘텐츠 서버 PUT /__ecdk/blob/{asset_key} → .ecdk/assets/, 흉내 API 자료 응답(current_version · draft)의
|
|
67
68
|
* asset_base_url(흉내 API /api/s/dev/) + assets/{material_id}/{asset_key}로 Range 지원해 내준다.
|
|
68
69
|
* dev CSP connect-src에는 PUT 경로만 더한다 (devOnlyConnectSrc)
|
|
70
|
+
* - 학생 파일 흉내 (dev/learner-files.ts): upload-url `learner/…`(learn 토큰, 학생 × 자료 1분 30번) → 같은 PUT 경로
|
|
71
|
+
* (/__ecdk/blob/learners/…, Azure 블록 업로드도 받음) → .ecdk/learners/, learner-files/url의 폴더 서명
|
|
72
|
+
* 주소(흉내 API /api/s/{exp}.{sig}/learners/{material}/{account}/) 아래 파일을 내준다
|
|
69
73
|
*/
|
|
70
74
|
async function startDevServer(opts) {
|
|
71
75
|
const dir = resolve(opts.dir);
|
|
@@ -74,6 +78,10 @@ async function startDevServer(opts) {
|
|
|
74
78
|
const state = createState();
|
|
75
79
|
/** 흉내 API가 발급한 자료 파일 업로드 주소 (PUT 한 번) */
|
|
76
80
|
const pendingUploads = new Map();
|
|
81
|
+
/** 흉내 API가 발급한 학생 파일 업로드 주소 (블록 업로드 또는 PUT 한 번) */
|
|
82
|
+
const pendingLearnerUploads = new Map();
|
|
83
|
+
/** 학생 파일 업로드 주소 발급 시각 (학생 × 자료 1분 30번) */
|
|
84
|
+
const learnerUploadRate = new Map();
|
|
77
85
|
// 편집 화면이 저장한 settings(내용 + grading)는 .ecdk/settings.json에 남겨 dev를 다시 열어도 그대로 (운영은 서버 settings)
|
|
78
86
|
state.settings = await loadSavedSettings(dir);
|
|
79
87
|
savedGrading(state.settings); // grading 형식이 틀리면 시작할 때 알린다
|
|
@@ -148,6 +156,16 @@ async function startDevServer(opts) {
|
|
|
148
156
|
// 자료 파일 올리기 (운영의 Blob 업로드 URL 자리). 같은 출처지만 CSP connect-src에 'self'가 없어 dev만 연 경로
|
|
149
157
|
if (url.pathname.startsWith(DEV_BLOB_PREFIX)) {
|
|
150
158
|
for (const [k, v] of Object.entries(headers)) res.setHeader(k, v);
|
|
159
|
+
const blobLog = m => log(`[api] ${m}`);
|
|
160
|
+
if (await handleLearnerBlobPut(req, res, url, {
|
|
161
|
+
dir,
|
|
162
|
+
pending: pendingLearnerUploads,
|
|
163
|
+
log: blobLog
|
|
164
|
+
}).catch(e => {
|
|
165
|
+
log(`[dev] 학생 파일을 받지 못했습니다: ${e.message}`);
|
|
166
|
+
if (!res.headersSent) res.writeHead(500).end('dev server error');
|
|
167
|
+
return true;
|
|
168
|
+
})) return;
|
|
151
169
|
await handleBlobPut(req, res, url.pathname, {
|
|
152
170
|
dir,
|
|
153
171
|
pending: pendingUploads,
|
|
@@ -196,6 +214,11 @@ async function startDevServer(opts) {
|
|
|
196
214
|
res.writeHead(404).end('not found');
|
|
197
215
|
return;
|
|
198
216
|
}
|
|
217
|
+
// 학생 파일 (learnerFiles base_url + {folder}/{file}), 흉내 API 출처의 폴더 서명 경로
|
|
218
|
+
if (url.pathname.startsWith('/api/s/') && url.pathname.includes('/learners/')) {
|
|
219
|
+
for (const [k, v] of Object.entries(cors)) res.setHeader(k, v);
|
|
220
|
+
if (await serveLearnerFile(req, res, url.pathname.slice(4), dir)) return;
|
|
221
|
+
}
|
|
199
222
|
if (url.pathname.startsWith('/api/')) {
|
|
200
223
|
for (const [k, v] of Object.entries(cors)) res.setHeader(k, v);
|
|
201
224
|
await handleMockApi(req, res, url.pathname.slice(4), {
|
|
@@ -209,6 +232,15 @@ async function startDevServer(opts) {
|
|
|
209
232
|
uploadOrigin: contentOrigin,
|
|
210
233
|
pending: pendingUploads
|
|
211
234
|
}),
|
|
235
|
+
createLearnerUploadUrl: (body, materialId, accountId) => createLearnerUploadUrl(body, {
|
|
236
|
+
dir,
|
|
237
|
+
materialId,
|
|
238
|
+
accountId,
|
|
239
|
+
uploadOrigin: contentOrigin,
|
|
240
|
+
pending: pendingLearnerUploads,
|
|
241
|
+
rate: learnerUploadRate
|
|
242
|
+
}),
|
|
243
|
+
learnerFolderUrl: (materialId, accountId) => learnerFolderUrl(`${hostOrigin}/api`, materialId, accountId),
|
|
212
244
|
onEvent: m => log(`[api] ${m}`)
|
|
213
245
|
});
|
|
214
246
|
return;
|
|
@@ -323,7 +355,9 @@ async function startDevServer(opts) {
|
|
|
323
355
|
force: true
|
|
324
356
|
});
|
|
325
357
|
await removeAssets(dir);
|
|
326
|
-
|
|
358
|
+
await removeLearnerFiles(dir);
|
|
359
|
+
learnerUploadRate.clear();
|
|
360
|
+
log(`[api] 저장 내용(${SETTINGS_DATA_FILE}) · 올린 파일 · 학생 파일 · 제출 기록을 지웠습니다`);
|
|
327
361
|
res.writeHead(204).end();
|
|
328
362
|
return;
|
|
329
363
|
}
|
package/es/rules/csp.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare function contentCsp(values?: CspValues, spec?: RulesSpec): string
|
|
|
21
21
|
/**
|
|
22
22
|
* dev에서만 콘텐츠 CSP 지시어에 더하는 출처 (운영 초안 CONTENT_CSP · rules.json은 넓히지 않는다).
|
|
23
23
|
* - frame-src: 로컬에서 띄운 엔트리 워크스페이스 (entry 템플릿이 ecdk dev에서 이 주소를 iframe으로 띄움)
|
|
24
|
+
* - img-src: 같은 워크스페이스가 주는 오브젝트 그림 (entry 편집 화면 AI 채점 오브젝트 목록, 서버도 워크스페이스 출처를 허용)
|
|
24
25
|
*/
|
|
25
26
|
export declare const DEV_ONLY_SOURCES: Readonly<Record<string, readonly string[]>>;
|
|
26
27
|
/** dev CSP: 지시어마다 DEV_ONLY_SOURCES를 더한다 ('none'만 있던 지시어는 'none'을 뺌) */
|
package/es/rules/csp.js
CHANGED
|
@@ -29,8 +29,10 @@ function contentCsp(values, spec = rules) {
|
|
|
29
29
|
/**
|
|
30
30
|
* dev에서만 콘텐츠 CSP 지시어에 더하는 출처 (운영 초안 CONTENT_CSP · rules.json은 넓히지 않는다).
|
|
31
31
|
* - frame-src: 로컬에서 띄운 엔트리 워크스페이스 (entry 템플릿이 ecdk dev에서 이 주소를 iframe으로 띄움)
|
|
32
|
+
* - img-src: 같은 워크스페이스가 주는 오브젝트 그림 (entry 편집 화면 AI 채점 오브젝트 목록, 서버도 워크스페이스 출처를 허용)
|
|
32
33
|
*/
|
|
33
34
|
const DEV_ONLY_SOURCES = {
|
|
35
|
+
'img-src': ['http://localhost:9000'],
|
|
34
36
|
'frame-src': ['http://localhost:9000']
|
|
35
37
|
};
|
|
36
38
|
/** dev CSP: 지시어마다 DEV_ONLY_SOURCES를 더한다 ('none'만 있던 지시어는 'none'을 뺌) */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliceio/cdk-cli",
|
|
3
|
-
"version": "1.6.0-entryqa.
|
|
3
|
+
"version": "1.6.0-entryqa.2",
|
|
4
4
|
"description": "교육자용 Custom HTML 콘텐츠 CLI",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"rollup": "^4.0.0",
|
|
47
47
|
"tslib": "^2.6.1",
|
|
48
48
|
"typescript": "~5.9.3",
|
|
49
|
-
"@eliceio/cdk": "^1.6.0-entryqa.
|
|
49
|
+
"@eliceio/cdk": "^1.6.0-entryqa.2"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"prebuild": "del-cli \"buildcache/*\" \"es/*\"",
|
|
@@ -127,6 +127,23 @@ interface Kvstore {
|
|
|
127
127
|
delete(key: string, init?: RequestInit): Promise<void>;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/** Learner files (provisional SDK API, waits for the SDK owners' agreement) */
|
|
131
|
+
interface LearnerFiles {
|
|
132
|
+
post(
|
|
133
|
+
file: Blob,
|
|
134
|
+
options: {
|
|
135
|
+
folder: string;
|
|
136
|
+
name: string;
|
|
137
|
+
contentType?: string;
|
|
138
|
+
onProgress?: (progress: { loaded: number; total: number }) => void;
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
}
|
|
141
|
+
): Promise<{ key: string; folder: string; name: string; size: number }>;
|
|
142
|
+
/** The mock has no signed folder: null */
|
|
143
|
+
baseUrl(): Promise<{ url: string; expiresAt: number } | null>;
|
|
144
|
+
url(path: string): Promise<string | null>;
|
|
145
|
+
}
|
|
146
|
+
|
|
130
147
|
interface Mlapi {
|
|
131
148
|
/** Same as `fetch`. The mock answers 503 SERVICE_UNAVAILABLE (reason ai_not_configured) */
|
|
132
149
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
@@ -159,6 +176,7 @@ export declare class MockEliceCDK {
|
|
|
159
176
|
/** 자료 파일. ecdk dev 콘텐츠 주소를 직접 열면 흉내 서버에, 아니면 이 페이지 메모리에만 (blob:) */
|
|
160
177
|
readonly assets: Assets;
|
|
161
178
|
readonly kvstore: Kvstore;
|
|
179
|
+
readonly learnerFiles: LearnerFiles;
|
|
162
180
|
readonly mlapi: Mlapi;
|
|
163
181
|
readonly accessToken: string | null;
|
|
164
182
|
readonly videoPlayerUrl: string | null;
|