@wix/wix-data-items-common 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/cjs/api/ApiClient.js +186 -0
- package/dist/cjs/api/ApiClient.js.map +1 -0
- package/dist/cjs/api/QueryBase.js +200 -0
- package/dist/cjs/api/QueryBase.js.map +1 -0
- package/dist/cjs/api/QueryValidator.js +36 -0
- package/dist/cjs/api/QueryValidator.js.map +1 -0
- package/dist/cjs/api/WixDataAggregate.js +4 -0
- package/dist/cjs/api/WixDataAggregate.js.map +1 -0
- package/dist/cjs/api/WixDataApi.js +800 -0
- package/dist/cjs/api/WixDataApi.js.map +1 -0
- package/dist/cjs/api/WixDataFilter.js +2 -0
- package/dist/cjs/api/WixDataFilter.js.map +1 -0
- package/dist/cjs/api/WixDataPatch.js +139 -0
- package/dist/cjs/api/WixDataPatch.js.map +1 -0
- package/dist/cjs/api/WixDataQuery.js +4 -0
- package/dist/cjs/api/WixDataQuery.js.map +1 -0
- package/dist/cjs/api/WixDataResult.js +4 -0
- package/dist/cjs/api/WixDataResult.js.map +1 -0
- package/dist/cjs/api/common.js +14 -0
- package/dist/cjs/api/common.js.map +1 -0
- package/dist/cjs/api/errors.js +67 -0
- package/dist/cjs/api/errors.js.map +1 -0
- package/dist/cjs/api/impl/WixDataAggregateImpl.js +193 -0
- package/dist/cjs/api/impl/WixDataAggregateImpl.js.map +1 -0
- package/dist/cjs/api/impl/WixDataQueryImpl.js +116 -0
- package/dist/cjs/api/impl/WixDataQueryImpl.js.map +1 -0
- package/dist/cjs/api/impl/WixDataResultImpl.js +111 -0
- package/dist/cjs/api/impl/WixDataResultImpl.js.map +1 -0
- package/dist/cjs/api/index.js +32 -0
- package/dist/cjs/api/index.js.map +1 -0
- package/dist/cjs/api/types.js +2 -0
- package/dist/cjs/api/types.js.map +1 -0
- package/dist/cjs/errors/base-validator.js +92 -0
- package/dist/cjs/errors/base-validator.js.map +1 -0
- package/dist/cjs/errors/errors.js +155 -0
- package/dist/cjs/errors/errors.js.map +1 -0
- package/dist/cjs/errors/index.js +15 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/errors/validations.js +91 -0
- package/dist/cjs/errors/validations.js.map +1 -0
- package/dist/cjs/external-types.d.js +2 -0
- package/dist/cjs/external-types.d.js.map +1 -0
- package/dist/cjs/filter/FilterTree.js +154 -0
- package/dist/cjs/filter/FilterTree.js.map +1 -0
- package/dist/cjs/filter/WithFilter.js +2 -0
- package/dist/cjs/filter/WithFilter.js.map +1 -0
- package/dist/cjs/filter/filterBuilder.js +53 -0
- package/dist/cjs/filter/filterBuilder.js.map +1 -0
- package/dist/cjs/filter/filterMixin.js +144 -0
- package/dist/cjs/filter/filterMixin.js.map +1 -0
- package/dist/cjs/filter/index.js +16 -0
- package/dist/cjs/filter/index.js.map +1 -0
- package/dist/cjs/index.js +120 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/sort/sortMixin.js +79 -0
- package/dist/cjs/sort/sortMixin.js.map +1 -0
- package/dist/cjs/test-types.d.js +2 -0
- package/dist/cjs/test-types.d.js.map +1 -0
- package/dist/cjs/types/api.js +4 -0
- package/dist/cjs/types/api.js.map +1 -0
- package/dist/cjs/types/data-item-types.js +46 -0
- package/dist/cjs/types/data-item-types.js.map +1 -0
- package/dist/cjs/types/error.js +2 -0
- package/dist/cjs/types/error.js.map +1 -0
- package/dist/cjs/types/index.js +16 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/base64url.js +51 -0
- package/dist/cjs/utils/base64url.js.map +1 -0
- package/dist/cjs/utils/clone.js +21 -0
- package/dist/cjs/utils/clone.js.map +1 -0
- package/dist/cjs/utils/codec.js +64 -0
- package/dist/cjs/utils/codec.js.map +1 -0
- package/dist/cjs/utils/field-key-utils.js +18 -0
- package/dist/cjs/utils/field-key-utils.js.map +1 -0
- package/dist/cjs/utils/index.js +25 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/type-utils.js +54 -0
- package/dist/cjs/utils/type-utils.js.map +1 -0
- package/dist/esm/api/ApiClient.js +174 -0
- package/dist/esm/api/ApiClient.js.map +1 -0
- package/dist/esm/api/QueryBase.js +117 -0
- package/dist/esm/api/QueryBase.js.map +1 -0
- package/dist/esm/api/QueryValidator.js +32 -0
- package/dist/esm/api/QueryValidator.js.map +1 -0
- package/dist/esm/api/WixDataAggregate.js +2 -0
- package/dist/esm/api/WixDataAggregate.js.map +1 -0
- package/dist/esm/api/WixDataApi.js +829 -0
- package/dist/esm/api/WixDataApi.js.map +1 -0
- package/dist/esm/api/WixDataFilter.js +2 -0
- package/dist/esm/api/WixDataFilter.js.map +1 -0
- package/dist/esm/api/WixDataPatch.js +134 -0
- package/dist/esm/api/WixDataPatch.js.map +1 -0
- package/dist/esm/api/WixDataQuery.js +2 -0
- package/dist/esm/api/WixDataQuery.js.map +1 -0
- package/dist/esm/api/WixDataResult.js +2 -0
- package/dist/esm/api/WixDataResult.js.map +1 -0
- package/dist/esm/api/common.js +10 -0
- package/dist/esm/api/common.js.map +1 -0
- package/dist/esm/api/errors.js +52 -0
- package/dist/esm/api/errors.js.map +1 -0
- package/dist/esm/api/impl/WixDataAggregateImpl.js +214 -0
- package/dist/esm/api/impl/WixDataAggregateImpl.js.map +1 -0
- package/dist/esm/api/impl/WixDataQueryImpl.js +119 -0
- package/dist/esm/api/impl/WixDataQueryImpl.js.map +1 -0
- package/dist/esm/api/impl/WixDataResultImpl.js +100 -0
- package/dist/esm/api/impl/WixDataResultImpl.js.map +1 -0
- package/dist/esm/api/index.js +5 -0
- package/dist/esm/api/index.js.map +1 -0
- package/dist/esm/api/types.js +2 -0
- package/dist/esm/api/types.js.map +1 -0
- package/dist/esm/errors/base-validator.js +71 -0
- package/dist/esm/errors/base-validator.js.map +1 -0
- package/dist/esm/errors/errors.js +147 -0
- package/dist/esm/errors/errors.js.map +1 -0
- package/dist/esm/errors/index.js +5 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/errors/validations.js +114 -0
- package/dist/esm/errors/validations.js.map +1 -0
- package/dist/esm/filter/FilterTree.js +148 -0
- package/dist/esm/filter/FilterTree.js.map +1 -0
- package/dist/esm/filter/WithFilter.js +2 -0
- package/dist/esm/filter/WithFilter.js.map +1 -0
- package/dist/esm/filter/filterBuilder.js +43 -0
- package/dist/esm/filter/filterBuilder.js.map +1 -0
- package/dist/esm/filter/filterMixin.js +137 -0
- package/dist/esm/filter/filterMixin.js.map +1 -0
- package/dist/esm/filter/index.js +5 -0
- package/dist/esm/filter/index.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/sort/sortMixin.js +74 -0
- package/dist/esm/sort/sortMixin.js.map +1 -0
- package/dist/esm/types/api.js +2 -0
- package/dist/esm/types/api.js.map +1 -0
- package/dist/esm/types/data-item-types.js +35 -0
- package/dist/esm/types/data-item-types.js.map +1 -0
- package/dist/esm/types/error.js +2 -0
- package/dist/esm/types/error.js.map +1 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/base64url.js +57 -0
- package/dist/esm/utils/base64url.js.map +1 -0
- package/dist/esm/utils/clone.js +18 -0
- package/dist/esm/utils/clone.js.map +1 -0
- package/dist/esm/utils/codec.js +60 -0
- package/dist/esm/utils/codec.js.map +1 -0
- package/dist/esm/utils/field-key-utils.js +14 -0
- package/dist/esm/utils/field-key-utils.js.map +1 -0
- package/dist/esm/utils/index.js +7 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/type-utils.js +40 -0
- package/dist/esm/utils/type-utils.js.map +1 -0
- package/dist/types/api/ApiClient.d.ts +30 -0
- package/dist/types/api/ApiClient.d.ts.map +1 -0
- package/dist/types/api/QueryBase.d.ts +111 -0
- package/dist/types/api/QueryBase.d.ts.map +1 -0
- package/dist/types/api/QueryValidator.d.ts +12 -0
- package/dist/types/api/QueryValidator.d.ts.map +1 -0
- package/dist/types/api/WixDataAggregate.d.ts +320 -0
- package/dist/types/api/WixDataAggregate.d.ts.map +1 -0
- package/dist/types/api/WixDataApi.d.ts +52 -0
- package/dist/types/api/WixDataApi.d.ts.map +1 -0
- package/dist/types/api/WixDataFilter.d.ts +424 -0
- package/dist/types/api/WixDataFilter.d.ts.map +1 -0
- package/dist/types/api/WixDataPatch.d.ts +80 -0
- package/dist/types/api/WixDataPatch.d.ts.map +1 -0
- package/dist/types/api/WixDataQuery.d.ts +702 -0
- package/dist/types/api/WixDataQuery.d.ts.map +1 -0
- package/dist/types/api/WixDataResult.d.ts +144 -0
- package/dist/types/api/WixDataResult.d.ts.map +1 -0
- package/dist/types/api/common.d.ts +3 -0
- package/dist/types/api/common.d.ts.map +1 -0
- package/dist/types/api/errors.d.ts +12 -0
- package/dist/types/api/errors.d.ts.map +1 -0
- package/dist/types/api/impl/WixDataAggregateImpl.d.ts +76 -0
- package/dist/types/api/impl/WixDataAggregateImpl.d.ts.map +1 -0
- package/dist/types/api/impl/WixDataQueryImpl.d.ts +72 -0
- package/dist/types/api/impl/WixDataQueryImpl.d.ts.map +1 -0
- package/dist/types/api/impl/WixDataResultImpl.d.ts +34 -0
- package/dist/types/api/impl/WixDataResultImpl.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +11 -0
- package/dist/types/api/index.d.ts.map +1 -0
- package/dist/types/api/types.d.ts +163 -0
- package/dist/types/api/types.d.ts.map +1 -0
- package/dist/types/errors/base-validator.d.ts +28 -0
- package/dist/types/errors/base-validator.d.ts.map +1 -0
- package/dist/types/errors/errors.d.ts +108 -0
- package/dist/types/errors/errors.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +5 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/errors/validations.d.ts +25 -0
- package/dist/types/errors/validations.d.ts.map +1 -0
- package/dist/types/filter/FilterTree.d.ts +56 -0
- package/dist/types/filter/FilterTree.d.ts.map +1 -0
- package/dist/types/filter/WithFilter.d.ts +470 -0
- package/dist/types/filter/WithFilter.d.ts.map +1 -0
- package/dist/types/filter/filterBuilder.d.ts +105 -0
- package/dist/types/filter/filterBuilder.d.ts.map +1 -0
- package/dist/types/filter/filterMixin.d.ts +61 -0
- package/dist/types/filter/filterMixin.d.ts.map +1 -0
- package/dist/types/filter/index.d.ts +8 -0
- package/dist/types/filter/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/sort/sortMixin.d.ts +46 -0
- package/dist/types/sort/sortMixin.d.ts.map +1 -0
- package/dist/types/types/api.d.ts +36 -0
- package/dist/types/types/api.d.ts.map +1 -0
- package/dist/types/types/data-item-types.d.ts +1448 -0
- package/dist/types/types/data-item-types.d.ts.map +1 -0
- package/dist/types/types/error.d.ts +23 -0
- package/dist/types/types/error.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/base64url.d.ts +2 -0
- package/dist/types/utils/base64url.d.ts.map +1 -0
- package/dist/types/utils/clone.d.ts +2 -0
- package/dist/types/utils/clone.d.ts.map +1 -0
- package/dist/types/utils/codec.d.ts +3 -0
- package/dist/types/utils/codec.d.ts.map +1 -0
- package/dist/types/utils/field-key-utils.d.ts +2 -0
- package/dist/types/utils/field-key-utils.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/type-utils.d.ts +11 -0
- package/dist/types/utils/type-utils.d.ts.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","apiTypes","_interopRequireWildcard","_utils","_common","_WixDataQueryImpl","_WixDataResultImpl","_WixDataAggregateImpl","_ApiClient","_errors2","_WixDataPatch","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","WixDataApi","constructor","clientFactory","allowGet","environment","gridAppId","tracer","_defineProperty2","withArgs","args","collectionName","options","apiValidator","arity","validateAndReject","trace","env","client","truncateDataItems","dataCollectionId","toOptions","itemId","dataItem","getDataItem","dataItemId","toReadOptions","fields","catch","recover","codes","ItemDoesNotExist","toDataItem","item","warnAboutBrokenFields","insertDataItem","id","_id","data","includeReferencedItems","includeReferences","saveDataItem","updateDataItem","removeDataItem","fieldUpdate","action","ACTION","SET_FIELD","fieldPath","setField","value","actionOptions","REMOVE_FIELD","INCREMENT_FIELD","incrementField","APPEND_TO_ARRAY","appendToArray","REMOVE_FROM_ARRAY","removeFromArray","Error","WixDataPatch","onRun","_args","patchParams","fieldUpdates","map","toFieldUpdateApi","result","patchDataItem","patchSet","itemIds","WixDataBulkPatch","results","bulkPatchDataItems","patchSets","toBulkResult","ensureValidQuery","invalidArgs","length","validationError","messages","queryValidations","queryInvalid","WixDataQueryImpl","onCount","params","invalidArguments","validateAndReturn","totalCount","countDataItems","filter","filterTree","onDistinct","field","_toSort$find","fieldName","order","toSort","orderBy","find","o","fetch","cursorOrOffset","returnTotalCount","distinctValues","pagingMetadata","queryDistinctValues","toPaging","limitNumber","isOffset","items","paging","skipNumber","WixDataResultImpl","onFind","dataItems","queryDataItems","query","projectedFields","sort","referencedItemOptions","included","cursor","limit","isNonEmptyString","WixDataAggregateImpl","validationErrors","aggregateValidations","aggregateInvalid","toOperation","itemFieldName","undefined","aggregateDataItems","initialFilter","aggregation","groupingFields","groupBy","operations","aggregates","resultFieldName","name","average","avg","min","max","sum","itemCount","count","finalFilter","havingTree","unwrapAggregationId","bulkRemoveOptions","bulkRemoveDataItems","dataItemIds","bulkInsertOptions","appId","runBulkSave","overrideExisting","bulkUpdateOptions","bulkUpdateDataItems","current","queryReferencedDataItems","onlyReferencedItems","holdingItem","relationshipAttribute","referenceParameter","referringItemId","referringItemFieldName","SortOrder","ASC","DESC","skip","refsOrAttr","leftOrOpts","right","refs","opts","argc","rights","asArray","relationshipName","left","references","bulkInsertDataItemReferences","dataItemReferences","referencedItemId","referenceParameters","replaceDataItemReferences","newReferencedItemIds","referenceRemoveParameters","bulkRemoveDataItemReferences","isReferenced","isReferencedDataItem","consistentRead","ApiClient","wixData","filterBuilder","request","bulkSaveDataItems","bulkInsertDataItems","ignoreCodes","fn","exports","arguments","res","suppressHooks","appOptions","showDrafts","publishPluginOptions","includeDraftItems","entries","every","kv","language","cursorPaging","offset","fieldOrder","providerOrValue","code","error","Promise","resolve","reject","hasFieldWithDollar","hasField","key","startsWith","hasFieldWithDot","includes","console","warn","errors","flatMap","_r$itemMetadata","_r$itemMetadata2","itemMetadata","success","BulkError","description","toKnownCode","originalIndex","_r$itemMetadata3","inserted","BulkActionType","INSERT","updated","UPDATE","PATCH","removed","DELETE","skipped","insertedItemIds","_r$itemMetadata4","updatedItemIds","_r$itemMetadata5","removedItemIds","_r$itemMetadata6","isObject","rest","keys","notEmpty","xOrXs","isArray"],"sources":["../../../src/api/WixDataApi.ts"],"sourcesContent":["import {\n apiValidator,\n codes,\n validationError,\n messages,\n BulkError,\n} from '../errors'\nimport { HttpApiClientFactory } from '../types/api'\nimport * as apiTypes from '../types/data-item-types'\n\nimport { hasField, isObject, isArray } from '../utils'\nimport { filterBuilder } from './common'\nimport {\n Provider,\n WixDataBulkResult,\n WixDataItem,\n WixDataItemOrId,\n WixDataOptions,\n WixDataQueryReferencedOptions,\n WixDataReadOptions,\n WixDataReadWithProjectionOptions,\n WixDataReference,\n WixDataUpdateOptions,\n} from './types'\nimport { QueryParams, WixDataQueryImpl } from './impl/WixDataQueryImpl'\nimport { WixDataQuery } from './WixDataQuery'\nimport { WixDataResultImpl, PageFetcher } from './impl/WixDataResultImpl'\nimport { WixDataAggregateImpl } from './impl/WixDataAggregateImpl'\nimport { ApiClient } from './ApiClient'\nimport { toKnownCode } from './errors'\nimport { WixDataPatch, FieldUpdate, WixDataBulkPatch } from './WixDataPatch'\nimport { WixDataAggregate } from './WixDataAggregate'\nimport { WixDataFilter } from './WixDataFilter'\nimport { WixDataResult } from './WixDataResult'\n\ntype ProvidedOpt<T> = T | undefined | Provider<T | undefined>\ntype TraceWith = (\n label: string,\n opts?: object\n) => <T>(fn: () => Promise<T>) => Promise<T>\n\nexport class WixDataApi {\n private client: ApiClient\n\n constructor(\n clientFactory: HttpApiClientFactory<any>,\n allowGet: boolean,\n private readonly environment?: apiTypes.Environment,\n private readonly gridAppId?: ProvidedOpt<string>,\n private readonly tracer?: TraceWith\n ) {\n this.client = new ApiClient(clientFactory, allowGet)\n }\n\n get wixData(): WixDataApi {\n return this\n }\n\n get filter(): WixDataFilter {\n return filterBuilder()\n }\n\n // NOTE sort method for builder is not implemented\n\n truncate = withArgs(\n async (\n args,\n collectionName: string,\n options?: WixDataOptions\n ): Promise<void> => {\n await apiValidator()\n .arity('truncate', args, 1, 2)\n .collectionName(collectionName)\n .options(options)\n .validateAndReject()\n\n return this.trace('truncate', { collectionName })(async (env) => {\n await this.client.truncateDataItems({\n ...env,\n dataCollectionId: collectionName,\n ...toOptions(options),\n })\n })\n }\n )\n\n // --- single-item methods ---\n\n get = withArgs(\n async (\n args,\n collectionName: string,\n itemId: string,\n options?: WixDataReadWithProjectionOptions\n ): Promise<WixDataItem | null> => {\n await apiValidator()\n .arity('get', args, 2, 3)\n .collectionName(collectionName)\n .itemId(itemId)\n .options(options)\n .validateAndReject()\n\n return this.trace('get', { collectionName, itemId })(async (env) => {\n const { dataItem } = await this.client\n .getDataItem({\n ...env,\n dataCollectionId: collectionName,\n dataItemId: itemId,\n ...toReadOptions(options),\n fields: options?.fields,\n })\n .catch(\n recover(codes.ItemDoesNotExist, {} as apiTypes.GetDataItemResponse)\n )\n\n return dataItem ? toDataItem(dataItem) : null\n })\n }\n )\n\n insert = withArgs(\n async (\n args,\n collectionName: string,\n item: Partial<WixDataItem>,\n options?: WixDataUpdateOptions\n ): Promise<WixDataItem> => {\n await apiValidator()\n .arity('insert', args, 2, 3)\n .collectionName(collectionName)\n .item(item, collectionName, false)\n .options(options)\n .validateAndReject()\n\n warnAboutBrokenFields(item)\n\n return this.trace('insert', { collectionName })(async (env) => {\n const { dataItem } = await this.client.insertDataItem({\n ...env,\n dataCollectionId: collectionName,\n dataItem: {\n id: item._id,\n data: item,\n },\n includeReferencedItems: options?.includeReferences,\n ...toOptions(options),\n })\n\n return toDataItem(dataItem!)\n })\n }\n )\n\n save = withArgs(\n async (\n args,\n collectionName: string,\n item: Partial<WixDataItem>,\n options?: WixDataUpdateOptions\n ): Promise<WixDataItem> => {\n await apiValidator()\n .arity('save', args, 2, 3)\n .collectionName(collectionName)\n .item(item, collectionName, false)\n .options(options)\n .validateAndReject()\n\n return this.trace('save', { collectionName })(async (env) => {\n const { dataItem } = await this.client.saveDataItem({\n ...env,\n dataCollectionId: collectionName,\n dataItem: {\n id: item._id,\n data: item,\n },\n ...toOptions(options),\n includeReferencedItems: options?.includeReferences,\n })\n return toDataItem(dataItem!)\n })\n }\n )\n\n update = withArgs(\n async (\n args,\n collectionName: string,\n item: WixDataItem,\n options?: WixDataUpdateOptions\n ) => {\n await apiValidator()\n .arity('update', args, 2, 3)\n .collectionName(collectionName)\n .item(item, collectionName, false)\n .options(options)\n .validateAndReject()\n\n return this.trace('update', { collectionName })(async (env) => {\n const { dataItem } = await this.client.updateDataItem({\n ...env,\n dataCollectionId: collectionName,\n dataItem: {\n id: item._id,\n data: item,\n },\n ...toOptions(options),\n includeReferencedItems: options?.includeReferences,\n })\n return toDataItem(dataItem!)\n })\n }\n )\n\n remove = withArgs(\n async (\n args,\n collectionName: string,\n itemId: string,\n options?: WixDataOptions\n ): Promise<WixDataItem | null> => {\n await apiValidator()\n .arity('remove', args, 2, 3)\n .collectionName(collectionName)\n .itemId(itemId)\n .options(options)\n .validateAndReject()\n\n return this.trace('remove', { collectionName, itemId })(async (env) => {\n const { dataItem } = await this.client\n .removeDataItem({\n ...env,\n dataCollectionId: collectionName,\n dataItemId: itemId,\n ...toOptions(options),\n })\n .catch(\n recover(codes.ItemDoesNotExist, {} as apiTypes.GetDataItemResponse)\n )\n return dataItem ? toDataItem(dataItem) : null\n })\n }\n )\n\n private toFieldUpdateApi = (fieldUpdate: FieldUpdate) => {\n switch (fieldUpdate.action) {\n case 'SET_FIELD':\n return {\n action: apiTypes.ACTION.SET_FIELD,\n fieldPath: fieldUpdate.fieldPath,\n setField: {\n value: fieldUpdate.actionOptions,\n },\n }\n case 'REMOVE_FIELD':\n return {\n action: apiTypes.ACTION.REMOVE_FIELD,\n fieldPath: fieldUpdate.fieldPath,\n }\n case 'INCREMENT_FIELD':\n return {\n action: apiTypes.ACTION.INCREMENT_FIELD,\n fieldPath: fieldUpdate.fieldPath,\n incrementField: {\n value: fieldUpdate.actionOptions,\n },\n }\n case 'APPEND_TO_ARRAY':\n return {\n action: apiTypes.ACTION.APPEND_TO_ARRAY,\n fieldPath: fieldUpdate.fieldPath,\n appendToArray: {\n value: fieldUpdate.actionOptions,\n },\n }\n case 'REMOVE_FROM_ARRAY':\n return {\n action: apiTypes.ACTION.REMOVE_FROM_ARRAY,\n fieldPath: fieldUpdate.fieldPath,\n removeFromArray: {\n value: fieldUpdate.actionOptions,\n },\n }\n default:\n throw new Error('Invalid patch action')\n }\n }\n\n patch = (collectionName: string, itemId: string): WixDataPatch => {\n return new WixDataPatch({\n collectionName,\n itemId,\n onRun: async (_args, patchParams, options) => {\n const fieldUpdates = patchParams.fieldUpdates.map(this.toFieldUpdateApi)\n\n return this.trace('patch', { collectionName })(async (env) => {\n const result = await this.client.patchDataItem({\n ...env,\n dataCollectionId: patchParams.collectionName,\n patchSet: {\n dataItemId: patchParams.itemId,\n fieldUpdates,\n },\n ...toOptions(options),\n })\n\n return result.dataItem ? toDataItem(result.dataItem) : null\n })\n },\n })\n }\n\n bulkPatch = (collectionName: string, itemIds: string[]): WixDataBulkPatch => {\n return new WixDataBulkPatch({\n collectionName,\n itemIds,\n onRun: async (_args, patchParams, options) => {\n const fieldUpdates = patchParams.fieldUpdates.map(this.toFieldUpdateApi)\n\n return this.trace('bulkPatch', { collectionName })(async (env) => {\n const { results } = await this.client.bulkPatchDataItems({\n ...env,\n dataCollectionId: patchParams.collectionName,\n patchSets: patchParams.itemIds.map((itemId) => ({\n dataItemId: itemId,\n fieldUpdates,\n })),\n ...toOptions(options),\n })\n\n return toBulkResult(itemIds, results!, ['WDE0073'])\n })\n },\n })\n }\n\n // --- query, count, distinct ---\n\n query = (collectionName: string): WixDataQuery => {\n const ensureValidQuery = (invalidArgs: string[]) => {\n if (invalidArgs.length > 0) {\n throw validationError(\n messages.queryValidations.queryInvalid(collectionName, invalidArgs)\n )\n }\n }\n\n return new WixDataQueryImpl({\n collectionName,\n onCount: async (args, params, options) => {\n ensureValidQuery([\n ...params.invalidArguments,\n ...apiValidator()\n .collectionName(collectionName)\n .arity('count', args, 0, 1)\n .options(options)\n .validateAndReturn(),\n ])\n\n return this.trace('count', { collectionName })(async (env) => {\n const { totalCount } = await this.client.countDataItems({\n ...env,\n dataCollectionId: collectionName,\n filter: params.filterTree,\n ...toReadOptions(options),\n })\n return totalCount!\n })\n },\n onDistinct: async (args, params, field, options) => {\n ensureValidQuery([\n ...params.invalidArguments,\n ...apiValidator()\n .collectionName(collectionName)\n .arity('distinct', args, 1, 2)\n .fieldName(field)\n .options(options)\n .validateAndReturn(),\n ])\n\n const order = toSort(params.orderBy).find(\n (o) => o.fieldName === field\n )?.order\n\n const fetch: PageFetcher<any> = (cursorOrOffset, returnTotalCount) =>\n this.trace('distinct', { collectionName, field })(async (env) => {\n const { distinctValues, pagingMetadata } =\n await this.client.queryDistinctValues({\n ...env,\n dataCollectionId: collectionName,\n ...toReadOptions(options),\n ...toPaging(params.limitNumber, cursorOrOffset),\n ...(isOffset(cursorOrOffset)\n ? {\n fieldName: field,\n filter: params.filterTree,\n order,\n returnTotalCount,\n }\n : {}),\n })\n return [distinctValues!, pagingMetadata!]\n })\n\n const [items, paging] = await fetch(\n params.skipNumber,\n options?.returnTotalCount\n )\n\n return new WixDataResultImpl(items, paging, fetch, params)\n },\n onFind: async (args, params, options) => {\n ensureValidQuery([\n ...params.invalidArguments,\n ...apiValidator()\n .collectionName(collectionName)\n .arity('find', args, 0, 1)\n .options(options)\n .validateAndReturn(),\n ])\n\n const fetch: PageFetcher = (cursorOrOffset, returnTotalCount) =>\n this.trace('query', { collectionName })(async (env) => {\n const { dataItems, pagingMetadata } =\n await this.client.queryDataItems({\n ...env,\n dataCollectionId: collectionName,\n query: {\n fields: params.projectedFields,\n ...toPaging(params.limitNumber, cursorOrOffset),\n ...(isOffset(cursorOrOffset)\n ? {\n filter: params.filterTree,\n sort: toSort(params.orderBy),\n }\n : {}),\n },\n referencedItemOptions: params.included,\n ...toReadOptions(options),\n ...(isOffset(cursorOrOffset) ? { returnTotalCount } : {}),\n })\n return [dataItems!.map(toDataItem), pagingMetadata!]\n })\n const [items, paging] = await fetch(\n params.skipNumber,\n options?.returnTotalCount\n )\n\n return new WixDataResultImpl(items, paging, fetch, params)\n },\n })\n }\n\n // NOTE find method is not implemented\n\n fetch = withArgs(\n async (\n args,\n collectionName: string,\n cursor: string,\n limit?: number,\n options?: WixDataReadOptions\n ): Promise<WixDataResult> => {\n await apiValidator()\n .arity('fetch', args, 2, 4)\n .collectionName(collectionName)\n .isNonEmptyString(cursor, 'cursor')\n .validateAndReject()\n\n const fetch: PageFetcher = (cursorOrOffset) =>\n this.trace('query', { collectionName })(async (env) => {\n const { dataItems, pagingMetadata } =\n await this.client.queryDataItems({\n ...env,\n dataCollectionId: collectionName,\n query: {\n ...toPaging(limit, cursorOrOffset),\n },\n ...toReadOptions(options),\n })\n return [dataItems!.map(toDataItem), pagingMetadata!]\n })\n const [items, paging] = await fetch(cursor)\n\n return new WixDataResultImpl(items, paging, fetch, {\n limitNumber: limit,\n collectionName,\n skipNumber: 0,\n })\n }\n )\n\n // --- aggregate ---\n\n aggregate = (collectionName: string): WixDataAggregate => {\n return new WixDataAggregateImpl({\n collectionName,\n onRun: async (args, params, options) => {\n const validationErrors = [\n ...params.invalidArguments,\n ...apiValidator()\n .arity('run', args, 0, 1)\n .collectionName(collectionName)\n .options(options)\n .validateAndReturn(),\n ]\n\n if (validationErrors.length > 0) {\n throw validationError(\n messages.aggregateValidations.aggregateInvalid(\n collectionName,\n validationErrors\n )\n )\n }\n\n const fetch: PageFetcher<Record<string, any>> = (\n cursorOrOffset,\n returnTotalCount\n ) =>\n this.trace('aggregate', { collectionName })(async (env) => {\n const toOperation = (field?: string) =>\n field ? { itemFieldName: field } : undefined\n\n const { results, pagingMetadata } =\n await this.client.aggregateDataItems({\n ...env,\n dataCollectionId: collectionName,\n ...toPaging(params.limitNumber, cursorOrOffset),\n ...toReadOptions(options),\n ...(isOffset(cursorOrOffset)\n ? {\n initialFilter: params.filterTree,\n aggregation: {\n groupingFields: params.groupBy,\n operations: params.aggregates.map((a) => ({\n resultFieldName: a.name,\n average: toOperation(a.avg),\n min: toOperation(a.min),\n max: toOperation(a.max),\n sum: toOperation(a.sum),\n itemCount: a.count ? {} : undefined,\n })),\n },\n finalFilter: params.havingTree,\n sort: toSort(params.orderBy),\n returnTotalCount,\n }\n : {}),\n })\n return [unwrapAggregationId(results!), pagingMetadata!]\n })\n\n const [items, paging] = await fetch(params.skipNumber, true)\n\n return new WixDataResultImpl(items, paging, fetch, params)\n },\n })\n }\n\n fetchAggregate = withArgs(\n async (\n args,\n collectionName: string,\n cursor: string,\n limit?: number,\n options?: WixDataReadOptions\n ) => {\n await apiValidator()\n .arity('fetchAggregate', args, 2, 4)\n .collectionName(collectionName)\n .isNonEmptyString(cursor, 'cursor')\n .validateAndReject()\n\n const fetch: PageFetcher<Record<string, any>> = (cursorOrOffset) =>\n this.trace('aggregate', { collectionName })(async (env) => {\n const { results, pagingMetadata } =\n await this.client.aggregateDataItems({\n ...env,\n dataCollectionId: collectionName,\n ...toPaging(limit, cursorOrOffset),\n ...toReadOptions(options),\n })\n return [unwrapAggregationId(results!), pagingMetadata!]\n })\n\n const [items, paging] = await fetch(cursor, true)\n\n return new WixDataResultImpl(items, paging, fetch, {\n limitNumber: limit,\n skipNumber: 0,\n collectionName,\n })\n }\n )\n\n // --- bulk methods ---\n\n bulkRemove = withArgs(\n async (\n args,\n collectionName: string,\n itemIds: string[],\n options?: WixDataOptions\n ): Promise<WixDataBulkResult> => {\n await apiValidator()\n .arity('bulkRemove', args, 2, 3)\n .collectionName(collectionName)\n .itemIds(itemIds, collectionName)\n .bulkRemoveOptions(options)\n .validateAndReject()\n\n return this.trace('bulkRemove', { collectionName })(async (env) => {\n const { results } = await this.client.bulkRemoveDataItems({\n ...env,\n dataCollectionId: collectionName,\n dataItemIds: itemIds,\n ...toOptions(options),\n })\n // Non-existing items are skipped and not reported as errors.\n return toBulkResult(itemIds, results!, ['WDE0073'])\n })\n }\n )\n\n private async runBulkSave(\n env: { environment?: apiTypes.Environment; appId?: string },\n collectionName: string,\n items: Partial<WixDataItem>[],\n options?: WixDataOptions,\n overrideExisting: boolean = true\n ): Promise<WixDataBulkResult> {\n const request: apiTypes.BulkInsertDataItemsRequest = {\n ...env,\n dataCollectionId: collectionName,\n dataItems: items.map((data) => ({\n id: data._id,\n data,\n })),\n ...toOptions(options),\n }\n const { results } = await (overrideExisting\n ? this.client.bulkSaveDataItems(request)\n : this.client.bulkInsertDataItems(request))\n const ignoreCodes = overrideExisting ? [] : ['WDE0074']\n return toBulkResult(items, results!, ignoreCodes)\n }\n\n bulkInsert = withArgs(\n async (\n args,\n collectionName: string,\n items: Partial<WixDataItem>[],\n options?: WixDataOptions & { overrideExisting?: boolean }\n ): Promise<WixDataBulkResult> => {\n await apiValidator()\n .arity('bulkInsert', args, 2, 3)\n .items(items, collectionName)\n .bulkInsertOptions(options)\n .collectionName(collectionName)\n .validateAndReject()\n\n return this.trace('bulkInsert', { collectionName, options })(\n async (appId) =>\n this.runBulkSave(\n appId,\n collectionName,\n items,\n options,\n options?.overrideExisting ?? false\n )\n )\n }\n )\n\n bulkSave = withArgs(\n async (\n args,\n collectionName: string,\n items: Partial<WixDataItem>[],\n options?: WixDataOptions\n ): Promise<WixDataBulkResult> => {\n await apiValidator()\n .arity('bulkSave', args, 2, 3)\n .bulkInsertOptions(options)\n .collectionName(collectionName)\n .items(items, collectionName)\n .validateAndReject()\n\n return this.trace('bulkSave', { collectionName })(async (env) =>\n this.runBulkSave(env, collectionName, items, options)\n )\n }\n )\n\n bulkUpdate = withArgs(\n async (\n args,\n collectionName: string,\n items: WixDataItem[],\n options?: WixDataOptions\n ): Promise<WixDataBulkResult> => {\n await apiValidator()\n .arity('bulkUpdate', args, 2, 3)\n .bulkUpdateOptions(options)\n .collectionName(collectionName)\n .items(items, collectionName)\n .validateAndReject()\n\n return this.trace('bulkUpdate', { collectionName })(async (env) => {\n const { results } = await this.client.bulkUpdateDataItems({\n ...env,\n dataCollectionId: collectionName,\n dataItems: items.map((data) => ({\n id: data._id,\n data,\n })),\n ...toOptions(options),\n })\n // Non-existing items are skipped and not reported as errors.\n return toBulkResult(items, results!, ['WDE0073'])\n })\n }\n )\n\n // --- references ---\n\n fetchReferenced = withArgs(\n async (\n args,\n collectionName: string,\n cursor: string,\n limit?: number,\n options?: WixDataReadWithProjectionOptions\n ): Promise<WixDataResult<WixDataItem | string>> => {\n await apiValidator()\n .arity('fetchReferenced', args, 2, 4)\n .isNonEmptyString(cursor, 'cursor')\n .collectionName(collectionName)\n .validateAndReject()\n\n const fetch: PageFetcher<WixDataItem | string> = (current) =>\n this.trace('fetchReferenced', { collectionName })(async (env) => {\n const { results, pagingMetadata } =\n await this.client.queryReferencedDataItems({\n ...env,\n ...toPaging(limit, current),\n ...toReadOptions(options),\n dataCollectionId: collectionName,\n fields: options?.fields,\n })\n return [onlyReferencedItems(results!), pagingMetadata!]\n })\n\n const [items, paging] = await fetch(cursor)\n return new WixDataResultImpl(items, paging, fetch, {\n collectionName,\n limitNumber: limit,\n skipNumber: 0,\n })\n }\n )\n\n queryReferenced = withArgs(\n async (\n args,\n collectionName: string,\n holdingItem: WixDataItemOrId,\n relationshipAttribute: string,\n options?: WixDataQueryReferencedOptions\n ): Promise<WixDataResult> => {\n await apiValidator()\n .arity('queryReferenced', args, 3, 4)\n .collectionName(collectionName)\n .referenceParameter(holdingItem)\n .isNonEmptyString(relationshipAttribute, 'relationshipAttribute')\n .options(options)\n .validateAndReject()\n\n const id = itemId(holdingItem)\n const fetch: PageFetcher = (cursorOrOffset, returnTotalCount) =>\n this.trace('queryReferenced', {\n collectionName,\n itemId: id,\n options,\n relationshipAttribute,\n })(async (env) => {\n const { results, pagingMetadata } =\n await this.client.queryReferencedDataItems({\n ...env,\n ...toPaging(options?.limit ?? 50, cursorOrOffset),\n ...toReadOptions(options),\n dataCollectionId: collectionName,\n fields: options?.fields,\n ...(isOffset(cursorOrOffset)\n ? {\n referringItemId: id,\n referringItemFieldName: relationshipAttribute,\n order:\n options?.order === 'asc'\n ? apiTypes.SortOrder.ASC\n : options?.order === 'desc'\n ? apiTypes.SortOrder.DESC\n : undefined,\n returnTotalCount,\n }\n : {}),\n })\n return [onlyReferencedItems(results!), pagingMetadata!]\n })\n\n const [items, paging] = await fetch(\n options?.skip ?? 0,\n options?.returnTotalCount\n )\n return new WixDataResultImpl(items, paging, fetch, {\n collectionName,\n limitNumber: options?.limit ?? 50,\n skipNumber: options?.skip ?? 0,\n })\n }\n )\n\n insertReference: {\n // overload with array of references\n (\n collectionName: string,\n refs: WixDataReference[],\n options?: WixDataOptions\n ): Promise<void>\n // overload with separate left and right(s)\n (\n collectionName: string,\n relationshipAttribute: string,\n left: WixDataItemOrId,\n right: WixDataItemOrId | WixDataItemOrId[],\n options?: WixDataOptions\n ): Promise<void>\n } = withArgs(\n async (\n args,\n collectionName: string,\n refsOrAttr: any,\n leftOrOpts?: any,\n right?: any,\n options?: any\n ) => {\n let refs: WixDataReference[]\n let opts: WixDataOptions\n let argc: [number, number]\n\n if (typeof refsOrAttr === 'string') {\n const rights: WixDataItemOrId[] = asArray(right)\n refs = rights.map((r) => ({\n relationshipName: refsOrAttr,\n left: leftOrOpts as WixDataItemOrId,\n right: r,\n }))\n opts = options\n argc = [4, 5]\n } else {\n refs = refsOrAttr\n opts = leftOrOpts\n argc = [2, 3]\n }\n await apiValidator()\n .arity('insertReference', args, ...argc)\n .collectionName(collectionName)\n .references(refs)\n .options(opts)\n .validateAndReject()\n\n await this.trace('insertReference', { collectionName })(async (env) =>\n this.client.bulkInsertDataItemReferences({\n ...env,\n dataCollectionId: collectionName,\n dataItemReferences: refs.map((r) => ({\n referringItemFieldName: r.relationshipName,\n referringItemId: itemId(r.left),\n referencedItemId: itemId(r.right),\n })),\n ...toOptions(opts),\n })\n )\n }\n )\n\n replaceReferences = withArgs(\n async (\n args,\n collectionName: string,\n relationshipAttribute: string,\n left: WixDataItemOrId,\n right: WixDataItemOrId | WixDataItemOrId[],\n options?: WixDataOptions\n ): Promise<void> => {\n const rights = asArray(right)\n await apiValidator()\n .arity('replaceReferences', args, 4, 5)\n .collectionName(collectionName)\n .isNonEmptyString(relationshipAttribute, 'relationshipAttribute')\n .referenceParameter(left)\n .referenceParameters(rights)\n .options(options)\n .validateAndReject()\n\n await this.trace('replaceReferences', {\n collectionName,\n relationshipAttribute,\n })(async (env) =>\n this.client.replaceDataItemReferences({\n ...env,\n dataCollectionId: collectionName,\n referringItemFieldName: relationshipAttribute,\n referringItemId: itemId(left),\n newReferencedItemIds: rights.map(itemId),\n ...toOptions(options),\n })\n )\n }\n )\n\n removeReference = withArgs(\n async (\n args,\n collectionName: string,\n relationshipAttribute: string,\n left: WixDataItemOrId,\n right: WixDataItemOrId | WixDataItemOrId[],\n options?: WixDataOptions\n ) => {\n const rights = asArray(right)\n await apiValidator()\n .arity('removeReference', args, 4, 5)\n .collectionName(collectionName)\n .referenceParameter(left)\n .referenceRemoveParameters(rights)\n .isNonEmptyString(relationshipAttribute, 'relationshipAttribute')\n .options(options)\n .validateAndReject()\n\n await this.trace('removeReference', {\n collectionName,\n relationshipAttribute,\n })(async (env) =>\n this.client.bulkRemoveDataItemReferences({\n ...env,\n dataCollectionId: collectionName,\n dataItemReferences: rights.map((r) => ({\n referringItemFieldName: relationshipAttribute,\n referringItemId: itemId(left),\n referencedItemId: itemId(r),\n })),\n ...toOptions(options),\n })\n )\n }\n )\n\n isReferenced = withArgs(\n async (\n args,\n collectionName: string,\n relationshipAttribute: string,\n left: WixDataItemOrId,\n right: WixDataItemOrId,\n options?: WixDataReadOptions\n ): Promise<boolean> => {\n await apiValidator()\n .arity('isReferenced', args, 4, 5)\n .collectionName(collectionName)\n .referenceParameter(left)\n .referenceParameter(right)\n .options(options)\n .validateAndReject()\n\n return this.trace('isReferenced', {\n collectionName,\n relationshipAttribute,\n })(async (env) => {\n const { isReferenced } = await this.client.isReferencedDataItem({\n ...env,\n dataCollectionId: collectionName,\n referringItemFieldName: relationshipAttribute,\n referringItemId: itemId(left),\n referencedItemId: itemId(right),\n ...toOptions(options),\n consistentRead: options?.consistentRead,\n })\n return isReferenced!\n })\n }\n )\n\n private trace(\n action: string,\n opts: object\n ): <R>(\n fn: (env: {\n environment?: apiTypes.Environment\n appId?: string\n }) => Promise<R>\n ) => Promise<R> {\n return async (fn) => {\n const gridAppId = await get(this.gridAppId)\n const env = { appId: gridAppId, environment: this.environment }\n if (this.tracer) {\n return this.tracer(`WixDataApi.${action}`, {\n ...opts,\n gridAppId,\n environment: this.environment,\n })(() => fn(env))\n }\n return fn(env)\n }\n }\n}\n\nfunction withArgs<Args extends any[], R>(\n fn: (all: IArguments, ...args: Args) => R\n): (...args: Args) => R {\n return function (...args) {\n return fn(arguments, ...args)\n }\n}\n\nfunction toOptions(opts?: WixDataOptions) {\n if (!opts) {\n return undefined\n }\n const res = {\n suppressHooks: opts.suppressHooks,\n appOptions: opts.appOptions,\n ...(opts.showDrafts !== undefined\n ? { publishPluginOptions: { includeDraftItems: opts.showDrafts } }\n : {}),\n }\n if (Object.entries(res).every((kv) => kv[1] === undefined)) {\n return undefined\n }\n return res\n}\n\nfunction toReadOptions(options?: WixDataReadOptions) {\n return {\n suppressHooks: options?.suppressHooks,\n appOptions: options?.appOptions,\n ...(options?.showDrafts !== undefined\n ? { publishPluginOptions: { includeDraftItems: options?.showDrafts } }\n : {}),\n consistentRead: options?.consistentRead,\n language: options?.language,\n }\n}\n\nfunction toDataItem(item: apiTypes.DataItem): WixDataItem {\n return item.data as WixDataItem\n}\n\nfunction toPaging(limit: number | undefined, cursorOrOffset: string | number) {\n return typeof cursorOrOffset === 'string'\n ? {\n cursorPaging: {\n limit,\n cursor: cursorOrOffset,\n },\n }\n : limit !== undefined || cursorOrOffset > 0\n ? {\n paging: {\n limit,\n offset: cursorOrOffset,\n },\n }\n : {}\n}\n\nfunction toSort(orderBy: QueryParams['orderBy']): apiTypes.Sorting[] {\n return orderBy.map((fieldOrder) => {\n const [[fieldName, sort]] = Object.entries(fieldOrder)\n const order =\n sort === 'asc'\n ? apiTypes.SortOrder.ASC\n : sort === 'desc'\n ? apiTypes.SortOrder.DESC\n : undefined\n return { fieldName, order }\n })\n}\n\nasync function get<T>(providerOrValue: T | Provider<T>): Promise<T> {\n if (typeof (providerOrValue as any)?.get === 'function') {\n return (providerOrValue as Provider<T>).get()\n }\n return providerOrValue as T\n}\n\nfunction recover<T>(code: string, value: T): (error: unknown) => Promise<T> {\n return (error) => {\n if (error instanceof Error && (error as any).code === code) {\n return Promise.resolve(value)\n }\n return Promise.reject(error)\n }\n}\n\nfunction warnAboutBrokenFields(item: Partial<WixDataItem>) {\n const hasFieldWithDollar = hasField(item, (key) => key.startsWith('$'))\n const hasFieldWithDot = hasField(item, (key) => key.includes('.'))\n if (hasFieldWithDollar) {\n console.error(\n \"Data inserted contains field name prefixed with symbol '$'. It is not recommended to use such field names as it will not work with some data operations.\"\n )\n }\n if (hasFieldWithDot) {\n console.warn(\n \"Data inserted contains field name containing symbol '.'. It is not recommended to use such field names as it will not work with some data operations.\"\n )\n }\n}\n\nfunction toBulkResult(\n request: any[],\n results: apiTypes.BulkDataItemResult[],\n ignoreCodes: string[] = []\n): WixDataBulkResult {\n const errors = results.flatMap((r) => {\n if (r.itemMetadata?.success || !r.itemMetadata?.error) {\n return []\n }\n if (ignoreCodes.includes(r.itemMetadata.error.code ?? '')) {\n return []\n }\n return [\n new BulkError(\n r.itemMetadata.error.description!,\n toKnownCode(r.itemMetadata.error.code!),\n request[r.itemMetadata.originalIndex!],\n 'BulkError',\n r.itemMetadata.originalIndex!\n ),\n ]\n })\n const success = results.filter((r) => r.itemMetadata?.success)\n const inserted = success.filter(\n (r) => r.action === apiTypes.BulkActionType.INSERT\n )\n const updated = success.filter(\n (r) =>\n r.action === apiTypes.BulkActionType.UPDATE ||\n r.action === apiTypes.BulkActionType.PATCH\n )\n const removed = success.filter(\n (r) => r.action === apiTypes.BulkActionType.DELETE\n )\n return {\n inserted: inserted.length,\n updated: updated.length,\n removed: removed.length,\n skipped: request.length - errors.length - success.length,\n errors,\n insertedItemIds: inserted.map((r) => r.itemMetadata?.id!),\n updatedItemIds: updated.map((r) => r.itemMetadata?.id!),\n removedItemIds: removed.map((r) => r.itemMetadata?.id!),\n }\n}\n\nfunction unwrapAggregationId(\n items: Record<string, any>[]\n): Record<string, any>[] {\n // When grouping by one field WixDataService returns value on _id field directly, DataItemService wraps it in an object, i.e.\n // grouping by surname returns {_id: 'Simpson'} in WixDataService vs {_id: {surname: 'Simpson'}} in DataItemService\n // When grouping by more fields, values are kept wrapped.\n return items.map((item) => {\n const id = item._id\n if (isObject(id)) {\n const [key, ...rest] = Object.keys(id)\n if (rest.length === 0) {\n item._id = id[key]\n return item\n }\n }\n return item\n })\n}\n\nfunction onlyReferencedItems(\n results: apiTypes.ReferencedResult[]\n): WixDataItem[] {\n return results\n .map((result) => result.dataItem)\n .filter(notEmpty)\n .map(toDataItem)\n}\n\nfunction notEmpty<T>(value: T | null | undefined): value is T {\n return value != null\n}\n\nfunction itemId(item: WixDataItemOrId): string {\n return typeof item === 'string' ? item : item._id\n}\n\nfunction asArray<T>(xOrXs: T | T[]): T[] {\n return isArray(xOrXs) ? (xOrXs as T[])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BAAmBA,CAC1B1F,OAAoC,EACrB;EACf,OAAOA,OAAO,CACXP,GAAG,CAAEE,MAAM,IAAKA,MAAM,CAAC5C,QAAQ,CAAC,CAChCmE,MAAM,CAAC0K,QAAQ,CAAC,CAChBnM,GAAG,CAACjC,UAAU,CAAC;AACpB;AAEA,SAASoO,QAAQA,CAAIlN,KAA2B,EAAc;EAC5D,OAAOA,KAAK,IAAI,IAAI;AACtB;AAEA,SAAS5B,MAAMA,CAACW,IAAqB,EAAU;EAC7C,OAAO,OAAOA,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACI,GAAG;AACnD;AAEA,SAAS8I,OAAOA,CAAIkF,KAAc,EAAO;EACvC,OAAO,IAAAC,cAAO,EAACD,KAAK,CAAC,GAAIA,KAAK,GAAW,CAACA,KAAK,CAAM;AACvD;AAEA,SAASxJ,QAAQA,CAACP,cAA+B,EAAE;EACjD,OAAO,OAAOA,cAAc,KAAK,QAAQ;AAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/api/WixDataFilter.ts"],"sourcesContent":["type Comparable = string | number | Date\n\n/**\n * @builder\n */\nexport interface WixDataFilter {\n /**\n * Refines a 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 filter.\n */\n eq(field: string, value: any): WixDataFilter\n\n /**\n * Refines a 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 filter.\n */\n ne(field: string, value: any): WixDataFilter\n\n /**\n * Refines a 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 filter.\n */\n ge(field: string, value: Comparable): WixDataFilter\n\n /**\n * Refines a 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 filter definition, based on the supplied parameters.\n */\n gt(field: string, value: Comparable): WixDataFilter\n\n /**\n * Refines a 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 filter.\n */\n le(field: string, value: Comparable): WixDataFilter\n\n /**\n * Refines a 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 filter definition, based on the supplied parameters.\n */\n lt(field: string, value: Comparable): WixDataFilter\n\n /**\n * Refines a 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 filter.\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 filter.\n */\n isNotEmpty(field: string): WixDataFilter\n\n /**\n * Refines a 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 filter.\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 filter.\n */\n isEmpty(field: string): WixDataFilter\n\n /**\n * Refines a 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 - The property whose value will be compared with the `value` parameter.\n * @requiredField field\n * @param value - The string to look for at the beginning of the specified property value.\n * @requiredField value\n * @returns An object representing the refined filter.\n */\n startsWith(field: string, value: string): WixDataFilter\n\n /**\n * Refines a 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 - The property whose value will be compared with the string.\n * @requiredField field\n * @param value - The string to look for at the end of the specified property value.\n * @requiredField value\n * @returns An object representing the refined filter.\n */\n endsWith(field: string, value: string): WixDataFilter\n\n /**\n * Refines a 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 filter.\n */\n contains(field: string, value: string): WixDataFilter\n\n /**\n * Refines a 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 filter.\n */\n hasSome(field: string, ...values: Comparable[]): WixDataFilter\n\n /**\n * Overload for `hasSome()`\n * @public\n * @documentationMaturity preview\n */\n hasSome(field: string, values: Comparable[]): WixDataFilter\n\n /**\n * Refines a 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 filter.\n */\n hasAll(field: string, ...values: Comparable[]): WixDataFilter\n\n /**\n * Overload for `hasAll()`\n * @public\n * @documentationMaturity preview\n */\n hasAll(field: string, values: Comparable[]): WixDataFilter\n\n /**\n * Adds an `or` condition to the filter.\n *\n * The `or()` function adds an inclusive `or` condition to this filter. A filter\n * with an `or` returns all the items that match the filter as defined up to\n * the `or` function, the items that match the filter passed to the `or`\n * function, and the items that match both.\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 - A filter to add to the initial filter as an `or` condition.\n * @requiredField filter\n * @returns An object representing the refined filter.\n */\n or(filter: WixDataFilter): WixDataFilter\n\n /**\n * Adds an `and` condition to the filter.\n *\n * The `and()` function adds an and condition to this filter. A filter with an `and` returns all the items\n * that match the filter as defined up to the `and` function and also match the filter passed to\n * the `and` function.\n *\n * Note that when chaining multiple `WixDataFilter` functions to a filter an and condition is assumed. In such cases,\n * you do not need to add a call to the `and()` function. For example, this filter returns results where status is\n * active **and** age is greater than 25.\n * ```js\n * wixClient.items.filter().eq(\"status\", \"active\").gt(\"age\", 25);\n * ```\n *\n * The `and()` function is needed when performing compound queries. For example, the final filter 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 statusFilter = wixClient.items.filter()\n * .eq(\"status\", \"pending\")\n * .or(wixClient.items.filter().eq(\"status\", \"rejected\"));\n *\n * let ageFilter = wixClient.items.filter()\n * .lt(\"age\", 25)\n * .or(wixData.items.filter().gt(\"age\", 65));\n *\n * let statusAndAgeFilter = statusFilter.and(ageFilter);\n * ```\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 filter as an `and` condition.\n * @requiredField filter\n * @returns An object representing the refined filter.\n */\n and(filter: WixDataFilter): WixDataFilter\n\n /**\n * Adds a `not` condition to the filter.\n *\n * The `not()` function adds a `not` condition to this filter. A filter with a `not`\n * returns all the items that match the filter as defined up to the `not`\n * function, but don't match the filter passed to the `not` function.\n *\n * If the filter only contains a `not()` function, it returns all the items\n * that don't match the filter defined by the `not` method.\n *\n * @public\n * @documentationMaturity preview\n * @param filter - A filter to add to the initial filter as a `not` condition.\n * @requiredField filter\n * @returns An object representing the refined filter.\n */\n not(filter: WixDataFilter): WixDataFilter\n\n /**\n * Refines a filter to match items whose specified property value is within a specified range.\n *\n * The `between()` function refines this filter 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 filter.\n */\n between<T extends Comparable>(\n field: string,\n rangeStart: T,\n rangeEnd: T\n ): WixDataFilter\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.WixDataPatch = exports.WixDataBulkPatch = exports.PatchValidator = void 0;
|
|
6
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
|
+
var _errors = require("../errors");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
class WixDataPatchBase {
|
|
10
|
+
constructor(origin) {
|
|
11
|
+
(0, _defineProperty2.default)(this, "fieldUpdates", void 0);
|
|
12
|
+
(0, _defineProperty2.default)(this, "collectionName", void 0);
|
|
13
|
+
(0, _defineProperty2.default)(this, "ownInvalidArguments", void 0);
|
|
14
|
+
this.ownInvalidArguments = origin.invalidArguments ?? [];
|
|
15
|
+
this.fieldUpdates = origin.fieldUpdates ?? [];
|
|
16
|
+
this.collectionName = origin.collectionName;
|
|
17
|
+
}
|
|
18
|
+
incrementField(fieldName, by) {
|
|
19
|
+
const [invalidArguments] = this.patchValidator('.incrementField').arityIsTwo(arguments).isNumber(fieldName, by).validateAndAggregate();
|
|
20
|
+
return this.copy({
|
|
21
|
+
invalidArguments,
|
|
22
|
+
addFieldUpdate: {
|
|
23
|
+
fieldPath: fieldName,
|
|
24
|
+
action: 'INCREMENT_FIELD',
|
|
25
|
+
actionOptions: by
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
setField(fieldName, value) {
|
|
30
|
+
const [invalidArguments] = this.patchValidator('.setField').arityIsTwo(arguments).validateAndAggregate();
|
|
31
|
+
return this.copy({
|
|
32
|
+
invalidArguments,
|
|
33
|
+
addFieldUpdate: {
|
|
34
|
+
fieldPath: fieldName,
|
|
35
|
+
action: 'SET_FIELD',
|
|
36
|
+
actionOptions: value
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
appendToArray(fieldName, value) {
|
|
41
|
+
const [invalidArguments] = this.patchValidator('.appendToArray').arityIsTwo(arguments).validateAndAggregate();
|
|
42
|
+
return this.copy({
|
|
43
|
+
invalidArguments,
|
|
44
|
+
addFieldUpdate: {
|
|
45
|
+
fieldPath: fieldName,
|
|
46
|
+
action: 'APPEND_TO_ARRAY',
|
|
47
|
+
actionOptions: value
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
removeFromArray(fieldName, value) {
|
|
52
|
+
const [invalidArguments] = this.patchValidator('.removeFromArray').arityIsTwo(arguments).validateAndAggregate();
|
|
53
|
+
return this.copy({
|
|
54
|
+
invalidArguments,
|
|
55
|
+
addFieldUpdate: {
|
|
56
|
+
fieldPath: fieldName,
|
|
57
|
+
action: 'REMOVE_FROM_ARRAY',
|
|
58
|
+
actionOptions: value
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
removeField(fieldName) {
|
|
63
|
+
const [invalidArguments] = this.patchValidator('.removeField').arityIsTwo(arguments).validateAndAggregate();
|
|
64
|
+
return this.copy({
|
|
65
|
+
invalidArguments,
|
|
66
|
+
addFieldUpdate: {
|
|
67
|
+
fieldPath: fieldName,
|
|
68
|
+
action: 'REMOVE_FIELD'
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
patchValidator(operatorName) {
|
|
73
|
+
return new PatchValidator(operatorName, this.ownInvalidArguments);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class WixDataBulkPatch extends WixDataPatchBase {
|
|
77
|
+
constructor(origin) {
|
|
78
|
+
super(origin);
|
|
79
|
+
(0, _defineProperty2.default)(this, "onRun", void 0);
|
|
80
|
+
(0, _defineProperty2.default)(this, "itemIds", void 0);
|
|
81
|
+
this.onRun = origin.onRun;
|
|
82
|
+
this.itemIds = origin.itemIds;
|
|
83
|
+
}
|
|
84
|
+
copy(params) {
|
|
85
|
+
return new WixDataBulkPatch({
|
|
86
|
+
...this,
|
|
87
|
+
invalidArguments: params.invalidArguments ?? this.ownInvalidArguments,
|
|
88
|
+
fieldUpdates: [...this.fieldUpdates, ...[params.addFieldUpdate]],
|
|
89
|
+
onRun: this.onRun
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
run(options) {
|
|
93
|
+
return this.onRun(arguments, {
|
|
94
|
+
collectionName: this.collectionName,
|
|
95
|
+
itemIds: this.itemIds,
|
|
96
|
+
invalidArguments: this.ownInvalidArguments,
|
|
97
|
+
fieldUpdates: this.fieldUpdates
|
|
98
|
+
}, options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.WixDataBulkPatch = WixDataBulkPatch;
|
|
102
|
+
class WixDataPatch extends WixDataPatchBase {
|
|
103
|
+
constructor(origin) {
|
|
104
|
+
super(origin);
|
|
105
|
+
(0, _defineProperty2.default)(this, "onRun", void 0);
|
|
106
|
+
(0, _defineProperty2.default)(this, "itemId", void 0);
|
|
107
|
+
this.onRun = origin.onRun;
|
|
108
|
+
this.itemId = origin.itemId;
|
|
109
|
+
}
|
|
110
|
+
copy(params) {
|
|
111
|
+
return new WixDataPatch({
|
|
112
|
+
...this,
|
|
113
|
+
invalidArguments: params.invalidArguments ?? this.ownInvalidArguments,
|
|
114
|
+
fieldUpdates: [...this.fieldUpdates, ...[params.addFieldUpdate]],
|
|
115
|
+
onRun: this.onRun
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
run(options) {
|
|
119
|
+
return this.onRun(arguments, {
|
|
120
|
+
collectionName: this.collectionName,
|
|
121
|
+
itemId: this.itemId,
|
|
122
|
+
invalidArguments: this.ownInvalidArguments,
|
|
123
|
+
fieldUpdates: this.fieldUpdates
|
|
124
|
+
}, options);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.WixDataPatch = WixDataPatch;
|
|
128
|
+
class PatchValidator extends _errors.AggregatingValidator {
|
|
129
|
+
constructor(operatorName, previousInvalidArguments) {
|
|
130
|
+
super(previousInvalidArguments);
|
|
131
|
+
this.operatorName = operatorName;
|
|
132
|
+
this.operatorName = operatorName;
|
|
133
|
+
}
|
|
134
|
+
isNumber(specifier, operand) {
|
|
135
|
+
return this.addValidation(() => (0, _utils.isNumber)(operand), () => _errors.messages.queryValidations.isNumber(this.operatorName, specifier, operand));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.PatchValidator = PatchValidator;
|
|
139
|
+
//# sourceMappingURL=WixDataPatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_utils","WixDataPatchBase","constructor","origin","_defineProperty2","default","ownInvalidArguments","invalidArguments","fieldUpdates","collectionName","incrementField","fieldName","by","patchValidator","arityIsTwo","arguments","isNumber","validateAndAggregate","copy","addFieldUpdate","fieldPath","action","actionOptions","setField","value","appendToArray","removeFromArray","removeField","operatorName","PatchValidator","WixDataBulkPatch","onRun","itemIds","params","run","options","exports","WixDataPatch","itemId","AggregatingValidator","previousInvalidArguments","specifier","operand","addValidation","messages","queryValidations"],"sources":["../../../src/api/WixDataPatch.ts"],"sourcesContent":["import { WixDataOptions, WixDataItem, WixDataBulkResult } from './types'\nimport { AggregatingValidator, messages } from '../errors'\nimport { isNumber } from '../utils'\n\nexport interface FieldUpdate {\n fieldPath: string\n action:\n | 'SET_FIELD'\n | 'REMOVE_FIELD'\n | 'INCREMENT_FIELD'\n | 'APPEND_TO_ARRAY'\n | 'REMOVE_FROM_ARRAY'\n actionOptions?: any\n}\n\ninterface BulkPatchParams {\n collectionName: string\n itemIds: string[]\n invalidArguments: string[]\n fieldUpdates: FieldUpdate[]\n}\n\ninterface PatchParams {\n collectionName: string\n itemId: string\n invalidArguments: string[]\n fieldUpdates: FieldUpdate[]\n}\n\ntype OnRun = (\n args: IArguments,\n params: PatchParams,\n options?: WixDataOptions\n) => Promise<WixDataItem | null>\n\ntype OnBulkRun = (\n args: IArguments,\n params: BulkPatchParams,\n options?: WixDataOptions\n) => Promise<WixDataBulkResult>\n\nabstract class WixDataPatchBase<Self> {\n protected readonly fieldUpdates: FieldUpdate[]\n protected readonly collectionName: string\n protected readonly ownInvalidArguments: string[]\n\n constructor(origin: {\n collectionName: string\n invalidArguments?: string[]\n fieldUpdates?: FieldUpdate[]\n }) {\n this.ownInvalidArguments = origin.invalidArguments ?? []\n this.fieldUpdates = origin.fieldUpdates ?? []\n this.collectionName = origin.collectionName\n }\n\n protected abstract copy(params: {\n invalidArguments?: string[]\n addFieldUpdate: FieldUpdate\n }): Self\n\n incrementField(fieldName: string, by: number): Self {\n const [invalidArguments] = this.patchValidator('.incrementField')\n .arityIsTwo(arguments)\n .isNumber(fieldName, by)\n .validateAndAggregate()\n\n return this.copy({\n invalidArguments,\n addFieldUpdate: {\n fieldPath: fieldName,\n action: 'INCREMENT_FIELD',\n actionOptions: by,\n },\n })\n }\n\n setField(fieldName: string, value: any): Self {\n const [invalidArguments] = this.patchValidator('.setField')\n .arityIsTwo(arguments)\n .validateAndAggregate()\n\n return this.copy({\n invalidArguments,\n addFieldUpdate: {\n fieldPath: fieldName,\n action: 'SET_FIELD',\n actionOptions: value,\n },\n })\n }\n\n appendToArray(fieldName: string, value: any): Self {\n const [invalidArguments] = this.patchValidator('.appendToArray')\n .arityIsTwo(arguments)\n .validateAndAggregate()\n\n return this.copy({\n invalidArguments,\n addFieldUpdate: {\n fieldPath: fieldName,\n action: 'APPEND_TO_ARRAY',\n actionOptions: value,\n },\n })\n }\n\n removeFromArray(fieldName: string, value: any): Self {\n const [invalidArguments] = this.patchValidator('.removeFromArray')\n .arityIsTwo(arguments)\n .validateAndAggregate()\n\n return this.copy({\n invalidArguments,\n addFieldUpdate: {\n fieldPath: fieldName,\n action: 'REMOVE_FROM_ARRAY',\n actionOptions: value,\n },\n })\n }\n\n removeField(fieldName: string): Self {\n const [invalidArguments] = this.patchValidator('.removeField')\n .arityIsTwo(arguments)\n .validateAndAggregate()\n\n return this.copy({\n invalidArguments,\n addFieldUpdate: {\n fieldPath: fieldName,\n action: 'REMOVE_FIELD',\n },\n })\n }\n\n private patchValidator(operatorName: string) {\n return new PatchValidator(operatorName, this.ownInvalidArguments)\n }\n}\n\nexport class WixDataBulkPatch extends WixDataPatchBase<WixDataBulkPatch> {\n private readonly onRun: OnBulkRun\n readonly itemIds: string[]\n\n constructor(origin: {\n collectionName: string\n itemIds: string[]\n invalidArguments?: string[]\n fieldUpdates?: FieldUpdate[]\n onRun: OnBulkRun\n }) {\n super(origin)\n this.onRun = origin.onRun\n this.itemIds = origin.itemIds\n }\n\n protected copy(params: {\n invalidArguments?: string[]\n addFieldUpdate: FieldUpdate\n }): WixDataBulkPatch {\n return new WixDataBulkPatch({\n ...this,\n invalidArguments: params.invalidArguments ?? this.ownInvalidArguments,\n fieldUpdates: [...this.fieldUpdates, ...[params.addFieldUpdate]],\n onRun: this.onRun,\n })\n }\n\n run(options?: WixDataOptions): Promise<WixDataBulkResult> {\n return this.onRun(\n arguments,\n {\n collectionName: this.collectionName,\n itemIds: this.itemIds,\n invalidArguments: this.ownInvalidArguments,\n fieldUpdates: this.fieldUpdates,\n },\n options\n )\n }\n}\n\nexport class WixDataPatch extends WixDataPatchBase<WixDataPatch> {\n private readonly onRun: OnRun\n readonly itemId: string\n\n constructor(origin: {\n collectionName: string\n itemId: string\n invalidArguments?: string[]\n fieldUpdates?: FieldUpdate[]\n onRun: OnRun\n }) {\n super(origin)\n this.onRun = origin.onRun\n this.itemId = origin.itemId\n }\n\n protected copy(params: {\n invalidArguments?: string[]\n addFieldUpdate: FieldUpdate\n }): WixDataPatch {\n return new WixDataPatch({\n ...this,\n invalidArguments: params.invalidArguments ?? this.ownInvalidArguments,\n fieldUpdates: [...this.fieldUpdates, ...[params.addFieldUpdate]],\n onRun: this.onRun,\n })\n }\n\n run(options?: WixDataOptions): Promise<WixDataItem | null> {\n return this.onRun(\n arguments,\n {\n collectionName: this.collectionName,\n itemId: this.itemId,\n invalidArguments: this.ownInvalidArguments,\n fieldUpdates: this.fieldUpdates,\n },\n options\n )\n }\n}\n\nexport class PatchValidator extends AggregatingValidator {\n constructor(public operatorName: string, previousInvalidArguments: string[]) {\n super(previousInvalidArguments)\n this.operatorName = operatorName\n }\n\n isNumber(specifier: string, operand: any) {\n return this.addValidation(\n () => isNumber(operand),\n () =>\n messages.queryValidations.isNumber(\n this.operatorName,\n specifier,\n operand\n )\n )\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAuCA,MAAeE,gBAAgB,CAAO;EAKpCC,WAAWA,CAACC,MAIX,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACD,IAAI,CAACC,mBAAmB,GAAGH,MAAM,CAACI,gBAAgB,IAAI,EAAE;IACxD,IAAI,CAACC,YAAY,GAAGL,MAAM,CAACK,YAAY,IAAI,EAAE;IAC7C,IAAI,CAACC,cAAc,GAAGN,MAAM,CAACM,cAAc;EAC7C;EAOAC,cAAcA,CAACC,SAAiB,EAAEC,EAAU,EAAQ;IAClD,MAAM,CAACL,gBAAgB,CAAC,GAAG,IAAI,CAACM,cAAc,CAAC,iBAAiB,CAAC,CAC9DC,UAAU,CAACC,SAAS,CAAC,CACrBC,QAAQ,CAACL,SAAS,EAAEC,EAAE,CAAC,CACvBK,oBAAoB,CAAC,CAAC;IAEzB,OAAO,IAAI,CAACC,IAAI,CAAC;MACfX,gBAAgB;MAChBY,cAAc,EAAE;QACdC,SAAS,EAAET,SAAS;QACpBU,MAAM,EAAE,iBAAiB;QACzBC,aAAa,EAAEV;MACjB;IACF,CAAC,CAAC;EACJ;EAEAW,QAAQA,CAACZ,SAAiB,EAAEa,KAAU,EAAQ;IAC5C,MAAM,CAACjB,gBAAgB,CAAC,GAAG,IAAI,CAACM,cAAc,CAAC,WAAW,CAAC,CACxDC,UAAU,CAACC,SAAS,CAAC,CACrBE,oBAAoB,CAAC,CAAC;IAEzB,OAAO,IAAI,CAACC,IAAI,CAAC;MACfX,gBAAgB;MAChBY,cAAc,EAAE;QACdC,SAAS,EAAET,SAAS;QACpBU,MAAM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II,YAAY,CAAC;MACtB,GAAG,IAAI;MACP9B,gBAAgB,EAAE0B,MAAM,CAAC1B,gBAAgB,IAAI,IAAI,CAACD,mBAAmB;MACrEE,YAAY,EAAE,CAAC,GAAG,IAAI,CAACA,YAAY,EAAE,GAAG,CAACyB,MAAM,CAACd,cAAc,CAAC,CAAC;MAChEY,KAAK,EAAE,IAAI,CAACA;IACd,CAAC,CAAC;EACJ;EAEAG,GAAGA,CAACC,OAAwB,EAA+B;IACzD,OAAO,IAAI,CAACJ,KAAK,CACfhB,SAAS,EACT;MACEN,cAAc,EAAE,IAAI,CAACA,cAAc;MACnC6B,MAAM,EAAE,IAAI,CAACA,MAAM;MACnB/B,gBAAgB,EAAE,IAAI,CAACD,mBAAmB;MAC1CE,YAAY,EAAE,IAAI,CAACA;IACrB,CAAC,EACD2B,OACF,CAAC;EACH;AACF;AAACC,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAEM,MAAMR,cAAc,SAASU,4BAAoB,CAAC;EACvDrC,WAAWA,CAAQ0B,YAAoB,EAAEY,wBAAkC,EAAE;IAC3E,KAAK,CAACA,wBAAwB,CAAC;IAAA,KADdZ,YAAoB,GAApBA,YAAoB;IAErC,IAAI,CAACA,YAAY,GAAGA,YAAY;EAClC;EAEAZ,QAAQA,CAACyB,SAAiB,EAAEC,OAAY,EAAE;IACxC,OAAO,IAAI,CAACC,aAAa,CACvB,MAAM,IAAA3B,eAAQ,EAAC0B,OAAO,CAAC,EACvB,MACEE,gBAAQ,CAACC,gBAAgB,CAAC7B,QAAQ,CAChC,IAAI,CAACY,YAAY,EACjBa,SAAS,EACTC,OACF,CACJ,CAAC;EACH;AACF;AAACN,OAAA,CAAAP,cAAA,GAAAA,cAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/api/WixDataQuery.ts"],"sourcesContent":["import { WixDataQueryOptions, WixDataReadOptions } from './types'\nimport { WixDataResult } from './WixDataResult'\nimport { WixDataFilter } from './WixDataFilter'\n\ntype Comparable = string | number | Date\n\n/**\n * @builder\n */\nexport interface WixDataQuery {\n /**\n * Adds a sort to a query or sort, sorting by the specified properties in descending order.\n *\n * The `descending()` function refines this query to sort in descending order of the specified properties. If you\n * specify more than one property, descending() sorts the results in descending order by each property in the order\n * they are listed.\n *\n * You can sort the following types:\n *\n * Number: Sorts numerically.\n * - Date: Sorts by date and time.\n * - String: Sorts lexicographically, so `\"abc\"` comes before `\"XYZ\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * If a property contains a number as a String, that value will be sorted alphabetically and not numerically. Items\n * that do not have a value for the specified sort property are ranked lowest.\n * @public\n * @documentationMaturity preview\n * @param fields - The properties used in the sort.\n * @requiredField fields\n * @returns An object representing the refined query.\n */\n descending(...fields: string[]): WixDataQuery\n\n descending(fields: string[]): WixDataQuery\n\n descending(...fields: any): WixDataQuery\n\n /**\n * Adds a sort to a query or sort, sorting by the specified properties in ascending order.\n *\n * The `ascending()` function refines this query in ascending order of the specified properties. If you specify more\n * than one property, ascending() sorts the results in ascending order by each property in the order they are listed.\n *\n * You can sort the following types:\n * - Number: Sorts numerically.\n * - Date: Sorts by date and time.\n * - String: Sorts lexicographically, so `\"abc\"` comes after `\"XYZ\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n *\n * If a property contains a number as a String, that value will be sorted alphabetically and not numerically.\n * Items that do not have a value for the specified sort property are ranked lowest.\n * @public\n * @documentationMaturity preview\n * @param fields - The properties used in the sort.\n * @requiredField fields\n * @returns An object representing the refined query.\n */\n ascending(...fields: string[]): WixDataQuery\n\n ascending(fields: string[]): WixDataQuery\n\n ascending(...fields: any): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value equals the specified value.\n *\n * The `eq()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value does not equal the specified value.\n *\n * The `ne()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value is greater than or equal to the specified\n * value.\n *\n * The `ge()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value is greater than the specified value.\n *\n * The `gt()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value is less than or equal to the specified\n * value.\n *\n * The `le()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value is less than the specified value.\n *\n * The `lt()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property has any value.\n *\n * The `isNotEmpty()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property does not exist or does not have any value.\n *\n * The `isEmpty()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value starts with a specified string.\n *\n * The `startsWith()` function refines this query 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 - The property whose value will be compared with the `value` parameter.\n * @requiredField field\n * @param value - The string to look for at the beginning of the specified property value.\n * @requiredField value\n * @returns A `WixDataQuery` object representing the refined query.\n */\n startsWith(field: string, value: string): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value ends with a specified string.\n *\n * The `endsWith()` function refines this query 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 - The property whose value will be compared with the string.\n * @requiredField field\n * @param value - The string to look for at the end of the specified property value.\n * @requiredField value\n * @returns A `WixDataQuery` object representing the refined query.\n */\n endsWith(field: string, value: string): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value contains a specified string.\n *\n * The `contains()` function refines this query 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): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property value equals any of the specified `values`\n * parameters.\n *\n * The `hasSome()` function refines this query 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[]): WixDataQuery\n\n /**\n * Overload for `hasSome()`\n * @public\n * @documentationMaturity preview\n */\n hasSome(field: string, values: Comparable[]): WixDataQuery\n\n /**\n * Refines a query to match items whose specified property values equals all of the specified `value`\n * parameters.\n *\n * The `hasAll()` function refines this query 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[]): WixDataQuery\n\n /**\n * Overload for `hasAll()`\n * @public\n * @documentationMaturity preview\n */\n hasAll(field: string, values: Comparable[]): WixDataQuery\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 '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 - A filter to add to the initial filter as an `or` condition.\n * @requiredField filter\n * @returns An object representing the refined query.\n */\n or(filter: WixDataFilter): WixDataQuery\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 * wixClient.items.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 = wixClient.items\n * .query(\"myCollection\")\n * .eq(\"status\", \"pending\")\n * .or(wixClient.items.filter().eq(\"status\", \"rejected\"));\n *\n * let ageQuery = wixClient.items\n * .filter()\n * .lt(\"age\", 25)\n * .or(wixClient.items.filter().gt(\"age\", 65));\n *\n * let statusAndAgeQuery = statusQuery.and(ageQuery);\n * ```\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: WixDataFilter): WixDataQuery\n\n /**\n * Adds a `not` condition to the query or filter.\n *\n * The `not()` function adds a `not` condition to this query. A query with a `not`\n * returns all the items that match the query as defined up to the `not`\n * function, but don't match the filter passed to the `not` function.\n *\n * If the query only contains a `not()` function, it returns all the items\n * that don't match the filter defined by the `not` method.\n *\n * @public\n * @documentationMaturity preview\n * @param filter - A filter to add to the initial filter as a `not` condition.\n * @requiredField filter\n * @returns An object representing the refined query.\n */\n not(filter: WixDataFilter): WixDataQuery\n\n /**\n * Refines a query 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>(\n field: string,\n rangeStart: T,\n rangeEnd: T\n ): WixDataQuery\n\n /**\n * Returns the number of items that match the query.\n *\n * The `count()` function returns a Promise that resolves to the number of\n * items that match the query. The Promise is rejected if `count()` is called\n * with incorrect permissions or if any of the functions used to refine the\n * query is invalid.\n *\n * Calling the `count()` function triggers the `beforeCount()` and `afterCount()` hooks if they have been defined.\n *\n * Use the `options` parameter to run `count()` without checking for permissions\n * or without its registered hooks.\n *\n * Any function that does not filter query results (e.g., [`ascending()`](#ascending))\n * does not affect the result of `count()`.\n *\n * If you build a query and don't refine it with any `WixDataQuery` functions,\n * `count()` returns the total number of items in the collection.\n *\n * If you have already run a query with `find()`, you can retrieve the number of query results without calling\n * `count()`.\n * @public\n * @documentationMaturity preview\n * @param options - An object containing options to use when processing this operation.\n * @returns The number of items that match the query.\n */\n count(options?: WixDataReadOptions): Promise<number>\n\n /**\n * Returns the distinct values that match the query, without duplicates.\n *\n * The `distinct()` function returns a Promise that resolves to:\n * - The distinct values found in the specified field when running the query.\n * - Additional information about the results, such as the number of values that match the query.\n *\n * Unlike `find()`, which returns all item objects that match the query, `distinct()` returns matching field values,\n * and eliminates duplicate field values from the query result. You cannot use `find()` and `distinct()` together.\n *\n * For an item to be resolved as distinct, only the specified field must be distinct. Other fields for that item in\n * the collection are not evaluated when resolving the promise.\n *\n * The Promise is rejected if `distinct()` is called with incorrect permissions or if any of the\n * functions used to refine the query is invalid.\n *\n * >**Note:** Only site visitors with [Data Read](https://support.wix.com/en/article/collection-permissions-an-overview#permissions)\n * permissions can retrieve and view data. You can override the permissions in backend code by setting the\n * `suppressAuth` option to `true`.\n * @public\n * @documentationMaturity preview\n * @param field - The property whose value will be compared for distinct values.\n * @requiredField field\n * @param options - An object containing options to use when processing this operation.\n * @returns A Promise that resolves to the results of the query.\n */\n distinct(\n field: string,\n options?: WixDataQueryOptions\n ): Promise<WixDataResult<any>>\n\n /**\n * Returns the items that match the query.\n *\n * The `find()` function returns a Promise that resolves to the results found\n * by the query and some information about the results. The Promise is\n * rejected if `find()` is called with incorrect permissions or if any of the\n * functions used to refine the query is invalid.\n *\n * Calling the `find()` function triggers the `beforeQuery()` and `afterQuery()` hooks if they have been defined.\n *\n * > **Note:**\n * > Calling `find()` triggers hooks for the specified collection only. It doesn't trigger hooks for referenced\n * > collections.\n *\n * Use the `options` parameter to override default preferences:\n * - Override permission checks with `suppressAuth`.\n * - Ensure the most up-to-date data is retrieved with `consistentRead`.\n * - Prevent hooks from running with `suppressHooks`.\n * - Speed up execution with `omitTotalCount`, if you don't need a count of items matching the query.\n *\n * If you build a query and don't refine it with any `wixDataQuery` functions,\n * `find()` returns the entire collection.\n * @public\n * @documentationMaturity preview\n * @param options - An object containing options to use when processing this operation.\n * @returns A Promise that resolves to the results of the query.\n */\n find(options?: WixDataQueryOptions): Promise<WixDataResult>\n\n /**\n * Lists the fields to return in a query's results.\n *\n * The `fields()` function returns only the specified fields in the query's results.\n *\n * You can use `include()` in conjunction with `fields()` to get referenced items.\n *\n * When `fields()` receives an empty or invalid property, the query behaves as follows:\n * - When no fields are specified, the query returns all fields.\n * - When multiple fields are specified but some are invalid, invalid fields are ignored and valid fields are returned.\n * - When only invalid fields are specified, only the default `_id` field is returned.\n * @public\n * @documentationMaturity preview\n * @param fields - Properties to return.\n * @requiredField fields\n * @returns A `WixDataQuery` object representing the query.\n */\n fields(...fields: string[]): WixDataQuery\n\n /**\n * Limits the number of items the query returns.\n *\n * The `limit()` function defines the number of results a query returns in each\n * page. Only one page of results is retrieved at a time. The `next()`\n * and `prev()` functions are used to\n * navigate the pages of a query result.\n *\n * By default, `limit` is set to `50`.\n *\n * The maximum value that `limit()` can accept is `1000`.\n *\n * Note that for some Wix app collections, the maximum value `limit()` can accept is\n * less than `1000`. For example, the maximum limit for the Wix `Stores/Product` collection is 100.\n * @public\n * @documentationMaturity preview\n * @param limitNumber - The number of items to return, which is also the `pageSize` of the results object.\n * @requiredField limitNumber\n * @returns A `WixDataQuery` object representing the refined query.\n */\n limit(limitNumber: number): WixDataQuery\n\n /**\n * Sets the number of items to skip before returning query results.\n *\n * The `skip()` function defines the number of results to skip in the query\n * results before returning new query results.\n *\n * For example, if you query a collection and 50 items match your query, but\n * you set `skip` to 10, the results returned will skip the first 10 items\n * that match and return the 11th through 50th items.\n *\n * By default, `skip` is set to 0.\n * @public\n * @documentationMaturity preview\n * @param skipNumber - The number of items to skip in the query results before returning the results.\n * @requiredField skipNumber\n * @returns A `WixDataQuery` object representing the refined query.\n */\n skip(skipNumber: number): WixDataQuery\n\n /**\n * Includes referenced items for the specified properties in a query's results.\n *\n * The `include()` function refines a query so that the items returned in the\n * query's results include the full referenced items for the specified properties.\n *\n * For example, suppose you have a **books** collection with an **author**\n * field that references an **authors** collection. Querying the **books**\n * collection with an `include(\"author\")` returns the relevant book items\n * and each item will include the full referenced author item in the book's\n * `author` property.\n *\n * When querying a collection that contains a reference field without using the\n * `include()` function:\n * - Single reference field: returned items contain only the ID of the\n * referenced item, and not the full referenced items.\n * - Multiple reference field: returned items do not contain the multiple\n * reference field at all.\n *\n * When including a property with multiple references, the following limitations\n * apply:\n * - Only one property with multiple references can be included.\n * - The query will return an error if more than 50 items are returned, regardless\n * of any query limit set using the `limit()` function.\n * - Each returned item can include up to 50 referenced items. If there are more\n * than 50 referenced items, only 50 are returned when the query is run\n * and the `partialIncludes`\n * property of the returned `WixDataQueryResult`\n * is `true`. To retrieve more than 50 referenced items, use the\n * `queryReferenced()` function.\n *\n * For a discussion of when to use the similar `queryReferenced()`\n * function and when to use `include()`, see [Querying Items that Reference Other Items](https://support.wix.com/en/article/including-referenced-data-when-filtering).\n *\n * > **Notes:**\n * > - Calling the `include()` function does not trigger any hooks.\n * > - The `include()` function is not supported for Single Item Collections.\n * @public\n * @documentationMaturity preview\n * @param fieldNames - The properties for which to include referenced items.\n * @requiredField fieldNames\n * @returns A `WixDataQuery` object representing the query.\n */\n include(...fieldNames: string[]): WixDataQuery\n\n /**\n * Overload for `include()`\n * @public\n * @documentationMaturity preview\n */\n include(fieldName: string, limit?: number): WixDataQuery\n\n /**\n * Overload for `include()`\n * @public\n * @documentationMaturity preview\n */\n include(fieldName1: string, fieldName2: string, limit?: number): WixDataQuery\n\n /**\n * Overload for `include()`\n * @public\n * @documentationMaturity preview\n */\n include(\n fieldName1: string,\n fieldName2: string,\n fieldName3: string,\n limit?: number\n ): WixDataQuery\n\n /**\n * Overload for `include()`\n * @public\n * @documentationMaturity preview\n */\n include(\n fieldName1: string,\n fieldName2: string,\n fieldName3: string,\n fieldName4: string,\n limit?: number\n ): WixDataQuery\n\n /**\n * Overload for `include()`\n * @public\n * @documentationMaturity preview\n */\n include(\n fieldName1: string,\n fieldName2: string,\n fieldName3: string,\n fieldName4: string,\n fieldName5: string,\n limit?: number\n ): WixDataQuery\n\n /**\n * Overload for `include()`\n * @public\n * @documentationMaturity preview\n */\n include(...fieldNamesAndLimit: [...string[], number]): WixDataQuery\n\n /**\n * Overload for `include()`\n * @public\n * @documentationMaturity preview\n */\n include(...args: unknown[]): WixDataQuery\n}\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/api/WixDataResult.ts"],"sourcesContent":["import { WixDataItem } from './types'\n\n/**\n * @builder\n */\nexport interface WixDataResult<Item = WixDataItem> {\n // query is not implemented\n\n /**\n * Returns the items that match the query.\n *\n * The current page of items retrieved by the query.\n *\n * The page size is defined by the `limit()`\n * function, can be retrieved using the `pageSize` property, and\n * navigating through pages is done with the `prev()` and\n * `next()` functions.\n *\n * When no items match the query, the `items` array is empty.\n * @public\n * @documentationMaturity preview\n * @readonly\n */\n readonly items: Item[]\n\n /**\n * Returns the total number of items that match the query.\n *\n * The `totalCount` returns the total number of items that match the query,\n * not just the number of items in the current page.\n *\n * > **Note:** available when requested with returnTotalCount = true\n * @public\n * @documentationMaturity preview\n * @readonly\n */\n readonly totalCount: number | undefined\n\n /**\n * Returns the query page size.\n *\n * The page size is defined by the `limit()`\n * function, can be retrieved using the `pageSize` property, and\n * navigating through pages is done with the `prev()` and\n * `next()` functions.\n * @public\n * @documentationMaturity preview\n * @readonly\n */\n readonly pageSize: number | undefined\n\n /**\n * Returns the index of the current results page number.\n *\n * The `currentPage` is a zero-based index of the current page of results.\n *\n * The page size is defined by the `limit()`\n * function, can be retrieved using the `pageSize` property, and\n * navigating through pages is done with the `prev()` and\n * `next()` functions.\n *\n * The `currentPage` property returns `undefined` if the query returned no results.\n * @public\n * @documentationMaturity preview\n * @readonly\n */\n readonly currentPage: number | undefined\n\n /**\n * Returns the number of items in the current results page.\n *\n * The page size is defined by the `limit()`\n * function, can be retrieved using the `pageSize` property, and\n * navigating through pages is done with the `prev()` and\n * `next()` functions.\n * @public\n * @documentationMaturity preview\n * @readonly\n */\n readonly length: number\n\n /**\n * Returns the total number of pages the query produced.\n *\n * The page size is defined by the `limit()`\n * function, can be retrieved using the `pageSize` property, and\n * navigating through pages is done with the `prev()` and\n * `next()` functions.\n *\n * > **Note:** available when requested with returnTotalCount = true\n * @public\n * @documentationMaturity preview\n * @readonly\n */\n readonly totalPages: number | undefined\n\n /**\n * Retrieves the next page of query results.\n *\n * The `next()` function retrieves the next page of query results.\n *\n * The page size is defined by the `limit()`\n * function, can be retrieved using the `pageSize` property, and\n * navigating through pages is done with the `prev()` and\n * `next()` functions.\n *\n * If items are added or removed between calls to `next()` the values returned may change.\n *\n * >**Note:** The `next()` function is not supported for Single Item Collections.\n *\n * @public\n * @documentationMaturity preview\n * @returns A query result object with the next page of query results.\n */\n next(): Promise<WixDataResult<Item>>\n\n /**\n * Retrieves the previous page of query results.\n *\n * The `prev()` function retrieves the previous page of query results.\n *\n * The page size is defined by the `limit()`\n * function, can be retrieved using the `pageSize` property, and\n * navigating through pages is done with the `prev()` and\n * `next()` functions.\n *\n * If items are added or removed between calls to `prev()` the values returned\n * may change.\n *\n * >**Note:** The `prev()` function is not supported for Single Item Collections.\n *\n * @public\n * @documentationMaturity preview\n * @returns A query result object with the previous page of query results.\n */\n prev(): Promise<WixDataResult<Item>>\n\n /**\n * Indicates if the query has more results.\n *\n * @public\n * @documentationMaturity preview\n * @returns `true` if there are more results.\n */\n hasNext(): boolean\n\n /**\n * Indicates the query has previous results.\n *\n * @public\n * @documentationMaturity preview\n * @returns `true` if there are previous results.\n */\n hasPrev(): boolean\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.filterBuilder = filterBuilder;
|
|
5
|
+
var _filter = require("../filter");
|
|
6
|
+
var _filterBuilder = require("@wix/filter-builder");
|
|
7
|
+
function filterBuilder(opts) {
|
|
8
|
+
return (0, _filter.platformizedFilterBuilder)({
|
|
9
|
+
...opts,
|
|
10
|
+
encoder: _filterBuilder.wixDataEncoder,
|
|
11
|
+
validateCollectionName: false
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_filter","require","_filterBuilder","filterBuilder","opts","platformizedFilterBuilder","encoder","wixDataEncoder","validateCollectionName"],"sources":["../../../src/api/common.ts"],"sourcesContent":["import { platformizedFilterBuilder, PlatformizedFilterBuilder } from '../filter'\nimport { wixDataEncoder } from '@wix/filter-builder'\n\nexport function filterBuilder(\n opts?: Record<string, any>\n): PlatformizedFilterBuilder {\n return platformizedFilterBuilder({\n ...opts,\n encoder: wixDataEncoder,\n validateCollectionName: false,\n })\n}\n"],"mappings":";;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEO,SAASE,aAAaA,CAC3BC,IAA0B,EACC;EAC3B,OAAO,IAAAC,iCAAyB,EAAC;IAC/B,GAAGD,IAAI;IACPE,OAAO,EAAEC,6BAAc;IACvBC,sBAAsB,EAAE;EAC1B,CAAC,CAAC;AACJ"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.isHttpError = isHttpError;
|
|
5
|
+
exports.parseError = parseError;
|
|
6
|
+
exports.parseHookError = parseHookError;
|
|
7
|
+
exports.parseValidationError = parseValidationError;
|
|
8
|
+
exports.toKnownCode = toKnownCode;
|
|
9
|
+
var _errors = require("../errors");
|
|
10
|
+
function isHttpError(error) {
|
|
11
|
+
var _response;
|
|
12
|
+
return !!((_response = error.response) != null && _response.status);
|
|
13
|
+
}
|
|
14
|
+
function parseHookError(data) {
|
|
15
|
+
if (data != null && data.jsErrorValue) {
|
|
16
|
+
const {
|
|
17
|
+
name,
|
|
18
|
+
message,
|
|
19
|
+
code
|
|
20
|
+
} = data.jsErrorValue;
|
|
21
|
+
const result = new Error(message);
|
|
22
|
+
result.name = name;
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
result.code = code;
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
return data == null ? void 0 : data.value;
|
|
28
|
+
}
|
|
29
|
+
function parseValidationError(error) {
|
|
30
|
+
var _error$details;
|
|
31
|
+
const fieldViolations = ((_error$details = error.details) == null || (_error$details = _error$details.validationError) == null ? void 0 : _error$details.fieldViolations) ?? [];
|
|
32
|
+
const violations = fieldViolations.map(v => `${v.field}: ${v.description}`);
|
|
33
|
+
return (0, _errors.wixDataError)([error.message, ...violations].join('\n'), 'WDE0080', error.details);
|
|
34
|
+
}
|
|
35
|
+
function parseError(error) {
|
|
36
|
+
var _details$applicationE, _error$details2;
|
|
37
|
+
const details = error.details ?? {};
|
|
38
|
+
if (((_details$applicationE = details.applicationError) == null ? void 0 : _details$applicationE.code) === 'WDE0078') {
|
|
39
|
+
const hookError = parseHookError(details.applicationError.data);
|
|
40
|
+
if (hookError) {
|
|
41
|
+
return hookError;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (details.applicationError) {
|
|
45
|
+
return (0, _errors.wixDataError)(details.applicationError.description, toKnownCode(details.applicationError.code), details);
|
|
46
|
+
}
|
|
47
|
+
if ((_error$details2 = error.details) != null && _error$details2.validationError) {
|
|
48
|
+
return parseValidationError(error);
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function toKnownCode(code) {
|
|
53
|
+
return KnownAppCodes[code] ?? code;
|
|
54
|
+
}
|
|
55
|
+
const KnownAppCodes = {
|
|
56
|
+
WDE0020: _errors.codes.ValidationError,
|
|
57
|
+
WDE0024: _errors.codes.ValidationError,
|
|
58
|
+
WDE0025: _errors.codes.SchemaDoesNotExist,
|
|
59
|
+
WDE0026: _errors.codes.CollectionDeleted,
|
|
60
|
+
WDE0027: _errors.codes.PermissionDenied,
|
|
61
|
+
WDE0052: _errors.codes.SiteInTemplateMode,
|
|
62
|
+
WDE0073: _errors.codes.ItemDoesNotExist,
|
|
63
|
+
WDE0074: _errors.codes.ItemAlreadyExists,
|
|
64
|
+
WDE0022: _errors.codes.ValidationError,
|
|
65
|
+
WDE0007: _errors.codes.ValidationError
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","isHttpError","error","_response","response","status","parseHookError","data","jsErrorValue","name","message","code","result","Error","value","parseValidationError","_error$details","fieldViolations","details","validationError","violations","map","v","field","description","wixDataError","join","parseError","_details$applicationE","_error$details2","applicationError","hookError","toKnownCode","KnownAppCodes","WDE0020","codes","ValidationError","WDE0024","WDE0025","SchemaDoesNotExist","WDE0026","CollectionDeleted","WDE0027","PermissionDenied","WDE0052","SiteInTemplateMode","WDE0073","ItemDoesNotExist","WDE0074","ItemAlreadyExists","WDE0022","WDE0007"],"sources":["../../../src/api/errors.ts"],"sourcesContent":["import * as apiError from '../types/error'\nimport { codes, wixDataError } from '../errors'\n\nexport function isHttpError(\n error: unknown\n): error is { response: { status: number; data: any } } {\n return !!(error as any).response?.status\n}\n\nexport function parseHookError(data: any) {\n if (data?.jsErrorValue) {\n const { name, message, code } = data.jsErrorValue\n const result = new Error(message)\n result.name = name\n // @ts-expect-error\n result.code = code\n return result\n }\n return data?.value\n}\n\nexport function parseValidationError(error: apiError.ServerError) {\n const fieldViolations = error.details?.validationError?.fieldViolations ?? []\n const violations = fieldViolations.map((v) => `${v.field}: ${v.description}`)\n\n return wixDataError(\n [error.message, ...violations].join('\\n'),\n 'WDE0080',\n error.details\n )\n}\n\nexport function parseError(error: apiError.ServerError): Error | null {\n const details = error.details ?? {}\n if (details.applicationError?.code === 'WDE0078') {\n const hookError = parseHookError(details.applicationError.data)\n if (hookError) {\n return hookError\n }\n }\n if (details.applicationError) {\n return wixDataError(\n details.applicationError.description!,\n toKnownCode(details.applicationError.code!),\n details\n )\n }\n if (error.details?.validationError) {\n return parseValidationError(error)\n }\n return null\n}\n\nexport function toKnownCode(code: string): string {\n return KnownAppCodes[code] ?? code\n}\n\nconst KnownAppCodes: Record<string, string> = {\n WDE0020: codes.ValidationError,\n WDE0024: codes.ValidationError,\n WDE0025: codes.SchemaDoesNotExist,\n WDE0026: codes.CollectionDeleted,\n WDE0027: codes.PermissionDenied,\n WDE0052: codes.SiteInTemplateMode,\n WDE0073: codes.ItemDoesNotExist,\n WDE0074: codes.ItemAlreadyExists,\n WDE0022: codes.ValidationError,\n WDE0007: codes.ValidationError,\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEO,SAASC,WAAWA,CACzBC,KAAc,EACwC;EAAA,IAAAC,SAAA;EACtD,OAAO,CAAC,GAAAA,SAAA,GAAED,KAAK,CAASE,QAAQ,aAAvBD,SAAA,CAAyBE,MAAM;AAC1C;AAEO,SAASC,cAAcA,CAACC,IAAS,EAAE;EACxC,IAAIA,IAAI,YAAJA,IAAI,CAAEC,YAAY,EAAE;IACtB,MAAM;MAAEC,IAAI;MAAEC,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