@cogover/sdk 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +55 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,69 +1,87 @@
1
1
  # `@cogover/sdk`
2
2
 
3
- TypeScript SDK dành cho code khách hàng chạy trên Cogover. Package cung cấp JavaScript
4
- implementation để chạy local và file khai báo `.d.ts` để IDE có autocomplete,
5
- documentation và type checking.
3
+ The TypeScript SDK for customer code running on Cogover. The package includes
4
+ type declarations for IDE autocomplete, inline documentation, and type checking.
6
5
 
7
- ## Cài đặt
6
+ ## Requirements
8
7
 
9
- Sau khi package được publish lên npm registry:
8
+ - Node.js 18 or later.
9
+ - A TypeScript project using ECMAScript Modules (ESM).
10
+
11
+ ## Installation
10
12
 
11
13
  ```bash
12
14
  npm install @cogover/sdk
13
15
  ```
14
16
 
15
- ## Sử dụng
17
+ ## Quick start
16
18
 
17
19
  ```typescript
18
20
  import { createGreeting } from "@cogover/sdk";
19
21
 
20
- console.log(createGreeting("Cogover")); // Hello Cogover
22
+ const greeting = createGreeting("Cogover");
23
+ console.log(greeting); // Hello Cogover
21
24
  ```
22
25
 
23
- Tài liệu chi tiết dành cho developer được duy trì trong
24
- `cogover-sdk/docs/` của source repository và không được đóng gói vào npm
25
- package.
26
+ The SDK uses named exports and currently has no default export.
26
27
 
27
- ## Các lệnh phát triển
28
+ ## Use in a Cogover handler
28
29
 
29
- ```bash
30
- npm install # Cài dependency theo package-lock.json
31
- npm run build # Build package và sinh runtime-tools/cogover-sdk.mjs
32
- npm run build:runtime # Sinh lại runtime module từ dist/index.js
33
- npm run typecheck # Kiểm tra TypeScript mà không sinh output
34
- npm test # Build rồi chạy test
35
- npm run check # Chạy typecheck và test
36
- npm run clean # Xóa dist/
37
- npm run pack:dry-run # Xem trước các file sẽ có trong npm package
30
+ ```typescript
31
+ import { createGreeting } from "@cogover/sdk";
32
+
33
+ interface Input {
34
+ name: string;
35
+ }
36
+
37
+ export default function handler(inputJson: string): string {
38
+ const input: Input = JSON.parse(inputJson);
39
+
40
+ return JSON.stringify({
41
+ greeting: createGreeting(input.name)
42
+ });
43
+ }
38
44
  ```
39
45
 
40
- ## Publish
46
+ A handler must default-export a synchronous function that accepts
47
+ `inputJson: string` and returns a JSON string or `null`.
41
48
 
42
- Cấu hình npm login/registry của Cogover, sau đó chạy:
49
+ ## API
43
50
 
44
- ```bash
45
- npm publish
51
+ ### `createGreeting(name)`
52
+
53
+ Creates a greeting by adding the `Hello ` prefix to a name.
54
+
55
+ ```typescript
56
+ function createGreeting(name: string): string;
46
57
  ```
47
58
 
48
- Với public npm registry, scoped package có thể cần:
59
+ Example:
49
60
 
50
- ```bash
51
- npm publish --access public
61
+ ```typescript
62
+ createGreeting("Cogover"); // "Hello Cogover"
52
63
  ```
53
64
 
54
- Lifecycle `prepack` tự chạy `npm run check`, do đó package không được đóng gói
55
- nếu typecheck hoặc test thất bại.
65
+ ## TypeScript
56
66
 
57
- ## Quan hệ với TypeScript Runtime
67
+ Type declarations are included in the package. After installation, IDEs can
68
+ resolve `@cogover/sdk` without a separate type package.
58
69
 
59
- Package này giúp IDE và môi trường local resolve `@cogover/sdk`. Khi project
60
- khách hàng được compile trên server, TypeScript Runtime thay import này bằng
61
- `runtime-tools/cogover-sdk.mjs` và không bundle `node_modules` của khách hàng.
70
+ Recommended `tsconfig.json` options:
62
71
 
63
- `src/index.ts` là source of truth. `npm run build` compile npm package và tự sinh lại
64
- `../runtime-tools/cogover-sdk.mjs` từ cùng source. Không sửa runtime module bằng
65
- tay. Test cũng so sánh public behavior của hai module để phát hiện sai lệch.
72
+ ```json
73
+ {
74
+ "compilerOptions": {
75
+ "target": "ES2022",
76
+ "module": "ESNext",
77
+ "moduleResolution": "Bundler",
78
+ "strict": true,
79
+ "noEmit": true,
80
+ "skipLibCheck": true
81
+ }
82
+ }
83
+ ```
66
84
 
67
85
  ## License
68
86
 
69
- `@cogover/sdk` được phát hành theo [MIT License](LICENSE).
87
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogover/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript SDK for customer code running on Cogover",
5
5
  "type": "module",
6
6
  "sideEffects": false,