cocobase 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.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Cocobase SDK
2
+
3
+ The official JavaScript/TypeScript SDK for Cocobase, a powerful Backend-as-a-Service platform.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install cocobase
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { Cocobase } from 'cocobase';
15
+
16
+ // Initialize the client
17
+ const db = new Cocobase({
18
+ apiKey: 'your-api-key'
19
+ });
20
+
21
+ // Create a document
22
+ const newUser = await db.createDocument('users', {
23
+ name: 'Alice',
24
+ age: 30
25
+ });
26
+
27
+ // Get a document
28
+ const user = await db.getDocument('users', newUser.id);
29
+
30
+ // Update a document
31
+ await db.updateDocument('users', newUser.id, {
32
+ age: 31
33
+ });
34
+
35
+ // List documents
36
+ const users = await db.listDocuments('users');
37
+
38
+ // Delete a document
39
+ await db.deleteDocument('users', newUser.id);
40
+ ```
41
+
42
+ ## API Reference
43
+
44
+ ### `new Cocobase(config)`
45
+
46
+ Creates a new Cocobase client instance.
47
+
48
+ - `config.apiKey` - Your Cocobase API key
49
+
50
+ ### Documents
51
+
52
+ #### `createDocument<T>(collection: string, data: T): Promise<Document<T>>`
53
+ Creates a new document in the specified collection.
54
+
55
+ #### `getDocument<T>(collection: string, docId: string): Promise<Document<T>>`
56
+ Retrieves a document by its ID.
57
+
58
+ #### `updateDocument<T>(collection: string, docId: string, data: Partial<T>): Promise<Document<T>>`
59
+ Updates an existing document.
60
+
61
+ #### `deleteDocument(collection: string, docId: string): Promise<{ success: boolean }>`
62
+ Deletes a document.
63
+
64
+ #### `listDocuments<T>(collection: string): Promise<Document<T>[]>`
65
+ Lists all documents in a collection.
66
+
67
+ ## Types
68
+
69
+ ```typescript
70
+ interface Document<T> {
71
+ data: T;
72
+ id: string;
73
+ collection_id: string;
74
+ created_at: string;
75
+ collection: {
76
+ name: string;
77
+ id: string;
78
+ created_at: string;
79
+ };
80
+ }
81
+ ```
82
+
83
+ ## License
84
+
85
+ MIT
@@ -0,0 +1,16 @@
1
+ import { CocobaseConfig, Document } from "../types/types";
2
+ export declare class Cocobase {
3
+ private baseURL;
4
+ private apiKey?;
5
+ constructor(config: CocobaseConfig);
6
+ private request;
7
+ private getErrorSuggestion;
8
+ getDocument<T = any>(collection: string, docId: string): Promise<Document<T>>;
9
+ createDocument<T = any>(collection: string, data: T): Promise<Document<T>>;
10
+ updateDocument<T = any>(collection: string, docId: string, data: Partial<T>): Promise<Document<T>>;
11
+ deleteDocument(collection: string, docId: string): Promise<{
12
+ success: boolean;
13
+ }>;
14
+ listDocuments<T = any>(collection: string): Promise<Document<T>[]>;
15
+ }
16
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1D,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAS;gBAEZ,MAAM,EAAE,cAAc;YAKpB,OAAO;IA6CrB,OAAO,CAAC,kBAAkB;IAkBpB,WAAW,CAAC,CAAC,GAAG,GAAG,EACvB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAKjB,cAAc,CAAC,CAAC,GAAG,GAAG,EAC1B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAKjB,cAAc,CAAC,CAAC,GAAG,GAAG,EAC1B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAKjB,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAK1B,aAAa,CAAC,CAAC,GAAG,GAAG,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;CAG1B"}
@@ -0,0 +1,81 @@
1
+ export class Cocobase {
2
+ constructor(config) {
3
+ this.baseURL = "https://cocobase-api.onrender.com";
4
+ this.apiKey = config.apiKey;
5
+ }
6
+ async request(method, path, body) {
7
+ const url = `${this.baseURL}${path}`;
8
+ try {
9
+ const res = await fetch(url, {
10
+ method,
11
+ headers: {
12
+ 'Content-Type': 'application/json',
13
+ ...(this.apiKey ? { 'x-api-key': `${this.apiKey}` } : {}),
14
+ },
15
+ ...(body ? { body: JSON.stringify({ data: body }) } : {}),
16
+ });
17
+ if (!res.ok) {
18
+ const errorText = await res.text();
19
+ let errorDetail;
20
+ try {
21
+ errorDetail = JSON.parse(errorText);
22
+ }
23
+ catch {
24
+ errorDetail = errorText;
25
+ }
26
+ const errorMessage = {
27
+ statusCode: res.status,
28
+ url,
29
+ method,
30
+ error: errorDetail,
31
+ suggestions: this.getErrorSuggestion(res.status, method)
32
+ };
33
+ throw new Error(`Request failed:\n${JSON.stringify(errorMessage, null, 2)}`);
34
+ }
35
+ return res.json();
36
+ }
37
+ catch (error) {
38
+ if (error instanceof Error) {
39
+ throw error;
40
+ }
41
+ throw new Error(`Unexpected error during ${method} request to ${url}: ${error}`);
42
+ }
43
+ }
44
+ getErrorSuggestion(status, method) {
45
+ switch (status) {
46
+ case 401:
47
+ return "Check if your API key is valid and properly set";
48
+ case 403:
49
+ return "You don't have permission to perform this action. Verify your access rights";
50
+ case 404:
51
+ return "The requested resource was not found. Verify the path and ID are correct";
52
+ case 405:
53
+ return `The ${method} method is not allowed for this endpoint. Check the API documentation for supported methods`;
54
+ case 429:
55
+ return "You've exceeded the rate limit. Please wait before making more requests";
56
+ default:
57
+ return "Check the API documentation and verify your request format";
58
+ }
59
+ }
60
+ // Fetch a single document
61
+ async getDocument(collection, docId) {
62
+ return this.request('GET', `/collections/${collection}/documents/${docId}`);
63
+ }
64
+ // Create a new document
65
+ async createDocument(collection, data) {
66
+ return this.request('POST', `/collections/documents?collection=${collection}`, data);
67
+ }
68
+ // Update a document
69
+ async updateDocument(collection, docId, data) {
70
+ return this.request('PATCH', `/collections/${collection}/documents/${docId}`, data);
71
+ }
72
+ // Delete a document
73
+ async deleteDocument(collection, docId) {
74
+ return this.request('DELETE', `/collections/${collection}/documents/${docId}`);
75
+ }
76
+ // List documents
77
+ async listDocuments(collection) {
78
+ return this.request('GET', `/collections/${collection}/documents`);
79
+ }
80
+ }
81
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core/core.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,QAAQ;IAInB,YAAY,MAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,mCAAmC,CAAC;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,MAA2C,EAC3C,IAAY,EACZ,IAAc;QAEd,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAC3B,MAAM;gBACN,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC1D;gBACD,GAAG,CAAC,IAAI,CAAC,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0EAA0E,CAAC;YACpF,KAAK,GAAG;gBACN,OAAO,OAAO,MAAM,6FAA6F,CAAC;YACpH,KAAK,GAAG;gBACN,OAAO,yEAAyE,CAAC;YACnF;gBACE,OAAO,4DAA4D,CAAC;QACxE,CAAC;IACH,CAAC;IAED,0BAA0B;IAC1B,KAAK,CAAC,WAAW,CACf,UAAkB,EAClB,KAAa;QAEb,OAAO,IAAI,CAAC,OAAO,CAAc,KAAK,EAAE,gBAAgB,UAAU,cAAc,KAAK,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,cAAc,CAClB,UAAkB,EAClB,IAAO;QAEP,OAAO,IAAI,CAAC,OAAO,CAAc,MAAM,EAAE,qCAAqC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;IACpG,CAAC;IAED,oBAAoB;IACpB,KAAK,CAAC,cAAc,CAClB,UAAkB,EAClB,KAAa,EACb,IAAgB;QAEhB,OAAO,IAAI,CAAC,OAAO,CAAc,OAAO,EAAE,gBAAgB,UAAU,cAAc,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC;IACnG,CAAC;IAED,oBAAoB;IACpB,KAAK,CAAC,cAAc,CAClB,UAAkB,EAClB,KAAa;QAEb,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,UAAU,cAAc,KAAK,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,iBAAiB;IACjB,KAAK,CAAC,aAAa,CACjB,UAAkB;QAElB,OAAO,IAAI,CAAC,OAAO,CAAgB,KAAK,EAAE,gBAAgB,UAAU,YAAY,CAAC,CAAC;IACpF,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { CocobaseConfig, Document } from "../types/types";
2
+ export declare class Cocobase {
3
+ private baseURL;
4
+ private apiKey?;
5
+ constructor(config: CocobaseConfig);
6
+ private request;
7
+ private getErrorSuggestion;
8
+ getDocument<T = any>(collection: string, docId: string): Promise<Document<T>>;
9
+ createDocument<T = any>(collection: string, data: T): Promise<Document<T>>;
10
+ updateDocument<T = any>(collection: string, docId: string, data: Partial<T>): Promise<Document<T>>;
11
+ deleteDocument(collection: string, docId: string): Promise<{
12
+ success: boolean;
13
+ }>;
14
+ listDocuments<T = any>(collection: string): Promise<Document<T>[]>;
15
+ }
16
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/core/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1D,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAS;gBAEZ,MAAM,EAAE,cAAc;YAKpB,OAAO;IA6CrB,OAAO,CAAC,kBAAkB;IAkBpB,WAAW,CAAC,CAAC,GAAG,GAAG,EACvB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAKjB,cAAc,CAAC,CAAC,GAAG,GAAG,EAC1B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAKjB,cAAc,CAAC,CAAC,GAAG,GAAG,EAC1B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAKjB,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAK1B,aAAa,CAAC,CAAC,GAAG,GAAG,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;CAG1B"}
@@ -0,0 +1,81 @@
1
+ export class Cocobase {
2
+ constructor(config) {
3
+ this.baseURL = "https://cocobase-api.onrender.com";
4
+ this.apiKey = config.apiKey;
5
+ }
6
+ async request(method, path, body) {
7
+ const url = `${this.baseURL}${path}`;
8
+ try {
9
+ const res = await fetch(url, {
10
+ method,
11
+ headers: {
12
+ 'Content-Type': 'application/json',
13
+ ...(this.apiKey ? { 'x-api-key': `${this.apiKey}` } : {}),
14
+ },
15
+ ...(body ? { body: JSON.stringify({ data: body }) } : {}),
16
+ });
17
+ if (!res.ok) {
18
+ const errorText = await res.text();
19
+ let errorDetail;
20
+ try {
21
+ errorDetail = JSON.parse(errorText);
22
+ }
23
+ catch {
24
+ errorDetail = errorText;
25
+ }
26
+ const errorMessage = {
27
+ statusCode: res.status,
28
+ url,
29
+ method,
30
+ error: errorDetail,
31
+ suggestions: this.getErrorSuggestion(res.status, method)
32
+ };
33
+ throw new Error(`Request failed:\n${JSON.stringify(errorMessage, null, 2)}`);
34
+ }
35
+ return res.json();
36
+ }
37
+ catch (error) {
38
+ if (error instanceof Error) {
39
+ throw error;
40
+ }
41
+ throw new Error(`Unexpected error during ${method} request to ${url}: ${error}`);
42
+ }
43
+ }
44
+ getErrorSuggestion(status, method) {
45
+ switch (status) {
46
+ case 401:
47
+ return "Check if your API key is valid and properly set";
48
+ case 403:
49
+ return "You don't have permission to perform this action. Verify your access rights";
50
+ case 404:
51
+ return "The requested resource was not found. Verify the path and ID are correct";
52
+ case 405:
53
+ return `The ${method} method is not allowed for this endpoint. Check the API documentation for supported methods`;
54
+ case 429:
55
+ return "You've exceeded the rate limit. Please wait before making more requests";
56
+ default:
57
+ return "Check the API documentation and verify your request format";
58
+ }
59
+ }
60
+ // Fetch a single document
61
+ async getDocument(collection, docId) {
62
+ return this.request('GET', `/collections/${collection}/documents/${docId}`);
63
+ }
64
+ // Create a new document
65
+ async createDocument(collection, data) {
66
+ return this.request('POST', `/collections/documents?collection=${collection}`, data);
67
+ }
68
+ // Update a document
69
+ async updateDocument(collection, docId, data) {
70
+ return this.request('PATCH', `/collections/${collection}/documents/${docId}`, data);
71
+ }
72
+ // Delete a document
73
+ async deleteDocument(collection, docId) {
74
+ return this.request('DELETE', `/collections/${collection}/documents/${docId}`);
75
+ }
76
+ // List documents
77
+ async listDocuments(collection) {
78
+ return this.request('GET', `/collections/${collection}/documents`);
79
+ }
80
+ }
81
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/core/core.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,QAAQ;IAInB,YAAY,MAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,mCAAmC,CAAC;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,MAA2C,EAC3C,IAAY,EACZ,IAAc;QAEd,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAC3B,MAAM;gBACN,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC1D;gBACD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,IAAI,EAAC,IAAI,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACvD,CAAC,CAAC;YAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;gBACnC,IAAI,WAAW,CAAC;gBAChB,IAAI,CAAC;oBACH,W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K,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,cAAc,CAClB,UAAkB,EAClB,IAAO;QAEP,OAAO,IAAI,CAAC,OAAO,CAAc,MAAM,EAAE,qCAAqC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;IACpG,CAAC;IAED,oBAAoB;IACpB,KAAK,CAAC,cAAc,CAClB,UAAkB,EAClB,KAAa,EACb,IAAgB;QAEhB,OAAO,IAAI,CAAC,OAAO,CAAc,OAAO,EAAE,gBAAgB,UAAU,cAAc,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC;IACnG,CAAC;IAED,oBAAoB;IACpB,KAAK,CAAC,cAAc,CAClB,UAAkB,EAClB,KAAa;QAEb,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,UAAU,cAAc,KAAK,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,iBAAiB;IACjB,KAAK,CAAC,aAAa,CACjB,UAAkB;QAElB,OAAO,IAAI,CAAC,OAAO,CAAgB,KAAK,EAAE,gBAAgB,UAAU,YAAY,CAAC,CAAC;IACpF,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import { Cocobase } from "./core/core";
2
+ export { Cocobase };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAC,QAAQ,EAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Cocobase } from "./core/core";
2
+ export { Cocobase };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAC,QAAQ,EAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface CocobaseConfig {
2
+ apiKey?: string;
3
+ }
4
+ export interface Collection {
5
+ name: string;
6
+ id: string;
7
+ created_at: string;
8
+ }
9
+ export interface Document<T> {
10
+ data: T;
11
+ id: string;
12
+ collection_id: string;
13
+ created_at: string;
14
+ collection: Collection;
15
+ }
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { Cocobase } from "./core/core";
2
+ export { Cocobase };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAC,QAAQ,EAAC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Cocobase } from "./core/core";
2
+ export { Cocobase };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAC,QAAQ,EAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface CocobaseConfig {
2
+ apiKey?: string;
3
+ }
4
+ export interface Collection {
5
+ name: string;
6
+ id: string;
7
+ created_at: string;
8
+ }
9
+ export interface Document<T> {
10
+ data: T;
11
+ id: string;
12
+ collection_id: string;
13
+ created_at: string;
14
+ collection: Collection;
15
+ }
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "cocobase",
3
+ "version": "0.0.1",
4
+ "description": "The Official cocobase sdk",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "npm run clean && npm run build:cjs && npm run build:esm",
14
+ "build:cjs": "tsc",
15
+ "build:esm": "tsc -m esnext --outDir dist/esm",
16
+ "clean": "if exist dist rd /s /q dist",
17
+ "test": "tsx test/app.ts",
18
+ "prepublishOnly": "npm run build",
19
+ "lint": "eslint src --ext .ts",
20
+ "format": "prettier --write \"src/**/*.ts\"",
21
+ "prepare": "npm run build"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/yourusername/cocobase.git"
26
+ },
27
+ "keywords": [
28
+ "baas",
29
+ "backend",
30
+ "api",
31
+ "client",
32
+ "cocobase",
33
+ "database",
34
+ "cloud"
35
+ ],
36
+ "author": "Your Name",
37
+ "license": "MIT",
38
+ "bugs": {
39
+ "url": "https://github.com/yourusername/cocobase/issues"
40
+ },
41
+ "homepage": "https://github.com/yourusername/cocobase#readme",
42
+ "devDependencies": {
43
+ "@rollup/plugin-node-resolve": "^16.0.1",
44
+ "@rollup/plugin-typescript": "^12.1.2",
45
+ "@types/node": "^22.15.29",
46
+ "nodemon": "^3.1.10",
47
+ "rollup": "^4.41.1",
48
+ "ts-node": "^10.9.2",
49
+ "tsx": "^4.19.4",
50
+ "typescript": "^5.8.3"
51
+ },
52
+ "engines": {
53
+ "node": ">=14.0.0"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ }
58
+ }