@luvabase/sdk 0.0.7 → 0.0.8
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/index.d.ts +109 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest-schema.json +9 -1
- package/package.json +2 -1
- package/src/envSchema.ts +14 -4
- package/src/index.ts +21 -1
- package/src/manifestSchema.ts +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,123 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/envSchema.d.ts
|
|
4
|
+
type LuvaEnv = z.infer<typeof LuvaEnv>;
|
|
5
|
+
declare const LuvaEnv: z.ZodLazy<z.ZodObject<{
|
|
6
|
+
podId: z.ZodString;
|
|
7
|
+
installedAt: z.ZodString;
|
|
8
|
+
updatedAt: z.ZodString;
|
|
9
|
+
services: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
10
|
+
type: z.ZodLiteral<"turso">;
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
createdAt: z.ZodString;
|
|
13
|
+
databaseName: z.ZodString;
|
|
14
|
+
databaseApiToken: z.ZodString;
|
|
15
|
+
databaseHostname: z.ZodString;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
type: z.ZodLiteral<"r2">;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
createdAt: z.ZodString;
|
|
20
|
+
bucketName: z.ZodString;
|
|
21
|
+
}, z.core.$strip>]>>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
type TursoRuntimeService = z.infer<typeof TursoRuntimeService>;
|
|
24
|
+
declare const TursoRuntimeService: z.ZodObject<{
|
|
25
|
+
type: z.ZodLiteral<"turso">;
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
createdAt: z.ZodString;
|
|
28
|
+
databaseName: z.ZodString;
|
|
29
|
+
databaseApiToken: z.ZodString;
|
|
30
|
+
databaseHostname: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
type R2RuntimeService = z.infer<typeof R2RuntimeService>;
|
|
33
|
+
declare const R2RuntimeService: z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"r2">;
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
createdAt: z.ZodString;
|
|
37
|
+
bucketName: z.ZodString;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
type RuntimeService = z.infer<typeof RuntimeService>;
|
|
40
|
+
declare const RuntimeService: z.ZodUnion<readonly [z.ZodObject<{
|
|
41
|
+
type: z.ZodLiteral<"turso">;
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
createdAt: z.ZodString;
|
|
44
|
+
databaseName: z.ZodString;
|
|
45
|
+
databaseApiToken: z.ZodString;
|
|
46
|
+
databaseHostname: z.ZodString;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"r2">;
|
|
49
|
+
name: z.ZodString;
|
|
50
|
+
createdAt: z.ZodString;
|
|
51
|
+
bucketName: z.ZodString;
|
|
52
|
+
}, z.core.$strip>]>;
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/manifestSchema.d.ts
|
|
55
|
+
type AppManifest = z.infer<typeof AppManifest>;
|
|
56
|
+
declare const AppManifest: z.ZodLazy<z.ZodObject<{
|
|
57
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
58
|
+
identifier: z.ZodOptional<z.ZodString>;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
61
|
+
description: z.ZodOptional<z.ZodString>;
|
|
62
|
+
screenshots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
category: z.ZodOptional<z.ZodString>;
|
|
64
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
65
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
66
|
+
services: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
67
|
+
type: z.ZodEnum<{
|
|
68
|
+
turso: "turso";
|
|
69
|
+
r2: "r2";
|
|
70
|
+
"durable-object": "durable-object";
|
|
71
|
+
}>;
|
|
72
|
+
name: z.ZodString;
|
|
73
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
74
|
+
}, z.core.$strip>>>;
|
|
75
|
+
relatedApps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
76
|
+
type: z.ZodEnum<{
|
|
77
|
+
android: "android";
|
|
78
|
+
ios: "ios";
|
|
79
|
+
}>;
|
|
80
|
+
identifier: z.ZodString;
|
|
81
|
+
downloadLink: z.ZodOptional<z.ZodString>;
|
|
82
|
+
redirectUrls: z.ZodArray<z.ZodString>;
|
|
83
|
+
}, z.core.$strip>>>;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
declare const RelatedApp: z.ZodObject<{
|
|
86
|
+
type: z.ZodEnum<{
|
|
87
|
+
android: "android";
|
|
88
|
+
ios: "ios";
|
|
89
|
+
}>;
|
|
90
|
+
identifier: z.ZodString;
|
|
91
|
+
downloadLink: z.ZodOptional<z.ZodString>;
|
|
92
|
+
redirectUrls: z.ZodArray<z.ZodString>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
//#endregion
|
|
1
95
|
//#region src/index.d.ts
|
|
2
|
-
declare function parseEnv(env: Record<string, unknown>): {
|
|
96
|
+
declare function parseEnv(env: Record<string, unknown> | string): {
|
|
3
97
|
podId: string;
|
|
4
|
-
appVersion: string;
|
|
5
98
|
installedAt: string;
|
|
6
99
|
updatedAt: string;
|
|
7
100
|
services: Record<string, {
|
|
8
101
|
type: "turso";
|
|
9
102
|
name: string;
|
|
103
|
+
createdAt: string;
|
|
10
104
|
databaseName: string;
|
|
11
105
|
databaseApiToken: string;
|
|
12
106
|
databaseHostname: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: "r2";
|
|
109
|
+
name: string;
|
|
110
|
+
createdAt: string;
|
|
111
|
+
bucketName: string;
|
|
13
112
|
}>;
|
|
14
113
|
};
|
|
114
|
+
declare function getAdminUrl(env: Record<string, unknown> | string): string;
|
|
115
|
+
declare function parseRequest(request: Request): {
|
|
116
|
+
user: {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
15
121
|
//#endregion
|
|
16
|
-
export { parseEnv };
|
|
122
|
+
export { AppManifest, LuvaEnv, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, parseEnv, parseRequest };
|
|
17
123
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/envSchema.ts","../src/manifestSchema.ts","../src/index.ts"],"mappings":";;;KAEY,OAAA,GAAU,CAAA,CAAE,KAAA,QAAa,OAAA;AAAA,cACxB,OAAA,EAAO,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;KASR,mBAAA,GAAsB,CAAA,CAAE,KAAA,QAAa,mBAAA;AAAA,cACpC,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;;KASpB,gBAAA,GAAmB,CAAA,CAAE,KAAA,QAAa,gBAAA;AAAA,cACjC,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;;;KAOjB,cAAA,GAAiB,CAAA,CAAE,KAAA,QAAa,cAAA;AAAA,cAC/B,cAAA,EAAc,CAAA,CAAA,QAAA,WAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;KC7Bf,WAAA,GAAc,CAAA,CAAE,KAAA,QAAa,WAAA;AAAA,cAC5B,WAAA,EAAW,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmEX,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;;;;iBCjEP,QAAA,CAAS,GAAA,EAAK,MAAA;;;;YAAA,MAAA;;;;;;;;;;;;;;iBAQd,WAAA,CAAY,GAAA,EAAK,MAAA;AAAA,iBAKjB,YAAA,CAAa,OAAA,EAAS,OAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import { z } from "zod";
|
|
|
3
3
|
//#region src/envSchema.ts
|
|
4
4
|
const LuvaEnv = z.lazy(() => z.object({
|
|
5
5
|
podId: z.string().describe("The id of the pod"),
|
|
6
|
-
appVersion: z.string(),
|
|
7
6
|
installedAt: z.string(),
|
|
8
7
|
updatedAt: z.string(),
|
|
9
8
|
services: z.record(z.string(), RuntimeService)
|
|
@@ -11,18 +10,65 @@ const LuvaEnv = z.lazy(() => z.object({
|
|
|
11
10
|
const TursoRuntimeService = z.object({
|
|
12
11
|
type: z.literal("turso"),
|
|
13
12
|
name: z.string(),
|
|
13
|
+
createdAt: z.string(),
|
|
14
14
|
databaseName: z.string(),
|
|
15
15
|
databaseApiToken: z.string(),
|
|
16
16
|
databaseHostname: z.string()
|
|
17
17
|
});
|
|
18
|
-
const
|
|
18
|
+
const R2RuntimeService = z.object({
|
|
19
|
+
type: z.literal("r2"),
|
|
20
|
+
name: z.string(),
|
|
21
|
+
createdAt: z.string(),
|
|
22
|
+
bucketName: z.string()
|
|
23
|
+
});
|
|
24
|
+
const RuntimeService = z.union([TursoRuntimeService, R2RuntimeService]);
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/manifestSchema.ts
|
|
28
|
+
const AppManifest = z.lazy(() => z.object({
|
|
29
|
+
$schema: z.string().optional().describe("JSON Schema for the manifest"),
|
|
30
|
+
identifier: z.string().regex(/^[a-z0-9-]+$/).min(3).max(50).optional().describe("Globally unique url safe and lowercased identifier for the app e.g. 'luvabase-snake' (required for Luvabase submissions)"),
|
|
31
|
+
name: z.string().min(3).max(30).describe("Name of the app e.g. 'Snake' (max 30 characters)"),
|
|
32
|
+
subtitle: z.string().min(3).max(50).optional().describe("Subtitle of the app e.g. 'Play the classic of classics' (max 50 characters)"),
|
|
33
|
+
description: z.string().max(1e4).optional().describe("Full description of the app"),
|
|
34
|
+
screenshots: z.array(z.string()).optional().describe("Relative paths of app screenshots e.g. ['images/screenshot1.png', 'images/screenshot2.png']"),
|
|
35
|
+
category: z.string().optional().describe("Could be 'productivity', 'health', etc (must be one of the standard categories listed here https://github.com/w3c/manifest/wiki/Categories)"),
|
|
36
|
+
icon: z.string().optional().describe("Relative path of the app icon inside the .luva app file e.g. 'images/icon.png'"),
|
|
37
|
+
repository: z.string().optional().describe("URL of the source code repository e.g. 'https://github.com/luvabase/snake'"),
|
|
38
|
+
services: z.array(z.object({
|
|
39
|
+
type: z.enum([
|
|
40
|
+
"turso",
|
|
41
|
+
"durable-object",
|
|
42
|
+
"r2"
|
|
43
|
+
]),
|
|
44
|
+
name: z.string(),
|
|
45
|
+
metadata: z.record(z.string(), z.any()).optional()
|
|
46
|
+
})).optional(),
|
|
47
|
+
relatedApps: z.array(RelatedApp).optional()
|
|
48
|
+
}));
|
|
49
|
+
const RelatedApp = z.object({
|
|
50
|
+
type: z.enum(["android", "ios"]),
|
|
51
|
+
identifier: z.string(),
|
|
52
|
+
downloadLink: z.string().optional(),
|
|
53
|
+
redirectUrls: z.array(z.string())
|
|
54
|
+
});
|
|
19
55
|
|
|
20
56
|
//#endregion
|
|
21
57
|
//#region src/index.ts
|
|
22
58
|
function parseEnv(env) {
|
|
59
|
+
if (typeof env === "string") env = JSON.parse(env);
|
|
23
60
|
return LuvaEnv.parse(env);
|
|
24
61
|
}
|
|
62
|
+
function getAdminUrl(env) {
|
|
63
|
+
return `https://luvabase.com/dash/pods/${parseEnv(env).podId}`;
|
|
64
|
+
}
|
|
65
|
+
function parseRequest(request) {
|
|
66
|
+
return { user: {
|
|
67
|
+
id: request.headers.get("x-luva-user-id"),
|
|
68
|
+
name: request.headers.get("x-luva-user-name")
|
|
69
|
+
} };
|
|
70
|
+
}
|
|
25
71
|
|
|
26
72
|
//#endregion
|
|
27
|
-
export { parseEnv };
|
|
73
|
+
export { AppManifest, LuvaEnv, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, parseEnv, parseRequest };
|
|
28
74
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/envSchema.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\"\n\nexport type
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/envSchema.ts","../src/manifestSchema.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\"\n\nexport type LuvaEnv = z.infer<typeof LuvaEnv>\nexport const LuvaEnv = z.lazy(() =>\n z.object({\n podId: z.string().describe(\"The id of the pod\"),\n installedAt: z.string(),\n updatedAt: z.string(),\n services: z.record(z.string(), RuntimeService),\n }),\n)\n\nexport type TursoRuntimeService = z.infer<typeof TursoRuntimeService>\nexport const TursoRuntimeService = z.object({\n type: z.literal(\"turso\"),\n name: z.string(),\n createdAt: z.string(),\n databaseName: z.string(),\n databaseApiToken: z.string(),\n databaseHostname: z.string(),\n})\n\nexport type R2RuntimeService = z.infer<typeof R2RuntimeService>\nexport const R2RuntimeService = z.object({\n type: z.literal(\"r2\"),\n name: z.string(),\n createdAt: z.string(),\n bucketName: z.string(),\n})\n\nexport type RuntimeService = z.infer<typeof RuntimeService>\nexport const RuntimeService = z.union([TursoRuntimeService, R2RuntimeService])\n","import { z } from \"zod\"\n\nexport type AppManifest = z.infer<typeof AppManifest>\nexport const AppManifest = z.lazy(() =>\n z.object({\n $schema: z.string().optional().describe(\"JSON Schema for the manifest\"),\n identifier: z\n .string()\n .regex(/^[a-z0-9-]+$/)\n .min(3)\n .max(50)\n .optional()\n .describe(\n \"Globally unique url safe and lowercased identifier for the app e.g. 'luvabase-snake' (required for Luvabase submissions)\",\n ),\n name: z\n .string()\n .min(3)\n .max(30)\n .describe(\"Name of the app e.g. 'Snake' (max 30 characters)\"),\n subtitle: z\n .string()\n .min(3)\n .max(50)\n .optional()\n .describe(\n \"Subtitle of the app e.g. 'Play the classic of classics' (max 50 characters)\",\n ),\n description: z\n .string()\n .max(10000)\n .optional()\n .describe(\"Full description of the app\"),\n screenshots: z\n .array(z.string())\n .optional()\n .describe(\n \"Relative paths of app screenshots e.g. ['images/screenshot1.png', 'images/screenshot2.png']\",\n ),\n category: z\n .string()\n .optional()\n .describe(\n \"Could be 'productivity', 'health', etc (must be one of the standard categories listed here https://github.com/w3c/manifest/wiki/Categories)\",\n ),\n icon: z\n .string()\n .optional()\n .describe(\n \"Relative path of the app icon inside the .luva app file e.g. 'images/icon.png'\",\n ),\n repository: z\n .string()\n .optional()\n .describe(\n \"URL of the source code repository e.g. 'https://github.com/luvabase/snake'\",\n ),\n services: z\n .array(\n z.object({\n type: z.enum([\"turso\", \"durable-object\", \"r2\"]),\n name: z.string(),\n metadata: z.record(z.string(), z.any()).optional(),\n }),\n )\n .optional(),\n relatedApps: z.array(RelatedApp).optional(),\n }),\n)\n\nexport const RelatedApp = z.object({\n type: z.enum([\"android\", \"ios\"]),\n identifier: z.string(), // android package name or ios bundle id\n downloadLink: z.string().optional(),\n redirectUrls: z.array(z.string()),\n})\n","import { LuvaEnv } from \"./envSchema\"\n\nexport * from \"./envSchema\"\nexport * from \"./manifestSchema\"\n\nexport function parseEnv(env: Record<string, unknown> | string) {\n if (typeof env === \"string\") {\n env = JSON.parse(env)\n }\n const luvabaseEnv = LuvaEnv.parse(env)\n return luvabaseEnv\n}\n\nexport function getAdminUrl(env: Record<string, unknown> | string) {\n const luvaEnv = parseEnv(env)\n return `https://luvabase.com/dash/pods/${luvaEnv.podId}`\n}\n\nexport function parseRequest(request: Request) {\n return {\n user: {\n id: request.headers.get(\"x-luva-user-id\")!,\n name: request.headers.get(\"x-luva-user-name\")!,\n },\n }\n}\n"],"mappings":";;;AAGA,MAAa,UAAU,EAAE,WACvB,EAAE,OAAO;CACP,OAAO,EAAE,QAAQ,CAAC,SAAS,oBAAoB;CAC/C,aAAa,EAAE,QAAQ;CACvB,WAAW,EAAE,QAAQ;CACrB,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe;CAC/C,CAAC,CACH;AAGD,MAAa,sBAAsB,EAAE,OAAO;CAC1C,MAAM,EAAE,QAAQ,QAAQ;CACxB,MAAM,EAAE,QAAQ;CAChB,WAAW,EAAE,QAAQ;CACrB,cAAc,EAAE,QAAQ;CACxB,kBAAkB,EAAE,QAAQ;CAC5B,kBAAkB,EAAE,QAAQ;CAC7B,CAAC;AAGF,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,EAAE,QAAQ,KAAK;CACrB,MAAM,EAAE,QAAQ;CAChB,WAAW,EAAE,QAAQ;CACrB,YAAY,EAAE,QAAQ;CACvB,CAAC;AAGF,MAAa,iBAAiB,EAAE,MAAM,CAAC,qBAAqB,iBAAiB,CAAC;;;;AC5B9E,MAAa,cAAc,EAAE,WAC3B,EAAE,OAAO;CACP,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,+BAA+B;CACvE,YAAY,EACT,QAAQ,CACR,MAAM,eAAe,CACrB,IAAI,EAAE,CACN,IAAI,GAAG,CACP,UAAU,CACV,SACC,2HACD;CACH,MAAM,EACH,QAAQ,CACR,IAAI,EAAE,CACN,IAAI,GAAG,CACP,SAAS,mDAAmD;CAC/D,UAAU,EACP,QAAQ,CACR,IAAI,EAAE,CACN,IAAI,GAAG,CACP,UAAU,CACV,SACC,8EACD;CACH,aAAa,EACV,QAAQ,CACR,IAAI,IAAM,CACV,UAAU,CACV,SAAS,8BAA8B;CAC1C,aAAa,EACV,MAAM,EAAE,QAAQ,CAAC,CACjB,UAAU,CACV,SACC,8FACD;CACH,UAAU,EACP,QAAQ,CACR,UAAU,CACV,SACC,8IACD;CACH,MAAM,EACH,QAAQ,CACR,UAAU,CACV,SACC,iFACD;CACH,YAAY,EACT,QAAQ,CACR,UAAU,CACV,SACC,6EACD;CACH,UAAU,EACP,MACC,EAAE,OAAO;EACP,MAAM,EAAE,KAAK;GAAC;GAAS;GAAkB;GAAK,CAAC;EAC/C,MAAM,EAAE,QAAQ;EAChB,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,UAAU;EACnD,CAAC,CACH,CACA,UAAU;CACb,aAAa,EAAE,MAAM,WAAW,CAAC,UAAU;CAC5C,CAAC,CACH;AAED,MAAa,aAAa,EAAE,OAAO;CACjC,MAAM,EAAE,KAAK,CAAC,WAAW,MAAM,CAAC;CAChC,YAAY,EAAE,QAAQ;CACtB,cAAc,EAAE,QAAQ,CAAC,UAAU;CACnC,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC;CAClC,CAAC;;;;ACtEF,SAAgB,SAAS,KAAuC;AAC9D,KAAI,OAAO,QAAQ,SACjB,OAAM,KAAK,MAAM,IAAI;AAGvB,QADoB,QAAQ,MAAM,IAAI;;AAIxC,SAAgB,YAAY,KAAuC;AAEjE,QAAO,kCADS,SAAS,IAAI,CACoB;;AAGnD,SAAgB,aAAa,SAAkB;AAC7C,QAAO,EACL,MAAM;EACJ,IAAI,QAAQ,QAAQ,IAAI,iBAAiB;EACzC,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;EAC9C,EACF"}
|
|
@@ -58,11 +58,19 @@
|
|
|
58
58
|
"type": "string",
|
|
59
59
|
"enum": [
|
|
60
60
|
"turso",
|
|
61
|
-
"
|
|
61
|
+
"durable-object",
|
|
62
|
+
"r2"
|
|
62
63
|
]
|
|
63
64
|
},
|
|
64
65
|
"name": {
|
|
65
66
|
"type": "string"
|
|
67
|
+
},
|
|
68
|
+
"metadata": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"propertyNames": {
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"additionalProperties": {}
|
|
66
74
|
}
|
|
67
75
|
},
|
|
68
76
|
"required": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvabase/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
+
"publish": "bun run build && bun publish",
|
|
16
17
|
"generate-manifest-json-schema": "bun -e \"import * as t from './tools/tools'; t.generateManifestJsonSchema()\"",
|
|
17
18
|
"build": "tsdown src/index.ts && bun run generate-manifest-json-schema"
|
|
18
19
|
},
|
package/src/envSchema.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { z } from "zod"
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type LuvaEnv = z.infer<typeof LuvaEnv>
|
|
4
4
|
export const LuvaEnv = z.lazy(() =>
|
|
5
5
|
z.object({
|
|
6
6
|
podId: z.string().describe("The id of the pod"),
|
|
7
|
-
appVersion: z.string(),
|
|
8
7
|
installedAt: z.string(),
|
|
9
8
|
updatedAt: z.string(),
|
|
10
9
|
services: z.record(z.string(), RuntimeService),
|
|
11
10
|
}),
|
|
12
11
|
)
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
export type TursoRuntimeService = z.infer<typeof TursoRuntimeService>
|
|
14
|
+
export const TursoRuntimeService = z.object({
|
|
15
15
|
type: z.literal("turso"),
|
|
16
16
|
name: z.string(),
|
|
17
|
+
createdAt: z.string(),
|
|
17
18
|
databaseName: z.string(),
|
|
18
19
|
databaseApiToken: z.string(),
|
|
19
20
|
databaseHostname: z.string(),
|
|
20
21
|
})
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
export type R2RuntimeService = z.infer<typeof R2RuntimeService>
|
|
24
|
+
export const R2RuntimeService = z.object({
|
|
25
|
+
type: z.literal("r2"),
|
|
26
|
+
name: z.string(),
|
|
27
|
+
createdAt: z.string(),
|
|
28
|
+
bucketName: z.string(),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export type RuntimeService = z.infer<typeof RuntimeService>
|
|
32
|
+
export const RuntimeService = z.union([TursoRuntimeService, R2RuntimeService])
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { LuvaEnv } from "./envSchema"
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export * from "./envSchema"
|
|
4
|
+
export * from "./manifestSchema"
|
|
5
|
+
|
|
6
|
+
export function parseEnv(env: Record<string, unknown> | string) {
|
|
7
|
+
if (typeof env === "string") {
|
|
8
|
+
env = JSON.parse(env)
|
|
9
|
+
}
|
|
4
10
|
const luvabaseEnv = LuvaEnv.parse(env)
|
|
5
11
|
return luvabaseEnv
|
|
6
12
|
}
|
|
13
|
+
|
|
14
|
+
export function getAdminUrl(env: Record<string, unknown> | string) {
|
|
15
|
+
const luvaEnv = parseEnv(env)
|
|
16
|
+
return `https://luvabase.com/dash/pods/${luvaEnv.podId}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function parseRequest(request: Request) {
|
|
20
|
+
return {
|
|
21
|
+
user: {
|
|
22
|
+
id: request.headers.get("x-luva-user-id")!,
|
|
23
|
+
name: request.headers.get("x-luva-user-name")!,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/manifestSchema.ts
CHANGED
|
@@ -58,8 +58,9 @@ export const AppManifest = z.lazy(() =>
|
|
|
58
58
|
services: z
|
|
59
59
|
.array(
|
|
60
60
|
z.object({
|
|
61
|
-
type: z.enum(["turso", "
|
|
61
|
+
type: z.enum(["turso", "durable-object", "r2"]),
|
|
62
62
|
name: z.string(),
|
|
63
|
+
metadata: z.record(z.string(), z.any()).optional(),
|
|
63
64
|
}),
|
|
64
65
|
)
|
|
65
66
|
.optional(),
|