@botlr/sdk 0.0.0-stage → 0.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/dist/index.js ADDED
@@ -0,0 +1,382 @@
1
+ // src/errors.ts
2
+ var BotlrError = class extends Error {
3
+ status;
4
+ details;
5
+ constructor(message, status, details) {
6
+ super(message);
7
+ this.name = "BotlrError";
8
+ this.status = status;
9
+ this.details = details;
10
+ }
11
+ };
12
+ var BotlrConflictError = class extends BotlrError {
13
+ latest;
14
+ constructor(message, latest, details) {
15
+ super(message, 409, details);
16
+ this.name = "BotlrConflictError";
17
+ this.latest = latest;
18
+ }
19
+ };
20
+
21
+ // src/client.ts
22
+ function toQueryString(query) {
23
+ const params = new URLSearchParams();
24
+ for (const [key, value] of Object.entries(query)) {
25
+ if (value === void 0 || value === null) continue;
26
+ if (Array.isArray(value)) {
27
+ for (const item of value) {
28
+ if (item !== void 0 && item !== null) {
29
+ params.append(key, String(item));
30
+ }
31
+ }
32
+ } else {
33
+ params.set(key, String(value));
34
+ }
35
+ }
36
+ const qs = params.toString();
37
+ return qs ? `?${qs}` : "";
38
+ }
39
+ function mergeContext(base, override) {
40
+ if (!base && !override) return void 0;
41
+ return { ...base, ...override };
42
+ }
43
+ function contextToHeaders(context) {
44
+ if (!context) return {};
45
+ return {
46
+ ...context.appId ? { "x-botlr-app-id": context.appId } : {},
47
+ ...context.locale ? { "x-botlr-locale": context.locale } : {},
48
+ ...context.preview !== void 0 ? { "x-botlr-preview": String(context.preview) } : {}
49
+ };
50
+ }
51
+ async function errorDetails(response) {
52
+ const text = await response.text().catch(() => void 0);
53
+ if (text === void 0 || text === "") return void 0;
54
+ try {
55
+ return JSON.parse(text);
56
+ } catch {
57
+ return text;
58
+ }
59
+ }
60
+ function conflictLatest(details) {
61
+ if (!details || typeof details !== "object") return null;
62
+ const detail = details.detail;
63
+ if (!detail || typeof detail !== "object") return null;
64
+ const latest = detail.latest;
65
+ if (!latest || typeof latest !== "object") return null;
66
+ const { version, contentHash: contentHash2 } = latest;
67
+ if (typeof version !== "number" || typeof contentHash2 !== "string") return null;
68
+ return { version, contentHash: contentHash2 };
69
+ }
70
+ function conflictMessage(details) {
71
+ if (!details || typeof details !== "object") return void 0;
72
+ const detail = details.detail;
73
+ if (!detail || typeof detail !== "object") return void 0;
74
+ const message = detail.message;
75
+ return typeof message === "string" ? message : void 0;
76
+ }
77
+ function createBotlrClient(config) {
78
+ const fetcher = config.fetch ?? globalThis.fetch;
79
+ if (typeof fetcher !== "function") {
80
+ throw new BotlrError("No fetch implementation: pass `fetch` in the client config");
81
+ }
82
+ const baseUrl = config.baseUrl.replace(/\/+$/, "");
83
+ const baseContext = {
84
+ appId: config.appId,
85
+ locale: config.locale,
86
+ preview: config.preview
87
+ };
88
+ async function request(path, options = {}) {
89
+ const { query, context: contextOverride, headers: extraHeaders, ...init } = options;
90
+ const context = mergeContext(baseContext, contextOverride);
91
+ const url = `${baseUrl}${path}${toQueryString(query ?? {})}`;
92
+ const response = await fetcher(url, {
93
+ ...init,
94
+ headers: {
95
+ Accept: "application/json",
96
+ "Content-Type": "application/json",
97
+ ...config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {},
98
+ ...contextToHeaders(context),
99
+ ...extraHeaders ?? {}
100
+ }
101
+ });
102
+ if (!response.ok) {
103
+ const details = await errorDetails(response);
104
+ if (response.status === 409) {
105
+ throw new BotlrConflictError(
106
+ conflictMessage(details) ?? `Botlr request failed with status 409`,
107
+ conflictLatest(details),
108
+ details
109
+ );
110
+ }
111
+ throw new BotlrError(`Botlr request failed with status ${response.status}`, response.status, details);
112
+ }
113
+ if (response.status === 204) {
114
+ return void 0;
115
+ }
116
+ return await response.json();
117
+ }
118
+ const sections = {
119
+ /** Every section the app can pull for `framework`, with the latest version per scope. */
120
+ list(params) {
121
+ return request("/api/sections/source", {
122
+ method: "GET",
123
+ query: { framework: params.framework, appInstanceId: baseContext.appId }
124
+ });
125
+ },
126
+ /** The section's source: this app's row first, the shared row second. */
127
+ pull(name, params) {
128
+ return request(`/api/sections/${encodeURIComponent(name)}/source`, {
129
+ method: "GET",
130
+ query: {
131
+ framework: params.framework,
132
+ appInstanceId: baseContext.appId,
133
+ version: params.version,
134
+ scope: params.scope
135
+ }
136
+ });
137
+ },
138
+ /**
139
+ * Push a new version with the personal access token (`write:sections`).
140
+ * Resolves with `created: true` on 201 and `created: false` when nothing
141
+ * changed; throws `BotlrConflictError` when `baseVersion` is not the latest.
142
+ */
143
+ push(name, body) {
144
+ if (!config.personalToken) {
145
+ return Promise.reject(
146
+ new BotlrError("sections.push needs `personalToken` (a personal access token with write:sections)")
147
+ );
148
+ }
149
+ const { appInstanceId, ...rest } = body;
150
+ return request(`/api/sections/${encodeURIComponent(name)}/source`, {
151
+ method: "PUT",
152
+ headers: { Authorization: `Bearer ${config.personalToken}` },
153
+ body: JSON.stringify({ appInstanceId: appInstanceId ?? baseContext.appId, ...rest })
154
+ });
155
+ }
156
+ };
157
+ return {
158
+ request,
159
+ /** The resolved config, for wrappers that need `baseUrl` or `appId`. */
160
+ config: { ...config, baseUrl },
161
+ withContext(contextOverride) {
162
+ return createBotlrClient({ ...config, ...contextOverride });
163
+ },
164
+ async getEntryBySlug(params) {
165
+ const result = await request("/entries/by-slug", {
166
+ method: "GET",
167
+ query: { contentType: params.contentType, slug: params.slug, locale: params.locale },
168
+ context: { locale: params.locale }
169
+ });
170
+ return result.item;
171
+ },
172
+ async getEntries(params) {
173
+ const query = {
174
+ contentType: params.contentType,
175
+ locale: params.locale,
176
+ limit: params.limit,
177
+ offset: params.offset,
178
+ sort: params.sort
179
+ };
180
+ for (const [key, value] of Object.entries(params.filters ?? {})) {
181
+ query[`filter.${key}`] = value;
182
+ }
183
+ return request("/entries", {
184
+ method: "GET",
185
+ query,
186
+ context: { locale: params.locale }
187
+ });
188
+ },
189
+ async getSingleton(params) {
190
+ const result = await request("/singletons", {
191
+ method: "GET",
192
+ query: { key: params.key, locale: params.locale },
193
+ context: { locale: params.locale }
194
+ });
195
+ return result.item;
196
+ },
197
+ getPageBySlug(slug, locale) {
198
+ return request(`/api/pages/${slug}`, {
199
+ query: {
200
+ appInstanceId: baseContext.appId,
201
+ locale: locale || baseContext.locale,
202
+ mode: baseContext.preview ? "draft" : "published"
203
+ }
204
+ });
205
+ },
206
+ resolveUrl(slug, locale) {
207
+ return request("/api/resolve", {
208
+ query: {
209
+ slug,
210
+ appInstanceId: baseContext.appId,
211
+ locale: locale || baseContext.locale,
212
+ mode: baseContext.preview ? "draft" : "published",
213
+ ...baseContext.preview && config.previewToken ? { token: config.previewToken } : {}
214
+ }
215
+ });
216
+ },
217
+ getPageList(params = {}) {
218
+ return request("/api/page-lists", {
219
+ query: {
220
+ appInstanceId: params.appInstanceId || baseContext.appId,
221
+ locale: params.locale || baseContext.locale,
222
+ parentId: params.parentId,
223
+ tags: params.tags,
224
+ limit: params.limit,
225
+ offset: params.offset,
226
+ type: params.type || "page",
227
+ orderBy: params.orderBy
228
+ }
229
+ });
230
+ },
231
+ getPageSlugList(params = {}) {
232
+ return request("/api/page-lists/slugs", {
233
+ query: {
234
+ appInstanceId: params.appInstanceId || baseContext.appId,
235
+ locale: params.locale || baseContext.locale,
236
+ limit: params.limit,
237
+ offset: params.offset
238
+ }
239
+ });
240
+ },
241
+ getMenu(key, locale) {
242
+ return request("/api/menus", {
243
+ query: { key, appInstanceId: baseContext.appId, locale: locale || baseContext.locale }
244
+ });
245
+ },
246
+ getForm(key, locale) {
247
+ return request("/api/forms", {
248
+ query: { key, appInstanceId: baseContext.appId, locale: locale || baseContext.locale }
249
+ });
250
+ },
251
+ getList(appId, listId, locale) {
252
+ return request(`/api/lists/${listId}/complete`, {
253
+ query: { appInstanceId: appId, locale: locale || baseContext.locale }
254
+ });
255
+ },
256
+ getConfigurator(configuratorId, versionId) {
257
+ return request(`/api/configurators/${configuratorId}`, {
258
+ query: { versionId, appInstanceId: baseContext.appId, locale: baseContext.locale }
259
+ });
260
+ },
261
+ /** GET `/api/{endpoint}` with the app and locale added to the query. */
262
+ getData(endpoint, queryParams, locale) {
263
+ return request(`/api/${endpoint}`, {
264
+ method: "GET",
265
+ query: { appInstanceId: baseContext.appId, locale: locale || baseContext.locale, ...queryParams }
266
+ });
267
+ },
268
+ /** POST `data` as JSON to `/api/{endpoint}`, for forms and other submissions. */
269
+ submitData(endpoint, data, locale, queryParams) {
270
+ return request(`/api/${endpoint}`, {
271
+ method: "POST",
272
+ body: JSON.stringify(data),
273
+ query: { appInstanceId: baseContext.appId, locale: locale || baseContext.locale, ...queryParams }
274
+ });
275
+ },
276
+ getAppInfo() {
277
+ return request(`/api/apps/${baseContext.appId}`);
278
+ },
279
+ getSitemap() {
280
+ return request(`/api/sitemap/${baseContext.appId}`);
281
+ },
282
+ /** Every redirect for the app, across all locales. */
283
+ getRedirects() {
284
+ return request(`/api/redirects/${baseContext.appId}`);
285
+ },
286
+ getAssetById(assetId) {
287
+ return request(`/api/assets/${assetId}`, {
288
+ query: { appInstanceId: baseContext.appId }
289
+ });
290
+ },
291
+ sections
292
+ };
293
+ }
294
+ function createBotlrFactory(defaults) {
295
+ return {
296
+ create(config) {
297
+ return createBotlrClient({ ...defaults, ...config });
298
+ }
299
+ };
300
+ }
301
+
302
+ // src/sections.ts
303
+ var MANIFEST_STATE_KEYS = ["version", "hash", "contentHash", "pulledAt", "scope"];
304
+ var SECTION_SOURCE_LIMITS = {
305
+ maxFiles: 50,
306
+ maxFileBytes: 512 * 1024,
307
+ maxTotalBytes: 2 * 1024 * 1024,
308
+ maxPathLength: 200,
309
+ maxMessageLength: 500
310
+ };
311
+ var SECTION_PATH_RE = /^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
312
+ var SECTION_FRAMEWORK_RE = /^[a-z0-9][a-z0-9-]{0,31}$/;
313
+ function isValidSectionPath(path) {
314
+ if (!path || path.length > SECTION_SOURCE_LIMITS.maxPathLength) return false;
315
+ if (!SECTION_PATH_RE.test(path)) return false;
316
+ return !path.split("/").some((segment) => segment === "." || segment === "..");
317
+ }
318
+ function isValidFramework(framework) {
319
+ return SECTION_FRAMEWORK_RE.test(framework);
320
+ }
321
+ var encoder = new TextEncoder();
322
+ function subtle() {
323
+ const c = globalThis.crypto;
324
+ if (!c || !c.subtle) {
325
+ throw new Error("Web Crypto is not available in this runtime (globalThis.crypto.subtle)");
326
+ }
327
+ return c.subtle;
328
+ }
329
+ function toHex(buffer) {
330
+ const bytes = new Uint8Array(buffer);
331
+ let out = "";
332
+ for (let i = 0; i < bytes.length; i++) {
333
+ out += bytes[i].toString(16).padStart(2, "0");
334
+ }
335
+ return out;
336
+ }
337
+ async function sha256Hex(input) {
338
+ return toHex(await subtle().digest("SHA-256", encoder.encode(input)));
339
+ }
340
+ function fileSha256(content) {
341
+ return sha256Hex(content);
342
+ }
343
+ async function contentHash(files) {
344
+ const hashed = await hashFiles(files);
345
+ const lines = hashed.map((f) => [f.path, f.sha256]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([path, sha]) => `${path}
346
+ ${sha}
347
+ `).join("");
348
+ return sha256Hex(lines);
349
+ }
350
+ async function hashFiles(files) {
351
+ return Promise.all(
352
+ files.map(async (f) => ({
353
+ path: f.path,
354
+ content: f.content,
355
+ sha256: "sha256" in f && typeof f.sha256 === "string" ? f.sha256 : await fileSha256(f.content)
356
+ }))
357
+ );
358
+ }
359
+ function stripManifestState(manifest) {
360
+ const copy = { ...manifest };
361
+ for (const key of MANIFEST_STATE_KEYS) delete copy[key];
362
+ return copy;
363
+ }
364
+ export {
365
+ BotlrConflictError,
366
+ BotlrError,
367
+ MANIFEST_STATE_KEYS,
368
+ SECTION_FRAMEWORK_RE,
369
+ SECTION_PATH_RE,
370
+ SECTION_SOURCE_LIMITS,
371
+ contentHash,
372
+ contextToHeaders,
373
+ createBotlrClient,
374
+ createBotlrFactory,
375
+ fileSha256,
376
+ hashFiles,
377
+ isValidFramework,
378
+ isValidSectionPath,
379
+ stripManifestState,
380
+ toQueryString
381
+ };
382
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/sections.ts"],"sourcesContent":["/**\n * Thrown for every non-2xx response. `status` is the HTTP status and\n * `details` the parsed JSON body (or the raw text when the body is not JSON).\n */\nexport class BotlrError extends Error {\n readonly status: number | undefined;\n readonly details: unknown;\n\n constructor(message: string, status?: number, details?: unknown) {\n super(message);\n this.name = \"BotlrError\";\n this.status = status;\n this.details = details;\n }\n}\n\n/** The latest version of a section source, as reported on a push conflict. */\nexport type ConflictLatest = {\n version: number;\n contentHash: string;\n};\n\n/**\n * Thrown by `sections.push` on 409: `baseVersion` was not the latest version,\n * or a concurrent push won. `latest` is null when the server has no version\n * at all (the client sent a `baseVersion` above 0 for a section with no source).\n */\nexport class BotlrConflictError extends BotlrError {\n readonly latest: ConflictLatest | null;\n\n constructor(message: string, latest: ConflictLatest | null, details?: unknown) {\n super(message, 409, details);\n this.name = \"BotlrConflictError\";\n this.latest = latest;\n }\n}\n","import type {\n BotlrClientConfig,\n BotlrContext,\n BotlrEntry,\n BotlrQuery,\n BotlrQueryValue,\n FormResponse,\n GetEntriesParams,\n GetEntryBySlugParams,\n GetPageListParams,\n GetPageSlugListParams,\n GetSingletonParams,\n ListResponse,\n MenuResponse,\n PageListResponse,\n PageResponse,\n PageSlugListResponse,\n RedirectsResponse,\n ResolveResponse,\n} from \"./types\";\nimport type {\n SectionSourceListParams,\n SectionSourceListResponse,\n SectionSourcePullParams,\n SectionSourcePullResponse,\n SectionSourcePushBody,\n SectionSourcePushResponse,\n} from \"./sections\";\nimport { BotlrConflictError, BotlrError } from \"./errors\";\n\nexport type RequestOptions = Omit<RequestInit, \"headers\"> & {\n query?: BotlrQuery;\n context?: Partial<BotlrContext>;\n headers?: Record<string, string>;\n};\n\nexport function toQueryString(query: BotlrQuery): string {\n const params = new URLSearchParams();\n\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item !== undefined && item !== null) {\n params.append(key, String(item));\n }\n }\n } else {\n params.set(key, String(value));\n }\n }\n\n const qs = params.toString();\n return qs ? `?${qs}` : \"\";\n}\n\nfunction mergeContext(\n base?: Partial<BotlrContext>,\n override?: Partial<BotlrContext>,\n): Partial<BotlrContext> | undefined {\n if (!base && !override) return undefined;\n return { ...base, ...override };\n}\n\nexport function contextToHeaders(context?: Partial<BotlrContext>): Record<string, string> {\n if (!context) return {};\n\n return {\n ...(context.appId ? { \"x-botlr-app-id\": context.appId } : {}),\n ...(context.locale ? { \"x-botlr-locale\": context.locale } : {}),\n ...(context.preview !== undefined ? { \"x-botlr-preview\": String(context.preview) } : {}),\n };\n}\n\nasync function errorDetails(response: Response): Promise<unknown> {\n const text = await response.text().catch(() => undefined);\n if (text === undefined || text === \"\") return undefined;\n try {\n return JSON.parse(text) as unknown;\n } catch {\n return text;\n }\n}\n\nfunction conflictLatest(details: unknown): { version: number; contentHash: string } | null {\n if (!details || typeof details !== \"object\") return null;\n const detail = (details as { detail?: unknown }).detail;\n if (!detail || typeof detail !== \"object\") return null;\n const latest = (detail as { latest?: unknown }).latest;\n if (!latest || typeof latest !== \"object\") return null;\n const { version, contentHash } = latest as { version?: unknown; contentHash?: unknown };\n if (typeof version !== \"number\" || typeof contentHash !== \"string\") return null;\n return { version, contentHash };\n}\n\nfunction conflictMessage(details: unknown): string | undefined {\n if (!details || typeof details !== \"object\") return undefined;\n const detail = (details as { detail?: unknown }).detail;\n if (!detail || typeof detail !== \"object\") return undefined;\n const message = (detail as { message?: unknown }).message;\n return typeof message === \"string\" ? message : undefined;\n}\n\nexport type BotlrClient = ReturnType<typeof createBotlrClient>;\n\n/**\n * A Botlr client. Every call sends the site token as `Authorization: Bearer`\n * plus `x-botlr-app-id`, `x-botlr-locale` and `x-botlr-preview` from the\n * config; `sections.push` sends the personal token instead.\n */\nexport function createBotlrClient(config: BotlrClientConfig) {\n const fetcher = config.fetch ?? globalThis.fetch;\n if (typeof fetcher !== \"function\") {\n throw new BotlrError(\"No fetch implementation: pass `fetch` in the client config\");\n }\n const baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n\n const baseContext: BotlrContext = {\n appId: config.appId,\n locale: config.locale,\n preview: config.preview,\n };\n\n async function request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { query, context: contextOverride, headers: extraHeaders, ...init } = options;\n const context = mergeContext(baseContext, contextOverride);\n const url = `${baseUrl}${path}${toQueryString(query ?? {})}`;\n\n const response = await fetcher(url, {\n ...init,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n ...(config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}),\n ...contextToHeaders(context),\n ...(extraHeaders ?? {}),\n },\n });\n\n if (!response.ok) {\n const details = await errorDetails(response);\n if (response.status === 409) {\n throw new BotlrConflictError(\n conflictMessage(details) ?? `Botlr request failed with status 409`,\n conflictLatest(details),\n details,\n );\n }\n throw new BotlrError(`Botlr request failed with status ${response.status}`, response.status, details);\n }\n\n if (response.status === 204) {\n return undefined as T;\n }\n\n return (await response.json()) as T;\n }\n\n const sections = {\n /** Every section the app can pull for `framework`, with the latest version per scope. */\n list(params: SectionSourceListParams): Promise<SectionSourceListResponse> {\n return request<SectionSourceListResponse>(\"/api/sections/source\", {\n method: \"GET\",\n query: { framework: params.framework, appInstanceId: baseContext.appId },\n });\n },\n\n /** The section's source: this app's row first, the shared row second. */\n pull(name: string, params: SectionSourcePullParams): Promise<SectionSourcePullResponse> {\n return request<SectionSourcePullResponse>(`/api/sections/${encodeURIComponent(name)}/source`, {\n method: \"GET\",\n query: {\n framework: params.framework,\n appInstanceId: baseContext.appId,\n version: params.version,\n scope: params.scope,\n },\n });\n },\n\n /**\n * Push a new version with the personal access token (`write:sections`).\n * Resolves with `created: true` on 201 and `created: false` when nothing\n * changed; throws `BotlrConflictError` when `baseVersion` is not the latest.\n */\n push(name: string, body: SectionSourcePushBody): Promise<SectionSourcePushResponse> {\n if (!config.personalToken) {\n return Promise.reject(\n new BotlrError(\"sections.push needs `personalToken` (a personal access token with write:sections)\"),\n );\n }\n const { appInstanceId, ...rest } = body;\n return request<SectionSourcePushResponse>(`/api/sections/${encodeURIComponent(name)}/source`, {\n method: \"PUT\",\n headers: { Authorization: `Bearer ${config.personalToken}` },\n body: JSON.stringify({ appInstanceId: appInstanceId ?? baseContext.appId, ...rest }),\n });\n },\n };\n\n return {\n request,\n\n /** The resolved config, for wrappers that need `baseUrl` or `appId`. */\n config: { ...config, baseUrl } as Readonly<BotlrClientConfig>,\n\n withContext(contextOverride: Partial<BotlrContext>) {\n return createBotlrClient({ ...config, ...contextOverride });\n },\n\n async getEntryBySlug<TFields>(params: GetEntryBySlugParams): Promise<BotlrEntry<TFields> | null> {\n const result = await request<{ item: BotlrEntry<TFields> | null }>(\"/entries/by-slug\", {\n method: \"GET\",\n query: { contentType: params.contentType, slug: params.slug, locale: params.locale },\n context: { locale: params.locale },\n });\n return result.item;\n },\n\n async getEntries<TFields>(\n params: GetEntriesParams,\n ): Promise<{ items: BotlrEntry<TFields>[]; total: number }> {\n const query: Record<string, BotlrQueryValue> = {\n contentType: params.contentType,\n locale: params.locale,\n limit: params.limit,\n offset: params.offset,\n sort: params.sort,\n };\n for (const [key, value] of Object.entries(params.filters ?? {})) {\n query[`filter.${key}`] = value;\n }\n return request<{ items: BotlrEntry<TFields>[]; total: number }>(\"/entries\", {\n method: \"GET\",\n query,\n context: { locale: params.locale },\n });\n },\n\n async getSingleton<TFields>(params: GetSingletonParams): Promise<BotlrEntry<TFields> | null> {\n const result = await request<{ item: BotlrEntry<TFields> | null }>(\"/singletons\", {\n method: \"GET\",\n query: { key: params.key, locale: params.locale },\n context: { locale: params.locale },\n });\n return result.item;\n },\n\n getPageBySlug(slug: string, locale?: string) {\n return request<PageResponse>(`/api/pages/${slug}`, {\n query: {\n appInstanceId: baseContext.appId,\n locale: locale || baseContext.locale,\n mode: baseContext.preview ? \"draft\" : \"published\",\n },\n });\n },\n\n resolveUrl(slug: string, locale?: string) {\n return request<ResolveResponse>(\"/api/resolve\", {\n query: {\n slug,\n appInstanceId: baseContext.appId,\n locale: locale || baseContext.locale,\n mode: baseContext.preview ? \"draft\" : \"published\",\n ...(baseContext.preview && config.previewToken ? { token: config.previewToken } : {}),\n },\n });\n },\n\n getPageList(params: GetPageListParams = {}) {\n return request<PageListResponse>(\"/api/page-lists\", {\n query: {\n appInstanceId: params.appInstanceId || baseContext.appId,\n locale: params.locale || baseContext.locale,\n parentId: params.parentId,\n tags: params.tags,\n limit: params.limit,\n offset: params.offset,\n type: params.type || \"page\",\n orderBy: params.orderBy,\n },\n });\n },\n\n getPageSlugList(params: GetPageSlugListParams = {}) {\n return request<PageSlugListResponse>(\"/api/page-lists/slugs\", {\n query: {\n appInstanceId: params.appInstanceId || baseContext.appId,\n locale: params.locale || baseContext.locale,\n limit: params.limit,\n offset: params.offset,\n },\n });\n },\n\n getMenu(key: string, locale?: string) {\n return request<MenuResponse>(\"/api/menus\", {\n query: { key, appInstanceId: baseContext.appId, locale: locale || baseContext.locale },\n });\n },\n\n getForm(key: string, locale?: string) {\n return request<FormResponse>(\"/api/forms\", {\n query: { key, appInstanceId: baseContext.appId, locale: locale || baseContext.locale },\n });\n },\n\n getList(appId: string, listId: string, locale?: string) {\n return request<ListResponse>(`/api/lists/${listId}/complete`, {\n query: { appInstanceId: appId, locale: locale || baseContext.locale },\n });\n },\n\n getConfigurator<T = unknown>(configuratorId: string, versionId?: string) {\n return request<T>(`/api/configurators/${configuratorId}`, {\n query: { versionId, appInstanceId: baseContext.appId, locale: baseContext.locale },\n });\n },\n\n /** GET `/api/{endpoint}` with the app and locale added to the query. */\n getData<T = unknown>(endpoint: string, queryParams?: BotlrQuery, locale?: string) {\n return request<T>(`/api/${endpoint}`, {\n method: \"GET\",\n query: { appInstanceId: baseContext.appId, locale: locale || baseContext.locale, ...queryParams },\n });\n },\n\n /** POST `data` as JSON to `/api/{endpoint}`, for forms and other submissions. */\n submitData<T = unknown>(\n endpoint: string,\n data: Record<string, unknown>,\n locale?: string,\n queryParams?: BotlrQuery,\n ) {\n return request<T>(`/api/${endpoint}`, {\n method: \"POST\",\n body: JSON.stringify(data),\n query: { appInstanceId: baseContext.appId, locale: locale || baseContext.locale, ...queryParams },\n });\n },\n\n getAppInfo<T = unknown>() {\n return request<T>(`/api/apps/${baseContext.appId}`);\n },\n\n getSitemap<T = unknown>() {\n return request<T>(`/api/sitemap/${baseContext.appId}`);\n },\n\n /** Every redirect for the app, across all locales. */\n getRedirects() {\n return request<RedirectsResponse>(`/api/redirects/${baseContext.appId}`);\n },\n\n getAssetById<T = unknown>(assetId: string) {\n return request<T>(`/api/assets/${assetId}`, {\n query: { appInstanceId: baseContext.appId },\n });\n },\n\n sections,\n };\n}\n\nexport function createBotlrFactory(defaults?: { fetch?: typeof fetch }) {\n return {\n create(config: Omit<BotlrClientConfig, \"fetch\">) {\n return createBotlrClient({ ...defaults, ...config });\n },\n };\n}\n","/**\n * Section source bridge: types and hash helpers.\n *\n * Mirrors the contract in xam-mono's docs/SECTION_SOURCE_BRIDGE.md. The hash\n * rules are reproduced here exactly as the server computes them, so a client\n * can tell \"clean\", \"modified\", \"behind\" and \"diverged\" apart without a\n * round trip:\n *\n * - `file.sha256` = sha256 of the UTF-8 content, hex, content exactly as sent\n * - `contentHash` = sha256 over `\"{path}\\n{sha256}\\n\"` for every file, sorted by path\n *\n * The manifest is not hashed.\n */\n\n/** The source variant a section is stored for, for example `react-next` or `html`. */\nexport type SectionFramework = string;\n\nexport type SectionSourceScope = \"instance\" | \"shared\";\n\n/** `<slug>.botlr.json`, kept next to the section's entry file. */\nexport interface SectionManifest {\n /** Section definition slug. Must equal the name used in the URL on push. */\n section: string;\n framework: SectionFramework;\n /** Entry file, relative to the manifest's directory. Must be listed in `files`. */\n entry: string;\n /** Named export of the component in `entry`. */\n exportName?: string;\n /** Every file of the section, relative to the manifest's directory, forward slashes only. */\n files: string[];\n title?: string;\n description?: string;\n category?: string;\n icon?: string;\n dependencies?: SectionDependencies;\n /** Unknown keys are kept by the server. */\n [key: string]: unknown;\n}\n\nexport interface SectionDependencies {\n /** npm packages the section imports, with the ranges the app uses. */\n npm?: Record<string, string>;\n /** Local modules the section imports; the pulling app must already have them. */\n internal?: string[];\n}\n\n/**\n * Pull state keys the server strips from a manifest. The CLI keeps these in\n * `.botlr/sections.lock.json`, never in the manifest.\n */\nexport const MANIFEST_STATE_KEYS = [\"version\", \"hash\", \"contentHash\", \"pulledAt\", \"scope\"] as const;\n\nexport interface SectionSourceFileInput {\n path: string;\n content: string;\n}\n\nexport interface SectionSourceFile extends SectionSourceFileInput {\n sha256: string;\n}\n\nexport interface SectionDefinitionScope {\n tenantId: string;\n organizationId: string | null;\n projectId: string | null;\n}\n\nexport interface SectionDefinition {\n id: string;\n name: string;\n title: string;\n schema: Record<string, unknown>;\n scope: SectionDefinitionScope;\n}\n\nexport interface SectionSource {\n scope: SectionSourceScope;\n framework: SectionFramework;\n version: number;\n contentHash: string;\n manifest: SectionManifest;\n message: string | null;\n createdAt: string;\n files: SectionSourceFile[];\n}\n\nexport interface SectionSourceScopeSummary {\n version: number;\n contentHash: string;\n updatedAt: string;\n}\n\nexport interface SectionSourceSummary {\n name: string;\n title: string;\n definitionId: string;\n instance: SectionSourceScopeSummary | null;\n shared: SectionSourceScopeSummary | null;\n /** Which scope a pull without `scope` returns. */\n effective: SectionSourceScope;\n}\n\nexport interface SectionSourceListResponse {\n framework: SectionFramework;\n sections: SectionSourceSummary[];\n}\n\nexport interface SectionSourcePullResponse {\n /** null only for an instance row whose section no longer resolves to a definition */\n definition: SectionDefinition | null;\n source: SectionSource;\n}\n\nexport interface SectionSourceListParams {\n framework: SectionFramework;\n}\n\nexport interface SectionSourcePullParams {\n framework: SectionFramework;\n /** A specific version; latest when omitted. */\n version?: number;\n /** Force one scope instead of \"instance first, shared second\". */\n scope?: SectionSourceScope;\n}\n\nexport interface SectionSourcePushBody {\n framework: SectionFramework;\n manifest: SectionManifest;\n files: SectionSourceFileInput[];\n /** Defaults to the client's `appId`. */\n appInstanceId?: string;\n /** Write the shared row (per section definition) instead of this app's row. */\n shared?: boolean;\n /**\n * The version the push is based on; 0 means \"none yet\". Omit to force the\n * push without a conflict check.\n */\n baseVersion?: number;\n /** At most 500 characters. */\n message?: string;\n /** Add a project-scoped section definition when none exists. */\n create?: boolean;\n}\n\nexport interface SectionSourcePushResponse {\n /** true on 201 (new version), false on 200 (nothing changed) */\n created: boolean;\n scope: SectionSourceScope;\n definition: SectionDefinition;\n version: number;\n contentHash: string;\n}\n\n// ---------------------------------------------------------------------------\n// Limits, as enforced by the server\n// ---------------------------------------------------------------------------\n\nexport const SECTION_SOURCE_LIMITS = {\n maxFiles: 50,\n maxFileBytes: 512 * 1024,\n maxTotalBytes: 2 * 1024 * 1024,\n maxPathLength: 200,\n maxMessageLength: 500,\n} as const;\n\nexport const SECTION_PATH_RE = /^[A-Za-z0-9._-]+(?:\\/[A-Za-z0-9._-]+)*$/;\nexport const SECTION_FRAMEWORK_RE = /^[a-z0-9][a-z0-9-]{0,31}$/;\n\n/** True when `path` is a relative path the bridge accepts. */\nexport function isValidSectionPath(path: string): boolean {\n if (!path || path.length > SECTION_SOURCE_LIMITS.maxPathLength) return false;\n if (!SECTION_PATH_RE.test(path)) return false;\n return !path.split(\"/\").some((segment) => segment === \".\" || segment === \"..\");\n}\n\nexport function isValidFramework(framework: string): boolean {\n return SECTION_FRAMEWORK_RE.test(framework);\n}\n\n// ---------------------------------------------------------------------------\n// Hashing (Web Crypto, so it runs in the browser, Node 20+ and edge runtimes)\n// ---------------------------------------------------------------------------\n\nconst encoder = new TextEncoder();\n\nfunction subtle(): SubtleCrypto {\n const c = globalThis.crypto;\n if (!c || !c.subtle) {\n throw new Error(\"Web Crypto is not available in this runtime (globalThis.crypto.subtle)\");\n }\n return c.subtle;\n}\n\nfunction toHex(buffer: ArrayBuffer): string {\n const bytes = new Uint8Array(buffer);\n let out = \"\";\n for (let i = 0; i < bytes.length; i++) {\n out += bytes[i]!.toString(16).padStart(2, \"0\");\n }\n return out;\n}\n\nasync function sha256Hex(input: string): Promise<string> {\n return toHex(await subtle().digest(\"SHA-256\", encoder.encode(input)));\n}\n\n/** sha256 of the UTF-8 encoding of `content`, as lowercase hex. */\nexport function fileSha256(content: string): Promise<string> {\n return sha256Hex(content);\n}\n\n/**\n * The content hash of a file set: sha256 over `\"{path}\\n{sha256}\\n\"` for every\n * file, sorted by path. Accepts files with a precomputed `sha256` or plain\n * `{ path, content }` pairs.\n */\nexport async function contentHash(\n files: ReadonlyArray<SectionSourceFileInput | SectionSourceFile>,\n): Promise<string> {\n const hashed = await hashFiles(files);\n const lines = hashed\n .map((f) => [f.path, f.sha256] as const)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([path, sha]) => `${path}\\n${sha}\\n`)\n .join(\"\");\n return sha256Hex(lines);\n}\n\n/** Every file with its `sha256`, in the order given. Files that already carry one are kept as is. */\nexport async function hashFiles(\n files: ReadonlyArray<SectionSourceFileInput | SectionSourceFile>,\n): Promise<SectionSourceFile[]> {\n return Promise.all(\n files.map(async (f) => ({\n path: f.path,\n content: f.content,\n sha256: \"sha256\" in f && typeof f.sha256 === \"string\" ? f.sha256 : await fileSha256(f.content),\n })),\n );\n}\n\n/** A copy of `manifest` without the pull-state keys the server strips. */\nexport function stripManifestState<T extends Record<string, unknown>>(manifest: T): SectionManifest {\n const copy: Record<string, unknown> = { ...manifest };\n for (const key of MANIFEST_STATE_KEYS) delete copy[key];\n return copy as SectionManifest;\n}\n"],"mappings":";AAIO,IAAM,aAAN,cAAyB,MAAM;AAAA,EAC3B;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,QAAiB,SAAmB;AAC/D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AACF;AAaO,IAAM,qBAAN,cAAiC,WAAW;AAAA,EACxC;AAAA,EAET,YAAY,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M;AACV,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,WAAO,MAAM,CAAC,EAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EAC/C;AACA,SAAO;AACT;AAEA,eAAe,UAAU,OAAgC;AACvD,SAAO,MAAM,MAAM,OAAO,EAAE,OAAO,WAAW,QAAQ,OAAO,KAAK,CAAC,CAAC;AACtE;AAGO,SAAS,WAAW,SAAkC;AAC3D,SAAO,UAAU,OAAO;AAC1B;AAOA,eAAsB,YACpB,OACiB;AACjB,QAAM,SAAS,MAAM,UAAU,KAAK;AACpC,QAAM,QAAQ,OACX,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAU,EACtC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAE,EAC/C,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI;AAAA,EAAK,GAAG;AAAA,CAAI,EACxC,KAAK,EAAE;AACV,SAAO,UAAU,KAAK;AACxB;AAGA,eAAsB,UACpB,OAC8B;AAC9B,SAAO,QAAQ;AAAA,IACb,MAAM,IAAI,OAAO,OAAO;AAAA,MACtB,MAAM,EAAE;AAAA,MACR,SAAS,EAAE;AAAA,MACX,QAAQ,YAAY,KAAK,OAAO,EAAE,WAAW,WAAW,EAAE,SAAS,MAAM,WAAW,EAAE,OAAO;AAAA,IAC/F,EAAE;AAAA,EACJ;AACF;AAGO,SAAS,mBAAsD,UAA8B;AAClG,QAAM,OAAgC,EAAE,GAAG,SAAS;AACpD,aAAW,OAAO,oBAAqB,QAAO,KAAK,GAAG;AACtD,SAAO;AACT;","names":["contentHash"]}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@botlr/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Fetch-only Botlr client and shared types. Works in the browser, Node and edge runtimes.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/botlr-io/botlr.git",
9
+ "directory": "packages/sdk"
10
+ },
11
+ "homepage": "https://github.com/botlr-io/botlr/tree/main/packages/sdk#readme",
12
+ "keywords": [
13
+ "botlr",
14
+ "cms",
15
+ "sdk",
16
+ "headless"
17
+ ],
18
+ "type": "module",
19
+ "sideEffects": false,
20
+ "main": "./dist/index.cjs",
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "CHANGELOG.md",
34
+ "README.md"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "engines": {
40
+ "node": ">=20"
41
+ },
42
+ "devDependencies": {
43
+ "tsup": "^8.5.0",
44
+ "typescript": "~5.9.3",
45
+ "vitest": "^3.2.4"
46
+ },
47
+ "scripts": {
48
+ "build": "tsup",
49
+ "typecheck": "tsc -p tsconfig.json",
50
+ "test": "vitest run"
51
+ }
6
52
  }