@oxyhq/contracts 0.13.1 → 0.14.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.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Account graph wire contracts — organization taxonomy and create-account input.
3
+ *
4
+ * `organizationCategory` classifies `kind: 'organization'` accounts (agency,
5
+ * cooperative, landlord, …) without polluting `User.kind`. Meaningful only when
6
+ * `kind === 'organization'`.
7
+ */
8
+ import { z } from 'zod';
9
+ export const ORGANIZATION_CATEGORIES = [
10
+ 'agency',
11
+ 'cooperative',
12
+ 'landlord',
13
+ 'other',
14
+ ];
15
+ export const organizationCategorySchema = z.enum(ORGANIZATION_CATEGORIES);
16
+ const accountNameSchema = z
17
+ .object({
18
+ first: z.string().trim().max(100).optional(),
19
+ last: z.string().trim().max(100).optional(),
20
+ })
21
+ .optional();
22
+ /**
23
+ * POST /accounts — create a non-personal account under the caller's tree.
24
+ * `organizationCategory` is accepted only when `kind` is `organization`.
25
+ */
26
+ export const createAccountRequestSchema = z
27
+ .object({
28
+ parentAccountId: z.string().trim().min(1).optional(),
29
+ kind: z.enum(['organization', 'project', 'bot']),
30
+ username: z.string().trim().min(1).max(100),
31
+ name: accountNameSchema,
32
+ bio: z.string().trim().max(500).optional(),
33
+ avatar: z.string().optional(),
34
+ description: z.string().trim().max(1000).optional(),
35
+ organizationCategory: organizationCategorySchema.optional(),
36
+ })
37
+ .superRefine((data, ctx) => {
38
+ if (data.organizationCategory !== undefined && data.kind !== 'organization') {
39
+ ctx.addIssue({
40
+ code: z.ZodIssueCode.custom,
41
+ message: 'organizationCategory applies only when kind is organization',
42
+ path: ['organizationCategory'],
43
+ });
44
+ }
45
+ });
package/dist/esm/index.js CHANGED
@@ -9,6 +9,7 @@
9
9
  * Platform-agnostic — zod is the only runtime dependency. No react/react-native/
10
10
  * expo, no `require()` in the ESM build.
11
11
  */
12
+ export { ORGANIZATION_CATEGORIES, organizationCategorySchema, createAccountRequestSchema, } from './accountGraph.js';
12
13
  export {
13
14
  // Schemas
14
15
  userNameSchema, userResponseSchema, userProfileUpdateSchema, currentUserResponseSchema, deviceLinkedSessionSchema, deviceLinkedSessionsResponseSchema,
@@ -30,6 +30,7 @@
30
30
  */
31
31
  import { z } from 'zod';
32
32
  import { verifiedDomainSchema } from './identity.js';
33
+ import { organizationCategorySchema } from './accountGraph.js';
33
34
  export const userNameSchema = z
34
35
  .object({
35
36
  first: z.string().optional(),
@@ -51,7 +52,7 @@ export const userNameSchema = z
51
52
  *
52
53
  * `.passthrough()` keeps the large tail of profile fields
53
54
  * (`privacySettings`, `locations`, `links`, `linksMetadata`, `bio`,
54
- * `description`, `language`, `verified`, timestamps, …) available to callers
55
+ * `description`, `languages`, `verified`, timestamps, …) available to callers
55
56
  * that need them without enumerating every nested shape here — the load-bearing
56
57
  * identity/display fields are the ones we pin precisely.
57
58
  */
@@ -73,7 +74,13 @@ export const userResponseSchema = z
73
74
  color: z.string().nullable().optional(),
74
75
  name: userNameSchema,
75
76
  verified: z.boolean().optional(),
76
- language: z.string().optional(),
77
+ /**
78
+ * The account's languages as full BCP-47 locales (`language-REGION`,
79
+ * e.g. `es-ES`, `en-US`, `pt-BR`), ordered with the PRIMARY (UI) locale
80
+ * first. `languages[0]` is the primary locale — there is no singular
81
+ * `language` field.
82
+ */
83
+ languages: z.array(z.string()).optional(),
77
84
  /**
78
85
  * The account's self-sovereign identifier
79
86
  * (`did:web:<FEDERATION_DOMAIN>:u:<userId>`). Surfaced as a `User`
@@ -85,6 +92,11 @@ export const userResponseSchema = z
85
92
  * entry; present only when the account has verified at least one domain.
86
93
  */
87
94
  verifiedDomains: z.array(verifiedDomainSchema).optional(),
95
+ /**
96
+ * Real-estate / team taxonomy for `kind: 'organization'` accounts.
97
+ * Absent on personal, project, and bot accounts.
98
+ */
99
+ organizationCategory: organizationCategorySchema.optional(),
88
100
  })
89
101
  .passthrough();
90
102
  export const userProfileUpdateSchema = z
@@ -115,7 +127,12 @@ export const userProfileUpdateSchema = z
115
127
  id: z.string().optional(),
116
128
  }))
117
129
  .optional(),
118
- language: z.string().optional(),
130
+ /**
131
+ * Ordered account locales (`language-REGION`), primary first. Replaces
132
+ * the eliminated singular `language`; `languages[0]` is the primary UI
133
+ * locale.
134
+ */
135
+ languages: z.array(z.string()).optional(),
119
136
  accountExpiresAfterInactivityDays: z.number().nullable().optional(),
120
137
  notificationPreferences: z.record(z.unknown()).optional(),
121
138
  userPreferences: z.record(z.unknown()).optional(),