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

fulcrum-expressions

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fulcrum-expressions - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

ts/functions/GEOMETRY.ts

3

dist/package.json
{
"name": "fulcrum-expressions",
"version": "1.1.1",
"version": "1.2.0",
"description": "Expression runtime for Fulcrum",

@@ -36,2 +36,3 @@ "author": "Fulcrum",

"devDependencies": {
"@types/geojson": "^7946.0.10",
"@types/lodash": "^4.14.191",

@@ -38,0 +39,0 @@ "@types/query-string": "^6.3.0",

{
"name": "fulcrum-expressions",
"version": "1.1.2",
"version": "1.2.0",
"description": "Expression runtime for Fulcrum",

@@ -36,2 +36,3 @@ "author": "Fulcrum",

"devDependencies": {
"@types/geojson": "^7946.0.10",
"@types/lodash": "^4.14.191",

@@ -38,0 +39,0 @@ "@types/query-string": "^6.3.0",

import { compact, concat, isUndefined } from "lodash"
import { FormFieldValues as ChoiceFieldValue} from "../types/values"
import { ChoiceFieldValue } from "../types/values"
import ISBLANK from "./ISBLANK"

@@ -14,14 +14,13 @@

*/
export default function CHOICEVALUES(field: ChoiceFieldValue): string[]
export default function CHOICEVALUES(field: any): any[]
export default function CHOICEVALUES(value: ChoiceFieldValue): string[]
export default function CHOICEVALUES(value: any): any[]
export default function CHOICEVALUES(): undefined
export default function CHOICEVALUES(field?: ChoiceFieldValue | any): string[] | undefined {
if (isUndefined(field)) { return undefined }
if (ISBLANK(field)) { return [] }
export default function CHOICEVALUES(value?: ChoiceFieldValue | any): string[] | undefined {
if (isUndefined(value)) { return undefined }
if (ISBLANK(value)) { return [] }
const choices = field as ChoiceFieldValue
const choiceValues = choices.choice_values || []
const otherValues = choices.other_values || []
const choiceValues = value.choice_values || []
const otherValues = value.other_values || []
return compact(concat(choiceValues, otherValues))
}

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

import { Geometry } from "../types/geojson"
export interface Config {

@@ -41,3 +42,3 @@ /** Optional: Set to record's altitude */

/** Optional: Object containing feature geometry */
featureGeometry?: FeatureGeometry,
featureGeometry?: Geometry,
/** Optional: current platform name */

@@ -63,6 +64,2 @@ platform?: string,

export interface FeatureGeometry {
coordinates: string[]
}
export const DEFAULTS = {

@@ -69,0 +66,0 @@ country: "US",

import { isUndefined, map } from "lodash"
import FIELDS, { FieldsOptions } from "./FIELDS"
import { ContainerFieldName, FieldName } from "../types/fields"
import { ContainerFieldName, FieldName, FormFields } from "../types/fields"

@@ -18,7 +18,3 @@ /**

export default function FIELDNAMES(dataName: ContainerFieldName, options = {}): FieldName[] | undefined {
const fields: FormFields[] | undefined = FIELDS(dataName, options)
if (isUndefined(fields)) { return undefined }
return map(fields, (o) => o.data_name)
return undefined;
}

@@ -1,5 +0,1 @@

import { isUndefined } from "lodash"
import { CONFIG, FeatureGeometry } from "./CONFIG"
import NUM from "./NUM"
/**

@@ -12,6 +8,4 @@ * Returns the latitude of the record if it exists.

export default function LATITUDE(): number {
const featureGeometry: FeatureGeometry|undefined = CONFIG().featureGeometry
if (isUndefined(featureGeometry)) { return NaN }
return NUM(featureGeometry.coordinates[1])
export default function LATITUDE(): number | null {
return null
}

@@ -1,5 +0,1 @@

import { isUndefined } from "lodash"
import { CONFIG, FeatureGeometry } from "./CONFIG"
import NUM from "./NUM"
/**

@@ -12,6 +8,4 @@ * Returns a record's longitude if it exists.

export default function LONGITUDE(): number {
const featureGeometry: FeatureGeometry|undefined = CONFIG().featureGeometry
if (isUndefined(featureGeometry)) { return NaN }
return NUM(featureGeometry.coordinates[0])
export default function LONGITUDE(): number | null {
return null;
}

@@ -55,48 +55,2 @@ import encodeUrl from "encodeurl"

export default function REQUEST(options: any, callback: HTTPRequestCallback) {
if (!callback || !isFunction(callback)) {
ERROR("A callback must be provided to REQUEST")
}
let config: RequestOptions = {
...DEFAULT_OPTIONS,
}
if (isString(options)) {
config.url = options as HTTPMethod
} else {
config = { ...config, ...options }
}
if (isEmpty(config.url)) {
ERROR("A url must be provided to REQUEST")
}
if (isObject(config.qs)) {
const url = config.url!
let queryString = stringify(config.qs!)
if (url.indexOf("?") < 0) {
queryString = `?${queryString}`
} else if (url.substr(url.length - 1) !== "&") {
queryString = `&${queryString}`
}
config.url += queryString
delete config.qs
}
if (config.json) {
config.headers!["Content-Type"] = "application/json"
if (!isString(config.json)) {
config.body = JSON.stringify(config.json)
}
delete config.json
}
config.url = encodeUrl(config.url!)
HostHTTPRequest(JSON.stringify(config), callback)
}

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

import isValidGeometry, { ValidGeometry } from "../util/is-valid-geometry"
import type { Geometry } from "../types/values"

@@ -11,10 +11,2 @@ /**

export default function SETGEOMETRY(geometry: ValidGeometry): void
export default function SETGEOMETRY(geometry: any): void
export default function SETGEOMETRY(geometry?: any): void {
if (!isValidGeometry(geometry)) {
ERROR('Geometry must be a valid GeoJSON value.')
}
SETVALUE('@geometry', geometry)
}
export default function SETGEOMETRY(geometry: Geometry | null): void {}
import { isNull, isUndefined } from "lodash"
import { FormFields, RepeatableField, FieldName } from "../types/fields"
import { SetValueResult } from "../types/results"
import { AddressFieldValue, ChoiceFieldValue } from "../types/values"
import { AddressFieldValue, ChoiceFieldValue, Geometry } from "../types/values"
import { RecordLinkIds } from "../util/converters"

@@ -22,42 +22,3 @@ import { ValidGeometry } from "../util/is-valid-geometry"

export default function SETVALUE(dataName: FieldName,
value: string|ChoiceFieldValue|AddressFieldValue|ValidGeometry|string[]|number[]|null): void {
const element: FormFields|undefined = FIELD(dataName)
let convertedValue: string|ChoiceFieldValue|AddressFieldValue|RecordLinkIds[]|null = null
if (!isUndefined(element)) {
// don't let the user accidentally blow out data in unsupported fields
// @ts-ignore Clash between $$runtime.elementsByKey type (FormFields) and RepeatableField type
// that will actually be returned by ternary operation
const repeatable: RepeatableField|null = !isNull($$runtime.repeatable) ?
$$runtime.elementsByKey[$$runtime.repeatable] : null
// set containterElements to repeatable children if setting a value in a repeatable field
// else set containerElements to all form elements
const containerElements: FormFields[] = repeatable ? repeatable.elements : $$runtime.form.elements
// check that requested changes is taking place in the current editing scope
// this is particularly important for repeatable values
const supported: boolean = isSetValueSupported(containerElements, element, element.type)
if (!supported) {
ERROR(FORMAT("Setting the value of '%s' is not supported.", dataName))
}
// takes value param and formats it for $$HOST according to field type
convertedValue = (!isUndefined(value) && !isUndefined(element)) ? makeValue(element, value) : null
}
// TODO(zhm) guard well-known supported values in the else case
// @project, @status, @geometry, etc
// Force the types to be correct so we don't pass back an array for
// the project or a number for the status, etc. The native apps
// should never be handed back data with the wrong JS types.
const result: SetValueResult = {
key: isUndefined(element) ? dataName : element.key,
type: "set-value",
value: isNull(convertedValue) ? JSON.stringify(value) : JSON.stringify(convertedValue),
}
$$runtime.results.push(result)
value: string|ChoiceFieldValue|AddressFieldValue|Geometry|string[]|number[]|null): void {
}

@@ -31,2 +31,3 @@ import { each,

import { MaybeString } from "../types/primitives"
import { CurrentLocation } from "../types/values"
import {

@@ -149,2 +150,4 @@ AlertResult,

currentLocation: CurrentLocation | null = null
variables: { [key: string]: any } = {}

@@ -151,0 +154,0 @@

import { GUID } from "./primitives"
import { FormFields, FieldName } from "./fields";
import { ChoiceFieldValue } from "./values"
import { ChoiceFieldValue, Geometry } from "./values"

@@ -95,6 +95,3 @@ export interface TriggeredEvent {

export interface GeometryEventValue {
coordinates: number[],
type: "Point"
}
export type GeometryEventValue = Geometry;

@@ -101,0 +98,0 @@ export interface GeometryEvent extends Event {

@@ -0,1 +1,3 @@

import { MaybeString } from "./primitives"
export interface AlertResult {

@@ -2,0 +4,0 @@ /** result type */

@@ -0,1 +1,5 @@

import type { Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon } from "../types/geojson"
export type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon
export type FormFieldValues =

@@ -2,0 +6,0 @@ ChoiceFieldValue

@@ -18,12 +18,3 @@ import { isArray, isFinite, isObject, isNull, isUndefined, some } from "lodash"

export default function isValidGeometry(geometry?: any): boolean {
if (isUndefined(geometry) || isNull(geometry)) { return true }
if (!isObject(geometry) ||
geometry.type !== "Point" ||
!isArray(geometry.coordinates) ||
geometry.coordinates.length !== 2 ||
some(geometry.coordinates, (coord) => !isFinite(coord))
) { return false }
return true
return false;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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