@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,119 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
/** One persisted widget in a dashboard `layout`. The FE owns the concrete schema. */
|
|
3
|
+
export type DashboardWidget = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* One metric inside a manager-overview widget. `value` is a server-side number
|
|
6
|
+
* (money is a rounded decimal, percent is 0..100, count is an integer). `base`
|
|
7
|
+
* names the denominator for ratio/percent metrics; `format` drives display.
|
|
8
|
+
*
|
|
9
|
+
* Find a metric by `key`, and show `display_label`. Both are optional because a core older
|
|
10
|
+
* than Dashboards contract 0.3.0 omits them; against such a core, fall back to `label`.
|
|
11
|
+
*/
|
|
12
|
+
export interface ManagerOverviewMetric {
|
|
13
|
+
/** Stable snake_case identifier, unique within its widget (e.g. `room_occupancy`). */
|
|
14
|
+
key?: string;
|
|
15
|
+
/** The ENGLISH name, unchanged since before `key` existed — kept for older clients. */
|
|
16
|
+
label: string;
|
|
17
|
+
/** The name in the reader's language (the request's Accept-Language). */
|
|
18
|
+
display_label?: string;
|
|
19
|
+
value: number;
|
|
20
|
+
base: string | null;
|
|
21
|
+
trend: 'up' | 'down' | 'flat' | null;
|
|
22
|
+
cta: string | null;
|
|
23
|
+
format: 'count' | 'money' | 'percent' | 'ratio';
|
|
24
|
+
/** Present only on `ratio` metrics. */
|
|
25
|
+
numerator?: number;
|
|
26
|
+
denominator?: number;
|
|
27
|
+
percent?: number | null;
|
|
28
|
+
}
|
|
29
|
+
/** One cross-module domain widget in the manager cockpit. */
|
|
30
|
+
export interface ManagerOverviewWidget {
|
|
31
|
+
key: string;
|
|
32
|
+
domain: string;
|
|
33
|
+
label: string;
|
|
34
|
+
cta: string | null;
|
|
35
|
+
metrics: ManagerOverviewMetric[];
|
|
36
|
+
}
|
|
37
|
+
/** The manager-overview envelope (BARE — not `{ data }` wrapped). */
|
|
38
|
+
export interface ManagerOverview {
|
|
39
|
+
period: {
|
|
40
|
+
key: string;
|
|
41
|
+
label: string;
|
|
42
|
+
starts_at: string;
|
|
43
|
+
ends_at: string;
|
|
44
|
+
};
|
|
45
|
+
lens: string | null;
|
|
46
|
+
widgets: ManagerOverviewWidget[];
|
|
47
|
+
}
|
|
48
|
+
export interface Dashboard {
|
|
49
|
+
id: string;
|
|
50
|
+
tenant_id?: string;
|
|
51
|
+
/** `null` ⇒ tenant-shared; a subject id ⇒ private to that user. */
|
|
52
|
+
owner_id: string | null;
|
|
53
|
+
/** A workspace role key when this is a per-role template; `null`/absent otherwise. */
|
|
54
|
+
role?: string | null;
|
|
55
|
+
/** `true` (with `role` set + `owner_id` null) ⇒ the tenant's default template for that role. */
|
|
56
|
+
is_default?: boolean;
|
|
57
|
+
name: string;
|
|
58
|
+
/** Sort order within the caller's dashboard list. */
|
|
59
|
+
position: number;
|
|
60
|
+
/** The persisted widget array (FE-owned schema). */
|
|
61
|
+
layout: DashboardWidget[];
|
|
62
|
+
created_at: string | null;
|
|
63
|
+
updated_at: string | null;
|
|
64
|
+
}
|
|
65
|
+
export interface DashboardInput {
|
|
66
|
+
name: string;
|
|
67
|
+
/** The widget array to persist. Defaults to `[]` server-side when omitted. */
|
|
68
|
+
layout?: DashboardWidget[];
|
|
69
|
+
position?: number;
|
|
70
|
+
/** `true` ⇒ create a tenant-shared dashboard (owner_id null). Defaults to private. */
|
|
71
|
+
shared?: boolean;
|
|
72
|
+
/** Tag this dashboard as a per-role template (a workspace role key). */
|
|
73
|
+
role?: string | null;
|
|
74
|
+
/** With `role` set + `shared: true`, marks this the role's default starter template. */
|
|
75
|
+
is_default?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** PUT body — a partial patch (every field is `sometimes` server-side). `shared` is ignored on update. */
|
|
78
|
+
export type UpdateDashboardInput = Partial<DashboardInput>;
|
|
79
|
+
export declare function createDashboardsNamespace(http: Http): {
|
|
80
|
+
/** GET /api/dashboards — the caller's own + tenant-shared dashboards, `{ data }` (no meta). */
|
|
81
|
+
list: () => Promise<{
|
|
82
|
+
data: Dashboard[];
|
|
83
|
+
}>;
|
|
84
|
+
/** GET /api/dashboards/{id} — `{ data }`. */
|
|
85
|
+
get: (id: string) => Promise<{
|
|
86
|
+
data: Dashboard;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* GET /api/dashboards/default?role= — the tenant's DEFAULT template for a role
|
|
90
|
+
* (owner_id null, is_default true). `{ data }` is `null` when the role has none.
|
|
91
|
+
*/
|
|
92
|
+
defaultFor: (role: string) => Promise<{
|
|
93
|
+
data: Dashboard | null;
|
|
94
|
+
}>;
|
|
95
|
+
/** POST /api/dashboards — 201, `{ data }`. */
|
|
96
|
+
create: (input: DashboardInput) => Promise<{
|
|
97
|
+
data: Dashboard;
|
|
98
|
+
}>;
|
|
99
|
+
/** PUT /api/dashboards/{id} — partial patch, `{ data }`. */
|
|
100
|
+
update: (id: string, input: UpdateDashboardInput) => Promise<{
|
|
101
|
+
data: Dashboard;
|
|
102
|
+
}>;
|
|
103
|
+
/** DELETE /api/dashboards/{id} — 204. */
|
|
104
|
+
remove: (id: string) => Promise<void>;
|
|
105
|
+
/** POST /api/dashboards/{id}/duplicate — 201, `{ data }` (a private copy owned by the caller). */
|
|
106
|
+
duplicate: (id: string) => Promise<{
|
|
107
|
+
data: Dashboard;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* GET /api/manager/overview — the READ-ONLY manager cross-module cockpit.
|
|
111
|
+
* `period` is soft (`this_week`/`this_month`/`this_quarter`; unknown ⇒
|
|
112
|
+
* this_month). `lens` narrows to a role subset (`accountant` /
|
|
113
|
+
* `clinic_admin` / `clinic_manager` / `insurance_coordinator` / `clinician`
|
|
114
|
+
* for clinics); `''`/omitted ⇒ the whole cockpit. Emits the BARE envelope
|
|
115
|
+
* (`{ period, lens, widgets }`), NOT `{ data }`.
|
|
116
|
+
*/
|
|
117
|
+
managerOverview: (period: string, lens?: string) => Promise<ManagerOverview>;
|
|
118
|
+
};
|
|
119
|
+
export type DashboardsNamespace = ReturnType<typeof createDashboardsNamespace>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function createDashboardsNamespace(http) {
|
|
2
|
+
return {
|
|
3
|
+
|
|
4
|
+
list: () => http.get('/api/dashboards'),
|
|
5
|
+
|
|
6
|
+
get: (id) => http.get(`/api/dashboards/${id}`),
|
|
7
|
+
|
|
8
|
+
defaultFor: (role) => http.get(`/api/dashboards/default?role=${encodeURIComponent(role)}`),
|
|
9
|
+
|
|
10
|
+
create: (input) => http.post('/api/dashboards', input),
|
|
11
|
+
|
|
12
|
+
update: (id, input) => http.put(`/api/dashboards/${id}`, input),
|
|
13
|
+
|
|
14
|
+
remove: (id) => http.delete(`/api/dashboards/${id}`),
|
|
15
|
+
|
|
16
|
+
duplicate: (id) => http.post(`/api/dashboards/${id}/duplicate`),
|
|
17
|
+
|
|
18
|
+
managerOverview: (period, lens) => http.get('/api/manager/overview', {
|
|
19
|
+
params: { period, lens: lens ?? '' },
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { Http, QueryParams, RequestOptions } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions, type PersonDomainCursorPage, type PersonDomainEnvelope } from './actors.js';
|
|
3
|
+
/** The header that acts for another person on a route that opted in. */
|
|
4
|
+
export declare const ON_BEHALF_OF_HEADER = "X-On-Behalf-Of";
|
|
5
|
+
/** `{ 'X-On-Behalf-Of': 'person:<id>' }`, to spread into a request's headers. */
|
|
6
|
+
export declare function onBehalfOf(personId: string): Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Per-call options for a route that accepts acting for another person (it opted in with
|
|
9
|
+
* `delegations.acting:<capability>`, e.g. "My data" under `data.consent`). `onBehalfOf` is the
|
|
10
|
+
* principal's person id — a ward, or someone who signed a delegation to the caller. Core verifies
|
|
11
|
+
* the delegation and its scope on every request; outside it the answer is 403
|
|
12
|
+
* `outside_delegation_scope`. Absent or null: act as the caller.
|
|
13
|
+
*/
|
|
14
|
+
export interface OnBehalfCallOptions extends PersonDomainCallOptions {
|
|
15
|
+
onBehalfOf?: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** {@link personDomainRequest} plus the `X-On-Behalf-Of` header when `onBehalfOf` is given. */
|
|
18
|
+
export declare function onBehalfRequest(options?: OnBehalfCallOptions, write?: boolean, params?: QueryParams): RequestOptions;
|
|
19
|
+
export type DelegationBasis = 'signed_delegation' | 'guardian_of_minor' | 'verified_legal_basis';
|
|
20
|
+
export type DelegationState = 'pending' | 'active' | 'disputed' | 'ended';
|
|
21
|
+
export type DelegationRole = 'principal' | 'delegate' | 'co_guardian';
|
|
22
|
+
export type DelegationDisputeReason = 'custody_disagreement' | 'safety_concern' | 'not_a_guardian' | 'other';
|
|
23
|
+
export interface DelegationScope {
|
|
24
|
+
/** Exact keys, `module.*`, or `*` (a guardianship of a minor only). */
|
|
25
|
+
capabilities: string[];
|
|
26
|
+
/** App registry keys; empty = every app. */
|
|
27
|
+
apps: string[];
|
|
28
|
+
/** Empty = every vertical. */
|
|
29
|
+
verticals: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface DelegationParty {
|
|
32
|
+
person_id: string;
|
|
33
|
+
name: string | null;
|
|
34
|
+
}
|
|
35
|
+
export interface Delegation {
|
|
36
|
+
id: string;
|
|
37
|
+
role: DelegationRole;
|
|
38
|
+
principal: DelegationParty;
|
|
39
|
+
delegate: DelegationParty;
|
|
40
|
+
basis: {
|
|
41
|
+
key: DelegationBasis;
|
|
42
|
+
label: BilingualText;
|
|
43
|
+
};
|
|
44
|
+
scope: DelegationScope;
|
|
45
|
+
state: {
|
|
46
|
+
key: DelegationState;
|
|
47
|
+
label: BilingualText;
|
|
48
|
+
};
|
|
49
|
+
awaiting: 'principal' | 'delegate' | 'case' | null;
|
|
50
|
+
awaiting_me: boolean;
|
|
51
|
+
end_rule: 'revoked' | 'expires' | 'age_of_majority';
|
|
52
|
+
starts_at: string;
|
|
53
|
+
ends_at: string | null;
|
|
54
|
+
confirmed_by_principal_at: string | null;
|
|
55
|
+
accepted_by_delegate_at: string | null;
|
|
56
|
+
disputed_at: string | null;
|
|
57
|
+
dispute_reason: string | null;
|
|
58
|
+
case_open: boolean;
|
|
59
|
+
awaiting_age_assurance: boolean;
|
|
60
|
+
ended_at: string | null;
|
|
61
|
+
ended_reason: string | null;
|
|
62
|
+
created_at: string;
|
|
63
|
+
/** What the viewer may do now — never offer a button the server refuses. */
|
|
64
|
+
actions: {
|
|
65
|
+
confirm: boolean;
|
|
66
|
+
revoke: boolean;
|
|
67
|
+
dispute: boolean;
|
|
68
|
+
view_actions: boolean;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface DelegationAction {
|
|
72
|
+
id: string;
|
|
73
|
+
delegation_id: string;
|
|
74
|
+
delegate_person_id: string;
|
|
75
|
+
capability: string;
|
|
76
|
+
http_method: string;
|
|
77
|
+
route_name: string | null;
|
|
78
|
+
response_status: number;
|
|
79
|
+
succeeded: boolean;
|
|
80
|
+
occurred_at: string;
|
|
81
|
+
}
|
|
82
|
+
export interface Dependent {
|
|
83
|
+
/** The id to send as `onBehalfOf(person_id)`. */
|
|
84
|
+
person_id: string;
|
|
85
|
+
name: string | null;
|
|
86
|
+
birthdate_declared: string;
|
|
87
|
+
age_assurance: {
|
|
88
|
+
key: string;
|
|
89
|
+
label: BilingualText;
|
|
90
|
+
};
|
|
91
|
+
claimed: boolean;
|
|
92
|
+
registered_by_me: boolean;
|
|
93
|
+
created_at: string;
|
|
94
|
+
guardianships: Delegation[];
|
|
95
|
+
}
|
|
96
|
+
export interface CreateDelegationInput extends Partial<Pick<DelegationScope, 'apps' | 'verticals'>> {
|
|
97
|
+
/** `principal`: I let @handle act for me (active at once). `delegate`: let me act for @handle (pending). */
|
|
98
|
+
as: 'principal' | 'delegate';
|
|
99
|
+
handle: string;
|
|
100
|
+
/** Required with `as: 'delegate'`. */
|
|
101
|
+
basis?: DelegationBasis;
|
|
102
|
+
capabilities: string[];
|
|
103
|
+
ends_at?: string | null;
|
|
104
|
+
}
|
|
105
|
+
export interface RegisterDependentInput extends Partial<DelegationScope> {
|
|
106
|
+
display_name: string;
|
|
107
|
+
/** `YYYY-MM-DD`, a minor's. */
|
|
108
|
+
date_of_birth: string;
|
|
109
|
+
}
|
|
110
|
+
/** The terms every delegation screen reads first: never assume 18, never print a capability key. */
|
|
111
|
+
export interface DelegationTerms {
|
|
112
|
+
/** The configured age of majority (a market setting); dependents must be younger. */
|
|
113
|
+
majority_age: number;
|
|
114
|
+
/** Exact keys, `module.*` wildcards and `*`, each with its words. */
|
|
115
|
+
capabilities: {
|
|
116
|
+
key: string;
|
|
117
|
+
label: BilingualText;
|
|
118
|
+
}[];
|
|
119
|
+
}
|
|
120
|
+
export declare function createDelegationsNamespace(http: Http): {
|
|
121
|
+
/** The age of majority and the capability catalogue. */
|
|
122
|
+
terms: (options?: PersonDomainCallOptions) => Promise<DelegationTerms>;
|
|
123
|
+
/** Given, received and shared guardianships, newest first. */
|
|
124
|
+
list: (query?: {
|
|
125
|
+
direction?: "given" | "received" | "all";
|
|
126
|
+
state?: DelegationState;
|
|
127
|
+
cursor?: string | null;
|
|
128
|
+
limit?: number;
|
|
129
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<Delegation>>;
|
|
130
|
+
get: (delegationId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Delegation>>;
|
|
131
|
+
create: (input: CreateDelegationInput, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Delegation>>;
|
|
132
|
+
confirm: (delegationId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Delegation>>;
|
|
133
|
+
/** Revoke (principal), resign (delegate) or decline. A minor's revoke follows `delegations.minor_revocation`. */
|
|
134
|
+
revoke: (delegationId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Delegation>>;
|
|
135
|
+
dispute: (delegationId: string, reason: DelegationDisputeReason, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Delegation>>;
|
|
136
|
+
/** "Done by X on behalf of Y", newest first. */
|
|
137
|
+
actions: (delegationId: string, query?: {
|
|
138
|
+
cursor?: string | null;
|
|
139
|
+
limit?: number;
|
|
140
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<DelegationAction>>;
|
|
141
|
+
dependents: (options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<Dependent>>;
|
|
142
|
+
/** Register a child with no account; send the same `idempotencyKey` when retrying. */
|
|
143
|
+
registerDependent: (input: RegisterDependentInput, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Dependent>>;
|
|
144
|
+
inviteGuardian: (dependentPersonId: string, input: {
|
|
145
|
+
handle: string;
|
|
146
|
+
} & Partial<DelegationScope>, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Delegation>>;
|
|
147
|
+
/** Give the child their OWN email or phone; the child verifies it by a code sent there. */
|
|
148
|
+
claimWithIdentifier: (dependentPersonId: string, input: {
|
|
149
|
+
kind: "email" | "phone";
|
|
150
|
+
value: string;
|
|
151
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
|
|
152
|
+
kind: "email" | "phone";
|
|
153
|
+
next: "child_verifies_by_code";
|
|
154
|
+
}>>;
|
|
155
|
+
/** A one-time code the child redeems while signing up. Shown once; a new one replaces it. */
|
|
156
|
+
issueClaimCode: (dependentPersonId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
|
|
157
|
+
code: string;
|
|
158
|
+
expires_at: string;
|
|
159
|
+
}>>;
|
|
160
|
+
};
|
|
161
|
+
export type DelegationsNamespace = ReturnType<typeof createDelegationsNamespace>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { personDomainRequest, } from './actors.js';
|
|
2
|
+
const BASE = '/api/person';
|
|
3
|
+
|
|
4
|
+
export const ON_BEHALF_OF_HEADER = 'X-On-Behalf-Of';
|
|
5
|
+
|
|
6
|
+
export function onBehalfOf(personId) {
|
|
7
|
+
return { [ON_BEHALF_OF_HEADER]: `person:${personId}` };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function onBehalfRequest(options = {}, write = false, params) {
|
|
11
|
+
const request = personDomainRequest(options, write, params);
|
|
12
|
+
if (options.onBehalfOf)
|
|
13
|
+
request.headers = { ...(request.headers ?? {}), ...onBehalfOf(options.onBehalfOf) };
|
|
14
|
+
return request;
|
|
15
|
+
}
|
|
16
|
+
export function createDelegationsNamespace(http) {
|
|
17
|
+
return {
|
|
18
|
+
|
|
19
|
+
terms: (options) => http.get(`${BASE}/delegation-terms`, personDomainRequest(options)),
|
|
20
|
+
|
|
21
|
+
list: (query = {}, options) => http.get(`${BASE}/delegations`, personDomainRequest(options, false, Object.fromEntries(Object.entries(query).filter(([, value]) => value != null)))),
|
|
22
|
+
get: (delegationId, options) => http.get(`${BASE}/delegations/${delegationId}`, personDomainRequest(options)),
|
|
23
|
+
create: (input, options) => http.post(`${BASE}/delegations`, input, personDomainRequest(options, true)),
|
|
24
|
+
confirm: (delegationId, options) => http.post(`${BASE}/delegations/${delegationId}/confirm`, undefined, personDomainRequest(options, true)),
|
|
25
|
+
|
|
26
|
+
revoke: (delegationId, options) => http.post(`${BASE}/delegations/${delegationId}/revoke`, undefined, personDomainRequest(options, true)),
|
|
27
|
+
dispute: (delegationId, reason, options) => http.post(`${BASE}/delegations/${delegationId}/dispute`, { reason }, personDomainRequest(options, true)),
|
|
28
|
+
|
|
29
|
+
actions: (delegationId, query = {}, options) => http.get(`${BASE}/delegations/${delegationId}/actions`, personDomainRequest(options, false, Object.fromEntries(Object.entries(query).filter(([, value]) => value != null)))),
|
|
30
|
+
dependents: (options) => http.get(`${BASE}/dependents`, personDomainRequest(options)),
|
|
31
|
+
|
|
32
|
+
registerDependent: (input, options) => http.post(`${BASE}/dependents`, input, personDomainRequest(options, true)),
|
|
33
|
+
inviteGuardian: (dependentPersonId, input, options) => http.post(`${BASE}/dependents/${dependentPersonId}/guardians`, input, personDomainRequest(options, true)),
|
|
34
|
+
|
|
35
|
+
claimWithIdentifier: (dependentPersonId, input, options) => http.post(`${BASE}/dependents/${dependentPersonId}/claim/identifier`, input, personDomainRequest(options, true)),
|
|
36
|
+
|
|
37
|
+
issueClaimCode: (dependentPersonId, options) => http.post(`${BASE}/dependents/${dependentPersonId}/claim/code`, undefined, personDomainRequest(options, true)),
|
|
38
|
+
};
|
|
39
|
+
}
|
package/dist/docs.d.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import type { Http, RequestOptions } from './http.js';
|
|
2
|
+
import type { LaravelPaginator } from './types.js';
|
|
3
|
+
/** The three OOXML formats the suite can create and edit. CHECK-constrained in the database. */
|
|
4
|
+
export type DocType = 'docx' | 'xlsx' | 'pptx';
|
|
5
|
+
/** A document is `archived` rather than deleted when staff retire it. */
|
|
6
|
+
export type DocStatus = 'active' | 'archived';
|
|
7
|
+
/**
|
|
8
|
+
* Where a document sits in the approval workflow, or `null` when it has never been
|
|
9
|
+
* submitted. Distinct from {@see DocStatus}: a document can be active and rejected at once.
|
|
10
|
+
*/
|
|
11
|
+
export type DocApprovalStatus = 'draft' | 'in_review' | 'approved' | 'rejected';
|
|
12
|
+
/**
|
|
13
|
+
* One immutable version snapshot. The suite writes a new row on every save, so the
|
|
14
|
+
* version list doubles as the document's history. Never updated after creation, which is
|
|
15
|
+
* why there is no `updated_at`.
|
|
16
|
+
*/
|
|
17
|
+
export interface DocVersion {
|
|
18
|
+
id: string;
|
|
19
|
+
document_id: string;
|
|
20
|
+
/** 1-based revision number. `(document_id, version_no)` is unique. */
|
|
21
|
+
version_no: number;
|
|
22
|
+
/** Blob location behind the storage seam — not a URL, and not fetchable by a client. */
|
|
23
|
+
storage_path: string;
|
|
24
|
+
size_bytes: number;
|
|
25
|
+
created_by_person_id: string | null;
|
|
26
|
+
created_at: string | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A document row.
|
|
30
|
+
*
|
|
31
|
+
* Named for its module rather than just `DocRecord`, because `@nuwah/ui`'s DocsWorkspace
|
|
32
|
+
* exports a `DocRecord` of its own and a screen imports from both packages at once. The
|
|
33
|
+
* two are not rivals and should not be merged: this one describes the bytes core sends,
|
|
34
|
+
* while the component's describes what it needs to draw a row — loosely typed, mostly
|
|
35
|
+
* optional, and satisfiable by a vault file as well as a document from this suite. The
|
|
36
|
+
* module prefix follows the same disambiguation already used for `ProcurementPurchaseOrder`.
|
|
37
|
+
*
|
|
38
|
+
* Serialised straight from the Eloquent model rather than through an API resource, which
|
|
39
|
+
* has two consequences worth knowing before you read a field off one:
|
|
40
|
+
*
|
|
41
|
+
* · Loaded relations keep their CAMEL-CASE accessor name, so the eager-loaded current
|
|
42
|
+
* version arrives as `currentVersion`, beside the snake-case `current_version_id`
|
|
43
|
+
* column. Both are declared below; neither is a typo.
|
|
44
|
+
* · Which relations are present depends on the endpoint, so both are optional here.
|
|
45
|
+
* `list` loads `currentVersion`; `show`, `create` and `createFromTemplate` load the
|
|
46
|
+
* full `versions` list.
|
|
47
|
+
*/
|
|
48
|
+
export interface DocsDocument {
|
|
49
|
+
id: string;
|
|
50
|
+
tenant_id: string;
|
|
51
|
+
title: string;
|
|
52
|
+
doc_type: DocType;
|
|
53
|
+
status: DocStatus;
|
|
54
|
+
created_by_person_id: string | null;
|
|
55
|
+
/** Points at the version the editor opens. Null only in the instant before version 1 exists. */
|
|
56
|
+
current_version_id: string | null;
|
|
57
|
+
/** Opaque WOPI lock string held by an in-progress editing session; null when unlocked. */
|
|
58
|
+
lock_id: string | null;
|
|
59
|
+
/** The lock's self-expiry. An expired lock counts as unlocked. */
|
|
60
|
+
lock_expires_at: string | null;
|
|
61
|
+
approval_status: DocApprovalStatus | null;
|
|
62
|
+
deleted_at: string | null;
|
|
63
|
+
created_at: string | null;
|
|
64
|
+
updated_at: string | null;
|
|
65
|
+
/** Present on `list` (eager-loaded). Camel-case because Eloquent serialises the relation name. */
|
|
66
|
+
currentVersion?: DocVersion | null;
|
|
67
|
+
/** Present on `show`, `create` and `createFromTemplate`, ordered oldest to newest. */
|
|
68
|
+
versions?: DocVersion[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The page sizes the list endpoint honours.
|
|
72
|
+
*
|
|
73
|
+
* The controller clamps `per_page` to this allow-list and silently falls back to 15 for
|
|
74
|
+
* anything else, so a value outside it does not error — it is ignored. Typing the union
|
|
75
|
+
* turns that silent fallback into a compile error instead.
|
|
76
|
+
*/
|
|
77
|
+
export type DocPerPage = 10 | 15 | 25 | 50 | 100;
|
|
78
|
+
export interface DocListQuery {
|
|
79
|
+
status?: DocStatus;
|
|
80
|
+
doc_type?: DocType;
|
|
81
|
+
/** Case-insensitive partial match on the title. */
|
|
82
|
+
q?: string;
|
|
83
|
+
per_page?: DocPerPage;
|
|
84
|
+
page?: number;
|
|
85
|
+
[param: string]: string | number | boolean | null | undefined | Array<string | number>;
|
|
86
|
+
}
|
|
87
|
+
export interface CreateDocInput {
|
|
88
|
+
title: string;
|
|
89
|
+
doc_type: DocType;
|
|
90
|
+
}
|
|
91
|
+
/** Both fields are optional — send only what changes. */
|
|
92
|
+
export interface UpdateDocInput {
|
|
93
|
+
title?: string;
|
|
94
|
+
status?: DocStatus;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Everything the front end needs to mount the editor in an iframe.
|
|
98
|
+
*
|
|
99
|
+
* Answers 503 with a `message` when the Document Server is offline or unconfigured, so a
|
|
100
|
+
* screen that offers editing should be prepared to say editing is temporarily unavailable
|
|
101
|
+
* rather than treating it as a failure of the document.
|
|
102
|
+
*/
|
|
103
|
+
export interface DocEditorConfig {
|
|
104
|
+
/** The Document Server action URL, already carrying the `WOPISrc` parameter. */
|
|
105
|
+
action_url: string;
|
|
106
|
+
access_token: string;
|
|
107
|
+
/**
|
|
108
|
+
* An ABSOLUTE expiry instant in epoch MILLISECONDS — not a duration, despite the name,
|
|
109
|
+
* which follows the WOPI specification's own field. Treating it as a lifetime in
|
|
110
|
+
* seconds would put the expiry about fifty thousand years out.
|
|
111
|
+
*/
|
|
112
|
+
access_token_ttl: number;
|
|
113
|
+
}
|
|
114
|
+
/** `edit` still yields a read-only session unless the caller holds the write right. */
|
|
115
|
+
export type DocEditorMode = 'edit' | 'view';
|
|
116
|
+
/**
|
|
117
|
+
* A template library entry as the LIST endpoint returns it.
|
|
118
|
+
*
|
|
119
|
+
* Deliberately a projection of five columns, not the whole row: the template's
|
|
120
|
+
* `storage_path` and `tenant_id` are never sent to a client. `upload` returns the full
|
|
121
|
+
* row, so {@see DocTemplateRecord} is what you get back from that one.
|
|
122
|
+
*/
|
|
123
|
+
export interface DocTemplateSummary {
|
|
124
|
+
id: string;
|
|
125
|
+
title: string;
|
|
126
|
+
doc_type: DocType;
|
|
127
|
+
size_bytes: number;
|
|
128
|
+
created_at: string | null;
|
|
129
|
+
}
|
|
130
|
+
/** The full template row, returned by `templates.upload`. */
|
|
131
|
+
export interface DocTemplateRecord extends DocTemplateSummary {
|
|
132
|
+
tenant_id: string;
|
|
133
|
+
storage_path: string | null;
|
|
134
|
+
created_by_person_id: string | null;
|
|
135
|
+
updated_at: string | null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Who a sharing grant addresses.
|
|
139
|
+
*
|
|
140
|
+
* `link` is never created through `shares.grant` — it belongs to the signed public link
|
|
141
|
+
* and is minted only by `shares.createPublicLink`. It appears here because an existing
|
|
142
|
+
* `link` share is listed alongside the others.
|
|
143
|
+
*/
|
|
144
|
+
export type DocShareSubject = 'user' | 'role' | 'org' | 'person' | 'link';
|
|
145
|
+
export type DocShareAccess = 'viewer' | 'editor';
|
|
146
|
+
export interface DocShare {
|
|
147
|
+
id: string;
|
|
148
|
+
tenant_id: string;
|
|
149
|
+
document_id: string;
|
|
150
|
+
subject_type: DocShareSubject;
|
|
151
|
+
/** The addressed user or role. Always null for an `org` share, which addresses every member. */
|
|
152
|
+
subject_id: string | null;
|
|
153
|
+
/** Set only on a `person` share. */
|
|
154
|
+
person_id: string | null;
|
|
155
|
+
access: DocShareAccess;
|
|
156
|
+
/** Only ever the sha256 of the public link's token — the token itself is never stored. */
|
|
157
|
+
link_token_hash: string | null;
|
|
158
|
+
expires_at: string | null;
|
|
159
|
+
created_by_person_id: string | null;
|
|
160
|
+
created_at: string | null;
|
|
161
|
+
updated_at: string | null;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Granting a share. The required fields depend on the ring, and the server enforces it:
|
|
165
|
+
*
|
|
166
|
+
* · `user` / `role` — `subject_id` is required.
|
|
167
|
+
* · `person` — `person_id` is required.
|
|
168
|
+
* · `org` — `subject_id` is REJECTED, not ignored, because an org share
|
|
169
|
+
* already addresses every member and an id would be meaningless.
|
|
170
|
+
*/
|
|
171
|
+
export interface GrantDocShareInput {
|
|
172
|
+
subject_type: Exclude<DocShareSubject, 'link'>;
|
|
173
|
+
subject_id?: string | null;
|
|
174
|
+
person_id?: string | null;
|
|
175
|
+
access: DocShareAccess;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The minted public link. The URL carries a signature and a raw token that is returned
|
|
179
|
+
* HERE AND NOWHERE ELSE — only its hash is persisted, so a lost URL cannot be recovered
|
|
180
|
+
* and has to be re-minted.
|
|
181
|
+
*/
|
|
182
|
+
export interface DocPublicLink {
|
|
183
|
+
url: string;
|
|
184
|
+
expires_at: string;
|
|
185
|
+
}
|
|
186
|
+
/** The outcome of entering the approval workflow. */
|
|
187
|
+
export interface DocApprovalSubmission {
|
|
188
|
+
document_id: string;
|
|
189
|
+
/** Read back off the saved document rather than assumed, so it reflects what the workflow set. */
|
|
190
|
+
approval_status: DocApprovalStatus | null;
|
|
191
|
+
workflow_item_id: string | null;
|
|
192
|
+
workflow_status: string | null;
|
|
193
|
+
}
|
|
194
|
+
export declare function createDocsNamespace(http: Http): {
|
|
195
|
+
/**
|
|
196
|
+
* GET /api/docs — the tenant's documents, newest first, each with its current
|
|
197
|
+
* version eager-loaded. Soft-deleted documents are excluded.
|
|
198
|
+
*
|
|
199
|
+
* Returns Laravel's raw paginator envelope (page fields at the top level beside
|
|
200
|
+
* `data`), NOT the `{data, meta}` shape most other namespaces return.
|
|
201
|
+
*/
|
|
202
|
+
list: (query?: DocListQuery, options?: RequestOptions) => Promise<LaravelPaginator<DocsDocument>>;
|
|
203
|
+
/** GET /api/docs/{documentId} — one document with its full version history. */
|
|
204
|
+
show: (documentId: string, options?: RequestOptions) => Promise<DocsDocument>;
|
|
205
|
+
/**
|
|
206
|
+
* POST /api/docs — create an empty document of the given format. Needs `docs.manage`.
|
|
207
|
+
*
|
|
208
|
+
* Seeded from a blank file of that format, which becomes version 1, so the result
|
|
209
|
+
* is immediately openable in the editor.
|
|
210
|
+
*/
|
|
211
|
+
create: (input: CreateDocInput, options?: RequestOptions) => Promise<DocsDocument>;
|
|
212
|
+
/** PATCH /api/docs/{documentId} — rename, archive or restore. Needs `docs.manage`. */
|
|
213
|
+
update: (documentId: string, changes: UpdateDocInput, options?: RequestOptions) => Promise<DocsDocument>;
|
|
214
|
+
/**
|
|
215
|
+
* DELETE /api/docs/{documentId} — soft-delete. Needs `docs.manage`.
|
|
216
|
+
*
|
|
217
|
+
* The stored bytes and the version rows are kept, so this hides the document
|
|
218
|
+
* rather than destroying its history.
|
|
219
|
+
*/
|
|
220
|
+
remove: (documentId: string, options?: RequestOptions) => Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* GET /api/docs/{documentId}/editor-config — bootstrap an editing or viewing session.
|
|
223
|
+
*
|
|
224
|
+
* Needs `docs.view` plus either `docs.manage` or a share on this document; without
|
|
225
|
+
* one of those it answers 403. Asking for `edit` does not guarantee a writable
|
|
226
|
+
* session — the server grants write only to a `docs.manage` holder or an editor-level
|
|
227
|
+
* share, and silently returns a read-only session otherwise. Answers 503 when the
|
|
228
|
+
* Document Server is unavailable.
|
|
229
|
+
*/
|
|
230
|
+
editorConfig: (documentId: string, mode?: DocEditorMode, options?: RequestOptions) => Promise<DocEditorConfig>;
|
|
231
|
+
/**
|
|
232
|
+
* POST /api/docs/{documentId}/submit-for-approval — enter the approval workflow.
|
|
233
|
+
* Needs `docs.manage`.
|
|
234
|
+
*
|
|
235
|
+
* The caller must be an identified person: a service token answers 422 because the
|
|
236
|
+
* workflow item records who submitted it. Answers 409 when no approval workflow is
|
|
237
|
+
* configured for documents in this tenant.
|
|
238
|
+
*/
|
|
239
|
+
submitForApproval: (documentId: string, options?: RequestOptions) => Promise<DocApprovalSubmission>;
|
|
240
|
+
/** The per-tenant template library, and starting a document from one. */
|
|
241
|
+
templates: {
|
|
242
|
+
/** GET /api/docs/templates — this tenant's templates, newest first. A bare array, not an envelope. */
|
|
243
|
+
list: (options?: RequestOptions) => Promise<DocTemplateSummary[]>;
|
|
244
|
+
/**
|
|
245
|
+
* POST /api/docs/templates — upload a reusable template. Needs `docs.manage`.
|
|
246
|
+
*
|
|
247
|
+
* The file's real format must match `docType` and it must stay under the tenant's
|
|
248
|
+
* configured ceiling (50 MB by default); either violation answers 422.
|
|
249
|
+
*/
|
|
250
|
+
upload: (title: string, docType: DocType, file: File | Blob, options?: RequestOptions & {
|
|
251
|
+
fileName?: string;
|
|
252
|
+
}) => Promise<DocTemplateRecord>;
|
|
253
|
+
/** DELETE /api/docs/templates/{templateId} — remove a template and its bytes. Needs `docs.manage`. */
|
|
254
|
+
remove: (templateId: string, options?: RequestOptions) => Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* POST /api/docs/from-template/{templateId} — start a NEW document from a template.
|
|
257
|
+
*
|
|
258
|
+
* The template's bytes become the new document's version 1 and its format is
|
|
259
|
+
* inherited, so there is no `doc_type` to pass. Omit `title` to reuse the
|
|
260
|
+
* template's own. Needs `docs.manage`.
|
|
261
|
+
*/
|
|
262
|
+
createDocument: (templateId: string, title?: string, options?: RequestOptions) => Promise<DocsDocument>;
|
|
263
|
+
};
|
|
264
|
+
/** A document's sharing grants, and the signed public link. */
|
|
265
|
+
shares: {
|
|
266
|
+
/** GET /api/docs/{documentId}/shares — the document's active grants, newest first. Needs `docs.manage`. */
|
|
267
|
+
list: (documentId: string, options?: RequestOptions) => Promise<{
|
|
268
|
+
data: DocShare[];
|
|
269
|
+
}>;
|
|
270
|
+
/**
|
|
271
|
+
* POST /api/docs/{documentId}/shares — grant access. Needs `docs.manage`.
|
|
272
|
+
*
|
|
273
|
+
* Returns the share unwrapped, unlike `list` which wraps its array in `{data}`.
|
|
274
|
+
* See {@see GrantDocShareInput} for the per-ring field requirements.
|
|
275
|
+
*/
|
|
276
|
+
grant: (documentId: string, input: GrantDocShareInput, options?: RequestOptions) => Promise<DocShare>;
|
|
277
|
+
/** DELETE /api/docs/{documentId}/shares/{shareId} — revoke a grant outright. Needs `docs.manage`. */
|
|
278
|
+
revoke: (documentId: string, shareId: string, options?: RequestOptions) => Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* POST /api/docs/{documentId}/share-link — mint a signed, view-only link for someone
|
|
281
|
+
* with no account. Needs `docs.manage`.
|
|
282
|
+
*
|
|
283
|
+
* `expiresDays` must be between 1 and 365 and defaults to 7. The returned URL
|
|
284
|
+
* contains the only copy of its token — see {@see DocPublicLink}.
|
|
285
|
+
*/
|
|
286
|
+
createPublicLink: (documentId: string, expiresDays?: number, options?: RequestOptions) => Promise<DocPublicLink>;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
export type DocsNamespace = ReturnType<typeof createDocsNamespace>;
|