@nuwah/vertical-sdk 0.0.0-stage → 0.2.0-rc.1
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/LICENSE +17 -0
- package/README.md +229 -2
- package/bin/nuwah-contract-check-rules.d.mts +41 -0
- package/bin/nuwah-contract-check-rules.mjs +333 -0
- package/bin/nuwah-contract-check.mjs +64 -0
- package/dist/accounting.d.ts +1417 -0
- package/dist/accounting.js +274 -0
- package/dist/active-org.d.ts +13 -0
- package/dist/active-org.js +59 -0
- package/dist/actors.d.ts +448 -0
- package/dist/actors.js +143 -0
- package/dist/ai.d.ts +359 -0
- package/dist/ai.js +229 -0
- package/dist/analytics.d.ts +37 -0
- package/dist/analytics.js +8 -0
- package/dist/atlas.d.ts +291 -0
- package/dist/atlas.js +78 -0
- package/dist/audit.d.ts +193 -0
- package/dist/audit.js +26 -0
- package/dist/authentication.d.ts +119 -0
- package/dist/authentication.js +83 -0
- package/dist/awards.d.ts +38 -0
- package/dist/awards.js +10 -0
- package/dist/blueprint/document.d.ts +178 -0
- package/dist/blueprint/document.js +17 -0
- package/dist/blueprint/index.d.ts +3 -0
- package/dist/blueprint/index.js +5 -0
- package/dist/blueprint/manifest.d.ts +105 -0
- package/dist/blueprint/manifest.js +11 -0
- package/dist/blueprint/validate.d.ts +14 -0
- package/dist/blueprint/validate.js +416 -0
- package/dist/bookings-directory.d.ts +118 -0
- package/dist/bookings-directory.js +289 -0
- package/dist/bookings-extra.d.ts +1448 -0
- package/dist/bookings-extra.js +582 -0
- package/dist/bookings.d.ts +1365 -0
- package/dist/bookings.js +305 -0
- package/dist/builder-code.d.ts +164 -0
- package/dist/builder-code.js +12 -0
- package/dist/builder-core-gaps.d.ts +83 -0
- package/dist/builder-core-gaps.js +8 -0
- package/dist/builder-repos.d.ts +73 -0
- package/dist/builder-repos.js +37 -0
- package/dist/builder.d.ts +730 -0
- package/dist/builder.js +105 -0
- package/dist/campaigns.d.ts +105 -0
- package/dist/campaigns.js +25 -0
- package/dist/catalogs.d.ts +188 -0
- package/dist/catalogs.js +36 -0
- package/dist/commerce-ai.d.ts +182 -0
- package/dist/commerce-ai.js +27 -0
- package/dist/connections.d.ts +278 -0
- package/dist/connections.js +96 -0
- package/dist/content-control.d.ts +121 -0
- package/dist/content-control.js +23 -0
- package/dist/contributions.d.ts +560 -0
- package/dist/contributions.js +140 -0
- package/dist/conversation-assist.d.ts +154 -0
- package/dist/conversation-assist.js +51 -0
- package/dist/conversation-info.d.ts +219 -0
- package/dist/conversation-info.js +43 -0
- package/dist/crm.d.ts +533 -0
- package/dist/crm.js +142 -0
- package/dist/dashboards.d.ts +119 -0
- package/dist/dashboards.js +22 -0
- package/dist/delegations.d.ts +161 -0
- package/dist/delegations.js +39 -0
- package/dist/docs.d.ts +289 -0
- package/dist/docs.js +49 -0
- package/dist/documents.d.ts +317 -0
- package/dist/documents.js +84 -0
- package/dist/drafts.d.ts +132 -0
- package/dist/drafts.js +56 -0
- package/dist/engagements.d.ts +133 -0
- package/dist/engagements.js +15 -0
- package/dist/event-stream.d.ts +54 -0
- package/dist/event-stream.js +228 -0
- package/dist/exchanges.d.ts +447 -0
- package/dist/exchanges.js +145 -0
- package/dist/exports.d.ts +113 -0
- package/dist/exports.js +81 -0
- package/dist/feeds.d.ts +228 -0
- package/dist/feeds.js +52 -0
- package/dist/files.d.ts +56 -0
- package/dist/files.js +55 -0
- package/dist/finance-insights.d.ts +41 -0
- package/dist/finance-insights.js +61 -0
- package/dist/fixed-assets.d.ts +155 -0
- package/dist/fixed-assets.js +28 -0
- package/dist/fulfilment-jobs.d.ts +405 -0
- package/dist/fulfilment-jobs.js +76 -0
- package/dist/fulfilment.d.ts +205 -0
- package/dist/fulfilment.js +39 -0
- package/dist/hr.d.ts +350 -0
- package/dist/hr.js +94 -0
- package/dist/http.d.ts +124 -0
- package/dist/http.js +392 -0
- package/dist/inbox.d.ts +206 -0
- package/dist/inbox.js +36 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +294 -0
- package/dist/insights.d.ts +176 -0
- package/dist/insights.js +52 -0
- package/dist/inventory.d.ts +797 -0
- package/dist/inventory.js +120 -0
- package/dist/list-query.d.ts +211 -0
- package/dist/list-query.js +158 -0
- package/dist/listings.d.ts +381 -0
- package/dist/listings.js +173 -0
- package/dist/location-sharing.d.ts +83 -0
- package/dist/location-sharing.js +20 -0
- package/dist/marketplace.d.ts +268 -0
- package/dist/marketplace.js +59 -0
- package/dist/matching.d.ts +103 -0
- package/dist/matching.js +22 -0
- package/dist/media.d.ts +221 -0
- package/dist/media.js +239 -0
- package/dist/metrics.d.ts +125 -0
- package/dist/metrics.js +45 -0
- package/dist/moderation.d.ts +240 -0
- package/dist/moderation.js +40 -0
- package/dist/money.d.ts +41 -0
- package/dist/money.js +79 -0
- package/dist/my-data.d.ts +266 -0
- package/dist/my-data.js +32 -0
- package/dist/names.d.ts +14 -0
- package/dist/names.js +17 -0
- package/dist/occasions.d.ts +256 -0
- package/dist/occasions.js +40 -0
- package/dist/onboarding.d.ts +88 -0
- package/dist/onboarding.js +38 -0
- package/dist/pagination.d.ts +204 -0
- package/dist/pagination.js +141 -0
- package/dist/party-baseline-attributes.d.ts +245 -0
- package/dist/party-baseline-attributes.js +36 -0
- package/dist/party.d.ts +401 -0
- package/dist/party.js +56 -0
- package/dist/patient.d.ts +161 -0
- package/dist/patient.js +45 -0
- package/dist/payroll.d.ts +378 -0
- package/dist/payroll.js +60 -0
- package/dist/person-addresses.d.ts +88 -0
- package/dist/person-addresses.js +18 -0
- package/dist/person-cart.d.ts +250 -0
- package/dist/person-cart.js +63 -0
- package/dist/person-chat-assist.d.ts +47 -0
- package/dist/person-chat-assist.js +13 -0
- package/dist/person-data-webhooks.d.ts +72 -0
- package/dist/person-data-webhooks.js +86 -0
- package/dist/person-data.d.ts +212 -0
- package/dist/person-data.js +162 -0
- package/dist/person-locations.d.ts +54 -0
- package/dist/person-locations.js +6 -0
- package/dist/person-messaging.d.ts +405 -0
- package/dist/person-messaging.js +112 -0
- package/dist/person-notifications.d.ts +319 -0
- package/dist/person-notifications.js +164 -0
- package/dist/personalisation.d.ts +21 -0
- package/dist/personalisation.js +8 -0
- package/dist/platform.d.ts +63 -0
- package/dist/platform.js +45 -0
- package/dist/portfolio.d.ts +163 -0
- package/dist/portfolio.js +28 -0
- package/dist/pos.d.ts +743 -0
- package/dist/pos.js +129 -0
- package/dist/procurement.d.ts +664 -0
- package/dist/procurement.js +157 -0
- package/dist/promotions.d.ts +169 -0
- package/dist/promotions.js +39 -0
- package/dist/publications.d.ts +583 -0
- package/dist/publications.js +164 -0
- package/dist/ranking.d.ts +43 -0
- package/dist/ranking.js +34 -0
- package/dist/ratings.d.ts +293 -0
- package/dist/ratings.js +109 -0
- package/dist/reactions.d.ts +123 -0
- package/dist/reactions.js +41 -0
- package/dist/recipient-orders.d.ts +294 -0
- package/dist/recipient-orders.js +73 -0
- package/dist/relationships.d.ts +18 -0
- package/dist/relationships.js +8 -0
- package/dist/reporting.d.ts +107 -0
- package/dist/reporting.js +56 -0
- package/dist/sales.d.ts +270 -0
- package/dist/sales.js +66 -0
- package/dist/shares.d.ts +105 -0
- package/dist/shares.js +27 -0
- package/dist/shop.d.ts +993 -0
- package/dist/shop.js +215 -0
- package/dist/shopping-assistant.d.ts +65 -0
- package/dist/shopping-assistant.js +14 -0
- package/dist/spaces.d.ts +422 -0
- package/dist/spaces.js +118 -0
- package/dist/stored-value.d.ts +754 -0
- package/dist/stored-value.js +177 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/dist/vault.d.ts +290 -0
- package/dist/vault.js +55 -0
- package/dist/vertical-runtime.d.ts +17 -0
- package/dist/vertical-runtime.js +8 -0
- package/dist/vite/build-manifest-plugin.d.ts +42 -0
- package/dist/vite/build-manifest-plugin.js +42 -0
- package/dist/vite/first-paint-plugin.d.ts +26 -0
- package/dist/vite/first-paint-plugin.js +57 -0
- package/dist/wishlists.d.ts +591 -0
- package/dist/wishlists.js +188 -0
- package/dist/workbench.d.ts +114 -0
- package/dist/workbench.js +22 -0
- package/dist/workspace.d.ts +190 -0
- package/dist/workspace.js +41 -0
- package/package.json +52 -4
- package/templates/extension-image.Dockerfile +38 -0
- package/templates/nuwah-vertical.yml +102 -0
- package/templates/vertical-app/.env.example +34 -0
- package/templates/vertical-app/README.md +108 -0
- package/templates/vertical-app/github/workflows/ci.yml +51 -0
- package/templates/vertical-app/gitignore +5 -0
- package/templates/vertical-app/index.html +12 -0
- package/templates/vertical-app/package.json +28 -0
- package/templates/vertical-app/src/App.tsx +64 -0
- package/templates/vertical-app/src/blueprint/blueprint.ts +45 -0
- package/templates/vertical-app/src/blueprint/screens.ts +15 -0
- package/templates/vertical-app/src/env.d.ts +18 -0
- package/templates/vertical-app/src/index.css +139 -0
- package/templates/vertical-app/src/lib/i18n.ts +5 -0
- package/templates/vertical-app/src/lib/iam.ts +19 -0
- package/templates/vertical-app/src/lib/operations.ts +93 -0
- package/templates/vertical-app/src/lib/router.ts +24 -0
- package/templates/vertical-app/src/lib/sdk.ts +21 -0
- package/templates/vertical-app/src/lib/theme.ts +18 -0
- package/templates/vertical-app/src/lib/words.ts +39 -0
- package/templates/vertical-app/src/main.tsx +25 -0
- package/templates/vertical-app/src/pages/AppScreens.tsx +71 -0
- package/templates/vertical-app/src/pages/AuthCallback.tsx +44 -0
- package/templates/vertical-app/src/pages/Home.tsx +36 -0
- package/templates/vertical-app/tsconfig.json +24 -0
- package/templates/vertical-app/vite.config.ts +23 -0
- package/templates/vertical-ci.yml +192 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { NuwahClientConfig, Http } from './http.js';
|
|
2
|
+
/** One selectable column on an export report card. */
|
|
3
|
+
export interface ExportColumnMeta {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Whether this column is on by default. */
|
|
7
|
+
default: boolean;
|
|
8
|
+
/** Whether it's a numeric/amount column (drives totals). */
|
|
9
|
+
amount: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** One filter control the builder renders for a report. */
|
|
12
|
+
export interface ExportFilterMeta {
|
|
13
|
+
key: string;
|
|
14
|
+
/** Control type, e.g. `date`, `select`, `text`. */
|
|
15
|
+
type: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** Present for `select`-type filters. */
|
|
18
|
+
options?: Array<{
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/** A single export-catalog card — a runnable report the caller may access. */
|
|
24
|
+
export interface ExportReportCard {
|
|
25
|
+
key: string;
|
|
26
|
+
/**
|
|
27
|
+
* Catalog domain group Report Studio buckets the card under
|
|
28
|
+
* (e.g. `finance`, `insurance`, `clinical`, `people`, `inventory`, `sales`, `operations`).
|
|
29
|
+
*/
|
|
30
|
+
group: string;
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
icon: string;
|
|
34
|
+
color: string;
|
|
35
|
+
columns: ExportColumnMeta[];
|
|
36
|
+
filters: ExportFilterMeta[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A live preview of an export: rows keyed by column key (so the client can
|
|
40
|
+
* slice/reorder without re-fetching), the total row count, and the report's
|
|
41
|
+
* summary block. No totals row here — the downloaded file carries totals.
|
|
42
|
+
*/
|
|
43
|
+
export interface ExportPreview {
|
|
44
|
+
rows: Array<Record<string, unknown>>;
|
|
45
|
+
total: number;
|
|
46
|
+
summary: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/** A saved column/filter preset for one report, scoped to the acting user. */
|
|
49
|
+
export interface ExportPreset {
|
|
50
|
+
id: string;
|
|
51
|
+
user_id: string;
|
|
52
|
+
report_key: string;
|
|
53
|
+
name: string;
|
|
54
|
+
columns: string[];
|
|
55
|
+
filters: Record<string, unknown>;
|
|
56
|
+
created_at?: string;
|
|
57
|
+
updated_at?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Body for creating a preset (`POST /exports/{report}/presets`). */
|
|
60
|
+
export interface CreateExportPresetInput {
|
|
61
|
+
name: string;
|
|
62
|
+
/** At least one column key, in display order. */
|
|
63
|
+
columns: string[];
|
|
64
|
+
filters?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/** Body for updating a preset (`PATCH /exports/presets/{id}`). */
|
|
67
|
+
export type UpdateExportPresetInput = Partial<CreateExportPresetInput>;
|
|
68
|
+
/** Report-scoped preview/download params: report filters + optional `columns` selection. */
|
|
69
|
+
export interface ExportRunParams {
|
|
70
|
+
/** Ordered column keys to include (`?columns=a,b,c`). Omit for the report defaults. */
|
|
71
|
+
columns?: string[];
|
|
72
|
+
/** `csv` or `xlsx` (download only; defaults to `xlsx` server-side). */
|
|
73
|
+
format?: 'csv' | 'xlsx';
|
|
74
|
+
/** Preview page size (`preview_limit`, 0 = all). */
|
|
75
|
+
preview_limit?: number;
|
|
76
|
+
/** Any additional report filter params (date_from, status, …). */
|
|
77
|
+
[param: string]: string | number | boolean | null | undefined | string[];
|
|
78
|
+
}
|
|
79
|
+
/** A downloaded export file: the binary blob plus the server-suggested filename. */
|
|
80
|
+
export interface ExportDownload {
|
|
81
|
+
blob: Blob;
|
|
82
|
+
filename: string;
|
|
83
|
+
}
|
|
84
|
+
export declare function createExportsNamespace(http: Http, config: NuwahClientConfig): {
|
|
85
|
+
/** GET /api/exports — the report cards the caller may access. */
|
|
86
|
+
catalog: () => Promise<ExportReportCard[]>;
|
|
87
|
+
/** GET /api/exports/{report}/preview — keyed rows + total + summary. */
|
|
88
|
+
preview: (report: string, params?: ExportRunParams) => Promise<ExportPreview>;
|
|
89
|
+
/** GET /api/exports/{report}/presets — the acting user's presets for one report. */
|
|
90
|
+
presets: (report: string) => Promise<ExportPreset[]>;
|
|
91
|
+
/**
|
|
92
|
+
* GET /api/exports/{report}/default?role= — the tenant's shared role-default
|
|
93
|
+
* preset for one report, or `null` when none is seeded. Used by Report Studio
|
|
94
|
+
* to pre-select a sensible column/filter set the first time a role opens a
|
|
95
|
+
* report it has no saved preset for.
|
|
96
|
+
*/
|
|
97
|
+
defaultPreset: (report: string, role: string) => Promise<ExportPreset | null>;
|
|
98
|
+
/** POST /api/exports/{report}/presets — save a new named preset (201). */
|
|
99
|
+
createPreset: (report: string, body: CreateExportPresetInput) => Promise<ExportPreset>;
|
|
100
|
+
/** PATCH /api/exports/presets/{id} — rename / update columns + filters. */
|
|
101
|
+
updatePreset: (id: string, body: UpdateExportPresetInput) => Promise<ExportPreset>;
|
|
102
|
+
/** DELETE /api/exports/presets/{id} — remove a preset (204). */
|
|
103
|
+
deletePreset: (id: string) => Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* GET /api/exports/{report} — download the report as a CSV/XLSX file.
|
|
106
|
+
*
|
|
107
|
+
* The transport `http` layer parses JSON, so the streamed binary is fetched
|
|
108
|
+
* directly here (same bearer token + query contract) and returned as a
|
|
109
|
+
* `{ blob, filename }` for the caller to save.
|
|
110
|
+
*/
|
|
111
|
+
download: (report: string, params?: ExportRunParams) => Promise<ExportDownload>;
|
|
112
|
+
};
|
|
113
|
+
export type ExportsNamespace = ReturnType<typeof createExportsNamespace>;
|
package/dist/exports.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
function toQuery(params) {
|
|
3
|
+
if (!params)
|
|
4
|
+
return {};
|
|
5
|
+
const { columns, ...rest } = params;
|
|
6
|
+
const out = { ...rest };
|
|
7
|
+
if (columns && columns.length > 0)
|
|
8
|
+
out.columns = columns.join(',');
|
|
9
|
+
return out;
|
|
10
|
+
}
|
|
11
|
+
export function createExportsNamespace(http, config) {
|
|
12
|
+
const baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
13
|
+
return {
|
|
14
|
+
|
|
15
|
+
catalog: () => http
|
|
16
|
+
.get('/api/exports')
|
|
17
|
+
.then((r) => r.data),
|
|
18
|
+
|
|
19
|
+
preview: (report, params) => http
|
|
20
|
+
.get(`/api/exports/${report}/preview`, {
|
|
21
|
+
params: toQuery(params),
|
|
22
|
+
})
|
|
23
|
+
.then((r) => r.data),
|
|
24
|
+
|
|
25
|
+
presets: (report) => http
|
|
26
|
+
.get(`/api/exports/${report}/presets`)
|
|
27
|
+
.then((r) => r.data),
|
|
28
|
+
|
|
29
|
+
defaultPreset: (report, role) => http
|
|
30
|
+
.get(`/api/exports/${report}/default`, {
|
|
31
|
+
params: { role },
|
|
32
|
+
})
|
|
33
|
+
.then((r) => r.data),
|
|
34
|
+
|
|
35
|
+
createPreset: (report, body) => http
|
|
36
|
+
.post(`/api/exports/${report}/presets`, body)
|
|
37
|
+
.then((r) => r.data),
|
|
38
|
+
|
|
39
|
+
updatePreset: (id, body) => http
|
|
40
|
+
.patch(`/api/exports/presets/${id}`, body)
|
|
41
|
+
.then((r) => r.data),
|
|
42
|
+
|
|
43
|
+
deletePreset: (id) => http.delete(`/api/exports/presets/${id}`),
|
|
44
|
+
|
|
45
|
+
download: async (report, params) => {
|
|
46
|
+
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
47
|
+
const token = await config.getToken();
|
|
48
|
+
const search = new URLSearchParams();
|
|
49
|
+
const q = toQuery(params);
|
|
50
|
+
for (const [key, value] of Object.entries(q)) {
|
|
51
|
+
if (value === null || value === undefined)
|
|
52
|
+
continue;
|
|
53
|
+
if (Array.isArray(value)) {
|
|
54
|
+
for (const item of value)
|
|
55
|
+
search.append(`${key}[]`, String(item));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
search.append(key, String(value));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const qs = search.toString();
|
|
62
|
+
const response = await fetchImpl(`${baseUrl}/api/exports/${report}${qs ? `?${qs}` : ''}`, {
|
|
63
|
+
method: 'GET',
|
|
64
|
+
headers: {
|
|
65
|
+
Accept: 'application/octet-stream',
|
|
66
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
67
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new Error(`Export download failed with status ${response.status}`);
|
|
72
|
+
}
|
|
73
|
+
const blob = await response.blob();
|
|
74
|
+
const fallback = `${report}-${new Date().toISOString().slice(0, 10)}.${params?.format ?? 'xlsx'}`;
|
|
75
|
+
const disposition = response.headers.get('content-disposition') ?? '';
|
|
76
|
+
const match = disposition.match(/filename\*?=(?:UTF-8'')?"?([^;"]+)"?/i);
|
|
77
|
+
const filename = match ? decodeURIComponent(match[1]) : fallback;
|
|
78
|
+
return { blob, filename };
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
package/dist/feeds.d.ts
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type ActorSummary, type BilingualText, type PartyReferenceString, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
|
|
3
|
+
import type { Publication } from './publications.js';
|
|
4
|
+
import type { RankingReason } from './ranking.js';
|
|
5
|
+
/** Who a declared feed is assembled for. `author` feeds need an `author` on every page call. */
|
|
6
|
+
export type FeedAudience = 'connections' | 'author' | 'explicit' | 'discovery' | (string & {});
|
|
7
|
+
/** One declared feed, for building tabs. */
|
|
8
|
+
export interface FeedDefinition {
|
|
9
|
+
key: string;
|
|
10
|
+
label: BilingualText;
|
|
11
|
+
audience: FeedAudience;
|
|
12
|
+
/** True for an author feed: pass `author` (`actor:<uuid>` or `organisation:<uuid>`). */
|
|
13
|
+
requires_author: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Reactions on a feed item as this viewer may see them; null when the subject has none to show. */
|
|
16
|
+
export interface FeedItemReactions {
|
|
17
|
+
/** Null when the counts are hidden from this viewer — not zero. */
|
|
18
|
+
counts: Record<string, number> | null;
|
|
19
|
+
total: number | null;
|
|
20
|
+
viewer_keys: string[];
|
|
21
|
+
}
|
|
22
|
+
/** One feed entry. `content` is the source's rendering for this viewer, passed through. */
|
|
23
|
+
export interface FeedItem<Content = Record<string, unknown>> {
|
|
24
|
+
subject_type: string;
|
|
25
|
+
id: string;
|
|
26
|
+
source_key: string;
|
|
27
|
+
published_at: string;
|
|
28
|
+
expires_at: string | null;
|
|
29
|
+
repost_of_id: string | null;
|
|
30
|
+
/** The position the ranker gave it on this page. */
|
|
31
|
+
position: number;
|
|
32
|
+
/** The author as this viewer may see them (a neutral placeholder when the directory was down). */
|
|
33
|
+
author: ActorSummary & {
|
|
34
|
+
kind: string;
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
content: Content;
|
|
38
|
+
reactions: FeedItemReactions | null;
|
|
39
|
+
viewer: {
|
|
40
|
+
/** What the viewer is connected to the author BY. Nothing about restrictions is sent. */
|
|
41
|
+
connection_kinds: string[];
|
|
42
|
+
is_own: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The strongest reason a RANKED feed placed this item here (null in a chronological feed).
|
|
46
|
+
* Show it as the entry point of "Why am I seeing this"; the full list comes from
|
|
47
|
+
* {@link FeedsNamespace.why}. Never a count — a reason names the signal, not a number.
|
|
48
|
+
*/
|
|
49
|
+
top_reason?: RankingReason | null;
|
|
50
|
+
/** Set only on a sponsored placement: it MUST be labelled with `label` wherever it renders. */
|
|
51
|
+
sponsored?: FeedSponsoredPlacement | null;
|
|
52
|
+
}
|
|
53
|
+
export interface FeedSponsoredPlacement {
|
|
54
|
+
label: BilingualText;
|
|
55
|
+
advertiser: ActorSummary & {
|
|
56
|
+
kind?: string;
|
|
57
|
+
id?: string;
|
|
58
|
+
};
|
|
59
|
+
campaign_key: string;
|
|
60
|
+
}
|
|
61
|
+
/** A dimension a person can ask to see less of. */
|
|
62
|
+
export type FeedShowLessDimension = 'author' | 'category' | 'subject_type';
|
|
63
|
+
/** GET /{feedKey}/why/{subjectType}/{id} — why an item was shown to this viewer. */
|
|
64
|
+
export interface FeedItemExplanation {
|
|
65
|
+
/** Strongest first, at most four, both languages. */
|
|
66
|
+
reasons: RankingReason[];
|
|
67
|
+
/** Whether the viewer's own interests shaped the order (false for minors, always). */
|
|
68
|
+
personalised: boolean;
|
|
69
|
+
ranker_key: string;
|
|
70
|
+
sponsored: FeedSponsoredPlacement | null;
|
|
71
|
+
/** True when answered from the page the item was served on; false when recomputed. */
|
|
72
|
+
from_page: boolean;
|
|
73
|
+
controls: {
|
|
74
|
+
can_show_less: boolean;
|
|
75
|
+
/** The dimensions this item offers for "show less like this". */
|
|
76
|
+
show_less: FeedShowLessDimension[];
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** One "show less like this" the person recorded. */
|
|
80
|
+
export interface FeedShowLessEntry {
|
|
81
|
+
id: string;
|
|
82
|
+
dimension: FeedShowLessDimension;
|
|
83
|
+
/** Server-derived: an author reference, a category key or a subject type. */
|
|
84
|
+
key: string;
|
|
85
|
+
label: BilingualText;
|
|
86
|
+
created_at: string;
|
|
87
|
+
}
|
|
88
|
+
export interface FeedPersonalisationState {
|
|
89
|
+
answer: 'personalised' | 'not_personalised' | 'unanswered' | (string & {});
|
|
90
|
+
personalised: boolean;
|
|
91
|
+
should_ask: boolean;
|
|
92
|
+
/** False for a minor (never personalised) — hide the switch, explain why. */
|
|
93
|
+
switch_available: boolean;
|
|
94
|
+
is_minor: boolean;
|
|
95
|
+
policy?: {
|
|
96
|
+
value: string;
|
|
97
|
+
decided_at: string;
|
|
98
|
+
label: BilingualText;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** GET /preferences — feed settings. */
|
|
102
|
+
export interface FeedPreferences {
|
|
103
|
+
personalisation: FeedPersonalisationState | null;
|
|
104
|
+
show_less: {
|
|
105
|
+
/** `off` (the feature is turned off here), `demote` or `hide`. */
|
|
106
|
+
mode: 'off' | 'demote' | 'hide' | (string & {});
|
|
107
|
+
mode_label: BilingualText;
|
|
108
|
+
entries: FeedShowLessEntry[];
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** POST /preferences/reset — what was cleared. */
|
|
112
|
+
export interface FeedPreferencesReset {
|
|
113
|
+
show_less_removed: number;
|
|
114
|
+
interests_forgotten: number;
|
|
115
|
+
}
|
|
116
|
+
export type PublicationFeedItem = FeedItem<PublicationFeedContent>;
|
|
117
|
+
/** A publication feed entry's content: the item, plus the first feed shape's three keys. */
|
|
118
|
+
export type PublicationFeedContent = Publication & {
|
|
119
|
+
/** Same as `kind`. */
|
|
120
|
+
kind_key: string;
|
|
121
|
+
/** Same as `audience`. */
|
|
122
|
+
visibility: Publication['audience'];
|
|
123
|
+
/** `mentions` as `kind:id` strings. */
|
|
124
|
+
mention_references: string[];
|
|
125
|
+
};
|
|
126
|
+
/** The subject type a publications feed entry carries. */
|
|
127
|
+
export declare const PUBLICATION_FEED_SUBJECT_TYPE = "publications.item";
|
|
128
|
+
/** Narrow a feed entry to a publication (then `content` is a {@link Publication}). */
|
|
129
|
+
export declare function isPublicationFeedItem(item: FeedItem): item is FeedItem & PublicationFeedItem;
|
|
130
|
+
/** A feed page: the items plus what the server says about how it was assembled. */
|
|
131
|
+
export interface FeedPage<Content = Record<string, unknown>> {
|
|
132
|
+
data: Array<FeedItem<Content>>;
|
|
133
|
+
feed_key: string;
|
|
134
|
+
/** The feed actually served — differs from `feed_key` when the cold-start fallback was used. */
|
|
135
|
+
served_feed_key: string;
|
|
136
|
+
is_fallback: boolean;
|
|
137
|
+
ranker_key: string;
|
|
138
|
+
next_cursor: string | null;
|
|
139
|
+
/** Sources that failed for this page; their items are missing. Calm notice, not an error. */
|
|
140
|
+
degraded_sources: string[];
|
|
141
|
+
/** Pass to {@link FeedsNamespace.why} so "why" answers from this exact page (15 minutes). */
|
|
142
|
+
page_token?: string | null;
|
|
143
|
+
/** Whether the viewer's own interests shaped this page. */
|
|
144
|
+
personalised?: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface FeedPageQuery {
|
|
147
|
+
/** Required by author feeds: `actor:<uuid>` or `organisation:<uuid>` — never a bare person. */
|
|
148
|
+
author?: Extract<PartyReferenceString, `actor:${string}` | `organisation:${string}`> | null;
|
|
149
|
+
cursor?: string | null;
|
|
150
|
+
/** Clamped by the server to 50, never refused. */
|
|
151
|
+
limit?: number;
|
|
152
|
+
}
|
|
153
|
+
/** One ephemeral item inside a tray entry (a kind with a lifetime that never reaches feeds). */
|
|
154
|
+
export interface EphemeralTrayItem {
|
|
155
|
+
id: string;
|
|
156
|
+
kind: string;
|
|
157
|
+
published_at: string;
|
|
158
|
+
expires_at: string | null;
|
|
159
|
+
/** The acting viewer already opened it. */
|
|
160
|
+
viewed: boolean;
|
|
161
|
+
media: Array<{
|
|
162
|
+
id: string;
|
|
163
|
+
mime_type: string;
|
|
164
|
+
signed_path: string | null;
|
|
165
|
+
path: string;
|
|
166
|
+
alt_text: {
|
|
167
|
+
en: string | null;
|
|
168
|
+
ar: string | null;
|
|
169
|
+
};
|
|
170
|
+
}>;
|
|
171
|
+
body: string | null;
|
|
172
|
+
body_direction: 'ltr' | 'rtl' | null;
|
|
173
|
+
}
|
|
174
|
+
/** One author in the tray, with their live ephemeral items oldest first. */
|
|
175
|
+
export interface EphemeralTrayEntry {
|
|
176
|
+
author: ActorSummary & {
|
|
177
|
+
kind?: string;
|
|
178
|
+
id?: string;
|
|
179
|
+
};
|
|
180
|
+
is_own: boolean;
|
|
181
|
+
has_unseen: boolean;
|
|
182
|
+
latest_published_at: string;
|
|
183
|
+
items: EphemeralTrayItem[];
|
|
184
|
+
}
|
|
185
|
+
/** The ephemeral tray, ordered by the server: own first, then unseen, then fully seen. */
|
|
186
|
+
export interface EphemeralTrayPage {
|
|
187
|
+
data: EphemeralTrayEntry[];
|
|
188
|
+
next_cursor: string | null;
|
|
189
|
+
}
|
|
190
|
+
/** The core discovery feed ranked by recent engagement, spread across authors. */
|
|
191
|
+
export declare const EXPLORE_FEED_KEY = "public.explore";
|
|
192
|
+
/** At most this many ids per `markSeen` call (`MarkFeedItemsSeenAction::MAXIMUM_IDS`). */
|
|
193
|
+
export declare const FEED_SEEN_BATCH_MAXIMUM = 50;
|
|
194
|
+
export declare function createFeedsNamespace(http: Http): {
|
|
195
|
+
/** GET /api/person/feeds — the declared feeds (for tabs). */
|
|
196
|
+
definitions: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<FeedDefinition[]>>;
|
|
197
|
+
/** GET /{feedKey}?author=&cursor=&limit= — one cursor page. An unknown key answers 404. */
|
|
198
|
+
page: <Content = Record<string, unknown>>(feedKey: string, query?: FeedPageQuery, options?: PersonDomainCallOptions) => Promise<FeedPage<Content>>;
|
|
199
|
+
/**
|
|
200
|
+
* GET /{feedKey}/why/{subjectType}/{id}?page_token= — "Why am I seeing this". 404 when the
|
|
201
|
+
* viewer may not see the item now. The answer fits `WhyAmISeeingSheet`'s `load` as is.
|
|
202
|
+
*/
|
|
203
|
+
why: (feedKey: string, subjectType: string, id: string, pageToken?: string | null, options?: PersonDomainCallOptions) => Promise<FeedItemExplanation>;
|
|
204
|
+
/** GET /preferences — personalisation state and the "show less" list. */
|
|
205
|
+
preferences: (options?: PersonDomainCallOptions) => Promise<FeedPreferences>;
|
|
206
|
+
/** POST /preferences/show-less — less of this item's author, category or kind (server derives the key). */
|
|
207
|
+
showLess: (feedKey: string, subjectType: string, id: string, dimension: FeedShowLessDimension, options?: PersonDomainCallOptions) => Promise<FeedShowLessEntry>;
|
|
208
|
+
/** DELETE /preferences/show-less/{entry} — undo one. */
|
|
209
|
+
undoShowLess: (entryId: string, options?: PersonDomainCallOptions) => Promise<{
|
|
210
|
+
removed: boolean;
|
|
211
|
+
}>;
|
|
212
|
+
/** POST /preferences/reset — remove every "show less" and forget learned interests (the personalisation answer stays). */
|
|
213
|
+
resetPreferences: (options?: PersonDomainCallOptions) => Promise<FeedPreferencesReset>;
|
|
214
|
+
/** GET /api/person/ephemeral-tray — the ephemeral tray for the acting viewer (≤ 30 authors a page). */
|
|
215
|
+
ephemeralTray: (query?: {
|
|
216
|
+
cursor?: string | null;
|
|
217
|
+
limit?: number;
|
|
218
|
+
}, options?: PersonDomainCallOptions) => Promise<EphemeralTrayPage>;
|
|
219
|
+
/**
|
|
220
|
+
* POST /{feedKey}/seen — record that items were shown. Idempotent by nature (a second mark
|
|
221
|
+
* is a no-op); ids the viewer may not see are silently skipped. At most
|
|
222
|
+
* {@link FEED_SEEN_BATCH_MAXIMUM} ids: this splits a longer list into several calls.
|
|
223
|
+
*/
|
|
224
|
+
markSeen: (feedKey: string, subjectType: string, ids: string[], options?: PersonDomainCallOptions) => Promise<{
|
|
225
|
+
recorded: number;
|
|
226
|
+
}>;
|
|
227
|
+
};
|
|
228
|
+
export type FeedsNamespace = ReturnType<typeof createFeedsNamespace>;
|
package/dist/feeds.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { personDomainRequest, } from './actors.js';
|
|
2
|
+
|
|
3
|
+
export const PUBLICATION_FEED_SUBJECT_TYPE = 'publications.item';
|
|
4
|
+
|
|
5
|
+
export function isPublicationFeedItem(item) {
|
|
6
|
+
return item.subject_type === PUBLICATION_FEED_SUBJECT_TYPE;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const EXPLORE_FEED_KEY = 'public.explore';
|
|
10
|
+
|
|
11
|
+
export const FEED_SEEN_BATCH_MAXIMUM = 50;
|
|
12
|
+
const BASE = '/api/person/feeds';
|
|
13
|
+
export function createFeedsNamespace(http) {
|
|
14
|
+
return {
|
|
15
|
+
|
|
16
|
+
definitions: (options) => http.get(BASE, personDomainRequest(options, false)),
|
|
17
|
+
|
|
18
|
+
page: (feedKey, query = {}, options) => http.get(`${BASE}/${encodeURIComponent(feedKey)}`, personDomainRequest(options, false, {
|
|
19
|
+
author: query.author ?? undefined,
|
|
20
|
+
cursor: query.cursor ?? undefined,
|
|
21
|
+
limit: query.limit,
|
|
22
|
+
})),
|
|
23
|
+
|
|
24
|
+
why: async (feedKey, subjectType, id, pageToken, options) => {
|
|
25
|
+
const answer = await http.get(`${BASE}/${encodeURIComponent(feedKey)}/why/${encodeURIComponent(subjectType)}/${encodeURIComponent(id)}`, personDomainRequest(options, false, { page_token: pageToken ?? undefined }));
|
|
26
|
+
return answer.data;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
preferences: async (options) => (await http.get(`${BASE}/preferences`, personDomainRequest(options, false))).data,
|
|
30
|
+
|
|
31
|
+
showLess: async (feedKey, subjectType, id, dimension, options) => (await http.post(`${BASE}/preferences/show-less`, { feed_key: feedKey, subject_type: subjectType, id, dimension }, personDomainRequest(options, true))).data,
|
|
32
|
+
|
|
33
|
+
undoShowLess: async (entryId, options) => (await http.delete(`${BASE}/preferences/show-less/${encodeURIComponent(entryId)}`, personDomainRequest(options, true))).data,
|
|
34
|
+
|
|
35
|
+
resetPreferences: async (options) => (await http.post(`${BASE}/preferences/reset`, {}, personDomainRequest(options, true))).data,
|
|
36
|
+
|
|
37
|
+
ephemeralTray: (query = {}, options) => http.get('/api/person/ephemeral-tray', personDomainRequest(options, false, { cursor: query.cursor ?? undefined, limit: query.limit })),
|
|
38
|
+
|
|
39
|
+
markSeen: async (feedKey, subjectType, ids, options) => {
|
|
40
|
+
let recorded = 0;
|
|
41
|
+
for (let start = 0, batch = 0; start < ids.length; start += FEED_SEEN_BATCH_MAXIMUM, batch++) {
|
|
42
|
+
|
|
43
|
+
const batchOptions = options?.idempotencyKey && batch > 0
|
|
44
|
+
? { ...options, idempotencyKey: `${options.idempotencyKey}-${batch}` }
|
|
45
|
+
: options;
|
|
46
|
+
const answer = await http.post(`${BASE}/${encodeURIComponent(feedKey)}/seen`, { subject_type: subjectType, ids: ids.slice(start, start + FEED_SEEN_BATCH_MAXIMUM) }, personDomainRequest(batchOptions, true));
|
|
47
|
+
recorded += answer.recorded;
|
|
48
|
+
}
|
|
49
|
+
return { recorded };
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Http, type RequestOptions, type QueryParams, type NuwahClientConfig } from './http.js';
|
|
2
|
+
/** One row from the normalised list projection (FilesClient::listForTenant). */
|
|
3
|
+
export interface PlatformFile {
|
|
4
|
+
id: string;
|
|
5
|
+
/** Original filename (normalised from files-verse's `original_filename`). */
|
|
6
|
+
name: string | null;
|
|
7
|
+
mime: string | null;
|
|
8
|
+
/** Size in bytes (number when files-verse reports it). */
|
|
9
|
+
size: number | null;
|
|
10
|
+
status: string | null;
|
|
11
|
+
created_at: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `GET /api/platform/files`. `available:false` (with an empty `files`) is a NORMAL,
|
|
15
|
+
* non-error response meaning the file plane is down/unconfigured — surface it, don't throw.
|
|
16
|
+
*/
|
|
17
|
+
export interface FileListResponse {
|
|
18
|
+
available: boolean;
|
|
19
|
+
files: PlatformFile[];
|
|
20
|
+
message: string | null;
|
|
21
|
+
}
|
|
22
|
+
/** `POST /api/platform/files` → `201 { id }` on success (id = the new file's uuid). */
|
|
23
|
+
export interface FileUploadResult {
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
export interface FileDeleteResult {
|
|
27
|
+
deleted: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function createFilesNamespace(http: Http, config: NuwahClientConfig): {
|
|
30
|
+
/**
|
|
31
|
+
* GET /api/platform/files — list the tenant's attachments.
|
|
32
|
+
* (The server currently ignores query params; `params` is accepted for
|
|
33
|
+
* forward-compat and header/signal passthrough.)
|
|
34
|
+
*/
|
|
35
|
+
list: (params?: QueryParams, options?: RequestOptions) => Promise<FileListResponse>;
|
|
36
|
+
download: (uuid: string, options?: RequestOptions) => Promise<Blob>;
|
|
37
|
+
downloadUrl: (uuid: string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* POST /api/platform/files — multipart upload. Field name is `file` (max 20 MB).
|
|
40
|
+
*
|
|
41
|
+
* Pass a browser `File`/`Blob` (or any Blob-like). In the browser a `File`
|
|
42
|
+
* carries its own name; for a bare `Blob` pass `filename` explicitly.
|
|
43
|
+
*
|
|
44
|
+
* Upload contract, if you'd rather build the request yourself:
|
|
45
|
+
* `Content-Type: multipart/form-data` with a single `file` part; the SDK's
|
|
46
|
+
* transport sets the boundary automatically for `FormData` bodies.
|
|
47
|
+
*/
|
|
48
|
+
upload: (file: Blob, filename?: string, options?: RequestOptions) => Promise<FileUploadResult>;
|
|
49
|
+
/**
|
|
50
|
+
* POST /api/platform/files — upload a pre-built `FormData` (single `file` part).
|
|
51
|
+
* Use when you need full control over the multipart body.
|
|
52
|
+
*/
|
|
53
|
+
uploadForm: (form: FormData, options?: RequestOptions) => Promise<FileUploadResult>;
|
|
54
|
+
remove: (uuid: string, options?: RequestOptions) => Promise<FileDeleteResult>;
|
|
55
|
+
};
|
|
56
|
+
export type FilesNamespace = ReturnType<typeof createFilesNamespace>;
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { NuwahApiError } from './http.js';
|
|
4
|
+
export function createFilesNamespace(http, config) {
|
|
5
|
+
const baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
6
|
+
return {
|
|
7
|
+
|
|
8
|
+
list: (params, options) => http.get('/api/platform/files', { ...options, params }),
|
|
9
|
+
|
|
10
|
+
download: async (uuid, options) => {
|
|
11
|
+
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
12
|
+
if (typeof fetchImpl !== 'function') {
|
|
13
|
+
throw new Error('No fetch implementation available. Pass `fetch` in the client config on runtimes without a global fetch.');
|
|
14
|
+
}
|
|
15
|
+
const token = await config.getToken();
|
|
16
|
+
const extraHeaders = typeof config.defaultHeaders === 'function' ? config.defaultHeaders() : config.defaultHeaders;
|
|
17
|
+
const response = await fetchImpl(`${baseUrl}/api/platform/files/${uuid}`, {
|
|
18
|
+
method: 'GET',
|
|
19
|
+
signal: options?.signal,
|
|
20
|
+
headers: {
|
|
21
|
+
Accept: 'application/octet-stream',
|
|
22
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
23
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
24
|
+
...extraHeaders,
|
|
25
|
+
...options?.headers,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const text = await response.text().catch(() => '');
|
|
30
|
+
throw new NuwahApiError(response.status, text || null);
|
|
31
|
+
}
|
|
32
|
+
return response.blob();
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
downloadUrl: (uuid) => `${baseUrl}/api/platform/files/${uuid}`,
|
|
36
|
+
|
|
37
|
+
upload: (file, filename, options) => {
|
|
38
|
+
const form = new FormData();
|
|
39
|
+
if (filename) {
|
|
40
|
+
form.append('file', file, filename);
|
|
41
|
+
}
|
|
42
|
+
else if (typeof File !== 'undefined' && file instanceof File) {
|
|
43
|
+
form.append('file', file, file.name);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
form.append('file', file);
|
|
47
|
+
}
|
|
48
|
+
return http.post('/api/platform/files', form, options);
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
uploadForm: (form, options) => http.post('/api/platform/files', form, options),
|
|
52
|
+
|
|
53
|
+
remove: (uuid, options) => http.delete(`/api/platform/files/${uuid}`, options),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AccountingNamespace } from './accounting.js';
|
|
2
|
+
/** The Deferred (unearned) Revenue liability account code in the default CoA. */
|
|
3
|
+
export declare const DEFERRED_REVENUE_CODE = "2300";
|
|
4
|
+
export interface DeferredPosition {
|
|
5
|
+
/** Whether a Deferred Revenue account (code 2300) exists in the chart. */
|
|
6
|
+
accountExists: boolean;
|
|
7
|
+
accountUuid: string | null;
|
|
8
|
+
/** Outstanding unearned liability = balance of account 2300 as of the date. */
|
|
9
|
+
balance: string;
|
|
10
|
+
asOf: string;
|
|
11
|
+
}
|
|
12
|
+
/** Build the finance-insight loaders against one app's accounting namespace. */
|
|
13
|
+
export interface RecognitionMovement {
|
|
14
|
+
accountExists: boolean;
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
openingBalance: string;
|
|
18
|
+
closingBalance: string;
|
|
19
|
+
/** New deferrals booked in the window = credits to account 2300 (packages sold). */
|
|
20
|
+
deferred: string;
|
|
21
|
+
/** Revenue recognised in the window = debits to account 2300 (credits redeemed). */
|
|
22
|
+
recognized: string;
|
|
23
|
+
/** Net change in the unearned liability over the window (deferred − recognized). */
|
|
24
|
+
netChange: string;
|
|
25
|
+
}
|
|
26
|
+
export interface InsuranceSplit {
|
|
27
|
+
/** Receivables owed by patients (AR invoices, all aging buckets). */
|
|
28
|
+
patientAr: string;
|
|
29
|
+
/** Receivables owed by insurers (open claims, billed less anything paid). */
|
|
30
|
+
insurerAr: string;
|
|
31
|
+
total: string;
|
|
32
|
+
/** insurerAr ÷ total (0–1), or null when nothing is outstanding. */
|
|
33
|
+
insurerShare: number | null;
|
|
34
|
+
openClaimCount: number;
|
|
35
|
+
}
|
|
36
|
+
export declare function createFinanceInsights(accounting: AccountingNamespace): {
|
|
37
|
+
loadDeferredPosition: (asOf: string) => Promise<DeferredPosition>;
|
|
38
|
+
loadRecognitionMovement: (from: string, to: string) => Promise<RecognitionMovement>;
|
|
39
|
+
loadInsuranceSplit: () => Promise<InsuranceSplit>;
|
|
40
|
+
};
|
|
41
|
+
export type FinanceInsights = ReturnType<typeof createFinanceInsights>;
|