openxiangda-cli 2.0.0-alpha.61 → 2.0.0-alpha.62

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 (38) hide show
  1. package/dist/create-workspace.d.ts.map +1 -1
  2. package/dist/create-workspace.js +1 -0
  3. package/dist/create-workspace.js.map +1 -1
  4. package/package.json +4 -4
  5. package/template/AGENTS.md +1 -1
  6. package/template/README.md +7 -7
  7. package/template/apps/server/package.json +1 -1
  8. package/template/apps/server/src/app.module.ts +1 -3
  9. package/template/apps/server/test/smoke.test.ts +6 -23
  10. package/template/apps/web/e2e/resources.spec.ts +20 -0
  11. package/template/apps/web/index.html +1 -1
  12. package/template/apps/web/package.json +1 -1
  13. package/template/apps/web/src/AuthoritativeSelector.tsx +38 -29
  14. package/template/apps/web/src/Shell.tsx +39 -211
  15. package/template/apps/web/src/components/platform-fields/AttachmentFileList.tsx +1 -1
  16. package/template/apps/web/src/components/resource/GeneratedResourceCrud.tsx +26 -5
  17. package/template/apps/web/src/components/resource/SurfaceFields.tsx +32 -1
  18. package/template/apps/web/src/data-provider.ts +23 -102
  19. package/template/apps/web/src/main.tsx +22 -82
  20. package/template/apps/web/src/platform-client.ts +71 -415
  21. package/template/apps/web/src/runtime-meta.ts +1 -1
  22. package/template/apps/web/src/styles.css +3 -3
  23. package/template/apps/web/test/contracts.test.ts +31 -769
  24. package/template/openxiangda.config.ts +14 -81
  25. package/template/package.json +3 -3
  26. package/template/packages/contracts/src/generated.ts +7 -804
  27. package/template/apps/server/src/instrument-context.controller.ts +0 -25
  28. package/template/apps/web/e2e/instruments.spec.ts +0 -1338
  29. package/template/apps/web/src/CollegePage.tsx +0 -181
  30. package/template/apps/web/src/InstrumentDetailPage.tsx +0 -176
  31. package/template/apps/web/src/InstrumentForm.tsx +0 -380
  32. package/template/apps/web/src/InstrumentFormPage.tsx +0 -82
  33. package/template/apps/web/src/InstrumentListPage.tsx +0 -457
  34. package/template/apps/web/src/fields.ts +0 -18
  35. package/template/apps/web/src/instrument.ts +0 -56
  36. package/template/platform/data/colleges.ts +0 -21
  37. package/template/platform/data/instrument-surface.ts +0 -125
  38. package/template/platform/data/instruments.ts +0 -83
@@ -1,96 +1,29 @@
1
1
  import { defineOpenXiangdaApp } from 'openxiangda-devkit-core';
2
- import {
3
- instruments,
4
- protectedFieldCapabilities,
5
- } from './platform/data/instruments.js';
6
- import { colleges } from './platform/data/colleges.js';
7
-
8
- const read = 'app:instrument-center:data:instruments:read';
9
- const create = 'app:instrument-center:data:instruments:create';
10
- const update = 'app:instrument-center:data:instruments:update';
11
- const remove = 'app:instrument-center:data:instruments:delete';
12
- const inspectContext = 'app:instrument-center:instrument:context:read';
13
- const directoryRead = 'app:instrument-center:directory:read';
14
- const collegeRead = 'app:instrument-center:data:colleges:read';
15
- const collegeCreate = 'app:instrument-center:data:colleges:create';
16
- const collegeUpdate = 'app:instrument-center:data:colleges:update';
17
- const allProtectedFieldCapabilities = Object.values(
18
- protectedFieldCapabilities
19
- ).flatMap(capabilities => [capabilities.create, capabilities.update]);
20
- const collegeCreateCapabilities = Object.values(
21
- protectedFieldCapabilities
22
- ).map(capabilities => capabilities.create);
23
- const collegeUpdateCapabilities = Object.entries(protectedFieldCapabilities)
24
- .filter(([field]) => field !== 'collegeId')
25
- .map(([, capabilities]) => capabilities.update);
26
2
 
3
+ /** Clean application scaffold: declare resources and fields, then generate CRUD. */
27
4
  export default defineOpenXiangdaApp({
28
5
  schemaVersion: 3,
29
- app: { code: 'instrument-center', name: '仪器资源管理' },
30
- frontend: {
31
- root: 'apps/web',
32
- routes: [
33
- { code: 'instruments', path: '/instruments', label: '仪器资源', surface: 'admin', navigation: 'menu', capability: read },
34
- { code: 'colleges', path: '/colleges', label: '学院字典', surface: 'admin', navigation: 'menu', capability: collegeRead },
35
- { code: 'instrument-create', path: '/instruments/new', label: '新增仪器', surface: 'admin', navigation: 'hidden', parentCode: 'instruments', capability: create },
36
- { code: 'instrument-edit', path: '/instruments/:id/edit', label: '编辑仪器', surface: 'admin', navigation: 'hidden', parentCode: 'instruments', capability: update },
37
- { code: 'instrument-detail', path: '/instruments/:id', label: '仪器详情', surface: 'admin', navigation: 'hidden', parentCode: 'instruments', capability: read },
38
- ],
39
- },
6
+ app: { code: 'openxiangda-application', name: 'OpenXiangda 应用' },
7
+ frontend: { root: 'apps/web', routes: [] },
40
8
  backend: {
41
9
  root: 'apps/server',
42
10
  runtime: 'node',
43
11
  framework: 'nestjs',
12
+ enabled: false,
44
13
  runMode: 'shared',
45
14
  secrets: [],
46
- operations: [
47
- {
48
- code: 'instrument-context.inspect',
49
- method: 'GET',
50
- path: '/api/instruments/context',
51
- capability: inspectContext,
52
- requestSchema: { type: 'object', additionalProperties: false },
53
- responseSchema: { type: 'object' },
54
- },
55
- ],
15
+ operations: [],
56
16
  },
57
17
  platform: { root: 'platform' },
58
18
  authz: {
59
- capabilities: [
60
- { code: inspectContext, kind: 'backend', name: '查看当前应用身份摘要' },
61
- ],
62
- roles: [
63
- { code: 'school_admin', name: '学校管理员', capabilities: [read, create, update, remove, collegeRead, collegeCreate, collegeUpdate, directoryRead, ...allProtectedFieldCapabilities, inspectContext] },
64
- { code: 'college_admin', name: '学院管理员', capabilities: [read, create, update, remove, directoryRead, ...collegeCreateCapabilities, ...collegeUpdateCapabilities, inspectContext] },
65
- { code: 'instrument_admin', name: '仪器管理员', capabilities: [read, update, directoryRead, inspectContext] },
66
- ],
67
- scopeDimensions: [
68
- {
69
- code: 'college',
70
- name: '学院',
71
- valueType: 'uuid',
72
- hierarchyMode: 'flat',
73
- valueSource: {
74
- kind: 'native_resource',
75
- resourceCode: 'colleges',
76
- labelField: 'name',
77
- enabledField: 'enabled',
78
- },
79
- },
80
- ],
81
- dataPolicies: [
82
- {
83
- code: 'instrument-access',
84
- name: '仪器数据范围',
85
- resourceCode: 'instruments',
86
- unrestrictedRoleCodes: ['school_admin'],
87
- matchMode: 'OR',
88
- rules: [
89
- { dimensionCode: 'college', field: 'collegeId', roleCodes: ['college_admin'] },
90
- { subject: 'current_user', field: 'instrumentAdminIds', roleCodes: ['instrument_admin'] },
91
- ],
92
- },
93
- ],
19
+ capabilities: [],
20
+ roles: [],
21
+ scopeDimensions: [],
22
+ scopeSources: [],
23
+ dataPolicies: [],
24
+ authorizationTransitions: [],
94
25
  },
95
- data: { resources: [colleges, instruments] },
26
+ data: { resources: [] },
27
+ events: { subscriptions: [], timers: [] },
28
+ workflows: { definitions: [], bindings: [], activations: [], providers: [], editableParameters: [] },
96
29
  });
@@ -21,9 +21,9 @@
21
21
  "build": "pnpm --recursive build"
22
22
  },
23
23
  "devDependencies": {
24
- "openxiangda-cli": "2.0.0-alpha.61",
25
- "openxiangda-contracts": "2.0.0-alpha.29",
26
- "openxiangda-devkit-core": "2.0.0-alpha.37",
24
+ "openxiangda-cli": "2.0.0-alpha.62",
25
+ "openxiangda-contracts": "2.0.0-alpha.30",
26
+ "openxiangda-devkit-core": "2.0.0-alpha.38",
27
27
  "typescript": "5.9.3"
28
28
  }
29
29
  }