@ssoeasy-dev/proto 1.1.1-beta.2 → 1.1.1-beta.4
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 +107 -164
- package/gen/ts/auth/v1/auth.ts +147 -0
- package/gen/ts/companies/v1/employee.ts +327 -0
- package/gen/ts/index.companies.v1.ts +1 -0
- package/package.json +1 -9
- package/proto/auth/v1/auth.proto +9 -0
- package/proto/companies/v1/employee.proto +22 -0
package/README.md
CHANGED
|
@@ -1,228 +1,171 @@
|
|
|
1
|
-
# SSO Easy
|
|
1
|
+
# SSO Easy — Protocol Buffers
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
4
|
|
|
5
5
|
Централизованный репозиторий Protocol Buffers контрактов для SSO Easy микросервисной архитектуры.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Пространства имён
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Пакет | Сервисы | Потребители |
|
|
10
|
+
| -------------- | ----------------------------------------------- | --------------------------- |
|
|
11
|
+
| `auth.v1` | AuthService, VerificationService | `auth.api`, `auth.svc` |
|
|
12
|
+
| `companies.v1` | CompanyService, EmployeeService, ServiceService | `auth.api`, `companies.svc` |
|
|
13
|
+
| `common.v1` | Общие типы (StatusResponse и др.) | все сервисы |
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
go get github.com/ssoeasy-dev/proto@latest
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Или конкретная версия:
|
|
15
|
+
## Структура проекта
|
|
16
16
|
|
|
17
|
-
```bash
|
|
18
|
-
go get github.com/ssoeasy-dev/proto@v1.0.0
|
|
19
17
|
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
.
|
|
19
|
+
├── proto/ # Исходные .proto файлы
|
|
20
|
+
│ ├── auth/v1/ # AuthService, VerificationService
|
|
21
|
+
│ ├── companies/v1/ # CompanyService, EmployeeService, ServiceService
|
|
22
|
+
│ └── common/v1/ # Общие типы
|
|
23
|
+
├── gen/go/ # Сгенерированный Go код (коммитится)
|
|
24
|
+
│ ├── auth/v1/
|
|
25
|
+
│ ├── companies/v1/
|
|
26
|
+
│ └── common/v1/
|
|
27
|
+
├── gen/ts/ # Сгенерированный TypeScript код (коммитится)
|
|
28
|
+
│ ├── index.ts
|
|
29
|
+
│ ├── index.auth.ts
|
|
30
|
+
│ ├── index.companies.ts
|
|
31
|
+
│ └── index.common.ts
|
|
32
|
+
├── buf.yaml
|
|
33
|
+
├── buf.gen.yaml # Генерация Go кода
|
|
34
|
+
├── buf.gen.ts.yaml # Генерация TypeScript кода
|
|
35
|
+
├── go.mod
|
|
36
|
+
├── package.json
|
|
37
|
+
├── Makefile
|
|
38
|
+
├── workflow.md # Процесс работы с изменениями и релизами
|
|
39
|
+
└── README.md
|
|
25
40
|
```
|
|
26
41
|
|
|
27
|
-
|
|
42
|
+
## Использование в сервисах
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
npm install @ssoeasy-dev/proto@1.0.0
|
|
31
|
-
```
|
|
44
|
+
### `auth.svc` и `companies.svc` (Go)
|
|
32
45
|
|
|
33
|
-
|
|
46
|
+
Подключение в `go.mod`:
|
|
34
47
|
|
|
35
|
-
```
|
|
36
|
-
|
|
48
|
+
```go
|
|
49
|
+
require github.com/ssoeasy-dev/proto v1.1.1
|
|
37
50
|
```
|
|
38
51
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Импорт в Go проект
|
|
52
|
+
Импорт в коде:
|
|
42
53
|
|
|
43
54
|
```go
|
|
44
|
-
package main
|
|
45
|
-
|
|
46
55
|
import (
|
|
47
|
-
|
|
48
|
-
"
|
|
56
|
+
authpb "github.com/ssoeasy-dev/proto/gen/go/auth/v1"
|
|
57
|
+
companiespb "github.com/ssoeasy-dev/proto/gen/go/companies/v1"
|
|
58
|
+
commonpb "github.com/ssoeasy-dev/proto/gen/go/common/v1"
|
|
49
59
|
)
|
|
50
|
-
|
|
51
|
-
func main() {
|
|
52
|
-
conn, _ := grpc.Dial("localhost:50051", grpc.WithInsecure())
|
|
53
|
-
defer conn.Close()
|
|
54
|
-
|
|
55
|
-
client := pb.NewCompanyServiceClient(conn)
|
|
56
|
-
// Используйте client...
|
|
57
|
-
}
|
|
58
60
|
```
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
import { CompanyServiceClient } from '@ssoeasy-dev/proto/companies';
|
|
64
|
-
import { CredentialServiceClient } from '@ssoeasy-dev/proto/auth';
|
|
65
|
-
import { EmployeeAttributeServiceClient } from '@ssoeasy-dev/proto/abac';
|
|
62
|
+
Обновление до последней версии:
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
```bash
|
|
65
|
+
go get github.com/ssoeasy-dev/proto@latest
|
|
66
|
+
go mod tidy
|
|
68
67
|
```
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
### Требования
|
|
73
|
-
|
|
74
|
-
- Go 1.24+
|
|
75
|
-
- Node.js 20+ (для TypeScript генерации и npm публикации)
|
|
76
|
-
- pnpm (для управления npm зависимостями)
|
|
77
|
-
- [Buf CLI](https://buf.build/docs/installation)
|
|
69
|
+
### `auth.api` (TypeScript / NestJS)
|
|
78
70
|
|
|
79
|
-
|
|
71
|
+
Подключение в `package.json`:
|
|
80
72
|
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# Linux
|
|
86
|
-
curl -sSL "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m)" \
|
|
87
|
-
-o "/usr/local/bin/buf"
|
|
88
|
-
chmod +x /usr/local/bin/buf
|
|
89
|
-
|
|
90
|
-
# Или через Go
|
|
91
|
-
make install-tools
|
|
73
|
+
```json
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@ssoeasy-dev/proto": "1.1.1"
|
|
76
|
+
}
|
|
92
77
|
```
|
|
93
78
|
|
|
94
|
-
|
|
79
|
+
Импорт в коде:
|
|
95
80
|
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
make format # Отформатировать proto файлы
|
|
103
|
-
make breaking # Проверить breaking changes
|
|
104
|
-
make clean # Очистить сгенерированные файлы
|
|
105
|
-
make tag VERSION=v1.0.0 # Создать git тег для релиза
|
|
106
|
-
make sync-version # Синхронизировать версию package.json с git тегом
|
|
107
|
-
make publish-npm # Опубликовать npm пакет (автоматически синхронизирует версию)
|
|
108
|
-
```
|
|
81
|
+
```typescript
|
|
82
|
+
// gRPC клиенты для auth.svc
|
|
83
|
+
import {
|
|
84
|
+
AuthServiceClient,
|
|
85
|
+
VerificationServiceClient,
|
|
86
|
+
} from "@ssoeasy-dev/proto/auth";
|
|
109
87
|
|
|
110
|
-
|
|
88
|
+
// gRPC клиенты для companies.svc
|
|
89
|
+
import {
|
|
90
|
+
CompanyServiceClient,
|
|
91
|
+
ServiceServiceClient,
|
|
92
|
+
} from "@ssoeasy-dev/proto/companies";
|
|
111
93
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
├── proto/ # Исходные .proto файлы
|
|
115
|
-
│ ├── common/v1/ # Общие типы
|
|
116
|
-
│ ├── <group>/<version>/ # Протофайлы
|
|
117
|
-
│ └── gateway/v1/ # Gateway
|
|
118
|
-
├── gen/go/ # ✅ Сгенерированный Go код (коммитится!)
|
|
119
|
-
│ ├── common/v1/
|
|
120
|
-
│ ├── <group>/<version>/
|
|
121
|
-
│ └── gateway/v1/
|
|
122
|
-
├── gen/ts/ # ✅ Сгенерированный TypeScript код (коммитится!)
|
|
123
|
-
│ ├── common/v1/
|
|
124
|
-
│ ├── <group>/<version>/
|
|
125
|
-
│ └── index.ts
|
|
126
|
-
├── scripts/ # Скрипты для автоматизации
|
|
127
|
-
│ └── sync-version.sh # Скрипт синхронизации версии
|
|
128
|
-
├── buf.yaml # Конфигурация Buf
|
|
129
|
-
├── buf.gen.yaml # Генерация Go кода
|
|
130
|
-
├── buf.gen.ts.yaml # Генерация TypeScript кода
|
|
131
|
-
├── go.mod # Go модуль
|
|
132
|
-
├── package.json # NPM пакет конфигурация
|
|
133
|
-
├── Makefile # Команды разработки
|
|
134
|
-
└── README.md
|
|
94
|
+
// Общие типы
|
|
95
|
+
import { StatusResponse } from "@ssoeasy-dev/proto/common";
|
|
135
96
|
```
|
|
136
97
|
|
|
137
|
-
|
|
98
|
+
Подключение gRPC-клиентов через NestJS ClientsModule — см. `src/infra/grpc/grpc.module.ts` в `auth.api`.
|
|
138
99
|
|
|
139
|
-
|
|
100
|
+
Обновление:
|
|
140
101
|
|
|
141
102
|
```bash
|
|
142
|
-
|
|
143
|
-
|
|
103
|
+
pnpm add @ssoeasy-dev/proto@latest
|
|
104
|
+
```
|
|
144
105
|
|
|
145
|
-
|
|
146
|
-
make lint
|
|
106
|
+
## Разработка
|
|
147
107
|
|
|
148
|
-
|
|
149
|
-
make format
|
|
108
|
+
### Требования
|
|
150
109
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
110
|
+
- Go 1.24+
|
|
111
|
+
- Node.js 20+
|
|
112
|
+
- pnpm
|
|
113
|
+
- [Buf CLI](https://buf.build/docs/installation)
|
|
154
114
|
|
|
155
|
-
###
|
|
115
|
+
### Установка инструментов
|
|
156
116
|
|
|
157
117
|
```bash
|
|
158
|
-
|
|
159
|
-
make generate
|
|
160
|
-
|
|
161
|
-
# Или отдельно
|
|
162
|
-
make generate-go # Только Go
|
|
163
|
-
make generate-ts # Только TypeScript
|
|
164
|
-
|
|
165
|
-
# Проверить что все работает
|
|
166
|
-
go mod tidy
|
|
167
|
-
pnpm install
|
|
118
|
+
make install-tools
|
|
168
119
|
```
|
|
169
120
|
|
|
170
|
-
###
|
|
121
|
+
### Команды
|
|
171
122
|
|
|
172
123
|
```bash
|
|
173
|
-
#
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
#
|
|
179
|
-
make
|
|
180
|
-
|
|
181
|
-
# GitHub Actions автоматически:
|
|
182
|
-
# - Создаст GitHub Release
|
|
183
|
-
# - Опубликует npm пакет с версией из тега
|
|
184
|
-
# - Go модуль будет доступен через git тег
|
|
124
|
+
make generate # Сгенерировать весь код (Go + TypeScript)
|
|
125
|
+
make generate-go # Только Go
|
|
126
|
+
make generate-ts # Только TypeScript
|
|
127
|
+
make lint # Проверить proto файлы
|
|
128
|
+
make format # Отформатировать proto файлы
|
|
129
|
+
make breaking # Проверить breaking changes относительно main
|
|
130
|
+
make clean # Очистить gen/
|
|
185
131
|
```
|
|
186
132
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
## 🔄 Обновление зависимости в проектах
|
|
190
|
-
|
|
191
|
-
### Go проекты
|
|
133
|
+
### Добавление нового proto файла
|
|
192
134
|
|
|
193
135
|
```bash
|
|
194
|
-
#
|
|
195
|
-
|
|
136
|
+
# 1. Создать файл в нужном пространстве имён
|
|
137
|
+
vim proto/auth/v1/my_service.proto
|
|
196
138
|
|
|
197
|
-
#
|
|
198
|
-
|
|
139
|
+
# 2. Проверить и отформатировать
|
|
140
|
+
make format && make lint
|
|
199
141
|
|
|
200
|
-
#
|
|
201
|
-
|
|
142
|
+
# 3. Сгенерировать код
|
|
143
|
+
make generate
|
|
202
144
|
|
|
203
|
-
|
|
145
|
+
# 4. Закоммитить proto и сгенерированный код вместе
|
|
146
|
+
git add proto/ gen/
|
|
147
|
+
git commit -m "feat: add MyService"
|
|
204
148
|
```
|
|
205
149
|
|
|
206
|
-
|
|
150
|
+
> **Важно:** всегда коммитьте `proto/` и `gen/` вместе. CI проверяет их синхронизацию.
|
|
207
151
|
|
|
208
|
-
|
|
209
|
-
# Обновить до последней версии
|
|
210
|
-
npm install @ssoeasy-dev/proto@latest
|
|
211
|
-
# или
|
|
212
|
-
pnpm add @ssoeasy-dev/proto@latest
|
|
152
|
+
## Релизы
|
|
213
153
|
|
|
214
|
-
|
|
215
|
-
npm install @ssoeasy-dev/proto@1.2.0
|
|
154
|
+
Подробный процесс — в [workflow.md](./workflow.md). Кратко:
|
|
216
155
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
156
|
+
| Событие | Результат |
|
|
157
|
+
| ------------------------------------ | ---------------------------------------------------------------------- |
|
|
158
|
+
| Открытие / обновление PR в `develop` | dev версия `v1.1.1-dev-{branch}.N` |
|
|
159
|
+
| Закрытие PR в `develop` | dev версия удаляется |
|
|
160
|
+
| Мерж в `develop` | beta версия `v1.1.1-beta.N` |
|
|
161
|
+
| Мерж в `main` | production версия из `package.json`, публикация в npm с тегом `latest` |
|
|
220
162
|
|
|
221
|
-
##
|
|
163
|
+
## Лицензия
|
|
222
164
|
|
|
223
|
-
MIT
|
|
165
|
+
MIT — см. [LICENSE](LICENSE).
|
|
224
166
|
|
|
225
|
-
##
|
|
167
|
+
## Контакты
|
|
226
168
|
|
|
169
|
+
- Email: morewiktor@yandex.ru
|
|
170
|
+
- Telegram: [@MoreWiktor](https://t.me/MoreWiktor)
|
|
227
171
|
- GitHub: [@MoreWiktor](https://github.com/MoreWiktor)
|
|
228
|
-
- Проект: [https://github.com/ssoeasy-dev/proto](https://github.com/ssoeasy-dev/proto)
|
package/gen/ts/auth/v1/auth.ts
CHANGED
|
@@ -18,6 +18,16 @@ import {
|
|
|
18
18
|
verificationTypeToNumber,
|
|
19
19
|
} from "./verification";
|
|
20
20
|
|
|
21
|
+
export interface GetMeRequest {
|
|
22
|
+
$type: "auth.v1.GetMeRequest";
|
|
23
|
+
token: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface GetMeResponse {
|
|
27
|
+
$type: "auth.v1.GetMeResponse";
|
|
28
|
+
userId: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
export interface AuthCode {
|
|
22
32
|
$type: "auth.v1.AuthCode";
|
|
23
33
|
id: string;
|
|
@@ -77,6 +87,133 @@ export interface AuthorizeRequest {
|
|
|
77
87
|
code?: CodeVerifier | undefined;
|
|
78
88
|
}
|
|
79
89
|
|
|
90
|
+
function createBaseGetMeRequest(): GetMeRequest {
|
|
91
|
+
return { $type: "auth.v1.GetMeRequest", token: "" };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const GetMeRequest: MessageFns<GetMeRequest, "auth.v1.GetMeRequest"> = {
|
|
95
|
+
$type: "auth.v1.GetMeRequest" as const,
|
|
96
|
+
|
|
97
|
+
encode(message: GetMeRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
98
|
+
if (message.token !== "") {
|
|
99
|
+
writer.uint32(10).string(message.token);
|
|
100
|
+
}
|
|
101
|
+
return writer;
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
decode(input: BinaryReader | Uint8Array, length?: number): GetMeRequest {
|
|
105
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
106
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
107
|
+
const message = createBaseGetMeRequest();
|
|
108
|
+
while (reader.pos < end) {
|
|
109
|
+
const tag = reader.uint32();
|
|
110
|
+
switch (tag >>> 3) {
|
|
111
|
+
case 1: {
|
|
112
|
+
if (tag !== 10) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
message.token = reader.string();
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
reader.skip(tag & 7);
|
|
124
|
+
}
|
|
125
|
+
return message;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
fromJSON(object: any): GetMeRequest {
|
|
129
|
+
return { $type: GetMeRequest.$type, token: isSet(object.token) ? globalThis.String(object.token) : "" };
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
toJSON(message: GetMeRequest): unknown {
|
|
133
|
+
const obj: any = {};
|
|
134
|
+
if (message.token !== "") {
|
|
135
|
+
obj.token = message.token;
|
|
136
|
+
}
|
|
137
|
+
return obj;
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
create<I extends Exact<DeepPartial<GetMeRequest>, I>>(base?: I): GetMeRequest {
|
|
141
|
+
return GetMeRequest.fromPartial(base ?? ({} as any));
|
|
142
|
+
},
|
|
143
|
+
fromPartial<I extends Exact<DeepPartial<GetMeRequest>, I>>(object: I): GetMeRequest {
|
|
144
|
+
const message = createBaseGetMeRequest();
|
|
145
|
+
message.token = object.token ?? "";
|
|
146
|
+
return message;
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
function createBaseGetMeResponse(): GetMeResponse {
|
|
151
|
+
return { $type: "auth.v1.GetMeResponse", userId: "" };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const GetMeResponse: MessageFns<GetMeResponse, "auth.v1.GetMeResponse"> = {
|
|
155
|
+
$type: "auth.v1.GetMeResponse" as const,
|
|
156
|
+
|
|
157
|
+
encode(message: GetMeResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
158
|
+
if (message.userId !== "") {
|
|
159
|
+
writer.uint32(10).string(message.userId);
|
|
160
|
+
}
|
|
161
|
+
return writer;
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
decode(input: BinaryReader | Uint8Array, length?: number): GetMeResponse {
|
|
165
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
166
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
167
|
+
const message = createBaseGetMeResponse();
|
|
168
|
+
while (reader.pos < end) {
|
|
169
|
+
const tag = reader.uint32();
|
|
170
|
+
switch (tag >>> 3) {
|
|
171
|
+
case 1: {
|
|
172
|
+
if (tag !== 10) {
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
message.userId = reader.string();
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
reader.skip(tag & 7);
|
|
184
|
+
}
|
|
185
|
+
return message;
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
fromJSON(object: any): GetMeResponse {
|
|
189
|
+
return {
|
|
190
|
+
$type: GetMeResponse.$type,
|
|
191
|
+
userId: isSet(object.userId)
|
|
192
|
+
? globalThis.String(object.userId)
|
|
193
|
+
: isSet(object.user_id)
|
|
194
|
+
? globalThis.String(object.user_id)
|
|
195
|
+
: "",
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
toJSON(message: GetMeResponse): unknown {
|
|
200
|
+
const obj: any = {};
|
|
201
|
+
if (message.userId !== "") {
|
|
202
|
+
obj.userId = message.userId;
|
|
203
|
+
}
|
|
204
|
+
return obj;
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
create<I extends Exact<DeepPartial<GetMeResponse>, I>>(base?: I): GetMeResponse {
|
|
208
|
+
return GetMeResponse.fromPartial(base ?? ({} as any));
|
|
209
|
+
},
|
|
210
|
+
fromPartial<I extends Exact<DeepPartial<GetMeResponse>, I>>(object: I): GetMeResponse {
|
|
211
|
+
const message = createBaseGetMeResponse();
|
|
212
|
+
message.userId = object.userId ?? "";
|
|
213
|
+
return message;
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
80
217
|
function createBaseAuthCode(): AuthCode {
|
|
81
218
|
return { $type: "auth.v1.AuthCode", id: "", value: "", expiresAt: 0 };
|
|
82
219
|
}
|
|
@@ -1008,6 +1145,14 @@ export const AuthServiceDefinition = {
|
|
|
1008
1145
|
responseStream: false,
|
|
1009
1146
|
options: {},
|
|
1010
1147
|
},
|
|
1148
|
+
getMe: {
|
|
1149
|
+
name: "GetMe",
|
|
1150
|
+
requestType: GetMeRequest,
|
|
1151
|
+
requestStream: false,
|
|
1152
|
+
responseType: GetMeResponse,
|
|
1153
|
+
responseStream: false,
|
|
1154
|
+
options: {},
|
|
1155
|
+
},
|
|
1011
1156
|
},
|
|
1012
1157
|
} as const;
|
|
1013
1158
|
|
|
@@ -1023,6 +1168,7 @@ export interface AuthServiceImplementation<CallContextExt = {}> {
|
|
|
1023
1168
|
login(request: LoginRequest, context: CallContext & CallContextExt): Promise<DeepPartial<LoginResponse>>;
|
|
1024
1169
|
authorize(request: AuthorizeRequest, context: CallContext & CallContextExt): Promise<DeepPartial<Tokens>>;
|
|
1025
1170
|
logout(request: Tokens, context: CallContext & CallContextExt): Promise<DeepPartial<StatusResponse>>;
|
|
1171
|
+
getMe(request: GetMeRequest, context: CallContext & CallContextExt): Promise<DeepPartial<GetMeResponse>>;
|
|
1026
1172
|
}
|
|
1027
1173
|
|
|
1028
1174
|
export interface AuthServiceClient<CallOptionsExt = {}> {
|
|
@@ -1037,6 +1183,7 @@ export interface AuthServiceClient<CallOptionsExt = {}> {
|
|
|
1037
1183
|
login(request: DeepPartial<LoginRequest>, options?: CallOptions & CallOptionsExt): Promise<LoginResponse>;
|
|
1038
1184
|
authorize(request: DeepPartial<AuthorizeRequest>, options?: CallOptions & CallOptionsExt): Promise<Tokens>;
|
|
1039
1185
|
logout(request: DeepPartial<Tokens>, options?: CallOptions & CallOptionsExt): Promise<StatusResponse>;
|
|
1186
|
+
getMe(request: DeepPartial<GetMeRequest>, options?: CallOptions & CallOptionsExt): Promise<GetMeResponse>;
|
|
1040
1187
|
}
|
|
1041
1188
|
|
|
1042
1189
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.4
|
|
4
|
+
// protoc unknown
|
|
5
|
+
// source: companies/v1/employee.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
|
+
import type { CallContext, CallOptions } from "nice-grpc-common";
|
|
10
|
+
|
|
11
|
+
export interface GetByUserIdRequest {
|
|
12
|
+
$type: "companies.v1.GetByUserIdRequest";
|
|
13
|
+
userId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface EmployeeCompany {
|
|
17
|
+
$type: "companies.v1.EmployeeCompany";
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface GetByUserIdResponse {
|
|
23
|
+
$type: "companies.v1.GetByUserIdResponse";
|
|
24
|
+
firstname: string;
|
|
25
|
+
lastname: string;
|
|
26
|
+
companies: EmployeeCompany[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function createBaseGetByUserIdRequest(): GetByUserIdRequest {
|
|
30
|
+
return { $type: "companies.v1.GetByUserIdRequest", userId: "" };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const GetByUserIdRequest: MessageFns<GetByUserIdRequest, "companies.v1.GetByUserIdRequest"> = {
|
|
34
|
+
$type: "companies.v1.GetByUserIdRequest" as const,
|
|
35
|
+
|
|
36
|
+
encode(message: GetByUserIdRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
37
|
+
if (message.userId !== "") {
|
|
38
|
+
writer.uint32(10).string(message.userId);
|
|
39
|
+
}
|
|
40
|
+
return writer;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
decode(input: BinaryReader | Uint8Array, length?: number): GetByUserIdRequest {
|
|
44
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
45
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
46
|
+
const message = createBaseGetByUserIdRequest();
|
|
47
|
+
while (reader.pos < end) {
|
|
48
|
+
const tag = reader.uint32();
|
|
49
|
+
switch (tag >>> 3) {
|
|
50
|
+
case 1: {
|
|
51
|
+
if (tag !== 10) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
message.userId = reader.string();
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
reader.skip(tag & 7);
|
|
63
|
+
}
|
|
64
|
+
return message;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
fromJSON(object: any): GetByUserIdRequest {
|
|
68
|
+
return {
|
|
69
|
+
$type: GetByUserIdRequest.$type,
|
|
70
|
+
userId: isSet(object.userId)
|
|
71
|
+
? globalThis.String(object.userId)
|
|
72
|
+
: isSet(object.user_id)
|
|
73
|
+
? globalThis.String(object.user_id)
|
|
74
|
+
: "",
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
toJSON(message: GetByUserIdRequest): unknown {
|
|
79
|
+
const obj: any = {};
|
|
80
|
+
if (message.userId !== "") {
|
|
81
|
+
obj.userId = message.userId;
|
|
82
|
+
}
|
|
83
|
+
return obj;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
create<I extends Exact<DeepPartial<GetByUserIdRequest>, I>>(base?: I): GetByUserIdRequest {
|
|
87
|
+
return GetByUserIdRequest.fromPartial(base ?? ({} as any));
|
|
88
|
+
},
|
|
89
|
+
fromPartial<I extends Exact<DeepPartial<GetByUserIdRequest>, I>>(object: I): GetByUserIdRequest {
|
|
90
|
+
const message = createBaseGetByUserIdRequest();
|
|
91
|
+
message.userId = object.userId ?? "";
|
|
92
|
+
return message;
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
function createBaseEmployeeCompany(): EmployeeCompany {
|
|
97
|
+
return { $type: "companies.v1.EmployeeCompany", id: "", name: "" };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const EmployeeCompany: MessageFns<EmployeeCompany, "companies.v1.EmployeeCompany"> = {
|
|
101
|
+
$type: "companies.v1.EmployeeCompany" as const,
|
|
102
|
+
|
|
103
|
+
encode(message: EmployeeCompany, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
104
|
+
if (message.id !== "") {
|
|
105
|
+
writer.uint32(10).string(message.id);
|
|
106
|
+
}
|
|
107
|
+
if (message.name !== "") {
|
|
108
|
+
writer.uint32(18).string(message.name);
|
|
109
|
+
}
|
|
110
|
+
return writer;
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
decode(input: BinaryReader | Uint8Array, length?: number): EmployeeCompany {
|
|
114
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
115
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
116
|
+
const message = createBaseEmployeeCompany();
|
|
117
|
+
while (reader.pos < end) {
|
|
118
|
+
const tag = reader.uint32();
|
|
119
|
+
switch (tag >>> 3) {
|
|
120
|
+
case 1: {
|
|
121
|
+
if (tag !== 10) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
message.id = reader.string();
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
case 2: {
|
|
129
|
+
if (tag !== 18) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
message.name = reader.string();
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
reader.skip(tag & 7);
|
|
141
|
+
}
|
|
142
|
+
return message;
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
fromJSON(object: any): EmployeeCompany {
|
|
146
|
+
return {
|
|
147
|
+
$type: EmployeeCompany.$type,
|
|
148
|
+
id: isSet(object.id) ? globalThis.String(object.id) : "",
|
|
149
|
+
name: isSet(object.name) ? globalThis.String(object.name) : "",
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
toJSON(message: EmployeeCompany): unknown {
|
|
154
|
+
const obj: any = {};
|
|
155
|
+
if (message.id !== "") {
|
|
156
|
+
obj.id = message.id;
|
|
157
|
+
}
|
|
158
|
+
if (message.name !== "") {
|
|
159
|
+
obj.name = message.name;
|
|
160
|
+
}
|
|
161
|
+
return obj;
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
create<I extends Exact<DeepPartial<EmployeeCompany>, I>>(base?: I): EmployeeCompany {
|
|
165
|
+
return EmployeeCompany.fromPartial(base ?? ({} as any));
|
|
166
|
+
},
|
|
167
|
+
fromPartial<I extends Exact<DeepPartial<EmployeeCompany>, I>>(object: I): EmployeeCompany {
|
|
168
|
+
const message = createBaseEmployeeCompany();
|
|
169
|
+
message.id = object.id ?? "";
|
|
170
|
+
message.name = object.name ?? "";
|
|
171
|
+
return message;
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
function createBaseGetByUserIdResponse(): GetByUserIdResponse {
|
|
176
|
+
return { $type: "companies.v1.GetByUserIdResponse", firstname: "", lastname: "", companies: [] };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export const GetByUserIdResponse: MessageFns<GetByUserIdResponse, "companies.v1.GetByUserIdResponse"> = {
|
|
180
|
+
$type: "companies.v1.GetByUserIdResponse" as const,
|
|
181
|
+
|
|
182
|
+
encode(message: GetByUserIdResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
183
|
+
if (message.firstname !== "") {
|
|
184
|
+
writer.uint32(10).string(message.firstname);
|
|
185
|
+
}
|
|
186
|
+
if (message.lastname !== "") {
|
|
187
|
+
writer.uint32(18).string(message.lastname);
|
|
188
|
+
}
|
|
189
|
+
for (const v of message.companies) {
|
|
190
|
+
EmployeeCompany.encode(v!, writer.uint32(26).fork()).join();
|
|
191
|
+
}
|
|
192
|
+
return writer;
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
decode(input: BinaryReader | Uint8Array, length?: number): GetByUserIdResponse {
|
|
196
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
197
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
198
|
+
const message = createBaseGetByUserIdResponse();
|
|
199
|
+
while (reader.pos < end) {
|
|
200
|
+
const tag = reader.uint32();
|
|
201
|
+
switch (tag >>> 3) {
|
|
202
|
+
case 1: {
|
|
203
|
+
if (tag !== 10) {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
message.firstname = reader.string();
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
case 2: {
|
|
211
|
+
if (tag !== 18) {
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
message.lastname = reader.string();
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
case 3: {
|
|
219
|
+
if (tag !== 26) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
message.companies.push(EmployeeCompany.decode(reader, reader.uint32()));
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
reader.skip(tag & 7);
|
|
231
|
+
}
|
|
232
|
+
return message;
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
fromJSON(object: any): GetByUserIdResponse {
|
|
236
|
+
return {
|
|
237
|
+
$type: GetByUserIdResponse.$type,
|
|
238
|
+
firstname: isSet(object.firstname) ? globalThis.String(object.firstname) : "",
|
|
239
|
+
lastname: isSet(object.lastname) ? globalThis.String(object.lastname) : "",
|
|
240
|
+
companies: globalThis.Array.isArray(object?.companies)
|
|
241
|
+
? object.companies.map((e: any) => EmployeeCompany.fromJSON(e))
|
|
242
|
+
: [],
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
toJSON(message: GetByUserIdResponse): unknown {
|
|
247
|
+
const obj: any = {};
|
|
248
|
+
if (message.firstname !== "") {
|
|
249
|
+
obj.firstname = message.firstname;
|
|
250
|
+
}
|
|
251
|
+
if (message.lastname !== "") {
|
|
252
|
+
obj.lastname = message.lastname;
|
|
253
|
+
}
|
|
254
|
+
if (message.companies?.length) {
|
|
255
|
+
obj.companies = message.companies.map((e) => EmployeeCompany.toJSON(e));
|
|
256
|
+
}
|
|
257
|
+
return obj;
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
create<I extends Exact<DeepPartial<GetByUserIdResponse>, I>>(base?: I): GetByUserIdResponse {
|
|
261
|
+
return GetByUserIdResponse.fromPartial(base ?? ({} as any));
|
|
262
|
+
},
|
|
263
|
+
fromPartial<I extends Exact<DeepPartial<GetByUserIdResponse>, I>>(object: I): GetByUserIdResponse {
|
|
264
|
+
const message = createBaseGetByUserIdResponse();
|
|
265
|
+
message.firstname = object.firstname ?? "";
|
|
266
|
+
message.lastname = object.lastname ?? "";
|
|
267
|
+
message.companies = object.companies?.map((e) => EmployeeCompany.fromPartial(e)) || [];
|
|
268
|
+
return message;
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export type EmployeeServiceDefinition = typeof EmployeeServiceDefinition;
|
|
273
|
+
export const EmployeeServiceDefinition = {
|
|
274
|
+
name: "EmployeeService",
|
|
275
|
+
fullName: "companies.v1.EmployeeService",
|
|
276
|
+
methods: {
|
|
277
|
+
getByUserId: {
|
|
278
|
+
name: "GetByUserId",
|
|
279
|
+
requestType: GetByUserIdRequest,
|
|
280
|
+
requestStream: false,
|
|
281
|
+
responseType: GetByUserIdResponse,
|
|
282
|
+
responseStream: false,
|
|
283
|
+
options: {},
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
} as const;
|
|
287
|
+
|
|
288
|
+
export interface EmployeeServiceImplementation<CallContextExt = {}> {
|
|
289
|
+
getByUserId(
|
|
290
|
+
request: GetByUserIdRequest,
|
|
291
|
+
context: CallContext & CallContextExt,
|
|
292
|
+
): Promise<DeepPartial<GetByUserIdResponse>>;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface EmployeeServiceClient<CallOptionsExt = {}> {
|
|
296
|
+
getByUserId(
|
|
297
|
+
request: DeepPartial<GetByUserIdRequest>,
|
|
298
|
+
options?: CallOptions & CallOptionsExt,
|
|
299
|
+
): Promise<GetByUserIdResponse>;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
303
|
+
|
|
304
|
+
type DeepPartial<T> = T extends Builtin ? T
|
|
305
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
306
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
307
|
+
: T extends { $case: string } ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { $case: T["$case"] }
|
|
308
|
+
: T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
|
|
309
|
+
: Partial<T>;
|
|
310
|
+
|
|
311
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
312
|
+
type Exact<P, I extends P> = P extends Builtin ? P
|
|
313
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
|
|
314
|
+
|
|
315
|
+
function isSet(value: any): boolean {
|
|
316
|
+
return value !== null && value !== undefined;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
interface MessageFns<T, V extends string> {
|
|
320
|
+
readonly $type: V;
|
|
321
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
322
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
323
|
+
fromJSON(object: any): T;
|
|
324
|
+
toJSON(message: T): unknown;
|
|
325
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
326
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
327
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssoeasy-dev/proto",
|
|
3
|
-
"version": "1.1.1-beta.
|
|
3
|
+
"version": "1.1.1-beta.4",
|
|
4
4
|
"description": "gRPC proto contracts and generated TypeScript clients for SSOEasy",
|
|
5
5
|
"main": "gen/ts/index.ts",
|
|
6
6
|
"types": "gen/ts/index.ts",
|
|
@@ -17,14 +17,6 @@
|
|
|
17
17
|
"types": "./gen/ts/index.companies.ts",
|
|
18
18
|
"default": "./gen/ts/index.companies.ts"
|
|
19
19
|
},
|
|
20
|
-
"./services": {
|
|
21
|
-
"types": "./gen/ts/index.services.ts",
|
|
22
|
-
"default": "./gen/ts/index.services.ts"
|
|
23
|
-
},
|
|
24
|
-
"./abac": {
|
|
25
|
-
"types": "./gen/ts/index.abac.ts",
|
|
26
|
-
"default": "./gen/ts/index.abac.ts"
|
|
27
|
-
},
|
|
28
20
|
"./common": {
|
|
29
21
|
"types": "./gen/ts/index.common.ts",
|
|
30
22
|
"default": "./gen/ts/index.common.ts"
|
package/proto/auth/v1/auth.proto
CHANGED
|
@@ -13,6 +13,15 @@ service AuthService {
|
|
|
13
13
|
rpc Login(LoginRequest) returns (LoginResponse);
|
|
14
14
|
rpc Authorize(AuthorizeRequest) returns (auth.v1.Tokens);
|
|
15
15
|
rpc Logout(Tokens) returns (common.v1.StatusResponse);
|
|
16
|
+
rpc GetMe(GetMeRequest) returns (GetMeResponse);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message GetMeRequest {
|
|
20
|
+
string token = 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
message GetMeResponse {
|
|
24
|
+
string user_id = 1;
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
message AuthCode {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package companies.v1;
|
|
4
|
+
|
|
5
|
+
service EmployeeService {
|
|
6
|
+
rpc GetByUserId(GetByUserIdRequest) returns (GetByUserIdResponse);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
message GetByUserIdRequest {
|
|
10
|
+
string user_id = 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message EmployeeCompany {
|
|
14
|
+
string id = 1;
|
|
15
|
+
string name = 2;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message GetByUserIdResponse {
|
|
19
|
+
string firstname = 1;
|
|
20
|
+
string lastname = 2;
|
|
21
|
+
repeated EmployeeCompany companies = 3;
|
|
22
|
+
}
|