@nymbalhq/platform 1.2.0 → 1.4.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.
Files changed (33) hide show
  1. package/dist/{chunk-UBEGSSFI.js → chunk-GMV3B3SC.js} +3681 -389
  2. package/dist/chunk-GMV3B3SC.js.map +1 -0
  3. package/dist/{chunk-XVUH34US.js → chunk-SNNK2OX3.js} +129 -7
  4. package/dist/chunk-SNNK2OX3.js.map +1 -0
  5. package/dist/db/schema/index.d.ts +1821 -323
  6. package/dist/db/schema/index.js +1 -1
  7. package/dist/index.d.ts +239 -10
  8. package/dist/index.js +734 -2169
  9. package/dist/index.js.map +1 -1
  10. package/dist/register-N2XGSFUF.js +8 -0
  11. package/migrations/postgres/0012_event_subject.sql +27 -0
  12. package/migrations/postgres/0013_order_access_keys.sql +11 -0
  13. package/migrations/postgres/0014_alert_subscriptions.sql +22 -0
  14. package/migrations/postgres/0015_events_retry_at.sql +1 -0
  15. package/migrations/postgres/meta/0012_snapshot.json +1926 -0
  16. package/migrations/postgres/meta/0013_snapshot.json +2000 -0
  17. package/migrations/postgres/meta/0014_snapshot.json +2185 -0
  18. package/migrations/postgres/meta/0015_snapshot.json +2191 -0
  19. package/migrations/postgres/meta/_journal.json +28 -0
  20. package/migrations/sqlite/0012_event_subject.sql +27 -0
  21. package/migrations/sqlite/0013_order_access_keys.sql +11 -0
  22. package/migrations/sqlite/0014_alert_subscriptions.sql +22 -0
  23. package/migrations/sqlite/0015_events_retry_at.sql +1 -0
  24. package/migrations/sqlite/meta/0012_snapshot.json +1728 -0
  25. package/migrations/sqlite/meta/0013_snapshot.json +1788 -0
  26. package/migrations/sqlite/meta/0014_snapshot.json +1931 -0
  27. package/migrations/sqlite/meta/0015_snapshot.json +1938 -0
  28. package/migrations/sqlite/meta/_journal.json +28 -0
  29. package/package.json +19 -19
  30. package/dist/chunk-UBEGSSFI.js.map +0 -1
  31. package/dist/chunk-XVUH34US.js.map +0 -1
  32. package/dist/register-NHG3TIRQ.js +0 -8
  33. /package/dist/{register-NHG3TIRQ.js.map → register-N2XGSFUF.js.map} +0 -0
@@ -85,6 +85,34 @@
85
85
  "when": 1792659500377,
86
86
  "tag": "0011_audit_entries",
87
87
  "breakpoints": true
88
+ },
89
+ {
90
+ "idx": 12,
91
+ "version": "7",
92
+ "when": 1792853533921,
93
+ "tag": "0012_event_subject",
94
+ "breakpoints": true
95
+ },
96
+ {
97
+ "idx": 13,
98
+ "version": "7",
99
+ "when": 1792918142785,
100
+ "tag": "0013_order_access_keys",
101
+ "breakpoints": true
102
+ },
103
+ {
104
+ "idx": 14,
105
+ "version": "7",
106
+ "when": 1792919479403,
107
+ "tag": "0014_alert_subscriptions",
108
+ "breakpoints": true
109
+ },
110
+ {
111
+ "idx": 15,
112
+ "version": "7",
113
+ "when": 1793018982663,
114
+ "tag": "0015_events_retry_at",
115
+ "breakpoints": true
88
116
  }
89
117
  ]
90
118
  }
@@ -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`);
@@ -0,0 +1,11 @@
1
+ -- What opens an order to a shopper with no session: the sha256 hex of each key a checkout or an email served.
2
+ CREATE TABLE `order_access_keys` (
3
+ `id` text PRIMARY KEY NOT NULL,
4
+ `order_id` text NOT NULL,
5
+ `key_hash` text NOT NULL,
6
+ `purpose` text NOT NULL,
7
+ `created_at` text NOT NULL
8
+ );
9
+ --> statement-breakpoint
10
+ CREATE UNIQUE INDEX `order_access_keys_key_hash_idx` ON `order_access_keys` (`key_hash`);--> statement-breakpoint
11
+ CREATE INDEX `order_access_keys_order_idx` ON `order_access_keys` (`order_id`);
@@ -0,0 +1,22 @@
1
+ CREATE TABLE `alert_subscriptions` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `email` text NOT NULL,
4
+ `kind` text NOT NULL,
5
+ `variant_id` text NOT NULL,
6
+ `product_id` text NOT NULL,
7
+ `status` text NOT NULL,
8
+ `confirm_token` text NOT NULL,
9
+ `unsubscribe_token` text NOT NULL,
10
+ `origin` text NOT NULL,
11
+ `baseline_price_minor` integer,
12
+ `created_at` text NOT NULL,
13
+ `updated_at` text NOT NULL,
14
+ `confirmed_at` text,
15
+ CONSTRAINT "alert_subscriptions_kind" CHECK("alert_subscriptions"."kind" IN ('back_in_stock', 'price_drop')),
16
+ CONSTRAINT "alert_subscriptions_status" CHECK("alert_subscriptions"."status" IN ('pending', 'active', 'fired', 'unsubscribed'))
17
+ );
18
+ --> statement-breakpoint
19
+ CREATE UNIQUE INDEX `alert_subscriptions_address_unique` ON `alert_subscriptions` (`email`,`variant_id`,`kind`);--> statement-breakpoint
20
+ CREATE UNIQUE INDEX `alert_subscriptions_confirm_token_unique` ON `alert_subscriptions` (`confirm_token`);--> statement-breakpoint
21
+ CREATE UNIQUE INDEX `alert_subscriptions_unsubscribe_token_unique` ON `alert_subscriptions` (`unsubscribe_token`);--> statement-breakpoint
22
+ CREATE INDEX `alert_subscriptions_fan_out_idx` ON `alert_subscriptions` (`variant_id`,`kind`,`status`);
@@ -0,0 +1 @@
1
+ ALTER TABLE `events` ADD `retry_at` text;