[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E44C5AYM5PQQEAN6V2XTWR":3,"skill-same:01M7E44C5AYM5PQQEAN6V2XTWR":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7E44C5AYM5PQQEAN6V2XTWR","new-mapping",null,"Write or convert a handler so the generated entity mapper copies the data — [MapFrom] a message onto an entity graph, [MapTo] a Row\u002FModel\u002FRef projection, EntityMapper.Map\u002FUpsert\u002FProject. Use when a handler would assign entity.X = message.X by hand, build a new Entity from a message, merge a child collection by key, or project with .Select; when adding a Create\u002FUpdate\u002FList\u002FGet\u002FLookup to a kit; or when a build says NSG004 to NSG013 or NSG025.","nsail-ar\u002Fnsail-stack","nsail-ar","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F311138441?v=4","01M7E43SJ8P0ZN6TB6CXGBQQ3R","01M7E43SK611Q8B0KG2CF9A58X",4,"MIT","https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack\u002Fblob\u002Fmain\u002Fplugins\u002Fnsail-stack\u002Fskills\u002Fnew-mapping\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: new-mapping\ndescription: Write or convert a handler so the generated entity mapper copies the data — [MapFrom] a message onto an entity graph, [MapTo] a Row\u002FModel\u002FRef projection, EntityMapper.Map\u002FUpsert\u002FProject. Use when a handler would assign entity.X = message.X by hand, build a new Entity from a message, merge a child collection by key, or project with .Select; when adding a Create\u002FUpdate\u002FList\u002FGet\u002FLookup to a kit; or when a build says NSG004 to NSG013 or NSG025.\n---\n\n# New mapping\n\nA handler's copy work is declared on the entity and generated; the handler keeps the\nrules. Read `${CLAUDE_PLUGIN_ROOT}\u002Fdoctrine\u002Fdata.md`, *Mapping* (the graph rules, one table of calls)\nbefore you declare anything. The mapper is Detached Mapper's graph semantics generated at\ncompile time: no reflection, nothing saved until the handler's `SaveChanges`.\n\n## The three pieces\n\n1. **The holder, once per Data project.** `Mappings.cs` with\n   `[Generated(Mappers.Entities)] public static partial void Add{Kit}Mappings(this IServiceCollection services);`,\n   the `NSail.SourceGenerator` analyzer reference in the csproj (`OutputItemType=Analyzer`),\n   and in the project's `Persistence.cs`: `services.Add{Kit}Mappings();` plus\n   `services.TryAddScoped\u003CEntityMapper>();`. Precedent: `NSail.Accounting.Data`.\n2. **The declaration, on the entity.** The entity names the message, never the reverse (the\n   Sdk that holds the message cannot see the Data types):\n   - `[MapFrom(typeof(CreateX))]` and `[MapFrom(typeof(UpdateX))]` — writes\n   - `[MapTo(typeof(XRow))]`, `[MapTo(typeof(XModel))]`, `[MapTo(typeof(XRef))]` — reads\n   - `[Composition]` on a collection the root owns, `[Parent]` on the child's way back,\n     `[MapFrom(typeof(XChildModel))]` on the child entity\n   - `[MapIgnore]` on a member the handler writes by rule; `[MapFrom(typeof(M), \"OrganizationId\")]`\n     on the member to say it out loud (NSG004 refuses it by name alone)\n   - **where the names differ, the entity says so**: `[MapFrom(typeof(M), \"Title\")]` on the member\n     written from `M.Title`, `[MapTo(typeof(T), \"Heading\")]` on the member read as `T.Heading`.\n     A message member no entity member writes is NSG011, a row member no entity member fills is\n     NSG012 — both warnings for data lost in silence, and a drop that is on purpose is declared\n     on the entity's own declaration: `[MapFrom(typeof(M), Ignore = [nameof(M.X)])]`,\n     `[MapTo(typeof(T), Ignore = [nameof(T.X)])]`\n3. **The call, in the handler.**\n\n| Handler act | Call |\n|---|---|\n| `Create` with a caller-supplied `Id` | `await _mapper.Upsert\u003CCreateX, X>(message, ct)` — `Map` on an `Id` that names no row is `NotFound` |\n| `Update` | guards first, then `await _mapper.Map\u003CUpdateX, X>(message, ct)` — a missing row is `NotFound` for free |\n| `List`\u002F`Get`\u002F`Lookup` | `_mapper.Project\u003CX, XRow>(query...)` — an expression tree, the store selects only the row's columns |\n| a document whose rows cannot be ordered | `Import` |\n\n## What stays in the handler\n\nThe mapper copies; it does not decide. Keep, in this order: **guards** (`Ensure*`, uniqueness,\nexists), then **the call**, then **what the mapper does not write** — the constants a Create\nsets (`IsEnabled = true`, `IsSystem = false`), anything `[MapIgnore]`d — then `SaveChanges`. Never\nthe stamps: an entity with `CreatedAt` and `UpdatedAt` implements `IAudited` and the save writes\nthem (an entity not yet on `IAudited` gets it as part of converting its handler).\n\n- A guard that needs the row's old state (`channel.IsEnabled` before the merge) loads it first;\n  the mapper's load returns the same tracked instance and merges onto it.\n- A claimed parent the message carries only to be checked (`FromOrganizationId`, `InsurerId`)\n  is `[MapIgnore]`d: it is verified against the row, never written.\n- Side effects that need the old value (`previousPartyId` for a publish) capture it before the call.\n\n## Graph boundaries\n\n**Aggregations are the boundary of a map; compositions are its nodes.** A member typed as an\nentity (or a `CustomerId`) is attached by key and never written: an `UpdateInvoice` cannot\nrewrite the `InvoiceType` it points at. A `[Composition]` is the root's own: matched by key,\nwhat the message no longer carries is deleted, a child with no key (`Guid.Empty`) is created\nwith a new id. So a message carries the **whole** set of a composition, never a diff.\n\n## One message per act\n\nC# has no *undefined*, so `null` cannot mean \"leave it\". The house answer is Detached's first\none: small specific messages, one per act (`RetargetTenderMethod` carries one field), never a\n`Save` and never a patch type. Create and Update are separate messages with their own\n`[MapFrom]`, which is also the answer to Detached's *profiles*: what differs between them (a\nconstant the create sets) is the handler's step after the call. The audit stamps are not: an\n`IAudited` entity's save writes them.\n\n## What not to convert\n\nLeave hand-written what is a rule and not a copy: credentials and sealed fields (`User`, the\nsettings handlers), priced or numbered documents (a sale, a voucher, a work order), state\nmachines and ledgers, writes that split or snapshot rows, orchestration across kits, and any\nprojection with a subquery, aggregate or merged source (`Select` that computes). A flat\n`Select(e => new XRow { Id = e.Id, Name = e.Name })` is a conversion; a `Select` with a\ncorrelated count is not.\n\n## Prove it with a unit test\n\nA mapping is a copy, so a unit test over `HandlerHost` proves it — no browser. For each\nconverted handler: create-then-get-then-update round trip; for a composition, the set rules\n(kept row, new row gets an id, dropped row gone, stamps kept); for an `IVersioned` entity, a\nstale version refused — an edit of the compositions alone included, since the root's token\nguards its parts (data.md, *Mapping*) — and a zero version not held; a missing row is `NotFound`. Precedents in\n`test\u002FKits\u002FAccounting\u002FNSail.Accounting.WebApi.Tests`: `CurrencyCrudTests`,\n`TenderMethodModalitiesTests`, `SalesChannelConcurrencyTests`. A build error is the generator\nspeaking: `NSG004` an organization axis mapped by name alone, `NSG005` a `[Primitive]` of another\ntype, `NSG006` a member with no conversion, `NSG007` no parameterless constructor, `NSG008`\na `[MapFrom]` that names a non-class, `NSG009` a projection that cannot carry a derived type,\n`NSG010` an open generic, `NSG013` an `Ignore` naming a member that does not exist, `NSG025` a\n`[MapFrom]` reading a nullable into a non-nullable member that is not the key (answer: make a\nside nullable or non-nullable, `[MapIgnore]` the member in both directions, or\n`Ignore = [nameof(M.X)]` on the `[MapFrom]` to drop it from that pairing only, so `[MapTo]`\nprojections still read it). `NSG011` and\n`NSG012` are warnings, not errors: the build is green and the data is gone.\n","# New mapping\n\nA handler's copy work is declared on the entity and generated; the handler keeps the\nrules. Read `${CLAUDE_PLUGIN_ROOT}\u002Fdoctrine\u002Fdata.md`, *Mapping* (the graph rules, one table of calls)\nbefore you declare anything. The mapper is Detached Mapper's graph semantics generated at\ncompile time: no reflection, nothing saved until the handler's `SaveChanges`.\n\n## The three pieces\n\n1. **The holder, once per Data project.** `Mappings.cs` with\n   `[Generated(Mappers.Entities)] public static partial void Add{Kit}Mappings(this IServiceCollection services);`,\n   the `NSail.SourceGenerator` analyzer reference in the csproj (`OutputItemType=Analyzer`),\n   and in the project's `Persistence.cs`: `services.Add{Kit}Mappings();` plus\n   `services.TryAddScoped\u003CEntityMapper>();`. Precedent: `NSail.Accounting.Data`.\n2. **The declaration, on the entity.** The entity names the message, never the reverse (the\n   Sdk that holds the message cannot see the Data types):\n   - `[MapFrom(typeof(CreateX))]` and `[MapFrom(typeof(UpdateX))]` — writes\n   - `[MapTo(typeof(XRow))]`, `[MapTo(typeof(XModel))]`, `[MapTo(typeof(XRef))]` — reads\n   - `[Composition]` on a collection the root owns, `[Parent]` on the child's way back,\n     `[MapFrom(typeof(XChildModel))]` on the child entity\n   - `[MapIgnore]` on a member the handler writes by rule; `[MapFrom(typeof(M), \"OrganizationId\")]`\n     on the member to say it out loud (NSG004 refuses it by name alone)\n   - **where the names differ, the entity says so**: `[MapFrom(typeof(M), \"Title\")]` on the member\n     written from `M.Title`, `[MapTo(typeof(T), \"Heading\")]` on the member read as `T.Heading`.\n     A message member no entity member writes is NSG011, a row member no entity member fills is\n     NSG012 — both warnings for data lost in silence, and a drop that is on purpose is declared\n     on the entity's own declaration: `[MapFrom(typeof(M), Ignore = [nameof(M.X)])]`,\n     `[MapTo(typeof(T), Ignore = [nameof(T.X)])]`\n3. **The call, in the handler.**\n\n| Handler act | Call |\n|---|---|\n| `Create` with a caller-supplied `Id` | `await _mapper.Upsert\u003CCreateX, X>(message, ct)` — `Map` on an `Id` that names no row is `NotFound` |\n| `Update` | guards first, then `await _mapper.Map\u003CUpdateX, X>(message, ct)` — a missing row is `NotFound` for free |\n| `List`\u002F`Get`\u002F`Lookup` | `_mapper.Project\u003CX, XRow>(query...)` — an expression tree, the store selects only the row's columns |\n| a document whose rows cannot be ordered | `Import` |\n\n## What stays in the handler\n\nThe mapper copies; it does not decide. Keep, in this order: **guards** (`Ensure*`, uniqueness,\nexists), then **the call**, then **what the mapper does not write** — the constants a Create\nsets (`IsEnabled = true`, `IsSystem = false`), anything `[MapIgnore]`d — then `SaveChanges`. Never\nthe stamps: an entity with `CreatedAt` and `UpdatedAt` implements `IAudited` and the save writes\nthem (an entity not yet on `IAudited` gets it as part of converting its handler).\n\n- A guard that needs the row's old state (`channel.IsEnabled` before the merge) loads it first;\n  the mapper's load returns the same tracked instance and merges onto it.\n- A claimed parent the message carries only to be checked (`FromOrganizationId`, `InsurerId`)\n  is `[MapIgnore]`d: it is verified against the row, never written.\n- Side effects that need the old value (`previousPartyId` for a publish) capture it before the call.\n\n## Graph boundaries\n\n**Aggregations are the boundary of a map; compositions are its nodes.** A member typed as an\nentity (or a `CustomerId`) is attached by key and never written: an `UpdateInvoice` cannot\nrewrite the `InvoiceType` it points at. A `[Composition]` is the root's own: matched by key,\nwhat the message no longer carries is deleted, a child with no key (`Guid.Empty`) is created\nwith a new id. So a message carries the **whole** set of a composition, never a diff.\n\n## One message per act\n\nC# has no *undefined*, so `null` cannot mean \"leave it\". The house answer is Detached's first\none: small specific messages, one per act (`RetargetTenderMethod` carries one field), never a\n`Save` and never a patch type. Create and Update are separate messages with their own\n`[MapFrom]`, which is also the answer to Detached's *profiles*: what differs between them (a\nconstant the create sets) is the handler's step after the call. The audit stamps are not: an\n`IAudited` entity's save writes them.\n\n## What not to convert\n\nLeave hand-written what is a rule and not a copy: credentials and sealed fields (`User`, the\nsettings handlers), priced or numbered documents (a sale, a voucher, a work order), state\nmachines and ledgers, writes that split or snapshot rows, orchestration across kits, and any\nprojection with a subquery, aggregate or merged source (`Select` that computes). A flat\n`Select(e => new XRow { Id = e.Id, Name = e.Name })` is a conversion; a `Select` with a\ncorrelated count is not.\n\n## Prove it with a unit test\n\nA mapping is a copy, so a unit test over `HandlerHost` proves it — no browser. For each\nconverted handler: create-then-get-then-update round trip; for a composition, the set rules\n(kept row, new row gets an id, dropped row gone, stamps kept); for an `IVersioned` entity, a\nstale version refused — an edit of the compositions alone included, since the root's token\nguards its parts (data.md, *Mapping*) — and a zero version not held; a missing row is `NotFound`. Precedents in\n`test\u002FKits\u002FAccounting\u002FNSail.Accounting.WebApi.Tests`: `CurrencyCrudTests`,\n`TenderMethodModalitiesTests`, `SalesChannelConcurrencyTests`. A build error is the generator\nspeaking: `NSG004` an organization axis mapped by name alone, `NSG005` a `[Primitive]` of another\ntype, `NSG006` a member with no conversion, `NSG007` no parameterless constructor, `NSG008`\na `[MapFrom]` that names a non-class, `NSG009` a projection that cannot carry a derived type,\n`NSG010` an open generic, `NSG013` an `Ignore` naming a member that does not exist, `NSG025` a\n`[MapFrom]` reading a nullable into a non-nullable member that is not the key (answer: make a\nside nullable or non-nullable, `[MapIgnore]` the member in both directions, or\n`Ignore = [nameof(M.X)]` on the `[MapFrom]` to drop it from that pairing only, so `[MapTo]`\nprojections still read it). `NSG011` and\n`NSG012` are warnings, not errors: the build is green and the data is gone.\n",{"name":5,"description":7},"main","05792baf2de3007074f23bcb6539a1a6b46b3486","plugins\u002Fnsail-stack\u002Fskills\u002Fnew-mapping",0,"https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack","https:\u002F\u002Fgithub.com\u002Fnsail-ar","2026-11-14 14:30:35",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add nsail-ar\u002Fnsail-stack --skill new-mapping",{"tool":36,"command":37},"bunx","bunx skills add nsail-ar\u002Fnsail-stack --skill new-mapping",{"tool":39,"command":40},"pnpm","pnpm dlx skills add nsail-ar\u002Fnsail-stack --skill new-mapping","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack\u002Fblob\u002Fmain\u002Fplugins\u002Fnsail-stack\u002Fskills\u002Fnew-mapping\u002FSKILL.md",true,[],[45,52,59,66,73],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":18},"01M7E44SDA4CP16CTBVTMK0VVK","test-harness","Write or run tests against the NSail harnesses — which layer owes the proof (Architecture, Stack, kit WebApi.Tests on Postgres, bUnit, Apps, browser E2E), HandlerHost, the Release-build E2E host, Api.Send, culture and viewport. Use for a kit, bUnit or E2E test, deciding whether a fix earns a regression test, a flaky or instantly-failing suite, or reporting test totals.","https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack\u002Fblob\u002Fmain\u002Fplugins\u002Fnsail-stack\u002Fskills\u002Ftest-harness\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":18},"01M7E44KMEW16SXT6XEGDKX03M","new-message","Add an NSail operation end to end — a message in the Sdk ([Http] route, validation), its IHandler in WebApi, the Row\u002FRef\u002FModel projection, BusinessException failures and strings; endpoint, DI and client are generated. Use for a query or command such as ListInvoices or CreatePayment, when choosing a verb (there is no Save), or on SenderNotFound.","https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack\u002Fblob\u002Fmain\u002Fplugins\u002Fnsail-stack\u002Fskills\u002Fnew-message\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":18},"01M7E446ZQC8228353102TW3HX","new-icon","Add an icon to an NSail icon catalog (NsIcons, a kit's or app's like ProductsIcons or OpticalIcons, a Stack library's own) from a Material Symbols path. Use when a screen, menu entry, button or field needs a glyph no catalog has, instead of Icons.Material.*, or when a pasted icon renders as nothing or a dot. Covers the 960-grid viewBox transform, catalog choice and sizing.","https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack\u002Fblob\u002Fmain\u002Fplugins\u002Fnsail-stack\u002Fskills\u002Fnew-icon\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M7E4414KBNYX5R1NTZ0RTHMT","doctrine","The Stack's architecture — which page to read before touching a message, handler, entity, migration, tenancy, permission, screen, Ns* component, test, React client, localization key or project layout. Use before editing code that builds on the Stack, when a CLAUDE.md routes the Stack's doctrine, or when asked how the Stack wants something done.","https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack\u002Fblob\u002Fmain\u002Fplugins\u002Fnsail-stack\u002Fskills\u002Fdoctrine\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7E43WB8NPCHVQ07KZQYBBS7","convert-to-nsload","Convert a screen's data read into an NsLoad region (OnLoad, Reload, Retry, NsPartial.Handoff for dashboard cards). Use whenever you touch a Blazor screen or card that loads in OnCreatedAsync, OnParametersSetAsync or OnInitializedAsync, or when a load failure shows as a toast, a card reads twice, or an empty state lies about a failed read.","https:\u002F\u002Fgithub.com\u002Fnsail-ar\u002Fnsail-stack\u002Fblob\u002Fmain\u002Fplugins\u002Fnsail-stack\u002Fskills\u002Fconvert-to-nsload\u002FSKILL.md",[],[]]