From c62c521128e5044b419a6021f21f1ef1d0b45fff Mon Sep 17 00:00:00 2001 From: Mohammad AbuAboud Date: Sun, 23 Jun 2024 20:48:31 +0000 Subject: [PATCH] chore: remove lodash --- .eslintrc.json | 6 +++ package-lock.json | 1 - package.json | 1 - .../airtable/src/lib/common/index.ts | 2 +- packages/pieces/community/common/package.json | 2 +- .../src/lib/actions/read-connection.ts | 2 +- .../src/lib/actions/records/create-record.ts | 9 +++- .../contentful/src/lib/common/utils.ts | 3 +- .../src/lib/properties/content-model.ts | 4 +- .../src/lib/properties/dynamic-fields.ts | 4 +- .../contentful/src/lib/properties/locale.ts | 4 +- .../src/lib/properties/select-fields.ts | 12 +++--- .../pieces/community/data-mapper/package.json | 2 +- .../data-mapper/src/lib/data-mapper.mdx | 42 ------------------- .../pieces/community/framework/package.json | 2 +- .../src/lib/validators/validators.ts | 2 +- .../pieces/community/math-helper/package.json | 4 +- .../src/lib/triggers/new-database-item.ts | 2 +- .../community/retable/src/lib/common/index.ts | 2 +- .../src/lib/actions/text-to-image.ts | 3 +- .../pieces/community/text-helper/package.json | 2 +- .../src/lib/triggers/new-or-updated-record.ts | 17 +++++--- packages/server/api/src/app/app.ts | 2 +- .../hooks/community-authentication-hooks.ts | 3 +- .../saml-authn/authn-sso-saml-service.ts | 3 +- .../ee/license-keys/license-keys-service.ts | 3 +- .../ee/project-plan/project-plan.service.ts | 3 +- .../api/src/app/flows/flow/flow.controller.ts | 2 +- packages/shared/package.json | 2 +- packages/shared/src/lib/common/utils/utils.ts | 33 +++++++++++++++ packages/ui/feature-flow-builder/package.json | 2 +- packages/ui/feature-tags/package.json | 2 +- 32 files changed, 92 insertions(+), 91 deletions(-) delete mode 100644 packages/pieces/community/data-mapper/src/lib/data-mapper.mdx diff --git a/.eslintrc.json b/.eslintrc.json index 23fdc198aa..2f0b9608fc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,6 +18,12 @@ } ] } + ], + "no-restricted-imports": [ + "error", + { + "patterns": ["lodash", "lodash/*"] + } ] } }, diff --git a/package-lock.json b/package-lock.json index 74e286973a..c12545d156 100644 --- a/package-lock.json +++ b/package-lock.json @@ -239,7 +239,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", diff --git a/package.json b/package.json index dd77c2b5eb..54033a7aed 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/pieces/community/airtable/src/lib/common/index.ts b/packages/pieces/community/airtable/src/lib/common/index.ts index dcca9b3c9c..7b25c3b420 100644 --- a/packages/pieces/community/airtable/src/lib/common/index.ts +++ b/packages/pieces/community/airtable/src/lib/common/index.ts @@ -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, @@ -16,6 +15,7 @@ import { AirtableTable, AirtableView, } from './models'; +import { isNil } from '@activepieces/shared'; export const airtableCommon = { base: Property.Dropdown({ diff --git a/packages/pieces/community/common/package.json b/packages/pieces/community/common/package.json index 19c7b7383a..4c01effc40 100644 --- a/packages/pieces/community/common/package.json +++ b/packages/pieces/community/common/package.json @@ -1,5 +1,5 @@ { "name": "@activepieces/pieces-common", - "version": "0.2.14", + "version": "0.2.15", "type": "commonjs" } \ No newline at end of file diff --git a/packages/pieces/community/connections/src/lib/actions/read-connection.ts b/packages/pieces/community/connections/src/lib/actions/read-connection.ts index d0580dac6f..ebaeb9005d 100644 --- a/packages/pieces/community/connections/src/lib/actions/read-connection.ts +++ b/packages/pieces/community/connections/src/lib/actions/read-connection.ts @@ -1,5 +1,5 @@ import { Property, createAction } from '@activepieces/pieces-framework'; -import { isNil } from 'lodash'; +import { isNil } from '@activepieces/shared'; const markdown = ` **Advanced Piece** diff --git a/packages/pieces/community/contentful/src/lib/actions/records/create-record.ts b/packages/pieces/community/contentful/src/lib/actions/records/create-record.ts index 8cf5b5fb70..9fbae08648 100644 --- a/packages/pieces/community/contentful/src/lib/actions/records/create-record.ts +++ b/packages/pieces/community/contentful/src/lib/actions/records/create-record.ts @@ -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(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, diff --git a/packages/pieces/community/contentful/src/lib/common/utils.ts b/packages/pieces/community/contentful/src/lib/common/utils.ts index 7f6834baa3..8edea49496 100644 --- a/packages/pieces/community/contentful/src/lib/common/utils.ts +++ b/packages/pieces/community/contentful/src/lib/common/utils.ts @@ -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'] diff --git a/packages/pieces/community/contentful/src/lib/properties/content-model.ts b/packages/pieces/community/contentful/src/lib/properties/content-model.ts index 99ac00cbf8..290751ac9b 100644 --- a/packages/pieces/community/contentful/src/lib/properties/content-model.ts +++ b/packages/pieces/community/contentful/src/lib/properties/content-model.ts @@ -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({ displayName: 'Content Model', required: true, refreshers: [], options: async ({ auth }) => { - if (_.isEmpty(auth)) { + if (isEmpty(auth)) { return { disabled: true, options: [], diff --git a/packages/pieces/community/contentful/src/lib/properties/dynamic-fields.ts b/packages/pieces/community/contentful/src/lib/properties/dynamic-fields.ts index 20e5baa95d..572989f1e1 100644 --- a/packages/pieces/community/contentful/src/lib/properties/dynamic-fields.ts +++ b/packages/pieces/community/contentful/src/lib/properties/dynamic-fields.ts @@ -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', @@ -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 { diff --git a/packages/pieces/community/contentful/src/lib/properties/locale.ts b/packages/pieces/community/contentful/src/lib/properties/locale.ts index a4e7492248..54bc640cc4 100644 --- a/packages/pieces/community/contentful/src/lib/properties/locale.ts +++ b/packages/pieces/community/contentful/src/lib/properties/locale.ts @@ -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: [], diff --git a/packages/pieces/community/contentful/src/lib/properties/select-fields.ts b/packages/pieces/community/contentful/src/lib/properties/select-fields.ts index a960091bf6..4d6b2389b6 100644 --- a/packages/pieces/community/contentful/src/lib/properties/select-fields.ts +++ b/packages/pieces/community/contentful/src/lib/properties/select-fields.ts @@ -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', @@ -14,7 +14,7 @@ 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); @@ -22,10 +22,10 @@ const SelectFields = Property.MultiSelectDropdown({ 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) { diff --git a/packages/pieces/community/data-mapper/package.json b/packages/pieces/community/data-mapper/package.json index d05512d8b8..ac3e38e68d 100644 --- a/packages/pieces/community/data-mapper/package.json +++ b/packages/pieces/community/data-mapper/package.json @@ -1,4 +1,4 @@ { "name": "@activepieces/piece-data-mapper", - "version": "0.3.5" + "version": "0.3.6" } \ No newline at end of file diff --git a/packages/pieces/community/data-mapper/src/lib/data-mapper.mdx b/packages/pieces/community/data-mapper/src/lib/data-mapper.mdx deleted file mode 100644 index 2545cc76d7..0000000000 --- a/packages/pieces/community/data-mapper/src/lib/data-mapper.mdx +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: 'Data Mapper' -description: '' ---- - -This utility helps you map outputs of steps to a specific JSON object of your design. -Example: -if you have step_1 and its output is : - -```json -{ - "firstName": "John", - "lastName": "Smith", - "age": 25 -} -``` - -and you want to use "firstName" and "lastName" to create "name" in a new object, you can input this to the mapping input: - -```json -{ - "name": "{{step_1.firstName}} {{step_1.lastName}}" -} -``` - -This would be resolved to: - -```json -{ - "name": "John Smith" -} -``` - -If you pass in an object it will be resolved to an object even though it is passed as -a string like "\{\{step_1}\}". -If there is any string next to it, the object will be stringified and concatenated. - ---- - -## Actions - -ACTIONS diff --git a/packages/pieces/community/framework/package.json b/packages/pieces/community/framework/package.json index 3989b64e20..0f99b72828 100644 --- a/packages/pieces/community/framework/package.json +++ b/packages/pieces/community/framework/package.json @@ -1,5 +1,5 @@ { "name": "@activepieces/pieces-framework", - "version": "0.7.31", + "version": "0.7.32", "type": "commonjs" } \ No newline at end of file diff --git a/packages/pieces/community/framework/src/lib/validators/validators.ts b/packages/pieces/community/framework/src/lib/validators/validators.ts index 04f6a04c85..4ef1f1b9b8 100644 --- a/packages/pieces/community/framework/src/lib/validators/validators.ts +++ b/packages/pieces/community/framework/src/lib/validators/validators.ts @@ -1,5 +1,4 @@ import dayjs, { OpUnitType } from 'dayjs'; -import { isEmpty, isInteger, isNil, isString } from 'lodash'; import { ErrorMessages } from './errors'; import { TypedValidatorFn, @@ -8,6 +7,7 @@ import { } from './types'; import { formatErrorMessage } from './utils'; import { ApFile } from '../property'; +import { isEmpty } from '@activepieces/shared'; class Validators { static pattern( diff --git a/packages/pieces/community/math-helper/package.json b/packages/pieces/community/math-helper/package.json index 85baf0f688..4fa0708a21 100644 --- a/packages/pieces/community/math-helper/package.json +++ b/packages/pieces/community/math-helper/package.json @@ -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" } } \ No newline at end of file diff --git a/packages/pieces/community/notion/src/lib/triggers/new-database-item.ts b/packages/pieces/community/notion/src/lib/triggers/new-database-item.ts index 4146b577ac..8004a978ac 100644 --- a/packages/pieces/community/notion/src/lib/triggers/new-database-item.ts +++ b/packages/pieces/community/notion/src/lib/triggers/new-database-item.ts @@ -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, diff --git a/packages/pieces/community/retable/src/lib/common/index.ts b/packages/pieces/community/retable/src/lib/common/index.ts index 6b856f26d2..9e4815f399 100644 --- a/packages/pieces/community/retable/src/lib/common/index.ts +++ b/packages/pieces/community/retable/src/lib/common/index.ts @@ -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', diff --git a/packages/pieces/community/stable-diffusion-webui/src/lib/actions/text-to-image.ts b/packages/pieces/community/stable-diffusion-webui/src/lib/actions/text-to-image.ts index 7ebf197def..4f6f2eaf50 100644 --- a/packages/pieces/community/stable-diffusion-webui/src/lib/actions/text-to-image.ts +++ b/packages/pieces/community/stable-diffusion-webui/src/lib/actions/text-to-image.ts @@ -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', diff --git a/packages/pieces/community/text-helper/package.json b/packages/pieces/community/text-helper/package.json index 0611eef93f..15699835c8 100644 --- a/packages/pieces/community/text-helper/package.json +++ b/packages/pieces/community/text-helper/package.json @@ -1,4 +1,4 @@ { "name": "@activepieces/piece-text-helper", - "version": "0.2.0" + "version": "0.2.1" } \ No newline at end of file diff --git a/packages/pieces/community/vtiger/src/lib/triggers/new-or-updated-record.ts b/packages/pieces/community/vtiger/src/lib/triggers/new-or-updated-record.ts index a2b77d2e66..1b1d7b77f1 100644 --- a/packages/pieces/community/vtiger/src/lib/triggers/new-or-updated-record.ts +++ b/packages/pieces/community/vtiger/src/lib/triggers/new-or-updated-record.ts @@ -17,7 +17,6 @@ import { prepareHttpRequest, } from '../common'; import dayjs from 'dayjs'; -import { filter, sortBy } from 'lodash'; export const newOrUpdatedRecord = createTrigger({ auth: vtigerAuth, @@ -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); diff --git a/packages/server/api/src/app/app.ts b/packages/server/api/src/app/app.ts index ccf29fc75b..29c344aa8a 100644 --- a/packages/server/api/src/app/app.ts +++ b/packages/server/api/src/app/app.ts @@ -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' @@ -105,6 +104,7 @@ import { AppConnectionWithoutSensitiveData, Flow, FlowRun, + isNil, ProjectWithLimits, spreadIfDefined, UserInvitation, diff --git a/packages/server/api/src/app/authentication/authentication-service/hooks/community-authentication-hooks.ts b/packages/server/api/src/app/authentication/authentication-service/hooks/community-authentication-hooks.ts index 0846583a6e..94a0b6a208 100644 --- a/packages/server/api/src/app/authentication/authentication-service/hooks/community-authentication-hooks.ts +++ b/packages/server/api/src/app/authentication/authentication-service/hooks/community-authentication-hooks.ts @@ -1,4 +1,3 @@ -import { isNil } from 'lodash' import { flagService } from '../../../flags/flag.service' import { platformService } from '../../../platform/platform.service' import { projectService } from '../../../project/project-service' @@ -6,7 +5,7 @@ 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' diff --git a/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.ts b/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.ts index 16bd044954..6398adb87c 100644 --- a/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.ts +++ b/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.ts @@ -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 { diff --git a/packages/server/api/src/app/ee/license-keys/license-keys-service.ts b/packages/server/api/src/app/ee/license-keys/license-keys-service.ts index 23520e7972..e335069784 100644 --- a/packages/server/api/src/app/ee/license-keys/license-keys-service.ts +++ b/packages/server/api/src/app/ee/license-keys/license-keys-service.ts @@ -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' diff --git a/packages/server/api/src/app/ee/project-plan/project-plan.service.ts b/packages/server/api/src/app/ee/project-plan/project-plan.service.ts index 0286163d60..03e6d230d1 100644 --- a/packages/server/api/src/app/ee/project-plan/project-plan.service.ts +++ b/packages/server/api/src/app/ee/project-plan/project-plan.service.ts @@ -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 = diff --git a/packages/server/api/src/app/flows/flow/flow.controller.ts b/packages/server/api/src/app/flows/flow/flow.controller.ts index 76739606fd..7803cd3fa1 100644 --- a/packages/server/api/src/app/flows/flow/flow.controller.ts +++ b/packages/server/api/src/app/flows/flow/flow.controller.ts @@ -4,7 +4,6 @@ import { } from '@fastify/type-provider-typebox' import dayjs from 'dayjs' import { StatusCodes } from 'http-status-codes' -import { isNil } from 'lodash' import { entitiesMustBeOwnedByCurrentProject } from '../../authentication/authorization' import { assertUserHasPermissionToFlow } from '../../ee/authentication/rbac/rbac-middleware' import { eventsHooks } from '../../helper/application-events' @@ -20,6 +19,7 @@ import { FlowOperationRequest, FlowTemplateWithoutProjectInformation, GetFlowQueryParamsRequest, + isNil, ListFlowsRequest, Permission, PopulatedFlow, diff --git a/packages/shared/package.json b/packages/shared/package.json index 20d2ed5d56..652e48553f 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,5 +1,5 @@ { "name": "@activepieces/shared", - "version": "0.10.106", + "version": "0.10.107", "type": "commonjs" } \ No newline at end of file diff --git a/packages/shared/src/lib/common/utils/utils.ts b/packages/shared/src/lib/common/utils/utils.ts index 36d53a5053..3abf2b4aa1 100644 --- a/packages/shared/src/lib/common/utils/utils.ts +++ b/packages/shared/src/lib/common/utils/utils.ts @@ -6,6 +6,16 @@ export function isNil(value: T | null | undefined): value is null | undefined return value === null || value === undefined } +export function kebabCase(str: string): string { + return str + .replace(/([a-z])([A-Z])/g, '$1-$2') // Handle camelCase by adding hyphen between lowercase and uppercase letters + .replace(/\s+/g, '-') // Replace spaces with hyphens + .replace(/_/g, '-') // Replace underscores with hyphens + .toLowerCase() // Convert to lowercase + .replace(/^-+|-+$/g, '') // Remove leading and trailing hyphens +} + + export function isEmpty(value: T | null | undefined): boolean { if (value == null) { return true @@ -22,6 +32,29 @@ export function isEmpty(value: T | null | undefined): boolean { return false } +type Dictionary = { + [key: string]: T +} + +export function startCase(str: string): string { + return str + .replace(/([a-z])([A-Z])/g, '$1 $2') + .replace(/[_-]+/g, ' ') + .replace(/\s+/g, ' ') + .replace(/^[a-z]/, match => match.toUpperCase()) + .replace(/\b[a-z]/g, match => match.toUpperCase()) +} + +export function camelCase(str: string): string { + return str + .replace(/([-_][a-z])/g, group => group.toUpperCase() + .replace('-', '') + .replace('_', '')) +} + + + + export function pickBy>( object: T, predicate: (value: T[keyof T], key: keyof T) => boolean, diff --git a/packages/ui/feature-flow-builder/package.json b/packages/ui/feature-flow-builder/package.json index bfbb019d10..989b6287ab 100644 --- a/packages/ui/feature-flow-builder/package.json +++ b/packages/ui/feature-flow-builder/package.json @@ -8,7 +8,7 @@ "rxjs": "7.8.1", "@activepieces/ui/feature-builder-store": "0.0.1", "@activepieces/ui/feature-builder-left-sidebar": "0.0.1", - "@activepieces/shared": "0.10.106", + "@activepieces/shared": "0.10.107", "@activepieces/ui-canvas-utils": "0.0.1", "@ctrl/ngx-codemirror": "5.1.1", "angular-svg-icon": "15.0.0", diff --git a/packages/ui/feature-tags/package.json b/packages/ui/feature-tags/package.json index 9a7487e213..67781480e0 100644 --- a/packages/ui/feature-tags/package.json +++ b/packages/ui/feature-tags/package.json @@ -4,7 +4,7 @@ "peerDependencies": { "@activepieces/ui/common": "0.0.2", "rxjs": "7.8.1", - "@activepieces/shared": "0.10.106", + "@activepieces/shared": "0.10.107", "@angular/core": "18.0.3", "@angular/common": "18.0.3", "@angular/cdk": "18.0.3",