@vertesia/common 0.42.2

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 (201) hide show
  1. package/LICENSE +13 -0
  2. package/lib/cjs/access-control.js +39 -0
  3. package/lib/cjs/access-control.js.map +1 -0
  4. package/lib/cjs/analytics.js +3 -0
  5. package/lib/cjs/analytics.js.map +1 -0
  6. package/lib/cjs/apikey.js +15 -0
  7. package/lib/cjs/apikey.js.map +1 -0
  8. package/lib/cjs/common.js +3 -0
  9. package/lib/cjs/common.js.map +1 -0
  10. package/lib/cjs/environment.js +116 -0
  11. package/lib/cjs/environment.js.map +1 -0
  12. package/lib/cjs/facets.js +3 -0
  13. package/lib/cjs/facets.js.map +1 -0
  14. package/lib/cjs/index.js +37 -0
  15. package/lib/cjs/index.js.map +1 -0
  16. package/lib/cjs/integrations.js +10 -0
  17. package/lib/cjs/integrations.js.map +1 -0
  18. package/lib/cjs/interaction.js +63 -0
  19. package/lib/cjs/interaction.js.map +1 -0
  20. package/lib/cjs/package.json +3 -0
  21. package/lib/cjs/payload.js +3 -0
  22. package/lib/cjs/payload.js.map +1 -0
  23. package/lib/cjs/project.js +50 -0
  24. package/lib/cjs/project.js.map +1 -0
  25. package/lib/cjs/prompt.js +21 -0
  26. package/lib/cjs/prompt.js.map +1 -0
  27. package/lib/cjs/query.js +3 -0
  28. package/lib/cjs/query.js.map +1 -0
  29. package/lib/cjs/refs.js +12 -0
  30. package/lib/cjs/refs.js.map +1 -0
  31. package/lib/cjs/runs.js +3 -0
  32. package/lib/cjs/runs.js.map +1 -0
  33. package/lib/cjs/store/activity-catalog.js +3 -0
  34. package/lib/cjs/store/activity-catalog.js.map +1 -0
  35. package/lib/cjs/store/common.js +3 -0
  36. package/lib/cjs/store/common.js.map +1 -0
  37. package/lib/cjs/store/dsl-workflow.js +5 -0
  38. package/lib/cjs/store/dsl-workflow.js.map +1 -0
  39. package/lib/cjs/store/index.js +24 -0
  40. package/lib/cjs/store/index.js.map +1 -0
  41. package/lib/cjs/store/object-types.js +98 -0
  42. package/lib/cjs/store/object-types.js.map +1 -0
  43. package/lib/cjs/store/store.js +18 -0
  44. package/lib/cjs/store/store.js.map +1 -0
  45. package/lib/cjs/store/temporalio.js +44 -0
  46. package/lib/cjs/store/temporalio.js.map +1 -0
  47. package/lib/cjs/store/workflow.js +24 -0
  48. package/lib/cjs/store/workflow.js.map +1 -0
  49. package/lib/cjs/training.js +14 -0
  50. package/lib/cjs/training.js.map +1 -0
  51. package/lib/cjs/transient-tokens.js +9 -0
  52. package/lib/cjs/transient-tokens.js.map +1 -0
  53. package/lib/cjs/user.js +12 -0
  54. package/lib/cjs/user.js.map +1 -0
  55. package/lib/cjs/utils/auth.js +15 -0
  56. package/lib/cjs/utils/auth.js.map +1 -0
  57. package/lib/cjs/utils/schemas.js +48 -0
  58. package/lib/cjs/utils/schemas.js.map +1 -0
  59. package/lib/esm/access-control.js +36 -0
  60. package/lib/esm/access-control.js.map +1 -0
  61. package/lib/esm/analytics.js +2 -0
  62. package/lib/esm/analytics.js.map +1 -0
  63. package/lib/esm/apikey.js +12 -0
  64. package/lib/esm/apikey.js.map +1 -0
  65. package/lib/esm/common.js +2 -0
  66. package/lib/esm/common.js.map +1 -0
  67. package/lib/esm/environment.js +113 -0
  68. package/lib/esm/environment.js.map +1 -0
  69. package/lib/esm/facets.js +2 -0
  70. package/lib/esm/facets.js.map +1 -0
  71. package/lib/esm/index.js +21 -0
  72. package/lib/esm/index.js.map +1 -0
  73. package/lib/esm/integrations.js +7 -0
  74. package/lib/esm/integrations.js.map +1 -0
  75. package/lib/esm/interaction.js +60 -0
  76. package/lib/esm/interaction.js.map +1 -0
  77. package/lib/esm/payload.js +2 -0
  78. package/lib/esm/payload.js.map +1 -0
  79. package/lib/esm/project.js +46 -0
  80. package/lib/esm/project.js.map +1 -0
  81. package/lib/esm/prompt.js +18 -0
  82. package/lib/esm/prompt.js.map +1 -0
  83. package/lib/esm/query.js +2 -0
  84. package/lib/esm/query.js.map +1 -0
  85. package/lib/esm/refs.js +9 -0
  86. package/lib/esm/refs.js.map +1 -0
  87. package/lib/esm/runs.js +2 -0
  88. package/lib/esm/runs.js.map +1 -0
  89. package/lib/esm/store/activity-catalog.js +2 -0
  90. package/lib/esm/store/activity-catalog.js.map +1 -0
  91. package/lib/esm/store/common.js +2 -0
  92. package/lib/esm/store/common.js.map +1 -0
  93. package/lib/esm/store/dsl-workflow.js +2 -0
  94. package/lib/esm/store/dsl-workflow.js.map +1 -0
  95. package/lib/esm/store/index.js +8 -0
  96. package/lib/esm/store/index.js.map +1 -0
  97. package/lib/esm/store/object-types.js +95 -0
  98. package/lib/esm/store/object-types.js.map +1 -0
  99. package/lib/esm/store/store.js +15 -0
  100. package/lib/esm/store/store.js.map +1 -0
  101. package/lib/esm/store/temporalio.js +41 -0
  102. package/lib/esm/store/temporalio.js.map +1 -0
  103. package/lib/esm/store/workflow.js +21 -0
  104. package/lib/esm/store/workflow.js.map +1 -0
  105. package/lib/esm/training.js +11 -0
  106. package/lib/esm/training.js.map +1 -0
  107. package/lib/esm/transient-tokens.js +6 -0
  108. package/lib/esm/transient-tokens.js.map +1 -0
  109. package/lib/esm/user.js +9 -0
  110. package/lib/esm/user.js.map +1 -0
  111. package/lib/esm/utils/auth.js +11 -0
  112. package/lib/esm/utils/auth.js.map +1 -0
  113. package/lib/esm/utils/schemas.js +44 -0
  114. package/lib/esm/utils/schemas.js.map +1 -0
  115. package/lib/tsconfig.tsbuildinfo +1 -0
  116. package/lib/types/access-control.d.ts +56 -0
  117. package/lib/types/access-control.d.ts.map +1 -0
  118. package/lib/types/analytics.d.ts +36 -0
  119. package/lib/types/analytics.d.ts.map +1 -0
  120. package/lib/types/apikey.d.ts +54 -0
  121. package/lib/types/apikey.d.ts.map +1 -0
  122. package/lib/types/common.d.ts +28 -0
  123. package/lib/types/common.d.ts.map +1 -0
  124. package/lib/types/environment.d.ts +79 -0
  125. package/lib/types/environment.d.ts.map +1 -0
  126. package/lib/types/facets.d.ts +34 -0
  127. package/lib/types/facets.d.ts.map +1 -0
  128. package/lib/types/index.d.ts +20 -0
  129. package/lib/types/index.d.ts.map +1 -0
  130. package/lib/types/integrations.d.ts +18 -0
  131. package/lib/types/integrations.d.ts.map +1 -0
  132. package/lib/types/interaction.d.ts +233 -0
  133. package/lib/types/interaction.d.ts.map +1 -0
  134. package/lib/types/payload.d.ts +49 -0
  135. package/lib/types/payload.d.ts.map +1 -0
  136. package/lib/types/project.d.ts +95 -0
  137. package/lib/types/project.d.ts.map +1 -0
  138. package/lib/types/prompt.d.ts +70 -0
  139. package/lib/types/prompt.d.ts.map +1 -0
  140. package/lib/types/query.d.ts +74 -0
  141. package/lib/types/query.d.ts.map +1 -0
  142. package/lib/types/refs.d.ts +19 -0
  143. package/lib/types/refs.d.ts.map +1 -0
  144. package/lib/types/runs.d.ts +24 -0
  145. package/lib/types/runs.d.ts.map +1 -0
  146. package/lib/types/store/activity-catalog.d.ts +24 -0
  147. package/lib/types/store/activity-catalog.d.ts.map +1 -0
  148. package/lib/types/store/common.d.ts +10 -0
  149. package/lib/types/store/common.d.ts.map +1 -0
  150. package/lib/types/store/dsl-workflow.d.ts +244 -0
  151. package/lib/types/store/dsl-workflow.d.ts.map +1 -0
  152. package/lib/types/store/index.d.ts +7 -0
  153. package/lib/types/store/index.d.ts.map +1 -0
  154. package/lib/types/store/object-types.d.ts +23 -0
  155. package/lib/types/store/object-types.d.ts.map +1 -0
  156. package/lib/types/store/store.d.ts +211 -0
  157. package/lib/types/store/store.d.ts.map +1 -0
  158. package/lib/types/store/temporalio.d.ts +16 -0
  159. package/lib/types/store/temporalio.d.ts.map +1 -0
  160. package/lib/types/store/workflow.d.ts +129 -0
  161. package/lib/types/store/workflow.d.ts.map +1 -0
  162. package/lib/types/training.d.ts +38 -0
  163. package/lib/types/training.d.ts.map +1 -0
  164. package/lib/types/transient-tokens.d.ts +27 -0
  165. package/lib/types/transient-tokens.d.ts.map +1 -0
  166. package/lib/types/user.d.ts +105 -0
  167. package/lib/types/user.d.ts.map +1 -0
  168. package/lib/types/utils/auth.d.ts +3 -0
  169. package/lib/types/utils/auth.d.ts.map +1 -0
  170. package/lib/types/utils/schemas.d.ts +5 -0
  171. package/lib/types/utils/schemas.d.ts.map +1 -0
  172. package/package.json +34 -0
  173. package/src/access-control.ts +77 -0
  174. package/src/analytics.ts +49 -0
  175. package/src/apikey.ts +68 -0
  176. package/src/common.ts +34 -0
  177. package/src/environment.ts +193 -0
  178. package/src/facets.ts +44 -0
  179. package/src/index.ts +20 -0
  180. package/src/integrations.ts +25 -0
  181. package/src/interaction.ts +300 -0
  182. package/src/payload.ts +62 -0
  183. package/src/project.ts +136 -0
  184. package/src/prompt.ts +95 -0
  185. package/src/query.ts +85 -0
  186. package/src/refs.ts +27 -0
  187. package/src/runs.ts +27 -0
  188. package/src/store/activity-catalog.ts +39 -0
  189. package/src/store/common.ts +10 -0
  190. package/src/store/dsl-workflow.ts +289 -0
  191. package/src/store/index.ts +7 -0
  192. package/src/store/ms.d.ts +11 -0
  193. package/src/store/object-types.ts +128 -0
  194. package/src/store/store.ts +262 -0
  195. package/src/store/temporalio.ts +54 -0
  196. package/src/store/workflow.ts +156 -0
  197. package/src/training.ts +44 -0
  198. package/src/transient-tokens.ts +30 -0
  199. package/src/user.ts +124 -0
  200. package/src/utils/auth.ts +12 -0
  201. package/src/utils/schemas.ts +44 -0
@@ -0,0 +1,262 @@
1
+ import { SearchPayload } from '../payload.js';
2
+ import { SupportedEmbeddingTypes } from '../project.js';
3
+ import { ComplexSearchQuery } from '../query.js';
4
+ import { BaseObject } from './common.js';
5
+ import { RenditionProperties } from './index.js';
6
+
7
+ export enum ContentObjectStatus {
8
+ created = 'created',
9
+ processing = 'processing', // the was created and still processing
10
+ completed = 'completed',
11
+ failed = 'failed',
12
+ archived = 'archived',
13
+ }
14
+
15
+
16
+ export interface Embedding {
17
+ model: string; //the model used to generate this embedding
18
+ values: number[];
19
+ etag?: string; // the etag of the text used for the embedding
20
+ }
21
+
22
+ export interface ContentObject<T = any> extends ContentObjectItem<T> {
23
+ text?: string; // the text representation of the object
24
+ text_etag?: string;
25
+ embeddings: Partial<Record<SupportedEmbeddingTypes, Embedding>>;
26
+ parts?: string[]; // the list of objectId of the parts of the object
27
+ parts_etag?: string; // the etag of the text used for the parts list
28
+ transcript?: Transcript;
29
+ }
30
+
31
+
32
+ export type ContentNature = 'video' | 'image' | 'audio' | 'document' | 'code' | 'other';
33
+
34
+ export interface Dimensions {
35
+ width: number;
36
+ height: number;
37
+ }
38
+
39
+ export interface Location {
40
+ latitude: number;
41
+ longitude: number;
42
+ }
43
+
44
+ export interface GenerationRunMetadata {
45
+ id: string;
46
+ date: string;
47
+ model: string;
48
+ target?: string;
49
+ }
50
+
51
+ export interface ContentMetadata {
52
+ // Common fields for all media types
53
+ type?: ContentNature;
54
+ size?: number; // in bytes
55
+ language?: string;
56
+ location?: Location;
57
+ generation_runs: GenerationRunMetadata[];
58
+ etag?: string;
59
+ }
60
+
61
+ // Example of type-specific metadata interfaces (optional, for better type safety)
62
+ export interface TemporalMediaMetadata extends ContentMetadata {
63
+ duration?: number; // in seconds
64
+ transcript?: Transcript
65
+ }
66
+
67
+ export interface ImageMetadata extends ContentMetadata {
68
+ type: 'image';
69
+ dimensions?: Dimensions;
70
+ }
71
+
72
+ export interface AudioMetadata extends TemporalMediaMetadata {
73
+ type: 'audio';
74
+ }
75
+
76
+ export interface VideoMetadata extends TemporalMediaMetadata {
77
+ type: 'video';
78
+ dimensions?: Dimensions;
79
+ }
80
+
81
+ export interface DocumentMetadata extends ContentMetadata {
82
+ type: 'document';
83
+ page_count?: number;
84
+ }
85
+
86
+ export interface Transcript {
87
+ text?: string;
88
+ segments?: TranscriptSegment[];
89
+ etag?: string;
90
+ }
91
+
92
+ export interface TranscriptSegment {
93
+ start: number
94
+ text: string
95
+ speaker?: number
96
+ end?: number
97
+ language?: string
98
+ confidence?: number
99
+ }
100
+
101
+ export interface ContentSource {
102
+ // the URI of the content source. Usually an URL to the uploaded file inside a cloud file storage like s3.
103
+ source?: string;
104
+ // the mime type of the content source.
105
+ type?: string;
106
+ // the original name of the input file if any
107
+ name?: string;
108
+ // the etag of the content source if any
109
+ etag?: string;
110
+ }
111
+
112
+ /**
113
+ * The content object item is a simplified version of the ContentObject that is returned by the store API when listing objects.
114
+ */
115
+ export interface ContentObjectItem<T = any> extends BaseObject {
116
+ root?: string; // the ID of the root parent object. The root object doesn't have the root field set.
117
+ parent: string; // the id of the direct parent object. The root object doesn't have the parent field set.
118
+ location: string; // the path of the parent object
119
+ status: ContentObjectStatus;
120
+ // A ref to the object type
121
+ type?: ContentObjectTypeRef;
122
+ // the content source URL and type
123
+ content: ContentSource;
124
+ external_id?: string;
125
+ properties: T | Record<string, any>; // a JSON object that describes the object
126
+ metadata?: VideoMetadata | AudioMetadata | ImageMetadata | DocumentMetadata | ContentMetadata;
127
+ tokens?: {
128
+ count: number; // the number of tokens in the text
129
+ encoding: string; // the encoding used to calculate the tokens
130
+ etag: string; //the etag of the text used for the token count
131
+ };
132
+ run?: string; // the ID of the interaction run that created the object
133
+ }
134
+
135
+ /**
136
+ * When creating from an uploaded file the content shouild be an URL to the uploaded file
137
+ */
138
+ export interface CreateContentObjectPayload<T = any> extends Partial<Omit<ContentObject<T>,
139
+ 'id' | 'root' | 'created_at' | 'updated_at' | 'type'
140
+ | 'owner'>> {
141
+ id?: string; // An optional existing object ID to be replaced by the new one
142
+ type?: string; // the object type ID
143
+ generation_run_info?: GenerationRunMetadata;
144
+ }
145
+
146
+ export interface ContentObjectTypeRef {
147
+ id: string;
148
+ name: string;
149
+ }
150
+
151
+ export interface ComplexSearchPayload extends Omit<SearchPayload, 'query'> {
152
+ query?: ComplexSearchQuery;
153
+ }
154
+
155
+ export interface ColumnLayout {
156
+ /**
157
+ * The path of the field to use (e.g. "properties.title")
158
+ */
159
+ field: string;
160
+ /**
161
+ * The name to display in the table column
162
+ */
163
+ name: string;
164
+ /**
165
+ * The type of the field specifies how the rendering will be done. If not specified the string type will be used.
166
+ * The type may contain additional parameters prepended using a web-like query string syntax: date?LLL
167
+ */
168
+ type?: string;
169
+ /*
170
+ * a fallback field to use if the field is not present in the object
171
+ */
172
+ fallback?: string;
173
+ /**
174
+ * A default value to be used if the field is not present in the object
175
+ */
176
+ default?: any;
177
+ }
178
+ 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
+ }
182
+ export interface ContentObjectTypeItem extends BaseObject {
183
+ 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
+ table_layout?: ColumnLayout[];
193
+ }
194
+
195
+ export interface CreateContentObjectTypePayload extends Omit<ContentObjectType, 'id' | 'created_at' | 'updated_at' | 'created_by' | 'updated_by'> {
196
+ }
197
+
198
+ export enum WorkflowRuleInputType {
199
+ single = 'single',
200
+ multiple = 'multiple',
201
+ none = 'none'
202
+ }
203
+ export interface WorkflowRuleItem extends BaseObject {
204
+ // the name of the workflow function
205
+ endpoint: string;
206
+ input_type: WorkflowRuleInputType;
207
+ }
208
+ export interface WorkflowRule extends WorkflowRuleItem {
209
+ /*
210
+ * mongo matching rules for a content event
211
+ */
212
+ match?: Record<string, any>;
213
+ /**
214
+ * Activities configuration if any.
215
+ */
216
+ config?: Record<string, any>;
217
+
218
+ /**
219
+ * Debug mode for the rule
220
+ * @default false
221
+ */
222
+ debug?: boolean;
223
+
224
+ /**
225
+ * Customer override for the rule
226
+ * When set to true the rule will not be updated by the system
227
+ */
228
+ customer_override?: boolean;
229
+ }
230
+
231
+
232
+ export interface CreateWorkflowRulePayload extends UploadWorkflowRulePayload {
233
+ name: string; // required
234
+ endpoint: string; // required
235
+ }
236
+ export interface UploadWorkflowRulePayload extends Partial<Omit<WorkflowRule, 'id' | 'created_at' | 'updated_at' | 'owner'>> {
237
+ }
238
+
239
+ export interface GetRenditionResponse {
240
+
241
+ status: 'found' | 'generating' | 'failed';
242
+ rendition?: ContentObject<RenditionProperties> //TODO add <Rendition>
243
+ workflow_run_id?: string;
244
+ }
245
+
246
+ export interface GetUploadUrlPayload {
247
+ name: string;
248
+ id?: string;
249
+ mime_type?: string;
250
+ ttl?: number;
251
+ }
252
+
253
+ export interface GetFileUrlPayload {
254
+ file: string;
255
+ }
256
+
257
+ export interface GetFileUrlResponse {
258
+ url: string;
259
+ id: string;
260
+ mime_type: string;
261
+ path: string;
262
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copied from temporalio
3
+ * The temporalio ParentClosePolicy
4
+ */
5
+ export type ParentClosePolicyType = "TERMINATE" | "ABANDON" | "REQUEST_CANCEL" | undefined;
6
+ interface ParentClosePolicyI {
7
+ TERMINATE: "TERMINATE",
8
+ ABANDON: "ABANDON",
9
+ REQUEST_CANCEL: "REQUEST_CANCEL",
10
+ PARENT_CLOSE_POLICY_UNSPECIFIED: undefined,
11
+ PARENT_CLOSE_POLICY_TERMINATE: "TERMINATE",
12
+ PARENT_CLOSE_POLICY_ABANDON: "ABANDON",
13
+ PARENT_CLOSE_POLICY_REQUEST_CANCEL: "REQUEST_CANCEL"
14
+ }
15
+ export const ParentClosePolicy = {
16
+ /**
17
+ * When the Parent is Closed, the Child is Terminated.
18
+ *
19
+ * @default
20
+ */
21
+ TERMINATE: "TERMINATE",
22
+ /**
23
+ * When the Parent is Closed, nothing is done to the Child.
24
+ */
25
+ ABANDON: "ABANDON",
26
+ /**
27
+ * When the Parent is Closed, the Child is Cancelled.
28
+ */
29
+ REQUEST_CANCEL: "REQUEST_CANCEL",
30
+ /**
31
+ * If a `ParentClosePolicy` is set to this, or is not set at all, the server default value will be used.
32
+ *
33
+ * @deprecated Either leave property `undefined`, or set an explicit policy instead.
34
+ */
35
+ PARENT_CLOSE_POLICY_UNSPECIFIED: undefined,
36
+ /**
37
+ * When the Parent is Closed, the Child is Terminated.
38
+ *
39
+ * @deprecated Use {@link ParentClosePolicy.TERMINATE} instead.
40
+ */
41
+ PARENT_CLOSE_POLICY_TERMINATE: "TERMINATE",
42
+ /**
43
+ * When the Parent is Closed, nothing is done to the Child.
44
+ *
45
+ * @deprecated Use {@link ParentClosePolicy.ABANDON} instead.
46
+ */
47
+ PARENT_CLOSE_POLICY_ABANDON: "ABANDON",
48
+ /**
49
+ * When the Parent is Closed, the Child is Cancelled.
50
+ *
51
+ * @deprecated Use {@link ParentClosePolicy.REQUEST_CANCEL} instead.
52
+ */
53
+ PARENT_CLOSE_POLICY_REQUEST_CANCEL: "REQUEST_CANCEL"
54
+ } as ParentClosePolicyI;
@@ -0,0 +1,156 @@
1
+
2
+ export enum ContentEventName {
3
+ create = "create",
4
+ change_type = "change_type",
5
+ update = "update",
6
+ delete = "delete",
7
+ workflow_finished = "workflow_finished",
8
+ workflow_execution_request = "workflow_execution_request",
9
+ }
10
+
11
+
12
+ export interface WorkflowExecutionPayload {
13
+ /**
14
+ * The event which started the workflow who created the activity.
15
+ */
16
+ event: ContentEventName;
17
+
18
+ /**
19
+ * The account ID of the user who created the activity.
20
+ * This is usefull to select the right database to work on.
21
+ */
22
+ account_id: string;
23
+
24
+ /**
25
+ * The project ID of the account who created the activity.
26
+ */
27
+ project_id: string;
28
+
29
+ /**
30
+ * The Unix timestamp when the workflow was started.
31
+ */
32
+ timestamp: number;
33
+
34
+ /*
35
+ * The Workflow Rule ID if any. If the workflow was started by a rule this field will contain the rule ID
36
+ * otherwise if the workflow was started on demand the property will be undefined.
37
+ */
38
+ wf_rule_name?: string;
39
+
40
+ /**
41
+ * The vars field is mainly used to pass the user input to the workflow.
42
+ * The user input ar custom user options that can be used to configure the workflow.
43
+ * You can see the user input as the arguments for a command line app.
44
+ *
45
+ * In the case of workflows started by events (e.g. using a a workflow rule) the user input vars will be initialized with the workflow rule configuration field.
46
+ *
47
+ * In case of dsl workflows the worflow execution payload vars will be applied over the default vars values stored in the DSL vars field.
48
+ */
49
+ vars: Record<string, any>;
50
+
51
+ /**
52
+ * Auth Token to access Zeno and Composable from the workers
53
+ */
54
+ auth_token: string;
55
+
56
+ /**
57
+ * The ID of the target objects processed by the workflow.
58
+ */
59
+ objectIds: string[];
60
+
61
+ /**
62
+ * The configuration for the workflow execution.
63
+ */
64
+ config?: {
65
+ studio_url: string;
66
+ store_url: string;
67
+ enabled_integrations?: string[]; //list of enabled integrations
68
+ }
69
+ }
70
+
71
+
72
+ export interface ExecuteWorkflowPayload {
73
+ objectIds?: string[];
74
+ vars?: Record<string, any>;
75
+ }
76
+
77
+ export interface ListWorkflowRunsPayload {
78
+ document_id?: string;
79
+ event_name?: string;
80
+ rule_id?: string;
81
+ start?: string;
82
+ end?: string;
83
+ status?: string;
84
+ search_term?: string;
85
+ }
86
+
87
+ interface WorkflowRunEvent {
88
+ event_id: number;
89
+ event_time: number;
90
+ event_type: string;
91
+ task_id: string;
92
+ attempt: number;
93
+
94
+ activity?: {
95
+ name: string;
96
+ id: string;
97
+ input?: any;
98
+ }
99
+
100
+ error?: {
101
+ message: string;
102
+ source: string;
103
+ stacktrace: string;
104
+ type?: string;
105
+ };
106
+
107
+ result?: any
108
+
109
+ }
110
+
111
+ export interface WorkflowRun {
112
+ status?: WorkflowExecutionStatus | string,
113
+ type?: string,
114
+ started_at?: number,
115
+ closed_at?: number,
116
+ execution_duration?: number,
117
+ run_id?: string,
118
+ workflow_id?: string,
119
+ raw?: any
120
+ }
121
+
122
+ export interface WorkflowRunWithDetails extends WorkflowRun {
123
+ history?: WorkflowRunEvent[];
124
+ }
125
+ export interface ListWorkflowRunsResponse {
126
+ runs: WorkflowRun[];
127
+ }
128
+
129
+ export interface MultiDocumentsInteractionParams extends Omit<WorkflowExecutionPayload, 'config'> {
130
+ config: {
131
+ interactionName: string;
132
+ action: DocumentActionConfig;
133
+ data: Record<string, any>;
134
+ }
135
+ }
136
+
137
+ export interface DocumentActionConfig {
138
+ contentTypeName?: string; //content type to use
139
+ setAsProperties: boolean; //set result as properties
140
+ setAsText: string; //set result as text, if result set the whole result as text
141
+ setNameFrom: string; //result property to use as name
142
+ upsert: boolean; //wether to upsert or update only
143
+ documentId?: string; //doc Id to update
144
+ parentId?: string; //parentId for the created doc
145
+ }
146
+
147
+ export enum WorkflowExecutionStatus {
148
+ UNKNOWN = 0,
149
+ RUNNING = 1,
150
+ COMPLETED = 2,
151
+ FAILED = 3,
152
+ CANCELED = 4,
153
+ TERMINATED = 5,
154
+ CONTINUED_AS_NEW = 6,
155
+ TIMED_OUT = 7,
156
+ }
@@ -0,0 +1,44 @@
1
+ import { TrainingJob } from "@llumiverse/core";
2
+ import { ExecutionEnvironmentRef } from "./environment.js";
3
+
4
+ export enum TrainingSessionStatus {
5
+ 'created' = 'created',
6
+ 'building' = 'building',
7
+ 'prepared' = 'prepared',
8
+ 'processing' = 'processing',
9
+ 'completed' = 'completed',
10
+ 'cancelled' = 'cancelled',
11
+ 'failed' = 'failed'
12
+ }
13
+
14
+ export interface TrainingSession {
15
+ id: string;
16
+ project: string;
17
+ name: string
18
+ env: ExecutionEnvironmentRef,
19
+ model: string,
20
+ status: TrainingSessionStatus,
21
+ runs: string[],
22
+ dataset: string, //the name of the file dataset which was generated in GCS
23
+ job: TrainingJob,
24
+ created_by: string,
25
+ updated_by: string,
26
+ created_at: Date,
27
+ updated_at: Date,
28
+ }
29
+
30
+ export interface TrainingSessionRef extends Omit<TrainingSession, 'runs'> {
31
+ }
32
+
33
+
34
+ export interface TrainingSessionCreatePayload {
35
+ name: string
36
+ env: string,
37
+ model: string,
38
+ }
39
+
40
+ export interface ListTrainingSessionsQuery {
41
+ limit?: number;
42
+ offset?: number;
43
+ status?: TrainingSessionStatus;
44
+ }
@@ -0,0 +1,30 @@
1
+ import { ProjectRoles } from "./project.js";
2
+ import { AccountRef } from "./user.js";
3
+
4
+
5
+ export enum TransientTokenType {
6
+ userInvite = 'user-invite',
7
+ migration = 'migration',
8
+ }
9
+
10
+ export interface TransientToken<T> {
11
+ id: string;
12
+ type: TransientTokenType;
13
+ data: T;
14
+ expires: Date;
15
+ account?: string;
16
+ created_at: Date;
17
+ updated_at: Date;
18
+ }
19
+
20
+
21
+ export interface CreateOrUpdateTransientTokenPayload<T> extends Partial<TransientToken<T>> {
22
+ }
23
+
24
+ export interface UserInviteTokenData {
25
+ email: string;
26
+ role: ProjectRoles;
27
+ account: AccountRef;
28
+ projects?: string[];
29
+ invitedBy: { name: string, email: string; };
30
+ }
package/src/user.ts ADDED
@@ -0,0 +1,124 @@
1
+ import { ApiKey } from "./apikey.js";
2
+ import { ProjectRoles } from "./project.js";
3
+
4
+ export interface UserWithAccounts extends User {
5
+ accounts: AccountRef[];
6
+ }
7
+ export interface User {
8
+ id: string;
9
+ externalId: string;
10
+ email: string;
11
+ name: string;
12
+ username?: string;
13
+ picture?: string;
14
+ language?: string;
15
+ phone?: string;
16
+ sign_in_provider?: string;
17
+ last_selected_account?: string;
18
+ }
19
+
20
+ export interface UserRef {
21
+ id: string;
22
+ name: string;
23
+ email: string;
24
+ picture?: string;
25
+ }
26
+ export const UserRefPopulate = "id name email picture";
27
+
28
+ export enum Datacenters {
29
+ aws = 'aws',
30
+ gcp = 'gcp',
31
+ azure = 'azure'
32
+ }
33
+
34
+ export interface Account {
35
+ id: string;
36
+ name: string;
37
+
38
+ email_domains: string[];
39
+ members: {
40
+ role: ProjectRoles;
41
+ user: UserRef;
42
+ disabled: boolean;
43
+ }[];
44
+
45
+ onboarding: {
46
+ completed: boolean,
47
+ completed_at: Date,
48
+ };
49
+
50
+ datacenter: string;
51
+
52
+ created_by: string;
53
+ updated_by: string;
54
+ created_at: string;
55
+ updated_at: string;
56
+ }
57
+
58
+ export interface UpdateAccountPayload {
59
+ name?: string;
60
+ email_domains?: string[];
61
+ }
62
+
63
+ export interface AccountRef {
64
+ id: string;
65
+ name: string;
66
+ }
67
+ export const AccountRefPopulate = "id name";
68
+
69
+
70
+ export interface InviteUserRequestPayload {
71
+ email: string;
72
+ role: ProjectRoles;
73
+ projects?: string[];
74
+ }
75
+
76
+ export interface InviteUserResponsePayload {
77
+ action: 'invited' | 'added';
78
+ }
79
+
80
+
81
+ type UserOrApiKey<T extends User | ApiKey> = T extends User ? User : ApiKey;
82
+ type SessionType<T extends User | ApiKey> = T extends User ? "user" : "apikey";
83
+ export interface SessionInfo<T extends User | ApiKey> {
84
+ isNew?: boolean;
85
+ type: SessionType<T>;
86
+ subject: UserOrApiKey<T>;
87
+ //User | ApiKey; // no user if using an apikey
88
+ current_account: Account;
89
+ //role: string; // TODO the role on the selected account
90
+ accounts: AccountRef[];
91
+ }
92
+
93
+ export interface UserSessionInfo extends SessionInfo<User> { }
94
+ export interface ApiKeySessionInfo extends SessionInfo<ApiKey> { }
95
+
96
+ export interface OnboardingProgress {
97
+ projects: boolean,
98
+ interactions: boolean,
99
+ prompts: boolean,
100
+ environments: boolean,
101
+ runs: boolean;
102
+ default_environment_defined: boolean
103
+ }
104
+
105
+
106
+ /**
107
+ * Data collected at signup
108
+ * used for onboarding and segments
109
+ **/
110
+ export interface SignupData {
111
+ accountType: string;
112
+ companyName?: string;
113
+ companySize?: number;
114
+ companyWebsite?: string;
115
+ maturity?: string;
116
+ }
117
+
118
+ /**
119
+ * Signup Payload: used to create a new user
120
+ */
121
+ export interface SignupPayload {
122
+ firebaseToken: string;
123
+ signupData: SignupData;
124
+ }
@@ -0,0 +1,12 @@
1
+ import { ProjectRef } from "../project.js";
2
+
3
+ export function getTenantId(accountId: string, projectId: string): string {
4
+ //use the last 6 characters of the accountId as the db name
5
+ //as in mongo the last 6 char are an incrementing counter
6
+ const accountLast6 = accountId.slice(-6);
7
+ const projectLast6 = projectId.slice(-6);
8
+ return accountLast6 + '_' + projectLast6;
9
+ }
10
+ export function getTenantIdFromProject(project: ProjectRef): string {
11
+ return getTenantId(project.account, project.id);
12
+ }