kyro-connect 0.1.2 → 0.1.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/dist/bin/kyro-codegen.cjs +2 -0
- package/dist/bin/kyro-codegen.js +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +1 -1
- package/package.json +4 -2
|
@@ -7,9 +7,11 @@ var import_path = require("path");
|
|
|
7
7
|
|
|
8
8
|
// src/codegen.ts
|
|
9
9
|
function capitalize(s) {
|
|
10
|
+
if (typeof s !== "string") return "";
|
|
10
11
|
return s.replace(/[-_]\w/g, (m) => m[1].toUpperCase()).replace(/^\w/, (c) => c.toUpperCase());
|
|
11
12
|
}
|
|
12
13
|
function toTSName(slug) {
|
|
14
|
+
if (typeof slug !== "string") return "";
|
|
13
15
|
return slug.replace(/[-_]\w/g, (m) => m[1].toUpperCase()).replace(/^_+/g, "");
|
|
14
16
|
}
|
|
15
17
|
function fieldToTS(field, depth = 0) {
|
package/dist/bin/kyro-codegen.js
CHANGED
|
@@ -6,9 +6,11 @@ import { resolve } from "path";
|
|
|
6
6
|
|
|
7
7
|
// src/codegen.ts
|
|
8
8
|
function capitalize(s) {
|
|
9
|
+
if (typeof s !== "string") return "";
|
|
9
10
|
return s.replace(/[-_]\w/g, (m) => m[1].toUpperCase()).replace(/^\w/, (c) => c.toUpperCase());
|
|
10
11
|
}
|
|
11
12
|
function toTSName(slug) {
|
|
13
|
+
if (typeof slug !== "string") return "";
|
|
12
14
|
return slug.replace(/[-_]\w/g, (m) => m[1].toUpperCase()).replace(/^_+/g, "");
|
|
13
15
|
}
|
|
14
16
|
function fieldToTS(field, depth = 0) {
|
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ var KyroConnectError = class extends Error {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
// src/client.ts
|
|
43
|
-
var MUTATIONS = /* @__PURE__ */ new Set(["create", "update", "delete"]);
|
|
43
|
+
var MUTATIONS = /* @__PURE__ */ new Set(["create", "update", "delete", "mutate"]);
|
|
44
44
|
async function handleResponse(res) {
|
|
45
45
|
if (!res.ok) {
|
|
46
46
|
let body2;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,17 @@ interface ClientOptions {
|
|
|
3
3
|
apiKey?: string;
|
|
4
4
|
fetch?: typeof globalThis.fetch;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
type ProcedureClient<I, O> = {
|
|
7
|
+
query: (input: I) => Promise<O>;
|
|
8
|
+
mutate: (input: I) => Promise<O>;
|
|
9
|
+
};
|
|
10
|
+
type RouterClient<T> = {
|
|
11
|
+
[K in keyof T]: T[K] extends {
|
|
12
|
+
input: infer I;
|
|
13
|
+
output: infer O;
|
|
14
|
+
} ? ProcedureClient<I, O> : T[K] extends Record<string, any> ? RouterClient<T[K]> : T[K];
|
|
15
|
+
};
|
|
16
|
+
declare function createClient<TRouter extends Record<string, any> = any>(opts: ClientOptions): RouterClient<TRouter>;
|
|
7
17
|
|
|
8
18
|
declare class KyroConnectError extends Error {
|
|
9
19
|
readonly status: number;
|
|
@@ -12,4 +22,4 @@ declare class KyroConnectError extends Error {
|
|
|
12
22
|
constructor(message: string, status?: number, raw?: any);
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
export { type ClientOptions, KyroConnectError, createClient };
|
|
25
|
+
export { type ClientOptions, KyroConnectError, type ProcedureClient, type RouterClient, createClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,17 @@ interface ClientOptions {
|
|
|
3
3
|
apiKey?: string;
|
|
4
4
|
fetch?: typeof globalThis.fetch;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
type ProcedureClient<I, O> = {
|
|
7
|
+
query: (input: I) => Promise<O>;
|
|
8
|
+
mutate: (input: I) => Promise<O>;
|
|
9
|
+
};
|
|
10
|
+
type RouterClient<T> = {
|
|
11
|
+
[K in keyof T]: T[K] extends {
|
|
12
|
+
input: infer I;
|
|
13
|
+
output: infer O;
|
|
14
|
+
} ? ProcedureClient<I, O> : T[K] extends Record<string, any> ? RouterClient<T[K]> : T[K];
|
|
15
|
+
};
|
|
16
|
+
declare function createClient<TRouter extends Record<string, any> = any>(opts: ClientOptions): RouterClient<TRouter>;
|
|
7
17
|
|
|
8
18
|
declare class KyroConnectError extends Error {
|
|
9
19
|
readonly status: number;
|
|
@@ -12,4 +22,4 @@ declare class KyroConnectError extends Error {
|
|
|
12
22
|
constructor(message: string, status?: number, raw?: any);
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
export { type ClientOptions, KyroConnectError, createClient };
|
|
25
|
+
export { type ClientOptions, KyroConnectError, type ProcedureClient, type RouterClient, createClient };
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var KyroConnectError = class extends Error {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// src/client.ts
|
|
16
|
-
var MUTATIONS = /* @__PURE__ */ new Set(["create", "update", "delete"]);
|
|
16
|
+
var MUTATIONS = /* @__PURE__ */ new Set(["create", "update", "delete", "mutate"]);
|
|
17
17
|
async function handleResponse(res) {
|
|
18
18
|
if (!res.ok) {
|
|
19
19
|
let body2;
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kyro-connect",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Universal SDK for Kyro CMS. Type-safe client + codegen for any platform.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
6
8
|
"exports": {
|
|
7
9
|
".": {
|
|
8
10
|
"types": "./dist/index.d.ts",
|
|
@@ -36,4 +38,4 @@
|
|
|
36
38
|
"tsup": "^8.0.0",
|
|
37
39
|
"typescript": "^5.0.0"
|
|
38
40
|
}
|
|
39
|
-
}
|
|
41
|
+
}
|