@wix/wix-data-items-common 1.0.103 → 1.0.105

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.
Files changed (45) hide show
  1. package/dist/cjs/api/ApiClient.js.map +1 -1
  2. package/dist/cjs/api/QueryBase.js.map +1 -1
  3. package/dist/cjs/api/QueryValidator.js.map +1 -1
  4. package/dist/cjs/api/WixDataAggregate.js.map +1 -1
  5. package/dist/cjs/api/WixDataApi.js.map +1 -1
  6. package/dist/cjs/api/WixDataFilter.js.map +1 -1
  7. package/dist/cjs/api/WixDataPatch.js.map +1 -1
  8. package/dist/cjs/api/WixDataQuery.js.map +1 -1
  9. package/dist/cjs/api/WixDataResult.js.map +1 -1
  10. package/dist/cjs/api/common.js.map +1 -1
  11. package/dist/cjs/api/errors.js.map +1 -1
  12. package/dist/cjs/api/impl/WixDataAggregateImpl.js.map +1 -1
  13. package/dist/cjs/api/impl/WixDataPatchImpl.js.map +1 -1
  14. package/dist/cjs/api/impl/WixDataQueryImpl.js.map +1 -1
  15. package/dist/cjs/api/impl/WixDataResultImpl.js +1 -3
  16. package/dist/cjs/api/impl/WixDataResultImpl.js.map +1 -1
  17. package/dist/cjs/api/index.js.map +1 -1
  18. package/dist/cjs/api/types.js.map +1 -1
  19. package/dist/cjs/errors/base-validator.js.map +1 -1
  20. package/dist/cjs/errors/errors.js.map +1 -1
  21. package/dist/cjs/errors/index.js.map +1 -1
  22. package/dist/cjs/errors/validations.js.map +1 -1
  23. package/dist/cjs/external-types.d.js.map +1 -1
  24. package/dist/cjs/filter/FilterTree.js.map +1 -1
  25. package/dist/cjs/filter/WithFilter.js.map +1 -1
  26. package/dist/cjs/filter/filterBuilder.js.map +1 -1
  27. package/dist/cjs/filter/filterMixin.js.map +1 -1
  28. package/dist/cjs/filter/index.js.map +1 -1
  29. package/dist/cjs/index.js.map +1 -1
  30. package/dist/cjs/sort/sortMixin.js.map +1 -1
  31. package/dist/cjs/test-types.d.js.map +1 -1
  32. package/dist/cjs/types/api.js.map +1 -1
  33. package/dist/cjs/types/data-item-types.js.map +1 -1
  34. package/dist/cjs/types/error.js.map +1 -1
  35. package/dist/cjs/types/index.js.map +1 -1
  36. package/dist/cjs/utils/base64url.js.map +1 -1
  37. package/dist/cjs/utils/clone.js.map +1 -1
  38. package/dist/cjs/utils/codec.js.map +1 -1
  39. package/dist/cjs/utils/field-key-utils.js.map +1 -1
  40. package/dist/cjs/utils/index.js.map +1 -1
  41. package/dist/cjs/utils/type-utils.js.map +1 -1
  42. package/dist/types/api/WixDataPatch.d.ts +12 -12
  43. package/dist/types/types/data-item-types.d.ts +2 -2
  44. package/dist/types/types/data-item-types.d.ts.map +1 -1
  45. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_errors","BaseValidator","constructor","_defineProperty2","default","_validations","arityIsZero","args","addValidation","length","messages","arityValidations","operatorName","arityIsOne","arityIsTwo","arityIsThree","arityIsAtLeastTwo","arityIsAtLeastOne","predicateFn","messageFn","push","AggregatingValidator","previousInvalidArguments","_invalidArguments","clone","validateAndAggregate","valid","every","_appendIfInvalid","message","exports","DistinctingValidator","RejectingValidator","buildError","validationError","validateAndReject","Promise","resolve","then","forEach","validateAndReturn","errors"],"sources":["../../../src/errors/base-validator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { clone } from '../utils'\nimport { messages, validationError } from './errors'\n\ninterface Validation {\n predicateFn: () => boolean\n messageFn: () => string\n}\nclass BaseValidator {\n public _validations: Validation[]\n public operatorName?: string\n\n constructor() {\n this._validations = []\n }\n\n arityIsZero(args: IArguments) {\n return this.addValidation(\n () => args.length === 0,\n () => messages.arityValidations.arityIsZero(this.operatorName ?? '')\n )\n }\n\n arityIsOne(args: IArguments) {\n return this.addValidation(\n () => args.length === 1,\n () => messages.arityValidations.arityIsOne(this.operatorName ?? '')\n )\n }\n\n arityIsTwo(args: IArguments) {\n return this.addValidation(\n () => args.length === 2,\n () => messages.arityValidations.arityIsTwo(this.operatorName ?? '')\n )\n }\n\n arityIsThree(args: IArguments) {\n return this.addValidation(\n () => args.length === 3,\n () => messages.arityValidations.arityIsThree(this.operatorName ?? '')\n )\n }\n\n arityIsAtLeastTwo(args: IArguments) {\n return this.addValidation(\n () => args.length >= 2,\n () => messages.arityValidations.arityIsAtLeastTwo(this.operatorName ?? '')\n )\n }\n\n arityIsAtLeastOne(args: IArguments | any[]) {\n return this.addValidation(\n () => args.length >= 1,\n () => messages.arityValidations.arityIsAtLeastOne(this.operatorName ?? '')\n )\n }\n\n addValidation(\n predicateFn: Validation['predicateFn'],\n messageFn: Validation['messageFn']\n ) {\n this._validations.push({\n predicateFn,\n messageFn,\n })\n return this\n }\n}\n\nexport class AggregatingValidator extends BaseValidator {\n private _invalidArguments: string[]\n\n constructor(previousInvalidArguments?: string[]) {\n super()\n this._invalidArguments = clone(previousInvalidArguments)\n }\n\n validateAndAggregate(): [string[], boolean] {\n const valid = this._validations.every(({ predicateFn, messageFn }) =>\n this._appendIfInvalid(predicateFn(), messageFn())\n )\n return [this._invalidArguments, valid]\n }\n\n _appendIfInvalid(valid: boolean, message: string) {\n if (!valid) {\n this._invalidArguments.push(message)\n return false\n }\n return true\n }\n}\n\nexport class DistinctingValidator extends BaseValidator {\n private _invalidArguments: string[]\n\n constructor(previousInvalidArguments?: string[]) {\n super()\n this._invalidArguments = clone(previousInvalidArguments)\n }\n\n validateAndAggregate(): [string[], boolean] {\n const valid = this._validations.every(({ predicateFn, messageFn }) =>\n this._appendIfInvalid(predicateFn(), messageFn())\n )\n return [this._invalidArguments, valid]\n }\n\n _appendIfInvalid(valid: boolean, message: string) {\n if (!valid) {\n this._invalidArguments.push(message)\n return false\n }\n return true\n }\n}\n\nexport class RejectingValidator extends BaseValidator {\n constructor(private buildError: (s: string) => Error = validationError) {\n super()\n }\n\n validateAndReject(): Promise<void> {\n return Promise.resolve().then(() => {\n this._validations.forEach(({ predicateFn, messageFn }) => {\n if (!predicateFn()) {\n throw this.buildError(messageFn())\n }\n })\n })\n }\n\n validateAndReturn(): string[] {\n const errors: string[] = []\n this._validations.forEach(({ predicateFn, messageFn }) => {\n if (!predicateFn()) {\n errors.push(messageFn())\n }\n })\n return errors\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAFA;;AAQA,MAAME,aAAa,CAAC;EAIlBC,WAAWA,CAAA,EAAG;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACZ,IAAI,CAACC,YAAY,GAAG,EAAE;EACxB;EAEAC,WAAWA,CAACC,IAAgB,EAAE;IAC5B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACL,WAAW,CAAC,IAAI,CAACM,YAAY,IAAI,EAAE,CACrE,CAAC;EACH;EAEAC,UAAUA,CAACN,IAAgB,EAAE;IAC3B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACE,UAAU,CAAC,IAAI,CAACD,YAAY,IAAI,EAAE,CACpE,CAAC;EACH;EAEAE,UAAUA,CAACP,IAAgB,EAAE;IAC3B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACG,UAAU,CAAC,IAAI,CAACF,YAAY,IAAI,EAAE,CACpE,CAAC;EACH;EAEAG,YAAYA,CAACR,IAAgB,EAAE;IAC7B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACI,YAAY,CAAC,IAAI,CAACH,YAAY,IAAI,EAAE,CACtE,CAAC;EACH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,CAAC;QACpC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEAqB,iBAAiBA,CAAA,EAAa;IAC5B,MAAMC,MAAgB,GAAG,EAAE;IAC3B,IAAI,CAACpC,YAAY,CAACkC,OAAO,CAAC,CAAC;MAAErB,WAAW;MAAEC;IAAU,CAAC,KAAK;MACxD,IAAI,CAACD,WAAW,CAAC,CAAC,EAAE;QAClBuB,MAAM,CAACrB,IAAI,CAACD,SAAS,CAAC,CAAC,CAAC;MAC1B;IACF,CAAC,CAAC;IACF,OAAOsB,MAAM;EACf;AACF;AAACX,OAAA,CAAAE,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["_utils","require","_errors","BaseValidator","constructor","_defineProperty2","default","_validations","arityIsZero","args","addValidation","length","messages","arityValidations","operatorName","arityIsOne","arityIsTwo","arityIsThree","arityIsAtLeastTwo","arityIsAtLeastOne","predicateFn","messageFn","push","AggregatingValidator","previousInvalidArguments","_invalidArguments","clone","validateAndAggregate","valid","every","_appendIfInvalid","message","exports","DistinctingValidator","RejectingValidator","buildError","validationError","validateAndReject","Promise","resolve","then","forEach","validateAndReturn","errors"],"sources":["../../../src/errors/base-validator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { clone } from '../utils'\nimport { messages, validationError } from './errors'\n\ninterface Validation {\n predicateFn: () => boolean\n messageFn: () => string\n}\nclass BaseValidator {\n public _validations: Validation[]\n public operatorName?: string\n\n constructor() {\n this._validations = []\n }\n\n arityIsZero(args: IArguments) {\n return this.addValidation(\n () => args.length === 0,\n () => messages.arityValidations.arityIsZero(this.operatorName ?? '')\n )\n }\n\n arityIsOne(args: IArguments) {\n return this.addValidation(\n () => args.length === 1,\n () => messages.arityValidations.arityIsOne(this.operatorName ?? '')\n )\n }\n\n arityIsTwo(args: IArguments) {\n return this.addValidation(\n () => args.length === 2,\n () => messages.arityValidations.arityIsTwo(this.operatorName ?? '')\n )\n }\n\n arityIsThree(args: IArguments) {\n return this.addValidation(\n () => args.length === 3,\n () => messages.arityValidations.arityIsThree(this.operatorName ?? '')\n )\n }\n\n arityIsAtLeastTwo(args: IArguments) {\n return this.addValidation(\n () => args.length >= 2,\n () => messages.arityValidations.arityIsAtLeastTwo(this.operatorName ?? '')\n )\n }\n\n arityIsAtLeastOne(args: IArguments | any[]) {\n return this.addValidation(\n () => args.length >= 1,\n () => messages.arityValidations.arityIsAtLeastOne(this.operatorName ?? '')\n )\n }\n\n addValidation(\n predicateFn: Validation['predicateFn'],\n messageFn: Validation['messageFn']\n ) {\n this._validations.push({\n predicateFn,\n messageFn,\n })\n return this\n }\n}\n\nexport class AggregatingValidator extends BaseValidator {\n private _invalidArguments: string[]\n\n constructor(previousInvalidArguments?: string[]) {\n super()\n this._invalidArguments = clone(previousInvalidArguments)\n }\n\n validateAndAggregate(): [string[], boolean] {\n const valid = this._validations.every(({ predicateFn, messageFn }) =>\n this._appendIfInvalid(predicateFn(), messageFn())\n )\n return [this._invalidArguments, valid]\n }\n\n _appendIfInvalid(valid: boolean, message: string) {\n if (!valid) {\n this._invalidArguments.push(message)\n return false\n }\n return true\n }\n}\n\nexport class DistinctingValidator extends BaseValidator {\n private _invalidArguments: string[]\n\n constructor(previousInvalidArguments?: string[]) {\n super()\n this._invalidArguments = clone(previousInvalidArguments)\n }\n\n validateAndAggregate(): [string[], boolean] {\n const valid = this._validations.every(({ predicateFn, messageFn }) =>\n this._appendIfInvalid(predicateFn(), messageFn())\n )\n return [this._invalidArguments, valid]\n }\n\n _appendIfInvalid(valid: boolean, message: string) {\n if (!valid) {\n this._invalidArguments.push(message)\n return false\n }\n return true\n }\n}\n\nexport class RejectingValidator extends BaseValidator {\n constructor(private buildError: (s: string) => Error = validationError) {\n super()\n }\n\n validateAndReject(): Promise<void> {\n return Promise.resolve().then(() => {\n this._validations.forEach(({ predicateFn, messageFn }) => {\n if (!predicateFn()) {\n throw this.buildError(messageFn())\n }\n })\n })\n }\n\n validateAndReturn(): string[] {\n const errors: string[] = []\n this._validations.forEach(({ predicateFn, messageFn }) => {\n if (!predicateFn()) {\n errors.push(messageFn())\n }\n })\n return errors\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAFA;;AAQA,MAAME,aAAa,CAAC;EAIlBC,WAAWA,CAAA,EAAG;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACZ,IAAI,CAACC,YAAY,GAAG,EAAE;EACxB;EAEAC,WAAWA,CAACC,IAAgB,EAAE;IAC5B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACL,WAAW,CAAC,IAAI,CAACM,YAAY,IAAI,EAAE,CACrE,CAAC;EACH;EAEAC,UAAUA,CAACN,IAAgB,EAAE;IAC3B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACE,UAAU,CAAC,IAAI,CAACD,YAAY,IAAI,EAAE,CACpE,CAAC;EACH;EAEAE,UAAUA,CAACP,IAAgB,EAAE;IAC3B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACG,UAAU,CAAC,IAAI,CAACF,YAAY,IAAI,EAAE,CACpE,CAAC;EACH;EAEAG,YAAYA,CAACR,IAAgB,EAAE;IAC7B,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMD,IAAI,CAACE,MAAM,KAAK,CAAC,EACvB,MAAMC,gBAAQ,CAACC,gBAAgB,CAACI,YAAY,CAAC,IAAI,CAACH,YAAY,IAAI,EAAE,CACtE,CAAC;EACH;EAEAI,iBAAiBA,CAACT,IAAgB,EAAE;IAClC,OAAO,IAAI,CAACC,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,iBAAiBA,CAAA,EAAa;IAC5B,MAAMC,MAAgB,GAAG,EAAE;IAC3B,IAAI,CAACpC,YAAY,CAACkC,OAAO,CAAC,CAAC;MAAErB,WAAW;MAAEC;IAAU,CAAC,KAAK;MACxD,IAAI,CAACD,WAAW,CAAC,CAAC,EAAE;QAClBuB,MAAM,CAACrB,IAAI,CAACD,SAAS,CAAC,CAAC,CAAC;MAC1B;IACF,CAAC,CAAC;IACF,OAAOsB,MAAM;EACf;AACF;AAACX,OAAA,CAAAE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_safeJsonStringify","_interopRequireDefault","messages","exports","collectionNameMustBeAString","itemIdMustBeAString","itemIdsMustBeArrayOfStrings","removeItemsMustBeLessThanThousand","collectionName","fieldNameMustBeAString","itemMustBeAnObject","item","itemsMustBeArrayOfObjects","itemsMustBeLessThanThousand","updateItemInvalid","invalidArgumentLength","method","from","to","actual","aggregateValidations","aggregateInvalid","invalidArguments","join","filterMustBeBuilder","operatorName","filterIsAlreadySet","groupIsAlreadySet","filterBuilderInvalid","groupBuilderInvalid","filterMustBeAnObject","sortBuilderInvalid","optionsInvalid","properties","referenceOperationParameterError","referenceOperationFieldError","fieldName","invalidReferenceError","queryValidations","queryInvalid","isNumber","specifier","operand","typeForDisplay","isPositiveNumber","isNonNegativeNumber","isInteger","isNonEmptyString","notGreaterThan","value","invalidSkipParameter","skipParameter","noPrevPage","noNextPage","arityValidations","arityIsZero","arityIsOne","arityIsTwo","arityIsThree","arityIsAtLeastTwo","arityIsAtLeastOne","filterValidations","typeIsString","typeIsStringNumberOrDate","sameType","first","second","typeIsStringNumberOrDateForAll","validFieldName","field","isInstanceOfSameClass","constructorName","obj","isForCollection","filterTreeValidations","objectType","stringify","arrayType","arrayLength","expectedLength","length","comparisonOperatorType","stringOperatorType","setOperatorItems","inOperatorItems","matchesOperatorRequiredProperty","propertyName","matchesOperatorIgnoreCase","matchesOperatorSpecItems","regexNotAllowed","sortValidations","typeIsStringOrArrayOfStrings","effectiveArgs","map","orderByValidations","sortModelType","sortModelItemType","sortModelItem","internalError","message","serverInvalidResponse","itemDoesNotExist","id","cursorPagingDoesNotSupportSkip","payloadIsTooLarge","safeJsonStringify","codes","ItemDoesNotExist","ItemAlreadyExists","SiteInTemplateMode","UnknownError","ValidationError","CollectionDeleted","SchemaDoesNotExist","PermissionDenied","BadRequest","Unauthorized","TooManyRequests","RequestTimedOut","QuotaExceeded","QueryExecutionError","wixDataError","code","details","buildError","validationError","wdeValidationError","startsWith","substring","undefined","applicationError","description","ErrorConstructor","WixDataError","Error","error","constructor","_defineProperty2","default","captureStackTrace","BulkError","name","originalIndex"],"sources":["../../../src/errors/errors.ts"],"sourcesContent":["import { typeForDisplay } from '../utils'\nimport safeJsonStringify from 'safe-json-stringify'\n\n// When adding new messages, update Support article with error code and explanation about the error.\nexport const messages = {\n collectionNameMustBeAString: () =>\n 'WDE0001: Collection name must be a string.',\n itemIdMustBeAString: () => 'WDE0002: ItemId must be a string.',\n itemIdsMustBeArrayOfStrings: () =>\n 'WDE0068: Item ids must be an array of strings',\n removeItemsMustBeLessThanThousand: (collectionName: string) =>\n `WDE0069: Failed to remove items from [${collectionName}].\\nCannot remove more than 1000 items in one request`,\n fieldNameMustBeAString: () => 'WDE0003: FieldName must be a string.',\n itemMustBeAnObject: (item: any, collectionName: string) =>\n `WDE0004: Failed to save [${item}] into [${collectionName}].\\nItems must be JavaScript objects.`,\n itemsMustBeArrayOfObjects: (collectionName: string) =>\n `WDE0005: Failed to bulk save items into [${collectionName}].\\nItems must be an array of JavaScript objects and itemIds must be strings if present.`,\n itemsMustBeLessThanThousand: (collectionName: string) =>\n `WDE0006: Failed to bulk save items into [${collectionName}].\\nCannot insert more than 1000 items in one request`,\n updateItemInvalid: () =>\n 'WDE0007: Invalid update. Updated object must have a string _id property.',\n invalidArgumentLength: (\n method: string,\n from: number,\n to: number,\n actual: number\n ) =>\n `WDE0008: wixData.${method} expects between ${from} and ${to} arguments, but was called with ${actual}.`,\n aggregateValidations: {\n aggregateInvalid: (collectionName: string, invalidArguments: string[]) =>\n `Failed to perform aggregation on [${collectionName}].\\n${invalidArguments.join(\n '\\n'\n )}`,\n filterMustBeBuilder: (operatorName: string) =>\n `WDE0011: Invalid ${operatorName} usage. ${operatorName} requires WixDataFilter.`,\n filterIsAlreadySet: (operatorName: string) =>\n `WDE0012: Invalid ${operatorName} usage. Filter is already set.`,\n groupIsAlreadySet: (operatorName: string) =>\n `WDE0013: Invalid ${operatorName} usage. Group is already set.`,\n },\n filterBuilderInvalid: (invalidArguments: string[]) =>\n `Failed to build a filter.\\n${invalidArguments.join('\\n')}.`,\n groupBuilderInvalid: (invalidArguments: string[]) =>\n `Failed to build group.\\n${invalidArguments.join('\\n')}.`,\n filterMustBeAnObject: () => 'WDE0016: Filter must be an object.',\n sortBuilderInvalid: (invalidArguments: string[]) =>\n `Failed to build a sort.\\n${invalidArguments.join('\\n')}.`,\n optionsInvalid: (properties: string[]) =>\n `WDE0018: Options must be an object with one or all of the following boolean properties: ${properties.join(\n ', '\n )}.`,\n referenceOperationParameterError: () =>\n 'WDE0019: Reference operation takes a string ID or an object with an ID to be connected.',\n referenceOperationFieldError: (fieldName: string) =>\n `WDE0020: Provided property [${fieldName}] is not a multi-reference field.`,\n invalidReferenceError: () => `WDE0021: Invalid reference`,\n queryValidations: {\n queryInvalid: (collectionName: string, invalidArguments: string[]) =>\n `Failed to perform query on [${collectionName}].\\n${invalidArguments.join(\n '\\n'\n )}`,\n isNumber: (operatorName: string, specifier: string, operand: any) =>\n `WDE0032: Invalid ${operatorName} parameter [${typeForDisplay(\n operand\n )}]. ${operatorName} parameter must be a ${specifier} number.`,\n isPositiveNumber: (operatorName: string, operand: number) =>\n `WDE0033: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter must be a positive number.`,\n isNonNegativeNumber: (operatorName: string, operand: number) =>\n `WDE0034: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter must be a non-negative number.`,\n isInteger: (operatorName: string, operand: number) =>\n `WDE0035: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter must be an integer.`,\n isNonEmptyString: (operatorName: string) =>\n `WDE0094: Invalid ${operatorName} parameter. ${operatorName} parameter must be non-empty string.`,\n notGreaterThan: (operatorName: string, operand: number, value: number) =>\n `WDE0036: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter cannot exceed ${value}.`,\n invalidSkipParameter: (collectionName: string, skipParameter: number) =>\n `WDE0037: Invalid query on [${collectionName}].\\nInvalid prev positioned query skip on a negative number ${skipParameter}.`,\n noPrevPage: (collectionName: string) =>\n `WDE0159: Invalid query on [${collectionName}].\\nThere is no prev page.`,\n noNextPage: (collectionName: string) =>\n `WDE0165: Invalid query on [${collectionName}].\\nThere is no next page.`,\n },\n arityValidations: {\n arityIsZero: (operatorName: string) =>\n `WDE0038: Invalid ${operatorName} usage. ${operatorName} does not take parameters.`,\n arityIsOne: (operatorName: string) =>\n `WDE0039: Invalid ${operatorName} usage. ${operatorName} requires one parameter.`,\n arityIsTwo: (operatorName: string) =>\n `WDE0040: Invalid ${operatorName} usage. ${operatorName} requires two parameters.`,\n arityIsThree: (operatorName: string) =>\n `WDE0041: Invalid ${operatorName} usage. ${operatorName} requires three parameters.`,\n arityIsAtLeastTwo: (operatorName: string) =>\n `WDE0042: Invalid ${operatorName} usage. ${operatorName} requires at least two parameters.`,\n arityIsAtLeastOne: (operatorName: string) =>\n `WDE0043: Invalid ${operatorName} usage. ${operatorName} requires at least one parameter.`,\n },\n filterValidations: {\n typeIsString: (operatorName: string, value: any) =>\n `WDE0044: Invalid ${operatorName} parameter value [${typeForDisplay(\n value\n )}]. ${operatorName} parameter must be a String.`,\n typeIsStringNumberOrDate: (operatorName: string, value: any) =>\n `WDE0045: Invalid ${operatorName} parameter value [${typeForDisplay(\n value\n )}]. Valid ${operatorName} parameter types are String, Number or Date.`,\n sameType: (operatorName: string, first: any, second: any) =>\n `WDE0046: Invalid ${operatorName} parameter values [${typeForDisplay(\n first\n )}] and [${typeForDisplay(\n second\n )}]. Both parameters must be of the same type.`,\n typeIsStringNumberOrDateForAll: (operatorName: string) =>\n `WDE0047: Invalid ${operatorName} usage. ${operatorName} supports only Number, String or Date items.`,\n validFieldName: (operatorName: string, field: string) =>\n `WDE0048: Invalid ${operatorName} field value [${typeForDisplay(\n field\n )}]. ${operatorName} field must be a String.`,\n isInstanceOfSameClass: (\n operatorName: string,\n constructorName: string,\n obj: any\n ) =>\n `WDE0049: Invalid ${operatorName} parameter [${typeForDisplay(\n obj\n )}]. ${operatorName} expects ${constructorName} only.`,\n isForCollection: (\n operatorName: string,\n constructorName: string,\n collectionName: string\n ) =>\n `WDE0050: Invalid ${operatorName} parameter query for [${collectionName}]. ${operatorName} accepts ${constructorName} for the same collection only.`,\n },\n filterTreeValidations: {\n objectType: (operatorName: string, value: any) =>\n `WDE0056: ${operatorName} should be an Object. Got ${stringify(\n value\n )} instead`,\n arrayType: (operatorName: string, value: any) =>\n `WDE0057: ${operatorName} should be an Array. Got ${stringify(\n value\n )} instead`,\n arrayLength: (operatorName: string, expectedLength: number, value: any[]) =>\n `WDE0057: ${stringify(value)}.length is ${\n value.length\n }. ${operatorName} Array should have length ${expectedLength}`,\n comparisonOperatorType: (operatorName: string, value: any) =>\n `WDE0058: ${operatorName} should be a Date, Number, or String. Got ${stringify(\n value\n )} instead`,\n stringOperatorType: (operatorName: string, value: any) =>\n `WDE0059: ${operatorName} should be a String. Got ${stringify(\n value\n )} instead`,\n setOperatorItems: (operatorName: string, value: any) =>\n `WDE0060: ${operatorName} Array should only contain values of types Date, Number, and String. Got ${stringify(\n value\n )} instead`,\n inOperatorItems: (value: any) =>\n `WDE0061: $in Array should have length 2, and match [String, Number]. Got ${stringify(\n value\n )} instead`,\n matchesOperatorRequiredProperty: (propertyName: string, value: any) =>\n `WDE0062: $matches value ${stringify(\n value\n )} does not have property ${propertyName}`,\n matchesOperatorIgnoreCase: (value: any) =>\n `WDE0063: $matches.ignoreCase should equal true. Got ${stringify(\n value\n )} instead`,\n matchesOperatorSpecItems: (value: any) =>\n `WDE0064: $matches.spec Array values should be either {\"type\":\"anyOf\",\"value\":\" -\"} or {\"type\":\"literal\",\"value\":String}. Got ${stringify(\n value\n )} instead`,\n regexNotAllowed: () => 'WDE0070: $regex keyword is not allowed.',\n },\n sortValidations: {\n typeIsStringOrArrayOfStrings: (\n operatorName: string,\n effectiveArgs: any[]\n ) =>\n `WDE0051: Invalid ${operatorName} parameters [${effectiveArgs.map(\n typeForDisplay\n )}]. Valid ${operatorName} values are String, Array of String or varargs String.`,\n },\n orderByValidations: {\n sortModelType: (value: any) =>\n `WDE0065: Sort Model should be an Array. Got ${stringify(value)} instead`,\n sortModelItemType: (value: any) =>\n `WDE0066: Sort Model Array should contain values of type Object only. Got ${stringify(\n value\n )} instead`,\n sortModelItem: (value: any) =>\n `WDE0067: Sort Model Array items should have a single property with value \"asc\" or \"desc\". Got ${stringify(\n value\n )} instead`,\n },\n internalError: (message: string) =>\n `WDE0053: Internal wixData error: ${message}`,\n serverInvalidResponse: (message: string) =>\n 'WDE0055: Failed to parse server response.' +\n (message ? ` ${message}` : ''),\n itemDoesNotExist: (id: string, collectionName: string) =>\n `WDE0073: Item [${id}] does not exist in collection [${collectionName}].`,\n cursorPagingDoesNotSupportSkip: () =>\n 'WDE0080: Skip is not supported in cursor paging.',\n payloadIsTooLarge: () => 'WDE0109: Payload is too large.',\n}\n\nfunction stringify(obj: any) {\n return safeJsonStringify(obj)\n}\n\nexport const codes = {\n ItemDoesNotExist: 'WD_ITEM_DOES_NOT_EXIST',\n ItemAlreadyExists: 'WD_ITEM_ALREADY_EXISTS',\n SiteInTemplateMode: 'WD_SITE_IN_TEMPLATE_MODE',\n UnknownError: 'WD_UNKNOWN_ERROR',\n ValidationError: 'WD_VALIDATION_ERROR',\n CollectionDeleted: 'WD_COLLECTION_DELETED',\n SchemaDoesNotExist: 'WD_SCHEMA_DOES_NOT_EXIST',\n PermissionDenied: 'WD_PERMISSION_DENIED',\n BadRequest: 'WD_BAD_REQUEST',\n Unauthorized: 'WD_UNAUTHORIZED',\n TooManyRequests: 'WD_TOO_MANY_REQUESTS',\n RequestTimedOut: 'WD_REQUEST_TIMED_OUT',\n QuotaExceeded: 'WD_DATABASE_QUOTA_EXCEEDED',\n QueryExecutionError: 'WD_QUERY_EXECUTION_ERROR',\n}\n\nexport function wixDataError(message: string, code?: string, details?: any) {\n return buildError(message, code, details)\n}\n\nexport function validationError(message: string) {\n return buildError(message, codes.ValidationError)\n}\n\nexport function wdeValidationError(message: string) {\n const code = message.startsWith('WDE') ? message.substring(0, 7) : 'WDE0020'\n return buildError(message, undefined, {\n applicationError: { code, description: message },\n })\n}\n\nfunction buildError(message: string, code?: string, details?: any) {\n const ErrorConstructor =\n code && code !== codes.UnknownError ? WixDataError : Error\n const error = new ErrorConstructor(message)\n if (code) {\n // @ts-expect-error-next-line\n error.code = code\n }\n if (details) {\n // @ts-expect-error-next-line\n error.details = details\n }\n return error\n}\n\nclass WixDataError extends Error {\n name = 'Error'\n\n // marker for user error\n errorGroup = 'User'\n\n constructor(message: string) {\n super(message)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, WixDataError)\n }\n }\n}\n\nexport class BulkError extends Error {\n constructor(\n public message: string,\n public code: string,\n public item: any,\n public name: string,\n public originalIndex: number\n ) {\n super(message)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, BulkError)\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA;AACO,MAAMG,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACtBE,2BAA2B,EAAEA,CAAA,KAC3B,4CAA4C;EAC9CC,mBAAmB,EAAEA,CAAA,KAAM,mCAAmC;EAC9DC,2BAA2B,EAAEA,CAAA,KAC3B,+CAA+C;EACjDC,iCAAiC,EAAGC,cA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IACAY,KAAK,CAACZ,OAAO,GAAGA,OAAO;EACzB;EACA,OAAOY,KAAK;AACd;AAEA,MAAMF,YAAY,SAASC,KAAK,CAAC;EAM/BE,WAAWA,CAACrC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IAAA,IAAAsC,gBAAA,CAAAC,OAAA,gBANT,OAAO;IAEd;IAAA,IAAAD,gBAAA,CAAAC,OAAA,sBACa,MAAM;IAIjB,IAAIJ,KAAK,CAACK,iBAAiB,EAAE;MAC3BL,KAAK,CAACK,iBAAiB,CAAC,IAAI,EAAEN,YAAY,CAAC;IAC7C;EACF;AACF;AAEO,MAAMO,SAAS,SAASN,KAAK,CAAC;EACnCE,WAAWA,CACFrC,OAAe,EACfuB,IAAY,EACZ/G,IAAS,EACTkI,IAAY,EACZC,aAAqB,EAC5B;IACA,KAAK,CAAC3C,OAAO,CAAC;IAAA,KANPA,OAAe,GAAfA,OAAe;IAAA,KACfuB,IAAY,GAAZA,IAAY;IAAA,KACZ/G,IAAS,GAATA,IAAS;IAAA,KACTkI,IAAY,GAAZA,IAAY;IAAA,KACZC,aAAqB,GAArBA,aAAqB;IAG5B,IAAIR,KAAK,CAACK,iBAAiB,EAAE;MAC3BL,KAAK,CAACK,iBAAiB,CAAC,IAAI,EAAEC,SAAS,CAAC;IAC1C;EACF;AACF;AAACzI,OAAA,CAAAyI,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_utils","require","_safeJsonStringify","_interopRequireDefault","messages","exports","collectionNameMustBeAString","itemIdMustBeAString","itemIdsMustBeArrayOfStrings","removeItemsMustBeLessThanThousand","collectionName","fieldNameMustBeAString","itemMustBeAnObject","item","itemsMustBeArrayOfObjects","itemsMustBeLessThanThousand","updateItemInvalid","invalidArgumentLength","method","from","to","actual","aggregateValidations","aggregateInvalid","invalidArguments","join","filterMustBeBuilder","operatorName","filterIsAlreadySet","groupIsAlreadySet","filterBuilderInvalid","groupBuilderInvalid","filterMustBeAnObject","sortBuilderInvalid","optionsInvalid","properties","referenceOperationParameterError","referenceOperationFieldError","fieldName","invalidReferenceError","queryValidations","queryInvalid","isNumber","specifier","operand","typeForDisplay","isPositiveNumber","isNonNegativeNumber","isInteger","isNonEmptyString","notGreaterThan","value","invalidSkipParameter","skipParameter","noPrevPage","noNextPage","arityValidations","arityIsZero","arityIsOne","arityIsTwo","arityIsThree","arityIsAtLeastTwo","arityIsAtLeastOne","filterValidations","typeIsString","typeIsStringNumberOrDate","sameType","first","second","typeIsStringNumberOrDateForAll","validFieldName","field","isInstanceOfSameClass","constructorName","obj","isForCollection","filterTreeValidations","objectType","stringify","arrayType","arrayLength","expectedLength","length","comparisonOperatorType","stringOperatorType","setOperatorItems","inOperatorItems","matchesOperatorRequiredProperty","propertyName","matchesOperatorIgnoreCase","matchesOperatorSpecItems","regexNotAllowed","sortValidations","typeIsStringOrArrayOfStrings","effectiveArgs","map","orderByValidations","sortModelType","sortModelItemType","sortModelItem","internalError","message","serverInvalidResponse","itemDoesNotExist","id","cursorPagingDoesNotSupportSkip","payloadIsTooLarge","safeJsonStringify","codes","ItemDoesNotExist","ItemAlreadyExists","SiteInTemplateMode","UnknownError","ValidationError","CollectionDeleted","SchemaDoesNotExist","PermissionDenied","BadRequest","Unauthorized","TooManyRequests","RequestTimedOut","QuotaExceeded","QueryExecutionError","wixDataError","code","details","buildError","validationError","wdeValidationError","startsWith","substring","undefined","applicationError","description","ErrorConstructor","WixDataError","Error","error","constructor","_defineProperty2","default","captureStackTrace","BulkError","name","originalIndex"],"sources":["../../../src/errors/errors.ts"],"sourcesContent":["import { typeForDisplay } from '../utils'\nimport safeJsonStringify from 'safe-json-stringify'\n\n// When adding new messages, update Support article with error code and explanation about the error.\nexport const messages = {\n collectionNameMustBeAString: () =>\n 'WDE0001: Collection name must be a string.',\n itemIdMustBeAString: () => 'WDE0002: ItemId must be a string.',\n itemIdsMustBeArrayOfStrings: () =>\n 'WDE0068: Item ids must be an array of strings',\n removeItemsMustBeLessThanThousand: (collectionName: string) =>\n `WDE0069: Failed to remove items from [${collectionName}].\\nCannot remove more than 1000 items in one request`,\n fieldNameMustBeAString: () => 'WDE0003: FieldName must be a string.',\n itemMustBeAnObject: (item: any, collectionName: string) =>\n `WDE0004: Failed to save [${item}] into [${collectionName}].\\nItems must be JavaScript objects.`,\n itemsMustBeArrayOfObjects: (collectionName: string) =>\n `WDE0005: Failed to bulk save items into [${collectionName}].\\nItems must be an array of JavaScript objects and itemIds must be strings if present.`,\n itemsMustBeLessThanThousand: (collectionName: string) =>\n `WDE0006: Failed to bulk save items into [${collectionName}].\\nCannot insert more than 1000 items in one request`,\n updateItemInvalid: () =>\n 'WDE0007: Invalid update. Updated object must have a string _id property.',\n invalidArgumentLength: (\n method: string,\n from: number,\n to: number,\n actual: number\n ) =>\n `WDE0008: wixData.${method} expects between ${from} and ${to} arguments, but was called with ${actual}.`,\n aggregateValidations: {\n aggregateInvalid: (collectionName: string, invalidArguments: string[]) =>\n `Failed to perform aggregation on [${collectionName}].\\n${invalidArguments.join(\n '\\n'\n )}`,\n filterMustBeBuilder: (operatorName: string) =>\n `WDE0011: Invalid ${operatorName} usage. ${operatorName} requires WixDataFilter.`,\n filterIsAlreadySet: (operatorName: string) =>\n `WDE0012: Invalid ${operatorName} usage. Filter is already set.`,\n groupIsAlreadySet: (operatorName: string) =>\n `WDE0013: Invalid ${operatorName} usage. Group is already set.`,\n },\n filterBuilderInvalid: (invalidArguments: string[]) =>\n `Failed to build a filter.\\n${invalidArguments.join('\\n')}.`,\n groupBuilderInvalid: (invalidArguments: string[]) =>\n `Failed to build group.\\n${invalidArguments.join('\\n')}.`,\n filterMustBeAnObject: () => 'WDE0016: Filter must be an object.',\n sortBuilderInvalid: (invalidArguments: string[]) =>\n `Failed to build a sort.\\n${invalidArguments.join('\\n')}.`,\n optionsInvalid: (properties: string[]) =>\n `WDE0018: Options must be an object with one or all of the following boolean properties: ${properties.join(\n ', '\n )}.`,\n referenceOperationParameterError: () =>\n 'WDE0019: Reference operation takes a string ID or an object with an ID to be connected.',\n referenceOperationFieldError: (fieldName: string) =>\n `WDE0020: Provided property [${fieldName}] is not a multi-reference field.`,\n invalidReferenceError: () => `WDE0021: Invalid reference`,\n queryValidations: {\n queryInvalid: (collectionName: string, invalidArguments: string[]) =>\n `Failed to perform query on [${collectionName}].\\n${invalidArguments.join(\n '\\n'\n )}`,\n isNumber: (operatorName: string, specifier: string, operand: any) =>\n `WDE0032: Invalid ${operatorName} parameter [${typeForDisplay(\n operand\n )}]. ${operatorName} parameter must be a ${specifier} number.`,\n isPositiveNumber: (operatorName: string, operand: number) =>\n `WDE0033: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter must be a positive number.`,\n isNonNegativeNumber: (operatorName: string, operand: number) =>\n `WDE0034: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter must be a non-negative number.`,\n isInteger: (operatorName: string, operand: number) =>\n `WDE0035: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter must be an integer.`,\n isNonEmptyString: (operatorName: string) =>\n `WDE0094: Invalid ${operatorName} parameter. ${operatorName} parameter must be non-empty string.`,\n notGreaterThan: (operatorName: string, operand: number, value: number) =>\n `WDE0036: Invalid ${operatorName} parameter [${operand}]. ${operatorName} parameter cannot exceed ${value}.`,\n invalidSkipParameter: (collectionName: string, skipParameter: number) =>\n `WDE0037: Invalid query on [${collectionName}].\\nInvalid prev positioned query skip on a negative number ${skipParameter}.`,\n noPrevPage: (collectionName: string) =>\n `WDE0159: Invalid query on [${collectionName}].\\nThere is no prev page.`,\n noNextPage: (collectionName: string) =>\n `WDE0165: Invalid query on [${collectionName}].\\nThere is no next page.`,\n },\n arityValidations: {\n arityIsZero: (operatorName: string) =>\n `WDE0038: Invalid ${operatorName} usage. ${operatorName} does not take parameters.`,\n arityIsOne: (operatorName: string) =>\n `WDE0039: Invalid ${operatorName} usage. ${operatorName} requires one parameter.`,\n arityIsTwo: (operatorName: string) =>\n `WDE0040: Invalid ${operatorName} usage. ${operatorName} requires two parameters.`,\n arityIsThree: (operatorName: string) =>\n `WDE0041: Invalid ${operatorName} usage. ${operatorName} requires three parameters.`,\n arityIsAtLeastTwo: (operatorName: string) =>\n `WDE0042: Invalid ${operatorName} usage. ${operatorName} requires at least two parameters.`,\n arityIsAtLeastOne: (operatorName: string) =>\n `WDE0043: Invalid ${operatorName} usage. ${operatorName} requires at least one parameter.`,\n },\n filterValidations: {\n typeIsString: (operatorName: string, value: any) =>\n `WDE0044: Invalid ${operatorName} parameter value [${typeForDisplay(\n value\n )}]. ${operatorName} parameter must be a String.`,\n typeIsStringNumberOrDate: (operatorName: string, value: any) =>\n `WDE0045: Invalid ${operatorName} parameter value [${typeForDisplay(\n value\n )}]. Valid ${operatorName} parameter types are String, Number or Date.`,\n sameType: (operatorName: string, first: any, second: any) =>\n `WDE0046: Invalid ${operatorName} parameter values [${typeForDisplay(\n first\n )}] and [${typeForDisplay(\n second\n )}]. Both parameters must be of the same type.`,\n typeIsStringNumberOrDateForAll: (operatorName: string) =>\n `WDE0047: Invalid ${operatorName} usage. ${operatorName} supports only Number, String or Date items.`,\n validFieldName: (operatorName: string, field: string) =>\n `WDE0048: Invalid ${operatorName} field value [${typeForDisplay(\n field\n )}]. ${operatorName} field must be a String.`,\n isInstanceOfSameClass: (\n operatorName: string,\n constructorName: string,\n obj: any\n ) =>\n `WDE0049: Invalid ${operatorName} parameter [${typeForDisplay(\n obj\n )}]. ${operatorName} expects ${constructorName} only.`,\n isForCollection: (\n operatorName: string,\n constructorName: string,\n collectionName: string\n ) =>\n `WDE0050: Invalid ${operatorName} parameter query for [${collectionName}]. ${operatorName} accepts ${constructorName} for the same collection only.`,\n },\n filterTreeValidations: {\n objectType: (operatorName: string, value: any) =>\n `WDE0056: ${operatorName} should be an Object. Got ${stringify(\n value\n )} instead`,\n arrayType: (operatorName: string, value: any) =>\n `WDE0057: ${operatorName} should be an Array. Got ${stringify(\n value\n )} instead`,\n arrayLength: (operatorName: string, expectedLength: number, value: any[]) =>\n `WDE0057: ${stringify(value)}.length is ${\n value.length\n }. ${operatorName} Array should have length ${expectedLength}`,\n comparisonOperatorType: (operatorName: string, value: any) =>\n `WDE0058: ${operatorName} should be a Date, Number, or String. Got ${stringify(\n value\n )} instead`,\n stringOperatorType: (operatorName: string, value: any) =>\n `WDE0059: ${operatorName} should be a String. Got ${stringify(\n value\n )} instead`,\n setOperatorItems: (operatorName: string, value: any) =>\n `WDE0060: ${operatorName} Array should only contain values of types Date, Number, and String. Got ${stringify(\n value\n )} instead`,\n inOperatorItems: (value: any) =>\n `WDE0061: $in Array should have length 2, and match [String, Number]. Got ${stringify(\n value\n )} instead`,\n matchesOperatorRequiredProperty: (propertyName: string, value: any) =>\n `WDE0062: $matches value ${stringify(\n value\n )} does not have property ${propertyName}`,\n matchesOperatorIgnoreCase: (value: any) =>\n `WDE0063: $matches.ignoreCase should equal true. Got ${stringify(\n value\n )} instead`,\n matchesOperatorSpecItems: (value: any) =>\n `WDE0064: $matches.spec Array values should be either {\"type\":\"anyOf\",\"value\":\" -\"} or {\"type\":\"literal\",\"value\":String}. Got ${stringify(\n value\n )} instead`,\n regexNotAllowed: () => 'WDE0070: $regex keyword is not allowed.',\n },\n sortValidations: {\n typeIsStringOrArrayOfStrings: (\n operatorName: string,\n effectiveArgs: any[]\n ) =>\n `WDE0051: Invalid ${operatorName} parameters [${effectiveArgs.map(\n typeForDisplay\n )}]. Valid ${operatorName} values are String, Array of String or varargs String.`,\n },\n orderByValidations: {\n sortModelType: (value: any) =>\n `WDE0065: Sort Model should be an Array. Got ${stringify(value)} instead`,\n sortModelItemType: (value: any) =>\n `WDE0066: Sort Model Array should contain values of type Object only. Got ${stringify(\n value\n )} instead`,\n sortModelItem: (value: any) =>\n `WDE0067: Sort Model Array items should have a single property with value \"asc\" or \"desc\". Got ${stringify(\n value\n )} instead`,\n },\n internalError: (message: string) =>\n `WDE0053: Internal wixData error: ${message}`,\n serverInvalidResponse: (message: string) =>\n 'WDE0055: Failed to parse server response.' +\n (message ? ` ${message}` : ''),\n itemDoesNotExist: (id: string, collectionName: string) =>\n `WDE0073: Item [${id}] does not exist in collection [${collectionName}].`,\n cursorPagingDoesNotSupportSkip: () =>\n 'WDE0080: Skip is not supported in cursor paging.',\n payloadIsTooLarge: () => 'WDE0109: Payload is too large.',\n}\n\nfunction stringify(obj: any) {\n return safeJsonStringify(obj)\n}\n\nexport const codes = {\n ItemDoesNotExist: 'WD_ITEM_DOES_NOT_EXIST',\n ItemAlreadyExists: 'WD_ITEM_ALREADY_EXISTS',\n SiteInTemplateMode: 'WD_SITE_IN_TEMPLATE_MODE',\n UnknownError: 'WD_UNKNOWN_ERROR',\n ValidationError: 'WD_VALIDATION_ERROR',\n CollectionDeleted: 'WD_COLLECTION_DELETED',\n SchemaDoesNotExist: 'WD_SCHEMA_DOES_NOT_EXIST',\n PermissionDenied: 'WD_PERMISSION_DENIED',\n BadRequest: 'WD_BAD_REQUEST',\n Unauthorized: 'WD_UNAUTHORIZED',\n TooManyRequests: 'WD_TOO_MANY_REQUESTS',\n RequestTimedOut: 'WD_REQUEST_TIMED_OUT',\n QuotaExceeded: 'WD_DATABASE_QUOTA_EXCEEDED',\n QueryExecutionError: 'WD_QUERY_EXECUTION_ERROR',\n}\n\nexport function wixDataError(message: string, code?: string, details?: any) {\n return buildError(message, code, details)\n}\n\nexport function validationError(message: string) {\n return buildError(message, codes.ValidationError)\n}\n\nexport function wdeValidationError(message: string) {\n const code = message.startsWith('WDE') ? message.substring(0, 7) : 'WDE0020'\n return buildError(message, undefined, {\n applicationError: { code, description: message },\n })\n}\n\nfunction buildError(message: string, code?: string, details?: any) {\n const ErrorConstructor =\n code && code !== codes.UnknownError ? WixDataError : Error\n const error = new ErrorConstructor(message)\n if (code) {\n // @ts-expect-error-next-line\n error.code = code\n }\n if (details) {\n // @ts-expect-error-next-line\n error.details = details\n }\n return error\n}\n\nclass WixDataError extends Error {\n name = 'Error'\n\n // marker for user error\n errorGroup = 'User'\n\n constructor(message: string) {\n super(message)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, WixDataError)\n }\n }\n}\n\nexport class BulkError extends Error {\n constructor(\n public message: string,\n public code: string,\n public item: any,\n public name: string,\n public originalIndex: number\n ) {\n super(message)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, BulkError)\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA;AACO,MAAMG,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACtBE,2BAA2B,EAAEA,CAAA,KAC3B,4CAA4C;EAC9CC,mBAAmB,EAAEA,CAAA,KAAM,mCAAmC;EAC9DC,2BAA2B,EAAEA,CAAA,KAC3B,+CAA+C;EACjDC,iCAAiC,EAAGC,cAAsB,IACxD,yCAAyCA,cAAc,uDAAuD;EAChHC,sBAAsB,EAAEA,CAAA,KAAM,sCAAsC;EACpEC,kBAAkB,EAAEA,CAACC,IAAS,EAAEH,cAAsB,KACpD,4BAA4BG,IAAI,WAAWH,cAAc,uCAAuC;EAClGI,yBAAyB,EAAGJ,cAAsB,IAChD,4CAA4CA,cAAc,0FAA0F;EACtJK,2BAA2B,EAAGL,cAAsB,IAClD,4CAA4CA,cAAc,uDAAuD;EACnHM,iBAAiB,EAAEA,CAAA,KACjB,0EAA0E;EAC5EC,qBAAqB,EAAEA,CACrBC,MAAc,EACdC,IAAY,EACZC,EAAU,EACVC,MAAc,KAEd,oBAAoBH,MAAM,oBAAoBC,IAAI,QAAQC,EAAE,mCAAmCC,MAAM,GAAG;EAC1GC,oBAAoB,EAAE;IACpBC,gBAAgB,EAAEA,CAACb,cAAsB,EAAEc,gBAA0B,KACnE,qCAAqCd,cAAc,OAAOc,gBAAgB,CAACC,IAAI,CAC7E,IACF,CAAC,EAAE;IACLC,mBAAmB,EAAGC,YAAoB,IACxC,oBAAoBA,YAAY,WAAWA,YAAY,0BAA0B;IACnFC,kBAAkB,EAAGD,YAA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AACK,iBAAiB,EAAE;MAC3BL,KAAK,CAACK,iBAAiB,CAAC,IAAI,EAAEC,SAAS,CAAC;IAC1C;EACF;AACF;AAACzI,OAAA,CAAAyI,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","Object","keys","forEach","key","exports","_validations","_baseValidator"],"sources":["../../../src/errors/index.ts"],"sourcesContent":["export * from './errors'\nexport * from './validations'\nexport * from './base-validator'\n"],"mappings":";;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,OAAA,CAAAK,GAAA;AAAA;AACA,IAAAE,YAAA,GAAAN,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAI,YAAA,EAAAH,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAE,YAAA,CAAAF,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAE,YAAA,CAAAF,GAAA;AAAA;AACA,IAAAG,cAAA,GAAAP,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAK,cAAA,EAAAJ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAG,cAAA,CAAAH,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAG,cAAA,CAAAH,GAAA;AAAA"}
1
+ {"version":3,"names":["_errors","require","Object","keys","forEach","key","exports","_validations","_baseValidator"],"sources":["../../../src/errors/index.ts"],"sourcesContent":["export * from './errors'\nexport * from './validations'\nexport * from './base-validator'\n"],"mappings":";;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,OAAA,CAAAK,GAAA;AAAA;AACA,IAAAE,YAAA,GAAAN,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAI,YAAA,EAAAH,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAE,YAAA,CAAAF,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAE,YAAA,CAAAF,GAAA;AAAA;AACA,IAAAG,cAAA,GAAAP,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAK,cAAA,EAAAJ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAG,cAAA,CAAAH,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAG,cAAA,CAAAH,GAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_utils","_baseValidator","ApiValidator","RejectingValidator","arity","method","args","from","to","addValidation","length","messages","invalidArgumentLength","_isObject","item","collectionName","isObject","itemMustBeAnObject","requireId","_id","undefined","isString","updateItemInvalid","items","isArray","every","itemsMustBeArrayOfObjects","itemsMustBeLessThanThousand","fieldName","fieldNameMustBeAString","itemId","itemIdMustBeAString","itemIds","itemIdsMustBeArrayOfStrings","removeItemsMustBeLessThanThousand","_options","options","flags","validOptions","flag","isNonEmptyStringIfDefined","isBooleanIfDefined","optionsInvalid","referenceRemoveParameters","parameters","isRemoveReferenceParameter","referenceOperationParameterError","referenceParameters","isReferenceParameter","referenceParameter","parameter","isNonEmptyString","operand","operandName","queryValidations","references","refs","ref","relationshipName","left","right","invalidReferenceError","bulkInsertOptions","bulkUpdateOptions","bulkRemoveOptions","truncateOptions","collectionNameMustBeAString","apiValidator","errorBuilder","value","isBoolean","hasOwnProperty"],"sources":["../../../src/errors/validations.ts"],"sourcesContent":["import { messages } from './errors'\nimport { isString, isBoolean, isObject, isArray } from '../utils'\nimport { RejectingValidator } from './base-validator'\n\nclass ApiValidator extends RejectingValidator {\n arity(method: string, args: IArguments, from: number, to: number) {\n return this.addValidation(\n () => args.length <= to && args.length >= from,\n () => messages.invalidArgumentLength(method, from, to, args.length)\n )\n }\n\n _isObject(item: any, collectionName: string) {\n return this.addValidation(\n () => isObject(item),\n () => messages.itemMustBeAnObject(item, collectionName)\n )\n }\n\n item(item: any, collectionName: string, requireId: boolean) {\n return this._isObject(item, collectionName).addValidation(\n () => (item._id !== undefined ? isString(item._id) : !requireId),\n () => messages.updateItemInvalid()\n )\n }\n\n items(items: any, collectionName: string) {\n return this.addValidation(\n () =>\n isArray(items) &&\n items.every(\n (item) =>\n isObject(item) &&\n (item._id === undefined || item._id === null || isString(item._id))\n ),\n () => messages.itemsMustBeArrayOfObjects(collectionName)\n ).addValidation(\n () => items.length <= 1000,\n () => messages.itemsMustBeLessThanThousand(collectionName)\n )\n }\n\n fieldName(fieldName: any) {\n return this.addValidation(\n () => isString(fieldName),\n () => messages.fieldNameMustBeAString()\n )\n }\n\n itemId(itemId: any) {\n return this.addValidation(\n () => isString(itemId),\n () => messages.itemIdMustBeAString()\n )\n }\n\n itemIds(itemIds: any, collectionName: string) {\n return this.addValidation(\n () => isArray(itemIds) && itemIds.every((itemId) => isString(itemId)),\n () => messages.itemIdsMustBeArrayOfStrings()\n ).addValidation(\n () => itemIds.length <= 1000,\n () => messages.removeItemsMustBeLessThanThousand(collectionName)\n )\n }\n\n _options(options: any, flags: string[]) {\n return this.addValidation(\n () => {\n const validOptions =\n isObject(options) &&\n flags.every((flag) => {\n if (flag === 'language') {\n return isNonEmptyStringIfDefined(options[flag])\n } else {\n return isBooleanIfDefined(options[flag])\n }\n })\n return options == null || validOptions\n },\n () => messages.optionsInvalid(flags)\n )\n }\n\n referenceRemoveParameters(parameters: any) {\n return this.addValidation(\n () => isArray(parameters) && parameters.every(isRemoveReferenceParameter),\n messages.referenceOperationParameterError\n )\n }\n\n referenceParameters(parameters: any) {\n return this.addValidation(\n () => isArray(parameters) && parameters.every(isReferenceParameter),\n messages.referenceOperationParameterError\n )\n }\n\n referenceParameter(parameter: any) {\n return this.addValidation(\n () => isReferenceParameter(parameter),\n messages.referenceOperationParameterError\n )\n }\n\n isNonEmptyString(operand: any, operandName: string) {\n return this.addValidation(\n () => typeof operand === 'string' && operand.length > 0,\n () => messages.queryValidations.isNonEmptyString(operandName)\n )\n }\n\n references(refs: any) {\n return this.addValidation(\n () =>\n isArray(refs) &&\n refs.every(\n (ref) =>\n isString(ref.relationshipName) &&\n isReferenceParameter(ref.left) &&\n isReferenceParameter(ref.right)\n ),\n messages.invalidReferenceError\n )\n }\n\n options(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'showDrafts',\n 'consistentRead',\n 'language',\n ])\n }\n\n bulkInsertOptions(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'overrideExisting',\n ])\n }\n\n bulkUpdateOptions(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'showDrafts',\n ])\n }\n\n bulkRemoveOptions(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'showDrafts',\n ])\n }\n\n truncateOptions(options: any) {\n return this._options(options, ['suppressAuth'])\n }\n\n collectionName(collectionName: any) {\n return this.addValidation(\n () => isString(collectionName),\n () => messages.collectionNameMustBeAString()\n )\n }\n}\n\nexport function apiValidator(errorBuilder?: (s: string) => Error) {\n return new ApiValidator(errorBuilder)\n}\n\nfunction isNonEmptyStringIfDefined(value: any) {\n return value == null || (isString(value) && value.length > 0)\n}\n\nfunction isBooleanIfDefined(value: any) {\n return value == null || isBoolean(value)\n}\n\nfunction isReferenceParameter(parameter: any) {\n return (\n (isString(parameter) && parameter !== '') ||\n (isObject(parameter) && parameter.hasOwnProperty('_id'))\n )\n}\n\nfunction isRemoveReferenceParameter(parameter: any) {\n return (\n isString(parameter) ||\n (isObject(parameter) && parameter.hasOwnProperty('_id'))\n )\n}\n"],"mappings":";;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,YAAY,SAASC,iCAAkB,CAAC;EAC5CC,KAAKA,CAACC,MAAc,EAAEC,IAAgB,EAAEC,IAAY,EAAEC,EAAU,EAAE;IAChE,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMH,IAAI,CAACI,MAAM,IAAIF,EAAE,IAAIF,IAAI,CAACI,MAAM,IAAIH,IAAI,EAC9C,MAAMI,gBAAQ,CAACC,qBAAqB,CAACP,MAAM,EAAEE,IAAI,EAAEC,EAAE,EAAEF,IAAI,CAACI,MAAM,CACpE,CAAC;EACH;EAEAG,SAASA,CAACC,IAAS,EAAEC,cAAsB,EAAE;IAC3C,OAAO,IAAI,CAACN,aAAa,CACvB,MAAM,IAAAO,eAAQ,EAACF,IAAI,CAAC,EACpB,MAAMH,gBAAQ,CAACM,kBAAkB,CAACH,IAAI,EAAEC,cAAc,CACxD,CAAC;EACH;EAEAD,IAAIA,CAACA,IAAS,EAAEC,cAAsB,EAAEG,SAAkB,EAAE;IAC1D,OAAO,IAAI,CAACL,SAAS,CAACC,IAAI,EAAEC,cAAc,CAAC,CAACN,aAAa,CACvD,MAAOK,IAAI,CAACK,GAAG,KAAKC,SAAS,GAAG,IAAAC,eAAQ,EAACP,IAAI,CAACK,GAAG,CAAC,GAAG,CAACD,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AO,IAAI,CAACN,aAAa,CACvB,MAAM,IAAAY,eAAQ,EAACN,cAAc,CAAC,EAC9B,MAAMJ,gBAAQ,CAACuD,2BAA2B,CAAC,CAC7C,CAAC;EACH;AACF;AAEO,SAASC,YAAYA,CAACC,YAAmC,EAAE;EAChE,OAAO,IAAIlE,YAAY,CAACkE,YAAY,CAAC;AACvC;AAEA,SAAS5B,yBAAyBA,CAAC6B,KAAU,EAAE;EAC7C,OAAOA,KAAK,IAAI,IAAI,IAAK,IAAAhD,eAAQ,EAACgD,KAAK,CAAC,IAAIA,KAAK,CAAC3D,MAAM,GAAG,CAAE;AAC/D;AAEA,SAAS+B,kBAAkBA,CAAC4B,KAAU,EAAE;EACtC,OAAOA,KAAK,IAAI,IAAI,IAAI,IAAAC,gBAAS,EAACD,KAAK,CAAC;AAC1C;AAEA,SAASrB,oBAAoBA,CAACE,SAAc,EAAE;EAC5C,OACG,IAAA7B,eAAQ,EAAC6B,SAAS,CAAC,IAAIA,SAAS,KAAK,EAAE,IACvC,IAAAlC,eAAQ,EAACkC,SAAS,CAAC,IAAIA,SAAS,CAACqB,cAAc,CAAC,KAAK,CAAE;AAE5D;AAEA,SAAS1B,0BAA0BA,CAACK,SAAc,EAAE;EAClD,OACE,IAAA7B,eAAQ,EAAC6B,SAAS,CAAC,IAClB,IAAAlC,eAAQ,EAACkC,SAAS,CAAC,IAAIA,SAAS,CAACqB,cAAc,CAAC,KAAK,CAAE;AAE5D"}
1
+ {"version":3,"names":["_errors","require","_utils","_baseValidator","ApiValidator","RejectingValidator","arity","method","args","from","to","addValidation","length","messages","invalidArgumentLength","_isObject","item","collectionName","isObject","itemMustBeAnObject","requireId","_id","undefined","isString","updateItemInvalid","items","isArray","every","itemsMustBeArrayOfObjects","itemsMustBeLessThanThousand","fieldName","fieldNameMustBeAString","itemId","itemIdMustBeAString","itemIds","itemIdsMustBeArrayOfStrings","removeItemsMustBeLessThanThousand","_options","options","flags","validOptions","flag","isNonEmptyStringIfDefined","isBooleanIfDefined","optionsInvalid","referenceRemoveParameters","parameters","isRemoveReferenceParameter","referenceOperationParameterError","referenceParameters","isReferenceParameter","referenceParameter","parameter","isNonEmptyString","operand","operandName","queryValidations","references","refs","ref","relationshipName","left","right","invalidReferenceError","bulkInsertOptions","bulkUpdateOptions","bulkRemoveOptions","truncateOptions","collectionNameMustBeAString","apiValidator","errorBuilder","value","isBoolean","hasOwnProperty"],"sources":["../../../src/errors/validations.ts"],"sourcesContent":["import { messages } from './errors'\nimport { isString, isBoolean, isObject, isArray } from '../utils'\nimport { RejectingValidator } from './base-validator'\n\nclass ApiValidator extends RejectingValidator {\n arity(method: string, args: IArguments, from: number, to: number) {\n return this.addValidation(\n () => args.length <= to && args.length >= from,\n () => messages.invalidArgumentLength(method, from, to, args.length)\n )\n }\n\n _isObject(item: any, collectionName: string) {\n return this.addValidation(\n () => isObject(item),\n () => messages.itemMustBeAnObject(item, collectionName)\n )\n }\n\n item(item: any, collectionName: string, requireId: boolean) {\n return this._isObject(item, collectionName).addValidation(\n () => (item._id !== undefined ? isString(item._id) : !requireId),\n () => messages.updateItemInvalid()\n )\n }\n\n items(items: any, collectionName: string) {\n return this.addValidation(\n () =>\n isArray(items) &&\n items.every(\n (item) =>\n isObject(item) &&\n (item._id === undefined || item._id === null || isString(item._id))\n ),\n () => messages.itemsMustBeArrayOfObjects(collectionName)\n ).addValidation(\n () => items.length <= 1000,\n () => messages.itemsMustBeLessThanThousand(collectionName)\n )\n }\n\n fieldName(fieldName: any) {\n return this.addValidation(\n () => isString(fieldName),\n () => messages.fieldNameMustBeAString()\n )\n }\n\n itemId(itemId: any) {\n return this.addValidation(\n () => isString(itemId),\n () => messages.itemIdMustBeAString()\n )\n }\n\n itemIds(itemIds: any, collectionName: string) {\n return this.addValidation(\n () => isArray(itemIds) && itemIds.every((itemId) => isString(itemId)),\n () => messages.itemIdsMustBeArrayOfStrings()\n ).addValidation(\n () => itemIds.length <= 1000,\n () => messages.removeItemsMustBeLessThanThousand(collectionName)\n )\n }\n\n _options(options: any, flags: string[]) {\n return this.addValidation(\n () => {\n const validOptions =\n isObject(options) &&\n flags.every((flag) => {\n if (flag === 'language') {\n return isNonEmptyStringIfDefined(options[flag])\n } else {\n return isBooleanIfDefined(options[flag])\n }\n })\n return options == null || validOptions\n },\n () => messages.optionsInvalid(flags)\n )\n }\n\n referenceRemoveParameters(parameters: any) {\n return this.addValidation(\n () => isArray(parameters) && parameters.every(isRemoveReferenceParameter),\n messages.referenceOperationParameterError\n )\n }\n\n referenceParameters(parameters: any) {\n return this.addValidation(\n () => isArray(parameters) && parameters.every(isReferenceParameter),\n messages.referenceOperationParameterError\n )\n }\n\n referenceParameter(parameter: any) {\n return this.addValidation(\n () => isReferenceParameter(parameter),\n messages.referenceOperationParameterError\n )\n }\n\n isNonEmptyString(operand: any, operandName: string) {\n return this.addValidation(\n () => typeof operand === 'string' && operand.length > 0,\n () => messages.queryValidations.isNonEmptyString(operandName)\n )\n }\n\n references(refs: any) {\n return this.addValidation(\n () =>\n isArray(refs) &&\n refs.every(\n (ref) =>\n isString(ref.relationshipName) &&\n isReferenceParameter(ref.left) &&\n isReferenceParameter(ref.right)\n ),\n messages.invalidReferenceError\n )\n }\n\n options(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'showDrafts',\n 'consistentRead',\n 'language',\n ])\n }\n\n bulkInsertOptions(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'overrideExisting',\n ])\n }\n\n bulkUpdateOptions(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'showDrafts',\n ])\n }\n\n bulkRemoveOptions(options: any) {\n return this._options(options, [\n 'suppressAuth',\n 'suppressHooks',\n 'showDrafts',\n ])\n }\n\n truncateOptions(options: any) {\n return this._options(options, ['suppressAuth'])\n }\n\n collectionName(collectionName: any) {\n return this.addValidation(\n () => isString(collectionName),\n () => messages.collectionNameMustBeAString()\n )\n }\n}\n\nexport function apiValidator(errorBuilder?: (s: string) => Error) {\n return new ApiValidator(errorBuilder)\n}\n\nfunction isNonEmptyStringIfDefined(value: any) {\n return value == null || (isString(value) && value.length > 0)\n}\n\nfunction isBooleanIfDefined(value: any) {\n return value == null || isBoolean(value)\n}\n\nfunction isReferenceParameter(parameter: any) {\n return (\n (isString(parameter) && parameter !== '') ||\n (isObject(parameter) && parameter.hasOwnProperty('_id'))\n )\n}\n\nfunction isRemoveReferenceParameter(parameter: any) {\n return (\n isString(parameter) ||\n (isObject(parameter) && parameter.hasOwnProperty('_id'))\n )\n}\n"],"mappings":";;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,YAAY,SAASC,iCAAkB,CAAC;EAC5CC,KAAKA,CAACC,MAAc,EAAEC,IAAgB,EAAEC,IAAY,EAAEC,EAAU,EAAE;IAChE,OAAO,IAAI,CAACC,aAAa,CACvB,MAAMH,IAAI,CAACI,MAAM,IAAIF,EAAE,IAAIF,IAAI,CAACI,MAAM,IAAIH,IAAI,EAC9C,MAAMI,gBAAQ,CAACC,qBAAqB,CAACP,MAAM,EAAEE,IAAI,EAAEC,EAAE,EAAEF,IAAI,CAACI,MAAM,CACpE,CAAC;EACH;EAEAG,SAASA,CAACC,IAAS,EAAEC,cAAsB,EAAE;IAC3C,OAAO,IAAI,CAACN,aAAa,CACvB,MAAM,IAAAO,eAAQ,EAACF,IAAI,CAAC,EACpB,MAAMH,gBAAQ,CAACM,kBAAkB,CAACH,IAAI,EAAEC,cAAc,CACxD,CAAC;EACH;EAEAD,IAAIA,CAACA,IAAS,EAAEC,cAAsB,EAAEG,SAAkB,EAAE;IAC1D,OAAO,IAAI,CAACL,SAAS,CAACC,IAAI,EAAEC,cAAc,CAAC,CAACN,aAAa,CACvD,MAAOK,IAAI,CAACK,GAAG,KAAKC,SAAS,GAAG,IAAAC,eAAQ,EAACP,IAAI,CAACK,GAAG,CAAC,GAAG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AClC,OAAO,IAAI,CAACN,aAAa,CACvB,MAAM,IAAAY,eAAQ,EAACN,cAAc,CAAC,EAC9B,MAAMJ,gBAAQ,CAACuD,2BAA2B,CAAC,CAC7C,CAAC;EACH;AACF;AAEO,SAASC,YAAYA,CAACC,YAAmC,EAAE;EAChE,OAAO,IAAIlE,YAAY,CAACkE,YAAY,CAAC;AACvC;AAEA,SAAS5B,yBAAyBA,CAAC6B,KAAU,EAAE;EAC7C,OAAOA,KAAK,IAAI,IAAI,IAAK,IAAAhD,eAAQ,EAACgD,KAAK,CAAC,IAAIA,KAAK,CAAC3D,MAAM,GAAG,CAAE;AAC/D;AAEA,SAAS+B,kBAAkBA,CAAC4B,KAAU,EAAE;EACtC,OAAOA,KAAK,IAAI,IAAI,IAAI,IAAAC,gBAAS,EAACD,KAAK,CAAC;AAC1C;AAEA,SAASrB,oBAAoBA,CAACE,SAAc,EAAE;EAC5C,OACG,IAAA7B,eAAQ,EAAC6B,SAAS,CAAC,IAAIA,SAAS,KAAK,EAAE,IACvC,IAAAlC,eAAQ,EAACkC,SAAS,CAAC,IAAIA,SAAS,CAACqB,cAAc,CAAC,KAAK,CAAE;AAE5D;AAEA,SAAS1B,0BAA0BA,CAACK,SAAc,EAAE;EAClD,OACE,IAAA7B,eAAQ,EAAC6B,SAAS,CAAC,IAClB,IAAAlC,eAAQ,EAACkC,SAAS,CAAC,IAAIA,SAAS,CAACqB,cAAc,CAAC,KAAK,CAAE;AAE5D","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/external-types.d.ts"],"sourcesContent":["/// <reference types=\"@wix/yoshi-flow-library/types\" />\n"],"mappings":"AAAA"}
1
+ {"version":3,"names":[],"sources":["../../src/external-types.d.ts"],"sourcesContent":["/// <reference types=\"@wix/yoshi-flow-library/types\" />\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_typeUtils","filterTreeValidations","errors","messages","validateFilterOrThrow","tree","failures","validateFilterTree","length","validationError","join","path","isObject","objectType","collectedErrors","key","Object","keys","value","at","isArray","push","arrayType","flatMap","x","arrayLength","startsWith","validateOperatorOrValue","isComparableValue","some","op","validateOperator","operator","comparisonOperatorType","isString","stringOperatorType","isBoolean","every","setOperatorItems","ignoreCase","matchesOperatorIgnoreCase","spec","validSpec","type","invalid","find","undefined","matchesOperatorSpecItems","regexNotAllowed","isDate","isNumber","$date","prefix","next"],"sources":["../../../src/filter/FilterTree.ts"],"sourcesContent":["import { messages, validationError } from '../errors/errors'\nimport {\n isArray,\n isObject,\n isString,\n isDate,\n isNumber,\n isBoolean,\n} from '../utils/type-utils'\n\nexport type FilterTree =\n | FieldFilter\n | { $and?: FilterTree[] }\n | { $or?: FilterTree[] }\n | { $not?: FilterTree | [FilterTree] } // [FilterTree] is old format\n\nexport type FieldFilter = {\n // just value is equivalent $eq operator\n [field: string]: Operator | Value\n}\n\ntype DateValue = Date | { $date: string }\n\ntype ComparableValue = string | number | DateValue\n\ntype Value = any\n\nexport type Operator =\n | { $eq?: Value }\n | { $ne?: Value }\n | { $gt?: ComparableValue }\n | { $gte?: ComparableValue }\n | { $lt?: ComparableValue }\n | { $lte?: ComparableValue }\n | { $startsWith?: string }\n | { $endsWith?: string }\n | { $contains?: string }\n | { $exists?: boolean }\n | { $hasSome?: ComparableValue[] }\n | { $in?: ComparableValue[] }\n | { $hasAll?: ComparableValue[] }\n | {\n $matches?: {\n specs: {\n type: 'literal' | 'anyOf'\n value: string\n }[]\n ignoreCase: true\n }\n }\n | { $not?: Operator }\n\nconst { filterTreeValidations: errors } = messages\n\nexport function validateFilterOrThrow(tree: unknown): tree is FilterTree {\n const failures = validateFilterTree(tree)\n if (failures.length === 0) {\n return true\n }\n throw validationError(`Invalid filter:${failures.join('\\n')}`)\n}\n\nexport function validateFilterTree(tree: unknown, path?: string): string[] {\n if (!isObject(tree)) {\n return [errors.objectType('Filter Model', tree)]\n }\n const collectedErrors = [] as string[]\n for (const key of Object.keys(tree)) {\n const value = tree[key]\n const at = join(path, key)\n switch (key) {\n case '$and':\n case '$or':\n if (!isArray(value)) {\n collectedErrors.push(errors.arrayType(at, value))\n }\n if (isArray(value)) {\n collectedErrors.push(\n ...value.flatMap((x) => validateFilterTree(x, at))\n )\n }\n break\n case '$not':\n if (!isArray(value)) {\n collectedErrors.push(...validateFilterTree(value, at))\n }\n if (isArray(value) && value.length !== 1) {\n collectedErrors.push(errors.arrayLength(at, 1, value))\n }\n if (isArray(value) && value.length > 0) {\n collectedErrors.push(...validateFilterTree(value[0], at))\n }\n break\n default:\n if (key.startsWith('$')) {\n collectedErrors.push(`Unexpected operator ${at}`)\n } else {\n collectedErrors.push(...validateOperatorOrValue(value, at))\n }\n }\n }\n return collectedErrors\n}\n\nfunction validateOperatorOrValue(value: unknown, path: string): string[] {\n if (\n isObject(value) &&\n !isComparableValue(value) &&\n Object.keys(value).some((op) => op.startsWith('$'))\n ) {\n return validateOperator(value, path)\n }\n return []\n}\n\nfunction validateOperator(operator: unknown, path: string): string[] {\n if (!isObject(operator)) {\n return [errors.objectType(path, operator)]\n }\n const collectedErrors = [] as string[]\n for (const key of Object.keys(operator)) {\n const at = join(path, key)\n const value = operator[key]\n switch (key) {\n case '$eq':\n case '$ne':\n break\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n if (!isComparableValue(value)) {\n collectedErrors.push(errors.comparisonOperatorType(at, value))\n }\n break\n case '$startsWith':\n case '$endsWith':\n case '$contains':\n if (!isString(value)) {\n collectedErrors.push(errors.stringOperatorType(at, value))\n }\n break\n case '$exists':\n if (!isBoolean(value)) {\n collectedErrors.push(`${at} should be a Boolean`)\n }\n break\n case '$hasSome':\n case '$hasAll':\n case '$in':\n if (!isArray(value)) {\n collectedErrors.push(errors.arrayType(at, value))\n }\n if (isArray(value) && !value.every(isComparableValue)) {\n collectedErrors.push(errors.setOperatorItems(at, value))\n }\n break\n case '$matches':\n if (!isObject(value)) {\n collectedErrors.push(errors.objectType(at, value))\n }\n if (isObject(value) && value.ignoreCase !== true) {\n collectedErrors.push(errors.matchesOperatorIgnoreCase(value))\n }\n if (isObject(value) && !isArray(value.spec)) {\n collectedErrors.push(errors.arrayType(`${at}.spec`, value.spec))\n }\n if (isArray(value?.spec)) {\n const validSpec = (spec: any) => {\n if (!isObject(spec)) {\n return false\n }\n if (spec.type === 'anyOf' && spec.value === ' \\t\\n-') {\n return true\n }\n return spec.type === 'literal' && isString(spec.value)\n }\n const invalid = value.spec.find((x: any) => !validSpec(x))\n if (invalid !== undefined) {\n collectedErrors.push(errors.matchesOperatorSpecItems(invalid))\n }\n }\n break\n case '$regex':\n collectedErrors.push(errors.regexNotAllowed())\n break\n case '$not':\n collectedErrors.push(...validateOperator(value, at))\n break\n default:\n collectedErrors.push(`Unknown operator ${at}`)\n }\n }\n return collectedErrors\n}\n\nfunction isComparableValue(x: unknown): x is ComparableValue {\n if (isDate(x) || isString(x) || isNumber(x)) {\n return true\n }\n return isObject(x) && isString(x.$date) && Object.keys(x).length === 1\n}\n\nfunction join(prefix: string | undefined, next: string) {\n return prefix === undefined ? next : `${prefix}.${next}`\n}\n"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAayC;;AAsCzC,MAAM;EAAEE,qBAAqB,EAAEC;AAAO,CAAC,GAAGC,gBAAQ;AAE3C,SAASC,qBAAqBA,CAACC,IAAa,EAAsB;EACvE,MAAMC,QAAQ,GAAGC,kBAAkB,CAACF,IAAI,CAAC;EACzC,IAAIC,QAAQ,CAACE,MAAM,KAAK,CAAC,EAAE;IACzB,OAAO,IAAI;EACb;EACA,MAAM,IAAAC,uBAAe,EAAE,kBAAiBH,QAAQ,CAACI,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;AAChE;AAEO,SAASH,kBAAkBA,CAACF,IAAa,EAAEM,IAAa,EAAY;EACzE,IAAI,CAAC,IAAAC,mBAAQ,EAACP,IAAI,CAAC,EAAE;IACnB,OAAO,C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iBAAM,EAACzB,CAAC,CAAC,IAAI,IAAAU,mBAAQ,EAACV,CAAC,CAAC,IAAI,IAAA0B,mBAAQ,EAAC1B,CAAC,CAAC,EAAE;IAC3C,OAAO,IAAI;EACb;EACA,OAAO,IAAAZ,mBAAQ,EAACY,CAAC,CAAC,IAAI,IAAAU,mBAAQ,EAACV,CAAC,CAAC2B,KAAK,CAAC,IAAInC,MAAM,CAACC,IAAI,CAACO,CAAC,CAAC,CAAChB,MAAM,KAAK,CAAC;AACxE;AAEA,SAASE,IAAIA,CAAC0C,MAA0B,EAAEC,IAAY,EAAE;EACtD,OAAOD,MAAM,KAAKN,SAAS,GAAGO,IAAI,GAAI,GAAED,MAAO,IAAGC,IAAK,EAAC;AAC1D"}
1
+ {"version":3,"names":["_errors","require","_typeUtils","filterTreeValidations","errors","messages","validateFilterOrThrow","tree","failures","validateFilterTree","length","validationError","join","path","isObject","objectType","collectedErrors","key","Object","keys","value","at","isArray","push","arrayType","flatMap","x","arrayLength","startsWith","validateOperatorOrValue","isComparableValue","some","op","validateOperator","operator","comparisonOperatorType","isString","stringOperatorType","isBoolean","every","setOperatorItems","ignoreCase","matchesOperatorIgnoreCase","spec","validSpec","type","invalid","find","undefined","matchesOperatorSpecItems","regexNotAllowed","isDate","isNumber","$date","prefix","next"],"sources":["../../../src/filter/FilterTree.ts"],"sourcesContent":["import { messages, validationError } from '../errors/errors'\nimport {\n isArray,\n isObject,\n isString,\n isDate,\n isNumber,\n isBoolean,\n} from '../utils/type-utils'\n\nexport type FilterTree =\n | FieldFilter\n | { $and?: FilterTree[] }\n | { $or?: FilterTree[] }\n | { $not?: FilterTree | [FilterTree] } // [FilterTree] is old format\n\nexport type FieldFilter = {\n // just value is equivalent $eq operator\n [field: string]: Operator | Value\n}\n\ntype DateValue = Date | { $date: string }\n\ntype ComparableValue = string | number | DateValue\n\ntype Value = any\n\nexport type Operator =\n | { $eq?: Value }\n | { $ne?: Value }\n | { $gt?: ComparableValue }\n | { $gte?: ComparableValue }\n | { $lt?: ComparableValue }\n | { $lte?: ComparableValue }\n | { $startsWith?: string }\n | { $endsWith?: string }\n | { $contains?: string }\n | { $exists?: boolean }\n | { $hasSome?: ComparableValue[] }\n | { $in?: ComparableValue[] }\n | { $hasAll?: ComparableValue[] }\n | {\n $matches?: {\n specs: {\n type: 'literal' | 'anyOf'\n value: string\n }[]\n ignoreCase: true\n }\n }\n | { $not?: Operator }\n\nconst { filterTreeValidations: errors } = messages\n\nexport function validateFilterOrThrow(tree: unknown): tree is FilterTree {\n const failures = validateFilterTree(tree)\n if (failures.length === 0) {\n return true\n }\n throw validationError(`Invalid filter:${failures.join('\\n')}`)\n}\n\nexport function validateFilterTree(tree: unknown, path?: string): string[] {\n if (!isObject(tree)) {\n return [errors.objectType('Filter Model', tree)]\n }\n const collectedErrors = [] as string[]\n for (const key of Object.keys(tree)) {\n const value = tree[key]\n const at = join(path, key)\n switch (key) {\n case '$and':\n case '$or':\n if (!isArray(value)) {\n collectedErrors.push(errors.arrayType(at, value))\n }\n if (isArray(value)) {\n collectedErrors.push(\n ...value.flatMap((x) => validateFilterTree(x, at))\n )\n }\n break\n case '$not':\n if (!isArray(value)) {\n collectedErrors.push(...validateFilterTree(value, at))\n }\n if (isArray(value) && value.length !== 1) {\n collectedErrors.push(errors.arrayLength(at, 1, value))\n }\n if (isArray(value) && value.length > 0) {\n collectedErrors.push(...validateFilterTree(value[0], at))\n }\n break\n default:\n if (key.startsWith('$')) {\n collectedErrors.push(`Unexpected operator ${at}`)\n } else {\n collectedErrors.push(...validateOperatorOrValue(value, at))\n }\n }\n }\n return collectedErrors\n}\n\nfunction validateOperatorOrValue(value: unknown, path: string): string[] {\n if (\n isObject(value) &&\n !isComparableValue(value) &&\n Object.keys(value).some((op) => op.startsWith('$'))\n ) {\n return validateOperator(value, path)\n }\n return []\n}\n\nfunction validateOperator(operator: unknown, path: string): string[] {\n if (!isObject(operator)) {\n return [errors.objectType(path, operator)]\n }\n const collectedErrors = [] as string[]\n for (const key of Object.keys(operator)) {\n const at = join(path, key)\n const value = operator[key]\n switch (key) {\n case '$eq':\n case '$ne':\n break\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n if (!isComparableValue(value)) {\n collectedErrors.push(errors.comparisonOperatorType(at, value))\n }\n break\n case '$startsWith':\n case '$endsWith':\n case '$contains':\n if (!isString(value)) {\n collectedErrors.push(errors.stringOperatorType(at, value))\n }\n break\n case '$exists':\n if (!isBoolean(value)) {\n collectedErrors.push(`${at} should be a Boolean`)\n }\n break\n case '$hasSome':\n case '$hasAll':\n case '$in':\n if (!isArray(value)) {\n collectedErrors.push(errors.arrayType(at, value))\n }\n if (isArray(value) && !value.every(isComparableValue)) {\n collectedErrors.push(errors.setOperatorItems(at, value))\n }\n break\n case '$matches':\n if (!isObject(value)) {\n collectedErrors.push(errors.objectType(at, value))\n }\n if (isObject(value) && value.ignoreCase !== true) {\n collectedErrors.push(errors.matchesOperatorIgnoreCase(value))\n }\n if (isObject(value) && !isArray(value.spec)) {\n collectedErrors.push(errors.arrayType(`${at}.spec`, value.spec))\n }\n if (isArray(value?.spec)) {\n const validSpec = (spec: any) => {\n if (!isObject(spec)) {\n return false\n }\n if (spec.type === 'anyOf' && spec.value === ' \\t\\n-') {\n return true\n }\n return spec.type === 'literal' && isString(spec.value)\n }\n const invalid = value.spec.find((x: any) => !validSpec(x))\n if (invalid !== undefined) {\n collectedErrors.push(errors.matchesOperatorSpecItems(invalid))\n }\n }\n break\n case '$regex':\n collectedErrors.push(errors.regexNotAllowed())\n break\n case '$not':\n collectedErrors.push(...validateOperator(value, at))\n break\n default:\n collectedErrors.push(`Unknown operator ${at}`)\n }\n }\n return collectedErrors\n}\n\nfunction isComparableValue(x: unknown): x is ComparableValue {\n if (isDate(x) || isString(x) || isNumber(x)) {\n return true\n }\n return isObject(x) && isString(x.$date) && Object.keys(x).length === 1\n}\n\nfunction join(prefix: string | undefined, next: string) {\n return prefix === undefined ? next : `${prefix}.${next}`\n}\n"],"mappings":";;;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,CAAClB,CAAC,CAAC,CAAC;UAC1D,IAAIoB,OAAO,KAAKE,SAAS,EAAE;YACzBhC,eAAe,CAACO,IAAI,CAACnB,MAAM,CAAC6C,wBAAwB,CAACH,OAAO,CAAC,CAAC;UAChE;QACF;QACA;MACF,KAAK,QAAQ;QACX9B,eAAe,CAACO,IAAI,CAACnB,MAAM,CAAC8C,eAAe,CAAC,CAAC,CAAC;QAC9C;MACF,KAAK,MAAM;QACTlC,eAAe,CAACO,IAAI,CAAC,GAAGU,gBAAgB,CAACb,KAAK,EAAEC,EAAE,CAAC,CAAC;QACpD;MACF;QACEL,eAAe,CAACO,IAAI,CAAC,oBAAoBF,EAAE,EAAE,CAAC;IAClD;EACF;EACA,OAAOL,eAAe;AACxB;AAEA,SAASc,iBAAiBA,CAACJ,CAAU,EAAwB;EAC3D,IAAI,IAAAyB,iBAAM,EAACzB,CAAC,CAAC,IAAI,IAAAU,mBAAQ,EAACV,CAAC,CAAC,IAAI,IAAA0B,mBAAQ,EAAC1B,CAAC,CAAC,EAAE;IAC3C,OAAO,IAAI;EACb;EACA,OAAO,IAAAZ,mBAAQ,EAACY,CAAC,CAAC,IAAI,IAAAU,mBAAQ,EAACV,CAAC,CAAC2B,KAAK,CAAC,IAAInC,MAAM,CAACC,IAAI,CAACO,CAAC,CAAC,CAAChB,MAAM,KAAK,CAAC;AACxE;AAEA,SAASE,IAAIA,CAAC0C,MAA0B,EAAEC,IAAY,EAAE;EACtD,OAAOD,MAAM,KAAKN,SAAS,GAAGO,IAAI,GAAG,GAAGD,MAAM,IAAIC,IAAI,EAAE;AAC1D","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/filter/WithFilter.ts"],"sourcesContent":["type Comparable = string | number | Date\n\n/**\n * Type that allow filter construction.\n * All construction methods return copy of self\n */\nexport default interface WithFilter<Self extends WithFilter<Self>> {\n /**\n * Filter JSON, possibly invalid\n * @internal\n */\n readonly filterTree: Record<string, any>\n\n /**\n * Validation errors, if empty filterTree is valid\n * @internal\n */\n readonly invalidArguments: string[]\n\n /**\n * Refines a query or filter to match items whose specified property value equals the specified value.\n *\n * The `eq()` function refines this filter to only\n * match items where the value of the specified property equals the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * Matching strings with `eq()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If `field` points to a collection field of type Array, `eq()` includes the item\n * as long as at least one Array element matches the specified `value`.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n eq(field: string, value: any): Self\n\n /**\n * Refines a query or filter to match items whose specified property value does not equal the specified value.\n *\n * The `ne()` function refines this filter to only\n * match items where the value of the specified property does not equal the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type is considered not equal to the same number stored as a Number type.\n *\n * Matching strings with `ne()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the `field` property is an Array, `ne()` includes items\n * in which none of the elements of the Array match the specified `value`.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n ne(field: string, value: any): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is greater than or equal to the specified\n * value.\n *\n * The `ge()` function refines this filter to only\n * match items where the value of the specified property is greater than or\n * equal to the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically,\n * so `\"abc\"` is greater than or equal to `\"ABC\"` (because of the greater than),\n * but `\"ABC\"` is not greater than or equal to `\"abc\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n ge(field: string, value: Comparable): Self\n\n /**\n * Alias for `ge()`\n * @internal\n */\n gte(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is greater than the specified value.\n *\n * The `gt()` function refines this filter to only match\n * items where the value of the specified property is greater than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"text\"` is greater than `\"Text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object with the query definition, based on the supplied parameters.\n */\n gt(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is less than or equal to the specified\n * value.\n *\n * The `le()` function refines this filter to only match\n * items where the value of the specified property is less than or equal to the\n * specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically,\n * so `\"ABC\"` is less than or equal to `\"abc\"` (because of the less than),\n * but `\"abc\"` is not less than or equal to `\"ABC\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n le(field: string, value: Comparable): Self\n\n /**\n * Alias for `le()`\n * @internal\n */\n lte(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is less than the specified value.\n *\n * The `lt()` function refines this filter to only match\n * items where the value of the specified property is less than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"Text\"` is less than `\"text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object with the query definition, based on the supplied parameters.\n */\n lt(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property has any value.\n *\n * The `isNotEmpty()` function refines this filter to only match items where the\n * value of the specified property is not `null` or `undefined`.\n *\n * If the property contains any value at all for a given item, including the\n * empty string or an invalid value, that item will match the query.\n * @public\n * @documentationMaturity preview\n * @param field - The property in which to check for a value.\n * @requiredField field\n * @returns An object representing the refined query.\n */\n isNotEmpty(field: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property does not exist or does not have any value.\n *\n * The `isEmpty()` function refines this filter to only match items where the\n * value of the specified property is `null` or `undefined` or the property does\n * not exist.\n *\n * If the property contains any value at all for a given item, including the\n * empty string or an invalid value, that item will match the query.\n * @public\n * @documentationMaturity preview\n * @param field - The property in which to check for a value.\n * @requiredField field\n * @returns An object representing the refined query.\n */\n isEmpty(field: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value starts with a specified string.\n *\n * The `startsWith()` function refines this filter to\n * only match items where the value of the specified property starts with the\n * defined `string`. Matching with `startsWith()` is not case sensitive, so `\"TEXT\"` starts\n * with `\"tex\"`.\n *\n * You can only use `startsWith()` with a property whose value is a String or Reference.\n * When using a Reference, `startsWith()` matches by the ID of the referenced item as Strings.\n * @public\n * @documentationMaturity preview\n * @param field - Property whose value will be compared with the `value` parameter.\n * @requiredField field\n * @param value - String to look for at the beginning of the specified property value.\n * @requiredField value\n * @returns `WixDataQuery` object representing the refined query.\n */\n startsWith(field: string, value: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value ends with a specified string.\n *\n * The `endsWith()` function refines this filter to only\n * match items where the value of the specified property ends with the specified\n * `string`. Matching with `endsWith()` is not case sensitive, so `\"TEXT\"` ends\n * with `\"ext\"`.\n *\n * You can only use `endsWith()` with a property whose value is a String or Reference.\n * When using a Reference, `endsWith()` matches by the ID of the referenced item as Strings.\n * @public\n * @documentationMaturity preview\n * @param field - Property whose value will be compared with the string.\n * @requiredField field\n * @param value - String to look for at the end of the specified property value.\n * @requiredField value\n * @returns `WixDataQuery` object representing the refined query.\n */\n endsWith(field: string, value: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value contains a specified string.\n *\n * The `contains()` function refines this filter to\n * only match items where the value of the specified property contains the\n * specified `string`. Matching with `contains()` is not case sensitive, so\n * `\"text\"` does contain `\"Tex\"`.\n *\n * You can use `contains()` with a property whose value is a String or a Reference.\n * For properties of type reference it is recommended that you use the [`eq()`](#eq)\n * function instead of `contains()`. With properties that are References, `contains()`\n * matches by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with the string.\n * @requiredField field\n * @param value - The string to look for inside the specified property value.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n contains(field: string, value: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value equals any of the specified `values`\n * parameters.\n *\n * The `hasSome()` function refines this filter to\n * only match items where the value of the specified property equals any of\n * the specified values.\n *\n * Matching strings with `hasSome()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the specified property is an array, `hasSome()` will match\n * if any of the elements of that array match any of the specified values.\n *\n * If the specified property contains multiple references, pass item IDs in the\n * `value` property. In such a case, `hasSome()` will match if any of the\n * multiple references match any of the specified ID values.\n *\n * You can specify a list of values to match by providing an array of\n * String, Number, or Date types as the `value` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param values - The values to match against.\n * @requiredField values\n * @returns An object representing the refined query.\n */\n hasSome(field: string, ...values: Comparable[]): Self\n\n /**\n * Overload for `hasSome()`\n * @public\n * @documentationMaturity preview\n */\n hasSome(field: string, values: Comparable[]): Self\n\n /**\n * Alias for `hasSome()`\n * @internal\n */\n in(field: string, ...values: Comparable[]): Self\n\n /**\n * Alias for `hasSome()`\n * @internal\n */\n in(field: string, values: Comparable[]): Self\n\n /**\n * Refines a query or filter to match items whose specified property values equals all of the specified `value`\n * parameters.\n *\n * The `hasAll()` function refines this filter to\n * only match items where the value of the specified property equals all of\n * the specified values.\n *\n * Matching strings with `hasAll()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the specified property is an array, `hasAll()` will match\n * if there is a match in the elements of that array for all of the specified\n * values.\n *\n * You can specify a list of values to match by providing an array of\n * String, Number, or Date types as the `value` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param values - The values to match against.\n * @requiredField values\n * @returns An object representing the refined query.\n */\n hasAll(field: string, ...values: Comparable[]): Self\n\n /**\n * Overload for `hasAll()`\n * @public\n * @documentationMaturity preview\n */\n hasAll(field: string, values: Comparable[]): Self\n\n /**\n * Exists filter.\n * @returns `current $and (field $exists value)`\n * @internal\n */\n exists(field: string, value: boolean): Self\n\n /**\n * Adds an `or` condition to the query or filter.\n *\n * The `or()` function adds an inclusive `or` condition to this filter. A query or filter\n * with an `or` returns all the items that match the query or filter as defined up to\n * the `or` function, the items that match the query or filter passed to the `or`\n * function, and the items that match both.\n *\n * The collections used by both the initial query and the query passed\n * to the `or` function must be the same.\n *\n * The 'or()' function is designed to work with 2 or more queries or filters.\n * If you use it on its own, it will return all the items in a collection.\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as an `or` condition.\n * @requiredField filter\n * @returns Object representing the refined query.\n */\n or(filter: WithFilter<any>): Self\n\n /**\n * Adds an `and` condition to the query or filter.\n *\n * The `and()` function adds an and condition to this query. A query or filter with an `and` returns all the items\n * that match the query or filter as defined up to the `and` function and also match the query or filter passed to\n * the `and` function.\n *\n * Note that when chaining multiple `WixDataFilter` functions to a query an and condition is assumed. In such cases,\n * you do not need to add a call to the `and()` function. For example, this query returns results where status is\n * active **and** age is greater than 25.\n * ```js\n * wixData.query(\"myCollection\").eq(\"status\", \"active\").gt(\"age\", 25);\n * ```\n *\n * The `and()` function is needed when performing compound queries. For example, the final query in this set of\n * queries returns results where status is either pending or rejected **and** age is either less than 25 or greater\n * than 65.\n * ```js\n * let statusQuery = wixData\n * .query(\"myCollection\")\n * .eq(\"status\", \"pending\")\n * .or(wixData.query(\"myCollection\").eq(\"status\", \"rejected\"));\n *\n * let ageQuery = wixData\n * .query(\"myCollection\")\n * .lt(\"age\", 25)\n * .or(wixData.query(\"myCollection\").gt(\"age\", 65));\n *\n * let statusAndAgeQuery = statusQuery.and(ageQuery);\n * ```\n *\n * The collections referenced by both the initial query and the query passed to the `and` function must be the same.\n *\n * The `and()` function is designed to work with 2 or more queries or filters. If you use it on its own, it will\n * return all the items in a collection.\n * @public\n * @documentationMaturity preview\n * @param filter - A filter to add to the initial query as an `and` condition.\n * @requiredField filter\n * @returns An object representing the refined query.\n */\n and(filter: WithFilter<any>): Self\n\n /**\n * Adds a `not` condition to the query or filter.\n *\n * The `not()` function adds a `not` condition to this filter. A query or filter with a `not`\n * returns all the items that match the query or filter as defined up to the `not`\n * function, but don't match the query or filter passed to the `not` function.\n *\n * If the query or filter only contains a `not()` function, it returns all the items\n * that don't match the query defined by the `not` method.\n *\n * The collections referenced by both the initial query and the query passed\n * to the `not` function must be the same.\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as a `not` condition.\n * @requiredField filter\n * @returns Object representing the refined query.\n */\n not(filter: WithFilter<any>): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is within a specified range.\n *\n * The `between()` function refines this query to only match items where the value of the specified property is\n * greater than or equal to `rangeStart` and less than `rangeEnd`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the\n * same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared alphabetically and not numerically. Items\n * that do not have a value for the specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so\n * - `\"A\"` and `\"M\"` are between `\"A\"` and `\"Z\"`, but `\"a\"`, `\"m\"`, `\"z\"` and `\"Z\"` are not.\n * - `\"A\"`, `\"M\"`, `\"Z\"`, and `\"a\"` are between `\"A\"` and `\"z\"`, but `\"z\"` is not.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with rangeStart and rangeEnd.\n * @requiredField field\n * @param rangeStart - The beginning value of the range to match against.\n * @requiredField rangeStart\n * @param rangeEnd - The ending value of the range to match against.\n * @requiredField rangeEnd\n * @returns An object representing the refined query.\n */\n between<T extends Comparable>(field: string, rangeStart: T, rangeEnd: T): Self\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["../../../src/filter/WithFilter.ts"],"sourcesContent":["type Comparable = string | number | Date\n\n/**\n * Type that allow filter construction.\n * All construction methods return copy of self\n */\nexport default interface WithFilter<Self extends WithFilter<Self>> {\n /**\n * Filter JSON, possibly invalid\n * @internal\n */\n readonly filterTree: Record<string, any>\n\n /**\n * Validation errors, if empty filterTree is valid\n * @internal\n */\n readonly invalidArguments: string[]\n\n /**\n * Refines a query or filter to match items whose specified property value equals the specified value.\n *\n * The `eq()` function refines this filter to only\n * match items where the value of the specified property equals the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * Matching strings with `eq()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If `field` points to a collection field of type Array, `eq()` includes the item\n * as long as at least one Array element matches the specified `value`.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n eq(field: string, value: any): Self\n\n /**\n * Refines a query or filter to match items whose specified property value does not equal the specified value.\n *\n * The `ne()` function refines this filter to only\n * match items where the value of the specified property does not equal the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type is considered not equal to the same number stored as a Number type.\n *\n * Matching strings with `ne()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the `field` property is an Array, `ne()` includes items\n * in which none of the elements of the Array match the specified `value`.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n ne(field: string, value: any): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is greater than or equal to the specified\n * value.\n *\n * The `ge()` function refines this filter to only\n * match items where the value of the specified property is greater than or\n * equal to the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically,\n * so `\"abc\"` is greater than or equal to `\"ABC\"` (because of the greater than),\n * but `\"ABC\"` is not greater than or equal to `\"abc\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n ge(field: string, value: Comparable): Self\n\n /**\n * Alias for `ge()`\n * @internal\n */\n gte(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is greater than the specified value.\n *\n * The `gt()` function refines this filter to only match\n * items where the value of the specified property is greater than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"text\"` is greater than `\"Text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object with the query definition, based on the supplied parameters.\n */\n gt(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is less than or equal to the specified\n * value.\n *\n * The `le()` function refines this filter to only match\n * items where the value of the specified property is less than or equal to the\n * specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically,\n * so `\"ABC\"` is less than or equal to `\"abc\"` (because of the less than),\n * but `\"abc\"` is not less than or equal to `\"ABC\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n le(field: string, value: Comparable): Self\n\n /**\n * Alias for `le()`\n * @internal\n */\n lte(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is less than the specified value.\n *\n * The `lt()` function refines this filter to only match\n * items where the value of the specified property is less than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"Text\"` is less than `\"text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param value - The value to match against.\n * @requiredField value\n * @returns An object with the query definition, based on the supplied parameters.\n */\n lt(field: string, value: Comparable): Self\n\n /**\n * Refines a query or filter to match items whose specified property has any value.\n *\n * The `isNotEmpty()` function refines this filter to only match items where the\n * value of the specified property is not `null` or `undefined`.\n *\n * If the property contains any value at all for a given item, including the\n * empty string or an invalid value, that item will match the query.\n * @public\n * @documentationMaturity preview\n * @param field - The property in which to check for a value.\n * @requiredField field\n * @returns An object representing the refined query.\n */\n isNotEmpty(field: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property does not exist or does not have any value.\n *\n * The `isEmpty()` function refines this filter to only match items where the\n * value of the specified property is `null` or `undefined` or the property does\n * not exist.\n *\n * If the property contains any value at all for a given item, including the\n * empty string or an invalid value, that item will match the query.\n * @public\n * @documentationMaturity preview\n * @param field - The property in which to check for a value.\n * @requiredField field\n * @returns An object representing the refined query.\n */\n isEmpty(field: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value starts with a specified string.\n *\n * The `startsWith()` function refines this filter to\n * only match items where the value of the specified property starts with the\n * defined `string`. Matching with `startsWith()` is not case sensitive, so `\"TEXT\"` starts\n * with `\"tex\"`.\n *\n * You can only use `startsWith()` with a property whose value is a String or Reference.\n * When using a Reference, `startsWith()` matches by the ID of the referenced item as Strings.\n * @public\n * @documentationMaturity preview\n * @param field - Property whose value will be compared with the `value` parameter.\n * @requiredField field\n * @param value - String to look for at the beginning of the specified property value.\n * @requiredField value\n * @returns `WixDataQuery` object representing the refined query.\n */\n startsWith(field: string, value: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value ends with a specified string.\n *\n * The `endsWith()` function refines this filter to only\n * match items where the value of the specified property ends with the specified\n * `string`. Matching with `endsWith()` is not case sensitive, so `\"TEXT\"` ends\n * with `\"ext\"`.\n *\n * You can only use `endsWith()` with a property whose value is a String or Reference.\n * When using a Reference, `endsWith()` matches by the ID of the referenced item as Strings.\n * @public\n * @documentationMaturity preview\n * @param field - Property whose value will be compared with the string.\n * @requiredField field\n * @param value - String to look for at the end of the specified property value.\n * @requiredField value\n * @returns `WixDataQuery` object representing the refined query.\n */\n endsWith(field: string, value: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value contains a specified string.\n *\n * The `contains()` function refines this filter to\n * only match items where the value of the specified property contains the\n * specified `string`. Matching with `contains()` is not case sensitive, so\n * `\"text\"` does contain `\"Tex\"`.\n *\n * You can use `contains()` with a property whose value is a String or a Reference.\n * For properties of type reference it is recommended that you use the [`eq()`](#eq)\n * function instead of `contains()`. With properties that are References, `contains()`\n * matches by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with the string.\n * @requiredField field\n * @param value - The string to look for inside the specified property value.\n * @requiredField value\n * @returns An object representing the refined query.\n */\n contains(field: string, value: string): Self\n\n /**\n * Refines a query or filter to match items whose specified property value equals any of the specified `values`\n * parameters.\n *\n * The `hasSome()` function refines this filter to\n * only match items where the value of the specified property equals any of\n * the specified values.\n *\n * Matching strings with `hasSome()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the specified property is an array, `hasSome()` will match\n * if any of the elements of that array match any of the specified values.\n *\n * If the specified property contains multiple references, pass item IDs in the\n * `value` property. In such a case, `hasSome()` will match if any of the\n * multiple references match any of the specified ID values.\n *\n * You can specify a list of values to match by providing an array of\n * String, Number, or Date types as the `value` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param values - The values to match against.\n * @requiredField values\n * @returns An object representing the refined query.\n */\n hasSome(field: string, ...values: Comparable[]): Self\n\n /**\n * Overload for `hasSome()`\n * @public\n * @documentationMaturity preview\n */\n hasSome(field: string, values: Comparable[]): Self\n\n /**\n * Alias for `hasSome()`\n * @internal\n */\n in(field: string, ...values: Comparable[]): Self\n\n /**\n * Alias for `hasSome()`\n * @internal\n */\n in(field: string, values: Comparable[]): Self\n\n /**\n * Refines a query or filter to match items whose specified property values equals all of the specified `value`\n * parameters.\n *\n * The `hasAll()` function refines this filter to\n * only match items where the value of the specified property equals all of\n * the specified values.\n *\n * Matching strings with `hasAll()` is case sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the specified property is an array, `hasAll()` will match\n * if there is a match in the elements of that array for all of the specified\n * values.\n *\n * You can specify a list of values to match by providing an array of\n * String, Number, or Date types as the `value` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with `value`.\n * @requiredField field\n * @param values - The values to match against.\n * @requiredField values\n * @returns An object representing the refined query.\n */\n hasAll(field: string, ...values: Comparable[]): Self\n\n /**\n * Overload for `hasAll()`\n * @public\n * @documentationMaturity preview\n */\n hasAll(field: string, values: Comparable[]): Self\n\n /**\n * Exists filter.\n * @returns `current $and (field $exists value)`\n * @internal\n */\n exists(field: string, value: boolean): Self\n\n /**\n * Adds an `or` condition to the query or filter.\n *\n * The `or()` function adds an inclusive `or` condition to this filter. A query or filter\n * with an `or` returns all the items that match the query or filter as defined up to\n * the `or` function, the items that match the query or filter passed to the `or`\n * function, and the items that match both.\n *\n * The collections used by both the initial query and the query passed\n * to the `or` function must be the same.\n *\n * The 'or()' function is designed to work with 2 or more queries or filters.\n * If you use it on its own, it will return all the items in a collection.\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as an `or` condition.\n * @requiredField filter\n * @returns Object representing the refined query.\n */\n or(filter: WithFilter<any>): Self\n\n /**\n * Adds an `and` condition to the query or filter.\n *\n * The `and()` function adds an and condition to this query. A query or filter with an `and` returns all the items\n * that match the query or filter as defined up to the `and` function and also match the query or filter passed to\n * the `and` function.\n *\n * Note that when chaining multiple `WixDataFilter` functions to a query an and condition is assumed. In such cases,\n * you do not need to add a call to the `and()` function. For example, this query returns results where status is\n * active **and** age is greater than 25.\n * ```js\n * wixData.query(\"myCollection\").eq(\"status\", \"active\").gt(\"age\", 25);\n * ```\n *\n * The `and()` function is needed when performing compound queries. For example, the final query in this set of\n * queries returns results where status is either pending or rejected **and** age is either less than 25 or greater\n * than 65.\n * ```js\n * let statusQuery = wixData\n * .query(\"myCollection\")\n * .eq(\"status\", \"pending\")\n * .or(wixData.query(\"myCollection\").eq(\"status\", \"rejected\"));\n *\n * let ageQuery = wixData\n * .query(\"myCollection\")\n * .lt(\"age\", 25)\n * .or(wixData.query(\"myCollection\").gt(\"age\", 65));\n *\n * let statusAndAgeQuery = statusQuery.and(ageQuery);\n * ```\n *\n * The collections referenced by both the initial query and the query passed to the `and` function must be the same.\n *\n * The `and()` function is designed to work with 2 or more queries or filters. If you use it on its own, it will\n * return all the items in a collection.\n * @public\n * @documentationMaturity preview\n * @param filter - A filter to add to the initial query as an `and` condition.\n * @requiredField filter\n * @returns An object representing the refined query.\n */\n and(filter: WithFilter<any>): Self\n\n /**\n * Adds a `not` condition to the query or filter.\n *\n * The `not()` function adds a `not` condition to this filter. A query or filter with a `not`\n * returns all the items that match the query or filter as defined up to the `not`\n * function, but don't match the query or filter passed to the `not` function.\n *\n * If the query or filter only contains a `not()` function, it returns all the items\n * that don't match the query defined by the `not` method.\n *\n * The collections referenced by both the initial query and the query passed\n * to the `not` function must be the same.\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as a `not` condition.\n * @requiredField filter\n * @returns Object representing the refined query.\n */\n not(filter: WithFilter<any>): Self\n\n /**\n * Refines a query or filter to match items whose specified property value is within a specified range.\n *\n * The `between()` function refines this query to only match items where the value of the specified property is\n * greater than or equal to `rangeStart` and less than `rangeEnd`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the\n * same number stored as a Number type.\n *\n * If a property contains a number as a String, that value will be compared alphabetically and not numerically. Items\n * that do not have a value for the specified property are ranked lowest.\n *\n * The following types of properties can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so\n * - `\"A\"` and `\"M\"` are between `\"A\"` and `\"Z\"`, but `\"a\"`, `\"m\"`, `\"z\"` and `\"Z\"` are not.\n * - `\"A\"`, `\"M\"`, `\"Z\"`, and `\"a\"` are between `\"A\"` and `\"z\"`, but `\"z\"` is not.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared with rangeStart and rangeEnd.\n * @requiredField field\n * @param rangeStart - The beginning value of the range to match against.\n * @requiredField rangeStart\n * @param rangeEnd - The ending value of the range to match against.\n * @requiredField rangeEnd\n * @returns An object representing the refined query.\n */\n between<T extends Comparable>(field: string, rangeStart: T, rangeEnd: T): Self\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_filterMixin","_interopRequireDefault","require","FilterBuilder","filterMixin","constructorName","_build","getFilterModel","exports","PlatformizedFilterBuilder","in","args","_AndSetOperand","exists","_binaryAnd","gte","field","value","ge","lte","le","build","hasAnyFilter","_this$filterTree","filterTree","undefined","Object","keys","every","x","$and","length","platformizedFilterBuilder","options","filterBuilderFactory","_default","default"],"sources":["../../../src/filter/filterBuilder.ts"],"sourcesContent":["import filterMixin from './filterMixin'\nimport WithFilter from './WithFilter'\n\nexport class FilterBuilder extends filterMixin() {\n get constructorName() {\n return 'FilterBuilder'\n }\n\n _build() {\n return this.getFilterModel()\n }\n}\n\nexport class PlatformizedFilterBuilder\n extends filterMixin()\n implements WithFilter<PlatformizedFilterBuilder>\n{\n in(...args: any[]) {\n return this._AndSetOperand('$in', '.in', args)\n }\n\n exists(...args: any[]) {\n return this._binaryAnd('$exists', '.exists', args)\n }\n\n gte(field: any, value: any) {\n return this.ge(field, value)\n }\n\n lte(field: any, value: any) {\n return this.le(field, value)\n }\n\n build() {\n return this.getFilterModel()\n }\n\n hasAnyFilter(): boolean {\n if (this.filterTree === null || this.filterTree === undefined) {\n return false\n }\n if (!Object.keys(this.filterTree).every((x) => x === '$and')) {\n return false\n }\n return (this.filterTree?.$and?.length ?? 0) > 0\n }\n}\n\nexport function platformizedFilterBuilder(options = {}) {\n return new PlatformizedFilterBuilder(options)\n}\n\nexport function filterBuilderFactory() {\n return new FilterBuilder({})\n}\n\nexport default filterBuilderFactory\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGO,MAAMC,aAAa,SAAS,IAAAC,oBAAW,EAAC,CAAC,CAAC;EAC/C,IAAIC,eAAeA,CAAA,EAAG;IACpB,OAAO,eAAe;EACxB;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI,CAACC,cAAc,CAAC,CAAC;EAC9B;AACF;AAACC,OAAA,CAAAL,aAAA,GAAAA,aAAA;AAEM,MAAMM,yBAAyB,SAC5B,IAAAL,oBAAW,EAAC,CAAC,CAEvB;EACEM,EAAEA,CAAC,GAAGC,IAAW,EAAE;IACjB,OAAO,IAAI,CAACC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAED,IAAI,CAAC;EAChD;EAEAE,MAAMA,CAAC,GAAGF,IAAW,EAAE;IACrB,OAAO,IAAI,CAACG,UAAU,CAAC,SAAS,EAAE,SAAS,EAAEH,IAAI,CAAC;EACpD;EAEAI,GAAGA,CAACC,KAAU,EAAEC,KAAU,EAAE;IAC1B,OAAO,IAAI,CAACC,EAAE,CAACF,KAAK,EAAEC,KAAK,CAAC;EAC9B;EAEAE,GAAGA,CAACH,KAAU,EAAEC,KAAU,EAAE;IAC1B,OAAO,IAAI,CAACG,EAAE,CAACJ,KAAK,EAAEC,KAAK,CAAC;EAC9B;EAEAI,KAAKA,CAAA,EAAG;IACN,OAAO,IAAI,CAACd,cAAc,CAAC,CAAC;EAC9B;EAEAe,YAAYA,CAAA,EAAY;IAAA,IAAAC,gBAAA;IACtB,IAAI,IAAI,CAACC,UAAU,KAAK,IAAI,IAAI,IAAI,CAACA,UAAU,KAAKC,SAAS,EAAE;MAC7D,OAAO,KAAK;IACd;IACA,IAAI,CAACC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACH,UAAU,CAAC,CAACI,KAAK,CAAEC,CAAC,IAAKA,CAAC,KAAK,MAAM,CAAC,EAAE;MAC5D,OAAO,KAAK;IACd;IACA,OAAO,CAAC,EAAAN,gBAAA,OAAI,CAACC,UAAU,cAAAD,gBAAA,GAAfA,gBAAA,CAAiBO,IAAI,qBAArBP,gBAAA,CAAuBQ,MAAM,KAAI,CAAC,IAAI,CAAC;EACjD;AACF;AAACvB,OAAA,CAAAC,yBAAA,GAAAA,yBAAA;AAEM,SAASuB,yBAAyBA,CAACC,OAAO,GAAG,CAAC,CAAC,EAAE;EACtD,OAAO,IAAIxB,yBAAyB,CAACwB,OAAO,CAAC;AAC/C;AAEO,SAASC,oBAAoBA,CAAA,EAAG;EACrC,OAAO,IAAI/B,aAAa,CAAC,CAAC,CAAC,CAAC;AAC9B;AAAC,IAAAgC,QAAA,GAAA3B,OAAA,CAAA4B,OAAA,GAEcF,oBAAoB"}
1
+ {"version":3,"names":["_filterMixin","_interopRequireDefault","require","FilterBuilder","filterMixin","constructorName","_build","getFilterModel","exports","PlatformizedFilterBuilder","in","args","_AndSetOperand","exists","_binaryAnd","gte","field","value","ge","lte","le","build","hasAnyFilter","_this$filterTree","filterTree","undefined","Object","keys","every","x","$and","length","platformizedFilterBuilder","options","filterBuilderFactory","_default","default"],"sources":["../../../src/filter/filterBuilder.ts"],"sourcesContent":["import filterMixin from './filterMixin'\nimport WithFilter from './WithFilter'\n\nexport class FilterBuilder extends filterMixin() {\n get constructorName() {\n return 'FilterBuilder'\n }\n\n _build() {\n return this.getFilterModel()\n }\n}\n\nexport class PlatformizedFilterBuilder\n extends filterMixin()\n implements WithFilter<PlatformizedFilterBuilder>\n{\n in(...args: any[]) {\n return this._AndSetOperand('$in', '.in', args)\n }\n\n exists(...args: any[]) {\n return this._binaryAnd('$exists', '.exists', args)\n }\n\n gte(field: any, value: any) {\n return this.ge(field, value)\n }\n\n lte(field: any, value: any) {\n return this.le(field, value)\n }\n\n build() {\n return this.getFilterModel()\n }\n\n hasAnyFilter(): boolean {\n if (this.filterTree === null || this.filterTree === undefined) {\n return false\n }\n if (!Object.keys(this.filterTree).every((x) => x === '$and')) {\n return false\n }\n return (this.filterTree?.$and?.length ?? 0) > 0\n }\n}\n\nexport function platformizedFilterBuilder(options = {}) {\n return new PlatformizedFilterBuilder(options)\n}\n\nexport function filterBuilderFactory() {\n return new FilterBuilder({})\n}\n\nexport default filterBuilderFactory\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGO,MAAMC,aAAa,SAAS,IAAAC,oBAAW,EAAC,CAAC,CAAC;EAC/C,IAAIC,eAAeA,CAAA,EAAG;IACpB,OAAO,eAAe;EACxB;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI,CAACC,cAAc,CAAC,CAAC;EAC9B;AACF;AAACC,OAAA,CAAAL,aAAA,GAAAA,aAAA;AAEM,MAAMM,yBAAyB,SAC5B,IAAAL,oBAAW,EAAC,CAAC,CAEvB;EACEM,EAAEA,CAAC,GAAGC,IAAW,EAAE;IACjB,OAAO,IAAI,CAACC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAED,IAAI,CAAC;EAChD;EAEAE,MAAMA,CAAC,GAAGF,IAAW,EAAE;IACrB,OAAO,IAAI,CAACG,UAAU,CAAC,SAAS,EAAE,SAAS,EAAEH,IAAI,CAAC;EACpD;EAEAI,GAAGA,CAACC,KAAU,EAAEC,KAAU,EAAE;IAC1B,OAAO,IAAI,CAACC,EAAE,CAACF,KAAK,EAAEC,KAAK,CAAC;EAC9B;EAEAE,GAAGA,CAACH,KAAU,EAAEC,KAAU,EAAE;IAC1B,OAAO,IAAI,CAACG,EAAE,CAACJ,KAAK,EAAEC,KAAK,CAAC;EAC9B;EAEAI,KAAKA,CAAA,EAAG;IACN,OAAO,IAAI,CAACd,cAAc,CAAC,CAAC;EAC9B;EAEAe,YAAYA,CAAA,EAAY;IAAA,IAAAC,gBAAA;IACtB,IAAI,IAAI,CAACC,UAAU,KAAK,IAAI,IAAI,IAAI,CAACA,UAAU,KAAKC,SAAS,EAAE;MAC7D,OAAO,KAAK;IACd;IACA,IAAI,CAACC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACH,UAAU,CAAC,CAACI,KAAK,CAAEC,CAAC,IAAKA,CAAC,KAAK,MAAM,CAAC,EAAE;MAC5D,OAAO,KAAK;IACd;IACA,OAAO,CAAC,EAAAN,gBAAA,OAAI,CAACC,UAAU,cAAAD,gBAAA,GAAfA,gBAAA,CAAiBO,IAAI,qBAArBP,gBAAA,CAAuBQ,MAAM,KAAI,CAAC,IAAI,CAAC;EACjD;AACF;AAACvB,OAAA,CAAAC,yBAAA,GAAAA,yBAAA;AAEM,SAASuB,yBAAyBA,CAACC,OAAO,GAAG,CAAC,CAAC,EAAE;EACtD,OAAO,IAAIxB,yBAAyB,CAACwB,OAAO,CAAC;AAC/C;AAEO,SAASC,oBAAoBA,CAAA,EAAG;EACrC,OAAO,IAAI/B,aAAa,CAAC,CAAC,CAAC,CAAC;AAC9B;AAAC,IAAAgC,QAAA,GAAA3B,OAAA,CAAA4B,OAAA,GAEcF,oBAAoB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_typeUtils","require","_baseValidator","_errors","_filterBuilder","filterMixin","Base","genericFilterMixin","constructor","origin","_defineProperty2","default","validateCollectionName","or","otherQuery","orQuery","apply","arguments","_validateCollectionName","and","andQuery","not","notQuery","query","originalQuery","operationName","invalidArguments","length","withCollectionName","withCollectionNameIfUnset","collectionName","newInvalidArguments","valid","FilterValidator","constructorName","name","isForCollection","validateAndAggregate","_copy","filterTree","_matchesUrlized","field","operand","_filterValidator","arityIsTwo","validFieldName","typeIsString","newFilterTree","_makeNewFilter","createMatchesOrInFilter","getFilterModel","validationError","messages","filterBuilderInvalid","filterOperatorName","looksLikeAnInteger","Number","parseInt","ignoreCase","spec","createMatchSpec","str","test","fieldValue","literals","split","result","i","appendLiteralSegment","appendAnyOfSegment","res","literalValue","push","type","value","AggregatingValidator","operatorName","previousInvalidArguments","ctor","addValidation","isString","filterValidations","typeIsStringNumberOrDate","isDateStringOrNumber","sameType","first","second","typeForDisplay","typeIsStringNumberOrDateForAll","values","every","isInstanceOfSameClass","obj","otherFilterBuilder","expectedCollectionName","exports","isNumber","isDate","filter","_default"],"sources":["../../../src/filter/filterMixin.ts"],"sourcesContent":["import { typeForDisplay, isDate, isString, isNumber } from '../utils/type-utils'\nimport { AggregatingValidator } from '../errors/base-validator'\nimport { messages, validationError } from '../errors/errors'\nimport {\n filterMixin as genericFilterMixin,\n Validator,\n} from '@wix/filter-builder'\n\nconst filterMixin = (Base: any = class {}) =>\n class extends genericFilterMixin(Base) {\n readonly validateCollectionName: boolean\n\n constructor(origin?: {\n validateCollectionName?: boolean\n filterTree?: object\n invalidArguments?: string[]\n encoder?: Function\n }) {\n super(origin)\n this.validateCollectionName = origin?.validateCollectionName ?? true\n }\n\n or(otherQuery: any) {\n const orQuery = super.or.apply(this, arguments as any)\n return this._validateCollectionName(orQuery, otherQuery, '.or')\n }\n\n and(otherQuery: any) {\n const andQuery = super.and.apply(this, arguments as any)\n return this._validateCollectionName(andQuery, otherQuery, '.and')\n }\n\n not(otherQuery: any) {\n const notQuery = super.not.apply(this, arguments as any)\n return this._validateCollectionName(notQuery, otherQuery, '.not')\n }\n\n _validateCollectionName(\n query: any,\n originalQuery: any,\n operationName: string\n ) {\n if (query.invalidArguments.length > 0 || !this.validateCollectionName) {\n return query\n }\n const withCollectionName = withCollectionNameIfUnset(\n originalQuery,\n this.collectionName\n )\n const [newInvalidArguments, valid] = new FilterValidator(\n operationName,\n query.invalidArguments,\n this.constructor,\n this.constructorName ?? this.constructor.name\n )\n .isForCollection(withCollectionName, this.collectionName)\n .validateAndAggregate()\n\n if (!valid) {\n return this._copy(this.filterTree, newInvalidArguments)\n }\n return query\n }\n\n // used only from data binding router internally\n _matchesUrlized(field: any, operand: any) {\n const [newInvalidArguments, valid] = this._filterValidator(\n '._matchesUrlized'\n )\n .arityIsTwo(arguments)\n .validFieldName(field)\n .typeIsString(operand)\n .validateAndAggregate()\n\n if (valid) {\n const newFilterTree = this._makeNewFilter(\n field,\n // @ts-expect-error-next-line\n ...createMatchesOrInFilter(operand)\n )\n return this._copy(newFilterTree, newInvalidArguments)\n }\n\n return this._copy(this.filterTree, newInvalidArguments)\n }\n\n getFilterModel() {\n if (this.invalidArguments.length > 0) {\n throw validationError(\n messages.filterBuilderInvalid(this.invalidArguments)\n )\n }\n return super.getFilterModel()\n }\n\n _filterValidator(filterOperatorName: string): Validator {\n return new FilterValidator(\n filterOperatorName,\n this.invalidArguments,\n this.constructor,\n this.constructorName ?? this.constructor.name\n )\n }\n }\n\nfunction createMatchesOrInFilter(operand: string) {\n if (looksLikeAnInteger(operand)) {\n // eslint-disable-next-line radix\n return ['$in', [operand, Number.parseInt(operand)]]\n } else {\n return [\n '$matches',\n {\n ignoreCase: true,\n spec: createMatchSpec(operand),\n },\n ]\n }\n\n function looksLikeAnInteger(str: string) {\n return /^-?[0-9]{1,16}$/.test(str)\n }\n}\ninterface MatchSpec {\n type: string\n value: string\n}\n\nfunction createMatchSpec(fieldValue: string) {\n const literals = fieldValue.split('-')\n const result: MatchSpec[] = []\n\n for (let i = 0; i < literals.length - 1; i++) {\n appendLiteralSegment(result, literals[i])\n appendAnyOfSegment(result)\n }\n appendLiteralSegment(result, literals[literals.length - 1])\n\n return result\n\n function appendLiteralSegment(res: MatchSpec[], literalValue: string) {\n if (literalValue.length !== 0) {\n res.push({ type: 'literal', value: literalValue })\n }\n }\n\n function appendAnyOfSegment(res: MatchSpec[]) {\n res.push({ type: 'anyOf', value: ' \\t\\n-' })\n }\n}\n\nexport class FilterValidator extends AggregatingValidator {\n constructor(\n public operatorName: string,\n previousInvalidArguments: string[],\n private ctor: any,\n private constructorName: string\n ) {\n super(previousInvalidArguments)\n }\n\n typeIsString(value: any) {\n return this.addValidation(\n () => isString(value),\n () => messages.filterValidations.typeIsString(this.operatorName, value)\n )\n }\n\n typeIsStringNumberOrDate(value: any) {\n return this.addValidation(\n () => isDateStringOrNumber(value),\n () =>\n messages.filterValidations.typeIsStringNumberOrDate(\n this.operatorName,\n value\n )\n )\n }\n\n sameType(first: any, second: any) {\n return this.addValidation(\n () => typeForDisplay(first) === typeForDisplay(second),\n () =>\n messages.filterValidations.sameType(this.operatorName, first, second)\n )\n }\n\n typeIsStringNumberOrDateForAll(values: any) {\n return this.addValidation(\n () => values.every(isDateStringOrNumber),\n () =>\n messages.filterValidations.typeIsStringNumberOrDateForAll(\n this.operatorName\n )\n )\n }\n\n validFieldName(field: any) {\n return this.addValidation(\n () => isString(field),\n () => messages.filterValidations.validFieldName(this.operatorName, field)\n )\n }\n\n isInstanceOfSameClass(obj: any) {\n return this.addValidation(\n () => obj instanceof this.ctor,\n () =>\n messages.filterValidations.isInstanceOfSameClass(\n this.operatorName,\n this.constructorName,\n obj\n )\n )\n }\n\n isForCollection(otherFilterBuilder: any, expectedCollectionName: any) {\n return this.addValidation(\n () => otherFilterBuilder.collectionName === expectedCollectionName,\n () =>\n messages.filterValidations.isForCollection(\n this.operatorName,\n this.constructorName,\n otherFilterBuilder.collectionName\n )\n )\n }\n}\n\nfunction isDateStringOrNumber(value: any) {\n return isString(value) || isNumber(value) || isDate(value)\n}\n\nfunction withCollectionNameIfUnset(filter: any, name: string) {\n if (!filter || !filter.constructor) {\n return filter\n }\n\n const collectionName = filter.collectionName ? filter.collectionName : name\n\n return new filter.constructor({ ...filter, collectionName })\n}\n\nexport default filterMixin\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;A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EAAE;IAClC,OAAO0F,MAAM;EACf;EAEA,MAAMpE,cAAc,GAAGoE,MAAM,CAACpE,cAAc,GAAGoE,MAAM,CAACpE,cAAc,GAAGK,IAAI;EAE3E,OAAO,IAAI+D,MAAM,CAAC1F,WAAW,CAAC;IAAE,GAAG0F,MAAM;IAAEpE;EAAe,CAAC,CAAC;AAC9D;AAAC,IAAAqE,QAAA,GAAAJ,OAAA,CAAApF,OAAA,GAEcN,WAAW"}
1
+ {"version":3,"names":["_typeUtils","require","_baseValidator","_errors","_filterBuilder","filterMixin","Base","genericFilterMixin","constructor","origin","_defineProperty2","default","validateCollectionName","or","otherQuery","orQuery","apply","arguments","_validateCollectionName","and","andQuery","not","notQuery","query","originalQuery","operationName","invalidArguments","length","withCollectionName","withCollectionNameIfUnset","collectionName","newInvalidArguments","valid","FilterValidator","constructorName","name","isForCollection","validateAndAggregate","_copy","filterTree","_matchesUrlized","field","operand","_filterValidator","arityIsTwo","validFieldName","typeIsString","newFilterTree","_makeNewFilter","createMatchesOrInFilter","getFilterModel","validationError","messages","filterBuilderInvalid","filterOperatorName","looksLikeAnInteger","Number","parseInt","ignoreCase","spec","createMatchSpec","str","test","fieldValue","literals","split","result","i","appendLiteralSegment","appendAnyOfSegment","res","literalValue","push","type","value","AggregatingValidator","operatorName","previousInvalidArguments","ctor","addValidation","isString","filterValidations","typeIsStringNumberOrDate","isDateStringOrNumber","sameType","first","second","typeForDisplay","typeIsStringNumberOrDateForAll","values","every","isInstanceOfSameClass","obj","otherFilterBuilder","expectedCollectionName","exports","isNumber","isDate","filter","_default"],"sources":["../../../src/filter/filterMixin.ts"],"sourcesContent":["import { typeForDisplay, isDate, isString, isNumber } from '../utils/type-utils'\nimport { AggregatingValidator } from '../errors/base-validator'\nimport { messages, validationError } from '../errors/errors'\nimport {\n filterMixin as genericFilterMixin,\n Validator,\n} from '@wix/filter-builder'\n\nconst filterMixin = (Base: any = class {}) =>\n class extends genericFilterMixin(Base) {\n readonly validateCollectionName: boolean\n\n constructor(origin?: {\n validateCollectionName?: boolean\n filterTree?: object\n invalidArguments?: string[]\n encoder?: Function\n }) {\n super(origin)\n this.validateCollectionName = origin?.validateCollectionName ?? true\n }\n\n or(otherQuery: any) {\n const orQuery = super.or.apply(this, arguments as any)\n return this._validateCollectionName(orQuery, otherQuery, '.or')\n }\n\n and(otherQuery: any) {\n const andQuery = super.and.apply(this, arguments as any)\n return this._validateCollectionName(andQuery, otherQuery, '.and')\n }\n\n not(otherQuery: any) {\n const notQuery = super.not.apply(this, arguments as any)\n return this._validateCollectionName(notQuery, otherQuery, '.not')\n }\n\n _validateCollectionName(\n query: any,\n originalQuery: any,\n operationName: string\n ) {\n if (query.invalidArguments.length > 0 || !this.validateCollectionName) {\n return query\n }\n const withCollectionName = withCollectionNameIfUnset(\n originalQuery,\n this.collectionName\n )\n const [newInvalidArguments, valid] = new FilterValidator(\n operationName,\n query.invalidArguments,\n this.constructor,\n this.constructorName ?? this.constructor.name\n )\n .isForCollection(withCollectionName, this.collectionName)\n .validateAndAggregate()\n\n if (!valid) {\n return this._copy(this.filterTree, newInvalidArguments)\n }\n return query\n }\n\n // used only from data binding router internally\n _matchesUrlized(field: any, operand: any) {\n const [newInvalidArguments, valid] = this._filterValidator(\n '._matchesUrlized'\n )\n .arityIsTwo(arguments)\n .validFieldName(field)\n .typeIsString(operand)\n .validateAndAggregate()\n\n if (valid) {\n const newFilterTree = this._makeNewFilter(\n field,\n // @ts-expect-error-next-line\n ...createMatchesOrInFilter(operand)\n )\n return this._copy(newFilterTree, newInvalidArguments)\n }\n\n return this._copy(this.filterTree, newInvalidArguments)\n }\n\n getFilterModel() {\n if (this.invalidArguments.length > 0) {\n throw validationError(\n messages.filterBuilderInvalid(this.invalidArguments)\n )\n }\n return super.getFilterModel()\n }\n\n _filterValidator(filterOperatorName: string): Validator {\n return new FilterValidator(\n filterOperatorName,\n this.invalidArguments,\n this.constructor,\n this.constructorName ?? this.constructor.name\n )\n }\n }\n\nfunction createMatchesOrInFilter(operand: string) {\n if (looksLikeAnInteger(operand)) {\n // eslint-disable-next-line radix\n return ['$in', [operand, Number.parseInt(operand)]]\n } else {\n return [\n '$matches',\n {\n ignoreCase: true,\n spec: createMatchSpec(operand),\n },\n ]\n }\n\n function looksLikeAnInteger(str: string) {\n return /^-?[0-9]{1,16}$/.test(str)\n }\n}\ninterface MatchSpec {\n type: string\n value: string\n}\n\nfunction createMatchSpec(fieldValue: string) {\n const literals = fieldValue.split('-')\n const result: MatchSpec[] = []\n\n for (let i = 0; i < literals.length - 1; i++) {\n appendLiteralSegment(result, literals[i])\n appendAnyOfSegment(result)\n }\n appendLiteralSegment(result, literals[literals.length - 1])\n\n return result\n\n function appendLiteralSegment(res: MatchSpec[], literalValue: string) {\n if (literalValue.length !== 0) {\n res.push({ type: 'literal', value: literalValue })\n }\n }\n\n function appendAnyOfSegment(res: MatchSpec[]) {\n res.push({ type: 'anyOf', value: ' \\t\\n-' })\n }\n}\n\nexport class FilterValidator extends AggregatingValidator {\n constructor(\n public operatorName: string,\n previousInvalidArguments: string[],\n private ctor: any,\n private constructorName: string\n ) {\n super(previousInvalidArguments)\n }\n\n typeIsString(value: any) {\n return this.addValidation(\n () => isString(value),\n () => messages.filterValidations.typeIsString(this.operatorName, value)\n )\n }\n\n typeIsStringNumberOrDate(value: any) {\n return this.addValidation(\n () => isDateStringOrNumber(value),\n () =>\n messages.filterValidations.typeIsStringNumberOrDate(\n this.operatorName,\n value\n )\n )\n }\n\n sameType(first: any, second: any) {\n return this.addValidation(\n () => typeForDisplay(first) === typeForDisplay(second),\n () =>\n messages.filterValidations.sameType(this.operatorName, first, second)\n )\n }\n\n typeIsStringNumberOrDateForAll(values: any) {\n return this.addValidation(\n () => values.every(isDateStringOrNumber),\n () =>\n messages.filterValidations.typeIsStringNumberOrDateForAll(\n this.operatorName\n )\n )\n }\n\n validFieldName(field: any) {\n return this.addValidation(\n () => isString(field),\n () => messages.filterValidations.validFieldName(this.operatorName, field)\n )\n }\n\n isInstanceOfSameClass(obj: any) {\n return this.addValidation(\n () => obj instanceof this.ctor,\n () =>\n messages.filterValidations.isInstanceOfSameClass(\n this.operatorName,\n this.constructorName,\n obj\n )\n )\n }\n\n isForCollection(otherFilterBuilder: any, expectedCollectionName: any) {\n return this.addValidation(\n () => otherFilterBuilder.collectionName === expectedCollectionName,\n () =>\n messages.filterValidations.isForCollection(\n this.operatorName,\n this.constructorName,\n otherFilterBuilder.collectionName\n )\n )\n }\n}\n\nfunction isDateStringOrNumber(value: any) {\n return isString(value) || isNumber(value) || isDate(value)\n}\n\nfunction withCollectionNameIfUnset(filter: any, name: string) {\n if (!filter || !filter.constructor) {\n return filter\n }\n\n const collectionName = filter.collectionName ? filter.collectionName : name\n\n return new filter.constructor({ ...filter, collectionName })\n}\n\nexport default filterMixin\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAKA,MAAMI,WAAW,GAAGA,CAACC,IAAS,GAAG,MAAM,EAAE,KACvC,cAAc,IAAAC,0BAAkB,EAACD,IAAI,CAAC,CAAC;EAGrCE,WAAWA,CAACC,MAKX,EAAE;IACD,KAAK,CAACA,MAAM,CAAC;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IACb,IAAI,CAACC,sBAAsB,GAAG,CAAAH,MAAM,oBAANA,MAAM,CAAEG,sBAAsB,KAAI,IAAI;EACtE;EAEAC,EAAEA,CAACC,UAAe,EAAE;IAClB,MAAMC,OAAO,GAAG,KAAK,CAACF,EAAE,CAACG,KAAK,CAAC,IAAI,EAAEC,SAAgB,CAAC;IACtD,OAAO,IAAI,CAACC,uBAAuB,CAACH,OAAO,EAAED,UAAU,EAAE,KAAK,CAAC;EACjE;EAEAK,GAAGA,CAACL,UAAe,EAAE;IACnB,MAAMM,QAAQ,GAAG,KAAK,CAACD,GAAG,CAACH,KAAK,CAAC,IAAI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AC;EACH;EAEAxD,eAAeA,CAACyD,kBAAuB,EAAEC,sBAA2B,EAAE;IACpE,OAAO,IAAI,CAACf,aAAa,CACvB,MAAMc,kBAAkB,CAAC/D,cAAc,KAAKgE,sBAAsB,EAClE,MACE1C,gBAAQ,CAAC6B,iBAAiB,CAAC7C,eAAe,CACxC,IAAI,CAACwC,YAAY,EACjB,IAAI,CAAC1C,eAAe,EACpB2D,kBAAkB,CAAC/D,cACrB,CACJ,CAAC;EACH;AACF;AAACiE,OAAA,CAAA9D,eAAA,GAAAA,eAAA;AAED,SAASkD,oBAAoBA,CAACT,KAAU,EAAE;EACxC,OAAO,IAAAM,mBAAQ,EAACN,KAAK,CAAC,IAAI,IAAAsB,mBAAQ,EAACtB,KAAK,CAAC,IAAI,IAAAuB,iBAAM,EAACvB,KAAK,CAAC;AAC5D;AAEA,SAAS7C,yBAAyBA,CAACqE,MAAW,EAAE/D,IAAY,EAAE;EAC5D,IAAI,CAAC+D,MAAM,IAAI,CAACA,MAAM,CAAC1F,WAAW,EAAE;IAClC,OAAO0F,MAAM;EACf;EAEA,MAAMpE,cAAc,GAAGoE,MAAM,CAACpE,cAAc,GAAGoE,MAAM,CAACpE,cAAc,GAAGK,IAAI;EAE3E,OAAO,IAAI+D,MAAM,CAAC1F,WAAW,CAAC;IAAE,GAAG0F,MAAM;IAAEpE;EAAe,CAAC,CAAC;AAC9D;AAAC,IAAAqE,QAAA,GAAAJ,OAAA,CAAApF,OAAA,GAEcN,WAAW","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_FilterTree","require","exports","validateFilterTree","validateFilterOrThrow","_WithFilter","_interopRequireDefault","WithFilter","default","_filterBuilder","filterBuilderFactory","platformizedFilterBuilder","PlatformizedFilterBuilder","_filterMixin","filterMixin"],"sources":["../../../src/filter/index.ts"],"sourcesContent":["import { validateFilterTree, validateFilterOrThrow } from './FilterTree'\nimport type { FilterTree } from './FilterTree'\nimport WithFilter from './WithFilter'\nimport {\n filterBuilderFactory,\n platformizedFilterBuilder,\n PlatformizedFilterBuilder,\n} from './filterBuilder'\nimport filterMixin from './filterMixin'\n\nexport type { FilterTree }\nexport {\n validateFilterTree,\n validateFilterOrThrow,\n WithFilter,\n filterBuilderFactory,\n platformizedFilterBuilder,\n PlatformizedFilterBuilder,\n filterMixin,\n}\n"],"mappings":";;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAwEC,OAAA,CAAAC,kBAAA,GAAAH,WAAA,CAAAG,kBAAA;AAAAD,OAAA,CAAAE,qBAAA,GAAAJ,WAAA,CAAAI,qBAAA;AAExE,IAAAC,WAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAqCC,OAAA,CAAAK,UAAA,GAAAF,WAAA,CAAAG,OAAA;AACrC,IAAAC,cAAA,GAAAR,OAAA;AAIwBC,OAAA,CAAAQ,oBAAA,GAAAD,cAAA,CAAAC,oBAAA;AAAAR,OAAA,CAAAS,yBAAA,GAAAF,cAAA,CAAAE,yBAAA;AAAAT,OAAA,CAAAU,yBAAA,GAAAH,cAAA,CAAAG,yBAAA;AACxB,IAAAC,YAAA,GAAAP,sBAAA,CAAAL,OAAA;AAAuCC,OAAA,CAAAY,WAAA,GAAAD,YAAA,CAAAL,OAAA"}
1
+ {"version":3,"names":["_FilterTree","require","exports","validateFilterTree","validateFilterOrThrow","_WithFilter","_interopRequireDefault","WithFilter","default","_filterBuilder","filterBuilderFactory","platformizedFilterBuilder","PlatformizedFilterBuilder","_filterMixin","filterMixin"],"sources":["../../../src/filter/index.ts"],"sourcesContent":["import { validateFilterTree, validateFilterOrThrow } from './FilterTree'\nimport type { FilterTree } from './FilterTree'\nimport WithFilter from './WithFilter'\nimport {\n filterBuilderFactory,\n platformizedFilterBuilder,\n PlatformizedFilterBuilder,\n} from './filterBuilder'\nimport filterMixin from './filterMixin'\n\nexport type { FilterTree }\nexport {\n validateFilterTree,\n validateFilterOrThrow,\n WithFilter,\n filterBuilderFactory,\n platformizedFilterBuilder,\n PlatformizedFilterBuilder,\n filterMixin,\n}\n"],"mappings":";;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAwEC,OAAA,CAAAC,kBAAA,GAAAH,WAAA,CAAAG,kBAAA;AAAAD,OAAA,CAAAE,qBAAA,GAAAJ,WAAA,CAAAI,qBAAA;AAExE,IAAAC,WAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAqCC,OAAA,CAAAK,UAAA,GAAAF,WAAA,CAAAG,OAAA;AACrC,IAAAC,cAAA,GAAAR,OAAA;AAIwBC,OAAA,CAAAQ,oBAAA,GAAAD,cAAA,CAAAC,oBAAA;AAAAR,OAAA,CAAAS,yBAAA,GAAAF,cAAA,CAAAE,yBAAA;AAAAT,OAAA,CAAAU,yBAAA,GAAAH,cAAA,CAAAG,yBAAA;AACxB,IAAAC,YAAA,GAAAP,sBAAA,CAAAL,OAAA;AAAuCC,OAAA,CAAAY,WAAA,GAAAD,YAAA,CAAAL,OAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_sortMixin","_interopRequireDefault","require","exports","sortMixin","default","_filterBuilder","optimiseQuery","wixDataEncoder","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","_filter","_errors","_api","_types"],"sources":["../../src/index.ts"],"sourcesContent":["import sortMixin from './sort/sortMixin'\n\nexport { sortMixin }\nexport { optimiseQuery, wixDataEncoder } from '@wix/filter-builder'\nexport * from './utils'\nexport * from './filter'\nexport * from './errors'\nexport * from './api'\nexport * from './types'\nexport type { FilterTree } from './filter'\nexport type { HttpApiClientFactory, RequestInterceptor } from './types'\nexport type { WixDataItemOrId } from './api'\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwCC,OAAA,CAAAC,SAAA,GAAAJ,UAAA,CAAAK,OAAA;AAGxC,IAAAC,cAAA,GAAAJ,OAAA;AAAmEC,OAAA,CAAAI,aAAA,GAAAD,cAAA,CAAAC,aAAA;AAAAJ,OAAA,CAAAK,cAA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IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAV,OAAA,IAAAA,OAAA,CAAAU,GAAA,MAAAO,IAAA,CAAAP,GAAA;EAAAV,OAAA,CAAAU,GAAA,IAAAO,IAAA,CAAAP,GAAA;AAAA;AACA,IAAAQ,MAAA,GAAAnB,OAAA;AAAAQ,MAAA,CAAAC,IAAA,CAAAU,MAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAV,OAAA,IAAAA,OAAA,CAAAU,GAAA,MAAAQ,MAAA,CAAAR,GAAA;EAAAV,OAAA,CAAAU,GAAA,IAAAQ,MAAA,CAAAR,GAAA;AAAA"}
1
+ {"version":3,"names":["_sortMixin","_interopRequireDefault","require","exports","sortMixin","default","_filterBuilder","optimiseQuery","wixDataEncoder","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","_filter","_errors","_api","_types"],"sources":["../../src/index.ts"],"sourcesContent":["import sortMixin from './sort/sortMixin'\n\nexport { sortMixin }\nexport { optimiseQuery, wixDataEncoder } from '@wix/filter-builder'\nexport * from './utils'\nexport * from './filter'\nexport * from './errors'\nexport * from './api'\nexport * from './types'\nexport type { FilterTree } from './filter'\nexport type { HttpApiClientFactory, RequestInterceptor } from './types'\nexport type { WixDataItemOrId } from './api'\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwCC,OAAA,CAAAC,SAAA,GAAAJ,UAAA,CAAAK,OAAA;AAGxC,IAAAC,cAAA,GAAAJ,OAAA;AAAmEC,OAAA,CAAAI,aAAA,GAAAD,cAAA,CAAAC,aAAA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,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAV,OAAA,IAAAA,OAAA,CAAAU,GAAA,MAAAO,IAAA,CAAAP,GAAA;EAAAV,OAAA,CAAAU,GAAA,IAAAO,IAAA,CAAAP,GAAA;AAAA;AACA,IAAAQ,MAAA,GAAAnB,OAAA;AAAAQ,MAAA,CAAAC,IAAA,CAAAU,MAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAV,OAAA,IAAAA,OAAA,CAAAU,GAAA,MAAAQ,MAAA,CAAAR,GAAA;EAAAV,OAAA,CAAAU,GAAA,IAAAQ,MAAA,CAAAR,GAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_errors","sortMixin","Base","constructor","obj","_defineProperty2","default","orderBy","invalidArguments","ascending","fields","_sortClause","descending","getSortModel","length","validationError","messages","sortBuilderInvalid","setSortModel","sortModel","_copySort","operatorSymbol","operatorName","args","clone","appendClause","createAppendClauseFn","effectiveArgs","isArray","Array","prototype","slice","call","newInvalidArguments","valid","_sortValidator","arityIsAtLeastOne","allStrings","validateAndAggregate","forEach","SortValidator","destination","direction","field","spec","push","AggregatingValidator","previousInvalidArguments","addValidation","every","isString","sortValidations","typeIsStringOrArrayOfStrings","exports","Sort","_default"],"sources":["../../../src/sort/sortMixin.ts"],"sourcesContent":["import { clone, isString, isArray } from '../utils'\nimport { AggregatingValidator, messages, validationError } from '../errors'\n\nexport type Direction = 'asc' | 'desc'\nexport interface OrderBySpec {\n [field: string]: Direction\n}\nexport type OrderBy = OrderBySpec[]\n\ninterface WithConstructor {\n // eslint-disable-next-line @typescript-eslint/prefer-function-type\n new (...args: any): any\n}\n\nconst sortMixin = (Base: WithConstructor = class {}) =>\n class extends Base {\n orderBy: OrderBy\n invalidArguments: string[]\n\n constructor(obj: any = {}) {\n super(obj)\n this.orderBy = obj.orderBy || []\n this.invalidArguments = obj.invalidArguments || []\n }\n\n ascending(...fields: any[]) {\n return this._sortClause('asc', '.ascending', fields)\n }\n\n descending(...fields: any[]) {\n return this._sortClause('desc', '.descending', fields)\n }\n\n getSortModel() {\n if (this.invalidArguments.length > 0) {\n throw validationError(\n messages.sortBuilderInvalid(this.invalidArguments)\n )\n }\n return this.orderBy\n }\n\n setSortModel(sortModel: any[]) {\n return this._copySort(sortModel, [])\n }\n\n _sortClause(operatorSymbol: Direction, operatorName: string, args: any[]) {\n let orderBy: OrderBy = []\n if (this.orderBy) {\n orderBy = clone(this.orderBy)\n }\n\n const appendClause = createAppendClauseFn(orderBy, operatorSymbol)\n const effectiveArgs =\n isArray(args[0]) && args.length === 1\n ? args[0]\n : Array.prototype.slice.call(args, 0)\n const [newInvalidArguments, valid] = this._sortValidator(operatorName)\n .arityIsAtLeastOne(args)\n .allStrings(effectiveArgs)\n .validateAndAggregate()\n\n if (valid) {\n effectiveArgs.forEach(appendClause)\n }\n\n return this._copySort(orderBy, newInvalidArguments)\n }\n\n _sortValidator(operatorName: string) {\n return new SortValidator(operatorName, this.invalidArguments)\n }\n\n _copySort(orderBy: OrderBy, invalidArguments: string[]) {\n return new (this.constructor as WithConstructor)({\n ...this,\n orderBy,\n invalidArguments,\n })\n }\n }\n\nfunction createAppendClauseFn(destination: OrderBy, direction: Direction) {\n return (field: string) => {\n const spec: OrderBySpec = { [field]: direction }\n destination.push(spec)\n }\n}\n\nexport class SortValidator extends AggregatingValidator {\n constructor(public operatorName: string, previousInvalidArguments: string[]) {\n super(previousInvalidArguments)\n }\n\n allStrings(effectiveArgs: any[]) {\n return this.addValidation(\n () => effectiveArgs.every(isString),\n () => {\n return messages.sortValidations.typeIsStringOrArrayOfStrings(\n this.operatorName,\n effectiveArgs\n )\n }\n )\n }\n}\n\nexport class Sort extends sortMixin() {}\n\nexport default sortMixin\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAaA,MAAME,SAAS,GAAGA,CAACC,IAAqB,GAAG,MAAM,EAAE,KACjD,cAAcA,IAAI,CAAC;EAIjBC,WAAWA,CAACC,GAAQ,GAAG,CAAC,CAAC,EAAE;IACzB,KAAK,CAACA,GAAG,CAAC;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACV,IAAI,CAACC,OAAO,GAAGH,GAAG,CAACG,OAAO,IAAI,EAAE;IAChC,IAAI,CAACC,gBAAgB,GAAGJ,GAAG,CAACI,gBAAgB,IAAI,EAAE;EACpD;EAEAC,SAASA,CAAC,GAAGC,MAAa,EAAE;IAC1B,OAAO,IAAI,CAACC,WAAW,CAAC,KAAK,EAAE,YAAY,EAAED,MAAM,CAAC;EACtD;EAEAE,UAAUA,CAAC,GAAGF,MAAa,EAAE;IAC3B,OAAO,IAAI,CAACC,WAAW,CAAC,MAAM,EAAE,aAAa,EAAED,MAAM,CAAC;EACxD;EAEAG,YAAYA,CAAA,EAAG;IACb,IAAI,IAAI,CAACL,gBAAgB,CAACM,MAAM,GAAG,CAAC,EAAE;MACpC,MAAM,IAAAC,uBAAe,EACnBC,gBAAQ,CAACC,kBAAkB,CAAC,IAAI,CAACT,gBAAgB,CACnD,CAAC;IACH;IACA,OAAO,IAAI,CAACD,OAAO;EACrB;EAEAW,YAAYA,CAACC,SAAgB,EAAE;IAC7B,OAAO,IAAI,CAACC,SAAS,CAACD,SAAS,EAAE,EAAE,CAAC;EACtC;EAEAR,WAAWA,CAACU,cAAyB,EAAEC,YAAoB,EAAEC,IAAW,EAAE;IACxE,IAAIhB,OAAgB,GAAG,EAAE;IACzB,IAAI,IAAI,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tD3C,WAAWA,CAAQmB,YAAoB,EAAEyB,wBAAkC,EAAE;IAC3E,KAAK,CAACA,wBAAwB,CAAC;IAAA,KADdzB,YAAoB,GAApBA,YAAoB;EAEvC;EAEAe,UAAUA,CAACV,aAAoB,EAAE;IAC/B,OAAO,IAAI,CAACqB,aAAa,CACvB,MAAMrB,aAAa,CAACsB,KAAK,CAACC,eAAQ,CAAC,EACnC,MAAM;MACJ,OAAOlC,gBAAQ,CAACmC,eAAe,CAACC,4BAA4B,CAC1D,IAAI,CAAC9B,YAAY,EACjBK,aACF,CAAC;IACH,CACF,CAAC;EACH;AACF;AAAC0B,OAAA,CAAAb,aAAA,GAAAA,aAAA;AAEM,MAAMc,IAAI,SAASrD,SAAS,CAAC,CAAC,CAAC;AAAEoD,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAAA,IAAAC,QAAA,GAAAF,OAAA,CAAA/C,OAAA,GAEzBL,SAAS"}
1
+ {"version":3,"names":["_utils","require","_errors","sortMixin","Base","constructor","obj","_defineProperty2","default","orderBy","invalidArguments","ascending","fields","_sortClause","descending","getSortModel","length","validationError","messages","sortBuilderInvalid","setSortModel","sortModel","_copySort","operatorSymbol","operatorName","args","clone","appendClause","createAppendClauseFn","effectiveArgs","isArray","Array","prototype","slice","call","newInvalidArguments","valid","_sortValidator","arityIsAtLeastOne","allStrings","validateAndAggregate","forEach","SortValidator","destination","direction","field","spec","push","AggregatingValidator","previousInvalidArguments","addValidation","every","isString","sortValidations","typeIsStringOrArrayOfStrings","exports","Sort","_default"],"sources":["../../../src/sort/sortMixin.ts"],"sourcesContent":["import { clone, isString, isArray } from '../utils'\nimport { AggregatingValidator, messages, validationError } from '../errors'\n\nexport type Direction = 'asc' | 'desc'\nexport interface OrderBySpec {\n [field: string]: Direction\n}\nexport type OrderBy = OrderBySpec[]\n\ninterface WithConstructor {\n // eslint-disable-next-line @typescript-eslint/prefer-function-type\n new (...args: any): any\n}\n\nconst sortMixin = (Base: WithConstructor = class {}) =>\n class extends Base {\n orderBy: OrderBy\n invalidArguments: string[]\n\n constructor(obj: any = {}) {\n super(obj)\n this.orderBy = obj.orderBy || []\n this.invalidArguments = obj.invalidArguments || []\n }\n\n ascending(...fields: any[]) {\n return this._sortClause('asc', '.ascending', fields)\n }\n\n descending(...fields: any[]) {\n return this._sortClause('desc', '.descending', fields)\n }\n\n getSortModel() {\n if (this.invalidArguments.length > 0) {\n throw validationError(\n messages.sortBuilderInvalid(this.invalidArguments)\n )\n }\n return this.orderBy\n }\n\n setSortModel(sortModel: any[]) {\n return this._copySort(sortModel, [])\n }\n\n _sortClause(operatorSymbol: Direction, operatorName: string, args: any[]) {\n let orderBy: OrderBy = []\n if (this.orderBy) {\n orderBy = clone(this.orderBy)\n }\n\n const appendClause = createAppendClauseFn(orderBy, operatorSymbol)\n const effectiveArgs =\n isArray(args[0]) && args.length === 1\n ? args[0]\n : Array.prototype.slice.call(args, 0)\n const [newInvalidArguments, valid] = this._sortValidator(operatorName)\n .arityIsAtLeastOne(args)\n .allStrings(effectiveArgs)\n .validateAndAggregate()\n\n if (valid) {\n effectiveArgs.forEach(appendClause)\n }\n\n return this._copySort(orderBy, newInvalidArguments)\n }\n\n _sortValidator(operatorName: string) {\n return new SortValidator(operatorName, this.invalidArguments)\n }\n\n _copySort(orderBy: OrderBy, invalidArguments: string[]) {\n return new (this.constructor as WithConstructor)({\n ...this,\n orderBy,\n invalidArguments,\n })\n }\n }\n\nfunction createAppendClauseFn(destination: OrderBy, direction: Direction) {\n return (field: string) => {\n const spec: OrderBySpec = { [field]: direction }\n destination.push(spec)\n }\n}\n\nexport class SortValidator extends AggregatingValidator {\n constructor(public operatorName: string, previousInvalidArguments: string[]) {\n super(previousInvalidArguments)\n }\n\n allStrings(effectiveArgs: any[]) {\n return this.addValidation(\n () => effectiveArgs.every(isString),\n () => {\n return messages.sortValidations.typeIsStringOrArrayOfStrings(\n this.operatorName,\n effectiveArgs\n )\n }\n )\n }\n}\n\nexport class Sort extends sortMixin() {}\n\nex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oB,GAApBA,YAAoB;EAEvC;EAEAe,UAAUA,CAACV,aAAoB,EAAE;IAC/B,OAAO,IAAI,CAACqB,aAAa,CACvB,MAAMrB,aAAa,CAACsB,KAAK,CAACC,eAAQ,CAAC,EACnC,MAAM;MACJ,OAAOlC,gBAAQ,CAACmC,eAAe,CAACC,4BAA4B,CAC1D,IAAI,CAAC9B,YAAY,EACjBK,aACF,CAAC;IACH,CACF,CAAC;EACH;AACF;AAAC0B,OAAA,CAAAb,aAAA,GAAAA,aAAA;AAEM,MAAMc,IAAI,SAASrD,SAAS,CAAC,CAAC,CAAC;AAAEoD,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAAA,IAAAC,QAAA,GAAAF,OAAA,CAAA/C,OAAA,GAEzBL,SAAS","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/test-types.d.ts"],"sourcesContent":["/// <reference types=\"@wix/jest-yoshi-preset/types\" />\n"],"mappings":"AAAA"}
1
+ {"version":3,"names":[],"sources":["../../src/test-types.d.ts"],"sourcesContent":["/// <reference types=\"@wix/jest-yoshi-preset/types\" />\n"],"mappings":"AAAA","ignoreList":[]}