@maravilla-labs/types 0.1.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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/index.ts +138 -0
  3. package/package.json +25 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # packages/types
2
+
3
+ Shared TypeScript definitions for Maravilla Runtime.
package/index.ts ADDED
@@ -0,0 +1,138 @@
1
+ /**
2
+ * TypeScript definitions for Maravilla Runtime platform APIs
3
+ */
4
+
5
+ // KV Store Types
6
+
7
+ /**
8
+ * Request options for KV list operations with cursor-based pagination
9
+ */
10
+ export interface KvListRequest {
11
+ /** Optional cursor for pagination continuation */
12
+ cursor?: string;
13
+ /** Maximum number of keys to return (max 1000) */
14
+ limit?: number;
15
+ /** Optional prefix filter for keys */
16
+ prefix?: string;
17
+ }
18
+
19
+ /**
20
+ * Metadata for a single key in KV list results
21
+ */
22
+ export interface KvKeyMetadata {
23
+ /** Key name */
24
+ name: string;
25
+ /** Optional expiration timestamp (Unix timestamp in seconds) */
26
+ expiration?: number;
27
+ }
28
+
29
+ /**
30
+ * Pagination result information
31
+ */
32
+ export interface KvResultInfo {
33
+ /** Cursor for next page (undefined if no more results) */
34
+ cursor?: string;
35
+ /** Number of keys returned in this response */
36
+ count: number;
37
+ }
38
+
39
+ /**
40
+ * Response structure for KV list operations
41
+ */
42
+ export interface KvListResponse {
43
+ /** List of key metadata */
44
+ result: KvKeyMetadata[];
45
+ /** Success indicator */
46
+ success: boolean;
47
+ /** Pagination information */
48
+ result_info: KvResultInfo;
49
+ }
50
+
51
+ /**
52
+ * Options for KV put operations
53
+ */
54
+ export interface KvPutOptions {
55
+ /** Time-to-live in seconds */
56
+ ttl?: number;
57
+ }
58
+
59
+ /**
60
+ * KV Store interface
61
+ */
62
+ export interface KvStore {
63
+ /**
64
+ * Get a value by key
65
+ */
66
+ get(namespace: string, key: string): Promise<any>;
67
+
68
+ /**
69
+ * Put a value with optional TTL
70
+ */
71
+ put(namespace: string, key: string, value: any, options?: KvPutOptions): Promise<void>;
72
+
73
+ /**
74
+ * Delete a key
75
+ */
76
+ delete(namespace: string, key: string): Promise<void>;
77
+
78
+ /**
79
+ * List keys with cursor-based pagination
80
+ */
81
+ list(namespace: string, options?: KvListRequest): Promise<KvListResponse>;
82
+ }
83
+
84
+ // Database Types
85
+
86
+ /**
87
+ * Database find options
88
+ */
89
+ export interface DbFindOptions {
90
+ limit?: number;
91
+ skip?: number;
92
+ sort?: Record<string, 1 | -1>;
93
+ projection?: Record<string, 1 | 0>;
94
+ }
95
+
96
+ /**
97
+ * Database collection interface
98
+ */
99
+ export interface DbCollection {
100
+ find(filter?: Record<string, any>, options?: DbFindOptions): Promise<any[]>;
101
+ findOne(filter?: Record<string, any>): Promise<any | null>;
102
+ insertOne(document: Record<string, any>): Promise<string>;
103
+ updateOne(filter: Record<string, any>, update: Record<string, any>): Promise<void>;
104
+ deleteOne(filter: Record<string, any>): Promise<void>;
105
+ }
106
+
107
+ /**
108
+ * Database interface with dynamic collection access
109
+ */
110
+ export interface Database {
111
+ [collection: string]: DbCollection;
112
+ }
113
+
114
+ // Platform Types
115
+
116
+ /**
117
+ * Main platform interface available in runtime
118
+ */
119
+ export interface Platform {
120
+ /** KV Store instance */
121
+ kv: KvStore;
122
+ /** Database instance with dynamic collection access */
123
+ db: Database;
124
+ /** Legacy aliases for compatibility */
125
+ env: {
126
+ KV: KvStore;
127
+ DB: Database;
128
+ };
129
+ }
130
+
131
+ /**
132
+ * Global platform object available in runtime
133
+ */
134
+ declare global {
135
+ const platform: Platform;
136
+ }
137
+
138
+ export { Platform as default };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@maravilla-labs/types",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript definitions for Maravilla Runtime platform APIs",
5
+ "main": "index.ts",
6
+ "types": "index.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "typecheck": "tsc --noEmit"
10
+ },
11
+ "keywords": [
12
+ "maravilla",
13
+ "runtime",
14
+ "types",
15
+ "typescript"
16
+ ],
17
+ "author": "SOLUTAS GmbH",
18
+ "license": "Proprietary",
19
+ "devDependencies": {
20
+ "typescript": "^5.0.0"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ }
25
+ }