@twin.org/entity-storage-service 0.0.2-next.9 → 0.0.3-next.10

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 (39) hide show
  1. package/README.md +2 -2
  2. package/dist/es/entityStorageRoutes.js +399 -0
  3. package/dist/es/entityStorageRoutes.js.map +1 -0
  4. package/dist/es/entityStorageService.js +113 -0
  5. package/dist/es/entityStorageService.js.map +1 -0
  6. package/dist/es/index.js +9 -0
  7. package/dist/es/index.js.map +1 -0
  8. package/dist/es/models/IEntityStorageRoutesExamples.js +2 -0
  9. package/dist/es/models/IEntityStorageRoutesExamples.js.map +1 -0
  10. package/dist/es/models/IEntityStorageServiceConfig.js +4 -0
  11. package/dist/es/models/IEntityStorageServiceConfig.js.map +1 -0
  12. package/dist/es/models/IEntityStorageServiceConstructorOptions.js +2 -0
  13. package/dist/es/models/IEntityStorageServiceConstructorOptions.js.map +1 -0
  14. package/dist/es/restEntryPoints.js +15 -0
  15. package/dist/es/restEntryPoints.js.map +1 -0
  16. package/dist/types/entityStorageRoutes.d.ts +34 -2
  17. package/dist/types/entityStorageService.d.ts +35 -12
  18. package/dist/types/index.d.ts +6 -6
  19. package/dist/types/models/IEntityStorageRoutesExamples.d.ts +8 -1
  20. package/dist/types/models/IEntityStorageServiceConfig.d.ts +5 -0
  21. package/dist/types/models/IEntityStorageServiceConstructorOptions.d.ts +2 -2
  22. package/docs/changelog.md +220 -31
  23. package/docs/examples.md +77 -1
  24. package/docs/open-api/spec.json +441 -62
  25. package/docs/reference/classes/EntityStorageService.md +114 -36
  26. package/docs/reference/functions/entityStorageCount.md +31 -0
  27. package/docs/reference/functions/entityStorageEmpty.md +31 -0
  28. package/docs/reference/functions/entityStorageRemoveBatch.md +31 -0
  29. package/docs/reference/functions/entityStorageSetBatch.md +31 -0
  30. package/docs/reference/index.md +5 -1
  31. package/docs/reference/interfaces/IEntityStorageRoutesExamples.md +24 -8
  32. package/docs/reference/interfaces/IEntityStorageServiceConfig.md +3 -0
  33. package/docs/reference/interfaces/IEntityStorageServiceConstructorOptions.md +3 -3
  34. package/locales/en.json +1 -7
  35. package/package.json +13 -11
  36. package/dist/cjs/index.cjs +0 -421
  37. package/dist/esm/index.mjs +0 -412
  38. package/dist/types/models/IEntityStorageConfig.d.ts +0 -10
  39. package/docs/reference/interfaces/IEntityStorageConfig.md +0 -17
package/docs/examples.md CHANGED
@@ -1 +1,77 @@
1
- # @twin.org/entity-storage-service - Examples
1
+ # Entity Storage Service Examples
2
+
3
+ Use these snippets to wire a registered connector into the service layer and to expose matching REST routes.
4
+
5
+ ## EntityStorageService
6
+
7
+ ```typescript
8
+ import {
9
+ EntityStorageService,
10
+ generateRestRoutesEntityStorage
11
+ } from '@twin.org/entity-storage-service';
12
+ import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
13
+ import { MemoryEntityStorageConnector } from '@twin.org/entity-storage-connector-memory';
14
+ import {
15
+ ComparisonOperator,
16
+ LogicalOperator,
17
+ SortDirection,
18
+ type EntityCondition
19
+ } from '@twin.org/entity';
20
+
21
+ interface Profile {
22
+ id: string;
23
+ email: string;
24
+ status: 'active' | 'inactive';
25
+ createdAt: string;
26
+ }
27
+
28
+ EntityStorageConnectorFactory.register(
29
+ 'profile-storage',
30
+ () =>
31
+ new MemoryEntityStorageConnector<Profile>({
32
+ entitySchema: 'Profile'
33
+ })
34
+ );
35
+
36
+ const service = new EntityStorageService<Profile>({
37
+ entityStorageType: 'profile-storage'
38
+ });
39
+
40
+ const className = service.className();
41
+
42
+ await service.set({
43
+ id: 'profile-1',
44
+ email: 'ada@example.com',
45
+ status: 'active',
46
+ createdAt: '2026-03-09T10:30:00.000Z'
47
+ });
48
+
49
+ const byPrimaryKey = await service.get('profile-1');
50
+ const bySecondaryIndex = await service.get('ada@example.com', 'email');
51
+
52
+ const activeCondition: EntityCondition<Profile> = {
53
+ logicalOperator: LogicalOperator.And,
54
+ conditions: [
55
+ {
56
+ property: 'status',
57
+ comparison: ComparisonOperator.Equals,
58
+ value: 'active'
59
+ }
60
+ ]
61
+ };
62
+
63
+ const result = await service.query(
64
+ activeCondition,
65
+ 'createdAt',
66
+ SortDirection.Descending,
67
+ ['id', 'email', 'status'],
68
+ undefined,
69
+ 25
70
+ );
71
+
72
+ await service.remove('profile-1');
73
+
74
+ const routes = generateRestRoutesEntityStorage('/profiles', 'profileStorageComponent', {
75
+ typeName: 'Profile'
76
+ });
77
+ ```