a15c4177de
Memind CI / Test, build, and release guards (push) Successful in 10m3s
Add dry-run, e2e, and poem-page remediation scripts for cursor executor and help escalation verification. Co-authored-by: Cursor <cursoragent@cursor.com>
104 lines
3.3 KiB
JavaScript
104 lines
3.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* 为 1c99b83b 工作区搭建 product-order Page Data
|
|
*/
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { loadH5Environment } from './load-env.mjs';
|
|
import { createDbPool } from '../db.mjs';
|
|
import { bindWorkspaceHtmlForPageData } from '../page-data-workspace-bind.mjs';
|
|
import { resolveMindSpaceStorageRoot } from '../mindspace-runtime-config.mjs';
|
|
import { createUserDataSpaceService } from '../user-data-space-service.mjs';
|
|
|
|
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
loadH5Environment(import.meta.dirname);
|
|
|
|
const USER_ID = '1c99b83b-0454-474f-a5d2-129d34506a32';
|
|
const WORKSPACE_ROOT = path.join(root, 'MindSpace', USER_ID);
|
|
const ADMIN_PASSWORD = '88888888';
|
|
const DATASET = 'product_orders';
|
|
|
|
const FORM_POLICY = {
|
|
accessMode: 'public',
|
|
datasets: {
|
|
product_orders: {
|
|
insert: true,
|
|
read: false,
|
|
columns: {
|
|
insert: ['customer_name', 'phone', 'product_items', 'total_amount', 'address', 'remark', 'status'],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const ADMIN_POLICY = {
|
|
accessMode: 'password',
|
|
datasets: {
|
|
product_orders: {
|
|
insert: false,
|
|
read: true,
|
|
columns: {
|
|
read: ['id', 'customer_name', 'phone', 'product_items', 'total_amount', 'address', 'remark', 'status', 'created_at'],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
async function main() {
|
|
const dataSpace = createUserDataSpaceService({ workspaceRoot: WORKSPACE_ROOT, userId: USER_ID });
|
|
await dataSpace.executeSql(`CREATE TABLE IF NOT EXISTS product_orders (
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
customer_name TEXT NOT NULL DEFAULT '',
|
|
phone TEXT NOT NULL DEFAULT '',
|
|
product_items TEXT NOT NULL DEFAULT '',
|
|
total_amount TEXT NOT NULL DEFAULT '0',
|
|
address TEXT NOT NULL DEFAULT '',
|
|
remark TEXT NOT NULL DEFAULT '',
|
|
status TEXT NOT NULL DEFAULT '待处理',
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);`);
|
|
await dataSpace.upsertDataset({
|
|
name: DATASET,
|
|
table: DATASET,
|
|
description: '精选好物下单页订单表',
|
|
actions: ['read', 'insert'],
|
|
columns: {
|
|
insert: FORM_POLICY.datasets.product_orders.columns.insert,
|
|
read: ADMIN_POLICY.datasets.product_orders.columns.read,
|
|
},
|
|
});
|
|
|
|
const pool = createDbPool();
|
|
const storageRoot = resolveMindSpaceStorageRoot(root);
|
|
const pages = [
|
|
{ relativePath: 'public/product-order.html', accessMode: 'public', password: null, policy: FORM_POLICY },
|
|
{ relativePath: 'public/product-order-admin.html', accessMode: 'password', password: ADMIN_PASSWORD, policy: ADMIN_POLICY },
|
|
];
|
|
|
|
console.log('==> product-order Page Data 搭建\n');
|
|
for (const page of pages) {
|
|
const result = await bindWorkspaceHtmlForPageData({
|
|
pool,
|
|
h5Root: root,
|
|
storageRoot,
|
|
userId: USER_ID,
|
|
workspaceRoot: WORKSPACE_ROOT,
|
|
relativePath: page.relativePath,
|
|
accessMode: page.accessMode,
|
|
password: page.password,
|
|
pageDataPolicy: page.policy,
|
|
});
|
|
console.log(`✓ ${page.relativePath}`);
|
|
console.log(` pageId: ${result.pageId}`);
|
|
console.log(` URL: ${result.workspaceUrl}\n`);
|
|
}
|
|
|
|
console.log('后台口令:', ADMIN_PASSWORD);
|
|
await pool.end();
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err instanceof Error ? err.stack ?? err.message : err);
|
|
process.exit(1);
|
|
});
|