@fias/arche-sdk 2.30.0 → 2.32.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/types.d.ts CHANGED
@@ -13,9 +13,20 @@ export { VALID_PLUGIN_PERMISSIONS, isValidPluginPermission } from './generated/p
13
13
  * User profile data available via useFiasUser() hook.
14
14
  */
15
15
  export interface FiasUser {
16
- userId: string;
16
+ /**
17
+ * Your app's identifier for this person (`aur_…`). The same everywhere in
18
+ * your app, different in every other app, so it can't link people across
19
+ * apps. Store it wherever your data names a person.
20
+ */
21
+ ref: string;
17
22
  displayName: string;
18
23
  avatar: string | null;
24
+ /**
25
+ * @deprecated The platform user id. Present only for apps that existed
26
+ * before app user refs, until the sunset; new apps never receive it. Use
27
+ * `ref`. Removed in the next major version.
28
+ */
29
+ userId?: string;
19
30
  }
20
31
  /**
21
32
  * Platform theme tokens available via useFiasTheme() hook.
@@ -596,7 +607,7 @@ export interface ImageGenerationParams {
596
607
  */
597
608
  referenceStrength?: number;
598
609
  /**
599
- * Generate in a style from the user's Creative Library (ADR-035) — a style
610
+ * Generate in a style from the user's Creative Library (ADR-037) — a style
600
611
  * made in FiasWorks Studio, say. Needs `vault:creative:read`. The platform
601
612
  * adds the style's reference pictures after your own references (up to
602
613
  * three, while the model has room) and its words to the prompt; with no
@@ -609,7 +620,7 @@ export interface ImageGenerationParams {
609
620
  *
610
621
  * Or `{ shipped: key }`: a style this arche ships for its players — listed
611
622
  * 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
623
+ * `style:<key>` (ADR-037 D7). No permission beyond this one. It is read
613
624
  * from the arche's PUBLISHED version — publish once with the style before
614
625
  * relying on it; the dev harness has none (SHIPPED_STYLE_UNAVAILABLE). The
615
626
  * player pays, as for any generation.
@@ -865,6 +876,20 @@ export interface FiasChromeState {
865
876
  * plugin that owns its chrome draws its own (`setSidebarCollapsed(false)`).
866
877
  */
867
878
  hostExpandButton: boolean;
879
+ /**
880
+ * Where the person came from, when a Fias tool opened this arche — the forge
881
+ * page's "Open FiasWorks Studio", say (ADR-037 D8) — or null. `useOpener`
882
+ * reads it without taking the chrome over. A host older than this field
883
+ * sends none (read it as null).
884
+ */
885
+ opener?: FiasOpener | null;
886
+ }
887
+ /** A Fias tool this arche was opened from (ADR-037 D8). */
888
+ export interface FiasOpener {
889
+ /** What it is: a Fias Forge, or an arche in the Arche Builder. */
890
+ kind: 'forge' | 'builder';
891
+ /** The arche's name as the person knows it ("My Arche"). */
892
+ name: string;
868
893
  }
869
894
  /** What `chrome_set` may carry — every present key a boolean. */
870
895
  export interface FiasChromeSetPayload {
@@ -874,7 +899,7 @@ export interface FiasChromeSetPayload {
874
899
  hostExpandButton?: boolean;
875
900
  }
876
901
  /** The host destinations a plugin may leave for — a closed enum, never a URL. */
877
- export type FiasChromeNavigateTarget = 'home' | 'worktop';
902
+ export type FiasChromeNavigateTarget = 'home' | 'worktop' | 'opener';
878
903
  /**
879
904
  * Host-chrome API available via useFiasChrome() — the state above plus the
880
905
  * controls the platform's own focus-mode bar carries, so a plugin can place
@@ -1893,8 +1918,10 @@ export interface CommunityAssetUrl {
1893
1918
  }
1894
1919
  export interface CommunityAssetPublishInput {
1895
1920
  /**
1896
- * The `fileId` from a `useImageGeneration()` result — the image must be one
1897
- * YOU created or uploaded, in your own Fias files.
1921
+ * The `fileId` of an image the user made IN THIS APP: a `useImageGeneration()`
1922
+ * result, or a picture uploaded through `useVaultDocuments().upload()`. A
1923
+ * file in the user's Documents (even one they granted you) is not
1924
+ * publishable by id — save your own copy with `upload()` first.
1898
1925
  *
1899
1926
  * Required here, while `ImageGenerationResult.fileId` is OPTIONAL (it is
1900
1927
  * absent if the generated image was never written to the user's files). That
@@ -1922,7 +1949,8 @@ export interface CommunityAssetPublishInput {
1922
1949
  * One item's outcome from `publishMany`. Items succeed or fail INDEPENDENTLY —
1923
1950
  * a single rejected page must not sink a whole book — and retrying only the
1924
1951
  * failures is safe: publishing the same bytes twice returns the first result
1925
- * rather than creating a duplicate.
1952
+ * rather than creating a duplicate. An item the user can't pay the safety check
1953
+ * for fails with `INSUFFICIENT_CREDITS`; the ones before it still went through.
1926
1954
  */
1927
1955
  export type CommunityAssetPublishResult = {
1928
1956
  clientRef: string | null;
@@ -1953,8 +1981,14 @@ export type CommunityAssetReportReason = 'sexual' | 'violence' | 'hate' | 'illeg
1953
1981
  export interface CommunityAssetsApi {
1954
1982
  /**
1955
1983
  * Publish one image you created so other users of this arche can see it.
1956
- * Free. It becomes visible only after moderation — expect
1984
+ * It becomes visible only after moderation — expect
1957
1985
  * `status: 'pending_moderation'` back, not `'published'`.
1986
+ *
1987
+ * The user pays for each picture's safety check (0.6 credits, charged when it
1988
+ * runs; publishing the same bytes again costs nothing). A user who can't pay
1989
+ * for it — and for their pictures still waiting to be checked — is refused
1990
+ * with `INSUFFICIENT_CREDITS` before anything is stored; tell them, rather
1991
+ * than retrying.
1958
1992
  */
1959
1993
  publish: (input: CommunityAssetPublishInput) => Promise<CommunityAsset>;
1960
1994
  /** Publish up to 20 at once; each item succeeds or fails on its own. */
@@ -1983,11 +2017,17 @@ export interface CommunityAssetsApi {
1983
2017
  }>;
1984
2018
  }
1985
2019
  /**
1986
- * A recipient: a member named by user id (the address is resolved by the
1987
- * platform and never returned to the app), or a raw address — accepted only
1988
- * when the Company allowed this app to email anyone.
2020
+ * A recipient: a member named by your app's ref for them (`FiasUser.ref`, or a
2021
+ * ref you stored — the address is resolved by the platform and never returned
2022
+ * to the app), or a raw address — accepted only when the Company allowed this
2023
+ * app to email anyone. `{ userId }` is deprecated and accepted only from apps
2024
+ * that existed before refs.
1989
2025
  */
1990
2026
  export type CompanyEmailRecipient = {
2027
+ ref: string;
2028
+ }
2029
+ /** @deprecated Use `{ ref }`. Accepted only from apps that existed before refs. */
2030
+ | {
1991
2031
  userId: string;
1992
2032
  } | {
1993
2033
  email: string;
@@ -2077,6 +2117,127 @@ export interface FiasConnectionsApi {
2077
2117
  /** Give up this app's access to one connection. */
2078
2118
  release: (connectionId: string) => Promise<void>;
2079
2119
  }
2120
+ export type FiasWebSourceSiteCategory = 'credit_union' | 'bank' | 'government' | 'other';
2121
+ /** A website Fias approved for apps to read. Any page on it (or its `www.` twin) may be read. */
2122
+ export interface FiasWebSourceSite {
2123
+ host: string;
2124
+ name: string;
2125
+ category: FiasWebSourceSiteCategory;
2126
+ }
2127
+ export interface FiasWebSourceListOptions {
2128
+ category?: FiasWebSourceSiteCategory;
2129
+ /** Matched against the site's name and host. */
2130
+ search?: string;
2131
+ /** 1–200; default 50. */
2132
+ limit?: number;
2133
+ offset?: number;
2134
+ }
2135
+ export interface FiasWebSourceSiteList {
2136
+ sites: FiasWebSourceSite[];
2137
+ total: number;
2138
+ /** Pass as `offset` for the next page; null on the last page. */
2139
+ nextOffset: number | null;
2140
+ }
2141
+ /**
2142
+ * One field of a form. Every value may come back `null` (the page did not
2143
+ * say). Fias enforces the kinds in code: a value that breaks its field's rules
2144
+ * is returned as `null` and named in `discarded`. There is no free-text kind —
2145
+ * a page never gets words of its own in front of your app; describe what you
2146
+ * need as numbers, dates, yes/no and your own `enum` choices.
2147
+ */
2148
+ export type FiasWebSourceFormScalarField = {
2149
+ kind: 'number';
2150
+ description?: string;
2151
+ min?: number;
2152
+ max?: number;
2153
+ } | {
2154
+ kind: 'integer';
2155
+ description?: string;
2156
+ min?: number;
2157
+ max?: number;
2158
+ } | {
2159
+ kind: 'boolean';
2160
+ description?: string;
2161
+ }
2162
+ /** `YYYY-MM-DD`. */
2163
+ | {
2164
+ kind: 'date';
2165
+ description?: string;
2166
+ }
2167
+ /** One of `values` (1–50 values, each ≤ 60 characters). */
2168
+ | {
2169
+ kind: 'enum';
2170
+ description?: string;
2171
+ values: string[];
2172
+ };
2173
+ /** Rows of a table: up to `maxItems` (≤ 200) objects of scalar fields. */
2174
+ export interface FiasWebSourceFormListField {
2175
+ kind: 'list';
2176
+ description?: string;
2177
+ maxItems?: number;
2178
+ item: Record<string, FiasWebSourceFormScalarField>;
2179
+ }
2180
+ export type FiasWebSourceFormField = FiasWebSourceFormScalarField | FiasWebSourceFormListField;
2181
+ /**
2182
+ * What to read off the page: up to 30 fields, names matching
2183
+ * `^[a-zA-Z][a-zA-Z0-9_]{0,39}$`. Descriptions (≤ 200 characters) tell the
2184
+ * reader what each field means.
2185
+ */
2186
+ export interface FiasWebSourceForm {
2187
+ /** What the form is for (≤ 300 characters). */
2188
+ description?: string;
2189
+ fields: Record<string, FiasWebSourceFormField>;
2190
+ }
2191
+ export type FiasWebSourceValue = number | boolean | string | null;
2192
+ export type FiasWebSourceData = Record<string, FiasWebSourceValue | Array<Record<string, FiasWebSourceValue>>>;
2193
+ export interface FiasWebSourceExtractRequest {
2194
+ /** An `https://` page on an approved site. */
2195
+ url: string;
2196
+ form: FiasWebSourceForm;
2197
+ /**
2198
+ * The oldest copy you will accept, in seconds (default one day, up to 30
2199
+ * days). A page is fetched from its site at most once an hour for the
2200
+ * whole platform, so anything under 3600 is treated as 3600.
2201
+ */
2202
+ maxAgeSeconds?: number;
2203
+ }
2204
+ export interface FiasWebSourceExtraction<T extends FiasWebSourceData = FiasWebSourceData> {
2205
+ url: string;
2206
+ /**
2207
+ * The site redirected this address to another page on the same site, and
2208
+ * that page is what was read. The new address is not returned: it is text
2209
+ * the site chose.
2210
+ */
2211
+ redirected: boolean;
2212
+ site: FiasWebSourceSite;
2213
+ /** When the page was fetched from its site (ISO 8601) — show it beside the figures. */
2214
+ fetchedAt: string;
2215
+ /** Older than `maxAgeSeconds`: the site could not be asked again just now. */
2216
+ stale: boolean;
2217
+ /** Nothing was fetched or read for this call, so nothing was charged. */
2218
+ fromCache: boolean;
2219
+ /** The page's values, in the form's shape. */
2220
+ data: T;
2221
+ /** Fields (and list rows) whose values broke the form's rules and became null or were dropped. */
2222
+ discarded: string[];
2223
+ /** The page was longer than the reader reads; values past the cut are missing. */
2224
+ pageTruncated: boolean;
2225
+ /**
2226
+ * Scripts present and almost no text: the page probably builds its content
2227
+ * with JavaScript, which is never run. Read the site's PDF or data address instead.
2228
+ */
2229
+ scriptHeavy: boolean;
2230
+ }
2231
+ export interface FiasWebSourcesApi {
2232
+ /** The sites Fias approved for apps to read. Free. */
2233
+ listSites: (options?: FiasWebSourceListOptions) => Promise<FiasWebSourceSiteList>;
2234
+ /**
2235
+ * A page on an approved site, read into `form`. A fresh fetch (about a
2236
+ * tenth of a cent) and the reading (a fast model's tokens) are charged to
2237
+ * the user; a cached result is free. Never returns the page's text.
2238
+ */
2239
+ extract: <T extends FiasWebSourceData = FiasWebSourceData>(request: FiasWebSourceExtractRequest) => Promise<FiasWebSourceExtraction<T>>;
2240
+ }
2080
2241
  export type FiasCreativeItemKind = 'style' | 'character';
2081
2242
  /** A style or character, as the Creative Library returns it. */
2082
2243
  export interface FiasCreativeItem {
@@ -2126,7 +2287,7 @@ export interface FiasCreativeLibraryApi {
2126
2287
  }) => Promise<FiasCreativeItem[]>;
2127
2288
  /** One item, with preview URLs; pass `version` for an earlier version. */
2128
2289
  get: (itemId: string, version?: number) => Promise<FiasCreativeItem>;
2129
- /** Needs `vault:creative:write`. A style has 1–12 pictures; a character exactly one. */
2290
+ /** Needs `vault:creative:write`. A style has 1–100 pictures; a character exactly one. */
2130
2291
  create: (fields: FiasCreativeItemFields & {
2131
2292
  kind: FiasCreativeItemKind;
2132
2293
  name: string;
@@ -2153,6 +2314,36 @@ export interface FiasCreativeLibraryApi {
2153
2314
  kind?: FiasCreativeItemKind;
2154
2315
  }) => Promise<FiasCreativePickResult>;
2155
2316
  }
2317
+ /**
2318
+ * Where the person came from, and what you can do about it (ADR-037 D8) —
2319
+ * `useOpener()`.
2320
+ */
2321
+ export interface FiasOpenerApi {
2322
+ /** The Fias tool that opened this arche, or null — then show neither action. */
2323
+ opener: FiasOpener | null;
2324
+ /** Take the person back to `opener`. Does nothing without one. */
2325
+ returnTo: () => void;
2326
+ /**
2327
+ * Offer one of YOUR files (a Vault file this arche created) to `opener`:
2328
+ * Fias shows the person a sheet naming the file and the destination, and
2329
+ * their Send moves it — into a Fias Forge's `public/`, or an Arche Builder
2330
+ * arche's asset library. `name` is the name it should land as. Requires
2331
+ * `opener:send`. Resolves `{ sent: true, name }` once it arrived (the name
2332
+ * it landed as), or `{ canceled: true }`. Rejects with `NO_OPENER` without
2333
+ * an `opener`, `SHEET_BUSY` while another Fias sheet is open, and
2334
+ * `SEND_UNAVAILABLE` where there is none (the dev harness).
2335
+ */
2336
+ send: (file: {
2337
+ fileId: string;
2338
+ name?: string;
2339
+ }) => Promise<FiasSendToOpenerResult>;
2340
+ }
2341
+ export type FiasSendToOpenerResult = {
2342
+ sent: true;
2343
+ name: string;
2344
+ } | {
2345
+ canceled: true;
2346
+ };
2156
2347
  /** What `useCreativeLibrary().pick()` resolves with. */
2157
2348
  export type FiasCreativePickResult = {
2158
2349
  item: {
@@ -2741,6 +2932,13 @@ export interface DataStoreCollectionConstraints {
2741
2932
  immutableFields?: string[];
2742
2933
  references?: DataStoreReference[];
2743
2934
  ledgerSums?: DataStoreLedgerSum[];
2935
+ /**
2936
+ * Field paths that name people (ADR-040): when present, each holds one app
2937
+ * user ref (`useFiasUser().ref`) or an array of up to 20, and nothing else.
2938
+ * Declare every field your data uses for a person — it is what lets Fias
2939
+ * relate your records to people and carry refs safely between apps.
2940
+ */
2941
+ personFields?: string[];
2744
2942
  }
2745
2943
  /**
2746
2944
  * Counter-follows-ledger: `field` on this collection's documents may only
@@ -3155,15 +3353,31 @@ export interface DataStoreWorkspace {
3155
3353
  */
3156
3354
  holderBacked?: boolean;
3157
3355
  }
3158
- /** A member of a workspace. Members are addressed by username — the platform
3159
- * userId is internal and never exposed to plugins or users. */
3356
+ /**
3357
+ * A member of a workspace (ADR-040 §4). Members are named by your app's `ref`
3358
+ * for them, with their display name; the platform userId is never exposed.
3359
+ * Apps that existed before refs still get `username` instead.
3360
+ */
3160
3361
  export interface DataStoreWorkspaceMember {
3161
- username: string;
3362
+ /** Your app's ref for this member — pass it back to `updateMember` / `removeMember`. */
3363
+ ref?: string;
3364
+ displayName?: string;
3365
+ /** @deprecated Only for apps that existed before refs, which get it instead of `ref`. */
3366
+ username?: string;
3162
3367
  role: WorkspaceRole;
3163
3368
  grantedAt: string;
3164
3369
  /** ISO-8601 expiry, or null for a permanent membership. Owners never expire. */
3165
3370
  expiresAt: string | null;
3166
3371
  }
3372
+ /**
3373
+ * Who a membership change is about: `{ ref }` from `listMembers`. A plain
3374
+ * username string works only for apps from before app user refs (until the
3375
+ * sunset) and in the dev harness and Forge test channel; elsewhere it rejects
3376
+ * with `MEMBER_TARGET_USE_REF`.
3377
+ */
3378
+ export type WorkspaceMemberTarget = string | {
3379
+ ref: string;
3380
+ };
3167
3381
  /**
3168
3382
  * Workspace tenancy API available via the `useFiasWorkspaces()` hook.
3169
3383
  *
@@ -3207,14 +3421,57 @@ export interface FiasWorkspacesApi {
3207
3421
  archive: (workspaceId: string) => Promise<void>;
3208
3422
  /** List a workspace's members (any member). */
3209
3423
  listMembers: (workspaceId: string) => Promise<DataStoreWorkspaceMember[]>;
3210
- /** Add a member by username, with a role (owner/admin; cannot grant above your
3211
- * own role). Optionally time-bound the membership with an ISO-8601 `expiresAt`
3212
- * (owners cannot expire). Rejects with `USER_NOT_FOUND` if no such user. */
3424
+ /**
3425
+ * Let the person add people to a workspace, in a sheet Fias draws (ADR-040).
3426
+ * The person picks co-members of their Fias workspace or types an exact
3427
+ * username, and may change the suggested `role`; you never name anyone.
3428
+ * Resolves with who was added (empty if they added no one), by `ref`.
3429
+ * Rejects with `ADD_PEOPLE_UNAVAILABLE` where Fias draws no sheet (the
3430
+ * Forge test channel) and `SHEET_BUSY` while another sheet is open.
3431
+ */
3432
+ addPeople: (workspaceId: string, options?: {
3433
+ role?: 'admin' | 'member' | 'viewer';
3434
+ }) => Promise<{
3435
+ added: AddedWorkspacePerson[];
3436
+ }>;
3437
+ /**
3438
+ * @deprecated Use `addPeople`. Adding by a username your code supplies works
3439
+ * only for apps that existed before app user refs (until the sunset), and in
3440
+ * the dev harness and Forge test channel; elsewhere it rejects with
3441
+ * `ADD_MEMBER_USE_SHEET`. Owner/admin; cannot grant above your own role;
3442
+ * optional ISO-8601 `expiresAt` (owners cannot expire).
3443
+ */
3213
3444
  addMember: (workspaceId: string, username: string, role: WorkspaceRole, expiresAt?: string) => Promise<DataStoreWorkspaceMember>;
3214
- /** Change a member's role by username (owner/admin; keeps the one-owner invariant). */
3215
- updateMember: (workspaceId: string, username: string, role: WorkspaceRole) => Promise<DataStoreWorkspaceMember>;
3216
- /** Remove a member by username (owner/admin, or yourself; keeps the one-owner invariant). */
3217
- removeMember: (workspaceId: string, username: string) => Promise<void>;
3445
+ /** Change a member's role (owner/admin; keeps the one-owner invariant). */
3446
+ updateMember: (workspaceId: string, member: WorkspaceMemberTarget, role: WorkspaceRole) => Promise<DataStoreWorkspaceMember>;
3447
+ /** Remove a member (owner/admin, or yourself; keeps the one-owner invariant). */
3448
+ removeMember: (workspaceId: string, member: WorkspaceMemberTarget) => Promise<void>;
3449
+ /**
3450
+ * Names for people your app knows by ref (`FiasUser.ref`, or refs you
3451
+ * stored), any number (an empty list answers `[]`; the SDK pages large
3452
+ * lists), in the order given. A ref is named only
3453
+ * when it belongs to a current member of `workspaceId` — a workspace you
3454
+ * belong to — and every other ref is `null`: someone who left, an unknown
3455
+ * ref, another app's ref. Without `workspaceId`, only the user's own ref
3456
+ * resolves. In a Fias org workspace, names also need `data:workspace-people:read`
3457
+ * and the workspace's approval of your app covering it; otherwise every ref
3458
+ * is `null`. Never returns an id or an email. Refuses like `get` when you
3459
+ * are not a member.
3460
+ */
3461
+ resolvePeople: (refs: string[], workspaceId?: string) => Promise<(FiasPerson | null)[]>;
3462
+ }
3463
+ /** Someone the person added in the Add people sheet (ADR-040). */
3464
+ export interface AddedWorkspacePerson {
3465
+ /** Your app's ref for them. */
3466
+ ref: string;
3467
+ displayName: string;
3468
+ role: string;
3469
+ }
3470
+ /** A person your app named by ref (ADR-040): display name only, never an id. */
3471
+ export interface FiasPerson {
3472
+ ref: string;
3473
+ displayName: string;
3474
+ avatar: string | null;
3218
3475
  }
3219
3476
  /**
3220
3477
  * The current user's access in one workspace where only workspace TIERS