@portqueue/core 1.0.3 → 1.1.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.
Files changed (64) hide show
  1. package/dist/conformance/index.cjs +70 -1
  2. package/dist/conformance/index.cjs.map +1 -1
  3. package/dist/conformance/index.d.ts +4 -2
  4. package/dist/conformance/index.mjs +70 -1
  5. package/dist/conformance/index.mjs.map +1 -1
  6. package/dist/constants/job.constants.d.ts +3 -1
  7. package/dist/constants/storage.constants.d.ts +8 -0
  8. package/dist/constants/time.constants.d.ts +13 -0
  9. package/dist/constants/worker.constants.d.ts +5 -0
  10. package/dist/drivers/driver.interface.d.ts +47 -0
  11. package/dist/drivers/mysql/index.cjs +169 -76
  12. package/dist/drivers/mysql/index.cjs.map +1 -1
  13. package/dist/drivers/mysql/index.mjs +169 -76
  14. package/dist/drivers/mysql/index.mjs.map +1 -1
  15. package/dist/drivers/mysql/mysql-driver.d.ts +42 -19
  16. package/dist/drivers/oracle/index.cjs +144 -65
  17. package/dist/drivers/oracle/index.cjs.map +1 -1
  18. package/dist/drivers/oracle/index.mjs +144 -65
  19. package/dist/drivers/oracle/index.mjs.map +1 -1
  20. package/dist/drivers/oracle/oracle-driver.d.ts +34 -15
  21. package/dist/drivers/pglite/index.cjs +3 -3
  22. package/dist/drivers/pglite/index.mjs +3 -3
  23. package/dist/drivers/postgresql/index.cjs +1 -1
  24. package/dist/drivers/postgresql/index.mjs +1 -1
  25. package/dist/drivers/postgresql/postgresql-driver.d.ts +33 -7
  26. package/dist/drivers/shared/base-driver.d.ts +2 -0
  27. package/dist/drivers/shared/migration-runner.service.d.ts +19 -4
  28. package/dist/drivers/shared/migration.d.ts +5 -3
  29. package/dist/drivers/sqlite/index.cjs +113 -42
  30. package/dist/drivers/sqlite/index.cjs.map +1 -1
  31. package/dist/drivers/sqlite/index.mjs +113 -42
  32. package/dist/drivers/sqlite/index.mjs.map +1 -1
  33. package/dist/drivers/sqlite/sqlite-driver.d.ts +26 -0
  34. package/dist/drivers/table-names.d.ts +3 -2
  35. package/dist/index.cjs +519 -316
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.mjs +521 -318
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/{migration-D73ANkYV.js → migration-D0IRP2oq.js} +6 -2
  41. package/dist/migration-D0IRP2oq.js.map +1 -0
  42. package/dist/{migration-CoTjpgBl.cjs → migration-Dx8eUthW.cjs} +6 -2
  43. package/dist/migration-Dx8eUthW.cjs.map +1 -0
  44. package/dist/monitoring/system-monitor.service.d.ts +6 -5
  45. package/dist/options/enums.d.ts +22 -0
  46. package/dist/options/job-options.d.ts +2 -1
  47. package/dist/port-queue.d.ts +76 -4
  48. package/dist/{postgresql-driver-BUHuyRYj.js → postgresql-driver-CPHv5SUT.js} +128 -55
  49. package/dist/postgresql-driver-CPHv5SUT.js.map +1 -0
  50. package/dist/{postgresql-driver-CIk94XCq.cjs → postgresql-driver-DRT68TKb.cjs} +128 -55
  51. package/dist/postgresql-driver-DRT68TKb.cjs.map +1 -0
  52. package/dist/producer/producer.service.d.ts +12 -0
  53. package/dist/producer/results.d.ts +35 -1
  54. package/dist/{storage.constants-B5oQjxp5.cjs → storage.constants-BKeXcSQe.cjs} +13 -1
  55. package/dist/storage.constants-BKeXcSQe.cjs.map +1 -0
  56. package/dist/{storage.constants-DwSzjjMZ.js → storage.constants-DYEQUmc8.js} +14 -2
  57. package/dist/storage.constants-DYEQUmc8.js.map +1 -0
  58. package/package.json +1 -1
  59. package/dist/migration-CoTjpgBl.cjs.map +0 -1
  60. package/dist/migration-D73ANkYV.js.map +0 -1
  61. package/dist/postgresql-driver-BUHuyRYj.js.map +0 -1
  62. package/dist/postgresql-driver-CIk94XCq.cjs.map +0 -1
  63. package/dist/storage.constants-B5oQjxp5.cjs.map +0 -1
  64. package/dist/storage.constants-DwSzjjMZ.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.constants-DwSzjjMZ.js","sources":["../src/jobs/job-state.enum.ts","../src/options/enums.ts","../src/drivers/driver-capabilities.ts","../src/constants/storage.constants.ts"],"sourcesContent":["/**\n * Job lifecycle states. Exported so consumers never use magic strings.\n *\n * There is no `STALLED` state: an `ACTIVE` row past its lock deadline is *derived*, and it is\n * derived in exactly one place — {@link import('./snapshot').toSnapshot} sets `JobSnapshot.stalled`.\n * A second spelling of the same idea (an exported `'STALLED'` constant nothing compared against) is\n * a state consumers could branch on and never see.\n */\nexport enum JobStatus {\n PENDING = 'PENDING',\n ACTIVE = 'ACTIVE',\n COMPLETED = 'COMPLETED',\n FAILED = 'FAILED',\n RETRY = 'RETRY',\n CANCELLED = 'CANCELLED',\n EXPIRED = 'EXPIRED',\n}\n\n/**\n * The terminal statuses retention may act on, and the default scope of a retention policy that\n * names none.\n */\nexport const FINISHED_STATUSES: readonly JobStatus[] = [\n JobStatus.COMPLETED,\n JobStatus.FAILED,\n JobStatus.CANCELLED,\n JobStatus.EXPIRED,\n];\n\n/**\n * Statuses in which a job holds a claim / occupies an \"active-ish\" slot for singleton uniqueness.\n * Every driver's singleton dedup binds this list rather than inlining the three names.\n */\nexport const ACTIVE_STATUSES: readonly JobStatus[] = [\n JobStatus.PENDING,\n JobStatus.ACTIVE,\n JobStatus.RETRY,\n];\n\n/**\n * A zeroed count per status — the shape every \"jobs by status\" answer takes.\n *\n * Defined beside the enum because it *is* the enum's shape: a new status has to appear here, and one\n * definition is what makes that automatic for the drivers' grouped counts and the read service alike\n * (they used to hold identical copies of this literal).\n */\nexport function emptyStatusCounts(): Record<JobStatus, number> {\n return {\n [JobStatus.PENDING]: 0,\n [JobStatus.ACTIVE]: 0,\n [JobStatus.COMPLETED]: 0,\n [JobStatus.FAILED]: 0,\n [JobStatus.RETRY]: 0,\n [JobStatus.CANCELLED]: 0,\n [JobStatus.EXPIRED]: 0,\n };\n}\n","/** Retry backoff strategies. */\nexport enum BackoffStrategy {\n FIXED = 'FIXED',\n EXPONENTIAL = 'EXPONENTIAL',\n}\n\n/** How a queue is paused. */\nexport enum PauseMode {\n /** Workers stop claiming/running jobs, but the queue still accepts new adds. */\n PROCESSING = 'PROCESSING',\n /** Also refuse new jobs (drain/incident control). */\n ALL = 'ALL',\n}\n\n/** Why an add was deduplicated. */\nexport enum DeduplicationReason {\n IDEMPOTENCY = 'IDEMPOTENCY',\n SINGLETON = 'SINGLETON',\n}\n\n/**\n * What a `cancelJob` actually did. Three states rather than a boolean, because \"asked to stop\" and\n * \"stopped\" are not the same claim and a caller acting on the difference (reporting it, waiting for\n * it) needs to know which it got.\n */\nexport enum CancelOutcome {\n /** The row is now `CANCELLED`; the job will never run. */\n CANCELLED = 'CANCELLED',\n /**\n * The job is running in **this** process, so its handler's `AbortSignal` was fired. Cancellation\n * is cooperative: a handler that ignores `job.signal` runs to completion and the row ends\n * `COMPLETED`, so nothing has been cancelled yet.\n */\n SIGNALLED = 'SIGNALLED',\n /**\n * The job exists but was not cancellable: it has already finished, or it is `ACTIVE` in another\n * process — which only that process can signal.\n */\n NOT_CANCELLABLE = 'NOT_CANCELLABLE',\n}\n\n/** Auto-migration behavior on init. */\nexport enum MigrationMode {\n AUTO = 'AUTO',\n MANUAL = 'MANUAL',\n VALIDATE_ONLY = 'VALIDATE_ONLY',\n}\n\n/** Database engines a driver can advertise. */\nexport enum DatabaseEngine {\n POSTGRESQL = 'POSTGRESQL',\n PGLITE = 'PGLITE',\n SQLITE = 'SQLITE',\n ORACLE = 'ORACLE',\n MYSQL = 'MYSQL',\n CUSTOM = 'CUSTOM',\n}\n\n/**\n * How much of a handler's failure is kept on the job row (`createQueue({ failureDetail })`).\n *\n * Not a boolean, because \"store the stack\" and \"store the message\" are two named policies an\n * operator chooses between, and a `storeStack: false` reads as a workaround rather than a decision.\n */\nexport enum FailureDetail {\n /** `error.stack` — the throw site and the frames around it, truncated. The default. */\n STACK = 'STACK',\n /** `Error: message` only. For a queue that fails often, where the frames are noise and bytes. */\n MESSAGE = 'MESSAGE',\n}\n","/**\n * Capability flags a driver advertises. Core branches on these, never identity — and every flag\n * here is read somewhere. A flag nothing branches on is a promise nothing keeps, so it does not\n * exist.\n */\nexport enum DriverCapability {\n /** The engine can push notifications, so a producer wakes a consumer without waiting on a poll. */\n LISTEN_NOTIFY = 'LISTEN_NOTIFY',\n /** `FOR UPDATE SKIP LOCKED`, so concurrent claimers never contend on the same rows. */\n SKIP_LOCKED = 'SKIP_LOCKED',\n /** DML can return the rows it changed, so a mutate-and-read is one statement rather than two. */\n RETURNING = 'RETURNING',\n /** Statements can be grouped in a transaction (a driver without this no-ops the wrapper). */\n TRANSACTIONS = 'TRANSACTIONS',\n /** Cross-connection advisory locks, used to elect a single migrator. */\n ADVISORY_LOCK = 'ADVISORY_LOCK',\n}\n\n/** A frozen set of capability → boolean. */\nexport type DriverCapabilitySet = Readonly<Record<DriverCapability, boolean>>;\n\n/** Build a full capability set from a partial (missing flags default to false). */\nexport function capabilities(\n partial: Partial<Record<DriverCapability, boolean>>,\n): DriverCapabilitySet {\n const full = {} as Record<DriverCapability, boolean>;\n for (const cap of Object.values(DriverCapability)) {\n full[cap] = partial[cap] ?? false;\n }\n return Object.freeze(full);\n}\n","/** Storage-layout defaults every driver shares. */\n\n/** Prefix on every physical table name. `<driver>Options.tablePrefix`. */\nexport const DEFAULT_TABLE_PREFIX = 'pq_';\n\n/** Logical prefix for pub/sub channels when several PortQueues share one database. */\nexport const DEFAULT_NAMESPACE = 'portqueue';\n\n/** Identifier length ceiling a driver assumes when it declares none (PostgreSQL' limit). */\nexport const DEFAULT_MAX_IDENTIFIER_LEN = 63;\n\n/**\n * The most ids one batch call may carry — `addJobs`, `requeueJobs`, `cancelJobs`, `removeJobs`,\n * `deleteSchedules`, and the dashboard's bulk actions.\n *\n * Oracle caps the expressions in an `IN` list at 1000 and is the lowest of the engines here, so its\n * limit is everyone's: a 1001-id batch that works on PostgreSQL and raises ORA-01795 on Oracle is a\n * portability bug the tool refuses up front rather than one a caller discovers in production. It is\n * a cap on what a single *call* may ask for — a set that still needs several statements (an insert\n * binds ~25 values per job) is chunked by `BaseDriver.chunkForBind` underneath.\n */\nexport const MAX_BATCH_IDS = 1000;\n\n/**\n * How far the multi-instance claim path scans for affinity-matching candidates in one pass, as a\n * multiple of the requested batch (clamped by {@link AFFINITY_PAGE_MIN_HEADROOM} and\n * {@link AFFINITY_PAGE_MAX}). Affinity is a regex, which portable SQL cannot evaluate, so\n * candidates are paged and filtered in the tool.\n */\nexport const AFFINITY_PAGE_FACTOR = 5;\n/** Extra rows added to a small batch so a single page is worth the round trip. */\nexport const AFFINITY_PAGE_MIN_HEADROOM = 20;\n/** The largest affinity candidate page. */\nexport const AFFINITY_PAGE_MAX = 500;\n/** Pages one claim will scan before giving up and letting the next tick resume from the top. */\nexport const AFFINITY_MAX_PAGES = 20;\n/** The floor on total rows scanned, so a tiny batch still makes progress through a backlog. */\nexport const AFFINITY_MIN_SCAN = 2000;\n"],"names":["JobStatus","BackoffStrategy","PauseMode","DeduplicationReason","CancelOutcome","MigrationMode","DatabaseEngine","FailureDetail","DriverCapability"],"mappings":"AAQO,IAAK,8BAAAA,eAAL;AACLA,aAAA,SAAA,IAAU;AACVA,aAAA,QAAA,IAAS;AACTA,aAAA,WAAA,IAAY;AACZA,aAAA,QAAA,IAAS;AACTA,aAAA,OAAA,IAAQ;AACRA,aAAA,WAAA,IAAY;AACZA,aAAA,SAAA,IAAU;AAPA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAcL,MAAM,oBAA0C;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AACF;AAMO,MAAM,kBAAwC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA;AACF;AASO,SAAS,oBAA+C;AAC7D,SAAO;AAAA,IACL;AAAA,MAAC;AAAA;AAAA,OAAoB;AAAA,IACrB;AAAA,MAAC;AAAA;AAAA,OAAmB;AAAA,IACpB;AAAA,MAAC;AAAA;AAAA,OAAsB;AAAA,IACvB;AAAA,M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