@logto/cloud 0.2.5-fadb481

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +93 -0
  2. package/build/env-set/index.d.ts +5 -0
  3. package/build/index.d.ts +1 -0
  4. package/build/libraries/services.d.ts +16 -0
  5. package/build/libraries/tenants.d.ts +11 -0
  6. package/build/middleware/with-auth.d.ts +18 -0
  7. package/build/middleware/with-error-report.d.ts +5 -0
  8. package/build/middleware/with-http-proxy.d.ts +7 -0
  9. package/build/middleware/with-pathname.d.ts +11 -0
  10. package/build/middleware/with-security-headers.d.ts +2 -0
  11. package/build/middleware/with-spa.d.ts +28 -0
  12. package/build/models/checkout-sessions.d.ts +24 -0
  13. package/build/models/consts/subscription-plan-quota.d.ts +10 -0
  14. package/build/models/subscription-plans.d.ts +132 -0
  15. package/build/models/subscriptions-usage.d.ts +24 -0
  16. package/build/models/subscriptions.d.ts +31 -0
  17. package/build/models/tenants-subscriptions.d.ts +20 -0
  18. package/build/queries/application.d.ts +9 -0
  19. package/build/queries/connector.d.ts +11 -0
  20. package/build/queries/index.d.ts +104 -0
  21. package/build/queries/roles.d.ts +6 -0
  22. package/build/queries/service-logs.d.ts +10 -0
  23. package/build/queries/system.d.ts +22 -0
  24. package/build/queries/tenants.d.ts +30 -0
  25. package/build/queries/users.d.ts +7 -0
  26. package/build/queries/utils.d.ts +3 -0
  27. package/build/routes/index.d.ts +78 -0
  28. package/build/routes/services.d.ts +53 -0
  29. package/build/routes/tenants.d.ts +24 -0
  30. package/build/routes-anonymous/index.d.ts +13 -0
  31. package/build/test-utils/context.d.ts +14 -0
  32. package/build/test-utils/function.d.ts +1 -0
  33. package/build/test-utils/libraries.d.ts +26 -0
  34. package/build/utils/connector/index.d.ts +2 -0
  35. package/build/utils/connector/seed.d.ts +17 -0
  36. package/build/utils/connector/types.d.ts +11 -0
  37. package/build/utils/email-service/index.d.ts +13 -0
  38. package/build/utils/email-service/sendgrid.d.ts +6 -0
  39. package/build/utils/email-service/utils.d.ts +2 -0
  40. package/build/utils/guard.d.ts +3 -0
  41. package/build/utils/logto.d.ts +3 -0
  42. package/build/utils/postgres.d.ts +4 -0
  43. package/build/utils/query.d.ts +2 -0
  44. package/build/utils/tenant.d.ts +1 -0
  45. package/build/utils/url.d.ts +2 -0
  46. package/package.json +80 -0
package/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that
84
+ organization. **control** means ownership of substantially all the assets of an
85
+ entity, or the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
@@ -0,0 +1,5 @@
1
+ import { GlobalValues } from '@logto/shared';
2
+ export declare const EnvSet: {
3
+ global: GlobalValues;
4
+ readonly isProduction: boolean;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { SendMessagePayload, ConnectorType } from '@logto/connector-kit';
2
+ import type { ServiceLogType } from '@logto/schemas';
3
+ import type { Queries } from '#src/queries/index.js';
4
+ import type { LogtoConnector } from '#src/utils/connector/index.js';
5
+ export declare const serviceCountLimitForTenant = 100;
6
+ export declare class ServicesLibrary {
7
+ readonly queries: Queries;
8
+ constructor(queries: Queries);
9
+ getTenantIdFromApplicationId(applicationId: string): Promise<string | undefined>;
10
+ getAdminTenantLogtoConnectors(): Promise<LogtoConnector[]>;
11
+ sendMessage(type: ConnectorType.Email | ConnectorType.Sms, data: SendMessagePayload): Promise<unknown>;
12
+ sendEmail(data: SendMessagePayload): Promise<import("got").Response<string>>;
13
+ addLog(tenantId: string, type: ServiceLogType, payload?: unknown): Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
14
+ getTenantBalanceForType(tenantId: string, type: ServiceLogType): Promise<number>;
15
+ getTenantUsageByTypeFrom(tenantId: string, type: ServiceLogType, from?: Date): Promise<number>;
16
+ }
@@ -0,0 +1,11 @@
1
+ import { type TenantModel } from '@logto/schemas';
2
+ import type { TenantInfo } from '@logto/schemas/models';
3
+ import type { Queries } from '#src/queries/index.js';
4
+ export declare class TenantsLibrary {
5
+ readonly queries: Queries;
6
+ constructor(queries: Queries);
7
+ getAvailableTenants(userId: string): Promise<TenantInfo[]>;
8
+ updateTenantById(tenantId: string, payload: Partial<Pick<TenantModel, 'name' | 'tag'>>): Promise<TenantInfo>;
9
+ deleteTenantById(tenantId: string): Promise<void>;
10
+ createNewTenant(forUserId: string, payload: Partial<Pick<TenantModel, 'name' | 'tag'>>): Promise<TenantInfo>;
11
+ }
@@ -0,0 +1,18 @@
1
+ import type { IncomingHttpHeaders } from 'node:http';
2
+ import type { NextFunction, RequestContext } from '@withtyped/server';
3
+ export declare const extractBearerTokenFromHeaders: ({ authorization }: IncomingHttpHeaders) => string;
4
+ export type WithAuthContext<Context = RequestContext> = Context & {
5
+ auth: {
6
+ id: string;
7
+ scopes: string[];
8
+ };
9
+ };
10
+ export type WithAuthConfig = {
11
+ /** The Logto admin tenant endpoint. */
12
+ endpoint: URL;
13
+ /** The audience (i.e. Resource Indicator) to expect. */
14
+ audience: string;
15
+ /** The scopes (i.e. permissions) to expect. */
16
+ scopes?: string[];
17
+ };
18
+ export default function withAuth<InputContext extends RequestContext>({ endpoint, audience, scopes: expectScopes, }: WithAuthConfig): (context: InputContext, next: NextFunction<WithAuthContext<InputContext>>) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ import type { BaseContext, NextFunction } from '@withtyped/server';
2
+ /**
3
+ * Build a middleware function that reports error to Azure Application Insights.
4
+ */
5
+ export default function withErrorReport<InputContext extends BaseContext>(): (context: InputContext, next: NextFunction<InputContext>) => Promise<void>;
@@ -0,0 +1,7 @@
1
+ import type { HttpContext, NextFunction, RequestContext } from '@withtyped/server';
2
+ import type { ServerOptions } from 'http-proxy';
3
+ export type WithHttpProxyOptions = ServerOptions & {
4
+ /** An array of pathname prefixes to ignore. */
5
+ ignorePathnames?: string[];
6
+ };
7
+ export default function withHttpProxy<InputContext extends RequestContext>(pathname: string, { ignorePathnames, ...options }: WithHttpProxyOptions): (context: InputContext, next: NextFunction<InputContext>, { request, response }: HttpContext) => Promise<void>;
@@ -0,0 +1,11 @@
1
+ import type { HttpContext, MiddlewareFunction, NextFunction, RequestContext } from '@withtyped/server';
2
+ /**
3
+ * Build a middleware function that conditionally runs the given middleware function when:
4
+ *
5
+ * - The current pathname matches the given pathname prefix; and
6
+ * - `context.status` is unset (i.e. `undefined`).
7
+ *
8
+ * @param pathname The pathname prefix to match.
9
+ * @param run The middleware function to run with the prefix matches.
10
+ */
11
+ export default function withPathname<InputContext extends RequestContext, OutputContext extends RequestContext>(pathname: string, run: MiddlewareFunction<InputContext, InputContext | OutputContext>): (context: InputContext, next: NextFunction<InputContext | OutputContext>, httpContext: HttpContext) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { NextFunction, HttpContext, RequestContext } from '@withtyped/server';
2
+ export default function withSecurityHeaders<InputContext extends RequestContext>(): (context: InputContext, next: NextFunction<InputContext>, { response, request }: HttpContext) => Promise<void>;
@@ -0,0 +1,28 @@
1
+ import type { HttpContext, NextFunction, RequestContext } from '@withtyped/server';
2
+ export type WithSpaConfig = {
3
+ /**
4
+ * Browser cache max-age in seconds.
5
+ * @default 604_800 // 7 days
6
+ */
7
+ maxAge?: number;
8
+ /** The root directory to serve files. */
9
+ root: string;
10
+ /**
11
+ * The URL pathname to serve as root.
12
+ * @default '/'
13
+ */
14
+ pathname?: string;
15
+ /** An array of pathname prefixes to ignore. */
16
+ ignorePathnames?: string[];
17
+ /**
18
+ * The path to file to serve when the given path cannot be found in the file system.
19
+ * @default 'index.html'
20
+ */
21
+ indexPath?: string;
22
+ /**
23
+ * Explicitly disable cache for the index file in order to keep fresh and avoid cache invalidation issues.
24
+ * @default true
25
+ */
26
+ disableIndexCache?: boolean;
27
+ };
28
+ export default function withSpa<InputContext extends RequestContext>({ maxAge, root, pathname: rootPathname, ignorePathnames, indexPath: index, disableIndexCache, }: WithSpaConfig): (context: InputContext, next: NextFunction<InputContext>, { request }: HttpContext) => Promise<void>;
@@ -0,0 +1,24 @@
1
+ import { type InferModelType } from '@withtyped/server/model';
2
+ import { z } from 'zod';
3
+ /**
4
+ * This table is used for tracking user initialed checkout sessions.
5
+ * A successful checkout session trigger a subscription creation webhook.
6
+ * Logto will create a subscription record in the subscriptions table.
7
+ * Incase of a failed or delayed webhook event, we can use this table to fetch the session result.
8
+ *
9
+ *
10
+ * _id: should use the session id from stripe.
11
+ * _tenant_id: if present, the subscription is made for a existing tenant. Otherwise need to create a new tenant.
12
+ * _status: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-status
13
+ */
14
+ export declare const sessionStatusGuard: z.ZodUnion<[z.ZodLiteral<"open">, z.ZodLiteral<"complete">, z.ZodLiteral<"expired">]>;
15
+ export declare const CheckoutSessionsModel: import("@withtyped/server/model").default<"checkout_sessions", {
16
+ id: string;
17
+ tenantId: string | null;
18
+ userId: string;
19
+ planId: string;
20
+ status: "open" | "complete" | "expired";
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ }, never, never>;
24
+ export type CheckoutSessions = InferModelType<typeof CheckoutSessionsModel>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This is the default Logto subscription plan quota definition.
3
+ * For DB seed only, value may be outdated.
4
+ * Please refer to the DB data as the source of truth.
5
+ */
6
+ import { type SubscriptionPlanQuota, type SubscriptionPlans } from '../subscription-plans.js';
7
+ export declare const free: SubscriptionPlanQuota;
8
+ export declare const hobby: SubscriptionPlanQuota;
9
+ export declare const pro: SubscriptionPlanQuota;
10
+ export declare const seedData: Array<Omit<SubscriptionPlans, 'createdAt' | 'updatedAt'>>;
@@ -0,0 +1,132 @@
1
+ import { type InferModelType } from '@withtyped/server/model';
2
+ import { z } from 'zod';
3
+ export declare enum ProductType {
4
+ FlatRate = "FlatRate",
5
+ Tier1 = "tier1",
6
+ Tier2 = "tier2",
7
+ Tier3 = "tier3"
8
+ }
9
+ export declare const productGuard: z.ZodObject<{
10
+ id: z.ZodString;
11
+ name: z.ZodString;
12
+ type: z.ZodNativeEnum<typeof ProductType>;
13
+ description: z.ZodOptional<z.ZodString>;
14
+ price: z.ZodObject<{
15
+ id: z.ZodString;
16
+ unitAmount: z.ZodNumber;
17
+ unitAmountDecimal: z.ZodString;
18
+ }, "strip", z.ZodTypeAny, {
19
+ id: string;
20
+ unitAmount: number;
21
+ unitAmountDecimal: string;
22
+ }, {
23
+ id: string;
24
+ unitAmount: number;
25
+ unitAmountDecimal: string;
26
+ }>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ description?: string | undefined;
29
+ type: ProductType;
30
+ id: string;
31
+ name: string;
32
+ price: {
33
+ id: string;
34
+ unitAmount: number;
35
+ unitAmountDecimal: string;
36
+ };
37
+ }, {
38
+ description?: string | undefined;
39
+ type: ProductType;
40
+ id: string;
41
+ name: string;
42
+ price: {
43
+ id: string;
44
+ unitAmount: number;
45
+ unitAmountDecimal: string;
46
+ };
47
+ }>;
48
+ export declare const subscriptionPlanQuotaGuard: z.ZodObject<{
49
+ tenantLimit: z.ZodNullable<z.ZodNumber>;
50
+ mauLimit: z.ZodNullable<z.ZodNumber>;
51
+ applicationsLimit: z.ZodNumber;
52
+ machineToMachineLimit: z.ZodNumber;
53
+ resourcesLimit: z.ZodNumber;
54
+ scopesPerResourceLimit: z.ZodNumber;
55
+ customDomainEnabled: z.ZodBoolean;
56
+ omniSignInEnabled: z.ZodBoolean;
57
+ builtInEmailConnectorEnabled: z.ZodBoolean;
58
+ socialConnectorsLimit: z.ZodNullable<z.ZodNumber>;
59
+ standardConnectorsLimit: z.ZodNumber;
60
+ rolesLimit: z.ZodNumber;
61
+ scopesPerRoleLimit: z.ZodNullable<z.ZodNumber>;
62
+ hooksLimit: z.ZodNumber;
63
+ auditLogsRetentionDays: z.ZodNumber;
64
+ }, "strip", z.ZodTypeAny, {
65
+ tenantLimit: number | null;
66
+ mauLimit: number | null;
67
+ applicationsLimit: number;
68
+ machineToMachineLimit: number;
69
+ resourcesLimit: number;
70
+ scopesPerResourceLimit: number;
71
+ customDomainEnabled: boolean;
72
+ omniSignInEnabled: boolean;
73
+ builtInEmailConnectorEnabled: boolean;
74
+ socialConnectorsLimit: number | null;
75
+ standardConnectorsLimit: number;
76
+ rolesLimit: number;
77
+ scopesPerRoleLimit: number | null;
78
+ hooksLimit: number;
79
+ auditLogsRetentionDays: number;
80
+ }, {
81
+ tenantLimit: number | null;
82
+ mauLimit: number | null;
83
+ applicationsLimit: number;
84
+ machineToMachineLimit: number;
85
+ resourcesLimit: number;
86
+ scopesPerResourceLimit: number;
87
+ customDomainEnabled: boolean;
88
+ omniSignInEnabled: boolean;
89
+ builtInEmailConnectorEnabled: boolean;
90
+ socialConnectorsLimit: number | null;
91
+ standardConnectorsLimit: number;
92
+ rolesLimit: number;
93
+ scopesPerRoleLimit: number | null;
94
+ hooksLimit: number;
95
+ auditLogsRetentionDays: number;
96
+ }>;
97
+ export declare const SubscriptionPlansModel: import("@withtyped/server/model").default<"subscription_plans", {
98
+ id: string;
99
+ name: string;
100
+ products: {
101
+ description?: string | undefined;
102
+ type: ProductType;
103
+ id: string;
104
+ name: string;
105
+ price: {
106
+ id: string;
107
+ unitAmount: number;
108
+ unitAmountDecimal: string;
109
+ };
110
+ }[];
111
+ quota: {
112
+ tenantLimit: number | null;
113
+ mauLimit: number | null;
114
+ applicationsLimit: number;
115
+ machineToMachineLimit: number;
116
+ resourcesLimit: number;
117
+ scopesPerResourceLimit: number;
118
+ customDomainEnabled: boolean;
119
+ omniSignInEnabled: boolean;
120
+ builtInEmailConnectorEnabled: boolean;
121
+ socialConnectorsLimit: number | null;
122
+ standardConnectorsLimit: number;
123
+ rolesLimit: number;
124
+ scopesPerRoleLimit: number | null;
125
+ hooksLimit: number;
126
+ auditLogsRetentionDays: number;
127
+ };
128
+ createdAt: Date;
129
+ updatedAt: Date;
130
+ }, "createdAt" | "updatedAt" | "products", "createdAt">;
131
+ export type SubscriptionPlans = InferModelType<typeof SubscriptionPlansModel>;
132
+ export type SubscriptionPlanQuota = z.infer<typeof subscriptionPlanQuotaGuard>;
@@ -0,0 +1,24 @@
1
+ import { type InferModelType } from '@withtyped/server/model';
2
+ import { z } from 'zod';
3
+ import { ProductType } from './subscription-plans.js';
4
+ /**
5
+ * This table is used for recording and tracking the MAU based usage of a tenant for each business cycle.
6
+ * The same usage data record will be reported to stripe for billing.
7
+ *
8
+ * constraint subscriptions_usage__start_at: Usage record should be unique for each business cycle.
9
+ * constraint subscriptions_usage__linear_range: start_at should be earlier than end_at.
10
+ * exclude using gist: Prevent overlapping usage records for the same subscription.
11
+ */
12
+ export declare const usageGuard: z.ZodRecord<z.ZodNativeEnum<typeof ProductType>, z.ZodNumber>;
13
+ export declare const SubscriptionsUsageModel: import("@withtyped/server/model").default<"subscriptions_usage", {
14
+ updatedAt: Date;
15
+ id: string;
16
+ subscriptionId: string;
17
+ startAt: Date;
18
+ endAt: Date | null;
19
+ usage: Partial<Record<ProductType, number>>;
20
+ exclude: null;
21
+ "'[)')": null;
22
+ }, "usage", never>;
23
+ export type UsageType = z.infer<typeof usageGuard>;
24
+ export type SubscriptionsUsage = InferModelType<typeof SubscriptionsUsageModel>;
@@ -0,0 +1,31 @@
1
+ import { type InferModelType } from '@withtyped/server/model';
2
+ import { z } from 'zod';
3
+ /**
4
+ * Stripe Subscription Object
5
+ * https://stripe.com/docs/api/subscriptions/object
6
+ */
7
+ export declare const subscriptionStatusGuard: z.ZodUnion<[z.ZodLiteral<"incomplete">, z.ZodLiteral<"incomplete_expired">, z.ZodLiteral<"trialing">, z.ZodLiteral<"active">, z.ZodLiteral<"past_due">, z.ZodLiteral<"canceled">, z.ZodLiteral<"unpaid">]>;
8
+ /**
9
+ * _tenant_id:
10
+ * Refrain from marking tenant_id as a foreign key in this case,
11
+ * as the parent tenant data may undergo hard deletion,
12
+ * while it is necessary to retain the subscription data for billing purposes.
13
+ * Need to validate the tenant_id exclusively in the application layer.
14
+ *
15
+ * _plan_id:
16
+ * Can not delete a subscription plan if it is being used by a tenant.
17
+ */
18
+ export declare const SubscriptionsModel: import("@withtyped/server/model").default<"subscriptions", {
19
+ planId: string;
20
+ status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "canceled" | "unpaid";
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ id: string;
24
+ tenantId: string;
25
+ currentPeriodStart: Date;
26
+ currentPeriodEnd: Date;
27
+ customerId: string;
28
+ latestInvoiceId: string | null;
29
+ canceledAt: Date | null;
30
+ }, never, never>;
31
+ export type Subscriptions = InferModelType<typeof SubscriptionsModel>;
@@ -0,0 +1,20 @@
1
+ import { type InferModelType } from '@withtyped/server/model';
2
+ /**
3
+ * Create a tenants_subscriptions relation record only on tenant first ever sign up a paid plan.
4
+ * If no record found, the tenant is on a free plan and never had a stripe payment before.
5
+ *
6
+ * _current_subscription_id:
7
+ * Can not delete a subscription if it is being used by a tenant.
8
+ * Remain null for free plan tenants.
9
+ *
10
+ * _customer_id:
11
+ * constraint unique customer_id for each tenant.
12
+ */
13
+ export declare const TenantsSubscriptionsModel: import("@withtyped/server/model").default<"tenants_subscriptions", {
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ customerId: string;
17
+ tenantId: string;
18
+ currentSubscriptionId: string | null;
19
+ }, "createdAt" | "updatedAt", "createdAt">;
20
+ export type TenantsSubscriptions = InferModelType<typeof TenantsSubscriptionsModel>;
@@ -0,0 +1,9 @@
1
+ import type { Application, CreateApplication, CreateApplicationsRole } from '@logto/schemas';
2
+ import type { PostgreSql } from '@withtyped/postgres';
3
+ import type { Queryable } from '@withtyped/server';
4
+ export type ApplicationsQuery = ReturnType<typeof createApplicationsQueries>;
5
+ export declare const createApplicationsQueries: (client: Queryable<PostgreSql>) => {
6
+ insertApplication: (data: CreateApplication) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
7
+ assignRoleToApplication: (data: CreateApplicationsRole) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
8
+ findApplicationById: (id: string, tenantId: string) => Promise<Application>;
9
+ };
@@ -0,0 +1,11 @@
1
+ import type { Connector, CreateConnector } from '@logto/schemas';
2
+ import type { PostgreSql } from '@withtyped/postgres';
3
+ import type { JsonObject, Queryable } from '@withtyped/server';
4
+ export type ConnectorsQuery = ReturnType<typeof createConnectorsQuery>;
5
+ export declare const createConnectorsQuery: (client: Queryable<PostgreSql>) => {
6
+ findAllConnectors: (tenantId: string) => Promise<Connector[]>;
7
+ insertConnector: (connector: Pick<CreateConnector, 'id' | 'tenantId' | 'connectorId'> & {
8
+ config: JsonObject;
9
+ metadata?: JsonObject;
10
+ }) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
11
+ };
@@ -0,0 +1,104 @@
1
+ export declare class Queries {
2
+ static default: Queries;
3
+ readonly client: import("@withtyped/postgres").PostgresQueryClient;
4
+ readonly tenants: {
5
+ getManagementApiLikeIndicatorsForUser: (userId: string) => Promise<import("@withtyped/server").QueryResult<{
6
+ indicator: string;
7
+ }>>;
8
+ insertTenant: (tenant: Pick<{
9
+ id: string;
10
+ dbUser: string | null;
11
+ dbUserPassword: string | null;
12
+ name: string;
13
+ tag: import("@logto/schemas/lib/models/tenants.js").TenantTag;
14
+ createdAt: Date;
15
+ }, "id" | "dbUser" | "dbUserPassword"> & Partial<Pick<{
16
+ id: string;
17
+ dbUser: string | null;
18
+ dbUserPassword: string | null;
19
+ name: string;
20
+ tag: import("@logto/schemas/lib/models/tenants.js").TenantTag;
21
+ createdAt: Date;
22
+ }, "name" | "tag">>) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
23
+ updateTenantById: (tenantId: string, payload: Partial<Pick<{
24
+ id: string;
25
+ dbUser: string | null;
26
+ dbUserPassword: string | null;
27
+ name: string;
28
+ tag: import("@logto/schemas/lib/models/tenants.js").TenantTag;
29
+ createdAt: Date;
30
+ }, "name" | "tag">>) => Promise<{
31
+ id: string;
32
+ dbUser: string | null;
33
+ dbUserPassword: string | null;
34
+ name: string;
35
+ tag: import("@logto/schemas/lib/models/tenants.js").TenantTag;
36
+ createdAt: Date;
37
+ }>;
38
+ createTenantRole: (parentRole: string, role: string, password: string) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
39
+ deleteDatabaseRoleForTenant: (role: string) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
40
+ insertAdminData: (data: import("@logto/schemas").AdminData) => Promise<void>;
41
+ getTenantById: (id: string) => Promise<Pick<{
42
+ id: string;
43
+ dbUser: string | null;
44
+ dbUserPassword: string | null;
45
+ name: string;
46
+ tag: import("@logto/schemas/lib/models/tenants.js").TenantTag;
47
+ createdAt: Date;
48
+ }, "name" | "tag" | "dbUser">>;
49
+ getTenantsByIds: (tenantIds: string[]) => Promise<Pick<{
50
+ id: string;
51
+ dbUser: string | null;
52
+ dbUserPassword: string | null;
53
+ name: string;
54
+ tag: import("@logto/schemas/lib/models/tenants.js").TenantTag;
55
+ createdAt: Date;
56
+ }, "id" | "name" | "tag">[]>;
57
+ deleteClientTenantManagementApplicationById: (tenantId: string) => Promise<void>;
58
+ deleteClientTenantManagementApiResourceByTenantId: (tenantId: string) => Promise<void>;
59
+ deleteClientTenantRoleById: (tenantId: string) => Promise<void>;
60
+ deleteTenantById: (id: string) => Promise<void>;
61
+ appendAdminConsoleRedirectUris: (...urls: URL[]) => Promise<void>;
62
+ removeUrisFromAdminConsoleRedirectUris: (...urls: URL[]) => Promise<void>;
63
+ };
64
+ readonly users: {
65
+ assignRoleToUser: (data: import("@logto/schemas").UsersRole) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
66
+ };
67
+ readonly applications: {
68
+ insertApplication: (data: import("@logto/schemas").CreateApplication) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
69
+ assignRoleToApplication: (data: import("@logto/schemas").CreateApplicationsRole) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
70
+ findApplicationById: (id: string, tenantId: string) => Promise<import("@logto/schemas").Application>;
71
+ };
72
+ readonly connectors: {
73
+ findAllConnectors: (tenantId: string) => Promise<import("@logto/schemas").Connector[]>;
74
+ insertConnector: (connector: Pick<import("@logto/schemas").CreateConnector, "tenantId" | "id" | "connectorId"> & {
75
+ config: import("@withtyped/server").JsonObject;
76
+ metadata?: import("@withtyped/server").JsonObject | undefined;
77
+ }) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
78
+ };
79
+ readonly serviceLogs: {
80
+ insertLog: (data: Omit<import("@logto/schemas").CreateServiceLog, "payload"> & {
81
+ payload?: import("@withtyped/server").JsonObject | undefined;
82
+ }) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
83
+ countTenantLogs: (tenantId: string, type: import("@logto/schemas").ServiceLogType, from?: Date | undefined) => Promise<number>;
84
+ };
85
+ readonly systems: {
86
+ getDemoSocialValue: () => Promise<{
87
+ name: string;
88
+ logo: string;
89
+ logoDark: string;
90
+ provider: import("@logto/schemas").DemoSocialProvider;
91
+ clientId: string;
92
+ }[] | undefined>;
93
+ getEmailServiceConfig: () => Promise<{
94
+ provider: import("@logto/schemas").EmailServiceProvider;
95
+ apiKey: string;
96
+ fromName: string;
97
+ fromEmail: string;
98
+ templates: Partial<Record<import("@logto/schemas").OtherEmailTemplate | import("@logto/connector-kit").VerificationCodeType, {
99
+ subject: string;
100
+ content: string;
101
+ }>>;
102
+ } | undefined>;
103
+ };
104
+ }
@@ -0,0 +1,6 @@
1
+ import type { PostgreSql } from '@withtyped/postgres';
2
+ import type { Queryable } from '@withtyped/server';
3
+ export type RolesQuery = ReturnType<typeof createRolesQuery>;
4
+ export declare const createRolesQuery: (client: Queryable<PostgreSql>) => {
5
+ findRoleIdByName: (roleName: string, tenantId: string) => Promise<string>;
6
+ };
@@ -0,0 +1,10 @@
1
+ import type { CreateServiceLog, ServiceLogType } from '@logto/schemas';
2
+ import type { PostgreSql } from '@withtyped/postgres';
3
+ import type { JsonObject, Queryable } from '@withtyped/server';
4
+ export type ServiceLogsQueries = ReturnType<typeof createServiceLogsQueries>;
5
+ export declare const createServiceLogsQueries: (client: Queryable<PostgreSql>) => {
6
+ insertLog: (data: Omit<CreateServiceLog, 'payload'> & {
7
+ payload?: JsonObject;
8
+ }) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
9
+ countTenantLogs: (tenantId: string, type: ServiceLogType, from?: Date) => Promise<number>;
10
+ };
@@ -0,0 +1,22 @@
1
+ import type { PostgreSql } from '@withtyped/postgres';
2
+ import type { Queryable } from '@withtyped/server';
3
+ export type SystemsQuery = ReturnType<typeof createSystemsQuery>;
4
+ export declare const createSystemsQuery: (client: Queryable<PostgreSql>) => {
5
+ getDemoSocialValue: () => Promise<{
6
+ name: string;
7
+ logo: string;
8
+ logoDark: string;
9
+ provider: import("@logto/schemas").DemoSocialProvider;
10
+ clientId: string;
11
+ }[] | undefined>;
12
+ getEmailServiceConfig: () => Promise<{
13
+ provider: import("@logto/schemas").EmailServiceProvider;
14
+ apiKey: string;
15
+ fromName: string;
16
+ fromEmail: string;
17
+ templates: Partial<Record<import("@logto/schemas").OtherEmailTemplate | import("@logto/connector-kit").VerificationCodeType, {
18
+ subject: string;
19
+ content: string;
20
+ }>>;
21
+ } | undefined>;
22
+ };
@@ -0,0 +1,30 @@
1
+ import { type AdminData } from '@logto/schemas';
2
+ import type { TenantModel } from '@logto/schemas/models';
3
+ import { type PostgreSql } from '@withtyped/postgres';
4
+ import type { Queryable } from '@withtyped/server';
5
+ export type TenantsQueries = ReturnType<typeof createTenantsQueries>;
6
+ export declare const createTenantsQueries: (client: Queryable<PostgreSql>) => {
7
+ getManagementApiLikeIndicatorsForUser: (userId: string) => Promise<import("@withtyped/server").QueryResult<{
8
+ indicator: string;
9
+ }>>;
10
+ insertTenant: (tenant: Pick<TenantModel, 'id' | 'dbUser' | 'dbUserPassword'> & Partial<Pick<TenantModel, 'name' | 'tag'>>) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
11
+ updateTenantById: (tenantId: string, payload: Partial<Pick<TenantModel, 'name' | 'tag'>>) => Promise<{
12
+ id: string;
13
+ dbUser: string | null;
14
+ dbUserPassword: string | null;
15
+ name: string;
16
+ tag: import("@logto/schemas/models").TenantTag;
17
+ createdAt: Date;
18
+ }>;
19
+ createTenantRole: (parentRole: string, role: string, password: string) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
20
+ deleteDatabaseRoleForTenant: (role: string) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
21
+ insertAdminData: (data: AdminData) => Promise<void>;
22
+ getTenantById: (id: string) => Promise<Pick<TenantModel, 'dbUser' | 'name' | 'tag'>>;
23
+ getTenantsByIds: (tenantIds: string[]) => Promise<Array<Pick<TenantModel, 'id' | 'name' | 'tag'>>>;
24
+ deleteClientTenantManagementApplicationById: (tenantId: string) => Promise<void>;
25
+ deleteClientTenantManagementApiResourceByTenantId: (tenantId: string) => Promise<void>;
26
+ deleteClientTenantRoleById: (tenantId: string) => Promise<void>;
27
+ deleteTenantById: (id: string) => Promise<void>;
28
+ appendAdminConsoleRedirectUris: (...urls: URL[]) => Promise<void>;
29
+ removeUrisFromAdminConsoleRedirectUris: (...urls: URL[]) => Promise<void>;
30
+ };
@@ -0,0 +1,7 @@
1
+ import type { UsersRole } from '@logto/schemas';
2
+ import type { PostgreSql } from '@withtyped/postgres';
3
+ import type { Queryable } from '@withtyped/server';
4
+ export type UsersQueries = ReturnType<typeof createUsersQueries>;
5
+ export declare const createUsersQueries: (client: Queryable<PostgreSql>) => {
6
+ assignRoleToUser: (data: UsersRole) => Promise<import("@withtyped/server").QueryResult<Record<string, unknown>>>;
7
+ };
@@ -0,0 +1,3 @@
1
+ import type { PostgreSql } from '@withtyped/postgres';
2
+ import type { Queryable } from '@withtyped/server';
3
+ export declare const getDatabaseName: (client: Queryable<PostgreSql>) => Promise<string>;
@@ -0,0 +1,78 @@
1
+ import type { WithAuthContext } from '#src/middleware/with-auth.js';
2
+ declare const router: import("@withtyped/server").Router<WithAuthContext, import("@withtyped/server").MergeRoutes<import("@withtyped/server").MergeRoutes<import("@withtyped/server").BaseRoutes, import("@withtyped/server").RoutesWithPrefix<{
3
+ options: {};
4
+ patch: {
5
+ "/tenants/:tenantId": import("@withtyped/server").PathGuard<"/:tenantId", unknown, {
6
+ name?: string | undefined;
7
+ tag?: import("@logto/schemas/lib/models/tenants.js").TenantTag | undefined;
8
+ }, import("@logto/schemas/lib/models/tenants.js").TenantInfo>;
9
+ };
10
+ get: {
11
+ "/tenants": import("@withtyped/server").PathGuard<"/", unknown, unknown, import("@logto/schemas/lib/models/tenants.js").TenantInfo[]>;
12
+ };
13
+ post: {
14
+ "/tenants": import("@withtyped/server").PathGuard<"/", unknown, {
15
+ name?: string | undefined;
16
+ tag?: import("@logto/schemas/lib/models/tenants.js").TenantTag | undefined;
17
+ }, import("@logto/schemas/lib/models/tenants.js").TenantInfo>;
18
+ };
19
+ put: {};
20
+ head: {};
21
+ delete: {
22
+ "/tenants/:tenantId": import("@withtyped/server").PathGuard<"/:tenantId", unknown, unknown, unknown>;
23
+ };
24
+ copy: {};
25
+ }, "/api">>, import("@withtyped/server").RoutesWithPrefix<{
26
+ options: {};
27
+ patch: {};
28
+ get: {
29
+ "/services/mails/usage": import("@withtyped/server").PathGuard<"/mails/usage", {
30
+ from?: string | undefined;
31
+ }, unknown, unknown>;
32
+ };
33
+ post: {
34
+ "/services/send-email": import("@withtyped/server").PathGuard<"/send-email", unknown, {
35
+ data: {
36
+ type: import("@logto/connector-kit").VerificationCodeType;
37
+ to: string;
38
+ payload: {
39
+ fromName?: string | undefined;
40
+ companyAddress?: string | undefined;
41
+ appLogo?: string | undefined;
42
+ code: string;
43
+ };
44
+ };
45
+ }, unknown>;
46
+ } & {
47
+ "/services/mails": import("@withtyped/server").PathGuard<"/mails", unknown, {
48
+ data: {
49
+ type: import("@logto/connector-kit").VerificationCodeType;
50
+ to: string;
51
+ payload: {
52
+ fromName?: string | undefined;
53
+ companyAddress?: string | undefined;
54
+ appLogo?: string | undefined;
55
+ code: string;
56
+ };
57
+ };
58
+ }, unknown>;
59
+ } & {
60
+ "/services/send-sms": import("@withtyped/server").PathGuard<"/send-sms", unknown, {
61
+ data: {
62
+ type: import("@logto/connector-kit").VerificationCodeType;
63
+ to: string;
64
+ payload: {
65
+ fromName?: string | undefined;
66
+ companyAddress?: string | undefined;
67
+ appLogo?: string | undefined;
68
+ code: string;
69
+ };
70
+ };
71
+ }, unknown>;
72
+ };
73
+ put: {};
74
+ head: {};
75
+ delete: {};
76
+ copy: {};
77
+ }, "/api">>, "/api">;
78
+ export default router;
@@ -0,0 +1,53 @@
1
+ import type { ServicesLibrary } from '#src/libraries/services.js';
2
+ import type { WithAuthContext } from '#src/middleware/with-auth.js';
3
+ export declare const servicesRoutes: (library: ServicesLibrary) => import("@withtyped/server").RouterWithRoute<WithAuthContext, {
4
+ options: {};
5
+ patch: {};
6
+ get: {
7
+ "/services/mails/usage": import("@withtyped/server").PathGuard<"/mails/usage", {
8
+ from?: string | undefined;
9
+ }, unknown, unknown>;
10
+ };
11
+ post: {
12
+ "/services/send-email": import("@withtyped/server").PathGuard<"/send-email", unknown, {
13
+ data: {
14
+ type: import("@logto/connector-kit").VerificationCodeType;
15
+ to: string;
16
+ payload: {
17
+ fromName?: string | undefined;
18
+ companyAddress?: string | undefined;
19
+ appLogo?: string | undefined;
20
+ code: string;
21
+ };
22
+ };
23
+ }, unknown>;
24
+ } & {
25
+ "/services/mails": import("@withtyped/server").PathGuard<"/mails", unknown, {
26
+ data: {
27
+ type: import("@logto/connector-kit").VerificationCodeType;
28
+ to: string;
29
+ payload: {
30
+ fromName?: string | undefined;
31
+ companyAddress?: string | undefined;
32
+ appLogo?: string | undefined;
33
+ code: string;
34
+ };
35
+ };
36
+ }, unknown>;
37
+ };
38
+ put: {};
39
+ head: {};
40
+ delete: {};
41
+ copy: {};
42
+ }, "/services", "post", "/send-sms", unknown, {
43
+ data: {
44
+ type: import("@logto/connector-kit").VerificationCodeType;
45
+ to: string;
46
+ payload: {
47
+ fromName?: string | undefined;
48
+ companyAddress?: string | undefined;
49
+ appLogo?: string | undefined;
50
+ code: string;
51
+ };
52
+ };
53
+ }, unknown>;
@@ -0,0 +1,24 @@
1
+ import type { TenantsLibrary } from '#src/libraries/tenants.js';
2
+ import type { WithAuthContext } from '#src/middleware/with-auth.js';
3
+ export declare const tenantsRoutes: (library: TenantsLibrary) => import("@withtyped/server").RouterWithRoute<WithAuthContext, {
4
+ options: {};
5
+ patch: {
6
+ "/tenants/:tenantId": import("@withtyped/server").PathGuard<"/:tenantId", unknown, {
7
+ name?: string | undefined;
8
+ tag?: import("@logto/schemas/models").TenantTag | undefined;
9
+ }, import("@logto/schemas/models").TenantInfo>;
10
+ };
11
+ get: {
12
+ "/tenants": import("@withtyped/server").PathGuard<"/", unknown, unknown, import("@logto/schemas/models").TenantInfo[]>;
13
+ };
14
+ post: {
15
+ "/tenants": import("@withtyped/server").PathGuard<"/", unknown, {
16
+ name?: string | undefined;
17
+ tag?: import("@logto/schemas/models").TenantTag | undefined;
18
+ }, import("@logto/schemas/models").TenantInfo>;
19
+ };
20
+ put: {};
21
+ head: {};
22
+ delete: {};
23
+ copy: {};
24
+ }, "/tenants", "delete", "/:tenantId", unknown, unknown, unknown>;
@@ -0,0 +1,13 @@
1
+ declare const router: import("@withtyped/server").RouterWithRoute<import("@withtyped/server").RequestContext, {
2
+ options: {};
3
+ patch: {};
4
+ get: {
5
+ "/api/status": import("@withtyped/server").PathGuard<"/status", unknown, unknown, unknown>;
6
+ };
7
+ post: {};
8
+ put: {};
9
+ head: {};
10
+ delete: {};
11
+ copy: {};
12
+ }, "/api", "get", "/teapot", unknown, unknown, unknown>;
13
+ export default router;
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node/http.js" />
3
+ import type { HttpContext, RequestContext, RequestMethod } from '@withtyped/server';
4
+ import type { WithAuthContext } from '#src/middleware/with-auth.js';
5
+ export declare const createHttpContext: (isHttps?: boolean) => HttpContext;
6
+ type BuildRequestContext = Partial<RequestContext['request']>;
7
+ export declare const buildRequestContext: <Path extends `GET ${string}` | `POST ${string}` | `PUT ${string}` | `PATCH ${string}` | `DELETE ${string}` | `COPY ${string}` | `HEAD ${string}` | `OPTIONS ${string}`>(path: Path, { headers, body }?: BuildRequestContext) => RequestContext;
8
+ export declare const buildRequestAuthContext: <Path extends `GET ${string}` | `POST ${string}` | `PUT ${string}` | `PATCH ${string}` | `DELETE ${string}` | `COPY ${string}` | `HEAD ${string}` | `OPTIONS ${string}`>(args_0: Path, args_1?: Partial<Record<string, unknown> & {
9
+ method?: RequestMethod | undefined;
10
+ headers: import("http").IncomingHttpHeaders;
11
+ url: URL;
12
+ body?: unknown;
13
+ }> | undefined) => (scopes?: string[]) => WithAuthContext;
14
+ export {};
@@ -0,0 +1 @@
1
+ export declare const noop: () => Promise<void>;
@@ -0,0 +1,26 @@
1
+ /// <reference types="jest" />
2
+ import type { ServiceLogType } from '@logto/schemas';
3
+ import type { TenantInfo, TenantTag } from '@logto/schemas/models';
4
+ import type { ServicesLibrary } from '#src/libraries/services.js';
5
+ import type { TenantsLibrary } from '#src/libraries/tenants.js';
6
+ import type { Queries } from '#src/queries/index.js';
7
+ export declare class MockTenantsLibrary implements TenantsLibrary {
8
+ get queries(): Queries;
9
+ getAvailableTenants: jest.Mock<Promise<TenantInfo[]>, [string], any>;
10
+ createNewTenant: jest.Mock<Promise<TenantInfo>, [string, Record<string, unknown>], any>;
11
+ updateTenantById: jest.Mock<Promise<TenantInfo>, [string, {
12
+ name?: string | undefined;
13
+ tag?: TenantTag | undefined;
14
+ }], any>;
15
+ deleteTenantById: jest.Mock<Promise<void>, [string], any>;
16
+ }
17
+ export declare class MockServicesLibrary implements ServicesLibrary {
18
+ get queries(): Queries;
19
+ getTenantIdFromApplicationId: jest.Mock<Promise<string>, [string], any>;
20
+ sendMessage: jest.Mock<any, any, any>;
21
+ sendEmail: jest.Mock<any, any, any>;
22
+ getAdminTenantLogtoConnectors: jest.Mock<any, any, any>;
23
+ addLog: jest.Mock<any, any, any>;
24
+ getTenantBalanceForType: jest.Mock<Promise<number>, [string, ServiceLogType], any>;
25
+ getTenantUsageByTypeFrom: jest.Mock<Promise<number>, [string, ServiceLogType, Date], any>;
26
+ }
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export declare const loadConnectorFactories: () => Promise<import("@logto/cli/lib/connector/types.js").ConnectorFactory[]>;
@@ -0,0 +1,17 @@
1
+ export declare const createCloudServiceConnector: (data: {
2
+ tenantId: string;
3
+ connectorId: string;
4
+ appId: string;
5
+ appSecret: string;
6
+ }) => {
7
+ id: string;
8
+ tenantId: string;
9
+ connectorId: string;
10
+ config: {
11
+ appId: string;
12
+ appSecret: string;
13
+ tokenEndpoint: string;
14
+ endpoint: string;
15
+ resource: string;
16
+ };
17
+ };
@@ -0,0 +1,11 @@
1
+ import type { AllConnector } from '@logto/connector-kit';
2
+ import type { Connector } from '@logto/schemas';
3
+ export { ConnectorType } from '@logto/schemas';
4
+ /**
5
+ * The connector type with full context.
6
+ */
7
+ export type LogtoConnector<T extends AllConnector = AllConnector> = T & {
8
+ validateConfig: (config: unknown) => void;
9
+ } & {
10
+ dbEntry: Connector;
11
+ };
@@ -0,0 +1,13 @@
1
+ import { type EmailServiceData } from '@logto/schemas';
2
+ export declare const buildEmailService: (config: EmailServiceData) => {
3
+ send: (sendMessagePayload: {
4
+ type: import("@logto/connector-kit").VerificationCodeType;
5
+ to: string;
6
+ payload: {
7
+ fromName?: string | undefined;
8
+ companyAddress?: string | undefined;
9
+ appLogo?: string | undefined;
10
+ code: string;
11
+ };
12
+ }) => Promise<import("got").Response<string>>;
13
+ };
@@ -0,0 +1,6 @@
1
+ import type { SendMessagePayload } from '@logto/connector-kit';
2
+ import { type SendgridEmailServiceData } from '@logto/schemas';
3
+ export declare const sendgridEndpoint = "https://api.sendgrid.com/v3/mail/send";
4
+ export declare const buildSendgridEmailService: (config: SendgridEmailServiceData) => {
5
+ send: (sendMessagePayload: SendMessagePayload) => Promise<import("got").Response<string>>;
6
+ };
@@ -0,0 +1,2 @@
1
+ import { type Optional } from '@silverhand/essentials';
2
+ export declare const replacePlaceholders: (rawContent: string, patterns: Record<string, Optional<string>>) => string;
@@ -0,0 +1,3 @@
1
+ import type { Json } from '@withtyped/server';
2
+ import { z } from 'zod';
3
+ export declare const jsonObjectGuard: z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>;
@@ -0,0 +1,3 @@
1
+ export declare const findLogtoInstanceDirectory: () => Promise<string>;
2
+ export declare const getLogtoConsoleAppDirectory: () => Promise<string>;
3
+ export declare const getLogtoCoreConnectorsDirectory: () => Promise<string>;
@@ -0,0 +1,4 @@
1
+ import type { createQueryClient } from '@withtyped/postgres';
2
+ type CreateClientConfig = Parameters<typeof createQueryClient>[0];
3
+ export declare const parseDsn: (dsn?: string) => CreateClientConfig;
4
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { JsonObject } from '@withtyped/server';
2
+ export declare const insertInto: <T extends JsonObject>(object: T, table: string) => import("@withtyped/postgres").PostgreSql;
@@ -0,0 +1 @@
1
+ export declare const getTenantIdFromManagementApiIndicator: (indicator: string) => string | undefined;
@@ -0,0 +1,2 @@
1
+ export declare const normalizePath: (pathLike: string) => string;
2
+ export declare const matchPathname: (toMatch: string, pathname: string, ignorePathnames?: string[]) => string | false;
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@logto/cloud",
3
+ "version": "0.2.5-fadb481",
4
+ "description": "Logto Cloud service.",
5
+ "main": "build/index.js",
6
+ "author": "Silverhand Inc. <contact@silverhand.io>",
7
+ "license": "Elastic-2.0",
8
+ "type": "module",
9
+ "files": [
10
+ "build"
11
+ ],
12
+ "exports": {
13
+ "./routes": "./build/routes/index.js"
14
+ },
15
+ "imports": {
16
+ "#src/*": "./build/*"
17
+ },
18
+ "dependencies": {
19
+ "@logto/app-insights": "link:../../.logto/packages/app-insights",
20
+ "@logto/cli": "link:../../.logto/packages/cli",
21
+ "@logto/connector-kit": "link:../../.logto/packages/toolkit/connector-kit",
22
+ "@logto/core-kit": "link:../../.logto/packages/toolkit/core-kit",
23
+ "@logto/schemas": "link:../../.logto/packages/schemas",
24
+ "@logto/shared": "link:../../.logto/packages/shared",
25
+ "@silverhand/essentials": "^2.6.2",
26
+ "@withtyped/postgres": "^0.11.0",
27
+ "@withtyped/server": "^0.11.1",
28
+ "accepts": "^1.3.8",
29
+ "chalk": "^5.0.0",
30
+ "decamelize": "^6.0.0",
31
+ "dotenv": "^16.0.0",
32
+ "fetch-retry": "^5.0.4",
33
+ "find-up": "^6.3.0",
34
+ "got": "^13.0.0",
35
+ "helmet": "^7.0.0",
36
+ "http-proxy": "^1.18.1",
37
+ "jose": "^4.11.0",
38
+ "mime-types": "^2.1.35",
39
+ "zod": "^3.20.2"
40
+ },
41
+ "devDependencies": {
42
+ "@silverhand/eslint-config": "3.0.1",
43
+ "@silverhand/jest-config": "3.0.0",
44
+ "@silverhand/ts-config": "3.0.0",
45
+ "@types/accepts": "^1.3.5",
46
+ "@types/http-proxy": "^1.17.9",
47
+ "@types/jest": "^29.4.0",
48
+ "@types/mime-types": "^2.1.1",
49
+ "@types/node": "^18.11.18",
50
+ "eslint": "^8.21.0",
51
+ "jest": "^29.5.0",
52
+ "lint-staged": "^13.0.0",
53
+ "nodemon": "^2.0.19",
54
+ "prettier": "^2.8.1",
55
+ "typescript": "^5.0.0"
56
+ },
57
+ "engines": {
58
+ "node": "^18.12.0"
59
+ },
60
+ "eslintConfig": {
61
+ "extends": "@silverhand"
62
+ },
63
+ "prettier": "@silverhand/eslint-config/.prettierrc",
64
+ "publishConfig": {
65
+ "access": "public"
66
+ },
67
+ "scripts": {
68
+ "precommit": "lint-staged",
69
+ "build": "rm -rf build/ && tsc -p tsconfig.build.json",
70
+ "build:lib": "rm -rf build/ && tsc -p tsconfig.build.lib.json",
71
+ "build:test": "rm -rf build/ && tsc -p tsconfig.test.json --sourcemap",
72
+ "lint": "eslint --ext .ts src",
73
+ "lint:report": "pnpm lint --format json --output-file report.json",
74
+ "dev": "rm -rf build/ && nodemon",
75
+ "start": "NODE_ENV=production node .",
76
+ "test:only": "NODE_OPTIONS=\"--experimental-vm-modules --max_old_space_size=4096\" jest --logHeapUsage",
77
+ "test": "pnpm build:test && pnpm test:only",
78
+ "test:ci": "pnpm test:only --coverage --silent"
79
+ }
80
+ }