@odla-ai/chapter 0.33.1 → 0.33.2
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 +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +20 -4
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.js +20 -4
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
- package/runbooks/greenfield.md +4 -0
package/dist/worker/index.js
CHANGED
|
@@ -547,6 +547,11 @@ function groupAttrs(document) {
|
|
|
547
547
|
...document.scheduling ? { schedulingJson: document.scheduling } : {}
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
|
+
var byPublicId = (ns, value) => ({
|
|
551
|
+
ns,
|
|
552
|
+
attr: "id",
|
|
553
|
+
value
|
|
554
|
+
});
|
|
550
555
|
async function materializeSignupControl(db, envelope, previous, receivedAt) {
|
|
551
556
|
const { document, digest } = envelope;
|
|
552
557
|
const currentRows = (await db.query({ tiers: { $: {
|
|
@@ -558,10 +563,12 @@ async function materializeSignupControl(db, envelope, previous, receivedAt) {
|
|
|
558
563
|
if (previous?.active) ops.push({ t: "update", ns: "signupControls", id: previous.id, attrs: { active: false } });
|
|
559
564
|
for (const row of currentRows) {
|
|
560
565
|
const id2 = String(row.id ?? "");
|
|
561
|
-
if (id2 && !incoming.has(id2))
|
|
566
|
+
if (id2 && !incoming.has(id2)) {
|
|
567
|
+
ops.push({ t: "update", ns: "tiers", id: byPublicId("tiers", id2), attrs: { active: false } });
|
|
568
|
+
}
|
|
562
569
|
}
|
|
563
570
|
for (const tier of document.tiers) {
|
|
564
|
-
ops.push({ t: "update", ns: "tiers", id: tier.id, attrs: {
|
|
571
|
+
ops.push({ t: "update", ns: "tiers", id: byPublicId("tiers", tier.id), attrs: {
|
|
565
572
|
id: tier.id,
|
|
566
573
|
groupId: document.target.chapterId,
|
|
567
574
|
name: tier.name,
|
|
@@ -573,7 +580,12 @@ async function materializeSignupControl(db, envelope, previous, receivedAt) {
|
|
|
573
580
|
createdAt: receivedAt
|
|
574
581
|
} });
|
|
575
582
|
}
|
|
576
|
-
ops.push({
|
|
583
|
+
ops.push({
|
|
584
|
+
t: "update",
|
|
585
|
+
ns: "groups",
|
|
586
|
+
id: byPublicId("groups", document.target.chapterId),
|
|
587
|
+
attrs: groupAttrs(document)
|
|
588
|
+
});
|
|
577
589
|
const id = `signup-control:${document.target.environment}:${document.revision}`;
|
|
578
590
|
ops.push({ t: "update", ns: "signupControls", id, attrs: {
|
|
579
591
|
id,
|
|
@@ -1803,7 +1815,11 @@ var handleSignupControl = async (req, url, env, ctx) => {
|
|
|
1803
1815
|
});
|
|
1804
1816
|
}
|
|
1805
1817
|
const receivedAt = Date.now();
|
|
1806
|
-
|
|
1818
|
+
try {
|
|
1819
|
+
await materializeSignupControl(db, { digest, document }, latest, receivedAt);
|
|
1820
|
+
} catch {
|
|
1821
|
+
return reject("materialization_failed", 503);
|
|
1822
|
+
}
|
|
1807
1823
|
return json({
|
|
1808
1824
|
ok: true,
|
|
1809
1825
|
target: { chapterId: ctx.chapter.id, environment: env.ODLA_ENV },
|