@lota-sdk/shared 0.3.0 → 0.3.2

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": "@lota-sdk/shared",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -5,6 +5,8 @@ import { THREAD } from '../constants/thread'
5
5
  const SURREALDB_RECORD_ID_CLASSES = new Set(['RecordId', 'StringRecordId'])
6
6
 
7
7
  export const unixTimestampSchema = z.coerce.date()
8
+ export const isoDateTimeSchema = z.iso.datetime({ offset: true })
9
+ export const transportIdSchema = z.string().trim().min(1)
8
10
 
9
11
  function coerceRecordIdToString(val: unknown): unknown {
10
12
  if (val === null || val === undefined) return val
@@ -36,7 +38,11 @@ export const recordIdSchema = z.preprocess(
36
38
  }
37
39
  // Handle plain { tb, id } objects
38
40
  const record = val as { tb?: unknown; id?: unknown }
39
- if (typeof record.tb === 'string' && (typeof record.id === 'string' || typeof record.id === 'number')) {
41
+ if (
42
+ typeof record.tb === 'string' &&
43
+ (typeof record.id === 'string' || typeof record.id === 'number') &&
44
+ Object.keys(val).length === 2
45
+ ) {
40
46
  return val
41
47
  }
42
48
  }
@@ -49,7 +55,7 @@ export const recordIdStringSchema = z.preprocess(coerceRecordIdToString, z.strin
49
55
 
50
56
  export const paginationTakeSchema = z.coerce.number().int().min(1).max(THREAD.MAX_MESSAGES_PER_PAGE)
51
57
  export const paginationPageSchema = z.coerce.number().int().min(1)
52
- export const paginationCursorSchema = z.preprocess((value) => value, recordIdSchema)
58
+ export const paginationCursorSchema = z.string().trim().min(1)
53
59
 
54
60
  export const paginationSchemaBase = z.object({
55
61
  page: paginationPageSchema.optional(),
@@ -1,12 +1,12 @@
1
1
  import { z } from 'zod'
2
2
 
3
- import { recordIdSchema } from './common'
3
+ import { transportIdSchema } from './common'
4
4
  import { sdkOrganizationSchema } from './organization'
5
5
 
6
6
  export const createSdkOrganizationRequestSchema = z.object({ name: z.string().trim().min(1).max(100) })
7
7
 
8
8
  export const upsertSdkOrganizationRequestSchema = z.object({
9
- id: recordIdSchema,
9
+ id: transportIdSchema,
10
10
  name: z.string().trim().min(1).max(100),
11
11
  })
12
12
 
@@ -1,12 +1,12 @@
1
1
  import { z } from 'zod'
2
2
 
3
3
  import { baseChatMessageSchema } from './chat-api'
4
- import { paginationPageSchema, paginationTakeSchema, recordIdSchema } from './common'
4
+ import { paginationPageSchema, paginationTakeSchema, transportIdSchema } from './common'
5
5
  import { sdkThreadSchema, sdkThreadTypeSchema } from './thread'
6
6
 
7
7
  export const listSdkThreadsRequestSchema = z.object({
8
- userId: recordIdSchema,
9
- organizationId: recordIdSchema,
8
+ userId: transportIdSchema,
9
+ organizationId: transportIdSchema,
10
10
  type: sdkThreadTypeSchema.optional(),
11
11
  page: paginationPageSchema.optional(),
12
12
  take: paginationTakeSchema.optional(),
@@ -14,8 +14,8 @@ export const listSdkThreadsRequestSchema = z.object({
14
14
  })
15
15
 
16
16
  export const createSdkThreadRequestSchema = z.object({
17
- userId: recordIdSchema,
18
- organizationId: recordIdSchema,
17
+ userId: transportIdSchema,
18
+ organizationId: transportIdSchema,
19
19
  title: z.string().trim().min(1).max(200).optional(),
20
20
  type: sdkThreadTypeSchema.default('default'),
21
21
  agentId: z.string().trim().min(1).optional(),
@@ -45,12 +45,15 @@ export const listSdkThreadMessagesResponseSchema = z.object({
45
45
  nextCursor: z.string().nullable().optional(),
46
46
  })
47
47
 
48
- export const sdkThreadMessageLookupSchema = z.object({ threadId: recordIdSchema, messageId: z.string().trim().min(1) })
48
+ export const sdkThreadMessageLookupSchema = z.object({
49
+ threadId: transportIdSchema,
50
+ messageId: z.string().trim().min(1),
51
+ })
49
52
 
50
53
  export const sdkThreadSendMessageRequestSchema = z.object({
51
- threadId: recordIdSchema,
52
- organizationId: recordIdSchema,
53
- userId: recordIdSchema,
54
+ threadId: transportIdSchema,
55
+ organizationId: transportIdSchema,
56
+ userId: transportIdSchema,
54
57
  userName: z.string().trim().min(1),
55
58
  messages: z.array(baseChatMessageSchema).min(1),
56
59
  })
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod'
2
2
 
3
- import { recordIdSchema } from './common'
3
+ import { transportIdSchema } from './common'
4
4
  import { sdkUserSchema } from './user'
5
5
 
6
6
  export const upsertSdkUserRequestSchema = z.object({
7
- id: recordIdSchema,
7
+ id: transportIdSchema,
8
8
  name: z.string().trim().min(1).max(100),
9
9
  email: z.string().email(),
10
10
  })