remove sdk/types package and move it to main sdk package

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-28 11:09:51 +01:00
parent a898cfb14a
commit 43b2fbe7e4
28 changed files with 48 additions and 393 deletions

View File

@@ -15,7 +15,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"@types/node": "^18.16.0",
"@types/ramda": "^0.29.6",
"eslint": "^8.48.0",

View File

@@ -26,7 +26,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"@types/node": "^18.16.0",
"@types/ramda": "^0.29.6",
"@types/uuid": "^9.0.8",

View File

@@ -15,7 +15,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"@types/node": "^18.16.0",
"eslint": "^8.48.0",
"prettier": "^3.0.3",

View File

@@ -15,7 +15,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"@types/node": "^18.16.0",
"eslint": "^8.48.0",
"prettier": "^3.0.3",

View File

@@ -2,9 +2,8 @@ import { AppState, Platform } from 'react-native';
import * as Application from 'expo-application';
import Constants from 'expo-constants';
import type { MixanOptions } from '@mixan/sdk';
import type { MixanOptions, PostEventPayload } from '@mixan/sdk';
import { Mixan } from '@mixan/sdk';
import type { PostEventPayload } from '@mixan/types';
type MixanNativeOptions = MixanOptions;

View File

@@ -15,7 +15,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",

View File

@@ -1,11 +1,11 @@
import Script from 'next/script';
import type { MixanWebOptions } from '@mixan/sdk-web';
import type {
MixanEventOptions,
MixanWebOptions,
PostEventPayload,
UpdateProfilePayload,
} from '@mixan/types';
} from '@mixan/sdk-web';
const CDN_URL = 'http://localhost:3002/op.js';

View File

@@ -20,7 +20,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",

View File

@@ -1,6 +1,7 @@
import type { MixanOptions } from '@mixan/sdk';
import type { MixanOptions, PostEventPayload } from '@mixan/sdk';
import { Mixan } from '@mixan/sdk';
import type { PostEventPayload } from '@mixan/types';
export * from '@mixan/sdk';
export type MixanWebOptions = MixanOptions & {
trackOutgoingLinks?: boolean;

View File

@@ -16,7 +16,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",

View File

@@ -1,10 +1,37 @@
import type {
DecrementProfilePayload,
IncrementProfilePayload,
MixanEventOptions,
PostEventPayload,
UpdateProfilePayload,
} from '@mixan/types';
// NEW
export interface MixanEventOptions {
profileId?: string;
}
export interface PostEventPayload {
name: string;
timestamp: string;
deviceId?: string;
profileId?: string;
properties?: Record<string, unknown> & MixanEventOptions;
}
export interface UpdateProfilePayload {
profileId: string;
firstName?: string;
lastName?: string;
email?: string;
avatar?: string;
properties?: Record<string, unknown>;
}
export interface IncrementProfilePayload {
profileId: string;
property: string;
value: number;
}
export interface DecrementProfilePayload {
profileId?: string;
property: string;
value: number;
}
export interface MixanOptions {
url: string;

View File

@@ -13,7 +13,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",

View File

@@ -1,13 +0,0 @@
# types
To install dependencies:
```bash
pnpm install
```
To run:
```bash
pnpm run index.ts
```

View File

@@ -1 +0,0 @@
export * from './src/sdk.types';

View File

@@ -1,27 +0,0 @@
{
"name": "@mixan/types",
"version": "0.0.1",
"module": "index.ts",
"scripts": {
"build": "rm -rf dist && tsup",
"lint": "eslint .",
"format": "prettier --check \"**/*.{mjs,ts,md,json}\"",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
},
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
}

View File

@@ -1,168 +0,0 @@
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export type MixanJson = Record<string, any>;
// Deprecated
export interface EventPayload {
name: string;
time: string;
profileId: string | null;
properties: MixanJson;
}
// Deprecated
export interface ProfilePayload {
first_name?: string;
last_name?: string;
email?: string;
avatar?: string;
id?: string;
properties?: MixanJson;
}
export type BatchPayload =
| {
type: 'increment';
payload: BatchProfileIncrementPayload;
}
| {
type: 'decrement';
payload: BatchProfileDecrementPayload;
}
| {
type: 'event';
payload: BatchEventPayload;
}
| {
type: 'create_profile';
payload: BatchCreateProfilePayload;
}
| {
type: 'update_profile';
payload: BatchUpdateProfilePayload;
}
| {
type: 'update_session';
payload: BatchUpdateSessionPayload;
}
| {
type: 'set_profile_property';
payload: BatchSetProfilePropertyPayload;
};
export interface BatchSetProfilePropertyPayload {
profileId: string;
name: string;
value: any;
update: boolean;
}
export interface CreateProfileResponse {
id: string;
}
export interface BatchCreateProfilePayload {
profileId: string;
properties?: MixanJson;
}
export interface BatchUpdateSessionPayload {
profileId: string;
properties?: MixanJson;
}
export interface BatchEventPayload {
name: string;
time: string;
profileId: string;
properties: MixanJson;
}
export interface BatchUpdateProfilePayload {
first_name?: string;
last_name?: string;
email?: string;
avatar?: string;
id?: string;
properties?: MixanJson;
profileId: string;
}
export interface ProfileIncrementPayload {
name: string;
value: number;
profileId: string;
}
export interface ProfileDecrementPayload {
name: string;
value: number;
profileId: string;
}
export interface BatchProfileIncrementPayload {
name: string;
value: number;
profileId: string;
}
export interface BatchProfileDecrementPayload {
name: string;
value: number;
profileId: string;
}
export interface MixanIssue {
field: string;
message: string;
value: any;
}
export interface MixanErrorResponse {
status: 'error';
code: number;
message: string;
issues?: MixanIssue[] | undefined;
stack?: string | undefined;
}
export interface MixanResponse<T> {
result: T;
status: 'ok';
}
// NEW
export interface MixanEventOptions {
profileId?: string;
}
export interface PostEventPayload {
name: string;
timestamp: string;
deviceId?: string;
profileId?: string;
properties?: Record<string, unknown> & MixanEventOptions;
}
export interface UpdateProfilePayload {
profileId: string;
firstName?: string;
lastName?: string;
email?: string;
avatar?: string;
properties?: MixanJson;
}
export interface IncrementProfilePayload {
profileId: string;
property: string;
value: number;
}
export interface DecrementProfilePayload {
profileId?: string;
property: string;
value: number;
}

View File

@@ -1,6 +0,0 @@
{
"extends": "@mixan/tsconfig/sdk.json",
"compilerOptions": {
"outDir": "dist"
}
}

View File

@@ -1,9 +0,0 @@
import { defineConfig } from 'tsup';
import config from '@mixan/tsconfig/tsup.config.json' assert { type: 'json' };
export default defineConfig({
...(config as any),
entry: ['index.ts', 'cdn.ts'],
format: ['cjs', 'esm', 'iife'],
});

View File

@@ -15,7 +15,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"@types/node": "^18.16.0",
"eslint": "^8.48.0",
"prettier": "^3.0.3",