@maravilla-labs/types 0.1.9 → 0.1.11

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