@notty/types 0.2.0 → 0.2.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.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @notty/types
2
+
3
+ TypeScript type definitions for Notty CMS.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @notty/types
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import type { NottySchema, NottyConfig, NottyPlugin } from '@notty/types';
15
+ ```
16
+
17
+ ## Types
18
+
19
+ - `NottySchema` - Content type schema definition
20
+ - `NottyConfig` - Server configuration
21
+ - `NottyPlugin` - Plugin interface
22
+ - `DatabaseConfig` - Database connection config
23
+ - `JwtConfig` - JWT authentication config
24
+
25
+ ## License
26
+
27
+ MIT
28
+
29
+ ---
30
+
31
+ Part of [Notty CMS](https://github.com/anv-pro/notty)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notty/types",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Shared TypeScript types for Notty CMS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
package/dist/index.d.mts DELETED
@@ -1,224 +0,0 @@
1
- /**
2
- * Content Types
3
- */
4
- interface ContentEntry {
5
- id: string;
6
- createdAt: Date;
7
- updatedAt: Date;
8
- publishedAt?: Date;
9
- [key: string]: unknown;
10
- }
11
- interface QueryOptions {
12
- filters?: Record<string, unknown>;
13
- sort?: string[];
14
- pagination?: {
15
- page: number;
16
- pageSize: number;
17
- };
18
- }
19
-
20
- /**
21
- * User Types
22
- */
23
- interface User {
24
- id: string;
25
- email: string;
26
- username: string;
27
- role: 'admin' | 'editor' | 'viewer';
28
- createdAt: Date;
29
- updatedAt: Date;
30
- }
31
-
32
- /**
33
- * Plugin Types
34
- */
35
- interface Plugin {
36
- name: string;
37
- version: string;
38
- enabled: boolean;
39
- config?: Record<string, unknown>;
40
- }
41
- interface PluginHooks {
42
- beforeCreate?: (data: unknown) => Promise<unknown>;
43
- afterCreate?: (data: unknown) => Promise<void>;
44
- beforeUpdate?: (id: string, data: unknown) => Promise<unknown>;
45
- afterUpdate?: (id: string, data: unknown) => Promise<void>;
46
- }
47
-
48
- /**
49
- * Theme Types
50
- */
51
- interface Theme {
52
- name: string;
53
- version: string;
54
- description: string;
55
- author: string;
56
- templates: string[];
57
- }
58
- interface ThemeConfig {
59
- colors?: Record<string, string>;
60
- fonts?: Record<string, string>;
61
- [key: string]: unknown;
62
- }
63
-
64
- /**
65
- * ACms Universal Schema Format
66
- * Аналог Strapi schema, но адаптированный для Drizzle
67
- */
68
- type FieldType = 'string' | 'text' | 'richtext' | 'integer' | 'bigint' | 'decimal' | 'boolean' | 'date' | 'datetime' | 'json' | 'enum' | 'relation' | 'component' | 'media';
69
- interface ACmsField {
70
- type: FieldType;
71
- required?: boolean;
72
- unique?: boolean;
73
- default?: unknown;
74
- minLength?: number;
75
- maxLength?: number;
76
- min?: number;
77
- max?: number;
78
- enum?: string[];
79
- target?: string;
80
- relation?: 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany';
81
- mappedBy?: string;
82
- inversedBy?: string;
83
- onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT';
84
- component?: string;
85
- repeatable?: boolean;
86
- index?: boolean | 'unique' | 'fulltext';
87
- foreignKey?: {
88
- table: string;
89
- field: string;
90
- onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
91
- onUpdate?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
92
- };
93
- }
94
- interface ACmsSchema {
95
- kind: 'collectionType' | 'singleType';
96
- info: {
97
- singularName: string;
98
- pluralName: string;
99
- displayName: string;
100
- description?: string;
101
- };
102
- options?: {
103
- draftAndPublish?: boolean;
104
- timestamps?: boolean;
105
- softDelete?: boolean;
106
- };
107
- attributes: Record<string, ACmsField>;
108
- indexes?: Array<{
109
- fields: string[];
110
- type: 'index' | 'unique' | 'fulltext';
111
- name?: string;
112
- }>;
113
- }
114
- /**
115
- * Пример схемы в универсальном формате
116
- */
117
- declare const exampleSchema: ACmsSchema;
118
-
119
- /**
120
- * Validation types for ACms Schema
121
- */
122
- interface ValidationError {
123
- field: string;
124
- message: string;
125
- code: ValidationErrorCode;
126
- details?: unknown;
127
- }
128
- type ValidationErrorCode = 'MISSING_REQUIRED_FIELD' | 'INVALID_FIELD_TYPE' | 'INVALID_RELATION_TYPE' | 'DUPLICATE_FIELD_NAME' | 'INVALID_CONSTRAINT' | 'INVALID_ENUM_VALUES' | 'INVALID_RELATION_TARGET' | 'INVALID_RELATION_INVERSE' | 'MISSING_INFO' | 'EMPTY_ATTRIBUTES' | 'INVALID_MIN_MAX' | 'INVALID_LENGTH_CONSTRAINT' | 'INVALID_INDEX_TYPE' | 'INVALID_FOREIGN_KEY' | 'INVALID_INDEX_FIELDS';
129
- interface ValidationResult {
130
- valid: boolean;
131
- errors: ValidationError[];
132
- }
133
- declare class SchemaValidationError extends Error {
134
- result: ValidationResult;
135
- constructor(result: ValidationResult, message?: string);
136
- }
137
-
138
- /**
139
- * Migration types for ACms Database
140
- */
141
- /**
142
- * Database connection for migrations
143
- * Union type supporting SQLite, PostgreSQL, and MySQL
144
- */
145
- type MigrationDatabaseConnection = SQLiteMigrationConnection | PostgresMigrationConnection | MySQLMigrationConnection;
146
- /**
147
- * SQLite database connection for migrations
148
- */
149
- interface SQLiteMigrationConnection {
150
- exec(sql: string): void;
151
- prepare(sql: string): {
152
- run(...params: unknown[]): void;
153
- all(...params: unknown[]): unknown[];
154
- get(...params: unknown[]): unknown;
155
- };
156
- }
157
- /**
158
- * PostgreSQL database connection for migrations
159
- */
160
- interface PostgresMigrationConnection {
161
- execute(sql: string, params?: unknown[]): Promise<{
162
- rows?: unknown[];
163
- rowCount?: number;
164
- }>;
165
- query(sql: string, params?: unknown[]): Promise<{
166
- rows: unknown[];
167
- }>;
168
- }
169
- /**
170
- * MySQL database connection for migrations
171
- */
172
- interface MySQLMigrationConnection {
173
- execute(sql: string, params?: unknown[]): Promise<{
174
- rows?: unknown[];
175
- insertId?: number;
176
- affectedRows?: number;
177
- }>;
178
- query(sql: string, params?: unknown[]): Promise<unknown[]>;
179
- }
180
- /**
181
- * Migration interface - структура файла миграции
182
- */
183
- interface Migration {
184
- up: (db: MigrationDatabaseConnection) => Promise<void>;
185
- down: (db: MigrationDatabaseConnection) => Promise<void>;
186
- }
187
- /**
188
- * Migration record - запись в таблице _migrations
189
- */
190
- interface MigrationRecord {
191
- id: number;
192
- name: string;
193
- timestamp: string;
194
- batch: number;
195
- executedAt: Date;
196
- }
197
- /**
198
- * Migration status - статус отдельной миграции
199
- */
200
- interface MigrationStatus {
201
- name: string;
202
- timestamp: string;
203
- status: 'pending' | 'executed';
204
- batch?: number;
205
- executedAt?: Date;
206
- }
207
- /**
208
- * Migration result - результат выполнения миграции
209
- */
210
- interface MigrationResult {
211
- success: boolean;
212
- migrationsRun: string[];
213
- errors?: string[];
214
- }
215
- /**
216
- * Rollback result - результат отката миграций
217
- */
218
- interface RollbackResult {
219
- success: boolean;
220
- migrationsRolledBack: string[];
221
- errors?: string[];
222
- }
223
-
224
- export { type ACmsField, type ACmsSchema, type ContentEntry, type FieldType, type Migration, type MigrationDatabaseConnection, type MigrationRecord, type MigrationResult, type MigrationStatus, type MySQLMigrationConnection, type Plugin, type PluginHooks, type PostgresMigrationConnection, type QueryOptions, type RollbackResult, type SQLiteMigrationConnection, SchemaValidationError, type Theme, type ThemeConfig, type User, type ValidationError, type ValidationErrorCode, type ValidationResult, exampleSchema };
package/dist/index.mjs DELETED
@@ -1,57 +0,0 @@
1
- // src/acms-schema.ts
2
- var exampleSchema = {
3
- kind: "collectionType",
4
- info: {
5
- singularName: "article",
6
- pluralName: "articles",
7
- displayName: "Article",
8
- description: "Blog articles"
9
- },
10
- options: {
11
- draftAndPublish: true,
12
- timestamps: true
13
- },
14
- attributes: {
15
- title: {
16
- type: "string",
17
- required: true,
18
- maxLength: 255
19
- },
20
- slug: {
21
- type: "string",
22
- required: true,
23
- unique: true,
24
- maxLength: 255
25
- },
26
- content: {
27
- type: "richtext",
28
- required: true
29
- },
30
- publishedAt: {
31
- type: "datetime"
32
- },
33
- author: {
34
- type: "relation",
35
- relation: "manyToOne",
36
- target: "users"
37
- },
38
- categories: {
39
- type: "relation",
40
- relation: "manyToMany",
41
- target: "categories"
42
- }
43
- }
44
- };
45
-
46
- // src/validation.ts
47
- var SchemaValidationError = class extends Error {
48
- constructor(result, message) {
49
- super(message || "Schema validation failed");
50
- this.result = result;
51
- this.name = "SchemaValidationError";
52
- }
53
- };
54
- export {
55
- SchemaValidationError,
56
- exampleSchema
57
- };