@fias/arche-sdk 2.29.0 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge.d.ts +32 -6
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +73 -2
- package/dist/bridge.js.map +1 -1
- package/dist/bridge.test.js +71 -0
- package/dist/bridge.test.js.map +1 -1
- package/dist/entity-ops.d.ts +10 -0
- package/dist/entity-ops.d.ts.map +1 -1
- package/dist/entity-ops.js +11 -1
- package/dist/entity-ops.js.map +1 -1
- package/dist/generated/permissions.d.ts +1 -1
- package/dist/generated/permissions.d.ts.map +1 -1
- package/dist/generated/permissions.js +6 -0
- package/dist/generated/permissions.js.map +1 -1
- package/dist/generated/surfaces.d.ts +119 -5
- package/dist/generated/surfaces.d.ts.map +1 -1
- package/dist/generated/surfaces.js +14 -6
- package/dist/generated/surfaces.js.map +1 -1
- package/dist/hooks.d.ts +140 -18
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +611 -38
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.test.js +539 -0
- package/dist/hooks.test.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +495 -21
- package/dist/types.d.ts +432 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/use-fias-access.render.test.d.ts +12 -0
- package/dist/use-fias-access.render.test.d.ts.map +1 -0
- package/dist/use-fias-access.render.test.js +407 -0
- package/dist/use-fias-access.render.test.js.map +1 -0
- package/package.json +3 -2
- package/templates/default/AGENTS.md +282 -7
- package/templates/default/CLAUDE.md +282 -7
package/dist/types.d.ts
CHANGED
|
@@ -595,6 +595,32 @@ export interface ImageGenerationParams {
|
|
|
595
595
|
* `referenceImage` is provided.
|
|
596
596
|
*/
|
|
597
597
|
referenceStrength?: number;
|
|
598
|
+
/**
|
|
599
|
+
* Generate in a style from the user's Creative Library (ADR-035) — a style
|
|
600
|
+
* made in FiasWorks Studio, say. Needs `vault:creative:read`. The platform
|
|
601
|
+
* adds the style's reference pictures after your own references (up to
|
|
602
|
+
* three, while the model has room) and its words to the prompt; with no
|
|
603
|
+
* room left it carries the style in words, which needs a description
|
|
604
|
+
* (STYLE_NEEDS_DESCRIPTION otherwise). `version` pins one version of the
|
|
605
|
+
* style; leave it out for the current one. `pictures` chooses which of the
|
|
606
|
+
* style's pictures go, in order (1–3 of its `referenceDocumentIds`; an indoor
|
|
607
|
+
* picture for an indoor scene) — leave it out for its first. Get ids from
|
|
608
|
+
* `useCreativeLibrary`.
|
|
609
|
+
*
|
|
610
|
+
* Or `{ shipped: key }`: a style this arche ships for its players — listed
|
|
611
|
+
* in the manifest's `styles` with its pictures in the asset library tagged
|
|
612
|
+
* `style:<key>` (ADR-035 D7). No permission beyond this one. It is read
|
|
613
|
+
* from the arche's PUBLISHED version — publish once with the style before
|
|
614
|
+
* relying on it; the dev harness has none (SHIPPED_STYLE_UNAVAILABLE). The
|
|
615
|
+
* player pays, as for any generation.
|
|
616
|
+
*/
|
|
617
|
+
creativeStyle?: {
|
|
618
|
+
styleId: string;
|
|
619
|
+
version?: number;
|
|
620
|
+
pictures?: string[];
|
|
621
|
+
} | {
|
|
622
|
+
shipped: string;
|
|
623
|
+
};
|
|
598
624
|
}
|
|
599
625
|
/**
|
|
600
626
|
* A reference image for `useImageGeneration`: an asset from this arche's
|
|
@@ -799,6 +825,91 @@ export interface AudioGenerationApi {
|
|
|
799
825
|
result: AudioGenerationResult | null;
|
|
800
826
|
error: Error | null;
|
|
801
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* The host chrome around a plugin's arche, as the host reports it (`init`
|
|
830
|
+
* and every `chrome_update`). See `useFiasChrome`.
|
|
831
|
+
*
|
|
832
|
+
* "Focus mode" is the platform's expand: the platform header, the arche's
|
|
833
|
+
* own header and the suggested-arches sidebar are hidden so the arche fills
|
|
834
|
+
* the viewport, and the host draws a thin bar with the way back — Fias home,
|
|
835
|
+
* Worktop, Fias AI, Collapse — unless the plugin suppresses it and draws its
|
|
836
|
+
* own.
|
|
837
|
+
*/
|
|
838
|
+
export interface FiasChromeState {
|
|
839
|
+
/** The arche is expanded (platform header + sidebar hidden). */
|
|
840
|
+
focusMode: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Whether focus mode exists on this surface at all — only the normal
|
|
843
|
+
* signed-in layout has chrome to hide. False on public, full-screen and
|
|
844
|
+
* embedded views, where `setFocusMode` is ignored.
|
|
845
|
+
*/
|
|
846
|
+
focusModeAvailable: boolean;
|
|
847
|
+
/**
|
|
848
|
+
* Whether the layout draws the suggested-arches sidebar for this arche —
|
|
849
|
+
* false where the manifest declined it (`showSidebar: false`) and on
|
|
850
|
+
* surfaces that never had one. Hide your sidebar toggle when false.
|
|
851
|
+
*/
|
|
852
|
+
sidebarAvailable: boolean;
|
|
853
|
+
/** The sidebar is collapsed (only meaningful when `sidebarAvailable`). */
|
|
854
|
+
sidebarCollapsed: boolean;
|
|
855
|
+
/**
|
|
856
|
+
* In focus mode, the host draws its thin bar (Fias home · Worktop · Fias
|
|
857
|
+
* AI · Collapse). False when the plugin suppressed it to draw its own.
|
|
858
|
+
*/
|
|
859
|
+
hostExpandedBar: boolean;
|
|
860
|
+
/**
|
|
861
|
+
* The host draws its default expand button over the plugin. False once a
|
|
862
|
+
* plugin takes the chrome over (mounting `useFiasChrome` does that) or
|
|
863
|
+
* when the manifest declined it (`showExpandButton: false`). The takeover
|
|
864
|
+
* also removes the host's re-open control for a collapsed sidebar — a
|
|
865
|
+
* plugin that owns its chrome draws its own (`setSidebarCollapsed(false)`).
|
|
866
|
+
*/
|
|
867
|
+
hostExpandButton: boolean;
|
|
868
|
+
}
|
|
869
|
+
/** What `chrome_set` may carry — every present key a boolean. */
|
|
870
|
+
export interface FiasChromeSetPayload {
|
|
871
|
+
focusMode?: boolean;
|
|
872
|
+
sidebarCollapsed?: boolean;
|
|
873
|
+
hostExpandedBar?: boolean;
|
|
874
|
+
hostExpandButton?: boolean;
|
|
875
|
+
}
|
|
876
|
+
/** The host destinations a plugin may leave for — a closed enum, never a URL. */
|
|
877
|
+
export type FiasChromeNavigateTarget = 'home' | 'worktop';
|
|
878
|
+
/**
|
|
879
|
+
* Host-chrome API available via useFiasChrome() — the state above plus the
|
|
880
|
+
* controls the platform's own focus-mode bar carries, so a plugin can place
|
|
881
|
+
* them where its design wants them.
|
|
882
|
+
*/
|
|
883
|
+
export interface FiasChromeApi extends FiasChromeState {
|
|
884
|
+
/**
|
|
885
|
+
* The host delivered chrome state. False before `init` lands and on a host
|
|
886
|
+
* older than this API — the state fields then hold inert defaults and the
|
|
887
|
+
* setters are no-ops, so a plugin can render unconditionally.
|
|
888
|
+
*/
|
|
889
|
+
supported: boolean;
|
|
890
|
+
/** Expand (`true`) or collapse (`false`) — the platform's own expand/contract. */
|
|
891
|
+
setFocusMode: (on: boolean) => void;
|
|
892
|
+
/** Collapse or reopen the suggested-arches sidebar (when `sidebarAvailable`). */
|
|
893
|
+
setSidebarCollapsed: (collapsed: boolean) => void;
|
|
894
|
+
/**
|
|
895
|
+
* Keep (`true`, the default) or suppress (`false`) the host's focus-mode
|
|
896
|
+
* bar. Suppress it ONLY if you draw your own way back — once the chrome is
|
|
897
|
+
* hidden that bar is the only one. Focus mode you set persists across
|
|
898
|
+
* reloads only while the bar is kept; with it suppressed a reload restores
|
|
899
|
+
* the chrome, so a broken collapse control of yours is never a trap.
|
|
900
|
+
*/
|
|
901
|
+
setHostExpandedBar: (shown: boolean) => void;
|
|
902
|
+
/** Leave the arche for Fias home (`/`). */
|
|
903
|
+
goToFiasHome: () => void;
|
|
904
|
+
/** Leave the arche for the user's Worktop. */
|
|
905
|
+
goToWorktop: () => void;
|
|
906
|
+
/**
|
|
907
|
+
* Ask the host to open the Fias AI panel. No permission needed; no text can
|
|
908
|
+
* be passed (the assistant's input belongs to the user); the host debounces
|
|
909
|
+
* and honours the user's last dismissal — never call it on mount or in a loop.
|
|
910
|
+
*/
|
|
911
|
+
openAssistant: () => void;
|
|
912
|
+
}
|
|
802
913
|
/**
|
|
803
914
|
* Navigation API available via useFiasNavigation() hook.
|
|
804
915
|
*/
|
|
@@ -1966,6 +2077,93 @@ export interface FiasConnectionsApi {
|
|
|
1966
2077
|
/** Give up this app's access to one connection. */
|
|
1967
2078
|
release: (connectionId: string) => Promise<void>;
|
|
1968
2079
|
}
|
|
2080
|
+
export type FiasCreativeItemKind = 'style' | 'character';
|
|
2081
|
+
/** A style or character, as the Creative Library returns it. */
|
|
2082
|
+
export interface FiasCreativeItem {
|
|
2083
|
+
itemId: string;
|
|
2084
|
+
kind: FiasCreativeItemKind;
|
|
2085
|
+
name: string;
|
|
2086
|
+
/** The version shown — the current one unless you asked for another. */
|
|
2087
|
+
version: number;
|
|
2088
|
+
currentVersion: number;
|
|
2089
|
+
/** A style's description, or a character's appearance. */
|
|
2090
|
+
words: string;
|
|
2091
|
+
/** Vault document ids of the reference pictures, best first. */
|
|
2092
|
+
referenceDocumentIds: string[];
|
|
2093
|
+
/** A character's style: a library style id or a built-in style key. Null for a style. */
|
|
2094
|
+
styleRef: string | null;
|
|
2095
|
+
/** YOUR arche's own fields on this item; other arches' are never shown. */
|
|
2096
|
+
extension: Record<string, unknown> | null;
|
|
2097
|
+
/** The arche that created it, when one did. */
|
|
2098
|
+
sourceArcheId: string | null;
|
|
2099
|
+
createdAt: string;
|
|
2100
|
+
updatedAt: string;
|
|
2101
|
+
deletedAt: string | null;
|
|
2102
|
+
/** `get` only: short-lived (5 minute) inline preview URLs of the reference pictures. */
|
|
2103
|
+
previews?: Array<{
|
|
2104
|
+
documentId: string;
|
|
2105
|
+
url: string;
|
|
2106
|
+
expiresAt: string;
|
|
2107
|
+
}>;
|
|
2108
|
+
}
|
|
2109
|
+
export interface FiasCreativeItemFields {
|
|
2110
|
+
name?: string;
|
|
2111
|
+
words?: string;
|
|
2112
|
+
/** Images THIS arche created (e.g. with `useVaultDocuments().upload`), in the same library. */
|
|
2113
|
+
referenceDocumentIds?: string[];
|
|
2114
|
+
styleRef?: string | null;
|
|
2115
|
+
/** Your arche's own fields; `null` removes them on update. At most 16 KB. */
|
|
2116
|
+
extension?: Record<string, unknown> | null;
|
|
2117
|
+
}
|
|
2118
|
+
export interface FiasCreativeLibraryApi {
|
|
2119
|
+
/**
|
|
2120
|
+
* Styles and characters, most recently changed first — the whole library
|
|
2121
|
+
* (it holds at most 500); with `includeDeleted`, the 500 most recently changed.
|
|
2122
|
+
*/
|
|
2123
|
+
list: (options?: {
|
|
2124
|
+
kind?: FiasCreativeItemKind;
|
|
2125
|
+
includeDeleted?: boolean;
|
|
2126
|
+
}) => Promise<FiasCreativeItem[]>;
|
|
2127
|
+
/** One item, with preview URLs; pass `version` for an earlier version. */
|
|
2128
|
+
get: (itemId: string, version?: number) => Promise<FiasCreativeItem>;
|
|
2129
|
+
/** Needs `vault:creative:write`. A style has 1–12 pictures; a character exactly one. */
|
|
2130
|
+
create: (fields: FiasCreativeItemFields & {
|
|
2131
|
+
kind: FiasCreativeItemKind;
|
|
2132
|
+
name: string;
|
|
2133
|
+
}) => Promise<FiasCreativeItem>;
|
|
2134
|
+
/**
|
|
2135
|
+
* Writes the next version; fields left out carry forward. Pass
|
|
2136
|
+
* `expectedVersion` to fail with CREATIVE_VERSION_CONFLICT if someone else
|
|
2137
|
+
* changed it first.
|
|
2138
|
+
*/
|
|
2139
|
+
update: (itemId: string, fields: FiasCreativeItemFields & {
|
|
2140
|
+
expectedVersion?: number;
|
|
2141
|
+
}) => Promise<FiasCreativeItem>;
|
|
2142
|
+
/** To the trash (versions kept); `restore` brings it back. */
|
|
2143
|
+
remove: (itemId: string) => Promise<FiasCreativeItem>;
|
|
2144
|
+
restore: (itemId: string) => Promise<FiasCreativeItem>;
|
|
2145
|
+
/**
|
|
2146
|
+
* Let the person pick one style or character in a sheet Fias draws, with
|
|
2147
|
+
* its pictures — what `list` would return, nothing more. Resolves with the
|
|
2148
|
+
* item picked, or `{ canceled: true }` when they close the sheet. Rejects
|
|
2149
|
+
* with `PICKER_UNAVAILABLE` where there is no picker (the dev harness, the
|
|
2150
|
+
* builder preview) and `SHEET_BUSY` while another Fias sheet is open.
|
|
2151
|
+
*/
|
|
2152
|
+
pick: (options?: {
|
|
2153
|
+
kind?: FiasCreativeItemKind;
|
|
2154
|
+
}) => Promise<FiasCreativePickResult>;
|
|
2155
|
+
}
|
|
2156
|
+
/** What `useCreativeLibrary().pick()` resolves with. */
|
|
2157
|
+
export type FiasCreativePickResult = {
|
|
2158
|
+
item: {
|
|
2159
|
+
itemId: string;
|
|
2160
|
+
kind: FiasCreativeItemKind;
|
|
2161
|
+
name: string;
|
|
2162
|
+
version: number;
|
|
2163
|
+
};
|
|
2164
|
+
} | {
|
|
2165
|
+
canceled: true;
|
|
2166
|
+
};
|
|
1969
2167
|
/** One X post. Images are Vault document ids: this app's own files, or ones shared with it. */
|
|
1970
2168
|
export interface FiasXPostInput {
|
|
1971
2169
|
text: string;
|
|
@@ -2164,7 +2362,7 @@ export interface CompanyEmailApi {
|
|
|
2164
2362
|
/**
|
|
2165
2363
|
* Message types sent from the plugin iframe to the parent frame.
|
|
2166
2364
|
*/
|
|
2167
|
-
export type PluginToHostMessageType = 'ready' | 'resize' | 'toast' | 'get_user' | 'get_theme' | 'storage_read' | 'storage_write' | 'storage_list' | 'storage_delete' | 'entity_invoke' | 'client_entity_invoke' | 'image_generate' | 'entities_list_image' | 'audio_generate' | 'surface_invoke' | 'navigate' | 'open_arche' | 'data_create_collection' | 'data_list_collections' | 'data_delete_collection' | 'data_put' | 'data_get' | 'data_query' | 'data_delete' | 'data_batch' | 'data_search' | 'workspace_create' | 'workspace_list' | 'workspace_get' | 'workspace_archive' | 'workspace_list_members' | 'workspace_add_member' | 'workspace_update_member' | 'workspace_remove_member' | 'store_get_products' | 'store_purchase' | 'store_get_entitlements' | 'store_get_purchase_history' | 'store_restore' | 'store_cancel_subscription' | 'vault_documents_list' | 'vault_documents_read' | 'vault_documents_read_many' | 'vault_documents_download_url' | 'vault_documents_get_urls' | 'vault_documents_search' | 'vault_documents_write' | 'vault_documents_update' | 'vault_documents_delete' | 'vault_documents_attach' | 'vault_documents_detach' | 'vault_documents_upload_init' | 'vault_documents_upload_finalize' | 'vault_documents_upload' | 'vault_documents_pick' | 'arche_assets_list' | 'arche_assets_index' | 'arche_assets_get_url' | 'preview_state' | 'subscription_unsubscribe' | 'ai_actions_declare' | 'ai_state' | 'ai_action_result' | 'ai_open';
|
|
2365
|
+
export type PluginToHostMessageType = 'ready' | 'resize' | 'toast' | 'get_user' | 'get_theme' | 'storage_read' | 'storage_write' | 'storage_list' | 'storage_delete' | 'entity_invoke' | 'client_entity_invoke' | 'image_generate' | 'entities_list_image' | 'audio_generate' | 'surface_invoke' | 'navigate' | 'open_arche' | 'data_create_collection' | 'data_list_collections' | 'data_delete_collection' | 'data_put' | 'data_get' | 'data_query' | 'data_delete' | 'data_batch' | 'data_search' | 'workspace_create' | 'workspace_list' | 'workspace_get' | 'workspace_archive' | 'workspace_list_members' | 'workspace_add_member' | 'workspace_update_member' | 'workspace_remove_member' | 'store_get_products' | 'store_purchase' | 'store_get_entitlements' | 'store_get_purchase_history' | 'store_restore' | 'store_cancel_subscription' | 'vault_documents_list' | 'vault_documents_read' | 'vault_documents_read_many' | 'vault_documents_download_url' | 'vault_documents_get_urls' | 'vault_documents_search' | 'vault_documents_write' | 'vault_documents_update' | 'vault_documents_delete' | 'vault_documents_attach' | 'vault_documents_detach' | 'vault_documents_upload_init' | 'vault_documents_upload_finalize' | 'vault_documents_upload' | 'vault_documents_pick' | 'arche_assets_list' | 'arche_assets_index' | 'arche_assets_get_url' | 'preview_state' | 'subscription_unsubscribe' | 'ai_actions_declare' | 'ai_state' | 'ai_action_result' | 'ai_open' | 'chrome_set' | 'chrome_navigate';
|
|
2168
2366
|
/**
|
|
2169
2367
|
* One Fias AI action a plugin declares — what the platform assistant may do
|
|
2170
2368
|
* in this plugin's UI while it is open. Mirrors the platform's
|
|
@@ -2204,18 +2402,33 @@ export interface FiasAIActionsDeclaration {
|
|
|
2204
2402
|
/**
|
|
2205
2403
|
* Why a realtime subscription ended (ADR-012 Phase M4). Closed union so
|
|
2206
2404
|
* hooks can distinguish terminal endings (`authorization_revoked`,
|
|
2207
|
-
* `collection_deleted`
|
|
2208
|
-
* change (`limit`,
|
|
2405
|
+
* `collection_deleted` — the observed resource is gone, whatever its kind)
|
|
2406
|
+
* from ones worth resubscribing after conditions change (`limit`,
|
|
2407
|
+
* `transport_error`, `lease_expired`).
|
|
2209
2408
|
*/
|
|
2210
2409
|
export type SubscriptionEndedReason = 'authorization_revoked' | 'lease_expired' | 'collection_deleted' | 'limit' | 'transport_error' | 'unsubscribed';
|
|
2211
2410
|
/**
|
|
2212
|
-
*
|
|
2411
|
+
* A realtime invalidation delivered to a subscriber (ADR-012 Phase M4).
|
|
2412
|
+
* Notify-then-refetch: it says only that the observed resource changed.
|
|
2413
|
+
* `resource` is the resource's public identifier as you subscribed to it —
|
|
2414
|
+
* a datastore collection's name, a chat channel's id.
|
|
2213
2415
|
*/
|
|
2214
|
-
export interface
|
|
2416
|
+
export interface SubscriptionEvent {
|
|
2417
|
+
resource: string;
|
|
2418
|
+
changed: true;
|
|
2419
|
+
/** @deprecated Alias of `resource`, kept for bundles built before the `resource` rename; removed in the next major. */
|
|
2420
|
+
collection?: string;
|
|
2421
|
+
}
|
|
2422
|
+
/**
|
|
2423
|
+
* State reported by useEntitySubscription() and useDataSubscription().
|
|
2424
|
+
*/
|
|
2425
|
+
export interface EntitySubscriptionState {
|
|
2215
2426
|
status: 'subscribing' | 'active' | 'ended';
|
|
2216
2427
|
/** Set once status === 'ended'. */
|
|
2217
2428
|
endedReason?: SubscriptionEndedReason;
|
|
2218
2429
|
}
|
|
2430
|
+
/** State reported by useDataSubscription() — the same shape as every entity subscription. */
|
|
2431
|
+
export type DataSubscriptionState = EntitySubscriptionState;
|
|
2219
2432
|
/**
|
|
2220
2433
|
* Step navigation API available via useStepNavigation() hook.
|
|
2221
2434
|
*/
|
|
@@ -2241,7 +2454,7 @@ export interface StepNavigationOptions {
|
|
|
2241
2454
|
/**
|
|
2242
2455
|
* Message types sent from the parent frame to the plugin iframe.
|
|
2243
2456
|
*/
|
|
2244
|
-
export type HostToPluginMessageType = 'init' | 'response' | 'theme_update' | 'navigate_update' | 'step_navigate' | 'stream_token' | 'text_models_update' | 'preview_state_capture' | 'preview_state_restore' | 'subscription_event' | 'subscription_ended' | 'ai_action_dispatch' | 'arche_handoff';
|
|
2457
|
+
export type HostToPluginMessageType = 'init' | 'response' | 'theme_update' | 'access_update' | 'navigate_update' | 'chrome_update' | 'step_navigate' | 'stream_token' | 'text_models_update' | 'preview_state_capture' | 'preview_state_restore' | 'subscription_event' | 'subscription_ended' | 'ai_action_dispatch' | 'arche_handoff';
|
|
2245
2458
|
/**
|
|
2246
2459
|
* Base message structure for all bridge communication.
|
|
2247
2460
|
*/
|
|
@@ -2358,6 +2571,12 @@ export interface BridgeInitMessage {
|
|
|
2358
2571
|
theme: FiasTheme;
|
|
2359
2572
|
/** Plugin-relative path — see `FiasNavigationApi.currentPath`. */
|
|
2360
2573
|
currentPath: string;
|
|
2574
|
+
/**
|
|
2575
|
+
* The host-chrome state for this arche — see `FiasChromeState`. Absent
|
|
2576
|
+
* from hosts older than `useFiasChrome` (the hook then reports
|
|
2577
|
+
* `supported: false`), and null on a surface with no chrome of its own.
|
|
2578
|
+
*/
|
|
2579
|
+
chrome?: FiasChromeState | null;
|
|
2361
2580
|
/**
|
|
2362
2581
|
* Self-hosted vendored-library asset URLs (keyed by import specifier) —
|
|
2363
2582
|
* present only when the plugin declared `sandbox:vendored-libraries` and the
|
|
@@ -2432,6 +2651,20 @@ export interface DataStoreCollection {
|
|
|
2432
2651
|
* plugin can VERIFY its declared constraints took effect.
|
|
2433
2652
|
*/
|
|
2434
2653
|
constraints?: DataStoreCollectionConstraints | null;
|
|
2654
|
+
/**
|
|
2655
|
+
* The app-role permissions that protect this collection (workspace scope,
|
|
2656
|
+
* apps that declare `access` in fias-plugin.json); null = none. Set once,
|
|
2657
|
+
* from the manifest only. Returned so a plugin can VERIFY its declaration
|
|
2658
|
+
* took effect — absent from older platforms.
|
|
2659
|
+
*/
|
|
2660
|
+
readPermission?: string | null;
|
|
2661
|
+
writePermission?: string | null;
|
|
2662
|
+
/**
|
|
2663
|
+
* The audiences (manifest `access.audiences`) this collection's documents
|
|
2664
|
+
* may be placed in (ADR-034); null = none. Set with the permissions, then
|
|
2665
|
+
* only grows. Absent from older platforms.
|
|
2666
|
+
*/
|
|
2667
|
+
audiences?: string[] | null;
|
|
2435
2668
|
/**
|
|
2436
2669
|
* Which plugin project created this collection, as the dev harness reported
|
|
2437
2670
|
* it. Display metadata only — never a scope or an authorization input.
|
|
@@ -2601,9 +2834,15 @@ export interface DataStoreBatchOptions {
|
|
|
2601
2834
|
* read-back. Absent on platforms without conditional-write support.
|
|
2602
2835
|
*/
|
|
2603
2836
|
export interface DataStoreBatchResult {
|
|
2837
|
+
/**
|
|
2838
|
+
* Each put's key — the server-generated one for a put without a key, in a
|
|
2839
|
+
* collection with audiences — its version, and the audience it sits in
|
|
2840
|
+
* (where it has one).
|
|
2841
|
+
*/
|
|
2604
2842
|
written?: {
|
|
2605
2843
|
key: string;
|
|
2606
2844
|
version?: number;
|
|
2845
|
+
audience?: string;
|
|
2607
2846
|
}[];
|
|
2608
2847
|
}
|
|
2609
2848
|
/**
|
|
@@ -2614,6 +2853,14 @@ export interface DataStoreBatchResult {
|
|
|
2614
2853
|
*/
|
|
2615
2854
|
export interface DataStorePutResult {
|
|
2616
2855
|
version?: number;
|
|
2856
|
+
/**
|
|
2857
|
+
* The document's key — the one the server generated for a create in a
|
|
2858
|
+
* collection with audiences (see {@link FiasDataStoreApi.create}). Absent
|
|
2859
|
+
* from hosts that predate audiences.
|
|
2860
|
+
*/
|
|
2861
|
+
key?: string;
|
|
2862
|
+
/** The audience the document sits in, in a collection with audiences. */
|
|
2863
|
+
audience?: string;
|
|
2617
2864
|
}
|
|
2618
2865
|
/**
|
|
2619
2866
|
* A document returned from the data store.
|
|
@@ -2639,6 +2886,12 @@ export interface DataStoreDocument<T = Record<string, unknown>> {
|
|
|
2639
2886
|
* absent otherwise.
|
|
2640
2887
|
*/
|
|
2641
2888
|
authoredByCollaborator?: boolean;
|
|
2889
|
+
/**
|
|
2890
|
+
* The audience the document is placed in, in a collection with audiences
|
|
2891
|
+
* (ADR-034): who may read it is decided by the platform from the
|
|
2892
|
+
* audience's readers, never by your code. Absent elsewhere.
|
|
2893
|
+
*/
|
|
2894
|
+
audience?: string;
|
|
2642
2895
|
}
|
|
2643
2896
|
/**
|
|
2644
2897
|
* Filter condition for querying documents.
|
|
@@ -2727,6 +2980,8 @@ export interface DataStoreSearchMatch<T = Record<string, unknown>> {
|
|
|
2727
2980
|
version?: number;
|
|
2728
2981
|
/** Present on shared-scope matches: see {@link DataStoreDocument.authoredByCollaborator}. */
|
|
2729
2982
|
authoredByCollaborator?: boolean;
|
|
2983
|
+
/** The match's audience, in a collection with audiences — see {@link DataStoreDocument.audience}. */
|
|
2984
|
+
audience?: string;
|
|
2730
2985
|
}
|
|
2731
2986
|
/**
|
|
2732
2987
|
* Data Store API available via useFiasDataStore() hook.
|
|
@@ -2761,7 +3016,14 @@ export interface FiasDataStoreApi {
|
|
|
2761
3016
|
}) => Promise<DataStoreCollection>;
|
|
2762
3017
|
/** List all collections for this arche. */
|
|
2763
3018
|
listCollections: () => Promise<DataStoreCollection[]>;
|
|
2764
|
-
/**
|
|
3019
|
+
/**
|
|
3020
|
+
* Delete a collection and all its documents. Only an arche collaborator
|
|
3021
|
+
* (owner or publisher) may; anyone else gets `FORBIDDEN`. On a published app
|
|
3022
|
+
* it works only while the collection is EMPTY: one that still holds
|
|
3023
|
+
* documents (every user's, workspace's and tenant's) is refused with
|
|
3024
|
+
* `COLLECTION_NOT_EMPTY`. Sandbox tenants (fias-dev, builder preview, test
|
|
3025
|
+
* channel) can delete any.
|
|
3026
|
+
*/
|
|
2765
3027
|
deleteCollection: (name: string) => Promise<void>;
|
|
2766
3028
|
/**
|
|
2767
3029
|
* Write (upsert) a document by key. For a `workspace`-scoped collection pass
|
|
@@ -2771,7 +3033,30 @@ export interface FiasDataStoreApi {
|
|
|
2771
3033
|
* Resolves with the document's post-write `version` (ADR-014) so a follow-up
|
|
2772
3034
|
* conditional batch can assert it without a read-back.
|
|
2773
3035
|
*/
|
|
2774
|
-
put: <T extends Record<string, unknown> = Record<string, unknown>>(collection: string,
|
|
3036
|
+
put: <T extends Record<string, unknown> = Record<string, unknown>>(collection: string,
|
|
3037
|
+
/**
|
|
3038
|
+
* The document to write. In a collection with audiences keys are made by
|
|
3039
|
+
* the server: pass `null` to create one (or use {@link create}); a key
|
|
3040
|
+
* names an existing document you may change, and anything else —
|
|
3041
|
+
* missing, or in an audience you cannot read — is refused alike
|
|
3042
|
+
* (`DOCUMENT_NOT_FOUND`). Passing `{ audience }` with a key MOVES the
|
|
3043
|
+
* document to that audience.
|
|
3044
|
+
*/
|
|
3045
|
+
key: string | null, data: T, options?: DataStoreScopeOptions) => Promise<DataStorePutResult>;
|
|
3046
|
+
/**
|
|
3047
|
+
* Create a document in a collection with audiences (ADR-034): the server
|
|
3048
|
+
* makes its key and places it in `options.audience`, which you must name.
|
|
3049
|
+
* Placing needs the audience's `disclosedBy` permission — not its read
|
|
3050
|
+
* permission, so a person can file something they will not see afterwards.
|
|
3051
|
+
* Resolves with the new key. Only in collections with audiences — in one
|
|
3052
|
+
* without, a create is `INVALID_DOCUMENT_KEY` (keys there are yours). A
|
|
3053
|
+
* platform that predates audiences rejects the call as invalid parameters
|
|
3054
|
+
* (`INVALID_PARAMS`); `AUDIENCES_UNAVAILABLE` is only a backstop for a host
|
|
3055
|
+
* that accepted it yet returned no key.
|
|
3056
|
+
*/
|
|
3057
|
+
create: <T extends Record<string, unknown> = Record<string, unknown>>(collection: string, data: T, options: DataStoreScopeOptions & {
|
|
3058
|
+
audience: string;
|
|
3059
|
+
}) => Promise<Required<Pick<DataStorePutResult, 'key'>> & DataStorePutResult>;
|
|
2775
3060
|
/** Get a document by key. Returns null if not found. Pass `{ workspaceId }`
|
|
2776
3061
|
* for a workspace-scoped collection. */
|
|
2777
3062
|
get: <T extends Record<string, unknown> = Record<string, unknown>>(collection: string, key: string, options?: DataStoreScopeOptions) => Promise<T | null>;
|
|
@@ -2821,6 +3106,15 @@ export interface FiasDataStoreApi {
|
|
|
2821
3106
|
export interface DataStoreScopeOptions {
|
|
2822
3107
|
/** Target workspace for a `workspace`-scoped collection. */
|
|
2823
3108
|
workspaceId?: string;
|
|
3109
|
+
/**
|
|
3110
|
+
* An audience of a collection with audiences (ADR-034, the manifest's
|
|
3111
|
+
* `access.audiences`): where `put`/`create` places the document, or the one
|
|
3112
|
+
* audience `get`/`query`/`search` look in (by default they read every
|
|
3113
|
+
* audience the user reads). Ignored by `delete`. Naming one before the
|
|
3114
|
+
* workspace has turned the app's roles on is refused
|
|
3115
|
+
* (`ACCESS_SETUP_REQUIRED`).
|
|
3116
|
+
*/
|
|
3117
|
+
audience?: string;
|
|
2824
3118
|
}
|
|
2825
3119
|
/**
|
|
2826
3120
|
* One write in an atomic batch (see {@link FiasDataStoreApi.batch}). A `put`
|
|
@@ -2830,9 +3124,12 @@ export interface DataStoreScopeOptions {
|
|
|
2830
3124
|
export type DataStoreBatchOp = {
|
|
2831
3125
|
op: 'put';
|
|
2832
3126
|
collection: string;
|
|
2833
|
-
key
|
|
3127
|
+
/** Omit to create with a server-generated key (collections with audiences). */
|
|
3128
|
+
key?: string;
|
|
2834
3129
|
data: Record<string, unknown>;
|
|
2835
3130
|
workspaceId?: string;
|
|
3131
|
+
/** Where to place (or move) the document — see {@link DataStoreScopeOptions.audience}. */
|
|
3132
|
+
audience?: string;
|
|
2836
3133
|
} | {
|
|
2837
3134
|
op: 'delete';
|
|
2838
3135
|
collection: string;
|
|
@@ -2919,6 +3216,132 @@ export interface FiasWorkspacesApi {
|
|
|
2919
3216
|
/** Remove a member by username (owner/admin, or yourself; keeps the one-owner invariant). */
|
|
2920
3217
|
removeMember: (workspaceId: string, username: string) => Promise<void>;
|
|
2921
3218
|
}
|
|
3219
|
+
/**
|
|
3220
|
+
* The current user's access in one workspace where only workspace TIERS
|
|
3221
|
+
* (owner/admin/member/viewer) apply: an app that declares no roles, or a
|
|
3222
|
+
* workspace outside an organization, where roles never apply.
|
|
3223
|
+
*/
|
|
3224
|
+
export interface FiasTierAccess {
|
|
3225
|
+
mode: 'tier';
|
|
3226
|
+
workspaceId: string;
|
|
3227
|
+
/**
|
|
3228
|
+
* The user's tier in this workspace, or `null` when they have none: not a
|
|
3229
|
+
* member, an expired or removed membership, or a workspace this app cannot
|
|
3230
|
+
* see from where it is open.
|
|
3231
|
+
*/
|
|
3232
|
+
tier: WorkspaceRole | null;
|
|
3233
|
+
/** ISO-8601 expiry of the user's membership, or `null` when it does not expire. */
|
|
3234
|
+
expiresAt: string | null;
|
|
3235
|
+
}
|
|
3236
|
+
/**
|
|
3237
|
+
* An app that declares roles (manifest `access`), in an org workspace that has
|
|
3238
|
+
* not turned them on: it runs on TIERS until an owner activates roles. Collections that existed before the app declared roles work
|
|
3239
|
+
* as before; one created already protected is refused with
|
|
3240
|
+
* `ACCESS_SETUP_REQUIRED`.
|
|
3241
|
+
*/
|
|
3242
|
+
export interface FiasLegacyAccess {
|
|
3243
|
+
mode: 'legacy';
|
|
3244
|
+
workspaceId: string;
|
|
3245
|
+
tier: WorkspaceRole;
|
|
3246
|
+
/** ISO-8601 expiry of the user's membership, or `null` when it does not expire. */
|
|
3247
|
+
expiresAt: string | null;
|
|
3248
|
+
}
|
|
3249
|
+
/** One app role the user holds that counts now. */
|
|
3250
|
+
export interface FiasAccessRole {
|
|
3251
|
+
/** The role id your manifest declares. */
|
|
3252
|
+
id: string;
|
|
3253
|
+
/** ISO-8601 expiry of this assignment, or `null` when it does not expire. */
|
|
3254
|
+
expiresAt: string | null;
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* An app that declares roles, in an org workspace where they are on: the
|
|
3258
|
+
* user's roles that count at their current tier, and the permissions those
|
|
3259
|
+
* roles grant. A role whose `minTier` the user's tier does not meet is left
|
|
3260
|
+
* out — it grants nothing until they are promoted.
|
|
3261
|
+
*/
|
|
3262
|
+
export interface FiasRolesAccess {
|
|
3263
|
+
mode: 'roles';
|
|
3264
|
+
workspaceId: string;
|
|
3265
|
+
tier: WorkspaceRole;
|
|
3266
|
+
/** ISO-8601 expiry of the user's membership, or `null` when it does not expire. */
|
|
3267
|
+
expiresAt: string | null;
|
|
3268
|
+
roles: FiasAccessRole[];
|
|
3269
|
+
/** The permission ids the user holds here, sorted. */
|
|
3270
|
+
permissions: string[];
|
|
3271
|
+
/**
|
|
3272
|
+
* The audiences (manifest `access.audiences`) those permissions read, and
|
|
3273
|
+
* the ones they may place documents in. Across the app — a collection lists
|
|
3274
|
+
* which of them it uses, and reading one also needs the collection's own
|
|
3275
|
+
* read permission. Empty while the workspace is still placing its existing
|
|
3276
|
+
* documents. Absent from hosts that predate audiences.
|
|
3277
|
+
*/
|
|
3278
|
+
audiences?: {
|
|
3279
|
+
readable: string[];
|
|
3280
|
+
disclosable: string[];
|
|
3281
|
+
};
|
|
3282
|
+
}
|
|
3283
|
+
/**
|
|
3284
|
+
* The current user's own access in a workspace, from `useFiasAccess()`.
|
|
3285
|
+
*
|
|
3286
|
+
* `mode` says which model answered: `'tier'` for an app without roles (or a
|
|
3287
|
+
* workspace outside an organization, where roles never apply), `'legacy'`
|
|
3288
|
+
* for an app whose roles this workspace has not turned on yet, and
|
|
3289
|
+
* `'roles'` when they are on. Handle a `mode` you do not recognise by hiding
|
|
3290
|
+
* the controls it would gate, never by showing them.
|
|
3291
|
+
*
|
|
3292
|
+
* **A UI hint, never security.** The platform checks every read and write on
|
|
3293
|
+
* arrival; this only lets you hide controls a user could not use anyway.
|
|
3294
|
+
*/
|
|
3295
|
+
export type FiasAccess = FiasTierAccess | FiasLegacyAccess | FiasRolesAccess;
|
|
3296
|
+
/** What `useFiasAccess()` returns. */
|
|
3297
|
+
export interface FiasAccessState {
|
|
3298
|
+
/** The user's access, or `null` while loading, on error, or with no workspace given. */
|
|
3299
|
+
access: FiasAccess | null;
|
|
3300
|
+
/**
|
|
3301
|
+
* True until the first answer for this workspace. A later ask (focus,
|
|
3302
|
+
* `access_update`, `refetch()`) keeps the answer it has and does not set it.
|
|
3303
|
+
*/
|
|
3304
|
+
isLoading: boolean;
|
|
3305
|
+
/** A failure other than "no access here" (which is `access.tier === null`). */
|
|
3306
|
+
error: Error | null;
|
|
3307
|
+
/**
|
|
3308
|
+
* Whether the user holds `permission` here: true only in `'roles'` mode,
|
|
3309
|
+
* with that permission. Always false in `'tier'` and `'legacy'` mode, where
|
|
3310
|
+
* permissions are not in force — branch on `access.mode` (and the tier)
|
|
3311
|
+
* there.
|
|
3312
|
+
*/
|
|
3313
|
+
can: (permission: string) => boolean;
|
|
3314
|
+
/**
|
|
3315
|
+
* Whether the user reads `audience` here — true only in `'roles'` mode. A
|
|
3316
|
+
* UI hint like `can()`: the platform only ever returns documents of the
|
|
3317
|
+
* audiences the user reads. Reading a document also needs its collection's
|
|
3318
|
+
* `readPermission`; this does not check that — `can()` it too.
|
|
3319
|
+
*/
|
|
3320
|
+
canReadAudience: (audience: string) => boolean;
|
|
3321
|
+
/** Whether the user may place documents in `audience` here — true only in `'roles'` mode. */
|
|
3322
|
+
canDiscloseTo: (audience: string) => boolean;
|
|
3323
|
+
/**
|
|
3324
|
+
* Ask again. The answer is a snapshot and is NOT pushed when the user's
|
|
3325
|
+
* access changes elsewhere, so call this when it may have: after the app
|
|
3326
|
+
* changes a membership itself, or when the platform refuses an action with
|
|
3327
|
+
* `FORBIDDEN` / `NOT_A_MEMBER`. A refetch of the same workspace keeps the
|
|
3328
|
+
* current answer until the new one arrives.
|
|
3329
|
+
*/
|
|
3330
|
+
refetch: () => void;
|
|
3331
|
+
/**
|
|
3332
|
+
* Open Fias's access sheet for the workspace the person is acting in: their
|
|
3333
|
+
* own access to this app's data, why, asking for more, and — for an access
|
|
3334
|
+
* manager — managing roles. Drawn by Fias; the app passes nothing and
|
|
3335
|
+
* changes nothing itself. Resolves once the person closes it (and refetches
|
|
3336
|
+
* when their access changed); rejects with `NOT_IN_WORKSPACE` in a Personal
|
|
3337
|
+
* workspace, where app roles never apply, `SHEET_BUSY` while another Fias
|
|
3338
|
+
* sheet is open, or `ACCESS_UNAVAILABLE` where no Fias host can draw it (the
|
|
3339
|
+
* dev harness). Requires `data:workspace`.
|
|
3340
|
+
*/
|
|
3341
|
+
openAccessDialog: () => Promise<{
|
|
3342
|
+
changed: boolean;
|
|
3343
|
+
}>;
|
|
3344
|
+
}
|
|
2922
3345
|
/**
|
|
2923
3346
|
* IAP product type (mirrors Apple StoreKit).
|
|
2924
3347
|
*/
|