@nicia-ai/typegraph 0.10.0 → 0.11.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/index.cjs +107 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +107 -111
- package/dist/index.js.map +1 -1
- package/dist/interchange/index.d.cts +1 -1
- package/dist/interchange/index.d.ts +1 -1
- package/dist/profiler/index.d.cts +1 -1
- package/dist/profiler/index.d.ts +1 -1
- package/dist/{store-NE18RGqV.d.cts → store-DyGdpDFr.d.cts} +23 -0
- package/dist/{store-BcFe9jJe.d.ts → store-nQ1ATBlN.d.ts} +23 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8267,21 +8267,29 @@ function narrowEdge(edge) {
|
|
|
8267
8267
|
function narrowEdges(edges) {
|
|
8268
8268
|
return edges;
|
|
8269
8269
|
}
|
|
8270
|
+
function buildCreateEdgeInput(kind, from, to, props, options) {
|
|
8271
|
+
const input = {
|
|
8272
|
+
kind,
|
|
8273
|
+
fromKind: from.kind,
|
|
8274
|
+
fromId: from.id,
|
|
8275
|
+
toKind: to.kind,
|
|
8276
|
+
toId: to.id,
|
|
8277
|
+
props
|
|
8278
|
+
};
|
|
8279
|
+
if (options?.id !== void 0) input.id = options.id;
|
|
8280
|
+
if (options?.validFrom !== void 0) input.validFrom = options.validFrom;
|
|
8281
|
+
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8282
|
+
return input;
|
|
8283
|
+
}
|
|
8284
|
+
function buildUpdateEdgeInput(id, props, options) {
|
|
8285
|
+
const input = { id, props };
|
|
8286
|
+
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8287
|
+
return input;
|
|
8288
|
+
}
|
|
8270
8289
|
function mapBulkEdgeInputs(kind, items) {
|
|
8271
|
-
return items.map(
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
fromKind: item.from.kind,
|
|
8275
|
-
fromId: item.from.id,
|
|
8276
|
-
toKind: item.to.kind,
|
|
8277
|
-
toId: item.to.id,
|
|
8278
|
-
props: item.props ?? {}
|
|
8279
|
-
};
|
|
8280
|
-
if (item.id !== void 0) input.id = item.id;
|
|
8281
|
-
if (item.validFrom !== void 0) input.validFrom = item.validFrom;
|
|
8282
|
-
if (item.validTo !== void 0) input.validTo = item.validTo;
|
|
8283
|
-
return input;
|
|
8284
|
-
});
|
|
8290
|
+
return items.map(
|
|
8291
|
+
(item) => buildCreateEdgeInput(kind, item.from, item.to, item.props ?? {}, item)
|
|
8292
|
+
);
|
|
8285
8293
|
}
|
|
8286
8294
|
function createEdgeCollection(config) {
|
|
8287
8295
|
const {
|
|
@@ -8301,18 +8309,16 @@ function createEdgeCollection(config) {
|
|
|
8301
8309
|
} = config;
|
|
8302
8310
|
return {
|
|
8303
8311
|
async create(from, to, props, options) {
|
|
8304
|
-
const
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8315
|
-
const result = await executeEdgeCreate2(input, backend);
|
|
8312
|
+
const result = await executeEdgeCreate2(
|
|
8313
|
+
buildCreateEdgeInput(
|
|
8314
|
+
kind,
|
|
8315
|
+
from,
|
|
8316
|
+
to,
|
|
8317
|
+
props ?? {},
|
|
8318
|
+
options
|
|
8319
|
+
),
|
|
8320
|
+
backend
|
|
8321
|
+
);
|
|
8316
8322
|
return narrowEdge(result);
|
|
8317
8323
|
},
|
|
8318
8324
|
async getById(id, options) {
|
|
@@ -8349,12 +8355,10 @@ function createEdgeCollection(config) {
|
|
|
8349
8355
|
);
|
|
8350
8356
|
},
|
|
8351
8357
|
async update(id, props, options) {
|
|
8352
|
-
const
|
|
8353
|
-
id,
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8357
|
-
const result = await executeEdgeUpdate2(input, backend);
|
|
8358
|
+
const result = await executeEdgeUpdate2(
|
|
8359
|
+
buildUpdateEdgeInput(id, props, options),
|
|
8360
|
+
backend
|
|
8361
|
+
);
|
|
8358
8362
|
return narrowEdge(result);
|
|
8359
8363
|
},
|
|
8360
8364
|
async findFrom(from) {
|
|
@@ -8467,29 +8471,26 @@ function createEdgeCollection(config) {
|
|
|
8467
8471
|
for (const item of items) {
|
|
8468
8472
|
const existing = existingMap.get(item.id);
|
|
8469
8473
|
if (existing) {
|
|
8470
|
-
const input = {
|
|
8471
|
-
id: item.id,
|
|
8472
|
-
props: item.props
|
|
8473
|
-
};
|
|
8474
|
-
if (item.validTo !== void 0) input.validTo = item.validTo;
|
|
8475
8474
|
toUpdate.push({
|
|
8476
8475
|
index: itemIndex,
|
|
8477
|
-
input
|
|
8476
|
+
input: buildUpdateEdgeInput(
|
|
8477
|
+
item.id,
|
|
8478
|
+
item.props ?? {},
|
|
8479
|
+
item
|
|
8480
|
+
),
|
|
8478
8481
|
clearDeleted: existing.deleted_at !== void 0
|
|
8479
8482
|
});
|
|
8480
8483
|
} else {
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
if (item.validTo !== void 0) input.validTo = item.validTo;
|
|
8492
|
-
toCreate.push({ index: itemIndex, input });
|
|
8484
|
+
toCreate.push({
|
|
8485
|
+
index: itemIndex,
|
|
8486
|
+
input: buildCreateEdgeInput(
|
|
8487
|
+
kind,
|
|
8488
|
+
item.from,
|
|
8489
|
+
item.to,
|
|
8490
|
+
item.props ?? {},
|
|
8491
|
+
item
|
|
8492
|
+
)
|
|
8493
|
+
});
|
|
8493
8494
|
}
|
|
8494
8495
|
itemIndex++;
|
|
8495
8496
|
}
|
|
@@ -8618,17 +8619,20 @@ function narrowNode(node) {
|
|
|
8618
8619
|
function narrowNodes(nodes) {
|
|
8619
8620
|
return nodes;
|
|
8620
8621
|
}
|
|
8622
|
+
function buildCreateInput(kind, props, options) {
|
|
8623
|
+
const input = { kind, props };
|
|
8624
|
+
if (options?.id !== void 0) input.id = options.id;
|
|
8625
|
+
if (options?.validFrom !== void 0) input.validFrom = options.validFrom;
|
|
8626
|
+
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8627
|
+
return input;
|
|
8628
|
+
}
|
|
8629
|
+
function buildUpdateInput(kind, id, props, options) {
|
|
8630
|
+
const input = { kind, id, props };
|
|
8631
|
+
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8632
|
+
return input;
|
|
8633
|
+
}
|
|
8621
8634
|
function mapBulkNodeInputs(kind, items) {
|
|
8622
|
-
return items.map((item) =>
|
|
8623
|
-
const input = {
|
|
8624
|
-
kind,
|
|
8625
|
-
props: item.props
|
|
8626
|
-
};
|
|
8627
|
-
if (item.id !== void 0) input.id = item.id;
|
|
8628
|
-
if (item.validFrom !== void 0) input.validFrom = item.validFrom;
|
|
8629
|
-
if (item.validTo !== void 0) input.validTo = item.validTo;
|
|
8630
|
-
return input;
|
|
8631
|
-
});
|
|
8635
|
+
return items.map((item) => buildCreateInput(kind, item.props, item));
|
|
8632
8636
|
}
|
|
8633
8637
|
function createNodeCollection(config) {
|
|
8634
8638
|
const {
|
|
@@ -8653,14 +8657,13 @@ function createNodeCollection(config) {
|
|
|
8653
8657
|
} = config;
|
|
8654
8658
|
return {
|
|
8655
8659
|
async create(props, options) {
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
const result = await executeNodeCreate2(input, backend);
|
|
8660
|
+
return this.createFromRecord(props, options);
|
|
8661
|
+
},
|
|
8662
|
+
async createFromRecord(data, options) {
|
|
8663
|
+
const result = await executeNodeCreate2(
|
|
8664
|
+
buildCreateInput(kind, data, options),
|
|
8665
|
+
backend
|
|
8666
|
+
);
|
|
8664
8667
|
return narrowNode(result);
|
|
8665
8668
|
},
|
|
8666
8669
|
async getById(id, options) {
|
|
@@ -8698,13 +8701,10 @@ function createNodeCollection(config) {
|
|
|
8698
8701
|
);
|
|
8699
8702
|
},
|
|
8700
8703
|
async update(id, props, options) {
|
|
8701
|
-
const
|
|
8702
|
-
kind,
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
};
|
|
8706
|
-
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8707
|
-
const result = await executeNodeUpdate2(input, backend);
|
|
8704
|
+
const result = await executeNodeUpdate2(
|
|
8705
|
+
buildUpdateInput(kind, id, props, options),
|
|
8706
|
+
backend
|
|
8707
|
+
);
|
|
8708
8708
|
return narrowNode(result);
|
|
8709
8709
|
},
|
|
8710
8710
|
async delete(id) {
|
|
@@ -8760,31 +8760,28 @@ function createNodeCollection(config) {
|
|
|
8760
8760
|
return backend.countNodesByKind(params);
|
|
8761
8761
|
},
|
|
8762
8762
|
async upsertById(id, props, options) {
|
|
8763
|
+
return this.upsertByIdFromRecord(
|
|
8764
|
+
id,
|
|
8765
|
+
props,
|
|
8766
|
+
options
|
|
8767
|
+
);
|
|
8768
|
+
},
|
|
8769
|
+
async upsertByIdFromRecord(id, data, options) {
|
|
8763
8770
|
const existing = await backend.getNode(graphId, kind, id);
|
|
8764
8771
|
if (existing) {
|
|
8765
|
-
const input = {
|
|
8766
|
-
kind,
|
|
8767
|
-
id,
|
|
8768
|
-
props
|
|
8769
|
-
};
|
|
8770
|
-
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8771
8772
|
const clearDeleted = existing.deleted_at !== void 0;
|
|
8772
|
-
const
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
kind,
|
|
8779
|
-
id,
|
|
8780
|
-
props
|
|
8781
|
-
};
|
|
8782
|
-
if (options?.validFrom !== void 0)
|
|
8783
|
-
input.validFrom = options.validFrom;
|
|
8784
|
-
if (options?.validTo !== void 0) input.validTo = options.validTo;
|
|
8785
|
-
const result = await executeNodeCreate2(input, backend);
|
|
8786
|
-
return narrowNode(result);
|
|
8773
|
+
const result2 = await executeNodeUpdate2(
|
|
8774
|
+
buildUpdateInput(kind, id, data, options),
|
|
8775
|
+
backend,
|
|
8776
|
+
{ clearDeleted }
|
|
8777
|
+
);
|
|
8778
|
+
return narrowNode(result2);
|
|
8787
8779
|
}
|
|
8780
|
+
const result = await executeNodeCreate2(
|
|
8781
|
+
buildCreateInput(kind, data, { ...options, id }),
|
|
8782
|
+
backend
|
|
8783
|
+
);
|
|
8784
|
+
return narrowNode(result);
|
|
8788
8785
|
},
|
|
8789
8786
|
async bulkCreate(items) {
|
|
8790
8787
|
const batchInputs = mapBulkNodeInputs(
|
|
@@ -8828,26 +8825,25 @@ function createNodeCollection(config) {
|
|
|
8828
8825
|
for (const item of items) {
|
|
8829
8826
|
const existing = existingMap.get(item.id);
|
|
8830
8827
|
if (existing) {
|
|
8831
|
-
const input = {
|
|
8832
|
-
kind,
|
|
8833
|
-
id: item.id,
|
|
8834
|
-
props: item.props
|
|
8835
|
-
};
|
|
8836
|
-
if (item.validTo !== void 0) input.validTo = item.validTo;
|
|
8837
8828
|
toUpdate.push({
|
|
8838
8829
|
index: itemIndex,
|
|
8839
|
-
input
|
|
8830
|
+
input: buildUpdateInput(
|
|
8831
|
+
kind,
|
|
8832
|
+
item.id,
|
|
8833
|
+
item.props,
|
|
8834
|
+
item
|
|
8835
|
+
),
|
|
8840
8836
|
clearDeleted: existing.deleted_at !== void 0
|
|
8841
8837
|
});
|
|
8842
8838
|
} else {
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8839
|
+
toCreate.push({
|
|
8840
|
+
index: itemIndex,
|
|
8841
|
+
input: buildCreateInput(
|
|
8842
|
+
kind,
|
|
8843
|
+
item.props,
|
|
8844
|
+
item
|
|
8845
|
+
)
|
|
8846
|
+
});
|
|
8851
8847
|
}
|
|
8852
8848
|
itemIndex++;
|
|
8853
8849
|
}
|