@fias/arche-sdk 2.19.2 → 2.20.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/generated/permissions.d.ts +1 -1
- package/dist/generated/permissions.d.ts.map +1 -1
- package/dist/generated/permissions.js +15 -13
- package/dist/generated/permissions.js.map +1 -1
- package/dist/hooks.d.ts +53 -6
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +151 -24
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.test.js +143 -20
- 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 +5 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -31
- package/dist/types.d.ts +124 -61
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/templates/default/AGENTS.md +56 -22
- package/templates/default/CLAUDE.md +56 -22
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* `tests/architecture/sdk-permissions-match-db-types.test.ts` ensures
|
|
10
10
|
* this file stays in lockstep with the canonical source.
|
|
11
11
|
*/
|
|
12
|
-
export type PluginPermission = 'ai:actions' | 'assets:community:publish' | 'assets:community:read' | 'assets:read' | 'data:search' | 'data:store' | 'data:workspace' | 'entities:audio_generate' | 'entities:client_invoke' | 'entities:image_edit' | 'entities:image_generate' | 'entities:invoke' | 'entities:web_search' | 'navigation:open_arche' | 'sandbox:vendored-libraries' | 'storage:sandbox' | 'store:purchase' | 'theme:read' | 'user:profile:read' | 'vault:documents:read' | 'vault:documents:write' | 'vault:user-documents:edit' | 'vault:user-documents:read' | 'vault:user-documents:write';
|
|
12
|
+
export type PluginPermission = 'ai:actions' | 'assets:community:publish' | 'assets:community:read' | 'assets:read' | 'data:search' | 'data:store' | 'data:workspace' | 'entities:audio_generate' | 'entities:client_invoke' | 'entities:image_edit' | 'entities:image_generate' | 'entities:invoke' | 'entities:web_search' | 'navigation:open_arche' | 'sandbox:vendored-libraries' | 'storage:sandbox' | 'store:purchase' | 'theme:read' | 'user:profile:read' | 'vault:arche-saves:write' | 'vault:documents:read' | 'vault:documents:write' | 'vault:user-documents:edit' | 'vault:user-documents:read' | 'vault:user-documents:write';
|
|
13
13
|
export declare const VALID_PLUGIN_PERMISSIONS: readonly PluginPermission[];
|
|
14
14
|
export declare function isValidPluginPermission(perm: string): perm is PluginPermission;
|
|
15
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/generated/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,0BAA0B,GAC1B,uBAAuB,GACvB,aAAa,GACb,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,yBAAyB,GACzB,wBAAwB,GACxB,qBAAqB,GACrB,yBAAyB,GACzB,iBAAiB,GACjB,qBAAqB,GACrB,uBAAuB,GACvB,4BAA4B,GAC5B,iBAAiB,GACjB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,sBAAsB,GACtB,uBAAuB,GACvB,2BAA2B,GAC3B,2BAA2B,GAC3B,4BAA4B,CAAC;AAEjC,eAAO,MAAM,wBAAwB,EAAE,SAAS,gBAAgB,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/generated/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,0BAA0B,GAC1B,uBAAuB,GACvB,aAAa,GACb,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,yBAAyB,GACzB,wBAAwB,GACxB,qBAAqB,GACrB,yBAAyB,GACzB,iBAAiB,GACjB,qBAAqB,GACrB,uBAAuB,GACvB,4BAA4B,GAC5B,iBAAiB,GACjB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,yBAAyB,GACzB,sBAAsB,GACtB,uBAAuB,GACvB,2BAA2B,GAC3B,2BAA2B,GAC3B,4BAA4B,CAAC;AAEjC,eAAO,MAAM,wBAAwB,EAAE,SAAS,gBAAgB,EA0BtD,CAAC;AAEX,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAE9E;AAED;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAkCrF,CAAC"}
|
|
@@ -33,6 +33,7 @@ exports.VALID_PLUGIN_PERMISSIONS = [
|
|
|
33
33
|
'store:purchase',
|
|
34
34
|
'theme:read',
|
|
35
35
|
'user:profile:read',
|
|
36
|
+
'vault:arche-saves:write',
|
|
36
37
|
'vault:documents:read',
|
|
37
38
|
'vault:documents:write',
|
|
38
39
|
'vault:user-documents:edit',
|
|
@@ -48,12 +49,12 @@ function isValidPluginPermission(perm) {
|
|
|
48
49
|
* PLUGIN_PERMISSION_DESCRIPTIONS.
|
|
49
50
|
*/
|
|
50
51
|
exports.PLUGIN_PERMISSION_DESCRIPTIONS = {
|
|
51
|
-
'ai:actions': 'Let Fias AI operate this
|
|
52
|
-
'assets:community:publish': 'Share images you made here so other people using this
|
|
53
|
-
'assets:community:read': 'Show you images that other people using this
|
|
54
|
-
'assets:read': "Show images from this
|
|
55
|
-
'data:search': "Search this
|
|
56
|
-
'data:store': "Save structured data in this
|
|
52
|
+
'ai:actions': 'Let Fias AI operate this arche for you — only actions you could do yourself in its interface, and risky ones ask you first.',
|
|
53
|
+
'assets:community:publish': 'Share images you made here so other people using this arche can see them, and manage what you have shared.',
|
|
54
|
+
'assets:community:read': 'Show you images that other people using this arche have shared. Everything shared is checked before anyone can see it.',
|
|
55
|
+
'assets:read': "Show images from this arche's published asset library.",
|
|
56
|
+
'data:search': "Search this arche's own data semantically — costs credits per search.",
|
|
57
|
+
'data:store': "Save structured data in this arche's own private database.",
|
|
57
58
|
'data:workspace': 'Create team workspaces and manage their members.',
|
|
58
59
|
'entities:audio_generate': 'Generate audio with platform AI — costs credits.',
|
|
59
60
|
'entities:client_invoke': 'Use free on-device tools (grammar check, translation) in your browser.',
|
|
@@ -63,14 +64,15 @@ exports.PLUGIN_PERMISSION_DESCRIPTIONS = {
|
|
|
63
64
|
'entities:web_search': 'Search the live web on your behalf — costs credits.',
|
|
64
65
|
'navigation:open_arche': 'Open other arches for you (navigation only).',
|
|
65
66
|
'sandbox:vendored-libraries': 'Load platform-hosted libraries (like the PDF renderer) from the trusted CDN.',
|
|
66
|
-
'storage:sandbox': "Save files in this
|
|
67
|
-
'store:purchase': 'Offer
|
|
67
|
+
'storage:sandbox': "Save files in this arche's own private storage.",
|
|
68
|
+
'store:purchase': 'Offer purchases inside the arche (you approve each purchase).',
|
|
68
69
|
'theme:read': 'Match your platform theme.',
|
|
69
70
|
'user:profile:read': 'See your display name and avatar.',
|
|
70
|
-
'vault:
|
|
71
|
-
'vault:documents:
|
|
72
|
-
'vault:
|
|
73
|
-
'vault:user-documents:
|
|
74
|
-
'vault:user-documents:
|
|
71
|
+
'vault:arche-saves:write': 'Saves files to your Arche Saves automatically.',
|
|
72
|
+
'vault:documents:read': 'Read files this arche itself created, in its own folders of your Vault.',
|
|
73
|
+
'vault:documents:write': 'Create and manage its own files, in its own folder of your Vault.',
|
|
74
|
+
'vault:user-documents:edit': 'Save changes to files of yours that you let it edit — you choose each file, earlier versions are kept unless you turned version history off, and you can remove access any time in Vault → Arche Access.',
|
|
75
|
+
'vault:user-documents:read': 'Read documents YOU choose to share with it from your Vault — you pick each document, and you can remove access any time in Vault → Arche Access.',
|
|
76
|
+
'vault:user-documents:write': 'Save its work to your Documents — you choose the folder and the name each time.',
|
|
75
77
|
};
|
|
76
78
|
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/generated/permissions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/generated/permissions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAyDH,0DAEC;AA9BY,QAAA,wBAAwB,GAAgC;IACnE,YAAY;IACZ,0BAA0B;IAC1B,uBAAuB;IACvB,aAAa;IACb,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,yBAAyB;IACzB,wBAAwB;IACxB,qBAAqB;IACrB,yBAAyB;IACzB,iBAAiB;IACjB,qBAAqB;IACrB,uBAAuB;IACvB,4BAA4B;IAC5B,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,mBAAmB;IACnB,yBAAyB;IACzB,sBAAsB;IACtB,uBAAuB;IACvB,2BAA2B;IAC3B,2BAA2B;IAC3B,4BAA4B;CACpB,CAAC;AAEX,SAAgB,uBAAuB,CAAC,IAAY;IAClD,OAAQ,gCAA8C,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACU,QAAA,8BAA8B,GAA+C;IACxF,YAAY,EACV,6HAA6H;IAC/H,0BAA0B,EACxB,4GAA4G;IAC9G,uBAAuB,EACrB,wHAAwH;IAC1H,aAAa,EAAE,wDAAwD;IACvE,aAAa,EAAE,uEAAuE;IACtF,YAAY,EAAE,4DAA4D;IAC1E,gBAAgB,EAAE,kDAAkD;IACpE,yBAAyB,EAAE,kDAAkD;IAC7E,wBAAwB,EACtB,wEAAwE;IAC1E,qBAAqB,EAAE,+CAA+C;IACtE,yBAAyB,EAAE,mDAAmD;IAC9E,iBAAiB,EAAE,wDAAwD;IAC3E,qBAAqB,EAAE,qDAAqD;IAC5E,uBAAuB,EAAE,8CAA8C;IACvE,4BAA4B,EAC1B,8EAA8E;IAChF,iBAAiB,EAAE,iDAAiD;IACpE,gBAAgB,EAAE,+DAA+D;IACjF,YAAY,EAAE,4BAA4B;IAC1C,mBAAmB,EAAE,mCAAmC;IACxD,yBAAyB,EAAE,gDAAgD;IAC3E,sBAAsB,EAAE,yEAAyE;IACjG,uBAAuB,EAAE,mEAAmE;IAC5F,2BAA2B,EACzB,0MAA0M;IAC5M,2BAA2B,EACzB,kJAAkJ;IACpJ,4BAA4B,EAC1B,iFAAiF;CACpF,CAAC"}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArcheHandoffPayload, FiasUser, FiasTheme, FiasStorageApi, DataSubscriptionState, EntityInvocationApi, ClientEntityApi, ImageGenerationApi, ImageEntityFilter, ImageEntitySummary, NllbLanguageOption, AudioGenerationApi, FiasNavigationApi, StepNavigationApi, StepNavigationOptions, FiasDataStoreApi, FiasWorkspacesApi, FiasStoreApi, VaultDocumentsApi, VaultDocumentDownloadUrl, VaultUserDocumentSaveContentResult, ArcheAssetsApi, CommunityAssetsApi, FiasAIActionsDeclaration } from './types';
|
|
1
|
+
import type { ArcheHandoffPayload, FiasUser, FiasTheme, FiasStorageApi, DataSubscriptionState, EntityInvocationApi, ClientEntityApi, ImageGenerationApi, ImageEntityFilter, ImageEntitySummary, NllbLanguageOption, AudioGenerationApi, FiasNavigationApi, StepNavigationApi, StepNavigationOptions, FiasDataStoreApi, FiasWorkspacesApi, FiasStoreApi, VaultDocumentsApi, VaultDocumentDownloadUrl, VaultUserDocumentSaveContentResult, ArcheAssetsApi, FiasContentApi, FiasContentErrorCode, CommunityAssetsApi, FiasAIActionsDeclaration } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Access the current user's profile information.
|
|
4
4
|
* Requires the `user:profile:read` permission in fias-plugin.json.
|
|
@@ -342,6 +342,46 @@ export declare function useVaultDocuments(): VaultDocumentsApi;
|
|
|
342
342
|
* // entries[i].signedUrl is a short-lived URL you can use as <img src>
|
|
343
343
|
*/
|
|
344
344
|
export declare function useArcheAssets(): ArcheAssetsApi;
|
|
345
|
+
/**
|
|
346
|
+
* Entity ID of the plugin content pack client-side entity (ADR-021) — the
|
|
347
|
+
* host-side reader behind {@link useFiasContent}. Literal here so the SDK
|
|
348
|
+
* stays bundle-clean (no `@fias/entities` runtime dep).
|
|
349
|
+
*
|
|
350
|
+
* SYNC NOTE: must match `PLUGIN_CONTENT_ENTITY_ID` in
|
|
351
|
+
* `packages/entities/src/integrations/plugin-content/config.ts`. The
|
|
352
|
+
* architecture test `sdk-entity-id-constants-match.test.ts` pins this.
|
|
353
|
+
*/
|
|
354
|
+
export declare const PLUGIN_CONTENT_ENTITY_ID = "ent_intg_plugin_content_00000000";
|
|
355
|
+
/** A failed content read: `code` says why, `path` names the file when there is one. */
|
|
356
|
+
export declare class FiasContentError extends Error {
|
|
357
|
+
readonly code: FiasContentErrorCode;
|
|
358
|
+
readonly path?: string | undefined;
|
|
359
|
+
constructor(message: string, code: FiasContentErrorCode, path?: string | undefined);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Read this plugin's own content pack — the reviewed `content/` directory it
|
|
363
|
+
* was published with (lessons, data, images, audio, fonts).
|
|
364
|
+
*
|
|
365
|
+
* The host page reads the pack from the Fias content CDN, verifies every file
|
|
366
|
+
* against its hash, and caches it; nothing here touches the network, and a
|
|
367
|
+
* plugin can only read its own pack. Reads are free for your users; the
|
|
368
|
+
* contributor pays the pack's storage and bandwidth, and cached repeat reads
|
|
369
|
+
* cost nothing.
|
|
370
|
+
*
|
|
371
|
+
* Paths are relative to `content/`. In the Arche Builder and developer
|
|
372
|
+
* previews there is no published pack: calls fail with
|
|
373
|
+
* `CONTENT_UNAVAILABLE_IN_PREVIEW` (the dev harness serves your local
|
|
374
|
+
* `content/` instead).
|
|
375
|
+
*
|
|
376
|
+
* Permission: `entities:client_invoke`.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* const content = useFiasContent();
|
|
380
|
+
* const lessons = await content.list('lessons/');
|
|
381
|
+
* const markdown = await content.getText(lessons[0].path);
|
|
382
|
+
* const cover = await content.getObjectUrl('img/cover.webp'); // <img src={cover}>
|
|
383
|
+
*/
|
|
384
|
+
export declare function useFiasContent(): FiasContentApi;
|
|
345
385
|
/**
|
|
346
386
|
* Preserve transient UI state across a builder-preview rebuild.
|
|
347
387
|
*
|
|
@@ -463,6 +503,13 @@ export interface VaultUserDocumentsApi {
|
|
|
463
503
|
* `:read`, and every method of this hook (this one included) is gated
|
|
464
504
|
* on `:read`. */
|
|
465
505
|
access?: 'read' | 'write';
|
|
506
|
+
/**
|
|
507
|
+
* The types you can open: MIME types (`'application/pdf'`), MIME
|
|
508
|
+
* families (`'image/*'`) or extensions (`'.docx'`), up to 20. The host
|
|
509
|
+
* offers matching files; the user can still reveal the rest, shown
|
|
510
|
+
* disabled. Omitted: every type.
|
|
511
|
+
*/
|
|
512
|
+
accept?: readonly string[];
|
|
466
513
|
}): Promise<VaultUserDocumentPickResult>;
|
|
467
514
|
/**
|
|
468
515
|
* Ask the user to let you EDIT a document you can already open. The host
|
|
@@ -499,7 +546,7 @@ export interface VaultUserDocumentsApi {
|
|
|
499
546
|
*
|
|
500
547
|
* Rejects `EDIT_ACCESS_REQUIRED` when you hold view-only access (call
|
|
501
548
|
* `requestEditAccess`), and `DOCUMENT_NOT_FOUND` once the user removes your
|
|
502
|
-
* access in Vault →
|
|
549
|
+
* access in Vault → Arche Access — which takes effect on your very next save.
|
|
503
550
|
* Handle both. Debounce (a few seconds idle, plus blur and close) and
|
|
504
551
|
* surface `RATE_LIMIT` rather than looping: this lane allows fewer saves per
|
|
505
552
|
* minute than your own documents do. Every save is recorded with your app's
|
|
@@ -515,7 +562,7 @@ export interface VaultUserDocumentsApi {
|
|
|
515
562
|
* Read one granted document. `includeContent: true` returns UTF-8 text
|
|
516
563
|
* for text documents (a binary document rejects with BINARY_DOCUMENT —
|
|
517
564
|
* use getDownloadUrl for those). Rejects with DOCUMENT_NOT_FOUND once
|
|
518
|
-
* the user revokes access in Vault →
|
|
565
|
+
* the user revokes access in Vault → Arche Access — handle that path.
|
|
519
566
|
*/
|
|
520
567
|
get(documentId: string, options?: {
|
|
521
568
|
includeContent?: boolean;
|
|
@@ -541,7 +588,7 @@ export interface VaultUserDocumentsApi {
|
|
|
541
588
|
* the family, because it is the only one that can move megabytes: call
|
|
542
589
|
* sequentially and surface a RATE_LIMIT error to the user/assistant
|
|
543
590
|
* verbatim rather than retrying in a loop. Rejects with
|
|
544
|
-
* DOCUMENT_NOT_FOUND once the user revokes access in Vault →
|
|
591
|
+
* DOCUMENT_NOT_FOUND once the user revokes access in Vault → Arche Access
|
|
545
592
|
* — unlike a presigned URL from getDownloadUrl, which stays valid for
|
|
546
593
|
* its TTL, every getBytes call re-checks the grant.
|
|
547
594
|
*/
|
|
@@ -556,7 +603,7 @@ export interface VaultUserDocumentsApi {
|
|
|
556
603
|
* surface that reaches data your plugin did not create. Requires the
|
|
557
604
|
* `vault:user-documents:read` permission. Every access is user-consented
|
|
558
605
|
* (per-document grants created in the host picker, revocable any time in
|
|
559
|
-
* Vault →
|
|
606
|
+
* Vault → Arche Access) and audited by the platform.
|
|
560
607
|
*
|
|
561
608
|
* The picker offers the files of the workspace the user is acting in (the
|
|
562
609
|
* host's workspace switcher — Personal, or an org workspace they belong to)
|
|
@@ -631,7 +678,7 @@ export interface FiasAIActionsConfig extends FiasAIActionsDeclaration {
|
|
|
631
678
|
* You get a document REFERENCE, not bytes. Read it with
|
|
632
679
|
* `useVaultUserDocuments().getBytes(documentId)`: the host grants you that one
|
|
633
680
|
* document as it relays the handoff, so no `pick()` is needed first. The grant
|
|
634
|
-
* is per-document and revocable in Vault →
|
|
681
|
+
* is per-document and revocable in Vault → Arche Access exactly like a picked
|
|
635
682
|
* one, and it needs `vault:user-documents:read` — declare it, or the grant is
|
|
636
683
|
* refused and the file never arrives.
|
|
637
684
|
*
|
package/dist/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,mBAAmB,EACnB,QAAQ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D,kDAAkD;AAClD,MAAM,WAAW,mBAAoB,SAAQ,wBAAwB;IACnE;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,IAAI,CAYvF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG;IACpE,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CA0DA"}
|
package/dist/hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRAMMAR_CHECK_ENTITY_ID = exports.NLLB_LANGUAGES = exports.NLLB_TRANSLATION_ENTITY_ID = void 0;
|
|
3
|
+
exports.FiasContentError = exports.PLUGIN_CONTENT_ENTITY_ID = exports.GRAMMAR_CHECK_ENTITY_ID = exports.NLLB_LANGUAGES = exports.NLLB_TRANSLATION_ENTITY_ID = void 0;
|
|
4
4
|
exports.useFiasUser = useFiasUser;
|
|
5
5
|
exports.useFiasTheme = useFiasTheme;
|
|
6
6
|
exports.useFiasVendoredAssets = useFiasVendoredAssets;
|
|
@@ -20,6 +20,7 @@ exports.useFiasStore = useFiasStore;
|
|
|
20
20
|
exports.fetchVaultDocumentDownloadUrl = fetchVaultDocumentDownloadUrl;
|
|
21
21
|
exports.useVaultDocuments = useVaultDocuments;
|
|
22
22
|
exports.useArcheAssets = useArcheAssets;
|
|
23
|
+
exports.useFiasContent = useFiasContent;
|
|
23
24
|
exports.useFiasPreviewState = useFiasPreviewState;
|
|
24
25
|
exports.useDataSubscription = useDataSubscription;
|
|
25
26
|
exports.useVaultUserDocuments = useVaultUserDocuments;
|
|
@@ -1179,18 +1180,6 @@ function useVaultDocuments() {
|
|
|
1179
1180
|
// drop any cached URL for this document.
|
|
1180
1181
|
downloadUrlCache.delete(documentId);
|
|
1181
1182
|
}, [bridge]);
|
|
1182
|
-
const promoteToUserFiles = (0, react_1.useCallback)(async (documentId) => {
|
|
1183
|
-
// Rides the existing update op with a host-only flag. The HOST
|
|
1184
|
-
// intercepts it, shows the user its own confirmation, and performs the
|
|
1185
|
-
// promote from the user's session — nothing here (or anywhere in the
|
|
1186
|
-
// iframe) can promote a file without the user agreeing.
|
|
1187
|
-
const res = await bridge.request('vault_documents_update', {
|
|
1188
|
-
documentId,
|
|
1189
|
-
userVisible: true,
|
|
1190
|
-
});
|
|
1191
|
-
downloadUrlCache.delete(documentId);
|
|
1192
|
-
return res;
|
|
1193
|
-
}, [bridge]);
|
|
1194
1183
|
const deleteDocument = (0, react_1.useCallback)(async (documentId) => {
|
|
1195
1184
|
await bridge.request('vault_documents_delete', { documentId });
|
|
1196
1185
|
downloadUrlCache.delete(documentId);
|
|
@@ -1215,9 +1204,9 @@ function useVaultDocuments() {
|
|
|
1215
1204
|
await bridge.request('vault_documents_detach', { documentId, referenceId });
|
|
1216
1205
|
}, [bridge]);
|
|
1217
1206
|
const uploadInit = (0, react_1.useCallback)(async (params) => {
|
|
1218
|
-
// No
|
|
1219
|
-
// host's
|
|
1220
|
-
// whole upload. The host REJECTS a `visibility`
|
|
1207
|
+
// No destination here by construction: a save into the user's
|
|
1208
|
+
// Documents needs the host's Save dialog, which it can only show when it
|
|
1209
|
+
// orchestrates the whole upload. The host REJECTS a `visibility` here.
|
|
1221
1210
|
return bridge.request('vault_documents_upload_init', {
|
|
1222
1211
|
name: params.name,
|
|
1223
1212
|
mimeType: params.mimeType,
|
|
@@ -1252,13 +1241,22 @@ function useVaultDocuments() {
|
|
|
1252
1241
|
sensitivity: params.sensitivity,
|
|
1253
1242
|
folderPath: params.folderPath,
|
|
1254
1243
|
replacesDocumentId: params.replacesDocumentId,
|
|
1255
|
-
//
|
|
1256
|
-
//
|
|
1257
|
-
//
|
|
1258
|
-
//
|
|
1244
|
+
// A save into the user's Documents. The host turns this into its Save
|
|
1245
|
+
// dialog, which the iframe cannot see or script, and performs the
|
|
1246
|
+
// write itself from the user's session. Omitted (the common case)
|
|
1247
|
+
// keeps the arche-private default.
|
|
1248
|
+
destination: params.destination,
|
|
1259
1249
|
userVisible: params.userVisible,
|
|
1260
1250
|
});
|
|
1261
1251
|
}, [bridge]);
|
|
1252
|
+
const saveCopy = (0, react_1.useCallback)(async (documentId, options) => {
|
|
1253
|
+
// Rides the update op, intercepted by the host: it reads the bytes and
|
|
1254
|
+
// shows the Save dialog. Never forwarded — the original is unchanged.
|
|
1255
|
+
return bridge.request('vault_documents_update', {
|
|
1256
|
+
documentId,
|
|
1257
|
+
saveCopy: { ...(options?.suggestedName ? { suggestedName: options.suggestedName } : {}) },
|
|
1258
|
+
});
|
|
1259
|
+
}, [bridge]);
|
|
1262
1260
|
return (0, react_1.useMemo)(() => ({
|
|
1263
1261
|
list,
|
|
1264
1262
|
read,
|
|
@@ -1267,12 +1265,12 @@ function useVaultDocuments() {
|
|
|
1267
1265
|
getDownloadUrl,
|
|
1268
1266
|
write,
|
|
1269
1267
|
update,
|
|
1270
|
-
promoteToUserFiles,
|
|
1271
1268
|
delete: deleteDocument,
|
|
1272
1269
|
search,
|
|
1273
1270
|
attach,
|
|
1274
1271
|
detach,
|
|
1275
1272
|
upload,
|
|
1273
|
+
saveCopy,
|
|
1276
1274
|
uploadInit,
|
|
1277
1275
|
uploadFinalize,
|
|
1278
1276
|
}), [
|
|
@@ -1283,12 +1281,12 @@ function useVaultDocuments() {
|
|
|
1283
1281
|
getDownloadUrl,
|
|
1284
1282
|
write,
|
|
1285
1283
|
update,
|
|
1286
|
-
promoteToUserFiles,
|
|
1287
1284
|
deleteDocument,
|
|
1288
1285
|
search,
|
|
1289
1286
|
attach,
|
|
1290
1287
|
detach,
|
|
1291
1288
|
upload,
|
|
1289
|
+
saveCopy,
|
|
1292
1290
|
uploadInit,
|
|
1293
1291
|
uploadFinalize,
|
|
1294
1292
|
]);
|
|
@@ -1425,6 +1423,134 @@ function useArcheAssets() {
|
|
|
1425
1423
|
}, [bridge]);
|
|
1426
1424
|
return (0, react_1.useMemo)(() => ({ list, index, getUrl }), [list, index, getUrl]);
|
|
1427
1425
|
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Entity ID of the plugin content pack client-side entity (ADR-021) — the
|
|
1428
|
+
* host-side reader behind {@link useFiasContent}. Literal here so the SDK
|
|
1429
|
+
* stays bundle-clean (no `@fias/entities` runtime dep).
|
|
1430
|
+
*
|
|
1431
|
+
* SYNC NOTE: must match `PLUGIN_CONTENT_ENTITY_ID` in
|
|
1432
|
+
* `packages/entities/src/integrations/plugin-content/config.ts`. The
|
|
1433
|
+
* architecture test `sdk-entity-id-constants-match.test.ts` pins this.
|
|
1434
|
+
*/
|
|
1435
|
+
exports.PLUGIN_CONTENT_ENTITY_ID = 'ent_intg_plugin_content_00000000';
|
|
1436
|
+
/** A failed content read: `code` says why, `path` names the file when there is one. */
|
|
1437
|
+
class FiasContentError extends Error {
|
|
1438
|
+
constructor(message, code, path) {
|
|
1439
|
+
super(message);
|
|
1440
|
+
this.code = code;
|
|
1441
|
+
this.path = path;
|
|
1442
|
+
this.name = 'FiasContentError';
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
exports.FiasContentError = FiasContentError;
|
|
1446
|
+
function toContentError(err) {
|
|
1447
|
+
if (err instanceof FiasContentError)
|
|
1448
|
+
return err;
|
|
1449
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1450
|
+
const code = err?.code;
|
|
1451
|
+
if (/permission denied/i.test(message))
|
|
1452
|
+
return new FiasContentError(message, 'PERMISSION_DENIED');
|
|
1453
|
+
if (code === 'RATE_LIMITED' || /rate limit/i.test(message)) {
|
|
1454
|
+
return new FiasContentError(message, 'RATE_LIMIT');
|
|
1455
|
+
}
|
|
1456
|
+
return new FiasContentError(message, 'CONTENT_UNAVAILABLE');
|
|
1457
|
+
}
|
|
1458
|
+
function fileResult(results, path) {
|
|
1459
|
+
const result = results?.[path];
|
|
1460
|
+
if (!result) {
|
|
1461
|
+
throw new FiasContentError(`No result for content/${path}`, 'CONTENT_UNAVAILABLE', path);
|
|
1462
|
+
}
|
|
1463
|
+
if ('error' in result)
|
|
1464
|
+
throw new FiasContentError(result.error.message, result.error.code, path);
|
|
1465
|
+
return result;
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* `blob:` URLs built in this iframe, per path. A published pack is immutable,
|
|
1469
|
+
* so one URL per path serves the plugin for its whole life.
|
|
1470
|
+
*/
|
|
1471
|
+
const contentObjectUrls = new Map();
|
|
1472
|
+
/**
|
|
1473
|
+
* Read this plugin's own content pack — the reviewed `content/` directory it
|
|
1474
|
+
* was published with (lessons, data, images, audio, fonts).
|
|
1475
|
+
*
|
|
1476
|
+
* The host page reads the pack from the Fias content CDN, verifies every file
|
|
1477
|
+
* against its hash, and caches it; nothing here touches the network, and a
|
|
1478
|
+
* plugin can only read its own pack. Reads are free for your users; the
|
|
1479
|
+
* contributor pays the pack's storage and bandwidth, and cached repeat reads
|
|
1480
|
+
* cost nothing.
|
|
1481
|
+
*
|
|
1482
|
+
* Paths are relative to `content/`. In the Arche Builder and developer
|
|
1483
|
+
* previews there is no published pack: calls fail with
|
|
1484
|
+
* `CONTENT_UNAVAILABLE_IN_PREVIEW` (the dev harness serves your local
|
|
1485
|
+
* `content/` instead).
|
|
1486
|
+
*
|
|
1487
|
+
* Permission: `entities:client_invoke`.
|
|
1488
|
+
*
|
|
1489
|
+
* @example
|
|
1490
|
+
* const content = useFiasContent();
|
|
1491
|
+
* const lessons = await content.list('lessons/');
|
|
1492
|
+
* const markdown = await content.getText(lessons[0].path);
|
|
1493
|
+
* const cover = await content.getObjectUrl('img/cover.webp'); // <img src={cover}>
|
|
1494
|
+
*/
|
|
1495
|
+
function useFiasContent() {
|
|
1496
|
+
const bridge = useBridge();
|
|
1497
|
+
const call = (0, react_1.useCallback)(async (input) => {
|
|
1498
|
+
let response;
|
|
1499
|
+
try {
|
|
1500
|
+
response = await bridge.request('client_entity_invoke', { entityId: exports.PLUGIN_CONTENT_ENTITY_ID, input }, CLIENT_ENTITY_INVOKE_TIMEOUT_MS);
|
|
1501
|
+
}
|
|
1502
|
+
catch (err) {
|
|
1503
|
+
throw toContentError(err);
|
|
1504
|
+
}
|
|
1505
|
+
if (response?.error) {
|
|
1506
|
+
throw new FiasContentError(response.error.message, response.error.code);
|
|
1507
|
+
}
|
|
1508
|
+
return response ?? {};
|
|
1509
|
+
}, [bridge]);
|
|
1510
|
+
const list = (0, react_1.useCallback)(async (prefix) => (await call({ verb: 'list', ...(prefix !== undefined ? { prefix } : {}) })).files ?? [], [call]);
|
|
1511
|
+
const getText = (0, react_1.useCallback)(async (path) => {
|
|
1512
|
+
const { results } = await call({ verb: 'read', paths: [path], as: 'text' });
|
|
1513
|
+
return fileResult(results, path).text;
|
|
1514
|
+
}, [call]);
|
|
1515
|
+
const getJson = (0, react_1.useCallback)(async (path) => JSON.parse(await getText(path)), [getText]);
|
|
1516
|
+
const readBytes = (0, react_1.useCallback)(async (path) => {
|
|
1517
|
+
const { results } = await call({ verb: 'read', paths: [path], as: 'bytes' });
|
|
1518
|
+
return fileResult(results, path);
|
|
1519
|
+
}, [call]);
|
|
1520
|
+
const getBytes = (0, react_1.useCallback)(async (path) => (await readBytes(path)).bytes, [readBytes]);
|
|
1521
|
+
const getMany = (0, react_1.useCallback)(async (paths, as) => {
|
|
1522
|
+
const { results } = await call({ verb: 'read', paths, as });
|
|
1523
|
+
const out = {};
|
|
1524
|
+
for (const path of paths) {
|
|
1525
|
+
try {
|
|
1526
|
+
const result = fileResult(results, path);
|
|
1527
|
+
out[path] =
|
|
1528
|
+
as === 'text'
|
|
1529
|
+
? result.text
|
|
1530
|
+
: result.bytes;
|
|
1531
|
+
}
|
|
1532
|
+
catch (err) {
|
|
1533
|
+
out[path] = toContentError(err);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
return out;
|
|
1537
|
+
}, [call]);
|
|
1538
|
+
const getObjectUrl = (0, react_1.useCallback)(async (path) => {
|
|
1539
|
+
const cached = contentObjectUrls.get(path);
|
|
1540
|
+
if (cached)
|
|
1541
|
+
return cached;
|
|
1542
|
+
const pending = readBytes(path).then(({ bytes, mimeType }) => URL.createObjectURL(new Blob([bytes], { type: mimeType })));
|
|
1543
|
+
contentObjectUrls.set(path, pending);
|
|
1544
|
+
pending.catch(() => contentObjectUrls.delete(path));
|
|
1545
|
+
return pending;
|
|
1546
|
+
}, [readBytes]);
|
|
1547
|
+
const getUrl = (0, react_1.useCallback)(async (path) => {
|
|
1548
|
+
const { results } = await call({ verb: 'url', paths: [path] });
|
|
1549
|
+
const { url, expiresAt } = fileResult(results, path);
|
|
1550
|
+
return { url, expiresAt };
|
|
1551
|
+
}, [call]);
|
|
1552
|
+
return (0, react_1.useMemo)(() => ({ list, getText, getJson, getBytes, getMany, getObjectUrl, getUrl }), [list, getText, getJson, getBytes, getMany, getObjectUrl, getUrl]);
|
|
1553
|
+
}
|
|
1428
1554
|
/**
|
|
1429
1555
|
* Preserve transient UI state across a builder-preview rebuild.
|
|
1430
1556
|
*
|
|
@@ -1581,7 +1707,7 @@ function useDataSubscription(collection, onInvalidate, options) {
|
|
|
1581
1707
|
* surface that reaches data your plugin did not create. Requires the
|
|
1582
1708
|
* `vault:user-documents:read` permission. Every access is user-consented
|
|
1583
1709
|
* (per-document grants created in the host picker, revocable any time in
|
|
1584
|
-
* Vault →
|
|
1710
|
+
* Vault → Arche Access) and audited by the platform.
|
|
1585
1711
|
*
|
|
1586
1712
|
* The picker offers the files of the workspace the user is acting in (the
|
|
1587
1713
|
* host's workspace switcher — Personal, or an org workspace they belong to)
|
|
@@ -1599,6 +1725,7 @@ function useVaultUserDocuments() {
|
|
|
1599
1725
|
return bridge.request('vault_documents_pick', {
|
|
1600
1726
|
maxDocuments: options?.maxDocuments,
|
|
1601
1727
|
access: options?.access,
|
|
1728
|
+
...(options?.accept ? { accept: [...options.accept] } : {}),
|
|
1602
1729
|
});
|
|
1603
1730
|
}, [bridge]);
|
|
1604
1731
|
const requestEditAccess = (0, react_1.useCallback)(async (documentId) => {
|
|
@@ -1862,7 +1989,7 @@ function useCommunityAssets() {
|
|
|
1862
1989
|
* You get a document REFERENCE, not bytes. Read it with
|
|
1863
1990
|
* `useVaultUserDocuments().getBytes(documentId)`: the host grants you that one
|
|
1864
1991
|
* document as it relays the handoff, so no `pick()` is needed first. The grant
|
|
1865
|
-
* is per-document and revocable in Vault →
|
|
1992
|
+
* is per-document and revocable in Vault → Arche Access exactly like a picked
|
|
1866
1993
|
* one, and it needs `vault:user-documents:read` — declare it, or the grant is
|
|
1867
1994
|
* refused and the file never arrives.
|
|
1868
1995
|
*
|