@chill-sharp/ui-core 1.1.12

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 (204) hide show
  1. package/.agents/skills/chillsharp-current-user-preferences/SKILL.md +70 -0
  2. package/.agents/skills/chillsharp-ui-template/SKILL.md +18 -0
  3. package/README.md +103 -0
  4. package/chill-sharp-ui-core.d.ts.map +1 -0
  5. package/doc/AIAssistedDevelopment/README.md +185 -0
  6. package/doc/AttachmentModel/README.md +173 -0
  7. package/doc/AuthenticationModel/README.md +213 -0
  8. package/doc/AuthenticationModel/how-to-integreate-auth-minimal-api.md +293 -0
  9. package/doc/ChillSharpClient.md +464 -0
  10. package/doc/ClientGeneration/README.md +172 -0
  11. package/doc/ComplianceGuide/README.md +178 -0
  12. package/doc/Configuration/README.md +94 -0
  13. package/doc/CurrentUserPreferences.md +114 -0
  14. package/doc/DateTimePolicy/README.md +154 -0
  15. package/doc/DateTimeSerialization.md +423 -0
  16. package/doc/Endpoints.md +260 -0
  17. package/doc/HowTo/01-simple-blog-sqlite.md +153 -0
  18. package/doc/HowTo/02-blog-schema-labels.md +140 -0
  19. package/doc/HowTo/03-authentication.md +218 -0
  20. package/doc/HowTo/04-blog-posts-one-to-many.md +194 -0
  21. package/doc/HowTo/05-docker-env-variables.md +274 -0
  22. package/doc/HowTo/06-chunk-transactions-autocomplete.md +196 -0
  23. package/doc/Mcp/ChatGPT.md +291 -0
  24. package/doc/Mcp/README.md +799 -0
  25. package/doc/MenuGuide/README.md +49 -0
  26. package/doc/ModelPreparation.md +255 -0
  27. package/doc/PermissionModel/README.md +277 -0
  28. package/doc/README.md +228 -0
  29. package/doc/ReferenceExistence.md +130 -0
  30. package/doc/RegisterContext.md +217 -0
  31. package/doc/UiCore/CRUD.md +170 -0
  32. package/doc/UiCore/README.md +13 -0
  33. package/doc/ValidationModel/README.md +117 -0
  34. package/doc/it/AIAssistedDevelopment/README.md +185 -0
  35. package/doc/it/AttachmentModel/README.md +173 -0
  36. package/doc/it/AuthenticationModel/README.md +171 -0
  37. package/doc/it/AuthenticationModel/how-to-integreate-auth-minimal-api.md +292 -0
  38. package/doc/it/ChillSharpClient.md +464 -0
  39. package/doc/it/ClientGeneration/README.md +152 -0
  40. package/doc/it/ComplianceGuide/README.md +178 -0
  41. package/doc/it/Configuration/README.md +94 -0
  42. package/doc/it/CurrentUserPreferences.md +114 -0
  43. package/doc/it/DateTimePolicy/README.md +154 -0
  44. package/doc/it/DateTimeSerialization.md +423 -0
  45. package/doc/it/Endpoints.md +260 -0
  46. package/doc/it/HowTo/01-simple-blog-sqlite.md +152 -0
  47. package/doc/it/HowTo/02-blog-schema-labels.md +139 -0
  48. package/doc/it/HowTo/03-authentication.md +221 -0
  49. package/doc/it/HowTo/04-blog-posts-one-to-many.md +193 -0
  50. package/doc/it/HowTo/05-docker-env-variables.md +268 -0
  51. package/doc/it/HowTo/06-chunk-transactions-autocomplete.md +196 -0
  52. package/doc/it/Mcp/ChatGPT.md +291 -0
  53. package/doc/it/Mcp/README.md +799 -0
  54. package/doc/it/MenuGuide/README.md +49 -0
  55. package/doc/it/ModelPreparation.md +254 -0
  56. package/doc/it/PermissionModel/README.md +190 -0
  57. package/doc/it/README.md +172 -0
  58. package/doc/it/ReferenceExistence.md +130 -0
  59. package/doc/it/RegisterContext.md +218 -0
  60. package/doc/it/UiCore/CRUD.md +170 -0
  61. package/doc/it/UiCore/README.md +13 -0
  62. package/doc/it/ValidationModel/README.md +117 -0
  63. package/fesm2022/chill-sharp-ui-core.mjs +16725 -0
  64. package/fesm2022/chill-sharp-ui-core.mjs.map +1 -0
  65. package/index.d.ts +6 -0
  66. package/lib/chill-sharp-ui-root.component.d.ts +6 -0
  67. package/lib/chill-sharp-ui-root.component.d.ts.map +1 -0
  68. package/lib/chill-sharp-ui.routes.d.ts +3 -0
  69. package/lib/chill-sharp-ui.routes.d.ts.map +1 -0
  70. package/lib/chill.config.d.ts +5 -0
  71. package/lib/chill.config.d.ts.map +1 -0
  72. package/lib/layouts/auth-shell.component.d.ts +8 -0
  73. package/lib/layouts/auth-shell.component.d.ts.map +1 -0
  74. package/lib/layouts/workspace-page.component.d.ts +49 -0
  75. package/lib/layouts/workspace-page.component.d.ts.map +1 -0
  76. package/lib/lib/chill-form.component.d.ts +151 -0
  77. package/lib/lib/chill-form.component.d.ts.map +1 -0
  78. package/lib/lib/chill-i18n-button-label.component.d.ts +27 -0
  79. package/lib/lib/chill-i18n-button-label.component.d.ts.map +1 -0
  80. package/lib/lib/chill-i18n-label.component.d.ts +30 -0
  81. package/lib/lib/chill-i18n-label.component.d.ts.map +1 -0
  82. package/lib/lib/chill-json-input.component.d.ts +31 -0
  83. package/lib/lib/chill-json-input.component.d.ts.map +1 -0
  84. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-boolean-control.component.d.ts +12 -0
  85. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-boolean-control.component.d.ts.map +1 -0
  86. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-editor-control.component.d.ts +17 -0
  87. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-editor-control.component.d.ts.map +1 -0
  88. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-lookup-control.component.d.ts +45 -0
  89. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-lookup-control.component.d.ts.map +1 -0
  90. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-scalar-control.component.d.ts +19 -0
  91. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-scalar-control.component.d.ts.map +1 -0
  92. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-select-control.component.d.ts +12 -0
  93. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-select-control.component.d.ts.map +1 -0
  94. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-textarea-control.component.d.ts +13 -0
  95. package/lib/lib/chill-polymorphic-input-controls/chill-polymorphic-textarea-control.component.d.ts.map +1 -0
  96. package/lib/lib/chill-polymorphic-input.component.d.ts +452 -0
  97. package/lib/lib/chill-polymorphic-input.component.d.ts.map +1 -0
  98. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-boolean-control.component.d.ts +7 -0
  99. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-boolean-control.component.d.ts.map +1 -0
  100. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-lookup-control.component.d.ts +7 -0
  101. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-lookup-control.component.d.ts.map +1 -0
  102. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-number-control.component.d.ts +7 -0
  103. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-number-control.component.d.ts.map +1 -0
  104. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-temporal-control.component.d.ts +8 -0
  105. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-temporal-control.component.d.ts.map +1 -0
  106. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-value-control.component.d.ts +7 -0
  107. package/lib/lib/chill-polymorphic-output-controls/chill-polymorphic-output-value-control.component.d.ts.map +1 -0
  108. package/lib/lib/chill-polymorphic-output.component.d.ts +75 -0
  109. package/lib/lib/chill-polymorphic-output.component.d.ts.map +1 -0
  110. package/lib/lib/chill-table.component.d.ts +434 -0
  111. package/lib/lib/chill-table.component.d.ts.map +1 -0
  112. package/lib/lib/chill-text-editor-dialog.component.d.ts +14 -0
  113. package/lib/lib/chill-text-editor-dialog.component.d.ts.map +1 -0
  114. package/lib/lib/crud-configuration.utils.d.ts +4 -0
  115. package/lib/lib/crud-configuration.utils.d.ts.map +1 -0
  116. package/lib/lib/culture-name-options.d.ts +3 -0
  117. package/lib/lib/culture-name-options.d.ts.map +1 -0
  118. package/lib/lib/date-format-options.d.ts +3 -0
  119. package/lib/lib/date-format-options.d.ts.map +1 -0
  120. package/lib/lib/iana-time-zone-options.d.ts +3 -0
  121. package/lib/lib/iana-time-zone-options.d.ts.map +1 -0
  122. package/lib/lib/notice-transition.directive.d.ts +17 -0
  123. package/lib/lib/notice-transition.directive.d.ts.map +1 -0
  124. package/lib/lib/schema-property-dialog.component.d.ts +74 -0
  125. package/lib/lib/schema-property-dialog.component.d.ts.map +1 -0
  126. package/lib/models/chill-auth.models.d.ts +176 -0
  127. package/lib/models/chill-auth.models.d.ts.map +1 -0
  128. package/lib/models/chill-menu.models.d.ts +12 -0
  129. package/lib/models/chill-menu.models.d.ts.map +1 -0
  130. package/lib/models/chill-schema.models.d.ts +141 -0
  131. package/lib/models/chill-schema.models.d.ts.map +1 -0
  132. package/lib/models/workspace-dialog.models.d.ts +16 -0
  133. package/lib/models/workspace-dialog.models.d.ts.map +1 -0
  134. package/lib/models/workspace-task.models.d.ts +36 -0
  135. package/lib/models/workspace-task.models.d.ts.map +1 -0
  136. package/lib/pages/confirm-reset-page.component.d.ts +21 -0
  137. package/lib/pages/confirm-reset-page.component.d.ts.map +1 -0
  138. package/lib/pages/crud/attachment-upload-dialog.component.d.ts +24 -0
  139. package/lib/pages/crud/attachment-upload-dialog.component.d.ts.map +1 -0
  140. package/lib/pages/crud/crud-page.component.d.ts +244 -0
  141. package/lib/pages/crud/crud-page.component.d.ts.map +1 -0
  142. package/lib/pages/login-page.component.d.ts +21 -0
  143. package/lib/pages/login-page.component.d.ts.map +1 -0
  144. package/lib/pages/permissions/auth-role-dialog.component.d.ts +29 -0
  145. package/lib/pages/permissions/auth-role-dialog.component.d.ts.map +1 -0
  146. package/lib/pages/permissions/auth-search-select.component.d.ts +28 -0
  147. package/lib/pages/permissions/auth-search-select.component.d.ts.map +1 -0
  148. package/lib/pages/permissions/auth-user-dialog.component.d.ts +35 -0
  149. package/lib/pages/permissions/auth-user-dialog.component.d.ts.map +1 -0
  150. package/lib/pages/permissions/permission-editor.component.d.ts +55 -0
  151. package/lib/pages/permissions/permission-editor.component.d.ts.map +1 -0
  152. package/lib/pages/permissions/permissions-page.component.d.ts +38 -0
  153. package/lib/pages/permissions/permissions-page.component.d.ts.map +1 -0
  154. package/lib/pages/permissions/role-permission.component.d.ts +43 -0
  155. package/lib/pages/permissions/role-permission.component.d.ts.map +1 -0
  156. package/lib/pages/permissions/user-permission.component.d.ts +43 -0
  157. package/lib/pages/permissions/user-permission.component.d.ts.map +1 -0
  158. package/lib/pages/register-page.component.d.ts +24 -0
  159. package/lib/pages/register-page.component.d.ts.map +1 -0
  160. package/lib/pages/reset-password-page.component.d.ts +18 -0
  161. package/lib/pages/reset-password-page.component.d.ts.map +1 -0
  162. package/lib/provide-chill-sharp-ui-core.d.ts +8 -0
  163. package/lib/provide-chill-sharp-ui-core.d.ts.map +1 -0
  164. package/lib/services/chill.service.d.ts +249 -0
  165. package/lib/services/chill.service.d.ts.map +1 -0
  166. package/lib/services/workspace-dialog.service.d.ts +22 -0
  167. package/lib/services/workspace-dialog.service.d.ts.map +1 -0
  168. package/lib/services/workspace-layout.service.d.ts +13 -0
  169. package/lib/services/workspace-layout.service.d.ts.map +1 -0
  170. package/lib/services/workspace-task-registry.service.d.ts +35 -0
  171. package/lib/services/workspace-task-registry.service.d.ts.map +1 -0
  172. package/lib/services/workspace-toolbar.service.d.ts +23 -0
  173. package/lib/services/workspace-toolbar.service.d.ts.map +1 -0
  174. package/lib/services/workspace.service.d.ts +114 -0
  175. package/lib/services/workspace.service.d.ts.map +1 -0
  176. package/lib/storage-keys.d.ts +5 -0
  177. package/lib/storage-keys.d.ts.map +1 -0
  178. package/lib/tasks/crud-task/crud-task.component.d.ts +33 -0
  179. package/lib/tasks/crud-task/crud-task.component.d.ts.map +1 -0
  180. package/lib/tasks/goto-url-task/goto-url-task.component.d.ts +31 -0
  181. package/lib/tasks/goto-url-task/goto-url-task.component.d.ts.map +1 -0
  182. package/lib/workspace/confirm-message-dialog.component.d.ts +16 -0
  183. package/lib/workspace/confirm-message-dialog.component.d.ts.map +1 -0
  184. package/lib/workspace/entity-options-dialog.component.d.ts +29 -0
  185. package/lib/workspace/entity-options-dialog.component.d.ts.map +1 -0
  186. package/lib/workspace/external-task-api.d.ts +2 -0
  187. package/lib/workspace/external-task-api.d.ts.map +1 -0
  188. package/lib/workspace/user-profile-dialog.component.d.ts +30 -0
  189. package/lib/workspace/user-profile-dialog.component.d.ts.map +1 -0
  190. package/lib/workspace/workspace-dialog-host.component.d.ts +26 -0
  191. package/lib/workspace/workspace-dialog-host.component.d.ts.map +1 -0
  192. package/lib/workspace/workspace-menu-item-dialog.component.d.ts +61 -0
  193. package/lib/workspace/workspace-menu-item-dialog.component.d.ts.map +1 -0
  194. package/lib/workspace/workspace-menu.component.d.ts +104 -0
  195. package/lib/workspace/workspace-menu.component.d.ts.map +1 -0
  196. package/lib/workspace/workspace-taskbar.component.d.ts +14 -0
  197. package/lib/workspace/workspace-taskbar.component.d.ts.map +1 -0
  198. package/package.json +54 -0
  199. package/public-api.d.ts +56 -0
  200. package/public-api.d.ts.map +1 -0
  201. package/service-worker/chill-sharp-service-worker.js +166 -0
  202. package/styles/core-theme.scss +1268 -0
  203. package/template-customization/upgrade.ps1.template +342 -0
  204. package/template-customization/upgrade.sh.template +271 -0
@@ -0,0 +1,152 @@
1
+ # HOW-TO: API Blog Semplice Su SQLite
2
+
3
+ Versione originale in inglese: [English](../../HowTo/01-simple-blog-sqlite.md)
4
+
5
+ Questo esempio mostra la configurazione ChillSharp minima ma utile: una entita `Blog`, un contesto EF Core SQLite e una API ChillSharp senza testi label di schema negli attributi `ChillEntity` o `ChillProperty`.
6
+
7
+ ## Obiettivo
8
+
9
+ Costruire una API minima che possa creare e leggere entita `Blog` tramite ChillSharp.
10
+
11
+ ## 1. Definire L'Entita
12
+
13
+ Usa le versioni senza parametri di `ChillEntity` e `ChillProperty` quando non vuoi ancora fornire testi di schema.
14
+
15
+ ```csharp
16
+ using ChillSharp.Annotations;
17
+ using ChillSharp.EF;
18
+ using System.ComponentModel.DataAnnotations;
19
+
20
+ namespace MyBlogApp.Model;
21
+
22
+ [ChillEntity]
23
+ public class Blog : ChillEntity
24
+ {
25
+ [Key]
26
+ public override Guid Guid { get; set; }
27
+
28
+ [ChillProperty]
29
+ public string Name { get; set; } = string.Empty;
30
+
31
+ [ChillProperty]
32
+ public string? Url { get; set; }
33
+
34
+ public override string GetLabel(IChillContext context) => Name;
35
+ }
36
+ ```
37
+
38
+ ## 2. Definire Una Query
39
+
40
+ `Find` basta per caricare una sola entita tramite `Guid`, ma un tipo query resta utile quando vuoi filtri e proiezioni normali.
41
+
42
+ ```csharp
43
+ using ChillSharp.Annotations;
44
+ using ChillSharp.EF;
45
+
46
+ namespace MyBlogApp.Query;
47
+
48
+ [ChillEntity]
49
+ public class BlogQuery : ChillQuery
50
+ {
51
+ [ChillProperty]
52
+ public string? Name { get; set; }
53
+
54
+ public override IQueryable<IChillEntity> OnQuery(IChillContext context)
55
+ {
56
+ var db = (BloggingContext)context;
57
+ var query = db.Blogs.AsQueryable();
58
+
59
+ if (Guid.HasValue)
60
+ query = query.Where(x => x.Guid == Guid.Value);
61
+
62
+ if (!string.IsNullOrWhiteSpace(Name))
63
+ query = query.Where(x => x.Name.Contains(Name));
64
+
65
+ return query;
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## 3. Creare Il Contesto SQLite
71
+
72
+ Il contesto deve implementare `IChillContext` e restituire il prefisso namespace usato dai tipi model e query.
73
+
74
+ ```csharp
75
+ using Microsoft.EntityFrameworkCore;
76
+ using MyBlogApp.Model;
77
+
78
+ namespace MyBlogApp;
79
+
80
+ public class BloggingContext : DbContext, IChillContext
81
+ {
82
+ public DbSet<Blog> Blogs => Set<Blog>();
83
+
84
+ public BloggingContext(DbContextOptions<BloggingContext> options) : base(options)
85
+ {
86
+ }
87
+
88
+ public string GetChillTypePrefix() => "MyBlogApp";
89
+ }
90
+ ```
91
+
92
+ ## 4. Registrare ChillSharp
93
+
94
+ ```csharp
95
+ using ChillSharp.Api;
96
+ using Microsoft.EntityFrameworkCore;
97
+
98
+ var builder = WebApplication.CreateBuilder(args);
99
+
100
+ builder.Services.AddDbContext<BloggingContext>(options =>
101
+ options.UseSqlite("Data Source=blogging.db"));
102
+
103
+ builder.Services.AddChillApi<BloggingContext>();
104
+
105
+ var app = builder.Build();
106
+
107
+ using (var scope = app.Services.CreateScope())
108
+ {
109
+ var db = scope.ServiceProvider.GetRequiredService<BloggingContext>();
110
+ db.Database.EnsureCreated();
111
+ }
112
+
113
+ app.MapChillApi();
114
+ app.Run();
115
+ ```
116
+
117
+ ## 5. Creare E Leggere Un Blog Con `ChillSharpClient`
118
+
119
+ ```csharp
120
+ using ChillSharp.Client;
121
+ using ChillSharp.Client.Dto;
122
+
123
+ var client = new ChillSharpClient("http://localhost:5000/api/chill");
124
+
125
+ var blog = new ChillDtoEntity
126
+ {
127
+ ChillType = "Model.Blog",
128
+ Guid = Guid.NewGuid()
129
+ };
130
+ blog.Properties["Name"] = "SQLite Notes";
131
+ blog.Properties["Url"] = "https://example.local/sqlite-notes";
132
+
133
+ var created = client.Create(blog);
134
+
135
+ var query = new ChillDtoQuery
136
+ {
137
+ ChillType = "Query.BlogQuery"
138
+ };
139
+ query.Properties["Guid"] = created.Guid;
140
+ query.ResultProperties = ChillDtoProperty.Build("Guid", "Name", "Url");
141
+
142
+ var result = client.Query(query);
143
+ var loadedBlog = result.Results.Single();
144
+ Console.WriteLine($"{loadedBlog.GetString("Name")} -> {loadedBlog.GetString("Url")}");
145
+ ```
146
+
147
+ ## Note
148
+
149
+ - `Model.Blog` e `Query.BlogQuery` sono nomi tipo brevi. ChillSharp li espande usando `GetChillTypePrefix()`.
150
+ - Con attributi senza parametri, i metadati schema fanno fallback ai nomi CLR di tipo e proprieta.
151
+
152
+ Esempio successivo: [Aggiungere label di schema e leggerle tramite ChillSharp](02-blog-schema-labels.md)
@@ -0,0 +1,139 @@
1
+ # HOW-TO: Aggiungere Label Di Schema Al Blog E Leggerle
2
+
3
+ Versione originale in inglese: [English](../../HowTo/02-blog-schema-labels.md)
4
+
5
+ Questo esempio aggiorna il modello `Blog` precedente aggiungendo testi di schema a `ChillEntity` e `ChillProperty`, poi mostra come leggere quelle label.
6
+
7
+ ## Obiettivo
8
+
9
+ Decorare il modello con metadati di schema e recuperarli tramite i servizi schema di ChillSharp.
10
+
11
+ ## 1. Aggiungere Label A Entita E Proprieta
12
+
13
+ ```csharp
14
+ using ChillSharp.Annotations;
15
+ using ChillSharp.EF;
16
+ using System.ComponentModel.DataAnnotations;
17
+
18
+ namespace MyBlogApp.Model;
19
+
20
+ [ChillEntity(
21
+ UniquePropertyKeyString: "4E16F6C0-6B95-4D67-98BC-9F4D0D63EAF1",
22
+ PrimaryLanguageLabel: "Blog",
23
+ SecondaryLanguageLabel: "Blog")]
24
+ public class Blog : ChillEntity
25
+ {
26
+ [Key]
27
+ public override Guid Guid { get; set; }
28
+
29
+ [ChillProperty(
30
+ UniquePropertyKeyString: "50B1BB6C-D794-41E4-A85C-D4F9D7A6FA7E",
31
+ PrimaryLanguageLabel: "Blog name",
32
+ SecondaryLanguageLabel: "Nome blog")]
33
+ public string Name { get; set; } = string.Empty;
34
+
35
+ [ChillProperty(
36
+ UniquePropertyKeyString: "A18E7754-D8F7-45FE-B8A8-EA762A4EC9E6",
37
+ PrimaryLanguageLabel: "Blog url",
38
+ SecondaryLanguageLabel: "Url blog")]
39
+ public string? Url { get; set; }
40
+
41
+ public override string GetLabel(IChillContext context) => Name;
42
+ }
43
+ ```
44
+
45
+ ## 2. Abilitare La Persistenza Dello Schema
46
+
47
+ Per esporre metadati schema tramite `get-schema`, il contesto EF Core deve anche implementare `IChillSchemaDbContext`, aggiungere il modello schema e registrare `AddChillSchema<TContext>()`.
48
+
49
+ ```csharp
50
+ using ChillSharp.Schema;
51
+ using ChillSharp.Schema.Model;
52
+ using Microsoft.EntityFrameworkCore;
53
+ using MyBlogApp.Model;
54
+
55
+ namespace MyBlogApp;
56
+
57
+ public class BloggingContext : DbContext, IChillContext, IChillSchemaDbContext
58
+ {
59
+ public DbSet<Blog> Blogs => Set<Blog>();
60
+ public DbSet<ChillSchemaEntry> SchemaEntries => Set<ChillSchemaEntry>();
61
+
62
+ public BloggingContext(DbContextOptions<BloggingContext> options) : base(options)
63
+ {
64
+ }
65
+
66
+ public string GetChillTypePrefix() => "MyBlogApp";
67
+
68
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
69
+ {
70
+ base.OnModelCreating(modelBuilder);
71
+ modelBuilder.AddChillSchemaModel();
72
+ }
73
+ }
74
+ ```
75
+
76
+ Registra il servizio schema insieme all'API:
77
+
78
+ ```csharp
79
+ using ChillSharp.Api;
80
+ using ChillSharp.Schema;
81
+ using Microsoft.EntityFrameworkCore;
82
+
83
+ var builder = WebApplication.CreateBuilder(args);
84
+
85
+ builder.Services.AddDbContext<BloggingContext>(options =>
86
+ options.UseSqlite("Data Source=blogging.db"));
87
+
88
+ builder.Services.AddChillApi<BloggingContext>();
89
+ builder.Services.AddChillSchema<BloggingContext>();
90
+ ```
91
+
92
+ ## 3. Leggere I Metadati Di Schema Da Un Client
93
+
94
+ `ChillSharpClient.GetSchema(...)` restituisce metadati proprieta generati dal modello decorato.
95
+
96
+ ```csharp
97
+ using ChillSharp.Client;
98
+
99
+ var client = new ChillSharpClient("http://localhost:5000/api/chill");
100
+ var schema = client.GetSchema("Model.Blog", "default");
101
+
102
+ var nameProperty = schema?.Properties.Single(x => x.Name == "Name");
103
+ var urlProperty = schema?.Properties.Single(x => x.Name == "Url");
104
+
105
+ Console.WriteLine(nameProperty?.DisplayName); // Blog name
106
+ Console.WriteLine(urlProperty?.DisplayName); // Blog url
107
+ ```
108
+
109
+ ## 4. Leggere Il Nome Visualizzato Dell'Entita Sul Server
110
+
111
+ La `ChillSharp.Dto.ChillDtoSchema` lato server contiene anche il `DisplayName` dell'entita, popolato da `ChillEntityAttribute.PrimaryLanguageLabel`.
112
+
113
+ ```csharp
114
+ using ChillSharp;
115
+
116
+ public class SchemaDebugService
117
+ {
118
+ private readonly IChillDtoEngine _dtoEngine;
119
+
120
+ public SchemaDebugService(IChillDtoEngine dtoEngine)
121
+ {
122
+ _dtoEngine = dtoEngine;
123
+ }
124
+
125
+ public string? GetBlogSchemaDisplayName()
126
+ {
127
+ var schema = _dtoEngine.GetSchema("Model.Blog", "default");
128
+ return schema?.DisplayName;
129
+ }
130
+ }
131
+ ```
132
+
133
+ ## Note
134
+
135
+ - `DisplayName` della proprieta viene da `ChillPropertyAttribute.PrimaryLanguageLabel`.
136
+ - `DisplayName` dell'entita viene da `ChillEntityAttribute.PrimaryLanguageLabel`.
137
+ - Se poi chiami `SetSchema(...)`, i valori schema persistiti possono sovrascrivere i default generati per un dato `ChillType` e `ChillViewCode`.
138
+
139
+ Esempio successivo: [Usare l'autenticazione con ChillSharp](03-authentication.md)
@@ -0,0 +1,221 @@
1
+ # HOW-TO: Usare L'Autenticazione Con ChillSharp
2
+
3
+ Versione originale in inglese: [English](../../HowTo/03-authentication.md)
4
+
5
+ Questo esempio mostra la configurazione di autenticazione minima ma utile per una API ChillSharp: proteggere l'API, abilitare il modulo auth, registrare un account, fare login e lasciare che `ChillSharpClient` riusi e rinnovi i token automaticamente.
6
+
7
+ ## Obiettivo
8
+
9
+ Esporre una API ChillSharp protetta basata su ASP.NET Core Identity e autenticarsi con `ChillSharpClient`.
10
+
11
+ ## 1. Usare Un Contesto Che Supporti Identity E ChillSharp Auth
12
+
13
+ Il contesto deve supportare il normale modello ChillSharp e le tabelle auth.
14
+
15
+ ```csharp
16
+ using ChillSharp;
17
+ using ChillSharp.Auth;
18
+ using Microsoft.AspNetCore.Identity;
19
+ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
20
+ using Microsoft.EntityFrameworkCore;
21
+
22
+ namespace MyBlogApp;
23
+
24
+ public class BloggingContext : IdentityDbContext<IdentityUser>, IChillContext, IChillAuthDbContext
25
+ {
26
+ public BloggingContext(DbContextOptions<BloggingContext> options) : base(options)
27
+ {
28
+ }
29
+
30
+ public string GetChillTypePrefix() => "MyBlogApp";
31
+
32
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
33
+ {
34
+ base.OnModelCreating(modelBuilder);
35
+ modelBuilder.AddChillAuthModel();
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## 2. Registrare Identity, Authentication E I Servizi Auth ChillSharp
41
+
42
+ Proteggi la normale ChillSharp API e aggiungi sopra gli endpoint auth.
43
+
44
+ ```csharp
45
+ using ChillSharp.Api;
46
+ using ChillSharp.Auth;
47
+ using ChillSharp.Auth.Api;
48
+ using Microsoft.AspNetCore.Identity;
49
+ using Microsoft.EntityFrameworkCore;
50
+
51
+ var builder = WebApplication.CreateBuilder(args);
52
+
53
+ builder.Services.AddDbContext<BloggingContext>(options =>
54
+ options.UseSqlite("Data Source=blogging-auth.db"));
55
+
56
+ builder.Services.AddIdentityCore<IdentityUser>()
57
+ .AddEntityFrameworkStores<BloggingContext>()
58
+ .AddSignInManager()
59
+ .AddDefaultTokenProviders();
60
+
61
+ builder.Services.AddAuthentication(ChillAuthIdentityDefaults.AuthenticationScheme)
62
+ .AddChillAuthBearer();
63
+
64
+ builder.Services.AddAuthorization();
65
+
66
+ builder.Services.AddChillApi<BloggingContext>(options =>
67
+ {
68
+ options.ProtectedApi = true;
69
+ });
70
+
71
+ builder.Services.AddChillAuthIdentityApi<BloggingContext, IdentityUser>(options =>
72
+ {
73
+ options.ReturnPasswordResetTokensInResponse = true;
74
+ options.InitializeRootUserOnStartup = true;
75
+ options.CreateChillAuthUserForRoot = true;
76
+ options.RootUserName = "root";
77
+ options.RootPassword = "Pass123$";
78
+ options.RootEmail = "root@example.com";
79
+ options.RootDisplayName = "Root Administrator";
80
+ });
81
+ ```
82
+
83
+ Quando `CreateChillAuthUserForRoot = true`, all'avvio viene creato anche il relativo `AuthUser` ChillSharp e `CanManagePermissions = true` viene impostato per quell'utente root.
84
+
85
+ Puoi fornire gli stessi valori di bootstrap anche tramite variabili d'ambiente invece di hardcodarli:
86
+
87
+ ```text
88
+ CHILLSHARP_AUTH_ROOT_USERNAME=root
89
+ CHILLSHARP_AUTH_ROOT_PASSWORD=Pass123$
90
+ CHILLSHARP_AUTH_ROOT_EMAIL=root@example.com
91
+ CHILLSHARP_AUTH_ROOT_DISPLAY_NAME=Root Administrator
92
+ ```
93
+
94
+ ## 3. Abilitare Il Middleware E Mappare L'API
95
+
96
+ `MapChillApi()` espone sia gli endpoint normali ChillSharp sia quelli auth una volta registrati i servizi auth.
97
+
98
+ ```csharp
99
+ var app = builder.Build();
100
+
101
+ app.UseAuthentication();
102
+ app.UseAuthorization();
103
+
104
+ using (var scope = app.Services.CreateScope())
105
+ {
106
+ var db = scope.ServiceProvider.GetRequiredService<BloggingContext>();
107
+ db.Database.EnsureCreated();
108
+ }
109
+
110
+ app.MapChillApi();
111
+ app.Run();
112
+ ```
113
+
114
+ ## 4. Usare L'Utente Root Per Gestire I Permessi
115
+
116
+ L'inizializzatore root-user e la via piu semplice di bootstrap per un sistema protetto nuovo, perche l'utente auth ChillSharp collegato viene creato con la gestione permessi abilitata.
117
+
118
+ ```csharp
119
+ var rootClient = new ChillSharpClient("http://localhost:5000/api/chill");
120
+
121
+ var rootLogin = rootClient.LoginAuthAccount(new LoginAuthIdentityRequest
122
+ {
123
+ UserNameOrEmail = "root",
124
+ Password = "Pass123$"
125
+ });
126
+
127
+ var authUsers = rootClient.GetAuthUsers();
128
+ Console.WriteLine(authUsers.Count);
129
+ ```
130
+
131
+ Quel login puo chiamare endpoint di gestione auth come utenti, ruoli e regole di permesso perche l'`AuthUser` root generato ha `CanManagePermissions = true`.
132
+
133
+ ## 5. Registrare Il Primo Account Normale
134
+
135
+ Crea il client con il normale Chill base URL. Le chiamate auth passano automaticamente da `/api/chill` a `/api/chill-auth`.
136
+
137
+ ```csharp
138
+ using ChillSharp.Auth.Contracts;
139
+ using ChillSharp.Client;
140
+
141
+ var client = new ChillSharpClient("http://localhost:5000/api/chill");
142
+
143
+ var registerResponse = client.RegisterAuthAccount(new RegisterAuthIdentityRequest
144
+ {
145
+ UserName = "admin",
146
+ Email = "admin@example.com",
147
+ Password = "Pass123$",
148
+ DisplayName = "Administrator",
149
+ DisplayCultureName = "it-IT",
150
+ CreateChillAuthUser = true
151
+ });
152
+ ```
153
+
154
+ Dopo una registrazione riuscita, il client salva internamente access token e refresh token restituiti.
155
+
156
+ Se `DisplayCultureName` viene fornito e `CreateChillAuthUser = true`, il relativo `AuthUser` viene inizializzato con valori derivati dalla cultura per:
157
+
158
+ - `DisplayTimeZone`
159
+ - `DisplayDateFormat`
160
+ - `DisplayNumberFormat`
161
+
162
+ Per esempio, `it-IT` tipicamente produce preset come:
163
+
164
+ - `DisplayTimeZone = "W. Europe Standard Time"`
165
+ - `DisplayDateFormat = "DD/MM/YYYY"`
166
+ - `DisplayNumberFormat = "1.000,00"`
167
+
168
+ Questi sono preset server-side e possono essere modificati in seguito tramite la gestione utenti auth.
169
+
170
+ ## 6. Fare Login Esplicito
171
+
172
+ Se l'account esiste gia, fai login con lo stesso `ChillSharpClient`.
173
+
174
+ ```csharp
175
+ var loginResponse = client.LoginAuthAccount(new LoginAuthIdentityRequest
176
+ {
177
+ UserNameOrEmail = "admin",
178
+ Password = "Pass123$"
179
+ });
180
+ ```
181
+
182
+ ## 7. Chiamare Endpoint Protetti
183
+
184
+ Una volta autenticato, lo stesso client puo chiamare gli endpoint ChillSharp protetti.
185
+
186
+ ```csharp
187
+ using ChillSharp.Client.Dto;
188
+
189
+ var query = new ChillDtoQuery
190
+ {
191
+ ChillType = "Query.BlogQuery"
192
+ };
193
+ query.ResultProperties = ChillDtoProperty.Build("Guid", "Name");
194
+
195
+ var result = client.Query(query);
196
+ Console.WriteLine(result.Results.Count);
197
+ ```
198
+
199
+ ## 8. Lasciare Che Il Client Rinnovi I Token Automaticamente
200
+
201
+ Non devi allegare manualmente il bearer token a ogni richiesta. Se il client ha gia un refresh token, le chiamate autenticate rinnovano l'access token quando serve.
202
+
203
+ ```csharp
204
+ var roles = client.GetAuthRoles();
205
+ ```
206
+
207
+ Puoi anche fare refresh esplicito:
208
+
209
+ ```csharp
210
+ var refreshed = client.RefreshAuthAccount();
211
+ ```
212
+
213
+ ## Note
214
+
215
+ - Usa `options.ProtectedApi = true` su `AddChillApi<TContext>(...)` se gli endpoint ChillSharp devono richiedere autenticazione.
216
+ - L'utente root creato da `AddChillAuthIdentityApi(...)` e il percorso bootstrap amministrativo. Quando `CreateChillAuthUserForRoot = true`, il relativo `AuthUser` ChillSharp viene creato con `CanManagePermissions = true`.
217
+ - `CreateChillAuthUser = true` crea l'`AuthUser` ChillSharp collegato, ma non concede automaticamente permessi amministrativi.
218
+ - `DisplayCultureName` in registrazione preimposta `DisplayTimeZone`, `DisplayDateFormat` e `DisplayNumberFormat` per il relativo `AuthUser`.
219
+ - In produzione, inizializza il primo amministratore in modo deliberato, ad esempio con root-user initialization o un flusso trusted in fase di installazione.
220
+
221
+ Esempio successivo: [Creare un'immagine Docker e configurarla con variabili d'ambiente](05-docker-env-variables.md)
@@ -0,0 +1,193 @@
1
+ # HOW-TO: Gestire Una Relazione Blog-Posts Uno-a-Molti
2
+
3
+ Versione originale in inglese: [English](../../HowTo/04-blog-posts-one-to-many.md)
4
+
5
+ Questo esempio estende il modello blog con i post e mostra come caricare un blog insieme ai suoi post in una singola chiamata `ChillSharpClient.Query(...)`.
6
+
7
+ ## Obiettivo
8
+
9
+ Modellare una relazione uno-a-molti `Blog` -> `Posts` e proiettare la collezione annidata dal client ChillSharp.
10
+
11
+ ## 1. Definire Le Entita
12
+
13
+ ```csharp
14
+ using ChillSharp.Annotations;
15
+ using ChillSharp.EF;
16
+ using System.ComponentModel.DataAnnotations;
17
+
18
+ namespace MyBlogApp.Model;
19
+
20
+ [ChillEntity]
21
+ public class Blog : ChillEntity
22
+ {
23
+ [Key]
24
+ public override Guid Guid { get; set; }
25
+
26
+ [ChillProperty]
27
+ public string Name { get; set; } = string.Empty;
28
+
29
+ [ChillProperty]
30
+ public string? Url { get; set; }
31
+
32
+ [ChillProperty]
33
+ public ICollection<Post>? Posts { get; set; }
34
+
35
+ public override string GetLabel(IChillContext context) => Name;
36
+ }
37
+
38
+ [ChillEntity]
39
+ public class Post : ChillEntity
40
+ {
41
+ [Key]
42
+ public override Guid Guid { get; set; }
43
+
44
+ [ChillProperty]
45
+ public Blog? Blog { get; set; }
46
+
47
+ [ChillProperty]
48
+ public DateTime? CreatedAt { get; set; }
49
+
50
+ [ChillProperty]
51
+ public string Title { get; set; } = string.Empty;
52
+
53
+ [ChillProperty]
54
+ public string Content { get; set; } = string.Empty;
55
+
56
+ public override void OnCreate(IChillContext context)
57
+ {
58
+ base.OnCreate(context);
59
+ CreatedAt = DateTime.UtcNow;
60
+ }
61
+
62
+ public override string GetLabel(IChillContext context) => Title;
63
+ }
64
+ ```
65
+
66
+ ## 2. Aggiungere Entrambi I Set Al Contesto
67
+
68
+ ```csharp
69
+ using Microsoft.EntityFrameworkCore;
70
+ using MyBlogApp.Model;
71
+
72
+ namespace MyBlogApp;
73
+
74
+ public class BloggingContext : DbContext, IChillContext
75
+ {
76
+ public DbSet<Blog> Blogs => Set<Blog>();
77
+ public DbSet<Post> Posts => Set<Post>();
78
+
79
+ public BloggingContext(DbContextOptions<BloggingContext> options) : base(options)
80
+ {
81
+ }
82
+
83
+ public string GetChillTypePrefix() => "MyBlogApp";
84
+ }
85
+ ```
86
+
87
+ ## 3. Definire Una Query Per I Blog
88
+
89
+ ```csharp
90
+ using ChillSharp.Annotations;
91
+ using ChillSharp.EF;
92
+
93
+ namespace MyBlogApp.Query;
94
+
95
+ [ChillEntity]
96
+ public class BlogQuery : ChillQuery
97
+ {
98
+ [ChillProperty]
99
+ public string? Name { get; set; }
100
+
101
+ public override IQueryable<IChillEntity> OnQuery(IChillContext context)
102
+ {
103
+ var db = (BloggingContext)context;
104
+ var query = db.Blogs.AsQueryable();
105
+
106
+ if (Guid.HasValue)
107
+ query = query.Where(x => x.Guid == Guid.Value);
108
+
109
+ if (!string.IsNullOrWhiteSpace(Name))
110
+ query = query.Where(x => x.Name.Contains(Name));
111
+
112
+ return query;
113
+ }
114
+ }
115
+ ```
116
+
117
+ ## 4. Creare Un Blog E Due Post
118
+
119
+ La relazione viene creata inviando il DTO padre `Blog` come proprieta `Blog` di ogni `Post`.
120
+
121
+ ```csharp
122
+ using ChillSharp.Client;
123
+ using ChillSharp.Client.Dto;
124
+
125
+ var client = new ChillSharpClient("http://localhost:5000/api/chill");
126
+
127
+ var blog = new ChillDtoEntity
128
+ {
129
+ ChillType = "Model.Blog",
130
+ Guid = Guid.NewGuid()
131
+ };
132
+ blog.Properties["Name"] = "ChillSharp Blog";
133
+ blog.Properties["Url"] = "https://example.local/chillsharp-blog";
134
+
135
+ var createdBlog = client.Create(blog);
136
+
137
+ var firstPost = new ChillDtoEntity
138
+ {
139
+ ChillType = "Model.Post",
140
+ Guid = Guid.NewGuid()
141
+ };
142
+ firstPost.Properties["Title"] = "First post";
143
+ firstPost.Properties["Content"] = "Hello from ChillSharp";
144
+ firstPost.Properties["Blog"] = createdBlog.Mock();
145
+ client.Create(firstPost);
146
+
147
+ var secondPost = new ChillDtoEntity
148
+ {
149
+ ChillType = "Model.Post",
150
+ Guid = Guid.NewGuid()
151
+ };
152
+ secondPost.Properties["Title"] = "Second post";
153
+ secondPost.Properties["Content"] = "Nested queries are handy";
154
+ secondPost.Properties["Blog"] = createdBlog.Mock();
155
+ client.Create(secondPost);
156
+ ```
157
+
158
+ ## 5. Caricare Un Blog Con I Suoi Post In Una Chiamata
159
+
160
+ Questa e la parte piu importante per una relazione uno-a-molti: la proiezione annidata viene descritta tramite `ChillDtoProperty.With(...)`, e la collezione restituita viene letta con `GetCollection(...)`.
161
+
162
+ ```csharp
163
+ using ChillSharp.Client.Dto;
164
+
165
+ var query = new ChillDtoQuery
166
+ {
167
+ ChillType = "Query.BlogQuery"
168
+ };
169
+ query.Properties["Guid"] = createdBlog.Guid;
170
+ query.ResultProperties = ChillDtoProperty.Build(
171
+ "Guid",
172
+ "Name",
173
+ "Url",
174
+ ChillDtoProperty.With("Posts", "Guid", "Title", "CreatedAt"));
175
+
176
+ var queryResult = client.Query(query);
177
+ var loadedBlog = queryResult.Results.Single();
178
+
179
+ Console.WriteLine(loadedBlog.GetString("Name"));
180
+
181
+ foreach (var post in loadedBlog.GetCollection("Posts"))
182
+ {
183
+ Console.WriteLine(post.GetString("Title"));
184
+ }
185
+ ```
186
+
187
+ ## Cosa Ti Da Questo
188
+
189
+ - una chiamata HTTP per caricare l'entita padre e la collezione figlia
190
+ - un builder di proiezione fortemente tipizzato lato client
191
+ - gestione della relazione tramite DTO senza scrivere un controller dedicato per `Blog` o `Post`
192
+
193
+ Prossimo: [Torna all'indice della documentazione](../README.md)