Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fulcrum-core

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fulcrum-core - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6

12

dist/changeset.js

@@ -8,3 +8,3 @@ "use strict";

const util_1 = require("util");
const lodash_1 = require("lodash");
const lodash_compact_1 = __importDefault(require("lodash.compact"));
class Changeset {

@@ -111,12 +111,12 @@ constructor(attributes) {

const parts = [
(0, lodash_1.compact)([this.application,
(0, lodash_compact_1.default)([this.application,
this._metadata.application_version]).join(' '),
(0, lodash_1.compact)([this._metadata.browser,
(0, lodash_compact_1.default)([this._metadata.browser,
this._metadata.browser_version]).join(' '),
(0, lodash_1.compact)([this._metadata.platform,
(0, lodash_compact_1.default)([this._metadata.platform,
this._metadata.platform_version]).join(' '),
(0, lodash_1.compact)([this._metadata.device_manufacturer,
(0, lodash_compact_1.default)([this._metadata.device_manufacturer,
this._metadata.device_model]).join(' ')
];
return (0, lodash_1.compact)(parts).join(' / ');
return (0, lodash_compact_1.default)(parts).join(' / ');
}

@@ -123,0 +123,0 @@ get boundingBoxAsGeoJSON() {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const lodash_padstart_1 = __importDefault(require("lodash.padstart"));
class SRT {

@@ -10,9 +13,9 @@ static render(tracks) {

let x = t - this._firstTimestamp;
const ms = (0, lodash_1.padStart)(Math.floor(x % 1000), 2, '0');
const ms = (0, lodash_padstart_1.default)(Math.floor(x % 1000), 2, '0');
x /= 1000;
const ss = (0, lodash_1.padStart)(Math.floor(x % 60), 2, '0');
const ss = (0, lodash_padstart_1.default)(Math.floor(x % 60), 2, '0');
x /= 60;
const mm = (0, lodash_1.padStart)(Math.floor(x % 60), 2, '0');
const mm = (0, lodash_padstart_1.default)(Math.floor(x % 60), 2, '0');
x /= 60;
const hh = (0, lodash_1.padStart)(Math.floor(x % 24), 2, '0');
const hh = (0, lodash_padstart_1.default)(Math.floor(x % 24), 2, '0');
return `${hh}:${mm}:${ss},${ms}`;

@@ -19,0 +22,0 @@ }

@@ -26,8 +26,2 @@ export default class Record extends Feature {

get hasCoordinate(): boolean;
get hasLocation(): boolean;
set geometry(arg: any);
get geometry(): any;
_geometry: any;
_latitude: any;
_longitude: any;
set changeset(arg: any);

@@ -80,3 +74,2 @@ get changeset(): any;

edited_duration: any;
geometry: any;
};

@@ -86,2 +79,4 @@ updateFromAPIAttributes(attrs: any): void;

_formValuesJSON: any;
_latitude: any;
_longitude: any;
_projectID: any;

@@ -151,3 +146,6 @@ _projectName: any;

get course(): any;
get geometryAsGeoJSON(): any;
get geometryAsGeoJSON(): {
type: string;
coordinates: any[];
} | null;
set createdDuration(arg: any);

@@ -154,0 +152,0 @@ get createdDuration(): any;

@@ -11,3 +11,3 @@ "use strict";

const status_value_1 = __importDefault(require("./values/status-value"));
const uuid_1 = require("uuid");
const uuid_1 = __importDefault(require("uuid"));
const load_object_1 = __importDefault(require("./load-object"));

@@ -71,15 +71,2 @@ class Record extends feature_1.default {

}
get hasLocation() {
return this.hasCoordinate || this.geometry != null;
}
get geometry() {
return this._geometry;
}
set geometry(geometry) {
this._geometry = geometry;
if ((geometry === null || geometry === void 0 ? void 0 : geometry.type) === 'Point') {
this._latitude = geometry.coordinates[1];
this._longitude = geometry.coordinates[0];
}
}
get changeset() {

@@ -132,9 +119,7 @@ return this._changeset;

json.edited_duration = this.editedDuration;
json.geometry = this.geometry;
return json;
}
updateFromAPIAttributes(attrs) {
var _a;
const attributes = attrs || {};
this._id = attributes.id || (0, uuid_1.v4)();
this._id = attributes.id || uuid_1.default.v4();
this._version = attributes.version != null ? attributes.version : null;

@@ -188,5 +173,2 @@ this._createdAt = date_utils_1.default.parseISOTimestamp(attributes.created_at);

}
if (attributes.geometry) {
this._geometry = (_a = attributes.geometry) !== null && _a !== void 0 ? _a : null;
}
}

@@ -361,15 +343,12 @@ updateTimestamps() {

get geometryAsGeoJSON() {
if (this.geometry) {
return this.geometry;
if (!this.hasCoordinate) {
return null;
}
if (this.hasCoordinate) {
return {
type: 'Point',
coordinates: [
this.longitude,
this.latitude,
],
};
}
return null;
return {
type: 'Point',
coordinates: [
this.longitude,
this.latitude
]
};
}

@@ -376,0 +355,0 @@ get createdDuration() {

@@ -26,3 +26,2 @@ export default class Role {

_canDeleteRecords: boolean | undefined;
_canBulkDeleteRecords: boolean | undefined;
_canExportRecords: boolean | undefined;

@@ -57,5 +56,4 @@ _canImportRecords: boolean | undefined;

get canDeleteRecords(): boolean | undefined;
get canBulkDeleteRecords(): boolean | undefined;
get canExportRecords(): boolean | undefined;
get canRunReports(): boolean | undefined;
}

@@ -35,3 +35,2 @@ "use strict";

this._canDeleteRecords = !!attributes.can_delete_records;
this._canBulkDeleteRecords = !!attributes.can_bulk_delete_records;
this._canExportRecords = !!attributes.can_export_records;

@@ -115,5 +114,2 @@ this._canImportRecords = !!attributes.can_import_records;

}
get canBulkDeleteRecords() {
return this._canBulkDeleteRecords;
}
get canExportRecords() {

@@ -120,0 +116,0 @@ return this._canExportRecords;

@@ -7,3 +7,3 @@ "use strict";

const locale_1 = __importDefault(require("./locale"));
const lodash_1 = require("lodash");
const lodash_padstart_1 = __importDefault(require("lodash.padstart"));
const relative_date_1 = __importDefault(require("relative-date"));

@@ -38,4 +38,4 @@ let intl = null;

static formatTime(date) {
const hours = (0, lodash_1.padStart)(date.getHours(), 2, '0');
const minutes = (0, lodash_1.padStart)(date.getMinutes(), 2, '0');
const hours = (0, lodash_padstart_1.default)(date.getHours(), 2, '0');
const minutes = (0, lodash_padstart_1.default)(date.getMinutes(), 2, '0');
return hours + ':' + minutes;

@@ -49,12 +49,12 @@ }

const ms = (ss * 1000 % 1000);
const h = (0, lodash_1.padStart)(Math.floor(hh), 2, '0');
const m = (0, lodash_1.padStart)(Math.floor(mm), 2, '0');
const s = (0, lodash_1.padStart)(Math.floor(ss), 2, '0');
const u = (0, lodash_1.padStart)(Math.floor(ms), 3, '0');
const h = (0, lodash_padstart_1.default)(Math.floor(hh), 2, '0');
const m = (0, lodash_padstart_1.default)(Math.floor(mm), 2, '0');
const s = (0, lodash_padstart_1.default)(Math.floor(ss), 2, '0');
const u = (0, lodash_padstart_1.default)(Math.floor(ms), 3, '0');
return h + ':' + m + ':' + s + (milliseconds ? '.' + u : '');
}
static formatTimeParts(hours, minutes, seconds) {
const h = (0, lodash_1.padStart)(+hours, 2, '0');
const m = (0, lodash_1.padStart)(+minutes, 2, '0');
const s = (0, lodash_1.padStart)(+seconds, 2, '0');
const h = (0, lodash_padstart_1.default)(+hours, 2, '0');
const m = (0, lodash_padstart_1.default)(+minutes, 2, '0');
const s = (0, lodash_padstart_1.default)(+seconds, 2, '0');
return h + ':' + m + ':' + s;

@@ -157,4 +157,4 @@ }

const year = date.getFullYear();
const month = (0, lodash_1.padStart)(date.getMonth() + 1, 2, '0');
const day = (0, lodash_1.padStart)(date.getDate(), 2, '0');
const month = (0, lodash_padstart_1.default)(date.getMonth() + 1, 2, '0');
const day = (0, lodash_padstart_1.default)(date.getDate(), 2, '0');
return year + '-' + month + '-' + day;

@@ -180,4 +180,4 @@ }

const year = date.getFullYear();
const month = (0, lodash_1.padStart)(date.getMonth() + 1, 2, '0');
const day = (0, lodash_1.padStart)(date.getDate(), 2, '0');
const month = (0, lodash_padstart_1.default)(date.getMonth() + 1, 2, '0');
const day = (0, lodash_padstart_1.default)(date.getDate(), 2, '0');
return year + '-' + month + '-' + day;

@@ -184,0 +184,0 @@ }

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const lodash_includes_1 = __importDefault(require("lodash.includes"));
const lodash_startswith_1 = __importDefault(require("lodash.startswith"));
const lodash_trim_1 = __importDefault(require("lodash.trim"));
class TextUtils {

@@ -21,3 +26,3 @@ static isEmpty(value) {

}
return (0, lodash_1.includes)(haystack.toLowerCase(), needle.toLowerCase());
return (0, lodash_includes_1.default)(haystack.toLowerCase(), needle.toLowerCase());
}

@@ -28,6 +33,6 @@ static startsWith(haystack, needle) {

}
return (0, lodash_1.startsWith)(haystack, needle);
return (0, lodash_startswith_1.default)(haystack, needle);
}
static trim(value) {
return (0, lodash_1.trim)(value);
return (0, lodash_trim_1.default)(value);
}

@@ -34,0 +39,0 @@ }

@@ -42,3 +42,3 @@ "use strict";

if (record.form.isGeometryRequired) {
if (!record.hasLocation) {
if (!record.hasCoordinate) {
errors.push(new geometry_required_validation_error_1.default());

@@ -57,3 +57,3 @@ }

if (repeatableItem.element.isGeometryRequired) {
if (!repeatableItem.hasLocation) {
if (!repeatableItem.hasCoordinate) {
errors.push(new geometry_required_validation_error_1.default());

@@ -60,0 +60,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

const text_utils_1 = __importDefault(require("../utils/text-utils"));
const lodash_1 = require("lodash");
const lodash_includes_1 = __importDefault(require("lodash.includes"));
const ChoiceDisplaySeparator = ', ';

@@ -161,3 +161,3 @@ const ChoiceSearchSeparator = ' ';

isEqual(value) {
if ((0, lodash_1.includes)(this.selectedValues, value)) {
if ((0, lodash_includes_1.default)(this.selectedValues, value)) {
return true;

@@ -164,0 +164,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

const number_utils_1 = __importDefault(require("../utils/number-utils"));
const uuid_1 = require("uuid");
const uuid_1 = __importDefault(require("uuid"));
class DynamicValue extends form_value_1.default {

@@ -137,3 +137,3 @@ constructor(element, items) {

metadata: {
id: (0, uuid_1.v4)()
id: uuid_1.default.v4()
},

@@ -140,0 +140,0 @@ elements: [],

@@ -19,9 +19,3 @@ export default class RepeatableItemValue extends Feature {

_formValues: FormValues | undefined;
set geometry(arg: any);
get geometry(): any;
_geometry: any;
_latitude: any;
_longitude: any;
get hasCoordinate(): boolean;
get hasLocation(): boolean;
updateFromAPIAttributes(attrs: any): void;

@@ -43,2 +37,4 @@ _id: any;

_updatedByName: any;
_latitude: any;
_longitude: any;
_createdDuration: any;

@@ -62,3 +58,6 @@ _updatedDuration: any;

form_values: {};
geometry: any;
geometry: {
type: string;
coordinates: any[];
} | null;
created_location: {

@@ -88,3 +87,6 @@ latitude: any;

get searchableValue(): string;
get geometryAsGeoJSON(): any;
get geometryAsGeoJSON(): {
type: string;
coordinates: any[];
} | null;
set latitude(arg: any);

@@ -91,0 +93,0 @@ get latitude(): any;

@@ -60,20 +60,6 @@ "use strict";

}
get geometry() {
return this._geometry;
}
set geometry(geometry) {
this._geometry = geometry;
if ((geometry === null || geometry === void 0 ? void 0 : geometry.type) === 'Point') {
this._latitude = geometry.coordinates[1];
this._longitude = geometry.coordinates[0];
}
}
get hasCoordinate() {
return this._latitude != null && this._longitude != null;
}
get hasLocation() {
return this.hasCoordinate || this.geometry != null;
}
updateFromAPIAttributes(attrs) {
var _a;
this._id = attrs.id;

@@ -99,3 +85,2 @@ this._createdAt = date_utils_1.default.parseEpochTimestamp(attrs.created_at);

const geometry = attrs.geometry;
this._geometry = (_a = attrs.geometry) !== null && _a !== void 0 ? _a : null;
if (geometry != null &&

@@ -180,15 +165,9 @@ geometry.type === 'Point' &&

get geometryAsGeoJSON() {
if (this.geometry) {
return this.geometry;
if (!this.hasCoordinate) {
return null;
}
if (this.hasCoordinate) {
return {
type: 'Point',
coordinates: [
this.longitude,
this.latitude,
],
};
}
return null;
return {
type: 'Point',
coordinates: [this._longitude, this._latitude]
};
}

@@ -195,0 +174,0 @@ get latitude() {

@@ -13,3 +13,6 @@ export default class RepeatableValue extends FormValue {

form_values: {};
geometry: any;
geometry: {
type: string;
coordinates: any[];
} | null;
created_location: {

@@ -40,3 +43,6 @@ latitude: any;

form_values: {};
geometry: any;
geometry: {
type: string;
coordinates: any[];
} | null;
created_location: {

@@ -43,0 +49,0 @@ latitude: any;

@@ -9,3 +9,3 @@ "use strict";

const text_utils_1 = __importDefault(require("../utils/text-utils"));
const uuid_1 = require("uuid");
const uuid_1 = __importDefault(require("uuid"));
const SearchSeparator = ' ';

@@ -132,3 +132,3 @@ class RepeatableValue extends form_value_1.default {

const attributes = {
id: (0, uuid_1.v4)(),
id: uuid_1.default.v4(),
form_values: {}

@@ -135,0 +135,0 @@ };

{
"name": "fulcrum-core",
"version": "1.3.5",
"version": "1.3.6",
"description": "Fulcrum Core",

@@ -35,7 +35,11 @@ "homepage": "http://github.com/fulcrumapp/fulcrum-core",

"dependencies": {
"async": "^3.2.4",
"lodash": "^4.17.21",
"async": "^2.1.4",
"lodash.compact": "^3.0.1",
"lodash.includes": "^4.3.0",
"lodash.padstart": "^4.6.1",
"lodash.startswith": "^4.2.1",
"lodash.trim": "^4.5.1",
"mixmatch": "^0.0.4",
"relative-date": "^1.1.3",
"uuid": "^9.0.0"
"uuid": "^3.3.2"
},

@@ -42,0 +46,0 @@ "keywords": [

@@ -27,3 +27,3 @@ ## Fulcrum Core

```sh
yarn install
npm install fulcrum-core
```

@@ -34,5 +34,11 @@

```sh
yarn test
npm test
```
### Build
```sh
make
```
### Console

@@ -46,2 +52,3 @@

### Publishing

@@ -51,4 +58,4 @@

- Bump package.json version
- Merge to main
- Checkout main, `git pull`
- Merge to ~~main~~ master
- Checkout master, `git pull`
- `git tag -a vx.x.x -m "x.x.x"`

@@ -64,4 +71,5 @@ - `git push origin --tags`

- use "support@fulcrumapp.com" for the email address when prompted
- `yarn publish`
- Restore your .npmrc file
- `npm publish`
- Publish to artifactory
- `mv $HOME/fulcrum.npmrc $HOME/.npmrc`
- `npm publish`
import DateUtils from './utils/date-utils';
import { format } from 'util';
import { compact } from 'lodash';
import compact from 'lodash.compact';

@@ -5,0 +5,0 @@ export default class Changeset {

@@ -1,2 +0,2 @@

import { padStart } from 'lodash';
import padStart from 'lodash.padstart';

@@ -3,0 +3,0 @@ export default class SRT {

@@ -6,3 +6,3 @@ import Feature from './feature';

import StatusValue from './values/status-value';
import { v4 as uuidv4 } from 'uuid'
import uuid from 'uuid';
import loadObject from './load-object';

@@ -87,19 +87,2 @@

get hasLocation() {
return this.hasCoordinate || this.geometry != null;
}
get geometry() {
return this._geometry;
}
set geometry(geometry) {
this._geometry = geometry;
if (geometry?.type === 'Point') {
this._latitude = geometry.coordinates[1];
this._longitude = geometry.coordinates[0];
}
}
get changeset() {

@@ -165,4 +148,2 @@ return this._changeset;

json.geometry = this.geometry;
return json;

@@ -174,3 +155,3 @@ }

this._id = attributes.id || uuidv4();
this._id = attributes.id || uuid.v4();
this._version = attributes.version != null ? attributes.version : null;

@@ -234,6 +215,2 @@ this._createdAt = DateUtils.parseISOTimestamp(attributes.created_at);

}
if (attributes.geometry) {
this._geometry = attributes.geometry ?? null;
}
}

@@ -456,17 +433,13 @@

get geometryAsGeoJSON() {
if (this.geometry) {
return this.geometry;
if (!this.hasCoordinate) {
return null;
}
if (this.hasCoordinate) {
return {
type: 'Point',
coordinates: [
this.longitude,
this.latitude,
],
};
}
return null;
return {
type: 'Point',
coordinates: [
this.longitude,
this.latitude
]
};
}

@@ -473,0 +446,0 @@

@@ -33,3 +33,2 @@ import DateUtils from './utils/date-utils';

this._canDeleteRecords = !!attributes.can_delete_records;
this._canBulkDeleteRecords = !!attributes.can_bulk_delete_records;
this._canExportRecords = !!attributes.can_export_records;

@@ -138,6 +137,2 @@ this._canImportRecords = !!attributes.can_import_records;

get canBulkDeleteRecords() {
return this._canBulkDeleteRecords;
}
get canExportRecords() {

@@ -144,0 +139,0 @@ return this._canExportRecords;

import Locale from './locale';
import { padStart } from 'lodash';
import padStart from 'lodash.padstart';
import relativeDate from 'relative-date';

@@ -4,0 +4,0 @@

@@ -1,2 +0,4 @@

import { includes, startsWith, trim } from 'lodash';
import includes from 'lodash.includes';
import startsWith from 'lodash.startswith';
import trim from 'lodash.trim';

@@ -3,0 +5,0 @@ export default class TextUtils {

@@ -41,3 +41,3 @@ import RepeatableItemValue from '../values/repeatable-item-value';

if (record.form.isGeometryRequired) {
if (!record.hasLocation) {
if (!record.hasCoordinate) {
errors.push(new GeometryRequiredValidationError());

@@ -62,3 +62,3 @@ }

if (repeatableItem.element.isGeometryRequired) {
if (!repeatableItem.hasLocation) {
if (!repeatableItem.hasCoordinate) {
errors.push(new GeometryRequiredValidationError());

@@ -65,0 +65,0 @@ }

import FormValue from './form-value';
import TextUtils from '../utils/text-utils';
import { includes } from 'lodash';
import includes from 'lodash.includes';

@@ -5,0 +5,0 @@ const ChoiceDisplaySeparator = ', ';

@@ -5,3 +5,3 @@ import FormValue from './form-value';

import NumberUtils from '../utils/number-utils';
import { v4 as uuidv4 } from 'uuid'
import uuid from 'uuid';

@@ -172,3 +172,3 @@ export default class DynamicValue extends FormValue {

metadata: {
id: uuidv4()
id: uuid.v4()
},

@@ -175,0 +175,0 @@ elements: [],

@@ -73,15 +73,2 @@ import Feature from '../feature';

get geometry() {
return this._geometry;
}
set geometry(geometry) {
this._geometry = geometry;
if (geometry?.type === 'Point') {
this._latitude = geometry.coordinates[1];
this._longitude = geometry.coordinates[0];
}
}
get hasCoordinate() {

@@ -91,6 +78,2 @@ return this._latitude != null && this._longitude != null;

get hasLocation() {
return this.hasCoordinate || this.geometry != null;
}
updateFromAPIAttributes(attrs) {

@@ -123,4 +106,2 @@ this._id = attrs.id;

this._geometry = attrs.geometry ?? null;
if (geometry != null &&

@@ -226,17 +207,10 @@ geometry.type === 'Point' &&

get geometryAsGeoJSON() {
if (this.geometry) {
return this.geometry;
if (!this.hasCoordinate) {
return null;
}
if (this.hasCoordinate) {
return {
type: 'Point',
coordinates: [
this.longitude,
this.latitude,
],
};
}
return null;
return {
type: 'Point',
coordinates: [ this._longitude, this._latitude ]
};
}

@@ -243,0 +217,0 @@

import FormValue from './form-value';
import RepeatableItemValue from './repeatable-item-value';
import TextUtils from '../utils/text-utils';
import { v4 as uuidv4 } from 'uuid'
import uuid from 'uuid';

@@ -168,3 +168,3 @@ const SearchSeparator = ' ';

const attributes = {
id: uuidv4(),
id: uuid.v4(),
form_values: {}

@@ -171,0 +171,0 @@ };

@@ -56,3 +56,3 @@ {

],
"geometry_required": true,
"geometry_required": false,
"script": null,

@@ -527,3 +527,3 @@ "field_effects": {

],
"geometry_required": true,
"geometry_required": false,
"min_length": null,

@@ -530,0 +530,0 @@ "max_length": null

@@ -208,19 +208,3 @@ {

"version": 2,
"vertical_accuracy": 10,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-113.88508110499023, 41.986590560199076],
[-114.24422692261155, 36.145969116609116],
[-114.92373593397966, 35.89013106752292],
[-114.70851389289572, 35.26715302172084],
[-115.45608482966192, 35.615599740593446],
[-116.57685735205787, 36.48162345006174],
[-119.90992943973569, 39.21161503784098],
[-120.35625305990713, 41.87635182244613],
[-113.88508110499023, 41.986590560199076]
]
]
}
"vertical_accuracy": 10
}

@@ -48,3 +48,3 @@ {

],
"geometry_required": true,
"geometry_required": false,
"script": null,

@@ -582,3 +582,3 @@ "field_effects": {

],
"geometry_required": true,
"geometry_required": false,
"min_length": null,

@@ -585,0 +585,0 @@ "max_length": null

@@ -197,20 +197,4 @@ {

"version": 2,
"vertical_accuracy": 10.0,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-113.88508110499023, 41.986590560199076],
[-114.24422692261155, 36.145969116609116],
[-114.92373593397966, 35.89013106752292],
[-114.70851389289572, 35.26715302172084],
[-115.45608482966192, 35.615599740593446],
[-116.57685735205787, 36.48162345006174],
[-119.90992943973569, 39.21161503784098],
[-120.35625305990713, 41.87635182244613],
[-113.88508110499023, 41.986590560199076]
]
]
}
"vertical_accuracy": 10.0
}
}

@@ -6,3 +6,2 @@ import fs from 'fs';

import RequiredFieldValidationError from '../src/validation/required-field-validation-error';
import GeometryRequiredValidationError from '../src/validation/geometry-required-validation-error';
import CustomValidationError from '../src/validation/custom-validation-error';

@@ -59,119 +58,2 @@ import DataSource from '../src/data-source';

});
it('returns GeoJSON with only a latitude and longitude', () => {
record.geometry = null;
record.latitude = 1;
record.longitude = 2;
record.hasCoordinate.should.eql(true);
record.hasLocation.should.eql(true);
record.geometryAsGeoJSON.should.eql({
type: 'Point',
coordinates: [2, 1]
});
});
it('returns GeoJSON with a geometry', () => {
record.geometry = {
type: "LineString",
coordinates: [
[-82.47576689405734, 27.977757676187323],
[-82.47699950483403, 27.974250052144896],
]
};
record.latitude = null;
record.longitude = null;
record.hasCoordinate.should.eql(false);
record.hasLocation.should.eql(true);
record.geometryAsGeoJSON.should.eql({
type: "LineString",
coordinates: [
[-82.47576689405734, 27.977757676187323],
[-82.47699950483403, 27.974250052144896],
]
});
});
it('does not return GeoJSON with no location or geometry', () => {
record.geometry = null;
record.latitude = null;
record.longitude = null;
record.hasCoordinate.should.eql(false);
record.hasLocation.should.eql(false);
shouldBeNull(record.geometryAsGeoJSON);
});
it('returns GeoJSON with only a latitude and longitude inside a repeatable', () => {
const [ child ] = record.formValues.find('rooms').items;
child.geometry = null;
child.latitude = 1;
child.longitude = 2;
child.hasCoordinate.should.eql(true);
child.hasLocation.should.eql(true);
child.geometryAsGeoJSON.should.eql({
type: 'Point',
coordinates: [2, 1]
});
});
it('returns GeoJSON with a geometry inside a repeatable', () => {
const [ child ] = record.formValues.find('rooms').items;
child.geometry = {
type: "LineString",
coordinates: [
[-82.47576689405734, 27.977757676187323],
[-82.47699950483403, 27.974250052144896],
]
};
child.latitude = null;
child.longitude = null;
child.hasCoordinate.should.eql(false);
child.hasLocation.should.eql(true);
child.geometryAsGeoJSON.should.eql({
type: "LineString",
coordinates: [
[-82.47576689405734, 27.977757676187323],
[-82.47699950483403, 27.974250052144896],
]
});
});
it('update the latitude and longitude when updating Point geometry', () => {
record.geometry = {
type: "Point",
coordinates: [-82.47576689405734, 27.977757676187323]
};
record.latitude.should.eql(27.977757676187323);
record.longitude.should.eql(-82.47576689405734);
});
it('update the latitude and longitude when updating the geometry of a repeatable', () => {
const [ child ] = record.formValues.find('rooms').items;
child.geometry = {
type: "Point",
coordinates: [-82.47576689405734, 27.977757676187323]
};
child.latitude.should.eql(27.977757676187323);
child.longitude.should.eql(-82.47576689405734);
});
it('does not return GeoJSON with no geometry inside a repeatable', () => {
const [ child ] = record.formValues.find('rooms').items;
child.geometry = null;
child.latitude = null;
child.longitude = null;
child.hasCoordinate.should.eql(false);
child.hasLocation.should.eql(false);
shouldBeNull(child.geometryAsGeoJSON);
});
});

@@ -234,84 +116,2 @@

});
describe('geometry validation', () => {
it('returns an error when there is no geometry', () => {
record.geometry = null;
record.latitude = null;
record.longitude = null;
const [ error ] = FeatureValidator.validateRecord(record, record.formValues);
error.should.be.instanceOf(GeometryRequiredValidationError);
error.message.should.eql("A validation location is required.");
});
it('does not return an error when there is a latitude and longitude', () => {
record.latitude = 27.977757676187323;
record.longitude = -82.47576689405734;
record.geometry = null;
const errors = FeatureValidator.validateRecord(record, record.formValues);
errors.length.should.eql(0);
});
it('does not return an error when there is a geometry', () => {
record.geometry = {
type: "LineString",
coordinates: [
[-82.47576689405734, 27.977757676187323],
[-82.47699950483403, 27.974250052144896],
]
};
record.longitude = null;
record.latitude = null;
const errors = FeatureValidator.validateRecord(record, record.formValues);
errors.length.should.eql(0);
});
it('returns an error when there is no geometry in a repeatable', () => {
const [ child ] = record.formValues.find('rooms').items;
child.geometry = null;
child.latitude = null;
child.longitude = null;
const [ error ] = FeatureValidator.validateFeature(child, record, child.formValues);
error.should.be.instanceOf(GeometryRequiredValidationError);
error.message.should.eql("A validation location is required.");
});
it('does not return an error when there is a latitude and longitude in a repeatable', () => {
const [ child ] = record.formValues.find('rooms').items;
child.latitude = 27.977757676187323;
child.longitude = -82.47576689405734;
child.geometry = null;
const errors = FeatureValidator.validateFeature(child, record, child.formValues);
errors.length.should.eql(0);
});
it('does not return an error when there is a geometry in a repeatable', () => {
const [ child ] = record.formValues.find('rooms').items;
child.geometry = {
type: "LineString",
coordinates: [
[-82.47576689405734, 27.977757676187323],
[-82.47699950483403, 27.974250052144896],
]
};
child.latitude = null;
child.longitude = null;
const errors = FeatureValidator.validateFeature(child, record, child.formValues);
errors.length.should.eql(0);
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc