Repository navigation
New-core template: core's quality bar, RLS guard and a CRUD reference slice - #16
Conversation
…t rules it names AGENTS.md gets core's marked quality block unchanged; knip, check:generated and the skip check are review here until the plugin has them. The deprecated module.register telemetry hook moves to import-in-the-middle's registerHooks loader, @erxes/* skips pnpm's release-age gate since v2-next publishes daily, and ui/package.json sorts once @__id__/api has its real name.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
…e loads the template's skills The template embeds files only, so the generator makes the link. Windows without Developer Mode can't make a symlink and gets a junction instead.
Reviewer's GuideSchema and migrationsThe items schema and its migration add case-insensitive, per-organisation name uniqueness, with the snapshot recording the resulting schema.
APIThe items procedures define the typed CRUD interface, map the name constraint to a typed error, and return rows without the organisation identifier.
ImplementationThe database client adds unique-violation handling and documents transaction-scoped RLS, while the migration runner gains a standalone command.
Telemetry switches to import-in-the-middle hooks and reads its tracing setting from validated configuration.
The RLS guard provisions a fresh database, applies migrations, and reports tenancy or naming violations from the catalog query.
The shared SQL fixture defines the tenant functions used by migrations, while test setup loads that fixture.
The core scaffold sorts the generated UI dependencies and links Claude Code skills to the embedded skill directory.
UIThe item form presents typed name conflicts accessibly, and the list adds optimistic deletion with rollback and refetch.
ConfigurationCI runs the tenancy guard and adds a Node 26 PostgreSQL-backed generated-core case to the deliverables matrix.
The template adopts Node 26 across its runtime, package requirements, Docker image, and type definitions.
Package and lint configuration adds the RLS gate, release-age exclusion, restricted core database imports, and the quality rules enforced on API and UI code.
DocumentationThe root guide records the new-core template’s gates, RLS-backed reference feature, and skill links.
The template’s agent guide adds core’s quality section and clarifies the RLS, plugin boundary, and local checks.
The endpoint and schema-change skills teach agents to rely on tenant RLS and include the tenancy guard in schema completion.
The migration skill and generated checklist require parity without old bugs or workarounds and point UI ports to the component migration guide.
TestsThe items tests exercise typed-client CRUD, paging, case-insensitive conflicts, organisation isolation, and permission enforcement against Postgres.
The end-to-end test generates a core plugin and runs its install, checks, tests, RLS guard, and build.
The scaffold test verifies the generated Claude skills link and that Claude can resolve a skill through it.
The migration inventory registration formatting is adjusted to satisfy the formatter.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…d leave tenancy to RLS node/no-process-env replaces the AGENTS.md line asking for it, telemetry reads its switch from config. Queries drop their org filters: withOrg's row-level security already scopes them.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
tools/check-rls.sql fails a table with org_id that lacks forced RLS and the tenant policy, a table without org_id that isn't listed, and any name outside the plugin's prefix. Tests and the guard share core's tenant functions from one SQL file; db:migrate runs the migrations alone.
…ugin SDK The zod .catch and session advisory lock bans need core's local lint plugin, which the template doesn't have; they wait for @erxes/lint.
…and CI runs a generated plugin's gates Names are unique per organisation ignoring case; the 23505 becomes oRPC's typed ITEM_NAME_TAKEN in one place, which the form shows on the field through isDefinedError. Delete is optimistic through the oRPC query utils, lists keep keyset paging, rows go out without org_id. Tests use the typed client, and the e2e core case installs a fresh plugin and runs check, test, check:rls and build.
…oves to a constant The e2e case with a longer name caught the tableId line wrapping differently.
…ral fixes An item ticks once it works and its old bugs and workarounds are gone. A missing core feature gets an issue and waits for core, said as what to do. UI ports point at erxes-ui's old-to-new component table, and the pointer to core's plugin-migrate skill goes, since core deletes it.
pnpm 10 injects a copy of api into ui that keeps only the listed files, so the router types were missing and the UI failed its type check. pnpm 12 symlinks it, which hid this locally.
A plugin generated with
--erxes coresat below core's bar: no quality section, skills Claude Code never loaded, org filters next to RLS, no tenancy check, and an example feature without typed errors or delete. Agents copy the template, so they copied the gaps too.Scope is
templates/core/**plus the generator code and tests it needs. The old-platform templates are untouched.What changed, one commit each
AGENTS.mdcarries core's<!-- quality:start -->block byte for byte (checked withdiffagainst core-guard 13b5016274). The repo part below it keeps the fixed names, the prefix plus RLS rule, the SDK/pluginFetch boundary and the commands. knip,pnpm check:generatedand the skipped-test check don't exist in a plugin yet, so those rules are marked[review]there. Lint now turns on the rules the section names:no-deprecated,no-non-null-assertion,ban-ts-comment,no-warning-comments,max-lines300 andmax-lines-per-function80 onapi/andui/, plainno-console.no-deprecatedflaggedmodule.registerin telemetry, which moves to import-in-the-middle'sregisterHooksloader..claude/skills -> ../.agents/skills. Templates embed files only, so it's asymlinkcall. Windows without Developer Mode gets a junction.node/no-process-envreplaces the "only config.ts reads process.env" line. Telemetry reads its switch from config. Queries drop their org filters, sincewithOrg's RLS scopes them. Node 26 in.node-version,engines,@types/nodeand the Dockerfile.tools/check-rls.sqland.shport core's pg_catalog check to the plugin prefix.pnpm check:rlsruns in the plugin's CI and is the schema-change skill's done criterion. Tests and the guard share core's tenant functions fromapi/src/test/core-functions.sql. A newpnpm db:migrateruns migrations alone. Dropping the RLS line from the migration makes it fail withrow level security is off, ... not forced, no tenant policy.@erxes/core-dbis a restricted import. The zod.catchand session advisory lock rules need core's local anti-slop plugin, which the template doesn't have, so they wait for@erxes/lint.<name>_itemsgets a unique index on(org_id, lower(name)), list (keyset), create, update and delete.ITEM_NAME_TAKENis declared with.errors()and thrown aserrors.ITEM_NAME_TAKEN(...). The 23505 maps to it in one function (nameTaken, viauniqueViolationindb/client.ts). Rows go out withoutorg_id. Tests usecreateRouterClient: CRUD and paging, the conflict on create and update (case-insensitive), cross-org RLS (same name allowed, no read, update or delete of another org's row), and FORBIDDEN. The UI form shows the conflict on the name field throughisDefinedError. Delete is optimistic throughorpc.items.remove.mutationOptions, with rollback on error. NoasChildanywhere.plugin-migrateopens with the intent, drops the pointer to core's skill and says what to do when core lacks a feature.checklist.tsticks an item only when it works and its old bugs and workarounds are gone, and points UI ports atpackages/ui/MIGRATION.md.Smaller fixes found on the way:
ui/package.jsonfailedpnpm checkin every generated plugin.@__id__/apisorted differently once it had the real name. The generator now sorts it.migration/inventory.tsfailed the formatter.ItemsPagewrapped differently with a long plugin name.@<name>/api's types. pnpm 10 injects a copy ofapithat keeps onlyfiles, andsrc/wasn't listed. pnpm 12 symlinks it, so this only showed up in CI.apinow listssrc.@erxes/*skips pnpm's release-age gate. v2-next republishes daily, and a fresh install failedERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATIONfor a release 5 hours old.CI
test:e2egets acore-pnpmcase, added to the deliverables matrix on Node 26 with a Postgres container. It generatesinventory-tools, then runsinstall,check,test,check:rlsandbuild. Locally it passes in about 25 s with a warm store. The plugin has 7 tests, all passing. The generator's ownpnpm testpasses 57 of 57.Left for later
ui/AGENTS.md:6-8andui/rsbuild.config.tscopy core-ui'sSHAREDlist. Once erxes-ui exportsSHARED, the template should import it and drop the copy. That needs an erxes-ui release first, so this PR leaves it alone.rsbuild.config.tsexposes, the manifest permissions incore.ts, the index inschema.ts. Formatting the output after install would remove that whole class of problem.pnpm checkuntilmigrate:inventorywritesmigration/import-map.ts. The CLI runs it after install, so only--no-installusers see this.