@adaas/a-concept 0.3.3 → 0.3.5
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/dist/browser/index.d.mts +37 -12
- package/dist/browser/index.mjs +2 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/index.cjs +78 -26
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.mts +37 -12
- package/dist/node/index.d.ts +37 -12
- package/dist/node/index.mjs +78 -26
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Abstraction/A-Abstraction-Extend.decorator.ts +1 -1
- package/src/lib/A-Component/A-Component.meta.ts +1 -1
- package/src/lib/A-Container/A-Container.meta.ts +1 -1
- package/src/lib/A-Context/A-Context.class.ts +14 -2
- package/src/lib/A-Entity/A-Entity.class.ts +10 -9
- package/src/lib/A-Entity/A-Entity.constants.ts +5 -5
- package/src/lib/A-Entity/A-Entity.meta.ts +1 -1
- package/src/lib/A-Entity/A-Entity.types.ts +2 -1
- package/src/lib/A-Scope/A-Scope.class.ts +8 -3
- package/src/lib/A-StepManager/A-StepManager.class.ts +59 -5
- package/tests/A-Feature.test.ts +76 -0
package/dist/node/index.cjs
CHANGED
|
@@ -964,6 +964,20 @@ var A_EntityError = class extends A_Error {
|
|
|
964
964
|
*/
|
|
965
965
|
A_EntityError.ValidationError = "A-Entity Validation Error";
|
|
966
966
|
|
|
967
|
+
// src/lib/A-Entity/A-Entity.constants.ts
|
|
968
|
+
var A_TYPES__EntityMetaKey = /* @__PURE__ */ ((A_TYPES__EntityMetaKey2) => {
|
|
969
|
+
A_TYPES__EntityMetaKey2["EXTENSIONS"] = "a-component-extensions";
|
|
970
|
+
A_TYPES__EntityMetaKey2["FEATURES"] = "a-component-features";
|
|
971
|
+
A_TYPES__EntityMetaKey2["ABSTRACTIONS"] = "a-component-abstractions";
|
|
972
|
+
A_TYPES__EntityMetaKey2["INJECTIONS"] = "a-component-injections";
|
|
973
|
+
return A_TYPES__EntityMetaKey2;
|
|
974
|
+
})(A_TYPES__EntityMetaKey || {});
|
|
975
|
+
var A_TYPES__EntityFeatures = {
|
|
976
|
+
SAVE: "_A_Entity__Save",
|
|
977
|
+
DESTROY: "_A_Entity__Destroy",
|
|
978
|
+
LOAD: "_A_Entity__Load"
|
|
979
|
+
};
|
|
980
|
+
|
|
967
981
|
// src/lib/A-Entity/A-Entity.class.ts
|
|
968
982
|
var A_Entity = class {
|
|
969
983
|
// ====================================================================
|
|
@@ -1119,20 +1133,20 @@ var A_Entity = class {
|
|
|
1119
1133
|
/**
|
|
1120
1134
|
* The default method that can be called and extended to load entity data.
|
|
1121
1135
|
*/
|
|
1122
|
-
|
|
1123
|
-
return this.call(
|
|
1136
|
+
load(scope) {
|
|
1137
|
+
return this.call(A_TYPES__EntityFeatures.LOAD, scope);
|
|
1124
1138
|
}
|
|
1125
1139
|
/**
|
|
1126
1140
|
* The default method that can be called and extended to destroy entity data.
|
|
1127
1141
|
*/
|
|
1128
|
-
|
|
1129
|
-
return this.call(
|
|
1142
|
+
destroy(scope) {
|
|
1143
|
+
return this.call(A_TYPES__EntityFeatures.DESTROY, scope);
|
|
1130
1144
|
}
|
|
1131
1145
|
/**
|
|
1132
1146
|
* The default method that can be called and extended to save entity data.
|
|
1133
1147
|
*/
|
|
1134
|
-
|
|
1135
|
-
return this.call(
|
|
1148
|
+
save(scope) {
|
|
1149
|
+
return this.call(A_TYPES__EntityFeatures.SAVE, scope);
|
|
1136
1150
|
}
|
|
1137
1151
|
// ====================================================================
|
|
1138
1152
|
// ================== Entity Serialization ============================
|
|
@@ -1431,21 +1445,6 @@ var A_Meta = class _A_Meta {
|
|
|
1431
1445
|
}
|
|
1432
1446
|
};
|
|
1433
1447
|
|
|
1434
|
-
// src/lib/A-Entity/A-Entity.constants.ts
|
|
1435
|
-
var A_TYPES__EntityMetaKey = /* @__PURE__ */ ((A_TYPES__EntityMetaKey2) => {
|
|
1436
|
-
A_TYPES__EntityMetaKey2["EXTENSIONS"] = "a-component-extensions";
|
|
1437
|
-
A_TYPES__EntityMetaKey2["FEATURES"] = "a-component-features";
|
|
1438
|
-
A_TYPES__EntityMetaKey2["ABSTRACTIONS"] = "a-component-abstractions";
|
|
1439
|
-
A_TYPES__EntityMetaKey2["INJECTIONS"] = "a-component-injections";
|
|
1440
|
-
return A_TYPES__EntityMetaKey2;
|
|
1441
|
-
})(A_TYPES__EntityMetaKey || {});
|
|
1442
|
-
var A_TYPES__EntityFeatures = /* @__PURE__ */ ((A_TYPES__EntityFeatures2) => {
|
|
1443
|
-
A_TYPES__EntityFeatures2["SAVE"] = "save";
|
|
1444
|
-
A_TYPES__EntityFeatures2["DESTROY"] = "destroy";
|
|
1445
|
-
A_TYPES__EntityFeatures2["LOAD"] = "load";
|
|
1446
|
-
return A_TYPES__EntityFeatures2;
|
|
1447
|
-
})(A_TYPES__EntityFeatures || {});
|
|
1448
|
-
|
|
1449
1448
|
// src/lib/A-Entity/A-Entity.meta.ts
|
|
1450
1449
|
var A_EntityMeta = class extends A_Meta {
|
|
1451
1450
|
/**
|
|
@@ -3056,12 +3055,18 @@ A_StepManagerError.CircularDependencyError = "A-StepManager Circular Dependency
|
|
|
3056
3055
|
// src/lib/A-StepManager/A-StepManager.class.ts
|
|
3057
3056
|
var A_StepsManager = class {
|
|
3058
3057
|
constructor(entities) {
|
|
3058
|
+
/**
|
|
3059
|
+
* Maps each step instance to a unique ID.
|
|
3060
|
+
* Duplicate steps (same dependency.name + handler) get indexed suffixes (e.g., #1, #2).
|
|
3061
|
+
*/
|
|
3062
|
+
this._uniqueIdMap = /* @__PURE__ */ new Map();
|
|
3059
3063
|
this._isBuilt = false;
|
|
3060
3064
|
this.entities = this.prepareSteps(entities);
|
|
3061
3065
|
this.graph = /* @__PURE__ */ new Map();
|
|
3062
3066
|
this.visited = /* @__PURE__ */ new Set();
|
|
3063
3067
|
this.tempMark = /* @__PURE__ */ new Set();
|
|
3064
3068
|
this.sortedEntities = [];
|
|
3069
|
+
this.assignUniqueIds();
|
|
3065
3070
|
}
|
|
3066
3071
|
prepareSteps(entities) {
|
|
3067
3072
|
return entities.map((step) => ({
|
|
@@ -3073,15 +3078,54 @@ var A_StepsManager = class {
|
|
|
3073
3078
|
throwOnError: false
|
|
3074
3079
|
}));
|
|
3075
3080
|
}
|
|
3076
|
-
|
|
3081
|
+
/**
|
|
3082
|
+
* Returns the base (non-unique) ID for a step: `dependency.name.handler`
|
|
3083
|
+
*/
|
|
3084
|
+
baseID(step) {
|
|
3077
3085
|
return `${step.dependency.name}.${step.handler}`;
|
|
3078
3086
|
}
|
|
3087
|
+
/**
|
|
3088
|
+
* Returns the unique ID assigned to a specific step instance.
|
|
3089
|
+
* Falls back to baseID if not yet assigned.
|
|
3090
|
+
*/
|
|
3091
|
+
ID(step) {
|
|
3092
|
+
return this._uniqueIdMap.get(step) || this.baseID(step);
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* Assigns unique IDs to all steps.
|
|
3096
|
+
* Duplicate base IDs get an index suffix (#0, #1, ...).
|
|
3097
|
+
* Steps with unique base IDs keep their original ID (no suffix).
|
|
3098
|
+
*/
|
|
3099
|
+
assignUniqueIds() {
|
|
3100
|
+
const counts = /* @__PURE__ */ new Map();
|
|
3101
|
+
for (const step of this.entities) {
|
|
3102
|
+
const base = this.baseID(step);
|
|
3103
|
+
counts.set(base, (counts.get(base) || 0) + 1);
|
|
3104
|
+
}
|
|
3105
|
+
const indexTracker = /* @__PURE__ */ new Map();
|
|
3106
|
+
for (const step of this.entities) {
|
|
3107
|
+
const base = this.baseID(step);
|
|
3108
|
+
if (counts.get(base) > 1) {
|
|
3109
|
+
const idx = indexTracker.get(base) || 0;
|
|
3110
|
+
this._uniqueIdMap.set(step, `${base}#${idx}`);
|
|
3111
|
+
indexTracker.set(base, idx + 1);
|
|
3112
|
+
} else {
|
|
3113
|
+
this._uniqueIdMap.set(step, base);
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3079
3117
|
buildGraph() {
|
|
3080
3118
|
if (this._isBuilt) return;
|
|
3081
3119
|
this._isBuilt = true;
|
|
3082
3120
|
this.entities = this.entities.filter(
|
|
3083
|
-
(step, i, self) => !self.some((s) =>
|
|
3121
|
+
(step, i, self) => !self.some((s, j) => {
|
|
3122
|
+
if (i === j || !s.override) return false;
|
|
3123
|
+
const re = new RegExp(s.override);
|
|
3124
|
+
return re.test(this.baseID(step)) || re.test(step.handler);
|
|
3125
|
+
})
|
|
3084
3126
|
);
|
|
3127
|
+
this._uniqueIdMap.clear();
|
|
3128
|
+
this.assignUniqueIds();
|
|
3085
3129
|
this.entities.forEach((entity) => this.graph.set(this.ID(entity), /* @__PURE__ */ new Set()));
|
|
3086
3130
|
this.entities.forEach((entity) => {
|
|
3087
3131
|
const entityId = this.ID(entity);
|
|
@@ -3101,10 +3145,10 @@ var A_StepsManager = class {
|
|
|
3101
3145
|
}
|
|
3102
3146
|
});
|
|
3103
3147
|
}
|
|
3104
|
-
// Match entities by name or regex
|
|
3148
|
+
// Match entities by name or regex — matches against the base ID for pattern compatibility
|
|
3105
3149
|
matchEntities(entityId, pattern) {
|
|
3106
3150
|
const regex = new RegExp(pattern);
|
|
3107
|
-
return this.entities.filter((entity) => regex.test(this.
|
|
3151
|
+
return this.entities.filter((entity) => regex.test(this.baseID(entity)) && this.ID(entity) !== entityId).map((entity) => this.ID(entity));
|
|
3108
3152
|
}
|
|
3109
3153
|
// Topological sort with cycle detection
|
|
3110
3154
|
visit(node) {
|
|
@@ -3594,7 +3638,7 @@ var A_ComponentMeta = class extends A_Meta {
|
|
|
3594
3638
|
before: extension.before || "",
|
|
3595
3639
|
after: extension.after || "",
|
|
3596
3640
|
throwOnError: extension.throwOnError || true,
|
|
3597
|
-
override: ""
|
|
3641
|
+
override: extension.override || ""
|
|
3598
3642
|
});
|
|
3599
3643
|
});
|
|
3600
3644
|
});
|
|
@@ -5171,6 +5215,14 @@ var A_Context = class _A_Context {
|
|
|
5171
5215
|
if (inherited) {
|
|
5172
5216
|
steps.delete(`${A_CommonHelper.getComponentName(inherited)}.${declaration.handler}`);
|
|
5173
5217
|
}
|
|
5218
|
+
if (declaration.override) {
|
|
5219
|
+
const overrideRegexp = new RegExp(declaration.override);
|
|
5220
|
+
for (const [stepKey, step] of steps) {
|
|
5221
|
+
if (overrideRegexp.test(stepKey) || overrideRegexp.test(step.handler)) {
|
|
5222
|
+
steps.delete(stepKey);
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5174
5226
|
steps.set(`${A_CommonHelper.getComponentName(cmp)}.${declaration.handler}`, {
|
|
5175
5227
|
dependency: new A_Dependency(cmp),
|
|
5176
5228
|
...declaration
|