@xyo-network/xl1-protocol-sdk 1.22.25 → 1.22.27

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.
@@ -15,10 +15,7 @@ export declare abstract class ActorV2<TParams extends ActorParamsV2 = ActorParam
15
15
  protected readonly _intervals: Map<string, ReturnType<typeof setInterval>>;
16
16
  protected readonly _semaphores: Map<string, Semaphore>;
17
17
  protected readonly _timeouts: Map<string, ReturnType<typeof setTimeout>>;
18
- private _active;
19
18
  private _context;
20
- /** @deprecated use .name instead */
21
- get id(): import("@xylabs/sdk-js").CreatableName;
22
19
  protected get account(): AccountInstance;
23
20
  protected get config(): {
24
21
  api: {
@@ -154,14 +151,11 @@ export declare abstract class ActorV2<TParams extends ActorParamsV2 = ActorParam
154
151
  meterProvider?: import("@opentelemetry/api").MeterProvider;
155
152
  traceProvider?: import("@opentelemetry/api").TracerProvider;
156
153
  }>;
154
+ createHandler(): Promise<void>;
157
155
  /**
158
156
  * The timer runs until the actor is deactivated (or you manually stop it).
159
157
  */
160
158
  registerTimer(timerName: string, callback: () => Promise<void>, dueTimeMs: number, periodMs: number): void;
161
- /**
162
- * Called by the Orchestrator when the actor is activated.
163
- */
164
- startHandler(): Promise<void>;
165
159
  /**
166
160
  * Called by the Orchestrator when the actor is deactivated.
167
161
  * Stop all running timers.
@@ -1 +1 @@
1
- {"version":3,"file":"ActorV2.d.ts","sourceRoot":"","sources":["../../../src/actor/ActorV2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAC/C,MAAM,EACN,UAAU,EACX,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,iBAAiB,EAEJ,QAAQ,EACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,KAAK,EAAE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ACnE"}
@@ -1088,17 +1088,12 @@ var ActorV2 = class extends AbstractCreatable3 {
1088
1088
  _intervals = /* @__PURE__ */ new Map();
1089
1089
  _semaphores = /* @__PURE__ */ new Map();
1090
1090
  _timeouts = /* @__PURE__ */ new Map();
1091
- _active = false;
1092
1091
  _context;
1093
- /** @deprecated use .name instead */
1094
- get id() {
1095
- return this.name;
1096
- }
1097
1092
  get account() {
1098
1093
  return this.params.account;
1099
1094
  }
1100
1095
  get config() {
1101
- return this.context.config;
1096
+ return this.params.config;
1102
1097
  }
1103
1098
  get context() {
1104
1099
  return this._context;
@@ -1119,13 +1114,17 @@ var ActorV2 = class extends AbstractCreatable3 {
1119
1114
  config
1120
1115
  };
1121
1116
  }
1117
+ async createHandler() {
1118
+ await super.createHandler();
1119
+ this._context = await this.initContext();
1120
+ }
1122
1121
  /**
1123
1122
  * The timer runs until the actor is deactivated (or you manually stop it).
1124
1123
  */
1125
1124
  registerTimer(timerName, callback, dueTimeMs, periodMs) {
1126
- if (!this._active) {
1125
+ if (this.status !== "starting") {
1127
1126
  this.logger?.warn(
1128
- `Cannot register timer '${timerName}' because actor is not active.`
1127
+ `Cannot register timer '${timerName}' because actor is not starting.`
1129
1128
  );
1130
1129
  return;
1131
1130
  }
@@ -1134,7 +1133,7 @@ var ActorV2 = class extends AbstractCreatable3 {
1134
1133
  const timeoutId = setTimeout(() => {
1135
1134
  const intervalId = setInterval(() => {
1136
1135
  const semaphore = this._semaphores.get(timerName);
1137
- if (!this._active || !this._intervals.has(timerName) || !semaphore || running) return;
1136
+ if (this.status !== "started" || !this._intervals.has(timerName) || !semaphore || running) return;
1138
1137
  if (semaphore.isLocked()) {
1139
1138
  this.logger?.warn(
1140
1139
  `Skipping timer '${this.name}:${timerName}' execution because previous execution is still running.`
@@ -1173,22 +1172,12 @@ var ActorV2 = class extends AbstractCreatable3 {
1173
1172
  `Timer '${this.name}:${timerName}' registered: first call after ${dueTimeMs}ms, recurring every ${periodMs}ms.`
1174
1173
  );
1175
1174
  }
1176
- /**
1177
- * Called by the Orchestrator when the actor is activated.
1178
- */
1179
- async startHandler() {
1180
- await super.startHandler();
1181
- this._context = await this.initContext();
1182
- this._active = true;
1183
- this.logger?.log("Started.");
1184
- }
1185
1175
  /**
1186
1176
  * Called by the Orchestrator when the actor is deactivated.
1187
1177
  * Stop all running timers.
1188
1178
  */
1189
1179
  async stopHandler() {
1190
1180
  await super.stopHandler();
1191
- this._active = false;
1192
1181
  this.logger?.log("Stopping all timers...");
1193
1182
  await Promise.all(
1194
1183
  [...this._semaphores.values()].map(async (semaphore) => {