@favish/staffbase-utils 0.8.0 → 0.10.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 CHANGED
@@ -23,8 +23,10 @@ minimumReleaseAgeExclude:
23
23
 
24
24
  | Subpath | Exports |
25
25
  | --- | --- |
26
+ | `@favish/staffbase-utils/api` | `fetchJson`, `fetchAllPaginated`, `ApiError` |
26
27
  | `@favish/staffbase-utils/log` | `logError`, `logWarn`, `logDebug`, `setLoggingEnabled` |
27
28
  | `@favish/staffbase-utils/dom` | `getDynamicClasses` |
29
+ | `@favish/staffbase-utils/types` | `Channel`, `ChannelLink`, `ChannelLinkParameter`, `DropdownOption` (type-only) |
28
30
 
29
31
  More modules (`/env`, `/device`, `/html`, `/links`, `/widgets`) are added per the
30
32
  delivery roadmap; each is its own subpath so consumers only bundle what they import.
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class extends Error{status;constructor(e,t){super(t),this.name=`ApiError`,this.status=e}},t=async(t,n)=>{let r=await fetch(t,{credentials:`include`,...n});if(!r.ok)throw new e(r.status,`API request failed with status: ${r.status}`);return await r.json()},n=50,r=1e3,i=async(e,i={})=>{let{mapItem:a,limit:o=n,includeDrafts:s=!1,maxPages:c=r,onError:l}=i,u=[],d=0,f=0;for(;f<c;){let n=(await t(`${e}${e.includes(`?`)?`&`:`?`}limit=${o}&offset=${d}${s?`&includeDrafts=true`:``}`)).data??[];if(n.length===0)break;let r=a?n.map(a).filter(e=>e!==null):n;if(u.push(...r),n.length<o)break;d+=o,f+=1}return f>=c&&l?.(`Pagination cap (${c} pages) reached for ${e}; results may be truncated.`),u};exports.ApiError=e,exports.fetchAllPaginated=i,exports.fetchJson=t;
2
+ //# sourceMappingURL=api.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.cjs.js","names":[],"sources":["../src/api/ApiError.ts","../src/api/fetchJson.ts","../src/api/fetchAllPaginated.ts"],"sourcesContent":["/**\n * Error thrown by the API layer when a request resolves with a non-2xx status.\n * Carries the HTTP status so callers can branch (e.g. distinguish 401/403 from\n * 5xx) instead of collapsing every failure into one generic message.\n */\nexport class ApiError extends Error {\n public readonly status: number\n\n /**\n * Creates an ApiError carrying the failed response status.\n * @param {number} status - The HTTP status code of the failed response.\n * @param {string} message - A human-readable error message.\n */\n public constructor(status: number, message: string) {\n super(message)\n this.name = 'ApiError'\n this.status = status\n }\n}\n","import { ApiError } from './ApiError'\n\n/**\n * Fetches JSON from a URL using Staffbase session credentials.\n *\n * Throws {@link ApiError} (carrying the HTTP status) on a non-2xx response so\n * callers can branch on the status. Network/parse errors propagate as-is. This\n * helper does not log; the calling service layer owns error logging.\n * @template T The expected shape of the parsed JSON body.\n * @param {string} url - The API URL to fetch.\n * @param {RequestInit} [init] - Optional fetch overrides (merged after credentials).\n * @returns {Promise<T>} The parsed JSON body.\n * @throws {ApiError} When the response status is not ok.\n */\nexport const fetchJson = async <T>(\n url: string,\n init?: RequestInit,\n): Promise<T> => {\n const response = await fetch(url, { credentials: 'include', ...init })\n\n if (!response.ok) {\n throw new ApiError(\n response.status,\n `API request failed with status: ${response.status}`,\n )\n }\n\n return (await response.json()) as T\n}\n","import type { FetchAllPaginatedOptions } from '../types/api/FetchAllPaginatedOptions'\nimport { fetchJson } from './fetchJson'\n\nconst DEFAULT_LIMIT = 50\nconst DEFAULT_MAX_PAGES = 1000\n\n/**\n * Fetches every page of a Staffbase `{ data, total }` collection endpoint.\n *\n * Termination is driven by page contents (a short page ends the loop) rather\n * than the API's reported `total`, which avoids under-fetching when `total` is\n * under-reported. A `maxPages` cap bounds worst-case latency/memory; reaching it\n * invokes `onError` so the truncation is never silent.\n * @template TItem The mapped item type returned to the caller.\n * @template TSource The raw item type returned by the API before mapping.\n * @param {string} baseUrl - The base API URL (without limit/offset parameters).\n * @param {FetchAllPaginatedOptions<TItem, TSource>} [options] - Mapping and pagination options.\n * @returns {Promise<TItem[]>} All fetched (and optionally mapped) items.\n */\nexport const fetchAllPaginated = async <TItem, TSource = TItem>(\n baseUrl: string,\n options: FetchAllPaginatedOptions<TItem, TSource> = {},\n): Promise<TItem[]> => {\n const {\n mapItem,\n limit = DEFAULT_LIMIT,\n includeDrafts = false,\n maxPages = DEFAULT_MAX_PAGES,\n onError,\n } = options\n\n const results: TItem[] = []\n let offset = 0\n let page = 0\n\n while (page < maxPages) {\n const separator = baseUrl.includes('?') ? '&' : '?'\n const draftsParam = includeDrafts ? '&includeDrafts=true' : ''\n const url = `${baseUrl}${separator}limit=${limit}&offset=${offset}${draftsParam}`\n\n const data = await fetchJson<{ data: TSource[]; total?: number }>(url)\n const rawItems = data.data ?? []\n\n if (rawItems.length === 0) break\n\n const mapped = mapItem\n ? rawItems.map(mapItem).filter((item): item is TItem => item !== null)\n : (rawItems as unknown as TItem[])\n\n results.push(...mapped)\n\n // A short page means we reached the end of the collection.\n if (rawItems.length < limit) break\n\n offset += limit\n page += 1\n }\n\n if (page >= maxPages) {\n onError?.(\n `Pagination cap (${maxPages} pages) reached for ${baseUrl}; results may be truncated.`,\n )\n }\n\n return results\n}\n"],"mappings":"mEAKA,IAAa,EAAb,cAA8B,KAAM,CAClC,OAOA,YAAmB,EAAgB,EAAiB,CAClD,MAAM,CAAO,EACb,KAAK,KAAO,WACZ,KAAK,OAAS,CAChB,CACF,ECJa,EAAY,MACvB,EACA,IACe,CACf,IAAM,EAAW,MAAM,MAAM,EAAK,CAAE,YAAa,UAAW,GAAG,CAAK,CAAC,EAErE,GAAI,CAAC,EAAS,GACZ,MAAM,IAAI,EACR,EAAS,OACT,mCAAmC,EAAS,QAC9C,EAGF,OAAQ,MAAM,EAAS,KAAK,CAC9B,ECzBM,EAAgB,GAChB,EAAoB,IAeb,EAAoB,MAC/B,EACA,EAAoD,CAAC,IAChC,CACrB,GAAM,CACJ,UACA,QAAQ,EACR,gBAAgB,GAChB,WAAW,EACX,WACE,EAEE,EAAmB,CAAC,EACtB,EAAS,EACT,EAAO,EAEX,KAAO,EAAO,GAAU,CAMtB,IAAM,GAAW,MADE,EAA+C,GAFnD,IAFG,EAAQ,SAAS,GAAG,EAAI,IAAM,IAEb,QAAQ,EAAM,UAAU,IADvC,EAAgB,sBAAwB,IAGS,GAC/C,MAAQ,CAAC,EAE/B,GAAI,EAAS,SAAW,EAAG,MAE3B,IAAM,EAAS,EACX,EAAS,IAAI,CAAO,EAAE,OAAQ,GAAwB,IAAS,IAAI,EAClE,EAKL,GAHA,EAAQ,KAAK,GAAG,CAAM,EAGlB,EAAS,OAAS,EAAO,MAE7B,GAAU,EACV,GAAQ,CACV,CAQA,OANI,GAAQ,GACV,IACE,mBAAmB,EAAS,sBAAsB,EAAQ,4BAC5D,EAGK,CACT"}
@@ -0,0 +1,28 @@
1
+ //#region src/api/ApiError.ts
2
+ var e = class extends Error {
3
+ status;
4
+ constructor(e, t) {
5
+ super(t), this.name = "ApiError", this.status = e;
6
+ }
7
+ }, t = async (t, n) => {
8
+ let r = await fetch(t, {
9
+ credentials: "include",
10
+ ...n
11
+ });
12
+ if (!r.ok) throw new e(r.status, `API request failed with status: ${r.status}`);
13
+ return await r.json();
14
+ }, n = 50, r = 1e3, i = async (e, i = {}) => {
15
+ let { mapItem: a, limit: o = n, includeDrafts: s = !1, maxPages: c = r, onError: l } = i, u = [], d = 0, f = 0;
16
+ for (; f < c;) {
17
+ let n = (await t(`${e}${e.includes("?") ? "&" : "?"}limit=${o}&offset=${d}${s ? "&includeDrafts=true" : ""}`)).data ?? [];
18
+ if (n.length === 0) break;
19
+ let r = a ? n.map(a).filter((e) => e !== null) : n;
20
+ if (u.push(...r), n.length < o) break;
21
+ d += o, f += 1;
22
+ }
23
+ return f >= c && l?.(`Pagination cap (${c} pages) reached for ${e}; results may be truncated.`), u;
24
+ };
25
+ //#endregion
26
+ export { e as ApiError, i as fetchAllPaginated, t as fetchJson };
27
+
28
+ //# sourceMappingURL=api.es.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.es.mjs","names":[],"sources":["../src/api/ApiError.ts","../src/api/fetchJson.ts","../src/api/fetchAllPaginated.ts"],"sourcesContent":["/**\n * Error thrown by the API layer when a request resolves with a non-2xx status.\n * Carries the HTTP status so callers can branch (e.g. distinguish 401/403 from\n * 5xx) instead of collapsing every failure into one generic message.\n */\nexport class ApiError extends Error {\n public readonly status: number\n\n /**\n * Creates an ApiError carrying the failed response status.\n * @param {number} status - The HTTP status code of the failed response.\n * @param {string} message - A human-readable error message.\n */\n public constructor(status: number, message: string) {\n super(message)\n this.name = 'ApiError'\n this.status = status\n }\n}\n","import { ApiError } from './ApiError'\n\n/**\n * Fetches JSON from a URL using Staffbase session credentials.\n *\n * Throws {@link ApiError} (carrying the HTTP status) on a non-2xx response so\n * callers can branch on the status. Network/parse errors propagate as-is. This\n * helper does not log; the calling service layer owns error logging.\n * @template T The expected shape of the parsed JSON body.\n * @param {string} url - The API URL to fetch.\n * @param {RequestInit} [init] - Optional fetch overrides (merged after credentials).\n * @returns {Promise<T>} The parsed JSON body.\n * @throws {ApiError} When the response status is not ok.\n */\nexport const fetchJson = async <T>(\n url: string,\n init?: RequestInit,\n): Promise<T> => {\n const response = await fetch(url, { credentials: 'include', ...init })\n\n if (!response.ok) {\n throw new ApiError(\n response.status,\n `API request failed with status: ${response.status}`,\n )\n }\n\n return (await response.json()) as T\n}\n","import type { FetchAllPaginatedOptions } from '../types/api/FetchAllPaginatedOptions'\nimport { fetchJson } from './fetchJson'\n\nconst DEFAULT_LIMIT = 50\nconst DEFAULT_MAX_PAGES = 1000\n\n/**\n * Fetches every page of a Staffbase `{ data, total }` collection endpoint.\n *\n * Termination is driven by page contents (a short page ends the loop) rather\n * than the API's reported `total`, which avoids under-fetching when `total` is\n * under-reported. A `maxPages` cap bounds worst-case latency/memory; reaching it\n * invokes `onError` so the truncation is never silent.\n * @template TItem The mapped item type returned to the caller.\n * @template TSource The raw item type returned by the API before mapping.\n * @param {string} baseUrl - The base API URL (without limit/offset parameters).\n * @param {FetchAllPaginatedOptions<TItem, TSource>} [options] - Mapping and pagination options.\n * @returns {Promise<TItem[]>} All fetched (and optionally mapped) items.\n */\nexport const fetchAllPaginated = async <TItem, TSource = TItem>(\n baseUrl: string,\n options: FetchAllPaginatedOptions<TItem, TSource> = {},\n): Promise<TItem[]> => {\n const {\n mapItem,\n limit = DEFAULT_LIMIT,\n includeDrafts = false,\n maxPages = DEFAULT_MAX_PAGES,\n onError,\n } = options\n\n const results: TItem[] = []\n let offset = 0\n let page = 0\n\n while (page < maxPages) {\n const separator = baseUrl.includes('?') ? '&' : '?'\n const draftsParam = includeDrafts ? '&includeDrafts=true' : ''\n const url = `${baseUrl}${separator}limit=${limit}&offset=${offset}${draftsParam}`\n\n const data = await fetchJson<{ data: TSource[]; total?: number }>(url)\n const rawItems = data.data ?? []\n\n if (rawItems.length === 0) break\n\n const mapped = mapItem\n ? rawItems.map(mapItem).filter((item): item is TItem => item !== null)\n : (rawItems as unknown as TItem[])\n\n results.push(...mapped)\n\n // A short page means we reached the end of the collection.\n if (rawItems.length < limit) break\n\n offset += limit\n page += 1\n }\n\n if (page >= maxPages) {\n onError?.(\n `Pagination cap (${maxPages} pages) reached for ${baseUrl}; results may be truncated.`,\n )\n }\n\n return results\n}\n"],"mappings":";AAKA,IAAa,IAAb,cAA8B,MAAM;CAClC;CAOA,YAAmB,GAAgB,GAAiB;EAGlD,AAFA,MAAM,CAAO,GACb,KAAK,OAAO,YACZ,KAAK,SAAS;CAChB;AACF,GCJa,IAAY,OACvB,GACA,MACe;CACf,IAAM,IAAW,MAAM,MAAM,GAAK;EAAE,aAAa;EAAW,GAAG;CAAK,CAAC;CAErE,IAAI,CAAC,EAAS,IACZ,MAAM,IAAI,EACR,EAAS,QACT,mCAAmC,EAAS,QAC9C;CAGF,OAAQ,MAAM,EAAS,KAAK;AAC9B,GCzBM,IAAgB,IAChB,IAAoB,KAeb,IAAoB,OAC/B,GACA,IAAoD,CAAC,MAChC;CACrB,IAAM,EACJ,YACA,WAAQ,GACR,mBAAgB,IAChB,cAAW,GACX,eACE,GAEE,IAAmB,CAAC,GACtB,IAAS,GACT,IAAO;CAEX,OAAO,IAAO,IAAU;EAMtB,IAAM,KAAW,MADE,EAA+C,GAFnD,IAFG,EAAQ,SAAS,GAAG,IAAI,MAAM,IAEb,QAAQ,EAAM,UAAU,IADvC,IAAgB,wBAAwB,IAGS,GAC/C,QAAQ,CAAC;EAE/B,IAAI,EAAS,WAAW,GAAG;EAE3B,IAAM,IAAS,IACX,EAAS,IAAI,CAAO,EAAE,QAAQ,MAAwB,MAAS,IAAI,IAClE;EAKL,IAHA,EAAQ,KAAK,GAAG,CAAM,GAGlB,EAAS,SAAS,GAAO;EAG7B,AADA,KAAU,GACV,KAAQ;CACV;CAQA,OANI,KAAQ,KACV,IACE,mBAAmB,EAAS,sBAAsB,EAAQ,4BAC5D,GAGK;AACT"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Error thrown by the API layer when a request resolves with a non-2xx status.
3
+ * Carries the HTTP status so callers can branch (e.g. distinguish 401/403 from
4
+ * 5xx) instead of collapsing every failure into one generic message.
5
+ */
6
+ export declare class ApiError extends Error {
7
+ readonly status: number;
8
+ /**
9
+ * Creates an ApiError carrying the failed response status.
10
+ * @param {number} status - The HTTP status code of the failed response.
11
+ * @param {string} message - A human-readable error message.
12
+ */
13
+ constructor(status: number, message: string);
14
+ }
15
+ //# sourceMappingURL=ApiError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiError.d.ts","sourceRoot":"","sources":["../../../src/api/ApiError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,MAAM,EAAE,MAAM,CAAA;IAE9B;;;;OAIG;gBACgB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKnD"}
@@ -0,0 +1,16 @@
1
+ import { FetchAllPaginatedOptions } from '../types/api/FetchAllPaginatedOptions';
2
+ /**
3
+ * Fetches every page of a Staffbase `{ data, total }` collection endpoint.
4
+ *
5
+ * Termination is driven by page contents (a short page ends the loop) rather
6
+ * than the API's reported `total`, which avoids under-fetching when `total` is
7
+ * under-reported. A `maxPages` cap bounds worst-case latency/memory; reaching it
8
+ * invokes `onError` so the truncation is never silent.
9
+ * @template TItem The mapped item type returned to the caller.
10
+ * @template TSource The raw item type returned by the API before mapping.
11
+ * @param {string} baseUrl - The base API URL (without limit/offset parameters).
12
+ * @param {FetchAllPaginatedOptions<TItem, TSource>} [options] - Mapping and pagination options.
13
+ * @returns {Promise<TItem[]>} All fetched (and optionally mapped) items.
14
+ */
15
+ export declare const fetchAllPaginated: <TItem, TSource = TItem>(baseUrl: string, options?: FetchAllPaginatedOptions<TItem, TSource>) => Promise<TItem[]>;
16
+ //# sourceMappingURL=fetchAllPaginated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchAllPaginated.d.ts","sourceRoot":"","sources":["../../../src/api/fetchAllPaginated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAA;AAMrF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,GAAU,KAAK,EAAE,OAAO,GAAG,KAAK,EAC5D,SAAS,MAAM,EACf,UAAS,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAM,KACrD,OAAO,CAAC,KAAK,EAAE,CA2CjB,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Fetches JSON from a URL using Staffbase session credentials.
3
+ *
4
+ * Throws {@link ApiError} (carrying the HTTP status) on a non-2xx response so
5
+ * callers can branch on the status. Network/parse errors propagate as-is. This
6
+ * helper does not log; the calling service layer owns error logging.
7
+ * @template T The expected shape of the parsed JSON body.
8
+ * @param {string} url - The API URL to fetch.
9
+ * @param {RequestInit} [init] - Optional fetch overrides (merged after credentials).
10
+ * @returns {Promise<T>} The parsed JSON body.
11
+ * @throws {ApiError} When the response status is not ok.
12
+ */
13
+ export declare const fetchJson: <T>(url: string, init?: RequestInit) => Promise<T>;
14
+ //# sourceMappingURL=fetchJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchJson.d.ts","sourceRoot":"","sources":["../../../src/api/fetchJson.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAU,CAAC,EAC/B,KAAK,MAAM,EACX,OAAO,WAAW,KACjB,OAAO,CAAC,CAAC,CAWX,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { ApiError } from './ApiError';
2
+ export { fetchAllPaginated } from './fetchAllPaginated';
3
+ export { fetchJson } from './fetchJson';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Options for fetchAllPaginated.
3
+ * @template TItem The mapped item type returned to the caller.
4
+ * @template TSource The raw item type returned by the API before mapping.
5
+ */
6
+ export interface FetchAllPaginatedOptions<TItem, TSource = TItem> {
7
+ /**
8
+ * Maps/filters each raw API item. Return null to drop an item. When omitted,
9
+ * raw items are returned unchanged (TSource is assumed assignable to TItem).
10
+ * @param {TSource} item - The raw item from the API page.
11
+ * @returns {TItem | null} The mapped item, or null to skip it.
12
+ */
13
+ mapItem?: (item: TSource) => TItem | null;
14
+ /** Page size requested per call (default 50). */
15
+ limit?: number;
16
+ /** When true, appends `includeDrafts=true` to each request URL. */
17
+ includeDrafts?: boolean;
18
+ /**
19
+ * Hard cap on the number of pages fetched (default 1000), a runaway backstop.
20
+ * Lower it to bound first-paint latency on very large collections.
21
+ */
22
+ maxPages?: number;
23
+ /**
24
+ * Called with a diagnostic message when the maxPages cap is hit (so truncation
25
+ * is never silent). Injected because the library does not log directly.
26
+ * @param {string} message - The truncation diagnostic message.
27
+ * @returns {void} Nothing.
28
+ */
29
+ onError?: (message: string) => void;
30
+ }
31
+ //# sourceMappingURL=FetchAllPaginatedOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchAllPaginatedOptions.d.ts","sourceRoot":"","sources":["../../../../src/types/api/FetchAllPaginatedOptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK;IAC9D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,KAAK,GAAG,IAAI,CAAA;IACzC,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC"}
@@ -0,0 +1,70 @@
1
+ import { ChannelLink } from './ChannelLink';
2
+ /**
3
+ * Partial shape of a Staffbase content channel as returned by the channels API.
4
+ *
5
+ * Shared verbatim by the alerts, unacknowledged-bulletins and global-content
6
+ * widgets. The smart-search widget consumes a different (search-API) channel
7
+ * shape and keeps its own type. Marked partial because the platform may add
8
+ * fields; only the documented subset the widgets rely on is typed here.
9
+ */
10
+ export interface Channel {
11
+ pluginID: string;
12
+ menuFolderIDs: string[];
13
+ defaultMenuFolderId: string;
14
+ config: {
15
+ localization: Record<string, {
16
+ title: string;
17
+ description: string | null;
18
+ }>;
19
+ sidebarVisible: boolean;
20
+ showPageBackground: boolean;
21
+ showAdminActions: boolean;
22
+ };
23
+ availableInPublicArea: boolean;
24
+ contentType: string;
25
+ notificationChannelsAllowed: string[] | null;
26
+ notificationChannelsDefault: string[];
27
+ postCount: number;
28
+ id: string;
29
+ spaceID: string;
30
+ visibleInPublicArea: boolean;
31
+ displayAuthor: boolean;
32
+ acknowledgingAllowed: boolean;
33
+ commentingAllowed: boolean;
34
+ highlightingAllowed: boolean;
35
+ layout: {
36
+ primaryMedia: string;
37
+ };
38
+ likingAllowed: boolean;
39
+ sharingAllowed: boolean;
40
+ internalSharingAllowed: boolean;
41
+ externalSharingAllowed: boolean;
42
+ lastPostPublishedAt: string;
43
+ commentingEnabledDefault: boolean;
44
+ highlightingEnabledDefault: boolean;
45
+ likingEnabledDefault: boolean;
46
+ sharingEnabledDefault: boolean;
47
+ acknowledgingEnabledDefault: boolean;
48
+ internalSharingEnabledDefault: boolean;
49
+ externalSharingEnabledDefault: boolean;
50
+ published: string;
51
+ created: string;
52
+ entityType: string;
53
+ updated: string;
54
+ links: {
55
+ preview: ChannelLink;
56
+ create_post: ChannelLink;
57
+ move: ChannelLink;
58
+ accessors: ChannelLink;
59
+ available_news_pages: ChannelLink;
60
+ get_posts: ChannelLink;
61
+ menu_items: ChannelLink;
62
+ update: ChannelLink;
63
+ feeds: ChannelLink;
64
+ delete: ChannelLink;
65
+ users: ChannelLink;
66
+ update_news_pages: ChannelLink;
67
+ };
68
+ rights: string[];
69
+ }
70
+ //# sourceMappingURL=Channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../../../../src/types/content/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAClB,MAAM,EACN;YACE,KAAK,EAAE,MAAM,CAAA;YACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;SAC3B,CACF,CAAA;QACD,cAAc,EAAE,OAAO,CAAA;QACvB,kBAAkB,EAAE,OAAO,CAAA;QAC3B,gBAAgB,EAAE,OAAO,CAAA;KAC1B,CAAA;IACD,qBAAqB,EAAE,OAAO,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,2BAA2B,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC5C,2BAA2B,EAAE,MAAM,EAAE,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,mBAAmB,EAAE,OAAO,CAAA;IAC5B,aAAa,EAAE,OAAO,CAAA;IACtB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,aAAa,EAAE,OAAO,CAAA;IACtB,cAAc,EAAE,OAAO,CAAA;IACvB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,sBAAsB,EAAE,OAAO,CAAA;IAC/B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,wBAAwB,EAAE,OAAO,CAAA;IACjC,0BAA0B,EAAE,OAAO,CAAA;IACnC,oBAAoB,EAAE,OAAO,CAAA;IAC7B,qBAAqB,EAAE,OAAO,CAAA;IAC9B,2BAA2B,EAAE,OAAO,CAAA;IACpC,6BAA6B,EAAE,OAAO,CAAA;IACtC,6BAA6B,EAAE,OAAO,CAAA;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE;QACL,OAAO,EAAE,WAAW,CAAA;QACpB,WAAW,EAAE,WAAW,CAAA;QACxB,IAAI,EAAE,WAAW,CAAA;QACjB,SAAS,EAAE,WAAW,CAAA;QACtB,oBAAoB,EAAE,WAAW,CAAA;QACjC,SAAS,EAAE,WAAW,CAAA;QACtB,UAAU,EAAE,WAAW,CAAA;QACvB,MAAM,EAAE,WAAW,CAAA;QACnB,KAAK,EAAE,WAAW,CAAA;QAClB,MAAM,EAAE,WAAW,CAAA;QACnB,KAAK,EAAE,WAAW,CAAA;QAClB,iBAAiB,EAAE,WAAW,CAAA;KAC/B,CAAA;IACD,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB"}
@@ -0,0 +1,12 @@
1
+ import { ChannelLinkParameter } from './ChannelLinkParameter';
2
+ /**
3
+ * A single HAL link on a channel (method + href, with optional parameter and
4
+ * form descriptors). Used for each entry of a channel's `links` map.
5
+ */
6
+ export interface ChannelLink {
7
+ method: string;
8
+ href: string;
9
+ parameters?: Record<string, ChannelLinkParameter>;
10
+ form?: ChannelLinkParameter[];
11
+ }
12
+ //# sourceMappingURL=ChannelLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChannelLink.d.ts","sourceRoot":"","sources":["../../../../src/types/content/ChannelLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACjD,IAAI,CAAC,EAAE,oBAAoB,EAAE,CAAA;CAC9B"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A single parameter descriptor on a channel HAL link (an entry in a link's
3
+ * `parameters` map or `form` array). Mirrors the Staffbase channels API; the
4
+ * alerts, unacknowledged-bulletins and global-content widgets share this shape.
5
+ */
6
+ export interface ChannelLinkParameter {
7
+ type: string;
8
+ id: string;
9
+ format?: string;
10
+ value?: string | number;
11
+ required: boolean;
12
+ }
13
+ //# sourceMappingURL=ChannelLinkParameter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChannelLinkParameter.d.ts","sourceRoot":"","sources":["../../../../src/types/content/ChannelLinkParameter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;CAClB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Option shape for channel/article selector dropdowns.
3
+ *
4
+ * `spaceName` and `spaceId` are optional enrichment used by widgets that group
5
+ * options by space; widgets that do not group simply omit them. This is the
6
+ * superset of the alerts (id/title) and unacknowledged-bulletins (+space)
7
+ * variants.
8
+ */
9
+ export interface DropdownOption {
10
+ id: string;
11
+ title: string;
12
+ /** Optional space name for display in selectors. */
13
+ spaceName?: string;
14
+ /** Optional space id for enrichment. */
15
+ spaceId?: string;
16
+ }
17
+ //# sourceMappingURL=DropdownOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownOption.d.ts","sourceRoot":"","sources":["../../../../src/types/content/DropdownOption.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
@@ -0,0 +1,5 @@
1
+ export type { Channel } from './Channel';
2
+ export type { ChannelLink } from './ChannelLink';
3
+ export type { ChannelLinkParameter } from './ChannelLinkParameter';
4
+ export type { DropdownOption } from './DropdownOption';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/content/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@favish/staffbase-utils",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Shared internal/host utilities for Staffbase widgets",
5
5
  "author": "Favish <dev@favish.com>",
6
6
  "license": "UNLICENSED",
@@ -8,6 +8,11 @@
8
8
  "dist"
9
9
  ],
10
10
  "exports": {
11
+ "./api": {
12
+ "types": "./dist/src/api/index.d.ts",
13
+ "import": "./dist/api.es.mjs",
14
+ "require": "./dist/api.cjs.js"
15
+ },
11
16
  "./log": {
12
17
  "types": "./dist/src/log/index.d.ts",
13
18
  "import": "./dist/log.es.mjs",
@@ -42,6 +47,11 @@
42
47
  "types": "./dist/src/widgets/react/index.d.ts",
43
48
  "import": "./dist/widgets/react.es.mjs",
44
49
  "require": "./dist/widgets/react.cjs.js"
50
+ },
51
+ "./types": {
52
+ "types": "./dist/src/types/content/index.d.ts",
53
+ "import": "./dist/types.es.mjs",
54
+ "require": "./dist/types.cjs.js"
45
55
  }
46
56
  },
47
57
  "repository": {