@logto/schemas 1.2.2 → 1.3.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 (53) hide show
  1. package/alterations/1.0.0-1678716747-service-logs.ts +1 -1
  2. package/alterations/1.0.0_beta.10-1-logto-config.ts +1 -1
  3. package/alterations/1.3.0-1683292832-update-hooks.ts +105 -0
  4. package/alterations-js/1.0.0-1678716747-service-logs.js +1 -1
  5. package/alterations-js/1.0.0_beta.10-1-logto-config.js +1 -1
  6. package/alterations-js/1.3.0-1683292832-update-hooks.d.ts +3 -0
  7. package/alterations-js/1.3.0-1683292832-update-hooks.js +73 -0
  8. package/lib/db-entries/application.js +3 -3
  9. package/lib/db-entries/applications-role.js +3 -3
  10. package/lib/db-entries/connector.d.ts +3 -3
  11. package/lib/db-entries/connector.js +5 -5
  12. package/lib/db-entries/custom-phrase.js +2 -2
  13. package/lib/db-entries/hook.d.ts +11 -3
  14. package/lib/db-entries/hook.js +20 -4
  15. package/lib/db-entries/log.js +2 -2
  16. package/lib/db-entries/logto-config.d.ts +3 -3
  17. package/lib/db-entries/logto-config.js +4 -4
  18. package/lib/db-entries/oidc-model-instance.js +2 -2
  19. package/lib/db-entries/passcode.js +3 -3
  20. package/lib/db-entries/resource.js +3 -3
  21. package/lib/db-entries/role.js +3 -3
  22. package/lib/db-entries/roles-scope.js +3 -3
  23. package/lib/db-entries/scope.js +4 -4
  24. package/lib/db-entries/service-log.d.ts +3 -3
  25. package/lib/db-entries/service-log.js +5 -5
  26. package/lib/db-entries/sign-in-experience.js +1 -1
  27. package/lib/db-entries/system.d.ts +3 -3
  28. package/lib/db-entries/system.js +4 -4
  29. package/lib/db-entries/user.d.ts +3 -3
  30. package/lib/db-entries/user.js +4 -4
  31. package/lib/db-entries/users-role.js +3 -3
  32. package/lib/db-entries/verification-status.js +2 -2
  33. package/lib/foundations/jsonb-types.d.ts +22 -10
  34. package/lib/foundations/jsonb-types.js +15 -1
  35. package/lib/types/connector.d.ts +2984 -8
  36. package/lib/types/connector.js +22 -0
  37. package/lib/types/dashboard.d.ts +116 -0
  38. package/lib/types/dashboard.js +18 -0
  39. package/lib/types/index.d.ts +1 -0
  40. package/lib/types/index.js +1 -0
  41. package/lib/types/interactions.d.ts +6 -6
  42. package/lib/types/interactions.js +2 -2
  43. package/lib/types/scope.d.ts +40 -4
  44. package/lib/types/scope.js +4 -1
  45. package/lib/types/user.d.ts +129 -5
  46. package/lib/types/user.js +6 -0
  47. package/package.json +1 -1
  48. package/tables/connectors.sql +1 -1
  49. package/tables/hooks.sql +13 -11
  50. package/tables/logto_configs.sql +1 -1
  51. package/tables/service_logs.sql +1 -1
  52. package/tables/systems.sql +1 -1
  53. package/tables/users.sql +1 -1
@@ -1,10 +1,10 @@
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(),
7
- id: z.string().max(12),
7
+ id: z.string().min(1).max(12),
8
8
  username: z.string().max(128).nullable().optional(),
9
9
  primaryEmail: z.string().max(128).nullable().optional(),
10
10
  primaryPhone: z.string().max(128).nullable().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(),
@@ -2,9 +2,9 @@
2
2
  import { z } from 'zod';
3
3
  const createGuard = z.object({
4
4
  tenantId: z.string().max(21).optional(),
5
- id: z.string().max(21),
6
- userId: z.string().max(21),
7
- roleId: z.string().max(21),
5
+ id: z.string().min(1).max(21),
6
+ userId: z.string().min(1).max(21),
7
+ roleId: z.string().min(1).max(21),
8
8
  });
9
9
  const guard = z.object({
10
10
  tenantId: z.string().max(21),
@@ -2,8 +2,8 @@
2
2
  import { z } from 'zod';
3
3
  const createGuard = z.object({
4
4
  tenantId: z.string().max(21).optional(),
5
- id: z.string().max(21),
6
- userId: z.string().max(21),
5
+ id: z.string().min(1).max(21),
6
+ userId: z.string().min(1).max(21),
7
7
  createdAt: z.number().optional(),
8
8
  });
9
9
  const guard = z.object({
@@ -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>;
@@ -227,17 +228,28 @@ export declare enum HookEvent {
227
228
  PostResetPassword = "PostResetPassword"
228
229
  }
229
230
  export declare const hookEventGuard: z.ZodType<HookEvent>;
230
- export type HookConfig = {
231
+ export declare const hookEventsGuard: z.ZodArray<z.ZodType<HookEvent, z.ZodTypeDef, HookEvent>, "many">;
232
+ export type HookEvents = z.infer<typeof hookEventsGuard>;
233
+ export declare const hookConfigGuard: z.ZodObject<{
231
234
  /** We don't need `type` since v1 only has web hook */
232
235
  /** Method fixed to `POST` */
233
- url: string;
236
+ url: z.ZodString;
234
237
  /** Additional headers that attach to the request */
235
- headers?: Record<string, string>;
238
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
236
239
  /**
240
+ * @deprecated
237
241
  * Retry times when hook response status >= 500.
238
- *
239
- * Must be less than or equal to `3`. Use `0` to disable retry.
240
- **/
242
+ * Now the retry times is fixed to 3.
243
+ * Keep for backward compatibility.
244
+ */
245
+ retries: z.ZodNumber;
246
+ }, "strip", z.ZodTypeAny, {
247
+ headers?: Record<string, string> | undefined;
248
+ url: string;
241
249
  retries: number;
242
- };
243
- export declare const hookConfigGuard: z.ZodType<HookConfig>;
250
+ }, {
251
+ headers?: Record<string, string> | undefined;
252
+ url: string;
253
+ retries: number;
254
+ }>;
255
+ export type HookConfig = z.infer<typeof hookConfigGuard>;
@@ -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({
@@ -123,8 +126,19 @@ export var HookEvent;
123
126
  HookEvent["PostResetPassword"] = "PostResetPassword";
124
127
  })(HookEvent || (HookEvent = {}));
125
128
  export const hookEventGuard = z.nativeEnum(HookEvent);
129
+ export const hookEventsGuard = hookEventGuard.array();
126
130
  export const hookConfigGuard = z.object({
131
+ /** We don't need `type` since v1 only has web hook */
132
+ // type: 'web';
133
+ /** Method fixed to `POST` */
127
134
  url: z.string(),
135
+ /** Additional headers that attach to the request */
128
136
  headers: z.record(z.string()).optional(),
137
+ /**
138
+ * @deprecated
139
+ * Retry times when hook response status >= 500.
140
+ * Now the retry times is fixed to 3.
141
+ * Keep for backward compatibility.
142
+ */
129
143
  retries: z.number().gte(0).lte(3),
130
144
  });