@wix/wix-data-items-common 1.0.280 → 1.0.282

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.
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/api/types.ts"],"sourcesContent":["import { WixDataFilter } from './WixDataFilter'\n\nexport interface BaseOptions {\n /**\n * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend).\n *\n * Default: `false`.\n */\n suppressHooks?: boolean\n\n /**\n * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items.\n *\n * Default: `false`.\n */\n showDrafts?: boolean\n}\n\nexport interface WithAppOptions {\n /**\n * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections).\n */\n appOptions?: Record<string, any>\n}\n\nexport interface WixDataRemoveOptions extends WixDataOptions {\n /**\n * If provided, item will be updated only if condition is met.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataBulkPatchOptions extends WixDataOptions {\n /**\n * If provided, only items matching condition will be patched.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataOptions extends BaseOptions, WithAppOptions {}\n\nexport interface WixDataReadOptions extends WixDataOptions, WithAppOptions {\n /**\n * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format.\n * If provided, the result text is returned in the specified language. If not provided, the result text is not translated.\n *\n * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual).\n *\n */\n language?: string\n\n /**\n * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is\n * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency).\n */\n consistentRead?: boolean\n}\n\nexport interface WixDataReadWithProjectionOptions\n extends WixDataReadOptions,\n ProjectionOptions {}\n\nexport interface WixDataSaveOptions extends WixDataOptions {\n /**\n * If true, referenced items are included.\n * @internal\n */\n includeReferences?: boolean\n}\n\nexport interface WixDataInsertOptions extends WixDataOptions {\n /**\n * If true, referenced items are included.\n * @internal\n */\n includeReferences?: boolean\n}\n\nexport interface WixDataUpdateOptions extends WixDataOptions {\n /**\n * If true, referenced items are included.\n * @internal\n */\n includeReferences?: boolean\n /**\n * If provided, item will be updated only if condition is met.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataBulkUpdateOptions extends WixDataOptions {\n /**\n * If provided, only items matching condition will be updated.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataBulkRemoveOptions extends WixDataOptions {\n /**\n * If provided, only items matching condition will be removed.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataPatchOptions extends BaseOptions {\n /**\n * If provided, item will be patched only if condition is met.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataAggregateOptions extends WixDataQueryOptions {}\n\nexport interface WixDataQueryOptions extends WixDataReadOptions {\n /**\n * When `true`, the query results include a `totalCount` and `totalPages` properties containing the totals of items\n * matching query. Requesting total count slows down the query.\n *\n * Default: `false`\n */\n returnTotalCount?: boolean\n}\n\nexport interface WixDataQueryReferencedOptions\n extends WixDataQueryOptions,\n ProjectionOptions {\n /**\n * Order of the returned referenced items. Sorted by the date each item was referenced.\n *\n * Default: `asc`\n */\n order?: 'asc' | 'desc'\n\n /**\n * Number of items to skip in the current sort order.\n *\n * Default: `0`\n */\n skip?: number\n\n /**\n * Number of items to load.\n *\n * Default: `50`\n */\n limit?: number\n}\n\ninterface ProjectionOptions {\n /**\n * Lists of fields to return in a result.\n */\n fields?: string[]\n}\n\nexport interface WixDataItem {\n /**\n * Data item ID.\n */\n _id: string\n\n /**\n * Date and time the item was added to the collection.\n * @readonly\n */\n _createdDate?: Date\n\n /**\n * Date and time the item was last modified. When the item is first inserted, `_createdDate` and `_updatedDate` have\n * the same value.\n * @readonly\n */\n _updatedDate?: Date\n\n /**\n * ID of the user who created the item. Can be modified with site owner permissions.\n */\n _owner?: string\n\n /**\n * Data item contents.\n */\n [key: string]: any\n}\n\nexport type WixDataItemOrId = WixDataItem | string\nexport type Comparable = string | number | Date\n\nexport interface WixDataReference {\n relationshipName: string\n left: WixDataItemOrId\n right: WixDataItemOrId\n}\n\nexport interface Provider<T> {\n get(): T | Promise<T>\n}\n\nexport interface WixDataBulkError extends Error {\n /**\n * Description of the error.\n */\n message: string\n\n /**\n * Error code.\n */\n code: string\n\n /**\n * Index of the item within the request array. Allows for correlation between request and response items.\n */\n originalIndex: number\n\n /**\n * Failed item (or ID in case of `bulkRemove()`).\n */\n item: WixDataItem | string\n}\n\nexport interface WixDataBulkResult {\n /**\n * Number of inserted items.\n */\n inserted: number\n\n /**\n * Number of updated items.\n */\n updated: number\n\n /**\n * Number of removed items.\n */\n removed: number\n\n /**\n * Number of skipped items.\n */\n skipped: number\n\n /**\n * List of errors.\n */\n errors: WixDataBulkError[]\n\n /**\n * List of IDs of inserted items.\n */\n insertedItemIds: string[]\n\n /**\n * List of IDs of updated items.\n */\n updatedItemIds: string[]\n\n /**\n * List of IDs of removed items.\n */\n removedItemIds: string[]\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../../src/api/types.ts"],"sourcesContent":["import type { QueryRequest as SDKQueryRequest, QuerySpec } from '@wix/sdk-types'\nimport { WixDataFilter } from './WixDataFilter'\n\nexport interface BaseOptions {\n /**\n * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend).\n *\n * Default: `false`.\n */\n suppressHooks?: boolean\n\n /**\n * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items.\n *\n * Default: `false`.\n */\n showDrafts?: boolean\n}\n\nexport interface WithAppOptions {\n /**\n * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections).\n */\n appOptions?: Record<string, any>\n}\n\nexport interface WixDataRemoveOptions extends WixDataOptions {\n /**\n * If provided, item will be updated only if condition is met.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataBulkPatchOptions extends WixDataOptions {\n /**\n * If provided, only items matching condition will be patched.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataOptions extends BaseOptions, WithAppOptions {}\n\nexport interface WixDataReadOptions extends WixDataOptions, WithAppOptions {\n /**\n * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format.\n * If provided, the result text is returned in the specified language. If not provided, the result text is not translated.\n *\n * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual).\n *\n */\n language?: string\n\n /**\n * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is\n * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency).\n */\n consistentRead?: boolean\n}\n\nexport interface WixDataReadWithProjectionOptions\n extends WixDataReadOptions,\n ProjectionOptions {}\n\nexport interface WixDataSaveOptions extends WixDataOptions {\n /**\n * If true, referenced items are included.\n * @internal\n */\n includeReferences?: boolean\n}\n\nexport interface WixDataInsertOptions extends WixDataOptions {\n /**\n * If true, referenced items are included.\n * @internal\n */\n includeReferences?: boolean\n}\n\nexport interface WixDataUpdateOptions extends WixDataOptions {\n /**\n * If true, referenced items are included.\n * @internal\n */\n includeReferences?: boolean\n /**\n * If provided, item will be updated only if condition is met.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataBulkUpdateOptions extends WixDataOptions {\n /**\n * If provided, only items matching condition will be updated.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataBulkRemoveOptions extends WixDataOptions {\n /**\n * If provided, only items matching condition will be removed.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataPatchOptions extends BaseOptions {\n /**\n * If provided, item will be patched only if condition is met.\n */\n condition?: WixDataFilter\n}\n\nexport interface WixDataAggregateOptions extends WixDataQueryOptions {}\n\n/**\n * WixData query specification.\n * Since WixData collections are dynamic, we allow any string field.\n * @internal\n */\nexport interface WixDataQuerySpec extends QuerySpec {\n wql: [\n {\n fields: string[]\n sort: 'BOTH'\n }\n ]\n paging: 'offset'\n}\n\n/**\n * Request object for direct query execution.\n * Extends the SDK's QueryRequest with WixData-specific fields.\n * Use this with `wixData.query(collectionName, queryRequest)` for one-shot queries.\n * @internal\n */\nexport interface WixDataQueryRequest\n extends Omit<SDKQueryRequest<WixDataItem, WixDataQuerySpec>, 'filter'> {\n /**\n * Filter object. Supports operators like `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`,\n * `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`.\n *\n * Example:\n * ```js\n * { status: 'active', age: { $gt: 25 } }\n * ```\n */\n filter?: Record<string, any>\n\n /**\n * Cursor-based paging. Use this as an alternative to offset paging.\n *\n * Example:\n * ```js\n * { limit: 10, cursor: 'abc123' }\n * ```\n */\n cursorPaging?: {\n /** Maximum number of items to return. */\n limit?: number\n /** Cursor token pointing to a page of results. */\n cursor?: string\n }\n}\n\nexport interface WixDataQueryOptions extends WixDataReadOptions {\n /**\n * When `true`, the query results include a `totalCount` and `totalPages` properties containing the totals of items\n * matching query. Requesting total count slows down the query.\n *\n * Default: `false`\n */\n returnTotalCount?: boolean\n}\n\n/**\n * Options for direct query execution.\n * @internal\n */\nexport interface WixDataDirectQueryOptions extends WixDataQueryOptions {\n /**\n * Properties for which to include referenced items in the query's results.\n * Each option specifies a field name and optional limit.\n */\n referencedItemOptions?: { fieldName: string; limit?: number }[]\n}\n\nexport interface WixDataQueryReferencedOptions\n extends WixDataQueryOptions,\n ProjectionOptions {\n /**\n * Order of the returned referenced items. Sorted by the date each item was referenced.\n *\n * Default: `asc`\n */\n order?: 'asc' | 'desc'\n\n /**\n * Number of items to skip in the current sort order.\n *\n * Default: `0`\n */\n skip?: number\n\n /**\n * Number of items to load.\n *\n * Default: `50`\n */\n limit?: number\n}\n\ninterface ProjectionOptions {\n /**\n * Lists of fields to return in a result.\n */\n fields?: string[]\n}\n\nexport interface WixDataItem {\n /**\n * Data item ID.\n */\n _id: string\n\n /**\n * Date and time the item was added to the collection.\n * @readonly\n */\n _createdDate?: Date\n\n /**\n * Date and time the item was last modified. When the item is first inserted, `_createdDate` and `_updatedDate` have\n * the same value.\n * @readonly\n */\n _updatedDate?: Date\n\n /**\n * ID of the user who created the item. Can be modified with site owner permissions.\n */\n _owner?: string\n\n /**\n * Data item contents.\n */\n [key: string]: any\n}\n\nexport type WixDataItemOrId = WixDataItem | string\nexport type Comparable = string | number | Date\n\nexport interface WixDataReference {\n relationshipName: string\n left: WixDataItemOrId\n right: WixDataItemOrId\n}\n\nexport interface Provider<T> {\n get(): T | Promise<T>\n}\n\nexport interface WixDataBulkError extends Error {\n /**\n * Description of the error.\n */\n message: string\n\n /**\n * Error code.\n */\n code: string\n\n /**\n * Index of the item within the request array. Allows for correlation between request and response items.\n */\n originalIndex: number\n\n /**\n * Failed item (or ID in case of `bulkRemove()`).\n */\n item: WixDataItem | string\n}\n\nexport interface WixDataBulkResult {\n /**\n * Number of inserted items.\n */\n inserted: number\n\n /**\n * Number of updated items.\n */\n updated: number\n\n /**\n * Number of removed items.\n */\n removed: number\n\n /**\n * Number of skipped items.\n */\n skipped: number\n\n /**\n * List of errors.\n */\n errors: WixDataBulkError[]\n\n /**\n * List of IDs of inserted items.\n */\n insertedItemIds: string[]\n\n /**\n * List of IDs of updated items.\n */\n updatedItemIds: string[]\n\n /**\n * List of IDs of removed items.\n */\n removedItemIds: string[]\n}\n"],"mappings":"","ignoreList":[]}
@@ -110,8 +110,8 @@ const codes = exports.codes = {
110
110
  QuotaExceeded: 'WD_DATABASE_QUOTA_EXCEEDED',
111
111
  QueryExecutionError: 'WD_QUERY_EXECUTION_ERROR'
112
112
  };
113
- function wixDataError(message, code, details) {
114
- return buildError(message, code, details);
113
+ function wixDataError(message, code, details, cause) {
114
+ return buildError(message, code, details, cause);
115
115
  }
116
116
  function validationError(message) {
117
117
  return buildError(message, codes.ValidationError);
@@ -125,7 +125,7 @@ function wdeValidationError(message) {
125
125
  }
126
126
  });
127
127
  }
128
- function buildError(message, code, details) {
128
+ function buildError(message, code, details, cause) {
129
129
  const ErrorConstructor = code && code !== codes.UnknownError ? WixDataError : Error;
130
130
  const error = new ErrorConstructor(message);
131
131
  if (code) {
@@ -136,6 +136,9 @@ function buildError(message, code, details) {
136
136
  // @ts-expect-error-next-line
137
137
  error.details = details;
138
138
  }
139
+ if (cause) {
140
+ error.cause = cause;
141
+ }
139
142
  return error;
140
143
  }
141
144
  class WixDataError extends Error {
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","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","typeIsStringNumberBoolOrDate","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","safeStringify","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, safeStringify } from '../utils'\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 typeIsStringNumberBoolOrDate: (operatorName: string, value: any) =>\n `WDE0045: Invalid ${operatorName} parameter value [${typeForDisplay(\n value\n )}]. Valid ${operatorName} parameter types are String, Number, Boolean 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 safeStringify(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;AAEA;AACO,MAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACtBE,2BAA2B,EAAEA,CAAA,KAC3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jE,MAAMS,gBAAgB,GACpBV,IAAI,IAAIA,IAAI,KAAKhB,KAAK,CAACI,YAAY,GAAGuB,YAAY,GAAGC,KAAK;EAC5D,MAAMC,KAAK,GAAG,IAAIH,gBAAgB,CAACjC,OAAO,CAAC;EAC3C,IAAIuB,IAAI,EAAE;IACR;IACAa,KAAK,CAACb,IAAI,GAAGA,IAAI;EACnB;EACA,IAAIC,OAAO,EAAE;IACX;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,EACZhH,IAAS,EACTmI,IAAY,EACZC,aAAqB,EAC5B;IACA,KAAK,CAAC3C,OAAO,CAAC;IAAA,KANPA,OAAe,GAAfA,OAAe;IAAA,KACfuB,IAAY,GAAZA,IAAY;IAAA,KACZhH,IAAS,GAATA,IAAS;IAAA,KACTmI,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;AAAC1I,OAAA,CAAA0I,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"names":["_utils","require","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","typeIsStringNumberBoolOrDate","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","safeStringify","codes","ItemDoesNotExist","ItemAlreadyExists","SiteInTemplateMode","UnknownError","ValidationError","CollectionDeleted","SchemaDoesNotExist","PermissionDenied","BadRequest","Unauthorized","TooManyRequests","RequestTimedOut","QuotaExceeded","QueryExecutionError","wixDataError","code","details","cause","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, safeStringify } from '../utils'\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 typeIsStringNumberBoolOrDate: (operatorName: string, value: any) =>\n `WDE0045: Invalid ${operatorName} parameter value [${typeForDisplay(\n value\n )}]. Valid ${operatorName} parameter types are String, Number, Boolean 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 safeStringify(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(\n message: string,\n code?: string,\n details?: any,\n cause?: any\n) {\n return buildError(message, code, details, cause)\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(\n message: string,\n code?: string,\n details?: any,\n cause?: any\n) {\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 if (cause) {\n error.cause = cause\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;AAEA;AACO,MAAMC,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;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KAAK,CAAC;EAM/BE,WAAWA,CAACtC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IAAA,IAAAuC,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,CACFtC,OAAe,EACfuB,IAAY,EACZhH,IAAS,EACToI,IAAY,EACZC,aAAqB,EAC5B;IACA,KAAK,CAAC5C,OAAO,CAAC;IAAA,KANPA,OAAe,GAAfA,OAAe;IAAA,KACfuB,IAAY,GAAZA,IAAY;IAAA,KACZhH,IAAS,GAATA,IAAS;IAAA,KACToI,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;AAAC3I,OAAA,CAAA2I,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -179,7 +179,7 @@ export class ApiClient {
179
179
  throw parsedError;
180
180
  }
181
181
  }
182
- throw wixDataError(messages.internalError('Unknown error.'), codes.UnknownError);
182
+ throw wixDataError(messages.internalError('Unknown error.'), codes.UnknownError, null, error);
183
183
  }
184
184
  }
185
185
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ApiClient.js","sourceRoot":"","sources":["../../../src/api/ApiClient.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,MAAM,IAAI,cAAc,EACxB,SAAS,GACV,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEzD,OAAO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,iBAAiB,CAAC,CAAC,CAAC,CAAA;YAC9D,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,CAAyB;QAEzB,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE;YACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;YAC5D,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAI,IAAa;QAC9C,IAAI;YACF,OAAO,MAAM,IAAI,EAAE,CAAA;SACpB;QAAC,OAAO,KAAc,EAAE;YACvB,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;gBACtB,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE;oBAClC,MAAM,YAAY,CAAC,QAAQ,CAAC,iBAAiB,EAAE,EAAE,SAAS,CAAC,CAAA;iBAC5D;gBACD,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;gBACpD,IAAI,WAAW,EAAE;oBACf,MAAM,WAAW,CAAA;iBAClB;aACF;YACD,MAAM,YAAY,CAChB,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,EACxC,KAAK,CAAC,YAAY,EAClB,IAAI,EACJ,KAAK,CACN,CAAA;SACF;IACH,CAAC;CACF"}
@@ -235,105 +235,6 @@ export class WixDataApi {
235
235
  },
236
236
  });
237
237
  };
238
- // --- query, count, distinct ---
239
- this.query = (collectionName) => {
240
- const ensureValidQuery = (invalidArgs) => {
241
- if (invalidArgs.length > 0) {
242
- throw wdeValidationError(messages.queryValidations.queryInvalid(collectionName, invalidArgs));
243
- }
244
- };
245
- return new WixDataQueryImpl({
246
- collectionName,
247
- onCount: async (args, params, options) => {
248
- ensureValidQuery([
249
- ...params.invalidArguments,
250
- ...apiValidator()
251
- .collectionName(collectionName)
252
- .arity('count', args, 0, 1)
253
- .options(options)
254
- .validateAndReturn(),
255
- ]);
256
- return this.trace('count', { collectionName })(async (env) => {
257
- const { totalCount } = await this.client.countDataItems({
258
- ...env,
259
- dataCollectionId: collectionName,
260
- filter: params.filterTree,
261
- ...toReadOptions(options),
262
- });
263
- return totalCount;
264
- });
265
- },
266
- onDistinct: async (args, params, field, options) => {
267
- ensureValidQuery([
268
- ...params.invalidArguments,
269
- ...apiValidator()
270
- .collectionName(collectionName)
271
- .arity('distinct', args, 1, 2)
272
- .fieldName(field)
273
- .options(options)
274
- .validateAndReturn(),
275
- ]);
276
- const order = toSort(params.orderBy).find((o) => o.fieldName === field)?.order;
277
- const fetch = (cursorOrOffset, returnTotalCount) => this.trace('distinct', { collectionName, field })(async (env) => {
278
- const { distinctValues, pagingMetadata } = await this.client.queryDistinctValues({
279
- ...env,
280
- dataCollectionId: collectionName,
281
- ...toReadOptions(options),
282
- ...toPaging(params.limitNumber, cursorOrOffset),
283
- ...(isOffset(cursorOrOffset)
284
- ? {
285
- fieldName: field,
286
- filter: params.filterTree,
287
- order,
288
- returnTotalCount,
289
- }
290
- : {}),
291
- });
292
- return [distinctValues, pagingMetadata];
293
- });
294
- const [items, paging] = await fetch(params.skipNumber, options?.returnTotalCount);
295
- return new WixDataResultImpl(items, paging, fetch, params);
296
- },
297
- onFind: async (args, params, options) => {
298
- ensureValidQuery([
299
- ...params.invalidArguments,
300
- ...apiValidator()
301
- .collectionName(collectionName)
302
- .arity('find', args, 0, 1)
303
- .options(options)
304
- .validateAndReturn(),
305
- ]);
306
- const fetch = (cursorOrOffset, returnTotalCount) => this.trace('query', { collectionName })(async (env) => {
307
- const { dataItems, pagingMetadata } = await this.client.queryDataItems({
308
- ...env,
309
- dataCollectionId: collectionName,
310
- query: {
311
- fields: params.projectedFields,
312
- ...toPaging(params.limitNumber, cursorOrOffset),
313
- ...(isOffset(cursorOrOffset)
314
- ? {
315
- filter: params.filterTree,
316
- sort: toSort(params.orderBy),
317
- }
318
- : {}),
319
- },
320
- referencedItemOptions: params.included,
321
- ...toReadOptions(options),
322
- ...(isOffset(cursorOrOffset) ? { returnTotalCount } : {}),
323
- ...(params.randomSortOptions
324
- ? {
325
- sortMode: apiTypes.SortMode.RANDOM,
326
- randomOptions: { seed: params.randomSortOptions.seed },
327
- }
328
- : {}),
329
- });
330
- return [dataItems.map(toDataItem), pagingMetadata];
331
- });
332
- const [items, paging] = await fetch(params.skipNumber, options?.returnTotalCount);
333
- return new WixDataResultImpl(items, paging, fetch, params);
334
- },
335
- });
336
- };
337
238
  this.search = (collectionName) => {
338
239
  const ensureValidQuery = (invalidArgs) => {
339
240
  if (invalidArgs.length > 0) {
@@ -728,6 +629,154 @@ export class WixDataApi {
728
629
  get filter() {
729
630
  return filterBuilder();
730
631
  }
632
+ query(collectionName, queryRequest, options) {
633
+ // Direct query execution mode
634
+ if (queryRequest !== undefined) {
635
+ return this.executeDirectQuery(collectionName, queryRequest, options);
636
+ }
637
+ // Builder mode
638
+ const ensureValidQuery = (invalidArgs) => {
639
+ if (invalidArgs.length > 0) {
640
+ throw wdeValidationError(messages.queryValidations.queryInvalid(collectionName, invalidArgs));
641
+ }
642
+ };
643
+ return new WixDataQueryImpl({
644
+ collectionName,
645
+ onCount: async (args, params, options) => {
646
+ ensureValidQuery([
647
+ ...params.invalidArguments,
648
+ ...apiValidator()
649
+ .collectionName(collectionName)
650
+ .arity('count', args, 0, 1)
651
+ .options(options)
652
+ .validateAndReturn(),
653
+ ]);
654
+ return this.trace('count', { collectionName })(async (env) => {
655
+ const { totalCount } = await this.client.countDataItems({
656
+ ...env,
657
+ dataCollectionId: collectionName,
658
+ filter: params.filterTree,
659
+ ...toReadOptions(options),
660
+ });
661
+ return totalCount;
662
+ });
663
+ },
664
+ onDistinct: async (args, params, field, options) => {
665
+ ensureValidQuery([
666
+ ...params.invalidArguments,
667
+ ...apiValidator()
668
+ .collectionName(collectionName)
669
+ .arity('distinct', args, 1, 2)
670
+ .fieldName(field)
671
+ .options(options)
672
+ .validateAndReturn(),
673
+ ]);
674
+ const order = toSort(params.orderBy).find((o) => o.fieldName === field)?.order;
675
+ const fetch = (cursorOrOffset, returnTotalCount) => this.trace('distinct', { collectionName, field })(async (env) => {
676
+ const { distinctValues, pagingMetadata } = await this.client.queryDistinctValues({
677
+ ...env,
678
+ dataCollectionId: collectionName,
679
+ ...toReadOptions(options),
680
+ ...toPaging(params.limitNumber, cursorOrOffset),
681
+ ...(isOffset(cursorOrOffset)
682
+ ? {
683
+ fieldName: field,
684
+ filter: params.filterTree,
685
+ order,
686
+ returnTotalCount,
687
+ }
688
+ : {}),
689
+ });
690
+ return [distinctValues, pagingMetadata];
691
+ });
692
+ const [items, paging] = await fetch(params.skipNumber, options?.returnTotalCount);
693
+ return new WixDataResultImpl(items, paging, fetch, params);
694
+ },
695
+ onFind: async (args, params, options) => {
696
+ ensureValidQuery([
697
+ ...params.invalidArguments,
698
+ ...apiValidator()
699
+ .collectionName(collectionName)
700
+ .arity('find', args, 0, 1)
701
+ .options(options)
702
+ .validateAndReturn(),
703
+ ]);
704
+ const fetch = (cursorOrOffset, returnTotalCount) => this.trace('query', { collectionName })(async (env) => {
705
+ const { dataItems, pagingMetadata } = await this.client.queryDataItems({
706
+ ...env,
707
+ dataCollectionId: collectionName,
708
+ query: {
709
+ fields: params.projectedFields,
710
+ ...toPaging(params.limitNumber, cursorOrOffset),
711
+ ...(isOffset(cursorOrOffset)
712
+ ? {
713
+ filter: params.filterTree,
714
+ sort: toSort(params.orderBy),
715
+ }
716
+ : {}),
717
+ },
718
+ referencedItemOptions: params.included,
719
+ ...toReadOptions(options),
720
+ ...(isOffset(cursorOrOffset) ? { returnTotalCount } : {}),
721
+ ...(params.randomSortOptions
722
+ ? {
723
+ sortMode: apiTypes.SortMode.RANDOM,
724
+ randomOptions: { seed: params.randomSortOptions.seed },
725
+ }
726
+ : {}),
727
+ });
728
+ return [dataItems.map(toDataItem), pagingMetadata];
729
+ });
730
+ const [items, paging] = await fetch(params.skipNumber, options?.returnTotalCount);
731
+ return new WixDataResultImpl(items, paging, fetch, params);
732
+ },
733
+ });
734
+ }
735
+ async executeDirectQuery(collectionName, request, options) {
736
+ const validationErrors = apiValidator()
737
+ .collectionName(collectionName)
738
+ .options(options)
739
+ .validateAndReturn();
740
+ if (validationErrors.length > 0) {
741
+ throw wdeValidationError(messages.queryValidations.queryInvalid(collectionName, validationErrors));
742
+ }
743
+ const limit = request.paging?.limit ?? request.cursorPaging?.limit;
744
+ const offset = request.paging?.offset ?? 0;
745
+ const cursor = request.cursorPaging?.cursor;
746
+ const sort = (request.sort ?? []).map((s) => ({
747
+ [s.fieldName]: s.order === 'DESC' ? 'desc' : 'asc',
748
+ }));
749
+ const referencedItemOptions = options?.referencedItemOptions?.map((inc) => ({
750
+ fieldName: inc.fieldName,
751
+ limit: inc.limit,
752
+ }));
753
+ const fetch = (cursorOrOffset, returnTotalCount) => this.trace('query', { collectionName })(async (env) => {
754
+ const { dataItems, pagingMetadata } = await this.client.queryDataItems({
755
+ ...env,
756
+ dataCollectionId: collectionName,
757
+ query: {
758
+ fields: request.fields,
759
+ ...toPaging(limit, cursorOrOffset),
760
+ ...(isOffset(cursorOrOffset)
761
+ ? {
762
+ filter: request.filter,
763
+ sort: toSort(sort),
764
+ }
765
+ : {}),
766
+ },
767
+ referencedItemOptions,
768
+ ...toReadOptions(options),
769
+ ...(isOffset(cursorOrOffset) ? { returnTotalCount } : {}),
770
+ });
771
+ return [dataItems.map(toDataItem), pagingMetadata];
772
+ });
773
+ const [items, paging] = await fetch(cursor ?? offset, options?.returnTotalCount);
774
+ return new WixDataResultImpl(items, paging, fetch, {
775
+ collectionName,
776
+ limitNumber: limit,
777
+ skipNumber: offset,
778
+ });
779
+ }
731
780
  async runBulkSave(env, collectionName, items, options, overrideExisting = true) {
732
781
  const request = {
733
782
  ...env,