graphddb 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -3
- package/dist/{chunk-UNRQ5YJT.js → chunk-27XBTYVK.js} +1 -1
- package/dist/{chunk-347U24SB.js → chunk-3MI43FHU.js} +519 -48
- package/dist/{chunk-F27INYI2.js → chunk-CXIAECRS.js} +272 -97
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +5 -19
- package/dist/index.js +113 -7
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/{types-D6qLpw2M.d.ts → types-SKxZQbQO.d.ts} +230 -122
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
compileFragment,
|
|
29
29
|
compileMutationPlan,
|
|
30
30
|
compileSingleFragmentPlan,
|
|
31
|
-
|
|
31
|
+
conditionParamName,
|
|
32
32
|
contractOfMethodSpec,
|
|
33
33
|
decodeCursor,
|
|
34
34
|
definePlan,
|
|
@@ -68,7 +68,6 @@ import {
|
|
|
68
68
|
isLifecycleContract,
|
|
69
69
|
isMutationFragment,
|
|
70
70
|
isMutationInputRef,
|
|
71
|
-
isParam,
|
|
72
71
|
isPlannedCommandMethod,
|
|
73
72
|
isQueryModelContract,
|
|
74
73
|
isSelectBuilder,
|
|
@@ -78,7 +77,6 @@ import {
|
|
|
78
77
|
mintContractKeyFieldRef,
|
|
79
78
|
mintContractParamRef,
|
|
80
79
|
mutation,
|
|
81
|
-
param,
|
|
82
80
|
plan,
|
|
83
81
|
publicCommandModel,
|
|
84
82
|
publicQueryModel,
|
|
@@ -88,11 +86,11 @@ import {
|
|
|
88
86
|
validateDepth,
|
|
89
87
|
when,
|
|
90
88
|
wholeKeysSentinel
|
|
91
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-CXIAECRS.js";
|
|
92
90
|
import {
|
|
93
91
|
CdcEmulator,
|
|
94
92
|
createCdcEmulator
|
|
95
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-27XBTYVK.js";
|
|
96
94
|
import {
|
|
97
95
|
BATCH_GET_MAX_KEYS,
|
|
98
96
|
BATCH_WRITE_MAX_ITEMS,
|
|
@@ -110,7 +108,9 @@ import {
|
|
|
110
108
|
buildUpdateExpression,
|
|
111
109
|
buildUpdateInput,
|
|
112
110
|
collapseSameKeyItems,
|
|
111
|
+
collectRawConditionParams,
|
|
113
112
|
commitTransaction,
|
|
113
|
+
cond,
|
|
114
114
|
createDefaultLinter,
|
|
115
115
|
execItemKeySignature,
|
|
116
116
|
executeDelete,
|
|
@@ -121,16 +121,20 @@ import {
|
|
|
121
121
|
gsiAmbiguityRule,
|
|
122
122
|
isColumn,
|
|
123
123
|
isKeySegment,
|
|
124
|
+
isParam,
|
|
125
|
+
isRawCondition,
|
|
124
126
|
k,
|
|
125
127
|
key,
|
|
126
128
|
missingGsiRule,
|
|
127
129
|
noScanRule,
|
|
130
|
+
param,
|
|
128
131
|
relationDepthRule,
|
|
129
132
|
requireLimitRule,
|
|
133
|
+
resolveConditionTree,
|
|
130
134
|
resolveKey,
|
|
131
135
|
resolveModelClass,
|
|
132
136
|
serializeFieldValue
|
|
133
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-3MI43FHU.js";
|
|
134
138
|
|
|
135
139
|
// src/metadata/prefix.ts
|
|
136
140
|
function derivePrefix(customPrefix, className) {
|
|
@@ -413,6 +417,12 @@ function whenHolds(when2, params, element) {
|
|
|
413
417
|
const right = resolveTemplate(when2.right, params, element);
|
|
414
418
|
return when2.op === "eq" ? left === right : left !== right;
|
|
415
419
|
}
|
|
420
|
+
function resolveRawConditionValue(val, params, element) {
|
|
421
|
+
if (val !== null && typeof val === "object" && typeof val.$param === "string") {
|
|
422
|
+
return resolveValue(`{${val.$param}}`, params, element);
|
|
423
|
+
}
|
|
424
|
+
return val;
|
|
425
|
+
}
|
|
416
426
|
function applyCondition(condition, target, params, element) {
|
|
417
427
|
if (!condition) return;
|
|
418
428
|
const names = target.ExpressionAttributeNames ??= {};
|
|
@@ -428,6 +438,25 @@ function applyCondition(condition, target, params, element) {
|
|
|
428
438
|
return;
|
|
429
439
|
}
|
|
430
440
|
const values = target.ExpressionAttributeValues ??= {};
|
|
441
|
+
if (condition.kind === "raw") {
|
|
442
|
+
Object.assign(names, condition.names);
|
|
443
|
+
for (const [alias, val] of Object.entries(condition.values)) {
|
|
444
|
+
values[alias] = resolveRawConditionValue(val, params, element);
|
|
445
|
+
}
|
|
446
|
+
target.ConditionExpression = condition.expression;
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (condition.kind === "expr") {
|
|
450
|
+
const concrete = resolveConditionTree(
|
|
451
|
+
condition.declarative,
|
|
452
|
+
(name) => resolveValue(`{${name}}`, params, element)
|
|
453
|
+
);
|
|
454
|
+
const compiled = buildConditionExpression(concrete);
|
|
455
|
+
Object.assign(names, compiled.names);
|
|
456
|
+
Object.assign(values, compiled.values);
|
|
457
|
+
target.ConditionExpression = compiled.expression;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
431
460
|
const clauses = [];
|
|
432
461
|
let i = 0;
|
|
433
462
|
for (const [field2, tmpl] of Object.entries(condition.fields)) {
|
|
@@ -832,11 +861,88 @@ function entityRef(model2) {
|
|
|
832
861
|
}
|
|
833
862
|
function collectConditionParams(condition, out) {
|
|
834
863
|
if (condition === void 0) return;
|
|
864
|
+
if (isRawCondition(condition)) {
|
|
865
|
+
for (const { name, param: param2 } of collectRawConditionParams(condition)) {
|
|
866
|
+
out[name] = descriptorFromParam(name, param2, out[name]);
|
|
867
|
+
}
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
835
870
|
const obj = condition;
|
|
836
871
|
if (obj.notExists === true) return;
|
|
837
872
|
if (typeof obj.attributeExists === "string") return;
|
|
838
873
|
if (typeof obj.attributeNotExists === "string") return;
|
|
839
|
-
|
|
874
|
+
collectConditionTreeParams(obj, out);
|
|
875
|
+
}
|
|
876
|
+
var SINGLE_OPERAND_OPS = /* @__PURE__ */ new Set([
|
|
877
|
+
"eq",
|
|
878
|
+
"ne",
|
|
879
|
+
"gt",
|
|
880
|
+
"ge",
|
|
881
|
+
"lt",
|
|
882
|
+
"le",
|
|
883
|
+
"beginsWith",
|
|
884
|
+
"contains",
|
|
885
|
+
"notContains",
|
|
886
|
+
"attributeType",
|
|
887
|
+
"size"
|
|
888
|
+
]);
|
|
889
|
+
function collectConditionTreeParams(obj, out) {
|
|
890
|
+
for (const [key2, value] of Object.entries(obj)) {
|
|
891
|
+
if (value === void 0) continue;
|
|
892
|
+
if (key2 === "and" || key2 === "or") {
|
|
893
|
+
for (const sub of value) {
|
|
894
|
+
if (isRawCondition(sub)) {
|
|
895
|
+
for (const { name, param: param2 } of collectRawConditionParams(sub)) {
|
|
896
|
+
out[name] = descriptorFromParam(name, param2, out[name]);
|
|
897
|
+
}
|
|
898
|
+
continue;
|
|
899
|
+
}
|
|
900
|
+
collectConditionTreeParams(sub, out);
|
|
901
|
+
}
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
if (key2 === "not") {
|
|
905
|
+
if (isRawCondition(value)) {
|
|
906
|
+
for (const { name, param: param2 } of collectRawConditionParams(value)) {
|
|
907
|
+
out[name] = descriptorFromParam(name, param2, out[name]);
|
|
908
|
+
}
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
collectConditionTreeParams(value, out);
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
914
|
+
if (isParam(value)) {
|
|
915
|
+
out[key2] = descriptorFromParam(key2, value, out[key2]);
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
if (value === null || typeof value !== "object" || value instanceof Date) {
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
const ops = value;
|
|
922
|
+
for (const [op, opVal] of Object.entries(ops)) {
|
|
923
|
+
if (op === "between") {
|
|
924
|
+
const [lo, hi] = opVal;
|
|
925
|
+
if (isParam(lo)) {
|
|
926
|
+
const n = conditionParamName(key2, op, 0);
|
|
927
|
+
out[n] = descriptorFromParam(n, lo, out[n]);
|
|
928
|
+
}
|
|
929
|
+
if (isParam(hi)) {
|
|
930
|
+
const n = conditionParamName(key2, op, 1);
|
|
931
|
+
out[n] = descriptorFromParam(n, hi, out[n]);
|
|
932
|
+
}
|
|
933
|
+
} else if (op === "in") {
|
|
934
|
+
opVal.forEach((v, i) => {
|
|
935
|
+
if (isParam(v)) {
|
|
936
|
+
const n = conditionParamName(key2, op, i);
|
|
937
|
+
out[n] = descriptorFromParam(n, v, out[n]);
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
} else if (SINGLE_OPERAND_OPS.has(op) && isParam(opVal)) {
|
|
941
|
+
const n = conditionParamName(key2, op);
|
|
942
|
+
out[n] = descriptorFromParam(n, opVal, out[n]);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
840
946
|
}
|
|
841
947
|
function makeDefinition(model2, operation, key2, select, changes, condition) {
|
|
842
948
|
const params = collectParams(key2);
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as Executor, D as DynamoDBOperation, a as ExecutorResult, B as BatchGetExecInput, P as PutInput, W as WriteExecOptions, b as WriteResult, U as UpdateInput, c as DeleteInput, d as BatchWriteExecItem, T as TransactWriteExecItem, M as ModelStatic, e as DDBModel, C as ChangeEvent } from '../types-
|
|
1
|
+
import { E as Executor, D as DynamoDBOperation, a as ExecutorResult, B as BatchGetExecInput, P as PutInput, W as WriteExecOptions, b as WriteResult, U as UpdateInput, c as DeleteInput, d as BatchWriteExecItem, T as TransactWriteExecItem, M as ModelStatic, e as DDBModel, C as ChangeEvent } from '../types-SKxZQbQO.js';
|
|
2
2
|
import '@aws-sdk/client-dynamodb';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/testing/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCdcEmulator
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-27XBTYVK.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientManager,
|
|
6
6
|
MetadataRegistry,
|
|
7
7
|
TableMapping,
|
|
8
8
|
resolveModelClass
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-3MI43FHU.js";
|
|
10
10
|
|
|
11
11
|
// src/memory/memory-store.ts
|
|
12
12
|
function deepClone(value) {
|