@nest-batch/typeorm 0.2.0 → 0.2.2

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/README.ko.md ADDED
@@ -0,0 +1,55 @@
1
+ # @nest-batch/typeorm
2
+
3
+ `@nest-batch/core`용 TypeORM persistence adapter입니다.
4
+
5
+ English: [README.md](./README.md)
6
+
7
+ ## 설치
8
+
9
+ ```bash
10
+ pnpm add @nest-batch/core @nest-batch/typeorm typeorm
11
+ ```
12
+
13
+ Nest 애플리케이션에서 `@nestjs/typeorm`을 사용한다면 기존 `TypeOrmModule.forRoot`
14
+ 구성을 그대로 소유하면 됩니다.
15
+
16
+ ## Public Import
17
+
18
+ ```ts
19
+ import {
20
+ BATCH_META_ENTITIES,
21
+ TypeOrmAdapter,
22
+ TypeOrmJobRepository,
23
+ TypeOrmTransactionManager,
24
+ batchMetaEntities,
25
+ } from '@nest-batch/typeorm';
26
+ ```
27
+
28
+ ## Wiring
29
+
30
+ host-owned TypeORM data source에 batch metadata entity를 등록합니다.
31
+
32
+ ```ts
33
+ import { TypeOrmModule } from '@nestjs/typeorm';
34
+ import { InProcessAdapter, NestBatchModule } from '@nest-batch/core';
35
+ import { BATCH_META_ENTITIES, TypeOrmAdapter } from '@nest-batch/typeorm';
36
+
37
+ @Module({
38
+ imports: [
39
+ TypeOrmModule.forRoot({
40
+ type: 'postgres',
41
+ entities: [ProductEntity, ...BATCH_META_ENTITIES],
42
+ url: process.env.DATABASE_URL,
43
+ }),
44
+ NestBatchModule.forRoot({
45
+ adapters: {
46
+ persistence: TypeOrmAdapter.forRoot(),
47
+ transport: InProcessAdapter.forRoot(),
48
+ },
49
+ }),
50
+ ],
51
+ })
52
+ export class AppModule {}
53
+ ```
54
+
55
+ metadata entity를 추가한 뒤 application repository에서 migration을 생성하세요.
package/README.md CHANGED
@@ -1,263 +1,56 @@
1
- # `@nest-batch/typeorm`
1
+ # @nest-batch/typeorm
2
2
 
3
- The TypeORM 1.0.0 adapter for [`@nest-batch/core`](../core). It owns
4
- the same six Spring Batch-compatible batch meta-tables that
5
- `@nest-batch/mikro-orm` ships, expressed as TypeORM 1.0 entities plus
6
- a bundled migration. It exposes `TypeOrmJobRepository` and
7
- `TypeOrmTransactionManager` and runs the shared core contract suite
8
- against a real TypeORM `DataSource`.
3
+ TypeORM persistence adapter for `@nest-batch/core`.
9
4
 
10
- The package is a **sibling**, not a replacement. The dependency
11
- direction is strict and one-way:
12
-
13
- ```
14
- @nest-batch/typeorm ──▶ @nest-batch/core
15
-
16
- └──────▶ typeorm (peer, ^1.0.0)
17
- ```
18
-
19
- `@nest-batch/core` does not know this package exists. The boundary is
20
- enforced by a core test that fails the build if any `typeorm` import
21
- shows up in core.
22
-
23
- ---
24
-
25
- ## TypeORM 1.0.0-only policy
26
-
27
- This adapter targets **TypeORM 1.0.0 only**. The peer range is
28
- `typeorm: ^1.0.0` and intentionally excludes `0.3.x`.
29
-
30
- Why 1.0.0 and not 0.3? Two reasons:
31
-
32
- 1. The `Connection` → `DataSource` rename. TypeORM 1.0.0 finished the
33
- rename that 0.3 started; the API now exposes `DataSource`,
34
- `DataSourceOptions`, and `DataSource.transaction()` instead of
35
- `Connection`, `ConnectionOptions`, and `Connection.transaction()`.
36
- Maintaining 0.3 support would mean running the full codebase
37
- through `Connection → DataSource` shims, which is a waste of
38
- effort when 0.3 is on a separate support track.
39
- 2. The entity / migration surface. A few decorators and migration
40
- helpers moved between 0.3 and 1.0. Supporting both means
41
- conditional entity definitions, which is a smell.
42
-
43
- The peer range is `^1.0.0`, so any 1.x release works. The boundary
44
- test in core and a dedicated peer-range test in this package
45
- together ensure 0.3 does not silently sneak back in.
46
-
47
- If you're on TypeORM 0.3, stay on the previous
48
- `@nest-batch/nest-batch` package (pre-rename) or upgrade TypeORM
49
- first. There's no compatibility shim in this release.
50
-
51
- ---
5
+ Korean: [README.ko.md](./README.ko.md)
52
6
 
53
7
  ## Install
54
8
 
55
9
  ```bash
56
- pnpm add @nest-batch/typeorm
10
+ pnpm add @nest-batch/core @nest-batch/typeorm typeorm
57
11
  ```
58
12
 
59
- Peer dependencies the host must already provide:
60
-
61
- | Package | Range |
62
- | ------------------ | ------------- |
63
- | `@nest-batch/core` | `workspace:*` |
64
- | `typeorm` | `^1.0.0` |
13
+ If your Nest application uses `@nestjs/typeorm`, keep using your normal
14
+ `TypeOrmModule.forRoot` configuration.
65
15
 
66
- `typeorm` is a hard peer (declared in `peerDependencies` with
67
- `optional: false`). The `package.json` also lists it as a
68
- `devDependency` so the package's own test suite can resolve it
69
- without the host.
16
+ ## Public Imports
70
17
 
71
- ---
72
-
73
- ## Schema ownership
74
-
75
- This package owns the same six batch meta tables as
76
- `@nest-batch/mikro-orm`:
77
-
78
- | Table | Purpose |
79
- | ------------------------------ | ---------------------------------------------------------------------------------- |
80
- | `batch_job_instance` | One row per logical job (unique on `job_name`+`job_key`). |
81
- | `batch_job_execution` | One row per job run. Holds status, start/end, exit code/message. |
82
- | `batch_job_execution_params` | Composite-keyed params (one row per param name). |
83
- | `batch_step_execution` | One row per step run. Holds step status, exit code/message, last-chunk checkpoint. |
84
- | `batch_job_execution_context` | JSON checkpoint + execution context (job-scoped). |
85
- | `batch_step_execution_context` | JSON checkpoint + execution context (step-scoped). |
86
-
87
- The bundled migration lives at
88
- `src/migrations/1700000000000-CreateBatchMeta.ts` and is exported
89
- as `CreateBatchMeta1700000000000` from the package root. Apps that
90
- already have a TypeORM migration directory should copy the file in
91
- and renumber it to fit their own migration sequence.
92
-
93
- > **Note:** The six batch meta entities are also exported as a
94
- > single tuple under `batchMetaEntities` from the package root.
95
- > Because the adapter no longer bootstraps the `DataSource` (the
96
- > host owns the `TypeOrmModule.forRoot()` call), spreading
97
- > `batchMetaEntities` into your own `entities` array is the only
98
- > way the meta tables are registered with TypeORM's metadata
99
- > system. Forgetting the spread means `Repository<Entity>` lookups
100
- > for the meta tables fail silently and the repository throws at
101
- > first call.
102
-
103
- > The migration uses `datetime` (not `timestamptz`) on the SQLite
104
- > test driver and `timestamptz` on PostgreSQL production. The
105
- > entities declare `datetime` for portability, and the migration
106
- > handler emits the right per-driver type. This is intentional:
107
- > the test suite runs against `better-sqlite3` for speed, and the
108
- > production driver is PostgreSQL.
109
-
110
- ---
18
+ ```ts
19
+ import {
20
+ BATCH_META_ENTITIES,
21
+ TypeOrmAdapter,
22
+ TypeOrmJobRepository,
23
+ TypeOrmTransactionManager,
24
+ batchMetaEntities,
25
+ } from '@nest-batch/typeorm';
26
+ ```
111
27
 
112
28
  ## Wiring
113
29
 
114
- Wire the adapter with two imports in `AppModule.imports`: a host-
115
- owned `TypeOrmModule.forRoot()` call (which builds the
116
- `DataSource` and registers the meta entities) and a
117
- `TypeOrmAdapter.forRoot()` carrier passed to
118
- `NestBatchModule.forRoot({ adapters: { persistence, ... } })`.
119
-
120
- ### Bring-your-own `DataSource` (recommended)
121
-
122
- If your app already uses `@nestjs/typeorm` (the typical case for a
123
- Nest app with user-domain entities), call
124
- `TypeOrmModule.forRoot()` yourself, spread `batchMetaEntities()`
125
- into its `entities` array, and pass the adapter's no-arg
126
- `TypeOrmAdapter.forRoot()` to `NestBatchModule.forRoot()` under
127
- `adapters.persistence`:
30
+ Register the batch metadata entities in your host-owned TypeORM data source.
128
31
 
129
32
  ```ts
130
- import { Module } from '@nestjs/common';
131
33
  import { TypeOrmModule } from '@nestjs/typeorm';
132
- import { NestBatchModule } from '@nest-batch/core';
133
- import {
134
- batchMetaEntities,
135
- CreateBatchMeta1700000000000,
136
- TypeOrmAdapter,
137
- } from '@nest-batch/typeorm';
138
- import { ProductEntity } from './entities/product.entity';
34
+ import { InProcessAdapter, NestBatchModule } from '@nest-batch/core';
35
+ import { BATCH_META_ENTITIES, TypeOrmAdapter } from '@nest-batch/typeorm';
139
36
 
140
37
  @Module({
141
38
  imports: [
142
39
  TypeOrmModule.forRoot({
143
40
  type: 'postgres',
144
- host: '127.0.0.1',
145
- port: 5434,
146
- username: 'demo',
147
- password: 'demo',
148
- database: 'nest_batch_demo',
149
- entities: [ProductEntity, ...batchMetaEntities()],
150
- migrations: [CreateBatchMeta1700000000000 /* your other migrations */],
151
- migrationsRun: true,
41
+ entities: [ProductEntity, ...BATCH_META_ENTITIES],
42
+ url: process.env.DATABASE_URL,
152
43
  }),
153
44
  NestBatchModule.forRoot({
154
- adapters: { persistence: TypeOrmAdapter.forRoot() },
45
+ adapters: {
46
+ persistence: TypeOrmAdapter.forRoot(),
47
+ transport: InProcessAdapter.forRoot(),
48
+ },
155
49
  }),
156
50
  ],
157
51
  })
158
52
  export class AppModule {}
159
53
  ```
160
54
 
161
- `TypeOrmAdapter.forRoot()` takes no arguments on purpose. The host
162
- already owns the `TypeOrmModule.forRoot()` call; the adapter only
163
- declares its own provider and export surface. The
164
- `JOB_REPOSITORY_TOKEN` and `TRANSACTION_MANAGER_TOKEN` bindings are
165
- registered globally by the adapter, so you do **not** list
166
- `TypeOrmJobRepository` / `TypeOrmTransactionManager` in the
167
- `providers` array — they're already wired.
168
-
169
- > **Warning:** The adapter does **not** call `TypeOrmModule.forRoot()`
170
- > and does **not** create a `DataSource`. If you forget the
171
- > `TypeOrmModule.forRoot()` import, the app boots cleanly and the
172
- > batch module compiles, but the repository throws at first call
173
- > because `Repository<Entity>` resolution has nothing to bind to.
174
- > The two pieces are decoupled by design — the adapter is a
175
- > binding-only carrier, and the connection is the host's.
176
-
177
- > **Note:** `@nestjs/typeorm` defaults to `isGlobal: true`, which
178
- > is what the adapter assumes. Setting `isGlobal: false` breaks
179
- > `EntityManager` injection inside the adapter's own module: the
180
- > `DataSource` is registered on the host's `TypeOrmModule.forRoot()`
181
- > but the adapter module is `global: true`, so the `EntityManager`
182
- > token it needs is not exported across the boundary. Leave it at
183
- > the default unless you've wired an alternative.
184
-
185
- `forRootAsync` is the right call when the connection comes from a
186
- config service or a secret manager. Pass the standard `useFactory`
187
- plus `inject` list to `TypeOrmModule.forRootAsync()` and keep
188
- `TypeOrmAdapter.forRoot()` unchanged — the adapter doesn't care
189
- how the `DataSource` is built.
190
-
191
- ### DataSource, not Connection
192
-
193
- TypeORM 1.0.0 calls it `DataSource`. The old `Connection` type is
194
- gone, and so is `getConnection()` / `getRepository()` on the
195
- connection. Every example in this README uses `DataSource`. If
196
- you're migrating from a 0.3 codebase, the rename touches every
197
- test file, every import, and every import path — there is no
198
- `@typeorm/0.3-compat` shim.
199
-
200
- The `TypeOrmTransactionManager` accepts a `DataSource` and uses
201
- `dataSource.transaction()` to start a real DB transaction. The
202
- callback receives a transactional `EntityManager`; use that one,
203
- not a globally-injected one, so all reads and writes are part of
204
- the same transaction.
205
-
206
- ---
207
-
208
- ## DB-first semantics
209
-
210
- The repository is the durable source of truth for execution state.
211
- Same model as the MikroORM adapter, same invariants:
212
-
213
- 1. **The DB is canonical.** A BullMQ job is a correlation stamp, not
214
- a state row. The `JobExecution` row carries the actual
215
- `status`, `startTime`, `endTime`, `exitCode`, and `exitMessage`.
216
- 2. **Atomic launches are enforced by the row lock.** The
217
- `createExecutionAtomic` flow uses a transactional
218
- `SELECT ... FOR UPDATE SKIP LOCKED` (on PostgreSQL) to serialize
219
- concurrent launches. Two callers racing to launch the same
220
- `jobName + jobKey` get one winner; the loser sees a thrown
221
- `JobExecutionAlreadyRunningError`.
222
- 3. **Restart and checkpoint go through the DB.** `findLatestStepExecution`
223
- returns the most recent `StepExecution` for `(jobExecutionId, stepName)`
224
- regardless of status, so the executor can load the
225
- last-committed chunk index from
226
- `batch_step_execution_context` and resume from there.
227
-
228
- The contract suite is the same one `@nest-batch/mikro-orm` runs. If
229
- you change the repository or transaction manager, run the suite to
230
- confirm you haven't broken the contract.
231
-
232
- ---
233
-
234
- ## What is NOT in this package
235
-
236
- - A TypeORM 0.3 adapter. Use 1.0.0 or stay on the previous package.
237
- - A Drizzle adapter. Drizzle is explicitly excluded from this
238
- release. See `MIGRATION.md`.
239
- - A MikroORM adapter. Use `@nest-batch/mikro-orm` if you want
240
- MikroORM 6; the two packages expose the same six-table schema.
241
- - A transport. Use `@nest-batch/bullmq` to wire BullMQ as the
242
- execution strategy; the transport layer reads the same
243
- `JobExecution` rows.
244
- - An admin UI, metrics, tracing, webhook, or job visualization
245
- surface. Out of scope for the whole `@nest-batch/*` family.
246
-
247
- ---
248
-
249
- ## Scripts
250
-
251
- ```bash
252
- pnpm --filter @nest-batch/typeorm build # SWC transpile + tsc declarations
253
- pnpm --filter @nest-batch/typeorm test # vitest run (uses better-sqlite3 by default)
254
- pnpm --filter @nest-batch/typeorm test:watch # vitest watch
255
- pnpm --filter @nest-batch/typeorm typecheck # tsc --noEmit
256
- ```
257
-
258
- The contract suite runs against an in-memory SQLite database by
259
- default. The test driver is `better-sqlite3` because it gives
260
- sub-millisecond setup and teardown, and the contract tests are
261
- database-agnostic enough to not need a full PostgreSQL harness.
262
- For an end-to-end Postgres run, point the suite at your own
263
- `DataSource` via the documented test harness hook.
55
+ Generate migrations in the application repository after adding the metadata
56
+ entities.
@@ -4,8 +4,8 @@
4
4
  * One row per logical job instance. Uniqueness is enforced on
5
5
  * (jobName, jobKey) so that the same canonical key resolves to the
6
6
  * same instance across restarts. The composite unique index is
7
- * declared on the entity and is also reified in the bundled
8
- * migration under the same name.
7
+ * declared on the entity so host-owned TypeORM migrations can
8
+ * generate the matching database constraint.
9
9
  */
10
10
  export declare class JobInstanceEntity {
11
11
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"job-meta.entities.d.ts","sourceRoot":"","sources":["../../../src/entities/job-meta.entities.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,qBAEa,iBAAiB;IAE5B,EAAE,EAAG,MAAM,CAAC;IAGZ,OAAO,EAAG,MAAM,CAAC;IAGjB,MAAM,EAAG,MAAM,CAAC;IAYhB,SAAS,EAAE,IAAI,CAAc;CAC9B;AAED;;;;;;;;GAQG;AACH,qBAEa,kBAAkB;IAE7B,EAAE,EAAG,MAAM,CAAC;IAGZ,aAAa,EAAG,MAAM,CAAC;IAGvB,MAAM,EAAG,MAAM,CAAC;I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G;AACH,qBAEa,kBAAkB;IAE7B,EAAE,EAAG,MAAM,CAAC;IAGZ,aAAa,EAAG,MAAM,CAAC;IAGvB,MAAM,EAAG,MAAM,CAAC;IAGhB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAQ;IAG9B,OAAO,EAAE,IAAI,GAAG,IAAI,CAAQ;IAG5B,QAAQ,EAAG,MAAM,CAAC;IAGlB,WAAW,EAAG,MAAM,CAAC;IAErB;;;;;OAKG;IAEH,MAAM,EAAG,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,qBAEa,mBAAmB;IAE9B,EAAE,EAAG,MAAM,CAAC;IAGZ,cAAc,EAAG,MAAM,CAAC;IAGxB,QAAQ,EAAG,MAAM,CAAC;IAGlB,MAAM,EAAG,MAAM,CAAC;IAGhB,SAAS,EAAG,MAAM,CAAC;IAGnB,UAAU,EAAG,MAAM,CAAC;IAGpB,SAAS,EAAG,MAAM,CAAC;IAGnB,aAAa,EAAG,MAAM,CAAC;IAGvB,WAAW,EAAG,MAAM,CAAC;IAGrB,QAAQ,EAAG,MAAM,CAAC;IAGlB,WAAW,EAAG,MAAM,CAAC;IAOrB,SAAS,EAAE,IAAI,CAAc;CAC9B;AAED;;;;;GAKG;AACH,qBACa,yBAAyB;IAEpC,cAAc,EAAG,MAAM,CAAC;IAGxB,IAAI,EAAG,MAAM,CAAC;IAGd,OAAO,EAAG,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,qBACa,0BAA0B;IAErC,eAAe,EAAG,MAAM,CAAC;IAGzB,IAAI,EAAG,MAAM,CAAC;IAGd,OAAO,EAAG,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,iKAMtB,CAAC"}
@@ -71,10 +71,9 @@ _ts_decorate([
71
71
  (0, _typeorm.Column)({
72
72
  name: 'created_at',
73
73
  // `datetime` is portable across PostgreSQL and SQLite (the test
74
- // driver). The bundled migration uses timestamptz on
75
- // PostgreSQL by hand; SQLite loses the timezone qualifier,
76
- // which is acceptable for a creation-time stamp that is never
77
- // compared with sub-second precision in queries.
74
+ // driver). Hosts that generate PostgreSQL migrations can map the
75
+ // same logical column to timestamptz in their own migration
76
+ // pipeline.
78
77
  type: 'datetime',
79
78
  default: ()=>'CURRENT_TIMESTAMP'
80
79
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/entities/job-meta.entities.ts"],"sourcesContent":["import { Entity, PrimaryColumn, Column, Index } from 'typeorm';\n\n/**\n * `batch_job_instance` metadata row.\n *\n * One row per logical job instance. Uniqueness is enforced on\n * (jobName, jobKey) so that the same canonical key resolves to the\n * same instance across restarts. The composite unique index is\n * declared on the entity and is also reified in the bundled\n * migration under the same name.\n */\n@Entity('batch_job_instance')\n@Index('batch_job_instance_job_name_job_key_unique', ['jobName', 'jobKey'], { unique: true })\nexport class JobInstanceEntity {\n @PrimaryColumn({ type: 'varchar', length: 255 })\n id!: string;\n\n @Column({ name: 'job_name', type: 'varchar', length: 255 })\n jobName!: string;\n\n @Column({ name: 'job_key', type: 'varchar', length: 255 })\n jobKey!: string;\n\n @Column({\n name: 'created_at',\n // `datetime` is portable across PostgreSQL and SQLite (the test\n // driver). The bundled migration uses timestamptz on\n // PostgreSQL by hand; SQLite loses the timezone qualifier,\n // which is acceptable for a creation-time stamp that is never\n // compared with sub-second precision in queries.\n type: 'datetime',\n default: () => 'CURRENT_TIMESTAMP',\n })\n createdAt: Date = new Date();\n}\n\n/**\n * `batch_job_execution` metadata row.\n *\n * One row per job run. `status` is the stringified JobStatus enum\n * (kept as a plain varchar — TypeORM enum support varies across\n * drivers and v1.0.0 dropped a few columns we don't need). The\n * `jobInstanceId` column is indexed because every contract lookup\n * (\"is this instance running?\") scans by it.\n */\n@Entity('batch_job_execution')\n@Index('batch_job_execution_job_instance_id_index', ['jobInstanceId'])\nexport class JobExecutionEntity {\n @PrimaryColumn({ type: 'varchar', length: 255 })\n id!: string;\n\n @Column({ name: 'job_instance_id', type: 'varchar', length: 255 })\n jobInstanceId!: string;\n\n @Column({ type: 'varchar', length: 20 })\n status!: string;\n\n @Column({ name: 'start_time', type: 'datetime', nullable: true })\n startTime: Date | null = null;\n\n @Column({ name: 'end_time', type: 'datetime', nullable: true })\n endTime: Date | null = null;\n\n @Column({ name: 'exit_code', type: 'varchar', length: 255, default: '' })\n exitCode!: string;\n\n @Column({ name: 'exit_message', type: 'text', default: '' })\n exitMessage!: string;\n\n /**\n * JSON-serialized `JobParameters` snapshot. Stored as `text` (not\n * native `jsonb`) so the adapter works uniformly across SQLite (used\n * in unit tests) and PostgreSQL/MySQL — the column is always a\n * serialized payload, never queried by the ORM.\n */\n @Column({ name: 'params', type: 'text', default: '{}' })\n params!: string;\n}\n\n/**\n * `batch_step_execution` metadata row.\n *\n * One row per step run. Counters default to 0 so the entity can\n * be persisted immediately upon creation, before any items are\n * processed. `createdAt` is stamped on insert and used by\n * `findLatestStepExecution` to resolve the most recently created\n * step for a given `(jobExecutionId, stepName)` pair — a v4 UUID\n * primary key does not preserve insertion order, so an explicit\n * monotonic column is required.\n */\n@Entity('batch_step_execution')\n@Index('batch_step_execution_job_execution_id_index', ['jobExecutionId'])\nexport class StepExecutionEntity {\n @PrimaryColumn({ type: 'varchar', length: 255 })\n id!: string;\n\n @Column({ name: 'job_execution_id', type: 'varchar', length: 255 })\n jobExecutionId!: string;\n\n @Column({ name: 'step_name', type: 'varchar', length: 255 })\n stepName!: string;\n\n @Column({ type: 'varchar', length: 20 })\n status!: string;\n\n @Column({ name: 'read_count', type: 'int', default: 0 })\n readCount!: number;\n\n @Column({ name: 'write_count', type: 'int', default: 0 })\n writeCount!: number;\n\n @Column({ name: 'skip_count', type: 'int', default: 0 })\n skipCount!: number;\n\n @Column({ name: 'rollback_count', type: 'int', default: 0 })\n rollbackCount!: number;\n\n @Column({ name: 'commit_count', type: 'int', default: 0 })\n commitCount!: number;\n\n @Column({ name: 'exit_code', type: 'varchar', length: 255, default: '' })\n exitCode!: string;\n\n @Column({ name: 'exit_message', type: 'text', default: '' })\n exitMessage!: string;\n\n @Column({\n name: 'created_at',\n type: 'datetime',\n default: () => 'CURRENT_TIMESTAMP',\n })\n createdAt: Date = new Date();\n}\n\n/**\n * `batch_job_execution_context` metadata row.\n *\n * `data` is a JSON-serialized ExecutionContext payload. `version`\n * guards against lost updates during concurrent writers.\n */\n@Entity('batch_job_execution_context')\nexport class JobExecutionContextEntity {\n @PrimaryColumn({ name: 'job_execution_id', type: 'varchar', length: 255 })\n jobExecutionId!: string;\n\n @Column({ type: 'text' })\n data!: string;\n\n @Column({ type: 'int', default: 0 })\n version!: number;\n}\n\n/**\n * `batch_step_execution_context` metadata row.\n *\n * Mirrors the job-level context table but scoped to a single\n * step execution. There is intentionally no params sibling table\n * for steps — step parameters are derivable from the parent job\n * execution params + the step execution context.\n */\n@Entity('batch_step_execution_context')\nexport class StepExecutionContextEntity {\n @PrimaryColumn({ name: 'step_execution_id', type: 'varchar', length: 255 })\n stepExecutionId!: string;\n\n @Column({ type: 'text' })\n data!: string;\n\n @Column({ type: 'int', default: 0 })\n version!: number;\n}\n\n/**\n * All batch meta entities owned by this package. Hand to\n * `DataSource#entityMetadatas` (or `entities:`) so TypeORM\n * discovers them through the standard decorator scan.\n */\nexport const BATCH_META_ENTITIES = [\n JobInstanceEntity,\n JobExecutionEntity,\n StepExecutionEntity,\n JobExecutionContextEntity,\n StepExecutionContextEntity,\n] as const;\n"],"names":["BATCH_META_ENTITIES","JobExecutionContextEntity","JobExecutionEntity","JobInstanceEntity","StepExecutionContextEntity","StepExecutionEntity","id","jobName","jobKey","createdAt","Date","type","length","name","default","unique","jobInstanceId","status","startTime","endTime","exitCode","exitMessage","params","nullable","jobExecutionId","stepName","readCount","writeCount","skipCount","rollbackCount","commitCount","data","version","stepExecutionId"],"mappings":";;;;;;;;;;;QAiLaA;eAAAA;;QApCAC;eAAAA;;QA9FAC;eAAAA;;QAlCAC;eAAAA;;QAoJAC;eAAAA;;QArEAC;eAAAA;;;yBA5FwC;;;;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/B;;;QAvCmBC,MAAM;QAAWC,QAAQ;;;;;;QAGhCC,MAAM;QAAoBF,MAAM;QAAWC,QAAQ;;;;;;QAGnDC,MAAM;QAAaF,MAAM;QAAWC,QAAQ;;;;;;QAG5CD,MAAM;QAAWC,QAAQ;;;;;;QAGzBC,MAAM;QAAcF,MAAM;QAAOG,SAAS;;;;;;QAG1CD,MAAM;QAAeF,MAAM;QAAOG,SAAS;;;;;;QAG3CD,MAAM;QAAcF,MAAM;QAAOG,SAAS;;;;;;QAG1CD,MAAM;QAAkBF,MAAM;QAAOG,SAAS;;;;;;QAG9CD,MAAM;QAAgBF,MAAM;QAAOG,SAAS;;;;;;QAG5CD,MAAM;QAAaF,MAAM;QAAWC,QAAQ;QAAKE,SAAS;;;;;;QAG1DD,MAAM;QAAgBF,MAAM;QAAQG,SAAS;;;;;;QAIrDD,MAAM;QACNF,MAAM;QACNG,SAAS,IAAM;;;;;;;QAtCoC;;;AAkDhD,IAAA,AAAMb,4BAAN,MAAMA;IAEXuB,eAAwB;IAGxBO,KAAc;IAGdC,QAAiB;AACnB;;;QARmBnB,MAAM;QAAoBF,MAAM;QAAWC,QAAQ;;;;;;QAG1DD,MAAM;;;;;;QAGNA,MAAM;QAAOG,SAAS;;;;;;;AAa3B,IAAA,AAAMV,6BAAN,MAAMA;IAEX6B,gBAAyB;IAGzBF,KAAc;IAGdC,QAAiB;AACnB;;;QARmBnB,MAAM;QAAqBF,MAAM;QAAWC,QAAQ;;;;;;QAG3DD,MAAM;;;;;;QAGNA,MAAM;QAAOG,SAAS;;;;;;;AAS3B,MAAMd,sBAAsB;IACjCG;IACAD;IACAG;IACAJ;IACAG;CACD"}
1
+ {"version":3,"sources":["../../../src/entities/job-meta.entities.ts"],"sourcesContent":["import { Entity, PrimaryColumn, Column, Index } from 'typeorm';\n\n/**\n * `batch_job_instance` metadata row.\n *\n * One row per logical job instance. Uniqueness is enforced on\n * (jobName, jobKey) so that the same canonical key resolves to the\n * same instance across restarts. The composite unique index is\n * declared on the entity so host-owned TypeORM migrations can\n * generate the matching database constraint.\n */\n@Entity('batch_job_instance')\n@Index('batch_job_instance_job_name_job_key_unique', ['jobName', 'jobKey'], { unique: true })\nexport class JobInstanceEntity {\n @PrimaryColumn({ type: 'varchar', length: 255 })\n id!: string;\n\n @Column({ name: 'job_name', type: 'varchar', length: 255 })\n jobName!: string;\n\n @Column({ name: 'job_key', type: 'varchar', length: 255 })\n jobKey!: string;\n\n @Column({\n name: 'created_at',\n // `datetime` is portable across PostgreSQL and SQLite (the test\n // driver). Hosts that generate PostgreSQL migrations can map the\n // same logical column to timestamptz in their own migration\n // pipeline.\n type: 'datetime',\n default: () => 'CURRENT_TIMESTAMP',\n })\n createdAt: Date = new Date();\n}\n\n/**\n * `batch_job_execution` metadata row.\n *\n * One row per job run. `status` is the stringified JobStatus enum\n * (kept as a plain varchar — TypeORM enum support varies across\n * drivers and v1.0.0 dropped a few columns we don't need). The\n * `jobInstanceId` column is indexed because every contract lookup\n * (\"is this instance running?\") scans by it.\n */\n@Entity('batch_job_execution')\n@Index('batch_job_execution_job_instance_id_index', ['jobInstanceId'])\nexport class JobExecutionEntity {\n @PrimaryColumn({ type: 'varchar', length: 255 })\n id!: string;\n\n @Column({ name: 'job_instance_id', type: 'varchar', length: 255 })\n jobInstanceId!: string;\n\n @Column({ type: 'varchar', length: 20 })\n status!: string;\n\n @Column({ name: 'start_time', type: 'datetime', nullable: true })\n startTime: Date | null = null;\n\n @Column({ name: 'end_time', type: 'datetime', nullable: true })\n endTime: Date | null = null;\n\n @Column({ name: 'exit_code', type: 'varchar', length: 255, default: '' })\n exitCode!: string;\n\n @Column({ name: 'exit_message', type: 'text', default: '' })\n exitMessage!: string;\n\n /**\n * JSON-serialized `JobParameters` snapshot. Stored as `text` (not\n * native `jsonb`) so the adapter works uniformly across SQLite (used\n * in unit tests) and PostgreSQL/MySQL — the column is always a\n * serialized payload, never queried by the ORM.\n */\n @Column({ name: 'params', type: 'text', default: '{}' })\n params!: string;\n}\n\n/**\n * `batch_step_execution` metadata row.\n *\n * One row per step run. Counters default to 0 so the entity can\n * be persisted immediately upon creation, before any items are\n * processed. `createdAt` is stamped on insert and used by\n * `findLatestStepExecution` to resolve the most recently created\n * step for a given `(jobExecutionId, stepName)` pair — a v4 UUID\n * primary key does not preserve insertion order, so an explicit\n * monotonic column is required.\n */\n@Entity('batch_step_execution')\n@Index('batch_step_execution_job_execution_id_index', ['jobExecutionId'])\nexport class StepExecutionEntity {\n @PrimaryColumn({ type: 'varchar', length: 255 })\n id!: string;\n\n @Column({ name: 'job_execution_id', type: 'varchar', length: 255 })\n jobExecutionId!: string;\n\n @Column({ name: 'step_name', type: 'varchar', length: 255 })\n stepName!: string;\n\n @Column({ type: 'varchar', length: 20 })\n status!: string;\n\n @Column({ name: 'read_count', type: 'int', default: 0 })\n readCount!: number;\n\n @Column({ name: 'write_count', type: 'int', default: 0 })\n writeCount!: number;\n\n @Column({ name: 'skip_count', type: 'int', default: 0 })\n skipCount!: number;\n\n @Column({ name: 'rollback_count', type: 'int', default: 0 })\n rollbackCount!: number;\n\n @Column({ name: 'commit_count', type: 'int', default: 0 })\n commitCount!: number;\n\n @Column({ name: 'exit_code', type: 'varchar', length: 255, default: '' })\n exitCode!: string;\n\n @Column({ name: 'exit_message', type: 'text', default: '' })\n exitMessage!: string;\n\n @Column({\n name: 'created_at',\n type: 'datetime',\n default: () => 'CURRENT_TIMESTAMP',\n })\n createdAt: Date = new Date();\n}\n\n/**\n * `batch_job_execution_context` metadata row.\n *\n * `data` is a JSON-serialized ExecutionContext payload. `version`\n * guards against lost updates during concurrent writers.\n */\n@Entity('batch_job_execution_context')\nexport class JobExecutionContextEntity {\n @PrimaryColumn({ name: 'job_execution_id', type: 'varchar', length: 255 })\n jobExecutionId!: string;\n\n @Column({ type: 'text' })\n data!: string;\n\n @Column({ type: 'int', default: 0 })\n version!: number;\n}\n\n/**\n * `batch_step_execution_context` metadata row.\n *\n * Mirrors the job-level context table but scoped to a single\n * step execution. There is intentionally no params sibling table\n * for steps — step parameters are derivable from the parent job\n * execution params + the step execution context.\n */\n@Entity('batch_step_execution_context')\nexport class StepExecutionContextEntity {\n @PrimaryColumn({ name: 'step_execution_id', type: 'varchar', length: 255 })\n stepExecutionId!: string;\n\n @Column({ type: 'text' })\n data!: string;\n\n @Column({ type: 'int', default: 0 })\n version!: number;\n}\n\n/**\n * All batch meta entities owned by this package. Hand to\n * `DataSource#entityMetadatas` (or `entities:`) so TypeORM\n * discovers them through the standard decorator scan.\n */\nexport const BATCH_META_ENTITIES = [\n JobInstanceEntity,\n JobExecutionEntity,\n StepExecutionEntity,\n JobExecutionContextEntity,\n StepExecutionContextEntity,\n] as const;\n"],"names":["BATCH_META_ENTITIES","JobExecutionContextEntity","JobExecutionEntity","JobInstanceEntity","StepExecutionContextEntity","StepExecutionEntity","id","jobName","jobKey","createdAt","Date","type","length","name","default","unique","jobInstanceId","status","startTime","endTime","exitCode","exitMessage","params","nullable","jobExecutionId","stepName","readCount","writeCount","skipCount","rollbackCount","commitCount","data","version","stepExecutionId"],"mappings":";;;;;;;;;;;QAgLaA;eAAAA;;QApCAC;eAAAA;;QA9FAC;eAAAA;;QAjCAC;eAAAA;;QAmJAC;eAAAA;;QArEAC;eAAAA;;;yBA3FwC;;;;;;;;;;AAa9C,IAAA,AAAMF,oBAAN,MAAMA;IAEXG,GAAY;IAGZC,QAAiB;IAGjBC,OAAgB;IAWhBC,YAAkB,IAAIC,OAAO;AAC/B;;;QAnBmBC,MAAM;QAAWC,QAAQ;;;;;;QAGhCC,MAAM;QAAYF,MAAM;QAAWC,QAAQ;;;;;;QAG3CC,MAAM;QAAWF,MAAM;QAAWC,QAAQ;;;;;;QAIlDC,MAAM;QACN,gEAAgE;QAChE,iEAAiE;QACjE,4DAA4D;QAC5D,YAAY;QACZF,MAAM;QACNG,SAAS,IAAM;;;;;;;QAlBmC;QAAW;;QAAaC,QAAQ;;;AAkC/E,IAAA,AAAMb,qBAAN,MAAMA;IAEXI,GAA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SAAS;;;;;;QAG1DD,MAAM;QAAgBF,MAAM;QAAQG,SAAS;;;;;;QAIrDD,MAAM;QACNF,MAAM;QACNG,SAAS,IAAM;;;;;;;QAtCoC;;;AAkDhD,IAAA,AAAMb,4BAAN,MAAMA;IAEXuB,eAAwB;IAGxBO,KAAc;IAGdC,QAAiB;AACnB;;;QARmBnB,MAAM;QAAoBF,MAAM;QAAWC,QAAQ;;;;;;QAG1DD,MAAM;;;;;;QAGNA,MAAM;QAAOG,SAAS;;;;;;;AAa3B,IAAA,AAAMV,6BAAN,MAAMA;IAEX6B,gBAAyB;IAGzBF,KAAc;IAGdC,QAAiB;AACnB;;;QARmBnB,MAAM;QAAqBF,MAAM;QAAWC,QAAQ;;;;;;QAG3DD,MAAM;;;;;;QAGNA,MAAM;QAAOG,SAAS;;;;;;;AAS3B,MAAMd,sBAAsB;IACjCG;IACAD;IACAG;IACAJ;IACAG;CACD"}
@@ -1,6 +1,9 @@
1
+ import { BATCH_META_ENTITIES } from './entities';
1
2
  export { TypeOrmJobRepository } from './repository/typeorm-job-repository';
2
3
  export type { TypeOrmTransactionContext } from './transaction/typeorm-transaction-manager';
3
4
  export { TypeOrmTransactionManager } from './transaction/typeorm-transaction-manager';
4
5
  export * from './adapters';
6
+ export { BATCH_META_ENTITIES } from './entities';
5
7
  export * from './typeorm.driver-provider';
8
+ export declare const batchMetaEntities: () => typeof BATCH_META_ENTITIES;
6
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,YAAY,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,YAAY,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAE1C,eAAO,MAAM,iBAAiB,QAAO,OAAO,mBAA0C,CAAC"}
package/dist/src/index.js CHANGED
@@ -29,12 +29,11 @@
29
29
  // },
30
30
  // });
31
31
  //
32
- // The original `batchMetaEntities()` factory and the bundled
33
- // `CreateBatchMeta1700000000000` migration moved to
34
- // `@nest-batch/postgresql/src/migrations/`. The driver sibling owns
35
- // the TypeORM-specific entity classes and the migration scripts;
36
- // this package owns only the repository / transaction manager
37
- // shape and the driver-provider token.
32
+ // The TypeORM entity tuple stays in this package because it is the
33
+ // schema contract consumed by a host-owned TypeORM DataSource. Apps
34
+ // generate and own their runnable migration files in their own
35
+ // migration workflow. Driver siblings bind the
36
+ // `TypeOrmDriverProvider` token to a concrete database connection.
38
37
  "use strict";
39
38
  Object.defineProperty(exports, "__esModule", {
40
39
  value: true
@@ -46,13 +45,20 @@ function _export(target, all) {
46
45
  });
47
46
  }
48
47
  _export(exports, {
48
+ get BATCH_META_ENTITIES () {
49
+ return _entities.BATCH_META_ENTITIES;
50
+ },
49
51
  get TypeOrmJobRepository () {
50
52
  return _typeormjobrepository.TypeOrmJobRepository;
51
53
  },
52
54
  get TypeOrmTransactionManager () {
53
55
  return _typeormtransactionmanager.TypeOrmTransactionManager;
56
+ },
57
+ get batchMetaEntities () {
58
+ return batchMetaEntities;
54
59
  }
55
60
  });
61
+ const _entities = require("./entities");
56
62
  const _typeormjobrepository = require("./repository/typeorm-job-repository");
57
63
  const _typeormtransactionmanager = require("./transaction/typeorm-transaction-manager");
58
64
  _export_star(require("./adapters"), exports);
@@ -70,5 +76,6 @@ function _export_star(from, to) {
70
76
  });
71
77
  return from;
72
78
  }
79
+ const batchMetaEntities = ()=>_entities.BATCH_META_ENTITIES;
73
80
 
74
81
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Public API barrel for @nest-batch/typeorm.\n//\n// The package is a **driver-agnostic adapter SLOT**. It owns the\n// `TypeOrmAdapter` factory, the `TypeOrmJobRepository` /\n// `TypeOrmTransactionManager` interface shape, and the\n// `TypeOrmDriverProvider` injection token. It does NOT import\n// `@nestjs/typeorm` (which carries the Postgres driver) — the\n// driver implementation lives in the `@nest-batch/postgresql` (or\n// `@nest-batch/mysql`) sibling package, which binds the\n// `TypeOrmDriverProvider` token to the concrete `DataSource`\n// in its own `forRoot()` factory.\n//\n// Apps wire the persistence concern into `NestBatchModule.forRoot()`\n// via the new `BatchAdapter` factory pattern:\n//\n// import { NestBatchModule, InProcessAdapter } from '@nest-batch/core';\n// import { TypeOrmAdapter } from '@nest-batch/typeorm';\n// import { PostgresAdapter } from '@nest-batch/postgresql';\n//\n// // The host must also call\n// // `TypeOrmModule.forRoot({ ... })` in their `AppModule.imports`.\n// // The PostgresAdapter.forRoot() factory binds the\n// // TypeOrmDriverProvider token to the host's DataSource.\n//\n// NestBatchModule.forRoot({\n// adapters: {\n// persistence: PostgresAdapter.forRoot(),\n// transport: InProcessAdapter.forRoot(),\n// },\n// });\n//\n// The original `batchMetaEntities()` factory and the bundled\n// `CreateBatchMeta1700000000000` migration moved to\n// `@nest-batch/postgresql/src/migrations/`. The driver sibling owns\n// the TypeORM-specific entity classes and the migration scripts;\n// this package owns only the repository / transaction manager\n// shape and the driver-provider token.\nexport { TypeOrmJobRepository } from './repository/typeorm-job-repository';\nexport type { TypeOrmTransactionContext } from './transaction/typeorm-transaction-manager';\nexport { TypeOrmTransactionManager } from './transaction/typeorm-transaction-manager';\nexport * from './adapters';\nexport * from './typeorm.driver-provider';\n"],"names":["TypeOrmJobRepository","TypeOrmTransactionManager"],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,iEAAiE;AACjE,yDAAyD;AACzD,uDAAuD;AACvD,8DAA8D;AAC9D,8DAA8D;AAC9D,kEAAkE;AAClE,wDAAwD;AACxD,6DAA6D;AAC7D,kCAAkC;AAClC,EAAE;AACF,qEAAqE;AACrE,8CAA8C;AAC9C,EAAE;AACF,0EAA0E;AAC1E,0DAA0D;AAC1D,8DAA8D;AAC9D,EAAE;AACF,+BAA+B;AAC/B,sEAAsE;AACtE,uDAAuD;AACvD,6DAA6D;AAC7D,EAAE;AACF,8BAA8B;AAC9B,kBAAkB;AAClB,gDAAgD;AAChD,+CAA+C;AAC/C,SAAS;AACT,QAAQ;AACR,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AACpD,oEAAoE;AACpE,iEAAiE;AACjE,8DAA8D;AAC9D,uCAAuC;;;;;;;;;;;;QAC9BA;eAAAA,0CAAoB;;QAEpBC;eAAAA,oDAAyB;;;sCAFG;2CAEK;qBAC5B;qBACA"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Public API barrel for @nest-batch/typeorm.\n//\n// The package is a **driver-agnostic adapter SLOT**. It owns the\n// `TypeOrmAdapter` factory, the `TypeOrmJobRepository` /\n// `TypeOrmTransactionManager` interface shape, and the\n// `TypeOrmDriverProvider` injection token. It does NOT import\n// `@nestjs/typeorm` (which carries the Postgres driver) — the\n// driver implementation lives in the `@nest-batch/postgresql` (or\n// `@nest-batch/mysql`) sibling package, which binds the\n// `TypeOrmDriverProvider` token to the concrete `DataSource`\n// in its own `forRoot()` factory.\n//\n// Apps wire the persistence concern into `NestBatchModule.forRoot()`\n// via the new `BatchAdapter` factory pattern:\n//\n// import { NestBatchModule, InProcessAdapter } from '@nest-batch/core';\n// import { TypeOrmAdapter } from '@nest-batch/typeorm';\n// import { PostgresAdapter } from '@nest-batch/postgresql';\n//\n// // The host must also call\n// // `TypeOrmModule.forRoot({ ... })` in their `AppModule.imports`.\n// // The PostgresAdapter.forRoot() factory binds the\n// // TypeOrmDriverProvider token to the host's DataSource.\n//\n// NestBatchModule.forRoot({\n// adapters: {\n// persistence: PostgresAdapter.forRoot(),\n// transport: InProcessAdapter.forRoot(),\n// },\n// });\n//\n// The TypeORM entity tuple stays in this package because it is the\n// schema contract consumed by a host-owned TypeORM DataSource. Apps\n// generate and own their runnable migration files in their own\n// migration workflow. Driver siblings bind the\n// `TypeOrmDriverProvider` token to a concrete database connection.\nimport { BATCH_META_ENTITIES } from './entities';\n\nexport { TypeOrmJobRepository } from './repository/typeorm-job-repository';\nexport type { TypeOrmTransactionContext } from './transaction/typeorm-transaction-manager';\nexport { TypeOrmTransactionManager } from './transaction/typeorm-transaction-manager';\nexport * from './adapters';\nexport { BATCH_META_ENTITIES } from './entities';\nexport * from './typeorm.driver-provider';\n\nexport const batchMetaEntities = (): typeof BATCH_META_ENTITIES => BATCH_META_ENTITIES;\n"],"names":["BATCH_META_ENTITIES","TypeOrmJobRepository","TypeOrmTransactionManager","batchMetaEntities"],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,iEAAiE;AACjE,yDAAyD;AACzD,uDAAuD;AACvD,8DAA8D;AAC9D,8DAA8D;AAC9D,kEAAkE;AAClE,wDAAwD;AACxD,6DAA6D;AAC7D,kCAAkC;AAClC,EAAE;AACF,qEAAqE;AACrE,8CAA8C;AAC9C,EAAE;AACF,0EAA0E;AAC1E,0DAA0D;AAC1D,8DAA8D;AAC9D,EAAE;AACF,+BAA+B;AAC/B,sEAAsE;AACtE,uDAAuD;AACvD,6DAA6D;AAC7D,EAAE;AACF,8BAA8B;AAC9B,kBAAkB;AAClB,gDAAgD;AAChD,+CAA+C;AAC/C,SAAS;AACT,QAAQ;AACR,EAAE;AACF,mEAAmE;AACnE,oEAAoE;AACpE,+DAA+D;AAC/D,+CAA+C;AAC/C,mEAAmE;;;;;;;;;;;;QAO1DA;eAAAA,6BAAmB;;QAJnBC;eAAAA,0CAAoB;;QAEpBC;eAAAA,oDAAyB;;QAKrBC;eAAAA;;;0BATuB;sCAEC;2CAEK;qBAC5B;qBAEA;;;;;;;;;;;;;;AAEP,MAAMA,oBAAoB,IAAkCH,6BAAmB"}
@@ -8,8 +8,8 @@ import type { JobInstance, JobExecution, JobExecutionPatch, JobParameters, StepE
8
8
  * provided by the `@nest-batch/postgresql` (or future
9
9
  * `@nest-batch/mysql`) driver sibling via the `TypeOrmDriverProvider`
10
10
  * token. The repository itself uses raw SQL via `EntityManager.query`
11
- * so the column-shape contract is owned by the driver sibling
12
- * (the bundled 6-table migration).
11
+ * against the table contract represented by this package's exported
12
+ * TypeORM entities. The consuming app owns the runnable migration.
13
13
  *
14
14
  * The contract guarantees:
15
15
  * - `getOrCreateJobInstance` is race-safe via the (jobName, jobKey)
@@ -1 +1 @@
1
- {"version":3,"file":"typeorm-job-repository.d.ts","sourceRoot":"","sources":["../../../src/repository/typeorm-job-repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAqB,MAAM,SAAS,CAAC;AACxD,OAAO,EACL,aAAa,EAOd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAyG1B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,oBAAqB,SAAQ,aAAa;IAEpB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAKxE,OAAO,CAAC,EAAE;IAIJ,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAsC1E,kBAAkB,CACt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AC;IA4BrE,oBAAoB,CACxB,KAAK,EAAE,cAAc,EACrB,GAAG,EAAE,gBAAgB,EACrB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;CA0CjB"}
1
+ {"version":3,"file":"typeorm-job-repository.d.ts","sourceRoot":"","sources":["../../../src/repository/typeorm-job-repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAqB,MAAM,SAAS,CAAC;AACxD,OAAO,EACL,aAAa,EAOd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AA6G1B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,oBAAqB,SAAQ,aAAa;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAIlF,OAAO,CAAC,EAAE;IAIJ,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAsC1E,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBvF,qBAAqB,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,YAAY,CAAC;IA6DlB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgChF,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IASzD,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAWlE,g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