andesine 0.0.1-alpha.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.
@@ -0,0 +1,458 @@
1
+ import { d as PaginationParams, e as PaginationMeta, P as Profile, J as JSONContent, C as ContentPiece, f as ContentPiecesEndpoints, g as TagsEndpoints, h as ProfileEndpoints, A as APIFetcherConfig } from './andesine.5e4b2db8.mjs';
2
+
3
+ interface ContentGroup {
4
+ /**
5
+ * Content group name
6
+ */
7
+ name: string;
8
+ /**
9
+ * Content group ID
10
+ */
11
+ id: string;
12
+ /**
13
+ * IDs of ancestor content groups, ordered from furthest to closest
14
+ */
15
+ ancestors: string[];
16
+ /**
17
+ * IDs of directly-descendant content groups
18
+ */
19
+ descendants: string[];
20
+ }
21
+ interface ContentGroupWithSubtree {
22
+ /**
23
+ * Content group name
24
+ */
25
+ name: string;
26
+ /**
27
+ * Content group ID
28
+ */
29
+ id: string;
30
+ /**
31
+ * IDs of ancestor content groups, ordered from furthest to closest
32
+ */
33
+ ancestors: string[];
34
+ /**
35
+ * Descendant content groups
36
+ */
37
+ descendants: ContentGroupWithSubtree[];
38
+ }
39
+ interface ContentGroupsEndpoints {
40
+ list<Subtree extends true | false = false>(input?: {
41
+ ancestor?: string;
42
+ subtree?: Subtree;
43
+ }): Promise<Subtree extends true ? ContentGroupWithSubtree[] : ContentGroup[]>;
44
+ get<Subtree extends true | false = false>(input: Pick<ContentGroup, "id"> & {
45
+ subtree?: Subtree;
46
+ }): Promise<Subtree extends true ? ContentGroupWithSubtree : ContentGroup>;
47
+ create(input: Omit<ContentGroup, "id" | "ancestors" | "descendants"> & {
48
+ ancestor?: string;
49
+ }): Promise<Pick<ContentGroup, "id">>;
50
+ update(input: Partial<Omit<ContentGroup, "ancestors" | "descendants">> & Pick<ContentGroup, "id">): Promise<void>;
51
+ update(input: Partial<Omit<ContentGroup, "ancestors" | "descendants" | "name">> & Pick<ContentGroup, "id"> & {
52
+ ancestor?: string;
53
+ }): Promise<void>;
54
+ delete(input: Pick<ContentGroup, "id">): Promise<void>;
55
+ }
56
+
57
+ type UIAccentColor = "energy" | "neon" | "sublime" | "sunrise" | "flow";
58
+ interface UserSettings {
59
+ /**
60
+ * UI Theme
61
+ */
62
+ uiTheme: "light" | "dark" | "auto";
63
+ /**
64
+ * Code editor theme
65
+ */
66
+ codeEditorTheme: "light" | "dark" | "auto";
67
+ /**
68
+ * UI accent color
69
+ */
70
+ accentColor: UIAccentColor;
71
+ }
72
+ interface UserSettingsEndpoints {
73
+ get(): Promise<UserSettings>;
74
+ update(input: Partial<UserSettings>): Promise<void>;
75
+ }
76
+
77
+ type WebhookEvent = "contentPieceUpdated" | "contentPieceAdded" | "contentPieceRemoved" | "contentGroupAdded" | "contentGroupRemoved" | "memberInvited" | "memberAdded" | "memberRemoved";
78
+ interface Webhook {
79
+ /**
80
+ * Webhook ID
81
+ */
82
+ id: string;
83
+ /**
84
+ * Webhook target URL
85
+ */
86
+ url: string;
87
+ /**
88
+ * Webhook name
89
+ */
90
+ name: string;
91
+ /**
92
+ * Webhook description
93
+ */
94
+ description?: string;
95
+ /**
96
+ * Webhook signing secret
97
+ */
98
+ secret?: string;
99
+ /**
100
+ * Webhook metadata containing details about the Webhook configuration
101
+ */
102
+ metadata?: {
103
+ contentGroupId: string;
104
+ };
105
+ /**
106
+ * Webhook trigger event
107
+ */
108
+ event: WebhookEvent;
109
+ }
110
+ interface WebhooksEndpoints {
111
+ get(input: Pick<Webhook, "id">): Promise<Omit<Webhook, "secret"> & {
112
+ extension?: boolean;
113
+ }>;
114
+ create(input: Omit<Webhook, "id">): Promise<Pick<Webhook, "id">>;
115
+ update(input: Partial<Omit<Webhook, "secret">> & Pick<Webhook, "id">): Promise<void>;
116
+ delete(query: Pick<Webhook, "id">): Promise<void>;
117
+ list(input: PaginationParams & {
118
+ extensionOnly?: boolean;
119
+ }): Promise<Array<Omit<Webhook, "secret"> & {
120
+ extension?: boolean;
121
+ }> & {
122
+ meta: {
123
+ pagination: PaginationMeta;
124
+ };
125
+ }>;
126
+ }
127
+
128
+ interface WorkspaceDetails {
129
+ /**
130
+ * Workspace ID
131
+ */
132
+ id: string;
133
+ /**
134
+ * Workspace name
135
+ */
136
+ name: string;
137
+ /**
138
+ * Workspace description
139
+ */
140
+ description?: string;
141
+ /**
142
+ * Workspace logo URL
143
+ */
144
+ logo?: string;
145
+ }
146
+ interface WorkspaceEndpoints {
147
+ get(): Promise<WorkspaceDetails>;
148
+ }
149
+
150
+ type RolePermission = "editContent" | "editSnippets" | "editMetadata" | "manageDashboard" | "manageTokens" | "manageWebhooks" | "manageWorkspace";
151
+ type RoleBaseType = "admin" | "viewer";
152
+ interface Role {
153
+ /**
154
+ * Role ID
155
+ */
156
+ id: string;
157
+ /**
158
+ * Role name
159
+ */
160
+ name: string;
161
+ /**
162
+ * Role description
163
+ */
164
+ description?: boolean;
165
+ /**
166
+ * Role permissions
167
+ */
168
+ permissions: RolePermission[];
169
+ /**
170
+ * Base role type (if applicable)
171
+ */
172
+ baseType?: RoleBaseType;
173
+ }
174
+ interface RolesEndpoints {
175
+ get(input: Pick<Role, "id">): Promise<Role>;
176
+ create(input: Omit<Role, "id" | "baseType">): Promise<Pick<Role, "id">>;
177
+ update(input: Partial<Omit<Role, "id" | "baseType">> & Pick<Role, "id">): Promise<void>;
178
+ delete(input: Pick<Role, "id">): Promise<void>;
179
+ list(input: PaginationParams): Promise<Role[] & {
180
+ meta: {
181
+ pagination: PaginationMeta;
182
+ };
183
+ }>;
184
+ }
185
+
186
+ type Mark = "bold" | "italic" | "strike" | "code" | "link" | "underline" | "highlight" | "subscript" | "superscript";
187
+ type Block = "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "bulletList" | "orderedList" | "taskList" | "blockquote" | "codeBlock" | "horizontalRule" | "image" | "table" | "element";
188
+ type Embed = "codepen" | "codesandbox" | "youtube";
189
+ interface WorkspaceSettings {
190
+ /**
191
+ * Workspace settings ID
192
+ */
193
+ id: string;
194
+ /**
195
+ * JSON-stringified Prettier config
196
+ */
197
+ prettierConfig: string;
198
+ /**
199
+ * List of inline formatting marks enabled in the workspace
200
+ */
201
+ marks: Mark[];
202
+ /**
203
+ * List of content blocks enabled in the workspace
204
+ */
205
+ blocks: Block[];
206
+ /**
207
+ * List of embeds enabled in the workspace
208
+ */
209
+ embeds: Embed[];
210
+ /**
211
+ * Metadata settings
212
+ */
213
+ metadata?: Partial<{
214
+ canonicalLinkPattern: string;
215
+ enabledFields: Array<"date" | "tags" | "slug" | "filename" | "members" | "canonical-link">;
216
+ }>;
217
+ /**
218
+ * Dashboard views
219
+ */
220
+ dashboardViews?: {
221
+ table?: Array<{
222
+ id: string;
223
+ width: number;
224
+ }>;
225
+ };
226
+ }
227
+ interface WorkspaceSettingsEndpoints {
228
+ get(): Promise<WorkspaceSettings>;
229
+ update(input: Partial<Omit<WorkspaceSettings, "id">>): Promise<void>;
230
+ }
231
+
232
+ interface ListedMember {
233
+ /**
234
+ * Workspace membership ID
235
+ */
236
+ id: string;
237
+ /**
238
+ * ID of the user associated with the membership
239
+ */
240
+ userId?: string;
241
+ /**
242
+ * ID of the role assigned to the membership
243
+ */
244
+ roleId: string;
245
+ /**
246
+ * Email of the pending-invite user
247
+ */
248
+ email?: string;
249
+ /**
250
+ * Name of the pending-invite user
251
+ */
252
+ name?: string;
253
+ /**
254
+ * Whether the membership is a pending invite
255
+ */
256
+ pendingInvite: boolean;
257
+ /**
258
+ * Additional details about the profile of related user
259
+ */
260
+ profile?: Pick<Profile, "fullName" | "username" | "avatar">;
261
+ }
262
+ interface ListedWorkspace {
263
+ /**
264
+ * Workspace membership ID
265
+ */
266
+ id: string;
267
+ /**
268
+ * Additional details about the related workspace
269
+ */
270
+ workspace: WorkspaceDetails;
271
+ /**
272
+ * Additional details about the role assigned in the workspace
273
+ */
274
+ role?: Pick<Role, "id" | "name">;
275
+ }
276
+ interface WorkspaceMembershipsEndpoints {
277
+ listMembers(input: PaginationParams): Promise<ListedMember[] & {
278
+ meta: {
279
+ pagination: PaginationMeta;
280
+ };
281
+ }>;
282
+ listWorkspaces(input: PaginationParams): Promise<ListedWorkspace[] & {
283
+ meta: {
284
+ pagination: PaginationMeta;
285
+ };
286
+ }>;
287
+ create(input: {
288
+ email: string;
289
+ name: string;
290
+ roleId: string;
291
+ }): Promise<void>;
292
+ update(input: {
293
+ id: string;
294
+ roleId: string;
295
+ }): Promise<void>;
296
+ delete(input: {
297
+ id: string;
298
+ }): Promise<void>;
299
+ }
300
+
301
+ type ContextValue = string | number | boolean | ContextObject | ContextArray;
302
+ interface ContextObject {
303
+ [x: string]: ContextValue;
304
+ }
305
+ interface ContextArray extends Array<ContextValue> {
306
+ }
307
+ interface Extension {
308
+ id: string;
309
+ name: string;
310
+ url: string;
311
+ config: ContextObject;
312
+ token: string;
313
+ }
314
+ interface ExtensionEndpoints {
315
+ get(): Promise<Partial<Extension>>;
316
+ getData(): Promise<ContextObject>;
317
+ updateData(input: {
318
+ data: ContextObject;
319
+ }): Promise<void>;
320
+ updateContentPieceData(input: {
321
+ contentPieceId: string;
322
+ data: ContextObject;
323
+ }): Promise<void>;
324
+ }
325
+
326
+ interface Variant {
327
+ /**
328
+ * Variant ID
329
+ */
330
+ id: string;
331
+ /**
332
+ * Variant key
333
+ */
334
+ key: string;
335
+ /**
336
+ * Variant label
337
+ */
338
+ label: string;
339
+ /**
340
+ * Variant description
341
+ */
342
+ description?: string;
343
+ }
344
+ interface VariantsEndpoints {
345
+ create(input: Omit<Variant, "id">): Promise<Pick<Variant, "id">>;
346
+ update(input: Partial<Variant> & Pick<Variant, "id">): Promise<void>;
347
+ delete(query: Pick<Variant, "id">): Promise<void>;
348
+ list(): Promise<Variant[]>;
349
+ }
350
+
351
+ interface RemoteTransformer {
352
+ /**
353
+ * Transformer ID
354
+ */
355
+ id: string;
356
+ /**
357
+ * Transformer label
358
+ */
359
+ label: string;
360
+ /**
361
+ * Transformer input URL
362
+ */
363
+ input: string;
364
+ /**
365
+ * Transformer output URL
366
+ */
367
+ output: string;
368
+ /**
369
+ * Transformer max batch size (1-1000)
370
+ */
371
+ maxBatchSize: number;
372
+ }
373
+ interface TransformersEndpoints {
374
+ create(input: Omit<RemoteTransformer, "id">): Promise<Pick<RemoteTransformer, "id">>;
375
+ delete(query: Pick<RemoteTransformer, "id">): Promise<void>;
376
+ list(): Promise<Array<RemoteTransformer & {
377
+ inUse?: boolean;
378
+ }>>;
379
+ }
380
+
381
+ type Snippet<IncludeContent extends true | false = false> = {
382
+ /**
383
+ * Snippet ID
384
+ */
385
+ id: string;
386
+ /**
387
+ * Name
388
+ */
389
+ name: string;
390
+ } & (IncludeContent extends true ? {
391
+ /**
392
+ * JSON content
393
+ */
394
+ content: JSONContent;
395
+ } : {});
396
+ interface SnippetsEndpoints {
397
+ get<IncludeContent extends true | false = false>(input: Pick<Snippet, "id"> & {
398
+ content?: IncludeContent;
399
+ }): Promise<Snippet<IncludeContent>>;
400
+ create(input: Pick<Snippet, "name"> & {
401
+ content?: string;
402
+ }): Promise<Pick<Snippet, "id">>;
403
+ update(input: Partial<Pick<Snippet, "name"> & {
404
+ content?: string;
405
+ }> & Pick<Snippet, "id">): Promise<void>;
406
+ delete(input: Pick<Snippet, "id">): Promise<void>;
407
+ list<IncludeContent extends true | false = false>(input: {
408
+ content?: IncludeContent;
409
+ }): Promise<Array<Snippet<IncludeContent>>>;
410
+ }
411
+
412
+ interface SearchResult {
413
+ contentPieceId: string;
414
+ contentPiece: Omit<ContentPiece, "content" | "coverWidth">;
415
+ breadcrumb: string[];
416
+ content: string;
417
+ }
418
+ interface ClientConfig extends APIFetcherConfig {
419
+ }
420
+ interface Client {
421
+ contentGroups: ContentGroupsEndpoints;
422
+ contentPieces: ContentPiecesEndpoints;
423
+ snippets: SnippetsEndpoints;
424
+ tags: TagsEndpoints;
425
+ profile: ProfileEndpoints;
426
+ userSettings: UserSettingsEndpoints;
427
+ webhooks: WebhooksEndpoints;
428
+ workspace: WorkspaceEndpoints;
429
+ roles: RolesEndpoints;
430
+ workspaceSettings: WorkspaceSettingsEndpoints;
431
+ workspaceMemberships: WorkspaceMembershipsEndpoints;
432
+ extension: ExtensionEndpoints;
433
+ variants: VariantsEndpoints;
434
+ transformers: TransformersEndpoints;
435
+ search(input: {
436
+ query: string;
437
+ limit?: number;
438
+ variantId?: string;
439
+ contentGroupId?: string;
440
+ contentPieceId?: string;
441
+ byTitle?: boolean;
442
+ }): Promise<SearchResult[]>;
443
+ ask(input: {
444
+ query: string;
445
+ variantId?: string;
446
+ contentGroupId?: string;
447
+ contentPieceId?: string;
448
+ onChunk?(chunk: string, content: string): void;
449
+ onEnd?(content: string): void;
450
+ onError?(error: string): void;
451
+ }): void;
452
+ useSignal(signal: AbortSignal | null): Client;
453
+ reconfigure(config: ClientConfig): Client;
454
+ getConfig(): ClientConfig;
455
+ }
456
+ declare const createClient: (config: ClientConfig) => Client;
457
+
458
+ export { type Block as B, type Client as C, type Embed as E, type ListedMember as L, type Mark as M, type Role as R, type SearchResult as S, type UIAccentColor as U, type Variant as V, type Webhook as W, type ContentGroup as a, type ContentGroupWithSubtree as b, createClient as c, type Snippet as d, type RoleBaseType as e, type RolePermission as f, type UserSettings as g, type WebhookEvent as h, type WorkspaceDetails as i, type WorkspaceSettings as j, type ListedWorkspace as k, type Extension as l };
@@ -0,0 +1,31 @@
1
+ "use strict";const marked=require("marked"),N=p=>{const s=(o,n,l)=>{const a={node:o,index:n,ancestors:l,get parent(){return l[l.length-1]||null},get children(){return"content"in o?o.content?.map((r,t)=>s(r,t,[...l,a]))||[]:[]},previousSibling(){return this.parent&&this.parent.children[this.index-1]||null},nextSibling(){return this.parent&&this.parent.children[this.index+1]||null}};return a};return s(p,0,[])},O=p=>p,S=O(p=>{const s=N(p),o=t=>{let e="";return t.node.type==="text"&&(e=t.node.text,t.node.marks?.forEach(c=>{switch(c.type){case"link":e=`[${e}](${c.attrs.href})`;break;case"bold":e=`**${e}**`;break;case"code":e=`\`${e}\``;break;case"italic":e=`_${e}_`;break;case"strike":e=`~~${e}~~`;break}})),e},n=t=>`${t.children.map(e=>e.node.type==="text"?o(e):`
2
+ `).join("")}`,l=t=>{let e="";return t.children.forEach((c,m)=>{let d=!1;const $=c.children.map(h=>(h.node.type==="tableHeader"&&(d=!0),a(h)));m===t.children.length-1?e+=`| ${$.map(h=>h.replace(/\n/g," ")).join(" | ")} |`:e+=`| ${$.map(h=>h.replace(/\n/g," ")).join(" | ")} |
3
+ `,d&&m===0&&(e+=`| ${$.map(()=>"---").join(" | ")} |
4
+ `)}),e},a=t=>t.children.map(e=>{const c=e.node.type,m=e.previousSibling(),d=["bulletList","orderedList","taskList"].includes(m?.node.type||"");switch(c){case"paragraph":return`
5
+ ${n(e)}
6
+ `;case"bulletList":case"orderedList":case"taskList":return`${d?`
7
+ `:""}${r(e)}
8
+ `;case"table":return`
9
+ ${l(e)}
10
+ `;case"horizontalRule":return`
11
+ ---
12
+ `;case"image":return`
13
+ ![${e.node.attrs?.alt||""}](${e.node.attrs?.src||""})
14
+ `;case"heading":return`
15
+ ${"#".repeat(e.node.attrs?.level||1)} ${n(e)}
16
+ `;case"codeBlock":return`
17
+ \`\`\`${e.node.attrs?.lang||""}
18
+ ${n(e)}
19
+ \`\`\`
20
+ `;case"element":return`
21
+ ${a(e)}
22
+ `;case"blockquote":return`
23
+ ${a(e).split(`
24
+ `).map($=>`> ${$}`).join(`
25
+ `)}
26
+ `;default:return""}}).join("").trim(),r=t=>t.children.map(e=>({content:a(e),node:e.node})).map(({content:e,node:c},m)=>{let d="",$=0;return t.node.type==="taskList"&&c.type==="taskItem"&&(d=`${c.attrs?.checked?"- [x] ":"- [ ] "} `,$=2),t.node.type==="orderedList"&&(d=`${(t.node.attrs?.start||1)+m}. `,$=d.length),t.node.type==="bulletList"&&(d="- ",$=d.length),e.split(`
27
+ `).map((h,b)=>b===0?`${d}${h}`:`${" ".repeat($)}${h}`).join(`
28
+ `)}).join(`
29
+ `);return a(s).trim()}),J=O(p=>{const s=N(p),o=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),n=r=>{const t=[];return Object.entries(r).forEach(([e,c])=>{if(typeof c=="boolean"){t.push(`${e}`);return}typeof c<"u"&&(`${c}`.includes('"')?t.push(`${e}='${c}'`):t.push(`${e}="${c}"`))}),t.join(" ")},l=r=>{let t="";return r.node.type==="text"&&(t=r.node.text,r.node.marks?.forEach(e=>{switch(e.type){case"link":t=`<a href="${e.attrs.href}">${t}</a>`;break;case"bold":t=`<strong>${t}</strong>`;break;case"code":t=`<code>${o(t)}</code>`;break;case"italic":t=`<em>${t}</em>`;break;case"strike":t=`<s>${t}</s>`;break;case"highlight":t=`<mark>${t}</mark>`;break;case"superscript":t=`<sup>${t}</sup>`;break;case"subscript":t=`<sub>${t}</sub>`;break}})),t},a=r=>{switch(r.node.type){case"doc":return r.children.map(a).join("");case"text":return l(r);case"paragraph":return`<p>${r.children.map(t=>t.node.type==="text"?l(t):"<br/>").join("")}</p>`;case"bulletList":return`<ul>${r.children.map(a).join("")}</ul>`;case"orderedList":return`<ol start="${r.node.attrs.start}">${r.children.map(a).join("")}</ol>`;case"taskList":return`<ul data-type="taskList">${r.children.map(a).join("")}</ul>`;case"listItem":return`<li>${r.children.map(a).join("")}</li>`;case"taskItem":return`<li data-type="taskItem"><label><input ${n({type:"checkbox",...r.node.attrs.checked&&{checked:!0}})} />${r.children.map(a).join("")}</label></li>`;case"element":return`<div ${n({"data-type":r.node.attrs?.type,"data-props":JSON.stringify(r.node.attrs?.props)})}>${r.children.map(a).join("")}</div>`;case"blockquote":return`<blockquote>${r.children.map(a).join("")}</blockquote>`;case"heading":return`<h${r.node.attrs.level}>${r.children.map(a).join("")}</h${r.node.attrs.level}>`;case"codeBlock":return`<pre ${n({lang:r.node.attrs?.lang})}><code>${o(r.children.map(a).join(""))}</code></pre>`;case"image":return`<img ${n({src:r.node.attrs?.src,alt:r.node.attrs?.alt})}/>`;case"embed":return`<iframe ${n({src:r.node.attrs?.src,"data-type":r.node.attrs?.embed})}></iframe>`;case"horizontalRule":return"<hr/>";case"table":return`<table>${r.children.map(a).join("")}</table>`;case"tableRow":return`<tr>${r.children.map(a).join("")}</tr>`;case"tableCell":return`<td>${r.children.flatMap(a).join("")}</td>`;case"tableHeader":return`<th>${r.children.flatMap(a).join("")}</th>`;default:return""}};return a(s)}),i=p=>p,u=i(p=>({content:new marked.Marked({async:!1,renderer:{paragraph(s){return s.startsWith("<img")?`${s}
30
+ `:`<p>${s}</p>`},image(s,o,n){return`<img src="${(s||"").replace(/^(?:\[.*\]\((.*)\))|(?:(.*))$/,(l,a,r)=>a||r)}" alt="${n}">`},listitem(s,o,n){return`<li${o?' data-type="taskItem"':""}${n?' data-checked="true"':""}>${s.replace(/<br><(img|p|pre|blockquote|ul|ol|table)\s/g,"<$1 ")}</li>`},list(s,o,n){const l=o?"ol":"ul",a=o&&n!==1?` start="${n}"`:"",r=s.includes('data-type="taskItem"')?' data-type="taskList"':"";return`<${l}${a}${r}>${s}</${l}>
31
+ `}},gfm:!0,breaks:!0}).parse(p)}));exports.createContentWalker=N,exports.createInputTransformer=i,exports.createOutputTransformer=O,exports.gfmInputTransformer=u,exports.gfmOutputTransformer=S,exports.htmlOutputTransformer=J;