@proteos/sdk 0.18.1
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/LICENSE +40 -0
- package/dist/chunk-7RGN4E22.cjs +1185 -0
- package/dist/chunk-7RGN4E22.cjs.map +1 -0
- package/dist/chunk-XJP5WCRZ.js +1125 -0
- package/dist/chunk-XJP5WCRZ.js.map +1 -0
- package/dist/index.cjs +2384 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5225 -0
- package/dist/index.d.ts +5225 -0
- package/dist/index.js +2146 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/index.cjs +204 -0
- package/dist/meta/index.cjs.map +1 -0
- package/dist/meta/index.d.cts +2 -0
- package/dist/meta/index.d.ts +2 -0
- package/dist/meta/index.js +3 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/types-BNsjfU8N.d.cts +3299 -0
- package/dist/types-BNsjfU8N.d.ts +3299 -0
- package/package.json +86 -0
- package/src/agent/agents.ts +53 -0
- package/src/agent/index.ts +134 -0
- package/src/agent/mcp-servers.ts +102 -0
- package/src/agent/prompts.ts +80 -0
- package/src/agent/session-types.ts +397 -0
- package/src/agent/sessions.ts +197 -0
- package/src/agent/skills.ts +89 -0
- package/src/agent/tools.ts +53 -0
- package/src/agent/types.ts +362 -0
- package/src/auth/index.ts +111 -0
- package/src/auth/me.ts +46 -0
- package/src/auth/organizations.ts +128 -0
- package/src/auth/platform-entities.ts +78 -0
- package/src/auth/roles.ts +213 -0
- package/src/auth/types.ts +294 -0
- package/src/auth/users.ts +226 -0
- package/src/client.ts +441 -0
- package/src/connector/index.ts +120 -0
- package/src/connector/types.ts +150 -0
- package/src/conversation/index.ts +297 -0
- package/src/conversation/types.ts +590 -0
- package/src/conversation/voice.ts +123 -0
- package/src/data/index.ts +53 -0
- package/src/data/queries.ts +66 -0
- package/src/data/records.ts +122 -0
- package/src/data/types.ts +89 -0
- package/src/errors.ts +148 -0
- package/src/events/index.ts +172 -0
- package/src/events/types.ts +77 -0
- package/src/functions/actions.ts +95 -0
- package/src/functions/index.ts +32 -0
- package/src/functions/types.ts +71 -0
- package/src/http/index.ts +2 -0
- package/src/http/query-params.ts +106 -0
- package/src/index.ts +598 -0
- package/src/iterator.ts +183 -0
- package/src/knowledge/graph.ts +35 -0
- package/src/knowledge/index.ts +104 -0
- package/src/knowledge/labels.ts +70 -0
- package/src/knowledge/links.ts +65 -0
- package/src/knowledge/nodes.ts +198 -0
- package/src/knowledge/record-links.ts +66 -0
- package/src/knowledge/types.ts +569 -0
- package/src/meta/apps.ts +107 -0
- package/src/meta/components.ts +124 -0
- package/src/meta/currency/index.ts +202 -0
- package/src/meta/entities.ts +193 -0
- package/src/meta/filters.ts +76 -0
- package/src/meta/index.ts +227 -0
- package/src/meta/layout/common-props.ts +93 -0
- package/src/meta/layout/control-registry.json +70 -0
- package/src/meta/layout/control-registry.ts +92 -0
- package/src/meta/layout/elements.ts +203 -0
- package/src/meta/layout/index.ts +41 -0
- package/src/meta/layout/page-layout.ts +35 -0
- package/src/meta/layout/size-value.ts +27 -0
- package/src/meta/list-views.ts +109 -0
- package/src/meta/lists.ts +104 -0
- package/src/meta/menu-configurations.ts +128 -0
- package/src/meta/modules.ts +159 -0
- package/src/meta/pages.ts +106 -0
- package/src/meta/types.ts +1115 -0
- package/src/meta/variables.ts +98 -0
- package/src/storage/files.ts +183 -0
- package/src/storage/index.ts +33 -0
- package/src/storage/types.ts +70 -0
- package/src/types/common.ts +143 -0
- package/src/types/index.ts +28 -0
- package/src/types/options.ts +95 -0
- package/src/workflow/executions.ts +99 -0
- package/src/workflow/index.ts +109 -0
- package/src/workflow/node-types.ts +50 -0
- package/src/workflow/types.ts +658 -0
- package/src/workflow/workflows.ts +152 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
CommonProps,
|
|
3
|
+
LayoutAlign,
|
|
4
|
+
LayoutGap,
|
|
5
|
+
LayoutJustify,
|
|
6
|
+
ResponsiveSizing,
|
|
7
|
+
SizingProps,
|
|
8
|
+
} from './common-props.js'
|
|
9
|
+
export {
|
|
10
|
+
type AttributeForLookup,
|
|
11
|
+
BUILT_IN_CONTROLS,
|
|
12
|
+
type BuiltInControlSlug,
|
|
13
|
+
type ControlBucket,
|
|
14
|
+
isBuiltInControl,
|
|
15
|
+
lookupCompatibleControls,
|
|
16
|
+
lookupControls,
|
|
17
|
+
lookupPrimaryControl,
|
|
18
|
+
} from './control-registry.js'
|
|
19
|
+
export {
|
|
20
|
+
type ColumnElement,
|
|
21
|
+
type ComponentElement,
|
|
22
|
+
type DividerElement,
|
|
23
|
+
type FieldElement,
|
|
24
|
+
type LayoutElement,
|
|
25
|
+
LayoutElementSchema,
|
|
26
|
+
LayoutElementType,
|
|
27
|
+
type LayoutTab,
|
|
28
|
+
type RelatedListElement,
|
|
29
|
+
type RowElement,
|
|
30
|
+
type SectionElement,
|
|
31
|
+
type TabsElement,
|
|
32
|
+
type TextElement,
|
|
33
|
+
type TextVariant,
|
|
34
|
+
} from './elements.js'
|
|
35
|
+
export {
|
|
36
|
+
type PageLayout,
|
|
37
|
+
PageLayoutSchema,
|
|
38
|
+
type PageLayoutSidePanel,
|
|
39
|
+
PageLayoutSidePanelSchema,
|
|
40
|
+
} from './page-layout.js'
|
|
41
|
+
export { type SizeValue, SizeValueSchema } from './size-value.js'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { type LayoutElement, LayoutElementSchema } from './elements.js'
|
|
3
|
+
import { type SizeValue, SizeValueSchema } from './size-value.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Side panel slot. Rendered as a sticky-by-default right rail; collapses
|
|
7
|
+
* below the main column on narrow viewports.
|
|
8
|
+
*/
|
|
9
|
+
export interface PageLayoutSidePanel {
|
|
10
|
+
width?: SizeValue
|
|
11
|
+
is_sticky?: boolean
|
|
12
|
+
content: LayoutElement
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const PageLayoutSidePanelSchema = z.object({
|
|
16
|
+
width: SizeValueSchema.optional(),
|
|
17
|
+
is_sticky: z.boolean().optional(),
|
|
18
|
+
content: LayoutElementSchema,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Top-level page layout. Replaces the legacy `mainContent` / `side_panel`
|
|
23
|
+
* arrays of `PageSection`s with a single typed element tree.
|
|
24
|
+
*/
|
|
25
|
+
export interface PageLayout {
|
|
26
|
+
version: 1
|
|
27
|
+
main: LayoutElement
|
|
28
|
+
side_panel?: PageLayoutSidePanel
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const PageLayoutSchema = z.object({
|
|
32
|
+
version: z.literal(1),
|
|
33
|
+
main: LayoutElementSchema,
|
|
34
|
+
side_panel: PageLayoutSidePanelSchema.optional(),
|
|
35
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SizeValue is a polymorphic sizing value used by `width`, `height`, and the
|
|
5
|
+
* responsive overrides. Accepted forms:
|
|
6
|
+
*
|
|
7
|
+
* - JSON number in [0, 1] for a fraction (0.5 → 50%)
|
|
8
|
+
* - "n/m" fraction string ("1/2", "2/3", ...)
|
|
9
|
+
* - "Npx" pixel string
|
|
10
|
+
* - "N%" percent string
|
|
11
|
+
* - "auto" — size to content
|
|
12
|
+
* - "fill" — grow to fill remaining space
|
|
13
|
+
*/
|
|
14
|
+
export type SizeValue =
|
|
15
|
+
| number
|
|
16
|
+
| `${number}/${number}`
|
|
17
|
+
| `${number}px`
|
|
18
|
+
| `${number}%`
|
|
19
|
+
| 'auto'
|
|
20
|
+
| 'fill'
|
|
21
|
+
|
|
22
|
+
const SIZE_VALUE_STRING_RE = /^(\d+\/\d+|\d+px|\d+%|auto|fill)$/
|
|
23
|
+
|
|
24
|
+
export const SizeValueSchema: z.ZodType<SizeValue> = z.union([
|
|
25
|
+
z.number().min(0).max(1).describe('Fraction in [0, 1]'),
|
|
26
|
+
z.string().regex(SIZE_VALUE_STRING_RE, 'must match n/m, Npx, N%, "auto", or "fill"'),
|
|
27
|
+
]) as unknown as z.ZodType<SizeValue>
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
CreateListViewRequest,
|
|
6
|
+
ListListViewsOptions,
|
|
7
|
+
ListView,
|
|
8
|
+
UpdateListViewRequest,
|
|
9
|
+
} from './types.js'
|
|
10
|
+
|
|
11
|
+
const LIST_VIEWS_BASE_PATH = '/meta/v1/list-views'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Service for managing list view configurations.
|
|
15
|
+
* List views define filtered and sorted views of lists.
|
|
16
|
+
*/
|
|
17
|
+
export interface ListViewService {
|
|
18
|
+
/**
|
|
19
|
+
* Lists list views with optional filtering.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Filter and pagination options
|
|
22
|
+
* @returns Async iterator over list views
|
|
23
|
+
*/
|
|
24
|
+
list(options?: ListListViewsOptions): PageIterator<ListView, ListListViewsOptions>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches a single page of list views.
|
|
28
|
+
*/
|
|
29
|
+
listPage(options?: ListListViewsOptions): Promise<ListResult<ListView>>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Gets a single list view by slug.
|
|
33
|
+
*
|
|
34
|
+
* @param slug - List view slug
|
|
35
|
+
* @returns The list view
|
|
36
|
+
* @throws {ProteosError} If list view not found (404)
|
|
37
|
+
*/
|
|
38
|
+
get(slug: string): Promise<ListView>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new list view.
|
|
42
|
+
*
|
|
43
|
+
* @param request - List view creation request
|
|
44
|
+
* @returns The created list view
|
|
45
|
+
* @throws {ProteosError} If validation fails (400) or conflict (409)
|
|
46
|
+
*/
|
|
47
|
+
create(request: CreateListViewRequest): Promise<ListView>
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates or updates a list view (upsert operation).
|
|
51
|
+
*
|
|
52
|
+
* @param request - List view creation request
|
|
53
|
+
* @returns The created or updated list view
|
|
54
|
+
*/
|
|
55
|
+
upsert(request: CreateListViewRequest): Promise<ListView>
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Updates an existing list view.
|
|
59
|
+
*
|
|
60
|
+
* @param slug - List view slug
|
|
61
|
+
* @param request - Fields to update
|
|
62
|
+
* @returns The updated list view
|
|
63
|
+
* @throws {ProteosError} If list view not found (404) or validation fails (400)
|
|
64
|
+
*/
|
|
65
|
+
update(slug: string, request: UpdateListViewRequest): Promise<ListView>
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Deletes a list view.
|
|
69
|
+
*
|
|
70
|
+
* @param slug - List view slug
|
|
71
|
+
* @throws {ProteosError} If list view not found (404)
|
|
72
|
+
*/
|
|
73
|
+
delete(slug: string): Promise<void>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Implementation of ListViewService.
|
|
78
|
+
*/
|
|
79
|
+
export class ListViewServiceImpl implements ListViewService {
|
|
80
|
+
constructor(private readonly client: ProteosClient) {}
|
|
81
|
+
|
|
82
|
+
list(options: ListListViewsOptions = {}): PageIterator<ListView, ListListViewsOptions> {
|
|
83
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async listPage(options: ListListViewsOptions = {}): Promise<ListResult<ListView>> {
|
|
87
|
+
return this.client.requestWithQuery<ListResult<ListView>>('GET', LIST_VIEWS_BASE_PATH, options)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async get(slug: string): Promise<ListView> {
|
|
91
|
+
return this.client.request<ListView>('GET', `${LIST_VIEWS_BASE_PATH}/${slug}`)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async create(request: CreateListViewRequest): Promise<ListView> {
|
|
95
|
+
return this.client.request<ListView>('POST', LIST_VIEWS_BASE_PATH, request)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async upsert(request: CreateListViewRequest): Promise<ListView> {
|
|
99
|
+
return this.client.request<ListView>('POST', `${LIST_VIEWS_BASE_PATH}/upsert`, request)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async update(slug: string, request: UpdateListViewRequest): Promise<ListView> {
|
|
103
|
+
return this.client.request<ListView>('PATCH', `${LIST_VIEWS_BASE_PATH}/${slug}`, request)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async delete(slug: string): Promise<void> {
|
|
107
|
+
await this.client.request<void>('DELETE', `${LIST_VIEWS_BASE_PATH}/${slug}`)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { PageIterator } from '../iterator.js'
|
|
3
|
+
import type { ListResult } from '../types/common.js'
|
|
4
|
+
import type { CreateListRequest, List, ListListsOptions, UpdateListRequest } from './types.js'
|
|
5
|
+
|
|
6
|
+
const LISTS_BASE_PATH = '/meta/v1/lists'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Service for managing list configurations.
|
|
10
|
+
* Lists define how data is displayed in tabular format.
|
|
11
|
+
*/
|
|
12
|
+
export interface ListService {
|
|
13
|
+
/**
|
|
14
|
+
* Lists list configurations with optional filtering.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Filter and pagination options
|
|
17
|
+
* @returns Async iterator over lists
|
|
18
|
+
*/
|
|
19
|
+
list(options?: ListListsOptions): PageIterator<List, ListListsOptions>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Fetches a single page of lists.
|
|
23
|
+
*/
|
|
24
|
+
listPage(options?: ListListsOptions): Promise<ListResult<List>>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Gets a single list by slug.
|
|
28
|
+
*
|
|
29
|
+
* @param slug - List slug
|
|
30
|
+
* @returns The list
|
|
31
|
+
* @throws {ProteosError} If list not found (404)
|
|
32
|
+
*/
|
|
33
|
+
get(slug: string): Promise<List>
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new list.
|
|
37
|
+
*
|
|
38
|
+
* @param request - List creation request
|
|
39
|
+
* @returns The created list
|
|
40
|
+
* @throws {ProteosError} If validation fails (400) or conflict (409)
|
|
41
|
+
*/
|
|
42
|
+
create(request: CreateListRequest): Promise<List>
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates or updates a list (upsert operation).
|
|
46
|
+
*
|
|
47
|
+
* @param request - List creation request
|
|
48
|
+
* @returns The created or updated list
|
|
49
|
+
*/
|
|
50
|
+
upsert(request: CreateListRequest): Promise<List>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Updates an existing list.
|
|
54
|
+
*
|
|
55
|
+
* @param slug - List slug
|
|
56
|
+
* @param request - Fields to update
|
|
57
|
+
* @returns The updated list
|
|
58
|
+
* @throws {ProteosError} If list not found (404) or validation fails (400)
|
|
59
|
+
*/
|
|
60
|
+
update(slug: string, request: UpdateListRequest): Promise<List>
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Deletes a list.
|
|
64
|
+
*
|
|
65
|
+
* @param slug - List slug
|
|
66
|
+
* @throws {ProteosError} If list not found (404)
|
|
67
|
+
*/
|
|
68
|
+
delete(slug: string): Promise<void>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Implementation of ListService.
|
|
73
|
+
*/
|
|
74
|
+
export class ListServiceImpl implements ListService {
|
|
75
|
+
constructor(private readonly client: ProteosClient) {}
|
|
76
|
+
|
|
77
|
+
list(options: ListListsOptions = {}): PageIterator<List, ListListsOptions> {
|
|
78
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async listPage(options: ListListsOptions = {}): Promise<ListResult<List>> {
|
|
82
|
+
return this.client.requestWithQuery<ListResult<List>>('GET', LISTS_BASE_PATH, options)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async get(slug: string): Promise<List> {
|
|
86
|
+
return this.client.request<List>('GET', `${LISTS_BASE_PATH}/${slug}`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async create(request: CreateListRequest): Promise<List> {
|
|
90
|
+
return this.client.request<List>('POST', LISTS_BASE_PATH, request)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async upsert(request: CreateListRequest): Promise<List> {
|
|
94
|
+
return this.client.request<List>('POST', `${LISTS_BASE_PATH}/upsert`, request)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async update(slug: string, request: UpdateListRequest): Promise<List> {
|
|
98
|
+
return this.client.request<List>('PATCH', `${LISTS_BASE_PATH}/${slug}`, request)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async delete(slug: string): Promise<void> {
|
|
102
|
+
await this.client.request<void>('DELETE', `${LISTS_BASE_PATH}/${slug}`)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
CreateMenuConfigurationRequest,
|
|
6
|
+
ListMenuConfigurationsOptions,
|
|
7
|
+
MenuConfiguration,
|
|
8
|
+
UpdateMenuConfigurationRequest,
|
|
9
|
+
} from './types.js'
|
|
10
|
+
|
|
11
|
+
const MENU_CONFIGURATIONS_BASE_PATH = '/meta/v1/menu-configurations'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Service for managing menu configurations.
|
|
15
|
+
* Menu configurations define the navigation structure of applications.
|
|
16
|
+
*/
|
|
17
|
+
export interface MenuConfigurationService {
|
|
18
|
+
/**
|
|
19
|
+
* Lists menu configurations with optional filtering.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Filter and pagination options
|
|
22
|
+
* @returns Async iterator over menu configurations
|
|
23
|
+
*/
|
|
24
|
+
list(
|
|
25
|
+
options?: ListMenuConfigurationsOptions,
|
|
26
|
+
): PageIterator<MenuConfiguration, ListMenuConfigurationsOptions>
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Fetches a single page of menu configurations.
|
|
30
|
+
*/
|
|
31
|
+
listPage(options?: ListMenuConfigurationsOptions): Promise<ListResult<MenuConfiguration>>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Gets a single menu configuration by slug.
|
|
35
|
+
*
|
|
36
|
+
* @param slug - Menu configuration slug (author-controlled, kebab-case)
|
|
37
|
+
* @returns The menu configuration
|
|
38
|
+
* @throws {ProteosError} If menu configuration not found (404)
|
|
39
|
+
*/
|
|
40
|
+
get(slug: string): Promise<MenuConfiguration>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new menu configuration.
|
|
44
|
+
*
|
|
45
|
+
* @param request - Menu configuration creation request
|
|
46
|
+
* @returns The created menu configuration
|
|
47
|
+
* @throws {ProteosError} If validation fails (400) or conflict (409)
|
|
48
|
+
*/
|
|
49
|
+
create(request: CreateMenuConfigurationRequest): Promise<MenuConfiguration>
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Creates or updates a menu configuration idempotently by slug.
|
|
53
|
+
*
|
|
54
|
+
* @param slug - Menu configuration slug
|
|
55
|
+
* @param request - Body
|
|
56
|
+
* @returns The created or updated menu configuration
|
|
57
|
+
*/
|
|
58
|
+
upsert(slug: string, request: CreateMenuConfigurationRequest): Promise<MenuConfiguration>
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Updates an existing menu configuration.
|
|
62
|
+
*
|
|
63
|
+
* @param slug - Menu configuration slug
|
|
64
|
+
* @param request - Fields to update
|
|
65
|
+
* @returns The updated menu configuration
|
|
66
|
+
* @throws {ProteosError} If menu configuration not found (404) or validation fails (400)
|
|
67
|
+
*/
|
|
68
|
+
update(slug: string, request: UpdateMenuConfigurationRequest): Promise<MenuConfiguration>
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Deletes a menu configuration.
|
|
72
|
+
*
|
|
73
|
+
* @param slug - Menu configuration slug
|
|
74
|
+
* @throws {ProteosError} If menu configuration not found (404)
|
|
75
|
+
*/
|
|
76
|
+
delete(slug: string): Promise<void>
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Implementation of MenuConfigurationService.
|
|
81
|
+
*/
|
|
82
|
+
export class MenuConfigurationServiceImpl implements MenuConfigurationService {
|
|
83
|
+
constructor(private readonly client: ProteosClient) {}
|
|
84
|
+
|
|
85
|
+
list(
|
|
86
|
+
options: ListMenuConfigurationsOptions = {},
|
|
87
|
+
): PageIterator<MenuConfiguration, ListMenuConfigurationsOptions> {
|
|
88
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async listPage(
|
|
92
|
+
options: ListMenuConfigurationsOptions = {},
|
|
93
|
+
): Promise<ListResult<MenuConfiguration>> {
|
|
94
|
+
return this.client.requestWithQuery<ListResult<MenuConfiguration>>(
|
|
95
|
+
'GET',
|
|
96
|
+
MENU_CONFIGURATIONS_BASE_PATH,
|
|
97
|
+
options,
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async get(slug: string): Promise<MenuConfiguration> {
|
|
102
|
+
return this.client.request<MenuConfiguration>('GET', `${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async create(request: CreateMenuConfigurationRequest): Promise<MenuConfiguration> {
|
|
106
|
+
return this.client.request<MenuConfiguration>('POST', MENU_CONFIGURATIONS_BASE_PATH, request)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async upsert(slug: string, request: CreateMenuConfigurationRequest): Promise<MenuConfiguration> {
|
|
110
|
+
return this.client.request<MenuConfiguration>(
|
|
111
|
+
'PUT',
|
|
112
|
+
`${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`,
|
|
113
|
+
{ ...request, slug },
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async update(slug: string, request: UpdateMenuConfigurationRequest): Promise<MenuConfiguration> {
|
|
118
|
+
return this.client.request<MenuConfiguration>(
|
|
119
|
+
'PATCH',
|
|
120
|
+
`${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`,
|
|
121
|
+
request,
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async delete(slug: string): Promise<void> {
|
|
126
|
+
await this.client.request<void>('DELETE', `${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { PageIterator } from '../iterator.js'
|
|
3
|
+
import type { ListResult } from '../types/common.js'
|
|
4
|
+
import type { DeployModuleRequest, ListModulesOptions, Module } from './types.js'
|
|
5
|
+
|
|
6
|
+
const MODULES_BASE_PATH = '/meta/v1/modules'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Service for managing WebAssembly modules.
|
|
10
|
+
* Modules contain business logic that runs in the Proteos runtime.
|
|
11
|
+
*/
|
|
12
|
+
export interface ModuleService {
|
|
13
|
+
/**
|
|
14
|
+
* Lists modules with optional filtering.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Filter and pagination options
|
|
17
|
+
* @returns Async iterator over modules
|
|
18
|
+
*/
|
|
19
|
+
list(options?: ListModulesOptions): PageIterator<Module, ListModulesOptions>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Fetches a single page of modules.
|
|
23
|
+
*/
|
|
24
|
+
listPage(options?: ListModulesOptions): Promise<ListResult<Module>>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Gets a single module by slug.
|
|
28
|
+
*
|
|
29
|
+
* @param slug - Module slug
|
|
30
|
+
* @returns The module
|
|
31
|
+
* @throws {ProteosError} If module not found (404)
|
|
32
|
+
*/
|
|
33
|
+
get(slug: string): Promise<Module>
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Deploys a new module.
|
|
37
|
+
* Uploads a WASM file with metadata.
|
|
38
|
+
*
|
|
39
|
+
* @param request - Module metadata
|
|
40
|
+
* @param file - WASM file (File, Blob, or ArrayBuffer)
|
|
41
|
+
* @returns The deployed module
|
|
42
|
+
* @throws {ProteosError} If validation fails (400) or conflict (409)
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const wasmFile = new File([wasmBytes], 'module.wasm');
|
|
47
|
+
* const module = await service.deploy(
|
|
48
|
+
* {
|
|
49
|
+
* slug: 'my-module',
|
|
50
|
+
* version: '1.0.0',
|
|
51
|
+
* name: 'My Module',
|
|
52
|
+
* description: 'A custom module',
|
|
53
|
+
* },
|
|
54
|
+
* wasmFile
|
|
55
|
+
* );
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
deploy(request: DeployModuleRequest, file: File | Blob | ArrayBuffer): Promise<Module>
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Deletes a module.
|
|
62
|
+
*
|
|
63
|
+
* @param slug - Module slug
|
|
64
|
+
* @throws {ProteosError} If module not found (404)
|
|
65
|
+
*/
|
|
66
|
+
delete(slug: string): Promise<void>
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Activates a deactivated module.
|
|
70
|
+
*
|
|
71
|
+
* @param slug - Module slug
|
|
72
|
+
* @throws {ProteosError} If module not found (404)
|
|
73
|
+
*/
|
|
74
|
+
activate(slug: string): Promise<void>
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Deactivates an active module.
|
|
78
|
+
*
|
|
79
|
+
* @param slug - Module slug
|
|
80
|
+
* @throws {ProteosError} If module not found (404)
|
|
81
|
+
*/
|
|
82
|
+
deactivate(slug: string): Promise<void>
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Downloads the module WASM file.
|
|
86
|
+
*
|
|
87
|
+
* @param slug - Module slug
|
|
88
|
+
* @returns Object containing the readable stream and module metadata
|
|
89
|
+
* @throws {ProteosError} If module not found (404)
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const { body, module } = await service.download('my-module');
|
|
94
|
+
* const reader = body.getReader();
|
|
95
|
+
* // Read the stream...
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
download(slug: string): Promise<{ body: ReadableStream<Uint8Array> | null; module: Module }>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Implementation of ModuleService.
|
|
103
|
+
*/
|
|
104
|
+
export class ModuleServiceImpl implements ModuleService {
|
|
105
|
+
constructor(private readonly client: ProteosClient) {}
|
|
106
|
+
|
|
107
|
+
list(options: ListModulesOptions = {}): PageIterator<Module, ListModulesOptions> {
|
|
108
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async listPage(options: ListModulesOptions = {}): Promise<ListResult<Module>> {
|
|
112
|
+
return this.client.requestWithQuery<ListResult<Module>>('GET', MODULES_BASE_PATH, options)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async get(slug: string): Promise<Module> {
|
|
116
|
+
return this.client.request<Module>('GET', `${MODULES_BASE_PATH}/${slug}`)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async deploy(request: DeployModuleRequest, file: File | Blob | ArrayBuffer): Promise<Module> {
|
|
120
|
+
const formData = new FormData()
|
|
121
|
+
|
|
122
|
+
// Add metadata as JSON string
|
|
123
|
+
formData.append('metadata', JSON.stringify(request))
|
|
124
|
+
|
|
125
|
+
// Add file
|
|
126
|
+
let blob: Blob
|
|
127
|
+
if (file instanceof ArrayBuffer) {
|
|
128
|
+
blob = new Blob([file], { type: 'application/wasm' })
|
|
129
|
+
} else {
|
|
130
|
+
blob = file
|
|
131
|
+
}
|
|
132
|
+
formData.append('file', blob, 'module.wasm')
|
|
133
|
+
|
|
134
|
+
return this.client.requestMultipart<Module>('POST', `${MODULES_BASE_PATH}/deploy`, formData)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async delete(slug: string): Promise<void> {
|
|
138
|
+
await this.client.request<void>('DELETE', `${MODULES_BASE_PATH}/${slug}`)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async activate(slug: string): Promise<void> {
|
|
142
|
+
await this.client.request<void>('PATCH', `${MODULES_BASE_PATH}/${slug}/activate`)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async deactivate(slug: string): Promise<void> {
|
|
146
|
+
await this.client.request<void>('PATCH', `${MODULES_BASE_PATH}/${slug}/deactivate`)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async download(
|
|
150
|
+
slug: string,
|
|
151
|
+
): Promise<{ body: ReadableStream<Uint8Array> | null; module: Module }> {
|
|
152
|
+
const [{ body }, module] = await Promise.all([
|
|
153
|
+
this.client.requestRaw('GET', `${MODULES_BASE_PATH}/${slug}/download`),
|
|
154
|
+
this.get(slug),
|
|
155
|
+
])
|
|
156
|
+
|
|
157
|
+
return { body, module }
|
|
158
|
+
}
|
|
159
|
+
}
|