@chill-sharp/ui-core 1.1.12 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -103
- package/fesm2022/chill-sharp-ui-core.mjs +2446 -2446
- package/fesm2022/chill-sharp-ui-core.mjs.map +1 -1
- package/lib/lib/chill-form.component.d.ts +1 -1
- package/package.json +3 -3
- package/service-worker/chill-sharp-service-worker.js +166 -166
- package/styles/core-theme.scss +1235 -1235
- package/.agents/skills/chillsharp-current-user-preferences/SKILL.md +0 -70
- package/.agents/skills/chillsharp-ui-template/SKILL.md +0 -18
- package/doc/AIAssistedDevelopment/README.md +0 -185
- package/doc/AttachmentModel/README.md +0 -173
- package/doc/AuthenticationModel/README.md +0 -213
- package/doc/AuthenticationModel/how-to-integreate-auth-minimal-api.md +0 -293
- package/doc/ChillSharpClient.md +0 -464
- package/doc/ClientGeneration/README.md +0 -172
- package/doc/ComplianceGuide/README.md +0 -178
- package/doc/Configuration/README.md +0 -94
- package/doc/CurrentUserPreferences.md +0 -114
- package/doc/DateTimePolicy/README.md +0 -154
- package/doc/DateTimeSerialization.md +0 -423
- package/doc/Endpoints.md +0 -260
- package/doc/HowTo/01-simple-blog-sqlite.md +0 -153
- package/doc/HowTo/02-blog-schema-labels.md +0 -140
- package/doc/HowTo/03-authentication.md +0 -218
- package/doc/HowTo/04-blog-posts-one-to-many.md +0 -194
- package/doc/HowTo/05-docker-env-variables.md +0 -274
- package/doc/HowTo/06-chunk-transactions-autocomplete.md +0 -196
- package/doc/Mcp/ChatGPT.md +0 -291
- package/doc/Mcp/README.md +0 -799
- package/doc/MenuGuide/README.md +0 -49
- package/doc/ModelPreparation.md +0 -255
- package/doc/PermissionModel/README.md +0 -277
- package/doc/README.md +0 -228
- package/doc/ReferenceExistence.md +0 -130
- package/doc/RegisterContext.md +0 -217
- package/doc/UiCore/CRUD.md +0 -170
- package/doc/UiCore/README.md +0 -13
- package/doc/ValidationModel/README.md +0 -117
- package/doc/it/AIAssistedDevelopment/README.md +0 -185
- package/doc/it/AttachmentModel/README.md +0 -173
- package/doc/it/AuthenticationModel/README.md +0 -171
- package/doc/it/AuthenticationModel/how-to-integreate-auth-minimal-api.md +0 -292
- package/doc/it/ChillSharpClient.md +0 -464
- package/doc/it/ClientGeneration/README.md +0 -152
- package/doc/it/ComplianceGuide/README.md +0 -178
- package/doc/it/Configuration/README.md +0 -94
- package/doc/it/CurrentUserPreferences.md +0 -114
- package/doc/it/DateTimePolicy/README.md +0 -154
- package/doc/it/DateTimeSerialization.md +0 -423
- package/doc/it/Endpoints.md +0 -260
- package/doc/it/HowTo/01-simple-blog-sqlite.md +0 -152
- package/doc/it/HowTo/02-blog-schema-labels.md +0 -139
- package/doc/it/HowTo/03-authentication.md +0 -221
- package/doc/it/HowTo/04-blog-posts-one-to-many.md +0 -193
- package/doc/it/HowTo/05-docker-env-variables.md +0 -268
- package/doc/it/HowTo/06-chunk-transactions-autocomplete.md +0 -196
- package/doc/it/Mcp/ChatGPT.md +0 -291
- package/doc/it/Mcp/README.md +0 -799
- package/doc/it/MenuGuide/README.md +0 -49
- package/doc/it/ModelPreparation.md +0 -254
- package/doc/it/PermissionModel/README.md +0 -190
- package/doc/it/README.md +0 -172
- package/doc/it/ReferenceExistence.md +0 -130
- package/doc/it/RegisterContext.md +0 -218
- package/doc/it/UiCore/CRUD.md +0 -170
- package/doc/it/UiCore/README.md +0 -13
- package/doc/it/ValidationModel/README.md +0 -117
- package/template-customization/upgrade.ps1.template +0 -342
- package/template-customization/upgrade.sh.template +0 -271
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: chillsharp-current-user-preferences
|
|
3
|
-
description: Configure, expose, and consume ChillSharp.Auth's cached current-user culture, time zone, date-format, number-format, and theme preferences in server logic and UI clients.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# ChillSharp Current User Preferences
|
|
7
|
-
|
|
8
|
-
Use this skill when a ChillSharp feature needs the authenticated user's display culture, time zone, date format, or number format. It covers server-side lifecycle hooks and UI/client consumption of the authoritative `AuthUser` preferences. Do not use it for browser-only preferences unrelated to `AuthUser`.
|
|
9
|
-
|
|
10
|
-
## Model
|
|
11
|
-
|
|
12
|
-
`ChillUserPreferences` is an immutable snapshot with `DisplayCultureName`, `DisplayTimeZone`, `DisplayDateFormat`, `DisplayNumberFormat`, and `PreferredTheme`. The backend stores `PreferredTheme` as an opaque string. In UI Core, unauthenticated users follow browser `prefers-color-scheme`; clients register extra themes with `provideChillSharpUiCore({ additionalThemes: ['theme-name'] })`. Entity hooks read the snapshot synchronously through:
|
|
13
|
-
|
|
14
|
-
```csharp
|
|
15
|
-
var preferences = context.GetCurrentUserPreferences();
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Never load `AuthUser` from an `OnCreate`, `OnUpdate`, or other lifecycle hook merely to obtain these values.
|
|
19
|
-
|
|
20
|
-
## Auth integration
|
|
21
|
-
|
|
22
|
-
`AddChillAuthApi` registers `IChillAuthUserPreferencesAccessor` and the singleton `IChillAuthUserPreferencesCache`. Login and token refresh warm the snapshot; `ChillAuthService` refreshes it after an `AuthUser` save and removes it for deleted or renamed external identities.
|
|
23
|
-
|
|
24
|
-
For a custom host DbContext, inject the scoped accessor and implement the two `IChillContext` methods below. Keep the accessor optional only when the context must also be constructible outside DI, such as for migrations or tests.
|
|
25
|
-
|
|
26
|
-
```csharp
|
|
27
|
-
private readonly IChillAuthUserPreferencesAccessor? _userPreferencesAccessor;
|
|
28
|
-
|
|
29
|
-
public ChillUserPreferences GetCurrentUserPreferences() =>
|
|
30
|
-
_userPreferencesAccessor?.Current ?? ChillUserPreferences.Empty;
|
|
31
|
-
|
|
32
|
-
public string GetDefaultUserCultureName()
|
|
33
|
-
{
|
|
34
|
-
var cultureName = GetCurrentUserPreferences().DisplayCultureName;
|
|
35
|
-
return string.IsNullOrWhiteSpace(cultureName) ? GetPrimaryCultureName() : cultureName;
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
The accessor is cache-only: when there is no authenticated principal or no warmed snapshot, it returns `ChillUserPreferences.Empty`. Do not add a fallback database query to lifecycle hooks.
|
|
40
|
-
|
|
41
|
-
## API and client use
|
|
42
|
-
|
|
43
|
-
The authenticated endpoint `GET /api/chill-auth/current-user-preferences` returns the same `ChillUserPreferences` snapshot as JSON:
|
|
44
|
-
|
|
45
|
-
```json
|
|
46
|
-
{
|
|
47
|
-
"displayCultureName": "it-IT",
|
|
48
|
-
"displayTimeZone": "Europe/Rome",
|
|
49
|
-
"displayDateFormat": "dd/MM/yyyy",
|
|
50
|
-
"displayNumberFormat": "N2"
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Use this endpoint after authentication and when restoring a session; do not infer the active display culture or time zone from the browser, operating system, token claims, or auth-management user endpoints. The C#, Python, TypeScript, Angular, Vue, and React clients expose it as `GetCurrentUserPreferences`, `get_current_user_preferences`, or `getCurrentUserPreferences`; the Vue and React packages also provide `useCurrentUserPreferences`.
|
|
55
|
-
|
|
56
|
-
In Angular UI Core, inject `ChillService` and read its `userPreferences` signal (or its `displayCultureName`, `displayTimeZone`, `displayDateFormat`, and `displayNumberFormat` projections). Use these values to select UI language, format and parse dates and numbers, and convert UTC timestamps. Treat all fields as optional and choose an explicit fallback only when needed.
|
|
57
|
-
|
|
58
|
-
## Entity use
|
|
59
|
-
|
|
60
|
-
Use `DisplayTimeZone` as an IANA zone identifier only after validating it with the application's time-zone policy. Treat all fields as optional and provide an explicit fallback where one is required.
|
|
61
|
-
|
|
62
|
-
```csharp
|
|
63
|
-
public override void OnUpdate(IChillContext context)
|
|
64
|
-
{
|
|
65
|
-
var timeZone = context.GetCurrentUserPreferences().DisplayTimeZone;
|
|
66
|
-
// Apply application-specific behavior only when timeZone is available.
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
For full setup and cache behavior, read [CurrentUserPreferences.md](../../../doc/CurrentUserPreferences.md).
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: chillsharp-ui-template
|
|
3
|
-
description: Build and customize Angular ChillSharp client projects from the UI template, including plugins, overrides, i18n, permissions, and runtime configuration.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# ChillSharp UI Client Template
|
|
7
|
-
|
|
8
|
-
Use this skill for work in `chill-sharp-ui-template` or a client repository created from it.
|
|
9
|
-
|
|
10
|
-
The template owns runtime configuration, branding, routes, client plugins, and overrides. Shared controls, data access, schema rendering, auth, i18n primitives, and permission evaluation belong in `@chill-sharp/ui-core` and the ChillSharp client packages. Do not copy or patch shared package internals.
|
|
11
|
-
|
|
12
|
-
Keep `provideClientTemplateProviders()` in the app provider chain. Register feature routes in `src/app/core/plugins/register-client-plugins.ts`; register deliberate provider replacements in `src/app/core/overrides/register-client-overrides.ts`. Use public package APIs only.
|
|
13
|
-
|
|
14
|
-
Treat backend schema as the source of entity/property metadata rather than duplicating it in Angular. Use runtime API configuration from `public/env.js`. Request localized text with an explicit culture and preserve backend fallback behavior. UI permission checks can hide or disable operations, but the protected backend is the enforcement boundary.
|
|
15
|
-
|
|
16
|
-
Permission-sensitive features must account for `Module -> Entity -> Property`: entity `Query/Create/Update/Delete` is separate from property `See/Modify`. Never infer write access from a visible field.
|
|
17
|
-
|
|
18
|
-
Add plugins under the client-owned plugin folder, register providers through the override/provider points, keep tenant/feature flags/branding in runtime config, add focused tests, and run `npm run build` after registration changes. This `.agents/skills` directory travels with the template into client repositories.
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# AI-Assisted Development Guide
|
|
2
|
-
|
|
3
|
-
Versione italiana: [Italiano](../it/AIAssistedDevelopment/README.md)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
This document explains how ChillSharp can help when you build software with AI assistance and still want the codebase to remain structured, stable, and reviewable.
|
|
7
|
-
|
|
8
|
-
The key idea is simple: AI tools are much more reliable when they work inside a constrained, repetitive, well-defined architecture than when they are asked to manually keep many controllers, DTOs, endpoints, and validation paths in sync.
|
|
9
|
-
|
|
10
|
-
ChillSharp does not make AI-generated code automatically correct. What it does is reduce the amount of surface area that AI has to generate and maintain.
|
|
11
|
-
|
|
12
|
-
## Why This Matters
|
|
13
|
-
|
|
14
|
-
A common failure mode in AI-assisted backend development is that the model touches too many moving parts at once:
|
|
15
|
-
|
|
16
|
-
- controllers
|
|
17
|
-
- DTO mappings
|
|
18
|
-
- request/response contracts
|
|
19
|
-
- validation logic
|
|
20
|
-
- authorization checks
|
|
21
|
-
- duplicated CRUD behaviors
|
|
22
|
-
|
|
23
|
-
The more files and custom endpoints you have, the easier it is for AI to introduce accidental interface drift, inconsistent behavior, or broad refactors that were never intended.
|
|
24
|
-
|
|
25
|
-
ChillSharp reduces that risk by moving a large part of the backend surface into a uniform model-driven runtime.
|
|
26
|
-
|
|
27
|
-
## How ChillSharp Helps
|
|
28
|
-
|
|
29
|
-
### 1. Business logic grows inside a structured environment
|
|
30
|
-
|
|
31
|
-
With ChillSharp, the main extension points are explicit and predictable:
|
|
32
|
-
|
|
33
|
-
- `ChillEntity`
|
|
34
|
-
- `ChillQuery`
|
|
35
|
-
- `OnValidation()`
|
|
36
|
-
- lifecycle hooks such as `OnCreate()`, `OnUpdate()`, `OnAfterUpdate()`, `OnDelete()`, and `OnSelect()`
|
|
37
|
-
- metadata through `[ChillProperty]` and related annotations
|
|
38
|
-
|
|
39
|
-
That gives AI a narrower and more structured place to make changes.
|
|
40
|
-
|
|
41
|
-
Instead of asking an AI model to invent yet another controller, request DTO, response DTO, mapper, validator, and route contract, you can often ask it to:
|
|
42
|
-
|
|
43
|
-
- add a property
|
|
44
|
-
- add validation
|
|
45
|
-
- add a query filter
|
|
46
|
-
- add lifecycle logic
|
|
47
|
-
- adjust permission rules
|
|
48
|
-
|
|
49
|
-
This usually produces smaller and safer edits.
|
|
50
|
-
|
|
51
|
-
### 2. Lower risk of accidental endpoint refactoring
|
|
52
|
-
|
|
53
|
-
ChillSharp exposes a standard API surface through `app.MapChillApi()`, with stable operations such as:
|
|
54
|
-
|
|
55
|
-
- `POST /api/chill/query`
|
|
56
|
-
- `POST /api/chill/lookup`
|
|
57
|
-
- `POST /api/chill/find`
|
|
58
|
-
- `POST /api/chill/create`
|
|
59
|
-
- `POST /api/chill/update`
|
|
60
|
-
- `POST /api/chill/delete`
|
|
61
|
-
|
|
62
|
-
Because the transport surface is centralized, adding or evolving business entities does not require AI to keep rewriting a growing set of per-entity controllers and route definitions.
|
|
63
|
-
|
|
64
|
-
This reduces a specific AI risk:
|
|
65
|
-
|
|
66
|
-
- changing endpoint names by accident
|
|
67
|
-
- changing payload shapes inconsistently
|
|
68
|
-
- implementing one endpoint differently from the rest
|
|
69
|
-
- breaking clients through unnecessary API refactors
|
|
70
|
-
|
|
71
|
-
The interface still evolves when your model evolves, but the CRUD and query mechanics do not have to be re-authored every time.
|
|
72
|
-
|
|
73
|
-
### 3. Endpoints grow in a uniform way
|
|
74
|
-
|
|
75
|
-
In a traditional hand-written backend, every new entity tends to create more duplicated API code. Over time, small differences accumulate:
|
|
76
|
-
|
|
77
|
-
- one controller validates differently
|
|
78
|
-
- another controller returns slightly different payloads
|
|
79
|
-
- another endpoint forgets an authorization check
|
|
80
|
-
- another DTO mapper omits a field
|
|
81
|
-
|
|
82
|
-
AI tools amplify this problem because they continue the local pattern they see, even when the local pattern is already inconsistent.
|
|
83
|
-
|
|
84
|
-
ChillSharp pushes the system in the opposite direction: entities and queries plug into the same runtime model, so growth is more uniform by default.
|
|
85
|
-
|
|
86
|
-
That uniformity helps both:
|
|
87
|
-
|
|
88
|
-
- human maintainers reviewing AI-produced changes
|
|
89
|
-
- AI tools reasoning over the codebase with less ambiguity
|
|
90
|
-
|
|
91
|
-
### 4. Smaller program payload for AI tools
|
|
92
|
-
|
|
93
|
-
When a project relies on many custom CRUD controllers, DTO classes, mapping layers, and repetitive endpoint definitions, AI needs more repository context to make a safe change.
|
|
94
|
-
|
|
95
|
-
That increases:
|
|
96
|
-
|
|
97
|
-
- token usage
|
|
98
|
-
- latency
|
|
99
|
-
- cost
|
|
100
|
-
- the chance that the model misses one of the duplicated layers
|
|
101
|
-
|
|
102
|
-
ChillSharp reduces this burden because much of the repetitive transport logic is already handled by the framework runtime.
|
|
103
|
-
|
|
104
|
-
In practice this means an AI task can often be solved by reading and changing:
|
|
105
|
-
|
|
106
|
-
- one entity
|
|
107
|
-
- one query
|
|
108
|
-
- one validation rule
|
|
109
|
-
- one permission definition
|
|
110
|
-
|
|
111
|
-
instead of a long chain of related files.
|
|
112
|
-
|
|
113
|
-
### 5. Lower pressure for continuous large-scale refactoring
|
|
114
|
-
|
|
115
|
-
Without a model-driven framework, teams often ask AI to keep refactoring a growing list of:
|
|
116
|
-
|
|
117
|
-
- endpoints
|
|
118
|
-
- controllers
|
|
119
|
-
- DTOs
|
|
120
|
-
- validators
|
|
121
|
-
- mappers
|
|
122
|
-
- permission checks
|
|
123
|
-
|
|
124
|
-
That is expensive and fragile. It also encourages broad automated rewrites that may not deliver business value.
|
|
125
|
-
|
|
126
|
-
ChillSharp reduces the need for that style of maintenance because the generic CRUD/query surface is already centralized.
|
|
127
|
-
|
|
128
|
-
That has practical benefits:
|
|
129
|
-
|
|
130
|
-
- lower AI token consumption
|
|
131
|
-
- fewer broad refactors across repetitive files
|
|
132
|
-
- less review effort for generated code
|
|
133
|
-
- lower compute usage for the same feature work
|
|
134
|
-
|
|
135
|
-
If you care about both engineering efficiency and energy efficiency, this is one of the strongest arguments for using a uniform runtime instead of a large amount of repeated endpoint boilerplate.
|
|
136
|
-
|
|
137
|
-
## What ChillSharp Is Good At In AI Workflows
|
|
138
|
-
|
|
139
|
-
ChillSharp is a good fit when you want AI to help with:
|
|
140
|
-
|
|
141
|
-
- extending domain entities
|
|
142
|
-
- adding validation rules
|
|
143
|
-
- adding query capabilities
|
|
144
|
-
- exposing model changes through an existing generic API surface
|
|
145
|
-
- keeping permissions and metadata closer to the model
|
|
146
|
-
|
|
147
|
-
This is usually a better fit than asking AI to repeatedly generate large sets of CRUD infrastructure code.
|
|
148
|
-
|
|
149
|
-
## What ChillSharp Does Not Solve
|
|
150
|
-
|
|
151
|
-
ChillSharp does not remove the need for engineering review. In particular, you still need to verify:
|
|
152
|
-
|
|
153
|
-
- business rules are correct
|
|
154
|
-
- authorization rules are correct
|
|
155
|
-
- exposed properties are intentional
|
|
156
|
-
- model changes do not break consumers
|
|
157
|
-
- AI-generated lifecycle logic is actually safe
|
|
158
|
-
|
|
159
|
-
ChillSharp reduces duplication and drift. It does not remove the need for judgment.
|
|
160
|
-
|
|
161
|
-
## Recommended Positioning
|
|
162
|
-
|
|
163
|
-
If you want a short and defensible way to describe this in documentation or architecture notes, use something like:
|
|
164
|
-
|
|
165
|
-
"ChillSharp helps AI-assisted development by centralizing repetitive API mechanics into a model-driven runtime. This reduces accidental interface drift, keeps endpoint behavior more uniform, and lowers the amount of code and repository context that AI tools must generate and maintain."
|
|
166
|
-
|
|
167
|
-
## Practical Checklist
|
|
168
|
-
|
|
169
|
-
If you want to use ChillSharp as an AI-friendly backend architecture, the baseline is:
|
|
170
|
-
|
|
171
|
-
1. keep business entities and queries as the main place where feature behavior is defined
|
|
172
|
-
2. use `[ChillProperty]` consistently so the DTO and validation surface remains intentional
|
|
173
|
-
3. prefer `OnValidation()` and lifecycle hooks over ad-hoc controller logic
|
|
174
|
-
4. avoid reintroducing repetitive custom CRUD endpoints unless there is a real need
|
|
175
|
-
5. review model changes carefully because a model-driven surface can affect multiple client operations at once
|
|
176
|
-
6. keep permissions and authentication aligned with the same model-driven approach
|
|
177
|
-
|
|
178
|
-
## Related Documents
|
|
179
|
-
|
|
180
|
-
- [../README.md](../README.md)
|
|
181
|
-
- [../RegisterContext.md](../RegisterContext.md)
|
|
182
|
-
- [../ValidationModel/README.md](../ValidationModel/README.md)
|
|
183
|
-
- [../PermissionModel/README.md](../PermissionModel/README.md)
|
|
184
|
-
- [../AuthenticationModel/README.md](../AuthenticationModel/README.md)
|
|
185
|
-
- [../ClientGeneration/README.md](../ClientGeneration/README.md)
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# Attachment Module
|
|
2
|
-
|
|
3
|
-
Versione italiana: [Italiano](../it/AttachmentModel/README.md)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`ChillSharp.Attachment` adds a built-in attachment entity plus upload and download endpoints backed by a filesystem archive.
|
|
7
|
-
|
|
8
|
-
## What It Adds
|
|
9
|
-
|
|
10
|
-
- `Attachment` Chill entity persisted in the `attachment` table
|
|
11
|
-
- generic Chill CRUD support for attachment metadata
|
|
12
|
-
- `GET /api/chill-attachment/attachment/download?guid=...`
|
|
13
|
-
- `POST /api/chill-attachment/attachment/upload`
|
|
14
|
-
|
|
15
|
-
Because `Attachment` is a real `ChillEntity`, it is also exposed through schema discovery and can be managed through the standard Chill CRUD endpoints once the host `DbContext` implements `IChillAttachmentDbContext`.
|
|
16
|
-
|
|
17
|
-
The module also exposes an `AttachmentQuery` Chill query type, which client helpers can use to list attachments linked to a target entity.
|
|
18
|
-
|
|
19
|
-
## Register The Module
|
|
20
|
-
|
|
21
|
-
Add the module model to your context and expose the `DbSet`:
|
|
22
|
-
|
|
23
|
-
```csharp
|
|
24
|
-
using ChillSharp.Attachment;
|
|
25
|
-
using ChillSharp.Attachment.Model;
|
|
26
|
-
|
|
27
|
-
public class AppDbContext : DbContext, IChillContext, IChillAttachmentDbContext
|
|
28
|
-
{
|
|
29
|
-
public DbSet<Attachment> Attachments => Set<Attachment>();
|
|
30
|
-
|
|
31
|
-
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
32
|
-
{
|
|
33
|
-
base.OnModelCreating(modelBuilder);
|
|
34
|
-
modelBuilder.AddChillAttachmentModel();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public string GetChillTypePrefix() => "MyApp.Data";
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
When the context implements `IChillAttachmentDbContext`, `services.AddChillApi<AppDbContext>()` automatically registers the attachment endpoints.
|
|
42
|
-
|
|
43
|
-
## Archive Root Configuration
|
|
44
|
-
|
|
45
|
-
The module reads the archive root from:
|
|
46
|
-
|
|
47
|
-
- startup options via `services.Configure<ChillAttachmentOptions>(...)`
|
|
48
|
-
- environment variable `CHILLSHARP_ATTACHMENT_ARCHIVE_ROOT`
|
|
49
|
-
|
|
50
|
-
Example:
|
|
51
|
-
|
|
52
|
-
```csharp
|
|
53
|
-
builder.Services.Configure<ChillAttachmentOptions>(options =>
|
|
54
|
-
{
|
|
55
|
-
options.ArchiveRoot = "/srv/chill/attachments";
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Or through environment:
|
|
60
|
-
|
|
61
|
-
```env
|
|
62
|
-
CHILLSHARP_ATTACHMENT_ARCHIVE_ROOT=/srv/chill/attachments
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Archive Layout
|
|
66
|
-
|
|
67
|
-
Files are stored under the configured archive root using:
|
|
68
|
-
|
|
69
|
-
```csharp
|
|
70
|
-
public static string BuildAttachmentPath(
|
|
71
|
-
string archiveRoot,
|
|
72
|
-
string attachToChillType,
|
|
73
|
-
Guid id,
|
|
74
|
-
string extension,
|
|
75
|
-
DateTime createdAtUtc)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
The resulting layout is:
|
|
79
|
-
|
|
80
|
-
```text
|
|
81
|
-
{archiveRoot}/{attachToChillType}/{year}/{guid[0..2]}/{guid[2..4]}/{guid}{extension}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Example:
|
|
85
|
-
|
|
86
|
-
```text
|
|
87
|
-
/srv/chill/attachments/Post/2026/ab/cd/abcd1234....pdf
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Upload Endpoint
|
|
91
|
-
|
|
92
|
-
`POST /api/chill-attachment/attachment/upload`
|
|
93
|
-
|
|
94
|
-
Multipart form fields:
|
|
95
|
-
|
|
96
|
-
- `attachToChillType`
|
|
97
|
-
- `attachToGuid`
|
|
98
|
-
- `title`
|
|
99
|
-
- `description`
|
|
100
|
-
- `public`
|
|
101
|
-
- one or more `file` parts
|
|
102
|
-
|
|
103
|
-
For each uploaded file the module:
|
|
104
|
-
|
|
105
|
-
1. creates an `Attachment` Chill entity through `ChillEngine`
|
|
106
|
-
2. stores the physical file in the archive
|
|
107
|
-
3. returns the created attachment DTO payload
|
|
108
|
-
|
|
109
|
-
## Download Endpoint
|
|
110
|
-
|
|
111
|
-
`GET /api/chill-attachment/attachment/download?guid={attachmentGuid}`
|
|
112
|
-
|
|
113
|
-
Behavior:
|
|
114
|
-
|
|
115
|
-
- loads the `Attachment` entity from the database
|
|
116
|
-
- resolves the archived file path
|
|
117
|
-
- returns the file using the stored original filename and mime type
|
|
118
|
-
- allows anonymous download when `Public == true`
|
|
119
|
-
- requires an authenticated user when `Public == false`
|
|
120
|
-
|
|
121
|
-
## Client Helpers
|
|
122
|
-
|
|
123
|
-
### `.NET`
|
|
124
|
-
|
|
125
|
-
`ChillSharp.Client` now includes attachment helpers:
|
|
126
|
-
|
|
127
|
-
```csharp
|
|
128
|
-
var post = new ChillDtoEntity
|
|
129
|
-
{
|
|
130
|
-
Guid = postGuid,
|
|
131
|
-
ChillType = "Model.Post"
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
var uploaded = await client.UploadAttachmentAsync(
|
|
135
|
-
post,
|
|
136
|
-
File.ReadAllBytes("contract.pdf"),
|
|
137
|
-
"contract.pdf",
|
|
138
|
-
"application/pdf",
|
|
139
|
-
title: "Signed contract",
|
|
140
|
-
description: "Customer-facing version",
|
|
141
|
-
isPublic: false);
|
|
142
|
-
|
|
143
|
-
var attachments = await client.GetAttachmentsAsync(post);
|
|
144
|
-
var fileBytes = await client.DownloadAttachmentAsync(uploaded[0]);
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
Available overloads cover:
|
|
148
|
-
|
|
149
|
-
- upload from file path
|
|
150
|
-
- upload from `byte[]`
|
|
151
|
-
- upload from `Stream`
|
|
152
|
-
- download by attachment `Guid`
|
|
153
|
-
- download by attachment `ChillDtoEntity`
|
|
154
|
-
|
|
155
|
-
### TypeScript / Angular / React / Vue / Python
|
|
156
|
-
|
|
157
|
-
The generic client libraries under `extra-libs/` expose matching helpers:
|
|
158
|
-
|
|
159
|
-
- TypeScript: `uploadAttachment()`, `uploadAttachments()`, `getAttachments()`, `downloadAttachment()`
|
|
160
|
-
- Angular: same helpers through `ChillSharpNgClient` as `Observable` wrappers
|
|
161
|
-
- React and Vue: same helpers through the raw client returned by `useChillSharpClient()`
|
|
162
|
-
- Python: `upload_attachment()`, `upload_attachments()`, `get_attachments()`, `download_attachment()`
|
|
163
|
-
|
|
164
|
-
## Generic CRUD
|
|
165
|
-
|
|
166
|
-
Attachment metadata remains available through the standard Chill endpoints:
|
|
167
|
-
|
|
168
|
-
- `POST /api/chill/create`
|
|
169
|
-
- `POST /api/chill/find`
|
|
170
|
-
- `POST /api/chill/update`
|
|
171
|
-
- `POST /api/chill/delete`
|
|
172
|
-
|
|
173
|
-
Deleting an attachment through ChillSharp also removes the archived file from disk.
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
# ChillSharp Authentication And Authorization
|
|
2
|
-
|
|
3
|
-
Versione italiana: [Italiano](../it/AuthenticationModel/README.md)
|
|
4
|
-
|
|
5
|
-
This document covers the auth module at a reference level. For a guided setup, keep using [doc/HowTo/03-authentication.md](../HowTo/03-authentication.md).
|
|
6
|
-
|
|
7
|
-
## Module Split
|
|
8
|
-
|
|
9
|
-
`ChillSharp.Auth` exposes two related but distinct concerns:
|
|
10
|
-
|
|
11
|
-
- account authentication
|
|
12
|
-
ASP.NET Core Identity-backed register, login, refresh, password-change, and password-reset flows
|
|
13
|
-
|
|
14
|
-
- authorization management
|
|
15
|
-
auth users, roles, role assignments, permission rules, and permission evaluation
|
|
16
|
-
|
|
17
|
-
## Account Endpoints
|
|
18
|
-
|
|
19
|
-
Registered through:
|
|
20
|
-
|
|
21
|
-
```csharp
|
|
22
|
-
builder.Services.AddChillAuthIdentityApi<AppDbContext, IdentityUser>();
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Typical routes:
|
|
26
|
-
|
|
27
|
-
- `/api/chill-auth/account/register`
|
|
28
|
-
- `/api/chill-auth/account/login`
|
|
29
|
-
- `/api/chill-auth/account/refresh`
|
|
30
|
-
- `/api/chill-auth/account/change-password`
|
|
31
|
-
- `/api/chill-auth/account/request-password-reset`
|
|
32
|
-
- `/api/chill-auth/account/reset-password`
|
|
33
|
-
|
|
34
|
-
These are the routes used internally by `ChillSharpClient`.
|
|
35
|
-
|
|
36
|
-
`RegisterAuthIdentityRequest` also supports:
|
|
37
|
-
|
|
38
|
-
- `DisplayName`
|
|
39
|
-
- `DisplayCultureName`
|
|
40
|
-
- `CreateChillAuthUser`
|
|
41
|
-
|
|
42
|
-
When `CreateChillAuthUser` is enabled and `DisplayCultureName` is provided, the linked `AuthUser` is automatically preset with:
|
|
43
|
-
|
|
44
|
-
- `DisplayCultureName`
|
|
45
|
-
- `DisplayTimeZone`
|
|
46
|
-
- `DisplayDateFormat`
|
|
47
|
-
- `DisplayNumberFormat`
|
|
48
|
-
|
|
49
|
-
The server resolves those defaults from the selected culture by using a best-effort time-zone mapping plus the culture date and number separators.
|
|
50
|
-
|
|
51
|
-
## Authorization Management Endpoints
|
|
52
|
-
|
|
53
|
-
Registered through:
|
|
54
|
-
|
|
55
|
-
```csharp
|
|
56
|
-
builder.Services.AddChillAuthApi<AppDbContext>();
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Typical route groups:
|
|
60
|
-
|
|
61
|
-
- `/api/chill-auth/users`
|
|
62
|
-
- `/api/chill-auth/roles`
|
|
63
|
-
- `/api/chill-auth/permissions`
|
|
64
|
-
|
|
65
|
-
These endpoints manage:
|
|
66
|
-
|
|
67
|
-
- `AuthUser`
|
|
68
|
-
- `AuthRole`
|
|
69
|
-
- `AuthUserRole`
|
|
70
|
-
- `AuthPermissionRule`
|
|
71
|
-
- permission evaluation results
|
|
72
|
-
|
|
73
|
-
`AuthUser` now also carries optional UI display preferences:
|
|
74
|
-
|
|
75
|
-
- `DisplayCultureName`
|
|
76
|
-
- `DisplayTimeZone`
|
|
77
|
-
- `DisplayDateFormat`
|
|
78
|
-
- `DisplayNumberFormat`
|
|
79
|
-
|
|
80
|
-
`AuthUser` and `AuthRole` also carry:
|
|
81
|
-
|
|
82
|
-
- `MenuHierarchy`
|
|
83
|
-
|
|
84
|
-
`MenuHierarchy` is used by the schema menu endpoints to filter which menu nodes are visible to the current user.
|
|
85
|
-
|
|
86
|
-
- values can be single codes or comma-separated lists
|
|
87
|
-
- user and active role values are merged before filtering
|
|
88
|
-
- `*` means full menu access
|
|
89
|
-
- any other value works as a prefix match, for example `SECTION-A` allows nodes whose menu hierarchy starts with `SECTION-A`
|
|
90
|
-
- an empty merged menu hierarchy set means no menu access
|
|
91
|
-
|
|
92
|
-
For the full menu-tree model and endpoint behavior, see [MenuGuide/README.md](../MenuGuide/README.md).
|
|
93
|
-
|
|
94
|
-
## Token Lifetimes
|
|
95
|
-
|
|
96
|
-
ChillSharp auth account endpoints issue protected bearer access tokens and refresh tokens. These access tokens are not JWTs, but they are used in the same `Authorization: Bearer ...` header shape.
|
|
97
|
-
|
|
98
|
-
Default lifetimes:
|
|
99
|
-
|
|
100
|
-
- access token: 20 minutes
|
|
101
|
-
- refresh token: 14 days
|
|
102
|
-
|
|
103
|
-
Built-in environment variables:
|
|
104
|
-
|
|
105
|
-
- `CHILLSHARP_AUTH_ACCESS_TOKEN_MINUTES`
|
|
106
|
-
Positive integer number of minutes before an access token expires.
|
|
107
|
-
- `CHILLSHARP_AUTH_REFRESH_TOKEN_DAYS`
|
|
108
|
-
Positive integer number of days before a refresh token expires.
|
|
109
|
-
|
|
110
|
-
These variables are read by `ChillAuthIdentityApiOptions` and `ChillIdentityApiOptions` when the options object is created. Explicit code configuration still wins:
|
|
111
|
-
|
|
112
|
-
```csharp
|
|
113
|
-
builder.Services.AddChillAuthIdentityApi<AppDbContext, IdentityUser>(options =>
|
|
114
|
-
{
|
|
115
|
-
options.AccessTokenLifetime = TimeSpan.FromMinutes(30);
|
|
116
|
-
options.RefreshTokenLifetime = TimeSpan.FromDays(7);
|
|
117
|
-
});
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Context Requirements
|
|
121
|
-
|
|
122
|
-
The host context must:
|
|
123
|
-
|
|
124
|
-
- implement `IChillAuthDbContext`
|
|
125
|
-
- include `modelBuilder.AddChillAuthModel()`
|
|
126
|
-
|
|
127
|
-
For Identity-backed accounts, the context must also be a valid EF store for ASP.NET Core Identity, typically:
|
|
128
|
-
|
|
129
|
-
```csharp
|
|
130
|
-
public class AppDbContext : IdentityDbContext<IdentityUser>, IChillContext, IChillAuthDbContext
|
|
131
|
-
{
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Root User Bootstrap
|
|
136
|
-
|
|
137
|
-
`AddChillAuthIdentityApi(...)` can bootstrap a root account on startup.
|
|
138
|
-
|
|
139
|
-
Supported configuration:
|
|
140
|
-
|
|
141
|
-
- direct options in code
|
|
142
|
-
- environment variables
|
|
143
|
-
|
|
144
|
-
Default environment variables:
|
|
145
|
-
|
|
146
|
-
- `CHILLSHARP_AUTH_ROOT_USERNAME`
|
|
147
|
-
- `CHILLSHARP_AUTH_ROOT_PASSWORD`
|
|
148
|
-
- `CHILLSHARP_AUTH_ROOT_EMAIL`
|
|
149
|
-
- `CHILLSHARP_AUTH_ROOT_DISPLAY_NAME`
|
|
150
|
-
|
|
151
|
-
When enabled, the bootstrap flow can also create the linked ChillSharp `AuthUser` with permission-management access.
|
|
152
|
-
|
|
153
|
-
## Permission Management Access
|
|
154
|
-
|
|
155
|
-
Being authenticated is not enough to manage the auth module.
|
|
156
|
-
|
|
157
|
-
Auth-management endpoints require a ChillSharp auth user with permission-management rights, typically:
|
|
158
|
-
|
|
159
|
-
- `CanManagePermissions = true`
|
|
160
|
-
|
|
161
|
-
This is the critical bootstrap problem for a clean database:
|
|
162
|
-
|
|
163
|
-
- the first registered Identity user may exist
|
|
164
|
-
- the linked `AuthUser` may exist
|
|
165
|
-
- but no one may yet have rights to manage roles and permissions
|
|
166
|
-
|
|
167
|
-
That is why root-user bootstrap or another trusted setup path matters.
|
|
168
|
-
|
|
169
|
-
## Client Usage
|
|
170
|
-
|
|
171
|
-
Use the normal Chill base URL:
|
|
172
|
-
|
|
173
|
-
```csharp
|
|
174
|
-
var client = new ChillSharpClient("http://localhost:5000/api/chill");
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
`ChillSharpClient` automatically switches to `/api/chill-auth/...` for auth methods.
|
|
178
|
-
|
|
179
|
-
Examples:
|
|
180
|
-
|
|
181
|
-
- `RegisterAuthAccount`
|
|
182
|
-
- `LoginAuthAccount`
|
|
183
|
-
- `RefreshAuthAccount`
|
|
184
|
-
- `ChangeAuthPassword`
|
|
185
|
-
- `CreateAuthRole`
|
|
186
|
-
- `CreateAuthPermissionRule`
|
|
187
|
-
- `EvaluateAuthEntityPermission`
|
|
188
|
-
|
|
189
|
-
User list and user detail payloads also expose:
|
|
190
|
-
|
|
191
|
-
- `DisplayCultureName`
|
|
192
|
-
- `DisplayTimeZone`
|
|
193
|
-
- `DisplayDateFormat`
|
|
194
|
-
- `DisplayNumberFormat`
|
|
195
|
-
|
|
196
|
-
## Token Handling
|
|
197
|
-
|
|
198
|
-
`ChillSharpClient` stores:
|
|
199
|
-
|
|
200
|
-
- access token
|
|
201
|
-
- refresh token
|
|
202
|
-
|
|
203
|
-
If a refresh token is present, the client can renew the access token automatically during later authenticated calls.
|
|
204
|
-
|
|
205
|
-
## Relationship With The Permission Model
|
|
206
|
-
|
|
207
|
-
The exact permission-resolution rules are documented separately in:
|
|
208
|
-
|
|
209
|
-
- [PermissionModel/README.md](../PermissionModel/README.md)
|
|
210
|
-
|
|
211
|
-
Use that document for the precedence and scope model. Use this one for registration and runtime auth flow.
|
|
212
|
-
|
|
213
|
-
|