Skip to content

Commit

Permalink
feat: Added basic types
Browse files Browse the repository at this point in the history
  • Loading branch information
cmath10 committed Apr 26, 2024
1 parent 7ef75a7 commit 6bb2706
Show file tree
Hide file tree
Showing 10 changed files with 3,150 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Tests

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
eslint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 18.18.x, 20.x ]

steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: .yarn
key: ${{ runner.OS }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-${{ matrix.node-version }}-yarn-
- name: Install dependencies
run: yarn install

- name: Run lint
run: yarn lint
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.vscode
node_modules
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea
.vscode
node_modules

.gitignore
eslint.config.mjs
tsconfig.json
yarn.lock
43 changes: 43 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { FlatCompat } from '@eslint/eslintrc'

import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'

import globals from 'globals'
import pluginJs from '@eslint/js'
import stylistic from '@stylistic/eslint-plugin'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: pluginJs.configs.recommended,
})

// noinspection JSUnusedGlobalSymbols
export default [
{
languageOptions: {
globals: globals.browser,
parserOptions: {
project: './tsconfig.eslint.json',
},
},
},
stylistic.configs['recommended-flat'],
...compat.extends('standard-with-typescript'),
{
rules: {
'@stylistic/semi': ['error', 'never'],
'@typescript-eslint/comma-dangle': ['error', {
arrays: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
imports: 'always-multiline',
objects: 'always-multiline',
}],
'@typescript-eslint/naming-convention': 'off',
},
},
]
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@retailcrm/embed-ui",
"type": "module",
"version": "0.0.0",
"description": "API and components for creating RetailCRM UI extensions",
"main": "index.js",
"repository": "[email protected]:retailcrm/embed-ui.git",
"author": "RetailDriverLLC <[email protected]>",
"license": "MIT",
"contributors": [
"Kirill Zaytsev <[email protected]>"
],
"scripts": {
"lint": "eslint ."
},
"dependencies": {
"@remote-ui/core": "^2.2.4",
"@remote-ui/rpc": "^1.4.5"
},
"devDependencies": {
"@eslint/eslintrc": "^3.0.2",
"@eslint/js": "^9.1.1",
"@stylistic/eslint-plugin": "^1.7.2",
"eslint": "^9.1.1",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^17.3.1",
"eslint-plugin-promise": "^6.1.1",
"globals": "^15.0.0",
"standard-version": "^9.5.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.7.1"
},
"publishConfig": {
"access": "public"
}
}
44 changes: 44 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
],
"module": "esnext",
"moduleResolution": "node",
"paths": {
"@/*": ["./src/*"],
"~types/*": ["./types/*"],
"~tests/*": ["./tests/*"]
},
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": false,
"strict": true,
"target": "es2016",
"types": [
"node"
],
"useDefineForClassFields": true
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"src/shims-*.d.ts",
"tests/**/*.ts",
"tests/**/*.vue",
"tests/shims-*.d.ts",
"eslint.config.mjs"
]
}
18 changes: 18 additions & 0 deletions types/endpoint.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type {
AnyFunction,
None,
} from './scaffolding'

import type { RemoteChannel } from '@remote-ui/core'
import type { Endpoint as RemoteEndpoint } from '@remote-ui/rpc'

export interface EndpointApi<
PageApi extends Record<string, AnyFunction> = None
> {
run (channel: RemoteChannel, api: PageApi): Promise<void>;
release (): void;
}

export type Endpoint<
PageApi extends Record<string, AnyFunction> = None
> = RemoteEndpoint<EndpointApi<PageApi>>
11 changes: 11 additions & 0 deletions types/pages/order.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export type OrderCardMethods = {
getCustomerEmail: () => string | null,
setCustomerEmail: (value: string) => void,

getCustomerPhone: () => string | null,
setCustomerPhone: (value: string) => void,

getDeliveryAddress: () => string | null,
setDeliveryAddress: (value: string) => void,
parseDeliveryAddress: () => void,
}
2 changes: 2 additions & 0 deletions types/scaffolding.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type AnyFunction = (...payload: any[]) => unknown
export type None = Record<string, never>
Loading

0 comments on commit 6bb2706

Please sign in to comment.