@oxyhq/contracts 0.13.0 → 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
+ });
@@ -47,3 +47,25 @@ export const deviceTokenMintResponseSchema = z.object({
47
47
  nextDeviceSecret: z.string(),
48
48
  state: deviceSessionStateSchema,
49
49
  });
50
+ /* -------------------------------------------------------------------------- */
51
+ /* Hub ticket — server-side cross-origin device credential sync */
52
+ /* -------------------------------------------------------------------------- */
53
+ /** Request body for `POST /session/device/hub-ticket`. */
54
+ export const deviceHubTicketIssueRequestSchema = z.object({
55
+ returnOrigin: z.string().min(1),
56
+ });
57
+ /** Response from `POST /session/device/hub-ticket`. */
58
+ export const deviceHubTicketIssueResponseSchema = z.object({
59
+ ticket: z.string().min(1),
60
+ expiresIn: z.number().int().positive(),
61
+ });
62
+ /** Request body for `POST /session/device/redeem-ticket`. */
63
+ export const deviceHubTicketRedeemRequestSchema = z.object({
64
+ ticket: z.string().min(1),
65
+ returnOrigin: z.string().min(1),
66
+ });
67
+ /** Response from `POST /session/device/redeem-ticket`. */
68
+ export const deviceHubTicketRedeemResponseSchema = z.object({
69
+ deviceId: z.string().min(1),
70
+ deviceSecret: z.string().min(1),
71
+ });
package/dist/esm/index.js CHANGED
@@ -2,13 +2,14 @@
2
2
  * @oxyhq/contracts — single source of truth for API request/response contracts.
3
3
  *
4
4
  * Zod schemas plus their inferred types, shared by the backend (`@oxyhq/api`)
5
- * and the client SDKs (`@oxyhq/core`, `@oxyhq/auth`, `@oxyhq/services`). The
5
+ * and the client SDKs (`@oxyhq/core`, `@oxyhq/services`). The
6
6
  * producer validates its output and every consumer validates its input against
7
7
  * exactly the same definitions, so the wire shape cannot drift.
8
8
  *
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,
@@ -19,9 +20,6 @@ export {
19
20
  applicationTypeSchema, publicApplicationSchema, sessionStatusSchema, } from './sessionStatus.js';
20
21
  export {
21
22
  // Schemas
22
- fedcmTokenPayloadSchema, } from './fedcmToken.js';
23
- export {
24
- // Schemas
25
23
  recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, appAffinityEventTypeSchema, appAffinityEventSchema, appAffinityEventsIngestSchema, } from './recommendations.js';
26
24
  export {
27
25
  // Schemas
@@ -40,7 +38,7 @@ credentialRecordSchema, verifiableCredentialResponseSchema, credentialIssueResul
40
38
  export {
41
39
  // Schemas
42
40
  linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links.js';
43
- export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, } from './deviceSession.js';
41
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceHubTicketIssueRequestSchema, deviceHubTicketIssueResponseSchema, deviceHubTicketRedeemRequestSchema, deviceHubTicketRedeemResponseSchema, } from './deviceSession.js';
44
42
  export {
45
43
  // Schemas
46
44
  loginResultSchema, } from './deviceBoot.js';
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * This package (`@oxyhq/contracts`) is the dedicated, zero-dependency home for
13
13
  * these contracts so the backend (`@oxyhq/api`) and the client SDKs
14
- * (`@oxyhq/core`, `@oxyhq/auth`, `@oxyhq/services`) can all depend on it without
14
+ * (`@oxyhq/core`, `@oxyhq/services`) can all depend on it without
15
15
  * the backend having to depend on a client SDK to obtain its schemas.
16
16
  *
17
17
  * Faithful to the producers:
@@ -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