create-oke 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/package.json +36 -0
- package/src/cli.test.ts +110 -0
- package/src/cli.ts +156 -0
- package/src/index.ts +8 -0
- package/src/scaffold.ts +160 -0
- package/src/sync-templates.ts +65 -0
- package/src/templates.ts +85 -0
- package/src/transform.ts +124 -0
- package/templates/linkly/oke.config.ts +10 -0
- package/templates/linkly/package.json +15 -0
- package/templates/linkly/src/app.ts +21 -0
- package/templates/linkly/src/core.ts +4 -0
- package/templates/linkly/src/flows/analytics/index.ts +24 -0
- package/templates/linkly/src/flows/links/index.ts +59 -0
- package/templates/linkly/src/flows/links/shapes.ts +22 -0
- package/templates/linkly/src/flows/links/signals.ts +13 -0
- package/templates/linkly/src/gates.ts +8 -0
- package/templates/linkly/src/schema.ts +17 -0
- package/templates/linkly/tests/linkly.test.ts +19 -0
- package/templates/notes/oke.config.ts +7 -0
- package/templates/notes/package.json +16 -0
- package/templates/notes/src/app.ts +13 -0
- package/templates/notes/src/core.ts +4 -0
- package/templates/notes/src/flows/notes/index.ts +44 -0
- package/templates/notes/src/schema.ts +9 -0
- package/templates/notes/tests/notes.test.ts +10 -0
- package/templates/provisions/oke.config.ts +17 -0
- package/templates/provisions/package.json +15 -0
- package/templates/provisions/src/app.ts +60 -0
- package/templates/provisions/src/channels.ts +14 -0
- package/templates/provisions/src/core.ts +4 -0
- package/templates/provisions/src/flows/notifications/index.ts +19 -0
- package/templates/provisions/src/flows/orders/index.ts +70 -0
- package/templates/provisions/src/flows/orders/shapes.ts +21 -0
- package/templates/provisions/src/flows/orders/signals.ts +19 -0
- package/templates/provisions/src/flows/payments/index.ts +37 -0
- package/templates/provisions/src/flows/payments/shapes.ts +3 -0
- package/templates/provisions/src/flows/payments/stripe.ts +18 -0
- package/templates/provisions/src/gates.ts +4 -0
- package/templates/provisions/src/locales/ar.ts +1 -0
- package/templates/provisions/src/locales/en.ts +1 -0
- package/templates/provisions/src/plugins/audit-schema.ts +2 -0
- package/templates/provisions/src/plugins/audit.ts +14 -0
- package/templates/provisions/src/schema.ts +16 -0
- package/templates/provisions/src/vault.ts +16 -0
- package/templates/provisions/tests/orders.test.ts +18 -0
- package/templates/skyport/evals/triage.jsonl +1 -0
- package/templates/skyport/oke.config.ts +44 -0
- package/templates/skyport/oke.images.lock +4 -0
- package/templates/skyport/package.json +16 -0
- package/templates/skyport/src/ai.ts +25 -0
- package/templates/skyport/src/app.ts +57 -0
- package/templates/skyport/src/channels.ts +12 -0
- package/templates/skyport/src/core.ts +4 -0
- package/templates/skyport/src/flows/bookings/index.ts +50 -0
- package/templates/skyport/src/flows/bookings/shapes.ts +6 -0
- package/templates/skyport/src/flows/bookings/signals.ts +9 -0
- package/templates/skyport/src/flows/notifications/index.ts +16 -0
- package/templates/skyport/src/flows/payments/index.ts +14 -0
- package/templates/skyport/src/flows/payments/shapes.ts +5 -0
- package/templates/skyport/src/flows/support/index.ts +38 -0
- package/templates/skyport/src/flows/users/elements.ts +2 -0
- package/templates/skyport/src/flows/users/index.ts +12 -0
- package/templates/skyport/src/flows/users/shapes.ts +6 -0
- package/templates/skyport/src/gates.ts +10 -0
- package/templates/skyport/src/journeys.ts +9 -0
- package/templates/skyport/src/locales/ar.ts +4 -0
- package/templates/skyport/src/locales/en.ts +4 -0
- package/templates/skyport/src/plugins/audit-schema.ts +7 -0
- package/templates/skyport/src/plugins/audit.ts +14 -0
- package/templates/skyport/src/plugins/panel.tsx +4 -0
- package/templates/skyport/src/schema.ts +22 -0
- package/templates/skyport/src/vault.ts +24 -0
- package/templates/skyport/tests/support.test.ts +16 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { plugin, store } from "okengine";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const audit = plugin("audit", { version: "1.0.0" })
|
|
5
|
+
.config(z.object({ retain: z.string().default("2y") }))
|
|
6
|
+
.element(store.sql("audit", { schema: () => import("./audit-schema") }))
|
|
7
|
+
.needs("store.kv")
|
|
8
|
+
.decorate("audit", { enabled: true })
|
|
9
|
+
.hook("afterHandle", async (ctx, fx) => {
|
|
10
|
+
if (ctx.trigger.meta?.audit) await fx.store("audit").log(ctx);
|
|
11
|
+
})
|
|
12
|
+
.errors({ AuditWriteFailed: z.object({ reason: z.string() }) })
|
|
13
|
+
.consolePanel({ id: "audit", title: "Audit Trail", entry: "./panel.tsx" })
|
|
14
|
+
.cli("audit:export", ({ fx }) => fx.store("audit").exportCsv());
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
2
|
+
import { id } from "okengine/store";
|
|
3
|
+
|
|
4
|
+
export const bookings = sqliteTable("bookings", {
|
|
5
|
+
id: text("id").primaryKey().$defaultFn(id),
|
|
6
|
+
userId: text("user_id").notNull(),
|
|
7
|
+
flightId: text("flight_id").notNull(),
|
|
8
|
+
seats: integer("seats").notNull(),
|
|
9
|
+
status: text("status").notNull().default("pending"),
|
|
10
|
+
createdAt: integer("created_at").notNull(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const flights = sqliteTable("flights", {
|
|
14
|
+
id: text("id").primaryKey(),
|
|
15
|
+
seatsAvailable: integer("seats_available").notNull(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const tickets = sqliteTable("tickets", {
|
|
19
|
+
id: text("id").primaryKey(), subject: text("subject").notNull(),
|
|
20
|
+
body: text("body").notNull(), urgency: text("urgency"), team: text("team"),
|
|
21
|
+
summary: text("summary"),
|
|
22
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { vault } from "okengine";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const dbUrl = vault.secret("DATABASE_URL", {
|
|
5
|
+
schema: z.string().url(),
|
|
6
|
+
dev: vault.fromStack("store.sql"),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const dbReplica1 = vault.secret("DATABASE_REPLICA_1", {
|
|
10
|
+
schema: z.string().url(),
|
|
11
|
+
dev: "postgres://localhost/oke-replica",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const anthropicKey = vault.secret("ANTHROPIC_KEY", {
|
|
15
|
+
schema: z.string().min(1),
|
|
16
|
+
dev: "sk-ant-test",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const stripeKey = vault.secret("STRIPE_KEY", {
|
|
20
|
+
schema: z.string().startsWith("sk_"),
|
|
21
|
+
description: "Payments gateway key",
|
|
22
|
+
rotate: "90d",
|
|
23
|
+
dev: "sk_test_local",
|
|
24
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { test, expect } from "bun:test";
|
|
2
|
+
import { createTestApp } from "okengine/test";
|
|
3
|
+
import { app } from "../src/app";
|
|
4
|
+
import { triage } from "../src/ai";
|
|
5
|
+
|
|
6
|
+
test("AI triage is mockable and cost-bounded", async () => {
|
|
7
|
+
const t = await createTestApp(app);
|
|
8
|
+
t.ai.mock(triage, { urgency: "high", team: "ops", summary: "seat dispute" });
|
|
9
|
+
|
|
10
|
+
const u = await t.auth.loginAs({});
|
|
11
|
+
const { data } = await t.api.support.createTicket({ subject: "…", body: "…" }, { as: u });
|
|
12
|
+
|
|
13
|
+
expect(data!.urgency).toBe("high");
|
|
14
|
+
expect(t.ai.cost()).toBeLessThan(0.02); // budgets are assertable
|
|
15
|
+
await t.close();
|
|
16
|
+
});
|