@vertesia/common 0.50.1 → 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.
Files changed (120) hide show
  1. package/lib/cjs/Progress.js +61 -0
  2. package/lib/cjs/Progress.js.map +1 -0
  3. package/lib/cjs/environment.js.map +1 -1
  4. package/lib/cjs/index.js +3 -0
  5. package/lib/cjs/index.js.map +1 -1
  6. package/lib/cjs/integrations.js +1 -0
  7. package/lib/cjs/integrations.js.map +1 -1
  8. package/lib/cjs/interaction.js +2 -2
  9. package/lib/cjs/interaction.js.map +1 -1
  10. package/lib/cjs/meters.js +13 -0
  11. package/lib/cjs/meters.js.map +1 -0
  12. package/lib/cjs/project.js.map +1 -1
  13. package/lib/cjs/store/collections.js +9 -0
  14. package/lib/cjs/store/collections.js.map +1 -0
  15. package/lib/cjs/store/doc-analyzer.js +3 -0
  16. package/lib/cjs/store/doc-analyzer.js.map +1 -0
  17. package/lib/cjs/store/index.js +3 -0
  18. package/lib/cjs/store/index.js.map +1 -1
  19. package/lib/cjs/store/signals.js +3 -0
  20. package/lib/cjs/store/signals.js.map +1 -0
  21. package/lib/cjs/store/store.js.map +1 -1
  22. package/lib/cjs/store/workflow.js +16 -1
  23. package/lib/cjs/store/workflow.js.map +1 -1
  24. package/lib/cjs/user.js +6 -1
  25. package/lib/cjs/user.js.map +1 -1
  26. package/lib/cjs/utils/advanced-content-processing.js +25 -0
  27. package/lib/cjs/utils/advanced-content-processing.js.map +1 -0
  28. package/lib/cjs/utils/schemas.js +17 -0
  29. package/lib/cjs/utils/schemas.js.map +1 -1
  30. package/lib/esm/Progress.js +57 -0
  31. package/lib/esm/Progress.js.map +1 -0
  32. package/lib/esm/environment.js.map +1 -1
  33. package/lib/esm/index.js +3 -0
  34. package/lib/esm/index.js.map +1 -1
  35. package/lib/esm/integrations.js +1 -0
  36. package/lib/esm/integrations.js.map +1 -1
  37. package/lib/esm/interaction.js +2 -2
  38. package/lib/esm/interaction.js.map +1 -1
  39. package/lib/esm/meters.js +10 -0
  40. package/lib/esm/meters.js.map +1 -0
  41. package/lib/esm/project.js.map +1 -1
  42. package/lib/esm/store/collections.js +6 -0
  43. package/lib/esm/store/collections.js.map +1 -0
  44. package/lib/esm/store/doc-analyzer.js +2 -0
  45. package/lib/esm/store/doc-analyzer.js.map +1 -0
  46. package/lib/esm/store/index.js +3 -0
  47. package/lib/esm/store/index.js.map +1 -1
  48. package/lib/esm/store/signals.js +2 -0
  49. package/lib/esm/store/signals.js.map +1 -0
  50. package/lib/esm/store/store.js.map +1 -1
  51. package/lib/esm/store/workflow.js +15 -0
  52. package/lib/esm/store/workflow.js.map +1 -1
  53. package/lib/esm/user.js +5 -0
  54. package/lib/esm/user.js.map +1 -1
  55. package/lib/esm/utils/advanced-content-processing.js +19 -0
  56. package/lib/esm/utils/advanced-content-processing.js.map +1 -0
  57. package/lib/esm/utils/schemas.js +16 -0
  58. package/lib/esm/utils/schemas.js.map +1 -1
  59. package/lib/tsconfig.tsbuildinfo +1 -1
  60. package/lib/types/Progress.d.ts +21 -0
  61. package/lib/types/Progress.d.ts.map +1 -0
  62. package/lib/types/common.d.ts +1 -0
  63. package/lib/types/common.d.ts.map +1 -1
  64. package/lib/types/environment.d.ts +3 -2
  65. package/lib/types/environment.d.ts.map +1 -1
  66. package/lib/types/index.d.ts +3 -0
  67. package/lib/types/index.d.ts.map +1 -1
  68. package/lib/types/integrations.d.ts +6 -1
  69. package/lib/types/integrations.d.ts.map +1 -1
  70. package/lib/types/interaction.d.ts +171 -22
  71. package/lib/types/interaction.d.ts.map +1 -1
  72. package/lib/types/meters.d.ts +23 -0
  73. package/lib/types/meters.d.ts.map +1 -0
  74. package/lib/types/project.d.ts +7 -0
  75. package/lib/types/project.d.ts.map +1 -1
  76. package/lib/types/query.d.ts +2 -0
  77. package/lib/types/query.d.ts.map +1 -1
  78. package/lib/types/runs.d.ts +8 -0
  79. package/lib/types/runs.d.ts.map +1 -1
  80. package/lib/types/store/activity-catalog.d.ts +2 -2
  81. package/lib/types/store/activity-catalog.d.ts.map +1 -1
  82. package/lib/types/store/collections.d.ts +54 -0
  83. package/lib/types/store/collections.d.ts.map +1 -0
  84. package/lib/types/store/doc-analyzer.d.ts +132 -0
  85. package/lib/types/store/doc-analyzer.d.ts.map +1 -0
  86. package/lib/types/store/index.d.ts +3 -0
  87. package/lib/types/store/index.d.ts.map +1 -1
  88. package/lib/types/store/signals.d.ts +4 -0
  89. package/lib/types/store/signals.d.ts.map +1 -0
  90. package/lib/types/store/store.d.ts +20 -13
  91. package/lib/types/store/store.d.ts.map +1 -1
  92. package/lib/types/store/workflow.d.ts +64 -19
  93. package/lib/types/store/workflow.d.ts.map +1 -1
  94. package/lib/types/user.d.ts +10 -2
  95. package/lib/types/user.d.ts.map +1 -1
  96. package/lib/types/utils/advanced-content-processing.d.ts +15 -0
  97. package/lib/types/utils/advanced-content-processing.d.ts.map +1 -0
  98. package/lib/types/utils/schemas.d.ts +2 -0
  99. package/lib/types/utils/schemas.d.ts.map +1 -1
  100. package/package.json +4 -3
  101. package/src/Progress.ts +57 -0
  102. package/src/common.ts +1 -0
  103. package/src/environment.ts +3 -2
  104. package/src/index.ts +4 -0
  105. package/src/integrations.ts +8 -1
  106. package/src/interaction.ts +248 -51
  107. package/src/meters.ts +30 -0
  108. package/src/project.ts +7 -0
  109. package/src/query.ts +2 -0
  110. package/src/runs.ts +9 -0
  111. package/src/store/activity-catalog.ts +2 -2
  112. package/src/store/collections.ts +62 -0
  113. package/src/store/doc-analyzer.ts +152 -0
  114. package/src/store/index.ts +3 -0
  115. package/src/store/signals.ts +4 -0
  116. package/src/store/store.ts +22 -13
  117. package/src/store/workflow.ts +87 -42
  118. package/src/user.ts +13 -2
  119. package/src/utils/advanced-content-processing.ts +32 -0
  120. package/src/utils/schemas.ts +18 -1
@@ -0,0 +1,152 @@
1
+ import { WorkflowExecutionPayload, WorkflowRunStatus } from "./workflow.js";
2
+
3
+ export interface PdfToRichtextOptions {
4
+ features: string[];
5
+ debug?: boolean;
6
+ [key: string]: any;
7
+ }
8
+
9
+ export interface PdfToRichTextWorkflowPayload extends Omit<WorkflowExecutionPayload, "vars"> {
10
+ vars: PdfToRichtextOptions;
11
+ }
12
+
13
+ /**
14
+ * Represents a image in a document that has been analyzed
15
+ */
16
+ export interface DocImage {
17
+ id?: string;
18
+ page_number?: number;
19
+ description?: string;
20
+ is_meaningful?: boolean;
21
+ width?: number;
22
+ height?: number;
23
+ }
24
+
25
+ /**
26
+ * The export type formats for tables.
27
+ */
28
+ export type ExportTableFormats = 'json' | 'csv' | 'xml';
29
+
30
+ /**
31
+ * Represents a table in a document that has been analyzed
32
+ */
33
+ export interface DocTable {
34
+ page_number?: number;
35
+ table_number?: number;
36
+ title?: string;
37
+ format: "application/csv" | "application/json";
38
+ }
39
+
40
+ /**
41
+ * Represents a table in a document that has been analyzed in CSV format
42
+ */
43
+ export interface DocTableCsv extends DocTable {
44
+ format: "application/csv";
45
+ title?: string;
46
+ data: string;
47
+ }
48
+
49
+ /**
50
+ * Represents a table in a document that has been analyzed in JSON format
51
+ */
52
+ export interface DocTableJson extends DocTable {
53
+ format: "application/json";
54
+ title?: string;
55
+ data: Object[];
56
+ }
57
+
58
+ /**
59
+ * Represents a document analysis run status
60
+ */
61
+ export interface DocAnalyzeRunStatusResponse extends WorkflowRunStatus {
62
+ progress?: DocAnalyzerProgress;
63
+ }
64
+
65
+ export interface DocAnalyzerResultResponse {
66
+ document?: string;
67
+ tables?: DocTableCsv[] | DocTableJson[];
68
+ images?: DocImage[];
69
+ annotated?: string | null;
70
+ }
71
+
72
+ export interface DocAnalyzerProgress {
73
+ pages: DocAnalyzerProgressStatus;
74
+ images: DocAnalyzerProgressStatus;
75
+ tables: DocAnalyzerProgressStatus;
76
+ visuals: DocAnalyzerProgressStatus;
77
+ started_at?: number;
78
+ percent: number;
79
+ }
80
+
81
+ interface DocAnalyzerProgressStatus {
82
+ total: number;
83
+ processed: number;
84
+ success: number;
85
+ failed: number;
86
+ }
87
+
88
+ /**
89
+ * Adapt Tables Parameters, part of the request
90
+ */
91
+ export interface AdaptTablesParams {
92
+ /**
93
+ * JSON Schema to to convert the table into
94
+ */
95
+ target_schema: string;
96
+
97
+ /**
98
+ * Natural language description of the type item the table are composed of
99
+ */
100
+ item_name: string;
101
+
102
+ /**
103
+ * Natural language description of the type of table or item to convert
104
+ */
105
+ instructions?: string;
106
+
107
+ /**
108
+ * Format to return the data in (csv, json)
109
+ */
110
+ format?: "csv" | "json";
111
+
112
+ /**
113
+ * Process the table as a whole or by page
114
+ */
115
+ process_as?: "page" | "table";
116
+
117
+ /**
118
+ * Process the table as a CSV file
119
+ */
120
+ process_as_csv?: boolean;
121
+ }
122
+
123
+ interface DocAnalyzerRequestBase {
124
+ synchroneous?: boolean;
125
+
126
+ notify_endpoints?: string[];
127
+
128
+ /**
129
+ * What environmenet to use to run the request
130
+ * If none specified the project embedded environment will be used
131
+ */
132
+ environment?: string;
133
+ }
134
+
135
+ export interface AdaptTablesRequest extends DocAnalyzerRequestBase, AdaptTablesParams {}
136
+
137
+ /**
138
+ * Get Adapted Tables Request
139
+ * @param raw If true, the raw data will be returned
140
+ * @param format The format to return the data in (csv, json)
141
+ */
142
+ export interface GetAdaptedTablesRequestQuery {
143
+ raw?: boolean;
144
+ format: "csv" | "json";
145
+ }
146
+ /**
147
+ * The adapted table result format
148
+ */
149
+ export interface AdaptedTable {
150
+ comment?: string;
151
+ data: Record<string, any>[];
152
+ }
@@ -1,8 +1,11 @@
1
1
  export * from "./activity-catalog.js";
2
2
  export * from "./agent.js";
3
+ export * from "./collections.js";
3
4
  export * from "./common.js";
5
+ export * from "./doc-analyzer.js";
4
6
  export * from "./dsl-workflow.js";
5
7
  export * from "./object-types.js";
6
8
  export * from "./store.js";
7
9
  export * from "./temporalio.js";
8
10
  export * from "./workflow.js";
11
+ export * from "./signals.js";
@@ -0,0 +1,4 @@
1
+ export interface UserInputSignal {
2
+ message: string;
3
+ metadata?: Record<string, any>;
4
+ }
@@ -48,11 +48,13 @@ export interface GenerationRunMetadata {
48
48
  target?: string;
49
49
  }
50
50
 
51
+
52
+
51
53
  export interface ContentMetadata {
52
54
  // Common fields for all media types
53
55
  type?: ContentNature;
54
56
  size?: number; // in bytes
55
- language?: string;
57
+ languages?: string[];
56
58
  location?: Location;
57
59
  generation_runs: GenerationRunMetadata[];
58
60
  etag?: string;
@@ -81,6 +83,15 @@ export interface VideoMetadata extends TemporalMediaMetadata {
81
83
  export interface DocumentMetadata extends ContentMetadata {
82
84
  type: 'document';
83
85
  page_count?: number;
86
+ content_processor?: {
87
+ type?: string;
88
+ features_requested?: string[];
89
+ zones_requested?: string[];
90
+ table_count?: number;
91
+ image_count: number;
92
+ zone_count: number;
93
+ needs_ocr_count?: number;
94
+ }
84
95
  }
85
96
 
86
97
  export interface Transcript {
@@ -94,8 +105,8 @@ export interface TranscriptSegment {
94
105
  text: string
95
106
  speaker?: number
96
107
  end?: number
97
- language?: string
98
108
  confidence?: number
109
+ language?: string
99
110
  }
100
111
 
101
112
  export interface ContentSource {
@@ -129,7 +140,6 @@ export interface ContentObjectItem<T = any> extends BaseObject {
129
140
  encoding: string; // the encoding used to calculate the tokens
130
141
  etag: string; //the etag of the text used for the token count
131
142
  };
132
- run?: string; // the ID of the interaction run that created the object
133
143
  }
134
144
 
135
145
  /**
@@ -176,20 +186,19 @@ export interface ColumnLayout {
176
186
  default?: any;
177
187
  }
178
188
  export interface ContentObjectType extends ContentObjectTypeItem {
179
- object_schema?: Record<string, any>; // an optional JSON schema for the object properties.
180
- table_layout?: ColumnLayout[]; // an optional table layout for the object properties.
181
189
  }
182
190
  export interface ContentObjectTypeItem extends BaseObject {
183
191
  is_chunkable?: boolean;
184
- }
185
- /**
186
- * Used to list types with their table layout if any
187
- */
188
- export interface ContentObjectTypeLayout {
189
- id: string;
190
- name: string;
191
- description?: string;
192
+ /**
193
+ * This is only included in ContentObjectTypeItem if explicitely requested
194
+ * It is always included in ContentObjectType
195
+ */
192
196
  table_layout?: ColumnLayout[];
197
+ /**
198
+ * this is only included in ContentObjectTypeItem if explicitely requested
199
+ * It is always included in ContentObjectType
200
+ */
201
+ object_schema?: Record<string, any>; // an optional JSON schema for the object properties.
193
202
  }
194
203
 
195
204
  export interface CreateContentObjectTypePayload extends Omit<ContentObjectType, 'id' | 'created_at' | 'updated_at' | 'created_by' | 'updated_by'> {
@@ -1,4 +1,3 @@
1
-
2
1
  export enum ContentEventName {
3
2
  create = "create",
4
3
  change_type = "change_type",
@@ -6,19 +5,14 @@ export enum ContentEventName {
6
5
  delete = "delete",
7
6
  workflow_finished = "workflow_finished",
8
7
  workflow_execution_request = "workflow_execution_request",
8
+ api_request = "api_request",
9
9
  }
10
10
 
11
-
12
- export interface WorkflowExecutionPayload {
13
- /**
14
- * The event which started the workflow who created the activity.
15
- */
16
- event: ContentEventName;
17
-
11
+ export interface WorkflowExecutionBaseParams<T = Record<string, any>> {
18
12
  /**
19
13
  * The ref of the user who initiated the workflow.
20
14
  */
21
- initiated_by: string;
15
+ initiated_by?: string;
22
16
 
23
17
  /**
24
18
  * The account ID of the user who created the activity.
@@ -31,17 +25,6 @@ export interface WorkflowExecutionPayload {
31
25
  */
32
26
  project_id: string;
33
27
 
34
- /**
35
- * The Unix timestamp when the workflow was started.
36
- */
37
- timestamp: number;
38
-
39
- /*
40
- * The Workflow Rule ID if any. If the workflow was started by a rule this field will contain the rule ID
41
- * otherwise if the workflow was started on demand the property will be undefined.
42
- */
43
- wf_rule_name?: string;
44
-
45
28
  /**
46
29
  * The vars field is mainly used to pass the user input to the workflow.
47
30
  * The user input ar custom user options that can be used to configure the workflow.
@@ -51,17 +34,12 @@ export interface WorkflowExecutionPayload {
51
34
  *
52
35
  * In case of dsl workflows the worflow execution payload vars will be applied over the default vars values stored in the DSL vars field.
53
36
  */
54
- vars: Record<string, any>;
37
+ vars: T;
55
38
 
56
39
  /**
57
40
  * Auth Token to access Zeno and Composable from the workers
58
41
  */
59
- auth_token: string;
60
-
61
- /**
62
- * The ID of the target objects processed by the workflow.
63
- */
64
- objectIds: string[];
42
+ auth_token?: string;
65
43
 
66
44
  /**
67
45
  * The configuration for the workflow execution.
@@ -69,15 +47,46 @@ export interface WorkflowExecutionPayload {
69
47
  config?: {
70
48
  studio_url: string;
71
49
  store_url: string;
50
+ slack_app_url?: string;
72
51
  enabled_integrations?: string[]; //list of enabled integrations
73
- }
52
+ };
53
+
54
+ /**
55
+ * The list of endpoints to notify when the workflow finishes.
56
+ * It is handled by a subworkflow execution, so the main workflow will not wait for the notification to be sent.
57
+ */
58
+ notify_endpoints?: string[];
74
59
  }
75
60
 
61
+ export interface WorkflowExecutionPayload<T = Record<string, any>> extends WorkflowExecutionBaseParams<T> {
62
+ /**
63
+ * The event which started the workflow who created the activity.
64
+ */
65
+ event: ContentEventName;
66
+
67
+ /*
68
+ * The Workflow Rule ID if any. If the workflow was started by a rule this field will contain the rule ID
69
+ * otherwise if the workflow was started on demand the property will be undefined.
70
+ */
71
+ wf_rule_name?: string;
72
+
73
+ /**
74
+ * The ID of the target objects processed by the workflow.
75
+ */
76
+ objectIds: string[];
77
+
78
+ /**
79
+ * Auth Token to access Zeno and Composable from the workers
80
+ */
81
+ auth_token: string;
82
+ }
76
83
 
77
84
  export interface ExecuteWorkflowPayload {
78
85
  task_queue?: string;
79
86
  objectIds?: string[];
80
87
  vars?: Record<string, any>;
88
+ unique?: boolean;
89
+ timeout?: number; //timeout in seconds
81
90
  }
82
91
 
83
92
  export interface ListWorkflowRunsPayload {
@@ -88,6 +97,7 @@ export interface ListWorkflowRunsPayload {
88
97
  end?: string;
89
98
  status?: string;
90
99
  search_term?: string;
100
+ initiated_by?: string;
91
101
  }
92
102
 
93
103
  interface WorkflowRunEvent {
@@ -101,7 +111,7 @@ interface WorkflowRunEvent {
101
111
  name: string;
102
112
  id: string;
103
113
  input?: any;
104
- }
114
+ };
105
115
 
106
116
  error?: {
107
117
  message: string;
@@ -110,19 +120,20 @@ interface WorkflowRunEvent {
110
120
  type?: string;
111
121
  };
112
122
 
113
- result?: any
114
-
123
+ result?: any;
115
124
  }
116
125
 
117
126
  export interface WorkflowRun {
118
- status?: WorkflowExecutionStatus | string,
119
- type?: string,
120
- started_at?: number,
121
- closed_at?: number,
122
- execution_duration?: number,
123
- run_id?: string,
124
- workflow_id?: string,
125
- raw?: any
127
+ status?: WorkflowExecutionStatus | string;
128
+ type?: string;
129
+ started_at?: number;
130
+ closed_at?: number;
131
+ execution_duration?: number;
132
+ run_id?: string;
133
+ workflow_id?: string;
134
+ initiated_by?: string;
135
+ result?: any;
136
+ raw?: any;
126
137
  }
127
138
 
128
139
  export interface WorkflowRunWithDetails extends WorkflowRun {
@@ -132,12 +143,12 @@ export interface ListWorkflowRunsResponse {
132
143
  runs: WorkflowRun[];
133
144
  }
134
145
 
135
- export interface MultiDocumentsInteractionParams extends Omit<WorkflowExecutionPayload, 'config'> {
146
+ export interface MultiDocumentsInteractionParams extends Omit<WorkflowExecutionPayload, "config"> {
136
147
  config: {
137
148
  interactionName: string;
138
149
  action: DocumentActionConfig;
139
150
  data: Record<string, any>;
140
- }
151
+ };
141
152
  }
142
153
 
143
154
  export interface DocumentActionConfig {
@@ -159,4 +170,38 @@ export enum WorkflowExecutionStatus {
159
170
  TERMINATED = 5,
160
171
  CONTINUED_AS_NEW = 6,
161
172
  TIMED_OUT = 7,
162
- }
173
+ }
174
+
175
+ /**
176
+ * Basic response for anything run with an async workflow
177
+ */
178
+ export interface WorkflowRunStatus {
179
+ workflow_id: string | null;
180
+ workflow_run_id: string | null;
181
+ status: WorkflowExecutionStatus;
182
+ }
183
+
184
+ /**
185
+ * Workflow Update Message
186
+ */
187
+ export interface AgentMessage {
188
+ timestamp: number;
189
+ workflow_run_id: string;
190
+ type: AgentMessageType;
191
+ message?: string;
192
+ details?: any;
193
+ }
194
+
195
+ export enum AgentMessageType {
196
+ SYSTEM = "system",
197
+ THOUGHT = "thought",
198
+ PLAN = "plan",
199
+ UPDATE = "update",
200
+ COMPLETE = "complete",
201
+ WARNING = "warning",
202
+ ERROR = "error",
203
+ ANSWER = "answer",
204
+ QUESTION = "question",
205
+ REQUEST_INPUT = "request_input",
206
+ IDLE = "idle",
207
+ }
package/src/user.ts CHANGED
@@ -31,6 +31,16 @@ export enum Datacenters {
31
31
  azure = 'azure'
32
32
  }
33
33
 
34
+ export enum BillingMethod {
35
+ stripe = 'stripe',
36
+ invoice ='invoice'
37
+ }
38
+
39
+
40
+ interface AccountBilling {
41
+ method: BillingMethod;
42
+ stripe_customer_id?: string;
43
+ }
34
44
  export interface Account {
35
45
  id: string;
36
46
  name: string;
@@ -49,6 +59,8 @@ export interface Account {
49
59
 
50
60
  datacenter: string;
51
61
 
62
+ billing: AccountBilling;
63
+
52
64
  created_by: string;
53
65
  updated_by: string;
54
66
  created_at: string;
@@ -58,6 +70,7 @@ export interface Account {
58
70
  export interface UpdateAccountPayload {
59
71
  name?: string;
60
72
  email_domains?: string[];
73
+ billing?: AccountBilling;
61
74
  }
62
75
 
63
76
  export interface AccountRef {
@@ -94,11 +107,9 @@ export interface UserSessionInfo extends SessionInfo<User> { }
94
107
  export interface ApiKeySessionInfo extends SessionInfo<ApiKey> { }
95
108
 
96
109
  export interface OnboardingProgress {
97
- projects: boolean,
98
110
  interactions: boolean,
99
111
  prompts: boolean,
100
112
  environments: boolean,
101
- runs: boolean;
102
113
  default_environment_defined: boolean
103
114
  }
104
115
 
@@ -0,0 +1,32 @@
1
+ import mime from 'mime';
2
+
3
+
4
+ const ADVANCED_PROCESSING_PREFIX = 'magic-pdf';
5
+
6
+ export interface AdvancedProcessingObjectFileParams {
7
+ objectId: string;
8
+ fileId: string;
9
+ prefix?: string;
10
+ contentType?: string;
11
+ path?: any;
12
+ }
13
+
14
+ /**
15
+ *
16
+ * Advanced content processing only
17
+ * generate a file path based on object ID and file role
18
+ *
19
+ * @returns
20
+ */
21
+ export function getPathForAdvancedProcessingFile({ objectId, prefix, fileId, contentType }: AdvancedProcessingObjectFileParams) {
22
+
23
+ const extension = contentType ? `.${mime.getExtension(contentType)}` : '';
24
+ const p = prefix ? `${prefix}/` : '';
25
+
26
+ let path = `${ADVANCED_PROCESSING_PREFIX}/${objectId}/${p}${fileId}`;
27
+ if (!path.endsWith(extension)) {
28
+ path += extension;
29
+ }
30
+
31
+ return path;
32
+ }
@@ -1,8 +1,25 @@
1
- import { PromptRole } from "@llumiverse/core";
1
+ import { JSONSchema, PromptRole } from "@llumiverse/core";
2
2
  import { JSONSchema4 } from "json-schema";
3
3
  import { InteractionRefWithSchema, PopulatedInteraction } from "../interaction.js";
4
4
  import { PopulatedPromptSegmentDef, PromptSegmentDef, PromptSegmentDefType, PromptTemplateRefWithSchema } from "../prompt.js";
5
5
 
6
+
7
+ export function mergeJSONSchemas(schemas: JSONSchema[]) {
8
+ const props: Record<string, JSONSchema4> = {};
9
+ let required: string[] = [];
10
+ for (const schema of schemas) {
11
+ if (schema.properties) {
12
+ if (schema.required) {
13
+ for (const prop of schema.required as string[]) {
14
+ if (!required.includes(prop)) required.push(prop);
15
+ }
16
+ }
17
+ Object.assign(props, schema.properties);
18
+ }
19
+ }
20
+ return Object.keys(props).length > 0 ? { properties: props, required } as JSONSchema : null;
21
+ }
22
+
6
23
  export function _mergePromptsSchema(prompts: PromptSegmentDef<PromptTemplateRefWithSchema>[] | PopulatedPromptSegmentDef[]) {
7
24
  const props: Record<string, JSONSchema4> = {};
8
25
  let required: string[] = [];