@aws-amplify/datastore 3.14.4 → 3.14.5-unstable.4
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 +0 -8
- package/lib/authModeStrategies/defaultAuthStrategy.d.ts +2 -0
- package/lib/authModeStrategies/index.d.ts +2 -0
- package/lib/authModeStrategies/multiAuthStrategy.d.ts +13 -0
- package/lib/authModeStrategies/multiAuthStrategy.js +6 -64
- package/lib/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib/datastore/datastore.d.ts +207 -0
- package/lib/datastore/datastore.js +703 -297
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/index.d.ts +16 -0
- package/lib/index.js +6 -4
- package/lib/index.js.map +1 -1
- package/lib/predicates/index.d.ts +30 -0
- package/lib/predicates/index.js +127 -6
- package/lib/predicates/index.js.map +1 -1
- package/lib/predicates/next.d.ts +301 -0
- package/lib/predicates/next.js +816 -0
- package/lib/predicates/next.js.map +1 -0
- package/lib/predicates/sort.d.ts +8 -0
- package/lib/predicates/sort.js +10 -4
- package/lib/predicates/sort.js.map +1 -1
- package/lib/ssr/index.d.ts +3 -0
- package/lib/storage/adapter/AsyncStorageAdapter.d.ts +42 -0
- package/lib/storage/adapter/AsyncStorageAdapter.js +141 -382
- package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib/storage/adapter/AsyncStorageDatabase.d.ts +39 -0
- package/lib/storage/adapter/AsyncStorageDatabase.js +37 -98
- package/lib/storage/adapter/AsyncStorageDatabase.js.map +1 -1
- package/lib/storage/adapter/InMemoryStore.d.ts +11 -0
- package/lib/storage/adapter/InMemoryStore.js +16 -67
- package/lib/storage/adapter/InMemoryStore.js.map +1 -1
- package/lib/storage/adapter/InMemoryStore.native.d.ts +1 -0
- package/lib/storage/adapter/InMemoryStore.native.js +2 -4
- package/lib/storage/adapter/InMemoryStore.native.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.d.ts +61 -0
- package/lib/storage/adapter/IndexedDBAdapter.js +275 -419
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib/storage/adapter/getDefaultAdapter/index.d.ts +3 -0
- package/lib/storage/adapter/getDefaultAdapter/index.js +3 -5
- package/lib/storage/adapter/getDefaultAdapter/index.js.map +1 -1
- package/lib/storage/adapter/getDefaultAdapter/index.native.d.ts +3 -0
- package/lib/storage/adapter/getDefaultAdapter/index.native.js +2 -4
- package/lib/storage/adapter/getDefaultAdapter/index.native.js.map +1 -1
- package/lib/storage/adapter/index.d.ts +9 -0
- package/lib/storage/relationship.d.ts +140 -0
- package/lib/storage/relationship.js +335 -0
- package/lib/storage/relationship.js.map +1 -0
- package/lib/storage/storage.d.ts +50 -0
- package/lib/storage/storage.js +72 -143
- package/lib/storage/storage.js.map +1 -1
- package/lib/sync/datastoreConnectivity.d.ts +16 -0
- package/lib/sync/datastoreConnectivity.js +6 -55
- package/lib/sync/datastoreConnectivity.js.map +1 -1
- package/lib/sync/datastoreReachability/index.d.ts +3 -0
- package/lib/sync/datastoreReachability/index.native.d.ts +3 -0
- package/lib/sync/datastoreReachability/index.native.js +2 -4
- package/lib/sync/datastoreReachability/index.native.js.map +1 -1
- package/lib/sync/index.d.ts +89 -0
- package/lib/sync/index.js +49 -124
- package/lib/sync/index.js.map +1 -1
- package/lib/sync/merger.d.ts +17 -0
- package/lib/sync/merger.js +8 -74
- package/lib/sync/merger.js.map +1 -1
- package/lib/sync/outbox.d.ts +27 -0
- package/lib/sync/outbox.js +24 -97
- package/lib/sync/outbox.js.map +1 -1
- package/lib/sync/processors/errorMaps.d.ts +17 -0
- package/lib/sync/processors/errorMaps.js +5 -35
- package/lib/sync/processors/errorMaps.js.map +1 -1
- package/lib/sync/processors/mutation.d.ts +58 -0
- package/lib/sync/processors/mutation.js +47 -131
- package/lib/sync/processors/mutation.js.map +1 -1
- package/lib/sync/processors/subscription.d.ts +33 -0
- package/lib/sync/processors/subscription.js +29 -102
- package/lib/sync/processors/subscription.js.map +1 -1
- package/lib/sync/processors/sync.d.ts +28 -0
- package/lib/sync/processors/sync.js +26 -102
- package/lib/sync/processors/sync.js.map +1 -1
- package/lib/sync/utils.d.ts +42 -0
- package/lib/sync/utils.js +40 -103
- package/lib/sync/utils.js.map +1 -1
- package/lib/types.d.ts +554 -0
- package/lib/types.js +9 -39
- package/lib/types.js.map +1 -1
- package/lib/util.d.ts +189 -0
- package/lib/util.js +192 -188
- package/lib/util.js.map +1 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +2 -57
- package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib-esm/datastore/datastore.d.ts +59 -8
- package/lib-esm/datastore/datastore.js +642 -234
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/index.d.ts +3 -2
- package/lib-esm/index.js +2 -1
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/predicates/index.d.ts +16 -2
- package/lib-esm/predicates/index.js +128 -7
- package/lib-esm/predicates/index.js.map +1 -1
- package/lib-esm/predicates/next.d.ts +301 -0
- package/lib-esm/predicates/next.js +812 -0
- package/lib-esm/predicates/next.js.map +1 -0
- package/lib-esm/predicates/sort.js +10 -4
- package/lib-esm/predicates/sort.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.d.ts +2 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +112 -350
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +7 -68
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +1 -1
- package/lib-esm/storage/adapter/InMemoryStore.d.ts +1 -1
- package/lib-esm/storage/adapter/InMemoryStore.js +1 -52
- package/lib-esm/storage/adapter/InMemoryStore.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.d.ts +4 -2
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +230 -367
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js.map +1 -1
- package/lib-esm/storage/relationship.d.ts +140 -0
- package/lib-esm/storage/relationship.js +333 -0
- package/lib-esm/storage/relationship.js.map +1 -0
- package/lib-esm/storage/storage.d.ts +7 -6
- package/lib-esm/storage/storage.js +33 -101
- package/lib-esm/storage/storage.js.map +1 -1
- package/lib-esm/sync/datastoreConnectivity.js +1 -47
- package/lib-esm/sync/datastoreConnectivity.js.map +1 -1
- package/lib-esm/sync/index.js +4 -76
- package/lib-esm/sync/index.js.map +1 -1
- package/lib-esm/sync/merger.js +1 -67
- package/lib-esm/sync/merger.js.map +1 -1
- package/lib-esm/sync/outbox.js +1 -74
- package/lib-esm/sync/outbox.js.map +1 -1
- package/lib-esm/sync/processors/errorMaps.js +2 -32
- package/lib-esm/sync/processors/errorMaps.js.map +1 -1
- package/lib-esm/sync/processors/mutation.js +12 -93
- package/lib-esm/sync/processors/mutation.js.map +1 -1
- package/lib-esm/sync/processors/subscription.js +6 -69
- package/lib-esm/sync/processors/subscription.js.map +1 -1
- package/lib-esm/sync/processors/sync.js +2 -75
- package/lib-esm/sync/processors/sync.js.map +1 -1
- package/lib-esm/sync/utils.d.ts +1 -1
- package/lib-esm/sync/utils.js +32 -95
- package/lib-esm/sync/utils.js.map +1 -1
- package/lib-esm/types.d.ts +63 -10
- package/lib-esm/types.js +7 -38
- package/lib-esm/types.js.map +1 -1
- package/lib-esm/util.d.ts +39 -6
- package/lib-esm/util.js +171 -171
- package/lib-esm/util.js.map +1 -1
- package/package.json +21 -14
- package/src/authModeStrategies/multiAuthStrategy.ts +2 -2
- package/src/datastore/datastore.ts +699 -206
- package/src/index.ts +4 -0
- package/src/predicates/index.ts +143 -17
- package/src/predicates/next.ts +967 -0
- package/src/predicates/sort.ts +8 -2
- package/src/storage/adapter/AsyncStorageAdapter.ts +59 -181
- package/src/storage/adapter/AsyncStorageDatabase.ts +16 -15
- package/src/storage/adapter/InMemoryStore.ts +5 -2
- package/src/storage/adapter/IndexedDBAdapter.ts +169 -192
- package/src/storage/adapter/getDefaultAdapter/index.ts +2 -2
- package/src/storage/relationship.ts +272 -0
- package/src/storage/storage.ts +56 -37
- package/src/sync/datastoreConnectivity.ts +4 -4
- package/src/sync/index.ts +22 -28
- package/src/sync/merger.ts +1 -1
- package/src/sync/outbox.ts +6 -6
- package/src/sync/processors/errorMaps.ts +1 -1
- package/src/sync/processors/mutation.ts +23 -19
- package/src/sync/processors/subscription.ts +20 -16
- package/src/sync/processors/sync.ts +17 -17
- package/src/sync/utils.ts +42 -48
- package/src/types.ts +128 -16
- package/src/util.ts +108 -150
- package/build.js +0 -5
- package/dist/aws-amplify-datastore.js +0 -92787
- package/dist/aws-amplify-datastore.js.map +0 -1
- package/dist/aws-amplify-datastore.min.js +0 -66
- package/dist/aws-amplify-datastore.min.js.map +0 -1
- package/index.js +0 -7
- package/webpack.config.dev.js +0 -6
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { Scalar, PersistentModel, ModelMeta, AllOperators, PredicateFieldType, ModelPredicate as StoragePredicate } from '../types';
|
|
2
|
+
import { ExclusiveStorage as StorageAdapter } from '../storage/storage';
|
|
3
|
+
declare type MatchableTypes = string | string[] | number | number[] | boolean | boolean[];
|
|
4
|
+
declare type AllFieldOperators = keyof AllOperators;
|
|
5
|
+
declare type NonNeverKeys<T> = {
|
|
6
|
+
[K in keyof T]: T[K] extends never ? never : K;
|
|
7
|
+
}[keyof T];
|
|
8
|
+
declare type WithoutNevers<T> = Pick<T, NonNeverKeys<T>>;
|
|
9
|
+
/**
|
|
10
|
+
* A function that accepts a RecursiveModelPrecicate<T>, which it must use to
|
|
11
|
+
* return a final condition.
|
|
12
|
+
*
|
|
13
|
+
* This is used in `DataStore.query()`, `DataStore.observe()`, and
|
|
14
|
+
* `DataStore.observeQuery()` as the second argument. E.g.,
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* DataStore.query(MyModel, model => model.field.eq('some value'))
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* More complex queries should also be supported. E.g.,
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* DataStore.query(MyModel, model => model.and(m => [
|
|
24
|
+
* m.relatedEntity.or(relative => [
|
|
25
|
+
* relative.relativeField.eq('whatever'),
|
|
26
|
+
* relative.relativeField.eq('whatever else')
|
|
27
|
+
* ]),
|
|
28
|
+
* m.myModelField.ne('something')
|
|
29
|
+
* ]))
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare type RecursiveModelPredicateExtender<RT extends PersistentModel> = (lambda: RecursiveModelPredicate<RT>) => PredicateInternalsKey;
|
|
33
|
+
export declare type RecursiveModelPredicateAggregateExtender<RT extends PersistentModel> = (lambda: RecursiveModelPredicate<RT>) => PredicateInternalsKey[];
|
|
34
|
+
declare type RecursiveModelPredicateOperator<RT extends PersistentModel> = (predicates: RecursiveModelPredicateAggregateExtender<RT>) => PredicateInternalsKey;
|
|
35
|
+
declare type RecursiveModelPredicateNegation<RT extends PersistentModel> = (predicate: RecursiveModelPredicateExtender<RT>) => PredicateInternalsKey;
|
|
36
|
+
export declare type RecursiveModelPredicate<RT extends PersistentModel> = {
|
|
37
|
+
[K in keyof RT]-?: PredicateFieldType<RT[K]> extends PersistentModel ? RecursiveModelPredicate<PredicateFieldType<RT[K]>> : ValuePredicate<RT, RT[K]>;
|
|
38
|
+
} & {
|
|
39
|
+
or: RecursiveModelPredicateOperator<RT>;
|
|
40
|
+
and: RecursiveModelPredicateOperator<RT>;
|
|
41
|
+
not: RecursiveModelPredicateNegation<RT>;
|
|
42
|
+
} & PredicateInternalsKey;
|
|
43
|
+
/**
|
|
44
|
+
* A function that accepts a ModelPrecicate<T>, which it must use to return a
|
|
45
|
+
* final condition.
|
|
46
|
+
*
|
|
47
|
+
* This is used as predicates in `DataStore.save()`, `DataStore.delete()`, and
|
|
48
|
+
* DataStore sync expressions.
|
|
49
|
+
*
|
|
50
|
+
* ```
|
|
51
|
+
* DataStore.save(record, model => model.field.eq('some value'))
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Logical operators are supported. But, condtiions are related records are
|
|
55
|
+
* NOT supported. E.g.,
|
|
56
|
+
*
|
|
57
|
+
* ```
|
|
58
|
+
* DataStore.delete(record, model => model.or(m => [
|
|
59
|
+
* m.field.eq('whatever'),
|
|
60
|
+
* m.field.eq('whatever else')
|
|
61
|
+
* ]))
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare type ModelPredicateExtender<RT extends PersistentModel> = (lambda: ModelPredicate<RT>) => PredicateInternalsKey;
|
|
65
|
+
export declare type ModelPredicateAggregateExtender<RT extends PersistentModel> = (lambda: ModelPredicate<RT>) => PredicateInternalsKey[];
|
|
66
|
+
declare type ValuePredicate<RT extends PersistentModel, MT extends MatchableTypes> = {
|
|
67
|
+
[K in AllFieldOperators]: K extends 'between' ? (inclusiveLowerBound: Scalar<MT>, inclusiveUpperBound: Scalar<MT>) => PredicateInternalsKey : (operand: Scalar<MT>) => PredicateInternalsKey;
|
|
68
|
+
};
|
|
69
|
+
export declare type ModelPredicate<RT extends PersistentModel> = WithoutNevers<{
|
|
70
|
+
[K in keyof RT]-?: PredicateFieldType<RT[K]> extends PersistentModel ? never : ValuePredicate<RT, RT[K]>;
|
|
71
|
+
}> & {
|
|
72
|
+
or: ModelPredicateOperator<RT>;
|
|
73
|
+
and: ModelPredicateOperator<RT>;
|
|
74
|
+
not: ModelPredicateNegation<RT>;
|
|
75
|
+
} & PredicateInternalsKey;
|
|
76
|
+
declare type ModelPredicateOperator<RT extends PersistentModel> = (predicates: ModelPredicateAggregateExtender<RT>) => PredicateInternalsKey;
|
|
77
|
+
declare type ModelPredicateNegation<RT extends PersistentModel> = (predicate: ModelPredicateExtender<RT>) => PredicateInternalsKey;
|
|
78
|
+
declare type GroupOperator = 'and' | 'or' | 'not';
|
|
79
|
+
declare type UntypedCondition = {
|
|
80
|
+
fetch: (storage: StorageAdapter) => Promise<Record<string, any>[]>;
|
|
81
|
+
matches: (item: Record<string, any>) => Promise<boolean>;
|
|
82
|
+
copy(extract: GroupCondition): [UntypedCondition, GroupCondition | undefined];
|
|
83
|
+
toAST(): any;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A pointer used by DataStore internally to lookup predicate details
|
|
87
|
+
* that should not be exposed on public customer interfaces.
|
|
88
|
+
*/
|
|
89
|
+
export declare class PredicateInternalsKey {
|
|
90
|
+
private __isPredicateInternalsKeySentinel;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Takes a key object from `registerPredicateInternals()` to fetch an internal
|
|
94
|
+
* `GroupCondition` object, which can then be used to query storage or
|
|
95
|
+
* test/match objects.
|
|
96
|
+
*
|
|
97
|
+
* This indirection exists to hide `GroupCondition` from public interfaces, since
|
|
98
|
+
* `GroupCondition` contains extra methods and properties that public callers
|
|
99
|
+
* should not use.
|
|
100
|
+
*
|
|
101
|
+
* @param key A key object previously returned by `registerPredicateInternals()`
|
|
102
|
+
*/
|
|
103
|
+
export declare const internals: (key: any) => GroupCondition;
|
|
104
|
+
/**
|
|
105
|
+
* A condition that can operate against a single "primitive" field of a model or item.
|
|
106
|
+
* @member field The field of *some record* to test against.
|
|
107
|
+
* @member operator The equality or comparison operator to use.
|
|
108
|
+
* @member operands The operands for the equality/comparison check.
|
|
109
|
+
*/
|
|
110
|
+
export declare class FieldCondition {
|
|
111
|
+
field: string;
|
|
112
|
+
operator: string;
|
|
113
|
+
operands: string[];
|
|
114
|
+
constructor(field: string, operator: string, operands: string[]);
|
|
115
|
+
/**
|
|
116
|
+
* Creates a copy of self.
|
|
117
|
+
* @param extract Not used. Present only to fulfill the `UntypedCondition` interface.
|
|
118
|
+
* @returns A new, identitical `FieldCondition`.
|
|
119
|
+
*/
|
|
120
|
+
copy(extract: GroupCondition): [FieldCondition, GroupCondition | undefined];
|
|
121
|
+
toAST(): {
|
|
122
|
+
[x: string]: {
|
|
123
|
+
[x: string]: string | string[];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Not implemented. Not needed. GroupCondition instead consumes FieldConditions and
|
|
128
|
+
* transforms them into legacy predicates. (*For now.*)
|
|
129
|
+
* @param storage N/A. If ever implemented, the storage adapter to query.
|
|
130
|
+
* @returns N/A. If ever implemented, return items from `storage` that match.
|
|
131
|
+
*/
|
|
132
|
+
fetch(storage: StorageAdapter): Promise<Record<string, any>[]>;
|
|
133
|
+
/**
|
|
134
|
+
* Determins whether a given item matches the expressed condition.
|
|
135
|
+
* @param item The item to test.
|
|
136
|
+
* @returns `Promise<boolean>`, `true` if matches; `false` otherwise.
|
|
137
|
+
*/
|
|
138
|
+
matches(item: Record<string, any>): Promise<boolean>;
|
|
139
|
+
/**
|
|
140
|
+
* Checks `this.operands` for compatibility with `this.operator`.
|
|
141
|
+
*/
|
|
142
|
+
validate(): void;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A set of sub-conditions to operate against a model, optionally scoped to
|
|
146
|
+
* a specific field, combined with the given operator (one of `and`, `or`, or `not`).
|
|
147
|
+
* @member groupId Used to distinguish between GroupCondition instances for
|
|
148
|
+
* debugging and troublehsooting.
|
|
149
|
+
* @member model A metadata object that tells GroupCondition what to query and how.
|
|
150
|
+
* @member field The field on the model that the sub-conditions apply to.
|
|
151
|
+
* @member operator How to group child conditions together.
|
|
152
|
+
* @member operands The child conditions.
|
|
153
|
+
*/
|
|
154
|
+
export declare class GroupCondition {
|
|
155
|
+
/**
|
|
156
|
+
* The `ModelMeta` of the model to query and/or filter against.
|
|
157
|
+
* Expected to contain:
|
|
158
|
+
*
|
|
159
|
+
* ```js
|
|
160
|
+
* {
|
|
161
|
+
* builder: ModelConstructor,
|
|
162
|
+
* schema: SchemaModel,
|
|
163
|
+
* pkField: string[]
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
model: ModelMeta<any>;
|
|
168
|
+
/**
|
|
169
|
+
* If populated, this group specifices a condition on a relationship.
|
|
170
|
+
*
|
|
171
|
+
* If `field` does *not* point to a related model, that's an error. It
|
|
172
|
+
* could indicate that the `GroupCondition` was instantiated with bad
|
|
173
|
+
* data, or that the model metadata is incorrect.
|
|
174
|
+
*/
|
|
175
|
+
field: string | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* If a `field` is given, whether the relationship is a `HAS_ONE`,
|
|
178
|
+
* 'HAS_MANY`, or `BELONGS_TO`.
|
|
179
|
+
*
|
|
180
|
+
* TODO: Remove this and replace with derivation using
|
|
181
|
+
* `ModelRelationship.from(this.model, this.field).relationship`;
|
|
182
|
+
*/
|
|
183
|
+
relationshipType: string | undefined;
|
|
184
|
+
/**
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
operator: GroupOperator;
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
*/
|
|
191
|
+
operands: UntypedCondition[];
|
|
192
|
+
groupId: string;
|
|
193
|
+
constructor(
|
|
194
|
+
/**
|
|
195
|
+
* The `ModelMeta` of the model to query and/or filter against.
|
|
196
|
+
* Expected to contain:
|
|
197
|
+
*
|
|
198
|
+
* ```js
|
|
199
|
+
* {
|
|
200
|
+
* builder: ModelConstructor,
|
|
201
|
+
* schema: SchemaModel,
|
|
202
|
+
* pkField: string[]
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
model: ModelMeta<any>,
|
|
207
|
+
/**
|
|
208
|
+
* If populated, this group specifices a condition on a relationship.
|
|
209
|
+
*
|
|
210
|
+
* If `field` does *not* point to a related model, that's an error. It
|
|
211
|
+
* could indicate that the `GroupCondition` was instantiated with bad
|
|
212
|
+
* data, or that the model metadata is incorrect.
|
|
213
|
+
*/
|
|
214
|
+
field: string | undefined,
|
|
215
|
+
/**
|
|
216
|
+
* If a `field` is given, whether the relationship is a `HAS_ONE`,
|
|
217
|
+
* 'HAS_MANY`, or `BELONGS_TO`.
|
|
218
|
+
*
|
|
219
|
+
* TODO: Remove this and replace with derivation using
|
|
220
|
+
* `ModelRelationship.from(this.model, this.field).relationship`;
|
|
221
|
+
*/
|
|
222
|
+
relationshipType: string | undefined,
|
|
223
|
+
/**
|
|
224
|
+
*
|
|
225
|
+
*/
|
|
226
|
+
operator: GroupOperator,
|
|
227
|
+
/**
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
operands: UntypedCondition[]);
|
|
231
|
+
/**
|
|
232
|
+
* Returns a copy of a GroupCondition, which also returns the copy of a
|
|
233
|
+
* given reference node to "extract".
|
|
234
|
+
* @param extract A node of interest. Its copy will *also* be returned if the node exists.
|
|
235
|
+
* @returns [The full copy, the copy of `extract` | undefined]
|
|
236
|
+
*/
|
|
237
|
+
copy(extract: GroupCondition): [GroupCondition, GroupCondition | undefined];
|
|
238
|
+
/**
|
|
239
|
+
* Fetches matching records from a given storage adapter using legacy predicates (for now).
|
|
240
|
+
* @param storage The storage adapter this predicate will query against.
|
|
241
|
+
* @param breadcrumb For debugging/troubleshooting. A list of the `groupId`'s this
|
|
242
|
+
* GroupdCondition.fetch is nested within.
|
|
243
|
+
* @param negate Whether to match on the `NOT` of `this`.
|
|
244
|
+
* @returns An `Promise` of `any[]` from `storage` matching the child conditions.
|
|
245
|
+
*/
|
|
246
|
+
fetch(storage: StorageAdapter, breadcrumb?: string[], negate?: boolean): Promise<Record<string, any>[]>;
|
|
247
|
+
/**
|
|
248
|
+
* Determines whether a single item matches the conditions of `this`.
|
|
249
|
+
* When checking the target `item`'s properties, each property will be `await`'d
|
|
250
|
+
* to ensure lazy-loading is respected where applicable.
|
|
251
|
+
* @param item The item to match against.
|
|
252
|
+
* @param ignoreFieldName Tells `match()` that the field name has already been dereferenced.
|
|
253
|
+
* (Used for iterating over children on HAS_MANY checks.)
|
|
254
|
+
* @returns A boolean (promise): `true` if matched, `false` otherwise.
|
|
255
|
+
*/
|
|
256
|
+
matches(item: Record<string, any>, ignoreFieldName?: boolean): Promise<boolean>;
|
|
257
|
+
/**
|
|
258
|
+
* Tranfsorm to a AppSync GraphQL compatible AST.
|
|
259
|
+
* (Does not support filtering in nested types.)
|
|
260
|
+
*/
|
|
261
|
+
toAST(): {
|
|
262
|
+
[x: string]: any[];
|
|
263
|
+
};
|
|
264
|
+
toStoragePredicate<T>(baseCondition?: StoragePredicate<T>): StoragePredicate<T>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Creates a "seed" predicate that can be used to build an executable condition.
|
|
268
|
+
* This is used in `query()`, for example, to seed customer- E.g.,
|
|
269
|
+
*
|
|
270
|
+
* ```
|
|
271
|
+
* const p = predicateFor({builder: modelConstructor, schema: modelSchema, pkField: string[]});
|
|
272
|
+
* p.and(child => [
|
|
273
|
+
* child.field.eq('whatever'),
|
|
274
|
+
* child.childModel.childField.eq('whatever else'),
|
|
275
|
+
* child.childModel.or(child => [
|
|
276
|
+
* child.otherField.contains('x'),
|
|
277
|
+
* child.otherField.contains('y'),
|
|
278
|
+
* child.otherField.contains('z'),
|
|
279
|
+
* ])
|
|
280
|
+
* ])
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* `predicateFor()` returns objecst with recursive getters. To facilitate this,
|
|
284
|
+
* a `query` and `tail` can be provided to "accumulate" nested conditions.
|
|
285
|
+
*
|
|
286
|
+
* TODO: the sortof-immutable algorithm was originally done to support legacy style
|
|
287
|
+
* predicate branching (`p => p.x.eq(value).y.eq(value)`). i'm not sure this is
|
|
288
|
+
* necessary or beneficial at this point, since we decided that each field condition
|
|
289
|
+
* must flly terminate a branch. is the strong mutation barrier between chain links
|
|
290
|
+
* still necessary or helpful?
|
|
291
|
+
*
|
|
292
|
+
* @param ModelType The ModelMeta used to build child properties.
|
|
293
|
+
* @param field Scopes the query branch to a field.
|
|
294
|
+
* @param query A base query to build on. Omit to start a new query.
|
|
295
|
+
* @param tail The point in an existing `query` to attach new conditions to.
|
|
296
|
+
* @returns A ModelPredicate (builder) that customers can create queries with.
|
|
297
|
+
* (As shown in function description.)
|
|
298
|
+
*/
|
|
299
|
+
export declare function recursivePredicateFor<T extends PersistentModel>(ModelType: ModelMeta<T>, allowRecursion?: boolean, field?: string, query?: GroupCondition, tail?: GroupCondition): RecursiveModelPredicate<T> & PredicateInternalsKey;
|
|
300
|
+
export declare function predicateFor<T extends PersistentModel>(ModelType: ModelMeta<T>): ModelPredicate<T> & PredicateInternalsKey;
|
|
301
|
+
export {};
|