@luvabase/sdk 0.0.20 → 0.0.21
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.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +12 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,wBAAA,GAA2B,CAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,cACzC,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;;;;;KAQzB,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;;;;;;;;;;;;;;;;;;;;;KCtCf,WAAA,GAAc,CAAA,CAAE,KAAA,QAAa,WAAA;AAAA,cAC5B,WAAA,EAAW,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2EX,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;;;;KCzEX,MAAA;EACV,EAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACA,QAAA;AAAA;AAAA,KAGU,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MAAA,EAAQ,MAAA;AAAA;AAAA,iBAGM,UAAA,CAAA;;;;YAAU,MAAA;;;;;;;;;;;;;;;;;;;;iBAYV,WAAA,CAAA;AAAA,iBASM,UAAA,CAAW,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,OAAA;AAAA,iBAOtC,cAAA,CAAe,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,OAAA;AAAA,iBAI1C,UAAA,CAAW,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,MAAA;AAAA,iBAOtC,YAAA,CAAa,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,GAAA"}
|
package/dist/index.js
CHANGED
|
@@ -71,26 +71,29 @@ const RelatedApp = z.object({
|
|
|
71
71
|
function getLuvaEnv() {
|
|
72
72
|
let env = process.env.luvaEnv;
|
|
73
73
|
if (!env) throw new Error("Luva env is not available");
|
|
74
|
-
if (typeof
|
|
74
|
+
if (typeof env === "string") env = JSON.parse(env);
|
|
75
75
|
return LuvaEnv.parse(env);
|
|
76
76
|
}
|
|
77
77
|
function getAdminUrl() {
|
|
78
78
|
return `https://luvabase.com/dash/pods/${getLuvaEnv().podId}`;
|
|
79
79
|
}
|
|
80
|
+
function getLuvabaseUrl(request, pathname) {
|
|
81
|
+
return new URL(pathname, request.url).toString();
|
|
82
|
+
}
|
|
80
83
|
async function getSession(request) {
|
|
81
84
|
const headers = new Headers(request.headers);
|
|
82
|
-
return fetch("/luvabase/session", { headers }).then((res) => res.json());
|
|
85
|
+
return fetch(getLuvabaseUrl(request, "/luvabase/session"), { headers }).then((res) => res.json());
|
|
83
86
|
}
|
|
84
87
|
async function getSessionInfo(request) {
|
|
85
88
|
return getSession(request);
|
|
86
89
|
}
|
|
87
90
|
async function getMembers(request) {
|
|
88
91
|
const headers = new Headers(request.headers);
|
|
89
|
-
return fetch("/luvabase/members", { headers }).then((res) => res.json()).then((data) => data.members);
|
|
92
|
+
return fetch(getLuvabaseUrl(request, "/luvabase/members"), { headers }).then((res) => res.json()).then((data) => data.members);
|
|
90
93
|
}
|
|
91
94
|
async function getOtherPods(request) {
|
|
92
95
|
const headers = new Headers(request.headers);
|
|
93
|
-
return fetch("/luvabase/pods", { headers }).then((res) => res.json());
|
|
96
|
+
return fetch(getLuvabaseUrl(request, "/luvabase/pods"), { headers }).then((res) => res.json());
|
|
94
97
|
}
|
|
95
98
|
//#endregion
|
|
96
99
|
export { AppManifest, LuvaEnv, OpenRouterRuntimeService, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods, getSession, getSessionInfo };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 OpenRouterRuntimeService = z.infer<typeof OpenRouterRuntimeService>\nexport const OpenRouterRuntimeService = z.object({\n type: z.literal(\"openrouter\"),\n name: z.string(),\n createdAt: z.string(),\n apiKey: z.string(),\n apiKeyLabel: 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([\n TursoRuntimeService,\n OpenRouterRuntimeService,\n R2RuntimeService,\n])\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\", \"openrouter\", \"durable-object\", \"r2\"]),\n name: z.string(),\n metadata: z.record(z.string(), z.any()).optional(),\n }),\n )\n .optional(),\n hooks: z\n .array(\n z.object({\n type: z.enum([\"app.update\", \"member.update\"]),\n relativeUrl: z.string().describe(\"Relative URL to the hook handler\"),\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 type Member = {\n id: string\n type: \"user\" | \"agent\"\n role: string\n name: string\n imageUrl: string | null\n}\n\nexport type Pod = {\n id: string\n name: string\n}\n\nexport type Session = {\n isAuthenticated: boolean\n member: Member | null\n}\n\nexport function getLuvaEnv() {\n let env = process.env.luvaEnv\n if (!env) {\n throw new Error(\"Luva env is not available\")\n }\n if (typeof
|
|
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 OpenRouterRuntimeService = z.infer<typeof OpenRouterRuntimeService>\nexport const OpenRouterRuntimeService = z.object({\n type: z.literal(\"openrouter\"),\n name: z.string(),\n createdAt: z.string(),\n apiKey: z.string(),\n apiKeyLabel: 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([\n TursoRuntimeService,\n OpenRouterRuntimeService,\n R2RuntimeService,\n])\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\", \"openrouter\", \"durable-object\", \"r2\"]),\n name: z.string(),\n metadata: z.record(z.string(), z.any()).optional(),\n }),\n )\n .optional(),\n hooks: z\n .array(\n z.object({\n type: z.enum([\"app.update\", \"member.update\"]),\n relativeUrl: z.string().describe(\"Relative URL to the hook handler\"),\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 type Member = {\n id: string\n type: \"user\" | \"agent\"\n role: string\n name: string\n imageUrl: string | null\n}\n\nexport type Pod = {\n id: string\n name: string\n}\n\nexport type Session = {\n isAuthenticated: boolean\n member: Member | null\n}\n\nexport function getLuvaEnv() {\n let env = process.env.luvaEnv\n if (!env) {\n throw new Error(\"Luva env is not available\")\n }\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(): string {\n const luvaEnv = getLuvaEnv()\n return `https://luvabase.com/dash/pods/${luvaEnv.podId}`\n}\n\nfunction getLuvabaseUrl(request: Request, pathname: string): string {\n return new URL(pathname, request.url).toString()\n}\n\nexport async function getSession(request: Request): Promise<Session> {\n const headers = new Headers(request.headers)\n return fetch(getLuvabaseUrl(request, \"/luvabase/session\"), { headers }).then(\n (res) => res.json(),\n )\n}\n\nexport async function getSessionInfo(request: Request): Promise<Session> {\n return getSession(request)\n}\n\nexport async function getMembers(request: Request): Promise<Member[]> {\n const headers = new Headers(request.headers)\n return fetch(getLuvabaseUrl(request, \"/luvabase/members\"), { headers })\n .then((res) => res.json())\n .then((data) => data.members)\n}\n\nexport async function getOtherPods(request: Request): Promise<Pod[]> {\n const headers = new Headers(request.headers)\n return fetch(getLuvabaseUrl(request, \"/luvabase/pods\"), { headers }).then(\n (res) => res.json(),\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,2BAA2B,EAAE,OAAO;CAC/C,MAAM,EAAE,QAAQ,aAA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AAC5C,QAAO,MAAM,eAAe,SAAS,iBAAiB,EAAE,EAAE,SAAS,CAAC,CAAC,MAClE,QAAQ,IAAI,MAAM,CACpB"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ export function getLuvaEnv() {
|
|
|
26
26
|
if (!env) {
|
|
27
27
|
throw new Error("Luva env is not available")
|
|
28
28
|
}
|
|
29
|
-
if (typeof
|
|
29
|
+
if (typeof env === "string") {
|
|
30
30
|
env = JSON.parse(env)
|
|
31
31
|
}
|
|
32
32
|
const luvabaseEnv = LuvaEnv.parse(env)
|
|
@@ -38,9 +38,15 @@ export function getAdminUrl(): string {
|
|
|
38
38
|
return `https://luvabase.com/dash/pods/${luvaEnv.podId}`
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
function getLuvabaseUrl(request: Request, pathname: string): string {
|
|
42
|
+
return new URL(pathname, request.url).toString()
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
export async function getSession(request: Request): Promise<Session> {
|
|
42
46
|
const headers = new Headers(request.headers)
|
|
43
|
-
return fetch("/luvabase/session", { headers }).then(
|
|
47
|
+
return fetch(getLuvabaseUrl(request, "/luvabase/session"), { headers }).then(
|
|
48
|
+
(res) => res.json(),
|
|
49
|
+
)
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
export async function getSessionInfo(request: Request): Promise<Session> {
|
|
@@ -49,12 +55,14 @@ export async function getSessionInfo(request: Request): Promise<Session> {
|
|
|
49
55
|
|
|
50
56
|
export async function getMembers(request: Request): Promise<Member[]> {
|
|
51
57
|
const headers = new Headers(request.headers)
|
|
52
|
-
return fetch("/luvabase/members", { headers })
|
|
58
|
+
return fetch(getLuvabaseUrl(request, "/luvabase/members"), { headers })
|
|
53
59
|
.then((res) => res.json())
|
|
54
60
|
.then((data) => data.members)
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
export async function getOtherPods(request: Request): Promise<Pod[]> {
|
|
58
64
|
const headers = new Headers(request.headers)
|
|
59
|
-
return fetch("/luvabase/pods", { headers }).then(
|
|
65
|
+
return fetch(getLuvabaseUrl(request, "/luvabase/pods"), { headers }).then(
|
|
66
|
+
(res) => res.json(),
|
|
67
|
+
)
|
|
60
68
|
}
|