marcidb-client 0.0.2 → 0.0.4

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 CHANGED
@@ -31,7 +31,7 @@ model Post {
31
31
  ```bash
32
32
  marci generate
33
33
  # or with custom paths
34
- marci generate schema.marci node_modules/.marci/client
34
+ marci generate schema.marci node_modules/.marcidb/client
35
35
  ```
36
36
 
37
37
  3. Start your MarciDB server and connect:
Binary file
Binary file
package/bin.js CHANGED
@@ -20,7 +20,7 @@ const COMMANDS = {
20
20
 
21
21
  function help() {
22
22
  console.log(`
23
- marci <command> [options]
23
+ marcidb <command> [options]
24
24
 
25
25
  Commands:
26
26
  generate [schema] [output] Generate TypeScript types from schema
@@ -28,15 +28,15 @@ Commands:
28
28
  output — output directory (default: node_modules/marci-db/generated)
29
29
 
30
30
  Examples:
31
- marci generate
32
- marci generate schema.marci
33
- marci generate schema.marci node_modules/.marci/client
31
+ marcidb generate
32
+ marcidb generate schema.marci
33
+ marcidb generate schema.marci node_modules/.marcidb/client
34
34
  `);
35
35
  }
36
36
 
37
37
  function cmdGenerate(args) {
38
38
  const schema = args[0] ?? "schema.marci";
39
- const output = args[1] ?? "node_modules/.marci/client";
39
+ const output = args[1] ?? "node_modules/.marcidb/client";
40
40
 
41
41
  const key = `${os.platform()}-${os.arch()}`;
42
42
  const name = BINS[key];
package/client/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '.marci/client'
1
+ export * from '.marcidb/client'
package/client/index.js CHANGED
@@ -1 +1 @@
1
- export * from '.marci/client'
1
+ export * from '.marcidb/client'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "marcidb-client",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "den59k"
@@ -11,10 +11,10 @@
11
11
  "url": "git+https://github.com/den59k/marci-db.git"
12
12
  },
13
13
  "scripts": {
14
- "build": "bunup src/index.ts --external .marci/client --out-dir runtime"
14
+ "build": "bunup src/index.ts --external .marcidb/client --out-dir runtime"
15
15
  },
16
16
  "bin": {
17
- "marci": "bin.js"
17
+ "marcidb": "bin.js"
18
18
  },
19
19
  "files": [
20
20
  "bin/",
@@ -1,3 +1,3 @@
1
- import { MarciDB } from ".marci/client";
2
- declare const marci: (url: string) => MarciDB;
3
- export { marci };
1
+ declare function request(method: string, url: string, body?: any);
2
+ declare function encodeId(id: any);
3
+ export { request, encodeId };
package/runtime/index.js CHANGED
@@ -1,33 +1,15 @@
1
- // src/client.ts
2
- class MarciClient {
3
- baseUrl;
4
- constructor(url) {
5
- this.baseUrl = url.replace(/\/$/, "");
6
- }
7
- async#request(method, path, body) {
8
- const res = await fetch(`${this.baseUrl}${path}`, {
9
- method,
10
- headers: { "Content-Type": "application/json" },
11
- body: body !== undefined ? JSON.stringify(body) : undefined
12
- });
13
- if (!res.ok) {
14
- const text = await res.text();
15
- throw new Error(`MarciDB [${res.status}]: ${text}`);
16
- }
17
- return res.json();
18
- }
19
- findMany(model, select) {
20
- return this.#request("POST", `/${model}/findMany`, select);
21
- }
22
- insert(model, data) {
23
- return this.#request("POST", `/${model}/insert`, data);
24
- }
25
- update(model, id, data) {
26
- return this.#request("POST", `/${model}/update/${encodeId(id)}`, data);
27
- }
28
- delete(model, id) {
29
- return this.#request("POST", `/${model}/delete/${encodeId(id)}`);
1
+ // src/index.ts
2
+ async function request(method, url, body) {
3
+ const res = await fetch(url, {
4
+ method,
5
+ headers: { "Content-Type": "application/json" },
6
+ body: body !== undefined ? JSON.stringify(body) : undefined
7
+ });
8
+ if (!res.ok) {
9
+ const text = await res.text();
10
+ throw new Error(`MarciDB [${res.status}]: ${text}`);
30
11
  }
12
+ return res.json();
31
13
  }
32
14
  function encodeId(id) {
33
15
  if (typeof id === "object" && id !== null) {
@@ -35,13 +17,7 @@ function encodeId(id) {
35
17
  }
36
18
  return String(id);
37
19
  }
38
-
39
- // src/index.ts
40
- import { connect } from ".marci/client";
41
- var marci = (url) => {
42
- const client = new MarciClient(url);
43
- return connect(client);
44
- };
45
20
  export {
46
- marci
21
+ request,
22
+ encodeId
47
23
  };