@central-ticket/queue-sdk 0.0.2 → 0.0.4

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/server.d.ts CHANGED
@@ -1,6 +1,10 @@
1
- interface ValidateQueueTokenServerOptions {
1
+ interface CentralQServerClientOptions {
2
2
  apiUrl?: string;
3
3
  secretKey: string;
4
+ timeoutMs?: number;
5
+ fetch?: typeof fetch;
6
+ }
7
+ interface ValidateQueueTokenServerOptions extends CentralQServerClientOptions {
4
8
  eventId: string;
5
9
  token: string;
6
10
  }
@@ -13,9 +17,85 @@ type QueueTokenValidationResult = {
13
17
  valid: false;
14
18
  reason: string;
15
19
  };
20
+ interface VerifyQueueAccessServerOptions extends CentralQServerClientOptions {
21
+ eventId: string;
22
+ token?: string;
23
+ }
24
+ type QueueAccessValidationResult = {
25
+ allowed: true;
26
+ eventId: string;
27
+ protected: boolean;
28
+ reason?: string;
29
+ userId?: string;
30
+ expiresAt?: string;
31
+ } | {
32
+ allowed: false;
33
+ eventId?: string;
34
+ protected?: boolean;
35
+ reason?: string;
36
+ message?: string;
37
+ };
38
+ interface CompleteQueueAccessServerOptions extends CentralQServerClientOptions {
39
+ eventId: string;
40
+ token: string;
41
+ completionId: string;
42
+ }
43
+ type QueueAccessCompletionResult = {
44
+ completed: true;
45
+ alreadyCompleted: boolean;
46
+ } | {
47
+ completed: false;
48
+ reason: string;
49
+ };
50
+ type CentralQServerRequestErrorCode = "network_error" | "timeout";
51
+ declare class CentralQServerRequestError extends Error {
52
+ readonly code: CentralQServerRequestErrorCode;
53
+ constructor(code: CentralQServerRequestErrorCode, message: string, options?: {
54
+ cause?: unknown;
55
+ });
56
+ }
57
+ declare class CentralQServerClient {
58
+ private readonly apiUrl;
59
+ private readonly secretKey;
60
+ private readonly timeoutMs;
61
+ private readonly fetchFn;
62
+ constructor(options: CentralQServerClientOptions);
63
+ validateToken(input: {
64
+ eventId: string;
65
+ token: string;
66
+ }): Promise<{
67
+ status: number;
68
+ data: QueueTokenValidationResult;
69
+ }>;
70
+ verifyAccess(input: {
71
+ eventId: string;
72
+ token?: string;
73
+ }): Promise<{
74
+ status: number;
75
+ data: QueueAccessValidationResult;
76
+ }>;
77
+ completeAccess(input: {
78
+ eventId: string;
79
+ token: string;
80
+ completionId: string;
81
+ }): Promise<{
82
+ status: number;
83
+ data: QueueAccessCompletionResult;
84
+ }>;
85
+ private post;
86
+ }
87
+ declare function createCentralQServerClient(options: CentralQServerClientOptions): CentralQServerClient;
16
88
  declare function validateQueueTokenServer(options: ValidateQueueTokenServerOptions): Promise<{
17
89
  status: number;
18
90
  data: QueueTokenValidationResult;
19
91
  }>;
92
+ declare function verifyQueueAccessServer(options: VerifyQueueAccessServerOptions): Promise<{
93
+ status: number;
94
+ data: QueueAccessValidationResult;
95
+ }>;
96
+ declare function completeQueueAccessServer(options: CompleteQueueAccessServerOptions): Promise<{
97
+ status: number;
98
+ data: QueueAccessCompletionResult;
99
+ }>;
20
100
 
21
- export { type QueueTokenValidationResult, type ValidateQueueTokenServerOptions, validateQueueTokenServer };
101
+ export { CentralQServerClient, type CentralQServerClientOptions, CentralQServerRequestError, type CentralQServerRequestErrorCode, type CompleteQueueAccessServerOptions, type QueueAccessCompletionResult, type QueueAccessValidationResult, type QueueTokenValidationResult, type ValidateQueueTokenServerOptions, type VerifyQueueAccessServerOptions, completeQueueAccessServer, createCentralQServerClient, validateQueueTokenServer, verifyQueueAccessServer };
package/dist/server.js CHANGED
@@ -20,7 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/server.ts
21
21
  var server_exports = {};
22
22
  __export(server_exports, {
23
- validateQueueTokenServer: () => validateQueueTokenServer
23
+ CentralQServerClient: () => CentralQServerClient,
24
+ CentralQServerRequestError: () => CentralQServerRequestError,
25
+ completeQueueAccessServer: () => completeQueueAccessServer,
26
+ createCentralQServerClient: () => createCentralQServerClient,
27
+ validateQueueTokenServer: () => validateQueueTokenServer,
28
+ verifyQueueAccessServer: () => verifyQueueAccessServer
24
29
  });
25
30
  module.exports = __toCommonJS(server_exports);
26
31
 
@@ -28,29 +33,113 @@ module.exports = __toCommonJS(server_exports);
28
33
  var CENTRALQ_DEFAULT_API_URL = "http://localhost:3001";
29
34
 
30
35
  // src/server.ts
36
+ var DEFAULT_TIMEOUT_MS = 5e3;
37
+ var CentralQServerRequestError = class extends Error {
38
+ constructor(code, message, options) {
39
+ super(message, options);
40
+ this.name = "CentralQServerRequestError";
41
+ this.code = code;
42
+ }
43
+ };
31
44
  function normalizeApiUrl(apiUrl) {
32
- return apiUrl.replace(/\/+$/, "");
45
+ const trimmed = apiUrl.trim().replace(/\/+$/, "");
46
+ return trimmed.endsWith("/api") ? trimmed.slice(0, -4) : trimmed;
33
47
  }
34
- async function validateQueueTokenServer(options) {
35
- const apiUrl = options.apiUrl ?? CENTRALQ_DEFAULT_API_URL;
36
- const response = await fetch(
37
- `${normalizeApiUrl(apiUrl)}/api/queue/verify/${encodeURIComponent(options.eventId)}`,
38
- {
39
- method: "POST",
40
- headers: {
41
- "Content-Type": "application/json",
42
- "x-api-key": options.secretKey
48
+ function validateOptions(options) {
49
+ if (!options.secretKey?.trim()) {
50
+ throw new TypeError("CentralQ secretKey es requerida");
51
+ }
52
+ if (options.timeoutMs !== void 0 && options.timeoutMs <= 0) {
53
+ throw new TypeError("CentralQ timeoutMs debe ser mayor a cero");
54
+ }
55
+ }
56
+ var CentralQServerClient = class {
57
+ constructor(options) {
58
+ validateOptions(options);
59
+ this.apiUrl = normalizeApiUrl(options.apiUrl ?? CENTRALQ_DEFAULT_API_URL);
60
+ this.secretKey = options.secretKey.trim();
61
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
62
+ this.fetchFn = options.fetch ?? globalThis.fetch;
63
+ }
64
+ validateToken(input) {
65
+ return this.post(
66
+ `/api/queue/verify/${encodeURIComponent(input.eventId)}`,
67
+ { token: input.token },
68
+ { valid: false, reason: "Respuesta inv\xE1lida" }
69
+ );
70
+ }
71
+ verifyAccess(input) {
72
+ return this.post(
73
+ `/api/queue/verify/${encodeURIComponent(input.eventId)}/access`,
74
+ { token: input.token ?? null },
75
+ {
76
+ allowed: false,
77
+ reason: "invalid_response",
78
+ message: "Respuesta inv\xE1lida"
79
+ }
80
+ );
81
+ }
82
+ completeAccess(input) {
83
+ return this.post(
84
+ `/api/queue/verify/${encodeURIComponent(input.eventId)}/complete`,
85
+ {
86
+ token: input.token,
87
+ completionId: input.completionId
43
88
  },
44
- body: JSON.stringify({ token: options.token })
89
+ { completed: false, reason: "invalid_response" }
90
+ );
91
+ }
92
+ async post(path, body, fallback) {
93
+ const controller = new AbortController();
94
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
95
+ try {
96
+ const response = await this.fetchFn(`${this.apiUrl}${path}`, {
97
+ method: "POST",
98
+ headers: {
99
+ "Content-Type": "application/json",
100
+ "x-api-key": this.secretKey
101
+ },
102
+ body: JSON.stringify(body),
103
+ signal: controller.signal
104
+ });
105
+ const data = await response.json().catch(() => fallback);
106
+ return { status: response.status, data };
107
+ } catch (error) {
108
+ if (controller.signal.aborted) {
109
+ throw new CentralQServerRequestError(
110
+ "timeout",
111
+ `CentralQ no respondi\xF3 en ${this.timeoutMs}ms`,
112
+ { cause: error }
113
+ );
114
+ }
115
+ throw new CentralQServerRequestError(
116
+ "network_error",
117
+ "No se pudo conectar con CentralQ",
118
+ { cause: error }
119
+ );
120
+ } finally {
121
+ clearTimeout(timeout);
45
122
  }
46
- );
47
- const data = await response.json().catch(() => ({
48
- valid: false,
49
- reason: "Respuesta inv\xE1lida"
50
- }));
51
- return { status: response.status, data };
123
+ }
124
+ };
125
+ function createCentralQServerClient(options) {
126
+ return new CentralQServerClient(options);
127
+ }
128
+ function validateQueueTokenServer(options) {
129
+ return createCentralQServerClient(options).validateToken(options);
130
+ }
131
+ function verifyQueueAccessServer(options) {
132
+ return createCentralQServerClient(options).verifyAccess(options);
133
+ }
134
+ function completeQueueAccessServer(options) {
135
+ return createCentralQServerClient(options).completeAccess(options);
52
136
  }
53
137
  // Annotate the CommonJS export names for ESM import in node:
54
138
  0 && (module.exports = {
55
- validateQueueTokenServer
139
+ CentralQServerClient,
140
+ CentralQServerRequestError,
141
+ completeQueueAccessServer,
142
+ createCentralQServerClient,
143
+ validateQueueTokenServer,
144
+ verifyQueueAccessServer
56
145
  });
package/dist/server.mjs CHANGED
@@ -1,8 +1,18 @@
1
1
  import {
2
- validateQueueTokenServer
3
- } from "./chunk-JJ33EJ65.mjs";
4
- import "./chunk-P73Q2ZIO.mjs";
2
+ CentralQServerClient,
3
+ CentralQServerRequestError,
4
+ completeQueueAccessServer,
5
+ createCentralQServerClient,
6
+ validateQueueTokenServer,
7
+ verifyQueueAccessServer
8
+ } from "./chunk-CFWLZCAR.mjs";
9
+ import "./chunk-OR3GGW4J.mjs";
5
10
  import "./chunk-XRJFNASX.mjs";
6
11
  export {
7
- validateQueueTokenServer
12
+ CentralQServerClient,
13
+ CentralQServerRequestError,
14
+ completeQueueAccessServer,
15
+ createCentralQServerClient,
16
+ validateQueueTokenServer,
17
+ verifyQueueAccessServer
8
18
  };
package/dist/svelte.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'svelte/store';
2
- import { Q as QueueStatus, C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, d as CentralQOptions } from './centralq-C3ukDo0x.mjs';
2
+ import { m as QueueStatus, b as CentralQ, e as CentralQCreateOptions, c as CentralQClient, f as CentralQOptions } from './centralq-CCw_Cqam.mjs';
3
3
 
4
4
  interface CentralQStores {
5
5
  /** Store con el token JWT si el usuario fue admitido */
package/dist/svelte.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'svelte/store';
2
- import { Q as QueueStatus, C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, d as CentralQOptions } from './centralq-C3ukDo0x.js';
2
+ import { m as QueueStatus, b as CentralQ, e as CentralQCreateOptions, c as CentralQClient, f as CentralQOptions } from './centralq-CCw_Cqam.js';
3
3
 
4
4
  interface CentralQStores {
5
5
  /** Store con el token JWT si el usuario fue admitido */
package/dist/svelte.js CHANGED
@@ -68,6 +68,11 @@ var init_queue_element = __esm({
68
68
  Por favor, no cierres esta ventana.
69
69
  </p>
70
70
  ` : ""}
71
+ ${this.status === "PAUSED" ? import_lit.html`
72
+ <h2>La fila está temporalmente cerrada</h2>
73
+ <p>Volveremos a intentar automáticamente.</p>
74
+ <div class="spinner"></div>
75
+ ` : ""}
71
76
  ${this.status === "EXPIRED" ? import_lit.html`
72
77
  <h2 style="color: #f59e0b;">Tu sesión ha expirado</h2>
73
78
  <p>El tiempo para completar la compra terminó.</p>
@@ -193,6 +198,30 @@ var QueueHttpClient = class {
193
198
  }
194
199
  return res.json();
195
200
  }
201
+ /**
202
+ * Canjea un código de bypass por un token de acceso activo.
203
+ * El worker descuenta un uso únicamente cuando el canje es exitoso.
204
+ */
205
+ async redeemBypassCode(eventId, code, userId) {
206
+ const res = await fetch(
207
+ `${this.apiUrl}/api/queue/${encodeURIComponent(eventId)}/bypass`,
208
+ {
209
+ method: "POST",
210
+ headers: this.headers,
211
+ body: JSON.stringify({ code, userId })
212
+ }
213
+ );
214
+ const body = await res.json().catch(() => ({}));
215
+ if (!res.ok) {
216
+ throw new Error(
217
+ body.message ?? `Error ${res.status} al canjear c\xF3digo bypass`
218
+ );
219
+ }
220
+ if (body.status !== "ACTIVE" || !body.token || !body.expiresAt || body.bypass !== true) {
221
+ throw new Error("Respuesta inv\xE1lida al canjear c\xF3digo bypass");
222
+ }
223
+ return body;
224
+ }
196
225
  /**
197
226
  * Envía un heartbeat para mantener vivo el slot (waiting o active).
198
227
  * El SDK lo llama cada 10s automáticamente.
@@ -262,6 +291,7 @@ var QueueHttpClient = class {
262
291
  configured: body.configured === true,
263
292
  protected: body.protected === true,
264
293
  isActive: body.isActive === true,
294
+ isPaused: body.isPaused === true,
265
295
  admissionMode: body.admissionMode ?? "PUBLIC",
266
296
  challengeRequired: body.challengeRequired === true
267
297
  };
@@ -500,6 +530,24 @@ var CentralQ = class _CentralQ {
500
530
  this.pollInterval
501
531
  );
502
532
  }
533
+ } else if (res.status === "PAUSED") {
534
+ this.updateUI("PAUSED");
535
+ this.emit("paused", {
536
+ message: res.message,
537
+ retryAfterSeconds: res.retryAfterSeconds,
538
+ userId: this.userId,
539
+ eventId: this.eventId
540
+ });
541
+ if (!this.pollingTimer) {
542
+ const retryInterval = Math.max(
543
+ this.pollInterval,
544
+ res.retryAfterSeconds * 1e3
545
+ );
546
+ this.pollingTimer = setInterval(
547
+ () => this.checkQueue(),
548
+ retryInterval
549
+ );
550
+ }
503
551
  }
504
552
  } catch {
505
553
  this.updateUI("ERROR");
@@ -533,6 +581,11 @@ function createCentralQ(options) {
533
581
  _position.set(detail.position);
534
582
  _ahead.set(detail.ahead);
535
583
  });
584
+ queue.on("paused", () => {
585
+ _position.set(null);
586
+ _ahead.set(null);
587
+ _error.set(false);
588
+ });
536
589
  queue.on("expired", () => {
537
590
  _token.set(null);
538
591
  _expired.set(true);
@@ -643,6 +696,17 @@ function useQueue(optionsInput) {
643
696
  status.set("waiting");
644
697
  isPending.set(false);
645
698
  });
699
+ queue.on("paused", (_detail) => {
700
+ data.set({
701
+ token: null,
702
+ position: null,
703
+ ahead: null,
704
+ expiresAt: null
705
+ });
706
+ status.set("paused");
707
+ error.set(null);
708
+ isPending.set(false);
709
+ });
646
710
  queue.on("expired", () => {
647
711
  data.set({
648
712
  token: null,
package/dist/svelte.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CentralQ
3
- } from "./chunk-BVCZFNM3.mjs";
4
- import "./chunk-P73Q2ZIO.mjs";
3
+ } from "./chunk-OVV3CIZZ.mjs";
4
+ import "./chunk-OR3GGW4J.mjs";
5
5
  import "./chunk-XRJFNASX.mjs";
6
6
 
7
7
  // src/svelte.ts
@@ -27,6 +27,11 @@ function createCentralQ(options) {
27
27
  _position.set(detail.position);
28
28
  _ahead.set(detail.ahead);
29
29
  });
30
+ queue.on("paused", () => {
31
+ _position.set(null);
32
+ _ahead.set(null);
33
+ _error.set(false);
34
+ });
30
35
  queue.on("expired", () => {
31
36
  _token.set(null);
32
37
  _expired.set(true);
@@ -137,6 +142,17 @@ function useQueue(optionsInput) {
137
142
  status.set("waiting");
138
143
  isPending.set(false);
139
144
  });
145
+ queue.on("paused", (_detail) => {
146
+ data.set({
147
+ token: null,
148
+ position: null,
149
+ ahead: null,
150
+ expiresAt: null
151
+ });
152
+ status.set("paused");
153
+ error.set(null);
154
+ isPending.set(false);
155
+ });
140
156
  queue.on("expired", () => {
141
157
  data.set({
142
158
  token: null,
package/dist/vue.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Ref } from 'vue';
2
- import { c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, C as CentralQ } from './centralq-C3ukDo0x.mjs';
2
+ import { e as CentralQCreateOptions, c as CentralQClient, m as QueueStatus, b as CentralQ } from './centralq-CCw_Cqam.mjs';
3
3
 
4
4
  interface QueueData {
5
5
  token: string | null;
package/dist/vue.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Ref } from 'vue';
2
- import { c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, C as CentralQ } from './centralq-C3ukDo0x.js';
2
+ import { e as CentralQCreateOptions, c as CentralQClient, m as QueueStatus, b as CentralQ } from './centralq-CCw_Cqam.js';
3
3
 
4
4
  interface QueueData {
5
5
  token: string | null;
package/dist/vue.js CHANGED
@@ -71,6 +71,15 @@ function useQueue(optionsInput) {
71
71
  status.value = "waiting";
72
72
  isPending.value = false;
73
73
  });
74
+ queue.on("paused", (_detail) => {
75
+ token.value = null;
76
+ position.value = null;
77
+ ahead.value = null;
78
+ expiresAt.value = null;
79
+ status.value = "paused";
80
+ isPending.value = false;
81
+ error.value = null;
82
+ });
74
83
  queue.on("expired", () => {
75
84
  token.value = null;
76
85
  position.value = null;
package/dist/vue.mjs CHANGED
@@ -56,6 +56,15 @@ function useQueue(optionsInput) {
56
56
  status.value = "waiting";
57
57
  isPending.value = false;
58
58
  });
59
+ queue.on("paused", (_detail) => {
60
+ token.value = null;
61
+ position.value = null;
62
+ ahead.value = null;
63
+ expiresAt.value = null;
64
+ status.value = "paused";
65
+ isPending.value = false;
66
+ error.value = null;
67
+ });
59
68
  queue.on("expired", () => {
60
69
  token.value = null;
61
70
  position.value = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@central-ticket/queue-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "keywords": [
5
5
  "virtual-queue",
6
6
  "waiting-room",
@@ -53,7 +53,7 @@
53
53
  "access": "public"
54
54
  },
55
55
  "scripts": {
56
- "build": "tsup src/index.ts src/react.ts src/svelte.ts src/vue.ts src/server.ts --format cjs,esm --dts",
56
+ "build": "tsup src/index.ts src/react.ts src/svelte.ts src/vue.ts src/server.ts --format cjs,esm --dts --clean",
57
57
  "dev": "tsup src/index.ts src/react.ts src/svelte.ts src/vue.ts src/server.ts --format cjs,esm --dts --watch",
58
58
  "check-types": "tsc --noEmit",
59
59
  "test": "vitest run",
@@ -1,133 +0,0 @@
1
- interface CentralQOptions {
2
- /** URL del queue worker. */
3
- apiUrl?: string;
4
- /** Publishable API key (ctq_pub_xxx) */
5
- apiKey: string;
6
- /** ID del evento/recurso a proteger */
7
- eventId: string;
8
- /** ID de usuario externo. Si no se provee, se autogenera y persiste en sessionStorage */
9
- userId?: string;
10
- /** Init token corto emitido por backend (recomendado para producción) */
11
- queueInitToken?: string;
12
- /** Intervalo de polling en ms (default: 10000) */
13
- pollInterval?: number;
14
- /** Contenedor donde montar el overlay. Default: document.body */
15
- container?: HTMLElement;
16
- }
17
- interface CentralQClientOptions {
18
- /** URL del queue worker */
19
- apiUrl?: string;
20
- /** Publishable API key (ctq_pub_xxx) */
21
- apiKey: string;
22
- /** ID de usuario externo por defecto para todas las colas creadas por el client */
23
- userId?: string;
24
- /** Init token corto por defecto para colas creadas por el client */
25
- queueInitToken?: string;
26
- /** Intervalo de polling por defecto en ms */
27
- pollInterval?: number;
28
- /** Contenedor por defecto donde montar el overlay */
29
- container?: HTMLElement;
30
- }
31
- interface CentralQCreateOptions {
32
- /** ID del evento/recurso a proteger */
33
- eventId: string;
34
- /** Override opcional del userId por cola */
35
- userId?: string;
36
- /** Override opcional del queue init token por cola */
37
- queueInitToken?: string;
38
- /** Override opcional del poll interval por cola */
39
- pollInterval?: number;
40
- /** Override opcional del contenedor por cola */
41
- container?: HTMLElement;
42
- /** Override opcional del apiUrl por cola */
43
- apiUrl?: string;
44
- /** Override opcional del apiKey por cola */
45
- apiKey?: string;
46
- }
47
- interface PassedDetail {
48
- token: string;
49
- expiresAt: number;
50
- userId: string;
51
- eventId: string;
52
- }
53
- interface PositionDetail {
54
- position: number;
55
- ahead: number;
56
- userId: string;
57
- eventId: string;
58
- }
59
- interface ExpiredDetail {
60
- userId: string;
61
- eventId: string;
62
- }
63
- interface ErrorDetail {
64
- userId: string;
65
- eventId: string;
66
- }
67
- type EventMap = {
68
- passed: PassedDetail;
69
- expired: ExpiredDetail;
70
- position: PositionDetail;
71
- error: ErrorDetail;
72
- };
73
- type EventName = keyof EventMap;
74
- type Listener<T> = (detail: T) => void;
75
- type QueueStatus = "idle" | "joining" | "waiting" | "passed" | "expired" | "error";
76
- declare class CentralQ {
77
- private client;
78
- private element;
79
- private userId;
80
- private eventId;
81
- private pollInterval;
82
- private container;
83
- private pollingTimer?;
84
- private heartbeatTimer?;
85
- private expiryTimer?;
86
- private destroyed;
87
- private listeners;
88
- private constructor();
89
- /**
90
- * Inicializa CentralQ y comienza el flujo de cola automáticamente.
91
- * Monta el overlay de UI y empieza a hacer polling.
92
- */
93
- static init(options: CentralQOptions): CentralQ;
94
- /** Suscribirse a un evento del ciclo de vida de la cola */
95
- on<K extends EventName>(event: K, listener: Listener<EventMap[K]>): this;
96
- /** Desuscribirse de un evento */
97
- off<K extends EventName>(event: K, listener: Listener<EventMap[K]>): this;
98
- private emit;
99
- /**
100
- * Libera el slot del usuario inmediatamente.
101
- * Llamar cuando el usuario completa la compra.
102
- */
103
- leave(): void;
104
- /**
105
- * Destruye la instancia: para todos los timers, desmonta el overlay,
106
- * y libera el slot en el servidor.
107
- */
108
- destroy(): void;
109
- /** Retorna el userId resuelto (externo o autogenerado) */
110
- getUserId(): string;
111
- private resolveUserId;
112
- private mount;
113
- private unmount;
114
- private updateUI;
115
- private stopTimers;
116
- private startHeartbeat;
117
- private scheduleExpiry;
118
- private handleExpired;
119
- private checkQueue;
120
- }
121
- declare class CentralQClient {
122
- private defaults;
123
- constructor(defaults: CentralQClientOptions);
124
- issueQueueInitToken(eventId: string, userId?: string): Promise<{
125
- userId: string;
126
- queueInitToken: string;
127
- expiresAt: number;
128
- }>;
129
- createQueue(options: CentralQCreateOptions): CentralQ;
130
- }
131
- declare function createCentralQClient(options: CentralQClientOptions): CentralQClient;
132
-
133
- export { CentralQ as C, type ErrorDetail as E, type PassedDetail as P, type QueueStatus as Q, CentralQClient as a, type CentralQClientOptions as b, type CentralQCreateOptions as c, type CentralQOptions as d, type ExpiredDetail as e, type PositionDetail as f, createCentralQClient as g };