@aws-amplify/datastore 5.0.46 → 5.0.47
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/cjs/types.js +109 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/types.d.ts +109 -0
- package/dist/esm/types.mjs +109 -0
- package/dist/esm/types.mjs.map +1 -1
- package/package.json +4 -4
- package/src/types.ts +113 -0
package/dist/cjs/types.js
CHANGED
|
@@ -3,26 +3,57 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.PredicateInternalsKey = exports.LimitTimerRaceResolvedValues = exports.DISCARD = exports.ProcessName = exports.syncExpression = exports.ModelOperation = exports.AuthModeStrategyType = exports.SortDirection = exports.QueryOne = exports.isPredicateGroup = exports.isPredicateObj = exports.OpType = exports.isIdentifierObject = exports.isEnumFieldType = exports.isNonModelFieldType = exports.isModelFieldType = exports.isGraphQLScalarType = exports.GraphQLScalarType = exports.ModelAttributeAuthProvider = exports.ModelAttributeAuthAllow = exports.isModelAttributeCompositeKey = exports.isModelAttributePrimaryKey = exports.isModelAttributeKey = exports.isModelAttributeAuth = exports.isFieldAssociation = exports.isTargetNameAssociation = exports.isAssociatedWith = exports.isSchemaModelWithAttributes = exports.isSchemaModel = void 0;
|
|
5
5
|
const util_1 = require("./util");
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @param obj
|
|
9
|
+
* @returns `true` if the given object likely represents a model in a schema.
|
|
10
|
+
*/
|
|
6
11
|
function isSchemaModel(obj) {
|
|
7
12
|
return obj && obj.pluralName !== undefined;
|
|
8
13
|
}
|
|
9
14
|
exports.isSchemaModel = isSchemaModel;
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* @param m
|
|
18
|
+
* @returns `true` if the given schema entry defines Schema Model attributes.
|
|
19
|
+
*/
|
|
10
20
|
function isSchemaModelWithAttributes(m) {
|
|
11
21
|
return isSchemaModel(m) && m.attributes !== undefined;
|
|
12
22
|
}
|
|
13
23
|
exports.isSchemaModelWithAttributes = isSchemaModelWithAttributes;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @param obj
|
|
27
|
+
* @returns `true` if the object is an `AssociatedWith` definition.
|
|
28
|
+
*/
|
|
14
29
|
function isAssociatedWith(obj) {
|
|
15
30
|
return obj && obj.associatedWith;
|
|
16
31
|
}
|
|
17
32
|
exports.isAssociatedWith = isAssociatedWith;
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
* @param obj
|
|
36
|
+
* @returns `true` if the given object specifies either `targetName` or `targetNames`.
|
|
37
|
+
*/
|
|
18
38
|
function isTargetNameAssociation(obj) {
|
|
19
39
|
return obj?.targetName || obj?.targetNames;
|
|
20
40
|
}
|
|
21
41
|
exports.isTargetNameAssociation = isTargetNameAssociation;
|
|
42
|
+
/**
|
|
43
|
+
* @private
|
|
44
|
+
* @param obj
|
|
45
|
+
* @param fieldName
|
|
46
|
+
* @returns Truthy if the object has a `FieldAssociation` for the given `fieldName`.
|
|
47
|
+
*/
|
|
22
48
|
function isFieldAssociation(obj, fieldName) {
|
|
23
49
|
return obj?.fields[fieldName]?.association?.connectionType;
|
|
24
50
|
}
|
|
25
51
|
exports.isFieldAssociation = isFieldAssociation;
|
|
52
|
+
/**
|
|
53
|
+
* @private
|
|
54
|
+
* @param attr
|
|
55
|
+
* @returns `true` if the given attribute is an auth attribute with rules.
|
|
56
|
+
*/
|
|
26
57
|
function isModelAttributeAuth(attr) {
|
|
27
58
|
return (attr.type === 'auth' &&
|
|
28
59
|
attr.properties &&
|
|
@@ -30,6 +61,11 @@ function isModelAttributeAuth(attr) {
|
|
|
30
61
|
attr.properties.rules.length > 0);
|
|
31
62
|
}
|
|
32
63
|
exports.isModelAttributeAuth = isModelAttributeAuth;
|
|
64
|
+
/**
|
|
65
|
+
* @private
|
|
66
|
+
* @param attr
|
|
67
|
+
* @returns `true` if the given attribute is a key field.
|
|
68
|
+
*/
|
|
33
69
|
function isModelAttributeKey(attr) {
|
|
34
70
|
return (attr.type === 'key' &&
|
|
35
71
|
attr.properties &&
|
|
@@ -37,10 +73,20 @@ function isModelAttributeKey(attr) {
|
|
|
37
73
|
attr.properties.fields.length > 0);
|
|
38
74
|
}
|
|
39
75
|
exports.isModelAttributeKey = isModelAttributeKey;
|
|
76
|
+
/**
|
|
77
|
+
* @private
|
|
78
|
+
* @param attr
|
|
79
|
+
* @returns `true` if the given attribute is a primary key, indicated by the key being unnamed.
|
|
80
|
+
*/
|
|
40
81
|
function isModelAttributePrimaryKey(attr) {
|
|
41
82
|
return isModelAttributeKey(attr) && attr.properties.name === undefined;
|
|
42
83
|
}
|
|
43
84
|
exports.isModelAttributePrimaryKey = isModelAttributePrimaryKey;
|
|
85
|
+
/**
|
|
86
|
+
* @private
|
|
87
|
+
* @param attr
|
|
88
|
+
* @returns `true` if the given attribute represents a composite key with multiple fields.
|
|
89
|
+
*/
|
|
44
90
|
function isModelAttributeCompositeKey(attr) {
|
|
45
91
|
return (isModelAttributeKey(attr) &&
|
|
46
92
|
attr.properties.name !== undefined &&
|
|
@@ -131,10 +177,19 @@ var GraphQLScalarType;
|
|
|
131
177
|
}
|
|
132
178
|
GraphQLScalarType.getValidationFunction = getValidationFunction;
|
|
133
179
|
})(GraphQLScalarType = exports.GraphQLScalarType || (exports.GraphQLScalarType = {}));
|
|
180
|
+
/**
|
|
181
|
+
* @private
|
|
182
|
+
* @returns `true` if the given field specifies a scalar type.
|
|
183
|
+
*/
|
|
134
184
|
function isGraphQLScalarType(obj) {
|
|
135
185
|
return obj && GraphQLScalarType[obj] !== undefined;
|
|
136
186
|
}
|
|
137
187
|
exports.isGraphQLScalarType = isGraphQLScalarType;
|
|
188
|
+
/**
|
|
189
|
+
* @private
|
|
190
|
+
* @param obj
|
|
191
|
+
* @returns `true` if the given field specifies a Model.
|
|
192
|
+
*/
|
|
138
193
|
function isModelFieldType(obj) {
|
|
139
194
|
const modelField = 'model';
|
|
140
195
|
if (obj && obj[modelField])
|
|
@@ -142,6 +197,11 @@ function isModelFieldType(obj) {
|
|
|
142
197
|
return false;
|
|
143
198
|
}
|
|
144
199
|
exports.isModelFieldType = isModelFieldType;
|
|
200
|
+
/**
|
|
201
|
+
* @private
|
|
202
|
+
* @param obj
|
|
203
|
+
* @returns `true` if the given field specifies a custom non-model type.
|
|
204
|
+
*/
|
|
145
205
|
function isNonModelFieldType(obj) {
|
|
146
206
|
const typeField = 'nonModel';
|
|
147
207
|
if (obj && obj[typeField])
|
|
@@ -149,6 +209,11 @@ function isNonModelFieldType(obj) {
|
|
|
149
209
|
return false;
|
|
150
210
|
}
|
|
151
211
|
exports.isNonModelFieldType = isNonModelFieldType;
|
|
212
|
+
/**
|
|
213
|
+
* @private
|
|
214
|
+
* @param obj
|
|
215
|
+
* @returns `true` if the object is an `EnumFieldType`.
|
|
216
|
+
*/
|
|
152
217
|
function isEnumFieldType(obj) {
|
|
153
218
|
const modelField = 'enum';
|
|
154
219
|
if (obj && obj[modelField])
|
|
@@ -156,6 +221,12 @@ function isEnumFieldType(obj) {
|
|
|
156
221
|
return false;
|
|
157
222
|
}
|
|
158
223
|
exports.isEnumFieldType = isEnumFieldType;
|
|
224
|
+
/**
|
|
225
|
+
* @private
|
|
226
|
+
* @param obj
|
|
227
|
+
* @param modelDefinition
|
|
228
|
+
* @returns `true` if the given item is an object that has all identifier fields populated.
|
|
229
|
+
*/
|
|
159
230
|
function isIdentifierObject(obj, modelDefinition) {
|
|
160
231
|
const keys = (0, util_1.extractPrimaryKeyFieldNames)(modelDefinition);
|
|
161
232
|
return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));
|
|
@@ -166,10 +237,20 @@ exports.isIdentifierObject = isIdentifierObject;
|
|
|
166
237
|
OpType["UPDATE"] = "UPDATE";
|
|
167
238
|
OpType["DELETE"] = "DELETE";
|
|
168
239
|
})(exports.OpType || (exports.OpType = {}));
|
|
240
|
+
/**
|
|
241
|
+
* @private
|
|
242
|
+
* @param obj
|
|
243
|
+
* @returns `true` if the given predicate field object, specifying an [in-]equality test against a field.
|
|
244
|
+
*/
|
|
169
245
|
function isPredicateObj(obj) {
|
|
170
246
|
return obj && obj.field !== undefined;
|
|
171
247
|
}
|
|
172
248
|
exports.isPredicateObj = isPredicateObj;
|
|
249
|
+
/**
|
|
250
|
+
* @private
|
|
251
|
+
* @param obj
|
|
252
|
+
* @returns `true` if the given predicate object is a "group" like "and", "or", or "not".
|
|
253
|
+
*/
|
|
173
254
|
function isPredicateGroup(obj) {
|
|
174
255
|
return obj && obj.type !== undefined;
|
|
175
256
|
}
|
|
@@ -192,6 +273,34 @@ exports.isPredicateGroup = isPredicateGroup;
|
|
|
192
273
|
ModelOperation["UPDATE"] = "UPDATE";
|
|
193
274
|
ModelOperation["DELETE"] = "DELETE";
|
|
194
275
|
})(exports.ModelOperation || (exports.ModelOperation = {}));
|
|
276
|
+
/**
|
|
277
|
+
* Build an expression that can be used to filter which items of a given Model
|
|
278
|
+
* are synchronized down from the GraphQL service. E.g.,
|
|
279
|
+
*
|
|
280
|
+
* ```ts
|
|
281
|
+
* import { DataStore, syncExpression } from 'aws-amplify/datastore';
|
|
282
|
+
* import { Post, Comment } from './models';
|
|
283
|
+
*
|
|
284
|
+
*
|
|
285
|
+
* DataStore.configure({
|
|
286
|
+
* syncExpressions: [
|
|
287
|
+
* syncExpression(Post, () => {
|
|
288
|
+
* return (post) => post.rating.gt(5);
|
|
289
|
+
* }),
|
|
290
|
+
* syncExpression(Comment, () => {
|
|
291
|
+
* return (comment) => comment.status.eq('active');
|
|
292
|
+
* })
|
|
293
|
+
* ]
|
|
294
|
+
* });
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* When DataStore starts syncing, only Posts with `rating > 5` and Comments with
|
|
298
|
+
* `status === 'active'` will be synced down to the user's local store.
|
|
299
|
+
*
|
|
300
|
+
* @param modelConstructor The Model from the schema.
|
|
301
|
+
* @param conditionProducer A function that builds a condition object that can describe how to filter the model.
|
|
302
|
+
* @returns An sync expression object that can be attached to the DataStore `syncExpressions` configuration property.
|
|
303
|
+
*/
|
|
195
304
|
async function syncExpression(modelConstructor, conditionProducer) {
|
|
196
305
|
return {
|
|
197
306
|
modelConstructor,
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PredicateInternalsKey = exports.LimitTimerRaceResolvedValues = exports.DISCARD = exports.ProcessName = exports.syncExpression = exports.ModelOperation = exports.AuthModeStrategyType = exports.SortDirection = exports.QueryOne = exports.isPredicateGroup = exports.isPredicateObj = exports.OpType = exports.isIdentifierObject = exports.isEnumFieldType = exports.isNonModelFieldType = exports.isModelFieldType = exports.isGraphQLScalarType = exports.GraphQLScalarType = exports.ModelAttributeAuthProvider = exports.ModelAttributeAuthAllow = exports.isModelAttributeCompositeKey = exports.isModelAttributePrimaryKey = exports.isModelAttributeKey = exports.isModelAttributeAuth = exports.isFieldAssociation = exports.isTargetNameAssociation = exports.isAssociatedWith = exports.isSchemaModelWithAttributes = exports.isSchemaModel = void 0;\nconst util_1 = require(\"./util\");\nfunction isSchemaModel(obj) {\n return obj && obj.pluralName !== undefined;\n}\nexports.isSchemaModel = isSchemaModel;\nfunction isSchemaModelWithAttributes(m) {\n return isSchemaModel(m) && m.attributes !== undefined;\n}\nexports.isSchemaModelWithAttributes = isSchemaModelWithAttributes;\nfunction isAssociatedWith(obj) {\n return obj && obj.associatedWith;\n}\nexports.isAssociatedWith = isAssociatedWith;\nfunction isTargetNameAssociation(obj) {\n return obj?.targetName || obj?.targetNames;\n}\nexports.isTargetNameAssociation = isTargetNameAssociation;\nfunction isFieldAssociation(obj, fieldName) {\n return obj?.fields[fieldName]?.association?.connectionType;\n}\nexports.isFieldAssociation = isFieldAssociation;\nfunction isModelAttributeAuth(attr) {\n return (attr.type === 'auth' &&\n attr.properties &&\n attr.properties.rules &&\n attr.properties.rules.length > 0);\n}\nexports.isModelAttributeAuth = isModelAttributeAuth;\nfunction isModelAttributeKey(attr) {\n return (attr.type === 'key' &&\n attr.properties &&\n attr.properties.fields &&\n attr.properties.fields.length > 0);\n}\nexports.isModelAttributeKey = isModelAttributeKey;\nfunction isModelAttributePrimaryKey(attr) {\n return isModelAttributeKey(attr) && attr.properties.name === undefined;\n}\nexports.isModelAttributePrimaryKey = isModelAttributePrimaryKey;\nfunction isModelAttributeCompositeKey(attr) {\n return (isModelAttributeKey(attr) &&\n attr.properties.name !== undefined &&\n attr.properties.fields.length > 2);\n}\nexports.isModelAttributeCompositeKey = isModelAttributeCompositeKey;\nvar ModelAttributeAuthAllow;\n(function (ModelAttributeAuthAllow) {\n ModelAttributeAuthAllow[\"CUSTOM\"] = \"custom\";\n ModelAttributeAuthAllow[\"OWNER\"] = \"owner\";\n ModelAttributeAuthAllow[\"GROUPS\"] = \"groups\";\n ModelAttributeAuthAllow[\"PRIVATE\"] = \"private\";\n ModelAttributeAuthAllow[\"PUBLIC\"] = \"public\";\n})(ModelAttributeAuthAllow = exports.ModelAttributeAuthAllow || (exports.ModelAttributeAuthAllow = {}));\nvar ModelAttributeAuthProvider;\n(function (ModelAttributeAuthProvider) {\n ModelAttributeAuthProvider[\"FUNCTION\"] = \"function\";\n ModelAttributeAuthProvider[\"USER_POOLS\"] = \"userPools\";\n ModelAttributeAuthProvider[\"OIDC\"] = \"oidc\";\n ModelAttributeAuthProvider[\"IAM\"] = \"iam\";\n ModelAttributeAuthProvider[\"API_KEY\"] = \"apiKey\";\n})(ModelAttributeAuthProvider = exports.ModelAttributeAuthProvider || (exports.ModelAttributeAuthProvider = {}));\nvar GraphQLScalarType;\n(function (GraphQLScalarType) {\n GraphQLScalarType[GraphQLScalarType[\"ID\"] = 0] = \"ID\";\n GraphQLScalarType[GraphQLScalarType[\"String\"] = 1] = \"String\";\n GraphQLScalarType[GraphQLScalarType[\"Int\"] = 2] = \"Int\";\n GraphQLScalarType[GraphQLScalarType[\"Float\"] = 3] = \"Float\";\n GraphQLScalarType[GraphQLScalarType[\"Boolean\"] = 4] = \"Boolean\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDate\"] = 5] = \"AWSDate\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTime\"] = 6] = \"AWSTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDateTime\"] = 7] = \"AWSDateTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTimestamp\"] = 8] = \"AWSTimestamp\";\n GraphQLScalarType[GraphQLScalarType[\"AWSEmail\"] = 9] = \"AWSEmail\";\n GraphQLScalarType[GraphQLScalarType[\"AWSJSON\"] = 10] = \"AWSJSON\";\n GraphQLScalarType[GraphQLScalarType[\"AWSURL\"] = 11] = \"AWSURL\";\n GraphQLScalarType[GraphQLScalarType[\"AWSPhone\"] = 12] = \"AWSPhone\";\n GraphQLScalarType[GraphQLScalarType[\"AWSIPAddress\"] = 13] = \"AWSIPAddress\";\n})(GraphQLScalarType = exports.GraphQLScalarType || (exports.GraphQLScalarType = {}));\n// eslint-disable-next-line @typescript-eslint/no-namespace\n(function (GraphQLScalarType) {\n function getJSType(scalar) {\n switch (scalar) {\n case 'Boolean':\n return 'boolean';\n case 'ID':\n case 'String':\n case 'AWSDate':\n case 'AWSTime':\n case 'AWSDateTime':\n case 'AWSEmail':\n case 'AWSURL':\n case 'AWSPhone':\n case 'AWSIPAddress':\n return 'string';\n case 'Int':\n case 'Float':\n case 'AWSTimestamp':\n return 'number';\n case 'AWSJSON':\n return 'object';\n default:\n throw new Error('Invalid scalar type');\n }\n }\n GraphQLScalarType.getJSType = getJSType;\n function getValidationFunction(scalar) {\n switch (scalar) {\n case 'AWSDate':\n return util_1.isAWSDate;\n case 'AWSTime':\n return util_1.isAWSTime;\n case 'AWSDateTime':\n return util_1.isAWSDateTime;\n case 'AWSTimestamp':\n return util_1.isAWSTimestamp;\n case 'AWSEmail':\n return util_1.isAWSEmail;\n case 'AWSJSON':\n return util_1.isAWSJSON;\n case 'AWSURL':\n return util_1.isAWSURL;\n case 'AWSPhone':\n return util_1.isAWSPhone;\n case 'AWSIPAddress':\n return util_1.isAWSIPAddress;\n default:\n return undefined;\n }\n }\n GraphQLScalarType.getValidationFunction = getValidationFunction;\n})(GraphQLScalarType = exports.GraphQLScalarType || (exports.GraphQLScalarType = {}));\nfunction isGraphQLScalarType(obj) {\n return obj && GraphQLScalarType[obj] !== undefined;\n}\nexports.isGraphQLScalarType = isGraphQLScalarType;\nfunction isModelFieldType(obj) {\n const modelField = 'model';\n if (obj && obj[modelField])\n return true;\n return false;\n}\nexports.isModelFieldType = isModelFieldType;\nfunction isNonModelFieldType(obj) {\n const typeField = 'nonModel';\n if (obj && obj[typeField])\n return true;\n return false;\n}\nexports.isNonModelFieldType = isNonModelFieldType;\nfunction isEnumFieldType(obj) {\n const modelField = 'enum';\n if (obj && obj[modelField])\n return true;\n return false;\n}\nexports.isEnumFieldType = isEnumFieldType;\nfunction isIdentifierObject(obj, modelDefinition) {\n const keys = (0, util_1.extractPrimaryKeyFieldNames)(modelDefinition);\n return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));\n}\nexports.isIdentifierObject = isIdentifierObject;\n// #endregion\n// #region Subscription messages\nvar OpType;\n(function (OpType) {\n OpType[\"INSERT\"] = \"INSERT\";\n OpType[\"UPDATE\"] = \"UPDATE\";\n OpType[\"DELETE\"] = \"DELETE\";\n})(OpType = exports.OpType || (exports.OpType = {}));\nfunction isPredicateObj(obj) {\n return obj && obj.field !== undefined;\n}\nexports.isPredicateObj = isPredicateObj;\nfunction isPredicateGroup(obj) {\n return obj && obj.type !== undefined;\n}\nexports.isPredicateGroup = isPredicateGroup;\nvar QueryOne;\n(function (QueryOne) {\n QueryOne[QueryOne[\"FIRST\"] = 0] = \"FIRST\";\n QueryOne[QueryOne[\"LAST\"] = 1] = \"LAST\";\n})(QueryOne = exports.QueryOne || (exports.QueryOne = {}));\nvar SortDirection;\n(function (SortDirection) {\n SortDirection[\"ASCENDING\"] = \"ASCENDING\";\n SortDirection[\"DESCENDING\"] = \"DESCENDING\";\n})(SortDirection = exports.SortDirection || (exports.SortDirection = {}));\nvar AuthModeStrategyType;\n(function (AuthModeStrategyType) {\n AuthModeStrategyType[\"DEFAULT\"] = \"DEFAULT\";\n AuthModeStrategyType[\"MULTI_AUTH\"] = \"MULTI_AUTH\";\n})(AuthModeStrategyType = exports.AuthModeStrategyType || (exports.AuthModeStrategyType = {}));\nvar ModelOperation;\n(function (ModelOperation) {\n ModelOperation[\"CREATE\"] = \"CREATE\";\n ModelOperation[\"READ\"] = \"READ\";\n ModelOperation[\"UPDATE\"] = \"UPDATE\";\n ModelOperation[\"DELETE\"] = \"DELETE\";\n})(ModelOperation = exports.ModelOperation || (exports.ModelOperation = {}));\nasync function syncExpression(modelConstructor, conditionProducer) {\n return {\n modelConstructor,\n conditionProducer,\n };\n}\nexports.syncExpression = syncExpression;\nvar ProcessName;\n(function (ProcessName) {\n ProcessName[\"sync\"] = \"sync\";\n ProcessName[\"mutate\"] = \"mutate\";\n ProcessName[\"subscribe\"] = \"subscribe\";\n})(ProcessName = exports.ProcessName || (exports.ProcessName = {}));\nexports.DISCARD = Symbol('DISCARD');\nvar LimitTimerRaceResolvedValues;\n(function (LimitTimerRaceResolvedValues) {\n LimitTimerRaceResolvedValues[\"LIMIT\"] = \"LIMIT\";\n LimitTimerRaceResolvedValues[\"TIMER\"] = \"TIMER\";\n})(LimitTimerRaceResolvedValues = exports.LimitTimerRaceResolvedValues || (exports.LimitTimerRaceResolvedValues = {}));\n/**\n * A pointer used by DataStore internally to lookup predicate details\n * that should not be exposed on public customer interfaces.\n */\nclass PredicateInternalsKey {\n constructor() {\n this.__isPredicateInternalsKeySentinel = true;\n }\n}\nexports.PredicateInternalsKey = PredicateInternalsKey;\n// #endregion\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAA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;AACnE,IAAI,OAAO;AACX,QAAQ,gBAAgB;AACxB,QAAQ,iBAAiB;AACzB,KAAK,CAAC;AACN,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AAExC,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACjC,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACrC,IAAI,WAAW,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC3C,CAAC,EAAgB,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;AACpE,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAEpC,CAAC,UAAU,4BAA4B,EAAE;AACzC,IAAI,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD,IAAI,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD,CAAC,EAAiC,OAAO,CAAC,4BAA4B,KAAK,OAAO,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC,CAAC;AACvH;AACA;AACA;AACA;AACA,MAAM,qBAAqB,CAAC;AAC5B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,iCAAiC,GAAG,IAAI,CAAC;AACtD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;AACtD;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PredicateInternalsKey = exports.LimitTimerRaceResolvedValues = exports.DISCARD = exports.ProcessName = exports.syncExpression = exports.ModelOperation = exports.AuthModeStrategyType = exports.SortDirection = exports.QueryOne = exports.isPredicateGroup = exports.isPredicateObj = exports.OpType = exports.isIdentifierObject = exports.isEnumFieldType = exports.isNonModelFieldType = exports.isModelFieldType = exports.isGraphQLScalarType = exports.GraphQLScalarType = exports.ModelAttributeAuthProvider = exports.ModelAttributeAuthAllow = exports.isModelAttributeCompositeKey = exports.isModelAttributePrimaryKey = exports.isModelAttributeKey = exports.isModelAttributeAuth = exports.isFieldAssociation = exports.isTargetNameAssociation = exports.isAssociatedWith = exports.isSchemaModelWithAttributes = exports.isSchemaModel = void 0;\nconst util_1 = require(\"./util\");\n/**\n * @private\n * @param obj\n * @returns `true` if the given object likely represents a model in a schema.\n */\nfunction isSchemaModel(obj) {\n return obj && obj.pluralName !== undefined;\n}\nexports.isSchemaModel = isSchemaModel;\n/**\n * @private\n * @param m\n * @returns `true` if the given schema entry defines Schema Model attributes.\n */\nfunction isSchemaModelWithAttributes(m) {\n return isSchemaModel(m) && m.attributes !== undefined;\n}\nexports.isSchemaModelWithAttributes = isSchemaModelWithAttributes;\n/**\n * @private\n * @param obj\n * @returns `true` if the object is an `AssociatedWith` definition.\n */\nfunction isAssociatedWith(obj) {\n return obj && obj.associatedWith;\n}\nexports.isAssociatedWith = isAssociatedWith;\n/**\n * @private\n * @param obj\n * @returns `true` if the given object specifies either `targetName` or `targetNames`.\n */\nfunction isTargetNameAssociation(obj) {\n return obj?.targetName || obj?.targetNames;\n}\nexports.isTargetNameAssociation = isTargetNameAssociation;\n/**\n * @private\n * @param obj\n * @param fieldName\n * @returns Truthy if the object has a `FieldAssociation` for the given `fieldName`.\n */\nfunction isFieldAssociation(obj, fieldName) {\n return obj?.fields[fieldName]?.association?.connectionType;\n}\nexports.isFieldAssociation = isFieldAssociation;\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute is an auth attribute with rules.\n */\nfunction isModelAttributeAuth(attr) {\n return (attr.type === 'auth' &&\n attr.properties &&\n attr.properties.rules &&\n attr.properties.rules.length > 0);\n}\nexports.isModelAttributeAuth = isModelAttributeAuth;\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute is a key field.\n */\nfunction isModelAttributeKey(attr) {\n return (attr.type === 'key' &&\n attr.properties &&\n attr.properties.fields &&\n attr.properties.fields.length > 0);\n}\nexports.isModelAttributeKey = isModelAttributeKey;\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute is a primary key, indicated by the key being unnamed.\n */\nfunction isModelAttributePrimaryKey(attr) {\n return isModelAttributeKey(attr) && attr.properties.name === undefined;\n}\nexports.isModelAttributePrimaryKey = isModelAttributePrimaryKey;\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute represents a composite key with multiple fields.\n */\nfunction isModelAttributeCompositeKey(attr) {\n return (isModelAttributeKey(attr) &&\n attr.properties.name !== undefined &&\n attr.properties.fields.length > 2);\n}\nexports.isModelAttributeCompositeKey = isModelAttributeCompositeKey;\nvar ModelAttributeAuthAllow;\n(function (ModelAttributeAuthAllow) {\n ModelAttributeAuthAllow[\"CUSTOM\"] = \"custom\";\n ModelAttributeAuthAllow[\"OWNER\"] = \"owner\";\n ModelAttributeAuthAllow[\"GROUPS\"] = \"groups\";\n ModelAttributeAuthAllow[\"PRIVATE\"] = \"private\";\n ModelAttributeAuthAllow[\"PUBLIC\"] = \"public\";\n})(ModelAttributeAuthAllow = exports.ModelAttributeAuthAllow || (exports.ModelAttributeAuthAllow = {}));\nvar ModelAttributeAuthProvider;\n(function (ModelAttributeAuthProvider) {\n ModelAttributeAuthProvider[\"FUNCTION\"] = \"function\";\n ModelAttributeAuthProvider[\"USER_POOLS\"] = \"userPools\";\n ModelAttributeAuthProvider[\"OIDC\"] = \"oidc\";\n ModelAttributeAuthProvider[\"IAM\"] = \"iam\";\n ModelAttributeAuthProvider[\"API_KEY\"] = \"apiKey\";\n})(ModelAttributeAuthProvider = exports.ModelAttributeAuthProvider || (exports.ModelAttributeAuthProvider = {}));\nvar GraphQLScalarType;\n(function (GraphQLScalarType) {\n GraphQLScalarType[GraphQLScalarType[\"ID\"] = 0] = \"ID\";\n GraphQLScalarType[GraphQLScalarType[\"String\"] = 1] = \"String\";\n GraphQLScalarType[GraphQLScalarType[\"Int\"] = 2] = \"Int\";\n GraphQLScalarType[GraphQLScalarType[\"Float\"] = 3] = \"Float\";\n GraphQLScalarType[GraphQLScalarType[\"Boolean\"] = 4] = \"Boolean\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDate\"] = 5] = \"AWSDate\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTime\"] = 6] = \"AWSTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDateTime\"] = 7] = \"AWSDateTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTimestamp\"] = 8] = \"AWSTimestamp\";\n GraphQLScalarType[GraphQLScalarType[\"AWSEmail\"] = 9] = \"AWSEmail\";\n GraphQLScalarType[GraphQLScalarType[\"AWSJSON\"] = 10] = \"AWSJSON\";\n GraphQLScalarType[GraphQLScalarType[\"AWSURL\"] = 11] = \"AWSURL\";\n GraphQLScalarType[GraphQLScalarType[\"AWSPhone\"] = 12] = \"AWSPhone\";\n GraphQLScalarType[GraphQLScalarType[\"AWSIPAddress\"] = 13] = \"AWSIPAddress\";\n})(GraphQLScalarType = exports.GraphQLScalarType || (exports.GraphQLScalarType = {}));\n// eslint-disable-next-line @typescript-eslint/no-namespace\n(function (GraphQLScalarType) {\n function getJSType(scalar) {\n switch (scalar) {\n case 'Boolean':\n return 'boolean';\n case 'ID':\n case 'String':\n case 'AWSDate':\n case 'AWSTime':\n case 'AWSDateTime':\n case 'AWSEmail':\n case 'AWSURL':\n case 'AWSPhone':\n case 'AWSIPAddress':\n return 'string';\n case 'Int':\n case 'Float':\n case 'AWSTimestamp':\n return 'number';\n case 'AWSJSON':\n return 'object';\n default:\n throw new Error('Invalid scalar type');\n }\n }\n GraphQLScalarType.getJSType = getJSType;\n function getValidationFunction(scalar) {\n switch (scalar) {\n case 'AWSDate':\n return util_1.isAWSDate;\n case 'AWSTime':\n return util_1.isAWSTime;\n case 'AWSDateTime':\n return util_1.isAWSDateTime;\n case 'AWSTimestamp':\n return util_1.isAWSTimestamp;\n case 'AWSEmail':\n return util_1.isAWSEmail;\n case 'AWSJSON':\n return util_1.isAWSJSON;\n case 'AWSURL':\n return util_1.isAWSURL;\n case 'AWSPhone':\n return util_1.isAWSPhone;\n case 'AWSIPAddress':\n return util_1.isAWSIPAddress;\n default:\n return undefined;\n }\n }\n GraphQLScalarType.getValidationFunction = getValidationFunction;\n})(GraphQLScalarType = exports.GraphQLScalarType || (exports.GraphQLScalarType = {}));\n/**\n * @private\n * @returns `true` if the given field specifies a scalar type.\n */\nfunction isGraphQLScalarType(obj) {\n return obj && GraphQLScalarType[obj] !== undefined;\n}\nexports.isGraphQLScalarType = isGraphQLScalarType;\n/**\n * @private\n * @param obj\n * @returns `true` if the given field specifies a Model.\n */\nfunction isModelFieldType(obj) {\n const modelField = 'model';\n if (obj && obj[modelField])\n return true;\n return false;\n}\nexports.isModelFieldType = isModelFieldType;\n/**\n * @private\n * @param obj\n * @returns `true` if the given field specifies a custom non-model type.\n */\nfunction isNonModelFieldType(obj) {\n const typeField = 'nonModel';\n if (obj && obj[typeField])\n return true;\n return false;\n}\nexports.isNonModelFieldType = isNonModelFieldType;\n/**\n * @private\n * @param obj\n * @returns `true` if the object is an `EnumFieldType`.\n */\nfunction isEnumFieldType(obj) {\n const modelField = 'enum';\n if (obj && obj[modelField])\n return true;\n return false;\n}\nexports.isEnumFieldType = isEnumFieldType;\n/**\n * @private\n * @param obj\n * @param modelDefinition\n * @returns `true` if the given item is an object that has all identifier fields populated.\n */\nfunction isIdentifierObject(obj, modelDefinition) {\n const keys = (0, util_1.extractPrimaryKeyFieldNames)(modelDefinition);\n return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));\n}\nexports.isIdentifierObject = isIdentifierObject;\n// #endregion\n// #region Subscription messages\nvar OpType;\n(function (OpType) {\n OpType[\"INSERT\"] = \"INSERT\";\n OpType[\"UPDATE\"] = \"UPDATE\";\n OpType[\"DELETE\"] = \"DELETE\";\n})(OpType = exports.OpType || (exports.OpType = {}));\n/**\n * @private\n * @param obj\n * @returns `true` if the given predicate field object, specifying an [in-]equality test against a field.\n */\nfunction isPredicateObj(obj) {\n return obj && obj.field !== undefined;\n}\nexports.isPredicateObj = isPredicateObj;\n/**\n * @private\n * @param obj\n * @returns `true` if the given predicate object is a \"group\" like \"and\", \"or\", or \"not\".\n */\nfunction isPredicateGroup(obj) {\n return obj && obj.type !== undefined;\n}\nexports.isPredicateGroup = isPredicateGroup;\nvar QueryOne;\n(function (QueryOne) {\n QueryOne[QueryOne[\"FIRST\"] = 0] = \"FIRST\";\n QueryOne[QueryOne[\"LAST\"] = 1] = \"LAST\";\n})(QueryOne = exports.QueryOne || (exports.QueryOne = {}));\nvar SortDirection;\n(function (SortDirection) {\n SortDirection[\"ASCENDING\"] = \"ASCENDING\";\n SortDirection[\"DESCENDING\"] = \"DESCENDING\";\n})(SortDirection = exports.SortDirection || (exports.SortDirection = {}));\nvar AuthModeStrategyType;\n(function (AuthModeStrategyType) {\n AuthModeStrategyType[\"DEFAULT\"] = \"DEFAULT\";\n AuthModeStrategyType[\"MULTI_AUTH\"] = \"MULTI_AUTH\";\n})(AuthModeStrategyType = exports.AuthModeStrategyType || (exports.AuthModeStrategyType = {}));\nvar ModelOperation;\n(function (ModelOperation) {\n ModelOperation[\"CREATE\"] = \"CREATE\";\n ModelOperation[\"READ\"] = \"READ\";\n ModelOperation[\"UPDATE\"] = \"UPDATE\";\n ModelOperation[\"DELETE\"] = \"DELETE\";\n})(ModelOperation = exports.ModelOperation || (exports.ModelOperation = {}));\n/**\n * Build an expression that can be used to filter which items of a given Model\n * are synchronized down from the GraphQL service. E.g.,\n *\n * ```ts\n * import { DataStore, syncExpression } from 'aws-amplify/datastore';\n * import { Post, Comment } from './models';\n *\n *\n * DataStore.configure({\n * \tsyncExpressions: [\n * \t\tsyncExpression(Post, () => {\n * \t\t\treturn (post) => post.rating.gt(5);\n * \t\t}),\n * \t\tsyncExpression(Comment, () => {\n * \t\t\treturn (comment) => comment.status.eq('active');\n * \t\t})\n * \t]\n * });\n * ```\n *\n * When DataStore starts syncing, only Posts with `rating > 5` and Comments with\n * `status === 'active'` will be synced down to the user's local store.\n *\n * @param modelConstructor The Model from the schema.\n * @param conditionProducer A function that builds a condition object that can describe how to filter the model.\n * @returns An sync expression object that can be attached to the DataStore `syncExpressions` configuration property.\n */\nasync function syncExpression(modelConstructor, conditionProducer) {\n return {\n modelConstructor,\n conditionProducer,\n };\n}\nexports.syncExpression = syncExpression;\nvar ProcessName;\n(function (ProcessName) {\n ProcessName[\"sync\"] = \"sync\";\n ProcessName[\"mutate\"] = \"mutate\";\n ProcessName[\"subscribe\"] = \"subscribe\";\n})(ProcessName = exports.ProcessName || (exports.ProcessName = {}));\nexports.DISCARD = Symbol('DISCARD');\nvar LimitTimerRaceResolvedValues;\n(function (LimitTimerRaceResolvedValues) {\n LimitTimerRaceResolvedValues[\"LIMIT\"] = \"LIMIT\";\n LimitTimerRaceResolvedValues[\"TIMER\"] = \"TIMER\";\n})(LimitTimerRaceResolvedValues = exports.LimitTimerRaceResolvedValues || (exports.LimitTimerRaceResolvedValues = {}));\n/**\n * A pointer used by DataStore internally to lookup predicate details\n * that should not be exposed on public customer interfaces.\n */\nclass PredicateInternalsKey {\n constructor() {\n this.__isPredicateInternalsKeySentinel = true;\n }\n}\nexports.PredicateInternalsKey = PredicateInternalsKey;\n// #endregion\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,G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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,cAAc,CAAC,gBAAgB,EAAE,iBAAiB,EAAE;AACnE,IAAI,OAAO;AACX,QAAQ,gBAAgB;AACxB,QAAQ,iBAAiB;AACzB,KAAK,CAAC;AACN,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AAExC,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACjC,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACrC,IAAI,WAAW,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC3C,CAAC,EAAgB,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;AACpE,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAEpC,CAAC,UAAU,4BAA4B,EAAE;AACzC,IAAI,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD,IAAI,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD,CAAC,EAAiC,OAAO,CAAC,4BAA4B,KAAK,OAAO,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC,CAAC;AACvH;AACA;AACA;AACA;AACA,MAAM,qBAAqB,CAAC;AAC5B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,iCAAiC,GAAG,IAAI,CAAC;AACtD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;AACtD;;"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -47,7 +47,17 @@ export interface SchemaModel {
|
|
|
47
47
|
allFields?: ModelFields;
|
|
48
48
|
syncable?: boolean;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
* @param obj
|
|
53
|
+
* @returns `true` if the given object likely represents a model in a schema.
|
|
54
|
+
*/
|
|
50
55
|
export declare function isSchemaModel(obj: any): obj is SchemaModel;
|
|
56
|
+
/**
|
|
57
|
+
* @private
|
|
58
|
+
* @param m
|
|
59
|
+
* @returns `true` if the given schema entry defines Schema Model attributes.
|
|
60
|
+
*/
|
|
51
61
|
export declare function isSchemaModelWithAttributes(m: SchemaModel | SchemaNonModel): m is SchemaModel;
|
|
52
62
|
export type SchemaNonModels = Record<string, SchemaNonModel>;
|
|
53
63
|
export interface SchemaNonModel {
|
|
@@ -71,16 +81,32 @@ interface AssociatedWith {
|
|
|
71
81
|
targetName?: string;
|
|
72
82
|
targetNames?: string[];
|
|
73
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* @private
|
|
86
|
+
* @param obj
|
|
87
|
+
* @returns `true` if the object is an `AssociatedWith` definition.
|
|
88
|
+
*/
|
|
74
89
|
export declare function isAssociatedWith(obj: any): obj is AssociatedWith;
|
|
75
90
|
interface TargetNameAssociation {
|
|
76
91
|
connectionType: 'BELONGS_TO';
|
|
77
92
|
targetName?: string;
|
|
78
93
|
targetNames?: string[];
|
|
79
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* @private
|
|
97
|
+
* @param obj
|
|
98
|
+
* @returns `true` if the given object specifies either `targetName` or `targetNames`.
|
|
99
|
+
*/
|
|
80
100
|
export declare function isTargetNameAssociation(obj: any): obj is TargetNameAssociation;
|
|
81
101
|
interface FieldAssociation {
|
|
82
102
|
connectionType: 'HAS_ONE' | 'BELONGS_TO' | 'HAS_MANY';
|
|
83
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* @private
|
|
106
|
+
* @param obj
|
|
107
|
+
* @param fieldName
|
|
108
|
+
* @returns Truthy if the object has a `FieldAssociation` for the given `fieldName`.
|
|
109
|
+
*/
|
|
84
110
|
export declare function isFieldAssociation(obj: any, fieldName: string): obj is FieldAssociation;
|
|
85
111
|
export type ModelAttributes = ModelAttribute[];
|
|
86
112
|
export interface ModelAttribute {
|
|
@@ -103,6 +129,11 @@ export interface ModelAttributeAuth {
|
|
|
103
129
|
rules: ModelAuthRule[];
|
|
104
130
|
};
|
|
105
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* @private
|
|
134
|
+
* @param attr
|
|
135
|
+
* @returns `true` if the given attribute is an auth attribute with rules.
|
|
136
|
+
*/
|
|
106
137
|
export declare function isModelAttributeAuth(attr: ModelAttribute): attr is ModelAttributeAuth;
|
|
107
138
|
interface ModelAttributeKey {
|
|
108
139
|
type: 'key';
|
|
@@ -125,8 +156,23 @@ interface ModelAttributeCompositeKey {
|
|
|
125
156
|
fields: [string, string, string, string?, string?];
|
|
126
157
|
};
|
|
127
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* @private
|
|
161
|
+
* @param attr
|
|
162
|
+
* @returns `true` if the given attribute is a key field.
|
|
163
|
+
*/
|
|
128
164
|
export declare function isModelAttributeKey(attr: ModelAttribute): attr is ModelAttributeKey;
|
|
165
|
+
/**
|
|
166
|
+
* @private
|
|
167
|
+
* @param attr
|
|
168
|
+
* @returns `true` if the given attribute is a primary key, indicated by the key being unnamed.
|
|
169
|
+
*/
|
|
129
170
|
export declare function isModelAttributePrimaryKey(attr: ModelAttribute): attr is ModelAttributePrimaryKey;
|
|
171
|
+
/**
|
|
172
|
+
* @private
|
|
173
|
+
* @param attr
|
|
174
|
+
* @returns `true` if the given attribute represents a composite key with multiple fields.
|
|
175
|
+
*/
|
|
130
176
|
export declare function isModelAttributeCompositeKey(attr: ModelAttribute): attr is ModelAttributeCompositeKey;
|
|
131
177
|
export interface ModelAttributeAuthProperty {
|
|
132
178
|
allow: ModelAttributeAuthAllow;
|
|
@@ -182,19 +228,38 @@ export interface AuthorizationRule {
|
|
|
182
228
|
authStrategy: 'owner' | 'groups' | 'private' | 'public';
|
|
183
229
|
areSubscriptionsPublic: boolean;
|
|
184
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* @private
|
|
233
|
+
* @returns `true` if the given field specifies a scalar type.
|
|
234
|
+
*/
|
|
185
235
|
export declare function isGraphQLScalarType(obj: any): obj is keyof Omit<typeof GraphQLScalarType, 'getJSType' | 'getValidationFunction'>;
|
|
186
236
|
export interface ModelFieldType {
|
|
187
237
|
model: string;
|
|
188
238
|
modelConstructor?: ModelMeta<PersistentModel>;
|
|
189
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* @private
|
|
242
|
+
* @param obj
|
|
243
|
+
* @returns `true` if the given field specifies a Model.
|
|
244
|
+
*/
|
|
190
245
|
export declare function isModelFieldType<_ extends PersistentModel>(obj: any): obj is ModelFieldType;
|
|
191
246
|
export interface NonModelFieldType {
|
|
192
247
|
nonModel: string;
|
|
193
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* @private
|
|
251
|
+
* @param obj
|
|
252
|
+
* @returns `true` if the given field specifies a custom non-model type.
|
|
253
|
+
*/
|
|
194
254
|
export declare function isNonModelFieldType(obj: any): obj is NonModelFieldType;
|
|
195
255
|
interface EnumFieldType {
|
|
196
256
|
enum: string;
|
|
197
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* @private
|
|
260
|
+
* @param obj
|
|
261
|
+
* @returns `true` if the object is an `EnumFieldType`.
|
|
262
|
+
*/
|
|
198
263
|
export declare function isEnumFieldType(obj: any): obj is EnumFieldType;
|
|
199
264
|
export interface ModelField {
|
|
200
265
|
name: string;
|
|
@@ -304,6 +369,12 @@ export interface ModelInstanceMetadata {
|
|
|
304
369
|
}
|
|
305
370
|
export type IdentifierFieldValue<T extends PersistentModel, M extends PersistentModelMetaData<T>> = MetadataOrDefault<T, M>['identifier'] extends CompositeIdentifier<T, any> ? MetadataOrDefault<T, M>['identifier']['fields'] extends [any] ? T[MetadataOrDefault<T, M>['identifier']['fields'][0]] : never : T[MetadataOrDefault<T, M>['identifier']['field']];
|
|
306
371
|
export type IdentifierFieldOrIdentifierObject<T extends PersistentModel, M extends PersistentModelMetaData<T>> = Pick<T, IdentifierFields<T, M>> | IdentifierFieldValue<T, M>;
|
|
372
|
+
/**
|
|
373
|
+
* @private
|
|
374
|
+
* @param obj
|
|
375
|
+
* @param modelDefinition
|
|
376
|
+
* @returns `true` if the given item is an object that has all identifier fields populated.
|
|
377
|
+
*/
|
|
307
378
|
export declare function isIdentifierObject<T extends PersistentModel>(obj: any, modelDefinition: SchemaModel): obj is IdentifierFields<T extends PersistentModel ? T : never, any>;
|
|
308
379
|
export declare enum OpType {
|
|
309
380
|
INSERT = "INSERT",
|
|
@@ -369,7 +440,17 @@ export interface PredicatesGroup<T extends PersistentModel> {
|
|
|
369
440
|
type: keyof PredicateGroups<T>;
|
|
370
441
|
predicates: (PredicateObject<T> | PredicatesGroup<T>)[];
|
|
371
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* @private
|
|
445
|
+
* @param obj
|
|
446
|
+
* @returns `true` if the given predicate field object, specifying an [in-]equality test against a field.
|
|
447
|
+
*/
|
|
372
448
|
export declare function isPredicateObj<T extends PersistentModel>(obj: any): obj is PredicateObject<T>;
|
|
449
|
+
/**
|
|
450
|
+
* @private
|
|
451
|
+
* @param obj
|
|
452
|
+
* @returns `true` if the given predicate object is a "group" like "and", "or", or "not".
|
|
453
|
+
*/
|
|
373
454
|
export declare function isPredicateGroup<T extends PersistentModel>(obj: any): obj is PredicatesGroup<T>;
|
|
374
455
|
export interface PredicateObject<T extends PersistentModel> {
|
|
375
456
|
field: keyof T;
|
|
@@ -508,6 +589,34 @@ interface Lookup<T extends PersistentModel> {
|
|
|
508
589
|
1: PredicateInternalsKey | undefined;
|
|
509
590
|
}
|
|
510
591
|
type ConditionProducer<T extends PersistentModel, A extends Option<T>> = (...args: A) => A['length'] extends keyof Lookup<T> ? Lookup<T>[A['length']] : never;
|
|
592
|
+
/**
|
|
593
|
+
* Build an expression that can be used to filter which items of a given Model
|
|
594
|
+
* are synchronized down from the GraphQL service. E.g.,
|
|
595
|
+
*
|
|
596
|
+
* ```ts
|
|
597
|
+
* import { DataStore, syncExpression } from 'aws-amplify/datastore';
|
|
598
|
+
* import { Post, Comment } from './models';
|
|
599
|
+
*
|
|
600
|
+
*
|
|
601
|
+
* DataStore.configure({
|
|
602
|
+
* syncExpressions: [
|
|
603
|
+
* syncExpression(Post, () => {
|
|
604
|
+
* return (post) => post.rating.gt(5);
|
|
605
|
+
* }),
|
|
606
|
+
* syncExpression(Comment, () => {
|
|
607
|
+
* return (comment) => comment.status.eq('active');
|
|
608
|
+
* })
|
|
609
|
+
* ]
|
|
610
|
+
* });
|
|
611
|
+
* ```
|
|
612
|
+
*
|
|
613
|
+
* When DataStore starts syncing, only Posts with `rating > 5` and Comments with
|
|
614
|
+
* `status === 'active'` will be synced down to the user's local store.
|
|
615
|
+
*
|
|
616
|
+
* @param modelConstructor The Model from the schema.
|
|
617
|
+
* @param conditionProducer A function that builds a condition object that can describe how to filter the model.
|
|
618
|
+
* @returns An sync expression object that can be attached to the DataStore `syncExpressions` configuration property.
|
|
619
|
+
*/
|
|
511
620
|
export declare function syncExpression<T extends PersistentModel, A extends Option<T>>(modelConstructor: PersistentModelConstructor<T>, conditionProducer: ConditionProducer<T, A>): Promise<{
|
|
512
621
|
modelConstructor: PersistentModelConstructor<T>;
|
|
513
622
|
conditionProducer: ConditionProducer<T, A>;
|
package/dist/esm/types.mjs
CHANGED
|
@@ -1,35 +1,81 @@
|
|
|
1
1
|
import { isAWSIPAddress, isAWSPhone, isAWSURL, isAWSJSON, isAWSEmail, isAWSTimestamp, isAWSDateTime, isAWSTime, isAWSDate, extractPrimaryKeyFieldNames } from './util.mjs';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* @param obj
|
|
6
|
+
* @returns `true` if the given object likely represents a model in a schema.
|
|
7
|
+
*/
|
|
3
8
|
function isSchemaModel(obj) {
|
|
4
9
|
return obj && obj.pluralName !== undefined;
|
|
5
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
* @param m
|
|
14
|
+
* @returns `true` if the given schema entry defines Schema Model attributes.
|
|
15
|
+
*/
|
|
6
16
|
function isSchemaModelWithAttributes(m) {
|
|
7
17
|
return isSchemaModel(m) && m.attributes !== undefined;
|
|
8
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
* @param obj
|
|
22
|
+
* @returns `true` if the object is an `AssociatedWith` definition.
|
|
23
|
+
*/
|
|
9
24
|
function isAssociatedWith(obj) {
|
|
10
25
|
return obj && obj.associatedWith;
|
|
11
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
* @param obj
|
|
30
|
+
* @returns `true` if the given object specifies either `targetName` or `targetNames`.
|
|
31
|
+
*/
|
|
12
32
|
function isTargetNameAssociation(obj) {
|
|
13
33
|
return obj?.targetName || obj?.targetNames;
|
|
14
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
* @param obj
|
|
38
|
+
* @param fieldName
|
|
39
|
+
* @returns Truthy if the object has a `FieldAssociation` for the given `fieldName`.
|
|
40
|
+
*/
|
|
15
41
|
function isFieldAssociation(obj, fieldName) {
|
|
16
42
|
return obj?.fields[fieldName]?.association?.connectionType;
|
|
17
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
* @param attr
|
|
47
|
+
* @returns `true` if the given attribute is an auth attribute with rules.
|
|
48
|
+
*/
|
|
18
49
|
function isModelAttributeAuth(attr) {
|
|
19
50
|
return (attr.type === 'auth' &&
|
|
20
51
|
attr.properties &&
|
|
21
52
|
attr.properties.rules &&
|
|
22
53
|
attr.properties.rules.length > 0);
|
|
23
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
* @param attr
|
|
58
|
+
* @returns `true` if the given attribute is a key field.
|
|
59
|
+
*/
|
|
24
60
|
function isModelAttributeKey(attr) {
|
|
25
61
|
return (attr.type === 'key' &&
|
|
26
62
|
attr.properties &&
|
|
27
63
|
attr.properties.fields &&
|
|
28
64
|
attr.properties.fields.length > 0);
|
|
29
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @private
|
|
68
|
+
* @param attr
|
|
69
|
+
* @returns `true` if the given attribute is a primary key, indicated by the key being unnamed.
|
|
70
|
+
*/
|
|
30
71
|
function isModelAttributePrimaryKey(attr) {
|
|
31
72
|
return isModelAttributeKey(attr) && attr.properties.name === undefined;
|
|
32
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @private
|
|
76
|
+
* @param attr
|
|
77
|
+
* @returns `true` if the given attribute represents a composite key with multiple fields.
|
|
78
|
+
*/
|
|
33
79
|
function isModelAttributeCompositeKey(attr) {
|
|
34
80
|
return (isModelAttributeKey(attr) &&
|
|
35
81
|
attr.properties.name !== undefined &&
|
|
@@ -121,27 +167,52 @@ var GraphQLScalarType;
|
|
|
121
167
|
}
|
|
122
168
|
GraphQLScalarType.getValidationFunction = getValidationFunction;
|
|
123
169
|
})(GraphQLScalarType || (GraphQLScalarType = {}));
|
|
170
|
+
/**
|
|
171
|
+
* @private
|
|
172
|
+
* @returns `true` if the given field specifies a scalar type.
|
|
173
|
+
*/
|
|
124
174
|
function isGraphQLScalarType(obj) {
|
|
125
175
|
return obj && GraphQLScalarType[obj] !== undefined;
|
|
126
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* @private
|
|
179
|
+
* @param obj
|
|
180
|
+
* @returns `true` if the given field specifies a Model.
|
|
181
|
+
*/
|
|
127
182
|
function isModelFieldType(obj) {
|
|
128
183
|
const modelField = 'model';
|
|
129
184
|
if (obj && obj[modelField])
|
|
130
185
|
return true;
|
|
131
186
|
return false;
|
|
132
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* @private
|
|
190
|
+
* @param obj
|
|
191
|
+
* @returns `true` if the given field specifies a custom non-model type.
|
|
192
|
+
*/
|
|
133
193
|
function isNonModelFieldType(obj) {
|
|
134
194
|
const typeField = 'nonModel';
|
|
135
195
|
if (obj && obj[typeField])
|
|
136
196
|
return true;
|
|
137
197
|
return false;
|
|
138
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* @private
|
|
201
|
+
* @param obj
|
|
202
|
+
* @returns `true` if the object is an `EnumFieldType`.
|
|
203
|
+
*/
|
|
139
204
|
function isEnumFieldType(obj) {
|
|
140
205
|
const modelField = 'enum';
|
|
141
206
|
if (obj && obj[modelField])
|
|
142
207
|
return true;
|
|
143
208
|
return false;
|
|
144
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* @private
|
|
212
|
+
* @param obj
|
|
213
|
+
* @param modelDefinition
|
|
214
|
+
* @returns `true` if the given item is an object that has all identifier fields populated.
|
|
215
|
+
*/
|
|
145
216
|
function isIdentifierObject(obj, modelDefinition) {
|
|
146
217
|
const keys = extractPrimaryKeyFieldNames(modelDefinition);
|
|
147
218
|
return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));
|
|
@@ -154,9 +225,19 @@ var OpType;
|
|
|
154
225
|
OpType["UPDATE"] = "UPDATE";
|
|
155
226
|
OpType["DELETE"] = "DELETE";
|
|
156
227
|
})(OpType || (OpType = {}));
|
|
228
|
+
/**
|
|
229
|
+
* @private
|
|
230
|
+
* @param obj
|
|
231
|
+
* @returns `true` if the given predicate field object, specifying an [in-]equality test against a field.
|
|
232
|
+
*/
|
|
157
233
|
function isPredicateObj(obj) {
|
|
158
234
|
return obj && obj.field !== undefined;
|
|
159
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* @private
|
|
238
|
+
* @param obj
|
|
239
|
+
* @returns `true` if the given predicate object is a "group" like "and", "or", or "not".
|
|
240
|
+
*/
|
|
160
241
|
function isPredicateGroup(obj) {
|
|
161
242
|
return obj && obj.type !== undefined;
|
|
162
243
|
}
|
|
@@ -182,6 +263,34 @@ var ModelOperation;
|
|
|
182
263
|
ModelOperation["UPDATE"] = "UPDATE";
|
|
183
264
|
ModelOperation["DELETE"] = "DELETE";
|
|
184
265
|
})(ModelOperation || (ModelOperation = {}));
|
|
266
|
+
/**
|
|
267
|
+
* Build an expression that can be used to filter which items of a given Model
|
|
268
|
+
* are synchronized down from the GraphQL service. E.g.,
|
|
269
|
+
*
|
|
270
|
+
* ```ts
|
|
271
|
+
* import { DataStore, syncExpression } from 'aws-amplify/datastore';
|
|
272
|
+
* import { Post, Comment } from './models';
|
|
273
|
+
*
|
|
274
|
+
*
|
|
275
|
+
* DataStore.configure({
|
|
276
|
+
* syncExpressions: [
|
|
277
|
+
* syncExpression(Post, () => {
|
|
278
|
+
* return (post) => post.rating.gt(5);
|
|
279
|
+
* }),
|
|
280
|
+
* syncExpression(Comment, () => {
|
|
281
|
+
* return (comment) => comment.status.eq('active');
|
|
282
|
+
* })
|
|
283
|
+
* ]
|
|
284
|
+
* });
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* When DataStore starts syncing, only Posts with `rating > 5` and Comments with
|
|
288
|
+
* `status === 'active'` will be synced down to the user's local store.
|
|
289
|
+
*
|
|
290
|
+
* @param modelConstructor The Model from the schema.
|
|
291
|
+
* @param conditionProducer A function that builds a condition object that can describe how to filter the model.
|
|
292
|
+
* @returns An sync expression object that can be attached to the DataStore `syncExpressions` configuration property.
|
|
293
|
+
*/
|
|
185
294
|
async function syncExpression(modelConstructor, conditionProducer) {
|
|
186
295
|
return {
|
|
187
296
|
modelConstructor,
|
package/dist/esm/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sources":["../../src/types.ts"],"sourcesContent":["import { extractPrimaryKeyFieldNames, isAWSDate, isAWSDateTime, isAWSEmail, isAWSIPAddress, isAWSJSON, isAWSPhone, isAWSTime, isAWSTimestamp, isAWSURL, } from './util';\nexport function isSchemaModel(obj) {\n return obj && obj.pluralName !== undefined;\n}\nexport function isSchemaModelWithAttributes(m) {\n return isSchemaModel(m) && m.attributes !== undefined;\n}\nexport function isAssociatedWith(obj) {\n return obj && obj.associatedWith;\n}\nexport function isTargetNameAssociation(obj) {\n return obj?.targetName || obj?.targetNames;\n}\nexport function isFieldAssociation(obj, fieldName) {\n return obj?.fields[fieldName]?.association?.connectionType;\n}\nexport function isModelAttributeAuth(attr) {\n return (attr.type === 'auth' &&\n attr.properties &&\n attr.properties.rules &&\n attr.properties.rules.length > 0);\n}\nexport function isModelAttributeKey(attr) {\n return (attr.type === 'key' &&\n attr.properties &&\n attr.properties.fields &&\n attr.properties.fields.length > 0);\n}\nexport function isModelAttributePrimaryKey(attr) {\n return isModelAttributeKey(attr) && attr.properties.name === undefined;\n}\nexport function isModelAttributeCompositeKey(attr) {\n return (isModelAttributeKey(attr) &&\n attr.properties.name !== undefined &&\n attr.properties.fields.length > 2);\n}\nexport var ModelAttributeAuthAllow;\n(function (ModelAttributeAuthAllow) {\n ModelAttributeAuthAllow[\"CUSTOM\"] = \"custom\";\n ModelAttributeAuthAllow[\"OWNER\"] = \"owner\";\n ModelAttributeAuthAllow[\"GROUPS\"] = \"groups\";\n ModelAttributeAuthAllow[\"PRIVATE\"] = \"private\";\n ModelAttributeAuthAllow[\"PUBLIC\"] = \"public\";\n})(ModelAttributeAuthAllow || (ModelAttributeAuthAllow = {}));\nexport var ModelAttributeAuthProvider;\n(function (ModelAttributeAuthProvider) {\n ModelAttributeAuthProvider[\"FUNCTION\"] = \"function\";\n ModelAttributeAuthProvider[\"USER_POOLS\"] = \"userPools\";\n ModelAttributeAuthProvider[\"OIDC\"] = \"oidc\";\n ModelAttributeAuthProvider[\"IAM\"] = \"iam\";\n ModelAttributeAuthProvider[\"API_KEY\"] = \"apiKey\";\n})(ModelAttributeAuthProvider || (ModelAttributeAuthProvider = {}));\nexport var GraphQLScalarType;\n(function (GraphQLScalarType) {\n GraphQLScalarType[GraphQLScalarType[\"ID\"] = 0] = \"ID\";\n GraphQLScalarType[GraphQLScalarType[\"String\"] = 1] = \"String\";\n GraphQLScalarType[GraphQLScalarType[\"Int\"] = 2] = \"Int\";\n GraphQLScalarType[GraphQLScalarType[\"Float\"] = 3] = \"Float\";\n GraphQLScalarType[GraphQLScalarType[\"Boolean\"] = 4] = \"Boolean\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDate\"] = 5] = \"AWSDate\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTime\"] = 6] = \"AWSTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDateTime\"] = 7] = \"AWSDateTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTimestamp\"] = 8] = \"AWSTimestamp\";\n GraphQLScalarType[GraphQLScalarType[\"AWSEmail\"] = 9] = \"AWSEmail\";\n GraphQLScalarType[GraphQLScalarType[\"AWSJSON\"] = 10] = \"AWSJSON\";\n GraphQLScalarType[GraphQLScalarType[\"AWSURL\"] = 11] = \"AWSURL\";\n GraphQLScalarType[GraphQLScalarType[\"AWSPhone\"] = 12] = \"AWSPhone\";\n GraphQLScalarType[GraphQLScalarType[\"AWSIPAddress\"] = 13] = \"AWSIPAddress\";\n})(GraphQLScalarType || (GraphQLScalarType = {}));\n// eslint-disable-next-line @typescript-eslint/no-namespace\n(function (GraphQLScalarType) {\n function getJSType(scalar) {\n switch (scalar) {\n case 'Boolean':\n return 'boolean';\n case 'ID':\n case 'String':\n case 'AWSDate':\n case 'AWSTime':\n case 'AWSDateTime':\n case 'AWSEmail':\n case 'AWSURL':\n case 'AWSPhone':\n case 'AWSIPAddress':\n return 'string';\n case 'Int':\n case 'Float':\n case 'AWSTimestamp':\n return 'number';\n case 'AWSJSON':\n return 'object';\n default:\n throw new Error('Invalid scalar type');\n }\n }\n GraphQLScalarType.getJSType = getJSType;\n function getValidationFunction(scalar) {\n switch (scalar) {\n case 'AWSDate':\n return isAWSDate;\n case 'AWSTime':\n return isAWSTime;\n case 'AWSDateTime':\n return isAWSDateTime;\n case 'AWSTimestamp':\n return isAWSTimestamp;\n case 'AWSEmail':\n return isAWSEmail;\n case 'AWSJSON':\n return isAWSJSON;\n case 'AWSURL':\n return isAWSURL;\n case 'AWSPhone':\n return isAWSPhone;\n case 'AWSIPAddress':\n return isAWSIPAddress;\n default:\n return undefined;\n }\n }\n GraphQLScalarType.getValidationFunction = getValidationFunction;\n})(GraphQLScalarType || (GraphQLScalarType = {}));\nexport function isGraphQLScalarType(obj) {\n return obj && GraphQLScalarType[obj] !== undefined;\n}\nexport function isModelFieldType(obj) {\n const modelField = 'model';\n if (obj && obj[modelField])\n return true;\n return false;\n}\nexport function isNonModelFieldType(obj) {\n const typeField = 'nonModel';\n if (obj && obj[typeField])\n return true;\n return false;\n}\nexport function isEnumFieldType(obj) {\n const modelField = 'enum';\n if (obj && obj[modelField])\n return true;\n return false;\n}\nexport function isIdentifierObject(obj, modelDefinition) {\n const keys = extractPrimaryKeyFieldNames(modelDefinition);\n return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));\n}\n// #endregion\n// #region Subscription messages\nexport var OpType;\n(function (OpType) {\n OpType[\"INSERT\"] = \"INSERT\";\n OpType[\"UPDATE\"] = \"UPDATE\";\n OpType[\"DELETE\"] = \"DELETE\";\n})(OpType || (OpType = {}));\nexport function isPredicateObj(obj) {\n return obj && obj.field !== undefined;\n}\nexport function isPredicateGroup(obj) {\n return obj && obj.type !== undefined;\n}\nexport var QueryOne;\n(function (QueryOne) {\n QueryOne[QueryOne[\"FIRST\"] = 0] = \"FIRST\";\n QueryOne[QueryOne[\"LAST\"] = 1] = \"LAST\";\n})(QueryOne || (QueryOne = {}));\nexport var SortDirection;\n(function (SortDirection) {\n SortDirection[\"ASCENDING\"] = \"ASCENDING\";\n SortDirection[\"DESCENDING\"] = \"DESCENDING\";\n})(SortDirection || (SortDirection = {}));\nexport var AuthModeStrategyType;\n(function (AuthModeStrategyType) {\n AuthModeStrategyType[\"DEFAULT\"] = \"DEFAULT\";\n AuthModeStrategyType[\"MULTI_AUTH\"] = \"MULTI_AUTH\";\n})(AuthModeStrategyType || (AuthModeStrategyType = {}));\nexport var ModelOperation;\n(function (ModelOperation) {\n ModelOperation[\"CREATE\"] = \"CREATE\";\n ModelOperation[\"READ\"] = \"READ\";\n ModelOperation[\"UPDATE\"] = \"UPDATE\";\n ModelOperation[\"DELETE\"] = \"DELETE\";\n})(ModelOperation || (ModelOperation = {}));\nexport async function syncExpression(modelConstructor, conditionProducer) {\n return {\n modelConstructor,\n conditionProducer,\n };\n}\nexport var ProcessName;\n(function (ProcessName) {\n ProcessName[\"sync\"] = \"sync\";\n ProcessName[\"mutate\"] = \"mutate\";\n ProcessName[\"subscribe\"] = \"subscribe\";\n})(ProcessName || (ProcessName = {}));\nexport const DISCARD = Symbol('DISCARD');\nexport var LimitTimerRaceResolvedValues;\n(function (LimitTimerRaceResolvedValues) {\n LimitTimerRaceResolvedValues[\"LIMIT\"] = \"LIMIT\";\n LimitTimerRaceResolvedValues[\"TIMER\"] = \"TIMER\";\n})(LimitTimerRaceResolvedValues || (LimitTimerRaceResolvedValues = {}));\n/**\n * A pointer used by DataStore internally to lookup predicate details\n * that should not be exposed on public customer interfaces.\n */\nexport class PredicateInternalsKey {\n constructor() {\n this.__isPredicateInternalsKeySentinel = true;\n }\n}\n// #endregion\n"],"names":[],"mappings":";;AACO,SAAS,aAAa,CAAC,GAAG,EAAE;AACnC,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC;AAC/C,CAAC;AACM,SAAS,2BAA2B,CAAC,CAAC,EAAE;AAC/C,IAAI,OAAO,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,CAAC;AAC1D,CAAC;AACM,SAAS,gBAAgB,CAAC,GAAG,EAAE;AACtC,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC;AACrC,CAAC;AACM,SAAS,uBAAuB,CAAC,GAAG,EAAE;AAC7C,IAAI,OAAO,GAAG,EAAE,UAAU,IAAI,GAAG,EAAE,WAAW,CAAC;AAC/C,CAAC;AACM,SAAS,kBAAkB,CAAC,GAAG,EAAE,SAAS,EAAE;AACnD,IAAI,OAAO,GAAG,EAAE,MAAM,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,CAAC,gBAAgB,EAAE,iBAAiB,EAAE;AAC1E,IAAI,OAAO;AACX,QAAQ,gBAAgB;AACxB,QAAQ,iBAAiB;AACzB,KAAK,CAAC;AACN,CAAC;AACS,IAAC,YAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACjC,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACrC,IAAI,WAAW,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC3C,CAAC,EAAE,WAAW,KAAK,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;AAC1B,MAAC,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE;AAC/B,IAAC,6BAA6B;AACxC,CAAC,UAAU,4BAA4B,EAAE;AACzC,IAAI,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD,IAAI,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD,CAAC,EAAE,4BAA4B,KAAK,4BAA4B,GAAG,EAAE,CAAC,CAAC,CAAC;AACxE;AACA;AACA;AACA;AACO,MAAM,qBAAqB,CAAC;AACnC,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,iCAAiC,GAAG,IAAI,CAAC;AACtD,KAAK;AACL,CAAC;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../../src/types.ts"],"sourcesContent":["import { extractPrimaryKeyFieldNames, isAWSDate, isAWSDateTime, isAWSEmail, isAWSIPAddress, isAWSJSON, isAWSPhone, isAWSTime, isAWSTimestamp, isAWSURL, } from './util';\n/**\n * @private\n * @param obj\n * @returns `true` if the given object likely represents a model in a schema.\n */\nexport function isSchemaModel(obj) {\n return obj && obj.pluralName !== undefined;\n}\n/**\n * @private\n * @param m\n * @returns `true` if the given schema entry defines Schema Model attributes.\n */\nexport function isSchemaModelWithAttributes(m) {\n return isSchemaModel(m) && m.attributes !== undefined;\n}\n/**\n * @private\n * @param obj\n * @returns `true` if the object is an `AssociatedWith` definition.\n */\nexport function isAssociatedWith(obj) {\n return obj && obj.associatedWith;\n}\n/**\n * @private\n * @param obj\n * @returns `true` if the given object specifies either `targetName` or `targetNames`.\n */\nexport function isTargetNameAssociation(obj) {\n return obj?.targetName || obj?.targetNames;\n}\n/**\n * @private\n * @param obj\n * @param fieldName\n * @returns Truthy if the object has a `FieldAssociation` for the given `fieldName`.\n */\nexport function isFieldAssociation(obj, fieldName) {\n return obj?.fields[fieldName]?.association?.connectionType;\n}\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute is an auth attribute with rules.\n */\nexport function isModelAttributeAuth(attr) {\n return (attr.type === 'auth' &&\n attr.properties &&\n attr.properties.rules &&\n attr.properties.rules.length > 0);\n}\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute is a key field.\n */\nexport function isModelAttributeKey(attr) {\n return (attr.type === 'key' &&\n attr.properties &&\n attr.properties.fields &&\n attr.properties.fields.length > 0);\n}\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute is a primary key, indicated by the key being unnamed.\n */\nexport function isModelAttributePrimaryKey(attr) {\n return isModelAttributeKey(attr) && attr.properties.name === undefined;\n}\n/**\n * @private\n * @param attr\n * @returns `true` if the given attribute represents a composite key with multiple fields.\n */\nexport function isModelAttributeCompositeKey(attr) {\n return (isModelAttributeKey(attr) &&\n attr.properties.name !== undefined &&\n attr.properties.fields.length > 2);\n}\nexport var ModelAttributeAuthAllow;\n(function (ModelAttributeAuthAllow) {\n ModelAttributeAuthAllow[\"CUSTOM\"] = \"custom\";\n ModelAttributeAuthAllow[\"OWNER\"] = \"owner\";\n ModelAttributeAuthAllow[\"GROUPS\"] = \"groups\";\n ModelAttributeAuthAllow[\"PRIVATE\"] = \"private\";\n ModelAttributeAuthAllow[\"PUBLIC\"] = \"public\";\n})(ModelAttributeAuthAllow || (ModelAttributeAuthAllow = {}));\nexport var ModelAttributeAuthProvider;\n(function (ModelAttributeAuthProvider) {\n ModelAttributeAuthProvider[\"FUNCTION\"] = \"function\";\n ModelAttributeAuthProvider[\"USER_POOLS\"] = \"userPools\";\n ModelAttributeAuthProvider[\"OIDC\"] = \"oidc\";\n ModelAttributeAuthProvider[\"IAM\"] = \"iam\";\n ModelAttributeAuthProvider[\"API_KEY\"] = \"apiKey\";\n})(ModelAttributeAuthProvider || (ModelAttributeAuthProvider = {}));\nexport var GraphQLScalarType;\n(function (GraphQLScalarType) {\n GraphQLScalarType[GraphQLScalarType[\"ID\"] = 0] = \"ID\";\n GraphQLScalarType[GraphQLScalarType[\"String\"] = 1] = \"String\";\n GraphQLScalarType[GraphQLScalarType[\"Int\"] = 2] = \"Int\";\n GraphQLScalarType[GraphQLScalarType[\"Float\"] = 3] = \"Float\";\n GraphQLScalarType[GraphQLScalarType[\"Boolean\"] = 4] = \"Boolean\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDate\"] = 5] = \"AWSDate\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTime\"] = 6] = \"AWSTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSDateTime\"] = 7] = \"AWSDateTime\";\n GraphQLScalarType[GraphQLScalarType[\"AWSTimestamp\"] = 8] = \"AWSTimestamp\";\n GraphQLScalarType[GraphQLScalarType[\"AWSEmail\"] = 9] = \"AWSEmail\";\n GraphQLScalarType[GraphQLScalarType[\"AWSJSON\"] = 10] = \"AWSJSON\";\n GraphQLScalarType[GraphQLScalarType[\"AWSURL\"] = 11] = \"AWSURL\";\n GraphQLScalarType[GraphQLScalarType[\"AWSPhone\"] = 12] = \"AWSPhone\";\n GraphQLScalarType[GraphQLScalarType[\"AWSIPAddress\"] = 13] = \"AWSIPAddress\";\n})(GraphQLScalarType || (GraphQLScalarType = {}));\n// eslint-disable-next-line @typescript-eslint/no-namespace\n(function (GraphQLScalarType) {\n function getJSType(scalar) {\n switch (scalar) {\n case 'Boolean':\n return 'boolean';\n case 'ID':\n case 'String':\n case 'AWSDate':\n case 'AWSTime':\n case 'AWSDateTime':\n case 'AWSEmail':\n case 'AWSURL':\n case 'AWSPhone':\n case 'AWSIPAddress':\n return 'string';\n case 'Int':\n case 'Float':\n case 'AWSTimestamp':\n return 'number';\n case 'AWSJSON':\n return 'object';\n default:\n throw new Error('Invalid scalar type');\n }\n }\n GraphQLScalarType.getJSType = getJSType;\n function getValidationFunction(scalar) {\n switch (scalar) {\n case 'AWSDate':\n return isAWSDate;\n case 'AWSTime':\n return isAWSTime;\n case 'AWSDateTime':\n return isAWSDateTime;\n case 'AWSTimestamp':\n return isAWSTimestamp;\n case 'AWSEmail':\n return isAWSEmail;\n case 'AWSJSON':\n return isAWSJSON;\n case 'AWSURL':\n return isAWSURL;\n case 'AWSPhone':\n return isAWSPhone;\n case 'AWSIPAddress':\n return isAWSIPAddress;\n default:\n return undefined;\n }\n }\n GraphQLScalarType.getValidationFunction = getValidationFunction;\n})(GraphQLScalarType || (GraphQLScalarType = {}));\n/**\n * @private\n * @returns `true` if the given field specifies a scalar type.\n */\nexport function isGraphQLScalarType(obj) {\n return obj && GraphQLScalarType[obj] !== undefined;\n}\n/**\n * @private\n * @param obj\n * @returns `true` if the given field specifies a Model.\n */\nexport function isModelFieldType(obj) {\n const modelField = 'model';\n if (obj && obj[modelField])\n return true;\n return false;\n}\n/**\n * @private\n * @param obj\n * @returns `true` if the given field specifies a custom non-model type.\n */\nexport function isNonModelFieldType(obj) {\n const typeField = 'nonModel';\n if (obj && obj[typeField])\n return true;\n return false;\n}\n/**\n * @private\n * @param obj\n * @returns `true` if the object is an `EnumFieldType`.\n */\nexport function isEnumFieldType(obj) {\n const modelField = 'enum';\n if (obj && obj[modelField])\n return true;\n return false;\n}\n/**\n * @private\n * @param obj\n * @param modelDefinition\n * @returns `true` if the given item is an object that has all identifier fields populated.\n */\nexport function isIdentifierObject(obj, modelDefinition) {\n const keys = extractPrimaryKeyFieldNames(modelDefinition);\n return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));\n}\n// #endregion\n// #region Subscription messages\nexport var OpType;\n(function (OpType) {\n OpType[\"INSERT\"] = \"INSERT\";\n OpType[\"UPDATE\"] = \"UPDATE\";\n OpType[\"DELETE\"] = \"DELETE\";\n})(OpType || (OpType = {}));\n/**\n * @private\n * @param obj\n * @returns `true` if the given predicate field object, specifying an [in-]equality test against a field.\n */\nexport function isPredicateObj(obj) {\n return obj && obj.field !== undefined;\n}\n/**\n * @private\n * @param obj\n * @returns `true` if the given predicate object is a \"group\" like \"and\", \"or\", or \"not\".\n */\nexport function isPredicateGroup(obj) {\n return obj && obj.type !== undefined;\n}\nexport var QueryOne;\n(function (QueryOne) {\n QueryOne[QueryOne[\"FIRST\"] = 0] = \"FIRST\";\n QueryOne[QueryOne[\"LAST\"] = 1] = \"LAST\";\n})(QueryOne || (QueryOne = {}));\nexport var SortDirection;\n(function (SortDirection) {\n SortDirection[\"ASCENDING\"] = \"ASCENDING\";\n SortDirection[\"DESCENDING\"] = \"DESCENDING\";\n})(SortDirection || (SortDirection = {}));\nexport var AuthModeStrategyType;\n(function (AuthModeStrategyType) {\n AuthModeStrategyType[\"DEFAULT\"] = \"DEFAULT\";\n AuthModeStrategyType[\"MULTI_AUTH\"] = \"MULTI_AUTH\";\n})(AuthModeStrategyType || (AuthModeStrategyType = {}));\nexport var ModelOperation;\n(function (ModelOperation) {\n ModelOperation[\"CREATE\"] = \"CREATE\";\n ModelOperation[\"READ\"] = \"READ\";\n ModelOperation[\"UPDATE\"] = \"UPDATE\";\n ModelOperation[\"DELETE\"] = \"DELETE\";\n})(ModelOperation || (ModelOperation = {}));\n/**\n * Build an expression that can be used to filter which items of a given Model\n * are synchronized down from the GraphQL service. E.g.,\n *\n * ```ts\n * import { DataStore, syncExpression } from 'aws-amplify/datastore';\n * import { Post, Comment } from './models';\n *\n *\n * DataStore.configure({\n * \tsyncExpressions: [\n * \t\tsyncExpression(Post, () => {\n * \t\t\treturn (post) => post.rating.gt(5);\n * \t\t}),\n * \t\tsyncExpression(Comment, () => {\n * \t\t\treturn (comment) => comment.status.eq('active');\n * \t\t})\n * \t]\n * });\n * ```\n *\n * When DataStore starts syncing, only Posts with `rating > 5` and Comments with\n * `status === 'active'` will be synced down to the user's local store.\n *\n * @param modelConstructor The Model from the schema.\n * @param conditionProducer A function that builds a condition object that can describe how to filter the model.\n * @returns An sync expression object that can be attached to the DataStore `syncExpressions` configuration property.\n */\nexport async function syncExpression(modelConstructor, conditionProducer) {\n return {\n modelConstructor,\n conditionProducer,\n };\n}\nexport var ProcessName;\n(function (ProcessName) {\n ProcessName[\"sync\"] = \"sync\";\n ProcessName[\"mutate\"] = \"mutate\";\n ProcessName[\"subscribe\"] = \"subscribe\";\n})(ProcessName || (ProcessName = {}));\nexport const DISCARD = Symbol('DISCARD');\nexport var LimitTimerRaceResolvedValues;\n(function (LimitTimerRaceResolvedValues) {\n LimitTimerRaceResolvedValues[\"LIMIT\"] = \"LIMIT\";\n LimitTimerRaceResolvedValues[\"TIMER\"] = \"TIMER\";\n})(LimitTimerRaceResolvedValues || (LimitTimerRaceResolvedValues = {}));\n/**\n * A pointer used by DataStore internally to lookup predicate details\n * that should not be exposed on public customer interfaces.\n */\nexport class PredicateInternalsKey {\n constructor() {\n this.__isPredicateInternalsKeySentinel = true;\n }\n}\n// #endregion\n"],"names":[],"mappings":";;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,GAAG,EAAE;AACnC,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC;AAC/C,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2B,CAAC,CAAC,EAAE;AAC/C,IAAI,OAAO,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,CAAC;AAC1D,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,GAAG,EAAE;AACtC,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC;AACrC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pD,IAAI,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACpD,CAAC,EAAE,4BAA4B,KAAK,4BAA4B,GAAG,EAAE,CAAC,CAAC,CAAC;AACxE;AACA;AACA;AACA;AACO,MAAM,qBAAqB,CAAC;AACnC,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,iCAAiC,GAAG,IAAI,CAAC;AACtD,KAAK;AACL,CAAC;AACD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/datastore",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.47",
|
|
4
4
|
"description": "AppSyncLocal support for aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"src"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@aws-amplify/api": "6.0.
|
|
47
|
+
"@aws-amplify/api": "6.0.47",
|
|
48
48
|
"buffer": "4.9.2",
|
|
49
49
|
"idb": "5.0.6",
|
|
50
50
|
"immer": "9.0.6",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@aws-amplify/core": "^6.1.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@aws-amplify/core": "6.3.
|
|
58
|
+
"@aws-amplify/core": "6.3.12",
|
|
59
59
|
"@aws-amplify/react-native": "1.1.4",
|
|
60
60
|
"@types/uuid-validate": "^0.0.1",
|
|
61
61
|
"dexie": "3.2.2",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"limit": "65.25 kB"
|
|
73
73
|
}
|
|
74
74
|
],
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e2e9c5af8ce2c0a6f89e87e224c16d8551c491bd"
|
|
76
76
|
}
|
package/src/types.ts
CHANGED
|
@@ -71,10 +71,20 @@ export interface SchemaModel {
|
|
|
71
71
|
syncable?: boolean;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @private
|
|
76
|
+
* @param obj
|
|
77
|
+
* @returns `true` if the given object likely represents a model in a schema.
|
|
78
|
+
*/
|
|
74
79
|
export function isSchemaModel(obj: any): obj is SchemaModel {
|
|
75
80
|
return obj && (obj as SchemaModel).pluralName !== undefined;
|
|
76
81
|
}
|
|
77
82
|
|
|
83
|
+
/**
|
|
84
|
+
* @private
|
|
85
|
+
* @param m
|
|
86
|
+
* @returns `true` if the given schema entry defines Schema Model attributes.
|
|
87
|
+
*/
|
|
78
88
|
export function isSchemaModelWithAttributes(
|
|
79
89
|
m: SchemaModel | SchemaNonModel,
|
|
80
90
|
): m is SchemaModel {
|
|
@@ -104,6 +114,11 @@ interface AssociatedWith {
|
|
|
104
114
|
targetNames?: string[];
|
|
105
115
|
}
|
|
106
116
|
|
|
117
|
+
/**
|
|
118
|
+
* @private
|
|
119
|
+
* @param obj
|
|
120
|
+
* @returns `true` if the object is an `AssociatedWith` definition.
|
|
121
|
+
*/
|
|
107
122
|
export function isAssociatedWith(obj: any): obj is AssociatedWith {
|
|
108
123
|
return obj && obj.associatedWith;
|
|
109
124
|
}
|
|
@@ -114,6 +129,11 @@ interface TargetNameAssociation {
|
|
|
114
129
|
targetNames?: string[];
|
|
115
130
|
}
|
|
116
131
|
|
|
132
|
+
/**
|
|
133
|
+
* @private
|
|
134
|
+
* @param obj
|
|
135
|
+
* @returns `true` if the given object specifies either `targetName` or `targetNames`.
|
|
136
|
+
*/
|
|
117
137
|
export function isTargetNameAssociation(
|
|
118
138
|
obj: any,
|
|
119
139
|
): obj is TargetNameAssociation {
|
|
@@ -123,6 +143,13 @@ export function isTargetNameAssociation(
|
|
|
123
143
|
interface FieldAssociation {
|
|
124
144
|
connectionType: 'HAS_ONE' | 'BELONGS_TO' | 'HAS_MANY';
|
|
125
145
|
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @private
|
|
149
|
+
* @param obj
|
|
150
|
+
* @param fieldName
|
|
151
|
+
* @returns Truthy if the object has a `FieldAssociation` for the given `fieldName`.
|
|
152
|
+
*/
|
|
126
153
|
export function isFieldAssociation(
|
|
127
154
|
obj: any,
|
|
128
155
|
fieldName: string,
|
|
@@ -154,6 +181,11 @@ export interface ModelAttributeAuth {
|
|
|
154
181
|
};
|
|
155
182
|
}
|
|
156
183
|
|
|
184
|
+
/**
|
|
185
|
+
* @private
|
|
186
|
+
* @param attr
|
|
187
|
+
* @returns `true` if the given attribute is an auth attribute with rules.
|
|
188
|
+
*/
|
|
157
189
|
export function isModelAttributeAuth(
|
|
158
190
|
attr: ModelAttribute,
|
|
159
191
|
): attr is ModelAttributeAuth {
|
|
@@ -189,6 +221,11 @@ interface ModelAttributeCompositeKey {
|
|
|
189
221
|
};
|
|
190
222
|
}
|
|
191
223
|
|
|
224
|
+
/**
|
|
225
|
+
* @private
|
|
226
|
+
* @param attr
|
|
227
|
+
* @returns `true` if the given attribute is a key field.
|
|
228
|
+
*/
|
|
192
229
|
export function isModelAttributeKey(
|
|
193
230
|
attr: ModelAttribute,
|
|
194
231
|
): attr is ModelAttributeKey {
|
|
@@ -200,12 +237,22 @@ export function isModelAttributeKey(
|
|
|
200
237
|
);
|
|
201
238
|
}
|
|
202
239
|
|
|
240
|
+
/**
|
|
241
|
+
* @private
|
|
242
|
+
* @param attr
|
|
243
|
+
* @returns `true` if the given attribute is a primary key, indicated by the key being unnamed.
|
|
244
|
+
*/
|
|
203
245
|
export function isModelAttributePrimaryKey(
|
|
204
246
|
attr: ModelAttribute,
|
|
205
247
|
): attr is ModelAttributePrimaryKey {
|
|
206
248
|
return isModelAttributeKey(attr) && attr.properties.name === undefined;
|
|
207
249
|
}
|
|
208
250
|
|
|
251
|
+
/**
|
|
252
|
+
* @private
|
|
253
|
+
* @param attr
|
|
254
|
+
* @returns `true` if the given attribute represents a composite key with multiple fields.
|
|
255
|
+
*/
|
|
209
256
|
export function isModelAttributeCompositeKey(
|
|
210
257
|
attr: ModelAttribute,
|
|
211
258
|
): attr is ModelAttributeCompositeKey {
|
|
@@ -334,6 +381,10 @@ export interface AuthorizationRule {
|
|
|
334
381
|
areSubscriptionsPublic: boolean;
|
|
335
382
|
}
|
|
336
383
|
|
|
384
|
+
/**
|
|
385
|
+
* @private
|
|
386
|
+
* @returns `true` if the given field specifies a scalar type.
|
|
387
|
+
*/
|
|
337
388
|
export function isGraphQLScalarType(
|
|
338
389
|
obj: any,
|
|
339
390
|
): obj is keyof Omit<
|
|
@@ -347,6 +398,12 @@ export interface ModelFieldType {
|
|
|
347
398
|
model: string;
|
|
348
399
|
modelConstructor?: ModelMeta<PersistentModel>;
|
|
349
400
|
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* @private
|
|
404
|
+
* @param obj
|
|
405
|
+
* @returns `true` if the given field specifies a Model.
|
|
406
|
+
*/
|
|
350
407
|
export function isModelFieldType<_ extends PersistentModel>(
|
|
351
408
|
obj: any,
|
|
352
409
|
): obj is ModelFieldType {
|
|
@@ -359,6 +416,12 @@ export function isModelFieldType<_ extends PersistentModel>(
|
|
|
359
416
|
export interface NonModelFieldType {
|
|
360
417
|
nonModel: string;
|
|
361
418
|
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @private
|
|
422
|
+
* @param obj
|
|
423
|
+
* @returns `true` if the given field specifies a custom non-model type.
|
|
424
|
+
*/
|
|
362
425
|
export function isNonModelFieldType(obj: any): obj is NonModelFieldType {
|
|
363
426
|
const typeField: keyof NonModelFieldType = 'nonModel';
|
|
364
427
|
if (obj && obj[typeField]) return true;
|
|
@@ -369,6 +432,12 @@ export function isNonModelFieldType(obj: any): obj is NonModelFieldType {
|
|
|
369
432
|
interface EnumFieldType {
|
|
370
433
|
enum: string;
|
|
371
434
|
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @private
|
|
438
|
+
* @param obj
|
|
439
|
+
* @returns `true` if the object is an `EnumFieldType`.
|
|
440
|
+
*/
|
|
372
441
|
export function isEnumFieldType(obj: any): obj is EnumFieldType {
|
|
373
442
|
const modelField: keyof EnumFieldType = 'enum';
|
|
374
443
|
if (obj && obj[modelField]) return true;
|
|
@@ -648,6 +717,12 @@ export type IdentifierFieldOrIdentifierObject<
|
|
|
648
717
|
M extends PersistentModelMetaData<T>,
|
|
649
718
|
> = Pick<T, IdentifierFields<T, M>> | IdentifierFieldValue<T, M>;
|
|
650
719
|
|
|
720
|
+
/**
|
|
721
|
+
* @private
|
|
722
|
+
* @param obj
|
|
723
|
+
* @param modelDefinition
|
|
724
|
+
* @returns `true` if the given item is an object that has all identifier fields populated.
|
|
725
|
+
*/
|
|
651
726
|
export function isIdentifierObject<T extends PersistentModel>(
|
|
652
727
|
obj: any,
|
|
653
728
|
modelDefinition: SchemaModel,
|
|
@@ -772,12 +847,22 @@ export interface PredicatesGroup<T extends PersistentModel> {
|
|
|
772
847
|
predicates: (PredicateObject<T> | PredicatesGroup<T>)[];
|
|
773
848
|
}
|
|
774
849
|
|
|
850
|
+
/**
|
|
851
|
+
* @private
|
|
852
|
+
* @param obj
|
|
853
|
+
* @returns `true` if the given predicate field object, specifying an [in-]equality test against a field.
|
|
854
|
+
*/
|
|
775
855
|
export function isPredicateObj<T extends PersistentModel>(
|
|
776
856
|
obj: any,
|
|
777
857
|
): obj is PredicateObject<T> {
|
|
778
858
|
return obj && (obj as PredicateObject<T>).field !== undefined;
|
|
779
859
|
}
|
|
780
860
|
|
|
861
|
+
/**
|
|
862
|
+
* @private
|
|
863
|
+
* @param obj
|
|
864
|
+
* @returns `true` if the given predicate object is a "group" like "and", "or", or "not".
|
|
865
|
+
*/
|
|
781
866
|
export function isPredicateGroup<T extends PersistentModel>(
|
|
782
867
|
obj: any,
|
|
783
868
|
): obj is PredicatesGroup<T> {
|
|
@@ -1032,6 +1117,34 @@ type ConditionProducer<T extends PersistentModel, A extends Option<T>> = (
|
|
|
1032
1117
|
...args: A
|
|
1033
1118
|
) => A['length'] extends keyof Lookup<T> ? Lookup<T>[A['length']] : never;
|
|
1034
1119
|
|
|
1120
|
+
/**
|
|
1121
|
+
* Build an expression that can be used to filter which items of a given Model
|
|
1122
|
+
* are synchronized down from the GraphQL service. E.g.,
|
|
1123
|
+
*
|
|
1124
|
+
* ```ts
|
|
1125
|
+
* import { DataStore, syncExpression } from 'aws-amplify/datastore';
|
|
1126
|
+
* import { Post, Comment } from './models';
|
|
1127
|
+
*
|
|
1128
|
+
*
|
|
1129
|
+
* DataStore.configure({
|
|
1130
|
+
* syncExpressions: [
|
|
1131
|
+
* syncExpression(Post, () => {
|
|
1132
|
+
* return (post) => post.rating.gt(5);
|
|
1133
|
+
* }),
|
|
1134
|
+
* syncExpression(Comment, () => {
|
|
1135
|
+
* return (comment) => comment.status.eq('active');
|
|
1136
|
+
* })
|
|
1137
|
+
* ]
|
|
1138
|
+
* });
|
|
1139
|
+
* ```
|
|
1140
|
+
*
|
|
1141
|
+
* When DataStore starts syncing, only Posts with `rating > 5` and Comments with
|
|
1142
|
+
* `status === 'active'` will be synced down to the user's local store.
|
|
1143
|
+
*
|
|
1144
|
+
* @param modelConstructor The Model from the schema.
|
|
1145
|
+
* @param conditionProducer A function that builds a condition object that can describe how to filter the model.
|
|
1146
|
+
* @returns An sync expression object that can be attached to the DataStore `syncExpressions` configuration property.
|
|
1147
|
+
*/
|
|
1035
1148
|
export async function syncExpression<
|
|
1036
1149
|
T extends PersistentModel,
|
|
1037
1150
|
A extends Option<T>,
|