@happyvertical/smrt-jobs 0.30.0
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/AGENTS.md +71 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +151 -0
- package/dist/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/background-policy.d.ts +121 -0
- package/dist/background-policy.d.ts.map +1 -0
- package/dist/chunks/runner-DV8FBO0y.js +1642 -0
- package/dist/chunks/runner-DV8FBO0y.js.map +1 -0
- package/dist/chunks/worker-liveness-DOTjoIjr.js +65 -0
- package/dist/chunks/worker-liveness-DOTjoIjr.js.map +1 -0
- package/dist/error-redaction.d.ts +48 -0
- package/dist/error-redaction.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +926 -0
- package/dist/index.js.map +1 -0
- package/dist/job-builder.d.ts +94 -0
- package/dist/job-builder.d.ts.map +1 -0
- package/dist/job-handle.d.ts +71 -0
- package/dist/job-handle.d.ts.map +1 -0
- package/dist/logger-extension.d.ts +58 -0
- package/dist/logger-extension.d.ts.map +1 -0
- package/dist/manifest.json +1327 -0
- package/dist/object-extension.d.ts +68 -0
- package/dist/object-extension.d.ts.map +1 -0
- package/dist/playground.d.ts +2 -0
- package/dist/playground.d.ts.map +1 -0
- package/dist/playground.js +179 -0
- package/dist/playground.js.map +1 -0
- package/dist/runner.d.ts +189 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +15 -0
- package/dist/runner.js.map +1 -0
- package/dist/schedule-runner.d.ts +151 -0
- package/dist/schedule-runner.d.ts.map +1 -0
- package/dist/smrt-job-event.d.ts +54 -0
- package/dist/smrt-job-event.d.ts.map +1 -0
- package/dist/smrt-job.d.ts +215 -0
- package/dist/smrt-job.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +508 -0
- package/dist/smrt-worker.d.ts +72 -0
- package/dist/smrt-worker.d.ts.map +1 -0
- package/dist/stale-recovery.d.ts +34 -0
- package/dist/stale-recovery.d.ts.map +1 -0
- package/dist/svelte/components/JobActions.svelte +103 -0
- package/dist/svelte/components/JobActions.svelte.d.ts +23 -0
- package/dist/svelte/components/JobActions.svelte.d.ts.map +1 -0
- package/dist/svelte/components/JobDashboard.svelte +199 -0
- package/dist/svelte/components/JobDashboard.svelte.d.ts +27 -0
- package/dist/svelte/components/JobDashboard.svelte.d.ts.map +1 -0
- package/dist/svelte/components/JobDetail.svelte +256 -0
- package/dist/svelte/components/JobDetail.svelte.d.ts +17 -0
- package/dist/svelte/components/JobDetail.svelte.d.ts.map +1 -0
- package/dist/svelte/components/JobList.svelte +360 -0
- package/dist/svelte/components/JobList.svelte.d.ts +28 -0
- package/dist/svelte/components/JobList.svelte.d.ts.map +1 -0
- package/dist/svelte/components/JobStats.svelte +242 -0
- package/dist/svelte/components/JobStats.svelte.d.ts +15 -0
- package/dist/svelte/components/JobStats.svelte.d.ts.map +1 -0
- package/dist/svelte/components/JobStatusBadge.svelte +23 -0
- package/dist/svelte/components/JobStatusBadge.svelte.d.ts +9 -0
- package/dist/svelte/components/JobStatusBadge.svelte.d.ts.map +1 -0
- package/dist/svelte/components/types.d.ts +9 -0
- package/dist/svelte/components/types.d.ts.map +1 -0
- package/dist/svelte/components/types.js +8 -0
- package/dist/svelte/i18n.d.ts +22 -0
- package/dist/svelte/i18n.d.ts.map +1 -0
- package/dist/svelte/i18n.js +22 -0
- package/dist/svelte/index.d.ts +25 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +28 -0
- package/dist/svelte/playground.d.ts +329 -0
- package/dist/svelte/playground.d.ts.map +1 -0
- package/dist/svelte/playground.js +174 -0
- package/dist/svelte/types.d.ts +191 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +87 -0
- package/dist/ui.d.ts +10 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +69 -0
- package/dist/ui.js.map +1 -0
- package/dist/worker-liveness-thread.d.ts +2 -0
- package/dist/worker-liveness-thread.d.ts.map +1 -0
- package/dist/worker-liveness-thread.js +66 -0
- package/dist/worker-liveness-thread.js.map +1 -0
- package/dist/worker-liveness-ticker.d.ts +30 -0
- package/dist/worker-liveness-ticker.d.ts.map +1 -0
- package/dist/worker-liveness.d.ts +71 -0
- package/dist/worker-liveness.d.ts.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
+
export type SmrtJobEventType = 'status' | 'progress' | 'log' | 'error' | string;
|
|
3
|
+
export type SmrtJobEventLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
4
|
+
export interface SmrtJobEventData {
|
|
5
|
+
tenantId?: string | null;
|
|
6
|
+
jobId: string;
|
|
7
|
+
type?: SmrtJobEventType;
|
|
8
|
+
level?: SmrtJobEventLevel;
|
|
9
|
+
stage?: string | null;
|
|
10
|
+
progress?: number | null;
|
|
11
|
+
message?: string;
|
|
12
|
+
data?: Record<string, unknown>;
|
|
13
|
+
createdAt?: Date;
|
|
14
|
+
}
|
|
15
|
+
export interface JobEventCursor {
|
|
16
|
+
createdAt: string | Date;
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ListJobEventsOptions {
|
|
20
|
+
tenantId?: string | null;
|
|
21
|
+
limit?: number;
|
|
22
|
+
since?: string | Date;
|
|
23
|
+
afterId?: string;
|
|
24
|
+
cursor?: string | JobEventCursor;
|
|
25
|
+
}
|
|
26
|
+
export declare class SmrtJobEvent extends SmrtObject {
|
|
27
|
+
tenantId: string | null | undefined;
|
|
28
|
+
jobId: string;
|
|
29
|
+
type: SmrtJobEventType;
|
|
30
|
+
level: SmrtJobEventLevel;
|
|
31
|
+
stage: string | null;
|
|
32
|
+
progress: number | null;
|
|
33
|
+
message: string;
|
|
34
|
+
data: Record<string, unknown>;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
toCursor(): string;
|
|
37
|
+
}
|
|
38
|
+
export declare class SmrtJobEventCollection extends SmrtCollection<SmrtJobEvent> {
|
|
39
|
+
static readonly _itemClass: typeof SmrtJobEvent;
|
|
40
|
+
initialize(): Promise<this>;
|
|
41
|
+
append(input: SmrtJobEventData): Promise<SmrtJobEvent>;
|
|
42
|
+
listByJob(jobId: string, options?: ListJobEventsOptions): Promise<SmrtJobEvent[]>;
|
|
43
|
+
listSinceCursor(options?: ListJobEventsOptions & {
|
|
44
|
+
jobId?: string;
|
|
45
|
+
}): Promise<SmrtJobEvent[]>;
|
|
46
|
+
latestProgressByJobIds(jobIds: string[], options?: {
|
|
47
|
+
tenantId?: string | null;
|
|
48
|
+
}): Promise<Map<string, SmrtJobEvent>>;
|
|
49
|
+
private addTenantPredicate;
|
|
50
|
+
private createdAtComparableExpression;
|
|
51
|
+
private resolveCursorCreatedAt;
|
|
52
|
+
}
|
|
53
|
+
export default SmrtJobEvent;
|
|
54
|
+
//# sourceMappingURL=smrt-job-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smrt-job-event.d.ts","sourceRoot":"","sources":["../src/smrt-job-event.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAIL,cAAc,EACd,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAOlC,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhF,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,K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AAC;IActD,SAAS,CACb,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,YAAY,EAAE,CAAC;IAOpB,eAAe,CACnB,OAAO,GAAE,oBAAoB,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GACtD,OAAO,CAAC,YAAY,EAAE,CAAC;IA2CpB,sBAAsB,CAC1B,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAO,GACzC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAwCrC,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,6BAA6B;YAQvB,sBAAsB;CA6BrC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { RetryStrategyConfig } from '@happyvertical/jobs';
|
|
2
|
+
import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
|
|
3
|
+
/**
|
|
4
|
+
* Job status type
|
|
5
|
+
*/
|
|
6
|
+
export type JobStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
7
|
+
/**
|
|
8
|
+
* Timeout behavior type
|
|
9
|
+
*/
|
|
10
|
+
export type TimeoutBehavior = 'fail' | 'kill' | 'warn';
|
|
11
|
+
/**
|
|
12
|
+
* Persistent job record stored in the `_smrt_jobs` system table.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Each SmrtJob represents a deferred method call on a SmrtObject. The TaskRunner polls for
|
|
16
|
+
* pending jobs, resolves the target class via ObjectRegistry, and invokes the method. Jobs
|
|
17
|
+
* track status (`pending -> running -> completed/failed/cancelled`), retry attempts with
|
|
18
|
+
* configurable strategies, worker heartbeats for stale-job detection, and optional result pointers.
|
|
19
|
+
* Priority ordering is `higher = sooner`; the default timeout is 5 minutes (300000ms).
|
|
20
|
+
*/
|
|
21
|
+
export declare class SmrtJob extends SmrtObject {
|
|
22
|
+
/** Tenant context captured for this job, if any */
|
|
23
|
+
tenantId: string | null | undefined;
|
|
24
|
+
/** Queue name for the job */
|
|
25
|
+
queue: string;
|
|
26
|
+
/** Type of object to invoke method on */
|
|
27
|
+
objectType: string;
|
|
28
|
+
/** ID of the specific object (null for static methods) */
|
|
29
|
+
objectId: string | null;
|
|
30
|
+
/** Method name to invoke */
|
|
31
|
+
method: string;
|
|
32
|
+
/** Arguments to pass to the method (JSON) */
|
|
33
|
+
args: Record<string, unknown>;
|
|
34
|
+
/** When to run the job */
|
|
35
|
+
runAt: Date;
|
|
36
|
+
/** Priority (higher = sooner) */
|
|
37
|
+
priority: number;
|
|
38
|
+
/** Current status */
|
|
39
|
+
status: JobStatus;
|
|
40
|
+
/** Number of execution attempts */
|
|
41
|
+
attempts: number;
|
|
42
|
+
/** Maximum retry attempts */
|
|
43
|
+
maxAttempts: number;
|
|
44
|
+
/** Timeout in milliseconds */
|
|
45
|
+
timeout: number;
|
|
46
|
+
/** What to do on timeout */
|
|
47
|
+
timeoutBehavior: TimeoutBehavior;
|
|
48
|
+
/** When execution started */
|
|
49
|
+
startedAt: Date | null;
|
|
50
|
+
/** When execution completed */
|
|
51
|
+
completedAt: Date | null;
|
|
52
|
+
/** Last error message */
|
|
53
|
+
lastError: string | null;
|
|
54
|
+
/** Pointer to where result is stored */
|
|
55
|
+
resultPointer: string | null;
|
|
56
|
+
/** Retry strategy configuration */
|
|
57
|
+
retryStrategy: RetryStrategyConfig;
|
|
58
|
+
/** ID of the worker processing this job */
|
|
59
|
+
workerId: string | null;
|
|
60
|
+
/** Last heartbeat from the worker */
|
|
61
|
+
workerHeartbeat: Date | null;
|
|
62
|
+
/**
|
|
63
|
+
* Capture ambient tenant context when a job is saved inside withTenant().
|
|
64
|
+
*
|
|
65
|
+
* Scheduled jobs can also set this explicitly from their owning schedule.
|
|
66
|
+
*/
|
|
67
|
+
save(): Promise<this>;
|
|
68
|
+
/**
|
|
69
|
+
* Mark the job for retry
|
|
70
|
+
*/
|
|
71
|
+
retry(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Cancel the job
|
|
74
|
+
*/
|
|
75
|
+
cancel(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Get a human-readable description of the job
|
|
78
|
+
*/
|
|
79
|
+
getDescription(): string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Job data type (for create operations)
|
|
83
|
+
*/
|
|
84
|
+
export interface SmrtJobData {
|
|
85
|
+
tenantId?: string | null;
|
|
86
|
+
queue?: string;
|
|
87
|
+
objectType: string;
|
|
88
|
+
objectId?: string | null;
|
|
89
|
+
method: string;
|
|
90
|
+
args?: Record<string, unknown>;
|
|
91
|
+
runAt?: Date;
|
|
92
|
+
priority?: number;
|
|
93
|
+
maxAttempts?: number;
|
|
94
|
+
timeout?: number;
|
|
95
|
+
timeoutBehavior?: TimeoutBehavior;
|
|
96
|
+
retryStrategy?: RetryStrategyConfig;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Options controlling a centralized {@link SmrtJobCollection.enqueueJob} call.
|
|
100
|
+
*/
|
|
101
|
+
export interface EnqueueJobOptions {
|
|
102
|
+
/**
|
|
103
|
+
* Per-tenant in-flight cap. Defaults to {@link DEFAULT_TENANT_JOB_CAP}.
|
|
104
|
+
* `0`/negative disables the cap (trusted internal callers). Global
|
|
105
|
+
* (no-context / null tenant) jobs are always exempt.
|
|
106
|
+
*/
|
|
107
|
+
tenantJobCap?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Options for listReady
|
|
111
|
+
*/
|
|
112
|
+
export interface ListReadyOptions {
|
|
113
|
+
limit?: number;
|
|
114
|
+
queues?: string[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Options for atomically claiming ready jobs.
|
|
118
|
+
*/
|
|
119
|
+
export interface ClaimReadyOptions extends ListReadyOptions {
|
|
120
|
+
workerId: string;
|
|
121
|
+
now?: Date;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Collection for managing SmrtJob objects
|
|
125
|
+
*/
|
|
126
|
+
export declare class SmrtJobCollection extends SmrtCollection<SmrtJob> {
|
|
127
|
+
static readonly _itemClass: typeof SmrtJob;
|
|
128
|
+
initialize(): Promise<this>;
|
|
129
|
+
/**
|
|
130
|
+
* List jobs by status
|
|
131
|
+
*/
|
|
132
|
+
listByStatus(status: JobStatus | JobStatus[], options?: {
|
|
133
|
+
limit?: number;
|
|
134
|
+
queue?: string;
|
|
135
|
+
}): Promise<SmrtJob[]>;
|
|
136
|
+
/**
|
|
137
|
+
* List pending jobs ready to run
|
|
138
|
+
*/
|
|
139
|
+
listReady(options?: {
|
|
140
|
+
limit?: number;
|
|
141
|
+
queues?: string[];
|
|
142
|
+
}): Promise<SmrtJob[]>;
|
|
143
|
+
/**
|
|
144
|
+
* Atomically claim pending jobs ready to run for a worker.
|
|
145
|
+
*
|
|
146
|
+
* The claim is performed as one conditional UPDATE so concurrent workers
|
|
147
|
+
* cannot receive the same pending row. PostgreSQL additionally skips rows
|
|
148
|
+
* locked by other workers instead of waiting behind them.
|
|
149
|
+
*/
|
|
150
|
+
claimReady(options: ClaimReadyOptions): Promise<SmrtJob[]>;
|
|
151
|
+
/**
|
|
152
|
+
* Count non-terminal (pending/running) jobs owned by a tenant.
|
|
153
|
+
*
|
|
154
|
+
* Used to enforce the per-tenant creation cap so one tenant cannot exhaust
|
|
155
|
+
* the shared worker pool (S5 audit #1402). Reads `_smrt_jobs` directly so it
|
|
156
|
+
* works regardless of ambient tenant context.
|
|
157
|
+
*
|
|
158
|
+
* @param tenantId - Tenant to count for. `null` counts global (NULL-tenant)
|
|
159
|
+
* jobs.
|
|
160
|
+
*/
|
|
161
|
+
countInFlightForTenant(tenantId: string | null): Promise<number>;
|
|
162
|
+
/**
|
|
163
|
+
* The single creation path for queued jobs.
|
|
164
|
+
*
|
|
165
|
+
* Centralizes the two creation-time security guards from the S5 audit (#1402)
|
|
166
|
+
* so every enqueue — the fluent {@link "./job-builder".JobBuilder} *and* the
|
|
167
|
+
* ScheduleRunner's cron-triggered jobs — goes through one place:
|
|
168
|
+
*
|
|
169
|
+
* 1. `maxAttempts` is clamped to {@link MAX_JOB_RETRIES} so a misconfigured
|
|
170
|
+
* caller cannot pin a worker on a poison job indefinitely.
|
|
171
|
+
* 2. A per-tenant in-flight cap bounds how many non-terminal jobs one tenant
|
|
172
|
+
* may hold, so one tenant cannot exhaust the shared worker pool
|
|
173
|
+
* (cross-tenant denial of service). The cap applies to the row's effective
|
|
174
|
+
* tenant (explicit `data.tenantId` or, when absent, the ambient context);
|
|
175
|
+
* global (null-tenant) jobs are exempt.
|
|
176
|
+
*
|
|
177
|
+
* Atomicity note (best-effort soft cap, by design): the cap is a
|
|
178
|
+
* count-then-insert, NOT a hard transactional invariant. It is intentionally
|
|
179
|
+
* left non-atomic. A plain transaction would not help — under the adapters'
|
|
180
|
+
* default isolation two concurrent same-tenant enqueues would each read the
|
|
181
|
+
* same COUNT and both insert, so serializing them would require either a
|
|
182
|
+
* per-tenant lock row (`SELECT ... FOR UPDATE`) or SERIALIZABLE-isolation
|
|
183
|
+
* retry loops. That cross-process locking is fragile (lock-row contention,
|
|
184
|
+
* adapter-specific isolation behavior, the `transaction` adapter method being
|
|
185
|
+
* optional) and out of proportion to the threat: this cap is defense in depth
|
|
186
|
+
* against runaway/accidental creation exhausting the shared worker pool, not a
|
|
187
|
+
* billing/quota boundary. So under truly simultaneous enqueues a tenant may
|
|
188
|
+
* momentarily overshoot by the number of in-flight creators; the bound still
|
|
189
|
+
* prevents unbounded growth and closes the prior ScheduleRunner bypass. If a
|
|
190
|
+
* hard guarantee is ever needed, enforce it with a DB CHECK/trigger or a
|
|
191
|
+
* dedicated counter row, not an application-level lock.
|
|
192
|
+
*/
|
|
193
|
+
enqueueJob(data: SmrtJobData, options?: EnqueueJobOptions): Promise<SmrtJob>;
|
|
194
|
+
/**
|
|
195
|
+
* Get job statistics
|
|
196
|
+
*/
|
|
197
|
+
stats(queue?: string): Promise<{
|
|
198
|
+
pending: number;
|
|
199
|
+
running: number;
|
|
200
|
+
completed: number;
|
|
201
|
+
failed: number;
|
|
202
|
+
cancelled: number;
|
|
203
|
+
}>;
|
|
204
|
+
/**
|
|
205
|
+
* Cleanup old completed/failed jobs
|
|
206
|
+
*/
|
|
207
|
+
cleanup(options: {
|
|
208
|
+
completedBefore?: Date;
|
|
209
|
+
failedBefore?: Date;
|
|
210
|
+
cancelledBefore?: Date;
|
|
211
|
+
limit?: number;
|
|
212
|
+
}): Promise<number>;
|
|
213
|
+
}
|
|
214
|
+
export default SmrtJob;
|
|
215
|
+
//# sourceMappingURL=smrt-job.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smrt-job.d.ts","sourceRoot":"","sources":["../src/smrt-job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAIL,cAAc,EACd,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAalC;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,GACR,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD;;;;;;;;;GASG;AACH,qBAwBa,OAAQ,SAAQ,UAAU;IACrC,mDAAmD;IAEnD,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAa;IAEhD,6BAA6B;IAE7B,KAAK,EAAE,MAAM,CAAa;IAE1B,yCAAyC;IAEzC,UAAU,EAAE,MAAM,CAAM;IAExB,0DAA0D;IAE1D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,4BAA4B;IAE5B,MAAM,EAAE,MAAM,CAAM;IAEpB,6CAA6C;IAE7C,IAAI,EAAE,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