@fias/arche-sdk 2.19.2 → 2.21.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/entity-ops.d.ts +7 -1
- package/dist/entity-ops.d.ts.map +1 -1
- package/dist/entity-ops.js +7 -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 +17 -13
- package/dist/generated/permissions.js.map +1 -1
- package/dist/hooks.d.ts +156 -6
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +192 -24
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.test.js +202 -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 +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +184 -31
- package/dist/types.d.ts +193 -72
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/templates/default/AGENTS.md +177 -28
- package/templates/default/CLAUDE.md +177 -28
package/dist/index.mjs
CHANGED
|
@@ -876,6 +876,7 @@ var PLUGIN_STORE_ENTITY_ID = "ent_intg_plugin_store_0000000000";
|
|
|
876
876
|
var VAULT_USER_DOCUMENTS_ENTITY_ID = "ent_intg_vault_documents_0000000";
|
|
877
877
|
var VAULT_ARCHE_DOCUMENTS_ENTITY_ID = "ent_intg_vault_arche_docs_000000";
|
|
878
878
|
var COMMUNITY_ASSETS_ENTITY_ID = "ent_intg_community_assets_000000";
|
|
879
|
+
var DOCUMENT_SIGN_ENTITY_ID = "ent_intg_document_sign_000000000";
|
|
879
880
|
var COMMUNITY_ASSET_MAX_URL_BATCH = 50;
|
|
880
881
|
var COMMUNITY_ASSET_MAX_PUBLISH_BATCH = 20;
|
|
881
882
|
async function invokeEntityOp(bridge, entityId, op, args = {}) {
|
|
@@ -1840,17 +1841,6 @@ function useVaultDocuments() {
|
|
|
1840
1841
|
},
|
|
1841
1842
|
[bridge]
|
|
1842
1843
|
);
|
|
1843
|
-
const promoteToUserFiles = useCallback(
|
|
1844
|
-
async (documentId) => {
|
|
1845
|
-
const res = await bridge.request("vault_documents_update", {
|
|
1846
|
-
documentId,
|
|
1847
|
-
userVisible: true
|
|
1848
|
-
});
|
|
1849
|
-
downloadUrlCache.delete(documentId);
|
|
1850
|
-
return res;
|
|
1851
|
-
},
|
|
1852
|
-
[bridge]
|
|
1853
|
-
);
|
|
1854
1844
|
const deleteDocument = useCallback(
|
|
1855
1845
|
async (documentId) => {
|
|
1856
1846
|
await bridge.request("vault_documents_delete", { documentId });
|
|
@@ -1921,15 +1911,25 @@ function useVaultDocuments() {
|
|
|
1921
1911
|
sensitivity: params.sensitivity,
|
|
1922
1912
|
folderPath: params.folderPath,
|
|
1923
1913
|
replacesDocumentId: params.replacesDocumentId,
|
|
1924
|
-
//
|
|
1925
|
-
//
|
|
1926
|
-
//
|
|
1927
|
-
//
|
|
1914
|
+
// A save into the user's Documents. The host turns this into its Save
|
|
1915
|
+
// dialog, which the iframe cannot see or script, and performs the
|
|
1916
|
+
// write itself from the user's session. Omitted (the common case)
|
|
1917
|
+
// keeps the arche-private default.
|
|
1918
|
+
destination: params.destination,
|
|
1928
1919
|
userVisible: params.userVisible
|
|
1929
1920
|
});
|
|
1930
1921
|
},
|
|
1931
1922
|
[bridge]
|
|
1932
1923
|
);
|
|
1924
|
+
const saveCopy = useCallback(
|
|
1925
|
+
async (documentId, options) => {
|
|
1926
|
+
return bridge.request("vault_documents_update", {
|
|
1927
|
+
documentId,
|
|
1928
|
+
saveCopy: { ...options?.suggestedName ? { suggestedName: options.suggestedName } : {} }
|
|
1929
|
+
});
|
|
1930
|
+
},
|
|
1931
|
+
[bridge]
|
|
1932
|
+
);
|
|
1933
1933
|
return useMemo2(
|
|
1934
1934
|
() => ({
|
|
1935
1935
|
list,
|
|
@@ -1939,12 +1939,12 @@ function useVaultDocuments() {
|
|
|
1939
1939
|
getDownloadUrl,
|
|
1940
1940
|
write,
|
|
1941
1941
|
update,
|
|
1942
|
-
promoteToUserFiles,
|
|
1943
1942
|
delete: deleteDocument,
|
|
1944
1943
|
search,
|
|
1945
1944
|
attach,
|
|
1946
1945
|
detach,
|
|
1947
1946
|
upload,
|
|
1947
|
+
saveCopy,
|
|
1948
1948
|
uploadInit,
|
|
1949
1949
|
uploadFinalize
|
|
1950
1950
|
}),
|
|
@@ -1956,12 +1956,12 @@ function useVaultDocuments() {
|
|
|
1956
1956
|
getDownloadUrl,
|
|
1957
1957
|
write,
|
|
1958
1958
|
update,
|
|
1959
|
-
promoteToUserFiles,
|
|
1960
1959
|
deleteDocument,
|
|
1961
1960
|
search,
|
|
1962
1961
|
attach,
|
|
1963
1962
|
detach,
|
|
1964
1963
|
upload,
|
|
1964
|
+
saveCopy,
|
|
1965
1965
|
uploadInit,
|
|
1966
1966
|
uploadFinalize
|
|
1967
1967
|
]
|
|
@@ -2043,6 +2043,123 @@ function useArcheAssets() {
|
|
|
2043
2043
|
);
|
|
2044
2044
|
return useMemo2(() => ({ list, index, getUrl }), [list, index, getUrl]);
|
|
2045
2045
|
}
|
|
2046
|
+
var PLUGIN_CONTENT_ENTITY_ID = "ent_intg_plugin_content_00000000";
|
|
2047
|
+
var FiasContentError = class extends Error {
|
|
2048
|
+
constructor(message, code, path) {
|
|
2049
|
+
super(message);
|
|
2050
|
+
this.code = code;
|
|
2051
|
+
this.path = path;
|
|
2052
|
+
this.name = "FiasContentError";
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
function toContentError(err) {
|
|
2056
|
+
if (err instanceof FiasContentError) return err;
|
|
2057
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2058
|
+
const code = err?.code;
|
|
2059
|
+
if (/permission denied/i.test(message)) return new FiasContentError(message, "PERMISSION_DENIED");
|
|
2060
|
+
if (code === "RATE_LIMITED" || /rate limit/i.test(message)) {
|
|
2061
|
+
return new FiasContentError(message, "RATE_LIMIT");
|
|
2062
|
+
}
|
|
2063
|
+
return new FiasContentError(message, "CONTENT_UNAVAILABLE");
|
|
2064
|
+
}
|
|
2065
|
+
function fileResult(results, path) {
|
|
2066
|
+
const result = results?.[path];
|
|
2067
|
+
if (!result) {
|
|
2068
|
+
throw new FiasContentError(`No result for content/${path}`, "CONTENT_UNAVAILABLE", path);
|
|
2069
|
+
}
|
|
2070
|
+
if ("error" in result) throw new FiasContentError(result.error.message, result.error.code, path);
|
|
2071
|
+
return result;
|
|
2072
|
+
}
|
|
2073
|
+
var contentObjectUrls = /* @__PURE__ */ new Map();
|
|
2074
|
+
function useFiasContent() {
|
|
2075
|
+
const bridge = useBridge();
|
|
2076
|
+
const call = useCallback(
|
|
2077
|
+
async (input) => {
|
|
2078
|
+
let response;
|
|
2079
|
+
try {
|
|
2080
|
+
response = await bridge.request(
|
|
2081
|
+
"client_entity_invoke",
|
|
2082
|
+
{ entityId: PLUGIN_CONTENT_ENTITY_ID, input },
|
|
2083
|
+
CLIENT_ENTITY_INVOKE_TIMEOUT_MS
|
|
2084
|
+
);
|
|
2085
|
+
} catch (err) {
|
|
2086
|
+
throw toContentError(err);
|
|
2087
|
+
}
|
|
2088
|
+
if (response?.error) {
|
|
2089
|
+
throw new FiasContentError(response.error.message, response.error.code);
|
|
2090
|
+
}
|
|
2091
|
+
return response ?? {};
|
|
2092
|
+
},
|
|
2093
|
+
[bridge]
|
|
2094
|
+
);
|
|
2095
|
+
const list = useCallback(
|
|
2096
|
+
async (prefix) => (await call({ verb: "list", ...prefix !== void 0 ? { prefix } : {} })).files ?? [],
|
|
2097
|
+
[call]
|
|
2098
|
+
);
|
|
2099
|
+
const getText = useCallback(
|
|
2100
|
+
async (path) => {
|
|
2101
|
+
const { results } = await call({ verb: "read", paths: [path], as: "text" });
|
|
2102
|
+
return fileResult(results, path).text;
|
|
2103
|
+
},
|
|
2104
|
+
[call]
|
|
2105
|
+
);
|
|
2106
|
+
const getJson = useCallback(
|
|
2107
|
+
async (path) => JSON.parse(await getText(path)),
|
|
2108
|
+
[getText]
|
|
2109
|
+
);
|
|
2110
|
+
const readBytes = useCallback(
|
|
2111
|
+
async (path) => {
|
|
2112
|
+
const { results } = await call({ verb: "read", paths: [path], as: "bytes" });
|
|
2113
|
+
return fileResult(results, path);
|
|
2114
|
+
},
|
|
2115
|
+
[call]
|
|
2116
|
+
);
|
|
2117
|
+
const getBytes = useCallback(
|
|
2118
|
+
async (path) => (await readBytes(path)).bytes,
|
|
2119
|
+
[readBytes]
|
|
2120
|
+
);
|
|
2121
|
+
const getMany = useCallback(
|
|
2122
|
+
async (paths, as) => {
|
|
2123
|
+
const { results } = await call({ verb: "read", paths, as });
|
|
2124
|
+
const out = {};
|
|
2125
|
+
for (const path of paths) {
|
|
2126
|
+
try {
|
|
2127
|
+
const result = fileResult(results, path);
|
|
2128
|
+
out[path] = as === "text" ? result.text : result.bytes;
|
|
2129
|
+
} catch (err) {
|
|
2130
|
+
out[path] = toContentError(err);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
return out;
|
|
2134
|
+
},
|
|
2135
|
+
[call]
|
|
2136
|
+
);
|
|
2137
|
+
const getObjectUrl = useCallback(
|
|
2138
|
+
async (path) => {
|
|
2139
|
+
const cached = contentObjectUrls.get(path);
|
|
2140
|
+
if (cached) return cached;
|
|
2141
|
+
const pending = readBytes(path).then(
|
|
2142
|
+
({ bytes, mimeType }) => URL.createObjectURL(new Blob([bytes], { type: mimeType }))
|
|
2143
|
+
);
|
|
2144
|
+
contentObjectUrls.set(path, pending);
|
|
2145
|
+
pending.catch(() => contentObjectUrls.delete(path));
|
|
2146
|
+
return pending;
|
|
2147
|
+
},
|
|
2148
|
+
[readBytes]
|
|
2149
|
+
);
|
|
2150
|
+
const getUrl = useCallback(
|
|
2151
|
+
async (path) => {
|
|
2152
|
+
const { results } = await call({ verb: "url", paths: [path] });
|
|
2153
|
+
const { url, expiresAt } = fileResult(results, path);
|
|
2154
|
+
return { url, expiresAt };
|
|
2155
|
+
},
|
|
2156
|
+
[call]
|
|
2157
|
+
);
|
|
2158
|
+
return useMemo2(
|
|
2159
|
+
() => ({ list, getText, getJson, getBytes, getMany, getObjectUrl, getUrl }),
|
|
2160
|
+
[list, getText, getJson, getBytes, getMany, getObjectUrl, getUrl]
|
|
2161
|
+
);
|
|
2162
|
+
}
|
|
2046
2163
|
function useFiasPreviewState(key, getState, onRestore) {
|
|
2047
2164
|
const bridge = useBridge();
|
|
2048
2165
|
const getStateRef = useRef(getState);
|
|
@@ -2133,7 +2250,8 @@ function useVaultUserDocuments() {
|
|
|
2133
2250
|
async (options) => {
|
|
2134
2251
|
return bridge.request("vault_documents_pick", {
|
|
2135
2252
|
maxDocuments: options?.maxDocuments,
|
|
2136
|
-
access: options?.access
|
|
2253
|
+
access: options?.access,
|
|
2254
|
+
...options?.accept ? { accept: [...options.accept] } : {}
|
|
2137
2255
|
});
|
|
2138
2256
|
},
|
|
2139
2257
|
[bridge]
|
|
@@ -2406,6 +2524,33 @@ function useArcheHandoff(onHandoff) {
|
|
|
2406
2524
|
return () => bridge.clearHandoffHandler(handler);
|
|
2407
2525
|
}, [bridge]);
|
|
2408
2526
|
}
|
|
2527
|
+
function useDocumentSign() {
|
|
2528
|
+
const bridge = useBridge();
|
|
2529
|
+
const getEnvelope = useCallback(
|
|
2530
|
+
async (envelopeId) => {
|
|
2531
|
+
const res = await invokeEntityOp(
|
|
2532
|
+
bridge,
|
|
2533
|
+
DOCUMENT_SIGN_ENTITY_ID,
|
|
2534
|
+
"get_consented_envelope",
|
|
2535
|
+
{ envelopeId }
|
|
2536
|
+
);
|
|
2537
|
+
return res.envelope;
|
|
2538
|
+
},
|
|
2539
|
+
[bridge]
|
|
2540
|
+
);
|
|
2541
|
+
const listEvents = useCallback(
|
|
2542
|
+
async (envelopeId, options) => {
|
|
2543
|
+
return invokeEntityOp(
|
|
2544
|
+
bridge,
|
|
2545
|
+
DOCUMENT_SIGN_ENTITY_ID,
|
|
2546
|
+
"list_consented_envelope_events",
|
|
2547
|
+
{ envelopeId, limit: options?.limit, offset: options?.offset }
|
|
2548
|
+
);
|
|
2549
|
+
},
|
|
2550
|
+
[bridge]
|
|
2551
|
+
);
|
|
2552
|
+
return useMemo2(() => ({ getEnvelope, listEvents }), [getEnvelope, listEvents]);
|
|
2553
|
+
}
|
|
2409
2554
|
function useFiasAIActions(config) {
|
|
2410
2555
|
const bridge = useBridge();
|
|
2411
2556
|
const onActionRef = useRef(config?.onAction ?? null);
|
|
@@ -2524,6 +2669,7 @@ var VALID_PLUGIN_PERMISSIONS = [
|
|
|
2524
2669
|
"data:search",
|
|
2525
2670
|
"data:store",
|
|
2526
2671
|
"data:workspace",
|
|
2672
|
+
"docsign:envelopes:read",
|
|
2527
2673
|
"entities:audio_generate",
|
|
2528
2674
|
"entities:client_invoke",
|
|
2529
2675
|
"entities:image_edit",
|
|
@@ -2536,6 +2682,7 @@ var VALID_PLUGIN_PERMISSIONS = [
|
|
|
2536
2682
|
"store:purchase",
|
|
2537
2683
|
"theme:read",
|
|
2538
2684
|
"user:profile:read",
|
|
2685
|
+
"vault:arche-saves:write",
|
|
2539
2686
|
"vault:documents:read",
|
|
2540
2687
|
"vault:documents:write",
|
|
2541
2688
|
"vault:user-documents:edit",
|
|
@@ -2546,13 +2693,14 @@ function isValidPluginPermission(perm) {
|
|
|
2546
2693
|
return VALID_PLUGIN_PERMISSIONS.includes(perm);
|
|
2547
2694
|
}
|
|
2548
2695
|
var PLUGIN_PERMISSION_DESCRIPTIONS = {
|
|
2549
|
-
"ai:actions": "Let Fias AI operate this
|
|
2550
|
-
"assets:community:publish": "Share images you made here so other people using this
|
|
2551
|
-
"assets:community:read": "Show you images that other people using this
|
|
2552
|
-
"assets:read": "Show images from this
|
|
2553
|
-
"data:search": "Search this
|
|
2554
|
-
"data:store": "Save structured data in this
|
|
2696
|
+
"ai:actions": "Let Fias AI operate this arche for you \u2014 only actions you could do yourself in its interface, and risky ones ask you first.",
|
|
2697
|
+
"assets:community:publish": "Share images you made here so other people using this arche can see them, and manage what you have shared.",
|
|
2698
|
+
"assets:community:read": "Show you images that other people using this arche have shared. Everything shared is checked before anyone can see it.",
|
|
2699
|
+
"assets:read": "Show images from this arche's published asset library.",
|
|
2700
|
+
"data:search": "Search this arche's own data semantically \u2014 costs credits per search.",
|
|
2701
|
+
"data:store": "Save structured data in this arche's own private database.",
|
|
2555
2702
|
"data:workspace": "Create team workspaces and manage their members.",
|
|
2703
|
+
"docsign:envelopes:read": "Check on signature requests it started for you \u2014 who has signed, and what is still outstanding.",
|
|
2556
2704
|
"entities:audio_generate": "Generate audio with platform AI \u2014 costs credits.",
|
|
2557
2705
|
"entities:client_invoke": "Use free on-device tools (grammar check, translation) in your browser.",
|
|
2558
2706
|
"entities:image_edit": "Edit images with platform AI \u2014 costs credits.",
|
|
@@ -2561,15 +2709,16 @@ var PLUGIN_PERMISSION_DESCRIPTIONS = {
|
|
|
2561
2709
|
"entities:web_search": "Search the live web on your behalf \u2014 costs credits.",
|
|
2562
2710
|
"navigation:open_arche": "Open other arches for you (navigation only).",
|
|
2563
2711
|
"sandbox:vendored-libraries": "Load platform-hosted libraries (like the PDF renderer) from the trusted CDN.",
|
|
2564
|
-
"storage:sandbox": "Save files in this
|
|
2565
|
-
"store:purchase": "Offer
|
|
2712
|
+
"storage:sandbox": "Save files in this arche's own private storage.",
|
|
2713
|
+
"store:purchase": "Offer purchases inside the arche (you approve each purchase).",
|
|
2566
2714
|
"theme:read": "Match your platform theme.",
|
|
2567
2715
|
"user:profile:read": "See your display name and avatar.",
|
|
2568
|
-
"vault:
|
|
2569
|
-
"vault:documents:
|
|
2570
|
-
"vault:
|
|
2571
|
-
"vault:user-documents:
|
|
2572
|
-
"vault:user-documents:
|
|
2716
|
+
"vault:arche-saves:write": "Saves files to your Arche Saves automatically.",
|
|
2717
|
+
"vault:documents:read": "Read files this arche itself created, in its own folders of your Vault.",
|
|
2718
|
+
"vault:documents:write": "Create and manage its own files, in its own folder of your Vault.",
|
|
2719
|
+
"vault:user-documents:edit": "Save changes to files of yours that you let it edit \u2014 you choose each file, earlier versions are kept unless you turned version history off, and you can remove access any time in Vault \u2192 Arche Access.",
|
|
2720
|
+
"vault:user-documents:read": "Read documents YOU choose to share with it from your Vault \u2014 you pick each document, and you can remove access any time in Vault \u2192 Arche Access.",
|
|
2721
|
+
"vault:user-documents:write": "Save its work to your Documents \u2014 you choose the folder and the name each time."
|
|
2573
2722
|
};
|
|
2574
2723
|
|
|
2575
2724
|
// src/fias.ts
|
|
@@ -5056,6 +5205,7 @@ export {
|
|
|
5056
5205
|
FONT_PAIRINGS,
|
|
5057
5206
|
FiasBridge,
|
|
5058
5207
|
FiasBridgeError,
|
|
5208
|
+
FiasContentError,
|
|
5059
5209
|
FiasProvider,
|
|
5060
5210
|
GRAMMAR_CHECK_ENTITY_ID,
|
|
5061
5211
|
IMAGE_SMART_CONTROL_SURFACE_KEY,
|
|
@@ -5088,6 +5238,7 @@ export {
|
|
|
5088
5238
|
PANEL_THEME_LENGTH_MAX_INTEGER_DIGITS,
|
|
5089
5239
|
PANEL_THEME_Z_MAX,
|
|
5090
5240
|
PANEL_TITLE_MAX_LENGTH,
|
|
5241
|
+
PLUGIN_CONTENT_ENTITY_ID,
|
|
5091
5242
|
PLUGIN_PERMISSION_DESCRIPTIONS,
|
|
5092
5243
|
SDK_BRIDGE_PROTOCOL_VERSION,
|
|
5093
5244
|
SDK_REQUIRES_HOST_PROTOCOL_VERSION,
|
|
@@ -5108,6 +5259,7 @@ export {
|
|
|
5108
5259
|
useClientEntity,
|
|
5109
5260
|
useCommunityAssets,
|
|
5110
5261
|
useDataSubscription,
|
|
5262
|
+
useDocumentSign,
|
|
5111
5263
|
useElevenLabsAudioIsolation,
|
|
5112
5264
|
useElevenLabsForcedAlignment,
|
|
5113
5265
|
useElevenLabsMusic,
|
|
@@ -5118,6 +5270,7 @@ export {
|
|
|
5118
5270
|
useElevenLabsVoiceDesign,
|
|
5119
5271
|
useEntityInvocation,
|
|
5120
5272
|
useFiasAIActions,
|
|
5273
|
+
useFiasContent,
|
|
5121
5274
|
useFiasDataStore,
|
|
5122
5275
|
useFiasFonts,
|
|
5123
5276
|
useFiasNavigation,
|