@micro-cms/types 0.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.
@@ -0,0 +1,72 @@
1
+ export type FieldType = 'text' | 'number' | 'boolean' | 'date' | 'relation' | 'select';
2
+ export interface FieldConstraints {
3
+ required?: boolean;
4
+ min?: number;
5
+ max?: number;
6
+ minLength?: number;
7
+ maxLength?: number;
8
+ options?: string[];
9
+ }
10
+ export interface Field {
11
+ name: string;
12
+ type: FieldType;
13
+ label?: string;
14
+ constraints?: FieldConstraints;
15
+ relation?: {
16
+ targetEntity: string;
17
+ displayField: string;
18
+ };
19
+ }
20
+ export interface Entity {
21
+ name: string;
22
+ fields: Field[];
23
+ }
24
+ export interface Schema {
25
+ entities: Entity[];
26
+ }
27
+ export type EventStage = 'validation' | 'processing' | 'notification' | 'default';
28
+ export interface SubscriptionOptions {
29
+ priority?: number;
30
+ stage?: EventStage;
31
+ parallel?: boolean;
32
+ }
33
+ export interface ModuleManifest {
34
+ name: string;
35
+ version: string;
36
+ provides: string[];
37
+ requires?: string[];
38
+ optionalDependencies?: string[];
39
+ pairsWith?: Record<string, {
40
+ reason: string;
41
+ strength: 'required' | 'recommended' | 'compatible' | 'optional';
42
+ category?: string;
43
+ }>;
44
+ publishes?: Record<string, string>;
45
+ }
46
+ export interface CmsModule {
47
+ manifest: ModuleManifest;
48
+ load: (context: CmsContext) => void | Promise<void>;
49
+ }
50
+ export interface CmsContext {
51
+ runtime: {
52
+ register: (capability: string, implementation: any) => void;
53
+ getCapability: <T = any>(capability: string) => T | undefined;
54
+ };
55
+ events: {
56
+ emit: (event: string, payload: any, stage?: EventStage) => Promise<void>;
57
+ subscribe: (event: string, handler: (payload: any) => void | Promise<void>, options?: SubscriptionOptions) => void;
58
+ };
59
+ context: {
60
+ publish: (key: string, value: any) => void;
61
+ get: (key: string) => any;
62
+ subscribe: (key: string, handler: (value: any) => void) => void;
63
+ };
64
+ config: Record<string, any>;
65
+ }
66
+ export interface DataProvider {
67
+ introspect: () => Promise<Schema>;
68
+ find: (entity: string, query?: any) => Promise<any[]>;
69
+ create: (entity: string, data: any) => Promise<any>;
70
+ update: (entity: string, id: any, data: any) => Promise<any>;
71
+ delete: (entity: string, id: any) => Promise<any>;
72
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@micro-cms/types",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": ["dist"],
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepare": "pnpm build"
19
+ },
20
+ "devDependencies": {
21
+ "typescript": "^5.0.0"
22
+ }
23
+ }