@afora/core 0.0.7 → 0.0.8

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 (49) hide show
  1. package/README.md +34 -6
  2. package/dist/core/application/start.d.ts +7 -0
  3. package/dist/core/application/types/application.interface.d.ts +36 -2
  4. package/dist/core/command/types/command.interface.d.ts +7 -0
  5. package/dist/core/entity/abstract-entity.d.ts +28 -1
  6. package/dist/core/entity/entity.d.ts +1 -1
  7. package/dist/core/entity/event.d.ts +13 -2
  8. package/dist/core/entity/exceptions.d.ts +8 -0
  9. package/dist/core/entity/types/entity.interface.d.ts +66 -2
  10. package/dist/core/entity/version.d.ts +13 -0
  11. package/dist/core/event-policy/event-policy.d.ts +25 -0
  12. package/dist/core/event-policy/exceptions.d.ts +11 -0
  13. package/dist/core/event-policy/publish.d.ts +17 -0
  14. package/dist/core/event-policy/publishers.d.ts +18 -0
  15. package/dist/core/event-policy/types/event-policy.interface.d.ts +72 -0
  16. package/dist/core/output/coerce.d.ts +9 -0
  17. package/dist/core/output/openapi-sink.d.ts +138 -38
  18. package/dist/core/output/status.d.ts +1 -1
  19. package/dist/core/parse/parse.d.ts +10 -0
  20. package/dist/core/parse/strip.d.ts +13 -0
  21. package/dist/core/repository/exceptions.d.ts +30 -0
  22. package/dist/core/repository/in-memory.d.ts +14 -1
  23. package/dist/core/repository/plan.d.ts +20 -0
  24. package/dist/core/repository/provider.d.ts +1 -1
  25. package/dist/core/repository/query.d.ts +9 -2
  26. package/dist/core/repository/repository.d.ts +40 -8
  27. package/dist/core/repository/state.d.ts +30 -2
  28. package/dist/core/repository/types/query.interface.d.ts +106 -5
  29. package/dist/core/repository/types/repository.interface.d.ts +106 -7
  30. package/dist/experimental.js +4 -4
  31. package/dist/{index-r78dsvtc.js → index-qxfkyd6k.js} +612 -612
  32. package/dist/{index-q6hggpzw.js → index-t5qwtyj5.js} +1807 -280
  33. package/dist/index.d.ts +22 -11
  34. package/dist/index.js +62 -14
  35. package/dist/std/blueprint-plugin.d.ts +6 -2
  36. package/dist/std/blueprint.d.ts +3 -0
  37. package/dist/std/entity.d.ts +2 -1
  38. package/dist/std/event-policies.d.ts +2 -0
  39. package/dist/std/properties/exceptions.d.ts +11 -0
  40. package/dist/std/properties/json.d.ts +54 -0
  41. package/dist/std/properties/time.d.ts +4 -0
  42. package/dist/std/use-cases/crud.d.ts +6 -4
  43. package/dist/std/use-cases/shared.d.ts +32 -4
  44. package/dist/std/use-cases/types.d.ts +100 -21
  45. package/dist/testing/index.d.ts +2 -0
  46. package/dist/testing/index.js +347 -2
  47. package/dist/testing/memory-publisher.d.ts +16 -0
  48. package/dist/testing/provider-contract.d.ts +14 -0
  49. package/package.json +3 -2
package/dist/index.d.ts CHANGED
@@ -16,14 +16,19 @@ export type { BlueprintFactory, IBlueprintFactories, IBlueprintPlugin, } from ".
16
16
  export { commandBuilderOf, isCommand } from "./core/command/command.js";
17
17
  export { CommandEventFailed, InvalidCommandContext, InvalidCommandDeclaration, InvalidCommandEnvironment, UnknownCommandOperation, } from "./core/command/exceptions.js";
18
18
  export type { AnyCommand, CommandBuilder, CommandBuilderSettings, CommandEnvOption, CommandEventErrorHandler, CommandEventHandler, CommandEventInfo, CommandEvents, CommandExecution, CommandInput, CommandOf, CommandOperation, CommandOptions, CommandResponse, CommandSettings, CommandUseCases, CommandUseCasesOption, } from "./core/command/types/command.interface.js";
19
- export { AbstractEntity, ENTITY_IDENTITY_KEYS, EntityUniqueKeys, RESERVED_ENTITY_KEYS, } from "./core/entity/abstract-entity.js";
19
+ export { AbstractEntity, ENTITY_IDENTITY_KEYS, EntitySettings, EntityUniqueKeys, RESERVED_ENTITY_KEYS, } from "./core/entity/abstract-entity.js";
20
20
  export { entityBuilderOf, isEntity, isEntityClass } from "./core/entity/entity.js";
21
21
  export type { AnyEntityClass, EntityEvent, EntityEventReference, EntityEvents, EventDefinition, EventHandlerContext, } from "./core/entity/event.js";
22
22
  export { eventOf } from "./core/entity/event.js";
23
- export { DeletedEntity, ImmutableEntityKey, ReservedEntityKey, } from "./core/entity/exceptions.js";
24
- export type { DeclaredEntityInstance, EntityBuilder, EntityBuilderSettings, EntityConstructor, EntityIdentityKey, EntityInput, EntityOptions, EntityProperties, EntityUniqueKey, IEntityIdentity, } from "./core/entity/types/entity.interface.js";
23
+ export { DeletedEntity, ImmutableEntityKey, InvalidEntityExpiry, ReservedEntityKey, } from "./core/entity/exceptions.js";
24
+ export type { DeclaredEntityInstance, EntityBuilder, EntityBuilderSettings, EntityConstructor, EntityDuration, EntityExpires, EntityIdentityKey, EntityInput, EntityOptions, EntityProperties, EntityStorageOptions, EntityStorageSettings, EntityUniqueKey, ExpiresAtField, ExpiringIdentity, IEntityIdentity, IEntityVersion, VersionedIdentity, } from "./core/entity/types/entity.interface.js";
25
+ export { EntityVersion } from "./core/entity/version.js";
25
26
  export type { AnyEnvironment, EnvironmentDependencies, EnvironmentOptions, EnvironmentSource, EnvironmentValue, IEnvironment, } from "./core/environment/environment.js";
26
27
  export { environmentOf, InvalidEnvironment, isEnvironment, } from "./core/environment/environment.js";
28
+ export { eventPolicyCatalogOf, eventPolicyDescriptionOf, eventPolicyOf, } from "./core/event-policy/event-policy.js";
29
+ export { InvalidEventPolicy, PublisherNotBound, } from "./core/event-policy/exceptions.js";
30
+ export { publishEvents } from "./core/event-policy/publish.js";
31
+ export type { EventPolicyDescription, EventPolicyFactory, EventPolicyOptions, EventPolicySettings, IEventPolicyCatalog, IEventPublisher, PublishEventsOptions, PublishedEvent, } from "./core/event-policy/types/event-policy.interface.js";
27
32
  export { ExceptionLayers } from "./core/exception/enums/exception-layers.js";
28
33
  export type { DeclaredExceptionClass } from "./core/exception/exception.js";
29
34
  export { Exception, exceptionOf, UNEXPECTED_ERROR, } from "./core/exception/exception.js";
@@ -35,9 +40,10 @@ export { consoleLogProvider, jsonLogProvider, Logger, LogLevels, logProviderOf,
35
40
  export { InvalidOpenAPIModel } from "./core/openapi/exceptions.js";
36
41
  export { toOpenAPI } from "./core/openapi/openapi.js";
37
42
  export type { OpenAPIComponents, OpenAPIOptions, OpenAPISchema, } from "./core/openapi/types/openapi.interface.js";
43
+ export { coerceTextValues } from "./core/output/coerce.js";
38
44
  export { DuplicateOperation, InvalidOutputStage, } from "./core/output/exceptions.js";
39
- export type { OpenAPIDocument, OpenAPIMethod, OpenAPISinkOptions, OperationRoute, RouteOptions, } from "./core/output/openapi-sink.js";
40
- export { openapi, operationRoutes, routeOptionsIssue, } from "./core/output/openapi-sink.js";
45
+ export type { OpenAPIDocument, OpenAPIMethod, OpenAPISecurityScheme, OpenAPISinkOptions, OperationRoute, RouteOptions, RouteStatus, SecurityRequirement, } from "./core/output/openapi-sink.js";
46
+ export { openapi, operationRoutes, ROUTE_OPTION_KEYS, requestIdHeaderOf, routeOptionsIssue, } from "./core/output/openapi-sink.js";
41
47
  export { isOutput, operationOf, outputOf } from "./core/output/output.js";
42
48
  export { outputValueOf, PROBLEM_MEDIA_TYPE, problemOf, } from "./core/output/problem.js";
43
49
  export type { SelectOptions } from "./core/output/select.js";
@@ -45,6 +51,7 @@ export { select } from "./core/output/select.js";
45
51
  export { sinkOf, stageCatalogOf, stageDescriptionOf, stageKindOf, transformOf, } from "./core/output/stage.js";
46
52
  export { statusOf } from "./core/output/status.js";
47
53
  export type { AnyOutput, IStageCatalog, OperationCallOptions, OperationDescriptor, OperationPatch, OutputApplication, OutputOf, OutputSettings, OutputSource, OutputStatuses, PipeResult, Problem, ProblemOptions, SinkFactory, SinkSettings, SinkStage, Stage, StageContext, StageDescription, StageFactory, StageOptions, TransformFactory, TransformSettings, TransformStage, } from "./core/output/types/output.interface.js";
54
+ export { stripUndeclared } from "./core/parse/strip.js";
48
55
  export type { Issue, IssueCode, ParseResult, } from "./core/parse/types/parse.interface.js";
49
56
  export { AbstractProperty } from "./core/property/abstract-property.js";
50
57
  export { AbstractDefineProperty } from "./core/property/define-property.js";
@@ -75,13 +82,13 @@ export type { RecordBuilder } from "./core/record/record.js";
75
82
  export { recordBuilderOf } from "./core/record/record.js";
76
83
  export type { AnyRecordPlugin, IRecordPlugin, IRecordPluginCatalog, PluginUniqueKey, RecordPluginDescriptor, RecordPluginOptions, RecordPluginReference, RecordPluginRequirement, RecordPluginsOption, } from "./core/record/types/plugin.interface.js";
77
84
  export type { DeclaredRecordInstance, IRecord, MarkedUniqueKey, Masked, RecordChange, RecordChanges, RecordConstructor, RecordEffect, RecordEffects, RecordJson, RecordKey, RecordOptions, RecordSettings, RecordValue, } from "./core/record/types/record.interface.js";
78
- export { InvalidRepositoryCursor, InvalidRepositoryData, InvalidRepositoryDeclaration, InvalidRepositoryEntity, InvalidRepositoryQuery, RepositoryEntityNotFound, RepositoryUniqueViolation, } from "./core/repository/exceptions.js";
79
- export { inMemoryProvider } from "./core/repository/in-memory.js";
85
+ export { InvalidRepositoryCursor, InvalidRepositoryData, InvalidRepositoryDeclaration, InvalidRepositoryEntity, InvalidRepositoryIncrement, InvalidRepositoryQuery, RepositoryConcurrencyConflict, RepositoryEntityNotFound, RepositoryUniqueViolation, RepositoryUsedOutsideApplication, } from "./core/repository/exceptions.js";
86
+ export { type InMemoryProvider, inMemoryProvider, } from "./core/repository/in-memory.js";
80
87
  export { providerDescriptionOf, providerOf } from "./core/repository/provider.js";
81
88
  export type { RepositorySettings } from "./core/repository/repository.js";
82
89
  export { AbstractRepository, isRepository, RepositoryOf, repositoryOf, } from "./core/repository/repository.js";
83
- export type { ProviderCapabilities, ProviderDescription, ProviderOption, ProviderOptions, ProviderQuery, ProviderSettings, RepositoryCursorPage, RepositoryCursorQuery, RepositoryExists, RepositoryFindCursor, RepositoryFindMany, RepositoryFindPage, RepositoryOrder, RepositoryPage, RepositoryQuery, RepositoryWhere, } from "./core/repository/types/query.interface.js";
84
- export type { AnyRepository, AnyRepositoryEntity, EntityInstanceOf, EntityKeyOf, EntityNonUniqueKeyOf, EntityUniqueKeyOf, EntityValueOf, IRepositoryProvider, QueryValueOf, RepositoryAction, RepositoryContext, RepositoryCount, RepositoryCreate, RepositoryCreateInput, RepositoryData, RepositoryDelete, RepositoryFindBy, RepositoryFindManyBy, RepositoryRestore, RepositoryUpdate, } from "./core/repository/types/repository.interface.js";
90
+ export type { ProviderCapabilities, ProviderDescription, ProviderOption, ProviderOptions, ProviderQuery, ProviderSettings, RepositoryCursorPage, RepositoryCursorQuery, RepositoryExists, RepositoryExplain, RepositoryFindCursor, RepositoryFindMany, RepositoryFindPage, RepositoryForEachPage, RepositoryIndex, RepositoryOrder, RepositoryPage, RepositoryPlan, RepositoryQuery, RepositoryScans, RepositoryWalkOptions, RepositoryWalkPage, RepositoryWalkResult, RepositoryWhere, } from "./core/repository/types/query.interface.js";
91
+ export type { AnyRepository, AnyRepositoryEntity, EntityIncrementKeyOf, EntityInstanceOf, EntityKeyOf, EntityNonUniqueKeyOf, EntityUniqueKeyOf, EntityValueOf, IRepositoryProvider, ProviderIncrementOptions, ProviderKeyset, ProviderUpdateOptions, QueryValueOf, RepositoryAction, RepositoryContext, RepositoryCount, RepositoryCreate, RepositoryCreateInput, RepositoryData, RepositoryDelete, RepositoryFindBy, RepositoryFindManyBy, RepositoryIncrement, RepositoryIncrementDeltas, RepositoryIncrementOptions, RepositoryRestore, RepositoryUpdate, } from "./core/repository/types/repository.interface.js";
85
92
  export type { SchemaClass } from "./core/schema/schema.js";
86
93
  export { schemaOf } from "./core/schema/schema.js";
87
94
  export type { ISchema, ISchemaType, } from "./core/schema/types/schema.interface.js";
@@ -102,18 +109,22 @@ export { blueprintOf } from "./std/blueprint.js";
102
109
  export { Std } from "./std/blueprint-plugin.js";
103
110
  export { commandOf } from "./std/command.js";
104
111
  export { entityOf } from "./std/entity.js";
112
+ export { StdEventPolicies } from "./std/event-policies.js";
105
113
  export { Email, Ip, Phone, Url } from "./std/properties/contact.js";
106
114
  export type { EnumClass } from "./std/properties/enum.js";
107
115
  export { enumOf } from "./std/properties/enum.js";
116
+ export { InvalidJsonData, InvalidJsonSchema, } from "./std/properties/exceptions.js";
108
117
  export { SchemaProperty } from "./std/properties/headless.js";
109
118
  export { Id, Slug } from "./std/properties/identity.js";
119
+ export type { JsonClass, JsonValue } from "./std/properties/json.js";
120
+ export { checkJsonSchema, JsonProperty, jsonOf, jsonSchemaIssues, } from "./std/properties/json.js";
110
121
  export { isPasswordHash, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PASSWORD_SPECIAL_CHARACTERS, Password, PlainPassword, passwordIssues, } from "./std/properties/password.js";
111
122
  export { BooleanProperty, Integer, NumberProperty, StringProperty, Text, } from "./std/properties/primitives.js";
112
- export { CreatedAt, DateProperty, DateTime, DeletedAt, UpdatedAt, } from "./std/properties/time.js";
123
+ export { CreatedAt, DateProperty, DateTime, DeletedAt, ExpiresAt, UpdatedAt, } from "./std/properties/time.js";
113
124
  export { recordOf } from "./std/record.js";
114
125
  export { Archivable, Authenticatable, Ownable, Publishable, StdRecordPlugins, Taggable, } from "./std/record-plugins.js";
115
126
  export type { IdGenerator, PasswordHasher, RuntimeServices, } from "./std/runtime.js";
116
127
  export { configure, PasswordHasherRequired, resetRuntime, SyncVerifyUnsupported, } from "./std/runtime.js";
117
128
  export { StdStages } from "./std/stages.js";
118
129
  export { StdUseCases } from "./std/use-cases/index.js";
119
- export type { ArchiveMaker, CreateMaker, DeleteMaker, GetMaker, ListMaker, LoginMaker, PublishMaker, RegisterMaker, RestoreMaker, StdCreateOptions, StdEntityOptions, StdLifecycleOptions, StdListOptions, StdOwnerOption, StdUseCaseContext, StdUseCaseErrors, StdUseCaseOptions, StdUseCasePlugins, TagMaker, UpdateMaker, } from "./std/use-cases/types.js";
130
+ export type { ArchiveMaker, CreateMaker, DeleteMaker, GetMaker, ListMaker, LoginMaker, PublishMaker, RegisterMaker, RestoreMaker, StdCreateOptions, StdEntityOptions, StdHookArgs, StdHookOptions, StdLifecycleOptions, StdListOptions, StdNoHookOptions, StdOwnerOption, StdUseCaseContext, StdUseCaseErrors, StdUseCaseOptions, StdUseCasePlugins, TagMaker, UpdateMaker, } from "./std/use-cases/types.js";
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@ import {
2
2
  InvalidEnvironment2,
3
3
  environmentOf2,
4
4
  isEnvironment2,
5
- guard2,
6
5
  InvalidApplicationDeclaration2,
7
6
  DuplicateApplicationDeclaration2,
8
7
  ApplicationConflict2,
@@ -15,6 +14,9 @@ import {
15
14
  InvalidApplicationEnvironment2,
16
15
  useApplication2,
17
16
  resetApplication2,
17
+ InvalidEventPolicy2,
18
+ PublisherNotBound2,
19
+ guard2,
18
20
  InvalidLogDeclaration2,
19
21
  LogLevels2,
20
22
  logProviderOf2,
@@ -25,6 +27,8 @@ import {
25
27
  ReservedEntityKey2,
26
28
  ImmutableEntityKey2,
27
29
  DeletedEntity2,
30
+ InvalidEntityExpiry2,
31
+ EntityVersion2,
28
32
  entityBuilderOf2,
29
33
  isEntityClass2,
30
34
  isEntity2,
@@ -32,6 +36,7 @@ import {
32
36
  ENTITY_IDENTITY_KEYS2,
33
37
  RESERVED_ENTITY_KEYS2,
34
38
  EntityUniqueKeys2,
39
+ EntitySettings2,
35
40
  AbstractEntity2,
36
41
  InvalidRepositoryQuery2,
37
42
  InvalidRepositoryCursor2,
@@ -39,7 +44,10 @@ import {
39
44
  InvalidRepositoryEntity2,
40
45
  InvalidRepositoryData2,
41
46
  RepositoryUniqueViolation2,
47
+ RepositoryUsedOutsideApplication2,
42
48
  RepositoryEntityNotFound2,
49
+ RepositoryConcurrencyConflict2,
50
+ InvalidRepositoryIncrement2,
43
51
  providerOf2,
44
52
  providerDescriptionOf2,
45
53
  inMemoryProvider2,
@@ -77,6 +85,9 @@ import {
77
85
  CommandEventFailed2,
78
86
  commandBuilderOf2,
79
87
  isCommand2,
88
+ eventPolicyOf2,
89
+ eventPolicyDescriptionOf2,
90
+ eventPolicyCatalogOf2,
80
91
  InvalidOpenAPIModel2,
81
92
  InvalidOutputStage2,
82
93
  DuplicateOperation2,
@@ -99,14 +110,19 @@ import {
99
110
  isApplication2,
100
111
  applicationOf2,
101
112
  blueprintPluginOf2,
113
+ publishEvents2,
114
+ coerceTextValues2,
102
115
  statusOf2,
103
116
  PROBLEM_MEDIA_TYPE2,
104
117
  problemOf2,
105
118
  outputValueOf2,
119
+ ROUTE_OPTION_KEYS2,
106
120
  routeOptionsIssue2,
121
+ requestIdHeaderOf2,
107
122
  operationRoutes2,
108
123
  openapi2,
109
124
  select2,
125
+ stripUndeclared2,
110
126
  recordPluginCatalogOf2,
111
127
  Email2,
112
128
  Phone2,
@@ -120,6 +136,12 @@ import {
120
136
  resetRuntime2,
121
137
  Id2,
122
138
  Slug2,
139
+ InvalidJsonData2,
140
+ InvalidJsonSchema2,
141
+ jsonSchemaIssues2,
142
+ checkJsonSchema2,
143
+ JsonProperty2,
144
+ jsonOf2,
123
145
  PASSWORD_MIN_LENGTH2,
124
146
  PASSWORD_MAX_LENGTH2,
125
147
  PASSWORD_SPECIAL_CHARACTERS2,
@@ -137,6 +159,7 @@ import {
137
159
  CreatedAt2,
138
160
  UpdatedAt2,
139
161
  DeletedAt2,
162
+ ExpiresAt2,
140
163
  Std2,
141
164
  blueprintOf2,
142
165
  StdUseCases2,
@@ -148,9 +171,10 @@ import {
148
171
  Authenticatable2,
149
172
  StdRecordPlugins2,
150
173
  entityOf2,
174
+ StdEventPolicies2,
151
175
  recordOf2,
152
176
  StdStages2
153
- } from "./index-q6hggpzw.js";
177
+ } from "./index-t5qwtyj5.js";
154
178
  import {
155
179
  isProperty2,
156
180
  schemaOf2,
@@ -180,23 +204,23 @@ import {
180
204
  MASK2,
181
205
  RESERVED_RECORD_KEYS2,
182
206
  AbstractRecord2,
183
- pluginsOf2,
184
- isRecordPlugin2,
185
- hasPlugin2,
186
- recordPluginOf2,
187
- recordBuilderOf2,
188
- optionalOf2,
189
- ReservedBlueprintKey2,
190
- UndeclaredBlueprintProperty2,
191
- PropertyRequired2,
192
- InvalidPropertyValue2,
193
207
  State2,
194
208
  AbstractProperty2,
195
209
  PropertyStates2,
210
+ PropertyRequired2,
211
+ InvalidPropertyValue2,
196
212
  AbstractDefineProperty2,
197
213
  propertyOf2,
198
- blueprintBuilderOf2
199
- } from "./index-r78dsvtc.js";
214
+ ReservedBlueprintKey2,
215
+ UndeclaredBlueprintProperty2,
216
+ optionalOf2,
217
+ blueprintBuilderOf2,
218
+ pluginsOf2,
219
+ isRecordPlugin2,
220
+ hasPlugin2,
221
+ recordPluginOf2,
222
+ recordBuilderOf2
223
+ } from "./index-qxfkyd6k.js";
200
224
  export {
201
225
  AbstractDefineProperty2 as AbstractDefineProperty,
202
226
  AbstractEntity2 as AbstractEntity,
@@ -221,9 +245,12 @@ export {
221
245
  DuplicateOperation2 as DuplicateOperation,
222
246
  ENTITY_IDENTITY_KEYS2 as ENTITY_IDENTITY_KEYS,
223
247
  Email2 as Email,
248
+ EntitySettings2 as EntitySettings,
224
249
  EntityUniqueKeys2 as EntityUniqueKeys,
250
+ EntityVersion2 as EntityVersion,
225
251
  Exception2 as Exception,
226
252
  ExceptionLayers2 as ExceptionLayers,
253
+ ExpiresAt2 as ExpiresAt,
227
254
  Id2 as Id,
228
255
  ImmutableEntityKey2 as ImmutableEntityKey,
229
256
  IncompatibleRecordPlugin2 as IncompatibleRecordPlugin,
@@ -234,7 +261,11 @@ export {
234
261
  InvalidCommandContext2 as InvalidCommandContext,
235
262
  InvalidCommandDeclaration2 as InvalidCommandDeclaration,
236
263
  InvalidCommandEnvironment2 as InvalidCommandEnvironment,
264
+ InvalidEntityExpiry2 as InvalidEntityExpiry,
237
265
  InvalidEnvironment2 as InvalidEnvironment,
266
+ InvalidEventPolicy2 as InvalidEventPolicy,
267
+ InvalidJsonData2 as InvalidJsonData,
268
+ InvalidJsonSchema2 as InvalidJsonSchema,
238
269
  InvalidLogDeclaration2 as InvalidLogDeclaration,
239
270
  InvalidOpenAPIModel2 as InvalidOpenAPIModel,
240
271
  InvalidOutputStage2 as InvalidOutputStage,
@@ -246,12 +277,14 @@ export {
246
277
  InvalidRepositoryData2 as InvalidRepositoryData,
247
278
  InvalidRepositoryDeclaration2 as InvalidRepositoryDeclaration,
248
279
  InvalidRepositoryEntity2 as InvalidRepositoryEntity,
280
+ InvalidRepositoryIncrement2 as InvalidRepositoryIncrement,
249
281
  InvalidRepositoryQuery2 as InvalidRepositoryQuery,
250
282
  InvalidUseCaseDeclaration2 as InvalidUseCaseDeclaration,
251
283
  InvalidUseCaseDependencies2 as InvalidUseCaseDependencies,
252
284
  InvalidUseCasePlugin2 as InvalidUseCasePlugin,
253
285
  InvalidUseCaseStep2 as InvalidUseCaseStep,
254
286
  Ip2 as Ip,
287
+ JsonProperty2 as JsonProperty,
255
288
  Kind2 as Kind,
256
289
  LogLevels2 as LogLevels,
257
290
  Logger2 as Logger,
@@ -272,12 +305,16 @@ export {
272
305
  PropertyStates2 as PropertyStates,
273
306
  ProviderNotBound2 as ProviderNotBound,
274
307
  Publishable2 as Publishable,
308
+ PublisherNotBound2 as PublisherNotBound,
275
309
  RESERVED_ENTITY_KEYS2 as RESERVED_ENTITY_KEYS,
276
310
  RESERVED_RECORD_KEYS2 as RESERVED_RECORD_KEYS,
311
+ ROUTE_OPTION_KEYS2 as ROUTE_OPTION_KEYS,
277
312
  RecordPluginConflict2 as RecordPluginConflict,
313
+ RepositoryConcurrencyConflict2 as RepositoryConcurrencyConflict,
278
314
  RepositoryEntityNotFound2 as RepositoryEntityNotFound,
279
315
  RepositoryOf2 as RepositoryOf,
280
316
  RepositoryUniqueViolation2 as RepositoryUniqueViolation,
317
+ RepositoryUsedOutsideApplication2 as RepositoryUsedOutsideApplication,
281
318
  ReservedBlueprintKey2 as ReservedBlueprintKey,
282
319
  ReservedEntityKey2 as ReservedEntityKey,
283
320
  ReservedRecordKey2 as ReservedRecordKey,
@@ -285,6 +322,7 @@ export {
285
322
  Slug2 as Slug,
286
323
  State2 as State,
287
324
  Std2 as Std,
325
+ StdEventPolicies2 as StdEventPolicies,
288
326
  StdRecordPlugins2 as StdRecordPlugins,
289
327
  StdStages2 as StdStages,
290
328
  StdUseCases2 as StdUseCases,
@@ -312,6 +350,8 @@ export {
312
350
  blueprintBuilderOf2 as blueprintBuilderOf,
313
351
  blueprintOf2 as blueprintOf,
314
352
  blueprintPluginOf2 as blueprintPluginOf,
353
+ checkJsonSchema2 as checkJsonSchema,
354
+ coerceTextValues2 as coerceTextValues,
315
355
  commandBuilderOf2 as commandBuilderOf,
316
356
  commandOf2 as commandOf,
317
357
  configure2 as configure,
@@ -321,6 +361,9 @@ export {
321
361
  enumOf2 as enumOf,
322
362
  environmentOf2 as environmentOf,
323
363
  eventOf2 as eventOf,
364
+ eventPolicyCatalogOf2 as eventPolicyCatalogOf,
365
+ eventPolicyDescriptionOf2 as eventPolicyDescriptionOf,
366
+ eventPolicyOf2 as eventPolicyOf,
324
367
  exceptionOf2 as exceptionOf,
325
368
  guard2 as guard,
326
369
  hasPlugin2 as hasPlugin,
@@ -348,6 +391,8 @@ export {
348
391
  isUseCaseClass2 as isUseCaseClass,
349
392
  isUseCasePlugin2 as isUseCasePlugin,
350
393
  jsonLogProvider2 as jsonLogProvider,
394
+ jsonOf2 as jsonOf,
395
+ jsonSchemaIssues2 as jsonSchemaIssues,
351
396
  listOf2 as listOf,
352
397
  logFrom2 as logFrom,
353
398
  logProviderOf2 as logProviderOf,
@@ -368,6 +413,7 @@ export {
368
413
  providerFrom2 as providerFrom,
369
414
  providerOf2 as providerOf,
370
415
  providersOf2 as providersOf,
416
+ publishEvents2 as publishEvents,
371
417
  recordBuilderOf2 as recordBuilderOf,
372
418
  recordFieldOf2 as recordFieldOf,
373
419
  recordNameOf2 as recordNameOf,
@@ -375,6 +421,7 @@ export {
375
421
  recordPluginCatalogOf2 as recordPluginCatalogOf,
376
422
  recordPluginOf2 as recordPluginOf,
377
423
  repositoryOf2 as repositoryOf,
424
+ requestIdHeaderOf2 as requestIdHeaderOf,
378
425
  resetApplication2 as resetApplication,
379
426
  resetRuntime2 as resetRuntime,
380
427
  routeOptionsIssue2 as routeOptionsIssue,
@@ -385,6 +432,7 @@ export {
385
432
  stageDescriptionOf2 as stageDescriptionOf,
386
433
  stageKindOf2 as stageKindOf,
387
434
  statusOf2 as statusOf,
435
+ stripUndeclared2 as stripUndeclared,
388
436
  toOpenAPI2 as toOpenAPI,
389
437
  transformOf2 as transformOf,
390
438
  useApplication2 as useApplication,
@@ -1,11 +1,12 @@
1
1
  import { enumOf } from "./properties/enum.js";
2
2
  import { SchemaProperty } from "./properties/headless.js";
3
3
  import { Id, Slug } from "./properties/identity.js";
4
+ import { jsonOf } from "./properties/json.js";
4
5
  import { Password } from "./properties/password.js";
5
6
  import { CreatedAt, DateTime, DeletedAt, UpdatedAt } from "./properties/time.js";
6
7
  /**
7
- * The standard properties, for blueprints to pick from, and `enumOf`, as
8
- * `ctx.enumOf(["draft", "published"])`.
8
+ * The standard properties, for blueprints to pick from, and the factories
9
+ * `enumOf` and `jsonOf`, as `ctx.enumOf(["draft", "published"])`.
9
10
  */
10
11
  export declare const Std: import("../index.js").IBlueprintPlugin<{
11
12
  id: typeof Id;
@@ -26,10 +27,13 @@ export declare const Std: import("../index.js").IBlueprintPlugin<{
26
27
  updatedAt: typeof UpdatedAt;
27
28
  deletedAt: typeof DeletedAt;
28
29
  schema: typeof SchemaProperty;
30
+ json: import("../index.js").PropertyClass<import("typebox").TUnsafe<import("../index.js").JsonValue>, import("../index.js").JsonValue>;
29
31
  }, {
30
32
  enumOf: typeof enumOf;
33
+ jsonOf: typeof jsonOf;
31
34
  }> & {
32
35
  readonly factories: {
33
36
  enumOf: typeof enumOf;
37
+ jsonOf: typeof jsonOf;
34
38
  };
35
39
  };
@@ -22,10 +22,13 @@ export declare const blueprintOf: import("../index.js").BlueprintBuilder<readonl
22
22
  updatedAt: typeof import("../index.js").UpdatedAt;
23
23
  deletedAt: typeof import("../index.js").DeletedAt;
24
24
  schema: typeof import("../index.js").SchemaProperty;
25
+ json: import("../index.js").PropertyClass<import("typebox").TUnsafe<import("../index.js").JsonValue>, import("../index.js").JsonValue>;
25
26
  }, {
26
27
  enumOf: typeof import("../index.js").enumOf;
28
+ jsonOf: typeof import("../index.js").jsonOf;
27
29
  }> & {
28
30
  readonly factories: {
29
31
  enumOf: typeof import("../index.js").enumOf;
32
+ jsonOf: typeof import("../index.js").jsonOf;
30
33
  };
31
34
  }]>;
@@ -4,7 +4,8 @@ import { CreatedAt, DeletedAt, UpdatedAt } from "./properties/time.js";
4
4
  * An entity of `blueprint`: a record with an `id` (a UUID v7, in
5
5
  * `options.unique`) and a `createdAt`, both made when missing from its value,
6
6
  * an `updatedAt` set by each change, and a `deletedAt` set by `destroy`, after
7
- * which it no longer changes, e.g.
7
+ * which it no longer changes; with `expires: { after }`, an `expiresAt` too.
8
+ * E.g.
8
9
  * `class User extends entityOf(blueprintOf((ctx) => ({ name: ctx.string }))) {}`.
9
10
  * As a record, the class can be a field of another blueprint, e.g.
10
11
  * `{ author: User }`, with `optionalOf` and `listOf`. `options.plugins` picks
@@ -0,0 +1,2 @@
1
+ /** The built-in event policies by name; adapters add their own with `eventPolicyCatalogOf`. */
2
+ export declare const StdEventPolicies: import("../index.js").IEventPolicyCatalog;
@@ -0,0 +1,11 @@
1
+ import type { Issue } from "../../core/parse/types/parse.interface.js";
2
+ /**
3
+ * JSON data that its JSON Schema rejects, or that is not JSON at all, as
4
+ * `checkJsonSchema` finds it; `details.issues` says where and why (so
5
+ * `statusOf` gives 400).
6
+ */
7
+ export declare const InvalidJsonData: import("../../index.js").DeclaredExceptionClass<{
8
+ readonly issues: readonly Issue[];
9
+ }>;
10
+ /** A schema given to `jsonOf` or `checkJsonSchema` that is not a JSON Schema (draft 2020-12). */
11
+ export declare const InvalidJsonSchema: import("../../index.js").DeclaredExceptionClass<undefined>;
@@ -0,0 +1,54 @@
1
+ import { type Static, type TOptional, type TSchema, Type } from "typebox";
2
+ import type { Issue } from "../../core/parse/types/parse.interface.js";
3
+ import { type PropertyClass } from "../../core/property/property.js";
4
+ /** A value JSON can hold, as `JSON.parse` gives it. */
5
+ export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
6
+ readonly [key: string]: JsonValue;
7
+ };
8
+ /**
9
+ * Every issue that keeps `value` from being JSON valid for `schema` (a JSON
10
+ * Schema, draft 2020-12, or a TypeBox type), as afora issues: empty when
11
+ * there is none. For schemas known at runtime only, e.g. loaded from a
12
+ * database: TypeBox checks the value by walking the schema, compiling
13
+ * nothing. Throws `InvalidJsonSchema` when `schema` is not a JSON Schema.
14
+ */
15
+ export declare function jsonSchemaIssues(schema: unknown, value: unknown, { source }?: {
16
+ readonly source?: string;
17
+ }): readonly Issue[];
18
+ /**
19
+ * `value`, when it is JSON valid for `schema`; else throws `InvalidJsonData`
20
+ * with every issue in `details.issues` (a 400 for `statusOf`). `source` names
21
+ * what is checked in the issues and the exception, e.g. the content type.
22
+ * The value is typed by a schema whose type is known (`Static`), else as
23
+ * `JsonValue`, as for a schema loaded at runtime. See `jsonSchemaIssues`.
24
+ */
25
+ export declare function checkJsonSchema<const Schema extends TSchema>(schema: Schema, value: unknown, options?: {
26
+ readonly source?: string;
27
+ }): Static<Schema>;
28
+ export declare function checkJsonSchema(schema: unknown, value: unknown, options?: {
29
+ readonly source?: string;
30
+ }): JsonValue;
31
+ /**
32
+ * Any JSON value: `null`, a boolean, a finite number, a string, or a list or
33
+ * plain object of them, at any depth. Rejects `undefined` (in a list or an
34
+ * object too), functions, `NaN`, class instances such as `Date`, and cycles.
35
+ * For JSON of a known shape, `jsonOf({ schema })`.
36
+ */
37
+ export declare const JsonProperty: PropertyClass<Type.TUnsafe<JsonValue>, JsonValue>;
38
+ /** A class declared with `jsonOf`. */
39
+ export type JsonClass<Schema extends TSchema, Optional extends boolean = false> = PropertyClass<Optional extends true ? TOptional<Schema> : Schema, Static<Schema>>;
40
+ /**
41
+ * JSON checked by a JSON Schema (draft 2020-12) known when the property is
42
+ * declared, written as JSON (`{ type: "object", properties: {...} }`, typed
43
+ * as `Static` gives it) or with TypeBox (`Type.Object({...})`). Its issues
44
+ * are at the path of the data that breaks the schema. Throws
45
+ * `InvalidJsonSchema` for a schema that is not a JSON Schema. For a schema
46
+ * known only at runtime, `checkJsonSchema`.
47
+ */
48
+ export declare function jsonOf<const Schema extends TSchema, Optional extends boolean = false>({ schema, name, optional, default: _default, }: {
49
+ readonly schema: Schema;
50
+ readonly name?: string;
51
+ readonly optional?: Optional;
52
+ /** The demo value; one TypeBox makes from the schema, when it can, by default. */
53
+ readonly default?: Static<Schema>;
54
+ }): JsonClass<Schema, Optional>;
@@ -23,4 +23,8 @@ declare const DeletedAt_base: DateTimeClass<true>;
23
23
  /** When a record was soft-deleted; absent while it is not. */
24
24
  export declare class DeletedAt extends DeletedAt_base {
25
25
  }
26
+ declare const ExpiresAt_base: DateTimeClass<false>;
27
+ /** When a record expires, for entities declared with `expires: { after }`. */
28
+ export declare class ExpiresAt extends ExpiresAt_base {
29
+ }
26
30
  export {};
@@ -3,11 +3,13 @@ import type { AnyExceptionClass } from "../../core/use-case/use-case.js";
3
3
  import { type Options, type Step } from "./shared.js";
4
4
  import type { CreateMaker, DeleteMaker, GetMaker, ListMaker, RestoreMaker, UpdateMaker } from "./types.js";
5
5
  /**
6
- * The declaration of `create` and of `register`, which adds `before` and
7
- * its errors: an input of the keys of the entity, the entity built from it
8
- * and stored.
6
+ * The declaration of `create` and of `register`, which adds `checks` and
7
+ * their errors: an input of the keys of the entity, the entity built from
8
+ * it and stored. The option `before` runs first, and the steps after it read
9
+ * the input it gives; `checks` read it under `$input` all the same, rooted
10
+ * by the function given.
9
11
  */
10
- export declare function createCompilation(target: UseCaseTargetInfo, options: Options, verb: string, before?: readonly Step[], errors?: readonly AnyExceptionClass[]): UseCaseCompilation;
12
+ export declare function createCompilation(target: UseCaseTargetInfo, options: Options, verb: string, checks?: (input: string) => readonly Step[], errors?: readonly AnyExceptionClass[]): UseCaseCompilation;
11
13
  /** Builds an entity from the input and stores it. */
12
14
  export declare const create: import("../../index.js").IUseCasePlugin<"create", CreateMaker>;
13
15
  /** Gives the entity of an id. */
@@ -1,6 +1,6 @@
1
1
  import type { BlueprintField } from "../../core/blueprint/types/blueprint.interface.js";
2
2
  import type { UseCaseCompilation, UseCaseFieldPlan, UseCaseTargetInfo } from "../../core/use-case/types/plugin.interface.js";
3
- import type { AnyExceptionClass } from "../../core/use-case/use-case.js";
3
+ import type { AnyExceptionClass, UseCaseDependency } from "../../core/use-case/use-case.js";
4
4
  /** A blueprint of the fields given, with no context of properties. */
5
5
  export declare const fields: import("../../index.js").BlueprintBuilder<readonly []>;
6
6
  export type Options = Readonly<Record<string, unknown>>;
@@ -10,6 +10,8 @@ export declare const capitalize: (key: string) => string;
10
10
  export declare function literal(value: unknown): unknown;
11
11
  /** The option `key`, checked to be one of the `allowed` options of the use case. */
12
12
  export declare function checkOptions(target: UseCaseTargetInfo, options: Options, allowed: readonly string[]): void;
13
+ /** The options of the use cases that write: `before`, `after`, `dependencies`, `throws`. */
14
+ export declare const HOOKS: readonly ["before", "after", "dependencies", "throws"];
13
15
  /** The name, description, tags and `deprecated` of the use case. */
14
16
  export declare function metaOf(target: UseCaseTargetInfo, options: Options, verb: string): Pick<UseCaseCompilation, "name" | "description" | "tags" | "deprecated">;
15
17
  /** The key of the response that holds the entity: the option `as`, `item` by default. */
@@ -43,18 +45,44 @@ export declare function contextOf(owner: Owner | undefined): Pick<UseCaseCompila
43
45
  * when there is none, and when it is not the caller's.
44
46
  */
45
47
  export declare function loadSteps(owner: Owner | undefined, notFound: AnyExceptionClass): Step[];
48
+ /** What the options `before`, `after`, `dependencies` and `throws` add to a use case. */
49
+ export interface Hooks {
50
+ /** The root of the input the steps read: `$input`, or `$prepared` after `before`. */
51
+ readonly input: string;
52
+ /** The dependencies the options give, joined to those the use case makes. */
53
+ readonly dependencies: Readonly<Record<string, UseCaseDependency>>;
54
+ readonly throws: readonly AnyExceptionClass[];
55
+ /** The step of `before`, if any: it binds `prepared`, the input it gives back or the one it got. */
56
+ before(entity?: string): Step[];
57
+ /** The step of `after`, if any, over the entity written. */
58
+ after(entity: string): Step[];
59
+ }
60
+ /**
61
+ * The options `before`, `after`, `dependencies` and `throws`, checked: each
62
+ * hook becomes a `run` step, whose function gets `{ input, entity?,
63
+ * dependencies, context }` (the bound dependencies of the call, overrides
64
+ * included).
65
+ */
66
+ export declare function hooksOf(target: UseCaseTargetInfo, options: Options): Hooks;
67
+ /**
68
+ * The dependencies a use case makes, joined to those of the option
69
+ * `dependencies`; a name taken by both is unavailable.
70
+ */
71
+ export declare function joinDependencies(target: UseCaseTargetInfo, made: Readonly<Record<string, UseCaseDependency>>, hooks: Hooks): Readonly<Record<string, UseCaseDependency>>;
46
72
  /** The id field of the entity of `target`. */
47
73
  export declare const idOf: (target: UseCaseTargetInfo) => BlueprintField;
48
74
  /** The classes of `errors`, each once. */
49
75
  export declare const distinct: (...errors: readonly AnyExceptionClass[]) => AnyExceptionClass[];
50
76
  /**
51
77
  * A use case over one entity found by id: `{ id }` in, `{ [as]: entity }`
52
- * out; loads it, checks the owner, runs `steps` (which leave the entity to
53
- * give under `result`) and gives it.
78
+ * out; loads it, checks the owner, runs `before` (with `hooks`), `steps`
79
+ * (which leave the entity to give under `result`) and `after`, and gives it.
80
+ * `steps` read the input under `input`: `$input`, or what `before` gave.
54
81
  */
55
82
  export declare function entityUseCase(target: UseCaseTargetInfo, options: Options, verb: string, allowed: readonly string[], steps: (context: {
56
83
  readonly owner: Owner | undefined;
84
+ readonly input: string;
57
85
  }) => {
58
86
  readonly steps: readonly Step[];
59
87
  readonly result: string;
60
- }): UseCaseCompilation;
88
+ }, hooks?: boolean): UseCaseCompilation;