@afora/core 0.0.6 → 0.0.7
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 +2 -1
- package/dist/core/application/types/application.interface.d.ts +11 -0
- package/dist/core/command/command.d.ts +11 -4
- package/dist/core/command/types/command.interface.d.ts +19 -0
- package/dist/core/output/status.d.ts +2 -1
- package/dist/core/property/input.d.ts +20 -0
- package/dist/core/record/plugin.d.ts +6 -2
- package/dist/core/repository/repository.d.ts +1 -1
- package/dist/core/repository/state.d.ts +9 -0
- package/dist/core/repository/types/repository.interface.d.ts +9 -2
- package/dist/core/use-case/exceptions.d.ts +36 -0
- package/dist/core/use-case/plugin-catalog.d.ts +11 -0
- package/dist/core/use-case/plugin.d.ts +25 -0
- package/dist/core/use-case/steps/types/steps.interface.d.ts +23 -6
- package/dist/core/use-case/target.d.ts +9 -0
- package/dist/core/use-case/types/plugin.interface.d.ts +185 -0
- package/dist/experimental.js +2 -2
- package/dist/{index-gbgc40xe.js → index-q6hggpzw.js} +1024 -48
- package/dist/{index-3nd9bjnc.js → index-r78dsvtc.js} +68 -57
- package/dist/index.d.ts +15 -6
- package/dist/index.js +41 -5
- package/dist/std/command.d.ts +11 -0
- package/dist/std/properties/password.d.ts +16 -1
- package/dist/std/use-cases/auth.d.ts +5 -0
- package/dist/std/use-cases/crud.d.ts +23 -0
- package/dist/std/use-cases/index.d.ts +11 -0
- package/dist/std/use-cases/lifecycle.d.ts +13 -0
- package/dist/std/use-cases/shared.d.ts +60 -0
- package/dist/std/use-cases/types.d.ts +212 -0
- package/dist/testing/index.js +10 -2
- package/package.json +1 -1
|
@@ -1000,6 +1000,17 @@ function versionParts(version) {
|
|
|
1000
1000
|
const [, major, minor, patch] = SEMVER.exec(version);
|
|
1001
1001
|
return [Number(major), Number(minor), Number(patch)];
|
|
1002
1002
|
}
|
|
1003
|
+
function satisfies(available, requested) {
|
|
1004
|
+
const [major, minor, patch] = versionParts(available);
|
|
1005
|
+
const [wantedMajor, wantedMinor, wantedPatch] = versionParts(requested);
|
|
1006
|
+
if (major !== wantedMajor)
|
|
1007
|
+
return false;
|
|
1008
|
+
if (major === 0 && minor !== wantedMinor)
|
|
1009
|
+
return false;
|
|
1010
|
+
if (minor !== wantedMinor)
|
|
1011
|
+
return minor > wantedMinor;
|
|
1012
|
+
return patch >= wantedPatch;
|
|
1013
|
+
}
|
|
1003
1014
|
var HOOKS = ["onSet", "onSetAll"];
|
|
1004
1015
|
var internals = new WeakMap;
|
|
1005
1016
|
function pluginsOf2(value) {
|
|
@@ -1277,6 +1288,60 @@ function declareRecord(Base, declared, { plugins = [], name: declaredName, ...de
|
|
|
1277
1288
|
var CHANGE_MEMBER = "change";
|
|
1278
1289
|
var changeNamespaces = new WeakMap;
|
|
1279
1290
|
|
|
1291
|
+
// src/core/blueprint/optional.ts
|
|
1292
|
+
import { Type } from "typebox";
|
|
1293
|
+
var cache2 = new WeakMap;
|
|
1294
|
+
function optionalOf2(given) {
|
|
1295
|
+
const field = fieldOf(given);
|
|
1296
|
+
const cached = cache2.get(field);
|
|
1297
|
+
if (cached)
|
|
1298
|
+
return cached;
|
|
1299
|
+
if (isOptionalRecord2(field))
|
|
1300
|
+
return field;
|
|
1301
|
+
if (isRecordClass2(field)) {
|
|
1302
|
+
const optional = Object.freeze(withStandard({
|
|
1303
|
+
[Kind2]: "record",
|
|
1304
|
+
record: field,
|
|
1305
|
+
optional: true
|
|
1306
|
+
}, (value) => value === undefined ? { value } : field.safeParse(value)));
|
|
1307
|
+
cache2.set(field, optional);
|
|
1308
|
+
return optional;
|
|
1309
|
+
}
|
|
1310
|
+
if (isBlueprint2(field)) {
|
|
1311
|
+
if (field.optional)
|
|
1312
|
+
return field;
|
|
1313
|
+
const optional = {
|
|
1314
|
+
...field,
|
|
1315
|
+
optional: true,
|
|
1316
|
+
safeParse: (value) => value === undefined ? { value } : field.safeParse(value)
|
|
1317
|
+
};
|
|
1318
|
+
Object.freeze(withStandard(optional, (value) => optional.safeParse(value)));
|
|
1319
|
+
cache2.set(field, optional);
|
|
1320
|
+
return optional;
|
|
1321
|
+
}
|
|
1322
|
+
if (isBlueprintList2(field)) {
|
|
1323
|
+
if (field.optional)
|
|
1324
|
+
return field;
|
|
1325
|
+
const optional = standardListOf({ ...field, optional: true });
|
|
1326
|
+
cache2.set(field, optional);
|
|
1327
|
+
return optional;
|
|
1328
|
+
}
|
|
1329
|
+
const Property = field;
|
|
1330
|
+
if (Property.type.optional)
|
|
1331
|
+
return Property;
|
|
1332
|
+
const base = Property.type;
|
|
1333
|
+
const SchemaConstructor = schemaOf2(base.name, Type.Optional(base.schema.type.Type()));
|
|
1334
|
+
const type = {
|
|
1335
|
+
...base,
|
|
1336
|
+
schema: new SchemaConstructor,
|
|
1337
|
+
optional: true
|
|
1338
|
+
};
|
|
1339
|
+
const Optional = derivePropertyOf(Property, type);
|
|
1340
|
+
recordPropertyLineage(Optional, { kind: "optional", base: Property });
|
|
1341
|
+
cache2.set(Property, Optional);
|
|
1342
|
+
return Optional;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1280
1345
|
// src/core/blueprint/exceptions.ts
|
|
1281
1346
|
var ReservedBlueprintKey2 = exceptionOf2({
|
|
1282
1347
|
layer: "blueprint" /* Blueprint */,
|
|
@@ -1305,7 +1370,7 @@ var InvalidPropertyValue2 = exceptionOf2({
|
|
|
1305
1370
|
import { Type as Type3 } from "typebox";
|
|
1306
1371
|
|
|
1307
1372
|
// src/core/property/property.ts
|
|
1308
|
-
import { Type } from "typebox";
|
|
1373
|
+
import { Type as Type2 } from "typebox";
|
|
1309
1374
|
|
|
1310
1375
|
// src/core/symbols/state.ts
|
|
1311
1376
|
var State2 = Symbol("state");
|
|
@@ -1523,7 +1588,7 @@ function propertyOf2({
|
|
|
1523
1588
|
preHandle: onPreHandle,
|
|
1524
1589
|
afterHandle: onAfterHandle
|
|
1525
1590
|
}) {
|
|
1526
|
-
const valueSchema = optional ?
|
|
1591
|
+
const valueSchema = optional ? Type2.Optional(schema) : schema;
|
|
1527
1592
|
const SchemaConstructor = schemaOf2(name, valueSchema);
|
|
1528
1593
|
const type = {
|
|
1529
1594
|
[Demo2]: _default,
|
|
@@ -1555,60 +1620,6 @@ function propertyOf2({
|
|
|
1555
1620
|
return Property;
|
|
1556
1621
|
}
|
|
1557
1622
|
|
|
1558
|
-
// src/core/blueprint/optional.ts
|
|
1559
|
-
import { Type as Type2 } from "typebox";
|
|
1560
|
-
var cache2 = new WeakMap;
|
|
1561
|
-
function optionalOf2(given) {
|
|
1562
|
-
const field = fieldOf(given);
|
|
1563
|
-
const cached = cache2.get(field);
|
|
1564
|
-
if (cached)
|
|
1565
|
-
return cached;
|
|
1566
|
-
if (isOptionalRecord2(field))
|
|
1567
|
-
return field;
|
|
1568
|
-
if (isRecordClass2(field)) {
|
|
1569
|
-
const optional = Object.freeze(withStandard({
|
|
1570
|
-
[Kind2]: "record",
|
|
1571
|
-
record: field,
|
|
1572
|
-
optional: true
|
|
1573
|
-
}, (value) => value === undefined ? { value } : field.safeParse(value)));
|
|
1574
|
-
cache2.set(field, optional);
|
|
1575
|
-
return optional;
|
|
1576
|
-
}
|
|
1577
|
-
if (isBlueprint2(field)) {
|
|
1578
|
-
if (field.optional)
|
|
1579
|
-
return field;
|
|
1580
|
-
const optional = {
|
|
1581
|
-
...field,
|
|
1582
|
-
optional: true,
|
|
1583
|
-
safeParse: (value) => value === undefined ? { value } : field.safeParse(value)
|
|
1584
|
-
};
|
|
1585
|
-
Object.freeze(withStandard(optional, (value) => optional.safeParse(value)));
|
|
1586
|
-
cache2.set(field, optional);
|
|
1587
|
-
return optional;
|
|
1588
|
-
}
|
|
1589
|
-
if (isBlueprintList2(field)) {
|
|
1590
|
-
if (field.optional)
|
|
1591
|
-
return field;
|
|
1592
|
-
const optional = standardListOf({ ...field, optional: true });
|
|
1593
|
-
cache2.set(field, optional);
|
|
1594
|
-
return optional;
|
|
1595
|
-
}
|
|
1596
|
-
const Property = field;
|
|
1597
|
-
if (Property.type.optional)
|
|
1598
|
-
return Property;
|
|
1599
|
-
const base = Property.type;
|
|
1600
|
-
const SchemaConstructor = schemaOf2(base.name, Type2.Optional(base.schema.type.Type()));
|
|
1601
|
-
const type = {
|
|
1602
|
-
...base,
|
|
1603
|
-
schema: new SchemaConstructor,
|
|
1604
|
-
optional: true
|
|
1605
|
-
};
|
|
1606
|
-
const Optional = derivePropertyOf(Property, type);
|
|
1607
|
-
recordPropertyLineage(Optional, { kind: "optional", base: Property });
|
|
1608
|
-
cache2.set(Property, Optional);
|
|
1609
|
-
return Optional;
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
1623
|
// src/core/blueprint/blueprint.ts
|
|
1613
1624
|
function blueprintBuilderOf2(...base) {
|
|
1614
1625
|
return (sourcesOrDefine, maybeDefine) => {
|
|
@@ -1707,4 +1718,4 @@ function schemaOfField(key, field) {
|
|
|
1707
1718
|
});
|
|
1708
1719
|
}
|
|
1709
1720
|
|
|
1710
|
-
export { __export, isProperty2, schemaOf2, Demo2, recordPropertyLineage, propertyLineageOf2, fieldOf, Kind2, isBlueprint2, isRecordClass2, isOptionalRecord2, recordFieldOf2, recordNameOf2, declaredRecordNameOf, listOf2, isBlueprintList2, ExceptionLayers2, UNEXPECTED_ERROR2, Exception2, isDeclaredException, declaredMessageOf, exceptionOf2, Meta2, InvalidRecordValue2, InvalidRecordDeclaration2, UndeclaredRecordProperty2, ReservedRecordKey2, InvalidRecordPlugin2, RecordPluginConflict2, UnknownRecordPlugin2, IncompatibleRecordPlugin2, exports_exceptions, MASK2, RESERVED_RECORD_KEYS2, recordDataOf, recordFieldDataOf, storeRecordValue, runRecordEffects, AbstractRecord2, IdentifiedRecord, isVersion,
|
|
1721
|
+
export { __export, isProperty2, schemaOf2, Demo2, recordPropertyLineage, propertyLineageOf2, fieldOf, Kind2, isBlueprint2, isRecordClass2, isOptionalRecord2, recordFieldOf2, recordNameOf2, declaredRecordNameOf, listOf2, isBlueprintList2, ExceptionLayers2, UNEXPECTED_ERROR2, Exception2, isDeclaredException, declaredMessageOf, exceptionOf2, Meta2, InvalidRecordValue2, InvalidRecordDeclaration2, UndeclaredRecordProperty2, ReservedRecordKey2, InvalidRecordPlugin2, RecordPluginConflict2, UnknownRecordPlugin2, IncompatibleRecordPlugin2, exports_exceptions, MASK2, RESERVED_RECORD_KEYS2, recordDataOf, recordFieldDataOf, storeRecordValue, runRecordEffects, AbstractRecord2, IdentifiedRecord, isVersion, satisfies, pluginsOf2, isRecordPlugin2, hasPlugin2, recordPluginOf2, recordBuilderOf2, pluginContextOf, recordOf3, declareRecord, optionalOf2, ReservedBlueprintKey2, UndeclaredBlueprintProperty2, exports_exceptions2, PropertyRequired2, InvalidPropertyValue2, exports_exceptions3, State2, AbstractProperty2, PropertyStates2, AbstractDefineProperty2, propertyOf2, blueprintBuilderOf2, blueprintFromProperties };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ export { optionalOf } from "./core/blueprint/optional.js";
|
|
|
13
13
|
export { isOptionalRecord, isRecordClass, recordFieldOf, } from "./core/blueprint/record-field.js";
|
|
14
14
|
export type { AnyBlueprint, AnyBlueprintList, AnyOptionalRecord, AnyRecordClass, BlueprintBuilder, BlueprintContext, BlueprintData, BlueprintDefinition, BlueprintField, BlueprintHelpers, BlueprintInput, BlueprintListOptions, BlueprintPluginContext, BlueprintSchema, BlueprintSource, BlueprintValue, IBlueprint, IBlueprintCollection, IBlueprintList, OptionalBlueprint, OptionalBlueprintList, OptionalRecord, } from "./core/blueprint/types/blueprint.interface.js";
|
|
15
15
|
export type { BlueprintFactory, IBlueprintFactories, IBlueprintPlugin, } from "./core/blueprint/types/blueprint-plugin.interface.js";
|
|
16
|
-
export {
|
|
16
|
+
export { commandBuilderOf, isCommand } from "./core/command/command.js";
|
|
17
17
|
export { CommandEventFailed, InvalidCommandContext, InvalidCommandDeclaration, InvalidCommandEnvironment, UnknownCommandOperation, } from "./core/command/exceptions.js";
|
|
18
|
-
export type { AnyCommand, CommandEnvOption, CommandEventErrorHandler, CommandEventHandler, CommandEventInfo, CommandEvents, CommandExecution, CommandInput, CommandOf, CommandOperation, CommandOptions, CommandResponse, CommandSettings, CommandUseCases, } from "./core/command/types/command.interface.js";
|
|
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
19
|
export { AbstractEntity, ENTITY_IDENTITY_KEYS, 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";
|
|
@@ -50,6 +50,8 @@ export { AbstractProperty } from "./core/property/abstract-property.js";
|
|
|
50
50
|
export { AbstractDefineProperty } from "./core/property/define-property.js";
|
|
51
51
|
export { PropertyStates } from "./core/property/enums/property-states.js";
|
|
52
52
|
export { InvalidPropertyValue, PropertyRequired, } from "./core/property/exceptions.js";
|
|
53
|
+
export type { IPropertyInput } from "./core/property/input.js";
|
|
54
|
+
export { PropertyInput, propertyInputOf } from "./core/property/input.js";
|
|
53
55
|
export { isProperty } from "./core/property/is-property.js";
|
|
54
56
|
export type { PropertyLineage } from "./core/property/lineage.js";
|
|
55
57
|
export { propertyLineageOf } from "./core/property/lineage.js";
|
|
@@ -79,7 +81,7 @@ export { providerDescriptionOf, providerOf } from "./core/repository/provider.js
|
|
|
79
81
|
export type { RepositorySettings } from "./core/repository/repository.js";
|
|
80
82
|
export { AbstractRepository, isRepository, RepositoryOf, repositoryOf, } from "./core/repository/repository.js";
|
|
81
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";
|
|
82
|
-
export type { AnyRepository, AnyRepositoryEntity, EntityInstanceOf, EntityKeyOf, EntityNonUniqueKeyOf, EntityUniqueKeyOf, EntityValueOf, IRepositoryProvider, QueryValueOf, RepositoryAction, RepositoryContext, RepositoryCount, RepositoryCreate, RepositoryCreateInput, RepositoryData, RepositoryDelete, RepositoryFindBy, RepositoryFindManyBy, RepositoryUpdate, } from "./core/repository/types/repository.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";
|
|
83
85
|
export type { SchemaClass } from "./core/schema/schema.js";
|
|
84
86
|
export { schemaOf } from "./core/schema/schema.js";
|
|
85
87
|
export type { ISchema, ISchemaType, } from "./core/schema/types/schema.interface.js";
|
|
@@ -88,19 +90,24 @@ export { Demo } from "./core/symbols/demo.js";
|
|
|
88
90
|
export { Kind } from "./core/symbols/kind.js";
|
|
89
91
|
export { Meta } from "./core/symbols/meta.js";
|
|
90
92
|
export { State } from "./core/symbols/state.js";
|
|
91
|
-
export { InvalidUseCaseStep } from "./core/use-case/exceptions.js";
|
|
92
|
-
export
|
|
93
|
+
export { IncompatibleUseCasePlugin, InvalidUseCasePlugin, InvalidUseCaseStep, UnknownUseCasePlugin, UseCaseEntityConflict, UseCaseEntityNotFound, UseCaseInvalidCredentials, UseCaseUnavailable, } from "./core/use-case/exceptions.js";
|
|
94
|
+
export { isUseCasePlugin, useCaseOriginOf, useCasePluginOf, } from "./core/use-case/plugin.js";
|
|
95
|
+
export { isUseCaseCatalog, useCaseCatalogOf, } from "./core/use-case/plugin-catalog.js";
|
|
96
|
+
export type { StepArgs, StepEnsureKind, StepErrorDescription, StepFindTarget, StepReadAction, StepReference, StepRepositoryWith, StepValue, UseCaseStep, UseCaseStepDescription, } from "./core/use-case/steps/types/steps.interface.js";
|
|
97
|
+
export { useCaseTargetOf } from "./core/use-case/target.js";
|
|
98
|
+
export type { AnyUseCasePlugin, EntityOfRepository, IUseCaseCatalog, IUseCasePlugin, MissingRecordPlugin, MissingRepositoryAction, UseCaseCompilation, UseCaseContextOf, UseCaseFieldPlan, UseCaseMaker, UseCaseOriginInfo, UseCasePluginContext, UseCasePluginDescriptor, UseCasePluginRequirements, UseCasePluginSettings, UseCasePluginsByName, UseCaseTarget, UseCaseTargetInfo, } from "./core/use-case/types/plugin.interface.js";
|
|
93
99
|
export type { AnyExceptionClass, AnyUseCaseClass, DependencyFunctions, DependencyOf, DependencyOverrides, StepsUseCaseConstructor, UseCaseCollection, UseCaseConstructor, UseCaseContext, UseCaseDependencies, UseCaseDependency, UseCaseInput, UseCaseOptions, UseCaseResponse, UseCaseSettings, UseCaseStepsSettings, } from "./core/use-case/use-case.js";
|
|
94
100
|
export { AbstractUseCase, InvalidUseCaseDeclaration, InvalidUseCaseDependencies, isUseCase, isUseCaseClass, UseCaseAlreadyExecuted, useCaseOf, } from "./core/use-case/use-case.js";
|
|
95
101
|
export { blueprintOf } from "./std/blueprint.js";
|
|
96
102
|
export { Std } from "./std/blueprint-plugin.js";
|
|
103
|
+
export { commandOf } from "./std/command.js";
|
|
97
104
|
export { entityOf } from "./std/entity.js";
|
|
98
105
|
export { Email, Ip, Phone, Url } from "./std/properties/contact.js";
|
|
99
106
|
export type { EnumClass } from "./std/properties/enum.js";
|
|
100
107
|
export { enumOf } from "./std/properties/enum.js";
|
|
101
108
|
export { SchemaProperty } from "./std/properties/headless.js";
|
|
102
109
|
export { Id, Slug } from "./std/properties/identity.js";
|
|
103
|
-
export { isPasswordHash, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PASSWORD_SPECIAL_CHARACTERS, Password, passwordIssues, } from "./std/properties/password.js";
|
|
110
|
+
export { isPasswordHash, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PASSWORD_SPECIAL_CHARACTERS, Password, PlainPassword, passwordIssues, } from "./std/properties/password.js";
|
|
104
111
|
export { BooleanProperty, Integer, NumberProperty, StringProperty, Text, } from "./std/properties/primitives.js";
|
|
105
112
|
export { CreatedAt, DateProperty, DateTime, DeletedAt, UpdatedAt, } from "./std/properties/time.js";
|
|
106
113
|
export { recordOf } from "./std/record.js";
|
|
@@ -108,3 +115,5 @@ export { Archivable, Authenticatable, Ownable, Publishable, StdRecordPlugins, Ta
|
|
|
108
115
|
export type { IdGenerator, PasswordHasher, RuntimeServices, } from "./std/runtime.js";
|
|
109
116
|
export { configure, PasswordHasherRequired, resetRuntime, SyncVerifyUnsupported, } from "./std/runtime.js";
|
|
110
117
|
export { StdStages } from "./std/stages.js";
|
|
118
|
+
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";
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,16 @@ import {
|
|
|
48
48
|
RepositoryOf2,
|
|
49
49
|
isRepository2,
|
|
50
50
|
InvalidUseCaseStep2,
|
|
51
|
+
InvalidUseCasePlugin2,
|
|
52
|
+
UnknownUseCasePlugin2,
|
|
53
|
+
IncompatibleUseCasePlugin2,
|
|
54
|
+
UseCaseUnavailable2,
|
|
55
|
+
UseCaseEntityNotFound2,
|
|
56
|
+
UseCaseEntityConflict2,
|
|
57
|
+
UseCaseInvalidCredentials2,
|
|
58
|
+
PropertyInput2,
|
|
59
|
+
propertyInputOf2,
|
|
60
|
+
useCaseTargetOf2,
|
|
51
61
|
InvalidUseCaseDeclaration2,
|
|
52
62
|
UseCaseAlreadyExecuted2,
|
|
53
63
|
InvalidUseCaseDependencies2,
|
|
@@ -55,12 +65,17 @@ import {
|
|
|
55
65
|
useCaseOf2,
|
|
56
66
|
isUseCaseClass2,
|
|
57
67
|
isUseCase2,
|
|
68
|
+
isUseCasePlugin2,
|
|
69
|
+
useCaseOriginOf2,
|
|
70
|
+
useCasePluginOf2,
|
|
71
|
+
isUseCaseCatalog2,
|
|
72
|
+
useCaseCatalogOf2,
|
|
58
73
|
InvalidCommandDeclaration2,
|
|
59
74
|
UnknownCommandOperation2,
|
|
60
75
|
InvalidCommandContext2,
|
|
61
76
|
InvalidCommandEnvironment2,
|
|
62
77
|
CommandEventFailed2,
|
|
63
|
-
|
|
78
|
+
commandBuilderOf2,
|
|
64
79
|
isCommand2,
|
|
65
80
|
InvalidOpenAPIModel2,
|
|
66
81
|
InvalidOutputStage2,
|
|
@@ -110,6 +125,7 @@ import {
|
|
|
110
125
|
PASSWORD_SPECIAL_CHARACTERS2,
|
|
111
126
|
isPasswordHash2,
|
|
112
127
|
passwordIssues2,
|
|
128
|
+
PlainPassword2,
|
|
113
129
|
Password2,
|
|
114
130
|
StringProperty2,
|
|
115
131
|
Text2,
|
|
@@ -123,6 +139,8 @@ import {
|
|
|
123
139
|
DeletedAt2,
|
|
124
140
|
Std2,
|
|
125
141
|
blueprintOf2,
|
|
142
|
+
StdUseCases2,
|
|
143
|
+
commandOf2,
|
|
126
144
|
Publishable2,
|
|
127
145
|
Archivable2,
|
|
128
146
|
Taggable2,
|
|
@@ -132,7 +150,7 @@ import {
|
|
|
132
150
|
entityOf2,
|
|
133
151
|
recordOf2,
|
|
134
152
|
StdStages2
|
|
135
|
-
} from "./index-
|
|
153
|
+
} from "./index-q6hggpzw.js";
|
|
136
154
|
import {
|
|
137
155
|
isProperty2,
|
|
138
156
|
schemaOf2,
|
|
@@ -167,6 +185,7 @@ import {
|
|
|
167
185
|
hasPlugin2,
|
|
168
186
|
recordPluginOf2,
|
|
169
187
|
recordBuilderOf2,
|
|
188
|
+
optionalOf2,
|
|
170
189
|
ReservedBlueprintKey2,
|
|
171
190
|
UndeclaredBlueprintProperty2,
|
|
172
191
|
PropertyRequired2,
|
|
@@ -176,9 +195,8 @@ import {
|
|
|
176
195
|
PropertyStates2,
|
|
177
196
|
AbstractDefineProperty2,
|
|
178
197
|
propertyOf2,
|
|
179
|
-
optionalOf2,
|
|
180
198
|
blueprintBuilderOf2
|
|
181
|
-
} from "./index-
|
|
199
|
+
} from "./index-r78dsvtc.js";
|
|
182
200
|
export {
|
|
183
201
|
AbstractDefineProperty2 as AbstractDefineProperty,
|
|
184
202
|
AbstractEntity2 as AbstractEntity,
|
|
@@ -209,6 +227,7 @@ export {
|
|
|
209
227
|
Id2 as Id,
|
|
210
228
|
ImmutableEntityKey2 as ImmutableEntityKey,
|
|
211
229
|
IncompatibleRecordPlugin2 as IncompatibleRecordPlugin,
|
|
230
|
+
IncompatibleUseCasePlugin2 as IncompatibleUseCasePlugin,
|
|
212
231
|
Integer2 as Integer,
|
|
213
232
|
InvalidApplicationDeclaration2 as InvalidApplicationDeclaration,
|
|
214
233
|
InvalidApplicationEnvironment2 as InvalidApplicationEnvironment,
|
|
@@ -230,6 +249,7 @@ export {
|
|
|
230
249
|
InvalidRepositoryQuery2 as InvalidRepositoryQuery,
|
|
231
250
|
InvalidUseCaseDeclaration2 as InvalidUseCaseDeclaration,
|
|
232
251
|
InvalidUseCaseDependencies2 as InvalidUseCaseDependencies,
|
|
252
|
+
InvalidUseCasePlugin2 as InvalidUseCasePlugin,
|
|
233
253
|
InvalidUseCaseStep2 as InvalidUseCaseStep,
|
|
234
254
|
Ip2 as Ip,
|
|
235
255
|
Kind2 as Kind,
|
|
@@ -246,6 +266,8 @@ export {
|
|
|
246
266
|
Password2 as Password,
|
|
247
267
|
PasswordHasherRequired2 as PasswordHasherRequired,
|
|
248
268
|
Phone2 as Phone,
|
|
269
|
+
PlainPassword2 as PlainPassword,
|
|
270
|
+
PropertyInput2 as PropertyInput,
|
|
249
271
|
PropertyRequired2 as PropertyRequired,
|
|
250
272
|
PropertyStates2 as PropertyStates,
|
|
251
273
|
ProviderNotBound2 as ProviderNotBound,
|
|
@@ -265,6 +287,7 @@ export {
|
|
|
265
287
|
Std2 as Std,
|
|
266
288
|
StdRecordPlugins2 as StdRecordPlugins,
|
|
267
289
|
StdStages2 as StdStages,
|
|
290
|
+
StdUseCases2 as StdUseCases,
|
|
268
291
|
StringProperty2 as StringProperty,
|
|
269
292
|
SyncVerifyUnsupported2 as SyncVerifyUnsupported,
|
|
270
293
|
Taggable2 as Taggable,
|
|
@@ -274,16 +297,22 @@ export {
|
|
|
274
297
|
UndeclaredRecordProperty2 as UndeclaredRecordProperty,
|
|
275
298
|
UnknownCommandOperation2 as UnknownCommandOperation,
|
|
276
299
|
UnknownRecordPlugin2 as UnknownRecordPlugin,
|
|
300
|
+
UnknownUseCasePlugin2 as UnknownUseCasePlugin,
|
|
277
301
|
UnregisteredApplicationReference2 as UnregisteredApplicationReference,
|
|
278
302
|
UnregisteredRepositoryDependency2 as UnregisteredRepositoryDependency,
|
|
279
303
|
UnregisteredUseCaseDependency2 as UnregisteredUseCaseDependency,
|
|
280
304
|
UpdatedAt2 as UpdatedAt,
|
|
281
305
|
Url2 as Url,
|
|
282
306
|
UseCaseAlreadyExecuted2 as UseCaseAlreadyExecuted,
|
|
307
|
+
UseCaseEntityConflict2 as UseCaseEntityConflict,
|
|
308
|
+
UseCaseEntityNotFound2 as UseCaseEntityNotFound,
|
|
309
|
+
UseCaseInvalidCredentials2 as UseCaseInvalidCredentials,
|
|
310
|
+
UseCaseUnavailable2 as UseCaseUnavailable,
|
|
283
311
|
applicationOf2 as applicationOf,
|
|
284
312
|
blueprintBuilderOf2 as blueprintBuilderOf,
|
|
285
313
|
blueprintOf2 as blueprintOf,
|
|
286
314
|
blueprintPluginOf2 as blueprintPluginOf,
|
|
315
|
+
commandBuilderOf2 as commandBuilderOf,
|
|
287
316
|
commandOf2 as commandOf,
|
|
288
317
|
configure2 as configure,
|
|
289
318
|
consoleLogProvider2 as consoleLogProvider,
|
|
@@ -315,7 +344,9 @@ export {
|
|
|
315
344
|
isRecordPlugin2 as isRecordPlugin,
|
|
316
345
|
isRepository2 as isRepository,
|
|
317
346
|
isUseCase2 as isUseCase,
|
|
347
|
+
isUseCaseCatalog2 as isUseCaseCatalog,
|
|
318
348
|
isUseCaseClass2 as isUseCaseClass,
|
|
349
|
+
isUseCasePlugin2 as isUseCasePlugin,
|
|
319
350
|
jsonLogProvider2 as jsonLogProvider,
|
|
320
351
|
listOf2 as listOf,
|
|
321
352
|
logFrom2 as logFrom,
|
|
@@ -330,6 +361,7 @@ export {
|
|
|
330
361
|
passwordIssues2 as passwordIssues,
|
|
331
362
|
pluginsOf2 as pluginsOf,
|
|
332
363
|
problemOf2 as problemOf,
|
|
364
|
+
propertyInputOf2 as propertyInputOf,
|
|
333
365
|
propertyLineageOf2 as propertyLineageOf,
|
|
334
366
|
propertyOf2 as propertyOf,
|
|
335
367
|
providerDescriptionOf2 as providerDescriptionOf,
|
|
@@ -356,5 +388,9 @@ export {
|
|
|
356
388
|
toOpenAPI2 as toOpenAPI,
|
|
357
389
|
transformOf2 as transformOf,
|
|
358
390
|
useApplication2 as useApplication,
|
|
359
|
-
|
|
391
|
+
useCaseCatalogOf2 as useCaseCatalogOf,
|
|
392
|
+
useCaseOf2 as useCaseOf,
|
|
393
|
+
useCaseOriginOf2 as useCaseOriginOf,
|
|
394
|
+
useCasePluginOf2 as useCasePluginOf,
|
|
395
|
+
useCaseTargetOf2 as useCaseTargetOf
|
|
360
396
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommandBuilder } from "../core/command/types/command.interface.js";
|
|
2
|
+
import type { StdUseCaseContext } from "./use-cases/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Groups use cases under operation names and is the boundary of a call: the
|
|
5
|
+
* context is validated once, a transaction can wrap the use case, and the
|
|
6
|
+
* events it raised are handled by a policy once it succeeded. `useCases` is
|
|
7
|
+
* an object of use case classes, or a function of the standard use cases
|
|
8
|
+
* (`StdUseCases`) that gives one:
|
|
9
|
+
* `(ctx) => ({ create: ctx.create(Posts), custom: MyUseCase })`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const commandOf: CommandBuilder<StdUseCaseContext>;
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
+
import { type IPropertyInput, PropertyInput } from "../../core/property/input.js";
|
|
2
3
|
export declare const PASSWORD_MIN_LENGTH = 7;
|
|
3
4
|
export declare const PASSWORD_MAX_LENGTH = 128;
|
|
4
5
|
export declare const PASSWORD_SPECIAL_CHARACTERS = "!@#$%^&*()-_=+[]{}|\\;:'\",.<>/?`~";
|
|
5
6
|
export declare function isPasswordHash(value: string): boolean;
|
|
6
7
|
/** The rules a plain password breaks; empty when it is strong enough. */
|
|
7
8
|
export declare function passwordIssues(value: string): string[];
|
|
9
|
+
declare const PlainPassword_base: import("../../index.js").PropertyClass<Type.TString, string> & {
|
|
10
|
+
readonly type: {
|
|
11
|
+
readonly sensitive: true;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A password as a person types it, checked against the password rules
|
|
16
|
+
* (`passwordIssues`); sensitive. It is what an input takes for a `Password`,
|
|
17
|
+
* which stores the hash.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PlainPassword extends PlainPassword_base {
|
|
20
|
+
}
|
|
8
21
|
declare const Password_base: import("../../index.js").PropertyClass<Type.TString, string> & {
|
|
9
22
|
readonly type: {
|
|
10
23
|
readonly sensitive: true;
|
|
@@ -13,9 +26,11 @@ declare const Password_base: import("../../index.js").PropertyClass<Type.TString
|
|
|
13
26
|
/**
|
|
14
27
|
* A password stored as an Argon2 hash. The constructor only accepts a hash,
|
|
15
28
|
* e.g. one read from the database; `Password.hash` turns a plain password
|
|
16
|
-
* into one.
|
|
29
|
+
* into one. Under `PropertyInput` it says so to what derives inputs: they
|
|
30
|
+
* take a `PlainPassword` and hash it.
|
|
17
31
|
*/
|
|
18
32
|
export declare class Password extends Password_base {
|
|
33
|
+
static readonly [PropertyInput]: IPropertyInput<string>;
|
|
19
34
|
/** Validates `plain` against the password rules and hashes it with the configured hasher (argon2id by default). */
|
|
20
35
|
static hash(plain: string): Promise<Password>;
|
|
21
36
|
/** Whether `input` is the password this hash was made from. */
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LoginMaker, RegisterMaker } from "./types.js";
|
|
2
|
+
/** Stores an authenticatable entity, unless its email is taken. */
|
|
3
|
+
export declare const register: import("../../index.js").IUseCasePlugin<"register", RegisterMaker>;
|
|
4
|
+
/** Gives the authenticatable entity of an email, when the password matches. */
|
|
5
|
+
export declare const login: import("../../index.js").IUseCasePlugin<"login", LoginMaker>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UseCaseCompilation, UseCaseTargetInfo } from "../../core/use-case/types/plugin.interface.js";
|
|
2
|
+
import type { AnyExceptionClass } from "../../core/use-case/use-case.js";
|
|
3
|
+
import { type Options, type Step } from "./shared.js";
|
|
4
|
+
import type { CreateMaker, DeleteMaker, GetMaker, ListMaker, RestoreMaker, UpdateMaker } from "./types.js";
|
|
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.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createCompilation(target: UseCaseTargetInfo, options: Options, verb: string, before?: readonly Step[], errors?: readonly AnyExceptionClass[]): UseCaseCompilation;
|
|
11
|
+
/** Builds an entity from the input and stores it. */
|
|
12
|
+
export declare const create: import("../../index.js").IUseCasePlugin<"create", CreateMaker>;
|
|
13
|
+
/** Gives the entity of an id. */
|
|
14
|
+
export declare const get: import("../../index.js").IUseCasePlugin<"get", GetMaker>;
|
|
15
|
+
/** Gives a page of entities. */
|
|
16
|
+
export declare const list: import("../../index.js").IUseCasePlugin<"list", ListMaker>;
|
|
17
|
+
/** Changes the keys the input gives, of those the entity lets change. */
|
|
18
|
+
export declare const update: import("../../index.js").IUseCasePlugin<"update", UpdateMaker>;
|
|
19
|
+
/** Deletes the entity of an id, as the repository deletes: for good, or softly. */
|
|
20
|
+
declare const remove: import("../../index.js").IUseCasePlugin<"delete", DeleteMaker>;
|
|
21
|
+
export { remove as delete_ };
|
|
22
|
+
/** Brings back a soft-deleted entity. */
|
|
23
|
+
export declare const restore: import("../../index.js").IUseCasePlugin<"restore", RestoreMaker>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IUseCaseCatalog } from "../../core/use-case/types/plugin.interface.js";
|
|
2
|
+
import type { StdUseCasePlugins } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The standard use cases, by name, for the `useCases` of `commandOf` to
|
|
5
|
+
* pick from, as `(ctx) => ({ create: ctx.create(Posts) })`: `create`, `get`,
|
|
6
|
+
* `list`, `update`, `delete` and `restore` for any entity; `publish`,
|
|
7
|
+
* `unpublish`, `archive`, `unarchive`, `tag` and `untag` for the entities
|
|
8
|
+
* with those record plugins; `register` and `login` for the
|
|
9
|
+
* authenticatable ones. `StdUseCases.context` is that `ctx`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const StdUseCases: IUseCaseCatalog<StdUseCasePlugins>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ArchiveMaker, PublishMaker, TagMaker } from "./types.js";
|
|
2
|
+
/** Publishes the entity of an id. */
|
|
3
|
+
export declare const publish: import("../../index.js").IUseCasePlugin<"publish", PublishMaker>;
|
|
4
|
+
/** Makes the entity of an id a draft again. */
|
|
5
|
+
export declare const unpublish: import("../../index.js").IUseCasePlugin<"unpublish", PublishMaker>;
|
|
6
|
+
/** Archives the entity of an id. */
|
|
7
|
+
export declare const archive: import("../../index.js").IUseCasePlugin<"archive", ArchiveMaker>;
|
|
8
|
+
/** Makes the archived entity of an id active again. */
|
|
9
|
+
export declare const unarchive: import("../../index.js").IUseCasePlugin<"unarchive", ArchiveMaker>;
|
|
10
|
+
/** Adds tags to the entity of an id. */
|
|
11
|
+
export declare const tag: import("../../index.js").IUseCasePlugin<"tag", TagMaker>;
|
|
12
|
+
/** Removes tags from the entity of an id. */
|
|
13
|
+
export declare const untag: import("../../index.js").IUseCasePlugin<"untag", TagMaker>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BlueprintField } from "../../core/blueprint/types/blueprint.interface.js";
|
|
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";
|
|
4
|
+
/** A blueprint of the fields given, with no context of properties. */
|
|
5
|
+
export declare const fields: import("../../index.js").BlueprintBuilder<readonly []>;
|
|
6
|
+
export type Options = Readonly<Record<string, unknown>>;
|
|
7
|
+
export type Step = Readonly<Record<string, unknown>>;
|
|
8
|
+
export declare const capitalize: (key: string) => string;
|
|
9
|
+
/** A value given in options as a step takes it: a string that starts with `$` is not a reference. */
|
|
10
|
+
export declare function literal(value: unknown): unknown;
|
|
11
|
+
/** The option `key`, checked to be one of the `allowed` options of the use case. */
|
|
12
|
+
export declare function checkOptions(target: UseCaseTargetInfo, options: Options, allowed: readonly string[]): void;
|
|
13
|
+
/** The name, description, tags and `deprecated` of the use case. */
|
|
14
|
+
export declare function metaOf(target: UseCaseTargetInfo, options: Options, verb: string): Pick<UseCaseCompilation, "name" | "description" | "tags" | "deprecated">;
|
|
15
|
+
/** The key of the response that holds the entity: the option `as`, `item` by default. */
|
|
16
|
+
export declare function asOf(target: UseCaseTargetInfo, options: Options): string;
|
|
17
|
+
/** The error of `kind` the options give, else `fallback`. */
|
|
18
|
+
export declare function errorOf(target: UseCaseTargetInfo, options: Options, kind: "notFound" | "conflict" | "invalid" | "owner", fallback: AnyExceptionClass): AnyExceptionClass;
|
|
19
|
+
/** The list of names an option gives, each a key of the entity. */
|
|
20
|
+
export declare function keysOf(target: UseCaseTargetInfo, options: Options, option: string): readonly UseCaseFieldPlan[];
|
|
21
|
+
/** The object an option gives, by key of the entity. */
|
|
22
|
+
export declare function valuesOf(target: UseCaseTargetInfo, options: Options, option: string): Readonly<Record<string, unknown>>;
|
|
23
|
+
/** Who owns the entity, as the option `owner` says. */
|
|
24
|
+
export interface Owner {
|
|
25
|
+
readonly plan: UseCaseFieldPlan;
|
|
26
|
+
/** The key of the context that holds the id of the caller. */
|
|
27
|
+
readonly context: string;
|
|
28
|
+
/** The field of that context key: an id. */
|
|
29
|
+
readonly field: BlueprintField;
|
|
30
|
+
/** The reference to the id of the owner of the entity bound as `item`. */
|
|
31
|
+
readonly reference: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The option `owner: { key?, context }`: `key` (`ownerId` by default) holds
|
|
35
|
+
* the owner, an id or an entity, and `context` names the context key with
|
|
36
|
+
* the id of the caller.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ownerOf(target: UseCaseTargetInfo, options: Options): Owner | undefined;
|
|
39
|
+
/** The context blueprint an owner needs, if there is one. */
|
|
40
|
+
export declare function contextOf(owner: Owner | undefined): Pick<UseCaseCompilation, "context">;
|
|
41
|
+
/**
|
|
42
|
+
* The steps that load the entity of `$input.id` as `item`, throw `notFound`
|
|
43
|
+
* when there is none, and when it is not the caller's.
|
|
44
|
+
*/
|
|
45
|
+
export declare function loadSteps(owner: Owner | undefined, notFound: AnyExceptionClass): Step[];
|
|
46
|
+
/** The id field of the entity of `target`. */
|
|
47
|
+
export declare const idOf: (target: UseCaseTargetInfo) => BlueprintField;
|
|
48
|
+
/** The classes of `errors`, each once. */
|
|
49
|
+
export declare const distinct: (...errors: readonly AnyExceptionClass[]) => AnyExceptionClass[];
|
|
50
|
+
/**
|
|
51
|
+
* 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.
|
|
54
|
+
*/
|
|
55
|
+
export declare function entityUseCase(target: UseCaseTargetInfo, options: Options, verb: string, allowed: readonly string[], steps: (context: {
|
|
56
|
+
readonly owner: Owner | undefined;
|
|
57
|
+
}) => {
|
|
58
|
+
readonly steps: readonly Step[];
|
|
59
|
+
readonly result: string;
|
|
60
|
+
}): UseCaseCompilation;
|