@takeal/cusfront-sdk 0.3.20 → 0.6.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/CHANGELOG.md +137 -2
- package/README.md +407 -8
- package/dist/analytics.cjs +438 -0
- package/dist/analytics.cjs.map +1 -0
- package/dist/analytics.d.cts +129 -0
- package/dist/analytics.d.ts +129 -0
- package/dist/analytics.js +424 -0
- package/dist/analytics.js.map +1 -0
- package/dist/cards-B_aNY35J.d.cts +514 -0
- package/dist/cards-Ba1wZttb.d.ts +514 -0
- package/dist/deposits-BEc8U80M.d.cts +310 -0
- package/dist/deposits-DScyT_D9.d.ts +310 -0
- package/dist/{devices-DP_hxwmW.d.ts → devices-B_YveTl9.d.ts} +1 -1
- package/dist/{devices-C3JHi2Hi.d.cts → devices-a5Z45Mx_.d.cts} +1 -1
- package/dist/{http-B-OQwMYn.d.cts → http-DeANAoTs.d.cts} +11 -3
- package/dist/{http-B-OQwMYn.d.ts → http-DeANAoTs.d.ts} +11 -3
- package/dist/index.cjs +978 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -13
- package/dist/index.d.ts +101 -13
- package/dist/index.js +963 -102
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +2 -8
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +12 -5
- package/dist/react/index.d.ts +12 -5
- package/dist/react/index.js +2 -8
- package/dist/react/index.js.map +1 -1
- package/dist/resources/attribution.cjs +82 -0
- package/dist/resources/attribution.cjs.map +1 -0
- package/dist/resources/attribution.d.cts +100 -0
- package/dist/resources/attribution.d.ts +100 -0
- package/dist/resources/attribution.js +78 -0
- package/dist/resources/attribution.js.map +1 -0
- package/dist/resources/auth.cjs +81 -15
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +53 -6
- package/dist/resources/auth.d.ts +53 -6
- package/dist/resources/auth.js +81 -15
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/balance.d.cts +1 -1
- package/dist/resources/balance.d.ts +1 -1
- package/dist/resources/blog.cjs.map +1 -1
- package/dist/resources/blog.d.cts +8 -1
- package/dist/resources/blog.d.ts +8 -1
- package/dist/resources/blog.js.map +1 -1
- package/dist/resources/bonus.cjs +28 -0
- package/dist/resources/bonus.cjs.map +1 -0
- package/dist/resources/bonus.d.cts +121 -0
- package/dist/resources/bonus.d.ts +121 -0
- package/dist/resources/bonus.js +26 -0
- package/dist/resources/bonus.js.map +1 -0
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.cjs +55 -28
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -347
- package/dist/resources/cards.d.ts +2 -347
- package/dist/resources/cards.js +55 -29
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/codes.cjs +20 -0
- package/dist/resources/codes.cjs.map +1 -0
- package/dist/resources/codes.d.cts +100 -0
- package/dist/resources/codes.d.ts +100 -0
- package/dist/resources/codes.js +18 -0
- package/dist/resources/codes.js.map +1 -0
- package/dist/resources/deposits.cjs +32 -7
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +3 -176
- package/dist/resources/deposits.d.ts +3 -176
- package/dist/resources/deposits.js +32 -7
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/devices.cjs +3 -1
- package/dist/resources/devices.cjs.map +1 -1
- package/dist/resources/devices.d.cts +2 -2
- package/dist/resources/devices.d.ts +2 -2
- package/dist/resources/devices.js +3 -1
- package/dist/resources/devices.js.map +1 -1
- package/dist/resources/documents.cjs +66 -0
- package/dist/resources/documents.cjs.map +1 -0
- package/dist/resources/documents.d.cts +212 -0
- package/dist/resources/documents.d.ts +212 -0
- package/dist/resources/documents.js +64 -0
- package/dist/resources/documents.js.map +1 -0
- package/dist/resources/funding-options.cjs +16 -0
- package/dist/resources/funding-options.cjs.map +1 -0
- package/dist/resources/funding-options.d.cts +3 -0
- package/dist/resources/funding-options.d.ts +3 -0
- package/dist/resources/funding-options.js +14 -0
- package/dist/resources/funding-options.js.map +1 -0
- package/dist/resources/history.cjs +33 -0
- package/dist/resources/history.cjs.map +1 -0
- package/dist/resources/history.d.cts +95 -0
- package/dist/resources/history.d.ts +95 -0
- package/dist/resources/history.js +31 -0
- package/dist/resources/history.js.map +1 -0
- package/dist/resources/me.d.cts +3 -1
- package/dist/resources/me.d.ts +3 -1
- package/dist/resources/notifications.d.cts +1 -1
- package/dist/resources/notifications.d.ts +1 -1
- package/dist/resources/push.cjs +3 -1
- package/dist/resources/push.cjs.map +1 -1
- package/dist/resources/push.d.cts +1 -1
- package/dist/resources/push.d.ts +1 -1
- package/dist/resources/push.js +3 -1
- package/dist/resources/push.js.map +1 -1
- package/dist/resources/referral.cjs +16 -0
- package/dist/resources/referral.cjs.map +1 -0
- package/dist/resources/referral.d.cts +58 -0
- package/dist/resources/referral.d.ts +58 -0
- package/dist/resources/referral.js +14 -0
- package/dist/resources/referral.js.map +1 -0
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscription.cjs +24 -0
- package/dist/resources/subscription.cjs.map +1 -0
- package/dist/resources/subscription.d.cts +48 -0
- package/dist/resources/subscription.d.ts +48 -0
- package/dist/resources/subscription.js +22 -0
- package/dist/resources/subscription.js.map +1 -0
- package/dist/resources/subscriptions.d.cts +1 -1
- package/dist/resources/subscriptions.d.ts +1 -1
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +495 -111
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +12 -5
- package/dist/telegram.d.ts +12 -5
- package/dist/telegram.js +495 -111
- package/dist/telegram.js.map +1 -1
- package/package.json +57 -5
- package/dist/customer-CoxPwe5o.d.cts +0 -32
- package/dist/customer-CoxPwe5o.d.ts +0 -32
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/documents.ts"],"names":[],"mappings":"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","file":"documents.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Documents resource: `client.documents.*`.\n *\n * Everything the operators write lives in one tree: blog posts, the\n * knowledge base, legal pages, internal notes. Every call here works before\n * the user signs in and shows more once they have: a signed-in user sees the\n * documents marked for users, staff see theirs. The SDK sends the session\n * token when it has one, so the same call serves the public site and the\n * signed-in cabinet.\n *\n * A document arrives as a list of typed blocks. `body_blocks` is flat; map\n * each `type` onto your own component and the document inherits your site's\n * styling. `body_markdown` is there too if you'd rather run your own renderer.\n *\n * ```ts\n * // The knowledge base: folders and articles for a sidebar.\n * const tree = await client.documents.tree({ category: \"knowledge-base\" });\n *\n * // One article, with the text in force today.\n * const doc = await client.documents.get(\"how-to-top-up\");\n *\n * // A legal page as it read on a given day, and its history.\n * const then = await client.documents.get(\"offer\", { at: \"2026-01-01T00:00:00Z\" });\n * const versions = await client.documents.versions(\"offer\");\n *\n * doc.body_blocks.map((b) => {\n * switch (b.type) {\n * case \"heading\": return <Heading level={b.level}>{b.text}</Heading>;\n * case \"paragraph\": return <P>{b.text}</P>;\n * case \"image\": return <Figure src={client.assetUrl(b.url)} alt={b.alt} caption={b.caption} />;\n * case \"list\": return <List ordered={b.ordered} items={b.items} />;\n * case \"quote\": return <Quote>{b.text}</Quote>;\n * case \"code\": return <Code lang={b.lang}>{b.text}</Code>;\n * case \"divider\": return <Hr />;\n * }\n * });\n * ```\n *\n * Links between documents come out as site paths: `/blog/<slug>` for a post,\n * `/docs/<slug>` for everything else (`site_path` on each document says which\n * one it is). Route those two prefixes to your document pages and links keep\n * working after a document is renamed or moved.\n */\n\n/** Category keys: the four folders at the top of the tree. */\nexport type DocumentCategory = \"blog\" | \"knowledge-base\" | \"legal\" | \"internal\";\n\n/** Who may read a document. */\nexport type DocumentScope = \"public\" | \"users\" | \"staff\" | \"operators\";\n\n/** One node of a document body. Discriminated on `type`. */\nexport type DocumentBlock =\n | { type: \"heading\"; level: number; text: string }\n | { type: \"paragraph\"; text: string }\n | { type: \"image\"; url: string; alt?: string; caption?: string }\n | { type: \"list\"; ordered: boolean; items: string[] }\n | { type: \"quote\"; text: string }\n | { type: \"code\"; lang?: string; text: string }\n | { type: \"divider\" };\n\n/** One step of the folder trail, root first. */\nexport interface DocumentPathStep {\n id: string;\n key: string;\n title: string;\n}\n\nexport interface Document {\n /** Permanent address. Link by this; it survives renames and moves. */\n slug: string;\n title: string;\n /** Teaser for cards; falls back to the first paragraph. */\n excerpt: string;\n /** Image URL, relative to the API origin. Absent when no cover is set. */\n cover_url?: string;\n /** Raw Markdown, for consumers that bring their own renderer. */\n body_markdown: string;\n /** The recommended input for rendering; see the module docs. */\n body_blocks: DocumentBlock[];\n tags: string[];\n /** Present only when the document declares one. */\n locale?: string;\n /** Rough read time in minutes (minimum 1). */\n reading_minutes: number;\n published_at: string | null;\n updated_at: string;\n /** Category the document sits in. */\n category: DocumentCategory | string;\n /** Folder trail, root first. */\n path: DocumentPathStep[];\n /** Who may read it. */\n read_scope: DocumentScope;\n /** Number of the text shown. */\n version: number;\n /** When the text shown took effect. */\n effective_from: string;\n /** Path under the site root where this document is read. */\n site_path: string;\n}\n\nexport interface DocumentListInput {\n /** Category key. */\n category?: DocumentCategory | string;\n /** Only documents in this folder and the folders under it. */\n folderId?: string;\n /** Only documents carrying this tag. */\n tag?: string;\n /** Only documents in this locale. */\n locale?: string;\n /** Words to search for in the title and the text. */\n q?: string;\n /** 1-based. Default 1. */\n page?: number;\n /** 1..=50. Default 10. */\n perPage?: number;\n}\n\nexport interface DocumentList {\n documents: Document[];\n total: number;\n page: number;\n per_page: number;\n}\n\n/** A folder as it appears in the navigation tree. */\nexport interface DocumentFolder {\n id: string;\n parent_id: string | null;\n key: string;\n title: string;\n description: string;\n position: number;\n}\n\n/** A document as it appears in the navigation tree: enough for a link. */\nexport interface DocumentTreeEntry {\n folder_id: string;\n slug: string;\n title: string;\n excerpt: string;\n tags: string[];\n position: number;\n updated_at: string;\n site_path: string;\n}\n\nexport interface DocumentTree {\n /** Folders with at least one document you may read under them, plus the categories. */\n folders: DocumentFolder[];\n /** Published documents you may read, in folder order. */\n documents: DocumentTreeEntry[];\n}\n\n/** One saved text of a document, without the text itself. */\nexport interface DocumentVersionSummary {\n version: number;\n title: string;\n /** When this text took effect. */\n effective_from: string;\n /** What changed, in the editor's words. Often empty. */\n note: string;\n changed_at: string;\n}\n\nexport interface DocumentTag {\n tag: string;\n /** Published documents you may read that carry it. */\n count: number;\n}\n\nexport class DocumentsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Published documents you may read, paged. The blog comes newest first,\n * other categories in the order set by the editors.\n */\n async list(input: DocumentListInput = {}): Promise<DocumentList> {\n const q = new URLSearchParams();\n if (input.category) q.set(\"category\", input.category);\n if (input.folderId) q.set(\"folder_id\", input.folderId);\n if (input.tag) q.set(\"tag\", input.tag);\n if (input.locale) q.set(\"locale\", input.locale);\n if (input.q) q.set(\"q\", input.q);\n if (input.page) q.set(\"page\", String(input.page));\n if (input.perPage) q.set(\"per_page\", String(input.perPage));\n const qs = q.toString();\n return this.http.get<DocumentList>(`/documents${qs ? `?${qs}` : \"\"}`);\n }\n\n /** Folders and documents for a sidebar or a table of contents. */\n async tree(input: { category?: DocumentCategory | string } = {}): Promise<DocumentTree> {\n const qs = input.category ? `?category=${encodeURIComponent(input.category)}` : \"\";\n return this.http.get<DocumentTree>(`/documents/tree${qs}`);\n }\n\n /** Every tag on a document you may read, most used first. */\n async tags(): Promise<DocumentTag[]> {\n return this.http.get<DocumentTag[]>(\"/documents/tags\");\n }\n\n /**\n * One document by its address. Without `at`, the text in force now; with\n * `at` (an ISO 8601 moment), the text that was in force then. Unknown\n * addresses and documents above your level are a 404.\n */\n async get(slug: string, opts: { at?: string | Date } = {}): Promise<Document> {\n const at = opts.at instanceof Date ? opts.at.toISOString() : opts.at;\n const qs = at ? `?at=${encodeURIComponent(at)}` : \"\";\n return this.http.get<Document>(`/documents/${encodeURIComponent(slug)}${qs}`);\n }\n\n /** Every saved text of a document, newest first, with the date each took effect. */\n async versions(slug: string): Promise<DocumentVersionSummary[]> {\n return this.http.get<DocumentVersionSummary[]>(\n `/documents/${encodeURIComponent(slug)}/versions`,\n );\n }\n\n /** The document as it read in one version. */\n async version(slug: string, version: number): Promise<Document> {\n return this.http.get<Document>(`/documents/${encodeURIComponent(slug)}/versions/${version}`);\n }\n\n /**\n * Absolute URL for an image path returned inside a document (`cover_url`,\n * or an image block's `url`). Handy when the app renders on a different\n * origin than the API.\n */\n imageUrl(baseUrl: string, path: string): string {\n if (/^https?:\\/\\//i.test(path)) return path;\n return `${baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { H as HttpClient } from '../http-DeANAoTs.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Documents resource: `client.documents.*`.
|
|
5
|
+
*
|
|
6
|
+
* Everything the operators write lives in one tree: blog posts, the
|
|
7
|
+
* knowledge base, legal pages, internal notes. Every call here works before
|
|
8
|
+
* the user signs in and shows more once they have: a signed-in user sees the
|
|
9
|
+
* documents marked for users, staff see theirs. The SDK sends the session
|
|
10
|
+
* token when it has one, so the same call serves the public site and the
|
|
11
|
+
* signed-in cabinet.
|
|
12
|
+
*
|
|
13
|
+
* A document arrives as a list of typed blocks. `body_blocks` is flat; map
|
|
14
|
+
* each `type` onto your own component and the document inherits your site's
|
|
15
|
+
* styling. `body_markdown` is there too if you'd rather run your own renderer.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* // The knowledge base: folders and articles for a sidebar.
|
|
19
|
+
* const tree = await client.documents.tree({ category: "knowledge-base" });
|
|
20
|
+
*
|
|
21
|
+
* // One article, with the text in force today.
|
|
22
|
+
* const doc = await client.documents.get("how-to-top-up");
|
|
23
|
+
*
|
|
24
|
+
* // A legal page as it read on a given day, and its history.
|
|
25
|
+
* const then = await client.documents.get("offer", { at: "2026-01-01T00:00:00Z" });
|
|
26
|
+
* const versions = await client.documents.versions("offer");
|
|
27
|
+
*
|
|
28
|
+
* doc.body_blocks.map((b) => {
|
|
29
|
+
* switch (b.type) {
|
|
30
|
+
* case "heading": return <Heading level={b.level}>{b.text}</Heading>;
|
|
31
|
+
* case "paragraph": return <P>{b.text}</P>;
|
|
32
|
+
* case "image": return <Figure src={client.assetUrl(b.url)} alt={b.alt} caption={b.caption} />;
|
|
33
|
+
* case "list": return <List ordered={b.ordered} items={b.items} />;
|
|
34
|
+
* case "quote": return <Quote>{b.text}</Quote>;
|
|
35
|
+
* case "code": return <Code lang={b.lang}>{b.text}</Code>;
|
|
36
|
+
* case "divider": return <Hr />;
|
|
37
|
+
* }
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Links between documents come out as site paths: `/blog/<slug>` for a post,
|
|
42
|
+
* `/docs/<slug>` for everything else (`site_path` on each document says which
|
|
43
|
+
* one it is). Route those two prefixes to your document pages and links keep
|
|
44
|
+
* working after a document is renamed or moved.
|
|
45
|
+
*/
|
|
46
|
+
/** Category keys: the four folders at the top of the tree. */
|
|
47
|
+
type DocumentCategory = "blog" | "knowledge-base" | "legal" | "internal";
|
|
48
|
+
/** Who may read a document. */
|
|
49
|
+
type DocumentScope = "public" | "users" | "staff" | "operators";
|
|
50
|
+
/** One node of a document body. Discriminated on `type`. */
|
|
51
|
+
type DocumentBlock = {
|
|
52
|
+
type: "heading";
|
|
53
|
+
level: number;
|
|
54
|
+
text: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: "paragraph";
|
|
57
|
+
text: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "image";
|
|
60
|
+
url: string;
|
|
61
|
+
alt?: string;
|
|
62
|
+
caption?: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "list";
|
|
65
|
+
ordered: boolean;
|
|
66
|
+
items: string[];
|
|
67
|
+
} | {
|
|
68
|
+
type: "quote";
|
|
69
|
+
text: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: "code";
|
|
72
|
+
lang?: string;
|
|
73
|
+
text: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "divider";
|
|
76
|
+
};
|
|
77
|
+
/** One step of the folder trail, root first. */
|
|
78
|
+
interface DocumentPathStep {
|
|
79
|
+
id: string;
|
|
80
|
+
key: string;
|
|
81
|
+
title: string;
|
|
82
|
+
}
|
|
83
|
+
interface Document {
|
|
84
|
+
/** Permanent address. Link by this; it survives renames and moves. */
|
|
85
|
+
slug: string;
|
|
86
|
+
title: string;
|
|
87
|
+
/** Teaser for cards; falls back to the first paragraph. */
|
|
88
|
+
excerpt: string;
|
|
89
|
+
/** Image URL, relative to the API origin. Absent when no cover is set. */
|
|
90
|
+
cover_url?: string;
|
|
91
|
+
/** Raw Markdown, for consumers that bring their own renderer. */
|
|
92
|
+
body_markdown: string;
|
|
93
|
+
/** The recommended input for rendering; see the module docs. */
|
|
94
|
+
body_blocks: DocumentBlock[];
|
|
95
|
+
tags: string[];
|
|
96
|
+
/** Present only when the document declares one. */
|
|
97
|
+
locale?: string;
|
|
98
|
+
/** Rough read time in minutes (minimum 1). */
|
|
99
|
+
reading_minutes: number;
|
|
100
|
+
published_at: string | null;
|
|
101
|
+
updated_at: string;
|
|
102
|
+
/** Category the document sits in. */
|
|
103
|
+
category: DocumentCategory | string;
|
|
104
|
+
/** Folder trail, root first. */
|
|
105
|
+
path: DocumentPathStep[];
|
|
106
|
+
/** Who may read it. */
|
|
107
|
+
read_scope: DocumentScope;
|
|
108
|
+
/** Number of the text shown. */
|
|
109
|
+
version: number;
|
|
110
|
+
/** When the text shown took effect. */
|
|
111
|
+
effective_from: string;
|
|
112
|
+
/** Path under the site root where this document is read. */
|
|
113
|
+
site_path: string;
|
|
114
|
+
}
|
|
115
|
+
interface DocumentListInput {
|
|
116
|
+
/** Category key. */
|
|
117
|
+
category?: DocumentCategory | string;
|
|
118
|
+
/** Only documents in this folder and the folders under it. */
|
|
119
|
+
folderId?: string;
|
|
120
|
+
/** Only documents carrying this tag. */
|
|
121
|
+
tag?: string;
|
|
122
|
+
/** Only documents in this locale. */
|
|
123
|
+
locale?: string;
|
|
124
|
+
/** Words to search for in the title and the text. */
|
|
125
|
+
q?: string;
|
|
126
|
+
/** 1-based. Default 1. */
|
|
127
|
+
page?: number;
|
|
128
|
+
/** 1..=50. Default 10. */
|
|
129
|
+
perPage?: number;
|
|
130
|
+
}
|
|
131
|
+
interface DocumentList {
|
|
132
|
+
documents: Document[];
|
|
133
|
+
total: number;
|
|
134
|
+
page: number;
|
|
135
|
+
per_page: number;
|
|
136
|
+
}
|
|
137
|
+
/** A folder as it appears in the navigation tree. */
|
|
138
|
+
interface DocumentFolder {
|
|
139
|
+
id: string;
|
|
140
|
+
parent_id: string | null;
|
|
141
|
+
key: string;
|
|
142
|
+
title: string;
|
|
143
|
+
description: string;
|
|
144
|
+
position: number;
|
|
145
|
+
}
|
|
146
|
+
/** A document as it appears in the navigation tree: enough for a link. */
|
|
147
|
+
interface DocumentTreeEntry {
|
|
148
|
+
folder_id: string;
|
|
149
|
+
slug: string;
|
|
150
|
+
title: string;
|
|
151
|
+
excerpt: string;
|
|
152
|
+
tags: string[];
|
|
153
|
+
position: number;
|
|
154
|
+
updated_at: string;
|
|
155
|
+
site_path: string;
|
|
156
|
+
}
|
|
157
|
+
interface DocumentTree {
|
|
158
|
+
/** Folders with at least one document you may read under them, plus the categories. */
|
|
159
|
+
folders: DocumentFolder[];
|
|
160
|
+
/** Published documents you may read, in folder order. */
|
|
161
|
+
documents: DocumentTreeEntry[];
|
|
162
|
+
}
|
|
163
|
+
/** One saved text of a document, without the text itself. */
|
|
164
|
+
interface DocumentVersionSummary {
|
|
165
|
+
version: number;
|
|
166
|
+
title: string;
|
|
167
|
+
/** When this text took effect. */
|
|
168
|
+
effective_from: string;
|
|
169
|
+
/** What changed, in the editor's words. Often empty. */
|
|
170
|
+
note: string;
|
|
171
|
+
changed_at: string;
|
|
172
|
+
}
|
|
173
|
+
interface DocumentTag {
|
|
174
|
+
tag: string;
|
|
175
|
+
/** Published documents you may read that carry it. */
|
|
176
|
+
count: number;
|
|
177
|
+
}
|
|
178
|
+
declare class DocumentsResource {
|
|
179
|
+
private readonly http;
|
|
180
|
+
constructor(http: HttpClient);
|
|
181
|
+
/**
|
|
182
|
+
* Published documents you may read, paged. The blog comes newest first,
|
|
183
|
+
* other categories in the order set by the editors.
|
|
184
|
+
*/
|
|
185
|
+
list(input?: DocumentListInput): Promise<DocumentList>;
|
|
186
|
+
/** Folders and documents for a sidebar or a table of contents. */
|
|
187
|
+
tree(input?: {
|
|
188
|
+
category?: DocumentCategory | string;
|
|
189
|
+
}): Promise<DocumentTree>;
|
|
190
|
+
/** Every tag on a document you may read, most used first. */
|
|
191
|
+
tags(): Promise<DocumentTag[]>;
|
|
192
|
+
/**
|
|
193
|
+
* One document by its address. Without `at`, the text in force now; with
|
|
194
|
+
* `at` (an ISO 8601 moment), the text that was in force then. Unknown
|
|
195
|
+
* addresses and documents above your level are a 404.
|
|
196
|
+
*/
|
|
197
|
+
get(slug: string, opts?: {
|
|
198
|
+
at?: string | Date;
|
|
199
|
+
}): Promise<Document>;
|
|
200
|
+
/** Every saved text of a document, newest first, with the date each took effect. */
|
|
201
|
+
versions(slug: string): Promise<DocumentVersionSummary[]>;
|
|
202
|
+
/** The document as it read in one version. */
|
|
203
|
+
version(slug: string, version: number): Promise<Document>;
|
|
204
|
+
/**
|
|
205
|
+
* Absolute URL for an image path returned inside a document (`cover_url`,
|
|
206
|
+
* or an image block's `url`). Handy when the app renders on a different
|
|
207
|
+
* origin than the API.
|
|
208
|
+
*/
|
|
209
|
+
imageUrl(baseUrl: string, path: string): string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { type Document, type DocumentBlock, type DocumentCategory, type DocumentFolder, type DocumentList, type DocumentListInput, type DocumentPathStep, type DocumentScope, type DocumentTag, type DocumentTree, type DocumentTreeEntry, type DocumentVersionSummary, DocumentsResource };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { H as HttpClient } from '../http-DeANAoTs.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Documents resource: `client.documents.*`.
|
|
5
|
+
*
|
|
6
|
+
* Everything the operators write lives in one tree: blog posts, the
|
|
7
|
+
* knowledge base, legal pages, internal notes. Every call here works before
|
|
8
|
+
* the user signs in and shows more once they have: a signed-in user sees the
|
|
9
|
+
* documents marked for users, staff see theirs. The SDK sends the session
|
|
10
|
+
* token when it has one, so the same call serves the public site and the
|
|
11
|
+
* signed-in cabinet.
|
|
12
|
+
*
|
|
13
|
+
* A document arrives as a list of typed blocks. `body_blocks` is flat; map
|
|
14
|
+
* each `type` onto your own component and the document inherits your site's
|
|
15
|
+
* styling. `body_markdown` is there too if you'd rather run your own renderer.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* // The knowledge base: folders and articles for a sidebar.
|
|
19
|
+
* const tree = await client.documents.tree({ category: "knowledge-base" });
|
|
20
|
+
*
|
|
21
|
+
* // One article, with the text in force today.
|
|
22
|
+
* const doc = await client.documents.get("how-to-top-up");
|
|
23
|
+
*
|
|
24
|
+
* // A legal page as it read on a given day, and its history.
|
|
25
|
+
* const then = await client.documents.get("offer", { at: "2026-01-01T00:00:00Z" });
|
|
26
|
+
* const versions = await client.documents.versions("offer");
|
|
27
|
+
*
|
|
28
|
+
* doc.body_blocks.map((b) => {
|
|
29
|
+
* switch (b.type) {
|
|
30
|
+
* case "heading": return <Heading level={b.level}>{b.text}</Heading>;
|
|
31
|
+
* case "paragraph": return <P>{b.text}</P>;
|
|
32
|
+
* case "image": return <Figure src={client.assetUrl(b.url)} alt={b.alt} caption={b.caption} />;
|
|
33
|
+
* case "list": return <List ordered={b.ordered} items={b.items} />;
|
|
34
|
+
* case "quote": return <Quote>{b.text}</Quote>;
|
|
35
|
+
* case "code": return <Code lang={b.lang}>{b.text}</Code>;
|
|
36
|
+
* case "divider": return <Hr />;
|
|
37
|
+
* }
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Links between documents come out as site paths: `/blog/<slug>` for a post,
|
|
42
|
+
* `/docs/<slug>` for everything else (`site_path` on each document says which
|
|
43
|
+
* one it is). Route those two prefixes to your document pages and links keep
|
|
44
|
+
* working after a document is renamed or moved.
|
|
45
|
+
*/
|
|
46
|
+
/** Category keys: the four folders at the top of the tree. */
|
|
47
|
+
type DocumentCategory = "blog" | "knowledge-base" | "legal" | "internal";
|
|
48
|
+
/** Who may read a document. */
|
|
49
|
+
type DocumentScope = "public" | "users" | "staff" | "operators";
|
|
50
|
+
/** One node of a document body. Discriminated on `type`. */
|
|
51
|
+
type DocumentBlock = {
|
|
52
|
+
type: "heading";
|
|
53
|
+
level: number;
|
|
54
|
+
text: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: "paragraph";
|
|
57
|
+
text: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "image";
|
|
60
|
+
url: string;
|
|
61
|
+
alt?: string;
|
|
62
|
+
caption?: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "list";
|
|
65
|
+
ordered: boolean;
|
|
66
|
+
items: string[];
|
|
67
|
+
} | {
|
|
68
|
+
type: "quote";
|
|
69
|
+
text: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: "code";
|
|
72
|
+
lang?: string;
|
|
73
|
+
text: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "divider";
|
|
76
|
+
};
|
|
77
|
+
/** One step of the folder trail, root first. */
|
|
78
|
+
interface DocumentPathStep {
|
|
79
|
+
id: string;
|
|
80
|
+
key: string;
|
|
81
|
+
title: string;
|
|
82
|
+
}
|
|
83
|
+
interface Document {
|
|
84
|
+
/** Permanent address. Link by this; it survives renames and moves. */
|
|
85
|
+
slug: string;
|
|
86
|
+
title: string;
|
|
87
|
+
/** Teaser for cards; falls back to the first paragraph. */
|
|
88
|
+
excerpt: string;
|
|
89
|
+
/** Image URL, relative to the API origin. Absent when no cover is set. */
|
|
90
|
+
cover_url?: string;
|
|
91
|
+
/** Raw Markdown, for consumers that bring their own renderer. */
|
|
92
|
+
body_markdown: string;
|
|
93
|
+
/** The recommended input for rendering; see the module docs. */
|
|
94
|
+
body_blocks: DocumentBlock[];
|
|
95
|
+
tags: string[];
|
|
96
|
+
/** Present only when the document declares one. */
|
|
97
|
+
locale?: string;
|
|
98
|
+
/** Rough read time in minutes (minimum 1). */
|
|
99
|
+
reading_minutes: number;
|
|
100
|
+
published_at: string | null;
|
|
101
|
+
updated_at: string;
|
|
102
|
+
/** Category the document sits in. */
|
|
103
|
+
category: DocumentCategory | string;
|
|
104
|
+
/** Folder trail, root first. */
|
|
105
|
+
path: DocumentPathStep[];
|
|
106
|
+
/** Who may read it. */
|
|
107
|
+
read_scope: DocumentScope;
|
|
108
|
+
/** Number of the text shown. */
|
|
109
|
+
version: number;
|
|
110
|
+
/** When the text shown took effect. */
|
|
111
|
+
effective_from: string;
|
|
112
|
+
/** Path under the site root where this document is read. */
|
|
113
|
+
site_path: string;
|
|
114
|
+
}
|
|
115
|
+
interface DocumentListInput {
|
|
116
|
+
/** Category key. */
|
|
117
|
+
category?: DocumentCategory | string;
|
|
118
|
+
/** Only documents in this folder and the folders under it. */
|
|
119
|
+
folderId?: string;
|
|
120
|
+
/** Only documents carrying this tag. */
|
|
121
|
+
tag?: string;
|
|
122
|
+
/** Only documents in this locale. */
|
|
123
|
+
locale?: string;
|
|
124
|
+
/** Words to search for in the title and the text. */
|
|
125
|
+
q?: string;
|
|
126
|
+
/** 1-based. Default 1. */
|
|
127
|
+
page?: number;
|
|
128
|
+
/** 1..=50. Default 10. */
|
|
129
|
+
perPage?: number;
|
|
130
|
+
}
|
|
131
|
+
interface DocumentList {
|
|
132
|
+
documents: Document[];
|
|
133
|
+
total: number;
|
|
134
|
+
page: number;
|
|
135
|
+
per_page: number;
|
|
136
|
+
}
|
|
137
|
+
/** A folder as it appears in the navigation tree. */
|
|
138
|
+
interface DocumentFolder {
|
|
139
|
+
id: string;
|
|
140
|
+
parent_id: string | null;
|
|
141
|
+
key: string;
|
|
142
|
+
title: string;
|
|
143
|
+
description: string;
|
|
144
|
+
position: number;
|
|
145
|
+
}
|
|
146
|
+
/** A document as it appears in the navigation tree: enough for a link. */
|
|
147
|
+
interface DocumentTreeEntry {
|
|
148
|
+
folder_id: string;
|
|
149
|
+
slug: string;
|
|
150
|
+
title: string;
|
|
151
|
+
excerpt: string;
|
|
152
|
+
tags: string[];
|
|
153
|
+
position: number;
|
|
154
|
+
updated_at: string;
|
|
155
|
+
site_path: string;
|
|
156
|
+
}
|
|
157
|
+
interface DocumentTree {
|
|
158
|
+
/** Folders with at least one document you may read under them, plus the categories. */
|
|
159
|
+
folders: DocumentFolder[];
|
|
160
|
+
/** Published documents you may read, in folder order. */
|
|
161
|
+
documents: DocumentTreeEntry[];
|
|
162
|
+
}
|
|
163
|
+
/** One saved text of a document, without the text itself. */
|
|
164
|
+
interface DocumentVersionSummary {
|
|
165
|
+
version: number;
|
|
166
|
+
title: string;
|
|
167
|
+
/** When this text took effect. */
|
|
168
|
+
effective_from: string;
|
|
169
|
+
/** What changed, in the editor's words. Often empty. */
|
|
170
|
+
note: string;
|
|
171
|
+
changed_at: string;
|
|
172
|
+
}
|
|
173
|
+
interface DocumentTag {
|
|
174
|
+
tag: string;
|
|
175
|
+
/** Published documents you may read that carry it. */
|
|
176
|
+
count: number;
|
|
177
|
+
}
|
|
178
|
+
declare class DocumentsResource {
|
|
179
|
+
private readonly http;
|
|
180
|
+
constructor(http: HttpClient);
|
|
181
|
+
/**
|
|
182
|
+
* Published documents you may read, paged. The blog comes newest first,
|
|
183
|
+
* other categories in the order set by the editors.
|
|
184
|
+
*/
|
|
185
|
+
list(input?: DocumentListInput): Promise<DocumentList>;
|
|
186
|
+
/** Folders and documents for a sidebar or a table of contents. */
|
|
187
|
+
tree(input?: {
|
|
188
|
+
category?: DocumentCategory | string;
|
|
189
|
+
}): Promise<DocumentTree>;
|
|
190
|
+
/** Every tag on a document you may read, most used first. */
|
|
191
|
+
tags(): Promise<DocumentTag[]>;
|
|
192
|
+
/**
|
|
193
|
+
* One document by its address. Without `at`, the text in force now; with
|
|
194
|
+
* `at` (an ISO 8601 moment), the text that was in force then. Unknown
|
|
195
|
+
* addresses and documents above your level are a 404.
|
|
196
|
+
*/
|
|
197
|
+
get(slug: string, opts?: {
|
|
198
|
+
at?: string | Date;
|
|
199
|
+
}): Promise<Document>;
|
|
200
|
+
/** Every saved text of a document, newest first, with the date each took effect. */
|
|
201
|
+
versions(slug: string): Promise<DocumentVersionSummary[]>;
|
|
202
|
+
/** The document as it read in one version. */
|
|
203
|
+
version(slug: string, version: number): Promise<Document>;
|
|
204
|
+
/**
|
|
205
|
+
* Absolute URL for an image path returned inside a document (`cover_url`,
|
|
206
|
+
* or an image block's `url`). Handy when the app renders on a different
|
|
207
|
+
* origin than the API.
|
|
208
|
+
*/
|
|
209
|
+
imageUrl(baseUrl: string, path: string): string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { type Document, type DocumentBlock, type DocumentCategory, type DocumentFolder, type DocumentList, type DocumentListInput, type DocumentPathStep, type DocumentScope, type DocumentTag, type DocumentTree, type DocumentTreeEntry, type DocumentVersionSummary, DocumentsResource };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/resources/documents.ts
|
|
2
|
+
var DocumentsResource = class {
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Published documents you may read, paged. The blog comes newest first,
|
|
8
|
+
* other categories in the order set by the editors.
|
|
9
|
+
*/
|
|
10
|
+
async list(input = {}) {
|
|
11
|
+
const q = new URLSearchParams();
|
|
12
|
+
if (input.category) q.set("category", input.category);
|
|
13
|
+
if (input.folderId) q.set("folder_id", input.folderId);
|
|
14
|
+
if (input.tag) q.set("tag", input.tag);
|
|
15
|
+
if (input.locale) q.set("locale", input.locale);
|
|
16
|
+
if (input.q) q.set("q", input.q);
|
|
17
|
+
if (input.page) q.set("page", String(input.page));
|
|
18
|
+
if (input.perPage) q.set("per_page", String(input.perPage));
|
|
19
|
+
const qs = q.toString();
|
|
20
|
+
return this.http.get(`/documents${qs ? `?${qs}` : ""}`);
|
|
21
|
+
}
|
|
22
|
+
/** Folders and documents for a sidebar or a table of contents. */
|
|
23
|
+
async tree(input = {}) {
|
|
24
|
+
const qs = input.category ? `?category=${encodeURIComponent(input.category)}` : "";
|
|
25
|
+
return this.http.get(`/documents/tree${qs}`);
|
|
26
|
+
}
|
|
27
|
+
/** Every tag on a document you may read, most used first. */
|
|
28
|
+
async tags() {
|
|
29
|
+
return this.http.get("/documents/tags");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One document by its address. Without `at`, the text in force now; with
|
|
33
|
+
* `at` (an ISO 8601 moment), the text that was in force then. Unknown
|
|
34
|
+
* addresses and documents above your level are a 404.
|
|
35
|
+
*/
|
|
36
|
+
async get(slug, opts = {}) {
|
|
37
|
+
const at = opts.at instanceof Date ? opts.at.toISOString() : opts.at;
|
|
38
|
+
const qs = at ? `?at=${encodeURIComponent(at)}` : "";
|
|
39
|
+
return this.http.get(`/documents/${encodeURIComponent(slug)}${qs}`);
|
|
40
|
+
}
|
|
41
|
+
/** Every saved text of a document, newest first, with the date each took effect. */
|
|
42
|
+
async versions(slug) {
|
|
43
|
+
return this.http.get(
|
|
44
|
+
`/documents/${encodeURIComponent(slug)}/versions`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
/** The document as it read in one version. */
|
|
48
|
+
async version(slug, version) {
|
|
49
|
+
return this.http.get(`/documents/${encodeURIComponent(slug)}/versions/${version}`);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Absolute URL for an image path returned inside a document (`cover_url`,
|
|
53
|
+
* or an image block's `url`). Handy when the app renders on a different
|
|
54
|
+
* origin than the API.
|
|
55
|
+
*/
|
|
56
|
+
imageUrl(baseUrl, path) {
|
|
57
|
+
if (/^https?:\/\//i.test(path)) return path;
|
|
58
|
+
return `${baseUrl.replace(/\/$/, "")}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { DocumentsResource };
|
|
63
|
+
//# sourceMappingURL=documents.js.map
|
|
64
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/documents.ts"],"names":[],"mappings":"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","file":"documents.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Documents resource: `client.documents.*`.\n *\n * Everything the operators write lives in one tree: blog posts, the\n * knowledge base, legal pages, internal notes. Every call here works before\n * the user signs in and shows more once they have: a signed-in user sees the\n * documents marked for users, staff see theirs. The SDK sends the session\n * token when it has one, so the same call serves the public site and the\n * signed-in cabinet.\n *\n * A document arrives as a list of typed blocks. `body_blocks` is flat; map\n * each `type` onto your own component and the document inherits your site's\n * styling. `body_markdown` is there too if you'd rather run your own renderer.\n *\n * ```ts\n * // The knowledge base: folders and articles for a sidebar.\n * const tree = await client.documents.tree({ category: \"knowledge-base\" });\n *\n * // One article, with the text in force today.\n * const doc = await client.documents.get(\"how-to-top-up\");\n *\n * // A legal page as it read on a given day, and its history.\n * const then = await client.documents.get(\"offer\", { at: \"2026-01-01T00:00:00Z\" });\n * const versions = await client.documents.versions(\"offer\");\n *\n * doc.body_blocks.map((b) => {\n * switch (b.type) {\n * case \"heading\": return <Heading level={b.level}>{b.text}</Heading>;\n * case \"paragraph\": return <P>{b.text}</P>;\n * case \"image\": return <Figure src={client.assetUrl(b.url)} alt={b.alt} caption={b.caption} />;\n * case \"list\": return <List ordered={b.ordered} items={b.items} />;\n * case \"quote\": return <Quote>{b.text}</Quote>;\n * case \"code\": return <Code lang={b.lang}>{b.text}</Code>;\n * case \"divider\": return <Hr />;\n * }\n * });\n * ```\n *\n * Links between documents come out as site paths: `/blog/<slug>` for a post,\n * `/docs/<slug>` for everything else (`site_path` on each document says which\n * one it is). Route those two prefixes to your document pages and links keep\n * working after a document is renamed or moved.\n */\n\n/** Category keys: the four folders at the top of the tree. */\nexport type DocumentCategory = \"blog\" | \"knowledge-base\" | \"legal\" | \"internal\";\n\n/** Who may read a document. */\nexport type DocumentScope = \"public\" | \"users\" | \"staff\" | \"operators\";\n\n/** One node of a document body. Discriminated on `type`. */\nexport type DocumentBlock =\n | { type: \"heading\"; level: number; text: string }\n | { type: \"paragraph\"; text: string }\n | { type: \"image\"; url: string; alt?: string; caption?: string }\n | { type: \"list\"; ordered: boolean; items: string[] }\n | { type: \"quote\"; text: string }\n | { type: \"code\"; lang?: string; text: string }\n | { type: \"divider\" };\n\n/** One step of the folder trail, root first. */\nexport interface DocumentPathStep {\n id: string;\n key: string;\n title: string;\n}\n\nexport interface Document {\n /** Permanent address. Link by this; it survives renames and moves. */\n slug: string;\n title: string;\n /** Teaser for cards; falls back to the first paragraph. */\n excerpt: string;\n /** Image URL, relative to the API origin. Absent when no cover is set. */\n cover_url?: string;\n /** Raw Markdown, for consumers that bring their own renderer. */\n body_markdown: string;\n /** The recommended input for rendering; see the module docs. */\n body_blocks: DocumentBlock[];\n tags: string[];\n /** Present only when the document declares one. */\n locale?: string;\n /** Rough read time in minutes (minimum 1). */\n reading_minutes: number;\n published_at: string | null;\n updated_at: string;\n /** Category the document sits in. */\n category: DocumentCategory | string;\n /** Folder trail, root first. */\n path: DocumentPathStep[];\n /** Who may read it. */\n read_scope: DocumentScope;\n /** Number of the text shown. */\n version: number;\n /** When the text shown took effect. */\n effective_from: string;\n /** Path under the site root where this document is read. */\n site_path: string;\n}\n\nexport interface DocumentListInput {\n /** Category key. */\n category?: DocumentCategory | string;\n /** Only documents in this folder and the folders under it. */\n folderId?: string;\n /** Only documents carrying this tag. */\n tag?: string;\n /** Only documents in this locale. */\n locale?: string;\n /** Words to search for in the title and the text. */\n q?: string;\n /** 1-based. Default 1. */\n page?: number;\n /** 1..=50. Default 10. */\n perPage?: number;\n}\n\nexport interface DocumentList {\n documents: Document[];\n total: number;\n page: number;\n per_page: number;\n}\n\n/** A folder as it appears in the navigation tree. */\nexport interface DocumentFolder {\n id: string;\n parent_id: string | null;\n key: string;\n title: string;\n description: string;\n position: number;\n}\n\n/** A document as it appears in the navigation tree: enough for a link. */\nexport interface DocumentTreeEntry {\n folder_id: string;\n slug: string;\n title: string;\n excerpt: string;\n tags: string[];\n position: number;\n updated_at: string;\n site_path: string;\n}\n\nexport interface DocumentTree {\n /** Folders with at least one document you may read under them, plus the categories. */\n folders: DocumentFolder[];\n /** Published documents you may read, in folder order. */\n documents: DocumentTreeEntry[];\n}\n\n/** One saved text of a document, without the text itself. */\nexport interface DocumentVersionSummary {\n version: number;\n title: string;\n /** When this text took effect. */\n effective_from: string;\n /** What changed, in the editor's words. Often empty. */\n note: string;\n changed_at: string;\n}\n\nexport interface DocumentTag {\n tag: string;\n /** Published documents you may read that carry it. */\n count: number;\n}\n\nexport class DocumentsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Published documents you may read, paged. The blog comes newest first,\n * other categories in the order set by the editors.\n */\n async list(input: DocumentListInput = {}): Promise<DocumentList> {\n const q = new URLSearchParams();\n if (input.category) q.set(\"category\", input.category);\n if (input.folderId) q.set(\"folder_id\", input.folderId);\n if (input.tag) q.set(\"tag\", input.tag);\n if (input.locale) q.set(\"locale\", input.locale);\n if (input.q) q.set(\"q\", input.q);\n if (input.page) q.set(\"page\", String(input.page));\n if (input.perPage) q.set(\"per_page\", String(input.perPage));\n const qs = q.toString();\n return this.http.get<DocumentList>(`/documents${qs ? `?${qs}` : \"\"}`);\n }\n\n /** Folders and documents for a sidebar or a table of contents. */\n async tree(input: { category?: DocumentCategory | string } = {}): Promise<DocumentTree> {\n const qs = input.category ? `?category=${encodeURIComponent(input.category)}` : \"\";\n return this.http.get<DocumentTree>(`/documents/tree${qs}`);\n }\n\n /** Every tag on a document you may read, most used first. */\n async tags(): Promise<DocumentTag[]> {\n return this.http.get<DocumentTag[]>(\"/documents/tags\");\n }\n\n /**\n * One document by its address. Without `at`, the text in force now; with\n * `at` (an ISO 8601 moment), the text that was in force then. Unknown\n * addresses and documents above your level are a 404.\n */\n async get(slug: string, opts: { at?: string | Date } = {}): Promise<Document> {\n const at = opts.at instanceof Date ? opts.at.toISOString() : opts.at;\n const qs = at ? `?at=${encodeURIComponent(at)}` : \"\";\n return this.http.get<Document>(`/documents/${encodeURIComponent(slug)}${qs}`);\n }\n\n /** Every saved text of a document, newest first, with the date each took effect. */\n async versions(slug: string): Promise<DocumentVersionSummary[]> {\n return this.http.get<DocumentVersionSummary[]>(\n `/documents/${encodeURIComponent(slug)}/versions`,\n );\n }\n\n /** The document as it read in one version. */\n async version(slug: string, version: number): Promise<Document> {\n return this.http.get<Document>(`/documents/${encodeURIComponent(slug)}/versions/${version}`);\n }\n\n /**\n * Absolute URL for an image path returned inside a document (`cover_url`,\n * or an image block's `url`). Handy when the app renders on a different\n * origin than the API.\n */\n imageUrl(baseUrl: string, path: string): string {\n if (/^https?:\\/\\//i.test(path)) return path;\n return `${baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/resources/funding-options.ts
|
|
4
|
+
var FundingOptionsResource = class {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/** The ways to top up, preferred first. Empty when none is configured. */
|
|
9
|
+
async list() {
|
|
10
|
+
return this.http.get("/me/funding-options");
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.FundingOptionsResource = FundingOptionsResource;
|
|
15
|
+
//# sourceMappingURL=funding-options.cjs.map
|
|
16
|
+
//# sourceMappingURL=funding-options.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/funding-options.ts"],"names":[],"mappings":";;;AAwCO,IAAM,yBAAN,MAA6B;AAAA,EAClC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,GAAiC;AACrC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAqB,qBAAqB,CAAA;AAAA,EAC7D;AACF","file":"funding-options.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { DepositMethod } from \"./deposits.js\";\n\n/**\n * Funding options resource — `client.fundingOptions.*`.\n *\n * The ways the user can top up on this deployment: each funding connector,\n * where its top-ups may land and which payment methods it takes. Build the\n * top-up screen from this list instead of fixed connector names: a\n * deployment may top up the wallet only, cards only (no wallet at all), or\n * let the user choose.\n *\n * Mirrors `GET /me/funding-options`.\n */\n\n/**\n * Where a funding connector's top-ups may land: `wallet` (the wallet\n * only), `spool` (straight onto cards only) or `mixed` (either).\n */\nexport type FunderMode = \"wallet\" | \"spool\" | \"mixed\";\n\n/** Where one top-up goes: the wallet, or one of the user's cards. */\nexport type DepositTarget = \"wallet\" | \"card\";\n\n/** One way to top up. */\nexport interface FundingOption {\n /** Pass it as `funder_slug` to `deposits.initiate`. */\n slug: string;\n mode: FunderMode;\n /** Where a top-up through it may land. */\n targets: DepositTarget[];\n /** Payment methods it takes. */\n methods: DepositMethod[];\n /**\n * Whether a new card can be issued with a top-up through it\n * (`issue_card` on `deposits.initiate`).\n */\n issue_card: boolean;\n}\n\nexport class FundingOptionsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The ways to top up, preferred first. Empty when none is configured. */\n async list(): Promise<FundingOption[]> {\n return this.http.get<FundingOption[]>(\"/me/funding-options\");\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/resources/funding-options.ts
|
|
2
|
+
var FundingOptionsResource = class {
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
/** The ways to top up, preferred first. Empty when none is configured. */
|
|
7
|
+
async list() {
|
|
8
|
+
return this.http.get("/me/funding-options");
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { FundingOptionsResource };
|
|
13
|
+
//# sourceMappingURL=funding-options.js.map
|
|
14
|
+
//# sourceMappingURL=funding-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/funding-options.ts"],"names":[],"mappings":";AAwCO,IAAM,yBAAN,MAA6B;AAAA,EAClC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,GAAiC;AACrC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAqB,qBAAqB,CAAA;AAAA,EAC7D;AACF","file":"funding-options.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { DepositMethod } from \"./deposits.js\";\n\n/**\n * Funding options resource — `client.fundingOptions.*`.\n *\n * The ways the user can top up on this deployment: each funding connector,\n * where its top-ups may land and which payment methods it takes. Build the\n * top-up screen from this list instead of fixed connector names: a\n * deployment may top up the wallet only, cards only (no wallet at all), or\n * let the user choose.\n *\n * Mirrors `GET /me/funding-options`.\n */\n\n/**\n * Where a funding connector's top-ups may land: `wallet` (the wallet\n * only), `spool` (straight onto cards only) or `mixed` (either).\n */\nexport type FunderMode = \"wallet\" | \"spool\" | \"mixed\";\n\n/** Where one top-up goes: the wallet, or one of the user's cards. */\nexport type DepositTarget = \"wallet\" | \"card\";\n\n/** One way to top up. */\nexport interface FundingOption {\n /** Pass it as `funder_slug` to `deposits.initiate`. */\n slug: string;\n mode: FunderMode;\n /** Where a top-up through it may land. */\n targets: DepositTarget[];\n /** Payment methods it takes. */\n methods: DepositMethod[];\n /**\n * Whether a new card can be issued with a top-up through it\n * (`issue_card` on `deposits.initiate`).\n */\n issue_card: boolean;\n}\n\nexport class FundingOptionsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The ways to top up, preferred first. Empty when none is configured. */\n async list(): Promise<FundingOption[]> {\n return this.http.get<FundingOption[]>(\"/me/funding-options\");\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/resources/history.ts
|
|
4
|
+
var HistoryResource = class {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */
|
|
9
|
+
async list(params = {}) {
|
|
10
|
+
const q = new URLSearchParams();
|
|
11
|
+
if (params.cardId) q.set("card_id", params.cardId);
|
|
12
|
+
if (params.cursor) q.set("cursor", params.cursor);
|
|
13
|
+
if (params.limit !== void 0) q.set("limit", String(params.limit));
|
|
14
|
+
if (params.lang) q.set("lang", params.lang);
|
|
15
|
+
const qs = q.toString();
|
|
16
|
+
return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
|
|
17
|
+
signal: params.signal
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Every entry, page after page, newest first. */
|
|
21
|
+
async *all(params = {}) {
|
|
22
|
+
let cursor;
|
|
23
|
+
do {
|
|
24
|
+
const page = await this.list({ ...params, cursor });
|
|
25
|
+
yield* page.items;
|
|
26
|
+
cursor = page.next_cursor ?? void 0;
|
|
27
|
+
} while (cursor);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.HistoryResource = HistoryResource;
|
|
32
|
+
//# sourceMappingURL=history.cjs.map
|
|
33
|
+
//# sourceMappingURL=history.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/history.ts"],"names":[],"mappings":";;;AA8GO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,MAAA,GAA4B,EAAC,EAAyB;AAC/D,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,SAAA,EAAW,OAAO,MAAM,CAAA;AACjD,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,OAAO,MAAM,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAW,CAAA,CAAE,IAAI,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AACnE,IAAA,IAAI,OAAO,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,OAAO,IAAI,CAAA;AAC1C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACpE,QAAQ,MAAA,CAAO;AAAA,KAChB,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,OAAO,GAAA,CAAI,MAAA,GAA4C,EAAC,EAAgC;AACtF,IAAA,IAAI,MAAA;AACJ,IAAA,GAAG;AACD,MAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAClD,MAAA,OAAO,IAAA,CAAK,KAAA;AACZ,MAAA,MAAA,GAAS,KAAK,WAAA,IAAe,MAAA;AAAA,IAC/B,CAAA,QAAS,MAAA;AAAA,EACX;AACF","file":"history.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * History resource — `client.history.*`: everything that happened to the\n * user's money in one list, newest first.\n *\n * ```ts\n * const page = await client.history.list({ limit: 30 });\n * const more = await client.history.list({ cursor: page.next_cursor! });\n * const oneCard = await client.history.list({ cardId: card.id });\n * for await (const item of client.history.all()) { … }\n * ```\n *\n * New kinds are added over time. Render an unknown `kind` from its `title`,\n * `amount`, `direction` and `status`; don't drop it.\n */\n\nexport type HistoryKind =\n | \"card_purchase\"\n | \"card_refund\"\n | \"card_issued\"\n | \"card_topup\"\n | \"card_transfer\"\n | \"wallet_deposit\"\n | \"deposit_refund\"\n | \"fee\"\n | \"balance_adjustment\"\n | \"bonus\"\n // Any kind added later still type-checks.\n | (string & {});\n\nexport type HistoryStatus =\n \"completed\" | \"pending\" | \"declined\" | \"reversed\" | \"failed\" | (string & {});\n\nexport interface HistoryAmount {\n /** Decimal string, never negative; see `direction`. */\n amount: string;\n /** ISO 4217 code. */\n currency: string;\n}\n\nexport interface HistoryCard {\n id: string;\n name: string | null;\n last4: string | null;\n}\n\nexport interface HistoryItem {\n /** Unique across kinds. */\n id: string;\n kind: HistoryKind;\n occurred_at: string;\n /** `pending` is not finished yet; `reversed` is an authorisation that was released. */\n status: HistoryStatus;\n /** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */\n direction: \"out\" | \"in\" | \"internal\" | (string & {});\n /** The merchant, or what the operation was, in the language asked for. */\n title: string;\n /**\n * In the currency the operation happened in. For `bonus` the currency is\n * `BNS` and the amount is a number of bonuses, not money.\n */\n amount: HistoryAmount;\n /**\n * The other side of a conversion (what the card was billed, what the\n * wallet or card received). For a `bonus` spend: the part of the price\n * the bonuses covered, or what they added to a top-up.\n */\n counter_amount: HistoryAmount | null;\n /** Rate between `amount` and `counter_amount`, decimal string. */\n fx_rate: string | null;\n /** A fee charged with the operation, in the wallet's currency. */\n fee: HistoryAmount | null;\n /** The card; the source card of a transfer. */\n card: HistoryCard | null;\n /** The destination card of a transfer. */\n to_card: HistoryCard | null;\n merchant: { name: string | null; city: string | null; country: string | null } | null;\n /** On a declined payment: a stable code and the reason in plain words. */\n decline_reason: {\n code:\n | \"insufficient_funds\"\n | \"limit_exceeded\"\n | \"card_blocked\"\n | \"card_expired\"\n | \"wrong_details\"\n | \"merchant_not_allowed\"\n | \"other\"\n | (string & {});\n text: string;\n } | null;\n}\n\nexport interface HistoryPage {\n items: HistoryItem[];\n /** Pass as `cursor` for the next, older page; `null` on the last one. */\n next_cursor: string | null;\n}\n\nexport interface ListHistoryParams {\n /** Only this card's operations, transfers to and from it included. */\n cardId?: string;\n cursor?: string;\n /** 1 to 100, default 30. */\n limit?: number;\n /** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */\n lang?: \"en\" | \"ru\";\n signal?: AbortSignal;\n}\n\nexport class HistoryResource {\n constructor(private readonly http: HttpClient) {}\n\n /** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */\n async list(params: ListHistoryParams = {}): Promise<HistoryPage> {\n const q = new URLSearchParams();\n if (params.cardId) q.set(\"card_id\", params.cardId);\n if (params.cursor) q.set(\"cursor\", params.cursor);\n if (params.limit !== undefined) q.set(\"limit\", String(params.limit));\n if (params.lang) q.set(\"lang\", params.lang);\n const qs = q.toString();\n return this.http.get<HistoryPage>(`/me/history${qs ? `?${qs}` : \"\"}`, {\n signal: params.signal,\n });\n }\n\n /** Every entry, page after page, newest first. */\n async *all(params: Omit<ListHistoryParams, \"cursor\"> = {}): AsyncGenerator<HistoryItem> {\n let cursor: string | undefined;\n do {\n const page = await this.list({ ...params, cursor });\n yield* page.items;\n cursor = page.next_cursor ?? undefined;\n } while (cursor);\n }\n}\n"]}
|