@forumulate/sdk 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -15
- package/dist/content.d.ts +318 -0
- package/dist/content.js +81 -0
- package/dist/helpers.d.ts +303 -0
- package/dist/helpers.js +180 -0
- package/dist/http.d.ts +86 -0
- package/dist/http.js +200 -0
- package/dist/index.d.ts +471 -177
- package/dist/index.js +114 -269
- package/dist/operations.gen.d.ts +2597 -0
- package/dist/operations.gen.js +360 -0
- package/dist/pagination.d.ts +27 -0
- package/dist/pagination.js +79 -0
- package/dist/resources.d.ts +181 -0
- package/dist/resources.js +129 -0
- package/dist/schema.d.ts +2 -2
- package/dist/translations.d.ts +301 -0
- package/dist/translations.js +255 -0
- package/dist/typed.d.ts +2 -2
- package/dist/webhooks.d.ts +8 -0
- package/dist/webhooks.js +15 -0
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -14,48 +14,66 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ForumulateClient = exports.ForumulateError = exports.verifyWebhookSignature = void 0;
|
|
17
|
+
exports.ForumulateClient = exports.API_VERSION = exports.rowsOf = exports.retryDelayMs = exports.SDK_VERSION = exports.ForumulateError = exports.constructWebhookEvent = exports.verifyWebhookSignature = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
var webhooks_1 = require("./webhooks");
|
|
20
20
|
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return webhooks_1.verifyWebhookSignature; } });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* // or, from FORUMULATE_TOKEN / FORUMULATE_URL:
|
|
41
|
-
* const fromEnv = ForumulateClient.fromEnv();
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
21
|
+
Object.defineProperty(exports, "constructWebhookEvent", { enumerable: true, get: function () { return webhooks_1.constructWebhookEvent; } });
|
|
22
|
+
__exportStar(require("./content"), exports);
|
|
23
|
+
__exportStar(require("./translations"), exports);
|
|
24
|
+
var http_1 = require("./http");
|
|
25
|
+
Object.defineProperty(exports, "ForumulateError", { enumerable: true, get: function () { return http_1.ForumulateError; } });
|
|
26
|
+
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return http_1.SDK_VERSION; } });
|
|
27
|
+
Object.defineProperty(exports, "retryDelayMs", { enumerable: true, get: function () { return http_1.retryDelayMs; } });
|
|
28
|
+
var pagination_1 = require("./pagination");
|
|
29
|
+
Object.defineProperty(exports, "rowsOf", { enumerable: true, get: function () { return pagination_1.rowsOf; } });
|
|
30
|
+
var operations_gen_1 = require("./operations.gen");
|
|
31
|
+
Object.defineProperty(exports, "API_VERSION", { enumerable: true, get: function () { return operations_gen_1.API_VERSION; } });
|
|
32
|
+
const content_1 = require("./content");
|
|
33
|
+
const translations_1 = require("./translations");
|
|
34
|
+
const http_2 = require("./http");
|
|
35
|
+
const pagination_2 = require("./pagination");
|
|
36
|
+
const helpers_1 = require("./helpers");
|
|
37
|
+
const operations_gen_2 = require("./operations.gen");
|
|
38
|
+
const resources_1 = require("./resources");
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
44
40
|
class ForumulateClient {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
credentials;
|
|
48
|
-
defaultHeaders;
|
|
49
|
-
_fetch;
|
|
41
|
+
transport;
|
|
42
|
+
apiVersion;
|
|
50
43
|
constructor(opts) {
|
|
51
|
-
this.baseUrl = opts.baseUrl.replace(/\/$/, '');
|
|
52
|
-
this.token = opts.token;
|
|
53
|
-
this.credentials = opts.credentials ?? false;
|
|
54
|
-
this.defaultHeaders = { ...(opts.headers ?? {}) };
|
|
55
44
|
const f = opts.fetch ?? globalThis.fetch;
|
|
56
45
|
if (!f)
|
|
57
46
|
throw new Error('No fetch implementation available — pass one via options.fetch.');
|
|
58
|
-
|
|
47
|
+
const headers = { ...(opts.headers ?? {}) };
|
|
48
|
+
const inBrowser = typeof globalThis.document !== 'undefined';
|
|
49
|
+
if (!inBrowser && !Object.keys(headers).some((k) => k.toLowerCase() === 'user-agent')) {
|
|
50
|
+
headers['User-Agent'] = opts.userAgent ?? `forumulate-sdk-js/${http_2.SDK_VERSION}`;
|
|
51
|
+
}
|
|
52
|
+
this.transport = {
|
|
53
|
+
baseUrl: opts.baseUrl.replace(/\/$/, ''),
|
|
54
|
+
token: opts.token,
|
|
55
|
+
credentials: opts.credentials ?? false,
|
|
56
|
+
headers,
|
|
57
|
+
fetch: f,
|
|
58
|
+
maxRetries: opts.maxRetries ?? 2,
|
|
59
|
+
autoIdempotencyKey: opts.autoIdempotencyKey ?? true,
|
|
60
|
+
};
|
|
61
|
+
this.apiVersion = opts.apiVersion;
|
|
62
|
+
// Generated namespaces are built on first touch: a client that only ever
|
|
63
|
+
// calls `blog` never allocates the other 1,800 closures.
|
|
64
|
+
for (const name of (0, resources_1.namespaceNames)()) {
|
|
65
|
+
if (Object.prototype.hasOwnProperty.call(this, name))
|
|
66
|
+
continue;
|
|
67
|
+
Object.defineProperty(this, name, {
|
|
68
|
+
configurable: true,
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: () => {
|
|
71
|
+
const value = (0, resources_1.buildNamespace)(name, this.invoke);
|
|
72
|
+
Object.defineProperty(this, name, { value, enumerable: true });
|
|
73
|
+
return value;
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
59
77
|
}
|
|
60
78
|
/**
|
|
61
79
|
* A client configured from the environment, by the same names the CLI and
|
|
@@ -83,74 +101,34 @@ class ForumulateClient {
|
|
|
83
101
|
...opts,
|
|
84
102
|
});
|
|
85
103
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for (const [k, v] of Object.entries(opts.query ?? {})) {
|
|
90
|
-
if (v !== undefined)
|
|
91
|
-
url.searchParams.set(k, String(v));
|
|
92
|
-
}
|
|
93
|
-
/*
|
|
94
|
-
* Ours first, the caller's last, so a per-request header wins.
|
|
95
|
-
*
|
|
96
|
-
* `Idempotency-Key` has to be per-REQUEST (a key reused across two
|
|
97
|
-
* different writes is worse than none), and `Forumulate-Version` is
|
|
98
|
-
* naturally per-client — so both layers exist and the narrower one
|
|
99
|
-
* overrides. `Content-Type` is set before the caller's so a multipart or
|
|
100
|
-
* ndjson body can correct it rather than be forced to JSON.
|
|
101
|
-
*/
|
|
102
|
-
const headers = { ...this.defaultHeaders };
|
|
103
|
-
if (this.token)
|
|
104
|
-
headers.Authorization = `Bearer ${this.token}`;
|
|
105
|
-
if (opts.body !== undefined)
|
|
106
|
-
headers['Content-Type'] = 'application/json';
|
|
107
|
-
Object.assign(headers, opts.headers ?? {});
|
|
108
|
-
const res = await this._fetch(url.toString(), {
|
|
109
|
-
method,
|
|
110
|
-
headers,
|
|
111
|
-
credentials: this.credentials ? 'include' : 'same-origin',
|
|
112
|
-
body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
|
|
113
|
-
});
|
|
114
|
-
if (opts.raw) {
|
|
115
|
-
if (!res.ok)
|
|
116
|
-
throw await this.toError(res);
|
|
117
|
-
return res;
|
|
118
|
-
}
|
|
119
|
-
const text = await res.text();
|
|
120
|
-
const json = text ? JSON.parse(text) : undefined;
|
|
121
|
-
if (!res.ok) {
|
|
122
|
-
const err = (json?.error ?? {});
|
|
123
|
-
throw new ForumulateError(res.status, err.code ?? 'error', err.message ?? res.statusText);
|
|
104
|
+
request(a, b, c) {
|
|
105
|
+
if (typeof b === 'string') {
|
|
106
|
+
return this.http(a, b, (c ?? {}));
|
|
124
107
|
}
|
|
125
|
-
|
|
108
|
+
const route = (0, resources_1.routeTable)().byId.get(a);
|
|
109
|
+
if (!route)
|
|
110
|
+
return Promise.reject(new TypeError(`Unknown operationId "${a}"`));
|
|
111
|
+
return this.invoke(route, b);
|
|
112
|
+
}
|
|
113
|
+
paginate(operationId, args) {
|
|
114
|
+
const route = (0, resources_1.routeTable)().byId.get(operationId);
|
|
115
|
+
if (!route?.flags.includes('p'))
|
|
116
|
+
throw new TypeError(`"${operationId}" is not a paged operation`);
|
|
117
|
+
return this.invoke(route, args);
|
|
126
118
|
}
|
|
127
119
|
/**
|
|
128
|
-
* Fully-typed request against ANY endpoint in the OpenAPI spec.
|
|
120
|
+
* Fully-typed request against ANY endpoint in the OpenAPI spec, by path.
|
|
129
121
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* pass, so every one of the 600+ routes gets types and autocomplete without a
|
|
135
|
-
* bespoke wrapper. Path templates like `/orgs/{orgId}/spaces` are filled from
|
|
136
|
-
* `init.params`.
|
|
122
|
+
* The generated `paths` interface (`src/schema.ts`, produced from
|
|
123
|
+
* `openapi.json`) infers the path params, query params, JSON body and success
|
|
124
|
+
* response for the `(method, path)` you pass. Path templates like
|
|
125
|
+
* `/orgs/{orgId}/spaces` are filled from `init.params`.
|
|
137
126
|
*
|
|
138
127
|
* ```ts
|
|
139
|
-
* // GET a list — path param is required and checked; response is typed.
|
|
140
128
|
* const { spaces } = await forumulate.typed('get', '/orgs/{orgId}/spaces', {
|
|
141
|
-
* params: { orgId }, query: {
|
|
142
|
-
* });
|
|
143
|
-
*
|
|
144
|
-
* // POST with a body the spec knows the shape of.
|
|
145
|
-
* await forumulate.typed('post', '/orgs/{orgId}/spaces', {
|
|
146
|
-
* params: { orgId },
|
|
147
|
-
* body: { name: 'Docs', slug: 'docs', type: 'DOCS', visibility: 'PUBLIC' },
|
|
129
|
+
* params: { orgId }, query: { limit: 50 },
|
|
148
130
|
* });
|
|
149
131
|
* ```
|
|
150
|
-
*
|
|
151
|
-
* Regenerate the types after an API change with
|
|
152
|
-
* `pnpm --filter @forumulate/sdk dump-spec` then
|
|
153
|
-
* `npx openapi-typescript packages/sdk/openapi.json -o src/schema.ts`.
|
|
154
132
|
*/
|
|
155
133
|
typed(method, path, init) {
|
|
156
134
|
const opts = (init ?? {});
|
|
@@ -160,7 +138,7 @@ class ForumulateClient {
|
|
|
160
138
|
concrete = concrete.replace(`{${k}}`, encodeURIComponent(String(v)));
|
|
161
139
|
}
|
|
162
140
|
}
|
|
163
|
-
return this.
|
|
141
|
+
return this.http(String(method).toUpperCase(), concrete, {
|
|
164
142
|
body: opts.body,
|
|
165
143
|
query: opts.query,
|
|
166
144
|
raw: opts.raw,
|
|
@@ -169,185 +147,52 @@ class ForumulateClient {
|
|
|
169
147
|
headers: opts.headers,
|
|
170
148
|
});
|
|
171
149
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
150
|
+
/** The 0.5 door: no version stated unless the client pins one. */
|
|
151
|
+
http(method, path, opts = {}) {
|
|
152
|
+
return (0, http_2.send)(this.transport, { method, path, ...opts, version: this.apiVersion });
|
|
153
|
+
}
|
|
154
|
+
/** The generated door: path filled from the args, version always stated, lists iterable. */
|
|
155
|
+
invoke = (route, args) => {
|
|
156
|
+
let resolved;
|
|
175
157
|
try {
|
|
176
|
-
|
|
177
|
-
code = j?.error?.code ?? code;
|
|
178
|
-
message = j?.error?.message ?? message;
|
|
158
|
+
resolved = (0, resources_1.resolveArgs)(route, args);
|
|
179
159
|
}
|
|
180
|
-
catch {
|
|
181
|
-
|
|
160
|
+
catch (err) {
|
|
161
|
+
return Promise.reject(err);
|
|
182
162
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}),
|
|
196
|
-
};
|
|
197
|
-
// ── Organizations ─────────────────────────────────────────────────────────
|
|
198
|
-
orgs = {
|
|
199
|
-
list: () => this.request('GET', '/orgs'),
|
|
200
|
-
create: (input) => this.request('POST', '/orgs', { body: input }),
|
|
201
|
-
};
|
|
202
|
-
// ── Spaces & content ───────────────────────────────────────────────────────
|
|
203
|
-
spaces = {
|
|
204
|
-
list: (orgId) => this.request('GET', `/orgs/${orgId}/spaces`),
|
|
205
|
-
create: (orgId, input) => this.request('POST', `/orgs/${orgId}/spaces`, { body: input }),
|
|
206
|
-
createCollection: (orgId, spaceId, input) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/collections`, { body: input }),
|
|
207
|
-
createPage: (orgId, spaceId, collectionId, input) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/collections/${collectionId}/pages`, { body: input }),
|
|
208
|
-
setPageContent: (orgId, spaceId, pageId, input) => this.request('PUT', `/orgs/${orgId}/spaces/${spaceId}/pages/${pageId}/content`, { body: input }),
|
|
209
|
-
publishPage: (orgId, spaceId, pageId) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/pages/${pageId}/publish`, { body: {} }),
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* Shapes and pieces — the surface an agent works through.
|
|
213
|
-
*
|
|
214
|
-
* `shape` says what one piece of a space is made of and hands back JSON
|
|
215
|
-
* Schema; `items` writes one, whatever a piece happens to be in that space:
|
|
216
|
-
* a documentation page, a blog post, a release, an incident. The reply says
|
|
217
|
-
* which required sections are still empty, so an agent can create a piece,
|
|
218
|
-
* ask what it forgot, and close the gap.
|
|
219
|
-
*/
|
|
220
|
-
shapes = {
|
|
221
|
-
get: (orgId, spaceId) => this.request('GET', `/orgs/${orgId}/spaces/${spaceId}/shape`),
|
|
222
|
-
set: (orgId, spaceId, patch) => this.request('PUT', `/orgs/${orgId}/spaces/${spaceId}/shape`, {
|
|
223
|
-
body: patch,
|
|
224
|
-
}),
|
|
225
|
-
applyPreset: (orgId, spaceId, name) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/shape/presets/${name}`, {
|
|
226
|
-
body: {},
|
|
227
|
-
}),
|
|
228
|
-
};
|
|
229
|
-
items = {
|
|
230
|
-
create: (orgId, spaceId, input) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/items`, {
|
|
231
|
-
body: input,
|
|
232
|
-
}),
|
|
233
|
-
/**
|
|
234
|
-
* What is in a space: how something finds a piece it has no words for.
|
|
235
|
-
*
|
|
236
|
-
* Pass `include: ['body']` to get content. Asking for `sections` ALONE is
|
|
237
|
-
* the trap: it is populated only for pieces written against a shape, so a
|
|
238
|
-
* space of free-form pages answers with empty objects and a sync carries
|
|
239
|
-
* nothing while reporting success. Every row says which field holds its
|
|
240
|
-
* content in `contentIn`.
|
|
241
|
-
*
|
|
242
|
-
* Any option here puts the response in its paged form, so `page` and
|
|
243
|
-
* `sync` come back — `page.total` is what a walk should check its own
|
|
244
|
-
* count against, and `sync.checkpoint` is what an incremental sync stores.
|
|
245
|
-
*/
|
|
246
|
-
list: (orgId, spaceId, opts = {}) => {
|
|
247
|
-
// A bare number used to be the whole signature; keep it working.
|
|
248
|
-
const o = typeof opts === 'number' ? { limit: opts } : opts;
|
|
249
|
-
const query = {};
|
|
250
|
-
if (o.limit)
|
|
251
|
-
query.limit = o.limit;
|
|
252
|
-
if (o.include?.length)
|
|
253
|
-
query.include = o.include.join(',');
|
|
254
|
-
if (o.cursor)
|
|
255
|
-
query.cursor = o.cursor;
|
|
256
|
-
if (o.updatedSince)
|
|
257
|
-
query.updated_since = o.updatedSince;
|
|
258
|
-
if (o.includeDeleted)
|
|
259
|
-
query.include_deleted = 'true';
|
|
260
|
-
if (o.fields?.length)
|
|
261
|
-
query.fields = o.fields.join(',');
|
|
262
|
-
return this.request('GET', `/orgs/${orgId}/spaces/${spaceId}/items`, { query });
|
|
263
|
-
},
|
|
264
|
-
get: (orgId, spaceId, itemId) => this.request('GET', `/orgs/${orgId}/spaces/${spaceId}/items/${itemId}`),
|
|
265
|
-
/**
|
|
266
|
-
* Make it readable. Kinds that are live on creation say so and change nothing.
|
|
267
|
-
*
|
|
268
|
-
* `conformance` describes the piece AFTER publishing — which declared slots
|
|
269
|
-
* are filled and which are still missing — so an agent that has just made
|
|
270
|
-
* its work readable can tell a complete piece from one with holes in it
|
|
271
|
-
* without fetching it again. The server has always sent it and this type
|
|
272
|
-
* omitted it, so a TypeScript caller could not see the field the docs
|
|
273
|
-
* promise (E-11).
|
|
274
|
-
*/
|
|
275
|
-
publish: (orgId, spaceId, itemId) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/items/${itemId}/publish`, { body: {} }),
|
|
276
|
-
/**
|
|
277
|
-
* Replace a piece's whole body — as markdown, or as blocks.
|
|
278
|
-
*
|
|
279
|
-
* The create door has always taken markdown and this one took blocks only,
|
|
280
|
-
* so "make it from this file" worked and "update it from the same file" did
|
|
281
|
-
* not. Both now; blocks win if a caller sends both.
|
|
282
|
-
*/
|
|
283
|
-
setContent: (orgId, spaceId, itemId, input) => this.request('PUT', `/orgs/${orgId}/spaces/${spaceId}/items/${itemId}/content`, { body: input }),
|
|
284
|
-
/** Replace one named section. Idempotent — sending it twice writes it once. */
|
|
285
|
-
setSection: (orgId, spaceId, itemId, key, markdown) => this.request('PUT', `/orgs/${orgId}/spaces/${spaceId}/items/${itemId}/sections/${key}`, { body: { markdown } }),
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* The addresses a space answers at.
|
|
289
|
-
*
|
|
290
|
-
* Published because the question a customer asks about a custom domain —
|
|
291
|
-
* "why is it not live yet" — is answerable only from `verified`, `active` and
|
|
292
|
-
* the setup records, and the SDK could not reach any of them (DX-2). A failed
|
|
293
|
-
* verification is a 200 with `verified: false`: read the body, not the status.
|
|
294
|
-
*/
|
|
295
|
-
domains = {
|
|
296
|
-
list: (orgId, spaceId) => this.request('GET', `/orgs/${orgId}/spaces/${spaceId}/domains`),
|
|
297
|
-
add: (orgId, spaceId, input) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/domains`, {
|
|
298
|
-
body: input,
|
|
299
|
-
}),
|
|
300
|
-
/** Re-run the ownership check. `activate: false` proves it without switching traffic. */
|
|
301
|
-
verify: (orgId, spaceId, domainId, activate = true) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/domains/${domainId}/verify`, { body: { activate } }),
|
|
302
|
-
/** Switch traffic to an address whose ownership is already proven. */
|
|
303
|
-
activate: (orgId, spaceId, domainId) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/domains/${domainId}/activate`, { body: {} }),
|
|
304
|
-
/** What to configure, and what is still missing. */
|
|
305
|
-
setup: (orgId, spaceId, domainId) => this.request('GET', `/orgs/${orgId}/spaces/${spaceId}/domains/${domainId}/setup`),
|
|
306
|
-
};
|
|
307
|
-
// ── Webhooks ───────────────────────────────────────────────────────────────
|
|
308
|
-
webhooks = {
|
|
309
|
-
list: (orgId) => this.request('GET', `/orgs/${orgId}/webhooks`),
|
|
310
|
-
create: (orgId, input) => this.request('POST', `/orgs/${orgId}/webhooks`, { body: input }),
|
|
311
|
-
};
|
|
312
|
-
// ── Space snapshots (version history) ───────────────────────────────────────
|
|
313
|
-
snapshots = {
|
|
314
|
-
list: (orgId, spaceId) => this.request('GET', `/orgs/${orgId}/spaces/${spaceId}/snapshots`),
|
|
315
|
-
create: (orgId, spaceId, label) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/snapshots`, {
|
|
316
|
-
body: { label },
|
|
317
|
-
}),
|
|
318
|
-
restore: (orgId, spaceId, id) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/snapshots/${id}/restore`, { body: {} }),
|
|
319
|
-
};
|
|
320
|
-
// ── Community (forum topics) ────────────────────────────────────────────────
|
|
321
|
-
forum = {
|
|
322
|
-
listTopics: (orgId, spaceId, query = {}) => this.request('GET', `/orgs/${orgId}/spaces/${spaceId}/forum`, { query }),
|
|
323
|
-
createTopic: (orgId, spaceId, input) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/forum`, {
|
|
324
|
-
body: input,
|
|
325
|
-
}),
|
|
326
|
-
reply: (orgId, spaceId, topicId, content) => this.request('POST', `/orgs/${orgId}/spaces/${spaceId}/forum/${topicId}/replies`, { body: { content } }),
|
|
327
|
-
};
|
|
328
|
-
// ── Search & analytics (org-level) ──────────────────────────────────────────
|
|
329
|
-
search = {
|
|
330
|
-
unified: (orgId, q, opts = {}) => this.request('GET', `/orgs/${orgId}/search`, {
|
|
331
|
-
query: { q, ...opts },
|
|
332
|
-
}),
|
|
333
|
-
};
|
|
334
|
-
analytics = {
|
|
335
|
-
orgEvents: (orgId, days) => this.request('GET', `/orgs/${orgId}/analytics/events`, {
|
|
336
|
-
query: days ? { days } : {},
|
|
337
|
-
}),
|
|
338
|
-
};
|
|
339
|
-
// ── Public reader (no auth required) ────────────────────────────────────────
|
|
340
|
-
public = {
|
|
341
|
-
getPage: (orgId, spaceId, pageId) => this.request('GET', `/public/orgs/${orgId}/spaces/${spaceId}/pages/${pageId}`),
|
|
342
|
-
search: (orgId, spaceId, query) => this.request('GET', `/public/orgs/${orgId}/spaces/${spaceId}/search`, {
|
|
343
|
-
query: { q: query },
|
|
344
|
-
}),
|
|
345
|
-
listComments: (orgId, spaceId, pageId) => this.request('GET', `/public/orgs/${orgId}/spaces/${spaceId}/pages/${pageId}/comments`),
|
|
346
|
-
postComment: (orgId, spaceId, pageId, input) => this.request('POST', `/public/orgs/${orgId}/spaces/${spaceId}/pages/${pageId}/comments`, { body: input }),
|
|
347
|
-
reactToComment: (orgId, spaceId, commentId, emoji) => this.request('POST', `/public/orgs/${orgId}/spaces/${spaceId}/comments/${commentId}/react`, { body: { emoji } }),
|
|
348
|
-
/** Download the whole space as a PDF. Returns the raw `Response` (read `.blob()` / `.arrayBuffer()`). */
|
|
349
|
-
pdf: (orgId, spaceId) => this.request('GET', `/public/orgs/${orgId}/spaces/${spaceId}/pdf`, { raw: true }),
|
|
163
|
+
const { query, ...rest } = resolved;
|
|
164
|
+
const kind = route.flags.includes('b') ? 'binary' : route.flags.includes('t') ? 'text' : 'json';
|
|
165
|
+
const fetchPage = (q) => (0, http_2.send)(this.transport, {
|
|
166
|
+
...rest,
|
|
167
|
+
method: route.method,
|
|
168
|
+
query: q,
|
|
169
|
+
kind,
|
|
170
|
+
version: this.apiVersion ?? operations_gen_2.API_VERSION,
|
|
171
|
+
});
|
|
172
|
+
if (route.flags.includes('p'))
|
|
173
|
+
return (0, pagination_2.pagePromise)(fetchPage, query ?? {});
|
|
174
|
+
return fetchPage(query ?? {});
|
|
350
175
|
};
|
|
176
|
+
ns(name, hw) {
|
|
177
|
+
return (0, resources_1.mergeNamespace)((0, resources_1.buildNamespace)(name, this.invoke), hw);
|
|
178
|
+
}
|
|
179
|
+
helpers = (0, helpers_1.positionalHelpers)((method, path, opts) => this.http(method, path, opts));
|
|
180
|
+
// ── Namespaces with 0.5 helpers laid over the generated methods ─────────────
|
|
181
|
+
auth = this.ns('auth', this.helpers.auth);
|
|
182
|
+
content = this.ns('content', (0, content_1.contentApi)((method, path, opts) => this.http(method, path, opts)));
|
|
183
|
+
/** Translations of every kind of piece, routed by space type — see ./translations. */
|
|
184
|
+
translations = (0, translations_1.translationsApi)((method, path, opts) => this.http(method, path, opts));
|
|
185
|
+
orgs = this.ns('orgs', this.helpers.orgs);
|
|
186
|
+
spaces = this.ns('spaces', this.helpers.spaces);
|
|
187
|
+
shapes = this.ns('shapes', this.helpers.shapes);
|
|
188
|
+
items = this.ns('items', this.helpers.items);
|
|
189
|
+
domains = this.ns('domains', this.helpers.domains);
|
|
190
|
+
webhooks = this.ns('webhooks', this.helpers.webhooks);
|
|
191
|
+
snapshots = this.ns('snapshots', this.helpers.snapshots);
|
|
192
|
+
forum = this.ns('forum', this.helpers.forum);
|
|
193
|
+
search = this.ns('search', this.helpers.search);
|
|
194
|
+
analytics = this.ns('analytics', this.helpers.analytics);
|
|
195
|
+
public = this.ns('public', this.helpers.public);
|
|
351
196
|
}
|
|
352
197
|
exports.ForumulateClient = ForumulateClient;
|
|
353
198
|
//# sourceMappingURL=index.js.map
|