@seedprotocol/sdk 0.6.1 → 0.6.3
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/{BasePathResolver-DWY_hb8w.js → BasePathResolver-0IHnXxtL.js} +5 -1
- package/dist/BasePathResolver-0IHnXxtL.js.map +1 -0
- package/dist/{ModelProperty-CHIxRLfS.js → ModelProperty-BiDQu5rE.js} +40 -30
- package/dist/ModelProperty-BiDQu5rE.js.map +1 -0
- package/dist/{Schema-BaVOWeUb.js → Schema-qciDB7Nu.js} +43 -39
- package/dist/{Schema-BaVOWeUb.js.map → Schema-qciDB7Nu.js.map} +1 -1
- package/dist/{SchemaValidationService-BX4GcEKY.js → SchemaValidationService-BaOkRjsU.js} +6 -6
- package/dist/{SchemaValidationService-BX4GcEKY.js.map → SchemaValidationService-BaOkRjsU.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-6kBwLScb.js → backfillMetadataPropertyIds-oypxoBXv.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-6kBwLScb.js.map → backfillMetadataPropertyIds-oypxoBXv.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BphJm1e3.js → ModelProperty-DvIIhBnK.js} +17 -17
- package/dist/cjs/{ModelProperty-BphJm1e3.js.map → ModelProperty-DvIIhBnK.js.map} +1 -1
- package/dist/cjs/{Schema-z1fBr4Rv.js → Schema-FdzNqyGo.js} +20 -20
- package/dist/cjs/{Schema-z1fBr4Rv.js.map → Schema-FdzNqyGo.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-DWmIhQqz.js → SchemaValidationService-pxRoOs79.js} +2 -2
- package/dist/cjs/{SchemaValidationService-DWmIhQqz.js.map → SchemaValidationService-pxRoOs79.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds--9WN2zaG.js → backfillMetadataPropertyIds-D0o5VwBh.js} +2 -2
- package/dist/cjs/{backfillMetadataPropertyIds--9WN2zaG.js.map → backfillMetadataPropertyIds-D0o5VwBh.js.map} +1 -1
- package/dist/cjs/{eas-YuOI6X_v.js → eas-DSZkoDUn.js} +3 -3
- package/dist/cjs/{eas-YuOI6X_v.js.map → eas-DSZkoDUn.js.map} +1 -1
- package/dist/cjs/{getItem-CKDdJztx.js → getItem-CPcdcFuS.js} +2 -2
- package/dist/cjs/{getItem-CKDdJztx.js.map → getItem-CPcdcFuS.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-DXHDgXU3.js → getPublishPayload-BvmVTKoc.js} +11 -11
- package/dist/cjs/{getPublishPayload-DXHDgXU3.js.map → getPublishPayload-BvmVTKoc.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-yFW9CKSW.js → getPublishUploads-D2VZHZnu.js} +4 -4
- package/dist/cjs/{getPublishUploads-yFW9CKSW.js.map → getPublishUploads-D2VZHZnu.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-BLdMFDBt.js → getSegmentedItemProperties-Bm1TEvBS.js} +3 -3
- package/dist/cjs/{getSegmentedItemProperties-BLdMFDBt.js.map → getSegmentedItemProperties-Bm1TEvBS.js.map} +1 -1
- package/dist/cjs/{index-WOQkKWSU.js → index-C-POwaLs.js} +445 -315
- package/dist/cjs/index-C-POwaLs.js.map +1 -0
- package/dist/cjs/{index-Bp16LrkZ.js → index-D_ph4zut.js} +3 -3
- package/dist/cjs/index-D_ph4zut.js.map +1 -0
- package/dist/cjs/{property-DSh60oEw.js → property-DkUtJxV2.js} +4 -4
- package/dist/cjs/{property-DSh60oEw.js.map → property-DkUtJxV2.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-pVjTHk3y.js → syncDbWithEas-DRoys7eo.js} +17 -10
- package/dist/cjs/syncDbWithEas-DRoys7eo.js.map +1 -0
- package/dist/{configurePlatform-CXQCT7N8.js → configurePlatform-Df4BlXwQ.js} +3 -3
- package/dist/{configurePlatform-CXQCT7N8.js.map → configurePlatform-Df4BlXwQ.js.map} +1 -1
- package/dist/{constants-DMHTYMgJ.js → constants-Bre6dTJR.js} +3 -1
- package/dist/constants-Bre6dTJR.js.map +1 -0
- package/dist/{constants-B7aNfB_1.js → constants-CROrIRd-.js} +2 -2
- package/dist/{constants-B7aNfB_1.js.map → constants-CROrIRd-.js.map} +1 -1
- package/dist/{db-CMQ3TG6N.js → db-DVsy4QZe.js} +121 -56
- package/dist/db-DVsy4QZe.js.map +1 -0
- package/dist/{eas-BG3zRyHC.js → eas-z4W41ith.js} +5 -5
- package/dist/{eas-BG3zRyHC.js.map → eas-z4W41ith.js.map} +1 -1
- package/dist/{getItem-BFDi98NG.js → getItem-BiE_b7Fu.js} +6 -6
- package/dist/{getItem-BFDi98NG.js.map → getItem-BiE_b7Fu.js.map} +1 -1
- package/dist/{getPublishPayload-B2D-72EC.js → getPublishPayload-CuRGEZa5.js} +17 -17
- package/dist/{getPublishPayload-B2D-72EC.js.map → getPublishPayload-CuRGEZa5.js.map} +1 -1
- package/dist/{getPublishUploads-D-fMspZI.js → getPublishUploads-CMgzBCzZ.js} +8 -8
- package/dist/{getPublishUploads-D-fMspZI.js.map → getPublishUploads-CMgzBCzZ.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-DzjK6JE5.js → getSegmentedItemProperties-BCCSwTxr.js} +5 -5
- package/dist/{getSegmentedItemProperties-DzjK6JE5.js.map → getSegmentedItemProperties-BCCSwTxr.js.map} +1 -1
- package/dist/{index-BaPbRFSy.js → index-C41UZTmQ.js} +8 -8
- package/dist/index-C41UZTmQ.js.map +1 -0
- package/dist/{index-Dx0RL3Tx.js → index-DjwIC6U3.js} +418 -343
- package/dist/index-DjwIC6U3.js.map +1 -0
- package/dist/{index-DrEkRiuK.js → index-xNWgPtlN.js} +2 -2
- package/dist/index-xNWgPtlN.js.map +1 -0
- package/dist/{index.node-hhs7zosf.js → index.node-DQZ3cPe-.js} +14 -5
- package/dist/index.node-DQZ3cPe-.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +300 -24
- package/dist/main.js.map +1 -1
- package/dist/node.js +11 -11
- package/dist/platform.browser.js +14 -4
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +4 -4
- package/dist/{property-B2xdCZz_.js → property-Bs3a4Dna.js} +9 -9
- package/dist/{property-B2xdCZz_.js.map → property-Bs3a4Dna.js.map} +1 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -0
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +12 -0
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/db/read/getItems.d.ts.map +1 -1
- package/dist/src/db/read/summarizePublishWork.d.ts +24 -0
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -0
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts +11 -0
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -0
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/createSeed.d.ts.map +1 -1
- package/dist/src/db/write/createSeeds.d.ts.map +1 -1
- package/dist/src/db/write/createVersion.d.ts.map +1 -1
- package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
- package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
- package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -0
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts +2 -0
- package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
- package/dist/src/helpers/addresses.d.ts +14 -0
- package/dist/src/helpers/addresses.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts +2 -2
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/ownership.d.ts +36 -8
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/publishConfig.d.ts +4 -3
- package/dist/src/helpers/publishConfig.d.ts.map +1 -1
- package/dist/src/helpers/reactiveProxy.d.ts +10 -0
- package/dist/src/helpers/reactiveProxy.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/helpers/FileManager.d.ts +1 -0
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +6 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-B9Riqty1.js → syncDbWithEas-DRpLRxwb.js} +25 -18
- package/dist/syncDbWithEas-DRpLRxwb.js.map +1 -0
- package/dist/{updateSeedRevokedAt-CtRjZiyh.js → updateSeedRevokedAt-F0ZDvwOO.js} +2 -2
- package/dist/{updateSeedRevokedAt-CtRjZiyh.js.map → updateSeedRevokedAt-F0ZDvwOO.js.map} +1 -1
- package/package.json +5 -5
- package/dist/BasePathResolver-DWY_hb8w.js.map +0 -1
- package/dist/ModelProperty-CHIxRLfS.js.map +0 -1
- package/dist/cjs/index-Bp16LrkZ.js.map +0 -1
- package/dist/cjs/index-WOQkKWSU.js.map +0 -1
- package/dist/cjs/syncDbWithEas-pVjTHk3y.js.map +0 -1
- package/dist/constants-DMHTYMgJ.js.map +0 -1
- package/dist/db-CMQ3TG6N.js.map +0 -1
- package/dist/index-BaPbRFSy.js.map +0 -1
- package/dist/index-DrEkRiuK.js.map +0 -1
- package/dist/index-Dx0RL3Tx.js.map +0 -1
- package/dist/index.node-hhs7zosf.js.map +0 -1
- package/dist/syncDbWithEas-B9Riqty1.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as metadata, c as appState, d as arweaveL1FinalizeJobs, e as config, f as easSyncProcesses, h as htmlEmbeddedImageCoPublish, g as modelRelations, i as modelSchemas, j as modelUids, m as models, k as modelsRelations, p as properties, l as propertiesRelations, n as propertyUidRelations, o as propertyUids, q as publishProcesses, s as schemas, r as seeds, u as uploadProcesses, v as versions } from './BasePathResolver-
|
|
1
|
+
import { b as metadata, c as appState, d as arweaveL1FinalizeJobs, e as config, f as easSyncProcesses, h as htmlEmbeddedImageCoPublish, g as modelRelations, i as modelSchemas, j as modelUids, m as models, k as modelsRelations, p as properties, l as propertiesRelations, n as propertyUidRelations, o as propertyUids, q as publishProcesses, s as schemas, r as seeds, u as uploadProcesses, v as versions } from './BasePathResolver-0IHnXxtL.js';
|
|
2
2
|
|
|
3
3
|
var schema = /*#__PURE__*/Object.freeze({
|
|
4
4
|
__proto__: null,
|
|
@@ -25,4 +25,4 @@ var schema = /*#__PURE__*/Object.freeze({
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
export { schema as s };
|
|
28
|
-
//# sourceMappingURL=index-
|
|
28
|
+
//# sourceMappingURL=index-xNWgPtlN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-xNWgPtlN.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import fs__default from 'fs';
|
|
4
|
-
import { SEED_CONFIG_FILE, SEED_CONFIG_FALLBACKS } from './constants-
|
|
5
|
-
import { B as BaseFileManager, c as appState, t as BasePathResolver, a as BaseDb } from './BasePathResolver-
|
|
4
|
+
import { SEED_CONFIG_FILE, SEED_CONFIG_FALLBACKS } from './constants-Bre6dTJR.js';
|
|
5
|
+
import { B as BaseFileManager, c as appState, t as BasePathResolver, a as BaseDb } from './BasePathResolver-0IHnXxtL.js';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
import * as fsAsync from 'fs/promises';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import { s as schema } from './index-
|
|
9
|
+
import { s as schema } from './index-xNWgPtlN.js';
|
|
10
10
|
import { createClient } from '@libsql/client';
|
|
11
11
|
import { drizzle } from 'drizzle-orm/libsql';
|
|
12
12
|
import { migrate } from 'drizzle-orm/libsql/migrator';
|
|
@@ -39,6 +39,15 @@ class NodeFileManager {
|
|
|
39
39
|
async pathExists(filePath) {
|
|
40
40
|
return await fsAsync.access(filePath).then(() => true).catch(() => false);
|
|
41
41
|
}
|
|
42
|
+
async getFileSize(filePath) {
|
|
43
|
+
try {
|
|
44
|
+
const stat = await fsAsync.stat(filePath);
|
|
45
|
+
return stat.size;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
42
51
|
async listImageFiles() {
|
|
43
52
|
return this.listFiles('images');
|
|
44
53
|
}
|
|
@@ -249,7 +258,7 @@ class NodeDb {
|
|
|
249
258
|
logger$1('[Db.prepareDb] running migrations from %s', outDir);
|
|
250
259
|
await migrate(db, { migrationsFolder: outDir });
|
|
251
260
|
this.db = db;
|
|
252
|
-
const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-
|
|
261
|
+
const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-oypxoBXv.js');
|
|
253
262
|
await backfillMetadataPropertyIds();
|
|
254
263
|
return this.db;
|
|
255
264
|
}
|
|
@@ -500,4 +509,4 @@ function createPlatformServices() {
|
|
|
500
509
|
}
|
|
501
510
|
|
|
502
511
|
export { Db as D, FileManager as F, PathResolver as P, createPlatformServices as c, resolveSdkDrizzleMigrationsDir as r };
|
|
503
|
-
//# sourceMappingURL=index.node-
|
|
512
|
+
//# sourceMappingURL=index.node-DQZ3cPe-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node-DQZ3cPe-.js","sources":["../../src/node/helpers/FileManager.ts","../../src/node/db/Db.ts","../../src/node/helpers/PathResolver.ts","../../src/platform/index.node.ts"],"sourcesContent":["import * as fsAsync from 'fs/promises'\nimport * as fs from 'fs'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\nimport type { IFileManager } from '@/helpers/FileManager/IFileManager'\nimport path from 'path'\n\nexport class NodeFileManager implements IFileManager {\n async getFs() {\n return fs\n }\n\n getFsSync() {\n return fs\n }\n\n async getContentUrlFromPath(_path: string): Promise<string | undefined> {\n throw new Error('Not implemented')\n }\n\n async initializeFileSystem(_workingDir?: string): Promise<void> {\n return // No need to initialize file system in node\n }\n\n async downloadAllFiles(): Promise<void> {\n throw new Error('Not implemented')\n }\n\n async resizeImage(): Promise<void> {\n throw new Error('Not implemented')\n }\n\n async resizeAllImages(): Promise<void> {\n throw new Error('Not implemented')\n }\n\n async pathExists(filePath: string): Promise<boolean> {\n return await fsAsync.access(filePath).then(() => true).catch(() => false)\n }\n\n async getFileSize(filePath: string): Promise<number | null> {\n try {\n const stat = await fsAsync.stat(filePath)\n return stat.size\n } catch {\n return null\n }\n }\n\n async listImageFiles(): Promise<string[]> {\n return this.listFiles('images')\n }\n\n async listFiles(dir: string): Promise<string[]> {\n const targetDir = BaseFileManager.getFilesPath(dir)\n const exists = await this.pathExists(targetDir)\n if (!exists) {\n return []\n }\n const entries = await fsAsync.readdir(targetDir, { withFileTypes: true })\n return entries.filter((entry) => entry.isFile()).map((entry) => entry.name)\n }\n\n async createDirIfNotExists(filePath: string): Promise<void> {\n await fsAsync.mkdir(filePath, { recursive: true })\n }\n\n async waitForFile(filePath: string, interval: number = 1000, timeout: number = 60000): Promise<boolean> {\n const pathExists = await this.pathExists(filePath)\n if (pathExists) {\n return true\n }\n\n return new Promise((resolve, reject) => {\n const startTime = Date.now()\n let isBusy = false\n\n const checkInterval = setInterval(async () => {\n if (isBusy) {\n return\n }\n isBusy = true\n\n try {\n const exists = await this.pathExists(filePath)\n if (exists) {\n clearInterval(checkInterval)\n resolve(true)\n return\n }\n\n if (Date.now() - startTime >= timeout) {\n clearInterval(checkInterval)\n reject(new Error('Timeout exceeded while waiting for file'))\n return\n }\n } catch (error) {\n clearInterval(checkInterval)\n reject(error)\n return\n } finally {\n isBusy = false\n }\n }, interval)\n })\n }\n\n async waitForFileWithContent(filePath: string, interval: number = 100, timeout: number = 5000): Promise<boolean> {\n return this.waitForFile(filePath, interval, timeout)\n }\n\n async saveFile(filePath: string, content: string | Blob | ArrayBuffer): Promise<void> {\n const dir = path.dirname(filePath)\n await fsAsync.mkdir(dir, { recursive: true })\n\n if (typeof content === 'string') {\n await fsAsync.writeFile(filePath, content, 'utf-8')\n } else if (content instanceof Blob) {\n const arrayBuffer = await content.arrayBuffer()\n await fsAsync.writeFile(filePath, new Uint8Array(arrayBuffer))\n } else if (content instanceof ArrayBuffer) {\n await fsAsync.writeFile(filePath, new Uint8Array(content))\n } else {\n throw new Error('Unsupported content type')\n }\n }\n\n saveFileSync(filePath: string, content: string | Blob | ArrayBuffer): void {\n const dir = path.dirname(filePath)\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true })\n }\n\n if (typeof content === 'string') {\n fs.writeFileSync(filePath, content, 'utf-8')\n } else if (content instanceof Blob) {\n throw new Error('Blob content not supported in saveFileSync. Use saveFile() instead or convert to ArrayBuffer first.')\n } else if (content instanceof ArrayBuffer) {\n fs.writeFileSync(filePath, new Uint8Array(content))\n } else {\n throw new Error('Unsupported content type')\n }\n }\n\n async readFileAsBuffer(filePath: string): Promise<Buffer> {\n return await fsAsync.readFile(filePath)\n }\n\n async readFileAsString(filePath: string): Promise<string> {\n return await fsAsync.readFile(filePath, 'utf-8')\n }\n\n async readFile(filePath: string): Promise<File> {\n return new File([await fsAsync.readFile(filePath)], filePath)\n }\n\n readFileSync(filePath: string): File {\n return new File([fs.readFileSync(filePath)], filePath)\n }\n\n getParentDirPath(filePath: string): string {\n return path.dirname(filePath)\n }\n\n getFilenameFromPath(filePath: string): string {\n return path.basename(filePath)\n }\n\n getPathModule(): any {\n return path\n }\n}\n\n/** @deprecated Prefer NodeFileManager */\nexport const FileManager = NodeFileManager\n\nBaseFileManager.configure(new NodeFileManager())\n\nconst _check: IFileManager = new NodeFileManager()\nvoid _check\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport type { IDb } from '@/interfaces/IDb'\nimport path from 'path'\nimport { fileURLToPath } from 'node:url'\nimport debug from 'debug'\nimport { appState } from '@/seedSchema'\nimport fs from 'fs'\nimport { createClient } from '@libsql/client'\nimport { drizzle } from 'drizzle-orm/libsql'\nimport { migrate } from 'drizzle-orm/libsql/migrator'\nimport * as schema from '@/seedSchema'\nimport { Observable, interval, switchMap, distinctUntilChanged, startWith } from 'rxjs'\nimport { BasePathResolver } from '@/helpers/PathResolver/BasePathResolver'\n\nconst logger = debug('seedSdk:node:db:Db')\n\nexport interface DbConfig {\n dbUrl?: string\n /** @deprecated Unused — schema is the static SDK seedSchema + prebuilt SQL migrations */\n schemaDir?: string\n outDir?: string\n}\n\nfunction resolveDbPaths(filesDir: string, config?: DbConfig) {\n const outDir = config?.outDir || path.join(filesDir, 'db')\n const dbPath = config?.dbUrl\n ? (config.dbUrl.startsWith('file:') ? config.dbUrl.replace(/^file:/, '') : config.dbUrl)\n : path.join(outDir, 'seed.db')\n return { outDir, dbPath }\n}\n\n/**\n * Locate prebuilt drizzle migration SQL shipped with the SDK\n * (same files the browser embeds via drizzleFiles.ts).\n */\nexport function resolveSdkDrizzleMigrationsDir(sdkRootDir?: string): string {\n const root =\n sdkRootDir ||\n (() => {\n try {\n return BasePathResolver.getSdkRootDir()\n } catch {\n return process.cwd()\n }\n })()\n\n // Also resolve relative to this module so temp-cwd tests / odd roots still find\n // packages/sdk/src/db/drizzle (or dist/db/drizzle after publish).\n const moduleDir = path.dirname(fileURLToPath(import.meta.url))\n\n const candidates = [\n path.join(root, 'db', 'drizzle'), // production: sdkRoot is dist/\n path.join(root, 'dist', 'db', 'drizzle'), // sdk package root with built dist\n path.join(root, 'src', 'db', 'drizzle'), // monorepo / sdk-dev\n path.join(root, 'packages', 'sdk', 'src', 'db', 'drizzle'), // monorepo root as cwd\n path.join(root, 'packages', 'sdk', 'dist', 'db', 'drizzle'),\n path.join(moduleDir, '..', '..', 'db', 'drizzle'), // src/node/db -> src/db/drizzle\n path.join(moduleDir, '..', '..', '..', 'src', 'db', 'drizzle'), // dist/node -> src\n path.join(moduleDir, '..', 'db', 'drizzle'), // dist layout variants\n ]\n\n for (const candidate of candidates) {\n if (fs.existsSync(path.join(candidate, 'meta', '_journal.json'))) {\n return candidate\n }\n }\n\n throw new Error(\n `Could not find SDK drizzle migrations (meta/_journal.json). Searched under: ${candidates.join(', ')}`,\n )\n}\n\nfunction copyDirRecursive(sourceDir: string, targetDir: string) {\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true })\n }\n for (const entry of fs.readdirSync(sourceDir)) {\n const sourcePath = path.join(sourceDir, entry)\n const targetPath = path.join(targetDir, entry)\n const stats = fs.statSync(sourcePath)\n if (stats.isDirectory()) {\n copyDirRecursive(sourcePath, targetPath)\n } else {\n fs.copyFileSync(sourcePath, targetPath)\n }\n }\n}\n\nexport class NodeDb implements IDb {\n db: any\n\n\n getAppDb() {\n return this.db\n }\n\n isAppDbReady() {\n return true\n }\n\n /**\n * Copy prebuilt SQL migrations into the app db directory (overwrite to stay current).\n */\n copyDrizzleFiles(filesDir: string, migrationsSourceDir?: string): string {\n const { outDir } = resolveDbPaths(filesDir)\n const source = migrationsSourceDir || resolveSdkDrizzleMigrationsDir()\n logger('[Db.copyDrizzleFiles] copying from %s to %s', source, outDir)\n copyDirRecursive(source, outDir)\n return outDir\n }\n\n async prepareDb(filesDir: string, config?: DbConfig) {\n const resolvedFilesDir = path.resolve(filesDir)\n\n if (!fs.existsSync(resolvedFilesDir)) {\n fs.mkdirSync(resolvedFilesDir, { recursive: true })\n }\n\n const { outDir, dbPath } = resolveDbPaths(resolvedFilesDir, config)\n\n if (!fs.existsSync(outDir)) {\n fs.mkdirSync(outDir, { recursive: true })\n }\n\n // Install SDK migration SQL next to the DB (same source of truth as browser)\n this.copyDrizzleFiles(resolvedFilesDir)\n\n const dbUrl = config?.dbUrl\n ? (config.dbUrl.startsWith('file:') ? config.dbUrl : `file:${path.resolve(config.dbUrl)}`)\n : `file:${path.resolve(dbPath)}`\n\n const client = createClient({ url: dbUrl })\n const db = drizzle(client, { schema })\n\n logger('[Db.prepareDb] running migrations from %s', outDir)\n await migrate(db, { migrationsFolder: outDir })\n\n this.db = db\n\n const { backfillMetadataPropertyIds } = await import('@/db/backfillMetadataPropertyIds')\n await backfillMetadataPropertyIds()\n\n return this.db\n }\n\n async connectToDb(_pathToDir: string) {\n return {\n id: this.db ? this.db.constructor.name : '',\n }\n }\n\n async migrate(pathToDbDir: string, _dbName: string, _dbId: string) {\n try {\n if (!this.db) {\n throw new Error('Database not initialized. Call prepareDb first.')\n }\n\n await migrate(this.db, { migrationsFolder: pathToDbDir })\n const queryResult = await this.db.select().from(appState)\n logger('queryResult', queryResult)\n } catch (error: any) {\n const errorMessage = error.message || String(error) || ''\n const errorString = String(error)\n const isMigrationError =\n errorMessage.includes(\"Can't find meta/_journal.json\") ||\n errorMessage.includes('_journal.json') ||\n errorMessage.includes(\"Cannot read properties of undefined\") ||\n errorMessage.includes(\"reading 'dialect'\") ||\n errorMessage.includes('undefined is not an object') ||\n errorString.includes('dialect') ||\n errorString.includes('undefined is not an object')\n\n if (isMigrationError) {\n if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {\n logger(\n 'Warning: Migration failed, but continuing in test environment:',\n errorMessage || errorString,\n )\n return this.db\n }\n }\n throw error\n }\n\n return this.db\n }\n\n /**\n * Polling-based liveQuery stub for Node. Prefer browser reactive queries in UI apps.\n */\n liveQuery<T>(query: ((sql: any) => any) | any): Observable<T[]> {\n if (!this.db) {\n throw new Error('Database not initialized. Call prepareDb first.')\n }\n\n const pollInterval = 1000\n\n if (typeof query === 'function') {\n throw new Error(\n 'SQL tag functions are not supported in node liveQuery stub implementation. Use Drizzle query builders instead.',\n )\n }\n\n const queryBuilder = query\n\n return interval(pollInterval).pipe(\n startWith(0),\n switchMap(async () => {\n try {\n const result = await Promise.resolve(queryBuilder)\n return result as T[]\n } catch (error) {\n logger('[Db.liveQuery] Error executing query:', error)\n throw error\n }\n }),\n distinctUntilChanged((prev, curr) => {\n return JSON.stringify(prev) === JSON.stringify(curr)\n }),\n )\n }\n}\n\n/** @deprecated Prefer NodeDb */\nexport const Db = NodeDb\n\nBaseDb.configure(new NodeDb())\n\nconst _check: IDb = new NodeDb()\nvoid _check\n","import path from 'path'\nimport fs from 'fs'\nimport { SEED_CONFIG_FILE, SEED_CONFIG_FALLBACKS } from '@/helpers/constants'\nimport type { IPathResolver } from '@/helpers/PathResolver/IPathResolver'\nimport { BasePathResolver } from '@/helpers/PathResolver/BasePathResolver'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:node:helpers:PathResolver')\n\nexport class NodePathResolver implements IPathResolver {\n /** @deprecated Prefer BasePathResolver static methods or configure(). */\n static getInstance(): IPathResolver {\n return BasePathResolver.getInstance()\n }\n\n /**\n * Detects the current environment based on filesystem structure and package.json\n */\n private detectEnvironment(): 'sdk-dev' | 'linked-sdk' | 'production' | 'test' {\n // Check if we're in the SDK repo itself\n if (process.env.NODE_ENV !== 'test' && this.isInSdkRepo()) {\n return 'sdk-dev'\n }\n\n // Check if we're running tests\n if (process.env.NODE_ENV === 'test') {\n return 'test'\n }\n\n // Check if we're using a linked version of the SDK\n if (this.isUsingLinkedSdk()) {\n return 'linked-sdk'\n }\n\n // Default to production environment\n return 'production'\n }\n\n private isInSdkRepo(): boolean {\n try {\n const currentDir = process.cwd()\n // Check when running from packages/sdk (SDK package root)\n if (fs.existsSync(path.join(currentDir, 'src', 'node')) &&\n fs.existsSync(path.join(currentDir, 'package.json')) &&\n JSON.parse(fs.readFileSync(path.join(currentDir, 'package.json'), 'utf8')).name === '@seedprotocol/sdk') {\n return true\n }\n // Check when running from monorepo root\n if (fs.existsSync(path.join(currentDir, 'packages', 'sdk', 'src', 'node')) &&\n fs.existsSync(path.join(currentDir, 'packages', 'sdk', 'package.json')) &&\n JSON.parse(fs.readFileSync(path.join(currentDir, 'packages', 'sdk', 'package.json'), 'utf8')).name === '@seedprotocol/sdk') {\n return true\n }\n return false\n } catch {\n return false\n }\n }\n\n private isUsingLinkedSdk(): boolean {\n try {\n const pkgPath = path.join(process.cwd(), 'package.json')\n if (!fs.existsSync(pkgPath)) return false\n \n const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))\n const sdkDep = pkg.dependencies?.['@seedprotocol/sdk']\n \n return sdkDep && (sdkDep.startsWith('link:') || sdkDep.startsWith('portal:'))\n } catch {\n return false\n }\n }\n\n /**\n * Gets the root directory containing node_modules\n */\n getRootWithNodeModules(): string {\n const processCwd = process.cwd()\n\n const calledFromMocks = processCwd.includes('__mocks__')\n\n if (calledFromMocks) {\n return path.join(processCwd, '..', '..', '..', '..',)\n }\n\n return processCwd\n }\n\n /**\n * Gets the SDK root directory\n */\n getSdkRootDir(): string {\n const env = this.detectEnvironment()\n const rootWithNodeModules = this.getRootWithNodeModules()\n const processCwd = process.cwd()\n\n // For test environment, always return the SDK root directory\n if (env === 'test') {\n return rootWithNodeModules\n }\n\n if (env === 'linked-sdk') {\n // For linked packages, find the package directory\n const pkgJson = JSON.parse(fs.readFileSync(path.join(processCwd, 'package.json'), 'utf8'))\n const sdkPath = pkgJson.dependencies?.['@seedprotocol/sdk'] || pkgJson.devDependencies?.['@seedprotocol/sdk']\n if (sdkPath === 'link:@seedprotocol/sdk') {\n return path.join(processCwd, 'node_modules', '@seedprotocol', 'sdk',)\n }\n return path.resolve(processCwd, sdkPath.replace(/^(link:|portal:)/, ''))\n }\n\n // After early returns, env can only be 'sdk-dev' or 'production'\n if (env === 'sdk-dev') {\n // When running from monorepo root, SDK root is packages/sdk\n if (fs.existsSync(path.join(rootWithNodeModules, 'packages', 'sdk', 'package.json'))) {\n return path.join(rootWithNodeModules, 'packages', 'sdk')\n }\n // When running from packages/sdk directly\n return rootWithNodeModules\n }\n \n // Default to production environment\n // This should be {projectDir}/node_modules/@seedprotocol/sdk/dist\n return path.join(rootWithNodeModules, 'node_modules', '@seedprotocol', 'sdk', 'dist')\n }\n\n getNodeModulesDir(): string {\n const env = this.detectEnvironment()\n const rootWithNodeModules = this.getRootWithNodeModules()\n\n let nodeModulesDir = path.join(rootWithNodeModules, 'node_modules')\n\n if (env !== 'linked-sdk' && env !== 'sdk-dev' && nodeModulesDir.includes('__tests__')) {\n nodeModulesDir = path.join(process.cwd(), '..', '..', '..', '..', 'node_modules',)\n }\n\n return nodeModulesDir\n }\n\n /**\n * Gets the .seed directory path\n */\n getDotSeedDir(schemaFileDir?: string): string {\n if (!schemaFileDir && process.env.SEED_SDK_TEST_PROJECT_TYPE && !process.cwd().includes('__mocks__')) {\n return path.join(process.cwd(), '__tests__', '__mocks__', process.env.SEED_SDK_TEST_PROJECT_TYPE, 'project', '.seed')\n }\n return path.join(schemaFileDir || process.cwd(), '.seed')\n }\n\n /**\n * Finds the Seed Protocol config file in the given directory\n * @param searchDir - Directory to search for the config file\n * @returns The path to the found config file, or null if not found\n */\n findConfigFile(searchDir: string = process.cwd()): string | null {\n // First try the primary config file name\n const primaryPath = path.join(searchDir, SEED_CONFIG_FILE)\n if (fs.existsSync(primaryPath)) {\n return primaryPath\n }\n\n // Then try fallback names in order\n for (const fallbackName of SEED_CONFIG_FALLBACKS) {\n const fallbackPath = path.join(searchDir, fallbackName)\n if (fs.existsSync(fallbackPath)) {\n return fallbackPath\n }\n }\n\n return null\n }\n\n /**\n * Gets paths for app-specific directories\n */\n getAppPaths(schemaFileDir?: string | undefined) {\n const env = this.detectEnvironment()\n const dotSeedDir = this.getDotSeedDir(schemaFileDir)\n const nodeModulesDir = this.getNodeModulesDir()\n\n logger('env', env)\n\n logger('getAppPaths', {\n sdkRootDir: this.getSdkRootDir(),\n dotSeedDir,\n nodeModulesDir,\n appSchemaDir: path.join(dotSeedDir, 'schema'),\n appDbDir: path.join(dotSeedDir, 'db'),\n appMetaDir: path.join(dotSeedDir, 'db', 'meta'),\n })\n\n return {\n sdkRootDir: this.getSdkRootDir(),\n dotSeedDir,\n nodeModulesDir,\n appSchemaDir: path.join(dotSeedDir, 'schema'),\n appDbDir: path.join(dotSeedDir, 'db'),\n appMetaDir: path.join(dotSeedDir, 'db', 'meta'),\n }\n }\n}\n\n/** @deprecated Prefer NodePathResolver; kept for CLI / node entry exports. */\nexport const PathResolver = NodePathResolver\n\nBasePathResolver.configure(new NodePathResolver())\n\nconst _check: IPathResolver = new NodePathResolver()\nvoid _check\n","import { NodePathResolver } from '@/node/helpers/PathResolver'\nimport { NodeFileManager } from '@/node/helpers/FileManager'\nimport { NodeDb } from '@/node/db/Db'\nimport { NodeArweaveClient } from '@/node/helpers/ArweaveClient'\nimport { NodeEasClient } from '@/node/helpers/EasClient'\nimport { NodeQueryClient } from '@/node/helpers/QueryClient'\nimport type { PlatformServices } from './types'\n\nexport function createPlatformServices(): PlatformServices {\n return {\n pathResolver: new NodePathResolver(),\n fileManager: new NodeFileManager(),\n db: new NodeDb(),\n arweaveClient: new NodeArweaveClient(),\n easClient: new NodeEasClient(),\n queryClient: new NodeQueryClient(),\n }\n}\n"],"names":["logger","fs"],"mappings":";;;;;;;;;;;;;;;;MAMa,eAAe,CAAA;AAC1B,IAAA,MAAM,KAAK,GAAA;AACT,QAAA,OAAO,EAAE;IACX;IAEA,SAAS,GAAA;AACP,QAAA,OAAO,EAAE;IACX;IAEA,MAAM,qBAAqB,CAAC,KAAa,EAAA;AACvC,QAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;IACpC;IAEA,MAAM,oBAAoB,CAAC,WAAoB,EAAA;AAC7C,QAAA,OAAM;IACR;AAEA,IAAA,MAAM,gBAAgB,GAAA;AACpB,QAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;IACpC;AAEA,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;IACpC;AAEA,I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cAAc;YACd,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;YAC7C,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC;YACrC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC;SAChD;IACH;AACD;AAED;AACO,MAAM,YAAY,GAAG;AAE5B,gBAAgB,CAAC,SAAS,CAAC,IAAI,gBAAgB,EAAE,CAAC;;SCrMlC,sBAAsB,GAAA;IACpC,OAAO;QACL,YAAY,EAAE,IAAI,gBAAgB,EAAE;QACpC,WAAW,EAAE,IAAI,eAAe,EAAE;QAClC,EAAE,EAAE,IAAI,MAAM,EAAE;QAChB,aAAa,EAAE,IAAI,iBAAiB,EAAE;QACtC,SAAS,EAAE,IAAI,aAAa,EAAE;QAC9B,WAAW,EAAE,IAAI,eAAe,EAAE;KACnC;AACH;;"}
|
package/dist/main.cjs
CHANGED
package/dist/main.js
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { A as compareMetadataRowsLatestFirst, d as getLatestPublishedVersionRow, p as parseListPropertyValueFromStorage, I as Item, g as getContentHash, u as waitForEntityIdle } from './index-
|
|
3
|
-
export { B as ADDRESSES_PERSISTED_EVENT, j as ItemProperty, L as LOCAL_COPIES_REMOVED_EVENT, M as Model, C as client,
|
|
4
|
-
import { k as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString, M as ModelPropertyDataTypes, m as getArweaveUrlForTransaction } from './constants-
|
|
5
|
-
export { C as ClientManagerState, o as MachineIds, p as classifyMediaRef, l as getCorrectId, q as getFeedItemStringField, s as normalizeFeedItemFields, u as resolveMediaRef } from './constants-
|
|
6
|
-
export { getPropertySchema } from './property-
|
|
7
|
-
import { a as BaseDb, v as versions, b as metadata, r as seeds,
|
|
8
|
-
export { c as appState, d as arweaveL1FinalizeJobs, f as easSyncProcesses, i as modelSchemas, j as modelUids, m as models, p as properties, o as propertyUids, q as publishProcesses, s as schemas, u as uploadProcesses } from './BasePathResolver-
|
|
2
|
+
import { A as compareMetadataRowsLatestFirst, d as getLatestPublishedVersionRow, p as parseListPropertyValueFromStorage, I as Item, g as getContentHash, u as waitForEntityIdle } from './index-DjwIC6U3.js';
|
|
3
|
+
export { B as ADDRESSES_PERSISTED_EVENT, j as ItemProperty, L as LOCAL_COPIES_REMOVED_EVENT, M as Model, D as claimUnpublishedDrafts, C as client, E as createLocalQueryDataSource, F as createNewItem, G as createSchema, H as easSyncActor, f as eventEmitter, h as generateId, J as getClient, e as getEasSchemaForItemProperty, i as getGetAdditionalSyncAddresses, K as getGetPublisherForNewSeeds, N as getMetadataLatest, O as getPublishedSeedRecord, P as getRevokeExecutor, Q as getSchemaNameFromId, R as getUploadExecutor, S as getVersionData, l as importJsonSchema, U as isItemOwned, V as isLocalUnsealedDraft, W as isSeedQueryLocalSourceRegistered, X as isSeedRowOwned, Y as listSchemas, Z as loadAllSchemasFromDb, _ as mergeEasSyncRequestIntents, $ as ownedPublisherSql, a0 as parseAddressesPersistedPayload, a1 as propertyMachine, a2 as publisherInAddressListSql, a3 as publisherIsInOwnedSet, o as readJsonImportFile, a4 as readSchema, a5 as registerSeedQueryLocalSource, a6 as requestEasSyncFromAddressChange, a7 as requestEasSyncFromEventBus, a8 as requestEasSyncFromModelsInit, a9 as sendEasSyncClientRequest, aa as setAdditionalSyncAddresses, ab as setGetPublisherForNewSeeds, ac as setRevokeExecutor, ad as setUploadExecutor, ae as startEasSyncActor, q as syncSchemaFromSource, t as transformImportToSchemaFile, af as unregisterSeedQueryLocalSource } from './index-DjwIC6U3.js';
|
|
4
|
+
import { k as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString, M as ModelPropertyDataTypes, n as normalizeDataType, m as getArweaveUrlForTransaction } from './constants-CROrIRd-.js';
|
|
5
|
+
export { C as ClientManagerState, o as MachineIds, p as classifyMediaRef, l as getCorrectId, q as getFeedItemStringField, s as normalizeFeedItemFields, u as resolveMediaRef } from './constants-CROrIRd-.js';
|
|
6
|
+
export { getPropertySchema } from './property-Bs3a4Dna.js';
|
|
7
|
+
import { a as BaseDb, v as versions, b as metadata, r as seeds, B as BaseFileManager, h as htmlEmbeddedImageCoPublish } from './BasePathResolver-0IHnXxtL.js';
|
|
8
|
+
export { c as appState, d as arweaveL1FinalizeJobs, f as easSyncProcesses, i as modelSchemas, j as modelUids, m as models, p as properties, o as propertyUids, q as publishProcesses, s as schemas, u as uploadProcesses } from './BasePathResolver-0IHnXxtL.js';
|
|
9
9
|
import { eq, desc, or, and, isNotNull, ne } from 'drizzle-orm';
|
|
10
10
|
import { isPlaceholderUid, isValidEasAttestationUid, normalizeBytes32Hex } from '@seedprotocol/eas';
|
|
11
11
|
export { BaseEasClient as EasClient, getCanonicalItemPropertiesFromEas, getEasSchemaUidBySchemaName, getItemPropertiesFromEas, getItemVersionsFromEas, getSeedsBySchemaName, getSeedsFromSchemaUids, isPlaceholderUid, isValidEasAttestationUid, normalizeBytes32Hex, pickLatestPropertyAttestationsByRefAndSchema, setSchemaUidForModel, setSchemaUidForSchemaDefinition, withExcludeRevokedFilter } from '@seedprotocol/eas';
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
|
|
12
|
+
import { n as normalizePublisher } from './db-DVsy4QZe.js';
|
|
13
|
+
export { h as getAddressesForItemsFilter, i as normalizeAddressConfig, j as normalizeAddressList, b as normalizeHexAddress } from './db-DVsy4QZe.js';
|
|
14
|
+
export { S as Schema, d as deleteModelFromSchema, a as deletePropertyFromModel, r as renameModelProperty, s as schemaMachine, u as updateModelProperties } from './Schema-qciDB7Nu.js';
|
|
15
|
+
import { INTERNAL_PROPERTY_NAMES, ZERO_BYTES32 } from './constants-Bre6dTJR.js';
|
|
16
|
+
export { EAS_SEED_DATA_SYNCED_TO_DB_EVENT, INTERNAL_DATA_TYPES, ImageSize, SEED_PROTOCOL_SCHEMA_NAME, SeedModels, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA } from './constants-Bre6dTJR.js';
|
|
17
|
+
export { ModelProperty } from './ModelProperty-BiDQu5rE.js';
|
|
18
|
+
export { getModelSchemasFromEas } from './eas-z4W41ith.js';
|
|
16
19
|
export { BaseArweaveClient, DEFAULT_ARWEAVE_GATEWAYS, DEFAULT_ARWEAVE_GRAPHQL_URL, DEFAULT_ARWEAVE_HOST, DEFAULT_GATEWAY_SIDECAR_HOST, DEFAULT_GATEWAY_SIDECAR_PORT, DEFAULT_SEED_FEED_HYPER_KEY, DEFAULT_SEED_GATEWAY_HYPER_KEY, SEED_RSS_IMAGE_RELATION_FIELD_KEYS, ensureReadGatewaySelected, getArweaveUploadStatus, getDefaultArweaveReadGatewayHostsOrdered, getReadGatewayHostsForConfig, getResolvedSeedGatewayEndpoints, getUploadApiArweaveDataUrl, getUploadApiArweaveStatusUrl, getUploadPipelineTransactionStatus, invalidateReadGatewayCache, invalidateSidecarProbeCache, isArweaveL1AnchoringComplete, isEasAttestationExplorerUrl, isKnownArweaveGatewayHostname, mergePrimaryHostWithDefaults, normalizeUploadApiBaseUrl, queryArweaveGatewayTransaction, queryArweaveGatewayTransactionWithFallback, resetArweaveReadGatewayForTests, resolveSeedGatewayEndpoints, resolveSeedRssImageRelationFromItem, resolveSeedRssImageRelationRef, seedGatewayConfigFromClientContext, seedGatewayConfigFromSeedConfig, setResolvedSeedGatewayEndpoints } from '@seedprotocol/arweave';
|
|
17
|
-
export { u as updateSeedRevokedAt } from './updateSeedRevokedAt-
|
|
18
|
-
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export { itemHasPublishUploadCandidates } from './getPublishUploads-D-fMspZI.js';
|
|
22
|
-
import { parseFragment, serialize } from 'parse5';
|
|
20
|
+
export { u as updateSeedRevokedAt } from './updateSeedRevokedAt-F0ZDvwOO.js';
|
|
21
|
+
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-BCCSwTxr.js';
|
|
22
|
+
export { PublishValidationFailedError, resolvePublishPayloadValues, validateItemForPublish } from './getPublishPayload-CuRGEZa5.js';
|
|
23
|
+
export { itemHasPublishUploadCandidates } from './getPublishUploads-CMgzBCzZ.js';
|
|
23
24
|
import 'pluralize';
|
|
25
|
+
import { parseFragment, serialize } from 'parse5';
|
|
24
26
|
import 'js-yaml';
|
|
25
27
|
import 'fs';
|
|
26
28
|
import 'xstate';
|
|
@@ -34,7 +36,7 @@ import 'js-sha3';
|
|
|
34
36
|
import '@seedprotocol/query';
|
|
35
37
|
import '@sinclair/typebox';
|
|
36
38
|
import 'drizzle-orm/sqlite-core';
|
|
37
|
-
import './SchemaValidationService-
|
|
39
|
+
import './SchemaValidationService-BaOkRjsU.js';
|
|
38
40
|
import '@sinclair/typebox/value';
|
|
39
41
|
import '@ethereum-attestation-service/eas-sdk';
|
|
40
42
|
|
|
@@ -58,7 +60,8 @@ const updateVersionUid = async ({ seedLocalId, versionUid, publisher, attestatio
|
|
|
58
60
|
const toUpdate = rows.find((r) => r.localId && isPlaceholderUid(r.uid));
|
|
59
61
|
if (!toUpdate?.localId)
|
|
60
62
|
return;
|
|
61
|
-
|
|
63
|
+
const normalizedPublisher = normalizePublisher(publisher);
|
|
64
|
+
let shouldSetPublisher = normalizedPublisher != null;
|
|
62
65
|
if (shouldSetPublisher && toUpdate.publisher != null && toUpdate.publisher !== '') {
|
|
63
66
|
shouldSetPublisher = false;
|
|
64
67
|
}
|
|
@@ -66,7 +69,7 @@ const updateVersionUid = async ({ seedLocalId, versionUid, publisher, attestatio
|
|
|
66
69
|
.update(versions)
|
|
67
70
|
.set({
|
|
68
71
|
uid: versionUid,
|
|
69
|
-
...(shouldSetPublisher && { publisher }),
|
|
72
|
+
...(shouldSetPublisher && { publisher: normalizedPublisher }),
|
|
70
73
|
...(attestationCreatedAt != null && { attestationCreatedAt }),
|
|
71
74
|
updatedAt: Date.now(),
|
|
72
75
|
})
|
|
@@ -432,7 +435,7 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
|
|
|
432
435
|
visited.add(seedLocalId);
|
|
433
436
|
const result = [];
|
|
434
437
|
const { itemRelationProperties, itemImageProperties, itemListProperties } = await getSegmentedItemProperties(item);
|
|
435
|
-
const getItemMod = await import('./getItem-
|
|
438
|
+
const getItemMod = await import('./getItem-BiE_b7Fu.js');
|
|
436
439
|
const { getItem } = getItemMod;
|
|
437
440
|
const processRelationOrImage = async (prop) => {
|
|
438
441
|
const snapshot = prop.getService().getSnapshot();
|
|
@@ -453,8 +456,8 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
|
|
|
453
456
|
if (!value && prop.propertyName && isStorageSeed) {
|
|
454
457
|
const ctx = context;
|
|
455
458
|
if (ctx.seedLocalId || ctx.seedUid) {
|
|
456
|
-
const _mod_0 = await import('./index-
|
|
457
|
-
const _ns_0 = _mod_0.
|
|
459
|
+
const _mod_0 = await import('./index-DjwIC6U3.js');
|
|
460
|
+
const _ns_0 = _mod_0.ap;
|
|
458
461
|
const { getPropertyData } = _ns_0;
|
|
459
462
|
const meta = await getPropertyData({
|
|
460
463
|
propertyName: prop.propertyName,
|
|
@@ -512,6 +515,279 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
|
|
|
512
515
|
return result;
|
|
513
516
|
}
|
|
514
517
|
|
|
518
|
+
/**
|
|
519
|
+
* Counts seeds, property attestations, and Arweave upload bytes for a publish
|
|
520
|
+
* without building transactions or requiring a valid payload.
|
|
521
|
+
*/
|
|
522
|
+
const DATA_URI = /^data:[^;]+;base64,([\s\S]*)$/i;
|
|
523
|
+
const matchesDataType = (actual, expected) => normalizeDataType(actual) === expected;
|
|
524
|
+
function isZeroUid(uid) {
|
|
525
|
+
return !uid || uid === ZERO_BYTES32;
|
|
526
|
+
}
|
|
527
|
+
function isStorageTransactionPropertyName(name) {
|
|
528
|
+
return name === 'storageTransactionId' || name === 'storage_transaction_id';
|
|
529
|
+
}
|
|
530
|
+
/** Decoded byte length of a data-URI, or null if the string is not a base64 data URI. */
|
|
531
|
+
function estimateDataUriByteLength(dataUri) {
|
|
532
|
+
const m = DATA_URI.exec((dataUri ?? '').trim());
|
|
533
|
+
if (!m)
|
|
534
|
+
return null;
|
|
535
|
+
const b64 = m[1].replace(/\s/g, '');
|
|
536
|
+
if (!b64)
|
|
537
|
+
return 0;
|
|
538
|
+
const padding = b64.endsWith('==') ? 2 : b64.endsWith('=') ? 1 : 0;
|
|
539
|
+
return Math.max(0, Math.floor((b64.length * 3) / 4) - padding);
|
|
540
|
+
}
|
|
541
|
+
function propertyContext(prop) {
|
|
542
|
+
const snapshot = prop.getService().getSnapshot();
|
|
543
|
+
return snapshot && 'context' in snapshot
|
|
544
|
+
? (snapshot.context ?? null)
|
|
545
|
+
: null;
|
|
546
|
+
}
|
|
547
|
+
function getPublishValue(prop, context) {
|
|
548
|
+
const propertyDef = prop.propertyDef ?? context.propertyRecordSchema;
|
|
549
|
+
const isFileImageHtml = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.File) ||
|
|
550
|
+
matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Image) ||
|
|
551
|
+
matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Html);
|
|
552
|
+
const isJsonStorage = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Json) ||
|
|
553
|
+
matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Json);
|
|
554
|
+
const isRelation = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Relation);
|
|
555
|
+
const isStorageTransactionIdProp = isStorageTransactionPropertyName(prop.propertyName);
|
|
556
|
+
const preferPropertyValue = isFileImageHtml || isRelation || isJsonStorage || isStorageTransactionIdProp;
|
|
557
|
+
let value = preferPropertyValue
|
|
558
|
+
? context.propertyValue
|
|
559
|
+
: (prop.value ?? context.propertyValue);
|
|
560
|
+
if (isRelation || isFileImageHtml || isJsonStorage) {
|
|
561
|
+
const pv = context.propertyValue;
|
|
562
|
+
if (typeof value === 'object' || value == null) {
|
|
563
|
+
if (typeof pv === 'string' && pv.trim())
|
|
564
|
+
value = pv.trim();
|
|
565
|
+
else if (pv && typeof pv === 'object' && typeof pv.seedLocalId === 'string') {
|
|
566
|
+
value = pv.seedLocalId;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return value;
|
|
571
|
+
}
|
|
572
|
+
function shouldAttestProperty(prop, forceFullSnapshot) {
|
|
573
|
+
if (INTERNAL_PROPERTY_NAMES.includes(prop.propertyName))
|
|
574
|
+
return false;
|
|
575
|
+
const context = propertyContext(prop);
|
|
576
|
+
if (!context)
|
|
577
|
+
return false;
|
|
578
|
+
const value = getPublishValue(prop, context);
|
|
579
|
+
if (value == null || value === '')
|
|
580
|
+
return false;
|
|
581
|
+
if (prop.uid && !forceFullSnapshot) {
|
|
582
|
+
const allowStorageTx = isStorageTransactionPropertyName(prop.propertyName) &&
|
|
583
|
+
typeof value === 'string' &&
|
|
584
|
+
value.trim() !== '';
|
|
585
|
+
if (!allowStorageTx)
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
function getStorageDirForDataType(dataType) {
|
|
591
|
+
switch (dataType) {
|
|
592
|
+
case 'Image':
|
|
593
|
+
return BaseFileManager.getFilesPath('images');
|
|
594
|
+
case 'File':
|
|
595
|
+
return BaseFileManager.getFilesPath('files');
|
|
596
|
+
case 'Html':
|
|
597
|
+
return BaseFileManager.getFilesPath('html');
|
|
598
|
+
case 'Json':
|
|
599
|
+
return BaseFileManager.getFilesPath('json');
|
|
600
|
+
default:
|
|
601
|
+
return BaseFileManager.getFilesPath('images');
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
async function addUpload(acc, seen, key, bytes) {
|
|
605
|
+
if (bytes <= 0 || seen.has(key))
|
|
606
|
+
return;
|
|
607
|
+
seen.add(key);
|
|
608
|
+
acc.uploadCount += 1;
|
|
609
|
+
acc.uploadBytes += bytes;
|
|
610
|
+
}
|
|
611
|
+
async function addUploadFromPath(acc, seen, filePath, key) {
|
|
612
|
+
if (!filePath || filePath.endsWith('undefined'))
|
|
613
|
+
return;
|
|
614
|
+
const size = await BaseFileManager.getFileSize(filePath);
|
|
615
|
+
if (size == null || size <= 0)
|
|
616
|
+
return;
|
|
617
|
+
await addUpload(acc, seen, key, size);
|
|
618
|
+
}
|
|
619
|
+
async function collectUploadBytes(item, itemUploadProperties, itemImageProperties, relatedItemProperty, acc, seen) {
|
|
620
|
+
for (const uploadProperty of itemUploadProperties) {
|
|
621
|
+
let childBytes = 0;
|
|
622
|
+
let childCount = 0;
|
|
623
|
+
for (const childProperty of uploadProperty.childProperties) {
|
|
624
|
+
const filePath = childProperty.localStoragePath;
|
|
625
|
+
if (!filePath || filePath.endsWith('undefined'))
|
|
626
|
+
continue;
|
|
627
|
+
const size = await BaseFileManager.getFileSize(filePath);
|
|
628
|
+
if (size == null || size <= 0)
|
|
629
|
+
continue;
|
|
630
|
+
childBytes += size;
|
|
631
|
+
childCount += 1;
|
|
632
|
+
}
|
|
633
|
+
if (childCount > 0) {
|
|
634
|
+
await addUpload(acc, seen, `upload:${item.seedLocalId}:${uploadProperty.itemProperty.localId}`, childBytes);
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
for (const itemProperty of itemImageProperties) {
|
|
639
|
+
const context = propertyContext(itemProperty);
|
|
640
|
+
if (!context)
|
|
641
|
+
continue;
|
|
642
|
+
const refResolvedValue = (typeof context.refResolvedValue === 'string' && context.refResolvedValue) ||
|
|
643
|
+
itemProperty.refResolvedValue;
|
|
644
|
+
if (typeof refResolvedValue !== 'string' || !refResolvedValue)
|
|
645
|
+
continue;
|
|
646
|
+
const propertyValue = context.propertyValue;
|
|
647
|
+
const { seedLocalId } = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(propertyValue) ?? '');
|
|
648
|
+
const dataType = itemProperty.propertyDef?.refValueType ??
|
|
649
|
+
itemProperty.propertyDef?.dataType ??
|
|
650
|
+
'Image';
|
|
651
|
+
const fromGetter = itemProperty.localStoragePath;
|
|
652
|
+
const filePath = typeof fromGetter === 'string' && fromGetter
|
|
653
|
+
? fromGetter
|
|
654
|
+
: `${getStorageDirForDataType(String(dataType))}/${refResolvedValue}`;
|
|
655
|
+
await addUploadFromPath(acc, seen, filePath, seedLocalId ? `seed:${seedLocalId}` : `path:${filePath}`);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
async function loadRelatedItem(value) {
|
|
659
|
+
const normalized = normalizeRelationPropertyValue(value);
|
|
660
|
+
if (!normalized)
|
|
661
|
+
return undefined;
|
|
662
|
+
const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalized);
|
|
663
|
+
if (!seedLocalId && !seedUid)
|
|
664
|
+
return undefined;
|
|
665
|
+
const { getItem } = await import('./getItem-BiE_b7Fu.js');
|
|
666
|
+
try {
|
|
667
|
+
return await getItem({ seedLocalId, seedUid });
|
|
668
|
+
}
|
|
669
|
+
catch {
|
|
670
|
+
return undefined;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
async function relatedIfUnpublished(prop) {
|
|
674
|
+
const context = propertyContext(prop);
|
|
675
|
+
if (!context)
|
|
676
|
+
return undefined;
|
|
677
|
+
const related = await loadRelatedItem(context.propertyValue);
|
|
678
|
+
if (!related || !isZeroUid(related.seedUid))
|
|
679
|
+
return undefined;
|
|
680
|
+
return related;
|
|
681
|
+
}
|
|
682
|
+
async function unpublishedListItems(listProperty) {
|
|
683
|
+
const context = propertyContext(listProperty);
|
|
684
|
+
if (!context)
|
|
685
|
+
return [];
|
|
686
|
+
let value = context.propertyValue;
|
|
687
|
+
if (!value)
|
|
688
|
+
return [];
|
|
689
|
+
if (typeof value === 'string') {
|
|
690
|
+
value = parseListPropertyValueFromStorage(value);
|
|
691
|
+
}
|
|
692
|
+
const arr = Array.isArray(value) ? value : [];
|
|
693
|
+
const out = [];
|
|
694
|
+
for (const seedId of arr) {
|
|
695
|
+
const related = await loadRelatedItem(seedId);
|
|
696
|
+
if (related && isZeroUid(related.seedUid))
|
|
697
|
+
out.push(related);
|
|
698
|
+
}
|
|
699
|
+
return out;
|
|
700
|
+
}
|
|
701
|
+
async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot, publishMode) {
|
|
702
|
+
const appDb = BaseDb.getAppDb();
|
|
703
|
+
if (!appDb)
|
|
704
|
+
return;
|
|
705
|
+
const rows = await appDb
|
|
706
|
+
.select()
|
|
707
|
+
.from(htmlEmbeddedImageCoPublish)
|
|
708
|
+
.where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId));
|
|
709
|
+
for (const row of rows) {
|
|
710
|
+
const _mod_1 = await import('./index-DjwIC6U3.js');
|
|
711
|
+
const _ns_1 = _mod_1.aq;
|
|
712
|
+
const { Item } = _ns_1;
|
|
713
|
+
const imageItem = await Item.find({
|
|
714
|
+
seedLocalId: row.imageSeedLocalId,
|
|
715
|
+
modelName: 'Image',
|
|
716
|
+
});
|
|
717
|
+
if (!imageItem)
|
|
718
|
+
continue;
|
|
719
|
+
const st = imageItem.internalProperties['storageTransactionId'] ??
|
|
720
|
+
imageItem.allProperties['storageTransactionId'];
|
|
721
|
+
const stCtx = st ? propertyContext(st) : null;
|
|
722
|
+
const stValue = typeof stCtx?.propertyValue === 'string' ? stCtx.propertyValue : '';
|
|
723
|
+
const dataUriBytes = estimateDataUriByteLength(stValue);
|
|
724
|
+
if (dataUriBytes != null && dataUriBytes > 0) {
|
|
725
|
+
await addUpload(acc, seen, `seed:${imageItem.seedLocalId}`, dataUriBytes);
|
|
726
|
+
}
|
|
727
|
+
await summarizeItem(imageItem, publishMode, forceFullSnapshot, acc, seen, visited);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUploads, visited) {
|
|
731
|
+
const seedLocalId = item.seedLocalId;
|
|
732
|
+
if (!seedLocalId || visited.has(seedLocalId))
|
|
733
|
+
return;
|
|
734
|
+
visited.add(seedLocalId);
|
|
735
|
+
acc.seedCount += 1;
|
|
736
|
+
if (isZeroUid(item.seedUid))
|
|
737
|
+
acc.newSeedCount += 1;
|
|
738
|
+
if (isZeroUid(item.seedUid) || forceFullSnapshot)
|
|
739
|
+
acc.newVersionCount += 1;
|
|
740
|
+
const { itemBasicProperties, itemRelationProperties, itemListProperties, itemUploadProperties, itemImageProperties, } = await getSegmentedItemProperties(item);
|
|
741
|
+
await collectUploadBytes(item, itemUploadProperties, itemImageProperties, undefined, acc, seenUploads);
|
|
742
|
+
for (const rel of itemRelationProperties) {
|
|
743
|
+
const related = await relatedIfUnpublished(rel);
|
|
744
|
+
if (related) {
|
|
745
|
+
await summarizeItem(related, publishMode, forceFullSnapshot, acc, seenUploads, visited);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
for (const listProperty of itemListProperties) {
|
|
749
|
+
for (const related of await unpublishedListItems(listProperty)) {
|
|
750
|
+
await summarizeItem(related, publishMode, forceFullSnapshot, acc, seenUploads, visited);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
await appendCoPublishImages(item, acc, seenUploads, visited, forceFullSnapshot, publishMode);
|
|
754
|
+
const attestable = [
|
|
755
|
+
...itemBasicProperties,
|
|
756
|
+
...itemRelationProperties,
|
|
757
|
+
...itemListProperties,
|
|
758
|
+
...itemImageProperties,
|
|
759
|
+
...itemUploadProperties.map((u) => u.itemProperty),
|
|
760
|
+
];
|
|
761
|
+
const seenProps = new Set();
|
|
762
|
+
for (const prop of attestable) {
|
|
763
|
+
const key = prop.localId || `${prop.propertyName}:${prop.seedLocalId}`;
|
|
764
|
+
if (seenProps.has(key))
|
|
765
|
+
continue;
|
|
766
|
+
seenProps.add(key);
|
|
767
|
+
if (shouldAttestProperty(prop, forceFullSnapshot))
|
|
768
|
+
acc.attestationCount += 1;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Local measurement of what a publish would do: seed/version/attestation counts
|
|
773
|
+
* and Arweave upload byte totals. Does not hit the network or create transactions.
|
|
774
|
+
*/
|
|
775
|
+
const summarizePublishWork = async (item, options) => {
|
|
776
|
+
const publishMode = options?.publishMode ?? 'patch';
|
|
777
|
+
const forceFullSnapshot = publishMode === 'new_version';
|
|
778
|
+
const acc = {
|
|
779
|
+
publishMode,
|
|
780
|
+
seedCount: 0,
|
|
781
|
+
newSeedCount: 0,
|
|
782
|
+
newVersionCount: 0,
|
|
783
|
+
attestationCount: 0,
|
|
784
|
+
uploadCount: 0,
|
|
785
|
+
uploadBytes: 0,
|
|
786
|
+
};
|
|
787
|
+
await summarizeItem(item, publishMode, forceFullSnapshot, acc, new Set(), new Set());
|
|
788
|
+
return acc;
|
|
789
|
+
};
|
|
790
|
+
|
|
515
791
|
const HTML_EMBEDDED_MAX_IMAGES_PER_DOC = 50;
|
|
516
792
|
const HTML_EMBEDDED_MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
517
793
|
const HTML_EMBEDDED_MAX_TOTAL_BYTES = 25 * 1024 * 1024;
|
|
@@ -840,5 +1116,5 @@ async function clearHtmlEmbeddedImageCoPublishRows(parentSeedLocalId) {
|
|
|
840
1116
|
.where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentSeedLocalId.trim()));
|
|
841
1117
|
}
|
|
842
1118
|
|
|
843
|
-
export { BaseDb, BaseFileManager, BaseFileManager as FileManager, HTML_EMBEDDED_MAX_IMAGES_PER_DOC, HTML_EMBEDDED_MAX_IMAGE_BYTES, HTML_EMBEDDED_MAX_TOTAL_BYTES, HtmlEmbeddedDataUriLimitError, Item, ModelPropertyDataTypes, applyArweaveL1TransactionIdLocal, applyPropertyAttestationUidsFromPublish, clearHtmlEmbeddedImageCoPublishRows, extractDataUriImagesFromHtml, getArweaveUrlForTransaction, getAttesterForSeed, getMetadataAttestationUidsForSeedUid, getPublishPendingDiff, getRelatedItemsForPublish, getSeedPublishState, getSegmentedItemProperties, getVersionsForSeedUid, htmlEmbeddedImageCoPublish, metadata, prepareHtmlEmbeddedImagesForPublish, replaceDataUrisInParsedHtml, resolveEffectiveHtmlEmbeddedDataUriPolicy, rewriteHtmlEmbeddedImagesOnDisk, seeds, updateVersionUid, versions, waitForEntityIdle };
|
|
1119
|
+
export { BaseDb, BaseFileManager, BaseFileManager as FileManager, HTML_EMBEDDED_MAX_IMAGES_PER_DOC, HTML_EMBEDDED_MAX_IMAGE_BYTES, HTML_EMBEDDED_MAX_TOTAL_BYTES, HtmlEmbeddedDataUriLimitError, Item, ModelPropertyDataTypes, applyArweaveL1TransactionIdLocal, applyPropertyAttestationUidsFromPublish, clearHtmlEmbeddedImageCoPublishRows, estimateDataUriByteLength, extractDataUriImagesFromHtml, getArweaveUrlForTransaction, getAttesterForSeed, getMetadataAttestationUidsForSeedUid, getPublishPendingDiff, getRelatedItemsForPublish, getSeedPublishState, getSegmentedItemProperties, getVersionsForSeedUid, htmlEmbeddedImageCoPublish, metadata, normalizePublisher, prepareHtmlEmbeddedImagesForPublish, replaceDataUrisInParsedHtml, resolveEffectiveHtmlEmbeddedDataUriPolicy, rewriteHtmlEmbeddedImagesOnDisk, seeds, shouldAttestProperty, summarizePublishWork, updateVersionUid, versions, waitForEntityIdle };
|
|
844
1120
|
//# sourceMappingURL=main.js.map
|