@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
package/doc/ChillSharpClient.md
DELETED
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
# ChillSharp.Client
|
|
2
|
-
|
|
3
|
-
Versione italiana: [Italiano](it/ChillSharpClient.md)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`ChillSharp.Client` is the .NET client library for calling a ChillSharp host from console apps, workers, tests, desktop apps, or other .NET services.
|
|
7
|
-
|
|
8
|
-
Use it when the consumer is .NET. For browser frameworks or Python automation, use the generic clients under `extra-libs/` or generate a host-specific client from OpenAPI.
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
Reference the `ChillSharp.Client` project or package from the consuming .NET application.
|
|
13
|
-
|
|
14
|
-
```xml
|
|
15
|
-
<ProjectReference Include="..\ChillSharp.Client\ChillSharp.Client.csproj" />
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Then import the client namespaces:
|
|
19
|
-
|
|
20
|
-
```csharp
|
|
21
|
-
using ChillSharp.Client;
|
|
22
|
-
using ChillSharp.Client.Dto;
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Auth account methods use request and response contracts from `ChillSharp.Auth.Contracts`:
|
|
26
|
-
|
|
27
|
-
```csharp
|
|
28
|
-
using ChillSharp.Auth.Contracts;
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
I18n methods use contracts from `ChillSharp.I18n.Contracts`:
|
|
32
|
-
|
|
33
|
-
```csharp
|
|
34
|
-
using ChillSharp.I18n.Contracts;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Create A Client
|
|
38
|
-
|
|
39
|
-
The normal base URL is the core ChillSharp endpoint:
|
|
40
|
-
|
|
41
|
-
```csharp
|
|
42
|
-
var client = new ChillSharpClient("http://localhost:5000/api/chill");
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
You can also pass the host root. The client appends the default `api/chill` path:
|
|
46
|
-
|
|
47
|
-
```csharp
|
|
48
|
-
var client = new ChillSharpClient("http://localhost:5000");
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
For a custom API base path:
|
|
52
|
-
|
|
53
|
-
```csharp
|
|
54
|
-
var client = new ChillSharpClient(
|
|
55
|
-
"http://localhost:5000",
|
|
56
|
-
new ChillSharpClientOptions { ApiBasePath = "backend" });
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
This resolves the core API as:
|
|
60
|
-
|
|
61
|
-
```text
|
|
62
|
-
http://localhost:5000/backend/chill
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Culture
|
|
66
|
-
|
|
67
|
-
Pass a default culture when reading schemas or i18n text:
|
|
68
|
-
|
|
69
|
-
```csharp
|
|
70
|
-
var client = new ChillSharpClient(
|
|
71
|
-
"http://localhost:5000/api/chill",
|
|
72
|
-
CultureName: "it-IT");
|
|
73
|
-
|
|
74
|
-
var schema = client.GetSchema("Model.Blog", "default");
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
You can still override culture per schema call:
|
|
78
|
-
|
|
79
|
-
```csharp
|
|
80
|
-
var englishSchema = client.GetSchema("Model.Blog", "default", "en-GB");
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Authentication
|
|
84
|
-
|
|
85
|
-
If the API is protected, authenticate with one of these patterns.
|
|
86
|
-
|
|
87
|
-
Use an existing bearer token:
|
|
88
|
-
|
|
89
|
-
```csharp
|
|
90
|
-
var client = new ChillSharpClient(
|
|
91
|
-
"http://localhost:5000/api/chill",
|
|
92
|
-
AuthToken: accessToken);
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Use credentials and let the client log in on demand:
|
|
96
|
-
|
|
97
|
-
```csharp
|
|
98
|
-
var client = new ChillSharpClient(
|
|
99
|
-
"http://localhost:5000/api/chill",
|
|
100
|
-
UserName: "admin",
|
|
101
|
-
Password: "Pass123$");
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Register or log in through the auth account endpoints:
|
|
105
|
-
|
|
106
|
-
```csharp
|
|
107
|
-
var client = new ChillSharpClient("http://localhost:5000/api/chill");
|
|
108
|
-
|
|
109
|
-
var token = client.LoginAuthAccount(new LoginAuthIdentityRequest
|
|
110
|
-
{
|
|
111
|
-
UserNameOrEmail = "admin",
|
|
112
|
-
Password = "Pass123$"
|
|
113
|
-
});
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
The client stores the returned access token and refresh token. Later authenticated calls reuse the access token and refresh it automatically when possible.
|
|
117
|
-
|
|
118
|
-
To force refresh:
|
|
119
|
-
|
|
120
|
-
```csharp
|
|
121
|
-
client.RefreshAuthAccount();
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
To revoke the current session:
|
|
125
|
-
|
|
126
|
-
```csharp
|
|
127
|
-
client.LogoutAuthAccount();
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## Core Entity Operations
|
|
131
|
-
|
|
132
|
-
ChillSharp entity calls use `ChillDtoEntity`.
|
|
133
|
-
|
|
134
|
-
Create:
|
|
135
|
-
|
|
136
|
-
```csharp
|
|
137
|
-
var blog = new ChillDtoEntity
|
|
138
|
-
{
|
|
139
|
-
ChillType = "Model.Blog"
|
|
140
|
-
};
|
|
141
|
-
blog.Properties["Title"] = "My first blog";
|
|
142
|
-
blog.Properties["Description"] = "Created through ChillSharp.Client";
|
|
143
|
-
|
|
144
|
-
var created = client.Create(blog);
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
Find:
|
|
148
|
-
|
|
149
|
-
```csharp
|
|
150
|
-
var found = client.Find(new ChillDtoEntity
|
|
151
|
-
{
|
|
152
|
-
ChillType = "Model.Blog",
|
|
153
|
-
Guid = created.Guid
|
|
154
|
-
});
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Update:
|
|
158
|
-
|
|
159
|
-
```csharp
|
|
160
|
-
created.Properties["Title"] = "Updated blog";
|
|
161
|
-
var updated = client.Update(created);
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
Delete:
|
|
165
|
-
|
|
166
|
-
```csharp
|
|
167
|
-
client.Delete(updated);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Validate without saving:
|
|
171
|
-
|
|
172
|
-
```csharp
|
|
173
|
-
var errors = client.Validate(blog);
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Query And Lookup
|
|
177
|
-
|
|
178
|
-
Use `Query` when the host exposes an entity query type:
|
|
179
|
-
|
|
180
|
-
```csharp
|
|
181
|
-
var query = new ChillDtoQuery
|
|
182
|
-
{
|
|
183
|
-
ChillType = "Query.BlogQuery",
|
|
184
|
-
Pagination = new ChillPagination
|
|
185
|
-
{
|
|
186
|
-
Page = 1,
|
|
187
|
-
PageResults = 20
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
query.Properties["FullTextSearch"] = "release notes";
|
|
192
|
-
|
|
193
|
-
var result = client.Query(query);
|
|
194
|
-
foreach (var item in result.Results)
|
|
195
|
-
{
|
|
196
|
-
Console.WriteLine(item.Label);
|
|
197
|
-
}
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
Use `Lookup` for generic full-text entity lookup:
|
|
201
|
-
|
|
202
|
-
```csharp
|
|
203
|
-
var lookup = client.Lookup(new ChillDtoQuery
|
|
204
|
-
{
|
|
205
|
-
ChillType = "Model.Blog",
|
|
206
|
-
Properties =
|
|
207
|
-
{
|
|
208
|
-
["FullTextSearch"] = "release"
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
`FullTextSearch` searches against ChillSharp `FullTextContent`. Unquoted text without advanced selectors is normalized, split on whitespace, and AND-matched, so every token must be present. Brackets plus standalone `and`/`or` operators outside quotes enable grouped boolean search. Search the literal words `and` or `or` by wrapping them in matching quotes. Matching single or double quotes search one normalized phrase with word boundaries:
|
|
214
|
-
|
|
215
|
-
| Search text | Meaning |
|
|
216
|
-
| --- | --- |
|
|
217
|
-
| `release notes` | Match records containing both `release` and `notes`. |
|
|
218
|
-
| `[release and notes] or memo` | Match records containing both `release` and `notes`, or records containing `memo`. |
|
|
219
|
-
| `"and"` | Search the literal keyword `and` instead of the boolean operator. |
|
|
220
|
-
| `"la nazione"` | Match the exact phrase as whole words, for example `bla bla la nazione bla bla`, but not `bla bla della nazione bla bla`. |
|
|
221
|
-
| `"*la nazione"` or `"%la nazione"` | Relax the left boundary, so `della nazione` can match. |
|
|
222
|
-
| `"la nazione*"` or `"la nazione%"` | Relax the right boundary, so a suffix can match. |
|
|
223
|
-
| `"la*nazione"` or `"la%nazione"` | Treat the middle wildcard as a token separator and apply normal AND token matching. |
|
|
224
|
-
|
|
225
|
-
## Batch Operations
|
|
226
|
-
|
|
227
|
-
Use `Chunk` to send several operations in one HTTP call.
|
|
228
|
-
|
|
229
|
-
```csharp
|
|
230
|
-
var operations = new List<ChillOperation>
|
|
231
|
-
{
|
|
232
|
-
new() { Index = 0, Verb = ChillOperationVerb.TRANSACTION },
|
|
233
|
-
new()
|
|
234
|
-
{
|
|
235
|
-
Index = 1,
|
|
236
|
-
Verb = ChillOperationVerb.CREATE,
|
|
237
|
-
Entity = new ChillDtoEntity
|
|
238
|
-
{
|
|
239
|
-
ChillType = "Model.Blog",
|
|
240
|
-
Properties =
|
|
241
|
-
{
|
|
242
|
-
["Title"] = "Batch blog"
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
new() { Index = 2, Verb = ChillOperationVerb.COMMIT }
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
var processed = client.Chunk(operations);
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
Use a transaction/commit wrapper when the write operations must be committed together.
|
|
253
|
-
|
|
254
|
-
## Schema And Menu
|
|
255
|
-
|
|
256
|
-
Read schema metadata:
|
|
257
|
-
|
|
258
|
-
```csharp
|
|
259
|
-
var schema = client.GetSchema("Model.Blog", "default");
|
|
260
|
-
var schemaList = client.GetSchemaList();
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
Manage entity options:
|
|
264
|
-
|
|
265
|
-
```csharp
|
|
266
|
-
var options = client.GetEntityOptions("Model.Blog");
|
|
267
|
-
options.HandleAttachments = true;
|
|
268
|
-
client.SetEntityOptions(options);
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
Read menu nodes:
|
|
272
|
-
|
|
273
|
-
```csharp
|
|
274
|
-
var rootItems = client.GetMenu();
|
|
275
|
-
var children = client.GetMenu(rootItems[0].Guid);
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
Create or update a menu item:
|
|
279
|
-
|
|
280
|
-
```csharp
|
|
281
|
-
var item = client.SetMenu(new ChillDtoMenuItem
|
|
282
|
-
{
|
|
283
|
-
PositionNo = 10,
|
|
284
|
-
Title = "Blogs",
|
|
285
|
-
ComponentName = "CRUD",
|
|
286
|
-
MenuHierarchy = "CONTENT.BLOGS"
|
|
287
|
-
});
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
Delete a menu item and its descendants:
|
|
291
|
-
|
|
292
|
-
```csharp
|
|
293
|
-
client.DeleteMenu(item.Guid);
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
Schema write operations require schema-management access on protected hosts.
|
|
297
|
-
|
|
298
|
-
## Auth Management
|
|
299
|
-
|
|
300
|
-
Auth-management helpers are available when the host registers `ChillSharp.Auth`.
|
|
301
|
-
|
|
302
|
-
```csharp
|
|
303
|
-
var users = client.GetAuthUsers();
|
|
304
|
-
var roles = client.GetAuthRoles();
|
|
305
|
-
var permissions = client.GetAuthPermissions();
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
Create a managed auth user:
|
|
309
|
-
|
|
310
|
-
```csharp
|
|
311
|
-
var user = client.CreateAuthUser(new CreateAuthUserRequest
|
|
312
|
-
{
|
|
313
|
-
ExternalId = "external-user-id",
|
|
314
|
-
UserName = "editor",
|
|
315
|
-
DisplayName = "Editor",
|
|
316
|
-
IsActive = true,
|
|
317
|
-
MenuHierarchy = "CONTENT"
|
|
318
|
-
});
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
Create a role and assign it:
|
|
322
|
-
|
|
323
|
-
```csharp
|
|
324
|
-
var role = client.CreateAuthRole(new CreateAuthRoleRequest
|
|
325
|
-
{
|
|
326
|
-
Name = "Editors",
|
|
327
|
-
IsActive = true,
|
|
328
|
-
MenuHierarchy = "CONTENT"
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
client.AssignAuthRole(user.Guid, role.Guid);
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
For richer administration screens, use the aggregate helpers:
|
|
335
|
-
|
|
336
|
-
```csharp
|
|
337
|
-
var managedUser = client.GetAuthManagedUser(user.Guid);
|
|
338
|
-
var roleList = client.GetAuthRoleList();
|
|
339
|
-
var moduleList = client.GetAuthModuleList();
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
## I18n
|
|
343
|
-
|
|
344
|
-
Read a localized text:
|
|
345
|
-
|
|
346
|
-
```csharp
|
|
347
|
-
var text = client.GetText(new GetTextRequest
|
|
348
|
-
{
|
|
349
|
-
LabelGuid = labelGuid,
|
|
350
|
-
CultureName = "it-IT",
|
|
351
|
-
PrimaryDefaultText = "Hello"
|
|
352
|
-
});
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
Read several texts:
|
|
356
|
-
|
|
357
|
-
```csharp
|
|
358
|
-
var texts = client.GetTexts(requests);
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
Create or update a text:
|
|
362
|
-
|
|
363
|
-
```csharp
|
|
364
|
-
client.SetText(new SetTextRequest
|
|
365
|
-
{
|
|
366
|
-
LabelGuid = labelGuid,
|
|
367
|
-
CultureName = "it-IT",
|
|
368
|
-
Value = "Ciao"
|
|
369
|
-
});
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
## Attachments
|
|
373
|
-
|
|
374
|
-
Upload a file and attach it to an entity:
|
|
375
|
-
|
|
376
|
-
```csharp
|
|
377
|
-
var files = client.UploadAttachment(
|
|
378
|
-
created,
|
|
379
|
-
@"C:\temp\contract.pdf",
|
|
380
|
-
title: "Contract");
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
List attachments for an entity:
|
|
384
|
-
|
|
385
|
-
```csharp
|
|
386
|
-
var attachments = client.GetAttachments(created);
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
Download an attachment:
|
|
390
|
-
|
|
391
|
-
```csharp
|
|
392
|
-
var bytes = client.DownloadAttachment(attachments[0].Guid);
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
Download directly to a file:
|
|
396
|
-
|
|
397
|
-
```csharp
|
|
398
|
-
client.DownloadAttachmentToFile(
|
|
399
|
-
attachments[0].Guid,
|
|
400
|
-
@"C:\temp\downloaded-contract.pdf");
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
Attachment upload and private download require the attachment module and appropriate auth configuration.
|
|
404
|
-
|
|
405
|
-
## Custom HttpClient
|
|
406
|
-
|
|
407
|
-
Use a custom factory when tests or host integration need special headers, handlers, or certificates:
|
|
408
|
-
|
|
409
|
-
```csharp
|
|
410
|
-
var client = new ChillSharpClient(
|
|
411
|
-
"http://localhost:5000/api/chill",
|
|
412
|
-
() =>
|
|
413
|
-
{
|
|
414
|
-
var httpClient = new HttpClient();
|
|
415
|
-
httpClient.DefaultRequestHeaders.Add("X-Test-User", "integration-user");
|
|
416
|
-
return httpClient;
|
|
417
|
-
});
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
The factory is invoked for each request. Dispose any external resources according to your application’s `HttpClient` strategy.
|
|
421
|
-
|
|
422
|
-
## Errors
|
|
423
|
-
|
|
424
|
-
Server errors and transport failures are wrapped in `ChillClientException`.
|
|
425
|
-
|
|
426
|
-
```csharp
|
|
427
|
-
try
|
|
428
|
-
{
|
|
429
|
-
client.Create(blog);
|
|
430
|
-
}
|
|
431
|
-
catch (ChillClientException ex)
|
|
432
|
-
{
|
|
433
|
-
Console.WriteLine(ex.Message);
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
For HTTP errors, the exception message includes the status code and response body when available.
|
|
438
|
-
|
|
439
|
-
## Endpoint Resolution
|
|
440
|
-
|
|
441
|
-
From a core URL ending in `/chill`, the client resolves module endpoints automatically:
|
|
442
|
-
|
|
443
|
-
| Module | Resolved endpoint |
|
|
444
|
-
| --- | --- |
|
|
445
|
-
| Core | `/api/chill` |
|
|
446
|
-
| Auth | `/api/chill-auth` |
|
|
447
|
-
| Schema | `/api/chill-schema` |
|
|
448
|
-
| I18n | `/api/chill-i18n` |
|
|
449
|
-
| Attachment | `/api/chill-attachment` |
|
|
450
|
-
|
|
451
|
-
For example:
|
|
452
|
-
|
|
453
|
-
```csharp
|
|
454
|
-
var client = new ChillSharpClient("http://localhost:5000/api/chill");
|
|
455
|
-
client.GetMenu(); // calls /api/chill-schema/get-menu
|
|
456
|
-
client.LoginAuthAccount(...); // calls /api/chill-auth/login
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
## Related Documentation
|
|
460
|
-
|
|
461
|
-
- [AuthenticationModel/README.md](./AuthenticationModel/README.md)
|
|
462
|
-
- [MenuGuide/README.md](./MenuGuide/README.md)
|
|
463
|
-
- [AttachmentModel/README.md](./AttachmentModel/README.md)
|
|
464
|
-
- [ClientGeneration/README.md](./ClientGeneration/README.md)
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# Generating Client Libraries
|
|
2
|
-
|
|
3
|
-
Versione italiana: [Italiano](../it/ClientGeneration/README.md)
|
|
4
|
-
|
|
5
|
-
This section explains how to generate non-.NET client libraries for a ChillSharp host.
|
|
6
|
-
|
|
7
|
-
Targets covered here:
|
|
8
|
-
|
|
9
|
-
- TypeScript
|
|
10
|
-
- Python
|
|
11
|
-
|
|
12
|
-
For ready-to-use generic clients already included in this repository, see:
|
|
13
|
-
|
|
14
|
-
- [../../ext/chill-sharp-ts-client/README.md](../../ext/chill-sharp-ts-client/README.md)
|
|
15
|
-
- [../../ext/chill-sharp-react-client/README.md](../../ext/chill-sharp-react-client/README.md)
|
|
16
|
-
- [../../ext/chill-sharp-vue-client/README.md](../../ext/chill-sharp-vue-client/README.md)
|
|
17
|
-
- [../../ext/chill-sharp-ng-client/README.md](../../ext/chill-sharp-ng-client/README.md)
|
|
18
|
-
- [../../ext/chill-sharp-py-client/README.md](../../ext/chill-sharp-py-client/README.md)
|
|
19
|
-
|
|
20
|
-
Those packages are generic wrappers around the standard ChillSharp HTTP API. The rest of this document covers host-specific client generation from OpenAPI.
|
|
21
|
-
|
|
22
|
-
## Important Constraint
|
|
23
|
-
|
|
24
|
-
ChillSharp does not automatically publish an OpenAPI document by itself.
|
|
25
|
-
|
|
26
|
-
Client generation therefore depends on the host application exposing one through normal ASP.NET Core Swagger/OpenAPI tooling.
|
|
27
|
-
|
|
28
|
-
## 1. Expose OpenAPI In The Host
|
|
29
|
-
|
|
30
|
-
Add Swagger generation to the host application:
|
|
31
|
-
|
|
32
|
-
```csharp
|
|
33
|
-
builder.Services.AddEndpointsApiExplorer();
|
|
34
|
-
builder.Services.AddSwaggerGen();
|
|
35
|
-
|
|
36
|
-
var app = builder.Build();
|
|
37
|
-
|
|
38
|
-
app.UseSwagger();
|
|
39
|
-
app.UseSwaggerUI();
|
|
40
|
-
app.MapChillApi();
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
With that in place, a standard Swagger JSON document is typically available at:
|
|
44
|
-
|
|
45
|
-
```text
|
|
46
|
-
/swagger/v1/swagger.json
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Example:
|
|
50
|
-
|
|
51
|
-
```text
|
|
52
|
-
http://localhost:5000/swagger/v1/swagger.json
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## 2. Decide What The Generated Client Should Cover
|
|
56
|
-
|
|
57
|
-
A ChillSharp host may expose several surfaces:
|
|
58
|
-
|
|
59
|
-
- core Chill API
|
|
60
|
-
- schema endpoints
|
|
61
|
-
- auth/account endpoints
|
|
62
|
-
- auth-management endpoints
|
|
63
|
-
- i18n endpoints
|
|
64
|
-
|
|
65
|
-
If all modules are registered in one host and Swagger is enabled globally, the generated OpenAPI document can include all of them.
|
|
66
|
-
|
|
67
|
-
## 3. Generate A TypeScript Client
|
|
68
|
-
|
|
69
|
-
One practical option is `openapi-generator-cli`.
|
|
70
|
-
|
|
71
|
-
Install or use it through your preferred package manager, then run:
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
openapi-generator-cli generate \
|
|
75
|
-
-i http://localhost:5000/swagger/v1/swagger.json \
|
|
76
|
-
-g typescript-fetch \
|
|
77
|
-
-o generated/ts-client
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Other useful TypeScript generators include:
|
|
81
|
-
|
|
82
|
-
- `typescript-axios`
|
|
83
|
-
- `typescript-angular`
|
|
84
|
-
|
|
85
|
-
Example:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
openapi-generator-cli generate \
|
|
89
|
-
-i http://localhost:5000/swagger/v1/swagger.json \
|
|
90
|
-
-g typescript-axios \
|
|
91
|
-
-o generated/ts-client
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## 4. Generate A Python Client
|
|
95
|
-
|
|
96
|
-
Using the same OpenAPI document:
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
openapi-generator-cli generate \
|
|
100
|
-
-i http://localhost:5000/swagger/v1/swagger.json \
|
|
101
|
-
-g python \
|
|
102
|
-
-o generated/python-client
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
This produces a Python package with request models and API wrappers based on the published OpenAPI description.
|
|
106
|
-
|
|
107
|
-
## 5. Host-Specific Notes
|
|
108
|
-
|
|
109
|
-
Generated clients are only as accurate as the host’s OpenAPI document.
|
|
110
|
-
|
|
111
|
-
That means:
|
|
112
|
-
|
|
113
|
-
- if the host does not expose Swagger, there is nothing to generate from
|
|
114
|
-
- if the host excludes some controllers, those endpoints will not appear in the generated client
|
|
115
|
-
- if auth is enabled, the generated client still needs bearer-token handling configured by the consuming app
|
|
116
|
-
|
|
117
|
-
## 6. Recommended Workflow
|
|
118
|
-
|
|
119
|
-
For TypeScript and Python, the recommended workflow is:
|
|
120
|
-
|
|
121
|
-
1. build your ChillSharp host
|
|
122
|
-
2. add Swagger/OpenAPI to the host
|
|
123
|
-
3. run the host locally or in CI
|
|
124
|
-
4. export `/swagger/v1/swagger.json`
|
|
125
|
-
5. generate the client library
|
|
126
|
-
6. publish or commit the generated client as appropriate for your project
|
|
127
|
-
|
|
128
|
-
## 7. When To Prefer `ChillSharp.Client`
|
|
129
|
-
|
|
130
|
-
If the consumer is .NET, prefer `ChillSharp.Client`.
|
|
131
|
-
|
|
132
|
-
For usage examples, see [../ChillSharpClient.md](../ChillSharpClient.md).
|
|
133
|
-
|
|
134
|
-
Use generated TypeScript or Python clients when:
|
|
135
|
-
|
|
136
|
-
- the frontend is browser-based and not .NET
|
|
137
|
-
- you need Python-based automation or integration
|
|
138
|
-
- you want strongly typed clients for non-.NET environments
|
|
139
|
-
|
|
140
|
-
If you do not need generated, host-specific types, you can also use the generic clients shipped in `ext/`:
|
|
141
|
-
|
|
142
|
-
- `ext/chill-sharp-ts-client`
|
|
143
|
-
- `ext/chill-sharp-react-client`
|
|
144
|
-
- `ext/chill-sharp-vue-client`
|
|
145
|
-
- `ext/chill-sharp-ng-client`
|
|
146
|
-
- `ext/chill-sharp-py-client`
|
|
147
|
-
|
|
148
|
-
## 8. Stability Guidance
|
|
149
|
-
|
|
150
|
-
If you plan to generate clients regularly:
|
|
151
|
-
|
|
152
|
-
- keep your host’s public routes stable
|
|
153
|
-
- version the API
|
|
154
|
-
- regenerate clients as part of release workflow
|
|
155
|
-
- treat OpenAPI shape changes as public-contract changes
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
## 9. Generic Batch Operations
|
|
160
|
-
|
|
161
|
-
The generic clients shipped in `ext/` also support ChillSharp batch execution through `chunk()`.
|
|
162
|
-
|
|
163
|
-
Use a plain batch when you want multiple operations in one HTTP call.
|
|
164
|
-
Wrap the batch with `transaction` and `commit` when the write operations must be committed as a single database transaction.
|
|
165
|
-
|
|
166
|
-
See the package readmes for concrete examples:
|
|
167
|
-
|
|
168
|
-
- `ext/chill-sharp-ts-client/README.md`
|
|
169
|
-
- `ext/chill-sharp-ng-client/README.md`
|
|
170
|
-
- `ext/chill-sharp-react-client/README.md`
|
|
171
|
-
- `ext/chill-sharp-vue-client/README.md`
|
|
172
|
-
- `ext/chill-sharp-py-client/README.md`
|