@adaas/a-utils 0.1.12 → 0.1.13
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/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Command/A-Command.entity.ts +49 -8
- package/src/lib/A-Command/A-Command.error.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -206,6 +206,12 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
206
206
|
params: InvokeType | A_TYPES__Command_Serialized<InvokeType, ResultType> | string);
|
|
207
207
|
init(): Promise<void>;
|
|
208
208
|
compile(): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Processes the command execution
|
|
211
|
+
*
|
|
212
|
+
* @returns
|
|
213
|
+
*/
|
|
214
|
+
process(): Promise<void>;
|
|
209
215
|
/**
|
|
210
216
|
* Executes the command logic.
|
|
211
217
|
*/
|
|
@@ -258,9 +264,11 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
258
264
|
* @returns
|
|
259
265
|
*/
|
|
260
266
|
toJSON(): A_TYPES__Command_Serialized<InvokeType, ResultType>;
|
|
267
|
+
protected checkScopeInheritance(): void;
|
|
261
268
|
}
|
|
262
269
|
|
|
263
270
|
declare class A_CommandError extends A_Error {
|
|
271
|
+
static readonly CommandScopeBindingError = "A-Command Scope Binding Error";
|
|
264
272
|
}
|
|
265
273
|
|
|
266
274
|
interface Ifspolyfill {
|
package/dist/index.d.ts
CHANGED
|
@@ -206,6 +206,12 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
206
206
|
params: InvokeType | A_TYPES__Command_Serialized<InvokeType, ResultType> | string);
|
|
207
207
|
init(): Promise<void>;
|
|
208
208
|
compile(): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Processes the command execution
|
|
211
|
+
*
|
|
212
|
+
* @returns
|
|
213
|
+
*/
|
|
214
|
+
process(): Promise<void>;
|
|
209
215
|
/**
|
|
210
216
|
* Executes the command logic.
|
|
211
217
|
*/
|
|
@@ -258,9 +264,11 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
258
264
|
* @returns
|
|
259
265
|
*/
|
|
260
266
|
toJSON(): A_TYPES__Command_Serialized<InvokeType, ResultType>;
|
|
267
|
+
protected checkScopeInheritance(): void;
|
|
261
268
|
}
|
|
262
269
|
|
|
263
270
|
declare class A_CommandError extends A_Error {
|
|
271
|
+
static readonly CommandScopeBindingError = "A-Command Scope Binding Error";
|
|
264
272
|
}
|
|
265
273
|
|
|
266
274
|
interface Ifspolyfill {
|
package/dist/index.js
CHANGED
|
@@ -188,6 +188,9 @@ var A_Memory = class extends aConcept.A_Fragment {
|
|
|
188
188
|
return obj;
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
|
+
var A_CommandError = class extends aConcept.A_Error {
|
|
192
|
+
};
|
|
193
|
+
A_CommandError.CommandScopeBindingError = "A-Command Scope Binding Error";
|
|
191
194
|
|
|
192
195
|
// src/lib/A-Command/A-Command.entity.ts
|
|
193
196
|
var A_Command = class extends aConcept.A_Entity {
|
|
@@ -293,9 +296,7 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
293
296
|
}
|
|
294
297
|
this._status = "INITIALIZATION" /* INITIALIZATION */;
|
|
295
298
|
this._startTime = /* @__PURE__ */ new Date();
|
|
296
|
-
|
|
297
|
-
this.scope.inherit(aConcept.A_Context.scope(this));
|
|
298
|
-
}
|
|
299
|
+
this.checkScopeInheritance();
|
|
299
300
|
this.emit("init");
|
|
300
301
|
await this.call("init", this.scope);
|
|
301
302
|
this._status = "INITIALIZED" /* INITIALIZED */;
|
|
@@ -305,22 +306,34 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
305
306
|
if (this._status !== "INITIALIZED" /* INITIALIZED */) {
|
|
306
307
|
return;
|
|
307
308
|
}
|
|
309
|
+
this.checkScopeInheritance();
|
|
308
310
|
this._status = "COMPILATION" /* COMPILATION */;
|
|
309
311
|
this.emit("compile");
|
|
310
312
|
await this.call("compile", this.scope);
|
|
311
313
|
this._status = "COMPILED" /* COMPILED */;
|
|
312
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Processes the command execution
|
|
317
|
+
*
|
|
318
|
+
* @returns
|
|
319
|
+
*/
|
|
320
|
+
async process() {
|
|
321
|
+
if (this._status !== "COMPILED" /* COMPILED */)
|
|
322
|
+
return;
|
|
323
|
+
this._status = "IN_PROGRESS" /* IN_PROGRESS */;
|
|
324
|
+
this.checkScopeInheritance();
|
|
325
|
+
this.emit("execute");
|
|
326
|
+
await this.call("execute", this.scope);
|
|
327
|
+
}
|
|
313
328
|
/**
|
|
314
329
|
* Executes the command logic.
|
|
315
330
|
*/
|
|
316
331
|
async execute() {
|
|
332
|
+
this.checkScopeInheritance();
|
|
317
333
|
try {
|
|
318
334
|
await this.init();
|
|
319
335
|
await this.compile();
|
|
320
|
-
|
|
321
|
-
this.emit("execute");
|
|
322
|
-
await this.call("execute", this.scope);
|
|
323
|
-
}
|
|
336
|
+
await this.process();
|
|
324
337
|
await this.complete();
|
|
325
338
|
} catch (error) {
|
|
326
339
|
await this.fail();
|
|
@@ -330,6 +343,7 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
330
343
|
* Marks the command as completed
|
|
331
344
|
*/
|
|
332
345
|
async complete() {
|
|
346
|
+
this.checkScopeInheritance();
|
|
333
347
|
this._status = "COMPLETED" /* COMPLETED */;
|
|
334
348
|
this._endTime = /* @__PURE__ */ new Date();
|
|
335
349
|
this._result = this.scope.resolve(A_Memory).toJSON();
|
|
@@ -340,6 +354,7 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
340
354
|
* Marks the command as failed
|
|
341
355
|
*/
|
|
342
356
|
async fail() {
|
|
357
|
+
this.checkScopeInheritance();
|
|
343
358
|
this._status = "FAILED" /* FAILED */;
|
|
344
359
|
this._endTime = /* @__PURE__ */ new Date();
|
|
345
360
|
this._errors = this.scope.resolve(A_Memory).Errors;
|
|
@@ -442,8 +457,21 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
442
457
|
errors: this.errors ? Array.from(this.errors).map((err) => err.toJSON()) : void 0
|
|
443
458
|
};
|
|
444
459
|
}
|
|
445
|
-
|
|
446
|
-
|
|
460
|
+
checkScopeInheritance() {
|
|
461
|
+
let attachedScope;
|
|
462
|
+
try {
|
|
463
|
+
attachedScope = aConcept.A_Context.scope(this);
|
|
464
|
+
} catch (error) {
|
|
465
|
+
throw new A_CommandError({
|
|
466
|
+
title: A_CommandError.CommandScopeBindingError,
|
|
467
|
+
description: `Command ${this.code} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,
|
|
468
|
+
originalError: error
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
if (!this.scope.isInheritedFrom(aConcept.A_Context.scope(this))) {
|
|
472
|
+
this.scope.inherit(aConcept.A_Context.scope(this));
|
|
473
|
+
}
|
|
474
|
+
}
|
|
447
475
|
};
|
|
448
476
|
|
|
449
477
|
// src/lib/A-Config/A-Config.constants.ts
|