@proteos/sdk 0.44.0 → 0.46.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.
Files changed (39) hide show
  1. package/dist/{chunk-33EULWIM.cjs → chunk-F5DHWOGW.cjs} +195 -27
  2. package/dist/chunk-F5DHWOGW.cjs.map +1 -0
  3. package/dist/{chunk-IGIAJVX6.js → chunk-Y4CEHIRX.js} +191 -28
  4. package/dist/chunk-Y4CEHIRX.js.map +1 -0
  5. package/dist/index.cjs +453 -178
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +686 -13
  8. package/dist/index.d.ts +686 -13
  9. package/dist/index.js +355 -96
  10. package/dist/index.js.map +1 -1
  11. package/dist/meta/index.cjs +69 -53
  12. package/dist/meta/index.d.cts +1 -1
  13. package/dist/meta/index.d.ts +1 -1
  14. package/dist/meta/index.js +1 -1
  15. package/dist/{types-BTdBFq34.d.cts → types-D1PRIsSO.d.cts} +406 -14
  16. package/dist/{types-BTdBFq34.d.ts → types-D1PRIsSO.d.ts} +406 -14
  17. package/package.json +3 -3
  18. package/src/auth/index.ts +58 -1
  19. package/src/auth/me.ts +14 -1
  20. package/src/auth/platform-entities.ts +27 -0
  21. package/src/auth/roles.ts +3 -1
  22. package/src/auth/shares.ts +181 -0
  23. package/src/auth/teams.ts +135 -0
  24. package/src/auth/types.ts +192 -4
  25. package/src/auth/user-role-assignments.ts +65 -0
  26. package/src/conversation/index.ts +42 -0
  27. package/src/conversation/types.ts +37 -0
  28. package/src/index.ts +36 -0
  29. package/src/knowledge/graph.ts +6 -2
  30. package/src/knowledge/index.ts +15 -0
  31. package/src/knowledge/nodes.ts +4 -1
  32. package/src/knowledge/spaces.ts +86 -0
  33. package/src/knowledge/types.ts +89 -0
  34. package/src/meta/index.ts +11 -0
  35. package/src/meta/layout/control-registry.json +151 -26
  36. package/src/meta/types.ts +186 -4
  37. package/src/workflow/types.ts +20 -3
  38. package/dist/chunk-33EULWIM.cjs.map +0 -1
  39. package/dist/chunk-IGIAJVX6.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import type { ProteosClient } from '../client.js'
2
+ import { PageIterator } from '../iterator.js'
3
+ import type { ListResult } from '../types/common.js'
4
+ import type {
5
+ CreateSpaceRequest,
6
+ KnowledgeSpace,
7
+ ListSpacesOptions,
8
+ UpdateSpaceRequest,
9
+ } from './types.js'
10
+
11
+ const SPACES_BASE_PATH = '/knowledge/v1/spaces'
12
+
13
+ /**
14
+ * Service for knowledge spaces — the containers nodes live in.
15
+ *
16
+ * Every method is keyed by SLUG rather than id: a space's slug is half its
17
+ * primary key and is immutable, so there is no second identifier. To file a node
18
+ * into a space, set `space_slug` on the node (see `NodeService`).
19
+ *
20
+ * Granting access to a space is NOT done here — it goes through the shared
21
+ * `auth.shares` API, which routes `knowledge-spaces` to knowledge-service:
22
+ *
23
+ * ```ts
24
+ * await auth.shares.share('knowledge-spaces', 'engineering', { type: 'team', id: 'platform' }, 'read')
25
+ * ```
26
+ */
27
+ export interface SpaceService {
28
+ /** Lists spaces as an async iterator (pages are 0-indexed). */
29
+ list(options?: ListSpacesOptions): PageIterator<KnowledgeSpace, ListSpacesOptions>
30
+
31
+ /** Fetches a single page of spaces. */
32
+ listPage(options?: ListSpacesOptions): Promise<ListResult<KnowledgeSpace>>
33
+
34
+ /** Gets a single space by slug. */
35
+ get(slug: string): Promise<KnowledgeSpace>
36
+
37
+ /** Creates a space. The slug is permanent. */
38
+ create(request: CreateSpaceRequest): Promise<KnowledgeSpace>
39
+
40
+ /** Updates a space's presentation. The slug cannot be changed. */
41
+ update(slug: string, request: UpdateSpaceRequest): Promise<KnowledgeSpace>
42
+
43
+ /**
44
+ * Deletes a space and its access grants.
45
+ *
46
+ * Refused with 409 `knowledge_space_not_empty` while any node still lives in
47
+ * it — deleting a space never deletes the knowledge inside it, and never
48
+ * silently makes it org-visible by unfiling it. Move or delete the nodes first.
49
+ */
50
+ delete(slug: string): Promise<void>
51
+ }
52
+
53
+ /**
54
+ * Implementation of SpaceService.
55
+ */
56
+ export class SpaceServiceImpl implements SpaceService {
57
+ constructor(private readonly client: ProteosClient) {}
58
+
59
+ list(options: ListSpacesOptions = {}): PageIterator<KnowledgeSpace, ListSpacesOptions> {
60
+ return new PageIterator((opts) => this.listPage(opts), options)
61
+ }
62
+
63
+ async listPage(options: ListSpacesOptions = {}): Promise<ListResult<KnowledgeSpace>> {
64
+ return this.client.requestWithQuery<ListResult<KnowledgeSpace>>(
65
+ 'GET',
66
+ SPACES_BASE_PATH,
67
+ options,
68
+ )
69
+ }
70
+
71
+ async get(slug: string): Promise<KnowledgeSpace> {
72
+ return this.client.request<KnowledgeSpace>('GET', `${SPACES_BASE_PATH}/${slug}`)
73
+ }
74
+
75
+ async create(request: CreateSpaceRequest): Promise<KnowledgeSpace> {
76
+ return this.client.request<KnowledgeSpace>('POST', SPACES_BASE_PATH, request)
77
+ }
78
+
79
+ async update(slug: string, request: UpdateSpaceRequest): Promise<KnowledgeSpace> {
80
+ return this.client.request<KnowledgeSpace>('PATCH', `${SPACES_BASE_PATH}/${slug}`, request)
81
+ }
82
+
83
+ async delete(slug: string): Promise<void> {
84
+ await this.client.request<void>('DELETE', `${SPACES_BASE_PATH}/${slug}`)
85
+ }
86
+ }
@@ -56,6 +56,12 @@ export interface KnowledgeNodeMetadata extends AuditFields {
56
56
  /** Embedding provenance (null until ingestion runs). */
57
57
  embedding_model?: string | null
58
58
  embedded_at?: string | null
59
+ /**
60
+ * The space this node lives in, or null when UNASSIGNED. An unassigned node
61
+ * is visible to anyone holding knowledge-nodes:read — the behaviour every
62
+ * node had before spaces existed.
63
+ */
64
+ space_slug?: string | null
59
65
  /** Source pointer for `file` nodes (storage-service file id). */
60
66
  file_id?: string | null
61
67
  /** Source pointer for `url` nodes. */
@@ -148,6 +154,8 @@ export interface CreateNodeRequest {
148
154
  type: NodeType
149
155
  status: NodeStatus
150
156
  content?: string
157
+ /** File the node into a space. Omitted = unassigned. */
158
+ space_slug?: string
151
159
  file_id?: string
152
160
  url?: string
153
161
  summary?: string
@@ -170,6 +178,12 @@ export interface UpdateNodeRequest {
170
178
  */
171
179
  valid_from?: string | null
172
180
  valid_until?: string | null
181
+ /**
182
+ * Move the node between spaces, tri-state like the validity window: omit to
183
+ * leave it where it is, pass `null` to move it back to unassigned, or a slug
184
+ * to file it into that space.
185
+ */
186
+ space_slug?: string | null
173
187
  }
174
188
 
175
189
  /** Filters for listing nodes. */
@@ -180,6 +194,11 @@ export interface ListNodesOptions extends ListOptions {
180
194
  'title[contains]'?: string
181
195
  /** Keep only nodes carrying ANY of these labels (union). */
182
196
  label_ids?: string[]
197
+ /**
198
+ * Keep only nodes living in ANY of these spaces (union). Use
199
+ * `UNASSIGNED_SPACE_SLUG` to ask for nodes belonging to no space.
200
+ */
201
+ space_slugs?: string[]
183
202
  /** Created on/after this RFC3339 timestamp (inclusive). */
184
203
  created_after?: string
185
204
  /** Created on/before this RFC3339 timestamp (inclusive). */
@@ -298,6 +317,11 @@ export interface SearchNodesRequest {
298
317
  status?: NodeStatus
299
318
  /** Match nodes carrying ANY of these labels. */
300
319
  label_ids?: string[]
320
+ /**
321
+ * Match nodes living in ANY of these spaces (union). Use
322
+ * `UNASSIGNED_SPACE_SLUG` for nodes belonging to no space.
323
+ */
324
+ space_slugs?: string[]
301
325
  /** Match nodes connected (either direction) to this node. */
302
326
  linked_to_id?: string
303
327
  /**
@@ -365,6 +389,8 @@ export interface KnowledgeGraphNode {
365
389
  type: NodeType
366
390
  status: NodeStatus
367
391
  label_ids: string[]
392
+ /** The node's space, or null when unassigned. */
393
+ space_slug?: string | null
368
394
  degree: number
369
395
  }
370
396
 
@@ -386,6 +412,12 @@ export interface KnowledgeGraph {
386
412
  nodes: KnowledgeGraphNode[]
387
413
  links: KnowledgeGraphLink[]
388
414
  labels: KnowledgeLabel[]
415
+ /**
416
+ * The full org space set, sent once for the same reason as `labels`: the
417
+ * client renders the space navigator and filters by space without a second
418
+ * request, even when the graph is pruned to one space.
419
+ */
420
+ spaces: KnowledgeSpace[]
389
421
  total: number
390
422
  }
391
423
 
@@ -395,6 +427,8 @@ export interface KnowledgeGraph {
395
427
  */
396
428
  export interface GetGraphOptions {
397
429
  label_ids?: string[]
430
+ /** Prune to nodes in ANY of these spaces (union). */
431
+ space_slugs?: string[]
398
432
  }
399
433
 
400
434
  // ============================================================================
@@ -443,6 +477,61 @@ export interface ListRecordLinksOptions extends ListOptions {
443
477
  record_id?: string
444
478
  }
445
479
 
480
+ // ============================================================================
481
+ // Spaces
482
+ // ============================================================================
483
+
484
+ /**
485
+ * A knowledge space: the container a node lives in. A node belongs to at most
486
+ * one space; a node with no space is unassigned.
487
+ *
488
+ * A space is NOT a label. Labels are many-per-node, overlapping, non-security
489
+ * tags; a space is the single place a node lives, and it is what instance-level
490
+ * access is evaluated against.
491
+ *
492
+ * Keyed by `slug`, which is IMMUTABLE — it is half the primary key, node rows
493
+ * reference it and access grants name it, so renaming would orphan both. There
494
+ * is no id.
495
+ */
496
+ export interface KnowledgeSpace extends AuditFields {
497
+ org_id: string
498
+ slug: string
499
+ name: string
500
+ description?: string | null
501
+ color?: string | null
502
+ icon?: string | null
503
+ }
504
+
505
+ /**
506
+ * The reserved filter value meaning "nodes that belong to no space at all".
507
+ * Deliberately not a legal slug (slugs are kebab-case), so it can never collide
508
+ * with a space an org creates.
509
+ */
510
+ export const UNASSIGNED_SPACE_SLUG = '__unassigned__'
511
+
512
+ export interface CreateSpaceRequest {
513
+ /** Permanent — it is half the primary key and cannot be changed later. */
514
+ slug: string
515
+ name: string
516
+ description?: string
517
+ color?: string
518
+ icon?: string
519
+ }
520
+
521
+ /** Partial update. `slug` is absent because it is immutable. */
522
+ export interface UpdateSpaceRequest {
523
+ name?: string
524
+ description?: string
525
+ color?: string
526
+ icon?: string
527
+ }
528
+
529
+ export interface ListSpacesOptions extends ListOptions {
530
+ slug?: string
531
+ name?: string
532
+ 'name[contains]'?: string
533
+ }
534
+
446
535
  // ============================================================================
447
536
  // Label requests
448
537
  // ============================================================================
package/src/meta/index.ts CHANGED
@@ -123,6 +123,8 @@ export type {
123
123
  ArrayAttributeMeta,
124
124
  Attribute,
125
125
  AttributeMeta,
126
+ AttributeAccessRule,
127
+ AttributeRestrictions,
126
128
  AttributeType,
127
129
  Column,
128
130
  ComparisonOperator,
@@ -184,6 +186,7 @@ export type {
184
186
  // Page types
185
187
  Page,
186
188
  PageAction,
189
+ PageActionKind,
187
190
  PageType,
188
191
  PublicAccessOperation,
189
192
  PublicPageComponent,
@@ -204,6 +207,10 @@ export type {
204
207
  UpdatePageRequest,
205
208
  UpdateVariableRequest,
206
209
  // User attribute meta
210
+ PrincipalAttributeMeta,
211
+ CurrentUserDefault,
212
+ PrincipalRef,
213
+ PrincipalType,
207
214
  UserAttributeMeta,
208
215
  // Variable types
209
216
  Variable,
@@ -233,7 +240,11 @@ export {
233
240
  PageActionSchema,
234
241
  PageSchema,
235
242
  PLATFORM_ATTRIBUTE_NAMES,
243
+ CURRENT_USER_DEFAULT,
244
+ acceptsCurrentUserDefault,
245
+ isCurrentUserDefault,
236
246
  parseCurrencyMeta,
247
+ parsePrincipalMeta,
237
248
  parseFileMeta,
238
249
  parseRelationMeta,
239
250
  parseUserMeta,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "_comment": "SOURCE OF TRUTH for the page-layout control registry. Each entry under `controls` declares the primary control slug and the full compatible list for one (type[+format|+items.type]) combination. Renderer dispatches off `primary`; inspector picker dispatches off `compatible`. Edit this file then run `go run ./scripts/codegen/page-layout-registry` from the repo root to regenerate packages/go/model/page_layout_registry_gen.go.",
3
- "_attributeTypes": "Top-level keys MUST match the Go canonical AttributeType union in packages/go/model/meta/attribute.go (string · number · integer · boolean · array · object · datetime · enum · relation · user · currency · knowledge-text · file). `byFormat` keys for `string` MUST match StringFormat (email · uri · uuid · hostname · ipv4 · ipv6). `byFormat` keys for `datetime` MUST match DatetimeFormat (date-time · date · time · duration). `byItemsType` for `array` keys on the item Attribute's type. A null `primary` with empty `compatible` means \"render-only fallback\" see plan §3.2.5.",
4
- "_slugRoster": "v1 ships only lib-backed slugs. Slugs without a backing @proteos/ui component (markdown · json-editor · slider · stepper · percent · user-card) are intentionally omitted; they return when the matching lib primitive ships. See plan §3.2.4 / §7.3. The `user-picker` slug is backed by the web client's UserCombobox (account/user-service people picker). The `currency` slug is backed by the web client's currency control (CurrencyInput: decimal amount + ISO-4217 picker).",
3
+ "_attributeTypes": "Top-level keys MUST match the Go canonical AttributeType union in packages/go/model/meta/attribute.go (string \u00b7 number \u00b7 integer \u00b7 boolean \u00b7 array \u00b7 object \u00b7 datetime \u00b7 enum \u00b7 relation \u00b7 user \u00b7 currency \u00b7 knowledge-text \u00b7 file). `byFormat` keys for `string` MUST match StringFormat (email \u00b7 uri \u00b7 uuid \u00b7 hostname \u00b7 ipv4 \u00b7 ipv6). `byFormat` keys for `datetime` MUST match DatetimeFormat (date-time \u00b7 date \u00b7 time \u00b7 duration). `byItemsType` for `array` keys on the item Attribute's type. A null `primary` with empty `compatible` means \"render-only fallback\" \u2014 see plan \u00a73.2.5.",
4
+ "_slugRoster": "v1 ships only lib-backed slugs. Slugs without a backing @proteos/ui component (markdown \u00b7 json-editor \u00b7 slider \u00b7 stepper \u00b7 percent \u00b7 user-card) are intentionally omitted; they return when the matching lib primitive ships. See plan \u00a73.2.4 / \u00a77.3. The `user-picker` slug is backed by the web client's UserCombobox (account/user-service people picker). The `currency` slug is backed by the web client's currency control (CurrencyInput: decimal amount + ISO-4217 picker).",
5
5
  "builtInControls": [
6
6
  "text",
7
7
  "textarea",
@@ -21,6 +21,7 @@
21
21
  "tag-input",
22
22
  "entity-picker",
23
23
  "user-picker",
24
+ "principal-picker",
24
25
  "currency",
25
26
  "knowledge-text",
26
27
  "file",
@@ -29,43 +30,167 @@
29
30
  "controls": {
30
31
  "string": {
31
32
  "primary": "text",
32
- "compatible": ["text", "textarea", "password"],
33
+ "compatible": [
34
+ "text",
35
+ "textarea",
36
+ "password"
37
+ ],
33
38
  "byFormat": {
34
- "email": { "primary": "email", "compatible": ["email", "text"] },
35
- "uri": { "primary": "url", "compatible": ["url", "text"] },
36
- "uuid": { "primary": "text", "compatible": ["text"] },
37
- "hostname": { "primary": "text", "compatible": ["text"] },
38
- "ipv4": { "primary": "text", "compatible": ["text"] },
39
- "ipv6": { "primary": "text", "compatible": ["text"] }
39
+ "email": {
40
+ "primary": "email",
41
+ "compatible": [
42
+ "email",
43
+ "text"
44
+ ]
45
+ },
46
+ "uri": {
47
+ "primary": "url",
48
+ "compatible": [
49
+ "url",
50
+ "text"
51
+ ]
52
+ },
53
+ "uuid": {
54
+ "primary": "text",
55
+ "compatible": [
56
+ "text"
57
+ ]
58
+ },
59
+ "hostname": {
60
+ "primary": "text",
61
+ "compatible": [
62
+ "text"
63
+ ]
64
+ },
65
+ "ipv4": {
66
+ "primary": "text",
67
+ "compatible": [
68
+ "text"
69
+ ]
70
+ },
71
+ "ipv6": {
72
+ "primary": "text",
73
+ "compatible": [
74
+ "text"
75
+ ]
76
+ }
40
77
  }
41
78
  },
42
- "number": { "primary": "number", "compatible": ["number"] },
43
- "integer": { "primary": "number", "compatible": ["number"] },
44
- "boolean": { "primary": "switch", "compatible": ["switch", "checkbox"] },
45
- "enum": { "primary": "select", "compatible": ["select", "radio-group", "chip-group"] },
79
+ "number": {
80
+ "primary": "number",
81
+ "compatible": [
82
+ "number"
83
+ ]
84
+ },
85
+ "integer": {
86
+ "primary": "number",
87
+ "compatible": [
88
+ "number"
89
+ ]
90
+ },
91
+ "boolean": {
92
+ "primary": "switch",
93
+ "compatible": [
94
+ "switch",
95
+ "checkbox"
96
+ ]
97
+ },
98
+ "enum": {
99
+ "primary": "select",
100
+ "compatible": [
101
+ "select",
102
+ "radio-group",
103
+ "chip-group"
104
+ ]
105
+ },
46
106
  "array": {
47
107
  "primary": "tag-input",
48
- "compatible": ["tag-input"],
108
+ "compatible": [
109
+ "tag-input"
110
+ ],
49
111
  "byItemsType": {
50
- "string": { "primary": "tag-input", "compatible": ["tag-input"] },
51
- "enum": { "primary": "multi-select", "compatible": ["multi-select"] }
112
+ "string": {
113
+ "primary": "tag-input",
114
+ "compatible": [
115
+ "tag-input"
116
+ ]
117
+ },
118
+ "enum": {
119
+ "primary": "multi-select",
120
+ "compatible": [
121
+ "multi-select"
122
+ ]
123
+ }
52
124
  }
53
125
  },
54
126
  "datetime": {
55
127
  "primary": null,
56
128
  "compatible": [],
57
129
  "byFormat": {
58
- "date": { "primary": "date-picker", "compatible": ["date-picker"] },
59
- "date-time": { "primary": "datetime-picker", "compatible": ["datetime-picker"] },
60
- "time": { "primary": "time-picker", "compatible": ["time-picker"] },
61
- "duration": { "primary": null, "compatible": [] }
130
+ "date": {
131
+ "primary": "date-picker",
132
+ "compatible": [
133
+ "date-picker"
134
+ ]
135
+ },
136
+ "date-time": {
137
+ "primary": "datetime-picker",
138
+ "compatible": [
139
+ "datetime-picker"
140
+ ]
141
+ },
142
+ "time": {
143
+ "primary": "time-picker",
144
+ "compatible": [
145
+ "time-picker"
146
+ ]
147
+ },
148
+ "duration": {
149
+ "primary": null,
150
+ "compatible": []
151
+ }
62
152
  }
63
153
  },
64
- "object": { "primary": null, "compatible": [] },
65
- "relation": { "primary": "entity-picker", "compatible": ["entity-picker"] },
66
- "user": { "primary": "user-picker", "compatible": ["user-picker"] },
67
- "currency": { "primary": "currency", "compatible": ["currency"] },
68
- "knowledge-text": { "primary": "knowledge-text", "compatible": ["knowledge-text"] },
69
- "file": { "primary": "file", "compatible": ["file", "file-viewer"] }
154
+ "object": {
155
+ "primary": null,
156
+ "compatible": []
157
+ },
158
+ "relation": {
159
+ "primary": "entity-picker",
160
+ "compatible": [
161
+ "entity-picker"
162
+ ]
163
+ },
164
+ "user": {
165
+ "primary": "user-picker",
166
+ "compatible": [
167
+ "user-picker"
168
+ ]
169
+ },
170
+ "currency": {
171
+ "primary": "currency",
172
+ "compatible": [
173
+ "currency"
174
+ ]
175
+ },
176
+ "knowledge-text": {
177
+ "primary": "knowledge-text",
178
+ "compatible": [
179
+ "knowledge-text"
180
+ ]
181
+ },
182
+ "file": {
183
+ "primary": "file",
184
+ "compatible": [
185
+ "file",
186
+ "file-viewer"
187
+ ]
188
+ },
189
+ "principal": {
190
+ "primary": "principal-picker",
191
+ "compatible": [
192
+ "principal-picker"
193
+ ]
194
+ }
70
195
  }
71
196
  }