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

@formbricks/js

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formbricks/js - npm Package Compare versions

Comparing version 0.1.22 to 1.0.0

dist/js/src/components/ConsentQuestion.d.ts

7

dist/js/src/App.d.ts

@@ -1,7 +0,8 @@

import type { JsConfig, Survey } from "../../types/js";
import type { TJsConfig } from "../../types/v1/js";
import type { TSurvey } from "../../types/v1/surveys";
import { VNode } from "preact";
import { IErrorHandler } from "./lib/errors";
interface AppProps {
config: JsConfig;
survey: Survey;
config: TJsConfig;
survey: TSurvey;
closeSurvey: () => Promise<void>;

@@ -8,0 +9,0 @@ errorHandler: IErrorHandler;

@@ -1,8 +0,7 @@

import type { CTAQuestion } from "../../../types/questions";
import { h } from "preact";
import { TResponseData } from "../../../types/v1/responses";
import type { TSurveyCTAQuestion } from "../../../types/v1/surveys";
interface CTAQuestionProps {
question: CTAQuestion;
onSubmit: (data: {
[x: string]: any;
}) => void;
question: TSurveyCTAQuestion;
onSubmit: (data: TResponseData) => void;
lastQuestion: boolean;

@@ -9,0 +8,0 @@ brandColor: string;

@@ -0,6 +1,10 @@

import type { PlacementType } from "@formbricks/types/js";
import { h, VNode } from "preact";
export default function Modal({ children, isOpen, close, }: {
export default function Modal({ children, isOpen, placement, clickOutside, darkOverlay, close, }: {
children: VNode;
isOpen: boolean;
placement: PlacementType;
clickOutside: boolean;
darkOverlay: boolean;
close: () => void;
}): h.JSX.Element;

@@ -1,8 +0,7 @@

import type { MultipleChoiceMultiQuestion } from "../../../types/questions";
import { h } from "preact";
import { TResponseData } from "../../../types/v1/responses";
import type { TSurveyMultipleChoiceMultiQuestion } from "../../../types/v1/surveys";
interface MultipleChoiceMultiProps {
question: MultipleChoiceMultiQuestion;
onSubmit: (data: {
[x: string]: any;
}) => void;
question: TSurveyMultipleChoiceMultiQuestion;
onSubmit: (data: TResponseData) => void;
lastQuestion: boolean;

@@ -9,0 +8,0 @@ brandColor: string;

import { h } from "preact";
import type { MultipleChoiceSingleQuestion } from "../../../types/questions";
import { TResponseData } from "../../../types/v1/responses";
import type { TSurveyMultipleChoiceSingleQuestion } from "../../../types/v1/surveys";
interface MultipleChoiceSingleProps {
question: MultipleChoiceSingleQuestion;
onSubmit: (data: {
[x: string]: any;
}) => void;
question: TSurveyMultipleChoiceSingleQuestion;
onSubmit: (data: TResponseData) => void;
lastQuestion: boolean;

@@ -9,0 +8,0 @@ brandColor: string;

import { h } from "preact";
import type { NPSQuestion } from "../../../types/questions";
import { TResponseData } from "../../../types/v1/responses";
import type { TSurveyNPSQuestion } from "../../../types/v1/surveys";
interface NPSQuestionProps {
question: NPSQuestion;
onSubmit: (data: {
[x: string]: any;
}) => void;
question: TSurveyNPSQuestion;
onSubmit: (data: TResponseData) => void;
lastQuestion: boolean;

@@ -9,0 +8,0 @@ brandColor: string;

@@ -1,8 +0,7 @@

import type { OpenTextQuestion } from "../../../types/questions";
import { h } from "preact";
import { TResponseData } from "../../../types/v1/responses";
import type { TSurveyOpenTextQuestion } from "../../../types/v1/surveys";
interface OpenTextQuestionProps {
question: OpenTextQuestion;
onSubmit: (data: {
[x: string]: any;
}) => void;
question: TSurveyOpenTextQuestion;
onSubmit: (data: TResponseData) => void;
lastQuestion: boolean;

@@ -9,0 +8,0 @@ brandColor: string;

import { h } from "preact";
import { type Question } from "@formbricks/types/questions";
import { TSurveyQuestion } from "../../../types/v1/surveys";
interface QuestionConditionalProps {
question: Question;
question: TSurveyQuestion;
onSubmit: (data: {

@@ -6,0 +6,0 @@ [x: string]: any;

import { h } from "preact";
import type { RatingQuestion } from "../../../types/questions";
import { TResponseData } from "../../../types/v1/responses";
import type { TSurveyRatingQuestion } from "../../../types/v1/surveys";
interface RatingQuestionProps {
question: RatingQuestion;
onSubmit: (data: {
[x: string]: any;
}) => void;
question: TSurveyRatingQuestion;
onSubmit: (data: TResponseData) => void;
lastQuestion: boolean;

@@ -9,0 +8,0 @@ brandColor: string;

@@ -1,7 +0,8 @@

import type { JsConfig, Survey } from "../../../types/js";
import type { TJsConfig } from "../../../types/v1/js";
import type { TSurvey } from "../../../types/v1/surveys";
import { h } from "preact";
import { IErrorHandler } from "../lib/errors";
interface SurveyViewProps {
config: JsConfig;
survey: Survey;
config: TJsConfig;
survey: TSurvey;
close: () => void;

@@ -8,0 +9,0 @@ errorHandler: IErrorHandler;

@@ -8,9 +8,13 @@ import type { InitConfig } from "../../types/js";

setAttribute: (key: string, value: string) => Promise<void>;
track: (eventName: string, properties?: any) => Promise<void>;
track: (name: string, properties?: any) => Promise<void>;
logout: () => Promise<void>;
refresh: () => Promise<void>;
registerRouteChange: () => Promise<void>;
getApi: () => import("@formbricks/api").FormbricksAPI;
getPerson: () => import("../../types/js").Person;
getPerson: () => {
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
};
};
export { formbricks as default };

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

import type { JsConfig } from "../../../types/js";
import { TJsConfig } from "@formbricks/types/v1/js";
export declare class Config {

@@ -6,6 +6,6 @@ private static instance;

static getInstance(): Config;
update(newConfig: Partial<JsConfig>): void;
get(): JsConfig;
update(newConfig: Partial<TJsConfig>): void;
get(): TJsConfig;
private loadFromLocalStorage;
private saveToLocalStorage;
}

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

import type { DisplayCreateRequest, JsConfig, Response } from "../../../types/js";
import type { TDisplay, TDisplayInput } from "../../../types/v1/displays";
import type { TJsConfig } from "../../../types/v1/js";
import { NetworkError, Result } from "./errors";
export declare const createDisplay: (displayCreateRequest: DisplayCreateRequest, config: JsConfig) => Promise<Result<Response, NetworkError>>;
export declare const markDisplayResponded: (displayId: string, config: JsConfig) => Promise<Result<void, NetworkError>>;
export declare const createDisplay: (displayCreateRequest: TDisplayInput, config: TJsConfig) => Promise<Result<TDisplay, NetworkError>>;
export declare const markDisplayResponded: (displayId: string, config: TJsConfig) => Promise<Result<void, NetworkError>>;

@@ -1,22 +0,11 @@

import type { Person } from "../../../types/js";
import type { Session, Settings } from "../../../types/js";
import { TJsState } from "@formbricks/types/v1/js";
import { AttributeAlreadyExistsError, MissingPersonError, NetworkError, Result } from "./errors";
export declare const createPerson: () => Promise<Result<{
session: Session;
person: Person;
settings: Settings;
}, NetworkError>>;
export declare const updatePersonUserId: (userId: string) => Promise<Result<{
person: Person;
settings: Settings;
}, NetworkError | MissingPersonError>>;
export declare const updatePersonAttribute: (key: string, value: string) => Promise<Result<{
person: Person;
settings: Settings;
}, NetworkError | MissingPersonError>>;
export declare const attributeAlreadySet: (key: string, value: string) => boolean;
export declare const attributeAlreadyExists: (key: string) => boolean;
import { TPerson } from "@formbricks/types/v1/people";
export declare const updatePersonUserId: (userId: string) => Promise<Result<TJsState, NetworkError | MissingPersonError>>;
export declare const updatePersonAttribute: (key: string, value: string) => Promise<Result<TJsState, NetworkError | MissingPersonError>>;
export declare const hasAttributeValue: (key: string, value: string) => boolean;
export declare const hasAttributeKey: (key: string) => boolean;
export declare const setPersonUserId: (userId: string) => Promise<Result<void, NetworkError | MissingPersonError | AttributeAlreadyExistsError>>;
export declare const setPersonAttribute: (key: string, value: string) => Promise<Result<void, NetworkError | MissingPersonError>>;
export declare const resetPerson: () => Promise<Result<void, NetworkError>>;
export declare const getPerson: () => Person;
export declare const getPerson: () => TPerson;

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

import type { JsConfig } from "../../../types/js";
import type { TJsConfig } from "../../../types/v1/js";
import type { TResponse, TResponseInput } from "../../../types/v1/responses";
import { NetworkError, Result } from "./errors";
export declare const createResponse: (responseInput: TResponseInput, config: any) => Promise<Result<TResponse, NetworkError>>;
export declare const updateResponse: (responseInput: TResponseInput, responseId: string, config: JsConfig) => Promise<Result<TResponse, NetworkError>>;
export declare const updateResponse: (responseInput: TResponseInput, responseId: string, config: TJsConfig) => Promise<Result<TResponse, NetworkError>>;

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

import type { Session, Settings } from "../../../types/js";
import { MissingPersonError, NetworkError, Result } from "./errors";
export declare const createSession: () => Promise<Result<{
session: Session;
settings: Settings;
}, NetworkError | MissingPersonError>>;
export declare const extendSession: (session: Session) => Session;
export declare const isExpired: (session: Session) => boolean;
export declare const extendOrCreateSession: () => Promise<Result<void, NetworkError | MissingPersonError>>;
import { TSession } from "@formbricks/types/v1/sessions";
export declare const isExpired: (session: TSession) => boolean;
export declare const cn: (...classes: any[]) => string;
export declare function isLight(color: any): boolean;
export declare const shuffleArray: (array: any[], shuffleOption: string) => any[];

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

import type { Survey } from "../../../types/js";
export declare const renderWidget: (survey: Survey) => void;
import type { TSurvey } from "../../../types/v1/surveys";
export declare const renderWidget: (survey: TSurvey) => void;
export declare const closeSurvey: () => Promise<void>;
export declare const addWidgetContainer: () => void;

@@ -39,3 +39,3 @@ import { Question } from "./questions";

apiHost: string;
logLevel?: "debug" | "error";
debug?: boolean;
errorHandler?: ErrorHandler;

@@ -49,2 +49,5 @@ }

formbricksSignature?: boolean;
placement?: PlacementType;
clickOutsideClose?: boolean;
darkOverlay?: boolean;
}

@@ -83,1 +86,2 @@ export interface JsConfig {

export type MatchType = "exactMatch" | "contains" | "startsWith" | "endsWith" | "notMatch" | "notContains";
export type PlacementType = "bottomLeft" | "bottomRight" | "topLeft" | "topRight" | "center";

@@ -14,3 +14,3 @@ export interface Choice {

}
export type Question = OpenTextQuestion | MultipleChoiceSingleQuestion | MultipleChoiceMultiQuestion | NPSQuestion | CTAQuestion | RatingQuestion;
export type Question = OpenTextQuestion | MultipleChoiceSingleQuestion | MultipleChoiceMultiQuestion | NPSQuestion | CTAQuestion | RatingQuestion | ConsentQuestion;
export interface IQuestion<T extends Logic> {

@@ -24,5 +24,7 @@ id: string;

logic?: T[];
isDraft?: boolean;
}
export interface OpenTextQuestion extends IQuestion<OpenTextLogic> {
type: QuestionType.OpenText;
longAnswer?: boolean;
placeholder?: string;

@@ -33,2 +35,3 @@ }

choices: Choice[];
shuffleOption: string;
}

@@ -38,2 +41,3 @@ export interface MultipleChoiceMultiQuestion extends IQuestion<MultipleChoiceMultiLogic> {

choices: Choice[];
shuffleOption: string;
}

@@ -59,3 +63,9 @@ export interface NPSQuestion extends IQuestion<NPSLogic> {

}
export type LogicCondition = "submitted" | "skipped" | "equals" | "notEquals" | "lessThan" | "lessEqual" | "greaterThan" | "greaterEqual" | "includesAll" | "includesOne";
export interface ConsentQuestion extends IQuestion<CTALogic> {
type: "consent";
html?: string;
label: string;
dismissButtonLabel?: string;
}
export type LogicCondition = "submitted" | "skipped" | "accepted" | "clicked" | "equals" | "notEquals" | "lessThan" | "lessEqual" | "greaterThan" | "greaterEqual" | "includesAll" | "includesOne";
export interface LogicBase {

@@ -83,3 +93,3 @@ condition: LogicCondition | undefined;

export interface CTALogic extends LogicBase {
condition: "submitted" | "skipped" | undefined;
condition: "clicked" | "skipped" | undefined;
value?: undefined;

@@ -91,2 +101,6 @@ }

}
export type Logic = OpenTextLogic | MultipleChoiceSingleLogic | MultipleChoiceMultiLogic | NPSLogic | CTALogic | RatingLogic;
export interface ConsentLogic extends LogicBase {
condition: "submitted" | "skipped" | "accepted" | undefined;
value: undefined;
}
export type Logic = OpenTextLogic | MultipleChoiceSingleLogic | MultipleChoiceMultiLogic | NPSLogic | CTALogic | RatingLogic | ConsentLogic;

@@ -7,2 +7,6 @@ import { Question } from "./questions";

}
export interface SurveyClosedMessage {
heading?: string;
subheading?: string;
}
export interface Survey {

@@ -28,2 +32,4 @@ id: string;

autoComplete: number | null;
surveyClosedMessage: SurveyClosedMessage | null;
closeOnDate: Date | null;
}

@@ -35,1 +41,12 @@ export interface AttributeFilter {

}
export interface SurveyNotificationData {
id: string;
numDisplays: number;
numDisplaysResponded: number;
responseLenght: number;
responseCompletedLength: number;
latestResponse: any;
questions: Question[];
status: "draft" | "inProgress" | "archived" | "paused" | "completed";
name: String;
}
export interface NotificationSettings {
[surveyId: string]: {
responseFinished: boolean;
weeklySummary: boolean;
alert: {
[surveyId: string]: boolean;
};
weeklySummary: {
[productId: string]: boolean;
};
}
import { z } from "zod";
export declare const ZDisplay: z.ZodObject<
{
export declare const ZDisplay: z.ZodObject<{
id: z.ZodString;

@@ -8,25 +7,20 @@ createdAt: z.ZodDate;

surveyId: z.ZodString;
person: z.ZodNullable<
z.ZodObject<
{
id: z.ZodString;
attributes: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
},
"strip",
z.ZodTypeAny,
{
id?: string;
attributes?: Record<string, string | number>;
},
{
id?: string;
attributes?: Record<string, string | number>;
}
>
>;
person: z.ZodNullable<z.ZodObject<{
id: z.ZodString;
attributes: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
createdAt: z.ZodDate;
updatedAt: z.ZodDate;
}, "strip", z.ZodTypeAny, {
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
}, {
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
}>>;
status: z.ZodEnum<["seen", "responded"]>;
},
"strip",
z.ZodTypeAny,
{
}, "strip", z.ZodTypeAny, {
id?: string;

@@ -37,8 +31,9 @@ createdAt?: Date;

person?: {
id?: string;
attributes?: Record<string, string | number>;
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
};
status?: "seen" | "responded";
},
{
}, {
id?: string;

@@ -49,25 +44,20 @@ createdAt?: Date;

person?: {
id?: string;
attributes?: Record<string, string | number>;
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
};
status?: "seen" | "responded";
}
>;
}>;
export type TDisplay = z.infer<typeof ZDisplay>;
export declare const ZDisplayInput: z.ZodObject<
{
export declare const ZDisplayInput: z.ZodObject<{
surveyId: z.ZodString;
personId: z.ZodOptional<z.ZodString>;
},
"strip",
z.ZodTypeAny,
{
}, "strip", z.ZodTypeAny, {
surveyId?: string;
personId?: string;
},
{
}, {
surveyId?: string;
personId?: string;
}
>;
}>;
export type TDisplayInput = z.infer<typeof ZDisplayInput>;

@@ -7,9 +7,15 @@ import z from "zod";

attributes: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
createdAt: z.ZodDate;
updatedAt: z.ZodDate;
}, "strip", z.ZodTypeAny, {
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
}, {
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
}>;
export type TPerson = z.infer<typeof ZPerson>;

@@ -60,8 +60,14 @@ import { z } from "zod";

attributes: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
createdAt: z.ZodDate;
updatedAt: z.ZodDate;
}, "strip", z.ZodTypeAny, {
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
}, {
id?: string;
attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
}>>;

@@ -132,2 +138,4 @@ personAttributes: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;

attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
};

@@ -162,2 +170,4 @@ personAttributes?: Record<string, string | number>;

attributes?: Record<string, string | number>;
createdAt?: Date;
updatedAt?: Date;
};

@@ -164,0 +174,0 @@ personAttributes?: Record<string, string | number>;

import { z } from "zod";
export declare const ZUserNotificationSettings: z.ZodRecord<z.ZodString, z.ZodObject<{
responseFinished: z.ZodBoolean;
weeklySummary: z.ZodBoolean;
export declare const ZUserNotificationSettings: z.ZodObject<{
alert: z.ZodRecord<z.ZodString, z.ZodBoolean>;
weeklySummary: z.ZodRecord<z.ZodString, z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
responseFinished?: boolean;
weeklySummary?: boolean;
alert?: Record<string, boolean>;
weeklySummary?: Record<string, boolean>;
}, {
responseFinished?: boolean;
weeklySummary?: boolean;
}>>;
alert?: Record<string, boolean>;
weeklySummary?: Record<string, boolean>;
}>;
export type TUserNotificationSettings = z.infer<typeof ZUserNotificationSettings>;

@@ -27,10 +27,13 @@ import { z } from "zod";

url: z.ZodString;
trigger: z.ZodEnum<["responseFinished", "responseCreated", "responseUpdated"]>;
triggers: z.ZodArray<z.ZodEnum<["responseFinished", "responseCreated", "responseUpdated"]>, "many">;
surveyIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
url?: string;
trigger?: "responseFinished" | "responseCreated" | "responseUpdated";
triggers?: ("responseFinished" | "responseCreated" | "responseUpdated")[];
surveyIds?: string[];
}, {
url?: string;
trigger?: "responseFinished" | "responseCreated" | "responseUpdated";
triggers?: ("responseFinished" | "responseCreated" | "responseUpdated")[];
surveyIds?: string[];
}>;
export type TWebhookInput = z.infer<typeof ZWebhookInput>;
{
"name": "@formbricks/js",
"license": "MIT",
"version": "0.1.22",
"version": "1.0.0",
"description": "Formbricks-js allows you to connect your app to Formbricks, display surveys and trigger events.",

@@ -38,24 +38,23 @@ "keywords": [

"author": "Formbricks <hola@formbricks.com>",
"dependencies": {},
"devDependencies": {
"@types/enzyme": "^3.10.13",
"@types/jest": "^29.5.2",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@babel/core": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"@babel/preset-typescript": "^7.22.5",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"autoprefixer": "^10.4.14",
"babel-jest": "^29.6.1",
"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
"enzyme-adapter-preact-pure": "^4.1.0",
"eslint": "^8.42.0",
"eslint-config-preact": "^1.3.0",
"jest": "^29.5.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"jest-fetch-mock": "^3.0.3",
"jest-preset-preact": "^4.0.5",
"microbundle": "^0.15.1",
"postcss": "^8.4.24",
"preact": "10.15.1",
"preact-cli": "^3.4.5",
"preact-render-to-string": "^6.1.0",
"rimraf": "^5.0.1",
"tailwindcss": "^3.3.2",
"typescript": "^5.1.3",
"preact": "10.16.0",
"preact-cli": "^3.4.6",
"preact-render-to-string": "^6.2.0",
"regenerator-runtime": "^0.13.11",
"@formbricks/api": "0.1.0",

@@ -66,10 +65,17 @@ "@formbricks/types": "0.0.0",

"jest": {
"preset": "jest-preset-preact",
"transformIgnorePatterns": [
"!node_modules/"
],
"setupFiles": [
"<rootDir>/tests/__mocks__/setupTests.js"
]
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/tests/__mocks__/styleMock.js"
}
},
"scripts": {
"clean": "rimraf .turbo node_modules dist",
"dev": "microbundle --css inline",
"dev": "microbundle --css inline --watch",
"go": "microbundle --css inline --watch",
"lint": "eslint '{src,tests}/**/*.{ts,tsx}'",

@@ -76,0 +82,0 @@ "test": "jest",

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

Sorry, the diff of this file is not supported yet

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