@igorchugurov/public-api-sdk 1.3.0 → 1.4.0

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/LICENSE CHANGED
@@ -19,5 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
-
23
-
package/README.md CHANGED
@@ -17,6 +17,7 @@ pnpm add @igorchugurov/public-api-sdk
17
17
  SDK предоставляет полный набор инструментов для работы с универсальными сущностями:
18
18
 
19
19
  ### 🔄 CRUD операции
20
+
20
21
  - **Получение списка** с расширенной фильтрацией, поиском и пагинацией
21
22
  - **Получение одного экземпляра** с автоматической загрузкой связей и файлов
22
23
  - **Создание** экземпляров с поддержкой relations и автоматической установкой `created_by`
@@ -24,6 +25,7 @@ SDK предоставляет полный набор инструментов
24
25
  - **Удаление** экземпляров с автоматической очисткой связей
25
26
 
26
27
  ### 🔗 Работа со связями (Relations)
28
+
27
29
  - Автоматическое определение relation-полей из конфигурации
28
30
  - Поддержка всех типов связей: `manyToMany`, `manyToOne`, `oneToMany`, `oneToOne`
29
31
  - Batch-загрузка связанных объектов для оптимизации производительности
@@ -31,33 +33,39 @@ SDK предоставляет полный набор инструментов
31
33
  - Опция получения relations как ID или полных объектов
32
34
 
33
35
  ### 🔍 Поиск и фильтрация
36
+
34
37
  - **Умный поиск** по полям с флагом `searchable: true`
35
38
  - **JSONB фильтрация** для обычных полей
36
39
  - **Relation фильтрация** с автоматическим определением relation-полей
37
40
  - **Гибкая сортировка** по любому полю с поддержкой `asc`/`desc`
38
41
 
39
42
  ### 📁 Работа с файлами
43
+
40
44
  - Автоматическая загрузка файлов и изображений для полей типа `files` и `images`
41
45
  - Batch-загрузка файлов для оптимизации запросов
42
46
  - Поддержка множественных файлов на поле
43
47
 
44
48
  ### ⚡ Производительность
49
+
45
50
  - **Кэширование конфигурации** EntityDefinition и Fields (TTL: 5 минут по умолчанию)
46
51
  - **Batch-запросы** для relations и файлов
47
52
  - **Оптимизированные RPC функции** для поиска и загрузки связей
48
53
  - Поддержка ESM и CJS форматов
49
54
 
50
55
  ### 🎯 Типобезопасность
56
+
51
57
  - Полная типизация всех методов и параметров
52
58
  - Экспорт всех типов для использования в вашем коде
53
59
  - Типизированные ошибки для удобной обработки
54
60
 
55
61
  ### 🔐 Безопасность
62
+
56
63
  - Интеграция с Supabase RLS (Row Level Security)
57
64
  - Автоматическая проверка прав доступа
58
65
  - Типизированные ошибки для различных сценариев доступа
59
66
 
60
67
  ### 🎨 UI конфигурация
68
+
61
69
  - Автоматическая генерация UI конфигурации из EntityDefinition и Fields
62
70
  - Поддержка кастомных UI настроек
63
71
  - Генерация конфигурации колонок таблицы из полей
@@ -67,8 +75,8 @@ SDK предоставляет полный набор инструментов
67
75
  ### 1. Server Component (SSR)
68
76
 
69
77
  ```typescript
70
- import { createServerSDK } from '@igorchugurov/public-api-sdk/server';
71
- import { cookies } from 'next/headers';
78
+ import { createServerSDK } from "@igorchugurov/public-api-sdk/server";
79
+ import { cookies } from "next/headers";
72
80
 
73
81
  export default async function MyPage({ params }) {
74
82
  const { projectId } = await params;
@@ -97,7 +105,7 @@ export default async function MyPage({ params }) {
97
105
  const { data, pagination } = await sdk.getInstances(entityDefinitionId, {
98
106
  page: 1,
99
107
  limit: 20,
100
- search: 'test',
108
+ search: "test",
101
109
  });
102
110
 
103
111
  return <div>{/* ... */}</div>;
@@ -107,9 +115,9 @@ export default async function MyPage({ params }) {
107
115
  ### 2. Client Component
108
116
 
109
117
  ```typescript
110
- 'use client';
118
+ "use client";
111
119
 
112
- import { createClientSDK } from '@igorchugurov/public-api-sdk';
120
+ import { createClientSDK } from "@igorchugurov/public-api-sdk";
113
121
 
114
122
  const sdk = createClientSDK(
115
123
  projectId,
@@ -194,16 +202,24 @@ const instance = await sdk.getInstanceBySlug(entityDefinitionId, slug, {
194
202
 
195
203
  ```typescript
196
204
  // Базовое использование - без файлов
197
- const instance = await sdk.getInstanceBySlug("entity-def-id", "my-article-slug");
205
+ const instance = await sdk.getInstanceBySlug(
206
+ "entity-def-id",
207
+ "my-article-slug"
208
+ );
198
209
 
199
210
  // Для отображения с файлами - полные объекты
200
- const instance = await sdk.getInstanceBySlug("entity-def-id", "my-article-slug", {
201
- relationsAsIds: false,
202
- loadFiles: true, // файлы и изображения будут загружены как полные объекты EntityFile
203
- });
211
+ const instance = await sdk.getInstanceBySlug(
212
+ "entity-def-id",
213
+ "my-article-slug",
214
+ {
215
+ relationsAsIds: false,
216
+ loadFiles: true, // файлы и изображения будут загружены как полные объекты EntityFile
217
+ }
218
+ );
204
219
  ```
205
220
 
206
221
  **Особенности:**
222
+
207
223
  - Валидирует формат slug перед запросом (только строчные латинские буквы, цифры и дефисы)
208
224
  - Работает аналогично `getInstance`, но ищет по slug вместо id
209
225
  - Поддерживает те же параметры, что и `getInstance`
@@ -226,6 +242,7 @@ const instance = await sdk.createInstance(entityDefinitionId, {
226
242
  ```
227
243
 
228
244
  **Особенности:**
245
+
229
246
  - Автоматически генерирует уникальный `slug` из поля `name`
230
247
  - Если slug уже существует, добавляет случайный суффикс
231
248
  - Автоматически устанавливает `created_by` из текущего пользователя
@@ -290,7 +307,7 @@ import type {
290
307
  CreateInstanceData,
291
308
  UpdateInstanceData,
292
309
  PaginationResult,
293
- } from '@igorchugurov/public-api-sdk';
310
+ } from "@igorchugurov/public-api-sdk";
294
311
  ```
295
312
 
296
313
  ### Slug поддержка
@@ -328,7 +345,7 @@ import {
328
345
  ValidationError,
329
346
  AuthenticationError,
330
347
  SDKError,
331
- } from '@igorchugurov/public-api-sdk';
348
+ } from "@igorchugurov/public-api-sdk";
332
349
 
333
350
  try {
334
351
  const instance = await sdk.getInstance(entityDefinitionId, id);
@@ -375,5 +392,3 @@ pnpm dev
375
392
  ## 📄 Лицензия
376
393
 
377
394
  MIT
378
-
379
-
@@ -164,6 +164,8 @@ interface Field {
164
164
  selectorRelationId?: string | null;
165
165
  relationFieldName?: string | null;
166
166
  relationFieldLabel?: string | null;
167
+ relationFieldRequired?: boolean;
168
+ relationFieldRequiredText?: string | null;
167
169
  defaultStringValue?: string | null;
168
170
  defaultNumberValue?: number | null;
169
171
  defaultBooleanValue?: boolean | null;
@@ -177,6 +179,7 @@ interface Field {
177
179
  foreignKeyValue?: string | null;
178
180
  typeFieldName?: string | null;
179
181
  optionsFieldName?: string | null;
182
+ exclude?: string | null;
180
183
  acceptFileTypes?: string | null;
181
184
  maxFileSize?: number | null;
182
185
  maxFiles?: number | null;
@@ -164,6 +164,8 @@ interface Field {
164
164
  selectorRelationId?: string | null;
165
165
  relationFieldName?: string | null;
166
166
  relationFieldLabel?: string | null;
167
+ relationFieldRequired?: boolean;
168
+ relationFieldRequiredText?: string | null;
167
169
  defaultStringValue?: string | null;
168
170
  defaultNumberValue?: number | null;
169
171
  defaultBooleanValue?: boolean | null;
@@ -177,6 +179,7 @@ interface Field {
177
179
  foreignKeyValue?: string | null;
178
180
  typeFieldName?: string | null;
179
181
  optionsFieldName?: string | null;
182
+ exclude?: string | null;
180
183
  acceptFileTypes?: string | null;
181
184
  maxFileSize?: number | null;
182
185
  maxFiles?: number | null;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldConfig, a as FieldValue, E as EntityDefinition, b as Field, c as EntityUIConfig, C as ColumnConfig, S as SDKOptions, P as PublicAPIClient } from './client-D3jtlTId.mjs';
2
- export { y as ActionConfig, A as AuthResult, g as CreateInstanceData, D as DbType, l as DbTypeToTSType, m as EntityData, e as EntityDefinitionConfig, x as EntityFile, n as EntityInstance, q as EntityInstanceWithFields, p as EntityRelation, k as FieldOption, j as FieldType, r as FilterValue, z as FormPageConfig, G as GetInstancesOptions, I as InstanceData, L as ListPageConfig, M as MessagesConfig, h as PaginationResult, w as PartialInstanceData, B as PartialUIConfig, d as ProjectConfig, Q as QueryParams, R as RelationFilterInfo, f as RelationFilterMode, o as RelationType, s as RelationsData, i as SignUpData, U as UpdateInstanceData, v as getFieldValue, u as isEntityData, t as isFieldValue } from './client-D3jtlTId.mjs';
1
+ import { F as FieldConfig, a as FieldValue, E as EntityDefinition, b as Field, c as EntityUIConfig, C as ColumnConfig, S as SDKOptions, P as PublicAPIClient } from './client-BTvcDpY4.mjs';
2
+ export { y as ActionConfig, A as AuthResult, g as CreateInstanceData, D as DbType, l as DbTypeToTSType, m as EntityData, e as EntityDefinitionConfig, x as EntityFile, n as EntityInstance, q as EntityInstanceWithFields, p as EntityRelation, k as FieldOption, j as FieldType, r as FilterValue, z as FormPageConfig, G as GetInstancesOptions, I as InstanceData, L as ListPageConfig, M as MessagesConfig, h as PaginationResult, w as PartialInstanceData, B as PartialUIConfig, d as ProjectConfig, Q as QueryParams, R as RelationFilterInfo, f as RelationFilterMode, o as RelationType, s as RelationsData, i as SignUpData, U as UpdateInstanceData, v as getFieldValue, u as isEntityData, t as isFieldValue } from './client-BTvcDpY4.mjs';
3
3
  import '@supabase/supabase-js';
4
4
 
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldConfig, a as FieldValue, E as EntityDefinition, b as Field, c as EntityUIConfig, C as ColumnConfig, S as SDKOptions, P as PublicAPIClient } from './client-D3jtlTId.js';
2
- export { y as ActionConfig, A as AuthResult, g as CreateInstanceData, D as DbType, l as DbTypeToTSType, m as EntityData, e as EntityDefinitionConfig, x as EntityFile, n as EntityInstance, q as EntityInstanceWithFields, p as EntityRelation, k as FieldOption, j as FieldType, r as FilterValue, z as FormPageConfig, G as GetInstancesOptions, I as InstanceData, L as ListPageConfig, M as MessagesConfig, h as PaginationResult, w as PartialInstanceData, B as PartialUIConfig, d as ProjectConfig, Q as QueryParams, R as RelationFilterInfo, f as RelationFilterMode, o as RelationType, s as RelationsData, i as SignUpData, U as UpdateInstanceData, v as getFieldValue, u as isEntityData, t as isFieldValue } from './client-D3jtlTId.js';
1
+ import { F as FieldConfig, a as FieldValue, E as EntityDefinition, b as Field, c as EntityUIConfig, C as ColumnConfig, S as SDKOptions, P as PublicAPIClient } from './client-BTvcDpY4.js';
2
+ export { y as ActionConfig, A as AuthResult, g as CreateInstanceData, D as DbType, l as DbTypeToTSType, m as EntityData, e as EntityDefinitionConfig, x as EntityFile, n as EntityInstance, q as EntityInstanceWithFields, p as EntityRelation, k as FieldOption, j as FieldType, r as FilterValue, z as FormPageConfig, G as GetInstancesOptions, I as InstanceData, L as ListPageConfig, M as MessagesConfig, h as PaginationResult, w as PartialInstanceData, B as PartialUIConfig, d as ProjectConfig, Q as QueryParams, R as RelationFilterInfo, f as RelationFilterMode, o as RelationType, s as RelationsData, i as SignUpData, U as UpdateInstanceData, v as getFieldValue, u as isEntityData, t as isFieldValue } from './client-BTvcDpY4.js';
3
3
  import '@supabase/supabase-js';
4
4
 
5
5
  /**