@podosoft/podokit 1.0.1 → 1.1.2
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/README.md +19 -5
- package/dist/add.d.ts +14 -1
- package/dist/add.js +42 -5
- package/dist/create.d.ts +4 -0
- package/dist/create.js +9 -0
- package/dist/deploy-compose-profile.d.ts +3 -0
- package/dist/deploy-compose-profile.js +74 -8
- package/dist/deploy-compose-render.d.ts +2 -1
- package/dist/deploy-compose-render.js +50 -5
- package/dist/deploy-compose.js +2 -1
- package/dist/deploy-profile.js +18 -8
- package/dist/deploy-render.js +5 -5
- package/dist/deploy.js +157 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +41 -0
- package/dist/lib.d.ts +2 -0
- package/dist/lib.js +8 -2
- package/dist/lockfile.d.ts +6 -1
- package/dist/lockfile.js +22 -4
- package/dist/provider.d.ts +24 -0
- package/dist/provider.js +142 -0
- package/dist/remove.js +6 -3
- package/dist/templates/fullstack/AGENTS.md +5 -4
- package/dist/templates/fullstack/README.md +10 -3
- package/dist/templates/fullstack/apps/api/package.json +3 -2
- package/dist/templates/fullstack/apps/api/src/config/env.validation.ts +1 -0
- package/dist/templates/fullstack/apps/api/src/config/providers.ts +9 -0
- package/dist/templates/fullstack/apps/api/src/core/services.ts +7 -2
- package/dist/templates/fullstack/apps/api/src/database/data-source.ts +30 -8
- package/dist/templates/fullstack/apps/api/src/database/database.spec.ts +58 -0
- package/dist/templates/fullstack/apps/api/src/database/database.ts +58 -2
- package/dist/templates/fullstack/apps/api/src/database/migrate.ts +24 -2
- package/dist/templates/fullstack/apps/api/src/database/sqlite-migrator.spec.ts +50 -0
- package/dist/templates/fullstack/apps/api/src/database/sqlite-migrator.ts +134 -0
- package/dist/templates/fullstack/compose.dev.yaml +2 -2
- package/dist/templates/fullstack/dot-agents/skills/podokit-deploy/references/profile.md +10 -3
- package/dist/templates/fullstack/dot-env.example +2 -0
- package/dist/templates/modules/admin-dashboard/files/apps/api/src/admin.module.ts +2 -2
- package/dist/templates/modules/admin-dashboard/files/apps/api/src/profile-image/profile-image.service.spec.ts +10 -4
- package/dist/templates/modules/admin-dashboard/files/apps/api/src/profile-image/profile-image.service.ts +10 -4
- package/dist/templates/modules/admin-dashboard/files/apps/api/src/site-settings/site-settings.service.ts +10 -4
- package/dist/templates/modules/admin-dashboard/files/apps/web/src/lib/components/account-page.svelte +1 -1
- package/dist/templates/modules/admin-dashboard/files/apps/web/src/routes/setup-2fa/+page.svelte +1 -1
- package/dist/templates/modules/admin-dashboard/files/tests/ui/oidc.ui.spec.ts +10 -2
- package/dist/templates/modules/admin-dashboard/module.manifest.json +3 -5
- package/dist/templates/modules/audit-log/files/apps/api/src/audit/audit-enabled.ts +2 -5
- package/dist/templates/modules/audit-log/files/apps/api/src/audit/audit.migration.spec.ts +33 -0
- package/dist/templates/modules/audit-log/files/apps/api/src/audit/audit.service.spec.ts +13 -0
- package/dist/templates/modules/audit-log/files/apps/api/src/audit/audit.service.ts +17 -8
- package/dist/templates/modules/audit-log/files/apps/api/src/migrations/1720300000000-InitAuditLogs.ts +5 -4
- package/dist/templates/modules/audit-log/module.manifest.json +1 -1
- package/dist/templates/modules/auth/files/apps/api/src/auth/account-issuer-migration.spec.ts +170 -0
- package/dist/templates/modules/auth/files/apps/api/src/auth/account-issuer-migration.ts +260 -0
- package/dist/templates/modules/auth/files/apps/api/src/auth/auth-config-store.ts +2 -2
- package/dist/templates/modules/auth/files/apps/api/src/auth/auth.module.ts +4 -0
- package/dist/templates/modules/auth/files/apps/api/src/auth/auth.service.ts +2 -2
- package/dist/templates/modules/auth/files/apps/api/src/auth/auth.ts +4 -4
- package/dist/templates/modules/auth/files/apps/api/src/auth/db.ts +55 -10
- package/dist/templates/modules/auth/files/apps/api/src/auth/feature-gate.ts +10 -14
- package/dist/templates/modules/auth/files/apps/api/src/migrate.ts +22 -6
- package/dist/templates/modules/auth/files/apps/api/src/migrations/1720400000000-InitAppSettings.ts +2 -1
- package/dist/templates/modules/auth/files/apps/api/src/migrations/1720500000000-InitAuthConfig.ts +4 -3
- package/dist/templates/modules/auth/files/apps/api/src/settings/app-settings.migration.spec.ts +15 -4
- package/dist/templates/modules/auth/files/apps/api/src/settings/auth-config.migration.spec.ts +30 -0
- package/dist/templates/modules/auth/module.manifest.json +1 -1
- package/dist/templates/modules/bullmq/files/apps/api/src/jobs/bullmq-job.queue.spec.ts +10 -0
- package/dist/templates/modules/bullmq/files/apps/api/src/jobs/bullmq-job.queue.ts +107 -0
- package/dist/templates/modules/bullmq/files/apps/api/src/jobs/jobs.module.ts +12 -11
- package/dist/templates/modules/bullmq/files/apps/api/src/main-worker.ts +5 -0
- package/dist/templates/modules/bullmq/module.manifest.json +7 -0
- package/dist/templates/modules/cache-memory/files/apps/api/src/cache-memory/cache-memory.module.spec.ts +16 -0
- package/dist/templates/modules/cache-memory/files/apps/api/src/cache-memory/cache-memory.module.ts +12 -0
- package/dist/templates/modules/cache-memory/module.manifest.json +30 -0
- package/dist/templates/modules/events-memory/files/apps/api/src/events-provider-memory/events-memory.module.ts +14 -0
- package/dist/templates/modules/events-memory/module.manifest.json +30 -0
- package/dist/templates/modules/events-redis/files/apps/api/src/events-provider-redis/events-redis.module.ts +16 -0
- package/dist/templates/modules/events-redis/files/apps/api/src/events-provider-redis/redis-event.bus.ts +75 -0
- package/dist/templates/modules/events-redis/module.manifest.json +32 -0
- package/dist/templates/modules/file-upload/files/apps/api/src/files/files.module.ts +9 -5
- package/dist/templates/modules/file-upload/files/tests/api/files.api.spec.ts +1 -1
- package/dist/templates/modules/file-upload/module.manifest.json +4 -3
- package/dist/templates/modules/job-progress/files/apps/api/src/progress/job-progress.module.ts +36 -14
- package/dist/templates/modules/job-progress/files/apps/api/src/progress/progress.bridge.spec.ts +9 -32
- package/dist/templates/modules/job-progress/files/apps/api/src/progress/progress.processor.ts +16 -11
- package/dist/templates/modules/job-progress/module.manifest.json +7 -8
- package/dist/templates/modules/jobs-local/files/apps/api/src/jobs-local/jobs-local.module.ts +42 -0
- package/dist/templates/modules/jobs-local/files/apps/api/src/jobs-local/local-job.queue.spec.ts +45 -0
- package/dist/templates/modules/jobs-local/files/apps/api/src/jobs-local/local-job.queue.ts +212 -0
- package/dist/templates/modules/jobs-local/module.manifest.json +34 -0
- package/dist/templates/modules/mailer/files/apps/api/src/mail/mailer.ts +7 -3
- package/dist/templates/modules/mailer/module.manifest.json +2 -4
- package/dist/templates/modules/object-storage-local/files/apps/api/src/storage-local/storage-local.module.spec.ts +25 -0
- package/dist/templates/modules/object-storage-local/files/apps/api/src/storage-local/storage-local.module.ts +60 -0
- package/dist/templates/modules/object-storage-local/module.manifest.json +34 -0
- package/dist/templates/modules/object-storage-s3/files/apps/api/src/storage/s3-object.store.ts +50 -0
- package/dist/templates/modules/object-storage-s3/files/apps/api/src/storage/storage.module.ts +8 -0
- package/dist/templates/modules/object-storage-s3/files/infra/docker/minio.compose.yml +4 -4
- package/dist/templates/modules/object-storage-s3/files/tests/api/storage.api.spec.ts +20 -12
- package/dist/templates/modules/object-storage-s3/module.manifest.json +4 -2
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.module.spec.ts +14 -1
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.module.ts +18 -37
- package/dist/templates/modules/rate-limit/files/tests/api/rate-limit.api.spec.ts +12 -0
- package/dist/templates/modules/rate-limit/module.manifest.json +8 -6
- package/dist/templates/modules/redis/files/apps/api/src/redis/redis-cache.store.ts +82 -0
- package/dist/templates/modules/redis/files/apps/api/src/redis/redis.module.ts +6 -0
- package/dist/templates/modules/redis/module.manifest.json +2 -0
- package/dist/templates/modules/sse/files/apps/api/src/events/events.module.ts +5 -6
- package/dist/templates/modules/sse/files/apps/api/src/events/events.service.spec.ts +4 -4
- package/dist/templates/modules/sse/files/apps/api/src/events/events.service.ts +6 -5
- package/dist/templates/modules/sse/module.manifest.json +4 -6
- package/dist/templates/todo/AGENTS.md +1 -1
- package/dist/templates/todo/README.md +8 -3
- package/dist/toolchain.d.ts +1 -0
- package/dist/toolchain.js +4 -0
- package/package.json +2 -1
- package/dist/templates/modules/job-progress/files/apps/api/src/progress/progress.bridge.ts +0 -32
- package/dist/templates/modules/mailer/files/apps/api/src/mail/db.ts +0 -13
- package/dist/templates/modules/sse/files/apps/api/src/events/events.transport.ts +0 -111
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { RedisClient } from "bun";
|
|
2
|
-
import { redisConnectionUrl } from "../config/redis.connection";
|
|
3
|
-
|
|
4
|
-
export type EventHandler = (data: unknown) => void;
|
|
5
|
-
|
|
6
|
-
export interface EventsTransport {
|
|
7
|
-
connect(handler: EventHandler): Promise<void>;
|
|
8
|
-
publish(data: unknown): Promise<void>;
|
|
9
|
-
ready(): Promise<void>;
|
|
10
|
-
close(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function maxEventBytes(env: NodeJS.ProcessEnv): number {
|
|
14
|
-
const value = Number(env.SSE_MAX_EVENT_BYTES ?? 65_536);
|
|
15
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
16
|
-
throw new Error("SSE_MAX_EVENT_BYTES must be a positive integer");
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function encodedEvent(data: unknown, maximumBytes: number): string {
|
|
22
|
-
const message = JSON.stringify(data);
|
|
23
|
-
if (message === undefined) throw new Error("Event data must be JSON serializable");
|
|
24
|
-
if (Buffer.byteLength(message, "utf8") > maximumBytes) {
|
|
25
|
-
throw new Error("Event data exceeds SSE_MAX_EVENT_BYTES");
|
|
26
|
-
}
|
|
27
|
-
return message;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class MemoryEventsTransport implements EventsTransport {
|
|
31
|
-
private handler?: EventHandler;
|
|
32
|
-
private readonly maximumBytes: number;
|
|
33
|
-
|
|
34
|
-
constructor(env: NodeJS.ProcessEnv = process.env) {
|
|
35
|
-
this.maximumBytes = maxEventBytes(env);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
connect(handler: EventHandler): Promise<void> {
|
|
39
|
-
this.handler = handler;
|
|
40
|
-
return Promise.resolve();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async publish(data: unknown): Promise<void> {
|
|
44
|
-
this.handler?.(JSON.parse(encodedEvent(data, this.maximumBytes)) as unknown);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
ready(): Promise<void> {
|
|
48
|
-
return Promise.resolve();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
close(): Promise<void> {
|
|
52
|
-
this.handler = undefined;
|
|
53
|
-
return Promise.resolve();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export class RedisEventsTransport implements EventsTransport {
|
|
58
|
-
private readonly publisher: RedisClient;
|
|
59
|
-
private readonly subscriber: RedisClient;
|
|
60
|
-
private readonly channel: string;
|
|
61
|
-
private readonly maximumBytes: number;
|
|
62
|
-
private handler?: EventHandler;
|
|
63
|
-
private listener?: (message: string) => void;
|
|
64
|
-
|
|
65
|
-
constructor(env: NodeJS.ProcessEnv = process.env) {
|
|
66
|
-
const url = redisConnectionUrl(env);
|
|
67
|
-
this.publisher = new RedisClient(url, { connectionTimeout: 5_000 });
|
|
68
|
-
this.subscriber = new RedisClient(url, { connectionTimeout: 5_000 });
|
|
69
|
-
this.channel = env.SSE_REDIS_CHANNEL?.trim() || "podokit:events";
|
|
70
|
-
this.maximumBytes = maxEventBytes(env);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async connect(handler: EventHandler): Promise<void> {
|
|
74
|
-
this.handler = handler;
|
|
75
|
-
this.listener = (message: string): void => {
|
|
76
|
-
if (Buffer.byteLength(message, "utf8") > this.maximumBytes) return;
|
|
77
|
-
try {
|
|
78
|
-
this.handler?.(JSON.parse(message) as unknown);
|
|
79
|
-
} catch {
|
|
80
|
-
process.stderr.write("Discard malformed event transport message\n");
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
await Promise.all([this.publisher.connect(), this.subscriber.connect()]);
|
|
84
|
-
await this.subscriber.subscribe(this.channel, this.listener);
|
|
85
|
-
await this.ready();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async publish(data: unknown): Promise<void> {
|
|
89
|
-
await this.publisher.publish(this.channel, encodedEvent(data, this.maximumBytes));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async ready(): Promise<void> {
|
|
93
|
-
if (!this.subscriber.connected) throw new Error("Redis event subscriber is not ready");
|
|
94
|
-
await this.publisher.ping();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async close(): Promise<void> {
|
|
98
|
-
if (this.listener) await this.subscriber.unsubscribe(this.channel, this.listener);
|
|
99
|
-
this.handler = undefined;
|
|
100
|
-
this.listener = undefined;
|
|
101
|
-
this.publisher.close();
|
|
102
|
-
this.subscriber.close();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function createEventsTransport(env: NodeJS.ProcessEnv = process.env): EventsTransport {
|
|
107
|
-
const name = env.SSE_TRANSPORT?.trim().toLowerCase() || "memory";
|
|
108
|
-
if (name === "memory") return new MemoryEventsTransport(env);
|
|
109
|
-
if (name === "redis") return new RedisEventsTransport(env);
|
|
110
|
-
throw new Error('SSE_TRANSPORT must be either "memory" or "redis"');
|
|
111
|
-
}
|