@haatlabs-core/db-core 0.15.1 → 0.17.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/cjs/columns.d.ts +44 -2
- package/dist/cjs/columns.js +37 -3
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/repositories/disposable-email.repository.d.ts +18 -0
- package/dist/cjs/repositories/disposable-email.repository.js +60 -0
- package/dist/cjs/repositories/user-identity.repository.d.ts +30 -0
- package/dist/cjs/repositories/user-identity.repository.js +69 -0
- package/dist/columns.d.ts +44 -2
- package/dist/columns.js +41 -5
- package/dist/columns.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/repositories/disposable-email.repository.d.ts +18 -0
- package/dist/repositories/disposable-email.repository.js +45 -0
- package/dist/repositories/disposable-email.repository.js.map +1 -0
- package/dist/repositories/user-identity.repository.d.ts +30 -0
- package/dist/repositories/user-identity.repository.js +56 -0
- package/dist/repositories/user-identity.repository.js.map +1 -0
- package/package.json +6 -6
package/dist/cjs/columns.d.ts
CHANGED
|
@@ -101,6 +101,33 @@ export declare const extensionKeyIndexes: (t: {
|
|
|
101
101
|
organizationId: AnyPgColumn;
|
|
102
102
|
userId: AnyPgColumn;
|
|
103
103
|
}) => import("drizzle-orm/pg-core").IndexBuilder[];
|
|
104
|
+
/**
|
|
105
|
+
* A sign-in provider's account (Google, GitHub) that signs in as a user. Only which provider
|
|
106
|
+
* and its stable ID are kept, and the email it vouched for when linked: never its tokens.
|
|
107
|
+
*/
|
|
108
|
+
export declare const userIdentityColumns: (refs: {
|
|
109
|
+
users: Ref;
|
|
110
|
+
}) => {
|
|
111
|
+
createdAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"created_at">>>;
|
|
112
|
+
updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"updated_at">>>;
|
|
113
|
+
id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
|
|
114
|
+
userId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"user_id">>;
|
|
115
|
+
provider: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"provider", [string, ...string[]]>>;
|
|
116
|
+
providerUserId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"provider_user_id", [string, ...string[]]>>;
|
|
117
|
+
emailAtLink: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"email_at_link", [string, ...string[]]>>;
|
|
118
|
+
};
|
|
119
|
+
export declare const userIdentityIndexes: (t: {
|
|
120
|
+
provider: AnyPgColumn;
|
|
121
|
+
providerUserId: AnyPgColumn;
|
|
122
|
+
userId: AnyPgColumn;
|
|
123
|
+
}) => (import("drizzle-orm/pg-core").UniqueConstraintBuilder | import("drizzle-orm/pg-core").IndexBuilder)[];
|
|
124
|
+
/**
|
|
125
|
+
* Domains of throwaway mailbox providers: an account is not created for an address on one (or
|
|
126
|
+
* on a subdomain of one). The community list, replaced whole by a daily refresh.
|
|
127
|
+
*/
|
|
128
|
+
export declare const disposableEmailDomainColumns: () => {
|
|
129
|
+
domain: import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"domain", [string, ...string[]]>>>;
|
|
130
|
+
};
|
|
104
131
|
export declare const webhookEventColumns: (refs: {
|
|
105
132
|
organizations: Ref;
|
|
106
133
|
stores: Ref;
|
|
@@ -185,13 +212,19 @@ export declare const planColumns: () => {
|
|
|
185
212
|
id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
|
|
186
213
|
code: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"code", [string, ...string[]]>>;
|
|
187
214
|
name: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"name", [string, ...string[]]>>;
|
|
215
|
+
/**
|
|
216
|
+
* What the plan is for, when an app sells more than one thing (haatlabs-api's console: one
|
|
217
|
+
* plan per product). Every app with one thing to sell keeps `'app'`.
|
|
218
|
+
*/
|
|
219
|
+
product: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"product", [string, ...string[]]>>>;
|
|
188
220
|
/** The plan of an organization that has no current subscription. */
|
|
189
221
|
isDefault: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBooleanBuilderInitial<"is_default">>>;
|
|
190
222
|
position: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgIntegerBuilderInitial<"position">>;
|
|
191
223
|
};
|
|
192
|
-
/** Only one plan is the default. */
|
|
224
|
+
/** Only one plan is the default in each product. */
|
|
193
225
|
export declare const planIndexes: (t: {
|
|
194
226
|
isDefault: AnyPgColumn;
|
|
227
|
+
product: AnyPgColumn;
|
|
195
228
|
}) => import("drizzle-orm/pg-core").IndexBuilder[];
|
|
196
229
|
export declare const planFeatureColumns: (refs: {
|
|
197
230
|
plans: Ref;
|
|
@@ -218,6 +251,8 @@ export declare const subscriptionColumns: (refs: {
|
|
|
218
251
|
id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
|
|
219
252
|
organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
|
|
220
253
|
planId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"plan_id">>;
|
|
254
|
+
/** Its plan's product: an organization holds at most one subscription in each. */
|
|
255
|
+
product: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"product", [string, ...string[]]>>>;
|
|
221
256
|
status: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgEnumColumnBuilderInitial<"status", ["ACTIVE", "CANCELLED"]>>>;
|
|
222
257
|
periodStart: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"period_start">>;
|
|
223
258
|
periodEnd: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"period_end">>;
|
|
@@ -237,6 +272,11 @@ export declare const subscriptionColumns: (refs: {
|
|
|
237
272
|
priceAmountMinor: import("drizzle-orm/pg-core").PgBigInt53BuilderInitial<"price_amount_minor">;
|
|
238
273
|
priceCurrency: import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_currency", [string, ...string[]]>;
|
|
239
274
|
};
|
|
275
|
+
/** One subscription per organization in each product. */
|
|
276
|
+
export declare const subscriptionIndexes: (t: {
|
|
277
|
+
organizationId: AnyPgColumn;
|
|
278
|
+
product: AnyPgColumn;
|
|
279
|
+
}) => import("drizzle-orm/pg-core").UniqueConstraintBuilder[];
|
|
240
280
|
/** What a plan costs through each gateway, per currency, and the gateway's own ID for it. */
|
|
241
281
|
export declare const planPriceColumns: (refs: {
|
|
242
282
|
plans: Ref;
|
|
@@ -342,7 +382,7 @@ export declare const outboxPriorityColumn: () => import("drizzle-orm").HasDefaul
|
|
|
342
382
|
* app's migration, before the outbox table; run with `check_function_bodies = false` when
|
|
343
383
|
* the tables it reads come later in the same migration.
|
|
344
384
|
*/
|
|
345
|
-
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.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 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$$;";
|
|
385
|
+
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$$;";
|
|
346
386
|
type TableOf<N extends string, C extends Record<string, PgColumnBuilderBase>> = PgTableWithColumns<{
|
|
347
387
|
name: N;
|
|
348
388
|
schema: undefined;
|
|
@@ -353,6 +393,8 @@ export type UsersTable = TableOf<'users', ReturnType<typeof userColumns>>;
|
|
|
353
393
|
export type OrganizationsTable = TableOf<'organizations', ReturnType<typeof organizationColumns>>;
|
|
354
394
|
export type MembershipsTable = TableOf<'memberships', ReturnType<typeof membershipColumns>>;
|
|
355
395
|
export type ApiKeysTable = TableOf<'api_keys', ReturnType<typeof apiKeyColumns>>;
|
|
396
|
+
export type DisposableEmailDomainsTable = TableOf<'disposable_email_domains', ReturnType<typeof disposableEmailDomainColumns>>;
|
|
397
|
+
export type UserIdentitiesTable = TableOf<'user_identities', ReturnType<typeof userIdentityColumns>>;
|
|
356
398
|
export type ExtensionKeysTable = TableOf<'extension_keys', ReturnType<typeof extensionKeyColumns>>;
|
|
357
399
|
export type WebhookEventsTable = TableOf<'webhook_events', ReturnType<typeof webhookEventColumns>>;
|
|
358
400
|
export type OutboxMessagesTable = TableOf<'outbox_messages', ReturnType<typeof outboxMessageColumns>>;
|
package/dist/cjs/columns.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(columns_exports, {
|
|
|
23
23
|
apiKeyColumns: () => apiKeyColumns,
|
|
24
24
|
auditLogColumns: () => auditLogColumns,
|
|
25
25
|
auditLogIndexes: () => auditLogIndexes,
|
|
26
|
+
disposableEmailDomainColumns: () => disposableEmailDomainColumns,
|
|
26
27
|
extensionKeyColumns: () => extensionKeyColumns,
|
|
27
28
|
extensionKeyIndexes: () => extensionKeyIndexes,
|
|
28
29
|
membershipColumns: () => membershipColumns,
|
|
@@ -46,11 +47,14 @@ __export(columns_exports, {
|
|
|
46
47
|
roleEnum: () => roleEnum,
|
|
47
48
|
shopifyInstallationColumns: () => shopifyInstallationColumns,
|
|
48
49
|
subscriptionColumns: () => subscriptionColumns,
|
|
50
|
+
subscriptionIndexes: () => subscriptionIndexes,
|
|
49
51
|
subscriptionStatusEnum: () => subscriptionStatusEnum,
|
|
50
52
|
timestamps: () => timestamps,
|
|
51
53
|
usageRecordColumns: () => usageRecordColumns,
|
|
52
54
|
usageRecordIndexes: () => usageRecordIndexes,
|
|
53
55
|
userColumns: () => userColumns,
|
|
56
|
+
userIdentityColumns: () => userIdentityColumns,
|
|
57
|
+
userIdentityIndexes: () => userIdentityIndexes,
|
|
54
58
|
webhookEventColumns: () => webhookEventColumns
|
|
55
59
|
});
|
|
56
60
|
module.exports = __toCommonJS(columns_exports);
|
|
@@ -122,6 +126,21 @@ const extensionKeyColumns = (refs) => ({
|
|
|
122
126
|
const extensionKeyIndexes = (t) => [
|
|
123
127
|
(0, import_pg_core.index)("extension_keys_org_user_idx").on(t.organizationId, t.userId)
|
|
124
128
|
];
|
|
129
|
+
const userIdentityColumns = (refs) => ({
|
|
130
|
+
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
131
|
+
userId: (0, import_pg_core.uuid)("user_id").notNull().references(() => refs.users.id, { onDelete: "cascade" }),
|
|
132
|
+
provider: (0, import_pg_core.text)("provider").notNull(),
|
|
133
|
+
providerUserId: (0, import_pg_core.text)("provider_user_id").notNull(),
|
|
134
|
+
emailAtLink: (0, import_pg_core.text)("email_at_link").notNull(),
|
|
135
|
+
...timestamps()
|
|
136
|
+
});
|
|
137
|
+
const userIdentityIndexes = (t) => [
|
|
138
|
+
(0, import_pg_core.unique)("user_identities_provider_user_unique").on(t.provider, t.providerUserId),
|
|
139
|
+
(0, import_pg_core.index)("user_identities_user_idx").on(t.userId)
|
|
140
|
+
];
|
|
141
|
+
const disposableEmailDomainColumns = () => ({
|
|
142
|
+
domain: (0, import_pg_core.text)("domain").primaryKey()
|
|
143
|
+
});
|
|
125
144
|
const webhookEventColumns = (refs) => ({
|
|
126
145
|
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
127
146
|
organizationId: (0, import_pg_core.uuid)("organization_id").notNull().references(() => refs.organizations.id, { onDelete: "cascade" }),
|
|
@@ -188,13 +207,18 @@ const planColumns = () => ({
|
|
|
188
207
|
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
189
208
|
code: (0, import_pg_core.text)("code").notNull().unique(),
|
|
190
209
|
name: (0, import_pg_core.text)("name").notNull(),
|
|
210
|
+
/**
|
|
211
|
+
* What the plan is for, when an app sells more than one thing (haatlabs-api's console: one
|
|
212
|
+
* plan per product). Every app with one thing to sell keeps `'app'`.
|
|
213
|
+
*/
|
|
214
|
+
product: (0, import_pg_core.text)("product").notNull().default("app"),
|
|
191
215
|
/** The plan of an organization that has no current subscription. */
|
|
192
216
|
isDefault: (0, import_pg_core.boolean)("is_default").notNull().default(false),
|
|
193
217
|
position: (0, import_pg_core.integer)("position").notNull(),
|
|
194
218
|
...timestamps()
|
|
195
219
|
});
|
|
196
220
|
const planIndexes = (t) => [
|
|
197
|
-
(0, import_pg_core.uniqueIndex)("plans_one_default_idx").on(t.
|
|
221
|
+
(0, import_pg_core.uniqueIndex)("plans_one_default_idx").on(t.product).where(import_drizzle_orm.sql`${t.isDefault}`)
|
|
198
222
|
];
|
|
199
223
|
const planFeatureColumns = (refs) => ({
|
|
200
224
|
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
@@ -210,8 +234,10 @@ const planFeatureIndexes = (t) => [
|
|
|
210
234
|
];
|
|
211
235
|
const subscriptionColumns = (refs) => ({
|
|
212
236
|
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
213
|
-
organizationId: (0, import_pg_core.uuid)("organization_id").notNull().
|
|
237
|
+
organizationId: (0, import_pg_core.uuid)("organization_id").notNull().references(() => refs.organizations.id, { onDelete: "cascade" }),
|
|
214
238
|
planId: (0, import_pg_core.uuid)("plan_id").notNull().references(() => refs.plans.id),
|
|
239
|
+
/** Its plan's product: an organization holds at most one subscription in each. */
|
|
240
|
+
product: (0, import_pg_core.text)("product").notNull().default("app"),
|
|
215
241
|
status: subscriptionStatusEnum("status").notNull().default("ACTIVE"),
|
|
216
242
|
periodStart: (0, import_pg_core.timestamp)("period_start", { withTimezone: true }).notNull(),
|
|
217
243
|
periodEnd: (0, import_pg_core.timestamp)("period_end", { withTimezone: true }).notNull(),
|
|
@@ -232,6 +258,9 @@ const subscriptionColumns = (refs) => ({
|
|
|
232
258
|
priceCurrency: (0, import_pg_core.text)("price_currency"),
|
|
233
259
|
...timestamps()
|
|
234
260
|
});
|
|
261
|
+
const subscriptionIndexes = (t) => [
|
|
262
|
+
(0, import_pg_core.unique)("subscriptions_org_product_unique").on(t.organizationId, t.product)
|
|
263
|
+
];
|
|
235
264
|
const planPriceColumns = (refs) => ({
|
|
236
265
|
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
237
266
|
planId: (0, import_pg_core.uuid)("plan_id").notNull().references(() => refs.plans.id, { onDelete: "cascade" }),
|
|
@@ -306,6 +335,7 @@ AS $$
|
|
|
306
335
|
FROM subscriptions s
|
|
307
336
|
JOIN org ON s.organization_id = org.id
|
|
308
337
|
WHERE s.status = 'ACTIVE'
|
|
338
|
+
AND s.product = 'app'
|
|
309
339
|
AND s.period_start <= now()
|
|
310
340
|
AND (now() < s.period_end OR (s.provider = 'shopify' AND s.provider_ended_at IS NULL))
|
|
311
341
|
LIMIT 1
|
|
@@ -313,7 +343,7 @@ AS $$
|
|
|
313
343
|
plan AS (
|
|
314
344
|
SELECT COALESCE(
|
|
315
345
|
(SELECT plan_id FROM held),
|
|
316
|
-
(SELECT id FROM plans WHERE is_default LIMIT 1)
|
|
346
|
+
(SELECT id FROM plans WHERE is_default AND product = 'app' LIMIT 1)
|
|
317
347
|
) AS id
|
|
318
348
|
)
|
|
319
349
|
SELECT CASE
|
|
@@ -337,6 +367,7 @@ $$;`;
|
|
|
337
367
|
apiKeyColumns,
|
|
338
368
|
auditLogColumns,
|
|
339
369
|
auditLogIndexes,
|
|
370
|
+
disposableEmailDomainColumns,
|
|
340
371
|
extensionKeyColumns,
|
|
341
372
|
extensionKeyIndexes,
|
|
342
373
|
membershipColumns,
|
|
@@ -360,10 +391,13 @@ $$;`;
|
|
|
360
391
|
roleEnum,
|
|
361
392
|
shopifyInstallationColumns,
|
|
362
393
|
subscriptionColumns,
|
|
394
|
+
subscriptionIndexes,
|
|
363
395
|
subscriptionStatusEnum,
|
|
364
396
|
timestamps,
|
|
365
397
|
usageRecordColumns,
|
|
366
398
|
usageRecordIndexes,
|
|
367
399
|
userColumns,
|
|
400
|
+
userIdentityColumns,
|
|
401
|
+
userIdentityIndexes,
|
|
368
402
|
webhookEventColumns
|
|
369
403
|
});
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDatabase } from './client.js';
|
|
2
2
|
export type { Database, DatabaseHandle, DatabaseLogger, Tx } from './client.js';
|
|
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, subscriptionStatusEnum, timestamps, usageRecordColumns, usageRecordIndexes, userColumns, webhookEventColumns, extensionKeyColumns, extensionKeyIndexes, } from './columns.js';
|
|
4
|
-
export type { ApiKeysTable, ExtensionKeysTable, AuditLogsTable, MembershipsTable, OrganizationsTable, OrganizationFeaturesTable, AllowanceGrantsTable, OutboxMessagesTable, PaymentEventsTable, PlanFeaturesTable, PlanPricesTable, PlansTable, PlatformAdminsTable, ShopifyInstallationsTable, SubscriptionsTable, UsageRecordsTable, UsersTable, WebhookEventsTable, } from './columns.js';
|
|
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
|
+
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
5
|
export { isUniqueViolation } from './errors.js';
|
|
6
6
|
export { runMigrations, runMigrationsCli } from './migrate.js';
|
|
7
7
|
export { ApiKeyRepository } from './repositories/api-key.repository.js';
|
|
@@ -9,6 +9,8 @@ export type { ApiKeyRow } from './repositories/api-key.repository.js';
|
|
|
9
9
|
export { ExtensionKeyRepository } from './repositories/extension-key.repository.js';
|
|
10
10
|
export type { ExtensionKeyRow } from './repositories/extension-key.repository.js';
|
|
11
11
|
export { IdentityRepository } from './repositories/identity.repository.js';
|
|
12
|
+
export { UserIdentityRepository } from './repositories/user-identity.repository.js';
|
|
13
|
+
export { DisposableEmailRepository } from './repositories/disposable-email.repository.js';
|
|
12
14
|
export type { Role } from './repositories/identity.repository.js';
|
|
13
15
|
export { OutboxRepository } from './repositories/outbox.repository.js';
|
|
14
16
|
export type { OutboxMessage } from './repositories/outbox.repository.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var index_exports = {};
|
|
19
19
|
__export(index_exports, {
|
|
20
20
|
ApiKeyRepository: () => import_api_key_repository.ApiKeyRepository,
|
|
21
|
+
DisposableEmailRepository: () => import_disposable_email_repository.DisposableEmailRepository,
|
|
21
22
|
ExtensionKeyRepository: () => import_extension_key_repository.ExtensionKeyRepository,
|
|
22
23
|
IdentityRepository: () => import_identity_repository.IdentityRepository,
|
|
23
24
|
ORGANIZATION_GOES_FIRST_SQL: () => import_columns.ORGANIZATION_GOES_FIRST_SQL,
|
|
@@ -25,6 +26,7 @@ __export(index_exports, {
|
|
|
25
26
|
OutboxRepository: () => import_outbox_repository.OutboxRepository,
|
|
26
27
|
PlatformAdminRepository: () => import_platform_admin_repository.PlatformAdminRepository,
|
|
27
28
|
TENANT_SETTING: () => import_tenant.TENANT_SETTING,
|
|
29
|
+
UserIdentityRepository: () => import_user_identity_repository.UserIdentityRepository,
|
|
28
30
|
WebhookEventRepository: () => import_webhook_event_repository.WebhookEventRepository,
|
|
29
31
|
allowanceGrantColumns: () => import_columns.allowanceGrantColumns,
|
|
30
32
|
allowanceGrantIndexes: () => import_columns.allowanceGrantIndexes,
|
|
@@ -34,6 +36,7 @@ __export(index_exports, {
|
|
|
34
36
|
createAuditWriter: () => import_writers.createAuditWriter,
|
|
35
37
|
createDatabase: () => import_client.createDatabase,
|
|
36
38
|
createOutboxWriter: () => import_writers.createOutboxWriter,
|
|
39
|
+
disposableEmailDomainColumns: () => import_columns.disposableEmailDomainColumns,
|
|
37
40
|
extensionKeyColumns: () => import_columns.extensionKeyColumns,
|
|
38
41
|
extensionKeyIndexes: () => import_columns.extensionKeyIndexes,
|
|
39
42
|
isUniqueViolation: () => import_errors.isUniqueViolation,
|
|
@@ -60,11 +63,14 @@ __export(index_exports, {
|
|
|
60
63
|
runMigrationsCli: () => import_migrate.runMigrationsCli,
|
|
61
64
|
shopifyInstallationColumns: () => import_columns.shopifyInstallationColumns,
|
|
62
65
|
subscriptionColumns: () => import_columns.subscriptionColumns,
|
|
66
|
+
subscriptionIndexes: () => import_columns.subscriptionIndexes,
|
|
63
67
|
subscriptionStatusEnum: () => import_columns.subscriptionStatusEnum,
|
|
64
68
|
timestamps: () => import_columns.timestamps,
|
|
65
69
|
usageRecordColumns: () => import_columns.usageRecordColumns,
|
|
66
70
|
usageRecordIndexes: () => import_columns.usageRecordIndexes,
|
|
67
71
|
userColumns: () => import_columns.userColumns,
|
|
72
|
+
userIdentityColumns: () => import_columns.userIdentityColumns,
|
|
73
|
+
userIdentityIndexes: () => import_columns.userIdentityIndexes,
|
|
68
74
|
webhookEventColumns: () => import_columns.webhookEventColumns,
|
|
69
75
|
withTenant: () => import_tenant.withTenant
|
|
70
76
|
});
|
|
@@ -76,6 +82,8 @@ var import_migrate = require("./migrate.js");
|
|
|
76
82
|
var import_api_key_repository = require("./repositories/api-key.repository.js");
|
|
77
83
|
var import_extension_key_repository = require("./repositories/extension-key.repository.js");
|
|
78
84
|
var import_identity_repository = require("./repositories/identity.repository.js");
|
|
85
|
+
var import_user_identity_repository = require("./repositories/user-identity.repository.js");
|
|
86
|
+
var import_disposable_email_repository = require("./repositories/disposable-email.repository.js");
|
|
79
87
|
var import_outbox_repository = require("./repositories/outbox.repository.js");
|
|
80
88
|
var import_platform_admin_repository = require("./repositories/platform-admin.repository.js");
|
|
81
89
|
var import_webhook_event_repository = require("./repositories/webhook-event.repository.js");
|
|
@@ -84,6 +92,7 @@ var import_writers = require("./writers.js");
|
|
|
84
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
85
93
|
0 && (module.exports = {
|
|
86
94
|
ApiKeyRepository,
|
|
95
|
+
DisposableEmailRepository,
|
|
87
96
|
ExtensionKeyRepository,
|
|
88
97
|
IdentityRepository,
|
|
89
98
|
ORGANIZATION_GOES_FIRST_SQL,
|
|
@@ -91,6 +100,7 @@ var import_writers = require("./writers.js");
|
|
|
91
100
|
OutboxRepository,
|
|
92
101
|
PlatformAdminRepository,
|
|
93
102
|
TENANT_SETTING,
|
|
103
|
+
UserIdentityRepository,
|
|
94
104
|
WebhookEventRepository,
|
|
95
105
|
allowanceGrantColumns,
|
|
96
106
|
allowanceGrantIndexes,
|
|
@@ -100,6 +110,7 @@ var import_writers = require("./writers.js");
|
|
|
100
110
|
createAuditWriter,
|
|
101
111
|
createDatabase,
|
|
102
112
|
createOutboxWriter,
|
|
113
|
+
disposableEmailDomainColumns,
|
|
103
114
|
extensionKeyColumns,
|
|
104
115
|
extensionKeyIndexes,
|
|
105
116
|
isUniqueViolation,
|
|
@@ -126,11 +137,14 @@ var import_writers = require("./writers.js");
|
|
|
126
137
|
runMigrationsCli,
|
|
127
138
|
shopifyInstallationColumns,
|
|
128
139
|
subscriptionColumns,
|
|
140
|
+
subscriptionIndexes,
|
|
129
141
|
subscriptionStatusEnum,
|
|
130
142
|
timestamps,
|
|
131
143
|
usageRecordColumns,
|
|
132
144
|
usageRecordIndexes,
|
|
133
145
|
userColumns,
|
|
146
|
+
userIdentityColumns,
|
|
147
|
+
userIdentityIndexes,
|
|
134
148
|
webhookEventColumns,
|
|
135
149
|
withTenant
|
|
136
150
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Database } from '../client.js';
|
|
2
|
+
import type { DisposableEmailDomainsTable } from '../columns.js';
|
|
3
|
+
/**
|
|
4
|
+
* The list of throwaway mailbox domains, in the app's database (not in a process's memory).
|
|
5
|
+
* Read and written through the system connection only.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DisposableEmailRepository {
|
|
8
|
+
private readonly systemDb;
|
|
9
|
+
private readonly tables;
|
|
10
|
+
constructor(systemDb: Database, tables: {
|
|
11
|
+
disposableEmailDomains: DisposableEmailDomainsTable;
|
|
12
|
+
});
|
|
13
|
+
/** True when any of the domains is on the list. */
|
|
14
|
+
isListed(domains: readonly string[]): Promise<boolean>;
|
|
15
|
+
count(): Promise<number>;
|
|
16
|
+
/** Replaces the whole list in one transaction: a reader sees the old list or the new one. */
|
|
17
|
+
replaceAll(domains: readonly string[]): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 disposable_email_repository_exports = {};
|
|
19
|
+
__export(disposable_email_repository_exports, {
|
|
20
|
+
DisposableEmailRepository: () => DisposableEmailRepository
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(disposable_email_repository_exports);
|
|
23
|
+
var import_drizzle_orm = require("drizzle-orm");
|
|
24
|
+
const ROWS_PER_INSERT = 1e3;
|
|
25
|
+
class DisposableEmailRepository {
|
|
26
|
+
systemDb;
|
|
27
|
+
tables;
|
|
28
|
+
constructor(systemDb, tables) {
|
|
29
|
+
this.systemDb = systemDb;
|
|
30
|
+
this.tables = tables;
|
|
31
|
+
}
|
|
32
|
+
/** True when any of the domains is on the list. */
|
|
33
|
+
async isListed(domains) {
|
|
34
|
+
if (domains.length === 0)
|
|
35
|
+
return false;
|
|
36
|
+
const t = this.tables.disposableEmailDomains;
|
|
37
|
+
const rows = await this.systemDb.select({ domain: t.domain }).from(t).where((0, import_drizzle_orm.inArray)(t.domain, [...domains])).limit(1);
|
|
38
|
+
return rows.length > 0;
|
|
39
|
+
}
|
|
40
|
+
async count() {
|
|
41
|
+
const t = this.tables.disposableEmailDomains;
|
|
42
|
+
const [row] = await this.systemDb.select({ n: import_drizzle_orm.sql`count(*)::int` }).from(t);
|
|
43
|
+
return row?.n ?? 0;
|
|
44
|
+
}
|
|
45
|
+
/** Replaces the whole list in one transaction: a reader sees the old list or the new one. */
|
|
46
|
+
async replaceAll(domains) {
|
|
47
|
+
const unique = [...new Set(domains)];
|
|
48
|
+
const t = this.tables.disposableEmailDomains;
|
|
49
|
+
await this.systemDb.transaction(async (tx) => {
|
|
50
|
+
await tx.delete(t);
|
|
51
|
+
for (let from = 0; from < unique.length; from += ROWS_PER_INSERT) {
|
|
52
|
+
await tx.insert(t).values(unique.slice(from, from + ROWS_PER_INSERT).map((domain) => ({ domain })));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
DisposableEmailRepository
|
|
60
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Database } from '../client.js';
|
|
2
|
+
import type { AuditLogsTable, UserIdentitiesTable } from '../columns.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which user a sign-in provider's account (Google, GitHub) signs in as. Through the system
|
|
5
|
+
* connection only: the runtime role has no access.
|
|
6
|
+
*/
|
|
7
|
+
export declare class UserIdentityRepository {
|
|
8
|
+
private readonly systemDb;
|
|
9
|
+
private readonly tables;
|
|
10
|
+
private readonly insertAudit;
|
|
11
|
+
constructor(systemDb: Database, tables: {
|
|
12
|
+
userIdentities: UserIdentitiesTable;
|
|
13
|
+
auditLogs: AuditLogsTable;
|
|
14
|
+
});
|
|
15
|
+
/** The user this provider account signs in as, or null if it has never signed in. */
|
|
16
|
+
findUserId(provider: string, providerUserId: string): Promise<string | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Records that the provider account signs in as the user. An account already linked stays
|
|
19
|
+
* with its first user. A new link to an account that was there before (`existingAccount`) is
|
|
20
|
+
* written to the audit log: a new way into it. A brand-new account's first link is not.
|
|
21
|
+
*/
|
|
22
|
+
link(input: {
|
|
23
|
+
userId: string;
|
|
24
|
+
organizationId: string;
|
|
25
|
+
provider: string;
|
|
26
|
+
providerUserId: string;
|
|
27
|
+
email: string;
|
|
28
|
+
existingAccount: boolean;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 user_identity_repository_exports = {};
|
|
19
|
+
__export(user_identity_repository_exports, {
|
|
20
|
+
UserIdentityRepository: () => UserIdentityRepository
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(user_identity_repository_exports);
|
|
23
|
+
var import_drizzle_orm = require("drizzle-orm");
|
|
24
|
+
var import_writers = require("../writers.js");
|
|
25
|
+
class UserIdentityRepository {
|
|
26
|
+
systemDb;
|
|
27
|
+
tables;
|
|
28
|
+
insertAudit;
|
|
29
|
+
constructor(systemDb, tables) {
|
|
30
|
+
this.systemDb = systemDb;
|
|
31
|
+
this.tables = tables;
|
|
32
|
+
this.insertAudit = (0, import_writers.createAuditWriter)(tables);
|
|
33
|
+
}
|
|
34
|
+
/** The user this provider account signs in as, or null if it has never signed in. */
|
|
35
|
+
async findUserId(provider, providerUserId) {
|
|
36
|
+
const t = this.tables.userIdentities;
|
|
37
|
+
const [row] = await this.systemDb.select({ userId: t.userId }).from(t).where((0, import_drizzle_orm.and)((0, import_drizzle_orm.eq)(t.provider, provider), (0, import_drizzle_orm.eq)(t.providerUserId, providerUserId))).limit(1);
|
|
38
|
+
return row?.userId ?? null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Records that the provider account signs in as the user. An account already linked stays
|
|
42
|
+
* with its first user. A new link to an account that was there before (`existingAccount`) is
|
|
43
|
+
* written to the audit log: a new way into it. A brand-new account's first link is not.
|
|
44
|
+
*/
|
|
45
|
+
async link(input) {
|
|
46
|
+
await this.systemDb.transaction(async (tx) => {
|
|
47
|
+
const inserted = await tx.insert(this.tables.userIdentities).values({
|
|
48
|
+
userId: input.userId,
|
|
49
|
+
provider: input.provider,
|
|
50
|
+
providerUserId: input.providerUserId,
|
|
51
|
+
emailAtLink: input.email
|
|
52
|
+
}).onConflictDoNothing().returning({ id: this.tables.userIdentities.id });
|
|
53
|
+
if (inserted.length === 0 || !input.existingAccount)
|
|
54
|
+
return;
|
|
55
|
+
await this.insertAudit(tx, {
|
|
56
|
+
organizationId: input.organizationId,
|
|
57
|
+
actor: `user:${input.userId}`,
|
|
58
|
+
action: "sign_in.identity_linked",
|
|
59
|
+
entityType: "organization",
|
|
60
|
+
entityId: input.organizationId,
|
|
61
|
+
metadata: { provider: input.provider }
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
UserIdentityRepository
|
|
69
|
+
});
|
package/dist/columns.d.ts
CHANGED
|
@@ -101,6 +101,33 @@ export declare const extensionKeyIndexes: (t: {
|
|
|
101
101
|
organizationId: AnyPgColumn;
|
|
102
102
|
userId: AnyPgColumn;
|
|
103
103
|
}) => import("drizzle-orm/pg-core").IndexBuilder[];
|
|
104
|
+
/**
|
|
105
|
+
* A sign-in provider's account (Google, GitHub) that signs in as a user. Only which provider
|
|
106
|
+
* and its stable ID are kept, and the email it vouched for when linked: never its tokens.
|
|
107
|
+
*/
|
|
108
|
+
export declare const userIdentityColumns: (refs: {
|
|
109
|
+
users: Ref;
|
|
110
|
+
}) => {
|
|
111
|
+
createdAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"created_at">>>;
|
|
112
|
+
updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"updated_at">>>;
|
|
113
|
+
id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
|
|
114
|
+
userId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"user_id">>;
|
|
115
|
+
provider: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"provider", [string, ...string[]]>>;
|
|
116
|
+
providerUserId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"provider_user_id", [string, ...string[]]>>;
|
|
117
|
+
emailAtLink: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"email_at_link", [string, ...string[]]>>;
|
|
118
|
+
};
|
|
119
|
+
export declare const userIdentityIndexes: (t: {
|
|
120
|
+
provider: AnyPgColumn;
|
|
121
|
+
providerUserId: AnyPgColumn;
|
|
122
|
+
userId: AnyPgColumn;
|
|
123
|
+
}) => (import("drizzle-orm/pg-core").UniqueConstraintBuilder | import("drizzle-orm/pg-core").IndexBuilder)[];
|
|
124
|
+
/**
|
|
125
|
+
* Domains of throwaway mailbox providers: an account is not created for an address on one (or
|
|
126
|
+
* on a subdomain of one). The community list, replaced whole by a daily refresh.
|
|
127
|
+
*/
|
|
128
|
+
export declare const disposableEmailDomainColumns: () => {
|
|
129
|
+
domain: import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"domain", [string, ...string[]]>>>;
|
|
130
|
+
};
|
|
104
131
|
export declare const webhookEventColumns: (refs: {
|
|
105
132
|
organizations: Ref;
|
|
106
133
|
stores: Ref;
|
|
@@ -185,13 +212,19 @@ export declare const planColumns: () => {
|
|
|
185
212
|
id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
|
|
186
213
|
code: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"code", [string, ...string[]]>>;
|
|
187
214
|
name: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"name", [string, ...string[]]>>;
|
|
215
|
+
/**
|
|
216
|
+
* What the plan is for, when an app sells more than one thing (haatlabs-api's console: one
|
|
217
|
+
* plan per product). Every app with one thing to sell keeps `'app'`.
|
|
218
|
+
*/
|
|
219
|
+
product: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"product", [string, ...string[]]>>>;
|
|
188
220
|
/** The plan of an organization that has no current subscription. */
|
|
189
221
|
isDefault: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBooleanBuilderInitial<"is_default">>>;
|
|
190
222
|
position: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgIntegerBuilderInitial<"position">>;
|
|
191
223
|
};
|
|
192
|
-
/** Only one plan is the default. */
|
|
224
|
+
/** Only one plan is the default in each product. */
|
|
193
225
|
export declare const planIndexes: (t: {
|
|
194
226
|
isDefault: AnyPgColumn;
|
|
227
|
+
product: AnyPgColumn;
|
|
195
228
|
}) => import("drizzle-orm/pg-core").IndexBuilder[];
|
|
196
229
|
export declare const planFeatureColumns: (refs: {
|
|
197
230
|
plans: Ref;
|
|
@@ -218,6 +251,8 @@ export declare const subscriptionColumns: (refs: {
|
|
|
218
251
|
id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"id">>>>;
|
|
219
252
|
organizationId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"organization_id">>;
|
|
220
253
|
planId: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"plan_id">>;
|
|
254
|
+
/** Its plan's product: an organization holds at most one subscription in each. */
|
|
255
|
+
product: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"product", [string, ...string[]]>>>;
|
|
221
256
|
status: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgEnumColumnBuilderInitial<"status", ["ACTIVE", "CANCELLED"]>>>;
|
|
222
257
|
periodStart: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"period_start">>;
|
|
223
258
|
periodEnd: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"period_end">>;
|
|
@@ -237,6 +272,11 @@ export declare const subscriptionColumns: (refs: {
|
|
|
237
272
|
priceAmountMinor: import("drizzle-orm/pg-core").PgBigInt53BuilderInitial<"price_amount_minor">;
|
|
238
273
|
priceCurrency: import("drizzle-orm/pg-core").PgTextBuilderInitial<"price_currency", [string, ...string[]]>;
|
|
239
274
|
};
|
|
275
|
+
/** One subscription per organization in each product. */
|
|
276
|
+
export declare const subscriptionIndexes: (t: {
|
|
277
|
+
organizationId: AnyPgColumn;
|
|
278
|
+
product: AnyPgColumn;
|
|
279
|
+
}) => import("drizzle-orm/pg-core").UniqueConstraintBuilder[];
|
|
240
280
|
/** What a plan costs through each gateway, per currency, and the gateway's own ID for it. */
|
|
241
281
|
export declare const planPriceColumns: (refs: {
|
|
242
282
|
plans: Ref;
|
|
@@ -342,7 +382,7 @@ export declare const outboxPriorityColumn: () => import("drizzle-orm").HasDefaul
|
|
|
342
382
|
* app's migration, before the outbox table; run with `check_function_bodies = false` when
|
|
343
383
|
* the tables it reads come later in the same migration.
|
|
344
384
|
*/
|
|
345
|
-
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.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 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$$;";
|
|
385
|
+
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$$;";
|
|
346
386
|
type TableOf<N extends string, C extends Record<string, PgColumnBuilderBase>> = PgTableWithColumns<{
|
|
347
387
|
name: N;
|
|
348
388
|
schema: undefined;
|
|
@@ -353,6 +393,8 @@ export type UsersTable = TableOf<'users', ReturnType<typeof userColumns>>;
|
|
|
353
393
|
export type OrganizationsTable = TableOf<'organizations', ReturnType<typeof organizationColumns>>;
|
|
354
394
|
export type MembershipsTable = TableOf<'memberships', ReturnType<typeof membershipColumns>>;
|
|
355
395
|
export type ApiKeysTable = TableOf<'api_keys', ReturnType<typeof apiKeyColumns>>;
|
|
396
|
+
export type DisposableEmailDomainsTable = TableOf<'disposable_email_domains', ReturnType<typeof disposableEmailDomainColumns>>;
|
|
397
|
+
export type UserIdentitiesTable = TableOf<'user_identities', ReturnType<typeof userIdentityColumns>>;
|
|
356
398
|
export type ExtensionKeysTable = TableOf<'extension_keys', ReturnType<typeof extensionKeyColumns>>;
|
|
357
399
|
export type WebhookEventsTable = TableOf<'webhook_events', ReturnType<typeof webhookEventColumns>>;
|
|
358
400
|
export type OutboxMessagesTable = TableOf<'outbox_messages', ReturnType<typeof outboxMessageColumns>>;
|
package/dist/columns.js
CHANGED
|
@@ -95,6 +95,31 @@ export const extensionKeyColumns = (refs) => ({
|
|
|
95
95
|
export const extensionKeyIndexes = (t) => [
|
|
96
96
|
index('extension_keys_org_user_idx').on(t.organizationId, t.userId),
|
|
97
97
|
];
|
|
98
|
+
/**
|
|
99
|
+
* A sign-in provider's account (Google, GitHub) that signs in as a user. Only which provider
|
|
100
|
+
* and its stable ID are kept, and the email it vouched for when linked: never its tokens.
|
|
101
|
+
*/
|
|
102
|
+
export const userIdentityColumns = (refs) => ({
|
|
103
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
104
|
+
userId: uuid('user_id')
|
|
105
|
+
.notNull()
|
|
106
|
+
.references(() => refs.users.id, { onDelete: 'cascade' }),
|
|
107
|
+
provider: text('provider').notNull(),
|
|
108
|
+
providerUserId: text('provider_user_id').notNull(),
|
|
109
|
+
emailAtLink: text('email_at_link').notNull(),
|
|
110
|
+
...timestamps(),
|
|
111
|
+
});
|
|
112
|
+
export const userIdentityIndexes = (t) => [
|
|
113
|
+
unique('user_identities_provider_user_unique').on(t.provider, t.providerUserId),
|
|
114
|
+
index('user_identities_user_idx').on(t.userId),
|
|
115
|
+
];
|
|
116
|
+
/**
|
|
117
|
+
* Domains of throwaway mailbox providers: an account is not created for an address on one (or
|
|
118
|
+
* on a subdomain of one). The community list, replaced whole by a daily refresh.
|
|
119
|
+
*/
|
|
120
|
+
export const disposableEmailDomainColumns = () => ({
|
|
121
|
+
domain: text('domain').primaryKey(),
|
|
122
|
+
});
|
|
98
123
|
export const webhookEventColumns = (refs) => ({
|
|
99
124
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
100
125
|
organizationId: uuid('organization_id')
|
|
@@ -174,21 +199,26 @@ export const platformAdminColumns = () => ({
|
|
|
174
199
|
...timestamps(),
|
|
175
200
|
});
|
|
176
201
|
// Billing: plans are data. Their limits, caps, switches and priority are `plan_features`
|
|
177
|
-
// rows; an organization has at most one subscription; usage is counted once per key.
|
|
202
|
+
// rows; an organization has at most one subscription in each product; usage is counted once per key.
|
|
178
203
|
export const subscriptionStatusEnum = pgEnum('subscription_status', ['ACTIVE', 'CANCELLED']);
|
|
179
204
|
export const planColumns = () => ({
|
|
180
205
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
181
206
|
code: text('code').notNull().unique(),
|
|
182
207
|
name: text('name').notNull(),
|
|
208
|
+
/**
|
|
209
|
+
* What the plan is for, when an app sells more than one thing (haatlabs-api's console: one
|
|
210
|
+
* plan per product). Every app with one thing to sell keeps `'app'`.
|
|
211
|
+
*/
|
|
212
|
+
product: text('product').notNull().default('app'),
|
|
183
213
|
/** The plan of an organization that has no current subscription. */
|
|
184
214
|
isDefault: boolean('is_default').notNull().default(false),
|
|
185
215
|
position: integer('position').notNull(),
|
|
186
216
|
...timestamps(),
|
|
187
217
|
});
|
|
188
|
-
/** Only one plan is the default. */
|
|
218
|
+
/** Only one plan is the default in each product. */
|
|
189
219
|
export const planIndexes = (t) => [
|
|
190
220
|
uniqueIndex('plans_one_default_idx')
|
|
191
|
-
.on(t.
|
|
221
|
+
.on(t.product)
|
|
192
222
|
.where(sql `${t.isDefault}`),
|
|
193
223
|
];
|
|
194
224
|
export const planFeatureColumns = (refs) => ({
|
|
@@ -209,11 +239,12 @@ export const subscriptionColumns = (refs) => ({
|
|
|
209
239
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
210
240
|
organizationId: uuid('organization_id')
|
|
211
241
|
.notNull()
|
|
212
|
-
.unique()
|
|
213
242
|
.references(() => refs.organizations.id, { onDelete: 'cascade' }),
|
|
214
243
|
planId: uuid('plan_id')
|
|
215
244
|
.notNull()
|
|
216
245
|
.references(() => refs.plans.id),
|
|
246
|
+
/** Its plan's product: an organization holds at most one subscription in each. */
|
|
247
|
+
product: text('product').notNull().default('app'),
|
|
217
248
|
status: subscriptionStatusEnum('status').notNull().default('ACTIVE'),
|
|
218
249
|
periodStart: timestamp('period_start', { withTimezone: true }).notNull(),
|
|
219
250
|
periodEnd: timestamp('period_end', { withTimezone: true }).notNull(),
|
|
@@ -234,6 +265,10 @@ export const subscriptionColumns = (refs) => ({
|
|
|
234
265
|
priceCurrency: text('price_currency'),
|
|
235
266
|
...timestamps(),
|
|
236
267
|
});
|
|
268
|
+
/** One subscription per organization in each product. */
|
|
269
|
+
export const subscriptionIndexes = (t) => [
|
|
270
|
+
unique('subscriptions_org_product_unique').on(t.organizationId, t.product),
|
|
271
|
+
];
|
|
237
272
|
/** What a plan costs through each gateway, per currency, and the gateway's own ID for it. */
|
|
238
273
|
export const planPriceColumns = (refs) => ({
|
|
239
274
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
@@ -340,6 +375,7 @@ AS $$
|
|
|
340
375
|
FROM subscriptions s
|
|
341
376
|
JOIN org ON s.organization_id = org.id
|
|
342
377
|
WHERE s.status = 'ACTIVE'
|
|
378
|
+
AND s.product = 'app'
|
|
343
379
|
AND s.period_start <= now()
|
|
344
380
|
AND (now() < s.period_end OR (s.provider = 'shopify' AND s.provider_ended_at IS NULL))
|
|
345
381
|
LIMIT 1
|
|
@@ -347,7 +383,7 @@ AS $$
|
|
|
347
383
|
plan AS (
|
|
348
384
|
SELECT COALESCE(
|
|
349
385
|
(SELECT plan_id FROM held),
|
|
350
|
-
(SELECT id FROM plans WHERE is_default LIMIT 1)
|
|
386
|
+
(SELECT id FROM plans WHERE is_default AND product = 'app' LIMIT 1)
|
|
351
387
|
) AS id
|
|
352
388
|
)
|
|
353
389
|
SELECT CASE
|
package/dist/columns.js.map
CHANGED
|
@@ -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,SAA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;;;;;;;;;;;;;;;;;;;;;;;IAkCvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDatabase } from './client.js';
|
|
2
2
|
export type { Database, DatabaseHandle, DatabaseLogger, Tx } from './client.js';
|
|
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, subscriptionStatusEnum, timestamps, usageRecordColumns, usageRecordIndexes, userColumns, webhookEventColumns, extensionKeyColumns, extensionKeyIndexes, } from './columns.js';
|
|
4
|
-
export type { ApiKeysTable, ExtensionKeysTable, AuditLogsTable, MembershipsTable, OrganizationsTable, OrganizationFeaturesTable, AllowanceGrantsTable, OutboxMessagesTable, PaymentEventsTable, PlanFeaturesTable, PlanPricesTable, PlansTable, PlatformAdminsTable, ShopifyInstallationsTable, SubscriptionsTable, UsageRecordsTable, UsersTable, WebhookEventsTable, } from './columns.js';
|
|
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
|
+
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
5
|
export { isUniqueViolation } from './errors.js';
|
|
6
6
|
export { runMigrations, runMigrationsCli } from './migrate.js';
|
|
7
7
|
export { ApiKeyRepository } from './repositories/api-key.repository.js';
|
|
@@ -9,6 +9,8 @@ export type { ApiKeyRow } from './repositories/api-key.repository.js';
|
|
|
9
9
|
export { ExtensionKeyRepository } from './repositories/extension-key.repository.js';
|
|
10
10
|
export type { ExtensionKeyRow } from './repositories/extension-key.repository.js';
|
|
11
11
|
export { IdentityRepository } from './repositories/identity.repository.js';
|
|
12
|
+
export { UserIdentityRepository } from './repositories/user-identity.repository.js';
|
|
13
|
+
export { DisposableEmailRepository } from './repositories/disposable-email.repository.js';
|
|
12
14
|
export type { Role } from './repositories/identity.repository.js';
|
|
13
15
|
export { OutboxRepository } from './repositories/outbox.repository.js';
|
|
14
16
|
export type { OutboxMessage } from './repositories/outbox.repository.js';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { createDatabase } from './client.js';
|
|
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, subscriptionStatusEnum, timestamps, usageRecordColumns, usageRecordIndexes, userColumns, webhookEventColumns, extensionKeyColumns, extensionKeyIndexes, } from './columns.js';
|
|
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
3
|
export { isUniqueViolation } from './errors.js';
|
|
4
4
|
export { runMigrations, runMigrationsCli } from './migrate.js';
|
|
5
5
|
export { ApiKeyRepository } from './repositories/api-key.repository.js';
|
|
6
6
|
export { ExtensionKeyRepository } from './repositories/extension-key.repository.js';
|
|
7
7
|
export { IdentityRepository } from './repositories/identity.repository.js';
|
|
8
|
+
export { UserIdentityRepository } from './repositories/user-identity.repository.js';
|
|
9
|
+
export { DisposableEmailRepository } from './repositories/disposable-email.repository.js';
|
|
8
10
|
export { OutboxRepository } from './repositories/outbox.repository.js';
|
|
9
11
|
export { PlatformAdminRepository } from './repositories/platform-admin.repository.js';
|
|
10
12
|
export { WebhookEventRepository } from './repositories/webhook-event.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,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAC;
|
|
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,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,18 @@
|
|
|
1
|
+
import type { Database } from '../client.js';
|
|
2
|
+
import type { DisposableEmailDomainsTable } from '../columns.js';
|
|
3
|
+
/**
|
|
4
|
+
* The list of throwaway mailbox domains, in the app's database (not in a process's memory).
|
|
5
|
+
* Read and written through the system connection only.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DisposableEmailRepository {
|
|
8
|
+
private readonly systemDb;
|
|
9
|
+
private readonly tables;
|
|
10
|
+
constructor(systemDb: Database, tables: {
|
|
11
|
+
disposableEmailDomains: DisposableEmailDomainsTable;
|
|
12
|
+
});
|
|
13
|
+
/** True when any of the domains is on the list. */
|
|
14
|
+
isListed(domains: readonly string[]): Promise<boolean>;
|
|
15
|
+
count(): Promise<number>;
|
|
16
|
+
/** Replaces the whole list in one transaction: a reader sees the old list or the new one. */
|
|
17
|
+
replaceAll(domains: readonly string[]): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { inArray, sql } from 'drizzle-orm';
|
|
2
|
+
const ROWS_PER_INSERT = 1_000;
|
|
3
|
+
/**
|
|
4
|
+
* The list of throwaway mailbox domains, in the app's database (not in a process's memory).
|
|
5
|
+
* Read and written through the system connection only.
|
|
6
|
+
*/
|
|
7
|
+
export class DisposableEmailRepository {
|
|
8
|
+
systemDb;
|
|
9
|
+
tables;
|
|
10
|
+
constructor(systemDb, tables) {
|
|
11
|
+
this.systemDb = systemDb;
|
|
12
|
+
this.tables = tables;
|
|
13
|
+
}
|
|
14
|
+
/** True when any of the domains is on the list. */
|
|
15
|
+
async isListed(domains) {
|
|
16
|
+
if (domains.length === 0)
|
|
17
|
+
return false;
|
|
18
|
+
const t = this.tables.disposableEmailDomains;
|
|
19
|
+
const rows = await this.systemDb
|
|
20
|
+
.select({ domain: t.domain })
|
|
21
|
+
.from(t)
|
|
22
|
+
.where(inArray(t.domain, [...domains]))
|
|
23
|
+
.limit(1);
|
|
24
|
+
return rows.length > 0;
|
|
25
|
+
}
|
|
26
|
+
async count() {
|
|
27
|
+
const t = this.tables.disposableEmailDomains;
|
|
28
|
+
const [row] = await this.systemDb.select({ n: sql `count(*)::int` }).from(t);
|
|
29
|
+
return row?.n ?? 0;
|
|
30
|
+
}
|
|
31
|
+
/** Replaces the whole list in one transaction: a reader sees the old list or the new one. */
|
|
32
|
+
async replaceAll(domains) {
|
|
33
|
+
const unique = [...new Set(domains)];
|
|
34
|
+
const t = this.tables.disposableEmailDomains;
|
|
35
|
+
await this.systemDb.transaction(async (tx) => {
|
|
36
|
+
await tx.delete(t);
|
|
37
|
+
for (let from = 0; from < unique.length; from += ROWS_PER_INSERT) {
|
|
38
|
+
await tx
|
|
39
|
+
.insert(t)
|
|
40
|
+
.values(unique.slice(from, from + ROWS_PER_INSERT).map((domain) => ({ domain })));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=disposable-email.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disposable-email.repository.js","sourceRoot":"","sources":["../../src/repositories/disposable-email.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAI3C,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAEjB;IACA;IAFnB,YACmB,QAAkB,EAClB,MAA+D;QAD/D,aAAQ,GAAR,QAAQ,CAAU;QAClB,WAAM,GAAN,MAAM,CAAyD;IAC/E,CAAC;IAEJ,mDAAmD;IACnD,KAAK,CAAC,QAAQ,CAAC,OAA0B;QACvC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACvC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC;QAC7C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ;aAC7B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;aAC5B,IAAI,CAAC,CAAC,CAAC;aACP,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;aACtC,KAAK,CAAC,CAAC,CAAC,CAAC;QACZ,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC;QAC7C,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAQ,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpF,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,6FAA6F;IAC7F,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC;QAC7C,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YAC3C,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACnB,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,IAAI,eAAe,EAAE,CAAC;gBACjE,MAAM,EAAE;qBACL,MAAM,CAAC,CAAC,CAAC;qBACT,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YACtF,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Database } from '../client.js';
|
|
2
|
+
import type { AuditLogsTable, UserIdentitiesTable } from '../columns.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which user a sign-in provider's account (Google, GitHub) signs in as. Through the system
|
|
5
|
+
* connection only: the runtime role has no access.
|
|
6
|
+
*/
|
|
7
|
+
export declare class UserIdentityRepository {
|
|
8
|
+
private readonly systemDb;
|
|
9
|
+
private readonly tables;
|
|
10
|
+
private readonly insertAudit;
|
|
11
|
+
constructor(systemDb: Database, tables: {
|
|
12
|
+
userIdentities: UserIdentitiesTable;
|
|
13
|
+
auditLogs: AuditLogsTable;
|
|
14
|
+
});
|
|
15
|
+
/** The user this provider account signs in as, or null if it has never signed in. */
|
|
16
|
+
findUserId(provider: string, providerUserId: string): Promise<string | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Records that the provider account signs in as the user. An account already linked stays
|
|
19
|
+
* with its first user. A new link to an account that was there before (`existingAccount`) is
|
|
20
|
+
* written to the audit log: a new way into it. A brand-new account's first link is not.
|
|
21
|
+
*/
|
|
22
|
+
link(input: {
|
|
23
|
+
userId: string;
|
|
24
|
+
organizationId: string;
|
|
25
|
+
provider: string;
|
|
26
|
+
providerUserId: string;
|
|
27
|
+
email: string;
|
|
28
|
+
existingAccount: boolean;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { and, eq } from 'drizzle-orm';
|
|
2
|
+
import { createAuditWriter } from '../writers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which user a sign-in provider's account (Google, GitHub) signs in as. Through the system
|
|
5
|
+
* connection only: the runtime role has no access.
|
|
6
|
+
*/
|
|
7
|
+
export class UserIdentityRepository {
|
|
8
|
+
systemDb;
|
|
9
|
+
tables;
|
|
10
|
+
insertAudit;
|
|
11
|
+
constructor(systemDb, tables) {
|
|
12
|
+
this.systemDb = systemDb;
|
|
13
|
+
this.tables = tables;
|
|
14
|
+
this.insertAudit = createAuditWriter(tables);
|
|
15
|
+
}
|
|
16
|
+
/** The user this provider account signs in as, or null if it has never signed in. */
|
|
17
|
+
async findUserId(provider, providerUserId) {
|
|
18
|
+
const t = this.tables.userIdentities;
|
|
19
|
+
const [row] = await this.systemDb
|
|
20
|
+
.select({ userId: t.userId })
|
|
21
|
+
.from(t)
|
|
22
|
+
.where(and(eq(t.provider, provider), eq(t.providerUserId, providerUserId)))
|
|
23
|
+
.limit(1);
|
|
24
|
+
return row?.userId ?? null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Records that the provider account signs in as the user. An account already linked stays
|
|
28
|
+
* with its first user. A new link to an account that was there before (`existingAccount`) is
|
|
29
|
+
* written to the audit log: a new way into it. A brand-new account's first link is not.
|
|
30
|
+
*/
|
|
31
|
+
async link(input) {
|
|
32
|
+
await this.systemDb.transaction(async (tx) => {
|
|
33
|
+
const inserted = await tx
|
|
34
|
+
.insert(this.tables.userIdentities)
|
|
35
|
+
.values({
|
|
36
|
+
userId: input.userId,
|
|
37
|
+
provider: input.provider,
|
|
38
|
+
providerUserId: input.providerUserId,
|
|
39
|
+
emailAtLink: input.email,
|
|
40
|
+
})
|
|
41
|
+
.onConflictDoNothing()
|
|
42
|
+
.returning({ id: this.tables.userIdentities.id });
|
|
43
|
+
if (inserted.length === 0 || !input.existingAccount)
|
|
44
|
+
return;
|
|
45
|
+
await this.insertAudit(tx, {
|
|
46
|
+
organizationId: input.organizationId,
|
|
47
|
+
actor: `user:${input.userId}`,
|
|
48
|
+
action: 'sign_in.identity_linked',
|
|
49
|
+
entityType: 'organization',
|
|
50
|
+
entityId: input.organizationId,
|
|
51
|
+
metadata: { provider: input.provider },
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=user-identity.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-identity.repository.js","sourceRoot":"","sources":["../../src/repositories/user-identity.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAId;IACA;IAJF,WAAW,CAAc;IAE1C,YACmB,QAAkB,EAClB,MAA0E;QAD1E,aAAQ,GAAR,QAAQ,CAAU;QAClB,WAAM,GAAN,MAAM,CAAoE;QAE3F,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,UAAU,CAAC,QAAgB,EAAE,cAAsB;QACvD,MAAM,CAAC,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,EAAE,cAAc;gBAC1B,QAAQ,EAAE,KAAK,CAAC,cAAc;gBAC9B,QAAQ,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haatlabs-core/db-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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.
|
|
59
|
-
"@haatlabs-core/vitest-config": "0.
|
|
58
|
+
"@haatlabs-core/tsconfig": "0.17.0",
|
|
59
|
+
"@haatlabs-core/vitest-config": "0.17.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@haatlabs-core/
|
|
63
|
-
"@haatlabs-core/
|
|
64
|
-
"@haatlabs-core/
|
|
62
|
+
"@haatlabs-core/queue": "0.17.0",
|
|
63
|
+
"@haatlabs-core/errors": "0.17.0",
|
|
64
|
+
"@haatlabs-core/observability": "0.17.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"drizzle-orm": "^0.45.3",
|