MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / post

Function post

packages/wl-sdk/src/ops/post.ts:33–66  ·  view source on GitHub ↗
(opts: PostOptions)

Source from the content-addressed store, hash-verified

31};
32
33export 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}

Callers 2

postMethod · 0.90
post.test.tsFile · 0.90

Calls 3

insertWantedDMLFunction · 0.90
formatNowUtcFunction · 0.90
applyMutationFunction · 0.90

Tested by

no test coverage detected