@oxyhq/contracts 0.20.0 → 0.22.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.
@@ -1,11 +1,75 @@
1
1
  /**
2
- * Account graph wire contracts — organization taxonomy and create-account input.
2
+ * Account graph wire contracts — the account-kind vocabulary, organization
3
+ * taxonomy, and create-account input.
3
4
  *
4
5
  * `organizationCategory` classifies `kind: 'organization'` accounts (agency,
5
6
  * cooperative, landlord, …) without polluting `User.kind`. Meaningful only when
6
7
  * `kind === 'organization'`.
7
8
  */
8
9
  import { z } from 'zod';
10
+ /**
11
+ * Account-graph classification — the ONE authority for the kind vocabulary.
12
+ *
13
+ * `personal` is the only kind minted by signup and the only one that carries
14
+ * its own credentials; every other kind is a child account created under a
15
+ * parent and operated through `account_members`. The API schema, the Mongoose
16
+ * model and the SDK all derive from this list rather than restating it, so a
17
+ * new kind is one edit here instead of four literals that can drift.
18
+ */
19
+ export type AccountKind = 'personal' | 'organization' | 'project' | 'bot' | 'channel';
20
+ /**
21
+ * The union is spelled out above and the array proves coverage BOTH ways
22
+ * (`satisfies` here, the `Gap` alias below) — the same shape this package's
23
+ * `ORGANIZATION_CATEGORIES` / `TRUST_TIERS` pairs use, and the one
24
+ * `db/schema/users.ts` mirrors to keep the `users_kind_check` CHECK honest.
25
+ *
26
+ * Deriving the union from the array instead would cost nothing here and be paid
27
+ * by consumers: `kind` travels into `@oxyhq/services` through
28
+ * `SwitchableAccount`, where an indexed-access type is materially more
29
+ * expensive to check than a literal union.
30
+ */
31
+ export declare const ACCOUNT_KINDS: readonly ["personal", "organization", "project", "bot", "channel"];
32
+ /** `never` while `ACCOUNT_KINDS` covers the union. */
33
+ export type AccountKindGap = Exclude<AccountKind, (typeof ACCOUNT_KINDS)[number]>;
34
+ export declare const accountKindSchema: z.ZodEnum<["personal", "organization", "project", "bot", "channel"]>;
35
+ /**
36
+ * Kinds that may be CREATED as children of another account. Exactly
37
+ * `ACCOUNT_KINDS` minus `personal`, which is always a tree root.
38
+ */
39
+ export type ChildAccountKind = Exclude<AccountKind, 'personal'>;
40
+ export declare const CHILD_ACCOUNT_KINDS: readonly ["organization", "project", "bot", "channel"];
41
+ /** `never` while `CHILD_ACCOUNT_KINDS` covers the child union. */
42
+ export type ChildAccountKindGap = Exclude<ChildAccountKind, (typeof CHILD_ACCOUNT_KINDS)[number]>;
43
+ export declare const childAccountKindSchema: z.ZodEnum<["organization", "project", "bot", "channel"]>;
44
+ /**
45
+ * Whether an operator may ACT AS an account of this kind — switch the whole app
46
+ * into it (`POST /accounts/:id/switch`) or authorise an app to act as it
47
+ * (an OAuth delegated subject).
48
+ *
49
+ * Two kinds are refused, for opposite reasons:
50
+ *
51
+ * - `personal` is a human login, so assuming it would be impersonation.
52
+ * - `channel` is a CONTENT identity, not an operating one. A channel exists so
53
+ * that posts can be authored BY it; it is never a seat anybody occupies. Its
54
+ * operators act on it through their own membership, and an application
55
+ * publishes to it with its own credential. Refusing act-as is what makes
56
+ * "no login, ever" structural rather than incidental: no session can be
57
+ * minted whose subject is a channel, so no bearer exists that could add an
58
+ * auth method to one (every auth-method write resolves its target from the
59
+ * authenticated subject, never from a parameter).
60
+ *
61
+ * Consumers must gate on this predicate rather than testing `kind === 'personal'`,
62
+ * which silently admits every kind added after it was written.
63
+ */
64
+ export declare function isActAsEligibleKind(kind: AccountKind | null | undefined): boolean;
65
+ /**
66
+ * Narrow an unknown value to an {@link AccountKind}.
67
+ *
68
+ * The user-DTO serializers read from structurally-permissive `unknown` sources
69
+ * (a Drizzle row, a Mongo document, an already-formatted object), so each one
70
+ * would otherwise hand-roll this check and they would drift on what counts.
71
+ */
72
+ export declare function isAccountKind(value: unknown): value is AccountKind;
9
73
  export declare const ORGANIZATION_CATEGORIES: readonly ["agency", "cooperative", "landlord", "other"];
10
74
  export type OrganizationCategory = (typeof ORGANIZATION_CATEGORIES)[number];
11
75
  export declare const organizationCategorySchema: z.ZodEnum<["agency", "cooperative", "landlord", "other"]>;
@@ -15,65 +79,72 @@ export declare const organizationCategorySchema: z.ZodEnum<["agency", "cooperati
15
79
  */
16
80
  export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
17
81
  parentAccountId: z.ZodOptional<z.ZodString>;
18
- kind: z.ZodEnum<["organization", "project", "bot"]>;
82
+ kind: z.ZodEnum<["organization", "project", "bot", "channel"]>;
19
83
  username: z.ZodString;
20
84
  name: z.ZodOptional<z.ZodObject<{
21
85
  first: z.ZodOptional<z.ZodString>;
22
86
  last: z.ZodOptional<z.ZodString>;
87
+ displayName: z.ZodOptional<z.ZodString>;
23
88
  }, "strip", z.ZodTypeAny, {
24
89
  first?: string | undefined;
25
90
  last?: string | undefined;
91
+ displayName?: string | undefined;
26
92
  }, {
27
93
  first?: string | undefined;
28
94
  last?: string | undefined;
95
+ displayName?: string | undefined;
29
96
  }>>;
30
97
  bio: z.ZodOptional<z.ZodString>;
31
98
  avatar: z.ZodOptional<z.ZodString>;
32
99
  description: z.ZodOptional<z.ZodString>;
33
100
  organizationCategory: z.ZodOptional<z.ZodEnum<["agency", "cooperative", "landlord", "other"]>>;
34
101
  }, "strip", z.ZodTypeAny, {
35
- kind: "organization" | "project" | "bot";
102
+ kind: "organization" | "project" | "bot" | "channel";
36
103
  username: string;
37
104
  parentAccountId?: string | undefined;
38
105
  name?: {
39
106
  first?: string | undefined;
40
107
  last?: string | undefined;
108
+ displayName?: string | undefined;
41
109
  } | undefined;
42
110
  bio?: string | undefined;
43
111
  avatar?: string | undefined;
44
112
  description?: string | undefined;
45
113
  organizationCategory?: "agency" | "cooperative" | "landlord" | "other" | undefined;
46
114
  }, {
47
- kind: "organization" | "project" | "bot";
115
+ kind: "organization" | "project" | "bot" | "channel";
48
116
  username: string;
49
117
  parentAccountId?: string | undefined;
50
118
  name?: {
51
119
  first?: string | undefined;
52
120
  last?: string | undefined;
121
+ displayName?: string | undefined;
53
122
  } | undefined;
54
123
  bio?: string | undefined;
55
124
  avatar?: string | undefined;
56
125
  description?: string | undefined;
57
126
  organizationCategory?: "agency" | "cooperative" | "landlord" | "other" | undefined;
58
127
  }>, {
59
- kind: "organization" | "project" | "bot";
128
+ kind: "organization" | "project" | "bot" | "channel";
60
129
  username: string;
61
130
  parentAccountId?: string | undefined;
62
131
  name?: {
63
132
  first?: string | undefined;
64
133
  last?: string | undefined;
134
+ displayName?: string | undefined;
65
135
  } | undefined;
66
136
  bio?: string | undefined;
67
137
  avatar?: string | undefined;
68
138
  description?: string | undefined;
69
139
  organizationCategory?: "agency" | "cooperative" | "landlord" | "other" | undefined;
70
140
  }, {
71
- kind: "organization" | "project" | "bot";
141
+ kind: "organization" | "project" | "bot" | "channel";
72
142
  username: string;
73
143
  parentAccountId?: string | undefined;
74
144
  name?: {
75
145
  first?: string | undefined;
76
146
  last?: string | undefined;
147
+ displayName?: string | undefined;
77
148
  } | undefined;
78
149
  bio?: string | undefined;
79
150
  avatar?: string | undefined;
@@ -9,8 +9,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';
13
- export type { OrganizationCategory, CreateAccountRequest, } from './accountGraph';
12
+ export { ACCOUNT_KINDS, accountKindSchema, CHILD_ACCOUNT_KINDS, childAccountKindSchema, isAccountKind, isActAsEligibleKind, ORGANIZATION_CATEGORIES, organizationCategorySchema, createAccountRequestSchema, } from './accountGraph';
13
+ export type { AccountKind, ChildAccountKind, OrganizationCategory, CreateAccountRequest, } from './accountGraph';
14
14
  export { userNameSchema, userRelationshipSchema, themePreferenceSchema, userResponseSchema, userProfileUpdateSchema, currentUserResponseSchema, deviceLinkedSessionSchema, deviceLinkedSessionsResponseSchema, resolveUserId, safeParseContract, } from './userResponse';
15
15
  export type { UserNameResponse, UserRelationship, ThemePreference, UserResponse, UserProfileUpdate, CurrentUserResponseContract, DeviceLinkedSessionResponse, DeviceLinkedSessionsResponseContract, } from './userResponse';
16
16
  export { applicationTypeSchema, publicApplicationSchema, sessionStatusSchema, } from './sessionStatus';
@@ -19,6 +19,8 @@ export { COMMONS_DENY_REASONS, commonsDenyReasonSchema, IDENTITY_APPROVAL_PUSH_C
19
19
  export type { CommonsDenyReason } from './commonsSignIn';
20
20
  export { INBOX_EMAIL_PUSH_CHANNEL, INBOX_EMAIL_PUSH_TYPE, inboxEmailPushDataSchema, } from './inboxPush';
21
21
  export type { InboxEmailPushData } from './inboxPush';
22
+ export { OXY_USER_INVALIDATION_CHANNEL, OXY_USER_CHANGE_REASONS, OXY_PUBLISHED_USER_CHANGE_REASONS, isPublishedOxyUserChangeReason, oxyUserInvalidationEventSchema, } from './userInvalidation';
23
+ export type { OxyUserChangeReason, PublishedOxyUserChangeReason, OxyUserInvalidationEvent, } from './userInvalidation';
22
24
  export { recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, appAffinityEventTypeSchema, appAffinityEventSchema, appAffinityEventsIngestSchema, } from './recommendations';
23
25
  export type { RecommendationExcludeType, RecommendationBoost, RecommendationSignalWeights, RecommendationRequest, RecommendationCount, RecommendationItem, RecommendationResponse, AppEndorsementInput, AppInterestInput, AppUserSignalIngest, AppAffinityEventType, AppAffinityEvent, AppAffinityEventsIngest, } from './recommendations';
24
26
  export { verificationMethodSchema, didServiceSchema, didDocumentSchema, signedRecordEnvelopeSchema, verifiedDomainSchema, domainVerificationRequestSchema, domainVerificationInstructionsSchema, authMethodEntrySchema, authMethodsResponseSchema, exportAttestationSchema, exportBundleSchema, } from './identity';
@@ -31,6 +33,8 @@ export { publicCardSchema, signedPublicCardSchema, realLifeAttestationRecordSche
31
33
  export type { CardTrustTier, PersonhoodStatus, PublicCard, SignedPublicCard, RealLifeAttestationRecord, RealLifeAttestationResult, ValidationVerdict, ValidationRequestStatus, ValidationVerdictRecord, ValidationOpenRequest, ValidationOpenResult, ValidationRequestSummary, ValidationVoteResult, PersonhoodVouchRecord, PersonhoodBreakdown, PersonhoodStatusResult, VouchResult, CredentialStatus, CredentialRecord, VerifiableCredentialResponse, CredentialIssueResult, CredentialListResult, CredentialVerifyResult, } from './civic';
32
34
  export { REPUTATION_CATEGORIES, REPUTATION_TRANSACTION_STATUSES, TRUST_TIERS, REPUTATION_TARGET_ENTITY_TYPES, REPUTATION_DISPUTE_STATUSES, REPUTATION_INFLUENCE_CONTEXTS, reputationCategorySchema, reputationTransactionStatusSchema, trustTierSchema, reputationTargetEntityTypeSchema, reputationDisputeStatusSchema, reputationInfluenceContextSchema, reputationTransactionSchema, reputationBalanceBreakdownSchema, reputationInfluenceSchema, reputationReliabilitySchema, reputationBalanceSummarySchema, reputationBalanceSchema, reputationDisputeSchema, reputationRuleSchema, reputationLeaderboardUserSchema, reputationLeaderboardEntrySchema, reputationInfluenceResultSchema, reverseReputationTransactionResultSchema, awardReputationSchema, createReputationDisputeSchema, resolveReputationDisputeSchema, upsertReputationRuleSchema, reverseReputationTransactionSchema, isFullReputationBalance, } from './reputation';
33
35
  export type { ReputationCategory, ReputationTransactionStatus, TrustTier, ReputationTargetEntityType, ReputationDisputeStatus, ReputationInfluenceContext, ReputationTransaction, ReputationBalanceBreakdown, ReputationInfluence, ReputationReliability, ReputationBalanceSummary, ReputationBalance, ReputationBalanceView, ReputationDispute, ReputationRule, ReputationLeaderboardUser, ReputationLeaderboardEntry, ReputationInfluenceResult, ReverseReputationTransactionResult, AwardReputationInput, CreateReputationDisputeInput, ResolveReputationDisputeInput, UpsertReputationRuleInput, UpsertReputationRuleRequest, ReverseReputationTransactionInput, } from './reputation';
36
+ export { MODERATION_SEVERITIES, MODERATION_FINDING_SCOPES, MODERATION_ATTRIBUTIONS, MODERATION_DECISION_STATUSES, MODERATION_EFFECT_TYPES, MODERATION_EFFECT_STATUSES, MODERATION_EFFECT_SKIP_REASONS, CONDUCT_STRIKE_STATUSES, CONDUCT_STANDINGS, CONTRIBUTION_TIERS, PERSONHOOD_STATUSES, IDENTITY_BINDING_TYPES, IDENTITY_BINDING_STATUSES, APPLICATION_MODERATION_STANDINGS, moderationSeveritySchema, moderationFindingScopeSchema, moderationAttributionSchema, moderationDecisionStatusSchema, moderationEffectTypeSchema, moderationEffectStatusSchema, moderationEffectSkipReasonSchema, conductStrikeStatusSchema, conductStandingSchema, contributionTierSchema, personhoodStatusSchema, identityBindingTypeSchema, identityBindingStatusSchema, applicationModerationStandingSchema, moderationFindingSchema, moderationDecisionEventSubjectSchema, moderationPolicyVersionsSchema, moderationDecisionEventSchema, finalizeModerationDecisionSchema, reverseModerationEffectSchema, moderationEffectSchema, applyModerationDecisionResultSchema, reverseModerationEffectResultSchema, registerIdentityBindingSchema, identityBindingSchema, reputationPersonhoodSchema, reputationContributionSchema, reputationConductSchema, reputationReportingSchema, reputationReviewingSchema, reputationContextualInfluenceSchema, applicationModerationTrustSchema, } from './moderationReputation';
37
+ export type { ModerationSeverity, ModerationFindingScope, ModerationAttribution, ModerationDecisionStatus, ModerationEffectType, ModerationEffectStatus, ModerationEffectSkipReason, ConductStrikeStatus, ConductStanding, ContributionTier, PersonhoodStatusValue, IdentityBindingType, IdentityBindingStatus, ApplicationModerationStanding, ModerationFinding, ModerationDecisionEventSubject, ModerationPolicyVersions, ModerationDecisionEvent, FinalizeModerationDecisionInput, ReverseModerationEffectInput, ModerationEffect, ApplyModerationDecisionResult, ReverseModerationEffectResult, RegisterIdentityBindingInput, IdentityBinding, ReputationPersonhood, ReputationContribution, ReputationConduct, ReputationReporting, ReputationReviewing, ReputationContextualInfluence, ApplicationModerationTrust, } from './moderationReputation';
34
38
  export { linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links';
35
39
  export type { LinkPreviewStatus, LinkPreview, LinkPreviewBatchRequest, LinkPreviewBatchResponse, } from './links';
36
40
  export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceBackgroundCredentialResponseSchema, deviceBackgroundTokenRequestSchema, deviceBackgroundTokenResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession';