Skip to content

Commit

Permalink
chore: remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad AbuAboud committed Jun 23, 2024
1 parent 54cb67f commit c62c521
Show file tree
Hide file tree
Showing 32 changed files with 92 additions and 91 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
}
]
}
],
"no-restricted-imports": [
"error",
{
"patterns": ["lodash", "lodash/*"]
}
]
}
},
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@
"@types/is-base64": "1.1.1",
"@types/jest": "29.4.4",
"@types/json2xml": "0.1.1",
"@types/lodash": "4.17.0",
"@types/mailchimp__mailchimp_marketing": "3.0.10",
"@types/mailparser": "3.4.0",
"@types/marked": "4.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/airtable/src/lib/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '@activepieces/pieces-common';
import { DynamicPropsValue, Property } from '@activepieces/pieces-framework';
import Airtable from 'airtable';
import { isNil } from 'lodash';
import {
AirtableBase,
AirtableEnterpriseFields,
Expand All @@ -16,6 +15,7 @@ import {
AirtableTable,
AirtableView,
} from './models';
import { isNil } from '@activepieces/shared';

export const airtableCommon = {
base: Property.Dropdown({
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/common/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@activepieces/pieces-common",
"version": "0.2.14",
"version": "0.2.15",
"type": "commonjs"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Property, createAction } from '@activepieces/pieces-framework';
import { isNil } from 'lodash';
import { isNil } from '@activepieces/shared';

const markdown = `
**Advanced Piece**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ import {
} from '@activepieces/pieces-framework';
import { ContentfulAuth, PropertyKeys, makeClient } from '../../common';
import { ContentfulProperty } from '../../properties';
import keyBy from 'lodash/keyBy';
import { FieldProcessors } from '../../properties/processors';

function keyBy<T>(array: T[], key: keyof T): { [key: string]: T } {
return (array || []).reduce((result, item) => {
const keyValue = key ? item[key] : (item as unknown as string);
result[keyValue as unknown as string] = item;
return result;
}, {} as { [key: string]: T });
}

export const ContentfulCreateRecordAction = createAction({
name: 'contentful_record_create',
auth: ContentfulAuth,
Expand Down
3 changes: 1 addition & 2 deletions packages/pieces/community/contentful/src/lib/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { camelCase, startCase } from '@activepieces/shared';
import { ContentFields } from 'contentful-management';
import camelCase from 'lodash/camelCase';
import startCase from 'lodash/startCase';

export const getLinkHelperText = (
validations: ContentFields['validations']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { DropdownOption, Property } from '@activepieces/pieces-framework';
import _ from 'lodash';
import { ContentfulAuth, makeClient } from '../common';
import { isEmpty } from '@activepieces/shared';

const ContentModel = Property.Dropdown<string>({
displayName: 'Content Model',
required: true,
refreshers: [],
options: async ({ auth }) => {
if (_.isEmpty(auth)) {
if (isEmpty(auth)) {
return {
disabled: true,
options: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DynamicPropsValue, Property } from '@activepieces/pieces-framework';
import { ContentfulAuth, PropertyKeys, makeClient } from '../common';
import _ from 'lodash';
import { FieldTransformers } from './transformers';
import { FieldType } from 'contentful-management';
import { isEmpty, isNil } from '@activepieces/shared';

const DynamicFields = Property.DynamicProperties({
displayName: 'Fields',
Expand All @@ -14,7 +14,7 @@ const DynamicFields = Property.DynamicProperties({
[PropertyKeys.CONTENT_MODEL]: model,
[PropertyKeys.LOCALE]: locale,
}) => {
if (_.isEmpty(auth) || _.isNil(model)) return {};
if (isEmpty(auth) || isNil(model)) return {};
const dynamicFields: DynamicPropsValue = {};
const { client } = makeClient(auth as ContentfulAuth);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { DropdownOption, Property } from '@activepieces/pieces-framework';
import _ from 'lodash';
import { ContentfulAuth, makeClient } from '../common';
import { isEmpty } from '@activepieces/shared';

const Locale = Property.Dropdown({
displayName: 'Content Locale',
required: true,
refreshers: [],
options: async ({ auth }) => {
if (_.isEmpty(auth)) {
if (isEmpty(auth)) {
return {
disabled: true,
options: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DropdownState, Property } from '@activepieces/pieces-framework';
import { ContentfulAuth, PropertyKeys, makeClient } from '../common';
import _ from 'lodash';
import { isEmpty, isNil } from '@activepieces/shared';

const SelectFields = Property.MultiSelectDropdown({
displayName: 'Return Fields',
Expand All @@ -14,18 +14,18 @@ const SelectFields = Property.MultiSelectDropdown({
placeholder: '',
};

if (_.isEmpty(auth) || _.isNil(model)) return searchFields;
if (isEmpty(auth) || isNil(model)) return searchFields;

try {
const { client } = makeClient(auth as ContentfulAuth);
const contentType = await client.contentType.get({
contentTypeId: model as unknown as string,
});
// Process available options
searchFields.options = _.chain(contentType.fields)
.filter((f) => !!f.id && !f.omitted && !f.disabled && !f.deleted)
.map((f) => ({ label: f.name, value: `fields.${f.id}` }))
.value();
searchFields.options = contentType.fields
.filter((f) => !!f.id && !f.omitted && !f.disabled && !f.deleted)
.map((f) => ({ label: f.name as string, value: `fields.${f.id}` }));

searchFields.disabled = false;
searchFields.placeholder = 'Select fields to return';
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/data-mapper/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-data-mapper",
"version": "0.3.5"
"version": "0.3.6"
}
42 changes: 0 additions & 42 deletions packages/pieces/community/data-mapper/src/lib/data-mapper.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/pieces/community/framework/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@activepieces/pieces-framework",
"version": "0.7.31",
"version": "0.7.32",
"type": "commonjs"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dayjs, { OpUnitType } from 'dayjs';
import { isEmpty, isInteger, isNil, isString } from 'lodash';
import { ErrorMessages } from './errors';
import {
TypedValidatorFn,
Expand All @@ -8,6 +7,7 @@ import {
} from './types';
import { formatErrorMessage } from './utils';
import { ApFile } from '../property';
import { isEmpty } from '@activepieces/shared';

class Validators {
static pattern(
Expand Down
4 changes: 2 additions & 2 deletions packages/pieces/community/math-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@activepieces/piece-math-helper",
"version": "0.0.8",
"dependencies": {
"@activepieces/pieces-framework": "0.7.31",
"@activepieces/shared": "0.10.106",
"@activepieces/pieces-framework": "0.7.32",
"@activepieces/shared": "0.10.107",
"tslib": "2.6.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import dayjs from 'dayjs';
import { notionCommon } from '../common';
import { Client } from '@notionhq/client';
import { notionAuth } from '../..';
import { isNil } from 'lodash';
import { isNil } from '@activepieces/shared';

export const newDatabaseItem = createTrigger({
auth: notionAuth,
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/retable/src/lib/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
RetableProject,
RetableTable,
} from './models';
import { isNil } from 'lodash';
import { isNil } from '@activepieces/shared';

export const retableCommon = {
baseUrl: 'https://api.retable.io/v1/public',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { randomBytes } from 'node:crypto';
import { kebabCase } from 'lodash';

import {
httpClient,
HttpMethod,
HttpRequest,
} from '@activepieces/pieces-common';
import { stableDiffusionAuth, StableDiffusionAuthType } from '../../index';
import { kebabCase } from '@activepieces/shared';

export const textToImage = createAction({
name: 'textToImage',
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/text-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-text-helper",
"version": "0.2.0"
"version": "0.2.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
prepareHttpRequest,
} from '../common';
import dayjs from 'dayjs';
import { filter, sortBy } from 'lodash';

export const newOrUpdatedRecord = createTrigger({
auth: vtigerAuth,
Expand Down Expand Up @@ -127,14 +126,20 @@ const fetchRecords = async ({
const records = response.body.result;
const limit = propsValue['limit'] as number;

const newOrUpdatedRecords = filter(records, (record) => {
const newOrUpdatedRecords = records.filter((record) => {
const watchTime = dayjs(record[propsValue['watchBy'] as string] ?? 0);
return watchTime.diff(lastFetch) >= 0;
});
const sortedRecords = sortBy(
newOrUpdatedRecords,
(record) => record[propsValue['watchBy'] as string]
);
const sortedRecords = newOrUpdatedRecords.sort((a, b) => {
const key = propsValue['watchBy'] as string;
if (a[key] < b[key]) {
return -1;
}
if (a[key] > b[key]) {
return 1;
}
return 0;
});

if (limit > 0) {
return sortedRecords.slice(0, limit);
Expand Down
2 changes: 1 addition & 1 deletion packages/server/api/src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import fastify, { FastifyInstance, FastifyRequest, HTTPMethods } from 'fastify'
import fastifyFavicon from 'fastify-favicon'
import { fastifyRawBody } from 'fastify-raw-body'
import fastifySocketIO from 'fastify-socket.io'
import { isNil } from 'lodash'
import qs from 'qs'
import { Socket } from 'socket.io'
import { setPlatformOAuthService } from './app-connection/app-connection-service/oauth2'
Expand Down Expand Up @@ -105,6 +104,7 @@ import {
AppConnectionWithoutSensitiveData,
Flow,
FlowRun,
isNil,
ProjectWithLimits,
spreadIfDefined,
UserInvitation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { isNil } from 'lodash'
import { flagService } from '../../../flags/flag.service'
import { platformService } from '../../../platform/platform.service'
import { projectService } from '../../../project/project-service'
import { userService } from '../../../user/user-service'
import { userInvitationsService } from '../../../user-invitations/user-invitation.service'
import { accessTokenManager } from '../../lib/access-token-manager'
import { AuthenticationServiceHooks } from './authentication-service-hooks'
import { ActivepiecesError, ApFlagId, assertNotNullOrUndefined, ErrorCode, PrincipalType, Project, ProjectMemberRole, User } from '@activepieces/shared'
import { ActivepiecesError, ApFlagId, assertNotNullOrUndefined, ErrorCode, isNil, PrincipalType, Project, ProjectMemberRole, User } from '@activepieces/shared'

const DEFAULT_PLATFORM_NAME = 'platform'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

import { isNil } from 'lodash'
import { userService } from '../../../user/user-service'
import { createSamlClient, IdpLoginResponse, SamlAttributes } from './saml-client'
import { cryptoUtils } from '@activepieces/server-shared'
import { PlatformRole, SAMLAuthnProviderConfig, User } from '@activepieces/shared'
import { isNil, PlatformRole, SAMLAuthnProviderConfig, User } from '@activepieces/shared'

export const authnSsoSamlService = {
async login(platformId: string, samlProvider: SAMLAuthnProviderConfig): Promise<LoginResponse> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import dayjs from 'dayjs'
import { StatusCodes } from 'http-status-codes'
import { isNil } from 'lodash'
import { flagService } from '../../flags/flag.service'
import { telemetry } from '../../helper/telemetry.utils'
import { pieceMetadataService } from '../../pieces/piece-metadata-service'
import { platformService } from '../../platform/platform.service'
import { userService } from '../../user/user-service'
import { logger, rejectedPromiseHandler } from '@activepieces/server-shared'
import { ActivepiecesError, ApEdition, CreateTrialLicenseKeyRequestBody, ErrorCode, LicenseKeyEntity, PackageType, PlatformRole, TelemetryEventName, UserStatus } from '@activepieces/shared'
import { ActivepiecesError, ApEdition, CreateTrialLicenseKeyRequestBody, ErrorCode, isNil, LicenseKeyEntity, PackageType, PlatformRole, TelemetryEventName, UserStatus } from '@activepieces/shared'

const secretManagerLicenseKeysRoute = 'https://secrets.activepieces.com/license-keys'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { isNil } from 'lodash'
import { databaseConnection } from '../../database/database-connection'
import { ProjectPlanEntity } from './project-plan.entity'
import { DEFAULT_FREE_PLAN_LIMIT, FlowPlanLimits } from '@activepieces/ee-shared'
import {
ActivepiecesError,
apId, ErrorCode, ProjectPlan,
apId, ErrorCode, isNil, ProjectPlan,
} from '@activepieces/shared'

const projectPlanRepo =
Expand Down
Loading

0 comments on commit c62c521

Please sign in to comment.