@haatlabs-core/db-core 0.19.0 → 0.22.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.
@@ -57,6 +57,8 @@ export declare const membershipColumns: (refs: {
57
57
  userId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"user_id">>;
58
58
  organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
59
59
  role: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgEnumColumnBuilderInitial<"role", ["OWNER", "ADMIN", "MEMBER", "VIEWER"]>>;
60
+ /** When the person last switched to this organization: a sign-in lands on the latest. */
61
+ lastUsedAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"last_used_at">;
60
62
  };
61
63
  /** A person is a member of an organization once: for the table's third argument. */
62
64
  export declare const membershipIndexes: (t: {
@@ -271,6 +273,11 @@ export declare const subscriptionColumns: (refs: {
271
273
  */
272
274
  priceAmountMinor: import("drizzle-orm/pg-core").PgBigInt53BuilderInitial<"price_amount_minor">;
273
275
  priceCurrency: import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_currency", [string, ...string[]]>;
276
+ /**
277
+ * How often it is charged for, from its price: `MONTH` or `YEAR`. A yearly subscription's
278
+ * allowance is still for each month.
279
+ */
280
+ priceInterval: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_interval", [string, ...string[]]>>>;
274
281
  };
275
282
  /** One subscription per organization in each product. */
276
283
  export declare const subscriptionIndexes: (t: {
@@ -289,13 +296,16 @@ export declare const planPriceColumns: (refs: {
289
296
  /** A Stripe price ID, a Razorpay plan ID, or the name Shopify's charge is made under. */
290
297
  priceRef: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_ref", [string, ...string[]]>>;
291
298
  currency: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"currency", [string, ...string[]]>>;
292
- /** In the currency's smallest unit (cents, paise), per month. */
299
+ /** In the currency's smallest unit (cents, paise), for each interval. */
293
300
  amountMinor: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgIntegerBuilderInitial<"amount_minor">>;
301
+ /** How often it is charged: `MONTH` or `YEAR`. */
302
+ interval: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"interval", [string, ...string[]]>>>;
294
303
  };
295
304
  export declare const planPriceIndexes: (t: {
296
305
  planId: AnyPgColumn;
297
306
  provider: AnyPgColumn;
298
307
  currency: AnyPgColumn;
308
+ interval: AnyPgColumn;
299
309
  priceRef: AnyPgColumn;
300
310
  }) => import("drizzle-orm/pg-core").UniqueConstraintBuilder[];
301
311
  /** Every gateway webhook event that was applied, so a repeated delivery is not applied again. */
@@ -383,7 +393,7 @@ export declare const outboxPriorityColumn: () => import("drizzle-orm").HasDefaul
383
393
  * the tables it reads come later in the same migration.
384
394
  */
385
395
  export declare const ORGANIZATION_GOES_FIRST_SQL = "CREATE OR REPLACE FUNCTION organization_goes_first() RETURNS boolean\nLANGUAGE sql STABLE\nAS $$\n WITH org AS (\n SELECT NULLIF(current_setting('app.organization_id', true), '')::uuid AS id\n ),\n held AS (\n SELECT s.plan_id\n FROM subscriptions s\n JOIN org ON s.organization_id = org.id\n WHERE s.status = 'ACTIVE'\n AND s.product = 'app'\n AND s.period_start <= now()\n AND (now() < s.period_end OR (s.provider = 'shopify' AND s.provider_ended_at IS NULL))\n LIMIT 1\n ),\n plan AS (\n SELECT COALESCE(\n (SELECT plan_id FROM held),\n (SELECT id FROM plans WHERE is_default AND product = 'app' LIMIT 1)\n ) AS id\n )\n SELECT CASE\n WHEN (SELECT id FROM org) IS NULL THEN false\n ELSE COALESCE(\n (\n SELECT f.limit_value = 1\n FROM plan_features f\n JOIN plan ON f.plan_id = plan.id\n WHERE f.feature_key = 'PRIORITY'\n ),\n false\n )\n END\n$$;";
386
- type TableOf<N extends string, C extends Record<string, PgColumnBuilderBase>> = PgTableWithColumns<{
396
+ export type TableOf<N extends string, C extends Record<string, PgColumnBuilderBase>> = PgTableWithColumns<{
387
397
  name: N;
388
398
  schema: undefined;
389
399
  columns: BuildColumns<N, C, 'pg'>;
@@ -96,6 +96,8 @@ const membershipColumns = (refs) => ({
96
96
  userId: (0, import_pg_core.uuid)("user_id").notNull().references(() => refs.users.id, { onDelete: "cascade" }),
97
97
  organizationId: (0, import_pg_core.uuid)("organization_id").notNull().references(() => refs.organizations.id, { onDelete: "cascade" }),
98
98
  role: roleEnum("role").notNull(),
99
+ /** When the person last switched to this organization: a sign-in lands on the latest. */
100
+ lastUsedAt: (0, import_pg_core.timestamp)("last_used_at", { withTimezone: true }),
99
101
  ...timestamps()
100
102
  });
101
103
  const membershipIndexes = (t) => [
@@ -256,6 +258,11 @@ const subscriptionColumns = (refs) => ({
256
258
  */
257
259
  priceAmountMinor: (0, import_pg_core.bigint)("price_amount_minor", { mode: "number" }),
258
260
  priceCurrency: (0, import_pg_core.text)("price_currency"),
261
+ /**
262
+ * How often it is charged for, from its price: `MONTH` or `YEAR`. A yearly subscription's
263
+ * allowance is still for each month.
264
+ */
265
+ priceInterval: (0, import_pg_core.text)("price_interval").notNull().default("MONTH"),
259
266
  ...timestamps()
260
267
  });
261
268
  const subscriptionIndexes = (t) => [
@@ -268,12 +275,14 @@ const planPriceColumns = (refs) => ({
268
275
  /** A Stripe price ID, a Razorpay plan ID, or the name Shopify's charge is made under. */
269
276
  priceRef: (0, import_pg_core.text)("price_ref").notNull(),
270
277
  currency: (0, import_pg_core.text)("currency").notNull(),
271
- /** In the currency's smallest unit (cents, paise), per month. */
278
+ /** In the currency's smallest unit (cents, paise), for each interval. */
272
279
  amountMinor: (0, import_pg_core.integer)("amount_minor").notNull(),
280
+ /** How often it is charged: `MONTH` or `YEAR`. */
281
+ interval: (0, import_pg_core.text)("interval").notNull().default("MONTH"),
273
282
  ...timestamps()
274
283
  });
275
284
  const planPriceIndexes = (t) => [
276
- (0, import_pg_core.unique)("plan_prices_plan_provider_currency_unique").on(t.planId, t.provider, t.currency),
285
+ (0, import_pg_core.unique)("plan_prices_plan_provider_currency_interval_unique").on(t.planId, t.provider, t.currency, t.interval),
277
286
  (0, import_pg_core.unique)("plan_prices_provider_ref_unique").on(t.provider, t.priceRef)
278
287
  ];
279
288
  const paymentEventColumns = () => ({
@@ -2,6 +2,8 @@ export { createDatabase } from './client.js';
2
2
  export type { Database, DatabaseHandle, DatabaseLogger, Tx } from './client.js';
3
3
  export { ORGANIZATION_GOES_FIRST_SQL, apiKeyColumns, auditLogColumns, auditLogIndexes, membershipColumns, membershipIndexes, organizationColumns, organizationFeatureColumns, organizationFeatureIndexes, allowanceGrantColumns, allowanceGrantIndexes, organizationOriginEnum, outboxMessageColumns, outboxMessageIndexes, outboxPriorityColumn, paymentEventColumns, paymentEventIndexes, planColumns, planFeatureColumns, planFeatureIndexes, planIndexes, planPriceColumns, planPriceIndexes, platformAdminColumns, roleEnum, shopifyInstallationColumns, subscriptionColumns, subscriptionIndexes, subscriptionStatusEnum, timestamps, usageRecordColumns, usageRecordIndexes, userColumns, webhookEventColumns, extensionKeyColumns, userIdentityColumns, disposableEmailDomainColumns, userIdentityIndexes, extensionKeyIndexes, } from './columns.js';
4
4
  export type { ApiKeysTable, ExtensionKeysTable, UserIdentitiesTable, DisposableEmailDomainsTable, AuditLogsTable, MembershipsTable, OrganizationsTable, OrganizationFeaturesTable, AllowanceGrantsTable, OutboxMessagesTable, PaymentEventsTable, PlanFeaturesTable, PlanPricesTable, PlansTable, PlatformAdminsTable, ShopifyInstallationsTable, SubscriptionsTable, UsageRecordsTable, UsersTable, WebhookEventsTable, } from './columns.js';
5
+ export { notificationColumns, notificationDefaultColumns, notificationDefaultIndexes, notificationIndexes, notificationPreferenceColumns, notificationPreferenceIndexes, pushSubscriptionColumns, pushSubscriptionIndexes, } from './notification-columns.js';
6
+ export type { NotificationDefaultsTable, NotificationPreferencesTable, NotificationsTable, PushSubscriptionsTable, } from './notification-columns.js';
5
7
  export { isUniqueViolation } from './errors.js';
6
8
  export { runMigrations, runMigrationsCli } from './migrate.js';
7
9
  export { ApiKeyRepository } from './repositories/api-key.repository.js';
package/dist/cjs/index.js CHANGED
@@ -42,6 +42,12 @@ __export(index_exports, {
42
42
  isUniqueViolation: () => import_errors.isUniqueViolation,
43
43
  membershipColumns: () => import_columns.membershipColumns,
44
44
  membershipIndexes: () => import_columns.membershipIndexes,
45
+ notificationColumns: () => import_notification_columns.notificationColumns,
46
+ notificationDefaultColumns: () => import_notification_columns.notificationDefaultColumns,
47
+ notificationDefaultIndexes: () => import_notification_columns.notificationDefaultIndexes,
48
+ notificationIndexes: () => import_notification_columns.notificationIndexes,
49
+ notificationPreferenceColumns: () => import_notification_columns.notificationPreferenceColumns,
50
+ notificationPreferenceIndexes: () => import_notification_columns.notificationPreferenceIndexes,
45
51
  organizationColumns: () => import_columns.organizationColumns,
46
52
  organizationFeatureColumns: () => import_columns.organizationFeatureColumns,
47
53
  organizationFeatureIndexes: () => import_columns.organizationFeatureIndexes,
@@ -58,6 +64,8 @@ __export(index_exports, {
58
64
  planPriceColumns: () => import_columns.planPriceColumns,
59
65
  planPriceIndexes: () => import_columns.planPriceIndexes,
60
66
  platformAdminColumns: () => import_columns.platformAdminColumns,
67
+ pushSubscriptionColumns: () => import_notification_columns.pushSubscriptionColumns,
68
+ pushSubscriptionIndexes: () => import_notification_columns.pushSubscriptionIndexes,
61
69
  roleEnum: () => import_columns.roleEnum,
62
70
  runMigrations: () => import_migrate.runMigrations,
63
71
  runMigrationsCli: () => import_migrate.runMigrationsCli,
@@ -77,6 +85,7 @@ __export(index_exports, {
77
85
  module.exports = __toCommonJS(index_exports);
78
86
  var import_client = require("./client.js");
79
87
  var import_columns = require("./columns.js");
88
+ var import_notification_columns = require("./notification-columns.js");
80
89
  var import_errors = require("./errors.js");
81
90
  var import_migrate = require("./migrate.js");
82
91
  var import_api_key_repository = require("./repositories/api-key.repository.js");
@@ -116,6 +125,12 @@ var import_writers = require("./writers.js");
116
125
  isUniqueViolation,
117
126
  membershipColumns,
118
127
  membershipIndexes,
128
+ notificationColumns,
129
+ notificationDefaultColumns,
130
+ notificationDefaultIndexes,
131
+ notificationIndexes,
132
+ notificationPreferenceColumns,
133
+ notificationPreferenceIndexes,
119
134
  organizationColumns,
120
135
  organizationFeatureColumns,
121
136
  organizationFeatureIndexes,
@@ -132,6 +147,8 @@ var import_writers = require("./writers.js");
132
147
  planPriceColumns,
133
148
  planPriceIndexes,
134
149
  platformAdminColumns,
150
+ pushSubscriptionColumns,
151
+ pushSubscriptionIndexes,
135
152
  roleEnum,
136
153
  runMigrations,
137
154
  runMigrationsCli,
@@ -0,0 +1,106 @@
1
+ import type { AnyPgColumn } from 'drizzle-orm/pg-core';
2
+ import type { TableOf } from './columns.js';
3
+ /**
4
+ * The columns of the notification tables (@haatlabs-core/notifications). Built like the other
5
+ * shared columns: the app builds each table from these, with its own migrations.
6
+ */
7
+ type Ref = {
8
+ id: AnyPgColumn;
9
+ };
10
+ /** One inbox item for one recipient. The sent-at columns make each delivery idempotent. */
11
+ export declare const notificationColumns: (refs: {
12
+ organizations: Ref;
13
+ }) => {
14
+ id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
15
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
16
+ recipientType: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_type", [string, ...string[]]>>;
17
+ recipientId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_id", [string, ...string[]]>>;
18
+ event: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"event", [string, ...string[]]>>;
19
+ title: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"title", [string, ...string[]]>>;
20
+ body: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"body", [string, ...string[]]>>>;
21
+ /** An app-relative path. */
22
+ link: import("drizzle-orm/pg-core").PgTextBuilderInitial<"link", [string, ...string[]]>;
23
+ data: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgJsonbBuilderInitial<"data">>>;
24
+ /** Names the thing notified, so notifying it again adds no second row. */
25
+ dedupeKey: import("drizzle-orm/pg-core").PgTextBuilderInitial<"dedupe_key", [string, ...string[]]>;
26
+ readAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
27
+ liveSentAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
28
+ pushSentAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
29
+ emailSentAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
30
+ createdAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
31
+ };
32
+ /** The notifications' indexes, for the table's third argument. */
33
+ export declare const notificationIndexes: (t: {
34
+ organizationId: AnyPgColumn;
35
+ recipientType: AnyPgColumn;
36
+ recipientId: AnyPgColumn;
37
+ event: AnyPgColumn;
38
+ dedupeKey: AnyPgColumn;
39
+ createdAt: AnyPgColumn;
40
+ readAt: AnyPgColumn;
41
+ }) => import("drizzle-orm/pg-core").IndexBuilder[];
42
+ /** A person's own choice to get an event by a channel ('email' or 'push'). */
43
+ export declare const notificationPreferenceColumns: (refs: {
44
+ organizations: Ref;
45
+ }) => {
46
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
47
+ recipientType: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_type", [string, ...string[]]>>;
48
+ recipientId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_id", [string, ...string[]]>>;
49
+ event: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"event", [string, ...string[]]>>;
50
+ channel: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"channel", [string, ...string[]]>>;
51
+ enabled: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBooleanBuilderInitial<"enabled">>;
52
+ updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
53
+ };
54
+ export declare const notificationPreferenceIndexes: (t: {
55
+ organizationId: AnyPgColumn;
56
+ recipientType: AnyPgColumn;
57
+ recipientId: AnyPgColumn;
58
+ event: AnyPgColumn;
59
+ channel: AnyPgColumn;
60
+ }) => import("drizzle-orm/pg-core").PrimaryKeyBuilder[];
61
+ /** An organization's default for an audience, used when a person has made no choice. */
62
+ export declare const notificationDefaultColumns: (refs: {
63
+ organizations: Ref;
64
+ }) => {
65
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
66
+ audience: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"audience", [string, ...string[]]>>;
67
+ event: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"event", [string, ...string[]]>>;
68
+ channel: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"channel", [string, ...string[]]>>;
69
+ enabled: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBooleanBuilderInitial<"enabled">>;
70
+ updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
71
+ };
72
+ export declare const notificationDefaultIndexes: (t: {
73
+ organizationId: AnyPgColumn;
74
+ audience: AnyPgColumn;
75
+ event: AnyPgColumn;
76
+ channel: AnyPgColumn;
77
+ }) => import("drizzle-orm/pg-core").PrimaryKeyBuilder[];
78
+ /** A device that gets push: a Web Push subscription, or an FCM token. */
79
+ export declare const pushSubscriptionColumns: (refs: {
80
+ organizations: Ref;
81
+ }) => {
82
+ id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
83
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
84
+ recipientType: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_type", [string, ...string[]]>>;
85
+ recipientId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_id", [string, ...string[]]>>;
86
+ /** 'webpush' or 'fcm'. */
87
+ kind: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"kind", [string, ...string[]]>>;
88
+ /** The Web Push endpoint, or the FCM token. */
89
+ endpoint: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"endpoint", [string, ...string[]]>>;
90
+ p256dh: import("drizzle-orm/pg-core").PgTextBuilderInitial<"p256dh", [string, ...string[]]>;
91
+ auth: import("drizzle-orm/pg-core").PgTextBuilderInitial<"auth", [string, ...string[]]>;
92
+ userAgent: import("drizzle-orm/pg-core").PgTextBuilderInitial<"user_agent", [string, ...string[]]>;
93
+ createdAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
94
+ lastUsedAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
95
+ };
96
+ export declare const pushSubscriptionIndexes: (t: {
97
+ organizationId: AnyPgColumn;
98
+ recipientType: AnyPgColumn;
99
+ recipientId: AnyPgColumn;
100
+ endpoint: AnyPgColumn;
101
+ }) => (import("drizzle-orm/pg-core").UniqueConstraintBuilder | import("drizzle-orm/pg-core").IndexBuilder)[];
102
+ export type NotificationsTable = TableOf<'notifications', ReturnType<typeof notificationColumns>>;
103
+ export type NotificationPreferencesTable = TableOf<'notification_preferences', ReturnType<typeof notificationPreferenceColumns>>;
104
+ export type NotificationDefaultsTable = TableOf<'notification_defaults', ReturnType<typeof notificationDefaultColumns>>;
105
+ export type PushSubscriptionsTable = TableOf<'push_subscriptions', ReturnType<typeof pushSubscriptionColumns>>;
106
+ export {};
@@ -0,0 +1,118 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var notification_columns_exports = {};
19
+ __export(notification_columns_exports, {
20
+ notificationColumns: () => notificationColumns,
21
+ notificationDefaultColumns: () => notificationDefaultColumns,
22
+ notificationDefaultIndexes: () => notificationDefaultIndexes,
23
+ notificationIndexes: () => notificationIndexes,
24
+ notificationPreferenceColumns: () => notificationPreferenceColumns,
25
+ notificationPreferenceIndexes: () => notificationPreferenceIndexes,
26
+ pushSubscriptionColumns: () => pushSubscriptionColumns,
27
+ pushSubscriptionIndexes: () => pushSubscriptionIndexes
28
+ });
29
+ module.exports = __toCommonJS(notification_columns_exports);
30
+ var import_drizzle_orm = require("drizzle-orm");
31
+ var import_pg_core = require("drizzle-orm/pg-core");
32
+ const organizationId = (refs) => (0, import_pg_core.uuid)("organization_id").notNull().references(() => refs.organizations.id, { onDelete: "cascade" });
33
+ const timestamptz = (name) => (0, import_pg_core.timestamp)(name, { withTimezone: true });
34
+ const notificationColumns = (refs) => ({
35
+ id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
36
+ organizationId: organizationId(refs),
37
+ recipientType: (0, import_pg_core.text)("recipient_type").notNull(),
38
+ recipientId: (0, import_pg_core.text)("recipient_id").notNull(),
39
+ event: (0, import_pg_core.text)("event").notNull(),
40
+ title: (0, import_pg_core.text)("title").notNull(),
41
+ body: (0, import_pg_core.text)("body").notNull().default(""),
42
+ /** An app-relative path. */
43
+ link: (0, import_pg_core.text)("link"),
44
+ data: (0, import_pg_core.jsonb)("data").notNull().default({}),
45
+ /** Names the thing notified, so notifying it again adds no second row. */
46
+ dedupeKey: (0, import_pg_core.text)("dedupe_key"),
47
+ readAt: timestamptz("read_at"),
48
+ liveSentAt: timestamptz("live_sent_at"),
49
+ pushSentAt: timestamptz("push_sent_at"),
50
+ emailSentAt: timestamptz("email_sent_at"),
51
+ createdAt: timestamptz("created_at").notNull().defaultNow()
52
+ });
53
+ const notificationIndexes = (t) => [
54
+ (0, import_pg_core.index)("notifications_recipient_created_idx").on(t.organizationId, t.recipientType, t.recipientId, t.createdAt),
55
+ (0, import_pg_core.index)("notifications_unread_idx").on(t.organizationId, t.recipientType, t.recipientId).where(import_drizzle_orm.sql`${t.readAt} is null`),
56
+ (0, import_pg_core.uniqueIndex)("notifications_dedupe_uq").on(t.organizationId, t.recipientType, t.recipientId, t.event, t.dedupeKey).where(import_drizzle_orm.sql`${t.dedupeKey} is not null`)
57
+ ];
58
+ const notificationPreferenceColumns = (refs) => ({
59
+ organizationId: organizationId(refs),
60
+ recipientType: (0, import_pg_core.text)("recipient_type").notNull(),
61
+ recipientId: (0, import_pg_core.text)("recipient_id").notNull(),
62
+ event: (0, import_pg_core.text)("event").notNull(),
63
+ channel: (0, import_pg_core.text)("channel").notNull(),
64
+ enabled: (0, import_pg_core.boolean)("enabled").notNull(),
65
+ updatedAt: timestamptz("updated_at").notNull().defaultNow()
66
+ });
67
+ const notificationPreferenceIndexes = (t) => [
68
+ // Named: drizzle's own name is 85 characters, and Postgres cuts names at 63.
69
+ (0, import_pg_core.primaryKey)({
70
+ name: "notification_preferences_pkey",
71
+ columns: [t.organizationId, t.recipientType, t.recipientId, t.event, t.channel]
72
+ })
73
+ ];
74
+ const notificationDefaultColumns = (refs) => ({
75
+ organizationId: organizationId(refs),
76
+ audience: (0, import_pg_core.text)("audience").notNull(),
77
+ event: (0, import_pg_core.text)("event").notNull(),
78
+ channel: (0, import_pg_core.text)("channel").notNull(),
79
+ enabled: (0, import_pg_core.boolean)("enabled").notNull(),
80
+ updatedAt: timestamptz("updated_at").notNull().defaultNow()
81
+ });
82
+ const notificationDefaultIndexes = (t) => [
83
+ (0, import_pg_core.primaryKey)({
84
+ name: "notification_defaults_pkey",
85
+ columns: [t.organizationId, t.audience, t.event, t.channel]
86
+ })
87
+ ];
88
+ const pushSubscriptionColumns = (refs) => ({
89
+ id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
90
+ organizationId: organizationId(refs),
91
+ recipientType: (0, import_pg_core.text)("recipient_type").notNull(),
92
+ recipientId: (0, import_pg_core.text)("recipient_id").notNull(),
93
+ /** 'webpush' or 'fcm'. */
94
+ kind: (0, import_pg_core.text)("kind").notNull(),
95
+ /** The Web Push endpoint, or the FCM token. */
96
+ endpoint: (0, import_pg_core.text)("endpoint").notNull(),
97
+ p256dh: (0, import_pg_core.text)("p256dh"),
98
+ auth: (0, import_pg_core.text)("auth"),
99
+ userAgent: (0, import_pg_core.text)("user_agent"),
100
+ createdAt: timestamptz("created_at").notNull().defaultNow(),
101
+ lastUsedAt: timestamptz("last_used_at")
102
+ });
103
+ const pushSubscriptionIndexes = (t) => [
104
+ (0, import_pg_core.unique)("push_subscriptions_org_endpoint_unique").on(t.organizationId, t.endpoint),
105
+ // Delivery reads a recipient's devices.
106
+ (0, import_pg_core.index)("push_subscriptions_recipient_idx").on(t.organizationId, t.recipientType, t.recipientId)
107
+ ];
108
+ // Annotate the CommonJS export names for ESM import in node:
109
+ 0 && (module.exports = {
110
+ notificationColumns,
111
+ notificationDefaultColumns,
112
+ notificationDefaultIndexes,
113
+ notificationIndexes,
114
+ notificationPreferenceColumns,
115
+ notificationPreferenceIndexes,
116
+ pushSubscriptionColumns,
117
+ pushSubscriptionIndexes
118
+ });
@@ -33,11 +33,25 @@ export declare class IdentityRepository {
33
33
  email: string | null;
34
34
  passwordHash: string | null;
35
35
  } | null>;
36
- findMembership(userId: string): Promise<{
36
+ /**
37
+ * The person's membership of `organizationId`, or without one the organization they used
38
+ * last (switched to last), else the one they joined first. A suspended organization comes
39
+ * last: a person with another is never landed on the one they cannot use.
40
+ */
41
+ findMembership(userId: string, organizationId?: string): Promise<{
37
42
  organizationId: string;
38
43
  role: Role;
39
44
  since: Date;
40
45
  } | null>;
46
+ /** Every organization the person is a member of, the one joined first first. */
47
+ findMemberships(userId: string): Promise<{
48
+ organizationId: string;
49
+ organizationName: string;
50
+ role: Role;
51
+ since: Date;
52
+ }[]>;
53
+ /** Records that the person switched to the organization: their next sign-in lands there. */
54
+ markMembershipUsed(userId: string, organizationId: string): Promise<void>;
41
55
  getProfile(userId: string | null, organizationId: string): Promise<{
42
56
  user: {
43
57
  id: string;
@@ -61,14 +61,35 @@ class IdentityRepository {
61
61
  }).from(this.tables.users).where((0, import_drizzle_orm.eq)(this.tables.users.email, email)).limit(1);
62
62
  return row ?? null;
63
63
  }
64
- async findMembership(userId) {
64
+ /**
65
+ * The person's membership of `organizationId`, or without one the organization they used
66
+ * last (switched to last), else the one they joined first. A suspended organization comes
67
+ * last: a person with another is never landed on the one they cannot use.
68
+ */
69
+ async findMembership(userId, organizationId) {
70
+ const { memberships, organizations } = this.tables;
65
71
  const [row] = await this.systemDb.select({
66
- organizationId: this.tables.memberships.organizationId,
67
- role: this.tables.memberships.role,
68
- since: this.tables.memberships.createdAt
69
- }).from(this.tables.memberships).where((0, import_drizzle_orm.eq)(this.tables.memberships.userId, userId)).orderBy((0, import_drizzle_orm.asc)(this.tables.memberships.createdAt)).limit(1);
72
+ organizationId: memberships.organizationId,
73
+ role: memberships.role,
74
+ since: memberships.createdAt
75
+ }).from(memberships).innerJoin(organizations, (0, import_drizzle_orm.eq)(organizations.id, memberships.organizationId)).where(organizationId === void 0 ? (0, import_drizzle_orm.eq)(memberships.userId, userId) : (0, import_drizzle_orm.and)((0, import_drizzle_orm.eq)(memberships.userId, userId), (0, import_drizzle_orm.eq)(memberships.organizationId, organizationId))).orderBy(import_drizzle_orm.sql`${organizations.suspendedAt} is not null`, import_drizzle_orm.sql`${memberships.lastUsedAt} desc nulls last`, (0, import_drizzle_orm.asc)(memberships.createdAt)).limit(1);
70
76
  return row ?? null;
71
77
  }
78
+ /** Every organization the person is a member of, the one joined first first. */
79
+ async findMemberships(userId) {
80
+ const { memberships, organizations } = this.tables;
81
+ return this.systemDb.select({
82
+ organizationId: memberships.organizationId,
83
+ organizationName: organizations.name,
84
+ role: memberships.role,
85
+ since: memberships.createdAt
86
+ }).from(memberships).innerJoin(organizations, (0, import_drizzle_orm.eq)(organizations.id, memberships.organizationId)).where((0, import_drizzle_orm.eq)(memberships.userId, userId)).orderBy((0, import_drizzle_orm.asc)(memberships.createdAt), (0, import_drizzle_orm.asc)(memberships.id));
87
+ }
88
+ /** Records that the person switched to the organization: their next sign-in lands there. */
89
+ async markMembershipUsed(userId, organizationId) {
90
+ const { memberships } = this.tables;
91
+ await this.systemDb.update(memberships).set({ lastUsedAt: /* @__PURE__ */ new Date() }).where((0, import_drizzle_orm.and)((0, import_drizzle_orm.eq)(memberships.userId, userId), (0, import_drizzle_orm.eq)(memberships.organizationId, organizationId)));
92
+ }
72
93
  async getProfile(userId, organizationId) {
73
94
  const [organization] = await this.systemDb.select({ id: this.tables.organizations.id, name: this.tables.organizations.name }).from(this.tables.organizations).where((0, import_drizzle_orm.eq)(this.tables.organizations.id, organizationId)).limit(1);
74
95
  if (!organization)
package/dist/columns.d.ts CHANGED
@@ -57,6 +57,8 @@ export declare const membershipColumns: (refs: {
57
57
  userId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"user_id">>;
58
58
  organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
59
59
  role: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgEnumColumnBuilderInitial<"role", ["OWNER", "ADMIN", "MEMBER", "VIEWER"]>>;
60
+ /** When the person last switched to this organization: a sign-in lands on the latest. */
61
+ lastUsedAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"last_used_at">;
60
62
  };
61
63
  /** A person is a member of an organization once: for the table's third argument. */
62
64
  export declare const membershipIndexes: (t: {
@@ -271,6 +273,11 @@ export declare const subscriptionColumns: (refs: {
271
273
  */
272
274
  priceAmountMinor: import("drizzle-orm/pg-core").PgBigInt53BuilderInitial<"price_amount_minor">;
273
275
  priceCurrency: import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_currency", [string, ...string[]]>;
276
+ /**
277
+ * How often it is charged for, from its price: `MONTH` or `YEAR`. A yearly subscription's
278
+ * allowance is still for each month.
279
+ */
280
+ priceInterval: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_interval", [string, ...string[]]>>>;
274
281
  };
275
282
  /** One subscription per organization in each product. */
276
283
  export declare const subscriptionIndexes: (t: {
@@ -289,13 +296,16 @@ export declare const planPriceColumns: (refs: {
289
296
  /** A Stripe price ID, a Razorpay plan ID, or the name Shopify's charge is made under. */
290
297
  priceRef: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_ref", [string, ...string[]]>>;
291
298
  currency: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"currency", [string, ...string[]]>>;
292
- /** In the currency's smallest unit (cents, paise), per month. */
299
+ /** In the currency's smallest unit (cents, paise), for each interval. */
293
300
  amountMinor: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgIntegerBuilderInitial<"amount_minor">>;
301
+ /** How often it is charged: `MONTH` or `YEAR`. */
302
+ interval: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"interval", [string, ...string[]]>>>;
294
303
  };
295
304
  export declare const planPriceIndexes: (t: {
296
305
  planId: AnyPgColumn;
297
306
  provider: AnyPgColumn;
298
307
  currency: AnyPgColumn;
308
+ interval: AnyPgColumn;
299
309
  priceRef: AnyPgColumn;
300
310
  }) => import("drizzle-orm/pg-core").UniqueConstraintBuilder[];
301
311
  /** Every gateway webhook event that was applied, so a repeated delivery is not applied again. */
@@ -383,7 +393,7 @@ export declare const outboxPriorityColumn: () => import("drizzle-orm").HasDefaul
383
393
  * the tables it reads come later in the same migration.
384
394
  */
385
395
  export declare const ORGANIZATION_GOES_FIRST_SQL = "CREATE OR REPLACE FUNCTION organization_goes_first() RETURNS boolean\nLANGUAGE sql STABLE\nAS $$\n WITH org AS (\n SELECT NULLIF(current_setting('app.organization_id', true), '')::uuid AS id\n ),\n held AS (\n SELECT s.plan_id\n FROM subscriptions s\n JOIN org ON s.organization_id = org.id\n WHERE s.status = 'ACTIVE'\n AND s.product = 'app'\n AND s.period_start <= now()\n AND (now() < s.period_end OR (s.provider = 'shopify' AND s.provider_ended_at IS NULL))\n LIMIT 1\n ),\n plan AS (\n SELECT COALESCE(\n (SELECT plan_id FROM held),\n (SELECT id FROM plans WHERE is_default AND product = 'app' LIMIT 1)\n ) AS id\n )\n SELECT CASE\n WHEN (SELECT id FROM org) IS NULL THEN false\n ELSE COALESCE(\n (\n SELECT f.limit_value = 1\n FROM plan_features f\n JOIN plan ON f.plan_id = plan.id\n WHERE f.feature_key = 'PRIORITY'\n ),\n false\n )\n END\n$$;";
386
- type TableOf<N extends string, C extends Record<string, PgColumnBuilderBase>> = PgTableWithColumns<{
396
+ export type TableOf<N extends string, C extends Record<string, PgColumnBuilderBase>> = PgTableWithColumns<{
387
397
  name: N;
388
398
  schema: undefined;
389
399
  columns: BuildColumns<N, C, 'pg'>;
package/dist/columns.js CHANGED
@@ -53,6 +53,8 @@ export const membershipColumns = (refs) => ({
53
53
  .notNull()
54
54
  .references(() => refs.organizations.id, { onDelete: 'cascade' }),
55
55
  role: roleEnum('role').notNull(),
56
+ /** When the person last switched to this organization: a sign-in lands on the latest. */
57
+ lastUsedAt: timestamp('last_used_at', { withTimezone: true }),
56
58
  ...timestamps(),
57
59
  });
58
60
  /** A person is a member of an organization once: for the table's third argument. */
@@ -263,6 +265,11 @@ export const subscriptionColumns = (refs) => ({
263
265
  */
264
266
  priceAmountMinor: bigint('price_amount_minor', { mode: 'number' }),
265
267
  priceCurrency: text('price_currency'),
268
+ /**
269
+ * How often it is charged for, from its price: `MONTH` or `YEAR`. A yearly subscription's
270
+ * allowance is still for each month.
271
+ */
272
+ priceInterval: text('price_interval').notNull().default('MONTH'),
266
273
  ...timestamps(),
267
274
  });
268
275
  /** One subscription per organization in each product. */
@@ -279,12 +286,14 @@ export const planPriceColumns = (refs) => ({
279
286
  /** A Stripe price ID, a Razorpay plan ID, or the name Shopify's charge is made under. */
280
287
  priceRef: text('price_ref').notNull(),
281
288
  currency: text('currency').notNull(),
282
- /** In the currency's smallest unit (cents, paise), per month. */
289
+ /** In the currency's smallest unit (cents, paise), for each interval. */
283
290
  amountMinor: integer('amount_minor').notNull(),
291
+ /** How often it is charged: `MONTH` or `YEAR`. */
292
+ interval: text('interval').notNull().default('MONTH'),
284
293
  ...timestamps(),
285
294
  });
286
295
  export const planPriceIndexes = (t) => [
287
- unique('plan_prices_plan_provider_currency_unique').on(t.planId, t.provider, t.currency),
296
+ unique('plan_prices_plan_provider_currency_interval_unique').on(t.planId, t.provider, t.currency, t.interval),
288
297
  unique('plan_prices_provider_ref_unique').on(t.provider, t.priceRef),
289
298
  ];
290
299
  /** Every gateway webhook event that was applied, so a repeated delivery is not applied again. */
@@ -1 +1 @@
1
- {"version":3,"file":"columns.js","sourceRoot":"","sources":["../src/columns.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EACV,IAAI,EACJ,SAAS,EACT,MAAM,EACN,WAAW,EACX,IAAI,GACL,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IACjF,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAClF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;AAI9F,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,CAAC;IAChC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE;IAC3C,mFAAmF;IACnF,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;IAC7B,gFAA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EAAE,CAAC;IACnE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;IAChC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACvC,gFAAgF;IAChF,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;IAChC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;IAChC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAClF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAKrC,EAAE,EAAE,CAAC;IACJ,KAAK,CAAC,6BAA6B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;IAC7E,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAA,GAAG,CAAC,CAAC,QAAQ,MAAM,CAAC;CACpE,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE,CACvC,OAAO,CAAC,UAAU,CAAC;KAChB,OAAO,EAAE;KACT,OAAO,CAAC,GAAG,CAAA,2BAA2B,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkCvC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export { createDatabase } from './client.js';
2
2
  export type { Database, DatabaseHandle, DatabaseLogger, Tx } from './client.js';
3
3
  export { ORGANIZATION_GOES_FIRST_SQL, apiKeyColumns, auditLogColumns, auditLogIndexes, membershipColumns, membershipIndexes, organizationColumns, organizationFeatureColumns, organizationFeatureIndexes, allowanceGrantColumns, allowanceGrantIndexes, organizationOriginEnum, outboxMessageColumns, outboxMessageIndexes, outboxPriorityColumn, paymentEventColumns, paymentEventIndexes, planColumns, planFeatureColumns, planFeatureIndexes, planIndexes, planPriceColumns, planPriceIndexes, platformAdminColumns, roleEnum, shopifyInstallationColumns, subscriptionColumns, subscriptionIndexes, subscriptionStatusEnum, timestamps, usageRecordColumns, usageRecordIndexes, userColumns, webhookEventColumns, extensionKeyColumns, userIdentityColumns, disposableEmailDomainColumns, userIdentityIndexes, extensionKeyIndexes, } from './columns.js';
4
4
  export type { ApiKeysTable, ExtensionKeysTable, UserIdentitiesTable, DisposableEmailDomainsTable, AuditLogsTable, MembershipsTable, OrganizationsTable, OrganizationFeaturesTable, AllowanceGrantsTable, OutboxMessagesTable, PaymentEventsTable, PlanFeaturesTable, PlanPricesTable, PlansTable, PlatformAdminsTable, ShopifyInstallationsTable, SubscriptionsTable, UsageRecordsTable, UsersTable, WebhookEventsTable, } from './columns.js';
5
+ export { notificationColumns, notificationDefaultColumns, notificationDefaultIndexes, notificationIndexes, notificationPreferenceColumns, notificationPreferenceIndexes, pushSubscriptionColumns, pushSubscriptionIndexes, } from './notification-columns.js';
6
+ export type { NotificationDefaultsTable, NotificationPreferencesTable, NotificationsTable, PushSubscriptionsTable, } from './notification-columns.js';
5
7
  export { isUniqueViolation } from './errors.js';
6
8
  export { runMigrations, runMigrationsCli } from './migrate.js';
7
9
  export { ApiKeyRepository } from './repositories/api-key.repository.js';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { createDatabase } from './client.js';
2
2
  export { ORGANIZATION_GOES_FIRST_SQL, apiKeyColumns, auditLogColumns, auditLogIndexes, membershipColumns, membershipIndexes, organizationColumns, organizationFeatureColumns, organizationFeatureIndexes, allowanceGrantColumns, allowanceGrantIndexes, organizationOriginEnum, outboxMessageColumns, outboxMessageIndexes, outboxPriorityColumn, paymentEventColumns, paymentEventIndexes, planColumns, planFeatureColumns, planFeatureIndexes, planIndexes, planPriceColumns, planPriceIndexes, platformAdminColumns, roleEnum, shopifyInstallationColumns, subscriptionColumns, subscriptionIndexes, subscriptionStatusEnum, timestamps, usageRecordColumns, usageRecordIndexes, userColumns, webhookEventColumns, extensionKeyColumns, userIdentityColumns, disposableEmailDomainColumns, userIdentityIndexes, extensionKeyIndexes, } from './columns.js';
3
+ export { notificationColumns, notificationDefaultColumns, notificationDefaultIndexes, notificationIndexes, notificationPreferenceColumns, notificationPreferenceIndexes, pushSubscriptionColumns, pushSubscriptionIndexes, } from './notification-columns.js';
3
4
  export { isUniqueViolation } from './errors.js';
4
5
  export { runMigrations, runMigrationsCli } from './migrate.js';
5
6
  export { ApiKeyRepository } from './repositories/api-key.repository.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EACL,2BAA2B,EAC3B,aAAa,EACb,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAuBtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,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AAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAuBtB,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAEtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,106 @@
1
+ import type { AnyPgColumn } from 'drizzle-orm/pg-core';
2
+ import type { TableOf } from './columns.js';
3
+ /**
4
+ * The columns of the notification tables (@haatlabs-core/notifications). Built like the other
5
+ * shared columns: the app builds each table from these, with its own migrations.
6
+ */
7
+ type Ref = {
8
+ id: AnyPgColumn;
9
+ };
10
+ /** One inbox item for one recipient. The sent-at columns make each delivery idempotent. */
11
+ export declare const notificationColumns: (refs: {
12
+ organizations: Ref;
13
+ }) => {
14
+ id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
15
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
16
+ recipientType: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_type", [string, ...string[]]>>;
17
+ recipientId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_id", [string, ...string[]]>>;
18
+ event: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"event", [string, ...string[]]>>;
19
+ title: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"title", [string, ...string[]]>>;
20
+ body: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"body", [string, ...string[]]>>>;
21
+ /** An app-relative path. */
22
+ link: import("drizzle-orm/pg-core").PgTextBuilderInitial<"link", [string, ...string[]]>;
23
+ data: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgJsonbBuilderInitial<"data">>>;
24
+ /** Names the thing notified, so notifying it again adds no second row. */
25
+ dedupeKey: import("drizzle-orm/pg-core").PgTextBuilderInitial<"dedupe_key", [string, ...string[]]>;
26
+ readAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
27
+ liveSentAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
28
+ pushSentAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
29
+ emailSentAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
30
+ createdAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
31
+ };
32
+ /** The notifications' indexes, for the table's third argument. */
33
+ export declare const notificationIndexes: (t: {
34
+ organizationId: AnyPgColumn;
35
+ recipientType: AnyPgColumn;
36
+ recipientId: AnyPgColumn;
37
+ event: AnyPgColumn;
38
+ dedupeKey: AnyPgColumn;
39
+ createdAt: AnyPgColumn;
40
+ readAt: AnyPgColumn;
41
+ }) => import("drizzle-orm/pg-core").IndexBuilder[];
42
+ /** A person's own choice to get an event by a channel ('email' or 'push'). */
43
+ export declare const notificationPreferenceColumns: (refs: {
44
+ organizations: Ref;
45
+ }) => {
46
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
47
+ recipientType: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_type", [string, ...string[]]>>;
48
+ recipientId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_id", [string, ...string[]]>>;
49
+ event: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"event", [string, ...string[]]>>;
50
+ channel: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"channel", [string, ...string[]]>>;
51
+ enabled: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBooleanBuilderInitial<"enabled">>;
52
+ updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
53
+ };
54
+ export declare const notificationPreferenceIndexes: (t: {
55
+ organizationId: AnyPgColumn;
56
+ recipientType: AnyPgColumn;
57
+ recipientId: AnyPgColumn;
58
+ event: AnyPgColumn;
59
+ channel: AnyPgColumn;
60
+ }) => import("drizzle-orm/pg-core").PrimaryKeyBuilder[];
61
+ /** An organization's default for an audience, used when a person has made no choice. */
62
+ export declare const notificationDefaultColumns: (refs: {
63
+ organizations: Ref;
64
+ }) => {
65
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
66
+ audience: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"audience", [string, ...string[]]>>;
67
+ event: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"event", [string, ...string[]]>>;
68
+ channel: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"channel", [string, ...string[]]>>;
69
+ enabled: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBooleanBuilderInitial<"enabled">>;
70
+ updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
71
+ };
72
+ export declare const notificationDefaultIndexes: (t: {
73
+ organizationId: AnyPgColumn;
74
+ audience: AnyPgColumn;
75
+ event: AnyPgColumn;
76
+ channel: AnyPgColumn;
77
+ }) => import("drizzle-orm/pg-core").PrimaryKeyBuilder[];
78
+ /** A device that gets push: a Web Push subscription, or an FCM token. */
79
+ export declare const pushSubscriptionColumns: (refs: {
80
+ organizations: Ref;
81
+ }) => {
82
+ id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
83
+ organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
84
+ recipientType: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_type", [string, ...string[]]>>;
85
+ recipientId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"recipient_id", [string, ...string[]]>>;
86
+ /** 'webpush' or 'fcm'. */
87
+ kind: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"kind", [string, ...string[]]>>;
88
+ /** The Web Push endpoint, or the FCM token. */
89
+ endpoint: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"endpoint", [string, ...string[]]>>;
90
+ p256dh: import("drizzle-orm/pg-core").PgTextBuilderInitial<"p256dh", [string, ...string[]]>;
91
+ auth: import("drizzle-orm/pg-core").PgTextBuilderInitial<"auth", [string, ...string[]]>;
92
+ userAgent: import("drizzle-orm/pg-core").PgTextBuilderInitial<"user_agent", [string, ...string[]]>;
93
+ createdAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>>>;
94
+ lastUsedAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<string>;
95
+ };
96
+ export declare const pushSubscriptionIndexes: (t: {
97
+ organizationId: AnyPgColumn;
98
+ recipientType: AnyPgColumn;
99
+ recipientId: AnyPgColumn;
100
+ endpoint: AnyPgColumn;
101
+ }) => (import("drizzle-orm/pg-core").UniqueConstraintBuilder | import("drizzle-orm/pg-core").IndexBuilder)[];
102
+ export type NotificationsTable = TableOf<'notifications', ReturnType<typeof notificationColumns>>;
103
+ export type NotificationPreferencesTable = TableOf<'notification_preferences', ReturnType<typeof notificationPreferenceColumns>>;
104
+ export type NotificationDefaultsTable = TableOf<'notification_defaults', ReturnType<typeof notificationDefaultColumns>>;
105
+ export type PushSubscriptionsTable = TableOf<'push_subscriptions', ReturnType<typeof pushSubscriptionColumns>>;
106
+ export {};
@@ -0,0 +1,90 @@
1
+ import { sql } from 'drizzle-orm';
2
+ import { boolean, index, jsonb, primaryKey, text, timestamp, unique, uniqueIndex, uuid, } from 'drizzle-orm/pg-core';
3
+ const organizationId = (refs) => uuid('organization_id')
4
+ .notNull()
5
+ .references(() => refs.organizations.id, { onDelete: 'cascade' });
6
+ const timestamptz = (name) => timestamp(name, { withTimezone: true });
7
+ /** One inbox item for one recipient. The sent-at columns make each delivery idempotent. */
8
+ export const notificationColumns = (refs) => ({
9
+ id: uuid('id').primaryKey().defaultRandom(),
10
+ organizationId: organizationId(refs),
11
+ recipientType: text('recipient_type').notNull(),
12
+ recipientId: text('recipient_id').notNull(),
13
+ event: text('event').notNull(),
14
+ title: text('title').notNull(),
15
+ body: text('body').notNull().default(''),
16
+ /** An app-relative path. */
17
+ link: text('link'),
18
+ data: jsonb('data').notNull().default({}),
19
+ /** Names the thing notified, so notifying it again adds no second row. */
20
+ dedupeKey: text('dedupe_key'),
21
+ readAt: timestamptz('read_at'),
22
+ liveSentAt: timestamptz('live_sent_at'),
23
+ pushSentAt: timestamptz('push_sent_at'),
24
+ emailSentAt: timestamptz('email_sent_at'),
25
+ createdAt: timestamptz('created_at').notNull().defaultNow(),
26
+ });
27
+ /** The notifications' indexes, for the table's third argument. */
28
+ export const notificationIndexes = (t) => [
29
+ index('notifications_recipient_created_idx').on(t.organizationId, t.recipientType, t.recipientId, t.createdAt),
30
+ index('notifications_unread_idx')
31
+ .on(t.organizationId, t.recipientType, t.recipientId)
32
+ .where(sql `${t.readAt} is null`),
33
+ uniqueIndex('notifications_dedupe_uq')
34
+ .on(t.organizationId, t.recipientType, t.recipientId, t.event, t.dedupeKey)
35
+ .where(sql `${t.dedupeKey} is not null`),
36
+ ];
37
+ /** A person's own choice to get an event by a channel ('email' or 'push'). */
38
+ export const notificationPreferenceColumns = (refs) => ({
39
+ organizationId: organizationId(refs),
40
+ recipientType: text('recipient_type').notNull(),
41
+ recipientId: text('recipient_id').notNull(),
42
+ event: text('event').notNull(),
43
+ channel: text('channel').notNull(),
44
+ enabled: boolean('enabled').notNull(),
45
+ updatedAt: timestamptz('updated_at').notNull().defaultNow(),
46
+ });
47
+ export const notificationPreferenceIndexes = (t) => [
48
+ // Named: drizzle's own name is 85 characters, and Postgres cuts names at 63.
49
+ primaryKey({
50
+ name: 'notification_preferences_pkey',
51
+ columns: [t.organizationId, t.recipientType, t.recipientId, t.event, t.channel],
52
+ }),
53
+ ];
54
+ /** An organization's default for an audience, used when a person has made no choice. */
55
+ export const notificationDefaultColumns = (refs) => ({
56
+ organizationId: organizationId(refs),
57
+ audience: text('audience').notNull(),
58
+ event: text('event').notNull(),
59
+ channel: text('channel').notNull(),
60
+ enabled: boolean('enabled').notNull(),
61
+ updatedAt: timestamptz('updated_at').notNull().defaultNow(),
62
+ });
63
+ export const notificationDefaultIndexes = (t) => [
64
+ primaryKey({
65
+ name: 'notification_defaults_pkey',
66
+ columns: [t.organizationId, t.audience, t.event, t.channel],
67
+ }),
68
+ ];
69
+ /** A device that gets push: a Web Push subscription, or an FCM token. */
70
+ export const pushSubscriptionColumns = (refs) => ({
71
+ id: uuid('id').primaryKey().defaultRandom(),
72
+ organizationId: organizationId(refs),
73
+ recipientType: text('recipient_type').notNull(),
74
+ recipientId: text('recipient_id').notNull(),
75
+ /** 'webpush' or 'fcm'. */
76
+ kind: text('kind').notNull(),
77
+ /** The Web Push endpoint, or the FCM token. */
78
+ endpoint: text('endpoint').notNull(),
79
+ p256dh: text('p256dh'),
80
+ auth: text('auth'),
81
+ userAgent: text('user_agent'),
82
+ createdAt: timestamptz('created_at').notNull().defaultNow(),
83
+ lastUsedAt: timestamptz('last_used_at'),
84
+ });
85
+ export const pushSubscriptionIndexes = (t) => [
86
+ unique('push_subscriptions_org_endpoint_unique').on(t.organizationId, t.endpoint),
87
+ // Delivery reads a recipient's devices.
88
+ index('push_subscriptions_recipient_idx').on(t.organizationId, t.recipientType, t.recipientId),
89
+ ];
90
+ //# sourceMappingURL=notification-columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-columns.js","sourceRoot":"","sources":["../src/notification-columns.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,UAAU,EACV,IAAI,EACJ,SAAS,EACT,MAAM,EACN,WAAW,EACX,IAAI,GACL,MAAM,qBAAqB,CAAC;AAU7B,MAAM,cAAc,GAAG,CAAC,IAA4B,EAAE,EAAE,CACtD,IAAI,CAAC,iBAAiB,CAAC;KACpB,OAAO,EAAE;KACT,UAAU,CAAC,GAAG,EAAE,CAAC,I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AI,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE;IAC/C,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE;IAC3C,0BAA0B;IAC1B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,+CAA+C;IAC/C,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACpC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;IAC7B,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IAC3D,UAAU,EAAE,WAAW,CAAC,cAAc,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAKvC,EAAE,EAAE,CAAC;IACJ,MAAM,CAAC,wCAAwC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC;IACjF,wCAAwC;IACxC,KAAK,CAAC,kCAAkC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,WAAW,CAAC;CAC/F,CAAC"}
@@ -33,11 +33,25 @@ export declare class IdentityRepository {
33
33
  email: string | null;
34
34
  passwordHash: string | null;
35
35
  } | null>;
36
- findMembership(userId: string): Promise<{
36
+ /**
37
+ * The person's membership of `organizationId`, or without one the organization they used
38
+ * last (switched to last), else the one they joined first. A suspended organization comes
39
+ * last: a person with another is never landed on the one they cannot use.
40
+ */
41
+ findMembership(userId: string, organizationId?: string): Promise<{
37
42
  organizationId: string;
38
43
  role: Role;
39
44
  since: Date;
40
45
  } | null>;
46
+ /** Every organization the person is a member of, the one joined first first. */
47
+ findMemberships(userId: string): Promise<{
48
+ organizationId: string;
49
+ organizationName: string;
50
+ role: Role;
51
+ since: Date;
52
+ }[]>;
53
+ /** Records that the person switched to the organization: their next sign-in lands there. */
54
+ markMembershipUsed(userId: string, organizationId: string): Promise<void>;
41
55
  getProfile(userId: string | null, organizationId: string): Promise<{
42
56
  user: {
43
57
  id: string;
@@ -1,5 +1,5 @@
1
1
  import { AppError } from '@haatlabs-core/errors';
2
- import { and, asc, eq, isNull } from 'drizzle-orm';
2
+ import { and, asc, eq, isNull, sql } from 'drizzle-orm';
3
3
  import { isUniqueViolation } from '../errors.js';
4
4
  import { createAuditWriter } from '../writers.js';
5
5
  /** Identity lookups happen before a tenant is known, so this uses the system connection. */
@@ -53,19 +53,51 @@ export class IdentityRepository {
53
53
  .limit(1);
54
54
  return row ?? null;
55
55
  }
56
- async findMembership(userId) {
56
+ /**
57
+ * The person's membership of `organizationId`, or without one the organization they used
58
+ * last (switched to last), else the one they joined first. A suspended organization comes
59
+ * last: a person with another is never landed on the one they cannot use.
60
+ */
61
+ async findMembership(userId, organizationId) {
62
+ const { memberships, organizations } = this.tables;
57
63
  const [row] = await this.systemDb
58
64
  .select({
59
- organizationId: this.tables.memberships.organizationId,
60
- role: this.tables.memberships.role,
61
- since: this.tables.memberships.createdAt,
65
+ organizationId: memberships.organizationId,
66
+ role: memberships.role,
67
+ since: memberships.createdAt,
62
68
  })
63
- .from(this.tables.memberships)
64
- .where(eq(this.tables.memberships.userId, userId))
65
- .orderBy(asc(this.tables.memberships.createdAt))
69
+ .from(memberships)
70
+ .innerJoin(organizations, eq(organizations.id, memberships.organizationId))
71
+ .where(organizationId === undefined
72
+ ? eq(memberships.userId, userId)
73
+ : and(eq(memberships.userId, userId), eq(memberships.organizationId, organizationId)))
74
+ .orderBy(sql `${organizations.suspendedAt} is not null`, sql `${memberships.lastUsedAt} desc nulls last`, asc(memberships.createdAt))
66
75
  .limit(1);
67
76
  return row ?? null;
68
77
  }
78
+ /** Every organization the person is a member of, the one joined first first. */
79
+ async findMemberships(userId) {
80
+ const { memberships, organizations } = this.tables;
81
+ return this.systemDb
82
+ .select({
83
+ organizationId: memberships.organizationId,
84
+ organizationName: organizations.name,
85
+ role: memberships.role,
86
+ since: memberships.createdAt,
87
+ })
88
+ .from(memberships)
89
+ .innerJoin(organizations, eq(organizations.id, memberships.organizationId))
90
+ .where(eq(memberships.userId, userId))
91
+ .orderBy(asc(memberships.createdAt), asc(memberships.id));
92
+ }
93
+ /** Records that the person switched to the organization: their next sign-in lands there. */
94
+ async markMembershipUsed(userId, organizationId) {
95
+ const { memberships } = this.tables;
96
+ await this.systemDb
97
+ .update(memberships)
98
+ .set({ lastUsedAt: new Date() })
99
+ .where(and(eq(memberships.userId, userId), eq(memberships.organizationId, organizationId)));
100
+ }
69
101
  async getProfile(userId, organizationId) {
70
102
  const [organization] = await this.systemDb
71
103
  .select({ id: this.tables.organizations.id, name: this.tables.organizations.name })
@@ -1 +1 @@
1
- {"version":3,"file":"identity.repository.js","sourceRoot":"","sources":["../../src/repositories/identity.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKlD,4FAA4F;AAC5F,MAAM,OAAO,kBAAkB;IAIR;IACA;IAJJ,WAAW,CAAc;IAE1C,YACqB,QAAkB,EAClB,MAKlB;QANkB,aAAQ,GAAR,QAAQ,CAAU;QAClB,WAAM,GAAN,MAAM,CAKxB;QAED,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,0BAA0B,CAAC,KAGhC;QACC,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,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AAE,UAAU,CAAC,MAAM;iBAC5B,CAAC,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,iBAAiB,CAAC,KAAK,CAAC;gBAC1B,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,2CAA2C,CAAC,CAAC;YAC9E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haatlabs-core/db-core",
3
- "version": "0.19.0",
3
+ "version": "0.22.0",
4
4
  "description": "PostgreSQL and drizzle building blocks: shared columns, organizations, row-level security, audit logs.",
5
5
  "keywords": [
6
6
  "haatlabs",
@@ -55,13 +55,13 @@
55
55
  "drizzle-orm": "^0.45.3",
56
56
  "pg": "^8.23.1",
57
57
  "testcontainers": "^12.2.0",
58
- "@haatlabs-core/tsconfig": "0.19.0",
59
- "@haatlabs-core/vitest-config": "0.19.0"
58
+ "@haatlabs-core/tsconfig": "0.22.0",
59
+ "@haatlabs-core/vitest-config": "0.22.0"
60
60
  },
61
61
  "dependencies": {
62
- "@haatlabs-core/errors": "0.19.0",
63
- "@haatlabs-core/observability": "0.19.0",
64
- "@haatlabs-core/queue": "0.19.0"
62
+ "@haatlabs-core/errors": "0.22.0",
63
+ "@haatlabs-core/queue": "0.22.0",
64
+ "@haatlabs-core/observability": "0.22.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "drizzle-orm": "^0.45.3",