(opts: PostOptions)
| 31 | }; |
| 32 | |
| 33 | export async function post(opts: PostOptions): Promise<WlResult<PostOutcome>> { |
| 34 | try { |
| 35 | const now = (opts.ctx.now ?? (() => new Date()))(); |
| 36 | const dml = insertWantedDML({ |
| 37 | id: opts.wantedId, |
| 38 | title: opts.title, |
| 39 | description: opts.description, |
| 40 | project: opts.project, |
| 41 | type: opts.type, |
| 42 | priority: opts.priority, |
| 43 | tags: opts.tags, |
| 44 | postedBy: opts.ctx.rigHandle, |
| 45 | effortLevel: opts.effortLevel, |
| 46 | now: formatNowUtc(now), |
| 47 | }); |
| 48 | const outcome = await applyMutation({ |
| 49 | ctx: opts.ctx, |
| 50 | wantedId: opts.wantedId, |
| 51 | // A new INSERT lands at status='open'. |
| 52 | targetStatus: 'open', |
| 53 | statements: [dml], |
| 54 | commitMessage: `wl post: ${opts.wantedId}`, |
| 55 | // Brand-new items don't exist on main, so cleanup would |
| 56 | // misfire (treating absence-on-main as "match" via |
| 57 | // `wantedRowsEquivalent` returning false → no cleanup |
| 58 | // anyway, but disable explicitly for clarity). |
| 59 | autoCleanup: false, |
| 60 | }); |
| 61 | return { ok: true, data: { ...outcome, wantedId: opts.wantedId } }; |
| 62 | } catch (err) { |
| 63 | if (err instanceof WlError) return { ok: false, error: err }; |
| 64 | return { ok: false, error: new WlError('post failed', 'internal', err) }; |
| 65 | } |
| 66 | } |
no test coverage detected