@papr/memory 1.20.0 → 2.0.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.
- package/CHANGELOG.md +61 -0
- package/LICENSE +1 -1
- package/README.md +13 -1
- package/client.d.mts +37 -9
- package/client.d.mts.map +1 -1
- package/client.d.ts +37 -9
- package/client.d.ts.map +1 -1
- package/client.js +17 -2
- package/client.js.map +1 -1
- package/client.mjs +17 -2
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/tslib.js +22 -22
- package/package.json +1 -1
- package/resources/document.d.mts +16 -3
- package/resources/document.d.mts.map +1 -1
- package/resources/document.d.ts +16 -3
- package/resources/document.d.ts.map +1 -1
- package/resources/index.d.mts +6 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +7 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -0
- package/resources/index.mjs.map +1 -1
- package/resources/memory.d.mts +498 -119
- package/resources/memory.d.mts.map +1 -1
- package/resources/memory.d.ts +498 -119
- package/resources/memory.d.ts.map +1 -1
- package/resources/memory.js +8 -4
- package/resources/memory.js.map +1 -1
- package/resources/memory.mjs +8 -4
- package/resources/memory.mjs.map +1 -1
- package/resources/messages/index.d.mts +3 -0
- package/resources/messages/index.d.mts.map +1 -0
- package/resources/messages/index.d.ts +3 -0
- package/resources/messages/index.d.ts.map +1 -0
- package/resources/messages/index.js +9 -0
- package/resources/messages/index.js.map +1 -0
- package/resources/messages/index.mjs +4 -0
- package/resources/messages/index.mjs.map +1 -0
- package/resources/messages/messages.d.mts +160 -0
- package/resources/messages/messages.d.mts.map +1 -0
- package/resources/messages/messages.d.ts +160 -0
- package/resources/messages/messages.d.ts.map +1 -0
- package/resources/messages/messages.js +54 -0
- package/resources/messages/messages.js.map +1 -0
- package/resources/messages/messages.mjs +49 -0
- package/resources/messages/messages.mjs.map +1 -0
- package/resources/messages/sessions.d.mts +262 -0
- package/resources/messages/sessions.d.mts.map +1 -0
- package/resources/messages/sessions.d.ts +262 -0
- package/resources/messages/sessions.d.ts.map +1 -0
- package/resources/messages/sessions.js +122 -0
- package/resources/messages/sessions.js.map +1 -0
- package/resources/messages/sessions.mjs +118 -0
- package/resources/messages/sessions.mjs.map +1 -0
- package/resources/messages.d.mts +2 -0
- package/resources/messages.d.mts.map +1 -0
- package/resources/messages.d.ts +2 -0
- package/resources/messages.d.ts.map +1 -0
- package/resources/messages.js +6 -0
- package/resources/messages.js.map +1 -0
- package/resources/messages.mjs +3 -0
- package/resources/messages.mjs.map +1 -0
- package/resources/omo.d.mts +98 -0
- package/resources/omo.d.mts.map +1 -0
- package/resources/omo.d.ts +98 -0
- package/resources/omo.d.ts.map +1 -0
- package/resources/omo.js +36 -0
- package/resources/omo.js.map +1 -0
- package/resources/omo.mjs +32 -0
- package/resources/omo.mjs.map +1 -0
- package/resources/schemas.d.mts +667 -76
- package/resources/schemas.d.mts.map +1 -1
- package/resources/schemas.d.ts +667 -76
- package/resources/schemas.d.ts.map +1 -1
- package/resources/schemas.js.map +1 -1
- package/resources/schemas.mjs.map +1 -1
- package/resources/shared.d.mts +671 -0
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +671 -0
- package/resources/shared.d.ts.map +1 -1
- package/resources/sync.d.mts +142 -0
- package/resources/sync.d.mts.map +1 -0
- package/resources/sync.d.ts +142 -0
- package/resources/sync.d.ts.map +1 -0
- package/resources/sync.js +36 -0
- package/resources/sync.js.map +1 -0
- package/resources/sync.mjs +32 -0
- package/resources/sync.mjs.map +1 -0
- package/resources/user.d.mts +18 -1
- package/resources/user.d.mts.map +1 -1
- package/resources/user.d.ts +18 -1
- package/resources/user.d.ts.map +1 -1
- package/resources/user.js +11 -0
- package/resources/user.js.map +1 -1
- package/resources/user.mjs +11 -0
- package/resources/user.mjs.map +1 -1
- package/src/client.ts +80 -8
- package/src/internal/parse.ts +6 -0
- package/src/resources/document.ts +17 -4
- package/src/resources/index.ts +21 -0
- package/src/resources/memory.ts +548 -163
- package/src/resources/messages/index.ts +11 -0
- package/src/resources/messages/messages.ts +193 -0
- package/src/resources/messages/sessions.ts +315 -0
- package/src/resources/messages.ts +3 -0
- package/src/resources/omo.ts +132 -0
- package/src/resources/schemas.ts +701 -95
- package/src/resources/shared.ts +752 -0
- package/src/resources/sync.ts +179 -0
- package/src/resources/user.ts +23 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/resources/schemas.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { APIResource } from "../core/resource.js";
|
|
2
|
+
import * as SchemasAPI from "./schemas.js";
|
|
3
|
+
import * as Shared from "./shared.js";
|
|
2
4
|
import { APIPromise } from "../core/api-promise.js";
|
|
3
5
|
import { RequestOptions } from "../internal/request-options.js";
|
|
4
6
|
export declare class Schemas extends APIResource {
|
|
@@ -122,6 +124,113 @@ export declare class Schemas extends APIResource {
|
|
|
122
124
|
*/
|
|
123
125
|
delete(schemaID: string, options?: RequestOptions): APIPromise<unknown>;
|
|
124
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Property definition for nodes/relationships
|
|
129
|
+
*/
|
|
130
|
+
export interface PropertyDefinition {
|
|
131
|
+
type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
|
|
132
|
+
default?: unknown;
|
|
133
|
+
description?: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* List of allowed enum values (max 15)
|
|
136
|
+
*/
|
|
137
|
+
enum_values?: Array<string> | null;
|
|
138
|
+
max_length?: number | null;
|
|
139
|
+
max_value?: number | null;
|
|
140
|
+
min_length?: number | null;
|
|
141
|
+
min_value?: number | null;
|
|
142
|
+
pattern?: string | null;
|
|
143
|
+
required?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Configuration for finding/selecting existing nodes.
|
|
147
|
+
*
|
|
148
|
+
* Defines which properties to match on and how, in priority order. The first
|
|
149
|
+
* matching property wins.
|
|
150
|
+
*
|
|
151
|
+
* **String Shorthand** (simple cases - converts to exact match):
|
|
152
|
+
* SearchConfig(properties=["id", "email"]) # Equivalent to:
|
|
153
|
+
* SearchConfig(properties=[PropertyMatch.exact("id"),
|
|
154
|
+
* PropertyMatch.exact("email")])
|
|
155
|
+
*
|
|
156
|
+
* **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
|
|
157
|
+
* "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
|
|
158
|
+
* control ])
|
|
159
|
+
*
|
|
160
|
+
* **Full Form** (maximum control): SearchConfig(properties=[
|
|
161
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
162
|
+
* mode="semantic", threshold=0.85) ])
|
|
163
|
+
*
|
|
164
|
+
* **To select a specific node by ID**:
|
|
165
|
+
* SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
|
|
166
|
+
*/
|
|
167
|
+
export interface SearchConfigOutput {
|
|
168
|
+
/**
|
|
169
|
+
* Default search mode when property doesn't specify one. 'semantic' (vector
|
|
170
|
+
* similarity), 'exact' (property match), 'fuzzy' (partial match).
|
|
171
|
+
*/
|
|
172
|
+
mode?: 'semantic' | 'exact' | 'fuzzy';
|
|
173
|
+
/**
|
|
174
|
+
* Properties to match on, in priority order (first match wins). Accepts strings
|
|
175
|
+
* (converted to exact match) or PropertyMatch objects. Use PropertyMatch with
|
|
176
|
+
* 'value' field for specific node selection.
|
|
177
|
+
*/
|
|
178
|
+
properties?: Array<SearchConfigOutput.Property> | null;
|
|
179
|
+
/**
|
|
180
|
+
* Default similarity threshold for semantic/fuzzy matching (0.0-1.0). Used when
|
|
181
|
+
* property doesn't specify its own threshold.
|
|
182
|
+
*/
|
|
183
|
+
threshold?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Search for nodes via their relationships. Example: Find tasks assigned to a
|
|
186
|
+
* specific person. Each RelationshipMatch specifies edge_type, target_type, and
|
|
187
|
+
* target_search. Multiple relationship matches are ANDed together.
|
|
188
|
+
*/
|
|
189
|
+
via_relationship?: Array<unknown> | null;
|
|
190
|
+
}
|
|
191
|
+
export declare namespace SearchConfigOutput {
|
|
192
|
+
/**
|
|
193
|
+
* Property matching configuration.
|
|
194
|
+
*
|
|
195
|
+
* Defines which property to match on and how. When listed in search.properties,
|
|
196
|
+
* this property becomes a unique identifier.
|
|
197
|
+
*
|
|
198
|
+
* **Shorthand Helpers** (recommended for common cases):
|
|
199
|
+
* PropertyMatch.exact("id") # Exact match on id PropertyMatch.exact("id",
|
|
200
|
+
* "TASK-123") # Exact match with specific value PropertyMatch.semantic("title") #
|
|
201
|
+
* Semantic match with default threshold PropertyMatch.semantic("title", 0.9) #
|
|
202
|
+
* Semantic match with custom threshold PropertyMatch.semantic("title",
|
|
203
|
+
* value="bug") # Semantic search for "bug" PropertyMatch.fuzzy("name", 0.8) #
|
|
204
|
+
* Fuzzy match
|
|
205
|
+
*
|
|
206
|
+
* **Full Form** (when you need all options): PropertyMatch(name="title",
|
|
207
|
+
* mode="semantic", threshold=0.9, value="auth bug")
|
|
208
|
+
*
|
|
209
|
+
* **String Shorthand** (in SearchConfig.properties): properties=["id", "email"] #
|
|
210
|
+
* Equivalent to [PropertyMatch.exact("id"), PropertyMatch.exact("email")]
|
|
211
|
+
*/
|
|
212
|
+
interface Property {
|
|
213
|
+
/**
|
|
214
|
+
* Property name to match on (e.g., 'id', 'email', 'title')
|
|
215
|
+
*/
|
|
216
|
+
name: string;
|
|
217
|
+
/**
|
|
218
|
+
* Matching mode: 'exact' (string match), 'semantic' (embedding similarity),
|
|
219
|
+
* 'fuzzy' (Levenshtein distance)
|
|
220
|
+
*/
|
|
221
|
+
mode?: 'semantic' | 'exact' | 'fuzzy';
|
|
222
|
+
/**
|
|
223
|
+
* Similarity threshold for semantic/fuzzy modes (0.0-1.0). Ignored for exact mode.
|
|
224
|
+
*/
|
|
225
|
+
threshold?: number;
|
|
226
|
+
/**
|
|
227
|
+
* Runtime value override. If set, use this value for matching instead of
|
|
228
|
+
* extracting from content. Useful for memory-level overrides when you know the
|
|
229
|
+
* exact value to search for.
|
|
230
|
+
*/
|
|
231
|
+
value?: unknown;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
125
234
|
/**
|
|
126
235
|
* Complete user-defined graph schema
|
|
127
236
|
*/
|
|
@@ -131,18 +240,42 @@ export interface UserGraphSchemaOutput {
|
|
|
131
240
|
created_at?: string;
|
|
132
241
|
description?: string | null;
|
|
133
242
|
last_used_at?: string | null;
|
|
243
|
+
/**
|
|
244
|
+
* Default memory policy for memories using this schema. Includes mode ('auto',
|
|
245
|
+
* 'manual'), node_constraints (applied in auto mode when present), and OMO safety
|
|
246
|
+
* settings (consent, risk). Memory-level policies override schema-level.
|
|
247
|
+
*/
|
|
248
|
+
memory_policy?: {
|
|
249
|
+
[key: string]: unknown;
|
|
250
|
+
} | null;
|
|
251
|
+
/**
|
|
252
|
+
* @deprecated DEPRECATED: Use 'namespace_id' instead. Accepts Parse pointer or
|
|
253
|
+
* objectId.
|
|
254
|
+
*/
|
|
134
255
|
namespace?: string | {
|
|
135
256
|
[key: string]: unknown;
|
|
136
257
|
} | null;
|
|
258
|
+
/**
|
|
259
|
+
* Namespace ID this schema belongs to. Accepts legacy 'namespace' alias.
|
|
260
|
+
*/
|
|
261
|
+
namespace_id?: string | null;
|
|
137
262
|
/**
|
|
138
263
|
* Custom node types (max 10 per schema)
|
|
139
264
|
*/
|
|
140
265
|
node_types?: {
|
|
141
266
|
[key: string]: UserGraphSchemaOutput.NodeTypes;
|
|
142
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* @deprecated DEPRECATED: Use 'organization_id' instead. Accepts Parse pointer or
|
|
270
|
+
* objectId.
|
|
271
|
+
*/
|
|
143
272
|
organization?: string | {
|
|
144
273
|
[key: string]: unknown;
|
|
145
274
|
} | null;
|
|
275
|
+
/**
|
|
276
|
+
* Organization ID this schema belongs to. Accepts legacy 'organization' alias.
|
|
277
|
+
*/
|
|
278
|
+
organization_id?: string | null;
|
|
146
279
|
read_access?: Array<string>;
|
|
147
280
|
/**
|
|
148
281
|
* Custom relationship types (max 20 per schema)
|
|
@@ -168,49 +301,229 @@ export interface UserGraphSchemaOutput {
|
|
|
168
301
|
}
|
|
169
302
|
export declare namespace UserGraphSchemaOutput {
|
|
170
303
|
/**
|
|
171
|
-
* User-defined node type
|
|
304
|
+
* User-defined node type with optional inline constraint.
|
|
305
|
+
*
|
|
306
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
307
|
+
* directly within the node type definition. This replaces the need to put
|
|
308
|
+
* constraints only in memory_policy.node_constraints.
|
|
309
|
+
*
|
|
310
|
+
* Schema-level constraints:
|
|
311
|
+
*
|
|
312
|
+
* - `node_type` is implicit (taken from parent UserNodeType.name)
|
|
313
|
+
* - Defines default matching strategy via `search.properties`
|
|
314
|
+
* - Can be overridden per-memory via memory_policy.node_constraints
|
|
315
|
+
*
|
|
316
|
+
* Example: UserNodeType( name="Task", label="Task", properties={ "id":
|
|
317
|
+
* PropertyDefinition(type="string"), "title": PropertyDefinition(type="string",
|
|
318
|
+
* required=True) }, constraint=NodeConstraint( search=SearchConfig(properties=[
|
|
319
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
320
|
+
* mode="semantic", threshold=0.85) ]), create="auto" ) )
|
|
172
321
|
*/
|
|
173
322
|
interface NodeTypes {
|
|
174
323
|
label: string;
|
|
175
324
|
name: string;
|
|
176
325
|
color?: string | null;
|
|
326
|
+
/**
|
|
327
|
+
* Policy for how nodes of a specific type should be handled.
|
|
328
|
+
*
|
|
329
|
+
* Used in two places:
|
|
330
|
+
*
|
|
331
|
+
* 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
|
|
332
|
+
* from parent
|
|
333
|
+
* 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
|
|
334
|
+
* required
|
|
335
|
+
*
|
|
336
|
+
* Node constraints allow developers to control:
|
|
337
|
+
*
|
|
338
|
+
* - Which node types can be created vs. linked
|
|
339
|
+
* - How to find/select existing nodes (via `search`)
|
|
340
|
+
* - What property values to set (exact or auto-extracted)
|
|
341
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
342
|
+
*
|
|
343
|
+
* **The `search` field** handles node selection:
|
|
344
|
+
*
|
|
345
|
+
* - Uses PropertyMatch list to define unique identifiers and matching strategy
|
|
346
|
+
* - Example:
|
|
347
|
+
* `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
|
|
348
|
+
* - For direct selection, use PropertyMatch with value:
|
|
349
|
+
* `{"name": "id", "mode": "exact", "value": "proj_123"}`
|
|
350
|
+
*
|
|
351
|
+
* **The `set` field** controls property values:
|
|
352
|
+
*
|
|
353
|
+
* - Exact value: `{"status": "done"}` - sets exact value
|
|
354
|
+
* - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
|
|
355
|
+
*
|
|
356
|
+
* **The `when` field** supports logical operators:
|
|
357
|
+
*
|
|
358
|
+
* - Simple: `{"priority": "high"}`
|
|
359
|
+
* - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
|
|
360
|
+
* - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
|
|
361
|
+
* - NOT: `{"_not": {"status": "completed"}}`
|
|
362
|
+
* - Complex:
|
|
363
|
+
* `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
|
|
364
|
+
*/
|
|
365
|
+
constraint?: NodeTypes.Constraint | null;
|
|
177
366
|
description?: string | null;
|
|
178
367
|
icon?: string | null;
|
|
368
|
+
/**
|
|
369
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
370
|
+
* with create='lookup'. When True, only links to existing nodes (controlled
|
|
371
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
372
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
373
|
+
*/
|
|
374
|
+
link_only?: boolean;
|
|
179
375
|
/**
|
|
180
376
|
* Node properties (max 10 per node type)
|
|
181
377
|
*/
|
|
182
378
|
properties?: {
|
|
183
|
-
[key: string]:
|
|
379
|
+
[key: string]: SchemasAPI.PropertyDefinition;
|
|
184
380
|
};
|
|
185
381
|
required_properties?: Array<string>;
|
|
186
382
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
383
|
+
* Shorthand for constraint.create. 'upsert': Create if not found (default).
|
|
384
|
+
* 'lookup': Only link to existing nodes (controlled vocabulary). Equivalent to
|
|
385
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
386
|
+
* will set constraint.create accordingly.
|
|
387
|
+
*/
|
|
388
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
389
|
+
/**
|
|
390
|
+
* DEPRECATED: Use 'constraint.search.properties' instead. Properties that uniquely
|
|
391
|
+
* identify this node type. Example: ['name', 'email'] for Customer nodes.
|
|
189
392
|
*/
|
|
190
393
|
unique_identifiers?: Array<string>;
|
|
191
394
|
}
|
|
192
395
|
namespace NodeTypes {
|
|
193
396
|
/**
|
|
194
|
-
*
|
|
397
|
+
* Policy for how nodes of a specific type should be handled.
|
|
398
|
+
*
|
|
399
|
+
* Used in two places:
|
|
400
|
+
*
|
|
401
|
+
* 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
|
|
402
|
+
* from parent
|
|
403
|
+
* 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
|
|
404
|
+
* required
|
|
405
|
+
*
|
|
406
|
+
* Node constraints allow developers to control:
|
|
407
|
+
*
|
|
408
|
+
* - Which node types can be created vs. linked
|
|
409
|
+
* - How to find/select existing nodes (via `search`)
|
|
410
|
+
* - What property values to set (exact or auto-extracted)
|
|
411
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
412
|
+
*
|
|
413
|
+
* **The `search` field** handles node selection:
|
|
414
|
+
*
|
|
415
|
+
* - Uses PropertyMatch list to define unique identifiers and matching strategy
|
|
416
|
+
* - Example:
|
|
417
|
+
* `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
|
|
418
|
+
* - For direct selection, use PropertyMatch with value:
|
|
419
|
+
* `{"name": "id", "mode": "exact", "value": "proj_123"}`
|
|
420
|
+
*
|
|
421
|
+
* **The `set` field** controls property values:
|
|
422
|
+
*
|
|
423
|
+
* - Exact value: `{"status": "done"}` - sets exact value
|
|
424
|
+
* - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
|
|
425
|
+
*
|
|
426
|
+
* **The `when` field** supports logical operators:
|
|
427
|
+
*
|
|
428
|
+
* - Simple: `{"priority": "high"}`
|
|
429
|
+
* - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
|
|
430
|
+
* - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
|
|
431
|
+
* - NOT: `{"_not": {"status": "completed"}}`
|
|
432
|
+
* - Complex:
|
|
433
|
+
* `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
|
|
195
434
|
*/
|
|
196
|
-
interface
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
435
|
+
interface Constraint {
|
|
436
|
+
/**
|
|
437
|
+
* 'upsert': Create if not found via search (default). 'lookup': Only link to
|
|
438
|
+
* existing nodes (controlled vocabulary). Deprecated aliases: 'auto' -> 'upsert',
|
|
439
|
+
* 'never' -> 'lookup'.
|
|
440
|
+
*/
|
|
441
|
+
create?: 'upsert' | 'lookup' | 'auto' | 'never';
|
|
442
|
+
/**
|
|
443
|
+
* DEPRECATED: Use create='lookup' instead. Shorthand for create='lookup'. When
|
|
444
|
+
* True, only links to existing nodes (controlled vocabulary). Equivalent to
|
|
445
|
+
* @lookup decorator in schema definitions.
|
|
446
|
+
*/
|
|
447
|
+
link_only?: boolean;
|
|
448
|
+
/**
|
|
449
|
+
* Node type this constraint applies to (e.g., 'Task', 'Project', 'Person').
|
|
450
|
+
* Optional at schema level (implicit from parent UserNodeType), required at memory
|
|
451
|
+
* level (in memory_policy.node_constraints).
|
|
452
|
+
*/
|
|
453
|
+
node_type?: string | null;
|
|
454
|
+
/**
|
|
455
|
+
* Explicit behavior when no match found via search. 'create': create new node
|
|
456
|
+
* (same as upsert). 'ignore': skip node creation (same as lookup). 'error': raise
|
|
457
|
+
* error if node not found. If specified, overrides 'create' field.
|
|
458
|
+
*/
|
|
459
|
+
on_miss?: 'create' | 'ignore' | 'error' | null;
|
|
460
|
+
/**
|
|
461
|
+
* Configuration for finding/selecting existing nodes.
|
|
462
|
+
*
|
|
463
|
+
* Defines which properties to match on and how, in priority order. The first
|
|
464
|
+
* matching property wins.
|
|
465
|
+
*
|
|
466
|
+
* **String Shorthand** (simple cases - converts to exact match):
|
|
467
|
+
* SearchConfig(properties=["id", "email"]) # Equivalent to:
|
|
468
|
+
* SearchConfig(properties=[PropertyMatch.exact("id"),
|
|
469
|
+
* PropertyMatch.exact("email")])
|
|
470
|
+
*
|
|
471
|
+
* **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
|
|
472
|
+
* "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
|
|
473
|
+
* control ])
|
|
474
|
+
*
|
|
475
|
+
* **Full Form** (maximum control): SearchConfig(properties=[
|
|
476
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
477
|
+
* mode="semantic", threshold=0.85) ])
|
|
478
|
+
*
|
|
479
|
+
* **To select a specific node by ID**:
|
|
480
|
+
* SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
|
|
481
|
+
*/
|
|
482
|
+
search?: SchemasAPI.SearchConfigOutput | null;
|
|
483
|
+
/**
|
|
484
|
+
* Set property values on nodes. Supports: 1. Exact value: {'status': 'done'} -
|
|
485
|
+
* sets exact value. 2. Auto-extract: {'status': {'mode': 'auto'}} - LLM extracts
|
|
486
|
+
* from content. 3. Text mode: {'summary': {'mode': 'auto', 'text_mode':
|
|
487
|
+
* 'merge'}} - controls text updates. For text properties, text_mode can be
|
|
488
|
+
* 'replace', 'append', or 'merge'.
|
|
489
|
+
*/
|
|
490
|
+
set?: {
|
|
491
|
+
[key: string]: string | number | boolean | Array<unknown> | {
|
|
492
|
+
[key: string]: unknown;
|
|
493
|
+
} | Shared.PropertyValue;
|
|
494
|
+
} | null;
|
|
200
495
|
/**
|
|
201
|
-
*
|
|
496
|
+
* Condition for when this constraint applies. Supports logical operators: '\_and',
|
|
497
|
+
* '\_or', '\_not'. Examples: Simple: {'priority': 'high'} - matches when priority
|
|
498
|
+
* equals 'high'. AND: {'\_and': [{'priority': 'high'}, {'status': 'active'}]} -
|
|
499
|
+
* all must match. OR: {'\_or': [{'status': 'active'}, {'status': 'pending'}]} -
|
|
500
|
+
* any must match. NOT: {'\_not': {'status': 'completed'}} - negation. Complex:
|
|
501
|
+
* {'\_and': [{'priority': 'high'}, {'\_or': [{'status': 'active'}, {'urgent':
|
|
502
|
+
* true}]}]}
|
|
202
503
|
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
min_length?: number | null;
|
|
207
|
-
min_value?: number | null;
|
|
208
|
-
pattern?: string | null;
|
|
209
|
-
required?: boolean;
|
|
504
|
+
when?: {
|
|
505
|
+
[key: string]: unknown;
|
|
506
|
+
} | null;
|
|
210
507
|
}
|
|
211
508
|
}
|
|
212
509
|
/**
|
|
213
|
-
* User-defined relationship type
|
|
510
|
+
* User-defined relationship type with optional inline constraint.
|
|
511
|
+
*
|
|
512
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
513
|
+
* directly within the relationship type definition. This mirrors the pattern used
|
|
514
|
+
* in UserNodeType.constraint for nodes.
|
|
515
|
+
*
|
|
516
|
+
* Schema-level edge constraints:
|
|
517
|
+
*
|
|
518
|
+
* - `edge_type` is implicit (taken from parent UserRelationshipType.name)
|
|
519
|
+
* - Defines default target node matching strategy via `search.properties`
|
|
520
|
+
* - Can be overridden per-memory via memory_policy.edge_constraints
|
|
521
|
+
*
|
|
522
|
+
* Example: UserRelationshipType( name="MITIGATES", label="Mitigates",
|
|
523
|
+
* allowed_source_types=["SecurityBehavior"], allowed_target_types=["TacticDef"],
|
|
524
|
+
* constraint=EdgeConstraint( search=SearchConfig(properties=[
|
|
525
|
+
* PropertyMatch(name="name", mode="semantic", threshold=0.90) ]), create="never" #
|
|
526
|
+
* Controlled vocabulary - only link to existing targets ) )
|
|
214
527
|
*/
|
|
215
528
|
interface RelationshipTypes {
|
|
216
529
|
allowed_source_types: Array<string>;
|
|
@@ -219,29 +532,186 @@ export declare namespace UserGraphSchemaOutput {
|
|
|
219
532
|
name: string;
|
|
220
533
|
cardinality?: 'one-to-one' | 'one-to-many' | 'many-to-many';
|
|
221
534
|
color?: string | null;
|
|
535
|
+
/**
|
|
536
|
+
* Policy for how edges/relationships of a specific type should be handled.
|
|
537
|
+
*
|
|
538
|
+
* Used in two places:
|
|
539
|
+
*
|
|
540
|
+
* 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
|
|
541
|
+
* implicit from parent
|
|
542
|
+
* 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
|
|
543
|
+
* required
|
|
544
|
+
*
|
|
545
|
+
* Edge constraints allow developers to control:
|
|
546
|
+
*
|
|
547
|
+
* - Which edge types can be created vs. linked to existing targets
|
|
548
|
+
* - How to find/select target nodes (via `search`)
|
|
549
|
+
* - What edge property values to set (exact or auto-extracted)
|
|
550
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
551
|
+
* - Filter by source/target node types
|
|
552
|
+
*
|
|
553
|
+
* **The `search` field** handles target node selection:
|
|
554
|
+
*
|
|
555
|
+
* - Uses SearchConfig to define how to find existing target nodes
|
|
556
|
+
* - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
|
|
557
|
+
* - For controlled vocabulary: find existing target, don't create new
|
|
558
|
+
*
|
|
559
|
+
* **The `set` field** controls edge property values:
|
|
560
|
+
*
|
|
561
|
+
* - Exact value: `{"weight": 1.0}` - sets exact value
|
|
562
|
+
* - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
|
|
563
|
+
*
|
|
564
|
+
* **The `when` field** supports logical operators (same as NodeConstraint):
|
|
565
|
+
*
|
|
566
|
+
* - Simple: `{"severity": "high"}`
|
|
567
|
+
* - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
|
|
568
|
+
* - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
|
|
569
|
+
* - NOT: `{"_not": {"status": "deprecated"}}`
|
|
570
|
+
*/
|
|
571
|
+
constraint?: RelationshipTypes.Constraint | null;
|
|
222
572
|
description?: string | null;
|
|
573
|
+
/**
|
|
574
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
575
|
+
* with create='lookup'. When True, only links to existing target nodes (controlled
|
|
576
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
577
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
578
|
+
*/
|
|
579
|
+
link_only?: boolean;
|
|
223
580
|
properties?: {
|
|
224
|
-
[key: string]:
|
|
581
|
+
[key: string]: SchemasAPI.PropertyDefinition;
|
|
225
582
|
};
|
|
583
|
+
/**
|
|
584
|
+
* Shorthand for constraint.create. 'upsert': Create target if not found (default).
|
|
585
|
+
* 'lookup': Only link to existing targets (controlled vocabulary). Equivalent to
|
|
586
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
587
|
+
* will set constraint.create accordingly.
|
|
588
|
+
*/
|
|
589
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
226
590
|
}
|
|
227
591
|
namespace RelationshipTypes {
|
|
228
592
|
/**
|
|
229
|
-
*
|
|
593
|
+
* Policy for how edges/relationships of a specific type should be handled.
|
|
594
|
+
*
|
|
595
|
+
* Used in two places:
|
|
596
|
+
*
|
|
597
|
+
* 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
|
|
598
|
+
* implicit from parent
|
|
599
|
+
* 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
|
|
600
|
+
* required
|
|
601
|
+
*
|
|
602
|
+
* Edge constraints allow developers to control:
|
|
603
|
+
*
|
|
604
|
+
* - Which edge types can be created vs. linked to existing targets
|
|
605
|
+
* - How to find/select target nodes (via `search`)
|
|
606
|
+
* - What edge property values to set (exact or auto-extracted)
|
|
607
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
608
|
+
* - Filter by source/target node types
|
|
609
|
+
*
|
|
610
|
+
* **The `search` field** handles target node selection:
|
|
611
|
+
*
|
|
612
|
+
* - Uses SearchConfig to define how to find existing target nodes
|
|
613
|
+
* - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
|
|
614
|
+
* - For controlled vocabulary: find existing target, don't create new
|
|
615
|
+
*
|
|
616
|
+
* **The `set` field** controls edge property values:
|
|
617
|
+
*
|
|
618
|
+
* - Exact value: `{"weight": 1.0}` - sets exact value
|
|
619
|
+
* - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
|
|
620
|
+
*
|
|
621
|
+
* **The `when` field** supports logical operators (same as NodeConstraint):
|
|
622
|
+
*
|
|
623
|
+
* - Simple: `{"severity": "high"}`
|
|
624
|
+
* - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
|
|
625
|
+
* - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
|
|
626
|
+
* - NOT: `{"_not": {"status": "deprecated"}}`
|
|
230
627
|
*/
|
|
231
|
-
interface
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
628
|
+
interface Constraint {
|
|
629
|
+
/**
|
|
630
|
+
* 'upsert': Create target node if not found via search (default). 'lookup': Only
|
|
631
|
+
* link to existing target nodes (controlled vocabulary). When 'lookup', edges to
|
|
632
|
+
* non-existing targets are skipped. Deprecated aliases: 'auto' -> 'upsert',
|
|
633
|
+
* 'never' -> 'lookup'.
|
|
634
|
+
*/
|
|
635
|
+
create?: 'upsert' | 'lookup' | 'auto' | 'never';
|
|
636
|
+
/**
|
|
637
|
+
* Direction of edges this constraint applies to. 'outgoing': edges where current
|
|
638
|
+
* node is source (default). 'incoming': edges where current node is target.
|
|
639
|
+
* 'both': applies in either direction.
|
|
640
|
+
*/
|
|
641
|
+
direction?: 'outgoing' | 'incoming' | 'both';
|
|
642
|
+
/**
|
|
643
|
+
* Edge/relationship type this constraint applies to (e.g., 'MITIGATES',
|
|
644
|
+
* 'ASSIGNED_TO'). Optional at schema level (implicit from parent
|
|
645
|
+
* UserRelationshipType), required at memory level (in
|
|
646
|
+
* memory_policy.edge_constraints).
|
|
647
|
+
*/
|
|
648
|
+
edge_type?: string | null;
|
|
649
|
+
/**
|
|
650
|
+
* DEPRECATED: Use create='lookup' instead. Shorthand for create='lookup'. When
|
|
651
|
+
* True, only links to existing target nodes. Equivalent to @lookup decorator in
|
|
652
|
+
* schema definitions.
|
|
653
|
+
*/
|
|
654
|
+
link_only?: boolean;
|
|
655
|
+
/**
|
|
656
|
+
* Explicit behavior when no target match found via search. 'create': create new
|
|
657
|
+
* target node (same as upsert). 'ignore': skip edge creation (same as lookup).
|
|
658
|
+
* 'error': raise error if target not found. If specified, overrides 'create'
|
|
659
|
+
* field.
|
|
660
|
+
*/
|
|
661
|
+
on_miss?: 'create' | 'ignore' | 'error' | null;
|
|
662
|
+
/**
|
|
663
|
+
* Configuration for finding/selecting existing nodes.
|
|
664
|
+
*
|
|
665
|
+
* Defines which properties to match on and how, in priority order. The first
|
|
666
|
+
* matching property wins.
|
|
667
|
+
*
|
|
668
|
+
* **String Shorthand** (simple cases - converts to exact match):
|
|
669
|
+
* SearchConfig(properties=["id", "email"]) # Equivalent to:
|
|
670
|
+
* SearchConfig(properties=[PropertyMatch.exact("id"),
|
|
671
|
+
* PropertyMatch.exact("email")])
|
|
672
|
+
*
|
|
673
|
+
* **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
|
|
674
|
+
* "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
|
|
675
|
+
* control ])
|
|
676
|
+
*
|
|
677
|
+
* **Full Form** (maximum control): SearchConfig(properties=[
|
|
678
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
679
|
+
* mode="semantic", threshold=0.85) ])
|
|
680
|
+
*
|
|
681
|
+
* **To select a specific node by ID**:
|
|
682
|
+
* SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
|
|
683
|
+
*/
|
|
684
|
+
search?: SchemasAPI.SearchConfigOutput | null;
|
|
685
|
+
/**
|
|
686
|
+
* Set property values on edges. Supports: 1. Exact value: {'weight': 1.0} - sets
|
|
687
|
+
* exact value. 2. Auto-extract: {'reason': {'mode': 'auto'}} - LLM extracts from
|
|
688
|
+
* content. Edge properties are useful for relationship metadata (weight,
|
|
689
|
+
* timestamp, reason, etc.).
|
|
690
|
+
*/
|
|
691
|
+
set?: {
|
|
692
|
+
[key: string]: string | number | boolean | Array<unknown> | {
|
|
693
|
+
[key: string]: unknown;
|
|
694
|
+
} | Shared.PropertyValue;
|
|
695
|
+
} | null;
|
|
696
|
+
/**
|
|
697
|
+
* Filter: only apply when source node is of this type. Example:
|
|
698
|
+
* source_type='SecurityBehavior' - only applies to edges from SecurityBehavior
|
|
699
|
+
* nodes.
|
|
700
|
+
*/
|
|
701
|
+
source_type?: string | null;
|
|
235
702
|
/**
|
|
236
|
-
*
|
|
703
|
+
* Filter: only apply when target node is of this type. Example:
|
|
704
|
+
* target_type='TacticDef' - only applies to edges targeting TacticDef nodes.
|
|
237
705
|
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
706
|
+
target_type?: string | null;
|
|
707
|
+
/**
|
|
708
|
+
* Condition for when this constraint applies. Supports logical operators: '\_and',
|
|
709
|
+
* '\_or', '\_not'. Applied to edge properties or context. Example: {'\_and':
|
|
710
|
+
* [{'severity': 'high'}, {'_not': {'status': 'deprecated'}}]}
|
|
711
|
+
*/
|
|
712
|
+
when?: {
|
|
713
|
+
[key: string]: unknown;
|
|
714
|
+
} | null;
|
|
245
715
|
}
|
|
246
716
|
}
|
|
247
717
|
}
|
|
@@ -298,18 +768,42 @@ export interface SchemaCreateParams {
|
|
|
298
768
|
created_at?: string;
|
|
299
769
|
description?: string | null;
|
|
300
770
|
last_used_at?: string | null;
|
|
771
|
+
/**
|
|
772
|
+
* Default memory policy for memories using this schema. Includes mode ('auto',
|
|
773
|
+
* 'manual'), node_constraints (applied in auto mode when present), and OMO safety
|
|
774
|
+
* settings (consent, risk). Memory-level policies override schema-level.
|
|
775
|
+
*/
|
|
776
|
+
memory_policy?: {
|
|
777
|
+
[key: string]: unknown;
|
|
778
|
+
} | null;
|
|
779
|
+
/**
|
|
780
|
+
* @deprecated DEPRECATED: Use 'namespace_id' instead. Accepts Parse pointer or
|
|
781
|
+
* objectId.
|
|
782
|
+
*/
|
|
301
783
|
namespace?: string | {
|
|
302
784
|
[key: string]: unknown;
|
|
303
785
|
} | null;
|
|
786
|
+
/**
|
|
787
|
+
* Namespace ID this schema belongs to. Accepts legacy 'namespace' alias.
|
|
788
|
+
*/
|
|
789
|
+
namespace_id?: string | null;
|
|
304
790
|
/**
|
|
305
791
|
* Custom node types (max 10 per schema)
|
|
306
792
|
*/
|
|
307
793
|
node_types?: {
|
|
308
794
|
[key: string]: SchemaCreateParams.NodeTypes;
|
|
309
795
|
};
|
|
796
|
+
/**
|
|
797
|
+
* @deprecated DEPRECATED: Use 'organization_id' instead. Accepts Parse pointer or
|
|
798
|
+
* objectId.
|
|
799
|
+
*/
|
|
310
800
|
organization?: string | {
|
|
311
801
|
[key: string]: unknown;
|
|
312
802
|
} | null;
|
|
803
|
+
/**
|
|
804
|
+
* Organization ID this schema belongs to. Accepts legacy 'organization' alias.
|
|
805
|
+
*/
|
|
806
|
+
organization_id?: string | null;
|
|
313
807
|
read_access?: Array<string>;
|
|
314
808
|
/**
|
|
315
809
|
* Custom relationship types (max 20 per schema)
|
|
@@ -335,49 +829,115 @@ export interface SchemaCreateParams {
|
|
|
335
829
|
}
|
|
336
830
|
export declare namespace SchemaCreateParams {
|
|
337
831
|
/**
|
|
338
|
-
* User-defined node type
|
|
832
|
+
* User-defined node type with optional inline constraint.
|
|
833
|
+
*
|
|
834
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
835
|
+
* directly within the node type definition. This replaces the need to put
|
|
836
|
+
* constraints only in memory_policy.node_constraints.
|
|
837
|
+
*
|
|
838
|
+
* Schema-level constraints:
|
|
839
|
+
*
|
|
840
|
+
* - `node_type` is implicit (taken from parent UserNodeType.name)
|
|
841
|
+
* - Defines default matching strategy via `search.properties`
|
|
842
|
+
* - Can be overridden per-memory via memory_policy.node_constraints
|
|
843
|
+
*
|
|
844
|
+
* Example: UserNodeType( name="Task", label="Task", properties={ "id":
|
|
845
|
+
* PropertyDefinition(type="string"), "title": PropertyDefinition(type="string",
|
|
846
|
+
* required=True) }, constraint=NodeConstraint( search=SearchConfig(properties=[
|
|
847
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
848
|
+
* mode="semantic", threshold=0.85) ]), create="auto" ) )
|
|
339
849
|
*/
|
|
340
850
|
interface NodeTypes {
|
|
341
851
|
label: string;
|
|
342
852
|
name: string;
|
|
343
853
|
color?: string | null;
|
|
854
|
+
/**
|
|
855
|
+
* Policy for how nodes of a specific type should be handled.
|
|
856
|
+
*
|
|
857
|
+
* Used in two places:
|
|
858
|
+
*
|
|
859
|
+
* 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
|
|
860
|
+
* from parent
|
|
861
|
+
* 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
|
|
862
|
+
* required
|
|
863
|
+
*
|
|
864
|
+
* Node constraints allow developers to control:
|
|
865
|
+
*
|
|
866
|
+
* - Which node types can be created vs. linked
|
|
867
|
+
* - How to find/select existing nodes (via `search`)
|
|
868
|
+
* - What property values to set (exact or auto-extracted)
|
|
869
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
870
|
+
*
|
|
871
|
+
* **The `search` field** handles node selection:
|
|
872
|
+
*
|
|
873
|
+
* - Uses PropertyMatch list to define unique identifiers and matching strategy
|
|
874
|
+
* - Example:
|
|
875
|
+
* `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
|
|
876
|
+
* - For direct selection, use PropertyMatch with value:
|
|
877
|
+
* `{"name": "id", "mode": "exact", "value": "proj_123"}`
|
|
878
|
+
*
|
|
879
|
+
* **The `set` field** controls property values:
|
|
880
|
+
*
|
|
881
|
+
* - Exact value: `{"status": "done"}` - sets exact value
|
|
882
|
+
* - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
|
|
883
|
+
*
|
|
884
|
+
* **The `when` field** supports logical operators:
|
|
885
|
+
*
|
|
886
|
+
* - Simple: `{"priority": "high"}`
|
|
887
|
+
* - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
|
|
888
|
+
* - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
|
|
889
|
+
* - NOT: `{"_not": {"status": "completed"}}`
|
|
890
|
+
* - Complex:
|
|
891
|
+
* `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
|
|
892
|
+
*/
|
|
893
|
+
constraint?: Shared.NodeConstraintInput | null;
|
|
344
894
|
description?: string | null;
|
|
345
895
|
icon?: string | null;
|
|
896
|
+
/**
|
|
897
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
898
|
+
* with create='lookup'. When True, only links to existing nodes (controlled
|
|
899
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
900
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
901
|
+
*/
|
|
902
|
+
link_only?: boolean;
|
|
346
903
|
/**
|
|
347
904
|
* Node properties (max 10 per node type)
|
|
348
905
|
*/
|
|
349
906
|
properties?: {
|
|
350
|
-
[key: string]:
|
|
907
|
+
[key: string]: SchemasAPI.PropertyDefinition;
|
|
351
908
|
};
|
|
352
909
|
required_properties?: Array<string>;
|
|
353
910
|
/**
|
|
354
|
-
*
|
|
355
|
-
*
|
|
911
|
+
* Shorthand for constraint.create. 'upsert': Create if not found (default).
|
|
912
|
+
* 'lookup': Only link to existing nodes (controlled vocabulary). Equivalent to
|
|
913
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
914
|
+
* will set constraint.create accordingly.
|
|
356
915
|
*/
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
namespace NodeTypes {
|
|
916
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
360
917
|
/**
|
|
361
|
-
*
|
|
918
|
+
* DEPRECATED: Use 'constraint.search.properties' instead. Properties that uniquely
|
|
919
|
+
* identify this node type. Example: ['name', 'email'] for Customer nodes.
|
|
362
920
|
*/
|
|
363
|
-
|
|
364
|
-
type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
|
|
365
|
-
default?: unknown;
|
|
366
|
-
description?: string | null;
|
|
367
|
-
/**
|
|
368
|
-
* List of allowed enum values (max 15)
|
|
369
|
-
*/
|
|
370
|
-
enum_values?: Array<string> | null;
|
|
371
|
-
max_length?: number | null;
|
|
372
|
-
max_value?: number | null;
|
|
373
|
-
min_length?: number | null;
|
|
374
|
-
min_value?: number | null;
|
|
375
|
-
pattern?: string | null;
|
|
376
|
-
required?: boolean;
|
|
377
|
-
}
|
|
921
|
+
unique_identifiers?: Array<string>;
|
|
378
922
|
}
|
|
379
923
|
/**
|
|
380
|
-
* User-defined relationship type
|
|
924
|
+
* User-defined relationship type with optional inline constraint.
|
|
925
|
+
*
|
|
926
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
927
|
+
* directly within the relationship type definition. This mirrors the pattern used
|
|
928
|
+
* in UserNodeType.constraint for nodes.
|
|
929
|
+
*
|
|
930
|
+
* Schema-level edge constraints:
|
|
931
|
+
*
|
|
932
|
+
* - `edge_type` is implicit (taken from parent UserRelationshipType.name)
|
|
933
|
+
* - Defines default target node matching strategy via `search.properties`
|
|
934
|
+
* - Can be overridden per-memory via memory_policy.edge_constraints
|
|
935
|
+
*
|
|
936
|
+
* Example: UserRelationshipType( name="MITIGATES", label="Mitigates",
|
|
937
|
+
* allowed_source_types=["SecurityBehavior"], allowed_target_types=["TacticDef"],
|
|
938
|
+
* constraint=EdgeConstraint( search=SearchConfig(properties=[
|
|
939
|
+
* PropertyMatch(name="name", mode="semantic", threshold=0.90) ]), create="never" #
|
|
940
|
+
* Controlled vocabulary - only link to existing targets ) )
|
|
381
941
|
*/
|
|
382
942
|
interface RelationshipTypes {
|
|
383
943
|
allowed_source_types: Array<string>;
|
|
@@ -386,30 +946,61 @@ export declare namespace SchemaCreateParams {
|
|
|
386
946
|
name: string;
|
|
387
947
|
cardinality?: 'one-to-one' | 'one-to-many' | 'many-to-many';
|
|
388
948
|
color?: string | null;
|
|
949
|
+
/**
|
|
950
|
+
* Policy for how edges/relationships of a specific type should be handled.
|
|
951
|
+
*
|
|
952
|
+
* Used in two places:
|
|
953
|
+
*
|
|
954
|
+
* 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
|
|
955
|
+
* implicit from parent
|
|
956
|
+
* 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
|
|
957
|
+
* required
|
|
958
|
+
*
|
|
959
|
+
* Edge constraints allow developers to control:
|
|
960
|
+
*
|
|
961
|
+
* - Which edge types can be created vs. linked to existing targets
|
|
962
|
+
* - How to find/select target nodes (via `search`)
|
|
963
|
+
* - What edge property values to set (exact or auto-extracted)
|
|
964
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
965
|
+
* - Filter by source/target node types
|
|
966
|
+
*
|
|
967
|
+
* **The `search` field** handles target node selection:
|
|
968
|
+
*
|
|
969
|
+
* - Uses SearchConfig to define how to find existing target nodes
|
|
970
|
+
* - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
|
|
971
|
+
* - For controlled vocabulary: find existing target, don't create new
|
|
972
|
+
*
|
|
973
|
+
* **The `set` field** controls edge property values:
|
|
974
|
+
*
|
|
975
|
+
* - Exact value: `{"weight": 1.0}` - sets exact value
|
|
976
|
+
* - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
|
|
977
|
+
*
|
|
978
|
+
* **The `when` field** supports logical operators (same as NodeConstraint):
|
|
979
|
+
*
|
|
980
|
+
* - Simple: `{"severity": "high"}`
|
|
981
|
+
* - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
|
|
982
|
+
* - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
|
|
983
|
+
* - NOT: `{"_not": {"status": "deprecated"}}`
|
|
984
|
+
*/
|
|
985
|
+
constraint?: Shared.EdgeConstraintInput | null;
|
|
389
986
|
description?: string | null;
|
|
987
|
+
/**
|
|
988
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
989
|
+
* with create='lookup'. When True, only links to existing target nodes (controlled
|
|
990
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
991
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
992
|
+
*/
|
|
993
|
+
link_only?: boolean;
|
|
390
994
|
properties?: {
|
|
391
|
-
[key: string]:
|
|
995
|
+
[key: string]: SchemasAPI.PropertyDefinition;
|
|
392
996
|
};
|
|
393
|
-
}
|
|
394
|
-
namespace RelationshipTypes {
|
|
395
997
|
/**
|
|
396
|
-
*
|
|
998
|
+
* Shorthand for constraint.create. 'upsert': Create target if not found (default).
|
|
999
|
+
* 'lookup': Only link to existing targets (controlled vocabulary). Equivalent to
|
|
1000
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
1001
|
+
* will set constraint.create accordingly.
|
|
397
1002
|
*/
|
|
398
|
-
|
|
399
|
-
type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
|
|
400
|
-
default?: unknown;
|
|
401
|
-
description?: string | null;
|
|
402
|
-
/**
|
|
403
|
-
* List of allowed enum values (max 15)
|
|
404
|
-
*/
|
|
405
|
-
enum_values?: Array<string> | null;
|
|
406
|
-
max_length?: number | null;
|
|
407
|
-
max_value?: number | null;
|
|
408
|
-
min_length?: number | null;
|
|
409
|
-
min_value?: number | null;
|
|
410
|
-
pattern?: string | null;
|
|
411
|
-
required?: boolean;
|
|
412
|
-
}
|
|
1003
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
413
1004
|
}
|
|
414
1005
|
}
|
|
415
1006
|
export interface SchemaUpdateParams {
|
|
@@ -428,6 +1019,6 @@ export interface SchemaListParams {
|
|
|
428
1019
|
workspace_id?: string | null;
|
|
429
1020
|
}
|
|
430
1021
|
export declare namespace Schemas {
|
|
431
|
-
export { type UserGraphSchemaOutput as UserGraphSchemaOutput, type SchemaCreateResponse as SchemaCreateResponse, type SchemaRetrieveResponse as SchemaRetrieveResponse, type SchemaUpdateResponse as SchemaUpdateResponse, type SchemaListResponse as SchemaListResponse, type SchemaDeleteResponse as SchemaDeleteResponse, type SchemaCreateParams as SchemaCreateParams, type SchemaUpdateParams as SchemaUpdateParams, type SchemaListParams as SchemaListParams, };
|
|
1022
|
+
export { type PropertyDefinition as PropertyDefinition, type SearchConfigOutput as SearchConfigOutput, type UserGraphSchemaOutput as UserGraphSchemaOutput, type SchemaCreateResponse as SchemaCreateResponse, type SchemaRetrieveResponse as SchemaRetrieveResponse, type SchemaUpdateResponse as SchemaUpdateResponse, type SchemaListResponse as SchemaListResponse, type SchemaDeleteResponse as SchemaDeleteResponse, type SchemaCreateParams as SchemaCreateParams, type SchemaUpdateParams as SchemaUpdateParams, type SchemaListParams as SchemaListParams, };
|
|
432
1023
|
}
|
|
433
1024
|
//# sourceMappingURL=schemas.d.ts.map
|