@nocobase/app-skills 0.1.0-beta.64 → 0.1.0-beta.66

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 (31) hide show
  1. package/LICENSE.txt +24 -26
  2. package/package.json +4 -2
  3. package/skills/nocobase-app-development/SKILL.md +5 -0
  4. package/skills/nocobase-app-development/assets/business-examples/index.json +2 -0
  5. package/skills/nocobase-app-development/assets/business-examples/onboarding/database/main/migrations/202611130005_onboarding_definition_binding.ts +37 -0
  6. package/skills/nocobase-app-development/assets/business-examples/onboarding/server/lifecycles/onboarding.ts +3 -0
  7. package/skills/nocobase-app-development/assets/business-examples/onboarding/server/providers/onboarding.ts +19 -9
  8. package/skills/nocobase-app-development/assets/business-examples/onboarding/tests/database/onboarding.test.ts +46 -0
  9. package/skills/nocobase-app-development/assets/business-examples/procurement/database/main/migrations/202611130004_procurement_definition_binding.ts +37 -0
  10. package/skills/nocobase-app-development/assets/business-examples/procurement/server/lifecycles/procurement.ts +3 -0
  11. package/skills/nocobase-app-development/assets/business-examples/procurement/server/providers/procurement.ts +19 -9
  12. package/skills/nocobase-app-development/assets/business-examples/procurement/tests/database/procurement.test.ts +44 -0
  13. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/detail.tsx +25 -43
  14. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/index.tsx +27 -18
  15. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/locales.ts +2 -0
  16. package/skills/nocobase-app-development/assets/list-edit-example/tests/client/skill-projects.test.tsx +29 -16
  17. package/skills/nocobase-app-development/references/business-administration.md +1 -1
  18. package/skills/nocobase-app-development/references/database-and-data.md +2 -0
  19. package/skills/nocobase-app-development/references/frontend/component-selection.md +2 -0
  20. package/skills/nocobase-app-development/references/frontend/mobile.md +2 -2
  21. package/skills/nocobase-app-development/references/frontend/references/example/list-page.md +32 -83
  22. package/skills/nocobase-app-development/references/frontend/references/table.md +41 -7
  23. package/skills/nocobase-app-development/references/frontend/ui-guidelines.md +3 -2
  24. package/skills/nocobase-app-development/references/lifecycle-parameters.md +44 -67
  25. package/skills/nocobase-app-development/references/lifecycle-ui.md +14 -6
  26. package/skills/nocobase-app-development/references/lifecycle-versions.md +83 -0
  27. package/skills/nocobase-app-development/references/lifecycle.md +19 -9
  28. package/skills/nocobase-app-development/references/system-settings.md +3 -3
  29. package/skills/nocobase-app-development/scripts/check-ui-components.mjs +122 -0
  30. package/skills/nocobase-app-upgrade/SKILL.md +2 -0
  31. package/skills/nocobase-app-upgrade/references/lifecycle-versioning-upgrade.md +47 -0
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Updated Date: November 7, 2026
1
+ Updated Date: November 16, 2026
2
2
 
3
3
  NocoBase License Agreement
4
4
 
@@ -14,27 +14,21 @@ The Company reserves the right to formulate and modify this Agreement from time
14
14
  1. Definitions
15
15
  ==============
16
16
 
17
- 1.1 "Software" refers to NocoBase, consisting of Core, Studio, and Commercial Plugins, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
17
+ 1.1 "Software" refers to NocoBase, including its application foundation (Core), its workspace for people and agents building software together (Studio), and the application templates, development standards, and development skills that come with them, together with their source code, installation packages, images, and all their modifications, updates, and upgrades.
18
18
 
19
- 1.2 "Core" refers to NocoBase Core, the open source application foundation released by the Company, including the runtime, plugins, application templates, development standards, and development skills placed in the same code repository.
19
+ 1.2 "Community Edition" refers to the free version of the Software provided to the User as open source through public channels.
20
20
 
21
- 1.3 "Studio" refers to NocoBase Studio, the governance platform for people and agents building software together, provided in the Commercial Edition.
21
+ 1.3 "Commercial Edition" refers to the paid version of the Software purchased by the User from the Company or its agents, downloaded through exclusive channels, with additional features and benefits. It consists of two versions: Professional Edition and Enterprise Edition.
22
22
 
23
- 1.4 "Commercial Plugins" refers to the plugins provided in the Commercial Edition that extend the capabilities of Core, such as advanced approvals and enterprise SSO.
23
+ 1.4 "Application" refers to a specific business use case application serving internal or external customers of the User, developed based on the Software, such as ERP/CRM. Studio is a development tool and is not part of any Application.
24
24
 
25
- 1.5 "Community Edition" refers to the free version of the Software provided to the User through public channels, namely Core.
25
+ 1.5 "Customer" refers to the clients who commission the User to develop Applications or purchase the User's Applications.
26
26
 
27
- 1.6 "Commercial Edition" refers to the paid version of the Software purchased by the User from the Company or its agents, downloaded through exclusive channels, and includes additional benefits. In addition to Core, it includes Studio and Commercial Plugins, and consists of two versions: Professional Edition and Enterprise Edition.
27
+ 1.6 "Agent" refers to an AI agent that works with the Software, including the coding agents the User uses to develop Applications and the business agents in Applications.
28
28
 
29
- 1.7 "Application" refers to a specific business use case application serving internal or external customers of the User, developed based on the Software, such as ERP/CRM. Studio is a development tool and is not part of any Application.
29
+ 1.7 "Third-Party Services" refers to the large models, coding agents, cloud services, and other third-party products and services that the User chooses to use with the Software.
30
30
 
31
- 1.8 "Customer" refers to the clients who commission the User to develop Applications or purchase the User's Applications.
32
-
33
- 1.9 "Agent" refers to an AI agent that works with the Software, including the coding agents the User uses to develop Applications and the business agents in Applications.
34
-
35
- 1.10 "Third-Party Services" refers to the large models, coding agents, cloud services, and other third-party products and services that the User chooses to use with the Software.
36
-
37
- 1.11 "Third-Party Open Source Software" refers to open source software provided with the Software. They are licensed through various published open source software licenses or copyright notices accompanying such software.
31
+ 1.8 "Third-Party Open Source Software" refers to open source software provided with the Software. They are licensed through various published open source software licenses or copyright notices accompanying such software.
38
32
 
39
33
  ===================================
40
34
  2. Intellectual Property Protection
@@ -62,9 +56,9 @@ The Company claims no intellectual property rights in the business code written
62
56
 
63
57
  4.1 This Agreement serves as the unified license agreement for NocoBase Software, applying to both the Community Edition and the Commercial Editions.
64
58
 
65
- 4.2 Core is open source software. This Agreement incorporates and references the full text of the Apache License, Version 2.0 ("Apache-2.0", available at: https://www.apache.org/licenses/LICENSE-2.0 ). Users of Core must comply with the Apache-2.0 License as well as the supplementary terms set forth in this Agreement. In case of any inconsistency between Apache-2.0 and this Agreement, the supplementary terms of this Agreement shall prevail.
59
+ 4.2 The Community Edition is open source software. This Agreement incorporates and references the full text of the Apache License, Version 2.0 ("Apache-2.0", available at: https://www.apache.org/licenses/LICENSE-2.0 ). Users of the Community Edition must comply with the Apache-2.0 License as well as the supplementary terms set forth in this Agreement. In case of any inconsistency between Apache-2.0 and this Agreement, the supplementary terms of this Agreement shall prevail.
66
60
 
67
- 4.3 Studio and Commercial Plugins are commercial software of the Company and are not licensed under Apache-2.0. They can only be used under the Commercial License and in accordance with this Agreement.
61
+ 4.3 The features that the Commercial Edition adds to the Community Edition are commercial software of the Company and are not licensed under Apache-2.0. They can only be used under the Commercial License and in accordance with this Agreement.
68
62
 
69
63
  ================================================
70
64
  5. Rights and Obligations of Open Source License
@@ -76,7 +70,9 @@ The Company claims no intellectual property rights in the business code written
76
70
 
77
71
  5.3 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
78
72
 
79
- 5.4 It is not allowed to provide to the public any form of AI application development platform or agent development platform SaaS/PaaS products using the original or modified Software.
73
+ 5.4 It is not allowed to provide to the public any form of AI application development platform or agent development platform SaaS/PaaS products using the original or modified Software, including Studio.
74
+
75
+ 5.5 It is not allowed to publicly release any plugin, skill, application template, or other extension that provides features identical or substantially similar to those of the Commercial Edition, whether free or paid and whether open source or not, including by publishing it to public code repositories, package registries, marketplaces, or websites, or by providing it to the public as a hosted service. The features of the Commercial Edition are as published on the Company's website. Developing and using such features for the User's own business, or providing them within Applications delivered to Customers, is not subject to this restriction.
80
76
 
81
77
  ===============================
82
78
  6. Rights of Commercial License
@@ -84,11 +80,11 @@ The Company claims no intellectual property rights in the business code written
84
80
 
85
81
  6.1 Obtain a permanent commercial license of the Software.
86
82
 
87
- 6.2 Can develop Applications for Customers, deploy the completed Applications, including the Commercial Plugins they use, on Customers' servers, or host them and provide them to Customers as a service. This does not include Studio.
83
+ 6.2 Can develop Applications for Customers, deploy the completed Applications, including the Commercial Edition features they use, on Customers' servers, or host them and provide them to Customers as a service.
88
84
 
89
- 6.3 Customers can use the Commercial Plugins in the Applications delivered to them, within those Applications only, and can continue to develop those Applications on their own or through others.
85
+ 6.3 Customers can use the Commercial Edition features in the Applications delivered to them, within those Applications only, and can continue to develop those Applications on their own or through others.
90
86
 
91
- 6.4 Get software upgrades and exclusive technical support during the upgrade validity period. Upgrades and technical support are provided to the User only, and the User can upgrade the Commercial Plugins in Applications delivered to Customers during this period.
87
+ 6.4 Get software upgrades and exclusive technical support during the upgrade validity period. Upgrades and technical support are provided to the User only, and the User can upgrade the Applications delivered to Customers during this period.
92
88
 
93
89
  6.5 The licensed Software can be used for commercial purposes with no restrictions on the number of Applications, Customers, users, and Agents.
94
90
 
@@ -106,15 +102,17 @@ The Company claims no intellectual property rights in the business code written
106
102
 
107
103
  7.3 It is not allowed to sell, transfer, lease, share, or distribute any form of AI application development platform, agent development platform, or developer tools developed based on Software.
108
104
 
109
- 7.4 It is not allowed to provide any form of AI application development platform or agent development platform SaaS/PaaS products to the public using the original or modified Software.
105
+ 7.4 It is not allowed to provide any form of AI application development platform or agent development platform SaaS/PaaS products to the public using the original or modified Software, including Studio.
106
+
107
+ 7.5 It is not allowed to publicly release any plugin, skill, application template, or other extension that provides features identical or substantially similar to those of the Commercial Edition, whether free or paid and whether open source or not, including by publishing it to public code repositories, package registries, marketplaces, or websites, or by providing it to the public as a hosted service. The features of the Commercial Edition are as published on the Company's website. Developing and using such features for the User's own business, or providing them within Applications delivered to Customers, is not subject to this restriction.
110
108
 
111
- 7.5 Studio can only be used by the User holding the Commercial License, on servers owned or rented by the User. It is not allowed to deploy Studio for Customers, or to provide Studio to Customers or any third party in any form, including as a hosted service. Customers that need Studio shall purchase their own Commercial License.
109
+ 7.6 The Commercial Edition can only be used by the User holding the Commercial License, on servers owned or rented by the User. Except for delivering Applications under 6.2, it is not allowed to deploy the Commercial Edition for Customers, or to provide it to Customers or any third party in any form, including as a hosted service. Customers that need the Commercial Edition shall purchase their own Commercial License.
112
110
 
113
- 7.6 Customer personnel can take part in requirement confirmation, acceptance, and release approval in the User's Studio for the Applications the User develops for them. This is not considered providing Studio to Customers, but it is not allowed to let Customers use Studio to develop their own projects.
111
+ 7.7 Customer personnel can take part in requirement confirmation, acceptance, and release approval in the User's Studio for the Applications the User develops for them. This is not considered providing the Commercial Edition to Customers, but it is not allowed to let Customers use the User's Studio to develop their own projects.
114
112
 
115
- 7.7 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
113
+ 7.8 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
116
114
 
117
- 7.8 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
115
+ 7.9 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
118
116
 
119
117
  =============================================================
120
118
  8. Legal Jurisdiction, Interpretation, and Dispute Resolution
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/app-skills",
3
- "version": "0.1.0-beta.64",
3
+ "version": "0.1.0-beta.66",
4
4
  "description": "Agent Skills for developing applications and plugins, upgrading and deploying NocoBase applications.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,6 +22,7 @@
22
22
  "devDependencies": {
23
23
  "@playwright/test": "^1.62.1",
24
24
  "prettier": "^3.9.6",
25
+ "vitest": "^4.1.10",
25
26
  "@nocobase/dev-config": "0.1.0-beta.25"
26
27
  },
27
28
  "peerDependencies": {
@@ -39,6 +40,7 @@
39
40
  "scripts": {
40
41
  "format": "prettier . --write",
41
42
  "format:check": "prettier . --check",
42
- "check": "pnpm format:check"
43
+ "check": "pnpm format:check",
44
+ "test": "vitest run"
43
45
  }
44
46
  }
@@ -81,6 +81,8 @@ For approval requirements, check `@nocobase/app-plugin-approval` first and follo
81
81
 
82
82
  When the stages of a business record are fixed by developers rather than drawn by administrators — an expense report, a ticket, a contract, an order — build it with `@nocobase/lifecycle` as [record lifecycles](references/lifecycle.md) describes: the state stays in the record's own field and changes only through declared transitions. Declare only required business paths with precise sources and destinations; the diagram expands every `from × to` pair rather than analyzing routing logic. Follow [readable process graphs](references/lifecycle-ui.md#keep-process-graphs-readable) before rendering dense definitions.
83
83
 
84
+ Before changing lifecycle behavior or removing a version, read [versions of a process](references/lifecycle-versions.md): behavior freezes against the target main branch, unmerged new versions can be edited continuously, and deleting a frozen version requires explicit user retirement confirmation.
85
+
84
86
  For notification configuration or sending, follow the notification plugin Skill: `notification.channels` maps each name to one flat channel configuration with `type` (`provider` remains a compatibility alias), and `send({ idempotencyKey, messages })` supplies a complete message per Channel. Use native addresses; email and in-app arrays create independent deliveries, while Webhooks forbid `to`.
85
87
 
86
88
  Install, update and customize plugins, and remove a direct NocoBase package, as [plugins](references/plugins.md) describes: `pnpm nocobase plugin register`, `plugin update` and `package remove` keep the manifest, the lockfile, the composition roots and the synchronized Skills consistent, so never hand-edit only one of them.
@@ -133,6 +135,8 @@ For business lists, reuse the template-provided `DataTable` and companions from
133
135
 
134
136
  Every page and overlay you build or change works on a phone in the first delivery, without the user asking: decide its phone layout while designing it and verify it at phone widths before calling it done, following [the phone experience](references/frontend/mobile.md). Shrinking the desktop page, wrapping its toolbar or scrolling an ordinary table sideways does not count; ordinary lists use `DataTable`'s phone cards (`renderCard`) and its `search`, `filters` and `getColumnLabel` toolbar row, and create and edit forms sit in a `FeedbackForm` given `values={form.getValues}` and `savedValues` (the stored record, or the blank values; never the restored draft) inside the route overlay, which asks before discarding any difference on every way out, whatever changed it and with or without a saved draft.
135
137
 
138
+ **Table row actions are one "⋮" menu (T1.5, Must).** Every table row's actions, a single action included, render through `RowActions` from `#components/row-actions` at the end of the row: the same icon-only "⋮" trigger on every row, in every record state and on every page, business and administration lists alike, with no visible header text over the actions column and no sticky or right-pinned column. The record's state and the viewer's permissions change which items the menu holds, never how the entry looks; no item left means no menu. Never show an action as a text link, an outline button or a row of buttons because it seems frequent or primary: show a named action outside the menu (`exposed`) only when the user asked for it or a confirmed page design shows it, and pin the column only for a wide table whose actions are otherwise out of reach, recording the reason. Details: [section 8 of `table.md`](references/frontend/references/table.md#8-column-definitions-and-row-actions).
139
+
136
140
  **Unsaved input is never lost silently (M7.4, Must).** Every create or edit form is a `FeedbackForm` from `#components/feedback-form` with `values={form.getValues}` and `savedValues` (the stored record as the form shows it, or the blank values of a new record; never the restored draft), rendered inside its `RouteDialog`, `RouteDrawer` or covering `RouteChildPage`; a form kept in `useState` instead of React Hook Form passes `values={() => values}` and `savedValues` the same way. That layer then asks "Discard changes?" before Cancel, ×, Esc, the backdrop, browser back and links, and the browser warns before a reload, whenever the form differs from what is saved. Keeping a draft does not replace the question, and neither does working storage: do not swap `FeedbackForm` for a plain `<form>`, do not make `dirty` or a `beforeunload` handler depend on a draft or storage state, do not render `OwnDiscardQuestion` because a draft is kept (it only declares that the file's own guard asks about its unsaved input, as the settings forms do; a guard that only blocks while a save runs asks nothing), and do not test "cancel, reopen, the input is back" as the cancel path. An unknown outcome is not a lock: after a lost response, a 5xx or a timeout, `submission.pending` stays true for the same-key retry, but only `submitting` blocks leaving. Cancel stays enabled, `beforeClose` and any guard of your own read only the save in flight (never `submission.pending`), and the `FeedbackForm`'s `values` and `savedValues` make every way out ask "Discard changes?" as before the save; "Keep editing" keeps the input for the retry, and "Discard" really leaves, with the key left in session storage so reopening offers the same retry. The [component checker](scripts/check-ui-components.mjs) rejects a plain create or edit `<form>`, a `FeedbackForm` without `values` and `savedValues` (React Hook Form or `useState`), a draft-based `dirty`, and an `OwnDiscardQuestion` whose file has no guard reading an unsaved state, and no exception marker waives these findings. Details: [unsaved changes in an overlay](references/frontend/references/overlay.md#25-beforeclose-checks-before-closing).
137
141
 
138
142
  Use [the frontend workflow](references/frontend/ui-workflow.md) selected during feature planning, or select it before a frontend-only change. Routine pages and CRUD using established patterns take the quick workflow; complex interactions and cross-module design decisions take the full workflow with internal design and acceptance reviews. Theme changes use their own verification. Each workflow routes to the relevant [UI guidelines](references/frontend/ui-guidelines.md) and [frontend handbook](references/frontend/frontend-dev.md); none adds a default user approval round.
@@ -162,6 +166,7 @@ Read the page for the task in front of you. Do not read all of them.
162
166
  | A record that moves through stages defined in code: simple confirmations, tickets, orders, timeouts, effects after a state change | [record lifecycles](references/lifecycle.md) |
163
167
  | Administrator-adjustable approval departments, reviewers, thresholds or business values in a code-defined lifecycle | [configurable lifecycle parameters](references/lifecycle-parameters.md); keep workflow structure in source. For management forms and optional diagram-bound editing, see [Lifecycle UI](references/lifecycle-ui.md). |
164
168
  | Lifecycle definition catalogs, execution lists, process details, history or parameter settings | [Lifecycle UI](references/lifecycle-ui.md) |
169
+ | Changing lifecycle behavior, adding or deleting a version, or choosing an entry point's version | [versions of a process](references/lifecycle-versions.md) |
165
170
  | Flowcharts, process diagrams or lifecycle state diagrams | Use UI Library `@nocobase/flow-diagram` for generic graphs and `@nocobase/lifecycle-diagram` for lifecycle descriptions; see [diagram guidance](references/lifecycle.md#draw-an-interactive-lifecycle-diagram) and the [UI catalog](references/frontend/references/ui-library.md#diagrams). Preserve their application theme tokens. |
166
171
  | Use `@nocobase/app-testing` for database, server, client or CLI tests; verify before finishing | [testing and verification](references/testing.md) |
167
172
  | Run a CLI command: configure, migrate, manage plugins, read the data model | [the command line](references/cli.md) |
@@ -15,6 +15,7 @@
15
15
  "server/providers/procurement-reset.ts",
16
16
  "server/lifecycles/procurement.ts",
17
17
  "database/main/migrations/202611040001_create_procurement.ts",
18
+ "database/main/migrations/202611130004_procurement_definition_binding.ts",
18
19
  "database/main/seeds/202611040001_procurement.ts",
19
20
  "database/main/seeds/202611040002_procurement_samples.ts",
20
21
  "cli/commands/procurement-reset.ts",
@@ -127,6 +128,7 @@
127
128
  "server/providers/onboarding-reset.ts",
128
129
  "server/lifecycles/onboarding.ts",
129
130
  "database/main/migrations/202611050001_create_onboarding.ts",
131
+ "database/main/migrations/202611130005_onboarding_definition_binding.ts",
130
132
  "database/main/seeds/202611050001_onboarding.ts",
131
133
  "database/main/seeds/202611050002_onboarding_samples.ts",
132
134
  "cli/commands/onboarding-reset.ts",
@@ -0,0 +1,37 @@
1
+ import { defineMigration, type MigrationDefinition } from '@nocobase/db';
2
+
3
+ /**
4
+ * Each record names the lifecycle definition that created it, so a second
5
+ * version of a process can run on the same table without either version
6
+ * reading or moving the other's records. Every record here was created by
7
+ * the only definition its table has ever had, so that name is the reliable
8
+ * binding; a value already present is kept.
9
+ */
10
+ const BINDINGS: readonly (readonly [collection: string, definition: string])[] =
11
+ [
12
+ ['onboardingCases', 'onboarding'],
13
+ ];
14
+
15
+ const migration: MigrationDefinition = defineMigration({
16
+ name: '202611130005_onboarding_definition_binding',
17
+ async up({ builder, query }) {
18
+ for (const [collection, definition] of BINDINGS) {
19
+ await builder.alterCollection(collection, (table) => {
20
+ table.string('lifecycleDefinition').nullable();
21
+ });
22
+ await query
23
+ .updateTable(collection)
24
+ .set({ lifecycleDefinition: definition })
25
+ .where('lifecycleDefinition', 'is', null)
26
+ .execute();
27
+ }
28
+ },
29
+ async down({ builder }) {
30
+ for (const [collection] of [...BINDINGS].reverse())
31
+ await builder.alterCollection(collection, (table) => {
32
+ table.dropField('lifecycleDefinition');
33
+ });
34
+ },
35
+ });
36
+
37
+ export default migration;
@@ -7,6 +7,9 @@ export const onboardingLifecycle = defineLifecycle<{
7
7
  state: 'draft' | 'submitted';
8
8
  }>({
9
9
  name: 'onboarding',
10
+ key: 'onboarding',
11
+ version: 1,
12
+ definitionField: 'lifecycleDefinition',
10
13
  collection: 'onboardingCases',
11
14
  initial: 'draft',
12
15
  states: ['draft', { name: 'submitted', final: true }],
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import type { DatabaseConnection, Row, FilterBuilder } from '@nocobase/db';
3
3
  import type { AppAuthorization } from '@nocobase/app-plugin-authorization';
4
- import type { LifecycleRuntime } from '@nocobase/lifecycle';
4
+ import type { LifecycleRecord, LifecycleRuntime } from '@nocobase/lifecycle';
5
5
  import { ApiError } from '@nocobase/app-server/router';
6
6
  import {
7
7
  ONBOARDING_ACCESS,
@@ -160,7 +160,12 @@ export class OnboardingService {
160
160
  .repository('onboardingEmployees')
161
161
  .findOne({ filter: { caseId: id } })
162
162
  : null,
163
- this.runtime.view('onboarding', id, { id: actor.id }),
163
+ // The version the case is bound to, whichever is the latest.
164
+ this.runtime.view(
165
+ this.runtime.recordLifecycle('onboarding', row as LifecycleRecord),
166
+ id,
167
+ { id: actor.id },
168
+ ),
164
169
  ]);
165
170
  const editable =
166
171
  actor.coordinate &&
@@ -345,13 +350,18 @@ export class OnboardingService {
345
350
  );
346
351
  await this.validateDepartment(parsed.data.departmentId, actor, tx);
347
352
  // Native lifecycle version checks serialize edits/submissions of this case.
348
- await this.runtime.fire('onboarding', id, 'submit', {
349
- actor: { id: actor.id },
350
- manual: true,
351
- expect: { version },
352
- requestId: key,
353
- transaction: tx,
354
- });
353
+ await this.runtime.fire(
354
+ this.runtime.recordLifecycle('onboarding', row as LifecycleRecord),
355
+ id,
356
+ 'submit',
357
+ {
358
+ actor: { id: actor.id },
359
+ manual: true,
360
+ expect: { version },
361
+ requestId: key,
362
+ transaction: tx,
363
+ },
364
+ );
355
365
  email = parsed.data.workEmail;
356
366
  if (
357
367
  await tx
@@ -1,5 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { describeMigration } from '@nocobase/app-testing/server';
3
+ import { expect } from 'vitest';
3
4
 
4
5
  describeMigration('202611050001_create_onboarding', {
5
6
  sources: [
@@ -52,3 +53,48 @@ describeMigration('202611050001_create_onboarding', {
52
53
  await expectCollection(name).not.toExist();
53
54
  },
54
55
  });
56
+
57
+ // A case written before the binding column belongs to the only definition
58
+ // the table has had.
59
+ describeMigration('202611130005_onboarding_definition_binding', {
60
+ sources: [
61
+ {
62
+ packageName: 'onboarding-test',
63
+ directory: path.resolve(
64
+ import.meta.dirname,
65
+ '../../database/main/migrations',
66
+ ),
67
+ },
68
+ ],
69
+ async before({ connection }) {
70
+ await connection.repository('onboardingCases').createOne({
71
+ values: {
72
+ id: 'case-before-binding',
73
+ fullName: 'Lin Wei',
74
+ workEmail: 'lin@example.com',
75
+ nationality: 'CN',
76
+ jobTitle: 'Engineer',
77
+ startDate: '2026-12-01',
78
+ contractEndDate: '2027-12-01',
79
+ coordinatorId: 'chen',
80
+ status: 'draft',
81
+ statusChangedAt: '2026-11-01T00:00:00.000Z',
82
+ lifecycleVersion: 1,
83
+ createdAt: '2026-11-01T00:00:00.000Z',
84
+ },
85
+ });
86
+ },
87
+ async up({ connection, expectCollection }) {
88
+ await expectCollection('onboardingCases').toHaveField(
89
+ 'lifecycleDefinition',
90
+ { type: 'string', nullable: true },
91
+ );
92
+ const rows = await connection.repository('onboardingCases').findMany({});
93
+ expect(rows.map((row) => row.lifecycleDefinition)).toEqual(['onboarding']);
94
+ },
95
+ async down({ expectCollection }) {
96
+ await expectCollection('onboardingCases').not.toHaveField(
97
+ 'lifecycleDefinition',
98
+ );
99
+ },
100
+ });
@@ -0,0 +1,37 @@
1
+ import { defineMigration, type MigrationDefinition } from '@nocobase/db';
2
+
3
+ /**
4
+ * Each record names the lifecycle definition that created it, so a second
5
+ * version of a process can run on the same table without either version
6
+ * reading or moving the other's records. Every record here was created by
7
+ * the only definition its table has ever had, so that name is the reliable
8
+ * binding; a value already present is kept.
9
+ */
10
+ const BINDINGS: readonly (readonly [collection: string, definition: string])[] =
11
+ [
12
+ ['procurementRequests', 'procurement'],
13
+ ];
14
+
15
+ const migration: MigrationDefinition = defineMigration({
16
+ name: '202611130004_procurement_definition_binding',
17
+ async up({ builder, query }) {
18
+ for (const [collection, definition] of BINDINGS) {
19
+ await builder.alterCollection(collection, (table) => {
20
+ table.string('lifecycleDefinition').nullable();
21
+ });
22
+ await query
23
+ .updateTable(collection)
24
+ .set({ lifecycleDefinition: definition })
25
+ .where('lifecycleDefinition', 'is', null)
26
+ .execute();
27
+ }
28
+ },
29
+ async down({ builder }) {
30
+ for (const [collection] of [...BINDINGS].reverse())
31
+ await builder.alterCollection(collection, (table) => {
32
+ table.dropField('lifecycleDefinition');
33
+ });
34
+ },
35
+ });
36
+
37
+ export default migration;
@@ -23,6 +23,9 @@ const reviewer = ({
23
23
  // Capability checks and transaction-bound reference/amount checks belong to the service.
24
24
  export const procurementLifecycle = defineLifecycle<Types>({
25
25
  name: 'procurement',
26
+ key: 'procurement',
27
+ version: 1,
28
+ definitionField: 'lifecycleDefinition',
26
29
  collection: 'procurementRequests',
27
30
  initial: 'draft',
28
31
  states: ['draft', 'submitted', 'rejected', { name: 'approved', final: true }],
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import type { DatabaseConnection, Row } from '@nocobase/db';
3
3
  import type { AppAuthorization } from '@nocobase/app-plugin-authorization';
4
- import type { LifecycleRuntime } from '@nocobase/lifecycle';
4
+ import type { LifecycleRecord, LifecycleRuntime } from '@nocobase/lifecycle';
5
5
  import { ApiError } from '@nocobase/app-server/router';
6
6
  import {
7
7
  amount,
@@ -194,7 +194,12 @@ export class ProcurementService {
194
194
  filter: { requestId: id },
195
195
  sort: (s) => s.field('position').asc(),
196
196
  });
197
- const view = await this.runtime.view('procurement', id, { id: actor.id });
197
+ // The version the request is bound to, whichever is the latest.
198
+ const view = await this.runtime.view(
199
+ this.runtime.recordLifecycle('procurement', row as LifecycleRecord),
200
+ id,
201
+ { id: actor.id },
202
+ );
198
203
  const editable =
199
204
  actor.request &&
200
205
  row.applicantId === actor.id &&
@@ -475,13 +480,18 @@ export class ProcurementService {
475
480
  'Only the designated reviewer can decide.',
476
481
  'PERMISSION_DENIED',
477
482
  );
478
- const result = await this.runtime.fire('procurement', id, transition, {
479
- actor: { id: actor.id },
480
- manual: true,
481
- expect: { version },
482
- requestId,
483
- transaction: tx,
484
- });
483
+ const result = await this.runtime.fire(
484
+ this.runtime.recordLifecycle('procurement', row as LifecycleRecord),
485
+ id,
486
+ transition,
487
+ {
488
+ actor: { id: actor.id },
489
+ manual: true,
490
+ expect: { version },
491
+ requestId,
492
+ transaction: tx,
493
+ },
494
+ );
485
495
  return { id, replayed: result.replayed === true };
486
496
  });
487
497
  }
@@ -1,5 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { describeMigration } from '@nocobase/app-testing/server';
3
+ import { expect } from 'vitest';
3
4
 
4
5
  describeMigration('202611040001_create_procurement', {
5
6
  sources: [
@@ -46,3 +47,46 @@ describeMigration('202611040001_create_procurement', {
46
47
  await expectCollection(name).not.toExist();
47
48
  },
48
49
  });
50
+
51
+ // A request written before the binding column belongs to the only
52
+ // definition the table has had.
53
+ describeMigration('202611130004_procurement_definition_binding', {
54
+ sources: [
55
+ {
56
+ packageName: 'procurement-test',
57
+ directory: path.resolve(
58
+ import.meta.dirname,
59
+ '../../database/main/migrations',
60
+ ),
61
+ },
62
+ ],
63
+ async before({ connection }) {
64
+ await connection.repository('procurementRequests').createOne({
65
+ values: {
66
+ id: 'request-before-binding',
67
+ title: 'Notebooks',
68
+ applicantId: 'lin',
69
+ status: 'draft',
70
+ statusChangedAt: '2026-11-01T00:00:00.000Z',
71
+ lifecycleVersion: 1,
72
+ totalMinor: 1250,
73
+ createdAt: '2026-11-01T00:00:00.000Z',
74
+ },
75
+ });
76
+ },
77
+ async up({ connection, expectCollection }) {
78
+ await expectCollection('procurementRequests').toHaveField(
79
+ 'lifecycleDefinition',
80
+ { type: 'string', nullable: true },
81
+ );
82
+ const rows = await connection
83
+ .repository('procurementRequests')
84
+ .findMany({});
85
+ expect(rows.map((row) => row.lifecycleDefinition)).toEqual(['procurement']);
86
+ },
87
+ async down({ expectCollection }) {
88
+ await expectCollection('procurementRequests').not.toHaveField(
89
+ 'lifecycleDefinition',
90
+ );
91
+ },
92
+ });
@@ -13,7 +13,6 @@ import {
13
13
  useParams,
14
14
  } from 'react-router';
15
15
  import type { ColumnDef } from '@tanstack/react-table';
16
- import { MoreHorizontal } from 'lucide-react';
17
16
  import { RouteChildPage } from '#components/route-child-page';
18
17
  import { BackButton } from '#components/back-button';
19
18
  import { PageContainer } from '#components/page-container';
@@ -22,15 +21,9 @@ import { LongText } from '#components/long-text';
22
21
  import { DataTable } from '#components/data-table';
23
22
  import { RefreshIndicator } from '#components/loading';
24
23
  import { RecordLink } from '#components/record-link';
24
+ import { RowActions } from '#components/row-actions';
25
25
  import { StatusBadge } from '#components/status-badge';
26
26
  import { Button } from '#components/ui/button';
27
- import {
28
- DropdownMenu,
29
- DropdownMenuTrigger,
30
- DropdownMenuContent,
31
- DropdownMenuItem,
32
- DropdownMenuSeparator,
33
- } from '#components/ui/dropdown-menu';
34
27
  import {
35
28
  AlertDialog,
36
29
  AlertDialogContent,
@@ -111,39 +104,28 @@ export default function CustomerDetailPage() {
111
104
  parent.reload();
112
105
  },
113
106
  };
114
- // A contact's actions: the table row's menu, and the card's on a phone where it is a full-size tap target (M8.1).
115
- const contactMenu = (contact: Contact, size: 'icon-sm' | 'icon') => (
116
- <DropdownMenu>
117
- <DropdownMenuTrigger
118
- render={
119
- <Button
120
- variant='ghost'
121
- size={size}
122
- aria-label={t('customerContacts.actionsFor', {
123
- name: contact.name,
124
- })}
125
- />
126
- }
127
- >
128
- <MoreHorizontal />
129
- </DropdownMenuTrigger>
130
- <DropdownMenuContent align='end' className='w-auto min-w-40'>
131
- <DropdownMenuItem
132
- render={
107
+ // A contact's actions: the table row's "⋮" menu, which DataTable also hands to the contact's phone card.
108
+ const contactMenu = (contact: Contact) => (
109
+ <RowActions
110
+ label={t('customerContacts.actionsFor', { name: contact.name })}
111
+ actions={[
112
+ {
113
+ key: 'edit',
114
+ label: t('customerContacts.edit'),
115
+ render: (
133
116
  <Link
134
117
  to={{
135
118
  pathname: `contacts/${contact.id}/edit`,
136
119
  search: location.search,
137
120
  }}
138
121
  />
139
- }
140
- >
141
- {t('customerContacts.edit')}
142
- </DropdownMenuItem>
143
- <DropdownMenuSeparator />
144
- <DropdownMenuItem
145
- variant='destructive'
146
- onClick={() => {
122
+ ),
123
+ },
124
+ {
125
+ key: 'delete',
126
+ label: t('customerContacts.delete'),
127
+ destructive: true,
128
+ onClick: () => {
147
129
  void (async () => {
148
130
  if (!lock.acquire()) return;
149
131
  try {
@@ -157,12 +139,10 @@ export default function CustomerDetailPage() {
157
139
  lock.release();
158
140
  }
159
141
  })();
160
- }}
161
- >
162
- {t('customerContacts.delete')}
163
- </DropdownMenuItem>
164
- </DropdownMenuContent>
165
- </DropdownMenu>
142
+ },
143
+ },
144
+ ]}
145
+ />
166
146
  );
167
147
  const columns: ColumnDef<Contact>[] = [
168
148
  {
@@ -193,9 +173,11 @@ export default function CustomerDetailPage() {
193
173
  ? [
194
174
  {
195
175
  id: 'actions',
196
- header: t('customerContacts.actions'),
176
+ header: () => (
177
+ <span className='sr-only'>{t('customerContacts.actions')}</span>
178
+ ),
197
179
  cell: ({ row }: { row: { original: Contact } }) =>
198
- contactMenu(row.original, 'icon-sm'),
180
+ contactMenu(row.original),
199
181
  },
200
182
  ]
201
183
  : []),