@23blocks/block-company 2.0.0 → 3.0.1
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.
- package/README.md +267 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# @23blocks/block-company
|
|
2
|
+
|
|
3
|
+
Company block for the 23blocks SDK - company settings, departments, teams, and organizational structure.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@23blocks/block-company)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @23blocks/block-company @23blocks/transport-http
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
This package provides company and organizational management functionality including:
|
|
17
|
+
|
|
18
|
+
- **Companies** - Company settings and configuration
|
|
19
|
+
- **Departments** - Department hierarchy management
|
|
20
|
+
- **Teams** - Team management
|
|
21
|
+
- **Team Members** - Team membership management
|
|
22
|
+
- **Quarters** - Fiscal quarters and planning periods
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { createHttpTransport } from '@23blocks/transport-http';
|
|
28
|
+
import { createCompanyBlock } from '@23blocks/block-company';
|
|
29
|
+
|
|
30
|
+
const transport = createHttpTransport({
|
|
31
|
+
baseUrl: 'https://api.yourapp.com',
|
|
32
|
+
headers: () => {
|
|
33
|
+
const token = localStorage.getItem('access_token');
|
|
34
|
+
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const company = createCompanyBlock(transport, {
|
|
39
|
+
apiKey: 'your-api-key',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Get current company
|
|
43
|
+
const currentCompany = await company.companies.getCurrent();
|
|
44
|
+
console.log(currentCompany.name, currentCompany.domain);
|
|
45
|
+
|
|
46
|
+
// List departments
|
|
47
|
+
const { data: departments } = await company.departments.list();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Services
|
|
51
|
+
|
|
52
|
+
### companies - Company Management
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// List companies
|
|
56
|
+
const { data: companies } = await company.companies.list();
|
|
57
|
+
|
|
58
|
+
// Get company by ID
|
|
59
|
+
const companyData = await company.companies.get('company-id');
|
|
60
|
+
|
|
61
|
+
// Get current company
|
|
62
|
+
const current = await company.companies.getCurrent();
|
|
63
|
+
|
|
64
|
+
// Create company
|
|
65
|
+
const newCompany = await company.companies.create({
|
|
66
|
+
name: 'Acme Corp',
|
|
67
|
+
domain: 'acme.com',
|
|
68
|
+
industry: 'Technology',
|
|
69
|
+
size: '100-500',
|
|
70
|
+
timezone: 'America/New_York',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Update company
|
|
74
|
+
await company.companies.update('company-id', {
|
|
75
|
+
name: 'Acme Corporation',
|
|
76
|
+
settings: {
|
|
77
|
+
brandColor: '#0066cc',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Delete company
|
|
82
|
+
await company.companies.delete('company-id');
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### departments - Department Management
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// List departments
|
|
89
|
+
const { data: departments } = await company.departments.list({
|
|
90
|
+
companyId: 'company-id',
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Get department by ID
|
|
94
|
+
const department = await company.departments.get('department-id');
|
|
95
|
+
|
|
96
|
+
// Get department hierarchy
|
|
97
|
+
const hierarchy = await company.departments.getHierarchy('company-id');
|
|
98
|
+
|
|
99
|
+
// Create department
|
|
100
|
+
const newDepartment = await company.departments.create({
|
|
101
|
+
companyId: 'company-id',
|
|
102
|
+
name: 'Engineering',
|
|
103
|
+
code: 'ENG',
|
|
104
|
+
parentId: null, // Top-level department
|
|
105
|
+
managerId: 'user-id',
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Update department
|
|
109
|
+
await company.departments.update('department-id', {
|
|
110
|
+
name: 'Software Engineering',
|
|
111
|
+
managerId: 'new-manager-id',
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Delete department
|
|
115
|
+
await company.departments.delete('department-id');
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### teams - Team Management
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// List teams
|
|
122
|
+
const { data: teams } = await company.teams.list({
|
|
123
|
+
departmentId: 'department-id',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Get team by ID
|
|
127
|
+
const team = await company.teams.get('team-id');
|
|
128
|
+
|
|
129
|
+
// Create team
|
|
130
|
+
const newTeam = await company.teams.create({
|
|
131
|
+
departmentId: 'department-id',
|
|
132
|
+
name: 'Backend Team',
|
|
133
|
+
description: 'API and infrastructure development',
|
|
134
|
+
leadId: 'user-id',
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Update team
|
|
138
|
+
await company.teams.update('team-id', {
|
|
139
|
+
name: 'Platform Team',
|
|
140
|
+
leadId: 'new-lead-id',
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Delete team
|
|
144
|
+
await company.teams.delete('team-id');
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### teamMembers - Team Member Management
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// List team members
|
|
151
|
+
const { data: members } = await company.teamMembers.list({
|
|
152
|
+
teamId: 'team-id',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Get member by ID
|
|
156
|
+
const member = await company.teamMembers.get('member-id');
|
|
157
|
+
|
|
158
|
+
// Add team member
|
|
159
|
+
const newMember = await company.teamMembers.add({
|
|
160
|
+
teamId: 'team-id',
|
|
161
|
+
userId: 'user-id',
|
|
162
|
+
role: 'developer',
|
|
163
|
+
startDate: '2024-01-15',
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Update team member
|
|
167
|
+
await company.teamMembers.update('member-id', {
|
|
168
|
+
role: 'senior_developer',
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Remove team member
|
|
172
|
+
await company.teamMembers.remove('member-id');
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### quarters - Quarter Management
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// List quarters
|
|
179
|
+
const { data: quarters } = await company.quarters.list({
|
|
180
|
+
year: 2024,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Get quarter by ID
|
|
184
|
+
const quarter = await company.quarters.get('quarter-id');
|
|
185
|
+
|
|
186
|
+
// Get current quarter
|
|
187
|
+
const currentQuarter = await company.quarters.getCurrent();
|
|
188
|
+
|
|
189
|
+
// Create quarter
|
|
190
|
+
const newQuarter = await company.quarters.create({
|
|
191
|
+
companyId: 'company-id',
|
|
192
|
+
name: 'Q1 2024',
|
|
193
|
+
year: 2024,
|
|
194
|
+
quarter: 1,
|
|
195
|
+
startDate: '2024-01-01',
|
|
196
|
+
endDate: '2024-03-31',
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Update quarter
|
|
200
|
+
await company.quarters.update('quarter-id', {
|
|
201
|
+
goals: ['Launch v2.0', 'Expand to EU market'],
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Delete quarter
|
|
205
|
+
await company.quarters.delete('quarter-id');
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Types
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import type {
|
|
212
|
+
Company,
|
|
213
|
+
Department,
|
|
214
|
+
DepartmentHierarchy,
|
|
215
|
+
Team,
|
|
216
|
+
TeamMember,
|
|
217
|
+
Quarter,
|
|
218
|
+
CreateCompanyRequest,
|
|
219
|
+
CreateDepartmentRequest,
|
|
220
|
+
CreateTeamRequest,
|
|
221
|
+
AddTeamMemberRequest,
|
|
222
|
+
CreateQuarterRequest,
|
|
223
|
+
} from '@23blocks/block-company';
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Company
|
|
227
|
+
|
|
228
|
+
| Property | Type | Description |
|
|
229
|
+
|----------|------|-------------|
|
|
230
|
+
| `id` | `string` | Company ID |
|
|
231
|
+
| `name` | `string` | Company name |
|
|
232
|
+
| `domain` | `string` | Company domain |
|
|
233
|
+
| `industry` | `string` | Industry sector |
|
|
234
|
+
| `size` | `string` | Company size range |
|
|
235
|
+
| `timezone` | `string` | Default timezone |
|
|
236
|
+
| `settings` | `object` | Company settings |
|
|
237
|
+
|
|
238
|
+
### Department
|
|
239
|
+
|
|
240
|
+
| Property | Type | Description |
|
|
241
|
+
|----------|------|-------------|
|
|
242
|
+
| `id` | `string` | Department ID |
|
|
243
|
+
| `name` | `string` | Department name |
|
|
244
|
+
| `code` | `string` | Department code |
|
|
245
|
+
| `parentId` | `string` | Parent department ID |
|
|
246
|
+
| `managerId` | `string` | Manager user ID |
|
|
247
|
+
|
|
248
|
+
### Team
|
|
249
|
+
|
|
250
|
+
| Property | Type | Description |
|
|
251
|
+
|----------|------|-------------|
|
|
252
|
+
| `id` | `string` | Team ID |
|
|
253
|
+
| `name` | `string` | Team name |
|
|
254
|
+
| `description` | `string` | Team description |
|
|
255
|
+
| `departmentId` | `string` | Parent department ID |
|
|
256
|
+
| `leadId` | `string` | Team lead user ID |
|
|
257
|
+
|
|
258
|
+
## Related Packages
|
|
259
|
+
|
|
260
|
+
- [`@23blocks/block-authentication`](https://www.npmjs.com/package/@23blocks/block-authentication) - User management
|
|
261
|
+
- [`@23blocks/angular`](https://www.npmjs.com/package/@23blocks/angular) - Angular integration
|
|
262
|
+
- [`@23blocks/react`](https://www.npmjs.com/package/@23blocks/react) - React integration
|
|
263
|
+
- [`@23blocks/sdk`](https://www.npmjs.com/package/@23blocks/sdk) - Full SDK package
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
MIT - Copyright (c) 2024 23blocks
|
package/package.json
CHANGED