@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,319 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type ListPage, type ListQueryState } from './list-query.js';
|
|
3
|
+
import { type BilingualText, type PartyReference, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
|
|
4
|
+
export type PersonNotificationCategory = 'update' | 'needs_action';
|
|
5
|
+
/** A declared topic key — `social`, `money`, `orders`, `account`, `activity` today; modules may add. */
|
|
6
|
+
export type PersonNotificationTopicKey = 'social' | 'money' | 'orders' | 'account' | 'activity' | (string & {});
|
|
7
|
+
/**
|
|
8
|
+
* The list's orders on the declared wire (`-activity_at` default, `created_at` oldest first), plus the
|
|
9
|
+
* two names the first clients used — `newest` and `oldest` — which map onto them.
|
|
10
|
+
*/
|
|
11
|
+
export type PersonNotificationSort = 'newest' | 'oldest' | '-activity_at' | 'activity_at' | 'created_at' | '-created_at';
|
|
12
|
+
export type PersonNotificationBulkOperation = 'read' | 'unread' | 'dismiss';
|
|
13
|
+
export type PersonNotificationMuteScope = 'subject' | 'sender' | 'topic';
|
|
14
|
+
/** The realtime frame names on the person channel. Each means "ask again". */
|
|
15
|
+
export declare const PERSON_NOTIFICATION_FRAMES: readonly ["PersonNotificationReceived", "PersonInboxItemResolved", "PersonNotificationsChanged"];
|
|
16
|
+
export type PersonNotificationFrame = (typeof PERSON_NOTIFICATION_FRAMES)[number];
|
|
17
|
+
/** The person channel the frames arrive on. */
|
|
18
|
+
export declare function personNotificationChannel(personId: string): string;
|
|
19
|
+
export type PersonNotificationDigestFrequency = 'immediate' | 'hourly' | 'daily';
|
|
20
|
+
/** A declared button on a decision. `path` is a person-plane route of the owning module. */
|
|
21
|
+
export interface PersonNotificationAction {
|
|
22
|
+
key: string;
|
|
23
|
+
label: BilingualText;
|
|
24
|
+
method: 'POST' | 'PUT' | 'PATCH' | 'DELETE' | (string & {});
|
|
25
|
+
path: string;
|
|
26
|
+
/** `primary`, `secondary`, `danger` — a hint, not a rule. */
|
|
27
|
+
style: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PersonNotification {
|
|
30
|
+
id: string;
|
|
31
|
+
event_key: string;
|
|
32
|
+
category: PersonNotificationCategory;
|
|
33
|
+
title: BilingualText;
|
|
34
|
+
body: BilingualText;
|
|
35
|
+
deep_link_path: string | null;
|
|
36
|
+
subject: {
|
|
37
|
+
type: string;
|
|
38
|
+
id: string;
|
|
39
|
+
} | null;
|
|
40
|
+
sender: PartyReference | null;
|
|
41
|
+
/** Set when this reached the person as a member of a business profile. */
|
|
42
|
+
on_behalf_of: PartyReference | null;
|
|
43
|
+
inbox_item_key: string | null;
|
|
44
|
+
/** Present only while a decision is open; `[]` once resolved. */
|
|
45
|
+
actions: PersonNotificationAction[];
|
|
46
|
+
resolution: string | null;
|
|
47
|
+
resolved_at: string | null;
|
|
48
|
+
/** 1 for a single event; N when N events were folded into this row. */
|
|
49
|
+
aggregated_count: number;
|
|
50
|
+
/** The tab this row belongs to (stamped at delivery). */
|
|
51
|
+
topic: PersonNotificationTopicKey;
|
|
52
|
+
/** Up to three most recent senders of a grouped row, newest first. */
|
|
53
|
+
recent_senders: PartyReference[];
|
|
54
|
+
read: boolean;
|
|
55
|
+
read_at: string | null;
|
|
56
|
+
created_at: string;
|
|
57
|
+
/** Last activity — moves forward when another event is grouped into this row. */
|
|
58
|
+
activity_at: string;
|
|
59
|
+
}
|
|
60
|
+
export interface PersonNotificationTopic {
|
|
61
|
+
key: PersonNotificationTopicKey;
|
|
62
|
+
label: BilingualText;
|
|
63
|
+
/** An icon name hint (`users`, `wallet`, `shopping-bag`, `user`, `bell`). */
|
|
64
|
+
icon: string;
|
|
65
|
+
unread: number;
|
|
66
|
+
awaiting_decision: number;
|
|
67
|
+
}
|
|
68
|
+
export interface PersonNotificationTopics {
|
|
69
|
+
topics: PersonNotificationTopic[];
|
|
70
|
+
totals: PersonNotificationCounts;
|
|
71
|
+
/** Pushes are held until this instant; null when not snoozed. */
|
|
72
|
+
snoozed_until: string | null;
|
|
73
|
+
}
|
|
74
|
+
export interface PersonNotificationMute {
|
|
75
|
+
id: string;
|
|
76
|
+
scope: PersonNotificationMuteScope;
|
|
77
|
+
subject: {
|
|
78
|
+
type: string;
|
|
79
|
+
id: string;
|
|
80
|
+
} | null;
|
|
81
|
+
sender: PartyReference | null;
|
|
82
|
+
topic: PersonNotificationTopicKey | null;
|
|
83
|
+
/** Null: until unmuted. */
|
|
84
|
+
muted_until: string | null;
|
|
85
|
+
created_at: string;
|
|
86
|
+
}
|
|
87
|
+
/** What to mute: one of a subject (a post, a thread), a sender, or a topic. */
|
|
88
|
+
export type PersonNotificationMuteTarget = {
|
|
89
|
+
scope: 'subject';
|
|
90
|
+
subject_type: string;
|
|
91
|
+
subject_id: string;
|
|
92
|
+
} | {
|
|
93
|
+
scope: 'sender';
|
|
94
|
+
sender: string;
|
|
95
|
+
} | {
|
|
96
|
+
scope: 'topic';
|
|
97
|
+
topic: PersonNotificationTopicKey;
|
|
98
|
+
};
|
|
99
|
+
export interface ActorNotificationRoute {
|
|
100
|
+
topic: PersonNotificationTopicKey;
|
|
101
|
+
label: BilingualText;
|
|
102
|
+
/** Person ids chosen for this topic; empty = every member holding the capability. */
|
|
103
|
+
members: string[];
|
|
104
|
+
updated_at: string | null;
|
|
105
|
+
}
|
|
106
|
+
export interface ActorNotificationRoutes {
|
|
107
|
+
actor_id: string;
|
|
108
|
+
/** The profile's routing policy: routes apply only under `actor_routes`. */
|
|
109
|
+
routing: 'every_capability_holder' | 'actor_routes' | (string & {});
|
|
110
|
+
routes: ActorNotificationRoute[];
|
|
111
|
+
}
|
|
112
|
+
/** One row's outcome in {@link decideMany}. */
|
|
113
|
+
export interface PersonNotificationDecisionOutcome {
|
|
114
|
+
notificationId: string;
|
|
115
|
+
ok: boolean;
|
|
116
|
+
/** Why it was not sent or failed: `no_such_action`, `refused_locally`, or the error message. */
|
|
117
|
+
error?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface PersonNotificationCounts {
|
|
120
|
+
unread: number;
|
|
121
|
+
awaiting_decision: number;
|
|
122
|
+
}
|
|
123
|
+
export interface PersonNotificationChannelState {
|
|
124
|
+
/** Whether the event can reach this channel at all. */
|
|
125
|
+
declared: boolean;
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface PersonNotificationEventPreference {
|
|
129
|
+
event_key: string;
|
|
130
|
+
topic: PersonNotificationTopicKey;
|
|
131
|
+
label: BilingualText;
|
|
132
|
+
/** A mandatory event cannot be switched off (a security notice). */
|
|
133
|
+
mandatory: boolean;
|
|
134
|
+
channels: {
|
|
135
|
+
push: PersonNotificationChannelState;
|
|
136
|
+
email: PersonNotificationChannelState;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export interface PersonNotificationPreferences {
|
|
140
|
+
/** The person's own choice; null = the platform's policy. */
|
|
141
|
+
digest_frequency: PersonNotificationDigestFrequency | null;
|
|
142
|
+
effective_digest_frequency: PersonNotificationDigestFrequency;
|
|
143
|
+
events: PersonNotificationEventPreference[];
|
|
144
|
+
snoozed_until: string | null;
|
|
145
|
+
topics: Array<{
|
|
146
|
+
key: PersonNotificationTopicKey;
|
|
147
|
+
label: BilingualText;
|
|
148
|
+
icon: string;
|
|
149
|
+
}>;
|
|
150
|
+
mutes: PersonNotificationMute[];
|
|
151
|
+
}
|
|
152
|
+
export interface PersonNotificationListQuery {
|
|
153
|
+
category?: PersonNotificationCategory | null;
|
|
154
|
+
unread?: boolean;
|
|
155
|
+
awaiting_decision?: boolean;
|
|
156
|
+
topic?: PersonNotificationTopicKey | null;
|
|
157
|
+
/** `personal`, or a business profile id: rows that reached the person as its member. */
|
|
158
|
+
inbox?: 'personal' | (string & {}) | null;
|
|
159
|
+
/** `person:<uuid>` or `actor:<uuid>`. */
|
|
160
|
+
sender?: string | null;
|
|
161
|
+
event_key?: string | null;
|
|
162
|
+
/** Folded Arabic/English search over title and body, up to 100 characters. */
|
|
163
|
+
q?: string | null;
|
|
164
|
+
sort?: PersonNotificationSort;
|
|
165
|
+
cursor?: string | null;
|
|
166
|
+
/** Clamped by the server, never refused. */
|
|
167
|
+
limit?: number;
|
|
168
|
+
/** Ask for `meta.list` (the declared sorts and filters) — once, on the first page. */
|
|
169
|
+
describe?: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The query as the declared list wire (`App\Platform\Http\ListQuery`, list `person_notifications.list`):
|
|
173
|
+
* `filter[…]`, `search`, `sort=-activity_at`. A false `unread` / `awaiting_decision` means "no filter"
|
|
174
|
+
* here, as it always did — not "only the read ones".
|
|
175
|
+
*/
|
|
176
|
+
export declare function personNotificationListState(query?: PersonNotificationListQuery): ListQueryState;
|
|
177
|
+
/** True when an action may be sent by {@link perform}: a person-plane path and a write verb. */
|
|
178
|
+
export declare function isPerformablePersonNotificationAction(action: Pick<PersonNotificationAction, 'method' | 'path'>): boolean;
|
|
179
|
+
/** The server's ceiling for one bulk call. */
|
|
180
|
+
export declare const MAXIMUM_BULK = 100;
|
|
181
|
+
/**
|
|
182
|
+
* A quiet-hours window: a local wall-clock start and end (`HH:MM`, 24-hour) and the IANA zone
|
|
183
|
+
* that makes them meaningful. The window may wrap midnight (`21:00`–`07:00` is the usual case).
|
|
184
|
+
*/
|
|
185
|
+
export interface PersonQuietHoursWindow {
|
|
186
|
+
start: string;
|
|
187
|
+
end: string;
|
|
188
|
+
/** An IANA zone name, e.g. `Asia/Amman`. */
|
|
189
|
+
timezone: string;
|
|
190
|
+
}
|
|
191
|
+
/** `GET /api/person/preferences` — the whole object; the quiet-hours fields are null when unset. */
|
|
192
|
+
export interface PersonStandingPreferences {
|
|
193
|
+
conversation_invite_policy: string;
|
|
194
|
+
discoverable_by_handle: boolean;
|
|
195
|
+
discoverable_by_phone: boolean;
|
|
196
|
+
quiet_hours_start: string | null;
|
|
197
|
+
quiet_hours_end: string | null;
|
|
198
|
+
quiet_hours_timezone: string | null;
|
|
199
|
+
appearance_theme?: string | null;
|
|
200
|
+
appearance_locale?: string | null;
|
|
201
|
+
appearance_match_org_brand?: boolean | null;
|
|
202
|
+
}
|
|
203
|
+
/** The window in a preferences answer, or null when the person has none. */
|
|
204
|
+
export declare function quietHoursOf(preferences: PersonStandingPreferences): PersonQuietHoursWindow | null;
|
|
205
|
+
export declare function createPersonNotificationsNamespace(http: Http): {
|
|
206
|
+
/** GET / — latest activity first, cursor paged; `meta.query` echoes the applied question. */
|
|
207
|
+
list: (query?: PersonNotificationListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<PersonNotification>>;
|
|
208
|
+
/**
|
|
209
|
+
* POST /push-tokens — register this browser's FCM web-push token for the signed-in person.
|
|
210
|
+
* Core names the person from the token; the body carries only the device token.
|
|
211
|
+
*/
|
|
212
|
+
registerBrowserPushToken: (token: string, options?: PersonDomainCallOptions) => Promise<{
|
|
213
|
+
data: {
|
|
214
|
+
registered: boolean;
|
|
215
|
+
};
|
|
216
|
+
}>;
|
|
217
|
+
/**
|
|
218
|
+
* DELETE /push-tokens — remove it (switched off, or signing out on a shared computer). This
|
|
219
|
+
* transport sends no DELETE body, so the token rides as a query parameter here; the core SPA
|
|
220
|
+
* sends it in the body.
|
|
221
|
+
*/
|
|
222
|
+
unregisterBrowserPushToken: (token: string, options?: PersonDomainCallOptions) => Promise<{
|
|
223
|
+
data: {
|
|
224
|
+
registered: boolean;
|
|
225
|
+
};
|
|
226
|
+
}>;
|
|
227
|
+
/** GET /counts — the badge numbers. */
|
|
228
|
+
counts: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotificationCounts>>;
|
|
229
|
+
/** PUT /{id}/read. */
|
|
230
|
+
markRead: (notificationId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotification>>;
|
|
231
|
+
/** DELETE /{id}/read. */
|
|
232
|
+
markUnread: (notificationId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotification>>;
|
|
233
|
+
/**
|
|
234
|
+
* POST /read-all `{up_to}` — pass the `created_at` of the NEWEST row the screen showed, so
|
|
235
|
+
* a notification that arrived after it rendered stays unread. Without it, everything is
|
|
236
|
+
* marked (only for an explicit "mark everything" with nothing on screen).
|
|
237
|
+
*/
|
|
238
|
+
markAllRead: (upTo: string | null, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
|
|
239
|
+
marked_read: number;
|
|
240
|
+
}>>;
|
|
241
|
+
/** DELETE /{id} — dismiss from the list. */
|
|
242
|
+
dismiss: (notificationId: string, options?: PersonDomainCallOptions) => Promise<void>;
|
|
243
|
+
/** GET /topics — the tabs, each with unread / awaiting counts, plus totals and the snooze. */
|
|
244
|
+
topics: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotificationTopics>>;
|
|
245
|
+
/**
|
|
246
|
+
* POST /bulk — read / unread / dismiss up to 100 of the person's rows. Ids that are not
|
|
247
|
+
* theirs are ignored; `changed` counts real changes. Dismiss never removes an open decision.
|
|
248
|
+
*/
|
|
249
|
+
bulk: (operation: PersonNotificationBulkOperation, notificationIds: string[], options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
|
|
250
|
+
operation: PersonNotificationBulkOperation;
|
|
251
|
+
changed: number;
|
|
252
|
+
}>>;
|
|
253
|
+
mutes: {
|
|
254
|
+
/** POST /mutes — muting the same target again moves its end. `until` null: until unmuted. */
|
|
255
|
+
create: (target: PersonNotificationMuteTarget, until?: string | null, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotificationMute>>;
|
|
256
|
+
/** DELETE /mutes/{muteId}. */
|
|
257
|
+
remove: (muteId: string, options?: PersonDomainCallOptions) => Promise<void>;
|
|
258
|
+
};
|
|
259
|
+
/** PUT /preferences/snooze — hold every push until `until` (at most 30 days); null ends it. */
|
|
260
|
+
snooze: (until: string | null, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotificationPreferences>>;
|
|
261
|
+
/** Which members of a business profile hear each topic. Managers (`actor.manage`) only; 404 otherwise. */
|
|
262
|
+
actorRoutes: {
|
|
263
|
+
show: (actorId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ActorNotificationRoutes>>;
|
|
264
|
+
/** Replace one topic's members; an empty list returns the topic to every capability holder. */
|
|
265
|
+
update: (actorId: string, topic: PersonNotificationTopicKey, members: string[], options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ActorNotificationRoutes>>;
|
|
266
|
+
};
|
|
267
|
+
preferences: {
|
|
268
|
+
/** GET /preferences. Quiet hours are in the person's preferences — see `quietHours`. */
|
|
269
|
+
show: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotificationPreferences>>;
|
|
270
|
+
/** PUT /preferences — null hands the choice back to the platform's policy. */
|
|
271
|
+
setDigestFrequency: (frequency: PersonNotificationDigestFrequency | null, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotificationPreferences>>;
|
|
272
|
+
/** PUT /preferences/events/{eventKey} — name at least one channel. */
|
|
273
|
+
setEventChannels: (eventKey: string, channels: {
|
|
274
|
+
push?: boolean;
|
|
275
|
+
email?: boolean;
|
|
276
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonNotificationPreferences>>;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Quiet hours live in the person's standing preferences (`/api/person/preferences`), not
|
|
280
|
+
* in the notification preferences — they also govern who may reach the person at all.
|
|
281
|
+
* These calls replace the WINDOW alone (`PUT /api/person/preferences/quiet-hours`), so a
|
|
282
|
+
* notification screen never has to resend the privacy answers it did not show. Plain JSON
|
|
283
|
+
* (that endpoint is not version-negotiated); `X-Acting-As` does not apply — always the
|
|
284
|
+
* signed-in person's own preferences.
|
|
285
|
+
*/
|
|
286
|
+
quietHours: {
|
|
287
|
+
/** GET /api/person/preferences — read the window with {@link quietHoursOf}. */
|
|
288
|
+
show: (options?: {
|
|
289
|
+
signal?: AbortSignal;
|
|
290
|
+
}) => Promise<PersonDomainEnvelope<PersonStandingPreferences>>;
|
|
291
|
+
/** Set the window; all three parts are required. Answers the whole preferences object. */
|
|
292
|
+
set: (window: PersonQuietHoursWindow, options?: {
|
|
293
|
+
signal?: AbortSignal;
|
|
294
|
+
}) => Promise<PersonDomainEnvelope<PersonStandingPreferences>>;
|
|
295
|
+
/** Remove the window (all three null). */
|
|
296
|
+
clear: (options?: {
|
|
297
|
+
signal?: AbortSignal;
|
|
298
|
+
}) => Promise<PersonDomainEnvelope<PersonStandingPreferences>>;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Send one of a decision's declared actions. Refused locally (no request) unless the
|
|
302
|
+
* action is a write verb on a `/api/person/` path: a notification's payload must never be
|
|
303
|
+
* able to drive a request elsewhere. Pass ONE idempotency key per press and reuse it on
|
|
304
|
+
* a retry of the same press.
|
|
305
|
+
*/
|
|
306
|
+
perform: <Answer = unknown>(action: PersonNotificationAction, options?: PersonDomainCallOptions) => Promise<Answer>;
|
|
307
|
+
/**
|
|
308
|
+
* Bulk accept / decline: send the action named `actionKey` on every OPEN decision in
|
|
309
|
+
* `notifications`, a few at a time. Each row's own route is called (the owning module
|
|
310
|
+
* re-checks it); one fresh idempotency key per row. Rows without that action, or whose
|
|
311
|
+
* action is not performable, are reported, not sent. Never throws: read the outcomes.
|
|
312
|
+
*/
|
|
313
|
+
decideMany: (notifications: PersonNotification[], actionKey: string, settings?: {
|
|
314
|
+
concurrency?: number;
|
|
315
|
+
signal?: AbortSignal;
|
|
316
|
+
idempotencyKeyFor?: (notificationId: string) => string;
|
|
317
|
+
}) => Promise<PersonNotificationDecisionOutcome[]>;
|
|
318
|
+
};
|
|
319
|
+
export type PersonNotificationsNamespace = ReturnType<typeof createPersonNotificationsNamespace>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { listQueryParams } from './list-query.js';
|
|
2
|
+
import { newIdempotencyKey, personDomainRequest, } from './actors.js';
|
|
3
|
+
|
|
4
|
+
export const PERSON_NOTIFICATION_FRAMES = ['PersonNotificationReceived', 'PersonInboxItemResolved', 'PersonNotificationsChanged'];
|
|
5
|
+
|
|
6
|
+
export function personNotificationChannel(personId) {
|
|
7
|
+
return `private-messaging.person.${personId}`;
|
|
8
|
+
}
|
|
9
|
+
const LEGACY_SORTS = { newest: '-activity_at', oldest: 'created_at' };
|
|
10
|
+
|
|
11
|
+
export function personNotificationListState(query = {}) {
|
|
12
|
+
const sort = query.sort ? (LEGACY_SORTS[query.sort] ?? query.sort) : undefined;
|
|
13
|
+
return {
|
|
14
|
+
sort,
|
|
15
|
+
search: query.q?.trim() ? query.q.trim() : undefined,
|
|
16
|
+
cursor: query.cursor ?? undefined,
|
|
17
|
+
limit: query.limit,
|
|
18
|
+
describe: query.describe,
|
|
19
|
+
filter: {
|
|
20
|
+
category: query.category ? [query.category] : undefined,
|
|
21
|
+
topic: query.topic ?? undefined,
|
|
22
|
+
event_key: query.event_key ?? undefined,
|
|
23
|
+
unread: query.unread ? true : undefined,
|
|
24
|
+
awaiting_decision: query.awaiting_decision ? true : undefined,
|
|
25
|
+
inbox: query.inbox ?? undefined,
|
|
26
|
+
sender: query.sender ?? undefined,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ACTION_PATH = /^\/api\/person\/[A-Za-z0-9._~\-/]+$/;
|
|
32
|
+
const ACTION_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);
|
|
33
|
+
|
|
34
|
+
export function isPerformablePersonNotificationAction(action) {
|
|
35
|
+
return ACTION_METHODS.has(action.method.toUpperCase()) && ACTION_PATH.test(action.path) && !action.path.includes('..');
|
|
36
|
+
}
|
|
37
|
+
const BASE = '/api/person/notifications';
|
|
38
|
+
|
|
39
|
+
export const MAXIMUM_BULK = 100;
|
|
40
|
+
|
|
41
|
+
const PREFERENCES = '/api/person/preferences';
|
|
42
|
+
|
|
43
|
+
export function quietHoursOf(preferences) {
|
|
44
|
+
if (preferences.quiet_hours_start === null || preferences.quiet_hours_end === null || preferences.quiet_hours_timezone === null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return { start: preferences.quiet_hours_start, end: preferences.quiet_hours_end, timezone: preferences.quiet_hours_timezone };
|
|
48
|
+
}
|
|
49
|
+
export function createPersonNotificationsNamespace(http) {
|
|
50
|
+
const read = (options, params) => personDomainRequest(options, false, params);
|
|
51
|
+
const write = (options) => personDomainRequest(options, true);
|
|
52
|
+
return {
|
|
53
|
+
|
|
54
|
+
list: (query = {}, options) => http.get(BASE, personDomainRequest(options, false, listQueryParams(personNotificationListState(query)))),
|
|
55
|
+
|
|
56
|
+
registerBrowserPushToken: (token, options) => http.post(`${BASE}/push-tokens`, { token }, write(options)),
|
|
57
|
+
|
|
58
|
+
unregisterBrowserPushToken: (token, options) => http.delete(`${BASE}/push-tokens`, personDomainRequest(options, true, { token })),
|
|
59
|
+
|
|
60
|
+
counts: (options) => http.get(`${BASE}/counts`, read(options)),
|
|
61
|
+
|
|
62
|
+
markRead: (notificationId, options) => http.put(`${BASE}/${encodeURIComponent(notificationId)}/read`, undefined, write(options)),
|
|
63
|
+
|
|
64
|
+
markUnread: (notificationId, options) => http.delete(`${BASE}/${encodeURIComponent(notificationId)}/read`, write(options)),
|
|
65
|
+
|
|
66
|
+
markAllRead: (upTo, options) => http.post(`${BASE}/read-all`, upTo === null ? {} : { up_to: upTo }, write(options)),
|
|
67
|
+
|
|
68
|
+
dismiss: (notificationId, options) => http.delete(`${BASE}/${encodeURIComponent(notificationId)}`, write(options)),
|
|
69
|
+
|
|
70
|
+
topics: (options) => http.get(`${BASE}/topics`, read(options)),
|
|
71
|
+
|
|
72
|
+
bulk: (operation, notificationIds, options) => http.post(`${BASE}/bulk`, { operation, notification_ids: notificationIds.slice(0, MAXIMUM_BULK) }, write(options)),
|
|
73
|
+
mutes: {
|
|
74
|
+
|
|
75
|
+
create: (target, until = null, options) => http.post(`${BASE}/mutes`, until === null ? target : { ...target, until }, write(options)),
|
|
76
|
+
|
|
77
|
+
remove: (muteId, options) => http.delete(`${BASE}/mutes/${encodeURIComponent(muteId)}`, write(options)),
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
snooze: (until, options) => http.put(`${BASE}/preferences/snooze`, { until }, write(options)),
|
|
81
|
+
|
|
82
|
+
actorRoutes: {
|
|
83
|
+
show: (actorId, options) => http.get(`${BASE}/actors/${encodeURIComponent(actorId)}/routes`, read(options)),
|
|
84
|
+
|
|
85
|
+
update: (actorId, topic, members, options) => http.put(`${BASE}/actors/${encodeURIComponent(actorId)}/routes/${encodeURIComponent(topic)}`, { members }, write(options)),
|
|
86
|
+
},
|
|
87
|
+
preferences: {
|
|
88
|
+
|
|
89
|
+
show: (options) => http.get(`${BASE}/preferences`, read(options)),
|
|
90
|
+
|
|
91
|
+
setDigestFrequency: (frequency, options) => http.put(`${BASE}/preferences`, { digest_frequency: frequency }, write(options)),
|
|
92
|
+
|
|
93
|
+
setEventChannels: (eventKey, channels, options) => http.put(`${BASE}/preferences/events/${encodeURIComponent(eventKey)}`, channels, write(options)),
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
quietHours: {
|
|
97
|
+
|
|
98
|
+
show: (options = {}) => http.get(PREFERENCES, options.signal ? { signal: options.signal } : {}),
|
|
99
|
+
|
|
100
|
+
set: (window, options = {}) => http.put(`${PREFERENCES}/quiet-hours`, { quiet_hours_start: window.start, quiet_hours_end: window.end, quiet_hours_timezone: window.timezone }, options.signal ? { signal: options.signal } : {}),
|
|
101
|
+
|
|
102
|
+
clear: (options = {}) => http.put(`${PREFERENCES}/quiet-hours`, { quiet_hours_start: null, quiet_hours_end: null, quiet_hours_timezone: null }, options.signal ? { signal: options.signal } : {}),
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
perform: (action, options) => {
|
|
106
|
+
if (!isPerformablePersonNotificationAction(action)) {
|
|
107
|
+
return Promise.reject(new Error(`Refused to perform a notification action outside the person plane: ${action.method} ${action.path}`));
|
|
108
|
+
}
|
|
109
|
+
const method = action.method.toUpperCase();
|
|
110
|
+
const request = write(options);
|
|
111
|
+
if (method === 'DELETE')
|
|
112
|
+
return http.delete(action.path, request);
|
|
113
|
+
if (method === 'PUT')
|
|
114
|
+
return http.put(action.path, undefined, request);
|
|
115
|
+
if (method === 'PATCH')
|
|
116
|
+
return http.patch(action.path, undefined, request);
|
|
117
|
+
return http.post(action.path, undefined, request);
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
decideMany: async (notifications, actionKey, settings = {}) => {
|
|
121
|
+
const queue = [...notifications];
|
|
122
|
+
const outcomes = [];
|
|
123
|
+
const concurrency = Math.max(1, Math.min(settings.concurrency ?? 4, 8));
|
|
124
|
+
const performOne = async (notification) => {
|
|
125
|
+
const action = notification.actions.find((candidate) => candidate.key === actionKey);
|
|
126
|
+
if (!action)
|
|
127
|
+
return { notificationId: notification.id, ok: false, error: 'no_such_action' };
|
|
128
|
+
if (!isPerformablePersonNotificationAction(action))
|
|
129
|
+
return { notificationId: notification.id, ok: false, error: 'refused_locally' };
|
|
130
|
+
try {
|
|
131
|
+
const method = action.method.toUpperCase();
|
|
132
|
+
const request = write({
|
|
133
|
+
signal: settings.signal,
|
|
134
|
+
idempotencyKey: settings.idempotencyKeyFor?.(notification.id) ?? newIdempotencyKey(),
|
|
135
|
+
});
|
|
136
|
+
if (method === 'DELETE')
|
|
137
|
+
await http.delete(action.path, request);
|
|
138
|
+
else if (method === 'PUT')
|
|
139
|
+
await http.put(action.path, undefined, request);
|
|
140
|
+
else if (method === 'PATCH')
|
|
141
|
+
await http.patch(action.path, undefined, request);
|
|
142
|
+
else
|
|
143
|
+
await http.post(action.path, undefined, request);
|
|
144
|
+
return { notificationId: notification.id, ok: true };
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return { notificationId: notification.id, ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const worker = async () => {
|
|
151
|
+
for (let next = queue.shift(); next !== undefined; next = queue.shift()) {
|
|
152
|
+
if (settings.signal?.aborted) {
|
|
153
|
+
outcomes.push({ notificationId: next.id, ok: false, error: 'aborted' });
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
outcomes.push(await performOne(next));
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, queue.length) }, worker));
|
|
160
|
+
const order = new Map(notifications.map((notification, index) => [notification.id, index]));
|
|
161
|
+
return outcomes.sort((left, right) => (order.get(left.notificationId) ?? 0) - (order.get(right.notificationId) ?? 0));
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
|
|
3
|
+
export type PersonalisationAnswer = 'personalised' | 'not_personalised' | 'unanswered';
|
|
4
|
+
export type PersonalisationChoice = Exclude<PersonalisationAnswer, 'unanswered'>;
|
|
5
|
+
export interface PersonalisationState {
|
|
6
|
+
answer: PersonalisationAnswer;
|
|
7
|
+
personalised: boolean;
|
|
8
|
+
should_ask: boolean;
|
|
9
|
+
switch_available: boolean;
|
|
10
|
+
is_minor: boolean;
|
|
11
|
+
policy: {
|
|
12
|
+
value: 'ask_once' | 'personalised_with_switch' | 'opt_in' | (string & {});
|
|
13
|
+
decided_at: string;
|
|
14
|
+
label: BilingualText;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface PersonalisationNamespace {
|
|
18
|
+
get(options?: PersonDomainCallOptions): Promise<PersonDomainEnvelope<PersonalisationState>>;
|
|
19
|
+
answer(answer: PersonalisationChoice, options?: PersonDomainCallOptions): Promise<PersonDomainEnvelope<PersonalisationState>>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createPersonalisationNamespace(http: Http): PersonalisationNamespace;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { personDomainRequest } from './actors.js';
|
|
2
|
+
const PATH = '/api/person/preferences/personalisation';
|
|
3
|
+
export function createPersonalisationNamespace(http) {
|
|
4
|
+
return {
|
|
5
|
+
get: (options = {}) => http.get(PATH, personDomainRequest(options)),
|
|
6
|
+
answer: (answer, options = {}) => http.put(PATH, { answer }, personDomainRequest(options, true)),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform (super-admin) control plane — `/api/platform/*`.
|
|
3
|
+
*
|
|
4
|
+
* Task 3 · The platform-wide document-template gallery: super-admin CRUD over the
|
|
5
|
+
* gallery rows plus the tenant-submission review queue (approve / reject). These
|
|
6
|
+
* routes are CENTRAL / platform-wide (NOT tenant-scoped): the gallery lives on the
|
|
7
|
+
* never-switched `central` connection and a super-admin operator has no `org`. Every
|
|
8
|
+
* handler enforces the super-admin gate server-side (a non-super-admin bearer 403s).
|
|
9
|
+
*
|
|
10
|
+
* Response shapes reuse Accounting's gallery types: the `list`/`submissions`
|
|
11
|
+
* endpoints wrap in `{data}` (unwrapped here to a bare array); single-resource
|
|
12
|
+
* responses (`get`/`create`/`update`/`approve`/`reject`) are the BARE resolved
|
|
13
|
+
* object; `remove` is a 204.
|
|
14
|
+
*/
|
|
15
|
+
import type { Http } from './http.js';
|
|
16
|
+
import type { Paginated } from './types.js';
|
|
17
|
+
import type { PlatformDocumentTemplate, PlatformDocumentTemplateInput, PlatformTemplateListQuery } from './accounting.js';
|
|
18
|
+
/** One row of the active org's people directory — the PeoplePicker source. */
|
|
19
|
+
export interface OrgMember {
|
|
20
|
+
person_id: string;
|
|
21
|
+
name: string | null;
|
|
22
|
+
email: string | null;
|
|
23
|
+
}
|
|
24
|
+
export declare function createPlatformNamespace(http: Http): {
|
|
25
|
+
orgMembers: (search?: string, page?: number, perPage?: number) => Promise<Paginated<OrgMember>>;
|
|
26
|
+
/**
|
|
27
|
+
* Every member of the active org, walking the pages.
|
|
28
|
+
*
|
|
29
|
+
* What a people-picker wants. A picker that shows some of the organization is not
|
|
30
|
+
* a shorter picker — it is a picker that cannot select certain colleagues, with no
|
|
31
|
+
* sign of which ones or that any are missing.
|
|
32
|
+
*
|
|
33
|
+
* `onTruncated` fires only if the walk hits `MAXIMUM_PAGES_WALKED`, which is a
|
|
34
|
+
* real bound and an honest one: the caller is told how many rows it has against
|
|
35
|
+
* how many exist, and can say so on screen. Omitting the callback does not make
|
|
36
|
+
* the bound go away, it makes it silent — pass one.
|
|
37
|
+
*/
|
|
38
|
+
allOrgMembers: (search?: string, onTruncated?: (rowsLoaded: number, rowsTotal: number) => void) => Promise<OrgMember[]>;
|
|
39
|
+
/** Super-admin CRUD over the platform document-template gallery (all statuses). */
|
|
40
|
+
platformTemplates: {
|
|
41
|
+
/**
|
|
42
|
+
* GET /api/platform/document-templates — full gallery listing (all
|
|
43
|
+
* statuses), optionally filtered by `status`/`document_type`. Bare array
|
|
44
|
+
* (`{data}`-unwrapped).
|
|
45
|
+
*/
|
|
46
|
+
list: (filter?: PlatformTemplateListQuery) => Promise<PlatformDocumentTemplate[]>;
|
|
47
|
+
get: (id: string) => Promise<PlatformDocumentTemplate>;
|
|
48
|
+
/**
|
|
49
|
+
* POST /api/platform/document-templates — author a new gallery row
|
|
50
|
+
* (created `published`). Returns the bare created resource (201).
|
|
51
|
+
*/
|
|
52
|
+
create: (payload: PlatformDocumentTemplateInput) => Promise<PlatformDocumentTemplate>;
|
|
53
|
+
update: (id: string, payload: Partial<PlatformDocumentTemplateInput>) => Promise<PlatformDocumentTemplate>;
|
|
54
|
+
remove: (id: string) => Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
/** The tenant-submission review queue — approve or reject pending gallery submissions. */
|
|
57
|
+
submissions: {
|
|
58
|
+
list: () => Promise<PlatformDocumentTemplate[]>;
|
|
59
|
+
approve: (id: string) => Promise<PlatformDocumentTemplate>;
|
|
60
|
+
reject: (id: string, note?: string) => Promise<PlatformDocumentTemplate>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type PlatformNamespace = ReturnType<typeof createPlatformNamespace>;
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { fetchAllPages, withPageQuery } from './pagination.js';
|
|
2
|
+
|
|
3
|
+
function orgMembersPath(search) {
|
|
4
|
+
return search
|
|
5
|
+
? `/api/platform/org-members?search=${encodeURIComponent(search)}`
|
|
6
|
+
: '/api/platform/org-members';
|
|
7
|
+
}
|
|
8
|
+
export function createPlatformNamespace(http) {
|
|
9
|
+
return {
|
|
10
|
+
|
|
11
|
+
orgMembers: (search, page, perPage) => http.get(page === undefined && perPage === undefined
|
|
12
|
+
? orgMembersPath(search)
|
|
13
|
+
: withPageQuery(orgMembersPath(search), page ?? 1, perPage ?? 100)),
|
|
14
|
+
|
|
15
|
+
allOrgMembers: (search, onTruncated = () => { }) => fetchAllPages((page, perPage) => http.get(withPageQuery(orgMembersPath(search), page, perPage)), onTruncated),
|
|
16
|
+
|
|
17
|
+
platformTemplates: {
|
|
18
|
+
|
|
19
|
+
list: (filter) => http
|
|
20
|
+
.get('/api/platform/document-templates', {
|
|
21
|
+
params: filter,
|
|
22
|
+
})
|
|
23
|
+
.then((r) => r.data),
|
|
24
|
+
|
|
25
|
+
get: (id) => http.get(`/api/platform/document-templates/${id}`),
|
|
26
|
+
|
|
27
|
+
create: (payload) => http.post('/api/platform/document-templates', payload),
|
|
28
|
+
|
|
29
|
+
update: (id, payload) => http.put(`/api/platform/document-templates/${id}`, payload),
|
|
30
|
+
|
|
31
|
+
remove: (id) => http.delete(`/api/platform/document-templates/${id}`),
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
submissions: {
|
|
35
|
+
|
|
36
|
+
list: () => http
|
|
37
|
+
.get('/api/platform/document-templates/submissions')
|
|
38
|
+
.then((r) => r.data),
|
|
39
|
+
|
|
40
|
+
approve: (id) => http.post(`/api/platform/document-templates/${id}/approve`),
|
|
41
|
+
|
|
42
|
+
reject: (id, note) => http.post(`/api/platform/document-templates/${id}/reject`, { note }),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|