@luvabase/sdk 0.0.18 → 0.0.19
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 +6 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +12 -28
package/dist/index.d.ts
CHANGED
|
@@ -123,6 +123,8 @@ declare const RelatedApp: z.ZodObject<{
|
|
|
123
123
|
//#region src/index.d.ts
|
|
124
124
|
type Member = {
|
|
125
125
|
id: string;
|
|
126
|
+
type: "user" | "agent";
|
|
127
|
+
role: string;
|
|
126
128
|
name: string;
|
|
127
129
|
imageUrl: string | null;
|
|
128
130
|
};
|
|
@@ -131,15 +133,9 @@ type Pod = {
|
|
|
131
133
|
name: string;
|
|
132
134
|
};
|
|
133
135
|
type Session = {
|
|
134
|
-
|
|
136
|
+
isAuthenticated: boolean;
|
|
137
|
+
member: Member | null;
|
|
135
138
|
};
|
|
136
|
-
type FullEnvironment = {
|
|
137
|
-
luvaEnv: LuvaEnv;
|
|
138
|
-
session: Session;
|
|
139
|
-
members: Member[];
|
|
140
|
-
pods: Pod[];
|
|
141
|
-
};
|
|
142
|
-
declare function overrideEnvironment(env: FullEnvironment): void;
|
|
143
139
|
declare function getLuvaEnv(): {
|
|
144
140
|
podId: string;
|
|
145
141
|
installedAt: string;
|
|
@@ -165,9 +161,10 @@ declare function getLuvaEnv(): {
|
|
|
165
161
|
}>;
|
|
166
162
|
};
|
|
167
163
|
declare function getAdminUrl(): string;
|
|
164
|
+
declare function getSession(request: Request): Promise<Session>;
|
|
168
165
|
declare function getSessionInfo(request: Request): Promise<Session>;
|
|
169
166
|
declare function getMembers(request: Request): Promise<Member[]>;
|
|
170
167
|
declare function getOtherPods(request: Request): Promise<Pod[]>;
|
|
171
168
|
//#endregion
|
|
172
|
-
export { AppManifest, LuvaEnv, Member, OpenRouterRuntimeService, Pod, R2RuntimeService, RelatedApp, RuntimeService, Session, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods,
|
|
169
|
+
export { AppManifest, LuvaEnv, Member, OpenRouterRuntimeService, Pod, R2RuntimeService, RelatedApp, RuntimeService, Session, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods, getSession, getSessionInfo };
|
|
173
170
|
//# 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,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,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,CAAA;AAAA,iBAKM,UAAA,CAAW,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,OAAA;AAAA,iBAKtC,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
|
@@ -68,12 +68,7 @@ const RelatedApp = z.object({
|
|
|
68
68
|
});
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/index.ts
|
|
71
|
-
let overriddenEnv;
|
|
72
|
-
function overrideEnvironment(env) {
|
|
73
|
-
overriddenEnv = env;
|
|
74
|
-
}
|
|
75
71
|
function getLuvaEnv() {
|
|
76
|
-
if (overriddenEnv) return overriddenEnv.luvaEnv;
|
|
77
72
|
let env = process.env.luvaEnv;
|
|
78
73
|
if (!env) throw new Error("Luva env is not available");
|
|
79
74
|
if (typeof process.env === "string") env = JSON.parse(env);
|
|
@@ -82,22 +77,22 @@ function getLuvaEnv() {
|
|
|
82
77
|
function getAdminUrl() {
|
|
83
78
|
return `https://luvabase.com/dash/pods/${getLuvaEnv().podId}`;
|
|
84
79
|
}
|
|
85
|
-
async function
|
|
86
|
-
if (overriddenEnv) return overriddenEnv.session;
|
|
80
|
+
async function getSession(request) {
|
|
87
81
|
const headers = new Headers(request.headers);
|
|
88
82
|
return fetch("/luvabase/session", { headers }).then((res) => res.json());
|
|
89
83
|
}
|
|
84
|
+
async function getSessionInfo(request) {
|
|
85
|
+
return getSession(request);
|
|
86
|
+
}
|
|
90
87
|
async function getMembers(request) {
|
|
91
|
-
if (overriddenEnv) return overriddenEnv.members;
|
|
92
88
|
const headers = new Headers(request.headers);
|
|
93
|
-
return fetch("/luvabase/members", { headers }).then((res) => res.json());
|
|
89
|
+
return fetch("/luvabase/members", { headers }).then((res) => res.json()).then((data) => data.members);
|
|
94
90
|
}
|
|
95
91
|
async function getOtherPods(request) {
|
|
96
|
-
if (overriddenEnv) return overriddenEnv.pods;
|
|
97
92
|
const headers = new Headers(request.headers);
|
|
98
93
|
return fetch("/luvabase/pods", { headers }).then((res) => res.json());
|
|
99
94
|
}
|
|
100
95
|
//#endregion
|
|
101
|
-
export { AppManifest, LuvaEnv, OpenRouterRuntimeService, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods,
|
|
96
|
+
export { AppManifest, LuvaEnv, OpenRouterRuntimeService, R2RuntimeService, RelatedApp, RuntimeService, TursoRuntimeService, getAdminUrl, getLuvaEnv, getMembers, getOtherPods, getSession, getSessionInfo };
|
|
102
97
|
|
|
103
98
|
//# 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 name: string\n imageUrl: string | null\n}\n\nexport type Pod = {\n id: string\n name: string\n}\n\nexport type Session = {\n
|
|
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 process.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\nexport async function getSession(request: Request): Promise<Session> {\n const headers = new Headers(request.headers)\n return fetch(\"/luvabase/session\", { headers }).then((res) => res.json())\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(\"/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(\"/luvabase/pods\", { headers }).then((res) => res.json())\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,aAAa;CAC7B,MAAM,EAAE,QAAQ;CAChB,WAAW,EAAE,QAAQ;CACrB,QAAQ,EAAE,QAAQ;CAClB,aAAa,EAAE,QAAQ;CACxB,CAAC;AAGF,MAAa,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role: string
|
|
8
10
|
name: string
|
|
9
11
|
imageUrl: string | null
|
|
10
12
|
}
|
|
@@ -15,26 +17,11 @@ export type Pod = {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export type Session = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type FullEnvironment = {
|
|
22
|
-
luvaEnv: LuvaEnv
|
|
23
|
-
session: Session
|
|
24
|
-
members: Member[]
|
|
25
|
-
pods: Pod[]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let overriddenEnv: FullEnvironment | undefined
|
|
29
|
-
|
|
30
|
-
export function overrideEnvironment(env: FullEnvironment) {
|
|
31
|
-
overriddenEnv = env
|
|
20
|
+
isAuthenticated: boolean
|
|
21
|
+
member: Member | null
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
export function getLuvaEnv() {
|
|
35
|
-
if (overriddenEnv) {
|
|
36
|
-
return overriddenEnv.luvaEnv
|
|
37
|
-
}
|
|
38
25
|
let env = process.env.luvaEnv
|
|
39
26
|
if (!env) {
|
|
40
27
|
throw new Error("Luva env is not available")
|
|
@@ -51,26 +38,23 @@ export function getAdminUrl(): string {
|
|
|
51
38
|
return `https://luvabase.com/dash/pods/${luvaEnv.podId}`
|
|
52
39
|
}
|
|
53
40
|
|
|
54
|
-
export async function
|
|
55
|
-
if (overriddenEnv) {
|
|
56
|
-
return overriddenEnv.session
|
|
57
|
-
}
|
|
41
|
+
export async function getSession(request: Request): Promise<Session> {
|
|
58
42
|
const headers = new Headers(request.headers)
|
|
59
43
|
return fetch("/luvabase/session", { headers }).then((res) => res.json())
|
|
60
44
|
}
|
|
61
45
|
|
|
46
|
+
export async function getSessionInfo(request: Request): Promise<Session> {
|
|
47
|
+
return getSession(request)
|
|
48
|
+
}
|
|
49
|
+
|
|
62
50
|
export async function getMembers(request: Request): Promise<Member[]> {
|
|
63
|
-
if (overriddenEnv) {
|
|
64
|
-
return overriddenEnv.members
|
|
65
|
-
}
|
|
66
51
|
const headers = new Headers(request.headers)
|
|
67
|
-
return fetch("/luvabase/members", { headers })
|
|
52
|
+
return fetch("/luvabase/members", { headers })
|
|
53
|
+
.then((res) => res.json())
|
|
54
|
+
.then((data) => data.members)
|
|
68
55
|
}
|
|
69
56
|
|
|
70
57
|
export async function getOtherPods(request: Request): Promise<Pod[]> {
|
|
71
|
-
if (overriddenEnv) {
|
|
72
|
-
return overriddenEnv.pods
|
|
73
|
-
}
|
|
74
58
|
const headers = new Headers(request.headers)
|
|
75
59
|
return fetch("/luvabase/pods", { headers }).then((res) => res.json())
|
|
76
60
|
}
|