@formbricks/js
Advanced tools
Comparing version 2.0.0-beta.1 to 2.0.0-beta.2
@@ -1,6 +0,190 @@ | ||
import { TFormbricksApp } from '@formbricks/js-core/app'; | ||
import { z } from 'zod'; | ||
declare class ActionAPI { | ||
private apiHost; | ||
private environmentId; | ||
constructor(apiHost: string, environmentId: string); | ||
create(actionInput: Omit<TActionInput, "environmentId">): Promise<Result<{}, NetworkError | Error>>; | ||
} | ||
declare interface ApiConfig { | ||
environmentId: string; | ||
apiHost: string; | ||
} | ||
declare class AttributeAPI { | ||
private apiHost; | ||
private environmentId; | ||
constructor(apiHost: string, environmentId: string); | ||
update(attributeUpdateInput: Omit<TAttributeUpdateInput, "environmentId">): Promise<Result<{ | ||
changed: boolean; | ||
message: string; | ||
}, NetworkError | Error>>; | ||
} | ||
declare class Client { | ||
response: ResponseAPI; | ||
display: DisplayAPI; | ||
action: ActionAPI; | ||
people: PeopleAPI; | ||
storage: StorageAPI; | ||
attribute: AttributeAPI; | ||
constructor(options: ApiConfig); | ||
} | ||
declare class DisplayAPI { | ||
private apiHost; | ||
private environmentId; | ||
constructor(baseUrl: string, environmentId: string); | ||
create(displayInput: Omit<TDisplayCreateInput, "environmentId">): Promise<Result<{ | ||
id: string; | ||
}, NetworkError | Error>>; | ||
update(displayId: string, displayInput: Omit<TDisplayUpdateInput, "environmentId">): Promise<Result<{}, NetworkError | Error>>; | ||
} | ||
declare const formbricks: { | ||
init: (initConfig: TJsAppConfigInput) => Promise<void>; | ||
setEmail: (email: string) => Promise<void>; | ||
setAttribute: (key: string, value: any) => Promise<void>; | ||
track: (name: string, properties?: any) => Promise<void>; | ||
logout: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
registerRouteChange: () => Promise<void>; | ||
getApi: () => FormbricksAPI; | ||
}; | ||
declare class FormbricksAPI { | ||
client: Client; | ||
constructor(options: ApiConfig); | ||
} | ||
declare const formbricksApp: TFormbricksApp; | ||
export default formbricksApp; | ||
declare type NetworkError = { | ||
code: "network_error"; | ||
message: string; | ||
status: number; | ||
url: URL; | ||
}; | ||
declare class PeopleAPI { | ||
private apiHost; | ||
private environmentId; | ||
constructor(apiHost: string, environmentId: string); | ||
create(userId: string): Promise<Result<{}, NetworkError | Error>>; | ||
} | ||
declare class ResponseAPI { | ||
private apiHost; | ||
private environmentId; | ||
constructor(apiHost: string, environmentId: string); | ||
create(responseInput: Omit<TResponseInput, "environmentId">): Promise<Result<{ | ||
id: string; | ||
}, NetworkError | Error>>; | ||
update({ responseId, finished, data, ttc, }: TResponseUpdateInputWithResponseId): Promise<Result<{}, NetworkError | Error>>; | ||
} | ||
declare type Result<T, E = Error> = { ok: true; data: T } | { ok: false; error: E }; | ||
declare class StorageAPI { | ||
private apiHost; | ||
private environmentId; | ||
constructor(apiHost: string, environmentId: string); | ||
uploadFile(file: File, { allowedFileExtensions, surveyId }?: TUploadFileConfig | undefined): Promise<string>; | ||
} | ||
declare type TActionInput = z.infer<typeof ZActionInput>; | ||
declare type TAttributeUpdateInput = z.infer<typeof ZAttributeUpdateInput>; | ||
declare type TDisplayCreateInput = z.infer<typeof ZDisplayCreateInput>; | ||
declare type TDisplayUpdateInput = z.infer<typeof ZDisplayUpdateInput>; | ||
declare type TFormbricksApp = typeof formbricks; | ||
declare type TJsAppConfigInput = z.infer<typeof ZJsAppConfigInput>; | ||
declare type TResponseInput = z.infer<typeof ZResponseInput>; | ||
declare type TResponseUpdateInput = z.infer<typeof ZResponseUpdateInput>; | ||
declare type TResponseUpdateInputWithResponseId = TResponseUpdateInput & { | ||
responseId: string; | ||
}; | ||
declare type TUploadFileConfig = z.infer<typeof ZUploadFileConfig>; | ||
declare const ZActionInput = z.object({ | ||
environmentId: z.string().cuid(), | ||
userId: z.string(), | ||
name: z.string(), | ||
}); | ||
declare const ZAttributeUpdateInput = z.object({ | ||
environmentId: z.string().cuid2(), | ||
userId: z.string(), | ||
attributes: z.record(z.string()), | ||
}); | ||
declare const ZDisplayCreateInput = z.object({ | ||
environmentId: z.string().cuid(), | ||
surveyId: z.string().cuid(), | ||
userId: z.string().optional(), | ||
responseId: z.string().cuid().optional(), | ||
}); | ||
declare const ZDisplayUpdateInput = z.object({ | ||
environmentId: z.string().cuid(), | ||
userId: z.string().optional(), | ||
responseId: z.string().cuid().optional(), | ||
}); | ||
declare const ZJsAppConfigInput = z.object({ | ||
environmentId: z.string().cuid(), | ||
apiHost: z.string(), | ||
errorHandler: z.function().args(z.any()).returns(z.void()).optional(), | ||
userId: z.string(), | ||
attributes: z.record(z.string()).optional(), | ||
}); | ||
declare const ZResponseInput = z.object({ | ||
environmentId: z.string().cuid2(), | ||
surveyId: z.string().cuid2(), | ||
userId: z.string().nullish(), | ||
singleUseId: z.string().nullable().optional(), | ||
finished: z.boolean(), | ||
language: z.string().optional(), | ||
data: ZResponseData, | ||
ttc: ZResponseTtc.optional(), | ||
meta: z | ||
.object({ | ||
source: z.string().optional(), | ||
url: z.string().optional(), | ||
userAgent: z | ||
.object({ | ||
browser: z.string().optional(), | ||
device: z.string().optional(), | ||
os: z.string().optional(), | ||
}) | ||
.optional(), | ||
country: z.string().optional(), | ||
action: z.string().optional(), | ||
}) | ||
.optional(), | ||
}); | ||
declare const ZResponseUpdateInput = z.object({ | ||
finished: z.boolean(), | ||
data: ZResponseData, | ||
ttc: ZResponseTtc.optional(), | ||
language: z.string().optional(), | ||
}); | ||
declare const ZUploadFileConfig = z.object({ | ||
allowedFileExtensions: z.array(z.string()).optional(), | ||
surveyId: z.string().optional(), | ||
}); | ||
export { } | ||
@@ -7,0 +191,0 @@ |
@@ -1,6 +0,24 @@ | ||
import { TFormbricksWebsite } from '@formbricks/js-core/website'; | ||
import z from 'zod'; | ||
declare const formbricks: { | ||
init: (initConfig: TJsWebsiteConfigInput) => Promise<void>; | ||
track: (name: string, properties?: any) => Promise<void>; | ||
reset: () => Promise<void>; | ||
registerRouteChange: () => Promise<void>; | ||
}; | ||
declare const formbricksApp: TFormbricksWebsite; | ||
export default formbricksApp; | ||
declare type TFormbricksWebsite = typeof formbricks; | ||
declare type TJsWebsiteConfigInput = z.infer<typeof ZJsWebsiteConfigInput>; | ||
declare const ZJsWebsiteConfigInput = z.object({ | ||
environmentId: z.string().cuid(), | ||
apiHost: z.string(), | ||
errorHandler: z.function().args(z.any()).returns(z.void()).optional(), | ||
attributes: z.record(z.string()).optional(), | ||
}); | ||
export { } | ||
@@ -7,0 +25,0 @@ |
{ | ||
"name": "@formbricks/js", | ||
"license": "MIT", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-beta.2", | ||
"description": "Formbricks-js allows you to connect your app to Formbricks, display surveys and trigger events.", | ||
@@ -6,0 +6,0 @@ "homepage": "https://formbricks.com", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50340
381
4