@logto/schemas 1.2.2 → 1.2.3

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.
@@ -25,7 +25,7 @@ const alteration: AlterationScript = {
25
25
  tenant_id varchar(21) not null
26
26
  references tenants (id) on update cascade on delete cascade,
27
27
  type varchar(64) not null,
28
- payload jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
28
+ payload jsonb /* @use JsonObject */ not null default '{}'::jsonb,
29
29
  created_at timestamptz not null default(now()),
30
30
  primary key (id)
31
31
  );
@@ -7,7 +7,7 @@ const alteration: AlterationScript = {
7
7
  await pool.query(sql`
8
8
  create table _logto_configs (
9
9
  key varchar(256) not null,
10
- value jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
10
+ value jsonb /* @use JsonObject */ not null default '{}'::jsonb,
11
11
  primary key (key)
12
12
  );
13
13
  `);
@@ -17,7 +17,7 @@ const alteration = {
17
17
  tenant_id varchar(21) not null
18
18
  references tenants (id) on update cascade on delete cascade,
19
19
  type varchar(64) not null,
20
- payload jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
20
+ payload jsonb /* @use JsonObject */ not null default '{}'::jsonb,
21
21
  created_at timestamptz not null default(now()),
22
22
  primary key (id)
23
23
  );
@@ -4,7 +4,7 @@ const alteration = {
4
4
  await pool.query(sql `
5
5
  create table _logto_configs (
6
6
  key varchar(256) not null,
7
- value jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
7
+ value jsonb /* @use JsonObject */ not null default '{}'::jsonb,
8
8
  primary key (key)
9
9
  );
10
10
  `);
@@ -1,10 +1,10 @@
1
- import { ArbitraryObject, ConfigurableConnectorMetadata, GeneratedSchema } from './../foundations/index.js';
1
+ import { JsonObject, ConfigurableConnectorMetadata, GeneratedSchema } from './../foundations/index.js';
2
2
  export type CreateConnector = {
3
3
  tenantId?: string;
4
4
  id: string;
5
5
  syncProfile?: boolean;
6
6
  connectorId: string;
7
- config?: ArbitraryObject;
7
+ config?: JsonObject;
8
8
  metadata?: ConfigurableConnectorMetadata;
9
9
  createdAt?: number;
10
10
  };
@@ -13,7 +13,7 @@ export type Connector = {
13
13
  id: string;
14
14
  syncProfile: boolean;
15
15
  connectorId: string;
16
- config: ArbitraryObject;
16
+ config: JsonObject;
17
17
  metadata: ConfigurableConnectorMetadata;
18
18
  createdAt: number;
19
19
  };
@@ -1,12 +1,12 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
- import { arbitraryObjectGuard, configurableConnectorMetadataGuard } from './../foundations/index.js';
3
+ import { jsonObjectGuard, configurableConnectorMetadataGuard } from './../foundations/index.js';
4
4
  const createGuard = z.object({
5
5
  tenantId: z.string().max(21).optional(),
6
6
  id: z.string().max(128),
7
7
  syncProfile: z.boolean().optional(),
8
8
  connectorId: z.string().max(128),
9
- config: arbitraryObjectGuard.optional(),
9
+ config: jsonObjectGuard.optional(),
10
10
  metadata: configurableConnectorMetadataGuard.optional(),
11
11
  createdAt: z.number().optional(),
12
12
  });
@@ -15,7 +15,7 @@ const guard = z.object({
15
15
  id: z.string().max(128),
16
16
  syncProfile: z.boolean(),
17
17
  connectorId: z.string().max(128),
18
- config: arbitraryObjectGuard,
18
+ config: jsonObjectGuard,
19
19
  metadata: configurableConnectorMetadataGuard,
20
20
  createdAt: z.number(),
21
21
  });
@@ -1,12 +1,12 @@
1
- import { ArbitraryObject, GeneratedSchema } from './../foundations/index.js';
1
+ import { JsonObject, GeneratedSchema } from './../foundations/index.js';
2
2
  export type CreateLogtoConfig = {
3
3
  tenantId?: string;
4
4
  key: string;
5
- value?: ArbitraryObject;
5
+ value?: JsonObject;
6
6
  };
7
7
  export type LogtoConfig = {
8
8
  tenantId: string;
9
9
  key: string;
10
- value: ArbitraryObject;
10
+ value: JsonObject;
11
11
  };
12
12
  export declare const LogtoConfigs: GeneratedSchema<CreateLogtoConfig, LogtoConfig>;
@@ -1,15 +1,15 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
- import { arbitraryObjectGuard } from './../foundations/index.js';
3
+ import { jsonObjectGuard } from './../foundations/index.js';
4
4
  const createGuard = z.object({
5
5
  tenantId: z.string().max(21).optional(),
6
6
  key: z.string().max(256),
7
- value: arbitraryObjectGuard.optional(),
7
+ value: jsonObjectGuard.optional(),
8
8
  });
9
9
  const guard = z.object({
10
10
  tenantId: z.string().max(21),
11
11
  key: z.string().max(256),
12
- value: arbitraryObjectGuard,
12
+ value: jsonObjectGuard,
13
13
  });
14
14
  export const LogtoConfigs = Object.freeze({
15
15
  table: 'logto_configs',
@@ -1,16 +1,16 @@
1
- import { ArbitraryObject, GeneratedSchema } from './../foundations/index.js';
1
+ import { JsonObject, GeneratedSchema } from './../foundations/index.js';
2
2
  export type CreateServiceLog = {
3
3
  id: string;
4
4
  tenantId?: string;
5
5
  type: string;
6
- payload?: ArbitraryObject;
6
+ payload?: JsonObject;
7
7
  createdAt?: number;
8
8
  };
9
9
  export type ServiceLog = {
10
10
  id: string;
11
11
  tenantId: string;
12
12
  type: string;
13
- payload: ArbitraryObject;
13
+ payload: JsonObject;
14
14
  createdAt: number;
15
15
  };
16
16
  export declare const ServiceLogs: GeneratedSchema<CreateServiceLog, ServiceLog>;
@@ -1,18 +1,18 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
- import { arbitraryObjectGuard } from './../foundations/index.js';
3
+ import { jsonObjectGuard } from './../foundations/index.js';
4
4
  const createGuard = z.object({
5
5
  id: z.string().max(21),
6
6
  tenantId: z.string().max(21).optional(),
7
7
  type: z.string().max(64),
8
- payload: arbitraryObjectGuard.optional(),
8
+ payload: jsonObjectGuard.optional(),
9
9
  createdAt: z.number().optional(),
10
10
  });
11
11
  const guard = z.object({
12
12
  id: z.string().max(21),
13
13
  tenantId: z.string().max(21),
14
14
  type: z.string().max(64),
15
- payload: arbitraryObjectGuard,
15
+ payload: jsonObjectGuard,
16
16
  createdAt: z.number(),
17
17
  });
18
18
  export const ServiceLogs = Object.freeze({
@@ -1,10 +1,10 @@
1
- import { ArbitraryObject, GeneratedSchema } from './../foundations/index.js';
1
+ import { JsonObject, GeneratedSchema } from './../foundations/index.js';
2
2
  export type CreateSystem = {
3
3
  key: string;
4
- value?: ArbitraryObject;
4
+ value?: JsonObject;
5
5
  };
6
6
  export type System = {
7
7
  key: string;
8
- value: ArbitraryObject;
8
+ value: JsonObject;
9
9
  };
10
10
  export declare const Systems: GeneratedSchema<CreateSystem, System>;
@@ -1,13 +1,13 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
- import { arbitraryObjectGuard } from './../foundations/index.js';
3
+ import { jsonObjectGuard } from './../foundations/index.js';
4
4
  const createGuard = z.object({
5
5
  key: z.string().max(256),
6
- value: arbitraryObjectGuard.optional(),
6
+ value: jsonObjectGuard.optional(),
7
7
  });
8
8
  const guard = z.object({
9
9
  key: z.string().max(256),
10
- value: arbitraryObjectGuard,
10
+ value: jsonObjectGuard,
11
11
  });
12
12
  export const Systems = Object.freeze({
13
13
  table: 'systems',
@@ -1,4 +1,4 @@
1
- import { Identities, ArbitraryObject, GeneratedSchema } from './../foundations/index.js';
1
+ import { Identities, JsonObject, GeneratedSchema } from './../foundations/index.js';
2
2
  import { UsersPasswordEncryptionMethod } from './custom-types.js';
3
3
  export type CreateUser = {
4
4
  tenantId?: string;
@@ -12,7 +12,7 @@ export type CreateUser = {
12
12
  avatar?: string | null;
13
13
  applicationId?: string | null;
14
14
  identities?: Identities;
15
- customData?: ArbitraryObject;
15
+ customData?: JsonObject;
16
16
  isSuspended?: boolean;
17
17
  lastSignInAt?: number | null;
18
18
  createdAt?: number;
@@ -29,7 +29,7 @@ export type User = {
29
29
  avatar: string | null;
30
30
  applicationId: string | null;
31
31
  identities: Identities;
32
- customData: ArbitraryObject;
32
+ customData: JsonObject;
33
33
  isSuspended: boolean;
34
34
  lastSignInAt: number | null;
35
35
  createdAt: number;
@@ -1,6 +1,6 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
- import { identitiesGuard, arbitraryObjectGuard } from './../foundations/index.js';
3
+ import { identitiesGuard, jsonObjectGuard } from './../foundations/index.js';
4
4
  import { UsersPasswordEncryptionMethod } from './custom-types.js';
5
5
  const createGuard = z.object({
6
6
  tenantId: z.string().max(21).optional(),
@@ -14,7 +14,7 @@ const createGuard = z.object({
14
14
  avatar: z.string().max(2048).nullable().optional(),
15
15
  applicationId: z.string().max(21).nullable().optional(),
16
16
  identities: identitiesGuard.optional(),
17
- customData: arbitraryObjectGuard.optional(),
17
+ customData: jsonObjectGuard.optional(),
18
18
  isSuspended: z.boolean().optional(),
19
19
  lastSignInAt: z.number().nullable().optional(),
20
20
  createdAt: z.number().optional(),
@@ -31,7 +31,7 @@ const guard = z.object({
31
31
  avatar: z.string().max(2048).nullable(),
32
32
  applicationId: z.string().max(21).nullable(),
33
33
  identities: identitiesGuard,
34
- customData: arbitraryObjectGuard,
34
+ customData: jsonObjectGuard,
35
35
  isSuspended: z.boolean(),
36
36
  lastSignInAt: z.number().nullable(),
37
37
  createdAt: z.number(),
@@ -1,7 +1,8 @@
1
+ import type { Json } from '@withtyped/server';
1
2
  import { z } from 'zod';
2
3
  export { configurableConnectorMetadataGuard, type ConfigurableConnectorMetadata, } from '@logto/connector-kit';
3
- export declare const arbitraryObjectGuard: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4
- export type ArbitraryObject = z.infer<typeof arbitraryObjectGuard>;
4
+ export type { JsonObject } from '@withtyped/server';
5
+ export declare const jsonObjectGuard: z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>;
5
6
  export declare const oidcModelInstancePayloadGuard: z.ZodObject<{
6
7
  userCode: z.ZodOptional<z.ZodString>;
7
8
  uid: z.ZodOptional<z.ZodString>;
@@ -3,7 +3,10 @@ import { languageTagGuard } from '@logto/language-kit';
3
3
  import { z } from 'zod';
4
4
  export { configurableConnectorMetadataGuard, } from '@logto/connector-kit';
5
5
  /* === Commonly Used === */
6
- export const arbitraryObjectGuard = z.record(z.unknown());
6
+ // Copied from https://github.com/colinhacks/zod#json-type
7
+ const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
8
+ const jsonGuard = z.lazy(() => z.union([literalSchema, z.array(jsonGuard), z.record(jsonGuard)]));
9
+ export const jsonObjectGuard = z.record(jsonGuard);
7
10
  /* === OIDC Model Instances === */
8
11
  export const oidcModelInstancePayloadGuard = z
9
12
  .object({
@@ -38,13 +38,13 @@ export declare const phonePasswordPayloadGuard: z.ZodObject<{
38
38
  export type PhonePasswordPayload = z.infer<typeof phonePasswordPayloadGuard>;
39
39
  export declare const socialConnectorPayloadGuard: z.ZodObject<{
40
40
  connectorId: z.ZodString;
41
- connectorData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
41
+ connectorData: z.ZodRecord<z.ZodString, z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
42
42
  }, "strip", z.ZodTypeAny, {
43
43
  connectorId: string;
44
- connectorData: Record<string, unknown>;
44
+ connectorData: Record<string, import("@withtyped/server").Json>;
45
45
  }, {
46
46
  connectorId: string;
47
- connectorData: Record<string, unknown>;
47
+ connectorData: Record<string, import("@withtyped/server").Json>;
48
48
  }>;
49
49
  export type SocialConnectorPayload = z.infer<typeof socialConnectorPayloadGuard>;
50
50
  export declare const socialEmailPayloadGuard: z.ZodObject<{
@@ -123,13 +123,13 @@ export declare const identifierPayloadGuard: z.ZodUnion<[z.ZodObject<{
123
123
  verificationCode: string;
124
124
  }>, z.ZodObject<{
125
125
  connectorId: z.ZodString;
126
- connectorData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
126
+ connectorData: z.ZodRecord<z.ZodString, z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
127
127
  }, "strip", z.ZodTypeAny, {
128
128
  connectorId: string;
129
- connectorData: Record<string, unknown>;
129
+ connectorData: Record<string, import("@withtyped/server").Json>;
130
130
  }, {
131
131
  connectorId: string;
132
- connectorData: Record<string, unknown>;
132
+ connectorData: Record<string, import("@withtyped/server").Json>;
133
133
  }>, z.ZodObject<{
134
134
  connectorId: z.ZodString;
135
135
  email: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  import { emailRegEx, phoneRegEx, usernameRegEx, passwordRegEx } from '@logto/core-kit';
2
2
  import { z } from 'zod';
3
- import { arbitraryObjectGuard } from '../foundations/index.js';
3
+ import { jsonObjectGuard } from '../foundations/index.js';
4
4
  import { emailVerificationCodePayloadGuard, phoneVerificationCodePayloadGuard, } from './verification-code.js';
5
5
  /**
6
6
  * Detailed Identifier Methods guard
@@ -19,7 +19,7 @@ export const phonePasswordPayloadGuard = z.object({
19
19
  });
20
20
  export const socialConnectorPayloadGuard = z.object({
21
21
  connectorId: z.string(),
22
- connectorData: arbitraryObjectGuard,
22
+ connectorData: jsonObjectGuard,
23
23
  });
24
24
  export const socialEmailPayloadGuard = z.object({
25
25
  connectorId: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -4,7 +4,7 @@ create table connectors (
4
4
  id varchar(128) not null,
5
5
  sync_profile boolean not null default FALSE,
6
6
  connector_id varchar(128) not null,
7
- config jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
7
+ config jsonb /* @use JsonObject */ not null default '{}'::jsonb,
8
8
  metadata jsonb /* @use ConfigurableConnectorMetadata */ not null default '{}'::jsonb,
9
9
  created_at timestamptz not null default(now()),
10
10
  primary key (id)
@@ -2,6 +2,6 @@ create table logto_configs (
2
2
  tenant_id varchar(21) not null
3
3
  references tenants (id) on update cascade on delete cascade,
4
4
  key varchar(256) not null,
5
- value jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
5
+ value jsonb /* @use JsonObject */ not null default '{}'::jsonb,
6
6
  primary key (tenant_id, key)
7
7
  );
@@ -3,7 +3,7 @@ create table service_logs (
3
3
  tenant_id varchar(21) not null
4
4
  references tenants (id) on update cascade on delete cascade,
5
5
  type varchar(64) not null,
6
- payload jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
6
+ payload jsonb /* @use JsonObject */ not null default '{}'::jsonb,
7
7
  created_at timestamptz not null default(now()),
8
8
  primary key (id)
9
9
  );
@@ -1,6 +1,6 @@
1
1
  create table systems (
2
2
  key varchar(256) not null,
3
- value jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
3
+ value jsonb /* @use JsonObject */ not null default '{}'::jsonb,
4
4
  primary key (key)
5
5
  );
6
6
 
package/tables/users.sql CHANGED
@@ -15,7 +15,7 @@ create table users (
15
15
  avatar varchar(2048),
16
16
  application_id varchar(21),
17
17
  identities jsonb /* @use Identities */ not null default '{}'::jsonb,
18
- custom_data jsonb /* @use ArbitraryObject */ not null default '{}'::jsonb,
18
+ custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
19
19
  is_suspended boolean not null default false,
20
20
  last_sign_in_at timestamptz,
21
21
  created_at timestamptz not null default (now()),