@peers-app/peers-sdk 0.30.0 → 0.30.2
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/contracts/contract-resolvers.js +1 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/system/file-storage-contract.d.ts +170 -0
- package/dist/contracts/system/file-storage-contract.js +123 -0
- package/dist/contracts/system/files-contract.d.ts +5 -1
- package/dist/contracts/system/files-contract.js +50 -9
- package/dist/contracts/system/files-shared.d.ts +68 -3
- package/dist/contracts/system/files-shared.js +65 -5
- package/dist/data/derived-row-id.d.ts +26 -0
- package/dist/data/derived-row-id.js +47 -0
- package/dist/data/files/chunk-store.d.ts +119 -0
- package/dist/data/files/chunk-store.js +112 -0
- package/dist/data/files/file-read-stream.d.ts +32 -3
- package/dist/data/files/file-read-stream.js +44 -29
- package/dist/data/files/file-rows.d.ts +77 -0
- package/dist/data/files/file-rows.js +182 -0
- package/dist/data/files/file-write-stream.d.ts +27 -0
- package/dist/data/files/file-write-stream.js +67 -42
- package/dist/data/files/file.types.d.ts +59 -23
- package/dist/data/files/file.types.js +54 -51
- package/dist/data/files/files.d.ts +28 -24
- package/dist/data/files/files.js +71 -85
- package/dist/data/files/index.d.ts +2 -0
- package/dist/data/files/index.js +2 -0
- package/dist/data/groups.d.ts +13 -0
- package/dist/data/groups.js +6 -0
- package/dist/data/index.d.ts +1 -0
- package/dist/data/index.js +1 -0
- package/dist/data/orm/write-checks.d.ts +15 -0
- package/dist/data/orm/write-checks.js +21 -0
- package/dist/define/system-contracts.d.ts +9 -2
- package/dist/define/system-contracts.js +6 -2
- package/dist/device-pairing/types.d.ts +2 -2
- package/dist/invites/invite-messages.d.ts +38 -0
- package/dist/package-installer/package-installer.d.ts +3 -5
- package/dist/package-installer/package-installer.js +5 -21
- package/dist/package-installer/package-propagation.js +6 -17
- package/dist/system-ids.d.ts +2 -0
- package/dist/system-ids.js +3 -1
- package/package.json +1 -1
|
@@ -37,11 +37,9 @@ export declare function ensurePackageVersionAppNavs(dataContext: DataContext, de
|
|
|
37
37
|
*/
|
|
38
38
|
export declare function installAllPackageBundles(dataContext: DataContext, deps: IPackageInstallerDeps): Promise<void>;
|
|
39
39
|
/**
|
|
40
|
-
* Save a bundle's content as a
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* the existing record is reused — no new File is created. This eliminates
|
|
44
|
-
* the "new File record on every dev reload" bug.
|
|
40
|
+
* Save a bundle's content as a file the runtime owns: collected once no package version
|
|
41
|
+
* references it. The same content and name give the same file, so a rebuild with no change
|
|
42
|
+
* adds no row, and every save stores the chunks again (restoring any a device has freed).
|
|
45
43
|
*/
|
|
46
44
|
export declare function saveBundleFile(dataContext: DataContext, content: string, name: string, _packageId: string): Promise<{
|
|
47
45
|
fileId: string;
|
|
@@ -98,7 +98,7 @@ async function installPackageFromBundles(dataContext, deps, packageId, opts) {
|
|
|
98
98
|
});
|
|
99
99
|
return { packageVersion: existingPv, loaded, unchanged, warning };
|
|
100
100
|
}
|
|
101
|
-
// 7. Save bundle files (
|
|
101
|
+
// 7. Save bundle files (the same content and name is the same file)
|
|
102
102
|
const packageFile = await saveBundleFile(dataContext, packageBundle, `${packageId}-package.bundle.js`, packageId);
|
|
103
103
|
let routesFile;
|
|
104
104
|
if (routesBundle) {
|
|
@@ -278,28 +278,12 @@ async function installAllPackageBundles(dataContext, deps) {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
|
-
* Save a bundle's content as a
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* the existing record is reused — no new File is created. This eliminates
|
|
285
|
-
* the "new File record on every dev reload" bug.
|
|
281
|
+
* Save a bundle's content as a file the runtime owns: collected once no package version
|
|
282
|
+
* references it. The same content and name give the same file, so a rebuild with no change
|
|
283
|
+
* adds no row, and every save stores the chunks again (restoring any a device has freed).
|
|
286
284
|
*/
|
|
287
285
|
async function saveBundleFile(dataContext, content, name, _packageId) {
|
|
288
|
-
const
|
|
289
|
-
const filesTable = (0, files_1.Files)(dataContext);
|
|
290
|
-
// Check if a file with this hash already exists for this bundle name
|
|
291
|
-
const existing = await filesTable.findOne({ name, fileHash });
|
|
292
|
-
if (existing) {
|
|
293
|
-
return { fileId: existing.fileId, fileHash: existing.fileHash };
|
|
294
|
-
}
|
|
295
|
-
const fileId = (0, utils_1.newid)();
|
|
296
|
-
const metadata = {
|
|
297
|
-
fileId,
|
|
298
|
-
name,
|
|
299
|
-
fileSize: content.length,
|
|
300
|
-
mimeType: "application/javascript",
|
|
301
|
-
};
|
|
302
|
-
const saved = await filesTable.saveFile(metadata, content);
|
|
286
|
+
const saved = await (0, files_1.Files)(dataContext).saveFile({ name, mimeType: "application/javascript", keep: false }, content);
|
|
303
287
|
return { fileId: saved.fileId, fileHash: saved.fileHash };
|
|
304
288
|
}
|
|
305
289
|
/**
|
|
@@ -125,7 +125,7 @@ async function installPvInGroupNoActivate(source, dest, pv) {
|
|
|
125
125
|
if (!files)
|
|
126
126
|
return false;
|
|
127
127
|
for (const file of files) {
|
|
128
|
-
await
|
|
128
|
+
await copyBundleRow(dest, file);
|
|
129
129
|
}
|
|
130
130
|
const propagatedPv = buildPropagatedPv(pv, files);
|
|
131
131
|
await (0, package_versions_1.PackageVersions)(dest).signAndSave(propagatedPv, {
|
|
@@ -162,9 +162,9 @@ async function installPvInGroup(source, dest, pv, retryCnt = 0) {
|
|
|
162
162
|
if (!files) {
|
|
163
163
|
return await retryOrFail(source, dest, pv, retryCnt, "missing files");
|
|
164
164
|
}
|
|
165
|
-
// Copy
|
|
165
|
+
// Copy the bundles' rows into the destination
|
|
166
166
|
for (const file of files) {
|
|
167
|
-
await
|
|
167
|
+
await copyBundleRow(dest, file);
|
|
168
168
|
}
|
|
169
169
|
// Save sanitized PV
|
|
170
170
|
const propagatedPv = buildPropagatedPv(pv, files);
|
|
@@ -231,20 +231,9 @@ async function copyBundleFiles(source, pv) {
|
|
|
231
231
|
}
|
|
232
232
|
return bundles;
|
|
233
233
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
async function saveFileAndIndexTree(sourceFiles, destFiles, file, copiedIds) {
|
|
238
|
-
if (copiedIds.has(file.fileId))
|
|
239
|
-
return;
|
|
240
|
-
copiedIds.add(file.fileId);
|
|
241
|
-
if (file.indexFileId) {
|
|
242
|
-
const indexFile = await sourceFiles.get(file.indexFileId);
|
|
243
|
-
if (indexFile) {
|
|
244
|
-
await saveFileAndIndexTree(sourceFiles, destFiles, indexFile, copiedIds);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
await destFiles.saveFileRecord(file);
|
|
234
|
+
/** Copy a bundle's row into `dest`. It keeps its id: a file's id doesn't depend on its context. */
|
|
235
|
+
async function copyBundleRow(dest, bundle) {
|
|
236
|
+
await (0, files_1.Files)(dest).saveFileRecord(bundle.file);
|
|
248
237
|
}
|
|
249
238
|
/** Select the best publisher-signed release under an Admin-approved package's follow policy. */
|
|
250
239
|
async function activateBestEligibleVersion(dataContext, pkg) {
|
package/dist/system-ids.d.ts
CHANGED
|
@@ -217,3 +217,5 @@ export declare const hostShellContractId = "00mveexhw7ezjfghxomlo011g";
|
|
|
217
217
|
export declare const groupMembersContractId = "00mvzfzkuf4djwjrsxq9cnaxt";
|
|
218
218
|
/** Local-only System Files v1: save and read files in the caller's own context; allocated once with newid(). */
|
|
219
219
|
export declare const filesContractId = "00mw1pvs1eupopu6sttetmki0";
|
|
220
|
+
/** Local-only System File Storage v1: this device's chunk store and its migration; allocated once with newid(). */
|
|
221
|
+
export declare const fileStorageContractId = "00mw2svtlb4yv8opod7vnofgn";
|
package/dist/system-ids.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.filesContractId = exports.groupMembersContractId = exports.hostShellContractId = exports.packagesContractId = exports.desktopToolsContractId = exports.hostToolsContractId = exports.toolCatalogContractId = exports.schedulerToolIds = exports.schedulerContractId = exports.contractCatalogToolIds = exports.contractCatalogContractId = exports.httpToolIds = exports.httpContractId = exports.localFoldersToolIds = exports.localFoldersContractId = exports.identityToolIds = exports.identityContractId = exports.invitesToolIds = exports.invitesContractId = exports.toolAccessControlToolIds = exports.toolAccessControlContractId = exports.syncCheckContractId = exports.appUpdatesContractId = exports.networkControlContractId = exports.networkDiagnosticsContractId = exports.deviceOperationsContractId = exports.logsContractId = exports.peersSystemPackageId = exports.peersCoreRevokedPublishPublicKeys = exports.peersCorePublishPublicKey = exports.peersCorePackageRepoUrl = exports.peersCorePackageId = exports.createGroupToolId = exports.queryDatabaseToolId = exports.runWorkflowToolId = exports.defaultSendMessageToolId = exports.defaultAssistantRunnerToolId = exports.adminAssistantId = exports.openCodeAssistantId = exports.defaultAssistantId = exports.peersRootUserId = void 0;
|
|
3
|
+
exports.fileStorageContractId = exports.filesContractId = exports.groupMembersContractId = exports.hostShellContractId = exports.packagesContractId = exports.desktopToolsContractId = exports.hostToolsContractId = exports.toolCatalogContractId = exports.schedulerToolIds = exports.schedulerContractId = exports.contractCatalogToolIds = exports.contractCatalogContractId = exports.httpToolIds = exports.httpContractId = exports.localFoldersToolIds = exports.localFoldersContractId = exports.identityToolIds = exports.identityContractId = exports.invitesToolIds = exports.invitesContractId = exports.toolAccessControlToolIds = exports.toolAccessControlContractId = exports.syncCheckContractId = exports.appUpdatesContractId = exports.networkControlContractId = exports.networkDiagnosticsContractId = exports.deviceOperationsContractId = exports.logsContractId = exports.peersSystemPackageId = exports.peersCoreRevokedPublishPublicKeys = exports.peersCorePublishPublicKey = exports.peersCorePackageRepoUrl = exports.peersCorePackageId = exports.createGroupToolId = exports.queryDatabaseToolId = exports.runWorkflowToolId = exports.defaultSendMessageToolId = exports.defaultAssistantRunnerToolId = exports.adminAssistantId = exports.openCodeAssistantId = exports.defaultAssistantId = exports.peersRootUserId = void 0;
|
|
4
4
|
/** Stable user ID that owns built-in Peers system records. */
|
|
5
5
|
exports.peersRootUserId = "000peers0user000000000001";
|
|
6
6
|
/** Default assistant used when no user-selected assistant is available. */
|
|
@@ -224,3 +224,5 @@ exports.hostShellContractId = "00mveexhw7ezjfghxomlo011g";
|
|
|
224
224
|
exports.groupMembersContractId = "00mvzfzkuf4djwjrsxq9cnaxt";
|
|
225
225
|
/** Local-only System Files v1: save and read files in the caller's own context; allocated once with newid(). */
|
|
226
226
|
exports.filesContractId = "00mw1pvs1eupopu6sttetmki0";
|
|
227
|
+
/** Local-only System File Storage v1: this device's chunk store and its migration; allocated once with newid(). */
|
|
228
|
+
exports.fileStorageContractId = "00mw2svtlb4yv8opod7vnofgn";
|