graphddb 0.7.8 → 0.7.9
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/cdc/index.d.ts +2 -2
- package/dist/cdc/index.js +2 -2
- package/dist/{chunk-NZRCBEWS.js → chunk-NYM7K2ST.js} +156 -70
- package/dist/{chunk-HFFIB77D.js → chunk-PFFPLD4B.js} +1 -0
- package/dist/{chunk-IA6MW2HP.js → chunk-ZPNRLOKA.js} +1 -1
- package/dist/cli.js +387 -29
- package/dist/{from-change-w2Ih8fkm.d.ts → from-change-DanwjE5b.d.ts} +1 -1
- package/dist/{index-Deugy2sa.d.ts → index-CtPJSMrc.d.ts} +2 -2
- package/dist/index.d.ts +125 -115
- package/dist/index.js +93 -34
- package/dist/linter/index.d.ts +4 -4
- package/dist/{maintenance-view-adapter-BCbgKG5d.d.ts → maintenance-view-adapter-BATUh_I8.d.ts} +103 -41
- package/dist/{registry-pAnFcc62.d.ts → registry-CXhP4TaE.d.ts} +1 -1
- package/dist/{relation-depth-C9t4s9bt.d.ts → relation-depth-Dg3yhl7S.d.ts} +1 -1
- package/dist/spec/index.d.ts +3 -3
- package/dist/spec/index.js +2 -2
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -2
- package/package.json +2 -1
package/dist/cdc/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as CdcEmulator, M as MAINT_OUTBOX_PK_PREFIX, a as MaintenanceDrain, b as MaintenanceDrainOptions, c as createCdcEmulator, d as createMaintenanceDrain, e as createMaintenanceDrainHandler, p as parseChange } from '../from-change-
|
|
2
|
-
export { B as BatchResult, C as CdcEmulatorOptions, a as CdcMode, b as ChangeBatch, c as ChangeEvent, d as ChangeEventName, e as ChangeHandler, f as ClockMode, g as ConcurrentRecomputeRef, E as EventLog, F as FaultSpec, R as ReplayOptions, S as ShardId, h as StartingPosition, i as StreamViewType, j as SubscribeHandler, k as SubscribeHandlers, U as Unsubscribe, l as buildSubscribeHandler } from '../maintenance-view-adapter-
|
|
1
|
+
export { C as CdcEmulator, M as MAINT_OUTBOX_PK_PREFIX, a as MaintenanceDrain, b as MaintenanceDrainOptions, c as createCdcEmulator, d as createMaintenanceDrain, e as createMaintenanceDrainHandler, p as parseChange } from '../from-change-DanwjE5b.js';
|
|
2
|
+
export { B as BatchResult, C as CdcEmulatorOptions, a as CdcMode, b as ChangeBatch, c as ChangeEvent, d as ChangeEventName, e as ChangeHandler, f as ClockMode, g as ConcurrentRecomputeRef, E as EventLog, F as FaultSpec, R as ReplayOptions, S as ShardId, h as StartingPosition, i as StreamViewType, j as SubscribeHandler, k as SubscribeHandlers, U as Unsubscribe, l as buildSubscribeHandler } from '../maintenance-view-adapter-BATUh_I8.js';
|
|
3
3
|
import '@aws-sdk/client-dynamodb';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/cdc/index.js
CHANGED
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
createMaintenanceDrainHandler,
|
|
9
9
|
hashString,
|
|
10
10
|
shardIdFor
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-ZPNRLOKA.js";
|
|
12
12
|
import {
|
|
13
13
|
buildSubscribeHandler,
|
|
14
14
|
parseChange
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-PFFPLD4B.js";
|
|
16
16
|
import "../chunk-PDUVTYC5.js";
|
|
17
17
|
export {
|
|
18
18
|
CdcEmulator,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
MAX_TRANSACT_ITEMS,
|
|
7
7
|
MetadataRegistry,
|
|
8
8
|
NO_MIDDLEWARE,
|
|
9
|
+
SELECT_SPEC,
|
|
9
10
|
attachHiddenKey,
|
|
10
11
|
attachModelClass,
|
|
11
12
|
buildConditionExpression,
|
|
@@ -51,7 +52,7 @@ import {
|
|
|
51
52
|
serializeRawCondition,
|
|
52
53
|
skTemplate,
|
|
53
54
|
validateInlineSnapshotSelect
|
|
54
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-PFFPLD4B.js";
|
|
55
56
|
import {
|
|
56
57
|
TableMapping,
|
|
57
58
|
createColumnMap,
|
|
@@ -1754,6 +1755,154 @@ async function executeQueryInner(modelClass, key, selectSpec, options, mw) {
|
|
|
1754
1755
|
return hydratedItem;
|
|
1755
1756
|
}
|
|
1756
1757
|
|
|
1758
|
+
// src/runtime/read-plan.ts
|
|
1759
|
+
function bindSlots(slots, params) {
|
|
1760
|
+
const out = {};
|
|
1761
|
+
for (const [field, slot] of Object.entries(slots)) {
|
|
1762
|
+
out[field] = slot.kind === "param" ? params[slot.name] : slot.value;
|
|
1763
|
+
}
|
|
1764
|
+
return out;
|
|
1765
|
+
}
|
|
1766
|
+
function bindOptionalSlot(slot, params) {
|
|
1767
|
+
if (slot === void 0) return void 0;
|
|
1768
|
+
return slot.kind === "param" ? params[slot.name] : slot.value;
|
|
1769
|
+
}
|
|
1770
|
+
function executeCompiledReadRoute(route, params, options) {
|
|
1771
|
+
const key = bindSlots(route.keySlots, params);
|
|
1772
|
+
const opts = { ...options ?? {} };
|
|
1773
|
+
if (route.kind === "query") {
|
|
1774
|
+
if (route.consistentReadSlot !== void 0) {
|
|
1775
|
+
opts.consistentRead = bindOptionalSlot(route.consistentReadSlot, params);
|
|
1776
|
+
}
|
|
1777
|
+
if (route.maxDepth !== void 0) opts.maxDepth = route.maxDepth;
|
|
1778
|
+
return executeQuery(route.modelClass, key, route.select, opts);
|
|
1779
|
+
}
|
|
1780
|
+
if (route.limitSlot !== void 0) {
|
|
1781
|
+
opts.limit = bindOptionalSlot(route.limitSlot, params);
|
|
1782
|
+
}
|
|
1783
|
+
if (route.afterSlot !== void 0) {
|
|
1784
|
+
opts.after = bindOptionalSlot(route.afterSlot, params);
|
|
1785
|
+
}
|
|
1786
|
+
if (route.order !== void 0) opts.order = route.order;
|
|
1787
|
+
if (route.filter !== void 0) opts.filter = route.filter;
|
|
1788
|
+
return executeList(route.modelClass, key, route.select, opts);
|
|
1789
|
+
}
|
|
1790
|
+
var MODEL_CLASS_IDS = /* @__PURE__ */ new WeakMap();
|
|
1791
|
+
var nextModelClassId = 1;
|
|
1792
|
+
function modelClassIdentity(cls) {
|
|
1793
|
+
let id = MODEL_CLASS_IDS.get(cls);
|
|
1794
|
+
if (id === void 0) {
|
|
1795
|
+
id = nextModelClassId++;
|
|
1796
|
+
MODEL_CLASS_IDS.set(cls, id);
|
|
1797
|
+
}
|
|
1798
|
+
return `model#${id}`;
|
|
1799
|
+
}
|
|
1800
|
+
var BoundedLru = class {
|
|
1801
|
+
constructor(max) {
|
|
1802
|
+
this.max = max;
|
|
1803
|
+
}
|
|
1804
|
+
max;
|
|
1805
|
+
map = /* @__PURE__ */ new Map();
|
|
1806
|
+
get(key) {
|
|
1807
|
+
const v = this.map.get(key);
|
|
1808
|
+
if (v !== void 0) {
|
|
1809
|
+
this.map.delete(key);
|
|
1810
|
+
this.map.set(key, v);
|
|
1811
|
+
}
|
|
1812
|
+
return v;
|
|
1813
|
+
}
|
|
1814
|
+
set(key, value) {
|
|
1815
|
+
if (this.map.has(key)) this.map.delete(key);
|
|
1816
|
+
this.map.set(key, value);
|
|
1817
|
+
if (this.map.size > this.max) {
|
|
1818
|
+
const oldest = this.map.keys().next().value;
|
|
1819
|
+
if (oldest !== void 0) this.map.delete(oldest);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
get size() {
|
|
1823
|
+
return this.map.size;
|
|
1824
|
+
}
|
|
1825
|
+
clear() {
|
|
1826
|
+
this.map.clear();
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
var ADHOC_READ_PLAN_CACHE_MAX = 256;
|
|
1830
|
+
var ADHOC_READ_PLAN_CACHE = new BoundedLru(ADHOC_READ_PLAN_CACHE_MAX);
|
|
1831
|
+
var adHocCompileCount = 0;
|
|
1832
|
+
function shapeToken(value) {
|
|
1833
|
+
if (value === null) return "null";
|
|
1834
|
+
const t = typeof value;
|
|
1835
|
+
if (t === "string") return JSON.stringify(value);
|
|
1836
|
+
if (t === "number" || t === "boolean") return String(value);
|
|
1837
|
+
if (t === "undefined") return "u";
|
|
1838
|
+
if (t === "bigint") return `n${String(value)}`;
|
|
1839
|
+
if (t === "function" || t === "symbol") return null;
|
|
1840
|
+
if (value instanceof Date) return `D${value.getTime()}`;
|
|
1841
|
+
if (Array.isArray(value)) {
|
|
1842
|
+
const parts2 = [];
|
|
1843
|
+
for (const v of value) {
|
|
1844
|
+
const p = shapeToken(v);
|
|
1845
|
+
if (p === null) return null;
|
|
1846
|
+
parts2.push(p);
|
|
1847
|
+
}
|
|
1848
|
+
return `[${parts2.join(",")}]`;
|
|
1849
|
+
}
|
|
1850
|
+
if (isSelectBuilder(value)) {
|
|
1851
|
+
const spec = value[SELECT_SPEC];
|
|
1852
|
+
const inner = shapeToken({
|
|
1853
|
+
select: spec.select,
|
|
1854
|
+
filter: spec.filter,
|
|
1855
|
+
limit: spec.limit,
|
|
1856
|
+
after: spec.after,
|
|
1857
|
+
order: spec.order
|
|
1858
|
+
});
|
|
1859
|
+
return inner === null ? null : `B${inner}`;
|
|
1860
|
+
}
|
|
1861
|
+
const proto = Object.getPrototypeOf(value);
|
|
1862
|
+
if (proto !== Object.prototype && proto !== null) return null;
|
|
1863
|
+
const rec = value;
|
|
1864
|
+
const parts = [];
|
|
1865
|
+
for (const k of Object.keys(rec).sort()) {
|
|
1866
|
+
const p = shapeToken(rec[k]);
|
|
1867
|
+
if (p === null) return null;
|
|
1868
|
+
parts.push(`${JSON.stringify(k)}:${p}`);
|
|
1869
|
+
}
|
|
1870
|
+
return `{${parts.join(",")}}`;
|
|
1871
|
+
}
|
|
1872
|
+
function adHocStructureKey(kind, modelClass, key, select) {
|
|
1873
|
+
const selectToken = shapeToken(select);
|
|
1874
|
+
if (selectToken === null) return null;
|
|
1875
|
+
const fields = Object.keys(key).map((f) => JSON.stringify(f)).join(",");
|
|
1876
|
+
return `${kind}|${modelClassIdentity(modelClass)}|${fields}|${selectToken}`;
|
|
1877
|
+
}
|
|
1878
|
+
function lowerAdHocReadRoute(kind, modelClass, key, select) {
|
|
1879
|
+
const cacheKey = adHocStructureKey(kind, modelClass, key, select);
|
|
1880
|
+
if (cacheKey !== null) {
|
|
1881
|
+
const cached = ADHOC_READ_PLAN_CACHE.get(cacheKey);
|
|
1882
|
+
if (cached !== void 0) return cached;
|
|
1883
|
+
}
|
|
1884
|
+
adHocCompileCount++;
|
|
1885
|
+
const keySlots = {};
|
|
1886
|
+
for (const field of Object.keys(key)) {
|
|
1887
|
+
keySlots[field] = { kind: "param", name: field };
|
|
1888
|
+
}
|
|
1889
|
+
const route = { alias: "$adhoc", kind, modelClass, select, keySlots };
|
|
1890
|
+
if (cacheKey !== null) ADHOC_READ_PLAN_CACHE.set(cacheKey, route);
|
|
1891
|
+
return route;
|
|
1892
|
+
}
|
|
1893
|
+
function runAdHoc(route, select, key, options) {
|
|
1894
|
+
const effective = route.select === select ? route : { ...route, select };
|
|
1895
|
+
return executeCompiledReadRoute(effective, key, options);
|
|
1896
|
+
}
|
|
1897
|
+
function executeAdHocQuery(modelClass, key, selectSpec, options) {
|
|
1898
|
+
const route = lowerAdHocReadRoute("query", modelClass, key, selectSpec);
|
|
1899
|
+
return runAdHoc(route, selectSpec, key, options);
|
|
1900
|
+
}
|
|
1901
|
+
function executeAdHocList(modelClass, key, selectSpec, options) {
|
|
1902
|
+
const route = lowerAdHocReadRoute("list", modelClass, key, selectSpec);
|
|
1903
|
+
return runAdHoc(route, selectSpec, key, options);
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1757
1906
|
// src/operations/explain.ts
|
|
1758
1907
|
function executeExplain(modelClass, key, options) {
|
|
1759
1908
|
const metadata = MetadataRegistry.get(modelClass);
|
|
@@ -4273,13 +4422,13 @@ async function executeReadRoute(alias, route) {
|
|
|
4273
4422
|
);
|
|
4274
4423
|
const opt = route.options ?? {};
|
|
4275
4424
|
if (isQuery) {
|
|
4276
|
-
return
|
|
4425
|
+
return executeAdHocQuery(modelClass, route.key, route.select, {
|
|
4277
4426
|
consistentRead: opt.consistentRead,
|
|
4278
4427
|
maxDepth: opt.maxDepth,
|
|
4279
4428
|
context: opt.context
|
|
4280
4429
|
});
|
|
4281
4430
|
}
|
|
4282
|
-
return
|
|
4431
|
+
return executeAdHocList(modelClass, route.key, route.select, {
|
|
4283
4432
|
limit: opt.limit,
|
|
4284
4433
|
after: opt.after,
|
|
4285
4434
|
order: opt.order,
|
|
@@ -4514,17 +4663,6 @@ function recordSlots(binding, where) {
|
|
|
4514
4663
|
}
|
|
4515
4664
|
return { fields, slots };
|
|
4516
4665
|
}
|
|
4517
|
-
function bindSlots(slots, params) {
|
|
4518
|
-
const out = {};
|
|
4519
|
-
for (const [field, slot] of Object.entries(slots)) {
|
|
4520
|
-
out[field] = slot.kind === "param" ? params[slot.name] : slot.value;
|
|
4521
|
-
}
|
|
4522
|
-
return out;
|
|
4523
|
-
}
|
|
4524
|
-
function bindOptionalSlot(slot, params) {
|
|
4525
|
-
if (slot === void 0) return void 0;
|
|
4526
|
-
return slot.kind === "param" ? params[slot.name] : slot.value;
|
|
4527
|
-
}
|
|
4528
4666
|
function recordOptionSlot(value, where) {
|
|
4529
4667
|
if (value === void 0) return void 0;
|
|
4530
4668
|
if (isPreparedParamRef(value)) return { kind: "param", name: value.name };
|
|
@@ -4584,23 +4722,7 @@ var PreparedReadStatement = class {
|
|
|
4584
4722
|
return out;
|
|
4585
4723
|
}
|
|
4586
4724
|
runRoute(route, params, options) {
|
|
4587
|
-
|
|
4588
|
-
const consistentRead = bindOptionalSlot(route.consistentReadSlot, params);
|
|
4589
|
-
if (route.kind === "query") {
|
|
4590
|
-
return executeQuery(route.modelClass, key, route.select, {
|
|
4591
|
-
consistentRead,
|
|
4592
|
-
maxDepth: route.maxDepth,
|
|
4593
|
-
...options.retry !== void 0 ? { retry: options.retry } : {},
|
|
4594
|
-
...options.context !== void 0 ? { context: options.context } : {}
|
|
4595
|
-
});
|
|
4596
|
-
}
|
|
4597
|
-
const limit = bindOptionalSlot(route.limitSlot, params);
|
|
4598
|
-
const after = bindOptionalSlot(route.afterSlot, params);
|
|
4599
|
-
return executeList(route.modelClass, key, route.select, {
|
|
4600
|
-
limit,
|
|
4601
|
-
after,
|
|
4602
|
-
order: route.order,
|
|
4603
|
-
filter: route.filter,
|
|
4725
|
+
return executeCompiledReadRoute(route, params, {
|
|
4604
4726
|
...options.retry !== void 0 ? { retry: options.retry } : {},
|
|
4605
4727
|
...options.context !== void 0 ? { context: options.context } : {}
|
|
4606
4728
|
});
|
|
@@ -4764,35 +4886,6 @@ function assertStaticTemplate(value, where) {
|
|
|
4764
4886
|
}
|
|
4765
4887
|
}
|
|
4766
4888
|
var PREPARE_CACHE_MAX = 256;
|
|
4767
|
-
var BoundedLru = class {
|
|
4768
|
-
constructor(max) {
|
|
4769
|
-
this.max = max;
|
|
4770
|
-
}
|
|
4771
|
-
max;
|
|
4772
|
-
map = /* @__PURE__ */ new Map();
|
|
4773
|
-
get(key) {
|
|
4774
|
-
const v = this.map.get(key);
|
|
4775
|
-
if (v !== void 0) {
|
|
4776
|
-
this.map.delete(key);
|
|
4777
|
-
this.map.set(key, v);
|
|
4778
|
-
}
|
|
4779
|
-
return v;
|
|
4780
|
-
}
|
|
4781
|
-
set(key, value) {
|
|
4782
|
-
if (this.map.has(key)) this.map.delete(key);
|
|
4783
|
-
this.map.set(key, value);
|
|
4784
|
-
if (this.map.size > this.max) {
|
|
4785
|
-
const oldest = this.map.keys().next().value;
|
|
4786
|
-
if (oldest !== void 0) this.map.delete(oldest);
|
|
4787
|
-
}
|
|
4788
|
-
}
|
|
4789
|
-
get size() {
|
|
4790
|
-
return this.map.size;
|
|
4791
|
-
}
|
|
4792
|
-
clear() {
|
|
4793
|
-
this.map.clear();
|
|
4794
|
-
}
|
|
4795
|
-
};
|
|
4796
4889
|
var PREPARE_CACHE = new BoundedLru(PREPARE_CACHE_MAX);
|
|
4797
4890
|
function structureKey(routes) {
|
|
4798
4891
|
const parts = routes.map(({ alias, route }) => {
|
|
@@ -4808,18 +4901,11 @@ function structureKey(routes) {
|
|
|
4808
4901
|
});
|
|
4809
4902
|
return parts.join("||");
|
|
4810
4903
|
}
|
|
4811
|
-
var MODEL_IDENTITY_IDS = /* @__PURE__ */ new WeakMap();
|
|
4812
|
-
var nextModelIdentityId = 1;
|
|
4813
4904
|
function modelIdentity(ref, alias) {
|
|
4814
4905
|
try {
|
|
4815
4906
|
const model = resolveModelStatic(ref, alias);
|
|
4816
4907
|
const cls = resolveModelClass(model);
|
|
4817
|
-
|
|
4818
|
-
if (id === void 0) {
|
|
4819
|
-
id = nextModelIdentityId++;
|
|
4820
|
-
MODEL_IDENTITY_IDS.set(cls, id);
|
|
4821
|
-
}
|
|
4822
|
-
return `model#${id}`;
|
|
4908
|
+
return modelClassIdentity(cls);
|
|
4823
4909
|
} catch {
|
|
4824
4910
|
return "unresolved";
|
|
4825
4911
|
}
|
|
@@ -5119,10 +5205,10 @@ var DDBModel = class {
|
|
|
5119
5205
|
// method type — the public overloads (the only caller-visible surface)
|
|
5120
5206
|
// are untouched.
|
|
5121
5207
|
query: ((key, select, options) => {
|
|
5122
|
-
return
|
|
5208
|
+
return executeAdHocQuery(modelClass, key, select, options);
|
|
5123
5209
|
}),
|
|
5124
5210
|
list: ((key, select, options) => {
|
|
5125
|
-
return
|
|
5211
|
+
return executeAdHocList(modelClass, key, select, options);
|
|
5126
5212
|
}),
|
|
5127
5213
|
explain(key, options) {
|
|
5128
5214
|
return executeExplain(
|