openxiangda 1.0.21 → 1.0.24
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 +28 -10
- package/lib/cli.js +723 -11
- package/lib/workspace-init.js +13 -0
- package/openxiangda-skills/SKILL.md +26 -10
- package/openxiangda-skills/references/architecture-patterns.md +44 -22
- package/openxiangda-skills/references/automation-v3.md +2 -0
- package/openxiangda-skills/references/best-practices.md +163 -0
- package/openxiangda-skills/references/connector-resources.md +3 -0
- package/openxiangda-skills/references/notifications.md +80 -0
- package/openxiangda-skills/references/openxiangda-api.md +45 -0
- package/openxiangda-skills/references/pages/page-sdk.md +1 -0
- package/openxiangda-skills/references/pages/workspace-structure.md +5 -3
- package/openxiangda-skills/references/workspace-state.md +6 -0
- package/openxiangda-skills/skills/openxiangda-app/SKILL.md +11 -7
- package/openxiangda-skills/skills/openxiangda-core/SKILL.md +22 -4
- package/openxiangda-skills/skills/openxiangda-form/SKILL.md +6 -1
- package/openxiangda-skills/skills/openxiangda-page/SKILL.md +9 -1
- package/openxiangda-skills/skills/openxiangda-permission-settings/SKILL.md +3 -0
- package/openxiangda-skills/skills/openxiangda-workflow-automation/SKILL.md +9 -0
- package/package.json +1 -1
- package/packages/sdk/dist/runtime/index.cjs +34 -2
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +66 -1
- package/packages/sdk/dist/runtime/index.d.ts +66 -1
- package/packages/sdk/dist/runtime/index.mjs +34 -2
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/README.md +32 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/catalog.json +61 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/decision-guide.md +44 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/design-style.md +30 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/module-structure.md +48 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/index.ts +2 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.test.ts +35 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.ts +24 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/types.ts +17 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/index.ts +4 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/permissions.test.ts +42 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/permissions.ts +23 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/state-machine.test.ts +63 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/state-machine.ts +73 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/ticket-query.test.ts +34 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/ticket-query.ts +73 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/types.ts +64 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/page.tsx +1 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/schema.ts +57 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/customer-profile/page.tsx +1 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/customer-profile/schema.ts +83 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/page.tsx +1 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/schema.ts +97 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/ticket-action-log/page.tsx +1 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/ticket-action-log/schema.ts +65 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/js-code-nodes/daily_ticket_digest/index.ts +44 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/js-code-nodes/sync_roles_to_platform/index.ts +33 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/App.tsx +7 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/WorkbenchPage.tsx +36 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/components/ConfigPanel.tsx +34 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/components/PreviewPanel.tsx +17 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/index.tsx +10 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/page.config.ts +9 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/reducer.ts +29 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/styles.css +24 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/App.tsx +7 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/MobilePortalShell.tsx +31 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/index.tsx +10 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/modules/MobileHome.tsx +13 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/page.config.ts +14 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/routes.ts +13 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/styles.css +11 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/App.tsx +7 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/PcPortalShell.tsx +35 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/components/PortalMetric.tsx +11 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/index.tsx +10 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/modules/HomeModule.tsx +25 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/modules/TicketsModule.tsx +14 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/page.config.ts +14 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/routes.ts +19 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/styles.css +35 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/App.tsx +7 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/TicketOpsPage.tsx +105 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketActionTimeline.tsx +22 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketDetailDrawer.tsx +41 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketTableActions.tsx +55 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/index.tsx +10 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/page.config.ts +9 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/styles.css +35 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/automations/daily-ticket-digest/automation.json +25 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/automations/daily-ticket-digest/trigger.json +9 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/notifications/daily-ticket-digest.json +24 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/permissions/form-groups/service-ticket-college.json +21 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/permissions/roles.json +17 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/workflows/expense-approval-workflow.json +48 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/ConfirmAction.tsx +22 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/QueryState.tsx +37 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/StatusTag.tsx +20 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/hooks/useTicketOps.ts +96 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/services/role-governance.ts +48 -0
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/services/service-ticket.ts +113 -0
- package/templates/sy-lowcode-app-workspace/package.json +1 -0
- package/templates/sy-lowcode-app-workspace/src/dev/App.tsx +11 -1
- package/templates/sy-lowcode-app-workspace/tsconfig.examples.json +24 -0
|
@@ -40,22 +40,35 @@ Use `--profile` for every destructive or publishing action. Treat the profile as
|
|
|
40
40
|
|
|
41
41
|
Run write commands sequentially in the same workspace because they update `.openxiangda/state.json`. Read-only commands such as list, pull, snapshot, and inspect may run in parallel.
|
|
42
42
|
|
|
43
|
+
## Updates
|
|
44
|
+
|
|
45
|
+
Use the official npm registry for OpenXiangda package updates because domestic mirrors may lag:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g openxiangda@latest --registry=https://registry.npmjs.org
|
|
49
|
+
openxiangda update check --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
At the start of substantial work, run `openxiangda update check --json`. If `updateAvailable` is true, run `openxiangda update install` before generating or publishing so the CLI and installed skills stay compatible. If the installed CLI does not support `update`, reinstall with the official registry command above, then run `openxiangda skill install --force`.
|
|
53
|
+
|
|
43
54
|
## Workspace State
|
|
44
55
|
|
|
45
56
|
Create a workspace when the current project does not already contain a `sy-lowcode-app-workspace`:
|
|
46
57
|
|
|
47
58
|
```bash
|
|
48
|
-
openxiangda workspace init ./my-app-workspace --profile dev --app-
|
|
59
|
+
openxiangda workspace init ./my-app-workspace --profile dev --app-name "测试应用"
|
|
49
60
|
cd ./my-app-workspace
|
|
50
61
|
pnpm install
|
|
51
62
|
openxiangda env --profile dev
|
|
52
63
|
```
|
|
53
64
|
|
|
54
|
-
If the
|
|
65
|
+
Local workspace state is authoritative. If `.openxiangda/state.json` already contains an app binding for the target profile, use it. If there is no local binding, create a new app with `workspace init --app-name`; do not search platform apps for similar names.
|
|
66
|
+
|
|
67
|
+
After workspace initialization, inspect `examples/best-practices/` before generating a real app. The examples are copied locally but are not published by default; copy only the selected pattern into `src/`.
|
|
68
|
+
|
|
69
|
+
If the workspace already exists and the user explicitly provides an existing app, bind each platform to its own app, then publish from `sy-lowcode-app-workspace`:
|
|
55
70
|
|
|
56
71
|
```bash
|
|
57
|
-
openxiangda app list --profile dev
|
|
58
|
-
openxiangda app create "测试应用" --profile dev
|
|
59
72
|
openxiangda workspace bind --profile dev --app-type APP_DEV
|
|
60
73
|
openxiangda workspace bind --profile prod --app-type APP_PROD
|
|
61
74
|
cd /path/to/sy-lowcode-app-workspace
|
|
@@ -96,6 +109,10 @@ Project state is stored in `.openxiangda/state.json`:
|
|
|
96
109
|
"menus": {},
|
|
97
110
|
"roles": {},
|
|
98
111
|
"connectors": {},
|
|
112
|
+
"notifications": {
|
|
113
|
+
"templates": {},
|
|
114
|
+
"typeConfigs": {}
|
|
115
|
+
},
|
|
99
116
|
"pagePermissionGroups": {},
|
|
100
117
|
"formPermissionGroups": {},
|
|
101
118
|
"formSettings": {}
|
|
@@ -145,3 +162,4 @@ The publish script is responsible for:
|
|
|
145
162
|
- `../../references/openxiangda-api.md` — exact endpoint contracts.
|
|
146
163
|
- `../../references/workspace-state.md` — `.openxiangda/state.json` shape and profile-scoped resource maps.
|
|
147
164
|
- `../../references/architecture-patterns.md` — overall architecture of an OpenXiangda app workspace (CRUD data flow, page/form layering, recommended directory organization). Read this when you need to understand how forms, pages, workflows, and platform state fit together end-to-end.
|
|
165
|
+
- `../../references/best-practices.md` — initialized best-practice templates and rules for modular pages, status lifecycles, role governance, data isolation, query performance, and workflow boundaries.
|
|
@@ -18,11 +18,13 @@ cd /path/to/sy-lowcode-app-workspace
|
|
|
18
18
|
If the workspace does not exist yet, create it before writing form source:
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
openxiangda workspace init ./my-app-workspace --profile <name> --app-
|
|
21
|
+
openxiangda workspace init ./my-app-workspace --profile <name> --app-name "应用名称"
|
|
22
22
|
cd ./my-app-workspace
|
|
23
23
|
pnpm install
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
Use `--app-type APP_XXX` only when the user explicitly provides an existing app to reuse.
|
|
27
|
+
|
|
26
28
|
Create or edit workspace source:
|
|
27
29
|
|
|
28
30
|
```text
|
|
@@ -61,10 +63,13 @@ Read these references only when writing or reviewing schema:
|
|
|
61
63
|
- `../../references/forms/layout-and-rules.md`
|
|
62
64
|
- `../../references/platform-data-model.md` — how each field type is persisted (JSONB, `{label, value}` for option fields, attachment shape). Consult before designing schema or wiring values.
|
|
63
65
|
- `../../references/component-guide.md` — when to pick platform form components vs. custom widgets, and the option-component rules.
|
|
66
|
+
- `../../references/best-practices.md` — status lifecycle fields, ownership redundancy, role-governance fields, and the boundary between normal forms and workflow forms.
|
|
64
67
|
|
|
65
68
|
## Rules
|
|
66
69
|
|
|
67
70
|
- Prefer deterministic `formCode` as local key; bind live `formUuid` under the active profile.
|
|
71
|
+
- For business lifecycles, model status with normal form fields (`status`, owner/responsibility fields, action-log relation fields) unless the scenario has real approval tasks. Do not create workflow forms for ordinary status transitions.
|
|
72
|
+
- For permission isolation, add redundant ownership fields such as `collegeId`, `classId`, `ownerDeptId`, and `ownerUserId` at schema time so form permission groups can use structured conditions later.
|
|
68
73
|
- For multi-platform publishing, create or bind the form separately for each profile.
|
|
69
74
|
- Do not copy `formUuid` from dev to prod unless the target platform explicitly already uses that ID.
|
|
70
75
|
- Keep `schema.ts` and `page.tsx` as the source for fields/layout/rules and presentation; generated build output is not the source of truth.
|
|
@@ -19,11 +19,13 @@ openxiangda workspace publish --profile <name>
|
|
|
19
19
|
If the workspace does not exist yet, initialize it first:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
openxiangda workspace init ./my-app-workspace --profile <name> --app-
|
|
22
|
+
openxiangda workspace init ./my-app-workspace --profile <name> --app-name "应用名称"
|
|
23
23
|
cd ./my-app-workspace
|
|
24
24
|
pnpm install
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Use `--app-type APP_XXX` only when the user explicitly provides an existing app to reuse.
|
|
28
|
+
|
|
27
29
|
Direct publish is only for already built assets or targeted repair:
|
|
28
30
|
|
|
29
31
|
```bash
|
|
@@ -41,7 +43,9 @@ Read these references only when editing page code:
|
|
|
41
43
|
|
|
42
44
|
- `../../references/pages/workspace-structure.md`
|
|
43
45
|
- `../../references/pages/app-shell.md` — formal backend / PC portal / mobile portal entry pattern. Read before creating any user-facing main entry or admin console.
|
|
46
|
+
- `../../references/best-practices.md` — initialized examples for modular pages, status lifecycles, role governance, high-performance queries, portal shells, and interactive workbenches. Read before scaffolding complex pages or data management pages.
|
|
44
47
|
- `../../references/pages/page-sdk.md`
|
|
48
|
+
- `../../references/notifications.md` — notification resources and `sdk.notification` usage. Read before adding reminders, alerts, or message templates to a page.
|
|
45
49
|
- `../../references/pages/publish-flow.md`
|
|
46
50
|
- `../../references/style-system.md` — three-layer style architecture, CSS namespace, and the no-hardcoded-color rule. Read before writing any page CSS or Tailwind class.
|
|
47
51
|
- `../../references/architecture-patterns.md` — CRUD data flow, `DataManagementList` pattern, and recommended `src/pages/<pageCode>/` layout. Read before scaffolding a new page or list view.
|
|
@@ -52,8 +56,11 @@ Read these references only when editing page code:
|
|
|
52
56
|
|
|
53
57
|
- Keep `pageCode` stable and use it as the local logical key.
|
|
54
58
|
- Formal user-facing entries such as admin consoles, PC portals, and mobile portals must be app-shell code pages. Declare `entry: { mode: "app-shell", hidePlatformNav: true, defaultRoute: "<home-route>" }` in `page.config.ts`.
|
|
59
|
+
- Do not generate single-file large pages. Split complex code pages into `domain/`, `shared/services/`, `shared/hooks/`, shared/page-local `components/`, route/config files, and `styles.css` as described in `../../references/best-practices.md`.
|
|
60
|
+
- Keep view code thin. Page components call hooks/services; business rules, state transition rules, permission predicates, and query builders live outside TSX and are reusable by PC and mobile pages.
|
|
55
61
|
- Store live `pageId`, `routeKey`, and `legacyFormUuid` under the current profile only.
|
|
56
62
|
- Use `openxiangda/runtime` for platform data access instead of hardcoding backend URLs in page code.
|
|
63
|
+
- For reminders, alerts, and business messages, declare `src/resources/notifications/` first and call `sdk.notification`; do not hardcode notification API URLs.
|
|
57
64
|
- Named imports from `@ant-design/icons` are supported by the `openxiangda` workspace build proxy, which enumerates icon module exports at runtime.
|
|
58
65
|
- Publish through `openxiangda workspace publish --profile <name>` unless there is a specific repair reason to call `page publish` directly.
|
|
59
66
|
- Do not create custom code pages by writing platform schema directly. The source is React workspace code plus `page.config.ts`.
|
|
@@ -62,6 +69,7 @@ Read these references only when editing page code:
|
|
|
62
69
|
- For prod, explicitly run with `--profile prod`; never rely on the current profile for release operations.
|
|
63
70
|
- Follow the style system in `../../references/style-system.md`: never hardcode colors, fonts, spacing, or radii — use the platform CSS variables and the page CSS namespace.
|
|
64
71
|
- For list / detail / CRUD pages, follow `../../references/architecture-patterns.md` (e.g. `DataManagementList`) before writing custom data-fetching loops.
|
|
72
|
+
- Query pages must use pagination with structured conditions. Do not fetch a large `pageSize` and filter in the browser; avoid default `searchKeyWord`, and build multi-field fuzzy search with explicit `filterGroup` + `OR`.
|
|
65
73
|
- Pick components per `../../references/component-guide.md`: prefer the platform component, fall back to Ant Design, and only build a custom component when neither fits.
|
|
66
74
|
- When a page misbehaves (lost styles, `options is undefined`, option labels showing raw values, etc.), consult `../../references/troubleshooting.md` before patching symptoms.
|
|
67
75
|
- For custom portal pages and business modals, do not temporarily embed a single `FormProvider` field component from the standard form runtime. If a standard component is required, navigate to a full standard form page or render a complete `StandardFormPage` inside a dedicated carrier route.
|
|
@@ -34,6 +34,8 @@ Use role codes in permission group JSON. Bind existing role IDs only inside the
|
|
|
34
34
|
openxiangda permission role-bind sales --role-id <id> --profile dev
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
For dynamic multi-role apps, do not hardcode role behavior only in page code. Create a role maintenance form, sync it to platform roles with automation / JS_CODE, and add redundant ownership fields to business forms (`collegeId`, `classId`, `ownerDeptId`, `ownerUserId`, `roleCode`). Use page permission groups for entry visibility and form permission groups with condition-based data permissions for real data isolation.
|
|
38
|
+
|
|
37
39
|
## Page Permission Groups
|
|
38
40
|
|
|
39
41
|
Page permission groups control menu/page visibility:
|
|
@@ -92,5 +94,6 @@ Do not store platform-specific public access IDs locally. The CLI resolves by `a
|
|
|
92
94
|
## References
|
|
93
95
|
|
|
94
96
|
- Permission model and examples: `../../references/permissions-settings.md`
|
|
97
|
+
- Dynamic role governance and data-isolation pattern: `../../references/best-practices.md`
|
|
95
98
|
- Profile-isolated IDs: `../../references/workspace-state.md`
|
|
96
99
|
- API fields: `../../references/openxiangda-api.md`
|
|
@@ -7,6 +7,12 @@ description: Build, validate, publish, enable, and inspect OpenXiangda workflow
|
|
|
7
7
|
|
|
8
8
|
Use this skill when the user asks for approval workflows, workflow forms, automation rules, scheduled jobs, form-event triggers, or process-triggered automation in OpenXiangda.
|
|
9
9
|
|
|
10
|
+
## Architecture Boundary
|
|
11
|
+
|
|
12
|
+
Most business lifecycle flows are not workflows. For ordinary status changes such as `pending -> processing -> resolved -> closed`, use a normal form, a `status` field, redundant responsibility fields, an action-log form, a domain state machine, a service method, and optional automation / JS_CODE.
|
|
13
|
+
|
|
14
|
+
Create workflow definitions only when the scenario has real approval semantics: approvers, approval tasks, agree/reject actions, approval opinions, node-level permissions, process records, or approval-node side effects.
|
|
15
|
+
|
|
10
16
|
## Required Context
|
|
11
17
|
|
|
12
18
|
Before any write:
|
|
@@ -76,6 +82,7 @@ Inside the TypeScript script, prefer `export default async function (ctx) {}` or
|
|
|
76
82
|
|
|
77
83
|
- Context: `ctx.triggerEvent`, `ctx.formData`, `ctx.workflowData`, `ctx.operator`, `ctx.app`, `ctx.variables`, and `ctx.node`.
|
|
78
84
|
- Data/process methods: `ctx.methods.queryOneData`, `queryManyData`, `updateOneData`, `updateDataByFormInstanceId`, `updateManyData`, `createOneData`, `terminateProcess`, and `getAllParentDepartments`.
|
|
85
|
+
- Notification bridge: `ctx.notification.sendByType`, `batchSendByType`, `findConfig`, and `previewTemplate`. Declare templates in `src/resources/notifications/` before using custom `notificationType`.
|
|
79
86
|
- Platform API bridge: `ctx.platform.api.get/post/put/patch/delete/request` for `/openxiangda-api/v1`.
|
|
80
87
|
- Node runtime helpers: `require`, `process`, `Buffer`, `ctx.utils`, `ctx.utils.http`, and `ctx.console`.
|
|
81
88
|
|
|
@@ -100,7 +107,9 @@ Use `automation disable` before risky edits. Published automations create a draf
|
|
|
100
107
|
|
|
101
108
|
## References
|
|
102
109
|
|
|
110
|
+
- Best-practice architecture and status-flow boundary: `../../references/best-practices.md`
|
|
103
111
|
- Workflow v3 JSON: `../../references/workflow-v3.md`
|
|
104
112
|
- Automation v3 JSON and triggers: `../../references/automation-v3.md`
|
|
113
|
+
- Notification resources and runtime calls: `../../references/notifications.md`
|
|
105
114
|
- API fields: `../../references/openxiangda-api.md`
|
|
106
115
|
- Profile-isolated IDs: `../../references/workspace-state.md`
|
package/package.json
CHANGED
|
@@ -65,6 +65,9 @@ var resolveAppType = (context, explicitAppType) => {
|
|
|
65
65
|
return appType;
|
|
66
66
|
};
|
|
67
67
|
var buildAppPath = (context, explicitAppType, suffix) => `/${resolveAppType(context, explicitAppType)}${suffix}`;
|
|
68
|
+
var buildOpenXiangdaAppPath = (context, explicitAppType, suffix) => `/openxiangda-api/v1/apps/${encodePathSegment(
|
|
69
|
+
resolveAppType(context, explicitAppType)
|
|
70
|
+
)}${suffix}`;
|
|
68
71
|
var encodePathSegment = (value) => encodeURIComponent(String(value));
|
|
69
72
|
var getHeaderValue = (headers, name) => {
|
|
70
73
|
if (!headers) {
|
|
@@ -1077,7 +1080,11 @@ var createPageSdk = (context) => {
|
|
|
1077
1080
|
};
|
|
1078
1081
|
const notification = {
|
|
1079
1082
|
sendByType: (params) => request({
|
|
1080
|
-
path:
|
|
1083
|
+
path: buildOpenXiangdaAppPath(
|
|
1084
|
+
context,
|
|
1085
|
+
params.appType,
|
|
1086
|
+
"/notifications/send-by-type"
|
|
1087
|
+
),
|
|
1081
1088
|
method: "post",
|
|
1082
1089
|
body: {
|
|
1083
1090
|
...params,
|
|
@@ -1085,7 +1092,32 @@ var createPageSdk = (context) => {
|
|
|
1085
1092
|
}
|
|
1086
1093
|
}),
|
|
1087
1094
|
batchSendByType: (params) => request({
|
|
1088
|
-
path:
|
|
1095
|
+
path: buildOpenXiangdaAppPath(
|
|
1096
|
+
context,
|
|
1097
|
+
params.appType,
|
|
1098
|
+
"/notifications/batch-send-by-type"
|
|
1099
|
+
),
|
|
1100
|
+
method: "post",
|
|
1101
|
+
body: {
|
|
1102
|
+
...params,
|
|
1103
|
+
appType: resolveAppType(context, params.appType)
|
|
1104
|
+
}
|
|
1105
|
+
}),
|
|
1106
|
+
findConfig: (notificationType, params = {}) => request({
|
|
1107
|
+
path: buildOpenXiangdaAppPath(
|
|
1108
|
+
context,
|
|
1109
|
+
params.appType,
|
|
1110
|
+
`/notifications/type-configs/${encodePathSegment(notificationType)}`
|
|
1111
|
+
),
|
|
1112
|
+
method: "get",
|
|
1113
|
+
query: params.formUuid ? { formUuid: params.formUuid } : void 0
|
|
1114
|
+
}),
|
|
1115
|
+
previewTemplate: (params) => request({
|
|
1116
|
+
path: buildOpenXiangdaAppPath(
|
|
1117
|
+
context,
|
|
1118
|
+
params.appType,
|
|
1119
|
+
"/notifications/templates/preview"
|
|
1120
|
+
),
|
|
1089
1121
|
method: "post",
|
|
1090
1122
|
body: {
|
|
1091
1123
|
...params,
|