added tooling (eslint, typescript and prettier)

This commit is contained in:
Carl-Gerhard Lindesvärd
2023-11-02 12:14:37 +01:00
parent 575b3c23bf
commit 493e1b7650
82 changed files with 1890 additions and 1363 deletions

View File

@@ -1,76 +1,76 @@
export type MixanJson = Record<string, any>
export type MixanJson = Record<string, any>;
export type EventPayload = {
name: string
time: string
profileId: string | null
properties: MixanJson
export interface EventPayload {
name: string;
time: string;
profileId: string | null;
properties: MixanJson;
}
export type ProfilePayload = {
first_name?: string
last_name?: string
email?: string
avatar?: string
id?: string
properties?: MixanJson
export interface 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 interface ProfileIncrementPayload {
name: string;
value: number;
id: string;
}
export type ProfileDecrementPayload = {
name: string
value: number
id: string
export interface ProfileDecrementPayload {
name: string;
value: number;
id: string;
}
// Batching
export type BatchEvent = {
type: 'event'
payload: EventPayload
export interface BatchEvent {
type: 'event';
payload: EventPayload;
}
export type BatchProfile = {
type: 'profile'
payload: ProfilePayload
export interface BatchProfile {
type: 'profile';
payload: ProfilePayload;
}
export type BatchProfileIncrement = {
type: 'profile_increment'
payload: ProfileIncrementPayload
export interface BatchProfileIncrement {
type: 'profile_increment';
payload: ProfileIncrementPayload;
}
export type BatchProfileDecrement = {
type: 'profile_decrement'
payload: ProfileDecrementPayload
export interface BatchProfileDecrement {
type: 'profile_decrement';
payload: ProfileDecrementPayload;
}
export type BatchItem =
| BatchEvent
| BatchProfile
| BatchProfileIncrement
| BatchProfileDecrement
export type BatchPayload = Array<BatchItem>
| BatchProfileDecrement;
export type BatchPayload = BatchItem[];
export type MixanIssue = {
field: string
message: string
value: any
export interface MixanIssue {
field: string;
message: string;
value: any;
}
export type MixanErrorResponse = {
status: 'error'
code: number
message: string
issues?: Array<MixanIssue> | undefined
stack?: string | undefined
export interface MixanErrorResponse {
status: 'error';
code: number;
message: string;
issues?: MixanIssue[] | undefined;
stack?: string | undefined;
}
export type MixanResponse<T> = {
result: T
status: 'ok'
export interface MixanResponse<T> {
result: T;
status: 'ok';
}

View File

@@ -3,8 +3,22 @@
"version": "0.0.1",
"type": "module",
"module": "index.ts",
"scripts": {
"lint": "eslint .",
"format": "prettier --check \"**/*.{mjs,ts,md,json}\"",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"tsup": "^7.2.0",
"typescript": "^5.0.0"
}
}
"typescript": "^5.2.0"
},
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
}

View File

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