@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.
- package/README.md +157 -25
- package/dist/adapters.d.ts +25 -0
- package/dist/adapters.js +56 -0
- package/dist/core/application/exceptions.d.ts +17 -0
- package/dist/core/application/migrate.d.ts +19 -0
- package/dist/core/application/schema.d.ts +30 -0
- package/dist/core/application/start.d.ts +7 -0
- package/dist/core/application/types/application.interface.d.ts +73 -2
- package/dist/core/auth/jwt.d.ts +30 -0
- package/dist/core/auth/types/jwt.interface.d.ts +66 -0
- package/dist/core/blueprint/exceptions.d.ts +5 -0
- package/dist/core/blueprint/optional.d.ts +3 -1
- package/dist/core/blueprint/types/blueprint.interface.d.ts +79 -5
- package/dist/core/blueprint/variant.d.ts +32 -0
- package/dist/core/command/types/command.interface.d.ts +7 -0
- package/dist/core/entity/abstract-entity.d.ts +33 -1
- package/dist/core/entity/entity.d.ts +1 -1
- package/dist/core/entity/event.d.ts +13 -2
- package/dist/core/entity/exceptions.d.ts +17 -0
- package/dist/core/entity/trust.d.ts +24 -0
- package/dist/core/entity/types/entity.interface.d.ts +96 -2
- package/dist/core/entity/version.d.ts +13 -0
- package/dist/core/event-policy/event-policy.d.ts +25 -0
- package/dist/core/event-policy/exceptions.d.ts +11 -0
- package/dist/core/event-policy/publish.d.ts +17 -0
- package/dist/core/event-policy/publishers.d.ts +18 -0
- package/dist/core/event-policy/types/event-policy.interface.d.ts +72 -0
- package/dist/core/output/access.d.ts +16 -0
- package/dist/core/output/coerce.d.ts +9 -0
- package/dist/core/output/exceptions.d.ts +16 -0
- package/dist/core/output/http.d.ts +36 -0
- package/dist/core/output/openapi-sink.d.ts +160 -39
- package/dist/core/output/stage.d.ts +7 -2
- package/dist/core/output/status.d.ts +2 -2
- package/dist/core/output/types/http.interface.d.ts +130 -0
- package/dist/core/output/types/output.interface.d.ts +25 -5
- package/dist/core/parse/issue.d.ts +28 -3
- package/dist/core/parse/parse.d.ts +19 -0
- package/dist/core/parse/strip.d.ts +13 -0
- package/dist/core/property/abstract-property.d.ts +9 -0
- package/dist/core/property/define-property.d.ts +34 -6
- package/dist/core/property/types/property-options.interface.d.ts +10 -0
- package/dist/core/property/types/property-type.interface.d.ts +4 -0
- package/dist/core/record/abstract-record.d.ts +7 -0
- package/dist/core/record/types/record.interface.d.ts +12 -1
- package/dist/core/repository/exceptions.d.ts +43 -0
- package/dist/core/repository/in-memory.d.ts +16 -3
- package/dist/core/repository/migrate.d.ts +20 -0
- package/dist/core/repository/plan.d.ts +20 -0
- package/dist/core/repository/provider.d.ts +1 -1
- package/dist/core/repository/query.d.ts +9 -2
- package/dist/core/repository/repository.d.ts +40 -8
- package/dist/core/repository/state.d.ts +32 -2
- package/dist/core/repository/types/query.interface.d.ts +106 -5
- package/dist/core/repository/types/repository.interface.d.ts +139 -7
- package/dist/core/repository/types/schema.interface.d.ts +126 -0
- package/dist/core/repository/upcast.d.ts +64 -0
- package/dist/core/schema/schema.d.ts +28 -0
- package/dist/core/symbols/kind.d.ts +1 -1
- package/dist/core/use-case/access.d.ts +12 -0
- package/dist/core/use-case/decorators.d.ts +40 -0
- package/dist/core/use-case/route.d.ts +18 -0
- package/dist/core/use-case/steps/types/check.interface.d.ts +214 -0
- package/dist/core/use-case/types/access.interface.d.ts +39 -0
- package/dist/core/use-case/types/route.interface.d.ts +66 -0
- package/dist/core/use-case/use-case.d.ts +52 -2
- package/dist/experimental.d.ts +13 -1
- package/dist/experimental.js +64 -26
- package/dist/index-3aae5jfq.js +2997 -0
- package/dist/index-hg1z2s2v.js +1055 -0
- package/dist/index-ny3as79r.js +4567 -0
- package/dist/index-xegv6a1p.js +4291 -0
- package/dist/index-y280ew0k.js +396 -0
- package/dist/index.d.ts +55 -48
- package/dist/index.js +141 -169
- package/dist/std/blueprint-plugin.d.ts +6 -2
- package/dist/std/blueprint.d.ts +3 -0
- package/dist/std/entity.d.ts +2 -1
- package/dist/std/event-policies.d.ts +2 -0
- package/dist/std/properties/exceptions.d.ts +11 -0
- package/dist/std/properties/json.d.ts +54 -0
- package/dist/std/properties/password.d.ts +0 -2
- package/dist/std/properties/time.d.ts +4 -0
- package/dist/std/record-plugins.d.ts +2 -2
- package/dist/std/resource.d.ts +31 -0
- package/dist/std/runtime.d.ts +6 -0
- package/dist/std/use-cases/auth.d.ts +5 -1
- package/dist/std/use-cases/crud.d.ts +6 -4
- package/dist/std/use-cases/index.d.ts +1 -1
- package/dist/std/use-cases/shared.d.ts +34 -6
- package/dist/std/use-cases/types.d.ts +197 -22
- package/dist/testing/http-provider-contract.d.ts +32 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +839 -3
- package/dist/testing/memory-publisher.d.ts +16 -0
- package/dist/testing/provider-contract.d.ts +31 -1
- package/package.json +17 -3
- package/dist/index-q6hggpzw.js +0 -6667
- package/dist/index-r78dsvtc.js +0 -1721
package/dist/experimental.js
CHANGED
|
@@ -1,47 +1,63 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
propertyLineageOf2,
|
|
3
|
+
isBlueprint,
|
|
4
|
+
isRecordClass,
|
|
5
|
+
recordFieldOf,
|
|
6
|
+
InvalidBlueprintVariant2,
|
|
7
|
+
UndeclaredBlueprintProperty2,
|
|
8
|
+
isBlueprintVariant,
|
|
5
9
|
recordNameOf2,
|
|
6
10
|
listOf2,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declareRecord,
|
|
11
|
+
isBlueprintList,
|
|
12
|
+
AbstractRecord,
|
|
10
13
|
optionalOf2,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 (
|
|
35
|
+
if (isBlueprintList(field))
|
|
20
36
|
return propertiesOfField(field.item);
|
|
21
|
-
const record =
|
|
37
|
+
const record = recordFieldOf(field);
|
|
22
38
|
if (record)
|
|
23
39
|
return record.record.blueprint.properties;
|
|
24
|
-
return
|
|
40
|
+
return isBlueprint(field) ? field.properties : undefined;
|
|
25
41
|
}
|
|
26
42
|
function maskOf(selector, against) {
|
|
27
|
-
if (
|
|
43
|
+
if (isRecordClass(selector))
|
|
28
44
|
return maskOf(selector.blueprint, against);
|
|
29
|
-
if (
|
|
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 (
|
|
36
|
-
return fieldMaskOf(field.item,
|
|
51
|
+
if (isBlueprintList(field)) {
|
|
52
|
+
return fieldMaskOf(field.item, isBlueprintList(other) ? other.item : other);
|
|
37
53
|
}
|
|
38
|
-
const record =
|
|
54
|
+
const record = recordFieldOf(field);
|
|
39
55
|
if (record) {
|
|
40
|
-
if (record.record ===
|
|
56
|
+
if (record.record === recordFieldOf(other)?.record)
|
|
41
57
|
return true;
|
|
42
58
|
return maskOf(record.record, propertiesOfField(other));
|
|
43
59
|
}
|
|
44
|
-
if (
|
|
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(
|
|
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 (
|
|
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 =
|
|
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 (
|
|
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 =
|
|
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
|
};
|