@micro-cms/types 1.0.5 → 1.0.8
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/dist/index.d.mts +113 -0
- package/dist/index.d.ts +19 -18
- package/dist/index.js +18 -2
- package/dist/index.mjs +0 -0
- package/package.json +7 -6
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
type FieldType = 'text' | 'number' | 'boolean' | 'date' | 'relation' | 'select';
|
|
2
|
+
interface FieldConstraints {
|
|
3
|
+
required?: boolean;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
minLength?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
options?: string[];
|
|
9
|
+
}
|
|
10
|
+
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
|
+
interface Entity {
|
|
21
|
+
name: string;
|
|
22
|
+
fields: Field[];
|
|
23
|
+
}
|
|
24
|
+
interface Schema {
|
|
25
|
+
entities: Entity[];
|
|
26
|
+
}
|
|
27
|
+
type EventStage = 'validation' | 'processing' | 'notification' | 'default';
|
|
28
|
+
interface SubscriptionOptions {
|
|
29
|
+
priority?: number;
|
|
30
|
+
stage?: EventStage;
|
|
31
|
+
parallel?: boolean;
|
|
32
|
+
}
|
|
33
|
+
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
|
+
interface CmsModule {
|
|
47
|
+
manifest: ModuleManifest;
|
|
48
|
+
load: (context: CmsContext) => void | Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
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
|
+
interface PaginatedResponse<T = any> {
|
|
67
|
+
data: T[];
|
|
68
|
+
total: number;
|
|
69
|
+
page: number;
|
|
70
|
+
limit: number;
|
|
71
|
+
}
|
|
72
|
+
interface DataProvider {
|
|
73
|
+
introspect: () => Promise<Schema>;
|
|
74
|
+
find: (entity: string, query?: {
|
|
75
|
+
page?: number;
|
|
76
|
+
limit?: number;
|
|
77
|
+
filter?: any;
|
|
78
|
+
sort?: string;
|
|
79
|
+
}) => Promise<PaginatedResponse | any[]>;
|
|
80
|
+
findById: (entity: string, id: any) => Promise<any>;
|
|
81
|
+
create: (entity: string, data: any) => Promise<any>;
|
|
82
|
+
update: (entity: string, id: any, data: any) => Promise<any>;
|
|
83
|
+
delete: (entity: string, id: any) => Promise<any>;
|
|
84
|
+
}
|
|
85
|
+
interface RouteDefinition {
|
|
86
|
+
method: 'GET' | 'POST' | 'PATCH' | 'DELETE' | 'PUT';
|
|
87
|
+
path: string;
|
|
88
|
+
handler: (req: any, res: any) => Promise<void>;
|
|
89
|
+
middleware?: string[];
|
|
90
|
+
meta?: Record<string, any>;
|
|
91
|
+
}
|
|
92
|
+
interface RouteProvider {
|
|
93
|
+
getRoutes: () => RouteDefinition[];
|
|
94
|
+
}
|
|
95
|
+
interface PaymentIntent {
|
|
96
|
+
orderId: string;
|
|
97
|
+
paymentAddress: string;
|
|
98
|
+
amount: string;
|
|
99
|
+
currency: string;
|
|
100
|
+
network: string;
|
|
101
|
+
nonce: string;
|
|
102
|
+
}
|
|
103
|
+
interface PaymentVerification {
|
|
104
|
+
transactionHash: string;
|
|
105
|
+
orderId: string;
|
|
106
|
+
status: 'pending' | 'confirmed' | 'failed';
|
|
107
|
+
}
|
|
108
|
+
interface PaymentProvider {
|
|
109
|
+
initiatePayment: (orderId: string, options: any) => Promise<PaymentIntent>;
|
|
110
|
+
verifyPayment: (txHash: string, orderId: string) => Promise<PaymentVerification>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type { CmsContext, CmsModule, DataProvider, Entity, EventStage, Field, FieldConstraints, FieldType, ModuleManifest, PaginatedResponse, PaymentIntent, PaymentProvider, PaymentVerification, RouteDefinition, RouteProvider, Schema, SubscriptionOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type FieldType = 'text' | 'number' | 'boolean' | 'date' | 'relation' | 'select';
|
|
2
|
+
interface FieldConstraints {
|
|
3
3
|
required?: boolean;
|
|
4
4
|
min?: number;
|
|
5
5
|
max?: number;
|
|
@@ -7,7 +7,7 @@ export interface FieldConstraints {
|
|
|
7
7
|
maxLength?: number;
|
|
8
8
|
options?: string[];
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface Field {
|
|
11
11
|
name: string;
|
|
12
12
|
type: FieldType;
|
|
13
13
|
label?: string;
|
|
@@ -17,20 +17,20 @@ export interface Field {
|
|
|
17
17
|
displayField: string;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
interface Entity {
|
|
21
21
|
name: string;
|
|
22
22
|
fields: Field[];
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
interface Schema {
|
|
25
25
|
entities: Entity[];
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
type EventStage = 'validation' | 'processing' | 'notification' | 'default';
|
|
28
|
+
interface SubscriptionOptions {
|
|
29
29
|
priority?: number;
|
|
30
30
|
stage?: EventStage;
|
|
31
31
|
parallel?: boolean;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
interface ModuleManifest {
|
|
34
34
|
name: string;
|
|
35
35
|
version: string;
|
|
36
36
|
provides: string[];
|
|
@@ -43,11 +43,11 @@ export interface ModuleManifest {
|
|
|
43
43
|
}>;
|
|
44
44
|
publishes?: Record<string, string>;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
interface CmsModule {
|
|
47
47
|
manifest: ModuleManifest;
|
|
48
48
|
load: (context: CmsContext) => void | Promise<void>;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
interface CmsContext {
|
|
51
51
|
runtime: {
|
|
52
52
|
register: (capability: string, implementation: any) => void;
|
|
53
53
|
getCapability: <T = any>(capability: string) => T | undefined;
|
|
@@ -63,13 +63,13 @@ export interface CmsContext {
|
|
|
63
63
|
};
|
|
64
64
|
config: Record<string, any>;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
interface PaginatedResponse<T = any> {
|
|
67
67
|
data: T[];
|
|
68
68
|
total: number;
|
|
69
69
|
page: number;
|
|
70
70
|
limit: number;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
interface DataProvider {
|
|
73
73
|
introspect: () => Promise<Schema>;
|
|
74
74
|
find: (entity: string, query?: {
|
|
75
75
|
page?: number;
|
|
@@ -82,17 +82,17 @@ export interface DataProvider {
|
|
|
82
82
|
update: (entity: string, id: any, data: any) => Promise<any>;
|
|
83
83
|
delete: (entity: string, id: any) => Promise<any>;
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
interface RouteDefinition {
|
|
86
86
|
method: 'GET' | 'POST' | 'PATCH' | 'DELETE' | 'PUT';
|
|
87
87
|
path: string;
|
|
88
88
|
handler: (req: any, res: any) => Promise<void>;
|
|
89
89
|
middleware?: string[];
|
|
90
90
|
meta?: Record<string, any>;
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
interface RouteProvider {
|
|
93
93
|
getRoutes: () => RouteDefinition[];
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
interface PaymentIntent {
|
|
96
96
|
orderId: string;
|
|
97
97
|
paymentAddress: string;
|
|
98
98
|
amount: string;
|
|
@@ -100,13 +100,14 @@ export interface PaymentIntent {
|
|
|
100
100
|
network: string;
|
|
101
101
|
nonce: string;
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
interface PaymentVerification {
|
|
104
104
|
transactionHash: string;
|
|
105
105
|
orderId: string;
|
|
106
106
|
status: 'pending' | 'confirmed' | 'failed';
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
interface PaymentProvider {
|
|
109
109
|
initiatePayment: (orderId: string, options: any) => Promise<PaymentIntent>;
|
|
110
110
|
verifyPayment: (txHash: string, orderId: string) => Promise<PaymentVerification>;
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
|
|
113
|
+
export type { CmsContext, CmsModule, DataProvider, Entity, EventStage, Field, FieldConstraints, FieldType, ModuleManifest, PaginatedResponse, PaymentIntent, PaymentProvider, PaymentVerification, RouteDefinition, RouteProvider, Schema, SubscriptionOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var index_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(index_exports);
|
package/dist/index.mjs
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-cms/types",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "1.0.8",
|
|
5
4
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.
|
|
5
|
+
"module": "dist/index.mjs",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
7
|
"files": [
|
|
9
8
|
"dist"
|
|
@@ -11,15 +10,17 @@
|
|
|
11
10
|
"exports": {
|
|
12
11
|
".": {
|
|
13
12
|
"types": "./dist/index.d.ts",
|
|
14
|
-
"import": "./dist/index.
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
20
20
|
"prepare": "pnpm build"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"typescript": "^5.0.0"
|
|
23
|
+
"typescript": "^5.0.0",
|
|
24
|
+
"tsup": "^8.0.2"
|
|
24
25
|
}
|
|
25
26
|
}
|