@logto/schemas 1.5.0 → 1.7.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.
Files changed (51) hide show
  1. package/LICENSE +0 -6
  2. package/alterations/1.6.0-1685691718-domain-unique.ts +20 -0
  3. package/alterations/1.7.0-1688375200-sync-cloud-m2m-to-logto-config.ts +85 -0
  4. package/alterations/1.7.0-1688613459-remove-m2m-credentials-from-existing-logto-email-connector-config.ts +88 -0
  5. package/alterations/1.7.0-1688627407-daily-active-users.ts +61 -0
  6. package/alterations-js/1.6.0-1685691718-domain-unique.d.ts +3 -0
  7. package/alterations-js/1.6.0-1685691718-domain-unique.js +16 -0
  8. package/alterations-js/1.7.0-1688375200-sync-cloud-m2m-to-logto-config.d.ts +3 -0
  9. package/alterations-js/1.7.0-1688375200-sync-cloud-m2m-to-logto-config.js +42 -0
  10. package/alterations-js/1.7.0-1688613459-remove-m2m-credentials-from-existing-logto-email-connector-config.d.ts +3 -0
  11. package/alterations-js/1.7.0-1688613459-remove-m2m-credentials-from-existing-logto-email-connector-config.js +55 -0
  12. package/alterations-js/1.7.0-1688627407-daily-active-users.d.ts +3 -0
  13. package/alterations-js/1.7.0-1688627407-daily-active-users.js +53 -0
  14. package/lib/consts/date.d.ts +5 -0
  15. package/lib/consts/date.js +1 -0
  16. package/lib/consts/index.d.ts +2 -0
  17. package/lib/consts/index.js +2 -0
  18. package/lib/consts/oidc.d.ts +5 -0
  19. package/lib/consts/oidc.js +6 -0
  20. package/lib/consts/tenant.d.ts +1 -0
  21. package/lib/consts/tenant.js +1 -0
  22. package/lib/db-entries/daily-active-user.d.ts +14 -0
  23. package/lib/db-entries/daily-active-user.js +32 -0
  24. package/lib/db-entries/domain.d.ts +3 -3
  25. package/lib/db-entries/domain.js +3 -3
  26. package/lib/db-entries/index.d.ts +1 -0
  27. package/lib/db-entries/index.js +1 -0
  28. package/lib/foundations/jsonb-types.d.ts +22 -38
  29. package/lib/foundations/jsonb-types.js +18 -3
  30. package/lib/models/tenants.d.ts +34 -3
  31. package/lib/models/tenants.js +16 -4
  32. package/lib/seeds/cloud-api.d.ts +5 -1
  33. package/lib/seeds/cloud-api.js +4 -0
  34. package/lib/seeds/logto-config.d.ts +6 -1
  35. package/lib/seeds/logto-config.js +10 -0
  36. package/lib/seeds/tenant.d.ts +1 -3
  37. package/lib/types/connector.d.ts +17 -5
  38. package/lib/types/connector.js +2 -0
  39. package/lib/types/domain.d.ts +3 -25
  40. package/lib/types/domain.js +0 -7
  41. package/lib/types/index.d.ts +0 -1
  42. package/lib/types/index.js +0 -1
  43. package/lib/types/logto-config.d.ts +16 -0
  44. package/lib/types/logto-config.js +8 -0
  45. package/lib/types/system.d.ts +55 -6
  46. package/lib/types/system.js +25 -2
  47. package/package.json +10 -8
  48. package/tables/daily_active_users.sql +13 -0
  49. package/tables/domains.sql +2 -2
  50. package/lib/types/tenant.d.ts +0 -37
  51. package/lib/types/tenant.js +0 -19
@@ -64,6 +64,58 @@ export type StorageProviderType = {
64
64
  export declare const storageProviderGuard: Readonly<{
65
65
  [key in StorageProviderKey]: ZodType<StorageProviderType[key]>;
66
66
  }>;
67
+ export declare enum EmailServiceProvider {
68
+ SendGrid = "SendGrid"
69
+ }
70
+ export declare const sendgridEmailServiceDataGuard: z.ZodObject<{
71
+ provider: z.ZodLiteral<EmailServiceProvider>;
72
+ apiKey: z.ZodString;
73
+ templateId: z.ZodString;
74
+ fromName: z.ZodString;
75
+ fromEmail: z.ZodString;
76
+ }, "strip", z.ZodTypeAny, {
77
+ provider: EmailServiceProvider;
78
+ apiKey: string;
79
+ templateId: string;
80
+ fromName: string;
81
+ fromEmail: string;
82
+ }, {
83
+ provider: EmailServiceProvider;
84
+ apiKey: string;
85
+ templateId: string;
86
+ fromName: string;
87
+ fromEmail: string;
88
+ }>;
89
+ export type SendgridEmailServiceData = z.infer<typeof sendgridEmailServiceDataGuard>;
90
+ export declare const emailServiceDataGuard: z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
91
+ provider: z.ZodLiteral<EmailServiceProvider>;
92
+ apiKey: z.ZodString;
93
+ templateId: z.ZodString;
94
+ fromName: z.ZodString;
95
+ fromEmail: z.ZodString;
96
+ }, "strip", z.ZodTypeAny, {
97
+ provider: EmailServiceProvider;
98
+ apiKey: string;
99
+ templateId: string;
100
+ fromName: string;
101
+ fromEmail: string;
102
+ }, {
103
+ provider: EmailServiceProvider;
104
+ apiKey: string;
105
+ templateId: string;
106
+ fromName: string;
107
+ fromEmail: string;
108
+ }>]>;
109
+ export type EmailServiceData = z.infer<typeof emailServiceDataGuard>;
110
+ export declare enum EmailServiceProviderKey {
111
+ EmailServiceProvider = "emailServiceProvider"
112
+ }
113
+ export type EmailServiceProviderType = {
114
+ [EmailServiceProviderKey.EmailServiceProvider]: EmailServiceData;
115
+ };
116
+ export declare const emailServiceProviderGuard: Readonly<{
117
+ [key in EmailServiceProviderKey]: ZodType<EmailServiceProviderType[key]>;
118
+ }>;
67
119
  export declare enum DemoSocialProvider {
68
120
  Google = "google",
69
121
  GitHub = "github",
@@ -101,15 +153,12 @@ export declare const demoSocialGuard: Readonly<{
101
153
  export declare const hostnameProviderDataGuard: z.ZodObject<{
102
154
  zoneId: z.ZodString;
103
155
  apiToken: z.ZodString;
104
- fallbackOrigin: z.ZodString;
105
156
  }, "strip", z.ZodTypeAny, {
106
157
  zoneId: string;
107
158
  apiToken: string;
108
- fallbackOrigin: string;
109
159
  }, {
110
160
  zoneId: string;
111
161
  apiToken: string;
112
- fallbackOrigin: string;
113
162
  }>;
114
163
  export type HostnameProviderData = z.infer<typeof hostnameProviderDataGuard>;
115
164
  export declare enum CloudflareKey {
@@ -121,8 +170,8 @@ export type CloudflareType = {
121
170
  export declare const cloudflareGuard: Readonly<{
122
171
  [key in CloudflareKey]: ZodType<CloudflareType[key]>;
123
172
  }>;
124
- export type SystemKey = AlterationStateKey | StorageProviderKey | DemoSocialKey | CloudflareKey;
125
- export type SystemType = AlterationStateType | StorageProviderType | DemoSocialType | CloudflareType;
126
- export type SystemGuard = typeof alterationStateGuard & typeof storageProviderGuard & typeof demoSocialGuard & typeof cloudflareGuard;
173
+ export type SystemKey = AlterationStateKey | StorageProviderKey | DemoSocialKey | CloudflareKey | EmailServiceProviderKey;
174
+ export type SystemType = AlterationStateType | StorageProviderType | DemoSocialType | CloudflareType | EmailServiceProviderType;
175
+ export type SystemGuard = typeof alterationStateGuard & typeof storageProviderGuard & typeof demoSocialGuard & typeof cloudflareGuard & typeof emailServiceProviderGuard;
127
176
  export declare const systemKeys: readonly SystemKey[];
128
177
  export declare const systemGuards: SystemGuard;
@@ -42,6 +42,28 @@ export var StorageProviderKey;
42
42
  export const storageProviderGuard = Object.freeze({
43
43
  [StorageProviderKey.StorageProvider]: storageProviderDataGuard,
44
44
  });
45
+ // Email service provider
46
+ export var EmailServiceProvider;
47
+ (function (EmailServiceProvider) {
48
+ EmailServiceProvider["SendGrid"] = "SendGrid";
49
+ })(EmailServiceProvider || (EmailServiceProvider = {}));
50
+ export const sendgridEmailServiceDataGuard = z.object({
51
+ provider: z.literal(EmailServiceProvider.SendGrid),
52
+ apiKey: z.string(),
53
+ templateId: z.string(),
54
+ fromName: z.string(),
55
+ fromEmail: z.string(),
56
+ });
57
+ export const emailServiceDataGuard = z.discriminatedUnion('provider', [
58
+ sendgridEmailServiceDataGuard,
59
+ ]);
60
+ export var EmailServiceProviderKey;
61
+ (function (EmailServiceProviderKey) {
62
+ EmailServiceProviderKey["EmailServiceProvider"] = "emailServiceProvider";
63
+ })(EmailServiceProviderKey || (EmailServiceProviderKey = {}));
64
+ export const emailServiceProviderGuard = Object.freeze({
65
+ [EmailServiceProviderKey.EmailServiceProvider]: emailServiceDataGuard,
66
+ });
45
67
  // Demo social connectors
46
68
  export var DemoSocialProvider;
47
69
  (function (DemoSocialProvider) {
@@ -68,8 +90,7 @@ export const demoSocialGuard = Object.freeze({
68
90
  // Cloudflare Hostnames
69
91
  export const hostnameProviderDataGuard = z.object({
70
92
  zoneId: z.string(),
71
- apiToken: z.string(),
72
- fallbackOrigin: z.string(), // A domain name
93
+ apiToken: z.string(), // Requires zone permission for "SSL and Certificates Edit"
73
94
  });
74
95
  export var CloudflareKey;
75
96
  (function (CloudflareKey) {
@@ -83,10 +104,12 @@ export const systemKeys = Object.freeze([
83
104
  ...Object.values(StorageProviderKey),
84
105
  ...Object.values(DemoSocialKey),
85
106
  ...Object.values(CloudflareKey),
107
+ ...Object.values(EmailServiceProviderKey),
86
108
  ]);
87
109
  export const systemGuards = Object.freeze({
88
110
  ...alterationStateGuard,
89
111
  ...storageProviderGuard,
90
112
  ...demoSocialGuard,
91
113
  ...cloudflareGuard,
114
+ ...emailServiceProviderGuard,
92
115
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -24,20 +24,20 @@
24
24
  "node": "^18.12.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@silverhand/eslint-config": "3.0.1",
27
+ "@silverhand/eslint-config": "4.0.1",
28
28
  "@silverhand/essentials": "^2.5.0",
29
- "@silverhand/ts-config": "3.0.0",
29
+ "@silverhand/ts-config": "4.0.0",
30
30
  "@types/inquirer": "^9.0.0",
31
31
  "@types/jest": "^29.4.0",
32
32
  "@types/node": "^18.11.18",
33
33
  "@types/pluralize": "^0.0.29",
34
34
  "camelcase": "^7.0.0",
35
35
  "chalk": "^5.0.0",
36
- "eslint": "^8.34.0",
36
+ "eslint": "^8.44.0",
37
37
  "jest": "^29.5.0",
38
38
  "lint-staged": "^13.0.0",
39
39
  "pluralize": "^8.0.0",
40
- "prettier": "^2.8.2",
40
+ "prettier": "^3.0.0",
41
41
  "roarr": "^7.11.0",
42
42
  "slonik": "^30.0.0",
43
43
  "slonik-sql-tag-raw": "^1.1.4",
@@ -65,12 +65,14 @@
65
65
  "prettier": "@silverhand/eslint-config/.prettierrc",
66
66
  "dependencies": {
67
67
  "@logto/connector-kit": "^1.1.1",
68
- "@logto/core-kit": "^2.0.0",
68
+ "@logto/core-kit": "^2.0.1",
69
69
  "@logto/language-kit": "^1.0.0",
70
- "@logto/phrases": "^1.4.0",
70
+ "@logto/phrases": "^1.4.1",
71
71
  "@logto/phrases-ui": "^1.2.0",
72
72
  "@logto/shared": "^2.0.0",
73
- "@withtyped/server": "^0.9.0",
73
+ "@withtyped/server": "^0.12.8"
74
+ },
75
+ "peerDependencies": {
74
76
  "zod": "^3.20.2"
75
77
  },
76
78
  "scripts": {
@@ -0,0 +1,13 @@
1
+ create table daily_active_users (
2
+ id varchar(21) not null,
3
+ tenant_id varchar(21) not null
4
+ references tenants (id) on update cascade on delete cascade,
5
+ user_id varchar(21) not null,
6
+ date timestamptz not null,
7
+ primary key (id),
8
+ constraint daily_active_users__user_id_date
9
+ unique (user_id, date)
10
+ );
11
+
12
+ create index daily_active_users__id
13
+ on daily_active_users (tenant_id, id);
@@ -3,7 +3,7 @@ create table domains (
3
3
  references tenants (id) on update cascade on delete cascade,
4
4
  id varchar(21) not null,
5
5
  domain varchar(256) not null,
6
- status varchar(32) not null default('PendingVerification'),
6
+ status varchar(32) /* @use DomainStatus */ not null default('PendingVerification'),
7
7
  error_message varchar(1024),
8
8
  dns_records jsonb /* @use DomainDnsRecords */ not null default '[]'::jsonb,
9
9
  cloudflare_data jsonb /* @use CloudflareData */,
@@ -11,7 +11,7 @@ create table domains (
11
11
  created_at timestamptz not null default(now()),
12
12
  primary key (id),
13
13
  constraint domains__domain
14
- unique (domain)
14
+ unique (tenant_id, domain)
15
15
  );
16
16
 
17
17
  create index domains__id on domains (tenant_id, id);
@@ -1,37 +0,0 @@
1
- import { z } from 'zod';
2
- import { type TenantModel } from '../seeds/tenant.js';
3
- export declare enum TenantTag {
4
- Development = "development",
5
- Staging = "staging",
6
- Production = "production"
7
- }
8
- export type PatchTenant = Partial<Pick<TenantModel, 'name' | 'tag'>>;
9
- export type CreateTenant = Pick<TenantModel, 'id' | 'dbUser' | 'dbUserPassword'> & PatchTenant & {
10
- createdAt?: number;
11
- };
12
- export declare const createTenantGuard: z.ZodObject<{
13
- id: z.ZodString;
14
- dbUser: z.ZodString;
15
- dbUserPassword: z.ZodString;
16
- name: z.ZodOptional<z.ZodString>;
17
- tag: z.ZodOptional<z.ZodNativeEnum<typeof TenantTag>>;
18
- createdAt: z.ZodOptional<z.ZodNumber>;
19
- }, "strip", z.ZodTypeAny, {
20
- name?: string | undefined;
21
- createdAt?: number | undefined;
22
- tag?: TenantTag | undefined;
23
- id: string;
24
- dbUser: string;
25
- dbUserPassword: string;
26
- }, {
27
- name?: string | undefined;
28
- createdAt?: number | undefined;
29
- tag?: TenantTag | undefined;
30
- id: string;
31
- dbUser: string;
32
- dbUserPassword: string;
33
- }>;
34
- export type TenantInfo = Pick<TenantModel, 'id' | 'name' | 'tag'> & {
35
- indicator: string;
36
- };
37
- export declare const tenantInfoGuard: z.ZodType<TenantInfo>;
@@ -1,19 +0,0 @@
1
- import { z } from 'zod';
2
- export var TenantTag;
3
- (function (TenantTag) {
4
- TenantTag["Development"] = "development";
5
- TenantTag["Staging"] = "staging";
6
- TenantTag["Production"] = "production";
7
- })(TenantTag || (TenantTag = {}));
8
- export const createTenantGuard = z.object({
9
- id: z.string(),
10
- dbUser: z.string(),
11
- dbUserPassword: z.string(),
12
- name: z.string().optional(),
13
- tag: z.nativeEnum(TenantTag).optional(),
14
- createdAt: z.number().optional(),
15
- });
16
- export const tenantInfoGuard = createTenantGuard
17
- .pick({ id: true, name: true, tag: true })
18
- .extend({ indicator: z.string() })
19
- .required();