@proteos/sdk 0.51.0 → 0.52.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.
@@ -78,6 +78,8 @@ export type CardElement = CommonProps & {
78
78
  */
79
79
  export type LayoutTab = {
80
80
  id: string
81
+ /** Page-extension stamp for a contributed tab — same contract as `CommonProps.extension_key`. */
82
+ extension_key?: string
81
83
  label: string
82
84
  icon?: string
83
85
  visible_when?: FilterGroup
@@ -281,6 +283,18 @@ export type LayoutElement =
281
283
 
282
284
  // ──────────────────────────────────────────────────────────── Schemas ──
283
285
 
286
+ export const LayoutTabSchema: z.ZodType<LayoutTab> = z.lazy(() =>
287
+ z.object({
288
+ id: z.string().min(1),
289
+ extension_key: z.string().optional(),
290
+ label: z.string().min(1),
291
+ icon: z.string().optional(),
292
+ visible_when: FilterGroupSchema.optional(),
293
+ default_when: FilterGroupSchema.optional(),
294
+ content: LayoutElementSchema,
295
+ }),
296
+ )
297
+
284
298
  export const LayoutElementSchema: z.ZodType<LayoutElement> = z.lazy(() =>
285
299
  z.discriminatedUnion('type', [
286
300
  z.object({
@@ -321,16 +335,7 @@ export const LayoutElementSchema: z.ZodType<LayoutElement> = z.lazy(() =>
321
335
  z.object({
322
336
  type: z.literal('tabs'),
323
337
  ...commonPropsShape,
324
- tabs: z.array(
325
- z.object({
326
- id: z.string().min(1),
327
- label: z.string().min(1),
328
- icon: z.string().optional(),
329
- visible_when: FilterGroupSchema.optional(),
330
- default_when: FilterGroupSchema.optional(),
331
- content: LayoutElementSchema,
332
- }),
333
- ),
338
+ tabs: z.array(LayoutTabSchema),
334
339
  default_tab_id: z.string().optional(),
335
340
  }),
336
341
  z.object({
@@ -26,6 +26,7 @@ export {
26
26
  LayoutElementSchema,
27
27
  LayoutElementType,
28
28
  type LayoutTab,
29
+ LayoutTabSchema,
29
30
  type ListElement,
30
31
  type RecordFilterElement,
31
32
  type WorkflowTriggerElement,
@@ -0,0 +1,98 @@
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
+ CreateListExtensionRequest,
6
+ ListExtension,
7
+ ListListExtensionsOptions,
8
+ UpdateListExtensionRequest,
9
+ } from './types.js'
10
+
11
+ const LIST_EXTENSIONS_BASE_PATH = '/meta/v1/list-extensions'
12
+
13
+ /**
14
+ * Service for entity extensions — attributes contributed to an EXISTING host
15
+ * entity by a resource that does not own it (typically a second module). The
16
+ * host's `attributes` are the materialized merge: its own attributes plus every
17
+ * extension's, each stamped with `extension_key`. Every write here
18
+ * re-materializes the host; an attribute name shared with the host or another
19
+ * extension is refused (`entity_extension_attribute_collision`).
20
+ */
21
+ export interface ListExtensionService {
22
+ /** Lists entity extensions (auto-paginating iterator). */
23
+ list(
24
+ options?: ListListExtensionsOptions,
25
+ ): PageIterator<ListExtension, ListListExtensionsOptions>
26
+
27
+ /** Fetches a single page of entity extensions. */
28
+ listPage(options?: ListListExtensionsOptions): Promise<ListResult<ListExtension>>
29
+
30
+ /** Gets an entity extension by key (404 when unknown). */
31
+ get(key: string): Promise<ListExtension>
32
+
33
+ /**
34
+ * Creates an entity extension and merges its attributes into the host.
35
+ * @throws {ProteosError} 409 `entity_extension_already_exists` when the key
36
+ * is taken; 400 `entity_extension_entity_not_found` when the host does
37
+ * not exist; 400 `entity_extension_attribute_collision` on a name clash.
38
+ */
39
+ create(request: CreateListExtensionRequest): Promise<ListExtension>
40
+
41
+ /**
42
+ * Creates or replaces an entity extension idempotently by key
43
+ * (`PUT /meta/v1/list-extensions/:key`). Replaces the whole definition;
44
+ * the host binding (`list_slug`) of an existing key is immutable.
45
+ */
46
+ upsert(key: string, request: CreateListExtensionRequest): Promise<ListExtension>
47
+
48
+ /** Partially updates an entity extension (`attributes` replaces the whole list). */
49
+ update(key: string, request: UpdateListExtensionRequest): Promise<ListExtension>
50
+
51
+ /** Deletes an entity extension and removes its attributes from the host. */
52
+ delete(key: string): Promise<void>
53
+ }
54
+
55
+ export class ListExtensionServiceImpl implements ListExtensionService {
56
+ constructor(private readonly client: ProteosClient) {}
57
+
58
+ list(
59
+ options: ListListExtensionsOptions = {},
60
+ ): PageIterator<ListExtension, ListListExtensionsOptions> {
61
+ return new PageIterator((opts) => this.listPage(opts), options)
62
+ }
63
+
64
+ async listPage(options: ListListExtensionsOptions = {}): Promise<ListResult<ListExtension>> {
65
+ return this.client.requestWithQuery<ListResult<ListExtension>>(
66
+ 'GET',
67
+ LIST_EXTENSIONS_BASE_PATH,
68
+ options,
69
+ )
70
+ }
71
+
72
+ async get(key: string): Promise<ListExtension> {
73
+ return this.client.request<ListExtension>('GET', `${LIST_EXTENSIONS_BASE_PATH}/${key}`)
74
+ }
75
+
76
+ async create(request: CreateListExtensionRequest): Promise<ListExtension> {
77
+ return this.client.request<ListExtension>('POST', LIST_EXTENSIONS_BASE_PATH, request)
78
+ }
79
+
80
+ async upsert(key: string, request: CreateListExtensionRequest): Promise<ListExtension> {
81
+ return this.client.request<ListExtension>('PUT', `${LIST_EXTENSIONS_BASE_PATH}/${key}`, {
82
+ ...request,
83
+ key,
84
+ })
85
+ }
86
+
87
+ async update(key: string, request: UpdateListExtensionRequest): Promise<ListExtension> {
88
+ return this.client.request<ListExtension>(
89
+ 'PATCH',
90
+ `${LIST_EXTENSIONS_BASE_PATH}/${key}`,
91
+ request,
92
+ )
93
+ }
94
+
95
+ async delete(key: string): Promise<void> {
96
+ await this.client.request<void>('DELETE', `${LIST_EXTENSIONS_BASE_PATH}/${key}`)
97
+ }
98
+ }
@@ -0,0 +1,132 @@
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
+ CreateMenuConfigurationExtensionRequest,
6
+ ListMenuConfigurationExtensionsOptions,
7
+ MenuConfigurationExtension,
8
+ UpdateMenuConfigurationExtensionRequest,
9
+ } from './types.js'
10
+
11
+ const MENU_CONFIGURATION_EXTENSIONS_BASE_PATH = '/meta/v1/menu-configuration-extensions'
12
+
13
+ /**
14
+ * Service for menu-configuration extensions — items contributed to an EXISTING
15
+ * host menu configuration by a resource that does not own it (typically a
16
+ * second module). The host's `items` are the materialized merge: its own tree
17
+ * plus every extension's placements, each contributed item stamped with
18
+ * `extension_key` (a replaced / removed host item kept under `replaced_item`).
19
+ * Every write here re-materializes the host; an item id shared with the host
20
+ * or another extension is refused
21
+ * (`menu_configuration_extension_item_id_collision`), an anchor the host does
22
+ * not have too (`menu_configuration_extension_anchor_not_found`).
23
+ */
24
+ export interface MenuConfigurationExtensionService {
25
+ /** Lists menu-configuration extensions (auto-paginating iterator). */
26
+ list(
27
+ options?: ListMenuConfigurationExtensionsOptions,
28
+ ): PageIterator<MenuConfigurationExtension, ListMenuConfigurationExtensionsOptions>
29
+
30
+ /** Fetches a single page of menu-configuration extensions. */
31
+ listPage(
32
+ options?: ListMenuConfigurationExtensionsOptions,
33
+ ): Promise<ListResult<MenuConfigurationExtension>>
34
+
35
+ /** Gets a menu-configuration extension by key (404 when unknown). */
36
+ get(key: string): Promise<MenuConfigurationExtension>
37
+
38
+ /**
39
+ * Creates a menu-configuration extension and merges its items into the host.
40
+ * @throws {ProteosError} 409 `menu_configuration_extension_already_exists`
41
+ * when the key is taken; 400 `menu_configuration_extension_menu_not_found`
42
+ * when the host does not exist; 400
43
+ * `menu_configuration_extension_anchor_not_found` /
44
+ * `menu_configuration_extension_item_id_collision` on a bad placement.
45
+ */
46
+ create(request: CreateMenuConfigurationExtensionRequest): Promise<MenuConfigurationExtension>
47
+
48
+ /**
49
+ * Creates or replaces a menu-configuration extension idempotently by key
50
+ * (`PUT /meta/v1/menu-configuration-extensions/:key`). Replaces the whole definition;
51
+ * the host binding (`menu_slug`) of an existing key is immutable.
52
+ */
53
+ upsert(
54
+ key: string,
55
+ request: CreateMenuConfigurationExtensionRequest,
56
+ ): Promise<MenuConfigurationExtension>
57
+
58
+ /** Partially updates a menu-configuration extension (`placements` replaces the whole list). */
59
+ update(
60
+ key: string,
61
+ request: UpdateMenuConfigurationExtensionRequest,
62
+ ): Promise<MenuConfigurationExtension>
63
+
64
+ /** Deletes a menu-configuration extension and removes its items from the host. */
65
+ delete(key: string): Promise<void>
66
+ }
67
+
68
+ export class MenuConfigurationExtensionServiceImpl implements MenuConfigurationExtensionService {
69
+ constructor(private readonly client: ProteosClient) {}
70
+
71
+ list(
72
+ options: ListMenuConfigurationExtensionsOptions = {},
73
+ ): PageIterator<MenuConfigurationExtension, ListMenuConfigurationExtensionsOptions> {
74
+ return new PageIterator((opts) => this.listPage(opts), options)
75
+ }
76
+
77
+ async listPage(
78
+ options: ListMenuConfigurationExtensionsOptions = {},
79
+ ): Promise<ListResult<MenuConfigurationExtension>> {
80
+ return this.client.requestWithQuery<ListResult<MenuConfigurationExtension>>(
81
+ 'GET',
82
+ MENU_CONFIGURATION_EXTENSIONS_BASE_PATH,
83
+ options,
84
+ )
85
+ }
86
+
87
+ async get(key: string): Promise<MenuConfigurationExtension> {
88
+ return this.client.request<MenuConfigurationExtension>(
89
+ 'GET',
90
+ `${MENU_CONFIGURATION_EXTENSIONS_BASE_PATH}/${key}`,
91
+ )
92
+ }
93
+
94
+ async create(
95
+ request: CreateMenuConfigurationExtensionRequest,
96
+ ): Promise<MenuConfigurationExtension> {
97
+ return this.client.request<MenuConfigurationExtension>(
98
+ 'POST',
99
+ MENU_CONFIGURATION_EXTENSIONS_BASE_PATH,
100
+ request,
101
+ )
102
+ }
103
+
104
+ async upsert(
105
+ key: string,
106
+ request: CreateMenuConfigurationExtensionRequest,
107
+ ): Promise<MenuConfigurationExtension> {
108
+ return this.client.request<MenuConfigurationExtension>(
109
+ 'PUT',
110
+ `${MENU_CONFIGURATION_EXTENSIONS_BASE_PATH}/${key}`,
111
+ {
112
+ ...request,
113
+ key,
114
+ },
115
+ )
116
+ }
117
+
118
+ async update(
119
+ key: string,
120
+ request: UpdateMenuConfigurationExtensionRequest,
121
+ ): Promise<MenuConfigurationExtension> {
122
+ return this.client.request<MenuConfigurationExtension>(
123
+ 'PATCH',
124
+ `${MENU_CONFIGURATION_EXTENSIONS_BASE_PATH}/${key}`,
125
+ request,
126
+ )
127
+ }
128
+
129
+ async delete(key: string): Promise<void> {
130
+ await this.client.request<void>('DELETE', `${MENU_CONFIGURATION_EXTENSIONS_BASE_PATH}/${key}`)
131
+ }
132
+ }
@@ -0,0 +1,98 @@
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
+ CreatePageExtensionRequest,
6
+ PageExtension,
7
+ ListPageExtensionsOptions,
8
+ UpdatePageExtensionRequest,
9
+ } from './types.js'
10
+
11
+ const PAGE_EXTENSIONS_BASE_PATH = '/meta/v1/page-extensions'
12
+
13
+ /**
14
+ * Service for entity extensions — attributes contributed to an EXISTING host
15
+ * entity by a resource that does not own it (typically a second module). The
16
+ * host's `attributes` are the materialized merge: its own attributes plus every
17
+ * extension's, each stamped with `extension_key`. Every write here
18
+ * re-materializes the host; an attribute name shared with the host or another
19
+ * extension is refused (`entity_extension_attribute_collision`).
20
+ */
21
+ export interface PageExtensionService {
22
+ /** Lists entity extensions (auto-paginating iterator). */
23
+ list(
24
+ options?: ListPageExtensionsOptions,
25
+ ): PageIterator<PageExtension, ListPageExtensionsOptions>
26
+
27
+ /** Fetches a single page of entity extensions. */
28
+ listPage(options?: ListPageExtensionsOptions): Promise<ListResult<PageExtension>>
29
+
30
+ /** Gets an entity extension by key (404 when unknown). */
31
+ get(key: string): Promise<PageExtension>
32
+
33
+ /**
34
+ * Creates an entity extension and merges its attributes into the host.
35
+ * @throws {ProteosError} 409 `entity_extension_already_exists` when the key
36
+ * is taken; 400 `entity_extension_entity_not_found` when the host does
37
+ * not exist; 400 `entity_extension_attribute_collision` on a name clash.
38
+ */
39
+ create(request: CreatePageExtensionRequest): Promise<PageExtension>
40
+
41
+ /**
42
+ * Creates or replaces an entity extension idempotently by key
43
+ * (`PUT /meta/v1/page-extensions/:key`). Replaces the whole definition;
44
+ * the host binding (`page_slug`) of an existing key is immutable.
45
+ */
46
+ upsert(key: string, request: CreatePageExtensionRequest): Promise<PageExtension>
47
+
48
+ /** Partially updates an entity extension (`attributes` replaces the whole list). */
49
+ update(key: string, request: UpdatePageExtensionRequest): Promise<PageExtension>
50
+
51
+ /** Deletes an entity extension and removes its attributes from the host. */
52
+ delete(key: string): Promise<void>
53
+ }
54
+
55
+ export class PageExtensionServiceImpl implements PageExtensionService {
56
+ constructor(private readonly client: ProteosClient) {}
57
+
58
+ list(
59
+ options: ListPageExtensionsOptions = {},
60
+ ): PageIterator<PageExtension, ListPageExtensionsOptions> {
61
+ return new PageIterator((opts) => this.listPage(opts), options)
62
+ }
63
+
64
+ async listPage(options: ListPageExtensionsOptions = {}): Promise<ListResult<PageExtension>> {
65
+ return this.client.requestWithQuery<ListResult<PageExtension>>(
66
+ 'GET',
67
+ PAGE_EXTENSIONS_BASE_PATH,
68
+ options,
69
+ )
70
+ }
71
+
72
+ async get(key: string): Promise<PageExtension> {
73
+ return this.client.request<PageExtension>('GET', `${PAGE_EXTENSIONS_BASE_PATH}/${key}`)
74
+ }
75
+
76
+ async create(request: CreatePageExtensionRequest): Promise<PageExtension> {
77
+ return this.client.request<PageExtension>('POST', PAGE_EXTENSIONS_BASE_PATH, request)
78
+ }
79
+
80
+ async upsert(key: string, request: CreatePageExtensionRequest): Promise<PageExtension> {
81
+ return this.client.request<PageExtension>('PUT', `${PAGE_EXTENSIONS_BASE_PATH}/${key}`, {
82
+ ...request,
83
+ key,
84
+ })
85
+ }
86
+
87
+ async update(key: string, request: UpdatePageExtensionRequest): Promise<PageExtension> {
88
+ return this.client.request<PageExtension>(
89
+ 'PATCH',
90
+ `${PAGE_EXTENSIONS_BASE_PATH}/${key}`,
91
+ request,
92
+ )
93
+ }
94
+
95
+ async delete(key: string): Promise<void> {
96
+ await this.client.request<void>('DELETE', `${PAGE_EXTENSIONS_BASE_PATH}/${key}`)
97
+ }
98
+ }