@aws-amplify/datastore 5.0.90-unstable.bd2125d.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,6 +54,8 @@ exports.comparisonKeys = new Set([
54
54
  'notContains',
55
55
  'beginsWith',
56
56
  'between',
57
+ 'in',
58
+ 'notIn',
57
59
  ]);
58
60
  /**
59
61
  * Determines whether an object is a GraphQL style predicate comparison node, which must
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/predicates/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ModelPredicateCreator = exports.Predicates = exports.PredicateAll = exports.comparisonKeys = exports.ModelSortPredicateCreator = void 0;\nexports.isPredicatesAll = isPredicatesAll;\nconst util_1 = require(\"../util\");\nvar sort_1 = require(\"./sort\");\nObject.defineProperty(exports, \"ModelSortPredicateCreator\", { enumerable: true, get: function () { return sort_1.ModelSortPredicateCreator; } });\nconst predicatesAllSet = new WeakSet();\nfunction isPredicatesAll(predicate) {\n return predicatesAllSet.has(predicate);\n}\n/**\n * The valid logical grouping keys for a predicate group.\n */\nconst groupKeys = new Set(['and', 'or', 'not']);\n/**\n * Determines whether an object is a GraphQL style predicate \"group\", which must be an\n * object containing a single \"group key\", which then contains the child condition(s).\n *\n * E.g.,\n *\n * ```\n * { and: [ ... ] }\n * { not: { ... } }\n * ```\n *\n * @param o The object to test.\n */\nconst isGroup = o => {\n const keys = [...Object.keys(o)];\n return keys.length === 1 && groupKeys.has(keys[0]);\n};\n/**\n * Determines whether an object specifies no conditions and should match everything,\n * as would be the case with `Predicates.ALL`.\n *\n * @param o The object to test.\n */\nconst isEmpty = o => {\n return !Array.isArray(o) && Object.keys(o).length === 0;\n};\n/**\n * The valid comparison operators that can be used as keys in a predicate comparison object.\n */\nexports.comparisonKeys = new Set([\n 'eq',\n 'ne',\n 'gt',\n 'lt',\n 'ge',\n 'le',\n 'contains',\n 'notContains',\n 'beginsWith',\n 'between',\n]);\n/**\n * Determines whether an object is a GraphQL style predicate comparison node, which must\n * be an object containing a single \"comparison operator\" key, which then contains the\n * operand or operands to compare against.\n *\n * @param o The object to test.\n */\nconst isComparison = o => {\n const keys = [...Object.keys(o)];\n return !Array.isArray(o) && keys.length === 1 && exports.comparisonKeys.has(keys[0]);\n};\n/**\n * A light check to determine whether an object is a valid GraphQL Condition AST.\n *\n * @param o The object to test.\n */\nconst isValid = o => {\n if (Array.isArray(o)) {\n return o.every(v => isValid(v));\n }\n else {\n return Object.keys(o).length <= 1;\n }\n};\n// This symbol is not used at runtime, only its type (unique symbol)\nexports.PredicateAll = Symbol('A predicate that matches all records');\nclass Predicates {\n static get ALL() {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const predicate = (c => c);\n predicatesAllSet.add(predicate);\n return predicate;\n }\n}\nexports.Predicates = Predicates;\nclass ModelPredicateCreator {\n /**\n * Determines whether the given storage predicate (lookup key) is a predicate\n * key that DataStore recognizes.\n *\n * @param predicate The storage predicate (lookup key) to test.\n */\n static isValidPredicate(predicate) {\n return ModelPredicateCreator.predicateGroupsMap.has(predicate);\n }\n /**\n * Looks for the storage predicate AST that corresponds to a given storage\n * predicate key.\n *\n * The key must have been created internally by a DataStore utility\n * method, such as `ModelPredicate.createFromAST()`.\n *\n * @param predicate The predicate reference to look up.\n * @param throwOnInvalid Whether to throw an exception if the predicate\n * isn't a valid DataStore predicate.\n */\n static getPredicates(predicate, throwOnInvalid = true) {\n if (throwOnInvalid && !ModelPredicateCreator.isValidPredicate(predicate)) {\n throw new Error('The predicate is not valid');\n }\n return ModelPredicateCreator.predicateGroupsMap.get(predicate);\n }\n /**\n * using the PK values from the given `model` (which can be a partial of T\n * Creates a predicate that matches an instance described by `modelDefinition`\n * that contains only PK field values.)\n *\n * @param modelDefinition The model definition to create a predicate for.\n * @param model The model instance to extract value equalities from.\n */\n static createForPk(modelDefinition, model) {\n const keyFields = (0, util_1.extractPrimaryKeyFieldNames)(modelDefinition);\n const keyValues = (0, util_1.extractPrimaryKeyValues)(model, keyFields);\n const predicate = this.createFromAST(modelDefinition, {\n and: keyFields.map((field, idx) => {\n const operand = keyValues[idx];\n return { [field]: { eq: operand } };\n }),\n });\n return predicate;\n }\n /**\n * Searches a `Model` table for records matching the given equalities object.\n *\n * This only matches against fields given in the equalities object. No other\n * fields are tested by the predicate.\n *\n * @param modelDefinition The model we need a predicate for.\n * @param flatEqualities An object holding field equalities to search for.\n */\n static createFromFlatEqualities(modelDefinition, flatEqualities) {\n const ast = {\n and: Object.entries(flatEqualities).map(([k, v]) => ({ [k]: { eq: v } })),\n };\n return this.createFromAST(modelDefinition, ast);\n }\n /**\n * Accepts a GraphQL style filter predicate tree and transforms it into an\n * AST that can be used for a storage adapter predicate. Example input:\n *\n * ```js\n * {\n * \tand: [\n * \t\t{ name: { eq: \"Bob Jones\" } },\n * \t\t{ age: { between: [32, 64] } },\n * \t\t{ not: {\n * \t\t\tor: [\n * \t\t\t\t{ favoriteFood: { eq: 'pizza' } },\n * \t\t\t\t{ favoriteFood: { eq: 'tacos' } },\n * \t\t\t]\n * \t\t}}\n * \t]\n * }\n * ```\n *\n * @param gql GraphQL style filter node.\n */\n static transformGraphQLFilterNodeToPredicateAST(gql) {\n if (!isValid(gql)) {\n throw new Error('Invalid GraphQL Condition or subtree: ' + JSON.stringify(gql));\n }\n if (isEmpty(gql)) {\n return {\n type: 'and',\n predicates: [],\n };\n }\n else if (isGroup(gql)) {\n const groupkey = Object.keys(gql)[0];\n const children = this.transformGraphQLFilterNodeToPredicateAST(gql[groupkey]);\n return {\n type: groupkey,\n predicates: Array.isArray(children) ? children : [children],\n };\n }\n else if (isComparison(gql)) {\n const operatorKey = Object.keys(gql)[0];\n return {\n operator: operatorKey,\n operand: gql[operatorKey],\n };\n }\n else {\n if (Array.isArray(gql)) {\n return gql.map(o => this.transformGraphQLFilterNodeToPredicateAST(o));\n }\n else {\n const fieldKey = Object.keys(gql)[0];\n return {\n field: fieldKey,\n ...this.transformGraphQLFilterNodeToPredicateAST(gql[fieldKey]),\n };\n }\n }\n }\n /**\n * Accepts a GraphQL style filter predicate tree and transforms it into a predicate\n * that storage adapters understand. Example input:\n *\n * ```js\n * {\n * \tand: [\n * \t\t{ name: { eq: \"Bob Jones\" } },\n * \t\t{ age: { between: [32, 64] } },\n * \t\t{ not: {\n * \t\t\tor: [\n * \t\t\t\t{ favoriteFood: { eq: 'pizza' } },\n * \t\t\t\t{ favoriteFood: { eq: 'tacos' } },\n * \t\t\t]\n * \t\t}}\n * \t]\n * }\n * ```\n *\n * @param modelDefinition The model that the AST/predicate must be compatible with.\n * @param ast The graphQL style AST that should specify conditions for `modelDefinition`.\n */\n static createFromAST(modelDefinition, ast) {\n const key = {};\n ModelPredicateCreator.predicateGroupsMap.set(key, this.transformGraphQLFilterNodeToPredicateAST(ast));\n return key;\n }\n}\nexports.ModelPredicateCreator = ModelPredicateCreator;\n/**\n * Map of storage predicates (key objects) to storage predicate AST's.\n */\nModelPredicateCreator.predicateGroupsMap = new WeakMap();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,yBAAyB,GAAG,MAAM;AAC/I,OAAO,CAAC,eAAe,GAAG,eAAe;AACzC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;AACjC,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAC9B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,2BAA2B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,CAAC;AAChJ,MAAM,gBAAg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CAAC,CAAC,CAAC;AACpD,gBAAgB,OAAO;AACvB,oBAAoB,KAAK,EAAE,QAAQ;AACnC,oBAAoB,GAAG,IAAI,CAAC,wCAAwC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnF,iBAAiB;AACjB,YAAY;AACZ,QAAQ;AACR,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,aAAa,CAAC,eAAe,EAAE,GAAG,EAAE;AAC/C,QAAQ,MAAM,GAAG,GAAG,EAAE;AACtB,QAAQ,qBAAqB,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,wCAAwC,CAAC,GAAG,CAAC,CAAC;AAC7G,QAAQ,OAAO,GAAG;AAClB,IAAI;AACJ;AACA,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD;AACA;AACA;AACA,qBAAqB,CAAC,kBAAkB,GAAG,IAAI,OAAO,EAAE;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/predicates/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ModelPredicateCreator = exports.Predicates = exports.PredicateAll = exports.comparisonKeys = exports.ModelSortPredicateCreator = void 0;\nexports.isPredicatesAll = isPredicatesAll;\nconst util_1 = require(\"../util\");\nvar sort_1 = require(\"./sort\");\nObject.defineProperty(exports, \"ModelSortPredicateCreator\", { enumerable: true, get: function () { return sort_1.ModelSortPredicateCreator; } });\nconst predicatesAllSet = new WeakSet();\nfunction isPredicatesAll(predicate) {\n return predicatesAllSet.has(predicate);\n}\n/**\n * The valid logical grouping keys for a predicate group.\n */\nconst groupKeys = new Set(['and', 'or', 'not']);\n/**\n * Determines whether an object is a GraphQL style predicate \"group\", which must be an\n * object containing a single \"group key\", which then contains the child condition(s).\n *\n * E.g.,\n *\n * ```\n * { and: [ ... ] }\n * { not: { ... } }\n * ```\n *\n * @param o The object to test.\n */\nconst isGroup = o => {\n const keys = [...Object.keys(o)];\n return keys.length === 1 && groupKeys.has(keys[0]);\n};\n/**\n * Determines whether an object specifies no conditions and should match everything,\n * as would be the case with `Predicates.ALL`.\n *\n * @param o The object to test.\n */\nconst isEmpty = o => {\n return !Array.isArray(o) && Object.keys(o).length === 0;\n};\n/**\n * The valid comparison operators that can be used as keys in a predicate comparison object.\n */\nexports.comparisonKeys = new Set([\n 'eq',\n 'ne',\n 'gt',\n 'lt',\n 'ge',\n 'le',\n 'contains',\n 'notContains',\n 'beginsWith',\n 'between',\n 'in',\n 'notIn',\n]);\n/**\n * Determines whether an object is a GraphQL style predicate comparison node, which must\n * be an object containing a single \"comparison operator\" key, which then contains the\n * operand or operands to compare against.\n *\n * @param o The object to test.\n */\nconst isComparison = o => {\n const keys = [...Object.keys(o)];\n return !Array.isArray(o) && keys.length === 1 && exports.comparisonKeys.has(keys[0]);\n};\n/**\n * A light check to determine whether an object is a valid GraphQL Condition AST.\n *\n * @param o The object to test.\n */\nconst isValid = o => {\n if (Array.isArray(o)) {\n return o.every(v => isValid(v));\n }\n else {\n return Object.keys(o).length <= 1;\n }\n};\n// This symbol is not used at runtime, only its type (unique symbol)\nexports.PredicateAll = Symbol('A predicate that matches all records');\nclass Predicates {\n static get ALL() {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const predicate = (c => c);\n predicatesAllSet.add(predicate);\n return predicate;\n }\n}\nexports.Predicates = Predicates;\nclass ModelPredicateCreator {\n /**\n * Determines whether the given storage predicate (lookup key) is a predicate\n * key that DataStore recognizes.\n *\n * @param predicate The storage predicate (lookup key) to test.\n */\n static isValidPredicate(predicate) {\n return ModelPredicateCreator.predicateGroupsMap.has(predicate);\n }\n /**\n * Looks for the storage predicate AST that corresponds to a given storage\n * predicate key.\n *\n * The key must have been created internally by a DataStore utility\n * method, such as `ModelPredicate.createFromAST()`.\n *\n * @param predicate The predicate reference to look up.\n * @param throwOnInvalid Whether to throw an exception if the predicate\n * isn't a valid DataStore predicate.\n */\n static getPredicates(predicate, throwOnInvalid = true) {\n if (throwOnInvalid && !ModelPredicateCreator.isValidPredicate(predicate)) {\n throw new Error('The predicate is not valid');\n }\n return ModelPredicateCreator.predicateGroupsMap.get(predicate);\n }\n /**\n * using the PK values from the given `model` (which can be a partial of T\n * Creates a predicate that matches an instance described by `modelDefinition`\n * that contains only PK field values.)\n *\n * @param modelDefinition The model definition to create a predicate for.\n * @param model The model instance to extract value equalities from.\n */\n static createForPk(modelDefinition, model) {\n const keyFields = (0, util_1.extractPrimaryKeyFieldNames)(modelDefinition);\n const keyValues = (0, util_1.extractPrimaryKeyValues)(model, keyFields);\n const predicate = this.createFromAST(modelDefinition, {\n and: keyFields.map((field, idx) => {\n const operand = keyValues[idx];\n return { [field]: { eq: operand } };\n }),\n });\n return predicate;\n }\n /**\n * Searches a `Model` table for records matching the given equalities object.\n *\n * This only matches against fields given in the equalities object. No other\n * fields are tested by the predicate.\n *\n * @param modelDefinition The model we need a predicate for.\n * @param flatEqualities An object holding field equalities to search for.\n */\n static createFromFlatEqualities(modelDefinition, flatEqualities) {\n const ast = {\n and: Object.entries(flatEqualities).map(([k, v]) => ({ [k]: { eq: v } })),\n };\n return this.createFromAST(modelDefinition, ast);\n }\n /**\n * Accepts a GraphQL style filter predicate tree and transforms it into an\n * AST that can be used for a storage adapter predicate. Example input:\n *\n * ```js\n * {\n * \tand: [\n * \t\t{ name: { eq: \"Bob Jones\" } },\n * \t\t{ age: { between: [32, 64] } },\n * \t\t{ not: {\n * \t\t\tor: [\n * \t\t\t\t{ favoriteFood: { eq: 'pizza' } },\n * \t\t\t\t{ favoriteFood: { eq: 'tacos' } },\n * \t\t\t]\n * \t\t}}\n * \t]\n * }\n * ```\n *\n * @param gql GraphQL style filter node.\n */\n static transformGraphQLFilterNodeToPredicateAST(gql) {\n if (!isValid(gql)) {\n throw new Error('Invalid GraphQL Condition or subtree: ' + JSON.stringify(gql));\n }\n if (isEmpty(gql)) {\n return {\n type: 'and',\n predicates: [],\n };\n }\n else if (isGroup(gql)) {\n const groupkey = Object.keys(gql)[0];\n const children = this.transformGraphQLFilterNodeToPredicateAST(gql[groupkey]);\n return {\n type: groupkey,\n predicates: Array.isArray(children) ? children : [children],\n };\n }\n else if (isComparison(gql)) {\n const operatorKey = Object.keys(gql)[0];\n return {\n operator: operatorKey,\n operand: gql[operatorKey],\n };\n }\n else {\n if (Array.isArray(gql)) {\n return gql.map(o => this.transformGraphQLFilterNodeToPredicateAST(o));\n }\n else {\n const fieldKey = Object.keys(gql)[0];\n return {\n field: fieldKey,\n ...this.transformGraphQLFilterNodeToPredicateAST(gql[fieldKey]),\n };\n }\n }\n }\n /**\n * Accepts a GraphQL style filter predicate tree and transforms it into a predicate\n * that storage adapters understand. Example input:\n *\n * ```js\n * {\n * \tand: [\n * \t\t{ name: { eq: \"Bob Jones\" } },\n * \t\t{ age: { between: [32, 64] } },\n * \t\t{ not: {\n * \t\t\tor: [\n * \t\t\t\t{ favoriteFood: { eq: 'pizza' } },\n * \t\t\t\t{ favoriteFood: { eq: 'tacos' } },\n * \t\t\t]\n * \t\t}}\n * \t]\n * }\n * ```\n *\n * @param modelDefinition The model that the AST/predicate must be compatible with.\n * @param ast The graphQL style AST that should specify conditions for `modelDefinition`.\n */\n static createFromAST(modelDefinition, ast) {\n const key = {};\n ModelPredicateCreator.predicateGroupsMap.set(key, this.transformGraphQLFilterNodeToPredicateAST(ast));\n return key;\n }\n}\nexports.ModelPredicateCreator = ModelPredicateCreator;\n/**\n * Map of storage predicates (key objects) to storage predicate AST's.\n */\nModelPredicateCreator.predicateGroupsMap = new WeakMap();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,GAAG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C,CAAC,CAAC,CAAC;AACnD,YAAY,OAAO;AACnB,gBAAgB,QAAQ,EAAE,WAAW;AACrC,gBAAgB,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC;AACzC,aAAa;AACb,QAAQ;AACR,aAAa;AACb,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AACpC,gBAAgB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,wCAAwC,CAAC,CAAC,CAAC,CAAC;AACrF,YAAY;AACZ,iBAAiB;AACjB,gBAAgB,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACpD,gBAAgB,OAAO;AACvB,oBAAoB,KAAK,EAAE,QAAQ;AACnC,oBAAoB,GAAG,IAAI,CAAC,wCAAwC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnF,iBAAiB;AACjB,YAAY;AACZ,QAAQ;AACR,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,aAAa,CAAC,eAAe,EAAE,GAAG,EAAE;AAC/C,QAAQ,MAAM,GAAG,GAAG,EAAE;AACtB,QAAQ,qBAAqB,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,wCAAwC,CAAC,GAAG,CAAC,CAAC;AAC7G,QAAQ,OAAO,GAAG;AAClB,IAAI;AACJ;AACA,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD;AACA;AACA;AACA,qBAAqB,CAAC,kBAAkB,GAAG,IAAI,OAAO,EAAE;;"}
@@ -64,6 +64,8 @@ const negations = {
64
64
  le: 'gt',
65
65
  contains: 'notContains',
66
66
  notContains: 'contains',
67
+ in: 'notIn',
68
+ notIn: 'in',
67
69
  };
68
70
  /**
69
71
  * A condition that can operate against a single "primitive" field of a model or item.
@@ -177,6 +179,14 @@ class FieldCondition {
177
179
  notContains: () => (!v ? true : v.indexOf(this.operands[0]) === -1),
178
180
  beginsWith: () => v?.startsWith(this.operands[0]),
179
181
  between: () => v >= this.operands[0] && v <= this.operands[1],
182
+ in: () => {
183
+ const values = this.operands[0];
184
+ return Array.isArray(values) && values.includes(v);
185
+ },
186
+ notIn: () => {
187
+ const values = this.operands[0];
188
+ return Array.isArray(values) && !values.includes(v);
189
+ },
180
190
  };
181
191
  const operation = operations[this.operator];
182
192
  if (operation) {
@@ -221,6 +231,26 @@ class FieldCondition {
221
231
  (this.operands[0] > this.operands[1]
222
232
  ? 'The first argument must be less than or equal to the second argument.'
223
233
  : null),
234
+ in: () => {
235
+ const countError = argumentCount(1)();
236
+ if (countError)
237
+ return countError;
238
+ const values = this.operands[0];
239
+ if (!Array.isArray(values)) {
240
+ return 'The argument must be an array.';
241
+ }
242
+ return null;
243
+ },
244
+ notIn: () => {
245
+ const countError = argumentCount(1)();
246
+ if (countError)
247
+ return countError;
248
+ const values = this.operands[0];
249
+ if (!Array.isArray(values)) {
250
+ return 'The argument must be an array.';
251
+ }
252
+ return null;
253
+ },
224
254
  };
225
255
  const validate = validations[this.operator];
226
256
  if (validate) {
@@ -1 +1 @@
1
- {"version":3,"file":"next.js","sources":["../../../src/predicates/next.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GroupCondition = exports.FieldCondition = exports.internals = void 0;\nexports.recursivePredicateFor = recursivePredicateFor;\nexports.predicateFor = predicateFor;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst types_1 = require(\"../types\");\nconst relationship_1 = require(\"../storage/relationship\");\nconst util_1 = require(\"../util\");\nconst index_1 = require(\"./index\");\nconst ops = [...index_1.comparisonKeys];\n/**\n * A map from keys (exposed to customers) to the internal predicate data\n * structures invoking code should not muck with.\n */\nconst predicateInternalsMap = new Map();\n/**\n * Creates a link between a key (and generates a key if needed) and an internal\n * `GroupCondition`, which allows us to return a key object instead of the gory\n * conditions details to customers/invoking code.\n *\n * @param condition The internal condition to keep hidden.\n * @param key The object DataStore will use to find the internal condition.\n * If no key is given, an empty one is created.\n */\nconst registerPredicateInternals = (condition, key) => {\n const finalKey = key || new types_1.PredicateInternalsKey();\n predicateInternalsMap.set(finalKey, condition);\n return finalKey;\n};\n/**\n * Takes a key object from `registerPredicateInternals()` to fetch an internal\n * `GroupCondition` object, which can then be used to query storage or\n * test/match objects.\n *\n * This indirection exists to hide `GroupCondition` from public interfaces, since\n * `GroupCondition` contains extra methods and properties that public callers\n * should not use.\n *\n * @param key A key object previously returned by `registerPredicateInternals()`\n */\nconst internals = (key) => {\n if (!predicateInternalsMap.has(key)) {\n throw new Error(\"Invalid predicate. Terminate your predicate with a valid condition (e.g., `p => p.field.eq('value')`) or pass `Predicates.ALL`.\");\n }\n return predicateInternalsMap.get(key);\n};\nexports.internals = internals;\n/**\n * Maps operators to negated operators.\n * Used to facilitate propagation of negation down a tree of conditions.\n */\nconst negations = {\n and: 'or',\n or: 'and',\n not: 'and',\n eq: 'ne',\n ne: 'eq',\n gt: 'le',\n ge: 'lt',\n lt: 'ge',\n le: 'gt',\n contains: 'notContains',\n notContains: 'contains',\n};\n/**\n * A condition that can operate against a single \"primitive\" field of a model or item.\n * @member field The field of *some record* to test against.\n * @member operator The equality or comparison operator to use.\n * @member operands The operands for the equality/comparison check.\n */\nclass FieldCondition {\n constructor(field, operator, operands) {\n this.field = field;\n this.operator = operator;\n this.operands = operands;\n this.validate();\n }\n /**\n * Creates a copy of self.\n * @param extract Not used. Present only to fulfill the `UntypedCondition` interface.\n * @returns A new, identitical `FieldCondition`.\n */\n copy() {\n return [\n new FieldCondition(this.field, this.operator, [...this.operands]),\n undefined,\n ];\n }\n /**\n * Produces a tree structure similar to a graphql condition. The returned\n * structure is \"dumb\" and is intended for another query/condition\n * generation mechanism to interpret, such as the cloud or storage query\n * builders.\n *\n * E.g.,\n *\n * ```json\n * {\n * \t\"name\": {\n * \t\t\"eq\": \"robert\"\n * \t}\n * }\n * ```\n */\n toAST() {\n return {\n [this.field]: {\n [this.operator]: this.operator === 'between'\n ? [this.operands[0], this.operands[1]]\n : this.operands[0],\n },\n };\n }\n /**\n * Produces a new condition (`FieldCondition` or `GroupCondition`) that\n * matches the opposite of this condition.\n *\n * Intended to be used when applying De Morgan's Law, which can be done to\n * produce more efficient queries against the storage layer if a negation\n * appears in the query tree.\n *\n * For example:\n *\n * 1. `name.eq('robert')` becomes `name.ne('robert')`\n * 2. `price.between(100, 200)` becomes `m => m.or(m => [m.price.lt(100), m.price.gt(200)])`\n *\n * @param model The model meta to use when construction a new `GroupCondition`\n * for cases where the negation requires multiple `FieldCondition`'s.\n */\n negated(model) {\n if (this.operator === 'between') {\n return new GroupCondition(model, undefined, undefined, 'or', [\n new FieldCondition(this.field, 'lt', [this.operands[0]]),\n new FieldCondition(this.field, 'gt', [this.operands[1]]),\n ]);\n }\n else if (this.operator === 'beginsWith') {\n // beginsWith negation doesn't have a good, safe optimation right now.\n // just re-wrap it in negation. The adapter will have to scan-and-filter,\n // as is likely optimal for negated beginsWith conditions *anyway*.\n return new GroupCondition(model, undefined, undefined, 'not', [\n new FieldCondition(this.field, 'beginsWith', [this.operands[0]]),\n ]);\n }\n else {\n return new FieldCondition(this.field, negations[this.operator], this.operands);\n }\n }\n /**\n * Not implemented. Not needed. GroupCondition instead consumes FieldConditions and\n * transforms them into legacy predicates. (*For now.*)\n * @param storage N/A. If ever implemented, the storage adapter to query.\n * @returns N/A. If ever implemented, return items from `storage` that match.\n */\n async fetch() {\n // eslint-disable-next-line prefer-promise-reject-errors\n return Promise.reject('No implementation needed [yet].');\n }\n /**\n * Determins whether a given item matches the expressed condition.\n * @param item The item to test.\n * @returns `Promise<boolean>`, `true` if matches; `false` otherwise.\n */\n async matches(item) {\n const v = item[this.field];\n const operations = {\n eq: () => v === this.operands[0],\n ne: () => v !== this.operands[0],\n gt: () => v > this.operands[0],\n ge: () => v >= this.operands[0],\n lt: () => v < this.operands[0],\n le: () => v <= this.operands[0],\n contains: () => v?.indexOf(this.operands[0]) > -1,\n notContains: () => (!v ? true : v.indexOf(this.operands[0]) === -1),\n beginsWith: () => v?.startsWith(this.operands[0]),\n between: () => v >= this.operands[0] && v <= this.operands[1],\n };\n const operation = operations[this.operator];\n if (operation) {\n const result = operation();\n return result;\n }\n else {\n throw new Error(`Invalid operator given: ${this.operator}`);\n }\n }\n /**\n * Checks `this.operands` for compatibility with `this.operator`.\n */\n validate() {\n /**\n * Creates a validator that checks for a particular `operands` count.\n * Throws an exception if the `count` disagrees with `operands.length`.\n * @param count The number of `operands` expected.\n */\n const argumentCount = count => {\n const argsClause = count === 1 ? 'argument is' : 'arguments are';\n return () => {\n if (this.operands.length !== count) {\n return `Exactly ${count} ${argsClause} required.`;\n }\n };\n };\n // NOTE: validations should return a message on failure.\n // hence, they should be \"joined\" together with logical OR's\n // as seen in the `between:` entry.\n const validations = {\n eq: argumentCount(1),\n ne: argumentCount(1),\n gt: argumentCount(1),\n ge: argumentCount(1),\n lt: argumentCount(1),\n le: argumentCount(1),\n contains: argumentCount(1),\n notContains: argumentCount(1),\n beginsWith: argumentCount(1),\n between: () => argumentCount(2)() ||\n (this.operands[0] > this.operands[1]\n ? 'The first argument must be less than or equal to the second argument.'\n : null),\n };\n const validate = validations[this.operator];\n if (validate) {\n const e = validate();\n if (typeof e === 'string')\n throw new Error(`Incorrect usage of \\`${this.operator}()\\`: ${e}`);\n }\n else {\n throw new Error(`Non-existent operator: \\`${this.operator}()\\``);\n }\n }\n}\nexports.FieldCondition = FieldCondition;\n/**\n * Small utility function to generate a monotonically increasing ID.\n * Used by GroupCondition to help keep track of which group is doing what,\n * when, and where during troubleshooting.\n */\nconst getGroupId = (() => {\n let seed = 1;\n return () => `group_${seed++}`;\n})();\n/**\n * A set of sub-conditions to operate against a model, optionally scoped to\n * a specific field, combined with the given operator (one of `and`, `or`, or `not`).\n * @member groupId Used to distinguish between GroupCondition instances for\n * debugging and troublehsooting.\n * @member model A metadata object that tells GroupCondition what to query and how.\n * @member field The field on the model that the sub-conditions apply to.\n * @member operator How to group child conditions together.\n * @member operands The child conditions.\n */\nclass GroupCondition {\n constructor(\n /**\n * The `ModelMeta` of the model to query and/or filter against.\n * Expected to contain:\n *\n * ```js\n * {\n * \tbuilder: ModelConstructor,\n * \tschema: SchemaModel,\n * \tpkField: string[]\n * }\n * ```\n */\n model, \n /**\n * If populated, this group specifices a condition on a relationship.\n *\n * If `field` does *not* point to a related model, that's an error. It\n * could indicate that the `GroupCondition` was instantiated with bad\n * data, or that the model metadata is incorrect.\n */\n field, \n /**\n * If a `field` is given, whether the relationship is a `HAS_ONE`,\n * 'HAS_MANY`, or `BELONGS_TO`.\n *\n * TODO: Remove this and replace with derivation using\n * `ModelRelationship.from(this.model, this.field).relationship`;\n */\n relationshipType, \n /**\n *\n */\n operator, \n /**\n *\n */\n operands, \n /**\n * Whether this GroupCondition is the result of an optimize call.\n *\n * This is used to guard against infinitely fetch -> optimize -> fetch\n * recursion.\n */\n isOptimized = false) {\n this.model = model;\n this.field = field;\n this.relationshipType = relationshipType;\n this.operator = operator;\n this.operands = operands;\n this.isOptimized = isOptimized;\n // `groupId` was used for development/debugging.\n // Should we leave this in for future troubleshooting?\n this.groupId = getGroupId();\n }\n /**\n * Returns a copy of a GroupCondition, which also returns the copy of a\n * given reference node to \"extract\".\n * @param extract A node of interest. Its copy will *also* be returned if the node exists.\n * @returns [The full copy, the copy of `extract` | undefined]\n */\n copy(extract) {\n const copied = new GroupCondition(this.model, this.field, this.relationshipType, this.operator, []);\n let extractedCopy = extract === this ? copied : undefined;\n this.operands.forEach(o => {\n const [operandCopy, extractedFromOperand] = o.copy(extract);\n copied.operands.push(operandCopy);\n extractedCopy = extractedCopy || extractedFromOperand;\n });\n return [copied, extractedCopy];\n }\n /**\n * Creates a new `GroupCondition` that contains only the local field conditions,\n * omitting related model conditions. That resulting `GroupCondition` can be\n * used to produce predicates that are compatible with the storage adapters and\n * Cloud storage.\n *\n * @param negate Whether the condition tree should be negated according\n * to De Morgan's law.\n */\n withFieldConditionsOnly(negate) {\n const negateChildren = negate !== (this.operator === 'not');\n return new GroupCondition(this.model, undefined, undefined, (negate ? negations[this.operator] : this.operator), this.operands\n .filter(o => o instanceof FieldCondition)\n .map(o => negateChildren ? o.negated(this.model) : o));\n }\n /**\n * Returns a version of the predicate tree with unnecessary logical groups\n * condensed and merged together. This is intended to create a dense tree\n * with leaf nodes (`FieldCondition`'s) aggregated under as few group conditions\n * as possible for the most efficient fetching possible -- it allows `fetch()`.\n *\n * E.g. a grouping like this:\n *\n * ```yaml\n * and:\n * \tand:\n * \t\tid:\n * \t\t\teq: \"abc\"\n * \tand:\n * \t\tname:\n * \t\t\teq: \"xyz\"\n * ```\n *\n * Will become this:\n *\n * ```yaml\n * and:\n * \tid:\n * \t\teq: \"abc\"\n * \tname:\n * \t\teq: \"xyz\"\n * ```\n *\n * This allows `fetch()` to pass both the `id` and `name` conditions to the adapter\n * together, which can then decide what index to use based on both fields together.\n *\n * @param preserveNode Whether to preserve the current node and to explicitly not eliminate\n * it during optimization. Used internally to preserve the root node and children of\n * `not` groups. `not` groups will always have a single child, so there's nothing to\n * optimize below a `not` (for now), and it makes the query logic simpler later.\n */\n optimized(preserveNode = true) {\n const operands = this.operands.map(o => o instanceof GroupCondition ? o.optimized(this.operator === 'not') : o);\n // we're only collapsing and/or groups that contains a single child for now,\n // because they're much more common and much more trivial to collapse. basically,\n // an `and`/`or` that contains a single child doesn't require the layer of\n // logical grouping.\n if (!preserveNode &&\n ['and', 'or'].includes(this.operator) &&\n !this.field &&\n operands.length === 1) {\n const operand = operands[0];\n if (operand instanceof FieldCondition) {\n // between conditions should NOT be passed up the chain. if they\n // need to be *negated* later, it is important that they be properly\n // contained in an AND group. when de morgan's law is applied, the\n // conditions are reversed and the AND group flips to an OR. this\n // doesn't work right if the a `between` doesn't live in an AND group.\n if (operand.operator !== 'between') {\n return operand;\n }\n }\n else {\n return operand;\n }\n }\n return new GroupCondition(this.model, this.field, this.relationshipType, this.operator, operands, true);\n }\n /**\n * Fetches matching records from a given storage adapter using legacy predicates (for now).\n * @param storage The storage adapter this predicate will query against.\n * @param breadcrumb For debugging/troubleshooting. A list of the `groupId`'s this\n * GroupdCondition.fetch is nested within.\n * @param negate Whether to match on the `NOT` of `this`.\n * @returns An `Promise` of `any[]` from `storage` matching the child conditions.\n */\n async fetch(storage, breadcrumb = [], negate = false) {\n if (!this.isOptimized) {\n return this.optimized().fetch(storage);\n }\n const resultGroups = [];\n const operator = (negate ? negations[this.operator] : this.operator);\n const negateChildren = negate !== (this.operator === 'not');\n /**\n * Conditions that must be branched out and used to generate a base, \"candidate\"\n * result set.\n *\n * If `field` is populated, these groups select *related* records, and the base,\n * candidate results are selected to match those.\n */\n const groups = this.operands.filter(op => op instanceof GroupCondition);\n /**\n * Simple conditions that must match the target model of `this`.\n */\n const conditions = this.operands.filter(op => op instanceof FieldCondition);\n for (const g of groups) {\n const relatives = await g.fetch(storage, [...breadcrumb, this.groupId], negateChildren);\n // no relatives -> no need to attempt to perform a \"join\" query for\n // candidate results:\n //\n // select a.* from a,b where b.id in EMPTY_SET ==> EMPTY_SET\n //\n // Additionally, the entire (sub)-query can be short-circuited if\n // the operator is `AND`. Illustrated in SQL:\n //\n // select a.* from a where\n // id in [a,b,c]\n // AND <\n // id in EMTPY_SET <<< Look!\n // AND <\n // id in [x,y,z]\n //\n // YIELDS: EMPTY_SET // <-- Easy peasy. Lemon squeezy.\n //\n if (relatives.length === 0) {\n // aggressively short-circuit as soon as we know the group condition will fail\n if (operator === 'and') {\n return [];\n }\n // less aggressive short-circuit if we know the relatives will produce no\n // candidate results; but aren't sure yet how this affects the group condition.\n resultGroups.push([]);\n continue;\n }\n if (g.field) {\n // `relatives` are actual relatives. We'll skim them for FK query values.\n // Use the relatives to add candidate result sets (`resultGroups`)\n const relationship = relationship_1.ModelRelationship.from(this.model, g.field);\n if (relationship) {\n const allJoinConditions = [];\n for (const relative of relatives) {\n const relativeConditions = [];\n for (let i = 0; i < relationship.localJoinFields.length; i++) {\n relativeConditions.push({\n [relationship.localJoinFields[i]]: {\n eq: relative[relationship.remoteJoinFields[i]],\n },\n });\n }\n allJoinConditions.push({ and: relativeConditions });\n }\n const predicate = index_1.ModelPredicateCreator.createFromAST(this.model.schema, {\n or: allJoinConditions,\n });\n resultGroups.push(await storage.query(this.model.builder, predicate));\n }\n else {\n throw new Error('Missing field metadata.');\n }\n }\n else {\n // relatives are not actually relatives. they're candidate results.\n resultGroups.push(relatives);\n }\n }\n // if conditions is empty at this point, child predicates found no matches.\n // i.e., we can stop looking and return empty.\n if (conditions.length > 0) {\n const predicate = this.withFieldConditionsOnly(negateChildren).toStoragePredicate();\n resultGroups.push(await storage.query(this.model.builder, predicate));\n }\n else if (conditions.length === 0 && resultGroups.length === 0) {\n resultGroups.push(await storage.query(this.model.builder));\n }\n // PK might be a single field, like `id`, or it might be several fields.\n // so, we'll need to extract the list of PK fields from an object\n // and stringify the list for easy comparison / merging.\n const getPKValue = item => JSON.stringify(this.model.pkField.map(name => item[name]));\n // will be used for intersecting or unioning results\n let resultIndex;\n if (operator === 'and') {\n if (resultGroups.length === 0) {\n return [];\n }\n // for each group, we intersect, removing items from the result index\n // that aren't present in each subsequent group.\n for (const group of resultGroups) {\n if (resultIndex === undefined) {\n resultIndex = new Map(group.map(item => [getPKValue(item), item]));\n }\n else {\n const intersectWith = new Map(group.map(item => [getPKValue(item), item]));\n for (const k of resultIndex.keys()) {\n if (!intersectWith.has(k)) {\n resultIndex.delete(k);\n }\n }\n }\n }\n }\n else if (operator === 'or' || operator === 'not') {\n // it's OK to handle NOT here, because NOT must always only negate\n // a single child predicate. NOT logic will have been distributed down\n // to the leaf conditions already.\n resultIndex = new Map();\n // just merge the groups, performing DISTINCT-ification by ID.\n for (const group of resultGroups) {\n for (const item of group) {\n resultIndex.set(getPKValue(item), item);\n }\n }\n }\n return Array.from(resultIndex?.values() || []);\n }\n /**\n * Determines whether a single item matches the conditions of `this`.\n * When checking the target `item`'s properties, each property will be `await`'d\n * to ensure lazy-loading is respected where applicable.\n * @param item The item to match against.\n * @param ignoreFieldName Tells `match()` that the field name has already been dereferenced.\n * (Used for iterating over children on HAS_MANY checks.)\n * @returns A boolean (promise): `true` if matched, `false` otherwise.\n */\n async matches(item, ignoreFieldName = false) {\n const itemToCheck = this.field && !ignoreFieldName ? await item[this.field] : item;\n // if there is no item to check, we can stop recursing immediately.\n // a condition cannot match against an item that does not exist. this\n // can occur when `item.field` is optional in the schema.\n if (!itemToCheck) {\n return false;\n }\n if (this.relationshipType === 'HAS_MANY' &&\n typeof itemToCheck[Symbol.asyncIterator] === 'function') {\n for await (const singleItem of itemToCheck) {\n if (await this.matches(singleItem, true)) {\n return true;\n }\n }\n return false;\n }\n if (this.operator === 'or') {\n return (0, util_1.asyncSome)(this.operands, c => c.matches(itemToCheck));\n }\n else if (this.operator === 'and') {\n return (0, util_1.asyncEvery)(this.operands, c => c.matches(itemToCheck));\n }\n else if (this.operator === 'not') {\n if (this.operands.length !== 1) {\n throw new Error('Invalid arguments! `not()` accepts exactly one predicate expression.');\n }\n return !(await this.operands[0].matches(itemToCheck));\n }\n else {\n throw new Error('Invalid group operator!');\n }\n }\n /**\n * Tranfsorm to a AppSync GraphQL compatible AST.\n * (Does not support filtering in nested types.)\n */\n toAST() {\n if (this.field)\n throw new Error('Nested type conditions are not supported!');\n return {\n [this.operator]: this.operands.map(operand => operand.toAST()),\n };\n }\n /**\n * Turn this predicate group into something a storage adapter\n * understands how to use.\n */\n toStoragePredicate() {\n return index_1.ModelPredicateCreator.createFromAST(this.model.schema, this.toAST());\n }\n /**\n * A JSON representation that's good for debugging.\n */\n toJSON() {\n return {\n ...this,\n model: this.model.schema.name,\n };\n }\n}\nexports.GroupCondition = GroupCondition;\n/**\n * Creates a \"seed\" predicate that can be used to build an executable condition.\n * This is used in `query()`, for example, to seed customer- E.g.,\n *\n * ```\n * const p = predicateFor({builder: modelConstructor, schema: modelSchema, pkField: string[]});\n * p.and(child => [\n * child.field.eq('whatever'),\n * child.childModel.childField.eq('whatever else'),\n * child.childModel.or(child => [\n * child.otherField.contains('x'),\n * child.otherField.contains('y'),\n * child.otherField.contains('z'),\n * ])\n * ])\n * ```\n *\n * `predicateFor()` returns objecst with recursive getters. To facilitate this,\n * a `query` and `tail` can be provided to \"accumulate\" nested conditions.\n *\n * @param ModelType The ModelMeta used to build child properties.\n * @param field Scopes the query branch to a field.\n * @param query A base query to build on. Omit to start a new query.\n * @param tail The point in an existing `query` to attach new conditions to.\n * @returns A ModelPredicate (builder) that customers can create queries with.\n * (As shown in function description.)\n */\nfunction recursivePredicateFor(ModelType, allowRecursion = true, field, query, tail) {\n // to be used if we don't have a base query or tail to build onto\n const starter = new GroupCondition(ModelType, field, undefined, 'and', []);\n const baseCondition = query && tail ? query : starter;\n const tailCondition = query && tail ? tail : starter;\n // our eventual return object, which can be built upon.\n // next steps will be to add or(), and(), not(), and field.op() methods.\n const link = {};\n // so it can be looked up later with in the internals when processing conditions.\n registerPredicateInternals(baseCondition, link);\n const copyLink = () => {\n const [copiedQuery, newTail] = baseCondition.copy(tailCondition);\n const newLink = recursivePredicateFor(ModelType, allowRecursion, undefined, copiedQuery, newTail);\n return { query: copiedQuery, newTail, newLink };\n };\n // Adds .or() and .and() methods to the link.\n // TODO: If revisiting this code, consider writing a Proxy instead.\n ['and', 'or'].forEach(op => {\n link[op] = (builder) => {\n // or() and and() will return a copy of the original link\n // to head off mutability concerns.\n const { query: copiedLinkQuery, newTail } = copyLink();\n const childConditions = builder(recursivePredicateFor(ModelType, allowRecursion));\n if (!Array.isArray(childConditions)) {\n throw new Error(`Invalid predicate. \\`${op}\\` groups must return an array of child conditions.`);\n }\n // the customer will supply a child predicate, which apply to the `model.field`\n // of the tail GroupCondition.\n newTail?.operands.push(new GroupCondition(ModelType, field, undefined, op, childConditions.map(c => (0, exports.internals)(c))));\n // FinalPredicate\n return registerPredicateInternals(copiedLinkQuery);\n };\n });\n // TODO: If revisiting this code, consider proxy.\n link.not = (builder) => {\n // not() will return a copy of the original link\n // to head off mutability concerns.\n const { query: copiedLinkQuery, newTail } = copyLink();\n // unlike and() and or(), the customer will supply a \"singular\" child predicate.\n // the difference being: not() does not accept an array of predicate-like objects.\n // it negates only a *single* predicate subtree.\n newTail?.operands.push(new GroupCondition(ModelType, field, undefined, 'not', [\n (0, exports.internals)(builder(recursivePredicateFor(ModelType, allowRecursion))),\n ]));\n // A `FinalModelPredicate`.\n // Return a thing that can no longer be extended, but instead used to `async filter(items)`\n // or query storage: `.__query.fetch(storage)`.\n return registerPredicateInternals(copiedLinkQuery);\n };\n // For each field on the model schema, we want to add a getter\n // that creates the appropriate new `link` in the query chain.\n // TODO: If revisiting, consider a proxy.\n for (const fieldName in ModelType.schema.allFields) {\n Object.defineProperty(link, fieldName, {\n enumerable: true,\n get: () => {\n const def = ModelType.schema.allFields[fieldName];\n if (!def.association) {\n // we're looking at a value field. we need to return a\n // \"field matcher object\", which contains all of the comparison\n // functions ('eq', 'ne', 'gt', etc.), scoped to operate\n // against the target field (fieldName).\n return ops.reduce((fieldMatcher, operator) => {\n return {\n ...fieldMatcher,\n // each operator on the fieldMatcher objcect is a function.\n // when the customer calls the function, it returns a new link\n // in the chain -- for now -- this is the \"leaf\" link that\n // cannot be further extended.\n [operator]: (...operands) => {\n // build off a fresh copy of the existing `link`, just in case\n // the same link is being used elsewhere by the customer.\n const { query: copiedLinkQuery, newTail } = copyLink();\n // normalize operands. if any of the values are `undefiend`, use\n // `null` instead, because that's what will be stored cross-platform.\n const normalizedOperands = operands.map(o => o === undefined ? null : o);\n // add the given condition to the link's TAIL node.\n // remember: the base link might go N nodes deep! e.g.,\n newTail?.operands.push(new FieldCondition(fieldName, operator, normalizedOperands));\n // A `FinalModelPredicate`.\n // Return a thing that can no longer be extended, but instead used to `async filter(items)`\n // or query storage: `.__query.fetch(storage)`.\n return registerPredicateInternals(copiedLinkQuery);\n },\n };\n }, {});\n }\n else {\n if (!allowRecursion) {\n throw new Error('Predication on releated models is not supported in this context.');\n }\n else if (def.association.connectionType === 'BELONGS_TO' ||\n def.association.connectionType === 'HAS_ONE' ||\n def.association.connectionType === 'HAS_MANY') {\n // the use has just typed '.someRelatedModel'. we need to given them\n // back a predicate chain.\n const relatedMeta = def.type.modelConstructor;\n if (!relatedMeta) {\n throw new Error('Related model metadata is missing. This is a bug! Please report it.');\n }\n // `Model.reletedModelField` returns a copy of the original link,\n // and will contains copies of internal GroupConditions\n // to head off mutability concerns.\n const [newquery, oldtail] = baseCondition.copy(tailCondition);\n const newtail = new GroupCondition(relatedMeta, fieldName, def.association.connectionType, 'and', []);\n // `oldtail` here refers to the *copy* of the old tail.\n // so, it's safe to modify at this point. and we need to modify\n // it to push the *new* tail onto the end of it.\n oldtail.operands.push(newtail);\n const newlink = recursivePredicateFor(relatedMeta, allowRecursion, undefined, newquery, newtail);\n return newlink;\n }\n else {\n throw new Error(\"Related model definition doesn't have a typedef. This is a bug! Please report it.\");\n }\n }\n },\n });\n }\n return link;\n}\nfunction predicateFor(ModelType) {\n // the cast here is just a cheap way to reduce the surface area from\n // the recursive type.\n return recursivePredicateFor(ModelType, false);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,SAAS,GAAG,MAAM;AAC5E,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD,OAAO,CAAC,YAAY,GAAG,YAAY;AACnC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;AACnC,MAAM,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;AACzD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;AACjC,MAAM,OAAO,GAA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AAU,EAAE;AACvE;AACA;AACA,wBAAwB,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,gBAAgB;AACrE,wBAAwB,IAAI,CAAC,WAAW,EAAE;AAC1C,4BAA4B,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC;AAClH,wBAAwB;AACxB;AACA;AACA;AACA,wBAAwB,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC;AACrF,wBAAwB,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,WAAW,EAAE,SAAS,EAAE,GAAG,CAAC,WAAW,CAAC,cAAc,EAAE,KAAK,EAAE,EAAE,CAAC;AAC7H;AACA;AACA;AACA,wBAAwB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;AACtD,wBAAwB,MAAM,OAAO,GAAG,qBAAqB,CAAC,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC;AACxH,wBAAwB,OAAO,OAAO;AACtC,oBAAoB;AACpB,yBAAyB;AACzB,wBAAwB,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC;AAC5H,oBAAoB;AACpB,gBAAgB;AAChB,YAAY,CAAC;AACb,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,IAAI;AACf;AACA,SAAS,YAAY,CAAC,SAAS,EAAE;AACjC;AACA;AACA,IAAI,OAAO,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC;AAClD;;"}
1
+ {"version":3,"file":"next.js","sources":["../../../src/predicates/next.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GroupCondition = exports.FieldCondition = exports.internals = void 0;\nexports.recursivePredicateFor = recursivePredicateFor;\nexports.predicateFor = predicateFor;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst types_1 = require(\"../types\");\nconst relationship_1 = require(\"../storage/relationship\");\nconst util_1 = require(\"../util\");\nconst index_1 = require(\"./index\");\nconst ops = [...index_1.comparisonKeys];\n/**\n * A map from keys (exposed to customers) to the internal predicate data\n * structures invoking code should not muck with.\n */\nconst predicateInternalsMap = new Map();\n/**\n * Creates a link between a key (and generates a key if needed) and an internal\n * `GroupCondition`, which allows us to return a key object instead of the gory\n * conditions details to customers/invoking code.\n *\n * @param condition The internal condition to keep hidden.\n * @param key The object DataStore will use to find the internal condition.\n * If no key is given, an empty one is created.\n */\nconst registerPredicateInternals = (condition, key) => {\n const finalKey = key || new types_1.PredicateInternalsKey();\n predicateInternalsMap.set(finalKey, condition);\n return finalKey;\n};\n/**\n * Takes a key object from `registerPredicateInternals()` to fetch an internal\n * `GroupCondition` object, which can then be used to query storage or\n * test/match objects.\n *\n * This indirection exists to hide `GroupCondition` from public interfaces, since\n * `GroupCondition` contains extra methods and properties that public callers\n * should not use.\n *\n * @param key A key object previously returned by `registerPredicateInternals()`\n */\nconst internals = (key) => {\n if (!predicateInternalsMap.has(key)) {\n throw new Error(\"Invalid predicate. Terminate your predicate with a valid condition (e.g., `p => p.field.eq('value')`) or pass `Predicates.ALL`.\");\n }\n return predicateInternalsMap.get(key);\n};\nexports.internals = internals;\n/**\n * Maps operators to negated operators.\n * Used to facilitate propagation of negation down a tree of conditions.\n */\nconst negations = {\n and: 'or',\n or: 'and',\n not: 'and',\n eq: 'ne',\n ne: 'eq',\n gt: 'le',\n ge: 'lt',\n lt: 'ge',\n le: 'gt',\n contains: 'notContains',\n notContains: 'contains',\n in: 'notIn',\n notIn: 'in',\n};\n/**\n * A condition that can operate against a single \"primitive\" field of a model or item.\n * @member field The field of *some record* to test against.\n * @member operator The equality or comparison operator to use.\n * @member operands The operands for the equality/comparison check.\n */\nclass FieldCondition {\n constructor(field, operator, operands) {\n this.field = field;\n this.operator = operator;\n this.operands = operands;\n this.validate();\n }\n /**\n * Creates a copy of self.\n * @param extract Not used. Present only to fulfill the `UntypedCondition` interface.\n * @returns A new, identitical `FieldCondition`.\n */\n copy() {\n return [\n new FieldCondition(this.field, this.operator, [...this.operands]),\n undefined,\n ];\n }\n /**\n * Produces a tree structure similar to a graphql condition. The returned\n * structure is \"dumb\" and is intended for another query/condition\n * generation mechanism to interpret, such as the cloud or storage query\n * builders.\n *\n * E.g.,\n *\n * ```json\n * {\n * \t\"name\": {\n * \t\t\"eq\": \"robert\"\n * \t}\n * }\n * ```\n */\n toAST() {\n return {\n [this.field]: {\n [this.operator]: this.operator === 'between'\n ? [this.operands[0], this.operands[1]]\n : this.operands[0],\n },\n };\n }\n /**\n * Produces a new condition (`FieldCondition` or `GroupCondition`) that\n * matches the opposite of this condition.\n *\n * Intended to be used when applying De Morgan's Law, which can be done to\n * produce more efficient queries against the storage layer if a negation\n * appears in the query tree.\n *\n * For example:\n *\n * 1. `name.eq('robert')` becomes `name.ne('robert')`\n * 2. `price.between(100, 200)` becomes `m => m.or(m => [m.price.lt(100), m.price.gt(200)])`\n *\n * @param model The model meta to use when construction a new `GroupCondition`\n * for cases where the negation requires multiple `FieldCondition`'s.\n */\n negated(model) {\n if (this.operator === 'between') {\n return new GroupCondition(model, undefined, undefined, 'or', [\n new FieldCondition(this.field, 'lt', [this.operands[0]]),\n new FieldCondition(this.field, 'gt', [this.operands[1]]),\n ]);\n }\n else if (this.operator === 'beginsWith') {\n // beginsWith negation doesn't have a good, safe optimation right now.\n // just re-wrap it in negation. The adapter will have to scan-and-filter,\n // as is likely optimal for negated beginsWith conditions *anyway*.\n return new GroupCondition(model, undefined, undefined, 'not', [\n new FieldCondition(this.field, 'beginsWith', [this.operands[0]]),\n ]);\n }\n else {\n return new FieldCondition(this.field, negations[this.operator], this.operands);\n }\n }\n /**\n * Not implemented. Not needed. GroupCondition instead consumes FieldConditions and\n * transforms them into legacy predicates. (*For now.*)\n * @param storage N/A. If ever implemented, the storage adapter to query.\n * @returns N/A. If ever implemented, return items from `storage` that match.\n */\n async fetch() {\n // eslint-disable-next-line prefer-promise-reject-errors\n return Promise.reject('No implementation needed [yet].');\n }\n /**\n * Determins whether a given item matches the expressed condition.\n * @param item The item to test.\n * @returns `Promise<boolean>`, `true` if matches; `false` otherwise.\n */\n async matches(item) {\n const v = item[this.field];\n const operations = {\n eq: () => v === this.operands[0],\n ne: () => v !== this.operands[0],\n gt: () => v > this.operands[0],\n ge: () => v >= this.operands[0],\n lt: () => v < this.operands[0],\n le: () => v <= this.operands[0],\n contains: () => v?.indexOf(this.operands[0]) > -1,\n notContains: () => (!v ? true : v.indexOf(this.operands[0]) === -1),\n beginsWith: () => v?.startsWith(this.operands[0]),\n between: () => v >= this.operands[0] && v <= this.operands[1],\n in: () => {\n const values = this.operands[0];\n return Array.isArray(values) && values.includes(v);\n },\n notIn: () => {\n const values = this.operands[0];\n return Array.isArray(values) && !values.includes(v);\n },\n };\n const operation = operations[this.operator];\n if (operation) {\n const result = operation();\n return result;\n }\n else {\n throw new Error(`Invalid operator given: ${this.operator}`);\n }\n }\n /**\n * Checks `this.operands` for compatibility with `this.operator`.\n */\n validate() {\n /**\n * Creates a validator that checks for a particular `operands` count.\n * Throws an exception if the `count` disagrees with `operands.length`.\n * @param count The number of `operands` expected.\n */\n const argumentCount = count => {\n const argsClause = count === 1 ? 'argument is' : 'arguments are';\n return () => {\n if (this.operands.length !== count) {\n return `Exactly ${count} ${argsClause} required.`;\n }\n };\n };\n // NOTE: validations should return a message on failure.\n // hence, they should be \"joined\" together with logical OR's\n // as seen in the `between:` entry.\n const validations = {\n eq: argumentCount(1),\n ne: argumentCount(1),\n gt: argumentCount(1),\n ge: argumentCount(1),\n lt: argumentCount(1),\n le: argumentCount(1),\n contains: argumentCount(1),\n notContains: argumentCount(1),\n beginsWith: argumentCount(1),\n between: () => argumentCount(2)() ||\n (this.operands[0] > this.operands[1]\n ? 'The first argument must be less than or equal to the second argument.'\n : null),\n in: () => {\n const countError = argumentCount(1)();\n if (countError)\n return countError;\n const values = this.operands[0];\n if (!Array.isArray(values)) {\n return 'The argument must be an array.';\n }\n return null;\n },\n notIn: () => {\n const countError = argumentCount(1)();\n if (countError)\n return countError;\n const values = this.operands[0];\n if (!Array.isArray(values)) {\n return 'The argument must be an array.';\n }\n return null;\n },\n };\n const validate = validations[this.operator];\n if (validate) {\n const e = validate();\n if (typeof e === 'string')\n throw new Error(`Incorrect usage of \\`${this.operator}()\\`: ${e}`);\n }\n else {\n throw new Error(`Non-existent operator: \\`${this.operator}()\\``);\n }\n }\n}\nexports.FieldCondition = FieldCondition;\n/**\n * Small utility function to generate a monotonically increasing ID.\n * Used by GroupCondition to help keep track of which group is doing what,\n * when, and where during troubleshooting.\n */\nconst getGroupId = (() => {\n let seed = 1;\n return () => `group_${seed++}`;\n})();\n/**\n * A set of sub-conditions to operate against a model, optionally scoped to\n * a specific field, combined with the given operator (one of `and`, `or`, or `not`).\n * @member groupId Used to distinguish between GroupCondition instances for\n * debugging and troublehsooting.\n * @member model A metadata object that tells GroupCondition what to query and how.\n * @member field The field on the model that the sub-conditions apply to.\n * @member operator How to group child conditions together.\n * @member operands The child conditions.\n */\nclass GroupCondition {\n constructor(\n /**\n * The `ModelMeta` of the model to query and/or filter against.\n * Expected to contain:\n *\n * ```js\n * {\n * \tbuilder: ModelConstructor,\n * \tschema: SchemaModel,\n * \tpkField: string[]\n * }\n * ```\n */\n model, \n /**\n * If populated, this group specifices a condition on a relationship.\n *\n * If `field` does *not* point to a related model, that's an error. It\n * could indicate that the `GroupCondition` was instantiated with bad\n * data, or that the model metadata is incorrect.\n */\n field, \n /**\n * If a `field` is given, whether the relationship is a `HAS_ONE`,\n * 'HAS_MANY`, or `BELONGS_TO`.\n *\n * TODO: Remove this and replace with derivation using\n * `ModelRelationship.from(this.model, this.field).relationship`;\n */\n relationshipType, \n /**\n *\n */\n operator, \n /**\n *\n */\n operands, \n /**\n * Whether this GroupCondition is the result of an optimize call.\n *\n * This is used to guard against infinitely fetch -> optimize -> fetch\n * recursion.\n */\n isOptimized = false) {\n this.model = model;\n this.field = field;\n this.relationshipType = relationshipType;\n this.operator = operator;\n this.operands = operands;\n this.isOptimized = isOptimized;\n // `groupId` was used for development/debugging.\n // Should we leave this in for future troubleshooting?\n this.groupId = getGroupId();\n }\n /**\n * Returns a copy of a GroupCondition, which also returns the copy of a\n * given reference node to \"extract\".\n * @param extract A node of interest. Its copy will *also* be returned if the node exists.\n * @returns [The full copy, the copy of `extract` | undefined]\n */\n copy(extract) {\n const copied = new GroupCondition(this.model, this.field, this.relationshipType, this.operator, []);\n let extractedCopy = extract === this ? copied : undefined;\n this.operands.forEach(o => {\n const [operandCopy, extractedFromOperand] = o.copy(extract);\n copied.operands.push(operandCopy);\n extractedCopy = extractedCopy || extractedFromOperand;\n });\n return [copied, extractedCopy];\n }\n /**\n * Creates a new `GroupCondition` that contains only the local field conditions,\n * omitting related model conditions. That resulting `GroupCondition` can be\n * used to produce predicates that are compatible with the storage adapters and\n * Cloud storage.\n *\n * @param negate Whether the condition tree should be negated according\n * to De Morgan's law.\n */\n withFieldConditionsOnly(negate) {\n const negateChildren = negate !== (this.operator === 'not');\n return new GroupCondition(this.model, undefined, undefined, (negate ? negations[this.operator] : this.operator), this.operands\n .filter(o => o instanceof FieldCondition)\n .map(o => negateChildren ? o.negated(this.model) : o));\n }\n /**\n * Returns a version of the predicate tree with unnecessary logical groups\n * condensed and merged together. This is intended to create a dense tree\n * with leaf nodes (`FieldCondition`'s) aggregated under as few group conditions\n * as possible for the most efficient fetching possible -- it allows `fetch()`.\n *\n * E.g. a grouping like this:\n *\n * ```yaml\n * and:\n * \tand:\n * \t\tid:\n * \t\t\teq: \"abc\"\n * \tand:\n * \t\tname:\n * \t\t\teq: \"xyz\"\n * ```\n *\n * Will become this:\n *\n * ```yaml\n * and:\n * \tid:\n * \t\teq: \"abc\"\n * \tname:\n * \t\teq: \"xyz\"\n * ```\n *\n * This allows `fetch()` to pass both the `id` and `name` conditions to the adapter\n * together, which can then decide what index to use based on both fields together.\n *\n * @param preserveNode Whether to preserve the current node and to explicitly not eliminate\n * it during optimization. Used internally to preserve the root node and children of\n * `not` groups. `not` groups will always have a single child, so there's nothing to\n * optimize below a `not` (for now), and it makes the query logic simpler later.\n */\n optimized(preserveNode = true) {\n const operands = this.operands.map(o => o instanceof GroupCondition ? o.optimized(this.operator === 'not') : o);\n // we're only collapsing and/or groups that contains a single child for now,\n // because they're much more common and much more trivial to collapse. basically,\n // an `and`/`or` that contains a single child doesn't require the layer of\n // logical grouping.\n if (!preserveNode &&\n ['and', 'or'].includes(this.operator) &&\n !this.field &&\n operands.length === 1) {\n const operand = operands[0];\n if (operand instanceof FieldCondition) {\n // between conditions should NOT be passed up the chain. if they\n // need to be *negated* later, it is important that they be properly\n // contained in an AND group. when de morgan's law is applied, the\n // conditions are reversed and the AND group flips to an OR. this\n // doesn't work right if the a `between` doesn't live in an AND group.\n if (operand.operator !== 'between') {\n return operand;\n }\n }\n else {\n return operand;\n }\n }\n return new GroupCondition(this.model, this.field, this.relationshipType, this.operator, operands, true);\n }\n /**\n * Fetches matching records from a given storage adapter using legacy predicates (for now).\n * @param storage The storage adapter this predicate will query against.\n * @param breadcrumb For debugging/troubleshooting. A list of the `groupId`'s this\n * GroupdCondition.fetch is nested within.\n * @param negate Whether to match on the `NOT` of `this`.\n * @returns An `Promise` of `any[]` from `storage` matching the child conditions.\n */\n async fetch(storage, breadcrumb = [], negate = false) {\n if (!this.isOptimized) {\n return this.optimized().fetch(storage);\n }\n const resultGroups = [];\n const operator = (negate ? negations[this.operator] : this.operator);\n const negateChildren = negate !== (this.operator === 'not');\n /**\n * Conditions that must be branched out and used to generate a base, \"candidate\"\n * result set.\n *\n * If `field` is populated, these groups select *related* records, and the base,\n * candidate results are selected to match those.\n */\n const groups = this.operands.filter(op => op instanceof GroupCondition);\n /**\n * Simple conditions that must match the target model of `this`.\n */\n const conditions = this.operands.filter(op => op instanceof FieldCondition);\n for (const g of groups) {\n const relatives = await g.fetch(storage, [...breadcrumb, this.groupId], negateChildren);\n // no relatives -> no need to attempt to perform a \"join\" query for\n // candidate results:\n //\n // select a.* from a,b where b.id in EMPTY_SET ==> EMPTY_SET\n //\n // Additionally, the entire (sub)-query can be short-circuited if\n // the operator is `AND`. Illustrated in SQL:\n //\n // select a.* from a where\n // id in [a,b,c]\n // AND <\n // id in EMTPY_SET <<< Look!\n // AND <\n // id in [x,y,z]\n //\n // YIELDS: EMPTY_SET // <-- Easy peasy. Lemon squeezy.\n //\n if (relatives.length === 0) {\n // aggressively short-circuit as soon as we know the group condition will fail\n if (operator === 'and') {\n return [];\n }\n // less aggressive short-circuit if we know the relatives will produce no\n // candidate results; but aren't sure yet how this affects the group condition.\n resultGroups.push([]);\n continue;\n }\n if (g.field) {\n // `relatives` are actual relatives. We'll skim them for FK query values.\n // Use the relatives to add candidate result sets (`resultGroups`)\n const relationship = relationship_1.ModelRelationship.from(this.model, g.field);\n if (relationship) {\n const allJoinConditions = [];\n for (const relative of relatives) {\n const relativeConditions = [];\n for (let i = 0; i < relationship.localJoinFields.length; i++) {\n relativeConditions.push({\n [relationship.localJoinFields[i]]: {\n eq: relative[relationship.remoteJoinFields[i]],\n },\n });\n }\n allJoinConditions.push({ and: relativeConditions });\n }\n const predicate = index_1.ModelPredicateCreator.createFromAST(this.model.schema, {\n or: allJoinConditions,\n });\n resultGroups.push(await storage.query(this.model.builder, predicate));\n }\n else {\n throw new Error('Missing field metadata.');\n }\n }\n else {\n // relatives are not actually relatives. they're candidate results.\n resultGroups.push(relatives);\n }\n }\n // if conditions is empty at this point, child predicates found no matches.\n // i.e., we can stop looking and return empty.\n if (conditions.length > 0) {\n const predicate = this.withFieldConditionsOnly(negateChildren).toStoragePredicate();\n resultGroups.push(await storage.query(this.model.builder, predicate));\n }\n else if (conditions.length === 0 && resultGroups.length === 0) {\n resultGroups.push(await storage.query(this.model.builder));\n }\n // PK might be a single field, like `id`, or it might be several fields.\n // so, we'll need to extract the list of PK fields from an object\n // and stringify the list for easy comparison / merging.\n const getPKValue = item => JSON.stringify(this.model.pkField.map(name => item[name]));\n // will be used for intersecting or unioning results\n let resultIndex;\n if (operator === 'and') {\n if (resultGroups.length === 0) {\n return [];\n }\n // for each group, we intersect, removing items from the result index\n // that aren't present in each subsequent group.\n for (const group of resultGroups) {\n if (resultIndex === undefined) {\n resultIndex = new Map(group.map(item => [getPKValue(item), item]));\n }\n else {\n const intersectWith = new Map(group.map(item => [getPKValue(item), item]));\n for (const k of resultIndex.keys()) {\n if (!intersectWith.has(k)) {\n resultIndex.delete(k);\n }\n }\n }\n }\n }\n else if (operator === 'or' || operator === 'not') {\n // it's OK to handle NOT here, because NOT must always only negate\n // a single child predicate. NOT logic will have been distributed down\n // to the leaf conditions already.\n resultIndex = new Map();\n // just merge the groups, performing DISTINCT-ification by ID.\n for (const group of resultGroups) {\n for (const item of group) {\n resultIndex.set(getPKValue(item), item);\n }\n }\n }\n return Array.from(resultIndex?.values() || []);\n }\n /**\n * Determines whether a single item matches the conditions of `this`.\n * When checking the target `item`'s properties, each property will be `await`'d\n * to ensure lazy-loading is respected where applicable.\n * @param item The item to match against.\n * @param ignoreFieldName Tells `match()` that the field name has already been dereferenced.\n * (Used for iterating over children on HAS_MANY checks.)\n * @returns A boolean (promise): `true` if matched, `false` otherwise.\n */\n async matches(item, ignoreFieldName = false) {\n const itemToCheck = this.field && !ignoreFieldName ? await item[this.field] : item;\n // if there is no item to check, we can stop recursing immediately.\n // a condition cannot match against an item that does not exist. this\n // can occur when `item.field` is optional in the schema.\n if (!itemToCheck) {\n return false;\n }\n if (this.relationshipType === 'HAS_MANY' &&\n typeof itemToCheck[Symbol.asyncIterator] === 'function') {\n for await (const singleItem of itemToCheck) {\n if (await this.matches(singleItem, true)) {\n return true;\n }\n }\n return false;\n }\n if (this.operator === 'or') {\n return (0, util_1.asyncSome)(this.operands, c => c.matches(itemToCheck));\n }\n else if (this.operator === 'and') {\n return (0, util_1.asyncEvery)(this.operands, c => c.matches(itemToCheck));\n }\n else if (this.operator === 'not') {\n if (this.operands.length !== 1) {\n throw new Error('Invalid arguments! `not()` accepts exactly one predicate expression.');\n }\n return !(await this.operands[0].matches(itemToCheck));\n }\n else {\n throw new Error('Invalid group operator!');\n }\n }\n /**\n * Tranfsorm to a AppSync GraphQL compatible AST.\n * (Does not support filtering in nested types.)\n */\n toAST() {\n if (this.field)\n throw new Error('Nested type conditions are not supported!');\n return {\n [this.operator]: this.operands.map(operand => operand.toAST()),\n };\n }\n /**\n * Turn this predicate group into something a storage adapter\n * understands how to use.\n */\n toStoragePredicate() {\n return index_1.ModelPredicateCreator.createFromAST(this.model.schema, this.toAST());\n }\n /**\n * A JSON representation that's good for debugging.\n */\n toJSON() {\n return {\n ...this,\n model: this.model.schema.name,\n };\n }\n}\nexports.GroupCondition = GroupCondition;\n/**\n * Creates a \"seed\" predicate that can be used to build an executable condition.\n * This is used in `query()`, for example, to seed customer- E.g.,\n *\n * ```\n * const p = predicateFor({builder: modelConstructor, schema: modelSchema, pkField: string[]});\n * p.and(child => [\n * child.field.eq('whatever'),\n * child.childModel.childField.eq('whatever else'),\n * child.childModel.or(child => [\n * child.otherField.contains('x'),\n * child.otherField.contains('y'),\n * child.otherField.contains('z'),\n * ])\n * ])\n * ```\n *\n * `predicateFor()` returns objecst with recursive getters. To facilitate this,\n * a `query` and `tail` can be provided to \"accumulate\" nested conditions.\n *\n * @param ModelType The ModelMeta used to build child properties.\n * @param field Scopes the query branch to a field.\n * @param query A base query to build on. Omit to start a new query.\n * @param tail The point in an existing `query` to attach new conditions to.\n * @returns A ModelPredicate (builder) that customers can create queries with.\n * (As shown in function description.)\n */\nfunction recursivePredicateFor(ModelType, allowRecursion = true, field, query, tail) {\n // to be used if we don't have a base query or tail to build onto\n const starter = new GroupCondition(ModelType, field, undefined, 'and', []);\n const baseCondition = query && tail ? query : starter;\n const tailCondition = query && tail ? tail : starter;\n // our eventual return object, which can be built upon.\n // next steps will be to add or(), and(), not(), and field.op() methods.\n const link = {};\n // so it can be looked up later with in the internals when processing conditions.\n registerPredicateInternals(baseCondition, link);\n const copyLink = () => {\n const [copiedQuery, newTail] = baseCondition.copy(tailCondition);\n const newLink = recursivePredicateFor(ModelType, allowRecursion, undefined, copiedQuery, newTail);\n return { query: copiedQuery, newTail, newLink };\n };\n // Adds .or() and .and() methods to the link.\n // TODO: If revisiting this code, consider writing a Proxy instead.\n ['and', 'or'].forEach(op => {\n link[op] = (builder) => {\n // or() and and() will return a copy of the original link\n // to head off mutability concerns.\n const { query: copiedLinkQuery, newTail } = copyLink();\n const childConditions = builder(recursivePredicateFor(ModelType, allowRecursion));\n if (!Array.isArray(childConditions)) {\n throw new Error(`Invalid predicate. \\`${op}\\` groups must return an array of child conditions.`);\n }\n // the customer will supply a child predicate, which apply to the `model.field`\n // of the tail GroupCondition.\n newTail?.operands.push(new GroupCondition(ModelType, field, undefined, op, childConditions.map(c => (0, exports.internals)(c))));\n // FinalPredicate\n return registerPredicateInternals(copiedLinkQuery);\n };\n });\n // TODO: If revisiting this code, consider proxy.\n link.not = (builder) => {\n // not() will return a copy of the original link\n // to head off mutability concerns.\n const { query: copiedLinkQuery, newTail } = copyLink();\n // unlike and() and or(), the customer will supply a \"singular\" child predicate.\n // the difference being: not() does not accept an array of predicate-like objects.\n // it negates only a *single* predicate subtree.\n newTail?.operands.push(new GroupCondition(ModelType, field, undefined, 'not', [\n (0, exports.internals)(builder(recursivePredicateFor(ModelType, allowRecursion))),\n ]));\n // A `FinalModelPredicate`.\n // Return a thing that can no longer be extended, but instead used to `async filter(items)`\n // or query storage: `.__query.fetch(storage)`.\n return registerPredicateInternals(copiedLinkQuery);\n };\n // For each field on the model schema, we want to add a getter\n // that creates the appropriate new `link` in the query chain.\n // TODO: If revisiting, consider a proxy.\n for (const fieldName in ModelType.schema.allFields) {\n Object.defineProperty(link, fieldName, {\n enumerable: true,\n get: () => {\n const def = ModelType.schema.allFields[fieldName];\n if (!def.association) {\n // we're looking at a value field. we need to return a\n // \"field matcher object\", which contains all of the comparison\n // functions ('eq', 'ne', 'gt', etc.), scoped to operate\n // against the target field (fieldName).\n return ops.reduce((fieldMatcher, operator) => {\n return {\n ...fieldMatcher,\n // each operator on the fieldMatcher objcect is a function.\n // when the customer calls the function, it returns a new link\n // in the chain -- for now -- this is the \"leaf\" link that\n // cannot be further extended.\n [operator]: (...operands) => {\n // build off a fresh copy of the existing `link`, just in case\n // the same link is being used elsewhere by the customer.\n const { query: copiedLinkQuery, newTail } = copyLink();\n // normalize operands. if any of the values are `undefiend`, use\n // `null` instead, because that's what will be stored cross-platform.\n const normalizedOperands = operands.map(o => o === undefined ? null : o);\n // add the given condition to the link's TAIL node.\n // remember: the base link might go N nodes deep! e.g.,\n newTail?.operands.push(new FieldCondition(fieldName, operator, normalizedOperands));\n // A `FinalModelPredicate`.\n // Return a thing that can no longer be extended, but instead used to `async filter(items)`\n // or query storage: `.__query.fetch(storage)`.\n return registerPredicateInternals(copiedLinkQuery);\n },\n };\n }, {});\n }\n else {\n if (!allowRecursion) {\n throw new Error('Predication on releated models is not supported in this context.');\n }\n else if (def.association.connectionType === 'BELONGS_TO' ||\n def.association.connectionType === 'HAS_ONE' ||\n def.association.connectionType === 'HAS_MANY') {\n // the use has just typed '.someRelatedModel'. we need to given them\n // back a predicate chain.\n const relatedMeta = def.type.modelConstructor;\n if (!relatedMeta) {\n throw new Error('Related model metadata is missing. This is a bug! Please report it.');\n }\n // `Model.reletedModelField` returns a copy of the original link,\n // and will contains copies of internal GroupConditions\n // to head off mutability concerns.\n const [newquery, oldtail] = baseCondition.copy(tailCondition);\n const newtail = new GroupCondition(relatedMeta, fieldName, def.association.connectionType, 'and', []);\n // `oldtail` here refers to the *copy* of the old tail.\n // so, it's safe to modify at this point. and we need to modify\n // it to push the *new* tail onto the end of it.\n oldtail.operands.push(newtail);\n const newlink = recursivePredicateFor(relatedMeta, allowRecursion, undefined, newquery, newtail);\n return newlink;\n }\n else {\n throw new Error(\"Related model definition doesn't have a typedef. This is a bug! Please report it.\");\n }\n }\n },\n });\n }\n return link;\n}\nfunction predicateFor(ModelType) {\n // the cast here is just a cheap way to reduce the surface area from\n // the recursive type.\n return recursivePredicateFor(ModelType, false);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,SAAS,GAAG,MAAM;AAC5E,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD,OAAO,CAAC,YAAY,GAAG,YAAY;AACnC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;AACnC,MAAM,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;AACzD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;AACjC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;AAClC,MAAM,GAAG,GAAG,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;AACvC;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAE;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,0BAA0B,GAAG,CAAC,SAAS,EAAE,GAAG,KAAK;AACvD,IAAI,MAAM,QAAQ,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,qBAAqB,EAAE;AAC/D,IAAI,qBAAqB,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC;AAClD,IAAI,OAAO,QAAQ;AACnB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,SAAS,GAAG,CAAC,GAAG,KAAK;AAC3B,IAAI,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACzC,QAAQ,MAAM,IAAI,KAAK,CAAC,iIAAiI,CAAC;AAC1J,IAAI;AACJ,IAAI,OAAO,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC;AACzC,CAAC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,KAAK,CAAC,mFAAmF,CAAC;AAC5H,oBAAoB;AACpB,gBAAgB;AAChB,YAAY,CAAC;AACb,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,IAAI;AACf;AACA,SAAS,YAAY,CAAC,SAAS,EAAE;AACjC;AACA;AACA,IAAI,OAAO,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC;AAClD;;"}
package/dist/cjs/util.js CHANGED
@@ -129,6 +129,18 @@ const validatePredicateField = (value, operator, operand) => {
129
129
  return ((0, exports.isNullOrUndefined)(value) ||
130
130
  value.indexOf(operand) ===
131
131
  -1);
132
+ case 'in': {
133
+ // Early return if operand is not an array
134
+ if (!Array.isArray(operand))
135
+ return false;
136
+ return operand.includes(value);
137
+ }
138
+ case 'notIn': {
139
+ // Early return if operand is not an array
140
+ if (!Array.isArray(operand))
141
+ return false;
142
+ return !operand.includes(value);
143
+ }
132
144
  default:
133
145
  return false;
134
146
  }