@oxyhq/contracts 0.13.1 → 0.13.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.
@@ -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(),
@@ -85,6 +86,11 @@ export const userResponseSchema = z
85
86
  * entry; present only when the account has verified at least one domain.
86
87
  */
87
88
  verifiedDomains: z.array(verifiedDomainSchema).optional(),
89
+ /**
90
+ * Real-estate / team taxonomy for `kind: 'organization'` accounts.
91
+ * Absent on personal, project, and bot accounts.
92
+ */
93
+ organizationCategory: organizationCategorySchema.optional(),
88
94
  })
89
95
  .passthrough();
90
96
  export const userProfileUpdateSchema = z