@luvabase/sdk 0.0.22 → 0.0.24
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 +1 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -32
package/dist/index.d.ts
CHANGED
|
@@ -132,10 +132,6 @@ type Pod = {
|
|
|
132
132
|
id: string;
|
|
133
133
|
name: string;
|
|
134
134
|
};
|
|
135
|
-
type Session = {
|
|
136
|
-
isAuthenticated: boolean;
|
|
137
|
-
member: Member | null;
|
|
138
|
-
};
|
|
139
135
|
declare function getLuvaEnv(): {
|
|
140
136
|
podId: string;
|
|
141
137
|
installedAt: string;
|
|
@@ -161,10 +157,8 @@ declare function getLuvaEnv(): {
|
|
|
161
157
|
}>;
|
|
162
158
|
};
|
|
163
159
|
declare function getAdminUrl(): string;
|
|
164
|
-
declare function getSession(request: Request): Promise<Session>;
|
|
165
|
-
declare function getSessionInfo(request: Request): Promise<Session>;
|
|
166
160
|
declare function getMembers(request: Request): Promise<Member[]>;
|
|
167
161
|
declare function getOtherPods(request: Request): Promise<Pod[]>;
|
|
168
162
|
//#endregion
|
|
169
|
-
export { AppManifest, LuvaEnv, Member, OpenRouterRuntimeService, Pod, R2RuntimeService, RelatedApp, RuntimeService,
|
|
163
|
+
export { AppManifest, LuvaEnv, Member, OpenRouterRuntimeService, Pod, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods };
|
|
170
164
|
//# sourceMappingURL=index.d.ts.map
|
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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AE,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,GAAA;EACV,EAAA;EACA,IAAA;AAAA;AAAA,iBAGc,UAAA,CAAA;;;;YAAU,MAAA;;;;;;;;;;;;;;;;;;;;iBAYV,WAAA,CAAA;AAAA,iBAcM,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
|
@@ -78,21 +78,10 @@ function getAdminUrl() {
|
|
|
78
78
|
return `https://luvabase.com/dash/pods/${getLuvaEnv().podId}`;
|
|
79
79
|
}
|
|
80
80
|
function getLuvabaseUrl(request, pathname) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
if (forwardedProto) url.protocol = `${forwardedProto}:`;
|
|
86
|
-
const urlString = new URL(pathname, url).toString();
|
|
87
|
-
console.log("Using Luvabase URL", urlString);
|
|
88
|
-
return urlString;
|
|
89
|
-
}
|
|
90
|
-
async function getSession(request) {
|
|
91
|
-
const headers = new Headers(request.headers);
|
|
92
|
-
return fetch(getLuvabaseUrl(request, "/luvabase/session"), { headers }).then((res) => res.json());
|
|
93
|
-
}
|
|
94
|
-
async function getSessionInfo(request) {
|
|
95
|
-
return getSession(request);
|
|
81
|
+
const podUrl = request.headers.get("x-luvabase-pod-url");
|
|
82
|
+
if (!podUrl) throw new Error("x-luvabase-pod-url header is not set");
|
|
83
|
+
const url = new URL(podUrl);
|
|
84
|
+
return new URL(pathname, url).toString();
|
|
96
85
|
}
|
|
97
86
|
async function getMembers(request) {
|
|
98
87
|
const headers = new Headers(request.headers);
|
|
@@ -103,6 +92,6 @@ async function getOtherPods(request) {
|
|
|
103
92
|
return fetch(getLuvabaseUrl(request, "/luvabase/pods"), { headers }).then((res) => res.json());
|
|
104
93
|
}
|
|
105
94
|
//#endregion
|
|
106
|
-
export { AppManifest, LuvaEnv, OpenRouterRuntimeService, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods
|
|
95
|
+
export { AppManifest, LuvaEnv, OpenRouterRuntimeService, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods };
|
|
107
96
|
|
|
108
97
|
//# sourceMappingURL=index.js.map
|
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
|
|
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 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 const podUrl = request.headers.get(\"x-luvabase-pod-url\")\n if (!podUrl) {\n throw new Error(\"x-luvabase-pod-url header is not set\")\n }\n const url = new URL(podUrl)\n return new URL(pathname, url).toString()\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;CAC1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AAM,QAAQ,IAAI,MAAM,CAAC,CACzB,MAAM,SAAS,KAAK,QAAQ;;AAGjC,eAAsB,aAAa,SAAkC;CACnE,MAAM,UAAU,IAAI,QAAQ,QAAQ,QAAQ;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
|
@@ -16,11 +16,6 @@ export type Pod = {
|
|
|
16
16
|
name: string
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export type Session = {
|
|
20
|
-
isAuthenticated: boolean
|
|
21
|
-
member: Member | null
|
|
22
|
-
}
|
|
23
|
-
|
|
24
19
|
export function getLuvaEnv() {
|
|
25
20
|
let env = process.env.luvaEnv
|
|
26
21
|
if (!env) {
|
|
@@ -39,34 +34,12 @@ export function getAdminUrl(): string {
|
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
function getLuvabaseUrl(request: Request, pathname: string): string {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (forwardedHost) {
|
|
47
|
-
url.host = forwardedHost
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (forwardedProto) {
|
|
51
|
-
url.protocol = `${forwardedProto}:`
|
|
37
|
+
const podUrl = request.headers.get("x-luvabase-pod-url")
|
|
38
|
+
if (!podUrl) {
|
|
39
|
+
throw new Error("x-luvabase-pod-url header is not set")
|
|
52
40
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log("Using Luvabase URL", urlString)
|
|
57
|
-
|
|
58
|
-
return urlString
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function getSession(request: Request): Promise<Session> {
|
|
62
|
-
const headers = new Headers(request.headers)
|
|
63
|
-
return fetch(getLuvabaseUrl(request, "/luvabase/session"), { headers }).then(
|
|
64
|
-
(res) => res.json(),
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function getSessionInfo(request: Request): Promise<Session> {
|
|
69
|
-
return getSession(request)
|
|
41
|
+
const url = new URL(podUrl)
|
|
42
|
+
return new URL(pathname, url).toString()
|
|
70
43
|
}
|
|
71
44
|
|
|
72
45
|
export async function getMembers(request: Request): Promise<Member[]> {
|