@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.
- package/dist/{chunk-UBEGSSFI.js → chunk-2PLYK5RU.js} +567 -38
- package/dist/chunk-2PLYK5RU.js.map +1 -0
- package/dist/{chunk-XVUH34US.js → chunk-QN56IB4G.js} +11 -3
- package/dist/chunk-QN56IB4G.js.map +1 -0
- package/dist/db/schema/index.d.ts +136 -0
- package/dist/db/schema/index.js +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.js +96 -18
- package/dist/index.js.map +1 -1
- package/dist/register-UUQ64HZP.js +8 -0
- package/migrations/postgres/0012_event_subject.sql +27 -0
- package/migrations/postgres/meta/0012_snapshot.json +1926 -0
- package/migrations/postgres/meta/_journal.json +7 -0
- package/migrations/sqlite/0012_event_subject.sql +27 -0
- package/migrations/sqlite/meta/0012_snapshot.json +1728 -0
- package/migrations/sqlite/meta/_journal.json +7 -0
- package/package.json +19 -19
- package/dist/chunk-UBEGSSFI.js.map +0 -1
- package/dist/chunk-XVUH34US.js.map +0 -1
- package/dist/register-NHG3TIRQ.js +0 -8
- /package/dist/{register-NHG3TIRQ.js.map → register-UUQ64HZP.js.map} +0 -0
|
@@ -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 `subject_type` text;--> statement-breakpoint
|
|
4
|
+
ALTER TABLE `events` ADD `subject_id` text;--> statement-breakpoint
|
|
5
|
+
UPDATE `events` SET
|
|
6
|
+
`subject_type` = CASE
|
|
7
|
+
WHEN `type` GLOB 'product.*' THEN 'product'
|
|
8
|
+
WHEN `type` GLOB 'order.*' OR `type` GLOB 'payment.*' THEN 'order'
|
|
9
|
+
WHEN `type` GLOB 'customer.*' THEN 'customer'
|
|
10
|
+
WHEN `type` GLOB 'inventory.*' THEN 'variant'
|
|
11
|
+
END,
|
|
12
|
+
`subject_id` = CASE
|
|
13
|
+
WHEN `type` GLOB 'product.*' THEN CASE
|
|
14
|
+
WHEN json_type(`envelope`, '$.payload.product.id') = 'text' THEN json_extract(`envelope`, '$.payload.product.id')
|
|
15
|
+
WHEN json_type(`envelope`, '$.payload.productId') = 'text' THEN json_extract(`envelope`, '$.payload.productId')
|
|
16
|
+
END
|
|
17
|
+
WHEN `type` GLOB 'order.*' OR `type` GLOB 'payment.*' THEN CASE
|
|
18
|
+
WHEN json_type(`envelope`, '$.payload.order.id') = 'text' THEN json_extract(`envelope`, '$.payload.order.id')
|
|
19
|
+
WHEN json_type(`envelope`, '$.payload.orderId') = 'text' THEN json_extract(`envelope`, '$.payload.orderId')
|
|
20
|
+
END
|
|
21
|
+
WHEN `type` GLOB 'customer.*' AND json_type(`envelope`, '$.payload.customerId') = 'text'
|
|
22
|
+
THEN json_extract(`envelope`, '$.payload.customerId')
|
|
23
|
+
WHEN `type` GLOB 'inventory.*' AND json_type(`envelope`, '$.payload.variantId') = 'text'
|
|
24
|
+
THEN json_extract(`envelope`, '$.payload.variantId')
|
|
25
|
+
END;--> statement-breakpoint
|
|
26
|
+
UPDATE `events` SET `subject_type` = NULL WHERE `subject_id` IS NULL;--> statement-breakpoint
|
|
27
|
+
CREATE INDEX `events_subject_idx` ON `events` (`subject_type`,`subject_id`,`seq`);
|