@odla-ai/chapter 0.10.0 → 0.10.1

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,17 @@ async function createClerkUser(secretKey, input, fetchImpl = fetch) {
184
184
  }
185
185
 
186
186
  // src/member.ts
187
+ var IDENTITY_FIELDS = /* @__PURE__ */ new Set(["email", "firstName", "lastName"]);
188
+ function applicantProfile(chapter, fields) {
189
+ const profile = {};
190
+ for (const f of [...chapter.application.required, ...chapter.application.optional]) {
191
+ if (IDENTITY_FIELDS.has(f)) continue;
192
+ const v = fields[f];
193
+ if (typeof v === "string" && v.trim() !== "") profile[f] = v.trim();
194
+ }
195
+ if (fields.focus !== void 0) profile.focus = fields.focus;
196
+ return Object.keys(profile).length > 0 ? profile : void 0;
197
+ }
187
198
  async function submitApplication(db, chapter, fields, opts) {
188
199
  const app = chapter.application;
189
200
  for (const f of app.required) {
@@ -202,6 +213,7 @@ async function submitApplication(db, chapter, fields, opts) {
202
213
  }
203
214
  if (fields.focus !== void 0) row.focus = fields.focus;
204
215
  if (opts.groupId) row.groupId = opts.groupId;
216
+ if (fields.disclaimerAck === true || fields.disclaimerAck === "true") row.disclaimerAckAt = opts.now;
205
217
  const { duplicate } = await db.transact(
206
218
  [{ t: "update", ns: "applications", id, attrs: row }],
207
219
  opts.submissionId ? { mutationId: `join:${opts.submissionId}` } : void 0
@@ -515,8 +527,13 @@ async function provisionApplicant(db, chapter, applicationId, fields) {
515
527
  try {
516
528
  const secret = await getVaultSecret(db, "clerk_secret_key");
517
529
  if (secret) {
518
- if (chapter.account === "create") await createClerkUser(secret, { email, firstName: s(fields.firstName), lastName: s(fields.lastName) });
519
- else await createClerkInvitation(secret, { email });
530
+ const profile = applicantProfile(chapter, fields);
531
+ const publicMetadata = { applicationId, ...profile ? { profile } : {} };
532
+ if (chapter.account === "create") {
533
+ await createClerkUser(secret, { email, firstName: s(fields.firstName), lastName: s(fields.lastName), publicMetadata });
534
+ } else {
535
+ await createClerkInvitation(secret, { email, publicMetadata });
536
+ }
520
537
  }
521
538
  } catch {
522
539
  }