@workglow/indexeddb 0.2.37 → 0.3.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.
@@ -752,6 +752,8 @@ class IndexedDbQueueStorage {
752
752
  updated.progress_message = fields.progress_message ?? "";
753
753
  if ("progress_details" in fields)
754
754
  updated.progress_details = fields.progress_details ?? null;
755
+ if ("visible_at" in fields)
756
+ updated.visible_at = fields.visible_at ?? null;
755
757
  await this.put(updated);
756
758
  }
757
759
  async deleteAll() {
@@ -1229,6 +1231,55 @@ class IndexedDbJobStore {
1229
1231
  async saveStatus(id, status) {
1230
1232
  await this.core.saveStatus(id, status);
1231
1233
  }
1234
+ async create(body, opts) {
1235
+ const enriched = {
1236
+ ...body,
1237
+ fingerprint: opts.fingerprint ?? body.fingerprint,
1238
+ job_run_id: opts.jobRunId ?? body.job_run_id,
1239
+ max_attempts: opts.maxAttempts ?? body.max_attempts,
1240
+ deadline_at: opts.timeoutSeconds != null ? new Date(Date.now() + opts.timeoutSeconds * 1000).toISOString() : body.deadline_at
1241
+ };
1242
+ return this.core.add(enriched);
1243
+ }
1244
+ async findActiveByFingerprint(fingerprint, _queueName) {
1245
+ const [pending, processing] = await Promise.all([
1246
+ this.core.peek("PENDING"),
1247
+ this.core.peek("PROCESSING")
1248
+ ]);
1249
+ return [...pending, ...processing].find((j) => j.fingerprint === fingerprint);
1250
+ }
1251
+ async getMany(ids) {
1252
+ return Promise.all(ids.map((id) => this.core.get(id)));
1253
+ }
1254
+ async completeWithResult(id, result) {
1255
+ this.pending.delete(id);
1256
+ await this.core.finalize(id, {
1257
+ output: result,
1258
+ error: null,
1259
+ error_code: null,
1260
+ status: "COMPLETED",
1261
+ completed_at: new Date().toISOString()
1262
+ });
1263
+ }
1264
+ async failWithError(id, opts) {
1265
+ this.pending.delete(id);
1266
+ const current = await this.core.get(id);
1267
+ const now = new Date().toISOString();
1268
+ const abortRequestedAt = opts.abortRequested === true ? current?.abort_requested_at ?? now : current?.abort_requested_at ?? null;
1269
+ await this.core.finalize(id, {
1270
+ ..."error" in opts ? { error: opts.error ?? null } : {},
1271
+ ..."errorCode" in opts ? { error_code: opts.errorCode ?? null } : {},
1272
+ abort_requested_at: abortRequestedAt,
1273
+ status: "FAILED",
1274
+ completed_at: current?.completed_at ?? now
1275
+ });
1276
+ }
1277
+ async markEnqueueDeferred(id, opts) {
1278
+ await this.core.finalize(id, {
1279
+ visible_at: opts.visible_at.toISOString(),
1280
+ error_code: opts.errorCode
1281
+ });
1282
+ }
1232
1283
  }
1233
1284
  // src/job-queue/createIndexedDbQueue.ts
1234
1285
  function createIndexedDbQueue(queueName, opts) {
@@ -1595,4 +1646,4 @@ export {
1595
1646
  INDEXED_DB_QUEUE_STORAGE
1596
1647
  };
1597
1648
 
1598
- //# debugId=90BAEB2124C483DB64756E2164756E21
1649
+ //# debugId=C2BBAF5E9139F28A64756E2164756E21