
DINHDANH Creator · Bài AM03 · API REFERENCE §2 · 15 method
đủ method - tham số · trả về · lưu ý
Một tờ JSON cả file (cài đặt), tạo/xóa/khôi phục, đổi tên, tìm file, đọc-ghi từng field trong kho dữ liệu.
Mục tiêu: Tra cứu đủ 15 method §2; biết flat ≠ sổ indexed (AM02).
Cấm: readFile/writeFile với login.json - dùng AM06. Không deleteFile cả sổ để xóa 1 dòng - dùng updateData(..., null) (AM02).
Mục lục nhanh: A đọc/ghi tờ · B tạo/xóa/đổi tên · C kiểm tra/tìm · D field
A. Đọc / ghi tờ cấu hình

appifio_readFile(fileName) - flat (không truyền id) · PublicViệc: Đọc cả tờ cấu hình JSON.
Tham số: fileName - vd. shop-settings.json, cms-settings.json.
const res = await appifio_client.appifio_readFile('cms-settings.json');
let settings = res.data?.content; // object hoặc ""Trả về: { data: { content: object } } hoặc content: "" nếu chưa có tờ.
Lưu ý: Cùng tên hàm với AM02 nhưng không id. Có id = 1 dòng sổ. Đã parse JSON - không JSON.parse thêm.
appifio_writeFile(fileName, content, fileType?) · Admin+Việc: Ghi đè cả tờ (hoặc tạo master indexed nếu cần).
Tham số: content = chuỗi JSON (thường JSON.stringify(obj)). fileType: 'flat' (mặc định) | 'indexed' (tạo sổ cho append).
await appifio_client.appifio_writeFile(
'config.json',
JSON.stringify({ shopName: 'Shop Lan', phone: '090...' })
);Trả về: { success: true }
Lưu ý: Không dùng để ghi từng dòng list. File hệ thống có policy riêng (login.json bị từ chối). Append lần đầu thường tự tạo sổ - indexed không bắt buộc.
B. Tạo · xóa · khôi phục · đổi tên · sao chép
appifio_createFile(fileName, content?) · Admin+Việc: Tạo file mới. Tham số: content chuỗi, mặc định ''.
await appifio_client.appifio_createFile('config.json', '{}');Trả về: { success: true } - lỗi nếu tên đã tồn tại (khác writeFile ghi đè).
appifio_deleteFile(fileName) · Admin+ (role user bị chặn)await appifio_client.appifio_deleteFile('old-config.json');Trả về: { success: true } - xóa mềm (còn khôi phục). Xóa 1 dòng trong list → AM02 updateData(..., null), không delete cả master.
appifio_restoreFile(fileName) · Admin+await appifio_client.appifio_restoreFile('old-config.json');Trả về: { success: true } - lấy lại file đã xóa mềm.
appifio_hardDeleteFile(fileName) · Chỉ siêu quản trịawait appifio_client.appifio_hardDeleteFile('spam.json');Trả về: { success: true }. Lưu ý: Xóa vĩnh viễn (kèm phần chia nhỏ của sổ) - không hoàn tác.
appifio_renameFile(oldName, newName) · Admin+Tham số: Đuôi file phải giữ nguyên (vd. cả hai .json).
await appifio_client.appifio_renameFile('a.json', 'b.json');Trả về: { success: true }
appifio_copyFile(sourceFile, destFile) · Admin+await appifio_client.appifio_copyFile('blog.json', 'blog-backup.json');Trả về: { success: true } - nếu là sổ indexed, sao chép cả phần chia nhỏ.
C. Kiểm tra · thông tin · liệt kê · tìm
appifio_fileExists(fileName) · Publicconst r = await appifio_client.appifio_fileExists('config.json');
// r.data.exists === true | falseTrả về: { success: true, data: { exists: true|false } }. File hệ thống nhạy cảm có thể luôn báo false (không lộ).
appifio_getFileInfo(fileName) · Publicconst r = await appifio_client.appifio_getFileInfo('config.json');
// data: file_name, file_type, file_size, is_deleted, created_at, updated_atLưu ý: File chưa có → success: false (khác readFile trả rỗng). Flow thường ưu tiên fileExists / readFile.
appifio_listFiles(includeDeleted?) · Publicconst r = await appifio_client.appifio_listFiles();
// r.data.files = [{ file_name, file_type, file_size, ... }]
await appifio_client.appifio_listFiles(true); // kèm đã xóa mềm - cần đã loginLưu ý: Ẩn file hệ thống + phần chia nhỏ nội bộ. includeDeleted: true chỉ có hiệu lực khi đã đăng nhập quản trị.
appifio_searchFiles(pattern) · PublicTham số: wildcard *, ? - vd. blog-*.json.
const r = await appifio_client.appifio_searchFiles('blog-*.json');
// r.data.files = [...]appifio_findByName(fileName) · Publicconst r = await appifio_client.appifio_findByName('config.json');
// r.data.files - khớp tên chính xácD. Đọc / ghi một field (đường dẫn chấm)
appifio_readField(fileName, fieldPath) · PublicTham số: fieldPath dạng chấm - vd. display_formats.date, timezone.
const r = await appifio_client.appifio_readField('cms-settings.json', 'timezone');
// r.data.value - any | null (không có file/field → null)appifio_writeField(fileName, fieldPath, value) · Admin+await appifio_client.appifio_writeField('config.json', 'theme.color', '#ff0000');Trả về: { success: true }. Tự tạo tờ flat nếu chưa có. Nếu value là object, hệ thống tự chuyển sang JSON.
AM04 - File trang & upload (§3 - 7 method)
Điều hướng nội bộ (cùng ngôn ngữ)
DINHDANH Creator · Loạt Method · AM03