@nocobase/app-skills 0.1.0-beta.54 → 0.1.0-beta.55

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 (97) hide show
  1. package/package.json +1 -1
  2. package/skills/nocobase-app-development/SKILL.md +16 -1
  3. package/skills/nocobase-app-development/assets/business-examples/index.json +186 -0
  4. package/skills/nocobase-app-development/assets/business-examples/procurement/cli/commands/procurement-reset.ts +63 -0
  5. package/skills/nocobase-app-development/assets/business-examples/procurement/client/pages/procurement/detail.tsx +501 -0
  6. package/skills/nocobase-app-development/assets/business-examples/procurement/client/pages/procurement/index.tsx +123 -0
  7. package/skills/nocobase-app-development/assets/business-examples/procurement/client/pages/procurement/locales.ts +127 -0
  8. package/skills/nocobase-app-development/assets/business-examples/procurement/client/pages/procurement/reference.tsx +131 -0
  9. package/skills/nocobase-app-development/assets/business-examples/procurement/database/main/migrations/202611040001_create_procurement.ts +58 -0
  10. package/skills/nocobase-app-development/assets/business-examples/procurement/database/main/seeds/202611040001_procurement.ts +46 -0
  11. package/skills/nocobase-app-development/assets/business-examples/procurement/database/main/seeds/202611040002_procurement_samples.ts +18 -0
  12. package/skills/nocobase-app-development/assets/business-examples/procurement/docs/procurement.md +46 -0
  13. package/skills/nocobase-app-development/assets/business-examples/procurement/server/lifecycles/procurement.ts +50 -0
  14. package/skills/nocobase-app-development/assets/business-examples/procurement/server/providers/procurement-registration.ts +27 -0
  15. package/skills/nocobase-app-development/assets/business-examples/procurement/server/providers/procurement-reset.ts +23 -0
  16. package/skills/nocobase-app-development/assets/business-examples/procurement/server/providers/procurement.ts +513 -0
  17. package/skills/nocobase-app-development/assets/business-examples/procurement/server/routes/procurement.ts +317 -0
  18. package/skills/nocobase-app-development/assets/business-examples/procurement/shared/procurement.ts +98 -0
  19. package/skills/nocobase-app-development/assets/business-examples/procurement/tests/client/procurement.test.tsx +394 -0
  20. package/skills/nocobase-app-development/assets/business-examples/procurement/tests/database/procurement.test.ts +48 -0
  21. package/skills/nocobase-app-development/assets/business-examples/procurement/tests/playwright/procurement.test.ts +442 -0
  22. package/skills/nocobase-app-development/assets/business-examples/procurement/tests/server/procurement.test.ts +631 -0
  23. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/batch.tsx +174 -0
  24. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/detail.tsx +362 -0
  25. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/edit.tsx +414 -0
  26. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/index.tsx +472 -0
  27. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/locales.ts +152 -0
  28. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/model.ts +69 -0
  29. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/relation-picker.tsx +281 -0
  30. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/shared.tsx +150 -0
  31. package/skills/nocobase-app-development/assets/customer-contacts-example/database/main/migrations/202611030002_create_customer_contacts.ts +43 -0
  32. package/skills/nocobase-app-development/assets/customer-contacts-example/database/main/seeds/202611030002_customer_contacts.ts +184 -0
  33. package/skills/nocobase-app-development/assets/customer-contacts-example/server/providers/customer-contacts-authorization.ts +156 -0
  34. package/skills/nocobase-app-development/assets/customer-contacts-example/server/providers/customer-contacts-data.ts +44 -0
  35. package/skills/nocobase-app-development/assets/customer-contacts-example/server/providers/customer-contacts.ts +375 -0
  36. package/skills/nocobase-app-development/assets/customer-contacts-example/server/routes/customer-contacts.ts +370 -0
  37. package/skills/nocobase-app-development/assets/customer-contacts-example/tests/client/customer-contacts.test.tsx +527 -0
  38. package/skills/nocobase-app-development/assets/customer-contacts-example/tests/database/customer-contacts-migration.test.ts +36 -0
  39. package/skills/nocobase-app-development/assets/customer-contacts-example/tests/server/customer-contacts.test.ts +375 -0
  40. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/edit.tsx +369 -0
  41. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/index.tsx +255 -0
  42. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/locales.ts +79 -0
  43. package/skills/nocobase-app-development/assets/list-edit-example/database/main/migrations/202611030001_create_skill_projects.ts +14 -0
  44. package/skills/nocobase-app-development/assets/list-edit-example/server/providers/skill-projects.ts +48 -0
  45. package/skills/nocobase-app-development/assets/list-edit-example/server/routes/skill-projects.ts +204 -0
  46. package/skills/nocobase-app-development/assets/list-edit-example/tests/client/skill-projects.test.tsx +735 -0
  47. package/skills/nocobase-app-development/assets/list-edit-example/tests/database/skill-projects-migration.test.ts +27 -0
  48. package/skills/nocobase-app-development/assets/list-edit-example/tests/server/skill-projects.test.ts +211 -0
  49. package/skills/nocobase-app-development/references/authorization.md +3 -1
  50. package/skills/nocobase-app-development/references/business-examples.md +13 -0
  51. package/skills/nocobase-app-development/references/frontend/component-selection.md +45 -0
  52. package/skills/nocobase-app-development/references/frontend/design-contract.md +81 -0
  53. package/skills/nocobase-app-development/references/frontend/design-sources.md +22 -0
  54. package/skills/nocobase-app-development/references/frontend/frontend-dev.md +8 -2
  55. package/skills/nocobase-app-development/references/frontend/references/api.md +10 -2
  56. package/skills/nocobase-app-development/references/frontend/references/example/copy.md +1 -6
  57. package/skills/nocobase-app-development/references/frontend/references/example/list-page.md +72 -140
  58. package/skills/nocobase-app-development/references/frontend/references/example/server-table.md +48 -69
  59. package/skills/nocobase-app-development/references/frontend/references/example.md +3 -1
  60. package/skills/nocobase-app-development/references/frontend/references/executable-list-edit.md +41 -0
  61. package/skills/nocobase-app-development/references/frontend/references/executable-relation-batch.md +44 -0
  62. package/skills/nocobase-app-development/references/frontend/references/form.md +11 -0
  63. package/skills/nocobase-app-development/references/frontend/references/i18n.md +9 -9
  64. package/skills/nocobase-app-development/references/frontend/references/list-feedback.md +98 -0
  65. package/skills/nocobase-app-development/references/frontend/references/overlay.md +20 -6
  66. package/skills/nocobase-app-development/references/frontend/references/page.md +16 -28
  67. package/skills/nocobase-app-development/references/frontend/references/shadcn.md +2 -0
  68. package/skills/nocobase-app-development/references/frontend/references/styling.md +1 -1
  69. package/skills/nocobase-app-development/references/frontend/references/table.md +15 -26
  70. package/skills/nocobase-app-development/references/frontend/references/testing.md +30 -0
  71. package/skills/nocobase-app-development/references/frontend/references/ui-library.md +13 -1
  72. package/skills/nocobase-app-development/references/frontend/templates/design.md +35 -22
  73. package/skills/nocobase-app-development/references/frontend/templates/prompts.md +22 -12
  74. package/skills/nocobase-app-development/references/frontend/templates/review.md +27 -11
  75. package/skills/nocobase-app-development/references/frontend/templates/run.md +19 -3
  76. package/skills/nocobase-app-development/references/frontend/templates/system-design.md +39 -0
  77. package/skills/nocobase-app-development/references/frontend/ui-acceptance.md +47 -0
  78. package/skills/nocobase-app-development/references/frontend/ui-guidelines.md +22 -18
  79. package/skills/nocobase-app-development/references/frontend/ui-workflow.md +41 -38
  80. package/skills/nocobase-app-development/references/lifecycle.md +1 -1
  81. package/skills/nocobase-app-development/references/plugins.md +1 -1
  82. package/skills/nocobase-app-development/references/services-and-jobs.md +6 -2
  83. package/skills/nocobase-app-development/references/submission.md +10 -6
  84. package/skills/nocobase-app-development/scripts/check-ui-components.mjs +339 -0
  85. package/skills/nocobase-app-plugin-development/SKILL.md +4 -1
  86. package/skills/nocobase-app-plugin-development/assets/testing-example/package.json +2 -1
  87. package/skills/nocobase-app-plugin-development/assets/testing-example/tests/fixtures/app/server/app.ts +0 -2
  88. package/skills/nocobase-app-plugin-development/assets/testing-example/tests/fixtures/app/server/runtime.ts +1 -1
  89. package/skills/nocobase-app-plugin-development/references/client-components.md +4 -0
  90. package/skills/nocobase-app-plugin-development/references/configuration.md +4 -0
  91. package/skills/nocobase-app-plugin-development/references/server.md +1 -1
  92. package/skills/nocobase-app-plugin-development/references/testing.md +5 -1
  93. package/skills/nocobase-app-plugin-development/references/ui-design.md +38 -0
  94. package/skills/nocobase-app-upgrade/SKILL.md +4 -0
  95. package/skills/nocobase-app-upgrade/references/edge-cases.md +6 -0
  96. package/skills/nocobase-app-upgrade/references/list-feedback-upgrade.md +38 -0
  97. package/skills/nocobase-deployment/SKILL.md +6 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/app-skills",
3
- "version": "0.1.0-beta.54",
3
+ "version": "0.1.0-beta.55",
4
4
  "description": "Agent Skills for developing applications and plugins, upgrading and deploying NocoBase applications.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,8 +37,18 @@ If instead you find `client/plugin.ts`, `server/plugin.ts`, or a `defineServerPl
37
37
 
38
38
  Do not infer the application's capabilities from a template name or from this Skill. Inspect `package.json`, `client/plugins.ts`, `server/plugins.ts`, `cli/plugins.ts`, `server/config/index.ts`, and `database/` before deciding what is installed, registered, configured, or application-owned. `nocobase.templatePackage` and `nocobase.templateKind` identify known template ancestry when present, but a new template remains valid without being listed here. Read [template variants](references/template-variants.md) only when those files identify one of the documented official templates.
39
39
 
40
+ ## Plan the complete feature before implementation
41
+
42
+ For a new application or a feature spanning frontend and backend, identify the users' tasks, pages and key interactions together with the data, endpoint contracts and permissions before implementing either side. Read [the frontend workflow](references/frontend/ui-workflow.md#choosing-a-workflow) at this point, not only when opening `client/`. Reuse existing requirements, designs and installed capabilities; a routine CRUD feature can use a short implementation plan without a separate design document. Keep API-only, UI-only and other explicitly limited requests within their requested scope.
43
+
44
+ Proceed through the authorized implementation and verification without a routine design approval stop. Ask early only when a material business rule or scope decision cannot be resolved from the requirements, existing decisions and conventions, when work exceeds authorization, or when the user explicitly requested review first. State reasonable assumptions, preserve prior answers and continue unaffected work while a necessary decision is pending. Internal design and acceptance reviews are quality checks, not additional user approval rounds.
45
+
46
+ Deliver the requested user operation across its layers: pages invoke real endpoints, data is saved and refreshed correctly, permissions hold, and loading, empty and failure states are handled. Backend tests or a design document alone are progress, not completion of a full application. If the backend is already implemented, reuse and check its contracts against the required pages, close any gaps and finish the frontend without restarting design approval. Report missing implementation and unavailable verification explicitly.
47
+
40
48
  ## Choose where the feature belongs
41
49
 
50
+ For a complete parent/child business flow with scoped references, amounts and single-person review, consult the [business example catalogue](references/business-examples.md) and its runnable scenario index. Its resources supplement the existing list/edit patterns; read each scenario's integration dependencies before adapting it.
51
+
42
52
  Build application-specific features directly in the application by default. Use a plugin when the user requests one or when code reuse or modular organization calls for a separately registered, maintainable feature. Create local plugins under `packages/` with the project plugin development Skill; do not use the source repository's `packages/plugins/` layout. The App builds and packages registered local plugins for deployment without an npm release. Publish only when distributing the plugin through a package registry.
43
53
 
44
54
  Ordinary internal workspace packages can share code without plugin registration. Follow [internal workspace packages](references/dependencies.md#internal-workspace-packages), keeping one application at the workspace root with internal packages under `packages/`. The [runnable package example](references/internal-package-example.md) supplies complete configuration and explains declaration watching.
@@ -106,9 +116,13 @@ For initialization prerequisites introduced by the feature, apply [setup readine
106
116
 
107
117
  ## Frontend work
108
118
 
119
+ Before implementing interactions, follow [component selection and source review](references/frontend/component-selection.md): existing business component → installed shadcn primitive → registry addition → justified custom composition/primitive. Record the actual component source and run the targeted component checker before delivery; a matching screenshot alone does not justify duplicating a primitive.
120
+
121
+ Application and plugin UI share [the UI design contract](references/frontend/design-contract.md). Read the application's existing design records and original UI references first: record whether a reference controls appearance, structure or style, apply authorized page exceptions, and retain reusable decisions outside synchronized Skills. Use the contract's system-design section when planning a business system across modules; do not redesign the system for a small edit. Plugin implementation still belongs to `nocobase-app-plugin-development`, whose UI entry points to these same design and acceptance rules.
122
+
109
123
  For business lists, reuse the template-provided `DataTable` and companions from `#components/data-table`, backed by the supported TanStack Table v8 dependency. Use its controlled manual mode for server paging/sorting. Do not replace it with an agent-written table engine when a dependency version is incompatible; inspect and repair the dependency first. See [tables](references/frontend/references/table.md).
110
124
 
111
- Before writing or changing anything under `client/` — pages, components, styles, copy — read [the frontend workflow](references/frontend/ui-workflow.md). It decides whether the change takes the full workflow (a design file reviewed once, then an independent acceptance review), a theme change (tokens and presets, verified with the theme tests and a browser check) or a quick change (edit directly, then the static checks, the related tests and one look at the changed element in the browser), and which parts of [the UI guidelines](references/frontend/ui-guidelines.md) and [the frontend handbook](references/frontend/frontend-dev.md) to read at each step.
125
+ 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.
112
126
 
113
127
  The handbook's "Look up by task" table routes each frontend task to the sections that cover it, and [the worked example](references/frontend/references/example.md) holds the complete files of the projects feature its rules are illustrated with. Components are shadcn/ui primitives, added with the CLI when a page first needs one: the shadcn/ui skill in `references/frontend/shadcn/` covers their API and composition rules, and [its guide in this handbook](references/frontend/references/shadcn.md) says what to read there and where this application departs from it.
114
128
 
@@ -119,6 +133,7 @@ Read the page for the task in front of you. Do not read all of them.
119
133
  | Task | Read |
120
134
  | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
121
135
  | Anything under `client/`: pages, routes, components, styling, forms, API calls, copy, frontend tests | [frontend workflow](references/frontend/ui-workflow.md), which routes to the [frontend handbook](references/frontend/frontend-dev.md), the theme reference or the worked example |
136
+ | Search/paginate relation choices, save associations, or batch-assign selected records | [executable relation and batch example](references/frontend/references/executable-relation-batch.md), then the installed authorization Skill |
122
137
  | Add an API endpoint, a webhook, or a callback; authenticate and authorize it | [server routes](references/server-routes.md) |
123
138
  | Name an endpoint, shape its response or errors, validate its input, paginate a list, document it in the API document | [HTTP API design](references/http-api.md) |
124
139
  | A list, chart or polled endpoint, or keeping one live: read it with a fixed number of queries, refresh only what changed | [server routes](references/server-routes.md#lists-and-statistics-a-fixed-number-of-queries) and [client API requests](references/frontend/references/api.md#keeping-lists-and-charts-live) |
@@ -0,0 +1,186 @@
1
+ [
2
+ {
3
+ "id": "procurement",
4
+ "title": "Purchasing request and decision",
5
+ "status": "runnable",
6
+ "sources": [
7
+ "client/pages/procurement/index.tsx",
8
+ "client/pages/procurement/detail.tsx",
9
+ "client/pages/procurement/reference.tsx",
10
+ "client/pages/procurement/locales.ts",
11
+ "shared/procurement.ts",
12
+ "server/routes/procurement.ts",
13
+ "server/providers/procurement.ts",
14
+ "server/providers/procurement-registration.ts",
15
+ "server/providers/procurement-reset.ts",
16
+ "server/lifecycles/procurement.ts",
17
+ "database/main/migrations/202611040001_create_procurement.ts",
18
+ "database/main/seeds/202611040001_procurement.ts",
19
+ "database/main/seeds/202611040002_procurement_samples.ts",
20
+ "cli/commands/procurement-reset.ts",
21
+ "tests/client/procurement.test.tsx",
22
+ "tests/server/procurement.test.ts",
23
+ "tests/database/procurement.test.ts",
24
+ "tests/playwright/procurement.test.ts",
25
+ "docs/procurement.md"
26
+ ],
27
+ "destination": "assets/business-examples/procurement/",
28
+ "entries": {
29
+ "page": "/procurement",
30
+ "api": [
31
+ "/api/procurement",
32
+ "/api/procurement/context",
33
+ "/api/procurement/candidates",
34
+ "/api/procurement/{id}",
35
+ "/api/procurement/{id}/fire"
36
+ ]
37
+ },
38
+ "dependencies": [
39
+ "Native authentication, Users and authorization with explicit per-user roles",
40
+ "Registered lifecycle example server runtime and its existing history collections, or the target application runtime/store adapted as documented",
41
+ "Existing submission provider/receipt migration and template-owned UI components"
42
+ ],
43
+ "commands": {
44
+ "install": "pnpm install",
45
+ "start": "pnpm dev",
46
+ "test": "pnpm exec vitest run tests/client/procurement.test.tsx tests/server/procurement.test.ts tests/database/procurement.test.ts && pnpm exec playwright test tests/playwright/procurement.test.ts",
47
+ "reset": "pnpm nocobase app procurement-reset --dry-run --json; pnpm nocobase app procurement-reset --force --json"
48
+ },
49
+ "applicability": "Application-owned business feature in the Examples template",
50
+ "replacementPoints": [
51
+ "Business fields and labels",
52
+ "Reference scope",
53
+ "Ownership and action permission rules",
54
+ "Lifecycle transitions"
55
+ ],
56
+ "limitations": [
57
+ "One currency, positive integer quantities, at most 50 lines and one designated non-self reviewer",
58
+ "No multi-level approvals, tax, stock reservation or workflow editor",
59
+ "Reference searches return at most 100 matches; reviewer membership is checked before the transaction",
60
+ "Default integration requires explicit runtime/store and UI registration; see docs/procurement.md",
61
+ "Example verification and independent agent adaptation outcomes are separate records"
62
+ ]
63
+ },
64
+ {
65
+ "id": "customers",
66
+ "title": "Customers and contacts",
67
+ "status": "runnable",
68
+ "sources": [
69
+ "client/pages/customer-contacts/index.tsx",
70
+ "client/pages/customer-contacts/detail.tsx",
71
+ "client/pages/customer-contacts/edit.tsx",
72
+ "client/pages/customer-contacts/batch.tsx",
73
+ "client/pages/customer-contacts/model.ts",
74
+ "client/pages/customer-contacts/shared.tsx",
75
+ "client/pages/customer-contacts/relation-picker.tsx",
76
+ "client/pages/customer-contacts/locales.ts",
77
+ "server/routes/customer-contacts.ts",
78
+ "server/providers/customer-contacts.ts",
79
+ "server/providers/customer-contacts-authorization.ts",
80
+ "server/providers/customer-contacts-data.ts",
81
+ "database/main/migrations/202611030002_create_customer_contacts.ts",
82
+ "database/main/seeds/202611030002_customer_contacts.ts",
83
+ "tests/client/customer-contacts.test.tsx",
84
+ "tests/server/customer-contacts.test.ts",
85
+ "tests/database/customer-contacts-migration.test.ts"
86
+ ],
87
+ "destination": "assets/customer-contacts-example/",
88
+ "entries": {
89
+ "page": "/customer-contacts",
90
+ "api": ["/api/customerContacts"]
91
+ },
92
+ "dependencies": [
93
+ "Default registered authentication, Users and authorization capabilities"
94
+ ],
95
+ "commands": {
96
+ "install": "pnpm install",
97
+ "start": "pnpm dev",
98
+ "test": "pnpm exec vitest run tests/client/customer-contacts.test.tsx tests/server/customer-contacts.test.ts tests/database/customer-contacts-migration.test.ts",
99
+ "reset": "POST <application-base>/api/customerContacts/reset (native unrestricted administrator session; also available as Reset example data on the page)"
100
+ },
101
+ "applicability": "Application-owned business feature in the Examples template",
102
+ "replacementPoints": [
103
+ "Customer and contact fields and labels",
104
+ "Ownership and permitted relation scope",
105
+ "Batch field allowlist and per-record outcomes"
106
+ ],
107
+ "limitations": [
108
+ "Current-page batches contain at most 100 unique IDs",
109
+ "The existing example installs fictional users; replace demonstration accounts and data before production adaptation",
110
+ "Batch writes use one transaction without persistent receipts; inspect saved rows after an uncertain response",
111
+ "See docs/customer-contacts.md and the relation/batch Skill reference for integration and independent adaptation guidance"
112
+ ]
113
+ },
114
+ {
115
+ "id": "onboarding",
116
+ "title": "Employee onboarding",
117
+ "status": "planned",
118
+ "sources": [
119
+ "client/pages/onboarding/",
120
+ "server/routes/onboarding.ts",
121
+ "server/providers/onboarding.ts",
122
+ "database/main/migrations/",
123
+ "database/main/seeds/",
124
+ "tests/client/onboarding.test.tsx",
125
+ "tests/server/onboarding.test.ts",
126
+ "tests/database/onboarding.test.ts",
127
+ "tests/playwright/onboarding.test.ts"
128
+ ],
129
+ "destination": "assets/business-examples/onboarding/",
130
+ "entries": {
131
+ "page": "/onboarding",
132
+ "api": []
133
+ },
134
+ "dependencies": [
135
+ "Default registered authentication, Users and authorization capabilities",
136
+ "lifecycle"
137
+ ],
138
+ "commands": {
139
+ "install": "pnpm install",
140
+ "start": "pnpm dev",
141
+ "test": "pnpm test && pnpm test:e2e",
142
+ "reset": "implementation must supply isolated test-data reset"
143
+ },
144
+ "applicability": "Application-owned business feature in the Examples template",
145
+ "replacementPoints": [
146
+ "Business fields and labels",
147
+ "Reference scope",
148
+ "Ownership and action permission rules",
149
+ "Lifecycle transitions"
150
+ ],
151
+ "limitations": [
152
+ "Not implemented or published by this collection-material change"
153
+ ]
154
+ },
155
+ {
156
+ "id": "expenses",
157
+ "title": "Expense reimbursement",
158
+ "status": "held-out",
159
+ "sources": [],
160
+ "destination": null,
161
+ "entries": {
162
+ "page": null,
163
+ "api": []
164
+ },
165
+ "dependencies": [
166
+ "Default registered authentication, Users and authorization capabilities",
167
+ "lifecycle"
168
+ ],
169
+ "commands": {
170
+ "install": "pnpm install",
171
+ "start": "pnpm dev",
172
+ "test": "pnpm test && pnpm test:e2e",
173
+ "reset": "implementation must supply isolated test-data reset"
174
+ },
175
+ "applicability": "Held-out business-model substitution from an available example",
176
+ "replacementPoints": [
177
+ "Business fields and labels",
178
+ "Reference scope",
179
+ "Ownership and action permission rules",
180
+ "Lifecycle transitions"
181
+ ],
182
+ "limitations": [
183
+ "Not implemented or published by this collection-material change"
184
+ ]
185
+ }
186
+ ]
@@ -0,0 +1,63 @@
1
+ import { AppCommand, CommandError } from '@nocobase/app-cli';
2
+ import { Flags } from '@oclif/core';
3
+
4
+ export default class ProcurementReset extends AppCommand {
5
+ static override summary =
6
+ 'Clear procurement requests and their lifecycle history in a disposable development application.';
7
+ static override examples = [
8
+ '<%= config.bin %> <%= command.id %> --dry-run --json',
9
+ ];
10
+ static override flags = {
11
+ 'dry-run': Flags.boolean({
12
+ description: 'Count records without deleting them.',
13
+ default: false,
14
+ }),
15
+ force: Flags.boolean({
16
+ description:
17
+ 'Confirm deletion of every procurement request in this development database.',
18
+ default: false,
19
+ }),
20
+ };
21
+ async run(): Promise<{ requests: number; lines: number; dryRun: boolean }> {
22
+ const { flags } = await this.parse(ProcurementReset);
23
+ if (process.env.NODE_ENV === 'production')
24
+ throw new CommandError(
25
+ 'Procurement reset is available only in disposable development applications.',
26
+ { code: 'DEVELOPMENT_ONLY' },
27
+ );
28
+ if (!flags['dry-run'] && !flags.force)
29
+ throw new CommandError(
30
+ 'Preview the procurement deletion plan, then confirm the disposable database.',
31
+ {
32
+ code: 'FORCE_REQUIRED',
33
+ exit: 2,
34
+ suggestions: [
35
+ {
36
+ message: 'Preview the plan.',
37
+ run: this.cliCommand([
38
+ 'app',
39
+ 'procurement-reset',
40
+ '--dry-run',
41
+ '--json',
42
+ ]),
43
+ },
44
+ ],
45
+ },
46
+ );
47
+ const result = await this.withApp(async ({ app }) => {
48
+ app.registerProviders();
49
+ const { databaseManagerToken } = await import('@nocobase/db');
50
+ const { resetProcurement } =
51
+ await import('../../server/providers/procurement-reset.js');
52
+ return resetProcurement(
53
+ app.container.resolve(databaseManagerToken).connection(),
54
+ flags['dry-run'],
55
+ );
56
+ });
57
+ if (flags['dry-run']) this.setStatus('success-noop');
58
+ this.log(
59
+ `Procurement requests: ${result.requests}; lines: ${result.lines}.`,
60
+ );
61
+ return result;
62
+ }
63
+ }