# @crosscopy/core

> Shared js library for main CrossCopy logic

Latest version **0.1.0-alpha.36** (published 2023-02-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install @crosscopy/core
pnpm add @crosscopy/core
yarn add @crosscopy/core
bun add @crosscopy/core
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.36 |
| Published | 2023-02-06 |
| First published | 2022-11-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 19 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Huakun Shen |
| Maintainers | huakunshen |
| Keywords | crosscopy |

## Links

- npm: https://www.npmjs.com/package/@crosscopy/core
- Repository: https://github.com/CrossCopy/crosscopy-core
- Homepage: https://github.com/CrossCopy/crosscopy-core#readme
- Issues: https://github.com/CrossCopy/crosscopy-core/issues
- npm.io page: https://npm.io/package/@crosscopy/core

## Dependencies (19)

- [npm](https://npm.io/package/npm.md) ^8.13.1
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.1
- [events](https://npm.io/package/events.md) ^3.3.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [install](https://npm.io/package/install.md) ^0.13.0
- [sqlite3](https://npm.io/package/sqlite3.md) ^5.0.8
- [typeorm](https://npm.io/package/typeorm.md) ^0.3.6
- [prettier](https://npm.io/package/prettier.md) ^2.7.1
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.1.1
- [clipboardy](https://npm.io/package/clipboardy.md) ^2.3.0
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.12.6
- [@crosscopy/db](https://npm.io/package/@crosscopy/db.md) *
- [graphql-request](https://npm.io/package/graphql-request.md) ^4.3.0
- [@notionhq/client](https://npm.io/package/@notionhq/client.md) ^1.0.4
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^4.5.1
- [@crosscopy/graphql-schema](https://npm.io/package/@crosscopy/graphql-schema.md) ^0.1.3-pre-alpha.4
- [@graphql-typed-document-node/core](https://npm.io/package/@graphql-typed-document-node/core.md) ^3.1.1

## Recent versions

- 0.1.0-alpha.36 (latest) — 2023-02-06
- 0.1.0-alpha.9 — 2023-02-06
- 0.1.0-alpha.8 — 2023-02-06
- 0.1.0-alpha.7 — 2023-02-06
- 0.1.0-alpha.6 — 2023-02-06
- 0.1.0-alpha.5 — 2023-02-06
- 0.1.0-alpha.4 — 2023-02-06
- 0.1.0-alpha.3 — 2023-02-06
- 0.1.0-alpha.2 — 2023-02-06
- 0.1.0-alpha.1 — 2023-02-06
- 0.0.5-alpha.16 — 2023-02-06
- 0.0.5-alpha.15 — 2023-02-05
- 0.0.5-alpha.14 — 2022-12-24
- 0.0.4-alpha.5 — 2022-12-03
- 0.0.4-alpha.4 — 2022-11-10
- … 1 more at https://npm.io/package/@crosscopy/core/versions

## README

# crosscopy-core

Core npm package containing main logic and algorithms used in crosscopy

# Main Components

- crypto
  - For encryption and decryption
- plugin
  - A plugin system
  - Including plugins
    - `encryptionPlugin`
    - `syncPlugin`
    - `notionPlugin`
- database

# Limitation

This package doesn't support ESM. Although a ESM version is compiled, it won 't work due to missing ESM of crypto.js.

# NPM Package

## Install Package

If you want to install this package, set the registry first

```bash
# choose one of the following if you don't have a .npmrc file
npm config set @crosscopy:registry https://registry.npmjs.org
npm config set @crosscopy:registry https://npm.pkg.github.com
```

## Publish Package

```bash
# publish to npmjs registry
npm config set @crosscopy:registry https://registry.npmjs.org
npm publish --access public

# publish to github registry
npm config set @crosscopy:registry https://npm.pkg.github.com
npm publish
```

## Sample Usage

### Service

```ts
import { PrismaClient } from '@prisma/client';
import { createClient, RedisClientType } from 'redis';
import {
  UserServiceImpl,
  UserServicePrismaImpl,
  UserServiceRedisImpl,
} from '@crosscopy/core/service';

import dotenv from 'dotenv';

dotenv.config();

const url = process.env.DATABASE_URL;
const prisma = new PrismaClient({ datasources: { db: { url } } });
const redisUrl = process.env.REDIS_URL;
const redisClient: RedisClientType = createClient({ url: redisUrl });

redisClient.connect().then(() => {
  const userServiceRedis = new UserServiceRedisImpl(redisClient);
  const userServicePrisma = new UserServicePrismaImpl(prisma, redisClient);
  const userService = new UserServiceImpl(
    userServicePrisma,
    userServiceRedis,
    redisClient
  );

  userService.findByUsername('username').then((user) => {
    console.log(user);
  });
});
```


```json
".": {
  "require": "./dist/index.cjs",
  "import": "./dist/index.js",
  "types": "./dist/index.d.ts"
},
"./plugin": {
  "require": "./dist/plugin.cjs",
  "import": "./dist/plugin.js",
  "types": "./dist/plugin.d.ts"
},
"./crypto": {
  "require": "./dist/crypto.cjs",
  "import": "./dist/crypto.js",
  "types": "./dist/crypto.d.ts"
},
"./io": {
  "require": "./dist/io.cjs",
  "import": "./dist/io.js",
  "types": "./dist/io.d.ts"
},
"./syncer": {
  "require": "./dist/syncer.cjs",
  "import": "./dist/syncer.js",
  "types": "./dist/syncer.d.ts"
},
"./util": {
  "require": "./dist/util.cjs",
  "import": "./dist/util.js",
  "types": "./dist/util.d.ts"
},
"./service": {
  "require": "./dist/service.cjs",
  "import": "./dist/service.js",
  "types": "./dist/service.d.ts"
}

```

---
_Source: https://npm.io/package/@crosscopy/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
