This commit is contained in:
Carl-Gerhard Lindesvärd
2023-10-11 12:34:35 +02:00
commit 903fd155c3
40 changed files with 1385 additions and 0 deletions

15
packages/types/README.md Normal file
View File

@@ -0,0 +1,15 @@
# types
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run index.ts
```
This project was created using `bun init` in bun v1.0.4. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

74
packages/types/index.ts Normal file
View File

@@ -0,0 +1,74 @@
export type MixanJson = Record<string, any>
export type EventPayload = {
name: string
time: string
externalId: string | null
properties: MixanJson
}
export type ProfilePayload = {
first_name?: string
last_name?: string
email?: string
avatar?: string
id: string
properties: MixanJson
}
export type ProfileIncrementPayload = {
name: string
value: number
id: string
}
export type ProfileDecrementPayload = {
name: string
value: number
id: string
}
// Batching
export type BatchEvent = {
type: 'event',
payload: EventPayload
}
export type BatchProfile = {
type: 'profile',
payload: ProfilePayload
}
export type BatchProfileIncrement = {
type: 'profile_increment',
payload: ProfileIncrementPayload
}
export type BatchProfileDecrement = {
type: 'profile_decrement',
payload: ProfileDecrementPayload
}
export type BatchItem = BatchEvent | BatchProfile | BatchProfileIncrement | BatchProfileDecrement
export type BatchPayload = Array<BatchItem>
export type MixanIssue = {
field: string
message: string
value: any
}
export type MixanIssuesResponse = {
issues: Array<MixanIssue>,
}
export type MixanErrorResponse = {
code: string
message: string
}
export type MixanResponse<T> = {
result: T
status: 'ok'
}

View File

@@ -0,0 +1,12 @@
{
"name": "@mixan/types",
"version": "0.0.1",
"type": "module",
"module": "index.ts",
"devDependencies": {
"bun-types": "latest"
},
"dependencies": {
"typescript": "^5.0.0"
}
}

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"noEmit": true,
"composite": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
}

View File

@@ -0,0 +1,10 @@
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["index.ts"],
format: ["cjs", "esm"], // Build for commonJS and ESmodules
dts: true, // Generate declaration file (.d.ts)
splitting: false,
sourcemap: false,
clean: true,
});