@haatlabs-core/templates 0.16.0 → 0.17.1

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,13 @@
57
57
  "when": 1794494308207,
58
58
  "tag": "0007_user_identities",
59
59
  "breakpoints": true
60
+ },
61
+ {
62
+ "idx": 8,
63
+ "version": "7",
64
+ "when": 1794501701224,
65
+ "tag": "0008_product_and_disposable",
66
+ "breakpoints": true
60
67
  }
61
68
  ]
62
69
  }
@@ -5,6 +5,7 @@ export { runMigrations } from './migrate';
5
5
  export * from './repositories/shared';
6
6
  export * from './repositories/identity.repository';
7
7
  export * from './repositories/user-identity.repository';
8
+ export * from './repositories/disposable-email.repository';
8
9
  export * from './repositories/api-key.repository';
9
10
  export * from './repositories/extension-key.repository';
10
11
  export * from './repositories/system-store.repository';
@@ -72,6 +72,9 @@ const quantity = sql<number>`coalesce(sum(${usageRecords.quantity}), 0)::int`;
72
72
  * The platform administrators' accounts (the shared PlatformAdminRepository: sign-in,
73
73
  * the operator's command) and what they see across every tenant.
74
74
  */
75
+ /** The app's own product (`@haatlabs-core/billing`'s DEFAULT_PRODUCT): what the panel shows. */
76
+ const DEFAULT_PRODUCT = 'app';
77
+
75
78
  export class SystemAdminRepository extends PlatformAdminRepository {
76
79
  constructor(systemDb: Database) {
77
80
  super(systemDb, { platformAdmins });
@@ -167,11 +170,13 @@ export class SystemAdminRepository extends PlatformAdminRepository {
167
170
  updatedAt: subscriptions.updatedAt,
168
171
  })
169
172
  .from(subscriptions)
170
- .innerJoin(plans, eq(plans.id, subscriptions.planId)),
173
+ .innerJoin(plans, eq(plans.id, subscriptions.planId))
174
+ // The panel shows the app's own product: one subscription per organization.
175
+ .where(eq(subscriptions.product, DEFAULT_PRODUCT)),
171
176
  db
172
177
  .select({ planId: plans.id, code: plans.code, name: plans.name })
173
178
  .from(plans)
174
- .where(eq(plans.isDefault, true)),
179
+ .where(and(eq(plans.isDefault, true), eq(plans.product, DEFAULT_PRODUCT))),
175
180
  db.select().from(organizationFeatures),
176
181
  db
177
182
  .select({
@@ -295,6 +300,7 @@ export class SystemAdminRepository extends PlatformAdminRepository {
295
300
  return this.systemDb
296
301
  .select({ code: plans.code, name: plans.name, isDefault: plans.isDefault })
297
302
  .from(plans)
303
+ .where(eq(plans.product, DEFAULT_PRODUCT))
298
304
  .orderBy(asc(plans.position), asc(plans.code));
299
305
  }
300
306
  }
@@ -0,0 +1,10 @@
1
+ import { DisposableEmailRepository as SharedDisposableEmailRepository } from '@haatlabs-core/db-core';
2
+ import type { Database } from '../client';
3
+ import { disposableEmailDomains } from '../schema';
4
+
5
+ /** The throwaway mailbox domains a new account's address is checked against. */
6
+ export class DisposableEmailRepository extends SharedDisposableEmailRepository {
7
+ constructor(systemDb: Database) {
8
+ super(systemDb, { disposableEmailDomains });
9
+ }
10
+ }
@@ -14,6 +14,7 @@ import {
14
14
  planPriceColumns,
15
15
  planPriceIndexes,
16
16
  subscriptionColumns,
17
+ subscriptionIndexes,
17
18
  usageRecordColumns,
18
19
  usageRecordIndexes,
19
20
  } from '@haatlabs-core/db-core';
@@ -34,6 +35,7 @@ export const planFeatures = pgTable('plan_features', planFeatureColumns({ plans
34
35
  export const subscriptions = pgTable(
35
36
  'subscriptions',
36
37
  subscriptionColumns({ organizations, plans }),
38
+ (t) => subscriptionIndexes(t),
37
39
  );
38
40
 
39
41
  /** What a plan costs through each gateway, per currency, and the gateway's own ID for it. */
@@ -11,6 +11,7 @@ import {
11
11
  timestamps as sharedTimestamps,
12
12
  userColumns,
13
13
  userIdentityColumns,
14
+ disposableEmailDomainColumns,
14
15
  userIdentityIndexes,
15
16
  } from '@haatlabs-core/db-core';
16
17
 
@@ -40,6 +41,15 @@ export const extensionKeys = pgTable(
40
41
  (t) => extensionKeyIndexes(t),
41
42
  );
42
43
 
44
+ /**
45
+ * Throwaway mailbox domains: no account is made for an address on one. Replaced whole by the
46
+ * worker's daily refresh; read through the system connection only.
47
+ */
48
+ export const disposableEmailDomains = pgTable(
49
+ 'disposable_email_domains',
50
+ disposableEmailDomainColumns(),
51
+ );
52
+
43
53
  /**
44
54
  * The Google or GitHub accounts that sign in as a user: which provider and its ID, never its
45
55
  * tokens. Read through the system connection only.