@logto/cloud 0.2.5-fadb481 → 0.2.5-fd82773
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/lib/routes/index.d.ts +1442 -0
- package/package.json +34 -45
- package/build/env-set/index.d.ts +0 -5
- package/build/index.d.ts +0 -1
- package/build/libraries/services.d.ts +0 -16
- package/build/libraries/tenants.d.ts +0 -11
- package/build/middleware/with-auth.d.ts +0 -18
- package/build/middleware/with-error-report.d.ts +0 -5
- package/build/middleware/with-http-proxy.d.ts +0 -7
- package/build/middleware/with-pathname.d.ts +0 -11
- package/build/middleware/with-security-headers.d.ts +0 -2
- package/build/middleware/with-spa.d.ts +0 -28
- package/build/models/checkout-sessions.d.ts +0 -24
- package/build/models/consts/subscription-plan-quota.d.ts +0 -10
- package/build/models/subscription-plans.d.ts +0 -132
- package/build/models/subscriptions-usage.d.ts +0 -24
- package/build/models/subscriptions.d.ts +0 -31
- package/build/models/tenants-subscriptions.d.ts +0 -20
- package/build/queries/application.d.ts +0 -9
- package/build/queries/connector.d.ts +0 -11
- package/build/queries/index.d.ts +0 -104
- package/build/queries/roles.d.ts +0 -6
- package/build/queries/service-logs.d.ts +0 -10
- package/build/queries/system.d.ts +0 -22
- package/build/queries/tenants.d.ts +0 -30
- package/build/queries/users.d.ts +0 -7
- package/build/queries/utils.d.ts +0 -3
- package/build/routes/index.d.ts +0 -78
- package/build/routes/services.d.ts +0 -53
- package/build/routes/tenants.d.ts +0 -24
- package/build/routes-anonymous/index.d.ts +0 -13
- package/build/test-utils/context.d.ts +0 -14
- package/build/test-utils/function.d.ts +0 -1
- package/build/test-utils/libraries.d.ts +0 -26
- package/build/utils/connector/index.d.ts +0 -2
- package/build/utils/connector/seed.d.ts +0 -17
- package/build/utils/connector/types.d.ts +0 -11
- package/build/utils/email-service/index.d.ts +0 -13
- package/build/utils/email-service/sendgrid.d.ts +0 -6
- package/build/utils/email-service/utils.d.ts +0 -2
- package/build/utils/guard.d.ts +0 -3
- package/build/utils/logto.d.ts +0 -3
- package/build/utils/postgres.d.ts +0 -4
- package/build/utils/query.d.ts +0 -2
- package/build/utils/tenant.d.ts +0 -1
- package/build/utils/url.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,80 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/cloud",
|
|
3
|
-
"version": "0.2.5-
|
|
3
|
+
"version": "0.2.5-fd82773",
|
|
4
4
|
"description": "Logto Cloud service.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
7
7
|
"license": "Elastic-2.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
10
|
+
"lib"
|
|
11
11
|
],
|
|
12
12
|
"exports": {
|
|
13
|
-
"./routes": "./
|
|
13
|
+
"./routes": "./lib/routes/index.js"
|
|
14
14
|
},
|
|
15
15
|
"imports": {
|
|
16
16
|
"#src/*": "./build/*"
|
|
17
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
18
|
"devDependencies": {
|
|
42
|
-
"@silverhand/eslint-config": "
|
|
43
|
-
"@silverhand/
|
|
44
|
-
"@silverhand/ts-config": "3.0.0",
|
|
19
|
+
"@silverhand/eslint-config": "6.0.1",
|
|
20
|
+
"@silverhand/ts-config": "6.0.0",
|
|
45
21
|
"@types/accepts": "^1.3.5",
|
|
46
22
|
"@types/http-proxy": "^1.17.9",
|
|
47
|
-
"@types/jest": "^29.4.0",
|
|
48
23
|
"@types/mime-types": "^2.1.1",
|
|
49
|
-
"@types/node": "^
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
24
|
+
"@types/node": "^22.14.0",
|
|
25
|
+
"@types/yargs": "^17.0.24",
|
|
26
|
+
"dts-bundle-generator": "^9.3.1",
|
|
27
|
+
"eslint": "^8.57.0",
|
|
28
|
+
"lint-staged": "^15.0.0",
|
|
29
|
+
"nodemon": "^3.0.0",
|
|
30
|
+
"prettier": "^3.0.0",
|
|
31
|
+
"typescript": "^5.3.3",
|
|
32
|
+
"vite-tsconfig-paths": "^5.0.0",
|
|
33
|
+
"vitest": "^3.1.1"
|
|
56
34
|
},
|
|
57
35
|
"engines": {
|
|
58
|
-
"node": "^
|
|
36
|
+
"node": "^22.14.0"
|
|
59
37
|
},
|
|
60
38
|
"eslintConfig": {
|
|
61
|
-
"extends": "@silverhand"
|
|
39
|
+
"extends": "@silverhand",
|
|
40
|
+
"rules": {
|
|
41
|
+
"no-console": "error"
|
|
42
|
+
},
|
|
43
|
+
"ignorePatterns": [
|
|
44
|
+
"types.test.ts"
|
|
45
|
+
]
|
|
62
46
|
},
|
|
63
47
|
"prettier": "@silverhand/eslint-config/.prettierrc",
|
|
64
48
|
"publishConfig": {
|
|
65
49
|
"access": "public"
|
|
66
50
|
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@silverhand/essentials": "^2.9.2",
|
|
53
|
+
"@withtyped/server": "^0.14.0"
|
|
54
|
+
},
|
|
67
55
|
"scripts": {
|
|
68
56
|
"precommit": "lint-staged",
|
|
69
|
-
"build": "rm -rf build/ && tsc -p tsconfig.build.json",
|
|
70
|
-
"
|
|
71
|
-
"build:
|
|
57
|
+
"build": "rm -rf build/ && tsc -p tsconfig.build.json && pnpm build:lib",
|
|
58
|
+
"//": "It is not used to build the service itself.",
|
|
59
|
+
"build:lib": "rm -rf lib/ && dts-bundle-generator src/routes/index.ts --project tsconfig.build.lib.json -o lib/routes/index.d.ts",
|
|
72
60
|
"lint": "eslint --ext .ts src",
|
|
73
61
|
"lint:report": "pnpm lint --format json --output-file report.json",
|
|
74
62
|
"dev": "rm -rf build/ && nodemon",
|
|
75
63
|
"start": "NODE_ENV=production node .",
|
|
76
|
-
"test
|
|
77
|
-
"test": "
|
|
78
|
-
"test:
|
|
64
|
+
"test": "vitest && pnpm build:lib && pnpm test:types",
|
|
65
|
+
"test:types": "tsc -p tsconfig.test.types.json",
|
|
66
|
+
"test:only": "vitest",
|
|
67
|
+
"cli": "node ./build/cli/index.js"
|
|
79
68
|
}
|
|
80
69
|
}
|
package/build/env-set/index.d.ts
DELETED
package/build/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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>;
|
|
@@ -1,5 +0,0 @@
|
|
|
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>;
|
|
@@ -1,7 +0,0 @@
|
|
|
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>;
|
|
@@ -1,11 +0,0 @@
|
|
|
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>;
|
|
@@ -1,2 +0,0 @@
|
|
|
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>;
|
|
@@ -1,28 +0,0 @@
|
|
|
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>;
|
|
@@ -1,24 +0,0 @@
|
|
|
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>;
|
|
@@ -1,10 +0,0 @@
|
|
|
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'>>;
|
|
@@ -1,132 +0,0 @@
|
|
|
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>;
|
|
@@ -1,24 +0,0 @@
|
|
|
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>;
|
|
@@ -1,31 +0,0 @@
|
|
|
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>;
|
|
@@ -1,20 +0,0 @@
|
|
|
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>;
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|
package/build/queries/index.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
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
|
-
}
|
package/build/queries/roles.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
};
|