@igorchugurov/public-api-sdk 1.0.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.
@@ -0,0 +1,108 @@
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-DqqjGYgA.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-DqqjGYgA.mjs';
3
+ import '@supabase/supabase-js';
4
+
5
+ /**
6
+ * Классы ошибок для публичного API SDK
7
+ */
8
+ declare class SDKError extends Error {
9
+ code: string;
10
+ statusCode?: number | undefined;
11
+ details?: unknown | undefined;
12
+ constructor(code: string, message: string, statusCode?: number | undefined, details?: unknown | undefined);
13
+ }
14
+ declare class NotFoundError extends SDKError {
15
+ constructor(resource: string, id?: string);
16
+ }
17
+ declare class PermissionDeniedError extends SDKError {
18
+ constructor(action: string, resource: string);
19
+ }
20
+ declare class ValidationError extends SDKError {
21
+ constructor(field: string, message: string);
22
+ }
23
+ declare class AuthenticationError extends SDKError {
24
+ constructor(message?: string);
25
+ }
26
+ /**
27
+ * Обработка ошибок Supabase и преобразование в SDK ошибки
28
+ */
29
+ declare function handleSupabaseError(error: any): never;
30
+ /**
31
+ * Обработка ошибок при работе с entity instance
32
+ * Специфичная обработка для операций с instances
33
+ */
34
+ declare function handleInstanceError(error: any, instanceId: string): never;
35
+
36
+ /**
37
+ * Утилиты для публичного API SDK
38
+ */
39
+
40
+ /**
41
+ * Результат валидации данных
42
+ */
43
+ interface ValidationResult {
44
+ valid: boolean;
45
+ errors: Array<{
46
+ field: string;
47
+ message: string;
48
+ }>;
49
+ }
50
+ /**
51
+ * Валидация данных на основе fields конфигурации
52
+ */
53
+ declare function validateInstanceData(data: Record<string, unknown>, fields: FieldConfig[]): ValidationResult;
54
+ /**
55
+ * Нормализация значения поля
56
+ */
57
+ declare function normalizeFieldValue(value: unknown, field: FieldConfig): FieldValue;
58
+ /**
59
+ * Трансформация snake_case → camelCase
60
+ */
61
+ declare function toCamelCase(str: string): string;
62
+ /**
63
+ * Трансформация camelCase → snake_case
64
+ */
65
+ declare function toSnakeCase(str: string): string;
66
+
67
+ /**
68
+ * Генерация UI конфигурации из EntityDefinition и Fields
69
+ * Единый источник истины для генерации UI конфигурации в SDK
70
+ *
71
+ * Основная логика:
72
+ * 1. Генерируем defaults на основе имени сущности
73
+ * 2. Мержим с custom конфигом из entityDefinition.uiConfig
74
+ * 3. Генерируем колонки таблицы из полей с displayInTable: true
75
+ */
76
+
77
+ /**
78
+ * Генерирует полную UI конфигурацию с defaults
79
+ * @param entityDefinition - Определение сущности из БД
80
+ * @param fields - Поля сущности из БД
81
+ * @returns Полная UI конфигурация со всеми значениями
82
+ */
83
+ declare function generateUIConfig(entityDefinition: EntityDefinition, fields: Field[]): EntityUIConfig;
84
+ /**
85
+ * Утилита для форматирования колонок из старого формата
86
+ * Для обратной совместимости с config/*.json
87
+ */
88
+ declare function getColumnsFromFields(fields: Field[]): ColumnConfig[];
89
+
90
+ /**
91
+ * Фабрика для создания SDK клиента в Client Components
92
+ * Автономная версия - принимает ключи Supabase как параметры
93
+ */
94
+
95
+ /**
96
+ * Создать SDK клиент для Client Components
97
+ * @param projectId - ID проекта
98
+ * @param config - Конфигурация Supabase
99
+ * @param config.supabaseUrl - URL Supabase проекта
100
+ * @param config.supabaseAnonKey - Anon ключ Supabase
101
+ * @param options - Опции SDK (кэширование и т.д.)
102
+ */
103
+ declare function createClientSDK(projectId: string, config: {
104
+ supabaseUrl: string;
105
+ supabaseAnonKey: string;
106
+ }, options?: SDKOptions): PublicAPIClient;
107
+
108
+ export { AuthenticationError, ColumnConfig, EntityDefinition, EntityUIConfig, Field, FieldConfig, FieldValue, NotFoundError, PermissionDeniedError, PublicAPIClient, SDKError, SDKOptions, ValidationError, type ValidationResult, createClientSDK, generateUIConfig, getColumnsFromFields, handleInstanceError, handleSupabaseError, normalizeFieldValue, toCamelCase, toSnakeCase, validateInstanceData };
@@ -0,0 +1,108 @@
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-DqqjGYgA.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-DqqjGYgA.js';
3
+ import '@supabase/supabase-js';
4
+
5
+ /**
6
+ * Классы ошибок для публичного API SDK
7
+ */
8
+ declare class SDKError extends Error {
9
+ code: string;
10
+ statusCode?: number | undefined;
11
+ details?: unknown | undefined;
12
+ constructor(code: string, message: string, statusCode?: number | undefined, details?: unknown | undefined);
13
+ }
14
+ declare class NotFoundError extends SDKError {
15
+ constructor(resource: string, id?: string);
16
+ }
17
+ declare class PermissionDeniedError extends SDKError {
18
+ constructor(action: string, resource: string);
19
+ }
20
+ declare class ValidationError extends SDKError {
21
+ constructor(field: string, message: string);
22
+ }
23
+ declare class AuthenticationError extends SDKError {
24
+ constructor(message?: string);
25
+ }
26
+ /**
27
+ * Обработка ошибок Supabase и преобразование в SDK ошибки
28
+ */
29
+ declare function handleSupabaseError(error: any): never;
30
+ /**
31
+ * Обработка ошибок при работе с entity instance
32
+ * Специфичная обработка для операций с instances
33
+ */
34
+ declare function handleInstanceError(error: any, instanceId: string): never;
35
+
36
+ /**
37
+ * Утилиты для публичного API SDK
38
+ */
39
+
40
+ /**
41
+ * Результат валидации данных
42
+ */
43
+ interface ValidationResult {
44
+ valid: boolean;
45
+ errors: Array<{
46
+ field: string;
47
+ message: string;
48
+ }>;
49
+ }
50
+ /**
51
+ * Валидация данных на основе fields конфигурации
52
+ */
53
+ declare function validateInstanceData(data: Record<string, unknown>, fields: FieldConfig[]): ValidationResult;
54
+ /**
55
+ * Нормализация значения поля
56
+ */
57
+ declare function normalizeFieldValue(value: unknown, field: FieldConfig): FieldValue;
58
+ /**
59
+ * Трансформация snake_case → camelCase
60
+ */
61
+ declare function toCamelCase(str: string): string;
62
+ /**
63
+ * Трансформация camelCase → snake_case
64
+ */
65
+ declare function toSnakeCase(str: string): string;
66
+
67
+ /**
68
+ * Генерация UI конфигурации из EntityDefinition и Fields
69
+ * Единый источник истины для генерации UI конфигурации в SDK
70
+ *
71
+ * Основная логика:
72
+ * 1. Генерируем defaults на основе имени сущности
73
+ * 2. Мержим с custom конфигом из entityDefinition.uiConfig
74
+ * 3. Генерируем колонки таблицы из полей с displayInTable: true
75
+ */
76
+
77
+ /**
78
+ * Генерирует полную UI конфигурацию с defaults
79
+ * @param entityDefinition - Определение сущности из БД
80
+ * @param fields - Поля сущности из БД
81
+ * @returns Полная UI конфигурация со всеми значениями
82
+ */
83
+ declare function generateUIConfig(entityDefinition: EntityDefinition, fields: Field[]): EntityUIConfig;
84
+ /**
85
+ * Утилита для форматирования колонок из старого формата
86
+ * Для обратной совместимости с config/*.json
87
+ */
88
+ declare function getColumnsFromFields(fields: Field[]): ColumnConfig[];
89
+
90
+ /**
91
+ * Фабрика для создания SDK клиента в Client Components
92
+ * Автономная версия - принимает ключи Supabase как параметры
93
+ */
94
+
95
+ /**
96
+ * Создать SDK клиент для Client Components
97
+ * @param projectId - ID проекта
98
+ * @param config - Конфигурация Supabase
99
+ * @param config.supabaseUrl - URL Supabase проекта
100
+ * @param config.supabaseAnonKey - Anon ключ Supabase
101
+ * @param options - Опции SDK (кэширование и т.д.)
102
+ */
103
+ declare function createClientSDK(projectId: string, config: {
104
+ supabaseUrl: string;
105
+ supabaseAnonKey: string;
106
+ }, options?: SDKOptions): PublicAPIClient;
107
+
108
+ export { AuthenticationError, ColumnConfig, EntityDefinition, EntityUIConfig, Field, FieldConfig, FieldValue, NotFoundError, PermissionDeniedError, PublicAPIClient, SDKError, SDKOptions, ValidationError, type ValidationResult, createClientSDK, generateUIConfig, getColumnsFromFields, handleInstanceError, handleSupabaseError, normalizeFieldValue, toCamelCase, toSnakeCase, validateInstanceData };