@dudousxd/nestjs-durable-store-mikro-orm 0.8.0 → 0.9.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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0DAAwC;AACxC,2CAAyB"}
1
+ {"version":3,"sources":["../src/entities.ts","../src/mikro-orm-state-store.ts","../src/schema.ts"],"sourcesContent":["import type { RunStatus, StepKind } from '@dudousxd/nestjs-durable-core';\nimport { Entity, PrimaryKey, Property } from '@mikro-orm/core';\n\n@Entity({ tableName: 'durable_workflow_runs' })\nexport class WorkflowRunEntity {\n @PrimaryKey()\n id!: string;\n\n @Property()\n workflow!: string;\n\n @Property()\n workflowVersion!: string;\n\n @Property()\n status!: RunStatus;\n\n @Property({ type: 'json', nullable: true })\n input?: unknown;\n\n @Property({ type: 'json', nullable: true })\n output?: unknown;\n\n @Property({ type: 'json', nullable: true })\n error?: unknown;\n\n @Property({ nullable: true })\n wakeAt?: Date;\n\n @Property({ nullable: true })\n lockedBy?: string;\n\n @Property({ nullable: true })\n lockedUntil?: Date;\n\n @Property({ type: 'integer', nullable: true })\n recoveryAttempts?: number;\n\n @Property({ type: 'json', nullable: true })\n tags?: string[] | null;\n\n @Property({ type: 'json', nullable: true })\n searchAttributes?: Record<string, string | number | boolean> | null;\n\n @Property()\n createdAt!: Date;\n\n @Property()\n updatedAt!: Date;\n}\n\n@Entity({ tableName: 'durable_step_checkpoints' })\nexport class StepCheckpointEntity {\n @PrimaryKey()\n runId!: string;\n\n @PrimaryKey()\n seq!: number;\n\n @Property()\n name!: string;\n\n @Property()\n kind!: StepKind;\n\n @Property()\n stepId!: string;\n\n @Property()\n status!: 'pending' | 'running' | 'completed' | 'failed';\n\n @Property({ type: 'json', nullable: true })\n input?: unknown;\n\n @Property({ type: 'json', nullable: true })\n output?: unknown;\n\n @Property({ type: 'json', nullable: true })\n error?: unknown;\n\n @Property({ type: 'json', nullable: true })\n events?: unknown;\n\n @Property()\n attempts!: number;\n\n @Property({ nullable: true })\n workerGroup?: string;\n\n @Property({ nullable: true })\n wakeAt?: Date;\n\n @Property({ nullable: true })\n enqueuedAt?: Date;\n\n @Property()\n startedAt!: Date;\n\n @Property()\n finishedAt!: Date;\n}\n\n/**\n * Normalized side-table for search attributes: one row per (run, key), so range/equality predicates\n * push DOWN into SQL (an EXISTS join indexed on `(key, numValue)` / `(key, strValue)`) instead of a\n * coarse scan + in-process filter. Maintained on every createRun/updateRun. Numbers land in\n * `numValue`, strings/booleans in `strValue` (booleans as \"true\"/\"false\"); see normalizeAttributeRows.\n */\n@Entity({ tableName: 'durable_run_attributes' })\nexport class RunAttributeEntity {\n @PrimaryKey()\n runId!: string;\n\n @PrimaryKey()\n key!: string;\n\n @Property({ type: 'string', nullable: true })\n strValue?: string | null;\n\n // `float`/`double` is portable across SQLite/MySQL/Postgres for numeric range scans.\n @Property({ type: 'float', nullable: true })\n numValue?: number | null;\n}\n\n@Entity({ tableName: 'durable_signal_waiters' })\nexport class SignalWaiterEntity {\n @PrimaryKey()\n token!: string;\n\n @Property()\n runId!: string;\n\n @Property()\n seq!: number;\n}\n\n@Entity({ tableName: 'durable_buffered_signals' })\nexport class BufferedSignalEntity {\n @PrimaryKey({ autoincrement: true })\n id!: number;\n\n @Property({ index: true })\n token!: string;\n\n @Property({ type: 'json', nullable: true })\n payload?: unknown;\n}\n\nexport const ENTITIES = [\n WorkflowRunEntity,\n StepCheckpointEntity,\n RunAttributeEntity,\n SignalWaiterEntity,\n BufferedSignalEntity,\n] as const;\n","import {\n type AttributeFilter,\n type RunQuery,\n type SignalWaiter,\n type StateStore,\n type StepCheckpoint,\n type StepError,\n type StepEvent,\n type WorkflowRun,\n attributeColumnFor,\n attributeOperand,\n normalizeAttributeRows,\n sqlComparator,\n} from '@dudousxd/nestjs-durable-core';\nimport type { EntityManager, MikroORM } from '@mikro-orm/core';\n\n/** Minimal structural surface of the SQL EntityManager's QueryBuilder (from `@mikro-orm/knex`),\n * typed here so the adapter needn't add a hard dependency on the knex types — a real SQL-driver EM\n * satisfies it at runtime. */\ninterface DurableQueryBuilder<T> {\n where(cond: Record<string, unknown>): DurableQueryBuilder<T>;\n andWhere(cond: string): DurableQueryBuilder<T>;\n orderBy(cond: Record<string, unknown>): DurableQueryBuilder<T>;\n limit(n: number): DurableQueryBuilder<T>;\n offset(n: number): DurableQueryBuilder<T>;\n getResultList(): Promise<T[]>;\n}\ntype SqlEm = EntityManager & {\n createQueryBuilder<T>(entity: unknown, alias: string): DurableQueryBuilder<T>;\n};\n\n/** Resolved side-table column names (per the active naming strategy) for the raw EXISTS pushdown. */\ninterface AttributeColumns {\n table: string;\n /** Side-table FK column (the run id on `durable_run_attributes`). */\n runId: string;\n /** Run table PK column (the `id` on `durable_workflow_runs`) used for the outer correlation. */\n runPk: string;\n key: string;\n strValue: string;\n numValue: string;\n}\nimport {\n BufferedSignalEntity,\n RunAttributeEntity,\n SignalWaiterEntity,\n StepCheckpointEntity,\n WorkflowRunEntity,\n} from './entities';\nimport { ensureMikroOrmDurableSchema } from './schema';\n\n/**\n * MikroORM-backed `StateStore`. Works on any MikroORM driver — Postgres, MySQL, SQLite (tested);\n * timestamps and `wakeAt` use native datetime columns. Each operation runs on a forked\n * EntityManager so it owns its unit of work.\n */\nexport class MikroOrmStateStore implements StateStore {\n constructor(private readonly orm: MikroORM) {}\n\n async ensureSchema(): Promise<void> {\n await ensureMikroOrmDurableSchema(this.orm);\n }\n\n async createRun(run: WorkflowRun): Promise<void> {\n const em = this.orm.em.fork();\n em.create(WorkflowRunEntity, toRunEntity(run));\n await em.flush();\n await this.reindexAttributes(run.id, run.searchAttributes);\n }\n\n async updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void> {\n const em = this.orm.em.fork();\n const entity = await em.findOneOrFail(WorkflowRunEntity, { id: runId });\n Object.assign(entity, toRunEntity({ ...fromRunEntity(entity), ...patch } as WorkflowRun));\n await em.flush();\n // Keep the side-table in step with the run's attributes whenever they're patched.\n if ('searchAttributes' in patch) await this.reindexAttributes(runId, patch.searchAttributes);\n }\n\n /** Rewrite a run's normalized attribute rows: delete the old set, insert the current one. Mirrors\n * the in-memory store's reindex so the side-table always reflects the run's live searchAttributes. */\n private async reindexAttributes(\n runId: string,\n attributes: WorkflowRun['searchAttributes'],\n forked?: EntityManager,\n ): Promise<void> {\n const em = forked ?? this.orm.em.fork();\n await em.nativeDelete(RunAttributeEntity, { runId });\n const rows = normalizeAttributeRows(runId, attributes);\n if (rows.length) await em.insertMany(RunAttributeEntity, rows);\n }\n\n async getRun(runId: string): Promise<WorkflowRun | null> {\n const em = this.orm.em.fork();\n const entity = await em.findOne(WorkflowRunEntity, { id: runId });\n return entity ? fromRunEntity(entity) : null;\n }\n\n async getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null> {\n const em = this.orm.em.fork();\n const entity = await em.findOne(StepCheckpointEntity, { runId, seq });\n return entity ? fromCheckpointEntity(entity) : null;\n }\n\n async saveCheckpoint(checkpoint: StepCheckpoint): Promise<void> {\n const em = this.orm.em.fork();\n await em.upsert(StepCheckpointEntity, toCheckpointEntity(checkpoint));\n await em.flush();\n }\n\n async transaction<T>(\n work: (tx: {\n raw: unknown;\n saveCheckpoint: (cp: StepCheckpoint) => Promise<void>;\n }) => Promise<T>,\n ): Promise<T> {\n return this.orm.em.fork().transactional(async (em) =>\n work({\n raw: em,\n saveCheckpoint: async (cp) => {\n await em.upsert(StepCheckpointEntity, toCheckpointEntity(cp));\n },\n }),\n );\n }\n\n async listIncompleteRuns(): Promise<WorkflowRun[]> {\n const em = this.orm.em.fork();\n const rows = await em.find(WorkflowRunEntity, { status: 'running' });\n return rows.map(fromRunEntity);\n }\n\n async listPendingRuns(limit: number): Promise<WorkflowRun[]> {\n const em = this.orm.em.fork();\n const rows = await em.find(\n WorkflowRunEntity,\n { status: 'pending' },\n { orderBy: { createdAt: 'asc' }, limit }, // FIFO dispatch\n );\n return rows.map(fromRunEntity);\n }\n\n async listDueTimers(nowMs: number): Promise<WorkflowRun[]> {\n const em = this.orm.em.fork();\n const rows = await em.find(WorkflowRunEntity, {\n status: 'suspended',\n wakeAt: { $ne: null, $lte: new Date(nowMs) },\n });\n return rows.map(fromRunEntity);\n }\n\n async tryLockRun(\n runId: string,\n owner: string,\n leaseUntilMs: number,\n nowMs: number,\n ): Promise<boolean> {\n const em = this.orm.em.fork();\n const affected = await em.nativeUpdate(\n WorkflowRunEntity,\n { id: runId, $or: [{ lockedUntil: null }, { lockedUntil: { $lte: new Date(nowMs) } }] },\n { lockedBy: owner, lockedUntil: new Date(leaseUntilMs) },\n );\n return affected === 1;\n }\n\n async releaseRunLock(runId: string): Promise<void> {\n const em = this.orm.em.fork();\n await em.nativeUpdate(WorkflowRunEntity, { id: runId }, { lockedBy: null, lockedUntil: null });\n }\n\n async renewRunLock(runId: string, owner: string, leaseUntilMs: number): Promise<boolean> {\n const em = this.orm.em.fork();\n const affected = await em.nativeUpdate(\n WorkflowRunEntity,\n { id: runId, lockedBy: owner },\n { lockedUntil: new Date(leaseUntilMs) },\n );\n return affected === 1;\n }\n\n async listRuns(query: RunQuery): Promise<WorkflowRun[]> {\n const em = this.orm.em.fork();\n const where: Record<string, unknown> = {};\n if (query.workflow) where.workflow = query.workflow;\n // `status IN (...)`; an empty set matches nothing (mirrors the in-memory store). When both the\n // single `status` and `statuses` are set, AND them so the narrower set wins.\n if (query.status && query.statuses) {\n where.$and = [{ status: query.status }, { status: { $in: query.statuses } }];\n } else if (query.status) {\n where.status = query.status;\n } else if (query.statuses) {\n where.status = { $in: query.statuses };\n }\n const orderBy = { createdAt: 'desc' as const }; // newest first — recent runs on top in the dashboard\n // `tags`/attributes need raw SQL pushed through the QueryBuilder:\n // - tag: `tags` is a JSON column (native json/jsonb on PG/MySQL), and MikroORM JSON-serializes a\n // `{ $like }` operand (wrapping/escaping the LIKE pattern) so a plain where corrupts it to no\n // matches. A raw LIKE on the column-as-text matches the quoted token so `etl` doesn't match\n // `etl-foo`. Postgres `jsonb` rejects `LIKE` directly, so cast to text per dialect.\n // - attributes: each filter becomes a raw EXISTS against the normalized side-table, so the DB\n // filters AND paginates — no full scan + in-process filter (ANDed: one EXISTS per filter).\n // Use a QueryBuilder with a fixed root alias `r` so the raw correlations are stable across drivers.\n if (query.tag || query.attributes?.length) {\n const quote = this.idQuote(em);\n const cols = this.attributeColumns(em);\n const qb = (em as SqlEm)\n .createQueryBuilder<WorkflowRunEntity>(WorkflowRunEntity, 'r')\n .where(where)\n .orderBy(orderBy);\n if (query.tag) {\n const tagsCol = this.tagsColumn(em);\n const pattern = `%\"${query.tag.replace(/'/g, \"''\")}\"%`;\n const colExpr = this.jsonAsText(em, `${quote('r')}.${quote(tagsCol)}`);\n qb.andWhere(`${colExpr} LIKE '${pattern}'`);\n }\n for (const f of query.attributes ?? []) {\n qb.andWhere(this.attributeExistsSql(f, quote, 'r', cols));\n }\n if (query.limit != null) qb.limit(query.limit);\n if (query.offset != null) qb.offset(query.offset);\n const rows = await qb.getResultList();\n return rows.map(fromRunEntity);\n }\n const rows = await em.find(WorkflowRunEntity, where, {\n ...(query.limit != null ? { limit: query.limit } : {}),\n ...(query.offset != null ? { offset: query.offset } : {}),\n orderBy,\n });\n return rows.map(fromRunEntity);\n }\n\n /** One attribute predicate as a raw EXISTS subquery on the side-table, correlated to the outer run\n * alias. `<>` (ne) also excludes runs where the attribute is absent (missing-key-never-matches):\n * EXISTS already requires a present row, so EXISTS(... <> ...) is exactly ne-with-present. Numeric\n * operands compare the num column, everything else the str column. Identifiers are quoted per\n * driver and operands are inlined as literals (string operands are escaped by doubling quotes). */\n private attributeExistsSql(\n f: AttributeFilter,\n quote: (id: string) => string,\n alias: string,\n cols: AttributeColumns,\n ): string {\n const col = attributeColumnFor(f) === 'numValue' ? cols.numValue : cols.strValue;\n const cmp = sqlComparator(f.op);\n const operand = attributeOperand(f);\n const literal =\n typeof operand === 'number' ? String(operand) : `'${String(operand).replace(/'/g, \"''\")}'`;\n const a = quote(cols.table);\n const sub = quote('a');\n const outerId = `${quote(alias)}.${quote(cols.runPk)}`; // run PK column on the outer alias\n return `EXISTS (SELECT 1 FROM ${a} ${sub} WHERE ${sub}.${quote(cols.runId)} = ${outerId} AND ${sub}.${quote(cols.key)} = '${f.key.replace(/'/g, \"''\")}' AND ${sub}.${quote(col)} ${cmp} ${literal})`;\n }\n\n /** Resolve the side-table's actual column names from MikroORM metadata, so the raw EXISTS matches\n * the active naming strategy (underscore vs camelCase) rather than guessing. The run PK column is\n * reused for BOTH the outer correlation and the side-table FK (they share the same fieldName). */\n private attributeColumns(em: EntityManager): AttributeColumns {\n const meta = em.getMetadata().get(RunAttributeEntity.name);\n const field = (prop: string) => meta.properties[prop]?.fieldNames?.[0] ?? prop;\n const runMeta = em.getMetadata().get(WorkflowRunEntity.name);\n const runPk = runMeta.properties.id?.fieldNames?.[0] ?? 'id';\n return {\n table: meta.tableName,\n runId: field('runId'),\n runPk,\n key: field('key'),\n strValue: field('strValue'),\n numValue: field('numValue'),\n };\n }\n\n /** Resolve the `tags` column name from metadata (per the active naming strategy), for the raw LIKE. */\n private tagsColumn(em: EntityManager): string {\n const runMeta = em.getMetadata().get(WorkflowRunEntity.name);\n return runMeta.properties.tags?.fieldNames?.[0] ?? 'tags';\n }\n\n /** Wrap a JSON column reference so it can be `LIKE`d as text. Postgres `jsonb`/`json` rejects `LIKE`\n * directly (`operator does not exist: jsonb ~~ unknown`) — cast to `text`; MySQL JSON needs an\n * explicit `CHAR` cast; SQLite stores JSON as text already, so no cast. */\n private jsonAsText(em: EntityManager, colRef: string): string {\n const platform = String(em.getPlatform().constructor.name).toLowerCase();\n if (platform.includes('postgre')) return `${colRef}::text`;\n if (platform.includes('mysql') || platform.includes('mariadb'))\n return `CAST(${colRef} AS CHAR)`;\n return colRef;\n }\n\n /** Quote an identifier per the active SQL driver (MySQL/MariaDB backtick, others double-quote). */\n private idQuote(em: EntityManager): (id: string) => string {\n const platform = String(em.getPlatform().constructor.name).toLowerCase();\n const isMysql = platform.includes('mysql') || platform.includes('mariadb');\n const ch = isMysql ? '`' : '\"';\n return (id: string) => `${ch}${id}${ch}`;\n }\n\n async listCheckpoints(runId: string): Promise<StepCheckpoint[]> {\n const em = this.orm.em.fork();\n const rows = await em.find(StepCheckpointEntity, { runId }, { orderBy: { seq: 'asc' } });\n return rows.map(fromCheckpointEntity);\n }\n\n async putSignalWaiter(waiter: SignalWaiter): Promise<void> {\n const em = this.orm.em.fork();\n await em.upsert(SignalWaiterEntity, { ...waiter });\n await em.flush();\n }\n\n async takeSignalWaiter(token: string): Promise<SignalWaiter | null> {\n const em = this.orm.em.fork();\n const entity = await em.findOne(SignalWaiterEntity, { token });\n if (!entity) return null;\n const waiter: SignalWaiter = { token: entity.token, runId: entity.runId, seq: entity.seq };\n await em.removeAndFlush(entity);\n return waiter;\n }\n\n async listSignalWaiters(prefix: string): Promise<SignalWaiter[]> {\n const em = this.orm.em.fork();\n const rows = await em.find(SignalWaiterEntity, { token: { $like: `${prefix}%` } });\n return rows.map((e) => ({ token: e.token, runId: e.runId, seq: e.seq }));\n }\n\n async bufferSignal(token: string, payload: unknown): Promise<void> {\n const em = this.orm.em.fork();\n const e = new BufferedSignalEntity();\n e.token = token;\n e.payload = payload ?? null;\n em.persist(e);\n await em.flush();\n }\n\n async takeBufferedSignal(token: string): Promise<{ payload: unknown } | null> {\n const em = this.orm.em.fork();\n const entity = await em.findOne(BufferedSignalEntity, { token }, { orderBy: { id: 'asc' } });\n if (!entity) return null;\n const payload = entity.payload ?? undefined;\n await em.removeAndFlush(entity);\n return { payload };\n }\n}\n\nfunction toRunEntity(run: WorkflowRun): WorkflowRunEntity {\n const e = new WorkflowRunEntity();\n e.id = run.id;\n e.workflow = run.workflow;\n e.workflowVersion = run.workflowVersion;\n e.status = run.status;\n e.input = run.input ?? null;\n e.output = run.output ?? null;\n e.error = run.error ?? null;\n if (run.wakeAt != null) e.wakeAt = new Date(run.wakeAt);\n if (run.lockedBy !== undefined) e.lockedBy = run.lockedBy;\n if (run.lockedUntil != null) e.lockedUntil = new Date(run.lockedUntil);\n if (run.recoveryAttempts !== undefined) e.recoveryAttempts = run.recoveryAttempts;\n e.tags = run.tags ?? null;\n e.searchAttributes = run.searchAttributes ?? null;\n e.createdAt = run.createdAt;\n e.updatedAt = run.updatedAt;\n return e;\n}\n\nfunction fromRunEntity(e: WorkflowRunEntity): WorkflowRun {\n return {\n id: e.id,\n workflow: e.workflow,\n workflowVersion: e.workflowVersion,\n status: e.status,\n input: e.input ?? undefined,\n output: e.output ?? undefined,\n error: (e.error ?? undefined) as StepError | undefined,\n wakeAt: e.wakeAt?.getTime(),\n lockedBy: e.lockedBy ?? undefined,\n lockedUntil: e.lockedUntil?.getTime(),\n recoveryAttempts: e.recoveryAttempts ?? undefined,\n tags: e.tags ?? undefined,\n searchAttributes: e.searchAttributes ?? undefined,\n createdAt: e.createdAt,\n updatedAt: e.updatedAt,\n };\n}\n\nfunction toCheckpointEntity(cp: StepCheckpoint): StepCheckpointEntity {\n const e = new StepCheckpointEntity();\n e.runId = cp.runId;\n e.seq = cp.seq;\n e.name = cp.name;\n e.kind = cp.kind;\n e.stepId = cp.stepId;\n e.status = cp.status;\n e.input = cp.input ?? null;\n e.output = cp.output ?? null;\n e.error = cp.error ?? null;\n e.events = cp.events ?? null;\n e.attempts = cp.attempts;\n if (cp.workerGroup !== undefined) e.workerGroup = cp.workerGroup;\n if (cp.wakeAt != null) e.wakeAt = new Date(cp.wakeAt);\n e.enqueuedAt = cp.enqueuedAt;\n e.startedAt = cp.startedAt;\n e.finishedAt = cp.finishedAt;\n return e;\n}\n\nfunction fromCheckpointEntity(e: StepCheckpointEntity): StepCheckpoint {\n return {\n runId: e.runId,\n seq: e.seq,\n name: e.name,\n kind: e.kind,\n stepId: e.stepId,\n status: e.status,\n input: e.input ?? undefined,\n output: e.output ?? undefined,\n error: (e.error ?? undefined) as StepError | undefined,\n events: (e.events ?? undefined) as StepEvent[] | undefined,\n attempts: e.attempts,\n workerGroup: e.workerGroup ?? undefined,\n wakeAt: e.wakeAt?.getTime(),\n enqueuedAt: e.enqueuedAt ?? e.startedAt,\n startedAt: e.startedAt,\n finishedAt: e.finishedAt,\n };\n}\n","import type { MikroORM } from '@mikro-orm/core';\n\n/**\n * Idempotently create/extend the durable tables (additive, never drops). Safe to run on every\n * boot (auto-schema) and the function to call from a MikroORM migration when you disable\n * auto-schema:\n *\n * ```ts\n * export class AddDurableTables extends Migration {\n * async up() { await ensureMikroOrmDurableSchema(this.getEntityManager().getOrm()); }\n * }\n * ```\n */\nexport async function ensureMikroOrmDurableSchema(orm: MikroORM): Promise<void> {\n await orm.schema.updateSchema({ safe: true });\n}\n"],"mappings":";;;;AACA,SAASA,QAAQC,YAAYC,gBAAgB;;;;;;;;;;;;AAGtC,IAAMC,oBAAN,MAAMA;SAAAA;;;EAEXC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;EAGAC;AACF;;;;;;;;;;;;;;;;;;;IAhCcC,MAAM;IAAQC,UAAU;;;;;;IAGxBD,MAAM;IAAQC,UAAU;;;;;;IAGxBD,MAAM;IAAQC,UAAU;;;;;;IAGxBA,UAAU;;;;;;IAGVA,UAAU;;;;;;IAGVA,UAAU;;;;;;IAGVD,MAAM;IAAWC,UAAU;;;;;;IAG3BD,MAAM;IAAQC,UAAU;;;;;;IAGxBD,MAAM;IAAQC,UAAU;;;;;;;;;;;;;;IAtC5BC,WAAW;;;AAiDd,IAAMC,uBAAN,MAAMA;SAAAA;;;EAEXC;EAGAC;EAGAC;EAGAC;EAGAC;EAGApB;EAGAC;EAGAC;EAGAC;EAGAkB;EAGAC;EAGAC;EAGAnB;EAGAoB;EAGAC;EAGAC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;IA7Bcd,MAAM;I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AG+G;AACdf,IAAE7F,SAASH,GAAGG;AACd6F,IAAEQ,QAAQxG,GAAGwG,SAAS;AACtBR,IAAES,SAASzG,GAAGyG,UAAU;AACxBT,IAAEU,QAAQ1G,GAAG0G,SAAS;AACtBV,IAAEgB,SAAShH,GAAGgH,UAAU;AACxBhB,IAAEiB,WAAWjH,GAAGiH;AAChB,MAAIjH,GAAGkH,gBAAgBZ,OAAWN,GAAEkB,cAAclH,GAAGkH;AACrD,MAAIlH,GAAGW,UAAU,KAAMqF,GAAErF,SAAS,IAAIG,KAAKd,GAAGW,MAAM;AACpDqF,IAAEmB,aAAanH,GAAGmH;AAClBnB,IAAEoB,YAAYpH,GAAGoH;AACjBpB,IAAEqB,aAAarH,GAAGqH;AAClB,SAAOrB;AACT;AAnBSrG;AAqBT,SAASJ,qBAAqByG,GAAuB;AACnD,SAAO;IACL7H,OAAO6H,EAAE7H;IACTkB,KAAK2G,EAAE3G;IACPkF,MAAMyB,EAAEzB;IACRuC,MAAMd,EAAEc;IACRC,QAAQf,EAAEe;IACV5G,QAAQ6F,EAAE7F;IACVqG,OAAOR,EAAEQ,SAASF;IAClBG,QAAQT,EAAES,UAAUH;IACpBI,OAAQV,EAAEU,SAASJ;IACnBU,QAAShB,EAAEgB,UAAUV;IACrBW,UAAUjB,EAAEiB;IACZC,aAAalB,EAAEkB,eAAeZ;IAC9B3F,QAAQqF,EAAErF,QAAQkG,QAAAA;IAClBM,YAAYnB,EAAEmB,cAAcnB,EAAEoB;IAC9BA,WAAWpB,EAAEoB;IACbC,YAAYrB,EAAEqB;EAChB;AACF;AAnBS9H;","names":["Entity","PrimaryKey","Property","WorkflowRunEntity","id","workflow","workflowVersion","status","input","output","error","wakeAt","lockedBy","lockedUntil","recoveryAttempts","tags","searchAttributes","createdAt","updatedAt","type","nullable","tableName","StepCheckpointEntity","runId","seq","name","kind","stepId","events","attempts","workerGroup","enqueuedAt","startedAt","finishedAt","RunAttributeEntity","key","strValue","numValue","SignalWaiterEntity","token","BufferedSignalEntity","payload","autoincrement","index","ENTITIES","attributeColumnFor","attributeOperand","normalizeAttributeRows","sqlComparator","ensureMikroOrmDurableSchema","orm","schema","updateSchema","safe","MikroOrmStateStore","orm","ensureSchema","ensureMikroOrmDurableSchema","createRun","run","em","fork","create","WorkflowRunEntity","toRunEntity","flush","reindexAttributes","id","searchAttributes","updateRun","runId","patch","entity","findOneOrFail","Object","assign","fromRunEntity","attributes","forked","nativeDelete","RunAttributeEntity","rows","normalizeAttributeRows","length","insertMany","getRun","findOne","getCheckpoint","seq","StepCheckpointEntity","fromCheckpointEntity","saveCheckpoint","checkpoint","upsert","toCheckpointEntity","transaction","work","transactional","raw","cp","listIncompleteRuns","find","status","map","listPendingRuns","limit","orderBy","createdAt","listDueTimers","nowMs","wakeAt","$ne","$lte","Date","tryLockRun","owner","leaseUntilMs","affected","nativeUpdate","$or","lockedUntil","lockedBy","releaseRunLock","renewRunLock","listRuns","query","where","workflow","statuses","$and","$in","tag","quote","idQuote","cols","attributeColumns","qb","createQueryBuilder","tagsCol","tagsColumn","pattern","replace","colExpr","jsonAsText","andWhere","f","attributeExistsSql","offset","getResultList","alias","col","attributeColumnFor","numValue","strValue","cmp","sqlComparator","op","operand","attributeOperand","literal","String","a","table","sub","outerId","runPk","key","meta","getMetadata","get","name","field","prop","properties","fieldNames","runMeta","tableName","tags","colRef","platform","getPlatform","toLowerCase","includes","isMysql","ch","listCheckpoints","putSignalWaiter","waiter","SignalWaiterEntity","takeSignalWaiter","token","removeAndFlush","listSignalWaiters","prefix","$like","e","bufferSignal","payload","BufferedSignalEntity","persist","takeBufferedSignal","undefined","workflowVersion","input","output","error","recoveryAttempts","updatedAt","getTime","kind","stepId","events","attempts","workerGroup","enqueuedAt","startedAt","finishedAt"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-durable-store-mikro-orm",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "MikroORM adapter for the nestjs-durable StateStore (reference ORM adapter)",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -9,9 +9,9 @@
9
9
  "url": "https://github.com/DavideCarvalho/nestjs-durable.git",
10
10
  "directory": "packages/store-mikro-orm"
11
11
  },
12
- "type": "commonjs",
13
- "main": "dist/index.js",
14
- "types": "dist/index.d.ts",
12
+ "type": "module",
13
+ "main": "./dist/index.cjs",
14
+ "types": "./dist/index.d.ts",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -22,12 +22,31 @@
22
22
  "devDependencies": {
23
23
  "@mikro-orm/better-sqlite": "6.6.2",
24
24
  "@mikro-orm/core": "6.6.2",
25
+ "@mikro-orm/mysql": "6.6.2",
26
+ "@mikro-orm/postgresql": "6.6.2",
27
+ "@testcontainers/mysql": "10.18.0",
28
+ "@testcontainers/postgresql": "10.18.0",
25
29
  "reflect-metadata": "0.2.2",
26
30
  "typescript": "5.9.3",
27
- "@dudousxd/nestjs-durable-core": "^0.21.0"
31
+ "tsup": "8.3.5",
32
+ "@dudousxd/nestjs-durable-core": "^0.28.0",
33
+ "@dudousxd/nestjs-durable-testing": "^0.4.0"
34
+ },
35
+ "module": "./dist/index.js",
36
+ "exports": {
37
+ ".": {
38
+ "import": {
39
+ "types": "./dist/index.d.ts",
40
+ "default": "./dist/index.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ }
46
+ }
28
47
  },
29
48
  "scripts": {
30
- "build": "tsc -p tsconfig.json",
49
+ "build": "tsup",
31
50
  "typecheck": "tsc -p tsconfig.json --noEmit"
32
51
  }
33
52
  }
@@ -1,48 +0,0 @@
1
- import type { RunStatus, StepKind } from '@dudousxd/nestjs-durable-core';
2
- export declare class WorkflowRunEntity {
3
- id: string;
4
- workflow: string;
5
- workflowVersion: string;
6
- status: RunStatus;
7
- input?: unknown;
8
- output?: unknown;
9
- error?: unknown;
10
- wakeAt?: Date;
11
- lockedBy?: string;
12
- lockedUntil?: Date;
13
- recoveryAttempts?: number;
14
- tags?: string[] | null;
15
- searchAttributes?: Record<string, string | number | boolean> | null;
16
- createdAt: Date;
17
- updatedAt: Date;
18
- }
19
- export declare class StepCheckpointEntity {
20
- runId: string;
21
- seq: number;
22
- name: string;
23
- kind: StepKind;
24
- stepId: string;
25
- status: 'pending' | 'running' | 'completed' | 'failed';
26
- input?: unknown;
27
- output?: unknown;
28
- error?: unknown;
29
- events?: unknown;
30
- attempts: number;
31
- workerGroup?: string;
32
- wakeAt?: Date;
33
- enqueuedAt?: Date;
34
- startedAt: Date;
35
- finishedAt: Date;
36
- }
37
- export declare class SignalWaiterEntity {
38
- token: string;
39
- runId: string;
40
- seq: number;
41
- }
42
- export declare class BufferedSignalEntity {
43
- id: number;
44
- token: string;
45
- payload?: unknown;
46
- }
47
- export declare const ENTITIES: readonly [typeof WorkflowRunEntity, typeof StepCheckpointEntity, typeof SignalWaiterEntity, typeof BufferedSignalEntity];
48
- //# sourceMappingURL=entities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzE,qBACa,iBAAiB;IAE5B,EAAE,EAAG,MAAM,CAAC;IAGZ,QAAQ,EAAG,MAAM,CAAC;IAGlB,eAAe,EAAG,MAAM,CAAC;IAGzB,MAAM,EAAG,SAAS,CAAC;IAGnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,IAAI,CAAC;IAGd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,WAAW,CAAC,EAAE,IAAI,CAAC;IAGnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAGvB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;IAGpE,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAClB;AAED,qBACa,oBAAoB;IAE/B,KAAK,EAAG,MAAM,CAAC;IAGf,GAAG,EAAG,MAAM,CAAC;IAGb,IAAI,EAAG,MAAM,CAAC;IAGd,IAAI,EAAG,QAAQ,CAAC;IAGhB,MAAM,EAAG,MAAM,CAAC;IAGhB,MAAM,EAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAGxD,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,QAAQ,EAAG,MAAM,CAAC;IAGlB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,MAAM,CAAC,EAAE,IAAI,CAAC;IAGd,UAAU,CAAC,EAAE,IAAI,CAAC;IAGlB,SAAS,EAAG,IAAI,CAAC;IAGjB,UAAU,EAAG,IAAI,CAAC;CACnB;AAED,qBACa,kBAAkB;IAE7B,KAAK,EAAG,MAAM,CAAC;IAGf,KAAK,EAAG,MAAM,CAAC;IAGf,GAAG,EAAG,MAAM,CAAC;CACd;AAED,qBACa,oBAAoB;IAE/B,EAAE,EAAG,MAAM,CAAC;IAGZ,KAAK,EAAG,MAAM,CAAC;IAGf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,QAAQ,0HAKX,CAAC"}
package/dist/entities.js DELETED
@@ -1,229 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ENTITIES = exports.BufferedSignalEntity = exports.SignalWaiterEntity = exports.StepCheckpointEntity = exports.WorkflowRunEntity = void 0;
13
- const core_1 = require("@mikro-orm/core");
14
- let WorkflowRunEntity = class WorkflowRunEntity {
15
- id;
16
- workflow;
17
- workflowVersion;
18
- status;
19
- input;
20
- output;
21
- error;
22
- wakeAt;
23
- lockedBy;
24
- lockedUntil;
25
- recoveryAttempts;
26
- tags;
27
- searchAttributes;
28
- createdAt;
29
- updatedAt;
30
- };
31
- exports.WorkflowRunEntity = WorkflowRunEntity;
32
- __decorate([
33
- (0, core_1.PrimaryKey)(),
34
- __metadata("design:type", String)
35
- ], WorkflowRunEntity.prototype, "id", void 0);
36
- __decorate([
37
- (0, core_1.Property)(),
38
- __metadata("design:type", String)
39
- ], WorkflowRunEntity.prototype, "workflow", void 0);
40
- __decorate([
41
- (0, core_1.Property)(),
42
- __metadata("design:type", String)
43
- ], WorkflowRunEntity.prototype, "workflowVersion", void 0);
44
- __decorate([
45
- (0, core_1.Property)(),
46
- __metadata("design:type", String)
47
- ], WorkflowRunEntity.prototype, "status", void 0);
48
- __decorate([
49
- (0, core_1.Property)({ type: 'json', nullable: true }),
50
- __metadata("design:type", Object)
51
- ], WorkflowRunEntity.prototype, "input", void 0);
52
- __decorate([
53
- (0, core_1.Property)({ type: 'json', nullable: true }),
54
- __metadata("design:type", Object)
55
- ], WorkflowRunEntity.prototype, "output", void 0);
56
- __decorate([
57
- (0, core_1.Property)({ type: 'json', nullable: true }),
58
- __metadata("design:type", Object)
59
- ], WorkflowRunEntity.prototype, "error", void 0);
60
- __decorate([
61
- (0, core_1.Property)({ nullable: true }),
62
- __metadata("design:type", Date)
63
- ], WorkflowRunEntity.prototype, "wakeAt", void 0);
64
- __decorate([
65
- (0, core_1.Property)({ nullable: true }),
66
- __metadata("design:type", String)
67
- ], WorkflowRunEntity.prototype, "lockedBy", void 0);
68
- __decorate([
69
- (0, core_1.Property)({ nullable: true }),
70
- __metadata("design:type", Date)
71
- ], WorkflowRunEntity.prototype, "lockedUntil", void 0);
72
- __decorate([
73
- (0, core_1.Property)({ type: 'integer', nullable: true }),
74
- __metadata("design:type", Number)
75
- ], WorkflowRunEntity.prototype, "recoveryAttempts", void 0);
76
- __decorate([
77
- (0, core_1.Property)({ type: 'json', nullable: true }),
78
- __metadata("design:type", Object)
79
- ], WorkflowRunEntity.prototype, "tags", void 0);
80
- __decorate([
81
- (0, core_1.Property)({ type: 'json', nullable: true }),
82
- __metadata("design:type", Object)
83
- ], WorkflowRunEntity.prototype, "searchAttributes", void 0);
84
- __decorate([
85
- (0, core_1.Property)(),
86
- __metadata("design:type", Date)
87
- ], WorkflowRunEntity.prototype, "createdAt", void 0);
88
- __decorate([
89
- (0, core_1.Property)(),
90
- __metadata("design:type", Date)
91
- ], WorkflowRunEntity.prototype, "updatedAt", void 0);
92
- exports.WorkflowRunEntity = WorkflowRunEntity = __decorate([
93
- (0, core_1.Entity)({ tableName: 'durable_workflow_runs' })
94
- ], WorkflowRunEntity);
95
- let StepCheckpointEntity = class StepCheckpointEntity {
96
- runId;
97
- seq;
98
- name;
99
- kind;
100
- stepId;
101
- status;
102
- input;
103
- output;
104
- error;
105
- events;
106
- attempts;
107
- workerGroup;
108
- wakeAt;
109
- enqueuedAt;
110
- startedAt;
111
- finishedAt;
112
- };
113
- exports.StepCheckpointEntity = StepCheckpointEntity;
114
- __decorate([
115
- (0, core_1.PrimaryKey)(),
116
- __metadata("design:type", String)
117
- ], StepCheckpointEntity.prototype, "runId", void 0);
118
- __decorate([
119
- (0, core_1.PrimaryKey)(),
120
- __metadata("design:type", Number)
121
- ], StepCheckpointEntity.prototype, "seq", void 0);
122
- __decorate([
123
- (0, core_1.Property)(),
124
- __metadata("design:type", String)
125
- ], StepCheckpointEntity.prototype, "name", void 0);
126
- __decorate([
127
- (0, core_1.Property)(),
128
- __metadata("design:type", String)
129
- ], StepCheckpointEntity.prototype, "kind", void 0);
130
- __decorate([
131
- (0, core_1.Property)(),
132
- __metadata("design:type", String)
133
- ], StepCheckpointEntity.prototype, "stepId", void 0);
134
- __decorate([
135
- (0, core_1.Property)(),
136
- __metadata("design:type", String)
137
- ], StepCheckpointEntity.prototype, "status", void 0);
138
- __decorate([
139
- (0, core_1.Property)({ type: 'json', nullable: true }),
140
- __metadata("design:type", Object)
141
- ], StepCheckpointEntity.prototype, "input", void 0);
142
- __decorate([
143
- (0, core_1.Property)({ type: 'json', nullable: true }),
144
- __metadata("design:type", Object)
145
- ], StepCheckpointEntity.prototype, "output", void 0);
146
- __decorate([
147
- (0, core_1.Property)({ type: 'json', nullable: true }),
148
- __metadata("design:type", Object)
149
- ], StepCheckpointEntity.prototype, "error", void 0);
150
- __decorate([
151
- (0, core_1.Property)({ type: 'json', nullable: true }),
152
- __metadata("design:type", Object)
153
- ], StepCheckpointEntity.prototype, "events", void 0);
154
- __decorate([
155
- (0, core_1.Property)(),
156
- __metadata("design:type", Number)
157
- ], StepCheckpointEntity.prototype, "attempts", void 0);
158
- __decorate([
159
- (0, core_1.Property)({ nullable: true }),
160
- __metadata("design:type", String)
161
- ], StepCheckpointEntity.prototype, "workerGroup", void 0);
162
- __decorate([
163
- (0, core_1.Property)({ nullable: true }),
164
- __metadata("design:type", Date)
165
- ], StepCheckpointEntity.prototype, "wakeAt", void 0);
166
- __decorate([
167
- (0, core_1.Property)({ nullable: true }),
168
- __metadata("design:type", Date)
169
- ], StepCheckpointEntity.prototype, "enqueuedAt", void 0);
170
- __decorate([
171
- (0, core_1.Property)(),
172
- __metadata("design:type", Date)
173
- ], StepCheckpointEntity.prototype, "startedAt", void 0);
174
- __decorate([
175
- (0, core_1.Property)(),
176
- __metadata("design:type", Date)
177
- ], StepCheckpointEntity.prototype, "finishedAt", void 0);
178
- exports.StepCheckpointEntity = StepCheckpointEntity = __decorate([
179
- (0, core_1.Entity)({ tableName: 'durable_step_checkpoints' })
180
- ], StepCheckpointEntity);
181
- let SignalWaiterEntity = class SignalWaiterEntity {
182
- token;
183
- runId;
184
- seq;
185
- };
186
- exports.SignalWaiterEntity = SignalWaiterEntity;
187
- __decorate([
188
- (0, core_1.PrimaryKey)(),
189
- __metadata("design:type", String)
190
- ], SignalWaiterEntity.prototype, "token", void 0);
191
- __decorate([
192
- (0, core_1.Property)(),
193
- __metadata("design:type", String)
194
- ], SignalWaiterEntity.prototype, "runId", void 0);
195
- __decorate([
196
- (0, core_1.Property)(),
197
- __metadata("design:type", Number)
198
- ], SignalWaiterEntity.prototype, "seq", void 0);
199
- exports.SignalWaiterEntity = SignalWaiterEntity = __decorate([
200
- (0, core_1.Entity)({ tableName: 'durable_signal_waiters' })
201
- ], SignalWaiterEntity);
202
- let BufferedSignalEntity = class BufferedSignalEntity {
203
- id;
204
- token;
205
- payload;
206
- };
207
- exports.BufferedSignalEntity = BufferedSignalEntity;
208
- __decorate([
209
- (0, core_1.PrimaryKey)({ autoincrement: true }),
210
- __metadata("design:type", Number)
211
- ], BufferedSignalEntity.prototype, "id", void 0);
212
- __decorate([
213
- (0, core_1.Property)({ index: true }),
214
- __metadata("design:type", String)
215
- ], BufferedSignalEntity.prototype, "token", void 0);
216
- __decorate([
217
- (0, core_1.Property)({ type: 'json', nullable: true }),
218
- __metadata("design:type", Object)
219
- ], BufferedSignalEntity.prototype, "payload", void 0);
220
- exports.BufferedSignalEntity = BufferedSignalEntity = __decorate([
221
- (0, core_1.Entity)({ tableName: 'durable_buffered_signals' })
222
- ], BufferedSignalEntity);
223
- exports.ENTITIES = [
224
- WorkflowRunEntity,
225
- StepCheckpointEntity,
226
- SignalWaiterEntity,
227
- BufferedSignalEntity,
228
- ];
229
- //# sourceMappingURL=entities.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entities.js","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0CAA+D;AAGxD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE5B,EAAE,CAAU;IAGZ,QAAQ,CAAU;IAGlB,eAAe,CAAU;IAGzB,MAAM,CAAa;IAGnB,KAAK,CAAW;IAGhB,MAAM,CAAW;IAGjB,KAAK,CAAW;IAGhB,MAAM,CAAQ;IAGd,QAAQ,CAAU;IAGlB,WAAW,CAAQ;IAGnB,gBAAgB,CAAU;IAG1B,IAAI,CAAmB;IAGvB,gBAAgB,CAAoD;IAGpE,SAAS,CAAQ;IAGjB,SAAS,CAAQ;CAClB,CAAA;AA7CY,8CAAiB;AAE5B;IADC,IAAA,iBAAU,GAAE;;6CACD;AAGZ;IADC,IAAA,eAAQ,GAAE;;mDACO;AAGlB;IADC,IAAA,eAAQ,GAAE;;0DACc;AAGzB;IADC,IAAA,eAAQ,GAAE;;iDACQ;AAGnB;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC3B;AAGhB;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDAC1B;AAGjB;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC3B;AAGhB;IADC,IAAA,eAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACpB,IAAI;iDAAC;AAGd;IADC,IAAA,eAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACX;AAGlB;IADC,IA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BAAoB;IAE/B,EAAE,CAAU;IAGZ,KAAK,CAAU;IAGf,OAAO,CAAW;CACnB,CAAA;AATY,oDAAoB;AAE/B;IADC,IAAA,iBAAU,EAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;;gDACxB;AAGZ;IADC,IAAA,eAAQ,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;mDACX;AAGf;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACzB;+BARP,oBAAoB;IADhC,IAAA,aAAM,EAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC;GACrC,oBAAoB,CAShC;AAEY,QAAA,QAAQ,GAAG;IACtB,iBAAiB;IACjB,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;CACZ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC"}
@@ -1,37 +0,0 @@
1
- import { type RunQuery, type SignalWaiter, type StateStore, type StepCheckpoint, type WorkflowRun } from '@dudousxd/nestjs-durable-core';
2
- import type { MikroORM } from '@mikro-orm/core';
3
- /**
4
- * MikroORM-backed `StateStore`. Works on any MikroORM driver — Postgres, MySQL, SQLite (tested);
5
- * timestamps and `wakeAt` use native datetime columns. Each operation runs on a forked
6
- * EntityManager so it owns its unit of work.
7
- */
8
- export declare class MikroOrmStateStore implements StateStore {
9
- private readonly orm;
10
- constructor(orm: MikroORM);
11
- ensureSchema(): Promise<void>;
12
- createRun(run: WorkflowRun): Promise<void>;
13
- updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
14
- getRun(runId: string): Promise<WorkflowRun | null>;
15
- getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
16
- saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
17
- transaction<T>(work: (tx: {
18
- raw: unknown;
19
- saveCheckpoint: (cp: StepCheckpoint) => Promise<void>;
20
- }) => Promise<T>): Promise<T>;
21
- listIncompleteRuns(): Promise<WorkflowRun[]>;
22
- listPendingRuns(limit: number): Promise<WorkflowRun[]>;
23
- listDueTimers(nowMs: number): Promise<WorkflowRun[]>;
24
- tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
25
- releaseRunLock(runId: string): Promise<void>;
26
- renewRunLock(runId: string, owner: string, leaseUntilMs: number): Promise<boolean>;
27
- listRuns(query: RunQuery): Promise<WorkflowRun[]>;
28
- listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
29
- putSignalWaiter(waiter: SignalWaiter): Promise<void>;
30
- takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
31
- listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
32
- bufferSignal(token: string, payload: unknown): Promise<void>;
33
- takeBufferedSignal(token: string): Promise<{
34
- payload: unknown;
35
- } | null>;
36
- }
37
- //# sourceMappingURL=mikro-orm-state-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mikro-orm-state-store.d.ts","sourceRoot":"","sources":["../src/mikro-orm-state-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,cAAc,EAGnB,KAAK,WAAW,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAShD;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,UAAU;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,QAAQ;IAEpC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1C,SAAS,CAAC,KAAK,EAA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