@logto/schemas 1.24.0 → 1.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ import { sql } from '@silverhand/slonik';
2
+
3
+ import type { AlterationScript } from '../lib/types/alteration.js';
4
+
5
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
6
+
7
+ const alteration: AlterationScript = {
8
+ up: async (pool) => {
9
+ await pool.query(sql`
10
+ create table email_templates (
11
+ tenant_id varchar(21) not null
12
+ references tenants (id) on update cascade on delete cascade,
13
+ id varchar(21) not null,
14
+ language_tag varchar(16) not null,
15
+ template_type varchar(64) not null,
16
+ details jsonb not null,
17
+ created_at timestamptz not null default now(),
18
+ primary key (tenant_id, id),
19
+ constraint email_templates__tenant_id__language_tag__template_type
20
+ unique (tenant_id, language_tag, template_type)
21
+ );
22
+
23
+ create index email_templates__tenant_id__language_tag
24
+ on email_templates (tenant_id, language_tag);
25
+
26
+ create index email_templates__tenant_id__template_type
27
+ on email_templates (tenant_id, template_type);
28
+ `);
29
+
30
+ await applyTableRls(pool, 'email_templates');
31
+ },
32
+ down: async (pool) => {
33
+ await dropTableRls(pool, 'email_templates');
34
+ await pool.query(sql`
35
+ drop table if exists email_templates;
36
+ `);
37
+ },
38
+ };
39
+
40
+ export default alteration;
@@ -0,0 +1,34 @@
1
+ import { sql } from '@silverhand/slonik';
2
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
3
+ const alteration = {
4
+ up: async (pool) => {
5
+ await pool.query(sql `
6
+ create table email_templates (
7
+ tenant_id varchar(21) not null
8
+ references tenants (id) on update cascade on delete cascade,
9
+ id varchar(21) not null,
10
+ language_tag varchar(16) not null,
11
+ template_type varchar(64) not null,
12
+ details jsonb not null,
13
+ created_at timestamptz not null default now(),
14
+ primary key (tenant_id, id),
15
+ constraint email_templates__tenant_id__language_tag__template_type
16
+ unique (tenant_id, language_tag, template_type)
17
+ );
18
+
19
+ create index email_templates__tenant_id__language_tag
20
+ on email_templates (tenant_id, language_tag);
21
+
22
+ create index email_templates__tenant_id__template_type
23
+ on email_templates (tenant_id, template_type);
24
+ `);
25
+ await applyTableRls(pool, 'email_templates');
26
+ },
27
+ down: async (pool) => {
28
+ await dropTableRls(pool, 'email_templates');
29
+ await pool.query(sql `
30
+ drop table if exists email_templates;
31
+ `);
32
+ },
33
+ };
34
+ export default alteration;
@@ -0,0 +1,24 @@
1
+ import { TemplateType, EmailTemplateDetails, GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ *
4
+ * @remarks This is a type for database creation.
5
+ * @see {@link EmailTemplate} for the original type.
6
+ */
7
+ export type CreateEmailTemplate = {
8
+ tenantId?: string;
9
+ id: string;
10
+ languageTag: string;
11
+ templateType: TemplateType;
12
+ details: EmailTemplateDetails;
13
+ createdAt?: number;
14
+ };
15
+ export type EmailTemplate = {
16
+ tenantId: string;
17
+ id: string;
18
+ languageTag: string;
19
+ templateType: TemplateType;
20
+ details: EmailTemplateDetails;
21
+ createdAt: number;
22
+ };
23
+ export type EmailTemplateKeys = 'tenantId' | 'id' | 'languageTag' | 'templateType' | 'details' | 'createdAt';
24
+ export declare const EmailTemplates: GeneratedSchema<EmailTemplateKeys, CreateEmailTemplate, EmailTemplate, 'email_templates', 'email_template'>;
@@ -0,0 +1,42 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ import { templateTypeGuard, emailTemplateDetailsGuard } from './../foundations/index.js';
4
+ const createGuard = z.object({
5
+ tenantId: z.string().max(21).optional(),
6
+ id: z.string().min(1).max(21),
7
+ languageTag: z.string().min(1).max(16),
8
+ templateType: templateTypeGuard,
9
+ details: emailTemplateDetailsGuard,
10
+ createdAt: z.number().optional(),
11
+ });
12
+ const guard = z.object({
13
+ tenantId: z.string().max(21),
14
+ id: z.string().min(1).max(21),
15
+ languageTag: z.string().min(1).max(16),
16
+ templateType: templateTypeGuard,
17
+ details: emailTemplateDetailsGuard,
18
+ createdAt: z.number(),
19
+ });
20
+ export const EmailTemplates = Object.freeze({
21
+ table: 'email_templates',
22
+ tableSingular: 'email_template',
23
+ fields: {
24
+ tenantId: 'tenant_id',
25
+ id: 'id',
26
+ languageTag: 'language_tag',
27
+ templateType: 'template_type',
28
+ details: 'details',
29
+ createdAt: 'created_at',
30
+ },
31
+ fieldKeys: [
32
+ 'tenantId',
33
+ 'id',
34
+ 'languageTag',
35
+ 'templateType',
36
+ 'details',
37
+ 'createdAt',
38
+ ],
39
+ createGuard,
40
+ guard,
41
+ updateGuard: guard.partial(),
42
+ });
@@ -18,6 +18,7 @@ export * from './custom-phrase.js';
18
18
  export * from './daily-active-user.js';
19
19
  export * from './daily-token-usage.js';
20
20
  export * from './domain.js';
21
+ export * from './email-template.js';
21
22
  export * from './hook.js';
22
23
  export * from './idp-initiated-saml-sso-session.js';
23
24
  export * from './log.js';
@@ -19,6 +19,7 @@ export * from './custom-phrase.js';
19
19
  export * from './daily-active-user.js';
20
20
  export * from './daily-token-usage.js';
21
21
  export * from './domain.js';
22
+ export * from './email-template.js';
22
23
  export * from './hook.js';
23
24
  export * from './idp-initiated-saml-sso-session.js';
24
25
  export * from './log.js';
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod';
2
+ export { TemplateType, templateTypeGuard } from '@logto/connector-kit';
3
+ export type EmailTemplateDetails = {
4
+ subject: string;
5
+ content: string;
6
+ /**
7
+ * OPTIONAL: The content type of the email template.
8
+ *
9
+ * Some email clients may render email templates differently based on the content type. (e.g. Sendgrid, Mailgun)
10
+ * Use this field to specify the content type of the email template.
11
+ */
12
+ contentType?: 'text/html' | 'text/plain';
13
+ /**
14
+ * OPTIONAL: Custom replyTo template.
15
+ *
16
+ * Based on the email client, the replyTo field may be used to customize the reply-to field of the email.
17
+ * @remarks
18
+ * The original reply email value can be found in the template variables.
19
+ */
20
+ replyTo?: string;
21
+ /**
22
+ * OPTIONAL: Custom from template.
23
+ *
24
+ * Based on the email client, the sendFrom field may be used to customize the from field of the email.
25
+ * @remarks
26
+ * The sender email value can be found in the template variables.
27
+ */
28
+ sendFrom?: string;
29
+ };
30
+ export declare const emailTemplateDetailsGuard: z.ZodObject<{
31
+ subject: z.ZodString;
32
+ content: z.ZodString;
33
+ contentType: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"text/html">, z.ZodLiteral<"text/plain">]>>;
34
+ replyTo: z.ZodOptional<z.ZodString>;
35
+ sendFrom: z.ZodOptional<z.ZodString>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ subject: string;
38
+ content: string;
39
+ contentType?: "text/html" | "text/plain" | undefined;
40
+ replyTo?: string | undefined;
41
+ sendFrom?: string | undefined;
42
+ }, {
43
+ subject: string;
44
+ content: string;
45
+ contentType?: "text/html" | "text/plain" | undefined;
46
+ replyTo?: string | undefined;
47
+ sendFrom?: string | undefined;
48
+ }>;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export { TemplateType, templateTypeGuard } from '@logto/connector-kit';
3
+ export const emailTemplateDetailsGuard = z.object({
4
+ subject: z.string(),
5
+ content: z.string(),
6
+ contentType: z.union([z.literal('text/html'), z.literal('text/plain')]).optional(),
7
+ replyTo: z.string().optional(),
8
+ sendFrom: z.string().optional(),
9
+ });
@@ -12,5 +12,6 @@ export * from './verification-records.js';
12
12
  export * from './account-centers.js';
13
13
  export * from './saml-application-configs.js';
14
14
  export * from './saml-application-sessions.js';
15
+ export * from './email-templates.js';
15
16
  export { configurableConnectorMetadataGuard, type ConfigurableConnectorMetadata, jsonGuard, jsonObjectGuard, } from '@logto/connector-kit';
16
17
  export type { Json, JsonObject } from '@withtyped/server';
@@ -12,4 +12,5 @@ export * from './verification-records.js';
12
12
  export * from './account-centers.js';
13
13
  export * from './saml-application-configs.js';
14
14
  export * from './saml-application-sessions.js';
15
+ export * from './email-templates.js';
15
16
  export { configurableConnectorMetadataGuard, jsonGuard, jsonObjectGuard, } from '@logto/connector-kit';
@@ -3,7 +3,7 @@ export type AuthRequestInfo = {
3
3
  issuer: string;
4
4
  request: {
5
5
  id: string;
6
- destination: string;
6
+ destination?: string;
7
7
  issueInstant: string;
8
8
  assertionConsumerServiceUrl: string;
9
9
  };
@@ -12,34 +12,34 @@ export declare const authRequestInfoGuard: z.ZodObject<{
12
12
  issuer: z.ZodString;
13
13
  request: z.ZodObject<{
14
14
  id: z.ZodString;
15
- destination: z.ZodString;
15
+ destination: z.ZodOptional<z.ZodString>;
16
16
  issueInstant: z.ZodString;
17
17
  assertionConsumerServiceUrl: z.ZodString;
18
18
  }, "strip", z.ZodTypeAny, {
19
19
  id: string;
20
- destination: string;
21
20
  issueInstant: string;
22
21
  assertionConsumerServiceUrl: string;
22
+ destination?: string | undefined;
23
23
  }, {
24
24
  id: string;
25
- destination: string;
26
25
  issueInstant: string;
27
26
  assertionConsumerServiceUrl: string;
27
+ destination?: string | undefined;
28
28
  }>;
29
29
  }, "strip", z.ZodTypeAny, {
30
30
  issuer: string;
31
31
  request: {
32
32
  id: string;
33
- destination: string;
34
33
  issueInstant: string;
35
34
  assertionConsumerServiceUrl: string;
35
+ destination?: string | undefined;
36
36
  };
37
37
  }, {
38
38
  issuer: string;
39
39
  request: {
40
40
  id: string;
41
- destination: string;
42
41
  issueInstant: string;
43
42
  assertionConsumerServiceUrl: string;
43
+ destination?: string | undefined;
44
44
  };
45
45
  }>;
@@ -3,7 +3,7 @@ export const authRequestInfoGuard = z.object({
3
3
  issuer: z.string(),
4
4
  request: z.object({
5
5
  id: z.string(),
6
- destination: z.string(),
6
+ destination: z.string().optional(),
7
7
  issueInstant: z.string(),
8
8
  assertionConsumerServiceUrl: z.string(),
9
9
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.24.0",
3
+ "version": "1.24.1",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "@types/inquirer": "^9.0.0",
32
32
  "@types/node": "^20.9.5",
33
33
  "@types/pluralize": "^0.0.33",
34
- "@vitest/coverage-v8": "^2.1.8",
34
+ "@vitest/coverage-v8": "^2.1.9",
35
35
  "camelcase": "^8.0.0",
36
36
  "chalk": "^5.3.0",
37
37
  "eslint": "^8.56.0",
@@ -40,7 +40,7 @@
40
40
  "prettier": "^3.0.0",
41
41
  "roarr": "^7.11.0",
42
42
  "typescript": "^5.5.3",
43
- "vitest": "^2.1.8"
43
+ "vitest": "^2.1.9"
44
44
  },
45
45
  "eslintConfig": {
46
46
  "extends": "@silverhand",
@@ -63,12 +63,12 @@
63
63
  },
64
64
  "prettier": "@silverhand/eslint-config/.prettierrc",
65
65
  "dependencies": {
66
- "@logto/connector-kit": "^4.1.0",
67
- "@logto/core-kit": "^2.5.2",
68
- "@logto/language-kit": "^1.1.0",
69
- "@logto/phrases": "^1.17.0",
70
- "@logto/phrases-experience": "^1.9.0",
71
- "@logto/shared": "^3.1.2",
66
+ "@logto/connector-kit": "^4.1.1",
67
+ "@logto/core-kit": "^2.5.4",
68
+ "@logto/language-kit": "^1.1.1",
69
+ "@logto/phrases": "^1.18.0",
70
+ "@logto/phrases-experience": "^1.9.1",
71
+ "@logto/shared": "^3.1.4",
72
72
  "@withtyped/server": "^0.14.0",
73
73
  "nanoid": "^5.0.9"
74
74
  },
@@ -0,0 +1,18 @@
1
+ create table email_templates (
2
+ tenant_id varchar(21) not null
3
+ references tenants (id) on update cascade on delete cascade,
4
+ id varchar(21) not null,
5
+ language_tag varchar(16) not null,
6
+ template_type varchar(64) /* @use TemplateType */ not null,
7
+ details jsonb /* @use EmailTemplateDetails */ not null,
8
+ created_at timestamptz not null default now(),
9
+ primary key (tenant_id, id),
10
+ constraint email_templates__tenant_id__language_tag__template_type
11
+ unique (tenant_id, language_tag, template_type)
12
+ );
13
+
14
+ create index email_templates__tenant_id__language_tag
15
+ on email_templates (tenant_id, language_tag);
16
+
17
+ create index email_templates__tenant_id__template_type
18
+ on email_templates (tenant_id, template_type);