@teardown/schemas 0.1.46 → 0.1.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/schemas",
3
- "version": "0.1.46",
3
+ "version": "0.1.49",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -91,18 +91,18 @@
91
91
  },
92
92
  "scripts": {
93
93
  "dev": "bun run typecheck --watch",
94
- "typecheck": "tsc --noEmit --project ./tsconfig.json",
94
+ "typecheck": "bun x tsgo --noEmit --project ./tsconfig.json",
95
95
  "lint": "bun x biome lint .",
96
96
  "fmt": "bun x biome format --write .",
97
97
  "check": "bun x biome check ."
98
98
  },
99
99
  "dependencies": {
100
100
  "@sinclair/typebox": "^0.34.41",
101
- "@teardown/types": "0.1.46"
101
+ "@teardown/types": "0.1.49"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@biomejs/biome": "2.3.8",
105
- "@teardown/tsconfig": "0.1.46",
105
+ "@teardown/tsconfig": "0.1.49",
106
106
  "typescript": "5.9.3"
107
107
  },
108
108
  "peerDependencies": {
@@ -1,14 +1,14 @@
1
1
  /**
2
- * Session token expiry in days
2
+ * Session token expiry in minutes
3
3
  */
4
- export const SESSION_TOKEN_EXPIRY_DAYS = 30;
4
+ export const SESSION_TOKEN_EXPIRY_MINUTES = 15;
5
5
 
6
6
  /**
7
7
  * Session token expiry in milliseconds
8
8
  */
9
- export const SESSION_TOKEN_EXPIRY_MS = SESSION_TOKEN_EXPIRY_DAYS * 24 * 60 * 60 * 1000;
9
+ export const SESSION_TOKEN_EXPIRY_MS = SESSION_TOKEN_EXPIRY_MINUTES * 60 * 1000;
10
10
 
11
11
  /**
12
12
  * Session token expiry as jose duration string
13
13
  */
14
- export const SESSION_TOKEN_EXPIRY_JOSE = `${SESSION_TOKEN_EXPIRY_DAYS}d` as const;
14
+ export const SESSION_TOKEN_EXPIRY_JOSE = "15m" as const;
@@ -1,4 +1,4 @@
1
- import { Type, type Static } from "@sinclair/typebox";
1
+ import { type Static, Type } from "@sinclair/typebox";
2
2
  import { SubscriptionStatusEnum, SubscriptionTierEnum } from "@teardown/types";
3
3
 
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { VersionBuildStatusEnum } from "@teardown/types";
2
1
  import { type Static, Type } from "@sinclair/typebox";
2
+ import { VersionBuildStatusEnum } from "@teardown/types";
3
3
  import type { AssertSchemaCompatibleWithRow, AssertTrue } from "../../common";
4
4
  import { DevicePlatformSchema } from "../devices/schemas";
5
5
 
@@ -1,2 +1 @@
1
1
  export * from "./schemas";
2
-
@@ -18,7 +18,9 @@ export const EventSchema = Type.Object({
18
18
  /**
19
19
  * Type of event
20
20
  */
21
- event_type: Type.Union([Type.Literal("action"), Type.Literal("screen_view"), Type.Literal("custom")], { default: "custom" }),
21
+ event_type: Type.Union([Type.Literal("action"), Type.Literal("screen_view"), Type.Literal("custom")], {
22
+ default: "custom",
23
+ }),
22
24
  /**
23
25
  * Custom properties for the event (optional)
24
26
  */
@@ -120,14 +120,34 @@ export type DeviceInfo = Static<typeof DeviceInfoSchema>;
120
120
  /**
121
121
  * User info schema (optional fields)
122
122
  * Matches project_users table structure
123
+ *
124
+ * Supports both `persona_id` (preferred) and `user_id` (deprecated, for backwards compatibility).
125
+ * If both are provided, `persona_id` takes precedence.
123
126
  */
124
127
  export const UserInfoSchema = Type.Object({
125
- user_id: Type.Optional(Type.String({ error: "user_id is required" })),
128
+ /**
129
+ * Your app's unique identifier for this user (preferred)
130
+ */
131
+ persona_id: Type.Optional(Type.String({ error: "persona_id must be a string" })),
132
+ /**
133
+ * @deprecated Use `persona_id` instead. Kept for backwards compatibility.
134
+ * Your app's unique identifier for this user
135
+ */
136
+ user_id: Type.Optional(Type.String({ error: "user_id must be a string" })),
126
137
  email: Type.Optional(EmailSchema),
127
138
  name: Type.Optional(Type.String({ error: "name is required" })),
128
139
  });
129
140
  export type UserInfo = Static<typeof UserInfoSchema>;
130
141
 
142
+ /**
143
+ * Resolves the effective user identifier from UserInfo.
144
+ * Prefers persona_id over user_id for backwards compatibility.
145
+ */
146
+ export function resolvePersonaId(userInfo: UserInfo | undefined): string | undefined {
147
+ if (!userInfo) return undefined;
148
+ return userInfo.persona_id ?? userInfo.user_id;
149
+ }
150
+
131
151
  /** @deprecated Use UserInfoSchema instead */
132
152
  export const PersonaInfoSchema = UserInfoSchema;
133
153
  /** @deprecated Use UserInfo instead */
@@ -33,9 +33,12 @@ export const SearchProjectUsersQuerySchema = Type.Object({
33
33
  page: Type.Number({ minimum: 1, default: 1 }),
34
34
  limit: Type.Number({ minimum: 1, maximum: 100, default: 20 }),
35
35
  search: Type.Optional(Type.String()),
36
- sort_by: Type.Union([Type.Literal("created_at"), Type.Literal("updated_at"), Type.Literal("name"), Type.Literal("email")], {
37
- default: "created_at",
38
- }),
36
+ sort_by: Type.Union(
37
+ [Type.Literal("created_at"), Type.Literal("updated_at"), Type.Literal("name"), Type.Literal("email")],
38
+ {
39
+ default: "created_at",
40
+ }
41
+ ),
39
42
  sort_order: Type.Union([Type.Literal("asc"), Type.Literal("desc")], { default: "desc" }),
40
43
  });
41
44
  export type SearchProjectUsersQuery = Static<typeof SearchProjectUsersQuerySchema>;
package/tsconfig.json CHANGED
@@ -3,7 +3,6 @@
3
3
  "compilerOptions": {
4
4
  "noEmit": true,
5
5
  "rootDir": "./src",
6
- "baseUrl": ".",
7
6
  "paths": {
8
7
  "@/*": ["./src/*"]
9
8
  },