@company-semantics/contracts 1.11.1 → 1.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "1.11.1",
3
+ "version": "1.13.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -104,7 +104,8 @@
104
104
  "generate:api": "pnpm generate:api-types && pnpm generate:spec-hash",
105
105
  "generate:api-types": "openapi-typescript openapi/backend.yaml -o src/api/generated.ts",
106
106
  "generate:openapi-routes": "tsx scripts/generate-openapi-routes.ts",
107
- "generate:api-types:check": "openapi-typescript openapi/backend.yaml -o /tmp/cs-api-types-check.ts && diff -q src/api/generated.ts /tmp/cs-api-types-check.ts"
107
+ "generate:api-types:check": "openapi-typescript openapi/backend.yaml -o /tmp/cs-api-types-check.ts && diff -q src/api/generated.ts /tmp/cs-api-types-check.ts",
108
+ "generate:current": "tsx ../company-semantics-ci/scripts/generate-current.ts"
108
109
  },
109
110
  "packageManager": "pnpm@10.25.0",
110
111
  "engines": {
package/src/index.ts CHANGED
@@ -288,6 +288,7 @@ export type {
288
288
  // Company.md domain types (PRD-00173)
289
289
  CompanyMdVisibility,
290
290
  CompanyMdDocLevel,
291
+ CompanyMdDocKind,
291
292
  CompanyMdNodeType,
292
293
  CompanyMdSource,
293
294
  CompanyMdDependency,
@@ -6,15 +6,61 @@
6
6
  * @see PRD-00173 for design rationale
7
7
  */
8
8
 
9
- export type CompanyMdVisibility = 'public' | 'private';
9
+ export type CompanyMdVisibility = "public" | "private";
10
10
 
11
- export type CompanyMdDocLevel = 'root' | 'department' | 'team' | 'context';
11
+ /**
12
+ * @deprecated Since 1.12.0. `CompanyMdDocLevel` is superseded by `CompanyMdDocKind` + `depth`.
13
+ *
14
+ * The categorical naming here conflates structural position with a specific
15
+ * org's label vocabulary. `CompanyMdDocKind` ('root' | 'unit' | 'context')
16
+ * carries the structural discriminator; `depth` carries the position. Labels
17
+ * come from `org_level_config`.
18
+ *
19
+ * This alias remains valid through the next minor. It will be removed in the
20
+ * next major. Backend still emits these values on the wire until PRD-00524
21
+ * lands, after which `kind` + `depth` are canonical.
22
+ */
23
+ export type CompanyMdDocLevel = "root" | "department" | "team" | "context";
12
24
 
13
- export type CompanyMdNodeType = 'company' | 'department' | 'team' | 'cross_team' | 'doc' | 'goal' | 'source' | 'map' | 'context_bank';
25
+ /**
26
+ * Structural discriminator for a Company.md document.
27
+ *
28
+ * - `'root'`: the single org-wide doc (one per org).
29
+ * - `'unit'`: a doc owning an `org_unit` at depth 2..5. The specific depth is
30
+ * carried separately on `depth`. Use `depth` + `org_level_config` for
31
+ * presentation, never the string `'unit'` for user-visible labels.
32
+ * - `'context'`: a context-bank doc attached to a parent doc.
33
+ *
34
+ * Replaces the categorical `CompanyMdDocLevel` ('department' | 'team' ...).
35
+ */
36
+ export type CompanyMdDocKind = "root" | "unit" | "context";
37
+
38
+ /**
39
+ * Semantic node type used by the Company.md tree.
40
+ *
41
+ * Structural members ('company', 'department', 'team', 'cross_team') are
42
+ * @deprecated — use `'unit'` plus `depth` instead. They remain in the union
43
+ * through the next minor for backward compatibility and will be removed in
44
+ * the next major.
45
+ *
46
+ * Non-structural members ('doc', 'goal', 'source', 'map', 'context_bank')
47
+ * are not affected by the deprecation.
48
+ */
49
+ export type CompanyMdNodeType =
50
+ | "company" // @deprecated — use 'unit' with depth=1
51
+ | "department" // @deprecated — use 'unit' with depth=2
52
+ | "team" // @deprecated — use 'unit' with depth=3
53
+ | "cross_team" // @deprecated — use 'unit' with a custom typeTag
54
+ | "unit"
55
+ | "doc"
56
+ | "goal"
57
+ | "source"
58
+ | "map"
59
+ | "context_bank";
14
60
 
15
61
  export interface CompanyMdSource {
16
62
  readonly label: string;
17
- readonly sourceType: 'meeting' | 'document' | 'conversation' | 'manual';
63
+ readonly sourceType: "meeting" | "document" | "conversation" | "manual";
18
64
  readonly referencedAt: string;
19
65
  }
20
66
 
@@ -28,6 +74,15 @@ export interface CompanyMdNodeIdentity {
28
74
  readonly slug: string;
29
75
  readonly title: string;
30
76
  readonly level: CompanyMdDocLevel;
77
+ /**
78
+ * Authoritative structural position in the org tree (matches `nlevel(path)`
79
+ * on the owning org_unit). Null for non-structural nodes (context bank items,
80
+ * docs/goals/sources/maps that are not owned by a unit).
81
+ *
82
+ * Prefer this over `level` for structural reasoning. `level` is retained for
83
+ * backward compatibility and is @deprecated.
84
+ */
85
+ readonly depth: 1 | 2 | 3 | 4 | 5 | null;
31
86
  readonly parentId: string | null;
32
87
  readonly visibility: CompanyMdVisibility;
33
88
  /** Owning org_unit. Null for root docs or when the owning unit has been archived. */
@@ -53,9 +108,15 @@ export interface CompanyMdDocCore extends CompanyMdNodeIdentity {
53
108
 
54
109
  export interface CompanyMdDocCollaborators {
55
110
  readonly owner: { readonly id: string; readonly name: string } | null;
56
- readonly coOwners: ReadonlyArray<{ readonly id: string; readonly name: string }>;
111
+ readonly coOwners: ReadonlyArray<{
112
+ readonly id: string;
113
+ readonly name: string;
114
+ }>;
57
115
  readonly canEdit: boolean;
58
- readonly members: ReadonlyArray<{ readonly id: string; readonly name: string }>;
116
+ readonly members: ReadonlyArray<{
117
+ readonly id: string;
118
+ readonly name: string;
119
+ }>;
59
120
  }
60
121
 
61
122
  export interface CompanyMdDocRelations {
@@ -66,7 +127,9 @@ export interface CompanyMdDocRelations {
66
127
  readonly updatedAt: string;
67
128
  }
68
129
 
69
- export type CompanyMdDoc = CompanyMdDocCore & CompanyMdDocCollaborators & CompanyMdDocRelations;
130
+ export type CompanyMdDoc = CompanyMdDocCore &
131
+ CompanyMdDocCollaborators &
132
+ CompanyMdDocRelations;
70
133
 
71
134
  /**
72
135
  * A context bank item — a company.md doc associated with one or more parent nodes.
package/src/org/index.ts CHANGED
@@ -88,6 +88,7 @@ export { orderTreeNodes } from './tree-ordering';
88
88
  export type {
89
89
  CompanyMdVisibility,
90
90
  CompanyMdDocLevel,
91
+ CompanyMdDocKind,
91
92
  CompanyMdNodeType,
92
93
  CompanyMdSource,
93
94
  CompanyMdDependency,
@@ -234,6 +235,8 @@ export {
234
235
  OrgUnitMembershipListResponseSchema,
235
236
  OrgUnitPermissionsEntrySchema,
236
237
  ListOrgUnitPermissionsResponseSchema,
238
+ UpdateOrgUnitRequestSchema,
239
+ UpdateOrgUnitResponseSchema,
237
240
  } from './schemas';
238
241
  export type {
239
242
  OrgUnit,
@@ -253,4 +256,6 @@ export type {
253
256
  OrgUnitMembershipListResponse,
254
257
  OrgUnitPermissionsEntry,
255
258
  ListOrgUnitPermissionsResponse,
259
+ UpdateOrgUnitRequest,
260
+ UpdateOrgUnitResponse,
256
261
  } from './schemas';
@@ -788,6 +788,24 @@ export const ListOrgUnitPermissionsResponseSchema = z.object({
788
788
  entries: z.array(OrgUnitPermissionsEntrySchema),
789
789
  });
790
790
 
791
+ // ---------------------------------------------------------------------------
792
+ // PATCH /api/org-units/:unitId (PRD-00526)
793
+ // Request schema colocated with the response schema so the app can import
794
+ // the same shape backend validates against. This is a narrow deviation from
795
+ // ADR-CONT-044 (request schemas normally live in backend) because the
796
+ // partial-update + at-least-one-field refinement is the published promise
797
+ // consumers must satisfy.
798
+ // ---------------------------------------------------------------------------
799
+
800
+ export const UpdateOrgUnitRequestSchema = z.object({
801
+ name: z.string().min(1).max(255).optional(),
802
+ description: z.string().max(2000).nullable().optional(),
803
+ }).refine((v) => v.name !== undefined || v.description !== undefined, {
804
+ message: 'at least one of name or description must be provided',
805
+ });
806
+
807
+ export const UpdateOrgUnitResponseSchema = z.object({ unit: OrgUnitSchema });
808
+
791
809
  // --- Inferred types ---
792
810
 
793
811
  export type OrgUnit = z.infer<typeof OrgUnitSchema>;
@@ -807,3 +825,5 @@ export type OrgUnitMembershipResponse = z.infer<typeof OrgUnitMembershipResponse
807
825
  export type OrgUnitMembershipListResponse = z.infer<typeof OrgUnitMembershipListResponseSchema>;
808
826
  export type OrgUnitPermissionsEntry = z.infer<typeof OrgUnitPermissionsEntrySchema>;
809
827
  export type ListOrgUnitPermissionsResponse = z.infer<typeof ListOrgUnitPermissionsResponseSchema>;
828
+ export type UpdateOrgUnitRequest = z.infer<typeof UpdateOrgUnitRequestSchema>;
829
+ export type UpdateOrgUnitResponse = z.infer<typeof UpdateOrgUnitResponseSchema>;