@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.
- package/README.md +12 -0
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +19 -2
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.js +19 -2
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/worker/index.js
CHANGED
|
@@ -157,6 +157,17 @@ async function createClerkUser(secretKey, input, fetchImpl = fetch) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// src/member.ts
|
|
160
|
+
var IDENTITY_FIELDS = /* @__PURE__ */ new Set(["email", "firstName", "lastName"]);
|
|
161
|
+
function applicantProfile(chapter, fields) {
|
|
162
|
+
const profile = {};
|
|
163
|
+
for (const f of [...chapter.application.required, ...chapter.application.optional]) {
|
|
164
|
+
if (IDENTITY_FIELDS.has(f)) continue;
|
|
165
|
+
const v = fields[f];
|
|
166
|
+
if (typeof v === "string" && v.trim() !== "") profile[f] = v.trim();
|
|
167
|
+
}
|
|
168
|
+
if (fields.focus !== void 0) profile.focus = fields.focus;
|
|
169
|
+
return Object.keys(profile).length > 0 ? profile : void 0;
|
|
170
|
+
}
|
|
160
171
|
async function submitApplication(db, chapter, fields, opts) {
|
|
161
172
|
const app = chapter.application;
|
|
162
173
|
for (const f of app.required) {
|
|
@@ -175,6 +186,7 @@ async function submitApplication(db, chapter, fields, opts) {
|
|
|
175
186
|
}
|
|
176
187
|
if (fields.focus !== void 0) row.focus = fields.focus;
|
|
177
188
|
if (opts.groupId) row.groupId = opts.groupId;
|
|
189
|
+
if (fields.disclaimerAck === true || fields.disclaimerAck === "true") row.disclaimerAckAt = opts.now;
|
|
178
190
|
const { duplicate } = await db.transact(
|
|
179
191
|
[{ t: "update", ns: "applications", id, attrs: row }],
|
|
180
192
|
opts.submissionId ? { mutationId: `join:${opts.submissionId}` } : void 0
|
|
@@ -488,8 +500,13 @@ async function provisionApplicant(db, chapter, applicationId, fields) {
|
|
|
488
500
|
try {
|
|
489
501
|
const secret = await getVaultSecret(db, "clerk_secret_key");
|
|
490
502
|
if (secret) {
|
|
491
|
-
|
|
492
|
-
|
|
503
|
+
const profile = applicantProfile(chapter, fields);
|
|
504
|
+
const publicMetadata = { applicationId, ...profile ? { profile } : {} };
|
|
505
|
+
if (chapter.account === "create") {
|
|
506
|
+
await createClerkUser(secret, { email, firstName: s(fields.firstName), lastName: s(fields.lastName), publicMetadata });
|
|
507
|
+
} else {
|
|
508
|
+
await createClerkInvitation(secret, { email, publicMetadata });
|
|
509
|
+
}
|
|
493
510
|
}
|
|
494
511
|
} catch {
|
|
495
512
|
}
|