@company-semantics/contracts 1.2.0 → 1.4.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 +1 -1
- package/src/api/generated-spec-hash.ts +2 -2
- package/src/api/generated.ts +0 -90
- package/src/content/index.ts +0 -2
- package/src/content/schemas.ts +0 -12
- package/src/org/__tests__/org-units.test.ts +48 -0
- package/src/org/company-md.ts +0 -19
- package/src/org/index.ts +4 -5
- package/src/org/schemas.ts +22 -0
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// AUTO-GENERATED — do not edit. Run pnpm generate:spec-hash to regenerate.
|
|
2
|
-
export const SPEC_HASH = '
|
|
3
|
-
export const SPEC_HASH_FULL = '
|
|
2
|
+
export const SPEC_HASH = '2378a6034349' as const;
|
|
3
|
+
export const SPEC_HASH_FULL = '2378a6034349f4280d4f9aa3536002db130f8a1c03911b6f2513e14e036d85c4' as const;
|
package/src/api/generated.ts
CHANGED
|
@@ -1330,40 +1330,6 @@ export interface paths {
|
|
|
1330
1330
|
patch: operations["reorderCompanyMdContextBankItem"];
|
|
1331
1331
|
trace?: never;
|
|
1332
1332
|
};
|
|
1333
|
-
"/api/company-md/settings": {
|
|
1334
|
-
parameters: {
|
|
1335
|
-
query?: never;
|
|
1336
|
-
header?: never;
|
|
1337
|
-
path?: never;
|
|
1338
|
-
cookie?: never;
|
|
1339
|
-
};
|
|
1340
|
-
/** Get company.md settings for the org */
|
|
1341
|
-
get: operations["getCompanyMdSettings"];
|
|
1342
|
-
put?: never;
|
|
1343
|
-
post?: never;
|
|
1344
|
-
delete?: never;
|
|
1345
|
-
options?: never;
|
|
1346
|
-
head?: never;
|
|
1347
|
-
patch?: never;
|
|
1348
|
-
trace?: never;
|
|
1349
|
-
};
|
|
1350
|
-
"/api/company-md/settings/level-labels": {
|
|
1351
|
-
parameters: {
|
|
1352
|
-
query?: never;
|
|
1353
|
-
header?: never;
|
|
1354
|
-
path?: never;
|
|
1355
|
-
cookie?: never;
|
|
1356
|
-
};
|
|
1357
|
-
get?: never;
|
|
1358
|
-
/** Update company.md level labels */
|
|
1359
|
-
put: operations["updateCompanyMdLevelLabels"];
|
|
1360
|
-
post?: never;
|
|
1361
|
-
delete?: never;
|
|
1362
|
-
options?: never;
|
|
1363
|
-
head?: never;
|
|
1364
|
-
patch?: never;
|
|
1365
|
-
trace?: never;
|
|
1366
|
-
};
|
|
1367
1333
|
"/api/company-md/docs/{slug}/sharing": {
|
|
1368
1334
|
parameters: {
|
|
1369
1335
|
query?: never;
|
|
@@ -2869,18 +2835,6 @@ export interface components {
|
|
|
2869
2835
|
AssociateContextDocRequest: {
|
|
2870
2836
|
contextDocSlug: string;
|
|
2871
2837
|
};
|
|
2872
|
-
CompanyMdSettingsResponse: {
|
|
2873
|
-
levelLabels: {
|
|
2874
|
-
root: string;
|
|
2875
|
-
department: string;
|
|
2876
|
-
team: string;
|
|
2877
|
-
};
|
|
2878
|
-
};
|
|
2879
|
-
UpdateCompanyMdLevelLabelsRequest: {
|
|
2880
|
-
root?: string;
|
|
2881
|
-
department?: string;
|
|
2882
|
-
team?: string;
|
|
2883
|
-
};
|
|
2884
2838
|
CompanyMdShareResponse: {
|
|
2885
2839
|
/** @enum {string} */
|
|
2886
2840
|
sharingPolicy: "restricted" | "org_read" | "org_comment" | "org_edit";
|
|
@@ -5341,50 +5295,6 @@ export interface operations {
|
|
|
5341
5295
|
};
|
|
5342
5296
|
};
|
|
5343
5297
|
};
|
|
5344
|
-
getCompanyMdSettings: {
|
|
5345
|
-
parameters: {
|
|
5346
|
-
query?: never;
|
|
5347
|
-
header?: never;
|
|
5348
|
-
path?: never;
|
|
5349
|
-
cookie?: never;
|
|
5350
|
-
};
|
|
5351
|
-
requestBody?: never;
|
|
5352
|
-
responses: {
|
|
5353
|
-
/** @description Company.md settings */
|
|
5354
|
-
200: {
|
|
5355
|
-
headers: {
|
|
5356
|
-
[name: string]: unknown;
|
|
5357
|
-
};
|
|
5358
|
-
content: {
|
|
5359
|
-
"application/json": components["schemas"]["CompanyMdSettingsResponse"];
|
|
5360
|
-
};
|
|
5361
|
-
};
|
|
5362
|
-
};
|
|
5363
|
-
};
|
|
5364
|
-
updateCompanyMdLevelLabels: {
|
|
5365
|
-
parameters: {
|
|
5366
|
-
query?: never;
|
|
5367
|
-
header?: never;
|
|
5368
|
-
path?: never;
|
|
5369
|
-
cookie?: never;
|
|
5370
|
-
};
|
|
5371
|
-
requestBody: {
|
|
5372
|
-
content: {
|
|
5373
|
-
"application/json": components["schemas"]["UpdateCompanyMdLevelLabelsRequest"];
|
|
5374
|
-
};
|
|
5375
|
-
};
|
|
5376
|
-
responses: {
|
|
5377
|
-
/** @description Updated settings */
|
|
5378
|
-
200: {
|
|
5379
|
-
headers: {
|
|
5380
|
-
[name: string]: unknown;
|
|
5381
|
-
};
|
|
5382
|
-
content: {
|
|
5383
|
-
"application/json": components["schemas"]["CompanyMdSettingsResponse"];
|
|
5384
|
-
};
|
|
5385
|
-
};
|
|
5386
|
-
};
|
|
5387
|
-
};
|
|
5388
5298
|
getCompanyMdDocSharing: {
|
|
5389
5299
|
parameters: {
|
|
5390
5300
|
query?: never;
|
package/src/content/index.ts
CHANGED
|
@@ -11,14 +11,12 @@ export {
|
|
|
11
11
|
CompanyMdDocResponseSchema,
|
|
12
12
|
CompanyMdShareResponseSchema,
|
|
13
13
|
CompanyMdContextBankResponseSchema,
|
|
14
|
-
CompanyMdSettingsResponseSchema,
|
|
15
14
|
} from './schemas';
|
|
16
15
|
export type {
|
|
17
16
|
CompanyMdListResponse,
|
|
18
17
|
CompanyMdDocResponse,
|
|
19
18
|
CompanyMdShareResponse,
|
|
20
19
|
CompanyMdContextBankResponse,
|
|
21
|
-
CompanyMdSettingsResponse,
|
|
22
20
|
} from './schemas';
|
|
23
21
|
|
|
24
22
|
// Drive response schemas (PRD-00448)
|
package/src/content/schemas.ts
CHANGED
|
@@ -125,17 +125,6 @@ export const CompanyMdContextBankResponseSchema = z.object({
|
|
|
125
125
|
items: z.array(CompanyMdContextBankItemSchema),
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
const CompanyMdLevelLabelsSchema = z.object({
|
|
129
|
-
root: z.string(),
|
|
130
|
-
department: z.string(),
|
|
131
|
-
team: z.string(),
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
/** Response for GET /api/company-md/settings */
|
|
135
|
-
export const CompanyMdSettingsResponseSchema = z.object({
|
|
136
|
-
levelLabels: CompanyMdLevelLabelsSchema,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
128
|
// ---------------------------------------------------------------------------
|
|
140
129
|
// Drive Sub-schemas
|
|
141
130
|
// ---------------------------------------------------------------------------
|
|
@@ -182,6 +171,5 @@ export type CompanyMdListResponse = z.infer<typeof CompanyMdListResponseSchema>;
|
|
|
182
171
|
export type CompanyMdDocResponse = z.infer<typeof CompanyMdDocResponseSchema>;
|
|
183
172
|
export type CompanyMdShareResponse = z.infer<typeof CompanyMdShareResponseSchema>;
|
|
184
173
|
export type CompanyMdContextBankResponse = z.infer<typeof CompanyMdContextBankResponseSchema>;
|
|
185
|
-
export type CompanyMdSettingsResponse = z.infer<typeof CompanyMdSettingsResponseSchema>;
|
|
186
174
|
export type DriveFileListResponse = z.infer<typeof DriveFileListResponseSchema>;
|
|
187
175
|
export type DriveFileContentResponse = z.infer<typeof DriveFileContentResponseSchema>;
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
OrgUnitClassificationSchema,
|
|
13
13
|
OrgUnitRelationshipTypeSchema,
|
|
14
14
|
OrgUnitMembershipSourceSchema,
|
|
15
|
+
OrgUnitPermissionsEntrySchema,
|
|
16
|
+
ListOrgUnitPermissionsResponseSchema,
|
|
15
17
|
} from '../schemas.js';
|
|
16
18
|
|
|
17
19
|
const UUID_A = '11111111-1111-4111-8111-111111111111';
|
|
@@ -200,3 +202,49 @@ describe('Enum exhaustiveness', () => {
|
|
|
200
202
|
}
|
|
201
203
|
});
|
|
202
204
|
});
|
|
205
|
+
|
|
206
|
+
describe('OrgUnitPermissionsEntrySchema', () => {
|
|
207
|
+
const entry = {
|
|
208
|
+
userId: UUID_A,
|
|
209
|
+
membershipRole: 'manager' as const,
|
|
210
|
+
inheritedFromUnitId: UUID_C,
|
|
211
|
+
inheritedFromUnitName: 'Engineering',
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
it('accepts a well-formed entry', () => {
|
|
215
|
+
expect(() => OrgUnitPermissionsEntrySchema.parse(entry)).not.toThrow();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('rejects invalid membershipRole', () => {
|
|
219
|
+
expect(() =>
|
|
220
|
+
OrgUnitPermissionsEntrySchema.parse({ ...entry, membershipRole: 'member' })
|
|
221
|
+
).not.toThrow();
|
|
222
|
+
expect(() =>
|
|
223
|
+
OrgUnitPermissionsEntrySchema.parse({ ...entry, membershipRole: 'bogus' })
|
|
224
|
+
).toThrow();
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('requires UUIDs for user and inherited unit', () => {
|
|
228
|
+
expect(() =>
|
|
229
|
+
OrgUnitPermissionsEntrySchema.parse({ ...entry, userId: 'nope' })
|
|
230
|
+
).toThrow();
|
|
231
|
+
expect(() =>
|
|
232
|
+
OrgUnitPermissionsEntrySchema.parse({ ...entry, inheritedFromUnitId: 'nope' })
|
|
233
|
+
).toThrow();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('rejects empty inheritedFromUnitName', () => {
|
|
237
|
+
expect(() =>
|
|
238
|
+
OrgUnitPermissionsEntrySchema.parse({ ...entry, inheritedFromUnitName: '' })
|
|
239
|
+
).toThrow();
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('list response wraps entries with unitId', () => {
|
|
243
|
+
const parsed = ListOrgUnitPermissionsResponseSchema.parse({
|
|
244
|
+
unitId: UUID_B,
|
|
245
|
+
entries: [entry],
|
|
246
|
+
});
|
|
247
|
+
expect(parsed.entries).toHaveLength(1);
|
|
248
|
+
expect(parsed.unitId).toBe(UUID_B);
|
|
249
|
+
});
|
|
250
|
+
});
|
package/src/org/company-md.ts
CHANGED
|
@@ -68,25 +68,6 @@ export interface CompanyMdDocRelations {
|
|
|
68
68
|
|
|
69
69
|
export type CompanyMdDoc = CompanyMdDocCore & CompanyMdDocCollaborators & CompanyMdDocRelations;
|
|
70
70
|
|
|
71
|
-
export interface CompanyMdLevelLabels {
|
|
72
|
-
/** L1 label — defaults to org name */
|
|
73
|
-
readonly root: string;
|
|
74
|
-
/** L2 label — defaults to 'Department' */
|
|
75
|
-
readonly department: string;
|
|
76
|
-
/** L3 label — defaults to 'Team' */
|
|
77
|
-
readonly team: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface CompanyMdSettings {
|
|
81
|
-
readonly levelLabels: CompanyMdLevelLabels;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** System defaults for level labels. L1 (root) is set per-org at read time. */
|
|
85
|
-
export const DEFAULT_LEVEL_LABELS: Omit<CompanyMdLevelLabels, 'root'> = {
|
|
86
|
-
department: 'Department',
|
|
87
|
-
team: 'Team',
|
|
88
|
-
} as const;
|
|
89
|
-
|
|
90
71
|
/**
|
|
91
72
|
* A context bank item — a company.md doc associated with one or more parent nodes.
|
|
92
73
|
* Context bank files can belong to company, department, or team levels.
|
package/src/org/index.ts
CHANGED
|
@@ -94,13 +94,8 @@ export type {
|
|
|
94
94
|
CompanyMdDocRelations,
|
|
95
95
|
CompanyMdDoc,
|
|
96
96
|
CompanyMdContextBankItem,
|
|
97
|
-
// Level labels settings types (PRD-00453)
|
|
98
|
-
CompanyMdLevelLabels,
|
|
99
|
-
CompanyMdSettings,
|
|
100
97
|
} from './company-md';
|
|
101
98
|
|
|
102
|
-
export { DEFAULT_LEVEL_LABELS } from './company-md';
|
|
103
|
-
|
|
104
99
|
// Sharing and ACL types (PRD-00306)
|
|
105
100
|
export type {
|
|
106
101
|
AccessLevel,
|
|
@@ -230,6 +225,8 @@ export {
|
|
|
230
225
|
OrgLevelConfigResponseSchema,
|
|
231
226
|
OrgUnitMembershipResponseSchema,
|
|
232
227
|
OrgUnitMembershipListResponseSchema,
|
|
228
|
+
OrgUnitPermissionsEntrySchema,
|
|
229
|
+
ListOrgUnitPermissionsResponseSchema,
|
|
233
230
|
} from './schemas';
|
|
234
231
|
export type {
|
|
235
232
|
OrgUnit,
|
|
@@ -246,4 +243,6 @@ export type {
|
|
|
246
243
|
OrgLevelConfigResponse,
|
|
247
244
|
OrgUnitMembershipResponse,
|
|
248
245
|
OrgUnitMembershipListResponse,
|
|
246
|
+
OrgUnitPermissionsEntry,
|
|
247
|
+
ListOrgUnitPermissionsResponse,
|
|
249
248
|
} from './schemas';
|
package/src/org/schemas.ts
CHANGED
|
@@ -756,6 +756,26 @@ export const OrgUnitMembershipListResponseSchema = z.object({
|
|
|
756
756
|
memberships: z.array(OrgUnitMembershipSchema),
|
|
757
757
|
});
|
|
758
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Effective manager of an org unit — a user whose membership (direct or
|
|
761
|
+
* inherited from an ancestor) grants the `orgUnit.{id}.manage` capability.
|
|
762
|
+
*
|
|
763
|
+
* Direct grants have `inheritedFromUnitId === unitId`. For inherited grants,
|
|
764
|
+
* `inheritedFromUnitId` identifies the ancestor whose membership propagates
|
|
765
|
+
* authority down the subtree (ltree `path @>` containment).
|
|
766
|
+
*/
|
|
767
|
+
export const OrgUnitPermissionsEntrySchema = z.object({
|
|
768
|
+
userId: z.string().uuid(),
|
|
769
|
+
membershipRole: OrgUnitMembershipRoleSchema,
|
|
770
|
+
inheritedFromUnitId: z.string().uuid(),
|
|
771
|
+
inheritedFromUnitName: z.string().min(1),
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
export const ListOrgUnitPermissionsResponseSchema = z.object({
|
|
775
|
+
unitId: z.string().uuid(),
|
|
776
|
+
entries: z.array(OrgUnitPermissionsEntrySchema),
|
|
777
|
+
});
|
|
778
|
+
|
|
759
779
|
// --- Inferred types ---
|
|
760
780
|
|
|
761
781
|
export type OrgUnit = z.infer<typeof OrgUnitSchema>;
|
|
@@ -772,3 +792,5 @@ export type OrgUnitRelationshipsResponse = z.infer<typeof OrgUnitRelationshipsRe
|
|
|
772
792
|
export type OrgLevelConfigResponse = z.infer<typeof OrgLevelConfigResponseSchema>;
|
|
773
793
|
export type OrgUnitMembershipResponse = z.infer<typeof OrgUnitMembershipResponseSchema>;
|
|
774
794
|
export type OrgUnitMembershipListResponse = z.infer<typeof OrgUnitMembershipListResponseSchema>;
|
|
795
|
+
export type OrgUnitPermissionsEntry = z.infer<typeof OrgUnitPermissionsEntrySchema>;
|
|
796
|
+
export type ListOrgUnitPermissionsResponse = z.infer<typeof ListOrgUnitPermissionsResponseSchema>;
|