@nymbalhq/platform 1.2.0 → 1.3.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.
@@ -0,0 +1,8 @@
1
+ import {
2
+ registerAllRoutes
3
+ } from "./chunk-2PLYK5RU.js";
4
+ import "./chunk-QN56IB4G.js";
5
+ export {
6
+ registerAllRoutes
7
+ };
8
+ //# sourceMappingURL=register-UUQ64HZP.js.map
@@ -0,0 +1,27 @@
1
+ -- Whose event each row is, so one record's history is an index range. The backfill mirrors `subjectOf`
2
+ -- (src/history/subject.ts): a subject needs a string id at the first path its type names, else the row has none.
3
+ ALTER TABLE "events" ADD COLUMN "subject_type" text;--> statement-breakpoint
4
+ ALTER TABLE "events" ADD COLUMN "subject_id" text;--> statement-breakpoint
5
+ UPDATE "events" SET
6
+ "subject_type" = CASE
7
+ WHEN starts_with("type", 'product.') THEN 'product'
8
+ WHEN starts_with("type", 'order.') OR starts_with("type", 'payment.') THEN 'order'
9
+ WHEN starts_with("type", 'customer.') THEN 'customer'
10
+ WHEN starts_with("type", 'inventory.') THEN 'variant'
11
+ END,
12
+ "subject_id" = CASE
13
+ WHEN starts_with("type", 'product.') THEN CASE
14
+ WHEN jsonb_typeof("envelope" #> '{payload,product,id}') = 'string' THEN "envelope" #>> '{payload,product,id}'
15
+ WHEN jsonb_typeof("envelope" #> '{payload,productId}') = 'string' THEN "envelope" #>> '{payload,productId}'
16
+ END
17
+ WHEN starts_with("type", 'order.') OR starts_with("type", 'payment.') THEN CASE
18
+ WHEN jsonb_typeof("envelope" #> '{payload,order,id}') = 'string' THEN "envelope" #>> '{payload,order,id}'
19
+ WHEN jsonb_typeof("envelope" #> '{payload,orderId}') = 'string' THEN "envelope" #>> '{payload,orderId}'
20
+ END
21
+ WHEN starts_with("type", 'customer.') AND jsonb_typeof("envelope" #> '{payload,customerId}') = 'string'
22
+ THEN "envelope" #>> '{payload,customerId}'
23
+ WHEN starts_with("type", 'inventory.') AND jsonb_typeof("envelope" #> '{payload,variantId}') = 'string'
24
+ THEN "envelope" #>> '{payload,variantId}'
25
+ END;--> statement-breakpoint
26
+ UPDATE "events" SET "subject_type" = NULL WHERE "subject_id" IS NULL;--> statement-breakpoint
27
+ CREATE INDEX IF NOT EXISTS "events_subject_idx" ON "events" USING btree ("subject_type","subject_id","seq");