dineway 0.1.3
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/LICENSE +9 -0
- package/README.md +89 -0
- package/dist/adapters-BlzWJG82.d.mts +106 -0
- package/dist/apply-CAPvMfoU.mjs +1339 -0
- package/dist/astro/index.d.mts +50 -0
- package/dist/astro/index.mjs +1326 -0
- package/dist/astro/middleware/auth.d.mts +30 -0
- package/dist/astro/middleware/auth.mjs +708 -0
- package/dist/astro/middleware/redirect.d.mts +21 -0
- package/dist/astro/middleware/redirect.mjs +62 -0
- package/dist/astro/middleware/request-context.d.mts +17 -0
- package/dist/astro/middleware/request-context.mjs +1371 -0
- package/dist/astro/middleware/setup.d.mts +19 -0
- package/dist/astro/middleware/setup.mjs +46 -0
- package/dist/astro/middleware.d.mts +12 -0
- package/dist/astro/middleware.mjs +1716 -0
- package/dist/astro/types.d.mts +269 -0
- package/dist/astro/types.mjs +1 -0
- package/dist/base64-F8-DUraK.mjs +58 -0
- package/dist/byline-DeWCMU_i.mjs +234 -0
- package/dist/bylines-DyqBV9EQ.mjs +137 -0
- package/dist/chunk-ClPoSABd.mjs +21 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +3987 -0
- package/dist/client/external-auth-headers.d.mts +38 -0
- package/dist/client/external-auth-headers.mjs +101 -0
- package/dist/client/index.d.mts +397 -0
- package/dist/client/index.mjs +345 -0
- package/dist/config-Cq8H0SfX.mjs +46 -0
- package/dist/connection-C9pxzuag.mjs +52 -0
- package/dist/content-zSgdNmnt.mjs +836 -0
- package/dist/db/index.d.mts +4 -0
- package/dist/db/index.mjs +62 -0
- package/dist/db/libsql.d.mts +10 -0
- package/dist/db/libsql.mjs +21 -0
- package/dist/db/postgres.d.mts +10 -0
- package/dist/db/postgres.mjs +29 -0
- package/dist/db/sqlite.d.mts +10 -0
- package/dist/db/sqlite.mjs +15 -0
- package/dist/default-WYlzADZL.mjs +80 -0
- package/dist/dialect-helpers-B9uSp2GJ.mjs +89 -0
- package/dist/error-DrxtnGPg.mjs +26 -0
- package/dist/index-C-jx21qs.d.mts +4771 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.mjs +30 -0
- package/dist/load-C6FCD1FU.mjs +27 -0
- package/dist/loader-qKmo0wAY.mjs +446 -0
- package/dist/manifest-schema-CTSEyIJ3.mjs +186 -0
- package/dist/media/index.d.mts +25 -0
- package/dist/media/index.mjs +54 -0
- package/dist/media/local-runtime.d.mts +38 -0
- package/dist/media/local-runtime.mjs +132 -0
- package/dist/media-DMTr80Gv.mjs +199 -0
- package/dist/mode-BlyYtIFO.mjs +22 -0
- package/dist/page/index.d.mts +148 -0
- package/dist/page/index.mjs +419 -0
- package/dist/placeholder-B3knXwNc.mjs +267 -0
- package/dist/placeholder-bOx1xCTY.d.mts +283 -0
- package/dist/plugin-utils.d.mts +57 -0
- package/dist/plugin-utils.mjs +77 -0
- package/dist/plugins/adapt-sandbox-entry.d.mts +21 -0
- package/dist/plugins/adapt-sandbox-entry.mjs +112 -0
- package/dist/query-BiaPl_g2.mjs +459 -0
- package/dist/redirect-JPqLAbxa.mjs +328 -0
- package/dist/registry-DSd1GWB8.mjs +851 -0
- package/dist/request-context.d.mts +49 -0
- package/dist/request-context.mjs +42 -0
- package/dist/runner-B5l1JfOj.d.mts +26 -0
- package/dist/runner-BGUGywgG.mjs +1529 -0
- package/dist/runtime.d.mts +25 -0
- package/dist/runtime.mjs +41 -0
- package/dist/search-BNruJHDL.mjs +11054 -0
- package/dist/seed/index.d.mts +3 -0
- package/dist/seed/index.mjs +15 -0
- package/dist/seo/index.d.mts +69 -0
- package/dist/seo/index.mjs +69 -0
- package/dist/storage/local.d.mts +38 -0
- package/dist/storage/local.mjs +165 -0
- package/dist/storage/s3.d.mts +31 -0
- package/dist/storage/s3.mjs +174 -0
- package/dist/tokens-4vgYuXsZ.mjs +170 -0
- package/dist/transport-C5FYnid7.mjs +417 -0
- package/dist/transport-gIL-e43D.d.mts +41 -0
- package/dist/types-BawVha09.mjs +30 -0
- package/dist/types-BgQeVaPj.d.mts +192 -0
- package/dist/types-CLLdsG3g.d.mts +103 -0
- package/dist/types-D38djUXv.d.mts +1196 -0
- package/dist/types-DShnjzb6.mjs +15 -0
- package/dist/types-DkvMXalq.d.mts +425 -0
- package/dist/types-DuNbGKjF.mjs +74 -0
- package/dist/types-ju-_ORz7.d.mts +182 -0
- package/dist/validate-CXnRKfJK.mjs +327 -0
- package/dist/validate-CqRJb_xU.mjs +96 -0
- package/dist/validate-DVKJJ-M_.d.mts +377 -0
- package/locals.d.ts +47 -0
- package/package.json +313 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-ClPoSABd.mjs";
|
|
2
|
+
import { t as validateIdentifier } from "./validate-CqRJb_xU.mjs";
|
|
3
|
+
import { n as SQL_BATCH_SIZE, r as chunks, t as BylineRepository } from "./byline-DeWCMU_i.mjs";
|
|
4
|
+
import { n as getDb } from "./loader-qKmo0wAY.mjs";
|
|
5
|
+
import { sql } from "kysely";
|
|
6
|
+
|
|
7
|
+
//#region src/bylines/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* Runtime API for bylines
|
|
10
|
+
*
|
|
11
|
+
* Provides functions to query byline profiles and byline credits
|
|
12
|
+
* associated with content entries. Follows the same pattern as
|
|
13
|
+
* the taxonomies runtime API.
|
|
14
|
+
*/
|
|
15
|
+
var bylines_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
+
getByline: () => getByline,
|
|
17
|
+
getBylineBySlug: () => getBylineBySlug,
|
|
18
|
+
getBylinesForEntries: () => getBylinesForEntries
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Get a byline by ID.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { getByline } from "dineway";
|
|
26
|
+
*
|
|
27
|
+
* const byline = await getByline("01HXYZ...");
|
|
28
|
+
* if (byline) {
|
|
29
|
+
* console.log(byline.displayName);
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
async function getByline(id) {
|
|
34
|
+
return new BylineRepository(await getDb()).findById(id);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get a byline by slug.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { getBylineBySlug } from "dineway";
|
|
42
|
+
*
|
|
43
|
+
* const byline = await getBylineBySlug("jane-doe");
|
|
44
|
+
* if (byline) {
|
|
45
|
+
* console.log(byline.displayName); // "Jane Doe"
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async function getBylineBySlug(slug) {
|
|
50
|
+
return new BylineRepository(await getDb()).findBySlug(slug);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Batch-fetch byline credits for multiple content entries in a single query.
|
|
54
|
+
*
|
|
55
|
+
* This is more efficient than calling getEntryBylines for each entry
|
|
56
|
+
* when you need bylines for a list of entries (e.g., a blog index page).
|
|
57
|
+
*
|
|
58
|
+
* @param collection - The collection slug (e.g., "posts")
|
|
59
|
+
* @param entryIds - Array of entry IDs
|
|
60
|
+
* @returns Map from entry ID to array of byline credits
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { getBylinesForEntries, getDinewayCollection } from "dineway";
|
|
65
|
+
*
|
|
66
|
+
* const { entries } = await getDinewayCollection("posts");
|
|
67
|
+
* const ids = entries.map(e => e.data.id);
|
|
68
|
+
* const bylinesMap = await getBylinesForEntries("posts", ids);
|
|
69
|
+
*
|
|
70
|
+
* for (const entry of entries) {
|
|
71
|
+
* const bylines = bylinesMap.get(entry.data.id) ?? [];
|
|
72
|
+
* // render bylines
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
async function getBylinesForEntries(collection, entryIds) {
|
|
77
|
+
validateIdentifier(collection, "collection");
|
|
78
|
+
const result = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const id of entryIds) result.set(id, []);
|
|
80
|
+
if (entryIds.length === 0) return result;
|
|
81
|
+
const db = await getDb();
|
|
82
|
+
const repo = new BylineRepository(db);
|
|
83
|
+
const bylinesMap = await repo.getContentBylinesMany(collection, entryIds);
|
|
84
|
+
const fallbackEntryIds = [];
|
|
85
|
+
const needsFallback = /* @__PURE__ */ new Map();
|
|
86
|
+
for (const id of entryIds) if (!bylinesMap.has(id)) fallbackEntryIds.push(id);
|
|
87
|
+
if (fallbackEntryIds.length > 0) {
|
|
88
|
+
const authorMap = await getAuthorIds(db, collection, fallbackEntryIds);
|
|
89
|
+
for (const [entryId, authorId] of authorMap) needsFallback.set(entryId, authorId);
|
|
90
|
+
}
|
|
91
|
+
const uniqueAuthorIds = [...new Set(needsFallback.values())];
|
|
92
|
+
const authorBylineMap = await repo.findByUserIds(uniqueAuthorIds);
|
|
93
|
+
for (const id of entryIds) {
|
|
94
|
+
const explicit = bylinesMap.get(id);
|
|
95
|
+
if (explicit && explicit.length > 0) {
|
|
96
|
+
result.set(id, explicit.map((c) => ({
|
|
97
|
+
...c,
|
|
98
|
+
source: "explicit"
|
|
99
|
+
})));
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const authorId = needsFallback.get(id);
|
|
103
|
+
if (authorId) {
|
|
104
|
+
const fallback = authorBylineMap.get(authorId);
|
|
105
|
+
if (fallback) {
|
|
106
|
+
result.set(id, [{
|
|
107
|
+
byline: fallback,
|
|
108
|
+
sortOrder: 0,
|
|
109
|
+
roleLabel: null,
|
|
110
|
+
source: "inferred"
|
|
111
|
+
}]);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Batch-fetch author_ids for multiple content entries.
|
|
120
|
+
* Returns Map<entryId, authorId> (only entries with non-null author_id).
|
|
121
|
+
*/
|
|
122
|
+
async function getAuthorIds(db, collection, entryIds) {
|
|
123
|
+
const tableName = `ec_${collection}`;
|
|
124
|
+
validateIdentifier(tableName, "content table");
|
|
125
|
+
const map = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const chunk of chunks(entryIds, SQL_BATCH_SIZE)) {
|
|
127
|
+
const result = await sql`
|
|
128
|
+
SELECT id, author_id FROM ${sql.ref(tableName)}
|
|
129
|
+
WHERE id IN (${sql.join(chunk.map((id) => sql`${id}`))})
|
|
130
|
+
`.execute(db);
|
|
131
|
+
for (const row of result.rows) if (row.author_id) map.set(row.id, row.author_id);
|
|
132
|
+
}
|
|
133
|
+
return map;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
export { getByline as n, getBylineBySlug as r, bylines_exports as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) {
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (!no_symbols) {
|
|
14
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { __require as n, __exportAll as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|