@geoprotocol/grc-20 0.1.7 → 0.2.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/dist/builder/entity.d.ts +12 -6
- package/dist/builder/entity.d.ts.map +1 -1
- package/dist/builder/entity.js +15 -9
- package/dist/builder/entity.js.map +1 -1
- package/dist/builder/update.d.ts +12 -6
- package/dist/builder/update.d.ts.map +1 -1
- package/dist/builder/update.js +15 -9
- package/dist/builder/update.js.map +1 -1
- package/dist/codec/edit.d.ts.map +1 -1
- package/dist/codec/edit.js +153 -9
- package/dist/codec/edit.js.map +1 -1
- package/dist/codec/op.d.ts +8 -1
- package/dist/codec/op.d.ts.map +1 -1
- package/dist/codec/op.js +58 -2
- package/dist/codec/op.js.map +1 -1
- package/dist/codec/primitives.d.ts +33 -0
- package/dist/codec/primitives.d.ts.map +1 -1
- package/dist/codec/primitives.js +82 -0
- package/dist/codec/primitives.js.map +1 -1
- package/dist/codec/value.d.ts.map +1 -1
- package/dist/codec/value.js +48 -47
- package/dist/codec/value.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/test/basic.test.js +2 -322
- package/dist/test/basic.test.js.map +1 -1
- package/dist/types/edit.d.ts +28 -0
- package/dist/types/edit.d.ts.map +1 -1
- package/dist/types/edit.js +2 -0
- package/dist/types/edit.js.map +1 -1
- package/dist/types/op.d.ts +9 -0
- package/dist/types/op.d.ts.map +1 -1
- package/dist/types/op.js.map +1 -1
- package/dist/types/value.d.ts +15 -3
- package/dist/types/value.d.ts.map +1 -1
- package/dist/types/value.js +18 -0
- package/dist/types/value.js.map +1 -1
- package/package.json +1 -3
- package/readme.md +12 -100
- package/dist/ops/index.d.ts +0 -213
- package/dist/ops/index.d.ts.map +0 -1
- package/dist/ops/index.js +0 -203
- package/dist/ops/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|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G;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,CA2BpD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,EAAE,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,EAAE,CAAC;IACP,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CA0E9D"}
|
package/dist/types/value.js
CHANGED
|
@@ -112,6 +112,24 @@ export function validateValue(value) {
|
|
|
112
112
|
return "NaN is not allowed in Point altitude";
|
|
113
113
|
}
|
|
114
114
|
break;
|
|
115
|
+
case "date":
|
|
116
|
+
if (value.offsetMin < -1440 || value.offsetMin > 1440) {
|
|
117
|
+
return "DATE offsetMin outside range [-1440, +1440]";
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case "time":
|
|
121
|
+
if (value.timeUs < 0n || value.timeUs > 86399999999n) {
|
|
122
|
+
return "TIME timeUs outside range [0, 86399999999]";
|
|
123
|
+
}
|
|
124
|
+
if (value.offsetMin < -1440 || value.offsetMin > 1440) {
|
|
125
|
+
return "TIME offsetMin outside range [-1440, +1440]";
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case "datetime":
|
|
129
|
+
if (value.offsetMin < -1440 || value.offsetMin > 1440) {
|
|
130
|
+
return "DATETIME offsetMin outside range [-1440, +1440]";
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
115
133
|
case "embedding": {
|
|
116
134
|
const expected = embeddingBytesForDims(value.subType, value.dims);
|
|
117
135
|
if (value.data.length !== expected) {
|
package/dist/types/value.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../src/types/value.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MA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C,OAAO,yBAAyB,KAAK,CAAC,IAAI,CAAC,MAAM,2BAA2B,QAAQ,QAAQ,KAAK,CAAC,IAAI,OAAO,CAAC;YAChH,CAAC;YACD,sCAAsC;YACtC,IAAI,KAAK,CAAC,OAAO,KAAK,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAC/C,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC3F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;oBACpC,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;oBACvC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;wBACpB,OAAO,yCAAyC,CAAC;oBACnD,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoprotocol/grc-20",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "GRC-20 TypeScript library for binary property graph encoding/decoding",
|
|
5
|
-
"private": false,
|
|
6
|
-
"publishConfig": { "access": "public" },
|
|
7
5
|
"type": "module",
|
|
8
6
|
"main": "./dist/index.js",
|
|
9
7
|
"types": "./dist/index.d.ts",
|
package/readme.md
CHANGED
|
@@ -100,7 +100,6 @@ import {
|
|
|
100
100
|
EntityBuilder, // Build entity values
|
|
101
101
|
UpdateEntityBuilder, // Build update operations
|
|
102
102
|
RelationBuilder, // Build relation operations
|
|
103
|
-
UpdateRelationBuilder,// Build relation update operations
|
|
104
103
|
} from "@geoprotocol/grc-20";
|
|
105
104
|
```
|
|
106
105
|
|
|
@@ -115,19 +114,16 @@ const edit = new EditBuilder(editId)
|
|
|
115
114
|
.text(propId, "value", languageId)
|
|
116
115
|
.int64(propId, 42n, unitId)
|
|
117
116
|
.float64(propId, 3.14, undefined)
|
|
118
|
-
.decimal(propId, { exponent: -2, mantissa: 1234n }, undefined)
|
|
119
117
|
.bool(propId, true)
|
|
120
118
|
.bytes(propId, new Uint8Array([1, 2, 3]))
|
|
121
119
|
.point(propId, 40.7128, -74.006)
|
|
122
|
-
.date(propId,
|
|
123
|
-
.time(propId,
|
|
124
|
-
.datetime(propId,
|
|
120
|
+
.date(propId, 19738, 0) // days since epoch, offset in minutes
|
|
121
|
+
.time(propId, 37800000000n, 0) // microseconds since midnight, offset
|
|
122
|
+
.datetime(propId, 1705312200000000n, 0) // microseconds since epoch, offset
|
|
125
123
|
)
|
|
126
124
|
.updateEntity(entityId, u => u
|
|
127
125
|
.setText(propId, "new value", undefined)
|
|
128
|
-
.
|
|
129
|
-
.unsetText(propId, languageId) // Unset specific language
|
|
130
|
-
.unsetAll(propId) // Unset all values for property
|
|
126
|
+
.unsetAll(propId)
|
|
131
127
|
)
|
|
132
128
|
.deleteEntity(entityId)
|
|
133
129
|
.restoreEntity(entityId)
|
|
@@ -138,54 +134,9 @@ const edit = new EditBuilder(editId)
|
|
|
138
134
|
.relationType(relationTypeId)
|
|
139
135
|
)
|
|
140
136
|
.deleteRelation(relationId)
|
|
141
|
-
.restoreRelation(relationId)
|
|
142
|
-
.createValueRef(valueRefId, entityId, propId, {
|
|
143
|
-
type: "text",
|
|
144
|
-
value: "Referenceable value"
|
|
145
|
-
})
|
|
146
137
|
.build();
|
|
147
138
|
```
|
|
148
139
|
|
|
149
|
-
### Ops (Functional API)
|
|
150
|
-
|
|
151
|
-
`createEdit` defaults `id` to `randomId()` and `createdAt` to `0n` when omitted.
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
import {
|
|
155
|
-
createEdit,
|
|
156
|
-
createEntity,
|
|
157
|
-
createRelation,
|
|
158
|
-
randomId,
|
|
159
|
-
properties,
|
|
160
|
-
relationTypes,
|
|
161
|
-
} from "@geoprotocol/grc-20";
|
|
162
|
-
|
|
163
|
-
const entityId = randomId();
|
|
164
|
-
const authorId = randomId();
|
|
165
|
-
|
|
166
|
-
const ops = [
|
|
167
|
-
createEntity({
|
|
168
|
-
id: entityId,
|
|
169
|
-
values: [
|
|
170
|
-
{ property: properties.name(), value: { type: "text", value: "Alice" } },
|
|
171
|
-
{ property: properties.description(), value: { type: "text", value: "A person" } },
|
|
172
|
-
],
|
|
173
|
-
}),
|
|
174
|
-
createRelation({
|
|
175
|
-
id: randomId(),
|
|
176
|
-
relationType: relationTypes.types(),
|
|
177
|
-
from: entityId,
|
|
178
|
-
to: randomId(),
|
|
179
|
-
}),
|
|
180
|
-
];
|
|
181
|
-
|
|
182
|
-
const edit = createEdit({
|
|
183
|
-
name: "Create Alice",
|
|
184
|
-
author: authorId,
|
|
185
|
-
ops,
|
|
186
|
-
});
|
|
187
|
-
```
|
|
188
|
-
|
|
189
140
|
### Codec
|
|
190
141
|
|
|
191
142
|
```typescript
|
|
@@ -254,57 +205,18 @@ If using native ES modules without a bundler, add an import map for the WASM dep
|
|
|
254
205
|
|
|
255
206
|
```typescript
|
|
256
207
|
import {
|
|
257
|
-
randomId,
|
|
258
|
-
parseId,
|
|
259
|
-
formatId,
|
|
260
|
-
derivedUuid,
|
|
261
|
-
derivedUuidAsync, // Derive UUIDv8 from bytes (SHA-256, async)
|
|
208
|
+
randomId, // Generate random UUIDv4
|
|
209
|
+
parseId, // Parse hex string to Id
|
|
210
|
+
formatId, // Format Id as hex string
|
|
211
|
+
derivedUuid, // Derive UUIDv8 from bytes (SHA-256)
|
|
262
212
|
derivedUuidFromString,
|
|
263
|
-
uniqueRelationId,
|
|
264
|
-
relationEntityId,
|
|
265
|
-
idsEqual,
|
|
266
|
-
|
|
267
|
-
NIL_ID, // Zero UUID
|
|
213
|
+
uniqueRelationId, // Derive relation ID from endpoints
|
|
214
|
+
relationEntityId, // Derive entity ID from relation ID
|
|
215
|
+
idsEqual, // Compare two Ids
|
|
216
|
+
NIL_ID, // Zero UUID
|
|
268
217
|
} from "@geoprotocol/grc-20";
|
|
269
218
|
```
|
|
270
219
|
|
|
271
|
-
### Validation
|
|
272
|
-
|
|
273
|
-
Validate values and positions before encoding:
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
import { validateValue, validatePosition } from "@geoprotocol/grc-20";
|
|
277
|
-
|
|
278
|
-
// Validate a value matches its declared type
|
|
279
|
-
const result = validateValue(value, DataType.Text);
|
|
280
|
-
if (!result.valid) {
|
|
281
|
-
console.error(result.error);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Validate position string format
|
|
285
|
-
const posResult = validatePosition("a0");
|
|
286
|
-
if (!posResult.valid) {
|
|
287
|
-
console.error(posResult.error);
|
|
288
|
-
}
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Data Types Reference
|
|
292
|
-
|
|
293
|
-
| Type | TypeScript Representation |
|
|
294
|
-
|------|---------------------------|
|
|
295
|
-
| `BOOL` | `{ type: "bool", value: boolean }` |
|
|
296
|
-
| `INT64` | `{ type: "int64", value: bigint, unit?: Id }` |
|
|
297
|
-
| `FLOAT64` | `{ type: "float64", value: number, unit?: Id }` |
|
|
298
|
-
| `DECIMAL` | `{ type: "decimal", exponent: number, mantissa: bigint, unit?: Id }` |
|
|
299
|
-
| `TEXT` | `{ type: "text", value: string, language?: Id }` |
|
|
300
|
-
| `BYTES` | `{ type: "bytes", value: Uint8Array }` |
|
|
301
|
-
| `DATE` | `{ type: "date", value: string }` (ISO 8601) |
|
|
302
|
-
| `TIME` | `{ type: "time", value: string }` (HH:MM:SS) |
|
|
303
|
-
| `DATETIME` | `{ type: "datetime", value: string }` (ISO 8601) |
|
|
304
|
-
| `SCHEDULE` | `{ type: "schedule", value: string }` (cron-like) |
|
|
305
|
-
| `POINT` | `{ type: "point", lat: number, lon: number }` |
|
|
306
|
-
| `EMBEDDING` | `{ type: "embedding", subType: EmbeddingSubType.Float32 \| EmbeddingSubType.Int8 \| EmbeddingSubType.Binary, data: number[] }` |
|
|
307
|
-
|
|
308
220
|
### Genesis IDs
|
|
309
221
|
|
|
310
222
|
Well-known IDs from the Genesis Space:
|
package/dist/ops/index.d.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import type { Id } from "../types/id.js";
|
|
2
|
-
import type { Edit } from "../types/edit.js";
|
|
3
|
-
import type { CreateEntity, CreateRelation, CreateValueRef, DeleteEntity, DeleteRelation, Op, RestoreEntity, RestoreRelation, UnsetRelationField, UnsetValue, UpdateEntity, UpdateRelation } from "../types/op.js";
|
|
4
|
-
import type { PropertyValue } from "../types/value.js";
|
|
5
|
-
/**
|
|
6
|
-
* Input for creating an Edit.
|
|
7
|
-
*/
|
|
8
|
-
export interface CreateEditInput {
|
|
9
|
-
/** The edit ID. If omitted, a random ID is generated. */
|
|
10
|
-
id?: Id;
|
|
11
|
-
/** Human-readable name for the edit. */
|
|
12
|
-
name?: string;
|
|
13
|
-
/** Single author ID (convenience for single-author edits). */
|
|
14
|
-
author?: Id;
|
|
15
|
-
/** Multiple author IDs. Takes precedence over `author` if both provided. */
|
|
16
|
-
authors?: Id[];
|
|
17
|
-
/** Creation timestamp in microseconds since Unix epoch. */
|
|
18
|
-
createdAt?: bigint;
|
|
19
|
-
/** Operations to include in the edit. */
|
|
20
|
-
ops?: Op[];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Creates an Edit from the given input.
|
|
24
|
-
*
|
|
25
|
-
* This is the functional API equivalent to using {@link EditBuilder}.
|
|
26
|
-
*
|
|
27
|
-
* @param input - The edit configuration
|
|
28
|
-
* @returns A new Edit object
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const edit = createEdit({
|
|
33
|
-
* id: myEditId,
|
|
34
|
-
* name: "Add new entity",
|
|
35
|
-
* author: authorId,
|
|
36
|
-
* ops: [createEntity({ id: entityId, values: [...] })],
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare function createEdit(input: CreateEditInput): Edit;
|
|
41
|
-
/**
|
|
42
|
-
* Input for creating a CreateEntity operation.
|
|
43
|
-
*/
|
|
44
|
-
export interface CreateEntityInput {
|
|
45
|
-
/** The entity ID. */
|
|
46
|
-
id: Id;
|
|
47
|
-
/** Property values to set on the entity. */
|
|
48
|
-
values?: PropertyValue[];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Creates a CreateEntity operation.
|
|
52
|
-
*
|
|
53
|
-
* If the entity does not exist, it will be created. If it already exists,
|
|
54
|
-
* this acts as an update: values are applied as set_properties (LWW).
|
|
55
|
-
*
|
|
56
|
-
* @param input - The entity configuration
|
|
57
|
-
* @returns A CreateEntity operation
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* const op = createEntity({
|
|
62
|
-
* id: entityId,
|
|
63
|
-
* values: [
|
|
64
|
-
* { property: properties.name(), value: { type: "text", value: "Alice" } },
|
|
65
|
-
* ],
|
|
66
|
-
* });
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export declare function createEntity(input: CreateEntityInput): CreateEntity;
|
|
70
|
-
/**
|
|
71
|
-
* Input for creating an UpdateEntity operation.
|
|
72
|
-
*/
|
|
73
|
-
export interface UpdateEntityInput {
|
|
74
|
-
/** The entity ID to update. */
|
|
75
|
-
id: Id;
|
|
76
|
-
/** Property values to set (last-writer-wins). */
|
|
77
|
-
set?: PropertyValue[];
|
|
78
|
-
/** Property values to unset/clear. */
|
|
79
|
-
unset?: UnsetValue[];
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Creates an UpdateEntity operation.
|
|
83
|
-
*
|
|
84
|
-
* Updates an existing entity by setting and/or unsetting property values.
|
|
85
|
-
* Set operations use last-writer-wins (LWW) semantics.
|
|
86
|
-
*
|
|
87
|
-
* @param input - The update configuration
|
|
88
|
-
* @returns An UpdateEntity operation
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* const op = updateEntity({
|
|
93
|
-
* id: entityId,
|
|
94
|
-
* set: [{ property: propId, value: { type: "text", value: "New value" } }],
|
|
95
|
-
* unset: [{ property: oldPropId, language: { type: "all" } }],
|
|
96
|
-
* });
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export declare function updateEntity(input: UpdateEntityInput): UpdateEntity;
|
|
100
|
-
/**
|
|
101
|
-
* Creates a DeleteEntity operation.
|
|
102
|
-
*
|
|
103
|
-
* Transitions the entity to DELETED state. The entity can be restored
|
|
104
|
-
* using {@link restoreEntity}.
|
|
105
|
-
*
|
|
106
|
-
* @param id - The entity ID to delete
|
|
107
|
-
* @returns A DeleteEntity operation
|
|
108
|
-
*/
|
|
109
|
-
export declare function deleteEntity(id: Id): DeleteEntity;
|
|
110
|
-
/**
|
|
111
|
-
* Creates a RestoreEntity operation.
|
|
112
|
-
*
|
|
113
|
-
* Transitions a deleted entity back to ALIVE state.
|
|
114
|
-
*
|
|
115
|
-
* @param id - The entity ID to restore
|
|
116
|
-
* @returns A RestoreEntity operation
|
|
117
|
-
*/
|
|
118
|
-
export declare function restoreEntity(id: Id): RestoreEntity;
|
|
119
|
-
/**
|
|
120
|
-
* Input for creating a CreateRelation operation.
|
|
121
|
-
* Includes all fields from CreateRelation except the `type` discriminator.
|
|
122
|
-
*/
|
|
123
|
-
export type CreateRelationInput = Omit<CreateRelation, "type">;
|
|
124
|
-
/**
|
|
125
|
-
* Creates a CreateRelation operation.
|
|
126
|
-
*
|
|
127
|
-
* Creates a directed relation between two entities with a specified type.
|
|
128
|
-
* Relations can optionally have a position for ordering and reference
|
|
129
|
-
* entities in other spaces/versions.
|
|
130
|
-
*
|
|
131
|
-
* @param input - The relation configuration
|
|
132
|
-
* @returns A CreateRelation operation
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ```ts
|
|
136
|
-
* const op = createRelation({
|
|
137
|
-
* id: relationId,
|
|
138
|
-
* relationType: relationTypes.types(),
|
|
139
|
-
* from: entityA,
|
|
140
|
-
* to: entityB,
|
|
141
|
-
* });
|
|
142
|
-
* ```
|
|
143
|
-
*/
|
|
144
|
-
export declare function createRelation(input: CreateRelationInput): CreateRelation;
|
|
145
|
-
/**
|
|
146
|
-
* Input for creating an UpdateRelation operation.
|
|
147
|
-
*/
|
|
148
|
-
export interface UpdateRelationInput extends Omit<UpdateRelation, "type" | "unset"> {
|
|
149
|
-
/** Fields to unset on the relation. */
|
|
150
|
-
unset?: UnsetRelationField[];
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Creates an UpdateRelation operation.
|
|
154
|
-
*
|
|
155
|
-
* Updates an existing relation's position or cross-space references.
|
|
156
|
-
* Can also unset optional fields like position or space/version references.
|
|
157
|
-
*
|
|
158
|
-
* @param input - The update configuration
|
|
159
|
-
* @returns An UpdateRelation operation
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```ts
|
|
163
|
-
* const op = updateRelation({
|
|
164
|
-
* id: relationId,
|
|
165
|
-
* position: "abc",
|
|
166
|
-
* });
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
export declare function updateRelation(input: UpdateRelationInput): UpdateRelation;
|
|
170
|
-
/**
|
|
171
|
-
* Creates a DeleteRelation operation.
|
|
172
|
-
*
|
|
173
|
-
* Transitions the relation to DELETED state. The relation can be restored
|
|
174
|
-
* using {@link restoreRelation}.
|
|
175
|
-
*
|
|
176
|
-
* @param id - The relation ID to delete
|
|
177
|
-
* @returns A DeleteRelation operation
|
|
178
|
-
*/
|
|
179
|
-
export declare function deleteRelation(id: Id): DeleteRelation;
|
|
180
|
-
/**
|
|
181
|
-
* Creates a RestoreRelation operation.
|
|
182
|
-
*
|
|
183
|
-
* Transitions a deleted relation back to ALIVE state.
|
|
184
|
-
*
|
|
185
|
-
* @param id - The relation ID to restore
|
|
186
|
-
* @returns A RestoreRelation operation
|
|
187
|
-
*/
|
|
188
|
-
export declare function restoreRelation(id: Id): RestoreRelation;
|
|
189
|
-
/**
|
|
190
|
-
* Input for creating a CreateValueRef operation.
|
|
191
|
-
* Includes all fields from CreateValueRef except the `type` discriminator.
|
|
192
|
-
*/
|
|
193
|
-
export type CreateValueRefInput = Omit<CreateValueRef, "type">;
|
|
194
|
-
/**
|
|
195
|
-
* Creates a CreateValueRef operation.
|
|
196
|
-
*
|
|
197
|
-
* Creates a reference to a value on another entity, optionally in another space.
|
|
198
|
-
* This allows sharing values across entities without duplication.
|
|
199
|
-
*
|
|
200
|
-
* @param input - The value reference configuration
|
|
201
|
-
* @returns A CreateValueRef operation
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* ```ts
|
|
205
|
-
* const op = createValueRef({
|
|
206
|
-
* id: refId,
|
|
207
|
-
* entity: sourceEntityId,
|
|
208
|
-
* property: properties.name(),
|
|
209
|
-
* });
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
export declare function createValueRef(input: CreateValueRefInput): CreateValueRef;
|
|
213
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/ops/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,EAAE,EACF,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,cAAc,EACf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D;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAKzE;AAED;;GAEG;AACH,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9C,uCAAuC;IACvC,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAOzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,GAAG,cAAc,CAErD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,CAEvD;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAKzE"}
|
package/dist/ops/index.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { randomId } from "../util/id.js";
|
|
2
|
-
/**
|
|
3
|
-
* Creates an Edit from the given input.
|
|
4
|
-
*
|
|
5
|
-
* This is the functional API equivalent to using {@link EditBuilder}.
|
|
6
|
-
*
|
|
7
|
-
* @param input - The edit configuration
|
|
8
|
-
* @returns A new Edit object
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const edit = createEdit({
|
|
13
|
-
* id: myEditId,
|
|
14
|
-
* name: "Add new entity",
|
|
15
|
-
* author: authorId,
|
|
16
|
-
* ops: [createEntity({ id: entityId, values: [...] })],
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export function createEdit(input) {
|
|
21
|
-
const authors = input.authors ? [...input.authors] : input.author ? [input.author] : [];
|
|
22
|
-
return {
|
|
23
|
-
id: input.id ?? randomId(),
|
|
24
|
-
name: input.name ?? "",
|
|
25
|
-
authors,
|
|
26
|
-
createdAt: input.createdAt ?? 0n,
|
|
27
|
-
ops: input.ops ? [...input.ops] : [],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Creates a CreateEntity operation.
|
|
32
|
-
*
|
|
33
|
-
* If the entity does not exist, it will be created. If it already exists,
|
|
34
|
-
* this acts as an update: values are applied as set_properties (LWW).
|
|
35
|
-
*
|
|
36
|
-
* @param input - The entity configuration
|
|
37
|
-
* @returns A CreateEntity operation
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* const op = createEntity({
|
|
42
|
-
* id: entityId,
|
|
43
|
-
* values: [
|
|
44
|
-
* { property: properties.name(), value: { type: "text", value: "Alice" } },
|
|
45
|
-
* ],
|
|
46
|
-
* });
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export function createEntity(input) {
|
|
50
|
-
return {
|
|
51
|
-
type: "createEntity",
|
|
52
|
-
id: input.id,
|
|
53
|
-
values: input.values ?? [],
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Creates an UpdateEntity operation.
|
|
58
|
-
*
|
|
59
|
-
* Updates an existing entity by setting and/or unsetting property values.
|
|
60
|
-
* Set operations use last-writer-wins (LWW) semantics.
|
|
61
|
-
*
|
|
62
|
-
* @param input - The update configuration
|
|
63
|
-
* @returns An UpdateEntity operation
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* const op = updateEntity({
|
|
68
|
-
* id: entityId,
|
|
69
|
-
* set: [{ property: propId, value: { type: "text", value: "New value" } }],
|
|
70
|
-
* unset: [{ property: oldPropId, language: { type: "all" } }],
|
|
71
|
-
* });
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export function updateEntity(input) {
|
|
75
|
-
return {
|
|
76
|
-
type: "updateEntity",
|
|
77
|
-
id: input.id,
|
|
78
|
-
set: input.set ?? [],
|
|
79
|
-
unset: input.unset ?? [],
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Creates a DeleteEntity operation.
|
|
84
|
-
*
|
|
85
|
-
* Transitions the entity to DELETED state. The entity can be restored
|
|
86
|
-
* using {@link restoreEntity}.
|
|
87
|
-
*
|
|
88
|
-
* @param id - The entity ID to delete
|
|
89
|
-
* @returns A DeleteEntity operation
|
|
90
|
-
*/
|
|
91
|
-
export function deleteEntity(id) {
|
|
92
|
-
return { type: "deleteEntity", id };
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Creates a RestoreEntity operation.
|
|
96
|
-
*
|
|
97
|
-
* Transitions a deleted entity back to ALIVE state.
|
|
98
|
-
*
|
|
99
|
-
* @param id - The entity ID to restore
|
|
100
|
-
* @returns A RestoreEntity operation
|
|
101
|
-
*/
|
|
102
|
-
export function restoreEntity(id) {
|
|
103
|
-
return { type: "restoreEntity", id };
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Creates a CreateRelation operation.
|
|
107
|
-
*
|
|
108
|
-
* Creates a directed relation between two entities with a specified type.
|
|
109
|
-
* Relations can optionally have a position for ordering and reference
|
|
110
|
-
* entities in other spaces/versions.
|
|
111
|
-
*
|
|
112
|
-
* @param input - The relation configuration
|
|
113
|
-
* @returns A CreateRelation operation
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```ts
|
|
117
|
-
* const op = createRelation({
|
|
118
|
-
* id: relationId,
|
|
119
|
-
* relationType: relationTypes.types(),
|
|
120
|
-
* from: entityA,
|
|
121
|
-
* to: entityB,
|
|
122
|
-
* });
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
export function createRelation(input) {
|
|
126
|
-
return {
|
|
127
|
-
type: "createRelation",
|
|
128
|
-
...input,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Creates an UpdateRelation operation.
|
|
133
|
-
*
|
|
134
|
-
* Updates an existing relation's position or cross-space references.
|
|
135
|
-
* Can also unset optional fields like position or space/version references.
|
|
136
|
-
*
|
|
137
|
-
* @param input - The update configuration
|
|
138
|
-
* @returns An UpdateRelation operation
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```ts
|
|
142
|
-
* const op = updateRelation({
|
|
143
|
-
* id: relationId,
|
|
144
|
-
* position: "abc",
|
|
145
|
-
* });
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
export function updateRelation(input) {
|
|
149
|
-
const { unset, ...rest } = input;
|
|
150
|
-
return {
|
|
151
|
-
type: "updateRelation",
|
|
152
|
-
unset: unset ?? [],
|
|
153
|
-
...rest,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Creates a DeleteRelation operation.
|
|
158
|
-
*
|
|
159
|
-
* Transitions the relation to DELETED state. The relation can be restored
|
|
160
|
-
* using {@link restoreRelation}.
|
|
161
|
-
*
|
|
162
|
-
* @param id - The relation ID to delete
|
|
163
|
-
* @returns A DeleteRelation operation
|
|
164
|
-
*/
|
|
165
|
-
export function deleteRelation(id) {
|
|
166
|
-
return { type: "deleteRelation", id };
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Creates a RestoreRelation operation.
|
|
170
|
-
*
|
|
171
|
-
* Transitions a deleted relation back to ALIVE state.
|
|
172
|
-
*
|
|
173
|
-
* @param id - The relation ID to restore
|
|
174
|
-
* @returns A RestoreRelation operation
|
|
175
|
-
*/
|
|
176
|
-
export function restoreRelation(id) {
|
|
177
|
-
return { type: "restoreRelation", id };
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Creates a CreateValueRef operation.
|
|
181
|
-
*
|
|
182
|
-
* Creates a reference to a value on another entity, optionally in another space.
|
|
183
|
-
* This allows sharing values across entities without duplication.
|
|
184
|
-
*
|
|
185
|
-
* @param input - The value reference configuration
|
|
186
|
-
* @returns A CreateValueRef operation
|
|
187
|
-
*
|
|
188
|
-
* @example
|
|
189
|
-
* ```ts
|
|
190
|
-
* const op = createValueRef({
|
|
191
|
-
* id: refId,
|
|
192
|
-
* entity: sourceEntityId,
|
|
193
|
-
* property: properties.name(),
|
|
194
|
-
* });
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
export function createValueRef(input) {
|
|
198
|
-
return {
|
|
199
|
-
type: "createValueRef",
|
|
200
|
-
...input,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
//# sourceMappingURL=index.js.map
|
package/dist/ops/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAoBzC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAExF,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,QAAQ,EAAE;QAC1B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE;QACtB,OAAO;QACP,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,EAAE;QAChC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAA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