@afora/core 0.0.5 → 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.
Files changed (50) hide show
  1. package/README.md +4 -1
  2. package/dist/core/application/types/application.interface.d.ts +56 -11
  3. package/dist/core/blueprint/types/slice.interface.d.ts +5 -2
  4. package/dist/core/command/command.d.ts +11 -4
  5. package/dist/core/command/types/command.interface.d.ts +19 -0
  6. package/dist/core/entity/abstract-entity.d.ts +1 -1
  7. package/dist/core/entity/types/entity.interface.d.ts +13 -7
  8. package/dist/core/exception/exception.d.ts +10 -1
  9. package/dist/core/output/status.d.ts +4 -3
  10. package/dist/core/property/input.d.ts +20 -0
  11. package/dist/core/property/property.d.ts +4 -4
  12. package/dist/core/property/types/optional-property.type.d.ts +2 -2
  13. package/dist/core/property/types/property-type.interface.d.ts +17 -0
  14. package/dist/core/record/abstract-record.d.ts +4 -4
  15. package/dist/core/record/exceptions.d.ts +2 -0
  16. package/dist/core/record/name.d.ts +16 -0
  17. package/dist/core/record/plugin.d.ts +6 -2
  18. package/dist/core/record/record.d.ts +4 -3
  19. package/dist/core/record/types/plugin.interface.d.ts +11 -0
  20. package/dist/core/record/types/record.interface.d.ts +71 -10
  21. package/dist/core/repository/cursor.d.ts +13 -0
  22. package/dist/core/repository/exceptions.d.ts +10 -0
  23. package/dist/core/repository/query.d.ts +4 -4
  24. package/dist/core/repository/repository.d.ts +2 -2
  25. package/dist/core/repository/state.d.ts +9 -0
  26. package/dist/core/repository/types/query.interface.d.ts +37 -0
  27. package/dist/core/repository/types/repository.interface.d.ts +17 -6
  28. package/dist/core/use-case/exceptions.d.ts +36 -0
  29. package/dist/core/use-case/plugin-catalog.d.ts +11 -0
  30. package/dist/core/use-case/plugin.d.ts +25 -0
  31. package/dist/core/use-case/steps/types/steps.interface.d.ts +24 -7
  32. package/dist/core/use-case/target.d.ts +9 -0
  33. package/dist/core/use-case/types/plugin.interface.d.ts +185 -0
  34. package/dist/experimental.js +4 -3
  35. package/dist/{index-8m80wjzf.js → index-q6hggpzw.js} +1210 -85
  36. package/dist/{index-hn82hm31.js → index-r78dsvtc.js} +136 -66
  37. package/dist/index.d.ts +22 -12
  38. package/dist/index.js +47 -5
  39. package/dist/std/command.d.ts +11 -0
  40. package/dist/std/properties/password.d.ts +21 -2
  41. package/dist/std/record-plugins.d.ts +5 -5
  42. package/dist/std/use-cases/auth.d.ts +5 -0
  43. package/dist/std/use-cases/crud.d.ts +23 -0
  44. package/dist/std/use-cases/index.d.ts +11 -0
  45. package/dist/std/use-cases/lifecycle.d.ts +13 -0
  46. package/dist/std/use-cases/shared.d.ts +60 -0
  47. package/dist/std/use-cases/types.d.ts +212 -0
  48. package/dist/testing/index.js +99 -2
  49. package/dist/testing/provider-contract.d.ts +5 -0
  50. package/package.json +1 -1
@@ -17,6 +17,7 @@ var __export = (target, all) => {
17
17
  var exports_exceptions = {};
18
18
  __export(exports_exceptions, {
19
19
  IncompatibleRecordPlugin: () => IncompatibleRecordPlugin2,
20
+ InvalidRecordDeclaration: () => InvalidRecordDeclaration2,
20
21
  InvalidRecordPlugin: () => InvalidRecordPlugin2,
21
22
  InvalidRecordValue: () => InvalidRecordValue2,
22
23
  RecordPluginConflict: () => RecordPluginConflict2,
@@ -307,6 +308,31 @@ function recordFieldOf2(field) {
307
308
  return;
308
309
  }
309
310
 
311
+ // src/core/record/name.ts
312
+ var RECORD_NAME = /^[A-Za-z_$][\w$]*$/;
313
+ function isRecordName(name) {
314
+ return typeof name === "string" && RECORD_NAME.test(name);
315
+ }
316
+ function recordNameOf2(Class) {
317
+ const { recordName, name } = Class;
318
+ return typeof recordName === "string" ? recordName : String(name);
319
+ }
320
+ var declaredNames = new WeakMap;
321
+ function declareRecordName(Class, name) {
322
+ declaredNames.set(Class, name);
323
+ }
324
+ function declaredRecordNameOf(Class) {
325
+ for (let current = Class;typeof current === "function"; current = Object.getPrototypeOf(current)) {
326
+ const own = Object.getOwnPropertyDescriptor(current, "recordName")?.value;
327
+ if (typeof own === "string")
328
+ return own;
329
+ const declared = declaredNames.get(current);
330
+ if (declared !== undefined)
331
+ return declared;
332
+ }
333
+ return;
334
+ }
335
+
310
336
  // src/core/parse/issue.ts
311
337
  function withLazyCause(issue, build) {
312
338
  let cause;
@@ -454,7 +480,7 @@ function fieldAt(field, value, parent, key, source) {
454
480
  if (value instanceof record.record)
455
481
  return { value };
456
482
  if (!isPlainObject(value)) {
457
- return rejection("not_record", `must be an instance of record "${record.record.name}"`, pathAt(parent, key), source);
483
+ return rejection("not_record", `must be an instance of record "${recordNameOf2(record.record)}"`, pathAt(parent, key), source);
458
484
  }
459
485
  const result = record.record.safeParse(value);
460
486
  return result.issues ? underPath(result, pathAt(parent, key)) : result;
@@ -587,14 +613,16 @@ class Exception2 extends Error {
587
613
  message = this.message,
588
614
  details
589
615
  }) {
590
- return new Exception2({
616
+ const keepsClass = name === this.name && details === undefined && isDeclaredInstance(this);
617
+ const init = {
591
618
  layer,
592
619
  source,
593
620
  name,
594
621
  message,
595
- details,
622
+ details: keepsClass ? this.details : details,
596
623
  cause: this
597
- });
624
+ };
625
+ return keepsClass ? Reflect.construct(Exception2, [init], this.constructor) : new Exception2(init);
598
626
  }
599
627
  toJSON() {
600
628
  return { ...this.frame, trace: this.trace };
@@ -612,6 +640,13 @@ class Exception2 extends Error {
612
640
  }
613
641
  }
614
642
  var declarations = new WeakMap;
643
+ function isDeclaredInstance(exception) {
644
+ for (let current = exception.constructor;typeof current === "function"; current = Object.getPrototypeOf(current)) {
645
+ if (declarations.has(current))
646
+ return true;
647
+ }
648
+ return false;
649
+ }
615
650
  function isDeclaredException(value) {
616
651
  return typeof value === "function" && declarations.has(value);
617
652
  }
@@ -660,6 +695,11 @@ var InvalidRecordValue2 = exceptionOf2({
660
695
  errors
661
696
  }, source) => `Invalid value for ${key ? `"${key}" of ` : ""}record "${source}": ${errors.join("; ")}`
662
697
  });
698
+ var InvalidRecordDeclaration2 = exceptionOf2({
699
+ layer: "record" /* Record */,
700
+ name: "InvalidRecordDeclaration",
701
+ message: (reason, source) => `Invalid declaration of record "${source}": ${reason}`
702
+ });
663
703
  var UndeclaredRecordProperty2 = exceptionOf2({
664
704
  layer: "record" /* Record */,
665
705
  name: "UndeclaredRecordProperty",
@@ -781,7 +821,10 @@ function checkMembers(record, keys) {
781
821
  for (let prototype = Object.getPrototypeOf(record);prototype !== null && !Object.hasOwn(prototype.constructor, "blueprint"); prototype = Object.getPrototypeOf(prototype)) {
782
822
  const key = Object.getOwnPropertyNames(prototype).find((name) => keys.includes(name));
783
823
  if (key !== undefined) {
784
- throw new ReservedRecordKey2({ source: Class.name, details: { key } });
824
+ throw new ReservedRecordKey2({
825
+ source: recordNameOf2(Class),
826
+ details: { key }
827
+ });
785
828
  }
786
829
  }
787
830
  checked.add(Class);
@@ -837,7 +880,7 @@ function parseRecord(Class, value) {
837
880
  try {
838
881
  return { value: new Class(value) };
839
882
  } catch (error) {
840
- return { issues: issuesOfError(error, Class.name) };
883
+ return { issues: issuesOfError(error, recordNameOf2(Class)) };
841
884
  }
842
885
  }
843
886
  function recordValue(record) {
@@ -868,7 +911,7 @@ function recordFieldDataOf(field, value, options) {
868
911
  return value;
869
912
  }
870
913
  function storeRecordValue(record, key, value) {
871
- const source = record.constructor.name;
914
+ const source = recordNameOf2(record.constructor);
872
915
  const { properties } = record[Meta2].blueprint;
873
916
  if (!Object.hasOwn(properties, key)) {
874
917
  throw exceptionOfIssues([
@@ -921,7 +964,7 @@ class AbstractRecord2 {
921
964
  }
922
965
  constructor(value) {
923
966
  checkMembers(this, Object.keys(this[Meta2].blueprint.properties));
924
- const source = this.constructor.name;
967
+ const source = recordNameOf2(this.constructor);
925
968
  const result = parseCollection(this[Meta2].blueprint.properties, value, [], source);
926
969
  if (result.issues)
927
970
  throw exceptionOfIssues(result.issues, source);
@@ -957,6 +1000,17 @@ function versionParts(version) {
957
1000
  const [, major, minor, patch] = SEMVER.exec(version);
958
1001
  return [Number(major), Number(minor), Number(patch)];
959
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
+ }
960
1014
  var HOOKS = ["onSet", "onSetAll"];
961
1015
  var internals = new WeakMap;
962
1016
  function pluginsOf2(value) {
@@ -1140,7 +1194,14 @@ function pluginContextOf(catalogs) {
1140
1194
  return Object.freeze(Object.assign({}, ...catalogs.map((catalog) => catalog.plugins)));
1141
1195
  }
1142
1196
  var recordOf3 = recordBuilderOf2();
1143
- function declareRecord(Base, declared, { plugins = [], ...declaredOptions }, name, reserved = [], context = {}) {
1197
+ function declareRecord(Base, declared, { plugins = [], name: declaredName, ...declaredOptions }, fallback, reserved = [], context = {}) {
1198
+ if (declaredName !== undefined && !isRecordName(declaredName)) {
1199
+ throw new InvalidRecordDeclaration2({
1200
+ source: fallback,
1201
+ details: `"name" must be an identifier, got ${JSON.stringify(declaredName)}.`
1202
+ });
1203
+ }
1204
+ const name = declaredName ?? fallback;
1144
1205
  const applied = applyPlugins(declared, typeof plugins === "function" ? plugins(context) : plugins, name, reserved);
1145
1206
  const blueprint = applied.blueprint;
1146
1207
  const sensitive = [
@@ -1192,6 +1253,15 @@ function declareRecord(Base, declared, { plugins = [], ...declaredOptions }, nam
1192
1253
  static [RecordPlugins] = applied.plugins;
1193
1254
  static [RecordPluginHooks] = applied.hooks;
1194
1255
  }
1256
+ if (declaredName !== undefined) {
1257
+ declareRecordName(DeclaredRecord, declaredName);
1258
+ }
1259
+ Object.defineProperty(DeclaredRecord, "recordName", {
1260
+ get() {
1261
+ return declaredName ?? this.name;
1262
+ },
1263
+ configurable: true
1264
+ });
1195
1265
  exposeRecordKeys(DeclaredRecord.prototype, keys);
1196
1266
  for (const [member, descriptor] of Object.entries(applied.descriptors)) {
1197
1267
  Object.defineProperty(DeclaredRecord.prototype, member, descriptor);
@@ -1218,6 +1288,60 @@ function declareRecord(Base, declared, { plugins = [], ...declaredOptions }, nam
1218
1288
  var CHANGE_MEMBER = "change";
1219
1289
  var changeNamespaces = new WeakMap;
1220
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
+
1221
1345
  // src/core/blueprint/exceptions.ts
1222
1346
  var ReservedBlueprintKey2 = exceptionOf2({
1223
1347
  layer: "blueprint" /* Blueprint */,
@@ -1246,7 +1370,7 @@ var InvalidPropertyValue2 = exceptionOf2({
1246
1370
  import { Type as Type3 } from "typebox";
1247
1371
 
1248
1372
  // src/core/property/property.ts
1249
- import { Type } from "typebox";
1373
+ import { Type as Type2 } from "typebox";
1250
1374
 
1251
1375
  // src/core/symbols/state.ts
1252
1376
  var State2 = Symbol("state");
@@ -1464,7 +1588,7 @@ function propertyOf2({
1464
1588
  preHandle: onPreHandle,
1465
1589
  afterHandle: onAfterHandle
1466
1590
  }) {
1467
- const valueSchema = optional ? Type.Optional(schema) : schema;
1591
+ const valueSchema = optional ? Type2.Optional(schema) : schema;
1468
1592
  const SchemaConstructor = schemaOf2(name, valueSchema);
1469
1593
  const type = {
1470
1594
  [Demo2]: _default,
@@ -1496,60 +1620,6 @@ function propertyOf2({
1496
1620
  return Property;
1497
1621
  }
1498
1622
 
1499
- // src/core/blueprint/optional.ts
1500
- import { Type as Type2 } from "typebox";
1501
- var cache2 = new WeakMap;
1502
- function optionalOf2(given) {
1503
- const field = fieldOf(given);
1504
- const cached = cache2.get(field);
1505
- if (cached)
1506
- return cached;
1507
- if (isOptionalRecord2(field))
1508
- return field;
1509
- if (isRecordClass2(field)) {
1510
- const optional = Object.freeze(withStandard({
1511
- [Kind2]: "record",
1512
- record: field,
1513
- optional: true
1514
- }, (value) => value === undefined ? { value } : field.safeParse(value)));
1515
- cache2.set(field, optional);
1516
- return optional;
1517
- }
1518
- if (isBlueprint2(field)) {
1519
- if (field.optional)
1520
- return field;
1521
- const optional = {
1522
- ...field,
1523
- optional: true,
1524
- safeParse: (value) => value === undefined ? { value } : field.safeParse(value)
1525
- };
1526
- Object.freeze(withStandard(optional, (value) => optional.safeParse(value)));
1527
- cache2.set(field, optional);
1528
- return optional;
1529
- }
1530
- if (isBlueprintList2(field)) {
1531
- if (field.optional)
1532
- return field;
1533
- const optional = standardListOf({ ...field, optional: true });
1534
- cache2.set(field, optional);
1535
- return optional;
1536
- }
1537
- const Property = field;
1538
- if (Property.type.optional)
1539
- return Property;
1540
- const base = Property.type;
1541
- const SchemaConstructor = schemaOf2(base.name, Type2.Optional(base.schema.type.Type()));
1542
- const type = {
1543
- ...base,
1544
- schema: new SchemaConstructor,
1545
- optional: true
1546
- };
1547
- const Optional = derivePropertyOf(Property, type);
1548
- recordPropertyLineage(Optional, { kind: "optional", base: Property });
1549
- cache2.set(Property, Optional);
1550
- return Optional;
1551
- }
1552
-
1553
1623
  // src/core/blueprint/blueprint.ts
1554
1624
  function blueprintBuilderOf2(...base) {
1555
1625
  return (sourcesOrDefine, maybeDefine) => {
@@ -1648,4 +1718,4 @@ function schemaOfField(key, field) {
1648
1718
  });
1649
1719
  }
1650
1720
 
1651
- export { __export, isProperty2, schemaOf2, Demo2, recordPropertyLineage, propertyLineageOf2, fieldOf, Kind2, isBlueprint2, isRecordClass2, isOptionalRecord2, recordFieldOf2, listOf2, isBlueprintList2, ExceptionLayers2, UNEXPECTED_ERROR2, Exception2, isDeclaredException, declaredMessageOf, exceptionOf2, Meta2, InvalidRecordValue2, UndeclaredRecordProperty2, ReservedRecordKey2, InvalidRecordPlugin2, RecordPluginConflict2, UnknownRecordPlugin2, IncompatibleRecordPlugin2, exports_exceptions, MASK2, RESERVED_RECORD_KEYS2, recordDataOf, recordFieldDataOf, storeRecordValue, runRecordEffects, AbstractRecord2, IdentifiedRecord, isVersion, versionParts, pluginsOf2, isRecordPlugin2, hasPlugin2, recordPluginOf2, recordBuilderOf2, pluginContextOf, recordOf3, declareRecord, ReservedBlueprintKey2, UndeclaredBlueprintProperty2, exports_exceptions2, PropertyRequired2, InvalidPropertyValue2, exports_exceptions3, State2, AbstractProperty2, PropertyStates2, AbstractDefineProperty2, propertyOf2, optionalOf2, blueprintBuilderOf2, blueprintFromProperties };
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
@@ -3,7 +3,7 @@ export { ApplicationAlreadyStarted, ApplicationConflict, ApplicationNotStarted,
3
3
  export { isProviderSlot, isProviderStorage, type ProviderSlot, type ProviderStorage, providersOf, } from "./core/application/providers.js";
4
4
  export { type Register, type RegisteredApplication, resetApplication, useApplication, } from "./core/application/registry.js";
5
5
  export { isLogFactory, isProviderFactory, type LogFactory, logFrom, type ProviderFactory, providerFrom, } from "./core/application/start.js";
6
- export type { AnyApplication, ApplicationCollections, ApplicationContext, ApplicationDescription, ApplicationSettings, ApplicationStartOptions, CommandDescription, ExceptionDescription, FieldDescription, FieldsDescription, IApplication, LogDescription, OutputDescription, PropertyDescription, PropertyLineageDescription, PropertyReference, ProviderReference, RecordDescription, UseCaseDependencyDescription, UseCaseDescription, } from "./core/application/types/application.interface.js";
6
+ export type { AnyApplication, ApplicationCollections, ApplicationContext, ApplicationDescription, ApplicationRunArgs, ApplicationRunOptions, ApplicationSettings, ApplicationStartOptions, CommandDescription, ExceptionDescription, FieldDescription, FieldsDescription, IApplication, LogDescription, OutputDescription, PropertyDescription, PropertyLineageDescription, PropertyReference, ProviderReference, RecordDescription, UseCaseDependencyDescription, UseCaseDescription, } from "./core/application/types/application.interface.js";
7
7
  export { blueprintBuilderOf } from "./core/blueprint/blueprint.js";
8
8
  export { blueprintPluginOf } from "./core/blueprint/blueprint-plugin.js";
9
9
  export { ReservedBlueprintKey, UndeclaredBlueprintProperty, } from "./core/blueprint/exceptions.js";
@@ -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 { commandOf, isCommand } from "./core/command/command.js";
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";
@@ -62,23 +64,24 @@ export type { IProperty } from "./core/property/types/property.interface.js";
62
64
  export type { AnyPropertyConstructor, IPropertyCollection, } from "./core/property/types/property-collection.type.js";
63
65
  export type { PropertyValue } from "./core/property/types/property-constructor.type.js";
64
66
  export type { CallableProperty, NumberConstraints, PropertyMetadata, PropertyOptions, StringConstraints, } from "./core/property/types/property-options.interface.js";
65
- export type { IPropertyType, UniqueMark, } from "./core/property/types/property-type.interface.js";
67
+ export type { IPropertyType, SensitiveMark, UniqueMark, } from "./core/property/types/property-type.interface.js";
66
68
  export { AbstractRecord, RESERVED_RECORD_KEYS, } from "./core/record/abstract-record.js";
67
- export { IncompatibleRecordPlugin, InvalidRecordPlugin, InvalidRecordValue, RecordPluginConflict, ReservedRecordKey, UndeclaredRecordProperty, UnknownRecordPlugin, } from "./core/record/exceptions.js";
69
+ export { IncompatibleRecordPlugin, InvalidRecordDeclaration, InvalidRecordPlugin, InvalidRecordValue, RecordPluginConflict, ReservedRecordKey, UndeclaredRecordProperty, UnknownRecordPlugin, } from "./core/record/exceptions.js";
68
70
  export { MASK } from "./core/record/mask.js";
71
+ export { recordNameOf } from "./core/record/name.js";
69
72
  export { hasPlugin, isRecordPlugin, pluginsOf, recordPluginOf, } from "./core/record/plugin.js";
70
73
  export { recordPluginCatalogOf } from "./core/record/plugin-catalog.js";
71
74
  export type { RecordBuilder } from "./core/record/record.js";
72
75
  export { recordBuilderOf } from "./core/record/record.js";
73
76
  export type { AnyRecordPlugin, IRecordPlugin, IRecordPluginCatalog, PluginUniqueKey, RecordPluginDescriptor, RecordPluginOptions, RecordPluginReference, RecordPluginRequirement, RecordPluginsOption, } from "./core/record/types/plugin.interface.js";
74
- export type { DeclaredRecordInstance, IRecord, MarkedUniqueKey, RecordChange, RecordChanges, RecordConstructor, RecordEffect, RecordEffects, RecordKey, RecordOptions, RecordSettings, RecordValue, } from "./core/record/types/record.interface.js";
75
- export { InvalidRepositoryData, InvalidRepositoryDeclaration, InvalidRepositoryEntity, InvalidRepositoryQuery, RepositoryEntityNotFound, RepositoryUniqueViolation, } from "./core/repository/exceptions.js";
77
+ 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";
76
79
  export { inMemoryProvider } from "./core/repository/in-memory.js";
77
80
  export { providerDescriptionOf, providerOf } from "./core/repository/provider.js";
78
81
  export type { RepositorySettings } from "./core/repository/repository.js";
79
82
  export { AbstractRepository, isRepository, RepositoryOf, repositoryOf, } from "./core/repository/repository.js";
80
- export type { ProviderCapabilities, ProviderDescription, ProviderOption, ProviderOptions, ProviderSettings, RepositoryExists, RepositoryFindMany, RepositoryFindPage, RepositoryOrder, RepositoryPage, RepositoryQuery, RepositoryWhere, } from "./core/repository/types/query.interface.js";
81
- 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";
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";
82
85
  export type { SchemaClass } from "./core/schema/schema.js";
83
86
  export { schemaOf } from "./core/schema/schema.js";
84
87
  export type { ISchema, ISchemaType, } from "./core/schema/types/schema.interface.js";
@@ -87,19 +90,24 @@ export { Demo } from "./core/symbols/demo.js";
87
90
  export { Kind } from "./core/symbols/kind.js";
88
91
  export { Meta } from "./core/symbols/meta.js";
89
92
  export { State } from "./core/symbols/state.js";
90
- export { InvalidUseCaseStep } from "./core/use-case/exceptions.js";
91
- export type { StepEnsureKind, StepErrorDescription, StepFindTarget, StepReadAction, StepReference, StepRepositoryWith, StepValue, UseCaseStep, UseCaseStepDescription, } from "./core/use-case/steps/types/steps.interface.js";
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";
92
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";
93
100
  export { AbstractUseCase, InvalidUseCaseDeclaration, InvalidUseCaseDependencies, isUseCase, isUseCaseClass, UseCaseAlreadyExecuted, useCaseOf, } from "./core/use-case/use-case.js";
94
101
  export { blueprintOf } from "./std/blueprint.js";
95
102
  export { Std } from "./std/blueprint-plugin.js";
103
+ export { commandOf } from "./std/command.js";
96
104
  export { entityOf } from "./std/entity.js";
97
105
  export { Email, Ip, Phone, Url } from "./std/properties/contact.js";
98
106
  export type { EnumClass } from "./std/properties/enum.js";
99
107
  export { enumOf } from "./std/properties/enum.js";
100
108
  export { SchemaProperty } from "./std/properties/headless.js";
101
109
  export { Id, Slug } from "./std/properties/identity.js";
102
- 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";
103
111
  export { BooleanProperty, Integer, NumberProperty, StringProperty, Text, } from "./std/properties/primitives.js";
104
112
  export { CreatedAt, DateProperty, DateTime, DeletedAt, UpdatedAt, } from "./std/properties/time.js";
105
113
  export { recordOf } from "./std/record.js";
@@ -107,3 +115,5 @@ export { Archivable, Authenticatable, Ownable, Publishable, StdRecordPlugins, Ta
107
115
  export type { IdGenerator, PasswordHasher, RuntimeServices, } from "./std/runtime.js";
108
116
  export { configure, PasswordHasherRequired, resetRuntime, SyncVerifyUnsupported, } from "./std/runtime.js";
109
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
@@ -34,6 +34,7 @@ import {
34
34
  EntityUniqueKeys2,
35
35
  AbstractEntity2,
36
36
  InvalidRepositoryQuery2,
37
+ InvalidRepositoryCursor2,
37
38
  InvalidRepositoryDeclaration2,
38
39
  InvalidRepositoryEntity2,
39
40
  InvalidRepositoryData2,
@@ -47,6 +48,16 @@ import {
47
48
  RepositoryOf2,
48
49
  isRepository2,
49
50
  InvalidUseCaseStep2,
51
+ InvalidUseCasePlugin2,
52
+ UnknownUseCasePlugin2,
53
+ IncompatibleUseCasePlugin2,
54
+ UseCaseUnavailable2,
55
+ UseCaseEntityNotFound2,
56
+ UseCaseEntityConflict2,
57
+ UseCaseInvalidCredentials2,
58
+ PropertyInput2,
59
+ propertyInputOf2,
60
+ useCaseTargetOf2,
50
61
  InvalidUseCaseDeclaration2,
51
62
  UseCaseAlreadyExecuted2,
52
63
  InvalidUseCaseDependencies2,
@@ -54,12 +65,17 @@ import {
54
65
  useCaseOf2,
55
66
  isUseCaseClass2,
56
67
  isUseCase2,
68
+ isUseCasePlugin2,
69
+ useCaseOriginOf2,
70
+ useCasePluginOf2,
71
+ isUseCaseCatalog2,
72
+ useCaseCatalogOf2,
57
73
  InvalidCommandDeclaration2,
58
74
  UnknownCommandOperation2,
59
75
  InvalidCommandContext2,
60
76
  InvalidCommandEnvironment2,
61
77
  CommandEventFailed2,
62
- commandOf2,
78
+ commandBuilderOf2,
63
79
  isCommand2,
64
80
  InvalidOpenAPIModel2,
65
81
  InvalidOutputStage2,
@@ -109,6 +125,7 @@ import {
109
125
  PASSWORD_SPECIAL_CHARACTERS2,
110
126
  isPasswordHash2,
111
127
  passwordIssues2,
128
+ PlainPassword2,
112
129
  Password2,
113
130
  StringProperty2,
114
131
  Text2,
@@ -122,6 +139,8 @@ import {
122
139
  DeletedAt2,
123
140
  Std2,
124
141
  blueprintOf2,
142
+ StdUseCases2,
143
+ commandOf2,
125
144
  Publishable2,
126
145
  Archivable2,
127
146
  Taggable2,
@@ -131,7 +150,7 @@ import {
131
150
  entityOf2,
132
151
  recordOf2,
133
152
  StdStages2
134
- } from "./index-8m80wjzf.js";
153
+ } from "./index-q6hggpzw.js";
135
154
  import {
136
155
  isProperty2,
137
156
  schemaOf2,
@@ -142,6 +161,7 @@ import {
142
161
  isRecordClass2,
143
162
  isOptionalRecord2,
144
163
  recordFieldOf2,
164
+ recordNameOf2,
145
165
  listOf2,
146
166
  isBlueprintList2,
147
167
  ExceptionLayers2,
@@ -150,6 +170,7 @@ import {
150
170
  exceptionOf2,
151
171
  Meta2,
152
172
  InvalidRecordValue2,
173
+ InvalidRecordDeclaration2,
153
174
  UndeclaredRecordProperty2,
154
175
  ReservedRecordKey2,
155
176
  InvalidRecordPlugin2,
@@ -164,6 +185,7 @@ import {
164
185
  hasPlugin2,
165
186
  recordPluginOf2,
166
187
  recordBuilderOf2,
188
+ optionalOf2,
167
189
  ReservedBlueprintKey2,
168
190
  UndeclaredBlueprintProperty2,
169
191
  PropertyRequired2,
@@ -173,9 +195,8 @@ import {
173
195
  PropertyStates2,
174
196
  AbstractDefineProperty2,
175
197
  propertyOf2,
176
- optionalOf2,
177
198
  blueprintBuilderOf2
178
- } from "./index-hn82hm31.js";
199
+ } from "./index-r78dsvtc.js";
179
200
  export {
180
201
  AbstractDefineProperty2 as AbstractDefineProperty,
181
202
  AbstractEntity2 as AbstractEntity,
@@ -206,6 +227,7 @@ export {
206
227
  Id2 as Id,
207
228
  ImmutableEntityKey2 as ImmutableEntityKey,
208
229
  IncompatibleRecordPlugin2 as IncompatibleRecordPlugin,
230
+ IncompatibleUseCasePlugin2 as IncompatibleUseCasePlugin,
209
231
  Integer2 as Integer,
210
232
  InvalidApplicationDeclaration2 as InvalidApplicationDeclaration,
211
233
  InvalidApplicationEnvironment2 as InvalidApplicationEnvironment,
@@ -217,14 +239,17 @@ export {
217
239
  InvalidOpenAPIModel2 as InvalidOpenAPIModel,
218
240
  InvalidOutputStage2 as InvalidOutputStage,
219
241
  InvalidPropertyValue2 as InvalidPropertyValue,
242
+ InvalidRecordDeclaration2 as InvalidRecordDeclaration,
220
243
  InvalidRecordPlugin2 as InvalidRecordPlugin,
221
244
  InvalidRecordValue2 as InvalidRecordValue,
245
+ InvalidRepositoryCursor2 as InvalidRepositoryCursor,
222
246
  InvalidRepositoryData2 as InvalidRepositoryData,
223
247
  InvalidRepositoryDeclaration2 as InvalidRepositoryDeclaration,
224
248
  InvalidRepositoryEntity2 as InvalidRepositoryEntity,
225
249
  InvalidRepositoryQuery2 as InvalidRepositoryQuery,
226
250
  InvalidUseCaseDeclaration2 as InvalidUseCaseDeclaration,
227
251
  InvalidUseCaseDependencies2 as InvalidUseCaseDependencies,
252
+ InvalidUseCasePlugin2 as InvalidUseCasePlugin,
228
253
  InvalidUseCaseStep2 as InvalidUseCaseStep,
229
254
  Ip2 as Ip,
230
255
  Kind2 as Kind,
@@ -241,6 +266,8 @@ export {
241
266
  Password2 as Password,
242
267
  PasswordHasherRequired2 as PasswordHasherRequired,
243
268
  Phone2 as Phone,
269
+ PlainPassword2 as PlainPassword,
270
+ PropertyInput2 as PropertyInput,
244
271
  PropertyRequired2 as PropertyRequired,
245
272
  PropertyStates2 as PropertyStates,
246
273
  ProviderNotBound2 as ProviderNotBound,
@@ -260,6 +287,7 @@ export {
260
287
  Std2 as Std,
261
288
  StdRecordPlugins2 as StdRecordPlugins,
262
289
  StdStages2 as StdStages,
290
+ StdUseCases2 as StdUseCases,
263
291
  StringProperty2 as StringProperty,
264
292
  SyncVerifyUnsupported2 as SyncVerifyUnsupported,
265
293
  Taggable2 as Taggable,
@@ -269,16 +297,22 @@ export {
269
297
  UndeclaredRecordProperty2 as UndeclaredRecordProperty,
270
298
  UnknownCommandOperation2 as UnknownCommandOperation,
271
299
  UnknownRecordPlugin2 as UnknownRecordPlugin,
300
+ UnknownUseCasePlugin2 as UnknownUseCasePlugin,
272
301
  UnregisteredApplicationReference2 as UnregisteredApplicationReference,
273
302
  UnregisteredRepositoryDependency2 as UnregisteredRepositoryDependency,
274
303
  UnregisteredUseCaseDependency2 as UnregisteredUseCaseDependency,
275
304
  UpdatedAt2 as UpdatedAt,
276
305
  Url2 as Url,
277
306
  UseCaseAlreadyExecuted2 as UseCaseAlreadyExecuted,
307
+ UseCaseEntityConflict2 as UseCaseEntityConflict,
308
+ UseCaseEntityNotFound2 as UseCaseEntityNotFound,
309
+ UseCaseInvalidCredentials2 as UseCaseInvalidCredentials,
310
+ UseCaseUnavailable2 as UseCaseUnavailable,
278
311
  applicationOf2 as applicationOf,
279
312
  blueprintBuilderOf2 as blueprintBuilderOf,
280
313
  blueprintOf2 as blueprintOf,
281
314
  blueprintPluginOf2 as blueprintPluginOf,
315
+ commandBuilderOf2 as commandBuilderOf,
282
316
  commandOf2 as commandOf,
283
317
  configure2 as configure,
284
318
  consoleLogProvider2 as consoleLogProvider,
@@ -310,7 +344,9 @@ export {
310
344
  isRecordPlugin2 as isRecordPlugin,
311
345
  isRepository2 as isRepository,
312
346
  isUseCase2 as isUseCase,
347
+ isUseCaseCatalog2 as isUseCaseCatalog,
313
348
  isUseCaseClass2 as isUseCaseClass,
349
+ isUseCasePlugin2 as isUseCasePlugin,
314
350
  jsonLogProvider2 as jsonLogProvider,
315
351
  listOf2 as listOf,
316
352
  logFrom2 as logFrom,
@@ -325,6 +361,7 @@ export {
325
361
  passwordIssues2 as passwordIssues,
326
362
  pluginsOf2 as pluginsOf,
327
363
  problemOf2 as problemOf,
364
+ propertyInputOf2 as propertyInputOf,
328
365
  propertyLineageOf2 as propertyLineageOf,
329
366
  propertyOf2 as propertyOf,
330
367
  providerDescriptionOf2 as providerDescriptionOf,
@@ -333,6 +370,7 @@ export {
333
370
  providersOf2 as providersOf,
334
371
  recordBuilderOf2 as recordBuilderOf,
335
372
  recordFieldOf2 as recordFieldOf,
373
+ recordNameOf2 as recordNameOf,
336
374
  recordOf2 as recordOf,
337
375
  recordPluginCatalogOf2 as recordPluginCatalogOf,
338
376
  recordPluginOf2 as recordPluginOf,
@@ -350,5 +388,9 @@ export {
350
388
  toOpenAPI2 as toOpenAPI,
351
389
  transformOf2 as transformOf,
352
390
  useApplication2 as useApplication,
353
- useCaseOf2 as useCaseOf
391
+ useCaseCatalogOf2 as useCaseCatalogOf,
392
+ useCaseOf2 as useCaseOf,
393
+ useCaseOriginOf2 as useCaseOriginOf,
394
+ useCasePluginOf2 as useCasePluginOf,
395
+ useCaseTargetOf2 as useCaseTargetOf
354
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>;