@takosjp/yurucommu-core 3.4.5 → 4.1.0
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.en.md +3 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/src/backend/index.ts +44 -16
- package/src/backend/lib/blocklist-purge.ts +6 -6
- package/src/backend/public.ts +69 -4
- package/src/backend/routes/account-teardown.ts +2 -2
- package/src/backend/routes/apps.ts +4 -5
- package/src/backend/routes/media.ts +8 -5
- package/src/backend/routes/posts/delete-cascade.ts +7 -7
- package/src/backend/routes/stories/query-helpers.ts +2 -2
- package/src/backend/routes/stories/routes.ts +2 -5
- package/src/backend/runtime/bun.ts +655 -320
- package/src/backend/runtime/cloudflare.ts +20 -58
- package/src/backend/runtime/edge-facades.ts +336 -0
- package/src/backend/runtime/edge-kv.ts +204 -0
- package/src/backend/runtime/edge-objects.ts +120 -0
- package/src/backend/runtime/edge-queue.ts +135 -0
- package/src/backend/runtime/edge-sql.ts +207 -0
- package/src/backend/runtime/lane.ts +291 -0
- package/src/backend/runtime/managed-relational.ts +70 -23
- package/src/backend/runtime/managed-runtime.ts +117 -139
- package/src/backend/runtime/s3-fetch.ts +380 -0
- package/src/backend/runtime/sqlite-proxy-rows.ts +309 -0
- package/src/backend/runtime/types.ts +29 -61
- package/src/backend/server.ts +5 -0
- package/src/backend/types.ts +13 -4
- package/src/db/index.ts +2 -1
|
@@ -58,82 +58,50 @@ export interface IDatabase {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Bodies accepted by the provider-neutral object store seam.
|
|
62
|
+
*
|
|
63
|
+
* A body is handed to an adapter exactly once. Adapters must not eagerly
|
|
64
|
+
* consume or clone streams; callers that need replayability own that concern.
|
|
62
65
|
*/
|
|
63
|
-
export
|
|
66
|
+
export type ObjectStoreBody =
|
|
67
|
+
Blob | ReadableStream<Uint8Array> | ArrayBuffer | string;
|
|
68
|
+
|
|
69
|
+
/** Options for writing one object. */
|
|
70
|
+
export interface ObjectStorePutOptions {
|
|
64
71
|
contentType?: string;
|
|
65
|
-
contentLength?: number;
|
|
66
|
-
etag?: string;
|
|
67
|
-
httpMetadata?: {
|
|
68
|
-
contentType?: string;
|
|
69
|
-
cacheControl?: string;
|
|
70
|
-
contentDisposition?: string;
|
|
71
|
-
contentEncoding?: string;
|
|
72
|
-
contentLanguage?: string;
|
|
73
|
-
};
|
|
74
|
-
customMetadata?: Record<string, string>;
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
/**
|
|
78
|
-
*
|
|
75
|
+
* One object returned by an ObjectStore read.
|
|
76
|
+
*
|
|
77
|
+
* The body remains lazy and is consumed through the returned stream. Metadata
|
|
78
|
+
* is deliberately flat so callers do not depend on a vendor SDK's shape.
|
|
79
79
|
*/
|
|
80
|
-
export interface
|
|
80
|
+
export interface ObjectStoreObject {
|
|
81
81
|
key: string;
|
|
82
|
-
body: ReadableStream | null;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* backend (e.g. the in-memory test stub) tracks an etag.
|
|
87
|
-
*/
|
|
88
|
-
httpEtag?: string;
|
|
89
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
90
|
-
text(): Promise<string>;
|
|
91
|
-
json<T = unknown>(): Promise<T>;
|
|
92
|
-
httpMetadata?: ObjectMetadata["httpMetadata"];
|
|
93
|
-
customMetadata?: Record<string, string>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* List objects result
|
|
98
|
-
*/
|
|
99
|
-
export interface ListObjectsResult {
|
|
100
|
-
objects: Array<{
|
|
101
|
-
key: string;
|
|
102
|
-
size: number;
|
|
103
|
-
uploaded: Date;
|
|
104
|
-
etag?: string;
|
|
105
|
-
httpMetadata?: ObjectMetadata["httpMetadata"];
|
|
106
|
-
}>;
|
|
107
|
-
truncated: boolean;
|
|
108
|
-
cursor?: string;
|
|
109
|
-
delimitedPrefixes?: string[];
|
|
82
|
+
body: ReadableStream<Uint8Array> | null;
|
|
83
|
+
contentType?: string;
|
|
84
|
+
etag?: string;
|
|
85
|
+
byteLength?: number;
|
|
110
86
|
}
|
|
111
87
|
|
|
112
88
|
/**
|
|
113
|
-
*
|
|
89
|
+
* Provider-neutral object storage seam.
|
|
90
|
+
*
|
|
91
|
+
* Implementations expose only the operations used by production code. Object
|
|
92
|
+
* enumeration and separate metadata probes are intentionally not part of the
|
|
93
|
+
* contract; batch deletion is represented by passing an array of keys.
|
|
114
94
|
*/
|
|
115
|
-
export interface
|
|
95
|
+
export interface ObjectStore {
|
|
116
96
|
put(
|
|
117
97
|
key: string,
|
|
118
|
-
value:
|
|
119
|
-
options?:
|
|
120
|
-
httpMetadata?: ObjectMetadata["httpMetadata"];
|
|
121
|
-
customMetadata?: Record<string, string>;
|
|
122
|
-
},
|
|
98
|
+
value: ObjectStoreBody,
|
|
99
|
+
options?: ObjectStorePutOptions,
|
|
123
100
|
): Promise<void>;
|
|
124
101
|
|
|
125
|
-
get(key: string): Promise<
|
|
126
|
-
|
|
127
|
-
delete(key: string | string[]): Promise<void>;
|
|
128
|
-
|
|
129
|
-
list(options?: {
|
|
130
|
-
prefix?: string;
|
|
131
|
-
limit?: number;
|
|
132
|
-
cursor?: string;
|
|
133
|
-
delimiter?: string;
|
|
134
|
-
}): Promise<ListObjectsResult>;
|
|
102
|
+
get(key: string): Promise<ObjectStoreObject | null>;
|
|
135
103
|
|
|
136
|
-
|
|
104
|
+
delete(key: string | readonly string[]): Promise<void>;
|
|
137
105
|
}
|
|
138
106
|
|
|
139
107
|
/**
|
|
@@ -182,7 +150,7 @@ export interface IStaticAssets {
|
|
|
182
150
|
*/
|
|
183
151
|
export interface RuntimeEnv {
|
|
184
152
|
db: IDatabase;
|
|
185
|
-
storage?:
|
|
153
|
+
storage?: ObjectStore;
|
|
186
154
|
kv?: IKeyValueStore;
|
|
187
155
|
assets?: IStaticAssets;
|
|
188
156
|
|
package/src/backend/server.ts
CHANGED
|
@@ -89,6 +89,11 @@ type LocalRuntimeEnvKey = Exclude<keyof EnvVars, "APP_URL">;
|
|
|
89
89
|
// setting without an explicit local-runtime decision, instead of silently
|
|
90
90
|
// dropping authority/security configuration such as OIDC_OWNER_SUB.
|
|
91
91
|
const ENV_PASSTHROUGH_KEY_SET: Record<LocalRuntimeEnvKey, true> = {
|
|
92
|
+
// Carried so a shared env file reads the same everywhere, but nothing here
|
|
93
|
+
// consults it: this server builds the runtime ports directly from its own
|
|
94
|
+
// compat classes rather than wrapping a Worker's bindings, so it is neither
|
|
95
|
+
// the `cloudflare` nor the `portable` lane. See runtime/lane.ts.
|
|
96
|
+
YURUCOMMU_RUNTIME_LANE: true,
|
|
92
97
|
ENABLE_TAKOS_TOOLS: true,
|
|
93
98
|
AUTH_PASSWORD_HASH: true,
|
|
94
99
|
GOOGLE_CLIENT_ID: true,
|
package/src/backend/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Database } from "../db/index.ts";
|
|
2
2
|
import type {
|
|
3
3
|
IKeyValueStore,
|
|
4
|
-
|
|
4
|
+
ObjectStore,
|
|
5
5
|
IStaticAssets,
|
|
6
6
|
} from "./runtime/types.ts";
|
|
7
7
|
import type { IQueueProducer } from "./runtime/queue.ts";
|
|
@@ -16,6 +16,15 @@ import type {
|
|
|
16
16
|
export interface EnvVars {
|
|
17
17
|
APP_URL: string;
|
|
18
18
|
|
|
19
|
+
// What shape the Worker's bindings arrive in. Unset (or "cloudflare") = raw
|
|
20
|
+
// Cloudflare bindings, which is also what an ordinary-Workers Takoserver
|
|
21
|
+
// backend projects; "portable" = the edge.sql / edge.kv / edge.objects /
|
|
22
|
+
// edge.queue facades a wrapper host (self-host, managed
|
|
23
|
+
// Workers-for-Platforms) projects. The value is checked against the bindings
|
|
24
|
+
// and a disagreement refuses to start — see runtime/lane.ts and
|
|
25
|
+
// docs/design/runtime-lanes.md.
|
|
26
|
+
YURUCOMMU_RUNTIME_LANE?: string;
|
|
27
|
+
|
|
19
28
|
// Takos-specific endpoints are opt-in (fail-close by default).
|
|
20
29
|
ENABLE_TAKOS_TOOLS?: string;
|
|
21
30
|
|
|
@@ -133,8 +142,8 @@ export interface EnvVars {
|
|
|
133
142
|
/**
|
|
134
143
|
* Application Environment
|
|
135
144
|
*
|
|
136
|
-
* Uses the runtime-neutral
|
|
137
|
-
* wraps the native `D1Database` /
|
|
145
|
+
* Uses the runtime-neutral contracts. The Cloudflare worker entry
|
|
146
|
+
* wraps the native `D1Database` / object bucket / `KVNamespace` / `Fetcher`
|
|
138
147
|
* bindings with the adapters in `runtime/cloudflare.ts` before handing
|
|
139
148
|
* the Env to Hono. The local runtime compatibility classes already
|
|
140
149
|
* implement these contracts directly.
|
|
@@ -145,7 +154,7 @@ export interface EnvVars {
|
|
|
145
154
|
*/
|
|
146
155
|
export type Env = {
|
|
147
156
|
DB_INSTANCE: Database;
|
|
148
|
-
MEDIA?:
|
|
157
|
+
MEDIA?: ObjectStore;
|
|
149
158
|
KV: IKeyValueStore;
|
|
150
159
|
ASSETS?: IStaticAssets;
|
|
151
160
|
DELIVERY_QUEUE?: IQueueProducer<DeliveryQueueMessageV1>;
|
package/src/db/index.ts
CHANGED
|
@@ -18,12 +18,13 @@ import { drizzle as drizzleD1, type DrizzleD1Database } from "drizzle-orm/d1";
|
|
|
18
18
|
import type { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
19
19
|
import type { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
|
|
20
20
|
import type { ResultSet } from "@libsql/client";
|
|
21
|
+
import type { SqliteRemoteResult } from "drizzle-orm/sqlite-proxy";
|
|
21
22
|
import { isNull } from "drizzle-orm";
|
|
22
23
|
import * as schema from "./schema.ts";
|
|
23
24
|
|
|
24
25
|
export type Database = BaseSQLiteDatabase<
|
|
25
26
|
"async",
|
|
26
|
-
D1Result | ResultSet,
|
|
27
|
+
D1Result | ResultSet | SqliteRemoteResult,
|
|
27
28
|
typeof schema
|
|
28
29
|
>;
|
|
29
30
|
|