@afora/core 0.0.7 → 0.0.9

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 (99) hide show
  1. package/README.md +157 -25
  2. package/dist/adapters.d.ts +25 -0
  3. package/dist/adapters.js +56 -0
  4. package/dist/core/application/exceptions.d.ts +17 -0
  5. package/dist/core/application/migrate.d.ts +19 -0
  6. package/dist/core/application/schema.d.ts +30 -0
  7. package/dist/core/application/start.d.ts +7 -0
  8. package/dist/core/application/types/application.interface.d.ts +73 -2
  9. package/dist/core/auth/jwt.d.ts +30 -0
  10. package/dist/core/auth/types/jwt.interface.d.ts +66 -0
  11. package/dist/core/blueprint/exceptions.d.ts +5 -0
  12. package/dist/core/blueprint/optional.d.ts +3 -1
  13. package/dist/core/blueprint/types/blueprint.interface.d.ts +79 -5
  14. package/dist/core/blueprint/variant.d.ts +32 -0
  15. package/dist/core/command/types/command.interface.d.ts +7 -0
  16. package/dist/core/entity/abstract-entity.d.ts +33 -1
  17. package/dist/core/entity/entity.d.ts +1 -1
  18. package/dist/core/entity/event.d.ts +13 -2
  19. package/dist/core/entity/exceptions.d.ts +17 -0
  20. package/dist/core/entity/trust.d.ts +24 -0
  21. package/dist/core/entity/types/entity.interface.d.ts +96 -2
  22. package/dist/core/entity/version.d.ts +13 -0
  23. package/dist/core/event-policy/event-policy.d.ts +25 -0
  24. package/dist/core/event-policy/exceptions.d.ts +11 -0
  25. package/dist/core/event-policy/publish.d.ts +17 -0
  26. package/dist/core/event-policy/publishers.d.ts +18 -0
  27. package/dist/core/event-policy/types/event-policy.interface.d.ts +72 -0
  28. package/dist/core/output/access.d.ts +16 -0
  29. package/dist/core/output/coerce.d.ts +9 -0
  30. package/dist/core/output/exceptions.d.ts +16 -0
  31. package/dist/core/output/http.d.ts +36 -0
  32. package/dist/core/output/openapi-sink.d.ts +160 -39
  33. package/dist/core/output/stage.d.ts +7 -2
  34. package/dist/core/output/status.d.ts +2 -2
  35. package/dist/core/output/types/http.interface.d.ts +130 -0
  36. package/dist/core/output/types/output.interface.d.ts +25 -5
  37. package/dist/core/parse/issue.d.ts +28 -3
  38. package/dist/core/parse/parse.d.ts +19 -0
  39. package/dist/core/parse/strip.d.ts +13 -0
  40. package/dist/core/property/abstract-property.d.ts +9 -0
  41. package/dist/core/property/define-property.d.ts +34 -6
  42. package/dist/core/property/types/property-options.interface.d.ts +10 -0
  43. package/dist/core/property/types/property-type.interface.d.ts +4 -0
  44. package/dist/core/record/abstract-record.d.ts +7 -0
  45. package/dist/core/record/types/record.interface.d.ts +12 -1
  46. package/dist/core/repository/exceptions.d.ts +43 -0
  47. package/dist/core/repository/in-memory.d.ts +16 -3
  48. package/dist/core/repository/migrate.d.ts +20 -0
  49. package/dist/core/repository/plan.d.ts +20 -0
  50. package/dist/core/repository/provider.d.ts +1 -1
  51. package/dist/core/repository/query.d.ts +9 -2
  52. package/dist/core/repository/repository.d.ts +40 -8
  53. package/dist/core/repository/state.d.ts +32 -2
  54. package/dist/core/repository/types/query.interface.d.ts +106 -5
  55. package/dist/core/repository/types/repository.interface.d.ts +139 -7
  56. package/dist/core/repository/types/schema.interface.d.ts +126 -0
  57. package/dist/core/repository/upcast.d.ts +64 -0
  58. package/dist/core/schema/schema.d.ts +28 -0
  59. package/dist/core/symbols/kind.d.ts +1 -1
  60. package/dist/core/use-case/access.d.ts +12 -0
  61. package/dist/core/use-case/decorators.d.ts +40 -0
  62. package/dist/core/use-case/route.d.ts +18 -0
  63. package/dist/core/use-case/steps/types/check.interface.d.ts +214 -0
  64. package/dist/core/use-case/types/access.interface.d.ts +39 -0
  65. package/dist/core/use-case/types/route.interface.d.ts +66 -0
  66. package/dist/core/use-case/use-case.d.ts +52 -2
  67. package/dist/experimental.d.ts +13 -1
  68. package/dist/experimental.js +64 -26
  69. package/dist/index-3aae5jfq.js +2997 -0
  70. package/dist/index-hg1z2s2v.js +1055 -0
  71. package/dist/index-ny3as79r.js +4567 -0
  72. package/dist/index-xegv6a1p.js +4291 -0
  73. package/dist/index-y280ew0k.js +396 -0
  74. package/dist/index.d.ts +55 -48
  75. package/dist/index.js +141 -169
  76. package/dist/std/blueprint-plugin.d.ts +6 -2
  77. package/dist/std/blueprint.d.ts +3 -0
  78. package/dist/std/entity.d.ts +2 -1
  79. package/dist/std/event-policies.d.ts +2 -0
  80. package/dist/std/properties/exceptions.d.ts +11 -0
  81. package/dist/std/properties/json.d.ts +54 -0
  82. package/dist/std/properties/password.d.ts +0 -2
  83. package/dist/std/properties/time.d.ts +4 -0
  84. package/dist/std/record-plugins.d.ts +2 -2
  85. package/dist/std/resource.d.ts +31 -0
  86. package/dist/std/runtime.d.ts +6 -0
  87. package/dist/std/use-cases/auth.d.ts +5 -1
  88. package/dist/std/use-cases/crud.d.ts +6 -4
  89. package/dist/std/use-cases/index.d.ts +1 -1
  90. package/dist/std/use-cases/shared.d.ts +34 -6
  91. package/dist/std/use-cases/types.d.ts +197 -22
  92. package/dist/testing/http-provider-contract.d.ts +32 -0
  93. package/dist/testing/index.d.ts +4 -0
  94. package/dist/testing/index.js +839 -3
  95. package/dist/testing/memory-publisher.d.ts +16 -0
  96. package/dist/testing/provider-contract.d.ts +31 -1
  97. package/package.json +17 -3
  98. package/dist/index-q6hggpzw.js +0 -6667
  99. package/dist/index-r78dsvtc.js +0 -1721
@@ -1,47 +1,63 @@
1
1
  import {
2
- isBlueprint2,
3
- isRecordClass2,
4
- recordFieldOf2,
2
+ propertyLineageOf2,
3
+ isBlueprint,
4
+ isRecordClass,
5
+ recordFieldOf,
6
+ InvalidBlueprintVariant2,
7
+ UndeclaredBlueprintProperty2,
8
+ isBlueprintVariant,
5
9
  recordNameOf2,
6
10
  listOf2,
7
- isBlueprintList2,
8
- AbstractRecord2,
9
- declareRecord,
11
+ isBlueprintList,
12
+ AbstractRecord,
10
13
  optionalOf2,
11
- UndeclaredBlueprintProperty2,
12
- blueprintFromProperties
13
- } from "./index-r78dsvtc.js";
14
-
14
+ blueprintFromProperties,
15
+ declareRecord,
16
+ stageDescriptionOf2,
17
+ InvalidJwtOptions2,
18
+ jwtOf2
19
+ } from "./index-xegv6a1p.js";
20
+ import {
21
+ providerDescriptionOf2,
22
+ prepareQuery2,
23
+ sameValue2,
24
+ matchesQuery2,
25
+ selectRows2,
26
+ useCaseTargetOf2,
27
+ useCaseOriginOf2,
28
+ eventPolicyDescriptionOf2,
29
+ eventPolicyCatalogOf2
30
+ } from "./index-3aae5jfq.js";
15
31
  // src/core/blueprint/slice.ts
16
32
  function propertiesOfField(field) {
17
33
  if (field === undefined)
18
34
  return;
19
- if (isBlueprintList2(field))
35
+ if (isBlueprintList(field))
20
36
  return propertiesOfField(field.item);
21
- const record = recordFieldOf2(field);
37
+ const record = recordFieldOf(field);
22
38
  if (record)
23
39
  return record.record.blueprint.properties;
24
- return isBlueprint2(field) ? field.properties : undefined;
40
+ return isBlueprint(field) ? field.properties : undefined;
25
41
  }
26
42
  function maskOf(selector, against) {
27
- if (isRecordClass2(selector))
43
+ if (isRecordClass(selector))
28
44
  return maskOf(selector.blueprint, against);
29
- if (isBlueprint2(selector)) {
45
+ if (isBlueprint(selector)) {
30
46
  return Object.fromEntries(Object.entries(selector.properties).map(([key, field]) => [key, fieldMaskOf(field, against?.[key])]));
31
47
  }
32
48
  return selector;
33
49
  }
34
50
  function fieldMaskOf(field, other) {
35
- if (isBlueprintList2(field)) {
36
- return fieldMaskOf(field.item, isBlueprintList2(other) ? other.item : other);
51
+ if (isBlueprintList(field)) {
52
+ return fieldMaskOf(field.item, isBlueprintList(other) ? other.item : other);
37
53
  }
38
- const record = recordFieldOf2(field);
54
+ const record = recordFieldOf(field);
39
55
  if (record) {
40
- if (record.record === recordFieldOf2(other)?.record)
56
+ if (record.record === recordFieldOf(other)?.record)
41
57
  return true;
42
58
  return maskOf(record.record, propertiesOfField(other));
43
59
  }
44
- if (isBlueprint2(field)) {
60
+ if (isBlueprint(field)) {
45
61
  return field === other ? true : maskOf(field, propertiesOfField(other));
46
62
  }
47
63
  return true;
@@ -66,7 +82,7 @@ function slicedRecordOf(Original, mask, path) {
66
82
  const blueprint = blueprintFromProperties(source.plugins, sliceCollection(source.properties, mask, `${path}.`));
67
83
  const kept = (keys) => keys.filter((key) => Object.hasOwn(blueprint.properties, key));
68
84
  const { sensitive, unique, change } = Original.options;
69
- const Sliced = declareRecord(AbstractRecord2, blueprint, {
85
+ const Sliced = declareRecord(AbstractRecord, blueprint, {
70
86
  sensitive: kept(sensitive),
71
87
  unique: kept(unique),
72
88
  change: kept(change)
@@ -81,22 +97,31 @@ function slicedRecordOf(Original, mask, path) {
81
97
  function sliceField(field, selected, path) {
82
98
  if (selected === true)
83
99
  return field;
84
- if (isBlueprintList2(field)) {
100
+ if (isBlueprintList(field)) {
85
101
  const list = listOf2(sliceField(field.item, selected, path), {
86
102
  minItems: field.minItems,
87
103
  maxItems: field.maxItems
88
104
  });
89
105
  return field.optional ? optionalOf2(list) : list;
90
106
  }
91
- const record = recordFieldOf2(field);
107
+ const record = recordFieldOf(field);
92
108
  if (record) {
93
109
  const sliced = slicedRecordOf(record.record, selected, path);
94
110
  return record.optional ? optionalOf2(sliced) : sliced;
95
111
  }
96
- if (isBlueprint2(field)) {
112
+ if (isBlueprint(field)) {
97
113
  const sliced = blueprintFromProperties(field.plugins, sliceCollection(field.properties, selected, `${path}.`));
98
114
  return field.optional ? optionalOf2(sliced) : sliced;
99
115
  }
116
+ if (isBlueprintVariant(field)) {
117
+ throw new InvalidBlueprintVariant2({
118
+ source: "blueprint",
119
+ details: {
120
+ key: field.key,
121
+ reason: `"${path}" cannot be sliced by its keys yet, only picked whole`
122
+ }
123
+ });
124
+ }
100
125
  throw new UndeclaredBlueprintProperty2({
101
126
  source: "blueprint",
102
127
  details: { key: `${path}.${Object.keys(selected)[0] ?? ""}` }
@@ -109,7 +134,7 @@ function pick(value, mask) {
109
134
  return value.map((item) => pick(item, mask));
110
135
  if (typeof value !== "object" || value === null)
111
136
  return value;
112
- const source = isRecordClass2(value.constructor) ? value.toJSON() : value;
137
+ const source = isRecordClass(value.constructor) ? value.toJSON() : value;
113
138
  const picked = {};
114
139
  for (const [key, selected] of Object.entries(mask)) {
115
140
  if (!selected || !Object.hasOwn(source, key))
@@ -119,6 +144,19 @@ function pick(value, mask) {
119
144
  return picked;
120
145
  }
121
146
  export {
147
+ InvalidJwtOptions2 as InvalidJwtOptions,
148
+ eventPolicyCatalogOf2 as eventPolicyCatalogOf,
149
+ eventPolicyDescriptionOf2 as eventPolicyDescriptionOf,
150
+ jwtOf2 as jwtOf,
151
+ matchesQuery2 as matchesQuery,
152
+ prepareQuery2 as prepareQuery,
153
+ propertyLineageOf2 as propertyLineageOf,
154
+ providerDescriptionOf2 as providerDescriptionOf,
155
+ sameValue2 as sameValue,
156
+ selectRows2 as selectRows,
122
157
  sliceOf,
123
- sliceValue
158
+ sliceValue,
159
+ stageDescriptionOf2 as stageDescriptionOf,
160
+ useCaseOriginOf2 as useCaseOriginOf,
161
+ useCaseTargetOf2 as useCaseTargetOf
124
162
  };