@odla-ai/chapter 0.10.1 → 0.11.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.
@@ -184,6 +184,9 @@ async function createClerkUser(secretKey, input, fetchImpl = fetch) {
184
184
  }
185
185
 
186
186
  // src/member.ts
187
+ function hasDisclaimerAck(fields) {
188
+ return fields.disclaimerAck === true || fields.disclaimerAck === "true";
189
+ }
187
190
  var IDENTITY_FIELDS = /* @__PURE__ */ new Set(["email", "firstName", "lastName"]);
188
191
  function applicantProfile(chapter, fields) {
189
192
  const profile = {};
@@ -206,6 +209,10 @@ async function submitApplication(db, chapter, fields, opts) {
206
209
  const cap = app.maxLen[f] ?? app.defaultMaxLen;
207
210
  if (typeof v === "string" && v.length > cap) return { ok: false, error: `${f} exceeds ${cap} characters` };
208
211
  }
212
+ const acked = hasDisclaimerAck(fields);
213
+ if (app.requireDisclaimerAck && !acked) {
214
+ return { ok: false, error: "disclaimerAck is required" };
215
+ }
209
216
  const id = opts.newId();
210
217
  const row = { id, status: chapter.pipeline.initial, createdAt: opts.now };
211
218
  for (const f of [...app.required, ...app.optional]) {
@@ -213,12 +220,12 @@ async function submitApplication(db, chapter, fields, opts) {
213
220
  }
214
221
  if (fields.focus !== void 0) row.focus = fields.focus;
215
222
  if (opts.groupId) row.groupId = opts.groupId;
216
- if (fields.disclaimerAck === true || fields.disclaimerAck === "true") row.disclaimerAckAt = opts.now;
223
+ if (acked) row.disclaimerAckAt = opts.now;
217
224
  const { duplicate } = await db.transact(
218
225
  [{ t: "update", ns: "applications", id, attrs: row }],
219
226
  opts.submissionId ? { mutationId: `join:${opts.submissionId}` } : void 0
220
227
  );
221
- return { ok: true, id, duplicate, status: chapter.pipeline.initial };
228
+ return { ok: true, id, duplicate, status: chapter.pipeline.initial, disclaimerAckAt: acked ? opts.now : null };
222
229
  }
223
230
  function joinConfig(group, paymentsReady) {
224
231
  return {
@@ -674,7 +681,14 @@ var handleMember = async (req, url, env, ctx) => {
674
681
  }
675
682
  await provisionApplicant(db, chapter, result.id, parsed);
676
683
  }
677
- return json({ id: result.id, duplicate: result.duplicate, status: result.status });
684
+ return json({
685
+ id: result.id,
686
+ duplicate: result.duplicate,
687
+ status: result.status,
688
+ // Echoed so a site can see (and assert in an integration test) whether its
689
+ // join page actually posted the ack. Absent consent is otherwise invisible.
690
+ disclaimerAckAt: result.disclaimerAckAt
691
+ });
678
692
  }
679
693
  return null;
680
694
  };